new SheepShaver globals layout

This commit is contained in:
gbeauche 2004-11-22 21:22:58 +00:00
parent 970bc59e40
commit 40367bd931
2 changed files with 27 additions and 9 deletions

View File

@ -229,7 +229,8 @@ static void *extra_stack = NULL; // Stack for SIGSEGV inside interrupt handler
uint32 SheepMem::page_size; // Size of a native page
uintptr SheepMem::zero_page = 0; // Address of ro page filled in with zeros
uintptr SheepMem::base; // Address of SheepShaver data
uintptr SheepMem::top; // Top of SheepShaver data (stack like storage)
uintptr SheepMem::proc; // Bottom address of SheepShave procedures
uintptr SheepMem::data; // Top of SheepShaver data (stack like storage)
static area_id SheepMemArea; // SheepShaver data area ID
@ -2109,7 +2110,7 @@ bool SheepMem::Init(void)
delete_area(old_sheep_area);
// Create area for SheepShaver data
base = 0x60000000;
proc = base = 0x60000000;
SheepMemArea = create_area(SHEEP_AREA_NAME, (void **)&base, B_BASE_ADDRESS, size, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
if (SheepMemArea < 0)
return false;
@ -2119,7 +2120,7 @@ bool SheepMem::Init(void)
zero_page = const_zero_page;
D(bug("SheepShaver area %ld at %p\n", SheepMemArea, base));
top = base + size;
data = base + size;
return true;
}

View File

@ -93,8 +93,9 @@ protected:
static uint32 page_size;
static uintptr zero_page;
static uintptr base;
static uintptr top;
static const uint32 size = 0x40000; // 256 KB
static uintptr data;
static uintptr proc;
static const uint32 size = 0x80000; // 512 KB
public:
static bool Init(void);
static void Exit(void);
@ -102,6 +103,7 @@ public:
static uint32 ZeroPage();
static uint32 Reserve(uint32 size);
static void Release(uint32 size);
static uint32 ReserveProc(uint32 size);
friend class SheepVar;
};
@ -123,14 +125,29 @@ inline uint32 SheepMem::ZeroPage()
inline uint32 SheepMem::Reserve(uint32 size)
{
top -= align(size);
assert(top >= base);
return top;
data -= align(size);
assert(data >= proc);
return data;
}
inline void SheepMem::Release(uint32 size)
{
top += align(size);
data += align(size);
}
inline uint32 SheepMem::ReserveProc(uint32 size)
{
uint32 mproc = proc;
proc += align(size);
assert(proc < data);
return mproc;
}
static inline uint32 SheepProc(const uint8 *proc, uint32 proc_size)
{
uint32 mac_proc = SheepMem::ReserveProc(proc_size);
Host2Mac_memcpy(mac_proc, proc, proc_size);
return mac_proc;
}
class SheepVar