mirror of
https://github.com/ksherlock/mpw.git
synced 2025-02-22 08:29:08 +00:00
MM::Native::HLock / HUnlock
This commit is contained in:
parent
a0ea7c365a
commit
60869a697a
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user