/***************************************************************/\r
void WriteCellBigEndian( uint8_t *addr, ucell_t data )\r
{\r
- // Write should be in order of increasing address\r
- // to optimize for burst writes to DRAM.\r
+ /* Write should be in order of increasing address \r
+ * to optimize for burst writes to DRAM. */\r
if( sizeof(ucell_t) == 8 )\r
{\r
*addr++ = (uint8_t) (data>>56);\r
/***************************************************************/\r
void WriteCellLittleEndian( uint8_t *addr, ucell_t data )\r
{\r
- // Write should be in order of increasing address\r
- // to optimize for burst writes to DRAM.\r
+ /* Write should be in order of increasing address \r
+ * to optimize for burst writes to DRAM. */\r
if( sizeof(ucell_t) == 8 )\r
{\r
- *addr++ = (uint8_t) data; // LSB at near end\r
+ *addr++ = (uint8_t) data; /* LSB at near end */\r
data = data >> 8;\r
*addr++ = (uint8_t) data;\r
data = data >> 8;\r
return -1;\r
}\r
\r
+/* Convert dictionary info chunk between native and on-disk (big-endian). */\r
+static void\r
+convertDictionaryInfoWrite (DictionaryInfoChunk *sd)\r
+{\r
+/* Convert all fields in DictionaryInfoChunk from Native to BigEndian. \r
+ * This assumes they are all 32-bit integers.\r
+ */\r
+ int i;\r
+ uint32_t *p = (uint32_t *) sd;\r
+ for (i=0; i<((int)(sizeof(*sd)/sizeof(uint32_t))); i++)\r
+ {\r
+ Write32BigEndian( (uint8_t *)&p[i], p[i] );\r
+ }\r
+}\r
+\r
+static void\r
+convertDictionaryInfoRead (DictionaryInfoChunk *sd)\r
+{\r
+/* Convert all fields in structure from BigEndian to Native. */\r
+ int i;\r
+ uint32_t *p = (uint32_t *) sd;\r
+ for (i=0; i<((int)(sizeof(*sd)/sizeof(uint32_t))); i++)\r
+ {\r
+ p[i] = Read32BigEndian( (uint8_t *)&p[i] );\r
+ }\r
+}\r
+\r
/****************************************************************\r
** Save Dictionary in File.\r
** If EntryPoint is NULL, save as development environment.\r
uint32_t NameChunkSize = 0;\r
uint32_t CodeChunkSize;\r
uint32_t relativeCodePtr;\r
- int i;\r
\r
fid = sdOpenFile( FileName, "wb" );\r
if( fid == NULL )\r
uint32_t relativeHeaderPtr;\r
/* Development mode. */\r
SD.sd_RelContext = ABS_TO_NAMEREL(gVarContext);\r
- relativeHeaderPtr = ABS_TO_NAMEREL(gCurrentDictionary->dic_HeaderPtr.Byte);\r
+ relativeHeaderPtr = ABS_TO_NAMEREL(gCurrentDictionary->dic_HeaderPtr);\r
SD.sd_RelHeaderPtr = relativeHeaderPtr;\r
\r
/* How much real name space is there? */\r
SD.sd_CodeSize = CodeSize;\r
\r
\r
-/* Convert all fields in DictionaryInfoChunk from Native to BigEndian. \r
- * This assumes they are all 32-bit integers.\r
- */\r
- {\r
- uint32_t *p = (uint32_t *) &SD;\r
- for( i=0; i<((int)(sizeof(SD)/sizeof(uint32_t))); i++ )\r
- {\r
- Write32BigEndian( (uint8_t *)&p[i], p[i] );\r
- }\r
- }\r
+ convertDictionaryInfoWrite (&SD);\r
\r
if( WriteChunkToFile( fid, ID_P4DI, (char *) &SD, sizeof(DictionaryInfoChunk) ) < 0 ) goto error;\r
\r
uint32_t FormSize;\r
uint32_t BytesLeft;\r
uint32_t numr;\r
- int i;\r
int isDicBigEndian;\r
\r
DBUG(("pfLoadDictionary( %s )\n", FileName ));\r
if( numr != ChunkSize ) goto read_error;\r
BytesLeft -= ChunkSize;\r
\r
-/* Convert all fields in structure from BigEndian to Native. */\r
- {\r
- uint32_t *p = (uint32_t *) sd;\r
- for( i=0; i<((int)(sizeof(*sd)/sizeof(uint32_t))); i++ )\r
- {\r
- p[i] = Read32BigEndian( (uint8_t *)&p[i] );\r
- }\r
- }\r
- \r
+ convertDictionaryInfoRead (sd);\r
+\r
isDicBigEndian = sd->sd_Flags & SD_F_BIG_ENDIAN_DIC;\r
\r
if( !gVarQuiet )\r
gCurrentDictionary = dic;\r
if( sd->sd_NameSize > 0 )\r
{\r
- gVarContext = (char *) NAMEREL_TO_ABS(sd->sd_RelContext); /* Restore context. */\r
- gCurrentDictionary->dic_HeaderPtr.Byte = (uint8_t *)\r
+ gVarContext = NAMEREL_TO_ABS(sd->sd_RelContext); /* Restore context. */\r
+ gCurrentDictionary->dic_HeaderPtr = (ucell_t)(uint8_t *)\r
NAMEREL_TO_ABS(sd->sd_RelHeaderPtr);\r
}\r
else\r
{\r
gVarContext = 0;\r
- gCurrentDictionary->dic_HeaderPtr.Byte = NULL;\r
+ gCurrentDictionary->dic_HeaderPtr = (ucell_t)NULL;\r
}\r
gCurrentDictionary->dic_CodePtr.Byte = (uint8_t *) CODEREL_TO_ABS(sd->sd_RelCodePtr);\r
gNumPrimitives = sd->sd_NumPrimitives; /* Must match compiled dictionary. */\r
pfReportError("pfLoadDictionary", PF_ERR_NO_SHELL );\r
goto error;\r
#else\r
- if( NAME_BASE == NULL )\r
+ if( NAME_BASE == 0 )\r
{\r
pfReportError("pfLoadDictionary", PF_ERR_NO_NAMES );\r
goto error;\r
pfReportError("pfLoadDictionary", PF_ERR_TOO_BIG);\r
goto error;\r
}\r
- numr = sdReadFile( NAME_BASE, 1, ChunkSize, fid );\r
+ numr = sdReadFile( (char *) NAME_BASE, 1, ChunkSize, fid );\r
if( numr != ChunkSize ) goto read_error;\r
BytesLeft -= ChunkSize;\r
#endif /* PF_NO_SHELL */\r
pfReportError("pfLoadDictionary", PF_ERR_TOO_BIG);\r
goto error;\r
}\r
- numr = sdReadFile( CODE_BASE, 1, ChunkSize, fid );\r
+ numr = sdReadFile( (uint8_t *) CODE_BASE, 1, ChunkSize, fid );\r
if( numr != ChunkSize ) goto read_error;\r
BytesLeft -= ChunkSize;\r
break;\r
\r
sdCloseFile( fid );\r
\r
- if( NAME_BASE != NULL)\r
+ if( NAME_BASE != 0)\r
{\r
cell_t Result;\r
/* Find special words in dictionary for global XTs. */\r
gCurrentDictionary = dic = pfCreateDictionary( NewNameSize, NewCodeSize );\r
if( !dic ) goto nomem_error;\r
\r
- pfCopyMemory( dic->dic_HeaderBase, MinDicNames, sizeof(MinDicNames) );\r
- pfCopyMemory( dic->dic_CodeBase, MinDicCode, sizeof(MinDicCode) );\r
+ pfCopyMemory( (uint8_t *) dic->dic_HeaderBase, MinDicNames, sizeof(MinDicNames) );\r
+ pfCopyMemory( (uint8_t *) dic->dic_CodeBase, MinDicCode, sizeof(MinDicCode) );\r
DBUG(("Static data copied to newly allocated dictionaries.\n"));\r
\r
dic->dic_CodePtr.Byte = (uint8_t *) CODEREL_TO_ABS(CODEPTR);\r
gNumPrimitives = NUM_PRIMITIVES;\r
\r
- if( NAME_BASE != NULL)\r
+ if( NAME_BASE != 0)\r
{\r
/* Setup name space. */\r
- dic->dic_HeaderPtr.Byte = (uint8_t *) NAMEREL_TO_ABS(HEADERPTR);\r
- gVarContext = (char *) NAMEREL_TO_ABS(RELCONTEXT); /* Restore context. */\r
+ dic->dic_HeaderPtr = (ucell_t)(uint8_t *) NAMEREL_TO_ABS(HEADERPTR);\r
+ gVarContext = NAMEREL_TO_ABS(RELCONTEXT); /* Restore context. */\r
\r
/* Find special words in dictionary for global XTs. */\r
if( (Result = FindSpecialXTs()) < 0 )\r