MM::StackSpace / MM::HandleZone

This commit is contained in:
Kelvin Sherlock 2013-06-26 22:50:53 -04:00
parent f4d4100c5d
commit 13657ab760
2 changed files with 58 additions and 0 deletions

View File

@ -410,6 +410,34 @@ namespace MM
}
uint32_t StackSpace(uint16_t trap)
{
/*
* on entry:
*
* on exit:
* D0: Number of bytes between stack and heap
*
*/
uint32_t sp = cpuGetAReg(7);
SetMemError(0);
// find the pointer base...
for (const auto & iter : PtrMap)
{
if (sp >= iter.first && sp < iter.first + iter.second)
{
return sp - iter.first;
}
}
return 0;
}
#pragma mark Pointers
@ -945,5 +973,32 @@ namespace MM
return address;
}
uint16_t HandleZone(uint16_t trap)
{
// FUNCTION HandleZone (h: Handle): THz;
/*
* on entry:
* A0 Handle whose zone is to be found
*
* on exit:
* A0 Pointer to handles heap zone
* D0 Result code
*
*/
uint32_t h = cpuGetAReg(0);
Log("%04x HandleZone(%08x)\n", trap, h);
if (HandleMap.find(h) == HandleMap.end())
{
cpuSetAReg(0, 0);
return SetMemError(MacOS::memWZErr);
}
cpuSetAReg(0, 0);
return SetMemError(0);
}
}

View File

@ -65,6 +65,9 @@ namespace MM
uint16_t PtrToHand(uint16_t trap);
uint16_t PtrToXHand(uint16_t trap);
uint32_t StackSpace(uint16_t trap);
uint16_t HandleZone(uint16_t trap);
}