mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-31 14:58:22 -04:00
os: add DetachIoRegionHandle
This commit is contained in:
parent
8e258bde9d
commit
4ad8dad416
3 changed files with 24 additions and 0 deletions
|
@ -69,6 +69,28 @@ namespace ams::os {
|
|||
InitializeIoRegion(io_region, handle, size, managed);
|
||||
}
|
||||
|
||||
os::NativeHandle DetachIoRegionHandle(IoRegionType *io_region) {
|
||||
/* Check pre-conditions. */
|
||||
AMS_ASSERT(io_region->state != IoRegionType::State_NotInitialized);
|
||||
|
||||
/* Acquire exclusive access to the io region. */
|
||||
std::scoped_lock lk(util::GetReference(io_region->cs_io_region));
|
||||
|
||||
/* Check that we can detach. */
|
||||
AMS_ASSERT(io_region->state == IoRegionType::State_Initialized);
|
||||
|
||||
/* Set state as detached. */
|
||||
io_region->state = IoRegionType::State_Detached;
|
||||
|
||||
/* Detach the handle. */
|
||||
const auto handle = io_region->handle;
|
||||
|
||||
io_region->handle = os::InvalidNativeHandle;
|
||||
io_region->handle_managed = false;
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void DestroyIoRegion(IoRegionType *io_region) {
|
||||
/* Check pre-conditions. */
|
||||
AMS_ASSERT(io_region->state != IoRegionType::State_NotInitialized);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue