diff options
| author | 2019-03-13 05:02:14 -0400 | |
|---|---|---|
| committer | 2019-03-13 06:04:49 -0400 | |
| commit | 537906310863fd5528ca9fbcd4a5ee2d432c7abc (patch) | |
| tree | 68eb5c859c7617ec586b86f0234e8e9efecb5dc4 | |
| parent | core/hle/kernel/svc: Implement svcMapTransferMemory (diff) | |
| download | yuzu-537906310863fd5528ca9fbcd4a5ee2d432c7abc.tar.gz yuzu-537906310863fd5528ca9fbcd4a5ee2d432c7abc.tar.xz yuzu-537906310863fd5528ca9fbcd4a5ee2d432c7abc.zip | |
core/hle/kernel/svc: Implement svcUnmapTransferMemory
Similarly, like svcMapTransferMemory, we can also implement
svcUnmapTransferMemory fairly trivially as well.
Diffstat (limited to '')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 9d57b6650..bc89c4880 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -1646,6 +1646,53 @@ static ResultCode MapTransferMemory(Handle handle, VAddr address, u64 size, u32 | |||
| 1646 | return transfer_memory->MapMemory(address, size, permissions); | 1646 | return transfer_memory->MapMemory(address, size, permissions); |
| 1647 | } | 1647 | } |
| 1648 | 1648 | ||
| 1649 | static ResultCode UnmapTransferMemory(Handle handle, VAddr address, u64 size) { | ||
| 1650 | LOG_DEBUG(Kernel_SVC, "called. handle=0x{:08X}, address=0x{:016X}, size=0x{:016X}", handle, | ||
| 1651 | address, size); | ||
| 1652 | |||
| 1653 | if (!Common::Is4KBAligned(address)) { | ||
| 1654 | LOG_ERROR(Kernel_SVC, "Transfer memory addresses must be 4KB aligned (size=0x{:016X}).", | ||
| 1655 | address); | ||
| 1656 | return ERR_INVALID_ADDRESS; | ||
| 1657 | } | ||
| 1658 | |||
| 1659 | if (size == 0 || !Common::Is4KBAligned(size)) { | ||
| 1660 | LOG_ERROR(Kernel_SVC, | ||
| 1661 | "Transfer memory sizes must be 4KB aligned and not be zero (size=0x{:016X}).", | ||
| 1662 | size); | ||
| 1663 | return ERR_INVALID_SIZE; | ||
| 1664 | } | ||
| 1665 | |||
| 1666 | if (!IsValidAddressRange(address, size)) { | ||
| 1667 | LOG_ERROR(Kernel_SVC, | ||
| 1668 | "Given address and size overflows the 64-bit range (address=0x{:016X}, " | ||
| 1669 | "size=0x{:016X}).", | ||
| 1670 | address, size); | ||
| 1671 | return ERR_INVALID_ADDRESS_STATE; | ||
| 1672 | } | ||
| 1673 | |||
| 1674 | const auto& kernel = Core::System::GetInstance().Kernel(); | ||
| 1675 | const auto* const current_process = kernel.CurrentProcess(); | ||
| 1676 | const auto& handle_table = current_process->GetHandleTable(); | ||
| 1677 | |||
| 1678 | auto transfer_memory = handle_table.Get<TransferMemory>(handle); | ||
| 1679 | if (!transfer_memory) { | ||
| 1680 | LOG_ERROR(Kernel_SVC, "Nonexistent transfer memory handle given (handle=0x{:08X}).", | ||
| 1681 | handle); | ||
| 1682 | return ERR_INVALID_HANDLE; | ||
| 1683 | } | ||
| 1684 | |||
| 1685 | if (!current_process->VMManager().IsWithinASLRRegion(address, size)) { | ||
| 1686 | LOG_ERROR(Kernel_SVC, | ||
| 1687 | "Given address and size don't fully fit within the ASLR region " | ||
| 1688 | "(address=0x{:016X}, size=0x{:016X}).", | ||
| 1689 | address, size); | ||
| 1690 | return ERR_INVALID_MEMORY_RANGE; | ||
| 1691 | } | ||
| 1692 | |||
| 1693 | return transfer_memory->UnmapMemory(address, size); | ||
| 1694 | } | ||
| 1695 | |||
| 1649 | static ResultCode GetThreadCoreMask(Handle thread_handle, u32* core, u64* mask) { | 1696 | static ResultCode GetThreadCoreMask(Handle thread_handle, u32* core, u64* mask) { |
| 1650 | LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); | 1697 | LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); |
| 1651 | 1698 | ||
| @@ -2022,7 +2069,7 @@ static const FunctionDef SVC_Table[] = { | |||
| 2022 | {0x4F, nullptr, "SetProcessActivity"}, | 2069 | {0x4F, nullptr, "SetProcessActivity"}, |
| 2023 | {0x50, SvcWrap<CreateSharedMemory>, "CreateSharedMemory"}, | 2070 | {0x50, SvcWrap<CreateSharedMemory>, "CreateSharedMemory"}, |
| 2024 | {0x51, SvcWrap<MapTransferMemory>, "MapTransferMemory"}, | 2071 | {0x51, SvcWrap<MapTransferMemory>, "MapTransferMemory"}, |
| 2025 | {0x52, nullptr, "UnmapTransferMemory"}, | 2072 | {0x52, SvcWrap<UnmapTransferMemory>, "UnmapTransferMemory"}, |
| 2026 | {0x53, nullptr, "CreateInterruptEvent"}, | 2073 | {0x53, nullptr, "CreateInterruptEvent"}, |
| 2027 | {0x54, nullptr, "QueryPhysicalAddress"}, | 2074 | {0x54, nullptr, "QueryPhysicalAddress"}, |
| 2028 | {0x55, nullptr, "QueryIoMapping"}, | 2075 | {0x55, nullptr, "QueryIoMapping"}, |