Fix cache flushing

This commit is contained in:
Wolfgang Thaller 2017-09-28 17:51:19 +02:00
parent c757fb9520
commit 4897a9e039
3 changed files with 12 additions and 6 deletions

View File

@ -103,7 +103,7 @@ pascal void* Retro68LoadSegment(uint8_t *p)
++jtEntry; ++jtEntry;
} }
if(relocState.needFlushCache) if(relocState.hasFlushCodeCache)
FlushCodeCache(); FlushCodeCache();
/* Load Exception Information */ /* Load Exception Information */

View File

@ -90,7 +90,7 @@ typedef struct Retro68RelocState
Ptr bssPtr; Ptr bssPtr;
Handle codeHandle; Handle codeHandle;
char hasStripAddr; char hasStripAddr;
char needFlushCache; char hasFlushCodeCache;
} Retro68RelocState; } Retro68RelocState;
extern Retro68RelocState relocState; extern Retro68RelocState relocState;

View File

@ -118,14 +118,17 @@ void Retro68Relocate()
Boolean is128KROM = ((*ROM85) > 0); Boolean is128KROM = ((*ROM85) > 0);
Boolean hasSysEnvirons = false; Boolean hasSysEnvirons = false;
Boolean hasStripAddr = false; Boolean hasStripAddr = false;
Boolean hasFlushCodeCache = false;
if (is128KROM) if (is128KROM)
{ {
UniversalProcPtr trapSysEnv = GetOSTrapAddress(_SysEnvirons); UniversalProcPtr trapSysEnv = GetOSTrapAddress(_SysEnvirons);
UniversalProcPtr trapStripAddr = GetOSTrapAddress(_StripAddress); UniversalProcPtr trapStripAddr = GetOSTrapAddress(_StripAddress);
UniversalProcPtr trapFlushCodeCache = GetOSTrapAddress(0xA0BD);
UniversalProcPtr trapUnimpl = GetOSTrapAddress(_Unimplemented); UniversalProcPtr trapUnimpl = GetOSTrapAddress(_Unimplemented);
hasSysEnvirons = (trapSysEnv != trapUnimpl); hasSysEnvirons = (trapSysEnv != trapUnimpl);
hasStripAddr = (trapStripAddr != trapUnimpl); hasStripAddr = (trapStripAddr != trapUnimpl);
hasFlushCodeCache = (trapFlushCodeCache != trapUnimpl);
} }
// Figure out the displacement // Figure out the displacement
@ -162,6 +165,7 @@ void Retro68Relocate()
} }
rState->hasStripAddr = hasStripAddr; rState->hasStripAddr = hasStripAddr;
rState->hasFlushCodeCache = hasFlushCodeCache;
// Locate the start of the FLT file header inside the code resource // Locate the start of the FLT file header inside the code resource
uint8_t *orig_stext, *orig_etext, *orig_sdata, *orig_edata, *orig_sbss, *orig_ebss; uint8_t *orig_stext, *orig_etext, *orig_sdata, *orig_edata, *orig_sbss, *orig_ebss;
@ -261,7 +265,7 @@ void Retro68Relocate()
RealApplyRelocations(base, relocatableSize, reloc, displacements); RealApplyRelocations(base, relocatableSize, reloc, displacements);
// We're basically done. // We're basically done.
// Now check whether we're on 68040 or later and need to flush the cache. /*// Now check whether we're on 68040 or later and need to flush the cache.
// only do this if SysEnvirons is available. // only do this if SysEnvirons is available.
// if SysEnvirons is not available, that means we're on an old System or ROM // if SysEnvirons is not available, that means we're on an old System or ROM
// and likely not using a 68040, so we won't do this // and likely not using a 68040, so we won't do this
@ -276,7 +280,9 @@ void Retro68Relocate()
rState->needFlushCache = true; rState->needFlushCache = true;
FlushCodeCache(); FlushCodeCache();
} }
} }*/
if(hasFlushCodeCache)
FlushCodeCache();
// accessing globals and calling functions is OK below here. // accessing globals and calling functions is OK below here.
// ... as long as it is in the current segment. // ... as long as it is in the current segment.