mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-25 04:31:52 +00:00
move stack to the top of the memory to make MrC's stack checks happy.
This commit is contained in:
parent
d79f498cfd
commit
0b76b9266e
@ -418,7 +418,7 @@ void GlobalInit()
|
|||||||
// so put stack at top of memory?
|
// so put stack at top of memory?
|
||||||
|
|
||||||
// 0x0130 -- ApplLimit
|
// 0x0130 -- ApplLimit
|
||||||
memoryWriteLong(Flags.memorySize - 1, MacOS::ApplLimit);
|
memoryWriteLong(Flags.memorySize - Flags.stackSize - 1, MacOS::ApplLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -429,6 +429,7 @@ void CreateStack()
|
|||||||
uint32_t address;
|
uint32_t address;
|
||||||
uint16_t error;
|
uint16_t error;
|
||||||
|
|
||||||
|
#if 0
|
||||||
Flags.stackSize = (Flags.stackSize + 3) & ~0x03;
|
Flags.stackSize = (Flags.stackSize + 3) & ~0x03;
|
||||||
|
|
||||||
error = MM::Native::NewPtr(Flags.stackSize, true, address);
|
error = MM::Native::NewPtr(Flags.stackSize, true, address);
|
||||||
@ -437,7 +438,11 @@ void CreateStack()
|
|||||||
fprintf(stderr, "Unable to allocate stack (%08x bytes)\n", Flags.stackSize);
|
fprintf(stderr, "Unable to allocate stack (%08x bytes)\n", Flags.stackSize);
|
||||||
exit(EX_CONFIG);
|
exit(EX_CONFIG);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
address = Flags.memorySize - Flags.stackSize;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
Flags.stackRange.first = address;
|
Flags.stackRange.first = address;
|
||||||
Flags.stackRange.second = address + Flags.stackSize;
|
Flags.stackRange.second = address + Flags.stackSize;
|
||||||
@ -865,6 +870,9 @@ int main(int argc, char **argv)
|
|||||||
exit(EX_USAGE);
|
exit(EX_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Flags.stackSize = (Flags.stackSize + 0xff) & ~0xff;
|
||||||
|
Flags.memorySize = (Flags.memorySize + 0xff) & ~0xff;
|
||||||
|
|
||||||
if (Flags.stackSize < 0x100)
|
if (Flags.stackSize < 0x100)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Invalid stack size\n");
|
fprintf(stderr, "Invalid stack size\n");
|
||||||
@ -877,6 +885,12 @@ int main(int argc, char **argv)
|
|||||||
exit(EX_CONFIG);
|
exit(EX_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Flags.stackSize >= Flags.memorySize)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Invalid stack/ram size\n");
|
||||||
|
exit(EX_CONFIG);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string command(argv[0]); // InitMPW updates argv...
|
std::string command(argv[0]); // InitMPW updates argv...
|
||||||
|
|
||||||
@ -903,7 +917,7 @@ int main(int argc, char **argv)
|
|||||||
// should we subtract memory from the top
|
// should we subtract memory from the top
|
||||||
// for the stack vs allocating it?
|
// for the stack vs allocating it?
|
||||||
|
|
||||||
MM::Init(Memory, MemorySize, kGlobalSize);
|
MM::Init(Memory, MemorySize - Flags.stackSize, kGlobalSize);
|
||||||
OS::Init();
|
OS::Init();
|
||||||
MPW::Init(argc, argv, defines);
|
MPW::Init(argc, argv, defines);
|
||||||
|
|
||||||
@ -911,7 +925,6 @@ int main(int argc, char **argv)
|
|||||||
cpuStartup();
|
cpuStartup();
|
||||||
cpuSetModel(3,0);
|
cpuSetModel(3,0);
|
||||||
|
|
||||||
|
|
||||||
CreateStack();
|
CreateStack();
|
||||||
|
|
||||||
#ifdef LOADER_LOAD
|
#ifdef LOADER_LOAD
|
||||||
|
Loading…
Reference in New Issue
Block a user