mirror of
https://github.com/autc04/Retro68.git
synced 2024-06-08 04:29:46 +00:00
relocate.c: some cleanup
This commit is contained in:
parent
4c7b83bb75
commit
5fdd7b411f
|
@ -135,12 +135,12 @@ void Retro68ApplyRelocations(uint8_t *base, uint32_t size, void *relocations, ui
|
||||||
assert(addrPtr >= base);
|
assert(addrPtr >= base);
|
||||||
assert(addrPtr <= base + size - 4);
|
assert(addrPtr <= base + size - 4);
|
||||||
|
|
||||||
uint8_t *addr = (uint8_t*) READ_UNALIGNED_LONGWORD(addrPtr);
|
uint32_t addr = READ_UNALIGNED_LONGWORD(addrPtr);
|
||||||
addr += displacements[kind];
|
addr += displacements[kind];
|
||||||
if(relative)
|
if(relative)
|
||||||
addr -= (uint32_t) addrPtr;
|
addr -= (uint32_t) addrPtr;
|
||||||
|
|
||||||
WRITE_UNALIGNED_LONGWORD(addrPtr, (uint32_t) addr);
|
WRITE_UNALIGNED_LONGWORD(addrPtr, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
reloc++;
|
reloc++;
|
||||||
|
@ -245,8 +245,8 @@ void Retro68Relocate()
|
||||||
// this crashes with some implementations of the memory manager
|
// this crashes with some implementations of the memory manager
|
||||||
// if we guess wrong, so let's don't for now.
|
// if we guess wrong, so let's don't for now.
|
||||||
// Therefore, all Retro68-compiled code resources have to be locked,
|
// Therefore, all Retro68-compiled code resources have to be locked,
|
||||||
// or they might get relocated as soon as the global variables are
|
// or they might get moved as soon as the global variables are
|
||||||
// relocated below.
|
// allocated below.
|
||||||
// TODO: figure out a way to reliably determine the offset from the
|
// TODO: figure out a way to reliably determine the offset from the
|
||||||
// start of the resource (to pass it from Elf2Mac, probably).
|
// start of the resource (to pass it from Elf2Mac, probably).
|
||||||
|
|
||||||
|
@ -278,11 +278,9 @@ void Retro68Relocate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Relocation records consist of 4 bytes each.
|
Relocation records logically consist of
|
||||||
The lower three bytes are the offset of the longword being relocated.
|
* the offset of the longword being relocated
|
||||||
the first byte of each longword specifies which segment
|
* the displacement base, specified as an index into the following table:
|
||||||
the relocation leads to; the corresponding displacements are taken
|
|
||||||
from the following table:
|
|
||||||
*/
|
*/
|
||||||
long displacements[4] = {
|
long displacements[4] = {
|
||||||
displacement, // code
|
displacement, // code
|
||||||
|
@ -315,22 +313,6 @@ 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.
|
|
||||||
// only do this if SysEnvirons is available.
|
|
||||||
// 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
|
|
||||||
if (hasSysEnvirons)
|
|
||||||
{
|
|
||||||
SysEnvRec env;
|
|
||||||
|
|
||||||
env.processor = 0;
|
|
||||||
SysEnvirons(0, &env);
|
|
||||||
if(env.processor >= env68040)
|
|
||||||
{
|
|
||||||
rState->needFlushCache = true;
|
|
||||||
FlushCodeCache();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
if(hasFlushCodeCache)
|
if(hasFlushCodeCache)
|
||||||
FlushCodeCache();
|
FlushCodeCache();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user