MM::Native::HLock / HUnlock

This commit is contained in:
Kelvin Sherlock 2013-08-17 19:01:25 -04:00
parent a0ea7c365a
commit 60869a697a
2 changed files with 38 additions and 0 deletions

View File

@ -495,6 +495,19 @@ namespace MM
}
// template class to validate handle and work on it.
template<class FX>
uint16_t HandleIt(uint32_t handle, FX fx)
{
const auto iter = HandleMap.find(handle);
if (iter == HandleMap.end()) return SetMemError(MacOS::memWZErr);
auto &info = iter->second;
fx(info);
return SetMemError(0);
}
uint16_t HSetRBit(uint32_t handle)
{
const auto iter = HandleMap.find(handle);
@ -517,6 +530,29 @@ namespace MM
return SetMemError(0);
}
uint16_t HLock(uint32_t handle)
{
const auto iter = HandleMap.find(handle);
if (iter == HandleMap.end()) return SetMemError(MacOS::memWZErr);
auto &info = iter->second;
info.locked = true;
return SetMemError(0);
}
uint16_t HUnlock(uint32_t handle)
{
const auto iter = HandleMap.find(handle);
if (iter == HandleMap.end()) return SetMemError(MacOS::memWZErr);
auto &info = iter->second;
info.locked = false;
return SetMemError(0);
}
}

View File

@ -28,6 +28,8 @@ namespace MM
uint16_t HSetRBit(uint32_t handle);
uint16_t HClrRBit(uint32_t handle);
uint16_t HLock(uint32_t handle);
uint16_t HUnlock(uint32_t handle);
}
bool Init(uint8_t *memory, uint32_t memorySize, uint32_t reserved);