kern: add infra (but not impl) for all DeviceAddressSpace svcs

This commit is contained in:
Michael Scire
2020-07-14 18:46:25 -07:00
committed by SciresM
parent 863515a3b5
commit 0d3aa13f70
11 changed files with 303 additions and 13 deletions

View File

@@ -389,6 +389,30 @@ namespace ams::kern {
this->num_pages -= block->num_pages;
}
constexpr void ShareToDevice(KMemoryPermission new_perm) {
/* We must either be shared or have a zero lock count. */
MESOSPHERE_ASSERT((this->attribute & KMemoryAttribute_DeviceShared) == KMemoryAttribute_DeviceShared || this->device_use_count == 0);
/* Share. */
const u16 new_count = ++this->device_use_count;
MESOSPHERE_ABORT_UNLESS(new_count > 0);
this->attribute = static_cast<KMemoryAttribute>(this->attribute | KMemoryAttribute_DeviceShared);
}
constexpr void UnshareToDevice(KMemoryPermission new_perm) {
/* We must be shared. */
MESOSPHERE_ASSERT((this->attribute & KMemoryAttribute_DeviceShared) == KMemoryAttribute_DeviceShared);
/* Unhare. */
const u16 old_count = this->device_use_count--;
MESOSPHERE_ABORT_UNLESS(old_count > 0);
if (old_count == 1) {
this->attribute = static_cast<KMemoryAttribute>(this->attribute & ~KMemoryAttribute_DeviceShared);
}
}
constexpr void LockForIpc(KMemoryPermission new_perm) {
/* We must either be locked or have a zero lock count. */
MESOSPHERE_ASSERT((this->attribute & KMemoryAttribute_IpcLocked) == KMemoryAttribute_IpcLocked || this->ipc_lock_count == 0);