summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/ipc_helpers.h10
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp6
-rw-r--r--src/core/hle/kernel/hle_ipc.h13
-rw-r--r--src/core/hle/kernel/k_address_arbiter.cpp13
-rw-r--r--src/core/hle/kernel/k_address_arbiter.h19
-rw-r--r--src/core/hle/kernel/k_client_port.cpp4
-rw-r--r--src/core/hle/kernel/k_client_port.h4
-rw-r--r--src/core/hle/kernel/k_client_session.cpp4
-rw-r--r--src/core/hle/kernel/k_client_session.h6
-rw-r--r--src/core/hle/kernel/k_code_memory.cpp12
-rw-r--r--src/core/hle/kernel/k_code_memory.h14
-rw-r--r--src/core/hle/kernel/k_condition_variable.cpp14
-rw-r--r--src/core/hle/kernel/k_condition_variable.h6
-rw-r--r--src/core/hle/kernel/k_handle_table.cpp6
-rw-r--r--src/core/hle/kernel/k_handle_table.h8
-rw-r--r--src/core/hle/kernel/k_light_condition_variable.cpp3
-rw-r--r--src/core/hle/kernel/k_light_lock.cpp3
-rw-r--r--src/core/hle/kernel/k_memory_manager.cpp16
-rw-r--r--src/core/hle/kernel/k_memory_manager.h16
-rw-r--r--src/core/hle/kernel/k_page_group.h (renamed from src/core/hle/kernel/k_page_linked_list.h)10
-rw-r--r--src/core/hle/kernel/k_page_table.cpp177
-rw-r--r--src/core/hle/kernel/k_page_table.h173
-rw-r--r--src/core/hle/kernel/k_port.cpp2
-rw-r--r--src/core/hle/kernel/k_port.h2
-rw-r--r--src/core/hle/kernel/k_process.cpp35
-rw-r--r--src/core/hle/kernel/k_process.h31
-rw-r--r--src/core/hle/kernel/k_readable_event.cpp6
-rw-r--r--src/core/hle/kernel/k_readable_event.h6
-rw-r--r--src/core/hle/kernel/k_resource_limit.cpp2
-rw-r--r--src/core/hle/kernel/k_resource_limit.h4
-rw-r--r--src/core/hle/kernel/k_server_session.cpp12
-rw-r--r--src/core/hle/kernel/k_server_session.h12
-rw-r--r--src/core/hle/kernel/k_shared_memory.cpp16
-rw-r--r--src/core/hle/kernel/k_shared_memory.h18
-rw-r--r--src/core/hle/kernel/k_synchronization_object.cpp13
-rw-r--r--src/core/hle/kernel/k_synchronization_object.h8
-rw-r--r--src/core/hle/kernel/k_thread.cpp50
-rw-r--r--src/core/hle/kernel/k_thread.h61
-rw-r--r--src/core/hle/kernel/k_thread_local_page.cpp4
-rw-r--r--src/core/hle/kernel/k_thread_local_page.h4
-rw-r--r--src/core/hle/kernel/k_thread_queue.cpp9
-rw-r--r--src/core/hle/kernel/k_thread_queue.h9
-rw-r--r--src/core/hle/kernel/k_transfer_memory.cpp4
-rw-r--r--src/core/hle/kernel/k_transfer_memory.h4
-rw-r--r--src/core/hle/kernel/k_writable_event.cpp4
-rw-r--r--src/core/hle/kernel/k_writable_event.h4
-rw-r--r--src/core/hle/kernel/process_capability.cpp43
-rw-r--r--src/core/hle/kernel/process_capability.h38
-rw-r--r--src/core/hle/kernel/svc.cpp294
-rw-r--r--src/core/hle/kernel/svc_results.h58
-rw-r--r--src/core/hle/kernel/svc_wrap.h124
-rw-r--r--src/core/hle/result.h44
-rw-r--r--src/core/hle/service/acc/acc.cpp14
-rw-r--r--src/core/hle/service/acc/acc.h2
-rw-r--r--src/core/hle/service/acc/async_context.h2
-rw-r--r--src/core/hle/service/acc/errors.h4
-rw-r--r--src/core/hle/service/acc/profile_manager.cpp12
-rw-r--r--src/core/hle/service/acc/profile_manager.h6
-rw-r--r--src/core/hle/service/am/am.cpp8
-rw-r--r--src/core/hle/service/am/applets/applet_controller.cpp6
-rw-r--r--src/core/hle/service/am/applets/applet_controller.h4
-rw-r--r--src/core/hle/service/am/applets/applet_error.cpp18
-rw-r--r--src/core/hle/service/am/applets/applet_error.h4
-rw-r--r--src/core/hle/service/am/applets/applet_general_backend.cpp10
-rw-r--r--src/core/hle/service/am/applets/applet_general_backend.h6
-rw-r--r--src/core/hle/service/am/applets/applet_mii_edit.cpp2
-rw-r--r--src/core/hle/service/am/applets/applet_mii_edit.h2
-rw-r--r--src/core/hle/service/am/applets/applet_profile_select.cpp4
-rw-r--r--src/core/hle/service/am/applets/applet_profile_select.h4
-rw-r--r--src/core/hle/service/am/applets/applet_software_keyboard.cpp2
-rw-r--r--src/core/hle/service/am/applets/applet_software_keyboard.h4
-rw-r--r--src/core/hle/service/am/applets/applet_web_browser.cpp2
-rw-r--r--src/core/hle/service/am/applets/applet_web_browser.h4
-rw-r--r--src/core/hle/service/am/applets/applets.h4
-rw-r--r--src/core/hle/service/audio/errors.h6
-rw-r--r--src/core/hle/service/bcat/backend/backend.cpp2
-rw-r--r--src/core/hle/service/bcat/backend/backend.h4
-rw-r--r--src/core/hle/service/bcat/bcat_module.cpp10
-rw-r--r--src/core/hle/service/es/es.cpp4
-rw-r--r--src/core/hle/service/fatal/fatal.cpp11
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp29
-rw-r--r--src/core/hle/service/filesystem/filesystem.h26
-rw-r--r--src/core/hle/service/friend/errors.h2
-rw-r--r--src/core/hle/service/glue/arp.cpp2
-rw-r--r--src/core/hle/service/glue/errors.h8
-rw-r--r--src/core/hle/service/glue/glue_manager.cpp6
-rw-r--r--src/core/hle/service/glue/glue_manager.h4
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp60
-rw-r--r--src/core/hle/service/hid/controllers/npad.h69
-rw-r--r--src/core/hle/service/hid/errors.h14
-rw-r--r--src/core/hle/service/hid/hidbus.h2
-rw-r--r--src/core/hle/service/hid/hidbus/hidbus_base.h2
-rw-r--r--src/core/hle/service/ldn/errors.h2
-rw-r--r--src/core/hle/service/ldr/ldr.cpp41
-rw-r--r--src/core/hle/service/mii/mii.cpp2
-rw-r--r--src/core/hle/service/mii/mii_manager.cpp4
-rw-r--r--src/core/hle/service/mii/mii_manager.h2
-rw-r--r--src/core/hle/service/nfp/nfp.cpp32
-rw-r--r--src/core/hle/service/nfp/nfp.h28
-rw-r--r--src/core/hle/service/ns/errors.h2
-rw-r--r--src/core/hle/service/pctl/pctl_module.cpp8
-rw-r--r--src/core/hle/service/pm/pm.cpp12
-rw-r--r--src/core/hle/service/service.cpp4
-rw-r--r--src/core/hle/service/service.h4
-rw-r--r--src/core/hle/service/set/set.cpp2
-rw-r--r--src/core/hle/service/set/set_sys.cpp2
-rw-r--r--src/core/hle/service/sm/sm.cpp18
-rw-r--r--src/core/hle/service/sm/sm.h6
-rw-r--r--src/core/hle/service/sm/sm_controller.cpp2
-rw-r--r--src/core/hle/service/spl/spl_results.h32
-rw-r--r--src/core/hle/service/time/clock_types.h8
-rw-r--r--src/core/hle/service/time/errors.h20
-rw-r--r--src/core/hle/service/time/local_system_clock_context_writer.h2
-rw-r--r--src/core/hle/service/time/network_system_clock_context_writer.h2
-rw-r--r--src/core/hle/service/time/standard_user_system_clock_core.cpp22
-rw-r--r--src/core/hle/service/time/standard_user_system_clock_core.h10
-rw-r--r--src/core/hle/service/time/system_clock_context_update_callback.cpp6
-rw-r--r--src/core/hle/service/time/system_clock_context_update_callback.h4
-rw-r--r--src/core/hle/service/time/system_clock_core.cpp14
-rw-r--r--src/core/hle/service/time/system_clock_core.h14
-rw-r--r--src/core/hle/service/time/time.cpp25
-rw-r--r--src/core/hle/service/time/time.h2
-rw-r--r--src/core/hle/service/time/time_zone_content_manager.cpp10
-rw-r--r--src/core/hle/service/time/time_zone_content_manager.h6
-rw-r--r--src/core/hle/service/time/time_zone_manager.cpp46
-rw-r--r--src/core/hle/service/time/time_zone_manager.h20
-rw-r--r--src/core/hle/service/time/time_zone_service.cpp15
-rw-r--r--src/core/hle/service/vi/vi.cpp8
128 files changed, 1120 insertions, 1160 deletions
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h
index 3c4e45fcd..004bb2005 100644
--- a/src/core/hle/ipc_helpers.h
+++ b/src/core/hle/ipc_helpers.h
@@ -19,7 +19,7 @@
19 19
20namespace IPC { 20namespace IPC {
21 21
22constexpr ResultCode ERR_REMOTE_PROCESS_DEAD{ErrorModule::HIPC, 301}; 22constexpr Result ERR_REMOTE_PROCESS_DEAD{ErrorModule::HIPC, 301};
23 23
24class RequestHelperBase { 24class RequestHelperBase {
25protected: 25protected:
@@ -176,7 +176,7 @@ public:
176 void PushImpl(float value); 176 void PushImpl(float value);
177 void PushImpl(double value); 177 void PushImpl(double value);
178 void PushImpl(bool value); 178 void PushImpl(bool value);
179 void PushImpl(ResultCode value); 179 void PushImpl(Result value);
180 180
181 template <typename T> 181 template <typename T>
182 void Push(T value) { 182 void Push(T value) {
@@ -251,7 +251,7 @@ void ResponseBuilder::PushRaw(const T& value) {
251 index += (sizeof(T) + 3) / 4; // round up to word length 251 index += (sizeof(T) + 3) / 4; // round up to word length
252} 252}
253 253
254inline void ResponseBuilder::PushImpl(ResultCode value) { 254inline void ResponseBuilder::PushImpl(Result value) {
255 // Result codes are actually 64-bit in the IPC buffer, but only the high part is discarded. 255 // Result codes are actually 64-bit in the IPC buffer, but only the high part is discarded.
256 Push(value.raw); 256 Push(value.raw);
257 Push<u32>(0); 257 Push<u32>(0);
@@ -481,8 +481,8 @@ inline bool RequestParser::Pop() {
481} 481}
482 482
483template <> 483template <>
484inline ResultCode RequestParser::Pop() { 484inline Result RequestParser::Pop() {
485 return ResultCode{Pop<u32>()}; 485 return Result{Pop<u32>()};
486} 486}
487 487
488template <typename T> 488template <typename T>
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index 4650d25b0..45135a07f 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -188,8 +188,8 @@ void HLERequestContext::ParseCommandBuffer(const KHandleTable& handle_table, u32
188 rp.Skip(1, false); // The command is actually an u64, but we don't use the high part. 188 rp.Skip(1, false); // The command is actually an u64, but we don't use the high part.
189} 189}
190 190
191ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const KHandleTable& handle_table, 191Result HLERequestContext::PopulateFromIncomingCommandBuffer(const KHandleTable& handle_table,
192 u32_le* src_cmdbuf) { 192 u32_le* src_cmdbuf) {
193 ParseCommandBuffer(handle_table, src_cmdbuf, true); 193 ParseCommandBuffer(handle_table, src_cmdbuf, true);
194 194
195 if (command_header->IsCloseCommand()) { 195 if (command_header->IsCloseCommand()) {
@@ -202,7 +202,7 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const KHandleTab
202 return ResultSuccess; 202 return ResultSuccess;
203} 203}
204 204
205ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(KThread& requesting_thread) { 205Result HLERequestContext::WriteToOutgoingCommandBuffer(KThread& requesting_thread) {
206 auto current_offset = handles_offset; 206 auto current_offset = handles_offset;
207 auto& owner_process = *requesting_thread.GetOwnerProcess(); 207 auto& owner_process = *requesting_thread.GetOwnerProcess();
208 auto& handle_table = owner_process.GetHandleTable(); 208 auto& handle_table = owner_process.GetHandleTable();
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index 0ddc8df9e..d3abeee85 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -18,7 +18,7 @@
18#include "core/hle/ipc.h" 18#include "core/hle/ipc.h"
19#include "core/hle/kernel/svc_common.h" 19#include "core/hle/kernel/svc_common.h"
20 20
21union ResultCode; 21union Result;
22 22
23namespace Core::Memory { 23namespace Core::Memory {
24class Memory; 24class Memory;
@@ -71,10 +71,10 @@ public:
71 * it should be used to differentiate which client (As in ClientSession) we're answering to. 71 * it should be used to differentiate which client (As in ClientSession) we're answering to.
72 * TODO(Subv): Use a wrapper structure to hold all the information relevant to 72 * TODO(Subv): Use a wrapper structure to hold all the information relevant to
73 * this request (ServerSession, Originator thread, Translated command buffer, etc). 73 * this request (ServerSession, Originator thread, Translated command buffer, etc).
74 * @returns ResultCode the result code of the translate operation. 74 * @returns Result the result code of the translate operation.
75 */ 75 */
76 virtual ResultCode HandleSyncRequest(Kernel::KServerSession& session, 76 virtual Result HandleSyncRequest(Kernel::KServerSession& session,
77 Kernel::HLERequestContext& context) = 0; 77 Kernel::HLERequestContext& context) = 0;
78 78
79 /** 79 /**
80 * Signals that a client has just connected to this HLE handler and keeps the 80 * Signals that a client has just connected to this HLE handler and keeps the
@@ -212,11 +212,10 @@ public:
212 } 212 }
213 213
214 /// Populates this context with data from the requesting process/thread. 214 /// Populates this context with data from the requesting process/thread.
215 ResultCode PopulateFromIncomingCommandBuffer(const KHandleTable& handle_table, 215 Result PopulateFromIncomingCommandBuffer(const KHandleTable& handle_table, u32_le* src_cmdbuf);
216 u32_le* src_cmdbuf);
217 216
218 /// Writes data from this context back to the requesting process/thread. 217 /// Writes data from this context back to the requesting process/thread.
219 ResultCode WriteToOutgoingCommandBuffer(KThread& requesting_thread); 218 Result WriteToOutgoingCommandBuffer(KThread& requesting_thread);
220 219
221 u32_le GetHipcCommand() const { 220 u32_le GetHipcCommand() const {
222 return command; 221 return command;
diff --git a/src/core/hle/kernel/k_address_arbiter.cpp b/src/core/hle/kernel/k_address_arbiter.cpp
index 5fa67bae1..f85b11557 100644
--- a/src/core/hle/kernel/k_address_arbiter.cpp
+++ b/src/core/hle/kernel/k_address_arbiter.cpp
@@ -90,8 +90,7 @@ public:
90 explicit ThreadQueueImplForKAddressArbiter(KernelCore& kernel_, KAddressArbiter::ThreadTree* t) 90 explicit ThreadQueueImplForKAddressArbiter(KernelCore& kernel_, KAddressArbiter::ThreadTree* t)
91 : KThreadQueue(kernel_), m_tree(t) {} 91 : KThreadQueue(kernel_), m_tree(t) {}
92 92
93 void CancelWait(KThread* waiting_thread, ResultCode wait_result, 93 void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
94 bool cancel_timer_task) override {
95 // If the thread is waiting on an address arbiter, remove it from the tree. 94 // If the thread is waiting on an address arbiter, remove it from the tree.
96 if (waiting_thread->IsWaitingForAddressArbiter()) { 95 if (waiting_thread->IsWaitingForAddressArbiter()) {
97 m_tree->erase(m_tree->iterator_to(*waiting_thread)); 96 m_tree->erase(m_tree->iterator_to(*waiting_thread));
@@ -108,7 +107,7 @@ private:
108 107
109} // namespace 108} // namespace
110 109
111ResultCode KAddressArbiter::Signal(VAddr addr, s32 count) { 110Result KAddressArbiter::Signal(VAddr addr, s32 count) {
112 // Perform signaling. 111 // Perform signaling.
113 s32 num_waiters{}; 112 s32 num_waiters{};
114 { 113 {
@@ -131,7 +130,7 @@ ResultCode KAddressArbiter::Signal(VAddr addr, s32 count) {
131 return ResultSuccess; 130 return ResultSuccess;
132} 131}
133 132
134ResultCode KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 count) { 133Result KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 count) {
135 // Perform signaling. 134 // Perform signaling.
136 s32 num_waiters{}; 135 s32 num_waiters{};
137 { 136 {
@@ -164,7 +163,7 @@ ResultCode KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32
164 return ResultSuccess; 163 return ResultSuccess;
165} 164}
166 165
167ResultCode KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 value, s32 count) { 166Result KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 value, s32 count) {
168 // Perform signaling. 167 // Perform signaling.
169 s32 num_waiters{}; 168 s32 num_waiters{};
170 { 169 {
@@ -232,7 +231,7 @@ ResultCode KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32
232 return ResultSuccess; 231 return ResultSuccess;
233} 232}
234 233
235ResultCode KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout) { 234Result KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout) {
236 // Prepare to wait. 235 // Prepare to wait.
237 KThread* cur_thread = GetCurrentThreadPointer(kernel); 236 KThread* cur_thread = GetCurrentThreadPointer(kernel);
238 ThreadQueueImplForKAddressArbiter wait_queue(kernel, std::addressof(thread_tree)); 237 ThreadQueueImplForKAddressArbiter wait_queue(kernel, std::addressof(thread_tree));
@@ -285,7 +284,7 @@ ResultCode KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement
285 return cur_thread->GetWaitResult(); 284 return cur_thread->GetWaitResult();
286} 285}
287 286
288ResultCode KAddressArbiter::WaitIfEqual(VAddr addr, s32 value, s64 timeout) { 287Result KAddressArbiter::WaitIfEqual(VAddr addr, s32 value, s64 timeout) {
289 // Prepare to wait. 288 // Prepare to wait.
290 KThread* cur_thread = GetCurrentThreadPointer(kernel); 289 KThread* cur_thread = GetCurrentThreadPointer(kernel);
291 ThreadQueueImplForKAddressArbiter wait_queue(kernel, std::addressof(thread_tree)); 290 ThreadQueueImplForKAddressArbiter wait_queue(kernel, std::addressof(thread_tree));
diff --git a/src/core/hle/kernel/k_address_arbiter.h b/src/core/hle/kernel/k_address_arbiter.h
index 5fa19d386..e4085ae22 100644
--- a/src/core/hle/kernel/k_address_arbiter.h
+++ b/src/core/hle/kernel/k_address_arbiter.h
@@ -8,7 +8,7 @@
8#include "core/hle/kernel/k_condition_variable.h" 8#include "core/hle/kernel/k_condition_variable.h"
9#include "core/hle/kernel/svc_types.h" 9#include "core/hle/kernel/svc_types.h"
10 10
11union ResultCode; 11union Result;
12 12
13namespace Core { 13namespace Core {
14class System; 14class System;
@@ -25,8 +25,7 @@ public:
25 explicit KAddressArbiter(Core::System& system_); 25 explicit KAddressArbiter(Core::System& system_);
26 ~KAddressArbiter(); 26 ~KAddressArbiter();
27 27
28 [[nodiscard]] ResultCode SignalToAddress(VAddr addr, Svc::SignalType type, s32 value, 28 [[nodiscard]] Result SignalToAddress(VAddr addr, Svc::SignalType type, s32 value, s32 count) {
29 s32 count) {
30 switch (type) { 29 switch (type) {
31 case Svc::SignalType::Signal: 30 case Svc::SignalType::Signal:
32 return Signal(addr, count); 31 return Signal(addr, count);
@@ -39,8 +38,8 @@ public:
39 return ResultUnknown; 38 return ResultUnknown;
40 } 39 }
41 40
42 [[nodiscard]] ResultCode WaitForAddress(VAddr addr, Svc::ArbitrationType type, s32 value, 41 [[nodiscard]] Result WaitForAddress(VAddr addr, Svc::ArbitrationType type, s32 value,
43 s64 timeout) { 42 s64 timeout) {
44 switch (type) { 43 switch (type) {
45 case Svc::ArbitrationType::WaitIfLessThan: 44 case Svc::ArbitrationType::WaitIfLessThan:
46 return WaitIfLessThan(addr, value, false, timeout); 45 return WaitIfLessThan(addr, value, false, timeout);
@@ -54,11 +53,11 @@ public:
54 } 53 }
55 54
56private: 55private:
57 [[nodiscard]] ResultCode Signal(VAddr addr, s32 count); 56 [[nodiscard]] Result Signal(VAddr addr, s32 count);
58 [[nodiscard]] ResultCode SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 count); 57 [[nodiscard]] Result SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 count);
59 [[nodiscard]] ResultCode SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 value, s32 count); 58 [[nodiscard]] Result SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 value, s32 count);
60 [[nodiscard]] ResultCode WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout); 59 [[nodiscard]] Result WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout);
61 [[nodiscard]] ResultCode WaitIfEqual(VAddr addr, s32 value, s64 timeout); 60 [[nodiscard]] Result WaitIfEqual(VAddr addr, s32 value, s64 timeout);
62 61
63 ThreadTree thread_tree; 62 ThreadTree thread_tree;
64 63
diff --git a/src/core/hle/kernel/k_client_port.cpp b/src/core/hle/kernel/k_client_port.cpp
index ef168fe87..d63e77d15 100644
--- a/src/core/hle/kernel/k_client_port.cpp
+++ b/src/core/hle/kernel/k_client_port.cpp
@@ -59,8 +59,8 @@ bool KClientPort::IsSignaled() const {
59 return num_sessions < max_sessions; 59 return num_sessions < max_sessions;
60} 60}
61 61
62ResultCode KClientPort::CreateSession(KClientSession** out, 62Result KClientPort::CreateSession(KClientSession** out,
63 std::shared_ptr<SessionRequestManager> session_manager) { 63 std::shared_ptr<SessionRequestManager> session_manager) {
64 // Reserve a new session from the resource limit. 64 // Reserve a new session from the resource limit.
65 KScopedResourceReservation session_reservation(kernel.CurrentProcess()->GetResourceLimit(), 65 KScopedResourceReservation session_reservation(kernel.CurrentProcess()->GetResourceLimit(),
66 LimitableResource::Sessions); 66 LimitableResource::Sessions);
diff --git a/src/core/hle/kernel/k_client_port.h b/src/core/hle/kernel/k_client_port.h
index 54bb05e20..ef8583efc 100644
--- a/src/core/hle/kernel/k_client_port.h
+++ b/src/core/hle/kernel/k_client_port.h
@@ -53,8 +53,8 @@ public:
53 void Destroy() override; 53 void Destroy() override;
54 bool IsSignaled() const override; 54 bool IsSignaled() const override;
55 55
56 ResultCode CreateSession(KClientSession** out, 56 Result CreateSession(KClientSession** out,
57 std::shared_ptr<SessionRequestManager> session_manager = nullptr); 57 std::shared_ptr<SessionRequestManager> session_manager = nullptr);
58 58
59private: 59private:
60 std::atomic<s32> num_sessions{}; 60 std::atomic<s32> num_sessions{};
diff --git a/src/core/hle/kernel/k_client_session.cpp b/src/core/hle/kernel/k_client_session.cpp
index 731af079c..b2a887b14 100644
--- a/src/core/hle/kernel/k_client_session.cpp
+++ b/src/core/hle/kernel/k_client_session.cpp
@@ -21,8 +21,8 @@ void KClientSession::Destroy() {
21 21
22void KClientSession::OnServerClosed() {} 22void KClientSession::OnServerClosed() {}
23 23
24ResultCode KClientSession::SendSyncRequest(KThread* thread, Core::Memory::Memory& memory, 24Result KClientSession::SendSyncRequest(KThread* thread, Core::Memory::Memory& memory,
25 Core::Timing::CoreTiming& core_timing) { 25 Core::Timing::CoreTiming& core_timing) {
26 // Signal the server session that new data is available 26 // Signal the server session that new data is available
27 return parent->GetServerSession().HandleSyncRequest(thread, memory, core_timing); 27 return parent->GetServerSession().HandleSyncRequest(thread, memory, core_timing);
28} 28}
diff --git a/src/core/hle/kernel/k_client_session.h b/src/core/hle/kernel/k_client_session.h
index 7a7ec8450..0c750d756 100644
--- a/src/core/hle/kernel/k_client_session.h
+++ b/src/core/hle/kernel/k_client_session.h
@@ -9,7 +9,7 @@
9#include "core/hle/kernel/slab_helpers.h" 9#include "core/hle/kernel/slab_helpers.h"
10#include "core/hle/result.h" 10#include "core/hle/result.h"
11 11
12union ResultCode; 12union Result;
13 13
14namespace Core::Memory { 14namespace Core::Memory {
15class Memory; 15class Memory;
@@ -46,8 +46,8 @@ public:
46 return parent; 46 return parent;
47 } 47 }
48 48
49 ResultCode SendSyncRequest(KThread* thread, Core::Memory::Memory& memory, 49 Result SendSyncRequest(KThread* thread, Core::Memory::Memory& memory,
50 Core::Timing::CoreTiming& core_timing); 50 Core::Timing::CoreTiming& core_timing);
51 51
52 void OnServerClosed(); 52 void OnServerClosed();
53 53
diff --git a/src/core/hle/kernel/k_code_memory.cpp b/src/core/hle/kernel/k_code_memory.cpp
index 4ae40ec8e..da57ceb21 100644
--- a/src/core/hle/kernel/k_code_memory.cpp
+++ b/src/core/hle/kernel/k_code_memory.cpp
@@ -7,7 +7,7 @@
7#include "core/hle/kernel/k_code_memory.h" 7#include "core/hle/kernel/k_code_memory.h"
8#include "core/hle/kernel/k_light_lock.h" 8#include "core/hle/kernel/k_light_lock.h"
9#include "core/hle/kernel/k_memory_block.h" 9#include "core/hle/kernel/k_memory_block.h"
10#include "core/hle/kernel/k_page_linked_list.h" 10#include "core/hle/kernel/k_page_group.h"
11#include "core/hle/kernel/k_page_table.h" 11#include "core/hle/kernel/k_page_table.h"
12#include "core/hle/kernel/k_process.h" 12#include "core/hle/kernel/k_process.h"
13#include "core/hle/kernel/slab_helpers.h" 13#include "core/hle/kernel/slab_helpers.h"
@@ -19,7 +19,7 @@ namespace Kernel {
19KCodeMemory::KCodeMemory(KernelCore& kernel_) 19KCodeMemory::KCodeMemory(KernelCore& kernel_)
20 : KAutoObjectWithSlabHeapAndContainer{kernel_}, m_lock(kernel_) {} 20 : KAutoObjectWithSlabHeapAndContainer{kernel_}, m_lock(kernel_) {}
21 21
22ResultCode KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr, size_t size) { 22Result KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr, size_t size) {
23 // Set members. 23 // Set members.
24 m_owner = kernel.CurrentProcess(); 24 m_owner = kernel.CurrentProcess();
25 25
@@ -62,7 +62,7 @@ void KCodeMemory::Finalize() {
62 m_owner->Close(); 62 m_owner->Close();
63} 63}
64 64
65ResultCode KCodeMemory::Map(VAddr address, size_t size) { 65Result KCodeMemory::Map(VAddr address, size_t size) {
66 // Validate the size. 66 // Validate the size.
67 R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize); 67 R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize);
68 68
@@ -82,7 +82,7 @@ ResultCode KCodeMemory::Map(VAddr address, size_t size) {
82 return ResultSuccess; 82 return ResultSuccess;
83} 83}
84 84
85ResultCode KCodeMemory::Unmap(VAddr address, size_t size) { 85Result KCodeMemory::Unmap(VAddr address, size_t size) {
86 // Validate the size. 86 // Validate the size.
87 R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize); 87 R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize);
88 88
@@ -99,7 +99,7 @@ ResultCode KCodeMemory::Unmap(VAddr address, size_t size) {
99 return ResultSuccess; 99 return ResultSuccess;
100} 100}
101 101
102ResultCode KCodeMemory::MapToOwner(VAddr address, size_t size, Svc::MemoryPermission perm) { 102Result KCodeMemory::MapToOwner(VAddr address, size_t size, Svc::MemoryPermission perm) {
103 // Validate the size. 103 // Validate the size.
104 R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize); 104 R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize);
105 105
@@ -133,7 +133,7 @@ ResultCode KCodeMemory::MapToOwner(VAddr address, size_t size, Svc::MemoryPermis
133 return ResultSuccess; 133 return ResultSuccess;
134} 134}
135 135
136ResultCode KCodeMemory::UnmapFromOwner(VAddr address, size_t size) { 136Result KCodeMemory::UnmapFromOwner(VAddr address, size_t size) {
137 // Validate the size. 137 // Validate the size.
138 R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize); 138 R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize);
139 139
diff --git a/src/core/hle/kernel/k_code_memory.h b/src/core/hle/kernel/k_code_memory.h
index ab06b6f29..2410f74a3 100644
--- a/src/core/hle/kernel/k_code_memory.h
+++ b/src/core/hle/kernel/k_code_memory.h
@@ -7,7 +7,7 @@
7#include "core/device_memory.h" 7#include "core/device_memory.h"
8#include "core/hle/kernel/k_auto_object.h" 8#include "core/hle/kernel/k_auto_object.h"
9#include "core/hle/kernel/k_light_lock.h" 9#include "core/hle/kernel/k_light_lock.h"
10#include "core/hle/kernel/k_page_linked_list.h" 10#include "core/hle/kernel/k_page_group.h"
11#include "core/hle/kernel/k_process.h" 11#include "core/hle/kernel/k_process.h"
12#include "core/hle/kernel/slab_helpers.h" 12#include "core/hle/kernel/slab_helpers.h"
13#include "core/hle/kernel/svc_types.h" 13#include "core/hle/kernel/svc_types.h"
@@ -29,13 +29,13 @@ class KCodeMemory final
29public: 29public:
30 explicit KCodeMemory(KernelCore& kernel_); 30 explicit KCodeMemory(KernelCore& kernel_);
31 31
32 ResultCode Initialize(Core::DeviceMemory& device_memory, VAddr address, size_t size); 32 Result Initialize(Core::DeviceMemory& device_memory, VAddr address, size_t size);
33 void Finalize(); 33 void Finalize();
34 34
35 ResultCode Map(VAddr address, size_t size); 35 Result Map(VAddr address, size_t size);
36 ResultCode Unmap(VAddr address, size_t size); 36 Result Unmap(VAddr address, size_t size);
37 ResultCode MapToOwner(VAddr address, size_t size, Svc::MemoryPermission perm); 37 Result MapToOwner(VAddr address, size_t size, Svc::MemoryPermission perm);
38 ResultCode UnmapFromOwner(VAddr address, size_t size); 38 Result UnmapFromOwner(VAddr address, size_t size);
39 39
40 bool IsInitialized() const { 40 bool IsInitialized() const {
41 return m_is_initialized; 41 return m_is_initialized;
@@ -53,7 +53,7 @@ public:
53 } 53 }
54 54
55private: 55private:
56 KPageLinkedList m_page_group{}; 56 KPageGroup m_page_group{};
57 KProcess* m_owner{}; 57 KProcess* m_owner{};
58 VAddr m_address{}; 58 VAddr m_address{};
59 KLightLock m_lock; 59 KLightLock m_lock;
diff --git a/src/core/hle/kernel/k_condition_variable.cpp b/src/core/hle/kernel/k_condition_variable.cpp
index a8b5411e3..124149697 100644
--- a/src/core/hle/kernel/k_condition_variable.cpp
+++ b/src/core/hle/kernel/k_condition_variable.cpp
@@ -61,8 +61,7 @@ public:
61 explicit ThreadQueueImplForKConditionVariableWaitForAddress(KernelCore& kernel_) 61 explicit ThreadQueueImplForKConditionVariableWaitForAddress(KernelCore& kernel_)
62 : KThreadQueue(kernel_) {} 62 : KThreadQueue(kernel_) {}
63 63
64 void CancelWait(KThread* waiting_thread, ResultCode wait_result, 64 void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
65 bool cancel_timer_task) override {
66 // Remove the thread as a waiter from its owner. 65 // Remove the thread as a waiter from its owner.
67 waiting_thread->GetLockOwner()->RemoveWaiter(waiting_thread); 66 waiting_thread->GetLockOwner()->RemoveWaiter(waiting_thread);
68 67
@@ -80,8 +79,7 @@ public:
80 KernelCore& kernel_, KConditionVariable::ThreadTree* t) 79 KernelCore& kernel_, KConditionVariable::ThreadTree* t)
81 : KThreadQueue(kernel_), m_tree(t) {} 80 : KThreadQueue(kernel_), m_tree(t) {}
82 81
83 void CancelWait(KThread* waiting_thread, ResultCode wait_result, 82 void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
84 bool cancel_timer_task) override {
85 // Remove the thread as a waiter from its owner. 83 // Remove the thread as a waiter from its owner.
86 if (KThread* owner = waiting_thread->GetLockOwner(); owner != nullptr) { 84 if (KThread* owner = waiting_thread->GetLockOwner(); owner != nullptr) {
87 owner->RemoveWaiter(waiting_thread); 85 owner->RemoveWaiter(waiting_thread);
@@ -105,7 +103,7 @@ KConditionVariable::KConditionVariable(Core::System& system_)
105 103
106KConditionVariable::~KConditionVariable() = default; 104KConditionVariable::~KConditionVariable() = default;
107 105
108ResultCode KConditionVariable::SignalToAddress(VAddr addr) { 106Result KConditionVariable::SignalToAddress(VAddr addr) {
109 KThread* owner_thread = GetCurrentThreadPointer(kernel); 107 KThread* owner_thread = GetCurrentThreadPointer(kernel);
110 108
111 // Signal the address. 109 // Signal the address.
@@ -126,7 +124,7 @@ ResultCode KConditionVariable::SignalToAddress(VAddr addr) {
126 } 124 }
127 125
128 // Write the value to userspace. 126 // Write the value to userspace.
129 ResultCode result{ResultSuccess}; 127 Result result{ResultSuccess};
130 if (WriteToUser(system, addr, std::addressof(next_value))) [[likely]] { 128 if (WriteToUser(system, addr, std::addressof(next_value))) [[likely]] {
131 result = ResultSuccess; 129 result = ResultSuccess;
132 } else { 130 } else {
@@ -146,7 +144,7 @@ ResultCode KConditionVariable::SignalToAddress(VAddr addr) {
146 } 144 }
147} 145}
148 146
149ResultCode KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 value) { 147Result KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 value) {
150 KThread* cur_thread = GetCurrentThreadPointer(kernel); 148 KThread* cur_thread = GetCurrentThreadPointer(kernel);
151 ThreadQueueImplForKConditionVariableWaitForAddress wait_queue(kernel); 149 ThreadQueueImplForKConditionVariableWaitForAddress wait_queue(kernel);
152 150
@@ -261,7 +259,7 @@ void KConditionVariable::Signal(u64 cv_key, s32 count) {
261 } 259 }
262} 260}
263 261
264ResultCode KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) { 262Result KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) {
265 // Prepare to wait. 263 // Prepare to wait.
266 KThread* cur_thread = GetCurrentThreadPointer(kernel); 264 KThread* cur_thread = GetCurrentThreadPointer(kernel);
267 ThreadQueueImplForKConditionVariableWaitConditionVariable wait_queue( 265 ThreadQueueImplForKConditionVariableWaitConditionVariable wait_queue(
diff --git a/src/core/hle/kernel/k_condition_variable.h b/src/core/hle/kernel/k_condition_variable.h
index 7bc749d98..fad4ed011 100644
--- a/src/core/hle/kernel/k_condition_variable.h
+++ b/src/core/hle/kernel/k_condition_variable.h
@@ -25,12 +25,12 @@ public:
25 ~KConditionVariable(); 25 ~KConditionVariable();
26 26
27 // Arbitration 27 // Arbitration
28 [[nodiscard]] ResultCode SignalToAddress(VAddr addr); 28 [[nodiscard]] Result SignalToAddress(VAddr addr);
29 [[nodiscard]] ResultCode WaitForAddress(Handle handle, VAddr addr, u32 value); 29 [[nodiscard]] Result WaitForAddress(Handle handle, VAddr addr, u32 value);
30 30
31 // Condition variable 31 // Condition variable
32 void Signal(u64 cv_key, s32 count); 32 void Signal(u64 cv_key, s32 count);
33 [[nodiscard]] ResultCode Wait(VAddr addr, u64 key, u32 value, s64 timeout); 33 [[nodiscard]] Result Wait(VAddr addr, u64 key, u32 value, s64 timeout);
34 34
35private: 35private:
36 void SignalImpl(KThread* thread); 36 void SignalImpl(KThread* thread);
diff --git a/src/core/hle/kernel/k_handle_table.cpp b/src/core/hle/kernel/k_handle_table.cpp
index c453927ad..e830ca46e 100644
--- a/src/core/hle/kernel/k_handle_table.cpp
+++ b/src/core/hle/kernel/k_handle_table.cpp
@@ -8,7 +8,7 @@ namespace Kernel {
8KHandleTable::KHandleTable(KernelCore& kernel_) : kernel{kernel_} {} 8KHandleTable::KHandleTable(KernelCore& kernel_) : kernel{kernel_} {}
9KHandleTable::~KHandleTable() = default; 9KHandleTable::~KHandleTable() = default;
10 10
11ResultCode KHandleTable::Finalize() { 11Result KHandleTable::Finalize() {
12 // Get the table and clear our record of it. 12 // Get the table and clear our record of it.
13 u16 saved_table_size = 0; 13 u16 saved_table_size = 0;
14 { 14 {
@@ -62,7 +62,7 @@ bool KHandleTable::Remove(Handle handle) {
62 return true; 62 return true;
63} 63}
64 64
65ResultCode KHandleTable::Add(Handle* out_handle, KAutoObject* obj) { 65Result KHandleTable::Add(Handle* out_handle, KAutoObject* obj) {
66 KScopedDisableDispatch dd(kernel); 66 KScopedDisableDispatch dd(kernel);
67 KScopedSpinLock lk(m_lock); 67 KScopedSpinLock lk(m_lock);
68 68
@@ -85,7 +85,7 @@ ResultCode KHandleTable::Add(Handle* out_handle, KAutoObject* obj) {
85 return ResultSuccess; 85 return ResultSuccess;
86} 86}
87 87
88ResultCode KHandleTable::Reserve(Handle* out_handle) { 88Result KHandleTable::Reserve(Handle* out_handle) {
89 KScopedDisableDispatch dd(kernel); 89 KScopedDisableDispatch dd(kernel);
90 KScopedSpinLock lk(m_lock); 90 KScopedSpinLock lk(m_lock);
91 91
diff --git a/src/core/hle/kernel/k_handle_table.h b/src/core/hle/kernel/k_handle_table.h
index befdb2ec9..0864a737c 100644
--- a/src/core/hle/kernel/k_handle_table.h
+++ b/src/core/hle/kernel/k_handle_table.h
@@ -30,7 +30,7 @@ public:
30 explicit KHandleTable(KernelCore& kernel_); 30 explicit KHandleTable(KernelCore& kernel_);
31 ~KHandleTable(); 31 ~KHandleTable();
32 32
33 ResultCode Initialize(s32 size) { 33 Result Initialize(s32 size) {
34 R_UNLESS(size <= static_cast<s32>(MaxTableSize), ResultOutOfMemory); 34 R_UNLESS(size <= static_cast<s32>(MaxTableSize), ResultOutOfMemory);
35 35
36 // Initialize all fields. 36 // Initialize all fields.
@@ -60,7 +60,7 @@ public:
60 return m_max_count; 60 return m_max_count;
61 } 61 }
62 62
63 ResultCode Finalize(); 63 Result Finalize();
64 bool Remove(Handle handle); 64 bool Remove(Handle handle);
65 65
66 template <typename T = KAutoObject> 66 template <typename T = KAutoObject>
@@ -100,10 +100,10 @@ public:
100 return this->template GetObjectWithoutPseudoHandle<T>(handle); 100 return this->template GetObjectWithoutPseudoHandle<T>(handle);
101 } 101 }
102 102
103 ResultCode Reserve(Handle* out_handle); 103 Result Reserve(Handle* out_handle);
104 void Unreserve(Handle handle); 104 void Unreserve(Handle handle);
105 105
106 ResultCode Add(Handle* out_handle, KAutoObject* obj); 106 Result Add(Handle* out_handle, KAutoObject* obj);
107 void Register(Handle handle, KAutoObject* obj); 107 void Register(Handle handle, KAutoObject* obj);
108 108
109 template <typename T> 109 template <typename T>
diff --git a/src/core/hle/kernel/k_light_condition_variable.cpp b/src/core/hle/kernel/k_light_condition_variable.cpp
index a40f35f45..cade99cfd 100644
--- a/src/core/hle/kernel/k_light_condition_variable.cpp
+++ b/src/core/hle/kernel/k_light_condition_variable.cpp
@@ -17,8 +17,7 @@ public:
17 bool term) 17 bool term)
18 : KThreadQueue(kernel_), m_wait_list(wl), m_allow_terminating_thread(term) {} 18 : KThreadQueue(kernel_), m_wait_list(wl), m_allow_terminating_thread(term) {}
19 19
20 void CancelWait(KThread* waiting_thread, ResultCode wait_result, 20 void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
21 bool cancel_timer_task) override {
22 // Only process waits if we're allowed to. 21 // Only process waits if we're allowed to.
23 if (ResultTerminationRequested == wait_result && m_allow_terminating_thread) { 22 if (ResultTerminationRequested == wait_result && m_allow_terminating_thread) {
24 return; 23 return;
diff --git a/src/core/hle/kernel/k_light_lock.cpp b/src/core/hle/kernel/k_light_lock.cpp
index 0225734b4..43185320d 100644
--- a/src/core/hle/kernel/k_light_lock.cpp
+++ b/src/core/hle/kernel/k_light_lock.cpp
@@ -15,8 +15,7 @@ class ThreadQueueImplForKLightLock final : public KThreadQueue {
15public: 15public:
16 explicit ThreadQueueImplForKLightLock(KernelCore& kernel_) : KThreadQueue(kernel_) {} 16 explicit ThreadQueueImplForKLightLock(KernelCore& kernel_) : KThreadQueue(kernel_) {}
17 17
18 void CancelWait(KThread* waiting_thread, ResultCode wait_result, 18 void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
19 bool cancel_timer_task) override {
20 // Remove the thread as a waiter from its owner. 19 // Remove the thread as a waiter from its owner.
21 if (KThread* owner = waiting_thread->GetLockOwner(); owner != nullptr) { 20 if (KThread* owner = waiting_thread->GetLockOwner(); owner != nullptr) {
22 owner->RemoveWaiter(waiting_thread); 21 owner->RemoveWaiter(waiting_thread);
diff --git a/src/core/hle/kernel/k_memory_manager.cpp b/src/core/hle/kernel/k_memory_manager.cpp
index 58e540f31..5b0a9963a 100644
--- a/src/core/hle/kernel/k_memory_manager.cpp
+++ b/src/core/hle/kernel/k_memory_manager.cpp
@@ -11,7 +11,7 @@
11#include "core/device_memory.h" 11#include "core/device_memory.h"
12#include "core/hle/kernel/initial_process.h" 12#include "core/hle/kernel/initial_process.h"
13#include "core/hle/kernel/k_memory_manager.h" 13#include "core/hle/kernel/k_memory_manager.h"
14#include "core/hle/kernel/k_page_linked_list.h" 14#include "core/hle/kernel/k_page_group.h"
15#include "core/hle/kernel/kernel.h" 15#include "core/hle/kernel/kernel.h"
16#include "core/hle/kernel/svc_results.h" 16#include "core/hle/kernel/svc_results.h"
17 17
@@ -208,8 +208,8 @@ PAddr KMemoryManager::AllocateAndOpenContinuous(size_t num_pages, size_t align_p
208 return allocated_block; 208 return allocated_block;
209} 209}
210 210
211ResultCode KMemoryManager::AllocatePageGroupImpl(KPageLinkedList* out, size_t num_pages, Pool pool, 211Result KMemoryManager::AllocatePageGroupImpl(KPageGroup* out, size_t num_pages, Pool pool,
212 Direction dir, bool random) { 212 Direction dir, bool random) {
213 // Choose a heap based on our page size request. 213 // Choose a heap based on our page size request.
214 const s32 heap_index = KPageHeap::GetBlockIndex(num_pages); 214 const s32 heap_index = KPageHeap::GetBlockIndex(num_pages);
215 R_UNLESS(0 <= heap_index, ResultOutOfMemory); 215 R_UNLESS(0 <= heap_index, ResultOutOfMemory);
@@ -257,7 +257,7 @@ ResultCode KMemoryManager::AllocatePageGroupImpl(KPageLinkedList* out, size_t nu
257 return ResultSuccess; 257 return ResultSuccess;
258} 258}
259 259
260ResultCode KMemoryManager::AllocateAndOpen(KPageLinkedList* out, size_t num_pages, u32 option) { 260Result KMemoryManager::AllocateAndOpen(KPageGroup* out, size_t num_pages, u32 option) {
261 ASSERT(out != nullptr); 261 ASSERT(out != nullptr);
262 ASSERT(out->GetNumPages() == 0); 262 ASSERT(out->GetNumPages() == 0);
263 263
@@ -293,8 +293,8 @@ ResultCode KMemoryManager::AllocateAndOpen(KPageLinkedList* out, size_t num_page
293 return ResultSuccess; 293 return ResultSuccess;
294} 294}
295 295
296ResultCode KMemoryManager::AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, 296Result KMemoryManager::AllocateAndOpenForProcess(KPageGroup* out, size_t num_pages, u32 option,
297 u32 option, u64 process_id, u8 fill_pattern) { 297 u64 process_id, u8 fill_pattern) {
298 ASSERT(out != nullptr); 298 ASSERT(out != nullptr);
299 ASSERT(out->GetNumPages() == 0); 299 ASSERT(out->GetNumPages() == 0);
300 300
@@ -370,12 +370,12 @@ void KMemoryManager::Close(PAddr address, size_t num_pages) {
370 } 370 }
371} 371}
372 372
373void KMemoryManager::Close(const KPageLinkedList& pg) { 373void KMemoryManager::Close(const KPageGroup& pg) {
374 for (const auto& node : pg.Nodes()) { 374 for (const auto& node : pg.Nodes()) {
375 Close(node.GetAddress(), node.GetNumPages()); 375 Close(node.GetAddress(), node.GetNumPages());
376 } 376 }
377} 377}
378void KMemoryManager::Open(const KPageLinkedList& pg) { 378void KMemoryManager::Open(const KPageGroup& pg) {
379 for (const auto& node : pg.Nodes()) { 379 for (const auto& node : pg.Nodes()) {
380 Open(node.GetAddress(), node.GetNumPages()); 380 Open(node.GetAddress(), node.GetNumPages());
381 } 381 }
diff --git a/src/core/hle/kernel/k_memory_manager.h b/src/core/hle/kernel/k_memory_manager.h
index c7923cb82..dcb9b6348 100644
--- a/src/core/hle/kernel/k_memory_manager.h
+++ b/src/core/hle/kernel/k_memory_manager.h
@@ -19,7 +19,7 @@ class System;
19 19
20namespace Kernel { 20namespace Kernel {
21 21
22class KPageLinkedList; 22class KPageGroup;
23 23
24class KMemoryManager final { 24class KMemoryManager final {
25public: 25public:
@@ -65,17 +65,17 @@ public:
65 } 65 }
66 66
67 PAddr AllocateAndOpenContinuous(size_t num_pages, size_t align_pages, u32 option); 67 PAddr AllocateAndOpenContinuous(size_t num_pages, size_t align_pages, u32 option);
68 ResultCode AllocateAndOpen(KPageLinkedList* out, size_t num_pages, u32 option); 68 Result AllocateAndOpen(KPageGroup* out, size_t num_pages, u32 option);
69 ResultCode AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, u32 option, 69 Result AllocateAndOpenForProcess(KPageGroup* out, size_t num_pages, u32 option, u64 process_id,
70 u64 process_id, u8 fill_pattern); 70 u8 fill_pattern);
71 71
72 static constexpr size_t MaxManagerCount = 10; 72 static constexpr size_t MaxManagerCount = 10;
73 73
74 void Close(PAddr address, size_t num_pages); 74 void Close(PAddr address, size_t num_pages);
75 void Close(const KPageLinkedList& pg); 75 void Close(const KPageGroup& pg);
76 76
77 void Open(PAddr address, size_t num_pages); 77 void Open(PAddr address, size_t num_pages);
78 void Open(const KPageLinkedList& pg); 78 void Open(const KPageGroup& pg);
79 79
80public: 80public:
81 static size_t CalculateManagementOverheadSize(size_t region_size) { 81 static size_t CalculateManagementOverheadSize(size_t region_size) {
@@ -262,8 +262,8 @@ private:
262 } 262 }
263 } 263 }
264 264
265 ResultCode AllocatePageGroupImpl(KPageLinkedList* out, size_t num_pages, Pool pool, 265 Result AllocatePageGroupImpl(KPageGroup* out, size_t num_pages, Pool pool, Direction dir,
266 Direction dir, bool random); 266 bool random);
267 267
268private: 268private:
269 Core::System& system; 269 Core::System& system;
diff --git a/src/core/hle/kernel/k_page_linked_list.h b/src/core/hle/kernel/k_page_group.h
index 1f79c8330..968753992 100644
--- a/src/core/hle/kernel/k_page_linked_list.h
+++ b/src/core/hle/kernel/k_page_group.h
@@ -12,7 +12,7 @@
12 12
13namespace Kernel { 13namespace Kernel {
14 14
15class KPageLinkedList final { 15class KPageGroup final {
16public: 16public:
17 class Node final { 17 class Node final {
18 public: 18 public:
@@ -36,8 +36,8 @@ public:
36 }; 36 };
37 37
38public: 38public:
39 KPageLinkedList() = default; 39 KPageGroup() = default;
40 KPageLinkedList(u64 address, u64 num_pages) { 40 KPageGroup(u64 address, u64 num_pages) {
41 ASSERT(AddBlock(address, num_pages).IsSuccess()); 41 ASSERT(AddBlock(address, num_pages).IsSuccess());
42 } 42 }
43 43
@@ -57,7 +57,7 @@ public:
57 return num_pages; 57 return num_pages;
58 } 58 }
59 59
60 bool IsEqual(KPageLinkedList& other) const { 60 bool IsEqual(KPageGroup& other) const {
61 auto this_node = nodes.begin(); 61 auto this_node = nodes.begin();
62 auto other_node = other.nodes.begin(); 62 auto other_node = other.nodes.begin();
63 while (this_node != nodes.end() && other_node != other.nodes.end()) { 63 while (this_node != nodes.end() && other_node != other.nodes.end()) {
@@ -72,7 +72,7 @@ public:
72 return this_node == nodes.end() && other_node == other.nodes.end(); 72 return this_node == nodes.end() && other_node == other.nodes.end();
73 } 73 }
74 74
75 ResultCode AddBlock(u64 address, u64 num_pages) { 75 Result AddBlock(u64 address, u64 num_pages) {
76 if (!num_pages) { 76 if (!num_pages) {
77 return ResultSuccess; 77 return ResultSuccess;
78 } 78 }
diff --git a/src/core/hle/kernel/k_page_table.cpp b/src/core/hle/kernel/k_page_table.cpp
index 39b89da53..d975de844 100644
--- a/src/core/hle/kernel/k_page_table.cpp
+++ b/src/core/hle/kernel/k_page_table.cpp
@@ -9,7 +9,7 @@
9#include "core/hle/kernel/k_address_space_info.h" 9#include "core/hle/kernel/k_address_space_info.h"
10#include "core/hle/kernel/k_memory_block.h" 10#include "core/hle/kernel/k_memory_block.h"
11#include "core/hle/kernel/k_memory_block_manager.h" 11#include "core/hle/kernel/k_memory_block_manager.h"
12#include "core/hle/kernel/k_page_linked_list.h" 12#include "core/hle/kernel/k_page_group.h"
13#include "core/hle/kernel/k_page_table.h" 13#include "core/hle/kernel/k_page_table.h"
14#include "core/hle/kernel/k_process.h" 14#include "core/hle/kernel/k_process.h"
15#include "core/hle/kernel/k_resource_limit.h" 15#include "core/hle/kernel/k_resource_limit.h"
@@ -47,9 +47,9 @@ KPageTable::KPageTable(Core::System& system_)
47 47
48KPageTable::~KPageTable() = default; 48KPageTable::~KPageTable() = default;
49 49
50ResultCode KPageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, 50Result KPageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, bool enable_aslr,
51 bool enable_aslr, VAddr code_addr, 51 VAddr code_addr, std::size_t code_size,
52 std::size_t code_size, KMemoryManager::Pool pool) { 52 KMemoryManager::Pool pool) {
53 53
54 const auto GetSpaceStart = [this](KAddressSpaceInfo::Type type) { 54 const auto GetSpaceStart = [this](KAddressSpaceInfo::Type type) {
55 return KAddressSpaceInfo::GetAddressSpaceStart(address_space_width, type); 55 return KAddressSpaceInfo::GetAddressSpaceStart(address_space_width, type);
@@ -257,8 +257,8 @@ ResultCode KPageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_
257 return InitializeMemoryLayout(start, end); 257 return InitializeMemoryLayout(start, end);
258} 258}
259 259
260ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryState state, 260Result KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryState state,
261 KMemoryPermission perm) { 261 KMemoryPermission perm) {
262 const u64 size{num_pages * PageSize}; 262 const u64 size{num_pages * PageSize};
263 263
264 // Validate the mapping request. 264 // Validate the mapping request.
@@ -271,7 +271,7 @@ ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemory
271 R_TRY(this->CheckMemoryState(addr, size, KMemoryState::All, KMemoryState::Free, 271 R_TRY(this->CheckMemoryState(addr, size, KMemoryState::All, KMemoryState::Free,
272 KMemoryPermission::None, KMemoryPermission::None, 272 KMemoryPermission::None, KMemoryPermission::None,
273 KMemoryAttribute::None, KMemoryAttribute::None)); 273 KMemoryAttribute::None, KMemoryAttribute::None));
274 KPageLinkedList pg; 274 KPageGroup pg;
275 R_TRY(system.Kernel().MemoryManager().AllocateAndOpen( 275 R_TRY(system.Kernel().MemoryManager().AllocateAndOpen(
276 &pg, num_pages, 276 &pg, num_pages,
277 KMemoryManager::EncodeOption(KMemoryManager::Pool::Application, allocation_option))); 277 KMemoryManager::EncodeOption(KMemoryManager::Pool::Application, allocation_option)));
@@ -283,7 +283,7 @@ ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemory
283 return ResultSuccess; 283 return ResultSuccess;
284} 284}
285 285
286ResultCode KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size) { 286Result KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size) {
287 // Validate the mapping request. 287 // Validate the mapping request.
288 R_UNLESS(this->CanContain(dst_address, size, KMemoryState::AliasCode), 288 R_UNLESS(this->CanContain(dst_address, size, KMemoryState::AliasCode),
289 ResultInvalidMemoryRegion); 289 ResultInvalidMemoryRegion);
@@ -313,7 +313,7 @@ ResultCode KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std::
313 const std::size_t num_pages = size / PageSize; 313 const std::size_t num_pages = size / PageSize;
314 314
315 // Create page groups for the memory being mapped. 315 // Create page groups for the memory being mapped.
316 KPageLinkedList pg; 316 KPageGroup pg;
317 AddRegionToPages(src_address, num_pages, pg); 317 AddRegionToPages(src_address, num_pages, pg);
318 318
319 // Reprotect the source as kernel-read/not mapped. 319 // Reprotect the source as kernel-read/not mapped.
@@ -344,8 +344,8 @@ ResultCode KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std::
344 return ResultSuccess; 344 return ResultSuccess;
345} 345}
346 346
347ResultCode KPageTable::UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size, 347Result KPageTable::UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size,
348 ICacheInvalidationStrategy icache_invalidation_strategy) { 348 ICacheInvalidationStrategy icache_invalidation_strategy) {
349 // Validate the mapping request. 349 // Validate the mapping request.
350 R_UNLESS(this->CanContain(dst_address, size, KMemoryState::AliasCode), 350 R_UNLESS(this->CanContain(dst_address, size, KMemoryState::AliasCode),
351 ResultInvalidMemoryRegion); 351 ResultInvalidMemoryRegion);
@@ -489,7 +489,7 @@ VAddr KPageTable::FindFreeArea(VAddr region_start, std::size_t region_num_pages,
489 return address; 489 return address;
490} 490}
491 491
492ResultCode KPageTable::MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pages) { 492Result KPageTable::MakePageGroup(KPageGroup& pg, VAddr addr, size_t num_pages) {
493 ASSERT(this->IsLockedByCurrentThread()); 493 ASSERT(this->IsLockedByCurrentThread());
494 494
495 const size_t size = num_pages * PageSize; 495 const size_t size = num_pages * PageSize;
@@ -541,7 +541,7 @@ ResultCode KPageTable::MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num
541 return ResultSuccess; 541 return ResultSuccess;
542} 542}
543 543
544bool KPageTable::IsValidPageGroup(const KPageLinkedList& pg_ll, VAddr addr, size_t num_pages) { 544bool KPageTable::IsValidPageGroup(const KPageGroup& pg_ll, VAddr addr, size_t num_pages) {
545 ASSERT(this->IsLockedByCurrentThread()); 545 ASSERT(this->IsLockedByCurrentThread());
546 546
547 const size_t size = num_pages * PageSize; 547 const size_t size = num_pages * PageSize;
@@ -630,8 +630,8 @@ bool KPageTable::IsValidPageGroup(const KPageLinkedList& pg_ll, VAddr addr, size
630 return cur_block_address == cur_addr && cur_block_pages == (cur_size / PageSize); 630 return cur_block_address == cur_addr && cur_block_pages == (cur_size / PageSize);
631} 631}
632 632
633ResultCode KPageTable::UnmapProcessMemory(VAddr dst_addr, std::size_t size, 633Result KPageTable::UnmapProcessMemory(VAddr dst_addr, std::size_t size, KPageTable& src_page_table,
634 KPageTable& src_page_table, VAddr src_addr) { 634 VAddr src_addr) {
635 KScopedLightLock lk(general_lock); 635 KScopedLightLock lk(general_lock);
636 636
637 const std::size_t num_pages{size / PageSize}; 637 const std::size_t num_pages{size / PageSize};
@@ -660,7 +660,7 @@ ResultCode KPageTable::UnmapProcessMemory(VAddr dst_addr, std::size_t size,
660 return ResultSuccess; 660 return ResultSuccess;
661} 661}
662 662
663ResultCode KPageTable::MapPhysicalMemory(VAddr address, std::size_t size) { 663Result KPageTable::MapPhysicalMemory(VAddr address, std::size_t size) {
664 // Lock the physical memory lock. 664 // Lock the physical memory lock.
665 KScopedLightLock map_phys_mem_lk(map_physical_memory_lock); 665 KScopedLightLock map_phys_mem_lk(map_physical_memory_lock);
666 666
@@ -721,7 +721,7 @@ ResultCode KPageTable::MapPhysicalMemory(VAddr address, std::size_t size) {
721 R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached); 721 R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached);
722 722
723 // Allocate pages for the new memory. 723 // Allocate pages for the new memory.
724 KPageLinkedList pg; 724 KPageGroup pg;
725 R_TRY(system.Kernel().MemoryManager().AllocateAndOpenForProcess( 725 R_TRY(system.Kernel().MemoryManager().AllocateAndOpenForProcess(
726 &pg, (size - mapped_size) / PageSize, 726 &pg, (size - mapped_size) / PageSize,
727 KMemoryManager::EncodeOption(memory_pool, allocation_option), 0, 0)); 727 KMemoryManager::EncodeOption(memory_pool, allocation_option), 0, 0));
@@ -903,7 +903,7 @@ ResultCode KPageTable::MapPhysicalMemory(VAddr address, std::size_t size) {
903 } 903 }
904} 904}
905 905
906ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) { 906Result KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) {
907 // Lock the physical memory lock. 907 // Lock the physical memory lock.
908 KScopedLightLock map_phys_mem_lk(map_physical_memory_lock); 908 KScopedLightLock map_phys_mem_lk(map_physical_memory_lock);
909 909
@@ -972,7 +972,7 @@ ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) {
972 } 972 }
973 973
974 // Make a page group for the unmap region. 974 // Make a page group for the unmap region.
975 KPageLinkedList pg; 975 KPageGroup pg;
976 { 976 {
977 auto& impl = this->PageTableImpl(); 977 auto& impl = this->PageTableImpl();
978 978
@@ -1134,7 +1134,7 @@ ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) {
1134 return ResultSuccess; 1134 return ResultSuccess;
1135} 1135}
1136 1136
1137ResultCode KPageTable::MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) { 1137Result KPageTable::MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) {
1138 KScopedLightLock lk(general_lock); 1138 KScopedLightLock lk(general_lock);
1139 1139
1140 KMemoryState src_state{}; 1140 KMemoryState src_state{};
@@ -1147,7 +1147,7 @@ ResultCode KPageTable::MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t siz
1147 return ResultInvalidCurrentMemory; 1147 return ResultInvalidCurrentMemory;
1148 } 1148 }
1149 1149
1150 KPageLinkedList page_linked_list; 1150 KPageGroup page_linked_list;
1151 const std::size_t num_pages{size / PageSize}; 1151 const std::size_t num_pages{size / PageSize};
1152 1152
1153 AddRegionToPages(src_addr, num_pages, page_linked_list); 1153 AddRegionToPages(src_addr, num_pages, page_linked_list);
@@ -1173,7 +1173,7 @@ ResultCode KPageTable::MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t siz
1173 return ResultSuccess; 1173 return ResultSuccess;
1174} 1174}
1175 1175
1176ResultCode KPageTable::UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) { 1176Result KPageTable::UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) {
1177 KScopedLightLock lk(general_lock); 1177 KScopedLightLock lk(general_lock);
1178 1178
1179 KMemoryState src_state{}; 1179 KMemoryState src_state{};
@@ -1188,8 +1188,8 @@ ResultCode KPageTable::UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t s
1188 KMemoryPermission::None, KMemoryAttribute::Mask, 1188 KMemoryPermission::None, KMemoryAttribute::Mask,
1189 KMemoryAttribute::None, KMemoryAttribute::IpcAndDeviceMapped)); 1189 KMemoryAttribute::None, KMemoryAttribute::IpcAndDeviceMapped));
1190 1190
1191 KPageLinkedList src_pages; 1191 KPageGroup src_pages;
1192 KPageLinkedList dst_pages; 1192 KPageGroup dst_pages;
1193 const std::size_t num_pages{size / PageSize}; 1193 const std::size_t num_pages{size / PageSize};
1194 1194
1195 AddRegionToPages(src_addr, num_pages, src_pages); 1195 AddRegionToPages(src_addr, num_pages, src_pages);
@@ -1215,8 +1215,8 @@ ResultCode KPageTable::UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t s
1215 return ResultSuccess; 1215 return ResultSuccess;
1216} 1216}
1217 1217
1218ResultCode KPageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_list, 1218Result KPageTable::MapPages(VAddr addr, const KPageGroup& page_linked_list,
1219 KMemoryPermission perm) { 1219 KMemoryPermission perm) {
1220 ASSERT(this->IsLockedByCurrentThread()); 1220 ASSERT(this->IsLockedByCurrentThread());
1221 1221
1222 VAddr cur_addr{addr}; 1222 VAddr cur_addr{addr};
@@ -1239,8 +1239,8 @@ ResultCode KPageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_l
1239 return ResultSuccess; 1239 return ResultSuccess;
1240} 1240}
1241 1241
1242ResultCode KPageTable::MapPages(VAddr address, KPageLinkedList& page_linked_list, 1242Result KPageTable::MapPages(VAddr address, KPageGroup& page_linked_list, KMemoryState state,
1243 KMemoryState state, KMemoryPermission perm) { 1243 KMemoryPermission perm) {
1244 // Check that the map is in range. 1244 // Check that the map is in range.
1245 const std::size_t num_pages{page_linked_list.GetNumPages()}; 1245 const std::size_t num_pages{page_linked_list.GetNumPages()};
1246 const std::size_t size{num_pages * PageSize}; 1246 const std::size_t size{num_pages * PageSize};
@@ -1263,10 +1263,10 @@ ResultCode KPageTable::MapPages(VAddr address, KPageLinkedList& page_linked_list
1263 return ResultSuccess; 1263 return ResultSuccess;
1264} 1264}
1265 1265
1266ResultCode KPageTable::MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, 1266Result KPageTable::MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment,
1267 PAddr phys_addr, bool is_pa_valid, VAddr region_start, 1267 PAddr phys_addr, bool is_pa_valid, VAddr region_start,
1268 std::size_t region_num_pages, KMemoryState state, 1268 std::size_t region_num_pages, KMemoryState state,
1269 KMemoryPermission perm) { 1269 KMemoryPermission perm) {
1270 ASSERT(Common::IsAligned(alignment, PageSize) && alignment >= PageSize); 1270 ASSERT(Common::IsAligned(alignment, PageSize) && alignment >= PageSize);
1271 1271
1272 // Ensure this is a valid map request. 1272 // Ensure this is a valid map request.
@@ -1303,7 +1303,7 @@ ResultCode KPageTable::MapPages(VAddr* out_addr, std::size_t num_pages, std::siz
1303 return ResultSuccess; 1303 return ResultSuccess;
1304} 1304}
1305 1305
1306ResultCode KPageTable::UnmapPages(VAddr addr, const KPageLinkedList& page_linked_list) { 1306Result KPageTable::UnmapPages(VAddr addr, const KPageGroup& page_linked_list) {
1307 ASSERT(this->IsLockedByCurrentThread()); 1307 ASSERT(this->IsLockedByCurrentThread());
1308 1308
1309 VAddr cur_addr{addr}; 1309 VAddr cur_addr{addr};
@@ -1321,8 +1321,7 @@ ResultCode KPageTable::UnmapPages(VAddr addr, const KPageLinkedList& page_linked
1321 return ResultSuccess; 1321 return ResultSuccess;
1322} 1322}
1323 1323
1324ResultCode KPageTable::UnmapPages(VAddr addr, KPageLinkedList& page_linked_list, 1324Result KPageTable::UnmapPages(VAddr addr, KPageGroup& page_linked_list, KMemoryState state) {
1325 KMemoryState state) {
1326 // Check that the unmap is in range. 1325 // Check that the unmap is in range.
1327 const std::size_t num_pages{page_linked_list.GetNumPages()}; 1326 const std::size_t num_pages{page_linked_list.GetNumPages()};
1328 const std::size_t size{num_pages * PageSize}; 1327 const std::size_t size{num_pages * PageSize};
@@ -1345,7 +1344,7 @@ ResultCode KPageTable::UnmapPages(VAddr addr, KPageLinkedList& page_linked_list,
1345 return ResultSuccess; 1344 return ResultSuccess;
1346} 1345}
1347 1346
1348ResultCode KPageTable::UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state) { 1347Result KPageTable::UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state) {
1349 // Check that the unmap is in range. 1348 // Check that the unmap is in range.
1350 const std::size_t size = num_pages * PageSize; 1349 const std::size_t size = num_pages * PageSize;
1351 R_UNLESS(this->Contains(address, size), ResultInvalidCurrentMemory); 1350 R_UNLESS(this->Contains(address, size), ResultInvalidCurrentMemory);
@@ -1369,10 +1368,10 @@ ResultCode KPageTable::UnmapPages(VAddr address, std::size_t num_pages, KMemoryS
1369 return ResultSuccess; 1368 return ResultSuccess;
1370} 1369}
1371 1370
1372ResultCode KPageTable::MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address, size_t num_pages, 1371Result KPageTable::MakeAndOpenPageGroup(KPageGroup* out, VAddr address, size_t num_pages,
1373 KMemoryState state_mask, KMemoryState state, 1372 KMemoryState state_mask, KMemoryState state,
1374 KMemoryPermission perm_mask, KMemoryPermission perm, 1373 KMemoryPermission perm_mask, KMemoryPermission perm,
1375 KMemoryAttribute attr_mask, KMemoryAttribute attr) { 1374 KMemoryAttribute attr_mask, KMemoryAttribute attr) {
1376 // Ensure that the page group isn't null. 1375 // Ensure that the page group isn't null.
1377 ASSERT(out != nullptr); 1376 ASSERT(out != nullptr);
1378 1377
@@ -1394,8 +1393,8 @@ ResultCode KPageTable::MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address,
1394 return ResultSuccess; 1393 return ResultSuccess;
1395} 1394}
1396 1395
1397ResultCode KPageTable::SetProcessMemoryPermission(VAddr addr, std::size_t size, 1396Result KPageTable::SetProcessMemoryPermission(VAddr addr, std::size_t size,
1398 Svc::MemoryPermission svc_perm) { 1397 Svc::MemoryPermission svc_perm) {
1399 const size_t num_pages = size / PageSize; 1398 const size_t num_pages = size / PageSize;
1400 1399
1401 // Lock the table. 1400 // Lock the table.
@@ -1467,7 +1466,7 @@ KMemoryInfo KPageTable::QueryInfo(VAddr addr) {
1467 return QueryInfoImpl(addr); 1466 return QueryInfoImpl(addr);
1468} 1467}
1469 1468
1470ResultCode KPageTable::ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm) { 1469Result KPageTable::ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm) {
1471 KScopedLightLock lk(general_lock); 1470 KScopedLightLock lk(general_lock);
1472 1471
1473 KMemoryState state{}; 1472 KMemoryState state{};
@@ -1485,7 +1484,7 @@ ResultCode KPageTable::ReserveTransferMemory(VAddr addr, std::size_t size, KMemo
1485 return ResultSuccess; 1484 return ResultSuccess;
1486} 1485}
1487 1486
1488ResultCode KPageTable::ResetTransferMemory(VAddr addr, std::size_t size) { 1487Result KPageTable::ResetTransferMemory(VAddr addr, std::size_t size) {
1489 KScopedLightLock lk(general_lock); 1488 KScopedLightLock lk(general_lock);
1490 1489
1491 KMemoryState state{}; 1490 KMemoryState state{};
@@ -1500,8 +1499,8 @@ ResultCode KPageTable::ResetTransferMemory(VAddr addr, std::size_t size) {
1500 return ResultSuccess; 1499 return ResultSuccess;
1501} 1500}
1502 1501
1503ResultCode KPageTable::SetMemoryPermission(VAddr addr, std::size_t size, 1502Result KPageTable::SetMemoryPermission(VAddr addr, std::size_t size,
1504 Svc::MemoryPermission svc_perm) { 1503 Svc::MemoryPermission svc_perm) {
1505 const size_t num_pages = size / PageSize; 1504 const size_t num_pages = size / PageSize;
1506 1505
1507 // Lock the table. 1506 // Lock the table.
@@ -1528,7 +1527,7 @@ ResultCode KPageTable::SetMemoryPermission(VAddr addr, std::size_t size,
1528 return ResultSuccess; 1527 return ResultSuccess;
1529} 1528}
1530 1529
1531ResultCode KPageTable::SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask, u32 attr) { 1530Result KPageTable::SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask, u32 attr) {
1532 const size_t num_pages = size / PageSize; 1531 const size_t num_pages = size / PageSize;
1533 ASSERT((static_cast<KMemoryAttribute>(mask) | KMemoryAttribute::SetMask) == 1532 ASSERT((static_cast<KMemoryAttribute>(mask) | KMemoryAttribute::SetMask) ==
1534 KMemoryAttribute::SetMask); 1533 KMemoryAttribute::SetMask);
@@ -1563,7 +1562,7 @@ ResultCode KPageTable::SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask
1563 return ResultSuccess; 1562 return ResultSuccess;
1564} 1563}
1565 1564
1566ResultCode KPageTable::SetMaxHeapSize(std::size_t size) { 1565Result KPageTable::SetMaxHeapSize(std::size_t size) {
1567 // Lock the table. 1566 // Lock the table.
1568 KScopedLightLock lk(general_lock); 1567 KScopedLightLock lk(general_lock);
1569 1568
@@ -1575,7 +1574,7 @@ ResultCode KPageTable::SetMaxHeapSize(std::size_t size) {
1575 return ResultSuccess; 1574 return ResultSuccess;
1576} 1575}
1577 1576
1578ResultCode KPageTable::SetHeapSize(VAddr* out, std::size_t size) { 1577Result KPageTable::SetHeapSize(VAddr* out, std::size_t size) {
1579 // Lock the physical memory mutex. 1578 // Lock the physical memory mutex.
1580 KScopedLightLock map_phys_mem_lk(map_physical_memory_lock); 1579 KScopedLightLock map_phys_mem_lk(map_physical_memory_lock);
1581 1580
@@ -1642,7 +1641,7 @@ ResultCode KPageTable::SetHeapSize(VAddr* out, std::size_t size) {
1642 R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached); 1641 R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached);
1643 1642
1644 // Allocate pages for the heap extension. 1643 // Allocate pages for the heap extension.
1645 KPageLinkedList pg; 1644 KPageGroup pg;
1646 R_TRY(system.Kernel().MemoryManager().AllocateAndOpen( 1645 R_TRY(system.Kernel().MemoryManager().AllocateAndOpen(
1647 &pg, allocation_size / PageSize, 1646 &pg, allocation_size / PageSize,
1648 KMemoryManager::EncodeOption(memory_pool, allocation_option))); 1647 KMemoryManager::EncodeOption(memory_pool, allocation_option)));
@@ -1717,7 +1716,7 @@ ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages,
1717 if (is_map_only) { 1716 if (is_map_only) {
1718 R_TRY(Operate(addr, needed_num_pages, perm, OperationType::Map, map_addr)); 1717 R_TRY(Operate(addr, needed_num_pages, perm, OperationType::Map, map_addr));
1719 } else { 1718 } else {
1720 KPageLinkedList page_group; 1719 KPageGroup page_group;
1721 R_TRY(system.Kernel().MemoryManager().AllocateAndOpenForProcess( 1720 R_TRY(system.Kernel().MemoryManager().AllocateAndOpenForProcess(
1722 &page_group, needed_num_pages, 1721 &page_group, needed_num_pages,
1723 KMemoryManager::EncodeOption(memory_pool, allocation_option), 0, 0)); 1722 KMemoryManager::EncodeOption(memory_pool, allocation_option), 0, 0));
@@ -1729,11 +1728,11 @@ ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages,
1729 return addr; 1728 return addr;
1730} 1729}
1731 1730
1732ResultCode KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) { 1731Result KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) {
1733 KScopedLightLock lk(general_lock); 1732 KScopedLightLock lk(general_lock);
1734 1733
1735 KMemoryPermission perm{}; 1734 KMemoryPermission perm{};
1736 if (const ResultCode result{CheckMemoryState( 1735 if (const Result result{CheckMemoryState(
1737 nullptr, &perm, nullptr, nullptr, addr, size, KMemoryState::FlagCanChangeAttribute, 1736 nullptr, &perm, nullptr, nullptr, addr, size, KMemoryState::FlagCanChangeAttribute,
1738 KMemoryState::FlagCanChangeAttribute, KMemoryPermission::None, KMemoryPermission::None, 1737 KMemoryState::FlagCanChangeAttribute, KMemoryPermission::None, KMemoryPermission::None,
1739 KMemoryAttribute::LockedAndIpcLocked, KMemoryAttribute::None, 1738 KMemoryAttribute::LockedAndIpcLocked, KMemoryAttribute::None,
@@ -1752,11 +1751,11 @@ ResultCode KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) {
1752 return ResultSuccess; 1751 return ResultSuccess;
1753} 1752}
1754 1753
1755ResultCode KPageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size) { 1754Result KPageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size) {
1756 KScopedLightLock lk(general_lock); 1755 KScopedLightLock lk(general_lock);
1757 1756
1758 KMemoryPermission perm{}; 1757 KMemoryPermission perm{};
1759 if (const ResultCode result{CheckMemoryState( 1758 if (const Result result{CheckMemoryState(
1760 nullptr, &perm, nullptr, nullptr, addr, size, KMemoryState::FlagCanChangeAttribute, 1759 nullptr, &perm, nullptr, nullptr, addr, size, KMemoryState::FlagCanChangeAttribute,
1761 KMemoryState::FlagCanChangeAttribute, KMemoryPermission::None, KMemoryPermission::None, 1760 KMemoryState::FlagCanChangeAttribute, KMemoryPermission::None, KMemoryPermission::None,
1762 KMemoryAttribute::LockedAndIpcLocked, KMemoryAttribute::None, 1761 KMemoryAttribute::LockedAndIpcLocked, KMemoryAttribute::None,
@@ -1775,7 +1774,7 @@ ResultCode KPageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size)
1775 return ResultSuccess; 1774 return ResultSuccess;
1776} 1775}
1777 1776
1778ResultCode KPageTable::LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::size_t size) { 1777Result KPageTable::LockForCodeMemory(KPageGroup* out, VAddr addr, std::size_t size) {
1779 return this->LockMemoryAndOpen( 1778 return this->LockMemoryAndOpen(
1780 out, nullptr, addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory, 1779 out, nullptr, addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory,
1781 KMemoryPermission::All, KMemoryPermission::UserReadWrite, KMemoryAttribute::All, 1780 KMemoryPermission::All, KMemoryPermission::UserReadWrite, KMemoryAttribute::All,
@@ -1785,15 +1784,14 @@ ResultCode KPageTable::LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::
1785 KMemoryAttribute::Locked); 1784 KMemoryAttribute::Locked);
1786} 1785}
1787 1786
1788ResultCode KPageTable::UnlockForCodeMemory(VAddr addr, std::size_t size, 1787Result KPageTable::UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageGroup& pg) {
1789 const KPageLinkedList& pg) {
1790 return this->UnlockMemory( 1788 return this->UnlockMemory(
1791 addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory, 1789 addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory,
1792 KMemoryPermission::None, KMemoryPermission::None, KMemoryAttribute::All, 1790 KMemoryPermission::None, KMemoryPermission::None, KMemoryAttribute::All,
1793 KMemoryAttribute::Locked, KMemoryPermission::UserReadWrite, KMemoryAttribute::Locked, &pg); 1791 KMemoryAttribute::Locked, KMemoryPermission::UserReadWrite, KMemoryAttribute::Locked, &pg);
1794} 1792}
1795 1793
1796ResultCode KPageTable::InitializeMemoryLayout(VAddr start, VAddr end) { 1794Result KPageTable::InitializeMemoryLayout(VAddr start, VAddr end) {
1797 block_manager = std::make_unique<KMemoryBlockManager>(start, end); 1795 block_manager = std::make_unique<KMemoryBlockManager>(start, end);
1798 1796
1799 return ResultSuccess; 1797 return ResultSuccess;
@@ -1818,7 +1816,7 @@ bool KPageTable::IsRegionContiguous(VAddr addr, u64 size) const {
1818} 1816}
1819 1817
1820void KPageTable::AddRegionToPages(VAddr start, std::size_t num_pages, 1818void KPageTable::AddRegionToPages(VAddr start, std::size_t num_pages,
1821 KPageLinkedList& page_linked_list) { 1819 KPageGroup& page_linked_list) {
1822 VAddr addr{start}; 1820 VAddr addr{start};
1823 while (addr < start + (num_pages * PageSize)) { 1821 while (addr < start + (num_pages * PageSize)) {
1824 const PAddr paddr{GetPhysicalAddr(addr)}; 1822 const PAddr paddr{GetPhysicalAddr(addr)};
@@ -1837,8 +1835,8 @@ VAddr KPageTable::AllocateVirtualMemory(VAddr start, std::size_t region_num_page
1837 IsKernel() ? 1 : 4); 1835 IsKernel() ? 1 : 4);
1838} 1836}
1839 1837
1840ResultCode KPageTable::Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& page_group, 1838Result KPageTable::Operate(VAddr addr, std::size_t num_pages, const KPageGroup& page_group,
1841 OperationType operation) { 1839 OperationType operation) {
1842 ASSERT(this->IsLockedByCurrentThread()); 1840 ASSERT(this->IsLockedByCurrentThread());
1843 1841
1844 ASSERT(Common::IsAligned(addr, PageSize)); 1842 ASSERT(Common::IsAligned(addr, PageSize));
@@ -1862,8 +1860,8 @@ ResultCode KPageTable::Operate(VAddr addr, std::size_t num_pages, const KPageLin
1862 return ResultSuccess; 1860 return ResultSuccess;
1863} 1861}
1864 1862
1865ResultCode KPageTable::Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm, 1863Result KPageTable::Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm,
1866 OperationType operation, PAddr map_addr) { 1864 OperationType operation, PAddr map_addr) {
1867 ASSERT(this->IsLockedByCurrentThread()); 1865 ASSERT(this->IsLockedByCurrentThread());
1868 1866
1869 ASSERT(num_pages > 0); 1867 ASSERT(num_pages > 0);
@@ -2005,10 +2003,10 @@ bool KPageTable::CanContain(VAddr addr, std::size_t size, KMemoryState state) co
2005 } 2003 }
2006} 2004}
2007 2005
2008ResultCode KPageTable::CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask, 2006Result KPageTable::CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask,
2009 KMemoryState state, KMemoryPermission perm_mask, 2007 KMemoryState state, KMemoryPermission perm_mask,
2010 KMemoryPermission perm, KMemoryAttribute attr_mask, 2008 KMemoryPermission perm, KMemoryAttribute attr_mask,
2011 KMemoryAttribute attr) const { 2009 KMemoryAttribute attr) const {
2012 // Validate the states match expectation. 2010 // Validate the states match expectation.
2013 R_UNLESS((info.state & state_mask) == state, ResultInvalidCurrentMemory); 2011 R_UNLESS((info.state & state_mask) == state, ResultInvalidCurrentMemory);
2014 R_UNLESS((info.perm & perm_mask) == perm, ResultInvalidCurrentMemory); 2012 R_UNLESS((info.perm & perm_mask) == perm, ResultInvalidCurrentMemory);
@@ -2017,12 +2015,11 @@ ResultCode KPageTable::CheckMemoryState(const KMemoryInfo& info, KMemoryState st
2017 return ResultSuccess; 2015 return ResultSuccess;
2018} 2016}
2019 2017
2020ResultCode KPageTable::CheckMemoryStateContiguous(std::size_t* out_blocks_needed, VAddr addr, 2018Result KPageTable::CheckMemoryStateContiguous(std::size_t* out_blocks_needed, VAddr addr,
2021 std::size_t size, KMemoryState state_mask, 2019 std::size_t size, KMemoryState state_mask,
2022 KMemoryState state, KMemoryPermission perm_mask, 2020 KMemoryState state, KMemoryPermission perm_mask,
2023 KMemoryPermission perm, 2021 KMemoryPermission perm, KMemoryAttribute attr_mask,
2024 KMemoryAttribute attr_mask, 2022 KMemoryAttribute attr) const {
2025 KMemoryAttribute attr) const {
2026 ASSERT(this->IsLockedByCurrentThread()); 2023 ASSERT(this->IsLockedByCurrentThread());
2027 2024
2028 // Get information about the first block. 2025 // Get information about the first block.
@@ -2060,12 +2057,12 @@ ResultCode KPageTable::CheckMemoryStateContiguous(std::size_t* out_blocks_needed
2060 return ResultSuccess; 2057 return ResultSuccess;
2061} 2058}
2062 2059
2063ResultCode KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm, 2060Result KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm,
2064 KMemoryAttribute* out_attr, std::size_t* out_blocks_needed, 2061 KMemoryAttribute* out_attr, std::size_t* out_blocks_needed,
2065 VAddr addr, std::size_t size, KMemoryState state_mask, 2062 VAddr addr, std::size_t size, KMemoryState state_mask,
2066 KMemoryState state, KMemoryPermission perm_mask, 2063 KMemoryState state, KMemoryPermission perm_mask,
2067 KMemoryPermission perm, KMemoryAttribute attr_mask, 2064 KMemoryPermission perm, KMemoryAttribute attr_mask,
2068 KMemoryAttribute attr, KMemoryAttribute ignore_attr) const { 2065 KMemoryAttribute attr, KMemoryAttribute ignore_attr) const {
2069 ASSERT(this->IsLockedByCurrentThread()); 2066 ASSERT(this->IsLockedByCurrentThread());
2070 2067
2071 // Get information about the first block. 2068 // Get information about the first block.
@@ -2122,11 +2119,11 @@ ResultCode KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermissi
2122 return ResultSuccess; 2119 return ResultSuccess;
2123} 2120}
2124 2121
2125ResultCode KPageTable::LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_paddr, VAddr addr, 2122Result KPageTable::LockMemoryAndOpen(KPageGroup* out_pg, PAddr* out_paddr, VAddr addr, size_t size,
2126 size_t size, KMemoryState state_mask, KMemoryState state, 2123 KMemoryState state_mask, KMemoryState state,
2127 KMemoryPermission perm_mask, KMemoryPermission perm, 2124 KMemoryPermission perm_mask, KMemoryPermission perm,
2128 KMemoryAttribute attr_mask, KMemoryAttribute attr, 2125 KMemoryAttribute attr_mask, KMemoryAttribute attr,
2129 KMemoryPermission new_perm, KMemoryAttribute lock_attr) { 2126 KMemoryPermission new_perm, KMemoryAttribute lock_attr) {
2130 // Validate basic preconditions. 2127 // Validate basic preconditions.
2131 ASSERT((lock_attr & attr) == KMemoryAttribute::None); 2128 ASSERT((lock_attr & attr) == KMemoryAttribute::None);
2132 ASSERT((lock_attr & (KMemoryAttribute::IpcLocked | KMemoryAttribute::DeviceShared)) == 2129 ASSERT((lock_attr & (KMemoryAttribute::IpcLocked | KMemoryAttribute::DeviceShared)) ==
@@ -2180,11 +2177,11 @@ ResultCode KPageTable::LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_pad
2180 return ResultSuccess; 2177 return ResultSuccess;
2181} 2178}
2182 2179
2183ResultCode KPageTable::UnlockMemory(VAddr addr, size_t size, KMemoryState state_mask, 2180Result KPageTable::UnlockMemory(VAddr addr, size_t size, KMemoryState state_mask,
2184 KMemoryState state, KMemoryPermission perm_mask, 2181 KMemoryState state, KMemoryPermission perm_mask,
2185 KMemoryPermission perm, KMemoryAttribute attr_mask, 2182 KMemoryPermission perm, KMemoryAttribute attr_mask,
2186 KMemoryAttribute attr, KMemoryPermission new_perm, 2183 KMemoryAttribute attr, KMemoryPermission new_perm,
2187 KMemoryAttribute lock_attr, const KPageLinkedList* pg) { 2184 KMemoryAttribute lock_attr, const KPageGroup* pg) {
2188 // Validate basic preconditions. 2185 // Validate basic preconditions.
2189 ASSERT((attr_mask & lock_attr) == lock_attr); 2186 ASSERT((attr_mask & lock_attr) == lock_attr);
2190 ASSERT((attr & lock_attr) == lock_attr); 2187 ASSERT((attr & lock_attr) == lock_attr);
diff --git a/src/core/hle/kernel/k_page_table.h b/src/core/hle/kernel/k_page_table.h
index 6312eb682..25774f232 100644
--- a/src/core/hle/kernel/k_page_table.h
+++ b/src/core/hle/kernel/k_page_table.h
@@ -33,51 +33,49 @@ public:
33 explicit KPageTable(Core::System& system_); 33 explicit KPageTable(Core::System& system_);
34 ~KPageTable(); 34 ~KPageTable();
35 35
36 ResultCode InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, bool enable_aslr, 36 Result InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, bool enable_aslr,
37 VAddr code_addr, std::size_t code_size, 37 VAddr code_addr, std::size_t code_size, KMemoryManager::Pool pool);
38 KMemoryManager::Pool pool); 38 Result MapProcessCode(VAddr addr, std::size_t pages_count, KMemoryState state,
39 ResultCode MapProcessCode(VAddr addr, std::size_t pages_count, KMemoryState state, 39 KMemoryPermission perm);
40 KMemoryPermission perm); 40 Result MapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size);
41 ResultCode MapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size); 41 Result UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size,
42 ResultCode UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size, 42 ICacheInvalidationStrategy icache_invalidation_strategy);
43 ICacheInvalidationStrategy icache_invalidation_strategy); 43 Result UnmapProcessMemory(VAddr dst_addr, std::size_t size, KPageTable& src_page_table,
44 ResultCode UnmapProcessMemory(VAddr dst_addr, std::size_t size, KPageTable& src_page_table, 44 VAddr src_addr);
45 VAddr src_addr); 45 Result MapPhysicalMemory(VAddr addr, std::size_t size);
46 ResultCode MapPhysicalMemory(VAddr addr, std::size_t size); 46 Result UnmapPhysicalMemory(VAddr addr, std::size_t size);
47 ResultCode UnmapPhysicalMemory(VAddr addr, std::size_t size); 47 Result MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size);
48 ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); 48 Result UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size);
49 ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); 49 Result MapPages(VAddr addr, KPageGroup& page_linked_list, KMemoryState state,
50 ResultCode MapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state, 50 KMemoryPermission perm);
51 KMemoryPermission perm); 51 Result MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, PAddr phys_addr,
52 ResultCode MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, 52 KMemoryState state, KMemoryPermission perm) {
53 PAddr phys_addr, KMemoryState state, KMemoryPermission perm) {
54 return this->MapPages(out_addr, num_pages, alignment, phys_addr, true, 53 return this->MapPages(out_addr, num_pages, alignment, phys_addr, true,
55 this->GetRegionAddress(state), this->GetRegionSize(state) / PageSize, 54 this->GetRegionAddress(state), this->GetRegionSize(state) / PageSize,
56 state, perm); 55 state, perm);
57 } 56 }
58 ResultCode UnmapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state); 57 Result UnmapPages(VAddr addr, KPageGroup& page_linked_list, KMemoryState state);
59 ResultCode UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state); 58 Result UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state);
60 ResultCode SetProcessMemoryPermission(VAddr addr, std::size_t size, 59 Result SetProcessMemoryPermission(VAddr addr, std::size_t size, Svc::MemoryPermission svc_perm);
61 Svc::MemoryPermission svc_perm);
62 KMemoryInfo QueryInfo(VAddr addr); 60 KMemoryInfo QueryInfo(VAddr addr);
63 ResultCode ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm); 61 Result ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm);
64 ResultCode ResetTransferMemory(VAddr addr, std::size_t size); 62 Result ResetTransferMemory(VAddr addr, std::size_t size);
65 ResultCode SetMemoryPermission(VAddr addr, std::size_t size, Svc::MemoryPermission perm); 63 Result SetMemoryPermission(VAddr addr, std::size_t size, Svc::MemoryPermission perm);
66 ResultCode SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask, u32 attr); 64 Result SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask, u32 attr);
67 ResultCode SetMaxHeapSize(std::size_t size); 65 Result SetMaxHeapSize(std::size_t size);
68 ResultCode SetHeapSize(VAddr* out, std::size_t size); 66 Result SetHeapSize(VAddr* out, std::size_t size);
69 ResultVal<VAddr> AllocateAndMapMemory(std::size_t needed_num_pages, std::size_t align, 67 ResultVal<VAddr> AllocateAndMapMemory(std::size_t needed_num_pages, std::size_t align,
70 bool is_map_only, VAddr region_start, 68 bool is_map_only, VAddr region_start,
71 std::size_t region_num_pages, KMemoryState state, 69 std::size_t region_num_pages, KMemoryState state,
72 KMemoryPermission perm, PAddr map_addr = 0); 70 KMemoryPermission perm, PAddr map_addr = 0);
73 ResultCode LockForDeviceAddressSpace(VAddr addr, std::size_t size); 71 Result LockForDeviceAddressSpace(VAddr addr, std::size_t size);
74 ResultCode UnlockForDeviceAddressSpace(VAddr addr, std::size_t size); 72 Result UnlockForDeviceAddressSpace(VAddr addr, std::size_t size);
75 ResultCode LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::size_t size); 73 Result LockForCodeMemory(KPageGroup* out, VAddr addr, std::size_t size);
76 ResultCode UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageLinkedList& pg); 74 Result UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageGroup& pg);
77 ResultCode MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address, size_t num_pages, 75 Result MakeAndOpenPageGroup(KPageGroup* out, VAddr address, size_t num_pages,
78 KMemoryState state_mask, KMemoryState state, 76 KMemoryState state_mask, KMemoryState state,
79 KMemoryPermission perm_mask, KMemoryPermission perm, 77 KMemoryPermission perm_mask, KMemoryPermission perm,
80 KMemoryAttribute attr_mask, KMemoryAttribute attr); 78 KMemoryAttribute attr_mask, KMemoryAttribute attr);
81 79
82 Common::PageTable& PageTableImpl() { 80 Common::PageTable& PageTableImpl() {
83 return page_table_impl; 81 return page_table_impl;
@@ -102,83 +100,78 @@ private:
102 KMemoryAttribute::IpcLocked | 100 KMemoryAttribute::IpcLocked |
103 KMemoryAttribute::DeviceShared; 101 KMemoryAttribute::DeviceShared;
104 102
105 ResultCode InitializeMemoryLayout(VAddr start, VAddr end); 103 Result InitializeMemoryLayout(VAddr start, VAddr end);
106 ResultCode MapPages(VAddr addr, const KPageLinkedList& page_linked_list, 104 Result MapPages(VAddr addr, const KPageGroup& page_linked_list, KMemoryPermission perm);
107 KMemoryPermission perm); 105 Result MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, PAddr phys_addr,
108 ResultCode MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, 106 bool is_pa_valid, VAddr region_start, std::size_t region_num_pages,
109 PAddr phys_addr, bool is_pa_valid, VAddr region_start, 107 KMemoryState state, KMemoryPermission perm);
110 std::size_t region_num_pages, KMemoryState state, KMemoryPermission perm); 108 Result UnmapPages(VAddr addr, const KPageGroup& page_linked_list);
111 ResultCode UnmapPages(VAddr addr, const KPageLinkedList& page_linked_list);
112 bool IsRegionMapped(VAddr address, u64 size); 109 bool IsRegionMapped(VAddr address, u64 size);
113 bool IsRegionContiguous(VAddr addr, u64 size) const; 110 bool IsRegionContiguous(VAddr addr, u64 size) const;
114 void AddRegionToPages(VAddr start, std::size_t num_pages, KPageLinkedList& page_linked_list); 111 void AddRegionToPages(VAddr start, std::size_t num_pages, KPageGroup& page_linked_list);
115 KMemoryInfo QueryInfoImpl(VAddr addr); 112 KMemoryInfo QueryInfoImpl(VAddr addr);
116 VAddr AllocateVirtualMemory(VAddr start, std::size_t region_num_pages, u64 needed_num_pages, 113 VAddr AllocateVirtualMemory(VAddr start, std::size_t region_num_pages, u64 needed_num_pages,
117 std::size_t align); 114 std::size_t align);
118 ResultCode Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& page_group, 115 Result Operate(VAddr addr, std::size_t num_pages, const KPageGroup& page_group,
119 OperationType operation); 116 OperationType operation);
120 ResultCode Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm, 117 Result Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm,
121 OperationType operation, PAddr map_addr = 0); 118 OperationType operation, PAddr map_addr = 0);
122 VAddr GetRegionAddress(KMemoryState state) const; 119 VAddr GetRegionAddress(KMemoryState state) const;
123 std::size_t GetRegionSize(KMemoryState state) const; 120 std::size_t GetRegionSize(KMemoryState state) const;
124 121
125 VAddr FindFreeArea(VAddr region_start, std::size_t region_num_pages, std::size_t num_pages, 122 VAddr FindFreeArea(VAddr region_start, std::size_t region_num_pages, std::size_t num_pages,
126 std::size_t alignment, std::size_t offset, std::size_t guard_pages); 123 std::size_t alignment, std::size_t offset, std::size_t guard_pages);
127 124
128 ResultCode CheckMemoryStateContiguous(std::size_t* out_blocks_needed, VAddr addr, 125 Result CheckMemoryStateContiguous(std::size_t* out_blocks_needed, VAddr addr, std::size_t size,
129 std::size_t size, KMemoryState state_mask, 126 KMemoryState state_mask, KMemoryState state,
130 KMemoryState state, KMemoryPermission perm_mask, 127 KMemoryPermission perm_mask, KMemoryPermission perm,
131 KMemoryPermission perm, KMemoryAttribute attr_mask, 128 KMemoryAttribute attr_mask, KMemoryAttribute attr) const;
132 KMemoryAttribute attr) const; 129 Result CheckMemoryStateContiguous(VAddr addr, std::size_t size, KMemoryState state_mask,
133 ResultCode CheckMemoryStateContiguous(VAddr addr, std::size_t size, KMemoryState state_mask, 130 KMemoryState state, KMemoryPermission perm_mask,
134 KMemoryState state, KMemoryPermission perm_mask, 131 KMemoryPermission perm, KMemoryAttribute attr_mask,
135 KMemoryPermission perm, KMemoryAttribute attr_mask, 132 KMemoryAttribute attr) const {
136 KMemoryAttribute attr) const {
137 return this->CheckMemoryStateContiguous(nullptr, addr, size, state_mask, state, perm_mask, 133 return this->CheckMemoryStateContiguous(nullptr, addr, size, state_mask, state, perm_mask,
138 perm, attr_mask, attr); 134 perm, attr_mask, attr);
139 } 135 }
140 136
141 ResultCode CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask, 137 Result CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask, KMemoryState state,
142 KMemoryState state, KMemoryPermission perm_mask, 138 KMemoryPermission perm_mask, KMemoryPermission perm,
143 KMemoryPermission perm, KMemoryAttribute attr_mask, 139 KMemoryAttribute attr_mask, KMemoryAttribute attr) const;
144 KMemoryAttribute attr) const; 140 Result CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm,
145 ResultCode CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm, 141 KMemoryAttribute* out_attr, std::size_t* out_blocks_needed, VAddr addr,
146 KMemoryAttribute* out_attr, std::size_t* out_blocks_needed, 142 std::size_t size, KMemoryState state_mask, KMemoryState state,
147 VAddr addr, std::size_t size, KMemoryState state_mask, 143 KMemoryPermission perm_mask, KMemoryPermission perm,
148 KMemoryState state, KMemoryPermission perm_mask, 144 KMemoryAttribute attr_mask, KMemoryAttribute attr,
149 KMemoryPermission perm, KMemoryAttribute attr_mask, 145 KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const;
150 KMemoryAttribute attr, 146 Result CheckMemoryState(std::size_t* out_blocks_needed, VAddr addr, std::size_t size,
151 KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const; 147 KMemoryState state_mask, KMemoryState state,
152 ResultCode CheckMemoryState(std::size_t* out_blocks_needed, VAddr addr, std::size_t size, 148 KMemoryPermission perm_mask, KMemoryPermission perm,
153 KMemoryState state_mask, KMemoryState state, 149 KMemoryAttribute attr_mask, KMemoryAttribute attr,
154 KMemoryPermission perm_mask, KMemoryPermission perm, 150 KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const {
155 KMemoryAttribute attr_mask, KMemoryAttribute attr,
156 KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const {
157 return CheckMemoryState(nullptr, nullptr, nullptr, out_blocks_needed, addr, size, 151 return CheckMemoryState(nullptr, nullptr, nullptr, out_blocks_needed, addr, size,
158 state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr); 152 state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr);
159 } 153 }
160 ResultCode CheckMemoryState(VAddr addr, std::size_t size, KMemoryState state_mask, 154 Result CheckMemoryState(VAddr addr, std::size_t size, KMemoryState state_mask,
161 KMemoryState state, KMemoryPermission perm_mask, 155 KMemoryState state, KMemoryPermission perm_mask, KMemoryPermission perm,
162 KMemoryPermission perm, KMemoryAttribute attr_mask, 156 KMemoryAttribute attr_mask, KMemoryAttribute attr,
163 KMemoryAttribute attr, 157 KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const {
164 KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const {
165 return this->CheckMemoryState(nullptr, addr, size, state_mask, state, perm_mask, perm, 158 return this->CheckMemoryState(nullptr, addr, size, state_mask, state, perm_mask, perm,
166 attr_mask, attr, ignore_attr); 159 attr_mask, attr, ignore_attr);
167 } 160 }
168 161
169 ResultCode LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_paddr, VAddr addr, size_t size, 162 Result LockMemoryAndOpen(KPageGroup* out_pg, PAddr* out_paddr, VAddr addr, size_t size,
170 KMemoryState state_mask, KMemoryState state, 163 KMemoryState state_mask, KMemoryState state,
171 KMemoryPermission perm_mask, KMemoryPermission perm, 164 KMemoryPermission perm_mask, KMemoryPermission perm,
172 KMemoryAttribute attr_mask, KMemoryAttribute attr, 165 KMemoryAttribute attr_mask, KMemoryAttribute attr,
173 KMemoryPermission new_perm, KMemoryAttribute lock_attr); 166 KMemoryPermission new_perm, KMemoryAttribute lock_attr);
174 ResultCode UnlockMemory(VAddr addr, size_t size, KMemoryState state_mask, KMemoryState state, 167 Result UnlockMemory(VAddr addr, size_t size, KMemoryState state_mask, KMemoryState state,
175 KMemoryPermission perm_mask, KMemoryPermission perm, 168 KMemoryPermission perm_mask, KMemoryPermission perm,
176 KMemoryAttribute attr_mask, KMemoryAttribute attr, 169 KMemoryAttribute attr_mask, KMemoryAttribute attr,
177 KMemoryPermission new_perm, KMemoryAttribute lock_attr, 170 KMemoryPermission new_perm, KMemoryAttribute lock_attr,
178 const KPageLinkedList* pg); 171 const KPageGroup* pg);
179 172
180 ResultCode MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pages); 173 Result MakePageGroup(KPageGroup& pg, VAddr addr, size_t num_pages);
181 bool IsValidPageGroup(const KPageLinkedList& pg, VAddr addr, size_t num_pages); 174 bool IsValidPageGroup(const KPageGroup& pg, VAddr addr, size_t num_pages);
182 175
183 bool IsLockedByCurrentThread() const { 176 bool IsLockedByCurrentThread() const {
184 return general_lock.IsLockedByCurrentThread(); 177 return general_lock.IsLockedByCurrentThread();
diff --git a/src/core/hle/kernel/k_port.cpp b/src/core/hle/kernel/k_port.cpp
index 51c2cd1ef..7a5a9dc2a 100644
--- a/src/core/hle/kernel/k_port.cpp
+++ b/src/core/hle/kernel/k_port.cpp
@@ -50,7 +50,7 @@ bool KPort::IsServerClosed() const {
50 return state == State::ServerClosed; 50 return state == State::ServerClosed;
51} 51}
52 52
53ResultCode KPort::EnqueueSession(KServerSession* session) { 53Result KPort::EnqueueSession(KServerSession* session) {
54 KScopedSchedulerLock sl{kernel}; 54 KScopedSchedulerLock sl{kernel};
55 55
56 R_UNLESS(state == State::Normal, ResultPortClosed); 56 R_UNLESS(state == State::Normal, ResultPortClosed);
diff --git a/src/core/hle/kernel/k_port.h b/src/core/hle/kernel/k_port.h
index 1bfecf8c3..0cfc16dab 100644
--- a/src/core/hle/kernel/k_port.h
+++ b/src/core/hle/kernel/k_port.h
@@ -34,7 +34,7 @@ public:
34 34
35 bool IsServerClosed() const; 35 bool IsServerClosed() const;
36 36
37 ResultCode EnqueueSession(KServerSession* session); 37 Result EnqueueSession(KServerSession* session);
38 38
39 KClientPort& GetClientPort() { 39 KClientPort& GetClientPort() {
40 return client; 40 return client;
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp
index b477c6e55..183c693e3 100644
--- a/src/core/hle/kernel/k_process.cpp
+++ b/src/core/hle/kernel/k_process.cpp
@@ -67,8 +67,8 @@ void SetupMainThread(Core::System& system, KProcess& owner_process, u32 priority
67} 67}
68} // Anonymous namespace 68} // Anonymous namespace
69 69
70ResultCode KProcess::Initialize(KProcess* process, Core::System& system, std::string process_name, 70Result KProcess::Initialize(KProcess* process, Core::System& system, std::string process_name,
71 ProcessType type, KResourceLimit* res_limit) { 71 ProcessType type, KResourceLimit* res_limit) {
72 auto& kernel = system.Kernel(); 72 auto& kernel = system.Kernel();
73 73
74 process->name = std::move(process_name); 74 process->name = std::move(process_name);
@@ -219,8 +219,8 @@ void KProcess::UnpinThread(KThread* thread) {
219 KScheduler::SetSchedulerUpdateNeeded(kernel); 219 KScheduler::SetSchedulerUpdateNeeded(kernel);
220} 220}
221 221
222ResultCode KProcess::AddSharedMemory(KSharedMemory* shmem, [[maybe_unused]] VAddr address, 222Result KProcess::AddSharedMemory(KSharedMemory* shmem, [[maybe_unused]] VAddr address,
223 [[maybe_unused]] size_t size) { 223 [[maybe_unused]] size_t size) {
224 // Lock ourselves, to prevent concurrent access. 224 // Lock ourselves, to prevent concurrent access.
225 KScopedLightLock lk(state_lock); 225 KScopedLightLock lk(state_lock);
226 226
@@ -284,7 +284,7 @@ void KProcess::UnregisterThread(KThread* thread) {
284 thread_list.remove(thread); 284 thread_list.remove(thread);
285} 285}
286 286
287ResultCode KProcess::Reset() { 287Result KProcess::Reset() {
288 // Lock the process and the scheduler. 288 // Lock the process and the scheduler.
289 KScopedLightLock lk(state_lock); 289 KScopedLightLock lk(state_lock);
290 KScopedSchedulerLock sl{kernel}; 290 KScopedSchedulerLock sl{kernel};
@@ -298,7 +298,7 @@ ResultCode KProcess::Reset() {
298 return ResultSuccess; 298 return ResultSuccess;
299} 299}
300 300
301ResultCode KProcess::SetActivity(ProcessActivity activity) { 301Result KProcess::SetActivity(ProcessActivity activity) {
302 // Lock ourselves and the scheduler. 302 // Lock ourselves and the scheduler.
303 KScopedLightLock lk{state_lock}; 303 KScopedLightLock lk{state_lock};
304 KScopedLightLock list_lk{list_lock}; 304 KScopedLightLock list_lk{list_lock};
@@ -342,8 +342,7 @@ ResultCode KProcess::SetActivity(ProcessActivity activity) {
342 return ResultSuccess; 342 return ResultSuccess;
343} 343}
344 344
345ResultCode KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, 345Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size) {
346 std::size_t code_size) {
347 program_id = metadata.GetTitleID(); 346 program_id = metadata.GetTitleID();
348 ideal_core = metadata.GetMainThreadCore(); 347 ideal_core = metadata.GetMainThreadCore();
349 is_64bit_process = metadata.Is64BitProgram(); 348 is_64bit_process = metadata.Is64BitProgram();
@@ -358,24 +357,24 @@ ResultCode KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata,
358 return ResultLimitReached; 357 return ResultLimitReached;
359 } 358 }
360 // Initialize proces address space 359 // Initialize proces address space
361 if (const ResultCode result{ 360 if (const Result result{page_table->InitializeForProcess(metadata.GetAddressSpaceType(), false,
362 page_table->InitializeForProcess(metadata.GetAddressSpaceType(), false, 0x8000000, 361 0x8000000, code_size,
363 code_size, KMemoryManager::Pool::Application)}; 362 KMemoryManager::Pool::Application)};
364 result.IsError()) { 363 result.IsError()) {
365 return result; 364 return result;
366 } 365 }
367 366
368 // Map process code region 367 // Map process code region
369 if (const ResultCode result{page_table->MapProcessCode(page_table->GetCodeRegionStart(), 368 if (const Result result{page_table->MapProcessCode(page_table->GetCodeRegionStart(),
370 code_size / PageSize, KMemoryState::Code, 369 code_size / PageSize, KMemoryState::Code,
371 KMemoryPermission::None)}; 370 KMemoryPermission::None)};
372 result.IsError()) { 371 result.IsError()) {
373 return result; 372 return result;
374 } 373 }
375 374
376 // Initialize process capabilities 375 // Initialize process capabilities
377 const auto& caps{metadata.GetKernelCapabilities()}; 376 const auto& caps{metadata.GetKernelCapabilities()};
378 if (const ResultCode result{ 377 if (const Result result{
379 capabilities.InitializeForUserProcess(caps.data(), caps.size(), *page_table)}; 378 capabilities.InitializeForUserProcess(caps.data(), caps.size(), *page_table)};
380 result.IsError()) { 379 result.IsError()) {
381 return result; 380 return result;
@@ -482,7 +481,7 @@ void KProcess::Finalize() {
482 KAutoObjectWithSlabHeapAndContainer<KProcess, KWorkerTask>::Finalize(); 481 KAutoObjectWithSlabHeapAndContainer<KProcess, KWorkerTask>::Finalize();
483} 482}
484 483
485ResultCode KProcess::CreateThreadLocalRegion(VAddr* out) { 484Result KProcess::CreateThreadLocalRegion(VAddr* out) {
486 KThreadLocalPage* tlp = nullptr; 485 KThreadLocalPage* tlp = nullptr;
487 VAddr tlr = 0; 486 VAddr tlr = 0;
488 487
@@ -533,7 +532,7 @@ ResultCode KProcess::CreateThreadLocalRegion(VAddr* out) {
533 return ResultSuccess; 532 return ResultSuccess;
534} 533}
535 534
536ResultCode KProcess::DeleteThreadLocalRegion(VAddr addr) { 535Result KProcess::DeleteThreadLocalRegion(VAddr addr) {
537 KThreadLocalPage* page_to_free = nullptr; 536 KThreadLocalPage* page_to_free = nullptr;
538 537
539 // Release the region. 538 // Release the region.
@@ -664,7 +663,7 @@ void KProcess::ChangeStatus(ProcessStatus new_status) {
664 NotifyAvailable(); 663 NotifyAvailable();
665} 664}
666 665
667ResultCode KProcess::AllocateMainThreadStack(std::size_t stack_size) { 666Result KProcess::AllocateMainThreadStack(std::size_t stack_size) {
668 ASSERT(stack_size); 667 ASSERT(stack_size);
669 668
670 // The kernel always ensures that the given stack size is page aligned. 669 // The kernel always ensures that the given stack size is page aligned.
diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h
index c2086e5ba..5e3e22ad8 100644
--- a/src/core/hle/kernel/k_process.h
+++ b/src/core/hle/kernel/k_process.h
@@ -110,8 +110,8 @@ public:
110 110
111 static constexpr std::size_t RANDOM_ENTROPY_SIZE = 4; 111 static constexpr std::size_t RANDOM_ENTROPY_SIZE = 4;
112 112
113 static ResultCode Initialize(KProcess* process, Core::System& system, std::string process_name, 113 static Result Initialize(KProcess* process, Core::System& system, std::string process_name,
114 ProcessType type, KResourceLimit* res_limit); 114 ProcessType type, KResourceLimit* res_limit);
115 115
116 /// Gets a reference to the process' page table. 116 /// Gets a reference to the process' page table.
117 KPageTable& PageTable() { 117 KPageTable& PageTable() {
@@ -133,11 +133,11 @@ public:
133 return handle_table; 133 return handle_table;
134 } 134 }
135 135
136 ResultCode SignalToAddress(VAddr address) { 136 Result SignalToAddress(VAddr address) {
137 return condition_var.SignalToAddress(address); 137 return condition_var.SignalToAddress(address);
138 } 138 }
139 139
140 ResultCode WaitForAddress(Handle handle, VAddr address, u32 tag) { 140 Result WaitForAddress(Handle handle, VAddr address, u32 tag) {
141 return condition_var.WaitForAddress(handle, address, tag); 141 return condition_var.WaitForAddress(handle, address, tag);
142 } 142 }
143 143
@@ -145,17 +145,16 @@ public:
145 return condition_var.Signal(cv_key, count); 145 return condition_var.Signal(cv_key, count);
146 } 146 }
147 147
148 ResultCode WaitConditionVariable(VAddr address, u64 cv_key, u32 tag, s64 ns) { 148 Result WaitConditionVariable(VAddr address, u64 cv_key, u32 tag, s64 ns) {
149 return condition_var.Wait(address, cv_key, tag, ns); 149 return condition_var.Wait(address, cv_key, tag, ns);
150 } 150 }
151 151
152 ResultCode SignalAddressArbiter(VAddr address, Svc::SignalType signal_type, s32 value, 152 Result SignalAddressArbiter(VAddr address, Svc::SignalType signal_type, s32 value, s32 count) {
153 s32 count) {
154 return address_arbiter.SignalToAddress(address, signal_type, value, count); 153 return address_arbiter.SignalToAddress(address, signal_type, value, count);
155 } 154 }
156 155
157 ResultCode WaitAddressArbiter(VAddr address, Svc::ArbitrationType arb_type, s32 value, 156 Result WaitAddressArbiter(VAddr address, Svc::ArbitrationType arb_type, s32 value,
158 s64 timeout) { 157 s64 timeout) {
159 return address_arbiter.WaitForAddress(address, arb_type, value, timeout); 158 return address_arbiter.WaitForAddress(address, arb_type, value, timeout);
160 } 159 }
161 160
@@ -322,7 +321,7 @@ public:
322 /// @pre The process must be in a signaled state. If this is called on a 321 /// @pre The process must be in a signaled state. If this is called on a
323 /// process instance that is not signaled, ERR_INVALID_STATE will be 322 /// process instance that is not signaled, ERR_INVALID_STATE will be
324 /// returned. 323 /// returned.
325 ResultCode Reset(); 324 Result Reset();
326 325
327 /** 326 /**
328 * Loads process-specifics configuration info with metadata provided 327 * Loads process-specifics configuration info with metadata provided
@@ -333,7 +332,7 @@ public:
333 * @returns ResultSuccess if all relevant metadata was able to be 332 * @returns ResultSuccess if all relevant metadata was able to be
334 * loaded and parsed. Otherwise, an error code is returned. 333 * loaded and parsed. Otherwise, an error code is returned.
335 */ 334 */
336 ResultCode LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size); 335 Result LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size);
337 336
338 /** 337 /**
339 * Starts the main application thread for this process. 338 * Starts the main application thread for this process.
@@ -367,7 +366,7 @@ public:
367 366
368 void DoWorkerTaskImpl(); 367 void DoWorkerTaskImpl();
369 368
370 ResultCode SetActivity(ProcessActivity activity); 369 Result SetActivity(ProcessActivity activity);
371 370
372 void PinCurrentThread(s32 core_id); 371 void PinCurrentThread(s32 core_id);
373 void UnpinCurrentThread(s32 core_id); 372 void UnpinCurrentThread(s32 core_id);
@@ -377,17 +376,17 @@ public:
377 return state_lock; 376 return state_lock;
378 } 377 }
379 378
380 ResultCode AddSharedMemory(KSharedMemory* shmem, VAddr address, size_t size); 379 Result AddSharedMemory(KSharedMemory* shmem, VAddr address, size_t size);
381 void RemoveSharedMemory(KSharedMemory* shmem, VAddr address, size_t size); 380 void RemoveSharedMemory(KSharedMemory* shmem, VAddr address, size_t size);
382 381
383 /////////////////////////////////////////////////////////////////////////////////////////////// 382 ///////////////////////////////////////////////////////////////////////////////////////////////
384 // Thread-local storage management 383 // Thread-local storage management
385 384
386 // Marks the next available region as used and returns the address of the slot. 385 // Marks the next available region as used and returns the address of the slot.
387 [[nodiscard]] ResultCode CreateThreadLocalRegion(VAddr* out); 386 [[nodiscard]] Result CreateThreadLocalRegion(VAddr* out);
388 387
389 // Frees a used TLS slot identified by the given address 388 // Frees a used TLS slot identified by the given address
390 ResultCode DeleteThreadLocalRegion(VAddr addr); 389 Result DeleteThreadLocalRegion(VAddr addr);
391 390
392 /////////////////////////////////////////////////////////////////////////////////////////////// 391 ///////////////////////////////////////////////////////////////////////////////////////////////
393 // Debug watchpoint management 392 // Debug watchpoint management
@@ -423,7 +422,7 @@ private:
423 void ChangeStatus(ProcessStatus new_status); 422 void ChangeStatus(ProcessStatus new_status);
424 423
425 /// Allocates the main thread stack for the process, given the stack size in bytes. 424 /// Allocates the main thread stack for the process, given the stack size in bytes.
426 ResultCode AllocateMainThreadStack(std::size_t stack_size); 425 Result AllocateMainThreadStack(std::size_t stack_size);
427 426
428 /// Memory manager for this process 427 /// Memory manager for this process
429 std::unique_ptr<KPageTable> page_table; 428 std::unique_ptr<KPageTable> page_table;
diff --git a/src/core/hle/kernel/k_readable_event.cpp b/src/core/hle/kernel/k_readable_event.cpp
index dddba554d..94c5464fe 100644
--- a/src/core/hle/kernel/k_readable_event.cpp
+++ b/src/core/hle/kernel/k_readable_event.cpp
@@ -27,7 +27,7 @@ void KReadableEvent::Destroy() {
27 } 27 }
28} 28}
29 29
30ResultCode KReadableEvent::Signal() { 30Result KReadableEvent::Signal() {
31 KScopedSchedulerLock lk{kernel}; 31 KScopedSchedulerLock lk{kernel};
32 32
33 if (!is_signaled) { 33 if (!is_signaled) {
@@ -38,13 +38,13 @@ ResultCode KReadableEvent::Signal() {
38 return ResultSuccess; 38 return ResultSuccess;
39} 39}
40 40
41ResultCode KReadableEvent::Clear() { 41Result KReadableEvent::Clear() {
42 Reset(); 42 Reset();
43 43
44 return ResultSuccess; 44 return ResultSuccess;
45} 45}
46 46
47ResultCode KReadableEvent::Reset() { 47Result KReadableEvent::Reset() {
48 KScopedSchedulerLock lk{kernel}; 48 KScopedSchedulerLock lk{kernel};
49 49
50 if (!is_signaled) { 50 if (!is_signaled) {
diff --git a/src/core/hle/kernel/k_readable_event.h b/src/core/hle/kernel/k_readable_event.h
index 5065c7cc0..18dcad289 100644
--- a/src/core/hle/kernel/k_readable_event.h
+++ b/src/core/hle/kernel/k_readable_event.h
@@ -33,9 +33,9 @@ public:
33 bool IsSignaled() const override; 33 bool IsSignaled() const override;
34 void Destroy() override; 34 void Destroy() override;
35 35
36 ResultCode Signal(); 36 Result Signal();
37 ResultCode Clear(); 37 Result Clear();
38 ResultCode Reset(); 38 Result Reset();
39 39
40private: 40private:
41 bool is_signaled{}; 41 bool is_signaled{};
diff --git a/src/core/hle/kernel/k_resource_limit.cpp b/src/core/hle/kernel/k_resource_limit.cpp
index 3e0ecffdb..010dcf99e 100644
--- a/src/core/hle/kernel/k_resource_limit.cpp
+++ b/src/core/hle/kernel/k_resource_limit.cpp
@@ -73,7 +73,7 @@ s64 KResourceLimit::GetFreeValue(LimitableResource which) const {
73 return value; 73 return value;
74} 74}
75 75
76ResultCode KResourceLimit::SetLimitValue(LimitableResource which, s64 value) { 76Result KResourceLimit::SetLimitValue(LimitableResource which, s64 value) {
77 const auto index = static_cast<std::size_t>(which); 77 const auto index = static_cast<std::size_t>(which);
78 KScopedLightLock lk(lock); 78 KScopedLightLock lk(lock);
79 R_UNLESS(current_values[index] <= value, ResultInvalidState); 79 R_UNLESS(current_values[index] <= value, ResultInvalidState);
diff --git a/src/core/hle/kernel/k_resource_limit.h b/src/core/hle/kernel/k_resource_limit.h
index 43bf74b8d..65c98c979 100644
--- a/src/core/hle/kernel/k_resource_limit.h
+++ b/src/core/hle/kernel/k_resource_limit.h
@@ -8,7 +8,7 @@
8#include "core/hle/kernel/k_light_condition_variable.h" 8#include "core/hle/kernel/k_light_condition_variable.h"
9#include "core/hle/kernel/k_light_lock.h" 9#include "core/hle/kernel/k_light_lock.h"
10 10
11union ResultCode; 11union Result;
12 12
13namespace Core::Timing { 13namespace Core::Timing {
14class CoreTiming; 14class CoreTiming;
@@ -46,7 +46,7 @@ public:
46 s64 GetPeakValue(LimitableResource which) const; 46 s64 GetPeakValue(LimitableResource which) const;
47 s64 GetFreeValue(LimitableResource which) const; 47 s64 GetFreeValue(LimitableResource which) const;
48 48
49 ResultCode SetLimitValue(LimitableResource which, s64 value); 49 Result SetLimitValue(LimitableResource which, s64 value);
50 50
51 bool Reserve(LimitableResource which, s64 value); 51 bool Reserve(LimitableResource which, s64 value);
52 bool Reserve(LimitableResource which, s64 value, s64 timeout); 52 bool Reserve(LimitableResource which, s64 value, s64 timeout);
diff --git a/src/core/hle/kernel/k_server_session.cpp b/src/core/hle/kernel/k_server_session.cpp
index 60f8ed470..802c646a6 100644
--- a/src/core/hle/kernel/k_server_session.cpp
+++ b/src/core/hle/kernel/k_server_session.cpp
@@ -79,7 +79,7 @@ std::size_t KServerSession::NumDomainRequestHandlers() const {
79 return manager->DomainHandlerCount(); 79 return manager->DomainHandlerCount();
80} 80}
81 81
82ResultCode KServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& context) { 82Result KServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& context) {
83 if (!context.HasDomainMessageHeader()) { 83 if (!context.HasDomainMessageHeader()) {
84 return ResultSuccess; 84 return ResultSuccess;
85 } 85 }
@@ -123,7 +123,7 @@ ResultCode KServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& co
123 return ResultSuccess; 123 return ResultSuccess;
124} 124}
125 125
126ResultCode KServerSession::QueueSyncRequest(KThread* thread, Core::Memory::Memory& memory) { 126Result KServerSession::QueueSyncRequest(KThread* thread, Core::Memory::Memory& memory) {
127 u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))}; 127 u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))};
128 auto context = std::make_shared<HLERequestContext>(kernel, memory, this, thread); 128 auto context = std::make_shared<HLERequestContext>(kernel, memory, this, thread);
129 129
@@ -143,8 +143,8 @@ ResultCode KServerSession::QueueSyncRequest(KThread* thread, Core::Memory::Memor
143 return ResultSuccess; 143 return ResultSuccess;
144} 144}
145 145
146ResultCode KServerSession::CompleteSyncRequest(HLERequestContext& context) { 146Result KServerSession::CompleteSyncRequest(HLERequestContext& context) {
147 ResultCode result = ResultSuccess; 147 Result result = ResultSuccess;
148 148
149 // If the session has been converted to a domain, handle the domain request 149 // If the session has been converted to a domain, handle the domain request
150 if (manager->HasSessionRequestHandler(context)) { 150 if (manager->HasSessionRequestHandler(context)) {
@@ -173,8 +173,8 @@ ResultCode KServerSession::CompleteSyncRequest(HLERequestContext& context) {
173 return result; 173 return result;
174} 174}
175 175
176ResultCode KServerSession::HandleSyncRequest(KThread* thread, Core::Memory::Memory& memory, 176Result KServerSession::HandleSyncRequest(KThread* thread, Core::Memory::Memory& memory,
177 Core::Timing::CoreTiming& core_timing) { 177 Core::Timing::CoreTiming& core_timing) {
178 return QueueSyncRequest(thread, memory); 178 return QueueSyncRequest(thread, memory);
179} 179}
180 180
diff --git a/src/core/hle/kernel/k_server_session.h b/src/core/hle/kernel/k_server_session.h
index b628a843f..6d0821945 100644
--- a/src/core/hle/kernel/k_server_session.h
+++ b/src/core/hle/kernel/k_server_session.h
@@ -73,10 +73,10 @@ public:
73 * @param memory Memory context to handle the sync request under. 73 * @param memory Memory context to handle the sync request under.
74 * @param core_timing Core timing context to schedule the request event under. 74 * @param core_timing Core timing context to schedule the request event under.
75 * 75 *
76 * @returns ResultCode from the operation. 76 * @returns Result from the operation.
77 */ 77 */
78 ResultCode HandleSyncRequest(KThread* thread, Core::Memory::Memory& memory, 78 Result HandleSyncRequest(KThread* thread, Core::Memory::Memory& memory,
79 Core::Timing::CoreTiming& core_timing); 79 Core::Timing::CoreTiming& core_timing);
80 80
81 /// Adds a new domain request handler to the collection of request handlers within 81 /// Adds a new domain request handler to the collection of request handlers within
82 /// this ServerSession instance. 82 /// this ServerSession instance.
@@ -103,14 +103,14 @@ public:
103 103
104private: 104private:
105 /// Queues a sync request from the emulated application. 105 /// Queues a sync request from the emulated application.
106 ResultCode QueueSyncRequest(KThread* thread, Core::Memory::Memory& memory); 106 Result QueueSyncRequest(KThread* thread, Core::Memory::Memory& memory);
107 107
108 /// Completes a sync request from the emulated application. 108 /// Completes a sync request from the emulated application.
109 ResultCode CompleteSyncRequest(HLERequestContext& context); 109 Result CompleteSyncRequest(HLERequestContext& context);
110 110
111 /// Handles a SyncRequest to a domain, forwarding the request to the proper object or closing an 111 /// Handles a SyncRequest to a domain, forwarding the request to the proper object or closing an
112 /// object handle. 112 /// object handle.
113 ResultCode HandleDomainSyncRequest(Kernel::HLERequestContext& context); 113 Result HandleDomainSyncRequest(Kernel::HLERequestContext& context);
114 114
115 /// This session's HLE request handlers 115 /// This session's HLE request handlers
116 std::shared_ptr<SessionRequestManager> manager; 116 std::shared_ptr<SessionRequestManager> manager;
diff --git a/src/core/hle/kernel/k_shared_memory.cpp b/src/core/hle/kernel/k_shared_memory.cpp
index 51d7538ca..b77735736 100644
--- a/src/core/hle/kernel/k_shared_memory.cpp
+++ b/src/core/hle/kernel/k_shared_memory.cpp
@@ -18,12 +18,10 @@ KSharedMemory::~KSharedMemory() {
18 kernel.GetSystemResourceLimit()->Release(LimitableResource::PhysicalMemory, size); 18 kernel.GetSystemResourceLimit()->Release(LimitableResource::PhysicalMemory, size);
19} 19}
20 20
21ResultCode KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_, 21Result KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_,
22 KPageLinkedList&& page_list_, 22 KPageGroup&& page_list_, Svc::MemoryPermission owner_permission_,
23 Svc::MemoryPermission owner_permission_, 23 Svc::MemoryPermission user_permission_, PAddr physical_address_,
24 Svc::MemoryPermission user_permission_, 24 std::size_t size_, std::string name_) {
25 PAddr physical_address_, std::size_t size_,
26 std::string name_) {
27 // Set members. 25 // Set members.
28 owner_process = owner_process_; 26 owner_process = owner_process_;
29 device_memory = &device_memory_; 27 device_memory = &device_memory_;
@@ -67,8 +65,8 @@ void KSharedMemory::Finalize() {
67 KAutoObjectWithSlabHeapAndContainer<KSharedMemory, KAutoObjectWithList>::Finalize(); 65 KAutoObjectWithSlabHeapAndContainer<KSharedMemory, KAutoObjectWithList>::Finalize();
68} 66}
69 67
70ResultCode KSharedMemory::Map(KProcess& target_process, VAddr address, std::size_t map_size, 68Result KSharedMemory::Map(KProcess& target_process, VAddr address, std::size_t map_size,
71 Svc::MemoryPermission permissions) { 69 Svc::MemoryPermission permissions) {
72 const u64 page_count{(map_size + PageSize - 1) / PageSize}; 70 const u64 page_count{(map_size + PageSize - 1) / PageSize};
73 71
74 if (page_list.GetNumPages() != page_count) { 72 if (page_list.GetNumPages() != page_count) {
@@ -86,7 +84,7 @@ ResultCode KSharedMemory::Map(KProcess& target_process, VAddr address, std::size
86 ConvertToKMemoryPermission(permissions)); 84 ConvertToKMemoryPermission(permissions));
87} 85}
88 86
89ResultCode KSharedMemory::Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size) { 87Result KSharedMemory::Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size) {
90 const u64 page_count{(unmap_size + PageSize - 1) / PageSize}; 88 const u64 page_count{(unmap_size + PageSize - 1) / PageSize};
91 89
92 if (page_list.GetNumPages() != page_count) { 90 if (page_list.GetNumPages() != page_count) {
diff --git a/src/core/hle/kernel/k_shared_memory.h b/src/core/hle/kernel/k_shared_memory.h
index 81de36136..2c1db0e70 100644
--- a/src/core/hle/kernel/k_shared_memory.h
+++ b/src/core/hle/kernel/k_shared_memory.h
@@ -9,7 +9,7 @@
9#include "common/common_types.h" 9#include "common/common_types.h"
10#include "core/device_memory.h" 10#include "core/device_memory.h"
11#include "core/hle/kernel/k_memory_block.h" 11#include "core/hle/kernel/k_memory_block.h"
12#include "core/hle/kernel/k_page_linked_list.h" 12#include "core/hle/kernel/k_page_group.h"
13#include "core/hle/kernel/k_process.h" 13#include "core/hle/kernel/k_process.h"
14#include "core/hle/kernel/slab_helpers.h" 14#include "core/hle/kernel/slab_helpers.h"
15#include "core/hle/result.h" 15#include "core/hle/result.h"
@@ -26,10 +26,10 @@ public:
26 explicit KSharedMemory(KernelCore& kernel_); 26 explicit KSharedMemory(KernelCore& kernel_);
27 ~KSharedMemory() override; 27 ~KSharedMemory() override;
28 28
29 ResultCode Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_, 29 Result Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_,
30 KPageLinkedList&& page_list_, Svc::MemoryPermission owner_permission_, 30 KPageGroup&& page_list_, Svc::MemoryPermission owner_permission_,
31 Svc::MemoryPermission user_permission_, PAddr physical_address_, 31 Svc::MemoryPermission user_permission_, PAddr physical_address_,
32 std::size_t size_, std::string name_); 32 std::size_t size_, std::string name_);
33 33
34 /** 34 /**
35 * Maps a shared memory block to an address in the target process' address space 35 * Maps a shared memory block to an address in the target process' address space
@@ -38,8 +38,8 @@ public:
38 * @param map_size Size of the shared memory block to map 38 * @param map_size Size of the shared memory block to map
39 * @param permissions Memory block map permissions (specified by SVC field) 39 * @param permissions Memory block map permissions (specified by SVC field)
40 */ 40 */
41 ResultCode Map(KProcess& target_process, VAddr address, std::size_t map_size, 41 Result Map(KProcess& target_process, VAddr address, std::size_t map_size,
42 Svc::MemoryPermission permissions); 42 Svc::MemoryPermission permissions);
43 43
44 /** 44 /**
45 * Unmaps a shared memory block from an address in the target process' address space 45 * Unmaps a shared memory block from an address in the target process' address space
@@ -47,7 +47,7 @@ public:
47 * @param address Address in system memory to unmap shared memory block 47 * @param address Address in system memory to unmap shared memory block
48 * @param unmap_size Size of the shared memory block to unmap 48 * @param unmap_size Size of the shared memory block to unmap
49 */ 49 */
50 ResultCode Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size); 50 Result Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size);
51 51
52 /** 52 /**
53 * Gets a pointer to the shared memory block 53 * Gets a pointer to the shared memory block
@@ -77,7 +77,7 @@ public:
77private: 77private:
78 Core::DeviceMemory* device_memory; 78 Core::DeviceMemory* device_memory;
79 KProcess* owner_process{}; 79 KProcess* owner_process{};
80 KPageLinkedList page_list; 80 KPageGroup page_list;
81 Svc::MemoryPermission owner_permission{}; 81 Svc::MemoryPermission owner_permission{};
82 Svc::MemoryPermission user_permission{}; 82 Svc::MemoryPermission user_permission{};
83 PAddr physical_address{}; 83 PAddr physical_address{};
diff --git a/src/core/hle/kernel/k_synchronization_object.cpp b/src/core/hle/kernel/k_synchronization_object.cpp
index 8554144d5..802dca046 100644
--- a/src/core/hle/kernel/k_synchronization_object.cpp
+++ b/src/core/hle/kernel/k_synchronization_object.cpp
@@ -22,7 +22,7 @@ public:
22 : KThreadQueueWithoutEndWait(kernel_), m_objects(o), m_nodes(n), m_count(c) {} 22 : KThreadQueueWithoutEndWait(kernel_), m_objects(o), m_nodes(n), m_count(c) {}
23 23
24 void NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object, 24 void NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object,
25 ResultCode wait_result) override { 25 Result wait_result) override {
26 // Determine the sync index, and unlink all nodes. 26 // Determine the sync index, and unlink all nodes.
27 s32 sync_index = -1; 27 s32 sync_index = -1;
28 for (auto i = 0; i < m_count; ++i) { 28 for (auto i = 0; i < m_count; ++i) {
@@ -45,8 +45,7 @@ public:
45 KThreadQueue::EndWait(waiting_thread, wait_result); 45 KThreadQueue::EndWait(waiting_thread, wait_result);
46 } 46 }
47 47
48 void CancelWait(KThread* waiting_thread, ResultCode wait_result, 48 void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
49 bool cancel_timer_task) override {
50 // Remove all nodes from our list. 49 // Remove all nodes from our list.
51 for (auto i = 0; i < m_count; ++i) { 50 for (auto i = 0; i < m_count; ++i) {
52 m_objects[i]->UnlinkNode(std::addressof(m_nodes[i])); 51 m_objects[i]->UnlinkNode(std::addressof(m_nodes[i]));
@@ -72,9 +71,9 @@ void KSynchronizationObject::Finalize() {
72 KAutoObject::Finalize(); 71 KAutoObject::Finalize();
73} 72}
74 73
75ResultCode KSynchronizationObject::Wait(KernelCore& kernel_ctx, s32* out_index, 74Result KSynchronizationObject::Wait(KernelCore& kernel_ctx, s32* out_index,
76 KSynchronizationObject** objects, const s32 num_objects, 75 KSynchronizationObject** objects, const s32 num_objects,
77 s64 timeout) { 76 s64 timeout) {
78 // Allocate space on stack for thread nodes. 77 // Allocate space on stack for thread nodes.
79 std::vector<ThreadListNode> thread_nodes(num_objects); 78 std::vector<ThreadListNode> thread_nodes(num_objects);
80 79
@@ -148,7 +147,7 @@ KSynchronizationObject::KSynchronizationObject(KernelCore& kernel_)
148 147
149KSynchronizationObject::~KSynchronizationObject() = default; 148KSynchronizationObject::~KSynchronizationObject() = default;
150 149
151void KSynchronizationObject::NotifyAvailable(ResultCode result) { 150void KSynchronizationObject::NotifyAvailable(Result result) {
152 KScopedSchedulerLock sl(kernel); 151 KScopedSchedulerLock sl(kernel);
153 152
154 // If we're not signaled, we've nothing to notify. 153 // If we're not signaled, we've nothing to notify.
diff --git a/src/core/hle/kernel/k_synchronization_object.h b/src/core/hle/kernel/k_synchronization_object.h
index d7540d6c7..8d8122ab7 100644
--- a/src/core/hle/kernel/k_synchronization_object.h
+++ b/src/core/hle/kernel/k_synchronization_object.h
@@ -24,9 +24,9 @@ public:
24 KThread* thread{}; 24 KThread* thread{};
25 }; 25 };
26 26
27 [[nodiscard]] static ResultCode Wait(KernelCore& kernel, s32* out_index, 27 [[nodiscard]] static Result Wait(KernelCore& kernel, s32* out_index,
28 KSynchronizationObject** objects, const s32 num_objects, 28 KSynchronizationObject** objects, const s32 num_objects,
29 s64 timeout); 29 s64 timeout);
30 30
31 void Finalize() override; 31 void Finalize() override;
32 32
@@ -72,7 +72,7 @@ protected:
72 72
73 virtual void OnFinalizeSynchronizationObject() {} 73 virtual void OnFinalizeSynchronizationObject() {}
74 74
75 void NotifyAvailable(ResultCode result); 75 void NotifyAvailable(Result result);
76 void NotifyAvailable() { 76 void NotifyAvailable() {
77 return this->NotifyAvailable(ResultSuccess); 77 return this->NotifyAvailable(ResultSuccess);
78 } 78 }
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp
index fa5352847..8d7faa662 100644
--- a/src/core/hle/kernel/k_thread.cpp
+++ b/src/core/hle/kernel/k_thread.cpp
@@ -80,8 +80,7 @@ public:
80 explicit ThreadQueueImplForKThreadSetProperty(KernelCore& kernel_, KThread::WaiterList* wl) 80 explicit ThreadQueueImplForKThreadSetProperty(KernelCore& kernel_, KThread::WaiterList* wl)
81 : KThreadQueue(kernel_), m_wait_list(wl) {} 81 : KThreadQueue(kernel_), m_wait_list(wl) {}
82 82
83 void CancelWait(KThread* waiting_thread, ResultCode wait_result, 83 void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
84 bool cancel_timer_task) override {
85 // Remove the thread from the wait list. 84 // Remove the thread from the wait list.
86 m_wait_list->erase(m_wait_list->iterator_to(*waiting_thread)); 85 m_wait_list->erase(m_wait_list->iterator_to(*waiting_thread));
87 86
@@ -99,8 +98,8 @@ KThread::KThread(KernelCore& kernel_)
99 : KAutoObjectWithSlabHeapAndContainer{kernel_}, activity_pause_lock{kernel_} {} 98 : KAutoObjectWithSlabHeapAndContainer{kernel_}, activity_pause_lock{kernel_} {}
100KThread::~KThread() = default; 99KThread::~KThread() = default;
101 100
102ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, s32 prio, 101Result KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, s32 prio,
103 s32 virt_core, KProcess* owner, ThreadType type) { 102 s32 virt_core, KProcess* owner, ThreadType type) {
104 // Assert parameters are valid. 103 // Assert parameters are valid.
105 ASSERT((type == ThreadType::Main) || (type == ThreadType::Dummy) || 104 ASSERT((type == ThreadType::Main) || (type == ThreadType::Dummy) ||
106 (Svc::HighestThreadPriority <= prio && prio <= Svc::LowestThreadPriority)); 105 (Svc::HighestThreadPriority <= prio && prio <= Svc::LowestThreadPriority));
@@ -245,10 +244,10 @@ ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_s
245 return ResultSuccess; 244 return ResultSuccess;
246} 245}
247 246
248ResultCode KThread::InitializeThread(KThread* thread, KThreadFunction func, uintptr_t arg, 247Result KThread::InitializeThread(KThread* thread, KThreadFunction func, uintptr_t arg,
249 VAddr user_stack_top, s32 prio, s32 core, KProcess* owner, 248 VAddr user_stack_top, s32 prio, s32 core, KProcess* owner,
250 ThreadType type, std::function<void(void*)>&& init_func, 249 ThreadType type, std::function<void(void*)>&& init_func,
251 void* init_func_parameter) { 250 void* init_func_parameter) {
252 // Initialize the thread. 251 // Initialize the thread.
253 R_TRY(thread->Initialize(func, arg, user_stack_top, prio, core, owner, type)); 252 R_TRY(thread->Initialize(func, arg, user_stack_top, prio, core, owner, type));
254 253
@@ -260,27 +259,26 @@ ResultCode KThread::InitializeThread(KThread* thread, KThreadFunction func, uint
260 return ResultSuccess; 259 return ResultSuccess;
261} 260}
262 261
263ResultCode KThread::InitializeDummyThread(KThread* thread) { 262Result KThread::InitializeDummyThread(KThread* thread) {
264 return thread->Initialize({}, {}, {}, DummyThreadPriority, 3, {}, ThreadType::Dummy); 263 return thread->Initialize({}, {}, {}, DummyThreadPriority, 3, {}, ThreadType::Dummy);
265} 264}
266 265
267ResultCode KThread::InitializeIdleThread(Core::System& system, KThread* thread, s32 virt_core) { 266Result KThread::InitializeIdleThread(Core::System& system, KThread* thread, s32 virt_core) {
268 return InitializeThread(thread, {}, {}, {}, IdleThreadPriority, virt_core, {}, ThreadType::Main, 267 return InitializeThread(thread, {}, {}, {}, IdleThreadPriority, virt_core, {}, ThreadType::Main,
269 Core::CpuManager::GetIdleThreadStartFunc(), 268 Core::CpuManager::GetIdleThreadStartFunc(),
270 system.GetCpuManager().GetStartFuncParameter()); 269 system.GetCpuManager().GetStartFuncParameter());
271} 270}
272 271
273ResultCode KThread::InitializeHighPriorityThread(Core::System& system, KThread* thread, 272Result KThread::InitializeHighPriorityThread(Core::System& system, KThread* thread,
274 KThreadFunction func, uintptr_t arg, 273 KThreadFunction func, uintptr_t arg, s32 virt_core) {
275 s32 virt_core) {
276 return InitializeThread(thread, func, arg, {}, {}, virt_core, nullptr, ThreadType::HighPriority, 274 return InitializeThread(thread, func, arg, {}, {}, virt_core, nullptr, ThreadType::HighPriority,
277 Core::CpuManager::GetShutdownThreadStartFunc(), 275 Core::CpuManager::GetShutdownThreadStartFunc(),
278 system.GetCpuManager().GetStartFuncParameter()); 276 system.GetCpuManager().GetStartFuncParameter());
279} 277}
280 278
281ResultCode KThread::InitializeUserThread(Core::System& system, KThread* thread, 279Result KThread::InitializeUserThread(Core::System& system, KThread* thread, KThreadFunction func,
282 KThreadFunction func, uintptr_t arg, VAddr user_stack_top, 280 uintptr_t arg, VAddr user_stack_top, s32 prio, s32 virt_core,
283 s32 prio, s32 virt_core, KProcess* owner) { 281 KProcess* owner) {
284 system.Kernel().GlobalSchedulerContext().AddThread(thread); 282 system.Kernel().GlobalSchedulerContext().AddThread(thread);
285 return InitializeThread(thread, func, arg, user_stack_top, prio, virt_core, owner, 283 return InitializeThread(thread, func, arg, user_stack_top, prio, virt_core, owner,
286 ThreadType::User, Core::CpuManager::GetGuestThreadStartFunc(), 284 ThreadType::User, Core::CpuManager::GetGuestThreadStartFunc(),
@@ -523,7 +521,7 @@ void KThread::ClearInterruptFlag() {
523 memory.Write16(tls_address + offsetof(ThreadLocalRegion, interrupt_flag), 0); 521 memory.Write16(tls_address + offsetof(ThreadLocalRegion, interrupt_flag), 0);
524} 522}
525 523
526ResultCode KThread::GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask) { 524Result KThread::GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask) {
527 KScopedSchedulerLock sl{kernel}; 525 KScopedSchedulerLock sl{kernel};
528 526
529 // Get the virtual mask. 527 // Get the virtual mask.
@@ -533,7 +531,7 @@ ResultCode KThread::GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask) {
533 return ResultSuccess; 531 return ResultSuccess;
534} 532}
535 533
536ResultCode KThread::GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask) { 534Result KThread::GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask) {
537 KScopedSchedulerLock sl{kernel}; 535 KScopedSchedulerLock sl{kernel};
538 ASSERT(num_core_migration_disables >= 0); 536 ASSERT(num_core_migration_disables >= 0);
539 537
@@ -549,7 +547,7 @@ ResultCode KThread::GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_m
549 return ResultSuccess; 547 return ResultSuccess;
550} 548}
551 549
552ResultCode KThread::SetCoreMask(s32 core_id_, u64 v_affinity_mask) { 550Result KThread::SetCoreMask(s32 core_id_, u64 v_affinity_mask) {
553 ASSERT(parent != nullptr); 551 ASSERT(parent != nullptr);
554 ASSERT(v_affinity_mask != 0); 552 ASSERT(v_affinity_mask != 0);
555 KScopedLightLock lk(activity_pause_lock); 553 KScopedLightLock lk(activity_pause_lock);
@@ -761,7 +759,7 @@ void KThread::WaitUntilSuspended() {
761 } 759 }
762} 760}
763 761
764ResultCode KThread::SetActivity(Svc::ThreadActivity activity) { 762Result KThread::SetActivity(Svc::ThreadActivity activity) {
765 // Lock ourselves. 763 // Lock ourselves.
766 KScopedLightLock lk(activity_pause_lock); 764 KScopedLightLock lk(activity_pause_lock);
767 765
@@ -834,7 +832,7 @@ ResultCode KThread::SetActivity(Svc::ThreadActivity activity) {
834 return ResultSuccess; 832 return ResultSuccess;
835} 833}
836 834
837ResultCode KThread::GetThreadContext3(std::vector<u8>& out) { 835Result KThread::GetThreadContext3(std::vector<u8>& out) {
838 // Lock ourselves. 836 // Lock ourselves.
839 KScopedLightLock lk{activity_pause_lock}; 837 KScopedLightLock lk{activity_pause_lock};
840 838
@@ -999,7 +997,7 @@ KThread* KThread::RemoveWaiterByKey(s32* out_num_waiters, VAddr key) {
999 return next_lock_owner; 997 return next_lock_owner;
1000} 998}
1001 999
1002ResultCode KThread::Run() { 1000Result KThread::Run() {
1003 while (true) { 1001 while (true) {
1004 KScopedSchedulerLock lk{kernel}; 1002 KScopedSchedulerLock lk{kernel};
1005 1003
@@ -1060,7 +1058,7 @@ void KThread::Exit() {
1060 } 1058 }
1061} 1059}
1062 1060
1063ResultCode KThread::Sleep(s64 timeout) { 1061Result KThread::Sleep(s64 timeout) {
1064 ASSERT(!kernel.GlobalSchedulerContext().IsLocked()); 1062 ASSERT(!kernel.GlobalSchedulerContext().IsLocked());
1065 ASSERT(this == GetCurrentThreadPointer(kernel)); 1063 ASSERT(this == GetCurrentThreadPointer(kernel));
1066 ASSERT(timeout > 0); 1064 ASSERT(timeout > 0);
@@ -1116,7 +1114,7 @@ void KThread::BeginWait(KThreadQueue* queue) {
1116 wait_queue = queue; 1114 wait_queue = queue;
1117} 1115}
1118 1116
1119void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, ResultCode wait_result_) { 1117void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, Result wait_result_) {
1120 // Lock the scheduler. 1118 // Lock the scheduler.
1121 KScopedSchedulerLock sl(kernel); 1119 KScopedSchedulerLock sl(kernel);
1122 1120
@@ -1126,7 +1124,7 @@ void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, ResultCod
1126 } 1124 }
1127} 1125}
1128 1126
1129void KThread::EndWait(ResultCode wait_result_) { 1127void KThread::EndWait(Result wait_result_) {
1130 // Lock the scheduler. 1128 // Lock the scheduler.
1131 KScopedSchedulerLock sl(kernel); 1129 KScopedSchedulerLock sl(kernel);
1132 1130
@@ -1145,7 +1143,7 @@ void KThread::EndWait(ResultCode wait_result_) {
1145 } 1143 }
1146} 1144}
1147 1145
1148void KThread::CancelWait(ResultCode wait_result_, bool cancel_timer_task) { 1146void KThread::CancelWait(Result wait_result_, bool cancel_timer_task) {
1149 // Lock the scheduler. 1147 // Lock the scheduler.
1150 KScopedSchedulerLock sl(kernel); 1148 KScopedSchedulerLock sl(kernel);
1151 1149
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h
index c6ca37f56..94c4cd1c8 100644
--- a/src/core/hle/kernel/k_thread.h
+++ b/src/core/hle/kernel/k_thread.h
@@ -176,7 +176,7 @@ public:
176 176
177 void SetBasePriority(s32 value); 177 void SetBasePriority(s32 value);
178 178
179 [[nodiscard]] ResultCode Run(); 179 [[nodiscard]] Result Run();
180 180
181 void Exit(); 181 void Exit();
182 182
@@ -218,11 +218,11 @@ public:
218 return synced_index; 218 return synced_index;
219 } 219 }
220 220
221 constexpr void SetWaitResult(ResultCode wait_res) { 221 constexpr void SetWaitResult(Result wait_res) {
222 wait_result = wait_res; 222 wait_result = wait_res;
223 } 223 }
224 224
225 [[nodiscard]] constexpr ResultCode GetWaitResult() const { 225 [[nodiscard]] constexpr Result GetWaitResult() const {
226 return wait_result; 226 return wait_result;
227 } 227 }
228 228
@@ -345,15 +345,15 @@ public:
345 return physical_affinity_mask; 345 return physical_affinity_mask;
346 } 346 }
347 347
348 [[nodiscard]] ResultCode GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask); 348 [[nodiscard]] Result GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask);
349 349
350 [[nodiscard]] ResultCode GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask); 350 [[nodiscard]] Result GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask);
351 351
352 [[nodiscard]] ResultCode SetCoreMask(s32 cpu_core_id, u64 v_affinity_mask); 352 [[nodiscard]] Result SetCoreMask(s32 cpu_core_id, u64 v_affinity_mask);
353 353
354 [[nodiscard]] ResultCode SetActivity(Svc::ThreadActivity activity); 354 [[nodiscard]] Result SetActivity(Svc::ThreadActivity activity);
355 355
356 [[nodiscard]] ResultCode Sleep(s64 timeout); 356 [[nodiscard]] Result Sleep(s64 timeout);
357 357
358 [[nodiscard]] s64 GetYieldScheduleCount() const { 358 [[nodiscard]] s64 GetYieldScheduleCount() const {
359 return schedule_count; 359 return schedule_count;
@@ -411,20 +411,19 @@ public:
411 411
412 static void PostDestroy(uintptr_t arg); 412 static void PostDestroy(uintptr_t arg);
413 413
414 [[nodiscard]] static ResultCode InitializeDummyThread(KThread* thread); 414 [[nodiscard]] static Result InitializeDummyThread(KThread* thread);
415 415
416 [[nodiscard]] static ResultCode InitializeIdleThread(Core::System& system, KThread* thread, 416 [[nodiscard]] static Result InitializeIdleThread(Core::System& system, KThread* thread,
417 s32 virt_core); 417 s32 virt_core);
418 418
419 [[nodiscard]] static ResultCode InitializeHighPriorityThread(Core::System& system, 419 [[nodiscard]] static Result InitializeHighPriorityThread(Core::System& system, KThread* thread,
420 KThread* thread, 420 KThreadFunction func, uintptr_t arg,
421 KThreadFunction func, 421 s32 virt_core);
422 uintptr_t arg, s32 virt_core);
423 422
424 [[nodiscard]] static ResultCode InitializeUserThread(Core::System& system, KThread* thread, 423 [[nodiscard]] static Result InitializeUserThread(Core::System& system, KThread* thread,
425 KThreadFunction func, uintptr_t arg, 424 KThreadFunction func, uintptr_t arg,
426 VAddr user_stack_top, s32 prio, 425 VAddr user_stack_top, s32 prio, s32 virt_core,
427 s32 virt_core, KProcess* owner); 426 KProcess* owner);
428 427
429public: 428public:
430 struct StackParameters { 429 struct StackParameters {
@@ -610,7 +609,7 @@ public:
610 609
611 void RemoveWaiter(KThread* thread); 610 void RemoveWaiter(KThread* thread);
612 611
613 [[nodiscard]] ResultCode GetThreadContext3(std::vector<u8>& out); 612 [[nodiscard]] Result GetThreadContext3(std::vector<u8>& out);
614 613
615 [[nodiscard]] KThread* RemoveWaiterByKey(s32* out_num_waiters, VAddr key); 614 [[nodiscard]] KThread* RemoveWaiterByKey(s32* out_num_waiters, VAddr key);
616 615
@@ -636,9 +635,9 @@ public:
636 } 635 }
637 636
638 void BeginWait(KThreadQueue* queue); 637 void BeginWait(KThreadQueue* queue);
639 void NotifyAvailable(KSynchronizationObject* signaled_object, ResultCode wait_result_); 638 void NotifyAvailable(KSynchronizationObject* signaled_object, Result wait_result_);
640 void EndWait(ResultCode wait_result_); 639 void EndWait(Result wait_result_);
641 void CancelWait(ResultCode wait_result_, bool cancel_timer_task); 640 void CancelWait(Result wait_result_, bool cancel_timer_task);
642 641
643 [[nodiscard]] bool HasWaiters() const { 642 [[nodiscard]] bool HasWaiters() const {
644 return !waiter_list.empty(); 643 return !waiter_list.empty();
@@ -724,14 +723,14 @@ private:
724 723
725 void FinishTermination(); 724 void FinishTermination();
726 725
727 [[nodiscard]] ResultCode Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, 726 [[nodiscard]] Result Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top,
728 s32 prio, s32 virt_core, KProcess* owner, ThreadType type); 727 s32 prio, s32 virt_core, KProcess* owner, ThreadType type);
729 728
730 [[nodiscard]] static ResultCode InitializeThread(KThread* thread, KThreadFunction func, 729 [[nodiscard]] static Result InitializeThread(KThread* thread, KThreadFunction func,
731 uintptr_t arg, VAddr user_stack_top, s32 prio, 730 uintptr_t arg, VAddr user_stack_top, s32 prio,
732 s32 core, KProcess* owner, ThreadType type, 731 s32 core, KProcess* owner, ThreadType type,
733 std::function<void(void*)>&& init_func, 732 std::function<void(void*)>&& init_func,
734 void* init_func_parameter); 733 void* init_func_parameter);
735 734
736 static void RestorePriority(KernelCore& kernel_ctx, KThread* thread); 735 static void RestorePriority(KernelCore& kernel_ctx, KThread* thread);
737 736
@@ -768,7 +767,7 @@ private:
768 u32 suspend_request_flags{}; 767 u32 suspend_request_flags{};
769 u32 suspend_allowed_flags{}; 768 u32 suspend_allowed_flags{};
770 s32 synced_index{}; 769 s32 synced_index{};
771 ResultCode wait_result{ResultSuccess}; 770 Result wait_result{ResultSuccess};
772 s32 base_priority{}; 771 s32 base_priority{};
773 s32 physical_ideal_core_id{}; 772 s32 physical_ideal_core_id{};
774 s32 virtual_ideal_core_id{}; 773 s32 virtual_ideal_core_id{};
diff --git a/src/core/hle/kernel/k_thread_local_page.cpp b/src/core/hle/kernel/k_thread_local_page.cpp
index fbdc40b3a..563560114 100644
--- a/src/core/hle/kernel/k_thread_local_page.cpp
+++ b/src/core/hle/kernel/k_thread_local_page.cpp
@@ -13,7 +13,7 @@
13 13
14namespace Kernel { 14namespace Kernel {
15 15
16ResultCode KThreadLocalPage::Initialize(KernelCore& kernel, KProcess* process) { 16Result KThreadLocalPage::Initialize(KernelCore& kernel, KProcess* process) {
17 // Set that this process owns us. 17 // Set that this process owns us.
18 m_owner = process; 18 m_owner = process;
19 m_kernel = &kernel; 19 m_kernel = &kernel;
@@ -35,7 +35,7 @@ ResultCode KThreadLocalPage::Initialize(KernelCore& kernel, KProcess* process) {
35 return ResultSuccess; 35 return ResultSuccess;
36} 36}
37 37
38ResultCode KThreadLocalPage::Finalize() { 38Result KThreadLocalPage::Finalize() {
39 // Get the physical address of the page. 39 // Get the physical address of the page.
40 const PAddr phys_addr = m_owner->PageTable().GetPhysicalAddr(m_virt_addr); 40 const PAddr phys_addr = m_owner->PageTable().GetPhysicalAddr(m_virt_addr);
41 ASSERT(phys_addr); 41 ASSERT(phys_addr);
diff --git a/src/core/hle/kernel/k_thread_local_page.h b/src/core/hle/kernel/k_thread_local_page.h
index a4fe43ee5..0a7f22680 100644
--- a/src/core/hle/kernel/k_thread_local_page.h
+++ b/src/core/hle/kernel/k_thread_local_page.h
@@ -34,8 +34,8 @@ public:
34 return m_virt_addr; 34 return m_virt_addr;
35 } 35 }
36 36
37 ResultCode Initialize(KernelCore& kernel, KProcess* process); 37 Result Initialize(KernelCore& kernel, KProcess* process);
38 ResultCode Finalize(); 38 Result Finalize();
39 39
40 VAddr Reserve(); 40 VAddr Reserve();
41 void Release(VAddr addr); 41 void Release(VAddr addr);
diff --git a/src/core/hle/kernel/k_thread_queue.cpp b/src/core/hle/kernel/k_thread_queue.cpp
index 1c338904a..9f4e081ba 100644
--- a/src/core/hle/kernel/k_thread_queue.cpp
+++ b/src/core/hle/kernel/k_thread_queue.cpp
@@ -9,9 +9,9 @@ namespace Kernel {
9 9
10void KThreadQueue::NotifyAvailable([[maybe_unused]] KThread* waiting_thread, 10void KThreadQueue::NotifyAvailable([[maybe_unused]] KThread* waiting_thread,
11 [[maybe_unused]] KSynchronizationObject* signaled_object, 11 [[maybe_unused]] KSynchronizationObject* signaled_object,
12 [[maybe_unused]] ResultCode wait_result) {} 12 [[maybe_unused]] Result wait_result) {}
13 13
14void KThreadQueue::EndWait(KThread* waiting_thread, ResultCode wait_result) { 14void KThreadQueue::EndWait(KThread* waiting_thread, Result wait_result) {
15 // Set the thread's wait result. 15 // Set the thread's wait result.
16 waiting_thread->SetWaitResult(wait_result); 16 waiting_thread->SetWaitResult(wait_result);
17 17
@@ -25,8 +25,7 @@ void KThreadQueue::EndWait(KThread* waiting_thread, ResultCode wait_result) {
25 kernel.TimeManager().UnscheduleTimeEvent(waiting_thread); 25 kernel.TimeManager().UnscheduleTimeEvent(waiting_thread);
26} 26}
27 27
28void KThreadQueue::CancelWait(KThread* waiting_thread, ResultCode wait_result, 28void KThreadQueue::CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) {
29 bool cancel_timer_task) {
30 // Set the thread's wait result. 29 // Set the thread's wait result.
31 waiting_thread->SetWaitResult(wait_result); 30 waiting_thread->SetWaitResult(wait_result);
32 31
@@ -43,6 +42,6 @@ void KThreadQueue::CancelWait(KThread* waiting_thread, ResultCode wait_result,
43} 42}
44 43
45void KThreadQueueWithoutEndWait::EndWait([[maybe_unused]] KThread* waiting_thread, 44void KThreadQueueWithoutEndWait::EndWait([[maybe_unused]] KThread* waiting_thread,
46 [[maybe_unused]] ResultCode wait_result) {} 45 [[maybe_unused]] Result wait_result) {}
47 46
48} // namespace Kernel 47} // namespace Kernel
diff --git a/src/core/hle/kernel/k_thread_queue.h b/src/core/hle/kernel/k_thread_queue.h
index 4a7dbdd47..8d76ece81 100644
--- a/src/core/hle/kernel/k_thread_queue.h
+++ b/src/core/hle/kernel/k_thread_queue.h
@@ -14,10 +14,9 @@ public:
14 virtual ~KThreadQueue() = default; 14 virtual ~KThreadQueue() = default;
15 15
16 virtual void NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object, 16 virtual void NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object,
17 ResultCode wait_result); 17 Result wait_result);
18 virtual void EndWait(KThread* waiting_thread, ResultCode wait_result); 18 virtual void EndWait(KThread* waiting_thread, Result wait_result);
19 virtual void CancelWait(KThread* waiting_thread, ResultCode wait_result, 19 virtual void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task);
20 bool cancel_timer_task);
21 20
22private: 21private:
23 KernelCore& kernel; 22 KernelCore& kernel;
@@ -28,7 +27,7 @@ class KThreadQueueWithoutEndWait : public KThreadQueue {
28public: 27public:
29 explicit KThreadQueueWithoutEndWait(KernelCore& kernel_) : KThreadQueue(kernel_) {} 28 explicit KThreadQueueWithoutEndWait(KernelCore& kernel_) : KThreadQueue(kernel_) {}
30 29
31 void EndWait(KThread* waiting_thread, ResultCode wait_result) override final; 30 void EndWait(KThread* waiting_thread, Result wait_result) override final;
32}; 31};
33 32
34} // namespace Kernel 33} // namespace Kernel
diff --git a/src/core/hle/kernel/k_transfer_memory.cpp b/src/core/hle/kernel/k_transfer_memory.cpp
index 1ed4b0f6f..b0320eb73 100644
--- a/src/core/hle/kernel/k_transfer_memory.cpp
+++ b/src/core/hle/kernel/k_transfer_memory.cpp
@@ -13,8 +13,8 @@ KTransferMemory::KTransferMemory(KernelCore& kernel_)
13 13
14KTransferMemory::~KTransferMemory() = default; 14KTransferMemory::~KTransferMemory() = default;
15 15
16ResultCode KTransferMemory::Initialize(VAddr address_, std::size_t size_, 16Result KTransferMemory::Initialize(VAddr address_, std::size_t size_,
17 Svc::MemoryPermission owner_perm_) { 17 Svc::MemoryPermission owner_perm_) {
18 // Set members. 18 // Set members.
19 owner = kernel.CurrentProcess(); 19 owner = kernel.CurrentProcess();
20 20
diff --git a/src/core/hle/kernel/k_transfer_memory.h b/src/core/hle/kernel/k_transfer_memory.h
index 9ad80ba30..85d508ee7 100644
--- a/src/core/hle/kernel/k_transfer_memory.h
+++ b/src/core/hle/kernel/k_transfer_memory.h
@@ -7,7 +7,7 @@
7#include "core/hle/kernel/svc_types.h" 7#include "core/hle/kernel/svc_types.h"
8#include "core/hle/result.h" 8#include "core/hle/result.h"
9 9
10union ResultCode; 10union Result;
11 11
12namespace Core::Memory { 12namespace Core::Memory {
13class Memory; 13class Memory;
@@ -26,7 +26,7 @@ public:
26 explicit KTransferMemory(KernelCore& kernel_); 26 explicit KTransferMemory(KernelCore& kernel_);
27 ~KTransferMemory() override; 27 ~KTransferMemory() override;
28 28
29 ResultCode Initialize(VAddr address_, std::size_t size_, Svc::MemoryPermission owner_perm_); 29 Result Initialize(VAddr address_, std::size_t size_, Svc::MemoryPermission owner_perm_);
30 30
31 void Finalize() override; 31 void Finalize() override;
32 32
diff --git a/src/core/hle/kernel/k_writable_event.cpp b/src/core/hle/kernel/k_writable_event.cpp
index 26c8489ad..ff88c5acd 100644
--- a/src/core/hle/kernel/k_writable_event.cpp
+++ b/src/core/hle/kernel/k_writable_event.cpp
@@ -18,11 +18,11 @@ void KWritableEvent::Initialize(KEvent* parent_event_, std::string&& name_) {
18 parent->GetReadableEvent().Open(); 18 parent->GetReadableEvent().Open();
19} 19}
20 20
21ResultCode KWritableEvent::Signal() { 21Result KWritableEvent::Signal() {
22 return parent->GetReadableEvent().Signal(); 22 return parent->GetReadableEvent().Signal();
23} 23}
24 24
25ResultCode KWritableEvent::Clear() { 25Result KWritableEvent::Clear() {
26 return parent->GetReadableEvent().Clear(); 26 return parent->GetReadableEvent().Clear();
27} 27}
28 28
diff --git a/src/core/hle/kernel/k_writable_event.h b/src/core/hle/kernel/k_writable_event.h
index e289e80c4..3fd0c7d0a 100644
--- a/src/core/hle/kernel/k_writable_event.h
+++ b/src/core/hle/kernel/k_writable_event.h
@@ -25,8 +25,8 @@ public:
25 static void PostDestroy([[maybe_unused]] uintptr_t arg) {} 25 static void PostDestroy([[maybe_unused]] uintptr_t arg) {}
26 26
27 void Initialize(KEvent* parent_, std::string&& name_); 27 void Initialize(KEvent* parent_, std::string&& name_);
28 ResultCode Signal(); 28 Result Signal();
29 ResultCode Clear(); 29 Result Clear();
30 30
31 KEvent* GetParent() const { 31 KEvent* GetParent() const {
32 return parent; 32 return parent;
diff --git a/src/core/hle/kernel/process_capability.cpp b/src/core/hle/kernel/process_capability.cpp
index 54872626e..773319ad8 100644
--- a/src/core/hle/kernel/process_capability.cpp
+++ b/src/core/hle/kernel/process_capability.cpp
@@ -68,9 +68,9 @@ u32 GetFlagBitOffset(CapabilityType type) {
68 68
69} // Anonymous namespace 69} // Anonymous namespace
70 70
71ResultCode ProcessCapabilities::InitializeForKernelProcess(const u32* capabilities, 71Result ProcessCapabilities::InitializeForKernelProcess(const u32* capabilities,
72 std::size_t num_capabilities, 72 std::size_t num_capabilities,
73 KPageTable& page_table) { 73 KPageTable& page_table) {
74 Clear(); 74 Clear();
75 75
76 // Allow all cores and priorities. 76 // Allow all cores and priorities.
@@ -81,9 +81,9 @@ ResultCode ProcessCapabilities::InitializeForKernelProcess(const u32* capabiliti
81 return ParseCapabilities(capabilities, num_capabilities, page_table); 81 return ParseCapabilities(capabilities, num_capabilities, page_table);
82} 82}
83 83
84ResultCode ProcessCapabilities::InitializeForUserProcess(const u32* capabilities, 84Result ProcessCapabilities::InitializeForUserProcess(const u32* capabilities,
85 std::size_t num_capabilities, 85 std::size_t num_capabilities,
86 KPageTable& page_table) { 86 KPageTable& page_table) {
87 Clear(); 87 Clear();
88 88
89 return ParseCapabilities(capabilities, num_capabilities, page_table); 89 return ParseCapabilities(capabilities, num_capabilities, page_table);
@@ -107,9 +107,8 @@ void ProcessCapabilities::InitializeForMetadatalessProcess() {
107 can_force_debug = true; 107 can_force_debug = true;
108} 108}
109 109
110ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities, 110Result ProcessCapabilities::ParseCapabilities(const u32* capabilities, std::size_t num_capabilities,
111 std::size_t num_capabilities, 111 KPageTable& page_table) {
112 KPageTable& page_table) {
113 u32 set_flags = 0; 112 u32 set_flags = 0;
114 u32 set_svc_bits = 0; 113 u32 set_svc_bits = 0;
115 114
@@ -155,8 +154,8 @@ ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities,
155 return ResultSuccess; 154 return ResultSuccess;
156} 155}
157 156
158ResultCode ProcessCapabilities::ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, 157Result ProcessCapabilities::ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, u32 flag,
159 u32 flag, KPageTable& page_table) { 158 KPageTable& page_table) {
160 const auto type = GetCapabilityType(flag); 159 const auto type = GetCapabilityType(flag);
161 160
162 if (type == CapabilityType::Unset) { 161 if (type == CapabilityType::Unset) {
@@ -224,7 +223,7 @@ void ProcessCapabilities::Clear() {
224 can_force_debug = false; 223 can_force_debug = false;
225} 224}
226 225
227ResultCode ProcessCapabilities::HandlePriorityCoreNumFlags(u32 flags) { 226Result ProcessCapabilities::HandlePriorityCoreNumFlags(u32 flags) {
228 if (priority_mask != 0 || core_mask != 0) { 227 if (priority_mask != 0 || core_mask != 0) {
229 LOG_ERROR(Kernel, "Core or priority mask are not zero! priority_mask={}, core_mask={}", 228 LOG_ERROR(Kernel, "Core or priority mask are not zero! priority_mask={}, core_mask={}",
230 priority_mask, core_mask); 229 priority_mask, core_mask);
@@ -266,7 +265,7 @@ ResultCode ProcessCapabilities::HandlePriorityCoreNumFlags(u32 flags) {
266 return ResultSuccess; 265 return ResultSuccess;
267} 266}
268 267
269ResultCode ProcessCapabilities::HandleSyscallFlags(u32& set_svc_bits, u32 flags) { 268Result ProcessCapabilities::HandleSyscallFlags(u32& set_svc_bits, u32 flags) {
270 const u32 index = flags >> 29; 269 const u32 index = flags >> 29;
271 const u32 svc_bit = 1U << index; 270 const u32 svc_bit = 1U << index;
272 271
@@ -290,23 +289,23 @@ ResultCode ProcessCapabilities::HandleSyscallFlags(u32& set_svc_bits, u32 flags)
290 return ResultSuccess; 289 return ResultSuccess;
291} 290}
292 291
293ResultCode ProcessCapabilities::HandleMapPhysicalFlags(u32 flags, u32 size_flags, 292Result ProcessCapabilities::HandleMapPhysicalFlags(u32 flags, u32 size_flags,
294 KPageTable& page_table) { 293 KPageTable& page_table) {
295 // TODO(Lioncache): Implement once the memory manager can handle this. 294 // TODO(Lioncache): Implement once the memory manager can handle this.
296 return ResultSuccess; 295 return ResultSuccess;
297} 296}
298 297
299ResultCode ProcessCapabilities::HandleMapIOFlags(u32 flags, KPageTable& page_table) { 298Result ProcessCapabilities::HandleMapIOFlags(u32 flags, KPageTable& page_table) {
300 // TODO(Lioncache): Implement once the memory manager can handle this. 299 // TODO(Lioncache): Implement once the memory manager can handle this.
301 return ResultSuccess; 300 return ResultSuccess;
302} 301}
303 302
304ResultCode ProcessCapabilities::HandleMapRegionFlags(u32 flags, KPageTable& page_table) { 303Result ProcessCapabilities::HandleMapRegionFlags(u32 flags, KPageTable& page_table) {
305 // TODO(Lioncache): Implement once the memory manager can handle this. 304 // TODO(Lioncache): Implement once the memory manager can handle this.
306 return ResultSuccess; 305 return ResultSuccess;
307} 306}
308 307
309ResultCode ProcessCapabilities::HandleInterruptFlags(u32 flags) { 308Result ProcessCapabilities::HandleInterruptFlags(u32 flags) {
310 constexpr u32 interrupt_ignore_value = 0x3FF; 309 constexpr u32 interrupt_ignore_value = 0x3FF;
311 const u32 interrupt0 = (flags >> 12) & 0x3FF; 310 const u32 interrupt0 = (flags >> 12) & 0x3FF;
312 const u32 interrupt1 = (flags >> 22) & 0x3FF; 311 const u32 interrupt1 = (flags >> 22) & 0x3FF;
@@ -333,7 +332,7 @@ ResultCode ProcessCapabilities::HandleInterruptFlags(u32 flags) {
333 return ResultSuccess; 332 return ResultSuccess;
334} 333}
335 334
336ResultCode ProcessCapabilities::HandleProgramTypeFlags(u32 flags) { 335Result ProcessCapabilities::HandleProgramTypeFlags(u32 flags) {
337 const u32 reserved = flags >> 17; 336 const u32 reserved = flags >> 17;
338 if (reserved != 0) { 337 if (reserved != 0) {
339 LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved); 338 LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved);
@@ -344,7 +343,7 @@ ResultCode ProcessCapabilities::HandleProgramTypeFlags(u32 flags) {
344 return ResultSuccess; 343 return ResultSuccess;
345} 344}
346 345
347ResultCode ProcessCapabilities::HandleKernelVersionFlags(u32 flags) { 346Result ProcessCapabilities::HandleKernelVersionFlags(u32 flags) {
348 // Yes, the internal member variable is checked in the actual kernel here. 347 // Yes, the internal member variable is checked in the actual kernel here.
349 // This might look odd for options that are only allowed to be initialized 348 // This might look odd for options that are only allowed to be initialized
350 // just once, however the kernel has a separate initialization function for 349 // just once, however the kernel has a separate initialization function for
@@ -364,7 +363,7 @@ ResultCode ProcessCapabilities::HandleKernelVersionFlags(u32 flags) {
364 return ResultSuccess; 363 return ResultSuccess;
365} 364}
366 365
367ResultCode ProcessCapabilities::HandleHandleTableFlags(u32 flags) { 366Result ProcessCapabilities::HandleHandleTableFlags(u32 flags) {
368 const u32 reserved = flags >> 26; 367 const u32 reserved = flags >> 26;
369 if (reserved != 0) { 368 if (reserved != 0) {
370 LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved); 369 LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved);
@@ -375,7 +374,7 @@ ResultCode ProcessCapabilities::HandleHandleTableFlags(u32 flags) {
375 return ResultSuccess; 374 return ResultSuccess;
376} 375}
377 376
378ResultCode ProcessCapabilities::HandleDebugFlags(u32 flags) { 377Result ProcessCapabilities::HandleDebugFlags(u32 flags) {
379 const u32 reserved = flags >> 19; 378 const u32 reserved = flags >> 19;
380 if (reserved != 0) { 379 if (reserved != 0) {
381 LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved); 380 LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved);
diff --git a/src/core/hle/kernel/process_capability.h b/src/core/hle/kernel/process_capability.h
index 7f3a2339d..ff05dc5ff 100644
--- a/src/core/hle/kernel/process_capability.h
+++ b/src/core/hle/kernel/process_capability.h
@@ -7,7 +7,7 @@
7 7
8#include "common/common_types.h" 8#include "common/common_types.h"
9 9
10union ResultCode; 10union Result;
11 11
12namespace Kernel { 12namespace Kernel {
13 13
@@ -86,8 +86,8 @@ public:
86 /// @returns ResultSuccess if this capabilities instance was able to be initialized, 86 /// @returns ResultSuccess if this capabilities instance was able to be initialized,
87 /// otherwise, an error code upon failure. 87 /// otherwise, an error code upon failure.
88 /// 88 ///
89 ResultCode InitializeForKernelProcess(const u32* capabilities, std::size_t num_capabilities, 89 Result InitializeForKernelProcess(const u32* capabilities, std::size_t num_capabilities,
90 KPageTable& page_table); 90 KPageTable& page_table);
91 91
92 /// Initializes this process capabilities instance for a userland process. 92 /// Initializes this process capabilities instance for a userland process.
93 /// 93 ///
@@ -99,8 +99,8 @@ public:
99 /// @returns ResultSuccess if this capabilities instance was able to be initialized, 99 /// @returns ResultSuccess if this capabilities instance was able to be initialized,
100 /// otherwise, an error code upon failure. 100 /// otherwise, an error code upon failure.
101 /// 101 ///
102 ResultCode InitializeForUserProcess(const u32* capabilities, std::size_t num_capabilities, 102 Result InitializeForUserProcess(const u32* capabilities, std::size_t num_capabilities,
103 KPageTable& page_table); 103 KPageTable& page_table);
104 104
105 /// Initializes this process capabilities instance for a process that does not 105 /// Initializes this process capabilities instance for a process that does not
106 /// have any metadata to parse. 106 /// have any metadata to parse.
@@ -185,8 +185,8 @@ private:
185 /// 185 ///
186 /// @return ResultSuccess if no errors occur, otherwise an error code. 186 /// @return ResultSuccess if no errors occur, otherwise an error code.
187 /// 187 ///
188 ResultCode ParseCapabilities(const u32* capabilities, std::size_t num_capabilities, 188 Result ParseCapabilities(const u32* capabilities, std::size_t num_capabilities,
189 KPageTable& page_table); 189 KPageTable& page_table);
190 190
191 /// Attempts to parse a capability descriptor that is only represented by a 191 /// Attempts to parse a capability descriptor that is only represented by a
192 /// single flag set. 192 /// single flag set.
@@ -200,8 +200,8 @@ private:
200 /// 200 ///
201 /// @return ResultSuccess if no errors occurred, otherwise an error code. 201 /// @return ResultSuccess if no errors occurred, otherwise an error code.
202 /// 202 ///
203 ResultCode ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, u32 flag, 203 Result ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, u32 flag,
204 KPageTable& page_table); 204 KPageTable& page_table);
205 205
206 /// Clears the internal state of this process capability instance. Necessary, 206 /// Clears the internal state of this process capability instance. Necessary,
207 /// to have a sane starting point due to us allowing running executables without 207 /// to have a sane starting point due to us allowing running executables without
@@ -219,34 +219,34 @@ private:
219 void Clear(); 219 void Clear();
220 220
221 /// Handles flags related to the priority and core number capability flags. 221 /// Handles flags related to the priority and core number capability flags.
222 ResultCode HandlePriorityCoreNumFlags(u32 flags); 222 Result HandlePriorityCoreNumFlags(u32 flags);
223 223
224 /// Handles flags related to determining the allowable SVC mask. 224 /// Handles flags related to determining the allowable SVC mask.
225 ResultCode HandleSyscallFlags(u32& set_svc_bits, u32 flags); 225 Result HandleSyscallFlags(u32& set_svc_bits, u32 flags);
226 226
227 /// Handles flags related to mapping physical memory pages. 227 /// Handles flags related to mapping physical memory pages.
228 ResultCode HandleMapPhysicalFlags(u32 flags, u32 size_flags, KPageTable& page_table); 228 Result HandleMapPhysicalFlags(u32 flags, u32 size_flags, KPageTable& page_table);
229 229
230 /// Handles flags related to mapping IO pages. 230 /// Handles flags related to mapping IO pages.
231 ResultCode HandleMapIOFlags(u32 flags, KPageTable& page_table); 231 Result HandleMapIOFlags(u32 flags, KPageTable& page_table);
232 232
233 /// Handles flags related to mapping physical memory regions. 233 /// Handles flags related to mapping physical memory regions.
234 ResultCode HandleMapRegionFlags(u32 flags, KPageTable& page_table); 234 Result HandleMapRegionFlags(u32 flags, KPageTable& page_table);
235 235
236 /// Handles flags related to the interrupt capability flags. 236 /// Handles flags related to the interrupt capability flags.
237 ResultCode HandleInterruptFlags(u32 flags); 237 Result HandleInterruptFlags(u32 flags);
238 238
239 /// Handles flags related to the program type. 239 /// Handles flags related to the program type.
240 ResultCode HandleProgramTypeFlags(u32 flags); 240 Result HandleProgramTypeFlags(u32 flags);
241 241
242 /// Handles flags related to the handle table size. 242 /// Handles flags related to the handle table size.
243 ResultCode HandleHandleTableFlags(u32 flags); 243 Result HandleHandleTableFlags(u32 flags);
244 244
245 /// Handles flags related to the kernel version capability flags. 245 /// Handles flags related to the kernel version capability flags.
246 ResultCode HandleKernelVersionFlags(u32 flags); 246 Result HandleKernelVersionFlags(u32 flags);
247 247
248 /// Handles flags related to debug-specific capabilities. 248 /// Handles flags related to debug-specific capabilities.
249 ResultCode HandleDebugFlags(u32 flags); 249 Result HandleDebugFlags(u32 flags);
250 250
251 SyscallCapabilities svc_capabilities; 251 SyscallCapabilities svc_capabilities;
252 InterruptCapabilities interrupt_capabilities; 252 InterruptCapabilities interrupt_capabilities;
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 71ed17790..8655506b0 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -58,8 +58,8 @@ constexpr bool IsValidAddressRange(VAddr address, u64 size) {
58// Helper function that performs the common sanity checks for svcMapMemory 58// Helper function that performs the common sanity checks for svcMapMemory
59// and svcUnmapMemory. This is doable, as both functions perform their sanitizing 59// and svcUnmapMemory. This is doable, as both functions perform their sanitizing
60// in the same order. 60// in the same order.
61ResultCode MapUnmapMemorySanityChecks(const KPageTable& manager, VAddr dst_addr, VAddr src_addr, 61Result MapUnmapMemorySanityChecks(const KPageTable& manager, VAddr dst_addr, VAddr src_addr,
62 u64 size) { 62 u64 size) {
63 if (!Common::Is4KBAligned(dst_addr)) { 63 if (!Common::Is4KBAligned(dst_addr)) {
64 LOG_ERROR(Kernel_SVC, "Destination address is not aligned to 4KB, 0x{:016X}", dst_addr); 64 LOG_ERROR(Kernel_SVC, "Destination address is not aligned to 4KB, 0x{:016X}", dst_addr);
65 return ResultInvalidAddress; 65 return ResultInvalidAddress;
@@ -135,7 +135,7 @@ enum class ResourceLimitValueType {
135} // Anonymous namespace 135} // Anonymous namespace
136 136
137/// Set the process heap to a given Size. It can both extend and shrink the heap. 137/// Set the process heap to a given Size. It can both extend and shrink the heap.
138static ResultCode SetHeapSize(Core::System& system, VAddr* out_address, u64 size) { 138static Result SetHeapSize(Core::System& system, VAddr* out_address, u64 size) {
139 LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", size); 139 LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", size);
140 140
141 // Validate size. 141 // Validate size.
@@ -148,9 +148,9 @@ static ResultCode SetHeapSize(Core::System& system, VAddr* out_address, u64 size
148 return ResultSuccess; 148 return ResultSuccess;
149} 149}
150 150
151static ResultCode SetHeapSize32(Core::System& system, u32* heap_addr, u32 heap_size) { 151static Result SetHeapSize32(Core::System& system, u32* heap_addr, u32 heap_size) {
152 VAddr temp_heap_addr{}; 152 VAddr temp_heap_addr{};
153 const ResultCode result{SetHeapSize(system, &temp_heap_addr, heap_size)}; 153 const Result result{SetHeapSize(system, &temp_heap_addr, heap_size)};
154 *heap_addr = static_cast<u32>(temp_heap_addr); 154 *heap_addr = static_cast<u32>(temp_heap_addr);
155 return result; 155 return result;
156} 156}
@@ -166,8 +166,8 @@ constexpr bool IsValidSetMemoryPermission(MemoryPermission perm) {
166 } 166 }
167} 167}
168 168
169static ResultCode SetMemoryPermission(Core::System& system, VAddr address, u64 size, 169static Result SetMemoryPermission(Core::System& system, VAddr address, u64 size,
170 MemoryPermission perm) { 170 MemoryPermission perm) {
171 LOG_DEBUG(Kernel_SVC, "called, address=0x{:016X}, size=0x{:X}, perm=0x{:08X", address, size, 171 LOG_DEBUG(Kernel_SVC, "called, address=0x{:016X}, size=0x{:X}, perm=0x{:08X", address, size,
172 perm); 172 perm);
173 173
@@ -188,8 +188,8 @@ static ResultCode SetMemoryPermission(Core::System& system, VAddr address, u64 s
188 return page_table.SetMemoryPermission(address, size, perm); 188 return page_table.SetMemoryPermission(address, size, perm);
189} 189}
190 190
191static ResultCode SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask, 191static Result SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask,
192 u32 attr) { 192 u32 attr) {
193 LOG_DEBUG(Kernel_SVC, 193 LOG_DEBUG(Kernel_SVC,
194 "called, address=0x{:016X}, size=0x{:X}, mask=0x{:08X}, attribute=0x{:08X}", address, 194 "called, address=0x{:016X}, size=0x{:X}, mask=0x{:08X}, attribute=0x{:08X}", address,
195 size, mask, attr); 195 size, mask, attr);
@@ -213,19 +213,19 @@ static ResultCode SetMemoryAttribute(Core::System& system, VAddr address, u64 si
213 return page_table.SetMemoryAttribute(address, size, mask, attr); 213 return page_table.SetMemoryAttribute(address, size, mask, attr);
214} 214}
215 215
216static ResultCode SetMemoryAttribute32(Core::System& system, u32 address, u32 size, u32 mask, 216static Result SetMemoryAttribute32(Core::System& system, u32 address, u32 size, u32 mask,
217 u32 attr) { 217 u32 attr) {
218 return SetMemoryAttribute(system, address, size, mask, attr); 218 return SetMemoryAttribute(system, address, size, mask, attr);
219} 219}
220 220
221/// Maps a memory range into a different range. 221/// Maps a memory range into a different range.
222static ResultCode MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { 222static Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
223 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, 223 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
224 src_addr, size); 224 src_addr, size);
225 225
226 auto& page_table{system.Kernel().CurrentProcess()->PageTable()}; 226 auto& page_table{system.Kernel().CurrentProcess()->PageTable()};
227 227
228 if (const ResultCode result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)}; 228 if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)};
229 result.IsError()) { 229 result.IsError()) {
230 return result; 230 return result;
231 } 231 }
@@ -233,18 +233,18 @@ static ResultCode MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr
233 return page_table.MapMemory(dst_addr, src_addr, size); 233 return page_table.MapMemory(dst_addr, src_addr, size);
234} 234}
235 235
236static ResultCode MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { 236static Result MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) {
237 return MapMemory(system, dst_addr, src_addr, size); 237 return MapMemory(system, dst_addr, src_addr, size);
238} 238}
239 239
240/// Unmaps a region that was previously mapped with svcMapMemory 240/// Unmaps a region that was previously mapped with svcMapMemory
241static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { 241static Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
242 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, 242 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
243 src_addr, size); 243 src_addr, size);
244 244
245 auto& page_table{system.Kernel().CurrentProcess()->PageTable()}; 245 auto& page_table{system.Kernel().CurrentProcess()->PageTable()};
246 246
247 if (const ResultCode result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)}; 247 if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)};
248 result.IsError()) { 248 result.IsError()) {
249 return result; 249 return result;
250 } 250 }
@@ -252,12 +252,12 @@ static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_ad
252 return page_table.UnmapMemory(dst_addr, src_addr, size); 252 return page_table.UnmapMemory(dst_addr, src_addr, size);
253} 253}
254 254
255static ResultCode UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { 255static Result UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) {
256 return UnmapMemory(system, dst_addr, src_addr, size); 256 return UnmapMemory(system, dst_addr, src_addr, size);
257} 257}
258 258
259/// Connect to an OS service given the port name, returns the handle to the port to out 259/// Connect to an OS service given the port name, returns the handle to the port to out
260static ResultCode ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_address) { 260static Result ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_address) {
261 auto& memory = system.Memory(); 261 auto& memory = system.Memory();
262 if (!memory.IsValidVirtualAddress(port_name_address)) { 262 if (!memory.IsValidVirtualAddress(port_name_address)) {
263 LOG_ERROR(Kernel_SVC, 263 LOG_ERROR(Kernel_SVC,
@@ -307,14 +307,14 @@ static ResultCode ConnectToNamedPort(Core::System& system, Handle* out, VAddr po
307 return ResultSuccess; 307 return ResultSuccess;
308} 308}
309 309
310static ResultCode ConnectToNamedPort32(Core::System& system, Handle* out_handle, 310static Result ConnectToNamedPort32(Core::System& system, Handle* out_handle,
311 u32 port_name_address) { 311 u32 port_name_address) {
312 312
313 return ConnectToNamedPort(system, out_handle, port_name_address); 313 return ConnectToNamedPort(system, out_handle, port_name_address);
314} 314}
315 315
316/// Makes a blocking IPC call to an OS service. 316/// Makes a blocking IPC call to an OS service.
317static ResultCode SendSyncRequest(Core::System& system, Handle handle) { 317static Result SendSyncRequest(Core::System& system, Handle handle) {
318 auto& kernel = system.Kernel(); 318 auto& kernel = system.Kernel();
319 319
320 // Create the wait queue. 320 // Create the wait queue.
@@ -339,12 +339,12 @@ static ResultCode SendSyncRequest(Core::System& system, Handle handle) {
339 return GetCurrentThread(kernel).GetWaitResult(); 339 return GetCurrentThread(kernel).GetWaitResult();
340} 340}
341 341
342static ResultCode SendSyncRequest32(Core::System& system, Handle handle) { 342static Result SendSyncRequest32(Core::System& system, Handle handle) {
343 return SendSyncRequest(system, handle); 343 return SendSyncRequest(system, handle);
344} 344}
345 345
346/// Get the ID for the specified thread. 346/// Get the ID for the specified thread.
347static ResultCode GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) { 347static Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) {
348 // Get the thread from its handle. 348 // Get the thread from its handle.
349 KScopedAutoObject thread = 349 KScopedAutoObject thread =
350 system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle); 350 system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
@@ -355,10 +355,10 @@ static ResultCode GetThreadId(Core::System& system, u64* out_thread_id, Handle t
355 return ResultSuccess; 355 return ResultSuccess;
356} 356}
357 357
358static ResultCode GetThreadId32(Core::System& system, u32* out_thread_id_low, 358static Result GetThreadId32(Core::System& system, u32* out_thread_id_low, u32* out_thread_id_high,
359 u32* out_thread_id_high, Handle thread_handle) { 359 Handle thread_handle) {
360 u64 out_thread_id{}; 360 u64 out_thread_id{};
361 const ResultCode result{GetThreadId(system, &out_thread_id, thread_handle)}; 361 const Result result{GetThreadId(system, &out_thread_id, thread_handle)};
362 362
363 *out_thread_id_low = static_cast<u32>(out_thread_id >> 32); 363 *out_thread_id_low = static_cast<u32>(out_thread_id >> 32);
364 *out_thread_id_high = static_cast<u32>(out_thread_id & std::numeric_limits<u32>::max()); 364 *out_thread_id_high = static_cast<u32>(out_thread_id & std::numeric_limits<u32>::max());
@@ -367,7 +367,7 @@ static ResultCode GetThreadId32(Core::System& system, u32* out_thread_id_low,
367} 367}
368 368
369/// Gets the ID of the specified process or a specified thread's owning process. 369/// Gets the ID of the specified process or a specified thread's owning process.
370static ResultCode GetProcessId(Core::System& system, u64* out_process_id, Handle handle) { 370static Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) {
371 LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle); 371 LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle);
372 372
373 // Get the object from the handle table. 373 // Get the object from the handle table.
@@ -398,8 +398,8 @@ static ResultCode GetProcessId(Core::System& system, u64* out_process_id, Handle
398 return ResultSuccess; 398 return ResultSuccess;
399} 399}
400 400
401static ResultCode GetProcessId32(Core::System& system, u32* out_process_id_low, 401static Result GetProcessId32(Core::System& system, u32* out_process_id_low,
402 u32* out_process_id_high, Handle handle) { 402 u32* out_process_id_high, Handle handle) {
403 u64 out_process_id{}; 403 u64 out_process_id{};
404 const auto result = GetProcessId(system, &out_process_id, handle); 404 const auto result = GetProcessId(system, &out_process_id, handle);
405 *out_process_id_low = static_cast<u32>(out_process_id); 405 *out_process_id_low = static_cast<u32>(out_process_id);
@@ -408,8 +408,8 @@ static ResultCode GetProcessId32(Core::System& system, u32* out_process_id_low,
408} 408}
409 409
410/// Wait for the given handles to synchronize, timeout after the specified nanoseconds 410/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
411static ResultCode WaitSynchronization(Core::System& system, s32* index, VAddr handles_address, 411static Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_address,
412 s32 num_handles, s64 nano_seconds) { 412 s32 num_handles, s64 nano_seconds) {
413 LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, num_handles={}, nano_seconds={}", 413 LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, num_handles={}, nano_seconds={}",
414 handles_address, num_handles, nano_seconds); 414 handles_address, num_handles, nano_seconds);
415 415
@@ -444,14 +444,14 @@ static ResultCode WaitSynchronization(Core::System& system, s32* index, VAddr ha
444 nano_seconds); 444 nano_seconds);
445} 445}
446 446
447static ResultCode WaitSynchronization32(Core::System& system, u32 timeout_low, u32 handles_address, 447static Result WaitSynchronization32(Core::System& system, u32 timeout_low, u32 handles_address,
448 s32 num_handles, u32 timeout_high, s32* index) { 448 s32 num_handles, u32 timeout_high, s32* index) {
449 const s64 nano_seconds{(static_cast<s64>(timeout_high) << 32) | static_cast<s64>(timeout_low)}; 449 const s64 nano_seconds{(static_cast<s64>(timeout_high) << 32) | static_cast<s64>(timeout_low)};
450 return WaitSynchronization(system, index, handles_address, num_handles, nano_seconds); 450 return WaitSynchronization(system, index, handles_address, num_handles, nano_seconds);
451} 451}
452 452
453/// Resumes a thread waiting on WaitSynchronization 453/// Resumes a thread waiting on WaitSynchronization
454static ResultCode CancelSynchronization(Core::System& system, Handle handle) { 454static Result CancelSynchronization(Core::System& system, Handle handle) {
455 LOG_TRACE(Kernel_SVC, "called handle=0x{:X}", handle); 455 LOG_TRACE(Kernel_SVC, "called handle=0x{:X}", handle);
456 456
457 // Get the thread from its handle. 457 // Get the thread from its handle.
@@ -464,13 +464,12 @@ static ResultCode CancelSynchronization(Core::System& system, Handle handle) {
464 return ResultSuccess; 464 return ResultSuccess;
465} 465}
466 466
467static ResultCode CancelSynchronization32(Core::System& system, Handle handle) { 467static Result CancelSynchronization32(Core::System& system, Handle handle) {
468 return CancelSynchronization(system, handle); 468 return CancelSynchronization(system, handle);
469} 469}
470 470
471/// Attempts to locks a mutex 471/// Attempts to locks a mutex
472static ResultCode ArbitrateLock(Core::System& system, Handle thread_handle, VAddr address, 472static Result ArbitrateLock(Core::System& system, Handle thread_handle, VAddr address, u32 tag) {
473 u32 tag) {
474 LOG_TRACE(Kernel_SVC, "called thread_handle=0x{:08X}, address=0x{:X}, tag=0x{:08X}", 473 LOG_TRACE(Kernel_SVC, "called thread_handle=0x{:08X}, address=0x{:X}, tag=0x{:08X}",
475 thread_handle, address, tag); 474 thread_handle, address, tag);
476 475
@@ -488,13 +487,12 @@ static ResultCode ArbitrateLock(Core::System& system, Handle thread_handle, VAdd
488 return system.Kernel().CurrentProcess()->WaitForAddress(thread_handle, address, tag); 487 return system.Kernel().CurrentProcess()->WaitForAddress(thread_handle, address, tag);
489} 488}
490 489
491static ResultCode ArbitrateLock32(Core::System& system, Handle thread_handle, u32 address, 490static Result ArbitrateLock32(Core::System& system, Handle thread_handle, u32 address, u32 tag) {
492 u32 tag) {
493 return ArbitrateLock(system, thread_handle, address, tag); 491 return ArbitrateLock(system, thread_handle, address, tag);
494} 492}
495 493
496/// Unlock a mutex 494/// Unlock a mutex
497static ResultCode ArbitrateUnlock(Core::System& system, VAddr address) { 495static Result ArbitrateUnlock(Core::System& system, VAddr address) {
498 LOG_TRACE(Kernel_SVC, "called address=0x{:X}", address); 496 LOG_TRACE(Kernel_SVC, "called address=0x{:X}", address);
499 497
500 // Validate the input address. 498 // Validate the input address.
@@ -512,7 +510,7 @@ static ResultCode ArbitrateUnlock(Core::System& system, VAddr address) {
512 return system.Kernel().CurrentProcess()->SignalToAddress(address); 510 return system.Kernel().CurrentProcess()->SignalToAddress(address);
513} 511}
514 512
515static ResultCode ArbitrateUnlock32(Core::System& system, u32 address) { 513static Result ArbitrateUnlock32(Core::System& system, u32 address) {
516 return ArbitrateUnlock(system, address); 514 return ArbitrateUnlock(system, address);
517} 515}
518 516
@@ -655,8 +653,8 @@ static void OutputDebugString32(Core::System& system, u32 address, u32 len) {
655} 653}
656 654
657/// Gets system/memory information for the current process 655/// Gets system/memory information for the current process
658static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, 656static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle,
659 u64 info_sub_id) { 657 u64 info_sub_id) {
660 LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, 658 LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
661 info_sub_id, handle); 659 info_sub_id, handle);
662 660
@@ -943,12 +941,12 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle
943 } 941 }
944} 942}
945 943
946static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low, 944static Result GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low,
947 u32 info_id, u32 handle, u32 sub_id_high) { 945 u32 info_id, u32 handle, u32 sub_id_high) {
948 const u64 sub_id{u64{sub_id_low} | (u64{sub_id_high} << 32)}; 946 const u64 sub_id{u64{sub_id_low} | (u64{sub_id_high} << 32)};
949 u64 res_value{}; 947 u64 res_value{};
950 948
951 const ResultCode result{GetInfo(system, &res_value, info_id, handle, sub_id)}; 949 const Result result{GetInfo(system, &res_value, info_id, handle, sub_id)};
952 *result_high = static_cast<u32>(res_value >> 32); 950 *result_high = static_cast<u32>(res_value >> 32);
953 *result_low = static_cast<u32>(res_value & std::numeric_limits<u32>::max()); 951 *result_low = static_cast<u32>(res_value & std::numeric_limits<u32>::max());
954 952
@@ -956,7 +954,7 @@ static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_h
956} 954}
957 955
958/// Maps memory at a desired address 956/// Maps memory at a desired address
959static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { 957static Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
960 LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); 958 LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
961 959
962 if (!Common::Is4KBAligned(addr)) { 960 if (!Common::Is4KBAligned(addr)) {
@@ -1004,12 +1002,12 @@ static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size)
1004 return page_table.MapPhysicalMemory(addr, size); 1002 return page_table.MapPhysicalMemory(addr, size);
1005} 1003}
1006 1004
1007static ResultCode MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { 1005static Result MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) {
1008 return MapPhysicalMemory(system, addr, size); 1006 return MapPhysicalMemory(system, addr, size);
1009} 1007}
1010 1008
1011/// Unmaps memory previously mapped via MapPhysicalMemory 1009/// Unmaps memory previously mapped via MapPhysicalMemory
1012static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { 1010static Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
1013 LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); 1011 LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
1014 1012
1015 if (!Common::Is4KBAligned(addr)) { 1013 if (!Common::Is4KBAligned(addr)) {
@@ -1057,13 +1055,13 @@ static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size
1057 return page_table.UnmapPhysicalMemory(addr, size); 1055 return page_table.UnmapPhysicalMemory(addr, size);
1058} 1056}
1059 1057
1060static ResultCode UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { 1058static Result UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) {
1061 return UnmapPhysicalMemory(system, addr, size); 1059 return UnmapPhysicalMemory(system, addr, size);
1062} 1060}
1063 1061
1064/// Sets the thread activity 1062/// Sets the thread activity
1065static ResultCode SetThreadActivity(Core::System& system, Handle thread_handle, 1063static Result SetThreadActivity(Core::System& system, Handle thread_handle,
1066 ThreadActivity thread_activity) { 1064 ThreadActivity thread_activity) {
1067 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", thread_handle, 1065 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", thread_handle,
1068 thread_activity); 1066 thread_activity);
1069 1067
@@ -1088,13 +1086,13 @@ static ResultCode SetThreadActivity(Core::System& system, Handle thread_handle,
1088 return ResultSuccess; 1086 return ResultSuccess;
1089} 1087}
1090 1088
1091static ResultCode SetThreadActivity32(Core::System& system, Handle thread_handle, 1089static Result SetThreadActivity32(Core::System& system, Handle thread_handle,
1092 Svc::ThreadActivity thread_activity) { 1090 Svc::ThreadActivity thread_activity) {
1093 return SetThreadActivity(system, thread_handle, thread_activity); 1091 return SetThreadActivity(system, thread_handle, thread_activity);
1094} 1092}
1095 1093
1096/// Gets the thread context 1094/// Gets the thread context
1097static ResultCode GetThreadContext(Core::System& system, VAddr out_context, Handle thread_handle) { 1095static Result GetThreadContext(Core::System& system, VAddr out_context, Handle thread_handle) {
1098 LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context, 1096 LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context,
1099 thread_handle); 1097 thread_handle);
1100 1098
@@ -1151,12 +1149,12 @@ static ResultCode GetThreadContext(Core::System& system, VAddr out_context, Hand
1151 return ResultSuccess; 1149 return ResultSuccess;
1152} 1150}
1153 1151
1154static ResultCode GetThreadContext32(Core::System& system, u32 out_context, Handle thread_handle) { 1152static Result GetThreadContext32(Core::System& system, u32 out_context, Handle thread_handle) {
1155 return GetThreadContext(system, out_context, thread_handle); 1153 return GetThreadContext(system, out_context, thread_handle);
1156} 1154}
1157 1155
1158/// Gets the priority for the specified thread 1156/// Gets the priority for the specified thread
1159static ResultCode GetThreadPriority(Core::System& system, u32* out_priority, Handle handle) { 1157static Result GetThreadPriority(Core::System& system, u32* out_priority, Handle handle) {
1160 LOG_TRACE(Kernel_SVC, "called"); 1158 LOG_TRACE(Kernel_SVC, "called");
1161 1159
1162 // Get the thread from its handle. 1160 // Get the thread from its handle.
@@ -1169,12 +1167,12 @@ static ResultCode GetThreadPriority(Core::System& system, u32* out_priority, Han
1169 return ResultSuccess; 1167 return ResultSuccess;
1170} 1168}
1171 1169
1172static ResultCode GetThreadPriority32(Core::System& system, u32* out_priority, Handle handle) { 1170static Result GetThreadPriority32(Core::System& system, u32* out_priority, Handle handle) {
1173 return GetThreadPriority(system, out_priority, handle); 1171 return GetThreadPriority(system, out_priority, handle);
1174} 1172}
1175 1173
1176/// Sets the priority for the specified thread 1174/// Sets the priority for the specified thread
1177static ResultCode SetThreadPriority(Core::System& system, Handle thread_handle, u32 priority) { 1175static Result SetThreadPriority(Core::System& system, Handle thread_handle, u32 priority) {
1178 // Get the current process. 1176 // Get the current process.
1179 KProcess& process = *system.Kernel().CurrentProcess(); 1177 KProcess& process = *system.Kernel().CurrentProcess();
1180 1178
@@ -1192,7 +1190,7 @@ static ResultCode SetThreadPriority(Core::System& system, Handle thread_handle,
1192 return ResultSuccess; 1190 return ResultSuccess;
1193} 1191}
1194 1192
1195static ResultCode SetThreadPriority32(Core::System& system, Handle thread_handle, u32 priority) { 1193static Result SetThreadPriority32(Core::System& system, Handle thread_handle, u32 priority) {
1196 return SetThreadPriority(system, thread_handle, priority); 1194 return SetThreadPriority(system, thread_handle, priority);
1197} 1195}
1198 1196
@@ -1252,8 +1250,8 @@ constexpr bool IsValidUnmapFromOwnerCodeMemoryPermission(Svc::MemoryPermission p
1252 1250
1253} // Anonymous namespace 1251} // Anonymous namespace
1254 1252
1255static ResultCode MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, 1253static Result MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, u64 size,
1256 u64 size, Svc::MemoryPermission map_perm) { 1254 Svc::MemoryPermission map_perm) {
1257 LOG_TRACE(Kernel_SVC, 1255 LOG_TRACE(Kernel_SVC,
1258 "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", 1256 "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}",
1259 shmem_handle, address, size, map_perm); 1257 shmem_handle, address, size, map_perm);
@@ -1293,13 +1291,13 @@ static ResultCode MapSharedMemory(Core::System& system, Handle shmem_handle, VAd
1293 return ResultSuccess; 1291 return ResultSuccess;
1294} 1292}
1295 1293
1296static ResultCode MapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, 1294static Result MapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, u32 size,
1297 u32 size, Svc::MemoryPermission map_perm) { 1295 Svc::MemoryPermission map_perm) {
1298 return MapSharedMemory(system, shmem_handle, address, size, map_perm); 1296 return MapSharedMemory(system, shmem_handle, address, size, map_perm);
1299} 1297}
1300 1298
1301static ResultCode UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, 1299static Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address,
1302 u64 size) { 1300 u64 size) {
1303 // Validate the address/size. 1301 // Validate the address/size.
1304 R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress); 1302 R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress);
1305 R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize); 1303 R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize);
@@ -1326,13 +1324,13 @@ static ResultCode UnmapSharedMemory(Core::System& system, Handle shmem_handle, V
1326 return ResultSuccess; 1324 return ResultSuccess;
1327} 1325}
1328 1326
1329static ResultCode UnmapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, 1327static Result UnmapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address,
1330 u32 size) { 1328 u32 size) {
1331 return UnmapSharedMemory(system, shmem_handle, address, size); 1329 return UnmapSharedMemory(system, shmem_handle, address, size);
1332} 1330}
1333 1331
1334static ResultCode SetProcessMemoryPermission(Core::System& system, Handle process_handle, 1332static Result SetProcessMemoryPermission(Core::System& system, Handle process_handle, VAddr address,
1335 VAddr address, u64 size, Svc::MemoryPermission perm) { 1333 u64 size, Svc::MemoryPermission perm) {
1336 LOG_TRACE(Kernel_SVC, 1334 LOG_TRACE(Kernel_SVC,
1337 "called, process_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", 1335 "called, process_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}",
1338 process_handle, address, size, perm); 1336 process_handle, address, size, perm);
@@ -1361,8 +1359,8 @@ static ResultCode SetProcessMemoryPermission(Core::System& system, Handle proces
1361 return page_table.SetProcessMemoryPermission(address, size, perm); 1359 return page_table.SetProcessMemoryPermission(address, size, perm);
1362} 1360}
1363 1361
1364static ResultCode MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, 1362static Result MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle,
1365 VAddr src_address, u64 size) { 1363 VAddr src_address, u64 size) {
1366 LOG_TRACE(Kernel_SVC, 1364 LOG_TRACE(Kernel_SVC,
1367 "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}", 1365 "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}",
1368 dst_address, process_handle, src_address, size); 1366 dst_address, process_handle, src_address, size);
@@ -1391,7 +1389,7 @@ static ResultCode MapProcessMemory(Core::System& system, VAddr dst_address, Hand
1391 ResultInvalidMemoryRegion); 1389 ResultInvalidMemoryRegion);
1392 1390
1393 // Create a new page group. 1391 // Create a new page group.
1394 KPageLinkedList pg; 1392 KPageGroup pg;
1395 R_TRY(src_pt.MakeAndOpenPageGroup( 1393 R_TRY(src_pt.MakeAndOpenPageGroup(
1396 std::addressof(pg), src_address, size / PageSize, KMemoryState::FlagCanMapProcess, 1394 std::addressof(pg), src_address, size / PageSize, KMemoryState::FlagCanMapProcess,
1397 KMemoryState::FlagCanMapProcess, KMemoryPermission::None, KMemoryPermission::None, 1395 KMemoryState::FlagCanMapProcess, KMemoryPermission::None, KMemoryPermission::None,
@@ -1404,8 +1402,8 @@ static ResultCode MapProcessMemory(Core::System& system, VAddr dst_address, Hand
1404 return ResultSuccess; 1402 return ResultSuccess;
1405} 1403}
1406 1404
1407static ResultCode UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, 1405static Result UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle,
1408 VAddr src_address, u64 size) { 1406 VAddr src_address, u64 size) {
1409 LOG_TRACE(Kernel_SVC, 1407 LOG_TRACE(Kernel_SVC,
1410 "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}", 1408 "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}",
1411 dst_address, process_handle, src_address, size); 1409 dst_address, process_handle, src_address, size);
@@ -1439,7 +1437,7 @@ static ResultCode UnmapProcessMemory(Core::System& system, VAddr dst_address, Ha
1439 return ResultSuccess; 1437 return ResultSuccess;
1440} 1438}
1441 1439
1442static ResultCode CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t size) { 1440static Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t size) {
1443 LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, size=0x{:X}", address, size); 1441 LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, size=0x{:X}", address, size);
1444 1442
1445 // Get kernel instance. 1443 // Get kernel instance.
@@ -1474,12 +1472,12 @@ static ResultCode CreateCodeMemory(Core::System& system, Handle* out, VAddr addr
1474 return ResultSuccess; 1472 return ResultSuccess;
1475} 1473}
1476 1474
1477static ResultCode CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size) { 1475static Result CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size) {
1478 return CreateCodeMemory(system, out, address, size); 1476 return CreateCodeMemory(system, out, address, size);
1479} 1477}
1480 1478
1481static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation, 1479static Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation,
1482 VAddr address, size_t size, Svc::MemoryPermission perm) { 1480 VAddr address, size_t size, Svc::MemoryPermission perm) {
1483 1481
1484 LOG_TRACE(Kernel_SVC, 1482 LOG_TRACE(Kernel_SVC,
1485 "called, code_memory_handle=0x{:X}, operation=0x{:X}, address=0x{:X}, size=0x{:X}, " 1483 "called, code_memory_handle=0x{:X}, operation=0x{:X}, address=0x{:X}, size=0x{:X}, "
@@ -1557,15 +1555,13 @@ static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_han
1557 return ResultSuccess; 1555 return ResultSuccess;
1558} 1556}
1559 1557
1560static ResultCode ControlCodeMemory32(Core::System& system, Handle code_memory_handle, 1558static Result ControlCodeMemory32(Core::System& system, Handle code_memory_handle, u32 operation,
1561 u32 operation, u64 address, u64 size, 1559 u64 address, u64 size, Svc::MemoryPermission perm) {
1562 Svc::MemoryPermission perm) {
1563 return ControlCodeMemory(system, code_memory_handle, operation, address, size, perm); 1560 return ControlCodeMemory(system, code_memory_handle, operation, address, size, perm);
1564} 1561}
1565 1562
1566static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address, 1563static Result QueryProcessMemory(Core::System& system, VAddr memory_info_address,
1567 VAddr page_info_address, Handle process_handle, 1564 VAddr page_info_address, Handle process_handle, VAddr address) {
1568 VAddr address) {
1569 LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); 1565 LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address);
1570 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 1566 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
1571 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); 1567 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
@@ -1593,8 +1589,8 @@ static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_add
1593 return ResultSuccess; 1589 return ResultSuccess;
1594} 1590}
1595 1591
1596static ResultCode QueryMemory(Core::System& system, VAddr memory_info_address, 1592static Result QueryMemory(Core::System& system, VAddr memory_info_address, VAddr page_info_address,
1597 VAddr page_info_address, VAddr query_address) { 1593 VAddr query_address) {
1598 LOG_TRACE(Kernel_SVC, 1594 LOG_TRACE(Kernel_SVC,
1599 "called, memory_info_address=0x{:016X}, page_info_address=0x{:016X}, " 1595 "called, memory_info_address=0x{:016X}, page_info_address=0x{:016X}, "
1600 "query_address=0x{:016X}", 1596 "query_address=0x{:016X}",
@@ -1604,13 +1600,13 @@ static ResultCode QueryMemory(Core::System& system, VAddr memory_info_address,
1604 query_address); 1600 query_address);
1605} 1601}
1606 1602
1607static ResultCode QueryMemory32(Core::System& system, u32 memory_info_address, 1603static Result QueryMemory32(Core::System& system, u32 memory_info_address, u32 page_info_address,
1608 u32 page_info_address, u32 query_address) { 1604 u32 query_address) {
1609 return QueryMemory(system, memory_info_address, page_info_address, query_address); 1605 return QueryMemory(system, memory_info_address, page_info_address, query_address);
1610} 1606}
1611 1607
1612static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, 1608static Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address,
1613 u64 src_address, u64 size) { 1609 u64 src_address, u64 size) {
1614 LOG_DEBUG(Kernel_SVC, 1610 LOG_DEBUG(Kernel_SVC,
1615 "called. process_handle=0x{:08X}, dst_address=0x{:016X}, " 1611 "called. process_handle=0x{:08X}, dst_address=0x{:016X}, "
1616 "src_address=0x{:016X}, size=0x{:016X}", 1612 "src_address=0x{:016X}, size=0x{:016X}",
@@ -1677,8 +1673,8 @@ static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_hand
1677 return page_table.MapCodeMemory(dst_address, src_address, size); 1673 return page_table.MapCodeMemory(dst_address, src_address, size);
1678} 1674}
1679 1675
1680static ResultCode UnmapProcessCodeMemory(Core::System& system, Handle process_handle, 1676static Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address,
1681 u64 dst_address, u64 src_address, u64 size) { 1677 u64 src_address, u64 size) {
1682 LOG_DEBUG(Kernel_SVC, 1678 LOG_DEBUG(Kernel_SVC,
1683 "called. process_handle=0x{:08X}, dst_address=0x{:016X}, src_address=0x{:016X}, " 1679 "called. process_handle=0x{:08X}, dst_address=0x{:016X}, src_address=0x{:016X}, "
1684 "size=0x{:016X}", 1680 "size=0x{:016X}",
@@ -1770,8 +1766,8 @@ constexpr bool IsValidVirtualCoreId(int32_t core_id) {
1770} // Anonymous namespace 1766} // Anonymous namespace
1771 1767
1772/// Creates a new thread 1768/// Creates a new thread
1773static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg, 1769static Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg,
1774 VAddr stack_bottom, u32 priority, s32 core_id) { 1770 VAddr stack_bottom, u32 priority, s32 core_id) {
1775 LOG_DEBUG(Kernel_SVC, 1771 LOG_DEBUG(Kernel_SVC,
1776 "called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, " 1772 "called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, "
1777 "priority=0x{:08X}, core_id=0x{:08X}", 1773 "priority=0x{:08X}, core_id=0x{:08X}",
@@ -1842,13 +1838,13 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e
1842 return ResultSuccess; 1838 return ResultSuccess;
1843} 1839}
1844 1840
1845static ResultCode CreateThread32(Core::System& system, Handle* out_handle, u32 priority, 1841static Result CreateThread32(Core::System& system, Handle* out_handle, u32 priority,
1846 u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) { 1842 u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) {
1847 return CreateThread(system, out_handle, entry_point, arg, stack_top, priority, processor_id); 1843 return CreateThread(system, out_handle, entry_point, arg, stack_top, priority, processor_id);
1848} 1844}
1849 1845
1850/// Starts the thread for the provided handle 1846/// Starts the thread for the provided handle
1851static ResultCode StartThread(Core::System& system, Handle thread_handle) { 1847static Result StartThread(Core::System& system, Handle thread_handle) {
1852 LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); 1848 LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle);
1853 1849
1854 // Get the thread from its handle. 1850 // Get the thread from its handle.
@@ -1866,7 +1862,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) {
1866 return ResultSuccess; 1862 return ResultSuccess;
1867} 1863}
1868 1864
1869static ResultCode StartThread32(Core::System& system, Handle thread_handle) { 1865static Result StartThread32(Core::System& system, Handle thread_handle) {
1870 return StartThread(system, thread_handle); 1866 return StartThread(system, thread_handle);
1871} 1867}
1872 1868
@@ -1917,8 +1913,8 @@ static void SleepThread32(Core::System& system, u32 nanoseconds_low, u32 nanosec
1917} 1913}
1918 1914
1919/// Wait process wide key atomic 1915/// Wait process wide key atomic
1920static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_key, 1916static Result WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_key, u32 tag,
1921 u32 tag, s64 timeout_ns) { 1917 s64 timeout_ns) {
1922 LOG_TRACE(Kernel_SVC, "called address={:X}, cv_key={:X}, tag=0x{:08X}, timeout_ns={}", address, 1918 LOG_TRACE(Kernel_SVC, "called address={:X}, cv_key={:X}, tag=0x{:08X}, timeout_ns={}", address,
1923 cv_key, tag, timeout_ns); 1919 cv_key, tag, timeout_ns);
1924 1920
@@ -1953,8 +1949,8 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr address,
1953 address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout); 1949 address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout);
1954} 1950}
1955 1951
1956static ResultCode WaitProcessWideKeyAtomic32(Core::System& system, u32 address, u32 cv_key, u32 tag, 1952static Result WaitProcessWideKeyAtomic32(Core::System& system, u32 address, u32 cv_key, u32 tag,
1957 u32 timeout_ns_low, u32 timeout_ns_high) { 1953 u32 timeout_ns_low, u32 timeout_ns_high) {
1958 const auto timeout_ns = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); 1954 const auto timeout_ns = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32));
1959 return WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns); 1955 return WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns);
1960} 1956}
@@ -1999,8 +1995,8 @@ constexpr bool IsValidArbitrationType(Svc::ArbitrationType type) {
1999} // namespace 1995} // namespace
2000 1996
2001// Wait for an address (via Address Arbiter) 1997// Wait for an address (via Address Arbiter)
2002static ResultCode WaitForAddress(Core::System& system, VAddr address, Svc::ArbitrationType arb_type, 1998static Result WaitForAddress(Core::System& system, VAddr address, Svc::ArbitrationType arb_type,
2003 s32 value, s64 timeout_ns) { 1999 s32 value, s64 timeout_ns) {
2004 LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, arb_type=0x{:X}, value=0x{:X}, timeout_ns={}", 2000 LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, arb_type=0x{:X}, value=0x{:X}, timeout_ns={}",
2005 address, arb_type, value, timeout_ns); 2001 address, arb_type, value, timeout_ns);
2006 2002
@@ -2037,15 +2033,15 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, Svc::Arbit
2037 return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout); 2033 return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout);
2038} 2034}
2039 2035
2040static ResultCode WaitForAddress32(Core::System& system, u32 address, Svc::ArbitrationType arb_type, 2036static Result WaitForAddress32(Core::System& system, u32 address, Svc::ArbitrationType arb_type,
2041 s32 value, u32 timeout_ns_low, u32 timeout_ns_high) { 2037 s32 value, u32 timeout_ns_low, u32 timeout_ns_high) {
2042 const auto timeout = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); 2038 const auto timeout = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32));
2043 return WaitForAddress(system, address, arb_type, value, timeout); 2039 return WaitForAddress(system, address, arb_type, value, timeout);
2044} 2040}
2045 2041
2046// Signals to an address (via Address Arbiter) 2042// Signals to an address (via Address Arbiter)
2047static ResultCode SignalToAddress(Core::System& system, VAddr address, Svc::SignalType signal_type, 2043static Result SignalToAddress(Core::System& system, VAddr address, Svc::SignalType signal_type,
2048 s32 value, s32 count) { 2044 s32 value, s32 count) {
2049 LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, signal_type=0x{:X}, value=0x{:X}, count=0x{:X}", 2045 LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, signal_type=0x{:X}, value=0x{:X}, count=0x{:X}",
2050 address, signal_type, value, count); 2046 address, signal_type, value, count);
2051 2047
@@ -2086,8 +2082,8 @@ static void SynchronizePreemptionState(Core::System& system) {
2086 } 2082 }
2087} 2083}
2088 2084
2089static ResultCode SignalToAddress32(Core::System& system, u32 address, Svc::SignalType signal_type, 2085static Result SignalToAddress32(Core::System& system, u32 address, Svc::SignalType signal_type,
2090 s32 value, s32 count) { 2086 s32 value, s32 count) {
2091 return SignalToAddress(system, address, signal_type, value, count); 2087 return SignalToAddress(system, address, signal_type, value, count);
2092} 2088}
2093 2089
@@ -2125,7 +2121,7 @@ static void GetSystemTick32(Core::System& system, u32* time_low, u32* time_high)
2125} 2121}
2126 2122
2127/// Close a handle 2123/// Close a handle
2128static ResultCode CloseHandle(Core::System& system, Handle handle) { 2124static Result CloseHandle(Core::System& system, Handle handle) {
2129 LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle); 2125 LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle);
2130 2126
2131 // Remove the handle. 2127 // Remove the handle.
@@ -2135,12 +2131,12 @@ static ResultCode CloseHandle(Core::System& system, Handle handle) {
2135 return ResultSuccess; 2131 return ResultSuccess;
2136} 2132}
2137 2133
2138static ResultCode CloseHandle32(Core::System& system, Handle handle) { 2134static Result CloseHandle32(Core::System& system, Handle handle) {
2139 return CloseHandle(system, handle); 2135 return CloseHandle(system, handle);
2140} 2136}
2141 2137
2142/// Clears the signaled state of an event or process. 2138/// Clears the signaled state of an event or process.
2143static ResultCode ResetSignal(Core::System& system, Handle handle) { 2139static Result ResetSignal(Core::System& system, Handle handle) {
2144 LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); 2140 LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle);
2145 2141
2146 // Get the current handle table. 2142 // Get the current handle table.
@@ -2167,7 +2163,7 @@ static ResultCode ResetSignal(Core::System& system, Handle handle) {
2167 return ResultInvalidHandle; 2163 return ResultInvalidHandle;
2168} 2164}
2169 2165
2170static ResultCode ResetSignal32(Core::System& system, Handle handle) { 2166static Result ResetSignal32(Core::System& system, Handle handle) {
2171 return ResetSignal(system, handle); 2167 return ResetSignal(system, handle);
2172} 2168}
2173 2169
@@ -2187,8 +2183,8 @@ constexpr bool IsValidTransferMemoryPermission(MemoryPermission perm) {
2187} // Anonymous namespace 2183} // Anonymous namespace
2188 2184
2189/// Creates a TransferMemory object 2185/// Creates a TransferMemory object
2190static ResultCode CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u64 size, 2186static Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u64 size,
2191 MemoryPermission map_perm) { 2187 MemoryPermission map_perm) {
2192 auto& kernel = system.Kernel(); 2188 auto& kernel = system.Kernel();
2193 2189
2194 // Validate the size. 2190 // Validate the size.
@@ -2234,13 +2230,13 @@ static ResultCode CreateTransferMemory(Core::System& system, Handle* out, VAddr
2234 return ResultSuccess; 2230 return ResultSuccess;
2235} 2231}
2236 2232
2237static ResultCode CreateTransferMemory32(Core::System& system, Handle* out, u32 address, u32 size, 2233static Result CreateTransferMemory32(Core::System& system, Handle* out, u32 address, u32 size,
2238 MemoryPermission map_perm) { 2234 MemoryPermission map_perm) {
2239 return CreateTransferMemory(system, out, address, size, map_perm); 2235 return CreateTransferMemory(system, out, address, size, map_perm);
2240} 2236}
2241 2237
2242static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_core_id, 2238static Result GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_core_id,
2243 u64* out_affinity_mask) { 2239 u64* out_affinity_mask) {
2244 LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); 2240 LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle);
2245 2241
2246 // Get the thread from its handle. 2242 // Get the thread from its handle.
@@ -2254,8 +2250,8 @@ static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle,
2254 return ResultSuccess; 2250 return ResultSuccess;
2255} 2251}
2256 2252
2257static ResultCode GetThreadCoreMask32(Core::System& system, Handle thread_handle, s32* out_core_id, 2253static Result GetThreadCoreMask32(Core::System& system, Handle thread_handle, s32* out_core_id,
2258 u32* out_affinity_mask_low, u32* out_affinity_mask_high) { 2254 u32* out_affinity_mask_low, u32* out_affinity_mask_high) {
2259 u64 out_affinity_mask{}; 2255 u64 out_affinity_mask{};
2260 const auto result = GetThreadCoreMask(system, thread_handle, out_core_id, &out_affinity_mask); 2256 const auto result = GetThreadCoreMask(system, thread_handle, out_core_id, &out_affinity_mask);
2261 *out_affinity_mask_high = static_cast<u32>(out_affinity_mask >> 32); 2257 *out_affinity_mask_high = static_cast<u32>(out_affinity_mask >> 32);
@@ -2263,8 +2259,8 @@ static ResultCode GetThreadCoreMask32(Core::System& system, Handle thread_handle
2263 return result; 2259 return result;
2264} 2260}
2265 2261
2266static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id, 2262static Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id,
2267 u64 affinity_mask) { 2263 u64 affinity_mask) {
2268 // Determine the core id/affinity mask. 2264 // Determine the core id/affinity mask.
2269 if (core_id == IdealCoreUseProcessValue) { 2265 if (core_id == IdealCoreUseProcessValue) {
2270 core_id = system.Kernel().CurrentProcess()->GetIdealCoreId(); 2266 core_id = system.Kernel().CurrentProcess()->GetIdealCoreId();
@@ -2295,13 +2291,13 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle,
2295 return ResultSuccess; 2291 return ResultSuccess;
2296} 2292}
2297 2293
2298static ResultCode SetThreadCoreMask32(Core::System& system, Handle thread_handle, s32 core_id, 2294static Result SetThreadCoreMask32(Core::System& system, Handle thread_handle, s32 core_id,
2299 u32 affinity_mask_low, u32 affinity_mask_high) { 2295 u32 affinity_mask_low, u32 affinity_mask_high) {
2300 const auto affinity_mask = u64{affinity_mask_low} | (u64{affinity_mask_high} << 32); 2296 const auto affinity_mask = u64{affinity_mask_low} | (u64{affinity_mask_high} << 32);
2301 return SetThreadCoreMask(system, thread_handle, core_id, affinity_mask); 2297 return SetThreadCoreMask(system, thread_handle, core_id, affinity_mask);
2302} 2298}
2303 2299
2304static ResultCode SignalEvent(Core::System& system, Handle event_handle) { 2300static Result SignalEvent(Core::System& system, Handle event_handle) {
2305 LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); 2301 LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
2306 2302
2307 // Get the current handle table. 2303 // Get the current handle table.
@@ -2314,11 +2310,11 @@ static ResultCode SignalEvent(Core::System& system, Handle event_handle) {
2314 return writable_event->Signal(); 2310 return writable_event->Signal();
2315} 2311}
2316 2312
2317static ResultCode SignalEvent32(Core::System& system, Handle event_handle) { 2313static Result SignalEvent32(Core::System& system, Handle event_handle) {
2318 return SignalEvent(system, event_handle); 2314 return SignalEvent(system, event_handle);
2319} 2315}
2320 2316
2321static ResultCode ClearEvent(Core::System& system, Handle event_handle) { 2317static Result ClearEvent(Core::System& system, Handle event_handle) {
2322 LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); 2318 LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
2323 2319
2324 // Get the current handle table. 2320 // Get the current handle table.
@@ -2345,11 +2341,11 @@ static ResultCode ClearEvent(Core::System& system, Handle event_handle) {
2345 return ResultInvalidHandle; 2341 return ResultInvalidHandle;
2346} 2342}
2347 2343
2348static ResultCode ClearEvent32(Core::System& system, Handle event_handle) { 2344static Result ClearEvent32(Core::System& system, Handle event_handle) {
2349 return ClearEvent(system, event_handle); 2345 return ClearEvent(system, event_handle);
2350} 2346}
2351 2347
2352static ResultCode CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { 2348static Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) {
2353 LOG_DEBUG(Kernel_SVC, "called"); 2349 LOG_DEBUG(Kernel_SVC, "called");
2354 2350
2355 // Get the kernel reference and handle table. 2351 // Get the kernel reference and handle table.
@@ -2394,11 +2390,11 @@ static ResultCode CreateEvent(Core::System& system, Handle* out_write, Handle* o
2394 return ResultSuccess; 2390 return ResultSuccess;
2395} 2391}
2396 2392
2397static ResultCode CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read) { 2393static Result CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read) {
2398 return CreateEvent(system, out_write, out_read); 2394 return CreateEvent(system, out_write, out_read);
2399} 2395}
2400 2396
2401static ResultCode GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type) { 2397static Result GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type) {
2402 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type); 2398 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type);
2403 2399
2404 // This function currently only allows retrieving a process' status. 2400 // This function currently only allows retrieving a process' status.
@@ -2424,7 +2420,7 @@ static ResultCode GetProcessInfo(Core::System& system, u64* out, Handle process_
2424 return ResultSuccess; 2420 return ResultSuccess;
2425} 2421}
2426 2422
2427static ResultCode CreateResourceLimit(Core::System& system, Handle* out_handle) { 2423static Result CreateResourceLimit(Core::System& system, Handle* out_handle) {
2428 LOG_DEBUG(Kernel_SVC, "called"); 2424 LOG_DEBUG(Kernel_SVC, "called");
2429 2425
2430 // Create a new resource limit. 2426 // Create a new resource limit.
@@ -2447,9 +2443,8 @@ static ResultCode CreateResourceLimit(Core::System& system, Handle* out_handle)
2447 return ResultSuccess; 2443 return ResultSuccess;
2448} 2444}
2449 2445
2450static ResultCode GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value, 2446static Result GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value,
2451 Handle resource_limit_handle, 2447 Handle resource_limit_handle, LimitableResource which) {
2452 LimitableResource which) {
2453 LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, 2448 LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle,
2454 which); 2449 which);
2455 2450
@@ -2468,9 +2463,8 @@ static ResultCode GetResourceLimitLimitValue(Core::System& system, u64* out_limi
2468 return ResultSuccess; 2463 return ResultSuccess;
2469} 2464}
2470 2465
2471static ResultCode GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value, 2466static Result GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value,
2472 Handle resource_limit_handle, 2467 Handle resource_limit_handle, LimitableResource which) {
2473 LimitableResource which) {
2474 LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, 2468 LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle,
2475 which); 2469 which);
2476 2470
@@ -2489,8 +2483,8 @@ static ResultCode GetResourceLimitCurrentValue(Core::System& system, u64* out_cu
2489 return ResultSuccess; 2483 return ResultSuccess;
2490} 2484}
2491 2485
2492static ResultCode SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle, 2486static Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle,
2493 LimitableResource which, u64 limit_value) { 2487 LimitableResource which, u64 limit_value) {
2494 LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}", 2488 LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}",
2495 resource_limit_handle, which, limit_value); 2489 resource_limit_handle, which, limit_value);
2496 2490
@@ -2509,8 +2503,8 @@ static ResultCode SetResourceLimitLimitValue(Core::System& system, Handle resour
2509 return ResultSuccess; 2503 return ResultSuccess;
2510} 2504}
2511 2505
2512static ResultCode GetProcessList(Core::System& system, u32* out_num_processes, 2506static Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_process_ids,
2513 VAddr out_process_ids, u32 out_process_ids_size) { 2507 u32 out_process_ids_size) {
2514 LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}", 2508 LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}",
2515 out_process_ids, out_process_ids_size); 2509 out_process_ids, out_process_ids_size);
2516 2510
@@ -2546,8 +2540,8 @@ static ResultCode GetProcessList(Core::System& system, u32* out_num_processes,
2546 return ResultSuccess; 2540 return ResultSuccess;
2547} 2541}
2548 2542
2549static ResultCode GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_thread_ids, 2543static Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_thread_ids,
2550 u32 out_thread_ids_size, Handle debug_handle) { 2544 u32 out_thread_ids_size, Handle debug_handle) {
2551 // TODO: Handle this case when debug events are supported. 2545 // TODO: Handle this case when debug events are supported.
2552 UNIMPLEMENTED_IF(debug_handle != InvalidHandle); 2546 UNIMPLEMENTED_IF(debug_handle != InvalidHandle);
2553 2547
@@ -2586,9 +2580,9 @@ static ResultCode GetThreadList(Core::System& system, u32* out_num_threads, VAdd
2586 return ResultSuccess; 2580 return ResultSuccess;
2587} 2581}
2588 2582
2589static ResultCode FlushProcessDataCache32([[maybe_unused]] Core::System& system, 2583static Result FlushProcessDataCache32([[maybe_unused]] Core::System& system,
2590 [[maybe_unused]] Handle handle, 2584 [[maybe_unused]] Handle handle, [[maybe_unused]] u32 address,
2591 [[maybe_unused]] u32 address, [[maybe_unused]] u32 size) { 2585 [[maybe_unused]] u32 size) {
2592 // Note(Blinkhawk): For emulation purposes of the data cache this is mostly a no-op, 2586 // Note(Blinkhawk): For emulation purposes of the data cache this is mostly a no-op,
2593 // as all emulation is done in the same cache level in host architecture, thus data cache 2587 // as all emulation is done in the same cache level in host architecture, thus data cache
2594 // does not need flushing. 2588 // does not need flushing.
diff --git a/src/core/hle/kernel/svc_results.h b/src/core/hle/kernel/svc_results.h
index fab12d070..f27cade33 100644
--- a/src/core/hle/kernel/svc_results.h
+++ b/src/core/hle/kernel/svc_results.h
@@ -9,34 +9,34 @@ namespace Kernel {
9 9
10// Confirmed Switch kernel error codes 10// Confirmed Switch kernel error codes
11 11
12constexpr ResultCode ResultOutOfSessions{ErrorModule::Kernel, 7}; 12constexpr Result ResultOutOfSessions{ErrorModule::Kernel, 7};
13constexpr ResultCode ResultInvalidArgument{ErrorModule::Kernel, 14}; 13constexpr Result ResultInvalidArgument{ErrorModule::Kernel, 14};
14constexpr ResultCode ResultNoSynchronizationObject{ErrorModule::Kernel, 57}; 14constexpr Result ResultNoSynchronizationObject{ErrorModule::Kernel, 57};
15constexpr ResultCode ResultTerminationRequested{ErrorModule::Kernel, 59}; 15constexpr Result ResultTerminationRequested{ErrorModule::Kernel, 59};
16constexpr ResultCode ResultInvalidSize{ErrorModule::Kernel, 101}; 16constexpr Result ResultInvalidSize{ErrorModule::Kernel, 101};
17constexpr ResultCode ResultInvalidAddress{ErrorModule::Kernel, 102}; 17constexpr Result ResultInvalidAddress{ErrorModule::Kernel, 102};
18constexpr ResultCode ResultOutOfResource{ErrorModule::Kernel, 103}; 18constexpr Result ResultOutOfResource{ErrorModule::Kernel, 103};
19constexpr ResultCode ResultOutOfMemory{ErrorModule::Kernel, 104}; 19constexpr Result ResultOutOfMemory{ErrorModule::Kernel, 104};
20constexpr ResultCode ResultOutOfHandles{ErrorModule::Kernel, 105}; 20constexpr Result ResultOutOfHandles{ErrorModule::Kernel, 105};
21constexpr ResultCode ResultInvalidCurrentMemory{ErrorModule::Kernel, 106}; 21constexpr Result ResultInvalidCurrentMemory{ErrorModule::Kernel, 106};
22constexpr ResultCode ResultInvalidNewMemoryPermission{ErrorModule::Kernel, 108}; 22constexpr Result ResultInvalidNewMemoryPermission{ErrorModule::Kernel, 108};
23constexpr ResultCode ResultInvalidMemoryRegion{ErrorModule::Kernel, 110}; 23constexpr Result ResultInvalidMemoryRegion{ErrorModule::Kernel, 110};
24constexpr ResultCode ResultInvalidPriority{ErrorModule::Kernel, 112}; 24constexpr Result ResultInvalidPriority{ErrorModule::Kernel, 112};
25constexpr ResultCode ResultInvalidCoreId{ErrorModule::Kernel, 113}; 25constexpr Result ResultInvalidCoreId{ErrorModule::Kernel, 113};
26constexpr ResultCode ResultInvalidHandle{ErrorModule::Kernel, 114}; 26constexpr Result ResultInvalidHandle{ErrorModule::Kernel, 114};
27constexpr ResultCode ResultInvalidPointer{ErrorModule::Kernel, 115}; 27constexpr Result ResultInvalidPointer{ErrorModule::Kernel, 115};
28constexpr ResultCode ResultInvalidCombination{ErrorModule::Kernel, 116}; 28constexpr Result ResultInvalidCombination{ErrorModule::Kernel, 116};
29constexpr ResultCode ResultTimedOut{ErrorModule::Kernel, 117}; 29constexpr Result ResultTimedOut{ErrorModule::Kernel, 117};
30constexpr ResultCode ResultCancelled{ErrorModule::Kernel, 118}; 30constexpr Result ResultCancelled{ErrorModule::Kernel, 118};
31constexpr ResultCode ResultOutOfRange{ErrorModule::Kernel, 119}; 31constexpr Result ResultOutOfRange{ErrorModule::Kernel, 119};
32constexpr ResultCode ResultInvalidEnumValue{ErrorModule::Kernel, 120}; 32constexpr Result ResultInvalidEnumValue{ErrorModule::Kernel, 120};
33constexpr ResultCode ResultNotFound{ErrorModule::Kernel, 121}; 33constexpr Result ResultNotFound{ErrorModule::Kernel, 121};
34constexpr ResultCode ResultBusy{ErrorModule::Kernel, 122}; 34constexpr Result ResultBusy{ErrorModule::Kernel, 122};
35constexpr ResultCode ResultSessionClosed{ErrorModule::Kernel, 123}; 35constexpr Result ResultSessionClosed{ErrorModule::Kernel, 123};
36constexpr ResultCode ResultInvalidState{ErrorModule::Kernel, 125}; 36constexpr Result ResultInvalidState{ErrorModule::Kernel, 125};
37constexpr ResultCode ResultReservedUsed{ErrorModule::Kernel, 126}; 37constexpr Result ResultReservedUsed{ErrorModule::Kernel, 126};
38constexpr ResultCode ResultPortClosed{ErrorModule::Kernel, 131}; 38constexpr Result ResultPortClosed{ErrorModule::Kernel, 131};
39constexpr ResultCode ResultLimitReached{ErrorModule::Kernel, 132}; 39constexpr Result ResultLimitReached{ErrorModule::Kernel, 132};
40constexpr ResultCode ResultInvalidId{ErrorModule::Kernel, 519}; 40constexpr Result ResultInvalidId{ErrorModule::Kernel, 519};
41 41
42} // namespace Kernel 42} // namespace Kernel
diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h
index 2271bb80c..4bc49087e 100644
--- a/src/core/hle/kernel/svc_wrap.h
+++ b/src/core/hle/kernel/svc_wrap.h
@@ -33,24 +33,24 @@ static inline void FuncReturn32(Core::System& system, u32 result) {
33} 33}
34 34
35//////////////////////////////////////////////////////////////////////////////////////////////////// 35////////////////////////////////////////////////////////////////////////////////////////////////////
36// Function wrappers that return type ResultCode 36// Function wrappers that return type Result
37 37
38template <ResultCode func(Core::System&, u64)> 38template <Result func(Core::System&, u64)>
39void SvcWrap64(Core::System& system) { 39void SvcWrap64(Core::System& system) {
40 FuncReturn(system, func(system, Param(system, 0)).raw); 40 FuncReturn(system, func(system, Param(system, 0)).raw);
41} 41}
42 42
43template <ResultCode func(Core::System&, u64, u64)> 43template <Result func(Core::System&, u64, u64)>
44void SvcWrap64(Core::System& system) { 44void SvcWrap64(Core::System& system) {
45 FuncReturn(system, func(system, Param(system, 0), Param(system, 1)).raw); 45 FuncReturn(system, func(system, Param(system, 0), Param(system, 1)).raw);
46} 46}
47 47
48template <ResultCode func(Core::System&, u32)> 48template <Result func(Core::System&, u32)>
49void SvcWrap64(Core::System& system) { 49void SvcWrap64(Core::System& system) {
50 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0))).raw); 50 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0))).raw);
51} 51}
52 52
53template <ResultCode func(Core::System&, u32, u32)> 53template <Result func(Core::System&, u32, u32)>
54void SvcWrap64(Core::System& system) { 54void SvcWrap64(Core::System& system) {
55 FuncReturn( 55 FuncReturn(
56 system, 56 system,
@@ -58,14 +58,14 @@ void SvcWrap64(Core::System& system) {
58} 58}
59 59
60// Used by SetThreadActivity 60// Used by SetThreadActivity
61template <ResultCode func(Core::System&, Handle, Svc::ThreadActivity)> 61template <Result func(Core::System&, Handle, Svc::ThreadActivity)>
62void SvcWrap64(Core::System& system) { 62void SvcWrap64(Core::System& system) {
63 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), 63 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)),
64 static_cast<Svc::ThreadActivity>(Param(system, 1))) 64 static_cast<Svc::ThreadActivity>(Param(system, 1)))
65 .raw); 65 .raw);
66} 66}
67 67
68template <ResultCode func(Core::System&, u32, u64, u64, u64)> 68template <Result func(Core::System&, u32, u64, u64, u64)>
69void SvcWrap64(Core::System& system) { 69void SvcWrap64(Core::System& system) {
70 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1), 70 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1),
71 Param(system, 2), Param(system, 3)) 71 Param(system, 2), Param(system, 3))
@@ -73,7 +73,7 @@ void SvcWrap64(Core::System& system) {
73} 73}
74 74
75// Used by MapProcessMemory and UnmapProcessMemory 75// Used by MapProcessMemory and UnmapProcessMemory
76template <ResultCode func(Core::System&, u64, u32, u64, u64)> 76template <Result func(Core::System&, u64, u32, u64, u64)>
77void SvcWrap64(Core::System& system) { 77void SvcWrap64(Core::System& system) {
78 FuncReturn(system, func(system, Param(system, 0), static_cast<u32>(Param(system, 1)), 78 FuncReturn(system, func(system, Param(system, 0), static_cast<u32>(Param(system, 1)),
79 Param(system, 2), Param(system, 3)) 79 Param(system, 2), Param(system, 3))
@@ -81,7 +81,7 @@ void SvcWrap64(Core::System& system) {
81} 81}
82 82
83// Used by ControlCodeMemory 83// Used by ControlCodeMemory
84template <ResultCode func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)> 84template <Result func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)>
85void SvcWrap64(Core::System& system) { 85void SvcWrap64(Core::System& system) {
86 FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), 86 FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)),
87 static_cast<u32>(Param(system, 1)), Param(system, 2), Param(system, 3), 87 static_cast<u32>(Param(system, 1)), Param(system, 2), Param(system, 3),
@@ -89,7 +89,7 @@ void SvcWrap64(Core::System& system) {
89 .raw); 89 .raw);
90} 90}
91 91
92template <ResultCode func(Core::System&, u32*)> 92template <Result func(Core::System&, u32*)>
93void SvcWrap64(Core::System& system) { 93void SvcWrap64(Core::System& system) {
94 u32 param = 0; 94 u32 param = 0;
95 const u32 retval = func(system, &param).raw; 95 const u32 retval = func(system, &param).raw;
@@ -97,7 +97,7 @@ void SvcWrap64(Core::System& system) {
97 FuncReturn(system, retval); 97 FuncReturn(system, retval);
98} 98}
99 99
100template <ResultCode func(Core::System&, u32*, u32)> 100template <Result func(Core::System&, u32*, u32)>
101void SvcWrap64(Core::System& system) { 101void SvcWrap64(Core::System& system) {
102 u32 param_1 = 0; 102 u32 param_1 = 0;
103 const u32 retval = func(system, &param_1, static_cast<u32>(Param(system, 1))).raw; 103 const u32 retval = func(system, &param_1, static_cast<u32>(Param(system, 1))).raw;
@@ -105,7 +105,7 @@ void SvcWrap64(Core::System& system) {
105 FuncReturn(system, retval); 105 FuncReturn(system, retval);
106} 106}
107 107
108template <ResultCode func(Core::System&, u32*, u32*)> 108template <Result func(Core::System&, u32*, u32*)>
109void SvcWrap64(Core::System& system) { 109void SvcWrap64(Core::System& system) {
110 u32 param_1 = 0; 110 u32 param_1 = 0;
111 u32 param_2 = 0; 111 u32 param_2 = 0;
@@ -118,7 +118,7 @@ void SvcWrap64(Core::System& system) {
118 FuncReturn(system, retval); 118 FuncReturn(system, retval);
119} 119}
120 120
121template <ResultCode func(Core::System&, u32*, u64)> 121template <Result func(Core::System&, u32*, u64)>
122void SvcWrap64(Core::System& system) { 122void SvcWrap64(Core::System& system) {
123 u32 param_1 = 0; 123 u32 param_1 = 0;
124 const u32 retval = func(system, &param_1, Param(system, 1)).raw; 124 const u32 retval = func(system, &param_1, Param(system, 1)).raw;
@@ -126,7 +126,7 @@ void SvcWrap64(Core::System& system) {
126 FuncReturn(system, retval); 126 FuncReturn(system, retval);
127} 127}
128 128
129template <ResultCode func(Core::System&, u32*, u64, u32)> 129template <Result func(Core::System&, u32*, u64, u32)>
130void SvcWrap64(Core::System& system) { 130void SvcWrap64(Core::System& system) {
131 u32 param_1 = 0; 131 u32 param_1 = 0;
132 const u32 retval = 132 const u32 retval =
@@ -136,7 +136,7 @@ void SvcWrap64(Core::System& system) {
136 FuncReturn(system, retval); 136 FuncReturn(system, retval);
137} 137}
138 138
139template <ResultCode func(Core::System&, u64*, u32)> 139template <Result func(Core::System&, u64*, u32)>
140void SvcWrap64(Core::System& system) { 140void SvcWrap64(Core::System& system) {
141 u64 param_1 = 0; 141 u64 param_1 = 0;
142 const u32 retval = func(system, &param_1, static_cast<u32>(Param(system, 1))).raw; 142 const u32 retval = func(system, &param_1, static_cast<u32>(Param(system, 1))).raw;
@@ -145,12 +145,12 @@ void SvcWrap64(Core::System& system) {
145 FuncReturn(system, retval); 145 FuncReturn(system, retval);
146} 146}
147 147
148template <ResultCode func(Core::System&, u64, u32)> 148template <Result func(Core::System&, u64, u32)>
149void SvcWrap64(Core::System& system) { 149void SvcWrap64(Core::System& system) {
150 FuncReturn(system, func(system, Param(system, 0), static_cast<u32>(Param(system, 1))).raw); 150 FuncReturn(system, func(system, Param(system, 0), static_cast<u32>(Param(system, 1))).raw);
151} 151}
152 152
153template <ResultCode func(Core::System&, u64*, u64)> 153template <Result func(Core::System&, u64*, u64)>
154void SvcWrap64(Core::System& system) { 154void SvcWrap64(Core::System& system) {
155 u64 param_1 = 0; 155 u64 param_1 = 0;
156 const u32 retval = func(system, &param_1, Param(system, 1)).raw; 156 const u32 retval = func(system, &param_1, Param(system, 1)).raw;
@@ -159,7 +159,7 @@ void SvcWrap64(Core::System& system) {
159 FuncReturn(system, retval); 159 FuncReturn(system, retval);
160} 160}
161 161
162template <ResultCode func(Core::System&, u64*, u32, u32)> 162template <Result func(Core::System&, u64*, u32, u32)>
163void SvcWrap64(Core::System& system) { 163void SvcWrap64(Core::System& system) {
164 u64 param_1 = 0; 164 u64 param_1 = 0;
165 const u32 retval = func(system, &param_1, static_cast<u32>(Param(system, 1)), 165 const u32 retval = func(system, &param_1, static_cast<u32>(Param(system, 1)),
@@ -171,7 +171,7 @@ void SvcWrap64(Core::System& system) {
171} 171}
172 172
173// Used by GetResourceLimitLimitValue. 173// Used by GetResourceLimitLimitValue.
174template <ResultCode func(Core::System&, u64*, Handle, LimitableResource)> 174template <Result func(Core::System&, u64*, Handle, LimitableResource)>
175void SvcWrap64(Core::System& system) { 175void SvcWrap64(Core::System& system) {
176 u64 param_1 = 0; 176 u64 param_1 = 0;
177 const u32 retval = func(system, &param_1, static_cast<Handle>(Param(system, 1)), 177 const u32 retval = func(system, &param_1, static_cast<Handle>(Param(system, 1)),
@@ -182,13 +182,13 @@ void SvcWrap64(Core::System& system) {
182 FuncReturn(system, retval); 182 FuncReturn(system, retval);
183} 183}
184 184
185template <ResultCode func(Core::System&, u32, u64)> 185template <Result func(Core::System&, u32, u64)>
186void SvcWrap64(Core::System& system) { 186void SvcWrap64(Core::System& system) {
187 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1)).raw); 187 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1)).raw);
188} 188}
189 189
190// Used by SetResourceLimitLimitValue 190// Used by SetResourceLimitLimitValue
191template <ResultCode func(Core::System&, Handle, LimitableResource, u64)> 191template <Result func(Core::System&, Handle, LimitableResource, u64)>
192void SvcWrap64(Core::System& system) { 192void SvcWrap64(Core::System& system) {
193 FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), 193 FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)),
194 static_cast<LimitableResource>(Param(system, 1)), Param(system, 2)) 194 static_cast<LimitableResource>(Param(system, 1)), Param(system, 2))
@@ -196,7 +196,7 @@ void SvcWrap64(Core::System& system) {
196} 196}
197 197
198// Used by SetThreadCoreMask 198// Used by SetThreadCoreMask
199template <ResultCode func(Core::System&, Handle, s32, u64)> 199template <Result func(Core::System&, Handle, s32, u64)>
200void SvcWrap64(Core::System& system) { 200void SvcWrap64(Core::System& system) {
201 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), 201 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)),
202 static_cast<s32>(Param(system, 1)), Param(system, 2)) 202 static_cast<s32>(Param(system, 1)), Param(system, 2))
@@ -204,44 +204,44 @@ void SvcWrap64(Core::System& system) {
204} 204}
205 205
206// Used by GetThreadCoreMask 206// Used by GetThreadCoreMask
207template <ResultCode func(Core::System&, Handle, s32*, u64*)> 207template <Result func(Core::System&, Handle, s32*, u64*)>
208void SvcWrap64(Core::System& system) { 208void SvcWrap64(Core::System& system) {
209 s32 param_1 = 0; 209 s32 param_1 = 0;
210 u64 param_2 = 0; 210 u64 param_2 = 0;
211 const ResultCode retval = func(system, static_cast<u32>(Param(system, 2)), &param_1, &param_2); 211 const Result retval = func(system, static_cast<u32>(Param(system, 2)), &param_1, &param_2);
212 212
213 system.CurrentArmInterface().SetReg(1, param_1); 213 system.CurrentArmInterface().SetReg(1, param_1);
214 system.CurrentArmInterface().SetReg(2, param_2); 214 system.CurrentArmInterface().SetReg(2, param_2);
215 FuncReturn(system, retval.raw); 215 FuncReturn(system, retval.raw);
216} 216}
217 217
218template <ResultCode func(Core::System&, u64, u64, u32, u32)> 218template <Result func(Core::System&, u64, u64, u32, u32)>
219void SvcWrap64(Core::System& system) { 219void SvcWrap64(Core::System& system) {
220 FuncReturn(system, func(system, Param(system, 0), Param(system, 1), 220 FuncReturn(system, func(system, Param(system, 0), Param(system, 1),
221 static_cast<u32>(Param(system, 2)), static_cast<u32>(Param(system, 3))) 221 static_cast<u32>(Param(system, 2)), static_cast<u32>(Param(system, 3)))
222 .raw); 222 .raw);
223} 223}
224 224
225template <ResultCode func(Core::System&, u64, u64, u32, u64)> 225template <Result func(Core::System&, u64, u64, u32, u64)>
226void SvcWrap64(Core::System& system) { 226void SvcWrap64(Core::System& system) {
227 FuncReturn(system, func(system, Param(system, 0), Param(system, 1), 227 FuncReturn(system, func(system, Param(system, 0), Param(system, 1),
228 static_cast<u32>(Param(system, 2)), Param(system, 3)) 228 static_cast<u32>(Param(system, 2)), Param(system, 3))
229 .raw); 229 .raw);
230} 230}
231 231
232template <ResultCode func(Core::System&, u32, u64, u32)> 232template <Result func(Core::System&, u32, u64, u32)>
233void SvcWrap64(Core::System& system) { 233void SvcWrap64(Core::System& system) {
234 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1), 234 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1),
235 static_cast<u32>(Param(system, 2))) 235 static_cast<u32>(Param(system, 2)))
236 .raw); 236 .raw);
237} 237}
238 238
239template <ResultCode func(Core::System&, u64, u64, u64)> 239template <Result func(Core::System&, u64, u64, u64)>
240void SvcWrap64(Core::System& system) { 240void SvcWrap64(Core::System& system) {
241 FuncReturn(system, func(system, Param(system, 0), Param(system, 1), Param(system, 2)).raw); 241 FuncReturn(system, func(system, Param(system, 0), Param(system, 1), Param(system, 2)).raw);
242} 242}
243 243
244template <ResultCode func(Core::System&, u64, u64, u32)> 244template <Result func(Core::System&, u64, u64, u32)>
245void SvcWrap64(Core::System& system) { 245void SvcWrap64(Core::System& system) {
246 FuncReturn( 246 FuncReturn(
247 system, 247 system,
@@ -249,7 +249,7 @@ void SvcWrap64(Core::System& system) {
249} 249}
250 250
251// Used by SetMemoryPermission 251// Used by SetMemoryPermission
252template <ResultCode func(Core::System&, u64, u64, Svc::MemoryPermission)> 252template <Result func(Core::System&, u64, u64, Svc::MemoryPermission)>
253void SvcWrap64(Core::System& system) { 253void SvcWrap64(Core::System& system) {
254 FuncReturn(system, func(system, Param(system, 0), Param(system, 1), 254 FuncReturn(system, func(system, Param(system, 0), Param(system, 1),
255 static_cast<Svc::MemoryPermission>(Param(system, 2))) 255 static_cast<Svc::MemoryPermission>(Param(system, 2)))
@@ -257,14 +257,14 @@ void SvcWrap64(Core::System& system) {
257} 257}
258 258
259// Used by MapSharedMemory 259// Used by MapSharedMemory
260template <ResultCode func(Core::System&, Handle, u64, u64, Svc::MemoryPermission)> 260template <Result func(Core::System&, Handle, u64, u64, Svc::MemoryPermission)>
261void SvcWrap64(Core::System& system) { 261void SvcWrap64(Core::System& system) {
262 FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), Param(system, 1), 262 FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), Param(system, 1),
263 Param(system, 2), static_cast<Svc::MemoryPermission>(Param(system, 3))) 263 Param(system, 2), static_cast<Svc::MemoryPermission>(Param(system, 3)))
264 .raw); 264 .raw);
265} 265}
266 266
267template <ResultCode func(Core::System&, u32, u64, u64)> 267template <Result func(Core::System&, u32, u64, u64)>
268void SvcWrap64(Core::System& system) { 268void SvcWrap64(Core::System& system) {
269 FuncReturn( 269 FuncReturn(
270 system, 270 system,
@@ -272,7 +272,7 @@ void SvcWrap64(Core::System& system) {
272} 272}
273 273
274// Used by WaitSynchronization 274// Used by WaitSynchronization
275template <ResultCode func(Core::System&, s32*, u64, s32, s64)> 275template <Result func(Core::System&, s32*, u64, s32, s64)>
276void SvcWrap64(Core::System& system) { 276void SvcWrap64(Core::System& system) {
277 s32 param_1 = 0; 277 s32 param_1 = 0;
278 const u32 retval = func(system, &param_1, Param(system, 1), static_cast<s32>(Param(system, 2)), 278 const u32 retval = func(system, &param_1, Param(system, 1), static_cast<s32>(Param(system, 2)),
@@ -283,7 +283,7 @@ void SvcWrap64(Core::System& system) {
283 FuncReturn(system, retval); 283 FuncReturn(system, retval);
284} 284}
285 285
286template <ResultCode func(Core::System&, u64, u64, u32, s64)> 286template <Result func(Core::System&, u64, u64, u32, s64)>
287void SvcWrap64(Core::System& system) { 287void SvcWrap64(Core::System& system) {
288 FuncReturn(system, func(system, Param(system, 0), Param(system, 1), 288 FuncReturn(system, func(system, Param(system, 0), Param(system, 1),
289 static_cast<u32>(Param(system, 2)), static_cast<s64>(Param(system, 3))) 289 static_cast<u32>(Param(system, 2)), static_cast<s64>(Param(system, 3)))
@@ -291,7 +291,7 @@ void SvcWrap64(Core::System& system) {
291} 291}
292 292
293// Used by GetInfo 293// Used by GetInfo
294template <ResultCode func(Core::System&, u64*, u64, Handle, u64)> 294template <Result func(Core::System&, u64*, u64, Handle, u64)>
295void SvcWrap64(Core::System& system) { 295void SvcWrap64(Core::System& system) {
296 u64 param_1 = 0; 296 u64 param_1 = 0;
297 const u32 retval = func(system, &param_1, Param(system, 1), 297 const u32 retval = func(system, &param_1, Param(system, 1),
@@ -302,7 +302,7 @@ void SvcWrap64(Core::System& system) {
302 FuncReturn(system, retval); 302 FuncReturn(system, retval);
303} 303}
304 304
305template <ResultCode func(Core::System&, u32*, u64, u64, u64, u32, s32)> 305template <Result func(Core::System&, u32*, u64, u64, u64, u32, s32)>
306void SvcWrap64(Core::System& system) { 306void SvcWrap64(Core::System& system) {
307 u32 param_1 = 0; 307 u32 param_1 = 0;
308 const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2), Param(system, 3), 308 const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2), Param(system, 3),
@@ -314,7 +314,7 @@ void SvcWrap64(Core::System& system) {
314} 314}
315 315
316// Used by CreateTransferMemory 316// Used by CreateTransferMemory
317template <ResultCode func(Core::System&, Handle*, u64, u64, Svc::MemoryPermission)> 317template <Result func(Core::System&, Handle*, u64, u64, Svc::MemoryPermission)>
318void SvcWrap64(Core::System& system) { 318void SvcWrap64(Core::System& system) {
319 u32 param_1 = 0; 319 u32 param_1 = 0;
320 const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2), 320 const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2),
@@ -326,7 +326,7 @@ void SvcWrap64(Core::System& system) {
326} 326}
327 327
328// Used by CreateCodeMemory 328// Used by CreateCodeMemory
329template <ResultCode func(Core::System&, Handle*, u64, u64)> 329template <Result func(Core::System&, Handle*, u64, u64)>
330void SvcWrap64(Core::System& system) { 330void SvcWrap64(Core::System& system) {
331 u32 param_1 = 0; 331 u32 param_1 = 0;
332 const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2)).raw; 332 const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2)).raw;
@@ -335,7 +335,7 @@ void SvcWrap64(Core::System& system) {
335 FuncReturn(system, retval); 335 FuncReturn(system, retval);
336} 336}
337 337
338template <ResultCode func(Core::System&, Handle*, u64, u32, u32)> 338template <Result func(Core::System&, Handle*, u64, u32, u32)>
339void SvcWrap64(Core::System& system) { 339void SvcWrap64(Core::System& system) {
340 u32 param_1 = 0; 340 u32 param_1 = 0;
341 const u32 retval = func(system, &param_1, Param(system, 1), static_cast<u32>(Param(system, 2)), 341 const u32 retval = func(system, &param_1, Param(system, 1), static_cast<u32>(Param(system, 2)),
@@ -347,7 +347,7 @@ void SvcWrap64(Core::System& system) {
347} 347}
348 348
349// Used by WaitForAddress 349// Used by WaitForAddress
350template <ResultCode func(Core::System&, u64, Svc::ArbitrationType, s32, s64)> 350template <Result func(Core::System&, u64, Svc::ArbitrationType, s32, s64)>
351void SvcWrap64(Core::System& system) { 351void SvcWrap64(Core::System& system) {
352 FuncReturn(system, 352 FuncReturn(system,
353 func(system, Param(system, 0), static_cast<Svc::ArbitrationType>(Param(system, 1)), 353 func(system, Param(system, 0), static_cast<Svc::ArbitrationType>(Param(system, 1)),
@@ -356,7 +356,7 @@ void SvcWrap64(Core::System& system) {
356} 356}
357 357
358// Used by SignalToAddress 358// Used by SignalToAddress
359template <ResultCode func(Core::System&, u64, Svc::SignalType, s32, s32)> 359template <Result func(Core::System&, u64, Svc::SignalType, s32, s32)>
360void SvcWrap64(Core::System& system) { 360void SvcWrap64(Core::System& system) {
361 FuncReturn(system, 361 FuncReturn(system,
362 func(system, Param(system, 0), static_cast<Svc::SignalType>(Param(system, 1)), 362 func(system, Param(system, 0), static_cast<Svc::SignalType>(Param(system, 1)),
@@ -425,7 +425,7 @@ void SvcWrap64(Core::System& system) {
425} 425}
426 426
427// Used by QueryMemory32, ArbitrateLock32 427// Used by QueryMemory32, ArbitrateLock32
428template <ResultCode func(Core::System&, u32, u32, u32)> 428template <Result func(Core::System&, u32, u32, u32)>
429void SvcWrap32(Core::System& system) { 429void SvcWrap32(Core::System& system) {
430 FuncReturn32(system, 430 FuncReturn32(system,
431 func(system, Param32(system, 0), Param32(system, 1), Param32(system, 2)).raw); 431 func(system, Param32(system, 0), Param32(system, 1), Param32(system, 2)).raw);
@@ -456,7 +456,7 @@ void SvcWrap32(Core::System& system) {
456} 456}
457 457
458// Used by CreateThread32 458// Used by CreateThread32
459template <ResultCode func(Core::System&, Handle*, u32, u32, u32, u32, s32)> 459template <Result func(Core::System&, Handle*, u32, u32, u32, u32, s32)>
460void SvcWrap32(Core::System& system) { 460void SvcWrap32(Core::System& system) {
461 Handle param_1 = 0; 461 Handle param_1 = 0;
462 462
@@ -469,7 +469,7 @@ void SvcWrap32(Core::System& system) {
469} 469}
470 470
471// Used by GetInfo32 471// Used by GetInfo32
472template <ResultCode func(Core::System&, u32*, u32*, u32, u32, u32, u32)> 472template <Result func(Core::System&, u32*, u32*, u32, u32, u32, u32)>
473void SvcWrap32(Core::System& system) { 473void SvcWrap32(Core::System& system) {
474 u32 param_1 = 0; 474 u32 param_1 = 0;
475 u32 param_2 = 0; 475 u32 param_2 = 0;
@@ -484,7 +484,7 @@ void SvcWrap32(Core::System& system) {
484} 484}
485 485
486// Used by GetThreadPriority32, ConnectToNamedPort32 486// Used by GetThreadPriority32, ConnectToNamedPort32
487template <ResultCode func(Core::System&, u32*, u32)> 487template <Result func(Core::System&, u32*, u32)>
488void SvcWrap32(Core::System& system) { 488void SvcWrap32(Core::System& system) {
489 u32 param_1 = 0; 489 u32 param_1 = 0;
490 const u32 retval = func(system, &param_1, Param32(system, 1)).raw; 490 const u32 retval = func(system, &param_1, Param32(system, 1)).raw;
@@ -493,7 +493,7 @@ void SvcWrap32(Core::System& system) {
493} 493}
494 494
495// Used by GetThreadId32 495// Used by GetThreadId32
496template <ResultCode func(Core::System&, u32*, u32*, u32)> 496template <Result func(Core::System&, u32*, u32*, u32)>
497void SvcWrap32(Core::System& system) { 497void SvcWrap32(Core::System& system) {
498 u32 param_1 = 0; 498 u32 param_1 = 0;
499 u32 param_2 = 0; 499 u32 param_2 = 0;
@@ -516,7 +516,7 @@ void SvcWrap32(Core::System& system) {
516} 516}
517 517
518// Used by CreateEvent32 518// Used by CreateEvent32
519template <ResultCode func(Core::System&, Handle*, Handle*)> 519template <Result func(Core::System&, Handle*, Handle*)>
520void SvcWrap32(Core::System& system) { 520void SvcWrap32(Core::System& system) {
521 Handle param_1 = 0; 521 Handle param_1 = 0;
522 Handle param_2 = 0; 522 Handle param_2 = 0;
@@ -528,7 +528,7 @@ void SvcWrap32(Core::System& system) {
528} 528}
529 529
530// Used by GetThreadId32 530// Used by GetThreadId32
531template <ResultCode func(Core::System&, Handle, u32*, u32*, u32*)> 531template <Result func(Core::System&, Handle, u32*, u32*, u32*)>
532void SvcWrap32(Core::System& system) { 532void SvcWrap32(Core::System& system) {
533 u32 param_1 = 0; 533 u32 param_1 = 0;
534 u32 param_2 = 0; 534 u32 param_2 = 0;
@@ -542,7 +542,7 @@ void SvcWrap32(Core::System& system) {
542} 542}
543 543
544// Used by GetThreadCoreMask32 544// Used by GetThreadCoreMask32
545template <ResultCode func(Core::System&, Handle, s32*, u32*, u32*)> 545template <Result func(Core::System&, Handle, s32*, u32*, u32*)>
546void SvcWrap32(Core::System& system) { 546void SvcWrap32(Core::System& system) {
547 s32 param_1 = 0; 547 s32 param_1 = 0;
548 u32 param_2 = 0; 548 u32 param_2 = 0;
@@ -562,7 +562,7 @@ void SvcWrap32(Core::System& system) {
562} 562}
563 563
564// Used by SetThreadActivity32 564// Used by SetThreadActivity32
565template <ResultCode func(Core::System&, Handle, Svc::ThreadActivity)> 565template <Result func(Core::System&, Handle, Svc::ThreadActivity)>
566void SvcWrap32(Core::System& system) { 566void SvcWrap32(Core::System& system) {
567 const u32 retval = func(system, static_cast<Handle>(Param(system, 0)), 567 const u32 retval = func(system, static_cast<Handle>(Param(system, 0)),
568 static_cast<Svc::ThreadActivity>(Param(system, 1))) 568 static_cast<Svc::ThreadActivity>(Param(system, 1)))
@@ -571,7 +571,7 @@ void SvcWrap32(Core::System& system) {
571} 571}
572 572
573// Used by SetThreadPriority32 573// Used by SetThreadPriority32
574template <ResultCode func(Core::System&, Handle, u32)> 574template <Result func(Core::System&, Handle, u32)>
575void SvcWrap32(Core::System& system) { 575void SvcWrap32(Core::System& system) {
576 const u32 retval = 576 const u32 retval =
577 func(system, static_cast<Handle>(Param(system, 0)), static_cast<u32>(Param(system, 1))).raw; 577 func(system, static_cast<Handle>(Param(system, 0)), static_cast<u32>(Param(system, 1))).raw;
@@ -579,7 +579,7 @@ void SvcWrap32(Core::System& system) {
579} 579}
580 580
581// Used by SetMemoryAttribute32 581// Used by SetMemoryAttribute32
582template <ResultCode func(Core::System&, Handle, u32, u32, u32)> 582template <Result func(Core::System&, Handle, u32, u32, u32)>
583void SvcWrap32(Core::System& system) { 583void SvcWrap32(Core::System& system) {
584 const u32 retval = 584 const u32 retval =
585 func(system, static_cast<Handle>(Param(system, 0)), static_cast<u32>(Param(system, 1)), 585 func(system, static_cast<Handle>(Param(system, 0)), static_cast<u32>(Param(system, 1)),
@@ -589,7 +589,7 @@ void SvcWrap32(Core::System& system) {
589} 589}
590 590
591// Used by MapSharedMemory32 591// Used by MapSharedMemory32
592template <ResultCode func(Core::System&, Handle, u32, u32, Svc::MemoryPermission)> 592template <Result func(Core::System&, Handle, u32, u32, Svc::MemoryPermission)>
593void SvcWrap32(Core::System& system) { 593void SvcWrap32(Core::System& system) {
594 const u32 retval = func(system, static_cast<Handle>(Param(system, 0)), 594 const u32 retval = func(system, static_cast<Handle>(Param(system, 0)),
595 static_cast<u32>(Param(system, 1)), static_cast<u32>(Param(system, 2)), 595 static_cast<u32>(Param(system, 1)), static_cast<u32>(Param(system, 2)),
@@ -599,7 +599,7 @@ void SvcWrap32(Core::System& system) {
599} 599}
600 600
601// Used by SetThreadCoreMask32 601// Used by SetThreadCoreMask32
602template <ResultCode func(Core::System&, Handle, s32, u32, u32)> 602template <Result func(Core::System&, Handle, s32, u32, u32)>
603void SvcWrap32(Core::System& system) { 603void SvcWrap32(Core::System& system) {
604 const u32 retval = 604 const u32 retval =
605 func(system, static_cast<Handle>(Param(system, 0)), static_cast<s32>(Param(system, 1)), 605 func(system, static_cast<Handle>(Param(system, 0)), static_cast<s32>(Param(system, 1)),
@@ -609,7 +609,7 @@ void SvcWrap32(Core::System& system) {
609} 609}
610 610
611// Used by WaitProcessWideKeyAtomic32 611// Used by WaitProcessWideKeyAtomic32
612template <ResultCode func(Core::System&, u32, u32, Handle, u32, u32)> 612template <Result func(Core::System&, u32, u32, Handle, u32, u32)>
613void SvcWrap32(Core::System& system) { 613void SvcWrap32(Core::System& system) {
614 const u32 retval = 614 const u32 retval =
615 func(system, static_cast<u32>(Param(system, 0)), static_cast<u32>(Param(system, 1)), 615 func(system, static_cast<u32>(Param(system, 0)), static_cast<u32>(Param(system, 1)),
@@ -620,7 +620,7 @@ void SvcWrap32(Core::System& system) {
620} 620}
621 621
622// Used by WaitForAddress32 622// Used by WaitForAddress32
623template <ResultCode func(Core::System&, u32, Svc::ArbitrationType, s32, u32, u32)> 623template <Result func(Core::System&, u32, Svc::ArbitrationType, s32, u32, u32)>
624void SvcWrap32(Core::System& system) { 624void SvcWrap32(Core::System& system) {
625 const u32 retval = func(system, static_cast<u32>(Param(system, 0)), 625 const u32 retval = func(system, static_cast<u32>(Param(system, 0)),
626 static_cast<Svc::ArbitrationType>(Param(system, 1)), 626 static_cast<Svc::ArbitrationType>(Param(system, 1)),
@@ -631,7 +631,7 @@ void SvcWrap32(Core::System& system) {
631} 631}
632 632
633// Used by SignalToAddress32 633// Used by SignalToAddress32
634template <ResultCode func(Core::System&, u32, Svc::SignalType, s32, s32)> 634template <Result func(Core::System&, u32, Svc::SignalType, s32, s32)>
635void SvcWrap32(Core::System& system) { 635void SvcWrap32(Core::System& system) {
636 const u32 retval = func(system, static_cast<u32>(Param(system, 0)), 636 const u32 retval = func(system, static_cast<u32>(Param(system, 0)),
637 static_cast<Svc::SignalType>(Param(system, 1)), 637 static_cast<Svc::SignalType>(Param(system, 1)),
@@ -641,13 +641,13 @@ void SvcWrap32(Core::System& system) {
641} 641}
642 642
643// Used by SendSyncRequest32, ArbitrateUnlock32 643// Used by SendSyncRequest32, ArbitrateUnlock32
644template <ResultCode func(Core::System&, u32)> 644template <Result func(Core::System&, u32)>
645void SvcWrap32(Core::System& system) { 645void SvcWrap32(Core::System& system) {
646 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0))).raw); 646 FuncReturn(system, func(system, static_cast<u32>(Param(system, 0))).raw);
647} 647}
648 648
649// Used by CreateTransferMemory32 649// Used by CreateTransferMemory32
650template <ResultCode func(Core::System&, Handle*, u32, u32, Svc::MemoryPermission)> 650template <Result func(Core::System&, Handle*, u32, u32, Svc::MemoryPermission)>
651void SvcWrap32(Core::System& system) { 651void SvcWrap32(Core::System& system) {
652 Handle handle = 0; 652 Handle handle = 0;
653 const u32 retval = func(system, &handle, Param32(system, 1), Param32(system, 2), 653 const u32 retval = func(system, &handle, Param32(system, 1), Param32(system, 2),
@@ -658,7 +658,7 @@ void SvcWrap32(Core::System& system) {
658} 658}
659 659
660// Used by WaitSynchronization32 660// Used by WaitSynchronization32
661template <ResultCode func(Core::System&, u32, u32, s32, u32, s32*)> 661template <Result func(Core::System&, u32, u32, s32, u32, s32*)>
662void SvcWrap32(Core::System& system) { 662void SvcWrap32(Core::System& system) {
663 s32 param_1 = 0; 663 s32 param_1 = 0;
664 const u32 retval = func(system, Param32(system, 0), Param32(system, 1), Param32(system, 2), 664 const u32 retval = func(system, Param32(system, 0), Param32(system, 1), Param32(system, 2),
@@ -669,7 +669,7 @@ void SvcWrap32(Core::System& system) {
669} 669}
670 670
671// Used by CreateCodeMemory32 671// Used by CreateCodeMemory32
672template <ResultCode func(Core::System&, Handle*, u32, u32)> 672template <Result func(Core::System&, Handle*, u32, u32)>
673void SvcWrap32(Core::System& system) { 673void SvcWrap32(Core::System& system) {
674 Handle handle = 0; 674 Handle handle = 0;
675 675
@@ -680,7 +680,7 @@ void SvcWrap32(Core::System& system) {
680} 680}
681 681
682// Used by ControlCodeMemory32 682// Used by ControlCodeMemory32
683template <ResultCode func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)> 683template <Result func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)>
684void SvcWrap32(Core::System& system) { 684void SvcWrap32(Core::System& system) {
685 const u32 retval = 685 const u32 retval =
686 func(system, Param32(system, 0), Param32(system, 1), Param(system, 2), Param(system, 4), 686 func(system, Param32(system, 0), Param32(system, 1), Param(system, 2), Param(system, 4),
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index 569dd9f38..aa9e5b89d 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -112,15 +112,15 @@ enum class ErrorModule : u32 {
112}; 112};
113 113
114/// Encapsulates a Horizon OS error code, allowing it to be separated into its constituent fields. 114/// Encapsulates a Horizon OS error code, allowing it to be separated into its constituent fields.
115union ResultCode { 115union Result {
116 u32 raw; 116 u32 raw;
117 117
118 BitField<0, 9, ErrorModule> module; 118 BitField<0, 9, ErrorModule> module;
119 BitField<9, 13, u32> description; 119 BitField<9, 13, u32> description;
120 120
121 constexpr explicit ResultCode(u32 raw_) : raw(raw_) {} 121 constexpr explicit Result(u32 raw_) : raw(raw_) {}
122 122
123 constexpr ResultCode(ErrorModule module_, u32 description_) 123 constexpr Result(ErrorModule module_, u32 description_)
124 : raw(module.FormatValue(module_) | description.FormatValue(description_)) {} 124 : raw(module.FormatValue(module_) | description.FormatValue(description_)) {}
125 125
126 [[nodiscard]] constexpr bool IsSuccess() const { 126 [[nodiscard]] constexpr bool IsSuccess() const {
@@ -132,18 +132,18 @@ union ResultCode {
132 } 132 }
133}; 133};
134 134
135[[nodiscard]] constexpr bool operator==(const ResultCode& a, const ResultCode& b) { 135[[nodiscard]] constexpr bool operator==(const Result& a, const Result& b) {
136 return a.raw == b.raw; 136 return a.raw == b.raw;
137} 137}
138 138
139[[nodiscard]] constexpr bool operator!=(const ResultCode& a, const ResultCode& b) { 139[[nodiscard]] constexpr bool operator!=(const Result& a, const Result& b) {
140 return !operator==(a, b); 140 return !operator==(a, b);
141} 141}
142 142
143// Convenience functions for creating some common kinds of errors: 143// Convenience functions for creating some common kinds of errors:
144 144
145/// The default success `ResultCode`. 145/// The default success `Result`.
146constexpr ResultCode ResultSuccess(0); 146constexpr Result ResultSuccess(0);
147 147
148/** 148/**
149 * Placeholder result code used for unknown error codes. 149 * Placeholder result code used for unknown error codes.
@@ -151,24 +151,24 @@ constexpr ResultCode ResultSuccess(0);
151 * @note This should only be used when a particular error code 151 * @note This should only be used when a particular error code
152 * is not known yet. 152 * is not known yet.
153 */ 153 */
154constexpr ResultCode ResultUnknown(UINT32_MAX); 154constexpr Result ResultUnknown(UINT32_MAX);
155 155
156/** 156/**
157 * A ResultRange defines an inclusive range of error descriptions within an error module. 157 * A ResultRange defines an inclusive range of error descriptions within an error module.
158 * This can be used to check whether the description of a given ResultCode falls within the range. 158 * This can be used to check whether the description of a given Result falls within the range.
159 * The conversion function returns a ResultCode with its description set to description_start. 159 * The conversion function returns a Result with its description set to description_start.
160 * 160 *
161 * An example of how it could be used: 161 * An example of how it could be used:
162 * \code 162 * \code
163 * constexpr ResultRange ResultCommonError{ErrorModule::Common, 0, 9999}; 163 * constexpr ResultRange ResultCommonError{ErrorModule::Common, 0, 9999};
164 * 164 *
165 * ResultCode Example(int value) { 165 * Result Example(int value) {
166 * const ResultCode result = OtherExample(value); 166 * const Result result = OtherExample(value);
167 * 167 *
168 * // This will only evaluate to true if result.module is ErrorModule::Common and 168 * // This will only evaluate to true if result.module is ErrorModule::Common and
169 * // result.description is in between 0 and 9999 inclusive. 169 * // result.description is in between 0 and 9999 inclusive.
170 * if (ResultCommonError.Includes(result)) { 170 * if (ResultCommonError.Includes(result)) {
171 * // This returns ResultCode{ErrorModule::Common, 0}; 171 * // This returns Result{ErrorModule::Common, 0};
172 * return ResultCommonError; 172 * return ResultCommonError;
173 * } 173 * }
174 * 174 *
@@ -181,22 +181,22 @@ public:
181 consteval ResultRange(ErrorModule module, u32 description_start, u32 description_end_) 181 consteval ResultRange(ErrorModule module, u32 description_start, u32 description_end_)
182 : code{module, description_start}, description_end{description_end_} {} 182 : code{module, description_start}, description_end{description_end_} {}
183 183
184 [[nodiscard]] constexpr operator ResultCode() const { 184 [[nodiscard]] constexpr operator Result() const {
185 return code; 185 return code;
186 } 186 }
187 187
188 [[nodiscard]] constexpr bool Includes(ResultCode other) const { 188 [[nodiscard]] constexpr bool Includes(Result other) const {
189 return code.module == other.module && code.description <= other.description && 189 return code.module == other.module && code.description <= other.description &&
190 other.description <= description_end; 190 other.description <= description_end;
191 } 191 }
192 192
193private: 193private:
194 ResultCode code; 194 Result code;
195 u32 description_end; 195 u32 description_end;
196}; 196};
197 197
198/** 198/**
199 * This is an optional value type. It holds a `ResultCode` and, if that code is ResultSuccess, it 199 * This is an optional value type. It holds a `Result` and, if that code is ResultSuccess, it
200 * also holds a result of type `T`. If the code is an error code (not ResultSuccess), then trying 200 * also holds a result of type `T`. If the code is an error code (not ResultSuccess), then trying
201 * to access the inner value with operator* is undefined behavior and will assert with Unwrap(). 201 * to access the inner value with operator* is undefined behavior and will assert with Unwrap().
202 * Users of this class must be cognizant to check the status of the ResultVal with operator bool(), 202 * Users of this class must be cognizant to check the status of the ResultVal with operator bool(),
@@ -207,7 +207,7 @@ private:
207 * ResultVal<int> Frobnicate(float strength) { 207 * ResultVal<int> Frobnicate(float strength) {
208 * if (strength < 0.f || strength > 1.0f) { 208 * if (strength < 0.f || strength > 1.0f) {
209 * // Can't frobnicate too weakly or too strongly 209 * // Can't frobnicate too weakly or too strongly
210 * return ResultCode{ErrorModule::Common, 1}; 210 * return Result{ErrorModule::Common, 1};
211 * } else { 211 * } else {
212 * // Frobnicated! Give caller a cookie 212 * // Frobnicated! Give caller a cookie
213 * return 42; 213 * return 42;
@@ -230,7 +230,7 @@ class ResultVal {
230public: 230public:
231 constexpr ResultVal() : expected{} {} 231 constexpr ResultVal() : expected{} {}
232 232
233 constexpr ResultVal(ResultCode code) : expected{Common::Unexpected(code)} {} 233 constexpr ResultVal(Result code) : expected{Common::Unexpected(code)} {}
234 234
235 constexpr ResultVal(ResultRange range) : expected{Common::Unexpected(range)} {} 235 constexpr ResultVal(ResultRange range) : expected{Common::Unexpected(range)} {}
236 236
@@ -252,7 +252,7 @@ public:
252 return expected.has_value(); 252 return expected.has_value();
253 } 253 }
254 254
255 [[nodiscard]] constexpr ResultCode Code() const { 255 [[nodiscard]] constexpr Result Code() const {
256 return expected.has_value() ? ResultSuccess : expected.error(); 256 return expected.has_value() ? ResultSuccess : expected.error();
257 } 257 }
258 258
@@ -320,7 +320,7 @@ public:
320 320
321private: 321private:
322 // TODO (Morph): Replace this with C++23 std::expected. 322 // TODO (Morph): Replace this with C++23 std::expected.
323 Common::Expected<T, ResultCode> expected; 323 Common::Expected<T, Result> expected;
324}; 324};
325 325
326/** 326/**
@@ -337,7 +337,7 @@ private:
337 target = std::move(*CONCAT2(check_result_L, __LINE__)) 337 target = std::move(*CONCAT2(check_result_L, __LINE__))
338 338
339/** 339/**
340 * Analogous to CASCADE_RESULT, but for a bare ResultCode. The code will be propagated if 340 * Analogous to CASCADE_RESULT, but for a bare Result. The code will be propagated if
341 * non-success, or discarded otherwise. 341 * non-success, or discarded otherwise.
342 */ 342 */
343#define CASCADE_CODE(source) \ 343#define CASCADE_CODE(source) \
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 88b74cbb0..b726ac27a 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -28,11 +28,11 @@
28 28
29namespace Service::Account { 29namespace Service::Account {
30 30
31constexpr ResultCode ERR_INVALID_USER_ID{ErrorModule::Account, 20}; 31constexpr Result ERR_INVALID_USER_ID{ErrorModule::Account, 20};
32constexpr ResultCode ERR_INVALID_APPLICATION_ID{ErrorModule::Account, 22}; 32constexpr Result ERR_INVALID_APPLICATION_ID{ErrorModule::Account, 22};
33constexpr ResultCode ERR_INVALID_BUFFER{ErrorModule::Account, 30}; 33constexpr Result ERR_INVALID_BUFFER{ErrorModule::Account, 30};
34constexpr ResultCode ERR_INVALID_BUFFER_SIZE{ErrorModule::Account, 31}; 34constexpr Result ERR_INVALID_BUFFER_SIZE{ErrorModule::Account, 31};
35constexpr ResultCode ERR_FAILED_SAVE_DATA{ErrorModule::Account, 100}; 35constexpr Result ERR_FAILED_SAVE_DATA{ErrorModule::Account, 100};
36 36
37// Thumbnails are hard coded to be at least this size 37// Thumbnails are hard coded to be at least this size
38constexpr std::size_t THUMBNAIL_SIZE = 0x24000; 38constexpr std::size_t THUMBNAIL_SIZE = 0x24000;
@@ -505,7 +505,7 @@ protected:
505 505
506 void Cancel() override {} 506 void Cancel() override {}
507 507
508 ResultCode GetResult() const override { 508 Result GetResult() const override {
509 return ResultSuccess; 509 return ResultSuccess;
510 } 510 }
511}; 511};
@@ -747,7 +747,7 @@ void Module::Interface::InitializeApplicationInfoRestricted(Kernel::HLERequestCo
747 rb.Push(InitializeApplicationInfoBase()); 747 rb.Push(InitializeApplicationInfoBase());
748} 748}
749 749
750ResultCode Module::Interface::InitializeApplicationInfoBase() { 750Result Module::Interface::InitializeApplicationInfoBase() {
751 if (application_info) { 751 if (application_info) {
752 LOG_ERROR(Service_ACC, "Application already initialized"); 752 LOG_ERROR(Service_ACC, "Application already initialized");
753 return ERR_ACCOUNTINFO_ALREADY_INITIALIZED; 753 return ERR_ACCOUNTINFO_ALREADY_INITIALIZED;
diff --git a/src/core/hle/service/acc/acc.h b/src/core/hle/service/acc/acc.h
index fff447fc3..1621e7c0a 100644
--- a/src/core/hle/service/acc/acc.h
+++ b/src/core/hle/service/acc/acc.h
@@ -41,7 +41,7 @@ public:
41 void StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& ctx); 41 void StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& ctx);
42 42
43 private: 43 private:
44 ResultCode InitializeApplicationInfoBase(); 44 Result InitializeApplicationInfoBase();
45 void StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx, const Common::UUID& uuid, 45 void StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx, const Common::UUID& uuid,
46 const u64 tid); 46 const u64 tid);
47 47
diff --git a/src/core/hle/service/acc/async_context.h b/src/core/hle/service/acc/async_context.h
index e4929f7f0..26332d241 100644
--- a/src/core/hle/service/acc/async_context.h
+++ b/src/core/hle/service/acc/async_context.h
@@ -26,7 +26,7 @@ public:
26protected: 26protected:
27 virtual bool IsComplete() const = 0; 27 virtual bool IsComplete() const = 0;
28 virtual void Cancel() = 0; 28 virtual void Cancel() = 0;
29 virtual ResultCode GetResult() const = 0; 29 virtual Result GetResult() const = 0;
30 30
31 void MarkComplete(); 31 void MarkComplete();
32 32
diff --git a/src/core/hle/service/acc/errors.h b/src/core/hle/service/acc/errors.h
index eafb75713..e9c16b951 100644
--- a/src/core/hle/service/acc/errors.h
+++ b/src/core/hle/service/acc/errors.h
@@ -7,7 +7,7 @@
7 7
8namespace Service::Account { 8namespace Service::Account {
9 9
10constexpr ResultCode ERR_ACCOUNTINFO_BAD_APPLICATION{ErrorModule::Account, 22}; 10constexpr Result ERR_ACCOUNTINFO_BAD_APPLICATION{ErrorModule::Account, 22};
11constexpr ResultCode ERR_ACCOUNTINFO_ALREADY_INITIALIZED{ErrorModule::Account, 41}; 11constexpr Result ERR_ACCOUNTINFO_ALREADY_INITIALIZED{ErrorModule::Account, 41};
12 12
13} // namespace Service::Account 13} // namespace Service::Account
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp
index 0ef298180..8118ead33 100644
--- a/src/core/hle/service/acc/profile_manager.cpp
+++ b/src/core/hle/service/acc/profile_manager.cpp
@@ -33,9 +33,9 @@ struct ProfileDataRaw {
33static_assert(sizeof(ProfileDataRaw) == 0x650, "ProfileDataRaw has incorrect size."); 33static_assert(sizeof(ProfileDataRaw) == 0x650, "ProfileDataRaw has incorrect size.");
34 34
35// TODO(ogniK): Get actual error codes 35// TODO(ogniK): Get actual error codes
36constexpr ResultCode ERROR_TOO_MANY_USERS(ErrorModule::Account, u32(-1)); 36constexpr Result ERROR_TOO_MANY_USERS(ErrorModule::Account, u32(-1));
37constexpr ResultCode ERROR_USER_ALREADY_EXISTS(ErrorModule::Account, u32(-2)); 37constexpr Result ERROR_USER_ALREADY_EXISTS(ErrorModule::Account, u32(-2));
38constexpr ResultCode ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20); 38constexpr Result ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20);
39 39
40constexpr char ACC_SAVE_AVATORS_BASE_PATH[] = "system/save/8000000000000010/su/avators"; 40constexpr char ACC_SAVE_AVATORS_BASE_PATH[] = "system/save/8000000000000010/su/avators";
41 41
@@ -87,7 +87,7 @@ bool ProfileManager::RemoveProfileAtIndex(std::size_t index) {
87} 87}
88 88
89/// Helper function to register a user to the system 89/// Helper function to register a user to the system
90ResultCode ProfileManager::AddUser(const ProfileInfo& user) { 90Result ProfileManager::AddUser(const ProfileInfo& user) {
91 if (!AddToProfiles(user)) { 91 if (!AddToProfiles(user)) {
92 return ERROR_TOO_MANY_USERS; 92 return ERROR_TOO_MANY_USERS;
93 } 93 }
@@ -96,7 +96,7 @@ ResultCode ProfileManager::AddUser(const ProfileInfo& user) {
96 96
97/// Create a new user on the system. If the uuid of the user already exists, the user is not 97/// Create a new user on the system. If the uuid of the user already exists, the user is not
98/// created. 98/// created.
99ResultCode ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& username) { 99Result ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& username) {
100 if (user_count == MAX_USERS) { 100 if (user_count == MAX_USERS) {
101 return ERROR_TOO_MANY_USERS; 101 return ERROR_TOO_MANY_USERS;
102 } 102 }
@@ -123,7 +123,7 @@ ResultCode ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& usern
123/// Creates a new user on the system. This function allows a much simpler method of registration 123/// Creates a new user on the system. This function allows a much simpler method of registration
124/// specifically by allowing an std::string for the username. This is required specifically since 124/// specifically by allowing an std::string for the username. This is required specifically since
125/// we're loading a string straight from the config 125/// we're loading a string straight from the config
126ResultCode ProfileManager::CreateNewUser(UUID uuid, const std::string& username) { 126Result ProfileManager::CreateNewUser(UUID uuid, const std::string& username) {
127 ProfileUsername username_output{}; 127 ProfileUsername username_output{};
128 128
129 if (username.size() > username_output.size()) { 129 if (username.size() > username_output.size()) {
diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h
index 955dbd3d6..9940957f1 100644
--- a/src/core/hle/service/acc/profile_manager.h
+++ b/src/core/hle/service/acc/profile_manager.h
@@ -64,9 +64,9 @@ public:
64 ProfileManager(); 64 ProfileManager();
65 ~ProfileManager(); 65 ~ProfileManager();
66 66
67 ResultCode AddUser(const ProfileInfo& user); 67 Result AddUser(const ProfileInfo& user);
68 ResultCode CreateNewUser(Common::UUID uuid, const ProfileUsername& username); 68 Result CreateNewUser(Common::UUID uuid, const ProfileUsername& username);
69 ResultCode CreateNewUser(Common::UUID uuid, const std::string& username); 69 Result CreateNewUser(Common::UUID uuid, const std::string& username);
70 std::optional<Common::UUID> GetUser(std::size_t index) const; 70 std::optional<Common::UUID> GetUser(std::size_t index) const;
71 std::optional<std::size_t> GetUserIndex(const Common::UUID& uuid) const; 71 std::optional<std::size_t> GetUserIndex(const Common::UUID& uuid) const;
72 std::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const; 72 std::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const;
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index c4a93e524..d35644e73 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -40,9 +40,9 @@
40 40
41namespace Service::AM { 41namespace Service::AM {
42 42
43constexpr ResultCode ERR_NO_DATA_IN_CHANNEL{ErrorModule::AM, 2}; 43constexpr Result ERR_NO_DATA_IN_CHANNEL{ErrorModule::AM, 2};
44constexpr ResultCode ERR_NO_MESSAGES{ErrorModule::AM, 3}; 44constexpr Result ERR_NO_MESSAGES{ErrorModule::AM, 3};
45constexpr ResultCode ERR_SIZE_OUT_OF_BOUNDS{ErrorModule::AM, 503}; 45constexpr Result ERR_SIZE_OUT_OF_BOUNDS{ErrorModule::AM, 503};
46 46
47enum class LaunchParameterKind : u32 { 47enum class LaunchParameterKind : u32 {
48 ApplicationSpecific = 1, 48 ApplicationSpecific = 1,
@@ -365,7 +365,7 @@ void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) {
365 // Entry and exit of fatal sections must be balanced. 365 // Entry and exit of fatal sections must be balanced.
366 if (num_fatal_sections_entered == 0) { 366 if (num_fatal_sections_entered == 0) {
367 IPC::ResponseBuilder rb{ctx, 2}; 367 IPC::ResponseBuilder rb{ctx, 2};
368 rb.Push(ResultCode{ErrorModule::AM, 512}); 368 rb.Push(Result{ErrorModule::AM, 512});
369 return; 369 return;
370 } 370 }
371 371
diff --git a/src/core/hle/service/am/applets/applet_controller.cpp b/src/core/hle/service/am/applets/applet_controller.cpp
index 0a5603d18..b418031de 100644
--- a/src/core/hle/service/am/applets/applet_controller.cpp
+++ b/src/core/hle/service/am/applets/applet_controller.cpp
@@ -20,9 +20,9 @@
20namespace Service::AM::Applets { 20namespace Service::AM::Applets {
21 21
22// This error code (0x183ACA) is thrown when the applet fails to initialize. 22// This error code (0x183ACA) is thrown when the applet fails to initialize.
23[[maybe_unused]] constexpr ResultCode ERR_CONTROLLER_APPLET_3101{ErrorModule::HID, 3101}; 23[[maybe_unused]] constexpr Result ERR_CONTROLLER_APPLET_3101{ErrorModule::HID, 3101};
24// This error code (0x183CCA) is thrown when the u32 result in ControllerSupportResultInfo is 2. 24// This error code (0x183CCA) is thrown when the u32 result in ControllerSupportResultInfo is 2.
25[[maybe_unused]] constexpr ResultCode ERR_CONTROLLER_APPLET_3102{ErrorModule::HID, 3102}; 25[[maybe_unused]] constexpr Result ERR_CONTROLLER_APPLET_3102{ErrorModule::HID, 3102};
26 26
27static Core::Frontend::ControllerParameters ConvertToFrontendParameters( 27static Core::Frontend::ControllerParameters ConvertToFrontendParameters(
28 ControllerSupportArgPrivate private_arg, ControllerSupportArgHeader header, bool enable_text, 28 ControllerSupportArgPrivate private_arg, ControllerSupportArgHeader header, bool enable_text,
@@ -173,7 +173,7 @@ bool Controller::TransactionComplete() const {
173 return complete; 173 return complete;
174} 174}
175 175
176ResultCode Controller::GetStatus() const { 176Result Controller::GetStatus() const {
177 return status; 177 return status;
178} 178}
179 179
diff --git a/src/core/hle/service/am/applets/applet_controller.h b/src/core/hle/service/am/applets/applet_controller.h
index e1a34853d..1f9adec65 100644
--- a/src/core/hle/service/am/applets/applet_controller.h
+++ b/src/core/hle/service/am/applets/applet_controller.h
@@ -126,7 +126,7 @@ public:
126 void Initialize() override; 126 void Initialize() override;
127 127
128 bool TransactionComplete() const override; 128 bool TransactionComplete() const override;
129 ResultCode GetStatus() const override; 129 Result GetStatus() const override;
130 void ExecuteInteractive() override; 130 void ExecuteInteractive() override;
131 void Execute() override; 131 void Execute() override;
132 132
@@ -143,7 +143,7 @@ private:
143 ControllerUpdateFirmwareArg controller_update_arg; 143 ControllerUpdateFirmwareArg controller_update_arg;
144 ControllerKeyRemappingArg controller_key_remapping_arg; 144 ControllerKeyRemappingArg controller_key_remapping_arg;
145 bool complete{false}; 145 bool complete{false};
146 ResultCode status{ResultSuccess}; 146 Result status{ResultSuccess};
147 bool is_single_mode{false}; 147 bool is_single_mode{false};
148 std::vector<u8> out_data; 148 std::vector<u8> out_data;
149}; 149};
diff --git a/src/core/hle/service/am/applets/applet_error.cpp b/src/core/hle/service/am/applets/applet_error.cpp
index 0b87c60b9..fcf34bf7e 100644
--- a/src/core/hle/service/am/applets/applet_error.cpp
+++ b/src/core/hle/service/am/applets/applet_error.cpp
@@ -25,15 +25,15 @@ struct ErrorCode {
25 }; 25 };
26 } 26 }
27 27
28 static constexpr ErrorCode FromResultCode(ResultCode result) { 28 static constexpr ErrorCode FromResult(Result result) {
29 return { 29 return {
30 .error_category{2000 + static_cast<u32>(result.module.Value())}, 30 .error_category{2000 + static_cast<u32>(result.module.Value())},
31 .error_number{result.description.Value()}, 31 .error_number{result.description.Value()},
32 }; 32 };
33 } 33 }
34 34
35 constexpr ResultCode ToResultCode() const { 35 constexpr Result ToResult() const {
36 return ResultCode{static_cast<ErrorModule>(error_category - 2000), error_number}; 36 return Result{static_cast<ErrorModule>(error_category - 2000), error_number};
37 } 37 }
38}; 38};
39static_assert(sizeof(ErrorCode) == 0x8, "ErrorCode has incorrect size."); 39static_assert(sizeof(ErrorCode) == 0x8, "ErrorCode has incorrect size.");
@@ -97,8 +97,8 @@ void CopyArgumentData(const std::vector<u8>& data, T& variable) {
97 std::memcpy(&variable, data.data(), sizeof(T)); 97 std::memcpy(&variable, data.data(), sizeof(T));
98} 98}
99 99
100ResultCode Decode64BitError(u64 error) { 100Result Decode64BitError(u64 error) {
101 return ErrorCode::FromU64(error).ToResultCode(); 101 return ErrorCode::FromU64(error).ToResult();
102} 102}
103 103
104} // Anonymous namespace 104} // Anonymous namespace
@@ -127,16 +127,16 @@ void Error::Initialize() {
127 if (args->error.use_64bit_error_code) { 127 if (args->error.use_64bit_error_code) {
128 error_code = Decode64BitError(args->error.error_code_64); 128 error_code = Decode64BitError(args->error.error_code_64);
129 } else { 129 } else {
130 error_code = ResultCode(args->error.error_code_32); 130 error_code = Result(args->error.error_code_32);
131 } 131 }
132 break; 132 break;
133 case ErrorAppletMode::ShowSystemError: 133 case ErrorAppletMode::ShowSystemError:
134 CopyArgumentData(data, args->system_error); 134 CopyArgumentData(data, args->system_error);
135 error_code = ResultCode(Decode64BitError(args->system_error.error_code_64)); 135 error_code = Result(Decode64BitError(args->system_error.error_code_64));
136 break; 136 break;
137 case ErrorAppletMode::ShowApplicationError: 137 case ErrorAppletMode::ShowApplicationError:
138 CopyArgumentData(data, args->application_error); 138 CopyArgumentData(data, args->application_error);
139 error_code = ResultCode(args->application_error.error_code); 139 error_code = Result(args->application_error.error_code);
140 break; 140 break;
141 case ErrorAppletMode::ShowErrorRecord: 141 case ErrorAppletMode::ShowErrorRecord:
142 CopyArgumentData(data, args->error_record); 142 CopyArgumentData(data, args->error_record);
@@ -151,7 +151,7 @@ bool Error::TransactionComplete() const {
151 return complete; 151 return complete;
152} 152}
153 153
154ResultCode Error::GetStatus() const { 154Result Error::GetStatus() const {
155 return ResultSuccess; 155 return ResultSuccess;
156} 156}
157 157
diff --git a/src/core/hle/service/am/applets/applet_error.h b/src/core/hle/service/am/applets/applet_error.h
index 43487f647..d78d6f1d1 100644
--- a/src/core/hle/service/am/applets/applet_error.h
+++ b/src/core/hle/service/am/applets/applet_error.h
@@ -31,7 +31,7 @@ public:
31 void Initialize() override; 31 void Initialize() override;
32 32
33 bool TransactionComplete() const override; 33 bool TransactionComplete() const override;
34 ResultCode GetStatus() const override; 34 Result GetStatus() const override;
35 void ExecuteInteractive() override; 35 void ExecuteInteractive() override;
36 void Execute() override; 36 void Execute() override;
37 37
@@ -41,7 +41,7 @@ private:
41 union ErrorArguments; 41 union ErrorArguments;
42 42
43 const Core::Frontend::ErrorApplet& frontend; 43 const Core::Frontend::ErrorApplet& frontend;
44 ResultCode error_code = ResultSuccess; 44 Result error_code = ResultSuccess;
45 ErrorAppletMode mode = ErrorAppletMode::ShowError; 45 ErrorAppletMode mode = ErrorAppletMode::ShowError;
46 std::unique_ptr<ErrorArguments> args; 46 std::unique_ptr<ErrorArguments> args;
47 47
diff --git a/src/core/hle/service/am/applets/applet_general_backend.cpp b/src/core/hle/service/am/applets/applet_general_backend.cpp
index 41c002ef2..c34ef08b3 100644
--- a/src/core/hle/service/am/applets/applet_general_backend.cpp
+++ b/src/core/hle/service/am/applets/applet_general_backend.cpp
@@ -13,7 +13,7 @@
13 13
14namespace Service::AM::Applets { 14namespace Service::AM::Applets {
15 15
16constexpr ResultCode ERROR_INVALID_PIN{ErrorModule::PCTL, 221}; 16constexpr Result ERROR_INVALID_PIN{ErrorModule::PCTL, 221};
17 17
18static void LogCurrentStorage(AppletDataBroker& broker, std::string_view prefix) { 18static void LogCurrentStorage(AppletDataBroker& broker, std::string_view prefix) {
19 std::shared_ptr<IStorage> storage = broker.PopNormalDataToApplet(); 19 std::shared_ptr<IStorage> storage = broker.PopNormalDataToApplet();
@@ -71,7 +71,7 @@ bool Auth::TransactionComplete() const {
71 return complete; 71 return complete;
72} 72}
73 73
74ResultCode Auth::GetStatus() const { 74Result Auth::GetStatus() const {
75 return successful ? ResultSuccess : ERROR_INVALID_PIN; 75 return successful ? ResultSuccess : ERROR_INVALID_PIN;
76} 76}
77 77
@@ -136,7 +136,7 @@ void Auth::AuthFinished(bool is_successful) {
136 successful = is_successful; 136 successful = is_successful;
137 137
138 struct Return { 138 struct Return {
139 ResultCode result_code; 139 Result result_code;
140 }; 140 };
141 static_assert(sizeof(Return) == 0x4, "Return (AuthApplet) has incorrect size."); 141 static_assert(sizeof(Return) == 0x4, "Return (AuthApplet) has incorrect size.");
142 142
@@ -170,7 +170,7 @@ bool PhotoViewer::TransactionComplete() const {
170 return complete; 170 return complete;
171} 171}
172 172
173ResultCode PhotoViewer::GetStatus() const { 173Result PhotoViewer::GetStatus() const {
174 return ResultSuccess; 174 return ResultSuccess;
175} 175}
176 176
@@ -223,7 +223,7 @@ bool StubApplet::TransactionComplete() const {
223 return true; 223 return true;
224} 224}
225 225
226ResultCode StubApplet::GetStatus() const { 226Result StubApplet::GetStatus() const {
227 LOG_WARNING(Service_AM, "called (STUBBED)"); 227 LOG_WARNING(Service_AM, "called (STUBBED)");
228 return ResultSuccess; 228 return ResultSuccess;
229} 229}
diff --git a/src/core/hle/service/am/applets/applet_general_backend.h b/src/core/hle/service/am/applets/applet_general_backend.h
index e647d0f41..a9f2535a2 100644
--- a/src/core/hle/service/am/applets/applet_general_backend.h
+++ b/src/core/hle/service/am/applets/applet_general_backend.h
@@ -25,7 +25,7 @@ public:
25 25
26 void Initialize() override; 26 void Initialize() override;
27 bool TransactionComplete() const override; 27 bool TransactionComplete() const override;
28 ResultCode GetStatus() const override; 28 Result GetStatus() const override;
29 void ExecuteInteractive() override; 29 void ExecuteInteractive() override;
30 void Execute() override; 30 void Execute() override;
31 31
@@ -56,7 +56,7 @@ public:
56 56
57 void Initialize() override; 57 void Initialize() override;
58 bool TransactionComplete() const override; 58 bool TransactionComplete() const override;
59 ResultCode GetStatus() const override; 59 Result GetStatus() const override;
60 void ExecuteInteractive() override; 60 void ExecuteInteractive() override;
61 void Execute() override; 61 void Execute() override;
62 62
@@ -77,7 +77,7 @@ public:
77 void Initialize() override; 77 void Initialize() override;
78 78
79 bool TransactionComplete() const override; 79 bool TransactionComplete() const override;
80 ResultCode GetStatus() const override; 80 Result GetStatus() const override;
81 void ExecuteInteractive() override; 81 void ExecuteInteractive() override;
82 void Execute() override; 82 void Execute() override;
83 83
diff --git a/src/core/hle/service/am/applets/applet_mii_edit.cpp b/src/core/hle/service/am/applets/applet_mii_edit.cpp
index 8d847c3f6..ae80ef506 100644
--- a/src/core/hle/service/am/applets/applet_mii_edit.cpp
+++ b/src/core/hle/service/am/applets/applet_mii_edit.cpp
@@ -62,7 +62,7 @@ bool MiiEdit::TransactionComplete() const {
62 return is_complete; 62 return is_complete;
63} 63}
64 64
65ResultCode MiiEdit::GetStatus() const { 65Result MiiEdit::GetStatus() const {
66 return ResultSuccess; 66 return ResultSuccess;
67} 67}
68 68
diff --git a/src/core/hle/service/am/applets/applet_mii_edit.h b/src/core/hle/service/am/applets/applet_mii_edit.h
index 900754e57..d18dd3cf5 100644
--- a/src/core/hle/service/am/applets/applet_mii_edit.h
+++ b/src/core/hle/service/am/applets/applet_mii_edit.h
@@ -22,7 +22,7 @@ public:
22 void Initialize() override; 22 void Initialize() override;
23 23
24 bool TransactionComplete() const override; 24 bool TransactionComplete() const override;
25 ResultCode GetStatus() const override; 25 Result GetStatus() const override;
26 void ExecuteInteractive() override; 26 void ExecuteInteractive() override;
27 void Execute() override; 27 void Execute() override;
28 28
diff --git a/src/core/hle/service/am/applets/applet_profile_select.cpp b/src/core/hle/service/am/applets/applet_profile_select.cpp
index 02049fd9f..c738db028 100644
--- a/src/core/hle/service/am/applets/applet_profile_select.cpp
+++ b/src/core/hle/service/am/applets/applet_profile_select.cpp
@@ -12,7 +12,7 @@
12 12
13namespace Service::AM::Applets { 13namespace Service::AM::Applets {
14 14
15constexpr ResultCode ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1}; 15constexpr Result ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1};
16 16
17ProfileSelect::ProfileSelect(Core::System& system_, LibraryAppletMode applet_mode_, 17ProfileSelect::ProfileSelect(Core::System& system_, LibraryAppletMode applet_mode_,
18 const Core::Frontend::ProfileSelectApplet& frontend_) 18 const Core::Frontend::ProfileSelectApplet& frontend_)
@@ -39,7 +39,7 @@ bool ProfileSelect::TransactionComplete() const {
39 return complete; 39 return complete;
40} 40}
41 41
42ResultCode ProfileSelect::GetStatus() const { 42Result ProfileSelect::GetStatus() const {
43 return status; 43 return status;
44} 44}
45 45
diff --git a/src/core/hle/service/am/applets/applet_profile_select.h b/src/core/hle/service/am/applets/applet_profile_select.h
index 3a6e50eaa..b77f1d205 100644
--- a/src/core/hle/service/am/applets/applet_profile_select.h
+++ b/src/core/hle/service/am/applets/applet_profile_select.h
@@ -39,7 +39,7 @@ public:
39 void Initialize() override; 39 void Initialize() override;
40 40
41 bool TransactionComplete() const override; 41 bool TransactionComplete() const override;
42 ResultCode GetStatus() const override; 42 Result GetStatus() const override;
43 void ExecuteInteractive() override; 43 void ExecuteInteractive() override;
44 void Execute() override; 44 void Execute() override;
45 45
@@ -50,7 +50,7 @@ private:
50 50
51 UserSelectionConfig config; 51 UserSelectionConfig config;
52 bool complete = false; 52 bool complete = false;
53 ResultCode status = ResultSuccess; 53 Result status = ResultSuccess;
54 std::vector<u8> final_data; 54 std::vector<u8> final_data;
55 Core::System& system; 55 Core::System& system;
56}; 56};
diff --git a/src/core/hle/service/am/applets/applet_software_keyboard.cpp b/src/core/hle/service/am/applets/applet_software_keyboard.cpp
index 4116fbaa7..faa092957 100644
--- a/src/core/hle/service/am/applets/applet_software_keyboard.cpp
+++ b/src/core/hle/service/am/applets/applet_software_keyboard.cpp
@@ -80,7 +80,7 @@ bool SoftwareKeyboard::TransactionComplete() const {
80 return complete; 80 return complete;
81} 81}
82 82
83ResultCode SoftwareKeyboard::GetStatus() const { 83Result SoftwareKeyboard::GetStatus() const {
84 return status; 84 return status;
85} 85}
86 86
diff --git a/src/core/hle/service/am/applets/applet_software_keyboard.h b/src/core/hle/service/am/applets/applet_software_keyboard.h
index c36806a72..b01b31c98 100644
--- a/src/core/hle/service/am/applets/applet_software_keyboard.h
+++ b/src/core/hle/service/am/applets/applet_software_keyboard.h
@@ -28,7 +28,7 @@ public:
28 void Initialize() override; 28 void Initialize() override;
29 29
30 bool TransactionComplete() const override; 30 bool TransactionComplete() const override;
31 ResultCode GetStatus() const override; 31 Result GetStatus() const override;
32 void ExecuteInteractive() override; 32 void ExecuteInteractive() override;
33 void Execute() override; 33 void Execute() override;
34 34
@@ -180,7 +180,7 @@ private:
180 bool is_background{false}; 180 bool is_background{false};
181 181
182 bool complete{false}; 182 bool complete{false};
183 ResultCode status{ResultSuccess}; 183 Result status{ResultSuccess};
184}; 184};
185 185
186} // namespace Service::AM::Applets 186} // namespace Service::AM::Applets
diff --git a/src/core/hle/service/am/applets/applet_web_browser.cpp b/src/core/hle/service/am/applets/applet_web_browser.cpp
index 7b3f77a51..4b804b78c 100644
--- a/src/core/hle/service/am/applets/applet_web_browser.cpp
+++ b/src/core/hle/service/am/applets/applet_web_browser.cpp
@@ -288,7 +288,7 @@ bool WebBrowser::TransactionComplete() const {
288 return complete; 288 return complete;
289} 289}
290 290
291ResultCode WebBrowser::GetStatus() const { 291Result WebBrowser::GetStatus() const {
292 return status; 292 return status;
293} 293}
294 294
diff --git a/src/core/hle/service/am/applets/applet_web_browser.h b/src/core/hle/service/am/applets/applet_web_browser.h
index 6b602769b..fd727fac8 100644
--- a/src/core/hle/service/am/applets/applet_web_browser.h
+++ b/src/core/hle/service/am/applets/applet_web_browser.h
@@ -32,7 +32,7 @@ public:
32 void Initialize() override; 32 void Initialize() override;
33 33
34 bool TransactionComplete() const override; 34 bool TransactionComplete() const override;
35 ResultCode GetStatus() const override; 35 Result GetStatus() const override;
36 void ExecuteInteractive() override; 36 void ExecuteInteractive() override;
37 void Execute() override; 37 void Execute() override;
38 38
@@ -66,7 +66,7 @@ private:
66 const Core::Frontend::WebBrowserApplet& frontend; 66 const Core::Frontend::WebBrowserApplet& frontend;
67 67
68 bool complete{false}; 68 bool complete{false};
69 ResultCode status{ResultSuccess}; 69 Result status{ResultSuccess};
70 70
71 WebAppletVersion web_applet_version{}; 71 WebAppletVersion web_applet_version{};
72 WebArgHeader web_arg_header{}; 72 WebArgHeader web_arg_header{};
diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h
index 2861fed0e..e78a57657 100644
--- a/src/core/hle/service/am/applets/applets.h
+++ b/src/core/hle/service/am/applets/applets.h
@@ -9,7 +9,7 @@
9#include "common/swap.h" 9#include "common/swap.h"
10#include "core/hle/service/kernel_helpers.h" 10#include "core/hle/service/kernel_helpers.h"
11 11
12union ResultCode; 12union Result;
13 13
14namespace Core { 14namespace Core {
15class System; 15class System;
@@ -138,7 +138,7 @@ public:
138 virtual void Initialize(); 138 virtual void Initialize();
139 139
140 virtual bool TransactionComplete() const = 0; 140 virtual bool TransactionComplete() const = 0;
141 virtual ResultCode GetStatus() const = 0; 141 virtual Result GetStatus() const = 0;
142 virtual void ExecuteInteractive() = 0; 142 virtual void ExecuteInteractive() = 0;
143 virtual void Execute() = 0; 143 virtual void Execute() = 0;
144 144
diff --git a/src/core/hle/service/audio/errors.h b/src/core/hle/service/audio/errors.h
index 542fec899..ac6c514af 100644
--- a/src/core/hle/service/audio/errors.h
+++ b/src/core/hle/service/audio/errors.h
@@ -7,8 +7,8 @@
7 7
8namespace Service::Audio { 8namespace Service::Audio {
9 9
10constexpr ResultCode ERR_OPERATION_FAILED{ErrorModule::Audio, 2}; 10constexpr Result ERR_OPERATION_FAILED{ErrorModule::Audio, 2};
11constexpr ResultCode ERR_BUFFER_COUNT_EXCEEDED{ErrorModule::Audio, 8}; 11constexpr Result ERR_BUFFER_COUNT_EXCEEDED{ErrorModule::Audio, 8};
12constexpr ResultCode ERR_NOT_SUPPORTED{ErrorModule::Audio, 513}; 12constexpr Result ERR_NOT_SUPPORTED{ErrorModule::Audio, 513};
13 13
14} // namespace Service::Audio 14} // namespace Service::Audio
diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp
index 7e6d16230..cd0b405ff 100644
--- a/src/core/hle/service/bcat/backend/backend.cpp
+++ b/src/core/hle/service/bcat/backend/backend.cpp
@@ -74,7 +74,7 @@ void ProgressServiceBackend::CommitDirectory(std::string_view dir_name) {
74 SignalUpdate(); 74 SignalUpdate();
75} 75}
76 76
77void ProgressServiceBackend::FinishDownload(ResultCode result) { 77void ProgressServiceBackend::FinishDownload(Result result) {
78 impl.total_downloaded_bytes = impl.total_bytes; 78 impl.total_downloaded_bytes = impl.total_bytes;
79 impl.status = DeliveryCacheProgressImpl::Status::Done; 79 impl.status = DeliveryCacheProgressImpl::Status::Done;
80 impl.result = result; 80 impl.result = result;
diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h
index 7e8026c75..205ed0702 100644
--- a/src/core/hle/service/bcat/backend/backend.h
+++ b/src/core/hle/service/bcat/backend/backend.h
@@ -49,7 +49,7 @@ struct DeliveryCacheProgressImpl {
49 }; 49 };
50 50
51 Status status; 51 Status status;
52 ResultCode result = ResultSuccess; 52 Result result = ResultSuccess;
53 DirectoryName current_directory; 53 DirectoryName current_directory;
54 FileName current_file; 54 FileName current_file;
55 s64 current_downloaded_bytes; ///< Bytes downloaded on current file. 55 s64 current_downloaded_bytes; ///< Bytes downloaded on current file.
@@ -90,7 +90,7 @@ public:
90 void CommitDirectory(std::string_view dir_name); 90 void CommitDirectory(std::string_view dir_name);
91 91
92 // Notifies the application that the operation completed with result code result. 92 // Notifies the application that the operation completed with result code result.
93 void FinishDownload(ResultCode result); 93 void FinishDownload(Result result);
94 94
95private: 95private:
96 explicit ProgressServiceBackend(Core::System& system, std::string_view event_name); 96 explicit ProgressServiceBackend(Core::System& system, std::string_view event_name);
diff --git a/src/core/hle/service/bcat/bcat_module.cpp b/src/core/hle/service/bcat/bcat_module.cpp
index 076fd79e7..d928e37fb 100644
--- a/src/core/hle/service/bcat/bcat_module.cpp
+++ b/src/core/hle/service/bcat/bcat_module.cpp
@@ -18,15 +18,15 @@
18 18
19namespace Service::BCAT { 19namespace Service::BCAT {
20 20
21constexpr ResultCode ERROR_INVALID_ARGUMENT{ErrorModule::BCAT, 1}; 21constexpr Result ERROR_INVALID_ARGUMENT{ErrorModule::BCAT, 1};
22constexpr ResultCode ERROR_FAILED_OPEN_ENTITY{ErrorModule::BCAT, 2}; 22constexpr Result ERROR_FAILED_OPEN_ENTITY{ErrorModule::BCAT, 2};
23constexpr ResultCode ERROR_ENTITY_ALREADY_OPEN{ErrorModule::BCAT, 6}; 23constexpr Result ERROR_ENTITY_ALREADY_OPEN{ErrorModule::BCAT, 6};
24constexpr ResultCode ERROR_NO_OPEN_ENTITY{ErrorModule::BCAT, 7}; 24constexpr Result ERROR_NO_OPEN_ENTITY{ErrorModule::BCAT, 7};
25 25
26// The command to clear the delivery cache just calls fs IFileSystem DeleteFile on all of the files 26// The command to clear the delivery cache just calls fs IFileSystem DeleteFile on all of the files
27// and if any of them have a non-zero result it just forwards that result. This is the FS error code 27// and if any of them have a non-zero result it just forwards that result. This is the FS error code
28// for permission denied, which is the closest approximation of this scenario. 28// for permission denied, which is the closest approximation of this scenario.
29constexpr ResultCode ERROR_FAILED_CLEAR_CACHE{ErrorModule::FS, 6400}; 29constexpr Result ERROR_FAILED_CLEAR_CACHE{ErrorModule::FS, 6400};
30 30
31using BCATDigest = std::array<u8, 0x10>; 31using BCATDigest = std::array<u8, 0x10>;
32 32
diff --git a/src/core/hle/service/es/es.cpp b/src/core/hle/service/es/es.cpp
index cbe9d5f7c..ff9b0427c 100644
--- a/src/core/hle/service/es/es.cpp
+++ b/src/core/hle/service/es/es.cpp
@@ -8,8 +8,8 @@
8 8
9namespace Service::ES { 9namespace Service::ES {
10 10
11constexpr ResultCode ERROR_INVALID_ARGUMENT{ErrorModule::ETicket, 2}; 11constexpr Result ERROR_INVALID_ARGUMENT{ErrorModule::ETicket, 2};
12constexpr ResultCode ERROR_INVALID_RIGHTS_ID{ErrorModule::ETicket, 3}; 12constexpr Result ERROR_INVALID_RIGHTS_ID{ErrorModule::ETicket, 3};
13 13
14class ETicket final : public ServiceFramework<ETicket> { 14class ETicket final : public ServiceFramework<ETicket> {
15public: 15public:
diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp
index a99c90479..27675615b 100644
--- a/src/core/hle/service/fatal/fatal.cpp
+++ b/src/core/hle/service/fatal/fatal.cpp
@@ -62,8 +62,7 @@ enum class FatalType : u32 {
62 ErrorScreen = 2, 62 ErrorScreen = 2,
63}; 63};
64 64
65static void GenerateErrorReport(Core::System& system, ResultCode error_code, 65static void GenerateErrorReport(Core::System& system, Result error_code, const FatalInfo& info) {
66 const FatalInfo& info) {
67 const auto title_id = system.GetCurrentProcessProgramID(); 66 const auto title_id = system.GetCurrentProcessProgramID();
68 std::string crash_report = fmt::format( 67 std::string crash_report = fmt::format(
69 "Yuzu {}-{} crash report\n" 68 "Yuzu {}-{} crash report\n"
@@ -106,7 +105,7 @@ static void GenerateErrorReport(Core::System& system, ResultCode error_code,
106 info.backtrace_size, info.ArchAsString(), info.unk10); 105 info.backtrace_size, info.ArchAsString(), info.unk10);
107} 106}
108 107
109static void ThrowFatalError(Core::System& system, ResultCode error_code, FatalType fatal_type, 108static void ThrowFatalError(Core::System& system, Result error_code, FatalType fatal_type,
110 const FatalInfo& info) { 109 const FatalInfo& info) {
111 LOG_ERROR(Service_Fatal, "Threw fatal error type {} with error code 0x{:X}", fatal_type, 110 LOG_ERROR(Service_Fatal, "Threw fatal error type {} with error code 0x{:X}", fatal_type,
112 error_code.raw); 111 error_code.raw);
@@ -129,7 +128,7 @@ static void ThrowFatalError(Core::System& system, ResultCode error_code, FatalTy
129void Module::Interface::ThrowFatal(Kernel::HLERequestContext& ctx) { 128void Module::Interface::ThrowFatal(Kernel::HLERequestContext& ctx) {
130 LOG_ERROR(Service_Fatal, "called"); 129 LOG_ERROR(Service_Fatal, "called");
131 IPC::RequestParser rp{ctx}; 130 IPC::RequestParser rp{ctx};
132 const auto error_code = rp.Pop<ResultCode>(); 131 const auto error_code = rp.Pop<Result>();
133 132
134 ThrowFatalError(system, error_code, FatalType::ErrorScreen, {}); 133 ThrowFatalError(system, error_code, FatalType::ErrorScreen, {});
135 IPC::ResponseBuilder rb{ctx, 2}; 134 IPC::ResponseBuilder rb{ctx, 2};
@@ -139,7 +138,7 @@ void Module::Interface::ThrowFatal(Kernel::HLERequestContext& ctx) {
139void Module::Interface::ThrowFatalWithPolicy(Kernel::HLERequestContext& ctx) { 138void Module::Interface::ThrowFatalWithPolicy(Kernel::HLERequestContext& ctx) {
140 LOG_ERROR(Service_Fatal, "called"); 139 LOG_ERROR(Service_Fatal, "called");
141 IPC::RequestParser rp(ctx); 140 IPC::RequestParser rp(ctx);
142 const auto error_code = rp.Pop<ResultCode>(); 141 const auto error_code = rp.Pop<Result>();
143 const auto fatal_type = rp.PopEnum<FatalType>(); 142 const auto fatal_type = rp.PopEnum<FatalType>();
144 143
145 ThrowFatalError(system, error_code, fatal_type, 144 ThrowFatalError(system, error_code, fatal_type,
@@ -151,7 +150,7 @@ void Module::Interface::ThrowFatalWithPolicy(Kernel::HLERequestContext& ctx) {
151void Module::Interface::ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx) { 150void Module::Interface::ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx) {
152 LOG_ERROR(Service_Fatal, "called"); 151 LOG_ERROR(Service_Fatal, "called");
153 IPC::RequestParser rp(ctx); 152 IPC::RequestParser rp(ctx);
154 const auto error_code = rp.Pop<ResultCode>(); 153 const auto error_code = rp.Pop<Result>();
155 const auto fatal_type = rp.PopEnum<FatalType>(); 154 const auto fatal_type = rp.PopEnum<FatalType>();
156 const auto fatal_info = ctx.ReadBuffer(); 155 const auto fatal_info = ctx.ReadBuffer();
157 FatalInfo info{}; 156 FatalInfo info{};
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index f8e7519ca..11c604a0f 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -49,7 +49,7 @@ std::string VfsDirectoryServiceWrapper::GetName() const {
49 return backing->GetName(); 49 return backing->GetName();
50} 50}
51 51
52ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const { 52Result VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const {
53 std::string path(Common::FS::SanitizePath(path_)); 53 std::string path(Common::FS::SanitizePath(path_));
54 auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); 54 auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
55 if (dir == nullptr) { 55 if (dir == nullptr) {
@@ -73,7 +73,7 @@ ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64
73 return ResultSuccess; 73 return ResultSuccess;
74} 74}
75 75
76ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) const { 76Result VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) const {
77 std::string path(Common::FS::SanitizePath(path_)); 77 std::string path(Common::FS::SanitizePath(path_));
78 if (path.empty()) { 78 if (path.empty()) {
79 // TODO(DarkLordZach): Why do games call this and what should it do? Works as is but... 79 // TODO(DarkLordZach): Why do games call this and what should it do? Works as is but...
@@ -92,7 +92,7 @@ ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) cons
92 return ResultSuccess; 92 return ResultSuccess;
93} 93}
94 94
95ResultCode VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) const { 95Result VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) const {
96 std::string path(Common::FS::SanitizePath(path_)); 96 std::string path(Common::FS::SanitizePath(path_));
97 97
98 // NOTE: This is inaccurate behavior. CreateDirectory is not recursive. 98 // NOTE: This is inaccurate behavior. CreateDirectory is not recursive.
@@ -116,7 +116,7 @@ ResultCode VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_)
116 return ResultSuccess; 116 return ResultSuccess;
117} 117}
118 118
119ResultCode VfsDirectoryServiceWrapper::DeleteDirectory(const std::string& path_) const { 119Result VfsDirectoryServiceWrapper::DeleteDirectory(const std::string& path_) const {
120 std::string path(Common::FS::SanitizePath(path_)); 120 std::string path(Common::FS::SanitizePath(path_));
121 auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); 121 auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
122 if (!dir->DeleteSubdirectory(Common::FS::GetFilename(path))) { 122 if (!dir->DeleteSubdirectory(Common::FS::GetFilename(path))) {
@@ -126,7 +126,7 @@ ResultCode VfsDirectoryServiceWrapper::DeleteDirectory(const std::string& path_)
126 return ResultSuccess; 126 return ResultSuccess;
127} 127}
128 128
129ResultCode VfsDirectoryServiceWrapper::DeleteDirectoryRecursively(const std::string& path_) const { 129Result VfsDirectoryServiceWrapper::DeleteDirectoryRecursively(const std::string& path_) const {
130 std::string path(Common::FS::SanitizePath(path_)); 130 std::string path(Common::FS::SanitizePath(path_));
131 auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); 131 auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
132 if (!dir->DeleteSubdirectoryRecursive(Common::FS::GetFilename(path))) { 132 if (!dir->DeleteSubdirectoryRecursive(Common::FS::GetFilename(path))) {
@@ -136,7 +136,7 @@ ResultCode VfsDirectoryServiceWrapper::DeleteDirectoryRecursively(const std::str
136 return ResultSuccess; 136 return ResultSuccess;
137} 137}
138 138
139ResultCode VfsDirectoryServiceWrapper::CleanDirectoryRecursively(const std::string& path) const { 139Result VfsDirectoryServiceWrapper::CleanDirectoryRecursively(const std::string& path) const {
140 const std::string sanitized_path(Common::FS::SanitizePath(path)); 140 const std::string sanitized_path(Common::FS::SanitizePath(path));
141 auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(sanitized_path)); 141 auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(sanitized_path));
142 142
@@ -148,8 +148,8 @@ ResultCode VfsDirectoryServiceWrapper::CleanDirectoryRecursively(const std::stri
148 return ResultSuccess; 148 return ResultSuccess;
149} 149}
150 150
151ResultCode VfsDirectoryServiceWrapper::RenameFile(const std::string& src_path_, 151Result VfsDirectoryServiceWrapper::RenameFile(const std::string& src_path_,
152 const std::string& dest_path_) const { 152 const std::string& dest_path_) const {
153 std::string src_path(Common::FS::SanitizePath(src_path_)); 153 std::string src_path(Common::FS::SanitizePath(src_path_));
154 std::string dest_path(Common::FS::SanitizePath(dest_path_)); 154 std::string dest_path(Common::FS::SanitizePath(dest_path_));
155 auto src = backing->GetFileRelative(src_path); 155 auto src = backing->GetFileRelative(src_path);
@@ -183,8 +183,8 @@ ResultCode VfsDirectoryServiceWrapper::RenameFile(const std::string& src_path_,
183 return ResultSuccess; 183 return ResultSuccess;
184} 184}
185 185
186ResultCode VfsDirectoryServiceWrapper::RenameDirectory(const std::string& src_path_, 186Result VfsDirectoryServiceWrapper::RenameDirectory(const std::string& src_path_,
187 const std::string& dest_path_) const { 187 const std::string& dest_path_) const {
188 std::string src_path(Common::FS::SanitizePath(src_path_)); 188 std::string src_path(Common::FS::SanitizePath(src_path_));
189 std::string dest_path(Common::FS::SanitizePath(dest_path_)); 189 std::string dest_path(Common::FS::SanitizePath(dest_path_));
190 auto src = GetDirectoryRelativeWrapped(backing, src_path); 190 auto src = GetDirectoryRelativeWrapped(backing, src_path);
@@ -273,28 +273,27 @@ FileSystemController::FileSystemController(Core::System& system_) : system{syste
273 273
274FileSystemController::~FileSystemController() = default; 274FileSystemController::~FileSystemController() = default;
275 275
276ResultCode FileSystemController::RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory) { 276Result FileSystemController::RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory) {
277 romfs_factory = std::move(factory); 277 romfs_factory = std::move(factory);
278 LOG_DEBUG(Service_FS, "Registered RomFS"); 278 LOG_DEBUG(Service_FS, "Registered RomFS");
279 return ResultSuccess; 279 return ResultSuccess;
280} 280}
281 281
282ResultCode FileSystemController::RegisterSaveData( 282Result FileSystemController::RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory) {
283 std::unique_ptr<FileSys::SaveDataFactory>&& factory) {
284 ASSERT_MSG(save_data_factory == nullptr, "Tried to register a second save data"); 283 ASSERT_MSG(save_data_factory == nullptr, "Tried to register a second save data");
285 save_data_factory = std::move(factory); 284 save_data_factory = std::move(factory);
286 LOG_DEBUG(Service_FS, "Registered save data"); 285 LOG_DEBUG(Service_FS, "Registered save data");
287 return ResultSuccess; 286 return ResultSuccess;
288} 287}
289 288
290ResultCode FileSystemController::RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory) { 289Result FileSystemController::RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory) {
291 ASSERT_MSG(sdmc_factory == nullptr, "Tried to register a second SDMC"); 290 ASSERT_MSG(sdmc_factory == nullptr, "Tried to register a second SDMC");
292 sdmc_factory = std::move(factory); 291 sdmc_factory = std::move(factory);
293 LOG_DEBUG(Service_FS, "Registered SDMC"); 292 LOG_DEBUG(Service_FS, "Registered SDMC");
294 return ResultSuccess; 293 return ResultSuccess;
295} 294}
296 295
297ResultCode FileSystemController::RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory) { 296Result FileSystemController::RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory) {
298 ASSERT_MSG(bis_factory == nullptr, "Tried to register a second BIS"); 297 ASSERT_MSG(bis_factory == nullptr, "Tried to register a second BIS");
299 bis_factory = std::move(factory); 298 bis_factory = std::move(factory);
300 LOG_DEBUG(Service_FS, "Registered BIS"); 299 LOG_DEBUG(Service_FS, "Registered BIS");
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h
index 8dd2652fe..5b27de9fa 100644
--- a/src/core/hle/service/filesystem/filesystem.h
+++ b/src/core/hle/service/filesystem/filesystem.h
@@ -58,10 +58,10 @@ public:
58 explicit FileSystemController(Core::System& system_); 58 explicit FileSystemController(Core::System& system_);
59 ~FileSystemController(); 59 ~FileSystemController();
60 60
61 ResultCode RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory); 61 Result RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory);
62 ResultCode RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory); 62 Result RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory);
63 ResultCode RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory); 63 Result RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory);
64 ResultCode RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory); 64 Result RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory);
65 65
66 void SetPackedUpdate(FileSys::VirtualFile update_raw); 66 void SetPackedUpdate(FileSys::VirtualFile update_raw);
67 ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess() const; 67 ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess() const;
@@ -141,7 +141,7 @@ private:
141 141
142void InstallInterfaces(Core::System& system); 142void InstallInterfaces(Core::System& system);
143 143
144// A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of 144// A class that wraps a VfsDirectory with methods that return ResultVal and Result instead of
145// pointers and booleans. This makes using a VfsDirectory with switch services much easier and 145// pointers and booleans. This makes using a VfsDirectory with switch services much easier and
146// avoids repetitive code. 146// avoids repetitive code.
147class VfsDirectoryServiceWrapper { 147class VfsDirectoryServiceWrapper {
@@ -160,35 +160,35 @@ public:
160 * @param size The size of the new file, filled with zeroes 160 * @param size The size of the new file, filled with zeroes
161 * @return Result of the operation 161 * @return Result of the operation
162 */ 162 */
163 ResultCode CreateFile(const std::string& path, u64 size) const; 163 Result CreateFile(const std::string& path, u64 size) const;
164 164
165 /** 165 /**
166 * Delete a file specified by its path 166 * Delete a file specified by its path
167 * @param path Path relative to the archive 167 * @param path Path relative to the archive
168 * @return Result of the operation 168 * @return Result of the operation
169 */ 169 */
170 ResultCode DeleteFile(const std::string& path) const; 170 Result DeleteFile(const std::string& path) const;
171 171
172 /** 172 /**
173 * Create a directory specified by its path 173 * Create a directory specified by its path
174 * @param path Path relative to the archive 174 * @param path Path relative to the archive
175 * @return Result of the operation 175 * @return Result of the operation
176 */ 176 */
177 ResultCode CreateDirectory(const std::string& path) const; 177 Result CreateDirectory(const std::string& path) const;
178 178
179 /** 179 /**
180 * Delete a directory specified by its path 180 * Delete a directory specified by its path
181 * @param path Path relative to the archive 181 * @param path Path relative to the archive
182 * @return Result of the operation 182 * @return Result of the operation
183 */ 183 */
184 ResultCode DeleteDirectory(const std::string& path) const; 184 Result DeleteDirectory(const std::string& path) const;
185 185
186 /** 186 /**
187 * Delete a directory specified by its path and anything under it 187 * Delete a directory specified by its path and anything under it
188 * @param path Path relative to the archive 188 * @param path Path relative to the archive
189 * @return Result of the operation 189 * @return Result of the operation
190 */ 190 */
191 ResultCode DeleteDirectoryRecursively(const std::string& path) const; 191 Result DeleteDirectoryRecursively(const std::string& path) const;
192 192
193 /** 193 /**
194 * Cleans the specified directory. This is similar to DeleteDirectoryRecursively, 194 * Cleans the specified directory. This is similar to DeleteDirectoryRecursively,
@@ -200,7 +200,7 @@ public:
200 * 200 *
201 * @return Result of the operation. 201 * @return Result of the operation.
202 */ 202 */
203 ResultCode CleanDirectoryRecursively(const std::string& path) const; 203 Result CleanDirectoryRecursively(const std::string& path) const;
204 204
205 /** 205 /**
206 * Rename a File specified by its path 206 * Rename a File specified by its path
@@ -208,7 +208,7 @@ public:
208 * @param dest_path Destination path relative to the archive 208 * @param dest_path Destination path relative to the archive
209 * @return Result of the operation 209 * @return Result of the operation
210 */ 210 */
211 ResultCode RenameFile(const std::string& src_path, const std::string& dest_path) const; 211 Result RenameFile(const std::string& src_path, const std::string& dest_path) const;
212 212
213 /** 213 /**
214 * Rename a Directory specified by its path 214 * Rename a Directory specified by its path
@@ -216,7 +216,7 @@ public:
216 * @param dest_path Destination path relative to the archive 216 * @param dest_path Destination path relative to the archive
217 * @return Result of the operation 217 * @return Result of the operation
218 */ 218 */
219 ResultCode RenameDirectory(const std::string& src_path, const std::string& dest_path) const; 219 Result RenameDirectory(const std::string& src_path, const std::string& dest_path) const;
220 220
221 /** 221 /**
222 * Open a file specified by its path, using the specified mode 222 * Open a file specified by its path, using the specified mode
diff --git a/src/core/hle/service/friend/errors.h b/src/core/hle/service/friend/errors.h
index bc9fe0aca..ff525d865 100644
--- a/src/core/hle/service/friend/errors.h
+++ b/src/core/hle/service/friend/errors.h
@@ -7,5 +7,5 @@
7 7
8namespace Service::Friend { 8namespace Service::Friend {
9 9
10constexpr ResultCode ERR_NO_NOTIFICATIONS{ErrorModule::Account, 15}; 10constexpr Result ERR_NO_NOTIFICATIONS{ErrorModule::Account, 15};
11} 11}
diff --git a/src/core/hle/service/glue/arp.cpp b/src/core/hle/service/glue/arp.cpp
index fec7787ab..49b6d45fe 100644
--- a/src/core/hle/service/glue/arp.cpp
+++ b/src/core/hle/service/glue/arp.cpp
@@ -153,7 +153,7 @@ class IRegistrar final : public ServiceFramework<IRegistrar> {
153 friend class ARP_W; 153 friend class ARP_W;
154 154
155public: 155public:
156 using IssuerFn = std::function<ResultCode(u64, ApplicationLaunchProperty, std::vector<u8>)>; 156 using IssuerFn = std::function<Result(u64, ApplicationLaunchProperty, std::vector<u8>)>;
157 157
158 explicit IRegistrar(Core::System& system_, IssuerFn&& issuer) 158 explicit IRegistrar(Core::System& system_, IssuerFn&& issuer)
159 : ServiceFramework{system_, "IRegistrar"}, issue_process_id{std::move(issuer)} { 159 : ServiceFramework{system_, "IRegistrar"}, issue_process_id{std::move(issuer)} {
diff --git a/src/core/hle/service/glue/errors.h b/src/core/hle/service/glue/errors.h
index aefbe1f3e..d4ce7f44e 100644
--- a/src/core/hle/service/glue/errors.h
+++ b/src/core/hle/service/glue/errors.h
@@ -7,9 +7,9 @@
7 7
8namespace Service::Glue { 8namespace Service::Glue {
9 9
10constexpr ResultCode ERR_INVALID_RESOURCE{ErrorModule::ARP, 30}; 10constexpr Result ERR_INVALID_RESOURCE{ErrorModule::ARP, 30};
11constexpr ResultCode ERR_INVALID_PROCESS_ID{ErrorModule::ARP, 31}; 11constexpr Result ERR_INVALID_PROCESS_ID{ErrorModule::ARP, 31};
12constexpr ResultCode ERR_INVALID_ACCESS{ErrorModule::ARP, 42}; 12constexpr Result ERR_INVALID_ACCESS{ErrorModule::ARP, 42};
13constexpr ResultCode ERR_NOT_REGISTERED{ErrorModule::ARP, 102}; 13constexpr Result ERR_NOT_REGISTERED{ErrorModule::ARP, 102};
14 14
15} // namespace Service::Glue 15} // namespace Service::Glue
diff --git a/src/core/hle/service/glue/glue_manager.cpp b/src/core/hle/service/glue/glue_manager.cpp
index f1655b33e..8a654cdca 100644
--- a/src/core/hle/service/glue/glue_manager.cpp
+++ b/src/core/hle/service/glue/glue_manager.cpp
@@ -41,8 +41,8 @@ ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
41 return iter->second.control; 41 return iter->second.control;
42} 42}
43 43
44ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch, 44Result ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
45 std::vector<u8> control) { 45 std::vector<u8> control) {
46 if (title_id == 0) { 46 if (title_id == 0) {
47 return ERR_INVALID_PROCESS_ID; 47 return ERR_INVALID_PROCESS_ID;
48 } 48 }
@@ -56,7 +56,7 @@ ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
56 return ResultSuccess; 56 return ResultSuccess;
57} 57}
58 58
59ResultCode ARPManager::Unregister(u64 title_id) { 59Result ARPManager::Unregister(u64 title_id) {
60 if (title_id == 0) { 60 if (title_id == 0) {
61 return ERR_INVALID_PROCESS_ID; 61 return ERR_INVALID_PROCESS_ID;
62 } 62 }
diff --git a/src/core/hle/service/glue/glue_manager.h b/src/core/hle/service/glue/glue_manager.h
index 6246fd2ff..cd0b092ac 100644
--- a/src/core/hle/service/glue/glue_manager.h
+++ b/src/core/hle/service/glue/glue_manager.h
@@ -42,12 +42,12 @@ public:
42 // Adds a new entry to the internal database with the provided parameters, returning 42 // Adds a new entry to the internal database with the provided parameters, returning
43 // ERR_INVALID_ACCESS if attempting to re-register a title ID without an intermediate Unregister 43 // ERR_INVALID_ACCESS if attempting to re-register a title ID without an intermediate Unregister
44 // step, and ERR_INVALID_PROCESS_ID if the title ID is 0. 44 // step, and ERR_INVALID_PROCESS_ID if the title ID is 0.
45 ResultCode Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control); 45 Result Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control);
46 46
47 // Removes the registration for the provided title ID from the database, returning 47 // Removes the registration for the provided title ID from the database, returning
48 // ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID if the 48 // ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID if the
49 // title ID is 0. 49 // title ID is 0.
50 ResultCode Unregister(u64 title_id); 50 Result Unregister(u64 title_id);
51 51
52 // Removes all entries from the database, always succeeds. Should only be used when resetting 52 // Removes all entries from the database, always succeeds. Should only be used when resetting
53 // system state. 53 // system state.
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index ac5c38cc6..c08b0a5dc 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -56,7 +56,7 @@ bool Controller_NPad::IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle
56 return npad_id && npad_type && device_index; 56 return npad_id && npad_type && device_index;
57} 57}
58 58
59ResultCode Controller_NPad::VerifyValidSixAxisSensorHandle( 59Result Controller_NPad::VerifyValidSixAxisSensorHandle(
60 const Core::HID::SixAxisSensorHandle& device_handle) { 60 const Core::HID::SixAxisSensorHandle& device_handle) {
61 const auto npad_id = IsNpadIdValid(static_cast<Core::HID::NpadIdType>(device_handle.npad_id)); 61 const auto npad_id = IsNpadIdValid(static_cast<Core::HID::NpadIdType>(device_handle.npad_id));
62 if (!npad_id) { 62 if (!npad_id) {
@@ -720,9 +720,9 @@ Controller_NPad::NpadCommunicationMode Controller_NPad::GetNpadCommunicationMode
720 return communication_mode; 720 return communication_mode;
721} 721}
722 722
723ResultCode Controller_NPad::SetNpadMode(Core::HID::NpadIdType npad_id, 723Result Controller_NPad::SetNpadMode(Core::HID::NpadIdType npad_id,
724 NpadJoyDeviceType npad_device_type, 724 NpadJoyDeviceType npad_device_type,
725 NpadJoyAssignmentMode assignment_mode) { 725 NpadJoyAssignmentMode assignment_mode) {
726 if (!IsNpadIdValid(npad_id)) { 726 if (!IsNpadIdValid(npad_id)) {
727 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); 727 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
728 return InvalidNpadId; 728 return InvalidNpadId;
@@ -984,7 +984,7 @@ void Controller_NPad::UpdateControllerAt(Core::HID::NpadStyleIndex type,
984 InitNewlyAddedController(npad_id); 984 InitNewlyAddedController(npad_id);
985} 985}
986 986
987ResultCode Controller_NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) { 987Result Controller_NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) {
988 if (!IsNpadIdValid(npad_id)) { 988 if (!IsNpadIdValid(npad_id)) {
989 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); 989 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
990 return InvalidNpadId; 990 return InvalidNpadId;
@@ -1032,7 +1032,7 @@ ResultCode Controller_NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) {
1032 WriteEmptyEntry(shared_memory); 1032 WriteEmptyEntry(shared_memory);
1033 return ResultSuccess; 1033 return ResultSuccess;
1034} 1034}
1035ResultCode Controller_NPad::SetGyroscopeZeroDriftMode( 1035Result Controller_NPad::SetGyroscopeZeroDriftMode(
1036 const Core::HID::SixAxisSensorHandle& sixaxis_handle, GyroscopeZeroDriftMode drift_mode) { 1036 const Core::HID::SixAxisSensorHandle& sixaxis_handle, GyroscopeZeroDriftMode drift_mode) {
1037 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1037 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
1038 if (is_valid.IsError()) { 1038 if (is_valid.IsError()) {
@@ -1046,7 +1046,7 @@ ResultCode Controller_NPad::SetGyroscopeZeroDriftMode(
1046 return ResultSuccess; 1046 return ResultSuccess;
1047} 1047}
1048 1048
1049ResultCode Controller_NPad::GetGyroscopeZeroDriftMode( 1049Result Controller_NPad::GetGyroscopeZeroDriftMode(
1050 const Core::HID::SixAxisSensorHandle& sixaxis_handle, 1050 const Core::HID::SixAxisSensorHandle& sixaxis_handle,
1051 GyroscopeZeroDriftMode& drift_mode) const { 1051 GyroscopeZeroDriftMode& drift_mode) const {
1052 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1052 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
@@ -1061,8 +1061,8 @@ ResultCode Controller_NPad::GetGyroscopeZeroDriftMode(
1061 return ResultSuccess; 1061 return ResultSuccess;
1062} 1062}
1063 1063
1064ResultCode Controller_NPad::IsSixAxisSensorAtRest( 1064Result Controller_NPad::IsSixAxisSensorAtRest(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
1065 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_at_rest) const { 1065 bool& is_at_rest) const {
1066 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1066 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
1067 if (is_valid.IsError()) { 1067 if (is_valid.IsError()) {
1068 LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw); 1068 LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
@@ -1074,7 +1074,7 @@ ResultCode Controller_NPad::IsSixAxisSensorAtRest(
1074 return ResultSuccess; 1074 return ResultSuccess;
1075} 1075}
1076 1076
1077ResultCode Controller_NPad::IsFirmwareUpdateAvailableForSixAxisSensor( 1077Result Controller_NPad::IsFirmwareUpdateAvailableForSixAxisSensor(
1078 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const { 1078 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const {
1079 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1079 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
1080 if (is_valid.IsError()) { 1080 if (is_valid.IsError()) {
@@ -1087,7 +1087,7 @@ ResultCode Controller_NPad::IsFirmwareUpdateAvailableForSixAxisSensor(
1087 return ResultSuccess; 1087 return ResultSuccess;
1088} 1088}
1089 1089
1090ResultCode Controller_NPad::EnableSixAxisSensorUnalteredPassthrough( 1090Result Controller_NPad::EnableSixAxisSensorUnalteredPassthrough(
1091 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled) { 1091 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled) {
1092 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1092 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
1093 if (is_valid.IsError()) { 1093 if (is_valid.IsError()) {
@@ -1100,7 +1100,7 @@ ResultCode Controller_NPad::EnableSixAxisSensorUnalteredPassthrough(
1100 return ResultSuccess; 1100 return ResultSuccess;
1101} 1101}
1102 1102
1103ResultCode Controller_NPad::IsSixAxisSensorUnalteredPassthroughEnabled( 1103Result Controller_NPad::IsSixAxisSensorUnalteredPassthroughEnabled(
1104 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const { 1104 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const {
1105 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1105 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
1106 if (is_valid.IsError()) { 1106 if (is_valid.IsError()) {
@@ -1113,7 +1113,7 @@ ResultCode Controller_NPad::IsSixAxisSensorUnalteredPassthroughEnabled(
1113 return ResultSuccess; 1113 return ResultSuccess;
1114} 1114}
1115 1115
1116ResultCode Controller_NPad::LoadSixAxisSensorCalibrationParameter( 1116Result Controller_NPad::LoadSixAxisSensorCalibrationParameter(
1117 const Core::HID::SixAxisSensorHandle& sixaxis_handle, 1117 const Core::HID::SixAxisSensorHandle& sixaxis_handle,
1118 Core::HID::SixAxisSensorCalibrationParameter& calibration) const { 1118 Core::HID::SixAxisSensorCalibrationParameter& calibration) const {
1119 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1119 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
@@ -1128,7 +1128,7 @@ ResultCode Controller_NPad::LoadSixAxisSensorCalibrationParameter(
1128 return ResultSuccess; 1128 return ResultSuccess;
1129} 1129}
1130 1130
1131ResultCode Controller_NPad::GetSixAxisSensorIcInformation( 1131Result Controller_NPad::GetSixAxisSensorIcInformation(
1132 const Core::HID::SixAxisSensorHandle& sixaxis_handle, 1132 const Core::HID::SixAxisSensorHandle& sixaxis_handle,
1133 Core::HID::SixAxisSensorIcInformation& ic_information) const { 1133 Core::HID::SixAxisSensorIcInformation& ic_information) const {
1134 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1134 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
@@ -1143,7 +1143,7 @@ ResultCode Controller_NPad::GetSixAxisSensorIcInformation(
1143 return ResultSuccess; 1143 return ResultSuccess;
1144} 1144}
1145 1145
1146ResultCode Controller_NPad::ResetIsSixAxisSensorDeviceNewlyAssigned( 1146Result Controller_NPad::ResetIsSixAxisSensorDeviceNewlyAssigned(
1147 const Core::HID::SixAxisSensorHandle& sixaxis_handle) { 1147 const Core::HID::SixAxisSensorHandle& sixaxis_handle) {
1148 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1148 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
1149 if (is_valid.IsError()) { 1149 if (is_valid.IsError()) {
@@ -1157,8 +1157,8 @@ ResultCode Controller_NPad::ResetIsSixAxisSensorDeviceNewlyAssigned(
1157 return ResultSuccess; 1157 return ResultSuccess;
1158} 1158}
1159 1159
1160ResultCode Controller_NPad::SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, 1160Result Controller_NPad::SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
1161 bool sixaxis_status) { 1161 bool sixaxis_status) {
1162 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1162 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
1163 if (is_valid.IsError()) { 1163 if (is_valid.IsError()) {
1164 LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw); 1164 LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
@@ -1170,7 +1170,7 @@ ResultCode Controller_NPad::SetSixAxisEnabled(const Core::HID::SixAxisSensorHand
1170 return ResultSuccess; 1170 return ResultSuccess;
1171} 1171}
1172 1172
1173ResultCode Controller_NPad::IsSixAxisSensorFusionEnabled( 1173Result Controller_NPad::IsSixAxisSensorFusionEnabled(
1174 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_fusion_enabled) const { 1174 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_fusion_enabled) const {
1175 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1175 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
1176 if (is_valid.IsError()) { 1176 if (is_valid.IsError()) {
@@ -1183,7 +1183,7 @@ ResultCode Controller_NPad::IsSixAxisSensorFusionEnabled(
1183 1183
1184 return ResultSuccess; 1184 return ResultSuccess;
1185} 1185}
1186ResultCode Controller_NPad::SetSixAxisFusionEnabled( 1186Result Controller_NPad::SetSixAxisFusionEnabled(
1187 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_fusion_enabled) { 1187 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_fusion_enabled) {
1188 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1188 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
1189 if (is_valid.IsError()) { 1189 if (is_valid.IsError()) {
@@ -1197,7 +1197,7 @@ ResultCode Controller_NPad::SetSixAxisFusionEnabled(
1197 return ResultSuccess; 1197 return ResultSuccess;
1198} 1198}
1199 1199
1200ResultCode Controller_NPad::SetSixAxisFusionParameters( 1200Result Controller_NPad::SetSixAxisFusionParameters(
1201 const Core::HID::SixAxisSensorHandle& sixaxis_handle, 1201 const Core::HID::SixAxisSensorHandle& sixaxis_handle,
1202 Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters) { 1202 Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters) {
1203 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1203 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
@@ -1217,7 +1217,7 @@ ResultCode Controller_NPad::SetSixAxisFusionParameters(
1217 return ResultSuccess; 1217 return ResultSuccess;
1218} 1218}
1219 1219
1220ResultCode Controller_NPad::GetSixAxisFusionParameters( 1220Result Controller_NPad::GetSixAxisFusionParameters(
1221 const Core::HID::SixAxisSensorHandle& sixaxis_handle, 1221 const Core::HID::SixAxisSensorHandle& sixaxis_handle,
1222 Core::HID::SixAxisSensorFusionParameters& parameters) const { 1222 Core::HID::SixAxisSensorFusionParameters& parameters) const {
1223 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); 1223 const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
@@ -1232,8 +1232,8 @@ ResultCode Controller_NPad::GetSixAxisFusionParameters(
1232 return ResultSuccess; 1232 return ResultSuccess;
1233} 1233}
1234 1234
1235ResultCode Controller_NPad::MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1, 1235Result Controller_NPad::MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1,
1236 Core::HID::NpadIdType npad_id_2) { 1236 Core::HID::NpadIdType npad_id_2) {
1237 if (!IsNpadIdValid(npad_id_1) || !IsNpadIdValid(npad_id_2)) { 1237 if (!IsNpadIdValid(npad_id_1) || !IsNpadIdValid(npad_id_2)) {
1238 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id_1:{}, npad_id_2:{}", npad_id_1, 1238 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id_1:{}, npad_id_2:{}", npad_id_1,
1239 npad_id_2); 1239 npad_id_2);
@@ -1304,8 +1304,8 @@ void Controller_NPad::StopLRAssignmentMode() {
1304 is_in_lr_assignment_mode = false; 1304 is_in_lr_assignment_mode = false;
1305} 1305}
1306 1306
1307ResultCode Controller_NPad::SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, 1307Result Controller_NPad::SwapNpadAssignment(Core::HID::NpadIdType npad_id_1,
1308 Core::HID::NpadIdType npad_id_2) { 1308 Core::HID::NpadIdType npad_id_2) {
1309 if (!IsNpadIdValid(npad_id_1) || !IsNpadIdValid(npad_id_2)) { 1309 if (!IsNpadIdValid(npad_id_1) || !IsNpadIdValid(npad_id_2)) {
1310 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id_1:{}, npad_id_2:{}", npad_id_1, 1310 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id_1:{}, npad_id_2:{}", npad_id_1,
1311 npad_id_2); 1311 npad_id_2);
@@ -1336,8 +1336,8 @@ ResultCode Controller_NPad::SwapNpadAssignment(Core::HID::NpadIdType npad_id_1,
1336 return ResultSuccess; 1336 return ResultSuccess;
1337} 1337}
1338 1338
1339ResultCode Controller_NPad::GetLedPattern(Core::HID::NpadIdType npad_id, 1339Result Controller_NPad::GetLedPattern(Core::HID::NpadIdType npad_id,
1340 Core::HID::LedPattern& pattern) const { 1340 Core::HID::LedPattern& pattern) const {
1341 if (!IsNpadIdValid(npad_id)) { 1341 if (!IsNpadIdValid(npad_id)) {
1342 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); 1342 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
1343 return InvalidNpadId; 1343 return InvalidNpadId;
@@ -1347,8 +1347,8 @@ ResultCode Controller_NPad::GetLedPattern(Core::HID::NpadIdType npad_id,
1347 return ResultSuccess; 1347 return ResultSuccess;
1348} 1348}
1349 1349
1350ResultCode Controller_NPad::IsUnintendedHomeButtonInputProtectionEnabled( 1350Result Controller_NPad::IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id,
1351 Core::HID::NpadIdType npad_id, bool& is_valid) const { 1351 bool& is_valid) const {
1352 if (!IsNpadIdValid(npad_id)) { 1352 if (!IsNpadIdValid(npad_id)) {
1353 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); 1353 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
1354 return InvalidNpadId; 1354 return InvalidNpadId;
@@ -1358,7 +1358,7 @@ ResultCode Controller_NPad::IsUnintendedHomeButtonInputProtectionEnabled(
1358 return ResultSuccess; 1358 return ResultSuccess;
1359} 1359}
1360 1360
1361ResultCode Controller_NPad::SetUnintendedHomeButtonInputProtectionEnabled( 1361Result Controller_NPad::SetUnintendedHomeButtonInputProtectionEnabled(
1362 bool is_protection_enabled, Core::HID::NpadIdType npad_id) { 1362 bool is_protection_enabled, Core::HID::NpadIdType npad_id) {
1363 if (!IsNpadIdValid(npad_id)) { 1363 if (!IsNpadIdValid(npad_id)) {
1364 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); 1364 LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h
index 0b662b7f8..8b54724ed 100644
--- a/src/core/hle/service/hid/controllers/npad.h
+++ b/src/core/hle/service/hid/controllers/npad.h
@@ -29,7 +29,7 @@ namespace Service::KernelHelpers {
29class ServiceContext; 29class ServiceContext;
30} // namespace Service::KernelHelpers 30} // namespace Service::KernelHelpers
31 31
32union ResultCode; 32union Result;
33 33
34namespace Service::HID { 34namespace Service::HID {
35 35
@@ -107,8 +107,8 @@ public:
107 void SetNpadCommunicationMode(NpadCommunicationMode communication_mode_); 107 void SetNpadCommunicationMode(NpadCommunicationMode communication_mode_);
108 NpadCommunicationMode GetNpadCommunicationMode() const; 108 NpadCommunicationMode GetNpadCommunicationMode() const;
109 109
110 ResultCode SetNpadMode(Core::HID::NpadIdType npad_id, NpadJoyDeviceType npad_device_type, 110 Result SetNpadMode(Core::HID::NpadIdType npad_id, NpadJoyDeviceType npad_device_type,
111 NpadJoyAssignmentMode assignment_mode); 111 NpadJoyAssignmentMode assignment_mode);
112 112
113 bool VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index, 113 bool VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index,
114 const Core::HID::VibrationValue& vibration_value); 114 const Core::HID::VibrationValue& vibration_value);
@@ -141,56 +141,55 @@ public:
141 void UpdateControllerAt(Core::HID::NpadStyleIndex controller, Core::HID::NpadIdType npad_id, 141 void UpdateControllerAt(Core::HID::NpadStyleIndex controller, Core::HID::NpadIdType npad_id,
142 bool connected); 142 bool connected);
143 143
144 ResultCode DisconnectNpad(Core::HID::NpadIdType npad_id); 144 Result DisconnectNpad(Core::HID::NpadIdType npad_id);
145 145
146 ResultCode SetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle, 146 Result SetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
147 GyroscopeZeroDriftMode drift_mode); 147 GyroscopeZeroDriftMode drift_mode);
148 ResultCode GetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle, 148 Result GetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
149 GyroscopeZeroDriftMode& drift_mode) const; 149 GyroscopeZeroDriftMode& drift_mode) const;
150 ResultCode IsSixAxisSensorAtRest(const Core::HID::SixAxisSensorHandle& sixaxis_handle, 150 Result IsSixAxisSensorAtRest(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
151 bool& is_at_rest) const; 151 bool& is_at_rest) const;
152 ResultCode IsFirmwareUpdateAvailableForSixAxisSensor( 152 Result IsFirmwareUpdateAvailableForSixAxisSensor(
153 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const; 153 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const;
154 ResultCode EnableSixAxisSensorUnalteredPassthrough( 154 Result EnableSixAxisSensorUnalteredPassthrough(
155 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled); 155 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled);
156 ResultCode IsSixAxisSensorUnalteredPassthroughEnabled( 156 Result IsSixAxisSensorUnalteredPassthroughEnabled(
157 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const; 157 const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const;
158 ResultCode LoadSixAxisSensorCalibrationParameter( 158 Result LoadSixAxisSensorCalibrationParameter(
159 const Core::HID::SixAxisSensorHandle& sixaxis_handle, 159 const Core::HID::SixAxisSensorHandle& sixaxis_handle,
160 Core::HID::SixAxisSensorCalibrationParameter& calibration) const; 160 Core::HID::SixAxisSensorCalibrationParameter& calibration) const;
161 ResultCode GetSixAxisSensorIcInformation( 161 Result GetSixAxisSensorIcInformation(
162 const Core::HID::SixAxisSensorHandle& sixaxis_handle, 162 const Core::HID::SixAxisSensorHandle& sixaxis_handle,
163 Core::HID::SixAxisSensorIcInformation& ic_information) const; 163 Core::HID::SixAxisSensorIcInformation& ic_information) const;
164 ResultCode ResetIsSixAxisSensorDeviceNewlyAssigned( 164 Result ResetIsSixAxisSensorDeviceNewlyAssigned(
165 const Core::HID::SixAxisSensorHandle& sixaxis_handle); 165 const Core::HID::SixAxisSensorHandle& sixaxis_handle);
166 ResultCode SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, 166 Result SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
167 bool sixaxis_status); 167 bool sixaxis_status);
168 ResultCode IsSixAxisSensorFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, 168 Result IsSixAxisSensorFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
169 bool& is_fusion_enabled) const; 169 bool& is_fusion_enabled) const;
170 ResultCode SetSixAxisFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, 170 Result SetSixAxisFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
171 bool is_fusion_enabled); 171 bool is_fusion_enabled);
172 ResultCode SetSixAxisFusionParameters( 172 Result SetSixAxisFusionParameters(
173 const Core::HID::SixAxisSensorHandle& sixaxis_handle, 173 const Core::HID::SixAxisSensorHandle& sixaxis_handle,
174 Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters); 174 Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters);
175 ResultCode GetSixAxisFusionParameters( 175 Result GetSixAxisFusionParameters(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
176 const Core::HID::SixAxisSensorHandle& sixaxis_handle, 176 Core::HID::SixAxisSensorFusionParameters& parameters) const;
177 Core::HID::SixAxisSensorFusionParameters& parameters) const; 177 Result GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const;
178 ResultCode GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const; 178 Result IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id,
179 ResultCode IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id, 179 bool& is_enabled) const;
180 bool& is_enabled) const; 180 Result SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_enabled,
181 ResultCode SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_enabled, 181 Core::HID::NpadIdType npad_id);
182 Core::HID::NpadIdType npad_id);
183 void SetAnalogStickUseCenterClamp(bool use_center_clamp); 182 void SetAnalogStickUseCenterClamp(bool use_center_clamp);
184 void ClearAllConnectedControllers(); 183 void ClearAllConnectedControllers();
185 void DisconnectAllConnectedControllers(); 184 void DisconnectAllConnectedControllers();
186 void ConnectAllDisconnectedControllers(); 185 void ConnectAllDisconnectedControllers();
187 void ClearAllControllers(); 186 void ClearAllControllers();
188 187
189 ResultCode MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1, 188 Result MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1,
190 Core::HID::NpadIdType npad_id_2); 189 Core::HID::NpadIdType npad_id_2);
191 void StartLRAssignmentMode(); 190 void StartLRAssignmentMode();
192 void StopLRAssignmentMode(); 191 void StopLRAssignmentMode();
193 ResultCode SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, Core::HID::NpadIdType npad_id_2); 192 Result SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, Core::HID::NpadIdType npad_id_2);
194 193
195 // Logical OR for all buttons presses on all controllers 194 // Logical OR for all buttons presses on all controllers
196 // Specifically for cheat engine and other features. 195 // Specifically for cheat engine and other features.
@@ -198,7 +197,7 @@ public:
198 197
199 static bool IsNpadIdValid(Core::HID::NpadIdType npad_id); 198 static bool IsNpadIdValid(Core::HID::NpadIdType npad_id);
200 static bool IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle); 199 static bool IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle);
201 static ResultCode VerifyValidSixAxisSensorHandle( 200 static Result VerifyValidSixAxisSensorHandle(
202 const Core::HID::SixAxisSensorHandle& device_handle); 201 const Core::HID::SixAxisSensorHandle& device_handle);
203 202
204private: 203private:
diff --git a/src/core/hle/service/hid/errors.h b/src/core/hle/service/hid/errors.h
index 6c8ad04af..615c23b84 100644
--- a/src/core/hle/service/hid/errors.h
+++ b/src/core/hle/service/hid/errors.h
@@ -7,12 +7,12 @@
7 7
8namespace Service::HID { 8namespace Service::HID {
9 9
10constexpr ResultCode NpadInvalidHandle{ErrorModule::HID, 100}; 10constexpr Result NpadInvalidHandle{ErrorModule::HID, 100};
11constexpr ResultCode NpadDeviceIndexOutOfRange{ErrorModule::HID, 107}; 11constexpr Result NpadDeviceIndexOutOfRange{ErrorModule::HID, 107};
12constexpr ResultCode InvalidSixAxisFusionRange{ErrorModule::HID, 423}; 12constexpr Result InvalidSixAxisFusionRange{ErrorModule::HID, 423};
13constexpr ResultCode NpadIsDualJoycon{ErrorModule::HID, 601}; 13constexpr Result NpadIsDualJoycon{ErrorModule::HID, 601};
14constexpr ResultCode NpadIsSameType{ErrorModule::HID, 602}; 14constexpr Result NpadIsSameType{ErrorModule::HID, 602};
15constexpr ResultCode InvalidNpadId{ErrorModule::HID, 709}; 15constexpr Result InvalidNpadId{ErrorModule::HID, 709};
16constexpr ResultCode NpadNotConnected{ErrorModule::HID, 710}; 16constexpr Result NpadNotConnected{ErrorModule::HID, 710};
17 17
18} // namespace Service::HID 18} // namespace Service::HID
diff --git a/src/core/hle/service/hid/hidbus.h b/src/core/hle/service/hid/hidbus.h
index 6b3015a0f..8c687f678 100644
--- a/src/core/hle/service/hid/hidbus.h
+++ b/src/core/hle/service/hid/hidbus.h
@@ -71,7 +71,7 @@ private:
71 struct HidbusStatusManagerEntry { 71 struct HidbusStatusManagerEntry {
72 u8 is_connected{}; 72 u8 is_connected{};
73 INSERT_PADDING_BYTES(0x3); 73 INSERT_PADDING_BYTES(0x3);
74 ResultCode is_connected_result{0}; 74 Result is_connected_result{0};
75 u8 is_enabled{}; 75 u8 is_enabled{};
76 u8 is_in_focus{}; 76 u8 is_in_focus{};
77 u8 is_polling_mode{}; 77 u8 is_polling_mode{};
diff --git a/src/core/hle/service/hid/hidbus/hidbus_base.h b/src/core/hle/service/hid/hidbus/hidbus_base.h
index 01c52051b..d3960f506 100644
--- a/src/core/hle/service/hid/hidbus/hidbus_base.h
+++ b/src/core/hle/service/hid/hidbus/hidbus_base.h
@@ -26,7 +26,7 @@ enum class JoyPollingMode : u32 {
26}; 26};
27 27
28struct DataAccessorHeader { 28struct DataAccessorHeader {
29 ResultCode result{ResultUnknown}; 29 Result result{ResultUnknown};
30 INSERT_PADDING_WORDS(0x1); 30 INSERT_PADDING_WORDS(0x1);
31 std::array<u8, 0x18> unused{}; 31 std::array<u8, 0x18> unused{};
32 u64 latest_entry{}; 32 u64 latest_entry{};
diff --git a/src/core/hle/service/ldn/errors.h b/src/core/hle/service/ldn/errors.h
index fb86b9402..972a74806 100644
--- a/src/core/hle/service/ldn/errors.h
+++ b/src/core/hle/service/ldn/errors.h
@@ -7,6 +7,6 @@
7 7
8namespace Service::LDN { 8namespace Service::LDN {
9 9
10constexpr ResultCode ERROR_DISABLED{ErrorModule::LDN, 22}; 10constexpr Result ERROR_DISABLED{ErrorModule::LDN, 22};
11 11
12} // namespace Service::LDN 12} // namespace Service::LDN
diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp
index 72e4902cb..becd6d1b9 100644
--- a/src/core/hle/service/ldr/ldr.cpp
+++ b/src/core/hle/service/ldr/ldr.cpp
@@ -20,20 +20,20 @@
20 20
21namespace Service::LDR { 21namespace Service::LDR {
22 22
23constexpr ResultCode ERROR_INSUFFICIENT_ADDRESS_SPACE{ErrorModule::RO, 2}; 23constexpr Result ERROR_INSUFFICIENT_ADDRESS_SPACE{ErrorModule::RO, 2};
24 24
25[[maybe_unused]] constexpr ResultCode ERROR_INVALID_MEMORY_STATE{ErrorModule::Loader, 51}; 25[[maybe_unused]] constexpr Result ERROR_INVALID_MEMORY_STATE{ErrorModule::Loader, 51};
26constexpr ResultCode ERROR_INVALID_NRO{ErrorModule::Loader, 52}; 26constexpr Result ERROR_INVALID_NRO{ErrorModule::Loader, 52};
27constexpr ResultCode ERROR_INVALID_NRR{ErrorModule::Loader, 53}; 27constexpr Result ERROR_INVALID_NRR{ErrorModule::Loader, 53};
28constexpr ResultCode ERROR_MISSING_NRR_HASH{ErrorModule::Loader, 54}; 28constexpr Result ERROR_MISSING_NRR_HASH{ErrorModule::Loader, 54};
29constexpr ResultCode ERROR_MAXIMUM_NRO{ErrorModule::Loader, 55}; 29constexpr Result ERROR_MAXIMUM_NRO{ErrorModule::Loader, 55};
30constexpr ResultCode ERROR_MAXIMUM_NRR{ErrorModule::Loader, 56}; 30constexpr Result ERROR_MAXIMUM_NRR{ErrorModule::Loader, 56};
31constexpr ResultCode ERROR_ALREADY_LOADED{ErrorModule::Loader, 57}; 31constexpr Result ERROR_ALREADY_LOADED{ErrorModule::Loader, 57};
32constexpr ResultCode ERROR_INVALID_ALIGNMENT{ErrorModule::Loader, 81}; 32constexpr Result ERROR_INVALID_ALIGNMENT{ErrorModule::Loader, 81};
33constexpr ResultCode ERROR_INVALID_SIZE{ErrorModule::Loader, 82}; 33constexpr Result ERROR_INVALID_SIZE{ErrorModule::Loader, 82};
34constexpr ResultCode ERROR_INVALID_NRO_ADDRESS{ErrorModule::Loader, 84}; 34constexpr Result ERROR_INVALID_NRO_ADDRESS{ErrorModule::Loader, 84};
35[[maybe_unused]] constexpr ResultCode ERROR_INVALID_NRR_ADDRESS{ErrorModule::Loader, 85}; 35[[maybe_unused]] constexpr Result ERROR_INVALID_NRR_ADDRESS{ErrorModule::Loader, 85};
36constexpr ResultCode ERROR_NOT_INITIALIZED{ErrorModule::Loader, 87}; 36constexpr Result ERROR_NOT_INITIALIZED{ErrorModule::Loader, 87};
37 37
38constexpr std::size_t MAXIMUM_LOADED_RO{0x40}; 38constexpr std::size_t MAXIMUM_LOADED_RO{0x40};
39constexpr std::size_t MAXIMUM_MAP_RETRIES{0x200}; 39constexpr std::size_t MAXIMUM_MAP_RETRIES{0x200};
@@ -307,7 +307,7 @@ public:
307 return (start + size + padding_size) <= (end_info.GetAddress() + end_info.GetSize()); 307 return (start + size + padding_size) <= (end_info.GetAddress() + end_info.GetSize());
308 } 308 }
309 309
310 ResultCode GetAvailableMapRegion(Kernel::KPageTable& page_table, u64 size, VAddr& out_addr) { 310 Result GetAvailableMapRegion(Kernel::KPageTable& page_table, u64 size, VAddr& out_addr) {
311 size = Common::AlignUp(size, Kernel::PageSize); 311 size = Common::AlignUp(size, Kernel::PageSize);
312 size += page_table.GetNumGuardPages() * Kernel::PageSize * 4; 312 size += page_table.GetNumGuardPages() * Kernel::PageSize * 4;
313 313
@@ -364,7 +364,7 @@ public:
364 for (std::size_t retry = 0; retry < MAXIMUM_MAP_RETRIES; retry++) { 364 for (std::size_t retry = 0; retry < MAXIMUM_MAP_RETRIES; retry++) {
365 R_TRY(GetAvailableMapRegion(page_table, size, addr)); 365 R_TRY(GetAvailableMapRegion(page_table, size, addr));
366 366
367 const ResultCode result{page_table.MapCodeMemory(addr, base_addr, size)}; 367 const Result result{page_table.MapCodeMemory(addr, base_addr, size)};
368 if (result == Kernel::ResultInvalidCurrentMemory) { 368 if (result == Kernel::ResultInvalidCurrentMemory) {
369 continue; 369 continue;
370 } 370 }
@@ -397,8 +397,7 @@ public:
397 Kernel::KPageTable::ICacheInvalidationStrategy::InvalidateRange); 397 Kernel::KPageTable::ICacheInvalidationStrategy::InvalidateRange);
398 }); 398 });
399 399
400 const ResultCode result{ 400 const Result result{page_table.MapCodeMemory(addr + nro_size, bss_addr, bss_size)};
401 page_table.MapCodeMemory(addr + nro_size, bss_addr, bss_size)};
402 401
403 if (result == Kernel::ResultInvalidCurrentMemory) { 402 if (result == Kernel::ResultInvalidCurrentMemory) {
404 continue; 403 continue;
@@ -419,8 +418,8 @@ public:
419 return ERROR_INSUFFICIENT_ADDRESS_SPACE; 418 return ERROR_INSUFFICIENT_ADDRESS_SPACE;
420 } 419 }
421 420
422 ResultCode LoadNro(Kernel::KProcess* process, const NROHeader& nro_header, VAddr nro_addr, 421 Result LoadNro(Kernel::KProcess* process, const NROHeader& nro_header, VAddr nro_addr,
423 VAddr start) const { 422 VAddr start) const {
424 const VAddr text_start{start + nro_header.segment_headers[TEXT_INDEX].memory_offset}; 423 const VAddr text_start{start + nro_header.segment_headers[TEXT_INDEX].memory_offset};
425 const VAddr ro_start{start + nro_header.segment_headers[RO_INDEX].memory_offset}; 424 const VAddr ro_start{start + nro_header.segment_headers[RO_INDEX].memory_offset};
426 const VAddr data_start{start + nro_header.segment_headers[DATA_INDEX].memory_offset}; 425 const VAddr data_start{start + nro_header.segment_headers[DATA_INDEX].memory_offset};
@@ -569,7 +568,7 @@ public:
569 rb.Push(*map_result); 568 rb.Push(*map_result);
570 } 569 }
571 570
572 ResultCode UnmapNro(const NROInfo& info) { 571 Result UnmapNro(const NROInfo& info) {
573 // Each region must be unmapped separately to validate memory state 572 // Each region must be unmapped separately to validate memory state
574 auto& page_table{system.CurrentProcess()->PageTable()}; 573 auto& page_table{system.CurrentProcess()->PageTable()};
575 574
diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp
index 41755bf0b..efb569993 100644
--- a/src/core/hle/service/mii/mii.cpp
+++ b/src/core/hle/service/mii/mii.cpp
@@ -12,7 +12,7 @@
12 12
13namespace Service::Mii { 13namespace Service::Mii {
14 14
15constexpr ResultCode ERROR_INVALID_ARGUMENT{ErrorModule::Mii, 1}; 15constexpr Result ERROR_INVALID_ARGUMENT{ErrorModule::Mii, 1};
16 16
17class IDatabaseService final : public ServiceFramework<IDatabaseService> { 17class IDatabaseService final : public ServiceFramework<IDatabaseService> {
18public: 18public:
diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp
index 08300a1a6..544c92a00 100644
--- a/src/core/hle/service/mii/mii_manager.cpp
+++ b/src/core/hle/service/mii/mii_manager.cpp
@@ -16,7 +16,7 @@ namespace Service::Mii {
16 16
17namespace { 17namespace {
18 18
19constexpr ResultCode ERROR_CANNOT_FIND_ENTRY{ErrorModule::Mii, 4}; 19constexpr Result ERROR_CANNOT_FIND_ENTRY{ErrorModule::Mii, 4};
20 20
21constexpr std::size_t BaseMiiCount{2}; 21constexpr std::size_t BaseMiiCount{2};
22constexpr std::size_t DefaultMiiCount{RawData::DefaultMii.size()}; 22constexpr std::size_t DefaultMiiCount{RawData::DefaultMii.size()};
@@ -441,7 +441,7 @@ ResultVal<std::vector<MiiInfoElement>> MiiManager::GetDefault(SourceFlag source_
441 return result; 441 return result;
442} 442}
443 443
444ResultCode MiiManager::GetIndex([[maybe_unused]] const MiiInfo& info, u32& index) { 444Result MiiManager::GetIndex([[maybe_unused]] const MiiInfo& info, u32& index) {
445 constexpr u32 INVALID_INDEX{0xFFFFFFFF}; 445 constexpr u32 INVALID_INDEX{0xFFFFFFFF};
446 446
447 index = INVALID_INDEX; 447 index = INVALID_INDEX;
diff --git a/src/core/hle/service/mii/mii_manager.h b/src/core/hle/service/mii/mii_manager.h
index db217b9a5..6a286bd96 100644
--- a/src/core/hle/service/mii/mii_manager.h
+++ b/src/core/hle/service/mii/mii_manager.h
@@ -23,7 +23,7 @@ public:
23 MiiInfo BuildRandom(Age age, Gender gender, Race race); 23 MiiInfo BuildRandom(Age age, Gender gender, Race race);
24 MiiInfo BuildDefault(std::size_t index); 24 MiiInfo BuildDefault(std::size_t index);
25 ResultVal<std::vector<MiiInfoElement>> GetDefault(SourceFlag source_flag); 25 ResultVal<std::vector<MiiInfoElement>> GetDefault(SourceFlag source_flag);
26 ResultCode GetIndex(const MiiInfo& info, u32& index); 26 Result GetIndex(const MiiInfo& info, u32& index);
27 27
28private: 28private:
29 const Common::UUID user_id{}; 29 const Common::UUID user_id{};
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp
index 74891da57..6c5b41dd1 100644
--- a/src/core/hle/service/nfp/nfp.cpp
+++ b/src/core/hle/service/nfp/nfp.cpp
@@ -17,10 +17,10 @@
17 17
18namespace Service::NFP { 18namespace Service::NFP {
19namespace ErrCodes { 19namespace ErrCodes {
20constexpr ResultCode DeviceNotFound(ErrorModule::NFP, 64); 20constexpr Result DeviceNotFound(ErrorModule::NFP, 64);
21constexpr ResultCode WrongDeviceState(ErrorModule::NFP, 73); 21constexpr Result WrongDeviceState(ErrorModule::NFP, 73);
22constexpr ResultCode ApplicationAreaIsNotInitialized(ErrorModule::NFP, 128); 22constexpr Result ApplicationAreaIsNotInitialized(ErrorModule::NFP, 128);
23constexpr ResultCode ApplicationAreaExist(ErrorModule::NFP, 168); 23constexpr Result ApplicationAreaExist(ErrorModule::NFP, 168);
24} // namespace ErrCodes 24} // namespace ErrCodes
25 25
26constexpr u32 ApplicationAreaSize = 0xD8; 26constexpr u32 ApplicationAreaSize = 0xD8;
@@ -585,7 +585,7 @@ void Module::Interface::Finalize() {
585 application_area_data.clear(); 585 application_area_data.clear();
586} 586}
587 587
588ResultCode Module::Interface::StartDetection(s32 protocol_) { 588Result Module::Interface::StartDetection(s32 protocol_) {
589 auto npad_device = system.HIDCore().GetEmulatedController(npad_id); 589 auto npad_device = system.HIDCore().GetEmulatedController(npad_id);
590 590
591 // TODO(german77): Add callback for when nfc data is available 591 // TODO(german77): Add callback for when nfc data is available
@@ -601,7 +601,7 @@ ResultCode Module::Interface::StartDetection(s32 protocol_) {
601 return ErrCodes::WrongDeviceState; 601 return ErrCodes::WrongDeviceState;
602} 602}
603 603
604ResultCode Module::Interface::StopDetection() { 604Result Module::Interface::StopDetection() {
605 auto npad_device = system.HIDCore().GetEmulatedController(npad_id); 605 auto npad_device = system.HIDCore().GetEmulatedController(npad_id);
606 npad_device->SetPollingMode(Common::Input::PollingMode::Active); 606 npad_device->SetPollingMode(Common::Input::PollingMode::Active);
607 607
@@ -618,7 +618,7 @@ ResultCode Module::Interface::StopDetection() {
618 return ErrCodes::WrongDeviceState; 618 return ErrCodes::WrongDeviceState;
619} 619}
620 620
621ResultCode Module::Interface::Mount() { 621Result Module::Interface::Mount() {
622 if (device_state == DeviceState::TagFound) { 622 if (device_state == DeviceState::TagFound) {
623 device_state = DeviceState::TagMounted; 623 device_state = DeviceState::TagMounted;
624 return ResultSuccess; 624 return ResultSuccess;
@@ -628,7 +628,7 @@ ResultCode Module::Interface::Mount() {
628 return ErrCodes::WrongDeviceState; 628 return ErrCodes::WrongDeviceState;
629} 629}
630 630
631ResultCode Module::Interface::Unmount() { 631Result Module::Interface::Unmount() {
632 if (device_state == DeviceState::TagMounted) { 632 if (device_state == DeviceState::TagMounted) {
633 is_application_area_initialized = false; 633 is_application_area_initialized = false;
634 application_area_id = 0; 634 application_area_id = 0;
@@ -641,7 +641,7 @@ ResultCode Module::Interface::Unmount() {
641 return ErrCodes::WrongDeviceState; 641 return ErrCodes::WrongDeviceState;
642} 642}
643 643
644ResultCode Module::Interface::GetTagInfo(TagInfo& tag_info) const { 644Result Module::Interface::GetTagInfo(TagInfo& tag_info) const {
645 if (device_state == DeviceState::TagFound || device_state == DeviceState::TagMounted) { 645 if (device_state == DeviceState::TagFound || device_state == DeviceState::TagMounted) {
646 tag_info = { 646 tag_info = {
647 .uuid = tag_data.uuid, 647 .uuid = tag_data.uuid,
@@ -656,7 +656,7 @@ ResultCode Module::Interface::GetTagInfo(TagInfo& tag_info) const {
656 return ErrCodes::WrongDeviceState; 656 return ErrCodes::WrongDeviceState;
657} 657}
658 658
659ResultCode Module::Interface::GetCommonInfo(CommonInfo& common_info) const { 659Result Module::Interface::GetCommonInfo(CommonInfo& common_info) const {
660 if (device_state != DeviceState::TagMounted) { 660 if (device_state != DeviceState::TagMounted) {
661 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); 661 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state);
662 return ErrCodes::WrongDeviceState; 662 return ErrCodes::WrongDeviceState;
@@ -674,7 +674,7 @@ ResultCode Module::Interface::GetCommonInfo(CommonInfo& common_info) const {
674 return ResultSuccess; 674 return ResultSuccess;
675} 675}
676 676
677ResultCode Module::Interface::GetModelInfo(ModelInfo& model_info) const { 677Result Module::Interface::GetModelInfo(ModelInfo& model_info) const {
678 if (device_state != DeviceState::TagMounted) { 678 if (device_state != DeviceState::TagMounted) {
679 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); 679 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state);
680 return ErrCodes::WrongDeviceState; 680 return ErrCodes::WrongDeviceState;
@@ -684,7 +684,7 @@ ResultCode Module::Interface::GetModelInfo(ModelInfo& model_info) const {
684 return ResultSuccess; 684 return ResultSuccess;
685} 685}
686 686
687ResultCode Module::Interface::GetRegisterInfo(RegisterInfo& register_info) const { 687Result Module::Interface::GetRegisterInfo(RegisterInfo& register_info) const {
688 if (device_state != DeviceState::TagMounted) { 688 if (device_state != DeviceState::TagMounted) {
689 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); 689 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state);
690 return ErrCodes::WrongDeviceState; 690 return ErrCodes::WrongDeviceState;
@@ -704,7 +704,7 @@ ResultCode Module::Interface::GetRegisterInfo(RegisterInfo& register_info) const
704 return ResultSuccess; 704 return ResultSuccess;
705} 705}
706 706
707ResultCode Module::Interface::OpenApplicationArea(u32 access_id) { 707Result Module::Interface::OpenApplicationArea(u32 access_id) {
708 if (device_state != DeviceState::TagMounted) { 708 if (device_state != DeviceState::TagMounted) {
709 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); 709 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state);
710 return ErrCodes::WrongDeviceState; 710 return ErrCodes::WrongDeviceState;
@@ -721,7 +721,7 @@ ResultCode Module::Interface::OpenApplicationArea(u32 access_id) {
721 return ResultSuccess; 721 return ResultSuccess;
722} 722}
723 723
724ResultCode Module::Interface::GetApplicationArea(std::vector<u8>& data) const { 724Result Module::Interface::GetApplicationArea(std::vector<u8>& data) const {
725 if (device_state != DeviceState::TagMounted) { 725 if (device_state != DeviceState::TagMounted) {
726 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); 726 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state);
727 return ErrCodes::WrongDeviceState; 727 return ErrCodes::WrongDeviceState;
@@ -736,7 +736,7 @@ ResultCode Module::Interface::GetApplicationArea(std::vector<u8>& data) const {
736 return ResultSuccess; 736 return ResultSuccess;
737} 737}
738 738
739ResultCode Module::Interface::SetApplicationArea(const std::vector<u8>& data) { 739Result Module::Interface::SetApplicationArea(const std::vector<u8>& data) {
740 if (device_state != DeviceState::TagMounted) { 740 if (device_state != DeviceState::TagMounted) {
741 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); 741 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state);
742 return ErrCodes::WrongDeviceState; 742 return ErrCodes::WrongDeviceState;
@@ -750,7 +750,7 @@ ResultCode Module::Interface::SetApplicationArea(const std::vector<u8>& data) {
750 return ResultSuccess; 750 return ResultSuccess;
751} 751}
752 752
753ResultCode Module::Interface::CreateApplicationArea(u32 access_id, const std::vector<u8>& data) { 753Result Module::Interface::CreateApplicationArea(u32 access_id, const std::vector<u8>& data) {
754 if (device_state != DeviceState::TagMounted) { 754 if (device_state != DeviceState::TagMounted) {
755 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); 755 LOG_ERROR(Service_NFP, "Wrong device state {}", device_state);
756 return ErrCodes::WrongDeviceState; 756 return ErrCodes::WrongDeviceState;
diff --git a/src/core/hle/service/nfp/nfp.h b/src/core/hle/service/nfp/nfp.h
index d307c6a35..0fc808781 100644
--- a/src/core/hle/service/nfp/nfp.h
+++ b/src/core/hle/service/nfp/nfp.h
@@ -178,20 +178,20 @@ public:
178 void Initialize(); 178 void Initialize();
179 void Finalize(); 179 void Finalize();
180 180
181 ResultCode StartDetection(s32 protocol_); 181 Result StartDetection(s32 protocol_);
182 ResultCode StopDetection(); 182 Result StopDetection();
183 ResultCode Mount(); 183 Result Mount();
184 ResultCode Unmount(); 184 Result Unmount();
185 185
186 ResultCode GetTagInfo(TagInfo& tag_info) const; 186 Result GetTagInfo(TagInfo& tag_info) const;
187 ResultCode GetCommonInfo(CommonInfo& common_info) const; 187 Result GetCommonInfo(CommonInfo& common_info) const;
188 ResultCode GetModelInfo(ModelInfo& model_info) const; 188 Result GetModelInfo(ModelInfo& model_info) const;
189 ResultCode GetRegisterInfo(RegisterInfo& register_info) const; 189 Result GetRegisterInfo(RegisterInfo& register_info) const;
190 190
191 ResultCode OpenApplicationArea(u32 access_id); 191 Result OpenApplicationArea(u32 access_id);
192 ResultCode GetApplicationArea(std::vector<u8>& data) const; 192 Result GetApplicationArea(std::vector<u8>& data) const;
193 ResultCode SetApplicationArea(const std::vector<u8>& data); 193 Result SetApplicationArea(const std::vector<u8>& data);
194 ResultCode CreateApplicationArea(u32 access_id, const std::vector<u8>& data); 194 Result CreateApplicationArea(u32 access_id, const std::vector<u8>& data);
195 195
196 u64 GetHandle() const; 196 u64 GetHandle() const;
197 DeviceState GetCurrentState() const; 197 DeviceState GetCurrentState() const;
diff --git a/src/core/hle/service/ns/errors.h b/src/core/hle/service/ns/errors.h
index 3c50c66e0..8a7621798 100644
--- a/src/core/hle/service/ns/errors.h
+++ b/src/core/hle/service/ns/errors.h
@@ -7,5 +7,5 @@
7 7
8namespace Service::NS { 8namespace Service::NS {
9 9
10constexpr ResultCode ERR_APPLICATION_LANGUAGE_NOT_FOUND{ErrorModule::NS, 300}; 10constexpr Result ERR_APPLICATION_LANGUAGE_NOT_FOUND{ErrorModule::NS, 300};
11} \ No newline at end of file 11} \ No newline at end of file
diff --git a/src/core/hle/service/pctl/pctl_module.cpp b/src/core/hle/service/pctl/pctl_module.cpp
index 8d5729003..2a123b42d 100644
--- a/src/core/hle/service/pctl/pctl_module.cpp
+++ b/src/core/hle/service/pctl/pctl_module.cpp
@@ -13,10 +13,10 @@ namespace Service::PCTL {
13 13
14namespace Error { 14namespace Error {
15 15
16constexpr ResultCode ResultNoFreeCommunication{ErrorModule::PCTL, 101}; 16constexpr Result ResultNoFreeCommunication{ErrorModule::PCTL, 101};
17constexpr ResultCode ResultStereoVisionRestricted{ErrorModule::PCTL, 104}; 17constexpr Result ResultStereoVisionRestricted{ErrorModule::PCTL, 104};
18constexpr ResultCode ResultNoCapability{ErrorModule::PCTL, 131}; 18constexpr Result ResultNoCapability{ErrorModule::PCTL, 131};
19constexpr ResultCode ResultNoRestrictionEnabled{ErrorModule::PCTL, 181}; 19constexpr Result ResultNoRestrictionEnabled{ErrorModule::PCTL, 181};
20 20
21} // namespace Error 21} // namespace Error
22 22
diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp
index a8e2a5cbd..b10e86c8f 100644
--- a/src/core/hle/service/pm/pm.cpp
+++ b/src/core/hle/service/pm/pm.cpp
@@ -12,12 +12,12 @@ namespace Service::PM {
12 12
13namespace { 13namespace {
14 14
15constexpr ResultCode ResultProcessNotFound{ErrorModule::PM, 1}; 15constexpr Result ResultProcessNotFound{ErrorModule::PM, 1};
16[[maybe_unused]] constexpr ResultCode ResultAlreadyStarted{ErrorModule::PM, 2}; 16[[maybe_unused]] constexpr Result ResultAlreadyStarted{ErrorModule::PM, 2};
17[[maybe_unused]] constexpr ResultCode ResultNotTerminated{ErrorModule::PM, 3}; 17[[maybe_unused]] constexpr Result ResultNotTerminated{ErrorModule::PM, 3};
18[[maybe_unused]] constexpr ResultCode ResultDebugHookInUse{ErrorModule::PM, 4}; 18[[maybe_unused]] constexpr Result ResultDebugHookInUse{ErrorModule::PM, 4};
19[[maybe_unused]] constexpr ResultCode ResultApplicationRunning{ErrorModule::PM, 5}; 19[[maybe_unused]] constexpr Result ResultApplicationRunning{ErrorModule::PM, 5};
20[[maybe_unused]] constexpr ResultCode ResultInvalidSize{ErrorModule::PM, 6}; 20[[maybe_unused]] constexpr Result ResultInvalidSize{ErrorModule::PM, 6};
21 21
22constexpr u64 NO_PROCESS_FOUND_PID{0}; 22constexpr u64 NO_PROCESS_FOUND_PID{0};
23 23
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 574272b0c..318009e4f 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -190,8 +190,8 @@ void ServiceFrameworkBase::InvokeRequestTipc(Kernel::HLERequestContext& ctx) {
190 handler_invoker(this, info->handler_callback, ctx); 190 handler_invoker(this, info->handler_callback, ctx);
191} 191}
192 192
193ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::KServerSession& session, 193Result ServiceFrameworkBase::HandleSyncRequest(Kernel::KServerSession& session,
194 Kernel::HLERequestContext& ctx) { 194 Kernel::HLERequestContext& ctx) {
195 const auto guard = LockService(); 195 const auto guard = LockService();
196 196
197 switch (ctx.GetCommandType()) { 197 switch (ctx.GetCommandType()) {
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index f23e0cd64..5bf197c51 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -79,8 +79,8 @@ public:
79 Kernel::KClientPort& CreatePort(); 79 Kernel::KClientPort& CreatePort();
80 80
81 /// Handles a synchronization request for the service. 81 /// Handles a synchronization request for the service.
82 ResultCode HandleSyncRequest(Kernel::KServerSession& session, 82 Result HandleSyncRequest(Kernel::KServerSession& session,
83 Kernel::HLERequestContext& context) override; 83 Kernel::HLERequestContext& context) override;
84 84
85protected: 85protected:
86 /// Member-function pointer type of SyncRequest handlers. 86 /// Member-function pointer type of SyncRequest handlers.
diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp
index 2839cffcf..f761c2da4 100644
--- a/src/core/hle/service/set/set.cpp
+++ b/src/core/hle/service/set/set.cpp
@@ -74,7 +74,7 @@ constexpr std::array<std::pair<LanguageCode, KeyboardLayout>, 18> language_to_la
74constexpr std::size_t PRE_4_0_0_MAX_ENTRIES = 0xF; 74constexpr std::size_t PRE_4_0_0_MAX_ENTRIES = 0xF;
75constexpr std::size_t POST_4_0_0_MAX_ENTRIES = 0x40; 75constexpr std::size_t POST_4_0_0_MAX_ENTRIES = 0x40;
76 76
77constexpr ResultCode ERR_INVALID_LANGUAGE{ErrorModule::Settings, 625}; 77constexpr Result ERR_INVALID_LANGUAGE{ErrorModule::Settings, 625};
78 78
79void PushResponseLanguageCode(Kernel::HLERequestContext& ctx, std::size_t num_language_codes) { 79void PushResponseLanguageCode(Kernel::HLERequestContext& ctx, std::size_t num_language_codes) {
80 IPC::ResponseBuilder rb{ctx, 3}; 80 IPC::ResponseBuilder rb{ctx, 3};
diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp
index 87c6f7f85..2a0b812c1 100644
--- a/src/core/hle/service/set/set_sys.cpp
+++ b/src/core/hle/service/set/set_sys.cpp
@@ -32,7 +32,7 @@ void GetFirmwareVersionImpl(Kernel::HLERequestContext& ctx, GetFirmwareVersionTy
32 // consistence (currently reports as 5.1.0-0.0) 32 // consistence (currently reports as 5.1.0-0.0)
33 const auto archive = FileSys::SystemArchive::SystemVersion(); 33 const auto archive = FileSys::SystemArchive::SystemVersion();
34 34
35 const auto early_exit_failure = [&ctx](std::string_view desc, ResultCode code) { 35 const auto early_exit_failure = [&ctx](std::string_view desc, Result code) {
36 LOG_ERROR(Service_SET, "General failure while attempting to resolve firmware version ({}).", 36 LOG_ERROR(Service_SET, "General failure while attempting to resolve firmware version ({}).",
37 desc); 37 desc);
38 IPC::ResponseBuilder rb{ctx, 2}; 38 IPC::ResponseBuilder rb{ctx, 2};
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp
index 925608875..246c94623 100644
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -17,10 +17,10 @@
17 17
18namespace Service::SM { 18namespace Service::SM {
19 19
20constexpr ResultCode ERR_NOT_INITIALIZED(ErrorModule::SM, 2); 20constexpr Result ERR_NOT_INITIALIZED(ErrorModule::SM, 2);
21constexpr ResultCode ERR_ALREADY_REGISTERED(ErrorModule::SM, 4); 21constexpr Result ERR_ALREADY_REGISTERED(ErrorModule::SM, 4);
22constexpr ResultCode ERR_INVALID_NAME(ErrorModule::SM, 6); 22constexpr Result ERR_INVALID_NAME(ErrorModule::SM, 6);
23constexpr ResultCode ERR_SERVICE_NOT_REGISTERED(ErrorModule::SM, 7); 23constexpr Result ERR_SERVICE_NOT_REGISTERED(ErrorModule::SM, 7);
24 24
25ServiceManager::ServiceManager(Kernel::KernelCore& kernel_) : kernel{kernel_} {} 25ServiceManager::ServiceManager(Kernel::KernelCore& kernel_) : kernel{kernel_} {}
26ServiceManager::~ServiceManager() = default; 26ServiceManager::~ServiceManager() = default;
@@ -29,7 +29,7 @@ void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) {
29 controller_interface->InvokeRequest(context); 29 controller_interface->InvokeRequest(context);
30} 30}
31 31
32static ResultCode ValidateServiceName(const std::string& name) { 32static Result ValidateServiceName(const std::string& name) {
33 if (name.empty() || name.size() > 8) { 33 if (name.empty() || name.size() > 8) {
34 LOG_ERROR(Service_SM, "Invalid service name! service={}", name); 34 LOG_ERROR(Service_SM, "Invalid service name! service={}", name);
35 return ERR_INVALID_NAME; 35 return ERR_INVALID_NAME;
@@ -43,8 +43,8 @@ Kernel::KClientPort& ServiceManager::InterfaceFactory(ServiceManager& self, Core
43 return self.sm_interface->CreatePort(); 43 return self.sm_interface->CreatePort();
44} 44}
45 45
46ResultCode ServiceManager::RegisterService(std::string name, u32 max_sessions, 46Result ServiceManager::RegisterService(std::string name, u32 max_sessions,
47 Kernel::SessionRequestHandlerPtr handler) { 47 Kernel::SessionRequestHandlerPtr handler) {
48 48
49 CASCADE_CODE(ValidateServiceName(name)); 49 CASCADE_CODE(ValidateServiceName(name));
50 50
@@ -58,7 +58,7 @@ ResultCode ServiceManager::RegisterService(std::string name, u32 max_sessions,
58 return ResultSuccess; 58 return ResultSuccess;
59} 59}
60 60
61ResultCode ServiceManager::UnregisterService(const std::string& name) { 61Result ServiceManager::UnregisterService(const std::string& name) {
62 CASCADE_CODE(ValidateServiceName(name)); 62 CASCADE_CODE(ValidateServiceName(name));
63 63
64 const auto iter = registered_services.find(name); 64 const auto iter = registered_services.find(name);
@@ -94,7 +94,7 @@ ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name
94 * Inputs: 94 * Inputs:
95 * 0: 0x00000000 95 * 0: 0x00000000
96 * Outputs: 96 * Outputs:
97 * 0: ResultCode 97 * 0: Result
98 */ 98 */
99void SM::Initialize(Kernel::HLERequestContext& ctx) { 99void SM::Initialize(Kernel::HLERequestContext& ctx) {
100 LOG_DEBUG(Service_SM, "called"); 100 LOG_DEBUG(Service_SM, "called");
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h
index 43d445e97..878decc6f 100644
--- a/src/core/hle/service/sm/sm.h
+++ b/src/core/hle/service/sm/sm.h
@@ -55,9 +55,9 @@ public:
55 explicit ServiceManager(Kernel::KernelCore& kernel_); 55 explicit ServiceManager(Kernel::KernelCore& kernel_);
56 ~ServiceManager(); 56 ~ServiceManager();
57 57
58 ResultCode RegisterService(std::string name, u32 max_sessions, 58 Result RegisterService(std::string name, u32 max_sessions,
59 Kernel::SessionRequestHandlerPtr handler); 59 Kernel::SessionRequestHandlerPtr handler);
60 ResultCode UnregisterService(const std::string& name); 60 Result UnregisterService(const std::string& name);
61 ResultVal<Kernel::KPort*> GetServicePort(const std::string& name); 61 ResultVal<Kernel::KPort*> GetServicePort(const std::string& name);
62 62
63 template <Common::DerivedFrom<Kernel::SessionRequestHandler> T> 63 template <Common::DerivedFrom<Kernel::SessionRequestHandler> T>
diff --git a/src/core/hle/service/sm/sm_controller.cpp b/src/core/hle/service/sm/sm_controller.cpp
index a4ed4193e..2a4bd64ab 100644
--- a/src/core/hle/service/sm/sm_controller.cpp
+++ b/src/core/hle/service/sm/sm_controller.cpp
@@ -33,7 +33,7 @@ void Controller::CloneCurrentObject(Kernel::HLERequestContext& ctx) {
33 33
34 // Create a session. 34 // Create a session.
35 Kernel::KClientSession* session{}; 35 Kernel::KClientSession* session{};
36 const ResultCode result = parent_port.CreateSession(std::addressof(session), session_manager); 36 const Result result = parent_port.CreateSession(std::addressof(session), session_manager);
37 if (result.IsError()) { 37 if (result.IsError()) {
38 LOG_CRITICAL(Service, "CreateSession failed with error 0x{:08X}", result.raw); 38 LOG_CRITICAL(Service, "CreateSession failed with error 0x{:08X}", result.raw);
39 IPC::ResponseBuilder rb{ctx, 2}; 39 IPC::ResponseBuilder rb{ctx, 2};
diff --git a/src/core/hle/service/spl/spl_results.h b/src/core/hle/service/spl/spl_results.h
index 17ef655a9..dd7ba11f3 100644
--- a/src/core/hle/service/spl/spl_results.h
+++ b/src/core/hle/service/spl/spl_results.h
@@ -8,23 +8,23 @@
8namespace Service::SPL { 8namespace Service::SPL {
9 9
10// Description 0 - 99 10// Description 0 - 99
11constexpr ResultCode ResultSecureMonitorError{ErrorModule::SPL, 0}; 11constexpr Result ResultSecureMonitorError{ErrorModule::SPL, 0};
12constexpr ResultCode ResultSecureMonitorNotImplemented{ErrorModule::SPL, 1}; 12constexpr Result ResultSecureMonitorNotImplemented{ErrorModule::SPL, 1};
13constexpr ResultCode ResultSecureMonitorInvalidArgument{ErrorModule::SPL, 2}; 13constexpr Result ResultSecureMonitorInvalidArgument{ErrorModule::SPL, 2};
14constexpr ResultCode ResultSecureMonitorBusy{ErrorModule::SPL, 3}; 14constexpr Result ResultSecureMonitorBusy{ErrorModule::SPL, 3};
15constexpr ResultCode ResultSecureMonitorNoAsyncOperation{ErrorModule::SPL, 4}; 15constexpr Result ResultSecureMonitorNoAsyncOperation{ErrorModule::SPL, 4};
16constexpr ResultCode ResultSecureMonitorInvalidAsyncOperation{ErrorModule::SPL, 5}; 16constexpr Result ResultSecureMonitorInvalidAsyncOperation{ErrorModule::SPL, 5};
17constexpr ResultCode ResultSecureMonitorNotPermitted{ErrorModule::SPL, 6}; 17constexpr Result ResultSecureMonitorNotPermitted{ErrorModule::SPL, 6};
18constexpr ResultCode ResultSecureMonitorNotInitialized{ErrorModule::SPL, 7}; 18constexpr Result ResultSecureMonitorNotInitialized{ErrorModule::SPL, 7};
19 19
20constexpr ResultCode ResultInvalidSize{ErrorModule::SPL, 100}; 20constexpr Result ResultInvalidSize{ErrorModule::SPL, 100};
21constexpr ResultCode ResultUnknownSecureMonitorError{ErrorModule::SPL, 101}; 21constexpr Result ResultUnknownSecureMonitorError{ErrorModule::SPL, 101};
22constexpr ResultCode ResultDecryptionFailed{ErrorModule::SPL, 102}; 22constexpr Result ResultDecryptionFailed{ErrorModule::SPL, 102};
23 23
24constexpr ResultCode ResultOutOfKeySlots{ErrorModule::SPL, 104}; 24constexpr Result ResultOutOfKeySlots{ErrorModule::SPL, 104};
25constexpr ResultCode ResultInvalidKeySlot{ErrorModule::SPL, 105}; 25constexpr Result ResultInvalidKeySlot{ErrorModule::SPL, 105};
26constexpr ResultCode ResultBootReasonAlreadySet{ErrorModule::SPL, 106}; 26constexpr Result ResultBootReasonAlreadySet{ErrorModule::SPL, 106};
27constexpr ResultCode ResultBootReasonNotSet{ErrorModule::SPL, 107}; 27constexpr Result ResultBootReasonNotSet{ErrorModule::SPL, 107};
28constexpr ResultCode ResultInvalidArgument{ErrorModule::SPL, 108}; 28constexpr Result ResultInvalidArgument{ErrorModule::SPL, 108};
29 29
30} // namespace Service::SPL 30} // namespace Service::SPL
diff --git a/src/core/hle/service/time/clock_types.h b/src/core/hle/service/time/clock_types.h
index d0af06d94..ef070f32f 100644
--- a/src/core/hle/service/time/clock_types.h
+++ b/src/core/hle/service/time/clock_types.h
@@ -22,7 +22,7 @@ struct SteadyClockTimePoint {
22 s64 time_point; 22 s64 time_point;
23 Common::UUID clock_source_id; 23 Common::UUID clock_source_id;
24 24
25 ResultCode GetSpanBetween(SteadyClockTimePoint other, s64& span) const { 25 Result GetSpanBetween(SteadyClockTimePoint other, s64& span) const {
26 span = 0; 26 span = 0;
27 27
28 if (clock_source_id != other.clock_source_id) { 28 if (clock_source_id != other.clock_source_id) {
@@ -92,9 +92,9 @@ struct ClockSnapshot {
92 TimeType type; 92 TimeType type;
93 INSERT_PADDING_BYTES_NOINIT(0x2); 93 INSERT_PADDING_BYTES_NOINIT(0x2);
94 94
95 static ResultCode GetCurrentTime(s64& current_time, 95 static Result GetCurrentTime(s64& current_time,
96 const SteadyClockTimePoint& steady_clock_time_point, 96 const SteadyClockTimePoint& steady_clock_time_point,
97 const SystemClockContext& context) { 97 const SystemClockContext& context) {
98 if (steady_clock_time_point.clock_source_id != context.steady_time_point.clock_source_id) { 98 if (steady_clock_time_point.clock_source_id != context.steady_time_point.clock_source_id) {
99 current_time = 0; 99 current_time = 0;
100 return ERROR_TIME_MISMATCH; 100 return ERROR_TIME_MISMATCH;
diff --git a/src/core/hle/service/time/errors.h b/src/core/hle/service/time/errors.h
index 592921f6b..6655d30e1 100644
--- a/src/core/hle/service/time/errors.h
+++ b/src/core/hle/service/time/errors.h
@@ -7,15 +7,15 @@
7 7
8namespace Service::Time { 8namespace Service::Time {
9 9
10constexpr ResultCode ERROR_PERMISSION_DENIED{ErrorModule::Time, 1}; 10constexpr Result ERROR_PERMISSION_DENIED{ErrorModule::Time, 1};
11constexpr ResultCode ERROR_TIME_MISMATCH{ErrorModule::Time, 102}; 11constexpr Result ERROR_TIME_MISMATCH{ErrorModule::Time, 102};
12constexpr ResultCode ERROR_UNINITIALIZED_CLOCK{ErrorModule::Time, 103}; 12constexpr Result ERROR_UNINITIALIZED_CLOCK{ErrorModule::Time, 103};
13constexpr ResultCode ERROR_TIME_NOT_FOUND{ErrorModule::Time, 200}; 13constexpr Result ERROR_TIME_NOT_FOUND{ErrorModule::Time, 200};
14constexpr ResultCode ERROR_OVERFLOW{ErrorModule::Time, 201}; 14constexpr Result ERROR_OVERFLOW{ErrorModule::Time, 201};
15constexpr ResultCode ERROR_LOCATION_NAME_TOO_LONG{ErrorModule::Time, 801}; 15constexpr Result ERROR_LOCATION_NAME_TOO_LONG{ErrorModule::Time, 801};
16constexpr ResultCode ERROR_OUT_OF_RANGE{ErrorModule::Time, 902}; 16constexpr Result ERROR_OUT_OF_RANGE{ErrorModule::Time, 902};
17constexpr ResultCode ERROR_TIME_ZONE_CONVERSION_FAILED{ErrorModule::Time, 903}; 17constexpr Result ERROR_TIME_ZONE_CONVERSION_FAILED{ErrorModule::Time, 903};
18constexpr ResultCode ERROR_TIME_ZONE_NOT_FOUND{ErrorModule::Time, 989}; 18constexpr Result ERROR_TIME_ZONE_NOT_FOUND{ErrorModule::Time, 989};
19constexpr ResultCode ERROR_NOT_IMPLEMENTED{ErrorModule::Time, 990}; 19constexpr Result ERROR_NOT_IMPLEMENTED{ErrorModule::Time, 990};
20 20
21} // namespace Service::Time 21} // namespace Service::Time
diff --git a/src/core/hle/service/time/local_system_clock_context_writer.h b/src/core/hle/service/time/local_system_clock_context_writer.h
index 0977806b3..1639ef2b9 100644
--- a/src/core/hle/service/time/local_system_clock_context_writer.h
+++ b/src/core/hle/service/time/local_system_clock_context_writer.h
@@ -14,7 +14,7 @@ public:
14 : SystemClockContextUpdateCallback{}, shared_memory{shared_memory_} {} 14 : SystemClockContextUpdateCallback{}, shared_memory{shared_memory_} {}
15 15
16protected: 16protected:
17 ResultCode Update() override { 17 Result Update() override {
18 shared_memory.UpdateLocalSystemClockContext(context); 18 shared_memory.UpdateLocalSystemClockContext(context);
19 return ResultSuccess; 19 return ResultSuccess;
20 } 20 }
diff --git a/src/core/hle/service/time/network_system_clock_context_writer.h b/src/core/hle/service/time/network_system_clock_context_writer.h
index 975089af8..655e4c06d 100644
--- a/src/core/hle/service/time/network_system_clock_context_writer.h
+++ b/src/core/hle/service/time/network_system_clock_context_writer.h
@@ -15,7 +15,7 @@ public:
15 : SystemClockContextUpdateCallback{}, shared_memory{shared_memory_} {} 15 : SystemClockContextUpdateCallback{}, shared_memory{shared_memory_} {}
16 16
17protected: 17protected:
18 ResultCode Update() override { 18 Result Update() override {
19 shared_memory.UpdateNetworkSystemClockContext(context); 19 shared_memory.UpdateNetworkSystemClockContext(context);
20 return ResultSuccess; 20 return ResultSuccess;
21 } 21 }
diff --git a/src/core/hle/service/time/standard_user_system_clock_core.cpp b/src/core/hle/service/time/standard_user_system_clock_core.cpp
index 508091dc2..b033757ed 100644
--- a/src/core/hle/service/time/standard_user_system_clock_core.cpp
+++ b/src/core/hle/service/time/standard_user_system_clock_core.cpp
@@ -27,9 +27,9 @@ StandardUserSystemClockCore::~StandardUserSystemClockCore() {
27 service_context.CloseEvent(auto_correction_event); 27 service_context.CloseEvent(auto_correction_event);
28} 28}
29 29
30ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::System& system, 30Result StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::System& system,
31 bool value) { 31 bool value) {
32 if (const ResultCode result{ApplyAutomaticCorrection(system, value)}; result != ResultSuccess) { 32 if (const Result result{ApplyAutomaticCorrection(system, value)}; result != ResultSuccess) {
33 return result; 33 return result;
34 } 34 }
35 35
@@ -38,27 +38,27 @@ ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::Syst
38 return ResultSuccess; 38 return ResultSuccess;
39} 39}
40 40
41ResultCode StandardUserSystemClockCore::GetClockContext(Core::System& system, 41Result StandardUserSystemClockCore::GetClockContext(Core::System& system,
42 SystemClockContext& ctx) const { 42 SystemClockContext& ctx) const {
43 if (const ResultCode result{ApplyAutomaticCorrection(system, false)}; result != ResultSuccess) { 43 if (const Result result{ApplyAutomaticCorrection(system, false)}; result != ResultSuccess) {
44 return result; 44 return result;
45 } 45 }
46 46
47 return local_system_clock_core.GetClockContext(system, ctx); 47 return local_system_clock_core.GetClockContext(system, ctx);
48} 48}
49 49
50ResultCode StandardUserSystemClockCore::Flush(const SystemClockContext&) { 50Result StandardUserSystemClockCore::Flush(const SystemClockContext&) {
51 UNIMPLEMENTED(); 51 UNIMPLEMENTED();
52 return ERROR_NOT_IMPLEMENTED; 52 return ERROR_NOT_IMPLEMENTED;
53} 53}
54 54
55ResultCode StandardUserSystemClockCore::SetClockContext(const SystemClockContext&) { 55Result StandardUserSystemClockCore::SetClockContext(const SystemClockContext&) {
56 UNIMPLEMENTED(); 56 UNIMPLEMENTED();
57 return ERROR_NOT_IMPLEMENTED; 57 return ERROR_NOT_IMPLEMENTED;
58} 58}
59 59
60ResultCode StandardUserSystemClockCore::ApplyAutomaticCorrection(Core::System& system, 60Result StandardUserSystemClockCore::ApplyAutomaticCorrection(Core::System& system,
61 bool value) const { 61 bool value) const {
62 if (auto_correction_enabled == value) { 62 if (auto_correction_enabled == value) {
63 return ResultSuccess; 63 return ResultSuccess;
64 } 64 }
@@ -68,7 +68,7 @@ ResultCode StandardUserSystemClockCore::ApplyAutomaticCorrection(Core::System& s
68 } 68 }
69 69
70 SystemClockContext ctx{}; 70 SystemClockContext ctx{};
71 if (const ResultCode result{network_system_clock_core.GetClockContext(system, ctx)}; 71 if (const Result result{network_system_clock_core.GetClockContext(system, ctx)};
72 result != ResultSuccess) { 72 result != ResultSuccess) {
73 return result; 73 return result;
74 } 74 }
diff --git a/src/core/hle/service/time/standard_user_system_clock_core.h b/src/core/hle/service/time/standard_user_system_clock_core.h
index 22df23b29..ee6e29487 100644
--- a/src/core/hle/service/time/standard_user_system_clock_core.h
+++ b/src/core/hle/service/time/standard_user_system_clock_core.h
@@ -28,9 +28,9 @@ public:
28 28
29 ~StandardUserSystemClockCore() override; 29 ~StandardUserSystemClockCore() override;
30 30
31 ResultCode SetAutomaticCorrectionEnabled(Core::System& system, bool value); 31 Result SetAutomaticCorrectionEnabled(Core::System& system, bool value);
32 32
33 ResultCode GetClockContext(Core::System& system, SystemClockContext& ctx) const override; 33 Result GetClockContext(Core::System& system, SystemClockContext& ctx) const override;
34 34
35 bool IsAutomaticCorrectionEnabled() const { 35 bool IsAutomaticCorrectionEnabled() const {
36 return auto_correction_enabled; 36 return auto_correction_enabled;
@@ -41,11 +41,11 @@ public:
41 } 41 }
42 42
43protected: 43protected:
44 ResultCode Flush(const SystemClockContext&) override; 44 Result Flush(const SystemClockContext&) override;
45 45
46 ResultCode SetClockContext(const SystemClockContext&) override; 46 Result SetClockContext(const SystemClockContext&) override;
47 47
48 ResultCode ApplyAutomaticCorrection(Core::System& system, bool value) const; 48 Result ApplyAutomaticCorrection(Core::System& system, bool value) const;
49 49
50 const SteadyClockTimePoint& GetAutomaticCorrectionUpdatedTime() const { 50 const SteadyClockTimePoint& GetAutomaticCorrectionUpdatedTime() const {
51 return auto_correction_time; 51 return auto_correction_time;
diff --git a/src/core/hle/service/time/system_clock_context_update_callback.cpp b/src/core/hle/service/time/system_clock_context_update_callback.cpp
index 37c140c6f..a649bed3a 100644
--- a/src/core/hle/service/time/system_clock_context_update_callback.cpp
+++ b/src/core/hle/service/time/system_clock_context_update_callback.cpp
@@ -30,8 +30,8 @@ void SystemClockContextUpdateCallback::BroadcastOperationEvent() {
30 } 30 }
31} 31}
32 32
33ResultCode SystemClockContextUpdateCallback::Update(const SystemClockContext& value) { 33Result SystemClockContextUpdateCallback::Update(const SystemClockContext& value) {
34 ResultCode result{ResultSuccess}; 34 Result result{ResultSuccess};
35 35
36 if (NeedUpdate(value)) { 36 if (NeedUpdate(value)) {
37 context = value; 37 context = value;
@@ -47,7 +47,7 @@ ResultCode SystemClockContextUpdateCallback::Update(const SystemClockContext& va
47 return result; 47 return result;
48} 48}
49 49
50ResultCode SystemClockContextUpdateCallback::Update() { 50Result SystemClockContextUpdateCallback::Update() {
51 return ResultSuccess; 51 return ResultSuccess;
52} 52}
53 53
diff --git a/src/core/hle/service/time/system_clock_context_update_callback.h b/src/core/hle/service/time/system_clock_context_update_callback.h
index bee90e329..9c6caf196 100644
--- a/src/core/hle/service/time/system_clock_context_update_callback.h
+++ b/src/core/hle/service/time/system_clock_context_update_callback.h
@@ -28,10 +28,10 @@ public:
28 28
29 void BroadcastOperationEvent(); 29 void BroadcastOperationEvent();
30 30
31 ResultCode Update(const SystemClockContext& value); 31 Result Update(const SystemClockContext& value);
32 32
33protected: 33protected:
34 virtual ResultCode Update(); 34 virtual Result Update();
35 35
36 SystemClockContext context{}; 36 SystemClockContext context{};
37 37
diff --git a/src/core/hle/service/time/system_clock_core.cpp b/src/core/hle/service/time/system_clock_core.cpp
index cb132239c..da078241f 100644
--- a/src/core/hle/service/time/system_clock_core.cpp
+++ b/src/core/hle/service/time/system_clock_core.cpp
@@ -14,13 +14,13 @@ SystemClockCore::SystemClockCore(SteadyClockCore& steady_clock_core_)
14 14
15SystemClockCore::~SystemClockCore() = default; 15SystemClockCore::~SystemClockCore() = default;
16 16
17ResultCode SystemClockCore::GetCurrentTime(Core::System& system, s64& posix_time) const { 17Result SystemClockCore::GetCurrentTime(Core::System& system, s64& posix_time) const {
18 posix_time = 0; 18 posix_time = 0;
19 19
20 const SteadyClockTimePoint current_time_point{steady_clock_core.GetCurrentTimePoint(system)}; 20 const SteadyClockTimePoint current_time_point{steady_clock_core.GetCurrentTimePoint(system)};
21 21
22 SystemClockContext clock_context{}; 22 SystemClockContext clock_context{};
23 if (const ResultCode result{GetClockContext(system, clock_context)}; result != ResultSuccess) { 23 if (const Result result{GetClockContext(system, clock_context)}; result != ResultSuccess) {
24 return result; 24 return result;
25 } 25 }
26 26
@@ -33,26 +33,26 @@ ResultCode SystemClockCore::GetCurrentTime(Core::System& system, s64& posix_time
33 return ResultSuccess; 33 return ResultSuccess;
34} 34}
35 35
36ResultCode SystemClockCore::SetCurrentTime(Core::System& system, s64 posix_time) { 36Result SystemClockCore::SetCurrentTime(Core::System& system, s64 posix_time) {
37 const SteadyClockTimePoint current_time_point{steady_clock_core.GetCurrentTimePoint(system)}; 37 const SteadyClockTimePoint current_time_point{steady_clock_core.GetCurrentTimePoint(system)};
38 const SystemClockContext clock_context{posix_time - current_time_point.time_point, 38 const SystemClockContext clock_context{posix_time - current_time_point.time_point,
39 current_time_point}; 39 current_time_point};
40 40
41 if (const ResultCode result{SetClockContext(clock_context)}; result != ResultSuccess) { 41 if (const Result result{SetClockContext(clock_context)}; result != ResultSuccess) {
42 return result; 42 return result;
43 } 43 }
44 return Flush(clock_context); 44 return Flush(clock_context);
45} 45}
46 46
47ResultCode SystemClockCore::Flush(const SystemClockContext& clock_context) { 47Result SystemClockCore::Flush(const SystemClockContext& clock_context) {
48 if (!system_clock_context_update_callback) { 48 if (!system_clock_context_update_callback) {
49 return ResultSuccess; 49 return ResultSuccess;
50 } 50 }
51 return system_clock_context_update_callback->Update(clock_context); 51 return system_clock_context_update_callback->Update(clock_context);
52} 52}
53 53
54ResultCode SystemClockCore::SetSystemClockContext(const SystemClockContext& clock_context) { 54Result SystemClockCore::SetSystemClockContext(const SystemClockContext& clock_context) {
55 if (const ResultCode result{SetClockContext(clock_context)}; result != ResultSuccess) { 55 if (const Result result{SetClockContext(clock_context)}; result != ResultSuccess) {
56 return result; 56 return result;
57 } 57 }
58 return Flush(clock_context); 58 return Flush(clock_context);
diff --git a/src/core/hle/service/time/system_clock_core.h b/src/core/hle/service/time/system_clock_core.h
index 76d82f976..8cb34126f 100644
--- a/src/core/hle/service/time/system_clock_core.h
+++ b/src/core/hle/service/time/system_clock_core.h
@@ -29,28 +29,28 @@ public:
29 return steady_clock_core; 29 return steady_clock_core;
30 } 30 }
31 31
32 ResultCode GetCurrentTime(Core::System& system, s64& posix_time) const; 32 Result GetCurrentTime(Core::System& system, s64& posix_time) const;
33 33
34 ResultCode SetCurrentTime(Core::System& system, s64 posix_time); 34 Result SetCurrentTime(Core::System& system, s64 posix_time);
35 35
36 virtual ResultCode GetClockContext([[maybe_unused]] Core::System& system, 36 virtual Result GetClockContext([[maybe_unused]] Core::System& system,
37 SystemClockContext& value) const { 37 SystemClockContext& value) const {
38 value = context; 38 value = context;
39 return ResultSuccess; 39 return ResultSuccess;
40 } 40 }
41 41
42 virtual ResultCode SetClockContext(const SystemClockContext& value) { 42 virtual Result SetClockContext(const SystemClockContext& value) {
43 context = value; 43 context = value;
44 return ResultSuccess; 44 return ResultSuccess;
45 } 45 }
46 46
47 virtual ResultCode Flush(const SystemClockContext& clock_context); 47 virtual Result Flush(const SystemClockContext& clock_context);
48 48
49 void SetUpdateCallbackInstance(std::shared_ptr<SystemClockContextUpdateCallback> callback) { 49 void SetUpdateCallbackInstance(std::shared_ptr<SystemClockContextUpdateCallback> callback) {
50 system_clock_context_update_callback = std::move(callback); 50 system_clock_context_update_callback = std::move(callback);
51 } 51 }
52 52
53 ResultCode SetSystemClockContext(const SystemClockContext& context); 53 Result SetSystemClockContext(const SystemClockContext& context);
54 54
55 bool IsInitialized() const { 55 bool IsInitialized() const {
56 return is_initialized; 56 return is_initialized;
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index 095fa021c..f77cdbb43 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -43,8 +43,7 @@ private:
43 } 43 }
44 44
45 s64 posix_time{}; 45 s64 posix_time{};
46 if (const ResultCode result{clock_core.GetCurrentTime(system, posix_time)}; 46 if (const Result result{clock_core.GetCurrentTime(system, posix_time)}; result.IsError()) {
47 result.IsError()) {
48 IPC::ResponseBuilder rb{ctx, 2}; 47 IPC::ResponseBuilder rb{ctx, 2};
49 rb.Push(result); 48 rb.Push(result);
50 return; 49 return;
@@ -65,7 +64,7 @@ private:
65 } 64 }
66 65
67 Clock::SystemClockContext system_clock_context{}; 66 Clock::SystemClockContext system_clock_context{};
68 if (const ResultCode result{clock_core.GetClockContext(system, system_clock_context)}; 67 if (const Result result{clock_core.GetClockContext(system, system_clock_context)};
69 result.IsError()) { 68 result.IsError()) {
70 IPC::ResponseBuilder rb{ctx, 2}; 69 IPC::ResponseBuilder rb{ctx, 2};
71 rb.Push(result); 70 rb.Push(result);
@@ -116,7 +115,7 @@ private:
116 Clock::SteadyClockCore& clock_core; 115 Clock::SteadyClockCore& clock_core;
117}; 116};
118 117
119ResultCode Module::Interface::GetClockSnapshotFromSystemClockContextInternal( 118Result Module::Interface::GetClockSnapshotFromSystemClockContextInternal(
120 Kernel::KThread* thread, Clock::SystemClockContext user_context, 119 Kernel::KThread* thread, Clock::SystemClockContext user_context,
121 Clock::SystemClockContext network_context, Clock::TimeType type, 120 Clock::SystemClockContext network_context, Clock::TimeType type,
122 Clock::ClockSnapshot& clock_snapshot) { 121 Clock::ClockSnapshot& clock_snapshot) {
@@ -129,7 +128,7 @@ ResultCode Module::Interface::GetClockSnapshotFromSystemClockContextInternal(
129 time_manager.GetStandardUserSystemClockCore().IsAutomaticCorrectionEnabled(); 128 time_manager.GetStandardUserSystemClockCore().IsAutomaticCorrectionEnabled();
130 clock_snapshot.type = type; 129 clock_snapshot.type = type;
131 130
132 if (const ResultCode result{ 131 if (const Result result{
133 time_manager.GetTimeZoneContentManager().GetTimeZoneManager().GetDeviceLocationName( 132 time_manager.GetTimeZoneContentManager().GetTimeZoneManager().GetDeviceLocationName(
134 clock_snapshot.location_name)}; 133 clock_snapshot.location_name)};
135 result != ResultSuccess) { 134 result != ResultSuccess) {
@@ -138,7 +137,7 @@ ResultCode Module::Interface::GetClockSnapshotFromSystemClockContextInternal(
138 137
139 clock_snapshot.user_context = user_context; 138 clock_snapshot.user_context = user_context;
140 139
141 if (const ResultCode result{Clock::ClockSnapshot::GetCurrentTime( 140 if (const Result result{Clock::ClockSnapshot::GetCurrentTime(
142 clock_snapshot.user_time, clock_snapshot.steady_clock_time_point, 141 clock_snapshot.user_time, clock_snapshot.steady_clock_time_point,
143 clock_snapshot.user_context)}; 142 clock_snapshot.user_context)};
144 result != ResultSuccess) { 143 result != ResultSuccess) {
@@ -146,7 +145,7 @@ ResultCode Module::Interface::GetClockSnapshotFromSystemClockContextInternal(
146 } 145 }
147 146
148 TimeZone::CalendarInfo userCalendarInfo{}; 147 TimeZone::CalendarInfo userCalendarInfo{};
149 if (const ResultCode result{ 148 if (const Result result{
150 time_manager.GetTimeZoneContentManager().GetTimeZoneManager().ToCalendarTimeWithMyRules( 149 time_manager.GetTimeZoneContentManager().GetTimeZoneManager().ToCalendarTimeWithMyRules(
151 clock_snapshot.user_time, userCalendarInfo)}; 150 clock_snapshot.user_time, userCalendarInfo)};
152 result != ResultSuccess) { 151 result != ResultSuccess) {
@@ -165,7 +164,7 @@ ResultCode Module::Interface::GetClockSnapshotFromSystemClockContextInternal(
165 } 164 }
166 165
167 TimeZone::CalendarInfo networkCalendarInfo{}; 166 TimeZone::CalendarInfo networkCalendarInfo{};
168 if (const ResultCode result{ 167 if (const Result result{
169 time_manager.GetTimeZoneContentManager().GetTimeZoneManager().ToCalendarTimeWithMyRules( 168 time_manager.GetTimeZoneContentManager().GetTimeZoneManager().ToCalendarTimeWithMyRules(
170 clock_snapshot.network_time, networkCalendarInfo)}; 169 clock_snapshot.network_time, networkCalendarInfo)};
171 result != ResultSuccess) { 170 result != ResultSuccess) {
@@ -262,7 +261,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
262 LOG_DEBUG(Service_Time, "called, type={}", type); 261 LOG_DEBUG(Service_Time, "called, type={}", type);
263 262
264 Clock::SystemClockContext user_context{}; 263 Clock::SystemClockContext user_context{};
265 if (const ResultCode result{ 264 if (const Result result{
266 system.GetTimeManager().GetStandardUserSystemClockCore().GetClockContext(system, 265 system.GetTimeManager().GetStandardUserSystemClockCore().GetClockContext(system,
267 user_context)}; 266 user_context)};
268 result.IsError()) { 267 result.IsError()) {
@@ -272,7 +271,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
272 } 271 }
273 272
274 Clock::SystemClockContext network_context{}; 273 Clock::SystemClockContext network_context{};
275 if (const ResultCode result{ 274 if (const Result result{
276 system.GetTimeManager().GetStandardNetworkSystemClockCore().GetClockContext( 275 system.GetTimeManager().GetStandardNetworkSystemClockCore().GetClockContext(
277 system, network_context)}; 276 system, network_context)};
278 result.IsError()) { 277 result.IsError()) {
@@ -282,7 +281,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
282 } 281 }
283 282
284 Clock::ClockSnapshot clock_snapshot{}; 283 Clock::ClockSnapshot clock_snapshot{};
285 if (const ResultCode result{GetClockSnapshotFromSystemClockContextInternal( 284 if (const Result result{GetClockSnapshotFromSystemClockContextInternal(
286 &ctx.GetThread(), user_context, network_context, type, clock_snapshot)}; 285 &ctx.GetThread(), user_context, network_context, type, clock_snapshot)};
287 result.IsError()) { 286 result.IsError()) {
288 IPC::ResponseBuilder rb{ctx, 2}; 287 IPC::ResponseBuilder rb{ctx, 2};
@@ -308,7 +307,7 @@ void Module::Interface::GetClockSnapshotFromSystemClockContext(Kernel::HLEReques
308 LOG_DEBUG(Service_Time, "called, type={}", type); 307 LOG_DEBUG(Service_Time, "called, type={}", type);
309 308
310 Clock::ClockSnapshot clock_snapshot{}; 309 Clock::ClockSnapshot clock_snapshot{};
311 if (const ResultCode result{GetClockSnapshotFromSystemClockContextInternal( 310 if (const Result result{GetClockSnapshotFromSystemClockContextInternal(
312 &ctx.GetThread(), user_context, network_context, type, clock_snapshot)}; 311 &ctx.GetThread(), user_context, network_context, type, clock_snapshot)};
313 result != ResultSuccess) { 312 result != ResultSuccess) {
314 IPC::ResponseBuilder rb{ctx, 2}; 313 IPC::ResponseBuilder rb{ctx, 2};
@@ -365,7 +364,7 @@ void Module::Interface::CalculateSpanBetween(Kernel::HLERequestContext& ctx) {
365 Clock::TimeSpanType time_span_type{}; 364 Clock::TimeSpanType time_span_type{};
366 s64 span{}; 365 s64 span{};
367 366
368 if (const ResultCode result{snapshot_a.steady_clock_time_point.GetSpanBetween( 367 if (const Result result{snapshot_a.steady_clock_time_point.GetSpanBetween(
369 snapshot_b.steady_clock_time_point, span)}; 368 snapshot_b.steady_clock_time_point, span)};
370 result != ResultSuccess) { 369 result != ResultSuccess) {
371 if (snapshot_a.network_time && snapshot_b.network_time) { 370 if (snapshot_a.network_time && snapshot_b.network_time) {
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h
index 017f20a23..76a46cfc7 100644
--- a/src/core/hle/service/time/time.h
+++ b/src/core/hle/service/time/time.h
@@ -36,7 +36,7 @@ public:
36 void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx); 36 void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx);
37 37
38 private: 38 private:
39 ResultCode GetClockSnapshotFromSystemClockContextInternal( 39 Result GetClockSnapshotFromSystemClockContextInternal(
40 Kernel::KThread* thread, Clock::SystemClockContext user_context, 40 Kernel::KThread* thread, Clock::SystemClockContext user_context,
41 Clock::SystemClockContext network_context, Clock::TimeType type, 41 Clock::SystemClockContext network_context, Clock::TimeType type,
42 Clock::ClockSnapshot& cloc_snapshot); 42 Clock::ClockSnapshot& cloc_snapshot);
diff --git a/src/core/hle/service/time/time_zone_content_manager.cpp b/src/core/hle/service/time/time_zone_content_manager.cpp
index 80818eb70..afbfe9715 100644
--- a/src/core/hle/service/time/time_zone_content_manager.cpp
+++ b/src/core/hle/service/time/time_zone_content_manager.cpp
@@ -90,10 +90,10 @@ void TimeZoneContentManager::Initialize(TimeManager& time_manager) {
90 } 90 }
91} 91}
92 92
93ResultCode TimeZoneContentManager::LoadTimeZoneRule(TimeZoneRule& rules, 93Result TimeZoneContentManager::LoadTimeZoneRule(TimeZoneRule& rules,
94 const std::string& location_name) const { 94 const std::string& location_name) const {
95 FileSys::VirtualFile vfs_file; 95 FileSys::VirtualFile vfs_file;
96 if (const ResultCode result{GetTimeZoneInfoFile(location_name, vfs_file)}; 96 if (const Result result{GetTimeZoneInfoFile(location_name, vfs_file)};
97 result != ResultSuccess) { 97 result != ResultSuccess) {
98 return result; 98 return result;
99 } 99 }
@@ -106,8 +106,8 @@ bool TimeZoneContentManager::IsLocationNameValid(const std::string& location_nam
106 location_name_cache.end(); 106 location_name_cache.end();
107} 107}
108 108
109ResultCode TimeZoneContentManager::GetTimeZoneInfoFile(const std::string& location_name, 109Result TimeZoneContentManager::GetTimeZoneInfoFile(const std::string& location_name,
110 FileSys::VirtualFile& vfs_file) const { 110 FileSys::VirtualFile& vfs_file) const {
111 if (!IsLocationNameValid(location_name)) { 111 if (!IsLocationNameValid(location_name)) {
112 return ERROR_TIME_NOT_FOUND; 112 return ERROR_TIME_NOT_FOUND;
113 } 113 }
diff --git a/src/core/hle/service/time/time_zone_content_manager.h b/src/core/hle/service/time/time_zone_content_manager.h
index c6c94bcc0..3d94b6428 100644
--- a/src/core/hle/service/time/time_zone_content_manager.h
+++ b/src/core/hle/service/time/time_zone_content_manager.h
@@ -32,12 +32,12 @@ public:
32 return time_zone_manager; 32 return time_zone_manager;
33 } 33 }
34 34
35 ResultCode LoadTimeZoneRule(TimeZoneRule& rules, const std::string& location_name) const; 35 Result LoadTimeZoneRule(TimeZoneRule& rules, const std::string& location_name) const;
36 36
37private: 37private:
38 bool IsLocationNameValid(const std::string& location_name) const; 38 bool IsLocationNameValid(const std::string& location_name) const;
39 ResultCode GetTimeZoneInfoFile(const std::string& location_name, 39 Result GetTimeZoneInfoFile(const std::string& location_name,
40 FileSys::VirtualFile& vfs_file) const; 40 FileSys::VirtualFile& vfs_file) const;
41 41
42 Core::System& system; 42 Core::System& system;
43 TimeZoneManager time_zone_manager; 43 TimeZoneManager time_zone_manager;
diff --git a/src/core/hle/service/time/time_zone_manager.cpp b/src/core/hle/service/time/time_zone_manager.cpp
index fee05ec7a..2aa675df9 100644
--- a/src/core/hle/service/time/time_zone_manager.cpp
+++ b/src/core/hle/service/time/time_zone_manager.cpp
@@ -666,8 +666,8 @@ static bool ParseTimeZoneBinary(TimeZoneRule& time_zone_rule, FileSys::VirtualFi
666 return true; 666 return true;
667} 667}
668 668
669static ResultCode CreateCalendarTime(s64 time, int gmt_offset, CalendarTimeInternal& calendar_time, 669static Result CreateCalendarTime(s64 time, int gmt_offset, CalendarTimeInternal& calendar_time,
670 CalendarAdditionalInfo& calendar_additional_info) { 670 CalendarAdditionalInfo& calendar_additional_info) {
671 s64 year{epoch_year}; 671 s64 year{epoch_year};
672 s64 time_days{time / seconds_per_day}; 672 s64 time_days{time / seconds_per_day};
673 s64 remaining_seconds{time % seconds_per_day}; 673 s64 remaining_seconds{time % seconds_per_day};
@@ -741,9 +741,9 @@ static ResultCode CreateCalendarTime(s64 time, int gmt_offset, CalendarTimeInter
741 return ResultSuccess; 741 return ResultSuccess;
742} 742}
743 743
744static ResultCode ToCalendarTimeInternal(const TimeZoneRule& rules, s64 time, 744static Result ToCalendarTimeInternal(const TimeZoneRule& rules, s64 time,
745 CalendarTimeInternal& calendar_time, 745 CalendarTimeInternal& calendar_time,
746 CalendarAdditionalInfo& calendar_additional_info) { 746 CalendarAdditionalInfo& calendar_additional_info) {
747 if ((rules.go_ahead && time < rules.ats[0]) || 747 if ((rules.go_ahead && time < rules.ats[0]) ||
748 (rules.go_back && time > rules.ats[rules.time_count - 1])) { 748 (rules.go_back && time > rules.ats[rules.time_count - 1])) {
749 s64 seconds{}; 749 s64 seconds{};
@@ -766,7 +766,7 @@ static ResultCode ToCalendarTimeInternal(const TimeZoneRule& rules, s64 time,
766 if (new_time < rules.ats[0] && new_time > rules.ats[rules.time_count - 1]) { 766 if (new_time < rules.ats[0] && new_time > rules.ats[rules.time_count - 1]) {
767 return ERROR_TIME_NOT_FOUND; 767 return ERROR_TIME_NOT_FOUND;
768 } 768 }
769 if (const ResultCode result{ 769 if (const Result result{
770 ToCalendarTimeInternal(rules, new_time, calendar_time, calendar_additional_info)}; 770 ToCalendarTimeInternal(rules, new_time, calendar_time, calendar_additional_info)};
771 result != ResultSuccess) { 771 result != ResultSuccess) {
772 return result; 772 return result;
@@ -797,8 +797,8 @@ static ResultCode ToCalendarTimeInternal(const TimeZoneRule& rules, s64 time,
797 tti_index = rules.types[low - 1]; 797 tti_index = rules.types[low - 1];
798 } 798 }
799 799
800 if (const ResultCode result{CreateCalendarTime(time, rules.ttis[tti_index].gmt_offset, 800 if (const Result result{CreateCalendarTime(time, rules.ttis[tti_index].gmt_offset,
801 calendar_time, calendar_additional_info)}; 801 calendar_time, calendar_additional_info)};
802 result != ResultSuccess) { 802 result != ResultSuccess) {
803 return result; 803 return result;
804 } 804 }
@@ -811,9 +811,9 @@ static ResultCode ToCalendarTimeInternal(const TimeZoneRule& rules, s64 time,
811 return ResultSuccess; 811 return ResultSuccess;
812} 812}
813 813
814static ResultCode ToCalendarTimeImpl(const TimeZoneRule& rules, s64 time, CalendarInfo& calendar) { 814static Result ToCalendarTimeImpl(const TimeZoneRule& rules, s64 time, CalendarInfo& calendar) {
815 CalendarTimeInternal calendar_time{}; 815 CalendarTimeInternal calendar_time{};
816 const ResultCode result{ 816 const Result result{
817 ToCalendarTimeInternal(rules, time, calendar_time, calendar.additional_info)}; 817 ToCalendarTimeInternal(rules, time, calendar_time, calendar.additional_info)};
818 calendar.time.year = static_cast<s16>(calendar_time.year); 818 calendar.time.year = static_cast<s16>(calendar_time.year);
819 819
@@ -830,13 +830,13 @@ static ResultCode ToCalendarTimeImpl(const TimeZoneRule& rules, s64 time, Calend
830TimeZoneManager::TimeZoneManager() = default; 830TimeZoneManager::TimeZoneManager() = default;
831TimeZoneManager::~TimeZoneManager() = default; 831TimeZoneManager::~TimeZoneManager() = default;
832 832
833ResultCode TimeZoneManager::ToCalendarTime(const TimeZoneRule& rules, s64 time, 833Result TimeZoneManager::ToCalendarTime(const TimeZoneRule& rules, s64 time,
834 CalendarInfo& calendar) const { 834 CalendarInfo& calendar) const {
835 return ToCalendarTimeImpl(rules, time, calendar); 835 return ToCalendarTimeImpl(rules, time, calendar);
836} 836}
837 837
838ResultCode TimeZoneManager::SetDeviceLocationNameWithTimeZoneRule(const std::string& location_name, 838Result TimeZoneManager::SetDeviceLocationNameWithTimeZoneRule(const std::string& location_name,
839 FileSys::VirtualFile& vfs_file) { 839 FileSys::VirtualFile& vfs_file) {
840 TimeZoneRule rule{}; 840 TimeZoneRule rule{};
841 if (ParseTimeZoneBinary(rule, vfs_file)) { 841 if (ParseTimeZoneBinary(rule, vfs_file)) {
842 device_location_name = location_name; 842 device_location_name = location_name;
@@ -846,12 +846,12 @@ ResultCode TimeZoneManager::SetDeviceLocationNameWithTimeZoneRule(const std::str
846 return ERROR_TIME_ZONE_CONVERSION_FAILED; 846 return ERROR_TIME_ZONE_CONVERSION_FAILED;
847} 847}
848 848
849ResultCode TimeZoneManager::SetUpdatedTime(const Clock::SteadyClockTimePoint& value) { 849Result TimeZoneManager::SetUpdatedTime(const Clock::SteadyClockTimePoint& value) {
850 time_zone_update_time_point = value; 850 time_zone_update_time_point = value;
851 return ResultSuccess; 851 return ResultSuccess;
852} 852}
853 853
854ResultCode TimeZoneManager::ToCalendarTimeWithMyRules(s64 time, CalendarInfo& calendar) const { 854Result TimeZoneManager::ToCalendarTimeWithMyRules(s64 time, CalendarInfo& calendar) const {
855 if (is_initialized) { 855 if (is_initialized) {
856 return ToCalendarTime(time_zone_rule, time, calendar); 856 return ToCalendarTime(time_zone_rule, time, calendar);
857 } else { 857 } else {
@@ -859,16 +859,16 @@ ResultCode TimeZoneManager::ToCalendarTimeWithMyRules(s64 time, CalendarInfo& ca
859 } 859 }
860} 860}
861 861
862ResultCode TimeZoneManager::ParseTimeZoneRuleBinary(TimeZoneRule& rules, 862Result TimeZoneManager::ParseTimeZoneRuleBinary(TimeZoneRule& rules,
863 FileSys::VirtualFile& vfs_file) const { 863 FileSys::VirtualFile& vfs_file) const {
864 if (!ParseTimeZoneBinary(rules, vfs_file)) { 864 if (!ParseTimeZoneBinary(rules, vfs_file)) {
865 return ERROR_TIME_ZONE_CONVERSION_FAILED; 865 return ERROR_TIME_ZONE_CONVERSION_FAILED;
866 } 866 }
867 return ResultSuccess; 867 return ResultSuccess;
868} 868}
869 869
870ResultCode TimeZoneManager::ToPosixTime(const TimeZoneRule& rules, 870Result TimeZoneManager::ToPosixTime(const TimeZoneRule& rules, const CalendarTime& calendar_time,
871 const CalendarTime& calendar_time, s64& posix_time) const { 871 s64& posix_time) const {
872 posix_time = 0; 872 posix_time = 0;
873 873
874 CalendarTimeInternal internal_time{ 874 CalendarTimeInternal internal_time{
@@ -1020,8 +1020,8 @@ ResultCode TimeZoneManager::ToPosixTime(const TimeZoneRule& rules,
1020 return ResultSuccess; 1020 return ResultSuccess;
1021} 1021}
1022 1022
1023ResultCode TimeZoneManager::ToPosixTimeWithMyRule(const CalendarTime& calendar_time, 1023Result TimeZoneManager::ToPosixTimeWithMyRule(const CalendarTime& calendar_time,
1024 s64& posix_time) const { 1024 s64& posix_time) const {
1025 if (is_initialized) { 1025 if (is_initialized) {
1026 return ToPosixTime(time_zone_rule, calendar_time, posix_time); 1026 return ToPosixTime(time_zone_rule, calendar_time, posix_time);
1027 } 1027 }
@@ -1029,7 +1029,7 @@ ResultCode TimeZoneManager::ToPosixTimeWithMyRule(const CalendarTime& calendar_t
1029 return ERROR_UNINITIALIZED_CLOCK; 1029 return ERROR_UNINITIALIZED_CLOCK;
1030} 1030}
1031 1031
1032ResultCode TimeZoneManager::GetDeviceLocationName(LocationName& value) const { 1032Result TimeZoneManager::GetDeviceLocationName(LocationName& value) const {
1033 if (!is_initialized) { 1033 if (!is_initialized) {
1034 return ERROR_UNINITIALIZED_CLOCK; 1034 return ERROR_UNINITIALIZED_CLOCK;
1035 } 1035 }
diff --git a/src/core/hle/service/time/time_zone_manager.h b/src/core/hle/service/time/time_zone_manager.h
index 8c1b19f81..5ebd4035e 100644
--- a/src/core/hle/service/time/time_zone_manager.h
+++ b/src/core/hle/service/time/time_zone_manager.h
@@ -29,16 +29,16 @@ public:
29 is_initialized = true; 29 is_initialized = true;
30 } 30 }
31 31
32 ResultCode SetDeviceLocationNameWithTimeZoneRule(const std::string& location_name, 32 Result SetDeviceLocationNameWithTimeZoneRule(const std::string& location_name,
33 FileSys::VirtualFile& vfs_file); 33 FileSys::VirtualFile& vfs_file);
34 ResultCode SetUpdatedTime(const Clock::SteadyClockTimePoint& value); 34 Result SetUpdatedTime(const Clock::SteadyClockTimePoint& value);
35 ResultCode GetDeviceLocationName(TimeZone::LocationName& value) const; 35 Result GetDeviceLocationName(TimeZone::LocationName& value) const;
36 ResultCode ToCalendarTime(const TimeZoneRule& rules, s64 time, CalendarInfo& calendar) const; 36 Result ToCalendarTime(const TimeZoneRule& rules, s64 time, CalendarInfo& calendar) const;
37 ResultCode ToCalendarTimeWithMyRules(s64 time, CalendarInfo& calendar) const; 37 Result ToCalendarTimeWithMyRules(s64 time, CalendarInfo& calendar) const;
38 ResultCode ParseTimeZoneRuleBinary(TimeZoneRule& rules, FileSys::VirtualFile& vfs_file) const; 38 Result ParseTimeZoneRuleBinary(TimeZoneRule& rules, FileSys::VirtualFile& vfs_file) const;
39 ResultCode ToPosixTime(const TimeZoneRule& rules, const CalendarTime& calendar_time, 39 Result ToPosixTime(const TimeZoneRule& rules, const CalendarTime& calendar_time,
40 s64& posix_time) const; 40 s64& posix_time) const;
41 ResultCode ToPosixTimeWithMyRule(const CalendarTime& calendar_time, s64& posix_time) const; 41 Result ToPosixTimeWithMyRule(const CalendarTime& calendar_time, s64& posix_time) const;
42 42
43private: 43private:
44 bool is_initialized{}; 44 bool is_initialized{};
diff --git a/src/core/hle/service/time/time_zone_service.cpp b/src/core/hle/service/time/time_zone_service.cpp
index cbf0ef6fa..961040bfc 100644
--- a/src/core/hle/service/time/time_zone_service.cpp
+++ b/src/core/hle/service/time/time_zone_service.cpp
@@ -32,7 +32,7 @@ void ITimeZoneService::GetDeviceLocationName(Kernel::HLERequestContext& ctx) {
32 LOG_DEBUG(Service_Time, "called"); 32 LOG_DEBUG(Service_Time, "called");
33 33
34 TimeZone::LocationName location_name{}; 34 TimeZone::LocationName location_name{};
35 if (const ResultCode result{ 35 if (const Result result{
36 time_zone_content_manager.GetTimeZoneManager().GetDeviceLocationName(location_name)}; 36 time_zone_content_manager.GetTimeZoneManager().GetDeviceLocationName(location_name)};
37 result != ResultSuccess) { 37 result != ResultSuccess) {
38 IPC::ResponseBuilder rb{ctx, 2}; 38 IPC::ResponseBuilder rb{ctx, 2};
@@ -61,7 +61,7 @@ void ITimeZoneService::LoadTimeZoneRule(Kernel::HLERequestContext& ctx) {
61 LOG_DEBUG(Service_Time, "called, location_name={}", location_name); 61 LOG_DEBUG(Service_Time, "called, location_name={}", location_name);
62 62
63 TimeZone::TimeZoneRule time_zone_rule{}; 63 TimeZone::TimeZoneRule time_zone_rule{};
64 if (const ResultCode result{ 64 if (const Result result{
65 time_zone_content_manager.LoadTimeZoneRule(time_zone_rule, location_name)}; 65 time_zone_content_manager.LoadTimeZoneRule(time_zone_rule, location_name)};
66 result != ResultSuccess) { 66 result != ResultSuccess) {
67 IPC::ResponseBuilder rb{ctx, 2}; 67 IPC::ResponseBuilder rb{ctx, 2};
@@ -88,7 +88,7 @@ void ITimeZoneService::ToCalendarTime(Kernel::HLERequestContext& ctx) {
88 std::memcpy(&time_zone_rule, buffer.data(), buffer.size()); 88 std::memcpy(&time_zone_rule, buffer.data(), buffer.size());
89 89
90 TimeZone::CalendarInfo calendar_info{}; 90 TimeZone::CalendarInfo calendar_info{};
91 if (const ResultCode result{time_zone_content_manager.GetTimeZoneManager().ToCalendarTime( 91 if (const Result result{time_zone_content_manager.GetTimeZoneManager().ToCalendarTime(
92 time_zone_rule, posix_time, calendar_info)}; 92 time_zone_rule, posix_time, calendar_info)};
93 result != ResultSuccess) { 93 result != ResultSuccess) {
94 IPC::ResponseBuilder rb{ctx, 2}; 94 IPC::ResponseBuilder rb{ctx, 2};
@@ -108,7 +108,7 @@ void ITimeZoneService::ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx)
108 LOG_DEBUG(Service_Time, "called, posix_time=0x{:016X}", posix_time); 108 LOG_DEBUG(Service_Time, "called, posix_time=0x{:016X}", posix_time);
109 109
110 TimeZone::CalendarInfo calendar_info{}; 110 TimeZone::CalendarInfo calendar_info{};
111 if (const ResultCode result{ 111 if (const Result result{
112 time_zone_content_manager.GetTimeZoneManager().ToCalendarTimeWithMyRules( 112 time_zone_content_manager.GetTimeZoneManager().ToCalendarTimeWithMyRules(
113 posix_time, calendar_info)}; 113 posix_time, calendar_info)};
114 result != ResultSuccess) { 114 result != ResultSuccess) {
@@ -131,7 +131,7 @@ void ITimeZoneService::ToPosixTime(Kernel::HLERequestContext& ctx) {
131 std::memcpy(&time_zone_rule, ctx.ReadBuffer().data(), sizeof(TimeZone::TimeZoneRule)); 131 std::memcpy(&time_zone_rule, ctx.ReadBuffer().data(), sizeof(TimeZone::TimeZoneRule));
132 132
133 s64 posix_time{}; 133 s64 posix_time{};
134 if (const ResultCode result{time_zone_content_manager.GetTimeZoneManager().ToPosixTime( 134 if (const Result result{time_zone_content_manager.GetTimeZoneManager().ToPosixTime(
135 time_zone_rule, calendar_time, posix_time)}; 135 time_zone_rule, calendar_time, posix_time)};
136 result != ResultSuccess) { 136 result != ResultSuccess) {
137 IPC::ResponseBuilder rb{ctx, 2}; 137 IPC::ResponseBuilder rb{ctx, 2};
@@ -154,9 +154,8 @@ void ITimeZoneService::ToPosixTimeWithMyRule(Kernel::HLERequestContext& ctx) {
154 const auto calendar_time{rp.PopRaw<TimeZone::CalendarTime>()}; 154 const auto calendar_time{rp.PopRaw<TimeZone::CalendarTime>()};
155 155
156 s64 posix_time{}; 156 s64 posix_time{};
157 if (const ResultCode result{ 157 if (const Result result{time_zone_content_manager.GetTimeZoneManager().ToPosixTimeWithMyRule(
158 time_zone_content_manager.GetTimeZoneManager().ToPosixTimeWithMyRule(calendar_time, 158 calendar_time, posix_time)};
159 posix_time)};
160 result != ResultSuccess) { 159 result != ResultSuccess) {
161 IPC::ResponseBuilder rb{ctx, 2}; 160 IPC::ResponseBuilder rb{ctx, 2};
162 rb.Push(result); 161 rb.Push(result);
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index a7b53d7dc..546879648 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -34,10 +34,10 @@
34 34
35namespace Service::VI { 35namespace Service::VI {
36 36
37constexpr ResultCode ERR_OPERATION_FAILED{ErrorModule::VI, 1}; 37constexpr Result ERR_OPERATION_FAILED{ErrorModule::VI, 1};
38constexpr ResultCode ERR_PERMISSION_DENIED{ErrorModule::VI, 5}; 38constexpr Result ERR_PERMISSION_DENIED{ErrorModule::VI, 5};
39constexpr ResultCode ERR_UNSUPPORTED{ErrorModule::VI, 6}; 39constexpr Result ERR_UNSUPPORTED{ErrorModule::VI, 6};
40constexpr ResultCode ERR_NOT_FOUND{ErrorModule::VI, 7}; 40constexpr Result ERR_NOT_FOUND{ErrorModule::VI, 7};
41 41
42struct DisplayInfo { 42struct DisplayInfo {
43 /// The name of this particular display. 43 /// The name of this particular display.