diff options
Diffstat (limited to 'src/core/hle/kernel')
50 files changed, 656 insertions, 689 deletions
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 | ||
| 191 | ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const KHandleTable& handle_table, | 191 | Result 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 | ||
| 205 | ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(KThread& requesting_thread) { | 205 | Result 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 | ||
| 21 | union ResultCode; | 21 | union Result; |
| 22 | 22 | ||
| 23 | namespace Core::Memory { | 23 | namespace Core::Memory { |
| 24 | class Memory; | 24 | class 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 | ||
| 111 | ResultCode KAddressArbiter::Signal(VAddr addr, s32 count) { | 110 | Result 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 | ||
| 134 | ResultCode KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 count) { | 133 | Result 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 | ||
| 167 | ResultCode KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 value, s32 count) { | 166 | Result 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 | ||
| 235 | ResultCode KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout) { | 234 | Result 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 | ||
| 288 | ResultCode KAddressArbiter::WaitIfEqual(VAddr addr, s32 value, s64 timeout) { | 287 | Result 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 | ||
| 11 | union ResultCode; | 11 | union Result; |
| 12 | 12 | ||
| 13 | namespace Core { | 13 | namespace Core { |
| 14 | class System; | 14 | class 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 | ||
| 56 | private: | 55 | private: |
| 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 | ||
| 62 | ResultCode KClientPort::CreateSession(KClientSession** out, | 62 | Result 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 | ||
| 59 | private: | 59 | private: |
| 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 | ||
| 22 | void KClientSession::OnServerClosed() {} | 22 | void KClientSession::OnServerClosed() {} |
| 23 | 23 | ||
| 24 | ResultCode KClientSession::SendSyncRequest(KThread* thread, Core::Memory::Memory& memory, | 24 | Result 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 | ||
| 12 | union ResultCode; | 12 | union Result; |
| 13 | 13 | ||
| 14 | namespace Core::Memory { | 14 | namespace Core::Memory { |
| 15 | class Memory; | 15 | class 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..0579b8b19 100644 --- a/src/core/hle/kernel/k_code_memory.cpp +++ b/src/core/hle/kernel/k_code_memory.cpp | |||
| @@ -19,7 +19,7 @@ namespace Kernel { | |||
| 19 | KCodeMemory::KCodeMemory(KernelCore& kernel_) | 19 | KCodeMemory::KCodeMemory(KernelCore& kernel_) |
| 20 | : KAutoObjectWithSlabHeapAndContainer{kernel_}, m_lock(kernel_) {} | 20 | : KAutoObjectWithSlabHeapAndContainer{kernel_}, m_lock(kernel_) {} |
| 21 | 21 | ||
| 22 | ResultCode KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr, size_t size) { | 22 | Result 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 | ||
| 65 | ResultCode KCodeMemory::Map(VAddr address, size_t size) { | 65 | Result 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 | ||
| 85 | ResultCode KCodeMemory::Unmap(VAddr address, size_t size) { | 85 | Result 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 | ||
| 102 | ResultCode KCodeMemory::MapToOwner(VAddr address, size_t size, Svc::MemoryPermission perm) { | 102 | Result 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 | ||
| 136 | ResultCode KCodeMemory::UnmapFromOwner(VAddr address, size_t size) { | 136 | Result 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..715c645bd 100644 --- a/src/core/hle/kernel/k_code_memory.h +++ b/src/core/hle/kernel/k_code_memory.h | |||
| @@ -29,13 +29,13 @@ class KCodeMemory final | |||
| 29 | public: | 29 | public: |
| 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; |
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 | ||
| 106 | KConditionVariable::~KConditionVariable() = default; | 104 | KConditionVariable::~KConditionVariable() = default; |
| 107 | 105 | ||
| 108 | ResultCode KConditionVariable::SignalToAddress(VAddr addr) { | 106 | Result 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 | ||
| 149 | ResultCode KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 value) { | 147 | Result 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 | ||
| 264 | ResultCode KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) { | 262 | Result 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 | ||
| 35 | private: | 35 | private: |
| 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 { | |||
| 8 | KHandleTable::KHandleTable(KernelCore& kernel_) : kernel{kernel_} {} | 8 | KHandleTable::KHandleTable(KernelCore& kernel_) : kernel{kernel_} {} |
| 9 | KHandleTable::~KHandleTable() = default; | 9 | KHandleTable::~KHandleTable() = default; |
| 10 | 10 | ||
| 11 | ResultCode KHandleTable::Finalize() { | 11 | Result 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 | ||
| 65 | ResultCode KHandleTable::Add(Handle* out_handle, KAutoObject* obj) { | 65 | Result 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 | ||
| 88 | ResultCode KHandleTable::Reserve(Handle* out_handle) { | 88 | Result 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 { | |||
| 15 | public: | 15 | public: |
| 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..0cdb4a050 100644 --- a/src/core/hle/kernel/k_memory_manager.cpp +++ b/src/core/hle/kernel/k_memory_manager.cpp | |||
| @@ -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 | ||
| 211 | ResultCode KMemoryManager::AllocatePageGroupImpl(KPageLinkedList* out, size_t num_pages, Pool pool, | 211 | Result KMemoryManager::AllocatePageGroupImpl(KPageLinkedList* 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 | ||
| 260 | ResultCode KMemoryManager::AllocateAndOpen(KPageLinkedList* out, size_t num_pages, u32 option) { | 260 | Result KMemoryManager::AllocateAndOpen(KPageLinkedList* 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 | ||
| 296 | ResultCode KMemoryManager::AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, | 296 | Result KMemoryManager::AllocateAndOpenForProcess(KPageLinkedList* 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 | ||
diff --git a/src/core/hle/kernel/k_memory_manager.h b/src/core/hle/kernel/k_memory_manager.h index c7923cb82..1ebda7a4b 100644 --- a/src/core/hle/kernel/k_memory_manager.h +++ b/src/core/hle/kernel/k_memory_manager.h | |||
| @@ -65,9 +65,9 @@ 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(KPageLinkedList* out, size_t num_pages, u32 option); |
| 69 | ResultCode AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, u32 option, | 69 | Result AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, u32 option, |
| 70 | u64 process_id, u8 fill_pattern); | 70 | u64 process_id, u8 fill_pattern); |
| 71 | 71 | ||
| 72 | static constexpr size_t MaxManagerCount = 10; | 72 | static constexpr size_t MaxManagerCount = 10; |
| 73 | 73 | ||
| @@ -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(KPageLinkedList* out, size_t num_pages, Pool pool, Direction dir, |
| 266 | Direction dir, bool random); | 266 | bool random); |
| 267 | 267 | ||
| 268 | private: | 268 | private: |
| 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_linked_list.h index 1f79c8330..fc2ef9698 100644 --- a/src/core/hle/kernel/k_page_linked_list.h +++ b/src/core/hle/kernel/k_page_linked_list.h | |||
| @@ -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..909162716 100644 --- a/src/core/hle/kernel/k_page_table.cpp +++ b/src/core/hle/kernel/k_page_table.cpp | |||
| @@ -47,9 +47,9 @@ KPageTable::KPageTable(Core::System& system_) | |||
| 47 | 47 | ||
| 48 | KPageTable::~KPageTable() = default; | 48 | KPageTable::~KPageTable() = default; |
| 49 | 49 | ||
| 50 | ResultCode KPageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, | 50 | Result 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 | ||
| 260 | ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryState state, | 260 | Result 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. |
| @@ -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 | ||
| 286 | ResultCode KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size) { | 286 | Result 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); |
| @@ -344,8 +344,8 @@ ResultCode KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std:: | |||
| 344 | return ResultSuccess; | 344 | return ResultSuccess; |
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | ResultCode KPageTable::UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size, | 347 | Result 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 | ||
| 492 | ResultCode KPageTable::MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pages) { | 492 | Result KPageTable::MakePageGroup(KPageLinkedList& 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; |
| @@ -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 | ||
| 633 | ResultCode KPageTable::UnmapProcessMemory(VAddr dst_addr, std::size_t size, | 633 | Result 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 | ||
| 663 | ResultCode KPageTable::MapPhysicalMemory(VAddr address, std::size_t size) { | 663 | Result 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 | ||
| @@ -903,7 +903,7 @@ ResultCode KPageTable::MapPhysicalMemory(VAddr address, std::size_t size) { | |||
| 903 | } | 903 | } |
| 904 | } | 904 | } |
| 905 | 905 | ||
| 906 | ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) { | 906 | Result 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 | ||
| @@ -1134,7 +1134,7 @@ ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) { | |||
| 1134 | return ResultSuccess; | 1134 | return ResultSuccess; |
| 1135 | } | 1135 | } |
| 1136 | 1136 | ||
| 1137 | ResultCode KPageTable::MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) { | 1137 | Result 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{}; |
| @@ -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 | ||
| 1176 | ResultCode KPageTable::UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) { | 1176 | Result 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{}; |
| @@ -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 | ||
| 1218 | ResultCode KPageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_list, | 1218 | Result KPageTable::MapPages(VAddr addr, const KPageLinkedList& 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 | ||
| 1242 | ResultCode KPageTable::MapPages(VAddr address, KPageLinkedList& page_linked_list, | 1242 | Result KPageTable::MapPages(VAddr address, KPageLinkedList& 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 | ||
| 1266 | ResultCode KPageTable::MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, | 1266 | Result 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 | ||
| 1306 | ResultCode KPageTable::UnmapPages(VAddr addr, const KPageLinkedList& page_linked_list) { | 1306 | Result KPageTable::UnmapPages(VAddr addr, const KPageLinkedList& 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 | ||
| 1324 | ResultCode KPageTable::UnmapPages(VAddr addr, KPageLinkedList& page_linked_list, | 1324 | Result KPageTable::UnmapPages(VAddr addr, KPageLinkedList& 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 | ||
| 1348 | ResultCode KPageTable::UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state) { | 1347 | Result 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 | ||
| 1372 | ResultCode KPageTable::MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address, size_t num_pages, | 1371 | Result KPageTable::MakeAndOpenPageGroup(KPageLinkedList* 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 | ||
| 1397 | ResultCode KPageTable::SetProcessMemoryPermission(VAddr addr, std::size_t size, | 1396 | Result 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 | ||
| 1470 | ResultCode KPageTable::ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm) { | 1469 | Result 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 | ||
| 1488 | ResultCode KPageTable::ResetTransferMemory(VAddr addr, std::size_t size) { | 1487 | Result 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 | ||
| 1503 | ResultCode KPageTable::SetMemoryPermission(VAddr addr, std::size_t size, | 1502 | Result 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 | ||
| 1531 | ResultCode KPageTable::SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask, u32 attr) { | 1530 | Result 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 | ||
| 1566 | ResultCode KPageTable::SetMaxHeapSize(std::size_t size) { | 1565 | Result 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 | ||
| 1578 | ResultCode KPageTable::SetHeapSize(VAddr* out, std::size_t size) { | 1577 | Result 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 | ||
| @@ -1729,11 +1728,11 @@ ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages, | |||
| 1729 | return addr; | 1728 | return addr; |
| 1730 | } | 1729 | } |
| 1731 | 1730 | ||
| 1732 | ResultCode KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) { | 1731 | Result 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 | ||
| 1755 | ResultCode KPageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size) { | 1754 | Result 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 | ||
| 1778 | ResultCode KPageTable::LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::size_t size) { | 1777 | Result KPageTable::LockForCodeMemory(KPageLinkedList* 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 | ||
| 1788 | ResultCode KPageTable::UnlockForCodeMemory(VAddr addr, std::size_t size, | 1787 | Result KPageTable::UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageLinkedList& 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 | ||
| 1796 | ResultCode KPageTable::InitializeMemoryLayout(VAddr start, VAddr end) { | 1794 | Result 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; |
| @@ -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 | ||
| 1840 | ResultCode KPageTable::Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& page_group, | 1838 | Result KPageTable::Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& 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 | ||
| 1865 | ResultCode KPageTable::Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm, | 1863 | Result 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 | ||
| 2008 | ResultCode KPageTable::CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask, | 2006 | Result 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 | ||
| 2020 | ResultCode KPageTable::CheckMemoryStateContiguous(std::size_t* out_blocks_needed, VAddr addr, | 2018 | Result 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 | ||
| 2063 | ResultCode KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm, | 2060 | Result 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 | ||
| 2125 | ResultCode KPageTable::LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_paddr, VAddr addr, | 2122 | Result KPageTable::LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_paddr, VAddr addr, |
| 2126 | size_t size, KMemoryState state_mask, KMemoryState state, | 2123 | size_t size, 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 | ||
| 2183 | ResultCode KPageTable::UnlockMemory(VAddr addr, size_t size, KMemoryState state_mask, | 2180 | Result 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 KPageLinkedList* 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..64e770f8f 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, KPageLinkedList& 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, KPageLinkedList& 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(KPageLinkedList* 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 KPageLinkedList& pg); |
| 77 | ResultCode MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address, size_t num_pages, | 75 | Result MakeAndOpenPageGroup(KPageLinkedList* 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,82 +100,77 @@ 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 KPageLinkedList& 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 KPageLinkedList& 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, KPageLinkedList& 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 KPageLinkedList& 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(KPageLinkedList* 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 KPageLinkedList* pg); |
| 179 | 172 | ||
| 180 | ResultCode MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pages); | 173 | Result MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pages); |
| 181 | bool IsValidPageGroup(const KPageLinkedList& pg, VAddr addr, size_t num_pages); | 174 | bool IsValidPageGroup(const KPageLinkedList& pg, VAddr addr, size_t num_pages); |
| 182 | 175 | ||
| 183 | bool IsLockedByCurrentThread() const { | 176 | bool IsLockedByCurrentThread() const { |
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 | ||
| 53 | ResultCode KPort::EnqueueSession(KServerSession* session) { | 53 | Result 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 | ||
| 70 | ResultCode KProcess::Initialize(KProcess* process, Core::System& system, std::string process_name, | 70 | Result 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 | ||
| 222 | ResultCode KProcess::AddSharedMemory(KSharedMemory* shmem, [[maybe_unused]] VAddr address, | 222 | Result 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 | ||
| 287 | ResultCode KProcess::Reset() { | 287 | Result 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 | ||
| 301 | ResultCode KProcess::SetActivity(ProcessActivity activity) { | 301 | Result 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 | ||
| 345 | ResultCode KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, | 345 | Result 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 | ||
| 485 | ResultCode KProcess::CreateThreadLocalRegion(VAddr* out) { | 484 | Result 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 | ||
| 536 | ResultCode KProcess::DeleteThreadLocalRegion(VAddr addr) { | 535 | Result 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 | ||
| 667 | ResultCode KProcess::AllocateMainThreadStack(std::size_t stack_size) { | 666 | Result 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 | ||
| 30 | ResultCode KReadableEvent::Signal() { | 30 | Result 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 | ||
| 41 | ResultCode KReadableEvent::Clear() { | 41 | Result KReadableEvent::Clear() { |
| 42 | Reset(); | 42 | Reset(); |
| 43 | 43 | ||
| 44 | return ResultSuccess; | 44 | return ResultSuccess; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | ResultCode KReadableEvent::Reset() { | 47 | Result 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 | ||
| 40 | private: | 40 | private: |
| 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 | ||
| 76 | ResultCode KResourceLimit::SetLimitValue(LimitableResource which, s64 value) { | 76 | Result 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 | ||
| 11 | union ResultCode; | 11 | union Result; |
| 12 | 12 | ||
| 13 | namespace Core::Timing { | 13 | namespace Core::Timing { |
| 14 | class CoreTiming; | 14 | class 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 | ||
| 82 | ResultCode KServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& context) { | 82 | Result 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 | ||
| 126 | ResultCode KServerSession::QueueSyncRequest(KThread* thread, Core::Memory::Memory& memory) { | 126 | Result 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 | ||
| 146 | ResultCode KServerSession::CompleteSyncRequest(HLERequestContext& context) { | 146 | Result 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 | ||
| 176 | ResultCode KServerSession::HandleSyncRequest(KThread* thread, Core::Memory::Memory& memory, | 176 | Result 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 | ||
| 104 | private: | 104 | private: |
| 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..a1cd83873 100644 --- a/src/core/hle/kernel/k_shared_memory.cpp +++ b/src/core/hle/kernel/k_shared_memory.cpp | |||
| @@ -18,12 +18,11 @@ KSharedMemory::~KSharedMemory() { | |||
| 18 | kernel.GetSystemResourceLimit()->Release(LimitableResource::PhysicalMemory, size); | 18 | kernel.GetSystemResourceLimit()->Release(LimitableResource::PhysicalMemory, size); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | ResultCode KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_, | 21 | Result KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_, |
| 22 | KPageLinkedList&& page_list_, | 22 | KPageLinkedList&& page_list_, |
| 23 | Svc::MemoryPermission owner_permission_, | 23 | Svc::MemoryPermission owner_permission_, |
| 24 | Svc::MemoryPermission user_permission_, | 24 | Svc::MemoryPermission user_permission_, PAddr physical_address_, |
| 25 | PAddr physical_address_, std::size_t size_, | 25 | std::size_t size_, std::string name_) { |
| 26 | std::string name_) { | ||
| 27 | // Set members. | 26 | // Set members. |
| 28 | owner_process = owner_process_; | 27 | owner_process = owner_process_; |
| 29 | device_memory = &device_memory_; | 28 | device_memory = &device_memory_; |
| @@ -67,8 +66,8 @@ void KSharedMemory::Finalize() { | |||
| 67 | KAutoObjectWithSlabHeapAndContainer<KSharedMemory, KAutoObjectWithList>::Finalize(); | 66 | KAutoObjectWithSlabHeapAndContainer<KSharedMemory, KAutoObjectWithList>::Finalize(); |
| 68 | } | 67 | } |
| 69 | 68 | ||
| 70 | ResultCode KSharedMemory::Map(KProcess& target_process, VAddr address, std::size_t map_size, | 69 | Result KSharedMemory::Map(KProcess& target_process, VAddr address, std::size_t map_size, |
| 71 | Svc::MemoryPermission permissions) { | 70 | Svc::MemoryPermission permissions) { |
| 72 | const u64 page_count{(map_size + PageSize - 1) / PageSize}; | 71 | const u64 page_count{(map_size + PageSize - 1) / PageSize}; |
| 73 | 72 | ||
| 74 | if (page_list.GetNumPages() != page_count) { | 73 | if (page_list.GetNumPages() != page_count) { |
| @@ -86,7 +85,7 @@ ResultCode KSharedMemory::Map(KProcess& target_process, VAddr address, std::size | |||
| 86 | ConvertToKMemoryPermission(permissions)); | 85 | ConvertToKMemoryPermission(permissions)); |
| 87 | } | 86 | } |
| 88 | 87 | ||
| 89 | ResultCode KSharedMemory::Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size) { | 88 | Result KSharedMemory::Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size) { |
| 90 | const u64 page_count{(unmap_size + PageSize - 1) / PageSize}; | 89 | const u64 page_count{(unmap_size + PageSize - 1) / PageSize}; |
| 91 | 90 | ||
| 92 | if (page_list.GetNumPages() != page_count) { | 91 | 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..f84efa236 100644 --- a/src/core/hle/kernel/k_shared_memory.h +++ b/src/core/hle/kernel/k_shared_memory.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 | KPageLinkedList&& 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 |
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 | ||
| 75 | ResultCode KSynchronizationObject::Wait(KernelCore& kernel_ctx, s32* out_index, | 74 | Result 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 | ||
| 149 | KSynchronizationObject::~KSynchronizationObject() = default; | 148 | KSynchronizationObject::~KSynchronizationObject() = default; |
| 150 | 149 | ||
| 151 | void KSynchronizationObject::NotifyAvailable(ResultCode result) { | 150 | void 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_} {} |
| 100 | KThread::~KThread() = default; | 99 | KThread::~KThread() = default; |
| 101 | 100 | ||
| 102 | ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, s32 prio, | 101 | Result 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 | ||
| 248 | ResultCode KThread::InitializeThread(KThread* thread, KThreadFunction func, uintptr_t arg, | 247 | Result 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 | ||
| 263 | ResultCode KThread::InitializeDummyThread(KThread* thread) { | 262 | Result KThread::InitializeDummyThread(KThread* thread) { |
| 264 | return thread->Initialize({}, {}, {}, DummyThreadPriority, 3, {}, ThreadType::Dummy); | 263 | return thread->Initialize({}, {}, {}, DummyThreadPriority, 3, {}, ThreadType::Dummy); |
| 265 | } | 264 | } |
| 266 | 265 | ||
| 267 | ResultCode KThread::InitializeIdleThread(Core::System& system, KThread* thread, s32 virt_core) { | 266 | Result 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 | ||
| 273 | ResultCode KThread::InitializeHighPriorityThread(Core::System& system, KThread* thread, | 272 | Result 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 | ||
| 281 | ResultCode KThread::InitializeUserThread(Core::System& system, KThread* thread, | 279 | Result 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 | ||
| 526 | ResultCode KThread::GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask) { | 524 | Result 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 | ||
| 536 | ResultCode KThread::GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask) { | 534 | Result 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 | ||
| 552 | ResultCode KThread::SetCoreMask(s32 core_id_, u64 v_affinity_mask) { | 550 | Result 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 | ||
| 764 | ResultCode KThread::SetActivity(Svc::ThreadActivity activity) { | 762 | Result 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 | ||
| 837 | ResultCode KThread::GetThreadContext3(std::vector<u8>& out) { | 835 | Result 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 | ||
| 1002 | ResultCode KThread::Run() { | 1000 | Result 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 | ||
| 1063 | ResultCode KThread::Sleep(s64 timeout) { | 1061 | Result 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 | ||
| 1119 | void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, ResultCode wait_result_) { | 1117 | void 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 | ||
| 1129 | void KThread::EndWait(ResultCode wait_result_) { | 1127 | void 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 | ||
| 1148 | void KThread::CancelWait(ResultCode wait_result_, bool cancel_timer_task) { | 1146 | void 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 | ||
| 429 | public: | 428 | public: |
| 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 | ||
| 14 | namespace Kernel { | 14 | namespace Kernel { |
| 15 | 15 | ||
| 16 | ResultCode KThreadLocalPage::Initialize(KernelCore& kernel, KProcess* process) { | 16 | Result 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 | ||
| 38 | ResultCode KThreadLocalPage::Finalize() { | 38 | Result 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 | ||
| 10 | void KThreadQueue::NotifyAvailable([[maybe_unused]] KThread* waiting_thread, | 10 | void 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 | ||
| 14 | void KThreadQueue::EndWait(KThread* waiting_thread, ResultCode wait_result) { | 14 | void 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 | ||
| 28 | void KThreadQueue::CancelWait(KThread* waiting_thread, ResultCode wait_result, | 28 | void 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 | ||
| 45 | void KThreadQueueWithoutEndWait::EndWait([[maybe_unused]] KThread* waiting_thread, | 44 | void 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 | ||
| 22 | private: | 21 | private: |
| 23 | KernelCore& kernel; | 22 | KernelCore& kernel; |
| @@ -28,7 +27,7 @@ class KThreadQueueWithoutEndWait : public KThreadQueue { | |||
| 28 | public: | 27 | public: |
| 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 | ||
| 14 | KTransferMemory::~KTransferMemory() = default; | 14 | KTransferMemory::~KTransferMemory() = default; |
| 15 | 15 | ||
| 16 | ResultCode KTransferMemory::Initialize(VAddr address_, std::size_t size_, | 16 | Result 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 | ||
| 10 | union ResultCode; | 10 | union Result; |
| 11 | 11 | ||
| 12 | namespace Core::Memory { | 12 | namespace Core::Memory { |
| 13 | class Memory; | 13 | class 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 | ||
| 21 | ResultCode KWritableEvent::Signal() { | 21 | Result KWritableEvent::Signal() { |
| 22 | return parent->GetReadableEvent().Signal(); | 22 | return parent->GetReadableEvent().Signal(); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | ResultCode KWritableEvent::Clear() { | 25 | Result 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 | ||
| 71 | ResultCode ProcessCapabilities::InitializeForKernelProcess(const u32* capabilities, | 71 | Result 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 | ||
| 84 | ResultCode ProcessCapabilities::InitializeForUserProcess(const u32* capabilities, | 84 | Result 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 | ||
| 110 | ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities, | 110 | Result 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 | ||
| 158 | ResultCode ProcessCapabilities::ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, | 157 | Result 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 | ||
| 227 | ResultCode ProcessCapabilities::HandlePriorityCoreNumFlags(u32 flags) { | 226 | Result 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 | ||
| 269 | ResultCode ProcessCapabilities::HandleSyscallFlags(u32& set_svc_bits, u32 flags) { | 268 | Result 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 | ||
| 293 | ResultCode ProcessCapabilities::HandleMapPhysicalFlags(u32 flags, u32 size_flags, | 292 | Result 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 | ||
| 299 | ResultCode ProcessCapabilities::HandleMapIOFlags(u32 flags, KPageTable& page_table) { | 298 | Result 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 | ||
| 304 | ResultCode ProcessCapabilities::HandleMapRegionFlags(u32 flags, KPageTable& page_table) { | 303 | Result 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 | ||
| 309 | ResultCode ProcessCapabilities::HandleInterruptFlags(u32 flags) { | 308 | Result 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 | ||
| 336 | ResultCode ProcessCapabilities::HandleProgramTypeFlags(u32 flags) { | 335 | Result 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 | ||
| 347 | ResultCode ProcessCapabilities::HandleKernelVersionFlags(u32 flags) { | 346 | Result 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 | ||
| 367 | ResultCode ProcessCapabilities::HandleHandleTableFlags(u32 flags) { | 366 | Result 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 | ||
| 378 | ResultCode ProcessCapabilities::HandleDebugFlags(u32 flags) { | 377 | Result 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 | ||
| 10 | union ResultCode; | 10 | union Result; |
| 11 | 11 | ||
| 12 | namespace Kernel { | 12 | namespace 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 2b34fc19d..de8a0864c 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. |
| 61 | ResultCode MapUnmapMemorySanityChecks(const KPageTable& manager, VAddr dst_addr, VAddr src_addr, | 61 | Result 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. |
| 138 | static ResultCode SetHeapSize(Core::System& system, VAddr* out_address, u64 size) { | 138 | static 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 | ||
| 151 | static ResultCode SetHeapSize32(Core::System& system, u32* heap_addr, u32 heap_size) { | 151 | static 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 | ||
| 169 | static ResultCode SetMemoryPermission(Core::System& system, VAddr address, u64 size, | 169 | static 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 | ||
| 191 | static ResultCode SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask, | 191 | static 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 | ||
| 216 | static ResultCode SetMemoryAttribute32(Core::System& system, u32 address, u32 size, u32 mask, | 216 | static 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. |
| 222 | static ResultCode MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { | 222 | static 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 | ||
| 236 | static ResultCode MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { | 236 | static 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 |
| 241 | static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { | 241 | static 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 | ||
| 255 | static ResultCode UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { | 255 | static 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 |
| 260 | static ResultCode ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_address) { | 260 | static 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 | ||
| 310 | static ResultCode ConnectToNamedPort32(Core::System& system, Handle* out_handle, | 310 | static 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. |
| 317 | static ResultCode SendSyncRequest(Core::System& system, Handle handle) { | 317 | static 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 | ||
| 342 | static ResultCode SendSyncRequest32(Core::System& system, Handle handle) { | 342 | static 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. |
| 347 | static ResultCode GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) { | 347 | static 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 | ||
| 358 | static ResultCode GetThreadId32(Core::System& system, u32* out_thread_id_low, | 358 | static 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. |
| 370 | static ResultCode GetProcessId(Core::System& system, u64* out_process_id, Handle handle) { | 370 | static 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 | ||
| 401 | static ResultCode GetProcessId32(Core::System& system, u32* out_process_id_low, | 401 | static 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 |
| 411 | static ResultCode WaitSynchronization(Core::System& system, s32* index, VAddr handles_address, | 411 | static 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 | ||
| 447 | static ResultCode WaitSynchronization32(Core::System& system, u32 timeout_low, u32 handles_address, | 447 | static 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 |
| 454 | static ResultCode CancelSynchronization(Core::System& system, Handle handle) { | 454 | static 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 | ||
| 467 | static ResultCode CancelSynchronization32(Core::System& system, Handle handle) { | 467 | static 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 |
| 472 | static ResultCode ArbitrateLock(Core::System& system, Handle thread_handle, VAddr address, | 472 | static 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 | ||
| 491 | static ResultCode ArbitrateLock32(Core::System& system, Handle thread_handle, u32 address, | 490 | static 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 |
| 497 | static ResultCode ArbitrateUnlock(Core::System& system, VAddr address) { | 495 | static 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 | ||
| 515 | static ResultCode ArbitrateUnlock32(Core::System& system, u32 address) { | 513 | static 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 |
| 658 | static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, | 656 | static 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 | ||
| @@ -919,12 +917,12 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle | |||
| 919 | } | 917 | } |
| 920 | } | 918 | } |
| 921 | 919 | ||
| 922 | static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low, | 920 | static Result GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low, |
| 923 | u32 info_id, u32 handle, u32 sub_id_high) { | 921 | u32 info_id, u32 handle, u32 sub_id_high) { |
| 924 | const u64 sub_id{u64{sub_id_low} | (u64{sub_id_high} << 32)}; | 922 | const u64 sub_id{u64{sub_id_low} | (u64{sub_id_high} << 32)}; |
| 925 | u64 res_value{}; | 923 | u64 res_value{}; |
| 926 | 924 | ||
| 927 | const ResultCode result{GetInfo(system, &res_value, info_id, handle, sub_id)}; | 925 | const Result result{GetInfo(system, &res_value, info_id, handle, sub_id)}; |
| 928 | *result_high = static_cast<u32>(res_value >> 32); | 926 | *result_high = static_cast<u32>(res_value >> 32); |
| 929 | *result_low = static_cast<u32>(res_value & std::numeric_limits<u32>::max()); | 927 | *result_low = static_cast<u32>(res_value & std::numeric_limits<u32>::max()); |
| 930 | 928 | ||
| @@ -932,7 +930,7 @@ static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_h | |||
| 932 | } | 930 | } |
| 933 | 931 | ||
| 934 | /// Maps memory at a desired address | 932 | /// Maps memory at a desired address |
| 935 | static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { | 933 | static Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { |
| 936 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); | 934 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); |
| 937 | 935 | ||
| 938 | if (!Common::Is4KBAligned(addr)) { | 936 | if (!Common::Is4KBAligned(addr)) { |
| @@ -980,12 +978,12 @@ static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) | |||
| 980 | return page_table.MapPhysicalMemory(addr, size); | 978 | return page_table.MapPhysicalMemory(addr, size); |
| 981 | } | 979 | } |
| 982 | 980 | ||
| 983 | static ResultCode MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { | 981 | static Result MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { |
| 984 | return MapPhysicalMemory(system, addr, size); | 982 | return MapPhysicalMemory(system, addr, size); |
| 985 | } | 983 | } |
| 986 | 984 | ||
| 987 | /// Unmaps memory previously mapped via MapPhysicalMemory | 985 | /// Unmaps memory previously mapped via MapPhysicalMemory |
| 988 | static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { | 986 | static Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { |
| 989 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); | 987 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); |
| 990 | 988 | ||
| 991 | if (!Common::Is4KBAligned(addr)) { | 989 | if (!Common::Is4KBAligned(addr)) { |
| @@ -1033,13 +1031,13 @@ static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size | |||
| 1033 | return page_table.UnmapPhysicalMemory(addr, size); | 1031 | return page_table.UnmapPhysicalMemory(addr, size); |
| 1034 | } | 1032 | } |
| 1035 | 1033 | ||
| 1036 | static ResultCode UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { | 1034 | static Result UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { |
| 1037 | return UnmapPhysicalMemory(system, addr, size); | 1035 | return UnmapPhysicalMemory(system, addr, size); |
| 1038 | } | 1036 | } |
| 1039 | 1037 | ||
| 1040 | /// Sets the thread activity | 1038 | /// Sets the thread activity |
| 1041 | static ResultCode SetThreadActivity(Core::System& system, Handle thread_handle, | 1039 | static Result SetThreadActivity(Core::System& system, Handle thread_handle, |
| 1042 | ThreadActivity thread_activity) { | 1040 | ThreadActivity thread_activity) { |
| 1043 | LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", thread_handle, | 1041 | LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", thread_handle, |
| 1044 | thread_activity); | 1042 | thread_activity); |
| 1045 | 1043 | ||
| @@ -1064,13 +1062,13 @@ static ResultCode SetThreadActivity(Core::System& system, Handle thread_handle, | |||
| 1064 | return ResultSuccess; | 1062 | return ResultSuccess; |
| 1065 | } | 1063 | } |
| 1066 | 1064 | ||
| 1067 | static ResultCode SetThreadActivity32(Core::System& system, Handle thread_handle, | 1065 | static Result SetThreadActivity32(Core::System& system, Handle thread_handle, |
| 1068 | Svc::ThreadActivity thread_activity) { | 1066 | Svc::ThreadActivity thread_activity) { |
| 1069 | return SetThreadActivity(system, thread_handle, thread_activity); | 1067 | return SetThreadActivity(system, thread_handle, thread_activity); |
| 1070 | } | 1068 | } |
| 1071 | 1069 | ||
| 1072 | /// Gets the thread context | 1070 | /// Gets the thread context |
| 1073 | static ResultCode GetThreadContext(Core::System& system, VAddr out_context, Handle thread_handle) { | 1071 | static Result GetThreadContext(Core::System& system, VAddr out_context, Handle thread_handle) { |
| 1074 | LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context, | 1072 | LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context, |
| 1075 | thread_handle); | 1073 | thread_handle); |
| 1076 | 1074 | ||
| @@ -1127,12 +1125,12 @@ static ResultCode GetThreadContext(Core::System& system, VAddr out_context, Hand | |||
| 1127 | return ResultSuccess; | 1125 | return ResultSuccess; |
| 1128 | } | 1126 | } |
| 1129 | 1127 | ||
| 1130 | static ResultCode GetThreadContext32(Core::System& system, u32 out_context, Handle thread_handle) { | 1128 | static Result GetThreadContext32(Core::System& system, u32 out_context, Handle thread_handle) { |
| 1131 | return GetThreadContext(system, out_context, thread_handle); | 1129 | return GetThreadContext(system, out_context, thread_handle); |
| 1132 | } | 1130 | } |
| 1133 | 1131 | ||
| 1134 | /// Gets the priority for the specified thread | 1132 | /// Gets the priority for the specified thread |
| 1135 | static ResultCode GetThreadPriority(Core::System& system, u32* out_priority, Handle handle) { | 1133 | static Result GetThreadPriority(Core::System& system, u32* out_priority, Handle handle) { |
| 1136 | LOG_TRACE(Kernel_SVC, "called"); | 1134 | LOG_TRACE(Kernel_SVC, "called"); |
| 1137 | 1135 | ||
| 1138 | // Get the thread from its handle. | 1136 | // Get the thread from its handle. |
| @@ -1145,12 +1143,12 @@ static ResultCode GetThreadPriority(Core::System& system, u32* out_priority, Han | |||
| 1145 | return ResultSuccess; | 1143 | return ResultSuccess; |
| 1146 | } | 1144 | } |
| 1147 | 1145 | ||
| 1148 | static ResultCode GetThreadPriority32(Core::System& system, u32* out_priority, Handle handle) { | 1146 | static Result GetThreadPriority32(Core::System& system, u32* out_priority, Handle handle) { |
| 1149 | return GetThreadPriority(system, out_priority, handle); | 1147 | return GetThreadPriority(system, out_priority, handle); |
| 1150 | } | 1148 | } |
| 1151 | 1149 | ||
| 1152 | /// Sets the priority for the specified thread | 1150 | /// Sets the priority for the specified thread |
| 1153 | static ResultCode SetThreadPriority(Core::System& system, Handle thread_handle, u32 priority) { | 1151 | static Result SetThreadPriority(Core::System& system, Handle thread_handle, u32 priority) { |
| 1154 | // Get the current process. | 1152 | // Get the current process. |
| 1155 | KProcess& process = *system.Kernel().CurrentProcess(); | 1153 | KProcess& process = *system.Kernel().CurrentProcess(); |
| 1156 | 1154 | ||
| @@ -1168,7 +1166,7 @@ static ResultCode SetThreadPriority(Core::System& system, Handle thread_handle, | |||
| 1168 | return ResultSuccess; | 1166 | return ResultSuccess; |
| 1169 | } | 1167 | } |
| 1170 | 1168 | ||
| 1171 | static ResultCode SetThreadPriority32(Core::System& system, Handle thread_handle, u32 priority) { | 1169 | static Result SetThreadPriority32(Core::System& system, Handle thread_handle, u32 priority) { |
| 1172 | return SetThreadPriority(system, thread_handle, priority); | 1170 | return SetThreadPriority(system, thread_handle, priority); |
| 1173 | } | 1171 | } |
| 1174 | 1172 | ||
| @@ -1228,8 +1226,8 @@ constexpr bool IsValidUnmapFromOwnerCodeMemoryPermission(Svc::MemoryPermission p | |||
| 1228 | 1226 | ||
| 1229 | } // Anonymous namespace | 1227 | } // Anonymous namespace |
| 1230 | 1228 | ||
| 1231 | static ResultCode MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, | 1229 | static Result MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, u64 size, |
| 1232 | u64 size, Svc::MemoryPermission map_perm) { | 1230 | Svc::MemoryPermission map_perm) { |
| 1233 | LOG_TRACE(Kernel_SVC, | 1231 | LOG_TRACE(Kernel_SVC, |
| 1234 | "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", | 1232 | "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", |
| 1235 | shmem_handle, address, size, map_perm); | 1233 | shmem_handle, address, size, map_perm); |
| @@ -1269,13 +1267,13 @@ static ResultCode MapSharedMemory(Core::System& system, Handle shmem_handle, VAd | |||
| 1269 | return ResultSuccess; | 1267 | return ResultSuccess; |
| 1270 | } | 1268 | } |
| 1271 | 1269 | ||
| 1272 | static ResultCode MapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, | 1270 | static Result MapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, u32 size, |
| 1273 | u32 size, Svc::MemoryPermission map_perm) { | 1271 | Svc::MemoryPermission map_perm) { |
| 1274 | return MapSharedMemory(system, shmem_handle, address, size, map_perm); | 1272 | return MapSharedMemory(system, shmem_handle, address, size, map_perm); |
| 1275 | } | 1273 | } |
| 1276 | 1274 | ||
| 1277 | static ResultCode UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, | 1275 | static Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, |
| 1278 | u64 size) { | 1276 | u64 size) { |
| 1279 | // Validate the address/size. | 1277 | // Validate the address/size. |
| 1280 | R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress); | 1278 | R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress); |
| 1281 | R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize); | 1279 | R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize); |
| @@ -1302,13 +1300,13 @@ static ResultCode UnmapSharedMemory(Core::System& system, Handle shmem_handle, V | |||
| 1302 | return ResultSuccess; | 1300 | return ResultSuccess; |
| 1303 | } | 1301 | } |
| 1304 | 1302 | ||
| 1305 | static ResultCode UnmapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, | 1303 | static Result UnmapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, |
| 1306 | u32 size) { | 1304 | u32 size) { |
| 1307 | return UnmapSharedMemory(system, shmem_handle, address, size); | 1305 | return UnmapSharedMemory(system, shmem_handle, address, size); |
| 1308 | } | 1306 | } |
| 1309 | 1307 | ||
| 1310 | static ResultCode SetProcessMemoryPermission(Core::System& system, Handle process_handle, | 1308 | static Result SetProcessMemoryPermission(Core::System& system, Handle process_handle, VAddr address, |
| 1311 | VAddr address, u64 size, Svc::MemoryPermission perm) { | 1309 | u64 size, Svc::MemoryPermission perm) { |
| 1312 | LOG_TRACE(Kernel_SVC, | 1310 | LOG_TRACE(Kernel_SVC, |
| 1313 | "called, process_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", | 1311 | "called, process_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", |
| 1314 | process_handle, address, size, perm); | 1312 | process_handle, address, size, perm); |
| @@ -1337,8 +1335,8 @@ static ResultCode SetProcessMemoryPermission(Core::System& system, Handle proces | |||
| 1337 | return page_table.SetProcessMemoryPermission(address, size, perm); | 1335 | return page_table.SetProcessMemoryPermission(address, size, perm); |
| 1338 | } | 1336 | } |
| 1339 | 1337 | ||
| 1340 | static ResultCode MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, | 1338 | static Result MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, |
| 1341 | VAddr src_address, u64 size) { | 1339 | VAddr src_address, u64 size) { |
| 1342 | LOG_TRACE(Kernel_SVC, | 1340 | LOG_TRACE(Kernel_SVC, |
| 1343 | "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}", | 1341 | "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}", |
| 1344 | dst_address, process_handle, src_address, size); | 1342 | dst_address, process_handle, src_address, size); |
| @@ -1380,8 +1378,8 @@ static ResultCode MapProcessMemory(Core::System& system, VAddr dst_address, Hand | |||
| 1380 | return ResultSuccess; | 1378 | return ResultSuccess; |
| 1381 | } | 1379 | } |
| 1382 | 1380 | ||
| 1383 | static ResultCode UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, | 1381 | static Result UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, |
| 1384 | VAddr src_address, u64 size) { | 1382 | VAddr src_address, u64 size) { |
| 1385 | LOG_TRACE(Kernel_SVC, | 1383 | LOG_TRACE(Kernel_SVC, |
| 1386 | "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}", | 1384 | "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}", |
| 1387 | dst_address, process_handle, src_address, size); | 1385 | dst_address, process_handle, src_address, size); |
| @@ -1415,7 +1413,7 @@ static ResultCode UnmapProcessMemory(Core::System& system, VAddr dst_address, Ha | |||
| 1415 | return ResultSuccess; | 1413 | return ResultSuccess; |
| 1416 | } | 1414 | } |
| 1417 | 1415 | ||
| 1418 | static ResultCode CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t size) { | 1416 | static Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t size) { |
| 1419 | LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, size=0x{:X}", address, size); | 1417 | LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, size=0x{:X}", address, size); |
| 1420 | 1418 | ||
| 1421 | // Get kernel instance. | 1419 | // Get kernel instance. |
| @@ -1450,12 +1448,12 @@ static ResultCode CreateCodeMemory(Core::System& system, Handle* out, VAddr addr | |||
| 1450 | return ResultSuccess; | 1448 | return ResultSuccess; |
| 1451 | } | 1449 | } |
| 1452 | 1450 | ||
| 1453 | static ResultCode CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size) { | 1451 | static Result CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size) { |
| 1454 | return CreateCodeMemory(system, out, address, size); | 1452 | return CreateCodeMemory(system, out, address, size); |
| 1455 | } | 1453 | } |
| 1456 | 1454 | ||
| 1457 | static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation, | 1455 | static Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation, |
| 1458 | VAddr address, size_t size, Svc::MemoryPermission perm) { | 1456 | VAddr address, size_t size, Svc::MemoryPermission perm) { |
| 1459 | 1457 | ||
| 1460 | LOG_TRACE(Kernel_SVC, | 1458 | LOG_TRACE(Kernel_SVC, |
| 1461 | "called, code_memory_handle=0x{:X}, operation=0x{:X}, address=0x{:X}, size=0x{:X}, " | 1459 | "called, code_memory_handle=0x{:X}, operation=0x{:X}, address=0x{:X}, size=0x{:X}, " |
| @@ -1533,15 +1531,13 @@ static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_han | |||
| 1533 | return ResultSuccess; | 1531 | return ResultSuccess; |
| 1534 | } | 1532 | } |
| 1535 | 1533 | ||
| 1536 | static ResultCode ControlCodeMemory32(Core::System& system, Handle code_memory_handle, | 1534 | static Result ControlCodeMemory32(Core::System& system, Handle code_memory_handle, u32 operation, |
| 1537 | u32 operation, u64 address, u64 size, | 1535 | u64 address, u64 size, Svc::MemoryPermission perm) { |
| 1538 | Svc::MemoryPermission perm) { | ||
| 1539 | return ControlCodeMemory(system, code_memory_handle, operation, address, size, perm); | 1536 | return ControlCodeMemory(system, code_memory_handle, operation, address, size, perm); |
| 1540 | } | 1537 | } |
| 1541 | 1538 | ||
| 1542 | static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address, | 1539 | static Result QueryProcessMemory(Core::System& system, VAddr memory_info_address, |
| 1543 | VAddr page_info_address, Handle process_handle, | 1540 | VAddr page_info_address, Handle process_handle, VAddr address) { |
| 1544 | VAddr address) { | ||
| 1545 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); | 1541 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); |
| 1546 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 1542 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 1547 | KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); | 1543 | KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); |
| @@ -1569,8 +1565,8 @@ static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_add | |||
| 1569 | return ResultSuccess; | 1565 | return ResultSuccess; |
| 1570 | } | 1566 | } |
| 1571 | 1567 | ||
| 1572 | static ResultCode QueryMemory(Core::System& system, VAddr memory_info_address, | 1568 | static Result QueryMemory(Core::System& system, VAddr memory_info_address, VAddr page_info_address, |
| 1573 | VAddr page_info_address, VAddr query_address) { | 1569 | VAddr query_address) { |
| 1574 | LOG_TRACE(Kernel_SVC, | 1570 | LOG_TRACE(Kernel_SVC, |
| 1575 | "called, memory_info_address=0x{:016X}, page_info_address=0x{:016X}, " | 1571 | "called, memory_info_address=0x{:016X}, page_info_address=0x{:016X}, " |
| 1576 | "query_address=0x{:016X}", | 1572 | "query_address=0x{:016X}", |
| @@ -1580,13 +1576,13 @@ static ResultCode QueryMemory(Core::System& system, VAddr memory_info_address, | |||
| 1580 | query_address); | 1576 | query_address); |
| 1581 | } | 1577 | } |
| 1582 | 1578 | ||
| 1583 | static ResultCode QueryMemory32(Core::System& system, u32 memory_info_address, | 1579 | static Result QueryMemory32(Core::System& system, u32 memory_info_address, u32 page_info_address, |
| 1584 | u32 page_info_address, u32 query_address) { | 1580 | u32 query_address) { |
| 1585 | return QueryMemory(system, memory_info_address, page_info_address, query_address); | 1581 | return QueryMemory(system, memory_info_address, page_info_address, query_address); |
| 1586 | } | 1582 | } |
| 1587 | 1583 | ||
| 1588 | static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, | 1584 | static Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, |
| 1589 | u64 src_address, u64 size) { | 1585 | u64 src_address, u64 size) { |
| 1590 | LOG_DEBUG(Kernel_SVC, | 1586 | LOG_DEBUG(Kernel_SVC, |
| 1591 | "called. process_handle=0x{:08X}, dst_address=0x{:016X}, " | 1587 | "called. process_handle=0x{:08X}, dst_address=0x{:016X}, " |
| 1592 | "src_address=0x{:016X}, size=0x{:016X}", | 1588 | "src_address=0x{:016X}, size=0x{:016X}", |
| @@ -1653,8 +1649,8 @@ static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_hand | |||
| 1653 | return page_table.MapCodeMemory(dst_address, src_address, size); | 1649 | return page_table.MapCodeMemory(dst_address, src_address, size); |
| 1654 | } | 1650 | } |
| 1655 | 1651 | ||
| 1656 | static ResultCode UnmapProcessCodeMemory(Core::System& system, Handle process_handle, | 1652 | static Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, |
| 1657 | u64 dst_address, u64 src_address, u64 size) { | 1653 | u64 src_address, u64 size) { |
| 1658 | LOG_DEBUG(Kernel_SVC, | 1654 | LOG_DEBUG(Kernel_SVC, |
| 1659 | "called. process_handle=0x{:08X}, dst_address=0x{:016X}, src_address=0x{:016X}, " | 1655 | "called. process_handle=0x{:08X}, dst_address=0x{:016X}, src_address=0x{:016X}, " |
| 1660 | "size=0x{:016X}", | 1656 | "size=0x{:016X}", |
| @@ -1746,8 +1742,8 @@ constexpr bool IsValidVirtualCoreId(int32_t core_id) { | |||
| 1746 | } // Anonymous namespace | 1742 | } // Anonymous namespace |
| 1747 | 1743 | ||
| 1748 | /// Creates a new thread | 1744 | /// Creates a new thread |
| 1749 | static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg, | 1745 | static Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg, |
| 1750 | VAddr stack_bottom, u32 priority, s32 core_id) { | 1746 | VAddr stack_bottom, u32 priority, s32 core_id) { |
| 1751 | LOG_DEBUG(Kernel_SVC, | 1747 | LOG_DEBUG(Kernel_SVC, |
| 1752 | "called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, " | 1748 | "called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, " |
| 1753 | "priority=0x{:08X}, core_id=0x{:08X}", | 1749 | "priority=0x{:08X}, core_id=0x{:08X}", |
| @@ -1818,13 +1814,13 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e | |||
| 1818 | return ResultSuccess; | 1814 | return ResultSuccess; |
| 1819 | } | 1815 | } |
| 1820 | 1816 | ||
| 1821 | static ResultCode CreateThread32(Core::System& system, Handle* out_handle, u32 priority, | 1817 | static Result CreateThread32(Core::System& system, Handle* out_handle, u32 priority, |
| 1822 | u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) { | 1818 | u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) { |
| 1823 | return CreateThread(system, out_handle, entry_point, arg, stack_top, priority, processor_id); | 1819 | return CreateThread(system, out_handle, entry_point, arg, stack_top, priority, processor_id); |
| 1824 | } | 1820 | } |
| 1825 | 1821 | ||
| 1826 | /// Starts the thread for the provided handle | 1822 | /// Starts the thread for the provided handle |
| 1827 | static ResultCode StartThread(Core::System& system, Handle thread_handle) { | 1823 | static Result StartThread(Core::System& system, Handle thread_handle) { |
| 1828 | LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); | 1824 | LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); |
| 1829 | 1825 | ||
| 1830 | // Get the thread from its handle. | 1826 | // Get the thread from its handle. |
| @@ -1842,7 +1838,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) { | |||
| 1842 | return ResultSuccess; | 1838 | return ResultSuccess; |
| 1843 | } | 1839 | } |
| 1844 | 1840 | ||
| 1845 | static ResultCode StartThread32(Core::System& system, Handle thread_handle) { | 1841 | static Result StartThread32(Core::System& system, Handle thread_handle) { |
| 1846 | return StartThread(system, thread_handle); | 1842 | return StartThread(system, thread_handle); |
| 1847 | } | 1843 | } |
| 1848 | 1844 | ||
| @@ -1893,8 +1889,8 @@ static void SleepThread32(Core::System& system, u32 nanoseconds_low, u32 nanosec | |||
| 1893 | } | 1889 | } |
| 1894 | 1890 | ||
| 1895 | /// Wait process wide key atomic | 1891 | /// Wait process wide key atomic |
| 1896 | static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_key, | 1892 | static Result WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_key, u32 tag, |
| 1897 | u32 tag, s64 timeout_ns) { | 1893 | s64 timeout_ns) { |
| 1898 | LOG_TRACE(Kernel_SVC, "called address={:X}, cv_key={:X}, tag=0x{:08X}, timeout_ns={}", address, | 1894 | LOG_TRACE(Kernel_SVC, "called address={:X}, cv_key={:X}, tag=0x{:08X}, timeout_ns={}", address, |
| 1899 | cv_key, tag, timeout_ns); | 1895 | cv_key, tag, timeout_ns); |
| 1900 | 1896 | ||
| @@ -1929,8 +1925,8 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr address, | |||
| 1929 | address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout); | 1925 | address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout); |
| 1930 | } | 1926 | } |
| 1931 | 1927 | ||
| 1932 | static ResultCode WaitProcessWideKeyAtomic32(Core::System& system, u32 address, u32 cv_key, u32 tag, | 1928 | static Result WaitProcessWideKeyAtomic32(Core::System& system, u32 address, u32 cv_key, u32 tag, |
| 1933 | u32 timeout_ns_low, u32 timeout_ns_high) { | 1929 | u32 timeout_ns_low, u32 timeout_ns_high) { |
| 1934 | const auto timeout_ns = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); | 1930 | const auto timeout_ns = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); |
| 1935 | return WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns); | 1931 | return WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns); |
| 1936 | } | 1932 | } |
| @@ -1975,8 +1971,8 @@ constexpr bool IsValidArbitrationType(Svc::ArbitrationType type) { | |||
| 1975 | } // namespace | 1971 | } // namespace |
| 1976 | 1972 | ||
| 1977 | // Wait for an address (via Address Arbiter) | 1973 | // Wait for an address (via Address Arbiter) |
| 1978 | static ResultCode WaitForAddress(Core::System& system, VAddr address, Svc::ArbitrationType arb_type, | 1974 | static Result WaitForAddress(Core::System& system, VAddr address, Svc::ArbitrationType arb_type, |
| 1979 | s32 value, s64 timeout_ns) { | 1975 | s32 value, s64 timeout_ns) { |
| 1980 | LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, arb_type=0x{:X}, value=0x{:X}, timeout_ns={}", | 1976 | LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, arb_type=0x{:X}, value=0x{:X}, timeout_ns={}", |
| 1981 | address, arb_type, value, timeout_ns); | 1977 | address, arb_type, value, timeout_ns); |
| 1982 | 1978 | ||
| @@ -2013,15 +2009,15 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, Svc::Arbit | |||
| 2013 | return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout); | 2009 | return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout); |
| 2014 | } | 2010 | } |
| 2015 | 2011 | ||
| 2016 | static ResultCode WaitForAddress32(Core::System& system, u32 address, Svc::ArbitrationType arb_type, | 2012 | static Result WaitForAddress32(Core::System& system, u32 address, Svc::ArbitrationType arb_type, |
| 2017 | s32 value, u32 timeout_ns_low, u32 timeout_ns_high) { | 2013 | s32 value, u32 timeout_ns_low, u32 timeout_ns_high) { |
| 2018 | const auto timeout = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); | 2014 | const auto timeout = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); |
| 2019 | return WaitForAddress(system, address, arb_type, value, timeout); | 2015 | return WaitForAddress(system, address, arb_type, value, timeout); |
| 2020 | } | 2016 | } |
| 2021 | 2017 | ||
| 2022 | // Signals to an address (via Address Arbiter) | 2018 | // Signals to an address (via Address Arbiter) |
| 2023 | static ResultCode SignalToAddress(Core::System& system, VAddr address, Svc::SignalType signal_type, | 2019 | static Result SignalToAddress(Core::System& system, VAddr address, Svc::SignalType signal_type, |
| 2024 | s32 value, s32 count) { | 2020 | s32 value, s32 count) { |
| 2025 | LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, signal_type=0x{:X}, value=0x{:X}, count=0x{:X}", | 2021 | LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, signal_type=0x{:X}, value=0x{:X}, count=0x{:X}", |
| 2026 | address, signal_type, value, count); | 2022 | address, signal_type, value, count); |
| 2027 | 2023 | ||
| @@ -2062,8 +2058,8 @@ static void SynchronizePreemptionState(Core::System& system) { | |||
| 2062 | } | 2058 | } |
| 2063 | } | 2059 | } |
| 2064 | 2060 | ||
| 2065 | static ResultCode SignalToAddress32(Core::System& system, u32 address, Svc::SignalType signal_type, | 2061 | static Result SignalToAddress32(Core::System& system, u32 address, Svc::SignalType signal_type, |
| 2066 | s32 value, s32 count) { | 2062 | s32 value, s32 count) { |
| 2067 | return SignalToAddress(system, address, signal_type, value, count); | 2063 | return SignalToAddress(system, address, signal_type, value, count); |
| 2068 | } | 2064 | } |
| 2069 | 2065 | ||
| @@ -2101,7 +2097,7 @@ static void GetSystemTick32(Core::System& system, u32* time_low, u32* time_high) | |||
| 2101 | } | 2097 | } |
| 2102 | 2098 | ||
| 2103 | /// Close a handle | 2099 | /// Close a handle |
| 2104 | static ResultCode CloseHandle(Core::System& system, Handle handle) { | 2100 | static Result CloseHandle(Core::System& system, Handle handle) { |
| 2105 | LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle); | 2101 | LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle); |
| 2106 | 2102 | ||
| 2107 | // Remove the handle. | 2103 | // Remove the handle. |
| @@ -2111,12 +2107,12 @@ static ResultCode CloseHandle(Core::System& system, Handle handle) { | |||
| 2111 | return ResultSuccess; | 2107 | return ResultSuccess; |
| 2112 | } | 2108 | } |
| 2113 | 2109 | ||
| 2114 | static ResultCode CloseHandle32(Core::System& system, Handle handle) { | 2110 | static Result CloseHandle32(Core::System& system, Handle handle) { |
| 2115 | return CloseHandle(system, handle); | 2111 | return CloseHandle(system, handle); |
| 2116 | } | 2112 | } |
| 2117 | 2113 | ||
| 2118 | /// Clears the signaled state of an event or process. | 2114 | /// Clears the signaled state of an event or process. |
| 2119 | static ResultCode ResetSignal(Core::System& system, Handle handle) { | 2115 | static Result ResetSignal(Core::System& system, Handle handle) { |
| 2120 | LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); | 2116 | LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); |
| 2121 | 2117 | ||
| 2122 | // Get the current handle table. | 2118 | // Get the current handle table. |
| @@ -2143,7 +2139,7 @@ static ResultCode ResetSignal(Core::System& system, Handle handle) { | |||
| 2143 | return ResultInvalidHandle; | 2139 | return ResultInvalidHandle; |
| 2144 | } | 2140 | } |
| 2145 | 2141 | ||
| 2146 | static ResultCode ResetSignal32(Core::System& system, Handle handle) { | 2142 | static Result ResetSignal32(Core::System& system, Handle handle) { |
| 2147 | return ResetSignal(system, handle); | 2143 | return ResetSignal(system, handle); |
| 2148 | } | 2144 | } |
| 2149 | 2145 | ||
| @@ -2163,8 +2159,8 @@ constexpr bool IsValidTransferMemoryPermission(MemoryPermission perm) { | |||
| 2163 | } // Anonymous namespace | 2159 | } // Anonymous namespace |
| 2164 | 2160 | ||
| 2165 | /// Creates a TransferMemory object | 2161 | /// Creates a TransferMemory object |
| 2166 | static ResultCode CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u64 size, | 2162 | static Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u64 size, |
| 2167 | MemoryPermission map_perm) { | 2163 | MemoryPermission map_perm) { |
| 2168 | auto& kernel = system.Kernel(); | 2164 | auto& kernel = system.Kernel(); |
| 2169 | 2165 | ||
| 2170 | // Validate the size. | 2166 | // Validate the size. |
| @@ -2210,13 +2206,13 @@ static ResultCode CreateTransferMemory(Core::System& system, Handle* out, VAddr | |||
| 2210 | return ResultSuccess; | 2206 | return ResultSuccess; |
| 2211 | } | 2207 | } |
| 2212 | 2208 | ||
| 2213 | static ResultCode CreateTransferMemory32(Core::System& system, Handle* out, u32 address, u32 size, | 2209 | static Result CreateTransferMemory32(Core::System& system, Handle* out, u32 address, u32 size, |
| 2214 | MemoryPermission map_perm) { | 2210 | MemoryPermission map_perm) { |
| 2215 | return CreateTransferMemory(system, out, address, size, map_perm); | 2211 | return CreateTransferMemory(system, out, address, size, map_perm); |
| 2216 | } | 2212 | } |
| 2217 | 2213 | ||
| 2218 | static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_core_id, | 2214 | static Result GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_core_id, |
| 2219 | u64* out_affinity_mask) { | 2215 | u64* out_affinity_mask) { |
| 2220 | LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); | 2216 | LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); |
| 2221 | 2217 | ||
| 2222 | // Get the thread from its handle. | 2218 | // Get the thread from its handle. |
| @@ -2230,8 +2226,8 @@ static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle, | |||
| 2230 | return ResultSuccess; | 2226 | return ResultSuccess; |
| 2231 | } | 2227 | } |
| 2232 | 2228 | ||
| 2233 | static ResultCode GetThreadCoreMask32(Core::System& system, Handle thread_handle, s32* out_core_id, | 2229 | static Result GetThreadCoreMask32(Core::System& system, Handle thread_handle, s32* out_core_id, |
| 2234 | u32* out_affinity_mask_low, u32* out_affinity_mask_high) { | 2230 | u32* out_affinity_mask_low, u32* out_affinity_mask_high) { |
| 2235 | u64 out_affinity_mask{}; | 2231 | u64 out_affinity_mask{}; |
| 2236 | const auto result = GetThreadCoreMask(system, thread_handle, out_core_id, &out_affinity_mask); | 2232 | const auto result = GetThreadCoreMask(system, thread_handle, out_core_id, &out_affinity_mask); |
| 2237 | *out_affinity_mask_high = static_cast<u32>(out_affinity_mask >> 32); | 2233 | *out_affinity_mask_high = static_cast<u32>(out_affinity_mask >> 32); |
| @@ -2239,8 +2235,8 @@ static ResultCode GetThreadCoreMask32(Core::System& system, Handle thread_handle | |||
| 2239 | return result; | 2235 | return result; |
| 2240 | } | 2236 | } |
| 2241 | 2237 | ||
| 2242 | static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id, | 2238 | static Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id, |
| 2243 | u64 affinity_mask) { | 2239 | u64 affinity_mask) { |
| 2244 | // Determine the core id/affinity mask. | 2240 | // Determine the core id/affinity mask. |
| 2245 | if (core_id == IdealCoreUseProcessValue) { | 2241 | if (core_id == IdealCoreUseProcessValue) { |
| 2246 | core_id = system.Kernel().CurrentProcess()->GetIdealCoreId(); | 2242 | core_id = system.Kernel().CurrentProcess()->GetIdealCoreId(); |
| @@ -2271,13 +2267,13 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle, | |||
| 2271 | return ResultSuccess; | 2267 | return ResultSuccess; |
| 2272 | } | 2268 | } |
| 2273 | 2269 | ||
| 2274 | static ResultCode SetThreadCoreMask32(Core::System& system, Handle thread_handle, s32 core_id, | 2270 | static Result SetThreadCoreMask32(Core::System& system, Handle thread_handle, s32 core_id, |
| 2275 | u32 affinity_mask_low, u32 affinity_mask_high) { | 2271 | u32 affinity_mask_low, u32 affinity_mask_high) { |
| 2276 | const auto affinity_mask = u64{affinity_mask_low} | (u64{affinity_mask_high} << 32); | 2272 | const auto affinity_mask = u64{affinity_mask_low} | (u64{affinity_mask_high} << 32); |
| 2277 | return SetThreadCoreMask(system, thread_handle, core_id, affinity_mask); | 2273 | return SetThreadCoreMask(system, thread_handle, core_id, affinity_mask); |
| 2278 | } | 2274 | } |
| 2279 | 2275 | ||
| 2280 | static ResultCode SignalEvent(Core::System& system, Handle event_handle) { | 2276 | static Result SignalEvent(Core::System& system, Handle event_handle) { |
| 2281 | LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); | 2277 | LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); |
| 2282 | 2278 | ||
| 2283 | // Get the current handle table. | 2279 | // Get the current handle table. |
| @@ -2290,11 +2286,11 @@ static ResultCode SignalEvent(Core::System& system, Handle event_handle) { | |||
| 2290 | return writable_event->Signal(); | 2286 | return writable_event->Signal(); |
| 2291 | } | 2287 | } |
| 2292 | 2288 | ||
| 2293 | static ResultCode SignalEvent32(Core::System& system, Handle event_handle) { | 2289 | static Result SignalEvent32(Core::System& system, Handle event_handle) { |
| 2294 | return SignalEvent(system, event_handle); | 2290 | return SignalEvent(system, event_handle); |
| 2295 | } | 2291 | } |
| 2296 | 2292 | ||
| 2297 | static ResultCode ClearEvent(Core::System& system, Handle event_handle) { | 2293 | static Result ClearEvent(Core::System& system, Handle event_handle) { |
| 2298 | LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); | 2294 | LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); |
| 2299 | 2295 | ||
| 2300 | // Get the current handle table. | 2296 | // Get the current handle table. |
| @@ -2321,11 +2317,11 @@ static ResultCode ClearEvent(Core::System& system, Handle event_handle) { | |||
| 2321 | return ResultInvalidHandle; | 2317 | return ResultInvalidHandle; |
| 2322 | } | 2318 | } |
| 2323 | 2319 | ||
| 2324 | static ResultCode ClearEvent32(Core::System& system, Handle event_handle) { | 2320 | static Result ClearEvent32(Core::System& system, Handle event_handle) { |
| 2325 | return ClearEvent(system, event_handle); | 2321 | return ClearEvent(system, event_handle); |
| 2326 | } | 2322 | } |
| 2327 | 2323 | ||
| 2328 | static ResultCode CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { | 2324 | static Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { |
| 2329 | LOG_DEBUG(Kernel_SVC, "called"); | 2325 | LOG_DEBUG(Kernel_SVC, "called"); |
| 2330 | 2326 | ||
| 2331 | // Get the kernel reference and handle table. | 2327 | // Get the kernel reference and handle table. |
| @@ -2370,11 +2366,11 @@ static ResultCode CreateEvent(Core::System& system, Handle* out_write, Handle* o | |||
| 2370 | return ResultSuccess; | 2366 | return ResultSuccess; |
| 2371 | } | 2367 | } |
| 2372 | 2368 | ||
| 2373 | static ResultCode CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read) { | 2369 | static Result CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read) { |
| 2374 | return CreateEvent(system, out_write, out_read); | 2370 | return CreateEvent(system, out_write, out_read); |
| 2375 | } | 2371 | } |
| 2376 | 2372 | ||
| 2377 | static ResultCode GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type) { | 2373 | static Result GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type) { |
| 2378 | LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type); | 2374 | LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type); |
| 2379 | 2375 | ||
| 2380 | // This function currently only allows retrieving a process' status. | 2376 | // This function currently only allows retrieving a process' status. |
| @@ -2400,7 +2396,7 @@ static ResultCode GetProcessInfo(Core::System& system, u64* out, Handle process_ | |||
| 2400 | return ResultSuccess; | 2396 | return ResultSuccess; |
| 2401 | } | 2397 | } |
| 2402 | 2398 | ||
| 2403 | static ResultCode CreateResourceLimit(Core::System& system, Handle* out_handle) { | 2399 | static Result CreateResourceLimit(Core::System& system, Handle* out_handle) { |
| 2404 | LOG_DEBUG(Kernel_SVC, "called"); | 2400 | LOG_DEBUG(Kernel_SVC, "called"); |
| 2405 | 2401 | ||
| 2406 | // Create a new resource limit. | 2402 | // Create a new resource limit. |
| @@ -2423,9 +2419,8 @@ static ResultCode CreateResourceLimit(Core::System& system, Handle* out_handle) | |||
| 2423 | return ResultSuccess; | 2419 | return ResultSuccess; |
| 2424 | } | 2420 | } |
| 2425 | 2421 | ||
| 2426 | static ResultCode GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value, | 2422 | static Result GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value, |
| 2427 | Handle resource_limit_handle, | 2423 | Handle resource_limit_handle, LimitableResource which) { |
| 2428 | LimitableResource which) { | ||
| 2429 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, | 2424 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, |
| 2430 | which); | 2425 | which); |
| 2431 | 2426 | ||
| @@ -2444,9 +2439,8 @@ static ResultCode GetResourceLimitLimitValue(Core::System& system, u64* out_limi | |||
| 2444 | return ResultSuccess; | 2439 | return ResultSuccess; |
| 2445 | } | 2440 | } |
| 2446 | 2441 | ||
| 2447 | static ResultCode GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value, | 2442 | static Result GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value, |
| 2448 | Handle resource_limit_handle, | 2443 | Handle resource_limit_handle, LimitableResource which) { |
| 2449 | LimitableResource which) { | ||
| 2450 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, | 2444 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, |
| 2451 | which); | 2445 | which); |
| 2452 | 2446 | ||
| @@ -2465,8 +2459,8 @@ static ResultCode GetResourceLimitCurrentValue(Core::System& system, u64* out_cu | |||
| 2465 | return ResultSuccess; | 2459 | return ResultSuccess; |
| 2466 | } | 2460 | } |
| 2467 | 2461 | ||
| 2468 | static ResultCode SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle, | 2462 | static Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle, |
| 2469 | LimitableResource which, u64 limit_value) { | 2463 | LimitableResource which, u64 limit_value) { |
| 2470 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}", | 2464 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}", |
| 2471 | resource_limit_handle, which, limit_value); | 2465 | resource_limit_handle, which, limit_value); |
| 2472 | 2466 | ||
| @@ -2485,8 +2479,8 @@ static ResultCode SetResourceLimitLimitValue(Core::System& system, Handle resour | |||
| 2485 | return ResultSuccess; | 2479 | return ResultSuccess; |
| 2486 | } | 2480 | } |
| 2487 | 2481 | ||
| 2488 | static ResultCode GetProcessList(Core::System& system, u32* out_num_processes, | 2482 | static Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_process_ids, |
| 2489 | VAddr out_process_ids, u32 out_process_ids_size) { | 2483 | u32 out_process_ids_size) { |
| 2490 | LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}", | 2484 | LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}", |
| 2491 | out_process_ids, out_process_ids_size); | 2485 | out_process_ids, out_process_ids_size); |
| 2492 | 2486 | ||
| @@ -2522,8 +2516,8 @@ static ResultCode GetProcessList(Core::System& system, u32* out_num_processes, | |||
| 2522 | return ResultSuccess; | 2516 | return ResultSuccess; |
| 2523 | } | 2517 | } |
| 2524 | 2518 | ||
| 2525 | static ResultCode GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_thread_ids, | 2519 | static Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_thread_ids, |
| 2526 | u32 out_thread_ids_size, Handle debug_handle) { | 2520 | u32 out_thread_ids_size, Handle debug_handle) { |
| 2527 | // TODO: Handle this case when debug events are supported. | 2521 | // TODO: Handle this case when debug events are supported. |
| 2528 | UNIMPLEMENTED_IF(debug_handle != InvalidHandle); | 2522 | UNIMPLEMENTED_IF(debug_handle != InvalidHandle); |
| 2529 | 2523 | ||
| @@ -2562,9 +2556,9 @@ static ResultCode GetThreadList(Core::System& system, u32* out_num_threads, VAdd | |||
| 2562 | return ResultSuccess; | 2556 | return ResultSuccess; |
| 2563 | } | 2557 | } |
| 2564 | 2558 | ||
| 2565 | static ResultCode FlushProcessDataCache32([[maybe_unused]] Core::System& system, | 2559 | static Result FlushProcessDataCache32([[maybe_unused]] Core::System& system, |
| 2566 | [[maybe_unused]] Handle handle, | 2560 | [[maybe_unused]] Handle handle, [[maybe_unused]] u32 address, |
| 2567 | [[maybe_unused]] u32 address, [[maybe_unused]] u32 size) { | 2561 | [[maybe_unused]] u32 size) { |
| 2568 | // Note(Blinkhawk): For emulation purposes of the data cache this is mostly a no-op, | 2562 | // Note(Blinkhawk): For emulation purposes of the data cache this is mostly a no-op, |
| 2569 | // as all emulation is done in the same cache level in host architecture, thus data cache | 2563 | // as all emulation is done in the same cache level in host architecture, thus data cache |
| 2570 | // does not need flushing. | 2564 | // 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 | ||
| 12 | constexpr ResultCode ResultOutOfSessions{ErrorModule::Kernel, 7}; | 12 | constexpr Result ResultOutOfSessions{ErrorModule::Kernel, 7}; |
| 13 | constexpr ResultCode ResultInvalidArgument{ErrorModule::Kernel, 14}; | 13 | constexpr Result ResultInvalidArgument{ErrorModule::Kernel, 14}; |
| 14 | constexpr ResultCode ResultNoSynchronizationObject{ErrorModule::Kernel, 57}; | 14 | constexpr Result ResultNoSynchronizationObject{ErrorModule::Kernel, 57}; |
| 15 | constexpr ResultCode ResultTerminationRequested{ErrorModule::Kernel, 59}; | 15 | constexpr Result ResultTerminationRequested{ErrorModule::Kernel, 59}; |
| 16 | constexpr ResultCode ResultInvalidSize{ErrorModule::Kernel, 101}; | 16 | constexpr Result ResultInvalidSize{ErrorModule::Kernel, 101}; |
| 17 | constexpr ResultCode ResultInvalidAddress{ErrorModule::Kernel, 102}; | 17 | constexpr Result ResultInvalidAddress{ErrorModule::Kernel, 102}; |
| 18 | constexpr ResultCode ResultOutOfResource{ErrorModule::Kernel, 103}; | 18 | constexpr Result ResultOutOfResource{ErrorModule::Kernel, 103}; |
| 19 | constexpr ResultCode ResultOutOfMemory{ErrorModule::Kernel, 104}; | 19 | constexpr Result ResultOutOfMemory{ErrorModule::Kernel, 104}; |
| 20 | constexpr ResultCode ResultOutOfHandles{ErrorModule::Kernel, 105}; | 20 | constexpr Result ResultOutOfHandles{ErrorModule::Kernel, 105}; |
| 21 | constexpr ResultCode ResultInvalidCurrentMemory{ErrorModule::Kernel, 106}; | 21 | constexpr Result ResultInvalidCurrentMemory{ErrorModule::Kernel, 106}; |
| 22 | constexpr ResultCode ResultInvalidNewMemoryPermission{ErrorModule::Kernel, 108}; | 22 | constexpr Result ResultInvalidNewMemoryPermission{ErrorModule::Kernel, 108}; |
| 23 | constexpr ResultCode ResultInvalidMemoryRegion{ErrorModule::Kernel, 110}; | 23 | constexpr Result ResultInvalidMemoryRegion{ErrorModule::Kernel, 110}; |
| 24 | constexpr ResultCode ResultInvalidPriority{ErrorModule::Kernel, 112}; | 24 | constexpr Result ResultInvalidPriority{ErrorModule::Kernel, 112}; |
| 25 | constexpr ResultCode ResultInvalidCoreId{ErrorModule::Kernel, 113}; | 25 | constexpr Result ResultInvalidCoreId{ErrorModule::Kernel, 113}; |
| 26 | constexpr ResultCode ResultInvalidHandle{ErrorModule::Kernel, 114}; | 26 | constexpr Result ResultInvalidHandle{ErrorModule::Kernel, 114}; |
| 27 | constexpr ResultCode ResultInvalidPointer{ErrorModule::Kernel, 115}; | 27 | constexpr Result ResultInvalidPointer{ErrorModule::Kernel, 115}; |
| 28 | constexpr ResultCode ResultInvalidCombination{ErrorModule::Kernel, 116}; | 28 | constexpr Result ResultInvalidCombination{ErrorModule::Kernel, 116}; |
| 29 | constexpr ResultCode ResultTimedOut{ErrorModule::Kernel, 117}; | 29 | constexpr Result ResultTimedOut{ErrorModule::Kernel, 117}; |
| 30 | constexpr ResultCode ResultCancelled{ErrorModule::Kernel, 118}; | 30 | constexpr Result ResultCancelled{ErrorModule::Kernel, 118}; |
| 31 | constexpr ResultCode ResultOutOfRange{ErrorModule::Kernel, 119}; | 31 | constexpr Result ResultOutOfRange{ErrorModule::Kernel, 119}; |
| 32 | constexpr ResultCode ResultInvalidEnumValue{ErrorModule::Kernel, 120}; | 32 | constexpr Result ResultInvalidEnumValue{ErrorModule::Kernel, 120}; |
| 33 | constexpr ResultCode ResultNotFound{ErrorModule::Kernel, 121}; | 33 | constexpr Result ResultNotFound{ErrorModule::Kernel, 121}; |
| 34 | constexpr ResultCode ResultBusy{ErrorModule::Kernel, 122}; | 34 | constexpr Result ResultBusy{ErrorModule::Kernel, 122}; |
| 35 | constexpr ResultCode ResultSessionClosed{ErrorModule::Kernel, 123}; | 35 | constexpr Result ResultSessionClosed{ErrorModule::Kernel, 123}; |
| 36 | constexpr ResultCode ResultInvalidState{ErrorModule::Kernel, 125}; | 36 | constexpr Result ResultInvalidState{ErrorModule::Kernel, 125}; |
| 37 | constexpr ResultCode ResultReservedUsed{ErrorModule::Kernel, 126}; | 37 | constexpr Result ResultReservedUsed{ErrorModule::Kernel, 126}; |
| 38 | constexpr ResultCode ResultPortClosed{ErrorModule::Kernel, 131}; | 38 | constexpr Result ResultPortClosed{ErrorModule::Kernel, 131}; |
| 39 | constexpr ResultCode ResultLimitReached{ErrorModule::Kernel, 132}; | 39 | constexpr Result ResultLimitReached{ErrorModule::Kernel, 132}; |
| 40 | constexpr ResultCode ResultInvalidId{ErrorModule::Kernel, 519}; | 40 | constexpr 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 | ||
| 38 | template <ResultCode func(Core::System&, u64)> | 38 | template <Result func(Core::System&, u64)> |
| 39 | void SvcWrap64(Core::System& system) { | 39 | void 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 | ||
| 43 | template <ResultCode func(Core::System&, u64, u64)> | 43 | template <Result func(Core::System&, u64, u64)> |
| 44 | void SvcWrap64(Core::System& system) { | 44 | void 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 | ||
| 48 | template <ResultCode func(Core::System&, u32)> | 48 | template <Result func(Core::System&, u32)> |
| 49 | void SvcWrap64(Core::System& system) { | 49 | void 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 | ||
| 53 | template <ResultCode func(Core::System&, u32, u32)> | 53 | template <Result func(Core::System&, u32, u32)> |
| 54 | void SvcWrap64(Core::System& system) { | 54 | void 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 |
| 61 | template <ResultCode func(Core::System&, Handle, Svc::ThreadActivity)> | 61 | template <Result func(Core::System&, Handle, Svc::ThreadActivity)> |
| 62 | void SvcWrap64(Core::System& system) { | 62 | void 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 | ||
| 68 | template <ResultCode func(Core::System&, u32, u64, u64, u64)> | 68 | template <Result func(Core::System&, u32, u64, u64, u64)> |
| 69 | void SvcWrap64(Core::System& system) { | 69 | void 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 |
| 76 | template <ResultCode func(Core::System&, u64, u32, u64, u64)> | 76 | template <Result func(Core::System&, u64, u32, u64, u64)> |
| 77 | void SvcWrap64(Core::System& system) { | 77 | void 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 |
| 84 | template <ResultCode func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)> | 84 | template <Result func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)> |
| 85 | void SvcWrap64(Core::System& system) { | 85 | void 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 | ||
| 92 | template <ResultCode func(Core::System&, u32*)> | 92 | template <Result func(Core::System&, u32*)> |
| 93 | void SvcWrap64(Core::System& system) { | 93 | void SvcWrap64(Core::System& system) { |
| 94 | u32 param = 0; | 94 | u32 param = 0; |
| 95 | const u32 retval = func(system, ¶m).raw; | 95 | const u32 retval = func(system, ¶m).raw; |
| @@ -97,7 +97,7 @@ void SvcWrap64(Core::System& system) { | |||
| 97 | FuncReturn(system, retval); | 97 | FuncReturn(system, retval); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | template <ResultCode func(Core::System&, u32*, u32)> | 100 | template <Result func(Core::System&, u32*, u32)> |
| 101 | void SvcWrap64(Core::System& system) { | 101 | void SvcWrap64(Core::System& system) { |
| 102 | u32 param_1 = 0; | 102 | u32 param_1 = 0; |
| 103 | const u32 retval = func(system, ¶m_1, static_cast<u32>(Param(system, 1))).raw; | 103 | const u32 retval = func(system, ¶m_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 | ||
| 108 | template <ResultCode func(Core::System&, u32*, u32*)> | 108 | template <Result func(Core::System&, u32*, u32*)> |
| 109 | void SvcWrap64(Core::System& system) { | 109 | void 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 | ||
| 121 | template <ResultCode func(Core::System&, u32*, u64)> | 121 | template <Result func(Core::System&, u32*, u64)> |
| 122 | void SvcWrap64(Core::System& system) { | 122 | void SvcWrap64(Core::System& system) { |
| 123 | u32 param_1 = 0; | 123 | u32 param_1 = 0; |
| 124 | const u32 retval = func(system, ¶m_1, Param(system, 1)).raw; | 124 | const u32 retval = func(system, ¶m_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 | ||
| 129 | template <ResultCode func(Core::System&, u32*, u64, u32)> | 129 | template <Result func(Core::System&, u32*, u64, u32)> |
| 130 | void SvcWrap64(Core::System& system) { | 130 | void 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 | ||
| 139 | template <ResultCode func(Core::System&, u64*, u32)> | 139 | template <Result func(Core::System&, u64*, u32)> |
| 140 | void SvcWrap64(Core::System& system) { | 140 | void SvcWrap64(Core::System& system) { |
| 141 | u64 param_1 = 0; | 141 | u64 param_1 = 0; |
| 142 | const u32 retval = func(system, ¶m_1, static_cast<u32>(Param(system, 1))).raw; | 142 | const u32 retval = func(system, ¶m_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 | ||
| 148 | template <ResultCode func(Core::System&, u64, u32)> | 148 | template <Result func(Core::System&, u64, u32)> |
| 149 | void SvcWrap64(Core::System& system) { | 149 | void 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 | ||
| 153 | template <ResultCode func(Core::System&, u64*, u64)> | 153 | template <Result func(Core::System&, u64*, u64)> |
| 154 | void SvcWrap64(Core::System& system) { | 154 | void SvcWrap64(Core::System& system) { |
| 155 | u64 param_1 = 0; | 155 | u64 param_1 = 0; |
| 156 | const u32 retval = func(system, ¶m_1, Param(system, 1)).raw; | 156 | const u32 retval = func(system, ¶m_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 | ||
| 162 | template <ResultCode func(Core::System&, u64*, u32, u32)> | 162 | template <Result func(Core::System&, u64*, u32, u32)> |
| 163 | void SvcWrap64(Core::System& system) { | 163 | void SvcWrap64(Core::System& system) { |
| 164 | u64 param_1 = 0; | 164 | u64 param_1 = 0; |
| 165 | const u32 retval = func(system, ¶m_1, static_cast<u32>(Param(system, 1)), | 165 | const u32 retval = func(system, ¶m_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. |
| 174 | template <ResultCode func(Core::System&, u64*, Handle, LimitableResource)> | 174 | template <Result func(Core::System&, u64*, Handle, LimitableResource)> |
| 175 | void SvcWrap64(Core::System& system) { | 175 | void SvcWrap64(Core::System& system) { |
| 176 | u64 param_1 = 0; | 176 | u64 param_1 = 0; |
| 177 | const u32 retval = func(system, ¶m_1, static_cast<Handle>(Param(system, 1)), | 177 | const u32 retval = func(system, ¶m_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 | ||
| 185 | template <ResultCode func(Core::System&, u32, u64)> | 185 | template <Result func(Core::System&, u32, u64)> |
| 186 | void SvcWrap64(Core::System& system) { | 186 | void 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 |
| 191 | template <ResultCode func(Core::System&, Handle, LimitableResource, u64)> | 191 | template <Result func(Core::System&, Handle, LimitableResource, u64)> |
| 192 | void SvcWrap64(Core::System& system) { | 192 | void 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 |
| 199 | template <ResultCode func(Core::System&, Handle, s32, u64)> | 199 | template <Result func(Core::System&, Handle, s32, u64)> |
| 200 | void SvcWrap64(Core::System& system) { | 200 | void 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 |
| 207 | template <ResultCode func(Core::System&, Handle, s32*, u64*)> | 207 | template <Result func(Core::System&, Handle, s32*, u64*)> |
| 208 | void SvcWrap64(Core::System& system) { | 208 | void 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)), ¶m_1, ¶m_2); | 211 | const Result retval = func(system, static_cast<u32>(Param(system, 2)), ¶m_1, ¶m_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 | ||
| 218 | template <ResultCode func(Core::System&, u64, u64, u32, u32)> | 218 | template <Result func(Core::System&, u64, u64, u32, u32)> |
| 219 | void SvcWrap64(Core::System& system) { | 219 | void 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 | ||
| 225 | template <ResultCode func(Core::System&, u64, u64, u32, u64)> | 225 | template <Result func(Core::System&, u64, u64, u32, u64)> |
| 226 | void SvcWrap64(Core::System& system) { | 226 | void 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 | ||
| 232 | template <ResultCode func(Core::System&, u32, u64, u32)> | 232 | template <Result func(Core::System&, u32, u64, u32)> |
| 233 | void SvcWrap64(Core::System& system) { | 233 | void 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 | ||
| 239 | template <ResultCode func(Core::System&, u64, u64, u64)> | 239 | template <Result func(Core::System&, u64, u64, u64)> |
| 240 | void SvcWrap64(Core::System& system) { | 240 | void 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 | ||
| 244 | template <ResultCode func(Core::System&, u64, u64, u32)> | 244 | template <Result func(Core::System&, u64, u64, u32)> |
| 245 | void SvcWrap64(Core::System& system) { | 245 | void 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 |
| 252 | template <ResultCode func(Core::System&, u64, u64, Svc::MemoryPermission)> | 252 | template <Result func(Core::System&, u64, u64, Svc::MemoryPermission)> |
| 253 | void SvcWrap64(Core::System& system) { | 253 | void 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 |
| 260 | template <ResultCode func(Core::System&, Handle, u64, u64, Svc::MemoryPermission)> | 260 | template <Result func(Core::System&, Handle, u64, u64, Svc::MemoryPermission)> |
| 261 | void SvcWrap64(Core::System& system) { | 261 | void 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 | ||
| 267 | template <ResultCode func(Core::System&, u32, u64, u64)> | 267 | template <Result func(Core::System&, u32, u64, u64)> |
| 268 | void SvcWrap64(Core::System& system) { | 268 | void 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 |
| 275 | template <ResultCode func(Core::System&, s32*, u64, s32, s64)> | 275 | template <Result func(Core::System&, s32*, u64, s32, s64)> |
| 276 | void SvcWrap64(Core::System& system) { | 276 | void SvcWrap64(Core::System& system) { |
| 277 | s32 param_1 = 0; | 277 | s32 param_1 = 0; |
| 278 | const u32 retval = func(system, ¶m_1, Param(system, 1), static_cast<s32>(Param(system, 2)), | 278 | const u32 retval = func(system, ¶m_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 | ||
| 286 | template <ResultCode func(Core::System&, u64, u64, u32, s64)> | 286 | template <Result func(Core::System&, u64, u64, u32, s64)> |
| 287 | void SvcWrap64(Core::System& system) { | 287 | void 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 |
| 294 | template <ResultCode func(Core::System&, u64*, u64, Handle, u64)> | 294 | template <Result func(Core::System&, u64*, u64, Handle, u64)> |
| 295 | void SvcWrap64(Core::System& system) { | 295 | void SvcWrap64(Core::System& system) { |
| 296 | u64 param_1 = 0; | 296 | u64 param_1 = 0; |
| 297 | const u32 retval = func(system, ¶m_1, Param(system, 1), | 297 | const u32 retval = func(system, ¶m_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 | ||
| 305 | template <ResultCode func(Core::System&, u32*, u64, u64, u64, u32, s32)> | 305 | template <Result func(Core::System&, u32*, u64, u64, u64, u32, s32)> |
| 306 | void SvcWrap64(Core::System& system) { | 306 | void SvcWrap64(Core::System& system) { |
| 307 | u32 param_1 = 0; | 307 | u32 param_1 = 0; |
| 308 | const u32 retval = func(system, ¶m_1, Param(system, 1), Param(system, 2), Param(system, 3), | 308 | const u32 retval = func(system, ¶m_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 |
| 317 | template <ResultCode func(Core::System&, Handle*, u64, u64, Svc::MemoryPermission)> | 317 | template <Result func(Core::System&, Handle*, u64, u64, Svc::MemoryPermission)> |
| 318 | void SvcWrap64(Core::System& system) { | 318 | void SvcWrap64(Core::System& system) { |
| 319 | u32 param_1 = 0; | 319 | u32 param_1 = 0; |
| 320 | const u32 retval = func(system, ¶m_1, Param(system, 1), Param(system, 2), | 320 | const u32 retval = func(system, ¶m_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 |
| 329 | template <ResultCode func(Core::System&, Handle*, u64, u64)> | 329 | template <Result func(Core::System&, Handle*, u64, u64)> |
| 330 | void SvcWrap64(Core::System& system) { | 330 | void SvcWrap64(Core::System& system) { |
| 331 | u32 param_1 = 0; | 331 | u32 param_1 = 0; |
| 332 | const u32 retval = func(system, ¶m_1, Param(system, 1), Param(system, 2)).raw; | 332 | const u32 retval = func(system, ¶m_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 | ||
| 338 | template <ResultCode func(Core::System&, Handle*, u64, u32, u32)> | 338 | template <Result func(Core::System&, Handle*, u64, u32, u32)> |
| 339 | void SvcWrap64(Core::System& system) { | 339 | void SvcWrap64(Core::System& system) { |
| 340 | u32 param_1 = 0; | 340 | u32 param_1 = 0; |
| 341 | const u32 retval = func(system, ¶m_1, Param(system, 1), static_cast<u32>(Param(system, 2)), | 341 | const u32 retval = func(system, ¶m_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 |
| 350 | template <ResultCode func(Core::System&, u64, Svc::ArbitrationType, s32, s64)> | 350 | template <Result func(Core::System&, u64, Svc::ArbitrationType, s32, s64)> |
| 351 | void SvcWrap64(Core::System& system) { | 351 | void 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 |
| 359 | template <ResultCode func(Core::System&, u64, Svc::SignalType, s32, s32)> | 359 | template <Result func(Core::System&, u64, Svc::SignalType, s32, s32)> |
| 360 | void SvcWrap64(Core::System& system) { | 360 | void 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 |
| 428 | template <ResultCode func(Core::System&, u32, u32, u32)> | 428 | template <Result func(Core::System&, u32, u32, u32)> |
| 429 | void SvcWrap32(Core::System& system) { | 429 | void 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 |
| 459 | template <ResultCode func(Core::System&, Handle*, u32, u32, u32, u32, s32)> | 459 | template <Result func(Core::System&, Handle*, u32, u32, u32, u32, s32)> |
| 460 | void SvcWrap32(Core::System& system) { | 460 | void 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 |
| 472 | template <ResultCode func(Core::System&, u32*, u32*, u32, u32, u32, u32)> | 472 | template <Result func(Core::System&, u32*, u32*, u32, u32, u32, u32)> |
| 473 | void SvcWrap32(Core::System& system) { | 473 | void 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 |
| 487 | template <ResultCode func(Core::System&, u32*, u32)> | 487 | template <Result func(Core::System&, u32*, u32)> |
| 488 | void SvcWrap32(Core::System& system) { | 488 | void SvcWrap32(Core::System& system) { |
| 489 | u32 param_1 = 0; | 489 | u32 param_1 = 0; |
| 490 | const u32 retval = func(system, ¶m_1, Param32(system, 1)).raw; | 490 | const u32 retval = func(system, ¶m_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 |
| 496 | template <ResultCode func(Core::System&, u32*, u32*, u32)> | 496 | template <Result func(Core::System&, u32*, u32*, u32)> |
| 497 | void SvcWrap32(Core::System& system) { | 497 | void 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 |
| 519 | template <ResultCode func(Core::System&, Handle*, Handle*)> | 519 | template <Result func(Core::System&, Handle*, Handle*)> |
| 520 | void SvcWrap32(Core::System& system) { | 520 | void 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 |
| 531 | template <ResultCode func(Core::System&, Handle, u32*, u32*, u32*)> | 531 | template <Result func(Core::System&, Handle, u32*, u32*, u32*)> |
| 532 | void SvcWrap32(Core::System& system) { | 532 | void 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 |
| 545 | template <ResultCode func(Core::System&, Handle, s32*, u32*, u32*)> | 545 | template <Result func(Core::System&, Handle, s32*, u32*, u32*)> |
| 546 | void SvcWrap32(Core::System& system) { | 546 | void 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 |
| 565 | template <ResultCode func(Core::System&, Handle, Svc::ThreadActivity)> | 565 | template <Result func(Core::System&, Handle, Svc::ThreadActivity)> |
| 566 | void SvcWrap32(Core::System& system) { | 566 | void 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 |
| 574 | template <ResultCode func(Core::System&, Handle, u32)> | 574 | template <Result func(Core::System&, Handle, u32)> |
| 575 | void SvcWrap32(Core::System& system) { | 575 | void 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 |
| 582 | template <ResultCode func(Core::System&, Handle, u32, u32, u32)> | 582 | template <Result func(Core::System&, Handle, u32, u32, u32)> |
| 583 | void SvcWrap32(Core::System& system) { | 583 | void 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 |
| 592 | template <ResultCode func(Core::System&, Handle, u32, u32, Svc::MemoryPermission)> | 592 | template <Result func(Core::System&, Handle, u32, u32, Svc::MemoryPermission)> |
| 593 | void SvcWrap32(Core::System& system) { | 593 | void 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 |
| 602 | template <ResultCode func(Core::System&, Handle, s32, u32, u32)> | 602 | template <Result func(Core::System&, Handle, s32, u32, u32)> |
| 603 | void SvcWrap32(Core::System& system) { | 603 | void 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 |
| 612 | template <ResultCode func(Core::System&, u32, u32, Handle, u32, u32)> | 612 | template <Result func(Core::System&, u32, u32, Handle, u32, u32)> |
| 613 | void SvcWrap32(Core::System& system) { | 613 | void 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 |
| 623 | template <ResultCode func(Core::System&, u32, Svc::ArbitrationType, s32, u32, u32)> | 623 | template <Result func(Core::System&, u32, Svc::ArbitrationType, s32, u32, u32)> |
| 624 | void SvcWrap32(Core::System& system) { | 624 | void 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 |
| 634 | template <ResultCode func(Core::System&, u32, Svc::SignalType, s32, s32)> | 634 | template <Result func(Core::System&, u32, Svc::SignalType, s32, s32)> |
| 635 | void SvcWrap32(Core::System& system) { | 635 | void 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 |
| 644 | template <ResultCode func(Core::System&, u32)> | 644 | template <Result func(Core::System&, u32)> |
| 645 | void SvcWrap32(Core::System& system) { | 645 | void 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 |
| 650 | template <ResultCode func(Core::System&, Handle*, u32, u32, Svc::MemoryPermission)> | 650 | template <Result func(Core::System&, Handle*, u32, u32, Svc::MemoryPermission)> |
| 651 | void SvcWrap32(Core::System& system) { | 651 | void 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 |
| 661 | template <ResultCode func(Core::System&, u32, u32, s32, u32, s32*)> | 661 | template <Result func(Core::System&, u32, u32, s32, u32, s32*)> |
| 662 | void SvcWrap32(Core::System& system) { | 662 | void 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 |
| 672 | template <ResultCode func(Core::System&, Handle*, u32, u32)> | 672 | template <Result func(Core::System&, Handle*, u32, u32)> |
| 673 | void SvcWrap32(Core::System& system) { | 673 | void 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 |
| 683 | template <ResultCode func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)> | 683 | template <Result func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)> |
| 684 | void SvcWrap32(Core::System& system) { | 684 | void 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), |