diff options
| author | 2023-02-05 14:22:02 -0500 | |
|---|---|---|
| committer | 2023-02-06 23:57:44 -0500 | |
| commit | 2415d37ea296e8856267375989a8b95cebe2575a (patch) | |
| tree | 376baf5952a8ccc15b445702d38c056ffa71dd1b /src | |
| parent | Merge pull request #9731 from liamwhite/svc-move-only (diff) | |
| download | yuzu-2415d37ea296e8856267375989a8b95cebe2575a.tar.gz yuzu-2415d37ea296e8856267375989a8b95cebe2575a.tar.xz yuzu-2415d37ea296e8856267375989a8b95cebe2575a.zip | |
kernel/svc: switch to generated wrappers
Diffstat (limited to 'src')
45 files changed, 7468 insertions, 1570 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f16072e6c..8ef1fcaa8 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -310,6 +310,7 @@ add_library(core STATIC | |||
| 310 | hle/kernel/svc/svc_event.cpp | 310 | hle/kernel/svc/svc_event.cpp |
| 311 | hle/kernel/svc/svc_exception.cpp | 311 | hle/kernel/svc/svc_exception.cpp |
| 312 | hle/kernel/svc/svc_info.cpp | 312 | hle/kernel/svc/svc_info.cpp |
| 313 | hle/kernel/svc/svc_insecure_memory.cpp | ||
| 313 | hle/kernel/svc/svc_interrupt_event.cpp | 314 | hle/kernel/svc/svc_interrupt_event.cpp |
| 314 | hle/kernel/svc/svc_io_pool.cpp | 315 | hle/kernel/svc/svc_io_pool.cpp |
| 315 | hle/kernel/svc/svc_ipc.cpp | 316 | hle/kernel/svc/svc_ipc.cpp |
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index 7d62d030e..c40771c97 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <span> | 7 | #include <span> |
| 8 | #include <string> | ||
| 8 | #include <vector> | 9 | #include <vector> |
| 9 | 10 | ||
| 10 | #include <dynarmic/interface/halt_reason.h> | 11 | #include <dynarmic/interface/halt_reason.h> |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 4cb6f40a0..4ef57356e 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -1,449 +1,4435 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "common/common_types.h" | 4 | // This file is automatically generated using svc_generator.py. |
| 5 | |||
| 6 | #include <type_traits> | ||
| 7 | |||
| 8 | #include "core/arm/arm_interface.h" | ||
| 9 | #include "core/core.h" | ||
| 5 | #include "core/hle/kernel/k_process.h" | 10 | #include "core/hle/kernel/k_process.h" |
| 6 | #include "core/hle/kernel/k_thread.h" | ||
| 7 | #include "core/hle/kernel/svc.h" | 11 | #include "core/hle/kernel/svc.h" |
| 8 | #include "core/hle/kernel/svc_wrap.h" | ||
| 9 | #include "core/hle/result.h" | ||
| 10 | 12 | ||
| 11 | namespace Kernel::Svc { | 13 | namespace Kernel::Svc { |
| 12 | namespace { | 14 | |
| 13 | 15 | static uint32_t GetReg32(Core::System& system, int n) { | |
| 14 | struct FunctionDef { | 16 | return static_cast<uint32_t>(system.CurrentArmInterface().GetReg(n)); |
| 15 | using Func = void(Core::System&); | 17 | } |
| 16 | 18 | ||
| 17 | u32 id; | 19 | static void SetReg32(Core::System& system, int n, uint32_t result) { |
| 18 | Func* func; | 20 | system.CurrentArmInterface().SetReg(n, static_cast<uint64_t>(result)); |
| 19 | const char* name; | 21 | } |
| 20 | }; | 22 | |
| 21 | 23 | static uint64_t GetReg64(Core::System& system, int n) { | |
| 22 | } // namespace | 24 | return system.CurrentArmInterface().GetReg(n); |
| 23 | 25 | } | |
| 24 | static const FunctionDef SVC_Table_32[] = { | 26 | |
| 25 | {0x00, nullptr, "Unknown0"}, | 27 | static void SetReg64(Core::System& system, int n, uint64_t result) { |
| 26 | {0x01, SvcWrap32<SetHeapSize32>, "SetHeapSize32"}, | 28 | system.CurrentArmInterface().SetReg(n, result); |
| 27 | {0x02, nullptr, "SetMemoryPermission32"}, | 29 | } |
| 28 | {0x03, SvcWrap32<SetMemoryAttribute32>, "SetMemoryAttribute32"}, | 30 | |
| 29 | {0x04, SvcWrap32<MapMemory32>, "MapMemory32"}, | 31 | // Like bit_cast, but handles the case when the source and dest |
| 30 | {0x05, SvcWrap32<UnmapMemory32>, "UnmapMemory32"}, | 32 | // are differently-sized. |
| 31 | {0x06, SvcWrap32<QueryMemory32>, "QueryMemory32"}, | 33 | template <typename To, typename From> |
| 32 | {0x07, SvcWrap32<ExitProcess32>, "ExitProcess32"}, | 34 | requires(std::is_trivial_v<To> && std::is_trivially_copyable_v<From>) |
| 33 | {0x08, SvcWrap32<CreateThread32>, "CreateThread32"}, | 35 | static To Convert(const From& from) { |
| 34 | {0x09, SvcWrap32<StartThread32>, "StartThread32"}, | 36 | To to{}; |
| 35 | {0x0a, SvcWrap32<ExitThread32>, "ExitThread32"}, | 37 | |
| 36 | {0x0b, SvcWrap32<SleepThread32>, "SleepThread32"}, | 38 | if constexpr (sizeof(To) >= sizeof(From)) { |
| 37 | {0x0c, SvcWrap32<GetThreadPriority32>, "GetThreadPriority32"}, | 39 | std::memcpy(&to, &from, sizeof(From)); |
| 38 | {0x0d, SvcWrap32<SetThreadPriority32>, "SetThreadPriority32"}, | 40 | } else { |
| 39 | {0x0e, SvcWrap32<GetThreadCoreMask32>, "GetThreadCoreMask32"}, | 41 | std::memcpy(&to, &from, sizeof(To)); |
| 40 | {0x0f, SvcWrap32<SetThreadCoreMask32>, "SetThreadCoreMask32"}, | 42 | } |
| 41 | {0x10, SvcWrap32<GetCurrentProcessorNumber32>, "GetCurrentProcessorNumber32"}, | 43 | |
| 42 | {0x11, SvcWrap32<SignalEvent32>, "SignalEvent32"}, | 44 | return to; |
| 43 | {0x12, SvcWrap32<ClearEvent32>, "ClearEvent32"}, | 45 | } |
| 44 | {0x13, SvcWrap32<MapSharedMemory32>, "MapSharedMemory32"}, | 46 | |
| 45 | {0x14, SvcWrap32<UnmapSharedMemory32>, "UnmapSharedMemory32"}, | 47 | // clang-format off |
| 46 | {0x15, SvcWrap32<CreateTransferMemory32>, "CreateTransferMemory32"}, | 48 | static_assert(sizeof(ArbitrationType) == 4); |
| 47 | {0x16, SvcWrap32<CloseHandle32>, "CloseHandle32"}, | 49 | static_assert(sizeof(BreakReason) == 4); |
| 48 | {0x17, SvcWrap32<ResetSignal32>, "ResetSignal32"}, | 50 | static_assert(sizeof(CodeMemoryOperation) == 4); |
| 49 | {0x18, SvcWrap32<WaitSynchronization32>, "WaitSynchronization32"}, | 51 | static_assert(sizeof(DebugThreadParam) == 4); |
| 50 | {0x19, SvcWrap32<CancelSynchronization32>, "CancelSynchronization32"}, | 52 | static_assert(sizeof(DeviceName) == 4); |
| 51 | {0x1a, SvcWrap32<ArbitrateLock32>, "ArbitrateLock32"}, | 53 | static_assert(sizeof(HardwareBreakPointRegisterName) == 4); |
| 52 | {0x1b, SvcWrap32<ArbitrateUnlock32>, "ArbitrateUnlock32"}, | 54 | static_assert(sizeof(Handle) == 4); |
| 53 | {0x1c, SvcWrap32<WaitProcessWideKeyAtomic32>, "WaitProcessWideKeyAtomic32"}, | 55 | static_assert(sizeof(InfoType) == 4); |
| 54 | {0x1d, SvcWrap32<SignalProcessWideKey32>, "SignalProcessWideKey32"}, | 56 | static_assert(sizeof(InterruptType) == 4); |
| 55 | {0x1e, SvcWrap32<GetSystemTick32>, "GetSystemTick32"}, | 57 | static_assert(sizeof(IoPoolType) == 4); |
| 56 | {0x1f, SvcWrap32<ConnectToNamedPort32>, "ConnectToNamedPort32"}, | 58 | static_assert(sizeof(KernelDebugType) == 4); |
| 57 | {0x20, nullptr, "SendSyncRequestLight32"}, | 59 | static_assert(sizeof(KernelTraceState) == 4); |
| 58 | {0x21, SvcWrap32<SendSyncRequest32>, "SendSyncRequest32"}, | 60 | static_assert(sizeof(LimitableResource) == 4); |
| 59 | {0x22, nullptr, "SendSyncRequestWithUserBuffer32"}, | 61 | static_assert(sizeof(MemoryMapping) == 4); |
| 60 | {0x23, nullptr, "SendAsyncRequestWithUserBuffer32"}, | 62 | static_assert(sizeof(MemoryPermission) == 4); |
| 61 | {0x24, SvcWrap32<GetProcessId32>, "GetProcessId32"}, | 63 | static_assert(sizeof(PageInfo) == 4); |
| 62 | {0x25, SvcWrap32<GetThreadId32>, "GetThreadId32"}, | 64 | static_assert(sizeof(ProcessActivity) == 4); |
| 63 | {0x26, SvcWrap32<Break32>, "Break32"}, | 65 | static_assert(sizeof(ProcessInfoType) == 4); |
| 64 | {0x27, SvcWrap32<OutputDebugString32>, "OutputDebugString32"}, | 66 | static_assert(sizeof(Result) == 4); |
| 65 | {0x28, nullptr, "ReturnFromException32"}, | 67 | static_assert(sizeof(SignalType) == 4); |
| 66 | {0x29, SvcWrap32<GetInfo32>, "GetInfo32"}, | 68 | static_assert(sizeof(SystemInfoType) == 4); |
| 67 | {0x2a, nullptr, "FlushEntireDataCache32"}, | 69 | static_assert(sizeof(ThreadActivity) == 4); |
| 68 | {0x2b, nullptr, "FlushDataCache32"}, | 70 | static_assert(sizeof(ilp32::LastThreadContext) == 16); |
| 69 | {0x2c, SvcWrap32<MapPhysicalMemory32>, "MapPhysicalMemory32"}, | 71 | static_assert(sizeof(ilp32::PhysicalMemoryInfo) == 16); |
| 70 | {0x2d, SvcWrap32<UnmapPhysicalMemory32>, "UnmapPhysicalMemory32"}, | 72 | static_assert(sizeof(ilp32::SecureMonitorArguments) == 32); |
| 71 | {0x2e, nullptr, "GetDebugFutureThreadInfo32"}, | 73 | static_assert(sizeof(lp64::LastThreadContext) == 32); |
| 72 | {0x2f, nullptr, "GetLastThreadInfo32"}, | 74 | static_assert(sizeof(lp64::PhysicalMemoryInfo) == 24); |
| 73 | {0x30, nullptr, "GetResourceLimitLimitValue32"}, | 75 | static_assert(sizeof(lp64::SecureMonitorArguments) == 64); |
| 74 | {0x31, nullptr, "GetResourceLimitCurrentValue32"}, | 76 | static_assert(sizeof(bool) == 1); |
| 75 | {0x32, SvcWrap32<SetThreadActivity32>, "SetThreadActivity32"}, | 77 | static_assert(sizeof(int32_t) == 4); |
| 76 | {0x33, SvcWrap32<GetThreadContext32>, "GetThreadContext32"}, | 78 | static_assert(sizeof(int64_t) == 8); |
| 77 | {0x34, SvcWrap32<WaitForAddress32>, "WaitForAddress32"}, | 79 | static_assert(sizeof(uint32_t) == 4); |
| 78 | {0x35, SvcWrap32<SignalToAddress32>, "SignalToAddress32"}, | 80 | static_assert(sizeof(uint64_t) == 8); |
| 79 | {0x36, SvcWrap32<SynchronizePreemptionState>, "SynchronizePreemptionState32"}, | 81 | |
| 80 | {0x37, nullptr, "GetResourceLimitPeakValue32"}, | 82 | static void SvcWrap_SetHeapSize64From32(Core::System& system) { |
| 81 | {0x38, nullptr, "Unknown38"}, | 83 | Result ret{}; |
| 82 | {0x39, nullptr, "CreateIoPool32"}, | 84 | |
| 83 | {0x3a, nullptr, "CreateIoRegion32"}, | 85 | uintptr_t out_address{}; |
| 84 | {0x3b, nullptr, "Unknown3b"}, | 86 | uint32_t size{}; |
| 85 | {0x3c, nullptr, "KernelDebug32"}, | 87 | |
| 86 | {0x3d, nullptr, "ChangeKernelTraceState32"}, | 88 | size = Convert<uint32_t>(GetReg32(system, 1)); |
| 87 | {0x3e, nullptr, "Unknown3e"}, | 89 | |
| 88 | {0x3f, nullptr, "Unknown3f"}, | 90 | ret = SetHeapSize64From32(system, &out_address, size); |
| 89 | {0x40, nullptr, "CreateSession32"}, | 91 | |
| 90 | {0x41, nullptr, "AcceptSession32"}, | 92 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 91 | {0x42, nullptr, "ReplyAndReceiveLight32"}, | 93 | SetReg32(system, 1, Convert<uint32_t>(out_address)); |
| 92 | {0x43, nullptr, "ReplyAndReceive32"}, | 94 | } |
| 93 | {0x44, nullptr, "ReplyAndReceiveWithUserBuffer32"}, | 95 | |
| 94 | {0x45, SvcWrap32<CreateEvent32>, "CreateEvent32"}, | 96 | static void SvcWrap_SetMemoryPermission64From32(Core::System& system) { |
| 95 | {0x46, nullptr, "MapIoRegion32"}, | 97 | Result ret{}; |
| 96 | {0x47, nullptr, "UnmapIoRegion32"}, | 98 | |
| 97 | {0x48, nullptr, "MapPhysicalMemoryUnsafe32"}, | 99 | uint32_t address{}; |
| 98 | {0x49, nullptr, "UnmapPhysicalMemoryUnsafe32"}, | 100 | uint32_t size{}; |
| 99 | {0x4a, nullptr, "SetUnsafeLimit32"}, | 101 | MemoryPermission perm{}; |
| 100 | {0x4b, SvcWrap32<CreateCodeMemory32>, "CreateCodeMemory32"}, | 102 | |
| 101 | {0x4c, SvcWrap32<ControlCodeMemory32>, "ControlCodeMemory32"}, | 103 | address = Convert<uint32_t>(GetReg32(system, 0)); |
| 102 | {0x4d, nullptr, "SleepSystem32"}, | 104 | size = Convert<uint32_t>(GetReg32(system, 1)); |
| 103 | {0x4e, nullptr, "ReadWriteRegister32"}, | 105 | perm = Convert<MemoryPermission>(GetReg32(system, 2)); |
| 104 | {0x4f, nullptr, "SetProcessActivity32"}, | 106 | |
| 105 | {0x50, nullptr, "CreateSharedMemory32"}, | 107 | ret = SetMemoryPermission64From32(system, address, size, perm); |
| 106 | {0x51, nullptr, "MapTransferMemory32"}, | 108 | |
| 107 | {0x52, nullptr, "UnmapTransferMemory32"}, | 109 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 108 | {0x53, nullptr, "CreateInterruptEvent32"}, | 110 | } |
| 109 | {0x54, nullptr, "QueryPhysicalAddress32"}, | 111 | |
| 110 | {0x55, nullptr, "QueryIoMapping32"}, | 112 | static void SvcWrap_SetMemoryAttribute64From32(Core::System& system) { |
| 111 | {0x56, nullptr, "CreateDeviceAddressSpace32"}, | 113 | Result ret{}; |
| 112 | {0x57, nullptr, "AttachDeviceAddressSpace32"}, | 114 | |
| 113 | {0x58, nullptr, "DetachDeviceAddressSpace32"}, | 115 | uint32_t address{}; |
| 114 | {0x59, nullptr, "MapDeviceAddressSpaceByForce32"}, | 116 | uint32_t size{}; |
| 115 | {0x5a, nullptr, "MapDeviceAddressSpaceAligned32"}, | 117 | uint32_t mask{}; |
| 116 | {0x5b, nullptr, "MapDeviceAddressSpace32"}, | 118 | uint32_t attr{}; |
| 117 | {0x5c, nullptr, "UnmapDeviceAddressSpace32"}, | 119 | |
| 118 | {0x5d, nullptr, "InvalidateProcessDataCache32"}, | 120 | address = Convert<uint32_t>(GetReg32(system, 0)); |
| 119 | {0x5e, nullptr, "StoreProcessDataCache32"}, | 121 | size = Convert<uint32_t>(GetReg32(system, 1)); |
| 120 | {0x5F, SvcWrap32<FlushProcessDataCache32>, "FlushProcessDataCache32"}, | 122 | mask = Convert<uint32_t>(GetReg32(system, 2)); |
| 121 | {0x60, nullptr, "StoreProcessDataCache32"}, | 123 | attr = Convert<uint32_t>(GetReg32(system, 3)); |
| 122 | {0x61, nullptr, "BreakDebugProcess32"}, | 124 | |
| 123 | {0x62, nullptr, "TerminateDebugProcess32"}, | 125 | ret = SetMemoryAttribute64From32(system, address, size, mask, attr); |
| 124 | {0x63, nullptr, "GetDebugEvent32"}, | 126 | |
| 125 | {0x64, nullptr, "ContinueDebugEvent32"}, | 127 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 126 | {0x65, nullptr, "GetProcessList32"}, | 128 | } |
| 127 | {0x66, nullptr, "GetThreadList"}, | 129 | |
| 128 | {0x67, nullptr, "GetDebugThreadContext32"}, | 130 | static void SvcWrap_MapMemory64From32(Core::System& system) { |
| 129 | {0x68, nullptr, "SetDebugThreadContext32"}, | 131 | Result ret{}; |
| 130 | {0x69, nullptr, "QueryDebugProcessMemory32"}, | 132 | |
| 131 | {0x6A, nullptr, "ReadDebugProcessMemory32"}, | 133 | uint32_t dst_address{}; |
| 132 | {0x6B, nullptr, "WriteDebugProcessMemory32"}, | 134 | uint32_t src_address{}; |
| 133 | {0x6C, nullptr, "SetHardwareBreakPoint32"}, | 135 | uint32_t size{}; |
| 134 | {0x6D, nullptr, "GetDebugThreadParam32"}, | 136 | |
| 135 | {0x6E, nullptr, "Unknown6E"}, | 137 | dst_address = Convert<uint32_t>(GetReg32(system, 0)); |
| 136 | {0x6f, nullptr, "GetSystemInfo32"}, | 138 | src_address = Convert<uint32_t>(GetReg32(system, 1)); |
| 137 | {0x70, nullptr, "CreatePort32"}, | 139 | size = Convert<uint32_t>(GetReg32(system, 2)); |
| 138 | {0x71, nullptr, "ManageNamedPort32"}, | 140 | |
| 139 | {0x72, nullptr, "ConnectToPort32"}, | 141 | ret = MapMemory64From32(system, dst_address, src_address, size); |
| 140 | {0x73, nullptr, "SetProcessMemoryPermission32"}, | 142 | |
| 141 | {0x74, nullptr, "MapProcessMemory32"}, | 143 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 142 | {0x75, nullptr, "UnmapProcessMemory32"}, | 144 | } |
| 143 | {0x76, nullptr, "QueryProcessMemory32"}, | 145 | |
| 144 | {0x77, nullptr, "MapProcessCodeMemory32"}, | 146 | static void SvcWrap_UnmapMemory64From32(Core::System& system) { |
| 145 | {0x78, nullptr, "UnmapProcessCodeMemory32"}, | 147 | Result ret{}; |
| 146 | {0x79, nullptr, "CreateProcess32"}, | 148 | |
| 147 | {0x7A, nullptr, "StartProcess32"}, | 149 | uint32_t dst_address{}; |
| 148 | {0x7B, nullptr, "TerminateProcess32"}, | 150 | uint32_t src_address{}; |
| 149 | {0x7C, nullptr, "GetProcessInfo32"}, | 151 | uint32_t size{}; |
| 150 | {0x7D, nullptr, "CreateResourceLimit32"}, | 152 | |
| 151 | {0x7E, nullptr, "SetResourceLimitLimitValue32"}, | 153 | dst_address = Convert<uint32_t>(GetReg32(system, 0)); |
| 152 | {0x7F, nullptr, "CallSecureMonitor32"}, | 154 | src_address = Convert<uint32_t>(GetReg32(system, 1)); |
| 153 | {0x80, nullptr, "Unknown"}, | 155 | size = Convert<uint32_t>(GetReg32(system, 2)); |
| 154 | {0x81, nullptr, "Unknown"}, | 156 | |
| 155 | {0x82, nullptr, "Unknown"}, | 157 | ret = UnmapMemory64From32(system, dst_address, src_address, size); |
| 156 | {0x83, nullptr, "Unknown"}, | 158 | |
| 157 | {0x84, nullptr, "Unknown"}, | 159 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 158 | {0x85, nullptr, "Unknown"}, | 160 | } |
| 159 | {0x86, nullptr, "Unknown"}, | 161 | |
| 160 | {0x87, nullptr, "Unknown"}, | 162 | static void SvcWrap_QueryMemory64From32(Core::System& system) { |
| 161 | {0x88, nullptr, "Unknown"}, | 163 | Result ret{}; |
| 162 | {0x89, nullptr, "Unknown"}, | 164 | |
| 163 | {0x8A, nullptr, "Unknown"}, | 165 | PageInfo out_page_info{}; |
| 164 | {0x8B, nullptr, "Unknown"}, | 166 | uint32_t out_memory_info{}; |
| 165 | {0x8C, nullptr, "Unknown"}, | 167 | uint32_t address{}; |
| 166 | {0x8D, nullptr, "Unknown"}, | 168 | |
| 167 | {0x8E, nullptr, "Unknown"}, | 169 | out_memory_info = Convert<uint32_t>(GetReg32(system, 0)); |
| 168 | {0x8F, nullptr, "Unknown"}, | 170 | address = Convert<uint32_t>(GetReg32(system, 2)); |
| 169 | {0x90, nullptr, "Unknown"}, | 171 | |
| 170 | {0x91, nullptr, "Unknown"}, | 172 | ret = QueryMemory64From32(system, out_memory_info, &out_page_info, address); |
| 171 | {0x92, nullptr, "Unknown"}, | 173 | |
| 172 | {0x93, nullptr, "Unknown"}, | 174 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 173 | {0x94, nullptr, "Unknown"}, | 175 | SetReg32(system, 1, Convert<uint32_t>(out_page_info)); |
| 174 | {0x95, nullptr, "Unknown"}, | 176 | } |
| 175 | {0x96, nullptr, "Unknown"}, | 177 | |
| 176 | {0x97, nullptr, "Unknown"}, | 178 | static void SvcWrap_ExitProcess64From32(Core::System& system) { |
| 177 | {0x98, nullptr, "Unknown"}, | 179 | ExitProcess64From32(system); |
| 178 | {0x99, nullptr, "Unknown"}, | 180 | } |
| 179 | {0x9A, nullptr, "Unknown"}, | 181 | |
| 180 | {0x9B, nullptr, "Unknown"}, | 182 | static void SvcWrap_CreateThread64From32(Core::System& system) { |
| 181 | {0x9C, nullptr, "Unknown"}, | 183 | Result ret{}; |
| 182 | {0x9D, nullptr, "Unknown"}, | 184 | |
| 183 | {0x9E, nullptr, "Unknown"}, | 185 | Handle out_handle{}; |
| 184 | {0x9F, nullptr, "Unknown"}, | 186 | uint32_t func{}; |
| 185 | {0xA0, nullptr, "Unknown"}, | 187 | uint32_t arg{}; |
| 186 | {0xA1, nullptr, "Unknown"}, | 188 | uint32_t stack_bottom{}; |
| 187 | {0xA2, nullptr, "Unknown"}, | 189 | int32_t priority{}; |
| 188 | {0xA3, nullptr, "Unknown"}, | 190 | int32_t core_id{}; |
| 189 | {0xA4, nullptr, "Unknown"}, | 191 | |
| 190 | {0xA5, nullptr, "Unknown"}, | 192 | func = Convert<uint32_t>(GetReg32(system, 1)); |
| 191 | {0xA6, nullptr, "Unknown"}, | 193 | arg = Convert<uint32_t>(GetReg32(system, 2)); |
| 192 | {0xA7, nullptr, "Unknown"}, | 194 | stack_bottom = Convert<uint32_t>(GetReg32(system, 3)); |
| 193 | {0xA8, nullptr, "Unknown"}, | 195 | priority = Convert<int32_t>(GetReg32(system, 0)); |
| 194 | {0xA9, nullptr, "Unknown"}, | 196 | core_id = Convert<int32_t>(GetReg32(system, 4)); |
| 195 | {0xAA, nullptr, "Unknown"}, | 197 | |
| 196 | {0xAB, nullptr, "Unknown"}, | 198 | ret = CreateThread64From32(system, &out_handle, func, arg, stack_bottom, priority, core_id); |
| 197 | {0xAC, nullptr, "Unknown"}, | 199 | |
| 198 | {0xAD, nullptr, "Unknown"}, | 200 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 199 | {0xAE, nullptr, "Unknown"}, | 201 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); |
| 200 | {0xAF, nullptr, "Unknown"}, | 202 | } |
| 201 | {0xB0, nullptr, "Unknown"}, | 203 | |
| 202 | {0xB1, nullptr, "Unknown"}, | 204 | static void SvcWrap_StartThread64From32(Core::System& system) { |
| 203 | {0xB2, nullptr, "Unknown"}, | 205 | Result ret{}; |
| 204 | {0xB3, nullptr, "Unknown"}, | 206 | |
| 205 | {0xB4, nullptr, "Unknown"}, | 207 | Handle thread_handle{}; |
| 206 | {0xB5, nullptr, "Unknown"}, | 208 | |
| 207 | {0xB6, nullptr, "Unknown"}, | 209 | thread_handle = Convert<Handle>(GetReg32(system, 0)); |
| 208 | {0xB7, nullptr, "Unknown"}, | 210 | |
| 209 | {0xB8, nullptr, "Unknown"}, | 211 | ret = StartThread64From32(system, thread_handle); |
| 210 | {0xB9, nullptr, "Unknown"}, | 212 | |
| 211 | {0xBA, nullptr, "Unknown"}, | 213 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 212 | {0xBB, nullptr, "Unknown"}, | 214 | } |
| 213 | {0xBC, nullptr, "Unknown"}, | 215 | |
| 214 | {0xBD, nullptr, "Unknown"}, | 216 | static void SvcWrap_ExitThread64From32(Core::System& system) { |
| 215 | {0xBE, nullptr, "Unknown"}, | 217 | ExitThread64From32(system); |
| 216 | {0xBF, nullptr, "Unknown"}, | 218 | } |
| 217 | }; | 219 | |
| 218 | 220 | static void SvcWrap_SleepThread64From32(Core::System& system) { | |
| 219 | static const FunctionDef SVC_Table_64[] = { | 221 | int64_t ns{}; |
| 220 | {0x00, nullptr, "Unknown0"}, | 222 | |
| 221 | {0x01, SvcWrap64<SetHeapSize>, "SetHeapSize"}, | 223 | std::array<uint32_t, 2> ns_gather{}; |
| 222 | {0x02, SvcWrap64<SetMemoryPermission>, "SetMemoryPermission"}, | 224 | ns_gather[0] = GetReg32(system, 0); |
| 223 | {0x03, SvcWrap64<SetMemoryAttribute>, "SetMemoryAttribute"}, | 225 | ns_gather[1] = GetReg32(system, 1); |
| 224 | {0x04, SvcWrap64<MapMemory>, "MapMemory"}, | 226 | ns = Convert<int64_t>(ns_gather); |
| 225 | {0x05, SvcWrap64<UnmapMemory>, "UnmapMemory"}, | 227 | |
| 226 | {0x06, SvcWrap64<QueryMemory>, "QueryMemory"}, | 228 | SleepThread64From32(system, ns); |
| 227 | {0x07, SvcWrap64<ExitProcess>, "ExitProcess"}, | 229 | } |
| 228 | {0x08, SvcWrap64<CreateThread>, "CreateThread"}, | 230 | |
| 229 | {0x09, SvcWrap64<StartThread>, "StartThread"}, | 231 | static void SvcWrap_GetThreadPriority64From32(Core::System& system) { |
| 230 | {0x0A, SvcWrap64<ExitThread>, "ExitThread"}, | 232 | Result ret{}; |
| 231 | {0x0B, SvcWrap64<SleepThread>, "SleepThread"}, | 233 | |
| 232 | {0x0C, SvcWrap64<GetThreadPriority>, "GetThreadPriority"}, | 234 | int32_t out_priority{}; |
| 233 | {0x0D, SvcWrap64<SetThreadPriority>, "SetThreadPriority"}, | 235 | Handle thread_handle{}; |
| 234 | {0x0E, SvcWrap64<GetThreadCoreMask>, "GetThreadCoreMask"}, | 236 | |
| 235 | {0x0F, SvcWrap64<SetThreadCoreMask>, "SetThreadCoreMask"}, | 237 | thread_handle = Convert<Handle>(GetReg32(system, 1)); |
| 236 | {0x10, SvcWrap64<GetCurrentProcessorNumber>, "GetCurrentProcessorNumber"}, | 238 | |
| 237 | {0x11, SvcWrap64<SignalEvent>, "SignalEvent"}, | 239 | ret = GetThreadPriority64From32(system, &out_priority, thread_handle); |
| 238 | {0x12, SvcWrap64<ClearEvent>, "ClearEvent"}, | 240 | |
| 239 | {0x13, SvcWrap64<MapSharedMemory>, "MapSharedMemory"}, | 241 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 240 | {0x14, SvcWrap64<UnmapSharedMemory>, "UnmapSharedMemory"}, | 242 | SetReg32(system, 1, Convert<uint32_t>(out_priority)); |
| 241 | {0x15, SvcWrap64<CreateTransferMemory>, "CreateTransferMemory"}, | 243 | } |
| 242 | {0x16, SvcWrap64<CloseHandle>, "CloseHandle"}, | 244 | |
| 243 | {0x17, SvcWrap64<ResetSignal>, "ResetSignal"}, | 245 | static void SvcWrap_SetThreadPriority64From32(Core::System& system) { |
| 244 | {0x18, SvcWrap64<WaitSynchronization>, "WaitSynchronization"}, | 246 | Result ret{}; |
| 245 | {0x19, SvcWrap64<CancelSynchronization>, "CancelSynchronization"}, | 247 | |
| 246 | {0x1A, SvcWrap64<ArbitrateLock>, "ArbitrateLock"}, | 248 | Handle thread_handle{}; |
| 247 | {0x1B, SvcWrap64<ArbitrateUnlock>, "ArbitrateUnlock"}, | 249 | int32_t priority{}; |
| 248 | {0x1C, SvcWrap64<WaitProcessWideKeyAtomic>, "WaitProcessWideKeyAtomic"}, | 250 | |
| 249 | {0x1D, SvcWrap64<SignalProcessWideKey>, "SignalProcessWideKey"}, | 251 | thread_handle = Convert<Handle>(GetReg32(system, 0)); |
| 250 | {0x1E, SvcWrap64<GetSystemTick>, "GetSystemTick"}, | 252 | priority = Convert<int32_t>(GetReg32(system, 1)); |
| 251 | {0x1F, SvcWrap64<ConnectToNamedPort>, "ConnectToNamedPort"}, | 253 | |
| 252 | {0x20, nullptr, "SendSyncRequestLight"}, | 254 | ret = SetThreadPriority64From32(system, thread_handle, priority); |
| 253 | {0x21, SvcWrap64<SendSyncRequest>, "SendSyncRequest"}, | 255 | |
| 254 | {0x22, nullptr, "SendSyncRequestWithUserBuffer"}, | 256 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 255 | {0x23, nullptr, "SendAsyncRequestWithUserBuffer"}, | 257 | } |
| 256 | {0x24, SvcWrap64<GetProcessId>, "GetProcessId"}, | 258 | |
| 257 | {0x25, SvcWrap64<GetThreadId>, "GetThreadId"}, | 259 | static void SvcWrap_GetThreadCoreMask64From32(Core::System& system) { |
| 258 | {0x26, SvcWrap64<Break>, "Break"}, | 260 | Result ret{}; |
| 259 | {0x27, SvcWrap64<OutputDebugString>, "OutputDebugString"}, | 261 | |
| 260 | {0x28, nullptr, "ReturnFromException"}, | 262 | int32_t out_core_id{}; |
| 261 | {0x29, SvcWrap64<GetInfo>, "GetInfo"}, | 263 | uint64_t out_affinity_mask{}; |
| 262 | {0x2A, nullptr, "FlushEntireDataCache"}, | 264 | Handle thread_handle{}; |
| 263 | {0x2B, nullptr, "FlushDataCache"}, | 265 | |
| 264 | {0x2C, SvcWrap64<MapPhysicalMemory>, "MapPhysicalMemory"}, | 266 | thread_handle = Convert<Handle>(GetReg32(system, 2)); |
| 265 | {0x2D, SvcWrap64<UnmapPhysicalMemory>, "UnmapPhysicalMemory"}, | 267 | |
| 266 | {0x2E, nullptr, "GetFutureThreadInfo"}, | 268 | ret = GetThreadCoreMask64From32(system, &out_core_id, &out_affinity_mask, thread_handle); |
| 267 | {0x2F, nullptr, "GetLastThreadInfo"}, | 269 | |
| 268 | {0x30, SvcWrap64<GetResourceLimitLimitValue>, "GetResourceLimitLimitValue"}, | 270 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 269 | {0x31, SvcWrap64<GetResourceLimitCurrentValue>, "GetResourceLimitCurrentValue"}, | 271 | SetReg32(system, 1, Convert<uint32_t>(out_core_id)); |
| 270 | {0x32, SvcWrap64<SetThreadActivity>, "SetThreadActivity"}, | 272 | auto out_affinity_mask_scatter = Convert<std::array<uint32_t, 2>>(out_affinity_mask); |
| 271 | {0x33, SvcWrap64<GetThreadContext>, "GetThreadContext"}, | 273 | SetReg32(system, 2, out_affinity_mask_scatter[0]); |
| 272 | {0x34, SvcWrap64<WaitForAddress>, "WaitForAddress"}, | 274 | SetReg32(system, 3, out_affinity_mask_scatter[1]); |
| 273 | {0x35, SvcWrap64<SignalToAddress>, "SignalToAddress"}, | 275 | } |
| 274 | {0x36, SvcWrap64<SynchronizePreemptionState>, "SynchronizePreemptionState"}, | 276 | |
| 275 | {0x37, nullptr, "GetResourceLimitPeakValue"}, | 277 | static void SvcWrap_SetThreadCoreMask64From32(Core::System& system) { |
| 276 | {0x38, nullptr, "Unknown38"}, | 278 | Result ret{}; |
| 277 | {0x39, nullptr, "CreateIoPool"}, | 279 | |
| 278 | {0x3A, nullptr, "CreateIoRegion"}, | 280 | Handle thread_handle{}; |
| 279 | {0x3B, nullptr, "Unknown3B"}, | 281 | int32_t core_id{}; |
| 280 | {0x3C, SvcWrap64<KernelDebug>, "KernelDebug"}, | 282 | uint64_t affinity_mask{}; |
| 281 | {0x3D, SvcWrap64<ChangeKernelTraceState>, "ChangeKernelTraceState"}, | 283 | |
| 282 | {0x3E, nullptr, "Unknown3e"}, | 284 | thread_handle = Convert<Handle>(GetReg32(system, 0)); |
| 283 | {0x3F, nullptr, "Unknown3f"}, | 285 | core_id = Convert<int32_t>(GetReg32(system, 1)); |
| 284 | {0x40, SvcWrap64<CreateSession>, "CreateSession"}, | 286 | std::array<uint32_t, 2> affinity_mask_gather{}; |
| 285 | {0x41, nullptr, "AcceptSession"}, | 287 | affinity_mask_gather[0] = GetReg32(system, 2); |
| 286 | {0x42, nullptr, "ReplyAndReceiveLight"}, | 288 | affinity_mask_gather[1] = GetReg32(system, 3); |
| 287 | {0x43, SvcWrap64<ReplyAndReceive>, "ReplyAndReceive"}, | 289 | affinity_mask = Convert<uint64_t>(affinity_mask_gather); |
| 288 | {0x44, nullptr, "ReplyAndReceiveWithUserBuffer"}, | 290 | |
| 289 | {0x45, SvcWrap64<CreateEvent>, "CreateEvent"}, | 291 | ret = SetThreadCoreMask64From32(system, thread_handle, core_id, affinity_mask); |
| 290 | {0x46, nullptr, "MapIoRegion"}, | 292 | |
| 291 | {0x47, nullptr, "UnmapIoRegion"}, | 293 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 292 | {0x48, nullptr, "MapPhysicalMemoryUnsafe"}, | 294 | } |
| 293 | {0x49, nullptr, "UnmapPhysicalMemoryUnsafe"}, | 295 | |
| 294 | {0x4A, nullptr, "SetUnsafeLimit"}, | 296 | static void SvcWrap_GetCurrentProcessorNumber64From32(Core::System& system) { |
| 295 | {0x4B, SvcWrap64<CreateCodeMemory>, "CreateCodeMemory"}, | 297 | int32_t ret{}; |
| 296 | {0x4C, SvcWrap64<ControlCodeMemory>, "ControlCodeMemory"}, | 298 | |
| 297 | {0x4D, nullptr, "SleepSystem"}, | 299 | ret = GetCurrentProcessorNumber64From32(system); |
| 298 | {0x4E, nullptr, "ReadWriteRegister"}, | 300 | |
| 299 | {0x4F, nullptr, "SetProcessActivity"}, | 301 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 300 | {0x50, nullptr, "CreateSharedMemory"}, | 302 | } |
| 301 | {0x51, nullptr, "MapTransferMemory"}, | 303 | |
| 302 | {0x52, nullptr, "UnmapTransferMemory"}, | 304 | static void SvcWrap_SignalEvent64From32(Core::System& system) { |
| 303 | {0x53, nullptr, "CreateInterruptEvent"}, | 305 | Result ret{}; |
| 304 | {0x54, nullptr, "QueryPhysicalAddress"}, | 306 | |
| 305 | {0x55, nullptr, "QueryIoMapping"}, | 307 | Handle event_handle{}; |
| 306 | {0x56, nullptr, "CreateDeviceAddressSpace"}, | 308 | |
| 307 | {0x57, nullptr, "AttachDeviceAddressSpace"}, | 309 | event_handle = Convert<Handle>(GetReg32(system, 0)); |
| 308 | {0x58, nullptr, "DetachDeviceAddressSpace"}, | 310 | |
| 309 | {0x59, nullptr, "MapDeviceAddressSpaceByForce"}, | 311 | ret = SignalEvent64From32(system, event_handle); |
| 310 | {0x5A, nullptr, "MapDeviceAddressSpaceAligned"}, | 312 | |
| 311 | {0x5B, nullptr, "MapDeviceAddressSpace"}, | 313 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 312 | {0x5C, nullptr, "UnmapDeviceAddressSpace"}, | 314 | } |
| 313 | {0x5D, nullptr, "InvalidateProcessDataCache"}, | 315 | |
| 314 | {0x5E, nullptr, "StoreProcessDataCache"}, | 316 | static void SvcWrap_ClearEvent64From32(Core::System& system) { |
| 315 | {0x5F, nullptr, "FlushProcessDataCache"}, | 317 | Result ret{}; |
| 316 | {0x60, nullptr, "DebugActiveProcess"}, | 318 | |
| 317 | {0x61, nullptr, "BreakDebugProcess"}, | 319 | Handle event_handle{}; |
| 318 | {0x62, nullptr, "TerminateDebugProcess"}, | 320 | |
| 319 | {0x63, nullptr, "GetDebugEvent"}, | 321 | event_handle = Convert<Handle>(GetReg32(system, 0)); |
| 320 | {0x64, nullptr, "ContinueDebugEvent"}, | 322 | |
| 321 | {0x65, SvcWrap64<GetProcessList>, "GetProcessList"}, | 323 | ret = ClearEvent64From32(system, event_handle); |
| 322 | {0x66, SvcWrap64<GetThreadList>, "GetThreadList"}, | 324 | |
| 323 | {0x67, nullptr, "GetDebugThreadContext"}, | 325 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 324 | {0x68, nullptr, "SetDebugThreadContext"}, | 326 | } |
| 325 | {0x69, nullptr, "QueryDebugProcessMemory"}, | 327 | |
| 326 | {0x6A, nullptr, "ReadDebugProcessMemory"}, | 328 | static void SvcWrap_MapSharedMemory64From32(Core::System& system) { |
| 327 | {0x6B, nullptr, "WriteDebugProcessMemory"}, | 329 | Result ret{}; |
| 328 | {0x6C, nullptr, "SetHardwareBreakPoint"}, | 330 | |
| 329 | {0x6D, nullptr, "GetDebugThreadParam"}, | 331 | Handle shmem_handle{}; |
| 330 | {0x6E, nullptr, "Unknown6E"}, | 332 | uint32_t address{}; |
| 331 | {0x6F, nullptr, "GetSystemInfo"}, | 333 | uint32_t size{}; |
| 332 | {0x70, nullptr, "CreatePort"}, | 334 | MemoryPermission map_perm{}; |
| 333 | {0x71, nullptr, "ManageNamedPort"}, | 335 | |
| 334 | {0x72, nullptr, "ConnectToPort"}, | 336 | shmem_handle = Convert<Handle>(GetReg32(system, 0)); |
| 335 | {0x73, SvcWrap64<SetProcessMemoryPermission>, "SetProcessMemoryPermission"}, | 337 | address = Convert<uint32_t>(GetReg32(system, 1)); |
| 336 | {0x74, SvcWrap64<MapProcessMemory>, "MapProcessMemory"}, | 338 | size = Convert<uint32_t>(GetReg32(system, 2)); |
| 337 | {0x75, SvcWrap64<UnmapProcessMemory>, "UnmapProcessMemory"}, | 339 | map_perm = Convert<MemoryPermission>(GetReg32(system, 3)); |
| 338 | {0x76, SvcWrap64<QueryProcessMemory>, "QueryProcessMemory"}, | 340 | |
| 339 | {0x77, SvcWrap64<MapProcessCodeMemory>, "MapProcessCodeMemory"}, | 341 | ret = MapSharedMemory64From32(system, shmem_handle, address, size, map_perm); |
| 340 | {0x78, SvcWrap64<UnmapProcessCodeMemory>, "UnmapProcessCodeMemory"}, | 342 | |
| 341 | {0x79, nullptr, "CreateProcess"}, | 343 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 342 | {0x7A, nullptr, "StartProcess"}, | 344 | } |
| 343 | {0x7B, nullptr, "TerminateProcess"}, | 345 | |
| 344 | {0x7C, SvcWrap64<GetProcessInfo>, "GetProcessInfo"}, | 346 | static void SvcWrap_UnmapSharedMemory64From32(Core::System& system) { |
| 345 | {0x7D, SvcWrap64<CreateResourceLimit>, "CreateResourceLimit"}, | 347 | Result ret{}; |
| 346 | {0x7E, SvcWrap64<SetResourceLimitLimitValue>, "SetResourceLimitLimitValue"}, | 348 | |
| 347 | {0x7F, nullptr, "CallSecureMonitor"}, | 349 | Handle shmem_handle{}; |
| 348 | {0x80, nullptr, "Unknown"}, | 350 | uint32_t address{}; |
| 349 | {0x81, nullptr, "Unknown"}, | 351 | uint32_t size{}; |
| 350 | {0x82, nullptr, "Unknown"}, | 352 | |
| 351 | {0x83, nullptr, "Unknown"}, | 353 | shmem_handle = Convert<Handle>(GetReg32(system, 0)); |
| 352 | {0x84, nullptr, "Unknown"}, | 354 | address = Convert<uint32_t>(GetReg32(system, 1)); |
| 353 | {0x85, nullptr, "Unknown"}, | 355 | size = Convert<uint32_t>(GetReg32(system, 2)); |
| 354 | {0x86, nullptr, "Unknown"}, | 356 | |
| 355 | {0x87, nullptr, "Unknown"}, | 357 | ret = UnmapSharedMemory64From32(system, shmem_handle, address, size); |
| 356 | {0x88, nullptr, "Unknown"}, | 358 | |
| 357 | {0x89, nullptr, "Unknown"}, | 359 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 358 | {0x8A, nullptr, "Unknown"}, | 360 | } |
| 359 | {0x8B, nullptr, "Unknown"}, | 361 | |
| 360 | {0x8C, nullptr, "Unknown"}, | 362 | static void SvcWrap_CreateTransferMemory64From32(Core::System& system) { |
| 361 | {0x8D, nullptr, "Unknown"}, | 363 | Result ret{}; |
| 362 | {0x8E, nullptr, "Unknown"}, | 364 | |
| 363 | {0x8F, nullptr, "Unknown"}, | 365 | Handle out_handle{}; |
| 364 | {0x90, nullptr, "Unknown"}, | 366 | uint32_t address{}; |
| 365 | {0x91, nullptr, "Unknown"}, | 367 | uint32_t size{}; |
| 366 | {0x92, nullptr, "Unknown"}, | 368 | MemoryPermission map_perm{}; |
| 367 | {0x93, nullptr, "Unknown"}, | 369 | |
| 368 | {0x94, nullptr, "Unknown"}, | 370 | address = Convert<uint32_t>(GetReg32(system, 1)); |
| 369 | {0x95, nullptr, "Unknown"}, | 371 | size = Convert<uint32_t>(GetReg32(system, 2)); |
| 370 | {0x96, nullptr, "Unknown"}, | 372 | map_perm = Convert<MemoryPermission>(GetReg32(system, 3)); |
| 371 | {0x97, nullptr, "Unknown"}, | 373 | |
| 372 | {0x98, nullptr, "Unknown"}, | 374 | ret = CreateTransferMemory64From32(system, &out_handle, address, size, map_perm); |
| 373 | {0x99, nullptr, "Unknown"}, | 375 | |
| 374 | {0x9A, nullptr, "Unknown"}, | 376 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 375 | {0x9B, nullptr, "Unknown"}, | 377 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); |
| 376 | {0x9C, nullptr, "Unknown"}, | 378 | } |
| 377 | {0x9D, nullptr, "Unknown"}, | 379 | |
| 378 | {0x9E, nullptr, "Unknown"}, | 380 | static void SvcWrap_CloseHandle64From32(Core::System& system) { |
| 379 | {0x9F, nullptr, "Unknown"}, | 381 | Result ret{}; |
| 380 | {0xA0, nullptr, "Unknown"}, | 382 | |
| 381 | {0xA1, nullptr, "Unknown"}, | 383 | Handle handle{}; |
| 382 | {0xA2, nullptr, "Unknown"}, | 384 | |
| 383 | {0xA3, nullptr, "Unknown"}, | 385 | handle = Convert<Handle>(GetReg32(system, 0)); |
| 384 | {0xA4, nullptr, "Unknown"}, | 386 | |
| 385 | {0xA5, nullptr, "Unknown"}, | 387 | ret = CloseHandle64From32(system, handle); |
| 386 | {0xA6, nullptr, "Unknown"}, | 388 | |
| 387 | {0xA7, nullptr, "Unknown"}, | 389 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 388 | {0xA8, nullptr, "Unknown"}, | 390 | } |
| 389 | {0xA9, nullptr, "Unknown"}, | 391 | |
| 390 | {0xAA, nullptr, "Unknown"}, | 392 | static void SvcWrap_ResetSignal64From32(Core::System& system) { |
| 391 | {0xAB, nullptr, "Unknown"}, | 393 | Result ret{}; |
| 392 | {0xAC, nullptr, "Unknown"}, | 394 | |
| 393 | {0xAD, nullptr, "Unknown"}, | 395 | Handle handle{}; |
| 394 | {0xAE, nullptr, "Unknown"}, | 396 | |
| 395 | {0xAF, nullptr, "Unknown"}, | 397 | handle = Convert<Handle>(GetReg32(system, 0)); |
| 396 | {0xB0, nullptr, "Unknown"}, | 398 | |
| 397 | {0xB1, nullptr, "Unknown"}, | 399 | ret = ResetSignal64From32(system, handle); |
| 398 | {0xB2, nullptr, "Unknown"}, | 400 | |
| 399 | {0xB3, nullptr, "Unknown"}, | 401 | SetReg32(system, 0, Convert<uint32_t>(ret)); |
| 400 | {0xB4, nullptr, "Unknown"}, | 402 | } |
| 401 | {0xB5, nullptr, "Unknown"}, | 403 | |
| 402 | {0xB6, nullptr, "Unknown"}, | 404 | static void SvcWrap_WaitSynchronization64From32(Core::System& system) { |
| 403 | {0xB7, nullptr, "Unknown"}, | 405 | Result ret{}; |
| 404 | {0xB8, nullptr, "Unknown"}, | 406 | |
| 405 | {0xB9, nullptr, "Unknown"}, | 407 | int32_t out_index{}; |
| 406 | {0xBA, nullptr, "Unknown"}, | 408 | uint32_t handles{}; |
| 407 | {0xBB, nullptr, "Unknown"}, | 409 | int32_t num_handles{}; |
| 408 | {0xBC, nullptr, "Unknown"}, | 410 | int64_t timeout_ns{}; |
| 409 | {0xBD, nullptr, "Unknown"}, | 411 | |
| 410 | {0xBE, nullptr, "Unknown"}, | 412 | handles = Convert<uint32_t>(GetReg32(system, 1)); |
| 411 | {0xBF, nullptr, "Unknown"}, | 413 | num_handles = Convert<int32_t>(GetReg32(system, 2)); |
| 412 | }; | 414 | std::array<uint32_t, 2> timeout_ns_gather{}; |
| 413 | 415 | timeout_ns_gather[0] = GetReg32(system, 0); | |
| 414 | static const FunctionDef* GetSVCInfo32(u32 func_num) { | 416 | timeout_ns_gather[1] = GetReg32(system, 3); |
| 415 | if (func_num >= std::size(SVC_Table_32)) { | 417 | timeout_ns = Convert<int64_t>(timeout_ns_gather); |
| 416 | LOG_ERROR(Kernel_SVC, "Unknown svc=0x{:02X}", func_num); | 418 | |
| 417 | return nullptr; | 419 | ret = WaitSynchronization64From32(system, &out_index, handles, num_handles, timeout_ns); |
| 420 | |||
| 421 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 422 | SetReg32(system, 1, Convert<uint32_t>(out_index)); | ||
| 423 | } | ||
| 424 | |||
| 425 | static void SvcWrap_CancelSynchronization64From32(Core::System& system) { | ||
| 426 | Result ret{}; | ||
| 427 | |||
| 428 | Handle handle{}; | ||
| 429 | |||
| 430 | handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 431 | |||
| 432 | ret = CancelSynchronization64From32(system, handle); | ||
| 433 | |||
| 434 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 435 | } | ||
| 436 | |||
| 437 | static void SvcWrap_ArbitrateLock64From32(Core::System& system) { | ||
| 438 | Result ret{}; | ||
| 439 | |||
| 440 | Handle thread_handle{}; | ||
| 441 | uint32_t address{}; | ||
| 442 | uint32_t tag{}; | ||
| 443 | |||
| 444 | thread_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 445 | address = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 446 | tag = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 447 | |||
| 448 | ret = ArbitrateLock64From32(system, thread_handle, address, tag); | ||
| 449 | |||
| 450 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 451 | } | ||
| 452 | |||
| 453 | static void SvcWrap_ArbitrateUnlock64From32(Core::System& system) { | ||
| 454 | Result ret{}; | ||
| 455 | |||
| 456 | uint32_t address{}; | ||
| 457 | |||
| 458 | address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 459 | |||
| 460 | ret = ArbitrateUnlock64From32(system, address); | ||
| 461 | |||
| 462 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 463 | } | ||
| 464 | |||
| 465 | static void SvcWrap_WaitProcessWideKeyAtomic64From32(Core::System& system) { | ||
| 466 | Result ret{}; | ||
| 467 | |||
| 468 | uint32_t address{}; | ||
| 469 | uint32_t cv_key{}; | ||
| 470 | uint32_t tag{}; | ||
| 471 | int64_t timeout_ns{}; | ||
| 472 | |||
| 473 | address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 474 | cv_key = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 475 | tag = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 476 | std::array<uint32_t, 2> timeout_ns_gather{}; | ||
| 477 | timeout_ns_gather[0] = GetReg32(system, 3); | ||
| 478 | timeout_ns_gather[1] = GetReg32(system, 4); | ||
| 479 | timeout_ns = Convert<int64_t>(timeout_ns_gather); | ||
| 480 | |||
| 481 | ret = WaitProcessWideKeyAtomic64From32(system, address, cv_key, tag, timeout_ns); | ||
| 482 | |||
| 483 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 484 | } | ||
| 485 | |||
| 486 | static void SvcWrap_SignalProcessWideKey64From32(Core::System& system) { | ||
| 487 | uint32_t cv_key{}; | ||
| 488 | int32_t count{}; | ||
| 489 | |||
| 490 | cv_key = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 491 | count = Convert<int32_t>(GetReg32(system, 1)); | ||
| 492 | |||
| 493 | SignalProcessWideKey64From32(system, cv_key, count); | ||
| 494 | } | ||
| 495 | |||
| 496 | static void SvcWrap_GetSystemTick64From32(Core::System& system) { | ||
| 497 | int64_t ret{}; | ||
| 498 | |||
| 499 | ret = GetSystemTick64From32(system); | ||
| 500 | |||
| 501 | auto ret_scatter = Convert<std::array<uint32_t, 2>>(ret); | ||
| 502 | SetReg32(system, 0, ret_scatter[0]); | ||
| 503 | SetReg32(system, 1, ret_scatter[1]); | ||
| 504 | } | ||
| 505 | |||
| 506 | static void SvcWrap_ConnectToNamedPort64From32(Core::System& system) { | ||
| 507 | Result ret{}; | ||
| 508 | |||
| 509 | Handle out_handle{}; | ||
| 510 | uint32_t name{}; | ||
| 511 | |||
| 512 | name = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 513 | |||
| 514 | ret = ConnectToNamedPort64From32(system, &out_handle, name); | ||
| 515 | |||
| 516 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 517 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | ||
| 518 | } | ||
| 519 | |||
| 520 | static void SvcWrap_SendSyncRequest64From32(Core::System& system) { | ||
| 521 | Result ret{}; | ||
| 522 | |||
| 523 | Handle session_handle{}; | ||
| 524 | |||
| 525 | session_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 526 | |||
| 527 | ret = SendSyncRequest64From32(system, session_handle); | ||
| 528 | |||
| 529 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 530 | } | ||
| 531 | |||
| 532 | static void SvcWrap_SendSyncRequestWithUserBuffer64From32(Core::System& system) { | ||
| 533 | Result ret{}; | ||
| 534 | |||
| 535 | uint32_t message_buffer{}; | ||
| 536 | uint32_t message_buffer_size{}; | ||
| 537 | Handle session_handle{}; | ||
| 538 | |||
| 539 | message_buffer = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 540 | message_buffer_size = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 541 | session_handle = Convert<Handle>(GetReg32(system, 2)); | ||
| 542 | |||
| 543 | ret = SendSyncRequestWithUserBuffer64From32(system, message_buffer, message_buffer_size, session_handle); | ||
| 544 | |||
| 545 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 546 | } | ||
| 547 | |||
| 548 | static void SvcWrap_SendAsyncRequestWithUserBuffer64From32(Core::System& system) { | ||
| 549 | Result ret{}; | ||
| 550 | |||
| 551 | Handle out_event_handle{}; | ||
| 552 | uint32_t message_buffer{}; | ||
| 553 | uint32_t message_buffer_size{}; | ||
| 554 | Handle session_handle{}; | ||
| 555 | |||
| 556 | message_buffer = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 557 | message_buffer_size = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 558 | session_handle = Convert<Handle>(GetReg32(system, 3)); | ||
| 559 | |||
| 560 | ret = SendAsyncRequestWithUserBuffer64From32(system, &out_event_handle, message_buffer, message_buffer_size, session_handle); | ||
| 561 | |||
| 562 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 563 | SetReg32(system, 1, Convert<uint32_t>(out_event_handle)); | ||
| 564 | } | ||
| 565 | |||
| 566 | static void SvcWrap_GetProcessId64From32(Core::System& system) { | ||
| 567 | Result ret{}; | ||
| 568 | |||
| 569 | uint64_t out_process_id{}; | ||
| 570 | Handle process_handle{}; | ||
| 571 | |||
| 572 | process_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 573 | |||
| 574 | ret = GetProcessId64From32(system, &out_process_id, process_handle); | ||
| 575 | |||
| 576 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 577 | auto out_process_id_scatter = Convert<std::array<uint32_t, 2>>(out_process_id); | ||
| 578 | SetReg32(system, 1, out_process_id_scatter[0]); | ||
| 579 | SetReg32(system, 2, out_process_id_scatter[1]); | ||
| 580 | } | ||
| 581 | |||
| 582 | static void SvcWrap_GetThreadId64From32(Core::System& system) { | ||
| 583 | Result ret{}; | ||
| 584 | |||
| 585 | uint64_t out_thread_id{}; | ||
| 586 | Handle thread_handle{}; | ||
| 587 | |||
| 588 | thread_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 589 | |||
| 590 | ret = GetThreadId64From32(system, &out_thread_id, thread_handle); | ||
| 591 | |||
| 592 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 593 | auto out_thread_id_scatter = Convert<std::array<uint32_t, 2>>(out_thread_id); | ||
| 594 | SetReg32(system, 1, out_thread_id_scatter[0]); | ||
| 595 | SetReg32(system, 2, out_thread_id_scatter[1]); | ||
| 596 | } | ||
| 597 | |||
| 598 | static void SvcWrap_Break64From32(Core::System& system) { | ||
| 599 | BreakReason break_reason{}; | ||
| 600 | uint32_t arg{}; | ||
| 601 | uint32_t size{}; | ||
| 602 | |||
| 603 | break_reason = Convert<BreakReason>(GetReg32(system, 0)); | ||
| 604 | arg = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 605 | size = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 606 | |||
| 607 | Break64From32(system, break_reason, arg, size); | ||
| 608 | } | ||
| 609 | |||
| 610 | static void SvcWrap_OutputDebugString64From32(Core::System& system) { | ||
| 611 | Result ret{}; | ||
| 612 | |||
| 613 | uint32_t debug_str{}; | ||
| 614 | uint32_t len{}; | ||
| 615 | |||
| 616 | debug_str = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 617 | len = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 618 | |||
| 619 | ret = OutputDebugString64From32(system, debug_str, len); | ||
| 620 | |||
| 621 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 622 | } | ||
| 623 | |||
| 624 | static void SvcWrap_ReturnFromException64From32(Core::System& system) { | ||
| 625 | Result result{}; | ||
| 626 | |||
| 627 | result = Convert<Result>(GetReg32(system, 0)); | ||
| 628 | |||
| 629 | ReturnFromException64From32(system, result); | ||
| 630 | } | ||
| 631 | |||
| 632 | static void SvcWrap_GetInfo64From32(Core::System& system) { | ||
| 633 | Result ret{}; | ||
| 634 | |||
| 635 | uint64_t out{}; | ||
| 636 | InfoType info_type{}; | ||
| 637 | Handle handle{}; | ||
| 638 | uint64_t info_subtype{}; | ||
| 639 | |||
| 640 | info_type = Convert<InfoType>(GetReg32(system, 1)); | ||
| 641 | handle = Convert<Handle>(GetReg32(system, 2)); | ||
| 642 | std::array<uint32_t, 2> info_subtype_gather{}; | ||
| 643 | info_subtype_gather[0] = GetReg32(system, 0); | ||
| 644 | info_subtype_gather[1] = GetReg32(system, 3); | ||
| 645 | info_subtype = Convert<uint64_t>(info_subtype_gather); | ||
| 646 | |||
| 647 | ret = GetInfo64From32(system, &out, info_type, handle, info_subtype); | ||
| 648 | |||
| 649 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 650 | auto out_scatter = Convert<std::array<uint32_t, 2>>(out); | ||
| 651 | SetReg32(system, 1, out_scatter[0]); | ||
| 652 | SetReg32(system, 2, out_scatter[1]); | ||
| 653 | } | ||
| 654 | |||
| 655 | static void SvcWrap_FlushEntireDataCache64From32(Core::System& system) { | ||
| 656 | FlushEntireDataCache64From32(system); | ||
| 657 | } | ||
| 658 | |||
| 659 | static void SvcWrap_FlushDataCache64From32(Core::System& system) { | ||
| 660 | Result ret{}; | ||
| 661 | |||
| 662 | uint32_t address{}; | ||
| 663 | uint32_t size{}; | ||
| 664 | |||
| 665 | address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 666 | size = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 667 | |||
| 668 | ret = FlushDataCache64From32(system, address, size); | ||
| 669 | |||
| 670 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 671 | } | ||
| 672 | |||
| 673 | static void SvcWrap_MapPhysicalMemory64From32(Core::System& system) { | ||
| 674 | Result ret{}; | ||
| 675 | |||
| 676 | uint32_t address{}; | ||
| 677 | uint32_t size{}; | ||
| 678 | |||
| 679 | address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 680 | size = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 681 | |||
| 682 | ret = MapPhysicalMemory64From32(system, address, size); | ||
| 683 | |||
| 684 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 685 | } | ||
| 686 | |||
| 687 | static void SvcWrap_UnmapPhysicalMemory64From32(Core::System& system) { | ||
| 688 | Result ret{}; | ||
| 689 | |||
| 690 | uint32_t address{}; | ||
| 691 | uint32_t size{}; | ||
| 692 | |||
| 693 | address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 694 | size = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 695 | |||
| 696 | ret = UnmapPhysicalMemory64From32(system, address, size); | ||
| 697 | |||
| 698 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 699 | } | ||
| 700 | |||
| 701 | static void SvcWrap_GetDebugFutureThreadInfo64From32(Core::System& system) { | ||
| 702 | Result ret{}; | ||
| 703 | |||
| 704 | ilp32::LastThreadContext out_context{}; | ||
| 705 | uint64_t out_thread_id{}; | ||
| 706 | Handle debug_handle{}; | ||
| 707 | int64_t ns{}; | ||
| 708 | |||
| 709 | debug_handle = Convert<Handle>(GetReg32(system, 2)); | ||
| 710 | std::array<uint32_t, 2> ns_gather{}; | ||
| 711 | ns_gather[0] = GetReg32(system, 0); | ||
| 712 | ns_gather[1] = GetReg32(system, 1); | ||
| 713 | ns = Convert<int64_t>(ns_gather); | ||
| 714 | |||
| 715 | ret = GetDebugFutureThreadInfo64From32(system, &out_context, &out_thread_id, debug_handle, ns); | ||
| 716 | |||
| 717 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 718 | auto out_context_scatter = Convert<std::array<uint32_t, 4>>(out_context); | ||
| 719 | SetReg32(system, 1, out_context_scatter[0]); | ||
| 720 | SetReg32(system, 2, out_context_scatter[1]); | ||
| 721 | SetReg32(system, 3, out_context_scatter[2]); | ||
| 722 | SetReg32(system, 4, out_context_scatter[3]); | ||
| 723 | auto out_thread_id_scatter = Convert<std::array<uint32_t, 2>>(out_thread_id); | ||
| 724 | SetReg32(system, 5, out_thread_id_scatter[0]); | ||
| 725 | SetReg32(system, 6, out_thread_id_scatter[1]); | ||
| 726 | } | ||
| 727 | |||
| 728 | static void SvcWrap_GetLastThreadInfo64From32(Core::System& system) { | ||
| 729 | Result ret{}; | ||
| 730 | |||
| 731 | ilp32::LastThreadContext out_context{}; | ||
| 732 | uintptr_t out_tls_address{}; | ||
| 733 | uint32_t out_flags{}; | ||
| 734 | |||
| 735 | ret = GetLastThreadInfo64From32(system, &out_context, &out_tls_address, &out_flags); | ||
| 736 | |||
| 737 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 738 | auto out_context_scatter = Convert<std::array<uint32_t, 4>>(out_context); | ||
| 739 | SetReg32(system, 1, out_context_scatter[0]); | ||
| 740 | SetReg32(system, 2, out_context_scatter[1]); | ||
| 741 | SetReg32(system, 3, out_context_scatter[2]); | ||
| 742 | SetReg32(system, 4, out_context_scatter[3]); | ||
| 743 | SetReg32(system, 5, Convert<uint32_t>(out_tls_address)); | ||
| 744 | SetReg32(system, 6, Convert<uint32_t>(out_flags)); | ||
| 745 | } | ||
| 746 | |||
| 747 | static void SvcWrap_GetResourceLimitLimitValue64From32(Core::System& system) { | ||
| 748 | Result ret{}; | ||
| 749 | |||
| 750 | int64_t out_limit_value{}; | ||
| 751 | Handle resource_limit_handle{}; | ||
| 752 | LimitableResource which{}; | ||
| 753 | |||
| 754 | resource_limit_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 755 | which = Convert<LimitableResource>(GetReg32(system, 2)); | ||
| 756 | |||
| 757 | ret = GetResourceLimitLimitValue64From32(system, &out_limit_value, resource_limit_handle, which); | ||
| 758 | |||
| 759 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 760 | auto out_limit_value_scatter = Convert<std::array<uint32_t, 2>>(out_limit_value); | ||
| 761 | SetReg32(system, 1, out_limit_value_scatter[0]); | ||
| 762 | SetReg32(system, 2, out_limit_value_scatter[1]); | ||
| 763 | } | ||
| 764 | |||
| 765 | static void SvcWrap_GetResourceLimitCurrentValue64From32(Core::System& system) { | ||
| 766 | Result ret{}; | ||
| 767 | |||
| 768 | int64_t out_current_value{}; | ||
| 769 | Handle resource_limit_handle{}; | ||
| 770 | LimitableResource which{}; | ||
| 771 | |||
| 772 | resource_limit_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 773 | which = Convert<LimitableResource>(GetReg32(system, 2)); | ||
| 774 | |||
| 775 | ret = GetResourceLimitCurrentValue64From32(system, &out_current_value, resource_limit_handle, which); | ||
| 776 | |||
| 777 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 778 | auto out_current_value_scatter = Convert<std::array<uint32_t, 2>>(out_current_value); | ||
| 779 | SetReg32(system, 1, out_current_value_scatter[0]); | ||
| 780 | SetReg32(system, 2, out_current_value_scatter[1]); | ||
| 781 | } | ||
| 782 | |||
| 783 | static void SvcWrap_SetThreadActivity64From32(Core::System& system) { | ||
| 784 | Result ret{}; | ||
| 785 | |||
| 786 | Handle thread_handle{}; | ||
| 787 | ThreadActivity thread_activity{}; | ||
| 788 | |||
| 789 | thread_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 790 | thread_activity = Convert<ThreadActivity>(GetReg32(system, 1)); | ||
| 791 | |||
| 792 | ret = SetThreadActivity64From32(system, thread_handle, thread_activity); | ||
| 793 | |||
| 794 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 795 | } | ||
| 796 | |||
| 797 | static void SvcWrap_GetThreadContext364From32(Core::System& system) { | ||
| 798 | Result ret{}; | ||
| 799 | |||
| 800 | uint32_t out_context{}; | ||
| 801 | Handle thread_handle{}; | ||
| 802 | |||
| 803 | out_context = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 804 | thread_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 805 | |||
| 806 | ret = GetThreadContext364From32(system, out_context, thread_handle); | ||
| 807 | |||
| 808 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 809 | } | ||
| 810 | |||
| 811 | static void SvcWrap_WaitForAddress64From32(Core::System& system) { | ||
| 812 | Result ret{}; | ||
| 813 | |||
| 814 | uint32_t address{}; | ||
| 815 | ArbitrationType arb_type{}; | ||
| 816 | int32_t value{}; | ||
| 817 | int64_t timeout_ns{}; | ||
| 818 | |||
| 819 | address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 820 | arb_type = Convert<ArbitrationType>(GetReg32(system, 1)); | ||
| 821 | value = Convert<int32_t>(GetReg32(system, 2)); | ||
| 822 | std::array<uint32_t, 2> timeout_ns_gather{}; | ||
| 823 | timeout_ns_gather[0] = GetReg32(system, 3); | ||
| 824 | timeout_ns_gather[1] = GetReg32(system, 4); | ||
| 825 | timeout_ns = Convert<int64_t>(timeout_ns_gather); | ||
| 826 | |||
| 827 | ret = WaitForAddress64From32(system, address, arb_type, value, timeout_ns); | ||
| 828 | |||
| 829 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 830 | } | ||
| 831 | |||
| 832 | static void SvcWrap_SignalToAddress64From32(Core::System& system) { | ||
| 833 | Result ret{}; | ||
| 834 | |||
| 835 | uint32_t address{}; | ||
| 836 | SignalType signal_type{}; | ||
| 837 | int32_t value{}; | ||
| 838 | int32_t count{}; | ||
| 839 | |||
| 840 | address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 841 | signal_type = Convert<SignalType>(GetReg32(system, 1)); | ||
| 842 | value = Convert<int32_t>(GetReg32(system, 2)); | ||
| 843 | count = Convert<int32_t>(GetReg32(system, 3)); | ||
| 844 | |||
| 845 | ret = SignalToAddress64From32(system, address, signal_type, value, count); | ||
| 846 | |||
| 847 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 848 | } | ||
| 849 | |||
| 850 | static void SvcWrap_SynchronizePreemptionState64From32(Core::System& system) { | ||
| 851 | SynchronizePreemptionState64From32(system); | ||
| 852 | } | ||
| 853 | |||
| 854 | static void SvcWrap_GetResourceLimitPeakValue64From32(Core::System& system) { | ||
| 855 | Result ret{}; | ||
| 856 | |||
| 857 | int64_t out_peak_value{}; | ||
| 858 | Handle resource_limit_handle{}; | ||
| 859 | LimitableResource which{}; | ||
| 860 | |||
| 861 | resource_limit_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 862 | which = Convert<LimitableResource>(GetReg32(system, 2)); | ||
| 863 | |||
| 864 | ret = GetResourceLimitPeakValue64From32(system, &out_peak_value, resource_limit_handle, which); | ||
| 865 | |||
| 866 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 867 | auto out_peak_value_scatter = Convert<std::array<uint32_t, 2>>(out_peak_value); | ||
| 868 | SetReg32(system, 1, out_peak_value_scatter[0]); | ||
| 869 | SetReg32(system, 2, out_peak_value_scatter[1]); | ||
| 870 | } | ||
| 871 | |||
| 872 | static void SvcWrap_CreateIoPool64From32(Core::System& system) { | ||
| 873 | Result ret{}; | ||
| 874 | |||
| 875 | Handle out_handle{}; | ||
| 876 | IoPoolType which{}; | ||
| 877 | |||
| 878 | which = Convert<IoPoolType>(GetReg32(system, 1)); | ||
| 879 | |||
| 880 | ret = CreateIoPool64From32(system, &out_handle, which); | ||
| 881 | |||
| 882 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 883 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | ||
| 884 | } | ||
| 885 | |||
| 886 | static void SvcWrap_CreateIoRegion64From32(Core::System& system) { | ||
| 887 | Result ret{}; | ||
| 888 | |||
| 889 | Handle out_handle{}; | ||
| 890 | Handle io_pool{}; | ||
| 891 | uint64_t physical_address{}; | ||
| 892 | uint32_t size{}; | ||
| 893 | MemoryMapping mapping{}; | ||
| 894 | MemoryPermission perm{}; | ||
| 895 | |||
| 896 | io_pool = Convert<Handle>(GetReg32(system, 1)); | ||
| 897 | std::array<uint32_t, 2> physical_address_gather{}; | ||
| 898 | physical_address_gather[0] = GetReg32(system, 2); | ||
| 899 | physical_address_gather[1] = GetReg32(system, 3); | ||
| 900 | physical_address = Convert<uint64_t>(physical_address_gather); | ||
| 901 | size = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 902 | mapping = Convert<MemoryMapping>(GetReg32(system, 4)); | ||
| 903 | perm = Convert<MemoryPermission>(GetReg32(system, 5)); | ||
| 904 | |||
| 905 | ret = CreateIoRegion64From32(system, &out_handle, io_pool, physical_address, size, mapping, perm); | ||
| 906 | |||
| 907 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 908 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | ||
| 909 | } | ||
| 910 | |||
| 911 | static void SvcWrap_KernelDebug64From32(Core::System& system) { | ||
| 912 | KernelDebugType kern_debug_type{}; | ||
| 913 | uint64_t arg0{}; | ||
| 914 | uint64_t arg1{}; | ||
| 915 | uint64_t arg2{}; | ||
| 916 | |||
| 917 | kern_debug_type = Convert<KernelDebugType>(GetReg32(system, 0)); | ||
| 918 | std::array<uint32_t, 2> arg0_gather{}; | ||
| 919 | arg0_gather[0] = GetReg32(system, 2); | ||
| 920 | arg0_gather[1] = GetReg32(system, 3); | ||
| 921 | arg0 = Convert<uint64_t>(arg0_gather); | ||
| 922 | std::array<uint32_t, 2> arg1_gather{}; | ||
| 923 | arg1_gather[0] = GetReg32(system, 1); | ||
| 924 | arg1_gather[1] = GetReg32(system, 4); | ||
| 925 | arg1 = Convert<uint64_t>(arg1_gather); | ||
| 926 | std::array<uint32_t, 2> arg2_gather{}; | ||
| 927 | arg2_gather[0] = GetReg32(system, 5); | ||
| 928 | arg2_gather[1] = GetReg32(system, 6); | ||
| 929 | arg2 = Convert<uint64_t>(arg2_gather); | ||
| 930 | |||
| 931 | KernelDebug64From32(system, kern_debug_type, arg0, arg1, arg2); | ||
| 932 | } | ||
| 933 | |||
| 934 | static void SvcWrap_ChangeKernelTraceState64From32(Core::System& system) { | ||
| 935 | KernelTraceState kern_trace_state{}; | ||
| 936 | |||
| 937 | kern_trace_state = Convert<KernelTraceState>(GetReg32(system, 0)); | ||
| 938 | |||
| 939 | ChangeKernelTraceState64From32(system, kern_trace_state); | ||
| 940 | } | ||
| 941 | |||
| 942 | static void SvcWrap_CreateSession64From32(Core::System& system) { | ||
| 943 | Result ret{}; | ||
| 944 | |||
| 945 | Handle out_server_session_handle{}; | ||
| 946 | Handle out_client_session_handle{}; | ||
| 947 | bool is_light{}; | ||
| 948 | uint32_t name{}; | ||
| 949 | |||
| 950 | is_light = Convert<bool>(GetReg32(system, 2)); | ||
| 951 | name = Convert<uint32_t>(GetReg32(system, 3)); | ||
| 952 | |||
| 953 | ret = CreateSession64From32(system, &out_server_session_handle, &out_client_session_handle, is_light, name); | ||
| 954 | |||
| 955 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 956 | SetReg32(system, 1, Convert<uint32_t>(out_server_session_handle)); | ||
| 957 | SetReg32(system, 2, Convert<uint32_t>(out_client_session_handle)); | ||
| 958 | } | ||
| 959 | |||
| 960 | static void SvcWrap_AcceptSession64From32(Core::System& system) { | ||
| 961 | Result ret{}; | ||
| 962 | |||
| 963 | Handle out_handle{}; | ||
| 964 | Handle port{}; | ||
| 965 | |||
| 966 | port = Convert<Handle>(GetReg32(system, 1)); | ||
| 967 | |||
| 968 | ret = AcceptSession64From32(system, &out_handle, port); | ||
| 969 | |||
| 970 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 971 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | ||
| 972 | } | ||
| 973 | |||
| 974 | static void SvcWrap_ReplyAndReceive64From32(Core::System& system) { | ||
| 975 | Result ret{}; | ||
| 976 | |||
| 977 | int32_t out_index{}; | ||
| 978 | uint32_t handles{}; | ||
| 979 | int32_t num_handles{}; | ||
| 980 | Handle reply_target{}; | ||
| 981 | int64_t timeout_ns{}; | ||
| 982 | |||
| 983 | handles = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 984 | num_handles = Convert<int32_t>(GetReg32(system, 2)); | ||
| 985 | reply_target = Convert<Handle>(GetReg32(system, 3)); | ||
| 986 | std::array<uint32_t, 2> timeout_ns_gather{}; | ||
| 987 | timeout_ns_gather[0] = GetReg32(system, 0); | ||
| 988 | timeout_ns_gather[1] = GetReg32(system, 4); | ||
| 989 | timeout_ns = Convert<int64_t>(timeout_ns_gather); | ||
| 990 | |||
| 991 | ret = ReplyAndReceive64From32(system, &out_index, handles, num_handles, reply_target, timeout_ns); | ||
| 992 | |||
| 993 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 994 | SetReg32(system, 1, Convert<uint32_t>(out_index)); | ||
| 995 | } | ||
| 996 | |||
| 997 | static void SvcWrap_ReplyAndReceiveWithUserBuffer64From32(Core::System& system) { | ||
| 998 | Result ret{}; | ||
| 999 | |||
| 1000 | int32_t out_index{}; | ||
| 1001 | uint32_t message_buffer{}; | ||
| 1002 | uint32_t message_buffer_size{}; | ||
| 1003 | uint32_t handles{}; | ||
| 1004 | int32_t num_handles{}; | ||
| 1005 | Handle reply_target{}; | ||
| 1006 | int64_t timeout_ns{}; | ||
| 1007 | |||
| 1008 | message_buffer = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1009 | message_buffer_size = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 1010 | handles = Convert<uint32_t>(GetReg32(system, 3)); | ||
| 1011 | num_handles = Convert<int32_t>(GetReg32(system, 0)); | ||
| 1012 | reply_target = Convert<Handle>(GetReg32(system, 4)); | ||
| 1013 | std::array<uint32_t, 2> timeout_ns_gather{}; | ||
| 1014 | timeout_ns_gather[0] = GetReg32(system, 5); | ||
| 1015 | timeout_ns_gather[1] = GetReg32(system, 6); | ||
| 1016 | timeout_ns = Convert<int64_t>(timeout_ns_gather); | ||
| 1017 | |||
| 1018 | ret = ReplyAndReceiveWithUserBuffer64From32(system, &out_index, message_buffer, message_buffer_size, handles, num_handles, reply_target, timeout_ns); | ||
| 1019 | |||
| 1020 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1021 | SetReg32(system, 1, Convert<uint32_t>(out_index)); | ||
| 1022 | } | ||
| 1023 | |||
| 1024 | static void SvcWrap_CreateEvent64From32(Core::System& system) { | ||
| 1025 | Result ret{}; | ||
| 1026 | |||
| 1027 | Handle out_write_handle{}; | ||
| 1028 | Handle out_read_handle{}; | ||
| 1029 | |||
| 1030 | ret = CreateEvent64From32(system, &out_write_handle, &out_read_handle); | ||
| 1031 | |||
| 1032 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1033 | SetReg32(system, 1, Convert<uint32_t>(out_write_handle)); | ||
| 1034 | SetReg32(system, 2, Convert<uint32_t>(out_read_handle)); | ||
| 1035 | } | ||
| 1036 | |||
| 1037 | static void SvcWrap_MapIoRegion64From32(Core::System& system) { | ||
| 1038 | Result ret{}; | ||
| 1039 | |||
| 1040 | Handle io_region{}; | ||
| 1041 | uint32_t address{}; | ||
| 1042 | uint32_t size{}; | ||
| 1043 | MemoryPermission perm{}; | ||
| 1044 | |||
| 1045 | io_region = Convert<Handle>(GetReg32(system, 0)); | ||
| 1046 | address = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1047 | size = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 1048 | perm = Convert<MemoryPermission>(GetReg32(system, 3)); | ||
| 1049 | |||
| 1050 | ret = MapIoRegion64From32(system, io_region, address, size, perm); | ||
| 1051 | |||
| 1052 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1053 | } | ||
| 1054 | |||
| 1055 | static void SvcWrap_UnmapIoRegion64From32(Core::System& system) { | ||
| 1056 | Result ret{}; | ||
| 1057 | |||
| 1058 | Handle io_region{}; | ||
| 1059 | uint32_t address{}; | ||
| 1060 | uint32_t size{}; | ||
| 1061 | |||
| 1062 | io_region = Convert<Handle>(GetReg32(system, 0)); | ||
| 1063 | address = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1064 | size = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 1065 | |||
| 1066 | ret = UnmapIoRegion64From32(system, io_region, address, size); | ||
| 1067 | |||
| 1068 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1069 | } | ||
| 1070 | |||
| 1071 | static void SvcWrap_MapPhysicalMemoryUnsafe64From32(Core::System& system) { | ||
| 1072 | Result ret{}; | ||
| 1073 | |||
| 1074 | uint32_t address{}; | ||
| 1075 | uint32_t size{}; | ||
| 1076 | |||
| 1077 | address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1078 | size = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1079 | |||
| 1080 | ret = MapPhysicalMemoryUnsafe64From32(system, address, size); | ||
| 1081 | |||
| 1082 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1083 | } | ||
| 1084 | |||
| 1085 | static void SvcWrap_UnmapPhysicalMemoryUnsafe64From32(Core::System& system) { | ||
| 1086 | Result ret{}; | ||
| 1087 | |||
| 1088 | uint32_t address{}; | ||
| 1089 | uint32_t size{}; | ||
| 1090 | |||
| 1091 | address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1092 | size = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1093 | |||
| 1094 | ret = UnmapPhysicalMemoryUnsafe64From32(system, address, size); | ||
| 1095 | |||
| 1096 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1097 | } | ||
| 1098 | |||
| 1099 | static void SvcWrap_SetUnsafeLimit64From32(Core::System& system) { | ||
| 1100 | Result ret{}; | ||
| 1101 | |||
| 1102 | uint32_t limit{}; | ||
| 1103 | |||
| 1104 | limit = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1105 | |||
| 1106 | ret = SetUnsafeLimit64From32(system, limit); | ||
| 1107 | |||
| 1108 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1109 | } | ||
| 1110 | |||
| 1111 | static void SvcWrap_CreateCodeMemory64From32(Core::System& system) { | ||
| 1112 | Result ret{}; | ||
| 1113 | |||
| 1114 | Handle out_handle{}; | ||
| 1115 | uint32_t address{}; | ||
| 1116 | uint32_t size{}; | ||
| 1117 | |||
| 1118 | address = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1119 | size = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 1120 | |||
| 1121 | ret = CreateCodeMemory64From32(system, &out_handle, address, size); | ||
| 1122 | |||
| 1123 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1124 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | ||
| 1125 | } | ||
| 1126 | |||
| 1127 | static void SvcWrap_ControlCodeMemory64From32(Core::System& system) { | ||
| 1128 | Result ret{}; | ||
| 1129 | |||
| 1130 | Handle code_memory_handle{}; | ||
| 1131 | CodeMemoryOperation operation{}; | ||
| 1132 | uint64_t address{}; | ||
| 1133 | uint64_t size{}; | ||
| 1134 | MemoryPermission perm{}; | ||
| 1135 | |||
| 1136 | code_memory_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1137 | operation = Convert<CodeMemoryOperation>(GetReg32(system, 1)); | ||
| 1138 | std::array<uint32_t, 2> address_gather{}; | ||
| 1139 | address_gather[0] = GetReg32(system, 2); | ||
| 1140 | address_gather[1] = GetReg32(system, 3); | ||
| 1141 | address = Convert<uint64_t>(address_gather); | ||
| 1142 | std::array<uint32_t, 2> size_gather{}; | ||
| 1143 | size_gather[0] = GetReg32(system, 4); | ||
| 1144 | size_gather[1] = GetReg32(system, 5); | ||
| 1145 | size = Convert<uint64_t>(size_gather); | ||
| 1146 | perm = Convert<MemoryPermission>(GetReg32(system, 6)); | ||
| 1147 | |||
| 1148 | ret = ControlCodeMemory64From32(system, code_memory_handle, operation, address, size, perm); | ||
| 1149 | |||
| 1150 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1151 | } | ||
| 1152 | |||
| 1153 | static void SvcWrap_SleepSystem64From32(Core::System& system) { | ||
| 1154 | SleepSystem64From32(system); | ||
| 1155 | } | ||
| 1156 | |||
| 1157 | static void SvcWrap_ReadWriteRegister64From32(Core::System& system) { | ||
| 1158 | Result ret{}; | ||
| 1159 | |||
| 1160 | uint32_t out_value{}; | ||
| 1161 | uint64_t address{}; | ||
| 1162 | uint32_t mask{}; | ||
| 1163 | uint32_t value{}; | ||
| 1164 | |||
| 1165 | std::array<uint32_t, 2> address_gather{}; | ||
| 1166 | address_gather[0] = GetReg32(system, 2); | ||
| 1167 | address_gather[1] = GetReg32(system, 3); | ||
| 1168 | address = Convert<uint64_t>(address_gather); | ||
| 1169 | mask = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1170 | value = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1171 | |||
| 1172 | ret = ReadWriteRegister64From32(system, &out_value, address, mask, value); | ||
| 1173 | |||
| 1174 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1175 | SetReg32(system, 1, Convert<uint32_t>(out_value)); | ||
| 1176 | } | ||
| 1177 | |||
| 1178 | static void SvcWrap_SetProcessActivity64From32(Core::System& system) { | ||
| 1179 | Result ret{}; | ||
| 1180 | |||
| 1181 | Handle process_handle{}; | ||
| 1182 | ProcessActivity process_activity{}; | ||
| 1183 | |||
| 1184 | process_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1185 | process_activity = Convert<ProcessActivity>(GetReg32(system, 1)); | ||
| 1186 | |||
| 1187 | ret = SetProcessActivity64From32(system, process_handle, process_activity); | ||
| 1188 | |||
| 1189 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1190 | } | ||
| 1191 | |||
| 1192 | static void SvcWrap_CreateSharedMemory64From32(Core::System& system) { | ||
| 1193 | Result ret{}; | ||
| 1194 | |||
| 1195 | Handle out_handle{}; | ||
| 1196 | uint32_t size{}; | ||
| 1197 | MemoryPermission owner_perm{}; | ||
| 1198 | MemoryPermission remote_perm{}; | ||
| 1199 | |||
| 1200 | size = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1201 | owner_perm = Convert<MemoryPermission>(GetReg32(system, 2)); | ||
| 1202 | remote_perm = Convert<MemoryPermission>(GetReg32(system, 3)); | ||
| 1203 | |||
| 1204 | ret = CreateSharedMemory64From32(system, &out_handle, size, owner_perm, remote_perm); | ||
| 1205 | |||
| 1206 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1207 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | ||
| 1208 | } | ||
| 1209 | |||
| 1210 | static void SvcWrap_MapTransferMemory64From32(Core::System& system) { | ||
| 1211 | Result ret{}; | ||
| 1212 | |||
| 1213 | Handle trmem_handle{}; | ||
| 1214 | uint32_t address{}; | ||
| 1215 | uint32_t size{}; | ||
| 1216 | MemoryPermission owner_perm{}; | ||
| 1217 | |||
| 1218 | trmem_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1219 | address = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1220 | size = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 1221 | owner_perm = Convert<MemoryPermission>(GetReg32(system, 3)); | ||
| 1222 | |||
| 1223 | ret = MapTransferMemory64From32(system, trmem_handle, address, size, owner_perm); | ||
| 1224 | |||
| 1225 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1226 | } | ||
| 1227 | |||
| 1228 | static void SvcWrap_UnmapTransferMemory64From32(Core::System& system) { | ||
| 1229 | Result ret{}; | ||
| 1230 | |||
| 1231 | Handle trmem_handle{}; | ||
| 1232 | uint32_t address{}; | ||
| 1233 | uint32_t size{}; | ||
| 1234 | |||
| 1235 | trmem_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1236 | address = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1237 | size = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 1238 | |||
| 1239 | ret = UnmapTransferMemory64From32(system, trmem_handle, address, size); | ||
| 1240 | |||
| 1241 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1242 | } | ||
| 1243 | |||
| 1244 | static void SvcWrap_CreateInterruptEvent64From32(Core::System& system) { | ||
| 1245 | Result ret{}; | ||
| 1246 | |||
| 1247 | Handle out_read_handle{}; | ||
| 1248 | int32_t interrupt_id{}; | ||
| 1249 | InterruptType interrupt_type{}; | ||
| 1250 | |||
| 1251 | interrupt_id = Convert<int32_t>(GetReg32(system, 1)); | ||
| 1252 | interrupt_type = Convert<InterruptType>(GetReg32(system, 2)); | ||
| 1253 | |||
| 1254 | ret = CreateInterruptEvent64From32(system, &out_read_handle, interrupt_id, interrupt_type); | ||
| 1255 | |||
| 1256 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1257 | SetReg32(system, 1, Convert<uint32_t>(out_read_handle)); | ||
| 1258 | } | ||
| 1259 | |||
| 1260 | static void SvcWrap_QueryPhysicalAddress64From32(Core::System& system) { | ||
| 1261 | Result ret{}; | ||
| 1262 | |||
| 1263 | ilp32::PhysicalMemoryInfo out_info{}; | ||
| 1264 | uint32_t address{}; | ||
| 1265 | |||
| 1266 | address = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1267 | |||
| 1268 | ret = QueryPhysicalAddress64From32(system, &out_info, address); | ||
| 1269 | |||
| 1270 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1271 | auto out_info_scatter = Convert<std::array<uint32_t, 4>>(out_info); | ||
| 1272 | SetReg32(system, 1, out_info_scatter[0]); | ||
| 1273 | SetReg32(system, 2, out_info_scatter[1]); | ||
| 1274 | SetReg32(system, 3, out_info_scatter[2]); | ||
| 1275 | SetReg32(system, 4, out_info_scatter[3]); | ||
| 1276 | } | ||
| 1277 | |||
| 1278 | static void SvcWrap_QueryIoMapping64From32(Core::System& system) { | ||
| 1279 | Result ret{}; | ||
| 1280 | |||
| 1281 | uintptr_t out_address{}; | ||
| 1282 | uintptr_t out_size{}; | ||
| 1283 | uint64_t physical_address{}; | ||
| 1284 | uint32_t size{}; | ||
| 1285 | |||
| 1286 | std::array<uint32_t, 2> physical_address_gather{}; | ||
| 1287 | physical_address_gather[0] = GetReg32(system, 2); | ||
| 1288 | physical_address_gather[1] = GetReg32(system, 3); | ||
| 1289 | physical_address = Convert<uint64_t>(physical_address_gather); | ||
| 1290 | size = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1291 | |||
| 1292 | ret = QueryIoMapping64From32(system, &out_address, &out_size, physical_address, size); | ||
| 1293 | |||
| 1294 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1295 | SetReg32(system, 1, Convert<uint32_t>(out_address)); | ||
| 1296 | SetReg32(system, 2, Convert<uint32_t>(out_size)); | ||
| 1297 | } | ||
| 1298 | |||
| 1299 | static void SvcWrap_CreateDeviceAddressSpace64From32(Core::System& system) { | ||
| 1300 | Result ret{}; | ||
| 1301 | |||
| 1302 | Handle out_handle{}; | ||
| 1303 | uint64_t das_address{}; | ||
| 1304 | uint64_t das_size{}; | ||
| 1305 | |||
| 1306 | std::array<uint32_t, 2> das_address_gather{}; | ||
| 1307 | das_address_gather[0] = GetReg32(system, 2); | ||
| 1308 | das_address_gather[1] = GetReg32(system, 3); | ||
| 1309 | das_address = Convert<uint64_t>(das_address_gather); | ||
| 1310 | std::array<uint32_t, 2> das_size_gather{}; | ||
| 1311 | das_size_gather[0] = GetReg32(system, 0); | ||
| 1312 | das_size_gather[1] = GetReg32(system, 1); | ||
| 1313 | das_size = Convert<uint64_t>(das_size_gather); | ||
| 1314 | |||
| 1315 | ret = CreateDeviceAddressSpace64From32(system, &out_handle, das_address, das_size); | ||
| 1316 | |||
| 1317 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1318 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | ||
| 1319 | } | ||
| 1320 | |||
| 1321 | static void SvcWrap_AttachDeviceAddressSpace64From32(Core::System& system) { | ||
| 1322 | Result ret{}; | ||
| 1323 | |||
| 1324 | DeviceName device_name{}; | ||
| 1325 | Handle das_handle{}; | ||
| 1326 | |||
| 1327 | device_name = Convert<DeviceName>(GetReg32(system, 0)); | ||
| 1328 | das_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 1329 | |||
| 1330 | ret = AttachDeviceAddressSpace64From32(system, device_name, das_handle); | ||
| 1331 | |||
| 1332 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1333 | } | ||
| 1334 | |||
| 1335 | static void SvcWrap_DetachDeviceAddressSpace64From32(Core::System& system) { | ||
| 1336 | Result ret{}; | ||
| 1337 | |||
| 1338 | DeviceName device_name{}; | ||
| 1339 | Handle das_handle{}; | ||
| 1340 | |||
| 1341 | device_name = Convert<DeviceName>(GetReg32(system, 0)); | ||
| 1342 | das_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 1343 | |||
| 1344 | ret = DetachDeviceAddressSpace64From32(system, device_name, das_handle); | ||
| 1345 | |||
| 1346 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1347 | } | ||
| 1348 | |||
| 1349 | static void SvcWrap_MapDeviceAddressSpaceByForce64From32(Core::System& system) { | ||
| 1350 | Result ret{}; | ||
| 1351 | |||
| 1352 | Handle das_handle{}; | ||
| 1353 | Handle process_handle{}; | ||
| 1354 | uint64_t process_address{}; | ||
| 1355 | uint32_t size{}; | ||
| 1356 | uint64_t device_address{}; | ||
| 1357 | uint32_t option{}; | ||
| 1358 | |||
| 1359 | das_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1360 | process_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 1361 | std::array<uint32_t, 2> process_address_gather{}; | ||
| 1362 | process_address_gather[0] = GetReg32(system, 2); | ||
| 1363 | process_address_gather[1] = GetReg32(system, 3); | ||
| 1364 | process_address = Convert<uint64_t>(process_address_gather); | ||
| 1365 | size = Convert<uint32_t>(GetReg32(system, 4)); | ||
| 1366 | std::array<uint32_t, 2> device_address_gather{}; | ||
| 1367 | device_address_gather[0] = GetReg32(system, 5); | ||
| 1368 | device_address_gather[1] = GetReg32(system, 6); | ||
| 1369 | device_address = Convert<uint64_t>(device_address_gather); | ||
| 1370 | option = Convert<uint32_t>(GetReg32(system, 7)); | ||
| 1371 | |||
| 1372 | ret = MapDeviceAddressSpaceByForce64From32(system, das_handle, process_handle, process_address, size, device_address, option); | ||
| 1373 | |||
| 1374 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1375 | } | ||
| 1376 | |||
| 1377 | static void SvcWrap_MapDeviceAddressSpaceAligned64From32(Core::System& system) { | ||
| 1378 | Result ret{}; | ||
| 1379 | |||
| 1380 | Handle das_handle{}; | ||
| 1381 | Handle process_handle{}; | ||
| 1382 | uint64_t process_address{}; | ||
| 1383 | uint32_t size{}; | ||
| 1384 | uint64_t device_address{}; | ||
| 1385 | uint32_t option{}; | ||
| 1386 | |||
| 1387 | das_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1388 | process_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 1389 | std::array<uint32_t, 2> process_address_gather{}; | ||
| 1390 | process_address_gather[0] = GetReg32(system, 2); | ||
| 1391 | process_address_gather[1] = GetReg32(system, 3); | ||
| 1392 | process_address = Convert<uint64_t>(process_address_gather); | ||
| 1393 | size = Convert<uint32_t>(GetReg32(system, 4)); | ||
| 1394 | std::array<uint32_t, 2> device_address_gather{}; | ||
| 1395 | device_address_gather[0] = GetReg32(system, 5); | ||
| 1396 | device_address_gather[1] = GetReg32(system, 6); | ||
| 1397 | device_address = Convert<uint64_t>(device_address_gather); | ||
| 1398 | option = Convert<uint32_t>(GetReg32(system, 7)); | ||
| 1399 | |||
| 1400 | ret = MapDeviceAddressSpaceAligned64From32(system, das_handle, process_handle, process_address, size, device_address, option); | ||
| 1401 | |||
| 1402 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1403 | } | ||
| 1404 | |||
| 1405 | static void SvcWrap_UnmapDeviceAddressSpace64From32(Core::System& system) { | ||
| 1406 | Result ret{}; | ||
| 1407 | |||
| 1408 | Handle das_handle{}; | ||
| 1409 | Handle process_handle{}; | ||
| 1410 | uint64_t process_address{}; | ||
| 1411 | uint32_t size{}; | ||
| 1412 | uint64_t device_address{}; | ||
| 1413 | |||
| 1414 | das_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1415 | process_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 1416 | std::array<uint32_t, 2> process_address_gather{}; | ||
| 1417 | process_address_gather[0] = GetReg32(system, 2); | ||
| 1418 | process_address_gather[1] = GetReg32(system, 3); | ||
| 1419 | process_address = Convert<uint64_t>(process_address_gather); | ||
| 1420 | size = Convert<uint32_t>(GetReg32(system, 4)); | ||
| 1421 | std::array<uint32_t, 2> device_address_gather{}; | ||
| 1422 | device_address_gather[0] = GetReg32(system, 5); | ||
| 1423 | device_address_gather[1] = GetReg32(system, 6); | ||
| 1424 | device_address = Convert<uint64_t>(device_address_gather); | ||
| 1425 | |||
| 1426 | ret = UnmapDeviceAddressSpace64From32(system, das_handle, process_handle, process_address, size, device_address); | ||
| 1427 | |||
| 1428 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1429 | } | ||
| 1430 | |||
| 1431 | static void SvcWrap_InvalidateProcessDataCache64From32(Core::System& system) { | ||
| 1432 | Result ret{}; | ||
| 1433 | |||
| 1434 | Handle process_handle{}; | ||
| 1435 | uint64_t address{}; | ||
| 1436 | uint64_t size{}; | ||
| 1437 | |||
| 1438 | process_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1439 | std::array<uint32_t, 2> address_gather{}; | ||
| 1440 | address_gather[0] = GetReg32(system, 2); | ||
| 1441 | address_gather[1] = GetReg32(system, 3); | ||
| 1442 | address = Convert<uint64_t>(address_gather); | ||
| 1443 | std::array<uint32_t, 2> size_gather{}; | ||
| 1444 | size_gather[0] = GetReg32(system, 1); | ||
| 1445 | size_gather[1] = GetReg32(system, 4); | ||
| 1446 | size = Convert<uint64_t>(size_gather); | ||
| 1447 | |||
| 1448 | ret = InvalidateProcessDataCache64From32(system, process_handle, address, size); | ||
| 1449 | |||
| 1450 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1451 | } | ||
| 1452 | |||
| 1453 | static void SvcWrap_StoreProcessDataCache64From32(Core::System& system) { | ||
| 1454 | Result ret{}; | ||
| 1455 | |||
| 1456 | Handle process_handle{}; | ||
| 1457 | uint64_t address{}; | ||
| 1458 | uint64_t size{}; | ||
| 1459 | |||
| 1460 | process_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1461 | std::array<uint32_t, 2> address_gather{}; | ||
| 1462 | address_gather[0] = GetReg32(system, 2); | ||
| 1463 | address_gather[1] = GetReg32(system, 3); | ||
| 1464 | address = Convert<uint64_t>(address_gather); | ||
| 1465 | std::array<uint32_t, 2> size_gather{}; | ||
| 1466 | size_gather[0] = GetReg32(system, 1); | ||
| 1467 | size_gather[1] = GetReg32(system, 4); | ||
| 1468 | size = Convert<uint64_t>(size_gather); | ||
| 1469 | |||
| 1470 | ret = StoreProcessDataCache64From32(system, process_handle, address, size); | ||
| 1471 | |||
| 1472 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1473 | } | ||
| 1474 | |||
| 1475 | static void SvcWrap_FlushProcessDataCache64From32(Core::System& system) { | ||
| 1476 | Result ret{}; | ||
| 1477 | |||
| 1478 | Handle process_handle{}; | ||
| 1479 | uint64_t address{}; | ||
| 1480 | uint64_t size{}; | ||
| 1481 | |||
| 1482 | process_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1483 | std::array<uint32_t, 2> address_gather{}; | ||
| 1484 | address_gather[0] = GetReg32(system, 2); | ||
| 1485 | address_gather[1] = GetReg32(system, 3); | ||
| 1486 | address = Convert<uint64_t>(address_gather); | ||
| 1487 | std::array<uint32_t, 2> size_gather{}; | ||
| 1488 | size_gather[0] = GetReg32(system, 1); | ||
| 1489 | size_gather[1] = GetReg32(system, 4); | ||
| 1490 | size = Convert<uint64_t>(size_gather); | ||
| 1491 | |||
| 1492 | ret = FlushProcessDataCache64From32(system, process_handle, address, size); | ||
| 1493 | |||
| 1494 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1495 | } | ||
| 1496 | |||
| 1497 | static void SvcWrap_DebugActiveProcess64From32(Core::System& system) { | ||
| 1498 | Result ret{}; | ||
| 1499 | |||
| 1500 | Handle out_handle{}; | ||
| 1501 | uint64_t process_id{}; | ||
| 1502 | |||
| 1503 | std::array<uint32_t, 2> process_id_gather{}; | ||
| 1504 | process_id_gather[0] = GetReg32(system, 2); | ||
| 1505 | process_id_gather[1] = GetReg32(system, 3); | ||
| 1506 | process_id = Convert<uint64_t>(process_id_gather); | ||
| 1507 | |||
| 1508 | ret = DebugActiveProcess64From32(system, &out_handle, process_id); | ||
| 1509 | |||
| 1510 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1511 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | ||
| 1512 | } | ||
| 1513 | |||
| 1514 | static void SvcWrap_BreakDebugProcess64From32(Core::System& system) { | ||
| 1515 | Result ret{}; | ||
| 1516 | |||
| 1517 | Handle debug_handle{}; | ||
| 1518 | |||
| 1519 | debug_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1520 | |||
| 1521 | ret = BreakDebugProcess64From32(system, debug_handle); | ||
| 1522 | |||
| 1523 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1524 | } | ||
| 1525 | |||
| 1526 | static void SvcWrap_TerminateDebugProcess64From32(Core::System& system) { | ||
| 1527 | Result ret{}; | ||
| 1528 | |||
| 1529 | Handle debug_handle{}; | ||
| 1530 | |||
| 1531 | debug_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1532 | |||
| 1533 | ret = TerminateDebugProcess64From32(system, debug_handle); | ||
| 1534 | |||
| 1535 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1536 | } | ||
| 1537 | |||
| 1538 | static void SvcWrap_GetDebugEvent64From32(Core::System& system) { | ||
| 1539 | Result ret{}; | ||
| 1540 | |||
| 1541 | uint32_t out_info{}; | ||
| 1542 | Handle debug_handle{}; | ||
| 1543 | |||
| 1544 | out_info = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1545 | debug_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 1546 | |||
| 1547 | ret = GetDebugEvent64From32(system, out_info, debug_handle); | ||
| 1548 | |||
| 1549 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1550 | } | ||
| 1551 | |||
| 1552 | static void SvcWrap_ContinueDebugEvent64From32(Core::System& system) { | ||
| 1553 | Result ret{}; | ||
| 1554 | |||
| 1555 | Handle debug_handle{}; | ||
| 1556 | uint32_t flags{}; | ||
| 1557 | uint32_t thread_ids{}; | ||
| 1558 | int32_t num_thread_ids{}; | ||
| 1559 | |||
| 1560 | debug_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1561 | flags = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1562 | thread_ids = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 1563 | num_thread_ids = Convert<int32_t>(GetReg32(system, 3)); | ||
| 1564 | |||
| 1565 | ret = ContinueDebugEvent64From32(system, debug_handle, flags, thread_ids, num_thread_ids); | ||
| 1566 | |||
| 1567 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1568 | } | ||
| 1569 | |||
| 1570 | static void SvcWrap_GetProcessList64From32(Core::System& system) { | ||
| 1571 | Result ret{}; | ||
| 1572 | |||
| 1573 | int32_t out_num_processes{}; | ||
| 1574 | uint32_t out_process_ids{}; | ||
| 1575 | int32_t max_out_count{}; | ||
| 1576 | |||
| 1577 | out_process_ids = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1578 | max_out_count = Convert<int32_t>(GetReg32(system, 2)); | ||
| 1579 | |||
| 1580 | ret = GetProcessList64From32(system, &out_num_processes, out_process_ids, max_out_count); | ||
| 1581 | |||
| 1582 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1583 | SetReg32(system, 1, Convert<uint32_t>(out_num_processes)); | ||
| 1584 | } | ||
| 1585 | |||
| 1586 | static void SvcWrap_GetThreadList64From32(Core::System& system) { | ||
| 1587 | Result ret{}; | ||
| 1588 | |||
| 1589 | int32_t out_num_threads{}; | ||
| 1590 | uint32_t out_thread_ids{}; | ||
| 1591 | int32_t max_out_count{}; | ||
| 1592 | Handle debug_handle{}; | ||
| 1593 | |||
| 1594 | out_thread_ids = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1595 | max_out_count = Convert<int32_t>(GetReg32(system, 2)); | ||
| 1596 | debug_handle = Convert<Handle>(GetReg32(system, 3)); | ||
| 1597 | |||
| 1598 | ret = GetThreadList64From32(system, &out_num_threads, out_thread_ids, max_out_count, debug_handle); | ||
| 1599 | |||
| 1600 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1601 | SetReg32(system, 1, Convert<uint32_t>(out_num_threads)); | ||
| 1602 | } | ||
| 1603 | |||
| 1604 | static void SvcWrap_GetDebugThreadContext64From32(Core::System& system) { | ||
| 1605 | Result ret{}; | ||
| 1606 | |||
| 1607 | uint32_t out_context{}; | ||
| 1608 | Handle debug_handle{}; | ||
| 1609 | uint64_t thread_id{}; | ||
| 1610 | uint32_t context_flags{}; | ||
| 1611 | |||
| 1612 | out_context = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1613 | debug_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 1614 | std::array<uint32_t, 2> thread_id_gather{}; | ||
| 1615 | thread_id_gather[0] = GetReg32(system, 2); | ||
| 1616 | thread_id_gather[1] = GetReg32(system, 3); | ||
| 1617 | thread_id = Convert<uint64_t>(thread_id_gather); | ||
| 1618 | context_flags = Convert<uint32_t>(GetReg32(system, 4)); | ||
| 1619 | |||
| 1620 | ret = GetDebugThreadContext64From32(system, out_context, debug_handle, thread_id, context_flags); | ||
| 1621 | |||
| 1622 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1623 | } | ||
| 1624 | |||
| 1625 | static void SvcWrap_SetDebugThreadContext64From32(Core::System& system) { | ||
| 1626 | Result ret{}; | ||
| 1627 | |||
| 1628 | Handle debug_handle{}; | ||
| 1629 | uint64_t thread_id{}; | ||
| 1630 | uint32_t context{}; | ||
| 1631 | uint32_t context_flags{}; | ||
| 1632 | |||
| 1633 | debug_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1634 | std::array<uint32_t, 2> thread_id_gather{}; | ||
| 1635 | thread_id_gather[0] = GetReg32(system, 2); | ||
| 1636 | thread_id_gather[1] = GetReg32(system, 3); | ||
| 1637 | thread_id = Convert<uint64_t>(thread_id_gather); | ||
| 1638 | context = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1639 | context_flags = Convert<uint32_t>(GetReg32(system, 4)); | ||
| 1640 | |||
| 1641 | ret = SetDebugThreadContext64From32(system, debug_handle, thread_id, context, context_flags); | ||
| 1642 | |||
| 1643 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1644 | } | ||
| 1645 | |||
| 1646 | static void SvcWrap_QueryDebugProcessMemory64From32(Core::System& system) { | ||
| 1647 | Result ret{}; | ||
| 1648 | |||
| 1649 | PageInfo out_page_info{}; | ||
| 1650 | uint32_t out_memory_info{}; | ||
| 1651 | Handle process_handle{}; | ||
| 1652 | uint32_t address{}; | ||
| 1653 | |||
| 1654 | out_memory_info = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1655 | process_handle = Convert<Handle>(GetReg32(system, 2)); | ||
| 1656 | address = Convert<uint32_t>(GetReg32(system, 3)); | ||
| 1657 | |||
| 1658 | ret = QueryDebugProcessMemory64From32(system, out_memory_info, &out_page_info, process_handle, address); | ||
| 1659 | |||
| 1660 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1661 | SetReg32(system, 1, Convert<uint32_t>(out_page_info)); | ||
| 1662 | } | ||
| 1663 | |||
| 1664 | static void SvcWrap_ReadDebugProcessMemory64From32(Core::System& system) { | ||
| 1665 | Result ret{}; | ||
| 1666 | |||
| 1667 | uint32_t buffer{}; | ||
| 1668 | Handle debug_handle{}; | ||
| 1669 | uint32_t address{}; | ||
| 1670 | uint32_t size{}; | ||
| 1671 | |||
| 1672 | buffer = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1673 | debug_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 1674 | address = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 1675 | size = Convert<uint32_t>(GetReg32(system, 3)); | ||
| 1676 | |||
| 1677 | ret = ReadDebugProcessMemory64From32(system, buffer, debug_handle, address, size); | ||
| 1678 | |||
| 1679 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1680 | } | ||
| 1681 | |||
| 1682 | static void SvcWrap_WriteDebugProcessMemory64From32(Core::System& system) { | ||
| 1683 | Result ret{}; | ||
| 1684 | |||
| 1685 | Handle debug_handle{}; | ||
| 1686 | uint32_t buffer{}; | ||
| 1687 | uint32_t address{}; | ||
| 1688 | uint32_t size{}; | ||
| 1689 | |||
| 1690 | debug_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1691 | buffer = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1692 | address = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 1693 | size = Convert<uint32_t>(GetReg32(system, 3)); | ||
| 1694 | |||
| 1695 | ret = WriteDebugProcessMemory64From32(system, debug_handle, buffer, address, size); | ||
| 1696 | |||
| 1697 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1698 | } | ||
| 1699 | |||
| 1700 | static void SvcWrap_SetHardwareBreakPoint64From32(Core::System& system) { | ||
| 1701 | Result ret{}; | ||
| 1702 | |||
| 1703 | HardwareBreakPointRegisterName name{}; | ||
| 1704 | uint64_t flags{}; | ||
| 1705 | uint64_t value{}; | ||
| 1706 | |||
| 1707 | name = Convert<HardwareBreakPointRegisterName>(GetReg32(system, 0)); | ||
| 1708 | std::array<uint32_t, 2> flags_gather{}; | ||
| 1709 | flags_gather[0] = GetReg32(system, 2); | ||
| 1710 | flags_gather[1] = GetReg32(system, 3); | ||
| 1711 | flags = Convert<uint64_t>(flags_gather); | ||
| 1712 | std::array<uint32_t, 2> value_gather{}; | ||
| 1713 | value_gather[0] = GetReg32(system, 1); | ||
| 1714 | value_gather[1] = GetReg32(system, 4); | ||
| 1715 | value = Convert<uint64_t>(value_gather); | ||
| 1716 | |||
| 1717 | ret = SetHardwareBreakPoint64From32(system, name, flags, value); | ||
| 1718 | |||
| 1719 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1720 | } | ||
| 1721 | |||
| 1722 | static void SvcWrap_GetDebugThreadParam64From32(Core::System& system) { | ||
| 1723 | Result ret{}; | ||
| 1724 | |||
| 1725 | uint64_t out_64{}; | ||
| 1726 | uint32_t out_32{}; | ||
| 1727 | Handle debug_handle{}; | ||
| 1728 | uint64_t thread_id{}; | ||
| 1729 | DebugThreadParam param{}; | ||
| 1730 | |||
| 1731 | debug_handle = Convert<Handle>(GetReg32(system, 2)); | ||
| 1732 | std::array<uint32_t, 2> thread_id_gather{}; | ||
| 1733 | thread_id_gather[0] = GetReg32(system, 0); | ||
| 1734 | thread_id_gather[1] = GetReg32(system, 1); | ||
| 1735 | thread_id = Convert<uint64_t>(thread_id_gather); | ||
| 1736 | param = Convert<DebugThreadParam>(GetReg32(system, 3)); | ||
| 1737 | |||
| 1738 | ret = GetDebugThreadParam64From32(system, &out_64, &out_32, debug_handle, thread_id, param); | ||
| 1739 | |||
| 1740 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1741 | auto out_64_scatter = Convert<std::array<uint32_t, 2>>(out_64); | ||
| 1742 | SetReg32(system, 1, out_64_scatter[0]); | ||
| 1743 | SetReg32(system, 2, out_64_scatter[1]); | ||
| 1744 | SetReg32(system, 3, Convert<uint32_t>(out_32)); | ||
| 1745 | } | ||
| 1746 | |||
| 1747 | static void SvcWrap_GetSystemInfo64From32(Core::System& system) { | ||
| 1748 | Result ret{}; | ||
| 1749 | |||
| 1750 | uint64_t out{}; | ||
| 1751 | SystemInfoType info_type{}; | ||
| 1752 | Handle handle{}; | ||
| 1753 | uint64_t info_subtype{}; | ||
| 1754 | |||
| 1755 | info_type = Convert<SystemInfoType>(GetReg32(system, 1)); | ||
| 1756 | handle = Convert<Handle>(GetReg32(system, 2)); | ||
| 1757 | std::array<uint32_t, 2> info_subtype_gather{}; | ||
| 1758 | info_subtype_gather[0] = GetReg32(system, 0); | ||
| 1759 | info_subtype_gather[1] = GetReg32(system, 3); | ||
| 1760 | info_subtype = Convert<uint64_t>(info_subtype_gather); | ||
| 1761 | |||
| 1762 | ret = GetSystemInfo64From32(system, &out, info_type, handle, info_subtype); | ||
| 1763 | |||
| 1764 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1765 | auto out_scatter = Convert<std::array<uint32_t, 2>>(out); | ||
| 1766 | SetReg32(system, 1, out_scatter[0]); | ||
| 1767 | SetReg32(system, 2, out_scatter[1]); | ||
| 1768 | } | ||
| 1769 | |||
| 1770 | static void SvcWrap_CreatePort64From32(Core::System& system) { | ||
| 1771 | Result ret{}; | ||
| 1772 | |||
| 1773 | Handle out_server_handle{}; | ||
| 1774 | Handle out_client_handle{}; | ||
| 1775 | int32_t max_sessions{}; | ||
| 1776 | bool is_light{}; | ||
| 1777 | uint32_t name{}; | ||
| 1778 | |||
| 1779 | max_sessions = Convert<int32_t>(GetReg32(system, 2)); | ||
| 1780 | is_light = Convert<bool>(GetReg32(system, 3)); | ||
| 1781 | name = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1782 | |||
| 1783 | ret = CreatePort64From32(system, &out_server_handle, &out_client_handle, max_sessions, is_light, name); | ||
| 1784 | |||
| 1785 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1786 | SetReg32(system, 1, Convert<uint32_t>(out_server_handle)); | ||
| 1787 | SetReg32(system, 2, Convert<uint32_t>(out_client_handle)); | ||
| 1788 | } | ||
| 1789 | |||
| 1790 | static void SvcWrap_ManageNamedPort64From32(Core::System& system) { | ||
| 1791 | Result ret{}; | ||
| 1792 | |||
| 1793 | Handle out_server_handle{}; | ||
| 1794 | uint32_t name{}; | ||
| 1795 | int32_t max_sessions{}; | ||
| 1796 | |||
| 1797 | name = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1798 | max_sessions = Convert<int32_t>(GetReg32(system, 2)); | ||
| 1799 | |||
| 1800 | ret = ManageNamedPort64From32(system, &out_server_handle, name, max_sessions); | ||
| 1801 | |||
| 1802 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1803 | SetReg32(system, 1, Convert<uint32_t>(out_server_handle)); | ||
| 1804 | } | ||
| 1805 | |||
| 1806 | static void SvcWrap_ConnectToPort64From32(Core::System& system) { | ||
| 1807 | Result ret{}; | ||
| 1808 | |||
| 1809 | Handle out_handle{}; | ||
| 1810 | Handle port{}; | ||
| 1811 | |||
| 1812 | port = Convert<Handle>(GetReg32(system, 1)); | ||
| 1813 | |||
| 1814 | ret = ConnectToPort64From32(system, &out_handle, port); | ||
| 1815 | |||
| 1816 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1817 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | ||
| 1818 | } | ||
| 1819 | |||
| 1820 | static void SvcWrap_SetProcessMemoryPermission64From32(Core::System& system) { | ||
| 1821 | Result ret{}; | ||
| 1822 | |||
| 1823 | Handle process_handle{}; | ||
| 1824 | uint64_t address{}; | ||
| 1825 | uint64_t size{}; | ||
| 1826 | MemoryPermission perm{}; | ||
| 1827 | |||
| 1828 | process_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1829 | std::array<uint32_t, 2> address_gather{}; | ||
| 1830 | address_gather[0] = GetReg32(system, 2); | ||
| 1831 | address_gather[1] = GetReg32(system, 3); | ||
| 1832 | address = Convert<uint64_t>(address_gather); | ||
| 1833 | std::array<uint32_t, 2> size_gather{}; | ||
| 1834 | size_gather[0] = GetReg32(system, 1); | ||
| 1835 | size_gather[1] = GetReg32(system, 4); | ||
| 1836 | size = Convert<uint64_t>(size_gather); | ||
| 1837 | perm = Convert<MemoryPermission>(GetReg32(system, 5)); | ||
| 1838 | |||
| 1839 | ret = SetProcessMemoryPermission64From32(system, process_handle, address, size, perm); | ||
| 1840 | |||
| 1841 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1842 | } | ||
| 1843 | |||
| 1844 | static void SvcWrap_MapProcessMemory64From32(Core::System& system) { | ||
| 1845 | Result ret{}; | ||
| 1846 | |||
| 1847 | uint32_t dst_address{}; | ||
| 1848 | Handle process_handle{}; | ||
| 1849 | uint64_t src_address{}; | ||
| 1850 | uint32_t size{}; | ||
| 1851 | |||
| 1852 | dst_address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1853 | process_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 1854 | std::array<uint32_t, 2> src_address_gather{}; | ||
| 1855 | src_address_gather[0] = GetReg32(system, 2); | ||
| 1856 | src_address_gather[1] = GetReg32(system, 3); | ||
| 1857 | src_address = Convert<uint64_t>(src_address_gather); | ||
| 1858 | size = Convert<uint32_t>(GetReg32(system, 4)); | ||
| 1859 | |||
| 1860 | ret = MapProcessMemory64From32(system, dst_address, process_handle, src_address, size); | ||
| 1861 | |||
| 1862 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1863 | } | ||
| 1864 | |||
| 1865 | static void SvcWrap_UnmapProcessMemory64From32(Core::System& system) { | ||
| 1866 | Result ret{}; | ||
| 1867 | |||
| 1868 | uint32_t dst_address{}; | ||
| 1869 | Handle process_handle{}; | ||
| 1870 | uint64_t src_address{}; | ||
| 1871 | uint32_t size{}; | ||
| 1872 | |||
| 1873 | dst_address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1874 | process_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 1875 | std::array<uint32_t, 2> src_address_gather{}; | ||
| 1876 | src_address_gather[0] = GetReg32(system, 2); | ||
| 1877 | src_address_gather[1] = GetReg32(system, 3); | ||
| 1878 | src_address = Convert<uint64_t>(src_address_gather); | ||
| 1879 | size = Convert<uint32_t>(GetReg32(system, 4)); | ||
| 1880 | |||
| 1881 | ret = UnmapProcessMemory64From32(system, dst_address, process_handle, src_address, size); | ||
| 1882 | |||
| 1883 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1884 | } | ||
| 1885 | |||
| 1886 | static void SvcWrap_QueryProcessMemory64From32(Core::System& system) { | ||
| 1887 | Result ret{}; | ||
| 1888 | |||
| 1889 | PageInfo out_page_info{}; | ||
| 1890 | uint32_t out_memory_info{}; | ||
| 1891 | Handle process_handle{}; | ||
| 1892 | uint64_t address{}; | ||
| 1893 | |||
| 1894 | out_memory_info = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 1895 | process_handle = Convert<Handle>(GetReg32(system, 2)); | ||
| 1896 | std::array<uint32_t, 2> address_gather{}; | ||
| 1897 | address_gather[0] = GetReg32(system, 1); | ||
| 1898 | address_gather[1] = GetReg32(system, 3); | ||
| 1899 | address = Convert<uint64_t>(address_gather); | ||
| 1900 | |||
| 1901 | ret = QueryProcessMemory64From32(system, out_memory_info, &out_page_info, process_handle, address); | ||
| 1902 | |||
| 1903 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1904 | SetReg32(system, 1, Convert<uint32_t>(out_page_info)); | ||
| 1905 | } | ||
| 1906 | |||
| 1907 | static void SvcWrap_MapProcessCodeMemory64From32(Core::System& system) { | ||
| 1908 | Result ret{}; | ||
| 1909 | |||
| 1910 | Handle process_handle{}; | ||
| 1911 | uint64_t dst_address{}; | ||
| 1912 | uint64_t src_address{}; | ||
| 1913 | uint64_t size{}; | ||
| 1914 | |||
| 1915 | process_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1916 | std::array<uint32_t, 2> dst_address_gather{}; | ||
| 1917 | dst_address_gather[0] = GetReg32(system, 2); | ||
| 1918 | dst_address_gather[1] = GetReg32(system, 3); | ||
| 1919 | dst_address = Convert<uint64_t>(dst_address_gather); | ||
| 1920 | std::array<uint32_t, 2> src_address_gather{}; | ||
| 1921 | src_address_gather[0] = GetReg32(system, 1); | ||
| 1922 | src_address_gather[1] = GetReg32(system, 4); | ||
| 1923 | src_address = Convert<uint64_t>(src_address_gather); | ||
| 1924 | std::array<uint32_t, 2> size_gather{}; | ||
| 1925 | size_gather[0] = GetReg32(system, 5); | ||
| 1926 | size_gather[1] = GetReg32(system, 6); | ||
| 1927 | size = Convert<uint64_t>(size_gather); | ||
| 1928 | |||
| 1929 | ret = MapProcessCodeMemory64From32(system, process_handle, dst_address, src_address, size); | ||
| 1930 | |||
| 1931 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1932 | } | ||
| 1933 | |||
| 1934 | static void SvcWrap_UnmapProcessCodeMemory64From32(Core::System& system) { | ||
| 1935 | Result ret{}; | ||
| 1936 | |||
| 1937 | Handle process_handle{}; | ||
| 1938 | uint64_t dst_address{}; | ||
| 1939 | uint64_t src_address{}; | ||
| 1940 | uint64_t size{}; | ||
| 1941 | |||
| 1942 | process_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1943 | std::array<uint32_t, 2> dst_address_gather{}; | ||
| 1944 | dst_address_gather[0] = GetReg32(system, 2); | ||
| 1945 | dst_address_gather[1] = GetReg32(system, 3); | ||
| 1946 | dst_address = Convert<uint64_t>(dst_address_gather); | ||
| 1947 | std::array<uint32_t, 2> src_address_gather{}; | ||
| 1948 | src_address_gather[0] = GetReg32(system, 1); | ||
| 1949 | src_address_gather[1] = GetReg32(system, 4); | ||
| 1950 | src_address = Convert<uint64_t>(src_address_gather); | ||
| 1951 | std::array<uint32_t, 2> size_gather{}; | ||
| 1952 | size_gather[0] = GetReg32(system, 5); | ||
| 1953 | size_gather[1] = GetReg32(system, 6); | ||
| 1954 | size = Convert<uint64_t>(size_gather); | ||
| 1955 | |||
| 1956 | ret = UnmapProcessCodeMemory64From32(system, process_handle, dst_address, src_address, size); | ||
| 1957 | |||
| 1958 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1959 | } | ||
| 1960 | |||
| 1961 | static void SvcWrap_CreateProcess64From32(Core::System& system) { | ||
| 1962 | Result ret{}; | ||
| 1963 | |||
| 1964 | Handle out_handle{}; | ||
| 1965 | uint32_t parameters{}; | ||
| 1966 | uint32_t caps{}; | ||
| 1967 | int32_t num_caps{}; | ||
| 1968 | |||
| 1969 | parameters = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 1970 | caps = Convert<uint32_t>(GetReg32(system, 2)); | ||
| 1971 | num_caps = Convert<int32_t>(GetReg32(system, 3)); | ||
| 1972 | |||
| 1973 | ret = CreateProcess64From32(system, &out_handle, parameters, caps, num_caps); | ||
| 1974 | |||
| 1975 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1976 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | ||
| 1977 | } | ||
| 1978 | |||
| 1979 | static void SvcWrap_StartProcess64From32(Core::System& system) { | ||
| 1980 | Result ret{}; | ||
| 1981 | |||
| 1982 | Handle process_handle{}; | ||
| 1983 | int32_t priority{}; | ||
| 1984 | int32_t core_id{}; | ||
| 1985 | uint64_t main_thread_stack_size{}; | ||
| 1986 | |||
| 1987 | process_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 1988 | priority = Convert<int32_t>(GetReg32(system, 1)); | ||
| 1989 | core_id = Convert<int32_t>(GetReg32(system, 2)); | ||
| 1990 | std::array<uint32_t, 2> main_thread_stack_size_gather{}; | ||
| 1991 | main_thread_stack_size_gather[0] = GetReg32(system, 3); | ||
| 1992 | main_thread_stack_size_gather[1] = GetReg32(system, 4); | ||
| 1993 | main_thread_stack_size = Convert<uint64_t>(main_thread_stack_size_gather); | ||
| 1994 | |||
| 1995 | ret = StartProcess64From32(system, process_handle, priority, core_id, main_thread_stack_size); | ||
| 1996 | |||
| 1997 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 1998 | } | ||
| 1999 | |||
| 2000 | static void SvcWrap_TerminateProcess64From32(Core::System& system) { | ||
| 2001 | Result ret{}; | ||
| 2002 | |||
| 2003 | Handle process_handle{}; | ||
| 2004 | |||
| 2005 | process_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 2006 | |||
| 2007 | ret = TerminateProcess64From32(system, process_handle); | ||
| 2008 | |||
| 2009 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 2010 | } | ||
| 2011 | |||
| 2012 | static void SvcWrap_GetProcessInfo64From32(Core::System& system) { | ||
| 2013 | Result ret{}; | ||
| 2014 | |||
| 2015 | int64_t out_info{}; | ||
| 2016 | Handle process_handle{}; | ||
| 2017 | ProcessInfoType info_type{}; | ||
| 2018 | |||
| 2019 | process_handle = Convert<Handle>(GetReg32(system, 1)); | ||
| 2020 | info_type = Convert<ProcessInfoType>(GetReg32(system, 2)); | ||
| 2021 | |||
| 2022 | ret = GetProcessInfo64From32(system, &out_info, process_handle, info_type); | ||
| 2023 | |||
| 2024 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 2025 | auto out_info_scatter = Convert<std::array<uint32_t, 2>>(out_info); | ||
| 2026 | SetReg32(system, 1, out_info_scatter[0]); | ||
| 2027 | SetReg32(system, 2, out_info_scatter[1]); | ||
| 2028 | } | ||
| 2029 | |||
| 2030 | static void SvcWrap_CreateResourceLimit64From32(Core::System& system) { | ||
| 2031 | Result ret{}; | ||
| 2032 | |||
| 2033 | Handle out_handle{}; | ||
| 2034 | |||
| 2035 | ret = CreateResourceLimit64From32(system, &out_handle); | ||
| 2036 | |||
| 2037 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 2038 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | ||
| 2039 | } | ||
| 2040 | |||
| 2041 | static void SvcWrap_SetResourceLimitLimitValue64From32(Core::System& system) { | ||
| 2042 | Result ret{}; | ||
| 2043 | |||
| 2044 | Handle resource_limit_handle{}; | ||
| 2045 | LimitableResource which{}; | ||
| 2046 | int64_t limit_value{}; | ||
| 2047 | |||
| 2048 | resource_limit_handle = Convert<Handle>(GetReg32(system, 0)); | ||
| 2049 | which = Convert<LimitableResource>(GetReg32(system, 1)); | ||
| 2050 | std::array<uint32_t, 2> limit_value_gather{}; | ||
| 2051 | limit_value_gather[0] = GetReg32(system, 2); | ||
| 2052 | limit_value_gather[1] = GetReg32(system, 3); | ||
| 2053 | limit_value = Convert<int64_t>(limit_value_gather); | ||
| 2054 | |||
| 2055 | ret = SetResourceLimitLimitValue64From32(system, resource_limit_handle, which, limit_value); | ||
| 2056 | |||
| 2057 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 2058 | } | ||
| 2059 | |||
| 2060 | static void SvcWrap_MapInsecureMemory64From32(Core::System& system) { | ||
| 2061 | Result ret{}; | ||
| 2062 | |||
| 2063 | uint32_t address{}; | ||
| 2064 | uint32_t size{}; | ||
| 2065 | |||
| 2066 | address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 2067 | size = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 2068 | |||
| 2069 | ret = MapInsecureMemory64From32(system, address, size); | ||
| 2070 | |||
| 2071 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 2072 | } | ||
| 2073 | |||
| 2074 | static void SvcWrap_UnmapInsecureMemory64From32(Core::System& system) { | ||
| 2075 | Result ret{}; | ||
| 2076 | |||
| 2077 | uint32_t address{}; | ||
| 2078 | uint32_t size{}; | ||
| 2079 | |||
| 2080 | address = Convert<uint32_t>(GetReg32(system, 0)); | ||
| 2081 | size = Convert<uint32_t>(GetReg32(system, 1)); | ||
| 2082 | |||
| 2083 | ret = UnmapInsecureMemory64From32(system, address, size); | ||
| 2084 | |||
| 2085 | SetReg32(system, 0, Convert<uint32_t>(ret)); | ||
| 2086 | } | ||
| 2087 | |||
| 2088 | static void SvcWrap_SetHeapSize64(Core::System& system) { | ||
| 2089 | Result ret{}; | ||
| 2090 | |||
| 2091 | uintptr_t out_address{}; | ||
| 2092 | uint64_t size{}; | ||
| 2093 | |||
| 2094 | size = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2095 | |||
| 2096 | ret = SetHeapSize64(system, &out_address, size); | ||
| 2097 | |||
| 2098 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2099 | SetReg64(system, 1, Convert<uint64_t>(out_address)); | ||
| 2100 | } | ||
| 2101 | |||
| 2102 | static void SvcWrap_SetMemoryPermission64(Core::System& system) { | ||
| 2103 | Result ret{}; | ||
| 2104 | |||
| 2105 | uint64_t address{}; | ||
| 2106 | uint64_t size{}; | ||
| 2107 | MemoryPermission perm{}; | ||
| 2108 | |||
| 2109 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2110 | size = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2111 | perm = Convert<MemoryPermission>(GetReg64(system, 2)); | ||
| 2112 | |||
| 2113 | ret = SetMemoryPermission64(system, address, size, perm); | ||
| 2114 | |||
| 2115 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2116 | } | ||
| 2117 | |||
| 2118 | static void SvcWrap_SetMemoryAttribute64(Core::System& system) { | ||
| 2119 | Result ret{}; | ||
| 2120 | |||
| 2121 | uint64_t address{}; | ||
| 2122 | uint64_t size{}; | ||
| 2123 | uint32_t mask{}; | ||
| 2124 | uint32_t attr{}; | ||
| 2125 | |||
| 2126 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2127 | size = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2128 | mask = Convert<uint32_t>(GetReg64(system, 2)); | ||
| 2129 | attr = Convert<uint32_t>(GetReg64(system, 3)); | ||
| 2130 | |||
| 2131 | ret = SetMemoryAttribute64(system, address, size, mask, attr); | ||
| 2132 | |||
| 2133 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2134 | } | ||
| 2135 | |||
| 2136 | static void SvcWrap_MapMemory64(Core::System& system) { | ||
| 2137 | Result ret{}; | ||
| 2138 | |||
| 2139 | uint64_t dst_address{}; | ||
| 2140 | uint64_t src_address{}; | ||
| 2141 | uint64_t size{}; | ||
| 2142 | |||
| 2143 | dst_address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2144 | src_address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2145 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2146 | |||
| 2147 | ret = MapMemory64(system, dst_address, src_address, size); | ||
| 2148 | |||
| 2149 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2150 | } | ||
| 2151 | |||
| 2152 | static void SvcWrap_UnmapMemory64(Core::System& system) { | ||
| 2153 | Result ret{}; | ||
| 2154 | |||
| 2155 | uint64_t dst_address{}; | ||
| 2156 | uint64_t src_address{}; | ||
| 2157 | uint64_t size{}; | ||
| 2158 | |||
| 2159 | dst_address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2160 | src_address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2161 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2162 | |||
| 2163 | ret = UnmapMemory64(system, dst_address, src_address, size); | ||
| 2164 | |||
| 2165 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2166 | } | ||
| 2167 | |||
| 2168 | static void SvcWrap_QueryMemory64(Core::System& system) { | ||
| 2169 | Result ret{}; | ||
| 2170 | |||
| 2171 | PageInfo out_page_info{}; | ||
| 2172 | uint64_t out_memory_info{}; | ||
| 2173 | uint64_t address{}; | ||
| 2174 | |||
| 2175 | out_memory_info = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2176 | address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2177 | |||
| 2178 | ret = QueryMemory64(system, out_memory_info, &out_page_info, address); | ||
| 2179 | |||
| 2180 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2181 | SetReg64(system, 1, Convert<uint64_t>(out_page_info)); | ||
| 2182 | } | ||
| 2183 | |||
| 2184 | static void SvcWrap_ExitProcess64(Core::System& system) { | ||
| 2185 | ExitProcess64(system); | ||
| 2186 | } | ||
| 2187 | |||
| 2188 | static void SvcWrap_CreateThread64(Core::System& system) { | ||
| 2189 | Result ret{}; | ||
| 2190 | |||
| 2191 | Handle out_handle{}; | ||
| 2192 | uint64_t func{}; | ||
| 2193 | uint64_t arg{}; | ||
| 2194 | uint64_t stack_bottom{}; | ||
| 2195 | int32_t priority{}; | ||
| 2196 | int32_t core_id{}; | ||
| 2197 | |||
| 2198 | func = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2199 | arg = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2200 | stack_bottom = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 2201 | priority = Convert<int32_t>(GetReg64(system, 4)); | ||
| 2202 | core_id = Convert<int32_t>(GetReg64(system, 5)); | ||
| 2203 | |||
| 2204 | ret = CreateThread64(system, &out_handle, func, arg, stack_bottom, priority, core_id); | ||
| 2205 | |||
| 2206 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2207 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 2208 | } | ||
| 2209 | |||
| 2210 | static void SvcWrap_StartThread64(Core::System& system) { | ||
| 2211 | Result ret{}; | ||
| 2212 | |||
| 2213 | Handle thread_handle{}; | ||
| 2214 | |||
| 2215 | thread_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2216 | |||
| 2217 | ret = StartThread64(system, thread_handle); | ||
| 2218 | |||
| 2219 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2220 | } | ||
| 2221 | |||
| 2222 | static void SvcWrap_ExitThread64(Core::System& system) { | ||
| 2223 | ExitThread64(system); | ||
| 2224 | } | ||
| 2225 | |||
| 2226 | static void SvcWrap_SleepThread64(Core::System& system) { | ||
| 2227 | int64_t ns{}; | ||
| 2228 | |||
| 2229 | ns = Convert<int64_t>(GetReg64(system, 0)); | ||
| 2230 | |||
| 2231 | SleepThread64(system, ns); | ||
| 2232 | } | ||
| 2233 | |||
| 2234 | static void SvcWrap_GetThreadPriority64(Core::System& system) { | ||
| 2235 | Result ret{}; | ||
| 2236 | |||
| 2237 | int32_t out_priority{}; | ||
| 2238 | Handle thread_handle{}; | ||
| 2239 | |||
| 2240 | thread_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 2241 | |||
| 2242 | ret = GetThreadPriority64(system, &out_priority, thread_handle); | ||
| 2243 | |||
| 2244 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2245 | SetReg64(system, 1, Convert<uint64_t>(out_priority)); | ||
| 2246 | } | ||
| 2247 | |||
| 2248 | static void SvcWrap_SetThreadPriority64(Core::System& system) { | ||
| 2249 | Result ret{}; | ||
| 2250 | |||
| 2251 | Handle thread_handle{}; | ||
| 2252 | int32_t priority{}; | ||
| 2253 | |||
| 2254 | thread_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2255 | priority = Convert<int32_t>(GetReg64(system, 1)); | ||
| 2256 | |||
| 2257 | ret = SetThreadPriority64(system, thread_handle, priority); | ||
| 2258 | |||
| 2259 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2260 | } | ||
| 2261 | |||
| 2262 | static void SvcWrap_GetThreadCoreMask64(Core::System& system) { | ||
| 2263 | Result ret{}; | ||
| 2264 | |||
| 2265 | int32_t out_core_id{}; | ||
| 2266 | uint64_t out_affinity_mask{}; | ||
| 2267 | Handle thread_handle{}; | ||
| 2268 | |||
| 2269 | thread_handle = Convert<Handle>(GetReg64(system, 2)); | ||
| 2270 | |||
| 2271 | ret = GetThreadCoreMask64(system, &out_core_id, &out_affinity_mask, thread_handle); | ||
| 2272 | |||
| 2273 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2274 | SetReg64(system, 1, Convert<uint64_t>(out_core_id)); | ||
| 2275 | SetReg64(system, 2, Convert<uint64_t>(out_affinity_mask)); | ||
| 2276 | } | ||
| 2277 | |||
| 2278 | static void SvcWrap_SetThreadCoreMask64(Core::System& system) { | ||
| 2279 | Result ret{}; | ||
| 2280 | |||
| 2281 | Handle thread_handle{}; | ||
| 2282 | int32_t core_id{}; | ||
| 2283 | uint64_t affinity_mask{}; | ||
| 2284 | |||
| 2285 | thread_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2286 | core_id = Convert<int32_t>(GetReg64(system, 1)); | ||
| 2287 | affinity_mask = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2288 | |||
| 2289 | ret = SetThreadCoreMask64(system, thread_handle, core_id, affinity_mask); | ||
| 2290 | |||
| 2291 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2292 | } | ||
| 2293 | |||
| 2294 | static void SvcWrap_GetCurrentProcessorNumber64(Core::System& system) { | ||
| 2295 | int32_t ret{}; | ||
| 2296 | |||
| 2297 | ret = GetCurrentProcessorNumber64(system); | ||
| 2298 | |||
| 2299 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2300 | } | ||
| 2301 | |||
| 2302 | static void SvcWrap_SignalEvent64(Core::System& system) { | ||
| 2303 | Result ret{}; | ||
| 2304 | |||
| 2305 | Handle event_handle{}; | ||
| 2306 | |||
| 2307 | event_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2308 | |||
| 2309 | ret = SignalEvent64(system, event_handle); | ||
| 2310 | |||
| 2311 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2312 | } | ||
| 2313 | |||
| 2314 | static void SvcWrap_ClearEvent64(Core::System& system) { | ||
| 2315 | Result ret{}; | ||
| 2316 | |||
| 2317 | Handle event_handle{}; | ||
| 2318 | |||
| 2319 | event_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2320 | |||
| 2321 | ret = ClearEvent64(system, event_handle); | ||
| 2322 | |||
| 2323 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2324 | } | ||
| 2325 | |||
| 2326 | static void SvcWrap_MapSharedMemory64(Core::System& system) { | ||
| 2327 | Result ret{}; | ||
| 2328 | |||
| 2329 | Handle shmem_handle{}; | ||
| 2330 | uint64_t address{}; | ||
| 2331 | uint64_t size{}; | ||
| 2332 | MemoryPermission map_perm{}; | ||
| 2333 | |||
| 2334 | shmem_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2335 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2336 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2337 | map_perm = Convert<MemoryPermission>(GetReg64(system, 3)); | ||
| 2338 | |||
| 2339 | ret = MapSharedMemory64(system, shmem_handle, address, size, map_perm); | ||
| 2340 | |||
| 2341 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2342 | } | ||
| 2343 | |||
| 2344 | static void SvcWrap_UnmapSharedMemory64(Core::System& system) { | ||
| 2345 | Result ret{}; | ||
| 2346 | |||
| 2347 | Handle shmem_handle{}; | ||
| 2348 | uint64_t address{}; | ||
| 2349 | uint64_t size{}; | ||
| 2350 | |||
| 2351 | shmem_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2352 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2353 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2354 | |||
| 2355 | ret = UnmapSharedMemory64(system, shmem_handle, address, size); | ||
| 2356 | |||
| 2357 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2358 | } | ||
| 2359 | |||
| 2360 | static void SvcWrap_CreateTransferMemory64(Core::System& system) { | ||
| 2361 | Result ret{}; | ||
| 2362 | |||
| 2363 | Handle out_handle{}; | ||
| 2364 | uint64_t address{}; | ||
| 2365 | uint64_t size{}; | ||
| 2366 | MemoryPermission map_perm{}; | ||
| 2367 | |||
| 2368 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2369 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2370 | map_perm = Convert<MemoryPermission>(GetReg64(system, 3)); | ||
| 2371 | |||
| 2372 | ret = CreateTransferMemory64(system, &out_handle, address, size, map_perm); | ||
| 2373 | |||
| 2374 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2375 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 2376 | } | ||
| 2377 | |||
| 2378 | static void SvcWrap_CloseHandle64(Core::System& system) { | ||
| 2379 | Result ret{}; | ||
| 2380 | |||
| 2381 | Handle handle{}; | ||
| 2382 | |||
| 2383 | handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2384 | |||
| 2385 | ret = CloseHandle64(system, handle); | ||
| 2386 | |||
| 2387 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2388 | } | ||
| 2389 | |||
| 2390 | static void SvcWrap_ResetSignal64(Core::System& system) { | ||
| 2391 | Result ret{}; | ||
| 2392 | |||
| 2393 | Handle handle{}; | ||
| 2394 | |||
| 2395 | handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2396 | |||
| 2397 | ret = ResetSignal64(system, handle); | ||
| 2398 | |||
| 2399 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2400 | } | ||
| 2401 | |||
| 2402 | static void SvcWrap_WaitSynchronization64(Core::System& system) { | ||
| 2403 | Result ret{}; | ||
| 2404 | |||
| 2405 | int32_t out_index{}; | ||
| 2406 | uint64_t handles{}; | ||
| 2407 | int32_t num_handles{}; | ||
| 2408 | int64_t timeout_ns{}; | ||
| 2409 | |||
| 2410 | handles = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2411 | num_handles = Convert<int32_t>(GetReg64(system, 2)); | ||
| 2412 | timeout_ns = Convert<int64_t>(GetReg64(system, 3)); | ||
| 2413 | |||
| 2414 | ret = WaitSynchronization64(system, &out_index, handles, num_handles, timeout_ns); | ||
| 2415 | |||
| 2416 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2417 | SetReg64(system, 1, Convert<uint64_t>(out_index)); | ||
| 2418 | } | ||
| 2419 | |||
| 2420 | static void SvcWrap_CancelSynchronization64(Core::System& system) { | ||
| 2421 | Result ret{}; | ||
| 2422 | |||
| 2423 | Handle handle{}; | ||
| 2424 | |||
| 2425 | handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2426 | |||
| 2427 | ret = CancelSynchronization64(system, handle); | ||
| 2428 | |||
| 2429 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2430 | } | ||
| 2431 | |||
| 2432 | static void SvcWrap_ArbitrateLock64(Core::System& system) { | ||
| 2433 | Result ret{}; | ||
| 2434 | |||
| 2435 | Handle thread_handle{}; | ||
| 2436 | uint64_t address{}; | ||
| 2437 | uint32_t tag{}; | ||
| 2438 | |||
| 2439 | thread_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2440 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2441 | tag = Convert<uint32_t>(GetReg64(system, 2)); | ||
| 2442 | |||
| 2443 | ret = ArbitrateLock64(system, thread_handle, address, tag); | ||
| 2444 | |||
| 2445 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2446 | } | ||
| 2447 | |||
| 2448 | static void SvcWrap_ArbitrateUnlock64(Core::System& system) { | ||
| 2449 | Result ret{}; | ||
| 2450 | |||
| 2451 | uint64_t address{}; | ||
| 2452 | |||
| 2453 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2454 | |||
| 2455 | ret = ArbitrateUnlock64(system, address); | ||
| 2456 | |||
| 2457 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2458 | } | ||
| 2459 | |||
| 2460 | static void SvcWrap_WaitProcessWideKeyAtomic64(Core::System& system) { | ||
| 2461 | Result ret{}; | ||
| 2462 | |||
| 2463 | uint64_t address{}; | ||
| 2464 | uint64_t cv_key{}; | ||
| 2465 | uint32_t tag{}; | ||
| 2466 | int64_t timeout_ns{}; | ||
| 2467 | |||
| 2468 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2469 | cv_key = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2470 | tag = Convert<uint32_t>(GetReg64(system, 2)); | ||
| 2471 | timeout_ns = Convert<int64_t>(GetReg64(system, 3)); | ||
| 2472 | |||
| 2473 | ret = WaitProcessWideKeyAtomic64(system, address, cv_key, tag, timeout_ns); | ||
| 2474 | |||
| 2475 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2476 | } | ||
| 2477 | |||
| 2478 | static void SvcWrap_SignalProcessWideKey64(Core::System& system) { | ||
| 2479 | uint64_t cv_key{}; | ||
| 2480 | int32_t count{}; | ||
| 2481 | |||
| 2482 | cv_key = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2483 | count = Convert<int32_t>(GetReg64(system, 1)); | ||
| 2484 | |||
| 2485 | SignalProcessWideKey64(system, cv_key, count); | ||
| 2486 | } | ||
| 2487 | |||
| 2488 | static void SvcWrap_GetSystemTick64(Core::System& system) { | ||
| 2489 | int64_t ret{}; | ||
| 2490 | |||
| 2491 | ret = GetSystemTick64(system); | ||
| 2492 | |||
| 2493 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2494 | } | ||
| 2495 | |||
| 2496 | static void SvcWrap_ConnectToNamedPort64(Core::System& system) { | ||
| 2497 | Result ret{}; | ||
| 2498 | |||
| 2499 | Handle out_handle{}; | ||
| 2500 | uint64_t name{}; | ||
| 2501 | |||
| 2502 | name = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2503 | |||
| 2504 | ret = ConnectToNamedPort64(system, &out_handle, name); | ||
| 2505 | |||
| 2506 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2507 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 2508 | } | ||
| 2509 | |||
| 2510 | static void SvcWrap_SendSyncRequest64(Core::System& system) { | ||
| 2511 | Result ret{}; | ||
| 2512 | |||
| 2513 | Handle session_handle{}; | ||
| 2514 | |||
| 2515 | session_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2516 | |||
| 2517 | ret = SendSyncRequest64(system, session_handle); | ||
| 2518 | |||
| 2519 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2520 | } | ||
| 2521 | |||
| 2522 | static void SvcWrap_SendSyncRequestWithUserBuffer64(Core::System& system) { | ||
| 2523 | Result ret{}; | ||
| 2524 | |||
| 2525 | uint64_t message_buffer{}; | ||
| 2526 | uint64_t message_buffer_size{}; | ||
| 2527 | Handle session_handle{}; | ||
| 2528 | |||
| 2529 | message_buffer = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2530 | message_buffer_size = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2531 | session_handle = Convert<Handle>(GetReg64(system, 2)); | ||
| 2532 | |||
| 2533 | ret = SendSyncRequestWithUserBuffer64(system, message_buffer, message_buffer_size, session_handle); | ||
| 2534 | |||
| 2535 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2536 | } | ||
| 2537 | |||
| 2538 | static void SvcWrap_SendAsyncRequestWithUserBuffer64(Core::System& system) { | ||
| 2539 | Result ret{}; | ||
| 2540 | |||
| 2541 | Handle out_event_handle{}; | ||
| 2542 | uint64_t message_buffer{}; | ||
| 2543 | uint64_t message_buffer_size{}; | ||
| 2544 | Handle session_handle{}; | ||
| 2545 | |||
| 2546 | message_buffer = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2547 | message_buffer_size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2548 | session_handle = Convert<Handle>(GetReg64(system, 3)); | ||
| 2549 | |||
| 2550 | ret = SendAsyncRequestWithUserBuffer64(system, &out_event_handle, message_buffer, message_buffer_size, session_handle); | ||
| 2551 | |||
| 2552 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2553 | SetReg64(system, 1, Convert<uint64_t>(out_event_handle)); | ||
| 2554 | } | ||
| 2555 | |||
| 2556 | static void SvcWrap_GetProcessId64(Core::System& system) { | ||
| 2557 | Result ret{}; | ||
| 2558 | |||
| 2559 | uint64_t out_process_id{}; | ||
| 2560 | Handle process_handle{}; | ||
| 2561 | |||
| 2562 | process_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 2563 | |||
| 2564 | ret = GetProcessId64(system, &out_process_id, process_handle); | ||
| 2565 | |||
| 2566 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2567 | SetReg64(system, 1, Convert<uint64_t>(out_process_id)); | ||
| 2568 | } | ||
| 2569 | |||
| 2570 | static void SvcWrap_GetThreadId64(Core::System& system) { | ||
| 2571 | Result ret{}; | ||
| 2572 | |||
| 2573 | uint64_t out_thread_id{}; | ||
| 2574 | Handle thread_handle{}; | ||
| 2575 | |||
| 2576 | thread_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 2577 | |||
| 2578 | ret = GetThreadId64(system, &out_thread_id, thread_handle); | ||
| 2579 | |||
| 2580 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2581 | SetReg64(system, 1, Convert<uint64_t>(out_thread_id)); | ||
| 2582 | } | ||
| 2583 | |||
| 2584 | static void SvcWrap_Break64(Core::System& system) { | ||
| 2585 | BreakReason break_reason{}; | ||
| 2586 | uint64_t arg{}; | ||
| 2587 | uint64_t size{}; | ||
| 2588 | |||
| 2589 | break_reason = Convert<BreakReason>(GetReg64(system, 0)); | ||
| 2590 | arg = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2591 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2592 | |||
| 2593 | Break64(system, break_reason, arg, size); | ||
| 2594 | } | ||
| 2595 | |||
| 2596 | static void SvcWrap_OutputDebugString64(Core::System& system) { | ||
| 2597 | Result ret{}; | ||
| 2598 | |||
| 2599 | uint64_t debug_str{}; | ||
| 2600 | uint64_t len{}; | ||
| 2601 | |||
| 2602 | debug_str = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2603 | len = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2604 | |||
| 2605 | ret = OutputDebugString64(system, debug_str, len); | ||
| 2606 | |||
| 2607 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2608 | } | ||
| 2609 | |||
| 2610 | static void SvcWrap_ReturnFromException64(Core::System& system) { | ||
| 2611 | Result result{}; | ||
| 2612 | |||
| 2613 | result = Convert<Result>(GetReg64(system, 0)); | ||
| 2614 | |||
| 2615 | ReturnFromException64(system, result); | ||
| 2616 | } | ||
| 2617 | |||
| 2618 | static void SvcWrap_GetInfo64(Core::System& system) { | ||
| 2619 | Result ret{}; | ||
| 2620 | |||
| 2621 | uint64_t out{}; | ||
| 2622 | InfoType info_type{}; | ||
| 2623 | Handle handle{}; | ||
| 2624 | uint64_t info_subtype{}; | ||
| 2625 | |||
| 2626 | info_type = Convert<InfoType>(GetReg64(system, 1)); | ||
| 2627 | handle = Convert<Handle>(GetReg64(system, 2)); | ||
| 2628 | info_subtype = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 2629 | |||
| 2630 | ret = GetInfo64(system, &out, info_type, handle, info_subtype); | ||
| 2631 | |||
| 2632 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2633 | SetReg64(system, 1, Convert<uint64_t>(out)); | ||
| 2634 | } | ||
| 2635 | |||
| 2636 | static void SvcWrap_FlushEntireDataCache64(Core::System& system) { | ||
| 2637 | FlushEntireDataCache64(system); | ||
| 2638 | } | ||
| 2639 | |||
| 2640 | static void SvcWrap_FlushDataCache64(Core::System& system) { | ||
| 2641 | Result ret{}; | ||
| 2642 | |||
| 2643 | uint64_t address{}; | ||
| 2644 | uint64_t size{}; | ||
| 2645 | |||
| 2646 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2647 | size = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2648 | |||
| 2649 | ret = FlushDataCache64(system, address, size); | ||
| 2650 | |||
| 2651 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2652 | } | ||
| 2653 | |||
| 2654 | static void SvcWrap_MapPhysicalMemory64(Core::System& system) { | ||
| 2655 | Result ret{}; | ||
| 2656 | |||
| 2657 | uint64_t address{}; | ||
| 2658 | uint64_t size{}; | ||
| 2659 | |||
| 2660 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2661 | size = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2662 | |||
| 2663 | ret = MapPhysicalMemory64(system, address, size); | ||
| 2664 | |||
| 2665 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2666 | } | ||
| 2667 | |||
| 2668 | static void SvcWrap_UnmapPhysicalMemory64(Core::System& system) { | ||
| 2669 | Result ret{}; | ||
| 2670 | |||
| 2671 | uint64_t address{}; | ||
| 2672 | uint64_t size{}; | ||
| 2673 | |||
| 2674 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2675 | size = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2676 | |||
| 2677 | ret = UnmapPhysicalMemory64(system, address, size); | ||
| 2678 | |||
| 2679 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2680 | } | ||
| 2681 | |||
| 2682 | static void SvcWrap_GetDebugFutureThreadInfo64(Core::System& system) { | ||
| 2683 | Result ret{}; | ||
| 2684 | |||
| 2685 | lp64::LastThreadContext out_context{}; | ||
| 2686 | uint64_t out_thread_id{}; | ||
| 2687 | Handle debug_handle{}; | ||
| 2688 | int64_t ns{}; | ||
| 2689 | |||
| 2690 | debug_handle = Convert<Handle>(GetReg64(system, 2)); | ||
| 2691 | ns = Convert<int64_t>(GetReg64(system, 3)); | ||
| 2692 | |||
| 2693 | ret = GetDebugFutureThreadInfo64(system, &out_context, &out_thread_id, debug_handle, ns); | ||
| 2694 | |||
| 2695 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2696 | auto out_context_scatter = Convert<std::array<uint64_t, 4>>(out_context); | ||
| 2697 | SetReg64(system, 1, out_context_scatter[0]); | ||
| 2698 | SetReg64(system, 2, out_context_scatter[1]); | ||
| 2699 | SetReg64(system, 3, out_context_scatter[2]); | ||
| 2700 | SetReg64(system, 4, out_context_scatter[3]); | ||
| 2701 | SetReg64(system, 5, Convert<uint64_t>(out_thread_id)); | ||
| 2702 | } | ||
| 2703 | |||
| 2704 | static void SvcWrap_GetLastThreadInfo64(Core::System& system) { | ||
| 2705 | Result ret{}; | ||
| 2706 | |||
| 2707 | lp64::LastThreadContext out_context{}; | ||
| 2708 | uintptr_t out_tls_address{}; | ||
| 2709 | uint32_t out_flags{}; | ||
| 2710 | |||
| 2711 | ret = GetLastThreadInfo64(system, &out_context, &out_tls_address, &out_flags); | ||
| 2712 | |||
| 2713 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2714 | auto out_context_scatter = Convert<std::array<uint64_t, 4>>(out_context); | ||
| 2715 | SetReg64(system, 1, out_context_scatter[0]); | ||
| 2716 | SetReg64(system, 2, out_context_scatter[1]); | ||
| 2717 | SetReg64(system, 3, out_context_scatter[2]); | ||
| 2718 | SetReg64(system, 4, out_context_scatter[3]); | ||
| 2719 | SetReg64(system, 5, Convert<uint64_t>(out_tls_address)); | ||
| 2720 | SetReg64(system, 6, Convert<uint64_t>(out_flags)); | ||
| 2721 | } | ||
| 2722 | |||
| 2723 | static void SvcWrap_GetResourceLimitLimitValue64(Core::System& system) { | ||
| 2724 | Result ret{}; | ||
| 2725 | |||
| 2726 | int64_t out_limit_value{}; | ||
| 2727 | Handle resource_limit_handle{}; | ||
| 2728 | LimitableResource which{}; | ||
| 2729 | |||
| 2730 | resource_limit_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 2731 | which = Convert<LimitableResource>(GetReg64(system, 2)); | ||
| 2732 | |||
| 2733 | ret = GetResourceLimitLimitValue64(system, &out_limit_value, resource_limit_handle, which); | ||
| 2734 | |||
| 2735 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2736 | SetReg64(system, 1, Convert<uint64_t>(out_limit_value)); | ||
| 2737 | } | ||
| 2738 | |||
| 2739 | static void SvcWrap_GetResourceLimitCurrentValue64(Core::System& system) { | ||
| 2740 | Result ret{}; | ||
| 2741 | |||
| 2742 | int64_t out_current_value{}; | ||
| 2743 | Handle resource_limit_handle{}; | ||
| 2744 | LimitableResource which{}; | ||
| 2745 | |||
| 2746 | resource_limit_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 2747 | which = Convert<LimitableResource>(GetReg64(system, 2)); | ||
| 2748 | |||
| 2749 | ret = GetResourceLimitCurrentValue64(system, &out_current_value, resource_limit_handle, which); | ||
| 2750 | |||
| 2751 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2752 | SetReg64(system, 1, Convert<uint64_t>(out_current_value)); | ||
| 2753 | } | ||
| 2754 | |||
| 2755 | static void SvcWrap_SetThreadActivity64(Core::System& system) { | ||
| 2756 | Result ret{}; | ||
| 2757 | |||
| 2758 | Handle thread_handle{}; | ||
| 2759 | ThreadActivity thread_activity{}; | ||
| 2760 | |||
| 2761 | thread_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 2762 | thread_activity = Convert<ThreadActivity>(GetReg64(system, 1)); | ||
| 2763 | |||
| 2764 | ret = SetThreadActivity64(system, thread_handle, thread_activity); | ||
| 2765 | |||
| 2766 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2767 | } | ||
| 2768 | |||
| 2769 | static void SvcWrap_GetThreadContext364(Core::System& system) { | ||
| 2770 | Result ret{}; | ||
| 2771 | |||
| 2772 | uint64_t out_context{}; | ||
| 2773 | Handle thread_handle{}; | ||
| 2774 | |||
| 2775 | out_context = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2776 | thread_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 2777 | |||
| 2778 | ret = GetThreadContext364(system, out_context, thread_handle); | ||
| 2779 | |||
| 2780 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2781 | } | ||
| 2782 | |||
| 2783 | static void SvcWrap_WaitForAddress64(Core::System& system) { | ||
| 2784 | Result ret{}; | ||
| 2785 | |||
| 2786 | uint64_t address{}; | ||
| 2787 | ArbitrationType arb_type{}; | ||
| 2788 | int32_t value{}; | ||
| 2789 | int64_t timeout_ns{}; | ||
| 2790 | |||
| 2791 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2792 | arb_type = Convert<ArbitrationType>(GetReg64(system, 1)); | ||
| 2793 | value = Convert<int32_t>(GetReg64(system, 2)); | ||
| 2794 | timeout_ns = Convert<int64_t>(GetReg64(system, 3)); | ||
| 2795 | |||
| 2796 | ret = WaitForAddress64(system, address, arb_type, value, timeout_ns); | ||
| 2797 | |||
| 2798 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2799 | } | ||
| 2800 | |||
| 2801 | static void SvcWrap_SignalToAddress64(Core::System& system) { | ||
| 2802 | Result ret{}; | ||
| 2803 | |||
| 2804 | uint64_t address{}; | ||
| 2805 | SignalType signal_type{}; | ||
| 2806 | int32_t value{}; | ||
| 2807 | int32_t count{}; | ||
| 2808 | |||
| 2809 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 2810 | signal_type = Convert<SignalType>(GetReg64(system, 1)); | ||
| 2811 | value = Convert<int32_t>(GetReg64(system, 2)); | ||
| 2812 | count = Convert<int32_t>(GetReg64(system, 3)); | ||
| 2813 | |||
| 2814 | ret = SignalToAddress64(system, address, signal_type, value, count); | ||
| 2815 | |||
| 2816 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2817 | } | ||
| 2818 | |||
| 2819 | static void SvcWrap_SynchronizePreemptionState64(Core::System& system) { | ||
| 2820 | SynchronizePreemptionState64(system); | ||
| 2821 | } | ||
| 2822 | |||
| 2823 | static void SvcWrap_GetResourceLimitPeakValue64(Core::System& system) { | ||
| 2824 | Result ret{}; | ||
| 2825 | |||
| 2826 | int64_t out_peak_value{}; | ||
| 2827 | Handle resource_limit_handle{}; | ||
| 2828 | LimitableResource which{}; | ||
| 2829 | |||
| 2830 | resource_limit_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 2831 | which = Convert<LimitableResource>(GetReg64(system, 2)); | ||
| 2832 | |||
| 2833 | ret = GetResourceLimitPeakValue64(system, &out_peak_value, resource_limit_handle, which); | ||
| 2834 | |||
| 2835 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2836 | SetReg64(system, 1, Convert<uint64_t>(out_peak_value)); | ||
| 2837 | } | ||
| 2838 | |||
| 2839 | static void SvcWrap_CreateIoPool64(Core::System& system) { | ||
| 2840 | Result ret{}; | ||
| 2841 | |||
| 2842 | Handle out_handle{}; | ||
| 2843 | IoPoolType which{}; | ||
| 2844 | |||
| 2845 | which = Convert<IoPoolType>(GetReg64(system, 1)); | ||
| 2846 | |||
| 2847 | ret = CreateIoPool64(system, &out_handle, which); | ||
| 2848 | |||
| 2849 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2850 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 2851 | } | ||
| 2852 | |||
| 2853 | static void SvcWrap_CreateIoRegion64(Core::System& system) { | ||
| 2854 | Result ret{}; | ||
| 2855 | |||
| 2856 | Handle out_handle{}; | ||
| 2857 | Handle io_pool{}; | ||
| 2858 | uint64_t physical_address{}; | ||
| 2859 | uint64_t size{}; | ||
| 2860 | MemoryMapping mapping{}; | ||
| 2861 | MemoryPermission perm{}; | ||
| 2862 | |||
| 2863 | io_pool = Convert<Handle>(GetReg64(system, 1)); | ||
| 2864 | physical_address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2865 | size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 2866 | mapping = Convert<MemoryMapping>(GetReg64(system, 4)); | ||
| 2867 | perm = Convert<MemoryPermission>(GetReg64(system, 5)); | ||
| 2868 | |||
| 2869 | ret = CreateIoRegion64(system, &out_handle, io_pool, physical_address, size, mapping, perm); | ||
| 2870 | |||
| 2871 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2872 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 2873 | } | ||
| 2874 | |||
| 2875 | static void SvcWrap_KernelDebug64(Core::System& system) { | ||
| 2876 | KernelDebugType kern_debug_type{}; | ||
| 2877 | uint64_t arg0{}; | ||
| 2878 | uint64_t arg1{}; | ||
| 2879 | uint64_t arg2{}; | ||
| 2880 | |||
| 2881 | kern_debug_type = Convert<KernelDebugType>(GetReg64(system, 0)); | ||
| 2882 | arg0 = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2883 | arg1 = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2884 | arg2 = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 2885 | |||
| 2886 | KernelDebug64(system, kern_debug_type, arg0, arg1, arg2); | ||
| 2887 | } | ||
| 2888 | |||
| 2889 | static void SvcWrap_ChangeKernelTraceState64(Core::System& system) { | ||
| 2890 | KernelTraceState kern_trace_state{}; | ||
| 2891 | |||
| 2892 | kern_trace_state = Convert<KernelTraceState>(GetReg64(system, 0)); | ||
| 2893 | |||
| 2894 | ChangeKernelTraceState64(system, kern_trace_state); | ||
| 2895 | } | ||
| 2896 | |||
| 2897 | static void SvcWrap_CreateSession64(Core::System& system) { | ||
| 2898 | Result ret{}; | ||
| 2899 | |||
| 2900 | Handle out_server_session_handle{}; | ||
| 2901 | Handle out_client_session_handle{}; | ||
| 2902 | bool is_light{}; | ||
| 2903 | uint64_t name{}; | ||
| 2904 | |||
| 2905 | is_light = Convert<bool>(GetReg64(system, 2)); | ||
| 2906 | name = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 2907 | |||
| 2908 | ret = CreateSession64(system, &out_server_session_handle, &out_client_session_handle, is_light, name); | ||
| 2909 | |||
| 2910 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2911 | SetReg64(system, 1, Convert<uint64_t>(out_server_session_handle)); | ||
| 2912 | SetReg64(system, 2, Convert<uint64_t>(out_client_session_handle)); | ||
| 2913 | } | ||
| 2914 | |||
| 2915 | static void SvcWrap_AcceptSession64(Core::System& system) { | ||
| 2916 | Result ret{}; | ||
| 2917 | |||
| 2918 | Handle out_handle{}; | ||
| 2919 | Handle port{}; | ||
| 2920 | |||
| 2921 | port = Convert<Handle>(GetReg64(system, 1)); | ||
| 2922 | |||
| 2923 | ret = AcceptSession64(system, &out_handle, port); | ||
| 2924 | |||
| 2925 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2926 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 2927 | } | ||
| 2928 | |||
| 2929 | static void SvcWrap_ReplyAndReceive64(Core::System& system) { | ||
| 2930 | Result ret{}; | ||
| 2931 | |||
| 2932 | int32_t out_index{}; | ||
| 2933 | uint64_t handles{}; | ||
| 2934 | int32_t num_handles{}; | ||
| 2935 | Handle reply_target{}; | ||
| 2936 | int64_t timeout_ns{}; | ||
| 2937 | |||
| 2938 | handles = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2939 | num_handles = Convert<int32_t>(GetReg64(system, 2)); | ||
| 2940 | reply_target = Convert<Handle>(GetReg64(system, 3)); | ||
| 2941 | timeout_ns = Convert<int64_t>(GetReg64(system, 4)); | ||
| 2942 | |||
| 2943 | ret = ReplyAndReceive64(system, &out_index, handles, num_handles, reply_target, timeout_ns); | ||
| 2944 | |||
| 2945 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2946 | SetReg64(system, 1, Convert<uint64_t>(out_index)); | ||
| 2947 | } | ||
| 2948 | |||
| 2949 | static void SvcWrap_ReplyAndReceiveWithUserBuffer64(Core::System& system) { | ||
| 2950 | Result ret{}; | ||
| 2951 | |||
| 2952 | int32_t out_index{}; | ||
| 2953 | uint64_t message_buffer{}; | ||
| 2954 | uint64_t message_buffer_size{}; | ||
| 2955 | uint64_t handles{}; | ||
| 2956 | int32_t num_handles{}; | ||
| 2957 | Handle reply_target{}; | ||
| 2958 | int64_t timeout_ns{}; | ||
| 2959 | |||
| 2960 | message_buffer = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2961 | message_buffer_size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2962 | handles = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 2963 | num_handles = Convert<int32_t>(GetReg64(system, 4)); | ||
| 2964 | reply_target = Convert<Handle>(GetReg64(system, 5)); | ||
| 2965 | timeout_ns = Convert<int64_t>(GetReg64(system, 6)); | ||
| 2966 | |||
| 2967 | ret = ReplyAndReceiveWithUserBuffer64(system, &out_index, message_buffer, message_buffer_size, handles, num_handles, reply_target, timeout_ns); | ||
| 2968 | |||
| 2969 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2970 | SetReg64(system, 1, Convert<uint64_t>(out_index)); | ||
| 2971 | } | ||
| 2972 | |||
| 2973 | static void SvcWrap_CreateEvent64(Core::System& system) { | ||
| 2974 | Result ret{}; | ||
| 2975 | |||
| 2976 | Handle out_write_handle{}; | ||
| 2977 | Handle out_read_handle{}; | ||
| 2978 | |||
| 2979 | ret = CreateEvent64(system, &out_write_handle, &out_read_handle); | ||
| 2980 | |||
| 2981 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 2982 | SetReg64(system, 1, Convert<uint64_t>(out_write_handle)); | ||
| 2983 | SetReg64(system, 2, Convert<uint64_t>(out_read_handle)); | ||
| 2984 | } | ||
| 2985 | |||
| 2986 | static void SvcWrap_MapIoRegion64(Core::System& system) { | ||
| 2987 | Result ret{}; | ||
| 2988 | |||
| 2989 | Handle io_region{}; | ||
| 2990 | uint64_t address{}; | ||
| 2991 | uint64_t size{}; | ||
| 2992 | MemoryPermission perm{}; | ||
| 2993 | |||
| 2994 | io_region = Convert<Handle>(GetReg64(system, 0)); | ||
| 2995 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 2996 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 2997 | perm = Convert<MemoryPermission>(GetReg64(system, 3)); | ||
| 2998 | |||
| 2999 | ret = MapIoRegion64(system, io_region, address, size, perm); | ||
| 3000 | |||
| 3001 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3002 | } | ||
| 3003 | |||
| 3004 | static void SvcWrap_UnmapIoRegion64(Core::System& system) { | ||
| 3005 | Result ret{}; | ||
| 3006 | |||
| 3007 | Handle io_region{}; | ||
| 3008 | uint64_t address{}; | ||
| 3009 | uint64_t size{}; | ||
| 3010 | |||
| 3011 | io_region = Convert<Handle>(GetReg64(system, 0)); | ||
| 3012 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3013 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3014 | |||
| 3015 | ret = UnmapIoRegion64(system, io_region, address, size); | ||
| 3016 | |||
| 3017 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3018 | } | ||
| 3019 | |||
| 3020 | static void SvcWrap_MapPhysicalMemoryUnsafe64(Core::System& system) { | ||
| 3021 | Result ret{}; | ||
| 3022 | |||
| 3023 | uint64_t address{}; | ||
| 3024 | uint64_t size{}; | ||
| 3025 | |||
| 3026 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 3027 | size = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3028 | |||
| 3029 | ret = MapPhysicalMemoryUnsafe64(system, address, size); | ||
| 3030 | |||
| 3031 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3032 | } | ||
| 3033 | |||
| 3034 | static void SvcWrap_UnmapPhysicalMemoryUnsafe64(Core::System& system) { | ||
| 3035 | Result ret{}; | ||
| 3036 | |||
| 3037 | uint64_t address{}; | ||
| 3038 | uint64_t size{}; | ||
| 3039 | |||
| 3040 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 3041 | size = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3042 | |||
| 3043 | ret = UnmapPhysicalMemoryUnsafe64(system, address, size); | ||
| 3044 | |||
| 3045 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3046 | } | ||
| 3047 | |||
| 3048 | static void SvcWrap_SetUnsafeLimit64(Core::System& system) { | ||
| 3049 | Result ret{}; | ||
| 3050 | |||
| 3051 | uint64_t limit{}; | ||
| 3052 | |||
| 3053 | limit = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 3054 | |||
| 3055 | ret = SetUnsafeLimit64(system, limit); | ||
| 3056 | |||
| 3057 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3058 | } | ||
| 3059 | |||
| 3060 | static void SvcWrap_CreateCodeMemory64(Core::System& system) { | ||
| 3061 | Result ret{}; | ||
| 3062 | |||
| 3063 | Handle out_handle{}; | ||
| 3064 | uint64_t address{}; | ||
| 3065 | uint64_t size{}; | ||
| 3066 | |||
| 3067 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3068 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3069 | |||
| 3070 | ret = CreateCodeMemory64(system, &out_handle, address, size); | ||
| 3071 | |||
| 3072 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3073 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 3074 | } | ||
| 3075 | |||
| 3076 | static void SvcWrap_ControlCodeMemory64(Core::System& system) { | ||
| 3077 | Result ret{}; | ||
| 3078 | |||
| 3079 | Handle code_memory_handle{}; | ||
| 3080 | CodeMemoryOperation operation{}; | ||
| 3081 | uint64_t address{}; | ||
| 3082 | uint64_t size{}; | ||
| 3083 | MemoryPermission perm{}; | ||
| 3084 | |||
| 3085 | code_memory_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3086 | operation = Convert<CodeMemoryOperation>(GetReg64(system, 1)); | ||
| 3087 | address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3088 | size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3089 | perm = Convert<MemoryPermission>(GetReg64(system, 4)); | ||
| 3090 | |||
| 3091 | ret = ControlCodeMemory64(system, code_memory_handle, operation, address, size, perm); | ||
| 3092 | |||
| 3093 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3094 | } | ||
| 3095 | |||
| 3096 | static void SvcWrap_SleepSystem64(Core::System& system) { | ||
| 3097 | SleepSystem64(system); | ||
| 3098 | } | ||
| 3099 | |||
| 3100 | static void SvcWrap_ReadWriteRegister64(Core::System& system) { | ||
| 3101 | Result ret{}; | ||
| 3102 | |||
| 3103 | uint32_t out_value{}; | ||
| 3104 | uint64_t address{}; | ||
| 3105 | uint32_t mask{}; | ||
| 3106 | uint32_t value{}; | ||
| 3107 | |||
| 3108 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3109 | mask = Convert<uint32_t>(GetReg64(system, 2)); | ||
| 3110 | value = Convert<uint32_t>(GetReg64(system, 3)); | ||
| 3111 | |||
| 3112 | ret = ReadWriteRegister64(system, &out_value, address, mask, value); | ||
| 3113 | |||
| 3114 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3115 | SetReg64(system, 1, Convert<uint64_t>(out_value)); | ||
| 3116 | } | ||
| 3117 | |||
| 3118 | static void SvcWrap_SetProcessActivity64(Core::System& system) { | ||
| 3119 | Result ret{}; | ||
| 3120 | |||
| 3121 | Handle process_handle{}; | ||
| 3122 | ProcessActivity process_activity{}; | ||
| 3123 | |||
| 3124 | process_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3125 | process_activity = Convert<ProcessActivity>(GetReg64(system, 1)); | ||
| 3126 | |||
| 3127 | ret = SetProcessActivity64(system, process_handle, process_activity); | ||
| 3128 | |||
| 3129 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3130 | } | ||
| 3131 | |||
| 3132 | static void SvcWrap_CreateSharedMemory64(Core::System& system) { | ||
| 3133 | Result ret{}; | ||
| 3134 | |||
| 3135 | Handle out_handle{}; | ||
| 3136 | uint64_t size{}; | ||
| 3137 | MemoryPermission owner_perm{}; | ||
| 3138 | MemoryPermission remote_perm{}; | ||
| 3139 | |||
| 3140 | size = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3141 | owner_perm = Convert<MemoryPermission>(GetReg64(system, 2)); | ||
| 3142 | remote_perm = Convert<MemoryPermission>(GetReg64(system, 3)); | ||
| 3143 | |||
| 3144 | ret = CreateSharedMemory64(system, &out_handle, size, owner_perm, remote_perm); | ||
| 3145 | |||
| 3146 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3147 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 3148 | } | ||
| 3149 | |||
| 3150 | static void SvcWrap_MapTransferMemory64(Core::System& system) { | ||
| 3151 | Result ret{}; | ||
| 3152 | |||
| 3153 | Handle trmem_handle{}; | ||
| 3154 | uint64_t address{}; | ||
| 3155 | uint64_t size{}; | ||
| 3156 | MemoryPermission owner_perm{}; | ||
| 3157 | |||
| 3158 | trmem_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3159 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3160 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3161 | owner_perm = Convert<MemoryPermission>(GetReg64(system, 3)); | ||
| 3162 | |||
| 3163 | ret = MapTransferMemory64(system, trmem_handle, address, size, owner_perm); | ||
| 3164 | |||
| 3165 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3166 | } | ||
| 3167 | |||
| 3168 | static void SvcWrap_UnmapTransferMemory64(Core::System& system) { | ||
| 3169 | Result ret{}; | ||
| 3170 | |||
| 3171 | Handle trmem_handle{}; | ||
| 3172 | uint64_t address{}; | ||
| 3173 | uint64_t size{}; | ||
| 3174 | |||
| 3175 | trmem_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3176 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3177 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3178 | |||
| 3179 | ret = UnmapTransferMemory64(system, trmem_handle, address, size); | ||
| 3180 | |||
| 3181 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3182 | } | ||
| 3183 | |||
| 3184 | static void SvcWrap_CreateInterruptEvent64(Core::System& system) { | ||
| 3185 | Result ret{}; | ||
| 3186 | |||
| 3187 | Handle out_read_handle{}; | ||
| 3188 | int32_t interrupt_id{}; | ||
| 3189 | InterruptType interrupt_type{}; | ||
| 3190 | |||
| 3191 | interrupt_id = Convert<int32_t>(GetReg64(system, 1)); | ||
| 3192 | interrupt_type = Convert<InterruptType>(GetReg64(system, 2)); | ||
| 3193 | |||
| 3194 | ret = CreateInterruptEvent64(system, &out_read_handle, interrupt_id, interrupt_type); | ||
| 3195 | |||
| 3196 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3197 | SetReg64(system, 1, Convert<uint64_t>(out_read_handle)); | ||
| 3198 | } | ||
| 3199 | |||
| 3200 | static void SvcWrap_QueryPhysicalAddress64(Core::System& system) { | ||
| 3201 | Result ret{}; | ||
| 3202 | |||
| 3203 | lp64::PhysicalMemoryInfo out_info{}; | ||
| 3204 | uint64_t address{}; | ||
| 3205 | |||
| 3206 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3207 | |||
| 3208 | ret = QueryPhysicalAddress64(system, &out_info, address); | ||
| 3209 | |||
| 3210 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3211 | auto out_info_scatter = Convert<std::array<uint64_t, 3>>(out_info); | ||
| 3212 | SetReg64(system, 1, out_info_scatter[0]); | ||
| 3213 | SetReg64(system, 2, out_info_scatter[1]); | ||
| 3214 | SetReg64(system, 3, out_info_scatter[2]); | ||
| 3215 | } | ||
| 3216 | |||
| 3217 | static void SvcWrap_QueryIoMapping64(Core::System& system) { | ||
| 3218 | Result ret{}; | ||
| 3219 | |||
| 3220 | uintptr_t out_address{}; | ||
| 3221 | uintptr_t out_size{}; | ||
| 3222 | uint64_t physical_address{}; | ||
| 3223 | uint64_t size{}; | ||
| 3224 | |||
| 3225 | physical_address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3226 | size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3227 | |||
| 3228 | ret = QueryIoMapping64(system, &out_address, &out_size, physical_address, size); | ||
| 3229 | |||
| 3230 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3231 | SetReg64(system, 1, Convert<uint64_t>(out_address)); | ||
| 3232 | SetReg64(system, 2, Convert<uint64_t>(out_size)); | ||
| 3233 | } | ||
| 3234 | |||
| 3235 | static void SvcWrap_CreateDeviceAddressSpace64(Core::System& system) { | ||
| 3236 | Result ret{}; | ||
| 3237 | |||
| 3238 | Handle out_handle{}; | ||
| 3239 | uint64_t das_address{}; | ||
| 3240 | uint64_t das_size{}; | ||
| 3241 | |||
| 3242 | das_address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3243 | das_size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3244 | |||
| 3245 | ret = CreateDeviceAddressSpace64(system, &out_handle, das_address, das_size); | ||
| 3246 | |||
| 3247 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3248 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 3249 | } | ||
| 3250 | |||
| 3251 | static void SvcWrap_AttachDeviceAddressSpace64(Core::System& system) { | ||
| 3252 | Result ret{}; | ||
| 3253 | |||
| 3254 | DeviceName device_name{}; | ||
| 3255 | Handle das_handle{}; | ||
| 3256 | |||
| 3257 | device_name = Convert<DeviceName>(GetReg64(system, 0)); | ||
| 3258 | das_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 3259 | |||
| 3260 | ret = AttachDeviceAddressSpace64(system, device_name, das_handle); | ||
| 3261 | |||
| 3262 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3263 | } | ||
| 3264 | |||
| 3265 | static void SvcWrap_DetachDeviceAddressSpace64(Core::System& system) { | ||
| 3266 | Result ret{}; | ||
| 3267 | |||
| 3268 | DeviceName device_name{}; | ||
| 3269 | Handle das_handle{}; | ||
| 3270 | |||
| 3271 | device_name = Convert<DeviceName>(GetReg64(system, 0)); | ||
| 3272 | das_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 3273 | |||
| 3274 | ret = DetachDeviceAddressSpace64(system, device_name, das_handle); | ||
| 3275 | |||
| 3276 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3277 | } | ||
| 3278 | |||
| 3279 | static void SvcWrap_MapDeviceAddressSpaceByForce64(Core::System& system) { | ||
| 3280 | Result ret{}; | ||
| 3281 | |||
| 3282 | Handle das_handle{}; | ||
| 3283 | Handle process_handle{}; | ||
| 3284 | uint64_t process_address{}; | ||
| 3285 | uint64_t size{}; | ||
| 3286 | uint64_t device_address{}; | ||
| 3287 | uint32_t option{}; | ||
| 3288 | |||
| 3289 | das_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3290 | process_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 3291 | process_address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3292 | size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3293 | device_address = Convert<uint64_t>(GetReg64(system, 4)); | ||
| 3294 | option = Convert<uint32_t>(GetReg64(system, 5)); | ||
| 3295 | |||
| 3296 | ret = MapDeviceAddressSpaceByForce64(system, das_handle, process_handle, process_address, size, device_address, option); | ||
| 3297 | |||
| 3298 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3299 | } | ||
| 3300 | |||
| 3301 | static void SvcWrap_MapDeviceAddressSpaceAligned64(Core::System& system) { | ||
| 3302 | Result ret{}; | ||
| 3303 | |||
| 3304 | Handle das_handle{}; | ||
| 3305 | Handle process_handle{}; | ||
| 3306 | uint64_t process_address{}; | ||
| 3307 | uint64_t size{}; | ||
| 3308 | uint64_t device_address{}; | ||
| 3309 | uint32_t option{}; | ||
| 3310 | |||
| 3311 | das_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3312 | process_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 3313 | process_address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3314 | size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3315 | device_address = Convert<uint64_t>(GetReg64(system, 4)); | ||
| 3316 | option = Convert<uint32_t>(GetReg64(system, 5)); | ||
| 3317 | |||
| 3318 | ret = MapDeviceAddressSpaceAligned64(system, das_handle, process_handle, process_address, size, device_address, option); | ||
| 3319 | |||
| 3320 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3321 | } | ||
| 3322 | |||
| 3323 | static void SvcWrap_UnmapDeviceAddressSpace64(Core::System& system) { | ||
| 3324 | Result ret{}; | ||
| 3325 | |||
| 3326 | Handle das_handle{}; | ||
| 3327 | Handle process_handle{}; | ||
| 3328 | uint64_t process_address{}; | ||
| 3329 | uint64_t size{}; | ||
| 3330 | uint64_t device_address{}; | ||
| 3331 | |||
| 3332 | das_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3333 | process_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 3334 | process_address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3335 | size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3336 | device_address = Convert<uint64_t>(GetReg64(system, 4)); | ||
| 3337 | |||
| 3338 | ret = UnmapDeviceAddressSpace64(system, das_handle, process_handle, process_address, size, device_address); | ||
| 3339 | |||
| 3340 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3341 | } | ||
| 3342 | |||
| 3343 | static void SvcWrap_InvalidateProcessDataCache64(Core::System& system) { | ||
| 3344 | Result ret{}; | ||
| 3345 | |||
| 3346 | Handle process_handle{}; | ||
| 3347 | uint64_t address{}; | ||
| 3348 | uint64_t size{}; | ||
| 3349 | |||
| 3350 | process_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3351 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3352 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3353 | |||
| 3354 | ret = InvalidateProcessDataCache64(system, process_handle, address, size); | ||
| 3355 | |||
| 3356 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3357 | } | ||
| 3358 | |||
| 3359 | static void SvcWrap_StoreProcessDataCache64(Core::System& system) { | ||
| 3360 | Result ret{}; | ||
| 3361 | |||
| 3362 | Handle process_handle{}; | ||
| 3363 | uint64_t address{}; | ||
| 3364 | uint64_t size{}; | ||
| 3365 | |||
| 3366 | process_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3367 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3368 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3369 | |||
| 3370 | ret = StoreProcessDataCache64(system, process_handle, address, size); | ||
| 3371 | |||
| 3372 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3373 | } | ||
| 3374 | |||
| 3375 | static void SvcWrap_FlushProcessDataCache64(Core::System& system) { | ||
| 3376 | Result ret{}; | ||
| 3377 | |||
| 3378 | Handle process_handle{}; | ||
| 3379 | uint64_t address{}; | ||
| 3380 | uint64_t size{}; | ||
| 3381 | |||
| 3382 | process_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3383 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3384 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3385 | |||
| 3386 | ret = FlushProcessDataCache64(system, process_handle, address, size); | ||
| 3387 | |||
| 3388 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3389 | } | ||
| 3390 | |||
| 3391 | static void SvcWrap_DebugActiveProcess64(Core::System& system) { | ||
| 3392 | Result ret{}; | ||
| 3393 | |||
| 3394 | Handle out_handle{}; | ||
| 3395 | uint64_t process_id{}; | ||
| 3396 | |||
| 3397 | process_id = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3398 | |||
| 3399 | ret = DebugActiveProcess64(system, &out_handle, process_id); | ||
| 3400 | |||
| 3401 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3402 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 3403 | } | ||
| 3404 | |||
| 3405 | static void SvcWrap_BreakDebugProcess64(Core::System& system) { | ||
| 3406 | Result ret{}; | ||
| 3407 | |||
| 3408 | Handle debug_handle{}; | ||
| 3409 | |||
| 3410 | debug_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3411 | |||
| 3412 | ret = BreakDebugProcess64(system, debug_handle); | ||
| 3413 | |||
| 3414 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3415 | } | ||
| 3416 | |||
| 3417 | static void SvcWrap_TerminateDebugProcess64(Core::System& system) { | ||
| 3418 | Result ret{}; | ||
| 3419 | |||
| 3420 | Handle debug_handle{}; | ||
| 3421 | |||
| 3422 | debug_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3423 | |||
| 3424 | ret = TerminateDebugProcess64(system, debug_handle); | ||
| 3425 | |||
| 3426 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3427 | } | ||
| 3428 | |||
| 3429 | static void SvcWrap_GetDebugEvent64(Core::System& system) { | ||
| 3430 | Result ret{}; | ||
| 3431 | |||
| 3432 | uint64_t out_info{}; | ||
| 3433 | Handle debug_handle{}; | ||
| 3434 | |||
| 3435 | out_info = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 3436 | debug_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 3437 | |||
| 3438 | ret = GetDebugEvent64(system, out_info, debug_handle); | ||
| 3439 | |||
| 3440 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3441 | } | ||
| 3442 | |||
| 3443 | static void SvcWrap_ContinueDebugEvent64(Core::System& system) { | ||
| 3444 | Result ret{}; | ||
| 3445 | |||
| 3446 | Handle debug_handle{}; | ||
| 3447 | uint32_t flags{}; | ||
| 3448 | uint64_t thread_ids{}; | ||
| 3449 | int32_t num_thread_ids{}; | ||
| 3450 | |||
| 3451 | debug_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3452 | flags = Convert<uint32_t>(GetReg64(system, 1)); | ||
| 3453 | thread_ids = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3454 | num_thread_ids = Convert<int32_t>(GetReg64(system, 3)); | ||
| 3455 | |||
| 3456 | ret = ContinueDebugEvent64(system, debug_handle, flags, thread_ids, num_thread_ids); | ||
| 3457 | |||
| 3458 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3459 | } | ||
| 3460 | |||
| 3461 | static void SvcWrap_GetProcessList64(Core::System& system) { | ||
| 3462 | Result ret{}; | ||
| 3463 | |||
| 3464 | int32_t out_num_processes{}; | ||
| 3465 | uint64_t out_process_ids{}; | ||
| 3466 | int32_t max_out_count{}; | ||
| 3467 | |||
| 3468 | out_process_ids = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3469 | max_out_count = Convert<int32_t>(GetReg64(system, 2)); | ||
| 3470 | |||
| 3471 | ret = GetProcessList64(system, &out_num_processes, out_process_ids, max_out_count); | ||
| 3472 | |||
| 3473 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3474 | SetReg64(system, 1, Convert<uint64_t>(out_num_processes)); | ||
| 3475 | } | ||
| 3476 | |||
| 3477 | static void SvcWrap_GetThreadList64(Core::System& system) { | ||
| 3478 | Result ret{}; | ||
| 3479 | |||
| 3480 | int32_t out_num_threads{}; | ||
| 3481 | uint64_t out_thread_ids{}; | ||
| 3482 | int32_t max_out_count{}; | ||
| 3483 | Handle debug_handle{}; | ||
| 3484 | |||
| 3485 | out_thread_ids = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3486 | max_out_count = Convert<int32_t>(GetReg64(system, 2)); | ||
| 3487 | debug_handle = Convert<Handle>(GetReg64(system, 3)); | ||
| 3488 | |||
| 3489 | ret = GetThreadList64(system, &out_num_threads, out_thread_ids, max_out_count, debug_handle); | ||
| 3490 | |||
| 3491 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3492 | SetReg64(system, 1, Convert<uint64_t>(out_num_threads)); | ||
| 3493 | } | ||
| 3494 | |||
| 3495 | static void SvcWrap_GetDebugThreadContext64(Core::System& system) { | ||
| 3496 | Result ret{}; | ||
| 3497 | |||
| 3498 | uint64_t out_context{}; | ||
| 3499 | Handle debug_handle{}; | ||
| 3500 | uint64_t thread_id{}; | ||
| 3501 | uint32_t context_flags{}; | ||
| 3502 | |||
| 3503 | out_context = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 3504 | debug_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 3505 | thread_id = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3506 | context_flags = Convert<uint32_t>(GetReg64(system, 3)); | ||
| 3507 | |||
| 3508 | ret = GetDebugThreadContext64(system, out_context, debug_handle, thread_id, context_flags); | ||
| 3509 | |||
| 3510 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3511 | } | ||
| 3512 | |||
| 3513 | static void SvcWrap_SetDebugThreadContext64(Core::System& system) { | ||
| 3514 | Result ret{}; | ||
| 3515 | |||
| 3516 | Handle debug_handle{}; | ||
| 3517 | uint64_t thread_id{}; | ||
| 3518 | uint64_t context{}; | ||
| 3519 | uint32_t context_flags{}; | ||
| 3520 | |||
| 3521 | debug_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3522 | thread_id = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3523 | context = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3524 | context_flags = Convert<uint32_t>(GetReg64(system, 3)); | ||
| 3525 | |||
| 3526 | ret = SetDebugThreadContext64(system, debug_handle, thread_id, context, context_flags); | ||
| 3527 | |||
| 3528 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3529 | } | ||
| 3530 | |||
| 3531 | static void SvcWrap_QueryDebugProcessMemory64(Core::System& system) { | ||
| 3532 | Result ret{}; | ||
| 3533 | |||
| 3534 | PageInfo out_page_info{}; | ||
| 3535 | uint64_t out_memory_info{}; | ||
| 3536 | Handle process_handle{}; | ||
| 3537 | uint64_t address{}; | ||
| 3538 | |||
| 3539 | out_memory_info = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 3540 | process_handle = Convert<Handle>(GetReg64(system, 2)); | ||
| 3541 | address = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3542 | |||
| 3543 | ret = QueryDebugProcessMemory64(system, out_memory_info, &out_page_info, process_handle, address); | ||
| 3544 | |||
| 3545 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3546 | SetReg64(system, 1, Convert<uint64_t>(out_page_info)); | ||
| 3547 | } | ||
| 3548 | |||
| 3549 | static void SvcWrap_ReadDebugProcessMemory64(Core::System& system) { | ||
| 3550 | Result ret{}; | ||
| 3551 | |||
| 3552 | uint64_t buffer{}; | ||
| 3553 | Handle debug_handle{}; | ||
| 3554 | uint64_t address{}; | ||
| 3555 | uint64_t size{}; | ||
| 3556 | |||
| 3557 | buffer = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 3558 | debug_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 3559 | address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3560 | size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3561 | |||
| 3562 | ret = ReadDebugProcessMemory64(system, buffer, debug_handle, address, size); | ||
| 3563 | |||
| 3564 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3565 | } | ||
| 3566 | |||
| 3567 | static void SvcWrap_WriteDebugProcessMemory64(Core::System& system) { | ||
| 3568 | Result ret{}; | ||
| 3569 | |||
| 3570 | Handle debug_handle{}; | ||
| 3571 | uint64_t buffer{}; | ||
| 3572 | uint64_t address{}; | ||
| 3573 | uint64_t size{}; | ||
| 3574 | |||
| 3575 | debug_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3576 | buffer = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3577 | address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3578 | size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3579 | |||
| 3580 | ret = WriteDebugProcessMemory64(system, debug_handle, buffer, address, size); | ||
| 3581 | |||
| 3582 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3583 | } | ||
| 3584 | |||
| 3585 | static void SvcWrap_SetHardwareBreakPoint64(Core::System& system) { | ||
| 3586 | Result ret{}; | ||
| 3587 | |||
| 3588 | HardwareBreakPointRegisterName name{}; | ||
| 3589 | uint64_t flags{}; | ||
| 3590 | uint64_t value{}; | ||
| 3591 | |||
| 3592 | name = Convert<HardwareBreakPointRegisterName>(GetReg64(system, 0)); | ||
| 3593 | flags = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3594 | value = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3595 | |||
| 3596 | ret = SetHardwareBreakPoint64(system, name, flags, value); | ||
| 3597 | |||
| 3598 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3599 | } | ||
| 3600 | |||
| 3601 | static void SvcWrap_GetDebugThreadParam64(Core::System& system) { | ||
| 3602 | Result ret{}; | ||
| 3603 | |||
| 3604 | uint64_t out_64{}; | ||
| 3605 | uint32_t out_32{}; | ||
| 3606 | Handle debug_handle{}; | ||
| 3607 | uint64_t thread_id{}; | ||
| 3608 | DebugThreadParam param{}; | ||
| 3609 | |||
| 3610 | debug_handle = Convert<Handle>(GetReg64(system, 2)); | ||
| 3611 | thread_id = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3612 | param = Convert<DebugThreadParam>(GetReg64(system, 4)); | ||
| 3613 | |||
| 3614 | ret = GetDebugThreadParam64(system, &out_64, &out_32, debug_handle, thread_id, param); | ||
| 3615 | |||
| 3616 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3617 | SetReg64(system, 1, Convert<uint64_t>(out_64)); | ||
| 3618 | SetReg64(system, 2, Convert<uint64_t>(out_32)); | ||
| 3619 | } | ||
| 3620 | |||
| 3621 | static void SvcWrap_GetSystemInfo64(Core::System& system) { | ||
| 3622 | Result ret{}; | ||
| 3623 | |||
| 3624 | uint64_t out{}; | ||
| 3625 | SystemInfoType info_type{}; | ||
| 3626 | Handle handle{}; | ||
| 3627 | uint64_t info_subtype{}; | ||
| 3628 | |||
| 3629 | info_type = Convert<SystemInfoType>(GetReg64(system, 1)); | ||
| 3630 | handle = Convert<Handle>(GetReg64(system, 2)); | ||
| 3631 | info_subtype = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3632 | |||
| 3633 | ret = GetSystemInfo64(system, &out, info_type, handle, info_subtype); | ||
| 3634 | |||
| 3635 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3636 | SetReg64(system, 1, Convert<uint64_t>(out)); | ||
| 3637 | } | ||
| 3638 | |||
| 3639 | static void SvcWrap_CreatePort64(Core::System& system) { | ||
| 3640 | Result ret{}; | ||
| 3641 | |||
| 3642 | Handle out_server_handle{}; | ||
| 3643 | Handle out_client_handle{}; | ||
| 3644 | int32_t max_sessions{}; | ||
| 3645 | bool is_light{}; | ||
| 3646 | uint64_t name{}; | ||
| 3647 | |||
| 3648 | max_sessions = Convert<int32_t>(GetReg64(system, 2)); | ||
| 3649 | is_light = Convert<bool>(GetReg64(system, 3)); | ||
| 3650 | name = Convert<uint64_t>(GetReg64(system, 4)); | ||
| 3651 | |||
| 3652 | ret = CreatePort64(system, &out_server_handle, &out_client_handle, max_sessions, is_light, name); | ||
| 3653 | |||
| 3654 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3655 | SetReg64(system, 1, Convert<uint64_t>(out_server_handle)); | ||
| 3656 | SetReg64(system, 2, Convert<uint64_t>(out_client_handle)); | ||
| 3657 | } | ||
| 3658 | |||
| 3659 | static void SvcWrap_ManageNamedPort64(Core::System& system) { | ||
| 3660 | Result ret{}; | ||
| 3661 | |||
| 3662 | Handle out_server_handle{}; | ||
| 3663 | uint64_t name{}; | ||
| 3664 | int32_t max_sessions{}; | ||
| 3665 | |||
| 3666 | name = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3667 | max_sessions = Convert<int32_t>(GetReg64(system, 2)); | ||
| 3668 | |||
| 3669 | ret = ManageNamedPort64(system, &out_server_handle, name, max_sessions); | ||
| 3670 | |||
| 3671 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3672 | SetReg64(system, 1, Convert<uint64_t>(out_server_handle)); | ||
| 3673 | } | ||
| 3674 | |||
| 3675 | static void SvcWrap_ConnectToPort64(Core::System& system) { | ||
| 3676 | Result ret{}; | ||
| 3677 | |||
| 3678 | Handle out_handle{}; | ||
| 3679 | Handle port{}; | ||
| 3680 | |||
| 3681 | port = Convert<Handle>(GetReg64(system, 1)); | ||
| 3682 | |||
| 3683 | ret = ConnectToPort64(system, &out_handle, port); | ||
| 3684 | |||
| 3685 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3686 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 3687 | } | ||
| 3688 | |||
| 3689 | static void SvcWrap_SetProcessMemoryPermission64(Core::System& system) { | ||
| 3690 | Result ret{}; | ||
| 3691 | |||
| 3692 | Handle process_handle{}; | ||
| 3693 | uint64_t address{}; | ||
| 3694 | uint64_t size{}; | ||
| 3695 | MemoryPermission perm{}; | ||
| 3696 | |||
| 3697 | process_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3698 | address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3699 | size = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3700 | perm = Convert<MemoryPermission>(GetReg64(system, 3)); | ||
| 3701 | |||
| 3702 | ret = SetProcessMemoryPermission64(system, process_handle, address, size, perm); | ||
| 3703 | |||
| 3704 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3705 | } | ||
| 3706 | |||
| 3707 | static void SvcWrap_MapProcessMemory64(Core::System& system) { | ||
| 3708 | Result ret{}; | ||
| 3709 | |||
| 3710 | uint64_t dst_address{}; | ||
| 3711 | Handle process_handle{}; | ||
| 3712 | uint64_t src_address{}; | ||
| 3713 | uint64_t size{}; | ||
| 3714 | |||
| 3715 | dst_address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 3716 | process_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 3717 | src_address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3718 | size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3719 | |||
| 3720 | ret = MapProcessMemory64(system, dst_address, process_handle, src_address, size); | ||
| 3721 | |||
| 3722 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3723 | } | ||
| 3724 | |||
| 3725 | static void SvcWrap_UnmapProcessMemory64(Core::System& system) { | ||
| 3726 | Result ret{}; | ||
| 3727 | |||
| 3728 | uint64_t dst_address{}; | ||
| 3729 | Handle process_handle{}; | ||
| 3730 | uint64_t src_address{}; | ||
| 3731 | uint64_t size{}; | ||
| 3732 | |||
| 3733 | dst_address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 3734 | process_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 3735 | src_address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3736 | size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3737 | |||
| 3738 | ret = UnmapProcessMemory64(system, dst_address, process_handle, src_address, size); | ||
| 3739 | |||
| 3740 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3741 | } | ||
| 3742 | |||
| 3743 | static void SvcWrap_QueryProcessMemory64(Core::System& system) { | ||
| 3744 | Result ret{}; | ||
| 3745 | |||
| 3746 | PageInfo out_page_info{}; | ||
| 3747 | uint64_t out_memory_info{}; | ||
| 3748 | Handle process_handle{}; | ||
| 3749 | uint64_t address{}; | ||
| 3750 | |||
| 3751 | out_memory_info = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 3752 | process_handle = Convert<Handle>(GetReg64(system, 2)); | ||
| 3753 | address = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3754 | |||
| 3755 | ret = QueryProcessMemory64(system, out_memory_info, &out_page_info, process_handle, address); | ||
| 3756 | |||
| 3757 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3758 | SetReg64(system, 1, Convert<uint64_t>(out_page_info)); | ||
| 3759 | } | ||
| 3760 | |||
| 3761 | static void SvcWrap_MapProcessCodeMemory64(Core::System& system) { | ||
| 3762 | Result ret{}; | ||
| 3763 | |||
| 3764 | Handle process_handle{}; | ||
| 3765 | uint64_t dst_address{}; | ||
| 3766 | uint64_t src_address{}; | ||
| 3767 | uint64_t size{}; | ||
| 3768 | |||
| 3769 | process_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3770 | dst_address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3771 | src_address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3772 | size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3773 | |||
| 3774 | ret = MapProcessCodeMemory64(system, process_handle, dst_address, src_address, size); | ||
| 3775 | |||
| 3776 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3777 | } | ||
| 3778 | |||
| 3779 | static void SvcWrap_UnmapProcessCodeMemory64(Core::System& system) { | ||
| 3780 | Result ret{}; | ||
| 3781 | |||
| 3782 | Handle process_handle{}; | ||
| 3783 | uint64_t dst_address{}; | ||
| 3784 | uint64_t src_address{}; | ||
| 3785 | uint64_t size{}; | ||
| 3786 | |||
| 3787 | process_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3788 | dst_address = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3789 | src_address = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3790 | size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3791 | |||
| 3792 | ret = UnmapProcessCodeMemory64(system, process_handle, dst_address, src_address, size); | ||
| 3793 | |||
| 3794 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3795 | } | ||
| 3796 | |||
| 3797 | static void SvcWrap_CreateProcess64(Core::System& system) { | ||
| 3798 | Result ret{}; | ||
| 3799 | |||
| 3800 | Handle out_handle{}; | ||
| 3801 | uint64_t parameters{}; | ||
| 3802 | uint64_t caps{}; | ||
| 3803 | int32_t num_caps{}; | ||
| 3804 | |||
| 3805 | parameters = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3806 | caps = Convert<uint64_t>(GetReg64(system, 2)); | ||
| 3807 | num_caps = Convert<int32_t>(GetReg64(system, 3)); | ||
| 3808 | |||
| 3809 | ret = CreateProcess64(system, &out_handle, parameters, caps, num_caps); | ||
| 3810 | |||
| 3811 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3812 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 3813 | } | ||
| 3814 | |||
| 3815 | static void SvcWrap_StartProcess64(Core::System& system) { | ||
| 3816 | Result ret{}; | ||
| 3817 | |||
| 3818 | Handle process_handle{}; | ||
| 3819 | int32_t priority{}; | ||
| 3820 | int32_t core_id{}; | ||
| 3821 | uint64_t main_thread_stack_size{}; | ||
| 3822 | |||
| 3823 | process_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3824 | priority = Convert<int32_t>(GetReg64(system, 1)); | ||
| 3825 | core_id = Convert<int32_t>(GetReg64(system, 2)); | ||
| 3826 | main_thread_stack_size = Convert<uint64_t>(GetReg64(system, 3)); | ||
| 3827 | |||
| 3828 | ret = StartProcess64(system, process_handle, priority, core_id, main_thread_stack_size); | ||
| 3829 | |||
| 3830 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3831 | } | ||
| 3832 | |||
| 3833 | static void SvcWrap_TerminateProcess64(Core::System& system) { | ||
| 3834 | Result ret{}; | ||
| 3835 | |||
| 3836 | Handle process_handle{}; | ||
| 3837 | |||
| 3838 | process_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3839 | |||
| 3840 | ret = TerminateProcess64(system, process_handle); | ||
| 3841 | |||
| 3842 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3843 | } | ||
| 3844 | |||
| 3845 | static void SvcWrap_GetProcessInfo64(Core::System& system) { | ||
| 3846 | Result ret{}; | ||
| 3847 | |||
| 3848 | int64_t out_info{}; | ||
| 3849 | Handle process_handle{}; | ||
| 3850 | ProcessInfoType info_type{}; | ||
| 3851 | |||
| 3852 | process_handle = Convert<Handle>(GetReg64(system, 1)); | ||
| 3853 | info_type = Convert<ProcessInfoType>(GetReg64(system, 2)); | ||
| 3854 | |||
| 3855 | ret = GetProcessInfo64(system, &out_info, process_handle, info_type); | ||
| 3856 | |||
| 3857 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3858 | SetReg64(system, 1, Convert<uint64_t>(out_info)); | ||
| 3859 | } | ||
| 3860 | |||
| 3861 | static void SvcWrap_CreateResourceLimit64(Core::System& system) { | ||
| 3862 | Result ret{}; | ||
| 3863 | |||
| 3864 | Handle out_handle{}; | ||
| 3865 | |||
| 3866 | ret = CreateResourceLimit64(system, &out_handle); | ||
| 3867 | |||
| 3868 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3869 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | ||
| 3870 | } | ||
| 3871 | |||
| 3872 | static void SvcWrap_SetResourceLimitLimitValue64(Core::System& system) { | ||
| 3873 | Result ret{}; | ||
| 3874 | |||
| 3875 | Handle resource_limit_handle{}; | ||
| 3876 | LimitableResource which{}; | ||
| 3877 | int64_t limit_value{}; | ||
| 3878 | |||
| 3879 | resource_limit_handle = Convert<Handle>(GetReg64(system, 0)); | ||
| 3880 | which = Convert<LimitableResource>(GetReg64(system, 1)); | ||
| 3881 | limit_value = Convert<int64_t>(GetReg64(system, 2)); | ||
| 3882 | |||
| 3883 | ret = SetResourceLimitLimitValue64(system, resource_limit_handle, which, limit_value); | ||
| 3884 | |||
| 3885 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3886 | } | ||
| 3887 | |||
| 3888 | static void SvcWrap_MapInsecureMemory64(Core::System& system) { | ||
| 3889 | Result ret{}; | ||
| 3890 | |||
| 3891 | uint64_t address{}; | ||
| 3892 | uint64_t size{}; | ||
| 3893 | |||
| 3894 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 3895 | size = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3896 | |||
| 3897 | ret = MapInsecureMemory64(system, address, size); | ||
| 3898 | |||
| 3899 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3900 | } | ||
| 3901 | |||
| 3902 | static void SvcWrap_UnmapInsecureMemory64(Core::System& system) { | ||
| 3903 | Result ret{}; | ||
| 3904 | |||
| 3905 | uint64_t address{}; | ||
| 3906 | uint64_t size{}; | ||
| 3907 | |||
| 3908 | address = Convert<uint64_t>(GetReg64(system, 0)); | ||
| 3909 | size = Convert<uint64_t>(GetReg64(system, 1)); | ||
| 3910 | |||
| 3911 | ret = UnmapInsecureMemory64(system, address, size); | ||
| 3912 | |||
| 3913 | SetReg64(system, 0, Convert<uint64_t>(ret)); | ||
| 3914 | } | ||
| 3915 | |||
| 3916 | static void Call32(Core::System& system, u32 imm) { | ||
| 3917 | switch (static_cast<SvcId>(imm)) { | ||
| 3918 | case SvcId::SetHeapSize: | ||
| 3919 | return SvcWrap_SetHeapSize64From32(system); | ||
| 3920 | case SvcId::SetMemoryPermission: | ||
| 3921 | return SvcWrap_SetMemoryPermission64From32(system); | ||
| 3922 | case SvcId::SetMemoryAttribute: | ||
| 3923 | return SvcWrap_SetMemoryAttribute64From32(system); | ||
| 3924 | case SvcId::MapMemory: | ||
| 3925 | return SvcWrap_MapMemory64From32(system); | ||
| 3926 | case SvcId::UnmapMemory: | ||
| 3927 | return SvcWrap_UnmapMemory64From32(system); | ||
| 3928 | case SvcId::QueryMemory: | ||
| 3929 | return SvcWrap_QueryMemory64From32(system); | ||
| 3930 | case SvcId::ExitProcess: | ||
| 3931 | return SvcWrap_ExitProcess64From32(system); | ||
| 3932 | case SvcId::CreateThread: | ||
| 3933 | return SvcWrap_CreateThread64From32(system); | ||
| 3934 | case SvcId::StartThread: | ||
| 3935 | return SvcWrap_StartThread64From32(system); | ||
| 3936 | case SvcId::ExitThread: | ||
| 3937 | return SvcWrap_ExitThread64From32(system); | ||
| 3938 | case SvcId::SleepThread: | ||
| 3939 | return SvcWrap_SleepThread64From32(system); | ||
| 3940 | case SvcId::GetThreadPriority: | ||
| 3941 | return SvcWrap_GetThreadPriority64From32(system); | ||
| 3942 | case SvcId::SetThreadPriority: | ||
| 3943 | return SvcWrap_SetThreadPriority64From32(system); | ||
| 3944 | case SvcId::GetThreadCoreMask: | ||
| 3945 | return SvcWrap_GetThreadCoreMask64From32(system); | ||
| 3946 | case SvcId::SetThreadCoreMask: | ||
| 3947 | return SvcWrap_SetThreadCoreMask64From32(system); | ||
| 3948 | case SvcId::GetCurrentProcessorNumber: | ||
| 3949 | return SvcWrap_GetCurrentProcessorNumber64From32(system); | ||
| 3950 | case SvcId::SignalEvent: | ||
| 3951 | return SvcWrap_SignalEvent64From32(system); | ||
| 3952 | case SvcId::ClearEvent: | ||
| 3953 | return SvcWrap_ClearEvent64From32(system); | ||
| 3954 | case SvcId::MapSharedMemory: | ||
| 3955 | return SvcWrap_MapSharedMemory64From32(system); | ||
| 3956 | case SvcId::UnmapSharedMemory: | ||
| 3957 | return SvcWrap_UnmapSharedMemory64From32(system); | ||
| 3958 | case SvcId::CreateTransferMemory: | ||
| 3959 | return SvcWrap_CreateTransferMemory64From32(system); | ||
| 3960 | case SvcId::CloseHandle: | ||
| 3961 | return SvcWrap_CloseHandle64From32(system); | ||
| 3962 | case SvcId::ResetSignal: | ||
| 3963 | return SvcWrap_ResetSignal64From32(system); | ||
| 3964 | case SvcId::WaitSynchronization: | ||
| 3965 | return SvcWrap_WaitSynchronization64From32(system); | ||
| 3966 | case SvcId::CancelSynchronization: | ||
| 3967 | return SvcWrap_CancelSynchronization64From32(system); | ||
| 3968 | case SvcId::ArbitrateLock: | ||
| 3969 | return SvcWrap_ArbitrateLock64From32(system); | ||
| 3970 | case SvcId::ArbitrateUnlock: | ||
| 3971 | return SvcWrap_ArbitrateUnlock64From32(system); | ||
| 3972 | case SvcId::WaitProcessWideKeyAtomic: | ||
| 3973 | return SvcWrap_WaitProcessWideKeyAtomic64From32(system); | ||
| 3974 | case SvcId::SignalProcessWideKey: | ||
| 3975 | return SvcWrap_SignalProcessWideKey64From32(system); | ||
| 3976 | case SvcId::GetSystemTick: | ||
| 3977 | return SvcWrap_GetSystemTick64From32(system); | ||
| 3978 | case SvcId::ConnectToNamedPort: | ||
| 3979 | return SvcWrap_ConnectToNamedPort64From32(system); | ||
| 3980 | case SvcId::SendSyncRequestLight: | ||
| 3981 | return SvcWrap_SendSyncRequestLight64From32(system); | ||
| 3982 | case SvcId::SendSyncRequest: | ||
| 3983 | return SvcWrap_SendSyncRequest64From32(system); | ||
| 3984 | case SvcId::SendSyncRequestWithUserBuffer: | ||
| 3985 | return SvcWrap_SendSyncRequestWithUserBuffer64From32(system); | ||
| 3986 | case SvcId::SendAsyncRequestWithUserBuffer: | ||
| 3987 | return SvcWrap_SendAsyncRequestWithUserBuffer64From32(system); | ||
| 3988 | case SvcId::GetProcessId: | ||
| 3989 | return SvcWrap_GetProcessId64From32(system); | ||
| 3990 | case SvcId::GetThreadId: | ||
| 3991 | return SvcWrap_GetThreadId64From32(system); | ||
| 3992 | case SvcId::Break: | ||
| 3993 | return SvcWrap_Break64From32(system); | ||
| 3994 | case SvcId::OutputDebugString: | ||
| 3995 | return SvcWrap_OutputDebugString64From32(system); | ||
| 3996 | case SvcId::ReturnFromException: | ||
| 3997 | return SvcWrap_ReturnFromException64From32(system); | ||
| 3998 | case SvcId::GetInfo: | ||
| 3999 | return SvcWrap_GetInfo64From32(system); | ||
| 4000 | case SvcId::FlushEntireDataCache: | ||
| 4001 | return SvcWrap_FlushEntireDataCache64From32(system); | ||
| 4002 | case SvcId::FlushDataCache: | ||
| 4003 | return SvcWrap_FlushDataCache64From32(system); | ||
| 4004 | case SvcId::MapPhysicalMemory: | ||
| 4005 | return SvcWrap_MapPhysicalMemory64From32(system); | ||
| 4006 | case SvcId::UnmapPhysicalMemory: | ||
| 4007 | return SvcWrap_UnmapPhysicalMemory64From32(system); | ||
| 4008 | case SvcId::GetDebugFutureThreadInfo: | ||
| 4009 | return SvcWrap_GetDebugFutureThreadInfo64From32(system); | ||
| 4010 | case SvcId::GetLastThreadInfo: | ||
| 4011 | return SvcWrap_GetLastThreadInfo64From32(system); | ||
| 4012 | case SvcId::GetResourceLimitLimitValue: | ||
| 4013 | return SvcWrap_GetResourceLimitLimitValue64From32(system); | ||
| 4014 | case SvcId::GetResourceLimitCurrentValue: | ||
| 4015 | return SvcWrap_GetResourceLimitCurrentValue64From32(system); | ||
| 4016 | case SvcId::SetThreadActivity: | ||
| 4017 | return SvcWrap_SetThreadActivity64From32(system); | ||
| 4018 | case SvcId::GetThreadContext3: | ||
| 4019 | return SvcWrap_GetThreadContext364From32(system); | ||
| 4020 | case SvcId::WaitForAddress: | ||
| 4021 | return SvcWrap_WaitForAddress64From32(system); | ||
| 4022 | case SvcId::SignalToAddress: | ||
| 4023 | return SvcWrap_SignalToAddress64From32(system); | ||
| 4024 | case SvcId::SynchronizePreemptionState: | ||
| 4025 | return SvcWrap_SynchronizePreemptionState64From32(system); | ||
| 4026 | case SvcId::GetResourceLimitPeakValue: | ||
| 4027 | return SvcWrap_GetResourceLimitPeakValue64From32(system); | ||
| 4028 | case SvcId::CreateIoPool: | ||
| 4029 | return SvcWrap_CreateIoPool64From32(system); | ||
| 4030 | case SvcId::CreateIoRegion: | ||
| 4031 | return SvcWrap_CreateIoRegion64From32(system); | ||
| 4032 | case SvcId::KernelDebug: | ||
| 4033 | return SvcWrap_KernelDebug64From32(system); | ||
| 4034 | case SvcId::ChangeKernelTraceState: | ||
| 4035 | return SvcWrap_ChangeKernelTraceState64From32(system); | ||
| 4036 | case SvcId::CreateSession: | ||
| 4037 | return SvcWrap_CreateSession64From32(system); | ||
| 4038 | case SvcId::AcceptSession: | ||
| 4039 | return SvcWrap_AcceptSession64From32(system); | ||
| 4040 | case SvcId::ReplyAndReceiveLight: | ||
| 4041 | return SvcWrap_ReplyAndReceiveLight64From32(system); | ||
| 4042 | case SvcId::ReplyAndReceive: | ||
| 4043 | return SvcWrap_ReplyAndReceive64From32(system); | ||
| 4044 | case SvcId::ReplyAndReceiveWithUserBuffer: | ||
| 4045 | return SvcWrap_ReplyAndReceiveWithUserBuffer64From32(system); | ||
| 4046 | case SvcId::CreateEvent: | ||
| 4047 | return SvcWrap_CreateEvent64From32(system); | ||
| 4048 | case SvcId::MapIoRegion: | ||
| 4049 | return SvcWrap_MapIoRegion64From32(system); | ||
| 4050 | case SvcId::UnmapIoRegion: | ||
| 4051 | return SvcWrap_UnmapIoRegion64From32(system); | ||
| 4052 | case SvcId::MapPhysicalMemoryUnsafe: | ||
| 4053 | return SvcWrap_MapPhysicalMemoryUnsafe64From32(system); | ||
| 4054 | case SvcId::UnmapPhysicalMemoryUnsafe: | ||
| 4055 | return SvcWrap_UnmapPhysicalMemoryUnsafe64From32(system); | ||
| 4056 | case SvcId::SetUnsafeLimit: | ||
| 4057 | return SvcWrap_SetUnsafeLimit64From32(system); | ||
| 4058 | case SvcId::CreateCodeMemory: | ||
| 4059 | return SvcWrap_CreateCodeMemory64From32(system); | ||
| 4060 | case SvcId::ControlCodeMemory: | ||
| 4061 | return SvcWrap_ControlCodeMemory64From32(system); | ||
| 4062 | case SvcId::SleepSystem: | ||
| 4063 | return SvcWrap_SleepSystem64From32(system); | ||
| 4064 | case SvcId::ReadWriteRegister: | ||
| 4065 | return SvcWrap_ReadWriteRegister64From32(system); | ||
| 4066 | case SvcId::SetProcessActivity: | ||
| 4067 | return SvcWrap_SetProcessActivity64From32(system); | ||
| 4068 | case SvcId::CreateSharedMemory: | ||
| 4069 | return SvcWrap_CreateSharedMemory64From32(system); | ||
| 4070 | case SvcId::MapTransferMemory: | ||
| 4071 | return SvcWrap_MapTransferMemory64From32(system); | ||
| 4072 | case SvcId::UnmapTransferMemory: | ||
| 4073 | return SvcWrap_UnmapTransferMemory64From32(system); | ||
| 4074 | case SvcId::CreateInterruptEvent: | ||
| 4075 | return SvcWrap_CreateInterruptEvent64From32(system); | ||
| 4076 | case SvcId::QueryPhysicalAddress: | ||
| 4077 | return SvcWrap_QueryPhysicalAddress64From32(system); | ||
| 4078 | case SvcId::QueryIoMapping: | ||
| 4079 | return SvcWrap_QueryIoMapping64From32(system); | ||
| 4080 | case SvcId::CreateDeviceAddressSpace: | ||
| 4081 | return SvcWrap_CreateDeviceAddressSpace64From32(system); | ||
| 4082 | case SvcId::AttachDeviceAddressSpace: | ||
| 4083 | return SvcWrap_AttachDeviceAddressSpace64From32(system); | ||
| 4084 | case SvcId::DetachDeviceAddressSpace: | ||
| 4085 | return SvcWrap_DetachDeviceAddressSpace64From32(system); | ||
| 4086 | case SvcId::MapDeviceAddressSpaceByForce: | ||
| 4087 | return SvcWrap_MapDeviceAddressSpaceByForce64From32(system); | ||
| 4088 | case SvcId::MapDeviceAddressSpaceAligned: | ||
| 4089 | return SvcWrap_MapDeviceAddressSpaceAligned64From32(system); | ||
| 4090 | case SvcId::UnmapDeviceAddressSpace: | ||
| 4091 | return SvcWrap_UnmapDeviceAddressSpace64From32(system); | ||
| 4092 | case SvcId::InvalidateProcessDataCache: | ||
| 4093 | return SvcWrap_InvalidateProcessDataCache64From32(system); | ||
| 4094 | case SvcId::StoreProcessDataCache: | ||
| 4095 | return SvcWrap_StoreProcessDataCache64From32(system); | ||
| 4096 | case SvcId::FlushProcessDataCache: | ||
| 4097 | return SvcWrap_FlushProcessDataCache64From32(system); | ||
| 4098 | case SvcId::DebugActiveProcess: | ||
| 4099 | return SvcWrap_DebugActiveProcess64From32(system); | ||
| 4100 | case SvcId::BreakDebugProcess: | ||
| 4101 | return SvcWrap_BreakDebugProcess64From32(system); | ||
| 4102 | case SvcId::TerminateDebugProcess: | ||
| 4103 | return SvcWrap_TerminateDebugProcess64From32(system); | ||
| 4104 | case SvcId::GetDebugEvent: | ||
| 4105 | return SvcWrap_GetDebugEvent64From32(system); | ||
| 4106 | case SvcId::ContinueDebugEvent: | ||
| 4107 | return SvcWrap_ContinueDebugEvent64From32(system); | ||
| 4108 | case SvcId::GetProcessList: | ||
| 4109 | return SvcWrap_GetProcessList64From32(system); | ||
| 4110 | case SvcId::GetThreadList: | ||
| 4111 | return SvcWrap_GetThreadList64From32(system); | ||
| 4112 | case SvcId::GetDebugThreadContext: | ||
| 4113 | return SvcWrap_GetDebugThreadContext64From32(system); | ||
| 4114 | case SvcId::SetDebugThreadContext: | ||
| 4115 | return SvcWrap_SetDebugThreadContext64From32(system); | ||
| 4116 | case SvcId::QueryDebugProcessMemory: | ||
| 4117 | return SvcWrap_QueryDebugProcessMemory64From32(system); | ||
| 4118 | case SvcId::ReadDebugProcessMemory: | ||
| 4119 | return SvcWrap_ReadDebugProcessMemory64From32(system); | ||
| 4120 | case SvcId::WriteDebugProcessMemory: | ||
| 4121 | return SvcWrap_WriteDebugProcessMemory64From32(system); | ||
| 4122 | case SvcId::SetHardwareBreakPoint: | ||
| 4123 | return SvcWrap_SetHardwareBreakPoint64From32(system); | ||
| 4124 | case SvcId::GetDebugThreadParam: | ||
| 4125 | return SvcWrap_GetDebugThreadParam64From32(system); | ||
| 4126 | case SvcId::GetSystemInfo: | ||
| 4127 | return SvcWrap_GetSystemInfo64From32(system); | ||
| 4128 | case SvcId::CreatePort: | ||
| 4129 | return SvcWrap_CreatePort64From32(system); | ||
| 4130 | case SvcId::ManageNamedPort: | ||
| 4131 | return SvcWrap_ManageNamedPort64From32(system); | ||
| 4132 | case SvcId::ConnectToPort: | ||
| 4133 | return SvcWrap_ConnectToPort64From32(system); | ||
| 4134 | case SvcId::SetProcessMemoryPermission: | ||
| 4135 | return SvcWrap_SetProcessMemoryPermission64From32(system); | ||
| 4136 | case SvcId::MapProcessMemory: | ||
| 4137 | return SvcWrap_MapProcessMemory64From32(system); | ||
| 4138 | case SvcId::UnmapProcessMemory: | ||
| 4139 | return SvcWrap_UnmapProcessMemory64From32(system); | ||
| 4140 | case SvcId::QueryProcessMemory: | ||
| 4141 | return SvcWrap_QueryProcessMemory64From32(system); | ||
| 4142 | case SvcId::MapProcessCodeMemory: | ||
| 4143 | return SvcWrap_MapProcessCodeMemory64From32(system); | ||
| 4144 | case SvcId::UnmapProcessCodeMemory: | ||
| 4145 | return SvcWrap_UnmapProcessCodeMemory64From32(system); | ||
| 4146 | case SvcId::CreateProcess: | ||
| 4147 | return SvcWrap_CreateProcess64From32(system); | ||
| 4148 | case SvcId::StartProcess: | ||
| 4149 | return SvcWrap_StartProcess64From32(system); | ||
| 4150 | case SvcId::TerminateProcess: | ||
| 4151 | return SvcWrap_TerminateProcess64From32(system); | ||
| 4152 | case SvcId::GetProcessInfo: | ||
| 4153 | return SvcWrap_GetProcessInfo64From32(system); | ||
| 4154 | case SvcId::CreateResourceLimit: | ||
| 4155 | return SvcWrap_CreateResourceLimit64From32(system); | ||
| 4156 | case SvcId::SetResourceLimitLimitValue: | ||
| 4157 | return SvcWrap_SetResourceLimitLimitValue64From32(system); | ||
| 4158 | case SvcId::CallSecureMonitor: | ||
| 4159 | return SvcWrap_CallSecureMonitor64From32(system); | ||
| 4160 | case SvcId::MapInsecureMemory: | ||
| 4161 | return SvcWrap_MapInsecureMemory64From32(system); | ||
| 4162 | case SvcId::UnmapInsecureMemory: | ||
| 4163 | return SvcWrap_UnmapInsecureMemory64From32(system); | ||
| 4164 | default: | ||
| 4165 | LOG_CRITICAL(Kernel_SVC, "Unknown SVC {:x}!", imm); | ||
| 4166 | break; | ||
| 418 | } | 4167 | } |
| 419 | return &SVC_Table_32[func_num]; | ||
| 420 | } | 4168 | } |
| 421 | 4169 | ||
| 422 | static const FunctionDef* GetSVCInfo64(u32 func_num) { | 4170 | static void Call64(Core::System& system, u32 imm) { |
| 423 | if (func_num >= std::size(SVC_Table_64)) { | 4171 | switch (static_cast<SvcId>(imm)) { |
| 424 | LOG_ERROR(Kernel_SVC, "Unknown svc=0x{:02X}", func_num); | 4172 | case SvcId::SetHeapSize: |
| 425 | return nullptr; | 4173 | return SvcWrap_SetHeapSize64(system); |
| 4174 | case SvcId::SetMemoryPermission: | ||
| 4175 | return SvcWrap_SetMemoryPermission64(system); | ||
| 4176 | case SvcId::SetMemoryAttribute: | ||
| 4177 | return SvcWrap_SetMemoryAttribute64(system); | ||
| 4178 | case SvcId::MapMemory: | ||
| 4179 | return SvcWrap_MapMemory64(system); | ||
| 4180 | case SvcId::UnmapMemory: | ||
| 4181 | return SvcWrap_UnmapMemory64(system); | ||
| 4182 | case SvcId::QueryMemory: | ||
| 4183 | return SvcWrap_QueryMemory64(system); | ||
| 4184 | case SvcId::ExitProcess: | ||
| 4185 | return SvcWrap_ExitProcess64(system); | ||
| 4186 | case SvcId::CreateThread: | ||
| 4187 | return SvcWrap_CreateThread64(system); | ||
| 4188 | case SvcId::StartThread: | ||
| 4189 | return SvcWrap_StartThread64(system); | ||
| 4190 | case SvcId::ExitThread: | ||
| 4191 | return SvcWrap_ExitThread64(system); | ||
| 4192 | case SvcId::SleepThread: | ||
| 4193 | return SvcWrap_SleepThread64(system); | ||
| 4194 | case SvcId::GetThreadPriority: | ||
| 4195 | return SvcWrap_GetThreadPriority64(system); | ||
| 4196 | case SvcId::SetThreadPriority: | ||
| 4197 | return SvcWrap_SetThreadPriority64(system); | ||
| 4198 | case SvcId::GetThreadCoreMask: | ||
| 4199 | return SvcWrap_GetThreadCoreMask64(system); | ||
| 4200 | case SvcId::SetThreadCoreMask: | ||
| 4201 | return SvcWrap_SetThreadCoreMask64(system); | ||
| 4202 | case SvcId::GetCurrentProcessorNumber: | ||
| 4203 | return SvcWrap_GetCurrentProcessorNumber64(system); | ||
| 4204 | case SvcId::SignalEvent: | ||
| 4205 | return SvcWrap_SignalEvent64(system); | ||
| 4206 | case SvcId::ClearEvent: | ||
| 4207 | return SvcWrap_ClearEvent64(system); | ||
| 4208 | case SvcId::MapSharedMemory: | ||
| 4209 | return SvcWrap_MapSharedMemory64(system); | ||
| 4210 | case SvcId::UnmapSharedMemory: | ||
| 4211 | return SvcWrap_UnmapSharedMemory64(system); | ||
| 4212 | case SvcId::CreateTransferMemory: | ||
| 4213 | return SvcWrap_CreateTransferMemory64(system); | ||
| 4214 | case SvcId::CloseHandle: | ||
| 4215 | return SvcWrap_CloseHandle64(system); | ||
| 4216 | case SvcId::ResetSignal: | ||
| 4217 | return SvcWrap_ResetSignal64(system); | ||
| 4218 | case SvcId::WaitSynchronization: | ||
| 4219 | return SvcWrap_WaitSynchronization64(system); | ||
| 4220 | case SvcId::CancelSynchronization: | ||
| 4221 | return SvcWrap_CancelSynchronization64(system); | ||
| 4222 | case SvcId::ArbitrateLock: | ||
| 4223 | return SvcWrap_ArbitrateLock64(system); | ||
| 4224 | case SvcId::ArbitrateUnlock: | ||
| 4225 | return SvcWrap_ArbitrateUnlock64(system); | ||
| 4226 | case SvcId::WaitProcessWideKeyAtomic: | ||
| 4227 | return SvcWrap_WaitProcessWideKeyAtomic64(system); | ||
| 4228 | case SvcId::SignalProcessWideKey: | ||
| 4229 | return SvcWrap_SignalProcessWideKey64(system); | ||
| 4230 | case SvcId::GetSystemTick: | ||
| 4231 | return SvcWrap_GetSystemTick64(system); | ||
| 4232 | case SvcId::ConnectToNamedPort: | ||
| 4233 | return SvcWrap_ConnectToNamedPort64(system); | ||
| 4234 | case SvcId::SendSyncRequestLight: | ||
| 4235 | return SvcWrap_SendSyncRequestLight64(system); | ||
| 4236 | case SvcId::SendSyncRequest: | ||
| 4237 | return SvcWrap_SendSyncRequest64(system); | ||
| 4238 | case SvcId::SendSyncRequestWithUserBuffer: | ||
| 4239 | return SvcWrap_SendSyncRequestWithUserBuffer64(system); | ||
| 4240 | case SvcId::SendAsyncRequestWithUserBuffer: | ||
| 4241 | return SvcWrap_SendAsyncRequestWithUserBuffer64(system); | ||
| 4242 | case SvcId::GetProcessId: | ||
| 4243 | return SvcWrap_GetProcessId64(system); | ||
| 4244 | case SvcId::GetThreadId: | ||
| 4245 | return SvcWrap_GetThreadId64(system); | ||
| 4246 | case SvcId::Break: | ||
| 4247 | return SvcWrap_Break64(system); | ||
| 4248 | case SvcId::OutputDebugString: | ||
| 4249 | return SvcWrap_OutputDebugString64(system); | ||
| 4250 | case SvcId::ReturnFromException: | ||
| 4251 | return SvcWrap_ReturnFromException64(system); | ||
| 4252 | case SvcId::GetInfo: | ||
| 4253 | return SvcWrap_GetInfo64(system); | ||
| 4254 | case SvcId::FlushEntireDataCache: | ||
| 4255 | return SvcWrap_FlushEntireDataCache64(system); | ||
| 4256 | case SvcId::FlushDataCache: | ||
| 4257 | return SvcWrap_FlushDataCache64(system); | ||
| 4258 | case SvcId::MapPhysicalMemory: | ||
| 4259 | return SvcWrap_MapPhysicalMemory64(system); | ||
| 4260 | case SvcId::UnmapPhysicalMemory: | ||
| 4261 | return SvcWrap_UnmapPhysicalMemory64(system); | ||
| 4262 | case SvcId::GetDebugFutureThreadInfo: | ||
| 4263 | return SvcWrap_GetDebugFutureThreadInfo64(system); | ||
| 4264 | case SvcId::GetLastThreadInfo: | ||
| 4265 | return SvcWrap_GetLastThreadInfo64(system); | ||
| 4266 | case SvcId::GetResourceLimitLimitValue: | ||
| 4267 | return SvcWrap_GetResourceLimitLimitValue64(system); | ||
| 4268 | case SvcId::GetResourceLimitCurrentValue: | ||
| 4269 | return SvcWrap_GetResourceLimitCurrentValue64(system); | ||
| 4270 | case SvcId::SetThreadActivity: | ||
| 4271 | return SvcWrap_SetThreadActivity64(system); | ||
| 4272 | case SvcId::GetThreadContext3: | ||
| 4273 | return SvcWrap_GetThreadContext364(system); | ||
| 4274 | case SvcId::WaitForAddress: | ||
| 4275 | return SvcWrap_WaitForAddress64(system); | ||
| 4276 | case SvcId::SignalToAddress: | ||
| 4277 | return SvcWrap_SignalToAddress64(system); | ||
| 4278 | case SvcId::SynchronizePreemptionState: | ||
| 4279 | return SvcWrap_SynchronizePreemptionState64(system); | ||
| 4280 | case SvcId::GetResourceLimitPeakValue: | ||
| 4281 | return SvcWrap_GetResourceLimitPeakValue64(system); | ||
| 4282 | case SvcId::CreateIoPool: | ||
| 4283 | return SvcWrap_CreateIoPool64(system); | ||
| 4284 | case SvcId::CreateIoRegion: | ||
| 4285 | return SvcWrap_CreateIoRegion64(system); | ||
| 4286 | case SvcId::KernelDebug: | ||
| 4287 | return SvcWrap_KernelDebug64(system); | ||
| 4288 | case SvcId::ChangeKernelTraceState: | ||
| 4289 | return SvcWrap_ChangeKernelTraceState64(system); | ||
| 4290 | case SvcId::CreateSession: | ||
| 4291 | return SvcWrap_CreateSession64(system); | ||
| 4292 | case SvcId::AcceptSession: | ||
| 4293 | return SvcWrap_AcceptSession64(system); | ||
| 4294 | case SvcId::ReplyAndReceiveLight: | ||
| 4295 | return SvcWrap_ReplyAndReceiveLight64(system); | ||
| 4296 | case SvcId::ReplyAndReceive: | ||
| 4297 | return SvcWrap_ReplyAndReceive64(system); | ||
| 4298 | case SvcId::ReplyAndReceiveWithUserBuffer: | ||
| 4299 | return SvcWrap_ReplyAndReceiveWithUserBuffer64(system); | ||
| 4300 | case SvcId::CreateEvent: | ||
| 4301 | return SvcWrap_CreateEvent64(system); | ||
| 4302 | case SvcId::MapIoRegion: | ||
| 4303 | return SvcWrap_MapIoRegion64(system); | ||
| 4304 | case SvcId::UnmapIoRegion: | ||
| 4305 | return SvcWrap_UnmapIoRegion64(system); | ||
| 4306 | case SvcId::MapPhysicalMemoryUnsafe: | ||
| 4307 | return SvcWrap_MapPhysicalMemoryUnsafe64(system); | ||
| 4308 | case SvcId::UnmapPhysicalMemoryUnsafe: | ||
| 4309 | return SvcWrap_UnmapPhysicalMemoryUnsafe64(system); | ||
| 4310 | case SvcId::SetUnsafeLimit: | ||
| 4311 | return SvcWrap_SetUnsafeLimit64(system); | ||
| 4312 | case SvcId::CreateCodeMemory: | ||
| 4313 | return SvcWrap_CreateCodeMemory64(system); | ||
| 4314 | case SvcId::ControlCodeMemory: | ||
| 4315 | return SvcWrap_ControlCodeMemory64(system); | ||
| 4316 | case SvcId::SleepSystem: | ||
| 4317 | return SvcWrap_SleepSystem64(system); | ||
| 4318 | case SvcId::ReadWriteRegister: | ||
| 4319 | return SvcWrap_ReadWriteRegister64(system); | ||
| 4320 | case SvcId::SetProcessActivity: | ||
| 4321 | return SvcWrap_SetProcessActivity64(system); | ||
| 4322 | case SvcId::CreateSharedMemory: | ||
| 4323 | return SvcWrap_CreateSharedMemory64(system); | ||
| 4324 | case SvcId::MapTransferMemory: | ||
| 4325 | return SvcWrap_MapTransferMemory64(system); | ||
| 4326 | case SvcId::UnmapTransferMemory: | ||
| 4327 | return SvcWrap_UnmapTransferMemory64(system); | ||
| 4328 | case SvcId::CreateInterruptEvent: | ||
| 4329 | return SvcWrap_CreateInterruptEvent64(system); | ||
| 4330 | case SvcId::QueryPhysicalAddress: | ||
| 4331 | return SvcWrap_QueryPhysicalAddress64(system); | ||
| 4332 | case SvcId::QueryIoMapping: | ||
| 4333 | return SvcWrap_QueryIoMapping64(system); | ||
| 4334 | case SvcId::CreateDeviceAddressSpace: | ||
| 4335 | return SvcWrap_CreateDeviceAddressSpace64(system); | ||
| 4336 | case SvcId::AttachDeviceAddressSpace: | ||
| 4337 | return SvcWrap_AttachDeviceAddressSpace64(system); | ||
| 4338 | case SvcId::DetachDeviceAddressSpace: | ||
| 4339 | return SvcWrap_DetachDeviceAddressSpace64(system); | ||
| 4340 | case SvcId::MapDeviceAddressSpaceByForce: | ||
| 4341 | return SvcWrap_MapDeviceAddressSpaceByForce64(system); | ||
| 4342 | case SvcId::MapDeviceAddressSpaceAligned: | ||
| 4343 | return SvcWrap_MapDeviceAddressSpaceAligned64(system); | ||
| 4344 | case SvcId::UnmapDeviceAddressSpace: | ||
| 4345 | return SvcWrap_UnmapDeviceAddressSpace64(system); | ||
| 4346 | case SvcId::InvalidateProcessDataCache: | ||
| 4347 | return SvcWrap_InvalidateProcessDataCache64(system); | ||
| 4348 | case SvcId::StoreProcessDataCache: | ||
| 4349 | return SvcWrap_StoreProcessDataCache64(system); | ||
| 4350 | case SvcId::FlushProcessDataCache: | ||
| 4351 | return SvcWrap_FlushProcessDataCache64(system); | ||
| 4352 | case SvcId::DebugActiveProcess: | ||
| 4353 | return SvcWrap_DebugActiveProcess64(system); | ||
| 4354 | case SvcId::BreakDebugProcess: | ||
| 4355 | return SvcWrap_BreakDebugProcess64(system); | ||
| 4356 | case SvcId::TerminateDebugProcess: | ||
| 4357 | return SvcWrap_TerminateDebugProcess64(system); | ||
| 4358 | case SvcId::GetDebugEvent: | ||
| 4359 | return SvcWrap_GetDebugEvent64(system); | ||
| 4360 | case SvcId::ContinueDebugEvent: | ||
| 4361 | return SvcWrap_ContinueDebugEvent64(system); | ||
| 4362 | case SvcId::GetProcessList: | ||
| 4363 | return SvcWrap_GetProcessList64(system); | ||
| 4364 | case SvcId::GetThreadList: | ||
| 4365 | return SvcWrap_GetThreadList64(system); | ||
| 4366 | case SvcId::GetDebugThreadContext: | ||
| 4367 | return SvcWrap_GetDebugThreadContext64(system); | ||
| 4368 | case SvcId::SetDebugThreadContext: | ||
| 4369 | return SvcWrap_SetDebugThreadContext64(system); | ||
| 4370 | case SvcId::QueryDebugProcessMemory: | ||
| 4371 | return SvcWrap_QueryDebugProcessMemory64(system); | ||
| 4372 | case SvcId::ReadDebugProcessMemory: | ||
| 4373 | return SvcWrap_ReadDebugProcessMemory64(system); | ||
| 4374 | case SvcId::WriteDebugProcessMemory: | ||
| 4375 | return SvcWrap_WriteDebugProcessMemory64(system); | ||
| 4376 | case SvcId::SetHardwareBreakPoint: | ||
| 4377 | return SvcWrap_SetHardwareBreakPoint64(system); | ||
| 4378 | case SvcId::GetDebugThreadParam: | ||
| 4379 | return SvcWrap_GetDebugThreadParam64(system); | ||
| 4380 | case SvcId::GetSystemInfo: | ||
| 4381 | return SvcWrap_GetSystemInfo64(system); | ||
| 4382 | case SvcId::CreatePort: | ||
| 4383 | return SvcWrap_CreatePort64(system); | ||
| 4384 | case SvcId::ManageNamedPort: | ||
| 4385 | return SvcWrap_ManageNamedPort64(system); | ||
| 4386 | case SvcId::ConnectToPort: | ||
| 4387 | return SvcWrap_ConnectToPort64(system); | ||
| 4388 | case SvcId::SetProcessMemoryPermission: | ||
| 4389 | return SvcWrap_SetProcessMemoryPermission64(system); | ||
| 4390 | case SvcId::MapProcessMemory: | ||
| 4391 | return SvcWrap_MapProcessMemory64(system); | ||
| 4392 | case SvcId::UnmapProcessMemory: | ||
| 4393 | return SvcWrap_UnmapProcessMemory64(system); | ||
| 4394 | case SvcId::QueryProcessMemory: | ||
| 4395 | return SvcWrap_QueryProcessMemory64(system); | ||
| 4396 | case SvcId::MapProcessCodeMemory: | ||
| 4397 | return SvcWrap_MapProcessCodeMemory64(system); | ||
| 4398 | case SvcId::UnmapProcessCodeMemory: | ||
| 4399 | return SvcWrap_UnmapProcessCodeMemory64(system); | ||
| 4400 | case SvcId::CreateProcess: | ||
| 4401 | return SvcWrap_CreateProcess64(system); | ||
| 4402 | case SvcId::StartProcess: | ||
| 4403 | return SvcWrap_StartProcess64(system); | ||
| 4404 | case SvcId::TerminateProcess: | ||
| 4405 | return SvcWrap_TerminateProcess64(system); | ||
| 4406 | case SvcId::GetProcessInfo: | ||
| 4407 | return SvcWrap_GetProcessInfo64(system); | ||
| 4408 | case SvcId::CreateResourceLimit: | ||
| 4409 | return SvcWrap_CreateResourceLimit64(system); | ||
| 4410 | case SvcId::SetResourceLimitLimitValue: | ||
| 4411 | return SvcWrap_SetResourceLimitLimitValue64(system); | ||
| 4412 | case SvcId::CallSecureMonitor: | ||
| 4413 | return SvcWrap_CallSecureMonitor64(system); | ||
| 4414 | case SvcId::MapInsecureMemory: | ||
| 4415 | return SvcWrap_MapInsecureMemory64(system); | ||
| 4416 | case SvcId::UnmapInsecureMemory: | ||
| 4417 | return SvcWrap_UnmapInsecureMemory64(system); | ||
| 4418 | default: | ||
| 4419 | LOG_CRITICAL(Kernel_SVC, "Unknown SVC {:x}!", imm); | ||
| 4420 | break; | ||
| 426 | } | 4421 | } |
| 427 | return &SVC_Table_64[func_num]; | ||
| 428 | } | 4422 | } |
| 4423 | // clang-format on | ||
| 429 | 4424 | ||
| 430 | void Call(Core::System& system, u32 immediate) { | 4425 | void Call(Core::System& system, u32 imm) { |
| 431 | auto& kernel = system.Kernel(); | 4426 | auto& kernel = system.Kernel(); |
| 432 | kernel.EnterSVCProfile(); | 4427 | kernel.EnterSVCProfile(); |
| 433 | 4428 | ||
| 434 | auto* thread = GetCurrentThreadPointer(kernel); | 4429 | if (system.CurrentProcess()->Is64BitProcess()) { |
| 435 | thread->SetIsCallingSvc(); | 4430 | Call64(system, imm); |
| 436 | |||
| 437 | const FunctionDef* info = system.CurrentProcess()->Is64BitProcess() ? GetSVCInfo64(immediate) | ||
| 438 | : GetSVCInfo32(immediate); | ||
| 439 | if (info) { | ||
| 440 | if (info->func) { | ||
| 441 | info->func(system); | ||
| 442 | } else { | ||
| 443 | LOG_CRITICAL(Kernel_SVC, "Unimplemented SVC function {}(..)", info->name); | ||
| 444 | } | ||
| 445 | } else { | 4431 | } else { |
| 446 | LOG_CRITICAL(Kernel_SVC, "Unknown SVC function 0x{:X}", immediate); | 4432 | Call32(system, imm); |
| 447 | } | 4433 | } |
| 448 | 4434 | ||
| 449 | kernel.ExitSVCProfile(); | 4435 | kernel.ExitSVCProfile(); |
diff --git a/src/core/hle/kernel/svc.h b/src/core/hle/kernel/svc.h index b599f9a3d..36e619959 100644 --- a/src/core/hle/kernel/svc.h +++ b/src/core/hle/kernel/svc.h | |||
| @@ -1,172 +1,536 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #pragma once | 4 | // This file is automatically generated using svc_generator.py. |
| 5 | 5 | ||
| 6 | #include "common/common_types.h" | 6 | #pragma once |
| 7 | #include "core/hle/kernel/svc_types.h" | ||
| 8 | #include "core/hle/result.h" | ||
| 9 | 7 | ||
| 10 | namespace Core { | 8 | namespace Core { |
| 11 | class System; | 9 | class System; |
| 12 | } | 10 | } |
| 13 | 11 | ||
| 14 | namespace Kernel::Svc { | 12 | #include "common/common_types.h" |
| 13 | #include "core/hle/kernel/svc_types.h" | ||
| 14 | #include "core/hle/result.h" | ||
| 15 | 15 | ||
| 16 | void Call(Core::System& system, u32 immediate); | 16 | namespace Kernel::Svc { |
| 17 | 17 | ||
| 18 | Result SetHeapSize(Core::System& system, VAddr* out_address, u64 size); | 18 | // clang-format off |
| 19 | Result SetMemoryPermission(Core::System& system, VAddr address, u64 size, MemoryPermission perm); | 19 | Result SetHeapSize(Core::System& system, uintptr_t* out_address, uint64_t size); |
| 20 | Result SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask, u32 attr); | 20 | Result SetMemoryPermission(Core::System& system, uint64_t address, uint64_t size, MemoryPermission perm); |
| 21 | Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size); | 21 | Result SetMemoryAttribute(Core::System& system, uint64_t address, uint64_t size, uint32_t mask, uint32_t attr); |
| 22 | Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size); | 22 | Result MapMemory(Core::System& system, uint64_t dst_address, uint64_t src_address, uint64_t size); |
| 23 | Result QueryMemory(Core::System& system, VAddr memory_info_address, VAddr page_info_address, | 23 | Result UnmapMemory(Core::System& system, uint64_t dst_address, uint64_t src_address, uint64_t size); |
| 24 | VAddr query_address); | 24 | Result QueryMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, uint64_t address); |
| 25 | void ExitProcess(Core::System& system); | 25 | void ExitProcess(Core::System& system); |
| 26 | Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg, | 26 | Result CreateThread(Core::System& system, Handle* out_handle, uint64_t func, uint64_t arg, uint64_t stack_bottom, int32_t priority, int32_t core_id); |
| 27 | VAddr stack_bottom, u32 priority, s32 core_id); | ||
| 28 | Result StartThread(Core::System& system, Handle thread_handle); | 27 | Result StartThread(Core::System& system, Handle thread_handle); |
| 29 | void ExitThread(Core::System& system); | 28 | void ExitThread(Core::System& system); |
| 30 | void SleepThread(Core::System& system, s64 nanoseconds); | 29 | void SleepThread(Core::System& system, int64_t ns); |
| 31 | Result GetThreadPriority(Core::System& system, u32* out_priority, Handle handle); | 30 | Result GetThreadPriority(Core::System& system, int32_t* out_priority, Handle thread_handle); |
| 32 | Result SetThreadPriority(Core::System& system, Handle thread_handle, u32 priority); | 31 | Result SetThreadPriority(Core::System& system, Handle thread_handle, int32_t priority); |
| 33 | Result GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_core_id, | 32 | Result GetThreadCoreMask(Core::System& system, int32_t* out_core_id, uint64_t* out_affinity_mask, Handle thread_handle); |
| 34 | u64* out_affinity_mask); | 33 | Result SetThreadCoreMask(Core::System& system, Handle thread_handle, int32_t core_id, uint64_t affinity_mask); |
| 35 | Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id, | 34 | int32_t GetCurrentProcessorNumber(Core::System& system); |
| 36 | u64 affinity_mask); | ||
| 37 | u32 GetCurrentProcessorNumber(Core::System& system); | ||
| 38 | Result SignalEvent(Core::System& system, Handle event_handle); | 35 | Result SignalEvent(Core::System& system, Handle event_handle); |
| 39 | Result ClearEvent(Core::System& system, Handle event_handle); | 36 | Result ClearEvent(Core::System& system, Handle event_handle); |
| 40 | Result MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, u64 size, | 37 | Result MapSharedMemory(Core::System& system, Handle shmem_handle, uint64_t address, uint64_t size, MemoryPermission map_perm); |
| 41 | MemoryPermission map_perm); | 38 | Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, uint64_t address, uint64_t size); |
| 42 | Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, u64 size); | 39 | Result CreateTransferMemory(Core::System& system, Handle* out_handle, uint64_t address, uint64_t size, MemoryPermission map_perm); |
| 43 | Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u64 size, | ||
| 44 | MemoryPermission map_perm); | ||
| 45 | Result CloseHandle(Core::System& system, Handle handle); | 40 | Result CloseHandle(Core::System& system, Handle handle); |
| 46 | Result ResetSignal(Core::System& system, Handle handle); | 41 | Result ResetSignal(Core::System& system, Handle handle); |
| 47 | Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_address, s32 num_handles, | 42 | Result WaitSynchronization(Core::System& system, int32_t* out_index, uint64_t handles, int32_t num_handles, int64_t timeout_ns); |
| 48 | s64 nano_seconds); | ||
| 49 | Result CancelSynchronization(Core::System& system, Handle handle); | 43 | Result CancelSynchronization(Core::System& system, Handle handle); |
| 50 | Result ArbitrateLock(Core::System& system, Handle thread_handle, VAddr address, u32 tag); | 44 | Result ArbitrateLock(Core::System& system, Handle thread_handle, uint64_t address, uint32_t tag); |
| 51 | Result ArbitrateUnlock(Core::System& system, VAddr address); | 45 | Result ArbitrateUnlock(Core::System& system, uint64_t address); |
| 52 | Result WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_key, u32 tag, | 46 | Result WaitProcessWideKeyAtomic(Core::System& system, uint64_t address, uint64_t cv_key, uint32_t tag, int64_t timeout_ns); |
| 53 | s64 timeout_ns); | 47 | void SignalProcessWideKey(Core::System& system, uint64_t cv_key, int32_t count); |
| 54 | void SignalProcessWideKey(Core::System& system, VAddr cv_key, s32 count); | 48 | int64_t GetSystemTick(Core::System& system); |
| 55 | u64 GetSystemTick(Core::System& system); | 49 | Result ConnectToNamedPort(Core::System& system, Handle* out_handle, uint64_t name); |
| 56 | Result ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_address); | 50 | Result SendSyncRequest(Core::System& system, Handle session_handle); |
| 57 | Result SendSyncRequest(Core::System& system, Handle handle); | 51 | Result SendSyncRequestWithUserBuffer(Core::System& system, uint64_t message_buffer, uint64_t message_buffer_size, Handle session_handle); |
| 58 | Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle); | 52 | Result SendAsyncRequestWithUserBuffer(Core::System& system, Handle* out_event_handle, uint64_t message_buffer, uint64_t message_buffer_size, Handle session_handle); |
| 59 | Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle); | 53 | Result GetProcessId(Core::System& system, uint64_t* out_process_id, Handle process_handle); |
| 60 | void Break(Core::System& system, u32 reason, u64 info1, u64 info2); | 54 | Result GetThreadId(Core::System& system, uint64_t* out_thread_id, Handle thread_handle); |
| 61 | void OutputDebugString(Core::System& system, VAddr address, u64 len); | 55 | void Break(Core::System& system, BreakReason break_reason, uint64_t arg, uint64_t size); |
| 62 | Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, u64 info_sub_id); | 56 | Result OutputDebugString(Core::System& system, uint64_t debug_str, uint64_t len); |
| 63 | Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size); | 57 | void ReturnFromException(Core::System& system, Result result); |
| 64 | Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size); | 58 | Result GetInfo(Core::System& system, uint64_t* out, InfoType info_type, Handle handle, uint64_t info_subtype); |
| 65 | Result GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value, | 59 | void FlushEntireDataCache(Core::System& system); |
| 66 | Handle resource_limit_handle, LimitableResource which); | 60 | Result FlushDataCache(Core::System& system, uint64_t address, uint64_t size); |
| 67 | Result GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value, | 61 | Result MapPhysicalMemory(Core::System& system, uint64_t address, uint64_t size); |
| 68 | Handle resource_limit_handle, LimitableResource which); | 62 | Result UnmapPhysicalMemory(Core::System& system, uint64_t address, uint64_t size); |
| 69 | Result SetThreadActivity(Core::System& system, Handle thread_handle, | 63 | Result GetDebugFutureThreadInfo(Core::System& system, lp64::LastThreadContext* out_context, uint64_t* out_thread_id, Handle debug_handle, int64_t ns); |
| 70 | ThreadActivity thread_activity); | 64 | Result GetLastThreadInfo(Core::System& system, lp64::LastThreadContext* out_context, uintptr_t* out_tls_address, uint32_t* out_flags); |
| 71 | Result GetThreadContext(Core::System& system, VAddr out_context, Handle thread_handle); | 65 | Result GetResourceLimitLimitValue(Core::System& system, int64_t* out_limit_value, Handle resource_limit_handle, LimitableResource which); |
| 72 | Result WaitForAddress(Core::System& system, VAddr address, ArbitrationType arb_type, s32 value, | 66 | Result GetResourceLimitCurrentValue(Core::System& system, int64_t* out_current_value, Handle resource_limit_handle, LimitableResource which); |
| 73 | s64 timeout_ns); | 67 | Result SetThreadActivity(Core::System& system, Handle thread_handle, ThreadActivity thread_activity); |
| 74 | Result SignalToAddress(Core::System& system, VAddr address, SignalType signal_type, s32 value, | 68 | Result GetThreadContext3(Core::System& system, uint64_t out_context, Handle thread_handle); |
| 75 | s32 count); | 69 | Result WaitForAddress(Core::System& system, uint64_t address, ArbitrationType arb_type, int32_t value, int64_t timeout_ns); |
| 70 | Result SignalToAddress(Core::System& system, uint64_t address, SignalType signal_type, int32_t value, int32_t count); | ||
| 76 | void SynchronizePreemptionState(Core::System& system); | 71 | void SynchronizePreemptionState(Core::System& system); |
| 77 | void KernelDebug(Core::System& system, u32 kernel_debug_type, u64 param1, u64 param2, u64 param3); | 72 | Result GetResourceLimitPeakValue(Core::System& system, int64_t* out_peak_value, Handle resource_limit_handle, LimitableResource which); |
| 78 | void ChangeKernelTraceState(Core::System& system, u32 trace_state); | 73 | Result CreateIoPool(Core::System& system, Handle* out_handle, IoPoolType which); |
| 79 | Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, u32 is_light, | 74 | Result CreateIoRegion(Core::System& system, Handle* out_handle, Handle io_pool, uint64_t physical_address, uint64_t size, MemoryMapping mapping, MemoryPermission perm); |
| 80 | u64 name); | 75 | void KernelDebug(Core::System& system, KernelDebugType kern_debug_type, uint64_t arg0, uint64_t arg1, uint64_t arg2); |
| 81 | Result ReplyAndReceive(Core::System& system, s32* out_index, Handle* handles, s32 num_handles, | 76 | void ChangeKernelTraceState(Core::System& system, KernelTraceState kern_trace_state); |
| 82 | Handle reply_target, s64 timeout_ns); | 77 | Result CreateSession(Core::System& system, Handle* out_server_session_handle, Handle* out_client_session_handle, bool is_light, uint64_t name); |
| 83 | Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read); | 78 | Result AcceptSession(Core::System& system, Handle* out_handle, Handle port); |
| 84 | Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t size); | 79 | Result ReplyAndReceive(Core::System& system, int32_t* out_index, uint64_t handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns); |
| 85 | Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation, | 80 | Result ReplyAndReceiveWithUserBuffer(Core::System& system, int32_t* out_index, uint64_t message_buffer, uint64_t message_buffer_size, uint64_t handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns); |
| 86 | VAddr address, size_t size, MemoryPermission perm); | 81 | Result CreateEvent(Core::System& system, Handle* out_write_handle, Handle* out_read_handle); |
| 87 | Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_process_ids, | 82 | Result MapIoRegion(Core::System& system, Handle io_region, uint64_t address, uint64_t size, MemoryPermission perm); |
| 88 | u32 out_process_ids_size); | 83 | Result UnmapIoRegion(Core::System& system, Handle io_region, uint64_t address, uint64_t size); |
| 89 | Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_thread_ids, | 84 | Result MapPhysicalMemoryUnsafe(Core::System& system, uint64_t address, uint64_t size); |
| 90 | u32 out_thread_ids_size, Handle debug_handle); | 85 | Result UnmapPhysicalMemoryUnsafe(Core::System& system, uint64_t address, uint64_t size); |
| 91 | Result SetProcessMemoryPermission(Core::System& system, Handle process_handle, VAddr address, | 86 | Result SetUnsafeLimit(Core::System& system, uint64_t limit); |
| 92 | u64 size, MemoryPermission perm); | 87 | Result CreateCodeMemory(Core::System& system, Handle* out_handle, uint64_t address, uint64_t size); |
| 93 | Result MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, | 88 | Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, CodeMemoryOperation operation, uint64_t address, uint64_t size, MemoryPermission perm); |
| 94 | VAddr src_address, u64 size); | 89 | void SleepSystem(Core::System& system); |
| 95 | Result UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, | 90 | Result ReadWriteRegister(Core::System& system, uint32_t* out_value, uint64_t address, uint32_t mask, uint32_t value); |
| 96 | VAddr src_address, u64 size); | 91 | Result SetProcessActivity(Core::System& system, Handle process_handle, ProcessActivity process_activity); |
| 97 | Result QueryProcessMemory(Core::System& system, VAddr memory_info_address, VAddr page_info_address, | 92 | Result CreateSharedMemory(Core::System& system, Handle* out_handle, uint64_t size, MemoryPermission owner_perm, MemoryPermission remote_perm); |
| 98 | Handle process_handle, VAddr address); | 93 | Result MapTransferMemory(Core::System& system, Handle trmem_handle, uint64_t address, uint64_t size, MemoryPermission owner_perm); |
| 99 | Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, | 94 | Result UnmapTransferMemory(Core::System& system, Handle trmem_handle, uint64_t address, uint64_t size); |
| 100 | u64 src_address, u64 size); | 95 | Result CreateInterruptEvent(Core::System& system, Handle* out_read_handle, int32_t interrupt_id, InterruptType interrupt_type); |
| 101 | Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, | 96 | Result QueryPhysicalAddress(Core::System& system, lp64::PhysicalMemoryInfo* out_info, uint64_t address); |
| 102 | u64 src_address, u64 size); | 97 | Result QueryIoMapping(Core::System& system, uintptr_t* out_address, uintptr_t* out_size, uint64_t physical_address, uint64_t size); |
| 103 | Result GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type); | 98 | Result CreateDeviceAddressSpace(Core::System& system, Handle* out_handle, uint64_t das_address, uint64_t das_size); |
| 99 | Result AttachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle); | ||
| 100 | Result DetachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle); | ||
| 101 | Result MapDeviceAddressSpaceByForce(Core::System& system, Handle das_handle, Handle process_handle, uint64_t process_address, uint64_t size, uint64_t device_address, uint32_t option); | ||
| 102 | Result MapDeviceAddressSpaceAligned(Core::System& system, Handle das_handle, Handle process_handle, uint64_t process_address, uint64_t size, uint64_t device_address, uint32_t option); | ||
| 103 | Result UnmapDeviceAddressSpace(Core::System& system, Handle das_handle, Handle process_handle, uint64_t process_address, uint64_t size, uint64_t device_address); | ||
| 104 | Result InvalidateProcessDataCache(Core::System& system, Handle process_handle, uint64_t address, uint64_t size); | ||
| 105 | Result StoreProcessDataCache(Core::System& system, Handle process_handle, uint64_t address, uint64_t size); | ||
| 106 | Result FlushProcessDataCache(Core::System& system, Handle process_handle, uint64_t address, uint64_t size); | ||
| 107 | Result DebugActiveProcess(Core::System& system, Handle* out_handle, uint64_t process_id); | ||
| 108 | Result BreakDebugProcess(Core::System& system, Handle debug_handle); | ||
| 109 | Result TerminateDebugProcess(Core::System& system, Handle debug_handle); | ||
| 110 | Result GetDebugEvent(Core::System& system, uint64_t out_info, Handle debug_handle); | ||
| 111 | Result ContinueDebugEvent(Core::System& system, Handle debug_handle, uint32_t flags, uint64_t thread_ids, int32_t num_thread_ids); | ||
| 112 | Result GetProcessList(Core::System& system, int32_t* out_num_processes, uint64_t out_process_ids, int32_t max_out_count); | ||
| 113 | Result GetThreadList(Core::System& system, int32_t* out_num_threads, uint64_t out_thread_ids, int32_t max_out_count, Handle debug_handle); | ||
| 114 | Result GetDebugThreadContext(Core::System& system, uint64_t out_context, Handle debug_handle, uint64_t thread_id, uint32_t context_flags); | ||
| 115 | Result SetDebugThreadContext(Core::System& system, Handle debug_handle, uint64_t thread_id, uint64_t context, uint32_t context_flags); | ||
| 116 | Result QueryDebugProcessMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, Handle process_handle, uint64_t address); | ||
| 117 | Result ReadDebugProcessMemory(Core::System& system, uint64_t buffer, Handle debug_handle, uint64_t address, uint64_t size); | ||
| 118 | Result WriteDebugProcessMemory(Core::System& system, Handle debug_handle, uint64_t buffer, uint64_t address, uint64_t size); | ||
| 119 | Result SetHardwareBreakPoint(Core::System& system, HardwareBreakPointRegisterName name, uint64_t flags, uint64_t value); | ||
| 120 | Result GetDebugThreadParam(Core::System& system, uint64_t* out_64, uint32_t* out_32, Handle debug_handle, uint64_t thread_id, DebugThreadParam param); | ||
| 121 | Result GetSystemInfo(Core::System& system, uint64_t* out, SystemInfoType info_type, Handle handle, uint64_t info_subtype); | ||
| 122 | Result CreatePort(Core::System& system, Handle* out_server_handle, Handle* out_client_handle, int32_t max_sessions, bool is_light, uint64_t name); | ||
| 123 | Result ManageNamedPort(Core::System& system, Handle* out_server_handle, uint64_t name, int32_t max_sessions); | ||
| 124 | Result ConnectToPort(Core::System& system, Handle* out_handle, Handle port); | ||
| 125 | Result SetProcessMemoryPermission(Core::System& system, Handle process_handle, uint64_t address, uint64_t size, MemoryPermission perm); | ||
| 126 | Result MapProcessMemory(Core::System& system, uint64_t dst_address, Handle process_handle, uint64_t src_address, uint64_t size); | ||
| 127 | Result UnmapProcessMemory(Core::System& system, uint64_t dst_address, Handle process_handle, uint64_t src_address, uint64_t size); | ||
| 128 | Result QueryProcessMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, Handle process_handle, uint64_t address); | ||
| 129 | Result MapProcessCodeMemory(Core::System& system, Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size); | ||
| 130 | Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size); | ||
| 131 | Result CreateProcess(Core::System& system, Handle* out_handle, uint64_t parameters, uint64_t caps, int32_t num_caps); | ||
| 132 | Result StartProcess(Core::System& system, Handle process_handle, int32_t priority, int32_t core_id, uint64_t main_thread_stack_size); | ||
| 133 | Result TerminateProcess(Core::System& system, Handle process_handle); | ||
| 134 | Result GetProcessInfo(Core::System& system, int64_t* out_info, Handle process_handle, ProcessInfoType info_type); | ||
| 104 | Result CreateResourceLimit(Core::System& system, Handle* out_handle); | 135 | Result CreateResourceLimit(Core::System& system, Handle* out_handle); |
| 105 | Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle, | 136 | Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle, LimitableResource which, int64_t limit_value); |
| 106 | LimitableResource which, u64 limit_value); | 137 | Result MapInsecureMemory(Core::System& system, uint64_t address, uint64_t size); |
| 107 | 138 | Result UnmapInsecureMemory(Core::System& system, uint64_t address, uint64_t size); | |
| 108 | // | 139 | |
| 109 | 140 | Result SetHeapSize64From32(Core::System& system, uintptr_t* out_address, uint32_t size); | |
| 110 | Result SetHeapSize32(Core::System& system, u32* heap_addr, u32 heap_size); | 141 | Result SetMemoryPermission64From32(Core::System& system, uint32_t address, uint32_t size, MemoryPermission perm); |
| 111 | Result SetMemoryAttribute32(Core::System& system, u32 address, u32 size, u32 mask, u32 attr); | 142 | Result SetMemoryAttribute64From32(Core::System& system, uint32_t address, uint32_t size, uint32_t mask, uint32_t attr); |
| 112 | Result MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size); | 143 | Result MapMemory64From32(Core::System& system, uint32_t dst_address, uint32_t src_address, uint32_t size); |
| 113 | Result UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size); | 144 | Result UnmapMemory64From32(Core::System& system, uint32_t dst_address, uint32_t src_address, uint32_t size); |
| 114 | Result QueryMemory32(Core::System& system, u32 memory_info_address, u32 page_info_address, | 145 | Result QueryMemory64From32(Core::System& system, uint32_t out_memory_info, PageInfo* out_page_info, uint32_t address); |
| 115 | u32 query_address); | 146 | void ExitProcess64From32(Core::System& system); |
| 116 | void ExitProcess32(Core::System& system); | 147 | Result CreateThread64From32(Core::System& system, Handle* out_handle, uint32_t func, uint32_t arg, uint32_t stack_bottom, int32_t priority, int32_t core_id); |
| 117 | Result CreateThread32(Core::System& system, Handle* out_handle, u32 priority, u32 entry_point, | 148 | Result StartThread64From32(Core::System& system, Handle thread_handle); |
| 118 | u32 arg, u32 stack_top, s32 processor_id); | 149 | void ExitThread64From32(Core::System& system); |
| 119 | Result StartThread32(Core::System& system, Handle thread_handle); | 150 | void SleepThread64From32(Core::System& system, int64_t ns); |
| 120 | void ExitThread32(Core::System& system); | 151 | Result GetThreadPriority64From32(Core::System& system, int32_t* out_priority, Handle thread_handle); |
| 121 | void SleepThread32(Core::System& system, u32 nanoseconds_low, u32 nanoseconds_high); | 152 | Result SetThreadPriority64From32(Core::System& system, Handle thread_handle, int32_t priority); |
| 122 | Result GetThreadPriority32(Core::System& system, u32* out_priority, Handle handle); | 153 | Result GetThreadCoreMask64From32(Core::System& system, int32_t* out_core_id, uint64_t* out_affinity_mask, Handle thread_handle); |
| 123 | Result SetThreadPriority32(Core::System& system, Handle thread_handle, u32 priority); | 154 | Result SetThreadCoreMask64From32(Core::System& system, Handle thread_handle, int32_t core_id, uint64_t affinity_mask); |
| 124 | Result GetThreadCoreMask32(Core::System& system, Handle thread_handle, s32* out_core_id, | 155 | int32_t GetCurrentProcessorNumber64From32(Core::System& system); |
| 125 | u32* out_affinity_mask_low, u32* out_affinity_mask_high); | 156 | Result SignalEvent64From32(Core::System& system, Handle event_handle); |
| 126 | Result SetThreadCoreMask32(Core::System& system, Handle thread_handle, s32 core_id, | 157 | Result ClearEvent64From32(Core::System& system, Handle event_handle); |
| 127 | u32 affinity_mask_low, u32 affinity_mask_high); | 158 | Result MapSharedMemory64From32(Core::System& system, Handle shmem_handle, uint32_t address, uint32_t size, MemoryPermission map_perm); |
| 128 | u32 GetCurrentProcessorNumber32(Core::System& system); | 159 | Result UnmapSharedMemory64From32(Core::System& system, Handle shmem_handle, uint32_t address, uint32_t size); |
| 129 | Result SignalEvent32(Core::System& system, Handle event_handle); | 160 | Result CreateTransferMemory64From32(Core::System& system, Handle* out_handle, uint32_t address, uint32_t size, MemoryPermission map_perm); |
| 130 | Result ClearEvent32(Core::System& system, Handle event_handle); | 161 | Result CloseHandle64From32(Core::System& system, Handle handle); |
| 131 | Result MapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, u32 size, | 162 | Result ResetSignal64From32(Core::System& system, Handle handle); |
| 132 | MemoryPermission map_perm); | 163 | Result WaitSynchronization64From32(Core::System& system, int32_t* out_index, uint32_t handles, int32_t num_handles, int64_t timeout_ns); |
| 133 | Result UnmapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, u32 size); | 164 | Result CancelSynchronization64From32(Core::System& system, Handle handle); |
| 134 | Result CreateTransferMemory32(Core::System& system, Handle* out, u32 address, u32 size, | 165 | Result ArbitrateLock64From32(Core::System& system, Handle thread_handle, uint32_t address, uint32_t tag); |
| 135 | MemoryPermission map_perm); | 166 | Result ArbitrateUnlock64From32(Core::System& system, uint32_t address); |
| 136 | Result CloseHandle32(Core::System& system, Handle handle); | 167 | Result WaitProcessWideKeyAtomic64From32(Core::System& system, uint32_t address, uint32_t cv_key, uint32_t tag, int64_t timeout_ns); |
| 137 | Result ResetSignal32(Core::System& system, Handle handle); | 168 | void SignalProcessWideKey64From32(Core::System& system, uint32_t cv_key, int32_t count); |
| 138 | Result WaitSynchronization32(Core::System& system, u32 timeout_low, u32 handles_address, | 169 | int64_t GetSystemTick64From32(Core::System& system); |
| 139 | s32 num_handles, u32 timeout_high, s32* index); | 170 | Result ConnectToNamedPort64From32(Core::System& system, Handle* out_handle, uint32_t name); |
| 140 | Result CancelSynchronization32(Core::System& system, Handle handle); | 171 | Result SendSyncRequest64From32(Core::System& system, Handle session_handle); |
| 141 | Result ArbitrateLock32(Core::System& system, Handle thread_handle, u32 address, u32 tag); | 172 | Result SendSyncRequestWithUserBuffer64From32(Core::System& system, uint32_t message_buffer, uint32_t message_buffer_size, Handle session_handle); |
| 142 | Result ArbitrateUnlock32(Core::System& system, u32 address); | 173 | Result SendAsyncRequestWithUserBuffer64From32(Core::System& system, Handle* out_event_handle, uint32_t message_buffer, uint32_t message_buffer_size, Handle session_handle); |
| 143 | Result WaitProcessWideKeyAtomic32(Core::System& system, u32 address, u32 cv_key, u32 tag, | 174 | Result GetProcessId64From32(Core::System& system, uint64_t* out_process_id, Handle process_handle); |
| 144 | u32 timeout_ns_low, u32 timeout_ns_high); | 175 | Result GetThreadId64From32(Core::System& system, uint64_t* out_thread_id, Handle thread_handle); |
| 145 | void SignalProcessWideKey32(Core::System& system, u32 cv_key, s32 count); | 176 | void Break64From32(Core::System& system, BreakReason break_reason, uint32_t arg, uint32_t size); |
| 146 | void GetSystemTick32(Core::System& system, u32* time_low, u32* time_high); | 177 | Result OutputDebugString64From32(Core::System& system, uint32_t debug_str, uint32_t len); |
| 147 | Result ConnectToNamedPort32(Core::System& system, Handle* out_handle, u32 port_name_address); | 178 | void ReturnFromException64From32(Core::System& system, Result result); |
| 148 | Result SendSyncRequest32(Core::System& system, Handle handle); | 179 | Result GetInfo64From32(Core::System& system, uint64_t* out, InfoType info_type, Handle handle, uint64_t info_subtype); |
| 149 | Result GetProcessId32(Core::System& system, u32* out_process_id_low, u32* out_process_id_high, | 180 | void FlushEntireDataCache64From32(Core::System& system); |
| 150 | Handle handle); | 181 | Result FlushDataCache64From32(Core::System& system, uint32_t address, uint32_t size); |
| 151 | Result GetThreadId32(Core::System& system, u32* out_thread_id_low, u32* out_thread_id_high, | 182 | Result MapPhysicalMemory64From32(Core::System& system, uint32_t address, uint32_t size); |
| 152 | Handle thread_handle); | 183 | Result UnmapPhysicalMemory64From32(Core::System& system, uint32_t address, uint32_t size); |
| 153 | void Break32(Core::System& system, u32 reason, u32 info1, u32 info2); | 184 | Result GetDebugFutureThreadInfo64From32(Core::System& system, ilp32::LastThreadContext* out_context, uint64_t* out_thread_id, Handle debug_handle, int64_t ns); |
| 154 | void OutputDebugString32(Core::System& system, u32 address, u32 len); | 185 | Result GetLastThreadInfo64From32(Core::System& system, ilp32::LastThreadContext* out_context, uintptr_t* out_tls_address, uint32_t* out_flags); |
| 155 | Result GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low, | 186 | Result GetResourceLimitLimitValue64From32(Core::System& system, int64_t* out_limit_value, Handle resource_limit_handle, LimitableResource which); |
| 156 | u32 info_id, u32 handle, u32 sub_id_high); | 187 | Result GetResourceLimitCurrentValue64From32(Core::System& system, int64_t* out_current_value, Handle resource_limit_handle, LimitableResource which); |
| 157 | Result MapPhysicalMemory32(Core::System& system, u32 addr, u32 size); | 188 | Result SetThreadActivity64From32(Core::System& system, Handle thread_handle, ThreadActivity thread_activity); |
| 158 | Result UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size); | 189 | Result GetThreadContext364From32(Core::System& system, uint32_t out_context, Handle thread_handle); |
| 159 | Result SetThreadActivity32(Core::System& system, Handle thread_handle, | 190 | Result WaitForAddress64From32(Core::System& system, uint32_t address, ArbitrationType arb_type, int32_t value, int64_t timeout_ns); |
| 160 | ThreadActivity thread_activity); | 191 | Result SignalToAddress64From32(Core::System& system, uint32_t address, SignalType signal_type, int32_t value, int32_t count); |
| 161 | Result GetThreadContext32(Core::System& system, u32 out_context, Handle thread_handle); | 192 | void SynchronizePreemptionState64From32(Core::System& system); |
| 162 | Result WaitForAddress32(Core::System& system, u32 address, ArbitrationType arb_type, s32 value, | 193 | Result GetResourceLimitPeakValue64From32(Core::System& system, int64_t* out_peak_value, Handle resource_limit_handle, LimitableResource which); |
| 163 | u32 timeout_ns_low, u32 timeout_ns_high); | 194 | Result CreateIoPool64From32(Core::System& system, Handle* out_handle, IoPoolType which); |
| 164 | Result SignalToAddress32(Core::System& system, u32 address, SignalType signal_type, s32 value, | 195 | Result CreateIoRegion64From32(Core::System& system, Handle* out_handle, Handle io_pool, uint64_t physical_address, uint32_t size, MemoryMapping mapping, MemoryPermission perm); |
| 165 | s32 count); | 196 | void KernelDebug64From32(Core::System& system, KernelDebugType kern_debug_type, uint64_t arg0, uint64_t arg1, uint64_t arg2); |
| 166 | Result CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read); | 197 | void ChangeKernelTraceState64From32(Core::System& system, KernelTraceState kern_trace_state); |
| 167 | Result CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size); | 198 | Result CreateSession64From32(Core::System& system, Handle* out_server_session_handle, Handle* out_client_session_handle, bool is_light, uint32_t name); |
| 168 | Result ControlCodeMemory32(Core::System& system, Handle code_memory_handle, u32 operation, | 199 | Result AcceptSession64From32(Core::System& system, Handle* out_handle, Handle port); |
| 169 | u64 address, u64 size, MemoryPermission perm); | 200 | Result ReplyAndReceive64From32(Core::System& system, int32_t* out_index, uint32_t handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns); |
| 170 | Result FlushProcessDataCache32(Core::System& system, Handle process_handle, u64 address, u64 size); | 201 | Result ReplyAndReceiveWithUserBuffer64From32(Core::System& system, int32_t* out_index, uint32_t message_buffer, uint32_t message_buffer_size, uint32_t handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns); |
| 202 | Result CreateEvent64From32(Core::System& system, Handle* out_write_handle, Handle* out_read_handle); | ||
| 203 | Result MapIoRegion64From32(Core::System& system, Handle io_region, uint32_t address, uint32_t size, MemoryPermission perm); | ||
| 204 | Result UnmapIoRegion64From32(Core::System& system, Handle io_region, uint32_t address, uint32_t size); | ||
| 205 | Result MapPhysicalMemoryUnsafe64From32(Core::System& system, uint32_t address, uint32_t size); | ||
| 206 | Result UnmapPhysicalMemoryUnsafe64From32(Core::System& system, uint32_t address, uint32_t size); | ||
| 207 | Result SetUnsafeLimit64From32(Core::System& system, uint32_t limit); | ||
| 208 | Result CreateCodeMemory64From32(Core::System& system, Handle* out_handle, uint32_t address, uint32_t size); | ||
| 209 | Result ControlCodeMemory64From32(Core::System& system, Handle code_memory_handle, CodeMemoryOperation operation, uint64_t address, uint64_t size, MemoryPermission perm); | ||
| 210 | void SleepSystem64From32(Core::System& system); | ||
| 211 | Result ReadWriteRegister64From32(Core::System& system, uint32_t* out_value, uint64_t address, uint32_t mask, uint32_t value); | ||
| 212 | Result SetProcessActivity64From32(Core::System& system, Handle process_handle, ProcessActivity process_activity); | ||
| 213 | Result CreateSharedMemory64From32(Core::System& system, Handle* out_handle, uint32_t size, MemoryPermission owner_perm, MemoryPermission remote_perm); | ||
| 214 | Result MapTransferMemory64From32(Core::System& system, Handle trmem_handle, uint32_t address, uint32_t size, MemoryPermission owner_perm); | ||
| 215 | Result UnmapTransferMemory64From32(Core::System& system, Handle trmem_handle, uint32_t address, uint32_t size); | ||
| 216 | Result CreateInterruptEvent64From32(Core::System& system, Handle* out_read_handle, int32_t interrupt_id, InterruptType interrupt_type); | ||
| 217 | Result QueryPhysicalAddress64From32(Core::System& system, ilp32::PhysicalMemoryInfo* out_info, uint32_t address); | ||
| 218 | Result QueryIoMapping64From32(Core::System& system, uintptr_t* out_address, uintptr_t* out_size, uint64_t physical_address, uint32_t size); | ||
| 219 | Result CreateDeviceAddressSpace64From32(Core::System& system, Handle* out_handle, uint64_t das_address, uint64_t das_size); | ||
| 220 | Result AttachDeviceAddressSpace64From32(Core::System& system, DeviceName device_name, Handle das_handle); | ||
| 221 | Result DetachDeviceAddressSpace64From32(Core::System& system, DeviceName device_name, Handle das_handle); | ||
| 222 | Result MapDeviceAddressSpaceByForce64From32(Core::System& system, Handle das_handle, Handle process_handle, uint64_t process_address, uint32_t size, uint64_t device_address, uint32_t option); | ||
| 223 | Result MapDeviceAddressSpaceAligned64From32(Core::System& system, Handle das_handle, Handle process_handle, uint64_t process_address, uint32_t size, uint64_t device_address, uint32_t option); | ||
| 224 | Result UnmapDeviceAddressSpace64From32(Core::System& system, Handle das_handle, Handle process_handle, uint64_t process_address, uint32_t size, uint64_t device_address); | ||
| 225 | Result InvalidateProcessDataCache64From32(Core::System& system, Handle process_handle, uint64_t address, uint64_t size); | ||
| 226 | Result StoreProcessDataCache64From32(Core::System& system, Handle process_handle, uint64_t address, uint64_t size); | ||
| 227 | Result FlushProcessDataCache64From32(Core::System& system, Handle process_handle, uint64_t address, uint64_t size); | ||
| 228 | Result DebugActiveProcess64From32(Core::System& system, Handle* out_handle, uint64_t process_id); | ||
| 229 | Result BreakDebugProcess64From32(Core::System& system, Handle debug_handle); | ||
| 230 | Result TerminateDebugProcess64From32(Core::System& system, Handle debug_handle); | ||
| 231 | Result GetDebugEvent64From32(Core::System& system, uint32_t out_info, Handle debug_handle); | ||
| 232 | Result ContinueDebugEvent64From32(Core::System& system, Handle debug_handle, uint32_t flags, uint32_t thread_ids, int32_t num_thread_ids); | ||
| 233 | Result GetProcessList64From32(Core::System& system, int32_t* out_num_processes, uint32_t out_process_ids, int32_t max_out_count); | ||
| 234 | Result GetThreadList64From32(Core::System& system, int32_t* out_num_threads, uint32_t out_thread_ids, int32_t max_out_count, Handle debug_handle); | ||
| 235 | Result GetDebugThreadContext64From32(Core::System& system, uint32_t out_context, Handle debug_handle, uint64_t thread_id, uint32_t context_flags); | ||
| 236 | Result SetDebugThreadContext64From32(Core::System& system, Handle debug_handle, uint64_t thread_id, uint32_t context, uint32_t context_flags); | ||
| 237 | Result QueryDebugProcessMemory64From32(Core::System& system, uint32_t out_memory_info, PageInfo* out_page_info, Handle process_handle, uint32_t address); | ||
| 238 | Result ReadDebugProcessMemory64From32(Core::System& system, uint32_t buffer, Handle debug_handle, uint32_t address, uint32_t size); | ||
| 239 | Result WriteDebugProcessMemory64From32(Core::System& system, Handle debug_handle, uint32_t buffer, uint32_t address, uint32_t size); | ||
| 240 | Result SetHardwareBreakPoint64From32(Core::System& system, HardwareBreakPointRegisterName name, uint64_t flags, uint64_t value); | ||
| 241 | Result GetDebugThreadParam64From32(Core::System& system, uint64_t* out_64, uint32_t* out_32, Handle debug_handle, uint64_t thread_id, DebugThreadParam param); | ||
| 242 | Result GetSystemInfo64From32(Core::System& system, uint64_t* out, SystemInfoType info_type, Handle handle, uint64_t info_subtype); | ||
| 243 | Result CreatePort64From32(Core::System& system, Handle* out_server_handle, Handle* out_client_handle, int32_t max_sessions, bool is_light, uint32_t name); | ||
| 244 | Result ManageNamedPort64From32(Core::System& system, Handle* out_server_handle, uint32_t name, int32_t max_sessions); | ||
| 245 | Result ConnectToPort64From32(Core::System& system, Handle* out_handle, Handle port); | ||
| 246 | Result SetProcessMemoryPermission64From32(Core::System& system, Handle process_handle, uint64_t address, uint64_t size, MemoryPermission perm); | ||
| 247 | Result MapProcessMemory64From32(Core::System& system, uint32_t dst_address, Handle process_handle, uint64_t src_address, uint32_t size); | ||
| 248 | Result UnmapProcessMemory64From32(Core::System& system, uint32_t dst_address, Handle process_handle, uint64_t src_address, uint32_t size); | ||
| 249 | Result QueryProcessMemory64From32(Core::System& system, uint32_t out_memory_info, PageInfo* out_page_info, Handle process_handle, uint64_t address); | ||
| 250 | Result MapProcessCodeMemory64From32(Core::System& system, Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size); | ||
| 251 | Result UnmapProcessCodeMemory64From32(Core::System& system, Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size); | ||
| 252 | Result CreateProcess64From32(Core::System& system, Handle* out_handle, uint32_t parameters, uint32_t caps, int32_t num_caps); | ||
| 253 | Result StartProcess64From32(Core::System& system, Handle process_handle, int32_t priority, int32_t core_id, uint64_t main_thread_stack_size); | ||
| 254 | Result TerminateProcess64From32(Core::System& system, Handle process_handle); | ||
| 255 | Result GetProcessInfo64From32(Core::System& system, int64_t* out_info, Handle process_handle, ProcessInfoType info_type); | ||
| 256 | Result CreateResourceLimit64From32(Core::System& system, Handle* out_handle); | ||
| 257 | Result SetResourceLimitLimitValue64From32(Core::System& system, Handle resource_limit_handle, LimitableResource which, int64_t limit_value); | ||
| 258 | Result MapInsecureMemory64From32(Core::System& system, uint32_t address, uint32_t size); | ||
| 259 | Result UnmapInsecureMemory64From32(Core::System& system, uint32_t address, uint32_t size); | ||
| 260 | |||
| 261 | Result SetHeapSize64(Core::System& system, uintptr_t* out_address, uint64_t size); | ||
| 262 | Result SetMemoryPermission64(Core::System& system, uint64_t address, uint64_t size, MemoryPermission perm); | ||
| 263 | Result SetMemoryAttribute64(Core::System& system, uint64_t address, uint64_t size, uint32_t mask, uint32_t attr); | ||
| 264 | Result MapMemory64(Core::System& system, uint64_t dst_address, uint64_t src_address, uint64_t size); | ||
| 265 | Result UnmapMemory64(Core::System& system, uint64_t dst_address, uint64_t src_address, uint64_t size); | ||
| 266 | Result QueryMemory64(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, uint64_t address); | ||
| 267 | void ExitProcess64(Core::System& system); | ||
| 268 | Result CreateThread64(Core::System& system, Handle* out_handle, uint64_t func, uint64_t arg, uint64_t stack_bottom, int32_t priority, int32_t core_id); | ||
| 269 | Result StartThread64(Core::System& system, Handle thread_handle); | ||
| 270 | void ExitThread64(Core::System& system); | ||
| 271 | void SleepThread64(Core::System& system, int64_t ns); | ||
| 272 | Result GetThreadPriority64(Core::System& system, int32_t* out_priority, Handle thread_handle); | ||
| 273 | Result SetThreadPriority64(Core::System& system, Handle thread_handle, int32_t priority); | ||
| 274 | Result GetThreadCoreMask64(Core::System& system, int32_t* out_core_id, uint64_t* out_affinity_mask, Handle thread_handle); | ||
| 275 | Result SetThreadCoreMask64(Core::System& system, Handle thread_handle, int32_t core_id, uint64_t affinity_mask); | ||
| 276 | int32_t GetCurrentProcessorNumber64(Core::System& system); | ||
| 277 | Result SignalEvent64(Core::System& system, Handle event_handle); | ||
| 278 | Result ClearEvent64(Core::System& system, Handle event_handle); | ||
| 279 | Result MapSharedMemory64(Core::System& system, Handle shmem_handle, uint64_t address, uint64_t size, MemoryPermission map_perm); | ||
| 280 | Result UnmapSharedMemory64(Core::System& system, Handle shmem_handle, uint64_t address, uint64_t size); | ||
| 281 | Result CreateTransferMemory64(Core::System& system, Handle* out_handle, uint64_t address, uint64_t size, MemoryPermission map_perm); | ||
| 282 | Result CloseHandle64(Core::System& system, Handle handle); | ||
| 283 | Result ResetSignal64(Core::System& system, Handle handle); | ||
| 284 | Result WaitSynchronization64(Core::System& system, int32_t* out_index, uint64_t handles, int32_t num_handles, int64_t timeout_ns); | ||
| 285 | Result CancelSynchronization64(Core::System& system, Handle handle); | ||
| 286 | Result ArbitrateLock64(Core::System& system, Handle thread_handle, uint64_t address, uint32_t tag); | ||
| 287 | Result ArbitrateUnlock64(Core::System& system, uint64_t address); | ||
| 288 | Result WaitProcessWideKeyAtomic64(Core::System& system, uint64_t address, uint64_t cv_key, uint32_t tag, int64_t timeout_ns); | ||
| 289 | void SignalProcessWideKey64(Core::System& system, uint64_t cv_key, int32_t count); | ||
| 290 | int64_t GetSystemTick64(Core::System& system); | ||
| 291 | Result ConnectToNamedPort64(Core::System& system, Handle* out_handle, uint64_t name); | ||
| 292 | Result SendSyncRequest64(Core::System& system, Handle session_handle); | ||
| 293 | Result SendSyncRequestWithUserBuffer64(Core::System& system, uint64_t message_buffer, uint64_t message_buffer_size, Handle session_handle); | ||
| 294 | Result SendAsyncRequestWithUserBuffer64(Core::System& system, Handle* out_event_handle, uint64_t message_buffer, uint64_t message_buffer_size, Handle session_handle); | ||
| 295 | Result GetProcessId64(Core::System& system, uint64_t* out_process_id, Handle process_handle); | ||
| 296 | Result GetThreadId64(Core::System& system, uint64_t* out_thread_id, Handle thread_handle); | ||
| 297 | void Break64(Core::System& system, BreakReason break_reason, uint64_t arg, uint64_t size); | ||
| 298 | Result OutputDebugString64(Core::System& system, uint64_t debug_str, uint64_t len); | ||
| 299 | void ReturnFromException64(Core::System& system, Result result); | ||
| 300 | Result GetInfo64(Core::System& system, uint64_t* out, InfoType info_type, Handle handle, uint64_t info_subtype); | ||
| 301 | void FlushEntireDataCache64(Core::System& system); | ||
| 302 | Result FlushDataCache64(Core::System& system, uint64_t address, uint64_t size); | ||
| 303 | Result MapPhysicalMemory64(Core::System& system, uint64_t address, uint64_t size); | ||
| 304 | Result UnmapPhysicalMemory64(Core::System& system, uint64_t address, uint64_t size); | ||
| 305 | Result GetDebugFutureThreadInfo64(Core::System& system, lp64::LastThreadContext* out_context, uint64_t* out_thread_id, Handle debug_handle, int64_t ns); | ||
| 306 | Result GetLastThreadInfo64(Core::System& system, lp64::LastThreadContext* out_context, uintptr_t* out_tls_address, uint32_t* out_flags); | ||
| 307 | Result GetResourceLimitLimitValue64(Core::System& system, int64_t* out_limit_value, Handle resource_limit_handle, LimitableResource which); | ||
| 308 | Result GetResourceLimitCurrentValue64(Core::System& system, int64_t* out_current_value, Handle resource_limit_handle, LimitableResource which); | ||
| 309 | Result SetThreadActivity64(Core::System& system, Handle thread_handle, ThreadActivity thread_activity); | ||
| 310 | Result GetThreadContext364(Core::System& system, uint64_t out_context, Handle thread_handle); | ||
| 311 | Result WaitForAddress64(Core::System& system, uint64_t address, ArbitrationType arb_type, int32_t value, int64_t timeout_ns); | ||
| 312 | Result SignalToAddress64(Core::System& system, uint64_t address, SignalType signal_type, int32_t value, int32_t count); | ||
| 313 | void SynchronizePreemptionState64(Core::System& system); | ||
| 314 | Result GetResourceLimitPeakValue64(Core::System& system, int64_t* out_peak_value, Handle resource_limit_handle, LimitableResource which); | ||
| 315 | Result CreateIoPool64(Core::System& system, Handle* out_handle, IoPoolType which); | ||
| 316 | Result CreateIoRegion64(Core::System& system, Handle* out_handle, Handle io_pool, uint64_t physical_address, uint64_t size, MemoryMapping mapping, MemoryPermission perm); | ||
| 317 | void KernelDebug64(Core::System& system, KernelDebugType kern_debug_type, uint64_t arg0, uint64_t arg1, uint64_t arg2); | ||
| 318 | void ChangeKernelTraceState64(Core::System& system, KernelTraceState kern_trace_state); | ||
| 319 | Result CreateSession64(Core::System& system, Handle* out_server_session_handle, Handle* out_client_session_handle, bool is_light, uint64_t name); | ||
| 320 | Result AcceptSession64(Core::System& system, Handle* out_handle, Handle port); | ||
| 321 | Result ReplyAndReceive64(Core::System& system, int32_t* out_index, uint64_t handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns); | ||
| 322 | Result ReplyAndReceiveWithUserBuffer64(Core::System& system, int32_t* out_index, uint64_t message_buffer, uint64_t message_buffer_size, uint64_t handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns); | ||
| 323 | Result CreateEvent64(Core::System& system, Handle* out_write_handle, Handle* out_read_handle); | ||
| 324 | Result MapIoRegion64(Core::System& system, Handle io_region, uint64_t address, uint64_t size, MemoryPermission perm); | ||
| 325 | Result UnmapIoRegion64(Core::System& system, Handle io_region, uint64_t address, uint64_t size); | ||
| 326 | Result MapPhysicalMemoryUnsafe64(Core::System& system, uint64_t address, uint64_t size); | ||
| 327 | Result UnmapPhysicalMemoryUnsafe64(Core::System& system, uint64_t address, uint64_t size); | ||
| 328 | Result SetUnsafeLimit64(Core::System& system, uint64_t limit); | ||
| 329 | Result CreateCodeMemory64(Core::System& system, Handle* out_handle, uint64_t address, uint64_t size); | ||
| 330 | Result ControlCodeMemory64(Core::System& system, Handle code_memory_handle, CodeMemoryOperation operation, uint64_t address, uint64_t size, MemoryPermission perm); | ||
| 331 | void SleepSystem64(Core::System& system); | ||
| 332 | Result ReadWriteRegister64(Core::System& system, uint32_t* out_value, uint64_t address, uint32_t mask, uint32_t value); | ||
| 333 | Result SetProcessActivity64(Core::System& system, Handle process_handle, ProcessActivity process_activity); | ||
| 334 | Result CreateSharedMemory64(Core::System& system, Handle* out_handle, uint64_t size, MemoryPermission owner_perm, MemoryPermission remote_perm); | ||
| 335 | Result MapTransferMemory64(Core::System& system, Handle trmem_handle, uint64_t address, uint64_t size, MemoryPermission owner_perm); | ||
| 336 | Result UnmapTransferMemory64(Core::System& system, Handle trmem_handle, uint64_t address, uint64_t size); | ||
| 337 | Result CreateInterruptEvent64(Core::System& system, Handle* out_read_handle, int32_t interrupt_id, InterruptType interrupt_type); | ||
| 338 | Result QueryPhysicalAddress64(Core::System& system, lp64::PhysicalMemoryInfo* out_info, uint64_t address); | ||
| 339 | Result QueryIoMapping64(Core::System& system, uintptr_t* out_address, uintptr_t* out_size, uint64_t physical_address, uint64_t size); | ||
| 340 | Result CreateDeviceAddressSpace64(Core::System& system, Handle* out_handle, uint64_t das_address, uint64_t das_size); | ||
| 341 | Result AttachDeviceAddressSpace64(Core::System& system, DeviceName device_name, Handle das_handle); | ||
| 342 | Result DetachDeviceAddressSpace64(Core::System& system, DeviceName device_name, Handle das_handle); | ||
| 343 | Result MapDeviceAddressSpaceByForce64(Core::System& system, Handle das_handle, Handle process_handle, uint64_t process_address, uint64_t size, uint64_t device_address, uint32_t option); | ||
| 344 | Result MapDeviceAddressSpaceAligned64(Core::System& system, Handle das_handle, Handle process_handle, uint64_t process_address, uint64_t size, uint64_t device_address, uint32_t option); | ||
| 345 | Result UnmapDeviceAddressSpace64(Core::System& system, Handle das_handle, Handle process_handle, uint64_t process_address, uint64_t size, uint64_t device_address); | ||
| 346 | Result InvalidateProcessDataCache64(Core::System& system, Handle process_handle, uint64_t address, uint64_t size); | ||
| 347 | Result StoreProcessDataCache64(Core::System& system, Handle process_handle, uint64_t address, uint64_t size); | ||
| 348 | Result FlushProcessDataCache64(Core::System& system, Handle process_handle, uint64_t address, uint64_t size); | ||
| 349 | Result DebugActiveProcess64(Core::System& system, Handle* out_handle, uint64_t process_id); | ||
| 350 | Result BreakDebugProcess64(Core::System& system, Handle debug_handle); | ||
| 351 | Result TerminateDebugProcess64(Core::System& system, Handle debug_handle); | ||
| 352 | Result GetDebugEvent64(Core::System& system, uint64_t out_info, Handle debug_handle); | ||
| 353 | Result ContinueDebugEvent64(Core::System& system, Handle debug_handle, uint32_t flags, uint64_t thread_ids, int32_t num_thread_ids); | ||
| 354 | Result GetProcessList64(Core::System& system, int32_t* out_num_processes, uint64_t out_process_ids, int32_t max_out_count); | ||
| 355 | Result GetThreadList64(Core::System& system, int32_t* out_num_threads, uint64_t out_thread_ids, int32_t max_out_count, Handle debug_handle); | ||
| 356 | Result GetDebugThreadContext64(Core::System& system, uint64_t out_context, Handle debug_handle, uint64_t thread_id, uint32_t context_flags); | ||
| 357 | Result SetDebugThreadContext64(Core::System& system, Handle debug_handle, uint64_t thread_id, uint64_t context, uint32_t context_flags); | ||
| 358 | Result QueryDebugProcessMemory64(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, Handle process_handle, uint64_t address); | ||
| 359 | Result ReadDebugProcessMemory64(Core::System& system, uint64_t buffer, Handle debug_handle, uint64_t address, uint64_t size); | ||
| 360 | Result WriteDebugProcessMemory64(Core::System& system, Handle debug_handle, uint64_t buffer, uint64_t address, uint64_t size); | ||
| 361 | Result SetHardwareBreakPoint64(Core::System& system, HardwareBreakPointRegisterName name, uint64_t flags, uint64_t value); | ||
| 362 | Result GetDebugThreadParam64(Core::System& system, uint64_t* out_64, uint32_t* out_32, Handle debug_handle, uint64_t thread_id, DebugThreadParam param); | ||
| 363 | Result GetSystemInfo64(Core::System& system, uint64_t* out, SystemInfoType info_type, Handle handle, uint64_t info_subtype); | ||
| 364 | Result CreatePort64(Core::System& system, Handle* out_server_handle, Handle* out_client_handle, int32_t max_sessions, bool is_light, uint64_t name); | ||
| 365 | Result ManageNamedPort64(Core::System& system, Handle* out_server_handle, uint64_t name, int32_t max_sessions); | ||
| 366 | Result ConnectToPort64(Core::System& system, Handle* out_handle, Handle port); | ||
| 367 | Result SetProcessMemoryPermission64(Core::System& system, Handle process_handle, uint64_t address, uint64_t size, MemoryPermission perm); | ||
| 368 | Result MapProcessMemory64(Core::System& system, uint64_t dst_address, Handle process_handle, uint64_t src_address, uint64_t size); | ||
| 369 | Result UnmapProcessMemory64(Core::System& system, uint64_t dst_address, Handle process_handle, uint64_t src_address, uint64_t size); | ||
| 370 | Result QueryProcessMemory64(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, Handle process_handle, uint64_t address); | ||
| 371 | Result MapProcessCodeMemory64(Core::System& system, Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size); | ||
| 372 | Result UnmapProcessCodeMemory64(Core::System& system, Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size); | ||
| 373 | Result CreateProcess64(Core::System& system, Handle* out_handle, uint64_t parameters, uint64_t caps, int32_t num_caps); | ||
| 374 | Result StartProcess64(Core::System& system, Handle process_handle, int32_t priority, int32_t core_id, uint64_t main_thread_stack_size); | ||
| 375 | Result TerminateProcess64(Core::System& system, Handle process_handle); | ||
| 376 | Result GetProcessInfo64(Core::System& system, int64_t* out_info, Handle process_handle, ProcessInfoType info_type); | ||
| 377 | Result CreateResourceLimit64(Core::System& system, Handle* out_handle); | ||
| 378 | Result SetResourceLimitLimitValue64(Core::System& system, Handle resource_limit_handle, LimitableResource which, int64_t limit_value); | ||
| 379 | Result MapInsecureMemory64(Core::System& system, uint64_t address, uint64_t size); | ||
| 380 | Result UnmapInsecureMemory64(Core::System& system, uint64_t address, uint64_t size); | ||
| 381 | |||
| 382 | enum class SvcId : u32 { | ||
| 383 | SetHeapSize = 0x1, | ||
| 384 | SetMemoryPermission = 0x2, | ||
| 385 | SetMemoryAttribute = 0x3, | ||
| 386 | MapMemory = 0x4, | ||
| 387 | UnmapMemory = 0x5, | ||
| 388 | QueryMemory = 0x6, | ||
| 389 | ExitProcess = 0x7, | ||
| 390 | CreateThread = 0x8, | ||
| 391 | StartThread = 0x9, | ||
| 392 | ExitThread = 0xa, | ||
| 393 | SleepThread = 0xb, | ||
| 394 | GetThreadPriority = 0xc, | ||
| 395 | SetThreadPriority = 0xd, | ||
| 396 | GetThreadCoreMask = 0xe, | ||
| 397 | SetThreadCoreMask = 0xf, | ||
| 398 | GetCurrentProcessorNumber = 0x10, | ||
| 399 | SignalEvent = 0x11, | ||
| 400 | ClearEvent = 0x12, | ||
| 401 | MapSharedMemory = 0x13, | ||
| 402 | UnmapSharedMemory = 0x14, | ||
| 403 | CreateTransferMemory = 0x15, | ||
| 404 | CloseHandle = 0x16, | ||
| 405 | ResetSignal = 0x17, | ||
| 406 | WaitSynchronization = 0x18, | ||
| 407 | CancelSynchronization = 0x19, | ||
| 408 | ArbitrateLock = 0x1a, | ||
| 409 | ArbitrateUnlock = 0x1b, | ||
| 410 | WaitProcessWideKeyAtomic = 0x1c, | ||
| 411 | SignalProcessWideKey = 0x1d, | ||
| 412 | GetSystemTick = 0x1e, | ||
| 413 | ConnectToNamedPort = 0x1f, | ||
| 414 | SendSyncRequestLight = 0x20, | ||
| 415 | SendSyncRequest = 0x21, | ||
| 416 | SendSyncRequestWithUserBuffer = 0x22, | ||
| 417 | SendAsyncRequestWithUserBuffer = 0x23, | ||
| 418 | GetProcessId = 0x24, | ||
| 419 | GetThreadId = 0x25, | ||
| 420 | Break = 0x26, | ||
| 421 | OutputDebugString = 0x27, | ||
| 422 | ReturnFromException = 0x28, | ||
| 423 | GetInfo = 0x29, | ||
| 424 | FlushEntireDataCache = 0x2a, | ||
| 425 | FlushDataCache = 0x2b, | ||
| 426 | MapPhysicalMemory = 0x2c, | ||
| 427 | UnmapPhysicalMemory = 0x2d, | ||
| 428 | GetDebugFutureThreadInfo = 0x2e, | ||
| 429 | GetLastThreadInfo = 0x2f, | ||
| 430 | GetResourceLimitLimitValue = 0x30, | ||
| 431 | GetResourceLimitCurrentValue = 0x31, | ||
| 432 | SetThreadActivity = 0x32, | ||
| 433 | GetThreadContext3 = 0x33, | ||
| 434 | WaitForAddress = 0x34, | ||
| 435 | SignalToAddress = 0x35, | ||
| 436 | SynchronizePreemptionState = 0x36, | ||
| 437 | GetResourceLimitPeakValue = 0x37, | ||
| 438 | CreateIoPool = 0x39, | ||
| 439 | CreateIoRegion = 0x3a, | ||
| 440 | KernelDebug = 0x3c, | ||
| 441 | ChangeKernelTraceState = 0x3d, | ||
| 442 | CreateSession = 0x40, | ||
| 443 | AcceptSession = 0x41, | ||
| 444 | ReplyAndReceiveLight = 0x42, | ||
| 445 | ReplyAndReceive = 0x43, | ||
| 446 | ReplyAndReceiveWithUserBuffer = 0x44, | ||
| 447 | CreateEvent = 0x45, | ||
| 448 | MapIoRegion = 0x46, | ||
| 449 | UnmapIoRegion = 0x47, | ||
| 450 | MapPhysicalMemoryUnsafe = 0x48, | ||
| 451 | UnmapPhysicalMemoryUnsafe = 0x49, | ||
| 452 | SetUnsafeLimit = 0x4a, | ||
| 453 | CreateCodeMemory = 0x4b, | ||
| 454 | ControlCodeMemory = 0x4c, | ||
| 455 | SleepSystem = 0x4d, | ||
| 456 | ReadWriteRegister = 0x4e, | ||
| 457 | SetProcessActivity = 0x4f, | ||
| 458 | CreateSharedMemory = 0x50, | ||
| 459 | MapTransferMemory = 0x51, | ||
| 460 | UnmapTransferMemory = 0x52, | ||
| 461 | CreateInterruptEvent = 0x53, | ||
| 462 | QueryPhysicalAddress = 0x54, | ||
| 463 | QueryIoMapping = 0x55, | ||
| 464 | CreateDeviceAddressSpace = 0x56, | ||
| 465 | AttachDeviceAddressSpace = 0x57, | ||
| 466 | DetachDeviceAddressSpace = 0x58, | ||
| 467 | MapDeviceAddressSpaceByForce = 0x59, | ||
| 468 | MapDeviceAddressSpaceAligned = 0x5a, | ||
| 469 | UnmapDeviceAddressSpace = 0x5c, | ||
| 470 | InvalidateProcessDataCache = 0x5d, | ||
| 471 | StoreProcessDataCache = 0x5e, | ||
| 472 | FlushProcessDataCache = 0x5f, | ||
| 473 | DebugActiveProcess = 0x60, | ||
| 474 | BreakDebugProcess = 0x61, | ||
| 475 | TerminateDebugProcess = 0x62, | ||
| 476 | GetDebugEvent = 0x63, | ||
| 477 | ContinueDebugEvent = 0x64, | ||
| 478 | GetProcessList = 0x65, | ||
| 479 | GetThreadList = 0x66, | ||
| 480 | GetDebugThreadContext = 0x67, | ||
| 481 | SetDebugThreadContext = 0x68, | ||
| 482 | QueryDebugProcessMemory = 0x69, | ||
| 483 | ReadDebugProcessMemory = 0x6a, | ||
| 484 | WriteDebugProcessMemory = 0x6b, | ||
| 485 | SetHardwareBreakPoint = 0x6c, | ||
| 486 | GetDebugThreadParam = 0x6d, | ||
| 487 | GetSystemInfo = 0x6f, | ||
| 488 | CreatePort = 0x70, | ||
| 489 | ManageNamedPort = 0x71, | ||
| 490 | ConnectToPort = 0x72, | ||
| 491 | SetProcessMemoryPermission = 0x73, | ||
| 492 | MapProcessMemory = 0x74, | ||
| 493 | UnmapProcessMemory = 0x75, | ||
| 494 | QueryProcessMemory = 0x76, | ||
| 495 | MapProcessCodeMemory = 0x77, | ||
| 496 | UnmapProcessCodeMemory = 0x78, | ||
| 497 | CreateProcess = 0x79, | ||
| 498 | StartProcess = 0x7a, | ||
| 499 | TerminateProcess = 0x7b, | ||
| 500 | GetProcessInfo = 0x7c, | ||
| 501 | CreateResourceLimit = 0x7d, | ||
| 502 | SetResourceLimitLimitValue = 0x7e, | ||
| 503 | CallSecureMonitor = 0x7f, | ||
| 504 | MapInsecureMemory = 0x90, | ||
| 505 | UnmapInsecureMemory = 0x91, | ||
| 506 | }; | ||
| 507 | // clang-format on | ||
| 508 | |||
| 509 | // Custom ABI. | ||
| 510 | Result ReplyAndReceiveLight(Core::System& system, Handle handle, uint32_t* args); | ||
| 511 | Result ReplyAndReceiveLight64From32(Core::System& system, Handle handle, uint32_t* args); | ||
| 512 | Result ReplyAndReceiveLight64(Core::System& system, Handle handle, uint32_t* args); | ||
| 513 | |||
| 514 | Result SendSyncRequestLight(Core::System& system, Handle session_handle, uint32_t* args); | ||
| 515 | Result SendSyncRequestLight64From32(Core::System& system, Handle session_handle, uint32_t* args); | ||
| 516 | Result SendSyncRequestLight64(Core::System& system, Handle session_handle, uint32_t* args); | ||
| 517 | |||
| 518 | void CallSecureMonitor(Core::System& system, lp64::SecureMonitorArguments* args); | ||
| 519 | void CallSecureMonitor64From32(Core::System& system, ilp32::SecureMonitorArguments* args); | ||
| 520 | void CallSecureMonitor64(Core::System& system, lp64::SecureMonitorArguments* args); | ||
| 521 | |||
| 522 | // Defined in svc_light_ipc.cpp. | ||
| 523 | void SvcWrap_ReplyAndReceiveLight64From32(Core::System& system); | ||
| 524 | void SvcWrap_ReplyAndReceiveLight64(Core::System& system); | ||
| 525 | |||
| 526 | void SvcWrap_SendSyncRequestLight64From32(Core::System& system); | ||
| 527 | void SvcWrap_SendSyncRequestLight64(Core::System& system); | ||
| 528 | |||
| 529 | // Defined in svc_secure_monitor_call.cpp. | ||
| 530 | void SvcWrap_CallSecureMonitor64From32(Core::System& system); | ||
| 531 | void SvcWrap_CallSecureMonitor64(Core::System& system); | ||
| 532 | |||
| 533 | // Perform a supervisor call by index. | ||
| 534 | void Call(Core::System& system, u32 imm); | ||
| 171 | 535 | ||
| 172 | } // namespace Kernel::Svc | 536 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_activity.cpp b/src/core/hle/kernel/svc/svc_activity.cpp index 8774a5c98..1dcdb7a15 100644 --- a/src/core/hle/kernel/svc/svc_activity.cpp +++ b/src/core/hle/kernel/svc/svc_activity.cpp | |||
| @@ -36,9 +36,30 @@ Result SetThreadActivity(Core::System& system, Handle thread_handle, | |||
| 36 | return ResultSuccess; | 36 | return ResultSuccess; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | Result SetThreadActivity32(Core::System& system, Handle thread_handle, | 39 | Result SetProcessActivity(Core::System& system, Handle process_handle, |
| 40 | ProcessActivity process_activity) { | ||
| 41 | UNIMPLEMENTED(); | ||
| 42 | R_THROW(ResultNotImplemented); | ||
| 43 | } | ||
| 44 | |||
| 45 | Result SetThreadActivity64(Core::System& system, Handle thread_handle, | ||
| 40 | ThreadActivity thread_activity) { | 46 | ThreadActivity thread_activity) { |
| 41 | return SetThreadActivity(system, thread_handle, thread_activity); | 47 | return SetThreadActivity(system, thread_handle, thread_activity); |
| 42 | } | 48 | } |
| 43 | 49 | ||
| 50 | Result SetProcessActivity64(Core::System& system, Handle process_handle, | ||
| 51 | ProcessActivity process_activity) { | ||
| 52 | return SetProcessActivity(system, process_handle, process_activity); | ||
| 53 | } | ||
| 54 | |||
| 55 | Result SetThreadActivity64From32(Core::System& system, Handle thread_handle, | ||
| 56 | ThreadActivity thread_activity) { | ||
| 57 | return SetThreadActivity(system, thread_handle, thread_activity); | ||
| 58 | } | ||
| 59 | |||
| 60 | Result SetProcessActivity64From32(Core::System& system, Handle process_handle, | ||
| 61 | ProcessActivity process_activity) { | ||
| 62 | return SetProcessActivity(system, process_handle, process_activity); | ||
| 63 | } | ||
| 64 | |||
| 44 | } // namespace Kernel::Svc | 65 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_address_arbiter.cpp b/src/core/hle/kernel/svc/svc_address_arbiter.cpp index 842107726..e6a5d2ae5 100644 --- a/src/core/hle/kernel/svc/svc_address_arbiter.cpp +++ b/src/core/hle/kernel/svc/svc_address_arbiter.cpp | |||
| @@ -75,12 +75,6 @@ Result WaitForAddress(Core::System& system, VAddr address, ArbitrationType arb_t | |||
| 75 | return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout); | 75 | return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | Result WaitForAddress32(Core::System& system, u32 address, ArbitrationType arb_type, s32 value, | ||
| 79 | u32 timeout_ns_low, u32 timeout_ns_high) { | ||
| 80 | const auto timeout = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); | ||
| 81 | return WaitForAddress(system, address, arb_type, value, timeout); | ||
| 82 | } | ||
| 83 | |||
| 84 | // Signals to an address (via Address Arbiter) | 78 | // Signals to an address (via Address Arbiter) |
| 85 | Result SignalToAddress(Core::System& system, VAddr address, SignalType signal_type, s32 value, | 79 | Result SignalToAddress(Core::System& system, VAddr address, SignalType signal_type, s32 value, |
| 86 | s32 count) { | 80 | s32 count) { |
| @@ -105,9 +99,24 @@ Result SignalToAddress(Core::System& system, VAddr address, SignalType signal_ty | |||
| 105 | count); | 99 | count); |
| 106 | } | 100 | } |
| 107 | 101 | ||
| 108 | Result SignalToAddress32(Core::System& system, u32 address, SignalType signal_type, s32 value, | 102 | Result WaitForAddress64(Core::System& system, VAddr address, ArbitrationType arb_type, s32 value, |
| 103 | s64 timeout_ns) { | ||
| 104 | return WaitForAddress(system, address, arb_type, value, timeout_ns); | ||
| 105 | } | ||
| 106 | |||
| 107 | Result SignalToAddress64(Core::System& system, VAddr address, SignalType signal_type, s32 value, | ||
| 109 | s32 count) { | 108 | s32 count) { |
| 110 | return SignalToAddress(system, address, signal_type, value, count); | 109 | return SignalToAddress(system, address, signal_type, value, count); |
| 111 | } | 110 | } |
| 112 | 111 | ||
| 112 | Result WaitForAddress64From32(Core::System& system, u32 address, ArbitrationType arb_type, | ||
| 113 | s32 value, s64 timeout_ns) { | ||
| 114 | return WaitForAddress(system, address, arb_type, value, timeout_ns); | ||
| 115 | } | ||
| 116 | |||
| 117 | Result SignalToAddress64From32(Core::System& system, u32 address, SignalType signal_type, s32 value, | ||
| 118 | s32 count) { | ||
| 119 | return SignalToAddress(system, address, signal_type, value, count); | ||
| 120 | } | ||
| 121 | |||
| 113 | } // namespace Kernel::Svc | 122 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_address_translation.cpp b/src/core/hle/kernel/svc/svc_address_translation.cpp index 299e22ae6..c25e144cd 100644 --- a/src/core/hle/kernel/svc/svc_address_translation.cpp +++ b/src/core/hle/kernel/svc/svc_address_translation.cpp | |||
| @@ -2,5 +2,49 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/kernel/svc.h" | 4 | #include "core/hle/kernel/svc.h" |
| 5 | #include "core/hle/kernel/svc_results.h" | ||
| 5 | 6 | ||
| 6 | namespace Kernel::Svc {} // namespace Kernel::Svc | 7 | namespace Kernel::Svc { |
| 8 | |||
| 9 | Result QueryPhysicalAddress(Core::System& system, lp64::PhysicalMemoryInfo* out_info, | ||
| 10 | uint64_t address) { | ||
| 11 | UNIMPLEMENTED(); | ||
| 12 | R_THROW(ResultNotImplemented); | ||
| 13 | } | ||
| 14 | |||
| 15 | Result QueryIoMapping(Core::System& system, uintptr_t* out_address, uintptr_t* out_size, | ||
| 16 | uint64_t physical_address, uint64_t size) { | ||
| 17 | UNIMPLEMENTED(); | ||
| 18 | R_THROW(ResultNotImplemented); | ||
| 19 | } | ||
| 20 | |||
| 21 | Result QueryPhysicalAddress64(Core::System& system, lp64::PhysicalMemoryInfo* out_info, | ||
| 22 | uint64_t address) { | ||
| 23 | R_RETURN(QueryPhysicalAddress(system, out_info, address)); | ||
| 24 | } | ||
| 25 | |||
| 26 | Result QueryIoMapping64(Core::System& system, uintptr_t* out_address, uintptr_t* out_size, | ||
| 27 | uint64_t physical_address, uint64_t size) { | ||
| 28 | R_RETURN(QueryIoMapping(system, out_address, out_size, physical_address, size)); | ||
| 29 | } | ||
| 30 | |||
| 31 | Result QueryPhysicalAddress64From32(Core::System& system, ilp32::PhysicalMemoryInfo* out_info, | ||
| 32 | uint32_t address) { | ||
| 33 | lp64::PhysicalMemoryInfo info{}; | ||
| 34 | R_TRY(QueryPhysicalAddress(system, std::addressof(info), address)); | ||
| 35 | |||
| 36 | *out_info = { | ||
| 37 | .physical_address = info.physical_address, | ||
| 38 | .virtual_address = static_cast<u32>(info.virtual_address), | ||
| 39 | .size = static_cast<u32>(info.size), | ||
| 40 | }; | ||
| 41 | R_SUCCEED(); | ||
| 42 | } | ||
| 43 | |||
| 44 | Result QueryIoMapping64From32(Core::System& system, uintptr_t* out_address, uintptr_t* out_size, | ||
| 45 | uint64_t physical_address, uint32_t size) { | ||
| 46 | R_RETURN(QueryIoMapping(system, reinterpret_cast<uintptr_t*>(out_address), | ||
| 47 | reinterpret_cast<uintptr_t*>(out_size), physical_address, size)); | ||
| 48 | } | ||
| 49 | |||
| 50 | } // namespace Kernel::Svc | ||
diff --git a/src/core/hle/kernel/svc/svc_cache.cpp b/src/core/hle/kernel/svc/svc_cache.cpp index 42167d35b..b5404760e 100644 --- a/src/core/hle/kernel/svc/svc_cache.cpp +++ b/src/core/hle/kernel/svc/svc_cache.cpp | |||
| @@ -9,7 +9,28 @@ | |||
| 9 | 9 | ||
| 10 | namespace Kernel::Svc { | 10 | namespace Kernel::Svc { |
| 11 | 11 | ||
| 12 | Result FlushProcessDataCache32(Core::System& system, Handle process_handle, u64 address, u64 size) { | 12 | void FlushEntireDataCache(Core::System& system) { |
| 13 | UNIMPLEMENTED(); | ||
| 14 | } | ||
| 15 | |||
| 16 | Result FlushDataCache(Core::System& system, VAddr address, size_t size) { | ||
| 17 | UNIMPLEMENTED(); | ||
| 18 | R_THROW(ResultNotImplemented); | ||
| 19 | } | ||
| 20 | |||
| 21 | Result InvalidateProcessDataCache(Core::System& system, Handle process_handle, uint64_t address, | ||
| 22 | uint64_t size) { | ||
| 23 | UNIMPLEMENTED(); | ||
| 24 | R_THROW(ResultNotImplemented); | ||
| 25 | } | ||
| 26 | |||
| 27 | Result StoreProcessDataCache(Core::System& system, Handle process_handle, uint64_t address, | ||
| 28 | uint64_t size) { | ||
| 29 | UNIMPLEMENTED(); | ||
| 30 | R_THROW(ResultNotImplemented); | ||
| 31 | } | ||
| 32 | |||
| 33 | Result FlushProcessDataCache(Core::System& system, Handle process_handle, u64 address, u64 size) { | ||
| 13 | // Validate address/size. | 34 | // Validate address/size. |
| 14 | R_UNLESS(size > 0, ResultInvalidSize); | 35 | R_UNLESS(size > 0, ResultInvalidSize); |
| 15 | R_UNLESS(address == static_cast<uintptr_t>(address), ResultInvalidCurrentMemory); | 36 | R_UNLESS(address == static_cast<uintptr_t>(address), ResultInvalidCurrentMemory); |
| @@ -28,4 +49,50 @@ Result FlushProcessDataCache32(Core::System& system, Handle process_handle, u64 | |||
| 28 | R_RETURN(system.Memory().FlushDataCache(*process, address, size)); | 49 | R_RETURN(system.Memory().FlushDataCache(*process, address, size)); |
| 29 | } | 50 | } |
| 30 | 51 | ||
| 52 | void FlushEntireDataCache64(Core::System& system) { | ||
| 53 | FlushEntireDataCache(system); | ||
| 54 | } | ||
| 55 | |||
| 56 | Result FlushDataCache64(Core::System& system, VAddr address, size_t size) { | ||
| 57 | R_RETURN(FlushDataCache(system, address, size)); | ||
| 58 | } | ||
| 59 | |||
| 60 | Result InvalidateProcessDataCache64(Core::System& system, Handle process_handle, uint64_t address, | ||
| 61 | uint64_t size) { | ||
| 62 | R_RETURN(InvalidateProcessDataCache(system, process_handle, address, size)); | ||
| 63 | } | ||
| 64 | |||
| 65 | Result StoreProcessDataCache64(Core::System& system, Handle process_handle, uint64_t address, | ||
| 66 | uint64_t size) { | ||
| 67 | R_RETURN(StoreProcessDataCache(system, process_handle, address, size)); | ||
| 68 | } | ||
| 69 | |||
| 70 | Result FlushProcessDataCache64(Core::System& system, Handle process_handle, uint64_t address, | ||
| 71 | uint64_t size) { | ||
| 72 | R_RETURN(FlushProcessDataCache(system, process_handle, address, size)); | ||
| 73 | } | ||
| 74 | |||
| 75 | void FlushEntireDataCache64From32(Core::System& system) { | ||
| 76 | return FlushEntireDataCache(system); | ||
| 77 | } | ||
| 78 | |||
| 79 | Result FlushDataCache64From32(Core::System& system, uint32_t address, uint32_t size) { | ||
| 80 | R_RETURN(FlushDataCache(system, address, size)); | ||
| 81 | } | ||
| 82 | |||
| 83 | Result InvalidateProcessDataCache64From32(Core::System& system, Handle process_handle, | ||
| 84 | uint64_t address, uint64_t size) { | ||
| 85 | R_RETURN(InvalidateProcessDataCache(system, process_handle, address, size)); | ||
| 86 | } | ||
| 87 | |||
| 88 | Result StoreProcessDataCache64From32(Core::System& system, Handle process_handle, uint64_t address, | ||
| 89 | uint64_t size) { | ||
| 90 | R_RETURN(StoreProcessDataCache(system, process_handle, address, size)); | ||
| 91 | } | ||
| 92 | |||
| 93 | Result FlushProcessDataCache64From32(Core::System& system, Handle process_handle, uint64_t address, | ||
| 94 | uint64_t size) { | ||
| 95 | R_RETURN(FlushProcessDataCache(system, process_handle, address, size)); | ||
| 96 | } | ||
| 97 | |||
| 31 | } // namespace Kernel::Svc | 98 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_code_memory.cpp b/src/core/hle/kernel/svc/svc_code_memory.cpp index 4cb21e101..ec256b757 100644 --- a/src/core/hle/kernel/svc/svc_code_memory.cpp +++ b/src/core/hle/kernel/svc/svc_code_memory.cpp | |||
| @@ -63,12 +63,9 @@ Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t | |||
| 63 | return ResultSuccess; | 63 | return ResultSuccess; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | Result CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size) { | 66 | Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, |
| 67 | return CreateCodeMemory(system, out, address, size); | 67 | CodeMemoryOperation operation, VAddr address, size_t size, |
| 68 | } | 68 | MemoryPermission perm) { |
| 69 | |||
| 70 | Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation, | ||
| 71 | VAddr address, size_t size, MemoryPermission perm) { | ||
| 72 | 69 | ||
| 73 | LOG_TRACE(Kernel_SVC, | 70 | LOG_TRACE(Kernel_SVC, |
| 74 | "called, code_memory_handle=0x{:X}, operation=0x{:X}, address=0x{:X}, size=0x{:X}, " | 71 | "called, code_memory_handle=0x{:X}, operation=0x{:X}, address=0x{:X}, size=0x{:X}, " |
| @@ -90,7 +87,7 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 op | |||
| 90 | // This enables homebrew usage of these SVCs for JIT. | 87 | // This enables homebrew usage of these SVCs for JIT. |
| 91 | 88 | ||
| 92 | // Perform the operation. | 89 | // Perform the operation. |
| 93 | switch (static_cast<CodeMemoryOperation>(operation)) { | 90 | switch (operation) { |
| 94 | case CodeMemoryOperation::Map: { | 91 | case CodeMemoryOperation::Map: { |
| 95 | // Check that the region is in range. | 92 | // Check that the region is in range. |
| 96 | R_UNLESS( | 93 | R_UNLESS( |
| @@ -146,9 +143,26 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 op | |||
| 146 | return ResultSuccess; | 143 | return ResultSuccess; |
| 147 | } | 144 | } |
| 148 | 145 | ||
| 149 | Result ControlCodeMemory32(Core::System& system, Handle code_memory_handle, u32 operation, | 146 | Result CreateCodeMemory64(Core::System& system, Handle* out_handle, uint64_t address, |
| 150 | u64 address, u64 size, MemoryPermission perm) { | 147 | uint64_t size) { |
| 151 | return ControlCodeMemory(system, code_memory_handle, operation, address, size, perm); | 148 | R_RETURN(CreateCodeMemory(system, out_handle, address, size)); |
| 149 | } | ||
| 150 | |||
| 151 | Result ControlCodeMemory64(Core::System& system, Handle code_memory_handle, | ||
| 152 | CodeMemoryOperation operation, uint64_t address, uint64_t size, | ||
| 153 | MemoryPermission perm) { | ||
| 154 | R_RETURN(ControlCodeMemory(system, code_memory_handle, operation, address, size, perm)); | ||
| 155 | } | ||
| 156 | |||
| 157 | Result CreateCodeMemory64From32(Core::System& system, Handle* out_handle, uint32_t address, | ||
| 158 | uint32_t size) { | ||
| 159 | R_RETURN(CreateCodeMemory(system, out_handle, address, size)); | ||
| 160 | } | ||
| 161 | |||
| 162 | Result ControlCodeMemory64From32(Core::System& system, Handle code_memory_handle, | ||
| 163 | CodeMemoryOperation operation, uint64_t address, uint64_t size, | ||
| 164 | MemoryPermission perm) { | ||
| 165 | R_RETURN(ControlCodeMemory(system, code_memory_handle, operation, address, size, perm)); | ||
| 152 | } | 166 | } |
| 153 | 167 | ||
| 154 | } // namespace Kernel::Svc | 168 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_condition_variable.cpp b/src/core/hle/kernel/svc/svc_condition_variable.cpp index d6cfc87c5..b59a33e68 100644 --- a/src/core/hle/kernel/svc/svc_condition_variable.cpp +++ b/src/core/hle/kernel/svc/svc_condition_variable.cpp | |||
| @@ -47,12 +47,6 @@ Result WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_ke | |||
| 47 | address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout); | 47 | address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | Result WaitProcessWideKeyAtomic32(Core::System& system, u32 address, u32 cv_key, u32 tag, | ||
| 51 | u32 timeout_ns_low, u32 timeout_ns_high) { | ||
| 52 | const auto timeout_ns = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); | ||
| 53 | return WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns); | ||
| 54 | } | ||
| 55 | |||
| 56 | /// Signal process wide key | 50 | /// Signal process wide key |
| 57 | void SignalProcessWideKey(Core::System& system, VAddr cv_key, s32 count) { | 51 | void SignalProcessWideKey(Core::System& system, VAddr cv_key, s32 count) { |
| 58 | LOG_TRACE(Kernel_SVC, "called, cv_key=0x{:X}, count=0x{:08X}", cv_key, count); | 52 | LOG_TRACE(Kernel_SVC, "called, cv_key=0x{:X}, count=0x{:08X}", cv_key, count); |
| @@ -62,7 +56,21 @@ void SignalProcessWideKey(Core::System& system, VAddr cv_key, s32 count) { | |||
| 62 | Common::AlignDown(cv_key, sizeof(u32)), count); | 56 | Common::AlignDown(cv_key, sizeof(u32)), count); |
| 63 | } | 57 | } |
| 64 | 58 | ||
| 65 | void SignalProcessWideKey32(Core::System& system, u32 cv_key, s32 count) { | 59 | Result WaitProcessWideKeyAtomic64(Core::System& system, uint64_t address, uint64_t cv_key, |
| 60 | uint32_t tag, int64_t timeout_ns) { | ||
| 61 | R_RETURN(WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns)); | ||
| 62 | } | ||
| 63 | |||
| 64 | void SignalProcessWideKey64(Core::System& system, uint64_t cv_key, int32_t count) { | ||
| 65 | SignalProcessWideKey(system, cv_key, count); | ||
| 66 | } | ||
| 67 | |||
| 68 | Result WaitProcessWideKeyAtomic64From32(Core::System& system, uint32_t address, uint32_t cv_key, | ||
| 69 | uint32_t tag, int64_t timeout_ns) { | ||
| 70 | R_RETURN(WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns)); | ||
| 71 | } | ||
| 72 | |||
| 73 | void SignalProcessWideKey64From32(Core::System& system, uint32_t cv_key, int32_t count) { | ||
| 66 | SignalProcessWideKey(system, cv_key, count); | 74 | SignalProcessWideKey(system, cv_key, count); |
| 67 | } | 75 | } |
| 68 | 76 | ||
diff --git a/src/core/hle/kernel/svc/svc_debug.cpp b/src/core/hle/kernel/svc/svc_debug.cpp index 299e22ae6..a14050fa7 100644 --- a/src/core/hle/kernel/svc/svc_debug.cpp +++ b/src/core/hle/kernel/svc/svc_debug.cpp | |||
| @@ -2,5 +2,193 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/kernel/svc.h" | 4 | #include "core/hle/kernel/svc.h" |
| 5 | #include "core/hle/kernel/svc_results.h" | ||
| 5 | 6 | ||
| 6 | namespace Kernel::Svc {} // namespace Kernel::Svc | 7 | namespace Kernel::Svc { |
| 8 | |||
| 9 | Result DebugActiveProcess(Core::System& system, Handle* out_handle, uint64_t process_id) { | ||
| 10 | UNIMPLEMENTED(); | ||
| 11 | R_THROW(ResultNotImplemented); | ||
| 12 | } | ||
| 13 | |||
| 14 | Result BreakDebugProcess(Core::System& system, Handle debug_handle) { | ||
| 15 | UNIMPLEMENTED(); | ||
| 16 | R_THROW(ResultNotImplemented); | ||
| 17 | } | ||
| 18 | |||
| 19 | Result TerminateDebugProcess(Core::System& system, Handle debug_handle) { | ||
| 20 | UNIMPLEMENTED(); | ||
| 21 | R_THROW(ResultNotImplemented); | ||
| 22 | } | ||
| 23 | |||
| 24 | Result GetDebugEvent(Core::System& system, uint64_t out_info, Handle debug_handle) { | ||
| 25 | UNIMPLEMENTED(); | ||
| 26 | R_THROW(ResultNotImplemented); | ||
| 27 | } | ||
| 28 | |||
| 29 | Result ContinueDebugEvent(Core::System& system, Handle debug_handle, uint32_t flags, | ||
| 30 | uint64_t user_thread_ids, int32_t num_thread_ids) { | ||
| 31 | UNIMPLEMENTED(); | ||
| 32 | R_THROW(ResultNotImplemented); | ||
| 33 | } | ||
| 34 | |||
| 35 | Result GetDebugThreadContext(Core::System& system, uint64_t out_context, Handle debug_handle, | ||
| 36 | uint64_t thread_id, uint32_t context_flags) { | ||
| 37 | UNIMPLEMENTED(); | ||
| 38 | R_THROW(ResultNotImplemented); | ||
| 39 | } | ||
| 40 | |||
| 41 | Result SetDebugThreadContext(Core::System& system, Handle debug_handle, uint64_t thread_id, | ||
| 42 | uint64_t user_context, uint32_t context_flags) { | ||
| 43 | UNIMPLEMENTED(); | ||
| 44 | R_THROW(ResultNotImplemented); | ||
| 45 | } | ||
| 46 | |||
| 47 | Result QueryDebugProcessMemory(Core::System& system, uint64_t out_memory_info, | ||
| 48 | PageInfo* out_page_info, Handle debug_handle, uintptr_t address) { | ||
| 49 | UNIMPLEMENTED(); | ||
| 50 | R_THROW(ResultNotImplemented); | ||
| 51 | } | ||
| 52 | |||
| 53 | Result ReadDebugProcessMemory(Core::System& system, uintptr_t buffer, Handle debug_handle, | ||
| 54 | uintptr_t address, size_t size) { | ||
| 55 | UNIMPLEMENTED(); | ||
| 56 | R_THROW(ResultNotImplemented); | ||
| 57 | } | ||
| 58 | |||
| 59 | Result WriteDebugProcessMemory(Core::System& system, Handle debug_handle, uintptr_t buffer, | ||
| 60 | uintptr_t address, size_t size) { | ||
| 61 | UNIMPLEMENTED(); | ||
| 62 | R_THROW(ResultNotImplemented); | ||
| 63 | } | ||
| 64 | |||
| 65 | Result SetHardwareBreakPoint(Core::System& system, HardwareBreakPointRegisterName name, | ||
| 66 | uint64_t flags, uint64_t value) { | ||
| 67 | UNIMPLEMENTED(); | ||
| 68 | R_THROW(ResultNotImplemented); | ||
| 69 | } | ||
| 70 | |||
| 71 | Result GetDebugThreadParam(Core::System& system, uint64_t* out_64, uint32_t* out_32, | ||
| 72 | Handle debug_handle, uint64_t thread_id, DebugThreadParam param) { | ||
| 73 | UNIMPLEMENTED(); | ||
| 74 | R_THROW(ResultNotImplemented); | ||
| 75 | } | ||
| 76 | |||
| 77 | Result DebugActiveProcess64(Core::System& system, Handle* out_handle, uint64_t process_id) { | ||
| 78 | R_RETURN(DebugActiveProcess(system, out_handle, process_id)); | ||
| 79 | } | ||
| 80 | |||
| 81 | Result BreakDebugProcess64(Core::System& system, Handle debug_handle) { | ||
| 82 | R_RETURN(BreakDebugProcess(system, debug_handle)); | ||
| 83 | } | ||
| 84 | |||
| 85 | Result TerminateDebugProcess64(Core::System& system, Handle debug_handle) { | ||
| 86 | R_RETURN(TerminateDebugProcess(system, debug_handle)); | ||
| 87 | } | ||
| 88 | |||
| 89 | Result GetDebugEvent64(Core::System& system, uint64_t out_info, Handle debug_handle) { | ||
| 90 | R_RETURN(GetDebugEvent(system, out_info, debug_handle)); | ||
| 91 | } | ||
| 92 | |||
| 93 | Result ContinueDebugEvent64(Core::System& system, Handle debug_handle, uint32_t flags, | ||
| 94 | uint64_t thread_ids, int32_t num_thread_ids) { | ||
| 95 | R_RETURN(ContinueDebugEvent(system, debug_handle, flags, thread_ids, num_thread_ids)); | ||
| 96 | } | ||
| 97 | |||
| 98 | Result GetDebugThreadContext64(Core::System& system, uint64_t out_context, Handle debug_handle, | ||
| 99 | uint64_t thread_id, uint32_t context_flags) { | ||
| 100 | R_RETURN(GetDebugThreadContext(system, out_context, debug_handle, thread_id, context_flags)); | ||
| 101 | } | ||
| 102 | |||
| 103 | Result SetDebugThreadContext64(Core::System& system, Handle debug_handle, uint64_t thread_id, | ||
| 104 | uint64_t context, uint32_t context_flags) { | ||
| 105 | R_RETURN(SetDebugThreadContext(system, debug_handle, thread_id, context, context_flags)); | ||
| 106 | } | ||
| 107 | |||
| 108 | Result QueryDebugProcessMemory64(Core::System& system, uint64_t out_memory_info, | ||
| 109 | PageInfo* out_page_info, Handle debug_handle, uint64_t address) { | ||
| 110 | R_RETURN( | ||
| 111 | QueryDebugProcessMemory(system, out_memory_info, out_page_info, debug_handle, address)); | ||
| 112 | } | ||
| 113 | |||
| 114 | Result ReadDebugProcessMemory64(Core::System& system, uint64_t buffer, Handle debug_handle, | ||
| 115 | uint64_t address, uint64_t size) { | ||
| 116 | R_RETURN(ReadDebugProcessMemory(system, buffer, debug_handle, address, size)); | ||
| 117 | } | ||
| 118 | |||
| 119 | Result WriteDebugProcessMemory64(Core::System& system, Handle debug_handle, uint64_t buffer, | ||
| 120 | uint64_t address, uint64_t size) { | ||
| 121 | R_RETURN(WriteDebugProcessMemory(system, debug_handle, buffer, address, size)); | ||
| 122 | } | ||
| 123 | |||
| 124 | Result SetHardwareBreakPoint64(Core::System& system, HardwareBreakPointRegisterName name, | ||
| 125 | uint64_t flags, uint64_t value) { | ||
| 126 | R_RETURN(SetHardwareBreakPoint(system, name, flags, value)); | ||
| 127 | } | ||
| 128 | |||
| 129 | Result GetDebugThreadParam64(Core::System& system, uint64_t* out_64, uint32_t* out_32, | ||
| 130 | Handle debug_handle, uint64_t thread_id, DebugThreadParam param) { | ||
| 131 | R_RETURN(GetDebugThreadParam(system, out_64, out_32, debug_handle, thread_id, param)); | ||
| 132 | } | ||
| 133 | |||
| 134 | Result DebugActiveProcess64From32(Core::System& system, Handle* out_handle, uint64_t process_id) { | ||
| 135 | R_RETURN(DebugActiveProcess(system, out_handle, process_id)); | ||
| 136 | } | ||
| 137 | |||
| 138 | Result BreakDebugProcess64From32(Core::System& system, Handle debug_handle) { | ||
| 139 | R_RETURN(BreakDebugProcess(system, debug_handle)); | ||
| 140 | } | ||
| 141 | |||
| 142 | Result TerminateDebugProcess64From32(Core::System& system, Handle debug_handle) { | ||
| 143 | R_RETURN(TerminateDebugProcess(system, debug_handle)); | ||
| 144 | } | ||
| 145 | |||
| 146 | Result GetDebugEvent64From32(Core::System& system, uint32_t out_info, Handle debug_handle) { | ||
| 147 | R_RETURN(GetDebugEvent(system, out_info, debug_handle)); | ||
| 148 | } | ||
| 149 | |||
| 150 | Result ContinueDebugEvent64From32(Core::System& system, Handle debug_handle, uint32_t flags, | ||
| 151 | uint32_t thread_ids, int32_t num_thread_ids) { | ||
| 152 | R_RETURN(ContinueDebugEvent(system, debug_handle, flags, thread_ids, num_thread_ids)); | ||
| 153 | } | ||
| 154 | |||
| 155 | Result GetDebugThreadContext64From32(Core::System& system, uint32_t out_context, | ||
| 156 | Handle debug_handle, uint64_t thread_id, | ||
| 157 | uint32_t context_flags) { | ||
| 158 | R_RETURN(GetDebugThreadContext(system, out_context, debug_handle, thread_id, context_flags)); | ||
| 159 | } | ||
| 160 | |||
| 161 | Result SetDebugThreadContext64From32(Core::System& system, Handle debug_handle, uint64_t thread_id, | ||
| 162 | uint32_t context, uint32_t context_flags) { | ||
| 163 | R_RETURN(SetDebugThreadContext(system, debug_handle, thread_id, context, context_flags)); | ||
| 164 | } | ||
| 165 | |||
| 166 | Result QueryDebugProcessMemory64From32(Core::System& system, uint32_t out_memory_info, | ||
| 167 | PageInfo* out_page_info, Handle debug_handle, | ||
| 168 | uint32_t address) { | ||
| 169 | R_RETURN( | ||
| 170 | QueryDebugProcessMemory(system, out_memory_info, out_page_info, debug_handle, address)); | ||
| 171 | } | ||
| 172 | |||
| 173 | Result ReadDebugProcessMemory64From32(Core::System& system, uint32_t buffer, Handle debug_handle, | ||
| 174 | uint32_t address, uint32_t size) { | ||
| 175 | R_RETURN(ReadDebugProcessMemory(system, buffer, debug_handle, address, size)); | ||
| 176 | } | ||
| 177 | |||
| 178 | Result WriteDebugProcessMemory64From32(Core::System& system, Handle debug_handle, uint32_t buffer, | ||
| 179 | uint32_t address, uint32_t size) { | ||
| 180 | R_RETURN(WriteDebugProcessMemory(system, debug_handle, buffer, address, size)); | ||
| 181 | } | ||
| 182 | |||
| 183 | Result SetHardwareBreakPoint64From32(Core::System& system, HardwareBreakPointRegisterName name, | ||
| 184 | uint64_t flags, uint64_t value) { | ||
| 185 | R_RETURN(SetHardwareBreakPoint(system, name, flags, value)); | ||
| 186 | } | ||
| 187 | |||
| 188 | Result GetDebugThreadParam64From32(Core::System& system, uint64_t* out_64, uint32_t* out_32, | ||
| 189 | Handle debug_handle, uint64_t thread_id, | ||
| 190 | DebugThreadParam param) { | ||
| 191 | R_RETURN(GetDebugThreadParam(system, out_64, out_32, debug_handle, thread_id, param)); | ||
| 192 | } | ||
| 193 | |||
| 194 | } // namespace Kernel::Svc | ||
diff --git a/src/core/hle/kernel/svc/svc_debug_string.cpp b/src/core/hle/kernel/svc/svc_debug_string.cpp index 486e62cc4..d4bf062d1 100644 --- a/src/core/hle/kernel/svc/svc_debug_string.cpp +++ b/src/core/hle/kernel/svc/svc_debug_string.cpp | |||
| @@ -8,18 +8,22 @@ | |||
| 8 | namespace Kernel::Svc { | 8 | namespace Kernel::Svc { |
| 9 | 9 | ||
| 10 | /// Used to output a message on a debug hardware unit - does nothing on a retail unit | 10 | /// Used to output a message on a debug hardware unit - does nothing on a retail unit |
| 11 | void OutputDebugString(Core::System& system, VAddr address, u64 len) { | 11 | Result OutputDebugString(Core::System& system, VAddr address, u64 len) { |
| 12 | if (len == 0) { | 12 | R_SUCCEED_IF(len == 0); |
| 13 | return; | ||
| 14 | } | ||
| 15 | 13 | ||
| 16 | std::string str(len, '\0'); | 14 | std::string str(len, '\0'); |
| 17 | system.Memory().ReadBlock(address, str.data(), str.size()); | 15 | system.Memory().ReadBlock(address, str.data(), str.size()); |
| 18 | LOG_DEBUG(Debug_Emulated, "{}", str); | 16 | LOG_DEBUG(Debug_Emulated, "{}", str); |
| 17 | |||
| 18 | R_SUCCEED(); | ||
| 19 | } | ||
| 20 | |||
| 21 | Result OutputDebugString64(Core::System& system, uint64_t debug_str, uint64_t len) { | ||
| 22 | R_RETURN(OutputDebugString(system, debug_str, len)); | ||
| 19 | } | 23 | } |
| 20 | 24 | ||
| 21 | void OutputDebugString32(Core::System& system, u32 address, u32 len) { | 25 | Result OutputDebugString64From32(Core::System& system, uint32_t debug_str, uint32_t len) { |
| 22 | OutputDebugString(system, address, len); | 26 | R_RETURN(OutputDebugString(system, debug_str, len)); |
| 23 | } | 27 | } |
| 24 | 28 | ||
| 25 | } // namespace Kernel::Svc | 29 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_device_address_space.cpp b/src/core/hle/kernel/svc/svc_device_address_space.cpp index 299e22ae6..cdc453c35 100644 --- a/src/core/hle/kernel/svc/svc_device_address_space.cpp +++ b/src/core/hle/kernel/svc/svc_device_address_space.cpp | |||
| @@ -1,6 +1,253 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "common/alignment.h" | ||
| 5 | #include "common/scope_exit.h" | ||
| 6 | #include "core/core.h" | ||
| 7 | #include "core/hle/kernel/k_device_address_space.h" | ||
| 8 | #include "core/hle/kernel/k_process.h" | ||
| 4 | #include "core/hle/kernel/svc.h" | 9 | #include "core/hle/kernel/svc.h" |
| 5 | 10 | ||
| 6 | namespace Kernel::Svc {} // namespace Kernel::Svc | 11 | namespace Kernel::Svc { |
| 12 | |||
| 13 | constexpr inline u64 DeviceAddressSpaceAlignMask = (1ULL << 22) - 1; | ||
| 14 | |||
| 15 | constexpr bool IsProcessAndDeviceAligned(uint64_t process_address, uint64_t device_address) { | ||
| 16 | return (process_address & DeviceAddressSpaceAlignMask) == | ||
| 17 | (device_address & DeviceAddressSpaceAlignMask); | ||
| 18 | } | ||
| 19 | |||
| 20 | Result CreateDeviceAddressSpace(Core::System& system, Handle* out, uint64_t das_address, | ||
| 21 | uint64_t das_size) { | ||
| 22 | // Validate input. | ||
| 23 | R_UNLESS(Common::IsAligned(das_address, PageSize), ResultInvalidMemoryRegion); | ||
| 24 | R_UNLESS(Common::IsAligned(das_size, PageSize), ResultInvalidMemoryRegion); | ||
| 25 | R_UNLESS(das_size > 0, ResultInvalidMemoryRegion); | ||
| 26 | R_UNLESS((das_address < das_address + das_size), ResultInvalidMemoryRegion); | ||
| 27 | |||
| 28 | // Create the device address space. | ||
| 29 | KDeviceAddressSpace* das = KDeviceAddressSpace::Create(system.Kernel()); | ||
| 30 | R_UNLESS(das != nullptr, ResultOutOfResource); | ||
| 31 | SCOPE_EXIT({ das->Close(); }); | ||
| 32 | |||
| 33 | // Initialize the device address space. | ||
| 34 | R_TRY(das->Initialize(das_address, das_size)); | ||
| 35 | |||
| 36 | // Register the device address space. | ||
| 37 | KDeviceAddressSpace::Register(system.Kernel(), das); | ||
| 38 | |||
| 39 | // Add to the handle table. | ||
| 40 | R_TRY(system.CurrentProcess()->GetHandleTable().Add(out, das)); | ||
| 41 | |||
| 42 | R_SUCCEED(); | ||
| 43 | } | ||
| 44 | |||
| 45 | Result AttachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) { | ||
| 46 | // Get the device address space. | ||
| 47 | KScopedAutoObject das = | ||
| 48 | system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle); | ||
| 49 | R_UNLESS(das.IsNotNull(), ResultInvalidHandle); | ||
| 50 | |||
| 51 | // Attach. | ||
| 52 | R_RETURN(das->Attach(device_name)); | ||
| 53 | } | ||
| 54 | |||
| 55 | Result DetachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) { | ||
| 56 | // Get the device address space. | ||
| 57 | KScopedAutoObject das = | ||
| 58 | system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle); | ||
| 59 | R_UNLESS(das.IsNotNull(), ResultInvalidHandle); | ||
| 60 | |||
| 61 | // Detach. | ||
| 62 | R_RETURN(das->Detach(device_name)); | ||
| 63 | } | ||
| 64 | |||
| 65 | constexpr bool IsValidDeviceMemoryPermission(MemoryPermission device_perm) { | ||
| 66 | switch (device_perm) { | ||
| 67 | case MemoryPermission::Read: | ||
| 68 | case MemoryPermission::Write: | ||
| 69 | case MemoryPermission::ReadWrite: | ||
| 70 | return true; | ||
| 71 | default: | ||
| 72 | return false; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 76 | Result MapDeviceAddressSpaceByForce(Core::System& system, Handle das_handle, Handle process_handle, | ||
| 77 | uint64_t process_address, size_t size, uint64_t device_address, | ||
| 78 | u32 option) { | ||
| 79 | // Decode the option. | ||
| 80 | const MapDeviceAddressSpaceOption option_pack{option}; | ||
| 81 | const auto device_perm = option_pack.permission; | ||
| 82 | const auto reserved = option_pack.reserved; | ||
| 83 | |||
| 84 | // Validate input. | ||
| 85 | R_UNLESS(Common::IsAligned(process_address, PageSize), ResultInvalidAddress); | ||
| 86 | R_UNLESS(Common::IsAligned(device_address, PageSize), ResultInvalidAddress); | ||
| 87 | R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize); | ||
| 88 | R_UNLESS(size > 0, ResultInvalidSize); | ||
| 89 | R_UNLESS((process_address < process_address + size), ResultInvalidCurrentMemory); | ||
| 90 | R_UNLESS((device_address < device_address + size), ResultInvalidMemoryRegion); | ||
| 91 | R_UNLESS((process_address == static_cast<uintptr_t>(process_address)), | ||
| 92 | ResultInvalidCurrentMemory); | ||
| 93 | R_UNLESS(IsValidDeviceMemoryPermission(device_perm), ResultInvalidNewMemoryPermission); | ||
| 94 | R_UNLESS(reserved == 0, ResultInvalidEnumValue); | ||
| 95 | |||
| 96 | // Get the device address space. | ||
| 97 | KScopedAutoObject das = | ||
| 98 | system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle); | ||
| 99 | R_UNLESS(das.IsNotNull(), ResultInvalidHandle); | ||
| 100 | |||
| 101 | // Get the process. | ||
| 102 | KScopedAutoObject process = | ||
| 103 | system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle); | ||
| 104 | R_UNLESS(process.IsNotNull(), ResultInvalidHandle); | ||
| 105 | |||
| 106 | // Validate that the process address is within range. | ||
| 107 | auto& page_table = process->PageTable(); | ||
| 108 | R_UNLESS(page_table.Contains(process_address, size), ResultInvalidCurrentMemory); | ||
| 109 | |||
| 110 | // Map. | ||
| 111 | R_RETURN( | ||
| 112 | das->MapByForce(std::addressof(page_table), process_address, size, device_address, option)); | ||
| 113 | } | ||
| 114 | |||
| 115 | Result MapDeviceAddressSpaceAligned(Core::System& system, Handle das_handle, Handle process_handle, | ||
| 116 | uint64_t process_address, size_t size, uint64_t device_address, | ||
| 117 | u32 option) { | ||
| 118 | // Decode the option. | ||
| 119 | const MapDeviceAddressSpaceOption option_pack{option}; | ||
| 120 | const auto device_perm = option_pack.permission; | ||
| 121 | const auto reserved = option_pack.reserved; | ||
| 122 | |||
| 123 | // Validate input. | ||
| 124 | R_UNLESS(Common::IsAligned(process_address, PageSize), ResultInvalidAddress); | ||
| 125 | R_UNLESS(Common::IsAligned(device_address, PageSize), ResultInvalidAddress); | ||
| 126 | R_UNLESS(IsProcessAndDeviceAligned(process_address, device_address), ResultInvalidAddress); | ||
| 127 | R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize); | ||
| 128 | R_UNLESS(size > 0, ResultInvalidSize); | ||
| 129 | R_UNLESS((process_address < process_address + size), ResultInvalidCurrentMemory); | ||
| 130 | R_UNLESS((device_address < device_address + size), ResultInvalidMemoryRegion); | ||
| 131 | R_UNLESS((process_address == static_cast<uintptr_t>(process_address)), | ||
| 132 | ResultInvalidCurrentMemory); | ||
| 133 | R_UNLESS(IsValidDeviceMemoryPermission(device_perm), ResultInvalidNewMemoryPermission); | ||
| 134 | R_UNLESS(reserved == 0, ResultInvalidEnumValue); | ||
| 135 | |||
| 136 | // Get the device address space. | ||
| 137 | KScopedAutoObject das = | ||
| 138 | system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle); | ||
| 139 | R_UNLESS(das.IsNotNull(), ResultInvalidHandle); | ||
| 140 | |||
| 141 | // Get the process. | ||
| 142 | KScopedAutoObject process = | ||
| 143 | system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle); | ||
| 144 | R_UNLESS(process.IsNotNull(), ResultInvalidHandle); | ||
| 145 | |||
| 146 | // Validate that the process address is within range. | ||
| 147 | auto& page_table = process->PageTable(); | ||
| 148 | R_UNLESS(page_table.Contains(process_address, size), ResultInvalidCurrentMemory); | ||
| 149 | |||
| 150 | // Map. | ||
| 151 | R_RETURN( | ||
| 152 | das->MapAligned(std::addressof(page_table), process_address, size, device_address, option)); | ||
| 153 | } | ||
| 154 | |||
| 155 | Result UnmapDeviceAddressSpace(Core::System& system, Handle das_handle, Handle process_handle, | ||
| 156 | uint64_t process_address, size_t size, uint64_t device_address) { | ||
| 157 | // Validate input. | ||
| 158 | R_UNLESS(Common::IsAligned(process_address, PageSize), ResultInvalidAddress); | ||
| 159 | R_UNLESS(Common::IsAligned(device_address, PageSize), ResultInvalidAddress); | ||
| 160 | R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize); | ||
| 161 | R_UNLESS(size > 0, ResultInvalidSize); | ||
| 162 | R_UNLESS((process_address < process_address + size), ResultInvalidCurrentMemory); | ||
| 163 | R_UNLESS((device_address < device_address + size), ResultInvalidMemoryRegion); | ||
| 164 | R_UNLESS((process_address == static_cast<uintptr_t>(process_address)), | ||
| 165 | ResultInvalidCurrentMemory); | ||
| 166 | |||
| 167 | // Get the device address space. | ||
| 168 | KScopedAutoObject das = | ||
| 169 | system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle); | ||
| 170 | R_UNLESS(das.IsNotNull(), ResultInvalidHandle); | ||
| 171 | |||
| 172 | // Get the process. | ||
| 173 | KScopedAutoObject process = | ||
| 174 | system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle); | ||
| 175 | R_UNLESS(process.IsNotNull(), ResultInvalidHandle); | ||
| 176 | |||
| 177 | // Validate that the process address is within range. | ||
| 178 | auto& page_table = process->PageTable(); | ||
| 179 | R_UNLESS(page_table.Contains(process_address, size), ResultInvalidCurrentMemory); | ||
| 180 | |||
| 181 | R_RETURN(das->Unmap(std::addressof(page_table), process_address, size, device_address)); | ||
| 182 | } | ||
| 183 | |||
| 184 | Result CreateDeviceAddressSpace64(Core::System& system, Handle* out_handle, uint64_t das_address, | ||
| 185 | uint64_t das_size) { | ||
| 186 | R_RETURN(CreateDeviceAddressSpace(system, out_handle, das_address, das_size)); | ||
| 187 | } | ||
| 188 | |||
| 189 | Result AttachDeviceAddressSpace64(Core::System& system, DeviceName device_name, Handle das_handle) { | ||
| 190 | R_RETURN(AttachDeviceAddressSpace(system, device_name, das_handle)); | ||
| 191 | } | ||
| 192 | |||
| 193 | Result DetachDeviceAddressSpace64(Core::System& system, DeviceName device_name, Handle das_handle) { | ||
| 194 | R_RETURN(DetachDeviceAddressSpace(system, device_name, das_handle)); | ||
| 195 | } | ||
| 196 | |||
| 197 | Result MapDeviceAddressSpaceByForce64(Core::System& system, Handle das_handle, | ||
| 198 | Handle process_handle, uint64_t process_address, | ||
| 199 | uint64_t size, uint64_t device_address, u32 option) { | ||
| 200 | R_RETURN(MapDeviceAddressSpaceByForce(system, das_handle, process_handle, process_address, size, | ||
| 201 | device_address, option)); | ||
| 202 | } | ||
| 203 | |||
| 204 | Result MapDeviceAddressSpaceAligned64(Core::System& system, Handle das_handle, | ||
| 205 | Handle process_handle, uint64_t process_address, | ||
| 206 | uint64_t size, uint64_t device_address, u32 option) { | ||
| 207 | R_RETURN(MapDeviceAddressSpaceAligned(system, das_handle, process_handle, process_address, size, | ||
| 208 | device_address, option)); | ||
| 209 | } | ||
| 210 | |||
| 211 | Result UnmapDeviceAddressSpace64(Core::System& system, Handle das_handle, Handle process_handle, | ||
| 212 | uint64_t process_address, uint64_t size, uint64_t device_address) { | ||
| 213 | R_RETURN(UnmapDeviceAddressSpace(system, das_handle, process_handle, process_address, size, | ||
| 214 | device_address)); | ||
| 215 | } | ||
| 216 | |||
| 217 | Result CreateDeviceAddressSpace64From32(Core::System& system, Handle* out_handle, | ||
| 218 | uint64_t das_address, uint64_t das_size) { | ||
| 219 | R_RETURN(CreateDeviceAddressSpace(system, out_handle, das_address, das_size)); | ||
| 220 | } | ||
| 221 | |||
| 222 | Result AttachDeviceAddressSpace64From32(Core::System& system, DeviceName device_name, | ||
| 223 | Handle das_handle) { | ||
| 224 | R_RETURN(AttachDeviceAddressSpace(system, device_name, das_handle)); | ||
| 225 | } | ||
| 226 | |||
| 227 | Result DetachDeviceAddressSpace64From32(Core::System& system, DeviceName device_name, | ||
| 228 | Handle das_handle) { | ||
| 229 | R_RETURN(DetachDeviceAddressSpace(system, device_name, das_handle)); | ||
| 230 | } | ||
| 231 | |||
| 232 | Result MapDeviceAddressSpaceByForce64From32(Core::System& system, Handle das_handle, | ||
| 233 | Handle process_handle, uint64_t process_address, | ||
| 234 | uint32_t size, uint64_t device_address, u32 option) { | ||
| 235 | R_RETURN(MapDeviceAddressSpaceByForce(system, das_handle, process_handle, process_address, size, | ||
| 236 | device_address, option)); | ||
| 237 | } | ||
| 238 | |||
| 239 | Result MapDeviceAddressSpaceAligned64From32(Core::System& system, Handle das_handle, | ||
| 240 | Handle process_handle, uint64_t process_address, | ||
| 241 | uint32_t size, uint64_t device_address, u32 option) { | ||
| 242 | R_RETURN(MapDeviceAddressSpaceAligned(system, das_handle, process_handle, process_address, size, | ||
| 243 | device_address, option)); | ||
| 244 | } | ||
| 245 | |||
| 246 | Result UnmapDeviceAddressSpace64From32(Core::System& system, Handle das_handle, | ||
| 247 | Handle process_handle, uint64_t process_address, | ||
| 248 | uint32_t size, uint64_t device_address) { | ||
| 249 | R_RETURN(UnmapDeviceAddressSpace(system, das_handle, process_handle, process_address, size, | ||
| 250 | device_address)); | ||
| 251 | } | ||
| 252 | |||
| 253 | } // namespace Kernel::Svc | ||
diff --git a/src/core/hle/kernel/svc/svc_event.cpp b/src/core/hle/kernel/svc/svc_event.cpp index 885f02f50..e8fb9efbc 100644 --- a/src/core/hle/kernel/svc/svc_event.cpp +++ b/src/core/hle/kernel/svc/svc_event.cpp | |||
| @@ -24,10 +24,6 @@ Result SignalEvent(Core::System& system, Handle event_handle) { | |||
| 24 | return event->Signal(); | 24 | return event->Signal(); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | Result SignalEvent32(Core::System& system, Handle event_handle) { | ||
| 28 | return SignalEvent(system, event_handle); | ||
| 29 | } | ||
| 30 | |||
| 31 | Result ClearEvent(Core::System& system, Handle event_handle) { | 27 | Result ClearEvent(Core::System& system, Handle event_handle) { |
| 32 | LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); | 28 | LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); |
| 33 | 29 | ||
| @@ -55,10 +51,6 @@ Result ClearEvent(Core::System& system, Handle event_handle) { | |||
| 55 | return ResultInvalidHandle; | 51 | return ResultInvalidHandle; |
| 56 | } | 52 | } |
| 57 | 53 | ||
| 58 | Result ClearEvent32(Core::System& system, Handle event_handle) { | ||
| 59 | return ClearEvent(system, event_handle); | ||
| 60 | } | ||
| 61 | |||
| 62 | Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { | 54 | Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { |
| 63 | LOG_DEBUG(Kernel_SVC, "called"); | 55 | LOG_DEBUG(Kernel_SVC, "called"); |
| 64 | 56 | ||
| @@ -104,8 +96,29 @@ Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { | |||
| 104 | return ResultSuccess; | 96 | return ResultSuccess; |
| 105 | } | 97 | } |
| 106 | 98 | ||
| 107 | Result CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read) { | 99 | Result SignalEvent64(Core::System& system, Handle event_handle) { |
| 108 | return CreateEvent(system, out_write, out_read); | 100 | R_RETURN(SignalEvent(system, event_handle)); |
| 101 | } | ||
| 102 | |||
| 103 | Result ClearEvent64(Core::System& system, Handle event_handle) { | ||
| 104 | R_RETURN(ClearEvent(system, event_handle)); | ||
| 105 | } | ||
| 106 | |||
| 107 | Result CreateEvent64(Core::System& system, Handle* out_write_handle, Handle* out_read_handle) { | ||
| 108 | R_RETURN(CreateEvent(system, out_write_handle, out_read_handle)); | ||
| 109 | } | ||
| 110 | |||
| 111 | Result SignalEvent64From32(Core::System& system, Handle event_handle) { | ||
| 112 | R_RETURN(SignalEvent(system, event_handle)); | ||
| 113 | } | ||
| 114 | |||
| 115 | Result ClearEvent64From32(Core::System& system, Handle event_handle) { | ||
| 116 | R_RETURN(ClearEvent(system, event_handle)); | ||
| 117 | } | ||
| 118 | |||
| 119 | Result CreateEvent64From32(Core::System& system, Handle* out_write_handle, | ||
| 120 | Handle* out_read_handle) { | ||
| 121 | R_RETURN(CreateEvent(system, out_write_handle, out_read_handle)); | ||
| 109 | } | 122 | } |
| 110 | 123 | ||
| 111 | } // namespace Kernel::Svc | 124 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_exception.cpp b/src/core/hle/kernel/svc/svc_exception.cpp index fb9f133c1..c2782908d 100644 --- a/src/core/hle/kernel/svc/svc_exception.cpp +++ b/src/core/hle/kernel/svc/svc_exception.cpp | |||
| @@ -12,10 +12,10 @@ | |||
| 12 | namespace Kernel::Svc { | 12 | namespace Kernel::Svc { |
| 13 | 13 | ||
| 14 | /// Break program execution | 14 | /// Break program execution |
| 15 | void Break(Core::System& system, u32 reason, u64 info1, u64 info2) { | 15 | void Break(Core::System& system, BreakReason reason, u64 info1, u64 info2) { |
| 16 | BreakReason break_reason = | 16 | BreakReason break_reason = |
| 17 | static_cast<BreakReason>(reason & ~static_cast<u32>(BreakReason::NotificationOnlyFlag)); | 17 | reason & static_cast<BreakReason>(~BreakReason::NotificationOnlyFlag); |
| 18 | bool notification_only = (reason & static_cast<u32>(BreakReason::NotificationOnlyFlag)) != 0; | 18 | bool notification_only = True(reason & BreakReason::NotificationOnlyFlag); |
| 19 | 19 | ||
| 20 | bool has_dumped_buffer{}; | 20 | bool has_dumped_buffer{}; |
| 21 | std::vector<u8> debug_buffer; | 21 | std::vector<u8> debug_buffer; |
| @@ -90,9 +90,9 @@ void Break(Core::System& system, u32 reason, u64 info1, u64 info2) { | |||
| 90 | break; | 90 | break; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | system.GetReporter().SaveSvcBreakReport(reason, notification_only, info1, info2, | 93 | system.GetReporter().SaveSvcBreakReport( |
| 94 | has_dumped_buffer ? std::make_optional(debug_buffer) | 94 | static_cast<u32>(reason), notification_only, info1, info2, |
| 95 | : std::nullopt); | 95 | has_dumped_buffer ? std::make_optional(debug_buffer) : std::nullopt); |
| 96 | 96 | ||
| 97 | if (!notification_only) { | 97 | if (!notification_only) { |
| 98 | LOG_CRITICAL( | 98 | LOG_CRITICAL( |
| @@ -114,8 +114,24 @@ void Break(Core::System& system, u32 reason, u64 info1, u64 info2) { | |||
| 114 | } | 114 | } |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | void Break32(Core::System& system, u32 reason, u32 info1, u32 info2) { | 117 | void ReturnFromException(Core::System& system, Result result) { |
| 118 | Break(system, reason, info1, info2); | 118 | UNIMPLEMENTED(); |
| 119 | } | ||
| 120 | |||
| 121 | void Break64(Core::System& system, BreakReason break_reason, uint64_t arg, uint64_t size) { | ||
| 122 | Break(system, break_reason, arg, size); | ||
| 123 | } | ||
| 124 | |||
| 125 | void Break64From32(Core::System& system, BreakReason break_reason, uint32_t arg, uint32_t size) { | ||
| 126 | Break(system, break_reason, arg, size); | ||
| 127 | } | ||
| 128 | |||
| 129 | void ReturnFromException64(Core::System& system, Result result) { | ||
| 130 | ReturnFromException(system, result); | ||
| 131 | } | ||
| 132 | |||
| 133 | void ReturnFromException64From32(Core::System& system, Result result) { | ||
| 134 | ReturnFromException(system, result); | ||
| 119 | } | 135 | } |
| 120 | 136 | ||
| 121 | } // namespace Kernel::Svc | 137 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_info.cpp b/src/core/hle/kernel/svc/svc_info.cpp index df5dd85a4..75097c7f9 100644 --- a/src/core/hle/kernel/svc/svc_info.cpp +++ b/src/core/hle/kernel/svc/svc_info.cpp | |||
| @@ -10,11 +10,12 @@ | |||
| 10 | namespace Kernel::Svc { | 10 | namespace Kernel::Svc { |
| 11 | 11 | ||
| 12 | /// Gets system/memory information for the current process | 12 | /// Gets system/memory information for the current process |
| 13 | Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, u64 info_sub_id) { | 13 | Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle handle, |
| 14 | u64 info_sub_id) { | ||
| 14 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, | 15 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, |
| 15 | info_sub_id, handle); | 16 | info_sub_id, handle); |
| 16 | 17 | ||
| 17 | const auto info_id_type = static_cast<InfoType>(info_id); | 18 | u32 info_id = static_cast<u32>(info_id_type); |
| 18 | 19 | ||
| 19 | switch (info_id_type) { | 20 | switch (info_id_type) { |
| 20 | case InfoType::CoreMask: | 21 | case InfoType::CoreMask: |
| @@ -267,16 +268,30 @@ Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, u6 | |||
| 267 | } | 268 | } |
| 268 | } | 269 | } |
| 269 | 270 | ||
| 270 | Result GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low, | 271 | Result GetSystemInfo(Core::System& system, uint64_t* out, SystemInfoType info_type, Handle handle, |
| 271 | u32 info_id, u32 handle, u32 sub_id_high) { | 272 | uint64_t info_subtype) { |
| 272 | const u64 sub_id{u64{sub_id_low} | (u64{sub_id_high} << 32)}; | 273 | UNIMPLEMENTED(); |
| 273 | u64 res_value{}; | 274 | R_THROW(ResultNotImplemented); |
| 275 | } | ||
| 276 | |||
| 277 | Result GetInfo64(Core::System& system, uint64_t* out, InfoType info_type, Handle handle, | ||
| 278 | uint64_t info_subtype) { | ||
| 279 | R_RETURN(GetInfo(system, out, info_type, handle, info_subtype)); | ||
| 280 | } | ||
| 274 | 281 | ||
| 275 | const Result result{GetInfo(system, &res_value, info_id, handle, sub_id)}; | 282 | Result GetSystemInfo64(Core::System& system, uint64_t* out, SystemInfoType info_type, Handle handle, |
| 276 | *result_high = static_cast<u32>(res_value >> 32); | 283 | uint64_t info_subtype) { |
| 277 | *result_low = static_cast<u32>(res_value & std::numeric_limits<u32>::max()); | 284 | R_RETURN(GetSystemInfo(system, out, info_type, handle, info_subtype)); |
| 285 | } | ||
| 286 | |||
| 287 | Result GetInfo64From32(Core::System& system, uint64_t* out, InfoType info_type, Handle handle, | ||
| 288 | uint64_t info_subtype) { | ||
| 289 | R_RETURN(GetInfo(system, out, info_type, handle, info_subtype)); | ||
| 290 | } | ||
| 278 | 291 | ||
| 279 | return result; | 292 | Result GetSystemInfo64From32(Core::System& system, uint64_t* out, SystemInfoType info_type, |
| 293 | Handle handle, uint64_t info_subtype) { | ||
| 294 | R_RETURN(GetSystemInfo(system, out, info_type, handle, info_subtype)); | ||
| 280 | } | 295 | } |
| 281 | 296 | ||
| 282 | } // namespace Kernel::Svc | 297 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_insecure_memory.cpp b/src/core/hle/kernel/svc/svc_insecure_memory.cpp new file mode 100644 index 000000000..79882685d --- /dev/null +++ b/src/core/hle/kernel/svc/svc_insecure_memory.cpp | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/kernel/svc.h" | ||
| 5 | #include "core/hle/kernel/svc_results.h" | ||
| 6 | |||
| 7 | namespace Kernel::Svc { | ||
| 8 | |||
| 9 | Result MapInsecureMemory(Core::System& system, uintptr_t address, size_t size) { | ||
| 10 | UNIMPLEMENTED(); | ||
| 11 | R_THROW(ResultNotImplemented); | ||
| 12 | } | ||
| 13 | |||
| 14 | Result UnmapInsecureMemory(Core::System& system, uintptr_t address, size_t size) { | ||
| 15 | UNIMPLEMENTED(); | ||
| 16 | R_THROW(ResultNotImplemented); | ||
| 17 | } | ||
| 18 | |||
| 19 | Result MapInsecureMemory64(Core::System& system, uint64_t address, uint64_t size) { | ||
| 20 | R_RETURN(MapInsecureMemory(system, address, size)); | ||
| 21 | } | ||
| 22 | |||
| 23 | Result UnmapInsecureMemory64(Core::System& system, uint64_t address, uint64_t size) { | ||
| 24 | R_RETURN(UnmapInsecureMemory(system, address, size)); | ||
| 25 | } | ||
| 26 | |||
| 27 | Result MapInsecureMemory64From32(Core::System& system, uint32_t address, uint32_t size) { | ||
| 28 | R_RETURN(MapInsecureMemory(system, address, size)); | ||
| 29 | } | ||
| 30 | |||
| 31 | Result UnmapInsecureMemory64From32(Core::System& system, uint32_t address, uint32_t size) { | ||
| 32 | R_RETURN(UnmapInsecureMemory(system, address, size)); | ||
| 33 | } | ||
| 34 | |||
| 35 | } // namespace Kernel::Svc | ||
diff --git a/src/core/hle/kernel/svc/svc_interrupt_event.cpp b/src/core/hle/kernel/svc/svc_interrupt_event.cpp index 299e22ae6..768b30a1f 100644 --- a/src/core/hle/kernel/svc/svc_interrupt_event.cpp +++ b/src/core/hle/kernel/svc/svc_interrupt_event.cpp | |||
| @@ -2,5 +2,24 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/kernel/svc.h" | 4 | #include "core/hle/kernel/svc.h" |
| 5 | #include "core/hle/kernel/svc_results.h" | ||
| 5 | 6 | ||
| 6 | namespace Kernel::Svc {} // namespace Kernel::Svc | 7 | namespace Kernel::Svc { |
| 8 | |||
| 9 | Result CreateInterruptEvent(Core::System& system, Handle* out, int32_t interrupt_id, | ||
| 10 | InterruptType type) { | ||
| 11 | UNIMPLEMENTED(); | ||
| 12 | R_THROW(ResultNotImplemented); | ||
| 13 | } | ||
| 14 | |||
| 15 | Result CreateInterruptEvent64(Core::System& system, Handle* out_read_handle, int32_t interrupt_id, | ||
| 16 | InterruptType interrupt_type) { | ||
| 17 | R_RETURN(CreateInterruptEvent(system, out_read_handle, interrupt_id, interrupt_type)); | ||
| 18 | } | ||
| 19 | |||
| 20 | Result CreateInterruptEvent64From32(Core::System& system, Handle* out_read_handle, | ||
| 21 | int32_t interrupt_id, InterruptType interrupt_type) { | ||
| 22 | R_RETURN(CreateInterruptEvent(system, out_read_handle, interrupt_id, interrupt_type)); | ||
| 23 | } | ||
| 24 | |||
| 25 | } // namespace Kernel::Svc | ||
diff --git a/src/core/hle/kernel/svc/svc_io_pool.cpp b/src/core/hle/kernel/svc/svc_io_pool.cpp index 299e22ae6..33f3d69bf 100644 --- a/src/core/hle/kernel/svc/svc_io_pool.cpp +++ b/src/core/hle/kernel/svc/svc_io_pool.cpp | |||
| @@ -2,5 +2,70 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/kernel/svc.h" | 4 | #include "core/hle/kernel/svc.h" |
| 5 | #include "core/hle/kernel/svc_results.h" | ||
| 5 | 6 | ||
| 6 | namespace Kernel::Svc {} // namespace Kernel::Svc | 7 | namespace Kernel::Svc { |
| 8 | |||
| 9 | Result CreateIoPool(Core::System& system, Handle* out, IoPoolType pool_type) { | ||
| 10 | UNIMPLEMENTED(); | ||
| 11 | R_THROW(ResultNotImplemented); | ||
| 12 | } | ||
| 13 | |||
| 14 | Result CreateIoRegion(Core::System& system, Handle* out, Handle io_pool_handle, uint64_t phys_addr, | ||
| 15 | size_t size, MemoryMapping mapping, MemoryPermission perm) { | ||
| 16 | UNIMPLEMENTED(); | ||
| 17 | R_THROW(ResultNotImplemented); | ||
| 18 | } | ||
| 19 | |||
| 20 | Result MapIoRegion(Core::System& system, Handle io_region_handle, uintptr_t address, size_t size, | ||
| 21 | MemoryPermission map_perm) { | ||
| 22 | UNIMPLEMENTED(); | ||
| 23 | R_THROW(ResultNotImplemented); | ||
| 24 | } | ||
| 25 | |||
| 26 | Result UnmapIoRegion(Core::System& system, Handle io_region_handle, uintptr_t address, | ||
| 27 | size_t size) { | ||
| 28 | UNIMPLEMENTED(); | ||
| 29 | R_THROW(ResultNotImplemented); | ||
| 30 | } | ||
| 31 | |||
| 32 | Result CreateIoPool64(Core::System& system, Handle* out_handle, IoPoolType pool_type) { | ||
| 33 | R_RETURN(CreateIoPool(system, out_handle, pool_type)); | ||
| 34 | } | ||
| 35 | |||
| 36 | Result CreateIoRegion64(Core::System& system, Handle* out_handle, Handle io_pool, | ||
| 37 | uint64_t physical_address, uint64_t size, MemoryMapping mapping, | ||
| 38 | MemoryPermission perm) { | ||
| 39 | R_RETURN(CreateIoRegion(system, out_handle, io_pool, physical_address, size, mapping, perm)); | ||
| 40 | } | ||
| 41 | |||
| 42 | Result MapIoRegion64(Core::System& system, Handle io_region, uint64_t address, uint64_t size, | ||
| 43 | MemoryPermission perm) { | ||
| 44 | R_RETURN(MapIoRegion(system, io_region, address, size, perm)); | ||
| 45 | } | ||
| 46 | |||
| 47 | Result UnmapIoRegion64(Core::System& system, Handle io_region, uint64_t address, uint64_t size) { | ||
| 48 | R_RETURN(UnmapIoRegion(system, io_region, address, size)); | ||
| 49 | } | ||
| 50 | |||
| 51 | Result CreateIoPool64From32(Core::System& system, Handle* out_handle, IoPoolType pool_type) { | ||
| 52 | R_RETURN(CreateIoPool(system, out_handle, pool_type)); | ||
| 53 | } | ||
| 54 | |||
| 55 | Result CreateIoRegion64From32(Core::System& system, Handle* out_handle, Handle io_pool, | ||
| 56 | uint64_t physical_address, uint32_t size, MemoryMapping mapping, | ||
| 57 | MemoryPermission perm) { | ||
| 58 | R_RETURN(CreateIoRegion(system, out_handle, io_pool, physical_address, size, mapping, perm)); | ||
| 59 | } | ||
| 60 | |||
| 61 | Result MapIoRegion64From32(Core::System& system, Handle io_region, uint32_t address, uint32_t size, | ||
| 62 | MemoryPermission perm) { | ||
| 63 | R_RETURN(MapIoRegion(system, io_region, address, size, perm)); | ||
| 64 | } | ||
| 65 | |||
| 66 | Result UnmapIoRegion64From32(Core::System& system, Handle io_region, uint32_t address, | ||
| 67 | uint32_t size) { | ||
| 68 | R_RETURN(UnmapIoRegion(system, io_region, address, size)); | ||
| 69 | } | ||
| 70 | |||
| 71 | } // namespace Kernel::Svc | ||
diff --git a/src/core/hle/kernel/svc/svc_ipc.cpp b/src/core/hle/kernel/svc/svc_ipc.cpp index dbb68e89a..97ce49dde 100644 --- a/src/core/hle/kernel/svc/svc_ipc.cpp +++ b/src/core/hle/kernel/svc/svc_ipc.cpp | |||
| @@ -24,20 +24,37 @@ Result SendSyncRequest(Core::System& system, Handle handle) { | |||
| 24 | return session->SendSyncRequest(); | 24 | return session->SendSyncRequest(); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | Result SendSyncRequest32(Core::System& system, Handle handle) { | 27 | Result SendSyncRequestWithUserBuffer(Core::System& system, uint64_t message_buffer, |
| 28 | return SendSyncRequest(system, handle); | 28 | uint64_t message_buffer_size, Handle session_handle) { |
| 29 | UNIMPLEMENTED(); | ||
| 30 | R_THROW(ResultNotImplemented); | ||
| 29 | } | 31 | } |
| 30 | 32 | ||
| 31 | Result ReplyAndReceive(Core::System& system, s32* out_index, Handle* handles, s32 num_handles, | 33 | Result SendAsyncRequestWithUserBuffer(Core::System& system, Handle* out_event_handle, |
| 34 | uint64_t message_buffer, uint64_t message_buffer_size, | ||
| 35 | Handle session_handle) { | ||
| 36 | UNIMPLEMENTED(); | ||
| 37 | R_THROW(ResultNotImplemented); | ||
| 38 | } | ||
| 39 | |||
| 40 | Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_addr, s32 num_handles, | ||
| 32 | Handle reply_target, s64 timeout_ns) { | 41 | Handle reply_target, s64 timeout_ns) { |
| 33 | auto& kernel = system.Kernel(); | 42 | auto& kernel = system.Kernel(); |
| 34 | auto& handle_table = GetCurrentThread(kernel).GetOwnerProcess()->GetHandleTable(); | 43 | auto& handle_table = GetCurrentThread(kernel).GetOwnerProcess()->GetHandleTable(); |
| 35 | 44 | ||
| 45 | R_UNLESS(0 <= num_handles && num_handles <= ArgumentHandleCountMax, ResultOutOfRange); | ||
| 46 | R_UNLESS(system.Memory().IsValidVirtualAddressRange( | ||
| 47 | handles_addr, static_cast<u64>(sizeof(Handle) * num_handles)), | ||
| 48 | ResultInvalidPointer); | ||
| 49 | |||
| 50 | std::vector<Handle> handles(num_handles); | ||
| 51 | system.Memory().ReadBlock(handles_addr, handles.data(), sizeof(Handle) * num_handles); | ||
| 52 | |||
| 36 | // Convert handle list to object table. | 53 | // Convert handle list to object table. |
| 37 | std::vector<KSynchronizationObject*> objs(num_handles); | 54 | std::vector<KSynchronizationObject*> objs(num_handles); |
| 38 | R_UNLESS( | 55 | R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles.data(), |
| 39 | handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles, num_handles), | 56 | num_handles), |
| 40 | ResultInvalidHandle); | 57 | ResultInvalidHandle); |
| 41 | 58 | ||
| 42 | // Ensure handles are closed when we're done. | 59 | // Ensure handles are closed when we're done. |
| 43 | SCOPE_EXIT({ | 60 | SCOPE_EXIT({ |
| @@ -86,4 +103,72 @@ Result ReplyAndReceive(Core::System& system, s32* out_index, Handle* handles, s3 | |||
| 86 | } | 103 | } |
| 87 | } | 104 | } |
| 88 | 105 | ||
| 106 | Result ReplyAndReceiveWithUserBuffer(Core::System& system, int32_t* out_index, | ||
| 107 | uint64_t message_buffer, uint64_t message_buffer_size, | ||
| 108 | uint64_t handles, int32_t num_handles, Handle reply_target, | ||
| 109 | int64_t timeout_ns) { | ||
| 110 | UNIMPLEMENTED(); | ||
| 111 | R_THROW(ResultNotImplemented); | ||
| 112 | } | ||
| 113 | |||
| 114 | Result SendSyncRequest64(Core::System& system, Handle session_handle) { | ||
| 115 | R_RETURN(SendSyncRequest(system, session_handle)); | ||
| 116 | } | ||
| 117 | |||
| 118 | Result SendSyncRequestWithUserBuffer64(Core::System& system, uint64_t message_buffer, | ||
| 119 | uint64_t message_buffer_size, Handle session_handle) { | ||
| 120 | R_RETURN( | ||
| 121 | SendSyncRequestWithUserBuffer(system, message_buffer, message_buffer_size, session_handle)); | ||
| 122 | } | ||
| 123 | |||
| 124 | Result SendAsyncRequestWithUserBuffer64(Core::System& system, Handle* out_event_handle, | ||
| 125 | uint64_t message_buffer, uint64_t message_buffer_size, | ||
| 126 | Handle session_handle) { | ||
| 127 | R_RETURN(SendAsyncRequestWithUserBuffer(system, out_event_handle, message_buffer, | ||
| 128 | message_buffer_size, session_handle)); | ||
| 129 | } | ||
| 130 | |||
| 131 | Result ReplyAndReceive64(Core::System& system, int32_t* out_index, uint64_t handles, | ||
| 132 | int32_t num_handles, Handle reply_target, int64_t timeout_ns) { | ||
| 133 | R_RETURN(ReplyAndReceive(system, out_index, handles, num_handles, reply_target, timeout_ns)); | ||
| 134 | } | ||
| 135 | |||
| 136 | Result ReplyAndReceiveWithUserBuffer64(Core::System& system, int32_t* out_index, | ||
| 137 | uint64_t message_buffer, uint64_t message_buffer_size, | ||
| 138 | uint64_t handles, int32_t num_handles, Handle reply_target, | ||
| 139 | int64_t timeout_ns) { | ||
| 140 | R_RETURN(ReplyAndReceiveWithUserBuffer(system, out_index, message_buffer, message_buffer_size, | ||
| 141 | handles, num_handles, reply_target, timeout_ns)); | ||
| 142 | } | ||
| 143 | |||
| 144 | Result SendSyncRequest64From32(Core::System& system, Handle session_handle) { | ||
| 145 | R_RETURN(SendSyncRequest(system, session_handle)); | ||
| 146 | } | ||
| 147 | |||
| 148 | Result SendSyncRequestWithUserBuffer64From32(Core::System& system, uint32_t message_buffer, | ||
| 149 | uint32_t message_buffer_size, Handle session_handle) { | ||
| 150 | R_RETURN( | ||
| 151 | SendSyncRequestWithUserBuffer(system, message_buffer, message_buffer_size, session_handle)); | ||
| 152 | } | ||
| 153 | |||
| 154 | Result SendAsyncRequestWithUserBuffer64From32(Core::System& system, Handle* out_event_handle, | ||
| 155 | uint32_t message_buffer, uint32_t message_buffer_size, | ||
| 156 | Handle session_handle) { | ||
| 157 | R_RETURN(SendAsyncRequestWithUserBuffer(system, out_event_handle, message_buffer, | ||
| 158 | message_buffer_size, session_handle)); | ||
| 159 | } | ||
| 160 | |||
| 161 | Result ReplyAndReceive64From32(Core::System& system, int32_t* out_index, uint32_t handles, | ||
| 162 | int32_t num_handles, Handle reply_target, int64_t timeout_ns) { | ||
| 163 | R_RETURN(ReplyAndReceive(system, out_index, handles, num_handles, reply_target, timeout_ns)); | ||
| 164 | } | ||
| 165 | |||
| 166 | Result ReplyAndReceiveWithUserBuffer64From32(Core::System& system, int32_t* out_index, | ||
| 167 | uint32_t message_buffer, uint32_t message_buffer_size, | ||
| 168 | uint32_t handles, int32_t num_handles, | ||
| 169 | Handle reply_target, int64_t timeout_ns) { | ||
| 170 | R_RETURN(ReplyAndReceiveWithUserBuffer(system, out_index, message_buffer, message_buffer_size, | ||
| 171 | handles, num_handles, reply_target, timeout_ns)); | ||
| 172 | } | ||
| 173 | |||
| 89 | } // namespace Kernel::Svc | 174 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_kernel_debug.cpp b/src/core/hle/kernel/svc/svc_kernel_debug.cpp index 454255e7a..cee048279 100644 --- a/src/core/hle/kernel/svc/svc_kernel_debug.cpp +++ b/src/core/hle/kernel/svc/svc_kernel_debug.cpp | |||
| @@ -5,15 +5,31 @@ | |||
| 5 | 5 | ||
| 6 | namespace Kernel::Svc { | 6 | namespace Kernel::Svc { |
| 7 | 7 | ||
| 8 | void KernelDebug([[maybe_unused]] Core::System& system, [[maybe_unused]] u32 kernel_debug_type, | 8 | void KernelDebug(Core::System& system, KernelDebugType kernel_debug_type, u64 arg0, u64 arg1, |
| 9 | [[maybe_unused]] u64 param1, [[maybe_unused]] u64 param2, | 9 | u64 arg2) { |
| 10 | [[maybe_unused]] u64 param3) { | ||
| 11 | // Intentionally do nothing, as this does nothing in released kernel binaries. | 10 | // Intentionally do nothing, as this does nothing in released kernel binaries. |
| 12 | } | 11 | } |
| 13 | 12 | ||
| 14 | void ChangeKernelTraceState([[maybe_unused]] Core::System& system, | 13 | void ChangeKernelTraceState(Core::System& system, KernelTraceState trace_state) { |
| 15 | [[maybe_unused]] u32 trace_state) { | ||
| 16 | // Intentionally do nothing, as this does nothing in released kernel binaries. | 14 | // Intentionally do nothing, as this does nothing in released kernel binaries. |
| 17 | } | 15 | } |
| 18 | 16 | ||
| 17 | void KernelDebug64(Core::System& system, KernelDebugType kern_debug_type, uint64_t arg0, | ||
| 18 | uint64_t arg1, uint64_t arg2) { | ||
| 19 | KernelDebug(system, kern_debug_type, arg0, arg1, arg2); | ||
| 20 | } | ||
| 21 | |||
| 22 | void ChangeKernelTraceState64(Core::System& system, KernelTraceState kern_trace_state) { | ||
| 23 | ChangeKernelTraceState(system, kern_trace_state); | ||
| 24 | } | ||
| 25 | |||
| 26 | void KernelDebug64From32(Core::System& system, KernelDebugType kern_debug_type, uint64_t arg0, | ||
| 27 | uint64_t arg1, uint64_t arg2) { | ||
| 28 | KernelDebug(system, kern_debug_type, arg0, arg1, arg2); | ||
| 29 | } | ||
| 30 | |||
| 31 | void ChangeKernelTraceState64From32(Core::System& system, KernelTraceState kern_trace_state) { | ||
| 32 | ChangeKernelTraceState(system, kern_trace_state); | ||
| 33 | } | ||
| 34 | |||
| 19 | } // namespace Kernel::Svc | 35 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_light_ipc.cpp b/src/core/hle/kernel/svc/svc_light_ipc.cpp index 299e22ae6..b76ce984c 100644 --- a/src/core/hle/kernel/svc/svc_light_ipc.cpp +++ b/src/core/hle/kernel/svc/svc_light_ipc.cpp | |||
| @@ -1,6 +1,73 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/arm/arm_interface.h" | ||
| 5 | #include "core/core.h" | ||
| 4 | #include "core/hle/kernel/svc.h" | 6 | #include "core/hle/kernel/svc.h" |
| 7 | #include "core/hle/kernel/svc_results.h" | ||
| 5 | 8 | ||
| 6 | namespace Kernel::Svc {} // namespace Kernel::Svc | 9 | namespace Kernel::Svc { |
| 10 | |||
| 11 | Result SendSyncRequestLight(Core::System& system, Handle session_handle, u32* args) { | ||
| 12 | UNIMPLEMENTED(); | ||
| 13 | R_THROW(ResultNotImplemented); | ||
| 14 | } | ||
| 15 | |||
| 16 | Result ReplyAndReceiveLight(Core::System& system, Handle session_handle, u32* args) { | ||
| 17 | UNIMPLEMENTED(); | ||
| 18 | R_THROW(ResultNotImplemented); | ||
| 19 | } | ||
| 20 | |||
| 21 | Result SendSyncRequestLight64(Core::System& system, Handle session_handle, u32* args) { | ||
| 22 | R_RETURN(SendSyncRequestLight(system, session_handle, args)); | ||
| 23 | } | ||
| 24 | |||
| 25 | Result ReplyAndReceiveLight64(Core::System& system, Handle session_handle, u32* args) { | ||
| 26 | R_RETURN(ReplyAndReceiveLight(system, session_handle, args)); | ||
| 27 | } | ||
| 28 | |||
| 29 | Result SendSyncRequestLight64From32(Core::System& system, Handle session_handle, u32* args) { | ||
| 30 | R_RETURN(SendSyncRequestLight(system, session_handle, args)); | ||
| 31 | } | ||
| 32 | |||
| 33 | Result ReplyAndReceiveLight64From32(Core::System& system, Handle session_handle, u32* args) { | ||
| 34 | R_RETURN(ReplyAndReceiveLight(system, session_handle, args)); | ||
| 35 | } | ||
| 36 | |||
| 37 | // Custom ABI implementation for light IPC. | ||
| 38 | |||
| 39 | template <typename F> | ||
| 40 | static void SvcWrap_LightIpc(Core::System& system, F&& cb) { | ||
| 41 | auto& core = system.CurrentArmInterface(); | ||
| 42 | std::array<u32, 7> arguments{}; | ||
| 43 | |||
| 44 | Handle session_handle = static_cast<Handle>(core.GetReg(0)); | ||
| 45 | for (int i = 0; i < 7; i++) { | ||
| 46 | arguments[i] = static_cast<u32>(core.GetReg(i + 1)); | ||
| 47 | } | ||
| 48 | |||
| 49 | Result ret = cb(system, session_handle, arguments.data()); | ||
| 50 | |||
| 51 | core.SetReg(0, ret.raw); | ||
| 52 | for (int i = 0; i < 7; i++) { | ||
| 53 | core.SetReg(i + 1, arguments[i]); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | void SvcWrap_SendSyncRequestLight64(Core::System& system) { | ||
| 58 | SvcWrap_LightIpc(system, SendSyncRequestLight64); | ||
| 59 | } | ||
| 60 | |||
| 61 | void SvcWrap_ReplyAndReceiveLight64(Core::System& system) { | ||
| 62 | SvcWrap_LightIpc(system, ReplyAndReceiveLight64); | ||
| 63 | } | ||
| 64 | |||
| 65 | void SvcWrap_SendSyncRequestLight64From32(Core::System& system) { | ||
| 66 | SvcWrap_LightIpc(system, SendSyncRequestLight64From32); | ||
| 67 | } | ||
| 68 | |||
| 69 | void SvcWrap_ReplyAndReceiveLight64From32(Core::System& system) { | ||
| 70 | SvcWrap_LightIpc(system, ReplyAndReceiveLight64From32); | ||
| 71 | } | ||
| 72 | |||
| 73 | } // namespace Kernel::Svc | ||
diff --git a/src/core/hle/kernel/svc/svc_lock.cpp b/src/core/hle/kernel/svc/svc_lock.cpp index 45f2a6553..7005ac30b 100644 --- a/src/core/hle/kernel/svc/svc_lock.cpp +++ b/src/core/hle/kernel/svc/svc_lock.cpp | |||
| @@ -27,10 +27,6 @@ Result ArbitrateLock(Core::System& system, Handle thread_handle, VAddr address, | |||
| 27 | return system.Kernel().CurrentProcess()->WaitForAddress(thread_handle, address, tag); | 27 | return system.Kernel().CurrentProcess()->WaitForAddress(thread_handle, address, tag); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | Result ArbitrateLock32(Core::System& system, Handle thread_handle, u32 address, u32 tag) { | ||
| 31 | return ArbitrateLock(system, thread_handle, address, tag); | ||
| 32 | } | ||
| 33 | |||
| 34 | /// Unlock a mutex | 30 | /// Unlock a mutex |
| 35 | Result ArbitrateUnlock(Core::System& system, VAddr address) { | 31 | Result ArbitrateUnlock(Core::System& system, VAddr address) { |
| 36 | LOG_TRACE(Kernel_SVC, "called address=0x{:X}", address); | 32 | LOG_TRACE(Kernel_SVC, "called address=0x{:X}", address); |
| @@ -50,8 +46,21 @@ Result ArbitrateUnlock(Core::System& system, VAddr address) { | |||
| 50 | return system.Kernel().CurrentProcess()->SignalToAddress(address); | 46 | return system.Kernel().CurrentProcess()->SignalToAddress(address); |
| 51 | } | 47 | } |
| 52 | 48 | ||
| 53 | Result ArbitrateUnlock32(Core::System& system, u32 address) { | 49 | Result ArbitrateLock64(Core::System& system, Handle thread_handle, uint64_t address, uint32_t tag) { |
| 54 | return ArbitrateUnlock(system, address); | 50 | R_RETURN(ArbitrateLock(system, thread_handle, address, tag)); |
| 51 | } | ||
| 52 | |||
| 53 | Result ArbitrateUnlock64(Core::System& system, uint64_t address) { | ||
| 54 | R_RETURN(ArbitrateUnlock(system, address)); | ||
| 55 | } | ||
| 56 | |||
| 57 | Result ArbitrateLock64From32(Core::System& system, Handle thread_handle, uint32_t address, | ||
| 58 | uint32_t tag) { | ||
| 59 | R_RETURN(ArbitrateLock(system, thread_handle, address, tag)); | ||
| 60 | } | ||
| 61 | |||
| 62 | Result ArbitrateUnlock64From32(Core::System& system, uint32_t address) { | ||
| 63 | R_RETURN(ArbitrateUnlock(system, address)); | ||
| 55 | } | 64 | } |
| 56 | 65 | ||
| 57 | } // namespace Kernel::Svc | 66 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_memory.cpp b/src/core/hle/kernel/svc/svc_memory.cpp index f78b1239b..21f818da6 100644 --- a/src/core/hle/kernel/svc/svc_memory.cpp +++ b/src/core/hle/kernel/svc/svc_memory.cpp | |||
| @@ -144,10 +144,6 @@ Result SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mas | |||
| 144 | return page_table.SetMemoryAttribute(address, size, mask, attr); | 144 | return page_table.SetMemoryAttribute(address, size, mask, attr); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | Result SetMemoryAttribute32(Core::System& system, u32 address, u32 size, u32 mask, u32 attr) { | ||
| 148 | return SetMemoryAttribute(system, address, size, mask, attr); | ||
| 149 | } | ||
| 150 | |||
| 151 | /// Maps a memory range into a different range. | 147 | /// Maps a memory range into a different range. |
| 152 | Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { | 148 | Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { |
| 153 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, | 149 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, |
| @@ -163,10 +159,6 @@ Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) | |||
| 163 | return page_table.MapMemory(dst_addr, src_addr, size); | 159 | return page_table.MapMemory(dst_addr, src_addr, size); |
| 164 | } | 160 | } |
| 165 | 161 | ||
| 166 | Result MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { | ||
| 167 | return MapMemory(system, dst_addr, src_addr, size); | ||
| 168 | } | ||
| 169 | |||
| 170 | /// Unmaps a region that was previously mapped with svcMapMemory | 162 | /// Unmaps a region that was previously mapped with svcMapMemory |
| 171 | Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { | 163 | Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { |
| 172 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, | 164 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, |
| @@ -182,8 +174,44 @@ Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 siz | |||
| 182 | return page_table.UnmapMemory(dst_addr, src_addr, size); | 174 | return page_table.UnmapMemory(dst_addr, src_addr, size); |
| 183 | } | 175 | } |
| 184 | 176 | ||
| 185 | Result UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { | 177 | Result SetMemoryPermission64(Core::System& system, uint64_t address, uint64_t size, |
| 186 | return UnmapMemory(system, dst_addr, src_addr, size); | 178 | MemoryPermission perm) { |
| 179 | R_RETURN(SetMemoryPermission(system, address, size, perm)); | ||
| 180 | } | ||
| 181 | |||
| 182 | Result SetMemoryAttribute64(Core::System& system, uint64_t address, uint64_t size, uint32_t mask, | ||
| 183 | uint32_t attr) { | ||
| 184 | R_RETURN(SetMemoryAttribute(system, address, size, mask, attr)); | ||
| 185 | } | ||
| 186 | |||
| 187 | Result MapMemory64(Core::System& system, uint64_t dst_address, uint64_t src_address, | ||
| 188 | uint64_t size) { | ||
| 189 | R_RETURN(MapMemory(system, dst_address, src_address, size)); | ||
| 190 | } | ||
| 191 | |||
| 192 | Result UnmapMemory64(Core::System& system, uint64_t dst_address, uint64_t src_address, | ||
| 193 | uint64_t size) { | ||
| 194 | R_RETURN(UnmapMemory(system, dst_address, src_address, size)); | ||
| 195 | } | ||
| 196 | |||
| 197 | Result SetMemoryPermission64From32(Core::System& system, uint32_t address, uint32_t size, | ||
| 198 | MemoryPermission perm) { | ||
| 199 | R_RETURN(SetMemoryPermission(system, address, size, perm)); | ||
| 200 | } | ||
| 201 | |||
| 202 | Result SetMemoryAttribute64From32(Core::System& system, uint32_t address, uint32_t size, | ||
| 203 | uint32_t mask, uint32_t attr) { | ||
| 204 | R_RETURN(SetMemoryAttribute(system, address, size, mask, attr)); | ||
| 205 | } | ||
| 206 | |||
| 207 | Result MapMemory64From32(Core::System& system, uint32_t dst_address, uint32_t src_address, | ||
| 208 | uint32_t size) { | ||
| 209 | R_RETURN(MapMemory(system, dst_address, src_address, size)); | ||
| 210 | } | ||
| 211 | |||
| 212 | Result UnmapMemory64From32(Core::System& system, uint32_t dst_address, uint32_t src_address, | ||
| 213 | uint32_t size) { | ||
| 214 | R_RETURN(UnmapMemory(system, dst_address, src_address, size)); | ||
| 187 | } | 215 | } |
| 188 | 216 | ||
| 189 | } // namespace Kernel::Svc | 217 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_physical_memory.cpp b/src/core/hle/kernel/svc/svc_physical_memory.cpp index 0fc262203..8d00e1fc3 100644 --- a/src/core/hle/kernel/svc/svc_physical_memory.cpp +++ b/src/core/hle/kernel/svc/svc_physical_memory.cpp | |||
| @@ -21,13 +21,6 @@ Result SetHeapSize(Core::System& system, VAddr* out_address, u64 size) { | |||
| 21 | return ResultSuccess; | 21 | return ResultSuccess; |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | Result SetHeapSize32(Core::System& system, u32* heap_addr, u32 heap_size) { | ||
| 25 | VAddr temp_heap_addr{}; | ||
| 26 | const Result result{SetHeapSize(system, &temp_heap_addr, heap_size)}; | ||
| 27 | *heap_addr = static_cast<u32>(temp_heap_addr); | ||
| 28 | return result; | ||
| 29 | } | ||
| 30 | |||
| 31 | /// Maps memory at a desired address | 24 | /// Maps memory at a desired address |
| 32 | Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { | 25 | Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { |
| 33 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); | 26 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); |
| @@ -77,10 +70,6 @@ Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { | |||
| 77 | return page_table.MapPhysicalMemory(addr, size); | 70 | return page_table.MapPhysicalMemory(addr, size); |
| 78 | } | 71 | } |
| 79 | 72 | ||
| 80 | Result MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { | ||
| 81 | return MapPhysicalMemory(system, addr, size); | ||
| 82 | } | ||
| 83 | |||
| 84 | /// Unmaps memory previously mapped via MapPhysicalMemory | 73 | /// Unmaps memory previously mapped via MapPhysicalMemory |
| 85 | Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { | 74 | Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { |
| 86 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); | 75 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); |
| @@ -130,8 +119,67 @@ Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { | |||
| 130 | return page_table.UnmapPhysicalMemory(addr, size); | 119 | return page_table.UnmapPhysicalMemory(addr, size); |
| 131 | } | 120 | } |
| 132 | 121 | ||
| 133 | Result UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { | 122 | Result MapPhysicalMemoryUnsafe(Core::System& system, uint64_t address, uint64_t size) { |
| 134 | return UnmapPhysicalMemory(system, addr, size); | 123 | UNIMPLEMENTED(); |
| 124 | R_THROW(ResultNotImplemented); | ||
| 125 | } | ||
| 126 | |||
| 127 | Result UnmapPhysicalMemoryUnsafe(Core::System& system, uint64_t address, uint64_t size) { | ||
| 128 | UNIMPLEMENTED(); | ||
| 129 | R_THROW(ResultNotImplemented); | ||
| 130 | } | ||
| 131 | |||
| 132 | Result SetUnsafeLimit(Core::System& system, uint64_t limit) { | ||
| 133 | UNIMPLEMENTED(); | ||
| 134 | R_THROW(ResultNotImplemented); | ||
| 135 | } | ||
| 136 | |||
| 137 | Result SetHeapSize64(Core::System& system, uint64_t* out_address, uint64_t size) { | ||
| 138 | R_RETURN(SetHeapSize(system, out_address, size)); | ||
| 139 | } | ||
| 140 | |||
| 141 | Result MapPhysicalMemory64(Core::System& system, uint64_t address, uint64_t size) { | ||
| 142 | R_RETURN(MapPhysicalMemory(system, address, size)); | ||
| 143 | } | ||
| 144 | |||
| 145 | Result UnmapPhysicalMemory64(Core::System& system, uint64_t address, uint64_t size) { | ||
| 146 | R_RETURN(UnmapPhysicalMemory(system, address, size)); | ||
| 147 | } | ||
| 148 | |||
| 149 | Result MapPhysicalMemoryUnsafe64(Core::System& system, uint64_t address, uint64_t size) { | ||
| 150 | R_RETURN(MapPhysicalMemoryUnsafe(system, address, size)); | ||
| 151 | } | ||
| 152 | |||
| 153 | Result UnmapPhysicalMemoryUnsafe64(Core::System& system, uint64_t address, uint64_t size) { | ||
| 154 | R_RETURN(UnmapPhysicalMemoryUnsafe(system, address, size)); | ||
| 155 | } | ||
| 156 | |||
| 157 | Result SetUnsafeLimit64(Core::System& system, uint64_t limit) { | ||
| 158 | R_RETURN(SetUnsafeLimit(system, limit)); | ||
| 159 | } | ||
| 160 | |||
| 161 | Result SetHeapSize64From32(Core::System& system, uintptr_t* out_address, uint32_t size) { | ||
| 162 | R_RETURN(SetHeapSize(system, out_address, size)); | ||
| 163 | } | ||
| 164 | |||
| 165 | Result MapPhysicalMemory64From32(Core::System& system, uint32_t address, uint32_t size) { | ||
| 166 | R_RETURN(MapPhysicalMemory(system, address, size)); | ||
| 167 | } | ||
| 168 | |||
| 169 | Result UnmapPhysicalMemory64From32(Core::System& system, uint32_t address, uint32_t size) { | ||
| 170 | R_RETURN(UnmapPhysicalMemory(system, address, size)); | ||
| 171 | } | ||
| 172 | |||
| 173 | Result MapPhysicalMemoryUnsafe64From32(Core::System& system, uint32_t address, uint32_t size) { | ||
| 174 | R_RETURN(MapPhysicalMemoryUnsafe(system, address, size)); | ||
| 175 | } | ||
| 176 | |||
| 177 | Result UnmapPhysicalMemoryUnsafe64From32(Core::System& system, uint32_t address, uint32_t size) { | ||
| 178 | R_RETURN(UnmapPhysicalMemoryUnsafe(system, address, size)); | ||
| 179 | } | ||
| 180 | |||
| 181 | Result SetUnsafeLimit64From32(Core::System& system, uint32_t limit) { | ||
| 182 | R_RETURN(SetUnsafeLimit(system, limit)); | ||
| 135 | } | 183 | } |
| 136 | 184 | ||
| 137 | } // namespace Kernel::Svc | 185 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_port.cpp b/src/core/hle/kernel/svc/svc_port.cpp index cdfe0dd16..2e5d228bb 100644 --- a/src/core/hle/kernel/svc/svc_port.cpp +++ b/src/core/hle/kernel/svc/svc_port.cpp | |||
| @@ -63,9 +63,60 @@ Result ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_add | |||
| 63 | return ResultSuccess; | 63 | return ResultSuccess; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | Result ConnectToNamedPort32(Core::System& system, Handle* out_handle, u32 port_name_address) { | 66 | Result CreatePort(Core::System& system, Handle* out_server, Handle* out_client, |
| 67 | int32_t max_sessions, bool is_light, uintptr_t name) { | ||
| 68 | UNIMPLEMENTED(); | ||
| 69 | R_THROW(ResultNotImplemented); | ||
| 70 | } | ||
| 71 | |||
| 72 | Result ConnectToPort(Core::System& system, Handle* out_handle, Handle port) { | ||
| 73 | UNIMPLEMENTED(); | ||
| 74 | R_THROW(ResultNotImplemented); | ||
| 75 | } | ||
| 76 | |||
| 77 | Result ManageNamedPort(Core::System& system, Handle* out_server_handle, uint64_t name, | ||
| 78 | int32_t max_sessions) { | ||
| 79 | UNIMPLEMENTED(); | ||
| 80 | R_THROW(ResultNotImplemented); | ||
| 81 | } | ||
| 82 | |||
| 83 | Result ConnectToNamedPort64(Core::System& system, Handle* out_handle, uint64_t name) { | ||
| 84 | R_RETURN(ConnectToNamedPort(system, out_handle, name)); | ||
| 85 | } | ||
| 86 | |||
| 87 | Result CreatePort64(Core::System& system, Handle* out_server_handle, Handle* out_client_handle, | ||
| 88 | int32_t max_sessions, bool is_light, uint64_t name) { | ||
| 89 | R_RETURN( | ||
| 90 | CreatePort(system, out_server_handle, out_client_handle, max_sessions, is_light, name)); | ||
| 91 | } | ||
| 92 | |||
| 93 | Result ManageNamedPort64(Core::System& system, Handle* out_server_handle, uint64_t name, | ||
| 94 | int32_t max_sessions) { | ||
| 95 | R_RETURN(ManageNamedPort(system, out_server_handle, name, max_sessions)); | ||
| 96 | } | ||
| 97 | |||
| 98 | Result ConnectToPort64(Core::System& system, Handle* out_handle, Handle port) { | ||
| 99 | R_RETURN(ConnectToPort(system, out_handle, port)); | ||
| 100 | } | ||
| 101 | |||
| 102 | Result ConnectToNamedPort64From32(Core::System& system, Handle* out_handle, uint32_t name) { | ||
| 103 | R_RETURN(ConnectToNamedPort(system, out_handle, name)); | ||
| 104 | } | ||
| 105 | |||
| 106 | Result CreatePort64From32(Core::System& system, Handle* out_server_handle, | ||
| 107 | Handle* out_client_handle, int32_t max_sessions, bool is_light, | ||
| 108 | uint32_t name) { | ||
| 109 | R_RETURN( | ||
| 110 | CreatePort(system, out_server_handle, out_client_handle, max_sessions, is_light, name)); | ||
| 111 | } | ||
| 112 | |||
| 113 | Result ManageNamedPort64From32(Core::System& system, Handle* out_server_handle, uint32_t name, | ||
| 114 | int32_t max_sessions) { | ||
| 115 | R_RETURN(ManageNamedPort(system, out_server_handle, name, max_sessions)); | ||
| 116 | } | ||
| 67 | 117 | ||
| 68 | return ConnectToNamedPort(system, out_handle, port_name_address); | 118 | Result ConnectToPort64From32(Core::System& system, Handle* out_handle, Handle port) { |
| 119 | R_RETURN(ConnectToPort(system, out_handle, port)); | ||
| 69 | } | 120 | } |
| 70 | 121 | ||
| 71 | } // namespace Kernel::Svc | 122 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_power_management.cpp b/src/core/hle/kernel/svc/svc_power_management.cpp index 299e22ae6..f605a0317 100644 --- a/src/core/hle/kernel/svc/svc_power_management.cpp +++ b/src/core/hle/kernel/svc/svc_power_management.cpp | |||
| @@ -2,5 +2,20 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/kernel/svc.h" | 4 | #include "core/hle/kernel/svc.h" |
| 5 | #include "core/hle/kernel/svc_results.h" | ||
| 5 | 6 | ||
| 6 | namespace Kernel::Svc {} // namespace Kernel::Svc | 7 | namespace Kernel::Svc { |
| 8 | |||
| 9 | void SleepSystem(Core::System& system) { | ||
| 10 | UNIMPLEMENTED(); | ||
| 11 | } | ||
| 12 | |||
| 13 | void SleepSystem64(Core::System& system) { | ||
| 14 | return SleepSystem(system); | ||
| 15 | } | ||
| 16 | |||
| 17 | void SleepSystem64From32(Core::System& system) { | ||
| 18 | return SleepSystem(system); | ||
| 19 | } | ||
| 20 | |||
| 21 | } // namespace Kernel::Svc | ||
diff --git a/src/core/hle/kernel/svc/svc_process.cpp b/src/core/hle/kernel/svc/svc_process.cpp index d6c8b4561..d2c20aad2 100644 --- a/src/core/hle/kernel/svc/svc_process.cpp +++ b/src/core/hle/kernel/svc/svc_process.cpp | |||
| @@ -18,10 +18,6 @@ void ExitProcess(Core::System& system) { | |||
| 18 | system.Exit(); | 18 | system.Exit(); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | void ExitProcess32(Core::System& system) { | ||
| 22 | ExitProcess(system); | ||
| 23 | } | ||
| 24 | |||
| 25 | /// Gets the ID of the specified process or a specified thread's owning process. | 21 | /// Gets the ID of the specified process or a specified thread's owning process. |
| 26 | Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) { | 22 | Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) { |
| 27 | LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle); | 23 | LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle); |
| @@ -54,17 +50,8 @@ Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) { | |||
| 54 | return ResultSuccess; | 50 | return ResultSuccess; |
| 55 | } | 51 | } |
| 56 | 52 | ||
| 57 | Result GetProcessId32(Core::System& system, u32* out_process_id_low, u32* out_process_id_high, | 53 | Result GetProcessList(Core::System& system, s32* out_num_processes, VAddr out_process_ids, |
| 58 | Handle handle) { | 54 | int32_t out_process_ids_size) { |
| 59 | u64 out_process_id{}; | ||
| 60 | const auto result = GetProcessId(system, &out_process_id, handle); | ||
| 61 | *out_process_id_low = static_cast<u32>(out_process_id); | ||
| 62 | *out_process_id_high = static_cast<u32>(out_process_id >> 32); | ||
| 63 | return result; | ||
| 64 | } | ||
| 65 | |||
| 66 | Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_process_ids, | ||
| 67 | u32 out_process_ids_size) { | ||
| 68 | LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}", | 55 | LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}", |
| 69 | out_process_ids, out_process_ids_size); | 56 | out_process_ids, out_process_ids_size); |
| 70 | 57 | ||
| @@ -89,7 +76,8 @@ Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_pr | |||
| 89 | auto& memory = system.Memory(); | 76 | auto& memory = system.Memory(); |
| 90 | const auto& process_list = kernel.GetProcessList(); | 77 | const auto& process_list = kernel.GetProcessList(); |
| 91 | const auto num_processes = process_list.size(); | 78 | const auto num_processes = process_list.size(); |
| 92 | const auto copy_amount = std::min(std::size_t{out_process_ids_size}, num_processes); | 79 | const auto copy_amount = |
| 80 | std::min(static_cast<std::size_t>(out_process_ids_size), num_processes); | ||
| 93 | 81 | ||
| 94 | for (std::size_t i = 0; i < copy_amount; ++i) { | 82 | for (std::size_t i = 0; i < copy_amount; ++i) { |
| 95 | memory.Write64(out_process_ids, process_list[i]->GetProcessID()); | 83 | memory.Write64(out_process_ids, process_list[i]->GetProcessID()); |
| @@ -100,8 +88,9 @@ Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_pr | |||
| 100 | return ResultSuccess; | 88 | return ResultSuccess; |
| 101 | } | 89 | } |
| 102 | 90 | ||
| 103 | Result GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type) { | 91 | Result GetProcessInfo(Core::System& system, s64* out, Handle process_handle, |
| 104 | LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type); | 92 | ProcessInfoType info_type) { |
| 93 | LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, info_type); | ||
| 105 | 94 | ||
| 106 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 95 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 107 | KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); | 96 | KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); |
| @@ -111,14 +100,95 @@ Result GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 | |||
| 111 | return ResultInvalidHandle; | 100 | return ResultInvalidHandle; |
| 112 | } | 101 | } |
| 113 | 102 | ||
| 114 | const auto info_type = static_cast<ProcessInfoType>(type); | ||
| 115 | if (info_type != ProcessInfoType::ProcessState) { | 103 | if (info_type != ProcessInfoType::ProcessState) { |
| 116 | LOG_ERROR(Kernel_SVC, "Expected info_type to be ProcessState but got {} instead", type); | 104 | LOG_ERROR(Kernel_SVC, "Expected info_type to be ProcessState but got {} instead", |
| 105 | info_type); | ||
| 117 | return ResultInvalidEnumValue; | 106 | return ResultInvalidEnumValue; |
| 118 | } | 107 | } |
| 119 | 108 | ||
| 120 | *out = static_cast<u64>(process->GetState()); | 109 | *out = static_cast<s64>(process->GetState()); |
| 121 | return ResultSuccess; | 110 | return ResultSuccess; |
| 122 | } | 111 | } |
| 123 | 112 | ||
| 113 | Result CreateProcess(Core::System& system, Handle* out_handle, uint64_t parameters, uint64_t caps, | ||
| 114 | int32_t num_caps) { | ||
| 115 | UNIMPLEMENTED(); | ||
| 116 | R_THROW(ResultNotImplemented); | ||
| 117 | } | ||
| 118 | |||
| 119 | Result StartProcess(Core::System& system, Handle process_handle, int32_t priority, int32_t core_id, | ||
| 120 | uint64_t main_thread_stack_size) { | ||
| 121 | UNIMPLEMENTED(); | ||
| 122 | R_THROW(ResultNotImplemented); | ||
| 123 | } | ||
| 124 | |||
| 125 | Result TerminateProcess(Core::System& system, Handle process_handle) { | ||
| 126 | UNIMPLEMENTED(); | ||
| 127 | R_THROW(ResultNotImplemented); | ||
| 128 | } | ||
| 129 | |||
| 130 | void ExitProcess64(Core::System& system) { | ||
| 131 | ExitProcess(system); | ||
| 132 | } | ||
| 133 | |||
| 134 | Result GetProcessId64(Core::System& system, uint64_t* out_process_id, Handle process_handle) { | ||
| 135 | R_RETURN(GetProcessId(system, out_process_id, process_handle)); | ||
| 136 | } | ||
| 137 | |||
| 138 | Result GetProcessList64(Core::System& system, int32_t* out_num_processes, uint64_t out_process_ids, | ||
| 139 | int32_t max_out_count) { | ||
| 140 | R_RETURN(GetProcessList(system, out_num_processes, out_process_ids, max_out_count)); | ||
| 141 | } | ||
| 142 | |||
| 143 | Result CreateProcess64(Core::System& system, Handle* out_handle, uint64_t parameters, uint64_t caps, | ||
| 144 | int32_t num_caps) { | ||
| 145 | R_RETURN(CreateProcess(system, out_handle, parameters, caps, num_caps)); | ||
| 146 | } | ||
| 147 | |||
| 148 | Result StartProcess64(Core::System& system, Handle process_handle, int32_t priority, | ||
| 149 | int32_t core_id, uint64_t main_thread_stack_size) { | ||
| 150 | R_RETURN(StartProcess(system, process_handle, priority, core_id, main_thread_stack_size)); | ||
| 151 | } | ||
| 152 | |||
| 153 | Result TerminateProcess64(Core::System& system, Handle process_handle) { | ||
| 154 | R_RETURN(TerminateProcess(system, process_handle)); | ||
| 155 | } | ||
| 156 | |||
| 157 | Result GetProcessInfo64(Core::System& system, int64_t* out_info, Handle process_handle, | ||
| 158 | ProcessInfoType info_type) { | ||
| 159 | R_RETURN(GetProcessInfo(system, out_info, process_handle, info_type)); | ||
| 160 | } | ||
| 161 | |||
| 162 | void ExitProcess64From32(Core::System& system) { | ||
| 163 | ExitProcess(system); | ||
| 164 | } | ||
| 165 | |||
| 166 | Result GetProcessId64From32(Core::System& system, uint64_t* out_process_id, Handle process_handle) { | ||
| 167 | R_RETURN(GetProcessId(system, out_process_id, process_handle)); | ||
| 168 | } | ||
| 169 | |||
| 170 | Result GetProcessList64From32(Core::System& system, int32_t* out_num_processes, | ||
| 171 | uint32_t out_process_ids, int32_t max_out_count) { | ||
| 172 | R_RETURN(GetProcessList(system, out_num_processes, out_process_ids, max_out_count)); | ||
| 173 | } | ||
| 174 | |||
| 175 | Result CreateProcess64From32(Core::System& system, Handle* out_handle, uint32_t parameters, | ||
| 176 | uint32_t caps, int32_t num_caps) { | ||
| 177 | R_RETURN(CreateProcess(system, out_handle, parameters, caps, num_caps)); | ||
| 178 | } | ||
| 179 | |||
| 180 | Result StartProcess64From32(Core::System& system, Handle process_handle, int32_t priority, | ||
| 181 | int32_t core_id, uint64_t main_thread_stack_size) { | ||
| 182 | R_RETURN(StartProcess(system, process_handle, priority, core_id, main_thread_stack_size)); | ||
| 183 | } | ||
| 184 | |||
| 185 | Result TerminateProcess64From32(Core::System& system, Handle process_handle) { | ||
| 186 | R_RETURN(TerminateProcess(system, process_handle)); | ||
| 187 | } | ||
| 188 | |||
| 189 | Result GetProcessInfo64From32(Core::System& system, int64_t* out_info, Handle process_handle, | ||
| 190 | ProcessInfoType info_type) { | ||
| 191 | R_RETURN(GetProcessInfo(system, out_info, process_handle, info_type)); | ||
| 192 | } | ||
| 193 | |||
| 124 | } // namespace Kernel::Svc | 194 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_process_memory.cpp b/src/core/hle/kernel/svc/svc_process_memory.cpp index b6ac43af2..dbe24e139 100644 --- a/src/core/hle/kernel/svc/svc_process_memory.cpp +++ b/src/core/hle/kernel/svc/svc_process_memory.cpp | |||
| @@ -271,4 +271,54 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d | |||
| 271 | KPageTable::ICacheInvalidationStrategy::InvalidateAll); | 271 | KPageTable::ICacheInvalidationStrategy::InvalidateAll); |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | Result SetProcessMemoryPermission64(Core::System& system, Handle process_handle, uint64_t address, | ||
| 275 | uint64_t size, MemoryPermission perm) { | ||
| 276 | R_RETURN(SetProcessMemoryPermission(system, process_handle, address, size, perm)); | ||
| 277 | } | ||
| 278 | |||
| 279 | Result MapProcessMemory64(Core::System& system, uint64_t dst_address, Handle process_handle, | ||
| 280 | uint64_t src_address, uint64_t size) { | ||
| 281 | R_RETURN(MapProcessMemory(system, dst_address, process_handle, src_address, size)); | ||
| 282 | } | ||
| 283 | |||
| 284 | Result UnmapProcessMemory64(Core::System& system, uint64_t dst_address, Handle process_handle, | ||
| 285 | uint64_t src_address, uint64_t size) { | ||
| 286 | R_RETURN(UnmapProcessMemory(system, dst_address, process_handle, src_address, size)); | ||
| 287 | } | ||
| 288 | |||
| 289 | Result MapProcessCodeMemory64(Core::System& system, Handle process_handle, uint64_t dst_address, | ||
| 290 | uint64_t src_address, uint64_t size) { | ||
| 291 | R_RETURN(MapProcessCodeMemory(system, process_handle, dst_address, src_address, size)); | ||
| 292 | } | ||
| 293 | |||
| 294 | Result UnmapProcessCodeMemory64(Core::System& system, Handle process_handle, uint64_t dst_address, | ||
| 295 | uint64_t src_address, uint64_t size) { | ||
| 296 | R_RETURN(UnmapProcessCodeMemory(system, process_handle, dst_address, src_address, size)); | ||
| 297 | } | ||
| 298 | |||
| 299 | Result SetProcessMemoryPermission64From32(Core::System& system, Handle process_handle, | ||
| 300 | uint64_t address, uint64_t size, MemoryPermission perm) { | ||
| 301 | R_RETURN(SetProcessMemoryPermission(system, process_handle, address, size, perm)); | ||
| 302 | } | ||
| 303 | |||
| 304 | Result MapProcessMemory64From32(Core::System& system, uint32_t dst_address, Handle process_handle, | ||
| 305 | uint64_t src_address, uint32_t size) { | ||
| 306 | R_RETURN(MapProcessMemory(system, dst_address, process_handle, src_address, size)); | ||
| 307 | } | ||
| 308 | |||
| 309 | Result UnmapProcessMemory64From32(Core::System& system, uint32_t dst_address, Handle process_handle, | ||
| 310 | uint64_t src_address, uint32_t size) { | ||
| 311 | R_RETURN(UnmapProcessMemory(system, dst_address, process_handle, src_address, size)); | ||
| 312 | } | ||
| 313 | |||
| 314 | Result MapProcessCodeMemory64From32(Core::System& system, Handle process_handle, | ||
| 315 | uint64_t dst_address, uint64_t src_address, uint64_t size) { | ||
| 316 | R_RETURN(MapProcessCodeMemory(system, process_handle, dst_address, src_address, size)); | ||
| 317 | } | ||
| 318 | |||
| 319 | Result UnmapProcessCodeMemory64From32(Core::System& system, Handle process_handle, | ||
| 320 | uint64_t dst_address, uint64_t src_address, uint64_t size) { | ||
| 321 | R_RETURN(UnmapProcessCodeMemory(system, process_handle, dst_address, src_address, size)); | ||
| 322 | } | ||
| 323 | |||
| 274 | } // namespace Kernel::Svc | 324 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_processor.cpp b/src/core/hle/kernel/svc/svc_processor.cpp index 8561cf74f..7602ce6c0 100644 --- a/src/core/hle/kernel/svc/svc_processor.cpp +++ b/src/core/hle/kernel/svc/svc_processor.cpp | |||
| @@ -9,12 +9,16 @@ | |||
| 9 | namespace Kernel::Svc { | 9 | namespace Kernel::Svc { |
| 10 | 10 | ||
| 11 | /// Get which CPU core is executing the current thread | 11 | /// Get which CPU core is executing the current thread |
| 12 | u32 GetCurrentProcessorNumber(Core::System& system) { | 12 | int32_t GetCurrentProcessorNumber(Core::System& system) { |
| 13 | LOG_TRACE(Kernel_SVC, "called"); | 13 | LOG_TRACE(Kernel_SVC, "called"); |
| 14 | return static_cast<u32>(system.CurrentPhysicalCore().CoreIndex()); | 14 | return static_cast<int32_t>(system.CurrentPhysicalCore().CoreIndex()); |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | u32 GetCurrentProcessorNumber32(Core::System& system) { | 17 | int32_t GetCurrentProcessorNumber64(Core::System& system) { |
| 18 | return GetCurrentProcessorNumber(system); | ||
| 19 | } | ||
| 20 | |||
| 21 | int32_t GetCurrentProcessorNumber64From32(Core::System& system) { | ||
| 18 | return GetCurrentProcessorNumber(system); | 22 | return GetCurrentProcessorNumber(system); |
| 19 | } | 23 | } |
| 20 | 24 | ||
diff --git a/src/core/hle/kernel/svc/svc_query_memory.cpp b/src/core/hle/kernel/svc/svc_query_memory.cpp index aac3b2eca..db140a341 100644 --- a/src/core/hle/kernel/svc/svc_query_memory.cpp +++ b/src/core/hle/kernel/svc/svc_query_memory.cpp | |||
| @@ -7,24 +7,20 @@ | |||
| 7 | 7 | ||
| 8 | namespace Kernel::Svc { | 8 | namespace Kernel::Svc { |
| 9 | 9 | ||
| 10 | Result QueryMemory(Core::System& system, VAddr memory_info_address, VAddr page_info_address, | 10 | Result QueryMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, |
| 11 | VAddr query_address) { | 11 | VAddr query_address) { |
| 12 | LOG_TRACE(Kernel_SVC, | 12 | LOG_TRACE(Kernel_SVC, |
| 13 | "called, memory_info_address=0x{:016X}, page_info_address=0x{:016X}, " | 13 | "called, out_memory_info=0x{:016X}, " |
| 14 | "query_address=0x{:016X}", | 14 | "query_address=0x{:016X}", |
| 15 | memory_info_address, page_info_address, query_address); | 15 | out_memory_info, query_address); |
| 16 | 16 | ||
| 17 | return QueryProcessMemory(system, memory_info_address, page_info_address, CurrentProcess, | 17 | // Query memory is just QueryProcessMemory on the current process. |
| 18 | return QueryProcessMemory(system, out_memory_info, out_page_info, CurrentProcess, | ||
| 18 | query_address); | 19 | query_address); |
| 19 | } | 20 | } |
| 20 | 21 | ||
| 21 | Result QueryMemory32(Core::System& system, u32 memory_info_address, u32 page_info_address, | 22 | Result QueryProcessMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, |
| 22 | u32 query_address) { | 23 | Handle process_handle, uint64_t address) { |
| 23 | return QueryMemory(system, memory_info_address, page_info_address, query_address); | ||
| 24 | } | ||
| 25 | |||
| 26 | Result QueryProcessMemory(Core::System& system, VAddr memory_info_address, VAddr page_info_address, | ||
| 27 | Handle process_handle, VAddr address) { | ||
| 28 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); | 24 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); |
| 29 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 25 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 30 | KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); | 26 | KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); |
| @@ -37,19 +33,33 @@ Result QueryProcessMemory(Core::System& system, VAddr memory_info_address, VAddr | |||
| 37 | auto& memory{system.Memory()}; | 33 | auto& memory{system.Memory()}; |
| 38 | const auto memory_info{process->PageTable().QueryInfo(address).GetSvcMemoryInfo()}; | 34 | const auto memory_info{process->PageTable().QueryInfo(address).GetSvcMemoryInfo()}; |
| 39 | 35 | ||
| 40 | memory.Write64(memory_info_address + 0x00, memory_info.base_address); | 36 | memory.WriteBlock(out_memory_info, &memory_info, sizeof(memory_info)); |
| 41 | memory.Write64(memory_info_address + 0x08, memory_info.size); | 37 | |
| 42 | memory.Write32(memory_info_address + 0x10, static_cast<u32>(memory_info.state) & 0xff); | 38 | //! This is supposed to be part of the QueryInfo call. |
| 43 | memory.Write32(memory_info_address + 0x14, static_cast<u32>(memory_info.attribute)); | 39 | *out_page_info = {}; |
| 44 | memory.Write32(memory_info_address + 0x18, static_cast<u32>(memory_info.permission)); | 40 | |
| 45 | memory.Write32(memory_info_address + 0x1c, memory_info.ipc_count); | 41 | R_SUCCEED(); |
| 46 | memory.Write32(memory_info_address + 0x20, memory_info.device_count); | 42 | } |
| 47 | memory.Write32(memory_info_address + 0x24, 0); | 43 | |
| 44 | Result QueryMemory64(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, | ||
| 45 | uint64_t address) { | ||
| 46 | R_RETURN(QueryMemory(system, out_memory_info, out_page_info, address)); | ||
| 47 | } | ||
| 48 | 48 | ||
| 49 | // Page info appears to be currently unused by the kernel and is always set to zero. | 49 | Result QueryProcessMemory64(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, |
| 50 | memory.Write32(page_info_address, 0); | 50 | Handle process_handle, uint64_t address) { |
| 51 | R_RETURN(QueryProcessMemory(system, out_memory_info, out_page_info, process_handle, address)); | ||
| 52 | } | ||
| 53 | |||
| 54 | Result QueryMemory64From32(Core::System& system, uint32_t out_memory_info, PageInfo* out_page_info, | ||
| 55 | uint32_t address) { | ||
| 56 | R_RETURN(QueryMemory(system, out_memory_info, out_page_info, address)); | ||
| 57 | } | ||
| 51 | 58 | ||
| 52 | return ResultSuccess; | 59 | Result QueryProcessMemory64From32(Core::System& system, uint32_t out_memory_info, |
| 60 | PageInfo* out_page_info, Handle process_handle, | ||
| 61 | uint64_t address) { | ||
| 62 | R_RETURN(QueryProcessMemory(system, out_memory_info, out_page_info, process_handle, address)); | ||
| 53 | } | 63 | } |
| 54 | 64 | ||
| 55 | } // namespace Kernel::Svc | 65 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_register.cpp b/src/core/hle/kernel/svc/svc_register.cpp index 299e22ae6..b883e6618 100644 --- a/src/core/hle/kernel/svc/svc_register.cpp +++ b/src/core/hle/kernel/svc/svc_register.cpp | |||
| @@ -2,5 +2,26 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/kernel/svc.h" | 4 | #include "core/hle/kernel/svc.h" |
| 5 | #include "core/hle/kernel/svc_results.h" | ||
| 5 | 6 | ||
| 6 | namespace Kernel::Svc {} // namespace Kernel::Svc | 7 | namespace Kernel::Svc { |
| 8 | |||
| 9 | Result ReadWriteRegister(Core::System& system, uint32_t* out, uint64_t address, uint32_t mask, | ||
| 10 | uint32_t value) { | ||
| 11 | *out = 0; | ||
| 12 | |||
| 13 | UNIMPLEMENTED(); | ||
| 14 | R_THROW(ResultNotImplemented); | ||
| 15 | } | ||
| 16 | |||
| 17 | Result ReadWriteRegister64(Core::System& system, uint32_t* out_value, uint64_t address, | ||
| 18 | uint32_t mask, uint32_t value) { | ||
| 19 | R_RETURN(ReadWriteRegister(system, out_value, address, mask, value)); | ||
| 20 | } | ||
| 21 | |||
| 22 | Result ReadWriteRegister64From32(Core::System& system, uint32_t* out_value, uint64_t address, | ||
| 23 | uint32_t mask, uint32_t value) { | ||
| 24 | R_RETURN(ReadWriteRegister(system, out_value, address, mask, value)); | ||
| 25 | } | ||
| 26 | |||
| 27 | } // namespace Kernel::Svc | ||
diff --git a/src/core/hle/kernel/svc/svc_resource_limit.cpp b/src/core/hle/kernel/svc/svc_resource_limit.cpp index 679ba10fa..ebc886028 100644 --- a/src/core/hle/kernel/svc/svc_resource_limit.cpp +++ b/src/core/hle/kernel/svc/svc_resource_limit.cpp | |||
| @@ -32,7 +32,7 @@ Result CreateResourceLimit(Core::System& system, Handle* out_handle) { | |||
| 32 | return ResultSuccess; | 32 | return ResultSuccess; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Result GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value, | 35 | Result GetResourceLimitLimitValue(Core::System& system, s64* out_limit_value, |
| 36 | Handle resource_limit_handle, LimitableResource which) { | 36 | Handle resource_limit_handle, LimitableResource which) { |
| 37 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, | 37 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, |
| 38 | which); | 38 | which); |
| @@ -52,7 +52,7 @@ Result GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value, | |||
| 52 | return ResultSuccess; | 52 | return ResultSuccess; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | Result GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value, | 55 | Result GetResourceLimitCurrentValue(Core::System& system, s64* out_current_value, |
| 56 | Handle resource_limit_handle, LimitableResource which) { | 56 | Handle resource_limit_handle, LimitableResource which) { |
| 57 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, | 57 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, |
| 58 | which); | 58 | which); |
| @@ -73,7 +73,7 @@ Result GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value | |||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle, | 75 | Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle, |
| 76 | LimitableResource which, u64 limit_value) { | 76 | LimitableResource which, s64 limit_value) { |
| 77 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}", | 77 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}", |
| 78 | resource_limit_handle, which, limit_value); | 78 | resource_limit_handle, which, limit_value); |
| 79 | 79 | ||
| @@ -92,4 +92,58 @@ Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_ha | |||
| 92 | return ResultSuccess; | 92 | return ResultSuccess; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | Result GetResourceLimitPeakValue(Core::System& system, int64_t* out_peak_value, | ||
| 96 | Handle resource_limit_handle, LimitableResource which) { | ||
| 97 | UNIMPLEMENTED(); | ||
| 98 | R_THROW(ResultNotImplemented); | ||
| 99 | } | ||
| 100 | |||
| 101 | Result GetResourceLimitLimitValue64(Core::System& system, int64_t* out_limit_value, | ||
| 102 | Handle resource_limit_handle, LimitableResource which) { | ||
| 103 | R_RETURN(GetResourceLimitLimitValue(system, out_limit_value, resource_limit_handle, which)); | ||
| 104 | } | ||
| 105 | |||
| 106 | Result GetResourceLimitCurrentValue64(Core::System& system, int64_t* out_current_value, | ||
| 107 | Handle resource_limit_handle, LimitableResource which) { | ||
| 108 | R_RETURN(GetResourceLimitCurrentValue(system, out_current_value, resource_limit_handle, which)); | ||
| 109 | } | ||
| 110 | |||
| 111 | Result GetResourceLimitPeakValue64(Core::System& system, int64_t* out_peak_value, | ||
| 112 | Handle resource_limit_handle, LimitableResource which) { | ||
| 113 | R_RETURN(GetResourceLimitPeakValue(system, out_peak_value, resource_limit_handle, which)); | ||
| 114 | } | ||
| 115 | |||
| 116 | Result CreateResourceLimit64(Core::System& system, Handle* out_handle) { | ||
| 117 | R_RETURN(CreateResourceLimit(system, out_handle)); | ||
| 118 | } | ||
| 119 | |||
| 120 | Result SetResourceLimitLimitValue64(Core::System& system, Handle resource_limit_handle, | ||
| 121 | LimitableResource which, int64_t limit_value) { | ||
| 122 | R_RETURN(SetResourceLimitLimitValue(system, resource_limit_handle, which, limit_value)); | ||
| 123 | } | ||
| 124 | |||
| 125 | Result GetResourceLimitLimitValue64From32(Core::System& system, int64_t* out_limit_value, | ||
| 126 | Handle resource_limit_handle, LimitableResource which) { | ||
| 127 | R_RETURN(GetResourceLimitLimitValue(system, out_limit_value, resource_limit_handle, which)); | ||
| 128 | } | ||
| 129 | |||
| 130 | Result GetResourceLimitCurrentValue64From32(Core::System& system, int64_t* out_current_value, | ||
| 131 | Handle resource_limit_handle, LimitableResource which) { | ||
| 132 | R_RETURN(GetResourceLimitCurrentValue(system, out_current_value, resource_limit_handle, which)); | ||
| 133 | } | ||
| 134 | |||
| 135 | Result GetResourceLimitPeakValue64From32(Core::System& system, int64_t* out_peak_value, | ||
| 136 | Handle resource_limit_handle, LimitableResource which) { | ||
| 137 | R_RETURN(GetResourceLimitPeakValue(system, out_peak_value, resource_limit_handle, which)); | ||
| 138 | } | ||
| 139 | |||
| 140 | Result CreateResourceLimit64From32(Core::System& system, Handle* out_handle) { | ||
| 141 | R_RETURN(CreateResourceLimit(system, out_handle)); | ||
| 142 | } | ||
| 143 | |||
| 144 | Result SetResourceLimitLimitValue64From32(Core::System& system, Handle resource_limit_handle, | ||
| 145 | LimitableResource which, int64_t limit_value) { | ||
| 146 | R_RETURN(SetResourceLimitLimitValue(system, resource_limit_handle, which, limit_value)); | ||
| 147 | } | ||
| 148 | |||
| 95 | } // namespace Kernel::Svc | 149 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp b/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp index 299e22ae6..20f6ec643 100644 --- a/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp +++ b/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp | |||
| @@ -1,6 +1,53 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/core.h" | ||
| 5 | #include "core/hle/kernel/physical_core.h" | ||
| 4 | #include "core/hle/kernel/svc.h" | 6 | #include "core/hle/kernel/svc.h" |
| 5 | 7 | ||
| 6 | namespace Kernel::Svc {} // namespace Kernel::Svc | 8 | namespace Kernel::Svc { |
| 9 | |||
| 10 | void CallSecureMonitor(Core::System& system, lp64::SecureMonitorArguments* args) { | ||
| 11 | UNIMPLEMENTED(); | ||
| 12 | } | ||
| 13 | |||
| 14 | void CallSecureMonitor64(Core::System& system, lp64::SecureMonitorArguments* args) { | ||
| 15 | CallSecureMonitor(system, args); | ||
| 16 | } | ||
| 17 | |||
| 18 | void CallSecureMonitor64From32(Core::System& system, ilp32::SecureMonitorArguments* args) { | ||
| 19 | // CallSecureMonitor64From32 is not supported. | ||
| 20 | UNIMPLEMENTED_MSG("CallSecureMonitor64From32"); | ||
| 21 | } | ||
| 22 | |||
| 23 | // Custom ABI for CallSecureMonitor. | ||
| 24 | |||
| 25 | void SvcWrap_CallSecureMonitor64(Core::System& system) { | ||
| 26 | auto& core = system.CurrentPhysicalCore().ArmInterface(); | ||
| 27 | lp64::SecureMonitorArguments args{}; | ||
| 28 | for (int i = 0; i < 8; i++) { | ||
| 29 | args.r[i] = core.GetReg(i); | ||
| 30 | } | ||
| 31 | |||
| 32 | CallSecureMonitor64(system, &args); | ||
| 33 | |||
| 34 | for (int i = 0; i < 8; i++) { | ||
| 35 | core.SetReg(i, args.r[i]); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | void SvcWrap_CallSecureMonitor64From32(Core::System& system) { | ||
| 40 | auto& core = system.CurrentPhysicalCore().ArmInterface(); | ||
| 41 | ilp32::SecureMonitorArguments args{}; | ||
| 42 | for (int i = 0; i < 8; i++) { | ||
| 43 | args.r[i] = static_cast<u32>(core.GetReg(i)); | ||
| 44 | } | ||
| 45 | |||
| 46 | CallSecureMonitor64From32(system, &args); | ||
| 47 | |||
| 48 | for (int i = 0; i < 8; i++) { | ||
| 49 | core.SetReg(i, args.r[i]); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | } // namespace Kernel::Svc | ||
diff --git a/src/core/hle/kernel/svc/svc_session.cpp b/src/core/hle/kernel/svc/svc_session.cpp index dac8ce33c..0deb61b62 100644 --- a/src/core/hle/kernel/svc/svc_session.cpp +++ b/src/core/hle/kernel/svc/svc_session.cpp | |||
| @@ -90,14 +90,39 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien | |||
| 90 | 90 | ||
| 91 | } // namespace | 91 | } // namespace |
| 92 | 92 | ||
| 93 | Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, u32 is_light, | 93 | Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, bool is_light, |
| 94 | u64 name) { | 94 | u64 name) { |
| 95 | if (is_light) { | 95 | if (is_light) { |
| 96 | // return CreateSession<KLightSession>(system, out_server, out_client, name); | 96 | // return CreateSession<KLightSession>(system, out_server, out_client, name); |
| 97 | return ResultUnknown; | 97 | return ResultNotImplemented; |
| 98 | } else { | 98 | } else { |
| 99 | return CreateSession<KSession>(system, out_server, out_client, name); | 99 | return CreateSession<KSession>(system, out_server, out_client, name); |
| 100 | } | 100 | } |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | Result AcceptSession(Core::System& system, Handle* out_handle, Handle port_handle) { | ||
| 104 | UNIMPLEMENTED(); | ||
| 105 | R_THROW(ResultNotImplemented); | ||
| 106 | } | ||
| 107 | |||
| 108 | Result CreateSession64(Core::System& system, Handle* out_server_session_handle, | ||
| 109 | Handle* out_client_session_handle, bool is_light, uint64_t name) { | ||
| 110 | R_RETURN(CreateSession(system, out_server_session_handle, out_client_session_handle, is_light, | ||
| 111 | name)); | ||
| 112 | } | ||
| 113 | |||
| 114 | Result AcceptSession64(Core::System& system, Handle* out_handle, Handle port) { | ||
| 115 | R_RETURN(AcceptSession(system, out_handle, port)); | ||
| 116 | } | ||
| 117 | |||
| 118 | Result CreateSession64From32(Core::System& system, Handle* out_server_session_handle, | ||
| 119 | Handle* out_client_session_handle, bool is_light, uint32_t name) { | ||
| 120 | R_RETURN(CreateSession(system, out_server_session_handle, out_client_session_handle, is_light, | ||
| 121 | name)); | ||
| 122 | } | ||
| 123 | |||
| 124 | Result AcceptSession64From32(Core::System& system, Handle* out_handle, Handle port) { | ||
| 125 | R_RETURN(AcceptSession(system, out_handle, port)); | ||
| 126 | } | ||
| 127 | |||
| 103 | } // namespace Kernel::Svc | 128 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_shared_memory.cpp b/src/core/hle/kernel/svc/svc_shared_memory.cpp index d465bcbe7..40d6260e3 100644 --- a/src/core/hle/kernel/svc/svc_shared_memory.cpp +++ b/src/core/hle/kernel/svc/svc_shared_memory.cpp | |||
| @@ -67,11 +67,6 @@ Result MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, | |||
| 67 | return ResultSuccess; | 67 | return ResultSuccess; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | Result MapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, u32 size, | ||
| 71 | Svc::MemoryPermission map_perm) { | ||
| 72 | return MapSharedMemory(system, shmem_handle, address, size, map_perm); | ||
| 73 | } | ||
| 74 | |||
| 75 | Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, u64 size) { | 70 | Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, u64 size) { |
| 76 | // Validate the address/size. | 71 | // Validate the address/size. |
| 77 | R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress); | 72 | R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress); |
| @@ -99,8 +94,40 @@ Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr addres | |||
| 99 | return ResultSuccess; | 94 | return ResultSuccess; |
| 100 | } | 95 | } |
| 101 | 96 | ||
| 102 | Result UnmapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, u32 size) { | 97 | Result CreateSharedMemory(Core::System& system, Handle* out_handle, uint64_t size, |
| 103 | return UnmapSharedMemory(system, shmem_handle, address, size); | 98 | MemoryPermission owner_perm, MemoryPermission remote_perm) { |
| 99 | UNIMPLEMENTED(); | ||
| 100 | R_THROW(ResultNotImplemented); | ||
| 101 | } | ||
| 102 | |||
| 103 | Result MapSharedMemory64(Core::System& system, Handle shmem_handle, uint64_t address, uint64_t size, | ||
| 104 | MemoryPermission map_perm) { | ||
| 105 | R_RETURN(MapSharedMemory(system, shmem_handle, address, size, map_perm)); | ||
| 106 | } | ||
| 107 | |||
| 108 | Result UnmapSharedMemory64(Core::System& system, Handle shmem_handle, uint64_t address, | ||
| 109 | uint64_t size) { | ||
| 110 | R_RETURN(UnmapSharedMemory(system, shmem_handle, address, size)); | ||
| 111 | } | ||
| 112 | |||
| 113 | Result CreateSharedMemory64(Core::System& system, Handle* out_handle, uint64_t size, | ||
| 114 | MemoryPermission owner_perm, MemoryPermission remote_perm) { | ||
| 115 | R_RETURN(CreateSharedMemory(system, out_handle, size, owner_perm, remote_perm)); | ||
| 116 | } | ||
| 117 | |||
| 118 | Result MapSharedMemory64From32(Core::System& system, Handle shmem_handle, uint32_t address, | ||
| 119 | uint32_t size, MemoryPermission map_perm) { | ||
| 120 | R_RETURN(MapSharedMemory(system, shmem_handle, address, size, map_perm)); | ||
| 121 | } | ||
| 122 | |||
| 123 | Result UnmapSharedMemory64From32(Core::System& system, Handle shmem_handle, uint32_t address, | ||
| 124 | uint32_t size) { | ||
| 125 | R_RETURN(UnmapSharedMemory(system, shmem_handle, address, size)); | ||
| 126 | } | ||
| 127 | |||
| 128 | Result CreateSharedMemory64From32(Core::System& system, Handle* out_handle, uint32_t size, | ||
| 129 | MemoryPermission owner_perm, MemoryPermission remote_perm) { | ||
| 130 | R_RETURN(CreateSharedMemory(system, out_handle, size, owner_perm, remote_perm)); | ||
| 104 | } | 131 | } |
| 105 | 132 | ||
| 106 | } // namespace Kernel::Svc | 133 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_synchronization.cpp b/src/core/hle/kernel/svc/svc_synchronization.cpp index 1bf6a612a..e516a3800 100644 --- a/src/core/hle/kernel/svc/svc_synchronization.cpp +++ b/src/core/hle/kernel/svc/svc_synchronization.cpp | |||
| @@ -20,10 +20,6 @@ Result CloseHandle(Core::System& system, Handle handle) { | |||
| 20 | return ResultSuccess; | 20 | return ResultSuccess; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | Result CloseHandle32(Core::System& system, Handle handle) { | ||
| 24 | return CloseHandle(system, handle); | ||
| 25 | } | ||
| 26 | |||
| 27 | /// Clears the signaled state of an event or process. | 23 | /// Clears the signaled state of an event or process. |
| 28 | Result ResetSignal(Core::System& system, Handle handle) { | 24 | Result ResetSignal(Core::System& system, Handle handle) { |
| 29 | LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); | 25 | LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); |
| @@ -52,10 +48,6 @@ Result ResetSignal(Core::System& system, Handle handle) { | |||
| 52 | return ResultInvalidHandle; | 48 | return ResultInvalidHandle; |
| 53 | } | 49 | } |
| 54 | 50 | ||
| 55 | Result ResetSignal32(Core::System& system, Handle handle) { | ||
| 56 | return ResetSignal(system, handle); | ||
| 57 | } | ||
| 58 | |||
| 59 | /// Wait for the given handles to synchronize, timeout after the specified nanoseconds | 51 | /// Wait for the given handles to synchronize, timeout after the specified nanoseconds |
| 60 | Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_address, s32 num_handles, | 52 | Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_address, s32 num_handles, |
| 61 | s64 nano_seconds) { | 53 | s64 nano_seconds) { |
| @@ -93,12 +85,6 @@ Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_addre | |||
| 93 | nano_seconds); | 85 | nano_seconds); |
| 94 | } | 86 | } |
| 95 | 87 | ||
| 96 | Result WaitSynchronization32(Core::System& system, u32 timeout_low, u32 handles_address, | ||
| 97 | s32 num_handles, u32 timeout_high, s32* index) { | ||
| 98 | const s64 nano_seconds{(static_cast<s64>(timeout_high) << 32) | static_cast<s64>(timeout_low)}; | ||
| 99 | return WaitSynchronization(system, index, handles_address, num_handles, nano_seconds); | ||
| 100 | } | ||
| 101 | |||
| 102 | /// Resumes a thread waiting on WaitSynchronization | 88 | /// Resumes a thread waiting on WaitSynchronization |
| 103 | Result CancelSynchronization(Core::System& system, Handle handle) { | 89 | Result CancelSynchronization(Core::System& system, Handle handle) { |
| 104 | LOG_TRACE(Kernel_SVC, "called handle=0x{:X}", handle); | 90 | LOG_TRACE(Kernel_SVC, "called handle=0x{:X}", handle); |
| @@ -113,10 +99,6 @@ Result CancelSynchronization(Core::System& system, Handle handle) { | |||
| 113 | return ResultSuccess; | 99 | return ResultSuccess; |
| 114 | } | 100 | } |
| 115 | 101 | ||
| 116 | Result CancelSynchronization32(Core::System& system, Handle handle) { | ||
| 117 | return CancelSynchronization(system, handle); | ||
| 118 | } | ||
| 119 | |||
| 120 | void SynchronizePreemptionState(Core::System& system) { | 102 | void SynchronizePreemptionState(Core::System& system) { |
| 121 | auto& kernel = system.Kernel(); | 103 | auto& kernel = system.Kernel(); |
| 122 | 104 | ||
| @@ -136,4 +118,46 @@ void SynchronizePreemptionState(Core::System& system) { | |||
| 136 | } | 118 | } |
| 137 | } | 119 | } |
| 138 | 120 | ||
| 121 | Result CloseHandle64(Core::System& system, Handle handle) { | ||
| 122 | R_RETURN(CloseHandle(system, handle)); | ||
| 123 | } | ||
| 124 | |||
| 125 | Result ResetSignal64(Core::System& system, Handle handle) { | ||
| 126 | R_RETURN(ResetSignal(system, handle)); | ||
| 127 | } | ||
| 128 | |||
| 129 | Result WaitSynchronization64(Core::System& system, int32_t* out_index, uint64_t handles, | ||
| 130 | int32_t num_handles, int64_t timeout_ns) { | ||
| 131 | R_RETURN(WaitSynchronization(system, out_index, handles, num_handles, timeout_ns)); | ||
| 132 | } | ||
| 133 | |||
| 134 | Result CancelSynchronization64(Core::System& system, Handle handle) { | ||
| 135 | R_RETURN(CancelSynchronization(system, handle)); | ||
| 136 | } | ||
| 137 | |||
| 138 | void SynchronizePreemptionState64(Core::System& system) { | ||
| 139 | SynchronizePreemptionState(system); | ||
| 140 | } | ||
| 141 | |||
| 142 | Result CloseHandle64From32(Core::System& system, Handle handle) { | ||
| 143 | R_RETURN(CloseHandle(system, handle)); | ||
| 144 | } | ||
| 145 | |||
| 146 | Result ResetSignal64From32(Core::System& system, Handle handle) { | ||
| 147 | R_RETURN(ResetSignal(system, handle)); | ||
| 148 | } | ||
| 149 | |||
| 150 | Result WaitSynchronization64From32(Core::System& system, int32_t* out_index, uint32_t handles, | ||
| 151 | int32_t num_handles, int64_t timeout_ns) { | ||
| 152 | R_RETURN(WaitSynchronization(system, out_index, handles, num_handles, timeout_ns)); | ||
| 153 | } | ||
| 154 | |||
| 155 | Result CancelSynchronization64From32(Core::System& system, Handle handle) { | ||
| 156 | R_RETURN(CancelSynchronization(system, handle)); | ||
| 157 | } | ||
| 158 | |||
| 159 | void SynchronizePreemptionState64From32(Core::System& system) { | ||
| 160 | SynchronizePreemptionState(system); | ||
| 161 | } | ||
| 162 | |||
| 139 | } // namespace Kernel::Svc | 163 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_thread.cpp b/src/core/hle/kernel/svc/svc_thread.cpp index dd9f8e8b1..3e325c998 100644 --- a/src/core/hle/kernel/svc/svc_thread.cpp +++ b/src/core/hle/kernel/svc/svc_thread.cpp | |||
| @@ -20,7 +20,7 @@ constexpr bool IsValidVirtualCoreId(int32_t core_id) { | |||
| 20 | 20 | ||
| 21 | /// Creates a new thread | 21 | /// Creates a new thread |
| 22 | Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg, | 22 | Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg, |
| 23 | VAddr stack_bottom, u32 priority, s32 core_id) { | 23 | VAddr stack_bottom, s32 priority, s32 core_id) { |
| 24 | LOG_DEBUG(Kernel_SVC, | 24 | LOG_DEBUG(Kernel_SVC, |
| 25 | "called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, " | 25 | "called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, " |
| 26 | "priority=0x{:08X}, core_id=0x{:08X}", | 26 | "priority=0x{:08X}, core_id=0x{:08X}", |
| @@ -91,11 +91,6 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, | |||
| 91 | return ResultSuccess; | 91 | return ResultSuccess; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | Result CreateThread32(Core::System& system, Handle* out_handle, u32 priority, u32 entry_point, | ||
| 95 | u32 arg, u32 stack_top, s32 processor_id) { | ||
| 96 | return CreateThread(system, out_handle, entry_point, arg, stack_top, priority, processor_id); | ||
| 97 | } | ||
| 98 | |||
| 99 | /// Starts the thread for the provided handle | 94 | /// Starts the thread for the provided handle |
| 100 | Result StartThread(Core::System& system, Handle thread_handle) { | 95 | Result StartThread(Core::System& system, Handle thread_handle) { |
| 101 | LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); | 96 | LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); |
| @@ -115,10 +110,6 @@ Result StartThread(Core::System& system, Handle thread_handle) { | |||
| 115 | return ResultSuccess; | 110 | return ResultSuccess; |
| 116 | } | 111 | } |
| 117 | 112 | ||
| 118 | Result StartThread32(Core::System& system, Handle thread_handle) { | ||
| 119 | return StartThread(system, thread_handle); | ||
| 120 | } | ||
| 121 | |||
| 122 | /// Called when a thread exits | 113 | /// Called when a thread exits |
| 123 | void ExitThread(Core::System& system) { | 114 | void ExitThread(Core::System& system) { |
| 124 | LOG_DEBUG(Kernel_SVC, "called, pc=0x{:08X}", system.CurrentArmInterface().GetPC()); | 115 | LOG_DEBUG(Kernel_SVC, "called, pc=0x{:08X}", system.CurrentArmInterface().GetPC()); |
| @@ -129,10 +120,6 @@ void ExitThread(Core::System& system) { | |||
| 129 | system.Kernel().UnregisterInUseObject(current_thread); | 120 | system.Kernel().UnregisterInUseObject(current_thread); |
| 130 | } | 121 | } |
| 131 | 122 | ||
| 132 | void ExitThread32(Core::System& system) { | ||
| 133 | ExitThread(system); | ||
| 134 | } | ||
| 135 | |||
| 136 | /// Sleep the current thread | 123 | /// Sleep the current thread |
| 137 | void SleepThread(Core::System& system, s64 nanoseconds) { | 124 | void SleepThread(Core::System& system, s64 nanoseconds) { |
| 138 | auto& kernel = system.Kernel(); | 125 | auto& kernel = system.Kernel(); |
| @@ -160,13 +147,8 @@ void SleepThread(Core::System& system, s64 nanoseconds) { | |||
| 160 | } | 147 | } |
| 161 | } | 148 | } |
| 162 | 149 | ||
| 163 | void SleepThread32(Core::System& system, u32 nanoseconds_low, u32 nanoseconds_high) { | ||
| 164 | const auto nanoseconds = static_cast<s64>(u64{nanoseconds_low} | (u64{nanoseconds_high} << 32)); | ||
| 165 | SleepThread(system, nanoseconds); | ||
| 166 | } | ||
| 167 | |||
| 168 | /// Gets the thread context | 150 | /// Gets the thread context |
| 169 | Result GetThreadContext(Core::System& system, VAddr out_context, Handle thread_handle) { | 151 | Result GetThreadContext3(Core::System& system, VAddr out_context, Handle thread_handle) { |
| 170 | LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context, | 152 | LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context, |
| 171 | thread_handle); | 153 | thread_handle); |
| 172 | 154 | ||
| @@ -223,12 +205,8 @@ Result GetThreadContext(Core::System& system, VAddr out_context, Handle thread_h | |||
| 223 | return ResultSuccess; | 205 | return ResultSuccess; |
| 224 | } | 206 | } |
| 225 | 207 | ||
| 226 | Result GetThreadContext32(Core::System& system, u32 out_context, Handle thread_handle) { | ||
| 227 | return GetThreadContext(system, out_context, thread_handle); | ||
| 228 | } | ||
| 229 | |||
| 230 | /// Gets the priority for the specified thread | 208 | /// Gets the priority for the specified thread |
| 231 | Result GetThreadPriority(Core::System& system, u32* out_priority, Handle handle) { | 209 | Result GetThreadPriority(Core::System& system, s32* out_priority, Handle handle) { |
| 232 | LOG_TRACE(Kernel_SVC, "called"); | 210 | LOG_TRACE(Kernel_SVC, "called"); |
| 233 | 211 | ||
| 234 | // Get the thread from its handle. | 212 | // Get the thread from its handle. |
| @@ -241,12 +219,8 @@ Result GetThreadPriority(Core::System& system, u32* out_priority, Handle handle) | |||
| 241 | return ResultSuccess; | 219 | return ResultSuccess; |
| 242 | } | 220 | } |
| 243 | 221 | ||
| 244 | Result GetThreadPriority32(Core::System& system, u32* out_priority, Handle handle) { | ||
| 245 | return GetThreadPriority(system, out_priority, handle); | ||
| 246 | } | ||
| 247 | |||
| 248 | /// Sets the priority for the specified thread | 222 | /// Sets the priority for the specified thread |
| 249 | Result SetThreadPriority(Core::System& system, Handle thread_handle, u32 priority) { | 223 | Result SetThreadPriority(Core::System& system, Handle thread_handle, s32 priority) { |
| 250 | // Get the current process. | 224 | // Get the current process. |
| 251 | KProcess& process = *system.Kernel().CurrentProcess(); | 225 | KProcess& process = *system.Kernel().CurrentProcess(); |
| 252 | 226 | ||
| @@ -264,12 +238,8 @@ Result SetThreadPriority(Core::System& system, Handle thread_handle, u32 priorit | |||
| 264 | return ResultSuccess; | 238 | return ResultSuccess; |
| 265 | } | 239 | } |
| 266 | 240 | ||
| 267 | Result SetThreadPriority32(Core::System& system, Handle thread_handle, u32 priority) { | 241 | Result GetThreadList(Core::System& system, s32* out_num_threads, VAddr out_thread_ids, |
| 268 | return SetThreadPriority(system, thread_handle, priority); | 242 | s32 out_thread_ids_size, Handle debug_handle) { |
| 269 | } | ||
| 270 | |||
| 271 | Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_thread_ids, | ||
| 272 | u32 out_thread_ids_size, Handle debug_handle) { | ||
| 273 | // TODO: Handle this case when debug events are supported. | 243 | // TODO: Handle this case when debug events are supported. |
| 274 | UNIMPLEMENTED_IF(debug_handle != InvalidHandle); | 244 | UNIMPLEMENTED_IF(debug_handle != InvalidHandle); |
| 275 | 245 | ||
| @@ -296,7 +266,7 @@ Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_threa | |||
| 296 | auto& memory = system.Memory(); | 266 | auto& memory = system.Memory(); |
| 297 | const auto& thread_list = current_process->GetThreadList(); | 267 | const auto& thread_list = current_process->GetThreadList(); |
| 298 | const auto num_threads = thread_list.size(); | 268 | const auto num_threads = thread_list.size(); |
| 299 | const auto copy_amount = std::min(std::size_t{out_thread_ids_size}, num_threads); | 269 | const auto copy_amount = std::min(static_cast<std::size_t>(out_thread_ids_size), num_threads); |
| 300 | 270 | ||
| 301 | auto list_iter = thread_list.cbegin(); | 271 | auto list_iter = thread_list.cbegin(); |
| 302 | for (std::size_t i = 0; i < copy_amount; ++i, ++list_iter) { | 272 | for (std::size_t i = 0; i < copy_amount; ++i, ++list_iter) { |
| @@ -308,8 +278,8 @@ Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_threa | |||
| 308 | return ResultSuccess; | 278 | return ResultSuccess; |
| 309 | } | 279 | } |
| 310 | 280 | ||
| 311 | Result GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_core_id, | 281 | Result GetThreadCoreMask(Core::System& system, s32* out_core_id, u64* out_affinity_mask, |
| 312 | u64* out_affinity_mask) { | 282 | Handle thread_handle) { |
| 313 | LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); | 283 | LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); |
| 314 | 284 | ||
| 315 | // Get the thread from its handle. | 285 | // Get the thread from its handle. |
| @@ -323,15 +293,6 @@ Result GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_co | |||
| 323 | return ResultSuccess; | 293 | return ResultSuccess; |
| 324 | } | 294 | } |
| 325 | 295 | ||
| 326 | Result GetThreadCoreMask32(Core::System& system, Handle thread_handle, s32* out_core_id, | ||
| 327 | u32* out_affinity_mask_low, u32* out_affinity_mask_high) { | ||
| 328 | u64 out_affinity_mask{}; | ||
| 329 | const auto result = GetThreadCoreMask(system, thread_handle, out_core_id, &out_affinity_mask); | ||
| 330 | *out_affinity_mask_high = static_cast<u32>(out_affinity_mask >> 32); | ||
| 331 | *out_affinity_mask_low = static_cast<u32>(out_affinity_mask); | ||
| 332 | return result; | ||
| 333 | } | ||
| 334 | |||
| 335 | Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id, | 296 | Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id, |
| 336 | u64 affinity_mask) { | 297 | u64 affinity_mask) { |
| 337 | // Determine the core id/affinity mask. | 298 | // Determine the core id/affinity mask. |
| @@ -364,12 +325,6 @@ Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id | |||
| 364 | return ResultSuccess; | 325 | return ResultSuccess; |
| 365 | } | 326 | } |
| 366 | 327 | ||
| 367 | Result SetThreadCoreMask32(Core::System& system, Handle thread_handle, s32 core_id, | ||
| 368 | u32 affinity_mask_low, u32 affinity_mask_high) { | ||
| 369 | const auto affinity_mask = u64{affinity_mask_low} | (u64{affinity_mask_high} << 32); | ||
| 370 | return SetThreadCoreMask(system, thread_handle, core_id, affinity_mask); | ||
| 371 | } | ||
| 372 | |||
| 373 | /// Get the ID for the specified thread. | 328 | /// Get the ID for the specified thread. |
| 374 | Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) { | 329 | Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) { |
| 375 | // Get the thread from its handle. | 330 | // Get the thread from its handle. |
| @@ -382,15 +337,101 @@ Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handl | |||
| 382 | return ResultSuccess; | 337 | return ResultSuccess; |
| 383 | } | 338 | } |
| 384 | 339 | ||
| 385 | Result GetThreadId32(Core::System& system, u32* out_thread_id_low, u32* out_thread_id_high, | 340 | Result CreateThread64(Core::System& system, Handle* out_handle, uint64_t func, uint64_t arg, |
| 386 | Handle thread_handle) { | 341 | uint64_t stack_bottom, int32_t priority, int32_t core_id) { |
| 387 | u64 out_thread_id{}; | 342 | R_RETURN(CreateThread(system, out_handle, func, arg, stack_bottom, priority, core_id)); |
| 388 | const Result result{GetThreadId(system, &out_thread_id, thread_handle)}; | 343 | } |
| 344 | |||
| 345 | Result StartThread64(Core::System& system, Handle thread_handle) { | ||
| 346 | R_RETURN(StartThread(system, thread_handle)); | ||
| 347 | } | ||
| 348 | |||
| 349 | void ExitThread64(Core::System& system) { | ||
| 350 | return ExitThread(system); | ||
| 351 | } | ||
| 352 | |||
| 353 | void SleepThread64(Core::System& system, int64_t ns) { | ||
| 354 | return SleepThread(system, ns); | ||
| 355 | } | ||
| 356 | |||
| 357 | Result GetThreadPriority64(Core::System& system, int32_t* out_priority, Handle thread_handle) { | ||
| 358 | R_RETURN(GetThreadPriority(system, out_priority, thread_handle)); | ||
| 359 | } | ||
| 360 | |||
| 361 | Result SetThreadPriority64(Core::System& system, Handle thread_handle, int32_t priority) { | ||
| 362 | R_RETURN(SetThreadPriority(system, thread_handle, priority)); | ||
| 363 | } | ||
| 364 | |||
| 365 | Result GetThreadCoreMask64(Core::System& system, int32_t* out_core_id, uint64_t* out_affinity_mask, | ||
| 366 | Handle thread_handle) { | ||
| 367 | R_RETURN(GetThreadCoreMask(system, out_core_id, out_affinity_mask, thread_handle)); | ||
| 368 | } | ||
| 369 | |||
| 370 | Result SetThreadCoreMask64(Core::System& system, Handle thread_handle, int32_t core_id, | ||
| 371 | uint64_t affinity_mask) { | ||
| 372 | R_RETURN(SetThreadCoreMask(system, thread_handle, core_id, affinity_mask)); | ||
| 373 | } | ||
| 374 | |||
| 375 | Result GetThreadId64(Core::System& system, uint64_t* out_thread_id, Handle thread_handle) { | ||
| 376 | R_RETURN(GetThreadId(system, out_thread_id, thread_handle)); | ||
| 377 | } | ||
| 378 | |||
| 379 | Result GetThreadContext364(Core::System& system, uint64_t out_context, Handle thread_handle) { | ||
| 380 | R_RETURN(GetThreadContext3(system, out_context, thread_handle)); | ||
| 381 | } | ||
| 389 | 382 | ||
| 390 | *out_thread_id_low = static_cast<u32>(out_thread_id >> 32); | 383 | Result GetThreadList64(Core::System& system, int32_t* out_num_threads, uint64_t out_thread_ids, |
| 391 | *out_thread_id_high = static_cast<u32>(out_thread_id & std::numeric_limits<u32>::max()); | 384 | int32_t max_out_count, Handle debug_handle) { |
| 385 | R_RETURN(GetThreadList(system, out_num_threads, out_thread_ids, max_out_count, debug_handle)); | ||
| 386 | } | ||
| 387 | |||
| 388 | Result CreateThread64From32(Core::System& system, Handle* out_handle, uint32_t func, uint32_t arg, | ||
| 389 | uint32_t stack_bottom, int32_t priority, int32_t core_id) { | ||
| 390 | R_RETURN(CreateThread(system, out_handle, func, arg, stack_bottom, priority, core_id)); | ||
| 391 | } | ||
| 392 | |||
| 393 | Result StartThread64From32(Core::System& system, Handle thread_handle) { | ||
| 394 | R_RETURN(StartThread(system, thread_handle)); | ||
| 395 | } | ||
| 396 | |||
| 397 | void ExitThread64From32(Core::System& system) { | ||
| 398 | return ExitThread(system); | ||
| 399 | } | ||
| 400 | |||
| 401 | void SleepThread64From32(Core::System& system, int64_t ns) { | ||
| 402 | return SleepThread(system, ns); | ||
| 403 | } | ||
| 404 | |||
| 405 | Result GetThreadPriority64From32(Core::System& system, int32_t* out_priority, | ||
| 406 | Handle thread_handle) { | ||
| 407 | R_RETURN(GetThreadPriority(system, out_priority, thread_handle)); | ||
| 408 | } | ||
| 409 | |||
| 410 | Result SetThreadPriority64From32(Core::System& system, Handle thread_handle, int32_t priority) { | ||
| 411 | R_RETURN(SetThreadPriority(system, thread_handle, priority)); | ||
| 412 | } | ||
| 413 | |||
| 414 | Result GetThreadCoreMask64From32(Core::System& system, int32_t* out_core_id, | ||
| 415 | uint64_t* out_affinity_mask, Handle thread_handle) { | ||
| 416 | R_RETURN(GetThreadCoreMask(system, out_core_id, out_affinity_mask, thread_handle)); | ||
| 417 | } | ||
| 418 | |||
| 419 | Result SetThreadCoreMask64From32(Core::System& system, Handle thread_handle, int32_t core_id, | ||
| 420 | uint64_t affinity_mask) { | ||
| 421 | R_RETURN(SetThreadCoreMask(system, thread_handle, core_id, affinity_mask)); | ||
| 422 | } | ||
| 423 | |||
| 424 | Result GetThreadId64From32(Core::System& system, uint64_t* out_thread_id, Handle thread_handle) { | ||
| 425 | R_RETURN(GetThreadId(system, out_thread_id, thread_handle)); | ||
| 426 | } | ||
| 427 | |||
| 428 | Result GetThreadContext364From32(Core::System& system, uint32_t out_context, Handle thread_handle) { | ||
| 429 | R_RETURN(GetThreadContext3(system, out_context, thread_handle)); | ||
| 430 | } | ||
| 392 | 431 | ||
| 393 | return result; | 432 | Result GetThreadList64From32(Core::System& system, int32_t* out_num_threads, |
| 433 | uint32_t out_thread_ids, int32_t max_out_count, Handle debug_handle) { | ||
| 434 | R_RETURN(GetThreadList(system, out_num_threads, out_thread_ids, max_out_count, debug_handle)); | ||
| 394 | } | 435 | } |
| 395 | 436 | ||
| 396 | } // namespace Kernel::Svc | 437 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_thread_profiler.cpp b/src/core/hle/kernel/svc/svc_thread_profiler.cpp index 299e22ae6..40de7708b 100644 --- a/src/core/hle/kernel/svc/svc_thread_profiler.cpp +++ b/src/core/hle/kernel/svc/svc_thread_profiler.cpp | |||
| @@ -2,5 +2,59 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/kernel/svc.h" | 4 | #include "core/hle/kernel/svc.h" |
| 5 | #include "core/hle/kernel/svc_results.h" | ||
| 5 | 6 | ||
| 6 | namespace Kernel::Svc {} // namespace Kernel::Svc | 7 | namespace Kernel::Svc { |
| 8 | |||
| 9 | Result GetDebugFutureThreadInfo(Core::System& system, lp64::LastThreadContext* out_context, | ||
| 10 | uint64_t* out_thread_id, Handle debug_handle, int64_t ns) { | ||
| 11 | UNIMPLEMENTED(); | ||
| 12 | R_THROW(ResultNotImplemented); | ||
| 13 | } | ||
| 14 | |||
| 15 | Result GetLastThreadInfo(Core::System& system, lp64::LastThreadContext* out_context, | ||
| 16 | uint64_t* out_tls_address, uint32_t* out_flags) { | ||
| 17 | UNIMPLEMENTED(); | ||
| 18 | R_THROW(ResultNotImplemented); | ||
| 19 | } | ||
| 20 | |||
| 21 | Result GetDebugFutureThreadInfo64(Core::System& system, lp64::LastThreadContext* out_context, | ||
| 22 | uint64_t* out_thread_id, Handle debug_handle, int64_t ns) { | ||
| 23 | R_RETURN(GetDebugFutureThreadInfo(system, out_context, out_thread_id, debug_handle, ns)); | ||
| 24 | } | ||
| 25 | |||
| 26 | Result GetLastThreadInfo64(Core::System& system, lp64::LastThreadContext* out_context, | ||
| 27 | uint64_t* out_tls_address, uint32_t* out_flags) { | ||
| 28 | R_RETURN(GetLastThreadInfo(system, out_context, out_tls_address, out_flags)); | ||
| 29 | } | ||
| 30 | |||
| 31 | Result GetDebugFutureThreadInfo64From32(Core::System& system, ilp32::LastThreadContext* out_context, | ||
| 32 | uint64_t* out_thread_id, Handle debug_handle, int64_t ns) { | ||
| 33 | lp64::LastThreadContext context{}; | ||
| 34 | R_TRY( | ||
| 35 | GetDebugFutureThreadInfo(system, std::addressof(context), out_thread_id, debug_handle, ns)); | ||
| 36 | |||
| 37 | *out_context = { | ||
| 38 | .fp = static_cast<u32>(context.fp), | ||
| 39 | .sp = static_cast<u32>(context.sp), | ||
| 40 | .lr = static_cast<u32>(context.lr), | ||
| 41 | .pc = static_cast<u32>(context.pc), | ||
| 42 | }; | ||
| 43 | R_SUCCEED(); | ||
| 44 | } | ||
| 45 | |||
| 46 | Result GetLastThreadInfo64From32(Core::System& system, ilp32::LastThreadContext* out_context, | ||
| 47 | uint64_t* out_tls_address, uint32_t* out_flags) { | ||
| 48 | lp64::LastThreadContext context{}; | ||
| 49 | R_TRY(GetLastThreadInfo(system, std::addressof(context), out_tls_address, out_flags)); | ||
| 50 | |||
| 51 | *out_context = { | ||
| 52 | .fp = static_cast<u32>(context.fp), | ||
| 53 | .sp = static_cast<u32>(context.sp), | ||
| 54 | .lr = static_cast<u32>(context.lr), | ||
| 55 | .pc = static_cast<u32>(context.pc), | ||
| 56 | }; | ||
| 57 | R_SUCCEED(); | ||
| 58 | } | ||
| 59 | |||
| 60 | } // namespace Kernel::Svc | ||
diff --git a/src/core/hle/kernel/svc/svc_tick.cpp b/src/core/hle/kernel/svc/svc_tick.cpp index e9b4fd5a6..561336482 100644 --- a/src/core/hle/kernel/svc/svc_tick.cpp +++ b/src/core/hle/kernel/svc/svc_tick.cpp | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | namespace Kernel::Svc { | 9 | namespace Kernel::Svc { |
| 10 | 10 | ||
| 11 | /// This returns the total CPU ticks elapsed since the CPU was powered-on | 11 | /// This returns the total CPU ticks elapsed since the CPU was powered-on |
| 12 | u64 GetSystemTick(Core::System& system) { | 12 | int64_t GetSystemTick(Core::System& system) { |
| 13 | LOG_TRACE(Kernel_SVC, "called"); | 13 | LOG_TRACE(Kernel_SVC, "called"); |
| 14 | 14 | ||
| 15 | auto& core_timing = system.CoreTiming(); | 15 | auto& core_timing = system.CoreTiming(); |
| @@ -21,13 +21,15 @@ u64 GetSystemTick(Core::System& system) { | |||
| 21 | core_timing.AddTicks(400U); | 21 | core_timing.AddTicks(400U); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | return result; | 24 | return static_cast<int64_t>(result); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | void GetSystemTick32(Core::System& system, u32* time_low, u32* time_high) { | 27 | int64_t GetSystemTick64(Core::System& system) { |
| 28 | const auto time = GetSystemTick(system); | 28 | return GetSystemTick(system); |
| 29 | *time_low = static_cast<u32>(time); | 29 | } |
| 30 | *time_high = static_cast<u32>(time >> 32); | 30 | |
| 31 | int64_t GetSystemTick64From32(Core::System& system) { | ||
| 32 | return GetSystemTick(system); | ||
| 31 | } | 33 | } |
| 32 | 34 | ||
| 33 | } // namespace Kernel::Svc | 35 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc/svc_transfer_memory.cpp b/src/core/hle/kernel/svc/svc_transfer_memory.cpp index b14ae24a1..a4c040e49 100644 --- a/src/core/hle/kernel/svc/svc_transfer_memory.cpp +++ b/src/core/hle/kernel/svc/svc_transfer_memory.cpp | |||
| @@ -72,8 +72,46 @@ Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u6 | |||
| 72 | return ResultSuccess; | 72 | return ResultSuccess; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | Result CreateTransferMemory32(Core::System& system, Handle* out, u32 address, u32 size, | 75 | Result MapTransferMemory(Core::System& system, Handle trmem_handle, uint64_t address, uint64_t size, |
| 76 | MemoryPermission map_perm) { | 76 | MemoryPermission owner_perm) { |
| 77 | return CreateTransferMemory(system, out, address, size, map_perm); | 77 | UNIMPLEMENTED(); |
| 78 | R_THROW(ResultNotImplemented); | ||
| 78 | } | 79 | } |
| 80 | |||
| 81 | Result UnmapTransferMemory(Core::System& system, Handle trmem_handle, uint64_t address, | ||
| 82 | uint64_t size) { | ||
| 83 | UNIMPLEMENTED(); | ||
| 84 | R_THROW(ResultNotImplemented); | ||
| 85 | } | ||
| 86 | |||
| 87 | Result MapTransferMemory64(Core::System& system, Handle trmem_handle, uint64_t address, | ||
| 88 | uint64_t size, MemoryPermission owner_perm) { | ||
| 89 | R_RETURN(MapTransferMemory(system, trmem_handle, address, size, owner_perm)); | ||
| 90 | } | ||
| 91 | |||
| 92 | Result UnmapTransferMemory64(Core::System& system, Handle trmem_handle, uint64_t address, | ||
| 93 | uint64_t size) { | ||
| 94 | R_RETURN(UnmapTransferMemory(system, trmem_handle, address, size)); | ||
| 95 | } | ||
| 96 | |||
| 97 | Result CreateTransferMemory64(Core::System& system, Handle* out_handle, uint64_t address, | ||
| 98 | uint64_t size, MemoryPermission map_perm) { | ||
| 99 | R_RETURN(CreateTransferMemory(system, out_handle, address, size, map_perm)); | ||
| 100 | } | ||
| 101 | |||
| 102 | Result MapTransferMemory64From32(Core::System& system, Handle trmem_handle, uint32_t address, | ||
| 103 | uint32_t size, MemoryPermission owner_perm) { | ||
| 104 | R_RETURN(MapTransferMemory(system, trmem_handle, address, size, owner_perm)); | ||
| 105 | } | ||
| 106 | |||
| 107 | Result UnmapTransferMemory64From32(Core::System& system, Handle trmem_handle, uint32_t address, | ||
| 108 | uint32_t size) { | ||
| 109 | R_RETURN(UnmapTransferMemory(system, trmem_handle, address, size)); | ||
| 110 | } | ||
| 111 | |||
| 112 | Result CreateTransferMemory64From32(Core::System& system, Handle* out_handle, uint32_t address, | ||
| 113 | uint32_t size, MemoryPermission map_perm) { | ||
| 114 | R_RETURN(CreateTransferMemory(system, out_handle, address, size, map_perm)); | ||
| 115 | } | ||
| 116 | |||
| 79 | } // namespace Kernel::Svc | 117 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc_generator.py b/src/core/hle/kernel/svc_generator.py new file mode 100644 index 000000000..b0a5707ec --- /dev/null +++ b/src/core/hle/kernel/svc_generator.py | |||
| @@ -0,0 +1,716 @@ | |||
| 1 | # SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | # SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | # Raw SVC definitions from the kernel. | ||
| 5 | # | ||
| 6 | # Avoid modifying the prototypes; see below for how to customize generation | ||
| 7 | # for a given typename. | ||
| 8 | SVCS = [ | ||
| 9 | [0x01, "Result SetHeapSize(Address* out_address, Size size);"], | ||
| 10 | [0x02, "Result SetMemoryPermission(Address address, Size size, MemoryPermission perm);"], | ||
| 11 | [0x03, "Result SetMemoryAttribute(Address address, Size size, uint32_t mask, uint32_t attr);"], | ||
| 12 | [0x04, "Result MapMemory(Address dst_address, Address src_address, Size size);"], | ||
| 13 | [0x05, "Result UnmapMemory(Address dst_address, Address src_address, Size size);"], | ||
| 14 | [0x06, "Result QueryMemory(Address out_memory_info, PageInfo* out_page_info, Address address);"], | ||
| 15 | [0x07, "void ExitProcess();"], | ||
| 16 | [0x08, "Result CreateThread(Handle* out_handle, ThreadFunc func, Address arg, Address stack_bottom, int32_t priority, int32_t core_id);"], | ||
| 17 | [0x09, "Result StartThread(Handle thread_handle);"], | ||
| 18 | [0x0A, "void ExitThread();"], | ||
| 19 | [0x0B, "void SleepThread(int64_t ns);"], | ||
| 20 | [0x0C, "Result GetThreadPriority(int32_t* out_priority, Handle thread_handle);"], | ||
| 21 | [0x0D, "Result SetThreadPriority(Handle thread_handle, int32_t priority);"], | ||
| 22 | [0x0E, "Result GetThreadCoreMask(int32_t* out_core_id, uint64_t* out_affinity_mask, Handle thread_handle);"], | ||
| 23 | [0x0F, "Result SetThreadCoreMask(Handle thread_handle, int32_t core_id, uint64_t affinity_mask);"], | ||
| 24 | [0x10, "int32_t GetCurrentProcessorNumber();"], | ||
| 25 | [0x11, "Result SignalEvent(Handle event_handle);"], | ||
| 26 | [0x12, "Result ClearEvent(Handle event_handle);"], | ||
| 27 | [0x13, "Result MapSharedMemory(Handle shmem_handle, Address address, Size size, MemoryPermission map_perm);"], | ||
| 28 | [0x14, "Result UnmapSharedMemory(Handle shmem_handle, Address address, Size size);"], | ||
| 29 | [0x15, "Result CreateTransferMemory(Handle* out_handle, Address address, Size size, MemoryPermission map_perm);"], | ||
| 30 | [0x16, "Result CloseHandle(Handle handle);"], | ||
| 31 | [0x17, "Result ResetSignal(Handle handle);"], | ||
| 32 | [0x18, "Result WaitSynchronization(int32_t* out_index, Address handles, int32_t num_handles, int64_t timeout_ns);"], | ||
| 33 | [0x19, "Result CancelSynchronization(Handle handle);"], | ||
| 34 | [0x1A, "Result ArbitrateLock(Handle thread_handle, Address address, uint32_t tag);"], | ||
| 35 | [0x1B, "Result ArbitrateUnlock(Address address);"], | ||
| 36 | [0x1C, "Result WaitProcessWideKeyAtomic(Address address, Address cv_key, uint32_t tag, int64_t timeout_ns);"], | ||
| 37 | [0x1D, "void SignalProcessWideKey(Address cv_key, int32_t count);"], | ||
| 38 | [0x1E, "int64_t GetSystemTick();"], | ||
| 39 | [0x1F, "Result ConnectToNamedPort(Handle* out_handle, Address name);"], | ||
| 40 | [0x20, "Result SendSyncRequestLight(Handle session_handle);"], | ||
| 41 | [0x21, "Result SendSyncRequest(Handle session_handle);"], | ||
| 42 | [0x22, "Result SendSyncRequestWithUserBuffer(Address message_buffer, Size message_buffer_size, Handle session_handle);"], | ||
| 43 | [0x23, "Result SendAsyncRequestWithUserBuffer(Handle* out_event_handle, Address message_buffer, Size message_buffer_size, Handle session_handle);"], | ||
| 44 | [0x24, "Result GetProcessId(uint64_t* out_process_id, Handle process_handle);"], | ||
| 45 | [0x25, "Result GetThreadId(uint64_t* out_thread_id, Handle thread_handle);"], | ||
| 46 | [0x26, "void Break(BreakReason break_reason, Address arg, Size size);"], | ||
| 47 | [0x27, "Result OutputDebugString(Address debug_str, Size len);"], | ||
| 48 | [0x28, "void ReturnFromException(Result result);"], | ||
| 49 | [0x29, "Result GetInfo(uint64_t* out, InfoType info_type, Handle handle, uint64_t info_subtype);"], | ||
| 50 | [0x2A, "void FlushEntireDataCache();"], | ||
| 51 | [0x2B, "Result FlushDataCache(Address address, Size size);"], | ||
| 52 | [0x2C, "Result MapPhysicalMemory(Address address, Size size);"], | ||
| 53 | [0x2D, "Result UnmapPhysicalMemory(Address address, Size size);"], | ||
| 54 | [0x2E, "Result GetDebugFutureThreadInfo(LastThreadContext* out_context, uint64_t* out_thread_id, Handle debug_handle, int64_t ns);"], | ||
| 55 | [0x2F, "Result GetLastThreadInfo(LastThreadContext* out_context, Address* out_tls_address, uint32_t* out_flags);"], | ||
| 56 | [0x30, "Result GetResourceLimitLimitValue(int64_t* out_limit_value, Handle resource_limit_handle, LimitableResource which);"], | ||
| 57 | [0x31, "Result GetResourceLimitCurrentValue(int64_t* out_current_value, Handle resource_limit_handle, LimitableResource which);"], | ||
| 58 | [0x32, "Result SetThreadActivity(Handle thread_handle, ThreadActivity thread_activity);"], | ||
| 59 | [0x33, "Result GetThreadContext3(Address out_context, Handle thread_handle);"], | ||
| 60 | [0x34, "Result WaitForAddress(Address address, ArbitrationType arb_type, int32_t value, int64_t timeout_ns);"], | ||
| 61 | [0x35, "Result SignalToAddress(Address address, SignalType signal_type, int32_t value, int32_t count);"], | ||
| 62 | [0x36, "void SynchronizePreemptionState();"], | ||
| 63 | [0x37, "Result GetResourceLimitPeakValue(int64_t* out_peak_value, Handle resource_limit_handle, LimitableResource which);"], | ||
| 64 | |||
| 65 | [0x39, "Result CreateIoPool(Handle* out_handle, IoPoolType which);"], | ||
| 66 | [0x3A, "Result CreateIoRegion(Handle* out_handle, Handle io_pool, PhysicalAddress physical_address, Size size, MemoryMapping mapping, MemoryPermission perm);"], | ||
| 67 | |||
| 68 | [0x3C, "void KernelDebug(KernelDebugType kern_debug_type, uint64_t arg0, uint64_t arg1, uint64_t arg2);"], | ||
| 69 | [0x3D, "void ChangeKernelTraceState(KernelTraceState kern_trace_state);"], | ||
| 70 | |||
| 71 | [0x40, "Result CreateSession(Handle* out_server_session_handle, Handle* out_client_session_handle, bool is_light, Address name);"], | ||
| 72 | [0x41, "Result AcceptSession(Handle* out_handle, Handle port);"], | ||
| 73 | [0x42, "Result ReplyAndReceiveLight(Handle handle);"], | ||
| 74 | [0x43, "Result ReplyAndReceive(int32_t* out_index, Address handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns);"], | ||
| 75 | [0x44, "Result ReplyAndReceiveWithUserBuffer(int32_t* out_index, Address message_buffer, Size message_buffer_size, Address handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns);"], | ||
| 76 | [0x45, "Result CreateEvent(Handle* out_write_handle, Handle* out_read_handle);"], | ||
| 77 | [0x46, "Result MapIoRegion(Handle io_region, Address address, Size size, MemoryPermission perm);"], | ||
| 78 | [0x47, "Result UnmapIoRegion(Handle io_region, Address address, Size size);"], | ||
| 79 | [0x48, "Result MapPhysicalMemoryUnsafe(Address address, Size size);"], | ||
| 80 | [0x49, "Result UnmapPhysicalMemoryUnsafe(Address address, Size size);"], | ||
| 81 | [0x4A, "Result SetUnsafeLimit(Size limit);"], | ||
| 82 | [0x4B, "Result CreateCodeMemory(Handle* out_handle, Address address, Size size);"], | ||
| 83 | [0x4C, "Result ControlCodeMemory(Handle code_memory_handle, CodeMemoryOperation operation, uint64_t address, uint64_t size, MemoryPermission perm);"], | ||
| 84 | [0x4D, "void SleepSystem();"], | ||
| 85 | [0x4E, "Result ReadWriteRegister(uint32_t* out_value, PhysicalAddress address, uint32_t mask, uint32_t value);"], | ||
| 86 | [0x4F, "Result SetProcessActivity(Handle process_handle, ProcessActivity process_activity);"], | ||
| 87 | [0x50, "Result CreateSharedMemory(Handle* out_handle, Size size, MemoryPermission owner_perm, MemoryPermission remote_perm);"], | ||
| 88 | [0x51, "Result MapTransferMemory(Handle trmem_handle, Address address, Size size, MemoryPermission owner_perm);"], | ||
| 89 | [0x52, "Result UnmapTransferMemory(Handle trmem_handle, Address address, Size size);"], | ||
| 90 | [0x53, "Result CreateInterruptEvent(Handle* out_read_handle, int32_t interrupt_id, InterruptType interrupt_type);"], | ||
| 91 | [0x54, "Result QueryPhysicalAddress(PhysicalMemoryInfo* out_info, Address address);"], | ||
| 92 | [0x55, "Result QueryIoMapping(Address* out_address, Size* out_size, PhysicalAddress physical_address, Size size);"], | ||
| 93 | [0x56, "Result CreateDeviceAddressSpace(Handle* out_handle, uint64_t das_address, uint64_t das_size);"], | ||
| 94 | [0x57, "Result AttachDeviceAddressSpace(DeviceName device_name, Handle das_handle);"], | ||
| 95 | [0x58, "Result DetachDeviceAddressSpace(DeviceName device_name, Handle das_handle);"], | ||
| 96 | [0x59, "Result MapDeviceAddressSpaceByForce(Handle das_handle, Handle process_handle, uint64_t process_address, Size size, uint64_t device_address, uint32_t option);"], | ||
| 97 | [0x5A, "Result MapDeviceAddressSpaceAligned(Handle das_handle, Handle process_handle, uint64_t process_address, Size size, uint64_t device_address, uint32_t option);"], | ||
| 98 | [0x5C, "Result UnmapDeviceAddressSpace(Handle das_handle, Handle process_handle, uint64_t process_address, Size size, uint64_t device_address);"], | ||
| 99 | [0x5D, "Result InvalidateProcessDataCache(Handle process_handle, uint64_t address, uint64_t size);"], | ||
| 100 | [0x5E, "Result StoreProcessDataCache(Handle process_handle, uint64_t address, uint64_t size);"], | ||
| 101 | [0x5F, "Result FlushProcessDataCache(Handle process_handle, uint64_t address, uint64_t size);"], | ||
| 102 | [0x60, "Result DebugActiveProcess(Handle* out_handle, uint64_t process_id);"], | ||
| 103 | [0x61, "Result BreakDebugProcess(Handle debug_handle);"], | ||
| 104 | [0x62, "Result TerminateDebugProcess(Handle debug_handle);"], | ||
| 105 | [0x63, "Result GetDebugEvent(Address out_info, Handle debug_handle);"], | ||
| 106 | [0x64, "Result ContinueDebugEvent(Handle debug_handle, uint32_t flags, Address thread_ids, int32_t num_thread_ids);"], | ||
| 107 | [0x65, "Result GetProcessList(int32_t* out_num_processes, Address out_process_ids, int32_t max_out_count);"], | ||
| 108 | [0x66, "Result GetThreadList(int32_t* out_num_threads, Address out_thread_ids, int32_t max_out_count, Handle debug_handle);"], | ||
| 109 | [0x67, "Result GetDebugThreadContext(Address out_context, Handle debug_handle, uint64_t thread_id, uint32_t context_flags);"], | ||
| 110 | [0x68, "Result SetDebugThreadContext(Handle debug_handle, uint64_t thread_id, Address context, uint32_t context_flags);"], | ||
| 111 | [0x69, "Result QueryDebugProcessMemory(Address out_memory_info, PageInfo* out_page_info, Handle process_handle, Address address);"], | ||
| 112 | [0x6A, "Result ReadDebugProcessMemory(Address buffer, Handle debug_handle, Address address, Size size);"], | ||
| 113 | [0x6B, "Result WriteDebugProcessMemory(Handle debug_handle, Address buffer, Address address, Size size);"], | ||
| 114 | [0x6C, "Result SetHardwareBreakPoint(HardwareBreakPointRegisterName name, uint64_t flags, uint64_t value);"], | ||
| 115 | [0x6D, "Result GetDebugThreadParam(uint64_t* out_64, uint32_t* out_32, Handle debug_handle, uint64_t thread_id, DebugThreadParam param);"], | ||
| 116 | |||
| 117 | [0x6F, "Result GetSystemInfo(uint64_t* out, SystemInfoType info_type, Handle handle, uint64_t info_subtype);"], | ||
| 118 | [0x70, "Result CreatePort(Handle* out_server_handle, Handle* out_client_handle, int32_t max_sessions, bool is_light, Address name);"], | ||
| 119 | [0x71, "Result ManageNamedPort(Handle* out_server_handle, Address name, int32_t max_sessions);"], | ||
| 120 | [0x72, "Result ConnectToPort(Handle* out_handle, Handle port);"], | ||
| 121 | [0x73, "Result SetProcessMemoryPermission(Handle process_handle, uint64_t address, uint64_t size, MemoryPermission perm);"], | ||
| 122 | [0x74, "Result MapProcessMemory(Address dst_address, Handle process_handle, uint64_t src_address, Size size);"], | ||
| 123 | [0x75, "Result UnmapProcessMemory(Address dst_address, Handle process_handle, uint64_t src_address, Size size);"], | ||
| 124 | [0x76, "Result QueryProcessMemory(Address out_memory_info, PageInfo* out_page_info, Handle process_handle, uint64_t address);"], | ||
| 125 | [0x77, "Result MapProcessCodeMemory(Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size);"], | ||
| 126 | [0x78, "Result UnmapProcessCodeMemory(Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size);"], | ||
| 127 | [0x79, "Result CreateProcess(Handle* out_handle, Address parameters, Address caps, int32_t num_caps);"], | ||
| 128 | [0x7A, "Result StartProcess(Handle process_handle, int32_t priority, int32_t core_id, uint64_t main_thread_stack_size);"], | ||
| 129 | [0x7B, "Result TerminateProcess(Handle process_handle);"], | ||
| 130 | [0x7C, "Result GetProcessInfo(int64_t* out_info, Handle process_handle, ProcessInfoType info_type);"], | ||
| 131 | [0x7D, "Result CreateResourceLimit(Handle* out_handle);"], | ||
| 132 | [0x7E, "Result SetResourceLimitLimitValue(Handle resource_limit_handle, LimitableResource which, int64_t limit_value);"], | ||
| 133 | [0x7F, "void CallSecureMonitor(SecureMonitorArguments args);"], | ||
| 134 | |||
| 135 | [0x90, "Result MapInsecureMemory(Address address, Size size);"], | ||
| 136 | [0x91, "Result UnmapInsecureMemory(Address address, Size size);"], | ||
| 137 | ] | ||
| 138 | |||
| 139 | # These use a custom ABI, and therefore require custom wrappers | ||
| 140 | SKIP_WRAPPERS = { | ||
| 141 | 0x20: "SendSyncRequestLight", | ||
| 142 | 0x42: "ReplyAndReceiveLight", | ||
| 143 | 0x7F: "CallSecureMonitor", | ||
| 144 | } | ||
| 145 | |||
| 146 | BIT_32 = 0 | ||
| 147 | BIT_64 = 1 | ||
| 148 | |||
| 149 | REG_SIZES = [4, 8] | ||
| 150 | SUFFIX_NAMES = ["64From32", "64"] | ||
| 151 | TYPE_SIZES = { | ||
| 152 | # SVC types | ||
| 153 | "ArbitrationType": 4, | ||
| 154 | "BreakReason": 4, | ||
| 155 | "CodeMemoryOperation": 4, | ||
| 156 | "DebugThreadParam": 4, | ||
| 157 | "DeviceName": 4, | ||
| 158 | "HardwareBreakPointRegisterName": 4, | ||
| 159 | "Handle": 4, | ||
| 160 | "InfoType": 4, | ||
| 161 | "InterruptType": 4, | ||
| 162 | "IoPoolType": 4, | ||
| 163 | "KernelDebugType": 4, | ||
| 164 | "KernelTraceState": 4, | ||
| 165 | "LimitableResource": 4, | ||
| 166 | "MemoryMapping": 4, | ||
| 167 | "MemoryPermission": 4, | ||
| 168 | "PageInfo": 4, | ||
| 169 | "ProcessActivity": 4, | ||
| 170 | "ProcessInfoType": 4, | ||
| 171 | "Result": 4, | ||
| 172 | "SignalType": 4, | ||
| 173 | "SystemInfoType": 4, | ||
| 174 | "ThreadActivity": 4, | ||
| 175 | |||
| 176 | # Arch-specific types | ||
| 177 | "ilp32::LastThreadContext": 16, | ||
| 178 | "ilp32::PhysicalMemoryInfo": 16, | ||
| 179 | "ilp32::SecureMonitorArguments": 32, | ||
| 180 | "lp64::LastThreadContext": 32, | ||
| 181 | "lp64::PhysicalMemoryInfo": 24, | ||
| 182 | "lp64::SecureMonitorArguments": 64, | ||
| 183 | |||
| 184 | # Generic types | ||
| 185 | "bool": 1, | ||
| 186 | "int32_t": 4, | ||
| 187 | "int64_t": 8, | ||
| 188 | "uint32_t": 4, | ||
| 189 | "uint64_t": 8, | ||
| 190 | "void": 0, | ||
| 191 | } | ||
| 192 | |||
| 193 | TYPE_REPLACEMENTS = { | ||
| 194 | "Address": ["uint32_t", "uint64_t"], | ||
| 195 | "LastThreadContext": ["ilp32::LastThreadContext", "lp64::LastThreadContext"], | ||
| 196 | "PhysicalAddress": ["uint64_t", "uint64_t"], | ||
| 197 | "PhysicalMemoryInfo": ["ilp32::PhysicalMemoryInfo", "lp64::PhysicalMemoryInfo"], | ||
| 198 | "SecureMonitorArguments": ["ilp32::SecureMonitorArguments", "lp64::SecureMonitorArguments"], | ||
| 199 | "Size": ["uint32_t", "uint64_t"], | ||
| 200 | "ThreadFunc": ["uint32_t", "uint64_t"], | ||
| 201 | } | ||
| 202 | |||
| 203 | # Statically verify that the hardcoded sizes match the intended | ||
| 204 | # sizes in C++. | ||
| 205 | def emit_size_check(): | ||
| 206 | lines = [] | ||
| 207 | |||
| 208 | for type, size in TYPE_SIZES.items(): | ||
| 209 | if type != "void": | ||
| 210 | lines.append(f"static_assert(sizeof({type}) == {size});") | ||
| 211 | |||
| 212 | return "\n".join(lines) | ||
| 213 | |||
| 214 | |||
| 215 | # Replaces a type with an arch-specific one, if it exists. | ||
| 216 | def substitute_type(name, bitness): | ||
| 217 | if name in TYPE_REPLACEMENTS: | ||
| 218 | return TYPE_REPLACEMENTS[name][bitness] | ||
| 219 | else: | ||
| 220 | return name | ||
| 221 | |||
| 222 | |||
| 223 | class Argument: | ||
| 224 | def __init__(self, type_name, var_name, is_output, is_outptr, is_address): | ||
| 225 | self.type_name = type_name | ||
| 226 | self.var_name = var_name | ||
| 227 | self.is_output = is_output | ||
| 228 | self.is_outptr = is_outptr | ||
| 229 | self.is_address = is_address | ||
| 230 | |||
| 231 | |||
| 232 | # Parses C-style string declarations for SVCs. | ||
| 233 | def parse_declaration(declaration, bitness): | ||
| 234 | return_type, rest = declaration.split(" ", 1) | ||
| 235 | func_name, rest = rest.split("(", 1) | ||
| 236 | arg_names, rest = rest.split(")", 1) | ||
| 237 | argument_types = [] | ||
| 238 | |||
| 239 | return_type = substitute_type(return_type, bitness) | ||
| 240 | assert return_type in TYPE_SIZES, f"Unknown type '{return_type}'" | ||
| 241 | |||
| 242 | if arg_names: | ||
| 243 | for arg_name in arg_names.split(", "): | ||
| 244 | type_name, var_name = arg_name.replace("*", "").split(" ", 1) | ||
| 245 | |||
| 246 | # All outputs must contain out_ in the name. | ||
| 247 | is_output = var_name == "out" or var_name.find("out_") != -1 | ||
| 248 | |||
| 249 | # User-pointer outputs are not written to registers. | ||
| 250 | is_outptr = is_output and arg_name.find("*") == -1 | ||
| 251 | |||
| 252 | # Special handling is performed for output addresses to avoid awkwardness | ||
| 253 | # in conversion for the 32-bit equivalents. | ||
| 254 | is_address = is_output and not is_outptr and \ | ||
| 255 | type_name in ["Address", "Size"] | ||
| 256 | type_name = substitute_type(type_name, bitness) | ||
| 257 | |||
| 258 | assert type_name in TYPE_SIZES, f"Unknown type '{type_name}'" | ||
| 259 | |||
| 260 | argument_types.append( | ||
| 261 | Argument(type_name, var_name, is_output, is_outptr, is_address)) | ||
| 262 | |||
| 263 | return (return_type, func_name, argument_types) | ||
| 264 | |||
| 265 | |||
| 266 | class RegisterAllocator: | ||
| 267 | def __init__(self, num_regs, byte_size, parameter_count): | ||
| 268 | self.registers = {} | ||
| 269 | self.num_regs = num_regs | ||
| 270 | self.byte_size = byte_size | ||
| 271 | self.parameter_count = parameter_count | ||
| 272 | |||
| 273 | # Mark the given register as allocated, for use in layout | ||
| 274 | # calculation if the NGRN exceeds the ABI parameter count. | ||
| 275 | def allocate(self, i): | ||
| 276 | assert i not in self.registers, f"Register R{i} already allocated" | ||
| 277 | self.registers[i] = True | ||
| 278 | return i | ||
| 279 | |||
| 280 | # Calculate the next available location for a register; | ||
| 281 | # the NGRN has exceeded the ABI parameter count. | ||
| 282 | def allocate_first_free(self): | ||
| 283 | for i in range(0, self.num_regs): | ||
| 284 | if i in self.registers: | ||
| 285 | continue | ||
| 286 | |||
| 287 | self.allocate(i) | ||
| 288 | return i | ||
| 289 | |||
| 290 | assert False, "No registers available" | ||
| 291 | |||
| 292 | # Add a single register at the given NGRN. | ||
| 293 | # If the index exceeds the ABI parameter count, try to find a | ||
| 294 | # location to add it. Returns the output location and increment. | ||
| 295 | def add_single(self, ngrn): | ||
| 296 | if ngrn >= self.parameter_count: | ||
| 297 | return (self.allocate_first_free(), 0) | ||
| 298 | else: | ||
| 299 | return (self.allocate(ngrn), 1) | ||
| 300 | |||
| 301 | # Add registers at the given NGRN for a data type of | ||
| 302 | # the given size. Returns the output locations and increment. | ||
| 303 | def add(self, ngrn, data_size, align=True): | ||
| 304 | if data_size <= self.byte_size: | ||
| 305 | r, i = self.add_single(ngrn) | ||
| 306 | return ([r], i) | ||
| 307 | |||
| 308 | regs = [] | ||
| 309 | inc = ngrn % 2 if align else 0 | ||
| 310 | remaining_size = data_size | ||
| 311 | while remaining_size > 0: | ||
| 312 | r, i = self.add_single(ngrn + inc) | ||
| 313 | regs.append(r) | ||
| 314 | inc += i | ||
| 315 | remaining_size -= self.byte_size | ||
| 316 | |||
| 317 | return (regs, inc) | ||
| 318 | |||
| 319 | |||
| 320 | def reg_alloc(bitness): | ||
| 321 | if bitness == 0: | ||
| 322 | # aapcs32: 4 4-byte registers | ||
| 323 | return RegisterAllocator(8, 4, 4) | ||
| 324 | elif bitness == 1: | ||
| 325 | # aapcs64: 8 8-byte registers | ||
| 326 | return RegisterAllocator(8, 8, 8) | ||
| 327 | |||
| 328 | |||
| 329 | # Converts a parsed SVC declaration into register lists for | ||
| 330 | # the return value, outputs, and inputs. | ||
| 331 | def get_registers(parse_result, bitness): | ||
| 332 | output_alloc = reg_alloc(bitness) | ||
| 333 | input_alloc = reg_alloc(bitness) | ||
| 334 | return_type, _, arguments = parse_result | ||
| 335 | |||
| 336 | return_write = [] | ||
| 337 | output_writes = [] | ||
| 338 | input_reads = [] | ||
| 339 | |||
| 340 | input_ngrn = 0 | ||
| 341 | output_ngrn = 0 | ||
| 342 | |||
| 343 | # Run the input calculation. | ||
| 344 | for arg in arguments: | ||
| 345 | if arg.is_output and not arg.is_outptr: | ||
| 346 | input_ngrn += 1 | ||
| 347 | continue | ||
| 348 | |||
| 349 | regs, increment = input_alloc.add( | ||
| 350 | input_ngrn, TYPE_SIZES[arg.type_name], align=True) | ||
| 351 | input_reads.append([arg.type_name, arg.var_name, regs]) | ||
| 352 | input_ngrn += increment | ||
| 353 | |||
| 354 | # Include the return value if this SVC returns a value. | ||
| 355 | if return_type != "void": | ||
| 356 | regs, increment = output_alloc.add( | ||
| 357 | output_ngrn, TYPE_SIZES[return_type], align=False) | ||
| 358 | return_write.append([return_type, regs]) | ||
| 359 | output_ngrn += increment | ||
| 360 | |||
| 361 | # Run the output calculation. | ||
| 362 | for arg in arguments: | ||
| 363 | if not arg.is_output or arg.is_outptr: | ||
| 364 | continue | ||
| 365 | |||
| 366 | regs, increment = output_alloc.add( | ||
| 367 | output_ngrn, TYPE_SIZES[arg.type_name], align=False) | ||
| 368 | output_writes.append( | ||
| 369 | [arg.type_name, arg.var_name, regs, arg.is_address]) | ||
| 370 | output_ngrn += increment | ||
| 371 | |||
| 372 | return (return_write, output_writes, input_reads) | ||
| 373 | |||
| 374 | |||
| 375 | # Collects possibly multiple source registers into the named C++ value. | ||
| 376 | def emit_gather(sources, name, type_name, reg_size): | ||
| 377 | get_fn = f"GetReg{reg_size*8}" | ||
| 378 | |||
| 379 | if len(sources) == 1: | ||
| 380 | s, = sources | ||
| 381 | line = f"{name} = Convert<{type_name}>({get_fn}(system, {s}));" | ||
| 382 | return [line] | ||
| 383 | |||
| 384 | var_type = f"std::array<uint{reg_size*8}_t, {len(sources)}>" | ||
| 385 | lines = [ | ||
| 386 | f"{var_type} {name}_gather{{}};" | ||
| 387 | ] | ||
| 388 | for i in range(0, len(sources)): | ||
| 389 | lines.append( | ||
| 390 | f"{name}_gather[{i}] = {get_fn}(system, {sources[i]});") | ||
| 391 | |||
| 392 | lines.append(f"{name} = Convert<{type_name}>({name}_gather);") | ||
| 393 | return lines | ||
| 394 | |||
| 395 | |||
| 396 | # Produces one or more statements which assign the named C++ value | ||
| 397 | # into possibly multiple registers. | ||
| 398 | def emit_scatter(destinations, name, reg_size): | ||
| 399 | set_fn = f"SetReg{reg_size*8}" | ||
| 400 | reg_type = f"uint{reg_size*8}_t" | ||
| 401 | |||
| 402 | if len(destinations) == 1: | ||
| 403 | d, = destinations | ||
| 404 | line = f"{set_fn}(system, {d}, Convert<{reg_type}>({name}));" | ||
| 405 | return [line] | ||
| 406 | |||
| 407 | var_type = f"std::array<{reg_type}, {len(destinations)}>" | ||
| 408 | lines = [ | ||
| 409 | f"auto {name}_scatter = Convert<{var_type}>({name});" | ||
| 410 | ] | ||
| 411 | |||
| 412 | for i in range(0, len(destinations)): | ||
| 413 | lines.append( | ||
| 414 | f"{set_fn}(system, {destinations[i]}, {name}_scatter[{i}]);") | ||
| 415 | |||
| 416 | return lines | ||
| 417 | |||
| 418 | |||
| 419 | def emit_lines(lines, indent=' '): | ||
| 420 | output_lines = [] | ||
| 421 | first = True | ||
| 422 | for line in lines: | ||
| 423 | if line and not first: | ||
| 424 | output_lines.append(indent + line) | ||
| 425 | else: | ||
| 426 | output_lines.append(line) | ||
| 427 | first = False | ||
| 428 | |||
| 429 | return "\n".join(output_lines) | ||
| 430 | |||
| 431 | |||
| 432 | # Emit a C++ function to wrap a guest SVC. | ||
| 433 | def emit_wrapper(wrapped_fn, suffix, register_info, arguments, byte_size): | ||
| 434 | return_write, output_writes, input_reads = register_info | ||
| 435 | lines = [ | ||
| 436 | f"static void SvcWrap_{wrapped_fn}{suffix}(Core::System& system) {{" | ||
| 437 | ] | ||
| 438 | |||
| 439 | # Get everything ready. | ||
| 440 | for return_type, _ in return_write: | ||
| 441 | lines.append(f"{return_type} ret{{}};") | ||
| 442 | if return_write: | ||
| 443 | lines.append("") | ||
| 444 | |||
| 445 | for output_type, var_name, _, is_address in output_writes: | ||
| 446 | output_type = "uintptr_t" if is_address else output_type | ||
| 447 | lines.append(f"{output_type} {var_name}{{}};") | ||
| 448 | for input_type, var_name, _ in input_reads: | ||
| 449 | lines.append(f"{input_type} {var_name}{{}};") | ||
| 450 | |||
| 451 | if output_writes or input_reads: | ||
| 452 | lines.append("") | ||
| 453 | |||
| 454 | for input_type, var_name, sources in input_reads: | ||
| 455 | lines += emit_gather(sources, var_name, input_type, byte_size) | ||
| 456 | if input_reads: | ||
| 457 | lines.append("") | ||
| 458 | |||
| 459 | # Build the call. | ||
| 460 | call_arguments = ["system"] | ||
| 461 | for arg in arguments: | ||
| 462 | if arg.is_output and not arg.is_outptr: | ||
| 463 | call_arguments.append(f"&{arg.var_name}") | ||
| 464 | else: | ||
| 465 | call_arguments.append(arg.var_name) | ||
| 466 | |||
| 467 | line = "" | ||
| 468 | if return_write: | ||
| 469 | line += "ret = " | ||
| 470 | |||
| 471 | line += f"{wrapped_fn}{suffix}({', '.join(call_arguments)});" | ||
| 472 | lines.append(line) | ||
| 473 | |||
| 474 | if return_write or output_writes: | ||
| 475 | lines.append("") | ||
| 476 | |||
| 477 | # Write back the return value and outputs. | ||
| 478 | for _, destinations in return_write: | ||
| 479 | lines += emit_scatter(destinations, "ret", byte_size) | ||
| 480 | for _, var_name, destinations, _ in output_writes: | ||
| 481 | lines += emit_scatter(destinations, var_name, byte_size) | ||
| 482 | |||
| 483 | # Finish. | ||
| 484 | return emit_lines(lines) + "\n}" | ||
| 485 | |||
| 486 | |||
| 487 | COPYRIGHT = """\ | ||
| 488 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 489 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 490 | |||
| 491 | // This file is automatically generated using svc_generator.py. | ||
| 492 | """ | ||
| 493 | |||
| 494 | PROLOGUE_H = """ | ||
| 495 | #pragma once | ||
| 496 | |||
| 497 | namespace Core { | ||
| 498 | class System; | ||
| 499 | } | ||
| 500 | |||
| 501 | #include "common/common_types.h" | ||
| 502 | #include "core/hle/kernel/svc_types.h" | ||
| 503 | #include "core/hle/result.h" | ||
| 504 | |||
| 505 | namespace Kernel::Svc { | ||
| 506 | |||
| 507 | // clang-format off | ||
| 508 | """ | ||
| 509 | |||
| 510 | EPILOGUE_H = """ | ||
| 511 | // clang-format on | ||
| 512 | |||
| 513 | // Custom ABI. | ||
| 514 | Result ReplyAndReceiveLight(Core::System& system, Handle handle, uint32_t* args); | ||
| 515 | Result ReplyAndReceiveLight64From32(Core::System& system, Handle handle, uint32_t* args); | ||
| 516 | Result ReplyAndReceiveLight64(Core::System& system, Handle handle, uint32_t* args); | ||
| 517 | |||
| 518 | Result SendSyncRequestLight(Core::System& system, Handle session_handle, uint32_t* args); | ||
| 519 | Result SendSyncRequestLight64From32(Core::System& system, Handle session_handle, uint32_t* args); | ||
| 520 | Result SendSyncRequestLight64(Core::System& system, Handle session_handle, uint32_t* args); | ||
| 521 | |||
| 522 | void CallSecureMonitor(Core::System& system, lp64::SecureMonitorArguments* args); | ||
| 523 | void CallSecureMonitor64From32(Core::System& system, ilp32::SecureMonitorArguments* args); | ||
| 524 | void CallSecureMonitor64(Core::System& system, lp64::SecureMonitorArguments* args); | ||
| 525 | |||
| 526 | // Defined in svc_light_ipc.cpp. | ||
| 527 | void SvcWrap_ReplyAndReceiveLight64From32(Core::System& system); | ||
| 528 | void SvcWrap_ReplyAndReceiveLight64(Core::System& system); | ||
| 529 | |||
| 530 | void SvcWrap_SendSyncRequestLight64From32(Core::System& system); | ||
| 531 | void SvcWrap_SendSyncRequestLight64(Core::System& system); | ||
| 532 | |||
| 533 | // Defined in svc_secure_monitor_call.cpp. | ||
| 534 | void SvcWrap_CallSecureMonitor64From32(Core::System& system); | ||
| 535 | void SvcWrap_CallSecureMonitor64(Core::System& system); | ||
| 536 | |||
| 537 | // Perform a supervisor call by index. | ||
| 538 | void Call(Core::System& system, u32 imm); | ||
| 539 | |||
| 540 | } // namespace Kernel::Svc | ||
| 541 | """ | ||
| 542 | |||
| 543 | PROLOGUE_CPP = """ | ||
| 544 | #include <type_traits> | ||
| 545 | |||
| 546 | #include "core/arm/arm_interface.h" | ||
| 547 | #include "core/core.h" | ||
| 548 | #include "core/hle/kernel/k_process.h" | ||
| 549 | #include "core/hle/kernel/svc.h" | ||
| 550 | |||
| 551 | namespace Kernel::Svc { | ||
| 552 | |||
| 553 | static uint32_t GetReg32(Core::System& system, int n) { | ||
| 554 | return static_cast<uint32_t>(system.CurrentArmInterface().GetReg(n)); | ||
| 555 | } | ||
| 556 | |||
| 557 | static void SetReg32(Core::System& system, int n, uint32_t result) { | ||
| 558 | system.CurrentArmInterface().SetReg(n, static_cast<uint64_t>(result)); | ||
| 559 | } | ||
| 560 | |||
| 561 | static uint64_t GetReg64(Core::System& system, int n) { | ||
| 562 | return system.CurrentArmInterface().GetReg(n); | ||
| 563 | } | ||
| 564 | |||
| 565 | static void SetReg64(Core::System& system, int n, uint64_t result) { | ||
| 566 | system.CurrentArmInterface().SetReg(n, result); | ||
| 567 | } | ||
| 568 | |||
| 569 | // Like bit_cast, but handles the case when the source and dest | ||
| 570 | // are differently-sized. | ||
| 571 | template <typename To, typename From> | ||
| 572 | requires(std::is_trivial_v<To> && std::is_trivially_copyable_v<From>) | ||
| 573 | static To Convert(const From& from) { | ||
| 574 | To to{}; | ||
| 575 | |||
| 576 | if constexpr (sizeof(To) >= sizeof(From)) { | ||
| 577 | std::memcpy(&to, &from, sizeof(From)); | ||
| 578 | } else { | ||
| 579 | std::memcpy(&to, &from, sizeof(To)); | ||
| 580 | } | ||
| 581 | |||
| 582 | return to; | ||
| 583 | } | ||
| 584 | |||
| 585 | // clang-format off | ||
| 586 | """ | ||
| 587 | |||
| 588 | EPILOGUE_CPP = """ | ||
| 589 | // clang-format on | ||
| 590 | |||
| 591 | void Call(Core::System& system, u32 imm) { | ||
| 592 | auto& kernel = system.Kernel(); | ||
| 593 | kernel.EnterSVCProfile(); | ||
| 594 | |||
| 595 | if (system.CurrentProcess()->Is64BitProcess()) { | ||
| 596 | Call64(system, imm); | ||
| 597 | } else { | ||
| 598 | Call32(system, imm); | ||
| 599 | } | ||
| 600 | |||
| 601 | kernel.ExitSVCProfile(); | ||
| 602 | } | ||
| 603 | |||
| 604 | } // namespace Kernel::Svc | ||
| 605 | """ | ||
| 606 | |||
| 607 | |||
| 608 | def emit_call(bitness, names, suffix): | ||
| 609 | bit_size = REG_SIZES[bitness]*8 | ||
| 610 | indent = " " | ||
| 611 | lines = [ | ||
| 612 | f"static void Call{bit_size}(Core::System& system, u32 imm) {{", | ||
| 613 | f"{indent}switch (static_cast<SvcId>(imm)) {{" | ||
| 614 | ] | ||
| 615 | |||
| 616 | for _, name in names: | ||
| 617 | lines.append(f"{indent}case SvcId::{name}:") | ||
| 618 | lines.append(f"{indent*2}return SvcWrap_{name}{suffix}(system);") | ||
| 619 | |||
| 620 | lines.append(f"{indent}default:") | ||
| 621 | lines.append( | ||
| 622 | f"{indent*2}LOG_CRITICAL(Kernel_SVC, \"Unknown SVC {{:x}}!\", imm);") | ||
| 623 | lines.append(f"{indent*2}break;") | ||
| 624 | lines.append(f"{indent}}}") | ||
| 625 | lines.append("}") | ||
| 626 | |||
| 627 | return "\n".join(lines) | ||
| 628 | |||
| 629 | |||
| 630 | def build_fn_declaration(return_type, name, arguments): | ||
| 631 | arg_list = ["Core::System& system"] | ||
| 632 | for arg in arguments: | ||
| 633 | type_name = "uintptr_t" if arg.is_address else arg.type_name | ||
| 634 | pointer = "*" if arg.is_output and not arg.is_outptr else "" | ||
| 635 | arg_list.append(f"{type_name}{pointer} {arg.var_name}") | ||
| 636 | |||
| 637 | return f"{return_type} {name}({', '.join(arg_list)});" | ||
| 638 | |||
| 639 | |||
| 640 | def build_enum_declarations(): | ||
| 641 | lines = ["enum class SvcId : u32 {"] | ||
| 642 | indent = " " | ||
| 643 | |||
| 644 | for imm, decl in SVCS: | ||
| 645 | _, name, _ = parse_declaration(decl, BIT_64) | ||
| 646 | lines.append(f"{indent}{name} = {hex(imm)},") | ||
| 647 | |||
| 648 | lines.append("};") | ||
| 649 | return "\n".join(lines) | ||
| 650 | |||
| 651 | |||
| 652 | def main(): | ||
| 653 | arch_fw_declarations = [[], []] | ||
| 654 | svc_fw_declarations = [] | ||
| 655 | wrapper_fns = [] | ||
| 656 | names = [] | ||
| 657 | |||
| 658 | for imm, decl in SVCS: | ||
| 659 | return_type, name, arguments = parse_declaration(decl, BIT_64) | ||
| 660 | |||
| 661 | if imm not in SKIP_WRAPPERS: | ||
| 662 | svc_fw_declarations.append( | ||
| 663 | build_fn_declaration(return_type, name, arguments)) | ||
| 664 | |||
| 665 | names.append([imm, name]) | ||
| 666 | |||
| 667 | for bitness in range(2): | ||
| 668 | byte_size = REG_SIZES[bitness] | ||
| 669 | suffix = SUFFIX_NAMES[bitness] | ||
| 670 | |||
| 671 | for imm, decl in SVCS: | ||
| 672 | if imm in SKIP_WRAPPERS: | ||
| 673 | continue | ||
| 674 | |||
| 675 | parse_result = parse_declaration(decl, bitness) | ||
| 676 | return_type, name, arguments = parse_result | ||
| 677 | |||
| 678 | register_info = get_registers(parse_result, bitness) | ||
| 679 | wrapper_fns.append( | ||
| 680 | emit_wrapper(name, suffix, register_info, arguments, byte_size)) | ||
| 681 | arch_fw_declarations[bitness].append( | ||
| 682 | build_fn_declaration(return_type, name + suffix, arguments)) | ||
| 683 | |||
| 684 | call_32 = emit_call(BIT_32, names, SUFFIX_NAMES[BIT_32]) | ||
| 685 | call_64 = emit_call(BIT_64, names, SUFFIX_NAMES[BIT_64]) | ||
| 686 | enum_decls = build_enum_declarations() | ||
| 687 | |||
| 688 | with open("svc.h", "w") as f: | ||
| 689 | f.write(COPYRIGHT) | ||
| 690 | f.write(PROLOGUE_H) | ||
| 691 | f.write("\n".join(svc_fw_declarations)) | ||
| 692 | f.write("\n\n") | ||
| 693 | f.write("\n".join(arch_fw_declarations[BIT_32])) | ||
| 694 | f.write("\n\n") | ||
| 695 | f.write("\n".join(arch_fw_declarations[BIT_64])) | ||
| 696 | f.write("\n\n") | ||
| 697 | f.write(enum_decls) | ||
| 698 | f.write(EPILOGUE_H) | ||
| 699 | |||
| 700 | with open("svc.cpp", "w") as f: | ||
| 701 | f.write(COPYRIGHT) | ||
| 702 | f.write(PROLOGUE_CPP) | ||
| 703 | f.write(emit_size_check()) | ||
| 704 | f.write("\n\n") | ||
| 705 | f.write("\n\n".join(wrapper_fns)) | ||
| 706 | f.write("\n\n") | ||
| 707 | f.write(call_32) | ||
| 708 | f.write("\n\n") | ||
| 709 | f.write(call_64) | ||
| 710 | f.write(EPILOGUE_CPP) | ||
| 711 | |||
| 712 | print(f"Done (emitted {len(names)} definitions)") | ||
| 713 | |||
| 714 | |||
| 715 | if __name__ == "__main__": | ||
| 716 | main() | ||
diff --git a/src/core/hle/kernel/svc_results.h b/src/core/hle/kernel/svc_results.h index b7ca53085..e1ad78607 100644 --- a/src/core/hle/kernel/svc_results.h +++ b/src/core/hle/kernel/svc_results.h | |||
| @@ -11,6 +11,7 @@ namespace Kernel { | |||
| 11 | 11 | ||
| 12 | constexpr Result ResultOutOfSessions{ErrorModule::Kernel, 7}; | 12 | constexpr Result ResultOutOfSessions{ErrorModule::Kernel, 7}; |
| 13 | constexpr Result ResultInvalidArgument{ErrorModule::Kernel, 14}; | 13 | constexpr Result ResultInvalidArgument{ErrorModule::Kernel, 14}; |
| 14 | constexpr Result ResultNotImplemented{ErrorModule::Kernel, 33}; | ||
| 14 | constexpr Result ResultNoSynchronizationObject{ErrorModule::Kernel, 57}; | 15 | constexpr Result ResultNoSynchronizationObject{ErrorModule::Kernel, 57}; |
| 15 | constexpr Result ResultTerminationRequested{ErrorModule::Kernel, 59}; | 16 | constexpr Result ResultTerminationRequested{ErrorModule::Kernel, 59}; |
| 16 | constexpr Result ResultInvalidSize{ErrorModule::Kernel, 101}; | 17 | constexpr Result ResultInvalidSize{ErrorModule::Kernel, 101}; |
diff --git a/src/core/hle/kernel/svc_types.h b/src/core/hle/kernel/svc_types.h index e90c35601..542c13461 100644 --- a/src/core/hle/kernel/svc_types.h +++ b/src/core/hle/kernel/svc_types.h | |||
| @@ -168,6 +168,7 @@ enum class BreakReason : u32 { | |||
| 168 | 168 | ||
| 169 | NotificationOnlyFlag = 0x80000000, | 169 | NotificationOnlyFlag = 0x80000000, |
| 170 | }; | 170 | }; |
| 171 | DECLARE_ENUM_FLAG_OPERATORS(BreakReason); | ||
| 171 | 172 | ||
| 172 | enum class DebugEvent : u32 { | 173 | enum class DebugEvent : u32 { |
| 173 | CreateProcess = 0, | 174 | CreateProcess = 0, |
| @@ -596,6 +597,11 @@ enum class ProcessInfoType : u32 { | |||
| 596 | ProcessState = 0, | 597 | ProcessState = 0, |
| 597 | }; | 598 | }; |
| 598 | 599 | ||
| 600 | enum class ProcessActivity : u32 { | ||
| 601 | Runnable, | ||
| 602 | Paused, | ||
| 603 | }; | ||
| 604 | |||
| 599 | struct CreateProcessParameter { | 605 | struct CreateProcessParameter { |
| 600 | std::array<char, 12> name; | 606 | std::array<char, 12> name; |
| 601 | u32 version; | 607 | u32 version; |
| @@ -611,4 +617,9 @@ static_assert(sizeof(CreateProcessParameter) == 0x30); | |||
| 611 | constexpr size_t NumSupervisorCalls = 0xC0; | 617 | constexpr size_t NumSupervisorCalls = 0xC0; |
| 612 | using SvcAccessFlagSet = std::bitset<NumSupervisorCalls>; | 618 | using SvcAccessFlagSet = std::bitset<NumSupervisorCalls>; |
| 613 | 619 | ||
| 620 | enum class InitialProcessIdRangeInfo : u64 { | ||
| 621 | Minimum = 0, | ||
| 622 | Maximum = 1, | ||
| 623 | }; | ||
| 624 | |||
| 614 | } // namespace Kernel::Svc | 625 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h deleted file mode 100644 index 052be40dd..000000000 --- a/src/core/hle/kernel/svc_wrap.h +++ /dev/null | |||
| @@ -1,733 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/common_types.h" | ||
| 7 | #include "core/arm/arm_interface.h" | ||
| 8 | #include "core/core.h" | ||
| 9 | #include "core/hle/kernel/svc_types.h" | ||
| 10 | #include "core/hle/result.h" | ||
| 11 | #include "core/memory.h" | ||
| 12 | |||
| 13 | namespace Kernel { | ||
| 14 | |||
| 15 | static inline u64 Param(const Core::System& system, int n) { | ||
| 16 | return system.CurrentArmInterface().GetReg(n); | ||
| 17 | } | ||
| 18 | |||
| 19 | static inline u32 Param32(const Core::System& system, int n) { | ||
| 20 | return static_cast<u32>(system.CurrentArmInterface().GetReg(n)); | ||
| 21 | } | ||
| 22 | |||
| 23 | /** | ||
| 24 | * HLE a function return from the current ARM userland process | ||
| 25 | * @param system System context | ||
| 26 | * @param result Result to return | ||
| 27 | */ | ||
| 28 | static inline void FuncReturn(Core::System& system, u64 result) { | ||
| 29 | system.CurrentArmInterface().SetReg(0, result); | ||
| 30 | } | ||
| 31 | |||
| 32 | static inline void FuncReturn32(Core::System& system, u32 result) { | ||
| 33 | system.CurrentArmInterface().SetReg(0, (u64)result); | ||
| 34 | } | ||
| 35 | |||
| 36 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 37 | // Function wrappers that return type Result | ||
| 38 | |||
| 39 | template <Result func(Core::System&, u64)> | ||
| 40 | void SvcWrap64(Core::System& system) { | ||
| 41 | FuncReturn(system, func(system, Param(system, 0)).raw); | ||
| 42 | } | ||
| 43 | |||
| 44 | template <Result func(Core::System&, u64, u64)> | ||
| 45 | void SvcWrap64(Core::System& system) { | ||
| 46 | FuncReturn(system, func(system, Param(system, 0), Param(system, 1)).raw); | ||
| 47 | } | ||
| 48 | |||
| 49 | template <Result func(Core::System&, u32)> | ||
| 50 | void SvcWrap64(Core::System& system) { | ||
| 51 | FuncReturn(system, func(system, static_cast<u32>(Param(system, 0))).raw); | ||
| 52 | } | ||
| 53 | |||
| 54 | template <Result func(Core::System&, u32, u32)> | ||
| 55 | void SvcWrap64(Core::System& system) { | ||
| 56 | FuncReturn( | ||
| 57 | system, | ||
| 58 | func(system, static_cast<u32>(Param(system, 0)), static_cast<u32>(Param(system, 1))).raw); | ||
| 59 | } | ||
| 60 | |||
| 61 | // Used by SetThreadActivity | ||
| 62 | template <Result func(Core::System&, Handle, Svc::ThreadActivity)> | ||
| 63 | void SvcWrap64(Core::System& system) { | ||
| 64 | FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), | ||
| 65 | static_cast<Svc::ThreadActivity>(Param(system, 1))) | ||
| 66 | .raw); | ||
| 67 | } | ||
| 68 | |||
| 69 | template <Result func(Core::System&, u32, u64, u64, u64)> | ||
| 70 | void SvcWrap64(Core::System& system) { | ||
| 71 | FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1), | ||
| 72 | Param(system, 2), Param(system, 3)) | ||
| 73 | .raw); | ||
| 74 | } | ||
| 75 | |||
| 76 | // Used by MapProcessMemory and UnmapProcessMemory | ||
| 77 | template <Result func(Core::System&, u64, u32, u64, u64)> | ||
| 78 | void SvcWrap64(Core::System& system) { | ||
| 79 | FuncReturn(system, func(system, Param(system, 0), static_cast<u32>(Param(system, 1)), | ||
| 80 | Param(system, 2), Param(system, 3)) | ||
| 81 | .raw); | ||
| 82 | } | ||
| 83 | |||
| 84 | // Used by ControlCodeMemory | ||
| 85 | template <Result func(Core::System&, Handle, u32, VAddr, size_t, Svc::MemoryPermission)> | ||
| 86 | void SvcWrap64(Core::System& system) { | ||
| 87 | FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), | ||
| 88 | static_cast<u32>(Param(system, 1)), Param(system, 2), Param(system, 3), | ||
| 89 | static_cast<Svc::MemoryPermission>(Param(system, 4))) | ||
| 90 | .raw); | ||
| 91 | } | ||
| 92 | |||
| 93 | template <Result func(Core::System&, u32*)> | ||
| 94 | void SvcWrap64(Core::System& system) { | ||
| 95 | u32 param = 0; | ||
| 96 | const u32 retval = func(system, ¶m).raw; | ||
| 97 | system.CurrentArmInterface().SetReg(1, param); | ||
| 98 | FuncReturn(system, retval); | ||
| 99 | } | ||
| 100 | |||
| 101 | template <Result func(Core::System&, u32*, u32)> | ||
| 102 | void SvcWrap64(Core::System& system) { | ||
| 103 | u32 param_1 = 0; | ||
| 104 | const u32 retval = func(system, ¶m_1, static_cast<u32>(Param(system, 1))).raw; | ||
| 105 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 106 | FuncReturn(system, retval); | ||
| 107 | } | ||
| 108 | |||
| 109 | template <Result func(Core::System&, u32*, u32*)> | ||
| 110 | void SvcWrap64(Core::System& system) { | ||
| 111 | u32 param_1 = 0; | ||
| 112 | u32 param_2 = 0; | ||
| 113 | const u32 retval = func(system, ¶m_1, ¶m_2).raw; | ||
| 114 | |||
| 115 | auto& arm_interface = system.CurrentArmInterface(); | ||
| 116 | arm_interface.SetReg(1, param_1); | ||
| 117 | arm_interface.SetReg(2, param_2); | ||
| 118 | |||
| 119 | FuncReturn(system, retval); | ||
| 120 | } | ||
| 121 | |||
| 122 | template <Result func(Core::System&, u32*, u64)> | ||
| 123 | void SvcWrap64(Core::System& system) { | ||
| 124 | u32 param_1 = 0; | ||
| 125 | const u32 retval = func(system, ¶m_1, Param(system, 1)).raw; | ||
| 126 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 127 | FuncReturn(system, retval); | ||
| 128 | } | ||
| 129 | |||
| 130 | template <Result func(Core::System&, u32*, u64, u32)> | ||
| 131 | void SvcWrap64(Core::System& system) { | ||
| 132 | u32 param_1 = 0; | ||
| 133 | const u32 retval = | ||
| 134 | func(system, ¶m_1, Param(system, 1), static_cast<u32>(Param(system, 2))).raw; | ||
| 135 | |||
| 136 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 137 | FuncReturn(system, retval); | ||
| 138 | } | ||
| 139 | |||
| 140 | template <Result func(Core::System&, u64*, u32)> | ||
| 141 | void SvcWrap64(Core::System& system) { | ||
| 142 | u64 param_1 = 0; | ||
| 143 | const u32 retval = func(system, ¶m_1, static_cast<u32>(Param(system, 1))).raw; | ||
| 144 | |||
| 145 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 146 | FuncReturn(system, retval); | ||
| 147 | } | ||
| 148 | |||
| 149 | template <Result func(Core::System&, u64, u32)> | ||
| 150 | void SvcWrap64(Core::System& system) { | ||
| 151 | FuncReturn(system, func(system, Param(system, 0), static_cast<u32>(Param(system, 1))).raw); | ||
| 152 | } | ||
| 153 | |||
| 154 | template <Result func(Core::System&, u64*, u64)> | ||
| 155 | void SvcWrap64(Core::System& system) { | ||
| 156 | u64 param_1 = 0; | ||
| 157 | const u32 retval = func(system, ¶m_1, Param(system, 1)).raw; | ||
| 158 | |||
| 159 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 160 | FuncReturn(system, retval); | ||
| 161 | } | ||
| 162 | |||
| 163 | template <Result func(Core::System&, u64*, u32, u32)> | ||
| 164 | void SvcWrap64(Core::System& system) { | ||
| 165 | u64 param_1 = 0; | ||
| 166 | const u32 retval = func(system, ¶m_1, static_cast<u32>(Param(system, 1)), | ||
| 167 | static_cast<u32>(Param(system, 2))) | ||
| 168 | .raw; | ||
| 169 | |||
| 170 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 171 | FuncReturn(system, retval); | ||
| 172 | } | ||
| 173 | |||
| 174 | // Used by GetResourceLimitLimitValue. | ||
| 175 | template <Result func(Core::System&, u64*, Handle, Svc::LimitableResource)> | ||
| 176 | void SvcWrap64(Core::System& system) { | ||
| 177 | u64 param_1 = 0; | ||
| 178 | const u32 retval = func(system, ¶m_1, static_cast<Handle>(Param(system, 1)), | ||
| 179 | static_cast<Svc::LimitableResource>(Param(system, 2))) | ||
| 180 | .raw; | ||
| 181 | |||
| 182 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 183 | FuncReturn(system, retval); | ||
| 184 | } | ||
| 185 | |||
| 186 | template <Result func(Core::System&, u32, u64)> | ||
| 187 | void SvcWrap64(Core::System& system) { | ||
| 188 | FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1)).raw); | ||
| 189 | } | ||
| 190 | |||
| 191 | // Used by SetResourceLimitLimitValue | ||
| 192 | template <Result func(Core::System&, Handle, Svc::LimitableResource, u64)> | ||
| 193 | void SvcWrap64(Core::System& system) { | ||
| 194 | FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), | ||
| 195 | static_cast<Svc::LimitableResource>(Param(system, 1)), Param(system, 2)) | ||
| 196 | .raw); | ||
| 197 | } | ||
| 198 | |||
| 199 | // Used by SetThreadCoreMask | ||
| 200 | template <Result func(Core::System&, Handle, s32, u64)> | ||
| 201 | void SvcWrap64(Core::System& system) { | ||
| 202 | FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), | ||
| 203 | static_cast<s32>(Param(system, 1)), Param(system, 2)) | ||
| 204 | .raw); | ||
| 205 | } | ||
| 206 | |||
| 207 | // Used by GetThreadCoreMask | ||
| 208 | template <Result func(Core::System&, Handle, s32*, u64*)> | ||
| 209 | void SvcWrap64(Core::System& system) { | ||
| 210 | s32 param_1 = 0; | ||
| 211 | u64 param_2 = 0; | ||
| 212 | const Result retval = func(system, static_cast<u32>(Param(system, 2)), ¶m_1, ¶m_2); | ||
| 213 | |||
| 214 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 215 | system.CurrentArmInterface().SetReg(2, param_2); | ||
| 216 | FuncReturn(system, retval.raw); | ||
| 217 | } | ||
| 218 | |||
| 219 | template <Result func(Core::System&, u64, u64, u32, u32)> | ||
| 220 | void SvcWrap64(Core::System& system) { | ||
| 221 | FuncReturn(system, func(system, Param(system, 0), Param(system, 1), | ||
| 222 | static_cast<u32>(Param(system, 2)), static_cast<u32>(Param(system, 3))) | ||
| 223 | .raw); | ||
| 224 | } | ||
| 225 | |||
| 226 | template <Result func(Core::System&, u64, u64, u32, u64)> | ||
| 227 | void SvcWrap64(Core::System& system) { | ||
| 228 | FuncReturn(system, func(system, Param(system, 0), Param(system, 1), | ||
| 229 | static_cast<u32>(Param(system, 2)), Param(system, 3)) | ||
| 230 | .raw); | ||
| 231 | } | ||
| 232 | |||
| 233 | template <Result func(Core::System&, u32, u64, u32)> | ||
| 234 | void SvcWrap64(Core::System& system) { | ||
| 235 | FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1), | ||
| 236 | static_cast<u32>(Param(system, 2))) | ||
| 237 | .raw); | ||
| 238 | } | ||
| 239 | |||
| 240 | template <Result func(Core::System&, u64, u64, u64)> | ||
| 241 | void SvcWrap64(Core::System& system) { | ||
| 242 | FuncReturn(system, func(system, Param(system, 0), Param(system, 1), Param(system, 2)).raw); | ||
| 243 | } | ||
| 244 | |||
| 245 | template <Result func(Core::System&, u64, u64, u32)> | ||
| 246 | void SvcWrap64(Core::System& system) { | ||
| 247 | FuncReturn( | ||
| 248 | system, | ||
| 249 | func(system, Param(system, 0), Param(system, 1), static_cast<u32>(Param(system, 2))).raw); | ||
| 250 | } | ||
| 251 | |||
| 252 | // Used by SetMemoryPermission | ||
| 253 | template <Result func(Core::System&, u64, u64, Svc::MemoryPermission)> | ||
| 254 | void SvcWrap64(Core::System& system) { | ||
| 255 | FuncReturn(system, func(system, Param(system, 0), Param(system, 1), | ||
| 256 | static_cast<Svc::MemoryPermission>(Param(system, 2))) | ||
| 257 | .raw); | ||
| 258 | } | ||
| 259 | |||
| 260 | // Used by MapSharedMemory | ||
| 261 | template <Result func(Core::System&, Handle, u64, u64, Svc::MemoryPermission)> | ||
| 262 | void SvcWrap64(Core::System& system) { | ||
| 263 | FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), Param(system, 1), | ||
| 264 | Param(system, 2), static_cast<Svc::MemoryPermission>(Param(system, 3))) | ||
| 265 | .raw); | ||
| 266 | } | ||
| 267 | |||
| 268 | template <Result func(Core::System&, u32, u64, u64)> | ||
| 269 | void SvcWrap64(Core::System& system) { | ||
| 270 | FuncReturn( | ||
| 271 | system, | ||
| 272 | func(system, static_cast<u32>(Param(system, 0)), Param(system, 1), Param(system, 2)).raw); | ||
| 273 | } | ||
| 274 | |||
| 275 | // Used by WaitSynchronization | ||
| 276 | template <Result func(Core::System&, s32*, u64, s32, s64)> | ||
| 277 | void SvcWrap64(Core::System& system) { | ||
| 278 | s32 param_1 = 0; | ||
| 279 | const u32 retval = func(system, ¶m_1, Param(system, 1), static_cast<s32>(Param(system, 2)), | ||
| 280 | static_cast<s64>(Param(system, 3))) | ||
| 281 | .raw; | ||
| 282 | |||
| 283 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 284 | FuncReturn(system, retval); | ||
| 285 | } | ||
| 286 | |||
| 287 | template <Result func(Core::System&, u64, u64, u32, s64)> | ||
| 288 | void SvcWrap64(Core::System& system) { | ||
| 289 | FuncReturn(system, func(system, Param(system, 0), Param(system, 1), | ||
| 290 | static_cast<u32>(Param(system, 2)), static_cast<s64>(Param(system, 3))) | ||
| 291 | .raw); | ||
| 292 | } | ||
| 293 | |||
| 294 | // Used by GetInfo | ||
| 295 | template <Result func(Core::System&, u64*, u64, Handle, u64)> | ||
| 296 | void SvcWrap64(Core::System& system) { | ||
| 297 | u64 param_1 = 0; | ||
| 298 | const u32 retval = func(system, ¶m_1, Param(system, 1), | ||
| 299 | static_cast<Handle>(Param(system, 2)), Param(system, 3)) | ||
| 300 | .raw; | ||
| 301 | |||
| 302 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 303 | FuncReturn(system, retval); | ||
| 304 | } | ||
| 305 | |||
| 306 | template <Result func(Core::System&, u32*, u64, u64, u64, u32, s32)> | ||
| 307 | void SvcWrap64(Core::System& system) { | ||
| 308 | u32 param_1 = 0; | ||
| 309 | const u32 retval = func(system, ¶m_1, Param(system, 1), Param(system, 2), Param(system, 3), | ||
| 310 | static_cast<u32>(Param(system, 4)), static_cast<s32>(Param(system, 5))) | ||
| 311 | .raw; | ||
| 312 | |||
| 313 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 314 | FuncReturn(system, retval); | ||
| 315 | } | ||
| 316 | |||
| 317 | // Used by CreateTransferMemory | ||
| 318 | template <Result func(Core::System&, Handle*, u64, u64, Svc::MemoryPermission)> | ||
| 319 | void SvcWrap64(Core::System& system) { | ||
| 320 | u32 param_1 = 0; | ||
| 321 | const u32 retval = func(system, ¶m_1, Param(system, 1), Param(system, 2), | ||
| 322 | static_cast<Svc::MemoryPermission>(Param(system, 3))) | ||
| 323 | .raw; | ||
| 324 | |||
| 325 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 326 | FuncReturn(system, retval); | ||
| 327 | } | ||
| 328 | |||
| 329 | // Used by CreateCodeMemory | ||
| 330 | template <Result func(Core::System&, Handle*, VAddr, size_t)> | ||
| 331 | void SvcWrap64(Core::System& system) { | ||
| 332 | u32 param_1 = 0; | ||
| 333 | const u32 retval = func(system, ¶m_1, Param(system, 1), Param(system, 2)).raw; | ||
| 334 | |||
| 335 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 336 | FuncReturn(system, retval); | ||
| 337 | } | ||
| 338 | |||
| 339 | template <Result func(Core::System&, Handle*, u64, u32, u32)> | ||
| 340 | void SvcWrap64(Core::System& system) { | ||
| 341 | u32 param_1 = 0; | ||
| 342 | const u32 retval = func(system, ¶m_1, Param(system, 1), static_cast<u32>(Param(system, 2)), | ||
| 343 | static_cast<u32>(Param(system, 3))) | ||
| 344 | .raw; | ||
| 345 | |||
| 346 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 347 | FuncReturn(system, retval); | ||
| 348 | } | ||
| 349 | |||
| 350 | // Used by CreateSession | ||
| 351 | template <Result func(Core::System&, Handle*, Handle*, u32, u64)> | ||
| 352 | void SvcWrap64(Core::System& system) { | ||
| 353 | Handle param_1 = 0; | ||
| 354 | Handle param_2 = 0; | ||
| 355 | const u32 retval = func(system, ¶m_1, ¶m_2, static_cast<u32>(Param(system, 2)), | ||
| 356 | static_cast<u32>(Param(system, 3))) | ||
| 357 | .raw; | ||
| 358 | |||
| 359 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 360 | system.CurrentArmInterface().SetReg(2, param_2); | ||
| 361 | FuncReturn(system, retval); | ||
| 362 | } | ||
| 363 | |||
| 364 | // Used by ReplyAndReceive | ||
| 365 | template <Result func(Core::System&, s32*, Handle*, s32, Handle, s64)> | ||
| 366 | void SvcWrap64(Core::System& system) { | ||
| 367 | s32 param_1 = 0; | ||
| 368 | s32 num_handles = static_cast<s32>(Param(system, 2)); | ||
| 369 | |||
| 370 | std::vector<Handle> handles(num_handles); | ||
| 371 | system.Memory().ReadBlock(Param(system, 1), handles.data(), num_handles * sizeof(Handle)); | ||
| 372 | |||
| 373 | const u32 retval = func(system, ¶m_1, handles.data(), num_handles, | ||
| 374 | static_cast<s32>(Param(system, 3)), static_cast<s64>(Param(system, 4))) | ||
| 375 | .raw; | ||
| 376 | |||
| 377 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 378 | FuncReturn(system, retval); | ||
| 379 | } | ||
| 380 | |||
| 381 | // Used by WaitForAddress | ||
| 382 | template <Result func(Core::System&, u64, Svc::ArbitrationType, s32, s64)> | ||
| 383 | void SvcWrap64(Core::System& system) { | ||
| 384 | FuncReturn(system, | ||
| 385 | func(system, Param(system, 0), static_cast<Svc::ArbitrationType>(Param(system, 1)), | ||
| 386 | static_cast<s32>(Param(system, 2)), static_cast<s64>(Param(system, 3))) | ||
| 387 | .raw); | ||
| 388 | } | ||
| 389 | |||
| 390 | // Used by SignalToAddress | ||
| 391 | template <Result func(Core::System&, u64, Svc::SignalType, s32, s32)> | ||
| 392 | void SvcWrap64(Core::System& system) { | ||
| 393 | FuncReturn(system, | ||
| 394 | func(system, Param(system, 0), static_cast<Svc::SignalType>(Param(system, 1)), | ||
| 395 | static_cast<s32>(Param(system, 2)), static_cast<s32>(Param(system, 3))) | ||
| 396 | .raw); | ||
| 397 | } | ||
| 398 | |||
| 399 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 400 | // Function wrappers that return type u32 | ||
| 401 | |||
| 402 | template <u32 func(Core::System&)> | ||
| 403 | void SvcWrap64(Core::System& system) { | ||
| 404 | FuncReturn(system, func(system)); | ||
| 405 | } | ||
| 406 | |||
| 407 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 408 | // Function wrappers that return type u64 | ||
| 409 | |||
| 410 | template <u64 func(Core::System&)> | ||
| 411 | void SvcWrap64(Core::System& system) { | ||
| 412 | FuncReturn(system, func(system)); | ||
| 413 | } | ||
| 414 | |||
| 415 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 416 | /// Function wrappers that return type void | ||
| 417 | |||
| 418 | template <void func(Core::System&)> | ||
| 419 | void SvcWrap64(Core::System& system) { | ||
| 420 | func(system); | ||
| 421 | } | ||
| 422 | |||
| 423 | template <void func(Core::System&, u32)> | ||
| 424 | void SvcWrap64(Core::System& system) { | ||
| 425 | func(system, static_cast<u32>(Param(system, 0))); | ||
| 426 | } | ||
| 427 | |||
| 428 | template <void func(Core::System&, u32, u64, u64, u64)> | ||
| 429 | void SvcWrap64(Core::System& system) { | ||
| 430 | func(system, static_cast<u32>(Param(system, 0)), Param(system, 1), Param(system, 2), | ||
| 431 | Param(system, 3)); | ||
| 432 | } | ||
| 433 | |||
| 434 | template <void func(Core::System&, s64)> | ||
| 435 | void SvcWrap64(Core::System& system) { | ||
| 436 | func(system, static_cast<s64>(Param(system, 0))); | ||
| 437 | } | ||
| 438 | |||
| 439 | template <void func(Core::System&, u64, s32)> | ||
| 440 | void SvcWrap64(Core::System& system) { | ||
| 441 | func(system, Param(system, 0), static_cast<s32>(Param(system, 1))); | ||
| 442 | } | ||
| 443 | |||
| 444 | template <void func(Core::System&, u64, u64)> | ||
| 445 | void SvcWrap64(Core::System& system) { | ||
| 446 | func(system, Param(system, 0), Param(system, 1)); | ||
| 447 | } | ||
| 448 | |||
| 449 | template <void func(Core::System&, u64, u64, u64)> | ||
| 450 | void SvcWrap64(Core::System& system) { | ||
| 451 | func(system, Param(system, 0), Param(system, 1), Param(system, 2)); | ||
| 452 | } | ||
| 453 | |||
| 454 | template <void func(Core::System&, u32, u64, u64)> | ||
| 455 | void SvcWrap64(Core::System& system) { | ||
| 456 | func(system, static_cast<u32>(Param(system, 0)), Param(system, 1), Param(system, 2)); | ||
| 457 | } | ||
| 458 | |||
| 459 | // Used by QueryMemory32, ArbitrateLock32 | ||
| 460 | template <Result func(Core::System&, u32, u32, u32)> | ||
| 461 | void SvcWrap32(Core::System& system) { | ||
| 462 | FuncReturn32(system, | ||
| 463 | func(system, Param32(system, 0), Param32(system, 1), Param32(system, 2)).raw); | ||
| 464 | } | ||
| 465 | |||
| 466 | // Used by Break32 | ||
| 467 | template <void func(Core::System&, u32, u32, u32)> | ||
| 468 | void SvcWrap32(Core::System& system) { | ||
| 469 | func(system, Param32(system, 0), Param32(system, 1), Param32(system, 2)); | ||
| 470 | } | ||
| 471 | |||
| 472 | // Used by ExitProcess32, ExitThread32 | ||
| 473 | template <void func(Core::System&)> | ||
| 474 | void SvcWrap32(Core::System& system) { | ||
| 475 | func(system); | ||
| 476 | } | ||
| 477 | |||
| 478 | // Used by GetCurrentProcessorNumber32 | ||
| 479 | template <u32 func(Core::System&)> | ||
| 480 | void SvcWrap32(Core::System& system) { | ||
| 481 | FuncReturn32(system, func(system)); | ||
| 482 | } | ||
| 483 | |||
| 484 | // Used by SleepThread32 | ||
| 485 | template <void func(Core::System&, u32, u32)> | ||
| 486 | void SvcWrap32(Core::System& system) { | ||
| 487 | func(system, Param32(system, 0), Param32(system, 1)); | ||
| 488 | } | ||
| 489 | |||
| 490 | // Used by CreateThread32 | ||
| 491 | template <Result func(Core::System&, Handle*, u32, u32, u32, u32, s32)> | ||
| 492 | void SvcWrap32(Core::System& system) { | ||
| 493 | Handle param_1 = 0; | ||
| 494 | |||
| 495 | const u32 retval = func(system, ¶m_1, Param32(system, 0), Param32(system, 1), | ||
| 496 | Param32(system, 2), Param32(system, 3), Param32(system, 4)) | ||
| 497 | .raw; | ||
| 498 | |||
| 499 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 500 | FuncReturn(system, retval); | ||
| 501 | } | ||
| 502 | |||
| 503 | // Used by GetInfo32 | ||
| 504 | template <Result func(Core::System&, u32*, u32*, u32, u32, u32, u32)> | ||
| 505 | void SvcWrap32(Core::System& system) { | ||
| 506 | u32 param_1 = 0; | ||
| 507 | u32 param_2 = 0; | ||
| 508 | |||
| 509 | const u32 retval = func(system, ¶m_1, ¶m_2, Param32(system, 0), Param32(system, 1), | ||
| 510 | Param32(system, 2), Param32(system, 3)) | ||
| 511 | .raw; | ||
| 512 | |||
| 513 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 514 | system.CurrentArmInterface().SetReg(2, param_2); | ||
| 515 | FuncReturn(system, retval); | ||
| 516 | } | ||
| 517 | |||
| 518 | // Used by GetThreadPriority32, ConnectToNamedPort32 | ||
| 519 | template <Result func(Core::System&, u32*, u32)> | ||
| 520 | void SvcWrap32(Core::System& system) { | ||
| 521 | u32 param_1 = 0; | ||
| 522 | const u32 retval = func(system, ¶m_1, Param32(system, 1)).raw; | ||
| 523 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 524 | FuncReturn(system, retval); | ||
| 525 | } | ||
| 526 | |||
| 527 | // Used by GetThreadId32 | ||
| 528 | template <Result func(Core::System&, u32*, u32*, u32)> | ||
| 529 | void SvcWrap32(Core::System& system) { | ||
| 530 | u32 param_1 = 0; | ||
| 531 | u32 param_2 = 0; | ||
| 532 | |||
| 533 | const u32 retval = func(system, ¶m_1, ¶m_2, Param32(system, 1)).raw; | ||
| 534 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 535 | system.CurrentArmInterface().SetReg(2, param_2); | ||
| 536 | FuncReturn(system, retval); | ||
| 537 | } | ||
| 538 | |||
| 539 | // Used by GetSystemTick32 | ||
| 540 | template <void func(Core::System&, u32*, u32*)> | ||
| 541 | void SvcWrap32(Core::System& system) { | ||
| 542 | u32 param_1 = 0; | ||
| 543 | u32 param_2 = 0; | ||
| 544 | |||
| 545 | func(system, ¶m_1, ¶m_2); | ||
| 546 | system.CurrentArmInterface().SetReg(0, param_1); | ||
| 547 | system.CurrentArmInterface().SetReg(1, param_2); | ||
| 548 | } | ||
| 549 | |||
| 550 | // Used by CreateEvent32 | ||
| 551 | template <Result func(Core::System&, Handle*, Handle*)> | ||
| 552 | void SvcWrap32(Core::System& system) { | ||
| 553 | Handle param_1 = 0; | ||
| 554 | Handle param_2 = 0; | ||
| 555 | |||
| 556 | const u32 retval = func(system, ¶m_1, ¶m_2).raw; | ||
| 557 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 558 | system.CurrentArmInterface().SetReg(2, param_2); | ||
| 559 | FuncReturn(system, retval); | ||
| 560 | } | ||
| 561 | |||
| 562 | // Used by GetThreadId32 | ||
| 563 | template <Result func(Core::System&, Handle, u32*, u32*, u32*)> | ||
| 564 | void SvcWrap32(Core::System& system) { | ||
| 565 | u32 param_1 = 0; | ||
| 566 | u32 param_2 = 0; | ||
| 567 | u32 param_3 = 0; | ||
| 568 | |||
| 569 | const u32 retval = func(system, Param32(system, 2), ¶m_1, ¶m_2, ¶m_3).raw; | ||
| 570 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 571 | system.CurrentArmInterface().SetReg(2, param_2); | ||
| 572 | system.CurrentArmInterface().SetReg(3, param_3); | ||
| 573 | FuncReturn(system, retval); | ||
| 574 | } | ||
| 575 | |||
| 576 | // Used by GetThreadCoreMask32 | ||
| 577 | template <Result func(Core::System&, Handle, s32*, u32*, u32*)> | ||
| 578 | void SvcWrap32(Core::System& system) { | ||
| 579 | s32 param_1 = 0; | ||
| 580 | u32 param_2 = 0; | ||
| 581 | u32 param_3 = 0; | ||
| 582 | |||
| 583 | const u32 retval = func(system, Param32(system, 2), ¶m_1, ¶m_2, ¶m_3).raw; | ||
| 584 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 585 | system.CurrentArmInterface().SetReg(2, param_2); | ||
| 586 | system.CurrentArmInterface().SetReg(3, param_3); | ||
| 587 | FuncReturn(system, retval); | ||
| 588 | } | ||
| 589 | |||
| 590 | // Used by SignalProcessWideKey32 | ||
| 591 | template <void func(Core::System&, u32, s32)> | ||
| 592 | void SvcWrap32(Core::System& system) { | ||
| 593 | func(system, static_cast<u32>(Param(system, 0)), static_cast<s32>(Param(system, 1))); | ||
| 594 | } | ||
| 595 | |||
| 596 | // Used by SetThreadActivity32 | ||
| 597 | template <Result func(Core::System&, Handle, Svc::ThreadActivity)> | ||
| 598 | void SvcWrap32(Core::System& system) { | ||
| 599 | const u32 retval = func(system, static_cast<Handle>(Param(system, 0)), | ||
| 600 | static_cast<Svc::ThreadActivity>(Param(system, 1))) | ||
| 601 | .raw; | ||
| 602 | FuncReturn(system, retval); | ||
| 603 | } | ||
| 604 | |||
| 605 | // Used by SetThreadPriority32 | ||
| 606 | template <Result func(Core::System&, Handle, u32)> | ||
| 607 | void SvcWrap32(Core::System& system) { | ||
| 608 | const u32 retval = | ||
| 609 | func(system, static_cast<Handle>(Param(system, 0)), static_cast<u32>(Param(system, 1))).raw; | ||
| 610 | FuncReturn(system, retval); | ||
| 611 | } | ||
| 612 | |||
| 613 | // Used by SetMemoryAttribute32 | ||
| 614 | template <Result func(Core::System&, Handle, u32, u32, u32)> | ||
| 615 | void SvcWrap32(Core::System& system) { | ||
| 616 | const u32 retval = | ||
| 617 | func(system, static_cast<Handle>(Param(system, 0)), static_cast<u32>(Param(system, 1)), | ||
| 618 | static_cast<u32>(Param(system, 2)), static_cast<u32>(Param(system, 3))) | ||
| 619 | .raw; | ||
| 620 | FuncReturn(system, retval); | ||
| 621 | } | ||
| 622 | |||
| 623 | // Used by MapSharedMemory32 | ||
| 624 | template <Result func(Core::System&, Handle, u32, u32, Svc::MemoryPermission)> | ||
| 625 | void SvcWrap32(Core::System& system) { | ||
| 626 | const u32 retval = func(system, static_cast<Handle>(Param(system, 0)), | ||
| 627 | static_cast<u32>(Param(system, 1)), static_cast<u32>(Param(system, 2)), | ||
| 628 | static_cast<Svc::MemoryPermission>(Param(system, 3))) | ||
| 629 | .raw; | ||
| 630 | FuncReturn(system, retval); | ||
| 631 | } | ||
| 632 | |||
| 633 | // Used by SetThreadCoreMask32 | ||
| 634 | template <Result func(Core::System&, Handle, s32, u32, u32)> | ||
| 635 | void SvcWrap32(Core::System& system) { | ||
| 636 | const u32 retval = | ||
| 637 | func(system, static_cast<Handle>(Param(system, 0)), static_cast<s32>(Param(system, 1)), | ||
| 638 | static_cast<u32>(Param(system, 2)), static_cast<u32>(Param(system, 3))) | ||
| 639 | .raw; | ||
| 640 | FuncReturn(system, retval); | ||
| 641 | } | ||
| 642 | |||
| 643 | // Used by WaitProcessWideKeyAtomic32 | ||
| 644 | template <Result func(Core::System&, u32, u32, Handle, u32, u32)> | ||
| 645 | void SvcWrap32(Core::System& system) { | ||
| 646 | const u32 retval = | ||
| 647 | func(system, static_cast<u32>(Param(system, 0)), static_cast<u32>(Param(system, 1)), | ||
| 648 | static_cast<Handle>(Param(system, 2)), static_cast<u32>(Param(system, 3)), | ||
| 649 | static_cast<u32>(Param(system, 4))) | ||
| 650 | .raw; | ||
| 651 | FuncReturn(system, retval); | ||
| 652 | } | ||
| 653 | |||
| 654 | // Used by WaitForAddress32 | ||
| 655 | template <Result func(Core::System&, u32, Svc::ArbitrationType, s32, u32, u32)> | ||
| 656 | void SvcWrap32(Core::System& system) { | ||
| 657 | const u32 retval = func(system, static_cast<u32>(Param(system, 0)), | ||
| 658 | static_cast<Svc::ArbitrationType>(Param(system, 1)), | ||
| 659 | static_cast<s32>(Param(system, 2)), static_cast<u32>(Param(system, 3)), | ||
| 660 | static_cast<u32>(Param(system, 4))) | ||
| 661 | .raw; | ||
| 662 | FuncReturn(system, retval); | ||
| 663 | } | ||
| 664 | |||
| 665 | // Used by SignalToAddress32 | ||
| 666 | template <Result func(Core::System&, u32, Svc::SignalType, s32, s32)> | ||
| 667 | void SvcWrap32(Core::System& system) { | ||
| 668 | const u32 retval = func(system, static_cast<u32>(Param(system, 0)), | ||
| 669 | static_cast<Svc::SignalType>(Param(system, 1)), | ||
| 670 | static_cast<s32>(Param(system, 2)), static_cast<s32>(Param(system, 3))) | ||
| 671 | .raw; | ||
| 672 | FuncReturn(system, retval); | ||
| 673 | } | ||
| 674 | |||
| 675 | // Used by SendSyncRequest32, ArbitrateUnlock32 | ||
| 676 | template <Result func(Core::System&, u32)> | ||
| 677 | void SvcWrap32(Core::System& system) { | ||
| 678 | FuncReturn(system, func(system, static_cast<u32>(Param(system, 0))).raw); | ||
| 679 | } | ||
| 680 | |||
| 681 | // Used by CreateTransferMemory32 | ||
| 682 | template <Result func(Core::System&, Handle*, u32, u32, Svc::MemoryPermission)> | ||
| 683 | void SvcWrap32(Core::System& system) { | ||
| 684 | Handle handle = 0; | ||
| 685 | const u32 retval = func(system, &handle, Param32(system, 1), Param32(system, 2), | ||
| 686 | static_cast<Svc::MemoryPermission>(Param32(system, 3))) | ||
| 687 | .raw; | ||
| 688 | system.CurrentArmInterface().SetReg(1, handle); | ||
| 689 | FuncReturn(system, retval); | ||
| 690 | } | ||
| 691 | |||
| 692 | // Used by WaitSynchronization32 | ||
| 693 | template <Result func(Core::System&, u32, u32, s32, u32, s32*)> | ||
| 694 | void SvcWrap32(Core::System& system) { | ||
| 695 | s32 param_1 = 0; | ||
| 696 | const u32 retval = func(system, Param32(system, 0), Param32(system, 1), Param32(system, 2), | ||
| 697 | Param32(system, 3), ¶m_1) | ||
| 698 | .raw; | ||
| 699 | system.CurrentArmInterface().SetReg(1, param_1); | ||
| 700 | FuncReturn(system, retval); | ||
| 701 | } | ||
| 702 | |||
| 703 | // Used by CreateCodeMemory32 | ||
| 704 | template <Result func(Core::System&, Handle*, u32, u32)> | ||
| 705 | void SvcWrap32(Core::System& system) { | ||
| 706 | Handle handle = 0; | ||
| 707 | |||
| 708 | const u32 retval = func(system, &handle, Param32(system, 1), Param32(system, 2)).raw; | ||
| 709 | |||
| 710 | system.CurrentArmInterface().SetReg(1, handle); | ||
| 711 | FuncReturn(system, retval); | ||
| 712 | } | ||
| 713 | |||
| 714 | // Used by ControlCodeMemory32 | ||
| 715 | template <Result func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)> | ||
| 716 | void SvcWrap32(Core::System& system) { | ||
| 717 | const u32 retval = | ||
| 718 | func(system, Param32(system, 0), Param32(system, 1), Param(system, 2), Param(system, 4), | ||
| 719 | static_cast<Svc::MemoryPermission>(Param32(system, 6))) | ||
| 720 | .raw; | ||
| 721 | |||
| 722 | FuncReturn(system, retval); | ||
| 723 | } | ||
| 724 | |||
| 725 | // Used by Invalidate/Store/FlushProcessDataCache32 | ||
| 726 | template <Result func(Core::System&, Handle, u64, u64)> | ||
| 727 | void SvcWrap32(Core::System& system) { | ||
| 728 | const u64 address = (Param(system, 3) << 32) | Param(system, 2); | ||
| 729 | const u64 size = (Param(system, 4) << 32) | Param(system, 1); | ||
| 730 | FuncReturn32(system, func(system, Param32(system, 0), address, size).raw); | ||
| 731 | } | ||
| 732 | |||
| 733 | } // namespace Kernel | ||