diff options
| author | 2023-12-06 14:19:17 +0100 | |
|---|---|---|
| committer | 2023-12-06 14:19:17 +0100 | |
| commit | 8a79dd2d6c6445bff63ea1f2f5f1611a6afcd97a (patch) | |
| tree | 265bf3c7970a570479c6a3ac1250549995f0329c | |
| parent | Merge pull request #12271 from liamwhite/pretext-fix (diff) | |
| parent | arm: fix context save of vector regs (diff) | |
| download | yuzu-8a79dd2d6c6445bff63ea1f2f5f1611a6afcd97a.tar.gz yuzu-8a79dd2d6c6445bff63ea1f2f5f1611a6afcd97a.tar.xz yuzu-8a79dd2d6c6445bff63ea1f2f5f1611a6afcd97a.zip | |
Merge pull request #12236 from liamwhite/cpu-refactor
core: refactor emulated cpu core activation
Diffstat (limited to '')
47 files changed, 2925 insertions, 3275 deletions
diff --git a/.codespellrc b/.codespellrc index d1f998449..1874359d3 100644 --- a/.codespellrc +++ b/.codespellrc | |||
| @@ -3,4 +3,4 @@ | |||
| 3 | 3 | ||
| 4 | [codespell] | 4 | [codespell] |
| 5 | skip = ./.git,./build,./dist,./Doxyfile,./externals,./LICENSES,./src/android/app/src/main/res | 5 | skip = ./.git,./build,./dist,./Doxyfile,./externals,./LICENSES,./src/android/app/src/main/res |
| 6 | ignore-words-list = aci,allright,ba,canonicalizations,deques,froms,hda,inout,lod,masia,nam,nax,nce,nd,optin,pullrequests,pullrequest,te,transfered,unstall,uscaled,vas,zink | 6 | ignore-words-list = aci,allright,ba,canonicalizations,deques,fpr,froms,hda,inout,lod,masia,nam,nax,nce,nd,optin,pullrequests,pullrequest,te,transfered,unstall,uscaled,vas,zink |
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 85583941c..e2120bdfe 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | add_library(core STATIC | 4 | add_library(core STATIC |
| 5 | arm/arm_interface.h | 5 | arm/arm_interface.h |
| 6 | arm/arm_interface.cpp | 6 | arm/arm_interface.cpp |
| 7 | arm/debug.cpp | ||
| 8 | arm/debug.h | ||
| 7 | arm/exclusive_monitor.cpp | 9 | arm/exclusive_monitor.cpp |
| 8 | arm/exclusive_monitor.h | 10 | arm/exclusive_monitor.h |
| 9 | arm/symbols.cpp | 11 | arm/symbols.cpp |
diff --git a/src/core/arm/arm_interface.cpp b/src/core/arm/arm_interface.cpp index d231bf89c..698c9c8ad 100644 --- a/src/core/arm/arm_interface.cpp +++ b/src/core/arm/arm_interface.cpp | |||
| @@ -1,231 +1,32 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 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 <map> | ||
| 5 | #include <optional> | ||
| 6 | |||
| 7 | #include "common/bit_field.h" | ||
| 8 | #include "common/common_types.h" | ||
| 9 | #include "common/demangle.h" | ||
| 10 | #include "common/logging/log.h" | 4 | #include "common/logging/log.h" |
| 11 | #include "core/arm/arm_interface.h" | 5 | #include "core/arm/arm_interface.h" |
| 12 | #include "core/arm/symbols.h" | 6 | #include "core/arm/debug.h" |
| 13 | #include "core/core.h" | 7 | #include "core/core.h" |
| 14 | #include "core/debugger/debugger.h" | ||
| 15 | #include "core/hle/kernel/k_process.h" | 8 | #include "core/hle/kernel/k_process.h" |
| 16 | #include "core/hle/kernel/k_thread.h" | ||
| 17 | #include "core/hle/kernel/svc.h" | ||
| 18 | #include "core/loader/loader.h" | ||
| 19 | #include "core/memory.h" | ||
| 20 | 9 | ||
| 21 | namespace Core { | 10 | namespace Core { |
| 22 | 11 | ||
| 23 | constexpr u64 SEGMENT_BASE = 0x7100000000ull; | 12 | void ArmInterface::LogBacktrace(const Kernel::KProcess* process) const { |
| 24 | 13 | Kernel::Svc::ThreadContext ctx; | |
| 25 | std::vector<ARM_Interface::BacktraceEntry> ARM_Interface::GetBacktraceFromContext( | 14 | this->GetContext(ctx); |
| 26 | Core::System& system, const ARM_Interface::ThreadContext32& ctx) { | ||
| 27 | std::vector<BacktraceEntry> out; | ||
| 28 | auto& memory = system.ApplicationMemory(); | ||
| 29 | |||
| 30 | const auto& reg = ctx.cpu_registers; | ||
| 31 | u32 pc = reg[15], lr = reg[14], fp = reg[11]; | ||
| 32 | out.push_back({"", 0, pc, 0, ""}); | ||
| 33 | |||
| 34 | // fp (= r11) points to the last frame record. | ||
| 35 | // Frame records are two words long: | ||
| 36 | // fp+0 : pointer to previous frame record | ||
| 37 | // fp+4 : value of lr for frame | ||
| 38 | for (size_t i = 0; i < 256; i++) { | ||
| 39 | out.push_back({"", 0, lr, 0, ""}); | ||
| 40 | if (!fp || (fp % 4 != 0) || !memory.IsValidVirtualAddressRange(fp, 8)) { | ||
| 41 | break; | ||
| 42 | } | ||
| 43 | lr = memory.Read32(fp + 4); | ||
| 44 | fp = memory.Read32(fp); | ||
| 45 | } | ||
| 46 | |||
| 47 | SymbolicateBacktrace(system, out); | ||
| 48 | |||
| 49 | return out; | ||
| 50 | } | ||
| 51 | |||
| 52 | std::vector<ARM_Interface::BacktraceEntry> ARM_Interface::GetBacktraceFromContext( | ||
| 53 | Core::System& system, const ARM_Interface::ThreadContext64& ctx) { | ||
| 54 | std::vector<BacktraceEntry> out; | ||
| 55 | auto& memory = system.ApplicationMemory(); | ||
| 56 | |||
| 57 | const auto& reg = ctx.cpu_registers; | ||
| 58 | u64 pc = ctx.pc, lr = reg[30], fp = reg[29]; | ||
| 59 | |||
| 60 | out.push_back({"", 0, pc, 0, ""}); | ||
| 61 | |||
| 62 | // fp (= x29) points to the previous frame record. | ||
| 63 | // Frame records are two words long: | ||
| 64 | // fp+0 : pointer to previous frame record | ||
| 65 | // fp+8 : value of lr for frame | ||
| 66 | for (size_t i = 0; i < 256; i++) { | ||
| 67 | out.push_back({"", 0, lr, 0, ""}); | ||
| 68 | if (!fp || (fp % 4 != 0) || !memory.IsValidVirtualAddressRange(fp, 16)) { | ||
| 69 | break; | ||
| 70 | } | ||
| 71 | lr = memory.Read64(fp + 8); | ||
| 72 | fp = memory.Read64(fp); | ||
| 73 | } | ||
| 74 | |||
| 75 | SymbolicateBacktrace(system, out); | ||
| 76 | |||
| 77 | return out; | ||
| 78 | } | ||
| 79 | |||
| 80 | void ARM_Interface::SymbolicateBacktrace(Core::System& system, std::vector<BacktraceEntry>& out) { | ||
| 81 | std::map<VAddr, std::string> modules; | ||
| 82 | auto& loader{system.GetAppLoader()}; | ||
| 83 | if (loader.ReadNSOModules(modules) != Loader::ResultStatus::Success) { | ||
| 84 | return; | ||
| 85 | } | ||
| 86 | |||
| 87 | std::map<std::string, Symbols::Symbols> symbols; | ||
| 88 | for (const auto& module : modules) { | ||
| 89 | symbols.insert_or_assign(module.second, | ||
| 90 | Symbols::GetSymbols(module.first, system.ApplicationMemory(), | ||
| 91 | system.ApplicationProcess()->Is64Bit())); | ||
| 92 | } | ||
| 93 | |||
| 94 | for (auto& entry : out) { | ||
| 95 | VAddr base = 0; | ||
| 96 | for (auto iter = modules.rbegin(); iter != modules.rend(); ++iter) { | ||
| 97 | const auto& module{*iter}; | ||
| 98 | if (entry.original_address >= module.first) { | ||
| 99 | entry.module = module.second; | ||
| 100 | base = module.first; | ||
| 101 | break; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | entry.offset = entry.original_address - base; | ||
| 106 | entry.address = SEGMENT_BASE + entry.offset; | ||
| 107 | |||
| 108 | if (entry.module.empty()) { | ||
| 109 | entry.module = "unknown"; | ||
| 110 | } | ||
| 111 | |||
| 112 | const auto symbol_set = symbols.find(entry.module); | ||
| 113 | if (symbol_set != symbols.end()) { | ||
| 114 | const auto symbol = Symbols::GetSymbolName(symbol_set->second, entry.offset); | ||
| 115 | if (symbol) { | ||
| 116 | entry.name = Common::DemangleSymbol(*symbol); | ||
| 117 | } | ||
| 118 | } | ||
| 119 | } | ||
| 120 | } | ||
| 121 | |||
| 122 | std::vector<ARM_Interface::BacktraceEntry> ARM_Interface::GetBacktrace() const { | ||
| 123 | if (GetArchitecture() == Architecture::Aarch64) { | ||
| 124 | ThreadContext64 ctx; | ||
| 125 | SaveContext(ctx); | ||
| 126 | return GetBacktraceFromContext(system, ctx); | ||
| 127 | } else { | ||
| 128 | ThreadContext32 ctx; | ||
| 129 | SaveContext(ctx); | ||
| 130 | return GetBacktraceFromContext(system, ctx); | ||
| 131 | } | ||
| 132 | } | ||
| 133 | 15 | ||
| 134 | void ARM_Interface::LogBacktrace() const { | 16 | LOG_ERROR(Core_ARM, "Backtrace, sp={:016X}, pc={:016X}", ctx.sp, ctx.pc); |
| 135 | const VAddr sp = GetSP(); | ||
| 136 | const VAddr pc = GetPC(); | ||
| 137 | LOG_ERROR(Core_ARM, "Backtrace, sp={:016X}, pc={:016X}", sp, pc); | ||
| 138 | LOG_ERROR(Core_ARM, "{:20}{:20}{:20}{:20}{}", "Module Name", "Address", "Original Address", | 17 | LOG_ERROR(Core_ARM, "{:20}{:20}{:20}{:20}{}", "Module Name", "Address", "Original Address", |
| 139 | "Offset", "Symbol"); | 18 | "Offset", "Symbol"); |
| 140 | LOG_ERROR(Core_ARM, ""); | 19 | LOG_ERROR(Core_ARM, ""); |
| 141 | const auto backtrace = GetBacktrace(); | 20 | const auto backtrace = GetBacktraceFromContext(process, ctx); |
| 142 | for (const auto& entry : backtrace) { | 21 | for (const auto& entry : backtrace) { |
| 143 | LOG_ERROR(Core_ARM, "{:20}{:016X} {:016X} {:016X} {}", entry.module, entry.address, | 22 | LOG_ERROR(Core_ARM, "{:20}{:016X} {:016X} {:016X} {}", entry.module, entry.address, |
| 144 | entry.original_address, entry.offset, entry.name); | 23 | entry.original_address, entry.offset, entry.name); |
| 145 | } | 24 | } |
| 146 | } | 25 | } |
| 147 | 26 | ||
| 148 | void ARM_Interface::Run() { | 27 | const Kernel::DebugWatchpoint* ArmInterface::MatchingWatchpoint( |
| 149 | using Kernel::StepState; | ||
| 150 | using Kernel::SuspendType; | ||
| 151 | |||
| 152 | while (true) { | ||
| 153 | Kernel::KThread* current_thread{Kernel::GetCurrentThreadPointer(system.Kernel())}; | ||
| 154 | HaltReason hr{}; | ||
| 155 | |||
| 156 | // If the thread is scheduled for termination, exit the thread. | ||
| 157 | if (current_thread->HasDpc()) { | ||
| 158 | if (current_thread->IsTerminationRequested()) { | ||
| 159 | current_thread->Exit(); | ||
| 160 | UNREACHABLE(); | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 164 | // Notify the debugger and go to sleep if a step was performed | ||
| 165 | // and this thread has been scheduled again. | ||
| 166 | if (current_thread->GetStepState() == StepState::StepPerformed) { | ||
| 167 | system.GetDebugger().NotifyThreadStopped(current_thread); | ||
| 168 | current_thread->RequestSuspend(SuspendType::Debug); | ||
| 169 | break; | ||
| 170 | } | ||
| 171 | |||
| 172 | // Otherwise, run the thread. | ||
| 173 | system.EnterCPUProfile(); | ||
| 174 | if (current_thread->GetStepState() == StepState::StepPending) { | ||
| 175 | hr = StepJit(); | ||
| 176 | |||
| 177 | if (True(hr & HaltReason::StepThread)) { | ||
| 178 | current_thread->SetStepState(StepState::StepPerformed); | ||
| 179 | } | ||
| 180 | } else { | ||
| 181 | hr = RunJit(); | ||
| 182 | } | ||
| 183 | system.ExitCPUProfile(); | ||
| 184 | |||
| 185 | // Notify the debugger and go to sleep if a breakpoint was hit, | ||
| 186 | // or if the thread is unable to continue for any reason. | ||
| 187 | if (True(hr & HaltReason::InstructionBreakpoint) || True(hr & HaltReason::PrefetchAbort)) { | ||
| 188 | if (!True(hr & HaltReason::PrefetchAbort)) { | ||
| 189 | RewindBreakpointInstruction(); | ||
| 190 | } | ||
| 191 | if (system.DebuggerEnabled()) { | ||
| 192 | system.GetDebugger().NotifyThreadStopped(current_thread); | ||
| 193 | } else { | ||
| 194 | LogBacktrace(); | ||
| 195 | } | ||
| 196 | current_thread->RequestSuspend(SuspendType::Debug); | ||
| 197 | break; | ||
| 198 | } | ||
| 199 | |||
| 200 | // Notify the debugger and go to sleep if a watchpoint was hit. | ||
| 201 | if (True(hr & HaltReason::DataAbort)) { | ||
| 202 | if (system.DebuggerEnabled()) { | ||
| 203 | system.GetDebugger().NotifyThreadWatchpoint(current_thread, *HaltedWatchpoint()); | ||
| 204 | } else { | ||
| 205 | LogBacktrace(); | ||
| 206 | } | ||
| 207 | current_thread->RequestSuspend(SuspendType::Debug); | ||
| 208 | break; | ||
| 209 | } | ||
| 210 | |||
| 211 | // Handle syscalls and scheduling (this may change the current thread/core) | ||
| 212 | if (True(hr & HaltReason::SupervisorCall)) { | ||
| 213 | Kernel::Svc::Call(system, GetSvcNumber()); | ||
| 214 | break; | ||
| 215 | } | ||
| 216 | if (True(hr & HaltReason::BreakLoop) || !uses_wall_clock) { | ||
| 217 | break; | ||
| 218 | } | ||
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 222 | void ARM_Interface::LoadWatchpointArray(const WatchpointArray* wp) { | ||
| 223 | watchpoints = wp; | ||
| 224 | } | ||
| 225 | |||
| 226 | const Kernel::DebugWatchpoint* ARM_Interface::MatchingWatchpoint( | ||
| 227 | u64 addr, u64 size, Kernel::DebugWatchpointType access_type) const { | 28 | u64 addr, u64 size, Kernel::DebugWatchpointType access_type) const { |
| 228 | if (!watchpoints) { | 29 | if (!m_watchpoints) { |
| 229 | return nullptr; | 30 | return nullptr; |
| 230 | } | 31 | } |
| 231 | 32 | ||
| @@ -233,7 +34,7 @@ const Kernel::DebugWatchpoint* ARM_Interface::MatchingWatchpoint( | |||
| 233 | const u64 end_address{addr + size}; | 34 | const u64 end_address{addr + size}; |
| 234 | 35 | ||
| 235 | for (size_t i = 0; i < Core::Hardware::NUM_WATCHPOINTS; i++) { | 36 | for (size_t i = 0; i < Core::Hardware::NUM_WATCHPOINTS; i++) { |
| 236 | const auto& watch{(*watchpoints)[i]}; | 37 | const auto& watch{(*m_watchpoints)[i]}; |
| 237 | 38 | ||
| 238 | if (end_address <= GetInteger(watch.start_address)) { | 39 | if (end_address <= GetInteger(watch.start_address)) { |
| 239 | continue; | 40 | continue; |
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index a9d9ac09d..806c7c9e9 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h | |||
| @@ -12,20 +12,20 @@ | |||
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "core/hardware_properties.h" | 13 | #include "core/hardware_properties.h" |
| 14 | 14 | ||
| 15 | #include "core/hle/kernel/svc_types.h" | ||
| 16 | |||
| 15 | namespace Common { | 17 | namespace Common { |
| 16 | struct PageTable; | 18 | struct PageTable; |
| 17 | } | 19 | } |
| 18 | 20 | ||
| 19 | namespace Kernel { | 21 | namespace Kernel { |
| 20 | enum class VMAPermission : u8; | ||
| 21 | enum class DebugWatchpointType : u8; | 22 | enum class DebugWatchpointType : u8; |
| 22 | struct DebugWatchpoint; | 23 | struct DebugWatchpoint; |
| 24 | class KThread; | ||
| 25 | class KProcess; | ||
| 23 | } // namespace Kernel | 26 | } // namespace Kernel |
| 24 | 27 | ||
| 25 | namespace Core { | 28 | namespace Core { |
| 26 | class System; | ||
| 27 | class CPUInterruptHandler; | ||
| 28 | |||
| 29 | using WatchpointArray = std::array<Kernel::DebugWatchpoint, Core::Hardware::NUM_WATCHPOINTS>; | 29 | using WatchpointArray = std::array<Kernel::DebugWatchpoint, Core::Hardware::NUM_WATCHPOINTS>; |
| 30 | 30 | ||
| 31 | // NOTE: these values match the HaltReason enum in Dynarmic | 31 | // NOTE: these values match the HaltReason enum in Dynarmic |
| @@ -40,197 +40,74 @@ enum class HaltReason : u64 { | |||
| 40 | DECLARE_ENUM_FLAG_OPERATORS(HaltReason); | 40 | DECLARE_ENUM_FLAG_OPERATORS(HaltReason); |
| 41 | 41 | ||
| 42 | enum class Architecture { | 42 | enum class Architecture { |
| 43 | Aarch32, | 43 | AArch64, |
| 44 | Aarch64, | 44 | AArch32, |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | /// Generic ARMv8 CPU interface | 47 | /// Generic ARMv8 CPU interface |
| 48 | class ARM_Interface { | 48 | class ArmInterface { |
| 49 | public: | 49 | public: |
| 50 | YUZU_NON_COPYABLE(ARM_Interface); | 50 | YUZU_NON_COPYABLE(ArmInterface); |
| 51 | YUZU_NON_MOVEABLE(ARM_Interface); | 51 | YUZU_NON_MOVEABLE(ArmInterface); |
| 52 | 52 | ||
| 53 | explicit ARM_Interface(System& system_, bool uses_wall_clock_) | 53 | explicit ArmInterface(bool uses_wall_clock) : m_uses_wall_clock{uses_wall_clock} {} |
| 54 | : system{system_}, uses_wall_clock{uses_wall_clock_} {} | 54 | virtual ~ArmInterface() = default; |
| 55 | virtual ~ARM_Interface() = default; | 55 | |
| 56 | 56 | // Perform any backend-specific initialization. | |
| 57 | struct ThreadContext32 { | ||
| 58 | std::array<u32, 16> cpu_registers{}; | ||
| 59 | std::array<u32, 64> extension_registers{}; | ||
| 60 | u32 cpsr{}; | ||
| 61 | u32 fpscr{}; | ||
| 62 | u32 fpexc{}; | ||
| 63 | u32 tpidr{}; | ||
| 64 | }; | ||
| 65 | // Internally within the kernel, it expects the AArch32 version of the | ||
| 66 | // thread context to be 344 bytes in size. | ||
| 67 | static_assert(sizeof(ThreadContext32) == 0x150); | ||
| 68 | |||
| 69 | struct ThreadContext64 { | ||
| 70 | std::array<u64, 31> cpu_registers{}; | ||
| 71 | u64 sp{}; | ||
| 72 | u64 pc{}; | ||
| 73 | u32 pstate{}; | ||
| 74 | std::array<u8, 4> padding{}; | ||
| 75 | std::array<u128, 32> vector_registers{}; | ||
| 76 | u32 fpcr{}; | ||
| 77 | u32 fpsr{}; | ||
| 78 | u64 tpidr{}; | ||
| 79 | }; | ||
| 80 | // Internally within the kernel, it expects the AArch64 version of the | ||
| 81 | // thread context to be 800 bytes in size. | ||
| 82 | static_assert(sizeof(ThreadContext64) == 0x320); | ||
| 83 | |||
| 84 | /// Perform any backend-specific initialization. | ||
| 85 | virtual void Initialize() {} | 57 | virtual void Initialize() {} |
| 86 | 58 | ||
| 87 | /// Runs the CPU until an event happens | 59 | // Runs the CPU until an event happens. |
| 88 | void Run(); | 60 | virtual HaltReason RunThread(Kernel::KThread* thread) = 0; |
| 89 | 61 | ||
| 90 | /// Clear all instruction cache | 62 | // Runs the CPU for one instruction or until an event happens. |
| 63 | virtual HaltReason StepThread(Kernel::KThread* thread) = 0; | ||
| 64 | |||
| 65 | // Admits a backend-specific mechanism to lock the thread context. | ||
| 66 | virtual void LockThread(Kernel::KThread* thread) {} | ||
| 67 | virtual void UnlockThread(Kernel::KThread* thread) {} | ||
| 68 | |||
| 69 | // Clear the entire instruction cache for this CPU. | ||
| 91 | virtual void ClearInstructionCache() = 0; | 70 | virtual void ClearInstructionCache() = 0; |
| 92 | 71 | ||
| 93 | /** | 72 | // Clear a range of the instruction cache for this CPU. |
| 94 | * Clear instruction cache range | ||
| 95 | * @param addr Start address of the cache range to clear | ||
| 96 | * @param size Size of the cache range to clear, starting at addr | ||
| 97 | */ | ||
| 98 | virtual void InvalidateCacheRange(u64 addr, std::size_t size) = 0; | 73 | virtual void InvalidateCacheRange(u64 addr, std::size_t size) = 0; |
| 99 | 74 | ||
| 100 | /** | 75 | // Get the current architecture. |
| 101 | * Notifies CPU emulation that the current page table has changed. | 76 | // This returns AArch64 when PSTATE.nRW == 0 and AArch32 when PSTATE.nRW == 1. |
| 102 | * @param new_page_table The new page table. | ||
| 103 | * @param new_address_space_size_in_bits The new usable size of the address space in bits. | ||
| 104 | * This can be either 32, 36, or 39 on official software. | ||
| 105 | */ | ||
| 106 | virtual void PageTableChanged(Common::PageTable& new_page_table, | ||
| 107 | std::size_t new_address_space_size_in_bits) = 0; | ||
| 108 | |||
| 109 | /** | ||
| 110 | * Set the Program Counter to an address | ||
| 111 | * @param addr Address to set PC to | ||
| 112 | */ | ||
| 113 | virtual void SetPC(u64 addr) = 0; | ||
| 114 | |||
| 115 | /* | ||
| 116 | * Get the current Program Counter | ||
| 117 | * @return Returns current PC | ||
| 118 | */ | ||
| 119 | virtual u64 GetPC() const = 0; | ||
| 120 | |||
| 121 | /** | ||
| 122 | * Get the current Stack Pointer | ||
| 123 | * @return Returns current SP | ||
| 124 | */ | ||
| 125 | virtual u64 GetSP() const = 0; | ||
| 126 | |||
| 127 | /** | ||
| 128 | * Get an ARM register | ||
| 129 | * @param index Register index | ||
| 130 | * @return Returns the value in the register | ||
| 131 | */ | ||
| 132 | virtual u64 GetReg(int index) const = 0; | ||
| 133 | |||
| 134 | /** | ||
| 135 | * Set an ARM register | ||
| 136 | * @param index Register index | ||
| 137 | * @param value Value to set register to | ||
| 138 | */ | ||
| 139 | virtual void SetReg(int index, u64 value) = 0; | ||
| 140 | |||
| 141 | /** | ||
| 142 | * Gets the value of a specified vector register. | ||
| 143 | * | ||
| 144 | * @param index The index of the vector register. | ||
| 145 | * @return the value within the vector register. | ||
| 146 | */ | ||
| 147 | virtual u128 GetVectorReg(int index) const = 0; | ||
| 148 | |||
| 149 | /** | ||
| 150 | * Sets a given value into a vector register. | ||
| 151 | * | ||
| 152 | * @param index The index of the vector register. | ||
| 153 | * @param value The new value to place in the register. | ||
| 154 | */ | ||
| 155 | virtual void SetVectorReg(int index, u128 value) = 0; | ||
| 156 | |||
| 157 | /** | ||
| 158 | * Get the current PSTATE register | ||
| 159 | * @return Returns the value of the PSTATE register | ||
| 160 | */ | ||
| 161 | virtual u32 GetPSTATE() const = 0; | ||
| 162 | |||
| 163 | /** | ||
| 164 | * Set the current PSTATE register | ||
| 165 | * @param pstate Value to set PSTATE to | ||
| 166 | */ | ||
| 167 | virtual void SetPSTATE(u32 pstate) = 0; | ||
| 168 | |||
| 169 | virtual u64 GetTlsAddress() const = 0; | ||
| 170 | |||
| 171 | virtual void SetTlsAddress(u64 address) = 0; | ||
| 172 | |||
| 173 | /** | ||
| 174 | * Gets the value within the TPIDR_EL0 (read/write software thread ID) register. | ||
| 175 | * | ||
| 176 | * @return the value within the register. | ||
| 177 | */ | ||
| 178 | virtual u64 GetTPIDR_EL0() const = 0; | ||
| 179 | |||
| 180 | /** | ||
| 181 | * Sets a new value within the TPIDR_EL0 (read/write software thread ID) register. | ||
| 182 | * | ||
| 183 | * @param value The new value to place in the register. | ||
| 184 | */ | ||
| 185 | virtual void SetTPIDR_EL0(u64 value) = 0; | ||
| 186 | |||
| 187 | virtual Architecture GetArchitecture() const = 0; | 77 | virtual Architecture GetArchitecture() const = 0; |
| 188 | virtual void SaveContext(ThreadContext32& ctx) const = 0; | ||
| 189 | virtual void SaveContext(ThreadContext64& ctx) const = 0; | ||
| 190 | virtual void LoadContext(const ThreadContext32& ctx) = 0; | ||
| 191 | virtual void LoadContext(const ThreadContext64& ctx) = 0; | ||
| 192 | void LoadWatchpointArray(const WatchpointArray* wp); | ||
| 193 | 78 | ||
| 194 | /// Clears the exclusive monitor's state. | 79 | // Context accessors. |
| 195 | virtual void ClearExclusiveState() = 0; | 80 | // These should not be called if the CPU is running. |
| 81 | virtual void GetContext(Kernel::Svc::ThreadContext& ctx) const = 0; | ||
| 82 | virtual void SetContext(const Kernel::Svc::ThreadContext& ctx) = 0; | ||
| 83 | virtual void SetTpidrroEl0(u64 value) = 0; | ||
| 196 | 84 | ||
| 197 | /// Signal an interrupt and ask the core to halt as soon as possible. | 85 | virtual void GetSvcArguments(std::span<uint64_t, 8> args) const = 0; |
| 198 | virtual void SignalInterrupt() = 0; | 86 | virtual void SetSvcArguments(std::span<const uint64_t, 8> args) = 0; |
| 87 | virtual u32 GetSvcNumber() const = 0; | ||
| 199 | 88 | ||
| 200 | /// Clear a previous interrupt. | 89 | void SetWatchpointArray(const WatchpointArray* watchpoints) { |
| 201 | virtual void ClearInterrupt() = 0; | 90 | m_watchpoints = watchpoints; |
| 91 | } | ||
| 202 | 92 | ||
| 203 | struct BacktraceEntry { | 93 | // Signal an interrupt for execution to halt as soon as possible. |
| 204 | std::string module; | 94 | // It is safe to call this if the CPU is not running. |
| 205 | u64 address; | 95 | virtual void SignalInterrupt(Kernel::KThread* thread) = 0; |
| 206 | u64 original_address; | ||
| 207 | u64 offset; | ||
| 208 | std::string name; | ||
| 209 | }; | ||
| 210 | 96 | ||
| 211 | static std::vector<BacktraceEntry> GetBacktraceFromContext(System& system, | 97 | // Stack trace generation. |
| 212 | const ThreadContext32& ctx); | 98 | void LogBacktrace(const Kernel::KProcess* process) const; |
| 213 | static std::vector<BacktraceEntry> GetBacktraceFromContext(System& system, | ||
| 214 | const ThreadContext64& ctx); | ||
| 215 | 99 | ||
| 216 | std::vector<BacktraceEntry> GetBacktrace() const; | 100 | // Debug functionality. |
| 217 | void LogBacktrace() const; | 101 | virtual const Kernel::DebugWatchpoint* HaltedWatchpoint() const = 0; |
| 102 | virtual void RewindBreakpointInstruction() = 0; | ||
| 218 | 103 | ||
| 219 | protected: | 104 | protected: |
| 220 | /// System context that this ARM interface is running under. | ||
| 221 | System& system; | ||
| 222 | const WatchpointArray* watchpoints; | ||
| 223 | bool uses_wall_clock; | ||
| 224 | |||
| 225 | static void SymbolicateBacktrace(Core::System& system, std::vector<BacktraceEntry>& out); | ||
| 226 | const Kernel::DebugWatchpoint* MatchingWatchpoint( | 105 | const Kernel::DebugWatchpoint* MatchingWatchpoint( |
| 227 | u64 addr, u64 size, Kernel::DebugWatchpointType access_type) const; | 106 | u64 addr, u64 size, Kernel::DebugWatchpointType access_type) const; |
| 228 | 107 | ||
| 229 | virtual HaltReason RunJit() = 0; | 108 | protected: |
| 230 | virtual HaltReason StepJit() = 0; | 109 | const WatchpointArray* m_watchpoints{}; |
| 231 | virtual u32 GetSvcNumber() const = 0; | 110 | bool m_uses_wall_clock{}; |
| 232 | virtual const Kernel::DebugWatchpoint* HaltedWatchpoint() const = 0; | ||
| 233 | virtual void RewindBreakpointInstruction() = 0; | ||
| 234 | }; | 111 | }; |
| 235 | 112 | ||
| 236 | } // namespace Core | 113 | } // namespace Core |
diff --git a/src/core/arm/debug.cpp b/src/core/arm/debug.cpp new file mode 100644 index 000000000..1fe37b8ee --- /dev/null +++ b/src/core/arm/debug.cpp | |||
| @@ -0,0 +1,351 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "common/demangle.h" | ||
| 5 | #include "core/arm/debug.h" | ||
| 6 | #include "core/arm/symbols.h" | ||
| 7 | #include "core/hle/kernel/k_process.h" | ||
| 8 | #include "core/hle/kernel/k_thread.h" | ||
| 9 | #include "core/memory.h" | ||
| 10 | |||
| 11 | namespace Core { | ||
| 12 | |||
| 13 | namespace { | ||
| 14 | |||
| 15 | std::optional<std::string> GetNameFromThreadType64(Core::Memory::Memory& memory, | ||
| 16 | const Kernel::KThread& thread) { | ||
| 17 | // Read thread type from TLS | ||
| 18 | const VAddr tls_thread_type{memory.Read64(thread.GetTlsAddress() + 0x1f8)}; | ||
| 19 | const VAddr argument_thread_type{thread.GetArgument()}; | ||
| 20 | |||
| 21 | if (argument_thread_type && tls_thread_type != argument_thread_type) { | ||
| 22 | // Probably not created by nnsdk, no name available. | ||
| 23 | return std::nullopt; | ||
| 24 | } | ||
| 25 | |||
| 26 | if (!tls_thread_type) { | ||
| 27 | return std::nullopt; | ||
| 28 | } | ||
| 29 | |||
| 30 | const u16 version{memory.Read16(tls_thread_type + 0x46)}; | ||
| 31 | VAddr name_pointer{}; | ||
| 32 | if (version == 1) { | ||
| 33 | name_pointer = memory.Read64(tls_thread_type + 0x1a0); | ||
| 34 | } else { | ||
| 35 | name_pointer = memory.Read64(tls_thread_type + 0x1a8); | ||
| 36 | } | ||
| 37 | |||
| 38 | if (!name_pointer) { | ||
| 39 | // No name provided. | ||
| 40 | return std::nullopt; | ||
| 41 | } | ||
| 42 | |||
| 43 | return memory.ReadCString(name_pointer, 256); | ||
| 44 | } | ||
| 45 | |||
| 46 | std::optional<std::string> GetNameFromThreadType32(Core::Memory::Memory& memory, | ||
| 47 | const Kernel::KThread& thread) { | ||
| 48 | // Read thread type from TLS | ||
| 49 | const VAddr tls_thread_type{memory.Read32(thread.GetTlsAddress() + 0x1fc)}; | ||
| 50 | const VAddr argument_thread_type{thread.GetArgument()}; | ||
| 51 | |||
| 52 | if (argument_thread_type && tls_thread_type != argument_thread_type) { | ||
| 53 | // Probably not created by nnsdk, no name available. | ||
| 54 | return std::nullopt; | ||
| 55 | } | ||
| 56 | |||
| 57 | if (!tls_thread_type) { | ||
| 58 | return std::nullopt; | ||
| 59 | } | ||
| 60 | |||
| 61 | const u16 version{memory.Read16(tls_thread_type + 0x26)}; | ||
| 62 | VAddr name_pointer{}; | ||
| 63 | if (version == 1) { | ||
| 64 | name_pointer = memory.Read32(tls_thread_type + 0xe4); | ||
| 65 | } else { | ||
| 66 | name_pointer = memory.Read32(tls_thread_type + 0xe8); | ||
| 67 | } | ||
| 68 | |||
| 69 | if (!name_pointer) { | ||
| 70 | // No name provided. | ||
| 71 | return std::nullopt; | ||
| 72 | } | ||
| 73 | |||
| 74 | return memory.ReadCString(name_pointer, 256); | ||
| 75 | } | ||
| 76 | |||
| 77 | constexpr std::array<u64, 2> SegmentBases{ | ||
| 78 | 0x60000000ULL, | ||
| 79 | 0x7100000000ULL, | ||
| 80 | }; | ||
| 81 | |||
| 82 | void SymbolicateBacktrace(const Kernel::KProcess* process, std::vector<BacktraceEntry>& out) { | ||
| 83 | auto modules = FindModules(process); | ||
| 84 | |||
| 85 | const bool is_64 = process->Is64Bit(); | ||
| 86 | |||
| 87 | std::map<std::string, Symbols::Symbols> symbols; | ||
| 88 | for (const auto& module : modules) { | ||
| 89 | symbols.insert_or_assign(module.second, | ||
| 90 | Symbols::GetSymbols(module.first, process->GetMemory(), is_64)); | ||
| 91 | } | ||
| 92 | |||
| 93 | for (auto& entry : out) { | ||
| 94 | VAddr base = 0; | ||
| 95 | for (auto iter = modules.rbegin(); iter != modules.rend(); ++iter) { | ||
| 96 | const auto& module{*iter}; | ||
| 97 | if (entry.original_address >= module.first) { | ||
| 98 | entry.module = module.second; | ||
| 99 | base = module.first; | ||
| 100 | break; | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | entry.offset = entry.original_address - base; | ||
| 105 | entry.address = SegmentBases[is_64] + entry.offset; | ||
| 106 | |||
| 107 | if (entry.module.empty()) { | ||
| 108 | entry.module = "unknown"; | ||
| 109 | } | ||
| 110 | |||
| 111 | const auto symbol_set = symbols.find(entry.module); | ||
| 112 | if (symbol_set != symbols.end()) { | ||
| 113 | const auto symbol = Symbols::GetSymbolName(symbol_set->second, entry.offset); | ||
| 114 | if (symbol) { | ||
| 115 | entry.name = Common::DemangleSymbol(*symbol); | ||
| 116 | } | ||
| 117 | } | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 121 | std::vector<BacktraceEntry> GetAArch64Backtrace(const Kernel::KProcess* process, | ||
| 122 | const Kernel::Svc::ThreadContext& ctx) { | ||
| 123 | std::vector<BacktraceEntry> out; | ||
| 124 | auto& memory = process->GetMemory(); | ||
| 125 | auto pc = ctx.pc, lr = ctx.lr, fp = ctx.fp; | ||
| 126 | |||
| 127 | out.push_back({"", 0, pc, 0, ""}); | ||
| 128 | |||
| 129 | // fp (= x29) points to the previous frame record. | ||
| 130 | // Frame records are two words long: | ||
| 131 | // fp+0 : pointer to previous frame record | ||
| 132 | // fp+8 : value of lr for frame | ||
| 133 | for (size_t i = 0; i < 256; i++) { | ||
| 134 | out.push_back({"", 0, lr, 0, ""}); | ||
| 135 | if (!fp || (fp % 4 != 0) || !memory.IsValidVirtualAddressRange(fp, 16)) { | ||
| 136 | break; | ||
| 137 | } | ||
| 138 | lr = memory.Read64(fp + 8); | ||
| 139 | fp = memory.Read64(fp); | ||
| 140 | } | ||
| 141 | |||
| 142 | SymbolicateBacktrace(process, out); | ||
| 143 | |||
| 144 | return out; | ||
| 145 | } | ||
| 146 | |||
| 147 | std::vector<BacktraceEntry> GetAArch32Backtrace(const Kernel::KProcess* process, | ||
| 148 | const Kernel::Svc::ThreadContext& ctx) { | ||
| 149 | std::vector<BacktraceEntry> out; | ||
| 150 | auto& memory = process->GetMemory(); | ||
| 151 | auto pc = ctx.pc, lr = ctx.lr, fp = ctx.fp; | ||
| 152 | |||
| 153 | out.push_back({"", 0, pc, 0, ""}); | ||
| 154 | |||
| 155 | // fp (= r11) points to the last frame record. | ||
| 156 | // Frame records are two words long: | ||
| 157 | // fp+0 : pointer to previous frame record | ||
| 158 | // fp+4 : value of lr for frame | ||
| 159 | for (size_t i = 0; i < 256; i++) { | ||
| 160 | out.push_back({"", 0, lr, 0, ""}); | ||
| 161 | if (!fp || (fp % 4 != 0) || !memory.IsValidVirtualAddressRange(fp, 8)) { | ||
| 162 | break; | ||
| 163 | } | ||
| 164 | lr = memory.Read32(fp + 4); | ||
| 165 | fp = memory.Read32(fp); | ||
| 166 | } | ||
| 167 | |||
| 168 | SymbolicateBacktrace(process, out); | ||
| 169 | |||
| 170 | return out; | ||
| 171 | } | ||
| 172 | |||
| 173 | } // namespace | ||
| 174 | |||
| 175 | std::optional<std::string> GetThreadName(const Kernel::KThread* thread) { | ||
| 176 | const auto* process = thread->GetOwnerProcess(); | ||
| 177 | if (process->Is64Bit()) { | ||
| 178 | return GetNameFromThreadType64(process->GetMemory(), *thread); | ||
| 179 | } else { | ||
| 180 | return GetNameFromThreadType32(process->GetMemory(), *thread); | ||
| 181 | } | ||
| 182 | } | ||
| 183 | |||
| 184 | std::string_view GetThreadWaitReason(const Kernel::KThread* thread) { | ||
| 185 | switch (thread->GetWaitReasonForDebugging()) { | ||
| 186 | case Kernel::ThreadWaitReasonForDebugging::Sleep: | ||
| 187 | return "Sleep"; | ||
| 188 | case Kernel::ThreadWaitReasonForDebugging::IPC: | ||
| 189 | return "IPC"; | ||
| 190 | case Kernel::ThreadWaitReasonForDebugging::Synchronization: | ||
| 191 | return "Synchronization"; | ||
| 192 | case Kernel::ThreadWaitReasonForDebugging::ConditionVar: | ||
| 193 | return "ConditionVar"; | ||
| 194 | case Kernel::ThreadWaitReasonForDebugging::Arbitration: | ||
| 195 | return "Arbitration"; | ||
| 196 | case Kernel::ThreadWaitReasonForDebugging::Suspended: | ||
| 197 | return "Suspended"; | ||
| 198 | default: | ||
| 199 | return "Unknown"; | ||
| 200 | } | ||
| 201 | } | ||
| 202 | |||
| 203 | std::string GetThreadState(const Kernel::KThread* thread) { | ||
| 204 | switch (thread->GetState()) { | ||
| 205 | case Kernel::ThreadState::Initialized: | ||
| 206 | return "Initialized"; | ||
| 207 | case Kernel::ThreadState::Waiting: | ||
| 208 | return fmt::format("Waiting ({})", GetThreadWaitReason(thread)); | ||
| 209 | case Kernel::ThreadState::Runnable: | ||
| 210 | return "Runnable"; | ||
| 211 | case Kernel::ThreadState::Terminated: | ||
| 212 | return "Terminated"; | ||
| 213 | default: | ||
| 214 | return "Unknown"; | ||
| 215 | } | ||
| 216 | } | ||
| 217 | |||
| 218 | Kernel::KProcessAddress GetModuleEnd(const Kernel::KProcess* process, | ||
| 219 | Kernel::KProcessAddress base) { | ||
| 220 | Kernel::KMemoryInfo mem_info; | ||
| 221 | Kernel::Svc::MemoryInfo svc_mem_info; | ||
| 222 | Kernel::Svc::PageInfo page_info; | ||
| 223 | VAddr cur_addr{GetInteger(base)}; | ||
| 224 | auto& page_table = process->GetPageTable(); | ||
| 225 | |||
| 226 | // Expect: r-x Code (.text) | ||
| 227 | R_ASSERT(page_table.QueryInfo(std::addressof(mem_info), std::addressof(page_info), cur_addr)); | ||
| 228 | svc_mem_info = mem_info.GetSvcMemoryInfo(); | ||
| 229 | cur_addr = svc_mem_info.base_address + svc_mem_info.size; | ||
| 230 | if (svc_mem_info.state != Kernel::Svc::MemoryState::Code || | ||
| 231 | svc_mem_info.permission != Kernel::Svc::MemoryPermission::ReadExecute) { | ||
| 232 | return cur_addr - 1; | ||
| 233 | } | ||
| 234 | |||
| 235 | // Expect: r-- Code (.rodata) | ||
| 236 | R_ASSERT(page_table.QueryInfo(std::addressof(mem_info), std::addressof(page_info), cur_addr)); | ||
| 237 | svc_mem_info = mem_info.GetSvcMemoryInfo(); | ||
| 238 | cur_addr = svc_mem_info.base_address + svc_mem_info.size; | ||
| 239 | if (svc_mem_info.state != Kernel::Svc::MemoryState::Code || | ||
| 240 | svc_mem_info.permission != Kernel::Svc::MemoryPermission::Read) { | ||
| 241 | return cur_addr - 1; | ||
| 242 | } | ||
| 243 | |||
| 244 | // Expect: rw- CodeData (.data) | ||
| 245 | R_ASSERT(page_table.QueryInfo(std::addressof(mem_info), std::addressof(page_info), cur_addr)); | ||
| 246 | svc_mem_info = mem_info.GetSvcMemoryInfo(); | ||
| 247 | cur_addr = svc_mem_info.base_address + svc_mem_info.size; | ||
| 248 | return cur_addr - 1; | ||
| 249 | } | ||
| 250 | |||
| 251 | Loader::AppLoader::Modules FindModules(const Kernel::KProcess* process) { | ||
| 252 | Loader::AppLoader::Modules modules; | ||
| 253 | |||
| 254 | auto& page_table = process->GetPageTable(); | ||
| 255 | auto& memory = process->GetMemory(); | ||
| 256 | VAddr cur_addr = 0; | ||
| 257 | |||
| 258 | // Look for executable sections in Code or AliasCode regions. | ||
| 259 | while (true) { | ||
| 260 | Kernel::KMemoryInfo mem_info{}; | ||
| 261 | Kernel::Svc::PageInfo page_info{}; | ||
| 262 | R_ASSERT( | ||
| 263 | page_table.QueryInfo(std::addressof(mem_info), std::addressof(page_info), cur_addr)); | ||
| 264 | auto svc_mem_info = mem_info.GetSvcMemoryInfo(); | ||
| 265 | |||
| 266 | if (svc_mem_info.permission == Kernel::Svc::MemoryPermission::ReadExecute && | ||
| 267 | (svc_mem_info.state == Kernel::Svc::MemoryState::Code || | ||
| 268 | svc_mem_info.state == Kernel::Svc::MemoryState::AliasCode)) { | ||
| 269 | // Try to read the module name from its path. | ||
| 270 | constexpr s32 PathLengthMax = 0x200; | ||
| 271 | struct { | ||
| 272 | u32 zero; | ||
| 273 | s32 path_length; | ||
| 274 | std::array<char, PathLengthMax> path; | ||
| 275 | } module_path; | ||
| 276 | |||
| 277 | if (memory.ReadBlock(svc_mem_info.base_address + svc_mem_info.size, &module_path, | ||
| 278 | sizeof(module_path))) { | ||
| 279 | if (module_path.zero == 0 && module_path.path_length > 0) { | ||
| 280 | // Truncate module name. | ||
| 281 | module_path.path[PathLengthMax - 1] = '\0'; | ||
| 282 | |||
| 283 | // Ignore leading directories. | ||
| 284 | char* path_pointer = module_path.path.data(); | ||
| 285 | |||
| 286 | for (s32 i = 0; i < std::min(PathLengthMax, module_path.path_length) && | ||
| 287 | module_path.path[i] != '\0'; | ||
| 288 | i++) { | ||
| 289 | if (module_path.path[i] == '/' || module_path.path[i] == '\\') { | ||
| 290 | path_pointer = module_path.path.data() + i + 1; | ||
| 291 | } | ||
| 292 | } | ||
| 293 | |||
| 294 | // Insert output. | ||
| 295 | modules.emplace(svc_mem_info.base_address, path_pointer); | ||
| 296 | } | ||
| 297 | } | ||
| 298 | } | ||
| 299 | |||
| 300 | // Check if we're done. | ||
| 301 | const uintptr_t next_address = svc_mem_info.base_address + svc_mem_info.size; | ||
| 302 | if (next_address <= cur_addr) { | ||
| 303 | break; | ||
| 304 | } | ||
| 305 | |||
| 306 | cur_addr = next_address; | ||
| 307 | } | ||
| 308 | |||
| 309 | return modules; | ||
| 310 | } | ||
| 311 | |||
| 312 | Kernel::KProcessAddress FindMainModuleEntrypoint(const Kernel::KProcess* process) { | ||
| 313 | // Do we have any loaded executable sections? | ||
| 314 | auto modules = FindModules(process); | ||
| 315 | |||
| 316 | if (modules.size() >= 2) { | ||
| 317 | // If we have two or more, the first one is rtld and the second is main. | ||
| 318 | return std::next(modules.begin())->first; | ||
| 319 | } else if (!modules.empty()) { | ||
| 320 | // If we only have one, this is the main module. | ||
| 321 | return modules.begin()->first; | ||
| 322 | } | ||
| 323 | |||
| 324 | // As a last resort, use the start of the code region. | ||
| 325 | return GetInteger(process->GetPageTable().GetCodeRegionStart()); | ||
| 326 | } | ||
| 327 | |||
| 328 | void InvalidateInstructionCacheRange(const Kernel::KProcess* process, u64 address, u64 size) { | ||
| 329 | for (size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { | ||
| 330 | auto* interface = process->GetArmInterface(i); | ||
| 331 | if (interface) { | ||
| 332 | interface->InvalidateCacheRange(address, size); | ||
| 333 | } | ||
| 334 | } | ||
| 335 | } | ||
| 336 | |||
| 337 | std::vector<BacktraceEntry> GetBacktraceFromContext(const Kernel::KProcess* process, | ||
| 338 | const Kernel::Svc::ThreadContext& ctx) { | ||
| 339 | if (process->Is64Bit()) { | ||
| 340 | return GetAArch64Backtrace(process, ctx); | ||
| 341 | } else { | ||
| 342 | return GetAArch32Backtrace(process, ctx); | ||
| 343 | } | ||
| 344 | } | ||
| 345 | |||
| 346 | std::vector<BacktraceEntry> GetBacktrace(const Kernel::KThread* thread) { | ||
| 347 | Kernel::Svc::ThreadContext ctx = thread->GetContext(); | ||
| 348 | return GetBacktraceFromContext(thread->GetOwnerProcess(), ctx); | ||
| 349 | } | ||
| 350 | |||
| 351 | } // namespace Core | ||
diff --git a/src/core/arm/debug.h b/src/core/arm/debug.h new file mode 100644 index 000000000..c542633db --- /dev/null +++ b/src/core/arm/debug.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <optional> | ||
| 7 | |||
| 8 | #include "core/hle/kernel/k_thread.h" | ||
| 9 | #include "core/loader/loader.h" | ||
| 10 | |||
| 11 | namespace Core { | ||
| 12 | |||
| 13 | std::optional<std::string> GetThreadName(const Kernel::KThread* thread); | ||
| 14 | std::string_view GetThreadWaitReason(const Kernel::KThread* thread); | ||
| 15 | std::string GetThreadState(const Kernel::KThread* thread); | ||
| 16 | |||
| 17 | Loader::AppLoader::Modules FindModules(const Kernel::KProcess* process); | ||
| 18 | Kernel::KProcessAddress GetModuleEnd(const Kernel::KProcess* process, Kernel::KProcessAddress base); | ||
| 19 | Kernel::KProcessAddress FindMainModuleEntrypoint(const Kernel::KProcess* process); | ||
| 20 | |||
| 21 | void InvalidateInstructionCacheRange(const Kernel::KProcess* process, u64 address, u64 size); | ||
| 22 | |||
| 23 | struct BacktraceEntry { | ||
| 24 | std::string module; | ||
| 25 | u64 address; | ||
| 26 | u64 original_address; | ||
| 27 | u64 offset; | ||
| 28 | std::string name; | ||
| 29 | }; | ||
| 30 | |||
| 31 | std::vector<BacktraceEntry> GetBacktraceFromContext(const Kernel::KProcess* process, | ||
| 32 | const Kernel::Svc::ThreadContext& ctx); | ||
| 33 | std::vector<BacktraceEntry> GetBacktrace(const Kernel::KThread* thread); | ||
| 34 | |||
| 35 | } // namespace Core | ||
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 44a297cdc..f34865e26 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp | |||
| @@ -1,25 +1,13 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2020 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 <cinttypes> | ||
| 5 | #include <memory> | ||
| 6 | #include <dynarmic/interface/A32/a32.h> | ||
| 7 | #include <dynarmic/interface/A32/config.h> | ||
| 8 | #include "common/assert.h" | ||
| 9 | #include "common/literals.h" | ||
| 10 | #include "common/logging/log.h" | ||
| 11 | #include "common/page_table.h" | ||
| 12 | #include "common/settings.h" | 4 | #include "common/settings.h" |
| 13 | #include "core/arm/dynarmic/arm_dynarmic.h" | 5 | #include "core/arm/dynarmic/arm_dynarmic.h" |
| 14 | #include "core/arm/dynarmic/arm_dynarmic_32.h" | 6 | #include "core/arm/dynarmic/arm_dynarmic_32.h" |
| 15 | #include "core/arm/dynarmic/dynarmic_cp15.h" | 7 | #include "core/arm/dynarmic/dynarmic_cp15.h" |
| 16 | #include "core/arm/dynarmic/dynarmic_exclusive_monitor.h" | 8 | #include "core/arm/dynarmic/dynarmic_exclusive_monitor.h" |
| 17 | #include "core/core.h" | ||
| 18 | #include "core/core_timing.h" | 9 | #include "core/core_timing.h" |
| 19 | #include "core/debugger/debugger.h" | ||
| 20 | #include "core/hle/kernel/k_process.h" | 10 | #include "core/hle/kernel/k_process.h" |
| 21 | #include "core/hle/kernel/svc.h" | ||
| 22 | #include "core/memory.h" | ||
| 23 | 11 | ||
| 24 | namespace Core { | 12 | namespace Core { |
| 25 | 13 | ||
| @@ -27,78 +15,78 @@ using namespace Common::Literals; | |||
| 27 | 15 | ||
| 28 | class DynarmicCallbacks32 : public Dynarmic::A32::UserCallbacks { | 16 | class DynarmicCallbacks32 : public Dynarmic::A32::UserCallbacks { |
| 29 | public: | 17 | public: |
| 30 | explicit DynarmicCallbacks32(ARM_Dynarmic_32& parent_) | 18 | explicit DynarmicCallbacks32(ArmDynarmic32& parent, const Kernel::KProcess* process) |
| 31 | : parent{parent_}, memory(parent.system.ApplicationMemory()), | 19 | : m_parent{parent}, m_memory(process->GetMemory()), |
| 32 | debugger_enabled{parent.system.DebuggerEnabled()}, | 20 | m_process(process), m_debugger_enabled{parent.m_system.DebuggerEnabled()}, |
| 33 | check_memory_access{debugger_enabled || | 21 | m_check_memory_access{m_debugger_enabled || |
| 34 | !Settings::values.cpuopt_ignore_memory_aborts.GetValue()} {} | 22 | !Settings::values.cpuopt_ignore_memory_aborts.GetValue()} {} |
| 35 | 23 | ||
| 36 | u8 MemoryRead8(u32 vaddr) override { | 24 | u8 MemoryRead8(u32 vaddr) override { |
| 37 | CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Read); | 25 | CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Read); |
| 38 | return memory.Read8(vaddr); | 26 | return m_memory.Read8(vaddr); |
| 39 | } | 27 | } |
| 40 | u16 MemoryRead16(u32 vaddr) override { | 28 | u16 MemoryRead16(u32 vaddr) override { |
| 41 | CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Read); | 29 | CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Read); |
| 42 | return memory.Read16(vaddr); | 30 | return m_memory.Read16(vaddr); |
| 43 | } | 31 | } |
| 44 | u32 MemoryRead32(u32 vaddr) override { | 32 | u32 MemoryRead32(u32 vaddr) override { |
| 45 | CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Read); | 33 | CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Read); |
| 46 | return memory.Read32(vaddr); | 34 | return m_memory.Read32(vaddr); |
| 47 | } | 35 | } |
| 48 | u64 MemoryRead64(u32 vaddr) override { | 36 | u64 MemoryRead64(u32 vaddr) override { |
| 49 | CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Read); | 37 | CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Read); |
| 50 | return memory.Read64(vaddr); | 38 | return m_memory.Read64(vaddr); |
| 51 | } | 39 | } |
| 52 | std::optional<u32> MemoryReadCode(u32 vaddr) override { | 40 | std::optional<u32> MemoryReadCode(u32 vaddr) override { |
| 53 | if (!memory.IsValidVirtualAddressRange(vaddr, sizeof(u32))) { | 41 | if (!m_memory.IsValidVirtualAddressRange(vaddr, sizeof(u32))) { |
| 54 | return std::nullopt; | 42 | return std::nullopt; |
| 55 | } | 43 | } |
| 56 | return memory.Read32(vaddr); | 44 | return m_memory.Read32(vaddr); |
| 57 | } | 45 | } |
| 58 | 46 | ||
| 59 | void MemoryWrite8(u32 vaddr, u8 value) override { | 47 | void MemoryWrite8(u32 vaddr, u8 value) override { |
| 60 | if (CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Write)) { | 48 | if (CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Write)) { |
| 61 | memory.Write8(vaddr, value); | 49 | m_memory.Write8(vaddr, value); |
| 62 | } | 50 | } |
| 63 | } | 51 | } |
| 64 | void MemoryWrite16(u32 vaddr, u16 value) override { | 52 | void MemoryWrite16(u32 vaddr, u16 value) override { |
| 65 | if (CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Write)) { | 53 | if (CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Write)) { |
| 66 | memory.Write16(vaddr, value); | 54 | m_memory.Write16(vaddr, value); |
| 67 | } | 55 | } |
| 68 | } | 56 | } |
| 69 | void MemoryWrite32(u32 vaddr, u32 value) override { | 57 | void MemoryWrite32(u32 vaddr, u32 value) override { |
| 70 | if (CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Write)) { | 58 | if (CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Write)) { |
| 71 | memory.Write32(vaddr, value); | 59 | m_memory.Write32(vaddr, value); |
| 72 | } | 60 | } |
| 73 | } | 61 | } |
| 74 | void MemoryWrite64(u32 vaddr, u64 value) override { | 62 | void MemoryWrite64(u32 vaddr, u64 value) override { |
| 75 | if (CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Write)) { | 63 | if (CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Write)) { |
| 76 | memory.Write64(vaddr, value); | 64 | m_memory.Write64(vaddr, value); |
| 77 | } | 65 | } |
| 78 | } | 66 | } |
| 79 | 67 | ||
| 80 | bool MemoryWriteExclusive8(u32 vaddr, u8 value, u8 expected) override { | 68 | bool MemoryWriteExclusive8(u32 vaddr, u8 value, u8 expected) override { |
| 81 | return CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Write) && | 69 | return CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Write) && |
| 82 | memory.WriteExclusive8(vaddr, value, expected); | 70 | m_memory.WriteExclusive8(vaddr, value, expected); |
| 83 | } | 71 | } |
| 84 | bool MemoryWriteExclusive16(u32 vaddr, u16 value, u16 expected) override { | 72 | bool MemoryWriteExclusive16(u32 vaddr, u16 value, u16 expected) override { |
| 85 | return CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Write) && | 73 | return CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Write) && |
| 86 | memory.WriteExclusive16(vaddr, value, expected); | 74 | m_memory.WriteExclusive16(vaddr, value, expected); |
| 87 | } | 75 | } |
| 88 | bool MemoryWriteExclusive32(u32 vaddr, u32 value, u32 expected) override { | 76 | bool MemoryWriteExclusive32(u32 vaddr, u32 value, u32 expected) override { |
| 89 | return CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Write) && | 77 | return CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Write) && |
| 90 | memory.WriteExclusive32(vaddr, value, expected); | 78 | m_memory.WriteExclusive32(vaddr, value, expected); |
| 91 | } | 79 | } |
| 92 | bool MemoryWriteExclusive64(u32 vaddr, u64 value, u64 expected) override { | 80 | bool MemoryWriteExclusive64(u32 vaddr, u64 value, u64 expected) override { |
| 93 | return CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Write) && | 81 | return CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Write) && |
| 94 | memory.WriteExclusive64(vaddr, value, expected); | 82 | m_memory.WriteExclusive64(vaddr, value, expected); |
| 95 | } | 83 | } |
| 96 | 84 | ||
| 97 | void InterpreterFallback(u32 pc, std::size_t num_instructions) override { | 85 | void InterpreterFallback(u32 pc, std::size_t num_instructions) override { |
| 98 | parent.LogBacktrace(); | 86 | m_parent.LogBacktrace(m_process); |
| 99 | LOG_ERROR(Core_ARM, | 87 | LOG_ERROR(Core_ARM, |
| 100 | "Unimplemented instruction @ 0x{:X} for {} instructions (instr = {:08X})", pc, | 88 | "Unimplemented instruction @ 0x{:X} for {} instructions (instr = {:08X})", pc, |
| 101 | num_instructions, memory.Read32(pc)); | 89 | num_instructions, m_memory.Read32(pc)); |
| 102 | } | 90 | } |
| 103 | 91 | ||
| 104 | void ExceptionRaised(u32 pc, Dynarmic::A32::Exception exception) override { | 92 | void ExceptionRaised(u32 pc, Dynarmic::A32::Exception exception) override { |
| @@ -108,73 +96,64 @@ public: | |||
| 108 | ReturnException(pc, PrefetchAbort); | 96 | ReturnException(pc, PrefetchAbort); |
| 109 | return; | 97 | return; |
| 110 | default: | 98 | default: |
| 111 | if (debugger_enabled) { | 99 | if (m_debugger_enabled) { |
| 112 | ReturnException(pc, InstructionBreakpoint); | 100 | ReturnException(pc, InstructionBreakpoint); |
| 113 | return; | 101 | return; |
| 114 | } | 102 | } |
| 115 | 103 | ||
| 116 | parent.LogBacktrace(); | 104 | m_parent.LogBacktrace(m_process); |
| 117 | LOG_CRITICAL(Core_ARM, | 105 | LOG_CRITICAL(Core_ARM, |
| 118 | "ExceptionRaised(exception = {}, pc = {:08X}, code = {:08X}, thumb = {})", | 106 | "ExceptionRaised(exception = {}, pc = {:08X}, code = {:08X}, thumb = {})", |
| 119 | exception, pc, memory.Read32(pc), parent.IsInThumbMode()); | 107 | exception, pc, m_memory.Read32(pc), m_parent.IsInThumbMode()); |
| 120 | } | 108 | } |
| 121 | } | 109 | } |
| 122 | 110 | ||
| 123 | void CallSVC(u32 swi) override { | 111 | void CallSVC(u32 swi) override { |
| 124 | parent.svc_swi = swi; | 112 | m_parent.m_svc_swi = swi; |
| 125 | parent.jit.load()->HaltExecution(SupervisorCall); | 113 | m_parent.m_jit->HaltExecution(SupervisorCall); |
| 126 | } | 114 | } |
| 127 | 115 | ||
| 128 | void AddTicks(u64 ticks) override { | 116 | void AddTicks(u64 ticks) override { |
| 129 | if (parent.uses_wall_clock) { | 117 | ASSERT_MSG(!m_parent.m_uses_wall_clock, "Dynarmic ticking disabled"); |
| 130 | return; | ||
| 131 | } | ||
| 132 | 118 | ||
| 133 | // Divide the number of ticks by the amount of CPU cores. TODO(Subv): This yields only a | 119 | // Divide the number of ticks by the amount of CPU cores. TODO(Subv): This yields only a |
| 134 | // rough approximation of the amount of executed ticks in the system, it may be thrown off | 120 | // rough approximation of the amount of executed ticks in the system, it may be thrown off |
| 135 | // if not all cores are doing a similar amount of work. Instead of doing this, we should | 121 | // if not all cores are doing a similar amount of work. Instead of doing this, we should |
| 136 | // device a way so that timing is consistent across all cores without increasing the ticks 4 | 122 | // device a way so that timing is consistent across all cores without increasing the ticks 4 |
| 137 | // times. | 123 | // times. |
| 138 | u64 amortized_ticks = | 124 | u64 amortized_ticks = ticks / Core::Hardware::NUM_CPU_CORES; |
| 139 | (ticks - num_interpreted_instructions) / Core::Hardware::NUM_CPU_CORES; | ||
| 140 | // Always execute at least one tick. | 125 | // Always execute at least one tick. |
| 141 | amortized_ticks = std::max<u64>(amortized_ticks, 1); | 126 | amortized_ticks = std::max<u64>(amortized_ticks, 1); |
| 142 | 127 | ||
| 143 | parent.system.CoreTiming().AddTicks(amortized_ticks); | 128 | m_parent.m_system.CoreTiming().AddTicks(amortized_ticks); |
| 144 | num_interpreted_instructions = 0; | ||
| 145 | } | 129 | } |
| 146 | 130 | ||
| 147 | u64 GetTicksRemaining() override { | 131 | u64 GetTicksRemaining() override { |
| 148 | if (parent.uses_wall_clock) { | 132 | ASSERT_MSG(!m_parent.m_uses_wall_clock, "Dynarmic ticking disabled"); |
| 149 | if (!IsInterrupted()) { | ||
| 150 | return minimum_run_cycles; | ||
| 151 | } | ||
| 152 | return 0U; | ||
| 153 | } | ||
| 154 | 133 | ||
| 155 | return std::max<s64>(parent.system.CoreTiming().GetDowncount(), 0); | 134 | return std::max<s64>(m_parent.m_system.CoreTiming().GetDowncount(), 0); |
| 156 | } | 135 | } |
| 157 | 136 | ||
| 158 | bool CheckMemoryAccess(u64 addr, u64 size, Kernel::DebugWatchpointType type) { | 137 | bool CheckMemoryAccess(u64 addr, u64 size, Kernel::DebugWatchpointType type) { |
| 159 | if (!check_memory_access) { | 138 | if (!m_check_memory_access) { |
| 160 | return true; | 139 | return true; |
| 161 | } | 140 | } |
| 162 | 141 | ||
| 163 | if (!memory.IsValidVirtualAddressRange(addr, size)) { | 142 | if (!m_memory.IsValidVirtualAddressRange(addr, size)) { |
| 164 | LOG_CRITICAL(Core_ARM, "Stopping execution due to unmapped memory access at {:#x}", | 143 | LOG_CRITICAL(Core_ARM, "Stopping execution due to unmapped memory access at {:#x}", |
| 165 | addr); | 144 | addr); |
| 166 | parent.jit.load()->HaltExecution(PrefetchAbort); | 145 | m_parent.m_jit->HaltExecution(PrefetchAbort); |
| 167 | return false; | 146 | return false; |
| 168 | } | 147 | } |
| 169 | 148 | ||
| 170 | if (!debugger_enabled) { | 149 | if (!m_debugger_enabled) { |
| 171 | return true; | 150 | return true; |
| 172 | } | 151 | } |
| 173 | 152 | ||
| 174 | const auto match{parent.MatchingWatchpoint(addr, size, type)}; | 153 | const auto match{m_parent.MatchingWatchpoint(addr, size, type)}; |
| 175 | if (match) { | 154 | if (match) { |
| 176 | parent.halted_watchpoint = match; | 155 | m_parent.m_halted_watchpoint = match; |
| 177 | parent.jit.load()->HaltExecution(DataAbort); | 156 | m_parent.m_jit->HaltExecution(DataAbort); |
| 178 | return false; | 157 | return false; |
| 179 | } | 158 | } |
| 180 | 159 | ||
| @@ -182,32 +161,31 @@ public: | |||
| 182 | } | 161 | } |
| 183 | 162 | ||
| 184 | void ReturnException(u32 pc, Dynarmic::HaltReason hr) { | 163 | void ReturnException(u32 pc, Dynarmic::HaltReason hr) { |
| 185 | parent.SaveContext(parent.breakpoint_context); | 164 | m_parent.GetContext(m_parent.m_breakpoint_context); |
| 186 | parent.breakpoint_context.cpu_registers[15] = pc; | 165 | m_parent.m_breakpoint_context.pc = pc; |
| 187 | parent.jit.load()->HaltExecution(hr); | 166 | m_parent.m_breakpoint_context.r[15] = pc; |
| 188 | } | 167 | m_parent.m_jit->HaltExecution(hr); |
| 189 | |||
| 190 | bool IsInterrupted() { | ||
| 191 | return parent.system.Kernel().PhysicalCore(parent.core_index).IsInterrupted(); | ||
| 192 | } | 168 | } |
| 193 | 169 | ||
| 194 | ARM_Dynarmic_32& parent; | 170 | ArmDynarmic32& m_parent; |
| 195 | Core::Memory::Memory& memory; | 171 | Core::Memory::Memory& m_memory; |
| 196 | std::size_t num_interpreted_instructions{}; | 172 | const Kernel::KProcess* m_process{}; |
| 197 | const bool debugger_enabled{}; | 173 | const bool m_debugger_enabled{}; |
| 198 | const bool check_memory_access{}; | 174 | const bool m_check_memory_access{}; |
| 199 | static constexpr u64 minimum_run_cycles = 10000U; | 175 | static constexpr u64 MinimumRunCycles = 10000U; |
| 200 | }; | 176 | }; |
| 201 | 177 | ||
| 202 | std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable* page_table) const { | 178 | std::shared_ptr<Dynarmic::A32::Jit> ArmDynarmic32::MakeJit(Common::PageTable* page_table) const { |
| 203 | Dynarmic::A32::UserConfig config; | 179 | Dynarmic::A32::UserConfig config; |
| 204 | config.callbacks = cb.get(); | 180 | config.callbacks = m_cb.get(); |
| 205 | config.coprocessors[15] = cp15; | 181 | config.coprocessors[15] = m_cp15; |
| 206 | config.define_unpredictable_behaviour = true; | 182 | config.define_unpredictable_behaviour = true; |
| 207 | static constexpr std::size_t YUZU_PAGEBITS = 12; | 183 | |
| 208 | static constexpr std::size_t NUM_PAGE_TABLE_ENTRIES = 1 << (32 - YUZU_PAGEBITS); | ||
| 209 | if (page_table) { | 184 | if (page_table) { |
| 210 | config.page_table = reinterpret_cast<std::array<std::uint8_t*, NUM_PAGE_TABLE_ENTRIES>*>( | 185 | constexpr size_t PageBits = 12; |
| 186 | constexpr size_t NumPageTableEntries = 1 << (32 - PageBits); | ||
| 187 | |||
| 188 | config.page_table = reinterpret_cast<std::array<std::uint8_t*, NumPageTableEntries>*>( | ||
| 211 | page_table->pointers.data()); | 189 | page_table->pointers.data()); |
| 212 | config.absolute_offset_page_table = true; | 190 | config.absolute_offset_page_table = true; |
| 213 | config.page_table_pointer_mask_bits = Common::PageTable::ATTRIBUTE_BITS; | 191 | config.page_table_pointer_mask_bits = Common::PageTable::ATTRIBUTE_BITS; |
| @@ -221,12 +199,12 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable* | |||
| 221 | } | 199 | } |
| 222 | 200 | ||
| 223 | // Multi-process state | 201 | // Multi-process state |
| 224 | config.processor_id = core_index; | 202 | config.processor_id = m_core_index; |
| 225 | config.global_monitor = &exclusive_monitor.monitor; | 203 | config.global_monitor = &m_exclusive_monitor.monitor; |
| 226 | 204 | ||
| 227 | // Timing | 205 | // Timing |
| 228 | config.wall_clock_cntpct = uses_wall_clock; | 206 | config.wall_clock_cntpct = m_uses_wall_clock; |
| 229 | config.enable_cycle_counting = true; | 207 | config.enable_cycle_counting = !m_uses_wall_clock; |
| 230 | 208 | ||
| 231 | // Code cache size | 209 | // Code cache size |
| 232 | #ifdef ARCHITECTURE_arm64 | 210 | #ifdef ARCHITECTURE_arm64 |
| @@ -236,7 +214,7 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable* | |||
| 236 | #endif | 214 | #endif |
| 237 | 215 | ||
| 238 | // Allow memory fault handling to work | 216 | // Allow memory fault handling to work |
| 239 | if (system.DebuggerEnabled()) { | 217 | if (m_system.DebuggerEnabled()) { |
| 240 | config.check_halt_on_memory_access = true; | 218 | config.check_halt_on_memory_access = true; |
| 241 | } | 219 | } |
| 242 | 220 | ||
| @@ -325,137 +303,140 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable* | |||
| 325 | return std::make_unique<Dynarmic::A32::Jit>(config); | 303 | return std::make_unique<Dynarmic::A32::Jit>(config); |
| 326 | } | 304 | } |
| 327 | 305 | ||
| 328 | HaltReason ARM_Dynarmic_32::RunJit() { | 306 | static std::pair<u32, u32> FpscrToFpsrFpcr(u32 fpscr) { |
| 329 | return TranslateHaltReason(jit.load()->Run()); | 307 | // FPSCR bits [31:27] are mapped to FPSR[31:27]. |
| 308 | // FPSCR bit [7] is mapped to FPSR[7]. | ||
| 309 | // FPSCR bits [4:0] are mapped to FPSR[4:0]. | ||
| 310 | const u32 nzcv = fpscr & 0xf8000000; | ||
| 311 | const u32 idc = fpscr & 0x80; | ||
| 312 | const u32 fiq = fpscr & 0x1f; | ||
| 313 | const u32 fpsr = nzcv | idc | fiq; | ||
| 314 | |||
| 315 | // FPSCR bits [26:15] are mapped to FPCR[26:15]. | ||
| 316 | // FPSCR bits [12:8] are mapped to FPCR[12:8]. | ||
| 317 | const u32 round = fpscr & 0x7ff8000; | ||
| 318 | const u32 trap = fpscr & 0x1f00; | ||
| 319 | const u32 fpcr = round | trap; | ||
| 320 | |||
| 321 | return {fpsr, fpcr}; | ||
| 330 | } | 322 | } |
| 331 | 323 | ||
| 332 | HaltReason ARM_Dynarmic_32::StepJit() { | 324 | static u32 FpsrFpcrToFpscr(u64 fpsr, u64 fpcr) { |
| 333 | return TranslateHaltReason(jit.load()->Step()); | 325 | auto [s, c] = FpscrToFpsrFpcr(static_cast<u32>(fpsr | fpcr)); |
| 326 | return s | c; | ||
| 334 | } | 327 | } |
| 335 | 328 | ||
| 336 | u32 ARM_Dynarmic_32::GetSvcNumber() const { | 329 | bool ArmDynarmic32::IsInThumbMode() const { |
| 337 | return svc_swi; | 330 | return (m_jit->Cpsr() & 0x20) != 0; |
| 338 | } | 331 | } |
| 339 | 332 | ||
| 340 | const Kernel::DebugWatchpoint* ARM_Dynarmic_32::HaltedWatchpoint() const { | 333 | HaltReason ArmDynarmic32::RunThread(Kernel::KThread* thread) { |
| 341 | return halted_watchpoint; | 334 | m_jit->ClearExclusiveState(); |
| 335 | return TranslateHaltReason(m_jit->Run()); | ||
| 342 | } | 336 | } |
| 343 | 337 | ||
| 344 | void ARM_Dynarmic_32::RewindBreakpointInstruction() { | 338 | HaltReason ArmDynarmic32::StepThread(Kernel::KThread* thread) { |
| 345 | LoadContext(breakpoint_context); | 339 | m_jit->ClearExclusiveState(); |
| 340 | return TranslateHaltReason(m_jit->Step()); | ||
| 346 | } | 341 | } |
| 347 | 342 | ||
| 348 | ARM_Dynarmic_32::ARM_Dynarmic_32(System& system_, bool uses_wall_clock_, | 343 | u32 ArmDynarmic32::GetSvcNumber() const { |
| 349 | DynarmicExclusiveMonitor& exclusive_monitor_, | 344 | return m_svc_swi; |
| 350 | std::size_t core_index_) | 345 | } |
| 351 | : ARM_Interface{system_, uses_wall_clock_}, cb(std::make_unique<DynarmicCallbacks32>(*this)), | ||
| 352 | cp15(std::make_shared<DynarmicCP15>(*this)), core_index{core_index_}, | ||
| 353 | exclusive_monitor{exclusive_monitor_}, null_jit{MakeJit(nullptr)}, jit{null_jit.get()} {} | ||
| 354 | 346 | ||
| 355 | ARM_Dynarmic_32::~ARM_Dynarmic_32() = default; | 347 | void ArmDynarmic32::GetSvcArguments(std::span<uint64_t, 8> args) const { |
| 348 | Dynarmic::A32::Jit& j = *m_jit; | ||
| 349 | auto& gpr = j.Regs(); | ||
| 356 | 350 | ||
| 357 | void ARM_Dynarmic_32::SetPC(u64 pc) { | 351 | for (size_t i = 0; i < 8; i++) { |
| 358 | jit.load()->Regs()[15] = static_cast<u32>(pc); | 352 | args[i] = gpr[i]; |
| 353 | } | ||
| 359 | } | 354 | } |
| 360 | 355 | ||
| 361 | u64 ARM_Dynarmic_32::GetPC() const { | 356 | void ArmDynarmic32::SetSvcArguments(std::span<const uint64_t, 8> args) { |
| 362 | return jit.load()->Regs()[15]; | 357 | Dynarmic::A32::Jit& j = *m_jit; |
| 363 | } | 358 | auto& gpr = j.Regs(); |
| 364 | 359 | ||
| 365 | u64 ARM_Dynarmic_32::GetSP() const { | 360 | for (size_t i = 0; i < 8; i++) { |
| 366 | return jit.load()->Regs()[13]; | 361 | gpr[i] = static_cast<u32>(args[i]); |
| 362 | } | ||
| 367 | } | 363 | } |
| 368 | 364 | ||
| 369 | u64 ARM_Dynarmic_32::GetReg(int index) const { | 365 | const Kernel::DebugWatchpoint* ArmDynarmic32::HaltedWatchpoint() const { |
| 370 | return jit.load()->Regs()[index]; | 366 | return m_halted_watchpoint; |
| 371 | } | 367 | } |
| 372 | 368 | ||
| 373 | void ARM_Dynarmic_32::SetReg(int index, u64 value) { | 369 | void ArmDynarmic32::RewindBreakpointInstruction() { |
| 374 | jit.load()->Regs()[index] = static_cast<u32>(value); | 370 | this->SetContext(m_breakpoint_context); |
| 375 | } | 371 | } |
| 376 | 372 | ||
| 377 | u128 ARM_Dynarmic_32::GetVectorReg(int index) const { | 373 | ArmDynarmic32::ArmDynarmic32(System& system, bool uses_wall_clock, const Kernel::KProcess* process, |
| 378 | return {}; | 374 | DynarmicExclusiveMonitor& exclusive_monitor, std::size_t core_index) |
| 375 | : ArmInterface{uses_wall_clock}, m_system{system}, m_exclusive_monitor{exclusive_monitor}, | ||
| 376 | m_cb(std::make_unique<DynarmicCallbacks32>(*this, process)), | ||
| 377 | m_cp15(std::make_shared<DynarmicCP15>(*this)), m_core_index{core_index} { | ||
| 378 | auto& page_table_impl = process->GetPageTable().GetBasePageTable().GetImpl(); | ||
| 379 | m_jit = MakeJit(&page_table_impl); | ||
| 379 | } | 380 | } |
| 380 | 381 | ||
| 381 | void ARM_Dynarmic_32::SetVectorReg(int index, u128 value) {} | 382 | ArmDynarmic32::~ArmDynarmic32() = default; |
| 382 | 383 | ||
| 383 | u32 ARM_Dynarmic_32::GetPSTATE() const { | 384 | void ArmDynarmic32::SetTpidrroEl0(u64 value) { |
| 384 | return jit.load()->Cpsr(); | 385 | m_cp15->uro = static_cast<u32>(value); |
| 385 | } | 386 | } |
| 386 | 387 | ||
| 387 | void ARM_Dynarmic_32::SetPSTATE(u32 cpsr) { | 388 | void ArmDynarmic32::GetContext(Kernel::Svc::ThreadContext& ctx) const { |
| 388 | jit.load()->SetCpsr(cpsr); | 389 | Dynarmic::A32::Jit& j = *m_jit; |
| 389 | } | 390 | auto& gpr = j.Regs(); |
| 391 | auto& fpr = j.ExtRegs(); | ||
| 390 | 392 | ||
| 391 | u64 ARM_Dynarmic_32::GetTlsAddress() const { | 393 | for (size_t i = 0; i < 16; i++) { |
| 392 | return cp15->uro; | 394 | ctx.r[i] = gpr[i]; |
| 393 | } | 395 | } |
| 394 | 396 | ||
| 395 | void ARM_Dynarmic_32::SetTlsAddress(u64 address) { | 397 | ctx.fp = gpr[11]; |
| 396 | cp15->uro = static_cast<u32>(address); | 398 | ctx.sp = gpr[13]; |
| 397 | } | 399 | ctx.lr = gpr[14]; |
| 400 | ctx.pc = gpr[15]; | ||
| 401 | ctx.pstate = j.Cpsr(); | ||
| 398 | 402 | ||
| 399 | u64 ARM_Dynarmic_32::GetTPIDR_EL0() const { | 403 | static_assert(sizeof(fpr) <= sizeof(ctx.v)); |
| 400 | return cp15->uprw; | 404 | std::memcpy(ctx.v.data(), &fpr, sizeof(fpr)); |
| 401 | } | ||
| 402 | 405 | ||
| 403 | void ARM_Dynarmic_32::SetTPIDR_EL0(u64 value) { | 406 | auto [fpsr, fpcr] = FpscrToFpsrFpcr(j.Fpscr()); |
| 404 | cp15->uprw = static_cast<u32>(value); | 407 | ctx.fpcr = fpcr; |
| 408 | ctx.fpsr = fpsr; | ||
| 409 | ctx.tpidr = m_cp15->uprw; | ||
| 405 | } | 410 | } |
| 406 | 411 | ||
| 407 | void ARM_Dynarmic_32::SaveContext(ThreadContext32& ctx) const { | 412 | void ArmDynarmic32::SetContext(const Kernel::Svc::ThreadContext& ctx) { |
| 408 | Dynarmic::A32::Jit* j = jit.load(); | 413 | Dynarmic::A32::Jit& j = *m_jit; |
| 409 | ctx.cpu_registers = j->Regs(); | 414 | auto& gpr = j.Regs(); |
| 410 | ctx.extension_registers = j->ExtRegs(); | 415 | auto& fpr = j.ExtRegs(); |
| 411 | ctx.cpsr = j->Cpsr(); | ||
| 412 | ctx.fpscr = j->Fpscr(); | ||
| 413 | } | ||
| 414 | 416 | ||
| 415 | void ARM_Dynarmic_32::LoadContext(const ThreadContext32& ctx) { | 417 | for (size_t i = 0; i < 16; i++) { |
| 416 | Dynarmic::A32::Jit* j = jit.load(); | 418 | gpr[i] = static_cast<u32>(ctx.r[i]); |
| 417 | j->Regs() = ctx.cpu_registers; | 419 | } |
| 418 | j->ExtRegs() = ctx.extension_registers; | ||
| 419 | j->SetCpsr(ctx.cpsr); | ||
| 420 | j->SetFpscr(ctx.fpscr); | ||
| 421 | } | ||
| 422 | 420 | ||
| 423 | void ARM_Dynarmic_32::SignalInterrupt() { | 421 | j.SetCpsr(ctx.pstate); |
| 424 | jit.load()->HaltExecution(BreakLoop); | ||
| 425 | } | ||
| 426 | 422 | ||
| 427 | void ARM_Dynarmic_32::ClearInterrupt() { | 423 | static_assert(sizeof(fpr) <= sizeof(ctx.v)); |
| 428 | jit.load()->ClearHalt(BreakLoop); | 424 | std::memcpy(&fpr, ctx.v.data(), sizeof(fpr)); |
| 429 | } | ||
| 430 | 425 | ||
| 431 | void ARM_Dynarmic_32::ClearInstructionCache() { | 426 | j.SetFpscr(FpsrFpcrToFpscr(ctx.fpsr, ctx.fpcr)); |
| 432 | jit.load()->ClearCache(); | 427 | m_cp15->uprw = static_cast<u32>(ctx.tpidr); |
| 433 | } | 428 | } |
| 434 | 429 | ||
| 435 | void ARM_Dynarmic_32::InvalidateCacheRange(u64 addr, std::size_t size) { | 430 | void ArmDynarmic32::SignalInterrupt(Kernel::KThread* thread) { |
| 436 | jit.load()->InvalidateCacheRange(static_cast<u32>(addr), size); | 431 | m_jit->HaltExecution(BreakLoop); |
| 437 | } | 432 | } |
| 438 | 433 | ||
| 439 | void ARM_Dynarmic_32::ClearExclusiveState() { | 434 | void ArmDynarmic32::ClearInstructionCache() { |
| 440 | jit.load()->ClearExclusiveState(); | 435 | m_jit->ClearCache(); |
| 441 | } | 436 | } |
| 442 | 437 | ||
| 443 | void ARM_Dynarmic_32::PageTableChanged(Common::PageTable& page_table, | 438 | void ArmDynarmic32::InvalidateCacheRange(u64 addr, std::size_t size) { |
| 444 | std::size_t new_address_space_size_in_bits) { | 439 | m_jit->InvalidateCacheRange(static_cast<u32>(addr), size); |
| 445 | ThreadContext32 ctx{}; | ||
| 446 | SaveContext(ctx); | ||
| 447 | |||
| 448 | auto key = std::make_pair(&page_table, new_address_space_size_in_bits); | ||
| 449 | auto iter = jit_cache.find(key); | ||
| 450 | if (iter != jit_cache.end()) { | ||
| 451 | jit.store(iter->second.get()); | ||
| 452 | LoadContext(ctx); | ||
| 453 | return; | ||
| 454 | } | ||
| 455 | std::shared_ptr new_jit = MakeJit(&page_table); | ||
| 456 | jit.store(new_jit.get()); | ||
| 457 | LoadContext(ctx); | ||
| 458 | jit_cache.emplace(key, std::move(new_jit)); | ||
| 459 | } | 440 | } |
| 460 | 441 | ||
| 461 | } // namespace Core | 442 | } // namespace Core |
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.h b/src/core/arm/dynarmic/arm_dynarmic_32.h index 92fb3f836..185ac7cbf 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.h +++ b/src/core/arm/dynarmic/arm_dynarmic_32.h | |||
| @@ -3,14 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <atomic> | ||
| 7 | #include <memory> | ||
| 8 | #include <unordered_map> | ||
| 9 | |||
| 10 | #include <dynarmic/interface/A32/a32.h> | 6 | #include <dynarmic/interface/A32/a32.h> |
| 11 | #include <dynarmic/interface/A64/a64.h> | 7 | |
| 12 | #include "common/common_types.h" | ||
| 13 | #include "common/hash.h" | ||
| 14 | #include "core/arm/arm_interface.h" | 8 | #include "core/arm/arm_interface.h" |
| 15 | #include "core/arm/dynarmic/dynarmic_exclusive_monitor.h" | 9 | #include "core/arm/dynarmic/dynarmic_exclusive_monitor.h" |
| 16 | 10 | ||
| @@ -20,89 +14,63 @@ class Memory; | |||
| 20 | 14 | ||
| 21 | namespace Core { | 15 | namespace Core { |
| 22 | 16 | ||
| 23 | class CPUInterruptHandler; | ||
| 24 | class DynarmicCallbacks32; | 17 | class DynarmicCallbacks32; |
| 25 | class DynarmicCP15; | 18 | class DynarmicCP15; |
| 26 | class DynarmicExclusiveMonitor; | ||
| 27 | class System; | 19 | class System; |
| 28 | 20 | ||
| 29 | class ARM_Dynarmic_32 final : public ARM_Interface { | 21 | class ArmDynarmic32 final : public ArmInterface { |
| 30 | public: | 22 | public: |
| 31 | ARM_Dynarmic_32(System& system_, bool uses_wall_clock_, | 23 | ArmDynarmic32(System& system, bool uses_wall_clock, const Kernel::KProcess* process, |
| 32 | DynarmicExclusiveMonitor& exclusive_monitor_, std::size_t core_index_); | 24 | DynarmicExclusiveMonitor& exclusive_monitor, std::size_t core_index); |
| 33 | ~ARM_Dynarmic_32() override; | 25 | ~ArmDynarmic32() override; |
| 34 | |||
| 35 | void SetPC(u64 pc) override; | ||
| 36 | u64 GetPC() const override; | ||
| 37 | u64 GetSP() const override; | ||
| 38 | u64 GetReg(int index) const override; | ||
| 39 | void SetReg(int index, u64 value) override; | ||
| 40 | u128 GetVectorReg(int index) const override; | ||
| 41 | void SetVectorReg(int index, u128 value) override; | ||
| 42 | u32 GetPSTATE() const override; | ||
| 43 | void SetPSTATE(u32 pstate) override; | ||
| 44 | u64 GetTlsAddress() const override; | ||
| 45 | void SetTlsAddress(u64 address) override; | ||
| 46 | void SetTPIDR_EL0(u64 value) override; | ||
| 47 | u64 GetTPIDR_EL0() const override; | ||
| 48 | |||
| 49 | bool IsInThumbMode() const { | ||
| 50 | return (GetPSTATE() & 0x20) != 0; | ||
| 51 | } | ||
| 52 | 26 | ||
| 53 | Architecture GetArchitecture() const override { | 27 | Architecture GetArchitecture() const override { |
| 54 | return Architecture::Aarch32; | 28 | return Architecture::AArch32; |
| 55 | } | 29 | } |
| 56 | void SaveContext(ThreadContext32& ctx) const override; | ||
| 57 | void SaveContext(ThreadContext64& ctx) const override {} | ||
| 58 | void LoadContext(const ThreadContext32& ctx) override; | ||
| 59 | void LoadContext(const ThreadContext64& ctx) override {} | ||
| 60 | 30 | ||
| 61 | void SignalInterrupt() override; | 31 | bool IsInThumbMode() const; |
| 62 | void ClearInterrupt() override; | 32 | |
| 63 | void ClearExclusiveState() override; | 33 | HaltReason RunThread(Kernel::KThread* thread) override; |
| 34 | HaltReason StepThread(Kernel::KThread* thread) override; | ||
| 35 | |||
| 36 | void GetContext(Kernel::Svc::ThreadContext& ctx) const override; | ||
| 37 | void SetContext(const Kernel::Svc::ThreadContext& ctx) override; | ||
| 38 | void SetTpidrroEl0(u64 value) override; | ||
| 39 | |||
| 40 | void GetSvcArguments(std::span<uint64_t, 8> args) const override; | ||
| 41 | void SetSvcArguments(std::span<const uint64_t, 8> args) override; | ||
| 42 | u32 GetSvcNumber() const override; | ||
| 64 | 43 | ||
| 44 | void SignalInterrupt(Kernel::KThread* thread) override; | ||
| 65 | void ClearInstructionCache() override; | 45 | void ClearInstructionCache() override; |
| 66 | void InvalidateCacheRange(u64 addr, std::size_t size) override; | 46 | void InvalidateCacheRange(u64 addr, std::size_t size) override; |
| 67 | void PageTableChanged(Common::PageTable& new_page_table, | ||
| 68 | std::size_t new_address_space_size_in_bits) override; | ||
| 69 | 47 | ||
| 70 | protected: | 48 | protected: |
| 71 | HaltReason RunJit() override; | ||
| 72 | HaltReason StepJit() override; | ||
| 73 | u32 GetSvcNumber() const override; | ||
| 74 | const Kernel::DebugWatchpoint* HaltedWatchpoint() const override; | 49 | const Kernel::DebugWatchpoint* HaltedWatchpoint() const override; |
| 75 | void RewindBreakpointInstruction() override; | 50 | void RewindBreakpointInstruction() override; |
| 76 | 51 | ||
| 77 | private: | 52 | private: |
| 78 | std::shared_ptr<Dynarmic::A32::Jit> MakeJit(Common::PageTable* page_table) const; | 53 | System& m_system; |
| 79 | 54 | DynarmicExclusiveMonitor& m_exclusive_monitor; | |
| 80 | static std::vector<BacktraceEntry> GetBacktrace(Core::System& system, u64 fp, u64 lr, u64 pc); | ||
| 81 | |||
| 82 | using JitCacheKey = std::pair<Common::PageTable*, std::size_t>; | ||
| 83 | using JitCacheType = | ||
| 84 | std::unordered_map<JitCacheKey, std::shared_ptr<Dynarmic::A32::Jit>, Common::PairHash>; | ||
| 85 | 55 | ||
| 56 | private: | ||
| 86 | friend class DynarmicCallbacks32; | 57 | friend class DynarmicCallbacks32; |
| 87 | friend class DynarmicCP15; | 58 | friend class DynarmicCP15; |
| 88 | 59 | ||
| 89 | std::unique_ptr<DynarmicCallbacks32> cb; | 60 | std::shared_ptr<Dynarmic::A32::Jit> MakeJit(Common::PageTable* page_table) const; |
| 90 | JitCacheType jit_cache; | ||
| 91 | std::shared_ptr<DynarmicCP15> cp15; | ||
| 92 | std::size_t core_index; | ||
| 93 | DynarmicExclusiveMonitor& exclusive_monitor; | ||
| 94 | 61 | ||
| 95 | std::shared_ptr<Dynarmic::A32::Jit> null_jit; | 62 | std::unique_ptr<DynarmicCallbacks32> m_cb{}; |
| 63 | std::shared_ptr<DynarmicCP15> m_cp15{}; | ||
| 64 | std::size_t m_core_index{}; | ||
| 96 | 65 | ||
| 97 | // A raw pointer here is fine; we never delete Jit instances. | 66 | std::shared_ptr<Dynarmic::A32::Jit> m_jit{}; |
| 98 | std::atomic<Dynarmic::A32::Jit*> jit; | ||
| 99 | 67 | ||
| 100 | // SVC callback | 68 | // SVC callback |
| 101 | u32 svc_swi{}; | 69 | u32 m_svc_swi{}; |
| 102 | 70 | ||
| 103 | // Watchpoint info | 71 | // Watchpoint info |
| 104 | const Kernel::DebugWatchpoint* halted_watchpoint; | 72 | const Kernel::DebugWatchpoint* m_halted_watchpoint{}; |
| 105 | ThreadContext32 breakpoint_context; | 73 | Kernel::Svc::ThreadContext m_breakpoint_context{}; |
| 106 | }; | 74 | }; |
| 107 | 75 | ||
| 108 | } // namespace Core | 76 | } // namespace Core |
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 2e3674b6d..dff14756e 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp | |||
| @@ -1,25 +1,12 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 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 <cinttypes> | ||
| 5 | #include <memory> | ||
| 6 | #include <dynarmic/interface/A64/a64.h> | ||
| 7 | #include <dynarmic/interface/A64/config.h> | ||
| 8 | #include "common/assert.h" | ||
| 9 | #include "common/literals.h" | ||
| 10 | #include "common/logging/log.h" | ||
| 11 | #include "common/page_table.h" | ||
| 12 | #include "common/settings.h" | 4 | #include "common/settings.h" |
| 13 | #include "core/arm/dynarmic/arm_dynarmic.h" | 5 | #include "core/arm/dynarmic/arm_dynarmic.h" |
| 14 | #include "core/arm/dynarmic/arm_dynarmic_64.h" | 6 | #include "core/arm/dynarmic/arm_dynarmic_64.h" |
| 15 | #include "core/arm/dynarmic/dynarmic_exclusive_monitor.h" | 7 | #include "core/arm/dynarmic/dynarmic_exclusive_monitor.h" |
| 16 | #include "core/core.h" | ||
| 17 | #include "core/core_timing.h" | 8 | #include "core/core_timing.h" |
| 18 | #include "core/debugger/debugger.h" | ||
| 19 | #include "core/hardware_properties.h" | ||
| 20 | #include "core/hle/kernel/k_process.h" | 9 | #include "core/hle/kernel/k_process.h" |
| 21 | #include "core/hle/kernel/svc.h" | ||
| 22 | #include "core/memory.h" | ||
| 23 | 10 | ||
| 24 | namespace Core { | 11 | namespace Core { |
| 25 | 12 | ||
| @@ -28,92 +15,92 @@ using namespace Common::Literals; | |||
| 28 | 15 | ||
| 29 | class DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks { | 16 | class DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks { |
| 30 | public: | 17 | public: |
| 31 | explicit DynarmicCallbacks64(ARM_Dynarmic_64& parent_) | 18 | explicit DynarmicCallbacks64(ArmDynarmic64& parent, const Kernel::KProcess* process) |
| 32 | : parent{parent_}, memory(parent.system.ApplicationMemory()), | 19 | : m_parent{parent}, m_memory(process->GetMemory()), |
| 33 | debugger_enabled{parent.system.DebuggerEnabled()}, | 20 | m_process(process), m_debugger_enabled{parent.m_system.DebuggerEnabled()}, |
| 34 | check_memory_access{debugger_enabled || | 21 | m_check_memory_access{m_debugger_enabled || |
| 35 | !Settings::values.cpuopt_ignore_memory_aborts.GetValue()} {} | 22 | !Settings::values.cpuopt_ignore_memory_aborts.GetValue()} {} |
| 36 | 23 | ||
| 37 | u8 MemoryRead8(u64 vaddr) override { | 24 | u8 MemoryRead8(u64 vaddr) override { |
| 38 | CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Read); | 25 | CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Read); |
| 39 | return memory.Read8(vaddr); | 26 | return m_memory.Read8(vaddr); |
| 40 | } | 27 | } |
| 41 | u16 MemoryRead16(u64 vaddr) override { | 28 | u16 MemoryRead16(u64 vaddr) override { |
| 42 | CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Read); | 29 | CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Read); |
| 43 | return memory.Read16(vaddr); | 30 | return m_memory.Read16(vaddr); |
| 44 | } | 31 | } |
| 45 | u32 MemoryRead32(u64 vaddr) override { | 32 | u32 MemoryRead32(u64 vaddr) override { |
| 46 | CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Read); | 33 | CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Read); |
| 47 | return memory.Read32(vaddr); | 34 | return m_memory.Read32(vaddr); |
| 48 | } | 35 | } |
| 49 | u64 MemoryRead64(u64 vaddr) override { | 36 | u64 MemoryRead64(u64 vaddr) override { |
| 50 | CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Read); | 37 | CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Read); |
| 51 | return memory.Read64(vaddr); | 38 | return m_memory.Read64(vaddr); |
| 52 | } | 39 | } |
| 53 | Vector MemoryRead128(u64 vaddr) override { | 40 | Vector MemoryRead128(u64 vaddr) override { |
| 54 | CheckMemoryAccess(vaddr, 16, Kernel::DebugWatchpointType::Read); | 41 | CheckMemoryAccess(vaddr, 16, Kernel::DebugWatchpointType::Read); |
| 55 | return {memory.Read64(vaddr), memory.Read64(vaddr + 8)}; | 42 | return {m_memory.Read64(vaddr), m_memory.Read64(vaddr + 8)}; |
| 56 | } | 43 | } |
| 57 | std::optional<u32> MemoryReadCode(u64 vaddr) override { | 44 | std::optional<u32> MemoryReadCode(u64 vaddr) override { |
| 58 | if (!memory.IsValidVirtualAddressRange(vaddr, sizeof(u32))) { | 45 | if (!m_memory.IsValidVirtualAddressRange(vaddr, sizeof(u32))) { |
| 59 | return std::nullopt; | 46 | return std::nullopt; |
| 60 | } | 47 | } |
| 61 | return memory.Read32(vaddr); | 48 | return m_memory.Read32(vaddr); |
| 62 | } | 49 | } |
| 63 | 50 | ||
| 64 | void MemoryWrite8(u64 vaddr, u8 value) override { | 51 | void MemoryWrite8(u64 vaddr, u8 value) override { |
| 65 | if (CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Write)) { | 52 | if (CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Write)) { |
| 66 | memory.Write8(vaddr, value); | 53 | m_memory.Write8(vaddr, value); |
| 67 | } | 54 | } |
| 68 | } | 55 | } |
| 69 | void MemoryWrite16(u64 vaddr, u16 value) override { | 56 | void MemoryWrite16(u64 vaddr, u16 value) override { |
| 70 | if (CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Write)) { | 57 | if (CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Write)) { |
| 71 | memory.Write16(vaddr, value); | 58 | m_memory.Write16(vaddr, value); |
| 72 | } | 59 | } |
| 73 | } | 60 | } |
| 74 | void MemoryWrite32(u64 vaddr, u32 value) override { | 61 | void MemoryWrite32(u64 vaddr, u32 value) override { |
| 75 | if (CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Write)) { | 62 | if (CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Write)) { |
| 76 | memory.Write32(vaddr, value); | 63 | m_memory.Write32(vaddr, value); |
| 77 | } | 64 | } |
| 78 | } | 65 | } |
| 79 | void MemoryWrite64(u64 vaddr, u64 value) override { | 66 | void MemoryWrite64(u64 vaddr, u64 value) override { |
| 80 | if (CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Write)) { | 67 | if (CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Write)) { |
| 81 | memory.Write64(vaddr, value); | 68 | m_memory.Write64(vaddr, value); |
| 82 | } | 69 | } |
| 83 | } | 70 | } |
| 84 | void MemoryWrite128(u64 vaddr, Vector value) override { | 71 | void MemoryWrite128(u64 vaddr, Vector value) override { |
| 85 | if (CheckMemoryAccess(vaddr, 16, Kernel::DebugWatchpointType::Write)) { | 72 | if (CheckMemoryAccess(vaddr, 16, Kernel::DebugWatchpointType::Write)) { |
| 86 | memory.Write64(vaddr, value[0]); | 73 | m_memory.Write64(vaddr, value[0]); |
| 87 | memory.Write64(vaddr + 8, value[1]); | 74 | m_memory.Write64(vaddr + 8, value[1]); |
| 88 | } | 75 | } |
| 89 | } | 76 | } |
| 90 | 77 | ||
| 91 | bool MemoryWriteExclusive8(u64 vaddr, std::uint8_t value, std::uint8_t expected) override { | 78 | bool MemoryWriteExclusive8(u64 vaddr, std::uint8_t value, std::uint8_t expected) override { |
| 92 | return CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Write) && | 79 | return CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Write) && |
| 93 | memory.WriteExclusive8(vaddr, value, expected); | 80 | m_memory.WriteExclusive8(vaddr, value, expected); |
| 94 | } | 81 | } |
| 95 | bool MemoryWriteExclusive16(u64 vaddr, std::uint16_t value, std::uint16_t expected) override { | 82 | bool MemoryWriteExclusive16(u64 vaddr, std::uint16_t value, std::uint16_t expected) override { |
| 96 | return CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Write) && | 83 | return CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Write) && |
| 97 | memory.WriteExclusive16(vaddr, value, expected); | 84 | m_memory.WriteExclusive16(vaddr, value, expected); |
| 98 | } | 85 | } |
| 99 | bool MemoryWriteExclusive32(u64 vaddr, std::uint32_t value, std::uint32_t expected) override { | 86 | bool MemoryWriteExclusive32(u64 vaddr, std::uint32_t value, std::uint32_t expected) override { |
| 100 | return CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Write) && | 87 | return CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Write) && |
| 101 | memory.WriteExclusive32(vaddr, value, expected); | 88 | m_memory.WriteExclusive32(vaddr, value, expected); |
| 102 | } | 89 | } |
| 103 | bool MemoryWriteExclusive64(u64 vaddr, std::uint64_t value, std::uint64_t expected) override { | 90 | bool MemoryWriteExclusive64(u64 vaddr, std::uint64_t value, std::uint64_t expected) override { |
| 104 | return CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Write) && | 91 | return CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Write) && |
| 105 | memory.WriteExclusive64(vaddr, value, expected); | 92 | m_memory.WriteExclusive64(vaddr, value, expected); |
| 106 | } | 93 | } |
| 107 | bool MemoryWriteExclusive128(u64 vaddr, Vector value, Vector expected) override { | 94 | bool MemoryWriteExclusive128(u64 vaddr, Vector value, Vector expected) override { |
| 108 | return CheckMemoryAccess(vaddr, 16, Kernel::DebugWatchpointType::Write) && | 95 | return CheckMemoryAccess(vaddr, 16, Kernel::DebugWatchpointType::Write) && |
| 109 | memory.WriteExclusive128(vaddr, value, expected); | 96 | m_memory.WriteExclusive128(vaddr, value, expected); |
| 110 | } | 97 | } |
| 111 | 98 | ||
| 112 | void InterpreterFallback(u64 pc, std::size_t num_instructions) override { | 99 | void InterpreterFallback(u64 pc, std::size_t num_instructions) override { |
| 113 | parent.LogBacktrace(); | 100 | m_parent.LogBacktrace(m_process); |
| 114 | LOG_ERROR(Core_ARM, | 101 | LOG_ERROR(Core_ARM, |
| 115 | "Unimplemented instruction @ 0x{:X} for {} instructions (instr = {:08X})", pc, | 102 | "Unimplemented instruction @ 0x{:X} for {} instructions (instr = {:08X})", pc, |
| 116 | num_instructions, memory.Read32(pc)); | 103 | num_instructions, m_memory.Read32(pc)); |
| 117 | ReturnException(pc, PrefetchAbort); | 104 | ReturnException(pc, PrefetchAbort); |
| 118 | } | 105 | } |
| 119 | 106 | ||
| @@ -124,11 +111,11 @@ public: | |||
| 124 | static constexpr u64 ICACHE_LINE_SIZE = 64; | 111 | static constexpr u64 ICACHE_LINE_SIZE = 64; |
| 125 | 112 | ||
| 126 | const u64 cache_line_start = value & ~(ICACHE_LINE_SIZE - 1); | 113 | const u64 cache_line_start = value & ~(ICACHE_LINE_SIZE - 1); |
| 127 | parent.system.InvalidateCpuInstructionCacheRange(cache_line_start, ICACHE_LINE_SIZE); | 114 | m_parent.InvalidateCacheRange(cache_line_start, ICACHE_LINE_SIZE); |
| 128 | break; | 115 | break; |
| 129 | } | 116 | } |
| 130 | case Dynarmic::A64::InstructionCacheOperation::InvalidateAllToPoU: | 117 | case Dynarmic::A64::InstructionCacheOperation::InvalidateAllToPoU: |
| 131 | parent.system.InvalidateCpuInstructionCaches(); | 118 | m_parent.ClearInstructionCache(); |
| 132 | break; | 119 | break; |
| 133 | case Dynarmic::A64::InstructionCacheOperation::InvalidateAllToPoUInnerSharable: | 120 | case Dynarmic::A64::InstructionCacheOperation::InvalidateAllToPoUInnerSharable: |
| 134 | default: | 121 | default: |
| @@ -136,7 +123,7 @@ public: | |||
| 136 | break; | 123 | break; |
| 137 | } | 124 | } |
| 138 | 125 | ||
| 139 | parent.jit.load()->HaltExecution(Dynarmic::HaltReason::CacheInvalidation); | 126 | m_parent.m_jit->HaltExecution(Dynarmic::HaltReason::CacheInvalidation); |
| 140 | } | 127 | } |
| 141 | 128 | ||
| 142 | void ExceptionRaised(u64 pc, Dynarmic::A64::Exception exception) override { | 129 | void ExceptionRaised(u64 pc, Dynarmic::A64::Exception exception) override { |
| @@ -152,26 +139,24 @@ public: | |||
| 152 | ReturnException(pc, PrefetchAbort); | 139 | ReturnException(pc, PrefetchAbort); |
| 153 | return; | 140 | return; |
| 154 | default: | 141 | default: |
| 155 | if (debugger_enabled) { | 142 | if (m_debugger_enabled) { |
| 156 | ReturnException(pc, InstructionBreakpoint); | 143 | ReturnException(pc, InstructionBreakpoint); |
| 157 | return; | 144 | return; |
| 158 | } | 145 | } |
| 159 | 146 | ||
| 160 | parent.LogBacktrace(); | 147 | m_parent.LogBacktrace(m_process); |
| 161 | LOG_CRITICAL(Core_ARM, "ExceptionRaised(exception = {}, pc = {:08X}, code = {:08X})", | 148 | LOG_CRITICAL(Core_ARM, "ExceptionRaised(exception = {}, pc = {:08X}, code = {:08X})", |
| 162 | static_cast<std::size_t>(exception), pc, memory.Read32(pc)); | 149 | static_cast<std::size_t>(exception), pc, m_memory.Read32(pc)); |
| 163 | } | 150 | } |
| 164 | } | 151 | } |
| 165 | 152 | ||
| 166 | void CallSVC(u32 swi) override { | 153 | void CallSVC(u32 svc) override { |
| 167 | parent.svc_swi = swi; | 154 | m_parent.m_svc = svc; |
| 168 | parent.jit.load()->HaltExecution(SupervisorCall); | 155 | m_parent.m_jit->HaltExecution(SupervisorCall); |
| 169 | } | 156 | } |
| 170 | 157 | ||
| 171 | void AddTicks(u64 ticks) override { | 158 | void AddTicks(u64 ticks) override { |
| 172 | if (parent.uses_wall_clock) { | 159 | ASSERT_MSG(!m_parent.m_uses_wall_clock, "Dynarmic ticking disabled"); |
| 173 | return; | ||
| 174 | } | ||
| 175 | 160 | ||
| 176 | // Divide the number of ticks by the amount of CPU cores. TODO(Subv): This yields only a | 161 | // Divide the number of ticks by the amount of CPU cores. TODO(Subv): This yields only a |
| 177 | // rough approximation of the amount of executed ticks in the system, it may be thrown off | 162 | // rough approximation of the amount of executed ticks in the system, it may be thrown off |
| @@ -182,44 +167,39 @@ public: | |||
| 182 | // Always execute at least one tick. | 167 | // Always execute at least one tick. |
| 183 | amortized_ticks = std::max<u64>(amortized_ticks, 1); | 168 | amortized_ticks = std::max<u64>(amortized_ticks, 1); |
| 184 | 169 | ||
| 185 | parent.system.CoreTiming().AddTicks(amortized_ticks); | 170 | m_parent.m_system.CoreTiming().AddTicks(amortized_ticks); |
| 186 | } | 171 | } |
| 187 | 172 | ||
| 188 | u64 GetTicksRemaining() override { | 173 | u64 GetTicksRemaining() override { |
| 189 | if (parent.uses_wall_clock) { | 174 | ASSERT_MSG(!m_parent.m_uses_wall_clock, "Dynarmic ticking disabled"); |
| 190 | if (!IsInterrupted()) { | ||
| 191 | return minimum_run_cycles; | ||
| 192 | } | ||
| 193 | return 0U; | ||
| 194 | } | ||
| 195 | 175 | ||
| 196 | return std::max<s64>(parent.system.CoreTiming().GetDowncount(), 0); | 176 | return std::max<s64>(m_parent.m_system.CoreTiming().GetDowncount(), 0); |
| 197 | } | 177 | } |
| 198 | 178 | ||
| 199 | u64 GetCNTPCT() override { | 179 | u64 GetCNTPCT() override { |
| 200 | return parent.system.CoreTiming().GetClockTicks(); | 180 | return m_parent.m_system.CoreTiming().GetClockTicks(); |
| 201 | } | 181 | } |
| 202 | 182 | ||
| 203 | bool CheckMemoryAccess(u64 addr, u64 size, Kernel::DebugWatchpointType type) { | 183 | bool CheckMemoryAccess(u64 addr, u64 size, Kernel::DebugWatchpointType type) { |
| 204 | if (!check_memory_access) { | 184 | if (!m_check_memory_access) { |
| 205 | return true; | 185 | return true; |
| 206 | } | 186 | } |
| 207 | 187 | ||
| 208 | if (!memory.IsValidVirtualAddressRange(addr, size)) { | 188 | if (!m_memory.IsValidVirtualAddressRange(addr, size)) { |
| 209 | LOG_CRITICAL(Core_ARM, "Stopping execution due to unmapped memory access at {:#x}", | 189 | LOG_CRITICAL(Core_ARM, "Stopping execution due to unmapped memory access at {:#x}", |
| 210 | addr); | 190 | addr); |
| 211 | parent.jit.load()->HaltExecution(PrefetchAbort); | 191 | m_parent.m_jit->HaltExecution(PrefetchAbort); |
| 212 | return false; | 192 | return false; |
| 213 | } | 193 | } |
| 214 | 194 | ||
| 215 | if (!debugger_enabled) { | 195 | if (!m_debugger_enabled) { |
| 216 | return true; | 196 | return true; |
| 217 | } | 197 | } |
| 218 | 198 | ||
| 219 | const auto match{parent.MatchingWatchpoint(addr, size, type)}; | 199 | const auto match{m_parent.MatchingWatchpoint(addr, size, type)}; |
| 220 | if (match) { | 200 | if (match) { |
| 221 | parent.halted_watchpoint = match; | 201 | m_parent.m_halted_watchpoint = match; |
| 222 | parent.jit.load()->HaltExecution(DataAbort); | 202 | m_parent.m_jit->HaltExecution(DataAbort); |
| 223 | return false; | 203 | return false; |
| 224 | } | 204 | } |
| 225 | 205 | ||
| @@ -227,30 +207,27 @@ public: | |||
| 227 | } | 207 | } |
| 228 | 208 | ||
| 229 | void ReturnException(u64 pc, Dynarmic::HaltReason hr) { | 209 | void ReturnException(u64 pc, Dynarmic::HaltReason hr) { |
| 230 | parent.SaveContext(parent.breakpoint_context); | 210 | m_parent.GetContext(m_parent.m_breakpoint_context); |
| 231 | parent.breakpoint_context.pc = pc; | 211 | m_parent.m_breakpoint_context.pc = pc; |
| 232 | parent.jit.load()->HaltExecution(hr); | 212 | m_parent.m_jit->HaltExecution(hr); |
| 233 | } | 213 | } |
| 234 | 214 | ||
| 235 | bool IsInterrupted() { | 215 | ArmDynarmic64& m_parent; |
| 236 | return parent.system.Kernel().PhysicalCore(parent.core_index).IsInterrupted(); | 216 | Core::Memory::Memory& m_memory; |
| 237 | } | 217 | u64 m_tpidrro_el0{}; |
| 238 | 218 | u64 m_tpidr_el0{}; | |
| 239 | ARM_Dynarmic_64& parent; | 219 | const Kernel::KProcess* m_process{}; |
| 240 | Core::Memory::Memory& memory; | 220 | const bool m_debugger_enabled{}; |
| 241 | u64 tpidrro_el0 = 0; | 221 | const bool m_check_memory_access{}; |
| 242 | u64 tpidr_el0 = 0; | 222 | static constexpr u64 MinimumRunCycles = 10000U; |
| 243 | const bool debugger_enabled{}; | ||
| 244 | const bool check_memory_access{}; | ||
| 245 | static constexpr u64 minimum_run_cycles = 10000U; | ||
| 246 | }; | 223 | }; |
| 247 | 224 | ||
| 248 | std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable* page_table, | 225 | std::shared_ptr<Dynarmic::A64::Jit> ArmDynarmic64::MakeJit(Common::PageTable* page_table, |
| 249 | std::size_t address_space_bits) const { | 226 | std::size_t address_space_bits) const { |
| 250 | Dynarmic::A64::UserConfig config; | 227 | Dynarmic::A64::UserConfig config; |
| 251 | 228 | ||
| 252 | // Callbacks | 229 | // Callbacks |
| 253 | config.callbacks = cb.get(); | 230 | config.callbacks = m_cb.get(); |
| 254 | 231 | ||
| 255 | // Memory | 232 | // Memory |
| 256 | if (page_table) { | 233 | if (page_table) { |
| @@ -271,12 +248,12 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable* | |||
| 271 | } | 248 | } |
| 272 | 249 | ||
| 273 | // Multi-process state | 250 | // Multi-process state |
| 274 | config.processor_id = core_index; | 251 | config.processor_id = m_core_index; |
| 275 | config.global_monitor = &exclusive_monitor.monitor; | 252 | config.global_monitor = &m_exclusive_monitor.monitor; |
| 276 | 253 | ||
| 277 | // System registers | 254 | // System registers |
| 278 | config.tpidrro_el0 = &cb->tpidrro_el0; | 255 | config.tpidrro_el0 = &m_cb->m_tpidrro_el0; |
| 279 | config.tpidr_el0 = &cb->tpidr_el0; | 256 | config.tpidr_el0 = &m_cb->m_tpidr_el0; |
| 280 | config.dczid_el0 = 4; | 257 | config.dczid_el0 = 4; |
| 281 | config.ctr_el0 = 0x8444c004; | 258 | config.ctr_el0 = 0x8444c004; |
| 282 | config.cntfrq_el0 = Hardware::CNTFREQ; | 259 | config.cntfrq_el0 = Hardware::CNTFREQ; |
| @@ -285,8 +262,8 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable* | |||
| 285 | config.define_unpredictable_behaviour = true; | 262 | config.define_unpredictable_behaviour = true; |
| 286 | 263 | ||
| 287 | // Timing | 264 | // Timing |
| 288 | config.wall_clock_cntpct = uses_wall_clock; | 265 | config.wall_clock_cntpct = m_uses_wall_clock; |
| 289 | config.enable_cycle_counting = true; | 266 | config.enable_cycle_counting = !m_uses_wall_clock; |
| 290 | 267 | ||
| 291 | // Code cache size | 268 | // Code cache size |
| 292 | #ifdef ARCHITECTURE_arm64 | 269 | #ifdef ARCHITECTURE_arm64 |
| @@ -296,7 +273,7 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable* | |||
| 296 | #endif | 273 | #endif |
| 297 | 274 | ||
| 298 | // Allow memory fault handling to work | 275 | // Allow memory fault handling to work |
| 299 | if (system.DebuggerEnabled()) { | 276 | if (m_system.DebuggerEnabled()) { |
| 300 | config.check_halt_on_memory_access = true; | 277 | config.check_halt_on_memory_access = true; |
| 301 | } | 278 | } |
| 302 | 279 | ||
| @@ -384,147 +361,112 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable* | |||
| 384 | return std::make_shared<Dynarmic::A64::Jit>(config); | 361 | return std::make_shared<Dynarmic::A64::Jit>(config); |
| 385 | } | 362 | } |
| 386 | 363 | ||
| 387 | HaltReason ARM_Dynarmic_64::RunJit() { | 364 | HaltReason ArmDynarmic64::RunThread(Kernel::KThread* thread) { |
| 388 | return TranslateHaltReason(jit.load()->Run()); | 365 | m_jit->ClearExclusiveState(); |
| 389 | } | 366 | return TranslateHaltReason(m_jit->Run()); |
| 390 | |||
| 391 | HaltReason ARM_Dynarmic_64::StepJit() { | ||
| 392 | return TranslateHaltReason(jit.load()->Step()); | ||
| 393 | } | ||
| 394 | |||
| 395 | u32 ARM_Dynarmic_64::GetSvcNumber() const { | ||
| 396 | return svc_swi; | ||
| 397 | } | ||
| 398 | |||
| 399 | const Kernel::DebugWatchpoint* ARM_Dynarmic_64::HaltedWatchpoint() const { | ||
| 400 | return halted_watchpoint; | ||
| 401 | } | ||
| 402 | |||
| 403 | void ARM_Dynarmic_64::RewindBreakpointInstruction() { | ||
| 404 | LoadContext(breakpoint_context); | ||
| 405 | } | ||
| 406 | |||
| 407 | ARM_Dynarmic_64::ARM_Dynarmic_64(System& system_, bool uses_wall_clock_, | ||
| 408 | DynarmicExclusiveMonitor& exclusive_monitor_, | ||
| 409 | std::size_t core_index_) | ||
| 410 | : ARM_Interface{system_, uses_wall_clock_}, | ||
| 411 | cb(std::make_unique<DynarmicCallbacks64>(*this)), core_index{core_index_}, | ||
| 412 | exclusive_monitor{exclusive_monitor_}, null_jit{MakeJit(nullptr, 48)}, jit{null_jit.get()} {} | ||
| 413 | |||
| 414 | ARM_Dynarmic_64::~ARM_Dynarmic_64() = default; | ||
| 415 | |||
| 416 | void ARM_Dynarmic_64::SetPC(u64 pc) { | ||
| 417 | jit.load()->SetPC(pc); | ||
| 418 | } | ||
| 419 | |||
| 420 | u64 ARM_Dynarmic_64::GetPC() const { | ||
| 421 | return jit.load()->GetPC(); | ||
| 422 | } | 367 | } |
| 423 | 368 | ||
| 424 | u64 ARM_Dynarmic_64::GetSP() const { | 369 | HaltReason ArmDynarmic64::StepThread(Kernel::KThread* thread) { |
| 425 | return jit.load()->GetSP(); | 370 | m_jit->ClearExclusiveState(); |
| 371 | return TranslateHaltReason(m_jit->Step()); | ||
| 426 | } | 372 | } |
| 427 | 373 | ||
| 428 | u64 ARM_Dynarmic_64::GetReg(int index) const { | 374 | u32 ArmDynarmic64::GetSvcNumber() const { |
| 429 | return jit.load()->GetRegister(index); | 375 | return m_svc; |
| 430 | } | 376 | } |
| 431 | 377 | ||
| 432 | void ARM_Dynarmic_64::SetReg(int index, u64 value) { | 378 | void ArmDynarmic64::GetSvcArguments(std::span<uint64_t, 8> args) const { |
| 433 | jit.load()->SetRegister(index, value); | 379 | Dynarmic::A64::Jit& j = *m_jit; |
| 434 | } | ||
| 435 | 380 | ||
| 436 | u128 ARM_Dynarmic_64::GetVectorReg(int index) const { | 381 | for (size_t i = 0; i < 8; i++) { |
| 437 | return jit.load()->GetVector(index); | 382 | args[i] = j.GetRegister(i); |
| 383 | } | ||
| 438 | } | 384 | } |
| 439 | 385 | ||
| 440 | void ARM_Dynarmic_64::SetVectorReg(int index, u128 value) { | 386 | void ArmDynarmic64::SetSvcArguments(std::span<const uint64_t, 8> args) { |
| 441 | jit.load()->SetVector(index, value); | 387 | Dynarmic::A64::Jit& j = *m_jit; |
| 442 | } | ||
| 443 | 388 | ||
| 444 | u32 ARM_Dynarmic_64::GetPSTATE() const { | 389 | for (size_t i = 0; i < 8; i++) { |
| 445 | return jit.load()->GetPstate(); | 390 | j.SetRegister(i, args[i]); |
| 391 | } | ||
| 446 | } | 392 | } |
| 447 | 393 | ||
| 448 | void ARM_Dynarmic_64::SetPSTATE(u32 pstate) { | 394 | const Kernel::DebugWatchpoint* ArmDynarmic64::HaltedWatchpoint() const { |
| 449 | jit.load()->SetPstate(pstate); | 395 | return m_halted_watchpoint; |
| 450 | } | 396 | } |
| 451 | 397 | ||
| 452 | u64 ARM_Dynarmic_64::GetTlsAddress() const { | 398 | void ArmDynarmic64::RewindBreakpointInstruction() { |
| 453 | return cb->tpidrro_el0; | 399 | this->SetContext(m_breakpoint_context); |
| 454 | } | 400 | } |
| 455 | 401 | ||
| 456 | void ARM_Dynarmic_64::SetTlsAddress(u64 address) { | 402 | ArmDynarmic64::ArmDynarmic64(System& system, bool uses_wall_clock, const Kernel::KProcess* process, |
| 457 | cb->tpidrro_el0 = address; | 403 | DynarmicExclusiveMonitor& exclusive_monitor, std::size_t core_index) |
| 404 | : ArmInterface{uses_wall_clock}, m_system{system}, m_exclusive_monitor{exclusive_monitor}, | ||
| 405 | m_cb(std::make_unique<DynarmicCallbacks64>(*this, process)), m_core_index{core_index} { | ||
| 406 | auto& page_table = process->GetPageTable().GetBasePageTable(); | ||
| 407 | auto& page_table_impl = page_table.GetImpl(); | ||
| 408 | m_jit = MakeJit(&page_table_impl, page_table.GetAddressSpaceWidth()); | ||
| 458 | } | 409 | } |
| 459 | 410 | ||
| 460 | u64 ARM_Dynarmic_64::GetTPIDR_EL0() const { | 411 | ArmDynarmic64::~ArmDynarmic64() = default; |
| 461 | return cb->tpidr_el0; | ||
| 462 | } | ||
| 463 | 412 | ||
| 464 | void ARM_Dynarmic_64::SetTPIDR_EL0(u64 value) { | 413 | void ArmDynarmic64::SetTpidrroEl0(u64 value) { |
| 465 | cb->tpidr_el0 = value; | 414 | m_cb->m_tpidrro_el0 = value; |
| 466 | } | 415 | } |
| 467 | 416 | ||
| 468 | void ARM_Dynarmic_64::SaveContext(ThreadContext64& ctx) const { | 417 | void ArmDynarmic64::GetContext(Kernel::Svc::ThreadContext& ctx) const { |
| 469 | Dynarmic::A64::Jit* j = jit.load(); | 418 | Dynarmic::A64::Jit& j = *m_jit; |
| 470 | ctx.cpu_registers = j->GetRegisters(); | 419 | auto gpr = j.GetRegisters(); |
| 471 | ctx.sp = j->GetSP(); | 420 | auto fpr = j.GetVectors(); |
| 472 | ctx.pc = j->GetPC(); | ||
| 473 | ctx.pstate = j->GetPstate(); | ||
| 474 | ctx.vector_registers = j->GetVectors(); | ||
| 475 | ctx.fpcr = j->GetFpcr(); | ||
| 476 | ctx.fpsr = j->GetFpsr(); | ||
| 477 | ctx.tpidr = cb->tpidr_el0; | ||
| 478 | } | ||
| 479 | 421 | ||
| 480 | void ARM_Dynarmic_64::LoadContext(const ThreadContext64& ctx) { | 422 | // TODO: this is inconvenient |
| 481 | Dynarmic::A64::Jit* j = jit.load(); | 423 | for (size_t i = 0; i < 29; i++) { |
| 482 | j->SetRegisters(ctx.cpu_registers); | 424 | ctx.r[i] = gpr[i]; |
| 483 | j->SetSP(ctx.sp); | 425 | } |
| 484 | j->SetPC(ctx.pc); | 426 | ctx.fp = gpr[29]; |
| 485 | j->SetPstate(ctx.pstate); | 427 | ctx.lr = gpr[30]; |
| 486 | j->SetVectors(ctx.vector_registers); | 428 | |
| 487 | j->SetFpcr(ctx.fpcr); | 429 | ctx.sp = j.GetSP(); |
| 488 | j->SetFpsr(ctx.fpsr); | 430 | ctx.pc = j.GetPC(); |
| 489 | SetTPIDR_EL0(ctx.tpidr); | 431 | ctx.pstate = j.GetPstate(); |
| 432 | ctx.v = fpr; | ||
| 433 | ctx.fpcr = j.GetFpcr(); | ||
| 434 | ctx.fpsr = j.GetFpsr(); | ||
| 435 | ctx.tpidr = m_cb->m_tpidr_el0; | ||
| 490 | } | 436 | } |
| 491 | 437 | ||
| 492 | void ARM_Dynarmic_64::SignalInterrupt() { | 438 | void ArmDynarmic64::SetContext(const Kernel::Svc::ThreadContext& ctx) { |
| 493 | jit.load()->HaltExecution(BreakLoop); | 439 | Dynarmic::A64::Jit& j = *m_jit; |
| 494 | } | ||
| 495 | 440 | ||
| 496 | void ARM_Dynarmic_64::ClearInterrupt() { | 441 | // TODO: this is inconvenient |
| 497 | jit.load()->ClearHalt(BreakLoop); | 442 | std::array<u64, 31> gpr; |
| 498 | } | ||
| 499 | 443 | ||
| 500 | void ARM_Dynarmic_64::ClearInstructionCache() { | 444 | for (size_t i = 0; i < 29; i++) { |
| 501 | jit.load()->ClearCache(); | 445 | gpr[i] = ctx.r[i]; |
| 446 | } | ||
| 447 | gpr[29] = ctx.fp; | ||
| 448 | gpr[30] = ctx.lr; | ||
| 449 | |||
| 450 | j.SetRegisters(gpr); | ||
| 451 | j.SetSP(ctx.sp); | ||
| 452 | j.SetPC(ctx.pc); | ||
| 453 | j.SetPstate(ctx.pstate); | ||
| 454 | j.SetVectors(ctx.v); | ||
| 455 | j.SetFpcr(ctx.fpcr); | ||
| 456 | j.SetFpsr(ctx.fpsr); | ||
| 457 | m_cb->m_tpidr_el0 = ctx.tpidr; | ||
| 502 | } | 458 | } |
| 503 | 459 | ||
| 504 | void ARM_Dynarmic_64::InvalidateCacheRange(u64 addr, std::size_t size) { | 460 | void ArmDynarmic64::SignalInterrupt(Kernel::KThread* thread) { |
| 505 | jit.load()->InvalidateCacheRange(addr, size); | 461 | m_jit->HaltExecution(BreakLoop); |
| 506 | } | 462 | } |
| 507 | 463 | ||
| 508 | void ARM_Dynarmic_64::ClearExclusiveState() { | 464 | void ArmDynarmic64::ClearInstructionCache() { |
| 509 | jit.load()->ClearExclusiveState(); | 465 | m_jit->ClearCache(); |
| 510 | } | 466 | } |
| 511 | 467 | ||
| 512 | void ARM_Dynarmic_64::PageTableChanged(Common::PageTable& page_table, | 468 | void ArmDynarmic64::InvalidateCacheRange(u64 addr, std::size_t size) { |
| 513 | std::size_t new_address_space_size_in_bits) { | 469 | m_jit->InvalidateCacheRange(addr, size); |
| 514 | ThreadContext64 ctx{}; | ||
| 515 | SaveContext(ctx); | ||
| 516 | |||
| 517 | auto key = std::make_pair(&page_table, new_address_space_size_in_bits); | ||
| 518 | auto iter = jit_cache.find(key); | ||
| 519 | if (iter != jit_cache.end()) { | ||
| 520 | jit.store(iter->second.get()); | ||
| 521 | LoadContext(ctx); | ||
| 522 | return; | ||
| 523 | } | ||
| 524 | std::shared_ptr new_jit = MakeJit(&page_table, new_address_space_size_in_bits); | ||
| 525 | jit.store(new_jit.get()); | ||
| 526 | LoadContext(ctx); | ||
| 527 | jit_cache.emplace(key, std::move(new_jit)); | ||
| 528 | } | 470 | } |
| 529 | 471 | ||
| 530 | } // namespace Core | 472 | } // namespace Core |
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.h b/src/core/arm/dynarmic/arm_dynarmic_64.h index 2b88a08e2..4f3dd026f 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.h +++ b/src/core/arm/dynarmic/arm_dynarmic_64.h | |||
| @@ -23,76 +23,55 @@ class DynarmicCallbacks64; | |||
| 23 | class DynarmicExclusiveMonitor; | 23 | class DynarmicExclusiveMonitor; |
| 24 | class System; | 24 | class System; |
| 25 | 25 | ||
| 26 | class ARM_Dynarmic_64 final : public ARM_Interface { | 26 | class ArmDynarmic64 final : public ArmInterface { |
| 27 | public: | 27 | public: |
| 28 | ARM_Dynarmic_64(System& system_, bool uses_wall_clock_, | 28 | ArmDynarmic64(System& system, bool uses_wall_clock, const Kernel::KProcess* process, |
| 29 | DynarmicExclusiveMonitor& exclusive_monitor_, std::size_t core_index_); | 29 | DynarmicExclusiveMonitor& exclusive_monitor, std::size_t core_index); |
| 30 | ~ARM_Dynarmic_64() override; | 30 | ~ArmDynarmic64() override; |
| 31 | |||
| 32 | void SetPC(u64 pc) override; | ||
| 33 | u64 GetPC() const override; | ||
| 34 | u64 GetSP() const override; | ||
| 35 | u64 GetReg(int index) const override; | ||
| 36 | void SetReg(int index, u64 value) override; | ||
| 37 | u128 GetVectorReg(int index) const override; | ||
| 38 | void SetVectorReg(int index, u128 value) override; | ||
| 39 | u32 GetPSTATE() const override; | ||
| 40 | void SetPSTATE(u32 pstate) override; | ||
| 41 | u64 GetTlsAddress() const override; | ||
| 42 | void SetTlsAddress(u64 address) override; | ||
| 43 | void SetTPIDR_EL0(u64 value) override; | ||
| 44 | u64 GetTPIDR_EL0() const override; | ||
| 45 | 31 | ||
| 46 | Architecture GetArchitecture() const override { | 32 | Architecture GetArchitecture() const override { |
| 47 | return Architecture::Aarch64; | 33 | return Architecture::AArch64; |
| 48 | } | 34 | } |
| 49 | void SaveContext(ThreadContext32& ctx) const override {} | ||
| 50 | void SaveContext(ThreadContext64& ctx) const override; | ||
| 51 | void LoadContext(const ThreadContext32& ctx) override {} | ||
| 52 | void LoadContext(const ThreadContext64& ctx) override; | ||
| 53 | 35 | ||
| 54 | void SignalInterrupt() override; | 36 | HaltReason RunThread(Kernel::KThread* thread) override; |
| 55 | void ClearInterrupt() override; | 37 | HaltReason StepThread(Kernel::KThread* thread) override; |
| 56 | void ClearExclusiveState() override; | ||
| 57 | 38 | ||
| 39 | void GetContext(Kernel::Svc::ThreadContext& ctx) const override; | ||
| 40 | void SetContext(const Kernel::Svc::ThreadContext& ctx) override; | ||
| 41 | void SetTpidrroEl0(u64 value) override; | ||
| 42 | |||
| 43 | void GetSvcArguments(std::span<uint64_t, 8> args) const override; | ||
| 44 | void SetSvcArguments(std::span<const uint64_t, 8> args) override; | ||
| 45 | u32 GetSvcNumber() const override; | ||
| 46 | |||
| 47 | void SignalInterrupt(Kernel::KThread* thread) override; | ||
| 58 | void ClearInstructionCache() override; | 48 | void ClearInstructionCache() override; |
| 59 | void InvalidateCacheRange(u64 addr, std::size_t size) override; | 49 | void InvalidateCacheRange(u64 addr, std::size_t size) override; |
| 60 | void PageTableChanged(Common::PageTable& new_page_table, | ||
| 61 | std::size_t new_address_space_size_in_bits) override; | ||
| 62 | 50 | ||
| 63 | protected: | 51 | protected: |
| 64 | HaltReason RunJit() override; | ||
| 65 | HaltReason StepJit() override; | ||
| 66 | u32 GetSvcNumber() const override; | ||
| 67 | const Kernel::DebugWatchpoint* HaltedWatchpoint() const override; | 52 | const Kernel::DebugWatchpoint* HaltedWatchpoint() const override; |
| 68 | void RewindBreakpointInstruction() override; | 53 | void RewindBreakpointInstruction() override; |
| 69 | 54 | ||
| 70 | private: | 55 | private: |
| 71 | std::shared_ptr<Dynarmic::A64::Jit> MakeJit(Common::PageTable* page_table, | 56 | System& m_system; |
| 72 | std::size_t address_space_bits) const; | 57 | DynarmicExclusiveMonitor& m_exclusive_monitor; |
| 73 | |||
| 74 | using JitCacheKey = std::pair<Common::PageTable*, std::size_t>; | ||
| 75 | using JitCacheType = | ||
| 76 | std::unordered_map<JitCacheKey, std::shared_ptr<Dynarmic::A64::Jit>, Common::PairHash>; | ||
| 77 | 58 | ||
| 59 | private: | ||
| 78 | friend class DynarmicCallbacks64; | 60 | friend class DynarmicCallbacks64; |
| 79 | std::unique_ptr<DynarmicCallbacks64> cb; | ||
| 80 | JitCacheType jit_cache; | ||
| 81 | |||
| 82 | std::size_t core_index; | ||
| 83 | DynarmicExclusiveMonitor& exclusive_monitor; | ||
| 84 | 61 | ||
| 85 | std::shared_ptr<Dynarmic::A64::Jit> null_jit; | 62 | std::shared_ptr<Dynarmic::A64::Jit> MakeJit(Common::PageTable* page_table, |
| 63 | std::size_t address_space_bits) const; | ||
| 64 | std::unique_ptr<DynarmicCallbacks64> m_cb{}; | ||
| 65 | std::size_t m_core_index{}; | ||
| 86 | 66 | ||
| 87 | // A raw pointer here is fine; we never delete Jit instances. | 67 | std::shared_ptr<Dynarmic::A64::Jit> m_jit{}; |
| 88 | std::atomic<Dynarmic::A64::Jit*> jit; | ||
| 89 | 68 | ||
| 90 | // SVC callback | 69 | // SVC callback |
| 91 | u32 svc_swi{}; | 70 | u32 m_svc{}; |
| 92 | 71 | ||
| 93 | // Breakpoint info | 72 | // Watchpoint info |
| 94 | const Kernel::DebugWatchpoint* halted_watchpoint; | 73 | const Kernel::DebugWatchpoint* m_halted_watchpoint{}; |
| 95 | ThreadContext64 breakpoint_context; | 74 | Kernel::Svc::ThreadContext m_breakpoint_context{}; |
| 96 | }; | 75 | }; |
| 97 | 76 | ||
| 98 | } // namespace Core | 77 | } // namespace Core |
diff --git a/src/core/arm/dynarmic/dynarmic_cp15.cpp b/src/core/arm/dynarmic/dynarmic_cp15.cpp index 92c548db0..f3eee0d42 100644 --- a/src/core/arm/dynarmic/dynarmic_cp15.cpp +++ b/src/core/arm/dynarmic/dynarmic_cp15.cpp | |||
| @@ -124,8 +124,8 @@ CallbackOrAccessTwoWords DynarmicCP15::CompileGetTwoWords(bool two, unsigned opc | |||
| 124 | if (!two && opc == 0 && CRm == CoprocReg::C14) { | 124 | if (!two && opc == 0 && CRm == CoprocReg::C14) { |
| 125 | // CNTPCT | 125 | // CNTPCT |
| 126 | const auto callback = [](void* arg, u32, u32) -> u64 { | 126 | const auto callback = [](void* arg, u32, u32) -> u64 { |
| 127 | const auto& parent_arg = *static_cast<ARM_Dynarmic_32*>(arg); | 127 | const auto& parent_arg = *static_cast<ArmDynarmic32*>(arg); |
| 128 | return parent_arg.system.CoreTiming().GetClockTicks(); | 128 | return parent_arg.m_system.CoreTiming().GetClockTicks(); |
| 129 | }; | 129 | }; |
| 130 | return Callback{callback, &parent}; | 130 | return Callback{callback, &parent}; |
| 131 | } | 131 | } |
diff --git a/src/core/arm/dynarmic/dynarmic_cp15.h b/src/core/arm/dynarmic/dynarmic_cp15.h index d90b3e568..f3d96b0d8 100644 --- a/src/core/arm/dynarmic/dynarmic_cp15.h +++ b/src/core/arm/dynarmic/dynarmic_cp15.h | |||
| @@ -10,13 +10,13 @@ | |||
| 10 | 10 | ||
| 11 | namespace Core { | 11 | namespace Core { |
| 12 | 12 | ||
| 13 | class ARM_Dynarmic_32; | 13 | class ArmDynarmic32; |
| 14 | 14 | ||
| 15 | class DynarmicCP15 final : public Dynarmic::A32::Coprocessor { | 15 | class DynarmicCP15 final : public Dynarmic::A32::Coprocessor { |
| 16 | public: | 16 | public: |
| 17 | using CoprocReg = Dynarmic::A32::CoprocReg; | 17 | using CoprocReg = Dynarmic::A32::CoprocReg; |
| 18 | 18 | ||
| 19 | explicit DynarmicCP15(ARM_Dynarmic_32& parent_) : parent{parent_} {} | 19 | explicit DynarmicCP15(ArmDynarmic32& parent_) : parent{parent_} {} |
| 20 | 20 | ||
| 21 | std::optional<Callback> CompileInternalOperation(bool two, unsigned opc1, CoprocReg CRd, | 21 | std::optional<Callback> CompileInternalOperation(bool two, unsigned opc1, CoprocReg CRd, |
| 22 | CoprocReg CRn, CoprocReg CRm, | 22 | CoprocReg CRn, CoprocReg CRm, |
| @@ -32,11 +32,11 @@ public: | |||
| 32 | std::optional<Callback> CompileStoreWords(bool two, bool long_transfer, CoprocReg CRd, | 32 | std::optional<Callback> CompileStoreWords(bool two, bool long_transfer, CoprocReg CRd, |
| 33 | std::optional<u8> option) override; | 33 | std::optional<u8> option) override; |
| 34 | 34 | ||
| 35 | ARM_Dynarmic_32& parent; | 35 | ArmDynarmic32& parent; |
| 36 | u32 uprw = 0; | 36 | u32 uprw = 0; |
| 37 | u32 uro = 0; | 37 | u32 uro = 0; |
| 38 | 38 | ||
| 39 | friend class ARM_Dynarmic_32; | 39 | friend class ArmDynarmic32; |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
| 42 | } // namespace Core | 42 | } // namespace Core |
diff --git a/src/core/arm/dynarmic/dynarmic_exclusive_monitor.h b/src/core/arm/dynarmic/dynarmic_exclusive_monitor.h index fbfcd8d95..c4f22ec89 100644 --- a/src/core/arm/dynarmic/dynarmic_exclusive_monitor.h +++ b/src/core/arm/dynarmic/dynarmic_exclusive_monitor.h | |||
| @@ -14,8 +14,8 @@ class Memory; | |||
| 14 | 14 | ||
| 15 | namespace Core { | 15 | namespace Core { |
| 16 | 16 | ||
| 17 | class ARM_Dynarmic_32; | 17 | class ArmDynarmic32; |
| 18 | class ARM_Dynarmic_64; | 18 | class ArmDynarmic64; |
| 19 | 19 | ||
| 20 | class DynarmicExclusiveMonitor final : public ExclusiveMonitor { | 20 | class DynarmicExclusiveMonitor final : public ExclusiveMonitor { |
| 21 | public: | 21 | public: |
| @@ -36,8 +36,8 @@ public: | |||
| 36 | bool ExclusiveWrite128(std::size_t core_index, VAddr vaddr, u128 value) override; | 36 | bool ExclusiveWrite128(std::size_t core_index, VAddr vaddr, u128 value) override; |
| 37 | 37 | ||
| 38 | private: | 38 | private: |
| 39 | friend class ARM_Dynarmic_32; | 39 | friend class ArmDynarmic32; |
| 40 | friend class ARM_Dynarmic_64; | 40 | friend class ArmDynarmic64; |
| 41 | Dynarmic::ExclusiveMonitor monitor; | 41 | Dynarmic::ExclusiveMonitor monitor; |
| 42 | Core::Memory::Memory& memory; | 42 | Core::Memory::Memory& memory; |
| 43 | }; | 43 | }; |
diff --git a/src/core/arm/nce/arm_nce.cpp b/src/core/arm/nce/arm_nce.cpp index f7bdafd39..b42a32a0b 100644 --- a/src/core/arm/nce/arm_nce.cpp +++ b/src/core/arm/nce/arm_nce.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/signal_chain.h" | 7 | #include "common/signal_chain.h" |
| 8 | #include "core/arm/nce/arm_nce.h" | 8 | #include "core/arm/nce/arm_nce.h" |
| 9 | #include "core/arm/nce/guest_context.h" | ||
| 9 | #include "core/arm/nce/patcher.h" | 10 | #include "core/arm/nce/patcher.h" |
| 10 | #include "core/core.h" | 11 | #include "core/core.h" |
| 11 | #include "core/memory.h" | 12 | #include "core/memory.h" |
| @@ -38,7 +39,7 @@ fpsimd_context* GetFloatingPointState(mcontext_t& host_ctx) { | |||
| 38 | 39 | ||
| 39 | } // namespace | 40 | } // namespace |
| 40 | 41 | ||
| 41 | void* ARM_NCE::RestoreGuestContext(void* raw_context) { | 42 | void* ArmNce::RestoreGuestContext(void* raw_context) { |
| 42 | // Retrieve the host context. | 43 | // Retrieve the host context. |
| 43 | auto& host_ctx = static_cast<ucontext_t*>(raw_context)->uc_mcontext; | 44 | auto& host_ctx = static_cast<ucontext_t*>(raw_context)->uc_mcontext; |
| 44 | 45 | ||
| @@ -71,7 +72,7 @@ void* ARM_NCE::RestoreGuestContext(void* raw_context) { | |||
| 71 | return tpidr; | 72 | return tpidr; |
| 72 | } | 73 | } |
| 73 | 74 | ||
| 74 | void ARM_NCE::SaveGuestContext(GuestContext* guest_ctx, void* raw_context) { | 75 | void ArmNce::SaveGuestContext(GuestContext* guest_ctx, void* raw_context) { |
| 75 | // Retrieve the host context. | 76 | // Retrieve the host context. |
| 76 | auto& host_ctx = static_cast<ucontext_t*>(raw_context)->uc_mcontext; | 77 | auto& host_ctx = static_cast<ucontext_t*>(raw_context)->uc_mcontext; |
| 77 | 78 | ||
| @@ -103,7 +104,7 @@ void ARM_NCE::SaveGuestContext(GuestContext* guest_ctx, void* raw_context) { | |||
| 103 | host_ctx.regs[0] = guest_ctx->esr_el1.exchange(0); | 104 | host_ctx.regs[0] = guest_ctx->esr_el1.exchange(0); |
| 104 | } | 105 | } |
| 105 | 106 | ||
| 106 | bool ARM_NCE::HandleGuestFault(GuestContext* guest_ctx, void* raw_info, void* raw_context) { | 107 | bool ArmNce::HandleGuestFault(GuestContext* guest_ctx, void* raw_info, void* raw_context) { |
| 107 | auto& host_ctx = static_cast<ucontext_t*>(raw_context)->uc_mcontext; | 108 | auto& host_ctx = static_cast<ucontext_t*>(raw_context)->uc_mcontext; |
| 108 | auto* info = static_cast<siginfo_t*>(raw_info); | 109 | auto* info = static_cast<siginfo_t*>(raw_info); |
| 109 | 110 | ||
| @@ -134,7 +135,7 @@ bool ARM_NCE::HandleGuestFault(GuestContext* guest_ctx, void* raw_info, void* ra | |||
| 134 | // - If we lose the race, then SignalInterrupt will send us a signal we are masking, | 135 | // - If we lose the race, then SignalInterrupt will send us a signal we are masking, |
| 135 | // and it will do nothing when it is unmasked, as we have already left guest code. | 136 | // and it will do nothing when it is unmasked, as we have already left guest code. |
| 136 | // - If we win the race, then SignalInterrupt will wait for us to unlock first. | 137 | // - If we win the race, then SignalInterrupt will wait for us to unlock first. |
| 137 | auto& thread_params = guest_ctx->parent->running_thread->GetNativeExecutionParameters(); | 138 | auto& thread_params = guest_ctx->parent->m_running_thread->GetNativeExecutionParameters(); |
| 138 | thread_params.lock.store(SpinLockLocked); | 139 | thread_params.lock.store(SpinLockLocked); |
| 139 | 140 | ||
| 140 | // Return to host. | 141 | // Return to host. |
| @@ -142,97 +143,93 @@ bool ARM_NCE::HandleGuestFault(GuestContext* guest_ctx, void* raw_info, void* ra | |||
| 142 | return false; | 143 | return false; |
| 143 | } | 144 | } |
| 144 | 145 | ||
| 145 | void ARM_NCE::HandleHostFault(int sig, void* raw_info, void* raw_context) { | 146 | void ArmNce::HandleHostFault(int sig, void* raw_info, void* raw_context) { |
| 146 | return g_orig_action.sa_sigaction(sig, static_cast<siginfo_t*>(raw_info), raw_context); | 147 | return g_orig_action.sa_sigaction(sig, static_cast<siginfo_t*>(raw_info), raw_context); |
| 147 | } | 148 | } |
| 148 | 149 | ||
| 149 | HaltReason ARM_NCE::RunJit() { | 150 | void ArmNce::LockThread(Kernel::KThread* thread) { |
| 150 | // Get the thread parameters. | ||
| 151 | // TODO: pass the current thread down from ::Run | ||
| 152 | auto* thread = Kernel::GetCurrentThreadPointer(system.Kernel()); | ||
| 153 | auto* thread_params = &thread->GetNativeExecutionParameters(); | 151 | auto* thread_params = &thread->GetNativeExecutionParameters(); |
| 152 | LockThreadParameters(thread_params); | ||
| 153 | } | ||
| 154 | 154 | ||
| 155 | { | 155 | void ArmNce::UnlockThread(Kernel::KThread* thread) { |
| 156 | // Lock our core context. | 156 | auto* thread_params = &thread->GetNativeExecutionParameters(); |
| 157 | std::scoped_lock lk{lock}; | 157 | UnlockThreadParameters(thread_params); |
| 158 | 158 | } | |
| 159 | // We should not be running. | ||
| 160 | ASSERT(running_thread == nullptr); | ||
| 161 | |||
| 162 | // Check if we need to run. If we have already been halted, we are done. | ||
| 163 | u64 halt = guest_ctx.esr_el1.exchange(0); | ||
| 164 | if (halt != 0) { | ||
| 165 | return static_cast<HaltReason>(halt); | ||
| 166 | } | ||
| 167 | |||
| 168 | // Mark that we are running. | ||
| 169 | running_thread = thread; | ||
| 170 | 159 | ||
| 171 | // Acquire the lock on the thread parameters. | 160 | HaltReason ArmNce::RunThread(Kernel::KThread* thread) { |
| 172 | // This allows us to force synchronization with SignalInterrupt. | 161 | // Check if we're already interrupted. |
| 173 | LockThreadParameters(thread_params); | 162 | // If we are, we can just return immediately. |
| 163 | HaltReason hr = static_cast<HaltReason>(m_guest_ctx.esr_el1.exchange(0)); | ||
| 164 | if (True(hr)) { | ||
| 165 | return hr; | ||
| 174 | } | 166 | } |
| 175 | 167 | ||
| 168 | // Get the thread context. | ||
| 169 | auto* thread_params = &thread->GetNativeExecutionParameters(); | ||
| 170 | auto* process = thread->GetOwnerProcess(); | ||
| 171 | |||
| 176 | // Assign current members. | 172 | // Assign current members. |
| 177 | guest_ctx.parent = this; | 173 | m_running_thread = thread; |
| 178 | thread_params->native_context = &guest_ctx; | 174 | m_guest_ctx.parent = this; |
| 179 | thread_params->tpidr_el0 = guest_ctx.tpidr_el0; | 175 | thread_params->native_context = &m_guest_ctx; |
| 180 | thread_params->tpidrro_el0 = guest_ctx.tpidrro_el0; | 176 | thread_params->tpidr_el0 = m_guest_ctx.tpidr_el0; |
| 177 | thread_params->tpidrro_el0 = m_guest_ctx.tpidrro_el0; | ||
| 181 | thread_params->is_running = true; | 178 | thread_params->is_running = true; |
| 182 | 179 | ||
| 183 | HaltReason halt{}; | ||
| 184 | |||
| 185 | // TODO: finding and creating the post handler needs to be locked | 180 | // TODO: finding and creating the post handler needs to be locked |
| 186 | // to deal with dynamic loading of NROs. | 181 | // to deal with dynamic loading of NROs. |
| 187 | const auto& post_handlers = system.ApplicationProcess()->GetPostHandlers(); | 182 | const auto& post_handlers = process->GetPostHandlers(); |
| 188 | if (auto it = post_handlers.find(guest_ctx.pc); it != post_handlers.end()) { | 183 | if (auto it = post_handlers.find(m_guest_ctx.pc); it != post_handlers.end()) { |
| 189 | halt = ReturnToRunCodeByTrampoline(thread_params, &guest_ctx, it->second); | 184 | hr = ReturnToRunCodeByTrampoline(thread_params, &m_guest_ctx, it->second); |
| 190 | } else { | 185 | } else { |
| 191 | halt = ReturnToRunCodeByExceptionLevelChange(thread_id, thread_params); | 186 | hr = ReturnToRunCodeByExceptionLevelChange(m_thread_id, thread_params); |
| 192 | } | 187 | } |
| 193 | 188 | ||
| 194 | // Unload members. | 189 | // Unload members. |
| 195 | // The thread does not change, so we can persist the old reference. | 190 | // The thread does not change, so we can persist the old reference. |
| 196 | guest_ctx.tpidr_el0 = thread_params->tpidr_el0; | 191 | m_running_thread = nullptr; |
| 192 | m_guest_ctx.tpidr_el0 = thread_params->tpidr_el0; | ||
| 197 | thread_params->native_context = nullptr; | 193 | thread_params->native_context = nullptr; |
| 198 | thread_params->is_running = false; | 194 | thread_params->is_running = false; |
| 199 | 195 | ||
| 200 | // Unlock the thread parameters. | ||
| 201 | UnlockThreadParameters(thread_params); | ||
| 202 | |||
| 203 | { | ||
| 204 | // Lock the core context. | ||
| 205 | std::scoped_lock lk{lock}; | ||
| 206 | |||
| 207 | // On exit, we no longer have an active thread. | ||
| 208 | running_thread = nullptr; | ||
| 209 | } | ||
| 210 | |||
| 211 | // Return the halt reason. | 196 | // Return the halt reason. |
| 212 | return halt; | 197 | return hr; |
| 213 | } | 198 | } |
| 214 | 199 | ||
| 215 | HaltReason ARM_NCE::StepJit() { | 200 | HaltReason ArmNce::StepThread(Kernel::KThread* thread) { |
| 216 | return HaltReason::StepThread; | 201 | return HaltReason::StepThread; |
| 217 | } | 202 | } |
| 218 | 203 | ||
| 219 | u32 ARM_NCE::GetSvcNumber() const { | 204 | u32 ArmNce::GetSvcNumber() const { |
| 220 | return guest_ctx.svc_swi; | 205 | return m_guest_ctx.svc; |
| 206 | } | ||
| 207 | |||
| 208 | void ArmNce::GetSvcArguments(std::span<uint64_t, 8> args) const { | ||
| 209 | for (size_t i = 0; i < 8; i++) { | ||
| 210 | args[i] = m_guest_ctx.cpu_registers[i]; | ||
| 211 | } | ||
| 212 | } | ||
| 213 | |||
| 214 | void ArmNce::SetSvcArguments(std::span<const uint64_t, 8> args) { | ||
| 215 | for (size_t i = 0; i < 8; i++) { | ||
| 216 | m_guest_ctx.cpu_registers[i] = args[i]; | ||
| 217 | } | ||
| 221 | } | 218 | } |
| 222 | 219 | ||
| 223 | ARM_NCE::ARM_NCE(System& system_, bool uses_wall_clock_, std::size_t core_index_) | 220 | ArmNce::ArmNce(System& system, bool uses_wall_clock, std::size_t core_index) |
| 224 | : ARM_Interface{system_, uses_wall_clock_}, core_index{core_index_} { | 221 | : ArmInterface{uses_wall_clock}, m_system{system}, m_core_index{core_index} { |
| 225 | guest_ctx.system = &system_; | 222 | m_guest_ctx.system = &m_system; |
| 226 | } | 223 | } |
| 227 | 224 | ||
| 228 | ARM_NCE::~ARM_NCE() = default; | 225 | ArmNce::~ArmNce() = default; |
| 229 | 226 | ||
| 230 | void ARM_NCE::Initialize() { | 227 | void ArmNce::Initialize() { |
| 231 | thread_id = gettid(); | 228 | m_thread_id = gettid(); |
| 232 | 229 | ||
| 233 | // Setup our signals | 230 | // Setup our signals |
| 234 | static std::once_flag flag; | 231 | static std::once_flag signals; |
| 235 | std::call_once(flag, [] { | 232 | std::call_once(signals, [] { |
| 236 | using HandlerType = decltype(sigaction::sa_sigaction); | 233 | using HandlerType = decltype(sigaction::sa_sigaction); |
| 237 | 234 | ||
| 238 | sigset_t signal_mask; | 235 | sigset_t signal_mask; |
| @@ -244,7 +241,7 @@ void ARM_NCE::Initialize() { | |||
| 244 | struct sigaction return_to_run_code_action {}; | 241 | struct sigaction return_to_run_code_action {}; |
| 245 | return_to_run_code_action.sa_flags = SA_SIGINFO | SA_ONSTACK; | 242 | return_to_run_code_action.sa_flags = SA_SIGINFO | SA_ONSTACK; |
| 246 | return_to_run_code_action.sa_sigaction = reinterpret_cast<HandlerType>( | 243 | return_to_run_code_action.sa_sigaction = reinterpret_cast<HandlerType>( |
| 247 | &ARM_NCE::ReturnToRunCodeByExceptionLevelChangeSignalHandler); | 244 | &ArmNce::ReturnToRunCodeByExceptionLevelChangeSignalHandler); |
| 248 | return_to_run_code_action.sa_mask = signal_mask; | 245 | return_to_run_code_action.sa_mask = signal_mask; |
| 249 | Common::SigAction(ReturnToRunCodeByExceptionLevelChangeSignal, &return_to_run_code_action, | 246 | Common::SigAction(ReturnToRunCodeByExceptionLevelChangeSignal, &return_to_run_code_action, |
| 250 | nullptr); | 247 | nullptr); |
| @@ -252,14 +249,13 @@ void ARM_NCE::Initialize() { | |||
| 252 | struct sigaction break_from_run_code_action {}; | 249 | struct sigaction break_from_run_code_action {}; |
| 253 | break_from_run_code_action.sa_flags = SA_SIGINFO | SA_ONSTACK; | 250 | break_from_run_code_action.sa_flags = SA_SIGINFO | SA_ONSTACK; |
| 254 | break_from_run_code_action.sa_sigaction = | 251 | break_from_run_code_action.sa_sigaction = |
| 255 | reinterpret_cast<HandlerType>(&ARM_NCE::BreakFromRunCodeSignalHandler); | 252 | reinterpret_cast<HandlerType>(&ArmNce::BreakFromRunCodeSignalHandler); |
| 256 | break_from_run_code_action.sa_mask = signal_mask; | 253 | break_from_run_code_action.sa_mask = signal_mask; |
| 257 | Common::SigAction(BreakFromRunCodeSignal, &break_from_run_code_action, nullptr); | 254 | Common::SigAction(BreakFromRunCodeSignal, &break_from_run_code_action, nullptr); |
| 258 | 255 | ||
| 259 | struct sigaction fault_action {}; | 256 | struct sigaction fault_action {}; |
| 260 | fault_action.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESTART; | 257 | fault_action.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESTART; |
| 261 | fault_action.sa_sigaction = | 258 | fault_action.sa_sigaction = reinterpret_cast<HandlerType>(&ArmNce::GuestFaultSignalHandler); |
| 262 | reinterpret_cast<HandlerType>(&ARM_NCE::GuestFaultSignalHandler); | ||
| 263 | fault_action.sa_mask = signal_mask; | 259 | fault_action.sa_mask = signal_mask; |
| 264 | Common::SigAction(GuestFaultSignal, &fault_action, &g_orig_action); | 260 | Common::SigAction(GuestFaultSignal, &fault_action, &g_orig_action); |
| 265 | 261 | ||
| @@ -272,111 +268,59 @@ void ARM_NCE::Initialize() { | |||
| 272 | }); | 268 | }); |
| 273 | } | 269 | } |
| 274 | 270 | ||
| 275 | void ARM_NCE::SetPC(u64 pc) { | 271 | void ArmNce::SetTpidrroEl0(u64 value) { |
| 276 | guest_ctx.pc = pc; | 272 | m_guest_ctx.tpidrro_el0 = value; |
| 277 | } | 273 | } |
| 278 | 274 | ||
| 279 | u64 ARM_NCE::GetPC() const { | 275 | void ArmNce::GetContext(Kernel::Svc::ThreadContext& ctx) const { |
| 280 | return guest_ctx.pc; | 276 | for (size_t i = 0; i < 29; i++) { |
| 281 | } | 277 | ctx.r[i] = m_guest_ctx.cpu_registers[i]; |
| 282 | 278 | } | |
| 283 | u64 ARM_NCE::GetSP() const { | 279 | ctx.fp = m_guest_ctx.cpu_registers[29]; |
| 284 | return guest_ctx.sp; | 280 | ctx.lr = m_guest_ctx.cpu_registers[30]; |
| 285 | } | 281 | ctx.sp = m_guest_ctx.sp; |
| 286 | 282 | ctx.pc = m_guest_ctx.pc; | |
| 287 | u64 ARM_NCE::GetReg(int index) const { | 283 | ctx.pstate = m_guest_ctx.pstate; |
| 288 | return guest_ctx.cpu_registers[index]; | 284 | ctx.v = m_guest_ctx.vector_registers; |
| 289 | } | 285 | ctx.fpcr = m_guest_ctx.fpcr; |
| 290 | 286 | ctx.fpsr = m_guest_ctx.fpsr; | |
| 291 | void ARM_NCE::SetReg(int index, u64 value) { | 287 | ctx.tpidr = m_guest_ctx.tpidr_el0; |
| 292 | guest_ctx.cpu_registers[index] = value; | ||
| 293 | } | ||
| 294 | |||
| 295 | u128 ARM_NCE::GetVectorReg(int index) const { | ||
| 296 | return guest_ctx.vector_registers[index]; | ||
| 297 | } | ||
| 298 | |||
| 299 | void ARM_NCE::SetVectorReg(int index, u128 value) { | ||
| 300 | guest_ctx.vector_registers[index] = value; | ||
| 301 | } | ||
| 302 | |||
| 303 | u32 ARM_NCE::GetPSTATE() const { | ||
| 304 | return guest_ctx.pstate; | ||
| 305 | } | ||
| 306 | |||
| 307 | void ARM_NCE::SetPSTATE(u32 pstate) { | ||
| 308 | guest_ctx.pstate = pstate; | ||
| 309 | } | ||
| 310 | |||
| 311 | u64 ARM_NCE::GetTlsAddress() const { | ||
| 312 | return guest_ctx.tpidrro_el0; | ||
| 313 | } | ||
| 314 | |||
| 315 | void ARM_NCE::SetTlsAddress(u64 address) { | ||
| 316 | guest_ctx.tpidrro_el0 = address; | ||
| 317 | } | ||
| 318 | |||
| 319 | u64 ARM_NCE::GetTPIDR_EL0() const { | ||
| 320 | return guest_ctx.tpidr_el0; | ||
| 321 | } | ||
| 322 | |||
| 323 | void ARM_NCE::SetTPIDR_EL0(u64 value) { | ||
| 324 | guest_ctx.tpidr_el0 = value; | ||
| 325 | } | ||
| 326 | |||
| 327 | void ARM_NCE::SaveContext(ThreadContext64& ctx) const { | ||
| 328 | ctx.cpu_registers = guest_ctx.cpu_registers; | ||
| 329 | ctx.sp = guest_ctx.sp; | ||
| 330 | ctx.pc = guest_ctx.pc; | ||
| 331 | ctx.pstate = guest_ctx.pstate; | ||
| 332 | ctx.vector_registers = guest_ctx.vector_registers; | ||
| 333 | ctx.fpcr = guest_ctx.fpcr; | ||
| 334 | ctx.fpsr = guest_ctx.fpsr; | ||
| 335 | ctx.tpidr = guest_ctx.tpidr_el0; | ||
| 336 | } | 288 | } |
| 337 | 289 | ||
| 338 | void ARM_NCE::LoadContext(const ThreadContext64& ctx) { | 290 | void ArmNce::SetContext(const Kernel::Svc::ThreadContext& ctx) { |
| 339 | guest_ctx.cpu_registers = ctx.cpu_registers; | 291 | for (size_t i = 0; i < 29; i++) { |
| 340 | guest_ctx.sp = ctx.sp; | 292 | m_guest_ctx.cpu_registers[i] = ctx.r[i]; |
| 341 | guest_ctx.pc = ctx.pc; | 293 | } |
| 342 | guest_ctx.pstate = ctx.pstate; | 294 | m_guest_ctx.cpu_registers[29] = ctx.fp; |
| 343 | guest_ctx.vector_registers = ctx.vector_registers; | 295 | m_guest_ctx.cpu_registers[30] = ctx.lr; |
| 344 | guest_ctx.fpcr = ctx.fpcr; | 296 | m_guest_ctx.sp = ctx.sp; |
| 345 | guest_ctx.fpsr = ctx.fpsr; | 297 | m_guest_ctx.pc = ctx.pc; |
| 346 | guest_ctx.tpidr_el0 = ctx.tpidr; | 298 | m_guest_ctx.pstate = ctx.pstate; |
| 299 | m_guest_ctx.vector_registers = ctx.v; | ||
| 300 | m_guest_ctx.fpcr = ctx.fpcr; | ||
| 301 | m_guest_ctx.fpsr = ctx.fpsr; | ||
| 302 | m_guest_ctx.tpidr_el0 = ctx.tpidr; | ||
| 347 | } | 303 | } |
| 348 | 304 | ||
| 349 | void ARM_NCE::SignalInterrupt() { | 305 | void ArmNce::SignalInterrupt(Kernel::KThread* thread) { |
| 350 | // Lock core context. | ||
| 351 | std::scoped_lock lk{lock}; | ||
| 352 | |||
| 353 | // Add break loop condition. | 306 | // Add break loop condition. |
| 354 | guest_ctx.esr_el1.fetch_or(static_cast<u64>(HaltReason::BreakLoop)); | 307 | m_guest_ctx.esr_el1.fetch_or(static_cast<u64>(HaltReason::BreakLoop)); |
| 355 | |||
| 356 | // If there is no thread running, we are done. | ||
| 357 | if (running_thread == nullptr) { | ||
| 358 | return; | ||
| 359 | } | ||
| 360 | 308 | ||
| 361 | // Lock the thread context. | 309 | // Lock the thread context. |
| 362 | auto* params = &running_thread->GetNativeExecutionParameters(); | 310 | auto* params = &thread->GetNativeExecutionParameters(); |
| 363 | LockThreadParameters(params); | 311 | LockThreadParameters(params); |
| 364 | 312 | ||
| 365 | if (params->is_running) { | 313 | if (params->is_running) { |
| 366 | // We should signal to the running thread. | 314 | // We should signal to the running thread. |
| 367 | // The running thread will unlock the thread context. | 315 | // The running thread will unlock the thread context. |
| 368 | syscall(SYS_tkill, thread_id, BreakFromRunCodeSignal); | 316 | syscall(SYS_tkill, m_thread_id, BreakFromRunCodeSignal); |
| 369 | } else { | 317 | } else { |
| 370 | // If the thread is no longer running, we have nothing to do. | 318 | // If the thread is no longer running, we have nothing to do. |
| 371 | UnlockThreadParameters(params); | 319 | UnlockThreadParameters(params); |
| 372 | } | 320 | } |
| 373 | } | 321 | } |
| 374 | 322 | ||
| 375 | void ARM_NCE::ClearInterrupt() { | 323 | void ArmNce::ClearInstructionCache() { |
| 376 | guest_ctx.esr_el1 = {}; | ||
| 377 | } | ||
| 378 | |||
| 379 | void ARM_NCE::ClearInstructionCache() { | ||
| 380 | // TODO: This is not possible to implement correctly on Linux because | 324 | // TODO: This is not possible to implement correctly on Linux because |
| 381 | // we do not have any access to ic iallu. | 325 | // we do not have any access to ic iallu. |
| 382 | 326 | ||
| @@ -384,17 +328,8 @@ void ARM_NCE::ClearInstructionCache() { | |||
| 384 | std::atomic_thread_fence(std::memory_order_seq_cst); | 328 | std::atomic_thread_fence(std::memory_order_seq_cst); |
| 385 | } | 329 | } |
| 386 | 330 | ||
| 387 | void ARM_NCE::InvalidateCacheRange(u64 addr, std::size_t size) { | 331 | void ArmNce::InvalidateCacheRange(u64 addr, std::size_t size) { |
| 388 | this->ClearInstructionCache(); | 332 | this->ClearInstructionCache(); |
| 389 | } | 333 | } |
| 390 | 334 | ||
| 391 | void ARM_NCE::ClearExclusiveState() { | ||
| 392 | // No-op. | ||
| 393 | } | ||
| 394 | |||
| 395 | void ARM_NCE::PageTableChanged(Common::PageTable& page_table, | ||
| 396 | std::size_t new_address_space_size_in_bits) { | ||
| 397 | // No-op. Page table is never used. | ||
| 398 | } | ||
| 399 | |||
| 400 | } // namespace Core | 335 | } // namespace Core |
diff --git a/src/core/arm/nce/arm_nce.h b/src/core/arm/nce/arm_nce.h index 5fbd6dbf3..f55c10d1d 100644 --- a/src/core/arm/nce/arm_nce.h +++ b/src/core/arm/nce/arm_nce.h | |||
| @@ -3,11 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <atomic> | 6 | #include <mutex> |
| 7 | #include <memory> | ||
| 8 | #include <span> | ||
| 9 | #include <unordered_map> | ||
| 10 | #include <vector> | ||
| 11 | 7 | ||
| 12 | #include "core/arm/arm_interface.h" | 8 | #include "core/arm/arm_interface.h" |
| 13 | #include "core/arm/nce/guest_context.h" | 9 | #include "core/arm/nce/guest_context.h" |
| @@ -20,51 +16,36 @@ namespace Core { | |||
| 20 | 16 | ||
| 21 | class System; | 17 | class System; |
| 22 | 18 | ||
| 23 | class ARM_NCE final : public ARM_Interface { | 19 | class ArmNce final : public ArmInterface { |
| 24 | public: | 20 | public: |
| 25 | ARM_NCE(System& system_, bool uses_wall_clock_, std::size_t core_index_); | 21 | ArmNce(System& system, bool uses_wall_clock, std::size_t core_index); |
| 26 | 22 | ~ArmNce() override; | |
| 27 | ~ARM_NCE() override; | ||
| 28 | 23 | ||
| 29 | void Initialize() override; | 24 | void Initialize() override; |
| 30 | void SetPC(u64 pc) override; | ||
| 31 | u64 GetPC() const override; | ||
| 32 | u64 GetSP() const override; | ||
| 33 | u64 GetReg(int index) const override; | ||
| 34 | void SetReg(int index, u64 value) override; | ||
| 35 | u128 GetVectorReg(int index) const override; | ||
| 36 | void SetVectorReg(int index, u128 value) override; | ||
| 37 | |||
| 38 | u32 GetPSTATE() const override; | ||
| 39 | void SetPSTATE(u32 pstate) override; | ||
| 40 | u64 GetTlsAddress() const override; | ||
| 41 | void SetTlsAddress(u64 address) override; | ||
| 42 | void SetTPIDR_EL0(u64 value) override; | ||
| 43 | u64 GetTPIDR_EL0() const override; | ||
| 44 | 25 | ||
| 45 | Architecture GetArchitecture() const override { | 26 | Architecture GetArchitecture() const override { |
| 46 | return Architecture::Aarch64; | 27 | return Architecture::AArch64; |
| 47 | } | 28 | } |
| 48 | 29 | ||
| 49 | void SaveContext(ThreadContext32& ctx) const override {} | 30 | HaltReason RunThread(Kernel::KThread* thread) override; |
| 50 | void SaveContext(ThreadContext64& ctx) const override; | 31 | HaltReason StepThread(Kernel::KThread* thread) override; |
| 51 | void LoadContext(const ThreadContext32& ctx) override {} | 32 | |
| 52 | void LoadContext(const ThreadContext64& ctx) override; | 33 | void GetContext(Kernel::Svc::ThreadContext& ctx) const override; |
| 34 | void SetContext(const Kernel::Svc::ThreadContext& ctx) override; | ||
| 35 | void SetTpidrroEl0(u64 value) override; | ||
| 53 | 36 | ||
| 54 | void SignalInterrupt() override; | 37 | void GetSvcArguments(std::span<uint64_t, 8> args) const override; |
| 55 | void ClearInterrupt() override; | 38 | void SetSvcArguments(std::span<const uint64_t, 8> args) override; |
| 56 | void ClearExclusiveState() override; | 39 | u32 GetSvcNumber() const override; |
| 40 | |||
| 41 | void SignalInterrupt(Kernel::KThread* thread) override; | ||
| 57 | void ClearInstructionCache() override; | 42 | void ClearInstructionCache() override; |
| 58 | void InvalidateCacheRange(u64 addr, std::size_t size) override; | 43 | void InvalidateCacheRange(u64 addr, std::size_t size) override; |
| 59 | void PageTableChanged(Common::PageTable& new_page_table, | ||
| 60 | std::size_t new_address_space_size_in_bits) override; | ||
| 61 | |||
| 62 | protected: | ||
| 63 | HaltReason RunJit() override; | ||
| 64 | HaltReason StepJit() override; | ||
| 65 | 44 | ||
| 66 | u32 GetSvcNumber() const override; | 45 | void LockThread(Kernel::KThread* thread) override; |
| 46 | void UnlockThread(Kernel::KThread* thread) override; | ||
| 67 | 47 | ||
| 48 | protected: | ||
| 68 | const Kernel::DebugWatchpoint* HaltedWatchpoint() const override { | 49 | const Kernel::DebugWatchpoint* HaltedWatchpoint() const override { |
| 69 | return nullptr; | 50 | return nullptr; |
| 70 | } | 51 | } |
| @@ -93,16 +74,15 @@ private: | |||
| 93 | static void HandleHostFault(int sig, void* info, void* raw_context); | 74 | static void HandleHostFault(int sig, void* info, void* raw_context); |
| 94 | 75 | ||
| 95 | public: | 76 | public: |
| 77 | Core::System& m_system; | ||
| 78 | |||
| 96 | // Members set on initialization. | 79 | // Members set on initialization. |
| 97 | std::size_t core_index{}; | 80 | std::size_t m_core_index{}; |
| 98 | pid_t thread_id{-1}; | 81 | pid_t m_thread_id{-1}; |
| 99 | 82 | ||
| 100 | // Core context. | 83 | // Core context. |
| 101 | GuestContext guest_ctx; | 84 | GuestContext m_guest_ctx{}; |
| 102 | 85 | Kernel::KThread* m_running_thread{}; | |
| 103 | // Thread and invalidation info. | ||
| 104 | std::mutex lock; | ||
| 105 | Kernel::KThread* running_thread{}; | ||
| 106 | }; | 86 | }; |
| 107 | 87 | ||
| 108 | } // namespace Core | 88 | } // namespace Core |
diff --git a/src/core/arm/nce/arm_nce.s b/src/core/arm/nce/arm_nce.s index b98e09f31..4aeda4740 100644 --- a/src/core/arm/nce/arm_nce.s +++ b/src/core/arm/nce/arm_nce.s | |||
| @@ -8,11 +8,11 @@ | |||
| 8 | movk reg, #(((val) >> 0x10) & 0xFFFF), lsl #16 | 8 | movk reg, #(((val) >> 0x10) & 0xFFFF), lsl #16 |
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | /* static HaltReason Core::ARM_NCE::ReturnToRunCodeByTrampoline(void* tpidr, Core::GuestContext* ctx, u64 trampoline_addr) */ | 11 | /* static HaltReason Core::ArmNce::ReturnToRunCodeByTrampoline(void* tpidr, Core::GuestContext* ctx, u64 trampoline_addr) */ |
| 12 | .section .text._ZN4Core7ARM_NCE27ReturnToRunCodeByTrampolineEPvPNS_12GuestContextEm, "ax", %progbits | 12 | .section .text._ZN4Core6ArmNce27ReturnToRunCodeByTrampolineEPvPNS_12GuestContextEm, "ax", %progbits |
| 13 | .global _ZN4Core7ARM_NCE27ReturnToRunCodeByTrampolineEPvPNS_12GuestContextEm | 13 | .global _ZN4Core6ArmNce27ReturnToRunCodeByTrampolineEPvPNS_12GuestContextEm |
| 14 | .type _ZN4Core7ARM_NCE27ReturnToRunCodeByTrampolineEPvPNS_12GuestContextEm, %function | 14 | .type _ZN4Core6ArmNce27ReturnToRunCodeByTrampolineEPvPNS_12GuestContextEm, %function |
| 15 | _ZN4Core7ARM_NCE27ReturnToRunCodeByTrampolineEPvPNS_12GuestContextEm: | 15 | _ZN4Core6ArmNce27ReturnToRunCodeByTrampolineEPvPNS_12GuestContextEm: |
| 16 | /* Back up host sp to x3. */ | 16 | /* Back up host sp to x3. */ |
| 17 | /* Back up host tpidr_el0 to x4. */ | 17 | /* Back up host tpidr_el0 to x4. */ |
| 18 | mov x3, sp | 18 | mov x3, sp |
| @@ -49,11 +49,11 @@ _ZN4Core7ARM_NCE27ReturnToRunCodeByTrampolineEPvPNS_12GuestContextEm: | |||
| 49 | br x2 | 49 | br x2 |
| 50 | 50 | ||
| 51 | 51 | ||
| 52 | /* static HaltReason Core::ARM_NCE::ReturnToRunCodeByExceptionLevelChange(int tid, void* tpidr) */ | 52 | /* static HaltReason Core::ArmNce::ReturnToRunCodeByExceptionLevelChange(int tid, void* tpidr) */ |
| 53 | .section .text._ZN4Core7ARM_NCE37ReturnToRunCodeByExceptionLevelChangeEiPv, "ax", %progbits | 53 | .section .text._ZN4Core6ArmNce37ReturnToRunCodeByExceptionLevelChangeEiPv, "ax", %progbits |
| 54 | .global _ZN4Core7ARM_NCE37ReturnToRunCodeByExceptionLevelChangeEiPv | 54 | .global _ZN4Core6ArmNce37ReturnToRunCodeByExceptionLevelChangeEiPv |
| 55 | .type _ZN4Core7ARM_NCE37ReturnToRunCodeByExceptionLevelChangeEiPv, %function | 55 | .type _ZN4Core6ArmNce37ReturnToRunCodeByExceptionLevelChangeEiPv, %function |
| 56 | _ZN4Core7ARM_NCE37ReturnToRunCodeByExceptionLevelChangeEiPv: | 56 | _ZN4Core6ArmNce37ReturnToRunCodeByExceptionLevelChangeEiPv: |
| 57 | /* This jumps to the signal handler, which will restore the entire context. */ | 57 | /* This jumps to the signal handler, which will restore the entire context. */ |
| 58 | /* On entry, x0 = thread id, which is already in the right place. */ | 58 | /* On entry, x0 = thread id, which is already in the right place. */ |
| 59 | 59 | ||
| @@ -71,17 +71,17 @@ _ZN4Core7ARM_NCE37ReturnToRunCodeByExceptionLevelChangeEiPv: | |||
| 71 | brk #1000 | 71 | brk #1000 |
| 72 | 72 | ||
| 73 | 73 | ||
| 74 | /* static void Core::ARM_NCE::ReturnToRunCodeByExceptionLevelChangeSignalHandler(int sig, void* info, void* raw_context) */ | 74 | /* static void Core::ArmNce::ReturnToRunCodeByExceptionLevelChangeSignalHandler(int sig, void* info, void* raw_context) */ |
| 75 | .section .text._ZN4Core7ARM_NCE50ReturnToRunCodeByExceptionLevelChangeSignalHandlerEiPvS1_, "ax", %progbits | 75 | .section .text._ZN4Core6ArmNce50ReturnToRunCodeByExceptionLevelChangeSignalHandlerEiPvS1_, "ax", %progbits |
| 76 | .global _ZN4Core7ARM_NCE50ReturnToRunCodeByExceptionLevelChangeSignalHandlerEiPvS1_ | 76 | .global _ZN4Core6ArmNce50ReturnToRunCodeByExceptionLevelChangeSignalHandlerEiPvS1_ |
| 77 | .type _ZN4Core7ARM_NCE50ReturnToRunCodeByExceptionLevelChangeSignalHandlerEiPvS1_, %function | 77 | .type _ZN4Core6ArmNce50ReturnToRunCodeByExceptionLevelChangeSignalHandlerEiPvS1_, %function |
| 78 | _ZN4Core7ARM_NCE50ReturnToRunCodeByExceptionLevelChangeSignalHandlerEiPvS1_: | 78 | _ZN4Core6ArmNce50ReturnToRunCodeByExceptionLevelChangeSignalHandlerEiPvS1_: |
| 79 | stp x29, x30, [sp, #-0x10]! | 79 | stp x29, x30, [sp, #-0x10]! |
| 80 | mov x29, sp | 80 | mov x29, sp |
| 81 | 81 | ||
| 82 | /* Call the context restorer with the raw context. */ | 82 | /* Call the context restorer with the raw context. */ |
| 83 | mov x0, x2 | 83 | mov x0, x2 |
| 84 | bl _ZN4Core7ARM_NCE19RestoreGuestContextEPv | 84 | bl _ZN4Core6ArmNce19RestoreGuestContextEPv |
| 85 | 85 | ||
| 86 | /* Save the old value of tpidr_el0. */ | 86 | /* Save the old value of tpidr_el0. */ |
| 87 | mrs x8, tpidr_el0 | 87 | mrs x8, tpidr_el0 |
| @@ -92,18 +92,18 @@ _ZN4Core7ARM_NCE50ReturnToRunCodeByExceptionLevelChangeSignalHandlerEiPvS1_: | |||
| 92 | msr tpidr_el0, x0 | 92 | msr tpidr_el0, x0 |
| 93 | 93 | ||
| 94 | /* Unlock the context. */ | 94 | /* Unlock the context. */ |
| 95 | bl _ZN4Core7ARM_NCE22UnlockThreadParametersEPv | 95 | bl _ZN4Core6ArmNce22UnlockThreadParametersEPv |
| 96 | 96 | ||
| 97 | /* Returning from here will enter the guest. */ | 97 | /* Returning from here will enter the guest. */ |
| 98 | ldp x29, x30, [sp], #0x10 | 98 | ldp x29, x30, [sp], #0x10 |
| 99 | ret | 99 | ret |
| 100 | 100 | ||
| 101 | 101 | ||
| 102 | /* static void Core::ARM_NCE::BreakFromRunCodeSignalHandler(int sig, void* info, void* raw_context) */ | 102 | /* static void Core::ArmNce::BreakFromRunCodeSignalHandler(int sig, void* info, void* raw_context) */ |
| 103 | .section .text._ZN4Core7ARM_NCE29BreakFromRunCodeSignalHandlerEiPvS1_, "ax", %progbits | 103 | .section .text._ZN4Core6ArmNce29BreakFromRunCodeSignalHandlerEiPvS1_, "ax", %progbits |
| 104 | .global _ZN4Core7ARM_NCE29BreakFromRunCodeSignalHandlerEiPvS1_ | 104 | .global _ZN4Core6ArmNce29BreakFromRunCodeSignalHandlerEiPvS1_ |
| 105 | .type _ZN4Core7ARM_NCE29BreakFromRunCodeSignalHandlerEiPvS1_, %function | 105 | .type _ZN4Core6ArmNce29BreakFromRunCodeSignalHandlerEiPvS1_, %function |
| 106 | _ZN4Core7ARM_NCE29BreakFromRunCodeSignalHandlerEiPvS1_: | 106 | _ZN4Core6ArmNce29BreakFromRunCodeSignalHandlerEiPvS1_: |
| 107 | /* Check to see if we have the correct TLS magic. */ | 107 | /* Check to see if we have the correct TLS magic. */ |
| 108 | mrs x8, tpidr_el0 | 108 | mrs x8, tpidr_el0 |
| 109 | ldr w9, [x8, #(TpidrEl0TlsMagic)] | 109 | ldr w9, [x8, #(TpidrEl0TlsMagic)] |
| @@ -121,7 +121,7 @@ _ZN4Core7ARM_NCE29BreakFromRunCodeSignalHandlerEiPvS1_: | |||
| 121 | 121 | ||
| 122 | /* Tail call the restorer. */ | 122 | /* Tail call the restorer. */ |
| 123 | mov x1, x2 | 123 | mov x1, x2 |
| 124 | b _ZN4Core7ARM_NCE16SaveGuestContextEPNS_12GuestContextEPv | 124 | b _ZN4Core6ArmNce16SaveGuestContextEPNS_12GuestContextEPv |
| 125 | 125 | ||
| 126 | /* Returning from here will enter host code. */ | 126 | /* Returning from here will enter host code. */ |
| 127 | 127 | ||
| @@ -130,11 +130,11 @@ _ZN4Core7ARM_NCE29BreakFromRunCodeSignalHandlerEiPvS1_: | |||
| 130 | ret | 130 | ret |
| 131 | 131 | ||
| 132 | 132 | ||
| 133 | /* static void Core::ARM_NCE::GuestFaultSignalHandler(int sig, void* info, void* raw_context) */ | 133 | /* static void Core::ArmNce::GuestFaultSignalHandler(int sig, void* info, void* raw_context) */ |
| 134 | .section .text._ZN4Core7ARM_NCE23GuestFaultSignalHandlerEiPvS1_, "ax", %progbits | 134 | .section .text._ZN4Core6ArmNce23GuestFaultSignalHandlerEiPvS1_, "ax", %progbits |
| 135 | .global _ZN4Core7ARM_NCE23GuestFaultSignalHandlerEiPvS1_ | 135 | .global _ZN4Core6ArmNce23GuestFaultSignalHandlerEiPvS1_ |
| 136 | .type _ZN4Core7ARM_NCE23GuestFaultSignalHandlerEiPvS1_, %function | 136 | .type _ZN4Core6ArmNce23GuestFaultSignalHandlerEiPvS1_, %function |
| 137 | _ZN4Core7ARM_NCE23GuestFaultSignalHandlerEiPvS1_: | 137 | _ZN4Core6ArmNce23GuestFaultSignalHandlerEiPvS1_: |
| 138 | /* Check to see if we have the correct TLS magic. */ | 138 | /* Check to see if we have the correct TLS magic. */ |
| 139 | mrs x8, tpidr_el0 | 139 | mrs x8, tpidr_el0 |
| 140 | ldr w9, [x8, #(TpidrEl0TlsMagic)] | 140 | ldr w9, [x8, #(TpidrEl0TlsMagic)] |
| @@ -146,7 +146,7 @@ _ZN4Core7ARM_NCE23GuestFaultSignalHandlerEiPvS1_: | |||
| 146 | 146 | ||
| 147 | /* Incorrect TLS magic, so this is a host fault. */ | 147 | /* Incorrect TLS magic, so this is a host fault. */ |
| 148 | /* Tail call the handler. */ | 148 | /* Tail call the handler. */ |
| 149 | b _ZN4Core7ARM_NCE15HandleHostFaultEiPvS1_ | 149 | b _ZN4Core6ArmNce15HandleHostFaultEiPvS1_ |
| 150 | 150 | ||
| 151 | 1: | 151 | 1: |
| 152 | /* Correct TLS magic, so this is a guest fault. */ | 152 | /* Correct TLS magic, so this is a guest fault. */ |
| @@ -163,7 +163,7 @@ _ZN4Core7ARM_NCE23GuestFaultSignalHandlerEiPvS1_: | |||
| 163 | msr tpidr_el0, x3 | 163 | msr tpidr_el0, x3 |
| 164 | 164 | ||
| 165 | /* Call the handler. */ | 165 | /* Call the handler. */ |
| 166 | bl _ZN4Core7ARM_NCE16HandleGuestFaultEPNS_12GuestContextEPvS3_ | 166 | bl _ZN4Core6ArmNce16HandleGuestFaultEPNS_12GuestContextEPvS3_ |
| 167 | 167 | ||
| 168 | /* If the handler returned false, we want to preserve the host tpidr_el0. */ | 168 | /* If the handler returned false, we want to preserve the host tpidr_el0. */ |
| 169 | cbz x0, 2f | 169 | cbz x0, 2f |
| @@ -177,11 +177,11 @@ _ZN4Core7ARM_NCE23GuestFaultSignalHandlerEiPvS1_: | |||
| 177 | ret | 177 | ret |
| 178 | 178 | ||
| 179 | 179 | ||
| 180 | /* static void Core::ARM_NCE::LockThreadParameters(void* tpidr) */ | 180 | /* static void Core::ArmNce::LockThreadParameters(void* tpidr) */ |
| 181 | .section .text._ZN4Core7ARM_NCE20LockThreadParametersEPv, "ax", %progbits | 181 | .section .text._ZN4Core6ArmNce20LockThreadParametersEPv, "ax", %progbits |
| 182 | .global _ZN4Core7ARM_NCE20LockThreadParametersEPv | 182 | .global _ZN4Core6ArmNce20LockThreadParametersEPv |
| 183 | .type _ZN4Core7ARM_NCE20LockThreadParametersEPv, %function | 183 | .type _ZN4Core6ArmNce20LockThreadParametersEPv, %function |
| 184 | _ZN4Core7ARM_NCE20LockThreadParametersEPv: | 184 | _ZN4Core6ArmNce20LockThreadParametersEPv: |
| 185 | /* Offset to lock member. */ | 185 | /* Offset to lock member. */ |
| 186 | add x0, x0, #(TpidrEl0Lock) | 186 | add x0, x0, #(TpidrEl0Lock) |
| 187 | 187 | ||
| @@ -205,11 +205,11 @@ _ZN4Core7ARM_NCE20LockThreadParametersEPv: | |||
| 205 | ret | 205 | ret |
| 206 | 206 | ||
| 207 | 207 | ||
| 208 | /* static void Core::ARM_NCE::UnlockThreadParameters(void* tpidr) */ | 208 | /* static void Core::ArmNce::UnlockThreadParameters(void* tpidr) */ |
| 209 | .section .text._ZN4Core7ARM_NCE22UnlockThreadParametersEPv, "ax", %progbits | 209 | .section .text._ZN4Core6ArmNce22UnlockThreadParametersEPv, "ax", %progbits |
| 210 | .global _ZN4Core7ARM_NCE22UnlockThreadParametersEPv | 210 | .global _ZN4Core6ArmNce22UnlockThreadParametersEPv |
| 211 | .type _ZN4Core7ARM_NCE22UnlockThreadParametersEPv, %function | 211 | .type _ZN4Core6ArmNce22UnlockThreadParametersEPv, %function |
| 212 | _ZN4Core7ARM_NCE22UnlockThreadParametersEPv: | 212 | _ZN4Core6ArmNce22UnlockThreadParametersEPv: |
| 213 | /* Offset to lock member. */ | 213 | /* Offset to lock member. */ |
| 214 | add x0, x0, #(TpidrEl0Lock) | 214 | add x0, x0, #(TpidrEl0Lock) |
| 215 | 215 | ||
diff --git a/src/core/arm/nce/guest_context.h b/src/core/arm/nce/guest_context.h index 0767a0337..a7eadccce 100644 --- a/src/core/arm/nce/guest_context.h +++ b/src/core/arm/nce/guest_context.h | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <atomic> | ||
| 7 | |||
| 6 | #include "common/common_funcs.h" | 8 | #include "common/common_funcs.h" |
| 7 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 8 | #include "core/arm/arm_interface.h" | 10 | #include "core/arm/arm_interface.h" |
| @@ -10,7 +12,7 @@ | |||
| 10 | 12 | ||
| 11 | namespace Core { | 13 | namespace Core { |
| 12 | 14 | ||
| 13 | class ARM_NCE; | 15 | class ArmNce; |
| 14 | class System; | 16 | class System; |
| 15 | 17 | ||
| 16 | struct HostContext { | 18 | struct HostContext { |
| @@ -33,9 +35,9 @@ struct GuestContext { | |||
| 33 | u64 tpidr_el0{}; | 35 | u64 tpidr_el0{}; |
| 34 | std::atomic<u64> esr_el1{}; | 36 | std::atomic<u64> esr_el1{}; |
| 35 | u32 nzcv{}; | 37 | u32 nzcv{}; |
| 36 | u32 svc_swi{}; | 38 | u32 svc{}; |
| 37 | System* system{}; | 39 | System* system{}; |
| 38 | ARM_NCE* parent{}; | 40 | ArmNce* parent{}; |
| 39 | }; | 41 | }; |
| 40 | 42 | ||
| 41 | // Verify assembly offsets. | 43 | // Verify assembly offsets. |
diff --git a/src/core/arm/nce/patcher.cpp b/src/core/arm/nce/patcher.cpp index bdaa3af49..47a7a8880 100644 --- a/src/core/arm/nce/patcher.cpp +++ b/src/core/arm/nce/patcher.cpp | |||
| @@ -280,7 +280,7 @@ void Patcher::WriteSvcTrampoline(ModuleDestLabel module_dest, u32 svc_id) { | |||
| 280 | 280 | ||
| 281 | // Store SVC number to execute when we return | 281 | // Store SVC number to execute when we return |
| 282 | c.MOV(X2, svc_id); | 282 | c.MOV(X2, svc_id); |
| 283 | c.STR(W2, X1, offsetof(GuestContext, svc_swi)); | 283 | c.STR(W2, X1, offsetof(GuestContext, svc)); |
| 284 | 284 | ||
| 285 | // We are calling a SVC. Clear esr_el1 and return it. | 285 | // We are calling a SVC. Clear esr_el1 and return it. |
| 286 | static_assert(std::is_same_v<std::underlying_type_t<HaltReason>, u64>); | 286 | static_assert(std::is_same_v<std::underlying_type_t<HaltReason>, u64>); |
diff --git a/src/core/core.cpp b/src/core/core.cpp index 14d6c8c27..229cb879c 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -323,7 +323,6 @@ struct System::Impl { | |||
| 323 | static_cast<u32>(SystemResultStatus::ErrorLoader) + static_cast<u32>(load_result)); | 323 | static_cast<u32>(SystemResultStatus::ErrorLoader) + static_cast<u32>(load_result)); |
| 324 | } | 324 | } |
| 325 | AddGlueRegistrationForProcess(*app_loader, *main_process); | 325 | AddGlueRegistrationForProcess(*app_loader, *main_process); |
| 326 | kernel.InitializeCores(); | ||
| 327 | 326 | ||
| 328 | // Initialize cheat engine | 327 | // Initialize cheat engine |
| 329 | if (cheat_engine) { | 328 | if (cheat_engine) { |
| @@ -600,14 +599,6 @@ bool System::IsPaused() const { | |||
| 600 | return impl->IsPaused(); | 599 | return impl->IsPaused(); |
| 601 | } | 600 | } |
| 602 | 601 | ||
| 603 | void System::InvalidateCpuInstructionCaches() { | ||
| 604 | impl->kernel.InvalidateAllInstructionCaches(); | ||
| 605 | } | ||
| 606 | |||
| 607 | void System::InvalidateCpuInstructionCacheRange(u64 addr, std::size_t size) { | ||
| 608 | impl->kernel.InvalidateCpuInstructionCacheRange(addr, size); | ||
| 609 | } | ||
| 610 | |||
| 611 | void System::ShutdownMainProcess() { | 602 | void System::ShutdownMainProcess() { |
| 612 | impl->ShutdownMainProcess(); | 603 | impl->ShutdownMainProcess(); |
| 613 | } | 604 | } |
| @@ -696,14 +687,6 @@ const TelemetrySession& System::TelemetrySession() const { | |||
| 696 | return *impl->telemetry_session; | 687 | return *impl->telemetry_session; |
| 697 | } | 688 | } |
| 698 | 689 | ||
| 699 | ARM_Interface& System::CurrentArmInterface() { | ||
| 700 | return impl->kernel.CurrentPhysicalCore().ArmInterface(); | ||
| 701 | } | ||
| 702 | |||
| 703 | const ARM_Interface& System::CurrentArmInterface() const { | ||
| 704 | return impl->kernel.CurrentPhysicalCore().ArmInterface(); | ||
| 705 | } | ||
| 706 | |||
| 707 | Kernel::PhysicalCore& System::CurrentPhysicalCore() { | 690 | Kernel::PhysicalCore& System::CurrentPhysicalCore() { |
| 708 | return impl->kernel.CurrentPhysicalCore(); | 691 | return impl->kernel.CurrentPhysicalCore(); |
| 709 | } | 692 | } |
| @@ -738,14 +721,6 @@ const Kernel::KProcess* System::ApplicationProcess() const { | |||
| 738 | return impl->kernel.ApplicationProcess(); | 721 | return impl->kernel.ApplicationProcess(); |
| 739 | } | 722 | } |
| 740 | 723 | ||
| 741 | ARM_Interface& System::ArmInterface(std::size_t core_index) { | ||
| 742 | return impl->kernel.PhysicalCore(core_index).ArmInterface(); | ||
| 743 | } | ||
| 744 | |||
| 745 | const ARM_Interface& System::ArmInterface(std::size_t core_index) const { | ||
| 746 | return impl->kernel.PhysicalCore(core_index).ArmInterface(); | ||
| 747 | } | ||
| 748 | |||
| 749 | ExclusiveMonitor& System::Monitor() { | 724 | ExclusiveMonitor& System::Monitor() { |
| 750 | return impl->kernel.GetExclusiveMonitor(); | 725 | return impl->kernel.GetExclusiveMonitor(); |
| 751 | } | 726 | } |
diff --git a/src/core/core.h b/src/core/core.h index df20f26f3..05a222f5c 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -108,7 +108,6 @@ class RenderdocAPI; | |||
| 108 | 108 | ||
| 109 | namespace Core { | 109 | namespace Core { |
| 110 | 110 | ||
| 111 | class ARM_Interface; | ||
| 112 | class CpuManager; | 111 | class CpuManager; |
| 113 | class Debugger; | 112 | class Debugger; |
| 114 | class DeviceMemory; | 113 | class DeviceMemory; |
| @@ -171,15 +170,6 @@ public: | |||
| 171 | /// Check if the core is currently paused. | 170 | /// Check if the core is currently paused. |
| 172 | [[nodiscard]] bool IsPaused() const; | 171 | [[nodiscard]] bool IsPaused() const; |
| 173 | 172 | ||
| 174 | /** | ||
| 175 | * Invalidate the CPU instruction caches | ||
| 176 | * This function should only be used by GDB Stub to support breakpoints, memory updates and | ||
| 177 | * step/continue commands. | ||
| 178 | */ | ||
| 179 | void InvalidateCpuInstructionCaches(); | ||
| 180 | |||
| 181 | void InvalidateCpuInstructionCacheRange(u64 addr, std::size_t size); | ||
| 182 | |||
| 183 | /// Shutdown the main emulated process. | 173 | /// Shutdown the main emulated process. |
| 184 | void ShutdownMainProcess(); | 174 | void ShutdownMainProcess(); |
| 185 | 175 | ||
| @@ -244,24 +234,12 @@ public: | |||
| 244 | /// Gets and resets core performance statistics | 234 | /// Gets and resets core performance statistics |
| 245 | [[nodiscard]] PerfStatsResults GetAndResetPerfStats(); | 235 | [[nodiscard]] PerfStatsResults GetAndResetPerfStats(); |
| 246 | 236 | ||
| 247 | /// Gets an ARM interface to the CPU core that is currently running | ||
| 248 | [[nodiscard]] ARM_Interface& CurrentArmInterface(); | ||
| 249 | |||
| 250 | /// Gets an ARM interface to the CPU core that is currently running | ||
| 251 | [[nodiscard]] const ARM_Interface& CurrentArmInterface() const; | ||
| 252 | |||
| 253 | /// Gets the physical core for the CPU core that is currently running | 237 | /// Gets the physical core for the CPU core that is currently running |
| 254 | [[nodiscard]] Kernel::PhysicalCore& CurrentPhysicalCore(); | 238 | [[nodiscard]] Kernel::PhysicalCore& CurrentPhysicalCore(); |
| 255 | 239 | ||
| 256 | /// Gets the physical core for the CPU core that is currently running | 240 | /// Gets the physical core for the CPU core that is currently running |
| 257 | [[nodiscard]] const Kernel::PhysicalCore& CurrentPhysicalCore() const; | 241 | [[nodiscard]] const Kernel::PhysicalCore& CurrentPhysicalCore() const; |
| 258 | 242 | ||
| 259 | /// Gets a reference to an ARM interface for the CPU core with the specified index | ||
| 260 | [[nodiscard]] ARM_Interface& ArmInterface(std::size_t core_index); | ||
| 261 | |||
| 262 | /// Gets a const reference to an ARM interface from the CPU core with the specified index | ||
| 263 | [[nodiscard]] const ARM_Interface& ArmInterface(std::size_t core_index) const; | ||
| 264 | |||
| 265 | /// Gets a reference to the underlying CPU manager. | 243 | /// Gets a reference to the underlying CPU manager. |
| 266 | [[nodiscard]] CpuManager& GetCpuManager(); | 244 | [[nodiscard]] CpuManager& GetCpuManager(); |
| 267 | 245 | ||
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index 151eb3870..7a5c22f78 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp | |||
| @@ -73,12 +73,13 @@ void CpuManager::HandleInterrupt() { | |||
| 73 | void CpuManager::MultiCoreRunGuestThread() { | 73 | void CpuManager::MultiCoreRunGuestThread() { |
| 74 | // Similar to UserModeThreadStarter in HOS | 74 | // Similar to UserModeThreadStarter in HOS |
| 75 | auto& kernel = system.Kernel(); | 75 | auto& kernel = system.Kernel(); |
| 76 | auto* thread = Kernel::GetCurrentThreadPointer(kernel); | ||
| 76 | kernel.CurrentScheduler()->OnThreadStart(); | 77 | kernel.CurrentScheduler()->OnThreadStart(); |
| 77 | 78 | ||
| 78 | while (true) { | 79 | while (true) { |
| 79 | auto* physical_core = &kernel.CurrentPhysicalCore(); | 80 | auto* physical_core = &kernel.CurrentPhysicalCore(); |
| 80 | while (!physical_core->IsInterrupted()) { | 81 | while (!physical_core->IsInterrupted()) { |
| 81 | physical_core->Run(); | 82 | physical_core->RunThread(thread); |
| 82 | physical_core = &kernel.CurrentPhysicalCore(); | 83 | physical_core = &kernel.CurrentPhysicalCore(); |
| 83 | } | 84 | } |
| 84 | 85 | ||
| @@ -110,12 +111,13 @@ void CpuManager::MultiCoreRunIdleThread() { | |||
| 110 | 111 | ||
| 111 | void CpuManager::SingleCoreRunGuestThread() { | 112 | void CpuManager::SingleCoreRunGuestThread() { |
| 112 | auto& kernel = system.Kernel(); | 113 | auto& kernel = system.Kernel(); |
| 114 | auto* thread = Kernel::GetCurrentThreadPointer(kernel); | ||
| 113 | kernel.CurrentScheduler()->OnThreadStart(); | 115 | kernel.CurrentScheduler()->OnThreadStart(); |
| 114 | 116 | ||
| 115 | while (true) { | 117 | while (true) { |
| 116 | auto* physical_core = &kernel.CurrentPhysicalCore(); | 118 | auto* physical_core = &kernel.CurrentPhysicalCore(); |
| 117 | if (!physical_core->IsInterrupted()) { | 119 | if (!physical_core->IsInterrupted()) { |
| 118 | physical_core->Run(); | 120 | physical_core->RunThread(thread); |
| 119 | physical_core = &kernel.CurrentPhysicalCore(); | 121 | physical_core = &kernel.CurrentPhysicalCore(); |
| 120 | } | 122 | } |
| 121 | 123 | ||
| @@ -211,8 +213,6 @@ void CpuManager::RunThread(std::stop_token token, std::size_t core) { | |||
| 211 | system.GPU().ObtainContext(); | 213 | system.GPU().ObtainContext(); |
| 212 | } | 214 | } |
| 213 | 215 | ||
| 214 | system.ArmInterface(core).Initialize(); | ||
| 215 | |||
| 216 | auto& kernel = system.Kernel(); | 216 | auto& kernel = system.Kernel(); |
| 217 | auto& scheduler = *kernel.CurrentScheduler(); | 217 | auto& scheduler = *kernel.CurrentScheduler(); |
| 218 | auto* thread = scheduler.GetSchedulerCurrentThread(); | 218 | auto* thread = scheduler.GetSchedulerCurrentThread(); |
diff --git a/src/core/debugger/gdbstub.cpp b/src/core/debugger/gdbstub.cpp index 148dd3e39..66e46c4ba 100644 --- a/src/core/debugger/gdbstub.cpp +++ b/src/core/debugger/gdbstub.cpp | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include "common/settings.h" | 16 | #include "common/settings.h" |
| 17 | #include "common/string_util.h" | 17 | #include "common/string_util.h" |
| 18 | #include "core/arm/arm_interface.h" | 18 | #include "core/arm/arm_interface.h" |
| 19 | #include "core/arm/debug.h" | ||
| 19 | #include "core/core.h" | 20 | #include "core/core.h" |
| 20 | #include "core/debugger/gdbstub.h" | 21 | #include "core/debugger/gdbstub.h" |
| 21 | #include "core/debugger/gdbstub_arch.h" | 22 | #include "core/debugger/gdbstub_arch.h" |
| @@ -310,7 +311,7 @@ void GDBStub::ExecuteCommand(std::string_view packet, std::vector<DebuggerAction | |||
| 310 | const auto mem{Common::HexStringToVector(mem_substr, false)}; | 311 | const auto mem{Common::HexStringToVector(mem_substr, false)}; |
| 311 | 312 | ||
| 312 | if (system.ApplicationMemory().WriteBlock(addr, mem.data(), size)) { | 313 | if (system.ApplicationMemory().WriteBlock(addr, mem.data(), size)) { |
| 313 | system.InvalidateCpuInstructionCacheRange(addr, size); | 314 | Core::InvalidateInstructionCacheRange(system.ApplicationProcess(), addr, size); |
| 314 | SendReply(GDB_STUB_REPLY_OK); | 315 | SendReply(GDB_STUB_REPLY_OK); |
| 315 | } else { | 316 | } else { |
| 316 | SendReply(GDB_STUB_REPLY_ERR); | 317 | SendReply(GDB_STUB_REPLY_ERR); |
| @@ -363,7 +364,7 @@ void GDBStub::HandleBreakpointInsert(std::string_view command) { | |||
| 363 | case BreakpointType::Software: | 364 | case BreakpointType::Software: |
| 364 | replaced_instructions[addr] = system.ApplicationMemory().Read32(addr); | 365 | replaced_instructions[addr] = system.ApplicationMemory().Read32(addr); |
| 365 | system.ApplicationMemory().Write32(addr, arch->BreakpointInstruction()); | 366 | system.ApplicationMemory().Write32(addr, arch->BreakpointInstruction()); |
| 366 | system.InvalidateCpuInstructionCacheRange(addr, sizeof(u32)); | 367 | Core::InvalidateInstructionCacheRange(system.ApplicationProcess(), addr, sizeof(u32)); |
| 367 | success = true; | 368 | success = true; |
| 368 | break; | 369 | break; |
| 369 | case BreakpointType::WriteWatch: | 370 | case BreakpointType::WriteWatch: |
| @@ -411,7 +412,7 @@ void GDBStub::HandleBreakpointRemove(std::string_view command) { | |||
| 411 | const auto orig_insn{replaced_instructions.find(addr)}; | 412 | const auto orig_insn{replaced_instructions.find(addr)}; |
| 412 | if (orig_insn != replaced_instructions.end()) { | 413 | if (orig_insn != replaced_instructions.end()) { |
| 413 | system.ApplicationMemory().Write32(addr, orig_insn->second); | 414 | system.ApplicationMemory().Write32(addr, orig_insn->second); |
| 414 | system.InvalidateCpuInstructionCacheRange(addr, sizeof(u32)); | 415 | Core::InvalidateInstructionCacheRange(system.ApplicationProcess(), addr, sizeof(u32)); |
| 415 | replaced_instructions.erase(addr); | 416 | replaced_instructions.erase(addr); |
| 416 | success = true; | 417 | success = true; |
| 417 | } | 418 | } |
| @@ -442,114 +443,6 @@ void GDBStub::HandleBreakpointRemove(std::string_view command) { | |||
| 442 | } | 443 | } |
| 443 | } | 444 | } |
| 444 | 445 | ||
| 445 | // Structure offsets are from Atmosphere | ||
| 446 | // See osdbg_thread_local_region.os.horizon.hpp and osdbg_thread_type.os.horizon.hpp | ||
| 447 | |||
| 448 | static std::optional<std::string> GetNameFromThreadType32(Core::Memory::Memory& memory, | ||
| 449 | const Kernel::KThread& thread) { | ||
| 450 | // Read thread type from TLS | ||
| 451 | const VAddr tls_thread_type{memory.Read32(thread.GetTlsAddress() + 0x1fc)}; | ||
| 452 | const VAddr argument_thread_type{thread.GetArgument()}; | ||
| 453 | |||
| 454 | if (argument_thread_type && tls_thread_type != argument_thread_type) { | ||
| 455 | // Probably not created by nnsdk, no name available. | ||
| 456 | return std::nullopt; | ||
| 457 | } | ||
| 458 | |||
| 459 | if (!tls_thread_type) { | ||
| 460 | return std::nullopt; | ||
| 461 | } | ||
| 462 | |||
| 463 | const u16 version{memory.Read16(tls_thread_type + 0x26)}; | ||
| 464 | VAddr name_pointer{}; | ||
| 465 | if (version == 1) { | ||
| 466 | name_pointer = memory.Read32(tls_thread_type + 0xe4); | ||
| 467 | } else { | ||
| 468 | name_pointer = memory.Read32(tls_thread_type + 0xe8); | ||
| 469 | } | ||
| 470 | |||
| 471 | if (!name_pointer) { | ||
| 472 | // No name provided. | ||
| 473 | return std::nullopt; | ||
| 474 | } | ||
| 475 | |||
| 476 | return memory.ReadCString(name_pointer, 256); | ||
| 477 | } | ||
| 478 | |||
| 479 | static std::optional<std::string> GetNameFromThreadType64(Core::Memory::Memory& memory, | ||
| 480 | const Kernel::KThread& thread) { | ||
| 481 | // Read thread type from TLS | ||
| 482 | const VAddr tls_thread_type{memory.Read64(thread.GetTlsAddress() + 0x1f8)}; | ||
| 483 | const VAddr argument_thread_type{thread.GetArgument()}; | ||
| 484 | |||
| 485 | if (argument_thread_type && tls_thread_type != argument_thread_type) { | ||
| 486 | // Probably not created by nnsdk, no name available. | ||
| 487 | return std::nullopt; | ||
| 488 | } | ||
| 489 | |||
| 490 | if (!tls_thread_type) { | ||
| 491 | return std::nullopt; | ||
| 492 | } | ||
| 493 | |||
| 494 | const u16 version{memory.Read16(tls_thread_type + 0x46)}; | ||
| 495 | VAddr name_pointer{}; | ||
| 496 | if (version == 1) { | ||
| 497 | name_pointer = memory.Read64(tls_thread_type + 0x1a0); | ||
| 498 | } else { | ||
| 499 | name_pointer = memory.Read64(tls_thread_type + 0x1a8); | ||
| 500 | } | ||
| 501 | |||
| 502 | if (!name_pointer) { | ||
| 503 | // No name provided. | ||
| 504 | return std::nullopt; | ||
| 505 | } | ||
| 506 | |||
| 507 | return memory.ReadCString(name_pointer, 256); | ||
| 508 | } | ||
| 509 | |||
| 510 | static std::optional<std::string> GetThreadName(Core::System& system, | ||
| 511 | const Kernel::KThread& thread) { | ||
| 512 | if (system.ApplicationProcess()->Is64Bit()) { | ||
| 513 | return GetNameFromThreadType64(system.ApplicationMemory(), thread); | ||
| 514 | } else { | ||
| 515 | return GetNameFromThreadType32(system.ApplicationMemory(), thread); | ||
| 516 | } | ||
| 517 | } | ||
| 518 | |||
| 519 | static std::string_view GetThreadWaitReason(const Kernel::KThread& thread) { | ||
| 520 | switch (thread.GetWaitReasonForDebugging()) { | ||
| 521 | case Kernel::ThreadWaitReasonForDebugging::Sleep: | ||
| 522 | return "Sleep"; | ||
| 523 | case Kernel::ThreadWaitReasonForDebugging::IPC: | ||
| 524 | return "IPC"; | ||
| 525 | case Kernel::ThreadWaitReasonForDebugging::Synchronization: | ||
| 526 | return "Synchronization"; | ||
| 527 | case Kernel::ThreadWaitReasonForDebugging::ConditionVar: | ||
| 528 | return "ConditionVar"; | ||
| 529 | case Kernel::ThreadWaitReasonForDebugging::Arbitration: | ||
| 530 | return "Arbitration"; | ||
| 531 | case Kernel::ThreadWaitReasonForDebugging::Suspended: | ||
| 532 | return "Suspended"; | ||
| 533 | default: | ||
| 534 | return "Unknown"; | ||
| 535 | } | ||
| 536 | } | ||
| 537 | |||
| 538 | static std::string GetThreadState(const Kernel::KThread& thread) { | ||
| 539 | switch (thread.GetState()) { | ||
| 540 | case Kernel::ThreadState::Initialized: | ||
| 541 | return "Initialized"; | ||
| 542 | case Kernel::ThreadState::Waiting: | ||
| 543 | return fmt::format("Waiting ({})", GetThreadWaitReason(thread)); | ||
| 544 | case Kernel::ThreadState::Runnable: | ||
| 545 | return "Runnable"; | ||
| 546 | case Kernel::ThreadState::Terminated: | ||
| 547 | return "Terminated"; | ||
| 548 | default: | ||
| 549 | return "Unknown"; | ||
| 550 | } | ||
| 551 | } | ||
| 552 | |||
| 553 | static std::string PaginateBuffer(std::string_view buffer, std::string_view request) { | 446 | static std::string PaginateBuffer(std::string_view buffer, std::string_view request) { |
| 554 | const auto amount{request.substr(request.find(',') + 1)}; | 447 | const auto amount{request.substr(request.find(',') + 1)}; |
| 555 | const auto offset_val{static_cast<u64>(strtoll(request.data(), nullptr, 16))}; | 448 | const auto offset_val{static_cast<u64>(strtoll(request.data(), nullptr, 16))}; |
| @@ -562,120 +455,6 @@ static std::string PaginateBuffer(std::string_view buffer, std::string_view requ | |||
| 562 | } | 455 | } |
| 563 | } | 456 | } |
| 564 | 457 | ||
| 565 | static VAddr GetModuleEnd(Kernel::KProcessPageTable& page_table, VAddr base) { | ||
| 566 | Kernel::KMemoryInfo mem_info; | ||
| 567 | Kernel::Svc::MemoryInfo svc_mem_info; | ||
| 568 | Kernel::Svc::PageInfo page_info; | ||
| 569 | VAddr cur_addr{base}; | ||
| 570 | |||
| 571 | // Expect: r-x Code (.text) | ||
| 572 | R_ASSERT(page_table.QueryInfo(std::addressof(mem_info), std::addressof(page_info), cur_addr)); | ||
| 573 | svc_mem_info = mem_info.GetSvcMemoryInfo(); | ||
| 574 | cur_addr = svc_mem_info.base_address + svc_mem_info.size; | ||
| 575 | if (svc_mem_info.state != Kernel::Svc::MemoryState::Code || | ||
| 576 | svc_mem_info.permission != Kernel::Svc::MemoryPermission::ReadExecute) { | ||
| 577 | return cur_addr - 1; | ||
| 578 | } | ||
| 579 | |||
| 580 | // Expect: r-- Code (.rodata) | ||
| 581 | R_ASSERT(page_table.QueryInfo(std::addressof(mem_info), std::addressof(page_info), cur_addr)); | ||
| 582 | svc_mem_info = mem_info.GetSvcMemoryInfo(); | ||
| 583 | cur_addr = svc_mem_info.base_address + svc_mem_info.size; | ||
| 584 | if (svc_mem_info.state != Kernel::Svc::MemoryState::Code || | ||
| 585 | svc_mem_info.permission != Kernel::Svc::MemoryPermission::Read) { | ||
| 586 | return cur_addr - 1; | ||
| 587 | } | ||
| 588 | |||
| 589 | // Expect: rw- CodeData (.data) | ||
| 590 | R_ASSERT(page_table.QueryInfo(std::addressof(mem_info), std::addressof(page_info), cur_addr)); | ||
| 591 | svc_mem_info = mem_info.GetSvcMemoryInfo(); | ||
| 592 | cur_addr = svc_mem_info.base_address + svc_mem_info.size; | ||
| 593 | return cur_addr - 1; | ||
| 594 | } | ||
| 595 | |||
| 596 | static Loader::AppLoader::Modules FindModules(Core::System& system) { | ||
| 597 | Loader::AppLoader::Modules modules; | ||
| 598 | |||
| 599 | auto& page_table = system.ApplicationProcess()->GetPageTable(); | ||
| 600 | auto& memory = system.ApplicationMemory(); | ||
| 601 | VAddr cur_addr = 0; | ||
| 602 | |||
| 603 | // Look for executable sections in Code or AliasCode regions. | ||
| 604 | while (true) { | ||
| 605 | Kernel::KMemoryInfo mem_info{}; | ||
| 606 | Kernel::Svc::PageInfo page_info{}; | ||
| 607 | R_ASSERT( | ||
| 608 | page_table.QueryInfo(std::addressof(mem_info), std::addressof(page_info), cur_addr)); | ||
| 609 | auto svc_mem_info = mem_info.GetSvcMemoryInfo(); | ||
| 610 | |||
| 611 | if (svc_mem_info.permission == Kernel::Svc::MemoryPermission::ReadExecute && | ||
| 612 | (svc_mem_info.state == Kernel::Svc::MemoryState::Code || | ||
| 613 | svc_mem_info.state == Kernel::Svc::MemoryState::AliasCode)) { | ||
| 614 | // Try to read the module name from its path. | ||
| 615 | constexpr s32 PathLengthMax = 0x200; | ||
| 616 | struct { | ||
| 617 | u32 zero; | ||
| 618 | s32 path_length; | ||
| 619 | std::array<char, PathLengthMax> path; | ||
| 620 | } module_path; | ||
| 621 | |||
| 622 | if (memory.ReadBlock(svc_mem_info.base_address + svc_mem_info.size, &module_path, | ||
| 623 | sizeof(module_path))) { | ||
| 624 | if (module_path.zero == 0 && module_path.path_length > 0) { | ||
| 625 | // Truncate module name. | ||
| 626 | module_path.path[PathLengthMax - 1] = '\0'; | ||
| 627 | |||
| 628 | // Ignore leading directories. | ||
| 629 | char* path_pointer = module_path.path.data(); | ||
| 630 | |||
| 631 | for (s32 i = 0; i < std::min(PathLengthMax, module_path.path_length) && | ||
| 632 | module_path.path[i] != '\0'; | ||
| 633 | i++) { | ||
| 634 | if (module_path.path[i] == '/' || module_path.path[i] == '\\') { | ||
| 635 | path_pointer = module_path.path.data() + i + 1; | ||
| 636 | } | ||
| 637 | } | ||
| 638 | |||
| 639 | // Insert output. | ||
| 640 | modules.emplace(svc_mem_info.base_address, path_pointer); | ||
| 641 | } | ||
| 642 | } | ||
| 643 | } | ||
| 644 | |||
| 645 | // Check if we're done. | ||
| 646 | const uintptr_t next_address = svc_mem_info.base_address + svc_mem_info.size; | ||
| 647 | if (next_address <= cur_addr) { | ||
| 648 | break; | ||
| 649 | } | ||
| 650 | |||
| 651 | cur_addr = next_address; | ||
| 652 | } | ||
| 653 | |||
| 654 | return modules; | ||
| 655 | } | ||
| 656 | |||
| 657 | static VAddr FindMainModuleEntrypoint(Core::System& system) { | ||
| 658 | Loader::AppLoader::Modules modules; | ||
| 659 | system.GetAppLoader().ReadNSOModules(modules); | ||
| 660 | |||
| 661 | // Do we have a module named main? | ||
| 662 | const auto main = std::find_if(modules.begin(), modules.end(), | ||
| 663 | [](const auto& key) { return key.second == "main"; }); | ||
| 664 | |||
| 665 | if (main != modules.end()) { | ||
| 666 | return main->first; | ||
| 667 | } | ||
| 668 | |||
| 669 | // Do we have any loaded executable sections? | ||
| 670 | modules = FindModules(system); | ||
| 671 | if (!modules.empty()) { | ||
| 672 | return modules.begin()->first; | ||
| 673 | } | ||
| 674 | |||
| 675 | // As a last resort, use the start of the code region. | ||
| 676 | return GetInteger(system.ApplicationProcess()->GetPageTable().GetCodeRegionStart()); | ||
| 677 | } | ||
| 678 | |||
| 679 | void GDBStub::HandleQuery(std::string_view command) { | 458 | void GDBStub::HandleQuery(std::string_view command) { |
| 680 | if (command.starts_with("TStatus")) { | 459 | if (command.starts_with("TStatus")) { |
| 681 | // no tracepoint support | 460 | // no tracepoint support |
| @@ -687,10 +466,10 @@ void GDBStub::HandleQuery(std::string_view command) { | |||
| 687 | const auto target_xml{arch->GetTargetXML()}; | 466 | const auto target_xml{arch->GetTargetXML()}; |
| 688 | SendReply(PaginateBuffer(target_xml, command.substr(30))); | 467 | SendReply(PaginateBuffer(target_xml, command.substr(30))); |
| 689 | } else if (command.starts_with("Offsets")) { | 468 | } else if (command.starts_with("Offsets")) { |
| 690 | const auto main_offset = FindMainModuleEntrypoint(system); | 469 | const auto main_offset = Core::FindMainModuleEntrypoint(system.ApplicationProcess()); |
| 691 | SendReply(fmt::format("TextSeg={:x}", main_offset)); | 470 | SendReply(fmt::format("TextSeg={:x}", GetInteger(main_offset))); |
| 692 | } else if (command.starts_with("Xfer:libraries:read::")) { | 471 | } else if (command.starts_with("Xfer:libraries:read::")) { |
| 693 | auto modules = FindModules(system); | 472 | auto modules = Core::FindModules(system.ApplicationProcess()); |
| 694 | 473 | ||
| 695 | std::string buffer; | 474 | std::string buffer; |
| 696 | buffer += R"(<?xml version="1.0"?>)"; | 475 | buffer += R"(<?xml version="1.0"?>)"; |
| @@ -720,14 +499,14 @@ void GDBStub::HandleQuery(std::string_view command) { | |||
| 720 | 499 | ||
| 721 | const auto& threads = system.ApplicationProcess()->GetThreadList(); | 500 | const auto& threads = system.ApplicationProcess()->GetThreadList(); |
| 722 | for (const auto& thread : threads) { | 501 | for (const auto& thread : threads) { |
| 723 | auto thread_name{GetThreadName(system, thread)}; | 502 | auto thread_name{Core::GetThreadName(&thread)}; |
| 724 | if (!thread_name) { | 503 | if (!thread_name) { |
| 725 | thread_name = fmt::format("Thread {:d}", thread.GetThreadId()); | 504 | thread_name = fmt::format("Thread {:d}", thread.GetThreadId()); |
| 726 | } | 505 | } |
| 727 | 506 | ||
| 728 | buffer += fmt::format(R"(<thread id="{:x}" core="{:d}" name="{}">{}</thread>)", | 507 | buffer += fmt::format(R"(<thread id="{:x}" core="{:d}" name="{}">{}</thread>)", |
| 729 | thread.GetThreadId(), thread.GetActiveCore(), | 508 | thread.GetThreadId(), thread.GetActiveCore(), |
| 730 | EscapeXML(*thread_name), GetThreadState(thread)); | 509 | EscapeXML(*thread_name), GetThreadState(&thread)); |
| 731 | } | 510 | } |
| 732 | 511 | ||
| 733 | buffer += "</threads>"; | 512 | buffer += "</threads>"; |
| @@ -856,7 +635,7 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) { | |||
| 856 | reply = "Fastmem is not enabled.\n"; | 635 | reply = "Fastmem is not enabled.\n"; |
| 857 | } | 636 | } |
| 858 | } else if (command_str == "get info") { | 637 | } else if (command_str == "get info") { |
| 859 | auto modules = FindModules(system); | 638 | auto modules = Core::FindModules(process); |
| 860 | 639 | ||
| 861 | reply = fmt::format("Process: {:#x} ({})\n" | 640 | reply = fmt::format("Process: {:#x} ({})\n" |
| 862 | "Program Id: {:#018x}\n", | 641 | "Program Id: {:#018x}\n", |
| @@ -880,7 +659,7 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) { | |||
| 880 | 659 | ||
| 881 | for (const auto& [vaddr, name] : modules) { | 660 | for (const auto& [vaddr, name] : modules) { |
| 882 | reply += fmt::format(" {:#012x} - {:#012x} {}\n", vaddr, | 661 | reply += fmt::format(" {:#012x} - {:#012x} {}\n", vaddr, |
| 883 | GetModuleEnd(page_table, vaddr), name); | 662 | GetInteger(Core::GetModuleEnd(process, vaddr)), name); |
| 884 | } | 663 | } |
| 885 | } else if (command_str == "get mappings") { | 664 | } else if (command_str == "get mappings") { |
| 886 | reply = "Mappings:\n"; | 665 | reply = "Mappings:\n"; |
diff --git a/src/core/debugger/gdbstub_arch.cpp b/src/core/debugger/gdbstub_arch.cpp index 75c94a91a..f2a407dc8 100644 --- a/src/core/debugger/gdbstub_arch.cpp +++ b/src/core/debugger/gdbstub_arch.cpp | |||
| @@ -24,21 +24,6 @@ static std::string ValueToHex(const T value) { | |||
| 24 | return Common::HexToString(mem); | 24 | return Common::HexToString(mem); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | template <typename T> | ||
| 28 | static T GetSIMDRegister(const std::array<u32, 64>& simd_regs, size_t offset) { | ||
| 29 | static_assert(std::is_trivially_copyable_v<T>); | ||
| 30 | T value{}; | ||
| 31 | std::memcpy(&value, reinterpret_cast<const u8*>(simd_regs.data()) + sizeof(T) * offset, | ||
| 32 | sizeof(T)); | ||
| 33 | return value; | ||
| 34 | } | ||
| 35 | |||
| 36 | template <typename T> | ||
| 37 | static void PutSIMDRegister(std::array<u32, 64>& simd_regs, size_t offset, const T value) { | ||
| 38 | static_assert(std::is_trivially_copyable_v<T>); | ||
| 39 | std::memcpy(reinterpret_cast<u8*>(simd_regs.data()) + sizeof(T) * offset, &value, sizeof(T)); | ||
| 40 | } | ||
| 41 | |||
| 42 | // For sample XML files see the GDB source /gdb/features | 27 | // For sample XML files see the GDB source /gdb/features |
| 43 | // This XML defines what the registers are for this specific ARM device | 28 | // This XML defines what the registers are for this specific ARM device |
| 44 | std::string_view GDBStubA64::GetTargetXML() const { | 29 | std::string_view GDBStubA64::GetTargetXML() const { |
| @@ -184,12 +169,16 @@ std::string GDBStubA64::RegRead(const Kernel::KThread* thread, size_t id) const | |||
| 184 | return ""; | 169 | return ""; |
| 185 | } | 170 | } |
| 186 | 171 | ||
| 187 | const auto& context{thread->GetContext64()}; | 172 | const auto& context{thread->GetContext()}; |
| 188 | const auto& gprs{context.cpu_registers}; | 173 | const auto& gprs{context.r}; |
| 189 | const auto& fprs{context.vector_registers}; | 174 | const auto& fprs{context.v}; |
| 190 | 175 | ||
| 191 | if (id < SP_REGISTER) { | 176 | if (id < FP_REGISTER) { |
| 192 | return ValueToHex(gprs[id]); | 177 | return ValueToHex(gprs[id]); |
| 178 | } else if (id == FP_REGISTER) { | ||
| 179 | return ValueToHex(context.fp); | ||
| 180 | } else if (id == LR_REGISTER) { | ||
| 181 | return ValueToHex(context.lr); | ||
| 193 | } else if (id == SP_REGISTER) { | 182 | } else if (id == SP_REGISTER) { |
| 194 | return ValueToHex(context.sp); | 183 | return ValueToHex(context.sp); |
| 195 | } else if (id == PC_REGISTER) { | 184 | } else if (id == PC_REGISTER) { |
| @@ -212,10 +201,14 @@ void GDBStubA64::RegWrite(Kernel::KThread* thread, size_t id, std::string_view v | |||
| 212 | return; | 201 | return; |
| 213 | } | 202 | } |
| 214 | 203 | ||
| 215 | auto& context{thread->GetContext64()}; | 204 | auto& context{thread->GetContext()}; |
| 216 | 205 | ||
| 217 | if (id < SP_REGISTER) { | 206 | if (id < FP_REGISTER) { |
| 218 | context.cpu_registers[id] = HexToValue<u64>(value); | 207 | context.r[id] = HexToValue<u64>(value); |
| 208 | } else if (id == FP_REGISTER) { | ||
| 209 | context.fp = HexToValue<u64>(value); | ||
| 210 | } else if (id == LR_REGISTER) { | ||
| 211 | context.lr = HexToValue<u64>(value); | ||
| 219 | } else if (id == SP_REGISTER) { | 212 | } else if (id == SP_REGISTER) { |
| 220 | context.sp = HexToValue<u64>(value); | 213 | context.sp = HexToValue<u64>(value); |
| 221 | } else if (id == PC_REGISTER) { | 214 | } else if (id == PC_REGISTER) { |
| @@ -223,7 +216,7 @@ void GDBStubA64::RegWrite(Kernel::KThread* thread, size_t id, std::string_view v | |||
| 223 | } else if (id == PSTATE_REGISTER) { | 216 | } else if (id == PSTATE_REGISTER) { |
| 224 | context.pstate = HexToValue<u32>(value); | 217 | context.pstate = HexToValue<u32>(value); |
| 225 | } else if (id >= Q0_REGISTER && id < FPSR_REGISTER) { | 218 | } else if (id >= Q0_REGISTER && id < FPSR_REGISTER) { |
| 226 | context.vector_registers[id - Q0_REGISTER] = HexToValue<u128>(value); | 219 | context.v[id - Q0_REGISTER] = HexToValue<u128>(value); |
| 227 | } else if (id == FPSR_REGISTER) { | 220 | } else if (id == FPSR_REGISTER) { |
| 228 | context.fpsr = HexToValue<u32>(value); | 221 | context.fpsr = HexToValue<u32>(value); |
| 229 | } else if (id == FPCR_REGISTER) { | 222 | } else if (id == FPCR_REGISTER) { |
| @@ -381,22 +374,20 @@ std::string GDBStubA32::RegRead(const Kernel::KThread* thread, size_t id) const | |||
| 381 | return ""; | 374 | return ""; |
| 382 | } | 375 | } |
| 383 | 376 | ||
| 384 | const auto& context{thread->GetContext32()}; | 377 | const auto& context{thread->GetContext()}; |
| 385 | const auto& gprs{context.cpu_registers}; | 378 | const auto& gprs{context.r}; |
| 386 | const auto& fprs{context.extension_registers}; | 379 | const auto& fprs{context.v}; |
| 387 | 380 | ||
| 388 | if (id <= PC_REGISTER) { | 381 | if (id <= PC_REGISTER) { |
| 389 | return ValueToHex(gprs[id]); | 382 | return ValueToHex(static_cast<u32>(gprs[id])); |
| 390 | } else if (id == CPSR_REGISTER) { | 383 | } else if (id == CPSR_REGISTER) { |
| 391 | return ValueToHex(context.cpsr); | 384 | return ValueToHex(context.pstate); |
| 392 | } else if (id >= D0_REGISTER && id < Q0_REGISTER) { | 385 | } else if (id >= D0_REGISTER && id < Q0_REGISTER) { |
| 393 | const u64 dN{GetSIMDRegister<u64>(fprs, id - D0_REGISTER)}; | 386 | return ValueToHex(fprs[id - D0_REGISTER][0]); |
| 394 | return ValueToHex(dN); | ||
| 395 | } else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) { | 387 | } else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) { |
| 396 | const u128 qN{GetSIMDRegister<u128>(fprs, id - Q0_REGISTER)}; | 388 | return ValueToHex(fprs[id - Q0_REGISTER]); |
| 397 | return ValueToHex(qN); | ||
| 398 | } else if (id == FPSCR_REGISTER) { | 389 | } else if (id == FPSCR_REGISTER) { |
| 399 | return ValueToHex(context.fpscr); | 390 | return ValueToHex(context.fpcr | context.fpsr); |
| 400 | } else { | 391 | } else { |
| 401 | return ""; | 392 | return ""; |
| 402 | } | 393 | } |
| @@ -407,19 +398,20 @@ void GDBStubA32::RegWrite(Kernel::KThread* thread, size_t id, std::string_view v | |||
| 407 | return; | 398 | return; |
| 408 | } | 399 | } |
| 409 | 400 | ||
| 410 | auto& context{thread->GetContext32()}; | 401 | auto& context{thread->GetContext()}; |
| 411 | auto& fprs{context.extension_registers}; | 402 | auto& fprs{context.v}; |
| 412 | 403 | ||
| 413 | if (id <= PC_REGISTER) { | 404 | if (id <= PC_REGISTER) { |
| 414 | context.cpu_registers[id] = HexToValue<u32>(value); | 405 | context.r[id] = HexToValue<u32>(value); |
| 415 | } else if (id == CPSR_REGISTER) { | 406 | } else if (id == CPSR_REGISTER) { |
| 416 | context.cpsr = HexToValue<u32>(value); | 407 | context.pstate = HexToValue<u32>(value); |
| 417 | } else if (id >= D0_REGISTER && id < Q0_REGISTER) { | 408 | } else if (id >= D0_REGISTER && id < Q0_REGISTER) { |
| 418 | PutSIMDRegister(fprs, id - D0_REGISTER, HexToValue<u64>(value)); | 409 | fprs[id - D0_REGISTER] = {HexToValue<u64>(value), 0}; |
| 419 | } else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) { | 410 | } else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) { |
| 420 | PutSIMDRegister(fprs, id - Q0_REGISTER, HexToValue<u128>(value)); | 411 | fprs[id - Q0_REGISTER] = HexToValue<u128>(value); |
| 421 | } else if (id == FPSCR_REGISTER) { | 412 | } else if (id == FPSCR_REGISTER) { |
| 422 | context.fpscr = HexToValue<u32>(value); | 413 | context.fpcr = HexToValue<u32>(value); |
| 414 | context.fpsr = HexToValue<u32>(value); | ||
| 423 | } | 415 | } |
| 424 | } | 416 | } |
| 425 | 417 | ||
diff --git a/src/core/debugger/gdbstub_arch.h b/src/core/debugger/gdbstub_arch.h index 34530c788..d53714d69 100644 --- a/src/core/debugger/gdbstub_arch.h +++ b/src/core/debugger/gdbstub_arch.h | |||
| @@ -36,6 +36,7 @@ public: | |||
| 36 | u32 BreakpointInstruction() const override; | 36 | u32 BreakpointInstruction() const override; |
| 37 | 37 | ||
| 38 | private: | 38 | private: |
| 39 | static constexpr u32 FP_REGISTER = 29; | ||
| 39 | static constexpr u32 LR_REGISTER = 30; | 40 | static constexpr u32 LR_REGISTER = 30; |
| 40 | static constexpr u32 SP_REGISTER = 31; | 41 | static constexpr u32 SP_REGISTER = 31; |
| 41 | static constexpr u32 PC_REGISTER = 32; | 42 | static constexpr u32 PC_REGISTER = 32; |
diff --git a/src/core/hle/kernel/k_page_table_base.cpp b/src/core/hle/kernel/k_page_table_base.cpp index 6691586ed..4c416d809 100644 --- a/src/core/hle/kernel/k_page_table_base.cpp +++ b/src/core/hle/kernel/k_page_table_base.cpp | |||
| @@ -69,8 +69,16 @@ public: | |||
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | template <typename AddressType> | 71 | template <typename AddressType> |
| 72 | void InvalidateInstructionCache(Core::System& system, AddressType addr, u64 size) { | 72 | void InvalidateInstructionCache(KernelCore& kernel, AddressType addr, u64 size) { |
| 73 | system.InvalidateCpuInstructionCacheRange(GetInteger(addr), size); | 73 | // TODO: lock the process list |
| 74 | for (auto& process : kernel.GetProcessList()) { | ||
| 75 | for (size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { | ||
| 76 | auto* interface = process->GetArmInterface(i); | ||
| 77 | if (interface) { | ||
| 78 | interface->InvalidateCacheRange(GetInteger(addr), size); | ||
| 79 | } | ||
| 80 | } | ||
| 81 | } | ||
| 74 | } | 82 | } |
| 75 | 83 | ||
| 76 | template <typename AddressType> | 84 | template <typename AddressType> |
| @@ -1261,7 +1269,7 @@ Result KPageTableBase::UnmapCodeMemory(KProcessAddress dst_address, KProcessAddr | |||
| 1261 | bool reprotected_pages = false; | 1269 | bool reprotected_pages = false; |
| 1262 | SCOPE_EXIT({ | 1270 | SCOPE_EXIT({ |
| 1263 | if (reprotected_pages && any_code_pages) { | 1271 | if (reprotected_pages && any_code_pages) { |
| 1264 | InvalidateInstructionCache(m_system, dst_address, size); | 1272 | InvalidateInstructionCache(m_kernel, dst_address, size); |
| 1265 | } | 1273 | } |
| 1266 | }); | 1274 | }); |
| 1267 | 1275 | ||
| @@ -1997,7 +2005,7 @@ Result KPageTableBase::SetProcessMemoryPermission(KProcessAddress addr, size_t s | |||
| 1997 | for (const auto& block : pg) { | 2005 | for (const auto& block : pg) { |
| 1998 | StoreDataCache(GetHeapVirtualPointer(m_kernel, block.GetAddress()), block.GetSize()); | 2006 | StoreDataCache(GetHeapVirtualPointer(m_kernel, block.GetAddress()), block.GetSize()); |
| 1999 | } | 2007 | } |
| 2000 | InvalidateInstructionCache(m_system, addr, size); | 2008 | InvalidateInstructionCache(m_kernel, addr, size); |
| 2001 | } | 2009 | } |
| 2002 | 2010 | ||
| 2003 | R_SUCCEED(); | 2011 | R_SUCCEED(); |
| @@ -3239,7 +3247,7 @@ Result KPageTableBase::WriteDebugMemory(KProcessAddress dst_address, KProcessAdd | |||
| 3239 | R_TRY(PerformCopy()); | 3247 | R_TRY(PerformCopy()); |
| 3240 | 3248 | ||
| 3241 | // Invalidate the instruction cache, as this svc allows modifying executable pages. | 3249 | // Invalidate the instruction cache, as this svc allows modifying executable pages. |
| 3242 | InvalidateInstructionCache(m_system, dst_address, size); | 3250 | InvalidateInstructionCache(m_kernel, dst_address, size); |
| 3243 | 3251 | ||
| 3244 | R_SUCCEED(); | 3252 | R_SUCCEED(); |
| 3245 | } | 3253 | } |
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index 6c29eb72c..3a2635e1f 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp | |||
| @@ -13,6 +13,12 @@ | |||
| 13 | #include "core/hle/kernel/k_thread_queue.h" | 13 | #include "core/hle/kernel/k_thread_queue.h" |
| 14 | #include "core/hle/kernel/k_worker_task_manager.h" | 14 | #include "core/hle/kernel/k_worker_task_manager.h" |
| 15 | 15 | ||
| 16 | #include "core/arm/dynarmic/arm_dynarmic_32.h" | ||
| 17 | #include "core/arm/dynarmic/arm_dynarmic_64.h" | ||
| 18 | #ifdef HAS_NCE | ||
| 19 | #include "core/arm/nce/arm_nce.h" | ||
| 20 | #endif | ||
| 21 | |||
| 16 | namespace Kernel { | 22 | namespace Kernel { |
| 17 | 23 | ||
| 18 | namespace { | 24 | namespace { |
| @@ -957,10 +963,8 @@ Result KProcess::Run(s32 priority, size_t stack_size) { | |||
| 957 | R_TRY(m_handle_table.Add(std::addressof(thread_handle), main_thread)); | 963 | R_TRY(m_handle_table.Add(std::addressof(thread_handle), main_thread)); |
| 958 | 964 | ||
| 959 | // Set the thread arguments. | 965 | // Set the thread arguments. |
| 960 | main_thread->GetContext32().cpu_registers[0] = 0; | 966 | main_thread->GetContext().r[0] = 0; |
| 961 | main_thread->GetContext64().cpu_registers[0] = 0; | 967 | main_thread->GetContext().r[1] = thread_handle; |
| 962 | main_thread->GetContext32().cpu_registers[1] = thread_handle; | ||
| 963 | main_thread->GetContext64().cpu_registers[1] = thread_handle; | ||
| 964 | 968 | ||
| 965 | // Update our state. | 969 | // Update our state. |
| 966 | this->ChangeState((state == State::Created) ? State::Running : State::RunningAttached); | 970 | this->ChangeState((state == State::Created) ? State::Running : State::RunningAttached); |
| @@ -1199,6 +1203,9 @@ Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std: | |||
| 1199 | m_is_hbl = is_hbl; | 1203 | m_is_hbl = is_hbl; |
| 1200 | m_ideal_core_id = metadata.GetMainThreadCore(); | 1204 | m_ideal_core_id = metadata.GetMainThreadCore(); |
| 1201 | 1205 | ||
| 1206 | // Set up emulation context. | ||
| 1207 | this->InitializeInterfaces(); | ||
| 1208 | |||
| 1202 | // We succeeded. | 1209 | // We succeeded. |
| 1203 | R_SUCCEED(); | 1210 | R_SUCCEED(); |
| 1204 | } | 1211 | } |
| @@ -1227,6 +1234,31 @@ void KProcess::LoadModule(CodeSet code_set, KProcessAddress base_addr) { | |||
| 1227 | #endif | 1234 | #endif |
| 1228 | } | 1235 | } |
| 1229 | 1236 | ||
| 1237 | void KProcess::InitializeInterfaces() { | ||
| 1238 | this->GetMemory().SetCurrentPageTable(*this); | ||
| 1239 | |||
| 1240 | #ifdef HAS_NCE | ||
| 1241 | if (this->Is64Bit() && Settings::IsNceEnabled()) { | ||
| 1242 | for (size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { | ||
| 1243 | m_arm_interfaces[i] = std::make_unique<Core::ArmNce>(m_kernel.System(), true, i); | ||
| 1244 | } | ||
| 1245 | } else | ||
| 1246 | #endif | ||
| 1247 | if (this->Is64Bit()) { | ||
| 1248 | for (size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { | ||
| 1249 | m_arm_interfaces[i] = std::make_unique<Core::ArmDynarmic64>( | ||
| 1250 | m_kernel.System(), m_kernel.IsMulticore(), this, | ||
| 1251 | static_cast<Core::DynarmicExclusiveMonitor&>(m_kernel.GetExclusiveMonitor()), i); | ||
| 1252 | } | ||
| 1253 | } else { | ||
| 1254 | for (size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { | ||
| 1255 | m_arm_interfaces[i] = std::make_unique<Core::ArmDynarmic32>( | ||
| 1256 | m_kernel.System(), m_kernel.IsMulticore(), this, | ||
| 1257 | static_cast<Core::DynarmicExclusiveMonitor&>(m_kernel.GetExclusiveMonitor()), i); | ||
| 1258 | } | ||
| 1259 | } | ||
| 1260 | } | ||
| 1261 | |||
| 1230 | bool KProcess::InsertWatchpoint(KProcessAddress addr, u64 size, DebugWatchpointType type) { | 1262 | bool KProcess::InsertWatchpoint(KProcessAddress addr, u64 size, DebugWatchpointType type) { |
| 1231 | const auto watch{std::find_if(m_watchpoints.begin(), m_watchpoints.end(), [&](const auto& wp) { | 1263 | const auto watch{std::find_if(m_watchpoints.begin(), m_watchpoints.end(), [&](const auto& wp) { |
| 1232 | return wp.type == DebugWatchpointType::None; | 1264 | return wp.type == DebugWatchpointType::None; |
diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h index d8cd0fdde..4b114e39b 100644 --- a/src/core/hle/kernel/k_process.h +++ b/src/core/hle/kernel/k_process.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include <map> | 6 | #include <map> |
| 7 | 7 | ||
| 8 | #include "core/arm/arm_interface.h" | ||
| 8 | #include "core/file_sys/program_metadata.h" | 9 | #include "core/file_sys/program_metadata.h" |
| 9 | #include "core/hle/kernel/code_set.h" | 10 | #include "core/hle/kernel/code_set.h" |
| 10 | #include "core/hle/kernel/k_address_arbiter.h" | 11 | #include "core/hle/kernel/k_address_arbiter.h" |
| @@ -106,6 +107,8 @@ private: | |||
| 106 | bool m_is_suspended{}; | 107 | bool m_is_suspended{}; |
| 107 | bool m_is_immortal{}; | 108 | bool m_is_immortal{}; |
| 108 | bool m_is_handle_table_initialized{}; | 109 | bool m_is_handle_table_initialized{}; |
| 110 | std::array<std::unique_ptr<Core::ArmInterface>, Core::Hardware::NUM_CPU_CORES> | ||
| 111 | m_arm_interfaces{}; | ||
| 109 | std::array<KThread*, Core::Hardware::NUM_CPU_CORES> m_running_threads{}; | 112 | std::array<KThread*, Core::Hardware::NUM_CPU_CORES> m_running_threads{}; |
| 110 | std::array<u64, Core::Hardware::NUM_CPU_CORES> m_running_thread_idle_counts{}; | 113 | std::array<u64, Core::Hardware::NUM_CPU_CORES> m_running_thread_idle_counts{}; |
| 111 | std::array<u64, Core::Hardware::NUM_CPU_CORES> m_running_thread_switch_counts{}; | 114 | std::array<u64, Core::Hardware::NUM_CPU_CORES> m_running_thread_switch_counts{}; |
| @@ -476,6 +479,10 @@ public: | |||
| 476 | } | 479 | } |
| 477 | #endif | 480 | #endif |
| 478 | 481 | ||
| 482 | Core::ArmInterface* GetArmInterface(size_t core_index) const { | ||
| 483 | return m_arm_interfaces[core_index].get(); | ||
| 484 | } | ||
| 485 | |||
| 479 | public: | 486 | public: |
| 480 | // Attempts to insert a watchpoint into a free slot. Returns false if none are available. | 487 | // Attempts to insert a watchpoint into a free slot. Returns false if none are available. |
| 481 | bool InsertWatchpoint(KProcessAddress addr, u64 size, DebugWatchpointType type); | 488 | bool InsertWatchpoint(KProcessAddress addr, u64 size, DebugWatchpointType type); |
| @@ -493,6 +500,8 @@ public: | |||
| 493 | 500 | ||
| 494 | void LoadModule(CodeSet code_set, KProcessAddress base_addr); | 501 | void LoadModule(CodeSet code_set, KProcessAddress base_addr); |
| 495 | 502 | ||
| 503 | void InitializeInterfaces(); | ||
| 504 | |||
| 496 | Core::Memory::Memory& GetMemory() const; | 505 | Core::Memory::Memory& GetMemory() const; |
| 497 | 506 | ||
| 498 | public: | 507 | public: |
diff --git a/src/core/hle/kernel/k_process_page_table.h b/src/core/hle/kernel/k_process_page_table.h index 9e40f68bc..346d7ca08 100644 --- a/src/core/hle/kernel/k_process_page_table.h +++ b/src/core/hle/kernel/k_process_page_table.h | |||
| @@ -7,10 +7,6 @@ | |||
| 7 | #include "core/hle/kernel/k_scoped_lock.h" | 7 | #include "core/hle/kernel/k_scoped_lock.h" |
| 8 | #include "core/hle/kernel/svc_types.h" | 8 | #include "core/hle/kernel/svc_types.h" |
| 9 | 9 | ||
| 10 | namespace Core { | ||
| 11 | class ARM_Interface; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Kernel { | 10 | namespace Kernel { |
| 15 | 11 | ||
| 16 | class KProcessPageTable { | 12 | class KProcessPageTable { |
diff --git a/src/core/hle/kernel/k_scheduler.cpp b/src/core/hle/kernel/k_scheduler.cpp index 1bce63a56..27d1c3846 100644 --- a/src/core/hle/kernel/k_scheduler.cpp +++ b/src/core/hle/kernel/k_scheduler.cpp | |||
| @@ -494,12 +494,7 @@ void KScheduler::ScheduleImplFiber() { | |||
| 494 | } | 494 | } |
| 495 | 495 | ||
| 496 | void KScheduler::Unload(KThread* thread) { | 496 | void KScheduler::Unload(KThread* thread) { |
| 497 | auto& cpu_core = m_kernel.System().ArmInterface(m_core_id); | 497 | m_kernel.PhysicalCore(m_core_id).SaveContext(thread); |
| 498 | cpu_core.SaveContext(thread->GetContext32()); | ||
| 499 | cpu_core.SaveContext(thread->GetContext64()); | ||
| 500 | // Save the TPIDR_EL0 system register in case it was modified. | ||
| 501 | thread->SetTpidrEl0(cpu_core.GetTPIDR_EL0()); | ||
| 502 | cpu_core.ClearExclusiveState(); | ||
| 503 | 498 | ||
| 504 | // Check if the thread is terminated by checking the DPC flags. | 499 | // Check if the thread is terminated by checking the DPC flags. |
| 505 | if ((thread->GetStackParameters().dpc_flags & static_cast<u32>(DpcFlag::Terminated)) == 0) { | 500 | if ((thread->GetStackParameters().dpc_flags & static_cast<u32>(DpcFlag::Terminated)) == 0) { |
| @@ -509,14 +504,7 @@ void KScheduler::Unload(KThread* thread) { | |||
| 509 | } | 504 | } |
| 510 | 505 | ||
| 511 | void KScheduler::Reload(KThread* thread) { | 506 | void KScheduler::Reload(KThread* thread) { |
| 512 | auto& cpu_core = m_kernel.System().ArmInterface(m_core_id); | 507 | m_kernel.PhysicalCore(m_core_id).LoadContext(thread); |
| 513 | auto* process = thread->GetOwnerProcess(); | ||
| 514 | cpu_core.LoadContext(thread->GetContext32()); | ||
| 515 | cpu_core.LoadContext(thread->GetContext64()); | ||
| 516 | cpu_core.SetTlsAddress(GetInteger(thread->GetTlsAddress())); | ||
| 517 | cpu_core.SetTPIDR_EL0(thread->GetTpidrEl0()); | ||
| 518 | cpu_core.LoadWatchpointArray(process ? &process->GetWatchpoints() : nullptr); | ||
| 519 | cpu_core.ClearExclusiveState(); | ||
| 520 | } | 508 | } |
| 521 | 509 | ||
| 522 | void KScheduler::ClearPreviousThread(KernelCore& kernel, KThread* thread) { | 510 | void KScheduler::ClearPreviousThread(KernelCore& kernel, KThread* thread) { |
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index a6deb50ec..7d9a6e9cf 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp | |||
| @@ -41,24 +41,25 @@ namespace { | |||
| 41 | 41 | ||
| 42 | constexpr inline s32 TerminatingThreadPriority = Kernel::Svc::SystemThreadPriorityHighest - 1; | 42 | constexpr inline s32 TerminatingThreadPriority = Kernel::Svc::SystemThreadPriorityHighest - 1; |
| 43 | 43 | ||
| 44 | static void ResetThreadContext32(Kernel::KThread::ThreadContext32& context, u32 stack_top, | 44 | static void ResetThreadContext32(Kernel::Svc::ThreadContext& ctx, u64 stack_top, u64 entry_point, |
| 45 | u32 entry_point, u32 arg) { | 45 | u64 arg) { |
| 46 | context = {}; | 46 | ctx = {}; |
| 47 | context.cpu_registers[0] = arg; | 47 | ctx.r[0] = arg; |
| 48 | context.cpu_registers[15] = entry_point; | 48 | ctx.r[15] = entry_point; |
| 49 | context.cpu_registers[13] = stack_top; | 49 | ctx.r[13] = stack_top; |
| 50 | context.fpscr = 0; | 50 | ctx.fpcr = 0; |
| 51 | } | 51 | ctx.fpsr = 0; |
| 52 | 52 | } | |
| 53 | static void ResetThreadContext64(Kernel::KThread::ThreadContext64& context, u64 stack_top, | 53 | |
| 54 | u64 entry_point, u64 arg) { | 54 | static void ResetThreadContext64(Kernel::Svc::ThreadContext& ctx, u64 stack_top, u64 entry_point, |
| 55 | context = {}; | 55 | u64 arg) { |
| 56 | context.cpu_registers[0] = arg; | 56 | ctx = {}; |
| 57 | context.cpu_registers[18] = Kernel::KSystemControl::GenerateRandomU64() | 1; | 57 | ctx.r[0] = arg; |
| 58 | context.pc = entry_point; | 58 | ctx.r[18] = Kernel::KSystemControl::GenerateRandomU64() | 1; |
| 59 | context.sp = stack_top; | 59 | ctx.pc = entry_point; |
| 60 | context.fpcr = 0; | 60 | ctx.sp = stack_top; |
| 61 | context.fpsr = 0; | 61 | ctx.fpcr = 0; |
| 62 | ctx.fpsr = 0; | ||
| 62 | } | 63 | } |
| 63 | } // namespace | 64 | } // namespace |
| 64 | 65 | ||
| @@ -223,9 +224,11 @@ Result KThread::Initialize(KThreadFunction func, uintptr_t arg, KProcessAddress | |||
| 223 | } | 224 | } |
| 224 | 225 | ||
| 225 | // Initialize thread context. | 226 | // Initialize thread context. |
| 226 | ResetThreadContext64(m_thread_context_64, GetInteger(user_stack_top), GetInteger(func), arg); | 227 | if (m_parent != nullptr && !m_parent->Is64Bit()) { |
| 227 | ResetThreadContext32(m_thread_context_32, static_cast<u32>(GetInteger(user_stack_top)), | 228 | ResetThreadContext32(m_thread_context, GetInteger(user_stack_top), GetInteger(func), arg); |
| 228 | static_cast<u32>(GetInteger(func)), static_cast<u32>(arg)); | 229 | } else { |
| 230 | ResetThreadContext64(m_thread_context, GetInteger(user_stack_top), GetInteger(func), arg); | ||
| 231 | } | ||
| 229 | 232 | ||
| 230 | // Setup the stack parameters. | 233 | // Setup the stack parameters. |
| 231 | StackParameters& sp = this->GetStackParameters(); | 234 | StackParameters& sp = this->GetStackParameters(); |
| @@ -823,20 +826,7 @@ void KThread::CloneFpuStatus() { | |||
| 823 | ASSERT(this->GetOwnerProcess() != nullptr); | 826 | ASSERT(this->GetOwnerProcess() != nullptr); |
| 824 | ASSERT(this->GetOwnerProcess() == GetCurrentProcessPointer(m_kernel)); | 827 | ASSERT(this->GetOwnerProcess() == GetCurrentProcessPointer(m_kernel)); |
| 825 | 828 | ||
| 826 | if (this->GetOwnerProcess()->Is64Bit()) { | 829 | m_kernel.CurrentPhysicalCore().CloneFpuStatus(this); |
| 827 | // Clone FPSR and FPCR. | ||
| 828 | ThreadContext64 cur_ctx{}; | ||
| 829 | m_kernel.System().CurrentArmInterface().SaveContext(cur_ctx); | ||
| 830 | |||
| 831 | this->GetContext64().fpcr = cur_ctx.fpcr; | ||
| 832 | this->GetContext64().fpsr = cur_ctx.fpsr; | ||
| 833 | } else { | ||
| 834 | // Clone FPSCR. | ||
| 835 | ThreadContext32 cur_ctx{}; | ||
| 836 | m_kernel.System().CurrentArmInterface().SaveContext(cur_ctx); | ||
| 837 | |||
| 838 | this->GetContext32().fpscr = cur_ctx.fpscr; | ||
| 839 | } | ||
| 840 | } | 830 | } |
| 841 | 831 | ||
| 842 | Result KThread::SetActivity(Svc::ThreadActivity activity) { | 832 | Result KThread::SetActivity(Svc::ThreadActivity activity) { |
| @@ -912,7 +902,7 @@ Result KThread::SetActivity(Svc::ThreadActivity activity) { | |||
| 912 | R_SUCCEED(); | 902 | R_SUCCEED(); |
| 913 | } | 903 | } |
| 914 | 904 | ||
| 915 | Result KThread::GetThreadContext3(Common::ScratchBuffer<u8>& out) { | 905 | Result KThread::GetThreadContext3(Svc::ThreadContext* out) { |
| 916 | // Lock ourselves. | 906 | // Lock ourselves. |
| 917 | KScopedLightLock lk{m_activity_pause_lock}; | 907 | KScopedLightLock lk{m_activity_pause_lock}; |
| 918 | 908 | ||
| @@ -926,18 +916,16 @@ Result KThread::GetThreadContext3(Common::ScratchBuffer<u8>& out) { | |||
| 926 | 916 | ||
| 927 | // If we're not terminating, get the thread's user context. | 917 | // If we're not terminating, get the thread's user context. |
| 928 | if (!this->IsTerminationRequested()) { | 918 | if (!this->IsTerminationRequested()) { |
| 919 | *out = m_thread_context; | ||
| 920 | |||
| 921 | // Mask away mode bits, interrupt bits, IL bit, and other reserved bits. | ||
| 922 | constexpr u32 El0Aarch64PsrMask = 0xF0000000; | ||
| 923 | constexpr u32 El0Aarch32PsrMask = 0xFE0FFE20; | ||
| 924 | |||
| 929 | if (m_parent->Is64Bit()) { | 925 | if (m_parent->Is64Bit()) { |
| 930 | // Mask away mode bits, interrupt bits, IL bit, and other reserved bits. | 926 | out->pstate &= El0Aarch64PsrMask; |
| 931 | auto context = GetContext64(); | ||
| 932 | context.pstate &= 0xFF0FFE20; | ||
| 933 | out.resize_destructive(sizeof(context)); | ||
| 934 | std::memcpy(out.data(), std::addressof(context), sizeof(context)); | ||
| 935 | } else { | 927 | } else { |
| 936 | // Mask away mode bits, interrupt bits, IL bit, and other reserved bits. | 928 | out->pstate &= El0Aarch32PsrMask; |
| 937 | auto context = GetContext32(); | ||
| 938 | context.cpsr &= 0xFF0FFE20; | ||
| 939 | out.resize_destructive(sizeof(context)); | ||
| 940 | std::memcpy(out.data(), std::addressof(context), sizeof(context)); | ||
| 941 | } | 929 | } |
| 942 | } | 930 | } |
| 943 | } | 931 | } |
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index e9ca5dfca..390db2409 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h | |||
| @@ -38,7 +38,6 @@ namespace Core { | |||
| 38 | namespace Memory { | 38 | namespace Memory { |
| 39 | class Memory; | 39 | class Memory; |
| 40 | } | 40 | } |
| 41 | class ARM_Interface; | ||
| 42 | class System; | 41 | class System; |
| 43 | } // namespace Core | 42 | } // namespace Core |
| 44 | 43 | ||
| @@ -137,8 +136,6 @@ public: | |||
| 137 | ~KThread() override; | 136 | ~KThread() override; |
| 138 | 137 | ||
| 139 | public: | 138 | public: |
| 140 | using ThreadContext32 = Core::ARM_Interface::ThreadContext32; | ||
| 141 | using ThreadContext64 = Core::ARM_Interface::ThreadContext64; | ||
| 142 | using WaiterList = Common::IntrusiveListBaseTraits<KThread>::ListType; | 139 | using WaiterList = Common::IntrusiveListBaseTraits<KThread>::ListType; |
| 143 | 140 | ||
| 144 | /** | 141 | /** |
| @@ -246,31 +243,22 @@ public: | |||
| 246 | * @returns The value of the TPIDR_EL0 register. | 243 | * @returns The value of the TPIDR_EL0 register. |
| 247 | */ | 244 | */ |
| 248 | u64 GetTpidrEl0() const { | 245 | u64 GetTpidrEl0() const { |
| 249 | return m_thread_context_64.tpidr; | 246 | return m_thread_context.tpidr; |
| 250 | } | 247 | } |
| 251 | 248 | ||
| 252 | /// Sets the value of the TPIDR_EL0 Read/Write system register for this thread. | 249 | /// Sets the value of the TPIDR_EL0 Read/Write system register for this thread. |
| 253 | void SetTpidrEl0(u64 value) { | 250 | void SetTpidrEl0(u64 value) { |
| 254 | m_thread_context_64.tpidr = value; | 251 | m_thread_context.tpidr = value; |
| 255 | m_thread_context_32.tpidr = static_cast<u32>(value); | ||
| 256 | } | 252 | } |
| 257 | 253 | ||
| 258 | void CloneFpuStatus(); | 254 | void CloneFpuStatus(); |
| 259 | 255 | ||
| 260 | ThreadContext32& GetContext32() { | 256 | Svc::ThreadContext& GetContext() { |
| 261 | return m_thread_context_32; | 257 | return m_thread_context; |
| 262 | } | 258 | } |
| 263 | 259 | ||
| 264 | const ThreadContext32& GetContext32() const { | 260 | const Svc::ThreadContext& GetContext() const { |
| 265 | return m_thread_context_32; | 261 | return m_thread_context; |
| 266 | } | ||
| 267 | |||
| 268 | ThreadContext64& GetContext64() { | ||
| 269 | return m_thread_context_64; | ||
| 270 | } | ||
| 271 | |||
| 272 | const ThreadContext64& GetContext64() const { | ||
| 273 | return m_thread_context_64; | ||
| 274 | } | 262 | } |
| 275 | 263 | ||
| 276 | std::shared_ptr<Common::Fiber>& GetHostContext(); | 264 | std::shared_ptr<Common::Fiber>& GetHostContext(); |
| @@ -577,7 +565,7 @@ public: | |||
| 577 | 565 | ||
| 578 | void RemoveWaiter(KThread* thread); | 566 | void RemoveWaiter(KThread* thread); |
| 579 | 567 | ||
| 580 | Result GetThreadContext3(Common::ScratchBuffer<u8>& out); | 568 | Result GetThreadContext3(Svc::ThreadContext* out); |
| 581 | 569 | ||
| 582 | KThread* RemoveUserWaiterByKey(bool* out_has_waiters, KProcessAddress key) { | 570 | KThread* RemoveUserWaiterByKey(bool* out_has_waiters, KProcessAddress key) { |
| 583 | return this->RemoveWaiterByKey(out_has_waiters, key, false); | 571 | return this->RemoveWaiterByKey(out_has_waiters, key, false); |
| @@ -734,8 +722,7 @@ private: | |||
| 734 | std::function<void()>&& init_func); | 722 | std::function<void()>&& init_func); |
| 735 | 723 | ||
| 736 | // For core KThread implementation | 724 | // For core KThread implementation |
| 737 | ThreadContext32 m_thread_context_32{}; | 725 | Svc::ThreadContext m_thread_context{}; |
| 738 | ThreadContext64 m_thread_context_64{}; | ||
| 739 | Common::IntrusiveListNode m_process_list_node; | 726 | Common::IntrusiveListNode m_process_list_node; |
| 740 | Common::IntrusiveRedBlackTreeNode m_condvar_arbiter_tree_node{}; | 727 | Common::IntrusiveRedBlackTreeNode m_condvar_arbiter_tree_node{}; |
| 741 | s32 m_priority{}; | 728 | s32 m_priority{}; |
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 4a1559291..032c4e093 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -99,13 +99,6 @@ struct KernelCore::Impl { | |||
| 99 | RegisterHostThread(nullptr); | 99 | RegisterHostThread(nullptr); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | void InitializeCores() { | ||
| 103 | for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { | ||
| 104 | cores[core_id]->Initialize((*application_process).Is64Bit()); | ||
| 105 | system.ApplicationMemory().SetCurrentPageTable(*application_process, core_id); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | void TerminateApplicationProcess() { | 102 | void TerminateApplicationProcess() { |
| 110 | application_process.load()->Terminate(); | 103 | application_process.load()->Terminate(); |
| 111 | } | 104 | } |
| @@ -205,7 +198,7 @@ struct KernelCore::Impl { | |||
| 205 | const s32 core{static_cast<s32>(i)}; | 198 | const s32 core{static_cast<s32>(i)}; |
| 206 | 199 | ||
| 207 | schedulers[i] = std::make_unique<Kernel::KScheduler>(system.Kernel()); | 200 | schedulers[i] = std::make_unique<Kernel::KScheduler>(system.Kernel()); |
| 208 | cores[i] = std::make_unique<Kernel::PhysicalCore>(i, system, *schedulers[i]); | 201 | cores[i] = std::make_unique<Kernel::PhysicalCore>(system.Kernel(), i); |
| 209 | 202 | ||
| 210 | auto* main_thread{Kernel::KThread::Create(system.Kernel())}; | 203 | auto* main_thread{Kernel::KThread::Create(system.Kernel())}; |
| 211 | main_thread->SetCurrentCore(core); | 204 | main_thread->SetCurrentCore(core); |
| @@ -880,10 +873,6 @@ void KernelCore::Initialize() { | |||
| 880 | impl->Initialize(*this); | 873 | impl->Initialize(*this); |
| 881 | } | 874 | } |
| 882 | 875 | ||
| 883 | void KernelCore::InitializeCores() { | ||
| 884 | impl->InitializeCores(); | ||
| 885 | } | ||
| 886 | |||
| 887 | void KernelCore::Shutdown() { | 876 | void KernelCore::Shutdown() { |
| 888 | impl->Shutdown(); | 877 | impl->Shutdown(); |
| 889 | } | 878 | } |
| @@ -993,21 +982,6 @@ const KAutoObjectWithListContainer& KernelCore::ObjectListContainer() const { | |||
| 993 | return *impl->global_object_list_container; | 982 | return *impl->global_object_list_container; |
| 994 | } | 983 | } |
| 995 | 984 | ||
| 996 | void KernelCore::InvalidateAllInstructionCaches() { | ||
| 997 | for (auto& physical_core : impl->cores) { | ||
| 998 | physical_core->ArmInterface().ClearInstructionCache(); | ||
| 999 | } | ||
| 1000 | } | ||
| 1001 | |||
| 1002 | void KernelCore::InvalidateCpuInstructionCacheRange(KProcessAddress addr, std::size_t size) { | ||
| 1003 | for (auto& physical_core : impl->cores) { | ||
| 1004 | if (!physical_core->IsInitialized()) { | ||
| 1005 | continue; | ||
| 1006 | } | ||
| 1007 | physical_core->ArmInterface().InvalidateCacheRange(GetInteger(addr), size); | ||
| 1008 | } | ||
| 1009 | } | ||
| 1010 | |||
| 1011 | void KernelCore::PrepareReschedule(std::size_t id) { | 985 | void KernelCore::PrepareReschedule(std::size_t id) { |
| 1012 | // TODO: Reimplement, this | 986 | // TODO: Reimplement, this |
| 1013 | } | 987 | } |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index d8086c0ea..69b5bbd6c 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -104,9 +104,6 @@ public: | |||
| 104 | /// Resets the kernel to a clean slate for use. | 104 | /// Resets the kernel to a clean slate for use. |
| 105 | void Initialize(); | 105 | void Initialize(); |
| 106 | 106 | ||
| 107 | /// Initializes the CPU cores. | ||
| 108 | void InitializeCores(); | ||
| 109 | |||
| 110 | /// Clears all resources in use by the kernel instance. | 107 | /// Clears all resources in use by the kernel instance. |
| 111 | void Shutdown(); | 108 | void Shutdown(); |
| 112 | 109 | ||
| @@ -181,10 +178,6 @@ public: | |||
| 181 | 178 | ||
| 182 | const KAutoObjectWithListContainer& ObjectListContainer() const; | 179 | const KAutoObjectWithListContainer& ObjectListContainer() const; |
| 183 | 180 | ||
| 184 | void InvalidateAllInstructionCaches(); | ||
| 185 | |||
| 186 | void InvalidateCpuInstructionCacheRange(KProcessAddress addr, std::size_t size); | ||
| 187 | |||
| 188 | /// Registers all kernel objects with the global emulation state, this is purely for tracking | 181 | /// Registers all kernel objects with the global emulation state, this is purely for tracking |
| 189 | /// leaks after emulation has been shutdown. | 182 | /// leaks after emulation has been shutdown. |
| 190 | void RegisterKernelObject(KAutoObject* object); | 183 | void RegisterKernelObject(KAutoObject* object); |
diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index 073039825..7fa8e2a85 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp | |||
| @@ -1,62 +1,206 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2020 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/scope_exit.h" | ||
| 4 | #include "common/settings.h" | 5 | #include "common/settings.h" |
| 5 | #include "core/arm/dynarmic/arm_dynarmic_32.h" | ||
| 6 | #include "core/arm/dynarmic/arm_dynarmic_64.h" | ||
| 7 | #ifdef HAS_NCE | ||
| 8 | #include "core/arm/nce/arm_nce.h" | ||
| 9 | #endif | ||
| 10 | #include "core/core.h" | 6 | #include "core/core.h" |
| 11 | #include "core/hle/kernel/k_scheduler.h" | 7 | #include "core/debugger/debugger.h" |
| 8 | #include "core/hle/kernel/k_process.h" | ||
| 9 | #include "core/hle/kernel/k_thread.h" | ||
| 12 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/kernel.h" |
| 13 | #include "core/hle/kernel/physical_core.h" | 11 | #include "core/hle/kernel/physical_core.h" |
| 12 | #include "core/hle/kernel/svc.h" | ||
| 14 | 13 | ||
| 15 | namespace Kernel { | 14 | namespace Kernel { |
| 16 | 15 | ||
| 17 | PhysicalCore::PhysicalCore(std::size_t core_index, Core::System& system, KScheduler& scheduler) | 16 | PhysicalCore::PhysicalCore(KernelCore& kernel, std::size_t core_index) |
| 18 | : m_core_index{core_index}, m_system{system}, m_scheduler{scheduler} { | 17 | : m_kernel{kernel}, m_core_index{core_index} { |
| 19 | #if defined(ARCHITECTURE_x86_64) || defined(ARCHITECTURE_arm64) | 18 | m_is_single_core = !kernel.IsMulticore(); |
| 20 | // TODO(bunnei): Initialization relies on a core being available. We may later replace this with | ||
| 21 | // an NCE interface or a 32-bit instance of Dynarmic. This should be abstracted out to a CPU | ||
| 22 | // manager. | ||
| 23 | auto& kernel = system.Kernel(); | ||
| 24 | m_arm_interface = std::make_unique<Core::ARM_Dynarmic_64>( | ||
| 25 | system, kernel.IsMulticore(), | ||
| 26 | reinterpret_cast<Core::DynarmicExclusiveMonitor&>(kernel.GetExclusiveMonitor()), | ||
| 27 | m_core_index); | ||
| 28 | #else | ||
| 29 | #error Platform not supported yet. | ||
| 30 | #endif | ||
| 31 | } | 19 | } |
| 32 | |||
| 33 | PhysicalCore::~PhysicalCore() = default; | 20 | PhysicalCore::~PhysicalCore() = default; |
| 34 | 21 | ||
| 35 | void PhysicalCore::Initialize(bool is_64_bit) { | 22 | void PhysicalCore::RunThread(Kernel::KThread* thread) { |
| 36 | #if defined(HAS_NCE) | 23 | auto* process = thread->GetOwnerProcess(); |
| 37 | if (Settings::IsNceEnabled()) { | 24 | auto& system = m_kernel.System(); |
| 38 | m_arm_interface = std::make_unique<Core::ARM_NCE>(m_system, m_system.Kernel().IsMulticore(), | 25 | auto* interface = process->GetArmInterface(m_core_index); |
| 39 | m_core_index); | 26 | |
| 27 | interface->Initialize(); | ||
| 28 | |||
| 29 | const auto EnterContext = [&]() { | ||
| 30 | system.EnterCPUProfile(); | ||
| 31 | |||
| 32 | // Lock the core context. | ||
| 33 | std::scoped_lock lk{m_guard}; | ||
| 34 | |||
| 35 | // Check if we are already interrupted. If we are, we can just stop immediately. | ||
| 36 | if (m_is_interrupted) { | ||
| 37 | return false; | ||
| 38 | } | ||
| 39 | |||
| 40 | // Mark that we are running. | ||
| 41 | m_arm_interface = interface; | ||
| 42 | m_current_thread = thread; | ||
| 43 | |||
| 44 | // Acquire the lock on the thread parameters. | ||
| 45 | // This allows us to force synchronization with Interrupt. | ||
| 46 | interface->LockThread(thread); | ||
| 47 | |||
| 48 | return true; | ||
| 49 | }; | ||
| 50 | |||
| 51 | const auto ExitContext = [&]() { | ||
| 52 | // Unlock the thread. | ||
| 53 | interface->UnlockThread(thread); | ||
| 54 | |||
| 55 | // Lock the core context. | ||
| 56 | std::scoped_lock lk{m_guard}; | ||
| 57 | |||
| 58 | // On exit, we no longer are running. | ||
| 59 | m_arm_interface = nullptr; | ||
| 60 | m_current_thread = nullptr; | ||
| 61 | |||
| 62 | system.ExitCPUProfile(); | ||
| 63 | }; | ||
| 64 | |||
| 65 | while (true) { | ||
| 66 | // If the thread is scheduled for termination, exit. | ||
| 67 | if (thread->HasDpc() && thread->IsTerminationRequested()) { | ||
| 68 | thread->Exit(); | ||
| 69 | } | ||
| 70 | |||
| 71 | // Notify the debugger and go to sleep if a step was performed | ||
| 72 | // and this thread has been scheduled again. | ||
| 73 | if (thread->GetStepState() == StepState::StepPerformed) { | ||
| 74 | system.GetDebugger().NotifyThreadStopped(thread); | ||
| 75 | thread->RequestSuspend(SuspendType::Debug); | ||
| 76 | return; | ||
| 77 | } | ||
| 78 | |||
| 79 | // Otherwise, run the thread. | ||
| 80 | Core::HaltReason hr{}; | ||
| 81 | { | ||
| 82 | // If we were interrupted, exit immediately. | ||
| 83 | if (!EnterContext()) { | ||
| 84 | return; | ||
| 85 | } | ||
| 86 | |||
| 87 | if (thread->GetStepState() == StepState::StepPending) { | ||
| 88 | hr = interface->StepThread(thread); | ||
| 89 | |||
| 90 | if (True(hr & Core::HaltReason::StepThread)) { | ||
| 91 | thread->SetStepState(StepState::StepPerformed); | ||
| 92 | } | ||
| 93 | } else { | ||
| 94 | hr = interface->RunThread(thread); | ||
| 95 | } | ||
| 96 | |||
| 97 | ExitContext(); | ||
| 98 | } | ||
| 99 | |||
| 100 | // Determine why we stopped. | ||
| 101 | const bool supervisor_call = True(hr & Core::HaltReason::SupervisorCall); | ||
| 102 | const bool prefetch_abort = True(hr & Core::HaltReason::PrefetchAbort); | ||
| 103 | const bool breakpoint = True(hr & Core::HaltReason::InstructionBreakpoint); | ||
| 104 | const bool data_abort = True(hr & Core::HaltReason::DataAbort); | ||
| 105 | const bool interrupt = True(hr & Core::HaltReason::BreakLoop); | ||
| 106 | |||
| 107 | // Since scheduling may occur here, we cannot use any cached | ||
| 108 | // state after returning from calls we make. | ||
| 109 | |||
| 110 | // Notify the debugger and go to sleep if a breakpoint was hit, | ||
| 111 | // or if the thread is unable to continue for any reason. | ||
| 112 | if (breakpoint || prefetch_abort) { | ||
| 113 | if (breakpoint) { | ||
| 114 | interface->RewindBreakpointInstruction(); | ||
| 115 | } | ||
| 116 | if (system.DebuggerEnabled()) { | ||
| 117 | system.GetDebugger().NotifyThreadStopped(thread); | ||
| 118 | } else { | ||
| 119 | interface->LogBacktrace(process); | ||
| 120 | } | ||
| 121 | thread->RequestSuspend(SuspendType::Debug); | ||
| 122 | return; | ||
| 123 | } | ||
| 124 | |||
| 125 | // Notify the debugger and go to sleep on data abort. | ||
| 126 | if (data_abort) { | ||
| 127 | if (system.DebuggerEnabled()) { | ||
| 128 | system.GetDebugger().NotifyThreadWatchpoint(thread, *interface->HaltedWatchpoint()); | ||
| 129 | } | ||
| 130 | thread->RequestSuspend(SuspendType::Debug); | ||
| 131 | return; | ||
| 132 | } | ||
| 133 | |||
| 134 | // Handle system calls. | ||
| 135 | if (supervisor_call) { | ||
| 136 | // Perform call. | ||
| 137 | Svc::Call(system, interface->GetSvcNumber()); | ||
| 138 | return; | ||
| 139 | } | ||
| 140 | |||
| 141 | // Handle external interrupt sources. | ||
| 142 | if (interrupt || !m_is_single_core) { | ||
| 143 | return; | ||
| 144 | } | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | void PhysicalCore::LoadContext(const KThread* thread) { | ||
| 149 | auto* const process = thread->GetOwnerProcess(); | ||
| 150 | if (!process) { | ||
| 151 | // Kernel threads do not run on emulated CPU cores. | ||
| 40 | return; | 152 | return; |
| 41 | } | 153 | } |
| 42 | #endif | 154 | |
| 43 | #if defined(ARCHITECTURE_x86_64) || defined(ARCHITECTURE_arm64) | 155 | auto* interface = process->GetArmInterface(m_core_index); |
| 44 | auto& kernel = m_system.Kernel(); | 156 | if (interface) { |
| 45 | if (!is_64_bit) { | 157 | interface->SetContext(thread->GetContext()); |
| 46 | // We already initialized a 64-bit core, replace with a 32-bit one. | 158 | interface->SetTpidrroEl0(GetInteger(thread->GetTlsAddress())); |
| 47 | m_arm_interface = std::make_unique<Core::ARM_Dynarmic_32>( | 159 | interface->SetWatchpointArray(&process->GetWatchpoints()); |
| 48 | m_system, kernel.IsMulticore(), | ||
| 49 | reinterpret_cast<Core::DynarmicExclusiveMonitor&>(kernel.GetExclusiveMonitor()), | ||
| 50 | m_core_index); | ||
| 51 | } | 160 | } |
| 52 | #else | ||
| 53 | #error Platform not supported yet. | ||
| 54 | #endif | ||
| 55 | } | 161 | } |
| 56 | 162 | ||
| 57 | void PhysicalCore::Run() { | 163 | void PhysicalCore::LoadSvcArguments(const KProcess& process, std::span<const uint64_t, 8> args) { |
| 58 | m_arm_interface->Run(); | 164 | process.GetArmInterface(m_core_index)->SetSvcArguments(args); |
| 59 | m_arm_interface->ClearExclusiveState(); | 165 | } |
| 166 | |||
| 167 | void PhysicalCore::SaveContext(KThread* thread) const { | ||
| 168 | auto* const process = thread->GetOwnerProcess(); | ||
| 169 | if (!process) { | ||
| 170 | // Kernel threads do not run on emulated CPU cores. | ||
| 171 | return; | ||
| 172 | } | ||
| 173 | |||
| 174 | auto* interface = process->GetArmInterface(m_core_index); | ||
| 175 | if (interface) { | ||
| 176 | interface->GetContext(thread->GetContext()); | ||
| 177 | } | ||
| 178 | } | ||
| 179 | |||
| 180 | void PhysicalCore::SaveSvcArguments(KProcess& process, std::span<uint64_t, 8> args) const { | ||
| 181 | process.GetArmInterface(m_core_index)->GetSvcArguments(args); | ||
| 182 | } | ||
| 183 | |||
| 184 | void PhysicalCore::CloneFpuStatus(KThread* dst) const { | ||
| 185 | auto* process = dst->GetOwnerProcess(); | ||
| 186 | |||
| 187 | Svc::ThreadContext ctx{}; | ||
| 188 | process->GetArmInterface(m_core_index)->GetContext(ctx); | ||
| 189 | |||
| 190 | dst->GetContext().fpcr = ctx.fpcr; | ||
| 191 | dst->GetContext().fpsr = ctx.fpsr; | ||
| 192 | } | ||
| 193 | |||
| 194 | void PhysicalCore::LogBacktrace() { | ||
| 195 | auto* process = GetCurrentProcessPointer(m_kernel); | ||
| 196 | if (!process) { | ||
| 197 | return; | ||
| 198 | } | ||
| 199 | |||
| 200 | auto* interface = process->GetArmInterface(m_core_index); | ||
| 201 | if (interface) { | ||
| 202 | interface->LogBacktrace(process); | ||
| 203 | } | ||
| 60 | } | 204 | } |
| 61 | 205 | ||
| 62 | void PhysicalCore::Idle() { | 206 | void PhysicalCore::Idle() { |
| @@ -69,16 +213,31 @@ bool PhysicalCore::IsInterrupted() const { | |||
| 69 | } | 213 | } |
| 70 | 214 | ||
| 71 | void PhysicalCore::Interrupt() { | 215 | void PhysicalCore::Interrupt() { |
| 72 | std::unique_lock lk{m_guard}; | 216 | // Lock core context. |
| 217 | std::scoped_lock lk{m_guard}; | ||
| 218 | |||
| 219 | // Load members. | ||
| 220 | auto* arm_interface = m_arm_interface; | ||
| 221 | auto* thread = m_current_thread; | ||
| 222 | |||
| 223 | // Add interrupt flag. | ||
| 73 | m_is_interrupted = true; | 224 | m_is_interrupted = true; |
| 74 | m_arm_interface->SignalInterrupt(); | 225 | |
| 75 | m_on_interrupt.notify_all(); | 226 | // Interrupt ourselves. |
| 227 | m_on_interrupt.notify_one(); | ||
| 228 | |||
| 229 | // If there is no thread running, we are done. | ||
| 230 | if (arm_interface == nullptr) { | ||
| 231 | return; | ||
| 232 | } | ||
| 233 | |||
| 234 | // Interrupt the CPU. | ||
| 235 | arm_interface->SignalInterrupt(thread); | ||
| 76 | } | 236 | } |
| 77 | 237 | ||
| 78 | void PhysicalCore::ClearInterrupt() { | 238 | void PhysicalCore::ClearInterrupt() { |
| 79 | std::unique_lock lk{m_guard}; | 239 | std::scoped_lock lk{m_guard}; |
| 80 | m_is_interrupted = false; | 240 | m_is_interrupted = false; |
| 81 | m_arm_interface->ClearInterrupt(); | ||
| 82 | } | 241 | } |
| 83 | 242 | ||
| 84 | } // namespace Kernel | 243 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/physical_core.h b/src/core/hle/kernel/physical_core.h index 5cb398fdc..bae4fe5b8 100644 --- a/src/core/hle/kernel/physical_core.h +++ b/src/core/hle/kernel/physical_core.h | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #include "core/arm/arm_interface.h" | 11 | #include "core/arm/arm_interface.h" |
| 12 | 12 | ||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
| 14 | class KScheduler; | 14 | class KernelCore; |
| 15 | } // namespace Kernel | 15 | } // namespace Kernel |
| 16 | 16 | ||
| 17 | namespace Core { | 17 | namespace Core { |
| @@ -23,62 +23,55 @@ namespace Kernel { | |||
| 23 | 23 | ||
| 24 | class PhysicalCore { | 24 | class PhysicalCore { |
| 25 | public: | 25 | public: |
| 26 | PhysicalCore(std::size_t core_index_, Core::System& system_, KScheduler& scheduler_); | 26 | PhysicalCore(KernelCore& kernel, std::size_t core_index); |
| 27 | ~PhysicalCore(); | 27 | ~PhysicalCore(); |
| 28 | 28 | ||
| 29 | YUZU_NON_COPYABLE(PhysicalCore); | 29 | YUZU_NON_COPYABLE(PhysicalCore); |
| 30 | YUZU_NON_MOVEABLE(PhysicalCore); | 30 | YUZU_NON_MOVEABLE(PhysicalCore); |
| 31 | 31 | ||
| 32 | /// Initialize the core for the specified parameters. | 32 | // Execute guest code running on the given thread. |
| 33 | void Initialize(bool is_64_bit); | 33 | void RunThread(KThread* thread); |
| 34 | 34 | ||
| 35 | /// Execute current jit state | 35 | // Copy context from thread to current core. |
| 36 | void Run(); | 36 | void LoadContext(const KThread* thread); |
| 37 | void LoadSvcArguments(const KProcess& process, std::span<const uint64_t, 8> args); | ||
| 37 | 38 | ||
| 39 | // Copy context from current core to thread. | ||
| 40 | void SaveContext(KThread* thread) const; | ||
| 41 | void SaveSvcArguments(KProcess& process, std::span<uint64_t, 8> args) const; | ||
| 42 | |||
| 43 | // Copy floating point status registers to the target thread. | ||
| 44 | void CloneFpuStatus(KThread* dst) const; | ||
| 45 | |||
| 46 | // Log backtrace of current processor state. | ||
| 47 | void LogBacktrace(); | ||
| 48 | |||
| 49 | // Wait for an interrupt. | ||
| 38 | void Idle(); | 50 | void Idle(); |
| 39 | 51 | ||
| 40 | /// Interrupt this physical core. | 52 | // Interrupt this core. |
| 41 | void Interrupt(); | 53 | void Interrupt(); |
| 42 | 54 | ||
| 43 | /// Clear this core's interrupt | 55 | // Clear this core's interrupt. |
| 44 | void ClearInterrupt(); | 56 | void ClearInterrupt(); |
| 45 | 57 | ||
| 46 | /// Check if this core is interrupted | 58 | // Check if this core is interrupted. |
| 47 | bool IsInterrupted() const; | 59 | bool IsInterrupted() const; |
| 48 | 60 | ||
| 49 | bool IsInitialized() const { | ||
| 50 | return m_arm_interface != nullptr; | ||
| 51 | } | ||
| 52 | |||
| 53 | Core::ARM_Interface& ArmInterface() { | ||
| 54 | return *m_arm_interface; | ||
| 55 | } | ||
| 56 | |||
| 57 | const Core::ARM_Interface& ArmInterface() const { | ||
| 58 | return *m_arm_interface; | ||
| 59 | } | ||
| 60 | |||
| 61 | std::size_t CoreIndex() const { | 61 | std::size_t CoreIndex() const { |
| 62 | return m_core_index; | 62 | return m_core_index; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | Kernel::KScheduler& Scheduler() { | ||
| 66 | return m_scheduler; | ||
| 67 | } | ||
| 68 | |||
| 69 | const Kernel::KScheduler& Scheduler() const { | ||
| 70 | return m_scheduler; | ||
| 71 | } | ||
| 72 | |||
| 73 | private: | 65 | private: |
| 66 | KernelCore& m_kernel; | ||
| 74 | const std::size_t m_core_index; | 67 | const std::size_t m_core_index; |
| 75 | Core::System& m_system; | ||
| 76 | Kernel::KScheduler& m_scheduler; | ||
| 77 | 68 | ||
| 78 | std::mutex m_guard; | 69 | std::mutex m_guard; |
| 79 | std::condition_variable m_on_interrupt; | 70 | std::condition_variable m_on_interrupt; |
| 80 | std::unique_ptr<Core::ARM_Interface> m_arm_interface; | 71 | Core::ArmInterface* m_arm_interface{}; |
| 72 | KThread* m_current_thread{}; | ||
| 81 | bool m_is_interrupted{}; | 73 | bool m_is_interrupted{}; |
| 74 | bool m_is_single_core{}; | ||
| 82 | }; | 75 | }; |
| 83 | 76 | ||
| 84 | } // namespace Kernel | 77 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index b76683969..c55dc0c8a 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -12,20 +12,20 @@ | |||
| 12 | 12 | ||
| 13 | namespace Kernel::Svc { | 13 | namespace Kernel::Svc { |
| 14 | 14 | ||
| 15 | static uint32_t GetReg32(Core::System& system, int n) { | 15 | static uint32_t GetArg32(std::span<uint64_t, 8> args, int n) { |
| 16 | return static_cast<uint32_t>(system.CurrentArmInterface().GetReg(n)); | 16 | return static_cast<uint32_t>(args[n]); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | static void SetReg32(Core::System& system, int n, uint32_t result) { | 19 | static void SetArg32(std::span<uint64_t, 8> args, int n, uint32_t result) { |
| 20 | system.CurrentArmInterface().SetReg(n, static_cast<uint64_t>(result)); | 20 | args[n] = result; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | static uint64_t GetReg64(Core::System& system, int n) { | 23 | static uint64_t GetArg64(std::span<uint64_t, 8> args, int n) { |
| 24 | return system.CurrentArmInterface().GetReg(n); | 24 | return args[n]; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | static void SetReg64(Core::System& system, int n, uint64_t result) { | 27 | static void SetArg64(std::span<uint64_t, 8> args, int n, uint64_t result) { |
| 28 | system.CurrentArmInterface().SetReg(n, result); | 28 | args[n] = result; |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | // Like bit_cast, but handles the case when the source and dest | 31 | // Like bit_cast, but handles the case when the source and dest |
| @@ -79,37 +79,37 @@ static_assert(sizeof(int64_t) == 8); | |||
| 79 | static_assert(sizeof(uint32_t) == 4); | 79 | static_assert(sizeof(uint32_t) == 4); |
| 80 | static_assert(sizeof(uint64_t) == 8); | 80 | static_assert(sizeof(uint64_t) == 8); |
| 81 | 81 | ||
| 82 | static void SvcWrap_SetHeapSize64From32(Core::System& system) { | 82 | static void SvcWrap_SetHeapSize64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 83 | Result ret{}; | 83 | Result ret{}; |
| 84 | 84 | ||
| 85 | uint64_t out_address{}; | 85 | uint64_t out_address{}; |
| 86 | uint32_t size{}; | 86 | uint32_t size{}; |
| 87 | 87 | ||
| 88 | size = Convert<uint32_t>(GetReg32(system, 1)); | 88 | size = Convert<uint32_t>(GetArg32(args, 1)); |
| 89 | 89 | ||
| 90 | ret = SetHeapSize64From32(system, std::addressof(out_address), size); | 90 | ret = SetHeapSize64From32(system, std::addressof(out_address), size); |
| 91 | 91 | ||
| 92 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 92 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 93 | SetReg32(system, 1, Convert<uint32_t>(out_address)); | 93 | SetArg32(args, 1, Convert<uint32_t>(out_address)); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | static void SvcWrap_SetMemoryPermission64From32(Core::System& system) { | 96 | static void SvcWrap_SetMemoryPermission64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 97 | Result ret{}; | 97 | Result ret{}; |
| 98 | 98 | ||
| 99 | uint32_t address{}; | 99 | uint32_t address{}; |
| 100 | uint32_t size{}; | 100 | uint32_t size{}; |
| 101 | MemoryPermission perm{}; | 101 | MemoryPermission perm{}; |
| 102 | 102 | ||
| 103 | address = Convert<uint32_t>(GetReg32(system, 0)); | 103 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 104 | size = Convert<uint32_t>(GetReg32(system, 1)); | 104 | size = Convert<uint32_t>(GetArg32(args, 1)); |
| 105 | perm = Convert<MemoryPermission>(GetReg32(system, 2)); | 105 | perm = Convert<MemoryPermission>(GetArg32(args, 2)); |
| 106 | 106 | ||
| 107 | ret = SetMemoryPermission64From32(system, address, size, perm); | 107 | ret = SetMemoryPermission64From32(system, address, size, perm); |
| 108 | 108 | ||
| 109 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 109 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | static void SvcWrap_SetMemoryAttribute64From32(Core::System& system) { | 112 | static void SvcWrap_SetMemoryAttribute64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 113 | Result ret{}; | 113 | Result ret{}; |
| 114 | 114 | ||
| 115 | uint32_t address{}; | 115 | uint32_t address{}; |
| @@ -117,69 +117,69 @@ static void SvcWrap_SetMemoryAttribute64From32(Core::System& system) { | |||
| 117 | uint32_t mask{}; | 117 | uint32_t mask{}; |
| 118 | uint32_t attr{}; | 118 | uint32_t attr{}; |
| 119 | 119 | ||
| 120 | address = Convert<uint32_t>(GetReg32(system, 0)); | 120 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 121 | size = Convert<uint32_t>(GetReg32(system, 1)); | 121 | size = Convert<uint32_t>(GetArg32(args, 1)); |
| 122 | mask = Convert<uint32_t>(GetReg32(system, 2)); | 122 | mask = Convert<uint32_t>(GetArg32(args, 2)); |
| 123 | attr = Convert<uint32_t>(GetReg32(system, 3)); | 123 | attr = Convert<uint32_t>(GetArg32(args, 3)); |
| 124 | 124 | ||
| 125 | ret = SetMemoryAttribute64From32(system, address, size, mask, attr); | 125 | ret = SetMemoryAttribute64From32(system, address, size, mask, attr); |
| 126 | 126 | ||
| 127 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 127 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | static void SvcWrap_MapMemory64From32(Core::System& system) { | 130 | static void SvcWrap_MapMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 131 | Result ret{}; | 131 | Result ret{}; |
| 132 | 132 | ||
| 133 | uint32_t dst_address{}; | 133 | uint32_t dst_address{}; |
| 134 | uint32_t src_address{}; | 134 | uint32_t src_address{}; |
| 135 | uint32_t size{}; | 135 | uint32_t size{}; |
| 136 | 136 | ||
| 137 | dst_address = Convert<uint32_t>(GetReg32(system, 0)); | 137 | dst_address = Convert<uint32_t>(GetArg32(args, 0)); |
| 138 | src_address = Convert<uint32_t>(GetReg32(system, 1)); | 138 | src_address = Convert<uint32_t>(GetArg32(args, 1)); |
| 139 | size = Convert<uint32_t>(GetReg32(system, 2)); | 139 | size = Convert<uint32_t>(GetArg32(args, 2)); |
| 140 | 140 | ||
| 141 | ret = MapMemory64From32(system, dst_address, src_address, size); | 141 | ret = MapMemory64From32(system, dst_address, src_address, size); |
| 142 | 142 | ||
| 143 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 143 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | static void SvcWrap_UnmapMemory64From32(Core::System& system) { | 146 | static void SvcWrap_UnmapMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 147 | Result ret{}; | 147 | Result ret{}; |
| 148 | 148 | ||
| 149 | uint32_t dst_address{}; | 149 | uint32_t dst_address{}; |
| 150 | uint32_t src_address{}; | 150 | uint32_t src_address{}; |
| 151 | uint32_t size{}; | 151 | uint32_t size{}; |
| 152 | 152 | ||
| 153 | dst_address = Convert<uint32_t>(GetReg32(system, 0)); | 153 | dst_address = Convert<uint32_t>(GetArg32(args, 0)); |
| 154 | src_address = Convert<uint32_t>(GetReg32(system, 1)); | 154 | src_address = Convert<uint32_t>(GetArg32(args, 1)); |
| 155 | size = Convert<uint32_t>(GetReg32(system, 2)); | 155 | size = Convert<uint32_t>(GetArg32(args, 2)); |
| 156 | 156 | ||
| 157 | ret = UnmapMemory64From32(system, dst_address, src_address, size); | 157 | ret = UnmapMemory64From32(system, dst_address, src_address, size); |
| 158 | 158 | ||
| 159 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 159 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | static void SvcWrap_QueryMemory64From32(Core::System& system) { | 162 | static void SvcWrap_QueryMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 163 | Result ret{}; | 163 | Result ret{}; |
| 164 | 164 | ||
| 165 | PageInfo out_page_info{}; | 165 | PageInfo out_page_info{}; |
| 166 | uint32_t out_memory_info{}; | 166 | uint32_t out_memory_info{}; |
| 167 | uint32_t address{}; | 167 | uint32_t address{}; |
| 168 | 168 | ||
| 169 | out_memory_info = Convert<uint32_t>(GetReg32(system, 0)); | 169 | out_memory_info = Convert<uint32_t>(GetArg32(args, 0)); |
| 170 | address = Convert<uint32_t>(GetReg32(system, 2)); | 170 | address = Convert<uint32_t>(GetArg32(args, 2)); |
| 171 | 171 | ||
| 172 | ret = QueryMemory64From32(system, out_memory_info, std::addressof(out_page_info), address); | 172 | ret = QueryMemory64From32(system, out_memory_info, std::addressof(out_page_info), address); |
| 173 | 173 | ||
| 174 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 174 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 175 | SetReg32(system, 1, Convert<uint32_t>(out_page_info)); | 175 | SetArg32(args, 1, Convert<uint32_t>(out_page_info)); |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | static void SvcWrap_ExitProcess64From32(Core::System& system) { | 178 | static void SvcWrap_ExitProcess64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 179 | ExitProcess64From32(system); | 179 | ExitProcess64From32(system); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | static void SvcWrap_CreateThread64From32(Core::System& system) { | 182 | static void SvcWrap_CreateThread64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 183 | Result ret{}; | 183 | Result ret{}; |
| 184 | 184 | ||
| 185 | Handle out_handle{}; | 185 | Handle out_handle{}; |
| @@ -189,143 +189,143 @@ static void SvcWrap_CreateThread64From32(Core::System& system) { | |||
| 189 | int32_t priority{}; | 189 | int32_t priority{}; |
| 190 | int32_t core_id{}; | 190 | int32_t core_id{}; |
| 191 | 191 | ||
| 192 | func = Convert<uint32_t>(GetReg32(system, 1)); | 192 | func = Convert<uint32_t>(GetArg32(args, 1)); |
| 193 | arg = Convert<uint32_t>(GetReg32(system, 2)); | 193 | arg = Convert<uint32_t>(GetArg32(args, 2)); |
| 194 | stack_bottom = Convert<uint32_t>(GetReg32(system, 3)); | 194 | stack_bottom = Convert<uint32_t>(GetArg32(args, 3)); |
| 195 | priority = Convert<int32_t>(GetReg32(system, 0)); | 195 | priority = Convert<int32_t>(GetArg32(args, 0)); |
| 196 | core_id = Convert<int32_t>(GetReg32(system, 4)); | 196 | core_id = Convert<int32_t>(GetArg32(args, 4)); |
| 197 | 197 | ||
| 198 | ret = CreateThread64From32(system, std::addressof(out_handle), func, arg, stack_bottom, priority, core_id); | 198 | ret = CreateThread64From32(system, std::addressof(out_handle), func, arg, stack_bottom, priority, core_id); |
| 199 | 199 | ||
| 200 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 200 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 201 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 201 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | static void SvcWrap_StartThread64From32(Core::System& system) { | 204 | static void SvcWrap_StartThread64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 205 | Result ret{}; | 205 | Result ret{}; |
| 206 | 206 | ||
| 207 | Handle thread_handle{}; | 207 | Handle thread_handle{}; |
| 208 | 208 | ||
| 209 | thread_handle = Convert<Handle>(GetReg32(system, 0)); | 209 | thread_handle = Convert<Handle>(GetArg32(args, 0)); |
| 210 | 210 | ||
| 211 | ret = StartThread64From32(system, thread_handle); | 211 | ret = StartThread64From32(system, thread_handle); |
| 212 | 212 | ||
| 213 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 213 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | static void SvcWrap_ExitThread64From32(Core::System& system) { | 216 | static void SvcWrap_ExitThread64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 217 | ExitThread64From32(system); | 217 | ExitThread64From32(system); |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | static void SvcWrap_SleepThread64From32(Core::System& system) { | 220 | static void SvcWrap_SleepThread64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 221 | int64_t ns{}; | 221 | int64_t ns{}; |
| 222 | 222 | ||
| 223 | std::array<uint32_t, 2> ns_gather{}; | 223 | std::array<uint32_t, 2> ns_gather{}; |
| 224 | ns_gather[0] = GetReg32(system, 0); | 224 | ns_gather[0] = GetArg32(args, 0); |
| 225 | ns_gather[1] = GetReg32(system, 1); | 225 | ns_gather[1] = GetArg32(args, 1); |
| 226 | ns = Convert<int64_t>(ns_gather); | 226 | ns = Convert<int64_t>(ns_gather); |
| 227 | 227 | ||
| 228 | SleepThread64From32(system, ns); | 228 | SleepThread64From32(system, ns); |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | static void SvcWrap_GetThreadPriority64From32(Core::System& system) { | 231 | static void SvcWrap_GetThreadPriority64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 232 | Result ret{}; | 232 | Result ret{}; |
| 233 | 233 | ||
| 234 | int32_t out_priority{}; | 234 | int32_t out_priority{}; |
| 235 | Handle thread_handle{}; | 235 | Handle thread_handle{}; |
| 236 | 236 | ||
| 237 | thread_handle = Convert<Handle>(GetReg32(system, 1)); | 237 | thread_handle = Convert<Handle>(GetArg32(args, 1)); |
| 238 | 238 | ||
| 239 | ret = GetThreadPriority64From32(system, std::addressof(out_priority), thread_handle); | 239 | ret = GetThreadPriority64From32(system, std::addressof(out_priority), thread_handle); |
| 240 | 240 | ||
| 241 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 241 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 242 | SetReg32(system, 1, Convert<uint32_t>(out_priority)); | 242 | SetArg32(args, 1, Convert<uint32_t>(out_priority)); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | static void SvcWrap_SetThreadPriority64From32(Core::System& system) { | 245 | static void SvcWrap_SetThreadPriority64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 246 | Result ret{}; | 246 | Result ret{}; |
| 247 | 247 | ||
| 248 | Handle thread_handle{}; | 248 | Handle thread_handle{}; |
| 249 | int32_t priority{}; | 249 | int32_t priority{}; |
| 250 | 250 | ||
| 251 | thread_handle = Convert<Handle>(GetReg32(system, 0)); | 251 | thread_handle = Convert<Handle>(GetArg32(args, 0)); |
| 252 | priority = Convert<int32_t>(GetReg32(system, 1)); | 252 | priority = Convert<int32_t>(GetArg32(args, 1)); |
| 253 | 253 | ||
| 254 | ret = SetThreadPriority64From32(system, thread_handle, priority); | 254 | ret = SetThreadPriority64From32(system, thread_handle, priority); |
| 255 | 255 | ||
| 256 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 256 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | static void SvcWrap_GetThreadCoreMask64From32(Core::System& system) { | 259 | static void SvcWrap_GetThreadCoreMask64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 260 | Result ret{}; | 260 | Result ret{}; |
| 261 | 261 | ||
| 262 | int32_t out_core_id{}; | 262 | int32_t out_core_id{}; |
| 263 | uint64_t out_affinity_mask{}; | 263 | uint64_t out_affinity_mask{}; |
| 264 | Handle thread_handle{}; | 264 | Handle thread_handle{}; |
| 265 | 265 | ||
| 266 | thread_handle = Convert<Handle>(GetReg32(system, 2)); | 266 | thread_handle = Convert<Handle>(GetArg32(args, 2)); |
| 267 | 267 | ||
| 268 | ret = GetThreadCoreMask64From32(system, std::addressof(out_core_id), std::addressof(out_affinity_mask), thread_handle); | 268 | ret = GetThreadCoreMask64From32(system, std::addressof(out_core_id), std::addressof(out_affinity_mask), thread_handle); |
| 269 | 269 | ||
| 270 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 270 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 271 | SetReg32(system, 1, Convert<uint32_t>(out_core_id)); | 271 | SetArg32(args, 1, Convert<uint32_t>(out_core_id)); |
| 272 | auto out_affinity_mask_scatter = Convert<std::array<uint32_t, 2>>(out_affinity_mask); | 272 | auto out_affinity_mask_scatter = Convert<std::array<uint32_t, 2>>(out_affinity_mask); |
| 273 | SetReg32(system, 2, out_affinity_mask_scatter[0]); | 273 | SetArg32(args, 2, out_affinity_mask_scatter[0]); |
| 274 | SetReg32(system, 3, out_affinity_mask_scatter[1]); | 274 | SetArg32(args, 3, out_affinity_mask_scatter[1]); |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | static void SvcWrap_SetThreadCoreMask64From32(Core::System& system) { | 277 | static void SvcWrap_SetThreadCoreMask64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 278 | Result ret{}; | 278 | Result ret{}; |
| 279 | 279 | ||
| 280 | Handle thread_handle{}; | 280 | Handle thread_handle{}; |
| 281 | int32_t core_id{}; | 281 | int32_t core_id{}; |
| 282 | uint64_t affinity_mask{}; | 282 | uint64_t affinity_mask{}; |
| 283 | 283 | ||
| 284 | thread_handle = Convert<Handle>(GetReg32(system, 0)); | 284 | thread_handle = Convert<Handle>(GetArg32(args, 0)); |
| 285 | core_id = Convert<int32_t>(GetReg32(system, 1)); | 285 | core_id = Convert<int32_t>(GetArg32(args, 1)); |
| 286 | std::array<uint32_t, 2> affinity_mask_gather{}; | 286 | std::array<uint32_t, 2> affinity_mask_gather{}; |
| 287 | affinity_mask_gather[0] = GetReg32(system, 2); | 287 | affinity_mask_gather[0] = GetArg32(args, 2); |
| 288 | affinity_mask_gather[1] = GetReg32(system, 3); | 288 | affinity_mask_gather[1] = GetArg32(args, 3); |
| 289 | affinity_mask = Convert<uint64_t>(affinity_mask_gather); | 289 | affinity_mask = Convert<uint64_t>(affinity_mask_gather); |
| 290 | 290 | ||
| 291 | ret = SetThreadCoreMask64From32(system, thread_handle, core_id, affinity_mask); | 291 | ret = SetThreadCoreMask64From32(system, thread_handle, core_id, affinity_mask); |
| 292 | 292 | ||
| 293 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 293 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | static void SvcWrap_GetCurrentProcessorNumber64From32(Core::System& system) { | 296 | static void SvcWrap_GetCurrentProcessorNumber64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 297 | int32_t ret{}; | 297 | int32_t ret{}; |
| 298 | 298 | ||
| 299 | ret = GetCurrentProcessorNumber64From32(system); | 299 | ret = GetCurrentProcessorNumber64From32(system); |
| 300 | 300 | ||
| 301 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 301 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | static void SvcWrap_SignalEvent64From32(Core::System& system) { | 304 | static void SvcWrap_SignalEvent64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 305 | Result ret{}; | 305 | Result ret{}; |
| 306 | 306 | ||
| 307 | Handle event_handle{}; | 307 | Handle event_handle{}; |
| 308 | 308 | ||
| 309 | event_handle = Convert<Handle>(GetReg32(system, 0)); | 309 | event_handle = Convert<Handle>(GetArg32(args, 0)); |
| 310 | 310 | ||
| 311 | ret = SignalEvent64From32(system, event_handle); | 311 | ret = SignalEvent64From32(system, event_handle); |
| 312 | 312 | ||
| 313 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 313 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | static void SvcWrap_ClearEvent64From32(Core::System& system) { | 316 | static void SvcWrap_ClearEvent64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 317 | Result ret{}; | 317 | Result ret{}; |
| 318 | 318 | ||
| 319 | Handle event_handle{}; | 319 | Handle event_handle{}; |
| 320 | 320 | ||
| 321 | event_handle = Convert<Handle>(GetReg32(system, 0)); | 321 | event_handle = Convert<Handle>(GetArg32(args, 0)); |
| 322 | 322 | ||
| 323 | ret = ClearEvent64From32(system, event_handle); | 323 | ret = ClearEvent64From32(system, event_handle); |
| 324 | 324 | ||
| 325 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 325 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | static void SvcWrap_MapSharedMemory64From32(Core::System& system) { | 328 | static void SvcWrap_MapSharedMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 329 | Result ret{}; | 329 | Result ret{}; |
| 330 | 330 | ||
| 331 | Handle shmem_handle{}; | 331 | Handle shmem_handle{}; |
| @@ -333,33 +333,33 @@ static void SvcWrap_MapSharedMemory64From32(Core::System& system) { | |||
| 333 | uint32_t size{}; | 333 | uint32_t size{}; |
| 334 | MemoryPermission map_perm{}; | 334 | MemoryPermission map_perm{}; |
| 335 | 335 | ||
| 336 | shmem_handle = Convert<Handle>(GetReg32(system, 0)); | 336 | shmem_handle = Convert<Handle>(GetArg32(args, 0)); |
| 337 | address = Convert<uint32_t>(GetReg32(system, 1)); | 337 | address = Convert<uint32_t>(GetArg32(args, 1)); |
| 338 | size = Convert<uint32_t>(GetReg32(system, 2)); | 338 | size = Convert<uint32_t>(GetArg32(args, 2)); |
| 339 | map_perm = Convert<MemoryPermission>(GetReg32(system, 3)); | 339 | map_perm = Convert<MemoryPermission>(GetArg32(args, 3)); |
| 340 | 340 | ||
| 341 | ret = MapSharedMemory64From32(system, shmem_handle, address, size, map_perm); | 341 | ret = MapSharedMemory64From32(system, shmem_handle, address, size, map_perm); |
| 342 | 342 | ||
| 343 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 343 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 344 | } | 344 | } |
| 345 | 345 | ||
| 346 | static void SvcWrap_UnmapSharedMemory64From32(Core::System& system) { | 346 | static void SvcWrap_UnmapSharedMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 347 | Result ret{}; | 347 | Result ret{}; |
| 348 | 348 | ||
| 349 | Handle shmem_handle{}; | 349 | Handle shmem_handle{}; |
| 350 | uint32_t address{}; | 350 | uint32_t address{}; |
| 351 | uint32_t size{}; | 351 | uint32_t size{}; |
| 352 | 352 | ||
| 353 | shmem_handle = Convert<Handle>(GetReg32(system, 0)); | 353 | shmem_handle = Convert<Handle>(GetArg32(args, 0)); |
| 354 | address = Convert<uint32_t>(GetReg32(system, 1)); | 354 | address = Convert<uint32_t>(GetArg32(args, 1)); |
| 355 | size = Convert<uint32_t>(GetReg32(system, 2)); | 355 | size = Convert<uint32_t>(GetArg32(args, 2)); |
| 356 | 356 | ||
| 357 | ret = UnmapSharedMemory64From32(system, shmem_handle, address, size); | 357 | ret = UnmapSharedMemory64From32(system, shmem_handle, address, size); |
| 358 | 358 | ||
| 359 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 359 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | static void SvcWrap_CreateTransferMemory64From32(Core::System& system) { | 362 | static void SvcWrap_CreateTransferMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 363 | Result ret{}; | 363 | Result ret{}; |
| 364 | 364 | ||
| 365 | Handle out_handle{}; | 365 | Handle out_handle{}; |
| @@ -367,41 +367,41 @@ static void SvcWrap_CreateTransferMemory64From32(Core::System& system) { | |||
| 367 | uint32_t size{}; | 367 | uint32_t size{}; |
| 368 | MemoryPermission map_perm{}; | 368 | MemoryPermission map_perm{}; |
| 369 | 369 | ||
| 370 | address = Convert<uint32_t>(GetReg32(system, 1)); | 370 | address = Convert<uint32_t>(GetArg32(args, 1)); |
| 371 | size = Convert<uint32_t>(GetReg32(system, 2)); | 371 | size = Convert<uint32_t>(GetArg32(args, 2)); |
| 372 | map_perm = Convert<MemoryPermission>(GetReg32(system, 3)); | 372 | map_perm = Convert<MemoryPermission>(GetArg32(args, 3)); |
| 373 | 373 | ||
| 374 | ret = CreateTransferMemory64From32(system, std::addressof(out_handle), address, size, map_perm); | 374 | ret = CreateTransferMemory64From32(system, std::addressof(out_handle), address, size, map_perm); |
| 375 | 375 | ||
| 376 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 376 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 377 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 377 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | static void SvcWrap_CloseHandle64From32(Core::System& system) { | 380 | static void SvcWrap_CloseHandle64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 381 | Result ret{}; | 381 | Result ret{}; |
| 382 | 382 | ||
| 383 | Handle handle{}; | 383 | Handle handle{}; |
| 384 | 384 | ||
| 385 | handle = Convert<Handle>(GetReg32(system, 0)); | 385 | handle = Convert<Handle>(GetArg32(args, 0)); |
| 386 | 386 | ||
| 387 | ret = CloseHandle64From32(system, handle); | 387 | ret = CloseHandle64From32(system, handle); |
| 388 | 388 | ||
| 389 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 389 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 390 | } | 390 | } |
| 391 | 391 | ||
| 392 | static void SvcWrap_ResetSignal64From32(Core::System& system) { | 392 | static void SvcWrap_ResetSignal64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 393 | Result ret{}; | 393 | Result ret{}; |
| 394 | 394 | ||
| 395 | Handle handle{}; | 395 | Handle handle{}; |
| 396 | 396 | ||
| 397 | handle = Convert<Handle>(GetReg32(system, 0)); | 397 | handle = Convert<Handle>(GetArg32(args, 0)); |
| 398 | 398 | ||
| 399 | ret = ResetSignal64From32(system, handle); | 399 | ret = ResetSignal64From32(system, handle); |
| 400 | 400 | ||
| 401 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 401 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 402 | } | 402 | } |
| 403 | 403 | ||
| 404 | static void SvcWrap_WaitSynchronization64From32(Core::System& system) { | 404 | static void SvcWrap_WaitSynchronization64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 405 | Result ret{}; | 405 | Result ret{}; |
| 406 | 406 | ||
| 407 | int32_t out_index{}; | 407 | int32_t out_index{}; |
| @@ -409,60 +409,60 @@ static void SvcWrap_WaitSynchronization64From32(Core::System& system) { | |||
| 409 | int32_t num_handles{}; | 409 | int32_t num_handles{}; |
| 410 | int64_t timeout_ns{}; | 410 | int64_t timeout_ns{}; |
| 411 | 411 | ||
| 412 | handles = Convert<uint32_t>(GetReg32(system, 1)); | 412 | handles = Convert<uint32_t>(GetArg32(args, 1)); |
| 413 | num_handles = Convert<int32_t>(GetReg32(system, 2)); | 413 | num_handles = Convert<int32_t>(GetArg32(args, 2)); |
| 414 | std::array<uint32_t, 2> timeout_ns_gather{}; | 414 | std::array<uint32_t, 2> timeout_ns_gather{}; |
| 415 | timeout_ns_gather[0] = GetReg32(system, 0); | 415 | timeout_ns_gather[0] = GetArg32(args, 0); |
| 416 | timeout_ns_gather[1] = GetReg32(system, 3); | 416 | timeout_ns_gather[1] = GetArg32(args, 3); |
| 417 | timeout_ns = Convert<int64_t>(timeout_ns_gather); | 417 | timeout_ns = Convert<int64_t>(timeout_ns_gather); |
| 418 | 418 | ||
| 419 | ret = WaitSynchronization64From32(system, std::addressof(out_index), handles, num_handles, timeout_ns); | 419 | ret = WaitSynchronization64From32(system, std::addressof(out_index), handles, num_handles, timeout_ns); |
| 420 | 420 | ||
| 421 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 421 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 422 | SetReg32(system, 1, Convert<uint32_t>(out_index)); | 422 | SetArg32(args, 1, Convert<uint32_t>(out_index)); |
| 423 | } | 423 | } |
| 424 | 424 | ||
| 425 | static void SvcWrap_CancelSynchronization64From32(Core::System& system) { | 425 | static void SvcWrap_CancelSynchronization64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 426 | Result ret{}; | 426 | Result ret{}; |
| 427 | 427 | ||
| 428 | Handle handle{}; | 428 | Handle handle{}; |
| 429 | 429 | ||
| 430 | handle = Convert<Handle>(GetReg32(system, 0)); | 430 | handle = Convert<Handle>(GetArg32(args, 0)); |
| 431 | 431 | ||
| 432 | ret = CancelSynchronization64From32(system, handle); | 432 | ret = CancelSynchronization64From32(system, handle); |
| 433 | 433 | ||
| 434 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 434 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | static void SvcWrap_ArbitrateLock64From32(Core::System& system) { | 437 | static void SvcWrap_ArbitrateLock64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 438 | Result ret{}; | 438 | Result ret{}; |
| 439 | 439 | ||
| 440 | Handle thread_handle{}; | 440 | Handle thread_handle{}; |
| 441 | uint32_t address{}; | 441 | uint32_t address{}; |
| 442 | uint32_t tag{}; | 442 | uint32_t tag{}; |
| 443 | 443 | ||
| 444 | thread_handle = Convert<Handle>(GetReg32(system, 0)); | 444 | thread_handle = Convert<Handle>(GetArg32(args, 0)); |
| 445 | address = Convert<uint32_t>(GetReg32(system, 1)); | 445 | address = Convert<uint32_t>(GetArg32(args, 1)); |
| 446 | tag = Convert<uint32_t>(GetReg32(system, 2)); | 446 | tag = Convert<uint32_t>(GetArg32(args, 2)); |
| 447 | 447 | ||
| 448 | ret = ArbitrateLock64From32(system, thread_handle, address, tag); | 448 | ret = ArbitrateLock64From32(system, thread_handle, address, tag); |
| 449 | 449 | ||
| 450 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 450 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 451 | } | 451 | } |
| 452 | 452 | ||
| 453 | static void SvcWrap_ArbitrateUnlock64From32(Core::System& system) { | 453 | static void SvcWrap_ArbitrateUnlock64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 454 | Result ret{}; | 454 | Result ret{}; |
| 455 | 455 | ||
| 456 | uint32_t address{}; | 456 | uint32_t address{}; |
| 457 | 457 | ||
| 458 | address = Convert<uint32_t>(GetReg32(system, 0)); | 458 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 459 | 459 | ||
| 460 | ret = ArbitrateUnlock64From32(system, address); | 460 | ret = ArbitrateUnlock64From32(system, address); |
| 461 | 461 | ||
| 462 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 462 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 463 | } | 463 | } |
| 464 | 464 | ||
| 465 | static void SvcWrap_WaitProcessWideKeyAtomic64From32(Core::System& system) { | 465 | static void SvcWrap_WaitProcessWideKeyAtomic64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 466 | Result ret{}; | 466 | Result ret{}; |
| 467 | 467 | ||
| 468 | uint32_t address{}; | 468 | uint32_t address{}; |
| @@ -470,82 +470,82 @@ static void SvcWrap_WaitProcessWideKeyAtomic64From32(Core::System& system) { | |||
| 470 | uint32_t tag{}; | 470 | uint32_t tag{}; |
| 471 | int64_t timeout_ns{}; | 471 | int64_t timeout_ns{}; |
| 472 | 472 | ||
| 473 | address = Convert<uint32_t>(GetReg32(system, 0)); | 473 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 474 | cv_key = Convert<uint32_t>(GetReg32(system, 1)); | 474 | cv_key = Convert<uint32_t>(GetArg32(args, 1)); |
| 475 | tag = Convert<uint32_t>(GetReg32(system, 2)); | 475 | tag = Convert<uint32_t>(GetArg32(args, 2)); |
| 476 | std::array<uint32_t, 2> timeout_ns_gather{}; | 476 | std::array<uint32_t, 2> timeout_ns_gather{}; |
| 477 | timeout_ns_gather[0] = GetReg32(system, 3); | 477 | timeout_ns_gather[0] = GetArg32(args, 3); |
| 478 | timeout_ns_gather[1] = GetReg32(system, 4); | 478 | timeout_ns_gather[1] = GetArg32(args, 4); |
| 479 | timeout_ns = Convert<int64_t>(timeout_ns_gather); | 479 | timeout_ns = Convert<int64_t>(timeout_ns_gather); |
| 480 | 480 | ||
| 481 | ret = WaitProcessWideKeyAtomic64From32(system, address, cv_key, tag, timeout_ns); | 481 | ret = WaitProcessWideKeyAtomic64From32(system, address, cv_key, tag, timeout_ns); |
| 482 | 482 | ||
| 483 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 483 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 484 | } | 484 | } |
| 485 | 485 | ||
| 486 | static void SvcWrap_SignalProcessWideKey64From32(Core::System& system) { | 486 | static void SvcWrap_SignalProcessWideKey64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 487 | uint32_t cv_key{}; | 487 | uint32_t cv_key{}; |
| 488 | int32_t count{}; | 488 | int32_t count{}; |
| 489 | 489 | ||
| 490 | cv_key = Convert<uint32_t>(GetReg32(system, 0)); | 490 | cv_key = Convert<uint32_t>(GetArg32(args, 0)); |
| 491 | count = Convert<int32_t>(GetReg32(system, 1)); | 491 | count = Convert<int32_t>(GetArg32(args, 1)); |
| 492 | 492 | ||
| 493 | SignalProcessWideKey64From32(system, cv_key, count); | 493 | SignalProcessWideKey64From32(system, cv_key, count); |
| 494 | } | 494 | } |
| 495 | 495 | ||
| 496 | static void SvcWrap_GetSystemTick64From32(Core::System& system) { | 496 | static void SvcWrap_GetSystemTick64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 497 | int64_t ret{}; | 497 | int64_t ret{}; |
| 498 | 498 | ||
| 499 | ret = GetSystemTick64From32(system); | 499 | ret = GetSystemTick64From32(system); |
| 500 | 500 | ||
| 501 | auto ret_scatter = Convert<std::array<uint32_t, 2>>(ret); | 501 | auto ret_scatter = Convert<std::array<uint32_t, 2>>(ret); |
| 502 | SetReg32(system, 0, ret_scatter[0]); | 502 | SetArg32(args, 0, ret_scatter[0]); |
| 503 | SetReg32(system, 1, ret_scatter[1]); | 503 | SetArg32(args, 1, ret_scatter[1]); |
| 504 | } | 504 | } |
| 505 | 505 | ||
| 506 | static void SvcWrap_ConnectToNamedPort64From32(Core::System& system) { | 506 | static void SvcWrap_ConnectToNamedPort64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 507 | Result ret{}; | 507 | Result ret{}; |
| 508 | 508 | ||
| 509 | Handle out_handle{}; | 509 | Handle out_handle{}; |
| 510 | uint32_t name{}; | 510 | uint32_t name{}; |
| 511 | 511 | ||
| 512 | name = Convert<uint32_t>(GetReg32(system, 1)); | 512 | name = Convert<uint32_t>(GetArg32(args, 1)); |
| 513 | 513 | ||
| 514 | ret = ConnectToNamedPort64From32(system, std::addressof(out_handle), name); | 514 | ret = ConnectToNamedPort64From32(system, std::addressof(out_handle), name); |
| 515 | 515 | ||
| 516 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 516 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 517 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 517 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 518 | } | 518 | } |
| 519 | 519 | ||
| 520 | static void SvcWrap_SendSyncRequest64From32(Core::System& system) { | 520 | static void SvcWrap_SendSyncRequest64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 521 | Result ret{}; | 521 | Result ret{}; |
| 522 | 522 | ||
| 523 | Handle session_handle{}; | 523 | Handle session_handle{}; |
| 524 | 524 | ||
| 525 | session_handle = Convert<Handle>(GetReg32(system, 0)); | 525 | session_handle = Convert<Handle>(GetArg32(args, 0)); |
| 526 | 526 | ||
| 527 | ret = SendSyncRequest64From32(system, session_handle); | 527 | ret = SendSyncRequest64From32(system, session_handle); |
| 528 | 528 | ||
| 529 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 529 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 530 | } | 530 | } |
| 531 | 531 | ||
| 532 | static void SvcWrap_SendSyncRequestWithUserBuffer64From32(Core::System& system) { | 532 | static void SvcWrap_SendSyncRequestWithUserBuffer64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 533 | Result ret{}; | 533 | Result ret{}; |
| 534 | 534 | ||
| 535 | uint32_t message_buffer{}; | 535 | uint32_t message_buffer{}; |
| 536 | uint32_t message_buffer_size{}; | 536 | uint32_t message_buffer_size{}; |
| 537 | Handle session_handle{}; | 537 | Handle session_handle{}; |
| 538 | 538 | ||
| 539 | message_buffer = Convert<uint32_t>(GetReg32(system, 0)); | 539 | message_buffer = Convert<uint32_t>(GetArg32(args, 0)); |
| 540 | message_buffer_size = Convert<uint32_t>(GetReg32(system, 1)); | 540 | message_buffer_size = Convert<uint32_t>(GetArg32(args, 1)); |
| 541 | session_handle = Convert<Handle>(GetReg32(system, 2)); | 541 | session_handle = Convert<Handle>(GetArg32(args, 2)); |
| 542 | 542 | ||
| 543 | ret = SendSyncRequestWithUserBuffer64From32(system, message_buffer, message_buffer_size, session_handle); | 543 | ret = SendSyncRequestWithUserBuffer64From32(system, message_buffer, message_buffer_size, session_handle); |
| 544 | 544 | ||
| 545 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 545 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 546 | } | 546 | } |
| 547 | 547 | ||
| 548 | static void SvcWrap_SendAsyncRequestWithUserBuffer64From32(Core::System& system) { | 548 | static void SvcWrap_SendAsyncRequestWithUserBuffer64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 549 | Result ret{}; | 549 | Result ret{}; |
| 550 | 550 | ||
| 551 | Handle out_event_handle{}; | 551 | Handle out_event_handle{}; |
| @@ -553,83 +553,83 @@ static void SvcWrap_SendAsyncRequestWithUserBuffer64From32(Core::System& system) | |||
| 553 | uint32_t message_buffer_size{}; | 553 | uint32_t message_buffer_size{}; |
| 554 | Handle session_handle{}; | 554 | Handle session_handle{}; |
| 555 | 555 | ||
| 556 | message_buffer = Convert<uint32_t>(GetReg32(system, 1)); | 556 | message_buffer = Convert<uint32_t>(GetArg32(args, 1)); |
| 557 | message_buffer_size = Convert<uint32_t>(GetReg32(system, 2)); | 557 | message_buffer_size = Convert<uint32_t>(GetArg32(args, 2)); |
| 558 | session_handle = Convert<Handle>(GetReg32(system, 3)); | 558 | session_handle = Convert<Handle>(GetArg32(args, 3)); |
| 559 | 559 | ||
| 560 | ret = SendAsyncRequestWithUserBuffer64From32(system, std::addressof(out_event_handle), message_buffer, message_buffer_size, session_handle); | 560 | ret = SendAsyncRequestWithUserBuffer64From32(system, std::addressof(out_event_handle), message_buffer, message_buffer_size, session_handle); |
| 561 | 561 | ||
| 562 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 562 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 563 | SetReg32(system, 1, Convert<uint32_t>(out_event_handle)); | 563 | SetArg32(args, 1, Convert<uint32_t>(out_event_handle)); |
| 564 | } | 564 | } |
| 565 | 565 | ||
| 566 | static void SvcWrap_GetProcessId64From32(Core::System& system) { | 566 | static void SvcWrap_GetProcessId64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 567 | Result ret{}; | 567 | Result ret{}; |
| 568 | 568 | ||
| 569 | uint64_t out_process_id{}; | 569 | uint64_t out_process_id{}; |
| 570 | Handle process_handle{}; | 570 | Handle process_handle{}; |
| 571 | 571 | ||
| 572 | process_handle = Convert<Handle>(GetReg32(system, 1)); | 572 | process_handle = Convert<Handle>(GetArg32(args, 1)); |
| 573 | 573 | ||
| 574 | ret = GetProcessId64From32(system, std::addressof(out_process_id), process_handle); | 574 | ret = GetProcessId64From32(system, std::addressof(out_process_id), process_handle); |
| 575 | 575 | ||
| 576 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 576 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 577 | auto out_process_id_scatter = Convert<std::array<uint32_t, 2>>(out_process_id); | 577 | auto out_process_id_scatter = Convert<std::array<uint32_t, 2>>(out_process_id); |
| 578 | SetReg32(system, 1, out_process_id_scatter[0]); | 578 | SetArg32(args, 1, out_process_id_scatter[0]); |
| 579 | SetReg32(system, 2, out_process_id_scatter[1]); | 579 | SetArg32(args, 2, out_process_id_scatter[1]); |
| 580 | } | 580 | } |
| 581 | 581 | ||
| 582 | static void SvcWrap_GetThreadId64From32(Core::System& system) { | 582 | static void SvcWrap_GetThreadId64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 583 | Result ret{}; | 583 | Result ret{}; |
| 584 | 584 | ||
| 585 | uint64_t out_thread_id{}; | 585 | uint64_t out_thread_id{}; |
| 586 | Handle thread_handle{}; | 586 | Handle thread_handle{}; |
| 587 | 587 | ||
| 588 | thread_handle = Convert<Handle>(GetReg32(system, 1)); | 588 | thread_handle = Convert<Handle>(GetArg32(args, 1)); |
| 589 | 589 | ||
| 590 | ret = GetThreadId64From32(system, std::addressof(out_thread_id), thread_handle); | 590 | ret = GetThreadId64From32(system, std::addressof(out_thread_id), thread_handle); |
| 591 | 591 | ||
| 592 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 592 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 593 | auto out_thread_id_scatter = Convert<std::array<uint32_t, 2>>(out_thread_id); | 593 | auto out_thread_id_scatter = Convert<std::array<uint32_t, 2>>(out_thread_id); |
| 594 | SetReg32(system, 1, out_thread_id_scatter[0]); | 594 | SetArg32(args, 1, out_thread_id_scatter[0]); |
| 595 | SetReg32(system, 2, out_thread_id_scatter[1]); | 595 | SetArg32(args, 2, out_thread_id_scatter[1]); |
| 596 | } | 596 | } |
| 597 | 597 | ||
| 598 | static void SvcWrap_Break64From32(Core::System& system) { | 598 | static void SvcWrap_Break64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 599 | BreakReason break_reason{}; | 599 | BreakReason break_reason{}; |
| 600 | uint32_t arg{}; | 600 | uint32_t arg{}; |
| 601 | uint32_t size{}; | 601 | uint32_t size{}; |
| 602 | 602 | ||
| 603 | break_reason = Convert<BreakReason>(GetReg32(system, 0)); | 603 | break_reason = Convert<BreakReason>(GetArg32(args, 0)); |
| 604 | arg = Convert<uint32_t>(GetReg32(system, 1)); | 604 | arg = Convert<uint32_t>(GetArg32(args, 1)); |
| 605 | size = Convert<uint32_t>(GetReg32(system, 2)); | 605 | size = Convert<uint32_t>(GetArg32(args, 2)); |
| 606 | 606 | ||
| 607 | Break64From32(system, break_reason, arg, size); | 607 | Break64From32(system, break_reason, arg, size); |
| 608 | } | 608 | } |
| 609 | 609 | ||
| 610 | static void SvcWrap_OutputDebugString64From32(Core::System& system) { | 610 | static void SvcWrap_OutputDebugString64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 611 | Result ret{}; | 611 | Result ret{}; |
| 612 | 612 | ||
| 613 | uint32_t debug_str{}; | 613 | uint32_t debug_str{}; |
| 614 | uint32_t len{}; | 614 | uint32_t len{}; |
| 615 | 615 | ||
| 616 | debug_str = Convert<uint32_t>(GetReg32(system, 0)); | 616 | debug_str = Convert<uint32_t>(GetArg32(args, 0)); |
| 617 | len = Convert<uint32_t>(GetReg32(system, 1)); | 617 | len = Convert<uint32_t>(GetArg32(args, 1)); |
| 618 | 618 | ||
| 619 | ret = OutputDebugString64From32(system, debug_str, len); | 619 | ret = OutputDebugString64From32(system, debug_str, len); |
| 620 | 620 | ||
| 621 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 621 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 622 | } | 622 | } |
| 623 | 623 | ||
| 624 | static void SvcWrap_ReturnFromException64From32(Core::System& system) { | 624 | static void SvcWrap_ReturnFromException64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 625 | Result result{}; | 625 | Result result{}; |
| 626 | 626 | ||
| 627 | result = Convert<Result>(GetReg32(system, 0)); | 627 | result = Convert<Result>(GetArg32(args, 0)); |
| 628 | 628 | ||
| 629 | ReturnFromException64From32(system, result); | 629 | ReturnFromException64From32(system, result); |
| 630 | } | 630 | } |
| 631 | 631 | ||
| 632 | static void SvcWrap_GetInfo64From32(Core::System& system) { | 632 | static void SvcWrap_GetInfo64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 633 | Result ret{}; | 633 | Result ret{}; |
| 634 | 634 | ||
| 635 | uint64_t out{}; | 635 | uint64_t out{}; |
| @@ -637,68 +637,68 @@ static void SvcWrap_GetInfo64From32(Core::System& system) { | |||
| 637 | Handle handle{}; | 637 | Handle handle{}; |
| 638 | uint64_t info_subtype{}; | 638 | uint64_t info_subtype{}; |
| 639 | 639 | ||
| 640 | info_type = Convert<InfoType>(GetReg32(system, 1)); | 640 | info_type = Convert<InfoType>(GetArg32(args, 1)); |
| 641 | handle = Convert<Handle>(GetReg32(system, 2)); | 641 | handle = Convert<Handle>(GetArg32(args, 2)); |
| 642 | std::array<uint32_t, 2> info_subtype_gather{}; | 642 | std::array<uint32_t, 2> info_subtype_gather{}; |
| 643 | info_subtype_gather[0] = GetReg32(system, 0); | 643 | info_subtype_gather[0] = GetArg32(args, 0); |
| 644 | info_subtype_gather[1] = GetReg32(system, 3); | 644 | info_subtype_gather[1] = GetArg32(args, 3); |
| 645 | info_subtype = Convert<uint64_t>(info_subtype_gather); | 645 | info_subtype = Convert<uint64_t>(info_subtype_gather); |
| 646 | 646 | ||
| 647 | ret = GetInfo64From32(system, std::addressof(out), info_type, handle, info_subtype); | 647 | ret = GetInfo64From32(system, std::addressof(out), info_type, handle, info_subtype); |
| 648 | 648 | ||
| 649 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 649 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 650 | auto out_scatter = Convert<std::array<uint32_t, 2>>(out); | 650 | auto out_scatter = Convert<std::array<uint32_t, 2>>(out); |
| 651 | SetReg32(system, 1, out_scatter[0]); | 651 | SetArg32(args, 1, out_scatter[0]); |
| 652 | SetReg32(system, 2, out_scatter[1]); | 652 | SetArg32(args, 2, out_scatter[1]); |
| 653 | } | 653 | } |
| 654 | 654 | ||
| 655 | static void SvcWrap_FlushEntireDataCache64From32(Core::System& system) { | 655 | static void SvcWrap_FlushEntireDataCache64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 656 | FlushEntireDataCache64From32(system); | 656 | FlushEntireDataCache64From32(system); |
| 657 | } | 657 | } |
| 658 | 658 | ||
| 659 | static void SvcWrap_FlushDataCache64From32(Core::System& system) { | 659 | static void SvcWrap_FlushDataCache64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 660 | Result ret{}; | 660 | Result ret{}; |
| 661 | 661 | ||
| 662 | uint32_t address{}; | 662 | uint32_t address{}; |
| 663 | uint32_t size{}; | 663 | uint32_t size{}; |
| 664 | 664 | ||
| 665 | address = Convert<uint32_t>(GetReg32(system, 0)); | 665 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 666 | size = Convert<uint32_t>(GetReg32(system, 1)); | 666 | size = Convert<uint32_t>(GetArg32(args, 1)); |
| 667 | 667 | ||
| 668 | ret = FlushDataCache64From32(system, address, size); | 668 | ret = FlushDataCache64From32(system, address, size); |
| 669 | 669 | ||
| 670 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 670 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 671 | } | 671 | } |
| 672 | 672 | ||
| 673 | static void SvcWrap_MapPhysicalMemory64From32(Core::System& system) { | 673 | static void SvcWrap_MapPhysicalMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 674 | Result ret{}; | 674 | Result ret{}; |
| 675 | 675 | ||
| 676 | uint32_t address{}; | 676 | uint32_t address{}; |
| 677 | uint32_t size{}; | 677 | uint32_t size{}; |
| 678 | 678 | ||
| 679 | address = Convert<uint32_t>(GetReg32(system, 0)); | 679 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 680 | size = Convert<uint32_t>(GetReg32(system, 1)); | 680 | size = Convert<uint32_t>(GetArg32(args, 1)); |
| 681 | 681 | ||
| 682 | ret = MapPhysicalMemory64From32(system, address, size); | 682 | ret = MapPhysicalMemory64From32(system, address, size); |
| 683 | 683 | ||
| 684 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 684 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 685 | } | 685 | } |
| 686 | 686 | ||
| 687 | static void SvcWrap_UnmapPhysicalMemory64From32(Core::System& system) { | 687 | static void SvcWrap_UnmapPhysicalMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 688 | Result ret{}; | 688 | Result ret{}; |
| 689 | 689 | ||
| 690 | uint32_t address{}; | 690 | uint32_t address{}; |
| 691 | uint32_t size{}; | 691 | uint32_t size{}; |
| 692 | 692 | ||
| 693 | address = Convert<uint32_t>(GetReg32(system, 0)); | 693 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 694 | size = Convert<uint32_t>(GetReg32(system, 1)); | 694 | size = Convert<uint32_t>(GetArg32(args, 1)); |
| 695 | 695 | ||
| 696 | ret = UnmapPhysicalMemory64From32(system, address, size); | 696 | ret = UnmapPhysicalMemory64From32(system, address, size); |
| 697 | 697 | ||
| 698 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 698 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 699 | } | 699 | } |
| 700 | 700 | ||
| 701 | static void SvcWrap_GetDebugFutureThreadInfo64From32(Core::System& system) { | 701 | static void SvcWrap_GetDebugFutureThreadInfo64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 702 | Result ret{}; | 702 | Result ret{}; |
| 703 | 703 | ||
| 704 | ilp32::LastThreadContext out_context{}; | 704 | ilp32::LastThreadContext out_context{}; |
| @@ -706,26 +706,26 @@ static void SvcWrap_GetDebugFutureThreadInfo64From32(Core::System& system) { | |||
| 706 | Handle debug_handle{}; | 706 | Handle debug_handle{}; |
| 707 | int64_t ns{}; | 707 | int64_t ns{}; |
| 708 | 708 | ||
| 709 | debug_handle = Convert<Handle>(GetReg32(system, 2)); | 709 | debug_handle = Convert<Handle>(GetArg32(args, 2)); |
| 710 | std::array<uint32_t, 2> ns_gather{}; | 710 | std::array<uint32_t, 2> ns_gather{}; |
| 711 | ns_gather[0] = GetReg32(system, 0); | 711 | ns_gather[0] = GetArg32(args, 0); |
| 712 | ns_gather[1] = GetReg32(system, 1); | 712 | ns_gather[1] = GetArg32(args, 1); |
| 713 | ns = Convert<int64_t>(ns_gather); | 713 | ns = Convert<int64_t>(ns_gather); |
| 714 | 714 | ||
| 715 | ret = GetDebugFutureThreadInfo64From32(system, std::addressof(out_context), std::addressof(out_thread_id), debug_handle, ns); | 715 | ret = GetDebugFutureThreadInfo64From32(system, std::addressof(out_context), std::addressof(out_thread_id), debug_handle, ns); |
| 716 | 716 | ||
| 717 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 717 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 718 | auto out_context_scatter = Convert<std::array<uint32_t, 4>>(out_context); | 718 | auto out_context_scatter = Convert<std::array<uint32_t, 4>>(out_context); |
| 719 | SetReg32(system, 1, out_context_scatter[0]); | 719 | SetArg32(args, 1, out_context_scatter[0]); |
| 720 | SetReg32(system, 2, out_context_scatter[1]); | 720 | SetArg32(args, 2, out_context_scatter[1]); |
| 721 | SetReg32(system, 3, out_context_scatter[2]); | 721 | SetArg32(args, 3, out_context_scatter[2]); |
| 722 | SetReg32(system, 4, out_context_scatter[3]); | 722 | SetArg32(args, 4, out_context_scatter[3]); |
| 723 | auto out_thread_id_scatter = Convert<std::array<uint32_t, 2>>(out_thread_id); | 723 | auto out_thread_id_scatter = Convert<std::array<uint32_t, 2>>(out_thread_id); |
| 724 | SetReg32(system, 5, out_thread_id_scatter[0]); | 724 | SetArg32(args, 5, out_thread_id_scatter[0]); |
| 725 | SetReg32(system, 6, out_thread_id_scatter[1]); | 725 | SetArg32(args, 6, out_thread_id_scatter[1]); |
| 726 | } | 726 | } |
| 727 | 727 | ||
| 728 | static void SvcWrap_GetLastThreadInfo64From32(Core::System& system) { | 728 | static void SvcWrap_GetLastThreadInfo64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 729 | Result ret{}; | 729 | Result ret{}; |
| 730 | 730 | ||
| 731 | ilp32::LastThreadContext out_context{}; | 731 | ilp32::LastThreadContext out_context{}; |
| @@ -734,81 +734,81 @@ static void SvcWrap_GetLastThreadInfo64From32(Core::System& system) { | |||
| 734 | 734 | ||
| 735 | ret = GetLastThreadInfo64From32(system, std::addressof(out_context), std::addressof(out_tls_address), std::addressof(out_flags)); | 735 | ret = GetLastThreadInfo64From32(system, std::addressof(out_context), std::addressof(out_tls_address), std::addressof(out_flags)); |
| 736 | 736 | ||
| 737 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 737 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 738 | auto out_context_scatter = Convert<std::array<uint32_t, 4>>(out_context); | 738 | auto out_context_scatter = Convert<std::array<uint32_t, 4>>(out_context); |
| 739 | SetReg32(system, 1, out_context_scatter[0]); | 739 | SetArg32(args, 1, out_context_scatter[0]); |
| 740 | SetReg32(system, 2, out_context_scatter[1]); | 740 | SetArg32(args, 2, out_context_scatter[1]); |
| 741 | SetReg32(system, 3, out_context_scatter[2]); | 741 | SetArg32(args, 3, out_context_scatter[2]); |
| 742 | SetReg32(system, 4, out_context_scatter[3]); | 742 | SetArg32(args, 4, out_context_scatter[3]); |
| 743 | SetReg32(system, 5, Convert<uint32_t>(out_tls_address)); | 743 | SetArg32(args, 5, Convert<uint32_t>(out_tls_address)); |
| 744 | SetReg32(system, 6, Convert<uint32_t>(out_flags)); | 744 | SetArg32(args, 6, Convert<uint32_t>(out_flags)); |
| 745 | } | 745 | } |
| 746 | 746 | ||
| 747 | static void SvcWrap_GetResourceLimitLimitValue64From32(Core::System& system) { | 747 | static void SvcWrap_GetResourceLimitLimitValue64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 748 | Result ret{}; | 748 | Result ret{}; |
| 749 | 749 | ||
| 750 | int64_t out_limit_value{}; | 750 | int64_t out_limit_value{}; |
| 751 | Handle resource_limit_handle{}; | 751 | Handle resource_limit_handle{}; |
| 752 | LimitableResource which{}; | 752 | LimitableResource which{}; |
| 753 | 753 | ||
| 754 | resource_limit_handle = Convert<Handle>(GetReg32(system, 1)); | 754 | resource_limit_handle = Convert<Handle>(GetArg32(args, 1)); |
| 755 | which = Convert<LimitableResource>(GetReg32(system, 2)); | 755 | which = Convert<LimitableResource>(GetArg32(args, 2)); |
| 756 | 756 | ||
| 757 | ret = GetResourceLimitLimitValue64From32(system, std::addressof(out_limit_value), resource_limit_handle, which); | 757 | ret = GetResourceLimitLimitValue64From32(system, std::addressof(out_limit_value), resource_limit_handle, which); |
| 758 | 758 | ||
| 759 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 759 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 760 | auto out_limit_value_scatter = Convert<std::array<uint32_t, 2>>(out_limit_value); | 760 | auto out_limit_value_scatter = Convert<std::array<uint32_t, 2>>(out_limit_value); |
| 761 | SetReg32(system, 1, out_limit_value_scatter[0]); | 761 | SetArg32(args, 1, out_limit_value_scatter[0]); |
| 762 | SetReg32(system, 2, out_limit_value_scatter[1]); | 762 | SetArg32(args, 2, out_limit_value_scatter[1]); |
| 763 | } | 763 | } |
| 764 | 764 | ||
| 765 | static void SvcWrap_GetResourceLimitCurrentValue64From32(Core::System& system) { | 765 | static void SvcWrap_GetResourceLimitCurrentValue64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 766 | Result ret{}; | 766 | Result ret{}; |
| 767 | 767 | ||
| 768 | int64_t out_current_value{}; | 768 | int64_t out_current_value{}; |
| 769 | Handle resource_limit_handle{}; | 769 | Handle resource_limit_handle{}; |
| 770 | LimitableResource which{}; | 770 | LimitableResource which{}; |
| 771 | 771 | ||
| 772 | resource_limit_handle = Convert<Handle>(GetReg32(system, 1)); | 772 | resource_limit_handle = Convert<Handle>(GetArg32(args, 1)); |
| 773 | which = Convert<LimitableResource>(GetReg32(system, 2)); | 773 | which = Convert<LimitableResource>(GetArg32(args, 2)); |
| 774 | 774 | ||
| 775 | ret = GetResourceLimitCurrentValue64From32(system, std::addressof(out_current_value), resource_limit_handle, which); | 775 | ret = GetResourceLimitCurrentValue64From32(system, std::addressof(out_current_value), resource_limit_handle, which); |
| 776 | 776 | ||
| 777 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 777 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 778 | auto out_current_value_scatter = Convert<std::array<uint32_t, 2>>(out_current_value); | 778 | auto out_current_value_scatter = Convert<std::array<uint32_t, 2>>(out_current_value); |
| 779 | SetReg32(system, 1, out_current_value_scatter[0]); | 779 | SetArg32(args, 1, out_current_value_scatter[0]); |
| 780 | SetReg32(system, 2, out_current_value_scatter[1]); | 780 | SetArg32(args, 2, out_current_value_scatter[1]); |
| 781 | } | 781 | } |
| 782 | 782 | ||
| 783 | static void SvcWrap_SetThreadActivity64From32(Core::System& system) { | 783 | static void SvcWrap_SetThreadActivity64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 784 | Result ret{}; | 784 | Result ret{}; |
| 785 | 785 | ||
| 786 | Handle thread_handle{}; | 786 | Handle thread_handle{}; |
| 787 | ThreadActivity thread_activity{}; | 787 | ThreadActivity thread_activity{}; |
| 788 | 788 | ||
| 789 | thread_handle = Convert<Handle>(GetReg32(system, 0)); | 789 | thread_handle = Convert<Handle>(GetArg32(args, 0)); |
| 790 | thread_activity = Convert<ThreadActivity>(GetReg32(system, 1)); | 790 | thread_activity = Convert<ThreadActivity>(GetArg32(args, 1)); |
| 791 | 791 | ||
| 792 | ret = SetThreadActivity64From32(system, thread_handle, thread_activity); | 792 | ret = SetThreadActivity64From32(system, thread_handle, thread_activity); |
| 793 | 793 | ||
| 794 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 794 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 795 | } | 795 | } |
| 796 | 796 | ||
| 797 | static void SvcWrap_GetThreadContext364From32(Core::System& system) { | 797 | static void SvcWrap_GetThreadContext364From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 798 | Result ret{}; | 798 | Result ret{}; |
| 799 | 799 | ||
| 800 | uint32_t out_context{}; | 800 | uint32_t out_context{}; |
| 801 | Handle thread_handle{}; | 801 | Handle thread_handle{}; |
| 802 | 802 | ||
| 803 | out_context = Convert<uint32_t>(GetReg32(system, 0)); | 803 | out_context = Convert<uint32_t>(GetArg32(args, 0)); |
| 804 | thread_handle = Convert<Handle>(GetReg32(system, 1)); | 804 | thread_handle = Convert<Handle>(GetArg32(args, 1)); |
| 805 | 805 | ||
| 806 | ret = GetThreadContext364From32(system, out_context, thread_handle); | 806 | ret = GetThreadContext364From32(system, out_context, thread_handle); |
| 807 | 807 | ||
| 808 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 808 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 809 | } | 809 | } |
| 810 | 810 | ||
| 811 | static void SvcWrap_WaitForAddress64From32(Core::System& system) { | 811 | static void SvcWrap_WaitForAddress64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 812 | Result ret{}; | 812 | Result ret{}; |
| 813 | 813 | ||
| 814 | uint32_t address{}; | 814 | uint32_t address{}; |
| @@ -816,20 +816,20 @@ static void SvcWrap_WaitForAddress64From32(Core::System& system) { | |||
| 816 | int32_t value{}; | 816 | int32_t value{}; |
| 817 | int64_t timeout_ns{}; | 817 | int64_t timeout_ns{}; |
| 818 | 818 | ||
| 819 | address = Convert<uint32_t>(GetReg32(system, 0)); | 819 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 820 | arb_type = Convert<ArbitrationType>(GetReg32(system, 1)); | 820 | arb_type = Convert<ArbitrationType>(GetArg32(args, 1)); |
| 821 | value = Convert<int32_t>(GetReg32(system, 2)); | 821 | value = Convert<int32_t>(GetArg32(args, 2)); |
| 822 | std::array<uint32_t, 2> timeout_ns_gather{}; | 822 | std::array<uint32_t, 2> timeout_ns_gather{}; |
| 823 | timeout_ns_gather[0] = GetReg32(system, 3); | 823 | timeout_ns_gather[0] = GetArg32(args, 3); |
| 824 | timeout_ns_gather[1] = GetReg32(system, 4); | 824 | timeout_ns_gather[1] = GetArg32(args, 4); |
| 825 | timeout_ns = Convert<int64_t>(timeout_ns_gather); | 825 | timeout_ns = Convert<int64_t>(timeout_ns_gather); |
| 826 | 826 | ||
| 827 | ret = WaitForAddress64From32(system, address, arb_type, value, timeout_ns); | 827 | ret = WaitForAddress64From32(system, address, arb_type, value, timeout_ns); |
| 828 | 828 | ||
| 829 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 829 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 830 | } | 830 | } |
| 831 | 831 | ||
| 832 | static void SvcWrap_SignalToAddress64From32(Core::System& system) { | 832 | static void SvcWrap_SignalToAddress64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 833 | Result ret{}; | 833 | Result ret{}; |
| 834 | 834 | ||
| 835 | uint32_t address{}; | 835 | uint32_t address{}; |
| @@ -837,53 +837,53 @@ static void SvcWrap_SignalToAddress64From32(Core::System& system) { | |||
| 837 | int32_t value{}; | 837 | int32_t value{}; |
| 838 | int32_t count{}; | 838 | int32_t count{}; |
| 839 | 839 | ||
| 840 | address = Convert<uint32_t>(GetReg32(system, 0)); | 840 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 841 | signal_type = Convert<SignalType>(GetReg32(system, 1)); | 841 | signal_type = Convert<SignalType>(GetArg32(args, 1)); |
| 842 | value = Convert<int32_t>(GetReg32(system, 2)); | 842 | value = Convert<int32_t>(GetArg32(args, 2)); |
| 843 | count = Convert<int32_t>(GetReg32(system, 3)); | 843 | count = Convert<int32_t>(GetArg32(args, 3)); |
| 844 | 844 | ||
| 845 | ret = SignalToAddress64From32(system, address, signal_type, value, count); | 845 | ret = SignalToAddress64From32(system, address, signal_type, value, count); |
| 846 | 846 | ||
| 847 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 847 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 848 | } | 848 | } |
| 849 | 849 | ||
| 850 | static void SvcWrap_SynchronizePreemptionState64From32(Core::System& system) { | 850 | static void SvcWrap_SynchronizePreemptionState64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 851 | SynchronizePreemptionState64From32(system); | 851 | SynchronizePreemptionState64From32(system); |
| 852 | } | 852 | } |
| 853 | 853 | ||
| 854 | static void SvcWrap_GetResourceLimitPeakValue64From32(Core::System& system) { | 854 | static void SvcWrap_GetResourceLimitPeakValue64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 855 | Result ret{}; | 855 | Result ret{}; |
| 856 | 856 | ||
| 857 | int64_t out_peak_value{}; | 857 | int64_t out_peak_value{}; |
| 858 | Handle resource_limit_handle{}; | 858 | Handle resource_limit_handle{}; |
| 859 | LimitableResource which{}; | 859 | LimitableResource which{}; |
| 860 | 860 | ||
| 861 | resource_limit_handle = Convert<Handle>(GetReg32(system, 1)); | 861 | resource_limit_handle = Convert<Handle>(GetArg32(args, 1)); |
| 862 | which = Convert<LimitableResource>(GetReg32(system, 2)); | 862 | which = Convert<LimitableResource>(GetArg32(args, 2)); |
| 863 | 863 | ||
| 864 | ret = GetResourceLimitPeakValue64From32(system, std::addressof(out_peak_value), resource_limit_handle, which); | 864 | ret = GetResourceLimitPeakValue64From32(system, std::addressof(out_peak_value), resource_limit_handle, which); |
| 865 | 865 | ||
| 866 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 866 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 867 | auto out_peak_value_scatter = Convert<std::array<uint32_t, 2>>(out_peak_value); | 867 | auto out_peak_value_scatter = Convert<std::array<uint32_t, 2>>(out_peak_value); |
| 868 | SetReg32(system, 1, out_peak_value_scatter[0]); | 868 | SetArg32(args, 1, out_peak_value_scatter[0]); |
| 869 | SetReg32(system, 2, out_peak_value_scatter[1]); | 869 | SetArg32(args, 2, out_peak_value_scatter[1]); |
| 870 | } | 870 | } |
| 871 | 871 | ||
| 872 | static void SvcWrap_CreateIoPool64From32(Core::System& system) { | 872 | static void SvcWrap_CreateIoPool64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 873 | Result ret{}; | 873 | Result ret{}; |
| 874 | 874 | ||
| 875 | Handle out_handle{}; | 875 | Handle out_handle{}; |
| 876 | IoPoolType which{}; | 876 | IoPoolType which{}; |
| 877 | 877 | ||
| 878 | which = Convert<IoPoolType>(GetReg32(system, 1)); | 878 | which = Convert<IoPoolType>(GetArg32(args, 1)); |
| 879 | 879 | ||
| 880 | ret = CreateIoPool64From32(system, std::addressof(out_handle), which); | 880 | ret = CreateIoPool64From32(system, std::addressof(out_handle), which); |
| 881 | 881 | ||
| 882 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 882 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 883 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 883 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 884 | } | 884 | } |
| 885 | 885 | ||
| 886 | static void SvcWrap_CreateIoRegion64From32(Core::System& system) { | 886 | static void SvcWrap_CreateIoRegion64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 887 | Result ret{}; | 887 | Result ret{}; |
| 888 | 888 | ||
| 889 | Handle out_handle{}; | 889 | Handle out_handle{}; |
| @@ -893,53 +893,53 @@ static void SvcWrap_CreateIoRegion64From32(Core::System& system) { | |||
| 893 | MemoryMapping mapping{}; | 893 | MemoryMapping mapping{}; |
| 894 | MemoryPermission perm{}; | 894 | MemoryPermission perm{}; |
| 895 | 895 | ||
| 896 | io_pool = Convert<Handle>(GetReg32(system, 1)); | 896 | io_pool = Convert<Handle>(GetArg32(args, 1)); |
| 897 | std::array<uint32_t, 2> physical_address_gather{}; | 897 | std::array<uint32_t, 2> physical_address_gather{}; |
| 898 | physical_address_gather[0] = GetReg32(system, 2); | 898 | physical_address_gather[0] = GetArg32(args, 2); |
| 899 | physical_address_gather[1] = GetReg32(system, 3); | 899 | physical_address_gather[1] = GetArg32(args, 3); |
| 900 | physical_address = Convert<uint64_t>(physical_address_gather); | 900 | physical_address = Convert<uint64_t>(physical_address_gather); |
| 901 | size = Convert<uint32_t>(GetReg32(system, 0)); | 901 | size = Convert<uint32_t>(GetArg32(args, 0)); |
| 902 | mapping = Convert<MemoryMapping>(GetReg32(system, 4)); | 902 | mapping = Convert<MemoryMapping>(GetArg32(args, 4)); |
| 903 | perm = Convert<MemoryPermission>(GetReg32(system, 5)); | 903 | perm = Convert<MemoryPermission>(GetArg32(args, 5)); |
| 904 | 904 | ||
| 905 | ret = CreateIoRegion64From32(system, std::addressof(out_handle), io_pool, physical_address, size, mapping, perm); | 905 | ret = CreateIoRegion64From32(system, std::addressof(out_handle), io_pool, physical_address, size, mapping, perm); |
| 906 | 906 | ||
| 907 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 907 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 908 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 908 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 909 | } | 909 | } |
| 910 | 910 | ||
| 911 | static void SvcWrap_KernelDebug64From32(Core::System& system) { | 911 | static void SvcWrap_KernelDebug64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 912 | KernelDebugType kern_debug_type{}; | 912 | KernelDebugType kern_debug_type{}; |
| 913 | uint64_t arg0{}; | 913 | uint64_t arg0{}; |
| 914 | uint64_t arg1{}; | 914 | uint64_t arg1{}; |
| 915 | uint64_t arg2{}; | 915 | uint64_t arg2{}; |
| 916 | 916 | ||
| 917 | kern_debug_type = Convert<KernelDebugType>(GetReg32(system, 0)); | 917 | kern_debug_type = Convert<KernelDebugType>(GetArg32(args, 0)); |
| 918 | std::array<uint32_t, 2> arg0_gather{}; | 918 | std::array<uint32_t, 2> arg0_gather{}; |
| 919 | arg0_gather[0] = GetReg32(system, 2); | 919 | arg0_gather[0] = GetArg32(args, 2); |
| 920 | arg0_gather[1] = GetReg32(system, 3); | 920 | arg0_gather[1] = GetArg32(args, 3); |
| 921 | arg0 = Convert<uint64_t>(arg0_gather); | 921 | arg0 = Convert<uint64_t>(arg0_gather); |
| 922 | std::array<uint32_t, 2> arg1_gather{}; | 922 | std::array<uint32_t, 2> arg1_gather{}; |
| 923 | arg1_gather[0] = GetReg32(system, 1); | 923 | arg1_gather[0] = GetArg32(args, 1); |
| 924 | arg1_gather[1] = GetReg32(system, 4); | 924 | arg1_gather[1] = GetArg32(args, 4); |
| 925 | arg1 = Convert<uint64_t>(arg1_gather); | 925 | arg1 = Convert<uint64_t>(arg1_gather); |
| 926 | std::array<uint32_t, 2> arg2_gather{}; | 926 | std::array<uint32_t, 2> arg2_gather{}; |
| 927 | arg2_gather[0] = GetReg32(system, 5); | 927 | arg2_gather[0] = GetArg32(args, 5); |
| 928 | arg2_gather[1] = GetReg32(system, 6); | 928 | arg2_gather[1] = GetArg32(args, 6); |
| 929 | arg2 = Convert<uint64_t>(arg2_gather); | 929 | arg2 = Convert<uint64_t>(arg2_gather); |
| 930 | 930 | ||
| 931 | KernelDebug64From32(system, kern_debug_type, arg0, arg1, arg2); | 931 | KernelDebug64From32(system, kern_debug_type, arg0, arg1, arg2); |
| 932 | } | 932 | } |
| 933 | 933 | ||
| 934 | static void SvcWrap_ChangeKernelTraceState64From32(Core::System& system) { | 934 | static void SvcWrap_ChangeKernelTraceState64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 935 | KernelTraceState kern_trace_state{}; | 935 | KernelTraceState kern_trace_state{}; |
| 936 | 936 | ||
| 937 | kern_trace_state = Convert<KernelTraceState>(GetReg32(system, 0)); | 937 | kern_trace_state = Convert<KernelTraceState>(GetArg32(args, 0)); |
| 938 | 938 | ||
| 939 | ChangeKernelTraceState64From32(system, kern_trace_state); | 939 | ChangeKernelTraceState64From32(system, kern_trace_state); |
| 940 | } | 940 | } |
| 941 | 941 | ||
| 942 | static void SvcWrap_CreateSession64From32(Core::System& system) { | 942 | static void SvcWrap_CreateSession64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 943 | Result ret{}; | 943 | Result ret{}; |
| 944 | 944 | ||
| 945 | Handle out_server_session_handle{}; | 945 | Handle out_server_session_handle{}; |
| @@ -947,31 +947,31 @@ static void SvcWrap_CreateSession64From32(Core::System& system) { | |||
| 947 | bool is_light{}; | 947 | bool is_light{}; |
| 948 | uint32_t name{}; | 948 | uint32_t name{}; |
| 949 | 949 | ||
| 950 | is_light = Convert<bool>(GetReg32(system, 2)); | 950 | is_light = Convert<bool>(GetArg32(args, 2)); |
| 951 | name = Convert<uint32_t>(GetReg32(system, 3)); | 951 | name = Convert<uint32_t>(GetArg32(args, 3)); |
| 952 | 952 | ||
| 953 | ret = CreateSession64From32(system, std::addressof(out_server_session_handle), std::addressof(out_client_session_handle), is_light, name); | 953 | ret = CreateSession64From32(system, std::addressof(out_server_session_handle), std::addressof(out_client_session_handle), is_light, name); |
| 954 | 954 | ||
| 955 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 955 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 956 | SetReg32(system, 1, Convert<uint32_t>(out_server_session_handle)); | 956 | SetArg32(args, 1, Convert<uint32_t>(out_server_session_handle)); |
| 957 | SetReg32(system, 2, Convert<uint32_t>(out_client_session_handle)); | 957 | SetArg32(args, 2, Convert<uint32_t>(out_client_session_handle)); |
| 958 | } | 958 | } |
| 959 | 959 | ||
| 960 | static void SvcWrap_AcceptSession64From32(Core::System& system) { | 960 | static void SvcWrap_AcceptSession64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 961 | Result ret{}; | 961 | Result ret{}; |
| 962 | 962 | ||
| 963 | Handle out_handle{}; | 963 | Handle out_handle{}; |
| 964 | Handle port{}; | 964 | Handle port{}; |
| 965 | 965 | ||
| 966 | port = Convert<Handle>(GetReg32(system, 1)); | 966 | port = Convert<Handle>(GetArg32(args, 1)); |
| 967 | 967 | ||
| 968 | ret = AcceptSession64From32(system, std::addressof(out_handle), port); | 968 | ret = AcceptSession64From32(system, std::addressof(out_handle), port); |
| 969 | 969 | ||
| 970 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 970 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 971 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 971 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 972 | } | 972 | } |
| 973 | 973 | ||
| 974 | static void SvcWrap_ReplyAndReceive64From32(Core::System& system) { | 974 | static void SvcWrap_ReplyAndReceive64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 975 | Result ret{}; | 975 | Result ret{}; |
| 976 | 976 | ||
| 977 | int32_t out_index{}; | 977 | int32_t out_index{}; |
| @@ -980,21 +980,21 @@ static void SvcWrap_ReplyAndReceive64From32(Core::System& system) { | |||
| 980 | Handle reply_target{}; | 980 | Handle reply_target{}; |
| 981 | int64_t timeout_ns{}; | 981 | int64_t timeout_ns{}; |
| 982 | 982 | ||
| 983 | handles = Convert<uint32_t>(GetReg32(system, 1)); | 983 | handles = Convert<uint32_t>(GetArg32(args, 1)); |
| 984 | num_handles = Convert<int32_t>(GetReg32(system, 2)); | 984 | num_handles = Convert<int32_t>(GetArg32(args, 2)); |
| 985 | reply_target = Convert<Handle>(GetReg32(system, 3)); | 985 | reply_target = Convert<Handle>(GetArg32(args, 3)); |
| 986 | std::array<uint32_t, 2> timeout_ns_gather{}; | 986 | std::array<uint32_t, 2> timeout_ns_gather{}; |
| 987 | timeout_ns_gather[0] = GetReg32(system, 0); | 987 | timeout_ns_gather[0] = GetArg32(args, 0); |
| 988 | timeout_ns_gather[1] = GetReg32(system, 4); | 988 | timeout_ns_gather[1] = GetArg32(args, 4); |
| 989 | timeout_ns = Convert<int64_t>(timeout_ns_gather); | 989 | timeout_ns = Convert<int64_t>(timeout_ns_gather); |
| 990 | 990 | ||
| 991 | ret = ReplyAndReceive64From32(system, std::addressof(out_index), handles, num_handles, reply_target, timeout_ns); | 991 | ret = ReplyAndReceive64From32(system, std::addressof(out_index), handles, num_handles, reply_target, timeout_ns); |
| 992 | 992 | ||
| 993 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 993 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 994 | SetReg32(system, 1, Convert<uint32_t>(out_index)); | 994 | SetArg32(args, 1, Convert<uint32_t>(out_index)); |
| 995 | } | 995 | } |
| 996 | 996 | ||
| 997 | static void SvcWrap_ReplyAndReceiveWithUserBuffer64From32(Core::System& system) { | 997 | static void SvcWrap_ReplyAndReceiveWithUserBuffer64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 998 | Result ret{}; | 998 | Result ret{}; |
| 999 | 999 | ||
| 1000 | int32_t out_index{}; | 1000 | int32_t out_index{}; |
| @@ -1005,23 +1005,23 @@ static void SvcWrap_ReplyAndReceiveWithUserBuffer64From32(Core::System& system) | |||
| 1005 | Handle reply_target{}; | 1005 | Handle reply_target{}; |
| 1006 | int64_t timeout_ns{}; | 1006 | int64_t timeout_ns{}; |
| 1007 | 1007 | ||
| 1008 | message_buffer = Convert<uint32_t>(GetReg32(system, 1)); | 1008 | message_buffer = Convert<uint32_t>(GetArg32(args, 1)); |
| 1009 | message_buffer_size = Convert<uint32_t>(GetReg32(system, 2)); | 1009 | message_buffer_size = Convert<uint32_t>(GetArg32(args, 2)); |
| 1010 | handles = Convert<uint32_t>(GetReg32(system, 3)); | 1010 | handles = Convert<uint32_t>(GetArg32(args, 3)); |
| 1011 | num_handles = Convert<int32_t>(GetReg32(system, 0)); | 1011 | num_handles = Convert<int32_t>(GetArg32(args, 0)); |
| 1012 | reply_target = Convert<Handle>(GetReg32(system, 4)); | 1012 | reply_target = Convert<Handle>(GetArg32(args, 4)); |
| 1013 | std::array<uint32_t, 2> timeout_ns_gather{}; | 1013 | std::array<uint32_t, 2> timeout_ns_gather{}; |
| 1014 | timeout_ns_gather[0] = GetReg32(system, 5); | 1014 | timeout_ns_gather[0] = GetArg32(args, 5); |
| 1015 | timeout_ns_gather[1] = GetReg32(system, 6); | 1015 | timeout_ns_gather[1] = GetArg32(args, 6); |
| 1016 | timeout_ns = Convert<int64_t>(timeout_ns_gather); | 1016 | timeout_ns = Convert<int64_t>(timeout_ns_gather); |
| 1017 | 1017 | ||
| 1018 | ret = ReplyAndReceiveWithUserBuffer64From32(system, std::addressof(out_index), message_buffer, message_buffer_size, handles, num_handles, reply_target, timeout_ns); | 1018 | ret = ReplyAndReceiveWithUserBuffer64From32(system, std::addressof(out_index), message_buffer, message_buffer_size, handles, num_handles, reply_target, timeout_ns); |
| 1019 | 1019 | ||
| 1020 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1020 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1021 | SetReg32(system, 1, Convert<uint32_t>(out_index)); | 1021 | SetArg32(args, 1, Convert<uint32_t>(out_index)); |
| 1022 | } | 1022 | } |
| 1023 | 1023 | ||
| 1024 | static void SvcWrap_CreateEvent64From32(Core::System& system) { | 1024 | static void SvcWrap_CreateEvent64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1025 | Result ret{}; | 1025 | Result ret{}; |
| 1026 | 1026 | ||
| 1027 | Handle out_write_handle{}; | 1027 | Handle out_write_handle{}; |
| @@ -1029,12 +1029,12 @@ static void SvcWrap_CreateEvent64From32(Core::System& system) { | |||
| 1029 | 1029 | ||
| 1030 | ret = CreateEvent64From32(system, std::addressof(out_write_handle), std::addressof(out_read_handle)); | 1030 | ret = CreateEvent64From32(system, std::addressof(out_write_handle), std::addressof(out_read_handle)); |
| 1031 | 1031 | ||
| 1032 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1032 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1033 | SetReg32(system, 1, Convert<uint32_t>(out_write_handle)); | 1033 | SetArg32(args, 1, Convert<uint32_t>(out_write_handle)); |
| 1034 | SetReg32(system, 2, Convert<uint32_t>(out_read_handle)); | 1034 | SetArg32(args, 2, Convert<uint32_t>(out_read_handle)); |
| 1035 | } | 1035 | } |
| 1036 | 1036 | ||
| 1037 | static void SvcWrap_MapIoRegion64From32(Core::System& system) { | 1037 | static void SvcWrap_MapIoRegion64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1038 | Result ret{}; | 1038 | Result ret{}; |
| 1039 | 1039 | ||
| 1040 | Handle io_region{}; | 1040 | Handle io_region{}; |
| @@ -1042,89 +1042,89 @@ static void SvcWrap_MapIoRegion64From32(Core::System& system) { | |||
| 1042 | uint32_t size{}; | 1042 | uint32_t size{}; |
| 1043 | MemoryPermission perm{}; | 1043 | MemoryPermission perm{}; |
| 1044 | 1044 | ||
| 1045 | io_region = Convert<Handle>(GetReg32(system, 0)); | 1045 | io_region = Convert<Handle>(GetArg32(args, 0)); |
| 1046 | address = Convert<uint32_t>(GetReg32(system, 1)); | 1046 | address = Convert<uint32_t>(GetArg32(args, 1)); |
| 1047 | size = Convert<uint32_t>(GetReg32(system, 2)); | 1047 | size = Convert<uint32_t>(GetArg32(args, 2)); |
| 1048 | perm = Convert<MemoryPermission>(GetReg32(system, 3)); | 1048 | perm = Convert<MemoryPermission>(GetArg32(args, 3)); |
| 1049 | 1049 | ||
| 1050 | ret = MapIoRegion64From32(system, io_region, address, size, perm); | 1050 | ret = MapIoRegion64From32(system, io_region, address, size, perm); |
| 1051 | 1051 | ||
| 1052 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1052 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1053 | } | 1053 | } |
| 1054 | 1054 | ||
| 1055 | static void SvcWrap_UnmapIoRegion64From32(Core::System& system) { | 1055 | static void SvcWrap_UnmapIoRegion64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1056 | Result ret{}; | 1056 | Result ret{}; |
| 1057 | 1057 | ||
| 1058 | Handle io_region{}; | 1058 | Handle io_region{}; |
| 1059 | uint32_t address{}; | 1059 | uint32_t address{}; |
| 1060 | uint32_t size{}; | 1060 | uint32_t size{}; |
| 1061 | 1061 | ||
| 1062 | io_region = Convert<Handle>(GetReg32(system, 0)); | 1062 | io_region = Convert<Handle>(GetArg32(args, 0)); |
| 1063 | address = Convert<uint32_t>(GetReg32(system, 1)); | 1063 | address = Convert<uint32_t>(GetArg32(args, 1)); |
| 1064 | size = Convert<uint32_t>(GetReg32(system, 2)); | 1064 | size = Convert<uint32_t>(GetArg32(args, 2)); |
| 1065 | 1065 | ||
| 1066 | ret = UnmapIoRegion64From32(system, io_region, address, size); | 1066 | ret = UnmapIoRegion64From32(system, io_region, address, size); |
| 1067 | 1067 | ||
| 1068 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1068 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1069 | } | 1069 | } |
| 1070 | 1070 | ||
| 1071 | static void SvcWrap_MapPhysicalMemoryUnsafe64From32(Core::System& system) { | 1071 | static void SvcWrap_MapPhysicalMemoryUnsafe64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1072 | Result ret{}; | 1072 | Result ret{}; |
| 1073 | 1073 | ||
| 1074 | uint32_t address{}; | 1074 | uint32_t address{}; |
| 1075 | uint32_t size{}; | 1075 | uint32_t size{}; |
| 1076 | 1076 | ||
| 1077 | address = Convert<uint32_t>(GetReg32(system, 0)); | 1077 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 1078 | size = Convert<uint32_t>(GetReg32(system, 1)); | 1078 | size = Convert<uint32_t>(GetArg32(args, 1)); |
| 1079 | 1079 | ||
| 1080 | ret = MapPhysicalMemoryUnsafe64From32(system, address, size); | 1080 | ret = MapPhysicalMemoryUnsafe64From32(system, address, size); |
| 1081 | 1081 | ||
| 1082 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1082 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1083 | } | 1083 | } |
| 1084 | 1084 | ||
| 1085 | static void SvcWrap_UnmapPhysicalMemoryUnsafe64From32(Core::System& system) { | 1085 | static void SvcWrap_UnmapPhysicalMemoryUnsafe64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1086 | Result ret{}; | 1086 | Result ret{}; |
| 1087 | 1087 | ||
| 1088 | uint32_t address{}; | 1088 | uint32_t address{}; |
| 1089 | uint32_t size{}; | 1089 | uint32_t size{}; |
| 1090 | 1090 | ||
| 1091 | address = Convert<uint32_t>(GetReg32(system, 0)); | 1091 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 1092 | size = Convert<uint32_t>(GetReg32(system, 1)); | 1092 | size = Convert<uint32_t>(GetArg32(args, 1)); |
| 1093 | 1093 | ||
| 1094 | ret = UnmapPhysicalMemoryUnsafe64From32(system, address, size); | 1094 | ret = UnmapPhysicalMemoryUnsafe64From32(system, address, size); |
| 1095 | 1095 | ||
| 1096 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1096 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1097 | } | 1097 | } |
| 1098 | 1098 | ||
| 1099 | static void SvcWrap_SetUnsafeLimit64From32(Core::System& system) { | 1099 | static void SvcWrap_SetUnsafeLimit64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1100 | Result ret{}; | 1100 | Result ret{}; |
| 1101 | 1101 | ||
| 1102 | uint32_t limit{}; | 1102 | uint32_t limit{}; |
| 1103 | 1103 | ||
| 1104 | limit = Convert<uint32_t>(GetReg32(system, 0)); | 1104 | limit = Convert<uint32_t>(GetArg32(args, 0)); |
| 1105 | 1105 | ||
| 1106 | ret = SetUnsafeLimit64From32(system, limit); | 1106 | ret = SetUnsafeLimit64From32(system, limit); |
| 1107 | 1107 | ||
| 1108 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1108 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1109 | } | 1109 | } |
| 1110 | 1110 | ||
| 1111 | static void SvcWrap_CreateCodeMemory64From32(Core::System& system) { | 1111 | static void SvcWrap_CreateCodeMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1112 | Result ret{}; | 1112 | Result ret{}; |
| 1113 | 1113 | ||
| 1114 | Handle out_handle{}; | 1114 | Handle out_handle{}; |
| 1115 | uint32_t address{}; | 1115 | uint32_t address{}; |
| 1116 | uint32_t size{}; | 1116 | uint32_t size{}; |
| 1117 | 1117 | ||
| 1118 | address = Convert<uint32_t>(GetReg32(system, 1)); | 1118 | address = Convert<uint32_t>(GetArg32(args, 1)); |
| 1119 | size = Convert<uint32_t>(GetReg32(system, 2)); | 1119 | size = Convert<uint32_t>(GetArg32(args, 2)); |
| 1120 | 1120 | ||
| 1121 | ret = CreateCodeMemory64From32(system, std::addressof(out_handle), address, size); | 1121 | ret = CreateCodeMemory64From32(system, std::addressof(out_handle), address, size); |
| 1122 | 1122 | ||
| 1123 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1123 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1124 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 1124 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 1125 | } | 1125 | } |
| 1126 | 1126 | ||
| 1127 | static void SvcWrap_ControlCodeMemory64From32(Core::System& system) { | 1127 | static void SvcWrap_ControlCodeMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1128 | Result ret{}; | 1128 | Result ret{}; |
| 1129 | 1129 | ||
| 1130 | Handle code_memory_handle{}; | 1130 | Handle code_memory_handle{}; |
| @@ -1133,28 +1133,28 @@ static void SvcWrap_ControlCodeMemory64From32(Core::System& system) { | |||
| 1133 | uint64_t size{}; | 1133 | uint64_t size{}; |
| 1134 | MemoryPermission perm{}; | 1134 | MemoryPermission perm{}; |
| 1135 | 1135 | ||
| 1136 | code_memory_handle = Convert<Handle>(GetReg32(system, 0)); | 1136 | code_memory_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1137 | operation = Convert<CodeMemoryOperation>(GetReg32(system, 1)); | 1137 | operation = Convert<CodeMemoryOperation>(GetArg32(args, 1)); |
| 1138 | std::array<uint32_t, 2> address_gather{}; | 1138 | std::array<uint32_t, 2> address_gather{}; |
| 1139 | address_gather[0] = GetReg32(system, 2); | 1139 | address_gather[0] = GetArg32(args, 2); |
| 1140 | address_gather[1] = GetReg32(system, 3); | 1140 | address_gather[1] = GetArg32(args, 3); |
| 1141 | address = Convert<uint64_t>(address_gather); | 1141 | address = Convert<uint64_t>(address_gather); |
| 1142 | std::array<uint32_t, 2> size_gather{}; | 1142 | std::array<uint32_t, 2> size_gather{}; |
| 1143 | size_gather[0] = GetReg32(system, 4); | 1143 | size_gather[0] = GetArg32(args, 4); |
| 1144 | size_gather[1] = GetReg32(system, 5); | 1144 | size_gather[1] = GetArg32(args, 5); |
| 1145 | size = Convert<uint64_t>(size_gather); | 1145 | size = Convert<uint64_t>(size_gather); |
| 1146 | perm = Convert<MemoryPermission>(GetReg32(system, 6)); | 1146 | perm = Convert<MemoryPermission>(GetArg32(args, 6)); |
| 1147 | 1147 | ||
| 1148 | ret = ControlCodeMemory64From32(system, code_memory_handle, operation, address, size, perm); | 1148 | ret = ControlCodeMemory64From32(system, code_memory_handle, operation, address, size, perm); |
| 1149 | 1149 | ||
| 1150 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1150 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1151 | } | 1151 | } |
| 1152 | 1152 | ||
| 1153 | static void SvcWrap_SleepSystem64From32(Core::System& system) { | 1153 | static void SvcWrap_SleepSystem64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1154 | SleepSystem64From32(system); | 1154 | SleepSystem64From32(system); |
| 1155 | } | 1155 | } |
| 1156 | 1156 | ||
| 1157 | static void SvcWrap_ReadWriteRegister64From32(Core::System& system) { | 1157 | static void SvcWrap_ReadWriteRegister64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1158 | Result ret{}; | 1158 | Result ret{}; |
| 1159 | 1159 | ||
| 1160 | uint32_t out_value{}; | 1160 | uint32_t out_value{}; |
| @@ -1163,33 +1163,33 @@ static void SvcWrap_ReadWriteRegister64From32(Core::System& system) { | |||
| 1163 | uint32_t value{}; | 1163 | uint32_t value{}; |
| 1164 | 1164 | ||
| 1165 | std::array<uint32_t, 2> address_gather{}; | 1165 | std::array<uint32_t, 2> address_gather{}; |
| 1166 | address_gather[0] = GetReg32(system, 2); | 1166 | address_gather[0] = GetArg32(args, 2); |
| 1167 | address_gather[1] = GetReg32(system, 3); | 1167 | address_gather[1] = GetArg32(args, 3); |
| 1168 | address = Convert<uint64_t>(address_gather); | 1168 | address = Convert<uint64_t>(address_gather); |
| 1169 | mask = Convert<uint32_t>(GetReg32(system, 0)); | 1169 | mask = Convert<uint32_t>(GetArg32(args, 0)); |
| 1170 | value = Convert<uint32_t>(GetReg32(system, 1)); | 1170 | value = Convert<uint32_t>(GetArg32(args, 1)); |
| 1171 | 1171 | ||
| 1172 | ret = ReadWriteRegister64From32(system, std::addressof(out_value), address, mask, value); | 1172 | ret = ReadWriteRegister64From32(system, std::addressof(out_value), address, mask, value); |
| 1173 | 1173 | ||
| 1174 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1174 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1175 | SetReg32(system, 1, Convert<uint32_t>(out_value)); | 1175 | SetArg32(args, 1, Convert<uint32_t>(out_value)); |
| 1176 | } | 1176 | } |
| 1177 | 1177 | ||
| 1178 | static void SvcWrap_SetProcessActivity64From32(Core::System& system) { | 1178 | static void SvcWrap_SetProcessActivity64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1179 | Result ret{}; | 1179 | Result ret{}; |
| 1180 | 1180 | ||
| 1181 | Handle process_handle{}; | 1181 | Handle process_handle{}; |
| 1182 | ProcessActivity process_activity{}; | 1182 | ProcessActivity process_activity{}; |
| 1183 | 1183 | ||
| 1184 | process_handle = Convert<Handle>(GetReg32(system, 0)); | 1184 | process_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1185 | process_activity = Convert<ProcessActivity>(GetReg32(system, 1)); | 1185 | process_activity = Convert<ProcessActivity>(GetArg32(args, 1)); |
| 1186 | 1186 | ||
| 1187 | ret = SetProcessActivity64From32(system, process_handle, process_activity); | 1187 | ret = SetProcessActivity64From32(system, process_handle, process_activity); |
| 1188 | 1188 | ||
| 1189 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1189 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1190 | } | 1190 | } |
| 1191 | 1191 | ||
| 1192 | static void SvcWrap_CreateSharedMemory64From32(Core::System& system) { | 1192 | static void SvcWrap_CreateSharedMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1193 | Result ret{}; | 1193 | Result ret{}; |
| 1194 | 1194 | ||
| 1195 | Handle out_handle{}; | 1195 | Handle out_handle{}; |
| @@ -1197,17 +1197,17 @@ static void SvcWrap_CreateSharedMemory64From32(Core::System& system) { | |||
| 1197 | MemoryPermission owner_perm{}; | 1197 | MemoryPermission owner_perm{}; |
| 1198 | MemoryPermission remote_perm{}; | 1198 | MemoryPermission remote_perm{}; |
| 1199 | 1199 | ||
| 1200 | size = Convert<uint32_t>(GetReg32(system, 1)); | 1200 | size = Convert<uint32_t>(GetArg32(args, 1)); |
| 1201 | owner_perm = Convert<MemoryPermission>(GetReg32(system, 2)); | 1201 | owner_perm = Convert<MemoryPermission>(GetArg32(args, 2)); |
| 1202 | remote_perm = Convert<MemoryPermission>(GetReg32(system, 3)); | 1202 | remote_perm = Convert<MemoryPermission>(GetArg32(args, 3)); |
| 1203 | 1203 | ||
| 1204 | ret = CreateSharedMemory64From32(system, std::addressof(out_handle), size, owner_perm, remote_perm); | 1204 | ret = CreateSharedMemory64From32(system, std::addressof(out_handle), size, owner_perm, remote_perm); |
| 1205 | 1205 | ||
| 1206 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1206 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1207 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 1207 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 1208 | } | 1208 | } |
| 1209 | 1209 | ||
| 1210 | static void SvcWrap_MapTransferMemory64From32(Core::System& system) { | 1210 | static void SvcWrap_MapTransferMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1211 | Result ret{}; | 1211 | Result ret{}; |
| 1212 | 1212 | ||
| 1213 | Handle trmem_handle{}; | 1213 | Handle trmem_handle{}; |
| @@ -1215,67 +1215,67 @@ static void SvcWrap_MapTransferMemory64From32(Core::System& system) { | |||
| 1215 | uint32_t size{}; | 1215 | uint32_t size{}; |
| 1216 | MemoryPermission owner_perm{}; | 1216 | MemoryPermission owner_perm{}; |
| 1217 | 1217 | ||
| 1218 | trmem_handle = Convert<Handle>(GetReg32(system, 0)); | 1218 | trmem_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1219 | address = Convert<uint32_t>(GetReg32(system, 1)); | 1219 | address = Convert<uint32_t>(GetArg32(args, 1)); |
| 1220 | size = Convert<uint32_t>(GetReg32(system, 2)); | 1220 | size = Convert<uint32_t>(GetArg32(args, 2)); |
| 1221 | owner_perm = Convert<MemoryPermission>(GetReg32(system, 3)); | 1221 | owner_perm = Convert<MemoryPermission>(GetArg32(args, 3)); |
| 1222 | 1222 | ||
| 1223 | ret = MapTransferMemory64From32(system, trmem_handle, address, size, owner_perm); | 1223 | ret = MapTransferMemory64From32(system, trmem_handle, address, size, owner_perm); |
| 1224 | 1224 | ||
| 1225 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1225 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1226 | } | 1226 | } |
| 1227 | 1227 | ||
| 1228 | static void SvcWrap_UnmapTransferMemory64From32(Core::System& system) { | 1228 | static void SvcWrap_UnmapTransferMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1229 | Result ret{}; | 1229 | Result ret{}; |
| 1230 | 1230 | ||
| 1231 | Handle trmem_handle{}; | 1231 | Handle trmem_handle{}; |
| 1232 | uint32_t address{}; | 1232 | uint32_t address{}; |
| 1233 | uint32_t size{}; | 1233 | uint32_t size{}; |
| 1234 | 1234 | ||
| 1235 | trmem_handle = Convert<Handle>(GetReg32(system, 0)); | 1235 | trmem_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1236 | address = Convert<uint32_t>(GetReg32(system, 1)); | 1236 | address = Convert<uint32_t>(GetArg32(args, 1)); |
| 1237 | size = Convert<uint32_t>(GetReg32(system, 2)); | 1237 | size = Convert<uint32_t>(GetArg32(args, 2)); |
| 1238 | 1238 | ||
| 1239 | ret = UnmapTransferMemory64From32(system, trmem_handle, address, size); | 1239 | ret = UnmapTransferMemory64From32(system, trmem_handle, address, size); |
| 1240 | 1240 | ||
| 1241 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1241 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1242 | } | 1242 | } |
| 1243 | 1243 | ||
| 1244 | static void SvcWrap_CreateInterruptEvent64From32(Core::System& system) { | 1244 | static void SvcWrap_CreateInterruptEvent64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1245 | Result ret{}; | 1245 | Result ret{}; |
| 1246 | 1246 | ||
| 1247 | Handle out_read_handle{}; | 1247 | Handle out_read_handle{}; |
| 1248 | int32_t interrupt_id{}; | 1248 | int32_t interrupt_id{}; |
| 1249 | InterruptType interrupt_type{}; | 1249 | InterruptType interrupt_type{}; |
| 1250 | 1250 | ||
| 1251 | interrupt_id = Convert<int32_t>(GetReg32(system, 1)); | 1251 | interrupt_id = Convert<int32_t>(GetArg32(args, 1)); |
| 1252 | interrupt_type = Convert<InterruptType>(GetReg32(system, 2)); | 1252 | interrupt_type = Convert<InterruptType>(GetArg32(args, 2)); |
| 1253 | 1253 | ||
| 1254 | ret = CreateInterruptEvent64From32(system, std::addressof(out_read_handle), interrupt_id, interrupt_type); | 1254 | ret = CreateInterruptEvent64From32(system, std::addressof(out_read_handle), interrupt_id, interrupt_type); |
| 1255 | 1255 | ||
| 1256 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1256 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1257 | SetReg32(system, 1, Convert<uint32_t>(out_read_handle)); | 1257 | SetArg32(args, 1, Convert<uint32_t>(out_read_handle)); |
| 1258 | } | 1258 | } |
| 1259 | 1259 | ||
| 1260 | static void SvcWrap_QueryPhysicalAddress64From32(Core::System& system) { | 1260 | static void SvcWrap_QueryPhysicalAddress64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1261 | Result ret{}; | 1261 | Result ret{}; |
| 1262 | 1262 | ||
| 1263 | ilp32::PhysicalMemoryInfo out_info{}; | 1263 | ilp32::PhysicalMemoryInfo out_info{}; |
| 1264 | uint32_t address{}; | 1264 | uint32_t address{}; |
| 1265 | 1265 | ||
| 1266 | address = Convert<uint32_t>(GetReg32(system, 1)); | 1266 | address = Convert<uint32_t>(GetArg32(args, 1)); |
| 1267 | 1267 | ||
| 1268 | ret = QueryPhysicalAddress64From32(system, std::addressof(out_info), address); | 1268 | ret = QueryPhysicalAddress64From32(system, std::addressof(out_info), address); |
| 1269 | 1269 | ||
| 1270 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1270 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1271 | auto out_info_scatter = Convert<std::array<uint32_t, 4>>(out_info); | 1271 | auto out_info_scatter = Convert<std::array<uint32_t, 4>>(out_info); |
| 1272 | SetReg32(system, 1, out_info_scatter[0]); | 1272 | SetArg32(args, 1, out_info_scatter[0]); |
| 1273 | SetReg32(system, 2, out_info_scatter[1]); | 1273 | SetArg32(args, 2, out_info_scatter[1]); |
| 1274 | SetReg32(system, 3, out_info_scatter[2]); | 1274 | SetArg32(args, 3, out_info_scatter[2]); |
| 1275 | SetReg32(system, 4, out_info_scatter[3]); | 1275 | SetArg32(args, 4, out_info_scatter[3]); |
| 1276 | } | 1276 | } |
| 1277 | 1277 | ||
| 1278 | static void SvcWrap_QueryIoMapping64From32(Core::System& system) { | 1278 | static void SvcWrap_QueryIoMapping64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1279 | Result ret{}; | 1279 | Result ret{}; |
| 1280 | 1280 | ||
| 1281 | uint64_t out_address{}; | 1281 | uint64_t out_address{}; |
| @@ -1284,19 +1284,19 @@ static void SvcWrap_QueryIoMapping64From32(Core::System& system) { | |||
| 1284 | uint32_t size{}; | 1284 | uint32_t size{}; |
| 1285 | 1285 | ||
| 1286 | std::array<uint32_t, 2> physical_address_gather{}; | 1286 | std::array<uint32_t, 2> physical_address_gather{}; |
| 1287 | physical_address_gather[0] = GetReg32(system, 2); | 1287 | physical_address_gather[0] = GetArg32(args, 2); |
| 1288 | physical_address_gather[1] = GetReg32(system, 3); | 1288 | physical_address_gather[1] = GetArg32(args, 3); |
| 1289 | physical_address = Convert<uint64_t>(physical_address_gather); | 1289 | physical_address = Convert<uint64_t>(physical_address_gather); |
| 1290 | size = Convert<uint32_t>(GetReg32(system, 0)); | 1290 | size = Convert<uint32_t>(GetArg32(args, 0)); |
| 1291 | 1291 | ||
| 1292 | ret = QueryIoMapping64From32(system, std::addressof(out_address), std::addressof(out_size), physical_address, size); | 1292 | ret = QueryIoMapping64From32(system, std::addressof(out_address), std::addressof(out_size), physical_address, size); |
| 1293 | 1293 | ||
| 1294 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1294 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1295 | SetReg32(system, 1, Convert<uint32_t>(out_address)); | 1295 | SetArg32(args, 1, Convert<uint32_t>(out_address)); |
| 1296 | SetReg32(system, 2, Convert<uint32_t>(out_size)); | 1296 | SetArg32(args, 2, Convert<uint32_t>(out_size)); |
| 1297 | } | 1297 | } |
| 1298 | 1298 | ||
| 1299 | static void SvcWrap_CreateDeviceAddressSpace64From32(Core::System& system) { | 1299 | static void SvcWrap_CreateDeviceAddressSpace64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1300 | Result ret{}; | 1300 | Result ret{}; |
| 1301 | 1301 | ||
| 1302 | Handle out_handle{}; | 1302 | Handle out_handle{}; |
| @@ -1304,49 +1304,49 @@ static void SvcWrap_CreateDeviceAddressSpace64From32(Core::System& system) { | |||
| 1304 | uint64_t das_size{}; | 1304 | uint64_t das_size{}; |
| 1305 | 1305 | ||
| 1306 | std::array<uint32_t, 2> das_address_gather{}; | 1306 | std::array<uint32_t, 2> das_address_gather{}; |
| 1307 | das_address_gather[0] = GetReg32(system, 2); | 1307 | das_address_gather[0] = GetArg32(args, 2); |
| 1308 | das_address_gather[1] = GetReg32(system, 3); | 1308 | das_address_gather[1] = GetArg32(args, 3); |
| 1309 | das_address = Convert<uint64_t>(das_address_gather); | 1309 | das_address = Convert<uint64_t>(das_address_gather); |
| 1310 | std::array<uint32_t, 2> das_size_gather{}; | 1310 | std::array<uint32_t, 2> das_size_gather{}; |
| 1311 | das_size_gather[0] = GetReg32(system, 0); | 1311 | das_size_gather[0] = GetArg32(args, 0); |
| 1312 | das_size_gather[1] = GetReg32(system, 1); | 1312 | das_size_gather[1] = GetArg32(args, 1); |
| 1313 | das_size = Convert<uint64_t>(das_size_gather); | 1313 | das_size = Convert<uint64_t>(das_size_gather); |
| 1314 | 1314 | ||
| 1315 | ret = CreateDeviceAddressSpace64From32(system, std::addressof(out_handle), das_address, das_size); | 1315 | ret = CreateDeviceAddressSpace64From32(system, std::addressof(out_handle), das_address, das_size); |
| 1316 | 1316 | ||
| 1317 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1317 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1318 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 1318 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 1319 | } | 1319 | } |
| 1320 | 1320 | ||
| 1321 | static void SvcWrap_AttachDeviceAddressSpace64From32(Core::System& system) { | 1321 | static void SvcWrap_AttachDeviceAddressSpace64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1322 | Result ret{}; | 1322 | Result ret{}; |
| 1323 | 1323 | ||
| 1324 | DeviceName device_name{}; | 1324 | DeviceName device_name{}; |
| 1325 | Handle das_handle{}; | 1325 | Handle das_handle{}; |
| 1326 | 1326 | ||
| 1327 | device_name = Convert<DeviceName>(GetReg32(system, 0)); | 1327 | device_name = Convert<DeviceName>(GetArg32(args, 0)); |
| 1328 | das_handle = Convert<Handle>(GetReg32(system, 1)); | 1328 | das_handle = Convert<Handle>(GetArg32(args, 1)); |
| 1329 | 1329 | ||
| 1330 | ret = AttachDeviceAddressSpace64From32(system, device_name, das_handle); | 1330 | ret = AttachDeviceAddressSpace64From32(system, device_name, das_handle); |
| 1331 | 1331 | ||
| 1332 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1332 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1333 | } | 1333 | } |
| 1334 | 1334 | ||
| 1335 | static void SvcWrap_DetachDeviceAddressSpace64From32(Core::System& system) { | 1335 | static void SvcWrap_DetachDeviceAddressSpace64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1336 | Result ret{}; | 1336 | Result ret{}; |
| 1337 | 1337 | ||
| 1338 | DeviceName device_name{}; | 1338 | DeviceName device_name{}; |
| 1339 | Handle das_handle{}; | 1339 | Handle das_handle{}; |
| 1340 | 1340 | ||
| 1341 | device_name = Convert<DeviceName>(GetReg32(system, 0)); | 1341 | device_name = Convert<DeviceName>(GetArg32(args, 0)); |
| 1342 | das_handle = Convert<Handle>(GetReg32(system, 1)); | 1342 | das_handle = Convert<Handle>(GetArg32(args, 1)); |
| 1343 | 1343 | ||
| 1344 | ret = DetachDeviceAddressSpace64From32(system, device_name, das_handle); | 1344 | ret = DetachDeviceAddressSpace64From32(system, device_name, das_handle); |
| 1345 | 1345 | ||
| 1346 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1346 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1347 | } | 1347 | } |
| 1348 | 1348 | ||
| 1349 | static void SvcWrap_MapDeviceAddressSpaceByForce64From32(Core::System& system) { | 1349 | static void SvcWrap_MapDeviceAddressSpaceByForce64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1350 | Result ret{}; | 1350 | Result ret{}; |
| 1351 | 1351 | ||
| 1352 | Handle das_handle{}; | 1352 | Handle das_handle{}; |
| @@ -1356,25 +1356,25 @@ static void SvcWrap_MapDeviceAddressSpaceByForce64From32(Core::System& system) { | |||
| 1356 | uint64_t device_address{}; | 1356 | uint64_t device_address{}; |
| 1357 | uint32_t option{}; | 1357 | uint32_t option{}; |
| 1358 | 1358 | ||
| 1359 | das_handle = Convert<Handle>(GetReg32(system, 0)); | 1359 | das_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1360 | process_handle = Convert<Handle>(GetReg32(system, 1)); | 1360 | process_handle = Convert<Handle>(GetArg32(args, 1)); |
| 1361 | std::array<uint32_t, 2> process_address_gather{}; | 1361 | std::array<uint32_t, 2> process_address_gather{}; |
| 1362 | process_address_gather[0] = GetReg32(system, 2); | 1362 | process_address_gather[0] = GetArg32(args, 2); |
| 1363 | process_address_gather[1] = GetReg32(system, 3); | 1363 | process_address_gather[1] = GetArg32(args, 3); |
| 1364 | process_address = Convert<uint64_t>(process_address_gather); | 1364 | process_address = Convert<uint64_t>(process_address_gather); |
| 1365 | size = Convert<uint32_t>(GetReg32(system, 4)); | 1365 | size = Convert<uint32_t>(GetArg32(args, 4)); |
| 1366 | std::array<uint32_t, 2> device_address_gather{}; | 1366 | std::array<uint32_t, 2> device_address_gather{}; |
| 1367 | device_address_gather[0] = GetReg32(system, 5); | 1367 | device_address_gather[0] = GetArg32(args, 5); |
| 1368 | device_address_gather[1] = GetReg32(system, 6); | 1368 | device_address_gather[1] = GetArg32(args, 6); |
| 1369 | device_address = Convert<uint64_t>(device_address_gather); | 1369 | device_address = Convert<uint64_t>(device_address_gather); |
| 1370 | option = Convert<uint32_t>(GetReg32(system, 7)); | 1370 | option = Convert<uint32_t>(GetArg32(args, 7)); |
| 1371 | 1371 | ||
| 1372 | ret = MapDeviceAddressSpaceByForce64From32(system, das_handle, process_handle, process_address, size, device_address, option); | 1372 | ret = MapDeviceAddressSpaceByForce64From32(system, das_handle, process_handle, process_address, size, device_address, option); |
| 1373 | 1373 | ||
| 1374 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1374 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1375 | } | 1375 | } |
| 1376 | 1376 | ||
| 1377 | static void SvcWrap_MapDeviceAddressSpaceAligned64From32(Core::System& system) { | 1377 | static void SvcWrap_MapDeviceAddressSpaceAligned64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1378 | Result ret{}; | 1378 | Result ret{}; |
| 1379 | 1379 | ||
| 1380 | Handle das_handle{}; | 1380 | Handle das_handle{}; |
| @@ -1384,25 +1384,25 @@ static void SvcWrap_MapDeviceAddressSpaceAligned64From32(Core::System& system) { | |||
| 1384 | uint64_t device_address{}; | 1384 | uint64_t device_address{}; |
| 1385 | uint32_t option{}; | 1385 | uint32_t option{}; |
| 1386 | 1386 | ||
| 1387 | das_handle = Convert<Handle>(GetReg32(system, 0)); | 1387 | das_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1388 | process_handle = Convert<Handle>(GetReg32(system, 1)); | 1388 | process_handle = Convert<Handle>(GetArg32(args, 1)); |
| 1389 | std::array<uint32_t, 2> process_address_gather{}; | 1389 | std::array<uint32_t, 2> process_address_gather{}; |
| 1390 | process_address_gather[0] = GetReg32(system, 2); | 1390 | process_address_gather[0] = GetArg32(args, 2); |
| 1391 | process_address_gather[1] = GetReg32(system, 3); | 1391 | process_address_gather[1] = GetArg32(args, 3); |
| 1392 | process_address = Convert<uint64_t>(process_address_gather); | 1392 | process_address = Convert<uint64_t>(process_address_gather); |
| 1393 | size = Convert<uint32_t>(GetReg32(system, 4)); | 1393 | size = Convert<uint32_t>(GetArg32(args, 4)); |
| 1394 | std::array<uint32_t, 2> device_address_gather{}; | 1394 | std::array<uint32_t, 2> device_address_gather{}; |
| 1395 | device_address_gather[0] = GetReg32(system, 5); | 1395 | device_address_gather[0] = GetArg32(args, 5); |
| 1396 | device_address_gather[1] = GetReg32(system, 6); | 1396 | device_address_gather[1] = GetArg32(args, 6); |
| 1397 | device_address = Convert<uint64_t>(device_address_gather); | 1397 | device_address = Convert<uint64_t>(device_address_gather); |
| 1398 | option = Convert<uint32_t>(GetReg32(system, 7)); | 1398 | option = Convert<uint32_t>(GetArg32(args, 7)); |
| 1399 | 1399 | ||
| 1400 | ret = MapDeviceAddressSpaceAligned64From32(system, das_handle, process_handle, process_address, size, device_address, option); | 1400 | ret = MapDeviceAddressSpaceAligned64From32(system, das_handle, process_handle, process_address, size, device_address, option); |
| 1401 | 1401 | ||
| 1402 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1402 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1403 | } | 1403 | } |
| 1404 | 1404 | ||
| 1405 | static void SvcWrap_UnmapDeviceAddressSpace64From32(Core::System& system) { | 1405 | static void SvcWrap_UnmapDeviceAddressSpace64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1406 | Result ret{}; | 1406 | Result ret{}; |
| 1407 | 1407 | ||
| 1408 | Handle das_handle{}; | 1408 | Handle das_handle{}; |
| @@ -1411,145 +1411,145 @@ static void SvcWrap_UnmapDeviceAddressSpace64From32(Core::System& system) { | |||
| 1411 | uint32_t size{}; | 1411 | uint32_t size{}; |
| 1412 | uint64_t device_address{}; | 1412 | uint64_t device_address{}; |
| 1413 | 1413 | ||
| 1414 | das_handle = Convert<Handle>(GetReg32(system, 0)); | 1414 | das_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1415 | process_handle = Convert<Handle>(GetReg32(system, 1)); | 1415 | process_handle = Convert<Handle>(GetArg32(args, 1)); |
| 1416 | std::array<uint32_t, 2> process_address_gather{}; | 1416 | std::array<uint32_t, 2> process_address_gather{}; |
| 1417 | process_address_gather[0] = GetReg32(system, 2); | 1417 | process_address_gather[0] = GetArg32(args, 2); |
| 1418 | process_address_gather[1] = GetReg32(system, 3); | 1418 | process_address_gather[1] = GetArg32(args, 3); |
| 1419 | process_address = Convert<uint64_t>(process_address_gather); | 1419 | process_address = Convert<uint64_t>(process_address_gather); |
| 1420 | size = Convert<uint32_t>(GetReg32(system, 4)); | 1420 | size = Convert<uint32_t>(GetArg32(args, 4)); |
| 1421 | std::array<uint32_t, 2> device_address_gather{}; | 1421 | std::array<uint32_t, 2> device_address_gather{}; |
| 1422 | device_address_gather[0] = GetReg32(system, 5); | 1422 | device_address_gather[0] = GetArg32(args, 5); |
| 1423 | device_address_gather[1] = GetReg32(system, 6); | 1423 | device_address_gather[1] = GetArg32(args, 6); |
| 1424 | device_address = Convert<uint64_t>(device_address_gather); | 1424 | device_address = Convert<uint64_t>(device_address_gather); |
| 1425 | 1425 | ||
| 1426 | ret = UnmapDeviceAddressSpace64From32(system, das_handle, process_handle, process_address, size, device_address); | 1426 | ret = UnmapDeviceAddressSpace64From32(system, das_handle, process_handle, process_address, size, device_address); |
| 1427 | 1427 | ||
| 1428 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1428 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1429 | } | 1429 | } |
| 1430 | 1430 | ||
| 1431 | static void SvcWrap_InvalidateProcessDataCache64From32(Core::System& system) { | 1431 | static void SvcWrap_InvalidateProcessDataCache64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1432 | Result ret{}; | 1432 | Result ret{}; |
| 1433 | 1433 | ||
| 1434 | Handle process_handle{}; | 1434 | Handle process_handle{}; |
| 1435 | uint64_t address{}; | 1435 | uint64_t address{}; |
| 1436 | uint64_t size{}; | 1436 | uint64_t size{}; |
| 1437 | 1437 | ||
| 1438 | process_handle = Convert<Handle>(GetReg32(system, 0)); | 1438 | process_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1439 | std::array<uint32_t, 2> address_gather{}; | 1439 | std::array<uint32_t, 2> address_gather{}; |
| 1440 | address_gather[0] = GetReg32(system, 2); | 1440 | address_gather[0] = GetArg32(args, 2); |
| 1441 | address_gather[1] = GetReg32(system, 3); | 1441 | address_gather[1] = GetArg32(args, 3); |
| 1442 | address = Convert<uint64_t>(address_gather); | 1442 | address = Convert<uint64_t>(address_gather); |
| 1443 | std::array<uint32_t, 2> size_gather{}; | 1443 | std::array<uint32_t, 2> size_gather{}; |
| 1444 | size_gather[0] = GetReg32(system, 1); | 1444 | size_gather[0] = GetArg32(args, 1); |
| 1445 | size_gather[1] = GetReg32(system, 4); | 1445 | size_gather[1] = GetArg32(args, 4); |
| 1446 | size = Convert<uint64_t>(size_gather); | 1446 | size = Convert<uint64_t>(size_gather); |
| 1447 | 1447 | ||
| 1448 | ret = InvalidateProcessDataCache64From32(system, process_handle, address, size); | 1448 | ret = InvalidateProcessDataCache64From32(system, process_handle, address, size); |
| 1449 | 1449 | ||
| 1450 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1450 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1451 | } | 1451 | } |
| 1452 | 1452 | ||
| 1453 | static void SvcWrap_StoreProcessDataCache64From32(Core::System& system) { | 1453 | static void SvcWrap_StoreProcessDataCache64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1454 | Result ret{}; | 1454 | Result ret{}; |
| 1455 | 1455 | ||
| 1456 | Handle process_handle{}; | 1456 | Handle process_handle{}; |
| 1457 | uint64_t address{}; | 1457 | uint64_t address{}; |
| 1458 | uint64_t size{}; | 1458 | uint64_t size{}; |
| 1459 | 1459 | ||
| 1460 | process_handle = Convert<Handle>(GetReg32(system, 0)); | 1460 | process_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1461 | std::array<uint32_t, 2> address_gather{}; | 1461 | std::array<uint32_t, 2> address_gather{}; |
| 1462 | address_gather[0] = GetReg32(system, 2); | 1462 | address_gather[0] = GetArg32(args, 2); |
| 1463 | address_gather[1] = GetReg32(system, 3); | 1463 | address_gather[1] = GetArg32(args, 3); |
| 1464 | address = Convert<uint64_t>(address_gather); | 1464 | address = Convert<uint64_t>(address_gather); |
| 1465 | std::array<uint32_t, 2> size_gather{}; | 1465 | std::array<uint32_t, 2> size_gather{}; |
| 1466 | size_gather[0] = GetReg32(system, 1); | 1466 | size_gather[0] = GetArg32(args, 1); |
| 1467 | size_gather[1] = GetReg32(system, 4); | 1467 | size_gather[1] = GetArg32(args, 4); |
| 1468 | size = Convert<uint64_t>(size_gather); | 1468 | size = Convert<uint64_t>(size_gather); |
| 1469 | 1469 | ||
| 1470 | ret = StoreProcessDataCache64From32(system, process_handle, address, size); | 1470 | ret = StoreProcessDataCache64From32(system, process_handle, address, size); |
| 1471 | 1471 | ||
| 1472 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1472 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1473 | } | 1473 | } |
| 1474 | 1474 | ||
| 1475 | static void SvcWrap_FlushProcessDataCache64From32(Core::System& system) { | 1475 | static void SvcWrap_FlushProcessDataCache64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1476 | Result ret{}; | 1476 | Result ret{}; |
| 1477 | 1477 | ||
| 1478 | Handle process_handle{}; | 1478 | Handle process_handle{}; |
| 1479 | uint64_t address{}; | 1479 | uint64_t address{}; |
| 1480 | uint64_t size{}; | 1480 | uint64_t size{}; |
| 1481 | 1481 | ||
| 1482 | process_handle = Convert<Handle>(GetReg32(system, 0)); | 1482 | process_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1483 | std::array<uint32_t, 2> address_gather{}; | 1483 | std::array<uint32_t, 2> address_gather{}; |
| 1484 | address_gather[0] = GetReg32(system, 2); | 1484 | address_gather[0] = GetArg32(args, 2); |
| 1485 | address_gather[1] = GetReg32(system, 3); | 1485 | address_gather[1] = GetArg32(args, 3); |
| 1486 | address = Convert<uint64_t>(address_gather); | 1486 | address = Convert<uint64_t>(address_gather); |
| 1487 | std::array<uint32_t, 2> size_gather{}; | 1487 | std::array<uint32_t, 2> size_gather{}; |
| 1488 | size_gather[0] = GetReg32(system, 1); | 1488 | size_gather[0] = GetArg32(args, 1); |
| 1489 | size_gather[1] = GetReg32(system, 4); | 1489 | size_gather[1] = GetArg32(args, 4); |
| 1490 | size = Convert<uint64_t>(size_gather); | 1490 | size = Convert<uint64_t>(size_gather); |
| 1491 | 1491 | ||
| 1492 | ret = FlushProcessDataCache64From32(system, process_handle, address, size); | 1492 | ret = FlushProcessDataCache64From32(system, process_handle, address, size); |
| 1493 | 1493 | ||
| 1494 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1494 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1495 | } | 1495 | } |
| 1496 | 1496 | ||
| 1497 | static void SvcWrap_DebugActiveProcess64From32(Core::System& system) { | 1497 | static void SvcWrap_DebugActiveProcess64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1498 | Result ret{}; | 1498 | Result ret{}; |
| 1499 | 1499 | ||
| 1500 | Handle out_handle{}; | 1500 | Handle out_handle{}; |
| 1501 | uint64_t process_id{}; | 1501 | uint64_t process_id{}; |
| 1502 | 1502 | ||
| 1503 | std::array<uint32_t, 2> process_id_gather{}; | 1503 | std::array<uint32_t, 2> process_id_gather{}; |
| 1504 | process_id_gather[0] = GetReg32(system, 2); | 1504 | process_id_gather[0] = GetArg32(args, 2); |
| 1505 | process_id_gather[1] = GetReg32(system, 3); | 1505 | process_id_gather[1] = GetArg32(args, 3); |
| 1506 | process_id = Convert<uint64_t>(process_id_gather); | 1506 | process_id = Convert<uint64_t>(process_id_gather); |
| 1507 | 1507 | ||
| 1508 | ret = DebugActiveProcess64From32(system, std::addressof(out_handle), process_id); | 1508 | ret = DebugActiveProcess64From32(system, std::addressof(out_handle), process_id); |
| 1509 | 1509 | ||
| 1510 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1510 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1511 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 1511 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 1512 | } | 1512 | } |
| 1513 | 1513 | ||
| 1514 | static void SvcWrap_BreakDebugProcess64From32(Core::System& system) { | 1514 | static void SvcWrap_BreakDebugProcess64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1515 | Result ret{}; | 1515 | Result ret{}; |
| 1516 | 1516 | ||
| 1517 | Handle debug_handle{}; | 1517 | Handle debug_handle{}; |
| 1518 | 1518 | ||
| 1519 | debug_handle = Convert<Handle>(GetReg32(system, 0)); | 1519 | debug_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1520 | 1520 | ||
| 1521 | ret = BreakDebugProcess64From32(system, debug_handle); | 1521 | ret = BreakDebugProcess64From32(system, debug_handle); |
| 1522 | 1522 | ||
| 1523 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1523 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1524 | } | 1524 | } |
| 1525 | 1525 | ||
| 1526 | static void SvcWrap_TerminateDebugProcess64From32(Core::System& system) { | 1526 | static void SvcWrap_TerminateDebugProcess64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1527 | Result ret{}; | 1527 | Result ret{}; |
| 1528 | 1528 | ||
| 1529 | Handle debug_handle{}; | 1529 | Handle debug_handle{}; |
| 1530 | 1530 | ||
| 1531 | debug_handle = Convert<Handle>(GetReg32(system, 0)); | 1531 | debug_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1532 | 1532 | ||
| 1533 | ret = TerminateDebugProcess64From32(system, debug_handle); | 1533 | ret = TerminateDebugProcess64From32(system, debug_handle); |
| 1534 | 1534 | ||
| 1535 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1535 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1536 | } | 1536 | } |
| 1537 | 1537 | ||
| 1538 | static void SvcWrap_GetDebugEvent64From32(Core::System& system) { | 1538 | static void SvcWrap_GetDebugEvent64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1539 | Result ret{}; | 1539 | Result ret{}; |
| 1540 | 1540 | ||
| 1541 | uint32_t out_info{}; | 1541 | uint32_t out_info{}; |
| 1542 | Handle debug_handle{}; | 1542 | Handle debug_handle{}; |
| 1543 | 1543 | ||
| 1544 | out_info = Convert<uint32_t>(GetReg32(system, 0)); | 1544 | out_info = Convert<uint32_t>(GetArg32(args, 0)); |
| 1545 | debug_handle = Convert<Handle>(GetReg32(system, 1)); | 1545 | debug_handle = Convert<Handle>(GetArg32(args, 1)); |
| 1546 | 1546 | ||
| 1547 | ret = GetDebugEvent64From32(system, out_info, debug_handle); | 1547 | ret = GetDebugEvent64From32(system, out_info, debug_handle); |
| 1548 | 1548 | ||
| 1549 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1549 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1550 | } | 1550 | } |
| 1551 | 1551 | ||
| 1552 | static void SvcWrap_ContinueDebugEvent64From32(Core::System& system) { | 1552 | static void SvcWrap_ContinueDebugEvent64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1553 | Result ret{}; | 1553 | Result ret{}; |
| 1554 | 1554 | ||
| 1555 | Handle debug_handle{}; | 1555 | Handle debug_handle{}; |
| @@ -1557,33 +1557,33 @@ static void SvcWrap_ContinueDebugEvent64From32(Core::System& system) { | |||
| 1557 | uint32_t thread_ids{}; | 1557 | uint32_t thread_ids{}; |
| 1558 | int32_t num_thread_ids{}; | 1558 | int32_t num_thread_ids{}; |
| 1559 | 1559 | ||
| 1560 | debug_handle = Convert<Handle>(GetReg32(system, 0)); | 1560 | debug_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1561 | flags = Convert<uint32_t>(GetReg32(system, 1)); | 1561 | flags = Convert<uint32_t>(GetArg32(args, 1)); |
| 1562 | thread_ids = Convert<uint32_t>(GetReg32(system, 2)); | 1562 | thread_ids = Convert<uint32_t>(GetArg32(args, 2)); |
| 1563 | num_thread_ids = Convert<int32_t>(GetReg32(system, 3)); | 1563 | num_thread_ids = Convert<int32_t>(GetArg32(args, 3)); |
| 1564 | 1564 | ||
| 1565 | ret = ContinueDebugEvent64From32(system, debug_handle, flags, thread_ids, num_thread_ids); | 1565 | ret = ContinueDebugEvent64From32(system, debug_handle, flags, thread_ids, num_thread_ids); |
| 1566 | 1566 | ||
| 1567 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1567 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1568 | } | 1568 | } |
| 1569 | 1569 | ||
| 1570 | static void SvcWrap_GetProcessList64From32(Core::System& system) { | 1570 | static void SvcWrap_GetProcessList64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1571 | Result ret{}; | 1571 | Result ret{}; |
| 1572 | 1572 | ||
| 1573 | int32_t out_num_processes{}; | 1573 | int32_t out_num_processes{}; |
| 1574 | uint32_t out_process_ids{}; | 1574 | uint32_t out_process_ids{}; |
| 1575 | int32_t max_out_count{}; | 1575 | int32_t max_out_count{}; |
| 1576 | 1576 | ||
| 1577 | out_process_ids = Convert<uint32_t>(GetReg32(system, 1)); | 1577 | out_process_ids = Convert<uint32_t>(GetArg32(args, 1)); |
| 1578 | max_out_count = Convert<int32_t>(GetReg32(system, 2)); | 1578 | max_out_count = Convert<int32_t>(GetArg32(args, 2)); |
| 1579 | 1579 | ||
| 1580 | ret = GetProcessList64From32(system, std::addressof(out_num_processes), out_process_ids, max_out_count); | 1580 | ret = GetProcessList64From32(system, std::addressof(out_num_processes), out_process_ids, max_out_count); |
| 1581 | 1581 | ||
| 1582 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1582 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1583 | SetReg32(system, 1, Convert<uint32_t>(out_num_processes)); | 1583 | SetArg32(args, 1, Convert<uint32_t>(out_num_processes)); |
| 1584 | } | 1584 | } |
| 1585 | 1585 | ||
| 1586 | static void SvcWrap_GetThreadList64From32(Core::System& system) { | 1586 | static void SvcWrap_GetThreadList64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1587 | Result ret{}; | 1587 | Result ret{}; |
| 1588 | 1588 | ||
| 1589 | int32_t out_num_threads{}; | 1589 | int32_t out_num_threads{}; |
| @@ -1591,17 +1591,17 @@ static void SvcWrap_GetThreadList64From32(Core::System& system) { | |||
| 1591 | int32_t max_out_count{}; | 1591 | int32_t max_out_count{}; |
| 1592 | Handle debug_handle{}; | 1592 | Handle debug_handle{}; |
| 1593 | 1593 | ||
| 1594 | out_thread_ids = Convert<uint32_t>(GetReg32(system, 1)); | 1594 | out_thread_ids = Convert<uint32_t>(GetArg32(args, 1)); |
| 1595 | max_out_count = Convert<int32_t>(GetReg32(system, 2)); | 1595 | max_out_count = Convert<int32_t>(GetArg32(args, 2)); |
| 1596 | debug_handle = Convert<Handle>(GetReg32(system, 3)); | 1596 | debug_handle = Convert<Handle>(GetArg32(args, 3)); |
| 1597 | 1597 | ||
| 1598 | ret = GetThreadList64From32(system, std::addressof(out_num_threads), out_thread_ids, max_out_count, debug_handle); | 1598 | ret = GetThreadList64From32(system, std::addressof(out_num_threads), out_thread_ids, max_out_count, debug_handle); |
| 1599 | 1599 | ||
| 1600 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1600 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1601 | SetReg32(system, 1, Convert<uint32_t>(out_num_threads)); | 1601 | SetArg32(args, 1, Convert<uint32_t>(out_num_threads)); |
| 1602 | } | 1602 | } |
| 1603 | 1603 | ||
| 1604 | static void SvcWrap_GetDebugThreadContext64From32(Core::System& system) { | 1604 | static void SvcWrap_GetDebugThreadContext64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1605 | Result ret{}; | 1605 | Result ret{}; |
| 1606 | 1606 | ||
| 1607 | uint32_t out_context{}; | 1607 | uint32_t out_context{}; |
| @@ -1609,20 +1609,20 @@ static void SvcWrap_GetDebugThreadContext64From32(Core::System& system) { | |||
| 1609 | uint64_t thread_id{}; | 1609 | uint64_t thread_id{}; |
| 1610 | uint32_t context_flags{}; | 1610 | uint32_t context_flags{}; |
| 1611 | 1611 | ||
| 1612 | out_context = Convert<uint32_t>(GetReg32(system, 0)); | 1612 | out_context = Convert<uint32_t>(GetArg32(args, 0)); |
| 1613 | debug_handle = Convert<Handle>(GetReg32(system, 1)); | 1613 | debug_handle = Convert<Handle>(GetArg32(args, 1)); |
| 1614 | std::array<uint32_t, 2> thread_id_gather{}; | 1614 | std::array<uint32_t, 2> thread_id_gather{}; |
| 1615 | thread_id_gather[0] = GetReg32(system, 2); | 1615 | thread_id_gather[0] = GetArg32(args, 2); |
| 1616 | thread_id_gather[1] = GetReg32(system, 3); | 1616 | thread_id_gather[1] = GetArg32(args, 3); |
| 1617 | thread_id = Convert<uint64_t>(thread_id_gather); | 1617 | thread_id = Convert<uint64_t>(thread_id_gather); |
| 1618 | context_flags = Convert<uint32_t>(GetReg32(system, 4)); | 1618 | context_flags = Convert<uint32_t>(GetArg32(args, 4)); |
| 1619 | 1619 | ||
| 1620 | ret = GetDebugThreadContext64From32(system, out_context, debug_handle, thread_id, context_flags); | 1620 | ret = GetDebugThreadContext64From32(system, out_context, debug_handle, thread_id, context_flags); |
| 1621 | 1621 | ||
| 1622 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1622 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1623 | } | 1623 | } |
| 1624 | 1624 | ||
| 1625 | static void SvcWrap_SetDebugThreadContext64From32(Core::System& system) { | 1625 | static void SvcWrap_SetDebugThreadContext64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1626 | Result ret{}; | 1626 | Result ret{}; |
| 1627 | 1627 | ||
| 1628 | Handle debug_handle{}; | 1628 | Handle debug_handle{}; |
| @@ -1630,20 +1630,20 @@ static void SvcWrap_SetDebugThreadContext64From32(Core::System& system) { | |||
| 1630 | uint32_t context{}; | 1630 | uint32_t context{}; |
| 1631 | uint32_t context_flags{}; | 1631 | uint32_t context_flags{}; |
| 1632 | 1632 | ||
| 1633 | debug_handle = Convert<Handle>(GetReg32(system, 0)); | 1633 | debug_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1634 | std::array<uint32_t, 2> thread_id_gather{}; | 1634 | std::array<uint32_t, 2> thread_id_gather{}; |
| 1635 | thread_id_gather[0] = GetReg32(system, 2); | 1635 | thread_id_gather[0] = GetArg32(args, 2); |
| 1636 | thread_id_gather[1] = GetReg32(system, 3); | 1636 | thread_id_gather[1] = GetArg32(args, 3); |
| 1637 | thread_id = Convert<uint64_t>(thread_id_gather); | 1637 | thread_id = Convert<uint64_t>(thread_id_gather); |
| 1638 | context = Convert<uint32_t>(GetReg32(system, 1)); | 1638 | context = Convert<uint32_t>(GetArg32(args, 1)); |
| 1639 | context_flags = Convert<uint32_t>(GetReg32(system, 4)); | 1639 | context_flags = Convert<uint32_t>(GetArg32(args, 4)); |
| 1640 | 1640 | ||
| 1641 | ret = SetDebugThreadContext64From32(system, debug_handle, thread_id, context, context_flags); | 1641 | ret = SetDebugThreadContext64From32(system, debug_handle, thread_id, context, context_flags); |
| 1642 | 1642 | ||
| 1643 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1643 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1644 | } | 1644 | } |
| 1645 | 1645 | ||
| 1646 | static void SvcWrap_QueryDebugProcessMemory64From32(Core::System& system) { | 1646 | static void SvcWrap_QueryDebugProcessMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1647 | Result ret{}; | 1647 | Result ret{}; |
| 1648 | 1648 | ||
| 1649 | PageInfo out_page_info{}; | 1649 | PageInfo out_page_info{}; |
| @@ -1651,17 +1651,17 @@ static void SvcWrap_QueryDebugProcessMemory64From32(Core::System& system) { | |||
| 1651 | Handle process_handle{}; | 1651 | Handle process_handle{}; |
| 1652 | uint32_t address{}; | 1652 | uint32_t address{}; |
| 1653 | 1653 | ||
| 1654 | out_memory_info = Convert<uint32_t>(GetReg32(system, 0)); | 1654 | out_memory_info = Convert<uint32_t>(GetArg32(args, 0)); |
| 1655 | process_handle = Convert<Handle>(GetReg32(system, 2)); | 1655 | process_handle = Convert<Handle>(GetArg32(args, 2)); |
| 1656 | address = Convert<uint32_t>(GetReg32(system, 3)); | 1656 | address = Convert<uint32_t>(GetArg32(args, 3)); |
| 1657 | 1657 | ||
| 1658 | ret = QueryDebugProcessMemory64From32(system, out_memory_info, std::addressof(out_page_info), process_handle, address); | 1658 | ret = QueryDebugProcessMemory64From32(system, out_memory_info, std::addressof(out_page_info), process_handle, address); |
| 1659 | 1659 | ||
| 1660 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1660 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1661 | SetReg32(system, 1, Convert<uint32_t>(out_page_info)); | 1661 | SetArg32(args, 1, Convert<uint32_t>(out_page_info)); |
| 1662 | } | 1662 | } |
| 1663 | 1663 | ||
| 1664 | static void SvcWrap_ReadDebugProcessMemory64From32(Core::System& system) { | 1664 | static void SvcWrap_ReadDebugProcessMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1665 | Result ret{}; | 1665 | Result ret{}; |
| 1666 | 1666 | ||
| 1667 | uint32_t buffer{}; | 1667 | uint32_t buffer{}; |
| @@ -1669,17 +1669,17 @@ static void SvcWrap_ReadDebugProcessMemory64From32(Core::System& system) { | |||
| 1669 | uint32_t address{}; | 1669 | uint32_t address{}; |
| 1670 | uint32_t size{}; | 1670 | uint32_t size{}; |
| 1671 | 1671 | ||
| 1672 | buffer = Convert<uint32_t>(GetReg32(system, 0)); | 1672 | buffer = Convert<uint32_t>(GetArg32(args, 0)); |
| 1673 | debug_handle = Convert<Handle>(GetReg32(system, 1)); | 1673 | debug_handle = Convert<Handle>(GetArg32(args, 1)); |
| 1674 | address = Convert<uint32_t>(GetReg32(system, 2)); | 1674 | address = Convert<uint32_t>(GetArg32(args, 2)); |
| 1675 | size = Convert<uint32_t>(GetReg32(system, 3)); | 1675 | size = Convert<uint32_t>(GetArg32(args, 3)); |
| 1676 | 1676 | ||
| 1677 | ret = ReadDebugProcessMemory64From32(system, buffer, debug_handle, address, size); | 1677 | ret = ReadDebugProcessMemory64From32(system, buffer, debug_handle, address, size); |
| 1678 | 1678 | ||
| 1679 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1679 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1680 | } | 1680 | } |
| 1681 | 1681 | ||
| 1682 | static void SvcWrap_WriteDebugProcessMemory64From32(Core::System& system) { | 1682 | static void SvcWrap_WriteDebugProcessMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1683 | Result ret{}; | 1683 | Result ret{}; |
| 1684 | 1684 | ||
| 1685 | Handle debug_handle{}; | 1685 | Handle debug_handle{}; |
| @@ -1687,39 +1687,39 @@ static void SvcWrap_WriteDebugProcessMemory64From32(Core::System& system) { | |||
| 1687 | uint32_t address{}; | 1687 | uint32_t address{}; |
| 1688 | uint32_t size{}; | 1688 | uint32_t size{}; |
| 1689 | 1689 | ||
| 1690 | debug_handle = Convert<Handle>(GetReg32(system, 0)); | 1690 | debug_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1691 | buffer = Convert<uint32_t>(GetReg32(system, 1)); | 1691 | buffer = Convert<uint32_t>(GetArg32(args, 1)); |
| 1692 | address = Convert<uint32_t>(GetReg32(system, 2)); | 1692 | address = Convert<uint32_t>(GetArg32(args, 2)); |
| 1693 | size = Convert<uint32_t>(GetReg32(system, 3)); | 1693 | size = Convert<uint32_t>(GetArg32(args, 3)); |
| 1694 | 1694 | ||
| 1695 | ret = WriteDebugProcessMemory64From32(system, debug_handle, buffer, address, size); | 1695 | ret = WriteDebugProcessMemory64From32(system, debug_handle, buffer, address, size); |
| 1696 | 1696 | ||
| 1697 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1697 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1698 | } | 1698 | } |
| 1699 | 1699 | ||
| 1700 | static void SvcWrap_SetHardwareBreakPoint64From32(Core::System& system) { | 1700 | static void SvcWrap_SetHardwareBreakPoint64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1701 | Result ret{}; | 1701 | Result ret{}; |
| 1702 | 1702 | ||
| 1703 | HardwareBreakPointRegisterName name{}; | 1703 | HardwareBreakPointRegisterName name{}; |
| 1704 | uint64_t flags{}; | 1704 | uint64_t flags{}; |
| 1705 | uint64_t value{}; | 1705 | uint64_t value{}; |
| 1706 | 1706 | ||
| 1707 | name = Convert<HardwareBreakPointRegisterName>(GetReg32(system, 0)); | 1707 | name = Convert<HardwareBreakPointRegisterName>(GetArg32(args, 0)); |
| 1708 | std::array<uint32_t, 2> flags_gather{}; | 1708 | std::array<uint32_t, 2> flags_gather{}; |
| 1709 | flags_gather[0] = GetReg32(system, 2); | 1709 | flags_gather[0] = GetArg32(args, 2); |
| 1710 | flags_gather[1] = GetReg32(system, 3); | 1710 | flags_gather[1] = GetArg32(args, 3); |
| 1711 | flags = Convert<uint64_t>(flags_gather); | 1711 | flags = Convert<uint64_t>(flags_gather); |
| 1712 | std::array<uint32_t, 2> value_gather{}; | 1712 | std::array<uint32_t, 2> value_gather{}; |
| 1713 | value_gather[0] = GetReg32(system, 1); | 1713 | value_gather[0] = GetArg32(args, 1); |
| 1714 | value_gather[1] = GetReg32(system, 4); | 1714 | value_gather[1] = GetArg32(args, 4); |
| 1715 | value = Convert<uint64_t>(value_gather); | 1715 | value = Convert<uint64_t>(value_gather); |
| 1716 | 1716 | ||
| 1717 | ret = SetHardwareBreakPoint64From32(system, name, flags, value); | 1717 | ret = SetHardwareBreakPoint64From32(system, name, flags, value); |
| 1718 | 1718 | ||
| 1719 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1719 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1720 | } | 1720 | } |
| 1721 | 1721 | ||
| 1722 | static void SvcWrap_GetDebugThreadParam64From32(Core::System& system) { | 1722 | static void SvcWrap_GetDebugThreadParam64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1723 | Result ret{}; | 1723 | Result ret{}; |
| 1724 | 1724 | ||
| 1725 | uint64_t out_64{}; | 1725 | uint64_t out_64{}; |
| @@ -1728,23 +1728,23 @@ static void SvcWrap_GetDebugThreadParam64From32(Core::System& system) { | |||
| 1728 | uint64_t thread_id{}; | 1728 | uint64_t thread_id{}; |
| 1729 | DebugThreadParam param{}; | 1729 | DebugThreadParam param{}; |
| 1730 | 1730 | ||
| 1731 | debug_handle = Convert<Handle>(GetReg32(system, 2)); | 1731 | debug_handle = Convert<Handle>(GetArg32(args, 2)); |
| 1732 | std::array<uint32_t, 2> thread_id_gather{}; | 1732 | std::array<uint32_t, 2> thread_id_gather{}; |
| 1733 | thread_id_gather[0] = GetReg32(system, 0); | 1733 | thread_id_gather[0] = GetArg32(args, 0); |
| 1734 | thread_id_gather[1] = GetReg32(system, 1); | 1734 | thread_id_gather[1] = GetArg32(args, 1); |
| 1735 | thread_id = Convert<uint64_t>(thread_id_gather); | 1735 | thread_id = Convert<uint64_t>(thread_id_gather); |
| 1736 | param = Convert<DebugThreadParam>(GetReg32(system, 3)); | 1736 | param = Convert<DebugThreadParam>(GetArg32(args, 3)); |
| 1737 | 1737 | ||
| 1738 | ret = GetDebugThreadParam64From32(system, std::addressof(out_64), std::addressof(out_32), debug_handle, thread_id, param); | 1738 | ret = GetDebugThreadParam64From32(system, std::addressof(out_64), std::addressof(out_32), debug_handle, thread_id, param); |
| 1739 | 1739 | ||
| 1740 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1740 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1741 | auto out_64_scatter = Convert<std::array<uint32_t, 2>>(out_64); | 1741 | auto out_64_scatter = Convert<std::array<uint32_t, 2>>(out_64); |
| 1742 | SetReg32(system, 1, out_64_scatter[0]); | 1742 | SetArg32(args, 1, out_64_scatter[0]); |
| 1743 | SetReg32(system, 2, out_64_scatter[1]); | 1743 | SetArg32(args, 2, out_64_scatter[1]); |
| 1744 | SetReg32(system, 3, Convert<uint32_t>(out_32)); | 1744 | SetArg32(args, 3, Convert<uint32_t>(out_32)); |
| 1745 | } | 1745 | } |
| 1746 | 1746 | ||
| 1747 | static void SvcWrap_GetSystemInfo64From32(Core::System& system) { | 1747 | static void SvcWrap_GetSystemInfo64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1748 | Result ret{}; | 1748 | Result ret{}; |
| 1749 | 1749 | ||
| 1750 | uint64_t out{}; | 1750 | uint64_t out{}; |
| @@ -1752,22 +1752,22 @@ static void SvcWrap_GetSystemInfo64From32(Core::System& system) { | |||
| 1752 | Handle handle{}; | 1752 | Handle handle{}; |
| 1753 | uint64_t info_subtype{}; | 1753 | uint64_t info_subtype{}; |
| 1754 | 1754 | ||
| 1755 | info_type = Convert<SystemInfoType>(GetReg32(system, 1)); | 1755 | info_type = Convert<SystemInfoType>(GetArg32(args, 1)); |
| 1756 | handle = Convert<Handle>(GetReg32(system, 2)); | 1756 | handle = Convert<Handle>(GetArg32(args, 2)); |
| 1757 | std::array<uint32_t, 2> info_subtype_gather{}; | 1757 | std::array<uint32_t, 2> info_subtype_gather{}; |
| 1758 | info_subtype_gather[0] = GetReg32(system, 0); | 1758 | info_subtype_gather[0] = GetArg32(args, 0); |
| 1759 | info_subtype_gather[1] = GetReg32(system, 3); | 1759 | info_subtype_gather[1] = GetArg32(args, 3); |
| 1760 | info_subtype = Convert<uint64_t>(info_subtype_gather); | 1760 | info_subtype = Convert<uint64_t>(info_subtype_gather); |
| 1761 | 1761 | ||
| 1762 | ret = GetSystemInfo64From32(system, std::addressof(out), info_type, handle, info_subtype); | 1762 | ret = GetSystemInfo64From32(system, std::addressof(out), info_type, handle, info_subtype); |
| 1763 | 1763 | ||
| 1764 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1764 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1765 | auto out_scatter = Convert<std::array<uint32_t, 2>>(out); | 1765 | auto out_scatter = Convert<std::array<uint32_t, 2>>(out); |
| 1766 | SetReg32(system, 1, out_scatter[0]); | 1766 | SetArg32(args, 1, out_scatter[0]); |
| 1767 | SetReg32(system, 2, out_scatter[1]); | 1767 | SetArg32(args, 2, out_scatter[1]); |
| 1768 | } | 1768 | } |
| 1769 | 1769 | ||
| 1770 | static void SvcWrap_CreatePort64From32(Core::System& system) { | 1770 | static void SvcWrap_CreatePort64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1771 | Result ret{}; | 1771 | Result ret{}; |
| 1772 | 1772 | ||
| 1773 | Handle out_server_handle{}; | 1773 | Handle out_server_handle{}; |
| @@ -1776,48 +1776,48 @@ static void SvcWrap_CreatePort64From32(Core::System& system) { | |||
| 1776 | bool is_light{}; | 1776 | bool is_light{}; |
| 1777 | uint32_t name{}; | 1777 | uint32_t name{}; |
| 1778 | 1778 | ||
| 1779 | max_sessions = Convert<int32_t>(GetReg32(system, 2)); | 1779 | max_sessions = Convert<int32_t>(GetArg32(args, 2)); |
| 1780 | is_light = Convert<bool>(GetReg32(system, 3)); | 1780 | is_light = Convert<bool>(GetArg32(args, 3)); |
| 1781 | name = Convert<uint32_t>(GetReg32(system, 0)); | 1781 | name = Convert<uint32_t>(GetArg32(args, 0)); |
| 1782 | 1782 | ||
| 1783 | ret = CreatePort64From32(system, std::addressof(out_server_handle), std::addressof(out_client_handle), max_sessions, is_light, name); | 1783 | ret = CreatePort64From32(system, std::addressof(out_server_handle), std::addressof(out_client_handle), max_sessions, is_light, name); |
| 1784 | 1784 | ||
| 1785 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1785 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1786 | SetReg32(system, 1, Convert<uint32_t>(out_server_handle)); | 1786 | SetArg32(args, 1, Convert<uint32_t>(out_server_handle)); |
| 1787 | SetReg32(system, 2, Convert<uint32_t>(out_client_handle)); | 1787 | SetArg32(args, 2, Convert<uint32_t>(out_client_handle)); |
| 1788 | } | 1788 | } |
| 1789 | 1789 | ||
| 1790 | static void SvcWrap_ManageNamedPort64From32(Core::System& system) { | 1790 | static void SvcWrap_ManageNamedPort64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1791 | Result ret{}; | 1791 | Result ret{}; |
| 1792 | 1792 | ||
| 1793 | Handle out_server_handle{}; | 1793 | Handle out_server_handle{}; |
| 1794 | uint32_t name{}; | 1794 | uint32_t name{}; |
| 1795 | int32_t max_sessions{}; | 1795 | int32_t max_sessions{}; |
| 1796 | 1796 | ||
| 1797 | name = Convert<uint32_t>(GetReg32(system, 1)); | 1797 | name = Convert<uint32_t>(GetArg32(args, 1)); |
| 1798 | max_sessions = Convert<int32_t>(GetReg32(system, 2)); | 1798 | max_sessions = Convert<int32_t>(GetArg32(args, 2)); |
| 1799 | 1799 | ||
| 1800 | ret = ManageNamedPort64From32(system, std::addressof(out_server_handle), name, max_sessions); | 1800 | ret = ManageNamedPort64From32(system, std::addressof(out_server_handle), name, max_sessions); |
| 1801 | 1801 | ||
| 1802 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1802 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1803 | SetReg32(system, 1, Convert<uint32_t>(out_server_handle)); | 1803 | SetArg32(args, 1, Convert<uint32_t>(out_server_handle)); |
| 1804 | } | 1804 | } |
| 1805 | 1805 | ||
| 1806 | static void SvcWrap_ConnectToPort64From32(Core::System& system) { | 1806 | static void SvcWrap_ConnectToPort64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1807 | Result ret{}; | 1807 | Result ret{}; |
| 1808 | 1808 | ||
| 1809 | Handle out_handle{}; | 1809 | Handle out_handle{}; |
| 1810 | Handle port{}; | 1810 | Handle port{}; |
| 1811 | 1811 | ||
| 1812 | port = Convert<Handle>(GetReg32(system, 1)); | 1812 | port = Convert<Handle>(GetArg32(args, 1)); |
| 1813 | 1813 | ||
| 1814 | ret = ConnectToPort64From32(system, std::addressof(out_handle), port); | 1814 | ret = ConnectToPort64From32(system, std::addressof(out_handle), port); |
| 1815 | 1815 | ||
| 1816 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1816 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1817 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 1817 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 1818 | } | 1818 | } |
| 1819 | 1819 | ||
| 1820 | static void SvcWrap_SetProcessMemoryPermission64From32(Core::System& system) { | 1820 | static void SvcWrap_SetProcessMemoryPermission64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1821 | Result ret{}; | 1821 | Result ret{}; |
| 1822 | 1822 | ||
| 1823 | Handle process_handle{}; | 1823 | Handle process_handle{}; |
| @@ -1825,23 +1825,23 @@ static void SvcWrap_SetProcessMemoryPermission64From32(Core::System& system) { | |||
| 1825 | uint64_t size{}; | 1825 | uint64_t size{}; |
| 1826 | MemoryPermission perm{}; | 1826 | MemoryPermission perm{}; |
| 1827 | 1827 | ||
| 1828 | process_handle = Convert<Handle>(GetReg32(system, 0)); | 1828 | process_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1829 | std::array<uint32_t, 2> address_gather{}; | 1829 | std::array<uint32_t, 2> address_gather{}; |
| 1830 | address_gather[0] = GetReg32(system, 2); | 1830 | address_gather[0] = GetArg32(args, 2); |
| 1831 | address_gather[1] = GetReg32(system, 3); | 1831 | address_gather[1] = GetArg32(args, 3); |
| 1832 | address = Convert<uint64_t>(address_gather); | 1832 | address = Convert<uint64_t>(address_gather); |
| 1833 | std::array<uint32_t, 2> size_gather{}; | 1833 | std::array<uint32_t, 2> size_gather{}; |
| 1834 | size_gather[0] = GetReg32(system, 1); | 1834 | size_gather[0] = GetArg32(args, 1); |
| 1835 | size_gather[1] = GetReg32(system, 4); | 1835 | size_gather[1] = GetArg32(args, 4); |
| 1836 | size = Convert<uint64_t>(size_gather); | 1836 | size = Convert<uint64_t>(size_gather); |
| 1837 | perm = Convert<MemoryPermission>(GetReg32(system, 5)); | 1837 | perm = Convert<MemoryPermission>(GetArg32(args, 5)); |
| 1838 | 1838 | ||
| 1839 | ret = SetProcessMemoryPermission64From32(system, process_handle, address, size, perm); | 1839 | ret = SetProcessMemoryPermission64From32(system, process_handle, address, size, perm); |
| 1840 | 1840 | ||
| 1841 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1841 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1842 | } | 1842 | } |
| 1843 | 1843 | ||
| 1844 | static void SvcWrap_MapProcessMemory64From32(Core::System& system) { | 1844 | static void SvcWrap_MapProcessMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1845 | Result ret{}; | 1845 | Result ret{}; |
| 1846 | 1846 | ||
| 1847 | uint32_t dst_address{}; | 1847 | uint32_t dst_address{}; |
| @@ -1849,20 +1849,20 @@ static void SvcWrap_MapProcessMemory64From32(Core::System& system) { | |||
| 1849 | uint64_t src_address{}; | 1849 | uint64_t src_address{}; |
| 1850 | uint32_t size{}; | 1850 | uint32_t size{}; |
| 1851 | 1851 | ||
| 1852 | dst_address = Convert<uint32_t>(GetReg32(system, 0)); | 1852 | dst_address = Convert<uint32_t>(GetArg32(args, 0)); |
| 1853 | process_handle = Convert<Handle>(GetReg32(system, 1)); | 1853 | process_handle = Convert<Handle>(GetArg32(args, 1)); |
| 1854 | std::array<uint32_t, 2> src_address_gather{}; | 1854 | std::array<uint32_t, 2> src_address_gather{}; |
| 1855 | src_address_gather[0] = GetReg32(system, 2); | 1855 | src_address_gather[0] = GetArg32(args, 2); |
| 1856 | src_address_gather[1] = GetReg32(system, 3); | 1856 | src_address_gather[1] = GetArg32(args, 3); |
| 1857 | src_address = Convert<uint64_t>(src_address_gather); | 1857 | src_address = Convert<uint64_t>(src_address_gather); |
| 1858 | size = Convert<uint32_t>(GetReg32(system, 4)); | 1858 | size = Convert<uint32_t>(GetArg32(args, 4)); |
| 1859 | 1859 | ||
| 1860 | ret = MapProcessMemory64From32(system, dst_address, process_handle, src_address, size); | 1860 | ret = MapProcessMemory64From32(system, dst_address, process_handle, src_address, size); |
| 1861 | 1861 | ||
| 1862 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1862 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1863 | } | 1863 | } |
| 1864 | 1864 | ||
| 1865 | static void SvcWrap_UnmapProcessMemory64From32(Core::System& system) { | 1865 | static void SvcWrap_UnmapProcessMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1866 | Result ret{}; | 1866 | Result ret{}; |
| 1867 | 1867 | ||
| 1868 | uint32_t dst_address{}; | 1868 | uint32_t dst_address{}; |
| @@ -1870,20 +1870,20 @@ static void SvcWrap_UnmapProcessMemory64From32(Core::System& system) { | |||
| 1870 | uint64_t src_address{}; | 1870 | uint64_t src_address{}; |
| 1871 | uint32_t size{}; | 1871 | uint32_t size{}; |
| 1872 | 1872 | ||
| 1873 | dst_address = Convert<uint32_t>(GetReg32(system, 0)); | 1873 | dst_address = Convert<uint32_t>(GetArg32(args, 0)); |
| 1874 | process_handle = Convert<Handle>(GetReg32(system, 1)); | 1874 | process_handle = Convert<Handle>(GetArg32(args, 1)); |
| 1875 | std::array<uint32_t, 2> src_address_gather{}; | 1875 | std::array<uint32_t, 2> src_address_gather{}; |
| 1876 | src_address_gather[0] = GetReg32(system, 2); | 1876 | src_address_gather[0] = GetArg32(args, 2); |
| 1877 | src_address_gather[1] = GetReg32(system, 3); | 1877 | src_address_gather[1] = GetArg32(args, 3); |
| 1878 | src_address = Convert<uint64_t>(src_address_gather); | 1878 | src_address = Convert<uint64_t>(src_address_gather); |
| 1879 | size = Convert<uint32_t>(GetReg32(system, 4)); | 1879 | size = Convert<uint32_t>(GetArg32(args, 4)); |
| 1880 | 1880 | ||
| 1881 | ret = UnmapProcessMemory64From32(system, dst_address, process_handle, src_address, size); | 1881 | ret = UnmapProcessMemory64From32(system, dst_address, process_handle, src_address, size); |
| 1882 | 1882 | ||
| 1883 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1883 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1884 | } | 1884 | } |
| 1885 | 1885 | ||
| 1886 | static void SvcWrap_QueryProcessMemory64From32(Core::System& system) { | 1886 | static void SvcWrap_QueryProcessMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1887 | Result ret{}; | 1887 | Result ret{}; |
| 1888 | 1888 | ||
| 1889 | PageInfo out_page_info{}; | 1889 | PageInfo out_page_info{}; |
| @@ -1891,20 +1891,20 @@ static void SvcWrap_QueryProcessMemory64From32(Core::System& system) { | |||
| 1891 | Handle process_handle{}; | 1891 | Handle process_handle{}; |
| 1892 | uint64_t address{}; | 1892 | uint64_t address{}; |
| 1893 | 1893 | ||
| 1894 | out_memory_info = Convert<uint32_t>(GetReg32(system, 0)); | 1894 | out_memory_info = Convert<uint32_t>(GetArg32(args, 0)); |
| 1895 | process_handle = Convert<Handle>(GetReg32(system, 2)); | 1895 | process_handle = Convert<Handle>(GetArg32(args, 2)); |
| 1896 | std::array<uint32_t, 2> address_gather{}; | 1896 | std::array<uint32_t, 2> address_gather{}; |
| 1897 | address_gather[0] = GetReg32(system, 1); | 1897 | address_gather[0] = GetArg32(args, 1); |
| 1898 | address_gather[1] = GetReg32(system, 3); | 1898 | address_gather[1] = GetArg32(args, 3); |
| 1899 | address = Convert<uint64_t>(address_gather); | 1899 | address = Convert<uint64_t>(address_gather); |
| 1900 | 1900 | ||
| 1901 | ret = QueryProcessMemory64From32(system, out_memory_info, std::addressof(out_page_info), process_handle, address); | 1901 | ret = QueryProcessMemory64From32(system, out_memory_info, std::addressof(out_page_info), process_handle, address); |
| 1902 | 1902 | ||
| 1903 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1903 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1904 | SetReg32(system, 1, Convert<uint32_t>(out_page_info)); | 1904 | SetArg32(args, 1, Convert<uint32_t>(out_page_info)); |
| 1905 | } | 1905 | } |
| 1906 | 1906 | ||
| 1907 | static void SvcWrap_MapProcessCodeMemory64From32(Core::System& system) { | 1907 | static void SvcWrap_MapProcessCodeMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1908 | Result ret{}; | 1908 | Result ret{}; |
| 1909 | 1909 | ||
| 1910 | Handle process_handle{}; | 1910 | Handle process_handle{}; |
| @@ -1912,26 +1912,26 @@ static void SvcWrap_MapProcessCodeMemory64From32(Core::System& system) { | |||
| 1912 | uint64_t src_address{}; | 1912 | uint64_t src_address{}; |
| 1913 | uint64_t size{}; | 1913 | uint64_t size{}; |
| 1914 | 1914 | ||
| 1915 | process_handle = Convert<Handle>(GetReg32(system, 0)); | 1915 | process_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1916 | std::array<uint32_t, 2> dst_address_gather{}; | 1916 | std::array<uint32_t, 2> dst_address_gather{}; |
| 1917 | dst_address_gather[0] = GetReg32(system, 2); | 1917 | dst_address_gather[0] = GetArg32(args, 2); |
| 1918 | dst_address_gather[1] = GetReg32(system, 3); | 1918 | dst_address_gather[1] = GetArg32(args, 3); |
| 1919 | dst_address = Convert<uint64_t>(dst_address_gather); | 1919 | dst_address = Convert<uint64_t>(dst_address_gather); |
| 1920 | std::array<uint32_t, 2> src_address_gather{}; | 1920 | std::array<uint32_t, 2> src_address_gather{}; |
| 1921 | src_address_gather[0] = GetReg32(system, 1); | 1921 | src_address_gather[0] = GetArg32(args, 1); |
| 1922 | src_address_gather[1] = GetReg32(system, 4); | 1922 | src_address_gather[1] = GetArg32(args, 4); |
| 1923 | src_address = Convert<uint64_t>(src_address_gather); | 1923 | src_address = Convert<uint64_t>(src_address_gather); |
| 1924 | std::array<uint32_t, 2> size_gather{}; | 1924 | std::array<uint32_t, 2> size_gather{}; |
| 1925 | size_gather[0] = GetReg32(system, 5); | 1925 | size_gather[0] = GetArg32(args, 5); |
| 1926 | size_gather[1] = GetReg32(system, 6); | 1926 | size_gather[1] = GetArg32(args, 6); |
| 1927 | size = Convert<uint64_t>(size_gather); | 1927 | size = Convert<uint64_t>(size_gather); |
| 1928 | 1928 | ||
| 1929 | ret = MapProcessCodeMemory64From32(system, process_handle, dst_address, src_address, size); | 1929 | ret = MapProcessCodeMemory64From32(system, process_handle, dst_address, src_address, size); |
| 1930 | 1930 | ||
| 1931 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1931 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1932 | } | 1932 | } |
| 1933 | 1933 | ||
| 1934 | static void SvcWrap_UnmapProcessCodeMemory64From32(Core::System& system) { | 1934 | static void SvcWrap_UnmapProcessCodeMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1935 | Result ret{}; | 1935 | Result ret{}; |
| 1936 | 1936 | ||
| 1937 | Handle process_handle{}; | 1937 | Handle process_handle{}; |
| @@ -1939,26 +1939,26 @@ static void SvcWrap_UnmapProcessCodeMemory64From32(Core::System& system) { | |||
| 1939 | uint64_t src_address{}; | 1939 | uint64_t src_address{}; |
| 1940 | uint64_t size{}; | 1940 | uint64_t size{}; |
| 1941 | 1941 | ||
| 1942 | process_handle = Convert<Handle>(GetReg32(system, 0)); | 1942 | process_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1943 | std::array<uint32_t, 2> dst_address_gather{}; | 1943 | std::array<uint32_t, 2> dst_address_gather{}; |
| 1944 | dst_address_gather[0] = GetReg32(system, 2); | 1944 | dst_address_gather[0] = GetArg32(args, 2); |
| 1945 | dst_address_gather[1] = GetReg32(system, 3); | 1945 | dst_address_gather[1] = GetArg32(args, 3); |
| 1946 | dst_address = Convert<uint64_t>(dst_address_gather); | 1946 | dst_address = Convert<uint64_t>(dst_address_gather); |
| 1947 | std::array<uint32_t, 2> src_address_gather{}; | 1947 | std::array<uint32_t, 2> src_address_gather{}; |
| 1948 | src_address_gather[0] = GetReg32(system, 1); | 1948 | src_address_gather[0] = GetArg32(args, 1); |
| 1949 | src_address_gather[1] = GetReg32(system, 4); | 1949 | src_address_gather[1] = GetArg32(args, 4); |
| 1950 | src_address = Convert<uint64_t>(src_address_gather); | 1950 | src_address = Convert<uint64_t>(src_address_gather); |
| 1951 | std::array<uint32_t, 2> size_gather{}; | 1951 | std::array<uint32_t, 2> size_gather{}; |
| 1952 | size_gather[0] = GetReg32(system, 5); | 1952 | size_gather[0] = GetArg32(args, 5); |
| 1953 | size_gather[1] = GetReg32(system, 6); | 1953 | size_gather[1] = GetArg32(args, 6); |
| 1954 | size = Convert<uint64_t>(size_gather); | 1954 | size = Convert<uint64_t>(size_gather); |
| 1955 | 1955 | ||
| 1956 | ret = UnmapProcessCodeMemory64From32(system, process_handle, dst_address, src_address, size); | 1956 | ret = UnmapProcessCodeMemory64From32(system, process_handle, dst_address, src_address, size); |
| 1957 | 1957 | ||
| 1958 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1958 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1959 | } | 1959 | } |
| 1960 | 1960 | ||
| 1961 | static void SvcWrap_CreateProcess64From32(Core::System& system) { | 1961 | static void SvcWrap_CreateProcess64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1962 | Result ret{}; | 1962 | Result ret{}; |
| 1963 | 1963 | ||
| 1964 | Handle out_handle{}; | 1964 | Handle out_handle{}; |
| @@ -1966,17 +1966,17 @@ static void SvcWrap_CreateProcess64From32(Core::System& system) { | |||
| 1966 | uint32_t caps{}; | 1966 | uint32_t caps{}; |
| 1967 | int32_t num_caps{}; | 1967 | int32_t num_caps{}; |
| 1968 | 1968 | ||
| 1969 | parameters = Convert<uint32_t>(GetReg32(system, 1)); | 1969 | parameters = Convert<uint32_t>(GetArg32(args, 1)); |
| 1970 | caps = Convert<uint32_t>(GetReg32(system, 2)); | 1970 | caps = Convert<uint32_t>(GetArg32(args, 2)); |
| 1971 | num_caps = Convert<int32_t>(GetReg32(system, 3)); | 1971 | num_caps = Convert<int32_t>(GetArg32(args, 3)); |
| 1972 | 1972 | ||
| 1973 | ret = CreateProcess64From32(system, std::addressof(out_handle), parameters, caps, num_caps); | 1973 | ret = CreateProcess64From32(system, std::addressof(out_handle), parameters, caps, num_caps); |
| 1974 | 1974 | ||
| 1975 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1975 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1976 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 1976 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 1977 | } | 1977 | } |
| 1978 | 1978 | ||
| 1979 | static void SvcWrap_StartProcess64From32(Core::System& system) { | 1979 | static void SvcWrap_StartProcess64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 1980 | Result ret{}; | 1980 | Result ret{}; |
| 1981 | 1981 | ||
| 1982 | Handle process_handle{}; | 1982 | Handle process_handle{}; |
| @@ -1984,138 +1984,138 @@ static void SvcWrap_StartProcess64From32(Core::System& system) { | |||
| 1984 | int32_t core_id{}; | 1984 | int32_t core_id{}; |
| 1985 | uint64_t main_thread_stack_size{}; | 1985 | uint64_t main_thread_stack_size{}; |
| 1986 | 1986 | ||
| 1987 | process_handle = Convert<Handle>(GetReg32(system, 0)); | 1987 | process_handle = Convert<Handle>(GetArg32(args, 0)); |
| 1988 | priority = Convert<int32_t>(GetReg32(system, 1)); | 1988 | priority = Convert<int32_t>(GetArg32(args, 1)); |
| 1989 | core_id = Convert<int32_t>(GetReg32(system, 2)); | 1989 | core_id = Convert<int32_t>(GetArg32(args, 2)); |
| 1990 | std::array<uint32_t, 2> main_thread_stack_size_gather{}; | 1990 | std::array<uint32_t, 2> main_thread_stack_size_gather{}; |
| 1991 | main_thread_stack_size_gather[0] = GetReg32(system, 3); | 1991 | main_thread_stack_size_gather[0] = GetArg32(args, 3); |
| 1992 | main_thread_stack_size_gather[1] = GetReg32(system, 4); | 1992 | main_thread_stack_size_gather[1] = GetArg32(args, 4); |
| 1993 | main_thread_stack_size = Convert<uint64_t>(main_thread_stack_size_gather); | 1993 | main_thread_stack_size = Convert<uint64_t>(main_thread_stack_size_gather); |
| 1994 | 1994 | ||
| 1995 | ret = StartProcess64From32(system, process_handle, priority, core_id, main_thread_stack_size); | 1995 | ret = StartProcess64From32(system, process_handle, priority, core_id, main_thread_stack_size); |
| 1996 | 1996 | ||
| 1997 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 1997 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 1998 | } | 1998 | } |
| 1999 | 1999 | ||
| 2000 | static void SvcWrap_TerminateProcess64From32(Core::System& system) { | 2000 | static void SvcWrap_TerminateProcess64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 2001 | Result ret{}; | 2001 | Result ret{}; |
| 2002 | 2002 | ||
| 2003 | Handle process_handle{}; | 2003 | Handle process_handle{}; |
| 2004 | 2004 | ||
| 2005 | process_handle = Convert<Handle>(GetReg32(system, 0)); | 2005 | process_handle = Convert<Handle>(GetArg32(args, 0)); |
| 2006 | 2006 | ||
| 2007 | ret = TerminateProcess64From32(system, process_handle); | 2007 | ret = TerminateProcess64From32(system, process_handle); |
| 2008 | 2008 | ||
| 2009 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 2009 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 2010 | } | 2010 | } |
| 2011 | 2011 | ||
| 2012 | static void SvcWrap_GetProcessInfo64From32(Core::System& system) { | 2012 | static void SvcWrap_GetProcessInfo64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 2013 | Result ret{}; | 2013 | Result ret{}; |
| 2014 | 2014 | ||
| 2015 | int64_t out_info{}; | 2015 | int64_t out_info{}; |
| 2016 | Handle process_handle{}; | 2016 | Handle process_handle{}; |
| 2017 | ProcessInfoType info_type{}; | 2017 | ProcessInfoType info_type{}; |
| 2018 | 2018 | ||
| 2019 | process_handle = Convert<Handle>(GetReg32(system, 1)); | 2019 | process_handle = Convert<Handle>(GetArg32(args, 1)); |
| 2020 | info_type = Convert<ProcessInfoType>(GetReg32(system, 2)); | 2020 | info_type = Convert<ProcessInfoType>(GetArg32(args, 2)); |
| 2021 | 2021 | ||
| 2022 | ret = GetProcessInfo64From32(system, std::addressof(out_info), process_handle, info_type); | 2022 | ret = GetProcessInfo64From32(system, std::addressof(out_info), process_handle, info_type); |
| 2023 | 2023 | ||
| 2024 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 2024 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 2025 | auto out_info_scatter = Convert<std::array<uint32_t, 2>>(out_info); | 2025 | auto out_info_scatter = Convert<std::array<uint32_t, 2>>(out_info); |
| 2026 | SetReg32(system, 1, out_info_scatter[0]); | 2026 | SetArg32(args, 1, out_info_scatter[0]); |
| 2027 | SetReg32(system, 2, out_info_scatter[1]); | 2027 | SetArg32(args, 2, out_info_scatter[1]); |
| 2028 | } | 2028 | } |
| 2029 | 2029 | ||
| 2030 | static void SvcWrap_CreateResourceLimit64From32(Core::System& system) { | 2030 | static void SvcWrap_CreateResourceLimit64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 2031 | Result ret{}; | 2031 | Result ret{}; |
| 2032 | 2032 | ||
| 2033 | Handle out_handle{}; | 2033 | Handle out_handle{}; |
| 2034 | 2034 | ||
| 2035 | ret = CreateResourceLimit64From32(system, std::addressof(out_handle)); | 2035 | ret = CreateResourceLimit64From32(system, std::addressof(out_handle)); |
| 2036 | 2036 | ||
| 2037 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 2037 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 2038 | SetReg32(system, 1, Convert<uint32_t>(out_handle)); | 2038 | SetArg32(args, 1, Convert<uint32_t>(out_handle)); |
| 2039 | } | 2039 | } |
| 2040 | 2040 | ||
| 2041 | static void SvcWrap_SetResourceLimitLimitValue64From32(Core::System& system) { | 2041 | static void SvcWrap_SetResourceLimitLimitValue64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 2042 | Result ret{}; | 2042 | Result ret{}; |
| 2043 | 2043 | ||
| 2044 | Handle resource_limit_handle{}; | 2044 | Handle resource_limit_handle{}; |
| 2045 | LimitableResource which{}; | 2045 | LimitableResource which{}; |
| 2046 | int64_t limit_value{}; | 2046 | int64_t limit_value{}; |
| 2047 | 2047 | ||
| 2048 | resource_limit_handle = Convert<Handle>(GetReg32(system, 0)); | 2048 | resource_limit_handle = Convert<Handle>(GetArg32(args, 0)); |
| 2049 | which = Convert<LimitableResource>(GetReg32(system, 1)); | 2049 | which = Convert<LimitableResource>(GetArg32(args, 1)); |
| 2050 | std::array<uint32_t, 2> limit_value_gather{}; | 2050 | std::array<uint32_t, 2> limit_value_gather{}; |
| 2051 | limit_value_gather[0] = GetReg32(system, 2); | 2051 | limit_value_gather[0] = GetArg32(args, 2); |
| 2052 | limit_value_gather[1] = GetReg32(system, 3); | 2052 | limit_value_gather[1] = GetArg32(args, 3); |
| 2053 | limit_value = Convert<int64_t>(limit_value_gather); | 2053 | limit_value = Convert<int64_t>(limit_value_gather); |
| 2054 | 2054 | ||
| 2055 | ret = SetResourceLimitLimitValue64From32(system, resource_limit_handle, which, limit_value); | 2055 | ret = SetResourceLimitLimitValue64From32(system, resource_limit_handle, which, limit_value); |
| 2056 | 2056 | ||
| 2057 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 2057 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 2058 | } | 2058 | } |
| 2059 | 2059 | ||
| 2060 | static void SvcWrap_MapInsecureMemory64From32(Core::System& system) { | 2060 | static void SvcWrap_MapInsecureMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 2061 | Result ret{}; | 2061 | Result ret{}; |
| 2062 | 2062 | ||
| 2063 | uint32_t address{}; | 2063 | uint32_t address{}; |
| 2064 | uint32_t size{}; | 2064 | uint32_t size{}; |
| 2065 | 2065 | ||
| 2066 | address = Convert<uint32_t>(GetReg32(system, 0)); | 2066 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 2067 | size = Convert<uint32_t>(GetReg32(system, 1)); | 2067 | size = Convert<uint32_t>(GetArg32(args, 1)); |
| 2068 | 2068 | ||
| 2069 | ret = MapInsecureMemory64From32(system, address, size); | 2069 | ret = MapInsecureMemory64From32(system, address, size); |
| 2070 | 2070 | ||
| 2071 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 2071 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 2072 | } | 2072 | } |
| 2073 | 2073 | ||
| 2074 | static void SvcWrap_UnmapInsecureMemory64From32(Core::System& system) { | 2074 | static void SvcWrap_UnmapInsecureMemory64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 2075 | Result ret{}; | 2075 | Result ret{}; |
| 2076 | 2076 | ||
| 2077 | uint32_t address{}; | 2077 | uint32_t address{}; |
| 2078 | uint32_t size{}; | 2078 | uint32_t size{}; |
| 2079 | 2079 | ||
| 2080 | address = Convert<uint32_t>(GetReg32(system, 0)); | 2080 | address = Convert<uint32_t>(GetArg32(args, 0)); |
| 2081 | size = Convert<uint32_t>(GetReg32(system, 1)); | 2081 | size = Convert<uint32_t>(GetArg32(args, 1)); |
| 2082 | 2082 | ||
| 2083 | ret = UnmapInsecureMemory64From32(system, address, size); | 2083 | ret = UnmapInsecureMemory64From32(system, address, size); |
| 2084 | 2084 | ||
| 2085 | SetReg32(system, 0, Convert<uint32_t>(ret)); | 2085 | SetArg32(args, 0, Convert<uint32_t>(ret)); |
| 2086 | } | 2086 | } |
| 2087 | 2087 | ||
| 2088 | static void SvcWrap_SetHeapSize64(Core::System& system) { | 2088 | static void SvcWrap_SetHeapSize64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2089 | Result ret{}; | 2089 | Result ret{}; |
| 2090 | 2090 | ||
| 2091 | uint64_t out_address{}; | 2091 | uint64_t out_address{}; |
| 2092 | uint64_t size{}; | 2092 | uint64_t size{}; |
| 2093 | 2093 | ||
| 2094 | size = Convert<uint64_t>(GetReg64(system, 1)); | 2094 | size = Convert<uint64_t>(GetArg64(args, 1)); |
| 2095 | 2095 | ||
| 2096 | ret = SetHeapSize64(system, std::addressof(out_address), size); | 2096 | ret = SetHeapSize64(system, std::addressof(out_address), size); |
| 2097 | 2097 | ||
| 2098 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2098 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2099 | SetReg64(system, 1, Convert<uint64_t>(out_address)); | 2099 | SetArg64(args, 1, Convert<uint64_t>(out_address)); |
| 2100 | } | 2100 | } |
| 2101 | 2101 | ||
| 2102 | static void SvcWrap_SetMemoryPermission64(Core::System& system) { | 2102 | static void SvcWrap_SetMemoryPermission64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2103 | Result ret{}; | 2103 | Result ret{}; |
| 2104 | 2104 | ||
| 2105 | uint64_t address{}; | 2105 | uint64_t address{}; |
| 2106 | uint64_t size{}; | 2106 | uint64_t size{}; |
| 2107 | MemoryPermission perm{}; | 2107 | MemoryPermission perm{}; |
| 2108 | 2108 | ||
| 2109 | address = Convert<uint64_t>(GetReg64(system, 0)); | 2109 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 2110 | size = Convert<uint64_t>(GetReg64(system, 1)); | 2110 | size = Convert<uint64_t>(GetArg64(args, 1)); |
| 2111 | perm = Convert<MemoryPermission>(GetReg64(system, 2)); | 2111 | perm = Convert<MemoryPermission>(GetArg64(args, 2)); |
| 2112 | 2112 | ||
| 2113 | ret = SetMemoryPermission64(system, address, size, perm); | 2113 | ret = SetMemoryPermission64(system, address, size, perm); |
| 2114 | 2114 | ||
| 2115 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2115 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2116 | } | 2116 | } |
| 2117 | 2117 | ||
| 2118 | static void SvcWrap_SetMemoryAttribute64(Core::System& system) { | 2118 | static void SvcWrap_SetMemoryAttribute64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2119 | Result ret{}; | 2119 | Result ret{}; |
| 2120 | 2120 | ||
| 2121 | uint64_t address{}; | 2121 | uint64_t address{}; |
| @@ -2123,69 +2123,69 @@ static void SvcWrap_SetMemoryAttribute64(Core::System& system) { | |||
| 2123 | uint32_t mask{}; | 2123 | uint32_t mask{}; |
| 2124 | uint32_t attr{}; | 2124 | uint32_t attr{}; |
| 2125 | 2125 | ||
| 2126 | address = Convert<uint64_t>(GetReg64(system, 0)); | 2126 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 2127 | size = Convert<uint64_t>(GetReg64(system, 1)); | 2127 | size = Convert<uint64_t>(GetArg64(args, 1)); |
| 2128 | mask = Convert<uint32_t>(GetReg64(system, 2)); | 2128 | mask = Convert<uint32_t>(GetArg64(args, 2)); |
| 2129 | attr = Convert<uint32_t>(GetReg64(system, 3)); | 2129 | attr = Convert<uint32_t>(GetArg64(args, 3)); |
| 2130 | 2130 | ||
| 2131 | ret = SetMemoryAttribute64(system, address, size, mask, attr); | 2131 | ret = SetMemoryAttribute64(system, address, size, mask, attr); |
| 2132 | 2132 | ||
| 2133 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2133 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2134 | } | 2134 | } |
| 2135 | 2135 | ||
| 2136 | static void SvcWrap_MapMemory64(Core::System& system) { | 2136 | static void SvcWrap_MapMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2137 | Result ret{}; | 2137 | Result ret{}; |
| 2138 | 2138 | ||
| 2139 | uint64_t dst_address{}; | 2139 | uint64_t dst_address{}; |
| 2140 | uint64_t src_address{}; | 2140 | uint64_t src_address{}; |
| 2141 | uint64_t size{}; | 2141 | uint64_t size{}; |
| 2142 | 2142 | ||
| 2143 | dst_address = Convert<uint64_t>(GetReg64(system, 0)); | 2143 | dst_address = Convert<uint64_t>(GetArg64(args, 0)); |
| 2144 | src_address = Convert<uint64_t>(GetReg64(system, 1)); | 2144 | src_address = Convert<uint64_t>(GetArg64(args, 1)); |
| 2145 | size = Convert<uint64_t>(GetReg64(system, 2)); | 2145 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 2146 | 2146 | ||
| 2147 | ret = MapMemory64(system, dst_address, src_address, size); | 2147 | ret = MapMemory64(system, dst_address, src_address, size); |
| 2148 | 2148 | ||
| 2149 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2149 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2150 | } | 2150 | } |
| 2151 | 2151 | ||
| 2152 | static void SvcWrap_UnmapMemory64(Core::System& system) { | 2152 | static void SvcWrap_UnmapMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2153 | Result ret{}; | 2153 | Result ret{}; |
| 2154 | 2154 | ||
| 2155 | uint64_t dst_address{}; | 2155 | uint64_t dst_address{}; |
| 2156 | uint64_t src_address{}; | 2156 | uint64_t src_address{}; |
| 2157 | uint64_t size{}; | 2157 | uint64_t size{}; |
| 2158 | 2158 | ||
| 2159 | dst_address = Convert<uint64_t>(GetReg64(system, 0)); | 2159 | dst_address = Convert<uint64_t>(GetArg64(args, 0)); |
| 2160 | src_address = Convert<uint64_t>(GetReg64(system, 1)); | 2160 | src_address = Convert<uint64_t>(GetArg64(args, 1)); |
| 2161 | size = Convert<uint64_t>(GetReg64(system, 2)); | 2161 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 2162 | 2162 | ||
| 2163 | ret = UnmapMemory64(system, dst_address, src_address, size); | 2163 | ret = UnmapMemory64(system, dst_address, src_address, size); |
| 2164 | 2164 | ||
| 2165 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2165 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2166 | } | 2166 | } |
| 2167 | 2167 | ||
| 2168 | static void SvcWrap_QueryMemory64(Core::System& system) { | 2168 | static void SvcWrap_QueryMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2169 | Result ret{}; | 2169 | Result ret{}; |
| 2170 | 2170 | ||
| 2171 | PageInfo out_page_info{}; | 2171 | PageInfo out_page_info{}; |
| 2172 | uint64_t out_memory_info{}; | 2172 | uint64_t out_memory_info{}; |
| 2173 | uint64_t address{}; | 2173 | uint64_t address{}; |
| 2174 | 2174 | ||
| 2175 | out_memory_info = Convert<uint64_t>(GetReg64(system, 0)); | 2175 | out_memory_info = Convert<uint64_t>(GetArg64(args, 0)); |
| 2176 | address = Convert<uint64_t>(GetReg64(system, 2)); | 2176 | address = Convert<uint64_t>(GetArg64(args, 2)); |
| 2177 | 2177 | ||
| 2178 | ret = QueryMemory64(system, out_memory_info, std::addressof(out_page_info), address); | 2178 | ret = QueryMemory64(system, out_memory_info, std::addressof(out_page_info), address); |
| 2179 | 2179 | ||
| 2180 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2180 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2181 | SetReg64(system, 1, Convert<uint64_t>(out_page_info)); | 2181 | SetArg64(args, 1, Convert<uint64_t>(out_page_info)); |
| 2182 | } | 2182 | } |
| 2183 | 2183 | ||
| 2184 | static void SvcWrap_ExitProcess64(Core::System& system) { | 2184 | static void SvcWrap_ExitProcess64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2185 | ExitProcess64(system); | 2185 | ExitProcess64(system); |
| 2186 | } | 2186 | } |
| 2187 | 2187 | ||
| 2188 | static void SvcWrap_CreateThread64(Core::System& system) { | 2188 | static void SvcWrap_CreateThread64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2189 | Result ret{}; | 2189 | Result ret{}; |
| 2190 | 2190 | ||
| 2191 | Handle out_handle{}; | 2191 | Handle out_handle{}; |
| @@ -2195,135 +2195,135 @@ static void SvcWrap_CreateThread64(Core::System& system) { | |||
| 2195 | int32_t priority{}; | 2195 | int32_t priority{}; |
| 2196 | int32_t core_id{}; | 2196 | int32_t core_id{}; |
| 2197 | 2197 | ||
| 2198 | func = Convert<uint64_t>(GetReg64(system, 1)); | 2198 | func = Convert<uint64_t>(GetArg64(args, 1)); |
| 2199 | arg = Convert<uint64_t>(GetReg64(system, 2)); | 2199 | arg = Convert<uint64_t>(GetArg64(args, 2)); |
| 2200 | stack_bottom = Convert<uint64_t>(GetReg64(system, 3)); | 2200 | stack_bottom = Convert<uint64_t>(GetArg64(args, 3)); |
| 2201 | priority = Convert<int32_t>(GetReg64(system, 4)); | 2201 | priority = Convert<int32_t>(GetArg64(args, 4)); |
| 2202 | core_id = Convert<int32_t>(GetReg64(system, 5)); | 2202 | core_id = Convert<int32_t>(GetArg64(args, 5)); |
| 2203 | 2203 | ||
| 2204 | ret = CreateThread64(system, std::addressof(out_handle), func, arg, stack_bottom, priority, core_id); | 2204 | ret = CreateThread64(system, std::addressof(out_handle), func, arg, stack_bottom, priority, core_id); |
| 2205 | 2205 | ||
| 2206 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2206 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2207 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 2207 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 2208 | } | 2208 | } |
| 2209 | 2209 | ||
| 2210 | static void SvcWrap_StartThread64(Core::System& system) { | 2210 | static void SvcWrap_StartThread64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2211 | Result ret{}; | 2211 | Result ret{}; |
| 2212 | 2212 | ||
| 2213 | Handle thread_handle{}; | 2213 | Handle thread_handle{}; |
| 2214 | 2214 | ||
| 2215 | thread_handle = Convert<Handle>(GetReg64(system, 0)); | 2215 | thread_handle = Convert<Handle>(GetArg64(args, 0)); |
| 2216 | 2216 | ||
| 2217 | ret = StartThread64(system, thread_handle); | 2217 | ret = StartThread64(system, thread_handle); |
| 2218 | 2218 | ||
| 2219 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2219 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2220 | } | 2220 | } |
| 2221 | 2221 | ||
| 2222 | static void SvcWrap_ExitThread64(Core::System& system) { | 2222 | static void SvcWrap_ExitThread64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2223 | ExitThread64(system); | 2223 | ExitThread64(system); |
| 2224 | } | 2224 | } |
| 2225 | 2225 | ||
| 2226 | static void SvcWrap_SleepThread64(Core::System& system) { | 2226 | static void SvcWrap_SleepThread64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2227 | int64_t ns{}; | 2227 | int64_t ns{}; |
| 2228 | 2228 | ||
| 2229 | ns = Convert<int64_t>(GetReg64(system, 0)); | 2229 | ns = Convert<int64_t>(GetArg64(args, 0)); |
| 2230 | 2230 | ||
| 2231 | SleepThread64(system, ns); | 2231 | SleepThread64(system, ns); |
| 2232 | } | 2232 | } |
| 2233 | 2233 | ||
| 2234 | static void SvcWrap_GetThreadPriority64(Core::System& system) { | 2234 | static void SvcWrap_GetThreadPriority64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2235 | Result ret{}; | 2235 | Result ret{}; |
| 2236 | 2236 | ||
| 2237 | int32_t out_priority{}; | 2237 | int32_t out_priority{}; |
| 2238 | Handle thread_handle{}; | 2238 | Handle thread_handle{}; |
| 2239 | 2239 | ||
| 2240 | thread_handle = Convert<Handle>(GetReg64(system, 1)); | 2240 | thread_handle = Convert<Handle>(GetArg64(args, 1)); |
| 2241 | 2241 | ||
| 2242 | ret = GetThreadPriority64(system, std::addressof(out_priority), thread_handle); | 2242 | ret = GetThreadPriority64(system, std::addressof(out_priority), thread_handle); |
| 2243 | 2243 | ||
| 2244 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2244 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2245 | SetReg64(system, 1, Convert<uint64_t>(out_priority)); | 2245 | SetArg64(args, 1, Convert<uint64_t>(out_priority)); |
| 2246 | } | 2246 | } |
| 2247 | 2247 | ||
| 2248 | static void SvcWrap_SetThreadPriority64(Core::System& system) { | 2248 | static void SvcWrap_SetThreadPriority64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2249 | Result ret{}; | 2249 | Result ret{}; |
| 2250 | 2250 | ||
| 2251 | Handle thread_handle{}; | 2251 | Handle thread_handle{}; |
| 2252 | int32_t priority{}; | 2252 | int32_t priority{}; |
| 2253 | 2253 | ||
| 2254 | thread_handle = Convert<Handle>(GetReg64(system, 0)); | 2254 | thread_handle = Convert<Handle>(GetArg64(args, 0)); |
| 2255 | priority = Convert<int32_t>(GetReg64(system, 1)); | 2255 | priority = Convert<int32_t>(GetArg64(args, 1)); |
| 2256 | 2256 | ||
| 2257 | ret = SetThreadPriority64(system, thread_handle, priority); | 2257 | ret = SetThreadPriority64(system, thread_handle, priority); |
| 2258 | 2258 | ||
| 2259 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2259 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2260 | } | 2260 | } |
| 2261 | 2261 | ||
| 2262 | static void SvcWrap_GetThreadCoreMask64(Core::System& system) { | 2262 | static void SvcWrap_GetThreadCoreMask64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2263 | Result ret{}; | 2263 | Result ret{}; |
| 2264 | 2264 | ||
| 2265 | int32_t out_core_id{}; | 2265 | int32_t out_core_id{}; |
| 2266 | uint64_t out_affinity_mask{}; | 2266 | uint64_t out_affinity_mask{}; |
| 2267 | Handle thread_handle{}; | 2267 | Handle thread_handle{}; |
| 2268 | 2268 | ||
| 2269 | thread_handle = Convert<Handle>(GetReg64(system, 2)); | 2269 | thread_handle = Convert<Handle>(GetArg64(args, 2)); |
| 2270 | 2270 | ||
| 2271 | ret = GetThreadCoreMask64(system, std::addressof(out_core_id), std::addressof(out_affinity_mask), thread_handle); | 2271 | ret = GetThreadCoreMask64(system, std::addressof(out_core_id), std::addressof(out_affinity_mask), thread_handle); |
| 2272 | 2272 | ||
| 2273 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2273 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2274 | SetReg64(system, 1, Convert<uint64_t>(out_core_id)); | 2274 | SetArg64(args, 1, Convert<uint64_t>(out_core_id)); |
| 2275 | SetReg64(system, 2, Convert<uint64_t>(out_affinity_mask)); | 2275 | SetArg64(args, 2, Convert<uint64_t>(out_affinity_mask)); |
| 2276 | } | 2276 | } |
| 2277 | 2277 | ||
| 2278 | static void SvcWrap_SetThreadCoreMask64(Core::System& system) { | 2278 | static void SvcWrap_SetThreadCoreMask64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2279 | Result ret{}; | 2279 | Result ret{}; |
| 2280 | 2280 | ||
| 2281 | Handle thread_handle{}; | 2281 | Handle thread_handle{}; |
| 2282 | int32_t core_id{}; | 2282 | int32_t core_id{}; |
| 2283 | uint64_t affinity_mask{}; | 2283 | uint64_t affinity_mask{}; |
| 2284 | 2284 | ||
| 2285 | thread_handle = Convert<Handle>(GetReg64(system, 0)); | 2285 | thread_handle = Convert<Handle>(GetArg64(args, 0)); |
| 2286 | core_id = Convert<int32_t>(GetReg64(system, 1)); | 2286 | core_id = Convert<int32_t>(GetArg64(args, 1)); |
| 2287 | affinity_mask = Convert<uint64_t>(GetReg64(system, 2)); | 2287 | affinity_mask = Convert<uint64_t>(GetArg64(args, 2)); |
| 2288 | 2288 | ||
| 2289 | ret = SetThreadCoreMask64(system, thread_handle, core_id, affinity_mask); | 2289 | ret = SetThreadCoreMask64(system, thread_handle, core_id, affinity_mask); |
| 2290 | 2290 | ||
| 2291 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2291 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2292 | } | 2292 | } |
| 2293 | 2293 | ||
| 2294 | static void SvcWrap_GetCurrentProcessorNumber64(Core::System& system) { | 2294 | static void SvcWrap_GetCurrentProcessorNumber64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2295 | int32_t ret{}; | 2295 | int32_t ret{}; |
| 2296 | 2296 | ||
| 2297 | ret = GetCurrentProcessorNumber64(system); | 2297 | ret = GetCurrentProcessorNumber64(system); |
| 2298 | 2298 | ||
| 2299 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2299 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2300 | } | 2300 | } |
| 2301 | 2301 | ||
| 2302 | static void SvcWrap_SignalEvent64(Core::System& system) { | 2302 | static void SvcWrap_SignalEvent64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2303 | Result ret{}; | 2303 | Result ret{}; |
| 2304 | 2304 | ||
| 2305 | Handle event_handle{}; | 2305 | Handle event_handle{}; |
| 2306 | 2306 | ||
| 2307 | event_handle = Convert<Handle>(GetReg64(system, 0)); | 2307 | event_handle = Convert<Handle>(GetArg64(args, 0)); |
| 2308 | 2308 | ||
| 2309 | ret = SignalEvent64(system, event_handle); | 2309 | ret = SignalEvent64(system, event_handle); |
| 2310 | 2310 | ||
| 2311 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2311 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2312 | } | 2312 | } |
| 2313 | 2313 | ||
| 2314 | static void SvcWrap_ClearEvent64(Core::System& system) { | 2314 | static void SvcWrap_ClearEvent64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2315 | Result ret{}; | 2315 | Result ret{}; |
| 2316 | 2316 | ||
| 2317 | Handle event_handle{}; | 2317 | Handle event_handle{}; |
| 2318 | 2318 | ||
| 2319 | event_handle = Convert<Handle>(GetReg64(system, 0)); | 2319 | event_handle = Convert<Handle>(GetArg64(args, 0)); |
| 2320 | 2320 | ||
| 2321 | ret = ClearEvent64(system, event_handle); | 2321 | ret = ClearEvent64(system, event_handle); |
| 2322 | 2322 | ||
| 2323 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2323 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2324 | } | 2324 | } |
| 2325 | 2325 | ||
| 2326 | static void SvcWrap_MapSharedMemory64(Core::System& system) { | 2326 | static void SvcWrap_MapSharedMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2327 | Result ret{}; | 2327 | Result ret{}; |
| 2328 | 2328 | ||
| 2329 | Handle shmem_handle{}; | 2329 | Handle shmem_handle{}; |
| @@ -2331,33 +2331,33 @@ static void SvcWrap_MapSharedMemory64(Core::System& system) { | |||
| 2331 | uint64_t size{}; | 2331 | uint64_t size{}; |
| 2332 | MemoryPermission map_perm{}; | 2332 | MemoryPermission map_perm{}; |
| 2333 | 2333 | ||
| 2334 | shmem_handle = Convert<Handle>(GetReg64(system, 0)); | 2334 | shmem_handle = Convert<Handle>(GetArg64(args, 0)); |
| 2335 | address = Convert<uint64_t>(GetReg64(system, 1)); | 2335 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 2336 | size = Convert<uint64_t>(GetReg64(system, 2)); | 2336 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 2337 | map_perm = Convert<MemoryPermission>(GetReg64(system, 3)); | 2337 | map_perm = Convert<MemoryPermission>(GetArg64(args, 3)); |
| 2338 | 2338 | ||
| 2339 | ret = MapSharedMemory64(system, shmem_handle, address, size, map_perm); | 2339 | ret = MapSharedMemory64(system, shmem_handle, address, size, map_perm); |
| 2340 | 2340 | ||
| 2341 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2341 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2342 | } | 2342 | } |
| 2343 | 2343 | ||
| 2344 | static void SvcWrap_UnmapSharedMemory64(Core::System& system) { | 2344 | static void SvcWrap_UnmapSharedMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2345 | Result ret{}; | 2345 | Result ret{}; |
| 2346 | 2346 | ||
| 2347 | Handle shmem_handle{}; | 2347 | Handle shmem_handle{}; |
| 2348 | uint64_t address{}; | 2348 | uint64_t address{}; |
| 2349 | uint64_t size{}; | 2349 | uint64_t size{}; |
| 2350 | 2350 | ||
| 2351 | shmem_handle = Convert<Handle>(GetReg64(system, 0)); | 2351 | shmem_handle = Convert<Handle>(GetArg64(args, 0)); |
| 2352 | address = Convert<uint64_t>(GetReg64(system, 1)); | 2352 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 2353 | size = Convert<uint64_t>(GetReg64(system, 2)); | 2353 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 2354 | 2354 | ||
| 2355 | ret = UnmapSharedMemory64(system, shmem_handle, address, size); | 2355 | ret = UnmapSharedMemory64(system, shmem_handle, address, size); |
| 2356 | 2356 | ||
| 2357 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2357 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2358 | } | 2358 | } |
| 2359 | 2359 | ||
| 2360 | static void SvcWrap_CreateTransferMemory64(Core::System& system) { | 2360 | static void SvcWrap_CreateTransferMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2361 | Result ret{}; | 2361 | Result ret{}; |
| 2362 | 2362 | ||
| 2363 | Handle out_handle{}; | 2363 | Handle out_handle{}; |
| @@ -2365,41 +2365,41 @@ static void SvcWrap_CreateTransferMemory64(Core::System& system) { | |||
| 2365 | uint64_t size{}; | 2365 | uint64_t size{}; |
| 2366 | MemoryPermission map_perm{}; | 2366 | MemoryPermission map_perm{}; |
| 2367 | 2367 | ||
| 2368 | address = Convert<uint64_t>(GetReg64(system, 1)); | 2368 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 2369 | size = Convert<uint64_t>(GetReg64(system, 2)); | 2369 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 2370 | map_perm = Convert<MemoryPermission>(GetReg64(system, 3)); | 2370 | map_perm = Convert<MemoryPermission>(GetArg64(args, 3)); |
| 2371 | 2371 | ||
| 2372 | ret = CreateTransferMemory64(system, std::addressof(out_handle), address, size, map_perm); | 2372 | ret = CreateTransferMemory64(system, std::addressof(out_handle), address, size, map_perm); |
| 2373 | 2373 | ||
| 2374 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2374 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2375 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 2375 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 2376 | } | 2376 | } |
| 2377 | 2377 | ||
| 2378 | static void SvcWrap_CloseHandle64(Core::System& system) { | 2378 | static void SvcWrap_CloseHandle64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2379 | Result ret{}; | 2379 | Result ret{}; |
| 2380 | 2380 | ||
| 2381 | Handle handle{}; | 2381 | Handle handle{}; |
| 2382 | 2382 | ||
| 2383 | handle = Convert<Handle>(GetReg64(system, 0)); | 2383 | handle = Convert<Handle>(GetArg64(args, 0)); |
| 2384 | 2384 | ||
| 2385 | ret = CloseHandle64(system, handle); | 2385 | ret = CloseHandle64(system, handle); |
| 2386 | 2386 | ||
| 2387 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2387 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2388 | } | 2388 | } |
| 2389 | 2389 | ||
| 2390 | static void SvcWrap_ResetSignal64(Core::System& system) { | 2390 | static void SvcWrap_ResetSignal64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2391 | Result ret{}; | 2391 | Result ret{}; |
| 2392 | 2392 | ||
| 2393 | Handle handle{}; | 2393 | Handle handle{}; |
| 2394 | 2394 | ||
| 2395 | handle = Convert<Handle>(GetReg64(system, 0)); | 2395 | handle = Convert<Handle>(GetArg64(args, 0)); |
| 2396 | 2396 | ||
| 2397 | ret = ResetSignal64(system, handle); | 2397 | ret = ResetSignal64(system, handle); |
| 2398 | 2398 | ||
| 2399 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2399 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2400 | } | 2400 | } |
| 2401 | 2401 | ||
| 2402 | static void SvcWrap_WaitSynchronization64(Core::System& system) { | 2402 | static void SvcWrap_WaitSynchronization64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2403 | Result ret{}; | 2403 | Result ret{}; |
| 2404 | 2404 | ||
| 2405 | int32_t out_index{}; | 2405 | int32_t out_index{}; |
| @@ -2407,57 +2407,57 @@ static void SvcWrap_WaitSynchronization64(Core::System& system) { | |||
| 2407 | int32_t num_handles{}; | 2407 | int32_t num_handles{}; |
| 2408 | int64_t timeout_ns{}; | 2408 | int64_t timeout_ns{}; |
| 2409 | 2409 | ||
| 2410 | handles = Convert<uint64_t>(GetReg64(system, 1)); | 2410 | handles = Convert<uint64_t>(GetArg64(args, 1)); |
| 2411 | num_handles = Convert<int32_t>(GetReg64(system, 2)); | 2411 | num_handles = Convert<int32_t>(GetArg64(args, 2)); |
| 2412 | timeout_ns = Convert<int64_t>(GetReg64(system, 3)); | 2412 | timeout_ns = Convert<int64_t>(GetArg64(args, 3)); |
| 2413 | 2413 | ||
| 2414 | ret = WaitSynchronization64(system, std::addressof(out_index), handles, num_handles, timeout_ns); | 2414 | ret = WaitSynchronization64(system, std::addressof(out_index), handles, num_handles, timeout_ns); |
| 2415 | 2415 | ||
| 2416 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2416 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2417 | SetReg64(system, 1, Convert<uint64_t>(out_index)); | 2417 | SetArg64(args, 1, Convert<uint64_t>(out_index)); |
| 2418 | } | 2418 | } |
| 2419 | 2419 | ||
| 2420 | static void SvcWrap_CancelSynchronization64(Core::System& system) { | 2420 | static void SvcWrap_CancelSynchronization64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2421 | Result ret{}; | 2421 | Result ret{}; |
| 2422 | 2422 | ||
| 2423 | Handle handle{}; | 2423 | Handle handle{}; |
| 2424 | 2424 | ||
| 2425 | handle = Convert<Handle>(GetReg64(system, 0)); | 2425 | handle = Convert<Handle>(GetArg64(args, 0)); |
| 2426 | 2426 | ||
| 2427 | ret = CancelSynchronization64(system, handle); | 2427 | ret = CancelSynchronization64(system, handle); |
| 2428 | 2428 | ||
| 2429 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2429 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2430 | } | 2430 | } |
| 2431 | 2431 | ||
| 2432 | static void SvcWrap_ArbitrateLock64(Core::System& system) { | 2432 | static void SvcWrap_ArbitrateLock64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2433 | Result ret{}; | 2433 | Result ret{}; |
| 2434 | 2434 | ||
| 2435 | Handle thread_handle{}; | 2435 | Handle thread_handle{}; |
| 2436 | uint64_t address{}; | 2436 | uint64_t address{}; |
| 2437 | uint32_t tag{}; | 2437 | uint32_t tag{}; |
| 2438 | 2438 | ||
| 2439 | thread_handle = Convert<Handle>(GetReg64(system, 0)); | 2439 | thread_handle = Convert<Handle>(GetArg64(args, 0)); |
| 2440 | address = Convert<uint64_t>(GetReg64(system, 1)); | 2440 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 2441 | tag = Convert<uint32_t>(GetReg64(system, 2)); | 2441 | tag = Convert<uint32_t>(GetArg64(args, 2)); |
| 2442 | 2442 | ||
| 2443 | ret = ArbitrateLock64(system, thread_handle, address, tag); | 2443 | ret = ArbitrateLock64(system, thread_handle, address, tag); |
| 2444 | 2444 | ||
| 2445 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2445 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2446 | } | 2446 | } |
| 2447 | 2447 | ||
| 2448 | static void SvcWrap_ArbitrateUnlock64(Core::System& system) { | 2448 | static void SvcWrap_ArbitrateUnlock64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2449 | Result ret{}; | 2449 | Result ret{}; |
| 2450 | 2450 | ||
| 2451 | uint64_t address{}; | 2451 | uint64_t address{}; |
| 2452 | 2452 | ||
| 2453 | address = Convert<uint64_t>(GetReg64(system, 0)); | 2453 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 2454 | 2454 | ||
| 2455 | ret = ArbitrateUnlock64(system, address); | 2455 | ret = ArbitrateUnlock64(system, address); |
| 2456 | 2456 | ||
| 2457 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2457 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2458 | } | 2458 | } |
| 2459 | 2459 | ||
| 2460 | static void SvcWrap_WaitProcessWideKeyAtomic64(Core::System& system) { | 2460 | static void SvcWrap_WaitProcessWideKeyAtomic64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2461 | Result ret{}; | 2461 | Result ret{}; |
| 2462 | 2462 | ||
| 2463 | uint64_t address{}; | 2463 | uint64_t address{}; |
| @@ -2465,77 +2465,77 @@ static void SvcWrap_WaitProcessWideKeyAtomic64(Core::System& system) { | |||
| 2465 | uint32_t tag{}; | 2465 | uint32_t tag{}; |
| 2466 | int64_t timeout_ns{}; | 2466 | int64_t timeout_ns{}; |
| 2467 | 2467 | ||
| 2468 | address = Convert<uint64_t>(GetReg64(system, 0)); | 2468 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 2469 | cv_key = Convert<uint64_t>(GetReg64(system, 1)); | 2469 | cv_key = Convert<uint64_t>(GetArg64(args, 1)); |
| 2470 | tag = Convert<uint32_t>(GetReg64(system, 2)); | 2470 | tag = Convert<uint32_t>(GetArg64(args, 2)); |
| 2471 | timeout_ns = Convert<int64_t>(GetReg64(system, 3)); | 2471 | timeout_ns = Convert<int64_t>(GetArg64(args, 3)); |
| 2472 | 2472 | ||
| 2473 | ret = WaitProcessWideKeyAtomic64(system, address, cv_key, tag, timeout_ns); | 2473 | ret = WaitProcessWideKeyAtomic64(system, address, cv_key, tag, timeout_ns); |
| 2474 | 2474 | ||
| 2475 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2475 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2476 | } | 2476 | } |
| 2477 | 2477 | ||
| 2478 | static void SvcWrap_SignalProcessWideKey64(Core::System& system) { | 2478 | static void SvcWrap_SignalProcessWideKey64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2479 | uint64_t cv_key{}; | 2479 | uint64_t cv_key{}; |
| 2480 | int32_t count{}; | 2480 | int32_t count{}; |
| 2481 | 2481 | ||
| 2482 | cv_key = Convert<uint64_t>(GetReg64(system, 0)); | 2482 | cv_key = Convert<uint64_t>(GetArg64(args, 0)); |
| 2483 | count = Convert<int32_t>(GetReg64(system, 1)); | 2483 | count = Convert<int32_t>(GetArg64(args, 1)); |
| 2484 | 2484 | ||
| 2485 | SignalProcessWideKey64(system, cv_key, count); | 2485 | SignalProcessWideKey64(system, cv_key, count); |
| 2486 | } | 2486 | } |
| 2487 | 2487 | ||
| 2488 | static void SvcWrap_GetSystemTick64(Core::System& system) { | 2488 | static void SvcWrap_GetSystemTick64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2489 | int64_t ret{}; | 2489 | int64_t ret{}; |
| 2490 | 2490 | ||
| 2491 | ret = GetSystemTick64(system); | 2491 | ret = GetSystemTick64(system); |
| 2492 | 2492 | ||
| 2493 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2493 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2494 | } | 2494 | } |
| 2495 | 2495 | ||
| 2496 | static void SvcWrap_ConnectToNamedPort64(Core::System& system) { | 2496 | static void SvcWrap_ConnectToNamedPort64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2497 | Result ret{}; | 2497 | Result ret{}; |
| 2498 | 2498 | ||
| 2499 | Handle out_handle{}; | 2499 | Handle out_handle{}; |
| 2500 | uint64_t name{}; | 2500 | uint64_t name{}; |
| 2501 | 2501 | ||
| 2502 | name = Convert<uint64_t>(GetReg64(system, 1)); | 2502 | name = Convert<uint64_t>(GetArg64(args, 1)); |
| 2503 | 2503 | ||
| 2504 | ret = ConnectToNamedPort64(system, std::addressof(out_handle), name); | 2504 | ret = ConnectToNamedPort64(system, std::addressof(out_handle), name); |
| 2505 | 2505 | ||
| 2506 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2506 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2507 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 2507 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 2508 | } | 2508 | } |
| 2509 | 2509 | ||
| 2510 | static void SvcWrap_SendSyncRequest64(Core::System& system) { | 2510 | static void SvcWrap_SendSyncRequest64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2511 | Result ret{}; | 2511 | Result ret{}; |
| 2512 | 2512 | ||
| 2513 | Handle session_handle{}; | 2513 | Handle session_handle{}; |
| 2514 | 2514 | ||
| 2515 | session_handle = Convert<Handle>(GetReg64(system, 0)); | 2515 | session_handle = Convert<Handle>(GetArg64(args, 0)); |
| 2516 | 2516 | ||
| 2517 | ret = SendSyncRequest64(system, session_handle); | 2517 | ret = SendSyncRequest64(system, session_handle); |
| 2518 | 2518 | ||
| 2519 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2519 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2520 | } | 2520 | } |
| 2521 | 2521 | ||
| 2522 | static void SvcWrap_SendSyncRequestWithUserBuffer64(Core::System& system) { | 2522 | static void SvcWrap_SendSyncRequestWithUserBuffer64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2523 | Result ret{}; | 2523 | Result ret{}; |
| 2524 | 2524 | ||
| 2525 | uint64_t message_buffer{}; | 2525 | uint64_t message_buffer{}; |
| 2526 | uint64_t message_buffer_size{}; | 2526 | uint64_t message_buffer_size{}; |
| 2527 | Handle session_handle{}; | 2527 | Handle session_handle{}; |
| 2528 | 2528 | ||
| 2529 | message_buffer = Convert<uint64_t>(GetReg64(system, 0)); | 2529 | message_buffer = Convert<uint64_t>(GetArg64(args, 0)); |
| 2530 | message_buffer_size = Convert<uint64_t>(GetReg64(system, 1)); | 2530 | message_buffer_size = Convert<uint64_t>(GetArg64(args, 1)); |
| 2531 | session_handle = Convert<Handle>(GetReg64(system, 2)); | 2531 | session_handle = Convert<Handle>(GetArg64(args, 2)); |
| 2532 | 2532 | ||
| 2533 | ret = SendSyncRequestWithUserBuffer64(system, message_buffer, message_buffer_size, session_handle); | 2533 | ret = SendSyncRequestWithUserBuffer64(system, message_buffer, message_buffer_size, session_handle); |
| 2534 | 2534 | ||
| 2535 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2535 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2536 | } | 2536 | } |
| 2537 | 2537 | ||
| 2538 | static void SvcWrap_SendAsyncRequestWithUserBuffer64(Core::System& system) { | 2538 | static void SvcWrap_SendAsyncRequestWithUserBuffer64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2539 | Result ret{}; | 2539 | Result ret{}; |
| 2540 | 2540 | ||
| 2541 | Handle out_event_handle{}; | 2541 | Handle out_event_handle{}; |
| @@ -2543,79 +2543,79 @@ static void SvcWrap_SendAsyncRequestWithUserBuffer64(Core::System& system) { | |||
| 2543 | uint64_t message_buffer_size{}; | 2543 | uint64_t message_buffer_size{}; |
| 2544 | Handle session_handle{}; | 2544 | Handle session_handle{}; |
| 2545 | 2545 | ||
| 2546 | message_buffer = Convert<uint64_t>(GetReg64(system, 1)); | 2546 | message_buffer = Convert<uint64_t>(GetArg64(args, 1)); |
| 2547 | message_buffer_size = Convert<uint64_t>(GetReg64(system, 2)); | 2547 | message_buffer_size = Convert<uint64_t>(GetArg64(args, 2)); |
| 2548 | session_handle = Convert<Handle>(GetReg64(system, 3)); | 2548 | session_handle = Convert<Handle>(GetArg64(args, 3)); |
| 2549 | 2549 | ||
| 2550 | ret = SendAsyncRequestWithUserBuffer64(system, std::addressof(out_event_handle), message_buffer, message_buffer_size, session_handle); | 2550 | ret = SendAsyncRequestWithUserBuffer64(system, std::addressof(out_event_handle), message_buffer, message_buffer_size, session_handle); |
| 2551 | 2551 | ||
| 2552 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2552 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2553 | SetReg64(system, 1, Convert<uint64_t>(out_event_handle)); | 2553 | SetArg64(args, 1, Convert<uint64_t>(out_event_handle)); |
| 2554 | } | 2554 | } |
| 2555 | 2555 | ||
| 2556 | static void SvcWrap_GetProcessId64(Core::System& system) { | 2556 | static void SvcWrap_GetProcessId64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2557 | Result ret{}; | 2557 | Result ret{}; |
| 2558 | 2558 | ||
| 2559 | uint64_t out_process_id{}; | 2559 | uint64_t out_process_id{}; |
| 2560 | Handle process_handle{}; | 2560 | Handle process_handle{}; |
| 2561 | 2561 | ||
| 2562 | process_handle = Convert<Handle>(GetReg64(system, 1)); | 2562 | process_handle = Convert<Handle>(GetArg64(args, 1)); |
| 2563 | 2563 | ||
| 2564 | ret = GetProcessId64(system, std::addressof(out_process_id), process_handle); | 2564 | ret = GetProcessId64(system, std::addressof(out_process_id), process_handle); |
| 2565 | 2565 | ||
| 2566 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2566 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2567 | SetReg64(system, 1, Convert<uint64_t>(out_process_id)); | 2567 | SetArg64(args, 1, Convert<uint64_t>(out_process_id)); |
| 2568 | } | 2568 | } |
| 2569 | 2569 | ||
| 2570 | static void SvcWrap_GetThreadId64(Core::System& system) { | 2570 | static void SvcWrap_GetThreadId64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2571 | Result ret{}; | 2571 | Result ret{}; |
| 2572 | 2572 | ||
| 2573 | uint64_t out_thread_id{}; | 2573 | uint64_t out_thread_id{}; |
| 2574 | Handle thread_handle{}; | 2574 | Handle thread_handle{}; |
| 2575 | 2575 | ||
| 2576 | thread_handle = Convert<Handle>(GetReg64(system, 1)); | 2576 | thread_handle = Convert<Handle>(GetArg64(args, 1)); |
| 2577 | 2577 | ||
| 2578 | ret = GetThreadId64(system, std::addressof(out_thread_id), thread_handle); | 2578 | ret = GetThreadId64(system, std::addressof(out_thread_id), thread_handle); |
| 2579 | 2579 | ||
| 2580 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2580 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2581 | SetReg64(system, 1, Convert<uint64_t>(out_thread_id)); | 2581 | SetArg64(args, 1, Convert<uint64_t>(out_thread_id)); |
| 2582 | } | 2582 | } |
| 2583 | 2583 | ||
| 2584 | static void SvcWrap_Break64(Core::System& system) { | 2584 | static void SvcWrap_Break64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2585 | BreakReason break_reason{}; | 2585 | BreakReason break_reason{}; |
| 2586 | uint64_t arg{}; | 2586 | uint64_t arg{}; |
| 2587 | uint64_t size{}; | 2587 | uint64_t size{}; |
| 2588 | 2588 | ||
| 2589 | break_reason = Convert<BreakReason>(GetReg64(system, 0)); | 2589 | break_reason = Convert<BreakReason>(GetArg64(args, 0)); |
| 2590 | arg = Convert<uint64_t>(GetReg64(system, 1)); | 2590 | arg = Convert<uint64_t>(GetArg64(args, 1)); |
| 2591 | size = Convert<uint64_t>(GetReg64(system, 2)); | 2591 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 2592 | 2592 | ||
| 2593 | Break64(system, break_reason, arg, size); | 2593 | Break64(system, break_reason, arg, size); |
| 2594 | } | 2594 | } |
| 2595 | 2595 | ||
| 2596 | static void SvcWrap_OutputDebugString64(Core::System& system) { | 2596 | static void SvcWrap_OutputDebugString64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2597 | Result ret{}; | 2597 | Result ret{}; |
| 2598 | 2598 | ||
| 2599 | uint64_t debug_str{}; | 2599 | uint64_t debug_str{}; |
| 2600 | uint64_t len{}; | 2600 | uint64_t len{}; |
| 2601 | 2601 | ||
| 2602 | debug_str = Convert<uint64_t>(GetReg64(system, 0)); | 2602 | debug_str = Convert<uint64_t>(GetArg64(args, 0)); |
| 2603 | len = Convert<uint64_t>(GetReg64(system, 1)); | 2603 | len = Convert<uint64_t>(GetArg64(args, 1)); |
| 2604 | 2604 | ||
| 2605 | ret = OutputDebugString64(system, debug_str, len); | 2605 | ret = OutputDebugString64(system, debug_str, len); |
| 2606 | 2606 | ||
| 2607 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2607 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2608 | } | 2608 | } |
| 2609 | 2609 | ||
| 2610 | static void SvcWrap_ReturnFromException64(Core::System& system) { | 2610 | static void SvcWrap_ReturnFromException64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2611 | Result result{}; | 2611 | Result result{}; |
| 2612 | 2612 | ||
| 2613 | result = Convert<Result>(GetReg64(system, 0)); | 2613 | result = Convert<Result>(GetArg64(args, 0)); |
| 2614 | 2614 | ||
| 2615 | ReturnFromException64(system, result); | 2615 | ReturnFromException64(system, result); |
| 2616 | } | 2616 | } |
| 2617 | 2617 | ||
| 2618 | static void SvcWrap_GetInfo64(Core::System& system) { | 2618 | static void SvcWrap_GetInfo64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2619 | Result ret{}; | 2619 | Result ret{}; |
| 2620 | 2620 | ||
| 2621 | uint64_t out{}; | 2621 | uint64_t out{}; |
| @@ -2623,63 +2623,63 @@ static void SvcWrap_GetInfo64(Core::System& system) { | |||
| 2623 | Handle handle{}; | 2623 | Handle handle{}; |
| 2624 | uint64_t info_subtype{}; | 2624 | uint64_t info_subtype{}; |
| 2625 | 2625 | ||
| 2626 | info_type = Convert<InfoType>(GetReg64(system, 1)); | 2626 | info_type = Convert<InfoType>(GetArg64(args, 1)); |
| 2627 | handle = Convert<Handle>(GetReg64(system, 2)); | 2627 | handle = Convert<Handle>(GetArg64(args, 2)); |
| 2628 | info_subtype = Convert<uint64_t>(GetReg64(system, 3)); | 2628 | info_subtype = Convert<uint64_t>(GetArg64(args, 3)); |
| 2629 | 2629 | ||
| 2630 | ret = GetInfo64(system, std::addressof(out), info_type, handle, info_subtype); | 2630 | ret = GetInfo64(system, std::addressof(out), info_type, handle, info_subtype); |
| 2631 | 2631 | ||
| 2632 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2632 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2633 | SetReg64(system, 1, Convert<uint64_t>(out)); | 2633 | SetArg64(args, 1, Convert<uint64_t>(out)); |
| 2634 | } | 2634 | } |
| 2635 | 2635 | ||
| 2636 | static void SvcWrap_FlushEntireDataCache64(Core::System& system) { | 2636 | static void SvcWrap_FlushEntireDataCache64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2637 | FlushEntireDataCache64(system); | 2637 | FlushEntireDataCache64(system); |
| 2638 | } | 2638 | } |
| 2639 | 2639 | ||
| 2640 | static void SvcWrap_FlushDataCache64(Core::System& system) { | 2640 | static void SvcWrap_FlushDataCache64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2641 | Result ret{}; | 2641 | Result ret{}; |
| 2642 | 2642 | ||
| 2643 | uint64_t address{}; | 2643 | uint64_t address{}; |
| 2644 | uint64_t size{}; | 2644 | uint64_t size{}; |
| 2645 | 2645 | ||
| 2646 | address = Convert<uint64_t>(GetReg64(system, 0)); | 2646 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 2647 | size = Convert<uint64_t>(GetReg64(system, 1)); | 2647 | size = Convert<uint64_t>(GetArg64(args, 1)); |
| 2648 | 2648 | ||
| 2649 | ret = FlushDataCache64(system, address, size); | 2649 | ret = FlushDataCache64(system, address, size); |
| 2650 | 2650 | ||
| 2651 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2651 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2652 | } | 2652 | } |
| 2653 | 2653 | ||
| 2654 | static void SvcWrap_MapPhysicalMemory64(Core::System& system) { | 2654 | static void SvcWrap_MapPhysicalMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2655 | Result ret{}; | 2655 | Result ret{}; |
| 2656 | 2656 | ||
| 2657 | uint64_t address{}; | 2657 | uint64_t address{}; |
| 2658 | uint64_t size{}; | 2658 | uint64_t size{}; |
| 2659 | 2659 | ||
| 2660 | address = Convert<uint64_t>(GetReg64(system, 0)); | 2660 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 2661 | size = Convert<uint64_t>(GetReg64(system, 1)); | 2661 | size = Convert<uint64_t>(GetArg64(args, 1)); |
| 2662 | 2662 | ||
| 2663 | ret = MapPhysicalMemory64(system, address, size); | 2663 | ret = MapPhysicalMemory64(system, address, size); |
| 2664 | 2664 | ||
| 2665 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2665 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2666 | } | 2666 | } |
| 2667 | 2667 | ||
| 2668 | static void SvcWrap_UnmapPhysicalMemory64(Core::System& system) { | 2668 | static void SvcWrap_UnmapPhysicalMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2669 | Result ret{}; | 2669 | Result ret{}; |
| 2670 | 2670 | ||
| 2671 | uint64_t address{}; | 2671 | uint64_t address{}; |
| 2672 | uint64_t size{}; | 2672 | uint64_t size{}; |
| 2673 | 2673 | ||
| 2674 | address = Convert<uint64_t>(GetReg64(system, 0)); | 2674 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 2675 | size = Convert<uint64_t>(GetReg64(system, 1)); | 2675 | size = Convert<uint64_t>(GetArg64(args, 1)); |
| 2676 | 2676 | ||
| 2677 | ret = UnmapPhysicalMemory64(system, address, size); | 2677 | ret = UnmapPhysicalMemory64(system, address, size); |
| 2678 | 2678 | ||
| 2679 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2679 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2680 | } | 2680 | } |
| 2681 | 2681 | ||
| 2682 | static void SvcWrap_GetDebugFutureThreadInfo64(Core::System& system) { | 2682 | static void SvcWrap_GetDebugFutureThreadInfo64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2683 | Result ret{}; | 2683 | Result ret{}; |
| 2684 | 2684 | ||
| 2685 | lp64::LastThreadContext out_context{}; | 2685 | lp64::LastThreadContext out_context{}; |
| @@ -2687,21 +2687,21 @@ static void SvcWrap_GetDebugFutureThreadInfo64(Core::System& system) { | |||
| 2687 | Handle debug_handle{}; | 2687 | Handle debug_handle{}; |
| 2688 | int64_t ns{}; | 2688 | int64_t ns{}; |
| 2689 | 2689 | ||
| 2690 | debug_handle = Convert<Handle>(GetReg64(system, 2)); | 2690 | debug_handle = Convert<Handle>(GetArg64(args, 2)); |
| 2691 | ns = Convert<int64_t>(GetReg64(system, 3)); | 2691 | ns = Convert<int64_t>(GetArg64(args, 3)); |
| 2692 | 2692 | ||
| 2693 | ret = GetDebugFutureThreadInfo64(system, std::addressof(out_context), std::addressof(out_thread_id), debug_handle, ns); | 2693 | ret = GetDebugFutureThreadInfo64(system, std::addressof(out_context), std::addressof(out_thread_id), debug_handle, ns); |
| 2694 | 2694 | ||
| 2695 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2695 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2696 | auto out_context_scatter = Convert<std::array<uint64_t, 4>>(out_context); | 2696 | auto out_context_scatter = Convert<std::array<uint64_t, 4>>(out_context); |
| 2697 | SetReg64(system, 1, out_context_scatter[0]); | 2697 | SetArg64(args, 1, out_context_scatter[0]); |
| 2698 | SetReg64(system, 2, out_context_scatter[1]); | 2698 | SetArg64(args, 2, out_context_scatter[1]); |
| 2699 | SetReg64(system, 3, out_context_scatter[2]); | 2699 | SetArg64(args, 3, out_context_scatter[2]); |
| 2700 | SetReg64(system, 4, out_context_scatter[3]); | 2700 | SetArg64(args, 4, out_context_scatter[3]); |
| 2701 | SetReg64(system, 5, Convert<uint64_t>(out_thread_id)); | 2701 | SetArg64(args, 5, Convert<uint64_t>(out_thread_id)); |
| 2702 | } | 2702 | } |
| 2703 | 2703 | ||
| 2704 | static void SvcWrap_GetLastThreadInfo64(Core::System& system) { | 2704 | static void SvcWrap_GetLastThreadInfo64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2705 | Result ret{}; | 2705 | Result ret{}; |
| 2706 | 2706 | ||
| 2707 | lp64::LastThreadContext out_context{}; | 2707 | lp64::LastThreadContext out_context{}; |
| @@ -2710,77 +2710,77 @@ static void SvcWrap_GetLastThreadInfo64(Core::System& system) { | |||
| 2710 | 2710 | ||
| 2711 | ret = GetLastThreadInfo64(system, std::addressof(out_context), std::addressof(out_tls_address), std::addressof(out_flags)); | 2711 | ret = GetLastThreadInfo64(system, std::addressof(out_context), std::addressof(out_tls_address), std::addressof(out_flags)); |
| 2712 | 2712 | ||
| 2713 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2713 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2714 | auto out_context_scatter = Convert<std::array<uint64_t, 4>>(out_context); | 2714 | auto out_context_scatter = Convert<std::array<uint64_t, 4>>(out_context); |
| 2715 | SetReg64(system, 1, out_context_scatter[0]); | 2715 | SetArg64(args, 1, out_context_scatter[0]); |
| 2716 | SetReg64(system, 2, out_context_scatter[1]); | 2716 | SetArg64(args, 2, out_context_scatter[1]); |
| 2717 | SetReg64(system, 3, out_context_scatter[2]); | 2717 | SetArg64(args, 3, out_context_scatter[2]); |
| 2718 | SetReg64(system, 4, out_context_scatter[3]); | 2718 | SetArg64(args, 4, out_context_scatter[3]); |
| 2719 | SetReg64(system, 5, Convert<uint64_t>(out_tls_address)); | 2719 | SetArg64(args, 5, Convert<uint64_t>(out_tls_address)); |
| 2720 | SetReg64(system, 6, Convert<uint64_t>(out_flags)); | 2720 | SetArg64(args, 6, Convert<uint64_t>(out_flags)); |
| 2721 | } | 2721 | } |
| 2722 | 2722 | ||
| 2723 | static void SvcWrap_GetResourceLimitLimitValue64(Core::System& system) { | 2723 | static void SvcWrap_GetResourceLimitLimitValue64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2724 | Result ret{}; | 2724 | Result ret{}; |
| 2725 | 2725 | ||
| 2726 | int64_t out_limit_value{}; | 2726 | int64_t out_limit_value{}; |
| 2727 | Handle resource_limit_handle{}; | 2727 | Handle resource_limit_handle{}; |
| 2728 | LimitableResource which{}; | 2728 | LimitableResource which{}; |
| 2729 | 2729 | ||
| 2730 | resource_limit_handle = Convert<Handle>(GetReg64(system, 1)); | 2730 | resource_limit_handle = Convert<Handle>(GetArg64(args, 1)); |
| 2731 | which = Convert<LimitableResource>(GetReg64(system, 2)); | 2731 | which = Convert<LimitableResource>(GetArg64(args, 2)); |
| 2732 | 2732 | ||
| 2733 | ret = GetResourceLimitLimitValue64(system, std::addressof(out_limit_value), resource_limit_handle, which); | 2733 | ret = GetResourceLimitLimitValue64(system, std::addressof(out_limit_value), resource_limit_handle, which); |
| 2734 | 2734 | ||
| 2735 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2735 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2736 | SetReg64(system, 1, Convert<uint64_t>(out_limit_value)); | 2736 | SetArg64(args, 1, Convert<uint64_t>(out_limit_value)); |
| 2737 | } | 2737 | } |
| 2738 | 2738 | ||
| 2739 | static void SvcWrap_GetResourceLimitCurrentValue64(Core::System& system) { | 2739 | static void SvcWrap_GetResourceLimitCurrentValue64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2740 | Result ret{}; | 2740 | Result ret{}; |
| 2741 | 2741 | ||
| 2742 | int64_t out_current_value{}; | 2742 | int64_t out_current_value{}; |
| 2743 | Handle resource_limit_handle{}; | 2743 | Handle resource_limit_handle{}; |
| 2744 | LimitableResource which{}; | 2744 | LimitableResource which{}; |
| 2745 | 2745 | ||
| 2746 | resource_limit_handle = Convert<Handle>(GetReg64(system, 1)); | 2746 | resource_limit_handle = Convert<Handle>(GetArg64(args, 1)); |
| 2747 | which = Convert<LimitableResource>(GetReg64(system, 2)); | 2747 | which = Convert<LimitableResource>(GetArg64(args, 2)); |
| 2748 | 2748 | ||
| 2749 | ret = GetResourceLimitCurrentValue64(system, std::addressof(out_current_value), resource_limit_handle, which); | 2749 | ret = GetResourceLimitCurrentValue64(system, std::addressof(out_current_value), resource_limit_handle, which); |
| 2750 | 2750 | ||
| 2751 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2751 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2752 | SetReg64(system, 1, Convert<uint64_t>(out_current_value)); | 2752 | SetArg64(args, 1, Convert<uint64_t>(out_current_value)); |
| 2753 | } | 2753 | } |
| 2754 | 2754 | ||
| 2755 | static void SvcWrap_SetThreadActivity64(Core::System& system) { | 2755 | static void SvcWrap_SetThreadActivity64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2756 | Result ret{}; | 2756 | Result ret{}; |
| 2757 | 2757 | ||
| 2758 | Handle thread_handle{}; | 2758 | Handle thread_handle{}; |
| 2759 | ThreadActivity thread_activity{}; | 2759 | ThreadActivity thread_activity{}; |
| 2760 | 2760 | ||
| 2761 | thread_handle = Convert<Handle>(GetReg64(system, 0)); | 2761 | thread_handle = Convert<Handle>(GetArg64(args, 0)); |
| 2762 | thread_activity = Convert<ThreadActivity>(GetReg64(system, 1)); | 2762 | thread_activity = Convert<ThreadActivity>(GetArg64(args, 1)); |
| 2763 | 2763 | ||
| 2764 | ret = SetThreadActivity64(system, thread_handle, thread_activity); | 2764 | ret = SetThreadActivity64(system, thread_handle, thread_activity); |
| 2765 | 2765 | ||
| 2766 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2766 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2767 | } | 2767 | } |
| 2768 | 2768 | ||
| 2769 | static void SvcWrap_GetThreadContext364(Core::System& system) { | 2769 | static void SvcWrap_GetThreadContext364(Core::System& system, std::span<uint64_t, 8> args) { |
| 2770 | Result ret{}; | 2770 | Result ret{}; |
| 2771 | 2771 | ||
| 2772 | uint64_t out_context{}; | 2772 | uint64_t out_context{}; |
| 2773 | Handle thread_handle{}; | 2773 | Handle thread_handle{}; |
| 2774 | 2774 | ||
| 2775 | out_context = Convert<uint64_t>(GetReg64(system, 0)); | 2775 | out_context = Convert<uint64_t>(GetArg64(args, 0)); |
| 2776 | thread_handle = Convert<Handle>(GetReg64(system, 1)); | 2776 | thread_handle = Convert<Handle>(GetArg64(args, 1)); |
| 2777 | 2777 | ||
| 2778 | ret = GetThreadContext364(system, out_context, thread_handle); | 2778 | ret = GetThreadContext364(system, out_context, thread_handle); |
| 2779 | 2779 | ||
| 2780 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2780 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2781 | } | 2781 | } |
| 2782 | 2782 | ||
| 2783 | static void SvcWrap_WaitForAddress64(Core::System& system) { | 2783 | static void SvcWrap_WaitForAddress64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2784 | Result ret{}; | 2784 | Result ret{}; |
| 2785 | 2785 | ||
| 2786 | uint64_t address{}; | 2786 | uint64_t address{}; |
| @@ -2788,17 +2788,17 @@ static void SvcWrap_WaitForAddress64(Core::System& system) { | |||
| 2788 | int32_t value{}; | 2788 | int32_t value{}; |
| 2789 | int64_t timeout_ns{}; | 2789 | int64_t timeout_ns{}; |
| 2790 | 2790 | ||
| 2791 | address = Convert<uint64_t>(GetReg64(system, 0)); | 2791 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 2792 | arb_type = Convert<ArbitrationType>(GetReg64(system, 1)); | 2792 | arb_type = Convert<ArbitrationType>(GetArg64(args, 1)); |
| 2793 | value = Convert<int32_t>(GetReg64(system, 2)); | 2793 | value = Convert<int32_t>(GetArg64(args, 2)); |
| 2794 | timeout_ns = Convert<int64_t>(GetReg64(system, 3)); | 2794 | timeout_ns = Convert<int64_t>(GetArg64(args, 3)); |
| 2795 | 2795 | ||
| 2796 | ret = WaitForAddress64(system, address, arb_type, value, timeout_ns); | 2796 | ret = WaitForAddress64(system, address, arb_type, value, timeout_ns); |
| 2797 | 2797 | ||
| 2798 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2798 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2799 | } | 2799 | } |
| 2800 | 2800 | ||
| 2801 | static void SvcWrap_SignalToAddress64(Core::System& system) { | 2801 | static void SvcWrap_SignalToAddress64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2802 | Result ret{}; | 2802 | Result ret{}; |
| 2803 | 2803 | ||
| 2804 | uint64_t address{}; | 2804 | uint64_t address{}; |
| @@ -2806,51 +2806,51 @@ static void SvcWrap_SignalToAddress64(Core::System& system) { | |||
| 2806 | int32_t value{}; | 2806 | int32_t value{}; |
| 2807 | int32_t count{}; | 2807 | int32_t count{}; |
| 2808 | 2808 | ||
| 2809 | address = Convert<uint64_t>(GetReg64(system, 0)); | 2809 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 2810 | signal_type = Convert<SignalType>(GetReg64(system, 1)); | 2810 | signal_type = Convert<SignalType>(GetArg64(args, 1)); |
| 2811 | value = Convert<int32_t>(GetReg64(system, 2)); | 2811 | value = Convert<int32_t>(GetArg64(args, 2)); |
| 2812 | count = Convert<int32_t>(GetReg64(system, 3)); | 2812 | count = Convert<int32_t>(GetArg64(args, 3)); |
| 2813 | 2813 | ||
| 2814 | ret = SignalToAddress64(system, address, signal_type, value, count); | 2814 | ret = SignalToAddress64(system, address, signal_type, value, count); |
| 2815 | 2815 | ||
| 2816 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2816 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2817 | } | 2817 | } |
| 2818 | 2818 | ||
| 2819 | static void SvcWrap_SynchronizePreemptionState64(Core::System& system) { | 2819 | static void SvcWrap_SynchronizePreemptionState64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2820 | SynchronizePreemptionState64(system); | 2820 | SynchronizePreemptionState64(system); |
| 2821 | } | 2821 | } |
| 2822 | 2822 | ||
| 2823 | static void SvcWrap_GetResourceLimitPeakValue64(Core::System& system) { | 2823 | static void SvcWrap_GetResourceLimitPeakValue64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2824 | Result ret{}; | 2824 | Result ret{}; |
| 2825 | 2825 | ||
| 2826 | int64_t out_peak_value{}; | 2826 | int64_t out_peak_value{}; |
| 2827 | Handle resource_limit_handle{}; | 2827 | Handle resource_limit_handle{}; |
| 2828 | LimitableResource which{}; | 2828 | LimitableResource which{}; |
| 2829 | 2829 | ||
| 2830 | resource_limit_handle = Convert<Handle>(GetReg64(system, 1)); | 2830 | resource_limit_handle = Convert<Handle>(GetArg64(args, 1)); |
| 2831 | which = Convert<LimitableResource>(GetReg64(system, 2)); | 2831 | which = Convert<LimitableResource>(GetArg64(args, 2)); |
| 2832 | 2832 | ||
| 2833 | ret = GetResourceLimitPeakValue64(system, std::addressof(out_peak_value), resource_limit_handle, which); | 2833 | ret = GetResourceLimitPeakValue64(system, std::addressof(out_peak_value), resource_limit_handle, which); |
| 2834 | 2834 | ||
| 2835 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2835 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2836 | SetReg64(system, 1, Convert<uint64_t>(out_peak_value)); | 2836 | SetArg64(args, 1, Convert<uint64_t>(out_peak_value)); |
| 2837 | } | 2837 | } |
| 2838 | 2838 | ||
| 2839 | static void SvcWrap_CreateIoPool64(Core::System& system) { | 2839 | static void SvcWrap_CreateIoPool64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2840 | Result ret{}; | 2840 | Result ret{}; |
| 2841 | 2841 | ||
| 2842 | Handle out_handle{}; | 2842 | Handle out_handle{}; |
| 2843 | IoPoolType which{}; | 2843 | IoPoolType which{}; |
| 2844 | 2844 | ||
| 2845 | which = Convert<IoPoolType>(GetReg64(system, 1)); | 2845 | which = Convert<IoPoolType>(GetArg64(args, 1)); |
| 2846 | 2846 | ||
| 2847 | ret = CreateIoPool64(system, std::addressof(out_handle), which); | 2847 | ret = CreateIoPool64(system, std::addressof(out_handle), which); |
| 2848 | 2848 | ||
| 2849 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2849 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2850 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 2850 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 2851 | } | 2851 | } |
| 2852 | 2852 | ||
| 2853 | static void SvcWrap_CreateIoRegion64(Core::System& system) { | 2853 | static void SvcWrap_CreateIoRegion64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2854 | Result ret{}; | 2854 | Result ret{}; |
| 2855 | 2855 | ||
| 2856 | Handle out_handle{}; | 2856 | Handle out_handle{}; |
| @@ -2860,41 +2860,41 @@ static void SvcWrap_CreateIoRegion64(Core::System& system) { | |||
| 2860 | MemoryMapping mapping{}; | 2860 | MemoryMapping mapping{}; |
| 2861 | MemoryPermission perm{}; | 2861 | MemoryPermission perm{}; |
| 2862 | 2862 | ||
| 2863 | io_pool = Convert<Handle>(GetReg64(system, 1)); | 2863 | io_pool = Convert<Handle>(GetArg64(args, 1)); |
| 2864 | physical_address = Convert<uint64_t>(GetReg64(system, 2)); | 2864 | physical_address = Convert<uint64_t>(GetArg64(args, 2)); |
| 2865 | size = Convert<uint64_t>(GetReg64(system, 3)); | 2865 | size = Convert<uint64_t>(GetArg64(args, 3)); |
| 2866 | mapping = Convert<MemoryMapping>(GetReg64(system, 4)); | 2866 | mapping = Convert<MemoryMapping>(GetArg64(args, 4)); |
| 2867 | perm = Convert<MemoryPermission>(GetReg64(system, 5)); | 2867 | perm = Convert<MemoryPermission>(GetArg64(args, 5)); |
| 2868 | 2868 | ||
| 2869 | ret = CreateIoRegion64(system, std::addressof(out_handle), io_pool, physical_address, size, mapping, perm); | 2869 | ret = CreateIoRegion64(system, std::addressof(out_handle), io_pool, physical_address, size, mapping, perm); |
| 2870 | 2870 | ||
| 2871 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2871 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2872 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 2872 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 2873 | } | 2873 | } |
| 2874 | 2874 | ||
| 2875 | static void SvcWrap_KernelDebug64(Core::System& system) { | 2875 | static void SvcWrap_KernelDebug64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2876 | KernelDebugType kern_debug_type{}; | 2876 | KernelDebugType kern_debug_type{}; |
| 2877 | uint64_t arg0{}; | 2877 | uint64_t arg0{}; |
| 2878 | uint64_t arg1{}; | 2878 | uint64_t arg1{}; |
| 2879 | uint64_t arg2{}; | 2879 | uint64_t arg2{}; |
| 2880 | 2880 | ||
| 2881 | kern_debug_type = Convert<KernelDebugType>(GetReg64(system, 0)); | 2881 | kern_debug_type = Convert<KernelDebugType>(GetArg64(args, 0)); |
| 2882 | arg0 = Convert<uint64_t>(GetReg64(system, 1)); | 2882 | arg0 = Convert<uint64_t>(GetArg64(args, 1)); |
| 2883 | arg1 = Convert<uint64_t>(GetReg64(system, 2)); | 2883 | arg1 = Convert<uint64_t>(GetArg64(args, 2)); |
| 2884 | arg2 = Convert<uint64_t>(GetReg64(system, 3)); | 2884 | arg2 = Convert<uint64_t>(GetArg64(args, 3)); |
| 2885 | 2885 | ||
| 2886 | KernelDebug64(system, kern_debug_type, arg0, arg1, arg2); | 2886 | KernelDebug64(system, kern_debug_type, arg0, arg1, arg2); |
| 2887 | } | 2887 | } |
| 2888 | 2888 | ||
| 2889 | static void SvcWrap_ChangeKernelTraceState64(Core::System& system) { | 2889 | static void SvcWrap_ChangeKernelTraceState64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2890 | KernelTraceState kern_trace_state{}; | 2890 | KernelTraceState kern_trace_state{}; |
| 2891 | 2891 | ||
| 2892 | kern_trace_state = Convert<KernelTraceState>(GetReg64(system, 0)); | 2892 | kern_trace_state = Convert<KernelTraceState>(GetArg64(args, 0)); |
| 2893 | 2893 | ||
| 2894 | ChangeKernelTraceState64(system, kern_trace_state); | 2894 | ChangeKernelTraceState64(system, kern_trace_state); |
| 2895 | } | 2895 | } |
| 2896 | 2896 | ||
| 2897 | static void SvcWrap_CreateSession64(Core::System& system) { | 2897 | static void SvcWrap_CreateSession64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2898 | Result ret{}; | 2898 | Result ret{}; |
| 2899 | 2899 | ||
| 2900 | Handle out_server_session_handle{}; | 2900 | Handle out_server_session_handle{}; |
| @@ -2902,31 +2902,31 @@ static void SvcWrap_CreateSession64(Core::System& system) { | |||
| 2902 | bool is_light{}; | 2902 | bool is_light{}; |
| 2903 | uint64_t name{}; | 2903 | uint64_t name{}; |
| 2904 | 2904 | ||
| 2905 | is_light = Convert<bool>(GetReg64(system, 2)); | 2905 | is_light = Convert<bool>(GetArg64(args, 2)); |
| 2906 | name = Convert<uint64_t>(GetReg64(system, 3)); | 2906 | name = Convert<uint64_t>(GetArg64(args, 3)); |
| 2907 | 2907 | ||
| 2908 | ret = CreateSession64(system, std::addressof(out_server_session_handle), std::addressof(out_client_session_handle), is_light, name); | 2908 | ret = CreateSession64(system, std::addressof(out_server_session_handle), std::addressof(out_client_session_handle), is_light, name); |
| 2909 | 2909 | ||
| 2910 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2910 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2911 | SetReg64(system, 1, Convert<uint64_t>(out_server_session_handle)); | 2911 | SetArg64(args, 1, Convert<uint64_t>(out_server_session_handle)); |
| 2912 | SetReg64(system, 2, Convert<uint64_t>(out_client_session_handle)); | 2912 | SetArg64(args, 2, Convert<uint64_t>(out_client_session_handle)); |
| 2913 | } | 2913 | } |
| 2914 | 2914 | ||
| 2915 | static void SvcWrap_AcceptSession64(Core::System& system) { | 2915 | static void SvcWrap_AcceptSession64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2916 | Result ret{}; | 2916 | Result ret{}; |
| 2917 | 2917 | ||
| 2918 | Handle out_handle{}; | 2918 | Handle out_handle{}; |
| 2919 | Handle port{}; | 2919 | Handle port{}; |
| 2920 | 2920 | ||
| 2921 | port = Convert<Handle>(GetReg64(system, 1)); | 2921 | port = Convert<Handle>(GetArg64(args, 1)); |
| 2922 | 2922 | ||
| 2923 | ret = AcceptSession64(system, std::addressof(out_handle), port); | 2923 | ret = AcceptSession64(system, std::addressof(out_handle), port); |
| 2924 | 2924 | ||
| 2925 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2925 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2926 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 2926 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 2927 | } | 2927 | } |
| 2928 | 2928 | ||
| 2929 | static void SvcWrap_ReplyAndReceive64(Core::System& system) { | 2929 | static void SvcWrap_ReplyAndReceive64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2930 | Result ret{}; | 2930 | Result ret{}; |
| 2931 | 2931 | ||
| 2932 | int32_t out_index{}; | 2932 | int32_t out_index{}; |
| @@ -2935,18 +2935,18 @@ static void SvcWrap_ReplyAndReceive64(Core::System& system) { | |||
| 2935 | Handle reply_target{}; | 2935 | Handle reply_target{}; |
| 2936 | int64_t timeout_ns{}; | 2936 | int64_t timeout_ns{}; |
| 2937 | 2937 | ||
| 2938 | handles = Convert<uint64_t>(GetReg64(system, 1)); | 2938 | handles = Convert<uint64_t>(GetArg64(args, 1)); |
| 2939 | num_handles = Convert<int32_t>(GetReg64(system, 2)); | 2939 | num_handles = Convert<int32_t>(GetArg64(args, 2)); |
| 2940 | reply_target = Convert<Handle>(GetReg64(system, 3)); | 2940 | reply_target = Convert<Handle>(GetArg64(args, 3)); |
| 2941 | timeout_ns = Convert<int64_t>(GetReg64(system, 4)); | 2941 | timeout_ns = Convert<int64_t>(GetArg64(args, 4)); |
| 2942 | 2942 | ||
| 2943 | ret = ReplyAndReceive64(system, std::addressof(out_index), handles, num_handles, reply_target, timeout_ns); | 2943 | ret = ReplyAndReceive64(system, std::addressof(out_index), handles, num_handles, reply_target, timeout_ns); |
| 2944 | 2944 | ||
| 2945 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2945 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2946 | SetReg64(system, 1, Convert<uint64_t>(out_index)); | 2946 | SetArg64(args, 1, Convert<uint64_t>(out_index)); |
| 2947 | } | 2947 | } |
| 2948 | 2948 | ||
| 2949 | static void SvcWrap_ReplyAndReceiveWithUserBuffer64(Core::System& system) { | 2949 | static void SvcWrap_ReplyAndReceiveWithUserBuffer64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2950 | Result ret{}; | 2950 | Result ret{}; |
| 2951 | 2951 | ||
| 2952 | int32_t out_index{}; | 2952 | int32_t out_index{}; |
| @@ -2957,20 +2957,20 @@ static void SvcWrap_ReplyAndReceiveWithUserBuffer64(Core::System& system) { | |||
| 2957 | Handle reply_target{}; | 2957 | Handle reply_target{}; |
| 2958 | int64_t timeout_ns{}; | 2958 | int64_t timeout_ns{}; |
| 2959 | 2959 | ||
| 2960 | message_buffer = Convert<uint64_t>(GetReg64(system, 1)); | 2960 | message_buffer = Convert<uint64_t>(GetArg64(args, 1)); |
| 2961 | message_buffer_size = Convert<uint64_t>(GetReg64(system, 2)); | 2961 | message_buffer_size = Convert<uint64_t>(GetArg64(args, 2)); |
| 2962 | handles = Convert<uint64_t>(GetReg64(system, 3)); | 2962 | handles = Convert<uint64_t>(GetArg64(args, 3)); |
| 2963 | num_handles = Convert<int32_t>(GetReg64(system, 4)); | 2963 | num_handles = Convert<int32_t>(GetArg64(args, 4)); |
| 2964 | reply_target = Convert<Handle>(GetReg64(system, 5)); | 2964 | reply_target = Convert<Handle>(GetArg64(args, 5)); |
| 2965 | timeout_ns = Convert<int64_t>(GetReg64(system, 6)); | 2965 | timeout_ns = Convert<int64_t>(GetArg64(args, 6)); |
| 2966 | 2966 | ||
| 2967 | ret = ReplyAndReceiveWithUserBuffer64(system, std::addressof(out_index), message_buffer, message_buffer_size, handles, num_handles, reply_target, timeout_ns); | 2967 | ret = ReplyAndReceiveWithUserBuffer64(system, std::addressof(out_index), message_buffer, message_buffer_size, handles, num_handles, reply_target, timeout_ns); |
| 2968 | 2968 | ||
| 2969 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2969 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2970 | SetReg64(system, 1, Convert<uint64_t>(out_index)); | 2970 | SetArg64(args, 1, Convert<uint64_t>(out_index)); |
| 2971 | } | 2971 | } |
| 2972 | 2972 | ||
| 2973 | static void SvcWrap_CreateEvent64(Core::System& system) { | 2973 | static void SvcWrap_CreateEvent64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2974 | Result ret{}; | 2974 | Result ret{}; |
| 2975 | 2975 | ||
| 2976 | Handle out_write_handle{}; | 2976 | Handle out_write_handle{}; |
| @@ -2978,12 +2978,12 @@ static void SvcWrap_CreateEvent64(Core::System& system) { | |||
| 2978 | 2978 | ||
| 2979 | ret = CreateEvent64(system, std::addressof(out_write_handle), std::addressof(out_read_handle)); | 2979 | ret = CreateEvent64(system, std::addressof(out_write_handle), std::addressof(out_read_handle)); |
| 2980 | 2980 | ||
| 2981 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 2981 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 2982 | SetReg64(system, 1, Convert<uint64_t>(out_write_handle)); | 2982 | SetArg64(args, 1, Convert<uint64_t>(out_write_handle)); |
| 2983 | SetReg64(system, 2, Convert<uint64_t>(out_read_handle)); | 2983 | SetArg64(args, 2, Convert<uint64_t>(out_read_handle)); |
| 2984 | } | 2984 | } |
| 2985 | 2985 | ||
| 2986 | static void SvcWrap_MapIoRegion64(Core::System& system) { | 2986 | static void SvcWrap_MapIoRegion64(Core::System& system, std::span<uint64_t, 8> args) { |
| 2987 | Result ret{}; | 2987 | Result ret{}; |
| 2988 | 2988 | ||
| 2989 | Handle io_region{}; | 2989 | Handle io_region{}; |
| @@ -2991,89 +2991,89 @@ static void SvcWrap_MapIoRegion64(Core::System& system) { | |||
| 2991 | uint64_t size{}; | 2991 | uint64_t size{}; |
| 2992 | MemoryPermission perm{}; | 2992 | MemoryPermission perm{}; |
| 2993 | 2993 | ||
| 2994 | io_region = Convert<Handle>(GetReg64(system, 0)); | 2994 | io_region = Convert<Handle>(GetArg64(args, 0)); |
| 2995 | address = Convert<uint64_t>(GetReg64(system, 1)); | 2995 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 2996 | size = Convert<uint64_t>(GetReg64(system, 2)); | 2996 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 2997 | perm = Convert<MemoryPermission>(GetReg64(system, 3)); | 2997 | perm = Convert<MemoryPermission>(GetArg64(args, 3)); |
| 2998 | 2998 | ||
| 2999 | ret = MapIoRegion64(system, io_region, address, size, perm); | 2999 | ret = MapIoRegion64(system, io_region, address, size, perm); |
| 3000 | 3000 | ||
| 3001 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3001 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3002 | } | 3002 | } |
| 3003 | 3003 | ||
| 3004 | static void SvcWrap_UnmapIoRegion64(Core::System& system) { | 3004 | static void SvcWrap_UnmapIoRegion64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3005 | Result ret{}; | 3005 | Result ret{}; |
| 3006 | 3006 | ||
| 3007 | Handle io_region{}; | 3007 | Handle io_region{}; |
| 3008 | uint64_t address{}; | 3008 | uint64_t address{}; |
| 3009 | uint64_t size{}; | 3009 | uint64_t size{}; |
| 3010 | 3010 | ||
| 3011 | io_region = Convert<Handle>(GetReg64(system, 0)); | 3011 | io_region = Convert<Handle>(GetArg64(args, 0)); |
| 3012 | address = Convert<uint64_t>(GetReg64(system, 1)); | 3012 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3013 | size = Convert<uint64_t>(GetReg64(system, 2)); | 3013 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 3014 | 3014 | ||
| 3015 | ret = UnmapIoRegion64(system, io_region, address, size); | 3015 | ret = UnmapIoRegion64(system, io_region, address, size); |
| 3016 | 3016 | ||
| 3017 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3017 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3018 | } | 3018 | } |
| 3019 | 3019 | ||
| 3020 | static void SvcWrap_MapPhysicalMemoryUnsafe64(Core::System& system) { | 3020 | static void SvcWrap_MapPhysicalMemoryUnsafe64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3021 | Result ret{}; | 3021 | Result ret{}; |
| 3022 | 3022 | ||
| 3023 | uint64_t address{}; | 3023 | uint64_t address{}; |
| 3024 | uint64_t size{}; | 3024 | uint64_t size{}; |
| 3025 | 3025 | ||
| 3026 | address = Convert<uint64_t>(GetReg64(system, 0)); | 3026 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 3027 | size = Convert<uint64_t>(GetReg64(system, 1)); | 3027 | size = Convert<uint64_t>(GetArg64(args, 1)); |
| 3028 | 3028 | ||
| 3029 | ret = MapPhysicalMemoryUnsafe64(system, address, size); | 3029 | ret = MapPhysicalMemoryUnsafe64(system, address, size); |
| 3030 | 3030 | ||
| 3031 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3031 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3032 | } | 3032 | } |
| 3033 | 3033 | ||
| 3034 | static void SvcWrap_UnmapPhysicalMemoryUnsafe64(Core::System& system) { | 3034 | static void SvcWrap_UnmapPhysicalMemoryUnsafe64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3035 | Result ret{}; | 3035 | Result ret{}; |
| 3036 | 3036 | ||
| 3037 | uint64_t address{}; | 3037 | uint64_t address{}; |
| 3038 | uint64_t size{}; | 3038 | uint64_t size{}; |
| 3039 | 3039 | ||
| 3040 | address = Convert<uint64_t>(GetReg64(system, 0)); | 3040 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 3041 | size = Convert<uint64_t>(GetReg64(system, 1)); | 3041 | size = Convert<uint64_t>(GetArg64(args, 1)); |
| 3042 | 3042 | ||
| 3043 | ret = UnmapPhysicalMemoryUnsafe64(system, address, size); | 3043 | ret = UnmapPhysicalMemoryUnsafe64(system, address, size); |
| 3044 | 3044 | ||
| 3045 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3045 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3046 | } | 3046 | } |
| 3047 | 3047 | ||
| 3048 | static void SvcWrap_SetUnsafeLimit64(Core::System& system) { | 3048 | static void SvcWrap_SetUnsafeLimit64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3049 | Result ret{}; | 3049 | Result ret{}; |
| 3050 | 3050 | ||
| 3051 | uint64_t limit{}; | 3051 | uint64_t limit{}; |
| 3052 | 3052 | ||
| 3053 | limit = Convert<uint64_t>(GetReg64(system, 0)); | 3053 | limit = Convert<uint64_t>(GetArg64(args, 0)); |
| 3054 | 3054 | ||
| 3055 | ret = SetUnsafeLimit64(system, limit); | 3055 | ret = SetUnsafeLimit64(system, limit); |
| 3056 | 3056 | ||
| 3057 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3057 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3058 | } | 3058 | } |
| 3059 | 3059 | ||
| 3060 | static void SvcWrap_CreateCodeMemory64(Core::System& system) { | 3060 | static void SvcWrap_CreateCodeMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3061 | Result ret{}; | 3061 | Result ret{}; |
| 3062 | 3062 | ||
| 3063 | Handle out_handle{}; | 3063 | Handle out_handle{}; |
| 3064 | uint64_t address{}; | 3064 | uint64_t address{}; |
| 3065 | uint64_t size{}; | 3065 | uint64_t size{}; |
| 3066 | 3066 | ||
| 3067 | address = Convert<uint64_t>(GetReg64(system, 1)); | 3067 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3068 | size = Convert<uint64_t>(GetReg64(system, 2)); | 3068 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 3069 | 3069 | ||
| 3070 | ret = CreateCodeMemory64(system, std::addressof(out_handle), address, size); | 3070 | ret = CreateCodeMemory64(system, std::addressof(out_handle), address, size); |
| 3071 | 3071 | ||
| 3072 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3072 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3073 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 3073 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 3074 | } | 3074 | } |
| 3075 | 3075 | ||
| 3076 | static void SvcWrap_ControlCodeMemory64(Core::System& system) { | 3076 | static void SvcWrap_ControlCodeMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3077 | Result ret{}; | 3077 | Result ret{}; |
| 3078 | 3078 | ||
| 3079 | Handle code_memory_handle{}; | 3079 | Handle code_memory_handle{}; |
| @@ -3082,22 +3082,22 @@ static void SvcWrap_ControlCodeMemory64(Core::System& system) { | |||
| 3082 | uint64_t size{}; | 3082 | uint64_t size{}; |
| 3083 | MemoryPermission perm{}; | 3083 | MemoryPermission perm{}; |
| 3084 | 3084 | ||
| 3085 | code_memory_handle = Convert<Handle>(GetReg64(system, 0)); | 3085 | code_memory_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3086 | operation = Convert<CodeMemoryOperation>(GetReg64(system, 1)); | 3086 | operation = Convert<CodeMemoryOperation>(GetArg64(args, 1)); |
| 3087 | address = Convert<uint64_t>(GetReg64(system, 2)); | 3087 | address = Convert<uint64_t>(GetArg64(args, 2)); |
| 3088 | size = Convert<uint64_t>(GetReg64(system, 3)); | 3088 | size = Convert<uint64_t>(GetArg64(args, 3)); |
| 3089 | perm = Convert<MemoryPermission>(GetReg64(system, 4)); | 3089 | perm = Convert<MemoryPermission>(GetArg64(args, 4)); |
| 3090 | 3090 | ||
| 3091 | ret = ControlCodeMemory64(system, code_memory_handle, operation, address, size, perm); | 3091 | ret = ControlCodeMemory64(system, code_memory_handle, operation, address, size, perm); |
| 3092 | 3092 | ||
| 3093 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3093 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3094 | } | 3094 | } |
| 3095 | 3095 | ||
| 3096 | static void SvcWrap_SleepSystem64(Core::System& system) { | 3096 | static void SvcWrap_SleepSystem64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3097 | SleepSystem64(system); | 3097 | SleepSystem64(system); |
| 3098 | } | 3098 | } |
| 3099 | 3099 | ||
| 3100 | static void SvcWrap_ReadWriteRegister64(Core::System& system) { | 3100 | static void SvcWrap_ReadWriteRegister64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3101 | Result ret{}; | 3101 | Result ret{}; |
| 3102 | 3102 | ||
| 3103 | uint32_t out_value{}; | 3103 | uint32_t out_value{}; |
| @@ -3105,31 +3105,31 @@ static void SvcWrap_ReadWriteRegister64(Core::System& system) { | |||
| 3105 | uint32_t mask{}; | 3105 | uint32_t mask{}; |
| 3106 | uint32_t value{}; | 3106 | uint32_t value{}; |
| 3107 | 3107 | ||
| 3108 | address = Convert<uint64_t>(GetReg64(system, 1)); | 3108 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3109 | mask = Convert<uint32_t>(GetReg64(system, 2)); | 3109 | mask = Convert<uint32_t>(GetArg64(args, 2)); |
| 3110 | value = Convert<uint32_t>(GetReg64(system, 3)); | 3110 | value = Convert<uint32_t>(GetArg64(args, 3)); |
| 3111 | 3111 | ||
| 3112 | ret = ReadWriteRegister64(system, std::addressof(out_value), address, mask, value); | 3112 | ret = ReadWriteRegister64(system, std::addressof(out_value), address, mask, value); |
| 3113 | 3113 | ||
| 3114 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3114 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3115 | SetReg64(system, 1, Convert<uint64_t>(out_value)); | 3115 | SetArg64(args, 1, Convert<uint64_t>(out_value)); |
| 3116 | } | 3116 | } |
| 3117 | 3117 | ||
| 3118 | static void SvcWrap_SetProcessActivity64(Core::System& system) { | 3118 | static void SvcWrap_SetProcessActivity64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3119 | Result ret{}; | 3119 | Result ret{}; |
| 3120 | 3120 | ||
| 3121 | Handle process_handle{}; | 3121 | Handle process_handle{}; |
| 3122 | ProcessActivity process_activity{}; | 3122 | ProcessActivity process_activity{}; |
| 3123 | 3123 | ||
| 3124 | process_handle = Convert<Handle>(GetReg64(system, 0)); | 3124 | process_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3125 | process_activity = Convert<ProcessActivity>(GetReg64(system, 1)); | 3125 | process_activity = Convert<ProcessActivity>(GetArg64(args, 1)); |
| 3126 | 3126 | ||
| 3127 | ret = SetProcessActivity64(system, process_handle, process_activity); | 3127 | ret = SetProcessActivity64(system, process_handle, process_activity); |
| 3128 | 3128 | ||
| 3129 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3129 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3130 | } | 3130 | } |
| 3131 | 3131 | ||
| 3132 | static void SvcWrap_CreateSharedMemory64(Core::System& system) { | 3132 | static void SvcWrap_CreateSharedMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3133 | Result ret{}; | 3133 | Result ret{}; |
| 3134 | 3134 | ||
| 3135 | Handle out_handle{}; | 3135 | Handle out_handle{}; |
| @@ -3137,17 +3137,17 @@ static void SvcWrap_CreateSharedMemory64(Core::System& system) { | |||
| 3137 | MemoryPermission owner_perm{}; | 3137 | MemoryPermission owner_perm{}; |
| 3138 | MemoryPermission remote_perm{}; | 3138 | MemoryPermission remote_perm{}; |
| 3139 | 3139 | ||
| 3140 | size = Convert<uint64_t>(GetReg64(system, 1)); | 3140 | size = Convert<uint64_t>(GetArg64(args, 1)); |
| 3141 | owner_perm = Convert<MemoryPermission>(GetReg64(system, 2)); | 3141 | owner_perm = Convert<MemoryPermission>(GetArg64(args, 2)); |
| 3142 | remote_perm = Convert<MemoryPermission>(GetReg64(system, 3)); | 3142 | remote_perm = Convert<MemoryPermission>(GetArg64(args, 3)); |
| 3143 | 3143 | ||
| 3144 | ret = CreateSharedMemory64(system, std::addressof(out_handle), size, owner_perm, remote_perm); | 3144 | ret = CreateSharedMemory64(system, std::addressof(out_handle), size, owner_perm, remote_perm); |
| 3145 | 3145 | ||
| 3146 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3146 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3147 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 3147 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 3148 | } | 3148 | } |
| 3149 | 3149 | ||
| 3150 | static void SvcWrap_MapTransferMemory64(Core::System& system) { | 3150 | static void SvcWrap_MapTransferMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3151 | Result ret{}; | 3151 | Result ret{}; |
| 3152 | 3152 | ||
| 3153 | Handle trmem_handle{}; | 3153 | Handle trmem_handle{}; |
| @@ -3155,66 +3155,66 @@ static void SvcWrap_MapTransferMemory64(Core::System& system) { | |||
| 3155 | uint64_t size{}; | 3155 | uint64_t size{}; |
| 3156 | MemoryPermission owner_perm{}; | 3156 | MemoryPermission owner_perm{}; |
| 3157 | 3157 | ||
| 3158 | trmem_handle = Convert<Handle>(GetReg64(system, 0)); | 3158 | trmem_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3159 | address = Convert<uint64_t>(GetReg64(system, 1)); | 3159 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3160 | size = Convert<uint64_t>(GetReg64(system, 2)); | 3160 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 3161 | owner_perm = Convert<MemoryPermission>(GetReg64(system, 3)); | 3161 | owner_perm = Convert<MemoryPermission>(GetArg64(args, 3)); |
| 3162 | 3162 | ||
| 3163 | ret = MapTransferMemory64(system, trmem_handle, address, size, owner_perm); | 3163 | ret = MapTransferMemory64(system, trmem_handle, address, size, owner_perm); |
| 3164 | 3164 | ||
| 3165 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3165 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3166 | } | 3166 | } |
| 3167 | 3167 | ||
| 3168 | static void SvcWrap_UnmapTransferMemory64(Core::System& system) { | 3168 | static void SvcWrap_UnmapTransferMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3169 | Result ret{}; | 3169 | Result ret{}; |
| 3170 | 3170 | ||
| 3171 | Handle trmem_handle{}; | 3171 | Handle trmem_handle{}; |
| 3172 | uint64_t address{}; | 3172 | uint64_t address{}; |
| 3173 | uint64_t size{}; | 3173 | uint64_t size{}; |
| 3174 | 3174 | ||
| 3175 | trmem_handle = Convert<Handle>(GetReg64(system, 0)); | 3175 | trmem_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3176 | address = Convert<uint64_t>(GetReg64(system, 1)); | 3176 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3177 | size = Convert<uint64_t>(GetReg64(system, 2)); | 3177 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 3178 | 3178 | ||
| 3179 | ret = UnmapTransferMemory64(system, trmem_handle, address, size); | 3179 | ret = UnmapTransferMemory64(system, trmem_handle, address, size); |
| 3180 | 3180 | ||
| 3181 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3181 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3182 | } | 3182 | } |
| 3183 | 3183 | ||
| 3184 | static void SvcWrap_CreateInterruptEvent64(Core::System& system) { | 3184 | static void SvcWrap_CreateInterruptEvent64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3185 | Result ret{}; | 3185 | Result ret{}; |
| 3186 | 3186 | ||
| 3187 | Handle out_read_handle{}; | 3187 | Handle out_read_handle{}; |
| 3188 | int32_t interrupt_id{}; | 3188 | int32_t interrupt_id{}; |
| 3189 | InterruptType interrupt_type{}; | 3189 | InterruptType interrupt_type{}; |
| 3190 | 3190 | ||
| 3191 | interrupt_id = Convert<int32_t>(GetReg64(system, 1)); | 3191 | interrupt_id = Convert<int32_t>(GetArg64(args, 1)); |
| 3192 | interrupt_type = Convert<InterruptType>(GetReg64(system, 2)); | 3192 | interrupt_type = Convert<InterruptType>(GetArg64(args, 2)); |
| 3193 | 3193 | ||
| 3194 | ret = CreateInterruptEvent64(system, std::addressof(out_read_handle), interrupt_id, interrupt_type); | 3194 | ret = CreateInterruptEvent64(system, std::addressof(out_read_handle), interrupt_id, interrupt_type); |
| 3195 | 3195 | ||
| 3196 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3196 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3197 | SetReg64(system, 1, Convert<uint64_t>(out_read_handle)); | 3197 | SetArg64(args, 1, Convert<uint64_t>(out_read_handle)); |
| 3198 | } | 3198 | } |
| 3199 | 3199 | ||
| 3200 | static void SvcWrap_QueryPhysicalAddress64(Core::System& system) { | 3200 | static void SvcWrap_QueryPhysicalAddress64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3201 | Result ret{}; | 3201 | Result ret{}; |
| 3202 | 3202 | ||
| 3203 | lp64::PhysicalMemoryInfo out_info{}; | 3203 | lp64::PhysicalMemoryInfo out_info{}; |
| 3204 | uint64_t address{}; | 3204 | uint64_t address{}; |
| 3205 | 3205 | ||
| 3206 | address = Convert<uint64_t>(GetReg64(system, 1)); | 3206 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3207 | 3207 | ||
| 3208 | ret = QueryPhysicalAddress64(system, std::addressof(out_info), address); | 3208 | ret = QueryPhysicalAddress64(system, std::addressof(out_info), address); |
| 3209 | 3209 | ||
| 3210 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3210 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3211 | auto out_info_scatter = Convert<std::array<uint64_t, 3>>(out_info); | 3211 | auto out_info_scatter = Convert<std::array<uint64_t, 3>>(out_info); |
| 3212 | SetReg64(system, 1, out_info_scatter[0]); | 3212 | SetArg64(args, 1, out_info_scatter[0]); |
| 3213 | SetReg64(system, 2, out_info_scatter[1]); | 3213 | SetArg64(args, 2, out_info_scatter[1]); |
| 3214 | SetReg64(system, 3, out_info_scatter[2]); | 3214 | SetArg64(args, 3, out_info_scatter[2]); |
| 3215 | } | 3215 | } |
| 3216 | 3216 | ||
| 3217 | static void SvcWrap_QueryIoMapping64(Core::System& system) { | 3217 | static void SvcWrap_QueryIoMapping64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3218 | Result ret{}; | 3218 | Result ret{}; |
| 3219 | 3219 | ||
| 3220 | uint64_t out_address{}; | 3220 | uint64_t out_address{}; |
| @@ -3222,61 +3222,61 @@ static void SvcWrap_QueryIoMapping64(Core::System& system) { | |||
| 3222 | uint64_t physical_address{}; | 3222 | uint64_t physical_address{}; |
| 3223 | uint64_t size{}; | 3223 | uint64_t size{}; |
| 3224 | 3224 | ||
| 3225 | physical_address = Convert<uint64_t>(GetReg64(system, 2)); | 3225 | physical_address = Convert<uint64_t>(GetArg64(args, 2)); |
| 3226 | size = Convert<uint64_t>(GetReg64(system, 3)); | 3226 | size = Convert<uint64_t>(GetArg64(args, 3)); |
| 3227 | 3227 | ||
| 3228 | ret = QueryIoMapping64(system, std::addressof(out_address), std::addressof(out_size), physical_address, size); | 3228 | ret = QueryIoMapping64(system, std::addressof(out_address), std::addressof(out_size), physical_address, size); |
| 3229 | 3229 | ||
| 3230 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3230 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3231 | SetReg64(system, 1, Convert<uint64_t>(out_address)); | 3231 | SetArg64(args, 1, Convert<uint64_t>(out_address)); |
| 3232 | SetReg64(system, 2, Convert<uint64_t>(out_size)); | 3232 | SetArg64(args, 2, Convert<uint64_t>(out_size)); |
| 3233 | } | 3233 | } |
| 3234 | 3234 | ||
| 3235 | static void SvcWrap_CreateDeviceAddressSpace64(Core::System& system) { | 3235 | static void SvcWrap_CreateDeviceAddressSpace64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3236 | Result ret{}; | 3236 | Result ret{}; |
| 3237 | 3237 | ||
| 3238 | Handle out_handle{}; | 3238 | Handle out_handle{}; |
| 3239 | uint64_t das_address{}; | 3239 | uint64_t das_address{}; |
| 3240 | uint64_t das_size{}; | 3240 | uint64_t das_size{}; |
| 3241 | 3241 | ||
| 3242 | das_address = Convert<uint64_t>(GetReg64(system, 1)); | 3242 | das_address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3243 | das_size = Convert<uint64_t>(GetReg64(system, 2)); | 3243 | das_size = Convert<uint64_t>(GetArg64(args, 2)); |
| 3244 | 3244 | ||
| 3245 | ret = CreateDeviceAddressSpace64(system, std::addressof(out_handle), das_address, das_size); | 3245 | ret = CreateDeviceAddressSpace64(system, std::addressof(out_handle), das_address, das_size); |
| 3246 | 3246 | ||
| 3247 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3247 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3248 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 3248 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 3249 | } | 3249 | } |
| 3250 | 3250 | ||
| 3251 | static void SvcWrap_AttachDeviceAddressSpace64(Core::System& system) { | 3251 | static void SvcWrap_AttachDeviceAddressSpace64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3252 | Result ret{}; | 3252 | Result ret{}; |
| 3253 | 3253 | ||
| 3254 | DeviceName device_name{}; | 3254 | DeviceName device_name{}; |
| 3255 | Handle das_handle{}; | 3255 | Handle das_handle{}; |
| 3256 | 3256 | ||
| 3257 | device_name = Convert<DeviceName>(GetReg64(system, 0)); | 3257 | device_name = Convert<DeviceName>(GetArg64(args, 0)); |
| 3258 | das_handle = Convert<Handle>(GetReg64(system, 1)); | 3258 | das_handle = Convert<Handle>(GetArg64(args, 1)); |
| 3259 | 3259 | ||
| 3260 | ret = AttachDeviceAddressSpace64(system, device_name, das_handle); | 3260 | ret = AttachDeviceAddressSpace64(system, device_name, das_handle); |
| 3261 | 3261 | ||
| 3262 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3262 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3263 | } | 3263 | } |
| 3264 | 3264 | ||
| 3265 | static void SvcWrap_DetachDeviceAddressSpace64(Core::System& system) { | 3265 | static void SvcWrap_DetachDeviceAddressSpace64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3266 | Result ret{}; | 3266 | Result ret{}; |
| 3267 | 3267 | ||
| 3268 | DeviceName device_name{}; | 3268 | DeviceName device_name{}; |
| 3269 | Handle das_handle{}; | 3269 | Handle das_handle{}; |
| 3270 | 3270 | ||
| 3271 | device_name = Convert<DeviceName>(GetReg64(system, 0)); | 3271 | device_name = Convert<DeviceName>(GetArg64(args, 0)); |
| 3272 | das_handle = Convert<Handle>(GetReg64(system, 1)); | 3272 | das_handle = Convert<Handle>(GetArg64(args, 1)); |
| 3273 | 3273 | ||
| 3274 | ret = DetachDeviceAddressSpace64(system, device_name, das_handle); | 3274 | ret = DetachDeviceAddressSpace64(system, device_name, das_handle); |
| 3275 | 3275 | ||
| 3276 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3276 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3277 | } | 3277 | } |
| 3278 | 3278 | ||
| 3279 | static void SvcWrap_MapDeviceAddressSpaceByForce64(Core::System& system) { | 3279 | static void SvcWrap_MapDeviceAddressSpaceByForce64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3280 | Result ret{}; | 3280 | Result ret{}; |
| 3281 | 3281 | ||
| 3282 | Handle das_handle{}; | 3282 | Handle das_handle{}; |
| @@ -3286,19 +3286,19 @@ static void SvcWrap_MapDeviceAddressSpaceByForce64(Core::System& system) { | |||
| 3286 | uint64_t device_address{}; | 3286 | uint64_t device_address{}; |
| 3287 | uint32_t option{}; | 3287 | uint32_t option{}; |
| 3288 | 3288 | ||
| 3289 | das_handle = Convert<Handle>(GetReg64(system, 0)); | 3289 | das_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3290 | process_handle = Convert<Handle>(GetReg64(system, 1)); | 3290 | process_handle = Convert<Handle>(GetArg64(args, 1)); |
| 3291 | process_address = Convert<uint64_t>(GetReg64(system, 2)); | 3291 | process_address = Convert<uint64_t>(GetArg64(args, 2)); |
| 3292 | size = Convert<uint64_t>(GetReg64(system, 3)); | 3292 | size = Convert<uint64_t>(GetArg64(args, 3)); |
| 3293 | device_address = Convert<uint64_t>(GetReg64(system, 4)); | 3293 | device_address = Convert<uint64_t>(GetArg64(args, 4)); |
| 3294 | option = Convert<uint32_t>(GetReg64(system, 5)); | 3294 | option = Convert<uint32_t>(GetArg64(args, 5)); |
| 3295 | 3295 | ||
| 3296 | ret = MapDeviceAddressSpaceByForce64(system, das_handle, process_handle, process_address, size, device_address, option); | 3296 | ret = MapDeviceAddressSpaceByForce64(system, das_handle, process_handle, process_address, size, device_address, option); |
| 3297 | 3297 | ||
| 3298 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3298 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3299 | } | 3299 | } |
| 3300 | 3300 | ||
| 3301 | static void SvcWrap_MapDeviceAddressSpaceAligned64(Core::System& system) { | 3301 | static void SvcWrap_MapDeviceAddressSpaceAligned64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3302 | Result ret{}; | 3302 | Result ret{}; |
| 3303 | 3303 | ||
| 3304 | Handle das_handle{}; | 3304 | Handle das_handle{}; |
| @@ -3308,19 +3308,19 @@ static void SvcWrap_MapDeviceAddressSpaceAligned64(Core::System& system) { | |||
| 3308 | uint64_t device_address{}; | 3308 | uint64_t device_address{}; |
| 3309 | uint32_t option{}; | 3309 | uint32_t option{}; |
| 3310 | 3310 | ||
| 3311 | das_handle = Convert<Handle>(GetReg64(system, 0)); | 3311 | das_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3312 | process_handle = Convert<Handle>(GetReg64(system, 1)); | 3312 | process_handle = Convert<Handle>(GetArg64(args, 1)); |
| 3313 | process_address = Convert<uint64_t>(GetReg64(system, 2)); | 3313 | process_address = Convert<uint64_t>(GetArg64(args, 2)); |
| 3314 | size = Convert<uint64_t>(GetReg64(system, 3)); | 3314 | size = Convert<uint64_t>(GetArg64(args, 3)); |
| 3315 | device_address = Convert<uint64_t>(GetReg64(system, 4)); | 3315 | device_address = Convert<uint64_t>(GetArg64(args, 4)); |
| 3316 | option = Convert<uint32_t>(GetReg64(system, 5)); | 3316 | option = Convert<uint32_t>(GetArg64(args, 5)); |
| 3317 | 3317 | ||
| 3318 | ret = MapDeviceAddressSpaceAligned64(system, das_handle, process_handle, process_address, size, device_address, option); | 3318 | ret = MapDeviceAddressSpaceAligned64(system, das_handle, process_handle, process_address, size, device_address, option); |
| 3319 | 3319 | ||
| 3320 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3320 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3321 | } | 3321 | } |
| 3322 | 3322 | ||
| 3323 | static void SvcWrap_UnmapDeviceAddressSpace64(Core::System& system) { | 3323 | static void SvcWrap_UnmapDeviceAddressSpace64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3324 | Result ret{}; | 3324 | Result ret{}; |
| 3325 | 3325 | ||
| 3326 | Handle das_handle{}; | 3326 | Handle das_handle{}; |
| @@ -3329,118 +3329,118 @@ static void SvcWrap_UnmapDeviceAddressSpace64(Core::System& system) { | |||
| 3329 | uint64_t size{}; | 3329 | uint64_t size{}; |
| 3330 | uint64_t device_address{}; | 3330 | uint64_t device_address{}; |
| 3331 | 3331 | ||
| 3332 | das_handle = Convert<Handle>(GetReg64(system, 0)); | 3332 | das_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3333 | process_handle = Convert<Handle>(GetReg64(system, 1)); | 3333 | process_handle = Convert<Handle>(GetArg64(args, 1)); |
| 3334 | process_address = Convert<uint64_t>(GetReg64(system, 2)); | 3334 | process_address = Convert<uint64_t>(GetArg64(args, 2)); |
| 3335 | size = Convert<uint64_t>(GetReg64(system, 3)); | 3335 | size = Convert<uint64_t>(GetArg64(args, 3)); |
| 3336 | device_address = Convert<uint64_t>(GetReg64(system, 4)); | 3336 | device_address = Convert<uint64_t>(GetArg64(args, 4)); |
| 3337 | 3337 | ||
| 3338 | ret = UnmapDeviceAddressSpace64(system, das_handle, process_handle, process_address, size, device_address); | 3338 | ret = UnmapDeviceAddressSpace64(system, das_handle, process_handle, process_address, size, device_address); |
| 3339 | 3339 | ||
| 3340 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3340 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3341 | } | 3341 | } |
| 3342 | 3342 | ||
| 3343 | static void SvcWrap_InvalidateProcessDataCache64(Core::System& system) { | 3343 | static void SvcWrap_InvalidateProcessDataCache64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3344 | Result ret{}; | 3344 | Result ret{}; |
| 3345 | 3345 | ||
| 3346 | Handle process_handle{}; | 3346 | Handle process_handle{}; |
| 3347 | uint64_t address{}; | 3347 | uint64_t address{}; |
| 3348 | uint64_t size{}; | 3348 | uint64_t size{}; |
| 3349 | 3349 | ||
| 3350 | process_handle = Convert<Handle>(GetReg64(system, 0)); | 3350 | process_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3351 | address = Convert<uint64_t>(GetReg64(system, 1)); | 3351 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3352 | size = Convert<uint64_t>(GetReg64(system, 2)); | 3352 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 3353 | 3353 | ||
| 3354 | ret = InvalidateProcessDataCache64(system, process_handle, address, size); | 3354 | ret = InvalidateProcessDataCache64(system, process_handle, address, size); |
| 3355 | 3355 | ||
| 3356 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3356 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3357 | } | 3357 | } |
| 3358 | 3358 | ||
| 3359 | static void SvcWrap_StoreProcessDataCache64(Core::System& system) { | 3359 | static void SvcWrap_StoreProcessDataCache64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3360 | Result ret{}; | 3360 | Result ret{}; |
| 3361 | 3361 | ||
| 3362 | Handle process_handle{}; | 3362 | Handle process_handle{}; |
| 3363 | uint64_t address{}; | 3363 | uint64_t address{}; |
| 3364 | uint64_t size{}; | 3364 | uint64_t size{}; |
| 3365 | 3365 | ||
| 3366 | process_handle = Convert<Handle>(GetReg64(system, 0)); | 3366 | process_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3367 | address = Convert<uint64_t>(GetReg64(system, 1)); | 3367 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3368 | size = Convert<uint64_t>(GetReg64(system, 2)); | 3368 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 3369 | 3369 | ||
| 3370 | ret = StoreProcessDataCache64(system, process_handle, address, size); | 3370 | ret = StoreProcessDataCache64(system, process_handle, address, size); |
| 3371 | 3371 | ||
| 3372 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3372 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3373 | } | 3373 | } |
| 3374 | 3374 | ||
| 3375 | static void SvcWrap_FlushProcessDataCache64(Core::System& system) { | 3375 | static void SvcWrap_FlushProcessDataCache64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3376 | Result ret{}; | 3376 | Result ret{}; |
| 3377 | 3377 | ||
| 3378 | Handle process_handle{}; | 3378 | Handle process_handle{}; |
| 3379 | uint64_t address{}; | 3379 | uint64_t address{}; |
| 3380 | uint64_t size{}; | 3380 | uint64_t size{}; |
| 3381 | 3381 | ||
| 3382 | process_handle = Convert<Handle>(GetReg64(system, 0)); | 3382 | process_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3383 | address = Convert<uint64_t>(GetReg64(system, 1)); | 3383 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3384 | size = Convert<uint64_t>(GetReg64(system, 2)); | 3384 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 3385 | 3385 | ||
| 3386 | ret = FlushProcessDataCache64(system, process_handle, address, size); | 3386 | ret = FlushProcessDataCache64(system, process_handle, address, size); |
| 3387 | 3387 | ||
| 3388 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3388 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3389 | } | 3389 | } |
| 3390 | 3390 | ||
| 3391 | static void SvcWrap_DebugActiveProcess64(Core::System& system) { | 3391 | static void SvcWrap_DebugActiveProcess64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3392 | Result ret{}; | 3392 | Result ret{}; |
| 3393 | 3393 | ||
| 3394 | Handle out_handle{}; | 3394 | Handle out_handle{}; |
| 3395 | uint64_t process_id{}; | 3395 | uint64_t process_id{}; |
| 3396 | 3396 | ||
| 3397 | process_id = Convert<uint64_t>(GetReg64(system, 1)); | 3397 | process_id = Convert<uint64_t>(GetArg64(args, 1)); |
| 3398 | 3398 | ||
| 3399 | ret = DebugActiveProcess64(system, std::addressof(out_handle), process_id); | 3399 | ret = DebugActiveProcess64(system, std::addressof(out_handle), process_id); |
| 3400 | 3400 | ||
| 3401 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3401 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3402 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 3402 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 3403 | } | 3403 | } |
| 3404 | 3404 | ||
| 3405 | static void SvcWrap_BreakDebugProcess64(Core::System& system) { | 3405 | static void SvcWrap_BreakDebugProcess64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3406 | Result ret{}; | 3406 | Result ret{}; |
| 3407 | 3407 | ||
| 3408 | Handle debug_handle{}; | 3408 | Handle debug_handle{}; |
| 3409 | 3409 | ||
| 3410 | debug_handle = Convert<Handle>(GetReg64(system, 0)); | 3410 | debug_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3411 | 3411 | ||
| 3412 | ret = BreakDebugProcess64(system, debug_handle); | 3412 | ret = BreakDebugProcess64(system, debug_handle); |
| 3413 | 3413 | ||
| 3414 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3414 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3415 | } | 3415 | } |
| 3416 | 3416 | ||
| 3417 | static void SvcWrap_TerminateDebugProcess64(Core::System& system) { | 3417 | static void SvcWrap_TerminateDebugProcess64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3418 | Result ret{}; | 3418 | Result ret{}; |
| 3419 | 3419 | ||
| 3420 | Handle debug_handle{}; | 3420 | Handle debug_handle{}; |
| 3421 | 3421 | ||
| 3422 | debug_handle = Convert<Handle>(GetReg64(system, 0)); | 3422 | debug_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3423 | 3423 | ||
| 3424 | ret = TerminateDebugProcess64(system, debug_handle); | 3424 | ret = TerminateDebugProcess64(system, debug_handle); |
| 3425 | 3425 | ||
| 3426 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3426 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3427 | } | 3427 | } |
| 3428 | 3428 | ||
| 3429 | static void SvcWrap_GetDebugEvent64(Core::System& system) { | 3429 | static void SvcWrap_GetDebugEvent64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3430 | Result ret{}; | 3430 | Result ret{}; |
| 3431 | 3431 | ||
| 3432 | uint64_t out_info{}; | 3432 | uint64_t out_info{}; |
| 3433 | Handle debug_handle{}; | 3433 | Handle debug_handle{}; |
| 3434 | 3434 | ||
| 3435 | out_info = Convert<uint64_t>(GetReg64(system, 0)); | 3435 | out_info = Convert<uint64_t>(GetArg64(args, 0)); |
| 3436 | debug_handle = Convert<Handle>(GetReg64(system, 1)); | 3436 | debug_handle = Convert<Handle>(GetArg64(args, 1)); |
| 3437 | 3437 | ||
| 3438 | ret = GetDebugEvent64(system, out_info, debug_handle); | 3438 | ret = GetDebugEvent64(system, out_info, debug_handle); |
| 3439 | 3439 | ||
| 3440 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3440 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3441 | } | 3441 | } |
| 3442 | 3442 | ||
| 3443 | static void SvcWrap_ContinueDebugEvent64(Core::System& system) { | 3443 | static void SvcWrap_ContinueDebugEvent64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3444 | Result ret{}; | 3444 | Result ret{}; |
| 3445 | 3445 | ||
| 3446 | Handle debug_handle{}; | 3446 | Handle debug_handle{}; |
| @@ -3448,33 +3448,33 @@ static void SvcWrap_ContinueDebugEvent64(Core::System& system) { | |||
| 3448 | uint64_t thread_ids{}; | 3448 | uint64_t thread_ids{}; |
| 3449 | int32_t num_thread_ids{}; | 3449 | int32_t num_thread_ids{}; |
| 3450 | 3450 | ||
| 3451 | debug_handle = Convert<Handle>(GetReg64(system, 0)); | 3451 | debug_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3452 | flags = Convert<uint32_t>(GetReg64(system, 1)); | 3452 | flags = Convert<uint32_t>(GetArg64(args, 1)); |
| 3453 | thread_ids = Convert<uint64_t>(GetReg64(system, 2)); | 3453 | thread_ids = Convert<uint64_t>(GetArg64(args, 2)); |
| 3454 | num_thread_ids = Convert<int32_t>(GetReg64(system, 3)); | 3454 | num_thread_ids = Convert<int32_t>(GetArg64(args, 3)); |
| 3455 | 3455 | ||
| 3456 | ret = ContinueDebugEvent64(system, debug_handle, flags, thread_ids, num_thread_ids); | 3456 | ret = ContinueDebugEvent64(system, debug_handle, flags, thread_ids, num_thread_ids); |
| 3457 | 3457 | ||
| 3458 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3458 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3459 | } | 3459 | } |
| 3460 | 3460 | ||
| 3461 | static void SvcWrap_GetProcessList64(Core::System& system) { | 3461 | static void SvcWrap_GetProcessList64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3462 | Result ret{}; | 3462 | Result ret{}; |
| 3463 | 3463 | ||
| 3464 | int32_t out_num_processes{}; | 3464 | int32_t out_num_processes{}; |
| 3465 | uint64_t out_process_ids{}; | 3465 | uint64_t out_process_ids{}; |
| 3466 | int32_t max_out_count{}; | 3466 | int32_t max_out_count{}; |
| 3467 | 3467 | ||
| 3468 | out_process_ids = Convert<uint64_t>(GetReg64(system, 1)); | 3468 | out_process_ids = Convert<uint64_t>(GetArg64(args, 1)); |
| 3469 | max_out_count = Convert<int32_t>(GetReg64(system, 2)); | 3469 | max_out_count = Convert<int32_t>(GetArg64(args, 2)); |
| 3470 | 3470 | ||
| 3471 | ret = GetProcessList64(system, std::addressof(out_num_processes), out_process_ids, max_out_count); | 3471 | ret = GetProcessList64(system, std::addressof(out_num_processes), out_process_ids, max_out_count); |
| 3472 | 3472 | ||
| 3473 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3473 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3474 | SetReg64(system, 1, Convert<uint64_t>(out_num_processes)); | 3474 | SetArg64(args, 1, Convert<uint64_t>(out_num_processes)); |
| 3475 | } | 3475 | } |
| 3476 | 3476 | ||
| 3477 | static void SvcWrap_GetThreadList64(Core::System& system) { | 3477 | static void SvcWrap_GetThreadList64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3478 | Result ret{}; | 3478 | Result ret{}; |
| 3479 | 3479 | ||
| 3480 | int32_t out_num_threads{}; | 3480 | int32_t out_num_threads{}; |
| @@ -3482,17 +3482,17 @@ static void SvcWrap_GetThreadList64(Core::System& system) { | |||
| 3482 | int32_t max_out_count{}; | 3482 | int32_t max_out_count{}; |
| 3483 | Handle debug_handle{}; | 3483 | Handle debug_handle{}; |
| 3484 | 3484 | ||
| 3485 | out_thread_ids = Convert<uint64_t>(GetReg64(system, 1)); | 3485 | out_thread_ids = Convert<uint64_t>(GetArg64(args, 1)); |
| 3486 | max_out_count = Convert<int32_t>(GetReg64(system, 2)); | 3486 | max_out_count = Convert<int32_t>(GetArg64(args, 2)); |
| 3487 | debug_handle = Convert<Handle>(GetReg64(system, 3)); | 3487 | debug_handle = Convert<Handle>(GetArg64(args, 3)); |
| 3488 | 3488 | ||
| 3489 | ret = GetThreadList64(system, std::addressof(out_num_threads), out_thread_ids, max_out_count, debug_handle); | 3489 | ret = GetThreadList64(system, std::addressof(out_num_threads), out_thread_ids, max_out_count, debug_handle); |
| 3490 | 3490 | ||
| 3491 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3491 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3492 | SetReg64(system, 1, Convert<uint64_t>(out_num_threads)); | 3492 | SetArg64(args, 1, Convert<uint64_t>(out_num_threads)); |
| 3493 | } | 3493 | } |
| 3494 | 3494 | ||
| 3495 | static void SvcWrap_GetDebugThreadContext64(Core::System& system) { | 3495 | static void SvcWrap_GetDebugThreadContext64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3496 | Result ret{}; | 3496 | Result ret{}; |
| 3497 | 3497 | ||
| 3498 | uint64_t out_context{}; | 3498 | uint64_t out_context{}; |
| @@ -3500,17 +3500,17 @@ static void SvcWrap_GetDebugThreadContext64(Core::System& system) { | |||
| 3500 | uint64_t thread_id{}; | 3500 | uint64_t thread_id{}; |
| 3501 | uint32_t context_flags{}; | 3501 | uint32_t context_flags{}; |
| 3502 | 3502 | ||
| 3503 | out_context = Convert<uint64_t>(GetReg64(system, 0)); | 3503 | out_context = Convert<uint64_t>(GetArg64(args, 0)); |
| 3504 | debug_handle = Convert<Handle>(GetReg64(system, 1)); | 3504 | debug_handle = Convert<Handle>(GetArg64(args, 1)); |
| 3505 | thread_id = Convert<uint64_t>(GetReg64(system, 2)); | 3505 | thread_id = Convert<uint64_t>(GetArg64(args, 2)); |
| 3506 | context_flags = Convert<uint32_t>(GetReg64(system, 3)); | 3506 | context_flags = Convert<uint32_t>(GetArg64(args, 3)); |
| 3507 | 3507 | ||
| 3508 | ret = GetDebugThreadContext64(system, out_context, debug_handle, thread_id, context_flags); | 3508 | ret = GetDebugThreadContext64(system, out_context, debug_handle, thread_id, context_flags); |
| 3509 | 3509 | ||
| 3510 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3510 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3511 | } | 3511 | } |
| 3512 | 3512 | ||
| 3513 | static void SvcWrap_SetDebugThreadContext64(Core::System& system) { | 3513 | static void SvcWrap_SetDebugThreadContext64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3514 | Result ret{}; | 3514 | Result ret{}; |
| 3515 | 3515 | ||
| 3516 | Handle debug_handle{}; | 3516 | Handle debug_handle{}; |
| @@ -3518,17 +3518,17 @@ static void SvcWrap_SetDebugThreadContext64(Core::System& system) { | |||
| 3518 | uint64_t context{}; | 3518 | uint64_t context{}; |
| 3519 | uint32_t context_flags{}; | 3519 | uint32_t context_flags{}; |
| 3520 | 3520 | ||
| 3521 | debug_handle = Convert<Handle>(GetReg64(system, 0)); | 3521 | debug_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3522 | thread_id = Convert<uint64_t>(GetReg64(system, 1)); | 3522 | thread_id = Convert<uint64_t>(GetArg64(args, 1)); |
| 3523 | context = Convert<uint64_t>(GetReg64(system, 2)); | 3523 | context = Convert<uint64_t>(GetArg64(args, 2)); |
| 3524 | context_flags = Convert<uint32_t>(GetReg64(system, 3)); | 3524 | context_flags = Convert<uint32_t>(GetArg64(args, 3)); |
| 3525 | 3525 | ||
| 3526 | ret = SetDebugThreadContext64(system, debug_handle, thread_id, context, context_flags); | 3526 | ret = SetDebugThreadContext64(system, debug_handle, thread_id, context, context_flags); |
| 3527 | 3527 | ||
| 3528 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3528 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3529 | } | 3529 | } |
| 3530 | 3530 | ||
| 3531 | static void SvcWrap_QueryDebugProcessMemory64(Core::System& system) { | 3531 | static void SvcWrap_QueryDebugProcessMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3532 | Result ret{}; | 3532 | Result ret{}; |
| 3533 | 3533 | ||
| 3534 | PageInfo out_page_info{}; | 3534 | PageInfo out_page_info{}; |
| @@ -3536,17 +3536,17 @@ static void SvcWrap_QueryDebugProcessMemory64(Core::System& system) { | |||
| 3536 | Handle process_handle{}; | 3536 | Handle process_handle{}; |
| 3537 | uint64_t address{}; | 3537 | uint64_t address{}; |
| 3538 | 3538 | ||
| 3539 | out_memory_info = Convert<uint64_t>(GetReg64(system, 0)); | 3539 | out_memory_info = Convert<uint64_t>(GetArg64(args, 0)); |
| 3540 | process_handle = Convert<Handle>(GetReg64(system, 2)); | 3540 | process_handle = Convert<Handle>(GetArg64(args, 2)); |
| 3541 | address = Convert<uint64_t>(GetReg64(system, 3)); | 3541 | address = Convert<uint64_t>(GetArg64(args, 3)); |
| 3542 | 3542 | ||
| 3543 | ret = QueryDebugProcessMemory64(system, out_memory_info, std::addressof(out_page_info), process_handle, address); | 3543 | ret = QueryDebugProcessMemory64(system, out_memory_info, std::addressof(out_page_info), process_handle, address); |
| 3544 | 3544 | ||
| 3545 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3545 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3546 | SetReg64(system, 1, Convert<uint64_t>(out_page_info)); | 3546 | SetArg64(args, 1, Convert<uint64_t>(out_page_info)); |
| 3547 | } | 3547 | } |
| 3548 | 3548 | ||
| 3549 | static void SvcWrap_ReadDebugProcessMemory64(Core::System& system) { | 3549 | static void SvcWrap_ReadDebugProcessMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3550 | Result ret{}; | 3550 | Result ret{}; |
| 3551 | 3551 | ||
| 3552 | uint64_t buffer{}; | 3552 | uint64_t buffer{}; |
| @@ -3554,17 +3554,17 @@ static void SvcWrap_ReadDebugProcessMemory64(Core::System& system) { | |||
| 3554 | uint64_t address{}; | 3554 | uint64_t address{}; |
| 3555 | uint64_t size{}; | 3555 | uint64_t size{}; |
| 3556 | 3556 | ||
| 3557 | buffer = Convert<uint64_t>(GetReg64(system, 0)); | 3557 | buffer = Convert<uint64_t>(GetArg64(args, 0)); |
| 3558 | debug_handle = Convert<Handle>(GetReg64(system, 1)); | 3558 | debug_handle = Convert<Handle>(GetArg64(args, 1)); |
| 3559 | address = Convert<uint64_t>(GetReg64(system, 2)); | 3559 | address = Convert<uint64_t>(GetArg64(args, 2)); |
| 3560 | size = Convert<uint64_t>(GetReg64(system, 3)); | 3560 | size = Convert<uint64_t>(GetArg64(args, 3)); |
| 3561 | 3561 | ||
| 3562 | ret = ReadDebugProcessMemory64(system, buffer, debug_handle, address, size); | 3562 | ret = ReadDebugProcessMemory64(system, buffer, debug_handle, address, size); |
| 3563 | 3563 | ||
| 3564 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3564 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3565 | } | 3565 | } |
| 3566 | 3566 | ||
| 3567 | static void SvcWrap_WriteDebugProcessMemory64(Core::System& system) { | 3567 | static void SvcWrap_WriteDebugProcessMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3568 | Result ret{}; | 3568 | Result ret{}; |
| 3569 | 3569 | ||
| 3570 | Handle debug_handle{}; | 3570 | Handle debug_handle{}; |
| @@ -3572,33 +3572,33 @@ static void SvcWrap_WriteDebugProcessMemory64(Core::System& system) { | |||
| 3572 | uint64_t address{}; | 3572 | uint64_t address{}; |
| 3573 | uint64_t size{}; | 3573 | uint64_t size{}; |
| 3574 | 3574 | ||
| 3575 | debug_handle = Convert<Handle>(GetReg64(system, 0)); | 3575 | debug_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3576 | buffer = Convert<uint64_t>(GetReg64(system, 1)); | 3576 | buffer = Convert<uint64_t>(GetArg64(args, 1)); |
| 3577 | address = Convert<uint64_t>(GetReg64(system, 2)); | 3577 | address = Convert<uint64_t>(GetArg64(args, 2)); |
| 3578 | size = Convert<uint64_t>(GetReg64(system, 3)); | 3578 | size = Convert<uint64_t>(GetArg64(args, 3)); |
| 3579 | 3579 | ||
| 3580 | ret = WriteDebugProcessMemory64(system, debug_handle, buffer, address, size); | 3580 | ret = WriteDebugProcessMemory64(system, debug_handle, buffer, address, size); |
| 3581 | 3581 | ||
| 3582 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3582 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3583 | } | 3583 | } |
| 3584 | 3584 | ||
| 3585 | static void SvcWrap_SetHardwareBreakPoint64(Core::System& system) { | 3585 | static void SvcWrap_SetHardwareBreakPoint64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3586 | Result ret{}; | 3586 | Result ret{}; |
| 3587 | 3587 | ||
| 3588 | HardwareBreakPointRegisterName name{}; | 3588 | HardwareBreakPointRegisterName name{}; |
| 3589 | uint64_t flags{}; | 3589 | uint64_t flags{}; |
| 3590 | uint64_t value{}; | 3590 | uint64_t value{}; |
| 3591 | 3591 | ||
| 3592 | name = Convert<HardwareBreakPointRegisterName>(GetReg64(system, 0)); | 3592 | name = Convert<HardwareBreakPointRegisterName>(GetArg64(args, 0)); |
| 3593 | flags = Convert<uint64_t>(GetReg64(system, 1)); | 3593 | flags = Convert<uint64_t>(GetArg64(args, 1)); |
| 3594 | value = Convert<uint64_t>(GetReg64(system, 2)); | 3594 | value = Convert<uint64_t>(GetArg64(args, 2)); |
| 3595 | 3595 | ||
| 3596 | ret = SetHardwareBreakPoint64(system, name, flags, value); | 3596 | ret = SetHardwareBreakPoint64(system, name, flags, value); |
| 3597 | 3597 | ||
| 3598 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3598 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3599 | } | 3599 | } |
| 3600 | 3600 | ||
| 3601 | static void SvcWrap_GetDebugThreadParam64(Core::System& system) { | 3601 | static void SvcWrap_GetDebugThreadParam64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3602 | Result ret{}; | 3602 | Result ret{}; |
| 3603 | 3603 | ||
| 3604 | uint64_t out_64{}; | 3604 | uint64_t out_64{}; |
| @@ -3607,18 +3607,18 @@ static void SvcWrap_GetDebugThreadParam64(Core::System& system) { | |||
| 3607 | uint64_t thread_id{}; | 3607 | uint64_t thread_id{}; |
| 3608 | DebugThreadParam param{}; | 3608 | DebugThreadParam param{}; |
| 3609 | 3609 | ||
| 3610 | debug_handle = Convert<Handle>(GetReg64(system, 2)); | 3610 | debug_handle = Convert<Handle>(GetArg64(args, 2)); |
| 3611 | thread_id = Convert<uint64_t>(GetReg64(system, 3)); | 3611 | thread_id = Convert<uint64_t>(GetArg64(args, 3)); |
| 3612 | param = Convert<DebugThreadParam>(GetReg64(system, 4)); | 3612 | param = Convert<DebugThreadParam>(GetArg64(args, 4)); |
| 3613 | 3613 | ||
| 3614 | ret = GetDebugThreadParam64(system, std::addressof(out_64), std::addressof(out_32), debug_handle, thread_id, param); | 3614 | ret = GetDebugThreadParam64(system, std::addressof(out_64), std::addressof(out_32), debug_handle, thread_id, param); |
| 3615 | 3615 | ||
| 3616 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3616 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3617 | SetReg64(system, 1, Convert<uint64_t>(out_64)); | 3617 | SetArg64(args, 1, Convert<uint64_t>(out_64)); |
| 3618 | SetReg64(system, 2, Convert<uint64_t>(out_32)); | 3618 | SetArg64(args, 2, Convert<uint64_t>(out_32)); |
| 3619 | } | 3619 | } |
| 3620 | 3620 | ||
| 3621 | static void SvcWrap_GetSystemInfo64(Core::System& system) { | 3621 | static void SvcWrap_GetSystemInfo64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3622 | Result ret{}; | 3622 | Result ret{}; |
| 3623 | 3623 | ||
| 3624 | uint64_t out{}; | 3624 | uint64_t out{}; |
| @@ -3626,17 +3626,17 @@ static void SvcWrap_GetSystemInfo64(Core::System& system) { | |||
| 3626 | Handle handle{}; | 3626 | Handle handle{}; |
| 3627 | uint64_t info_subtype{}; | 3627 | uint64_t info_subtype{}; |
| 3628 | 3628 | ||
| 3629 | info_type = Convert<SystemInfoType>(GetReg64(system, 1)); | 3629 | info_type = Convert<SystemInfoType>(GetArg64(args, 1)); |
| 3630 | handle = Convert<Handle>(GetReg64(system, 2)); | 3630 | handle = Convert<Handle>(GetArg64(args, 2)); |
| 3631 | info_subtype = Convert<uint64_t>(GetReg64(system, 3)); | 3631 | info_subtype = Convert<uint64_t>(GetArg64(args, 3)); |
| 3632 | 3632 | ||
| 3633 | ret = GetSystemInfo64(system, std::addressof(out), info_type, handle, info_subtype); | 3633 | ret = GetSystemInfo64(system, std::addressof(out), info_type, handle, info_subtype); |
| 3634 | 3634 | ||
| 3635 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3635 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3636 | SetReg64(system, 1, Convert<uint64_t>(out)); | 3636 | SetArg64(args, 1, Convert<uint64_t>(out)); |
| 3637 | } | 3637 | } |
| 3638 | 3638 | ||
| 3639 | static void SvcWrap_CreatePort64(Core::System& system) { | 3639 | static void SvcWrap_CreatePort64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3640 | Result ret{}; | 3640 | Result ret{}; |
| 3641 | 3641 | ||
| 3642 | Handle out_server_handle{}; | 3642 | Handle out_server_handle{}; |
| @@ -3645,48 +3645,48 @@ static void SvcWrap_CreatePort64(Core::System& system) { | |||
| 3645 | bool is_light{}; | 3645 | bool is_light{}; |
| 3646 | uint64_t name{}; | 3646 | uint64_t name{}; |
| 3647 | 3647 | ||
| 3648 | max_sessions = Convert<int32_t>(GetReg64(system, 2)); | 3648 | max_sessions = Convert<int32_t>(GetArg64(args, 2)); |
| 3649 | is_light = Convert<bool>(GetReg64(system, 3)); | 3649 | is_light = Convert<bool>(GetArg64(args, 3)); |
| 3650 | name = Convert<uint64_t>(GetReg64(system, 4)); | 3650 | name = Convert<uint64_t>(GetArg64(args, 4)); |
| 3651 | 3651 | ||
| 3652 | ret = CreatePort64(system, std::addressof(out_server_handle), std::addressof(out_client_handle), max_sessions, is_light, name); | 3652 | ret = CreatePort64(system, std::addressof(out_server_handle), std::addressof(out_client_handle), max_sessions, is_light, name); |
| 3653 | 3653 | ||
| 3654 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3654 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3655 | SetReg64(system, 1, Convert<uint64_t>(out_server_handle)); | 3655 | SetArg64(args, 1, Convert<uint64_t>(out_server_handle)); |
| 3656 | SetReg64(system, 2, Convert<uint64_t>(out_client_handle)); | 3656 | SetArg64(args, 2, Convert<uint64_t>(out_client_handle)); |
| 3657 | } | 3657 | } |
| 3658 | 3658 | ||
| 3659 | static void SvcWrap_ManageNamedPort64(Core::System& system) { | 3659 | static void SvcWrap_ManageNamedPort64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3660 | Result ret{}; | 3660 | Result ret{}; |
| 3661 | 3661 | ||
| 3662 | Handle out_server_handle{}; | 3662 | Handle out_server_handle{}; |
| 3663 | uint64_t name{}; | 3663 | uint64_t name{}; |
| 3664 | int32_t max_sessions{}; | 3664 | int32_t max_sessions{}; |
| 3665 | 3665 | ||
| 3666 | name = Convert<uint64_t>(GetReg64(system, 1)); | 3666 | name = Convert<uint64_t>(GetArg64(args, 1)); |
| 3667 | max_sessions = Convert<int32_t>(GetReg64(system, 2)); | 3667 | max_sessions = Convert<int32_t>(GetArg64(args, 2)); |
| 3668 | 3668 | ||
| 3669 | ret = ManageNamedPort64(system, std::addressof(out_server_handle), name, max_sessions); | 3669 | ret = ManageNamedPort64(system, std::addressof(out_server_handle), name, max_sessions); |
| 3670 | 3670 | ||
| 3671 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3671 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3672 | SetReg64(system, 1, Convert<uint64_t>(out_server_handle)); | 3672 | SetArg64(args, 1, Convert<uint64_t>(out_server_handle)); |
| 3673 | } | 3673 | } |
| 3674 | 3674 | ||
| 3675 | static void SvcWrap_ConnectToPort64(Core::System& system) { | 3675 | static void SvcWrap_ConnectToPort64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3676 | Result ret{}; | 3676 | Result ret{}; |
| 3677 | 3677 | ||
| 3678 | Handle out_handle{}; | 3678 | Handle out_handle{}; |
| 3679 | Handle port{}; | 3679 | Handle port{}; |
| 3680 | 3680 | ||
| 3681 | port = Convert<Handle>(GetReg64(system, 1)); | 3681 | port = Convert<Handle>(GetArg64(args, 1)); |
| 3682 | 3682 | ||
| 3683 | ret = ConnectToPort64(system, std::addressof(out_handle), port); | 3683 | ret = ConnectToPort64(system, std::addressof(out_handle), port); |
| 3684 | 3684 | ||
| 3685 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3685 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3686 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 3686 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 3687 | } | 3687 | } |
| 3688 | 3688 | ||
| 3689 | static void SvcWrap_SetProcessMemoryPermission64(Core::System& system) { | 3689 | static void SvcWrap_SetProcessMemoryPermission64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3690 | Result ret{}; | 3690 | Result ret{}; |
| 3691 | 3691 | ||
| 3692 | Handle process_handle{}; | 3692 | Handle process_handle{}; |
| @@ -3694,17 +3694,17 @@ static void SvcWrap_SetProcessMemoryPermission64(Core::System& system) { | |||
| 3694 | uint64_t size{}; | 3694 | uint64_t size{}; |
| 3695 | MemoryPermission perm{}; | 3695 | MemoryPermission perm{}; |
| 3696 | 3696 | ||
| 3697 | process_handle = Convert<Handle>(GetReg64(system, 0)); | 3697 | process_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3698 | address = Convert<uint64_t>(GetReg64(system, 1)); | 3698 | address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3699 | size = Convert<uint64_t>(GetReg64(system, 2)); | 3699 | size = Convert<uint64_t>(GetArg64(args, 2)); |
| 3700 | perm = Convert<MemoryPermission>(GetReg64(system, 3)); | 3700 | perm = Convert<MemoryPermission>(GetArg64(args, 3)); |
| 3701 | 3701 | ||
| 3702 | ret = SetProcessMemoryPermission64(system, process_handle, address, size, perm); | 3702 | ret = SetProcessMemoryPermission64(system, process_handle, address, size, perm); |
| 3703 | 3703 | ||
| 3704 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3704 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3705 | } | 3705 | } |
| 3706 | 3706 | ||
| 3707 | static void SvcWrap_MapProcessMemory64(Core::System& system) { | 3707 | static void SvcWrap_MapProcessMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3708 | Result ret{}; | 3708 | Result ret{}; |
| 3709 | 3709 | ||
| 3710 | uint64_t dst_address{}; | 3710 | uint64_t dst_address{}; |
| @@ -3712,17 +3712,17 @@ static void SvcWrap_MapProcessMemory64(Core::System& system) { | |||
| 3712 | uint64_t src_address{}; | 3712 | uint64_t src_address{}; |
| 3713 | uint64_t size{}; | 3713 | uint64_t size{}; |
| 3714 | 3714 | ||
| 3715 | dst_address = Convert<uint64_t>(GetReg64(system, 0)); | 3715 | dst_address = Convert<uint64_t>(GetArg64(args, 0)); |
| 3716 | process_handle = Convert<Handle>(GetReg64(system, 1)); | 3716 | process_handle = Convert<Handle>(GetArg64(args, 1)); |
| 3717 | src_address = Convert<uint64_t>(GetReg64(system, 2)); | 3717 | src_address = Convert<uint64_t>(GetArg64(args, 2)); |
| 3718 | size = Convert<uint64_t>(GetReg64(system, 3)); | 3718 | size = Convert<uint64_t>(GetArg64(args, 3)); |
| 3719 | 3719 | ||
| 3720 | ret = MapProcessMemory64(system, dst_address, process_handle, src_address, size); | 3720 | ret = MapProcessMemory64(system, dst_address, process_handle, src_address, size); |
| 3721 | 3721 | ||
| 3722 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3722 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3723 | } | 3723 | } |
| 3724 | 3724 | ||
| 3725 | static void SvcWrap_UnmapProcessMemory64(Core::System& system) { | 3725 | static void SvcWrap_UnmapProcessMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3726 | Result ret{}; | 3726 | Result ret{}; |
| 3727 | 3727 | ||
| 3728 | uint64_t dst_address{}; | 3728 | uint64_t dst_address{}; |
| @@ -3730,17 +3730,17 @@ static void SvcWrap_UnmapProcessMemory64(Core::System& system) { | |||
| 3730 | uint64_t src_address{}; | 3730 | uint64_t src_address{}; |
| 3731 | uint64_t size{}; | 3731 | uint64_t size{}; |
| 3732 | 3732 | ||
| 3733 | dst_address = Convert<uint64_t>(GetReg64(system, 0)); | 3733 | dst_address = Convert<uint64_t>(GetArg64(args, 0)); |
| 3734 | process_handle = Convert<Handle>(GetReg64(system, 1)); | 3734 | process_handle = Convert<Handle>(GetArg64(args, 1)); |
| 3735 | src_address = Convert<uint64_t>(GetReg64(system, 2)); | 3735 | src_address = Convert<uint64_t>(GetArg64(args, 2)); |
| 3736 | size = Convert<uint64_t>(GetReg64(system, 3)); | 3736 | size = Convert<uint64_t>(GetArg64(args, 3)); |
| 3737 | 3737 | ||
| 3738 | ret = UnmapProcessMemory64(system, dst_address, process_handle, src_address, size); | 3738 | ret = UnmapProcessMemory64(system, dst_address, process_handle, src_address, size); |
| 3739 | 3739 | ||
| 3740 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3740 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3741 | } | 3741 | } |
| 3742 | 3742 | ||
| 3743 | static void SvcWrap_QueryProcessMemory64(Core::System& system) { | 3743 | static void SvcWrap_QueryProcessMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3744 | Result ret{}; | 3744 | Result ret{}; |
| 3745 | 3745 | ||
| 3746 | PageInfo out_page_info{}; | 3746 | PageInfo out_page_info{}; |
| @@ -3748,17 +3748,17 @@ static void SvcWrap_QueryProcessMemory64(Core::System& system) { | |||
| 3748 | Handle process_handle{}; | 3748 | Handle process_handle{}; |
| 3749 | uint64_t address{}; | 3749 | uint64_t address{}; |
| 3750 | 3750 | ||
| 3751 | out_memory_info = Convert<uint64_t>(GetReg64(system, 0)); | 3751 | out_memory_info = Convert<uint64_t>(GetArg64(args, 0)); |
| 3752 | process_handle = Convert<Handle>(GetReg64(system, 2)); | 3752 | process_handle = Convert<Handle>(GetArg64(args, 2)); |
| 3753 | address = Convert<uint64_t>(GetReg64(system, 3)); | 3753 | address = Convert<uint64_t>(GetArg64(args, 3)); |
| 3754 | 3754 | ||
| 3755 | ret = QueryProcessMemory64(system, out_memory_info, std::addressof(out_page_info), process_handle, address); | 3755 | ret = QueryProcessMemory64(system, out_memory_info, std::addressof(out_page_info), process_handle, address); |
| 3756 | 3756 | ||
| 3757 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3757 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3758 | SetReg64(system, 1, Convert<uint64_t>(out_page_info)); | 3758 | SetArg64(args, 1, Convert<uint64_t>(out_page_info)); |
| 3759 | } | 3759 | } |
| 3760 | 3760 | ||
| 3761 | static void SvcWrap_MapProcessCodeMemory64(Core::System& system) { | 3761 | static void SvcWrap_MapProcessCodeMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3762 | Result ret{}; | 3762 | Result ret{}; |
| 3763 | 3763 | ||
| 3764 | Handle process_handle{}; | 3764 | Handle process_handle{}; |
| @@ -3766,17 +3766,17 @@ static void SvcWrap_MapProcessCodeMemory64(Core::System& system) { | |||
| 3766 | uint64_t src_address{}; | 3766 | uint64_t src_address{}; |
| 3767 | uint64_t size{}; | 3767 | uint64_t size{}; |
| 3768 | 3768 | ||
| 3769 | process_handle = Convert<Handle>(GetReg64(system, 0)); | 3769 | process_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3770 | dst_address = Convert<uint64_t>(GetReg64(system, 1)); | 3770 | dst_address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3771 | src_address = Convert<uint64_t>(GetReg64(system, 2)); | 3771 | src_address = Convert<uint64_t>(GetArg64(args, 2)); |
| 3772 | size = Convert<uint64_t>(GetReg64(system, 3)); | 3772 | size = Convert<uint64_t>(GetArg64(args, 3)); |
| 3773 | 3773 | ||
| 3774 | ret = MapProcessCodeMemory64(system, process_handle, dst_address, src_address, size); | 3774 | ret = MapProcessCodeMemory64(system, process_handle, dst_address, src_address, size); |
| 3775 | 3775 | ||
| 3776 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3776 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3777 | } | 3777 | } |
| 3778 | 3778 | ||
| 3779 | static void SvcWrap_UnmapProcessCodeMemory64(Core::System& system) { | 3779 | static void SvcWrap_UnmapProcessCodeMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3780 | Result ret{}; | 3780 | Result ret{}; |
| 3781 | 3781 | ||
| 3782 | Handle process_handle{}; | 3782 | Handle process_handle{}; |
| @@ -3784,17 +3784,17 @@ static void SvcWrap_UnmapProcessCodeMemory64(Core::System& system) { | |||
| 3784 | uint64_t src_address{}; | 3784 | uint64_t src_address{}; |
| 3785 | uint64_t size{}; | 3785 | uint64_t size{}; |
| 3786 | 3786 | ||
| 3787 | process_handle = Convert<Handle>(GetReg64(system, 0)); | 3787 | process_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3788 | dst_address = Convert<uint64_t>(GetReg64(system, 1)); | 3788 | dst_address = Convert<uint64_t>(GetArg64(args, 1)); |
| 3789 | src_address = Convert<uint64_t>(GetReg64(system, 2)); | 3789 | src_address = Convert<uint64_t>(GetArg64(args, 2)); |
| 3790 | size = Convert<uint64_t>(GetReg64(system, 3)); | 3790 | size = Convert<uint64_t>(GetArg64(args, 3)); |
| 3791 | 3791 | ||
| 3792 | ret = UnmapProcessCodeMemory64(system, process_handle, dst_address, src_address, size); | 3792 | ret = UnmapProcessCodeMemory64(system, process_handle, dst_address, src_address, size); |
| 3793 | 3793 | ||
| 3794 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3794 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3795 | } | 3795 | } |
| 3796 | 3796 | ||
| 3797 | static void SvcWrap_CreateProcess64(Core::System& system) { | 3797 | static void SvcWrap_CreateProcess64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3798 | Result ret{}; | 3798 | Result ret{}; |
| 3799 | 3799 | ||
| 3800 | Handle out_handle{}; | 3800 | Handle out_handle{}; |
| @@ -3802,17 +3802,17 @@ static void SvcWrap_CreateProcess64(Core::System& system) { | |||
| 3802 | uint64_t caps{}; | 3802 | uint64_t caps{}; |
| 3803 | int32_t num_caps{}; | 3803 | int32_t num_caps{}; |
| 3804 | 3804 | ||
| 3805 | parameters = Convert<uint64_t>(GetReg64(system, 1)); | 3805 | parameters = Convert<uint64_t>(GetArg64(args, 1)); |
| 3806 | caps = Convert<uint64_t>(GetReg64(system, 2)); | 3806 | caps = Convert<uint64_t>(GetArg64(args, 2)); |
| 3807 | num_caps = Convert<int32_t>(GetReg64(system, 3)); | 3807 | num_caps = Convert<int32_t>(GetArg64(args, 3)); |
| 3808 | 3808 | ||
| 3809 | ret = CreateProcess64(system, std::addressof(out_handle), parameters, caps, num_caps); | 3809 | ret = CreateProcess64(system, std::addressof(out_handle), parameters, caps, num_caps); |
| 3810 | 3810 | ||
| 3811 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3811 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3812 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 3812 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 3813 | } | 3813 | } |
| 3814 | 3814 | ||
| 3815 | static void SvcWrap_StartProcess64(Core::System& system) { | 3815 | static void SvcWrap_StartProcess64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3816 | Result ret{}; | 3816 | Result ret{}; |
| 3817 | 3817 | ||
| 3818 | Handle process_handle{}; | 3818 | Handle process_handle{}; |
| @@ -3820,601 +3820,601 @@ static void SvcWrap_StartProcess64(Core::System& system) { | |||
| 3820 | int32_t core_id{}; | 3820 | int32_t core_id{}; |
| 3821 | uint64_t main_thread_stack_size{}; | 3821 | uint64_t main_thread_stack_size{}; |
| 3822 | 3822 | ||
| 3823 | process_handle = Convert<Handle>(GetReg64(system, 0)); | 3823 | process_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3824 | priority = Convert<int32_t>(GetReg64(system, 1)); | 3824 | priority = Convert<int32_t>(GetArg64(args, 1)); |
| 3825 | core_id = Convert<int32_t>(GetReg64(system, 2)); | 3825 | core_id = Convert<int32_t>(GetArg64(args, 2)); |
| 3826 | main_thread_stack_size = Convert<uint64_t>(GetReg64(system, 3)); | 3826 | main_thread_stack_size = Convert<uint64_t>(GetArg64(args, 3)); |
| 3827 | 3827 | ||
| 3828 | ret = StartProcess64(system, process_handle, priority, core_id, main_thread_stack_size); | 3828 | ret = StartProcess64(system, process_handle, priority, core_id, main_thread_stack_size); |
| 3829 | 3829 | ||
| 3830 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3830 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3831 | } | 3831 | } |
| 3832 | 3832 | ||
| 3833 | static void SvcWrap_TerminateProcess64(Core::System& system) { | 3833 | static void SvcWrap_TerminateProcess64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3834 | Result ret{}; | 3834 | Result ret{}; |
| 3835 | 3835 | ||
| 3836 | Handle process_handle{}; | 3836 | Handle process_handle{}; |
| 3837 | 3837 | ||
| 3838 | process_handle = Convert<Handle>(GetReg64(system, 0)); | 3838 | process_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3839 | 3839 | ||
| 3840 | ret = TerminateProcess64(system, process_handle); | 3840 | ret = TerminateProcess64(system, process_handle); |
| 3841 | 3841 | ||
| 3842 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3842 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3843 | } | 3843 | } |
| 3844 | 3844 | ||
| 3845 | static void SvcWrap_GetProcessInfo64(Core::System& system) { | 3845 | static void SvcWrap_GetProcessInfo64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3846 | Result ret{}; | 3846 | Result ret{}; |
| 3847 | 3847 | ||
| 3848 | int64_t out_info{}; | 3848 | int64_t out_info{}; |
| 3849 | Handle process_handle{}; | 3849 | Handle process_handle{}; |
| 3850 | ProcessInfoType info_type{}; | 3850 | ProcessInfoType info_type{}; |
| 3851 | 3851 | ||
| 3852 | process_handle = Convert<Handle>(GetReg64(system, 1)); | 3852 | process_handle = Convert<Handle>(GetArg64(args, 1)); |
| 3853 | info_type = Convert<ProcessInfoType>(GetReg64(system, 2)); | 3853 | info_type = Convert<ProcessInfoType>(GetArg64(args, 2)); |
| 3854 | 3854 | ||
| 3855 | ret = GetProcessInfo64(system, std::addressof(out_info), process_handle, info_type); | 3855 | ret = GetProcessInfo64(system, std::addressof(out_info), process_handle, info_type); |
| 3856 | 3856 | ||
| 3857 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3857 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3858 | SetReg64(system, 1, Convert<uint64_t>(out_info)); | 3858 | SetArg64(args, 1, Convert<uint64_t>(out_info)); |
| 3859 | } | 3859 | } |
| 3860 | 3860 | ||
| 3861 | static void SvcWrap_CreateResourceLimit64(Core::System& system) { | 3861 | static void SvcWrap_CreateResourceLimit64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3862 | Result ret{}; | 3862 | Result ret{}; |
| 3863 | 3863 | ||
| 3864 | Handle out_handle{}; | 3864 | Handle out_handle{}; |
| 3865 | 3865 | ||
| 3866 | ret = CreateResourceLimit64(system, std::addressof(out_handle)); | 3866 | ret = CreateResourceLimit64(system, std::addressof(out_handle)); |
| 3867 | 3867 | ||
| 3868 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3868 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3869 | SetReg64(system, 1, Convert<uint64_t>(out_handle)); | 3869 | SetArg64(args, 1, Convert<uint64_t>(out_handle)); |
| 3870 | } | 3870 | } |
| 3871 | 3871 | ||
| 3872 | static void SvcWrap_SetResourceLimitLimitValue64(Core::System& system) { | 3872 | static void SvcWrap_SetResourceLimitLimitValue64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3873 | Result ret{}; | 3873 | Result ret{}; |
| 3874 | 3874 | ||
| 3875 | Handle resource_limit_handle{}; | 3875 | Handle resource_limit_handle{}; |
| 3876 | LimitableResource which{}; | 3876 | LimitableResource which{}; |
| 3877 | int64_t limit_value{}; | 3877 | int64_t limit_value{}; |
| 3878 | 3878 | ||
| 3879 | resource_limit_handle = Convert<Handle>(GetReg64(system, 0)); | 3879 | resource_limit_handle = Convert<Handle>(GetArg64(args, 0)); |
| 3880 | which = Convert<LimitableResource>(GetReg64(system, 1)); | 3880 | which = Convert<LimitableResource>(GetArg64(args, 1)); |
| 3881 | limit_value = Convert<int64_t>(GetReg64(system, 2)); | 3881 | limit_value = Convert<int64_t>(GetArg64(args, 2)); |
| 3882 | 3882 | ||
| 3883 | ret = SetResourceLimitLimitValue64(system, resource_limit_handle, which, limit_value); | 3883 | ret = SetResourceLimitLimitValue64(system, resource_limit_handle, which, limit_value); |
| 3884 | 3884 | ||
| 3885 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3885 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3886 | } | 3886 | } |
| 3887 | 3887 | ||
| 3888 | static void SvcWrap_MapInsecureMemory64(Core::System& system) { | 3888 | static void SvcWrap_MapInsecureMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3889 | Result ret{}; | 3889 | Result ret{}; |
| 3890 | 3890 | ||
| 3891 | uint64_t address{}; | 3891 | uint64_t address{}; |
| 3892 | uint64_t size{}; | 3892 | uint64_t size{}; |
| 3893 | 3893 | ||
| 3894 | address = Convert<uint64_t>(GetReg64(system, 0)); | 3894 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 3895 | size = Convert<uint64_t>(GetReg64(system, 1)); | 3895 | size = Convert<uint64_t>(GetArg64(args, 1)); |
| 3896 | 3896 | ||
| 3897 | ret = MapInsecureMemory64(system, address, size); | 3897 | ret = MapInsecureMemory64(system, address, size); |
| 3898 | 3898 | ||
| 3899 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3899 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3900 | } | 3900 | } |
| 3901 | 3901 | ||
| 3902 | static void SvcWrap_UnmapInsecureMemory64(Core::System& system) { | 3902 | static void SvcWrap_UnmapInsecureMemory64(Core::System& system, std::span<uint64_t, 8> args) { |
| 3903 | Result ret{}; | 3903 | Result ret{}; |
| 3904 | 3904 | ||
| 3905 | uint64_t address{}; | 3905 | uint64_t address{}; |
| 3906 | uint64_t size{}; | 3906 | uint64_t size{}; |
| 3907 | 3907 | ||
| 3908 | address = Convert<uint64_t>(GetReg64(system, 0)); | 3908 | address = Convert<uint64_t>(GetArg64(args, 0)); |
| 3909 | size = Convert<uint64_t>(GetReg64(system, 1)); | 3909 | size = Convert<uint64_t>(GetArg64(args, 1)); |
| 3910 | 3910 | ||
| 3911 | ret = UnmapInsecureMemory64(system, address, size); | 3911 | ret = UnmapInsecureMemory64(system, address, size); |
| 3912 | 3912 | ||
| 3913 | SetReg64(system, 0, Convert<uint64_t>(ret)); | 3913 | SetArg64(args, 0, Convert<uint64_t>(ret)); |
| 3914 | } | 3914 | } |
| 3915 | 3915 | ||
| 3916 | static void Call32(Core::System& system, u32 imm) { | 3916 | static void Call32(Core::System& system, u32 imm, std::span<uint64_t, 8> args) { |
| 3917 | switch (static_cast<SvcId>(imm)) { | 3917 | switch (static_cast<SvcId>(imm)) { |
| 3918 | case SvcId::SetHeapSize: | 3918 | case SvcId::SetHeapSize: |
| 3919 | return SvcWrap_SetHeapSize64From32(system); | 3919 | return SvcWrap_SetHeapSize64From32(system, args); |
| 3920 | case SvcId::SetMemoryPermission: | 3920 | case SvcId::SetMemoryPermission: |
| 3921 | return SvcWrap_SetMemoryPermission64From32(system); | 3921 | return SvcWrap_SetMemoryPermission64From32(system, args); |
| 3922 | case SvcId::SetMemoryAttribute: | 3922 | case SvcId::SetMemoryAttribute: |
| 3923 | return SvcWrap_SetMemoryAttribute64From32(system); | 3923 | return SvcWrap_SetMemoryAttribute64From32(system, args); |
| 3924 | case SvcId::MapMemory: | 3924 | case SvcId::MapMemory: |
| 3925 | return SvcWrap_MapMemory64From32(system); | 3925 | return SvcWrap_MapMemory64From32(system, args); |
| 3926 | case SvcId::UnmapMemory: | 3926 | case SvcId::UnmapMemory: |
| 3927 | return SvcWrap_UnmapMemory64From32(system); | 3927 | return SvcWrap_UnmapMemory64From32(system, args); |
| 3928 | case SvcId::QueryMemory: | 3928 | case SvcId::QueryMemory: |
| 3929 | return SvcWrap_QueryMemory64From32(system); | 3929 | return SvcWrap_QueryMemory64From32(system, args); |
| 3930 | case SvcId::ExitProcess: | 3930 | case SvcId::ExitProcess: |
| 3931 | return SvcWrap_ExitProcess64From32(system); | 3931 | return SvcWrap_ExitProcess64From32(system, args); |
| 3932 | case SvcId::CreateThread: | 3932 | case SvcId::CreateThread: |
| 3933 | return SvcWrap_CreateThread64From32(system); | 3933 | return SvcWrap_CreateThread64From32(system, args); |
| 3934 | case SvcId::StartThread: | 3934 | case SvcId::StartThread: |
| 3935 | return SvcWrap_StartThread64From32(system); | 3935 | return SvcWrap_StartThread64From32(system, args); |
| 3936 | case SvcId::ExitThread: | 3936 | case SvcId::ExitThread: |
| 3937 | return SvcWrap_ExitThread64From32(system); | 3937 | return SvcWrap_ExitThread64From32(system, args); |
| 3938 | case SvcId::SleepThread: | 3938 | case SvcId::SleepThread: |
| 3939 | return SvcWrap_SleepThread64From32(system); | 3939 | return SvcWrap_SleepThread64From32(system, args); |
| 3940 | case SvcId::GetThreadPriority: | 3940 | case SvcId::GetThreadPriority: |
| 3941 | return SvcWrap_GetThreadPriority64From32(system); | 3941 | return SvcWrap_GetThreadPriority64From32(system, args); |
| 3942 | case SvcId::SetThreadPriority: | 3942 | case SvcId::SetThreadPriority: |
| 3943 | return SvcWrap_SetThreadPriority64From32(system); | 3943 | return SvcWrap_SetThreadPriority64From32(system, args); |
| 3944 | case SvcId::GetThreadCoreMask: | 3944 | case SvcId::GetThreadCoreMask: |
| 3945 | return SvcWrap_GetThreadCoreMask64From32(system); | 3945 | return SvcWrap_GetThreadCoreMask64From32(system, args); |
| 3946 | case SvcId::SetThreadCoreMask: | 3946 | case SvcId::SetThreadCoreMask: |
| 3947 | return SvcWrap_SetThreadCoreMask64From32(system); | 3947 | return SvcWrap_SetThreadCoreMask64From32(system, args); |
| 3948 | case SvcId::GetCurrentProcessorNumber: | 3948 | case SvcId::GetCurrentProcessorNumber: |
| 3949 | return SvcWrap_GetCurrentProcessorNumber64From32(system); | 3949 | return SvcWrap_GetCurrentProcessorNumber64From32(system, args); |
| 3950 | case SvcId::SignalEvent: | 3950 | case SvcId::SignalEvent: |
| 3951 | return SvcWrap_SignalEvent64From32(system); | 3951 | return SvcWrap_SignalEvent64From32(system, args); |
| 3952 | case SvcId::ClearEvent: | 3952 | case SvcId::ClearEvent: |
| 3953 | return SvcWrap_ClearEvent64From32(system); | 3953 | return SvcWrap_ClearEvent64From32(system, args); |
| 3954 | case SvcId::MapSharedMemory: | 3954 | case SvcId::MapSharedMemory: |
| 3955 | return SvcWrap_MapSharedMemory64From32(system); | 3955 | return SvcWrap_MapSharedMemory64From32(system, args); |
| 3956 | case SvcId::UnmapSharedMemory: | 3956 | case SvcId::UnmapSharedMemory: |
| 3957 | return SvcWrap_UnmapSharedMemory64From32(system); | 3957 | return SvcWrap_UnmapSharedMemory64From32(system, args); |
| 3958 | case SvcId::CreateTransferMemory: | 3958 | case SvcId::CreateTransferMemory: |
| 3959 | return SvcWrap_CreateTransferMemory64From32(system); | 3959 | return SvcWrap_CreateTransferMemory64From32(system, args); |
| 3960 | case SvcId::CloseHandle: | 3960 | case SvcId::CloseHandle: |
| 3961 | return SvcWrap_CloseHandle64From32(system); | 3961 | return SvcWrap_CloseHandle64From32(system, args); |
| 3962 | case SvcId::ResetSignal: | 3962 | case SvcId::ResetSignal: |
| 3963 | return SvcWrap_ResetSignal64From32(system); | 3963 | return SvcWrap_ResetSignal64From32(system, args); |
| 3964 | case SvcId::WaitSynchronization: | 3964 | case SvcId::WaitSynchronization: |
| 3965 | return SvcWrap_WaitSynchronization64From32(system); | 3965 | return SvcWrap_WaitSynchronization64From32(system, args); |
| 3966 | case SvcId::CancelSynchronization: | 3966 | case SvcId::CancelSynchronization: |
| 3967 | return SvcWrap_CancelSynchronization64From32(system); | 3967 | return SvcWrap_CancelSynchronization64From32(system, args); |
| 3968 | case SvcId::ArbitrateLock: | 3968 | case SvcId::ArbitrateLock: |
| 3969 | return SvcWrap_ArbitrateLock64From32(system); | 3969 | return SvcWrap_ArbitrateLock64From32(system, args); |
| 3970 | case SvcId::ArbitrateUnlock: | 3970 | case SvcId::ArbitrateUnlock: |
| 3971 | return SvcWrap_ArbitrateUnlock64From32(system); | 3971 | return SvcWrap_ArbitrateUnlock64From32(system, args); |
| 3972 | case SvcId::WaitProcessWideKeyAtomic: | 3972 | case SvcId::WaitProcessWideKeyAtomic: |
| 3973 | return SvcWrap_WaitProcessWideKeyAtomic64From32(system); | 3973 | return SvcWrap_WaitProcessWideKeyAtomic64From32(system, args); |
| 3974 | case SvcId::SignalProcessWideKey: | 3974 | case SvcId::SignalProcessWideKey: |
| 3975 | return SvcWrap_SignalProcessWideKey64From32(system); | 3975 | return SvcWrap_SignalProcessWideKey64From32(system, args); |
| 3976 | case SvcId::GetSystemTick: | 3976 | case SvcId::GetSystemTick: |
| 3977 | return SvcWrap_GetSystemTick64From32(system); | 3977 | return SvcWrap_GetSystemTick64From32(system, args); |
| 3978 | case SvcId::ConnectToNamedPort: | 3978 | case SvcId::ConnectToNamedPort: |
| 3979 | return SvcWrap_ConnectToNamedPort64From32(system); | 3979 | return SvcWrap_ConnectToNamedPort64From32(system, args); |
| 3980 | case SvcId::SendSyncRequestLight: | 3980 | case SvcId::SendSyncRequestLight: |
| 3981 | return SvcWrap_SendSyncRequestLight64From32(system); | 3981 | return SvcWrap_SendSyncRequestLight64From32(system, args); |
| 3982 | case SvcId::SendSyncRequest: | 3982 | case SvcId::SendSyncRequest: |
| 3983 | return SvcWrap_SendSyncRequest64From32(system); | 3983 | return SvcWrap_SendSyncRequest64From32(system, args); |
| 3984 | case SvcId::SendSyncRequestWithUserBuffer: | 3984 | case SvcId::SendSyncRequestWithUserBuffer: |
| 3985 | return SvcWrap_SendSyncRequestWithUserBuffer64From32(system); | 3985 | return SvcWrap_SendSyncRequestWithUserBuffer64From32(system, args); |
| 3986 | case SvcId::SendAsyncRequestWithUserBuffer: | 3986 | case SvcId::SendAsyncRequestWithUserBuffer: |
| 3987 | return SvcWrap_SendAsyncRequestWithUserBuffer64From32(system); | 3987 | return SvcWrap_SendAsyncRequestWithUserBuffer64From32(system, args); |
| 3988 | case SvcId::GetProcessId: | 3988 | case SvcId::GetProcessId: |
| 3989 | return SvcWrap_GetProcessId64From32(system); | 3989 | return SvcWrap_GetProcessId64From32(system, args); |
| 3990 | case SvcId::GetThreadId: | 3990 | case SvcId::GetThreadId: |
| 3991 | return SvcWrap_GetThreadId64From32(system); | 3991 | return SvcWrap_GetThreadId64From32(system, args); |
| 3992 | case SvcId::Break: | 3992 | case SvcId::Break: |
| 3993 | return SvcWrap_Break64From32(system); | 3993 | return SvcWrap_Break64From32(system, args); |
| 3994 | case SvcId::OutputDebugString: | 3994 | case SvcId::OutputDebugString: |
| 3995 | return SvcWrap_OutputDebugString64From32(system); | 3995 | return SvcWrap_OutputDebugString64From32(system, args); |
| 3996 | case SvcId::ReturnFromException: | 3996 | case SvcId::ReturnFromException: |
| 3997 | return SvcWrap_ReturnFromException64From32(system); | 3997 | return SvcWrap_ReturnFromException64From32(system, args); |
| 3998 | case SvcId::GetInfo: | 3998 | case SvcId::GetInfo: |
| 3999 | return SvcWrap_GetInfo64From32(system); | 3999 | return SvcWrap_GetInfo64From32(system, args); |
| 4000 | case SvcId::FlushEntireDataCache: | 4000 | case SvcId::FlushEntireDataCache: |
| 4001 | return SvcWrap_FlushEntireDataCache64From32(system); | 4001 | return SvcWrap_FlushEntireDataCache64From32(system, args); |
| 4002 | case SvcId::FlushDataCache: | 4002 | case SvcId::FlushDataCache: |
| 4003 | return SvcWrap_FlushDataCache64From32(system); | 4003 | return SvcWrap_FlushDataCache64From32(system, args); |
| 4004 | case SvcId::MapPhysicalMemory: | 4004 | case SvcId::MapPhysicalMemory: |
| 4005 | return SvcWrap_MapPhysicalMemory64From32(system); | 4005 | return SvcWrap_MapPhysicalMemory64From32(system, args); |
| 4006 | case SvcId::UnmapPhysicalMemory: | 4006 | case SvcId::UnmapPhysicalMemory: |
| 4007 | return SvcWrap_UnmapPhysicalMemory64From32(system); | 4007 | return SvcWrap_UnmapPhysicalMemory64From32(system, args); |
| 4008 | case SvcId::GetDebugFutureThreadInfo: | 4008 | case SvcId::GetDebugFutureThreadInfo: |
| 4009 | return SvcWrap_GetDebugFutureThreadInfo64From32(system); | 4009 | return SvcWrap_GetDebugFutureThreadInfo64From32(system, args); |
| 4010 | case SvcId::GetLastThreadInfo: | 4010 | case SvcId::GetLastThreadInfo: |
| 4011 | return SvcWrap_GetLastThreadInfo64From32(system); | 4011 | return SvcWrap_GetLastThreadInfo64From32(system, args); |
| 4012 | case SvcId::GetResourceLimitLimitValue: | 4012 | case SvcId::GetResourceLimitLimitValue: |
| 4013 | return SvcWrap_GetResourceLimitLimitValue64From32(system); | 4013 | return SvcWrap_GetResourceLimitLimitValue64From32(system, args); |
| 4014 | case SvcId::GetResourceLimitCurrentValue: | 4014 | case SvcId::GetResourceLimitCurrentValue: |
| 4015 | return SvcWrap_GetResourceLimitCurrentValue64From32(system); | 4015 | return SvcWrap_GetResourceLimitCurrentValue64From32(system, args); |
| 4016 | case SvcId::SetThreadActivity: | 4016 | case SvcId::SetThreadActivity: |
| 4017 | return SvcWrap_SetThreadActivity64From32(system); | 4017 | return SvcWrap_SetThreadActivity64From32(system, args); |
| 4018 | case SvcId::GetThreadContext3: | 4018 | case SvcId::GetThreadContext3: |
| 4019 | return SvcWrap_GetThreadContext364From32(system); | 4019 | return SvcWrap_GetThreadContext364From32(system, args); |
| 4020 | case SvcId::WaitForAddress: | 4020 | case SvcId::WaitForAddress: |
| 4021 | return SvcWrap_WaitForAddress64From32(system); | 4021 | return SvcWrap_WaitForAddress64From32(system, args); |
| 4022 | case SvcId::SignalToAddress: | 4022 | case SvcId::SignalToAddress: |
| 4023 | return SvcWrap_SignalToAddress64From32(system); | 4023 | return SvcWrap_SignalToAddress64From32(system, args); |
| 4024 | case SvcId::SynchronizePreemptionState: | 4024 | case SvcId::SynchronizePreemptionState: |
| 4025 | return SvcWrap_SynchronizePreemptionState64From32(system); | 4025 | return SvcWrap_SynchronizePreemptionState64From32(system, args); |
| 4026 | case SvcId::GetResourceLimitPeakValue: | 4026 | case SvcId::GetResourceLimitPeakValue: |
| 4027 | return SvcWrap_GetResourceLimitPeakValue64From32(system); | 4027 | return SvcWrap_GetResourceLimitPeakValue64From32(system, args); |
| 4028 | case SvcId::CreateIoPool: | 4028 | case SvcId::CreateIoPool: |
| 4029 | return SvcWrap_CreateIoPool64From32(system); | 4029 | return SvcWrap_CreateIoPool64From32(system, args); |
| 4030 | case SvcId::CreateIoRegion: | 4030 | case SvcId::CreateIoRegion: |
| 4031 | return SvcWrap_CreateIoRegion64From32(system); | 4031 | return SvcWrap_CreateIoRegion64From32(system, args); |
| 4032 | case SvcId::KernelDebug: | 4032 | case SvcId::KernelDebug: |
| 4033 | return SvcWrap_KernelDebug64From32(system); | 4033 | return SvcWrap_KernelDebug64From32(system, args); |
| 4034 | case SvcId::ChangeKernelTraceState: | 4034 | case SvcId::ChangeKernelTraceState: |
| 4035 | return SvcWrap_ChangeKernelTraceState64From32(system); | 4035 | return SvcWrap_ChangeKernelTraceState64From32(system, args); |
| 4036 | case SvcId::CreateSession: | 4036 | case SvcId::CreateSession: |
| 4037 | return SvcWrap_CreateSession64From32(system); | 4037 | return SvcWrap_CreateSession64From32(system, args); |
| 4038 | case SvcId::AcceptSession: | 4038 | case SvcId::AcceptSession: |
| 4039 | return SvcWrap_AcceptSession64From32(system); | 4039 | return SvcWrap_AcceptSession64From32(system, args); |
| 4040 | case SvcId::ReplyAndReceiveLight: | 4040 | case SvcId::ReplyAndReceiveLight: |
| 4041 | return SvcWrap_ReplyAndReceiveLight64From32(system); | 4041 | return SvcWrap_ReplyAndReceiveLight64From32(system, args); |
| 4042 | case SvcId::ReplyAndReceive: | 4042 | case SvcId::ReplyAndReceive: |
| 4043 | return SvcWrap_ReplyAndReceive64From32(system); | 4043 | return SvcWrap_ReplyAndReceive64From32(system, args); |
| 4044 | case SvcId::ReplyAndReceiveWithUserBuffer: | 4044 | case SvcId::ReplyAndReceiveWithUserBuffer: |
| 4045 | return SvcWrap_ReplyAndReceiveWithUserBuffer64From32(system); | 4045 | return SvcWrap_ReplyAndReceiveWithUserBuffer64From32(system, args); |
| 4046 | case SvcId::CreateEvent: | 4046 | case SvcId::CreateEvent: |
| 4047 | return SvcWrap_CreateEvent64From32(system); | 4047 | return SvcWrap_CreateEvent64From32(system, args); |
| 4048 | case SvcId::MapIoRegion: | 4048 | case SvcId::MapIoRegion: |
| 4049 | return SvcWrap_MapIoRegion64From32(system); | 4049 | return SvcWrap_MapIoRegion64From32(system, args); |
| 4050 | case SvcId::UnmapIoRegion: | 4050 | case SvcId::UnmapIoRegion: |
| 4051 | return SvcWrap_UnmapIoRegion64From32(system); | 4051 | return SvcWrap_UnmapIoRegion64From32(system, args); |
| 4052 | case SvcId::MapPhysicalMemoryUnsafe: | 4052 | case SvcId::MapPhysicalMemoryUnsafe: |
| 4053 | return SvcWrap_MapPhysicalMemoryUnsafe64From32(system); | 4053 | return SvcWrap_MapPhysicalMemoryUnsafe64From32(system, args); |
| 4054 | case SvcId::UnmapPhysicalMemoryUnsafe: | 4054 | case SvcId::UnmapPhysicalMemoryUnsafe: |
| 4055 | return SvcWrap_UnmapPhysicalMemoryUnsafe64From32(system); | 4055 | return SvcWrap_UnmapPhysicalMemoryUnsafe64From32(system, args); |
| 4056 | case SvcId::SetUnsafeLimit: | 4056 | case SvcId::SetUnsafeLimit: |
| 4057 | return SvcWrap_SetUnsafeLimit64From32(system); | 4057 | return SvcWrap_SetUnsafeLimit64From32(system, args); |
| 4058 | case SvcId::CreateCodeMemory: | 4058 | case SvcId::CreateCodeMemory: |
| 4059 | return SvcWrap_CreateCodeMemory64From32(system); | 4059 | return SvcWrap_CreateCodeMemory64From32(system, args); |
| 4060 | case SvcId::ControlCodeMemory: | 4060 | case SvcId::ControlCodeMemory: |
| 4061 | return SvcWrap_ControlCodeMemory64From32(system); | 4061 | return SvcWrap_ControlCodeMemory64From32(system, args); |
| 4062 | case SvcId::SleepSystem: | 4062 | case SvcId::SleepSystem: |
| 4063 | return SvcWrap_SleepSystem64From32(system); | 4063 | return SvcWrap_SleepSystem64From32(system, args); |
| 4064 | case SvcId::ReadWriteRegister: | 4064 | case SvcId::ReadWriteRegister: |
| 4065 | return SvcWrap_ReadWriteRegister64From32(system); | 4065 | return SvcWrap_ReadWriteRegister64From32(system, args); |
| 4066 | case SvcId::SetProcessActivity: | 4066 | case SvcId::SetProcessActivity: |
| 4067 | return SvcWrap_SetProcessActivity64From32(system); | 4067 | return SvcWrap_SetProcessActivity64From32(system, args); |
| 4068 | case SvcId::CreateSharedMemory: | 4068 | case SvcId::CreateSharedMemory: |
| 4069 | return SvcWrap_CreateSharedMemory64From32(system); | 4069 | return SvcWrap_CreateSharedMemory64From32(system, args); |
| 4070 | case SvcId::MapTransferMemory: | 4070 | case SvcId::MapTransferMemory: |
| 4071 | return SvcWrap_MapTransferMemory64From32(system); | 4071 | return SvcWrap_MapTransferMemory64From32(system, args); |
| 4072 | case SvcId::UnmapTransferMemory: | 4072 | case SvcId::UnmapTransferMemory: |
| 4073 | return SvcWrap_UnmapTransferMemory64From32(system); | 4073 | return SvcWrap_UnmapTransferMemory64From32(system, args); |
| 4074 | case SvcId::CreateInterruptEvent: | 4074 | case SvcId::CreateInterruptEvent: |
| 4075 | return SvcWrap_CreateInterruptEvent64From32(system); | 4075 | return SvcWrap_CreateInterruptEvent64From32(system, args); |
| 4076 | case SvcId::QueryPhysicalAddress: | 4076 | case SvcId::QueryPhysicalAddress: |
| 4077 | return SvcWrap_QueryPhysicalAddress64From32(system); | 4077 | return SvcWrap_QueryPhysicalAddress64From32(system, args); |
| 4078 | case SvcId::QueryIoMapping: | 4078 | case SvcId::QueryIoMapping: |
| 4079 | return SvcWrap_QueryIoMapping64From32(system); | 4079 | return SvcWrap_QueryIoMapping64From32(system, args); |
| 4080 | case SvcId::CreateDeviceAddressSpace: | 4080 | case SvcId::CreateDeviceAddressSpace: |
| 4081 | return SvcWrap_CreateDeviceAddressSpace64From32(system); | 4081 | return SvcWrap_CreateDeviceAddressSpace64From32(system, args); |
| 4082 | case SvcId::AttachDeviceAddressSpace: | 4082 | case SvcId::AttachDeviceAddressSpace: |
| 4083 | return SvcWrap_AttachDeviceAddressSpace64From32(system); | 4083 | return SvcWrap_AttachDeviceAddressSpace64From32(system, args); |
| 4084 | case SvcId::DetachDeviceAddressSpace: | 4084 | case SvcId::DetachDeviceAddressSpace: |
| 4085 | return SvcWrap_DetachDeviceAddressSpace64From32(system); | 4085 | return SvcWrap_DetachDeviceAddressSpace64From32(system, args); |
| 4086 | case SvcId::MapDeviceAddressSpaceByForce: | 4086 | case SvcId::MapDeviceAddressSpaceByForce: |
| 4087 | return SvcWrap_MapDeviceAddressSpaceByForce64From32(system); | 4087 | return SvcWrap_MapDeviceAddressSpaceByForce64From32(system, args); |
| 4088 | case SvcId::MapDeviceAddressSpaceAligned: | 4088 | case SvcId::MapDeviceAddressSpaceAligned: |
| 4089 | return SvcWrap_MapDeviceAddressSpaceAligned64From32(system); | 4089 | return SvcWrap_MapDeviceAddressSpaceAligned64From32(system, args); |
| 4090 | case SvcId::UnmapDeviceAddressSpace: | 4090 | case SvcId::UnmapDeviceAddressSpace: |
| 4091 | return SvcWrap_UnmapDeviceAddressSpace64From32(system); | 4091 | return SvcWrap_UnmapDeviceAddressSpace64From32(system, args); |
| 4092 | case SvcId::InvalidateProcessDataCache: | 4092 | case SvcId::InvalidateProcessDataCache: |
| 4093 | return SvcWrap_InvalidateProcessDataCache64From32(system); | 4093 | return SvcWrap_InvalidateProcessDataCache64From32(system, args); |
| 4094 | case SvcId::StoreProcessDataCache: | 4094 | case SvcId::StoreProcessDataCache: |
| 4095 | return SvcWrap_StoreProcessDataCache64From32(system); | 4095 | return SvcWrap_StoreProcessDataCache64From32(system, args); |
| 4096 | case SvcId::FlushProcessDataCache: | 4096 | case SvcId::FlushProcessDataCache: |
| 4097 | return SvcWrap_FlushProcessDataCache64From32(system); | 4097 | return SvcWrap_FlushProcessDataCache64From32(system, args); |
| 4098 | case SvcId::DebugActiveProcess: | 4098 | case SvcId::DebugActiveProcess: |
| 4099 | return SvcWrap_DebugActiveProcess64From32(system); | 4099 | return SvcWrap_DebugActiveProcess64From32(system, args); |
| 4100 | case SvcId::BreakDebugProcess: | 4100 | case SvcId::BreakDebugProcess: |
| 4101 | return SvcWrap_BreakDebugProcess64From32(system); | 4101 | return SvcWrap_BreakDebugProcess64From32(system, args); |
| 4102 | case SvcId::TerminateDebugProcess: | 4102 | case SvcId::TerminateDebugProcess: |
| 4103 | return SvcWrap_TerminateDebugProcess64From32(system); | 4103 | return SvcWrap_TerminateDebugProcess64From32(system, args); |
| 4104 | case SvcId::GetDebugEvent: | 4104 | case SvcId::GetDebugEvent: |
| 4105 | return SvcWrap_GetDebugEvent64From32(system); | 4105 | return SvcWrap_GetDebugEvent64From32(system, args); |
| 4106 | case SvcId::ContinueDebugEvent: | 4106 | case SvcId::ContinueDebugEvent: |
| 4107 | return SvcWrap_ContinueDebugEvent64From32(system); | 4107 | return SvcWrap_ContinueDebugEvent64From32(system, args); |
| 4108 | case SvcId::GetProcessList: | 4108 | case SvcId::GetProcessList: |
| 4109 | return SvcWrap_GetProcessList64From32(system); | 4109 | return SvcWrap_GetProcessList64From32(system, args); |
| 4110 | case SvcId::GetThreadList: | 4110 | case SvcId::GetThreadList: |
| 4111 | return SvcWrap_GetThreadList64From32(system); | 4111 | return SvcWrap_GetThreadList64From32(system, args); |
| 4112 | case SvcId::GetDebugThreadContext: | 4112 | case SvcId::GetDebugThreadContext: |
| 4113 | return SvcWrap_GetDebugThreadContext64From32(system); | 4113 | return SvcWrap_GetDebugThreadContext64From32(system, args); |
| 4114 | case SvcId::SetDebugThreadContext: | 4114 | case SvcId::SetDebugThreadContext: |
| 4115 | return SvcWrap_SetDebugThreadContext64From32(system); | 4115 | return SvcWrap_SetDebugThreadContext64From32(system, args); |
| 4116 | case SvcId::QueryDebugProcessMemory: | 4116 | case SvcId::QueryDebugProcessMemory: |
| 4117 | return SvcWrap_QueryDebugProcessMemory64From32(system); | 4117 | return SvcWrap_QueryDebugProcessMemory64From32(system, args); |
| 4118 | case SvcId::ReadDebugProcessMemory: | 4118 | case SvcId::ReadDebugProcessMemory: |
| 4119 | return SvcWrap_ReadDebugProcessMemory64From32(system); | 4119 | return SvcWrap_ReadDebugProcessMemory64From32(system, args); |
| 4120 | case SvcId::WriteDebugProcessMemory: | 4120 | case SvcId::WriteDebugProcessMemory: |
| 4121 | return SvcWrap_WriteDebugProcessMemory64From32(system); | 4121 | return SvcWrap_WriteDebugProcessMemory64From32(system, args); |
| 4122 | case SvcId::SetHardwareBreakPoint: | 4122 | case SvcId::SetHardwareBreakPoint: |
| 4123 | return SvcWrap_SetHardwareBreakPoint64From32(system); | 4123 | return SvcWrap_SetHardwareBreakPoint64From32(system, args); |
| 4124 | case SvcId::GetDebugThreadParam: | 4124 | case SvcId::GetDebugThreadParam: |
| 4125 | return SvcWrap_GetDebugThreadParam64From32(system); | 4125 | return SvcWrap_GetDebugThreadParam64From32(system, args); |
| 4126 | case SvcId::GetSystemInfo: | 4126 | case SvcId::GetSystemInfo: |
| 4127 | return SvcWrap_GetSystemInfo64From32(system); | 4127 | return SvcWrap_GetSystemInfo64From32(system, args); |
| 4128 | case SvcId::CreatePort: | 4128 | case SvcId::CreatePort: |
| 4129 | return SvcWrap_CreatePort64From32(system); | 4129 | return SvcWrap_CreatePort64From32(system, args); |
| 4130 | case SvcId::ManageNamedPort: | 4130 | case SvcId::ManageNamedPort: |
| 4131 | return SvcWrap_ManageNamedPort64From32(system); | 4131 | return SvcWrap_ManageNamedPort64From32(system, args); |
| 4132 | case SvcId::ConnectToPort: | 4132 | case SvcId::ConnectToPort: |
| 4133 | return SvcWrap_ConnectToPort64From32(system); | 4133 | return SvcWrap_ConnectToPort64From32(system, args); |
| 4134 | case SvcId::SetProcessMemoryPermission: | 4134 | case SvcId::SetProcessMemoryPermission: |
| 4135 | return SvcWrap_SetProcessMemoryPermission64From32(system); | 4135 | return SvcWrap_SetProcessMemoryPermission64From32(system, args); |
| 4136 | case SvcId::MapProcessMemory: | 4136 | case SvcId::MapProcessMemory: |
| 4137 | return SvcWrap_MapProcessMemory64From32(system); | 4137 | return SvcWrap_MapProcessMemory64From32(system, args); |
| 4138 | case SvcId::UnmapProcessMemory: | 4138 | case SvcId::UnmapProcessMemory: |
| 4139 | return SvcWrap_UnmapProcessMemory64From32(system); | 4139 | return SvcWrap_UnmapProcessMemory64From32(system, args); |
| 4140 | case SvcId::QueryProcessMemory: | 4140 | case SvcId::QueryProcessMemory: |
| 4141 | return SvcWrap_QueryProcessMemory64From32(system); | 4141 | return SvcWrap_QueryProcessMemory64From32(system, args); |
| 4142 | case SvcId::MapProcessCodeMemory: | 4142 | case SvcId::MapProcessCodeMemory: |
| 4143 | return SvcWrap_MapProcessCodeMemory64From32(system); | 4143 | return SvcWrap_MapProcessCodeMemory64From32(system, args); |
| 4144 | case SvcId::UnmapProcessCodeMemory: | 4144 | case SvcId::UnmapProcessCodeMemory: |
| 4145 | return SvcWrap_UnmapProcessCodeMemory64From32(system); | 4145 | return SvcWrap_UnmapProcessCodeMemory64From32(system, args); |
| 4146 | case SvcId::CreateProcess: | 4146 | case SvcId::CreateProcess: |
| 4147 | return SvcWrap_CreateProcess64From32(system); | 4147 | return SvcWrap_CreateProcess64From32(system, args); |
| 4148 | case SvcId::StartProcess: | 4148 | case SvcId::StartProcess: |
| 4149 | return SvcWrap_StartProcess64From32(system); | 4149 | return SvcWrap_StartProcess64From32(system, args); |
| 4150 | case SvcId::TerminateProcess: | 4150 | case SvcId::TerminateProcess: |
| 4151 | return SvcWrap_TerminateProcess64From32(system); | 4151 | return SvcWrap_TerminateProcess64From32(system, args); |
| 4152 | case SvcId::GetProcessInfo: | 4152 | case SvcId::GetProcessInfo: |
| 4153 | return SvcWrap_GetProcessInfo64From32(system); | 4153 | return SvcWrap_GetProcessInfo64From32(system, args); |
| 4154 | case SvcId::CreateResourceLimit: | 4154 | case SvcId::CreateResourceLimit: |
| 4155 | return SvcWrap_CreateResourceLimit64From32(system); | 4155 | return SvcWrap_CreateResourceLimit64From32(system, args); |
| 4156 | case SvcId::SetResourceLimitLimitValue: | 4156 | case SvcId::SetResourceLimitLimitValue: |
| 4157 | return SvcWrap_SetResourceLimitLimitValue64From32(system); | 4157 | return SvcWrap_SetResourceLimitLimitValue64From32(system, args); |
| 4158 | case SvcId::CallSecureMonitor: | 4158 | case SvcId::CallSecureMonitor: |
| 4159 | return SvcWrap_CallSecureMonitor64From32(system); | 4159 | return SvcWrap_CallSecureMonitor64From32(system, args); |
| 4160 | case SvcId::MapInsecureMemory: | 4160 | case SvcId::MapInsecureMemory: |
| 4161 | return SvcWrap_MapInsecureMemory64From32(system); | 4161 | return SvcWrap_MapInsecureMemory64From32(system, args); |
| 4162 | case SvcId::UnmapInsecureMemory: | 4162 | case SvcId::UnmapInsecureMemory: |
| 4163 | return SvcWrap_UnmapInsecureMemory64From32(system); | 4163 | return SvcWrap_UnmapInsecureMemory64From32(system, args); |
| 4164 | default: | 4164 | default: |
| 4165 | LOG_CRITICAL(Kernel_SVC, "Unknown SVC {:x}!", imm); | 4165 | LOG_CRITICAL(Kernel_SVC, "Unknown SVC {:x}!", imm); |
| 4166 | break; | 4166 | break; |
| 4167 | } | 4167 | } |
| 4168 | } | 4168 | } |
| 4169 | 4169 | ||
| 4170 | static void Call64(Core::System& system, u32 imm) { | 4170 | static void Call64(Core::System& system, u32 imm, std::span<uint64_t, 8> args) { |
| 4171 | switch (static_cast<SvcId>(imm)) { | 4171 | switch (static_cast<SvcId>(imm)) { |
| 4172 | case SvcId::SetHeapSize: | 4172 | case SvcId::SetHeapSize: |
| 4173 | return SvcWrap_SetHeapSize64(system); | 4173 | return SvcWrap_SetHeapSize64(system, args); |
| 4174 | case SvcId::SetMemoryPermission: | 4174 | case SvcId::SetMemoryPermission: |
| 4175 | return SvcWrap_SetMemoryPermission64(system); | 4175 | return SvcWrap_SetMemoryPermission64(system, args); |
| 4176 | case SvcId::SetMemoryAttribute: | 4176 | case SvcId::SetMemoryAttribute: |
| 4177 | return SvcWrap_SetMemoryAttribute64(system); | 4177 | return SvcWrap_SetMemoryAttribute64(system, args); |
| 4178 | case SvcId::MapMemory: | 4178 | case SvcId::MapMemory: |
| 4179 | return SvcWrap_MapMemory64(system); | 4179 | return SvcWrap_MapMemory64(system, args); |
| 4180 | case SvcId::UnmapMemory: | 4180 | case SvcId::UnmapMemory: |
| 4181 | return SvcWrap_UnmapMemory64(system); | 4181 | return SvcWrap_UnmapMemory64(system, args); |
| 4182 | case SvcId::QueryMemory: | 4182 | case SvcId::QueryMemory: |
| 4183 | return SvcWrap_QueryMemory64(system); | 4183 | return SvcWrap_QueryMemory64(system, args); |
| 4184 | case SvcId::ExitProcess: | 4184 | case SvcId::ExitProcess: |
| 4185 | return SvcWrap_ExitProcess64(system); | 4185 | return SvcWrap_ExitProcess64(system, args); |
| 4186 | case SvcId::CreateThread: | 4186 | case SvcId::CreateThread: |
| 4187 | return SvcWrap_CreateThread64(system); | 4187 | return SvcWrap_CreateThread64(system, args); |
| 4188 | case SvcId::StartThread: | 4188 | case SvcId::StartThread: |
| 4189 | return SvcWrap_StartThread64(system); | 4189 | return SvcWrap_StartThread64(system, args); |
| 4190 | case SvcId::ExitThread: | 4190 | case SvcId::ExitThread: |
| 4191 | return SvcWrap_ExitThread64(system); | 4191 | return SvcWrap_ExitThread64(system, args); |
| 4192 | case SvcId::SleepThread: | 4192 | case SvcId::SleepThread: |
| 4193 | return SvcWrap_SleepThread64(system); | 4193 | return SvcWrap_SleepThread64(system, args); |
| 4194 | case SvcId::GetThreadPriority: | 4194 | case SvcId::GetThreadPriority: |
| 4195 | return SvcWrap_GetThreadPriority64(system); | 4195 | return SvcWrap_GetThreadPriority64(system, args); |
| 4196 | case SvcId::SetThreadPriority: | 4196 | case SvcId::SetThreadPriority: |
| 4197 | return SvcWrap_SetThreadPriority64(system); | 4197 | return SvcWrap_SetThreadPriority64(system, args); |
| 4198 | case SvcId::GetThreadCoreMask: | 4198 | case SvcId::GetThreadCoreMask: |
| 4199 | return SvcWrap_GetThreadCoreMask64(system); | 4199 | return SvcWrap_GetThreadCoreMask64(system, args); |
| 4200 | case SvcId::SetThreadCoreMask: | 4200 | case SvcId::SetThreadCoreMask: |
| 4201 | return SvcWrap_SetThreadCoreMask64(system); | 4201 | return SvcWrap_SetThreadCoreMask64(system, args); |
| 4202 | case SvcId::GetCurrentProcessorNumber: | 4202 | case SvcId::GetCurrentProcessorNumber: |
| 4203 | return SvcWrap_GetCurrentProcessorNumber64(system); | 4203 | return SvcWrap_GetCurrentProcessorNumber64(system, args); |
| 4204 | case SvcId::SignalEvent: | 4204 | case SvcId::SignalEvent: |
| 4205 | return SvcWrap_SignalEvent64(system); | 4205 | return SvcWrap_SignalEvent64(system, args); |
| 4206 | case SvcId::ClearEvent: | 4206 | case SvcId::ClearEvent: |
| 4207 | return SvcWrap_ClearEvent64(system); | 4207 | return SvcWrap_ClearEvent64(system, args); |
| 4208 | case SvcId::MapSharedMemory: | 4208 | case SvcId::MapSharedMemory: |
| 4209 | return SvcWrap_MapSharedMemory64(system); | 4209 | return SvcWrap_MapSharedMemory64(system, args); |
| 4210 | case SvcId::UnmapSharedMemory: | 4210 | case SvcId::UnmapSharedMemory: |
| 4211 | return SvcWrap_UnmapSharedMemory64(system); | 4211 | return SvcWrap_UnmapSharedMemory64(system, args); |
| 4212 | case SvcId::CreateTransferMemory: | 4212 | case SvcId::CreateTransferMemory: |
| 4213 | return SvcWrap_CreateTransferMemory64(system); | 4213 | return SvcWrap_CreateTransferMemory64(system, args); |
| 4214 | case SvcId::CloseHandle: | 4214 | case SvcId::CloseHandle: |
| 4215 | return SvcWrap_CloseHandle64(system); | 4215 | return SvcWrap_CloseHandle64(system, args); |
| 4216 | case SvcId::ResetSignal: | 4216 | case SvcId::ResetSignal: |
| 4217 | return SvcWrap_ResetSignal64(system); | 4217 | return SvcWrap_ResetSignal64(system, args); |
| 4218 | case SvcId::WaitSynchronization: | 4218 | case SvcId::WaitSynchronization: |
| 4219 | return SvcWrap_WaitSynchronization64(system); | 4219 | return SvcWrap_WaitSynchronization64(system, args); |
| 4220 | case SvcId::CancelSynchronization: | 4220 | case SvcId::CancelSynchronization: |
| 4221 | return SvcWrap_CancelSynchronization64(system); | 4221 | return SvcWrap_CancelSynchronization64(system, args); |
| 4222 | case SvcId::ArbitrateLock: | 4222 | case SvcId::ArbitrateLock: |
| 4223 | return SvcWrap_ArbitrateLock64(system); | 4223 | return SvcWrap_ArbitrateLock64(system, args); |
| 4224 | case SvcId::ArbitrateUnlock: | 4224 | case SvcId::ArbitrateUnlock: |
| 4225 | return SvcWrap_ArbitrateUnlock64(system); | 4225 | return SvcWrap_ArbitrateUnlock64(system, args); |
| 4226 | case SvcId::WaitProcessWideKeyAtomic: | 4226 | case SvcId::WaitProcessWideKeyAtomic: |
| 4227 | return SvcWrap_WaitProcessWideKeyAtomic64(system); | 4227 | return SvcWrap_WaitProcessWideKeyAtomic64(system, args); |
| 4228 | case SvcId::SignalProcessWideKey: | 4228 | case SvcId::SignalProcessWideKey: |
| 4229 | return SvcWrap_SignalProcessWideKey64(system); | 4229 | return SvcWrap_SignalProcessWideKey64(system, args); |
| 4230 | case SvcId::GetSystemTick: | 4230 | case SvcId::GetSystemTick: |
| 4231 | return SvcWrap_GetSystemTick64(system); | 4231 | return SvcWrap_GetSystemTick64(system, args); |
| 4232 | case SvcId::ConnectToNamedPort: | 4232 | case SvcId::ConnectToNamedPort: |
| 4233 | return SvcWrap_ConnectToNamedPort64(system); | 4233 | return SvcWrap_ConnectToNamedPort64(system, args); |
| 4234 | case SvcId::SendSyncRequestLight: | 4234 | case SvcId::SendSyncRequestLight: |
| 4235 | return SvcWrap_SendSyncRequestLight64(system); | 4235 | return SvcWrap_SendSyncRequestLight64(system, args); |
| 4236 | case SvcId::SendSyncRequest: | 4236 | case SvcId::SendSyncRequest: |
| 4237 | return SvcWrap_SendSyncRequest64(system); | 4237 | return SvcWrap_SendSyncRequest64(system, args); |
| 4238 | case SvcId::SendSyncRequestWithUserBuffer: | 4238 | case SvcId::SendSyncRequestWithUserBuffer: |
| 4239 | return SvcWrap_SendSyncRequestWithUserBuffer64(system); | 4239 | return SvcWrap_SendSyncRequestWithUserBuffer64(system, args); |
| 4240 | case SvcId::SendAsyncRequestWithUserBuffer: | 4240 | case SvcId::SendAsyncRequestWithUserBuffer: |
| 4241 | return SvcWrap_SendAsyncRequestWithUserBuffer64(system); | 4241 | return SvcWrap_SendAsyncRequestWithUserBuffer64(system, args); |
| 4242 | case SvcId::GetProcessId: | 4242 | case SvcId::GetProcessId: |
| 4243 | return SvcWrap_GetProcessId64(system); | 4243 | return SvcWrap_GetProcessId64(system, args); |
| 4244 | case SvcId::GetThreadId: | 4244 | case SvcId::GetThreadId: |
| 4245 | return SvcWrap_GetThreadId64(system); | 4245 | return SvcWrap_GetThreadId64(system, args); |
| 4246 | case SvcId::Break: | 4246 | case SvcId::Break: |
| 4247 | return SvcWrap_Break64(system); | 4247 | return SvcWrap_Break64(system, args); |
| 4248 | case SvcId::OutputDebugString: | 4248 | case SvcId::OutputDebugString: |
| 4249 | return SvcWrap_OutputDebugString64(system); | 4249 | return SvcWrap_OutputDebugString64(system, args); |
| 4250 | case SvcId::ReturnFromException: | 4250 | case SvcId::ReturnFromException: |
| 4251 | return SvcWrap_ReturnFromException64(system); | 4251 | return SvcWrap_ReturnFromException64(system, args); |
| 4252 | case SvcId::GetInfo: | 4252 | case SvcId::GetInfo: |
| 4253 | return SvcWrap_GetInfo64(system); | 4253 | return SvcWrap_GetInfo64(system, args); |
| 4254 | case SvcId::FlushEntireDataCache: | 4254 | case SvcId::FlushEntireDataCache: |
| 4255 | return SvcWrap_FlushEntireDataCache64(system); | 4255 | return SvcWrap_FlushEntireDataCache64(system, args); |
| 4256 | case SvcId::FlushDataCache: | 4256 | case SvcId::FlushDataCache: |
| 4257 | return SvcWrap_FlushDataCache64(system); | 4257 | return SvcWrap_FlushDataCache64(system, args); |
| 4258 | case SvcId::MapPhysicalMemory: | 4258 | case SvcId::MapPhysicalMemory: |
| 4259 | return SvcWrap_MapPhysicalMemory64(system); | 4259 | return SvcWrap_MapPhysicalMemory64(system, args); |
| 4260 | case SvcId::UnmapPhysicalMemory: | 4260 | case SvcId::UnmapPhysicalMemory: |
| 4261 | return SvcWrap_UnmapPhysicalMemory64(system); | 4261 | return SvcWrap_UnmapPhysicalMemory64(system, args); |
| 4262 | case SvcId::GetDebugFutureThreadInfo: | 4262 | case SvcId::GetDebugFutureThreadInfo: |
| 4263 | return SvcWrap_GetDebugFutureThreadInfo64(system); | 4263 | return SvcWrap_GetDebugFutureThreadInfo64(system, args); |
| 4264 | case SvcId::GetLastThreadInfo: | 4264 | case SvcId::GetLastThreadInfo: |
| 4265 | return SvcWrap_GetLastThreadInfo64(system); | 4265 | return SvcWrap_GetLastThreadInfo64(system, args); |
| 4266 | case SvcId::GetResourceLimitLimitValue: | 4266 | case SvcId::GetResourceLimitLimitValue: |
| 4267 | return SvcWrap_GetResourceLimitLimitValue64(system); | 4267 | return SvcWrap_GetResourceLimitLimitValue64(system, args); |
| 4268 | case SvcId::GetResourceLimitCurrentValue: | 4268 | case SvcId::GetResourceLimitCurrentValue: |
| 4269 | return SvcWrap_GetResourceLimitCurrentValue64(system); | 4269 | return SvcWrap_GetResourceLimitCurrentValue64(system, args); |
| 4270 | case SvcId::SetThreadActivity: | 4270 | case SvcId::SetThreadActivity: |
| 4271 | return SvcWrap_SetThreadActivity64(system); | 4271 | return SvcWrap_SetThreadActivity64(system, args); |
| 4272 | case SvcId::GetThreadContext3: | 4272 | case SvcId::GetThreadContext3: |
| 4273 | return SvcWrap_GetThreadContext364(system); | 4273 | return SvcWrap_GetThreadContext364(system, args); |
| 4274 | case SvcId::WaitForAddress: | 4274 | case SvcId::WaitForAddress: |
| 4275 | return SvcWrap_WaitForAddress64(system); | 4275 | return SvcWrap_WaitForAddress64(system, args); |
| 4276 | case SvcId::SignalToAddress: | 4276 | case SvcId::SignalToAddress: |
| 4277 | return SvcWrap_SignalToAddress64(system); | 4277 | return SvcWrap_SignalToAddress64(system, args); |
| 4278 | case SvcId::SynchronizePreemptionState: | 4278 | case SvcId::SynchronizePreemptionState: |
| 4279 | return SvcWrap_SynchronizePreemptionState64(system); | 4279 | return SvcWrap_SynchronizePreemptionState64(system, args); |
| 4280 | case SvcId::GetResourceLimitPeakValue: | 4280 | case SvcId::GetResourceLimitPeakValue: |
| 4281 | return SvcWrap_GetResourceLimitPeakValue64(system); | 4281 | return SvcWrap_GetResourceLimitPeakValue64(system, args); |
| 4282 | case SvcId::CreateIoPool: | 4282 | case SvcId::CreateIoPool: |
| 4283 | return SvcWrap_CreateIoPool64(system); | 4283 | return SvcWrap_CreateIoPool64(system, args); |
| 4284 | case SvcId::CreateIoRegion: | 4284 | case SvcId::CreateIoRegion: |
| 4285 | return SvcWrap_CreateIoRegion64(system); | 4285 | return SvcWrap_CreateIoRegion64(system, args); |
| 4286 | case SvcId::KernelDebug: | 4286 | case SvcId::KernelDebug: |
| 4287 | return SvcWrap_KernelDebug64(system); | 4287 | return SvcWrap_KernelDebug64(system, args); |
| 4288 | case SvcId::ChangeKernelTraceState: | 4288 | case SvcId::ChangeKernelTraceState: |
| 4289 | return SvcWrap_ChangeKernelTraceState64(system); | 4289 | return SvcWrap_ChangeKernelTraceState64(system, args); |
| 4290 | case SvcId::CreateSession: | 4290 | case SvcId::CreateSession: |
| 4291 | return SvcWrap_CreateSession64(system); | 4291 | return SvcWrap_CreateSession64(system, args); |
| 4292 | case SvcId::AcceptSession: | 4292 | case SvcId::AcceptSession: |
| 4293 | return SvcWrap_AcceptSession64(system); | 4293 | return SvcWrap_AcceptSession64(system, args); |
| 4294 | case SvcId::ReplyAndReceiveLight: | 4294 | case SvcId::ReplyAndReceiveLight: |
| 4295 | return SvcWrap_ReplyAndReceiveLight64(system); | 4295 | return SvcWrap_ReplyAndReceiveLight64(system, args); |
| 4296 | case SvcId::ReplyAndReceive: | 4296 | case SvcId::ReplyAndReceive: |
| 4297 | return SvcWrap_ReplyAndReceive64(system); | 4297 | return SvcWrap_ReplyAndReceive64(system, args); |
| 4298 | case SvcId::ReplyAndReceiveWithUserBuffer: | 4298 | case SvcId::ReplyAndReceiveWithUserBuffer: |
| 4299 | return SvcWrap_ReplyAndReceiveWithUserBuffer64(system); | 4299 | return SvcWrap_ReplyAndReceiveWithUserBuffer64(system, args); |
| 4300 | case SvcId::CreateEvent: | 4300 | case SvcId::CreateEvent: |
| 4301 | return SvcWrap_CreateEvent64(system); | 4301 | return SvcWrap_CreateEvent64(system, args); |
| 4302 | case SvcId::MapIoRegion: | 4302 | case SvcId::MapIoRegion: |
| 4303 | return SvcWrap_MapIoRegion64(system); | 4303 | return SvcWrap_MapIoRegion64(system, args); |
| 4304 | case SvcId::UnmapIoRegion: | 4304 | case SvcId::UnmapIoRegion: |
| 4305 | return SvcWrap_UnmapIoRegion64(system); | 4305 | return SvcWrap_UnmapIoRegion64(system, args); |
| 4306 | case SvcId::MapPhysicalMemoryUnsafe: | 4306 | case SvcId::MapPhysicalMemoryUnsafe: |
| 4307 | return SvcWrap_MapPhysicalMemoryUnsafe64(system); | 4307 | return SvcWrap_MapPhysicalMemoryUnsafe64(system, args); |
| 4308 | case SvcId::UnmapPhysicalMemoryUnsafe: | 4308 | case SvcId::UnmapPhysicalMemoryUnsafe: |
| 4309 | return SvcWrap_UnmapPhysicalMemoryUnsafe64(system); | 4309 | return SvcWrap_UnmapPhysicalMemoryUnsafe64(system, args); |
| 4310 | case SvcId::SetUnsafeLimit: | 4310 | case SvcId::SetUnsafeLimit: |
| 4311 | return SvcWrap_SetUnsafeLimit64(system); | 4311 | return SvcWrap_SetUnsafeLimit64(system, args); |
| 4312 | case SvcId::CreateCodeMemory: | 4312 | case SvcId::CreateCodeMemory: |
| 4313 | return SvcWrap_CreateCodeMemory64(system); | 4313 | return SvcWrap_CreateCodeMemory64(system, args); |
| 4314 | case SvcId::ControlCodeMemory: | 4314 | case SvcId::ControlCodeMemory: |
| 4315 | return SvcWrap_ControlCodeMemory64(system); | 4315 | return SvcWrap_ControlCodeMemory64(system, args); |
| 4316 | case SvcId::SleepSystem: | 4316 | case SvcId::SleepSystem: |
| 4317 | return SvcWrap_SleepSystem64(system); | 4317 | return SvcWrap_SleepSystem64(system, args); |
| 4318 | case SvcId::ReadWriteRegister: | 4318 | case SvcId::ReadWriteRegister: |
| 4319 | return SvcWrap_ReadWriteRegister64(system); | 4319 | return SvcWrap_ReadWriteRegister64(system, args); |
| 4320 | case SvcId::SetProcessActivity: | 4320 | case SvcId::SetProcessActivity: |
| 4321 | return SvcWrap_SetProcessActivity64(system); | 4321 | return SvcWrap_SetProcessActivity64(system, args); |
| 4322 | case SvcId::CreateSharedMemory: | 4322 | case SvcId::CreateSharedMemory: |
| 4323 | return SvcWrap_CreateSharedMemory64(system); | 4323 | return SvcWrap_CreateSharedMemory64(system, args); |
| 4324 | case SvcId::MapTransferMemory: | 4324 | case SvcId::MapTransferMemory: |
| 4325 | return SvcWrap_MapTransferMemory64(system); | 4325 | return SvcWrap_MapTransferMemory64(system, args); |
| 4326 | case SvcId::UnmapTransferMemory: | 4326 | case SvcId::UnmapTransferMemory: |
| 4327 | return SvcWrap_UnmapTransferMemory64(system); | 4327 | return SvcWrap_UnmapTransferMemory64(system, args); |
| 4328 | case SvcId::CreateInterruptEvent: | 4328 | case SvcId::CreateInterruptEvent: |
| 4329 | return SvcWrap_CreateInterruptEvent64(system); | 4329 | return SvcWrap_CreateInterruptEvent64(system, args); |
| 4330 | case SvcId::QueryPhysicalAddress: | 4330 | case SvcId::QueryPhysicalAddress: |
| 4331 | return SvcWrap_QueryPhysicalAddress64(system); | 4331 | return SvcWrap_QueryPhysicalAddress64(system, args); |
| 4332 | case SvcId::QueryIoMapping: | 4332 | case SvcId::QueryIoMapping: |
| 4333 | return SvcWrap_QueryIoMapping64(system); | 4333 | return SvcWrap_QueryIoMapping64(system, args); |
| 4334 | case SvcId::CreateDeviceAddressSpace: | 4334 | case SvcId::CreateDeviceAddressSpace: |
| 4335 | return SvcWrap_CreateDeviceAddressSpace64(system); | 4335 | return SvcWrap_CreateDeviceAddressSpace64(system, args); |
| 4336 | case SvcId::AttachDeviceAddressSpace: | 4336 | case SvcId::AttachDeviceAddressSpace: |
| 4337 | return SvcWrap_AttachDeviceAddressSpace64(system); | 4337 | return SvcWrap_AttachDeviceAddressSpace64(system, args); |
| 4338 | case SvcId::DetachDeviceAddressSpace: | 4338 | case SvcId::DetachDeviceAddressSpace: |
| 4339 | return SvcWrap_DetachDeviceAddressSpace64(system); | 4339 | return SvcWrap_DetachDeviceAddressSpace64(system, args); |
| 4340 | case SvcId::MapDeviceAddressSpaceByForce: | 4340 | case SvcId::MapDeviceAddressSpaceByForce: |
| 4341 | return SvcWrap_MapDeviceAddressSpaceByForce64(system); | 4341 | return SvcWrap_MapDeviceAddressSpaceByForce64(system, args); |
| 4342 | case SvcId::MapDeviceAddressSpaceAligned: | 4342 | case SvcId::MapDeviceAddressSpaceAligned: |
| 4343 | return SvcWrap_MapDeviceAddressSpaceAligned64(system); | 4343 | return SvcWrap_MapDeviceAddressSpaceAligned64(system, args); |
| 4344 | case SvcId::UnmapDeviceAddressSpace: | 4344 | case SvcId::UnmapDeviceAddressSpace: |
| 4345 | return SvcWrap_UnmapDeviceAddressSpace64(system); | 4345 | return SvcWrap_UnmapDeviceAddressSpace64(system, args); |
| 4346 | case SvcId::InvalidateProcessDataCache: | 4346 | case SvcId::InvalidateProcessDataCache: |
| 4347 | return SvcWrap_InvalidateProcessDataCache64(system); | 4347 | return SvcWrap_InvalidateProcessDataCache64(system, args); |
| 4348 | case SvcId::StoreProcessDataCache: | 4348 | case SvcId::StoreProcessDataCache: |
| 4349 | return SvcWrap_StoreProcessDataCache64(system); | 4349 | return SvcWrap_StoreProcessDataCache64(system, args); |
| 4350 | case SvcId::FlushProcessDataCache: | 4350 | case SvcId::FlushProcessDataCache: |
| 4351 | return SvcWrap_FlushProcessDataCache64(system); | 4351 | return SvcWrap_FlushProcessDataCache64(system, args); |
| 4352 | case SvcId::DebugActiveProcess: | 4352 | case SvcId::DebugActiveProcess: |
| 4353 | return SvcWrap_DebugActiveProcess64(system); | 4353 | return SvcWrap_DebugActiveProcess64(system, args); |
| 4354 | case SvcId::BreakDebugProcess: | 4354 | case SvcId::BreakDebugProcess: |
| 4355 | return SvcWrap_BreakDebugProcess64(system); | 4355 | return SvcWrap_BreakDebugProcess64(system, args); |
| 4356 | case SvcId::TerminateDebugProcess: | 4356 | case SvcId::TerminateDebugProcess: |
| 4357 | return SvcWrap_TerminateDebugProcess64(system); | 4357 | return SvcWrap_TerminateDebugProcess64(system, args); |
| 4358 | case SvcId::GetDebugEvent: | 4358 | case SvcId::GetDebugEvent: |
| 4359 | return SvcWrap_GetDebugEvent64(system); | 4359 | return SvcWrap_GetDebugEvent64(system, args); |
| 4360 | case SvcId::ContinueDebugEvent: | 4360 | case SvcId::ContinueDebugEvent: |
| 4361 | return SvcWrap_ContinueDebugEvent64(system); | 4361 | return SvcWrap_ContinueDebugEvent64(system, args); |
| 4362 | case SvcId::GetProcessList: | 4362 | case SvcId::GetProcessList: |
| 4363 | return SvcWrap_GetProcessList64(system); | 4363 | return SvcWrap_GetProcessList64(system, args); |
| 4364 | case SvcId::GetThreadList: | 4364 | case SvcId::GetThreadList: |
| 4365 | return SvcWrap_GetThreadList64(system); | 4365 | return SvcWrap_GetThreadList64(system, args); |
| 4366 | case SvcId::GetDebugThreadContext: | 4366 | case SvcId::GetDebugThreadContext: |
| 4367 | return SvcWrap_GetDebugThreadContext64(system); | 4367 | return SvcWrap_GetDebugThreadContext64(system, args); |
| 4368 | case SvcId::SetDebugThreadContext: | 4368 | case SvcId::SetDebugThreadContext: |
| 4369 | return SvcWrap_SetDebugThreadContext64(system); | 4369 | return SvcWrap_SetDebugThreadContext64(system, args); |
| 4370 | case SvcId::QueryDebugProcessMemory: | 4370 | case SvcId::QueryDebugProcessMemory: |
| 4371 | return SvcWrap_QueryDebugProcessMemory64(system); | 4371 | return SvcWrap_QueryDebugProcessMemory64(system, args); |
| 4372 | case SvcId::ReadDebugProcessMemory: | 4372 | case SvcId::ReadDebugProcessMemory: |
| 4373 | return SvcWrap_ReadDebugProcessMemory64(system); | 4373 | return SvcWrap_ReadDebugProcessMemory64(system, args); |
| 4374 | case SvcId::WriteDebugProcessMemory: | 4374 | case SvcId::WriteDebugProcessMemory: |
| 4375 | return SvcWrap_WriteDebugProcessMemory64(system); | 4375 | return SvcWrap_WriteDebugProcessMemory64(system, args); |
| 4376 | case SvcId::SetHardwareBreakPoint: | 4376 | case SvcId::SetHardwareBreakPoint: |
| 4377 | return SvcWrap_SetHardwareBreakPoint64(system); | 4377 | return SvcWrap_SetHardwareBreakPoint64(system, args); |
| 4378 | case SvcId::GetDebugThreadParam: | 4378 | case SvcId::GetDebugThreadParam: |
| 4379 | return SvcWrap_GetDebugThreadParam64(system); | 4379 | return SvcWrap_GetDebugThreadParam64(system, args); |
| 4380 | case SvcId::GetSystemInfo: | 4380 | case SvcId::GetSystemInfo: |
| 4381 | return SvcWrap_GetSystemInfo64(system); | 4381 | return SvcWrap_GetSystemInfo64(system, args); |
| 4382 | case SvcId::CreatePort: | 4382 | case SvcId::CreatePort: |
| 4383 | return SvcWrap_CreatePort64(system); | 4383 | return SvcWrap_CreatePort64(system, args); |
| 4384 | case SvcId::ManageNamedPort: | 4384 | case SvcId::ManageNamedPort: |
| 4385 | return SvcWrap_ManageNamedPort64(system); | 4385 | return SvcWrap_ManageNamedPort64(system, args); |
| 4386 | case SvcId::ConnectToPort: | 4386 | case SvcId::ConnectToPort: |
| 4387 | return SvcWrap_ConnectToPort64(system); | 4387 | return SvcWrap_ConnectToPort64(system, args); |
| 4388 | case SvcId::SetProcessMemoryPermission: | 4388 | case SvcId::SetProcessMemoryPermission: |
| 4389 | return SvcWrap_SetProcessMemoryPermission64(system); | 4389 | return SvcWrap_SetProcessMemoryPermission64(system, args); |
| 4390 | case SvcId::MapProcessMemory: | 4390 | case SvcId::MapProcessMemory: |
| 4391 | return SvcWrap_MapProcessMemory64(system); | 4391 | return SvcWrap_MapProcessMemory64(system, args); |
| 4392 | case SvcId::UnmapProcessMemory: | 4392 | case SvcId::UnmapProcessMemory: |
| 4393 | return SvcWrap_UnmapProcessMemory64(system); | 4393 | return SvcWrap_UnmapProcessMemory64(system, args); |
| 4394 | case SvcId::QueryProcessMemory: | 4394 | case SvcId::QueryProcessMemory: |
| 4395 | return SvcWrap_QueryProcessMemory64(system); | 4395 | return SvcWrap_QueryProcessMemory64(system, args); |
| 4396 | case SvcId::MapProcessCodeMemory: | 4396 | case SvcId::MapProcessCodeMemory: |
| 4397 | return SvcWrap_MapProcessCodeMemory64(system); | 4397 | return SvcWrap_MapProcessCodeMemory64(system, args); |
| 4398 | case SvcId::UnmapProcessCodeMemory: | 4398 | case SvcId::UnmapProcessCodeMemory: |
| 4399 | return SvcWrap_UnmapProcessCodeMemory64(system); | 4399 | return SvcWrap_UnmapProcessCodeMemory64(system, args); |
| 4400 | case SvcId::CreateProcess: | 4400 | case SvcId::CreateProcess: |
| 4401 | return SvcWrap_CreateProcess64(system); | 4401 | return SvcWrap_CreateProcess64(system, args); |
| 4402 | case SvcId::StartProcess: | 4402 | case SvcId::StartProcess: |
| 4403 | return SvcWrap_StartProcess64(system); | 4403 | return SvcWrap_StartProcess64(system, args); |
| 4404 | case SvcId::TerminateProcess: | 4404 | case SvcId::TerminateProcess: |
| 4405 | return SvcWrap_TerminateProcess64(system); | 4405 | return SvcWrap_TerminateProcess64(system, args); |
| 4406 | case SvcId::GetProcessInfo: | 4406 | case SvcId::GetProcessInfo: |
| 4407 | return SvcWrap_GetProcessInfo64(system); | 4407 | return SvcWrap_GetProcessInfo64(system, args); |
| 4408 | case SvcId::CreateResourceLimit: | 4408 | case SvcId::CreateResourceLimit: |
| 4409 | return SvcWrap_CreateResourceLimit64(system); | 4409 | return SvcWrap_CreateResourceLimit64(system, args); |
| 4410 | case SvcId::SetResourceLimitLimitValue: | 4410 | case SvcId::SetResourceLimitLimitValue: |
| 4411 | return SvcWrap_SetResourceLimitLimitValue64(system); | 4411 | return SvcWrap_SetResourceLimitLimitValue64(system, args); |
| 4412 | case SvcId::CallSecureMonitor: | 4412 | case SvcId::CallSecureMonitor: |
| 4413 | return SvcWrap_CallSecureMonitor64(system); | 4413 | return SvcWrap_CallSecureMonitor64(system, args); |
| 4414 | case SvcId::MapInsecureMemory: | 4414 | case SvcId::MapInsecureMemory: |
| 4415 | return SvcWrap_MapInsecureMemory64(system); | 4415 | return SvcWrap_MapInsecureMemory64(system, args); |
| 4416 | case SvcId::UnmapInsecureMemory: | 4416 | case SvcId::UnmapInsecureMemory: |
| 4417 | return SvcWrap_UnmapInsecureMemory64(system); | 4417 | return SvcWrap_UnmapInsecureMemory64(system, args); |
| 4418 | default: | 4418 | default: |
| 4419 | LOG_CRITICAL(Kernel_SVC, "Unknown SVC {:x}!", imm); | 4419 | LOG_CRITICAL(Kernel_SVC, "Unknown SVC {:x}!", imm); |
| 4420 | break; | 4420 | break; |
| @@ -4424,15 +4424,20 @@ static void Call64(Core::System& system, u32 imm) { | |||
| 4424 | 4424 | ||
| 4425 | void Call(Core::System& system, u32 imm) { | 4425 | void Call(Core::System& system, u32 imm) { |
| 4426 | auto& kernel = system.Kernel(); | 4426 | auto& kernel = system.Kernel(); |
| 4427 | auto& process = GetCurrentProcess(kernel); | ||
| 4428 | |||
| 4429 | std::array<uint64_t, 8> args; | ||
| 4430 | kernel.CurrentPhysicalCore().SaveSvcArguments(process, args); | ||
| 4427 | kernel.EnterSVCProfile(); | 4431 | kernel.EnterSVCProfile(); |
| 4428 | 4432 | ||
| 4429 | if (GetCurrentProcess(system.Kernel()).Is64Bit()) { | 4433 | if (process.Is64Bit()) { |
| 4430 | Call64(system, imm); | 4434 | Call64(system, imm, args); |
| 4431 | } else { | 4435 | } else { |
| 4432 | Call32(system, imm); | 4436 | Call32(system, imm, args); |
| 4433 | } | 4437 | } |
| 4434 | 4438 | ||
| 4435 | kernel.ExitSVCProfile(); | 4439 | kernel.ExitSVCProfile(); |
| 4440 | kernel.CurrentPhysicalCore().LoadSvcArguments(process, args); | ||
| 4436 | } | 4441 | } |
| 4437 | 4442 | ||
| 4438 | } // namespace Kernel::Svc | 4443 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/svc.h b/src/core/hle/kernel/svc.h index ac4696008..828f39611 100644 --- a/src/core/hle/kernel/svc.h +++ b/src/core/hle/kernel/svc.h | |||
| @@ -9,6 +9,8 @@ namespace Core { | |||
| 9 | class System; | 9 | class System; |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | #include <span> | ||
| 13 | |||
| 12 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 13 | #include "core/hle/kernel/svc_types.h" | 15 | #include "core/hle/kernel/svc_types.h" |
| 14 | #include "core/hle/result.h" | 16 | #include "core/hle/result.h" |
| @@ -520,15 +522,15 @@ void CallSecureMonitor64From32(Core::System& system, ilp32::SecureMonitorArgumen | |||
| 520 | void CallSecureMonitor64(Core::System& system, lp64::SecureMonitorArguments* args); | 522 | void CallSecureMonitor64(Core::System& system, lp64::SecureMonitorArguments* args); |
| 521 | 523 | ||
| 522 | // Defined in svc_light_ipc.cpp. | 524 | // Defined in svc_light_ipc.cpp. |
| 523 | void SvcWrap_ReplyAndReceiveLight64From32(Core::System& system); | 525 | void SvcWrap_ReplyAndReceiveLight64From32(Core::System& system, std::span<uint64_t, 8> args); |
| 524 | void SvcWrap_ReplyAndReceiveLight64(Core::System& system); | 526 | void SvcWrap_ReplyAndReceiveLight64(Core::System& system, std::span<uint64_t, 8> args); |
| 525 | 527 | ||
| 526 | void SvcWrap_SendSyncRequestLight64From32(Core::System& system); | 528 | void SvcWrap_SendSyncRequestLight64From32(Core::System& system, std::span<uint64_t, 8> args); |
| 527 | void SvcWrap_SendSyncRequestLight64(Core::System& system); | 529 | void SvcWrap_SendSyncRequestLight64(Core::System& system, std::span<uint64_t, 8> args); |
| 528 | 530 | ||
| 529 | // Defined in svc_secure_monitor_call.cpp. | 531 | // Defined in svc_secure_monitor_call.cpp. |
| 530 | void SvcWrap_CallSecureMonitor64From32(Core::System& system); | 532 | void SvcWrap_CallSecureMonitor64From32(Core::System& system, std::span<uint64_t, 8> args); |
| 531 | void SvcWrap_CallSecureMonitor64(Core::System& system); | 533 | void SvcWrap_CallSecureMonitor64(Core::System& system, std::span<uint64_t, 8> args); |
| 532 | 534 | ||
| 533 | // Perform a supervisor call by index. | 535 | // Perform a supervisor call by index. |
| 534 | void Call(Core::System& system, u32 imm); | 536 | void Call(Core::System& system, u32 imm); |
diff --git a/src/core/hle/kernel/svc/svc_exception.cpp b/src/core/hle/kernel/svc/svc_exception.cpp index c581c086b..47b756828 100644 --- a/src/core/hle/kernel/svc/svc_exception.cpp +++ b/src/core/hle/kernel/svc/svc_exception.cpp | |||
| @@ -103,9 +103,7 @@ void Break(Core::System& system, BreakReason reason, u64 info1, u64 info2) { | |||
| 103 | 103 | ||
| 104 | handle_debug_buffer(info1, info2); | 104 | handle_debug_buffer(info1, info2); |
| 105 | 105 | ||
| 106 | auto* const current_thread = GetCurrentThreadPointer(system.Kernel()); | 106 | system.CurrentPhysicalCore().LogBacktrace(); |
| 107 | const auto thread_processor_id = current_thread->GetActiveCore(); | ||
| 108 | system.ArmInterface(static_cast<std::size_t>(thread_processor_id)).LogBacktrace(); | ||
| 109 | } | 107 | } |
| 110 | 108 | ||
| 111 | const bool is_hbl = GetCurrentProcess(system.Kernel()).IsHbl(); | 109 | const bool is_hbl = GetCurrentProcess(system.Kernel()).IsHbl(); |
diff --git a/src/core/hle/kernel/svc/svc_light_ipc.cpp b/src/core/hle/kernel/svc/svc_light_ipc.cpp index b76ce984c..d757d5af2 100644 --- a/src/core/hle/kernel/svc/svc_light_ipc.cpp +++ b/src/core/hle/kernel/svc/svc_light_ipc.cpp | |||
| @@ -37,37 +37,36 @@ Result ReplyAndReceiveLight64From32(Core::System& system, Handle session_handle, | |||
| 37 | // Custom ABI implementation for light IPC. | 37 | // Custom ABI implementation for light IPC. |
| 38 | 38 | ||
| 39 | template <typename F> | 39 | template <typename F> |
| 40 | static void SvcWrap_LightIpc(Core::System& system, F&& cb) { | 40 | static void SvcWrap_LightIpc(Core::System& system, std::span<uint64_t, 8> args, F&& cb) { |
| 41 | auto& core = system.CurrentArmInterface(); | 41 | std::array<u32, 7> ipc_args{}; |
| 42 | std::array<u32, 7> arguments{}; | ||
| 43 | 42 | ||
| 44 | Handle session_handle = static_cast<Handle>(core.GetReg(0)); | 43 | Handle session_handle = static_cast<Handle>(args[0]); |
| 45 | for (int i = 0; i < 7; i++) { | 44 | for (int i = 0; i < 7; i++) { |
| 46 | arguments[i] = static_cast<u32>(core.GetReg(i + 1)); | 45 | ipc_args[i] = static_cast<u32>(args[i + 1]); |
| 47 | } | 46 | } |
| 48 | 47 | ||
| 49 | Result ret = cb(system, session_handle, arguments.data()); | 48 | Result ret = cb(system, session_handle, ipc_args.data()); |
| 50 | 49 | ||
| 51 | core.SetReg(0, ret.raw); | 50 | args[0] = ret.raw; |
| 52 | for (int i = 0; i < 7; i++) { | 51 | for (int i = 0; i < 7; i++) { |
| 53 | core.SetReg(i + 1, arguments[i]); | 52 | args[i + 1] = ipc_args[i]; |
| 54 | } | 53 | } |
| 55 | } | 54 | } |
| 56 | 55 | ||
| 57 | void SvcWrap_SendSyncRequestLight64(Core::System& system) { | 56 | void SvcWrap_SendSyncRequestLight64(Core::System& system, std::span<uint64_t, 8> args) { |
| 58 | SvcWrap_LightIpc(system, SendSyncRequestLight64); | 57 | SvcWrap_LightIpc(system, args, SendSyncRequestLight64); |
| 59 | } | 58 | } |
| 60 | 59 | ||
| 61 | void SvcWrap_ReplyAndReceiveLight64(Core::System& system) { | 60 | void SvcWrap_ReplyAndReceiveLight64(Core::System& system, std::span<uint64_t, 8> args) { |
| 62 | SvcWrap_LightIpc(system, ReplyAndReceiveLight64); | 61 | SvcWrap_LightIpc(system, args, ReplyAndReceiveLight64); |
| 63 | } | 62 | } |
| 64 | 63 | ||
| 65 | void SvcWrap_SendSyncRequestLight64From32(Core::System& system) { | 64 | void SvcWrap_SendSyncRequestLight64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 66 | SvcWrap_LightIpc(system, SendSyncRequestLight64From32); | 65 | SvcWrap_LightIpc(system, args, SendSyncRequestLight64From32); |
| 67 | } | 66 | } |
| 68 | 67 | ||
| 69 | void SvcWrap_ReplyAndReceiveLight64From32(Core::System& system) { | 68 | void SvcWrap_ReplyAndReceiveLight64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 70 | SvcWrap_LightIpc(system, ReplyAndReceiveLight64From32); | 69 | SvcWrap_LightIpc(system, args, ReplyAndReceiveLight64From32); |
| 71 | } | 70 | } |
| 72 | 71 | ||
| 73 | } // namespace Kernel::Svc | 72 | } // 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 62c781551..48b564ec8 100644 --- a/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp +++ b/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp | |||
| @@ -22,31 +22,29 @@ void CallSecureMonitor64From32(Core::System& system, ilp32::SecureMonitorArgumen | |||
| 22 | 22 | ||
| 23 | // Custom ABI for CallSecureMonitor. | 23 | // Custom ABI for CallSecureMonitor. |
| 24 | 24 | ||
| 25 | void SvcWrap_CallSecureMonitor64(Core::System& system) { | 25 | void SvcWrap_CallSecureMonitor64(Core::System& system, std::span<uint64_t, 8> args) { |
| 26 | auto& core = system.CurrentPhysicalCore().ArmInterface(); | 26 | lp64::SecureMonitorArguments smc_args{}; |
| 27 | lp64::SecureMonitorArguments args{}; | ||
| 28 | for (int i = 0; i < 8; i++) { | 27 | for (int i = 0; i < 8; i++) { |
| 29 | args.r[i] = core.GetReg(i); | 28 | smc_args.r[i] = args[i]; |
| 30 | } | 29 | } |
| 31 | 30 | ||
| 32 | CallSecureMonitor64(system, std::addressof(args)); | 31 | CallSecureMonitor64(system, std::addressof(smc_args)); |
| 33 | 32 | ||
| 34 | for (int i = 0; i < 8; i++) { | 33 | for (int i = 0; i < 8; i++) { |
| 35 | core.SetReg(i, args.r[i]); | 34 | args[i] = smc_args.r[i]; |
| 36 | } | 35 | } |
| 37 | } | 36 | } |
| 38 | 37 | ||
| 39 | void SvcWrap_CallSecureMonitor64From32(Core::System& system) { | 38 | void SvcWrap_CallSecureMonitor64From32(Core::System& system, std::span<uint64_t, 8> args) { |
| 40 | auto& core = system.CurrentPhysicalCore().ArmInterface(); | 39 | ilp32::SecureMonitorArguments smc_args{}; |
| 41 | ilp32::SecureMonitorArguments args{}; | ||
| 42 | for (int i = 0; i < 8; i++) { | 40 | for (int i = 0; i < 8; i++) { |
| 43 | args.r[i] = static_cast<u32>(core.GetReg(i)); | 41 | smc_args.r[i] = static_cast<u32>(args[i]); |
| 44 | } | 42 | } |
| 45 | 43 | ||
| 46 | CallSecureMonitor64From32(system, std::addressof(args)); | 44 | CallSecureMonitor64From32(system, std::addressof(smc_args)); |
| 47 | 45 | ||
| 48 | for (int i = 0; i < 8; i++) { | 46 | for (int i = 0; i < 8; i++) { |
| 49 | core.SetReg(i, args.r[i]); | 47 | args[i] = smc_args.r[i]; |
| 50 | } | 48 | } |
| 51 | } | 49 | } |
| 52 | 50 | ||
diff --git a/src/core/hle/kernel/svc/svc_thread.cpp b/src/core/hle/kernel/svc/svc_thread.cpp index 755fd62b5..7681afa33 100644 --- a/src/core/hle/kernel/svc/svc_thread.cpp +++ b/src/core/hle/kernel/svc/svc_thread.cpp | |||
| @@ -90,8 +90,6 @@ Result StartThread(Core::System& system, Handle thread_handle) { | |||
| 90 | 90 | ||
| 91 | /// Called when a thread exits | 91 | /// Called when a thread exits |
| 92 | void ExitThread(Core::System& system) { | 92 | void ExitThread(Core::System& system) { |
| 93 | LOG_DEBUG(Kernel_SVC, "called, pc=0x{:08X}", system.CurrentArmInterface().GetPC()); | ||
| 94 | |||
| 95 | auto* const current_thread = GetCurrentThreadPointer(system.Kernel()); | 93 | auto* const current_thread = GetCurrentThreadPointer(system.Kernel()); |
| 96 | system.GlobalSchedulerContext().RemoveThread(current_thread); | 94 | system.GlobalSchedulerContext().RemoveThread(current_thread); |
| 97 | current_thread->Exit(); | 95 | current_thread->Exit(); |
| @@ -147,47 +145,19 @@ Result GetThreadContext3(Core::System& system, u64 out_context, Handle thread_ha | |||
| 147 | R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); | 145 | R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); |
| 148 | 146 | ||
| 149 | // Require the handle be to a non-current thread in the current process. | 147 | // Require the handle be to a non-current thread in the current process. |
| 150 | const auto* current_process = GetCurrentProcessPointer(kernel); | 148 | R_UNLESS(thread->GetOwnerProcess() == GetCurrentProcessPointer(kernel), ResultInvalidHandle); |
| 151 | R_UNLESS(current_process == thread->GetOwnerProcess(), ResultInvalidId); | 149 | R_UNLESS(thread.GetPointerUnsafe() != GetCurrentThreadPointer(kernel), ResultBusy); |
| 152 | |||
| 153 | // Verify that the thread isn't terminated. | ||
| 154 | R_UNLESS(thread->GetState() != ThreadState::Terminated, ResultTerminationRequested); | ||
| 155 | |||
| 156 | /// Check that the thread is not the current one. | ||
| 157 | /// NOTE: Nintendo does not check this, and thus the following loop will deadlock. | ||
| 158 | R_UNLESS(thread.GetPointerUnsafe() != GetCurrentThreadPointer(kernel), ResultInvalidId); | ||
| 159 | |||
| 160 | // Try to get the thread context until the thread isn't current on any core. | ||
| 161 | while (true) { | ||
| 162 | KScopedSchedulerLock sl{kernel}; | ||
| 163 | |||
| 164 | // TODO(bunnei): Enforce that thread is suspended for debug here. | ||
| 165 | |||
| 166 | // If the thread's raw state isn't runnable, check if it's current on some core. | ||
| 167 | if (thread->GetRawState() != ThreadState::Runnable) { | ||
| 168 | bool current = false; | ||
| 169 | for (auto i = 0; i < static_cast<s32>(Core::Hardware::NUM_CPU_CORES); ++i) { | ||
| 170 | if (thread.GetPointerUnsafe() == kernel.Scheduler(i).GetSchedulerCurrentThread()) { | ||
| 171 | current = true; | ||
| 172 | break; | ||
| 173 | } | ||
| 174 | } | ||
| 175 | 150 | ||
| 176 | // If the thread is current, retry until it isn't. | 151 | // Get the thread context. |
| 177 | if (current) { | 152 | Svc::ThreadContext context{}; |
| 178 | continue; | 153 | R_TRY(thread->GetThreadContext3(std::addressof(context))); |
| 179 | } | ||
| 180 | } | ||
| 181 | 154 | ||
| 182 | // Get the thread context. | 155 | // Copy the thread context to user space. |
| 183 | static thread_local Common::ScratchBuffer<u8> context; | 156 | R_UNLESS( |
| 184 | R_TRY(thread->GetThreadContext3(context)); | 157 | GetCurrentMemory(kernel).WriteBlock(out_context, std::addressof(context), sizeof(context)), |
| 158 | ResultInvalidPointer); | ||
| 185 | 159 | ||
| 186 | // Copy the thread context to user space. | 160 | R_SUCCEED(); |
| 187 | GetCurrentMemory(kernel).WriteBlock(out_context, context.data(), context.size()); | ||
| 188 | |||
| 189 | R_SUCCEED(); | ||
| 190 | } | ||
| 191 | } | 161 | } |
| 192 | 162 | ||
| 193 | /// Gets the priority for the specified thread | 163 | /// Gets the priority for the specified thread |
diff --git a/src/core/hle/kernel/svc_generator.py b/src/core/hle/kernel/svc_generator.py index 5531faac6..786189ab7 100644 --- a/src/core/hle/kernel/svc_generator.py +++ b/src/core/hle/kernel/svc_generator.py | |||
| @@ -374,11 +374,11 @@ def get_registers(parse_result, bitness): | |||
| 374 | 374 | ||
| 375 | # Collects possibly multiple source registers into the named C++ value. | 375 | # Collects possibly multiple source registers into the named C++ value. |
| 376 | def emit_gather(sources, name, type_name, reg_size): | 376 | def emit_gather(sources, name, type_name, reg_size): |
| 377 | get_fn = f"GetReg{reg_size*8}" | 377 | get_fn = f"GetArg{reg_size*8}" |
| 378 | 378 | ||
| 379 | if len(sources) == 1: | 379 | if len(sources) == 1: |
| 380 | s, = sources | 380 | s, = sources |
| 381 | line = f"{name} = Convert<{type_name}>({get_fn}(system, {s}));" | 381 | line = f"{name} = Convert<{type_name}>({get_fn}(args, {s}));" |
| 382 | return [line] | 382 | return [line] |
| 383 | 383 | ||
| 384 | var_type = f"std::array<uint{reg_size*8}_t, {len(sources)}>" | 384 | var_type = f"std::array<uint{reg_size*8}_t, {len(sources)}>" |
| @@ -387,7 +387,7 @@ def emit_gather(sources, name, type_name, reg_size): | |||
| 387 | ] | 387 | ] |
| 388 | for i in range(0, len(sources)): | 388 | for i in range(0, len(sources)): |
| 389 | lines.append( | 389 | lines.append( |
| 390 | f"{name}_gather[{i}] = {get_fn}(system, {sources[i]});") | 390 | f"{name}_gather[{i}] = {get_fn}(args, {sources[i]});") |
| 391 | 391 | ||
| 392 | lines.append(f"{name} = Convert<{type_name}>({name}_gather);") | 392 | lines.append(f"{name} = Convert<{type_name}>({name}_gather);") |
| 393 | return lines | 393 | return lines |
| @@ -396,12 +396,12 @@ def emit_gather(sources, name, type_name, reg_size): | |||
| 396 | # Produces one or more statements which assign the named C++ value | 396 | # Produces one or more statements which assign the named C++ value |
| 397 | # into possibly multiple registers. | 397 | # into possibly multiple registers. |
| 398 | def emit_scatter(destinations, name, reg_size): | 398 | def emit_scatter(destinations, name, reg_size): |
| 399 | set_fn = f"SetReg{reg_size*8}" | 399 | set_fn = f"SetArg{reg_size*8}" |
| 400 | reg_type = f"uint{reg_size*8}_t" | 400 | reg_type = f"uint{reg_size*8}_t" |
| 401 | 401 | ||
| 402 | if len(destinations) == 1: | 402 | if len(destinations) == 1: |
| 403 | d, = destinations | 403 | d, = destinations |
| 404 | line = f"{set_fn}(system, {d}, Convert<{reg_type}>({name}));" | 404 | line = f"{set_fn}(args, {d}, Convert<{reg_type}>({name}));" |
| 405 | return [line] | 405 | return [line] |
| 406 | 406 | ||
| 407 | var_type = f"std::array<{reg_type}, {len(destinations)}>" | 407 | var_type = f"std::array<{reg_type}, {len(destinations)}>" |
| @@ -411,7 +411,7 @@ def emit_scatter(destinations, name, reg_size): | |||
| 411 | 411 | ||
| 412 | for i in range(0, len(destinations)): | 412 | for i in range(0, len(destinations)): |
| 413 | lines.append( | 413 | lines.append( |
| 414 | f"{set_fn}(system, {destinations[i]}, {name}_scatter[{i}]);") | 414 | f"{set_fn}(args, {destinations[i]}, {name}_scatter[{i}]);") |
| 415 | 415 | ||
| 416 | return lines | 416 | return lines |
| 417 | 417 | ||
| @@ -433,7 +433,7 @@ def emit_lines(lines, indent=' '): | |||
| 433 | def emit_wrapper(wrapped_fn, suffix, register_info, arguments, byte_size): | 433 | def emit_wrapper(wrapped_fn, suffix, register_info, arguments, byte_size): |
| 434 | return_write, output_writes, input_reads = register_info | 434 | return_write, output_writes, input_reads = register_info |
| 435 | lines = [ | 435 | lines = [ |
| 436 | f"static void SvcWrap_{wrapped_fn}{suffix}(Core::System& system) {{" | 436 | f"static void SvcWrap_{wrapped_fn}{suffix}(Core::System& system, std::span<uint64_t, 8> args) {{" |
| 437 | ] | 437 | ] |
| 438 | 438 | ||
| 439 | # Get everything ready. | 439 | # Get everything ready. |
| @@ -498,6 +498,8 @@ namespace Core { | |||
| 498 | class System; | 498 | class System; |
| 499 | } | 499 | } |
| 500 | 500 | ||
| 501 | #include <span> | ||
| 502 | |||
| 501 | #include "common/common_types.h" | 503 | #include "common/common_types.h" |
| 502 | #include "core/hle/kernel/svc_types.h" | 504 | #include "core/hle/kernel/svc_types.h" |
| 503 | #include "core/hle/result.h" | 505 | #include "core/hle/result.h" |
| @@ -524,15 +526,15 @@ void CallSecureMonitor64From32(Core::System& system, ilp32::SecureMonitorArgumen | |||
| 524 | void CallSecureMonitor64(Core::System& system, lp64::SecureMonitorArguments* args); | 526 | void CallSecureMonitor64(Core::System& system, lp64::SecureMonitorArguments* args); |
| 525 | 527 | ||
| 526 | // Defined in svc_light_ipc.cpp. | 528 | // Defined in svc_light_ipc.cpp. |
| 527 | void SvcWrap_ReplyAndReceiveLight64From32(Core::System& system); | 529 | void SvcWrap_ReplyAndReceiveLight64From32(Core::System& system, std::span<uint64_t, 8> args); |
| 528 | void SvcWrap_ReplyAndReceiveLight64(Core::System& system); | 530 | void SvcWrap_ReplyAndReceiveLight64(Core::System& system, std::span<uint64_t, 8> args); |
| 529 | 531 | ||
| 530 | void SvcWrap_SendSyncRequestLight64From32(Core::System& system); | 532 | void SvcWrap_SendSyncRequestLight64From32(Core::System& system, std::span<uint64_t, 8> args); |
| 531 | void SvcWrap_SendSyncRequestLight64(Core::System& system); | 533 | void SvcWrap_SendSyncRequestLight64(Core::System& system, std::span<uint64_t, 8> args); |
| 532 | 534 | ||
| 533 | // Defined in svc_secure_monitor_call.cpp. | 535 | // Defined in svc_secure_monitor_call.cpp. |
| 534 | void SvcWrap_CallSecureMonitor64From32(Core::System& system); | 536 | void SvcWrap_CallSecureMonitor64From32(Core::System& system, std::span<uint64_t, 8> args); |
| 535 | void SvcWrap_CallSecureMonitor64(Core::System& system); | 537 | void SvcWrap_CallSecureMonitor64(Core::System& system, std::span<uint64_t, 8> args); |
| 536 | 538 | ||
| 537 | // Perform a supervisor call by index. | 539 | // Perform a supervisor call by index. |
| 538 | void Call(Core::System& system, u32 imm); | 540 | void Call(Core::System& system, u32 imm); |
| @@ -550,20 +552,20 @@ PROLOGUE_CPP = """ | |||
| 550 | 552 | ||
| 551 | namespace Kernel::Svc { | 553 | namespace Kernel::Svc { |
| 552 | 554 | ||
| 553 | static uint32_t GetReg32(Core::System& system, int n) { | 555 | static uint32_t GetArg32(std::span<uint64_t, 8> args, int n) { |
| 554 | return static_cast<uint32_t>(system.CurrentArmInterface().GetReg(n)); | 556 | return static_cast<uint32_t>(args[n]); |
| 555 | } | 557 | } |
| 556 | 558 | ||
| 557 | static void SetReg32(Core::System& system, int n, uint32_t result) { | 559 | static void SetArg32(std::span<uint64_t, 8> args, int n, uint32_t result) { |
| 558 | system.CurrentArmInterface().SetReg(n, static_cast<uint64_t>(result)); | 560 | args[n] = result; |
| 559 | } | 561 | } |
| 560 | 562 | ||
| 561 | static uint64_t GetReg64(Core::System& system, int n) { | 563 | static uint64_t GetArg64(std::span<uint64_t, 8> args, int n) { |
| 562 | return system.CurrentArmInterface().GetReg(n); | 564 | return args[n]; |
| 563 | } | 565 | } |
| 564 | 566 | ||
| 565 | static void SetReg64(Core::System& system, int n, uint64_t result) { | 567 | static void SetArg64(std::span<uint64_t, 8> args, int n, uint64_t result) { |
| 566 | system.CurrentArmInterface().SetReg(n, result); | 568 | args[n] = result; |
| 567 | } | 569 | } |
| 568 | 570 | ||
| 569 | // Like bit_cast, but handles the case when the source and dest | 571 | // Like bit_cast, but handles the case when the source and dest |
| @@ -590,15 +592,20 @@ EPILOGUE_CPP = """ | |||
| 590 | 592 | ||
| 591 | void Call(Core::System& system, u32 imm) { | 593 | void Call(Core::System& system, u32 imm) { |
| 592 | auto& kernel = system.Kernel(); | 594 | auto& kernel = system.Kernel(); |
| 595 | auto& process = GetCurrentProcess(kernel); | ||
| 596 | |||
| 597 | std::array<uint64_t, 8> args; | ||
| 598 | kernel.CurrentPhysicalCore().SaveSvcArguments(process, args); | ||
| 593 | kernel.EnterSVCProfile(); | 599 | kernel.EnterSVCProfile(); |
| 594 | 600 | ||
| 595 | if (GetCurrentProcess(system.Kernel()).Is64Bit()) { | 601 | if (process.Is64Bit()) { |
| 596 | Call64(system, imm); | 602 | Call64(system, imm, args); |
| 597 | } else { | 603 | } else { |
| 598 | Call32(system, imm); | 604 | Call32(system, imm, args); |
| 599 | } | 605 | } |
| 600 | 606 | ||
| 601 | kernel.ExitSVCProfile(); | 607 | kernel.ExitSVCProfile(); |
| 608 | kernel.CurrentPhysicalCore().LoadSvcArguments(process, args); | ||
| 602 | } | 609 | } |
| 603 | 610 | ||
| 604 | } // namespace Kernel::Svc | 611 | } // namespace Kernel::Svc |
| @@ -609,13 +616,13 @@ def emit_call(bitness, names, suffix): | |||
| 609 | bit_size = REG_SIZES[bitness]*8 | 616 | bit_size = REG_SIZES[bitness]*8 |
| 610 | indent = " " | 617 | indent = " " |
| 611 | lines = [ | 618 | lines = [ |
| 612 | f"static void Call{bit_size}(Core::System& system, u32 imm) {{", | 619 | f"static void Call{bit_size}(Core::System& system, u32 imm, std::span<uint64_t, 8> args) {{", |
| 613 | f"{indent}switch (static_cast<SvcId>(imm)) {{" | 620 | f"{indent}switch (static_cast<SvcId>(imm)) {{" |
| 614 | ] | 621 | ] |
| 615 | 622 | ||
| 616 | for _, name in names: | 623 | for _, name in names: |
| 617 | lines.append(f"{indent}case SvcId::{name}:") | 624 | lines.append(f"{indent}case SvcId::{name}:") |
| 618 | lines.append(f"{indent*2}return SvcWrap_{name}{suffix}(system);") | 625 | lines.append(f"{indent*2}return SvcWrap_{name}{suffix}(system, args);") |
| 619 | 626 | ||
| 620 | lines.append(f"{indent}default:") | 627 | lines.append(f"{indent}default:") |
| 621 | lines.append( | 628 | lines.append( |
diff --git a/src/core/hle/service/jit/jit.cpp b/src/core/hle/service/jit/jit.cpp index be996870f..65851fc05 100644 --- a/src/core/hle/service/jit/jit.cpp +++ b/src/core/hle/service/jit/jit.cpp | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2022 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/debug.h" | ||
| 4 | #include "core/arm/symbols.h" | 5 | #include "core/arm/symbols.h" |
| 5 | #include "core/core.h" | 6 | #include "core/core.h" |
| 6 | #include "core/hle/kernel/k_code_memory.h" | 7 | #include "core/hle/kernel/k_code_memory.h" |
| @@ -98,8 +99,9 @@ public: | |||
| 98 | if (return_value == 0) { | 99 | if (return_value == 0) { |
| 99 | // The callback has written to the output executable code range, | 100 | // The callback has written to the output executable code range, |
| 100 | // requiring an instruction cache invalidation | 101 | // requiring an instruction cache invalidation |
| 101 | system.InvalidateCpuInstructionCacheRange(configuration.user_rx_memory.offset, | 102 | Core::InvalidateInstructionCacheRange(process.GetPointerUnsafe(), |
| 102 | configuration.user_rx_memory.size); | 103 | configuration.user_rx_memory.offset, |
| 104 | configuration.user_rx_memory.size); | ||
| 103 | 105 | ||
| 104 | // Write back to the IPC output buffer, if provided | 106 | // Write back to the IPC output buffer, if provided |
| 105 | if (ctx.CanWriteBuffer()) { | 107 | if (ctx.CanWriteBuffer()) { |
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 5b376b202..169bf4c8c 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -43,13 +43,9 @@ bool AddressSpaceContains(const Common::PageTable& table, const Common::ProcessA | |||
| 43 | struct Memory::Impl { | 43 | struct Memory::Impl { |
| 44 | explicit Impl(Core::System& system_) : system{system_} {} | 44 | explicit Impl(Core::System& system_) : system{system_} {} |
| 45 | 45 | ||
| 46 | void SetCurrentPageTable(Kernel::KProcess& process, u32 core_id) { | 46 | void SetCurrentPageTable(Kernel::KProcess& process) { |
| 47 | current_page_table = &process.GetPageTable().GetImpl(); | 47 | current_page_table = &process.GetPageTable().GetImpl(); |
| 48 | current_page_table->fastmem_arena = system.DeviceMemory().buffer.VirtualBasePointer(); | 48 | current_page_table->fastmem_arena = system.DeviceMemory().buffer.VirtualBasePointer(); |
| 49 | |||
| 50 | const std::size_t address_space_width = process.GetPageTable().GetAddressSpaceWidth(); | ||
| 51 | |||
| 52 | system.ArmInterface(core_id).PageTableChanged(*current_page_table, address_space_width); | ||
| 53 | } | 49 | } |
| 54 | 50 | ||
| 55 | void MapMemoryRegion(Common::PageTable& page_table, Common::ProcessAddress base, u64 size, | 51 | void MapMemoryRegion(Common::PageTable& page_table, Common::ProcessAddress base, u64 size, |
| @@ -871,8 +867,8 @@ void Memory::Reset() { | |||
| 871 | impl = std::make_unique<Impl>(system); | 867 | impl = std::make_unique<Impl>(system); |
| 872 | } | 868 | } |
| 873 | 869 | ||
| 874 | void Memory::SetCurrentPageTable(Kernel::KProcess& process, u32 core_id) { | 870 | void Memory::SetCurrentPageTable(Kernel::KProcess& process) { |
| 875 | impl->SetCurrentPageTable(process, core_id); | 871 | impl->SetCurrentPageTable(process); |
| 876 | } | 872 | } |
| 877 | 873 | ||
| 878 | void Memory::MapMemoryRegion(Common::PageTable& page_table, Common::ProcessAddress base, u64 size, | 874 | void Memory::MapMemoryRegion(Common::PageTable& page_table, Common::ProcessAddress base, u64 size, |
diff --git a/src/core/memory.h b/src/core/memory.h index ed8ebb5eb..c1879e78f 100644 --- a/src/core/memory.h +++ b/src/core/memory.h | |||
| @@ -73,7 +73,7 @@ public: | |||
| 73 | * | 73 | * |
| 74 | * @param process The process to use the page table of. | 74 | * @param process The process to use the page table of. |
| 75 | */ | 75 | */ |
| 76 | void SetCurrentPageTable(Kernel::KProcess& process, u32 core_id); | 76 | void SetCurrentPageTable(Kernel::KProcess& process); |
| 77 | 77 | ||
| 78 | /** | 78 | /** |
| 79 | * Maps an allocated buffer onto a region of the emulated process address space. | 79 | * Maps an allocated buffer onto a region of the emulated process address space. |
diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp index 5d168cbc1..dc3883528 100644 --- a/src/core/reporter.cpp +++ b/src/core/reporter.cpp | |||
| @@ -109,41 +109,11 @@ json GetProcessorStateData(const std::string& architecture, u64 entry_point, u64 | |||
| 109 | return out; | 109 | return out; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | json GetProcessorStateDataAuto(Core::System& system) { | ||
| 113 | const auto* process{system.ApplicationProcess()}; | ||
| 114 | auto& arm{system.CurrentArmInterface()}; | ||
| 115 | |||
| 116 | Core::ARM_Interface::ThreadContext64 context{}; | ||
| 117 | arm.SaveContext(context); | ||
| 118 | |||
| 119 | return GetProcessorStateData(process->Is64Bit() ? "AArch64" : "AArch32", | ||
| 120 | GetInteger(process->GetEntryPoint()), context.sp, context.pc, | ||
| 121 | context.pstate, context.cpu_registers); | ||
| 122 | } | ||
| 123 | |||
| 124 | json GetBacktraceData(Core::System& system) { | ||
| 125 | auto out = json::array(); | ||
| 126 | const auto& backtrace{system.CurrentArmInterface().GetBacktrace()}; | ||
| 127 | for (const auto& entry : backtrace) { | ||
| 128 | out.push_back({ | ||
| 129 | {"module", entry.module}, | ||
| 130 | {"address", fmt::format("{:016X}", entry.address)}, | ||
| 131 | {"original_address", fmt::format("{:016X}", entry.original_address)}, | ||
| 132 | {"offset", fmt::format("{:016X}", entry.offset)}, | ||
| 133 | {"symbol_name", entry.name}, | ||
| 134 | }); | ||
| 135 | } | ||
| 136 | |||
| 137 | return out; | ||
| 138 | } | ||
| 139 | |||
| 140 | json GetFullDataAuto(const std::string& timestamp, u64 title_id, Core::System& system) { | 112 | json GetFullDataAuto(const std::string& timestamp, u64 title_id, Core::System& system) { |
| 141 | json out; | 113 | json out; |
| 142 | 114 | ||
| 143 | out["yuzu_version"] = GetYuzuVersionData(); | 115 | out["yuzu_version"] = GetYuzuVersionData(); |
| 144 | out["report_common"] = GetReportCommonData(title_id, ResultSuccess, timestamp); | 116 | out["report_common"] = GetReportCommonData(title_id, ResultSuccess, timestamp); |
| 145 | out["processor_state"] = GetProcessorStateDataAuto(system); | ||
| 146 | out["backtrace"] = GetBacktraceData(system); | ||
| 147 | 117 | ||
| 148 | return out; | 118 | return out; |
| 149 | } | 119 | } |
| @@ -351,8 +321,6 @@ void Reporter::SaveErrorReport(u64 title_id, Result result, | |||
| 351 | 321 | ||
| 352 | out["yuzu_version"] = GetYuzuVersionData(); | 322 | out["yuzu_version"] = GetYuzuVersionData(); |
| 353 | out["report_common"] = GetReportCommonData(title_id, result, timestamp); | 323 | out["report_common"] = GetReportCommonData(title_id, result, timestamp); |
| 354 | out["processor_state"] = GetProcessorStateDataAuto(system); | ||
| 355 | out["backtrace"] = GetBacktraceData(system); | ||
| 356 | 324 | ||
| 357 | out["error_custom_text"] = { | 325 | out["error_custom_text"] = { |
| 358 | {"main", custom_text_main.value_or("")}, | 326 | {"main", custom_text_main.value_or("")}, |
diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp index 6d227ef8d..c05a05057 100644 --- a/src/yuzu/debugger/wait_tree.cpp +++ b/src/yuzu/debugger/wait_tree.cpp | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include "yuzu/debugger/wait_tree.h" | 7 | #include "yuzu/debugger/wait_tree.h" |
| 8 | #include "yuzu/uisettings.h" | 8 | #include "yuzu/uisettings.h" |
| 9 | 9 | ||
| 10 | #include "core/arm/arm_interface.h" | 10 | #include "core/arm/debug.h" |
| 11 | #include "core/core.h" | 11 | #include "core/core.h" |
| 12 | #include "core/hle/kernel/k_class_token.h" | 12 | #include "core/hle/kernel/k_class_token.h" |
| 13 | #include "core/hle/kernel/k_handle_table.h" | 13 | #include "core/hle/kernel/k_handle_table.h" |
| @@ -129,7 +129,7 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeCallstack::GetChildren() cons | |||
| 129 | return list; | 129 | return list; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | auto backtrace = Core::ARM_Interface::GetBacktraceFromContext(system, thread.GetContext64()); | 132 | auto backtrace = Core::GetBacktraceFromContext(thread.GetOwnerProcess(), thread.GetContext()); |
| 133 | 133 | ||
| 134 | for (auto& entry : backtrace) { | 134 | for (auto& entry : backtrace) { |
| 135 | std::string s = fmt::format("{:20}{:016X} {:016X} {:016X} {}", entry.module, entry.address, | 135 | std::string s = fmt::format("{:20}{:016X} {:016X} {:016X} {}", entry.module, entry.address, |
| @@ -238,10 +238,10 @@ QString WaitTreeThread::GetText() const { | |||
| 238 | break; | 238 | break; |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | const auto& context = thread.GetContext64(); | 241 | const auto& context = thread.GetContext(); |
| 242 | const QString pc_info = tr(" PC = 0x%1 LR = 0x%2") | 242 | const QString pc_info = tr(" PC = 0x%1 LR = 0x%2") |
| 243 | .arg(context.pc, 8, 16, QLatin1Char{'0'}) | 243 | .arg(context.pc, 8, 16, QLatin1Char{'0'}) |
| 244 | .arg(context.cpu_registers[30], 8, 16, QLatin1Char{'0'}); | 244 | .arg(context.lr, 8, 16, QLatin1Char{'0'}); |
| 245 | return QStringLiteral("%1%2 (%3) ") | 245 | return QStringLiteral("%1%2 (%3) ") |
| 246 | .arg(WaitTreeSynchronizationObject::GetText(), pc_info, status); | 246 | .arg(WaitTreeSynchronizationObject::GetText(), pc_info, status); |
| 247 | } | 247 | } |