diff options
Diffstat (limited to 'src/core/hle/kernel')
50 files changed, 685 insertions, 719 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..da57ceb21 100644 --- a/src/core/hle/kernel/k_code_memory.cpp +++ b/src/core/hle/kernel/k_code_memory.cpp | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include "core/hle/kernel/k_code_memory.h" | 7 | #include "core/hle/kernel/k_code_memory.h" |
| 8 | #include "core/hle/kernel/k_light_lock.h" | 8 | #include "core/hle/kernel/k_light_lock.h" |
| 9 | #include "core/hle/kernel/k_memory_block.h" | 9 | #include "core/hle/kernel/k_memory_block.h" |
| 10 | #include "core/hle/kernel/k_page_linked_list.h" | 10 | #include "core/hle/kernel/k_page_group.h" |
| 11 | #include "core/hle/kernel/k_page_table.h" | 11 | #include "core/hle/kernel/k_page_table.h" |
| 12 | #include "core/hle/kernel/k_process.h" | 12 | #include "core/hle/kernel/k_process.h" |
| 13 | #include "core/hle/kernel/slab_helpers.h" | 13 | #include "core/hle/kernel/slab_helpers.h" |
| @@ -19,7 +19,7 @@ namespace Kernel { | |||
| 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..2410f74a3 100644 --- a/src/core/hle/kernel/k_code_memory.h +++ b/src/core/hle/kernel/k_code_memory.h | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include "core/device_memory.h" | 7 | #include "core/device_memory.h" |
| 8 | #include "core/hle/kernel/k_auto_object.h" | 8 | #include "core/hle/kernel/k_auto_object.h" |
| 9 | #include "core/hle/kernel/k_light_lock.h" | 9 | #include "core/hle/kernel/k_light_lock.h" |
| 10 | #include "core/hle/kernel/k_page_linked_list.h" | 10 | #include "core/hle/kernel/k_page_group.h" |
| 11 | #include "core/hle/kernel/k_process.h" | 11 | #include "core/hle/kernel/k_process.h" |
| 12 | #include "core/hle/kernel/slab_helpers.h" | 12 | #include "core/hle/kernel/slab_helpers.h" |
| 13 | #include "core/hle/kernel/svc_types.h" | 13 | #include "core/hle/kernel/svc_types.h" |
| @@ -29,13 +29,13 @@ class KCodeMemory final | |||
| 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; |
| @@ -53,7 +53,7 @@ public: | |||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | private: | 55 | private: |
| 56 | KPageLinkedList m_page_group{}; | 56 | KPageGroup m_page_group{}; |
| 57 | KProcess* m_owner{}; | 57 | KProcess* m_owner{}; |
| 58 | VAddr m_address{}; | 58 | VAddr m_address{}; |
| 59 | KLightLock m_lock; | 59 | KLightLock m_lock; |
diff --git a/src/core/hle/kernel/k_condition_variable.cpp b/src/core/hle/kernel/k_condition_variable.cpp index a8b5411e3..124149697 100644 --- a/src/core/hle/kernel/k_condition_variable.cpp +++ b/src/core/hle/kernel/k_condition_variable.cpp | |||
| @@ -61,8 +61,7 @@ public: | |||
| 61 | explicit ThreadQueueImplForKConditionVariableWaitForAddress(KernelCore& kernel_) | 61 | explicit ThreadQueueImplForKConditionVariableWaitForAddress(KernelCore& kernel_) |
| 62 | : KThreadQueue(kernel_) {} | 62 | : KThreadQueue(kernel_) {} |
| 63 | 63 | ||
| 64 | void CancelWait(KThread* waiting_thread, ResultCode wait_result, | 64 | void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override { |
| 65 | bool cancel_timer_task) override { | ||
| 66 | // Remove the thread as a waiter from its owner. | 65 | // Remove the thread as a waiter from its owner. |
| 67 | waiting_thread->GetLockOwner()->RemoveWaiter(waiting_thread); | 66 | waiting_thread->GetLockOwner()->RemoveWaiter(waiting_thread); |
| 68 | 67 | ||
| @@ -80,8 +79,7 @@ public: | |||
| 80 | KernelCore& kernel_, KConditionVariable::ThreadTree* t) | 79 | KernelCore& kernel_, KConditionVariable::ThreadTree* t) |
| 81 | : KThreadQueue(kernel_), m_tree(t) {} | 80 | : KThreadQueue(kernel_), m_tree(t) {} |
| 82 | 81 | ||
| 83 | void CancelWait(KThread* waiting_thread, ResultCode wait_result, | 82 | void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override { |
| 84 | bool cancel_timer_task) override { | ||
| 85 | // Remove the thread as a waiter from its owner. | 83 | // Remove the thread as a waiter from its owner. |
| 86 | if (KThread* owner = waiting_thread->GetLockOwner(); owner != nullptr) { | 84 | if (KThread* owner = waiting_thread->GetLockOwner(); owner != nullptr) { |
| 87 | owner->RemoveWaiter(waiting_thread); | 85 | owner->RemoveWaiter(waiting_thread); |
| @@ -105,7 +103,7 @@ KConditionVariable::KConditionVariable(Core::System& system_) | |||
| 105 | 103 | ||
| 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..5b0a9963a 100644 --- a/src/core/hle/kernel/k_memory_manager.cpp +++ b/src/core/hle/kernel/k_memory_manager.cpp | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #include "core/device_memory.h" | 11 | #include "core/device_memory.h" |
| 12 | #include "core/hle/kernel/initial_process.h" | 12 | #include "core/hle/kernel/initial_process.h" |
| 13 | #include "core/hle/kernel/k_memory_manager.h" | 13 | #include "core/hle/kernel/k_memory_manager.h" |
| 14 | #include "core/hle/kernel/k_page_linked_list.h" | 14 | #include "core/hle/kernel/k_page_group.h" |
| 15 | #include "core/hle/kernel/kernel.h" | 15 | #include "core/hle/kernel/kernel.h" |
| 16 | #include "core/hle/kernel/svc_results.h" | 16 | #include "core/hle/kernel/svc_results.h" |
| 17 | 17 | ||
| @@ -208,8 +208,8 @@ PAddr KMemoryManager::AllocateAndOpenContinuous(size_t num_pages, size_t align_p | |||
| 208 | return allocated_block; | 208 | return allocated_block; |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | ResultCode KMemoryManager::AllocatePageGroupImpl(KPageLinkedList* out, size_t num_pages, Pool pool, | 211 | Result KMemoryManager::AllocatePageGroupImpl(KPageGroup* out, size_t num_pages, Pool pool, |
| 212 | Direction dir, bool random) { | 212 | Direction dir, bool random) { |
| 213 | // Choose a heap based on our page size request. | 213 | // Choose a heap based on our page size request. |
| 214 | const s32 heap_index = KPageHeap::GetBlockIndex(num_pages); | 214 | const s32 heap_index = KPageHeap::GetBlockIndex(num_pages); |
| 215 | R_UNLESS(0 <= heap_index, ResultOutOfMemory); | 215 | R_UNLESS(0 <= heap_index, ResultOutOfMemory); |
| @@ -257,7 +257,7 @@ ResultCode KMemoryManager::AllocatePageGroupImpl(KPageLinkedList* out, size_t nu | |||
| 257 | return ResultSuccess; | 257 | return ResultSuccess; |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | ResultCode KMemoryManager::AllocateAndOpen(KPageLinkedList* out, size_t num_pages, u32 option) { | 260 | Result KMemoryManager::AllocateAndOpen(KPageGroup* out, size_t num_pages, u32 option) { |
| 261 | ASSERT(out != nullptr); | 261 | ASSERT(out != nullptr); |
| 262 | ASSERT(out->GetNumPages() == 0); | 262 | ASSERT(out->GetNumPages() == 0); |
| 263 | 263 | ||
| @@ -293,8 +293,8 @@ ResultCode KMemoryManager::AllocateAndOpen(KPageLinkedList* out, size_t num_page | |||
| 293 | return ResultSuccess; | 293 | return ResultSuccess; |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | ResultCode KMemoryManager::AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, | 296 | Result KMemoryManager::AllocateAndOpenForProcess(KPageGroup* out, size_t num_pages, u32 option, |
| 297 | u32 option, u64 process_id, u8 fill_pattern) { | 297 | u64 process_id, u8 fill_pattern) { |
| 298 | ASSERT(out != nullptr); | 298 | ASSERT(out != nullptr); |
| 299 | ASSERT(out->GetNumPages() == 0); | 299 | ASSERT(out->GetNumPages() == 0); |
| 300 | 300 | ||
| @@ -370,12 +370,12 @@ void KMemoryManager::Close(PAddr address, size_t num_pages) { | |||
| 370 | } | 370 | } |
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | void KMemoryManager::Close(const KPageLinkedList& pg) { | 373 | void KMemoryManager::Close(const KPageGroup& pg) { |
| 374 | for (const auto& node : pg.Nodes()) { | 374 | for (const auto& node : pg.Nodes()) { |
| 375 | Close(node.GetAddress(), node.GetNumPages()); | 375 | Close(node.GetAddress(), node.GetNumPages()); |
| 376 | } | 376 | } |
| 377 | } | 377 | } |
| 378 | void KMemoryManager::Open(const KPageLinkedList& pg) { | 378 | void KMemoryManager::Open(const KPageGroup& pg) { |
| 379 | for (const auto& node : pg.Nodes()) { | 379 | for (const auto& node : pg.Nodes()) { |
| 380 | Open(node.GetAddress(), node.GetNumPages()); | 380 | Open(node.GetAddress(), node.GetNumPages()); |
| 381 | } | 381 | } |
diff --git a/src/core/hle/kernel/k_memory_manager.h b/src/core/hle/kernel/k_memory_manager.h index c7923cb82..dcb9b6348 100644 --- a/src/core/hle/kernel/k_memory_manager.h +++ b/src/core/hle/kernel/k_memory_manager.h | |||
| @@ -19,7 +19,7 @@ class System; | |||
| 19 | 19 | ||
| 20 | namespace Kernel { | 20 | namespace Kernel { |
| 21 | 21 | ||
| 22 | class KPageLinkedList; | 22 | class KPageGroup; |
| 23 | 23 | ||
| 24 | class KMemoryManager final { | 24 | class KMemoryManager final { |
| 25 | public: | 25 | public: |
| @@ -65,17 +65,17 @@ public: | |||
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | PAddr AllocateAndOpenContinuous(size_t num_pages, size_t align_pages, u32 option); | 67 | PAddr AllocateAndOpenContinuous(size_t num_pages, size_t align_pages, u32 option); |
| 68 | ResultCode AllocateAndOpen(KPageLinkedList* out, size_t num_pages, u32 option); | 68 | Result AllocateAndOpen(KPageGroup* out, size_t num_pages, u32 option); |
| 69 | ResultCode AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, u32 option, | 69 | Result AllocateAndOpenForProcess(KPageGroup* out, size_t num_pages, u32 option, u64 process_id, |
| 70 | u64 process_id, u8 fill_pattern); | 70 | u8 fill_pattern); |
| 71 | 71 | ||
| 72 | static constexpr size_t MaxManagerCount = 10; | 72 | static constexpr size_t MaxManagerCount = 10; |
| 73 | 73 | ||
| 74 | void Close(PAddr address, size_t num_pages); | 74 | void Close(PAddr address, size_t num_pages); |
| 75 | void Close(const KPageLinkedList& pg); | 75 | void Close(const KPageGroup& pg); |
| 76 | 76 | ||
| 77 | void Open(PAddr address, size_t num_pages); | 77 | void Open(PAddr address, size_t num_pages); |
| 78 | void Open(const KPageLinkedList& pg); | 78 | void Open(const KPageGroup& pg); |
| 79 | 79 | ||
| 80 | public: | 80 | public: |
| 81 | static size_t CalculateManagementOverheadSize(size_t region_size) { | 81 | static size_t CalculateManagementOverheadSize(size_t region_size) { |
| @@ -262,8 +262,8 @@ private: | |||
| 262 | } | 262 | } |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | ResultCode AllocatePageGroupImpl(KPageLinkedList* out, size_t num_pages, Pool pool, | 265 | Result AllocatePageGroupImpl(KPageGroup* out, size_t num_pages, Pool pool, Direction dir, |
| 266 | Direction dir, bool random); | 266 | bool random); |
| 267 | 267 | ||
| 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_group.h index 1f79c8330..968753992 100644 --- a/src/core/hle/kernel/k_page_linked_list.h +++ b/src/core/hle/kernel/k_page_group.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
| 14 | 14 | ||
| 15 | class KPageLinkedList final { | 15 | class KPageGroup final { |
| 16 | public: | 16 | public: |
| 17 | class Node final { | 17 | class Node final { |
| 18 | public: | 18 | public: |
| @@ -36,8 +36,8 @@ public: | |||
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | public: | 38 | public: |
| 39 | KPageLinkedList() = default; | 39 | KPageGroup() = default; |
| 40 | KPageLinkedList(u64 address, u64 num_pages) { | 40 | KPageGroup(u64 address, u64 num_pages) { |
| 41 | ASSERT(AddBlock(address, num_pages).IsSuccess()); | 41 | ASSERT(AddBlock(address, num_pages).IsSuccess()); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| @@ -57,7 +57,7 @@ public: | |||
| 57 | return num_pages; | 57 | return num_pages; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | bool IsEqual(KPageLinkedList& other) const { | 60 | bool IsEqual(KPageGroup& other) const { |
| 61 | auto this_node = nodes.begin(); | 61 | auto this_node = nodes.begin(); |
| 62 | auto other_node = other.nodes.begin(); | 62 | auto other_node = other.nodes.begin(); |
| 63 | while (this_node != nodes.end() && other_node != other.nodes.end()) { | 63 | while (this_node != nodes.end() && other_node != other.nodes.end()) { |
| @@ -72,7 +72,7 @@ public: | |||
| 72 | return this_node == nodes.end() && other_node == other.nodes.end(); | 72 | return this_node == nodes.end() && other_node == other.nodes.end(); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | ResultCode AddBlock(u64 address, u64 num_pages) { | 75 | Result AddBlock(u64 address, u64 num_pages) { |
| 76 | if (!num_pages) { | 76 | if (!num_pages) { |
| 77 | return ResultSuccess; | 77 | return ResultSuccess; |
| 78 | } | 78 | } |
diff --git a/src/core/hle/kernel/k_page_table.cpp b/src/core/hle/kernel/k_page_table.cpp index 39b89da53..d975de844 100644 --- a/src/core/hle/kernel/k_page_table.cpp +++ b/src/core/hle/kernel/k_page_table.cpp | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "core/hle/kernel/k_address_space_info.h" | 9 | #include "core/hle/kernel/k_address_space_info.h" |
| 10 | #include "core/hle/kernel/k_memory_block.h" | 10 | #include "core/hle/kernel/k_memory_block.h" |
| 11 | #include "core/hle/kernel/k_memory_block_manager.h" | 11 | #include "core/hle/kernel/k_memory_block_manager.h" |
| 12 | #include "core/hle/kernel/k_page_linked_list.h" | 12 | #include "core/hle/kernel/k_page_group.h" |
| 13 | #include "core/hle/kernel/k_page_table.h" | 13 | #include "core/hle/kernel/k_page_table.h" |
| 14 | #include "core/hle/kernel/k_process.h" | 14 | #include "core/hle/kernel/k_process.h" |
| 15 | #include "core/hle/kernel/k_resource_limit.h" | 15 | #include "core/hle/kernel/k_resource_limit.h" |
| @@ -47,9 +47,9 @@ KPageTable::KPageTable(Core::System& system_) | |||
| 47 | 47 | ||
| 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. |
| @@ -271,7 +271,7 @@ ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemory | |||
| 271 | R_TRY(this->CheckMemoryState(addr, size, KMemoryState::All, KMemoryState::Free, | 271 | R_TRY(this->CheckMemoryState(addr, size, KMemoryState::All, KMemoryState::Free, |
| 272 | KMemoryPermission::None, KMemoryPermission::None, | 272 | KMemoryPermission::None, KMemoryPermission::None, |
| 273 | KMemoryAttribute::None, KMemoryAttribute::None)); | 273 | KMemoryAttribute::None, KMemoryAttribute::None)); |
| 274 | KPageLinkedList pg; | 274 | KPageGroup pg; |
| 275 | R_TRY(system.Kernel().MemoryManager().AllocateAndOpen( | 275 | R_TRY(system.Kernel().MemoryManager().AllocateAndOpen( |
| 276 | &pg, num_pages, | 276 | &pg, num_pages, |
| 277 | KMemoryManager::EncodeOption(KMemoryManager::Pool::Application, allocation_option))); | 277 | KMemoryManager::EncodeOption(KMemoryManager::Pool::Application, allocation_option))); |
| @@ -283,7 +283,7 @@ ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemory | |||
| 283 | return ResultSuccess; | 283 | return ResultSuccess; |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 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); |
| @@ -313,7 +313,7 @@ ResultCode KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std:: | |||
| 313 | const std::size_t num_pages = size / PageSize; | 313 | const std::size_t num_pages = size / PageSize; |
| 314 | 314 | ||
| 315 | // Create page groups for the memory being mapped. | 315 | // Create page groups for the memory being mapped. |
| 316 | KPageLinkedList pg; | 316 | KPageGroup pg; |
| 317 | AddRegionToPages(src_address, num_pages, pg); | 317 | AddRegionToPages(src_address, num_pages, pg); |
| 318 | 318 | ||
| 319 | // Reprotect the source as kernel-read/not mapped. | 319 | // Reprotect the source as kernel-read/not mapped. |
| @@ -344,8 +344,8 @@ ResultCode KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std:: | |||
| 344 | return ResultSuccess; | 344 | return ResultSuccess; |
| 345 | } | 345 | } |
| 346 | 346 | ||
| 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(KPageGroup& pg, VAddr addr, size_t num_pages) { |
| 493 | ASSERT(this->IsLockedByCurrentThread()); | 493 | ASSERT(this->IsLockedByCurrentThread()); |
| 494 | 494 | ||
| 495 | const size_t size = num_pages * PageSize; | 495 | const size_t size = num_pages * PageSize; |
| @@ -541,7 +541,7 @@ ResultCode KPageTable::MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num | |||
| 541 | return ResultSuccess; | 541 | return ResultSuccess; |
| 542 | } | 542 | } |
| 543 | 543 | ||
| 544 | bool KPageTable::IsValidPageGroup(const KPageLinkedList& pg_ll, VAddr addr, size_t num_pages) { | 544 | bool KPageTable::IsValidPageGroup(const KPageGroup& pg_ll, VAddr addr, size_t num_pages) { |
| 545 | ASSERT(this->IsLockedByCurrentThread()); | 545 | ASSERT(this->IsLockedByCurrentThread()); |
| 546 | 546 | ||
| 547 | const size_t size = num_pages * PageSize; | 547 | const size_t size = num_pages * PageSize; |
| @@ -630,8 +630,8 @@ bool KPageTable::IsValidPageGroup(const KPageLinkedList& pg_ll, VAddr addr, size | |||
| 630 | return cur_block_address == cur_addr && cur_block_pages == (cur_size / PageSize); | 630 | return cur_block_address == cur_addr && cur_block_pages == (cur_size / PageSize); |
| 631 | } | 631 | } |
| 632 | 632 | ||
| 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 | ||
| @@ -721,7 +721,7 @@ ResultCode KPageTable::MapPhysicalMemory(VAddr address, std::size_t size) { | |||
| 721 | R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached); | 721 | R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached); |
| 722 | 722 | ||
| 723 | // Allocate pages for the new memory. | 723 | // Allocate pages for the new memory. |
| 724 | KPageLinkedList pg; | 724 | KPageGroup pg; |
| 725 | R_TRY(system.Kernel().MemoryManager().AllocateAndOpenForProcess( | 725 | R_TRY(system.Kernel().MemoryManager().AllocateAndOpenForProcess( |
| 726 | &pg, (size - mapped_size) / PageSize, | 726 | &pg, (size - mapped_size) / PageSize, |
| 727 | KMemoryManager::EncodeOption(memory_pool, allocation_option), 0, 0)); | 727 | KMemoryManager::EncodeOption(memory_pool, allocation_option), 0, 0)); |
| @@ -903,7 +903,7 @@ ResultCode KPageTable::MapPhysicalMemory(VAddr address, std::size_t size) { | |||
| 903 | } | 903 | } |
| 904 | } | 904 | } |
| 905 | 905 | ||
| 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 | ||
| @@ -972,7 +972,7 @@ ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) { | |||
| 972 | } | 972 | } |
| 973 | 973 | ||
| 974 | // Make a page group for the unmap region. | 974 | // Make a page group for the unmap region. |
| 975 | KPageLinkedList pg; | 975 | KPageGroup pg; |
| 976 | { | 976 | { |
| 977 | auto& impl = this->PageTableImpl(); | 977 | auto& impl = this->PageTableImpl(); |
| 978 | 978 | ||
| @@ -1134,7 +1134,7 @@ ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) { | |||
| 1134 | return ResultSuccess; | 1134 | return ResultSuccess; |
| 1135 | } | 1135 | } |
| 1136 | 1136 | ||
| 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{}; |
| @@ -1147,7 +1147,7 @@ ResultCode KPageTable::MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t siz | |||
| 1147 | return ResultInvalidCurrentMemory; | 1147 | return ResultInvalidCurrentMemory; |
| 1148 | } | 1148 | } |
| 1149 | 1149 | ||
| 1150 | KPageLinkedList page_linked_list; | 1150 | KPageGroup page_linked_list; |
| 1151 | const std::size_t num_pages{size / PageSize}; | 1151 | const std::size_t num_pages{size / PageSize}; |
| 1152 | 1152 | ||
| 1153 | AddRegionToPages(src_addr, num_pages, page_linked_list); | 1153 | AddRegionToPages(src_addr, num_pages, page_linked_list); |
| @@ -1173,7 +1173,7 @@ ResultCode KPageTable::MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t siz | |||
| 1173 | return ResultSuccess; | 1173 | return ResultSuccess; |
| 1174 | } | 1174 | } |
| 1175 | 1175 | ||
| 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{}; |
| @@ -1188,8 +1188,8 @@ ResultCode KPageTable::UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t s | |||
| 1188 | KMemoryPermission::None, KMemoryAttribute::Mask, | 1188 | KMemoryPermission::None, KMemoryAttribute::Mask, |
| 1189 | KMemoryAttribute::None, KMemoryAttribute::IpcAndDeviceMapped)); | 1189 | KMemoryAttribute::None, KMemoryAttribute::IpcAndDeviceMapped)); |
| 1190 | 1190 | ||
| 1191 | KPageLinkedList src_pages; | 1191 | KPageGroup src_pages; |
| 1192 | KPageLinkedList dst_pages; | 1192 | KPageGroup dst_pages; |
| 1193 | const std::size_t num_pages{size / PageSize}; | 1193 | const std::size_t num_pages{size / PageSize}; |
| 1194 | 1194 | ||
| 1195 | AddRegionToPages(src_addr, num_pages, src_pages); | 1195 | AddRegionToPages(src_addr, num_pages, src_pages); |
| @@ -1215,8 +1215,8 @@ ResultCode KPageTable::UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t s | |||
| 1215 | return ResultSuccess; | 1215 | return ResultSuccess; |
| 1216 | } | 1216 | } |
| 1217 | 1217 | ||
| 1218 | ResultCode KPageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_list, | 1218 | Result KPageTable::MapPages(VAddr addr, const KPageGroup& page_linked_list, |
| 1219 | KMemoryPermission perm) { | 1219 | KMemoryPermission perm) { |
| 1220 | ASSERT(this->IsLockedByCurrentThread()); | 1220 | ASSERT(this->IsLockedByCurrentThread()); |
| 1221 | 1221 | ||
| 1222 | VAddr cur_addr{addr}; | 1222 | VAddr cur_addr{addr}; |
| @@ -1239,8 +1239,8 @@ ResultCode KPageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_l | |||
| 1239 | return ResultSuccess; | 1239 | return ResultSuccess; |
| 1240 | } | 1240 | } |
| 1241 | 1241 | ||
| 1242 | ResultCode KPageTable::MapPages(VAddr address, KPageLinkedList& page_linked_list, | 1242 | Result KPageTable::MapPages(VAddr address, KPageGroup& page_linked_list, KMemoryState state, |
| 1243 | KMemoryState state, KMemoryPermission perm) { | 1243 | KMemoryPermission perm) { |
| 1244 | // Check that the map is in range. | 1244 | // Check that the map is in range. |
| 1245 | const std::size_t num_pages{page_linked_list.GetNumPages()}; | 1245 | const std::size_t num_pages{page_linked_list.GetNumPages()}; |
| 1246 | const std::size_t size{num_pages * PageSize}; | 1246 | const std::size_t size{num_pages * PageSize}; |
| @@ -1263,10 +1263,10 @@ ResultCode KPageTable::MapPages(VAddr address, KPageLinkedList& page_linked_list | |||
| 1263 | return ResultSuccess; | 1263 | return ResultSuccess; |
| 1264 | } | 1264 | } |
| 1265 | 1265 | ||
| 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 KPageGroup& page_linked_list) { |
| 1307 | ASSERT(this->IsLockedByCurrentThread()); | 1307 | ASSERT(this->IsLockedByCurrentThread()); |
| 1308 | 1308 | ||
| 1309 | VAddr cur_addr{addr}; | 1309 | VAddr cur_addr{addr}; |
| @@ -1321,8 +1321,7 @@ ResultCode KPageTable::UnmapPages(VAddr addr, const KPageLinkedList& page_linked | |||
| 1321 | return ResultSuccess; | 1321 | return ResultSuccess; |
| 1322 | } | 1322 | } |
| 1323 | 1323 | ||
| 1324 | ResultCode KPageTable::UnmapPages(VAddr addr, KPageLinkedList& page_linked_list, | 1324 | Result KPageTable::UnmapPages(VAddr addr, KPageGroup& page_linked_list, KMemoryState state) { |
| 1325 | KMemoryState state) { | ||
| 1326 | // Check that the unmap is in range. | 1325 | // Check that the unmap is in range. |
| 1327 | const std::size_t num_pages{page_linked_list.GetNumPages()}; | 1326 | const std::size_t num_pages{page_linked_list.GetNumPages()}; |
| 1328 | const std::size_t size{num_pages * PageSize}; | 1327 | const std::size_t size{num_pages * PageSize}; |
| @@ -1345,7 +1344,7 @@ ResultCode KPageTable::UnmapPages(VAddr addr, KPageLinkedList& page_linked_list, | |||
| 1345 | return ResultSuccess; | 1344 | return ResultSuccess; |
| 1346 | } | 1345 | } |
| 1347 | 1346 | ||
| 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(KPageGroup* out, VAddr address, size_t num_pages, |
| 1373 | KMemoryState state_mask, KMemoryState state, | 1372 | KMemoryState state_mask, KMemoryState state, |
| 1374 | KMemoryPermission perm_mask, KMemoryPermission perm, | 1373 | KMemoryPermission perm_mask, KMemoryPermission perm, |
| 1375 | KMemoryAttribute attr_mask, KMemoryAttribute attr) { | 1374 | KMemoryAttribute attr_mask, KMemoryAttribute attr) { |
| 1376 | // Ensure that the page group isn't null. | 1375 | // Ensure that the page group isn't null. |
| 1377 | ASSERT(out != nullptr); | 1376 | ASSERT(out != nullptr); |
| 1378 | 1377 | ||
| @@ -1394,8 +1393,8 @@ ResultCode KPageTable::MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address, | |||
| 1394 | return ResultSuccess; | 1393 | return ResultSuccess; |
| 1395 | } | 1394 | } |
| 1396 | 1395 | ||
| 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 | ||
| @@ -1642,7 +1641,7 @@ ResultCode KPageTable::SetHeapSize(VAddr* out, std::size_t size) { | |||
| 1642 | R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached); | 1641 | R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached); |
| 1643 | 1642 | ||
| 1644 | // Allocate pages for the heap extension. | 1643 | // Allocate pages for the heap extension. |
| 1645 | KPageLinkedList pg; | 1644 | KPageGroup pg; |
| 1646 | R_TRY(system.Kernel().MemoryManager().AllocateAndOpen( | 1645 | R_TRY(system.Kernel().MemoryManager().AllocateAndOpen( |
| 1647 | &pg, allocation_size / PageSize, | 1646 | &pg, allocation_size / PageSize, |
| 1648 | KMemoryManager::EncodeOption(memory_pool, allocation_option))); | 1647 | KMemoryManager::EncodeOption(memory_pool, allocation_option))); |
| @@ -1717,7 +1716,7 @@ ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages, | |||
| 1717 | if (is_map_only) { | 1716 | if (is_map_only) { |
| 1718 | R_TRY(Operate(addr, needed_num_pages, perm, OperationType::Map, map_addr)); | 1717 | R_TRY(Operate(addr, needed_num_pages, perm, OperationType::Map, map_addr)); |
| 1719 | } else { | 1718 | } else { |
| 1720 | KPageLinkedList page_group; | 1719 | KPageGroup page_group; |
| 1721 | R_TRY(system.Kernel().MemoryManager().AllocateAndOpenForProcess( | 1720 | R_TRY(system.Kernel().MemoryManager().AllocateAndOpenForProcess( |
| 1722 | &page_group, needed_num_pages, | 1721 | &page_group, needed_num_pages, |
| 1723 | KMemoryManager::EncodeOption(memory_pool, allocation_option), 0, 0)); | 1722 | KMemoryManager::EncodeOption(memory_pool, allocation_option), 0, 0)); |
| @@ -1729,11 +1728,11 @@ ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages, | |||
| 1729 | return addr; | 1728 | return addr; |
| 1730 | } | 1729 | } |
| 1731 | 1730 | ||
| 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(KPageGroup* out, VAddr addr, std::size_t size) { |
| 1779 | return this->LockMemoryAndOpen( | 1778 | return this->LockMemoryAndOpen( |
| 1780 | out, nullptr, addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory, | 1779 | out, nullptr, addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory, |
| 1781 | KMemoryPermission::All, KMemoryPermission::UserReadWrite, KMemoryAttribute::All, | 1780 | KMemoryPermission::All, KMemoryPermission::UserReadWrite, KMemoryAttribute::All, |
| @@ -1785,15 +1784,14 @@ ResultCode KPageTable::LockForCodeMemory(KPageLinkedList* out, VAddr addr, std:: | |||
| 1785 | KMemoryAttribute::Locked); | 1784 | KMemoryAttribute::Locked); |
| 1786 | } | 1785 | } |
| 1787 | 1786 | ||
| 1788 | ResultCode KPageTable::UnlockForCodeMemory(VAddr addr, std::size_t size, | 1787 | Result KPageTable::UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageGroup& pg) { |
| 1789 | const KPageLinkedList& pg) { | ||
| 1790 | return this->UnlockMemory( | 1788 | return this->UnlockMemory( |
| 1791 | addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory, | 1789 | addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory, |
| 1792 | KMemoryPermission::None, KMemoryPermission::None, KMemoryAttribute::All, | 1790 | KMemoryPermission::None, KMemoryPermission::None, KMemoryAttribute::All, |
| 1793 | KMemoryAttribute::Locked, KMemoryPermission::UserReadWrite, KMemoryAttribute::Locked, &pg); | 1791 | KMemoryAttribute::Locked, KMemoryPermission::UserReadWrite, KMemoryAttribute::Locked, &pg); |
| 1794 | } | 1792 | } |
| 1795 | 1793 | ||
| 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; |
| @@ -1818,7 +1816,7 @@ bool KPageTable::IsRegionContiguous(VAddr addr, u64 size) const { | |||
| 1818 | } | 1816 | } |
| 1819 | 1817 | ||
| 1820 | void KPageTable::AddRegionToPages(VAddr start, std::size_t num_pages, | 1818 | void KPageTable::AddRegionToPages(VAddr start, std::size_t num_pages, |
| 1821 | KPageLinkedList& page_linked_list) { | 1819 | KPageGroup& page_linked_list) { |
| 1822 | VAddr addr{start}; | 1820 | VAddr addr{start}; |
| 1823 | while (addr < start + (num_pages * PageSize)) { | 1821 | while (addr < start + (num_pages * PageSize)) { |
| 1824 | const PAddr paddr{GetPhysicalAddr(addr)}; | 1822 | const PAddr paddr{GetPhysicalAddr(addr)}; |
| @@ -1837,8 +1835,8 @@ VAddr KPageTable::AllocateVirtualMemory(VAddr start, std::size_t region_num_page | |||
| 1837 | IsKernel() ? 1 : 4); | 1835 | IsKernel() ? 1 : 4); |
| 1838 | } | 1836 | } |
| 1839 | 1837 | ||
| 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 KPageGroup& page_group, |
| 1841 | OperationType operation) { | 1839 | OperationType operation) { |
| 1842 | ASSERT(this->IsLockedByCurrentThread()); | 1840 | ASSERT(this->IsLockedByCurrentThread()); |
| 1843 | 1841 | ||
| 1844 | ASSERT(Common::IsAligned(addr, PageSize)); | 1842 | ASSERT(Common::IsAligned(addr, PageSize)); |
| @@ -1862,8 +1860,8 @@ ResultCode KPageTable::Operate(VAddr addr, std::size_t num_pages, const KPageLin | |||
| 1862 | return ResultSuccess; | 1860 | return ResultSuccess; |
| 1863 | } | 1861 | } |
| 1864 | 1862 | ||
| 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(KPageGroup* out_pg, PAddr* out_paddr, VAddr addr, size_t size, |
| 2126 | size_t size, KMemoryState state_mask, KMemoryState state, | 2123 | KMemoryState state_mask, KMemoryState state, |
| 2127 | KMemoryPermission perm_mask, KMemoryPermission perm, | 2124 | KMemoryPermission perm_mask, KMemoryPermission perm, |
| 2128 | KMemoryAttribute attr_mask, KMemoryAttribute attr, | 2125 | KMemoryAttribute attr_mask, KMemoryAttribute attr, |
| 2129 | KMemoryPermission new_perm, KMemoryAttribute lock_attr) { | 2126 | KMemoryPermission new_perm, KMemoryAttribute lock_attr) { |
| 2130 | // Validate basic preconditions. | 2127 | // Validate basic preconditions. |
| 2131 | ASSERT((lock_attr & attr) == KMemoryAttribute::None); | 2128 | ASSERT((lock_attr & attr) == KMemoryAttribute::None); |
| 2132 | ASSERT((lock_attr & (KMemoryAttribute::IpcLocked | KMemoryAttribute::DeviceShared)) == | 2129 | ASSERT((lock_attr & (KMemoryAttribute::IpcLocked | KMemoryAttribute::DeviceShared)) == |
| @@ -2180,11 +2177,11 @@ ResultCode KPageTable::LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_pad | |||
| 2180 | return ResultSuccess; | 2177 | return ResultSuccess; |
| 2181 | } | 2178 | } |
| 2182 | 2179 | ||
| 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 KPageGroup* pg) { |
| 2188 | // Validate basic preconditions. | 2185 | // Validate basic preconditions. |
| 2189 | ASSERT((attr_mask & lock_attr) == lock_attr); | 2186 | ASSERT((attr_mask & lock_attr) == lock_attr); |
| 2190 | ASSERT((attr & lock_attr) == lock_attr); | 2187 | ASSERT((attr & lock_attr) == lock_attr); |
diff --git a/src/core/hle/kernel/k_page_table.h b/src/core/hle/kernel/k_page_table.h index 6312eb682..25774f232 100644 --- a/src/core/hle/kernel/k_page_table.h +++ b/src/core/hle/kernel/k_page_table.h | |||
| @@ -33,51 +33,49 @@ public: | |||
| 33 | explicit KPageTable(Core::System& system_); | 33 | explicit KPageTable(Core::System& system_); |
| 34 | ~KPageTable(); | 34 | ~KPageTable(); |
| 35 | 35 | ||
| 36 | ResultCode InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, bool enable_aslr, | 36 | Result InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, bool enable_aslr, |
| 37 | VAddr code_addr, std::size_t code_size, | 37 | VAddr code_addr, std::size_t code_size, KMemoryManager::Pool pool); |
| 38 | KMemoryManager::Pool pool); | 38 | Result MapProcessCode(VAddr addr, std::size_t pages_count, KMemoryState state, |
| 39 | ResultCode MapProcessCode(VAddr addr, std::size_t pages_count, KMemoryState state, | 39 | KMemoryPermission perm); |
| 40 | KMemoryPermission perm); | 40 | Result MapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size); |
| 41 | ResultCode MapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size); | 41 | Result UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size, |
| 42 | ResultCode UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size, | 42 | ICacheInvalidationStrategy icache_invalidation_strategy); |
| 43 | ICacheInvalidationStrategy icache_invalidation_strategy); | 43 | Result UnmapProcessMemory(VAddr dst_addr, std::size_t size, KPageTable& src_page_table, |
| 44 | ResultCode UnmapProcessMemory(VAddr dst_addr, std::size_t size, KPageTable& src_page_table, | 44 | VAddr src_addr); |
| 45 | VAddr src_addr); | 45 | Result MapPhysicalMemory(VAddr addr, std::size_t size); |
| 46 | ResultCode MapPhysicalMemory(VAddr addr, std::size_t size); | 46 | Result UnmapPhysicalMemory(VAddr addr, std::size_t size); |
| 47 | ResultCode UnmapPhysicalMemory(VAddr addr, std::size_t size); | 47 | Result MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); |
| 48 | ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); | 48 | Result UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); |
| 49 | ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); | 49 | Result MapPages(VAddr addr, KPageGroup& page_linked_list, KMemoryState state, |
| 50 | ResultCode MapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state, | 50 | KMemoryPermission perm); |
| 51 | KMemoryPermission perm); | 51 | Result MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, PAddr phys_addr, |
| 52 | ResultCode MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, | 52 | KMemoryState state, KMemoryPermission perm) { |
| 53 | PAddr phys_addr, KMemoryState state, KMemoryPermission perm) { | ||
| 54 | return this->MapPages(out_addr, num_pages, alignment, phys_addr, true, | 53 | return this->MapPages(out_addr, num_pages, alignment, phys_addr, true, |
| 55 | this->GetRegionAddress(state), this->GetRegionSize(state) / PageSize, | 54 | this->GetRegionAddress(state), this->GetRegionSize(state) / PageSize, |
| 56 | state, perm); | 55 | state, perm); |
| 57 | } | 56 | } |
| 58 | ResultCode UnmapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state); | 57 | Result UnmapPages(VAddr addr, KPageGroup& page_linked_list, KMemoryState state); |
| 59 | ResultCode UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state); | 58 | Result UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state); |
| 60 | ResultCode SetProcessMemoryPermission(VAddr addr, std::size_t size, | 59 | Result SetProcessMemoryPermission(VAddr addr, std::size_t size, Svc::MemoryPermission svc_perm); |
| 61 | Svc::MemoryPermission svc_perm); | ||
| 62 | KMemoryInfo QueryInfo(VAddr addr); | 60 | KMemoryInfo QueryInfo(VAddr addr); |
| 63 | ResultCode ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm); | 61 | Result ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm); |
| 64 | ResultCode ResetTransferMemory(VAddr addr, std::size_t size); | 62 | Result ResetTransferMemory(VAddr addr, std::size_t size); |
| 65 | ResultCode SetMemoryPermission(VAddr addr, std::size_t size, Svc::MemoryPermission perm); | 63 | Result SetMemoryPermission(VAddr addr, std::size_t size, Svc::MemoryPermission perm); |
| 66 | ResultCode SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask, u32 attr); | 64 | Result SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask, u32 attr); |
| 67 | ResultCode SetMaxHeapSize(std::size_t size); | 65 | Result SetMaxHeapSize(std::size_t size); |
| 68 | ResultCode SetHeapSize(VAddr* out, std::size_t size); | 66 | Result SetHeapSize(VAddr* out, std::size_t size); |
| 69 | ResultVal<VAddr> AllocateAndMapMemory(std::size_t needed_num_pages, std::size_t align, | 67 | ResultVal<VAddr> AllocateAndMapMemory(std::size_t needed_num_pages, std::size_t align, |
| 70 | bool is_map_only, VAddr region_start, | 68 | bool is_map_only, VAddr region_start, |
| 71 | std::size_t region_num_pages, KMemoryState state, | 69 | std::size_t region_num_pages, KMemoryState state, |
| 72 | KMemoryPermission perm, PAddr map_addr = 0); | 70 | KMemoryPermission perm, PAddr map_addr = 0); |
| 73 | ResultCode LockForDeviceAddressSpace(VAddr addr, std::size_t size); | 71 | Result LockForDeviceAddressSpace(VAddr addr, std::size_t size); |
| 74 | ResultCode UnlockForDeviceAddressSpace(VAddr addr, std::size_t size); | 72 | Result UnlockForDeviceAddressSpace(VAddr addr, std::size_t size); |
| 75 | ResultCode LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::size_t size); | 73 | Result LockForCodeMemory(KPageGroup* out, VAddr addr, std::size_t size); |
| 76 | ResultCode UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageLinkedList& pg); | 74 | Result UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageGroup& pg); |
| 77 | ResultCode MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address, size_t num_pages, | 75 | Result MakeAndOpenPageGroup(KPageGroup* out, VAddr address, size_t num_pages, |
| 78 | KMemoryState state_mask, KMemoryState state, | 76 | KMemoryState state_mask, KMemoryState state, |
| 79 | KMemoryPermission perm_mask, KMemoryPermission perm, | 77 | KMemoryPermission perm_mask, KMemoryPermission perm, |
| 80 | KMemoryAttribute attr_mask, KMemoryAttribute attr); | 78 | KMemoryAttribute attr_mask, KMemoryAttribute attr); |
| 81 | 79 | ||
| 82 | Common::PageTable& PageTableImpl() { | 80 | Common::PageTable& PageTableImpl() { |
| 83 | return page_table_impl; | 81 | return page_table_impl; |
| @@ -102,83 +100,78 @@ private: | |||
| 102 | KMemoryAttribute::IpcLocked | | 100 | KMemoryAttribute::IpcLocked | |
| 103 | KMemoryAttribute::DeviceShared; | 101 | KMemoryAttribute::DeviceShared; |
| 104 | 102 | ||
| 105 | ResultCode InitializeMemoryLayout(VAddr start, VAddr end); | 103 | Result InitializeMemoryLayout(VAddr start, VAddr end); |
| 106 | ResultCode MapPages(VAddr addr, const KPageLinkedList& page_linked_list, | 104 | Result MapPages(VAddr addr, const KPageGroup& page_linked_list, KMemoryPermission perm); |
| 107 | KMemoryPermission perm); | 105 | Result MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, PAddr phys_addr, |
| 108 | ResultCode MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, | 106 | bool is_pa_valid, VAddr region_start, std::size_t region_num_pages, |
| 109 | PAddr phys_addr, bool is_pa_valid, VAddr region_start, | 107 | KMemoryState state, KMemoryPermission perm); |
| 110 | std::size_t region_num_pages, KMemoryState state, KMemoryPermission perm); | 108 | Result UnmapPages(VAddr addr, const KPageGroup& page_linked_list); |
| 111 | ResultCode UnmapPages(VAddr addr, const KPageLinkedList& page_linked_list); | ||
| 112 | bool IsRegionMapped(VAddr address, u64 size); | 109 | bool IsRegionMapped(VAddr address, u64 size); |
| 113 | bool IsRegionContiguous(VAddr addr, u64 size) const; | 110 | bool IsRegionContiguous(VAddr addr, u64 size) const; |
| 114 | void AddRegionToPages(VAddr start, std::size_t num_pages, KPageLinkedList& page_linked_list); | 111 | void AddRegionToPages(VAddr start, std::size_t num_pages, KPageGroup& page_linked_list); |
| 115 | KMemoryInfo QueryInfoImpl(VAddr addr); | 112 | KMemoryInfo QueryInfoImpl(VAddr addr); |
| 116 | VAddr AllocateVirtualMemory(VAddr start, std::size_t region_num_pages, u64 needed_num_pages, | 113 | VAddr AllocateVirtualMemory(VAddr start, std::size_t region_num_pages, u64 needed_num_pages, |
| 117 | std::size_t align); | 114 | std::size_t align); |
| 118 | ResultCode Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& page_group, | 115 | Result Operate(VAddr addr, std::size_t num_pages, const KPageGroup& page_group, |
| 119 | OperationType operation); | 116 | OperationType operation); |
| 120 | ResultCode Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm, | 117 | Result Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm, |
| 121 | OperationType operation, PAddr map_addr = 0); | 118 | OperationType operation, PAddr map_addr = 0); |
| 122 | VAddr GetRegionAddress(KMemoryState state) const; | 119 | VAddr GetRegionAddress(KMemoryState state) const; |
| 123 | std::size_t GetRegionSize(KMemoryState state) const; | 120 | std::size_t GetRegionSize(KMemoryState state) const; |
| 124 | 121 | ||
| 125 | VAddr FindFreeArea(VAddr region_start, std::size_t region_num_pages, std::size_t num_pages, | 122 | VAddr FindFreeArea(VAddr region_start, std::size_t region_num_pages, std::size_t num_pages, |
| 126 | std::size_t alignment, std::size_t offset, std::size_t guard_pages); | 123 | std::size_t alignment, std::size_t offset, std::size_t guard_pages); |
| 127 | 124 | ||
| 128 | ResultCode CheckMemoryStateContiguous(std::size_t* out_blocks_needed, VAddr addr, | 125 | Result CheckMemoryStateContiguous(std::size_t* out_blocks_needed, VAddr addr, std::size_t size, |
| 129 | std::size_t size, KMemoryState state_mask, | 126 | KMemoryState state_mask, KMemoryState state, |
| 130 | KMemoryState state, KMemoryPermission perm_mask, | 127 | KMemoryPermission perm_mask, KMemoryPermission perm, |
| 131 | KMemoryPermission perm, KMemoryAttribute attr_mask, | 128 | KMemoryAttribute attr_mask, KMemoryAttribute attr) const; |
| 132 | KMemoryAttribute attr) const; | 129 | Result CheckMemoryStateContiguous(VAddr addr, std::size_t size, KMemoryState state_mask, |
| 133 | ResultCode CheckMemoryStateContiguous(VAddr addr, std::size_t size, KMemoryState state_mask, | 130 | KMemoryState state, KMemoryPermission perm_mask, |
| 134 | KMemoryState state, KMemoryPermission perm_mask, | 131 | KMemoryPermission perm, KMemoryAttribute attr_mask, |
| 135 | KMemoryPermission perm, KMemoryAttribute attr_mask, | 132 | KMemoryAttribute attr) const { |
| 136 | KMemoryAttribute attr) const { | ||
| 137 | return this->CheckMemoryStateContiguous(nullptr, addr, size, state_mask, state, perm_mask, | 133 | return this->CheckMemoryStateContiguous(nullptr, addr, size, state_mask, state, perm_mask, |
| 138 | perm, attr_mask, attr); | 134 | perm, attr_mask, attr); |
| 139 | } | 135 | } |
| 140 | 136 | ||
| 141 | ResultCode CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask, | 137 | Result CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask, KMemoryState state, |
| 142 | KMemoryState state, KMemoryPermission perm_mask, | 138 | KMemoryPermission perm_mask, KMemoryPermission perm, |
| 143 | KMemoryPermission perm, KMemoryAttribute attr_mask, | 139 | KMemoryAttribute attr_mask, KMemoryAttribute attr) const; |
| 144 | KMemoryAttribute attr) const; | 140 | Result CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm, |
| 145 | ResultCode CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm, | 141 | KMemoryAttribute* out_attr, std::size_t* out_blocks_needed, VAddr addr, |
| 146 | KMemoryAttribute* out_attr, std::size_t* out_blocks_needed, | 142 | std::size_t size, KMemoryState state_mask, KMemoryState state, |
| 147 | VAddr addr, std::size_t size, KMemoryState state_mask, | 143 | KMemoryPermission perm_mask, KMemoryPermission perm, |
| 148 | KMemoryState state, KMemoryPermission perm_mask, | 144 | KMemoryAttribute attr_mask, KMemoryAttribute attr, |
| 149 | KMemoryPermission perm, KMemoryAttribute attr_mask, | 145 | KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const; |
| 150 | KMemoryAttribute attr, | 146 | Result CheckMemoryState(std::size_t* out_blocks_needed, VAddr addr, std::size_t size, |
| 151 | KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const; | 147 | KMemoryState state_mask, KMemoryState state, |
| 152 | ResultCode CheckMemoryState(std::size_t* out_blocks_needed, VAddr addr, std::size_t size, | 148 | KMemoryPermission perm_mask, KMemoryPermission perm, |
| 153 | KMemoryState state_mask, KMemoryState state, | 149 | KMemoryAttribute attr_mask, KMemoryAttribute attr, |
| 154 | KMemoryPermission perm_mask, KMemoryPermission perm, | 150 | KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const { |
| 155 | KMemoryAttribute attr_mask, KMemoryAttribute attr, | ||
| 156 | KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const { | ||
| 157 | return CheckMemoryState(nullptr, nullptr, nullptr, out_blocks_needed, addr, size, | 151 | return CheckMemoryState(nullptr, nullptr, nullptr, out_blocks_needed, addr, size, |
| 158 | state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr); | 152 | state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr); |
| 159 | } | 153 | } |
| 160 | ResultCode CheckMemoryState(VAddr addr, std::size_t size, KMemoryState state_mask, | 154 | Result CheckMemoryState(VAddr addr, std::size_t size, KMemoryState state_mask, |
| 161 | KMemoryState state, KMemoryPermission perm_mask, | 155 | KMemoryState state, KMemoryPermission perm_mask, KMemoryPermission perm, |
| 162 | KMemoryPermission perm, KMemoryAttribute attr_mask, | 156 | KMemoryAttribute attr_mask, KMemoryAttribute attr, |
| 163 | KMemoryAttribute attr, | 157 | KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const { |
| 164 | KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const { | ||
| 165 | return this->CheckMemoryState(nullptr, addr, size, state_mask, state, perm_mask, perm, | 158 | return this->CheckMemoryState(nullptr, addr, size, state_mask, state, perm_mask, perm, |
| 166 | attr_mask, attr, ignore_attr); | 159 | attr_mask, attr, ignore_attr); |
| 167 | } | 160 | } |
| 168 | 161 | ||
| 169 | ResultCode LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_paddr, VAddr addr, size_t size, | 162 | Result LockMemoryAndOpen(KPageGroup* out_pg, PAddr* out_paddr, VAddr addr, size_t size, |
| 170 | KMemoryState state_mask, KMemoryState state, | 163 | KMemoryState state_mask, KMemoryState state, |
| 171 | KMemoryPermission perm_mask, KMemoryPermission perm, | 164 | KMemoryPermission perm_mask, KMemoryPermission perm, |
| 172 | KMemoryAttribute attr_mask, KMemoryAttribute attr, | 165 | KMemoryAttribute attr_mask, KMemoryAttribute attr, |
| 173 | KMemoryPermission new_perm, KMemoryAttribute lock_attr); | 166 | KMemoryPermission new_perm, KMemoryAttribute lock_attr); |
| 174 | ResultCode UnlockMemory(VAddr addr, size_t size, KMemoryState state_mask, KMemoryState state, | 167 | Result UnlockMemory(VAddr addr, size_t size, KMemoryState state_mask, KMemoryState state, |
| 175 | KMemoryPermission perm_mask, KMemoryPermission perm, | 168 | KMemoryPermission perm_mask, KMemoryPermission perm, |
| 176 | KMemoryAttribute attr_mask, KMemoryAttribute attr, | 169 | KMemoryAttribute attr_mask, KMemoryAttribute attr, |
| 177 | KMemoryPermission new_perm, KMemoryAttribute lock_attr, | 170 | KMemoryPermission new_perm, KMemoryAttribute lock_attr, |
| 178 | const KPageLinkedList* pg); | 171 | const KPageGroup* pg); |
| 179 | 172 | ||
| 180 | ResultCode MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pages); | 173 | Result MakePageGroup(KPageGroup& pg, VAddr addr, size_t num_pages); |
| 181 | bool IsValidPageGroup(const KPageLinkedList& pg, VAddr addr, size_t num_pages); | 174 | bool IsValidPageGroup(const KPageGroup& pg, VAddr addr, size_t num_pages); |
| 182 | 175 | ||
| 183 | bool IsLockedByCurrentThread() const { | 176 | bool IsLockedByCurrentThread() const { |
| 184 | return general_lock.IsLockedByCurrentThread(); | 177 | return general_lock.IsLockedByCurrentThread(); |
diff --git a/src/core/hle/kernel/k_port.cpp b/src/core/hle/kernel/k_port.cpp index 51c2cd1ef..7a5a9dc2a 100644 --- a/src/core/hle/kernel/k_port.cpp +++ b/src/core/hle/kernel/k_port.cpp | |||
| @@ -50,7 +50,7 @@ bool KPort::IsServerClosed() const { | |||
| 50 | return state == State::ServerClosed; | 50 | return state == State::ServerClosed; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 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..b77735736 100644 --- a/src/core/hle/kernel/k_shared_memory.cpp +++ b/src/core/hle/kernel/k_shared_memory.cpp | |||
| @@ -18,12 +18,10 @@ KSharedMemory::~KSharedMemory() { | |||
| 18 | kernel.GetSystemResourceLimit()->Release(LimitableResource::PhysicalMemory, size); | 18 | kernel.GetSystemResourceLimit()->Release(LimitableResource::PhysicalMemory, size); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 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 | KPageGroup&& page_list_, Svc::MemoryPermission owner_permission_, |
| 23 | Svc::MemoryPermission owner_permission_, | 23 | Svc::MemoryPermission user_permission_, PAddr physical_address_, |
| 24 | Svc::MemoryPermission user_permission_, | 24 | std::size_t size_, std::string name_) { |
| 25 | PAddr physical_address_, std::size_t size_, | ||
| 26 | std::string name_) { | ||
| 27 | // Set members. | 25 | // Set members. |
| 28 | owner_process = owner_process_; | 26 | owner_process = owner_process_; |
| 29 | device_memory = &device_memory_; | 27 | device_memory = &device_memory_; |
| @@ -67,8 +65,8 @@ void KSharedMemory::Finalize() { | |||
| 67 | KAutoObjectWithSlabHeapAndContainer<KSharedMemory, KAutoObjectWithList>::Finalize(); | 65 | KAutoObjectWithSlabHeapAndContainer<KSharedMemory, KAutoObjectWithList>::Finalize(); |
| 68 | } | 66 | } |
| 69 | 67 | ||
| 70 | ResultCode KSharedMemory::Map(KProcess& target_process, VAddr address, std::size_t map_size, | 68 | Result KSharedMemory::Map(KProcess& target_process, VAddr address, std::size_t map_size, |
| 71 | Svc::MemoryPermission permissions) { | 69 | Svc::MemoryPermission permissions) { |
| 72 | const u64 page_count{(map_size + PageSize - 1) / PageSize}; | 70 | const u64 page_count{(map_size + PageSize - 1) / PageSize}; |
| 73 | 71 | ||
| 74 | if (page_list.GetNumPages() != page_count) { | 72 | if (page_list.GetNumPages() != page_count) { |
| @@ -86,7 +84,7 @@ ResultCode KSharedMemory::Map(KProcess& target_process, VAddr address, std::size | |||
| 86 | ConvertToKMemoryPermission(permissions)); | 84 | ConvertToKMemoryPermission(permissions)); |
| 87 | } | 85 | } |
| 88 | 86 | ||
| 89 | ResultCode KSharedMemory::Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size) { | 87 | Result KSharedMemory::Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size) { |
| 90 | const u64 page_count{(unmap_size + PageSize - 1) / PageSize}; | 88 | const u64 page_count{(unmap_size + PageSize - 1) / PageSize}; |
| 91 | 89 | ||
| 92 | if (page_list.GetNumPages() != page_count) { | 90 | if (page_list.GetNumPages() != page_count) { |
diff --git a/src/core/hle/kernel/k_shared_memory.h b/src/core/hle/kernel/k_shared_memory.h index 81de36136..2c1db0e70 100644 --- a/src/core/hle/kernel/k_shared_memory.h +++ b/src/core/hle/kernel/k_shared_memory.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "core/device_memory.h" | 10 | #include "core/device_memory.h" |
| 11 | #include "core/hle/kernel/k_memory_block.h" | 11 | #include "core/hle/kernel/k_memory_block.h" |
| 12 | #include "core/hle/kernel/k_page_linked_list.h" | 12 | #include "core/hle/kernel/k_page_group.h" |
| 13 | #include "core/hle/kernel/k_process.h" | 13 | #include "core/hle/kernel/k_process.h" |
| 14 | #include "core/hle/kernel/slab_helpers.h" | 14 | #include "core/hle/kernel/slab_helpers.h" |
| 15 | #include "core/hle/result.h" | 15 | #include "core/hle/result.h" |
| @@ -26,10 +26,10 @@ public: | |||
| 26 | explicit KSharedMemory(KernelCore& kernel_); | 26 | explicit KSharedMemory(KernelCore& kernel_); |
| 27 | ~KSharedMemory() override; | 27 | ~KSharedMemory() override; |
| 28 | 28 | ||
| 29 | ResultCode Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_, | 29 | Result Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_, |
| 30 | KPageLinkedList&& page_list_, Svc::MemoryPermission owner_permission_, | 30 | KPageGroup&& page_list_, Svc::MemoryPermission owner_permission_, |
| 31 | Svc::MemoryPermission user_permission_, PAddr physical_address_, | 31 | Svc::MemoryPermission user_permission_, PAddr physical_address_, |
| 32 | std::size_t size_, std::string name_); | 32 | std::size_t size_, std::string name_); |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| 35 | * Maps a shared memory block to an address in the target process' address space | 35 | * Maps a shared memory block to an address in the target process' address space |
| @@ -38,8 +38,8 @@ public: | |||
| 38 | * @param map_size Size of the shared memory block to map | 38 | * @param map_size Size of the shared memory block to map |
| 39 | * @param permissions Memory block map permissions (specified by SVC field) | 39 | * @param permissions Memory block map permissions (specified by SVC field) |
| 40 | */ | 40 | */ |
| 41 | ResultCode Map(KProcess& target_process, VAddr address, std::size_t map_size, | 41 | Result Map(KProcess& target_process, VAddr address, std::size_t map_size, |
| 42 | Svc::MemoryPermission permissions); | 42 | Svc::MemoryPermission permissions); |
| 43 | 43 | ||
| 44 | /** | 44 | /** |
| 45 | * Unmaps a shared memory block from an address in the target process' address space | 45 | * Unmaps a shared memory block from an address in the target process' address space |
| @@ -47,7 +47,7 @@ public: | |||
| 47 | * @param address Address in system memory to unmap shared memory block | 47 | * @param address Address in system memory to unmap shared memory block |
| 48 | * @param unmap_size Size of the shared memory block to unmap | 48 | * @param unmap_size Size of the shared memory block to unmap |
| 49 | */ | 49 | */ |
| 50 | ResultCode Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size); | 50 | Result Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size); |
| 51 | 51 | ||
| 52 | /** | 52 | /** |
| 53 | * Gets a pointer to the shared memory block | 53 | * Gets a pointer to the shared memory block |
| @@ -77,7 +77,7 @@ public: | |||
| 77 | private: | 77 | private: |
| 78 | Core::DeviceMemory* device_memory; | 78 | Core::DeviceMemory* device_memory; |
| 79 | KProcess* owner_process{}; | 79 | KProcess* owner_process{}; |
| 80 | KPageLinkedList page_list; | 80 | KPageGroup page_list; |
| 81 | Svc::MemoryPermission owner_permission{}; | 81 | Svc::MemoryPermission owner_permission{}; |
| 82 | Svc::MemoryPermission user_permission{}; | 82 | Svc::MemoryPermission user_permission{}; |
| 83 | PAddr physical_address{}; | 83 | PAddr physical_address{}; |
diff --git a/src/core/hle/kernel/k_synchronization_object.cpp b/src/core/hle/kernel/k_synchronization_object.cpp index 8554144d5..802dca046 100644 --- a/src/core/hle/kernel/k_synchronization_object.cpp +++ b/src/core/hle/kernel/k_synchronization_object.cpp | |||
| @@ -22,7 +22,7 @@ public: | |||
| 22 | : KThreadQueueWithoutEndWait(kernel_), m_objects(o), m_nodes(n), m_count(c) {} | 22 | : KThreadQueueWithoutEndWait(kernel_), m_objects(o), m_nodes(n), m_count(c) {} |
| 23 | 23 | ||
| 24 | void NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object, | 24 | void NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object, |
| 25 | ResultCode wait_result) override { | 25 | Result wait_result) override { |
| 26 | // Determine the sync index, and unlink all nodes. | 26 | // Determine the sync index, and unlink all nodes. |
| 27 | s32 sync_index = -1; | 27 | s32 sync_index = -1; |
| 28 | for (auto i = 0; i < m_count; ++i) { | 28 | for (auto i = 0; i < m_count; ++i) { |
| @@ -45,8 +45,7 @@ public: | |||
| 45 | KThreadQueue::EndWait(waiting_thread, wait_result); | 45 | KThreadQueue::EndWait(waiting_thread, wait_result); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | void CancelWait(KThread* waiting_thread, ResultCode wait_result, | 48 | void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override { |
| 49 | bool cancel_timer_task) override { | ||
| 50 | // Remove all nodes from our list. | 49 | // Remove all nodes from our list. |
| 51 | for (auto i = 0; i < m_count; ++i) { | 50 | for (auto i = 0; i < m_count; ++i) { |
| 52 | m_objects[i]->UnlinkNode(std::addressof(m_nodes[i])); | 51 | m_objects[i]->UnlinkNode(std::addressof(m_nodes[i])); |
| @@ -72,9 +71,9 @@ void KSynchronizationObject::Finalize() { | |||
| 72 | KAutoObject::Finalize(); | 71 | KAutoObject::Finalize(); |
| 73 | } | 72 | } |
| 74 | 73 | ||
| 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 71ed17790..8655506b0 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -58,8 +58,8 @@ constexpr bool IsValidAddressRange(VAddr address, u64 size) { | |||
| 58 | // Helper function that performs the common sanity checks for svcMapMemory | 58 | // Helper function that performs the common sanity checks for svcMapMemory |
| 59 | // and svcUnmapMemory. This is doable, as both functions perform their sanitizing | 59 | // and svcUnmapMemory. This is doable, as both functions perform their sanitizing |
| 60 | // in the same order. | 60 | // in the same order. |
| 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 | ||
| @@ -943,12 +941,12 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle | |||
| 943 | } | 941 | } |
| 944 | } | 942 | } |
| 945 | 943 | ||
| 946 | static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low, | 944 | static Result GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low, |
| 947 | u32 info_id, u32 handle, u32 sub_id_high) { | 945 | u32 info_id, u32 handle, u32 sub_id_high) { |
| 948 | const u64 sub_id{u64{sub_id_low} | (u64{sub_id_high} << 32)}; | 946 | const u64 sub_id{u64{sub_id_low} | (u64{sub_id_high} << 32)}; |
| 949 | u64 res_value{}; | 947 | u64 res_value{}; |
| 950 | 948 | ||
| 951 | const ResultCode result{GetInfo(system, &res_value, info_id, handle, sub_id)}; | 949 | const Result result{GetInfo(system, &res_value, info_id, handle, sub_id)}; |
| 952 | *result_high = static_cast<u32>(res_value >> 32); | 950 | *result_high = static_cast<u32>(res_value >> 32); |
| 953 | *result_low = static_cast<u32>(res_value & std::numeric_limits<u32>::max()); | 951 | *result_low = static_cast<u32>(res_value & std::numeric_limits<u32>::max()); |
| 954 | 952 | ||
| @@ -956,7 +954,7 @@ static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_h | |||
| 956 | } | 954 | } |
| 957 | 955 | ||
| 958 | /// Maps memory at a desired address | 956 | /// Maps memory at a desired address |
| 959 | static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { | 957 | static Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { |
| 960 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); | 958 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); |
| 961 | 959 | ||
| 962 | if (!Common::Is4KBAligned(addr)) { | 960 | if (!Common::Is4KBAligned(addr)) { |
| @@ -1004,12 +1002,12 @@ static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) | |||
| 1004 | return page_table.MapPhysicalMemory(addr, size); | 1002 | return page_table.MapPhysicalMemory(addr, size); |
| 1005 | } | 1003 | } |
| 1006 | 1004 | ||
| 1007 | static ResultCode MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { | 1005 | static Result MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { |
| 1008 | return MapPhysicalMemory(system, addr, size); | 1006 | return MapPhysicalMemory(system, addr, size); |
| 1009 | } | 1007 | } |
| 1010 | 1008 | ||
| 1011 | /// Unmaps memory previously mapped via MapPhysicalMemory | 1009 | /// Unmaps memory previously mapped via MapPhysicalMemory |
| 1012 | static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { | 1010 | static Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { |
| 1013 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); | 1011 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); |
| 1014 | 1012 | ||
| 1015 | if (!Common::Is4KBAligned(addr)) { | 1013 | if (!Common::Is4KBAligned(addr)) { |
| @@ -1057,13 +1055,13 @@ static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size | |||
| 1057 | return page_table.UnmapPhysicalMemory(addr, size); | 1055 | return page_table.UnmapPhysicalMemory(addr, size); |
| 1058 | } | 1056 | } |
| 1059 | 1057 | ||
| 1060 | static ResultCode UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { | 1058 | static Result UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { |
| 1061 | return UnmapPhysicalMemory(system, addr, size); | 1059 | return UnmapPhysicalMemory(system, addr, size); |
| 1062 | } | 1060 | } |
| 1063 | 1061 | ||
| 1064 | /// Sets the thread activity | 1062 | /// Sets the thread activity |
| 1065 | static ResultCode SetThreadActivity(Core::System& system, Handle thread_handle, | 1063 | static Result SetThreadActivity(Core::System& system, Handle thread_handle, |
| 1066 | ThreadActivity thread_activity) { | 1064 | ThreadActivity thread_activity) { |
| 1067 | LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", thread_handle, | 1065 | LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", thread_handle, |
| 1068 | thread_activity); | 1066 | thread_activity); |
| 1069 | 1067 | ||
| @@ -1088,13 +1086,13 @@ static ResultCode SetThreadActivity(Core::System& system, Handle thread_handle, | |||
| 1088 | return ResultSuccess; | 1086 | return ResultSuccess; |
| 1089 | } | 1087 | } |
| 1090 | 1088 | ||
| 1091 | static ResultCode SetThreadActivity32(Core::System& system, Handle thread_handle, | 1089 | static Result SetThreadActivity32(Core::System& system, Handle thread_handle, |
| 1092 | Svc::ThreadActivity thread_activity) { | 1090 | Svc::ThreadActivity thread_activity) { |
| 1093 | return SetThreadActivity(system, thread_handle, thread_activity); | 1091 | return SetThreadActivity(system, thread_handle, thread_activity); |
| 1094 | } | 1092 | } |
| 1095 | 1093 | ||
| 1096 | /// Gets the thread context | 1094 | /// Gets the thread context |
| 1097 | static ResultCode GetThreadContext(Core::System& system, VAddr out_context, Handle thread_handle) { | 1095 | static Result GetThreadContext(Core::System& system, VAddr out_context, Handle thread_handle) { |
| 1098 | LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context, | 1096 | LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context, |
| 1099 | thread_handle); | 1097 | thread_handle); |
| 1100 | 1098 | ||
| @@ -1151,12 +1149,12 @@ static ResultCode GetThreadContext(Core::System& system, VAddr out_context, Hand | |||
| 1151 | return ResultSuccess; | 1149 | return ResultSuccess; |
| 1152 | } | 1150 | } |
| 1153 | 1151 | ||
| 1154 | static ResultCode GetThreadContext32(Core::System& system, u32 out_context, Handle thread_handle) { | 1152 | static Result GetThreadContext32(Core::System& system, u32 out_context, Handle thread_handle) { |
| 1155 | return GetThreadContext(system, out_context, thread_handle); | 1153 | return GetThreadContext(system, out_context, thread_handle); |
| 1156 | } | 1154 | } |
| 1157 | 1155 | ||
| 1158 | /// Gets the priority for the specified thread | 1156 | /// Gets the priority for the specified thread |
| 1159 | static ResultCode GetThreadPriority(Core::System& system, u32* out_priority, Handle handle) { | 1157 | static Result GetThreadPriority(Core::System& system, u32* out_priority, Handle handle) { |
| 1160 | LOG_TRACE(Kernel_SVC, "called"); | 1158 | LOG_TRACE(Kernel_SVC, "called"); |
| 1161 | 1159 | ||
| 1162 | // Get the thread from its handle. | 1160 | // Get the thread from its handle. |
| @@ -1169,12 +1167,12 @@ static ResultCode GetThreadPriority(Core::System& system, u32* out_priority, Han | |||
| 1169 | return ResultSuccess; | 1167 | return ResultSuccess; |
| 1170 | } | 1168 | } |
| 1171 | 1169 | ||
| 1172 | static ResultCode GetThreadPriority32(Core::System& system, u32* out_priority, Handle handle) { | 1170 | static Result GetThreadPriority32(Core::System& system, u32* out_priority, Handle handle) { |
| 1173 | return GetThreadPriority(system, out_priority, handle); | 1171 | return GetThreadPriority(system, out_priority, handle); |
| 1174 | } | 1172 | } |
| 1175 | 1173 | ||
| 1176 | /// Sets the priority for the specified thread | 1174 | /// Sets the priority for the specified thread |
| 1177 | static ResultCode SetThreadPriority(Core::System& system, Handle thread_handle, u32 priority) { | 1175 | static Result SetThreadPriority(Core::System& system, Handle thread_handle, u32 priority) { |
| 1178 | // Get the current process. | 1176 | // Get the current process. |
| 1179 | KProcess& process = *system.Kernel().CurrentProcess(); | 1177 | KProcess& process = *system.Kernel().CurrentProcess(); |
| 1180 | 1178 | ||
| @@ -1192,7 +1190,7 @@ static ResultCode SetThreadPriority(Core::System& system, Handle thread_handle, | |||
| 1192 | return ResultSuccess; | 1190 | return ResultSuccess; |
| 1193 | } | 1191 | } |
| 1194 | 1192 | ||
| 1195 | static ResultCode SetThreadPriority32(Core::System& system, Handle thread_handle, u32 priority) { | 1193 | static Result SetThreadPriority32(Core::System& system, Handle thread_handle, u32 priority) { |
| 1196 | return SetThreadPriority(system, thread_handle, priority); | 1194 | return SetThreadPriority(system, thread_handle, priority); |
| 1197 | } | 1195 | } |
| 1198 | 1196 | ||
| @@ -1252,8 +1250,8 @@ constexpr bool IsValidUnmapFromOwnerCodeMemoryPermission(Svc::MemoryPermission p | |||
| 1252 | 1250 | ||
| 1253 | } // Anonymous namespace | 1251 | } // Anonymous namespace |
| 1254 | 1252 | ||
| 1255 | static ResultCode MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, | 1253 | static Result MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, u64 size, |
| 1256 | u64 size, Svc::MemoryPermission map_perm) { | 1254 | Svc::MemoryPermission map_perm) { |
| 1257 | LOG_TRACE(Kernel_SVC, | 1255 | LOG_TRACE(Kernel_SVC, |
| 1258 | "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", | 1256 | "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", |
| 1259 | shmem_handle, address, size, map_perm); | 1257 | shmem_handle, address, size, map_perm); |
| @@ -1293,13 +1291,13 @@ static ResultCode MapSharedMemory(Core::System& system, Handle shmem_handle, VAd | |||
| 1293 | return ResultSuccess; | 1291 | return ResultSuccess; |
| 1294 | } | 1292 | } |
| 1295 | 1293 | ||
| 1296 | static ResultCode MapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, | 1294 | static Result MapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, u32 size, |
| 1297 | u32 size, Svc::MemoryPermission map_perm) { | 1295 | Svc::MemoryPermission map_perm) { |
| 1298 | return MapSharedMemory(system, shmem_handle, address, size, map_perm); | 1296 | return MapSharedMemory(system, shmem_handle, address, size, map_perm); |
| 1299 | } | 1297 | } |
| 1300 | 1298 | ||
| 1301 | static ResultCode UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, | 1299 | static Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, |
| 1302 | u64 size) { | 1300 | u64 size) { |
| 1303 | // Validate the address/size. | 1301 | // Validate the address/size. |
| 1304 | R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress); | 1302 | R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress); |
| 1305 | R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize); | 1303 | R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize); |
| @@ -1326,13 +1324,13 @@ static ResultCode UnmapSharedMemory(Core::System& system, Handle shmem_handle, V | |||
| 1326 | return ResultSuccess; | 1324 | return ResultSuccess; |
| 1327 | } | 1325 | } |
| 1328 | 1326 | ||
| 1329 | static ResultCode UnmapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, | 1327 | static Result UnmapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, |
| 1330 | u32 size) { | 1328 | u32 size) { |
| 1331 | return UnmapSharedMemory(system, shmem_handle, address, size); | 1329 | return UnmapSharedMemory(system, shmem_handle, address, size); |
| 1332 | } | 1330 | } |
| 1333 | 1331 | ||
| 1334 | static ResultCode SetProcessMemoryPermission(Core::System& system, Handle process_handle, | 1332 | static Result SetProcessMemoryPermission(Core::System& system, Handle process_handle, VAddr address, |
| 1335 | VAddr address, u64 size, Svc::MemoryPermission perm) { | 1333 | u64 size, Svc::MemoryPermission perm) { |
| 1336 | LOG_TRACE(Kernel_SVC, | 1334 | LOG_TRACE(Kernel_SVC, |
| 1337 | "called, process_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", | 1335 | "called, process_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", |
| 1338 | process_handle, address, size, perm); | 1336 | process_handle, address, size, perm); |
| @@ -1361,8 +1359,8 @@ static ResultCode SetProcessMemoryPermission(Core::System& system, Handle proces | |||
| 1361 | return page_table.SetProcessMemoryPermission(address, size, perm); | 1359 | return page_table.SetProcessMemoryPermission(address, size, perm); |
| 1362 | } | 1360 | } |
| 1363 | 1361 | ||
| 1364 | static ResultCode MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, | 1362 | static Result MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, |
| 1365 | VAddr src_address, u64 size) { | 1363 | VAddr src_address, u64 size) { |
| 1366 | LOG_TRACE(Kernel_SVC, | 1364 | LOG_TRACE(Kernel_SVC, |
| 1367 | "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}", | 1365 | "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}", |
| 1368 | dst_address, process_handle, src_address, size); | 1366 | dst_address, process_handle, src_address, size); |
| @@ -1391,7 +1389,7 @@ static ResultCode MapProcessMemory(Core::System& system, VAddr dst_address, Hand | |||
| 1391 | ResultInvalidMemoryRegion); | 1389 | ResultInvalidMemoryRegion); |
| 1392 | 1390 | ||
| 1393 | // Create a new page group. | 1391 | // Create a new page group. |
| 1394 | KPageLinkedList pg; | 1392 | KPageGroup pg; |
| 1395 | R_TRY(src_pt.MakeAndOpenPageGroup( | 1393 | R_TRY(src_pt.MakeAndOpenPageGroup( |
| 1396 | std::addressof(pg), src_address, size / PageSize, KMemoryState::FlagCanMapProcess, | 1394 | std::addressof(pg), src_address, size / PageSize, KMemoryState::FlagCanMapProcess, |
| 1397 | KMemoryState::FlagCanMapProcess, KMemoryPermission::None, KMemoryPermission::None, | 1395 | KMemoryState::FlagCanMapProcess, KMemoryPermission::None, KMemoryPermission::None, |
| @@ -1404,8 +1402,8 @@ static ResultCode MapProcessMemory(Core::System& system, VAddr dst_address, Hand | |||
| 1404 | return ResultSuccess; | 1402 | return ResultSuccess; |
| 1405 | } | 1403 | } |
| 1406 | 1404 | ||
| 1407 | static ResultCode UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, | 1405 | static Result UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, |
| 1408 | VAddr src_address, u64 size) { | 1406 | VAddr src_address, u64 size) { |
| 1409 | LOG_TRACE(Kernel_SVC, | 1407 | LOG_TRACE(Kernel_SVC, |
| 1410 | "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}", | 1408 | "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}", |
| 1411 | dst_address, process_handle, src_address, size); | 1409 | dst_address, process_handle, src_address, size); |
| @@ -1439,7 +1437,7 @@ static ResultCode UnmapProcessMemory(Core::System& system, VAddr dst_address, Ha | |||
| 1439 | return ResultSuccess; | 1437 | return ResultSuccess; |
| 1440 | } | 1438 | } |
| 1441 | 1439 | ||
| 1442 | static ResultCode CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t size) { | 1440 | static Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t size) { |
| 1443 | LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, size=0x{:X}", address, size); | 1441 | LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, size=0x{:X}", address, size); |
| 1444 | 1442 | ||
| 1445 | // Get kernel instance. | 1443 | // Get kernel instance. |
| @@ -1474,12 +1472,12 @@ static ResultCode CreateCodeMemory(Core::System& system, Handle* out, VAddr addr | |||
| 1474 | return ResultSuccess; | 1472 | return ResultSuccess; |
| 1475 | } | 1473 | } |
| 1476 | 1474 | ||
| 1477 | static ResultCode CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size) { | 1475 | static Result CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size) { |
| 1478 | return CreateCodeMemory(system, out, address, size); | 1476 | return CreateCodeMemory(system, out, address, size); |
| 1479 | } | 1477 | } |
| 1480 | 1478 | ||
| 1481 | static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation, | 1479 | static Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation, |
| 1482 | VAddr address, size_t size, Svc::MemoryPermission perm) { | 1480 | VAddr address, size_t size, Svc::MemoryPermission perm) { |
| 1483 | 1481 | ||
| 1484 | LOG_TRACE(Kernel_SVC, | 1482 | LOG_TRACE(Kernel_SVC, |
| 1485 | "called, code_memory_handle=0x{:X}, operation=0x{:X}, address=0x{:X}, size=0x{:X}, " | 1483 | "called, code_memory_handle=0x{:X}, operation=0x{:X}, address=0x{:X}, size=0x{:X}, " |
| @@ -1557,15 +1555,13 @@ static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_han | |||
| 1557 | return ResultSuccess; | 1555 | return ResultSuccess; |
| 1558 | } | 1556 | } |
| 1559 | 1557 | ||
| 1560 | static ResultCode ControlCodeMemory32(Core::System& system, Handle code_memory_handle, | 1558 | static Result ControlCodeMemory32(Core::System& system, Handle code_memory_handle, u32 operation, |
| 1561 | u32 operation, u64 address, u64 size, | 1559 | u64 address, u64 size, Svc::MemoryPermission perm) { |
| 1562 | Svc::MemoryPermission perm) { | ||
| 1563 | return ControlCodeMemory(system, code_memory_handle, operation, address, size, perm); | 1560 | return ControlCodeMemory(system, code_memory_handle, operation, address, size, perm); |
| 1564 | } | 1561 | } |
| 1565 | 1562 | ||
| 1566 | static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address, | 1563 | static Result QueryProcessMemory(Core::System& system, VAddr memory_info_address, |
| 1567 | VAddr page_info_address, Handle process_handle, | 1564 | VAddr page_info_address, Handle process_handle, VAddr address) { |
| 1568 | VAddr address) { | ||
| 1569 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); | 1565 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); |
| 1570 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 1566 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 1571 | KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); | 1567 | KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); |
| @@ -1593,8 +1589,8 @@ static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_add | |||
| 1593 | return ResultSuccess; | 1589 | return ResultSuccess; |
| 1594 | } | 1590 | } |
| 1595 | 1591 | ||
| 1596 | static ResultCode QueryMemory(Core::System& system, VAddr memory_info_address, | 1592 | static Result QueryMemory(Core::System& system, VAddr memory_info_address, VAddr page_info_address, |
| 1597 | VAddr page_info_address, VAddr query_address) { | 1593 | VAddr query_address) { |
| 1598 | LOG_TRACE(Kernel_SVC, | 1594 | LOG_TRACE(Kernel_SVC, |
| 1599 | "called, memory_info_address=0x{:016X}, page_info_address=0x{:016X}, " | 1595 | "called, memory_info_address=0x{:016X}, page_info_address=0x{:016X}, " |
| 1600 | "query_address=0x{:016X}", | 1596 | "query_address=0x{:016X}", |
| @@ -1604,13 +1600,13 @@ static ResultCode QueryMemory(Core::System& system, VAddr memory_info_address, | |||
| 1604 | query_address); | 1600 | query_address); |
| 1605 | } | 1601 | } |
| 1606 | 1602 | ||
| 1607 | static ResultCode QueryMemory32(Core::System& system, u32 memory_info_address, | 1603 | static Result QueryMemory32(Core::System& system, u32 memory_info_address, u32 page_info_address, |
| 1608 | u32 page_info_address, u32 query_address) { | 1604 | u32 query_address) { |
| 1609 | return QueryMemory(system, memory_info_address, page_info_address, query_address); | 1605 | return QueryMemory(system, memory_info_address, page_info_address, query_address); |
| 1610 | } | 1606 | } |
| 1611 | 1607 | ||
| 1612 | static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, | 1608 | static Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, |
| 1613 | u64 src_address, u64 size) { | 1609 | u64 src_address, u64 size) { |
| 1614 | LOG_DEBUG(Kernel_SVC, | 1610 | LOG_DEBUG(Kernel_SVC, |
| 1615 | "called. process_handle=0x{:08X}, dst_address=0x{:016X}, " | 1611 | "called. process_handle=0x{:08X}, dst_address=0x{:016X}, " |
| 1616 | "src_address=0x{:016X}, size=0x{:016X}", | 1612 | "src_address=0x{:016X}, size=0x{:016X}", |
| @@ -1677,8 +1673,8 @@ static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_hand | |||
| 1677 | return page_table.MapCodeMemory(dst_address, src_address, size); | 1673 | return page_table.MapCodeMemory(dst_address, src_address, size); |
| 1678 | } | 1674 | } |
| 1679 | 1675 | ||
| 1680 | static ResultCode UnmapProcessCodeMemory(Core::System& system, Handle process_handle, | 1676 | static Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, |
| 1681 | u64 dst_address, u64 src_address, u64 size) { | 1677 | u64 src_address, u64 size) { |
| 1682 | LOG_DEBUG(Kernel_SVC, | 1678 | LOG_DEBUG(Kernel_SVC, |
| 1683 | "called. process_handle=0x{:08X}, dst_address=0x{:016X}, src_address=0x{:016X}, " | 1679 | "called. process_handle=0x{:08X}, dst_address=0x{:016X}, src_address=0x{:016X}, " |
| 1684 | "size=0x{:016X}", | 1680 | "size=0x{:016X}", |
| @@ -1770,8 +1766,8 @@ constexpr bool IsValidVirtualCoreId(int32_t core_id) { | |||
| 1770 | } // Anonymous namespace | 1766 | } // Anonymous namespace |
| 1771 | 1767 | ||
| 1772 | /// Creates a new thread | 1768 | /// Creates a new thread |
| 1773 | static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg, | 1769 | static Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg, |
| 1774 | VAddr stack_bottom, u32 priority, s32 core_id) { | 1770 | VAddr stack_bottom, u32 priority, s32 core_id) { |
| 1775 | LOG_DEBUG(Kernel_SVC, | 1771 | LOG_DEBUG(Kernel_SVC, |
| 1776 | "called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, " | 1772 | "called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, " |
| 1777 | "priority=0x{:08X}, core_id=0x{:08X}", | 1773 | "priority=0x{:08X}, core_id=0x{:08X}", |
| @@ -1842,13 +1838,13 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e | |||
| 1842 | return ResultSuccess; | 1838 | return ResultSuccess; |
| 1843 | } | 1839 | } |
| 1844 | 1840 | ||
| 1845 | static ResultCode CreateThread32(Core::System& system, Handle* out_handle, u32 priority, | 1841 | static Result CreateThread32(Core::System& system, Handle* out_handle, u32 priority, |
| 1846 | u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) { | 1842 | u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) { |
| 1847 | return CreateThread(system, out_handle, entry_point, arg, stack_top, priority, processor_id); | 1843 | return CreateThread(system, out_handle, entry_point, arg, stack_top, priority, processor_id); |
| 1848 | } | 1844 | } |
| 1849 | 1845 | ||
| 1850 | /// Starts the thread for the provided handle | 1846 | /// Starts the thread for the provided handle |
| 1851 | static ResultCode StartThread(Core::System& system, Handle thread_handle) { | 1847 | static Result StartThread(Core::System& system, Handle thread_handle) { |
| 1852 | LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); | 1848 | LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); |
| 1853 | 1849 | ||
| 1854 | // Get the thread from its handle. | 1850 | // Get the thread from its handle. |
| @@ -1866,7 +1862,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) { | |||
| 1866 | return ResultSuccess; | 1862 | return ResultSuccess; |
| 1867 | } | 1863 | } |
| 1868 | 1864 | ||
| 1869 | static ResultCode StartThread32(Core::System& system, Handle thread_handle) { | 1865 | static Result StartThread32(Core::System& system, Handle thread_handle) { |
| 1870 | return StartThread(system, thread_handle); | 1866 | return StartThread(system, thread_handle); |
| 1871 | } | 1867 | } |
| 1872 | 1868 | ||
| @@ -1917,8 +1913,8 @@ static void SleepThread32(Core::System& system, u32 nanoseconds_low, u32 nanosec | |||
| 1917 | } | 1913 | } |
| 1918 | 1914 | ||
| 1919 | /// Wait process wide key atomic | 1915 | /// Wait process wide key atomic |
| 1920 | static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_key, | 1916 | static Result WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_key, u32 tag, |
| 1921 | u32 tag, s64 timeout_ns) { | 1917 | s64 timeout_ns) { |
| 1922 | LOG_TRACE(Kernel_SVC, "called address={:X}, cv_key={:X}, tag=0x{:08X}, timeout_ns={}", address, | 1918 | LOG_TRACE(Kernel_SVC, "called address={:X}, cv_key={:X}, tag=0x{:08X}, timeout_ns={}", address, |
| 1923 | cv_key, tag, timeout_ns); | 1919 | cv_key, tag, timeout_ns); |
| 1924 | 1920 | ||
| @@ -1953,8 +1949,8 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr address, | |||
| 1953 | address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout); | 1949 | address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout); |
| 1954 | } | 1950 | } |
| 1955 | 1951 | ||
| 1956 | static ResultCode WaitProcessWideKeyAtomic32(Core::System& system, u32 address, u32 cv_key, u32 tag, | 1952 | static Result WaitProcessWideKeyAtomic32(Core::System& system, u32 address, u32 cv_key, u32 tag, |
| 1957 | u32 timeout_ns_low, u32 timeout_ns_high) { | 1953 | u32 timeout_ns_low, u32 timeout_ns_high) { |
| 1958 | const auto timeout_ns = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); | 1954 | const auto timeout_ns = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); |
| 1959 | return WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns); | 1955 | return WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns); |
| 1960 | } | 1956 | } |
| @@ -1999,8 +1995,8 @@ constexpr bool IsValidArbitrationType(Svc::ArbitrationType type) { | |||
| 1999 | } // namespace | 1995 | } // namespace |
| 2000 | 1996 | ||
| 2001 | // Wait for an address (via Address Arbiter) | 1997 | // Wait for an address (via Address Arbiter) |
| 2002 | static ResultCode WaitForAddress(Core::System& system, VAddr address, Svc::ArbitrationType arb_type, | 1998 | static Result WaitForAddress(Core::System& system, VAddr address, Svc::ArbitrationType arb_type, |
| 2003 | s32 value, s64 timeout_ns) { | 1999 | s32 value, s64 timeout_ns) { |
| 2004 | LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, arb_type=0x{:X}, value=0x{:X}, timeout_ns={}", | 2000 | LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, arb_type=0x{:X}, value=0x{:X}, timeout_ns={}", |
| 2005 | address, arb_type, value, timeout_ns); | 2001 | address, arb_type, value, timeout_ns); |
| 2006 | 2002 | ||
| @@ -2037,15 +2033,15 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, Svc::Arbit | |||
| 2037 | return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout); | 2033 | return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout); |
| 2038 | } | 2034 | } |
| 2039 | 2035 | ||
| 2040 | static ResultCode WaitForAddress32(Core::System& system, u32 address, Svc::ArbitrationType arb_type, | 2036 | static Result WaitForAddress32(Core::System& system, u32 address, Svc::ArbitrationType arb_type, |
| 2041 | s32 value, u32 timeout_ns_low, u32 timeout_ns_high) { | 2037 | s32 value, u32 timeout_ns_low, u32 timeout_ns_high) { |
| 2042 | const auto timeout = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); | 2038 | const auto timeout = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); |
| 2043 | return WaitForAddress(system, address, arb_type, value, timeout); | 2039 | return WaitForAddress(system, address, arb_type, value, timeout); |
| 2044 | } | 2040 | } |
| 2045 | 2041 | ||
| 2046 | // Signals to an address (via Address Arbiter) | 2042 | // Signals to an address (via Address Arbiter) |
| 2047 | static ResultCode SignalToAddress(Core::System& system, VAddr address, Svc::SignalType signal_type, | 2043 | static Result SignalToAddress(Core::System& system, VAddr address, Svc::SignalType signal_type, |
| 2048 | s32 value, s32 count) { | 2044 | s32 value, s32 count) { |
| 2049 | LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, signal_type=0x{:X}, value=0x{:X}, count=0x{:X}", | 2045 | LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, signal_type=0x{:X}, value=0x{:X}, count=0x{:X}", |
| 2050 | address, signal_type, value, count); | 2046 | address, signal_type, value, count); |
| 2051 | 2047 | ||
| @@ -2086,8 +2082,8 @@ static void SynchronizePreemptionState(Core::System& system) { | |||
| 2086 | } | 2082 | } |
| 2087 | } | 2083 | } |
| 2088 | 2084 | ||
| 2089 | static ResultCode SignalToAddress32(Core::System& system, u32 address, Svc::SignalType signal_type, | 2085 | static Result SignalToAddress32(Core::System& system, u32 address, Svc::SignalType signal_type, |
| 2090 | s32 value, s32 count) { | 2086 | s32 value, s32 count) { |
| 2091 | return SignalToAddress(system, address, signal_type, value, count); | 2087 | return SignalToAddress(system, address, signal_type, value, count); |
| 2092 | } | 2088 | } |
| 2093 | 2089 | ||
| @@ -2125,7 +2121,7 @@ static void GetSystemTick32(Core::System& system, u32* time_low, u32* time_high) | |||
| 2125 | } | 2121 | } |
| 2126 | 2122 | ||
| 2127 | /// Close a handle | 2123 | /// Close a handle |
| 2128 | static ResultCode CloseHandle(Core::System& system, Handle handle) { | 2124 | static Result CloseHandle(Core::System& system, Handle handle) { |
| 2129 | LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle); | 2125 | LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle); |
| 2130 | 2126 | ||
| 2131 | // Remove the handle. | 2127 | // Remove the handle. |
| @@ -2135,12 +2131,12 @@ static ResultCode CloseHandle(Core::System& system, Handle handle) { | |||
| 2135 | return ResultSuccess; | 2131 | return ResultSuccess; |
| 2136 | } | 2132 | } |
| 2137 | 2133 | ||
| 2138 | static ResultCode CloseHandle32(Core::System& system, Handle handle) { | 2134 | static Result CloseHandle32(Core::System& system, Handle handle) { |
| 2139 | return CloseHandle(system, handle); | 2135 | return CloseHandle(system, handle); |
| 2140 | } | 2136 | } |
| 2141 | 2137 | ||
| 2142 | /// Clears the signaled state of an event or process. | 2138 | /// Clears the signaled state of an event or process. |
| 2143 | static ResultCode ResetSignal(Core::System& system, Handle handle) { | 2139 | static Result ResetSignal(Core::System& system, Handle handle) { |
| 2144 | LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); | 2140 | LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); |
| 2145 | 2141 | ||
| 2146 | // Get the current handle table. | 2142 | // Get the current handle table. |
| @@ -2167,7 +2163,7 @@ static ResultCode ResetSignal(Core::System& system, Handle handle) { | |||
| 2167 | return ResultInvalidHandle; | 2163 | return ResultInvalidHandle; |
| 2168 | } | 2164 | } |
| 2169 | 2165 | ||
| 2170 | static ResultCode ResetSignal32(Core::System& system, Handle handle) { | 2166 | static Result ResetSignal32(Core::System& system, Handle handle) { |
| 2171 | return ResetSignal(system, handle); | 2167 | return ResetSignal(system, handle); |
| 2172 | } | 2168 | } |
| 2173 | 2169 | ||
| @@ -2187,8 +2183,8 @@ constexpr bool IsValidTransferMemoryPermission(MemoryPermission perm) { | |||
| 2187 | } // Anonymous namespace | 2183 | } // Anonymous namespace |
| 2188 | 2184 | ||
| 2189 | /// Creates a TransferMemory object | 2185 | /// Creates a TransferMemory object |
| 2190 | static ResultCode CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u64 size, | 2186 | static Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u64 size, |
| 2191 | MemoryPermission map_perm) { | 2187 | MemoryPermission map_perm) { |
| 2192 | auto& kernel = system.Kernel(); | 2188 | auto& kernel = system.Kernel(); |
| 2193 | 2189 | ||
| 2194 | // Validate the size. | 2190 | // Validate the size. |
| @@ -2234,13 +2230,13 @@ static ResultCode CreateTransferMemory(Core::System& system, Handle* out, VAddr | |||
| 2234 | return ResultSuccess; | 2230 | return ResultSuccess; |
| 2235 | } | 2231 | } |
| 2236 | 2232 | ||
| 2237 | static ResultCode CreateTransferMemory32(Core::System& system, Handle* out, u32 address, u32 size, | 2233 | static Result CreateTransferMemory32(Core::System& system, Handle* out, u32 address, u32 size, |
| 2238 | MemoryPermission map_perm) { | 2234 | MemoryPermission map_perm) { |
| 2239 | return CreateTransferMemory(system, out, address, size, map_perm); | 2235 | return CreateTransferMemory(system, out, address, size, map_perm); |
| 2240 | } | 2236 | } |
| 2241 | 2237 | ||
| 2242 | static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_core_id, | 2238 | static Result GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_core_id, |
| 2243 | u64* out_affinity_mask) { | 2239 | u64* out_affinity_mask) { |
| 2244 | LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); | 2240 | LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); |
| 2245 | 2241 | ||
| 2246 | // Get the thread from its handle. | 2242 | // Get the thread from its handle. |
| @@ -2254,8 +2250,8 @@ static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle, | |||
| 2254 | return ResultSuccess; | 2250 | return ResultSuccess; |
| 2255 | } | 2251 | } |
| 2256 | 2252 | ||
| 2257 | static ResultCode GetThreadCoreMask32(Core::System& system, Handle thread_handle, s32* out_core_id, | 2253 | static Result GetThreadCoreMask32(Core::System& system, Handle thread_handle, s32* out_core_id, |
| 2258 | u32* out_affinity_mask_low, u32* out_affinity_mask_high) { | 2254 | u32* out_affinity_mask_low, u32* out_affinity_mask_high) { |
| 2259 | u64 out_affinity_mask{}; | 2255 | u64 out_affinity_mask{}; |
| 2260 | const auto result = GetThreadCoreMask(system, thread_handle, out_core_id, &out_affinity_mask); | 2256 | const auto result = GetThreadCoreMask(system, thread_handle, out_core_id, &out_affinity_mask); |
| 2261 | *out_affinity_mask_high = static_cast<u32>(out_affinity_mask >> 32); | 2257 | *out_affinity_mask_high = static_cast<u32>(out_affinity_mask >> 32); |
| @@ -2263,8 +2259,8 @@ static ResultCode GetThreadCoreMask32(Core::System& system, Handle thread_handle | |||
| 2263 | return result; | 2259 | return result; |
| 2264 | } | 2260 | } |
| 2265 | 2261 | ||
| 2266 | static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id, | 2262 | static Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id, |
| 2267 | u64 affinity_mask) { | 2263 | u64 affinity_mask) { |
| 2268 | // Determine the core id/affinity mask. | 2264 | // Determine the core id/affinity mask. |
| 2269 | if (core_id == IdealCoreUseProcessValue) { | 2265 | if (core_id == IdealCoreUseProcessValue) { |
| 2270 | core_id = system.Kernel().CurrentProcess()->GetIdealCoreId(); | 2266 | core_id = system.Kernel().CurrentProcess()->GetIdealCoreId(); |
| @@ -2295,13 +2291,13 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle, | |||
| 2295 | return ResultSuccess; | 2291 | return ResultSuccess; |
| 2296 | } | 2292 | } |
| 2297 | 2293 | ||
| 2298 | static ResultCode SetThreadCoreMask32(Core::System& system, Handle thread_handle, s32 core_id, | 2294 | static Result SetThreadCoreMask32(Core::System& system, Handle thread_handle, s32 core_id, |
| 2299 | u32 affinity_mask_low, u32 affinity_mask_high) { | 2295 | u32 affinity_mask_low, u32 affinity_mask_high) { |
| 2300 | const auto affinity_mask = u64{affinity_mask_low} | (u64{affinity_mask_high} << 32); | 2296 | const auto affinity_mask = u64{affinity_mask_low} | (u64{affinity_mask_high} << 32); |
| 2301 | return SetThreadCoreMask(system, thread_handle, core_id, affinity_mask); | 2297 | return SetThreadCoreMask(system, thread_handle, core_id, affinity_mask); |
| 2302 | } | 2298 | } |
| 2303 | 2299 | ||
| 2304 | static ResultCode SignalEvent(Core::System& system, Handle event_handle) { | 2300 | static Result SignalEvent(Core::System& system, Handle event_handle) { |
| 2305 | LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); | 2301 | LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); |
| 2306 | 2302 | ||
| 2307 | // Get the current handle table. | 2303 | // Get the current handle table. |
| @@ -2314,11 +2310,11 @@ static ResultCode SignalEvent(Core::System& system, Handle event_handle) { | |||
| 2314 | return writable_event->Signal(); | 2310 | return writable_event->Signal(); |
| 2315 | } | 2311 | } |
| 2316 | 2312 | ||
| 2317 | static ResultCode SignalEvent32(Core::System& system, Handle event_handle) { | 2313 | static Result SignalEvent32(Core::System& system, Handle event_handle) { |
| 2318 | return SignalEvent(system, event_handle); | 2314 | return SignalEvent(system, event_handle); |
| 2319 | } | 2315 | } |
| 2320 | 2316 | ||
| 2321 | static ResultCode ClearEvent(Core::System& system, Handle event_handle) { | 2317 | static Result ClearEvent(Core::System& system, Handle event_handle) { |
| 2322 | LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); | 2318 | LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); |
| 2323 | 2319 | ||
| 2324 | // Get the current handle table. | 2320 | // Get the current handle table. |
| @@ -2345,11 +2341,11 @@ static ResultCode ClearEvent(Core::System& system, Handle event_handle) { | |||
| 2345 | return ResultInvalidHandle; | 2341 | return ResultInvalidHandle; |
| 2346 | } | 2342 | } |
| 2347 | 2343 | ||
| 2348 | static ResultCode ClearEvent32(Core::System& system, Handle event_handle) { | 2344 | static Result ClearEvent32(Core::System& system, Handle event_handle) { |
| 2349 | return ClearEvent(system, event_handle); | 2345 | return ClearEvent(system, event_handle); |
| 2350 | } | 2346 | } |
| 2351 | 2347 | ||
| 2352 | static ResultCode CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { | 2348 | static Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { |
| 2353 | LOG_DEBUG(Kernel_SVC, "called"); | 2349 | LOG_DEBUG(Kernel_SVC, "called"); |
| 2354 | 2350 | ||
| 2355 | // Get the kernel reference and handle table. | 2351 | // Get the kernel reference and handle table. |
| @@ -2394,11 +2390,11 @@ static ResultCode CreateEvent(Core::System& system, Handle* out_write, Handle* o | |||
| 2394 | return ResultSuccess; | 2390 | return ResultSuccess; |
| 2395 | } | 2391 | } |
| 2396 | 2392 | ||
| 2397 | static ResultCode CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read) { | 2393 | static Result CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read) { |
| 2398 | return CreateEvent(system, out_write, out_read); | 2394 | return CreateEvent(system, out_write, out_read); |
| 2399 | } | 2395 | } |
| 2400 | 2396 | ||
| 2401 | static ResultCode GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type) { | 2397 | static Result GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type) { |
| 2402 | LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type); | 2398 | LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type); |
| 2403 | 2399 | ||
| 2404 | // This function currently only allows retrieving a process' status. | 2400 | // This function currently only allows retrieving a process' status. |
| @@ -2424,7 +2420,7 @@ static ResultCode GetProcessInfo(Core::System& system, u64* out, Handle process_ | |||
| 2424 | return ResultSuccess; | 2420 | return ResultSuccess; |
| 2425 | } | 2421 | } |
| 2426 | 2422 | ||
| 2427 | static ResultCode CreateResourceLimit(Core::System& system, Handle* out_handle) { | 2423 | static Result CreateResourceLimit(Core::System& system, Handle* out_handle) { |
| 2428 | LOG_DEBUG(Kernel_SVC, "called"); | 2424 | LOG_DEBUG(Kernel_SVC, "called"); |
| 2429 | 2425 | ||
| 2430 | // Create a new resource limit. | 2426 | // Create a new resource limit. |
| @@ -2447,9 +2443,8 @@ static ResultCode CreateResourceLimit(Core::System& system, Handle* out_handle) | |||
| 2447 | return ResultSuccess; | 2443 | return ResultSuccess; |
| 2448 | } | 2444 | } |
| 2449 | 2445 | ||
| 2450 | static ResultCode GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value, | 2446 | static Result GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value, |
| 2451 | Handle resource_limit_handle, | 2447 | Handle resource_limit_handle, LimitableResource which) { |
| 2452 | LimitableResource which) { | ||
| 2453 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, | 2448 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, |
| 2454 | which); | 2449 | which); |
| 2455 | 2450 | ||
| @@ -2468,9 +2463,8 @@ static ResultCode GetResourceLimitLimitValue(Core::System& system, u64* out_limi | |||
| 2468 | return ResultSuccess; | 2463 | return ResultSuccess; |
| 2469 | } | 2464 | } |
| 2470 | 2465 | ||
| 2471 | static ResultCode GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value, | 2466 | static Result GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value, |
| 2472 | Handle resource_limit_handle, | 2467 | Handle resource_limit_handle, LimitableResource which) { |
| 2473 | LimitableResource which) { | ||
| 2474 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, | 2468 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, |
| 2475 | which); | 2469 | which); |
| 2476 | 2470 | ||
| @@ -2489,8 +2483,8 @@ static ResultCode GetResourceLimitCurrentValue(Core::System& system, u64* out_cu | |||
| 2489 | return ResultSuccess; | 2483 | return ResultSuccess; |
| 2490 | } | 2484 | } |
| 2491 | 2485 | ||
| 2492 | static ResultCode SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle, | 2486 | static Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle, |
| 2493 | LimitableResource which, u64 limit_value) { | 2487 | LimitableResource which, u64 limit_value) { |
| 2494 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}", | 2488 | LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}", |
| 2495 | resource_limit_handle, which, limit_value); | 2489 | resource_limit_handle, which, limit_value); |
| 2496 | 2490 | ||
| @@ -2509,8 +2503,8 @@ static ResultCode SetResourceLimitLimitValue(Core::System& system, Handle resour | |||
| 2509 | return ResultSuccess; | 2503 | return ResultSuccess; |
| 2510 | } | 2504 | } |
| 2511 | 2505 | ||
| 2512 | static ResultCode GetProcessList(Core::System& system, u32* out_num_processes, | 2506 | static Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_process_ids, |
| 2513 | VAddr out_process_ids, u32 out_process_ids_size) { | 2507 | u32 out_process_ids_size) { |
| 2514 | LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}", | 2508 | LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}", |
| 2515 | out_process_ids, out_process_ids_size); | 2509 | out_process_ids, out_process_ids_size); |
| 2516 | 2510 | ||
| @@ -2546,8 +2540,8 @@ static ResultCode GetProcessList(Core::System& system, u32* out_num_processes, | |||
| 2546 | return ResultSuccess; | 2540 | return ResultSuccess; |
| 2547 | } | 2541 | } |
| 2548 | 2542 | ||
| 2549 | static ResultCode GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_thread_ids, | 2543 | static Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_thread_ids, |
| 2550 | u32 out_thread_ids_size, Handle debug_handle) { | 2544 | u32 out_thread_ids_size, Handle debug_handle) { |
| 2551 | // TODO: Handle this case when debug events are supported. | 2545 | // TODO: Handle this case when debug events are supported. |
| 2552 | UNIMPLEMENTED_IF(debug_handle != InvalidHandle); | 2546 | UNIMPLEMENTED_IF(debug_handle != InvalidHandle); |
| 2553 | 2547 | ||
| @@ -2586,9 +2580,9 @@ static ResultCode GetThreadList(Core::System& system, u32* out_num_threads, VAdd | |||
| 2586 | return ResultSuccess; | 2580 | return ResultSuccess; |
| 2587 | } | 2581 | } |
| 2588 | 2582 | ||
| 2589 | static ResultCode FlushProcessDataCache32([[maybe_unused]] Core::System& system, | 2583 | static Result FlushProcessDataCache32([[maybe_unused]] Core::System& system, |
| 2590 | [[maybe_unused]] Handle handle, | 2584 | [[maybe_unused]] Handle handle, [[maybe_unused]] u32 address, |
| 2591 | [[maybe_unused]] u32 address, [[maybe_unused]] u32 size) { | 2585 | [[maybe_unused]] u32 size) { |
| 2592 | // Note(Blinkhawk): For emulation purposes of the data cache this is mostly a no-op, | 2586 | // Note(Blinkhawk): For emulation purposes of the data cache this is mostly a no-op, |
| 2593 | // as all emulation is done in the same cache level in host architecture, thus data cache | 2587 | // as all emulation is done in the same cache level in host architecture, thus data cache |
| 2594 | // does not need flushing. | 2588 | // does not need flushing. |
diff --git a/src/core/hle/kernel/svc_results.h b/src/core/hle/kernel/svc_results.h index fab12d070..f27cade33 100644 --- a/src/core/hle/kernel/svc_results.h +++ b/src/core/hle/kernel/svc_results.h | |||
| @@ -9,34 +9,34 @@ namespace Kernel { | |||
| 9 | 9 | ||
| 10 | // Confirmed Switch kernel error codes | 10 | // Confirmed Switch kernel error codes |
| 11 | 11 | ||
| 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), |