summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc
diff options
context:
space:
mode:
authorGravatar Liam2023-02-05 14:22:02 -0500
committerGravatar Liam2023-02-06 23:57:44 -0500
commit2415d37ea296e8856267375989a8b95cebe2575a (patch)
tree376baf5952a8ccc15b445702d38c056ffa71dd1b /src/core/hle/kernel/svc
parentMerge pull request #9731 from liamwhite/svc-move-only (diff)
downloadyuzu-2415d37ea296e8856267375989a8b95cebe2575a.tar.gz
yuzu-2415d37ea296e8856267375989a8b95cebe2575a.tar.xz
yuzu-2415d37ea296e8856267375989a8b95cebe2575a.zip
kernel/svc: switch to generated wrappers
Diffstat (limited to 'src/core/hle/kernel/svc')
-rw-r--r--src/core/hle/kernel/svc/svc_activity.cpp23
-rw-r--r--src/core/hle/kernel/svc/svc_address_arbiter.cpp23
-rw-r--r--src/core/hle/kernel/svc/svc_address_translation.cpp46
-rw-r--r--src/core/hle/kernel/svc/svc_cache.cpp69
-rw-r--r--src/core/hle/kernel/svc/svc_code_memory.cpp34
-rw-r--r--src/core/hle/kernel/svc/svc_condition_variable.cpp22
-rw-r--r--src/core/hle/kernel/svc/svc_debug.cpp190
-rw-r--r--src/core/hle/kernel/svc/svc_debug_string.cpp16
-rw-r--r--src/core/hle/kernel/svc/svc_device_address_space.cpp249
-rw-r--r--src/core/hle/kernel/svc/svc_event.cpp33
-rw-r--r--src/core/hle/kernel/svc/svc_exception.cpp32
-rw-r--r--src/core/hle/kernel/svc/svc_info.cpp35
-rw-r--r--src/core/hle/kernel/svc/svc_insecure_memory.cpp35
-rw-r--r--src/core/hle/kernel/svc/svc_interrupt_event.cpp21
-rw-r--r--src/core/hle/kernel/svc/svc_io_pool.cpp67
-rw-r--r--src/core/hle/kernel/svc/svc_ipc.cpp97
-rw-r--r--src/core/hle/kernel/svc/svc_kernel_debug.cpp26
-rw-r--r--src/core/hle/kernel/svc/svc_light_ipc.cpp69
-rw-r--r--src/core/hle/kernel/svc/svc_lock.cpp21
-rw-r--r--src/core/hle/kernel/svc/svc_memory.cpp48
-rw-r--r--src/core/hle/kernel/svc/svc_physical_memory.cpp74
-rw-r--r--src/core/hle/kernel/svc/svc_port.cpp55
-rw-r--r--src/core/hle/kernel/svc/svc_power_management.cpp17
-rw-r--r--src/core/hle/kernel/svc/svc_process.cpp112
-rw-r--r--src/core/hle/kernel/svc/svc_process_memory.cpp50
-rw-r--r--src/core/hle/kernel/svc/svc_processor.cpp10
-rw-r--r--src/core/hle/kernel/svc/svc_query_memory.cpp54
-rw-r--r--src/core/hle/kernel/svc/svc_register.cpp23
-rw-r--r--src/core/hle/kernel/svc/svc_resource_limit.cpp60
-rw-r--r--src/core/hle/kernel/svc/svc_secure_monitor_call.cpp49
-rw-r--r--src/core/hle/kernel/svc/svc_session.cpp29
-rw-r--r--src/core/hle/kernel/svc/svc_shared_memory.cpp41
-rw-r--r--src/core/hle/kernel/svc/svc_synchronization.cpp60
-rw-r--r--src/core/hle/kernel/svc/svc_thread.cpp163
-rw-r--r--src/core/hle/kernel/svc/svc_thread_profiler.cpp56
-rw-r--r--src/core/hle/kernel/svc/svc_tick.cpp14
-rw-r--r--src/core/hle/kernel/svc/svc_transfer_memory.cpp44
37 files changed, 1809 insertions, 258 deletions
diff --git a/src/core/hle/kernel/svc/svc_activity.cpp b/src/core/hle/kernel/svc/svc_activity.cpp
index 8774a5c98..1dcdb7a15 100644
--- a/src/core/hle/kernel/svc/svc_activity.cpp
+++ b/src/core/hle/kernel/svc/svc_activity.cpp
@@ -36,9 +36,30 @@ Result SetThreadActivity(Core::System& system, Handle thread_handle,
36 return ResultSuccess; 36 return ResultSuccess;
37} 37}
38 38
39Result SetThreadActivity32(Core::System& system, Handle thread_handle, 39Result SetProcessActivity(Core::System& system, Handle process_handle,
40 ProcessActivity process_activity) {
41 UNIMPLEMENTED();
42 R_THROW(ResultNotImplemented);
43}
44
45Result SetThreadActivity64(Core::System& system, Handle thread_handle,
40 ThreadActivity thread_activity) { 46 ThreadActivity thread_activity) {
41 return SetThreadActivity(system, thread_handle, thread_activity); 47 return SetThreadActivity(system, thread_handle, thread_activity);
42} 48}
43 49
50Result SetProcessActivity64(Core::System& system, Handle process_handle,
51 ProcessActivity process_activity) {
52 return SetProcessActivity(system, process_handle, process_activity);
53}
54
55Result SetThreadActivity64From32(Core::System& system, Handle thread_handle,
56 ThreadActivity thread_activity) {
57 return SetThreadActivity(system, thread_handle, thread_activity);
58}
59
60Result SetProcessActivity64From32(Core::System& system, Handle process_handle,
61 ProcessActivity process_activity) {
62 return SetProcessActivity(system, process_handle, process_activity);
63}
64
44} // namespace Kernel::Svc 65} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_address_arbiter.cpp b/src/core/hle/kernel/svc/svc_address_arbiter.cpp
index 842107726..e6a5d2ae5 100644
--- a/src/core/hle/kernel/svc/svc_address_arbiter.cpp
+++ b/src/core/hle/kernel/svc/svc_address_arbiter.cpp
@@ -75,12 +75,6 @@ Result WaitForAddress(Core::System& system, VAddr address, ArbitrationType arb_t
75 return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout); 75 return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout);
76} 76}
77 77
78Result WaitForAddress32(Core::System& system, u32 address, ArbitrationType arb_type, s32 value,
79 u32 timeout_ns_low, u32 timeout_ns_high) {
80 const auto timeout = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32));
81 return WaitForAddress(system, address, arb_type, value, timeout);
82}
83
84// Signals to an address (via Address Arbiter) 78// Signals to an address (via Address Arbiter)
85Result SignalToAddress(Core::System& system, VAddr address, SignalType signal_type, s32 value, 79Result SignalToAddress(Core::System& system, VAddr address, SignalType signal_type, s32 value,
86 s32 count) { 80 s32 count) {
@@ -105,9 +99,24 @@ Result SignalToAddress(Core::System& system, VAddr address, SignalType signal_ty
105 count); 99 count);
106} 100}
107 101
108Result SignalToAddress32(Core::System& system, u32 address, SignalType signal_type, s32 value, 102Result WaitForAddress64(Core::System& system, VAddr address, ArbitrationType arb_type, s32 value,
103 s64 timeout_ns) {
104 return WaitForAddress(system, address, arb_type, value, timeout_ns);
105}
106
107Result SignalToAddress64(Core::System& system, VAddr address, SignalType signal_type, s32 value,
109 s32 count) { 108 s32 count) {
110 return SignalToAddress(system, address, signal_type, value, count); 109 return SignalToAddress(system, address, signal_type, value, count);
111} 110}
112 111
112Result WaitForAddress64From32(Core::System& system, u32 address, ArbitrationType arb_type,
113 s32 value, s64 timeout_ns) {
114 return WaitForAddress(system, address, arb_type, value, timeout_ns);
115}
116
117Result SignalToAddress64From32(Core::System& system, u32 address, SignalType signal_type, s32 value,
118 s32 count) {
119 return SignalToAddress(system, address, signal_type, value, count);
120}
121
113} // namespace Kernel::Svc 122} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_address_translation.cpp b/src/core/hle/kernel/svc/svc_address_translation.cpp
index 299e22ae6..c25e144cd 100644
--- a/src/core/hle/kernel/svc/svc_address_translation.cpp
+++ b/src/core/hle/kernel/svc/svc_address_translation.cpp
@@ -2,5 +2,49 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "core/hle/kernel/svc.h" 4#include "core/hle/kernel/svc.h"
5#include "core/hle/kernel/svc_results.h"
5 6
6namespace Kernel::Svc {} // namespace Kernel::Svc 7namespace Kernel::Svc {
8
9Result QueryPhysicalAddress(Core::System& system, lp64::PhysicalMemoryInfo* out_info,
10 uint64_t address) {
11 UNIMPLEMENTED();
12 R_THROW(ResultNotImplemented);
13}
14
15Result QueryIoMapping(Core::System& system, uintptr_t* out_address, uintptr_t* out_size,
16 uint64_t physical_address, uint64_t size) {
17 UNIMPLEMENTED();
18 R_THROW(ResultNotImplemented);
19}
20
21Result QueryPhysicalAddress64(Core::System& system, lp64::PhysicalMemoryInfo* out_info,
22 uint64_t address) {
23 R_RETURN(QueryPhysicalAddress(system, out_info, address));
24}
25
26Result QueryIoMapping64(Core::System& system, uintptr_t* out_address, uintptr_t* out_size,
27 uint64_t physical_address, uint64_t size) {
28 R_RETURN(QueryIoMapping(system, out_address, out_size, physical_address, size));
29}
30
31Result QueryPhysicalAddress64From32(Core::System& system, ilp32::PhysicalMemoryInfo* out_info,
32 uint32_t address) {
33 lp64::PhysicalMemoryInfo info{};
34 R_TRY(QueryPhysicalAddress(system, std::addressof(info), address));
35
36 *out_info = {
37 .physical_address = info.physical_address,
38 .virtual_address = static_cast<u32>(info.virtual_address),
39 .size = static_cast<u32>(info.size),
40 };
41 R_SUCCEED();
42}
43
44Result QueryIoMapping64From32(Core::System& system, uintptr_t* out_address, uintptr_t* out_size,
45 uint64_t physical_address, uint32_t size) {
46 R_RETURN(QueryIoMapping(system, reinterpret_cast<uintptr_t*>(out_address),
47 reinterpret_cast<uintptr_t*>(out_size), physical_address, size));
48}
49
50} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_cache.cpp b/src/core/hle/kernel/svc/svc_cache.cpp
index 42167d35b..b5404760e 100644
--- a/src/core/hle/kernel/svc/svc_cache.cpp
+++ b/src/core/hle/kernel/svc/svc_cache.cpp
@@ -9,7 +9,28 @@
9 9
10namespace Kernel::Svc { 10namespace Kernel::Svc {
11 11
12Result FlushProcessDataCache32(Core::System& system, Handle process_handle, u64 address, u64 size) { 12void FlushEntireDataCache(Core::System& system) {
13 UNIMPLEMENTED();
14}
15
16Result FlushDataCache(Core::System& system, VAddr address, size_t size) {
17 UNIMPLEMENTED();
18 R_THROW(ResultNotImplemented);
19}
20
21Result InvalidateProcessDataCache(Core::System& system, Handle process_handle, uint64_t address,
22 uint64_t size) {
23 UNIMPLEMENTED();
24 R_THROW(ResultNotImplemented);
25}
26
27Result StoreProcessDataCache(Core::System& system, Handle process_handle, uint64_t address,
28 uint64_t size) {
29 UNIMPLEMENTED();
30 R_THROW(ResultNotImplemented);
31}
32
33Result FlushProcessDataCache(Core::System& system, Handle process_handle, u64 address, u64 size) {
13 // Validate address/size. 34 // Validate address/size.
14 R_UNLESS(size > 0, ResultInvalidSize); 35 R_UNLESS(size > 0, ResultInvalidSize);
15 R_UNLESS(address == static_cast<uintptr_t>(address), ResultInvalidCurrentMemory); 36 R_UNLESS(address == static_cast<uintptr_t>(address), ResultInvalidCurrentMemory);
@@ -28,4 +49,50 @@ Result FlushProcessDataCache32(Core::System& system, Handle process_handle, u64
28 R_RETURN(system.Memory().FlushDataCache(*process, address, size)); 49 R_RETURN(system.Memory().FlushDataCache(*process, address, size));
29} 50}
30 51
52void FlushEntireDataCache64(Core::System& system) {
53 FlushEntireDataCache(system);
54}
55
56Result FlushDataCache64(Core::System& system, VAddr address, size_t size) {
57 R_RETURN(FlushDataCache(system, address, size));
58}
59
60Result InvalidateProcessDataCache64(Core::System& system, Handle process_handle, uint64_t address,
61 uint64_t size) {
62 R_RETURN(InvalidateProcessDataCache(system, process_handle, address, size));
63}
64
65Result StoreProcessDataCache64(Core::System& system, Handle process_handle, uint64_t address,
66 uint64_t size) {
67 R_RETURN(StoreProcessDataCache(system, process_handle, address, size));
68}
69
70Result FlushProcessDataCache64(Core::System& system, Handle process_handle, uint64_t address,
71 uint64_t size) {
72 R_RETURN(FlushProcessDataCache(system, process_handle, address, size));
73}
74
75void FlushEntireDataCache64From32(Core::System& system) {
76 return FlushEntireDataCache(system);
77}
78
79Result FlushDataCache64From32(Core::System& system, uint32_t address, uint32_t size) {
80 R_RETURN(FlushDataCache(system, address, size));
81}
82
83Result InvalidateProcessDataCache64From32(Core::System& system, Handle process_handle,
84 uint64_t address, uint64_t size) {
85 R_RETURN(InvalidateProcessDataCache(system, process_handle, address, size));
86}
87
88Result StoreProcessDataCache64From32(Core::System& system, Handle process_handle, uint64_t address,
89 uint64_t size) {
90 R_RETURN(StoreProcessDataCache(system, process_handle, address, size));
91}
92
93Result FlushProcessDataCache64From32(Core::System& system, Handle process_handle, uint64_t address,
94 uint64_t size) {
95 R_RETURN(FlushProcessDataCache(system, process_handle, address, size));
96}
97
31} // namespace Kernel::Svc 98} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_code_memory.cpp b/src/core/hle/kernel/svc/svc_code_memory.cpp
index 4cb21e101..ec256b757 100644
--- a/src/core/hle/kernel/svc/svc_code_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_code_memory.cpp
@@ -63,12 +63,9 @@ Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t
63 return ResultSuccess; 63 return ResultSuccess;
64} 64}
65 65
66Result CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size) { 66Result ControlCodeMemory(Core::System& system, Handle code_memory_handle,
67 return CreateCodeMemory(system, out, address, size); 67 CodeMemoryOperation operation, VAddr address, size_t size,
68} 68 MemoryPermission perm) {
69
70Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation,
71 VAddr address, size_t size, MemoryPermission perm) {
72 69
73 LOG_TRACE(Kernel_SVC, 70 LOG_TRACE(Kernel_SVC,
74 "called, code_memory_handle=0x{:X}, operation=0x{:X}, address=0x{:X}, size=0x{:X}, " 71 "called, code_memory_handle=0x{:X}, operation=0x{:X}, address=0x{:X}, size=0x{:X}, "
@@ -90,7 +87,7 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 op
90 // This enables homebrew usage of these SVCs for JIT. 87 // This enables homebrew usage of these SVCs for JIT.
91 88
92 // Perform the operation. 89 // Perform the operation.
93 switch (static_cast<CodeMemoryOperation>(operation)) { 90 switch (operation) {
94 case CodeMemoryOperation::Map: { 91 case CodeMemoryOperation::Map: {
95 // Check that the region is in range. 92 // Check that the region is in range.
96 R_UNLESS( 93 R_UNLESS(
@@ -146,9 +143,26 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 op
146 return ResultSuccess; 143 return ResultSuccess;
147} 144}
148 145
149Result ControlCodeMemory32(Core::System& system, Handle code_memory_handle, u32 operation, 146Result CreateCodeMemory64(Core::System& system, Handle* out_handle, uint64_t address,
150 u64 address, u64 size, MemoryPermission perm) { 147 uint64_t size) {
151 return ControlCodeMemory(system, code_memory_handle, operation, address, size, perm); 148 R_RETURN(CreateCodeMemory(system, out_handle, address, size));
149}
150
151Result ControlCodeMemory64(Core::System& system, Handle code_memory_handle,
152 CodeMemoryOperation operation, uint64_t address, uint64_t size,
153 MemoryPermission perm) {
154 R_RETURN(ControlCodeMemory(system, code_memory_handle, operation, address, size, perm));
155}
156
157Result CreateCodeMemory64From32(Core::System& system, Handle* out_handle, uint32_t address,
158 uint32_t size) {
159 R_RETURN(CreateCodeMemory(system, out_handle, address, size));
160}
161
162Result ControlCodeMemory64From32(Core::System& system, Handle code_memory_handle,
163 CodeMemoryOperation operation, uint64_t address, uint64_t size,
164 MemoryPermission perm) {
165 R_RETURN(ControlCodeMemory(system, code_memory_handle, operation, address, size, perm));
152} 166}
153 167
154} // namespace Kernel::Svc 168} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_condition_variable.cpp b/src/core/hle/kernel/svc/svc_condition_variable.cpp
index d6cfc87c5..b59a33e68 100644
--- a/src/core/hle/kernel/svc/svc_condition_variable.cpp
+++ b/src/core/hle/kernel/svc/svc_condition_variable.cpp
@@ -47,12 +47,6 @@ Result WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_ke
47 address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout); 47 address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout);
48} 48}
49 49
50Result WaitProcessWideKeyAtomic32(Core::System& system, u32 address, u32 cv_key, u32 tag,
51 u32 timeout_ns_low, u32 timeout_ns_high) {
52 const auto timeout_ns = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32));
53 return WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns);
54}
55
56/// Signal process wide key 50/// Signal process wide key
57void SignalProcessWideKey(Core::System& system, VAddr cv_key, s32 count) { 51void SignalProcessWideKey(Core::System& system, VAddr cv_key, s32 count) {
58 LOG_TRACE(Kernel_SVC, "called, cv_key=0x{:X}, count=0x{:08X}", cv_key, count); 52 LOG_TRACE(Kernel_SVC, "called, cv_key=0x{:X}, count=0x{:08X}", cv_key, count);
@@ -62,7 +56,21 @@ void SignalProcessWideKey(Core::System& system, VAddr cv_key, s32 count) {
62 Common::AlignDown(cv_key, sizeof(u32)), count); 56 Common::AlignDown(cv_key, sizeof(u32)), count);
63} 57}
64 58
65void SignalProcessWideKey32(Core::System& system, u32 cv_key, s32 count) { 59Result WaitProcessWideKeyAtomic64(Core::System& system, uint64_t address, uint64_t cv_key,
60 uint32_t tag, int64_t timeout_ns) {
61 R_RETURN(WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns));
62}
63
64void SignalProcessWideKey64(Core::System& system, uint64_t cv_key, int32_t count) {
65 SignalProcessWideKey(system, cv_key, count);
66}
67
68Result WaitProcessWideKeyAtomic64From32(Core::System& system, uint32_t address, uint32_t cv_key,
69 uint32_t tag, int64_t timeout_ns) {
70 R_RETURN(WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns));
71}
72
73void SignalProcessWideKey64From32(Core::System& system, uint32_t cv_key, int32_t count) {
66 SignalProcessWideKey(system, cv_key, count); 74 SignalProcessWideKey(system, cv_key, count);
67} 75}
68 76
diff --git a/src/core/hle/kernel/svc/svc_debug.cpp b/src/core/hle/kernel/svc/svc_debug.cpp
index 299e22ae6..a14050fa7 100644
--- a/src/core/hle/kernel/svc/svc_debug.cpp
+++ b/src/core/hle/kernel/svc/svc_debug.cpp
@@ -2,5 +2,193 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "core/hle/kernel/svc.h" 4#include "core/hle/kernel/svc.h"
5#include "core/hle/kernel/svc_results.h"
5 6
6namespace Kernel::Svc {} // namespace Kernel::Svc 7namespace Kernel::Svc {
8
9Result DebugActiveProcess(Core::System& system, Handle* out_handle, uint64_t process_id) {
10 UNIMPLEMENTED();
11 R_THROW(ResultNotImplemented);
12}
13
14Result BreakDebugProcess(Core::System& system, Handle debug_handle) {
15 UNIMPLEMENTED();
16 R_THROW(ResultNotImplemented);
17}
18
19Result TerminateDebugProcess(Core::System& system, Handle debug_handle) {
20 UNIMPLEMENTED();
21 R_THROW(ResultNotImplemented);
22}
23
24Result GetDebugEvent(Core::System& system, uint64_t out_info, Handle debug_handle) {
25 UNIMPLEMENTED();
26 R_THROW(ResultNotImplemented);
27}
28
29Result ContinueDebugEvent(Core::System& system, Handle debug_handle, uint32_t flags,
30 uint64_t user_thread_ids, int32_t num_thread_ids) {
31 UNIMPLEMENTED();
32 R_THROW(ResultNotImplemented);
33}
34
35Result GetDebugThreadContext(Core::System& system, uint64_t out_context, Handle debug_handle,
36 uint64_t thread_id, uint32_t context_flags) {
37 UNIMPLEMENTED();
38 R_THROW(ResultNotImplemented);
39}
40
41Result SetDebugThreadContext(Core::System& system, Handle debug_handle, uint64_t thread_id,
42 uint64_t user_context, uint32_t context_flags) {
43 UNIMPLEMENTED();
44 R_THROW(ResultNotImplemented);
45}
46
47Result QueryDebugProcessMemory(Core::System& system, uint64_t out_memory_info,
48 PageInfo* out_page_info, Handle debug_handle, uintptr_t address) {
49 UNIMPLEMENTED();
50 R_THROW(ResultNotImplemented);
51}
52
53Result ReadDebugProcessMemory(Core::System& system, uintptr_t buffer, Handle debug_handle,
54 uintptr_t address, size_t size) {
55 UNIMPLEMENTED();
56 R_THROW(ResultNotImplemented);
57}
58
59Result WriteDebugProcessMemory(Core::System& system, Handle debug_handle, uintptr_t buffer,
60 uintptr_t address, size_t size) {
61 UNIMPLEMENTED();
62 R_THROW(ResultNotImplemented);
63}
64
65Result SetHardwareBreakPoint(Core::System& system, HardwareBreakPointRegisterName name,
66 uint64_t flags, uint64_t value) {
67 UNIMPLEMENTED();
68 R_THROW(ResultNotImplemented);
69}
70
71Result GetDebugThreadParam(Core::System& system, uint64_t* out_64, uint32_t* out_32,
72 Handle debug_handle, uint64_t thread_id, DebugThreadParam param) {
73 UNIMPLEMENTED();
74 R_THROW(ResultNotImplemented);
75}
76
77Result DebugActiveProcess64(Core::System& system, Handle* out_handle, uint64_t process_id) {
78 R_RETURN(DebugActiveProcess(system, out_handle, process_id));
79}
80
81Result BreakDebugProcess64(Core::System& system, Handle debug_handle) {
82 R_RETURN(BreakDebugProcess(system, debug_handle));
83}
84
85Result TerminateDebugProcess64(Core::System& system, Handle debug_handle) {
86 R_RETURN(TerminateDebugProcess(system, debug_handle));
87}
88
89Result GetDebugEvent64(Core::System& system, uint64_t out_info, Handle debug_handle) {
90 R_RETURN(GetDebugEvent(system, out_info, debug_handle));
91}
92
93Result ContinueDebugEvent64(Core::System& system, Handle debug_handle, uint32_t flags,
94 uint64_t thread_ids, int32_t num_thread_ids) {
95 R_RETURN(ContinueDebugEvent(system, debug_handle, flags, thread_ids, num_thread_ids));
96}
97
98Result GetDebugThreadContext64(Core::System& system, uint64_t out_context, Handle debug_handle,
99 uint64_t thread_id, uint32_t context_flags) {
100 R_RETURN(GetDebugThreadContext(system, out_context, debug_handle, thread_id, context_flags));
101}
102
103Result SetDebugThreadContext64(Core::System& system, Handle debug_handle, uint64_t thread_id,
104 uint64_t context, uint32_t context_flags) {
105 R_RETURN(SetDebugThreadContext(system, debug_handle, thread_id, context, context_flags));
106}
107
108Result QueryDebugProcessMemory64(Core::System& system, uint64_t out_memory_info,
109 PageInfo* out_page_info, Handle debug_handle, uint64_t address) {
110 R_RETURN(
111 QueryDebugProcessMemory(system, out_memory_info, out_page_info, debug_handle, address));
112}
113
114Result ReadDebugProcessMemory64(Core::System& system, uint64_t buffer, Handle debug_handle,
115 uint64_t address, uint64_t size) {
116 R_RETURN(ReadDebugProcessMemory(system, buffer, debug_handle, address, size));
117}
118
119Result WriteDebugProcessMemory64(Core::System& system, Handle debug_handle, uint64_t buffer,
120 uint64_t address, uint64_t size) {
121 R_RETURN(WriteDebugProcessMemory(system, debug_handle, buffer, address, size));
122}
123
124Result SetHardwareBreakPoint64(Core::System& system, HardwareBreakPointRegisterName name,
125 uint64_t flags, uint64_t value) {
126 R_RETURN(SetHardwareBreakPoint(system, name, flags, value));
127}
128
129Result GetDebugThreadParam64(Core::System& system, uint64_t* out_64, uint32_t* out_32,
130 Handle debug_handle, uint64_t thread_id, DebugThreadParam param) {
131 R_RETURN(GetDebugThreadParam(system, out_64, out_32, debug_handle, thread_id, param));
132}
133
134Result DebugActiveProcess64From32(Core::System& system, Handle* out_handle, uint64_t process_id) {
135 R_RETURN(DebugActiveProcess(system, out_handle, process_id));
136}
137
138Result BreakDebugProcess64From32(Core::System& system, Handle debug_handle) {
139 R_RETURN(BreakDebugProcess(system, debug_handle));
140}
141
142Result TerminateDebugProcess64From32(Core::System& system, Handle debug_handle) {
143 R_RETURN(TerminateDebugProcess(system, debug_handle));
144}
145
146Result GetDebugEvent64From32(Core::System& system, uint32_t out_info, Handle debug_handle) {
147 R_RETURN(GetDebugEvent(system, out_info, debug_handle));
148}
149
150Result ContinueDebugEvent64From32(Core::System& system, Handle debug_handle, uint32_t flags,
151 uint32_t thread_ids, int32_t num_thread_ids) {
152 R_RETURN(ContinueDebugEvent(system, debug_handle, flags, thread_ids, num_thread_ids));
153}
154
155Result GetDebugThreadContext64From32(Core::System& system, uint32_t out_context,
156 Handle debug_handle, uint64_t thread_id,
157 uint32_t context_flags) {
158 R_RETURN(GetDebugThreadContext(system, out_context, debug_handle, thread_id, context_flags));
159}
160
161Result SetDebugThreadContext64From32(Core::System& system, Handle debug_handle, uint64_t thread_id,
162 uint32_t context, uint32_t context_flags) {
163 R_RETURN(SetDebugThreadContext(system, debug_handle, thread_id, context, context_flags));
164}
165
166Result QueryDebugProcessMemory64From32(Core::System& system, uint32_t out_memory_info,
167 PageInfo* out_page_info, Handle debug_handle,
168 uint32_t address) {
169 R_RETURN(
170 QueryDebugProcessMemory(system, out_memory_info, out_page_info, debug_handle, address));
171}
172
173Result ReadDebugProcessMemory64From32(Core::System& system, uint32_t buffer, Handle debug_handle,
174 uint32_t address, uint32_t size) {
175 R_RETURN(ReadDebugProcessMemory(system, buffer, debug_handle, address, size));
176}
177
178Result WriteDebugProcessMemory64From32(Core::System& system, Handle debug_handle, uint32_t buffer,
179 uint32_t address, uint32_t size) {
180 R_RETURN(WriteDebugProcessMemory(system, debug_handle, buffer, address, size));
181}
182
183Result SetHardwareBreakPoint64From32(Core::System& system, HardwareBreakPointRegisterName name,
184 uint64_t flags, uint64_t value) {
185 R_RETURN(SetHardwareBreakPoint(system, name, flags, value));
186}
187
188Result GetDebugThreadParam64From32(Core::System& system, uint64_t* out_64, uint32_t* out_32,
189 Handle debug_handle, uint64_t thread_id,
190 DebugThreadParam param) {
191 R_RETURN(GetDebugThreadParam(system, out_64, out_32, debug_handle, thread_id, param));
192}
193
194} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_debug_string.cpp b/src/core/hle/kernel/svc/svc_debug_string.cpp
index 486e62cc4..d4bf062d1 100644
--- a/src/core/hle/kernel/svc/svc_debug_string.cpp
+++ b/src/core/hle/kernel/svc/svc_debug_string.cpp
@@ -8,18 +8,22 @@
8namespace Kernel::Svc { 8namespace Kernel::Svc {
9 9
10/// Used to output a message on a debug hardware unit - does nothing on a retail unit 10/// Used to output a message on a debug hardware unit - does nothing on a retail unit
11void OutputDebugString(Core::System& system, VAddr address, u64 len) { 11Result OutputDebugString(Core::System& system, VAddr address, u64 len) {
12 if (len == 0) { 12 R_SUCCEED_IF(len == 0);
13 return;
14 }
15 13
16 std::string str(len, '\0'); 14 std::string str(len, '\0');
17 system.Memory().ReadBlock(address, str.data(), str.size()); 15 system.Memory().ReadBlock(address, str.data(), str.size());
18 LOG_DEBUG(Debug_Emulated, "{}", str); 16 LOG_DEBUG(Debug_Emulated, "{}", str);
17
18 R_SUCCEED();
19}
20
21Result OutputDebugString64(Core::System& system, uint64_t debug_str, uint64_t len) {
22 R_RETURN(OutputDebugString(system, debug_str, len));
19} 23}
20 24
21void OutputDebugString32(Core::System& system, u32 address, u32 len) { 25Result OutputDebugString64From32(Core::System& system, uint32_t debug_str, uint32_t len) {
22 OutputDebugString(system, address, len); 26 R_RETURN(OutputDebugString(system, debug_str, len));
23} 27}
24 28
25} // namespace Kernel::Svc 29} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_device_address_space.cpp b/src/core/hle/kernel/svc/svc_device_address_space.cpp
index 299e22ae6..cdc453c35 100644
--- a/src/core/hle/kernel/svc/svc_device_address_space.cpp
+++ b/src/core/hle/kernel/svc/svc_device_address_space.cpp
@@ -1,6 +1,253 @@
1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "common/alignment.h"
5#include "common/scope_exit.h"
6#include "core/core.h"
7#include "core/hle/kernel/k_device_address_space.h"
8#include "core/hle/kernel/k_process.h"
4#include "core/hle/kernel/svc.h" 9#include "core/hle/kernel/svc.h"
5 10
6namespace Kernel::Svc {} // namespace Kernel::Svc 11namespace Kernel::Svc {
12
13constexpr inline u64 DeviceAddressSpaceAlignMask = (1ULL << 22) - 1;
14
15constexpr bool IsProcessAndDeviceAligned(uint64_t process_address, uint64_t device_address) {
16 return (process_address & DeviceAddressSpaceAlignMask) ==
17 (device_address & DeviceAddressSpaceAlignMask);
18}
19
20Result CreateDeviceAddressSpace(Core::System& system, Handle* out, uint64_t das_address,
21 uint64_t das_size) {
22 // Validate input.
23 R_UNLESS(Common::IsAligned(das_address, PageSize), ResultInvalidMemoryRegion);
24 R_UNLESS(Common::IsAligned(das_size, PageSize), ResultInvalidMemoryRegion);
25 R_UNLESS(das_size > 0, ResultInvalidMemoryRegion);
26 R_UNLESS((das_address < das_address + das_size), ResultInvalidMemoryRegion);
27
28 // Create the device address space.
29 KDeviceAddressSpace* das = KDeviceAddressSpace::Create(system.Kernel());
30 R_UNLESS(das != nullptr, ResultOutOfResource);
31 SCOPE_EXIT({ das->Close(); });
32
33 // Initialize the device address space.
34 R_TRY(das->Initialize(das_address, das_size));
35
36 // Register the device address space.
37 KDeviceAddressSpace::Register(system.Kernel(), das);
38
39 // Add to the handle table.
40 R_TRY(system.CurrentProcess()->GetHandleTable().Add(out, das));
41
42 R_SUCCEED();
43}
44
45Result AttachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) {
46 // Get the device address space.
47 KScopedAutoObject das =
48 system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle);
49 R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
50
51 // Attach.
52 R_RETURN(das->Attach(device_name));
53}
54
55Result DetachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) {
56 // Get the device address space.
57 KScopedAutoObject das =
58 system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle);
59 R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
60
61 // Detach.
62 R_RETURN(das->Detach(device_name));
63}
64
65constexpr bool IsValidDeviceMemoryPermission(MemoryPermission device_perm) {
66 switch (device_perm) {
67 case MemoryPermission::Read:
68 case MemoryPermission::Write:
69 case MemoryPermission::ReadWrite:
70 return true;
71 default:
72 return false;
73 }
74}
75
76Result MapDeviceAddressSpaceByForce(Core::System& system, Handle das_handle, Handle process_handle,
77 uint64_t process_address, size_t size, uint64_t device_address,
78 u32 option) {
79 // Decode the option.
80 const MapDeviceAddressSpaceOption option_pack{option};
81 const auto device_perm = option_pack.permission;
82 const auto reserved = option_pack.reserved;
83
84 // Validate input.
85 R_UNLESS(Common::IsAligned(process_address, PageSize), ResultInvalidAddress);
86 R_UNLESS(Common::IsAligned(device_address, PageSize), ResultInvalidAddress);
87 R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize);
88 R_UNLESS(size > 0, ResultInvalidSize);
89 R_UNLESS((process_address < process_address + size), ResultInvalidCurrentMemory);
90 R_UNLESS((device_address < device_address + size), ResultInvalidMemoryRegion);
91 R_UNLESS((process_address == static_cast<uintptr_t>(process_address)),
92 ResultInvalidCurrentMemory);
93 R_UNLESS(IsValidDeviceMemoryPermission(device_perm), ResultInvalidNewMemoryPermission);
94 R_UNLESS(reserved == 0, ResultInvalidEnumValue);
95
96 // Get the device address space.
97 KScopedAutoObject das =
98 system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle);
99 R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
100
101 // Get the process.
102 KScopedAutoObject process =
103 system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle);
104 R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
105
106 // Validate that the process address is within range.
107 auto& page_table = process->PageTable();
108 R_UNLESS(page_table.Contains(process_address, size), ResultInvalidCurrentMemory);
109
110 // Map.
111 R_RETURN(
112 das->MapByForce(std::addressof(page_table), process_address, size, device_address, option));
113}
114
115Result MapDeviceAddressSpaceAligned(Core::System& system, Handle das_handle, Handle process_handle,
116 uint64_t process_address, size_t size, uint64_t device_address,
117 u32 option) {
118 // Decode the option.
119 const MapDeviceAddressSpaceOption option_pack{option};
120 const auto device_perm = option_pack.permission;
121 const auto reserved = option_pack.reserved;
122
123 // Validate input.
124 R_UNLESS(Common::IsAligned(process_address, PageSize), ResultInvalidAddress);
125 R_UNLESS(Common::IsAligned(device_address, PageSize), ResultInvalidAddress);
126 R_UNLESS(IsProcessAndDeviceAligned(process_address, device_address), ResultInvalidAddress);
127 R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize);
128 R_UNLESS(size > 0, ResultInvalidSize);
129 R_UNLESS((process_address < process_address + size), ResultInvalidCurrentMemory);
130 R_UNLESS((device_address < device_address + size), ResultInvalidMemoryRegion);
131 R_UNLESS((process_address == static_cast<uintptr_t>(process_address)),
132 ResultInvalidCurrentMemory);
133 R_UNLESS(IsValidDeviceMemoryPermission(device_perm), ResultInvalidNewMemoryPermission);
134 R_UNLESS(reserved == 0, ResultInvalidEnumValue);
135
136 // Get the device address space.
137 KScopedAutoObject das =
138 system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle);
139 R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
140
141 // Get the process.
142 KScopedAutoObject process =
143 system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle);
144 R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
145
146 // Validate that the process address is within range.
147 auto& page_table = process->PageTable();
148 R_UNLESS(page_table.Contains(process_address, size), ResultInvalidCurrentMemory);
149
150 // Map.
151 R_RETURN(
152 das->MapAligned(std::addressof(page_table), process_address, size, device_address, option));
153}
154
155Result UnmapDeviceAddressSpace(Core::System& system, Handle das_handle, Handle process_handle,
156 uint64_t process_address, size_t size, uint64_t device_address) {
157 // Validate input.
158 R_UNLESS(Common::IsAligned(process_address, PageSize), ResultInvalidAddress);
159 R_UNLESS(Common::IsAligned(device_address, PageSize), ResultInvalidAddress);
160 R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize);
161 R_UNLESS(size > 0, ResultInvalidSize);
162 R_UNLESS((process_address < process_address + size), ResultInvalidCurrentMemory);
163 R_UNLESS((device_address < device_address + size), ResultInvalidMemoryRegion);
164 R_UNLESS((process_address == static_cast<uintptr_t>(process_address)),
165 ResultInvalidCurrentMemory);
166
167 // Get the device address space.
168 KScopedAutoObject das =
169 system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle);
170 R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
171
172 // Get the process.
173 KScopedAutoObject process =
174 system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle);
175 R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
176
177 // Validate that the process address is within range.
178 auto& page_table = process->PageTable();
179 R_UNLESS(page_table.Contains(process_address, size), ResultInvalidCurrentMemory);
180
181 R_RETURN(das->Unmap(std::addressof(page_table), process_address, size, device_address));
182}
183
184Result CreateDeviceAddressSpace64(Core::System& system, Handle* out_handle, uint64_t das_address,
185 uint64_t das_size) {
186 R_RETURN(CreateDeviceAddressSpace(system, out_handle, das_address, das_size));
187}
188
189Result AttachDeviceAddressSpace64(Core::System& system, DeviceName device_name, Handle das_handle) {
190 R_RETURN(AttachDeviceAddressSpace(system, device_name, das_handle));
191}
192
193Result DetachDeviceAddressSpace64(Core::System& system, DeviceName device_name, Handle das_handle) {
194 R_RETURN(DetachDeviceAddressSpace(system, device_name, das_handle));
195}
196
197Result MapDeviceAddressSpaceByForce64(Core::System& system, Handle das_handle,
198 Handle process_handle, uint64_t process_address,
199 uint64_t size, uint64_t device_address, u32 option) {
200 R_RETURN(MapDeviceAddressSpaceByForce(system, das_handle, process_handle, process_address, size,
201 device_address, option));
202}
203
204Result MapDeviceAddressSpaceAligned64(Core::System& system, Handle das_handle,
205 Handle process_handle, uint64_t process_address,
206 uint64_t size, uint64_t device_address, u32 option) {
207 R_RETURN(MapDeviceAddressSpaceAligned(system, das_handle, process_handle, process_address, size,
208 device_address, option));
209}
210
211Result UnmapDeviceAddressSpace64(Core::System& system, Handle das_handle, Handle process_handle,
212 uint64_t process_address, uint64_t size, uint64_t device_address) {
213 R_RETURN(UnmapDeviceAddressSpace(system, das_handle, process_handle, process_address, size,
214 device_address));
215}
216
217Result CreateDeviceAddressSpace64From32(Core::System& system, Handle* out_handle,
218 uint64_t das_address, uint64_t das_size) {
219 R_RETURN(CreateDeviceAddressSpace(system, out_handle, das_address, das_size));
220}
221
222Result AttachDeviceAddressSpace64From32(Core::System& system, DeviceName device_name,
223 Handle das_handle) {
224 R_RETURN(AttachDeviceAddressSpace(system, device_name, das_handle));
225}
226
227Result DetachDeviceAddressSpace64From32(Core::System& system, DeviceName device_name,
228 Handle das_handle) {
229 R_RETURN(DetachDeviceAddressSpace(system, device_name, das_handle));
230}
231
232Result MapDeviceAddressSpaceByForce64From32(Core::System& system, Handle das_handle,
233 Handle process_handle, uint64_t process_address,
234 uint32_t size, uint64_t device_address, u32 option) {
235 R_RETURN(MapDeviceAddressSpaceByForce(system, das_handle, process_handle, process_address, size,
236 device_address, option));
237}
238
239Result MapDeviceAddressSpaceAligned64From32(Core::System& system, Handle das_handle,
240 Handle process_handle, uint64_t process_address,
241 uint32_t size, uint64_t device_address, u32 option) {
242 R_RETURN(MapDeviceAddressSpaceAligned(system, das_handle, process_handle, process_address, size,
243 device_address, option));
244}
245
246Result UnmapDeviceAddressSpace64From32(Core::System& system, Handle das_handle,
247 Handle process_handle, uint64_t process_address,
248 uint32_t size, uint64_t device_address) {
249 R_RETURN(UnmapDeviceAddressSpace(system, das_handle, process_handle, process_address, size,
250 device_address));
251}
252
253} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_event.cpp b/src/core/hle/kernel/svc/svc_event.cpp
index 885f02f50..e8fb9efbc 100644
--- a/src/core/hle/kernel/svc/svc_event.cpp
+++ b/src/core/hle/kernel/svc/svc_event.cpp
@@ -24,10 +24,6 @@ Result SignalEvent(Core::System& system, Handle event_handle) {
24 return event->Signal(); 24 return event->Signal();
25} 25}
26 26
27Result SignalEvent32(Core::System& system, Handle event_handle) {
28 return SignalEvent(system, event_handle);
29}
30
31Result ClearEvent(Core::System& system, Handle event_handle) { 27Result ClearEvent(Core::System& system, Handle event_handle) {
32 LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); 28 LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
33 29
@@ -55,10 +51,6 @@ Result ClearEvent(Core::System& system, Handle event_handle) {
55 return ResultInvalidHandle; 51 return ResultInvalidHandle;
56} 52}
57 53
58Result ClearEvent32(Core::System& system, Handle event_handle) {
59 return ClearEvent(system, event_handle);
60}
61
62Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { 54Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) {
63 LOG_DEBUG(Kernel_SVC, "called"); 55 LOG_DEBUG(Kernel_SVC, "called");
64 56
@@ -104,8 +96,29 @@ Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) {
104 return ResultSuccess; 96 return ResultSuccess;
105} 97}
106 98
107Result CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read) { 99Result SignalEvent64(Core::System& system, Handle event_handle) {
108 return CreateEvent(system, out_write, out_read); 100 R_RETURN(SignalEvent(system, event_handle));
101}
102
103Result ClearEvent64(Core::System& system, Handle event_handle) {
104 R_RETURN(ClearEvent(system, event_handle));
105}
106
107Result CreateEvent64(Core::System& system, Handle* out_write_handle, Handle* out_read_handle) {
108 R_RETURN(CreateEvent(system, out_write_handle, out_read_handle));
109}
110
111Result SignalEvent64From32(Core::System& system, Handle event_handle) {
112 R_RETURN(SignalEvent(system, event_handle));
113}
114
115Result ClearEvent64From32(Core::System& system, Handle event_handle) {
116 R_RETURN(ClearEvent(system, event_handle));
117}
118
119Result CreateEvent64From32(Core::System& system, Handle* out_write_handle,
120 Handle* out_read_handle) {
121 R_RETURN(CreateEvent(system, out_write_handle, out_read_handle));
109} 122}
110 123
111} // namespace Kernel::Svc 124} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_exception.cpp b/src/core/hle/kernel/svc/svc_exception.cpp
index fb9f133c1..c2782908d 100644
--- a/src/core/hle/kernel/svc/svc_exception.cpp
+++ b/src/core/hle/kernel/svc/svc_exception.cpp
@@ -12,10 +12,10 @@
12namespace Kernel::Svc { 12namespace Kernel::Svc {
13 13
14/// Break program execution 14/// Break program execution
15void Break(Core::System& system, u32 reason, u64 info1, u64 info2) { 15void Break(Core::System& system, BreakReason reason, u64 info1, u64 info2) {
16 BreakReason break_reason = 16 BreakReason break_reason =
17 static_cast<BreakReason>(reason & ~static_cast<u32>(BreakReason::NotificationOnlyFlag)); 17 reason & static_cast<BreakReason>(~BreakReason::NotificationOnlyFlag);
18 bool notification_only = (reason & static_cast<u32>(BreakReason::NotificationOnlyFlag)) != 0; 18 bool notification_only = True(reason & BreakReason::NotificationOnlyFlag);
19 19
20 bool has_dumped_buffer{}; 20 bool has_dumped_buffer{};
21 std::vector<u8> debug_buffer; 21 std::vector<u8> debug_buffer;
@@ -90,9 +90,9 @@ void Break(Core::System& system, u32 reason, u64 info1, u64 info2) {
90 break; 90 break;
91 } 91 }
92 92
93 system.GetReporter().SaveSvcBreakReport(reason, notification_only, info1, info2, 93 system.GetReporter().SaveSvcBreakReport(
94 has_dumped_buffer ? std::make_optional(debug_buffer) 94 static_cast<u32>(reason), notification_only, info1, info2,
95 : std::nullopt); 95 has_dumped_buffer ? std::make_optional(debug_buffer) : std::nullopt);
96 96
97 if (!notification_only) { 97 if (!notification_only) {
98 LOG_CRITICAL( 98 LOG_CRITICAL(
@@ -114,8 +114,24 @@ void Break(Core::System& system, u32 reason, u64 info1, u64 info2) {
114 } 114 }
115} 115}
116 116
117void Break32(Core::System& system, u32 reason, u32 info1, u32 info2) { 117void ReturnFromException(Core::System& system, Result result) {
118 Break(system, reason, info1, info2); 118 UNIMPLEMENTED();
119}
120
121void Break64(Core::System& system, BreakReason break_reason, uint64_t arg, uint64_t size) {
122 Break(system, break_reason, arg, size);
123}
124
125void Break64From32(Core::System& system, BreakReason break_reason, uint32_t arg, uint32_t size) {
126 Break(system, break_reason, arg, size);
127}
128
129void ReturnFromException64(Core::System& system, Result result) {
130 ReturnFromException(system, result);
131}
132
133void ReturnFromException64From32(Core::System& system, Result result) {
134 ReturnFromException(system, result);
119} 135}
120 136
121} // namespace Kernel::Svc 137} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_info.cpp b/src/core/hle/kernel/svc/svc_info.cpp
index df5dd85a4..75097c7f9 100644
--- a/src/core/hle/kernel/svc/svc_info.cpp
+++ b/src/core/hle/kernel/svc/svc_info.cpp
@@ -10,11 +10,12 @@
10namespace Kernel::Svc { 10namespace Kernel::Svc {
11 11
12/// Gets system/memory information for the current process 12/// Gets system/memory information for the current process
13Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, u64 info_sub_id) { 13Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle handle,
14 u64 info_sub_id) {
14 LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, 15 LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
15 info_sub_id, handle); 16 info_sub_id, handle);
16 17
17 const auto info_id_type = static_cast<InfoType>(info_id); 18 u32 info_id = static_cast<u32>(info_id_type);
18 19
19 switch (info_id_type) { 20 switch (info_id_type) {
20 case InfoType::CoreMask: 21 case InfoType::CoreMask:
@@ -267,16 +268,30 @@ Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, u6
267 } 268 }
268} 269}
269 270
270Result GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low, 271Result GetSystemInfo(Core::System& system, uint64_t* out, SystemInfoType info_type, Handle handle,
271 u32 info_id, u32 handle, u32 sub_id_high) { 272 uint64_t info_subtype) {
272 const u64 sub_id{u64{sub_id_low} | (u64{sub_id_high} << 32)}; 273 UNIMPLEMENTED();
273 u64 res_value{}; 274 R_THROW(ResultNotImplemented);
275}
276
277Result GetInfo64(Core::System& system, uint64_t* out, InfoType info_type, Handle handle,
278 uint64_t info_subtype) {
279 R_RETURN(GetInfo(system, out, info_type, handle, info_subtype));
280}
274 281
275 const Result result{GetInfo(system, &res_value, info_id, handle, sub_id)}; 282Result GetSystemInfo64(Core::System& system, uint64_t* out, SystemInfoType info_type, Handle handle,
276 *result_high = static_cast<u32>(res_value >> 32); 283 uint64_t info_subtype) {
277 *result_low = static_cast<u32>(res_value & std::numeric_limits<u32>::max()); 284 R_RETURN(GetSystemInfo(system, out, info_type, handle, info_subtype));
285}
286
287Result GetInfo64From32(Core::System& system, uint64_t* out, InfoType info_type, Handle handle,
288 uint64_t info_subtype) {
289 R_RETURN(GetInfo(system, out, info_type, handle, info_subtype));
290}
278 291
279 return result; 292Result GetSystemInfo64From32(Core::System& system, uint64_t* out, SystemInfoType info_type,
293 Handle handle, uint64_t info_subtype) {
294 R_RETURN(GetSystemInfo(system, out, info_type, handle, info_subtype));
280} 295}
281 296
282} // namespace Kernel::Svc 297} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_insecure_memory.cpp b/src/core/hle/kernel/svc/svc_insecure_memory.cpp
new file mode 100644
index 000000000..79882685d
--- /dev/null
+++ b/src/core/hle/kernel/svc/svc_insecure_memory.cpp
@@ -0,0 +1,35 @@
1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/kernel/svc.h"
5#include "core/hle/kernel/svc_results.h"
6
7namespace Kernel::Svc {
8
9Result MapInsecureMemory(Core::System& system, uintptr_t address, size_t size) {
10 UNIMPLEMENTED();
11 R_THROW(ResultNotImplemented);
12}
13
14Result UnmapInsecureMemory(Core::System& system, uintptr_t address, size_t size) {
15 UNIMPLEMENTED();
16 R_THROW(ResultNotImplemented);
17}
18
19Result MapInsecureMemory64(Core::System& system, uint64_t address, uint64_t size) {
20 R_RETURN(MapInsecureMemory(system, address, size));
21}
22
23Result UnmapInsecureMemory64(Core::System& system, uint64_t address, uint64_t size) {
24 R_RETURN(UnmapInsecureMemory(system, address, size));
25}
26
27Result MapInsecureMemory64From32(Core::System& system, uint32_t address, uint32_t size) {
28 R_RETURN(MapInsecureMemory(system, address, size));
29}
30
31Result UnmapInsecureMemory64From32(Core::System& system, uint32_t address, uint32_t size) {
32 R_RETURN(UnmapInsecureMemory(system, address, size));
33}
34
35} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_interrupt_event.cpp b/src/core/hle/kernel/svc/svc_interrupt_event.cpp
index 299e22ae6..768b30a1f 100644
--- a/src/core/hle/kernel/svc/svc_interrupt_event.cpp
+++ b/src/core/hle/kernel/svc/svc_interrupt_event.cpp
@@ -2,5 +2,24 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "core/hle/kernel/svc.h" 4#include "core/hle/kernel/svc.h"
5#include "core/hle/kernel/svc_results.h"
5 6
6namespace Kernel::Svc {} // namespace Kernel::Svc 7namespace Kernel::Svc {
8
9Result CreateInterruptEvent(Core::System& system, Handle* out, int32_t interrupt_id,
10 InterruptType type) {
11 UNIMPLEMENTED();
12 R_THROW(ResultNotImplemented);
13}
14
15Result CreateInterruptEvent64(Core::System& system, Handle* out_read_handle, int32_t interrupt_id,
16 InterruptType interrupt_type) {
17 R_RETURN(CreateInterruptEvent(system, out_read_handle, interrupt_id, interrupt_type));
18}
19
20Result CreateInterruptEvent64From32(Core::System& system, Handle* out_read_handle,
21 int32_t interrupt_id, InterruptType interrupt_type) {
22 R_RETURN(CreateInterruptEvent(system, out_read_handle, interrupt_id, interrupt_type));
23}
24
25} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_io_pool.cpp b/src/core/hle/kernel/svc/svc_io_pool.cpp
index 299e22ae6..33f3d69bf 100644
--- a/src/core/hle/kernel/svc/svc_io_pool.cpp
+++ b/src/core/hle/kernel/svc/svc_io_pool.cpp
@@ -2,5 +2,70 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "core/hle/kernel/svc.h" 4#include "core/hle/kernel/svc.h"
5#include "core/hle/kernel/svc_results.h"
5 6
6namespace Kernel::Svc {} // namespace Kernel::Svc 7namespace Kernel::Svc {
8
9Result CreateIoPool(Core::System& system, Handle* out, IoPoolType pool_type) {
10 UNIMPLEMENTED();
11 R_THROW(ResultNotImplemented);
12}
13
14Result CreateIoRegion(Core::System& system, Handle* out, Handle io_pool_handle, uint64_t phys_addr,
15 size_t size, MemoryMapping mapping, MemoryPermission perm) {
16 UNIMPLEMENTED();
17 R_THROW(ResultNotImplemented);
18}
19
20Result MapIoRegion(Core::System& system, Handle io_region_handle, uintptr_t address, size_t size,
21 MemoryPermission map_perm) {
22 UNIMPLEMENTED();
23 R_THROW(ResultNotImplemented);
24}
25
26Result UnmapIoRegion(Core::System& system, Handle io_region_handle, uintptr_t address,
27 size_t size) {
28 UNIMPLEMENTED();
29 R_THROW(ResultNotImplemented);
30}
31
32Result CreateIoPool64(Core::System& system, Handle* out_handle, IoPoolType pool_type) {
33 R_RETURN(CreateIoPool(system, out_handle, pool_type));
34}
35
36Result CreateIoRegion64(Core::System& system, Handle* out_handle, Handle io_pool,
37 uint64_t physical_address, uint64_t size, MemoryMapping mapping,
38 MemoryPermission perm) {
39 R_RETURN(CreateIoRegion(system, out_handle, io_pool, physical_address, size, mapping, perm));
40}
41
42Result MapIoRegion64(Core::System& system, Handle io_region, uint64_t address, uint64_t size,
43 MemoryPermission perm) {
44 R_RETURN(MapIoRegion(system, io_region, address, size, perm));
45}
46
47Result UnmapIoRegion64(Core::System& system, Handle io_region, uint64_t address, uint64_t size) {
48 R_RETURN(UnmapIoRegion(system, io_region, address, size));
49}
50
51Result CreateIoPool64From32(Core::System& system, Handle* out_handle, IoPoolType pool_type) {
52 R_RETURN(CreateIoPool(system, out_handle, pool_type));
53}
54
55Result CreateIoRegion64From32(Core::System& system, Handle* out_handle, Handle io_pool,
56 uint64_t physical_address, uint32_t size, MemoryMapping mapping,
57 MemoryPermission perm) {
58 R_RETURN(CreateIoRegion(system, out_handle, io_pool, physical_address, size, mapping, perm));
59}
60
61Result MapIoRegion64From32(Core::System& system, Handle io_region, uint32_t address, uint32_t size,
62 MemoryPermission perm) {
63 R_RETURN(MapIoRegion(system, io_region, address, size, perm));
64}
65
66Result UnmapIoRegion64From32(Core::System& system, Handle io_region, uint32_t address,
67 uint32_t size) {
68 R_RETURN(UnmapIoRegion(system, io_region, address, size));
69}
70
71} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_ipc.cpp b/src/core/hle/kernel/svc/svc_ipc.cpp
index dbb68e89a..97ce49dde 100644
--- a/src/core/hle/kernel/svc/svc_ipc.cpp
+++ b/src/core/hle/kernel/svc/svc_ipc.cpp
@@ -24,20 +24,37 @@ Result SendSyncRequest(Core::System& system, Handle handle) {
24 return session->SendSyncRequest(); 24 return session->SendSyncRequest();
25} 25}
26 26
27Result SendSyncRequest32(Core::System& system, Handle handle) { 27Result SendSyncRequestWithUserBuffer(Core::System& system, uint64_t message_buffer,
28 return SendSyncRequest(system, handle); 28 uint64_t message_buffer_size, Handle session_handle) {
29 UNIMPLEMENTED();
30 R_THROW(ResultNotImplemented);
29} 31}
30 32
31Result ReplyAndReceive(Core::System& system, s32* out_index, Handle* handles, s32 num_handles, 33Result SendAsyncRequestWithUserBuffer(Core::System& system, Handle* out_event_handle,
34 uint64_t message_buffer, uint64_t message_buffer_size,
35 Handle session_handle) {
36 UNIMPLEMENTED();
37 R_THROW(ResultNotImplemented);
38}
39
40Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_addr, s32 num_handles,
32 Handle reply_target, s64 timeout_ns) { 41 Handle reply_target, s64 timeout_ns) {
33 auto& kernel = system.Kernel(); 42 auto& kernel = system.Kernel();
34 auto& handle_table = GetCurrentThread(kernel).GetOwnerProcess()->GetHandleTable(); 43 auto& handle_table = GetCurrentThread(kernel).GetOwnerProcess()->GetHandleTable();
35 44
45 R_UNLESS(0 <= num_handles && num_handles <= ArgumentHandleCountMax, ResultOutOfRange);
46 R_UNLESS(system.Memory().IsValidVirtualAddressRange(
47 handles_addr, static_cast<u64>(sizeof(Handle) * num_handles)),
48 ResultInvalidPointer);
49
50 std::vector<Handle> handles(num_handles);
51 system.Memory().ReadBlock(handles_addr, handles.data(), sizeof(Handle) * num_handles);
52
36 // Convert handle list to object table. 53 // Convert handle list to object table.
37 std::vector<KSynchronizationObject*> objs(num_handles); 54 std::vector<KSynchronizationObject*> objs(num_handles);
38 R_UNLESS( 55 R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles.data(),
39 handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles, num_handles), 56 num_handles),
40 ResultInvalidHandle); 57 ResultInvalidHandle);
41 58
42 // Ensure handles are closed when we're done. 59 // Ensure handles are closed when we're done.
43 SCOPE_EXIT({ 60 SCOPE_EXIT({
@@ -86,4 +103,72 @@ Result ReplyAndReceive(Core::System& system, s32* out_index, Handle* handles, s3
86 } 103 }
87} 104}
88 105
106Result ReplyAndReceiveWithUserBuffer(Core::System& system, int32_t* out_index,
107 uint64_t message_buffer, uint64_t message_buffer_size,
108 uint64_t handles, int32_t num_handles, Handle reply_target,
109 int64_t timeout_ns) {
110 UNIMPLEMENTED();
111 R_THROW(ResultNotImplemented);
112}
113
114Result SendSyncRequest64(Core::System& system, Handle session_handle) {
115 R_RETURN(SendSyncRequest(system, session_handle));
116}
117
118Result SendSyncRequestWithUserBuffer64(Core::System& system, uint64_t message_buffer,
119 uint64_t message_buffer_size, Handle session_handle) {
120 R_RETURN(
121 SendSyncRequestWithUserBuffer(system, message_buffer, message_buffer_size, session_handle));
122}
123
124Result SendAsyncRequestWithUserBuffer64(Core::System& system, Handle* out_event_handle,
125 uint64_t message_buffer, uint64_t message_buffer_size,
126 Handle session_handle) {
127 R_RETURN(SendAsyncRequestWithUserBuffer(system, out_event_handle, message_buffer,
128 message_buffer_size, session_handle));
129}
130
131Result ReplyAndReceive64(Core::System& system, int32_t* out_index, uint64_t handles,
132 int32_t num_handles, Handle reply_target, int64_t timeout_ns) {
133 R_RETURN(ReplyAndReceive(system, out_index, handles, num_handles, reply_target, timeout_ns));
134}
135
136Result ReplyAndReceiveWithUserBuffer64(Core::System& system, int32_t* out_index,
137 uint64_t message_buffer, uint64_t message_buffer_size,
138 uint64_t handles, int32_t num_handles, Handle reply_target,
139 int64_t timeout_ns) {
140 R_RETURN(ReplyAndReceiveWithUserBuffer(system, out_index, message_buffer, message_buffer_size,
141 handles, num_handles, reply_target, timeout_ns));
142}
143
144Result SendSyncRequest64From32(Core::System& system, Handle session_handle) {
145 R_RETURN(SendSyncRequest(system, session_handle));
146}
147
148Result SendSyncRequestWithUserBuffer64From32(Core::System& system, uint32_t message_buffer,
149 uint32_t message_buffer_size, Handle session_handle) {
150 R_RETURN(
151 SendSyncRequestWithUserBuffer(system, message_buffer, message_buffer_size, session_handle));
152}
153
154Result SendAsyncRequestWithUserBuffer64From32(Core::System& system, Handle* out_event_handle,
155 uint32_t message_buffer, uint32_t message_buffer_size,
156 Handle session_handle) {
157 R_RETURN(SendAsyncRequestWithUserBuffer(system, out_event_handle, message_buffer,
158 message_buffer_size, session_handle));
159}
160
161Result ReplyAndReceive64From32(Core::System& system, int32_t* out_index, uint32_t handles,
162 int32_t num_handles, Handle reply_target, int64_t timeout_ns) {
163 R_RETURN(ReplyAndReceive(system, out_index, handles, num_handles, reply_target, timeout_ns));
164}
165
166Result ReplyAndReceiveWithUserBuffer64From32(Core::System& system, int32_t* out_index,
167 uint32_t message_buffer, uint32_t message_buffer_size,
168 uint32_t handles, int32_t num_handles,
169 Handle reply_target, int64_t timeout_ns) {
170 R_RETURN(ReplyAndReceiveWithUserBuffer(system, out_index, message_buffer, message_buffer_size,
171 handles, num_handles, reply_target, timeout_ns));
172}
173
89} // namespace Kernel::Svc 174} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_kernel_debug.cpp b/src/core/hle/kernel/svc/svc_kernel_debug.cpp
index 454255e7a..cee048279 100644
--- a/src/core/hle/kernel/svc/svc_kernel_debug.cpp
+++ b/src/core/hle/kernel/svc/svc_kernel_debug.cpp
@@ -5,15 +5,31 @@
5 5
6namespace Kernel::Svc { 6namespace Kernel::Svc {
7 7
8void KernelDebug([[maybe_unused]] Core::System& system, [[maybe_unused]] u32 kernel_debug_type, 8void KernelDebug(Core::System& system, KernelDebugType kernel_debug_type, u64 arg0, u64 arg1,
9 [[maybe_unused]] u64 param1, [[maybe_unused]] u64 param2, 9 u64 arg2) {
10 [[maybe_unused]] u64 param3) {
11 // Intentionally do nothing, as this does nothing in released kernel binaries. 10 // Intentionally do nothing, as this does nothing in released kernel binaries.
12} 11}
13 12
14void ChangeKernelTraceState([[maybe_unused]] Core::System& system, 13void ChangeKernelTraceState(Core::System& system, KernelTraceState trace_state) {
15 [[maybe_unused]] u32 trace_state) {
16 // Intentionally do nothing, as this does nothing in released kernel binaries. 14 // Intentionally do nothing, as this does nothing in released kernel binaries.
17} 15}
18 16
17void KernelDebug64(Core::System& system, KernelDebugType kern_debug_type, uint64_t arg0,
18 uint64_t arg1, uint64_t arg2) {
19 KernelDebug(system, kern_debug_type, arg0, arg1, arg2);
20}
21
22void ChangeKernelTraceState64(Core::System& system, KernelTraceState kern_trace_state) {
23 ChangeKernelTraceState(system, kern_trace_state);
24}
25
26void KernelDebug64From32(Core::System& system, KernelDebugType kern_debug_type, uint64_t arg0,
27 uint64_t arg1, uint64_t arg2) {
28 KernelDebug(system, kern_debug_type, arg0, arg1, arg2);
29}
30
31void ChangeKernelTraceState64From32(Core::System& system, KernelTraceState kern_trace_state) {
32 ChangeKernelTraceState(system, kern_trace_state);
33}
34
19} // namespace Kernel::Svc 35} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_light_ipc.cpp b/src/core/hle/kernel/svc/svc_light_ipc.cpp
index 299e22ae6..b76ce984c 100644
--- a/src/core/hle/kernel/svc/svc_light_ipc.cpp
+++ b/src/core/hle/kernel/svc/svc_light_ipc.cpp
@@ -1,6 +1,73 @@
1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "core/arm/arm_interface.h"
5#include "core/core.h"
4#include "core/hle/kernel/svc.h" 6#include "core/hle/kernel/svc.h"
7#include "core/hle/kernel/svc_results.h"
5 8
6namespace Kernel::Svc {} // namespace Kernel::Svc 9namespace Kernel::Svc {
10
11Result SendSyncRequestLight(Core::System& system, Handle session_handle, u32* args) {
12 UNIMPLEMENTED();
13 R_THROW(ResultNotImplemented);
14}
15
16Result ReplyAndReceiveLight(Core::System& system, Handle session_handle, u32* args) {
17 UNIMPLEMENTED();
18 R_THROW(ResultNotImplemented);
19}
20
21Result SendSyncRequestLight64(Core::System& system, Handle session_handle, u32* args) {
22 R_RETURN(SendSyncRequestLight(system, session_handle, args));
23}
24
25Result ReplyAndReceiveLight64(Core::System& system, Handle session_handle, u32* args) {
26 R_RETURN(ReplyAndReceiveLight(system, session_handle, args));
27}
28
29Result SendSyncRequestLight64From32(Core::System& system, Handle session_handle, u32* args) {
30 R_RETURN(SendSyncRequestLight(system, session_handle, args));
31}
32
33Result ReplyAndReceiveLight64From32(Core::System& system, Handle session_handle, u32* args) {
34 R_RETURN(ReplyAndReceiveLight(system, session_handle, args));
35}
36
37// Custom ABI implementation for light IPC.
38
39template <typename F>
40static void SvcWrap_LightIpc(Core::System& system, F&& cb) {
41 auto& core = system.CurrentArmInterface();
42 std::array<u32, 7> arguments{};
43
44 Handle session_handle = static_cast<Handle>(core.GetReg(0));
45 for (int i = 0; i < 7; i++) {
46 arguments[i] = static_cast<u32>(core.GetReg(i + 1));
47 }
48
49 Result ret = cb(system, session_handle, arguments.data());
50
51 core.SetReg(0, ret.raw);
52 for (int i = 0; i < 7; i++) {
53 core.SetReg(i + 1, arguments[i]);
54 }
55}
56
57void SvcWrap_SendSyncRequestLight64(Core::System& system) {
58 SvcWrap_LightIpc(system, SendSyncRequestLight64);
59}
60
61void SvcWrap_ReplyAndReceiveLight64(Core::System& system) {
62 SvcWrap_LightIpc(system, ReplyAndReceiveLight64);
63}
64
65void SvcWrap_SendSyncRequestLight64From32(Core::System& system) {
66 SvcWrap_LightIpc(system, SendSyncRequestLight64From32);
67}
68
69void SvcWrap_ReplyAndReceiveLight64From32(Core::System& system) {
70 SvcWrap_LightIpc(system, ReplyAndReceiveLight64From32);
71}
72
73} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_lock.cpp b/src/core/hle/kernel/svc/svc_lock.cpp
index 45f2a6553..7005ac30b 100644
--- a/src/core/hle/kernel/svc/svc_lock.cpp
+++ b/src/core/hle/kernel/svc/svc_lock.cpp
@@ -27,10 +27,6 @@ Result ArbitrateLock(Core::System& system, Handle thread_handle, VAddr address,
27 return system.Kernel().CurrentProcess()->WaitForAddress(thread_handle, address, tag); 27 return system.Kernel().CurrentProcess()->WaitForAddress(thread_handle, address, tag);
28} 28}
29 29
30Result ArbitrateLock32(Core::System& system, Handle thread_handle, u32 address, u32 tag) {
31 return ArbitrateLock(system, thread_handle, address, tag);
32}
33
34/// Unlock a mutex 30/// Unlock a mutex
35Result ArbitrateUnlock(Core::System& system, VAddr address) { 31Result ArbitrateUnlock(Core::System& system, VAddr address) {
36 LOG_TRACE(Kernel_SVC, "called address=0x{:X}", address); 32 LOG_TRACE(Kernel_SVC, "called address=0x{:X}", address);
@@ -50,8 +46,21 @@ Result ArbitrateUnlock(Core::System& system, VAddr address) {
50 return system.Kernel().CurrentProcess()->SignalToAddress(address); 46 return system.Kernel().CurrentProcess()->SignalToAddress(address);
51} 47}
52 48
53Result ArbitrateUnlock32(Core::System& system, u32 address) { 49Result ArbitrateLock64(Core::System& system, Handle thread_handle, uint64_t address, uint32_t tag) {
54 return ArbitrateUnlock(system, address); 50 R_RETURN(ArbitrateLock(system, thread_handle, address, tag));
51}
52
53Result ArbitrateUnlock64(Core::System& system, uint64_t address) {
54 R_RETURN(ArbitrateUnlock(system, address));
55}
56
57Result ArbitrateLock64From32(Core::System& system, Handle thread_handle, uint32_t address,
58 uint32_t tag) {
59 R_RETURN(ArbitrateLock(system, thread_handle, address, tag));
60}
61
62Result ArbitrateUnlock64From32(Core::System& system, uint32_t address) {
63 R_RETURN(ArbitrateUnlock(system, address));
55} 64}
56 65
57} // namespace Kernel::Svc 66} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_memory.cpp b/src/core/hle/kernel/svc/svc_memory.cpp
index f78b1239b..21f818da6 100644
--- a/src/core/hle/kernel/svc/svc_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_memory.cpp
@@ -144,10 +144,6 @@ Result SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mas
144 return page_table.SetMemoryAttribute(address, size, mask, attr); 144 return page_table.SetMemoryAttribute(address, size, mask, attr);
145} 145}
146 146
147Result SetMemoryAttribute32(Core::System& system, u32 address, u32 size, u32 mask, u32 attr) {
148 return SetMemoryAttribute(system, address, size, mask, attr);
149}
150
151/// Maps a memory range into a different range. 147/// Maps a memory range into a different range.
152Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { 148Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
153 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, 149 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
@@ -163,10 +159,6 @@ Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size)
163 return page_table.MapMemory(dst_addr, src_addr, size); 159 return page_table.MapMemory(dst_addr, src_addr, size);
164} 160}
165 161
166Result MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) {
167 return MapMemory(system, dst_addr, src_addr, size);
168}
169
170/// Unmaps a region that was previously mapped with svcMapMemory 162/// Unmaps a region that was previously mapped with svcMapMemory
171Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { 163Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
172 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, 164 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
@@ -182,8 +174,44 @@ Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 siz
182 return page_table.UnmapMemory(dst_addr, src_addr, size); 174 return page_table.UnmapMemory(dst_addr, src_addr, size);
183} 175}
184 176
185Result UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { 177Result SetMemoryPermission64(Core::System& system, uint64_t address, uint64_t size,
186 return UnmapMemory(system, dst_addr, src_addr, size); 178 MemoryPermission perm) {
179 R_RETURN(SetMemoryPermission(system, address, size, perm));
180}
181
182Result SetMemoryAttribute64(Core::System& system, uint64_t address, uint64_t size, uint32_t mask,
183 uint32_t attr) {
184 R_RETURN(SetMemoryAttribute(system, address, size, mask, attr));
185}
186
187Result MapMemory64(Core::System& system, uint64_t dst_address, uint64_t src_address,
188 uint64_t size) {
189 R_RETURN(MapMemory(system, dst_address, src_address, size));
190}
191
192Result UnmapMemory64(Core::System& system, uint64_t dst_address, uint64_t src_address,
193 uint64_t size) {
194 R_RETURN(UnmapMemory(system, dst_address, src_address, size));
195}
196
197Result SetMemoryPermission64From32(Core::System& system, uint32_t address, uint32_t size,
198 MemoryPermission perm) {
199 R_RETURN(SetMemoryPermission(system, address, size, perm));
200}
201
202Result SetMemoryAttribute64From32(Core::System& system, uint32_t address, uint32_t size,
203 uint32_t mask, uint32_t attr) {
204 R_RETURN(SetMemoryAttribute(system, address, size, mask, attr));
205}
206
207Result MapMemory64From32(Core::System& system, uint32_t dst_address, uint32_t src_address,
208 uint32_t size) {
209 R_RETURN(MapMemory(system, dst_address, src_address, size));
210}
211
212Result UnmapMemory64From32(Core::System& system, uint32_t dst_address, uint32_t src_address,
213 uint32_t size) {
214 R_RETURN(UnmapMemory(system, dst_address, src_address, size));
187} 215}
188 216
189} // namespace Kernel::Svc 217} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_physical_memory.cpp b/src/core/hle/kernel/svc/svc_physical_memory.cpp
index 0fc262203..8d00e1fc3 100644
--- a/src/core/hle/kernel/svc/svc_physical_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_physical_memory.cpp
@@ -21,13 +21,6 @@ Result SetHeapSize(Core::System& system, VAddr* out_address, u64 size) {
21 return ResultSuccess; 21 return ResultSuccess;
22} 22}
23 23
24Result SetHeapSize32(Core::System& system, u32* heap_addr, u32 heap_size) {
25 VAddr temp_heap_addr{};
26 const Result result{SetHeapSize(system, &temp_heap_addr, heap_size)};
27 *heap_addr = static_cast<u32>(temp_heap_addr);
28 return result;
29}
30
31/// Maps memory at a desired address 24/// Maps memory at a desired address
32Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { 25Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
33 LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); 26 LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
@@ -77,10 +70,6 @@ Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
77 return page_table.MapPhysicalMemory(addr, size); 70 return page_table.MapPhysicalMemory(addr, size);
78} 71}
79 72
80Result MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) {
81 return MapPhysicalMemory(system, addr, size);
82}
83
84/// Unmaps memory previously mapped via MapPhysicalMemory 73/// Unmaps memory previously mapped via MapPhysicalMemory
85Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { 74Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
86 LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); 75 LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
@@ -130,8 +119,67 @@ Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
130 return page_table.UnmapPhysicalMemory(addr, size); 119 return page_table.UnmapPhysicalMemory(addr, size);
131} 120}
132 121
133Result UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { 122Result MapPhysicalMemoryUnsafe(Core::System& system, uint64_t address, uint64_t size) {
134 return UnmapPhysicalMemory(system, addr, size); 123 UNIMPLEMENTED();
124 R_THROW(ResultNotImplemented);
125}
126
127Result UnmapPhysicalMemoryUnsafe(Core::System& system, uint64_t address, uint64_t size) {
128 UNIMPLEMENTED();
129 R_THROW(ResultNotImplemented);
130}
131
132Result SetUnsafeLimit(Core::System& system, uint64_t limit) {
133 UNIMPLEMENTED();
134 R_THROW(ResultNotImplemented);
135}
136
137Result SetHeapSize64(Core::System& system, uint64_t* out_address, uint64_t size) {
138 R_RETURN(SetHeapSize(system, out_address, size));
139}
140
141Result MapPhysicalMemory64(Core::System& system, uint64_t address, uint64_t size) {
142 R_RETURN(MapPhysicalMemory(system, address, size));
143}
144
145Result UnmapPhysicalMemory64(Core::System& system, uint64_t address, uint64_t size) {
146 R_RETURN(UnmapPhysicalMemory(system, address, size));
147}
148
149Result MapPhysicalMemoryUnsafe64(Core::System& system, uint64_t address, uint64_t size) {
150 R_RETURN(MapPhysicalMemoryUnsafe(system, address, size));
151}
152
153Result UnmapPhysicalMemoryUnsafe64(Core::System& system, uint64_t address, uint64_t size) {
154 R_RETURN(UnmapPhysicalMemoryUnsafe(system, address, size));
155}
156
157Result SetUnsafeLimit64(Core::System& system, uint64_t limit) {
158 R_RETURN(SetUnsafeLimit(system, limit));
159}
160
161Result SetHeapSize64From32(Core::System& system, uintptr_t* out_address, uint32_t size) {
162 R_RETURN(SetHeapSize(system, out_address, size));
163}
164
165Result MapPhysicalMemory64From32(Core::System& system, uint32_t address, uint32_t size) {
166 R_RETURN(MapPhysicalMemory(system, address, size));
167}
168
169Result UnmapPhysicalMemory64From32(Core::System& system, uint32_t address, uint32_t size) {
170 R_RETURN(UnmapPhysicalMemory(system, address, size));
171}
172
173Result MapPhysicalMemoryUnsafe64From32(Core::System& system, uint32_t address, uint32_t size) {
174 R_RETURN(MapPhysicalMemoryUnsafe(system, address, size));
175}
176
177Result UnmapPhysicalMemoryUnsafe64From32(Core::System& system, uint32_t address, uint32_t size) {
178 R_RETURN(UnmapPhysicalMemoryUnsafe(system, address, size));
179}
180
181Result SetUnsafeLimit64From32(Core::System& system, uint32_t limit) {
182 R_RETURN(SetUnsafeLimit(system, limit));
135} 183}
136 184
137} // namespace Kernel::Svc 185} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_port.cpp b/src/core/hle/kernel/svc/svc_port.cpp
index cdfe0dd16..2e5d228bb 100644
--- a/src/core/hle/kernel/svc/svc_port.cpp
+++ b/src/core/hle/kernel/svc/svc_port.cpp
@@ -63,9 +63,60 @@ Result ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_add
63 return ResultSuccess; 63 return ResultSuccess;
64} 64}
65 65
66Result ConnectToNamedPort32(Core::System& system, Handle* out_handle, u32 port_name_address) { 66Result CreatePort(Core::System& system, Handle* out_server, Handle* out_client,
67 int32_t max_sessions, bool is_light, uintptr_t name) {
68 UNIMPLEMENTED();
69 R_THROW(ResultNotImplemented);
70}
71
72Result ConnectToPort(Core::System& system, Handle* out_handle, Handle port) {
73 UNIMPLEMENTED();
74 R_THROW(ResultNotImplemented);
75}
76
77Result ManageNamedPort(Core::System& system, Handle* out_server_handle, uint64_t name,
78 int32_t max_sessions) {
79 UNIMPLEMENTED();
80 R_THROW(ResultNotImplemented);
81}
82
83Result ConnectToNamedPort64(Core::System& system, Handle* out_handle, uint64_t name) {
84 R_RETURN(ConnectToNamedPort(system, out_handle, name));
85}
86
87Result CreatePort64(Core::System& system, Handle* out_server_handle, Handle* out_client_handle,
88 int32_t max_sessions, bool is_light, uint64_t name) {
89 R_RETURN(
90 CreatePort(system, out_server_handle, out_client_handle, max_sessions, is_light, name));
91}
92
93Result ManageNamedPort64(Core::System& system, Handle* out_server_handle, uint64_t name,
94 int32_t max_sessions) {
95 R_RETURN(ManageNamedPort(system, out_server_handle, name, max_sessions));
96}
97
98Result ConnectToPort64(Core::System& system, Handle* out_handle, Handle port) {
99 R_RETURN(ConnectToPort(system, out_handle, port));
100}
101
102Result ConnectToNamedPort64From32(Core::System& system, Handle* out_handle, uint32_t name) {
103 R_RETURN(ConnectToNamedPort(system, out_handle, name));
104}
105
106Result CreatePort64From32(Core::System& system, Handle* out_server_handle,
107 Handle* out_client_handle, int32_t max_sessions, bool is_light,
108 uint32_t name) {
109 R_RETURN(
110 CreatePort(system, out_server_handle, out_client_handle, max_sessions, is_light, name));
111}
112
113Result ManageNamedPort64From32(Core::System& system, Handle* out_server_handle, uint32_t name,
114 int32_t max_sessions) {
115 R_RETURN(ManageNamedPort(system, out_server_handle, name, max_sessions));
116}
67 117
68 return ConnectToNamedPort(system, out_handle, port_name_address); 118Result ConnectToPort64From32(Core::System& system, Handle* out_handle, Handle port) {
119 R_RETURN(ConnectToPort(system, out_handle, port));
69} 120}
70 121
71} // namespace Kernel::Svc 122} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_power_management.cpp b/src/core/hle/kernel/svc/svc_power_management.cpp
index 299e22ae6..f605a0317 100644
--- a/src/core/hle/kernel/svc/svc_power_management.cpp
+++ b/src/core/hle/kernel/svc/svc_power_management.cpp
@@ -2,5 +2,20 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "core/hle/kernel/svc.h" 4#include "core/hle/kernel/svc.h"
5#include "core/hle/kernel/svc_results.h"
5 6
6namespace Kernel::Svc {} // namespace Kernel::Svc 7namespace Kernel::Svc {
8
9void SleepSystem(Core::System& system) {
10 UNIMPLEMENTED();
11}
12
13void SleepSystem64(Core::System& system) {
14 return SleepSystem(system);
15}
16
17void SleepSystem64From32(Core::System& system) {
18 return SleepSystem(system);
19}
20
21} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_process.cpp b/src/core/hle/kernel/svc/svc_process.cpp
index d6c8b4561..d2c20aad2 100644
--- a/src/core/hle/kernel/svc/svc_process.cpp
+++ b/src/core/hle/kernel/svc/svc_process.cpp
@@ -18,10 +18,6 @@ void ExitProcess(Core::System& system) {
18 system.Exit(); 18 system.Exit();
19} 19}
20 20
21void ExitProcess32(Core::System& system) {
22 ExitProcess(system);
23}
24
25/// Gets the ID of the specified process or a specified thread's owning process. 21/// Gets the ID of the specified process or a specified thread's owning process.
26Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) { 22Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) {
27 LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle); 23 LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle);
@@ -54,17 +50,8 @@ Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) {
54 return ResultSuccess; 50 return ResultSuccess;
55} 51}
56 52
57Result GetProcessId32(Core::System& system, u32* out_process_id_low, u32* out_process_id_high, 53Result GetProcessList(Core::System& system, s32* out_num_processes, VAddr out_process_ids,
58 Handle handle) { 54 int32_t out_process_ids_size) {
59 u64 out_process_id{};
60 const auto result = GetProcessId(system, &out_process_id, handle);
61 *out_process_id_low = static_cast<u32>(out_process_id);
62 *out_process_id_high = static_cast<u32>(out_process_id >> 32);
63 return result;
64}
65
66Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_process_ids,
67 u32 out_process_ids_size) {
68 LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}", 55 LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}",
69 out_process_ids, out_process_ids_size); 56 out_process_ids, out_process_ids_size);
70 57
@@ -89,7 +76,8 @@ Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_pr
89 auto& memory = system.Memory(); 76 auto& memory = system.Memory();
90 const auto& process_list = kernel.GetProcessList(); 77 const auto& process_list = kernel.GetProcessList();
91 const auto num_processes = process_list.size(); 78 const auto num_processes = process_list.size();
92 const auto copy_amount = std::min(std::size_t{out_process_ids_size}, num_processes); 79 const auto copy_amount =
80 std::min(static_cast<std::size_t>(out_process_ids_size), num_processes);
93 81
94 for (std::size_t i = 0; i < copy_amount; ++i) { 82 for (std::size_t i = 0; i < copy_amount; ++i) {
95 memory.Write64(out_process_ids, process_list[i]->GetProcessID()); 83 memory.Write64(out_process_ids, process_list[i]->GetProcessID());
@@ -100,8 +88,9 @@ Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_pr
100 return ResultSuccess; 88 return ResultSuccess;
101} 89}
102 90
103Result GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type) { 91Result GetProcessInfo(Core::System& system, s64* out, Handle process_handle,
104 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type); 92 ProcessInfoType info_type) {
93 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, info_type);
105 94
106 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 95 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
107 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); 96 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
@@ -111,14 +100,95 @@ Result GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32
111 return ResultInvalidHandle; 100 return ResultInvalidHandle;
112 } 101 }
113 102
114 const auto info_type = static_cast<ProcessInfoType>(type);
115 if (info_type != ProcessInfoType::ProcessState) { 103 if (info_type != ProcessInfoType::ProcessState) {
116 LOG_ERROR(Kernel_SVC, "Expected info_type to be ProcessState but got {} instead", type); 104 LOG_ERROR(Kernel_SVC, "Expected info_type to be ProcessState but got {} instead",
105 info_type);
117 return ResultInvalidEnumValue; 106 return ResultInvalidEnumValue;
118 } 107 }
119 108
120 *out = static_cast<u64>(process->GetState()); 109 *out = static_cast<s64>(process->GetState());
121 return ResultSuccess; 110 return ResultSuccess;
122} 111}
123 112
113Result CreateProcess(Core::System& system, Handle* out_handle, uint64_t parameters, uint64_t caps,
114 int32_t num_caps) {
115 UNIMPLEMENTED();
116 R_THROW(ResultNotImplemented);
117}
118
119Result StartProcess(Core::System& system, Handle process_handle, int32_t priority, int32_t core_id,
120 uint64_t main_thread_stack_size) {
121 UNIMPLEMENTED();
122 R_THROW(ResultNotImplemented);
123}
124
125Result TerminateProcess(Core::System& system, Handle process_handle) {
126 UNIMPLEMENTED();
127 R_THROW(ResultNotImplemented);
128}
129
130void ExitProcess64(Core::System& system) {
131 ExitProcess(system);
132}
133
134Result GetProcessId64(Core::System& system, uint64_t* out_process_id, Handle process_handle) {
135 R_RETURN(GetProcessId(system, out_process_id, process_handle));
136}
137
138Result GetProcessList64(Core::System& system, int32_t* out_num_processes, uint64_t out_process_ids,
139 int32_t max_out_count) {
140 R_RETURN(GetProcessList(system, out_num_processes, out_process_ids, max_out_count));
141}
142
143Result CreateProcess64(Core::System& system, Handle* out_handle, uint64_t parameters, uint64_t caps,
144 int32_t num_caps) {
145 R_RETURN(CreateProcess(system, out_handle, parameters, caps, num_caps));
146}
147
148Result StartProcess64(Core::System& system, Handle process_handle, int32_t priority,
149 int32_t core_id, uint64_t main_thread_stack_size) {
150 R_RETURN(StartProcess(system, process_handle, priority, core_id, main_thread_stack_size));
151}
152
153Result TerminateProcess64(Core::System& system, Handle process_handle) {
154 R_RETURN(TerminateProcess(system, process_handle));
155}
156
157Result GetProcessInfo64(Core::System& system, int64_t* out_info, Handle process_handle,
158 ProcessInfoType info_type) {
159 R_RETURN(GetProcessInfo(system, out_info, process_handle, info_type));
160}
161
162void ExitProcess64From32(Core::System& system) {
163 ExitProcess(system);
164}
165
166Result GetProcessId64From32(Core::System& system, uint64_t* out_process_id, Handle process_handle) {
167 R_RETURN(GetProcessId(system, out_process_id, process_handle));
168}
169
170Result GetProcessList64From32(Core::System& system, int32_t* out_num_processes,
171 uint32_t out_process_ids, int32_t max_out_count) {
172 R_RETURN(GetProcessList(system, out_num_processes, out_process_ids, max_out_count));
173}
174
175Result CreateProcess64From32(Core::System& system, Handle* out_handle, uint32_t parameters,
176 uint32_t caps, int32_t num_caps) {
177 R_RETURN(CreateProcess(system, out_handle, parameters, caps, num_caps));
178}
179
180Result StartProcess64From32(Core::System& system, Handle process_handle, int32_t priority,
181 int32_t core_id, uint64_t main_thread_stack_size) {
182 R_RETURN(StartProcess(system, process_handle, priority, core_id, main_thread_stack_size));
183}
184
185Result TerminateProcess64From32(Core::System& system, Handle process_handle) {
186 R_RETURN(TerminateProcess(system, process_handle));
187}
188
189Result GetProcessInfo64From32(Core::System& system, int64_t* out_info, Handle process_handle,
190 ProcessInfoType info_type) {
191 R_RETURN(GetProcessInfo(system, out_info, process_handle, info_type));
192}
193
124} // namespace Kernel::Svc 194} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_process_memory.cpp b/src/core/hle/kernel/svc/svc_process_memory.cpp
index b6ac43af2..dbe24e139 100644
--- a/src/core/hle/kernel/svc/svc_process_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_process_memory.cpp
@@ -271,4 +271,54 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d
271 KPageTable::ICacheInvalidationStrategy::InvalidateAll); 271 KPageTable::ICacheInvalidationStrategy::InvalidateAll);
272} 272}
273 273
274Result SetProcessMemoryPermission64(Core::System& system, Handle process_handle, uint64_t address,
275 uint64_t size, MemoryPermission perm) {
276 R_RETURN(SetProcessMemoryPermission(system, process_handle, address, size, perm));
277}
278
279Result MapProcessMemory64(Core::System& system, uint64_t dst_address, Handle process_handle,
280 uint64_t src_address, uint64_t size) {
281 R_RETURN(MapProcessMemory(system, dst_address, process_handle, src_address, size));
282}
283
284Result UnmapProcessMemory64(Core::System& system, uint64_t dst_address, Handle process_handle,
285 uint64_t src_address, uint64_t size) {
286 R_RETURN(UnmapProcessMemory(system, dst_address, process_handle, src_address, size));
287}
288
289Result MapProcessCodeMemory64(Core::System& system, Handle process_handle, uint64_t dst_address,
290 uint64_t src_address, uint64_t size) {
291 R_RETURN(MapProcessCodeMemory(system, process_handle, dst_address, src_address, size));
292}
293
294Result UnmapProcessCodeMemory64(Core::System& system, Handle process_handle, uint64_t dst_address,
295 uint64_t src_address, uint64_t size) {
296 R_RETURN(UnmapProcessCodeMemory(system, process_handle, dst_address, src_address, size));
297}
298
299Result SetProcessMemoryPermission64From32(Core::System& system, Handle process_handle,
300 uint64_t address, uint64_t size, MemoryPermission perm) {
301 R_RETURN(SetProcessMemoryPermission(system, process_handle, address, size, perm));
302}
303
304Result MapProcessMemory64From32(Core::System& system, uint32_t dst_address, Handle process_handle,
305 uint64_t src_address, uint32_t size) {
306 R_RETURN(MapProcessMemory(system, dst_address, process_handle, src_address, size));
307}
308
309Result UnmapProcessMemory64From32(Core::System& system, uint32_t dst_address, Handle process_handle,
310 uint64_t src_address, uint32_t size) {
311 R_RETURN(UnmapProcessMemory(system, dst_address, process_handle, src_address, size));
312}
313
314Result MapProcessCodeMemory64From32(Core::System& system, Handle process_handle,
315 uint64_t dst_address, uint64_t src_address, uint64_t size) {
316 R_RETURN(MapProcessCodeMemory(system, process_handle, dst_address, src_address, size));
317}
318
319Result UnmapProcessCodeMemory64From32(Core::System& system, Handle process_handle,
320 uint64_t dst_address, uint64_t src_address, uint64_t size) {
321 R_RETURN(UnmapProcessCodeMemory(system, process_handle, dst_address, src_address, size));
322}
323
274} // namespace Kernel::Svc 324} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_processor.cpp b/src/core/hle/kernel/svc/svc_processor.cpp
index 8561cf74f..7602ce6c0 100644
--- a/src/core/hle/kernel/svc/svc_processor.cpp
+++ b/src/core/hle/kernel/svc/svc_processor.cpp
@@ -9,12 +9,16 @@
9namespace Kernel::Svc { 9namespace Kernel::Svc {
10 10
11/// Get which CPU core is executing the current thread 11/// Get which CPU core is executing the current thread
12u32 GetCurrentProcessorNumber(Core::System& system) { 12int32_t GetCurrentProcessorNumber(Core::System& system) {
13 LOG_TRACE(Kernel_SVC, "called"); 13 LOG_TRACE(Kernel_SVC, "called");
14 return static_cast<u32>(system.CurrentPhysicalCore().CoreIndex()); 14 return static_cast<int32_t>(system.CurrentPhysicalCore().CoreIndex());
15} 15}
16 16
17u32 GetCurrentProcessorNumber32(Core::System& system) { 17int32_t GetCurrentProcessorNumber64(Core::System& system) {
18 return GetCurrentProcessorNumber(system);
19}
20
21int32_t GetCurrentProcessorNumber64From32(Core::System& system) {
18 return GetCurrentProcessorNumber(system); 22 return GetCurrentProcessorNumber(system);
19} 23}
20 24
diff --git a/src/core/hle/kernel/svc/svc_query_memory.cpp b/src/core/hle/kernel/svc/svc_query_memory.cpp
index aac3b2eca..db140a341 100644
--- a/src/core/hle/kernel/svc/svc_query_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_query_memory.cpp
@@ -7,24 +7,20 @@
7 7
8namespace Kernel::Svc { 8namespace Kernel::Svc {
9 9
10Result QueryMemory(Core::System& system, VAddr memory_info_address, VAddr page_info_address, 10Result QueryMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info,
11 VAddr query_address) { 11 VAddr query_address) {
12 LOG_TRACE(Kernel_SVC, 12 LOG_TRACE(Kernel_SVC,
13 "called, memory_info_address=0x{:016X}, page_info_address=0x{:016X}, " 13 "called, out_memory_info=0x{:016X}, "
14 "query_address=0x{:016X}", 14 "query_address=0x{:016X}",
15 memory_info_address, page_info_address, query_address); 15 out_memory_info, query_address);
16 16
17 return QueryProcessMemory(system, memory_info_address, page_info_address, CurrentProcess, 17 // Query memory is just QueryProcessMemory on the current process.
18 return QueryProcessMemory(system, out_memory_info, out_page_info, CurrentProcess,
18 query_address); 19 query_address);
19} 20}
20 21
21Result QueryMemory32(Core::System& system, u32 memory_info_address, u32 page_info_address, 22Result QueryProcessMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info,
22 u32 query_address) { 23 Handle process_handle, uint64_t address) {
23 return QueryMemory(system, memory_info_address, page_info_address, query_address);
24}
25
26Result QueryProcessMemory(Core::System& system, VAddr memory_info_address, VAddr page_info_address,
27 Handle process_handle, VAddr address) {
28 LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); 24 LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address);
29 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 25 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
30 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); 26 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
@@ -37,19 +33,33 @@ Result QueryProcessMemory(Core::System& system, VAddr memory_info_address, VAddr
37 auto& memory{system.Memory()}; 33 auto& memory{system.Memory()};
38 const auto memory_info{process->PageTable().QueryInfo(address).GetSvcMemoryInfo()}; 34 const auto memory_info{process->PageTable().QueryInfo(address).GetSvcMemoryInfo()};
39 35
40 memory.Write64(memory_info_address + 0x00, memory_info.base_address); 36 memory.WriteBlock(out_memory_info, &memory_info, sizeof(memory_info));
41 memory.Write64(memory_info_address + 0x08, memory_info.size); 37
42 memory.Write32(memory_info_address + 0x10, static_cast<u32>(memory_info.state) & 0xff); 38 //! This is supposed to be part of the QueryInfo call.
43 memory.Write32(memory_info_address + 0x14, static_cast<u32>(memory_info.attribute)); 39 *out_page_info = {};
44 memory.Write32(memory_info_address + 0x18, static_cast<u32>(memory_info.permission)); 40
45 memory.Write32(memory_info_address + 0x1c, memory_info.ipc_count); 41 R_SUCCEED();
46 memory.Write32(memory_info_address + 0x20, memory_info.device_count); 42}
47 memory.Write32(memory_info_address + 0x24, 0); 43
44Result QueryMemory64(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info,
45 uint64_t address) {
46 R_RETURN(QueryMemory(system, out_memory_info, out_page_info, address));
47}
48 48
49 // Page info appears to be currently unused by the kernel and is always set to zero. 49Result QueryProcessMemory64(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info,
50 memory.Write32(page_info_address, 0); 50 Handle process_handle, uint64_t address) {
51 R_RETURN(QueryProcessMemory(system, out_memory_info, out_page_info, process_handle, address));
52}
53
54Result QueryMemory64From32(Core::System& system, uint32_t out_memory_info, PageInfo* out_page_info,
55 uint32_t address) {
56 R_RETURN(QueryMemory(system, out_memory_info, out_page_info, address));
57}
51 58
52 return ResultSuccess; 59Result QueryProcessMemory64From32(Core::System& system, uint32_t out_memory_info,
60 PageInfo* out_page_info, Handle process_handle,
61 uint64_t address) {
62 R_RETURN(QueryProcessMemory(system, out_memory_info, out_page_info, process_handle, address));
53} 63}
54 64
55} // namespace Kernel::Svc 65} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_register.cpp b/src/core/hle/kernel/svc/svc_register.cpp
index 299e22ae6..b883e6618 100644
--- a/src/core/hle/kernel/svc/svc_register.cpp
+++ b/src/core/hle/kernel/svc/svc_register.cpp
@@ -2,5 +2,26 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "core/hle/kernel/svc.h" 4#include "core/hle/kernel/svc.h"
5#include "core/hle/kernel/svc_results.h"
5 6
6namespace Kernel::Svc {} // namespace Kernel::Svc 7namespace Kernel::Svc {
8
9Result ReadWriteRegister(Core::System& system, uint32_t* out, uint64_t address, uint32_t mask,
10 uint32_t value) {
11 *out = 0;
12
13 UNIMPLEMENTED();
14 R_THROW(ResultNotImplemented);
15}
16
17Result ReadWriteRegister64(Core::System& system, uint32_t* out_value, uint64_t address,
18 uint32_t mask, uint32_t value) {
19 R_RETURN(ReadWriteRegister(system, out_value, address, mask, value));
20}
21
22Result ReadWriteRegister64From32(Core::System& system, uint32_t* out_value, uint64_t address,
23 uint32_t mask, uint32_t value) {
24 R_RETURN(ReadWriteRegister(system, out_value, address, mask, value));
25}
26
27} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_resource_limit.cpp b/src/core/hle/kernel/svc/svc_resource_limit.cpp
index 679ba10fa..ebc886028 100644
--- a/src/core/hle/kernel/svc/svc_resource_limit.cpp
+++ b/src/core/hle/kernel/svc/svc_resource_limit.cpp
@@ -32,7 +32,7 @@ Result CreateResourceLimit(Core::System& system, Handle* out_handle) {
32 return ResultSuccess; 32 return ResultSuccess;
33} 33}
34 34
35Result GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value, 35Result GetResourceLimitLimitValue(Core::System& system, s64* out_limit_value,
36 Handle resource_limit_handle, LimitableResource which) { 36 Handle resource_limit_handle, LimitableResource which) {
37 LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, 37 LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle,
38 which); 38 which);
@@ -52,7 +52,7 @@ Result GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value,
52 return ResultSuccess; 52 return ResultSuccess;
53} 53}
54 54
55Result GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value, 55Result GetResourceLimitCurrentValue(Core::System& system, s64* out_current_value,
56 Handle resource_limit_handle, LimitableResource which) { 56 Handle resource_limit_handle, LimitableResource which) {
57 LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, 57 LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle,
58 which); 58 which);
@@ -73,7 +73,7 @@ Result GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value
73} 73}
74 74
75Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle, 75Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle,
76 LimitableResource which, u64 limit_value) { 76 LimitableResource which, s64 limit_value) {
77 LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}", 77 LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}",
78 resource_limit_handle, which, limit_value); 78 resource_limit_handle, which, limit_value);
79 79
@@ -92,4 +92,58 @@ Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_ha
92 return ResultSuccess; 92 return ResultSuccess;
93} 93}
94 94
95Result GetResourceLimitPeakValue(Core::System& system, int64_t* out_peak_value,
96 Handle resource_limit_handle, LimitableResource which) {
97 UNIMPLEMENTED();
98 R_THROW(ResultNotImplemented);
99}
100
101Result GetResourceLimitLimitValue64(Core::System& system, int64_t* out_limit_value,
102 Handle resource_limit_handle, LimitableResource which) {
103 R_RETURN(GetResourceLimitLimitValue(system, out_limit_value, resource_limit_handle, which));
104}
105
106Result GetResourceLimitCurrentValue64(Core::System& system, int64_t* out_current_value,
107 Handle resource_limit_handle, LimitableResource which) {
108 R_RETURN(GetResourceLimitCurrentValue(system, out_current_value, resource_limit_handle, which));
109}
110
111Result GetResourceLimitPeakValue64(Core::System& system, int64_t* out_peak_value,
112 Handle resource_limit_handle, LimitableResource which) {
113 R_RETURN(GetResourceLimitPeakValue(system, out_peak_value, resource_limit_handle, which));
114}
115
116Result CreateResourceLimit64(Core::System& system, Handle* out_handle) {
117 R_RETURN(CreateResourceLimit(system, out_handle));
118}
119
120Result SetResourceLimitLimitValue64(Core::System& system, Handle resource_limit_handle,
121 LimitableResource which, int64_t limit_value) {
122 R_RETURN(SetResourceLimitLimitValue(system, resource_limit_handle, which, limit_value));
123}
124
125Result GetResourceLimitLimitValue64From32(Core::System& system, int64_t* out_limit_value,
126 Handle resource_limit_handle, LimitableResource which) {
127 R_RETURN(GetResourceLimitLimitValue(system, out_limit_value, resource_limit_handle, which));
128}
129
130Result GetResourceLimitCurrentValue64From32(Core::System& system, int64_t* out_current_value,
131 Handle resource_limit_handle, LimitableResource which) {
132 R_RETURN(GetResourceLimitCurrentValue(system, out_current_value, resource_limit_handle, which));
133}
134
135Result GetResourceLimitPeakValue64From32(Core::System& system, int64_t* out_peak_value,
136 Handle resource_limit_handle, LimitableResource which) {
137 R_RETURN(GetResourceLimitPeakValue(system, out_peak_value, resource_limit_handle, which));
138}
139
140Result CreateResourceLimit64From32(Core::System& system, Handle* out_handle) {
141 R_RETURN(CreateResourceLimit(system, out_handle));
142}
143
144Result SetResourceLimitLimitValue64From32(Core::System& system, Handle resource_limit_handle,
145 LimitableResource which, int64_t limit_value) {
146 R_RETURN(SetResourceLimitLimitValue(system, resource_limit_handle, which, limit_value));
147}
148
95} // namespace Kernel::Svc 149} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp b/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp
index 299e22ae6..20f6ec643 100644
--- a/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp
+++ b/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp
@@ -1,6 +1,53 @@
1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "core/core.h"
5#include "core/hle/kernel/physical_core.h"
4#include "core/hle/kernel/svc.h" 6#include "core/hle/kernel/svc.h"
5 7
6namespace Kernel::Svc {} // namespace Kernel::Svc 8namespace Kernel::Svc {
9
10void CallSecureMonitor(Core::System& system, lp64::SecureMonitorArguments* args) {
11 UNIMPLEMENTED();
12}
13
14void CallSecureMonitor64(Core::System& system, lp64::SecureMonitorArguments* args) {
15 CallSecureMonitor(system, args);
16}
17
18void CallSecureMonitor64From32(Core::System& system, ilp32::SecureMonitorArguments* args) {
19 // CallSecureMonitor64From32 is not supported.
20 UNIMPLEMENTED_MSG("CallSecureMonitor64From32");
21}
22
23// Custom ABI for CallSecureMonitor.
24
25void SvcWrap_CallSecureMonitor64(Core::System& system) {
26 auto& core = system.CurrentPhysicalCore().ArmInterface();
27 lp64::SecureMonitorArguments args{};
28 for (int i = 0; i < 8; i++) {
29 args.r[i] = core.GetReg(i);
30 }
31
32 CallSecureMonitor64(system, &args);
33
34 for (int i = 0; i < 8; i++) {
35 core.SetReg(i, args.r[i]);
36 }
37}
38
39void SvcWrap_CallSecureMonitor64From32(Core::System& system) {
40 auto& core = system.CurrentPhysicalCore().ArmInterface();
41 ilp32::SecureMonitorArguments args{};
42 for (int i = 0; i < 8; i++) {
43 args.r[i] = static_cast<u32>(core.GetReg(i));
44 }
45
46 CallSecureMonitor64From32(system, &args);
47
48 for (int i = 0; i < 8; i++) {
49 core.SetReg(i, args.r[i]);
50 }
51}
52
53} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_session.cpp b/src/core/hle/kernel/svc/svc_session.cpp
index dac8ce33c..0deb61b62 100644
--- a/src/core/hle/kernel/svc/svc_session.cpp
+++ b/src/core/hle/kernel/svc/svc_session.cpp
@@ -90,14 +90,39 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien
90 90
91} // namespace 91} // namespace
92 92
93Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, u32 is_light, 93Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, bool is_light,
94 u64 name) { 94 u64 name) {
95 if (is_light) { 95 if (is_light) {
96 // return CreateSession<KLightSession>(system, out_server, out_client, name); 96 // return CreateSession<KLightSession>(system, out_server, out_client, name);
97 return ResultUnknown; 97 return ResultNotImplemented;
98 } else { 98 } else {
99 return CreateSession<KSession>(system, out_server, out_client, name); 99 return CreateSession<KSession>(system, out_server, out_client, name);
100 } 100 }
101} 101}
102 102
103Result AcceptSession(Core::System& system, Handle* out_handle, Handle port_handle) {
104 UNIMPLEMENTED();
105 R_THROW(ResultNotImplemented);
106}
107
108Result CreateSession64(Core::System& system, Handle* out_server_session_handle,
109 Handle* out_client_session_handle, bool is_light, uint64_t name) {
110 R_RETURN(CreateSession(system, out_server_session_handle, out_client_session_handle, is_light,
111 name));
112}
113
114Result AcceptSession64(Core::System& system, Handle* out_handle, Handle port) {
115 R_RETURN(AcceptSession(system, out_handle, port));
116}
117
118Result CreateSession64From32(Core::System& system, Handle* out_server_session_handle,
119 Handle* out_client_session_handle, bool is_light, uint32_t name) {
120 R_RETURN(CreateSession(system, out_server_session_handle, out_client_session_handle, is_light,
121 name));
122}
123
124Result AcceptSession64From32(Core::System& system, Handle* out_handle, Handle port) {
125 R_RETURN(AcceptSession(system, out_handle, port));
126}
127
103} // namespace Kernel::Svc 128} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_shared_memory.cpp b/src/core/hle/kernel/svc/svc_shared_memory.cpp
index d465bcbe7..40d6260e3 100644
--- a/src/core/hle/kernel/svc/svc_shared_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_shared_memory.cpp
@@ -67,11 +67,6 @@ Result MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address,
67 return ResultSuccess; 67 return ResultSuccess;
68} 68}
69 69
70Result MapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, u32 size,
71 Svc::MemoryPermission map_perm) {
72 return MapSharedMemory(system, shmem_handle, address, size, map_perm);
73}
74
75Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, u64 size) { 70Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, u64 size) {
76 // Validate the address/size. 71 // Validate the address/size.
77 R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress); 72 R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress);
@@ -99,8 +94,40 @@ Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr addres
99 return ResultSuccess; 94 return ResultSuccess;
100} 95}
101 96
102Result UnmapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, u32 size) { 97Result CreateSharedMemory(Core::System& system, Handle* out_handle, uint64_t size,
103 return UnmapSharedMemory(system, shmem_handle, address, size); 98 MemoryPermission owner_perm, MemoryPermission remote_perm) {
99 UNIMPLEMENTED();
100 R_THROW(ResultNotImplemented);
101}
102
103Result MapSharedMemory64(Core::System& system, Handle shmem_handle, uint64_t address, uint64_t size,
104 MemoryPermission map_perm) {
105 R_RETURN(MapSharedMemory(system, shmem_handle, address, size, map_perm));
106}
107
108Result UnmapSharedMemory64(Core::System& system, Handle shmem_handle, uint64_t address,
109 uint64_t size) {
110 R_RETURN(UnmapSharedMemory(system, shmem_handle, address, size));
111}
112
113Result CreateSharedMemory64(Core::System& system, Handle* out_handle, uint64_t size,
114 MemoryPermission owner_perm, MemoryPermission remote_perm) {
115 R_RETURN(CreateSharedMemory(system, out_handle, size, owner_perm, remote_perm));
116}
117
118Result MapSharedMemory64From32(Core::System& system, Handle shmem_handle, uint32_t address,
119 uint32_t size, MemoryPermission map_perm) {
120 R_RETURN(MapSharedMemory(system, shmem_handle, address, size, map_perm));
121}
122
123Result UnmapSharedMemory64From32(Core::System& system, Handle shmem_handle, uint32_t address,
124 uint32_t size) {
125 R_RETURN(UnmapSharedMemory(system, shmem_handle, address, size));
126}
127
128Result CreateSharedMemory64From32(Core::System& system, Handle* out_handle, uint32_t size,
129 MemoryPermission owner_perm, MemoryPermission remote_perm) {
130 R_RETURN(CreateSharedMemory(system, out_handle, size, owner_perm, remote_perm));
104} 131}
105 132
106} // namespace Kernel::Svc 133} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_synchronization.cpp b/src/core/hle/kernel/svc/svc_synchronization.cpp
index 1bf6a612a..e516a3800 100644
--- a/src/core/hle/kernel/svc/svc_synchronization.cpp
+++ b/src/core/hle/kernel/svc/svc_synchronization.cpp
@@ -20,10 +20,6 @@ Result CloseHandle(Core::System& system, Handle handle) {
20 return ResultSuccess; 20 return ResultSuccess;
21} 21}
22 22
23Result CloseHandle32(Core::System& system, Handle handle) {
24 return CloseHandle(system, handle);
25}
26
27/// Clears the signaled state of an event or process. 23/// Clears the signaled state of an event or process.
28Result ResetSignal(Core::System& system, Handle handle) { 24Result ResetSignal(Core::System& system, Handle handle) {
29 LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); 25 LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle);
@@ -52,10 +48,6 @@ Result ResetSignal(Core::System& system, Handle handle) {
52 return ResultInvalidHandle; 48 return ResultInvalidHandle;
53} 49}
54 50
55Result ResetSignal32(Core::System& system, Handle handle) {
56 return ResetSignal(system, handle);
57}
58
59/// Wait for the given handles to synchronize, timeout after the specified nanoseconds 51/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
60Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_address, s32 num_handles, 52Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_address, s32 num_handles,
61 s64 nano_seconds) { 53 s64 nano_seconds) {
@@ -93,12 +85,6 @@ Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_addre
93 nano_seconds); 85 nano_seconds);
94} 86}
95 87
96Result WaitSynchronization32(Core::System& system, u32 timeout_low, u32 handles_address,
97 s32 num_handles, u32 timeout_high, s32* index) {
98 const s64 nano_seconds{(static_cast<s64>(timeout_high) << 32) | static_cast<s64>(timeout_low)};
99 return WaitSynchronization(system, index, handles_address, num_handles, nano_seconds);
100}
101
102/// Resumes a thread waiting on WaitSynchronization 88/// Resumes a thread waiting on WaitSynchronization
103Result CancelSynchronization(Core::System& system, Handle handle) { 89Result CancelSynchronization(Core::System& system, Handle handle) {
104 LOG_TRACE(Kernel_SVC, "called handle=0x{:X}", handle); 90 LOG_TRACE(Kernel_SVC, "called handle=0x{:X}", handle);
@@ -113,10 +99,6 @@ Result CancelSynchronization(Core::System& system, Handle handle) {
113 return ResultSuccess; 99 return ResultSuccess;
114} 100}
115 101
116Result CancelSynchronization32(Core::System& system, Handle handle) {
117 return CancelSynchronization(system, handle);
118}
119
120void SynchronizePreemptionState(Core::System& system) { 102void SynchronizePreemptionState(Core::System& system) {
121 auto& kernel = system.Kernel(); 103 auto& kernel = system.Kernel();
122 104
@@ -136,4 +118,46 @@ void SynchronizePreemptionState(Core::System& system) {
136 } 118 }
137} 119}
138 120
121Result CloseHandle64(Core::System& system, Handle handle) {
122 R_RETURN(CloseHandle(system, handle));
123}
124
125Result ResetSignal64(Core::System& system, Handle handle) {
126 R_RETURN(ResetSignal(system, handle));
127}
128
129Result WaitSynchronization64(Core::System& system, int32_t* out_index, uint64_t handles,
130 int32_t num_handles, int64_t timeout_ns) {
131 R_RETURN(WaitSynchronization(system, out_index, handles, num_handles, timeout_ns));
132}
133
134Result CancelSynchronization64(Core::System& system, Handle handle) {
135 R_RETURN(CancelSynchronization(system, handle));
136}
137
138void SynchronizePreemptionState64(Core::System& system) {
139 SynchronizePreemptionState(system);
140}
141
142Result CloseHandle64From32(Core::System& system, Handle handle) {
143 R_RETURN(CloseHandle(system, handle));
144}
145
146Result ResetSignal64From32(Core::System& system, Handle handle) {
147 R_RETURN(ResetSignal(system, handle));
148}
149
150Result WaitSynchronization64From32(Core::System& system, int32_t* out_index, uint32_t handles,
151 int32_t num_handles, int64_t timeout_ns) {
152 R_RETURN(WaitSynchronization(system, out_index, handles, num_handles, timeout_ns));
153}
154
155Result CancelSynchronization64From32(Core::System& system, Handle handle) {
156 R_RETURN(CancelSynchronization(system, handle));
157}
158
159void SynchronizePreemptionState64From32(Core::System& system) {
160 SynchronizePreemptionState(system);
161}
162
139} // namespace Kernel::Svc 163} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_thread.cpp b/src/core/hle/kernel/svc/svc_thread.cpp
index dd9f8e8b1..3e325c998 100644
--- a/src/core/hle/kernel/svc/svc_thread.cpp
+++ b/src/core/hle/kernel/svc/svc_thread.cpp
@@ -20,7 +20,7 @@ constexpr bool IsValidVirtualCoreId(int32_t core_id) {
20 20
21/// Creates a new thread 21/// Creates a new thread
22Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg, 22Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg,
23 VAddr stack_bottom, u32 priority, s32 core_id) { 23 VAddr stack_bottom, s32 priority, s32 core_id) {
24 LOG_DEBUG(Kernel_SVC, 24 LOG_DEBUG(Kernel_SVC,
25 "called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, " 25 "called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, "
26 "priority=0x{:08X}, core_id=0x{:08X}", 26 "priority=0x{:08X}, core_id=0x{:08X}",
@@ -91,11 +91,6 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point,
91 return ResultSuccess; 91 return ResultSuccess;
92} 92}
93 93
94Result CreateThread32(Core::System& system, Handle* out_handle, u32 priority, u32 entry_point,
95 u32 arg, u32 stack_top, s32 processor_id) {
96 return CreateThread(system, out_handle, entry_point, arg, stack_top, priority, processor_id);
97}
98
99/// Starts the thread for the provided handle 94/// Starts the thread for the provided handle
100Result StartThread(Core::System& system, Handle thread_handle) { 95Result StartThread(Core::System& system, Handle thread_handle) {
101 LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); 96 LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle);
@@ -115,10 +110,6 @@ Result StartThread(Core::System& system, Handle thread_handle) {
115 return ResultSuccess; 110 return ResultSuccess;
116} 111}
117 112
118Result StartThread32(Core::System& system, Handle thread_handle) {
119 return StartThread(system, thread_handle);
120}
121
122/// Called when a thread exits 113/// Called when a thread exits
123void ExitThread(Core::System& system) { 114void ExitThread(Core::System& system) {
124 LOG_DEBUG(Kernel_SVC, "called, pc=0x{:08X}", system.CurrentArmInterface().GetPC()); 115 LOG_DEBUG(Kernel_SVC, "called, pc=0x{:08X}", system.CurrentArmInterface().GetPC());
@@ -129,10 +120,6 @@ void ExitThread(Core::System& system) {
129 system.Kernel().UnregisterInUseObject(current_thread); 120 system.Kernel().UnregisterInUseObject(current_thread);
130} 121}
131 122
132void ExitThread32(Core::System& system) {
133 ExitThread(system);
134}
135
136/// Sleep the current thread 123/// Sleep the current thread
137void SleepThread(Core::System& system, s64 nanoseconds) { 124void SleepThread(Core::System& system, s64 nanoseconds) {
138 auto& kernel = system.Kernel(); 125 auto& kernel = system.Kernel();
@@ -160,13 +147,8 @@ void SleepThread(Core::System& system, s64 nanoseconds) {
160 } 147 }
161} 148}
162 149
163void SleepThread32(Core::System& system, u32 nanoseconds_low, u32 nanoseconds_high) {
164 const auto nanoseconds = static_cast<s64>(u64{nanoseconds_low} | (u64{nanoseconds_high} << 32));
165 SleepThread(system, nanoseconds);
166}
167
168/// Gets the thread context 150/// Gets the thread context
169Result GetThreadContext(Core::System& system, VAddr out_context, Handle thread_handle) { 151Result GetThreadContext3(Core::System& system, VAddr out_context, Handle thread_handle) {
170 LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context, 152 LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context,
171 thread_handle); 153 thread_handle);
172 154
@@ -223,12 +205,8 @@ Result GetThreadContext(Core::System& system, VAddr out_context, Handle thread_h
223 return ResultSuccess; 205 return ResultSuccess;
224} 206}
225 207
226Result GetThreadContext32(Core::System& system, u32 out_context, Handle thread_handle) {
227 return GetThreadContext(system, out_context, thread_handle);
228}
229
230/// Gets the priority for the specified thread 208/// Gets the priority for the specified thread
231Result GetThreadPriority(Core::System& system, u32* out_priority, Handle handle) { 209Result GetThreadPriority(Core::System& system, s32* out_priority, Handle handle) {
232 LOG_TRACE(Kernel_SVC, "called"); 210 LOG_TRACE(Kernel_SVC, "called");
233 211
234 // Get the thread from its handle. 212 // Get the thread from its handle.
@@ -241,12 +219,8 @@ Result GetThreadPriority(Core::System& system, u32* out_priority, Handle handle)
241 return ResultSuccess; 219 return ResultSuccess;
242} 220}
243 221
244Result GetThreadPriority32(Core::System& system, u32* out_priority, Handle handle) {
245 return GetThreadPriority(system, out_priority, handle);
246}
247
248/// Sets the priority for the specified thread 222/// Sets the priority for the specified thread
249Result SetThreadPriority(Core::System& system, Handle thread_handle, u32 priority) { 223Result SetThreadPriority(Core::System& system, Handle thread_handle, s32 priority) {
250 // Get the current process. 224 // Get the current process.
251 KProcess& process = *system.Kernel().CurrentProcess(); 225 KProcess& process = *system.Kernel().CurrentProcess();
252 226
@@ -264,12 +238,8 @@ Result SetThreadPriority(Core::System& system, Handle thread_handle, u32 priorit
264 return ResultSuccess; 238 return ResultSuccess;
265} 239}
266 240
267Result SetThreadPriority32(Core::System& system, Handle thread_handle, u32 priority) { 241Result GetThreadList(Core::System& system, s32* out_num_threads, VAddr out_thread_ids,
268 return SetThreadPriority(system, thread_handle, priority); 242 s32 out_thread_ids_size, Handle debug_handle) {
269}
270
271Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_thread_ids,
272 u32 out_thread_ids_size, Handle debug_handle) {
273 // TODO: Handle this case when debug events are supported. 243 // TODO: Handle this case when debug events are supported.
274 UNIMPLEMENTED_IF(debug_handle != InvalidHandle); 244 UNIMPLEMENTED_IF(debug_handle != InvalidHandle);
275 245
@@ -296,7 +266,7 @@ Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_threa
296 auto& memory = system.Memory(); 266 auto& memory = system.Memory();
297 const auto& thread_list = current_process->GetThreadList(); 267 const auto& thread_list = current_process->GetThreadList();
298 const auto num_threads = thread_list.size(); 268 const auto num_threads = thread_list.size();
299 const auto copy_amount = std::min(std::size_t{out_thread_ids_size}, num_threads); 269 const auto copy_amount = std::min(static_cast<std::size_t>(out_thread_ids_size), num_threads);
300 270
301 auto list_iter = thread_list.cbegin(); 271 auto list_iter = thread_list.cbegin();
302 for (std::size_t i = 0; i < copy_amount; ++i, ++list_iter) { 272 for (std::size_t i = 0; i < copy_amount; ++i, ++list_iter) {
@@ -308,8 +278,8 @@ Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_threa
308 return ResultSuccess; 278 return ResultSuccess;
309} 279}
310 280
311Result GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_core_id, 281Result GetThreadCoreMask(Core::System& system, s32* out_core_id, u64* out_affinity_mask,
312 u64* out_affinity_mask) { 282 Handle thread_handle) {
313 LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); 283 LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle);
314 284
315 // Get the thread from its handle. 285 // Get the thread from its handle.
@@ -323,15 +293,6 @@ Result GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_co
323 return ResultSuccess; 293 return ResultSuccess;
324} 294}
325 295
326Result GetThreadCoreMask32(Core::System& system, Handle thread_handle, s32* out_core_id,
327 u32* out_affinity_mask_low, u32* out_affinity_mask_high) {
328 u64 out_affinity_mask{};
329 const auto result = GetThreadCoreMask(system, thread_handle, out_core_id, &out_affinity_mask);
330 *out_affinity_mask_high = static_cast<u32>(out_affinity_mask >> 32);
331 *out_affinity_mask_low = static_cast<u32>(out_affinity_mask);
332 return result;
333}
334
335Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id, 296Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id,
336 u64 affinity_mask) { 297 u64 affinity_mask) {
337 // Determine the core id/affinity mask. 298 // Determine the core id/affinity mask.
@@ -364,12 +325,6 @@ Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id
364 return ResultSuccess; 325 return ResultSuccess;
365} 326}
366 327
367Result SetThreadCoreMask32(Core::System& system, Handle thread_handle, s32 core_id,
368 u32 affinity_mask_low, u32 affinity_mask_high) {
369 const auto affinity_mask = u64{affinity_mask_low} | (u64{affinity_mask_high} << 32);
370 return SetThreadCoreMask(system, thread_handle, core_id, affinity_mask);
371}
372
373/// Get the ID for the specified thread. 328/// Get the ID for the specified thread.
374Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) { 329Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) {
375 // Get the thread from its handle. 330 // Get the thread from its handle.
@@ -382,15 +337,101 @@ Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handl
382 return ResultSuccess; 337 return ResultSuccess;
383} 338}
384 339
385Result GetThreadId32(Core::System& system, u32* out_thread_id_low, u32* out_thread_id_high, 340Result CreateThread64(Core::System& system, Handle* out_handle, uint64_t func, uint64_t arg,
386 Handle thread_handle) { 341 uint64_t stack_bottom, int32_t priority, int32_t core_id) {
387 u64 out_thread_id{}; 342 R_RETURN(CreateThread(system, out_handle, func, arg, stack_bottom, priority, core_id));
388 const Result result{GetThreadId(system, &out_thread_id, thread_handle)}; 343}
344
345Result StartThread64(Core::System& system, Handle thread_handle) {
346 R_RETURN(StartThread(system, thread_handle));
347}
348
349void ExitThread64(Core::System& system) {
350 return ExitThread(system);
351}
352
353void SleepThread64(Core::System& system, int64_t ns) {
354 return SleepThread(system, ns);
355}
356
357Result GetThreadPriority64(Core::System& system, int32_t* out_priority, Handle thread_handle) {
358 R_RETURN(GetThreadPriority(system, out_priority, thread_handle));
359}
360
361Result SetThreadPriority64(Core::System& system, Handle thread_handle, int32_t priority) {
362 R_RETURN(SetThreadPriority(system, thread_handle, priority));
363}
364
365Result GetThreadCoreMask64(Core::System& system, int32_t* out_core_id, uint64_t* out_affinity_mask,
366 Handle thread_handle) {
367 R_RETURN(GetThreadCoreMask(system, out_core_id, out_affinity_mask, thread_handle));
368}
369
370Result SetThreadCoreMask64(Core::System& system, Handle thread_handle, int32_t core_id,
371 uint64_t affinity_mask) {
372 R_RETURN(SetThreadCoreMask(system, thread_handle, core_id, affinity_mask));
373}
374
375Result GetThreadId64(Core::System& system, uint64_t* out_thread_id, Handle thread_handle) {
376 R_RETURN(GetThreadId(system, out_thread_id, thread_handle));
377}
378
379Result GetThreadContext364(Core::System& system, uint64_t out_context, Handle thread_handle) {
380 R_RETURN(GetThreadContext3(system, out_context, thread_handle));
381}
389 382
390 *out_thread_id_low = static_cast<u32>(out_thread_id >> 32); 383Result GetThreadList64(Core::System& system, int32_t* out_num_threads, uint64_t out_thread_ids,
391 *out_thread_id_high = static_cast<u32>(out_thread_id & std::numeric_limits<u32>::max()); 384 int32_t max_out_count, Handle debug_handle) {
385 R_RETURN(GetThreadList(system, out_num_threads, out_thread_ids, max_out_count, debug_handle));
386}
387
388Result CreateThread64From32(Core::System& system, Handle* out_handle, uint32_t func, uint32_t arg,
389 uint32_t stack_bottom, int32_t priority, int32_t core_id) {
390 R_RETURN(CreateThread(system, out_handle, func, arg, stack_bottom, priority, core_id));
391}
392
393Result StartThread64From32(Core::System& system, Handle thread_handle) {
394 R_RETURN(StartThread(system, thread_handle));
395}
396
397void ExitThread64From32(Core::System& system) {
398 return ExitThread(system);
399}
400
401void SleepThread64From32(Core::System& system, int64_t ns) {
402 return SleepThread(system, ns);
403}
404
405Result GetThreadPriority64From32(Core::System& system, int32_t* out_priority,
406 Handle thread_handle) {
407 R_RETURN(GetThreadPriority(system, out_priority, thread_handle));
408}
409
410Result SetThreadPriority64From32(Core::System& system, Handle thread_handle, int32_t priority) {
411 R_RETURN(SetThreadPriority(system, thread_handle, priority));
412}
413
414Result GetThreadCoreMask64From32(Core::System& system, int32_t* out_core_id,
415 uint64_t* out_affinity_mask, Handle thread_handle) {
416 R_RETURN(GetThreadCoreMask(system, out_core_id, out_affinity_mask, thread_handle));
417}
418
419Result SetThreadCoreMask64From32(Core::System& system, Handle thread_handle, int32_t core_id,
420 uint64_t affinity_mask) {
421 R_RETURN(SetThreadCoreMask(system, thread_handle, core_id, affinity_mask));
422}
423
424Result GetThreadId64From32(Core::System& system, uint64_t* out_thread_id, Handle thread_handle) {
425 R_RETURN(GetThreadId(system, out_thread_id, thread_handle));
426}
427
428Result GetThreadContext364From32(Core::System& system, uint32_t out_context, Handle thread_handle) {
429 R_RETURN(GetThreadContext3(system, out_context, thread_handle));
430}
392 431
393 return result; 432Result GetThreadList64From32(Core::System& system, int32_t* out_num_threads,
433 uint32_t out_thread_ids, int32_t max_out_count, Handle debug_handle) {
434 R_RETURN(GetThreadList(system, out_num_threads, out_thread_ids, max_out_count, debug_handle));
394} 435}
395 436
396} // namespace Kernel::Svc 437} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_thread_profiler.cpp b/src/core/hle/kernel/svc/svc_thread_profiler.cpp
index 299e22ae6..40de7708b 100644
--- a/src/core/hle/kernel/svc/svc_thread_profiler.cpp
+++ b/src/core/hle/kernel/svc/svc_thread_profiler.cpp
@@ -2,5 +2,59 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "core/hle/kernel/svc.h" 4#include "core/hle/kernel/svc.h"
5#include "core/hle/kernel/svc_results.h"
5 6
6namespace Kernel::Svc {} // namespace Kernel::Svc 7namespace Kernel::Svc {
8
9Result GetDebugFutureThreadInfo(Core::System& system, lp64::LastThreadContext* out_context,
10 uint64_t* out_thread_id, Handle debug_handle, int64_t ns) {
11 UNIMPLEMENTED();
12 R_THROW(ResultNotImplemented);
13}
14
15Result GetLastThreadInfo(Core::System& system, lp64::LastThreadContext* out_context,
16 uint64_t* out_tls_address, uint32_t* out_flags) {
17 UNIMPLEMENTED();
18 R_THROW(ResultNotImplemented);
19}
20
21Result GetDebugFutureThreadInfo64(Core::System& system, lp64::LastThreadContext* out_context,
22 uint64_t* out_thread_id, Handle debug_handle, int64_t ns) {
23 R_RETURN(GetDebugFutureThreadInfo(system, out_context, out_thread_id, debug_handle, ns));
24}
25
26Result GetLastThreadInfo64(Core::System& system, lp64::LastThreadContext* out_context,
27 uint64_t* out_tls_address, uint32_t* out_flags) {
28 R_RETURN(GetLastThreadInfo(system, out_context, out_tls_address, out_flags));
29}
30
31Result GetDebugFutureThreadInfo64From32(Core::System& system, ilp32::LastThreadContext* out_context,
32 uint64_t* out_thread_id, Handle debug_handle, int64_t ns) {
33 lp64::LastThreadContext context{};
34 R_TRY(
35 GetDebugFutureThreadInfo(system, std::addressof(context), out_thread_id, debug_handle, ns));
36
37 *out_context = {
38 .fp = static_cast<u32>(context.fp),
39 .sp = static_cast<u32>(context.sp),
40 .lr = static_cast<u32>(context.lr),
41 .pc = static_cast<u32>(context.pc),
42 };
43 R_SUCCEED();
44}
45
46Result GetLastThreadInfo64From32(Core::System& system, ilp32::LastThreadContext* out_context,
47 uint64_t* out_tls_address, uint32_t* out_flags) {
48 lp64::LastThreadContext context{};
49 R_TRY(GetLastThreadInfo(system, std::addressof(context), out_tls_address, out_flags));
50
51 *out_context = {
52 .fp = static_cast<u32>(context.fp),
53 .sp = static_cast<u32>(context.sp),
54 .lr = static_cast<u32>(context.lr),
55 .pc = static_cast<u32>(context.pc),
56 };
57 R_SUCCEED();
58}
59
60} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_tick.cpp b/src/core/hle/kernel/svc/svc_tick.cpp
index e9b4fd5a6..561336482 100644
--- a/src/core/hle/kernel/svc/svc_tick.cpp
+++ b/src/core/hle/kernel/svc/svc_tick.cpp
@@ -9,7 +9,7 @@
9namespace Kernel::Svc { 9namespace Kernel::Svc {
10 10
11/// This returns the total CPU ticks elapsed since the CPU was powered-on 11/// This returns the total CPU ticks elapsed since the CPU was powered-on
12u64 GetSystemTick(Core::System& system) { 12int64_t GetSystemTick(Core::System& system) {
13 LOG_TRACE(Kernel_SVC, "called"); 13 LOG_TRACE(Kernel_SVC, "called");
14 14
15 auto& core_timing = system.CoreTiming(); 15 auto& core_timing = system.CoreTiming();
@@ -21,13 +21,15 @@ u64 GetSystemTick(Core::System& system) {
21 core_timing.AddTicks(400U); 21 core_timing.AddTicks(400U);
22 } 22 }
23 23
24 return result; 24 return static_cast<int64_t>(result);
25} 25}
26 26
27void GetSystemTick32(Core::System& system, u32* time_low, u32* time_high) { 27int64_t GetSystemTick64(Core::System& system) {
28 const auto time = GetSystemTick(system); 28 return GetSystemTick(system);
29 *time_low = static_cast<u32>(time); 29}
30 *time_high = static_cast<u32>(time >> 32); 30
31int64_t GetSystemTick64From32(Core::System& system) {
32 return GetSystemTick(system);
31} 33}
32 34
33} // namespace Kernel::Svc 35} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_transfer_memory.cpp b/src/core/hle/kernel/svc/svc_transfer_memory.cpp
index b14ae24a1..a4c040e49 100644
--- a/src/core/hle/kernel/svc/svc_transfer_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_transfer_memory.cpp
@@ -72,8 +72,46 @@ Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u6
72 return ResultSuccess; 72 return ResultSuccess;
73} 73}
74 74
75Result CreateTransferMemory32(Core::System& system, Handle* out, u32 address, u32 size, 75Result MapTransferMemory(Core::System& system, Handle trmem_handle, uint64_t address, uint64_t size,
76 MemoryPermission map_perm) { 76 MemoryPermission owner_perm) {
77 return CreateTransferMemory(system, out, address, size, map_perm); 77 UNIMPLEMENTED();
78 R_THROW(ResultNotImplemented);
78} 79}
80
81Result UnmapTransferMemory(Core::System& system, Handle trmem_handle, uint64_t address,
82 uint64_t size) {
83 UNIMPLEMENTED();
84 R_THROW(ResultNotImplemented);
85}
86
87Result MapTransferMemory64(Core::System& system, Handle trmem_handle, uint64_t address,
88 uint64_t size, MemoryPermission owner_perm) {
89 R_RETURN(MapTransferMemory(system, trmem_handle, address, size, owner_perm));
90}
91
92Result UnmapTransferMemory64(Core::System& system, Handle trmem_handle, uint64_t address,
93 uint64_t size) {
94 R_RETURN(UnmapTransferMemory(system, trmem_handle, address, size));
95}
96
97Result CreateTransferMemory64(Core::System& system, Handle* out_handle, uint64_t address,
98 uint64_t size, MemoryPermission map_perm) {
99 R_RETURN(CreateTransferMemory(system, out_handle, address, size, map_perm));
100}
101
102Result MapTransferMemory64From32(Core::System& system, Handle trmem_handle, uint32_t address,
103 uint32_t size, MemoryPermission owner_perm) {
104 R_RETURN(MapTransferMemory(system, trmem_handle, address, size, owner_perm));
105}
106
107Result UnmapTransferMemory64From32(Core::System& system, Handle trmem_handle, uint32_t address,
108 uint32_t size) {
109 R_RETURN(UnmapTransferMemory(system, trmem_handle, address, size));
110}
111
112Result CreateTransferMemory64From32(Core::System& system, Handle* out_handle, uint32_t address,
113 uint32_t size, MemoryPermission map_perm) {
114 R_RETURN(CreateTransferMemory(system, out_handle, address, size, map_perm));
115}
116
79} // namespace Kernel::Svc 117} // namespace Kernel::Svc