MM::ReserveMem and minor cleanups

This commit is contained in:
Kelvin Sherlock 2013-03-31 23:49:59 -04:00
parent 05baff21ad
commit cbbab65d2c
3 changed files with 32 additions and 0 deletions

View File

@ -271,6 +271,7 @@ namespace MM
Log("%04x CompactMem(%08x)\n", trap, cbNeeded);
SetMemError(0);
return mplite_maxmem(&pool);
}
@ -288,6 +289,7 @@ namespace MM
Log("%04x MaxMem()\n", trap);
SetMemError(0);
return mplite_maxmem(&pool);
}
@ -305,9 +307,33 @@ namespace MM
Log("%04x FreeMem()\n", trap);
SetMemError(0);
return mplite_freemem(&pool);
}
uint16_t ReserveMem(uint16_t trap)
{
/*
* on entry:
* D0: cbNeeded (long word)
*
* on exit:
* D0: Result code.
*
*/
uint32_t cbNeeded = cpuGetDReg(0);
uint32_t available;
Log("%04x ReserveMem($%08x)\n", trap, cbNeeded);
available = mplite_maxmem(&pool);
// TODO -- if available < cbNeeded, purge handle and retry?
if (available < cbNeeded) return SetMemError(memFullErr);
return SetMemError(0);
}
uint16_t MoveHHi(uint16_t trap)
{

View File

@ -28,7 +28,9 @@ namespace MM
uint32_t CompactMem(uint16_t trap);
uint32_t MaxMem(uint16_t trap);
uint32_t FreeMem(uint16_t trap);
uint16_t ReserveMem(uint16_t trap);
uint16_t DisposeHandle(uint16_t trap);
uint16_t DisposePtr(uint16_t trap);

View File

@ -141,6 +141,10 @@ namespace ToolBox {
d0 = MM::CompactMem(trap);
break;
case 0xa040:
d0 = MM::ReserveMem(trap);
break;
case 0xa055:
d0 = MM::StripAddress(trap);
break;