1 /* @(#) pf_save.c 98/01/26 1.3 */
2 /***************************************************************
3 ** Save and Load Dictionary
4 ** for PForth based on 'C'
6 ** Compile file based version or static data based version
7 ** depending on PF_NO_FILEIO switch.
10 ** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom
12 ** The pForth software code is dedicated to the public domain,
13 ** and any third party may reproduce, distribute and modify
14 ** the pForth software code or any derivative works thereof
15 ** without any compensation or license. The pForth software
16 ** code is provided on an "as is" basis without any warranty
17 ** of any kind, including, without limitation, the implied
18 ** warranties of merchantability and fitness for a particular
19 ** purpose and their equivalents under the laws of any jurisdiction.
21 ****************************************************************
22 ** 940225 PLB Fixed CodePtr save, was using NAMEREL instead of CODEREL
23 ** This would only work if the relative location
24 ** of names and code was the same when saved and reloaded.
25 ** 940228 PLB Added PF_NO_FILEIO version
26 ** 961204 PLB Added PF_STATIC_DIC
27 ** 000623 PLB Cast chars as ucell_t before shifting for 16 bit systems.
28 ***************************************************************/
34 /* If no File I/O, then force static dictionary. */
46 Dictionary File Format based on IFF standard.
47 The chunk IDs, sizes, and data values are all Big Endian in conformance with the IFF standard.
48 The dictionaries may be big or little endian.
51 'P4TH' - Form Identifier
56 struct DictionaryInfoChunk
60 Name and Header portion of dictionary. (Big or Little Endian) (Optional)
64 Code portion of dictionary. (Big or Little Endian)
68 /***************************************************************/
69 /* Endian-ness tools. */
70 ucell_t ReadCellBigEndian( const uint8_t *addr )
72 ucell_t temp = (ucell_t)addr[0];
73 temp = (temp << 8) | ((ucell_t)addr[1]);
74 temp = (temp << 8) | ((ucell_t)addr[2]);
75 temp = (temp << 8) | ((ucell_t)addr[3]);
76 if( sizeof(ucell_t) == 8 )
78 temp = (temp << 8) | ((ucell_t)addr[4]);
79 temp = (temp << 8) | ((ucell_t)addr[5]);
80 temp = (temp << 8) | ((ucell_t)addr[6]);
81 temp = (temp << 8) | ((ucell_t)addr[7]);
86 /***************************************************************/
87 /* Endian-ness tools. */
88 uint32_t Read32BigEndian( const uint8_t *addr )
90 uint32_t temp = (uint32_t)addr[0];
91 temp = (temp << 8) | ((uint32_t)addr[1]);
92 temp = (temp << 8) | ((uint32_t)addr[2]);
93 temp = (temp << 8) | ((uint32_t)addr[3]);
97 /***************************************************************/
98 uint16_t Read16BigEndian( const uint8_t *addr )
100 return (uint16_t) ((addr[0]<<8) | addr[1]);
103 /***************************************************************/
104 ucell_t ReadCellLittleEndian( const uint8_t *addr )
107 if( sizeof(ucell_t) == 8 )
109 temp = (temp << 8) | ((uint32_t)addr[7]);
110 temp = (temp << 8) | ((uint32_t)addr[6]);
111 temp = (temp << 8) | ((uint32_t)addr[5]);
112 temp = (temp << 8) | ((uint32_t)addr[4]);
114 temp = (temp << 8) | ((uint32_t)addr[3]);
115 temp = (temp << 8) | ((uint32_t)addr[2]);
116 temp = (temp << 8) | ((uint32_t)addr[1]);
117 temp = (temp << 8) | ((uint32_t)addr[0]);
121 /***************************************************************/
122 uint32_t Read32LittleEndian( const uint8_t *addr )
124 uint32_t temp = (uint32_t)addr[3];
125 temp = (temp << 8) | ((uint32_t)addr[2]);
126 temp = (temp << 8) | ((uint32_t)addr[1]);
127 temp = (temp << 8) | ((uint32_t)addr[0]);
131 /***************************************************************/
132 uint16_t Read16LittleEndian( const uint8_t *addr )
134 const unsigned char *bp = (const unsigned char *) addr;
135 return (uint16_t) ((bp[1]<<8) | bp[0]);
140 /***************************************************************/
141 static void ReverseCopyFloat( const PF_FLOAT *src, PF_FLOAT *dst );
143 static void ReverseCopyFloat( const PF_FLOAT *src, PF_FLOAT *dst )
146 unsigned char *d = (unsigned char *) dst;
147 const unsigned char *s = (const unsigned char *) src;
149 for( i=0; i<sizeof(PF_FLOAT); i++ )
151 d[i] = s[sizeof(PF_FLOAT) - 1 - i];
155 /***************************************************************/
156 void WriteFloatBigEndian( PF_FLOAT *addr, PF_FLOAT data )
158 if( IsHostLittleEndian() )
160 ReverseCopyFloat( &data, addr );
168 /***************************************************************/
169 PF_FLOAT ReadFloatBigEndian( const PF_FLOAT *addr )
172 if( IsHostLittleEndian() )
174 ReverseCopyFloat( addr, &data );
183 /***************************************************************/
184 void WriteFloatLittleEndian( PF_FLOAT *addr, PF_FLOAT data )
186 if( IsHostLittleEndian() )
192 ReverseCopyFloat( &data, addr );
196 /***************************************************************/
197 PF_FLOAT ReadFloatLittleEndian( const PF_FLOAT *addr )
200 if( IsHostLittleEndian() )
206 ReverseCopyFloat( addr, &data );
211 #endif /* PF_SUPPORT_FP */
213 /***************************************************************/
214 void WriteCellBigEndian( uint8_t *addr, ucell_t data )
216 /* Write should be in order of increasing address
217 * to optimize for burst writes to DRAM. */
218 if( sizeof(ucell_t) == 8 )
220 *addr++ = (uint8_t) (data>>56);
221 *addr++ = (uint8_t) (data>>48);
222 *addr++ = (uint8_t) (data>>40);
223 *addr++ = (uint8_t) (data>>32);
225 *addr++ = (uint8_t) (data>>24);
226 *addr++ = (uint8_t) (data>>16);
227 *addr++ = (uint8_t) (data>>8);
228 *addr = (uint8_t) (data);
231 /***************************************************************/
232 void Write32BigEndian( uint8_t *addr, uint32_t data )
234 *addr++ = (uint8_t) (data>>24);
235 *addr++ = (uint8_t) (data>>16);
236 *addr++ = (uint8_t) (data>>8);
237 *addr = (uint8_t) (data);
240 /***************************************************************/
241 void Write16BigEndian( uint8_t *addr, uint16_t data )
243 *addr++ = (uint8_t) (data>>8);
244 *addr = (uint8_t) (data);
247 /***************************************************************/
248 void WriteCellLittleEndian( uint8_t *addr, ucell_t data )
250 /* Write should be in order of increasing address
251 * to optimize for burst writes to DRAM. */
252 if( sizeof(ucell_t) == 8 )
254 *addr++ = (uint8_t) data; /* LSB at near end */
256 *addr++ = (uint8_t) data;
258 *addr++ = (uint8_t) data;
260 *addr++ = (uint8_t) data;
263 *addr++ = (uint8_t) data;
265 *addr++ = (uint8_t) data;
267 *addr++ = (uint8_t) data;
269 *addr = (uint8_t) data;
271 /***************************************************************/
272 void Write32LittleEndian( uint8_t *addr, uint32_t data )
274 *addr++ = (uint8_t) data;
276 *addr++ = (uint8_t) data;
278 *addr++ = (uint8_t) data;
280 *addr = (uint8_t) data;
283 /***************************************************************/
284 void Write16LittleEndian( uint8_t *addr, uint16_t data )
286 *addr++ = (uint8_t) data;
288 *addr = (uint8_t) data;
291 /***************************************************************/
292 /* Return 1 if host CPU is Little Endian */
293 int IsHostLittleEndian( void )
295 static int gEndianCheck = 1;
296 unsigned char *bp = (unsigned char *) &gEndianCheck;
297 return (int) (*bp); /* Return byte pointed to by address. If LSB then == 1 */
300 #if defined(PF_NO_FILEIO) || defined(PF_NO_SHELL)
302 cell_t ffSaveForth( const char *FileName, ExecToken EntryPoint, cell_t NameSize, cell_t CodeSize)
309 pfReportError("ffSaveForth", PF_ERR_NOT_SUPPORTED);
313 #else /* PF_NO_FILEIO or PF_NO_SHELL */
315 /***************************************************************/
316 static int Write32ToFile( FileStream *fid, uint32_t Val )
321 Write32BigEndian(pad,Val);
322 numw = sdWriteFile( pad, 1, sizeof(pad), fid );
323 if( numw != sizeof(pad) ) return -1;
327 /***************************************************************/
328 static cell_t WriteChunkToFile( FileStream *fid, cell_t ID, char *Data, int32_t NumBytes )
333 EvenNumW = EVENUP(NumBytes);
335 if( Write32ToFile( fid, ID ) < 0 ) goto error;
336 if( Write32ToFile( fid, EvenNumW ) < 0 ) goto error;
338 numw = sdWriteFile( Data, 1, EvenNumW, fid );
339 if( numw != EvenNumW ) goto error;
342 pfReportError("WriteChunkToFile", PF_ERR_WRITE_FILE);
346 /* Convert dictionary info chunk between native and on-disk (big-endian). */
348 convertDictionaryInfoWrite (DictionaryInfoChunk *sd)
350 /* Convert all fields in DictionaryInfoChunk from Native to BigEndian.
351 * This assumes they are all 32-bit integers.
354 uint32_t *p = (uint32_t *) sd;
355 for (i=0; i<((int)(sizeof(*sd)/sizeof(uint32_t))); i++)
357 Write32BigEndian( (uint8_t *)&p[i], p[i] );
362 convertDictionaryInfoRead (DictionaryInfoChunk *sd)
364 /* Convert all fields in structure from BigEndian to Native. */
366 uint32_t *p = (uint32_t *) sd;
367 for (i=0; i<((int)(sizeof(*sd)/sizeof(uint32_t))); i++)
369 p[i] = Read32BigEndian( (uint8_t *)&p[i] );
373 /****************************************************************
374 ** Save Dictionary in File.
375 ** If EntryPoint is NULL, save as development environment.
376 ** If EntryPoint is non-NULL, save as turnKey environment with no names.
378 cell_t ffSaveForth( const char *FileName, ExecToken EntryPoint, cell_t NameSize, cell_t CodeSize)
381 DictionaryInfoChunk SD;
383 uint32_t NameChunkSize = 0;
384 uint32_t CodeChunkSize;
385 uint32_t relativeCodePtr;
387 fid = sdOpenFile( FileName, "wb" );
390 pfReportError("pfSaveDictionary", PF_ERR_OPEN_FILE);
394 /* Save in uninitialized form. */
395 pfExecIfDefined("AUTO.TERM");
397 /* Write FORM Header ---------------------------- */
398 if( Write32ToFile( fid, ID_FORM ) < 0 ) goto error;
399 if( Write32ToFile( fid, 0 ) < 0 ) goto error;
400 if( Write32ToFile( fid, ID_P4TH ) < 0 ) goto error;
402 /* Write P4DI Dictionary Info ------------------ */
403 SD.sd_Version = PF_FILE_VERSION;
405 relativeCodePtr = ABS_TO_CODEREL(gCurrentDictionary->dic_CodePtr.Byte); /* 940225 */
406 SD.sd_RelCodePtr = relativeCodePtr;
407 SD.sd_UserStackSize = sizeof(cell_t) * (gCurrentTask->td_StackBase - gCurrentTask->td_StackLimit);
408 SD.sd_ReturnStackSize = sizeof(cell_t) * (gCurrentTask->td_ReturnBase - gCurrentTask->td_ReturnLimit);
409 SD.sd_NumPrimitives = gNumPrimitives; /* Must match compiled dictionary. */
412 SD.sd_FloatSize = sizeof(PF_FLOAT); /* Must match compiled dictionary. */
417 SD.sd_CellSize = sizeof(cell_t);
419 /* Set bit that specifies whether dictionary is BIG or LITTLE Endian. */
421 #if defined(PF_BIG_ENDIAN_DIC)
422 int eflag = SD_F_BIG_ENDIAN_DIC;
423 #elif defined(PF_LITTLE_ENDIAN_DIC)
426 int eflag = IsHostLittleEndian() ? 0 : SD_F_BIG_ENDIAN_DIC;
433 SD.sd_EntryPoint = EntryPoint; /* Turnkey! */
437 SD.sd_EntryPoint = 0;
440 /* Do we save names? */
443 SD.sd_RelContext = 0;
444 SD.sd_RelHeaderPtr = 0;
449 uint32_t relativeHeaderPtr;
450 /* Development mode. */
451 SD.sd_RelContext = ABS_TO_NAMEREL(gVarContext);
452 relativeHeaderPtr = ABS_TO_NAMEREL(gCurrentDictionary->dic_HeaderPtr);
453 SD.sd_RelHeaderPtr = relativeHeaderPtr;
455 /* How much real name space is there? */
456 NameChunkSize = QUADUP(relativeHeaderPtr); /* Align */
458 /* NameSize must be 0 or greater than NameChunkSize + 1K */
459 NameSize = QUADUP(NameSize); /* Align */
462 NameSize = MAX( (ucell_t)NameSize, (NameChunkSize + 1024) );
464 SD.sd_NameSize = NameSize;
467 /* How much real code is there? */
468 CodeChunkSize = QUADUP(relativeCodePtr);
469 CodeSize = QUADUP(CodeSize); /* Align */
470 CodeSize = MAX( (ucell_t)CodeSize, (CodeChunkSize + 2048) );
471 SD.sd_CodeSize = CodeSize;
474 convertDictionaryInfoWrite (&SD);
476 if( WriteChunkToFile( fid, ID_P4DI, (char *) &SD, sizeof(DictionaryInfoChunk) ) < 0 ) goto error;
478 /* Write Name Fields if NameSize non-zero ------- */
481 if( WriteChunkToFile( fid, ID_P4NM, (char *) NAME_BASE,
482 NameChunkSize ) < 0 ) goto error;
485 /* Write Code Fields ---------------------------- */
486 if( WriteChunkToFile( fid, ID_P4CD, (char *) CODE_BASE,
487 CodeChunkSize ) < 0 ) goto error;
489 FormSize = (uint32_t) sdTellFile( fid ) - 8;
490 sdSeekFile( fid, 4, PF_SEEK_SET );
491 if( Write32ToFile( fid, FormSize ) < 0 ) goto error;
495 /* Restore initialization. */
496 pfExecIfDefined("AUTO.INIT");
500 sdSeekFile( fid, 0, PF_SEEK_SET );
501 Write32ToFile( fid, ID_BADF ); /* Mark file as bad. */
504 /* Restore initialization. */
505 pfExecIfDefined("AUTO.INIT");
510 #endif /* !PF_NO_FILEIO and !PF_NO_SHELL */
515 /***************************************************************/
516 static int32_t Read32FromFile( FileStream *fid, uint32_t *ValPtr )
520 numr = sdReadFile( pad, 1, sizeof(pad), fid );
521 if( numr != sizeof(pad) ) return -1;
522 *ValPtr = Read32BigEndian( pad );
526 /***************************************************************/
527 PForthDictionary pfLoadDictionary( const char *FileName, ExecToken *EntryPointPtr )
529 pfDictionary_t *dic = NULL;
531 DictionaryInfoChunk *sd;
539 DBUG(("pfLoadDictionary( %s )\n", FileName ));
542 fid = sdOpenFile( FileName, "rb" );
545 pfReportError("pfLoadDictionary", PF_ERR_OPEN_FILE);
549 /* Read FORM, Size, ID */
550 if (Read32FromFile( fid, &ChunkID ) < 0) goto read_error;
551 if( ChunkID != ID_FORM )
553 pfReportError("pfLoadDictionary", PF_ERR_WRONG_FILE);
557 if (Read32FromFile( fid, &FormSize ) < 0) goto read_error;
558 BytesLeft = FormSize;
560 if (Read32FromFile( fid, &ChunkID ) < 0) goto read_error;
562 if( ChunkID != ID_P4TH )
564 pfReportError("pfLoadDictionary", PF_ERR_BAD_FILE);
568 /* Scan and parse all chunks in file. */
569 while( BytesLeft > 0 )
571 if (Read32FromFile( fid, &ChunkID ) < 0) goto read_error;
572 if (Read32FromFile( fid, &ChunkSize ) < 0) goto read_error;
575 DBUG(("ChunkID = %4s, Size = %d\n", (char *)&ChunkID, ChunkSize ));
580 sd = (DictionaryInfoChunk *) pfAllocMem( ChunkSize );
581 if( sd == NULL ) goto nomem_error;
583 numr = sdReadFile( sd, 1, ChunkSize, fid );
584 if( numr != ChunkSize ) goto read_error;
585 BytesLeft -= ChunkSize;
587 convertDictionaryInfoRead (sd);
589 isDicBigEndian = sd->sd_Flags & SD_F_BIG_ENDIAN_DIC;
593 MSG("pForth loading dictionary from file "); MSG(FileName);
595 MSG_NUM_D(" File format version is ", sd->sd_Version );
596 MSG_NUM_D(" Name space size = ", sd->sd_NameSize );
597 MSG_NUM_D(" Code space size = ", sd->sd_CodeSize );
598 MSG_NUM_D(" Entry Point = ", sd->sd_EntryPoint );
599 MSG_NUM_D(" Cell Size = ", sd->sd_CellSize );
600 MSG( (isDicBigEndian ? " Big Endian Dictionary" :
601 " Little Endian Dictionary") );
602 if( isDicBigEndian == IsHostLittleEndian() ) MSG(" !!!!");
606 if( sd->sd_Version > PF_FILE_VERSION )
608 pfReportError("pfLoadDictionary", PF_ERR_VERSION_FUTURE );
611 if( sd->sd_Version < PF_EARLIEST_FILE_VERSION )
613 pfReportError("pfLoadDictionary", PF_ERR_VERSION_PAST );
616 if( sd->sd_CellSize != sizeof(cell_t) )
618 pfReportError("pfLoadDictionary", PF_ERR_CELL_SIZE_CONFLICT );
621 if( sd->sd_NumPrimitives > NUM_PRIMITIVES )
623 pfReportError("pfLoadDictionary", PF_ERR_NOT_SUPPORTED );
627 /* Check to make sure that EndianNess of dictionary matches mode of pForth. */
628 #if defined(PF_BIG_ENDIAN_DIC)
629 if(isDicBigEndian == 0)
630 #elif defined(PF_LITTLE_ENDIAN_DIC)
631 if(isDicBigEndian == 1)
633 if( isDicBigEndian == IsHostLittleEndian() )
636 pfReportError("pfLoadDictionary", PF_ERR_ENDIAN_CONFLICT );
640 /* Check for compatible float size. */
642 if( sd->sd_FloatSize != sizeof(PF_FLOAT) )
644 if( sd->sd_FloatSize != 0 )
647 pfReportError("pfLoadDictionary", PF_ERR_FLOAT_CONFLICT );
651 dic = pfCreateDictionary( sd->sd_NameSize, sd->sd_CodeSize );
652 if( dic == NULL ) goto nomem_error;
653 gCurrentDictionary = dic;
654 if( sd->sd_NameSize > 0 )
656 gVarContext = NAMEREL_TO_ABS(sd->sd_RelContext); /* Restore context. */
657 gCurrentDictionary->dic_HeaderPtr = (ucell_t)(uint8_t *)
658 NAMEREL_TO_ABS(sd->sd_RelHeaderPtr);
663 gCurrentDictionary->dic_HeaderPtr = (ucell_t)NULL;
665 gCurrentDictionary->dic_CodePtr.Byte = (uint8_t *) CODEREL_TO_ABS(sd->sd_RelCodePtr);
666 gNumPrimitives = sd->sd_NumPrimitives; /* Must match compiled dictionary. */
667 /* Pass EntryPoint back to caller. */
668 if( EntryPointPtr != NULL ) *EntryPointPtr = sd->sd_EntryPoint;
674 pfReportError("pfLoadDictionary", PF_ERR_NO_SHELL );
679 pfReportError("pfLoadDictionary", PF_ERR_NO_NAMES );
682 if( gCurrentDictionary == NULL )
684 pfReportError("pfLoadDictionary", PF_ERR_BAD_FILE );
687 if( ChunkSize > NAME_SIZE )
689 pfReportError("pfLoadDictionary", PF_ERR_TOO_BIG);
692 numr = sdReadFile( (char *) NAME_BASE, 1, ChunkSize, fid );
693 if( numr != ChunkSize ) goto read_error;
694 BytesLeft -= ChunkSize;
695 #endif /* PF_NO_SHELL */
699 if( gCurrentDictionary == NULL )
701 pfReportError("pfLoadDictionary", PF_ERR_BAD_FILE );
704 if( ChunkSize > CODE_SIZE )
706 pfReportError("pfLoadDictionary", PF_ERR_TOO_BIG);
709 numr = sdReadFile( (uint8_t *) CODE_BASE, 1, ChunkSize, fid );
710 if( numr != ChunkSize ) goto read_error;
711 BytesLeft -= ChunkSize;
715 pfReportError("pfLoadDictionary", PF_ERR_BAD_FILE );
716 sdSeekFile( fid, ChunkSize, PF_SEEK_CUR );
726 /* Find special words in dictionary for global XTs. */
727 if( (Result = FindSpecialXTs()) < 0 )
729 pfReportError("pfLoadDictionary: FindSpecialXTs", (Err)Result);
734 DBUG(("pfLoadDictionary: return %p\n", dic));
735 return (PForthDictionary) dic;
738 pfReportError("pfLoadDictionary", PF_ERR_NO_MEM);
743 pfReportError("pfLoadDictionary", PF_ERR_READ_FILE);
752 PForthDictionary pfLoadDictionary( const char *FileName, ExecToken *EntryPointPtr )
755 (void) EntryPointPtr;
758 #endif /* !PF_NO_FILEIO */
762 /***************************************************************/
763 PForthDictionary pfLoadStaticDictionary( void )
768 cell_t NewNameSize, NewCodeSize;
770 if( IF_LITTLE_ENDIAN != IsHostLittleEndian() )
772 MSG( (IF_LITTLE_ENDIAN ?
773 "Little Endian Dictionary on " :
774 "Big Endian Dictionary on ") );
775 MSG( (IsHostLittleEndian() ?
776 "Little Endian CPU" :
781 /* Check to make sure that EndianNess of dictionary matches mode of pForth. */
782 #if defined(PF_BIG_ENDIAN_DIC)
783 if(IF_LITTLE_ENDIAN == 1)
784 #elif defined(PF_LITTLE_ENDIAN_DIC)
785 if(IF_LITTLE_ENDIAN == 0)
786 #else /* Code is native endian! */
787 if( IF_LITTLE_ENDIAN != IsHostLittleEndian() )
790 pfReportError("pfLoadStaticDictionary", PF_ERR_ENDIAN_CONFLICT );
795 #ifndef PF_EXTRA_HEADERS
796 #define PF_EXTRA_HEADERS (20000)
798 #ifndef PF_EXTRA_CODE
799 #define PF_EXTRA_CODE (40000)
802 /* Copy static const data to allocated dictionaries. */
803 NewNameSize = sizeof(MinDicNames) + PF_EXTRA_HEADERS;
804 NewCodeSize = sizeof(MinDicCode) + PF_EXTRA_CODE;
806 DBUG_NUM_D( "static dic name size = ", NewNameSize );
807 DBUG_NUM_D( "static dic code size = ", NewCodeSize );
809 gCurrentDictionary = dic = pfCreateDictionary( NewNameSize, NewCodeSize );
810 if( !dic ) goto nomem_error;
812 pfCopyMemory( (uint8_t *) dic->dic_HeaderBase, MinDicNames, sizeof(MinDicNames) );
813 pfCopyMemory( (uint8_t *) dic->dic_CodeBase, MinDicCode, sizeof(MinDicCode) );
814 DBUG(("Static data copied to newly allocated dictionaries.\n"));
816 dic->dic_CodePtr.Byte = (uint8_t *) CODEREL_TO_ABS(CODEPTR);
817 gNumPrimitives = NUM_PRIMITIVES;
821 /* Setup name space. */
822 dic->dic_HeaderPtr = (ucell_t)(uint8_t *) NAMEREL_TO_ABS(HEADERPTR);
823 gVarContext = NAMEREL_TO_ABS(RELCONTEXT); /* Restore context. */
825 /* Find special words in dictionary for global XTs. */
826 if( (Result = FindSpecialXTs()) < 0 )
828 pfReportError("pfLoadStaticDictionary: FindSpecialXTs", Result);
833 return (PForthDictionary) dic;
839 pfReportError("pfLoadStaticDictionary", PF_ERR_NO_MEM);
840 #endif /* PF_STATIC_DIC */