From 2bd086232b6b5e44718e5374d59f7d9b8c886b78 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sat, 3 Aug 2013 19:17:50 -0400 Subject: [PATCH] HGetState --- toolbox/mm.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- toolbox/mm.h | 2 ++ toolbox/toolbox.cpp | 4 ++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/toolbox/mm.cpp b/toolbox/mm.cpp index ca83beb..483fc89 100644 --- a/toolbox/mm.cpp +++ b/toolbox/mm.cpp @@ -973,7 +973,50 @@ namespace MM #pragma mark Handle attributes - // these are all nops for now. + uint16_t HGetState(uint16_t trap) + { + /* + * on entry: + * A0 Handle + * + * on exit: + * D0 flag byte + * + */ + + unsigned flags = 0; + uint32_t hh = cpuGetAReg(0); + + Log("%04x HGetState(%08x)\n", trap, hh); + + + auto iter = HandleMap.find(hh); + + if (iter == HandleMap.end()) return SetMemError(MacOS::memWZErr); + + /* + * flag bits: + * 0-4: reserved + * 5: is a resource + * 6: set if purgeable + * 7: set if locked + */ + + const auto &info = iter->second; + + // resouce not yet supported... + // would need extra field and support in RM:: when + // creating. + // see HSetRBit, HClrRBit + if (info.resource) flags |= (1 << 5); + if (info.purgeable) flags |= (1 << 6); + if (info.locked) flags |= (1 << 7); + + SetMemError(0); + return flags; + } + + uint16_t HPurge(uint16_t trap) { diff --git a/toolbox/mm.h b/toolbox/mm.h index 76e50a0..807fb4e 100644 --- a/toolbox/mm.h +++ b/toolbox/mm.h @@ -52,6 +52,8 @@ namespace MM uint16_t SetHandleSize(uint16_t); uint16_t SetPtrSize(uint16_t); + uint16_t HGetState(uint16_t trap); + uint16_t HLock(uint16_t trap); uint16_t HUnlock(uint16_t trap); diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index ba19032..6395b40 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -221,6 +221,10 @@ namespace ToolBox { d0 = MM::MaxBlock(trap); break; + case 0xa069: + d0 = MM::HGetState(trap); + break; + // MoveHHi (h: Handle); case 0xa064: d0 = MM::MoveHHi(trap);