OSDispatch call

This commit is contained in:
Kelvin Sherlock 2014-12-14 19:52:08 -05:00
parent 91e142446b
commit f6f7964f81
3 changed files with 52 additions and 0 deletions

View File

@ -40,6 +40,8 @@
#include <macos/sysequ.h>
#include <macos/errors.h>
#include "stackframe.h"
using ToolBox::Log;
namespace
@ -1485,4 +1487,23 @@ namespace MM
cpuSetAReg(0, mplite_maxmem(&pool));
return mplite_freemem(&pool);
}
uint16_t TempMaxMem(void)
{
// FUNCTION TempMaxMem (VAR grow: Size): Size;
uint32_t address;
uint32_t sp = StackFrame<4>(address);
Log(" TempMaxMem(%08x)\n", address);
if (address) memoryWriteLong(0, address);
ToolReturn<4>(sp, mplite_maxmem(&pool));
SetMemError(0); // not sure if this is correct. oh well.
return 0;
}
}

View File

@ -84,6 +84,10 @@ namespace MM
uint16_t SetZone(uint16_t trap);
uint16_t MaxApplZone(uint16_t trap);
// OS Dispatch
uint16_t TempMaxMem(void);
}

View File

@ -42,6 +42,8 @@
#include "utility.h"
#include "loader.h"
#include "macos/traps.h"
#include "stackframe.h"
// yuck. TST.W d0
extern "C" void cpuSetFlagsNZ00NewW(UWO res);
@ -50,6 +52,27 @@ namespace ToolBox {
bool Trace = false;
uint16_t OSDispatch(uint16_t trap)
{
uint16_t selector;
StackFrame<2>(selector);
Log("%04x OSDispatch(%04x)\n", trap, selector);
switch(selector)
{
case 0x0015:
return MM::TempMaxMem();
default:
fprintf(stderr, "OSDispatch: selector %04x not implemented\n",
selector);
exit(1);
}
}
void dispatch(uint16_t trap)
{
// todo -- check/remove extra bits for save a0, toolglue, etc.
@ -522,6 +545,10 @@ namespace ToolBox {
d0 = Utility::BitTst(trap);
break;
case 0xa88f:
d0 = OSDispatch(trap);
break;
default:
fprintf(stderr, "Unsupported tool trap: %04x (%s)\n",
trap, TrapName(trap));