mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
core/hle/kernel/svc: Implement svcUnmapTransferMemory
Similarly, like svcMapTransferMemory, we can also implement svcUnmapTransferMemory fairly trivially as well.
This commit is contained in:
parent
567134f874
commit
5379063108
1 changed files with 48 additions and 1 deletions
|
@ -1646,6 +1646,53 @@ static ResultCode MapTransferMemory(Handle handle, VAddr address, u64 size, u32
|
|||
return transfer_memory->MapMemory(address, size, permissions);
|
||||
}
|
||||
|
||||
static ResultCode UnmapTransferMemory(Handle handle, VAddr address, u64 size) {
|
||||
LOG_DEBUG(Kernel_SVC, "called. handle=0x{:08X}, address=0x{:016X}, size=0x{:016X}", handle,
|
||||
address, size);
|
||||
|
||||
if (!Common::Is4KBAligned(address)) {
|
||||
LOG_ERROR(Kernel_SVC, "Transfer memory addresses must be 4KB aligned (size=0x{:016X}).",
|
||||
address);
|
||||
return ERR_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
if (size == 0 || !Common::Is4KBAligned(size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Transfer memory sizes must be 4KB aligned and not be zero (size=0x{:016X}).",
|
||||
size);
|
||||
return ERR_INVALID_SIZE;
|
||||
}
|
||||
|
||||
if (!IsValidAddressRange(address, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Given address and size overflows the 64-bit range (address=0x{:016X}, "
|
||||
"size=0x{:016X}).",
|
||||
address, size);
|
||||
return ERR_INVALID_ADDRESS_STATE;
|
||||
}
|
||||
|
||||
const auto& kernel = Core::System::GetInstance().Kernel();
|
||||
const auto* const current_process = kernel.CurrentProcess();
|
||||
const auto& handle_table = current_process->GetHandleTable();
|
||||
|
||||
auto transfer_memory = handle_table.Get<TransferMemory>(handle);
|
||||
if (!transfer_memory) {
|
||||
LOG_ERROR(Kernel_SVC, "Nonexistent transfer memory handle given (handle=0x{:08X}).",
|
||||
handle);
|
||||
return ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (!current_process->VMManager().IsWithinASLRRegion(address, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Given address and size don't fully fit within the ASLR region "
|
||||
"(address=0x{:016X}, size=0x{:016X}).",
|
||||
address, size);
|
||||
return ERR_INVALID_MEMORY_RANGE;
|
||||
}
|
||||
|
||||
return transfer_memory->UnmapMemory(address, size);
|
||||
}
|
||||
|
||||
static ResultCode GetThreadCoreMask(Handle thread_handle, u32* core, u64* mask) {
|
||||
LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle);
|
||||
|
||||
|
@ -2022,7 +2069,7 @@ static const FunctionDef SVC_Table[] = {
|
|||
{0x4F, nullptr, "SetProcessActivity"},
|
||||
{0x50, SvcWrap<CreateSharedMemory>, "CreateSharedMemory"},
|
||||
{0x51, SvcWrap<MapTransferMemory>, "MapTransferMemory"},
|
||||
{0x52, nullptr, "UnmapTransferMemory"},
|
||||
{0x52, SvcWrap<UnmapTransferMemory>, "UnmapTransferMemory"},
|
||||
{0x53, nullptr, "CreateInterruptEvent"},
|
||||
{0x54, nullptr, "QueryPhysicalAddress"},
|
||||
{0x55, nullptr, "QueryIoMapping"},
|
||||
|
|
Loading…
Reference in a new issue