Update of /cvsroot/arcem/arcem/arch
In directory vz-cvs-4.sog:/tmp/cvs-serv14186/arch
Modified Files:
Tag: arcem-fast
armarc.c armarc.h fastmap.c
Log Message:
Fix issues on 64bit hosts
* armemu.c: Make sure the "are we close to the end of a page?" checks work
properly if (addr<<20) has been implicitly expanded to 64 bits. With the way
the code was written this wouldn't have caused any problems except for some
performance loss due to the optimised path not being taken
* arch/armarc.c, arch/armarc.h: Make FastMap_Phy2Func deal with the use of
64bit function pointers on 64bit hosts
* arch/armarc.c: Fix FastMap_SetEntries truncating the address offset to 32
bits, causing issues if the OS uses pointers above the 4G limit
* arch/armarc.h: Fix FastMap_DecodeRead/FastMap_DecodeWrite truncating the
access mode to 32bits, causing the mode flags to be lost altogether on 64bit
systems
* arch/fastmap.c: Fix ARMul_StoreByte/ARMul_SwapByte masking off the high half
of phy when it should have only been masking off the bottom two bits
Index: fastmap.c
===================================================================
RCS file: /cvsroot/arcem/arcem/arch/Attic/fastmap.c,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -d -r1.1.2.4 -r1.1.2.5
--- fastmap.c 27 Oct 2011 20:57:31 -0000 1.1.2.4
+++ fastmap.c 12 May 2012 17:16:18 -0000 1.1.2.5
@@ -129,7 +129,7 @@
#endif
ARMword *phy = FastMap_Log2Phy(entry,address);
*((uint8_t *)phy) = data;
-
*(FastMap_Phy2Func(state,(ARMword*)((FastMapUInt)phy&~UINT32_C(3)))) =
FASTMAP_CLOBBEREDFUNC;
+
*(FastMap_Phy2Func(state,(ARMword*)(((FastMapUInt)phy)&~((FastMapUInt)3)))) =
FASTMAP_CLOBBEREDFUNC;
}
else if(FASTMAP_RESULT_FUNC(res))
{
@@ -211,7 +211,7 @@
ARMword *phy = FastMap_Log2Phy(entry,address);
temp = *((uint8_t *)phy);
*((uint8_t *)phy) = data;
-
*(FastMap_Phy2Func(state,(ARMword*)((FastMapUInt)phy&~UINT32_C(3)))) =
FASTMAP_CLOBBEREDFUNC;
+
*(FastMap_Phy2Func(state,(ARMword*)(((FastMapUInt)phy)&~((FastMapUInt)3)))) =
FASTMAP_CLOBBEREDFUNC;
return temp;
}
else if(FASTMAP_RESULT_FUNC(res))
Index: armarc.h
===================================================================
RCS file: /cvsroot/arcem/arcem/arch/armarc.h,v
retrieving revision 1.11.2.7
retrieving revision 1.11.2.8
diff -u -d -r1.11.2.7 -r1.11.2.8
--- armarc.h 27 Oct 2011 21:08:33 -0000 1.11.2.7
+++ armarc.h 12 May 2012 17:16:18 -0000 1.11.2.8
@@ -73,8 +73,8 @@
/* ------------------- inlined FastMap functions
------------------------------ */
static FastMapEntry *FastMap_GetEntry(ARMul_State *state,ARMword addr);
static FastMapEntry *FastMap_GetEntryNoWrap(ARMul_State *state,ARMword addr);
-static FastMapRes FastMap_DecodeRead(const FastMapEntry *entry,ARMword mode);
-static FastMapRes FastMap_DecodeWrite(const FastMapEntry *entry,ARMword mode);
+static FastMapRes FastMap_DecodeRead(const FastMapEntry *entry,FastMapUInt
mode);
+static FastMapRes FastMap_DecodeWrite(const FastMapEntry *entry,FastMapUInt
mode);
static ARMword *FastMap_Log2Phy(const FastMapEntry *entry,ARMword addr);
static ARMEmuFunc *FastMap_Phy2Func(ARMul_State *state,ARMword *addr);
static ARMword FastMap_LoadFunc(const FastMapEntry *entry,ARMul_State
*state,ARMword addr);
@@ -93,13 +93,13 @@
return &state->FastMap[addr>>12];
}
-static inline FastMapRes FastMap_DecodeRead(const FastMapEntry *entry,ARMword
mode)
+static inline FastMapRes FastMap_DecodeRead(const FastMapEntry
*entry,FastMapUInt mode)
{
/* Use the FASTMAP_RESULT_* macros to decide what to do */
return ((FastMapRes)((entry->FlagsAndData)&mode));
}
-static inline FastMapRes FastMap_DecodeWrite(const FastMapEntry *entry,ARMword
mode)
+static inline FastMapRes FastMap_DecodeWrite(const FastMapEntry
*entry,FastMapUInt mode)
{
/* Use the FASTMAP_RESULT_* macros to decide what to do */
return ((FastMapRes)((entry->FlagsAndData<<1)&mode));
@@ -114,7 +114,12 @@
static inline ARMEmuFunc *FastMap_Phy2Func(ARMul_State *state,ARMword *addr)
{
/* Return ARMEmuFunc * for an address returned by Log2Phy */
+#ifdef FASTMAP_64
+ /* Shift addr so we access ARMEmuFunc *'s as 64bit data types instead
of 32bit */
+ return
(ARMEmuFunc*)((((FastMapUInt)addr)<<1)+state->FastMapInstrFuncOfs);
+#else
return (ARMEmuFunc*)(((FastMapUInt)addr)+state->FastMapInstrFuncOfs);
+#endif
}
static inline ARMword FastMap_LoadFunc(const FastMapEntry *entry,ARMul_State
*state,ARMword addr)
Index: armarc.c
===================================================================
RCS file: /cvsroot/arcem/arcem/arch/armarc.c,v
retrieving revision 1.37.2.8
retrieving revision 1.37.2.9
diff -u -d -r1.37.2.8 -r1.37.2.9
--- armarc.c 27 Oct 2011 20:57:31 -0000 1.37.2.8
+++ armarc.c 12 May 2012 17:16:18 -0000 1.37.2.9
@@ -309,12 +309,17 @@
/* Now allocate ROMs & RAM in one chunk */
ARMword RAMChunkSize = MAX(MEMC.RAMSize,512*1024); /* Ensure at least 512K
RAM allocated to avoid any issues caused by DMA pointers going out of range */
MEMC.ROMRAMChunk = calloc(RAMChunkSize+MEMC.ROMHighSize+extnrom_size+256,1);
- MEMC.EmuFuncChunk = calloc(RAMChunkSize+MEMC.ROMHighSize+extnrom_size+256,1);
+ MEMC.EmuFuncChunk =
calloc(RAMChunkSize+MEMC.ROMHighSize+extnrom_size+256,sizeof(FastMapUInt)/4);
if((MEMC.ROMRAMChunk == NULL) || (MEMC.EmuFuncChunk == NULL)) {
fprintf(stderr,"Couldn't allocate ROMRAMChunk/EmuFuncChunk\n");
exit(3);
}
+#ifdef FASTMAP_64
+ /* On 64bit systems, ROMRAMChunk needs shifting to account for the shift
that occurs in FastMap_Phy2Func */
+ state->FastMapInstrFuncOfs =
((FastMapUInt)MEMC.EmuFuncChunk)-(((FastMapUInt)MEMC.ROMRAMChunk)<<1);
+#else
state->FastMapInstrFuncOfs =
((FastMapUInt)MEMC.EmuFuncChunk)-((FastMapUInt)MEMC.ROMRAMChunk);
+#endif
/* Get everything 256 byte aligned for FastMap to work */
MEMC.PhysRam = (ARMword*) ((((FastMapUInt)MEMC.ROMRAMChunk)+255)&~255); /*
RAM must come first for FastMap_LogRamFunc to work! */
MEMC.ROMHigh = MEMC.PhysRam + (RAMChunkSize>>2);
@@ -496,8 +501,8 @@
{
FastMapEntry *entry = FastMap_GetEntryNoWrap(&statestr,addr);
//
fprintf(stderr,"FastMap_SetEntries(%08x,%08x,%08x,%08x,%08x)\n",addr,data,func,flags,size);
- addr = ((FastMapUInt)data)-addr; /* Offset so we can just add the phy addr
to get a pointer back */
- flags |= addr>>8;
+ FastMapUInt offset = ((FastMapUInt)data)-addr; /* Offset so we can just add
the phy addr to get a pointer back */
+ flags |= offset>>8;
// fprintf(stderr,"->entry %08x\n->FlagsAndData %08x\n",entry,flags);
while(size) {
entry->FlagsAndData = flags;
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
--
arcem-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/arcem-cvs