diff options
| author | 2020-03-31 15:10:44 -0400 | |
|---|---|---|
| committer | 2020-04-17 00:59:28 -0400 | |
| commit | 4caff51710a793c6c2c1069ddd6e92185aa731fe (patch) | |
| tree | 9770a5cdbfc40f6bddab093d5010f80ddad5bd26 /src/core/hle/kernel | |
| parent | common: alignment: Add a helper function for generic alignment checking. (diff) | |
| download | yuzu-4caff51710a793c6c2c1069ddd6e92185aa731fe.tar.gz yuzu-4caff51710a793c6c2c1069ddd6e92185aa731fe.tar.xz yuzu-4caff51710a793c6c2c1069ddd6e92185aa731fe.zip | |
core: memory: Move to Core::Memory namespace.
- helpful to disambiguate Kernel::Memory namespace.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/client_session.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/kernel/client_session.h | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 13 | ||||
| -rw-r--r-- | src/core/hle/kernel/server_session.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/server_session.h | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 10 | ||||
| -rw-r--r-- | src/core/hle/kernel/transfer_memory.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/transfer_memory.h | 8 |
8 files changed, 29 insertions, 25 deletions
diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp index 6d66276bc..5ab204b9b 100644 --- a/src/core/hle/kernel/client_session.cpp +++ b/src/core/hle/kernel/client_session.cpp | |||
| @@ -47,7 +47,8 @@ ResultVal<std::shared_ptr<ClientSession>> ClientSession::Create(KernelCore& kern | |||
| 47 | return MakeResult(std::move(client_session)); | 47 | return MakeResult(std::move(client_session)); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | ResultCode ClientSession::SendSyncRequest(std::shared_ptr<Thread> thread, Memory::Memory& memory) { | 50 | ResultCode ClientSession::SendSyncRequest(std::shared_ptr<Thread> thread, |
| 51 | Core::Memory::Memory& memory) { | ||
| 51 | // Keep ServerSession alive until we're done working with it. | 52 | // Keep ServerSession alive until we're done working with it. |
| 52 | if (!parent->Server()) { | 53 | if (!parent->Server()) { |
| 53 | return ERR_SESSION_CLOSED_BY_REMOTE; | 54 | return ERR_SESSION_CLOSED_BY_REMOTE; |
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index d15b09554..c5f760d7d 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | union ResultCode; | 13 | union ResultCode; |
| 14 | 14 | ||
| 15 | namespace Memory { | 15 | namespace Core::Memory { |
| 16 | class Memory; | 16 | class Memory; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| @@ -42,7 +42,7 @@ public: | |||
| 42 | return HANDLE_TYPE; | 42 | return HANDLE_TYPE; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | ResultCode SendSyncRequest(std::shared_ptr<Thread> thread, Memory::Memory& memory); | 45 | ResultCode SendSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory); |
| 46 | 46 | ||
| 47 | bool ShouldWait(const Thread* thread) const override; | 47 | bool ShouldWait(const Thread* thread) const override; |
| 48 | 48 | ||
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index ddbd75b8d..bf727901d 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -59,7 +59,8 @@ void SetupMainThread(Process& owner_process, KernelCore& kernel, u32 priority) { | |||
| 59 | // (whichever page happens to have an available slot). | 59 | // (whichever page happens to have an available slot). |
| 60 | class TLSPage { | 60 | class TLSPage { |
| 61 | public: | 61 | public: |
| 62 | static constexpr std::size_t num_slot_entries = Memory::PAGE_SIZE / Memory::TLS_ENTRY_SIZE; | 62 | static constexpr std::size_t num_slot_entries = |
| 63 | Core::Memory::PAGE_SIZE / Core::Memory::TLS_ENTRY_SIZE; | ||
| 63 | 64 | ||
| 64 | explicit TLSPage(VAddr address) : base_address{address} {} | 65 | explicit TLSPage(VAddr address) : base_address{address} {} |
| 65 | 66 | ||
| @@ -78,7 +79,7 @@ public: | |||
| 78 | } | 79 | } |
| 79 | 80 | ||
| 80 | is_slot_used[i] = true; | 81 | is_slot_used[i] = true; |
| 81 | return base_address + (i * Memory::TLS_ENTRY_SIZE); | 82 | return base_address + (i * Core::Memory::TLS_ENTRY_SIZE); |
| 82 | } | 83 | } |
| 83 | 84 | ||
| 84 | return std::nullopt; | 85 | return std::nullopt; |
| @@ -88,15 +89,15 @@ public: | |||
| 88 | // Ensure that all given addresses are consistent with how TLS pages | 89 | // Ensure that all given addresses are consistent with how TLS pages |
| 89 | // are intended to be used when releasing slots. | 90 | // are intended to be used when releasing slots. |
| 90 | ASSERT(IsWithinPage(address)); | 91 | ASSERT(IsWithinPage(address)); |
| 91 | ASSERT((address % Memory::TLS_ENTRY_SIZE) == 0); | 92 | ASSERT((address % Core::Memory::TLS_ENTRY_SIZE) == 0); |
| 92 | 93 | ||
| 93 | const std::size_t index = (address - base_address) / Memory::TLS_ENTRY_SIZE; | 94 | const std::size_t index = (address - base_address) / Core::Memory::TLS_ENTRY_SIZE; |
| 94 | is_slot_used[index] = false; | 95 | is_slot_used[index] = false; |
| 95 | } | 96 | } |
| 96 | 97 | ||
| 97 | private: | 98 | private: |
| 98 | bool IsWithinPage(VAddr address) const { | 99 | bool IsWithinPage(VAddr address) const { |
| 99 | return base_address <= address && address < base_address + Memory::PAGE_SIZE; | 100 | return base_address <= address && address < base_address + Core::Memory::PAGE_SIZE; |
| 100 | } | 101 | } |
| 101 | 102 | ||
| 102 | VAddr base_address; | 103 | VAddr base_address; |
| @@ -306,7 +307,7 @@ VAddr Process::CreateTLSRegion() { | |||
| 306 | } | 307 | } |
| 307 | 308 | ||
| 308 | void Process::FreeTLSRegion(VAddr tls_address) { | 309 | void Process::FreeTLSRegion(VAddr tls_address) { |
| 309 | const VAddr aligned_address = Common::AlignDown(tls_address, Memory::PAGE_SIZE); | 310 | const VAddr aligned_address = Common::AlignDown(tls_address, Core::Memory::PAGE_SIZE); |
| 310 | auto iter = | 311 | auto iter = |
| 311 | std::find_if(tls_pages.begin(), tls_pages.end(), [aligned_address](const auto& page) { | 312 | std::find_if(tls_pages.begin(), tls_pages.end(), [aligned_address](const auto& page) { |
| 312 | return page.GetBaseAddress() == aligned_address; | 313 | return page.GetBaseAddress() == aligned_address; |
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index 4604e35c5..0f102ca44 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp | |||
| @@ -134,7 +134,8 @@ ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& con | |||
| 134 | return RESULT_SUCCESS; | 134 | return RESULT_SUCCESS; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | ResultCode ServerSession::QueueSyncRequest(std::shared_ptr<Thread> thread, Memory::Memory& memory) { | 137 | ResultCode ServerSession::QueueSyncRequest(std::shared_ptr<Thread> thread, |
| 138 | Core::Memory::Memory& memory) { | ||
| 138 | u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))}; | 139 | u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))}; |
| 139 | std::shared_ptr<Kernel::HLERequestContext> context{ | 140 | std::shared_ptr<Kernel::HLERequestContext> context{ |
| 140 | std::make_shared<Kernel::HLERequestContext>(SharedFrom(this), std::move(thread))}; | 141 | std::make_shared<Kernel::HLERequestContext>(SharedFrom(this), std::move(thread))}; |
| @@ -178,7 +179,7 @@ ResultCode ServerSession::CompleteSyncRequest() { | |||
| 178 | } | 179 | } |
| 179 | 180 | ||
| 180 | ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread, | 181 | ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread, |
| 181 | Memory::Memory& memory) { | 182 | Core::Memory::Memory& memory) { |
| 182 | Core::System::GetInstance().CoreTiming().ScheduleEvent(20000, request_event, {}); | 183 | Core::System::GetInstance().CoreTiming().ScheduleEvent(20000, request_event, {}); |
| 183 | return QueueSyncRequest(std::move(thread), memory); | 184 | return QueueSyncRequest(std::move(thread), memory); |
| 184 | } | 185 | } |
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index 77e4f6721..403aaf10b 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h | |||
| @@ -13,7 +13,7 @@ | |||
| 13 | #include "core/hle/kernel/synchronization_object.h" | 13 | #include "core/hle/kernel/synchronization_object.h" |
| 14 | #include "core/hle/result.h" | 14 | #include "core/hle/result.h" |
| 15 | 15 | ||
| 16 | namespace Memory { | 16 | namespace Core::Memory { |
| 17 | class Memory; | 17 | class Memory; |
| 18 | } | 18 | } |
| 19 | 19 | ||
| @@ -92,7 +92,7 @@ public: | |||
| 92 | * | 92 | * |
| 93 | * @returns ResultCode from the operation. | 93 | * @returns ResultCode from the operation. |
| 94 | */ | 94 | */ |
| 95 | ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread, Memory::Memory& memory); | 95 | ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory); |
| 96 | 96 | ||
| 97 | bool ShouldWait(const Thread* thread) const override; | 97 | bool ShouldWait(const Thread* thread) const override; |
| 98 | 98 | ||
| @@ -126,7 +126,7 @@ public: | |||
| 126 | 126 | ||
| 127 | private: | 127 | private: |
| 128 | /// Queues a sync request from the emulated application. | 128 | /// Queues a sync request from the emulated application. |
| 129 | ResultCode QueueSyncRequest(std::shared_ptr<Thread> thread, Memory::Memory& memory); | 129 | ResultCode QueueSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory); |
| 130 | 130 | ||
| 131 | /// Completes a sync request from the emulated application. | 131 | /// Completes a sync request from the emulated application. |
| 132 | ResultCode CompleteSyncRequest(); | 132 | ResultCode CompleteSyncRequest(); |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index abd579097..bde81fab5 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -539,7 +539,7 @@ static ResultCode ArbitrateLock(Core::System& system, Handle holding_thread_hand | |||
| 539 | "requesting_current_thread_handle=0x{:08X}", | 539 | "requesting_current_thread_handle=0x{:08X}", |
| 540 | holding_thread_handle, mutex_addr, requesting_thread_handle); | 540 | holding_thread_handle, mutex_addr, requesting_thread_handle); |
| 541 | 541 | ||
| 542 | if (Memory::IsKernelVirtualAddress(mutex_addr)) { | 542 | if (Core::Memory::IsKernelVirtualAddress(mutex_addr)) { |
| 543 | LOG_ERROR(Kernel_SVC, "Mutex Address is a kernel virtual address, mutex_addr={:016X}", | 543 | LOG_ERROR(Kernel_SVC, "Mutex Address is a kernel virtual address, mutex_addr={:016X}", |
| 544 | mutex_addr); | 544 | mutex_addr); |
| 545 | return ERR_INVALID_ADDRESS_STATE; | 545 | return ERR_INVALID_ADDRESS_STATE; |
| @@ -559,7 +559,7 @@ static ResultCode ArbitrateLock(Core::System& system, Handle holding_thread_hand | |||
| 559 | static ResultCode ArbitrateUnlock(Core::System& system, VAddr mutex_addr) { | 559 | static ResultCode ArbitrateUnlock(Core::System& system, VAddr mutex_addr) { |
| 560 | LOG_TRACE(Kernel_SVC, "called mutex_addr=0x{:X}", mutex_addr); | 560 | LOG_TRACE(Kernel_SVC, "called mutex_addr=0x{:X}", mutex_addr); |
| 561 | 561 | ||
| 562 | if (Memory::IsKernelVirtualAddress(mutex_addr)) { | 562 | if (Core::Memory::IsKernelVirtualAddress(mutex_addr)) { |
| 563 | LOG_ERROR(Kernel_SVC, "Mutex Address is a kernel virtual address, mutex_addr={:016X}", | 563 | LOG_ERROR(Kernel_SVC, "Mutex Address is a kernel virtual address, mutex_addr={:016X}", |
| 564 | mutex_addr); | 564 | mutex_addr); |
| 565 | return ERR_INVALID_ADDRESS_STATE; | 565 | return ERR_INVALID_ADDRESS_STATE; |
| @@ -1611,7 +1611,7 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr mutex_add | |||
| 1611 | "called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle=0x{:08X}, timeout={}", | 1611 | "called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle=0x{:08X}, timeout={}", |
| 1612 | mutex_addr, condition_variable_addr, thread_handle, nano_seconds); | 1612 | mutex_addr, condition_variable_addr, thread_handle, nano_seconds); |
| 1613 | 1613 | ||
| 1614 | if (Memory::IsKernelVirtualAddress(mutex_addr)) { | 1614 | if (Core::Memory::IsKernelVirtualAddress(mutex_addr)) { |
| 1615 | LOG_ERROR( | 1615 | LOG_ERROR( |
| 1616 | Kernel_SVC, | 1616 | Kernel_SVC, |
| 1617 | "Given mutex address must not be within the kernel address space. address=0x{:016X}", | 1617 | "Given mutex address must not be within the kernel address space. address=0x{:016X}", |
| @@ -1742,7 +1742,7 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, u32 type, | |||
| 1742 | type, value, timeout); | 1742 | type, value, timeout); |
| 1743 | 1743 | ||
| 1744 | // If the passed address is a kernel virtual address, return invalid memory state. | 1744 | // If the passed address is a kernel virtual address, return invalid memory state. |
| 1745 | if (Memory::IsKernelVirtualAddress(address)) { | 1745 | if (Core::Memory::IsKernelVirtualAddress(address)) { |
| 1746 | LOG_ERROR(Kernel_SVC, "Address is a kernel virtual address, address={:016X}", address); | 1746 | LOG_ERROR(Kernel_SVC, "Address is a kernel virtual address, address={:016X}", address); |
| 1747 | return ERR_INVALID_ADDRESS_STATE; | 1747 | return ERR_INVALID_ADDRESS_STATE; |
| 1748 | } | 1748 | } |
| @@ -1770,7 +1770,7 @@ static ResultCode SignalToAddress(Core::System& system, VAddr address, u32 type, | |||
| 1770 | address, type, value, num_to_wake); | 1770 | address, type, value, num_to_wake); |
| 1771 | 1771 | ||
| 1772 | // If the passed address is a kernel virtual address, return invalid memory state. | 1772 | // If the passed address is a kernel virtual address, return invalid memory state. |
| 1773 | if (Memory::IsKernelVirtualAddress(address)) { | 1773 | if (Core::Memory::IsKernelVirtualAddress(address)) { |
| 1774 | LOG_ERROR(Kernel_SVC, "Address is a kernel virtual address, address={:016X}", address); | 1774 | LOG_ERROR(Kernel_SVC, "Address is a kernel virtual address, address={:016X}", address); |
| 1775 | return ERR_INVALID_ADDRESS_STATE; | 1775 | return ERR_INVALID_ADDRESS_STATE; |
| 1776 | } | 1776 | } |
diff --git a/src/core/hle/kernel/transfer_memory.cpp b/src/core/hle/kernel/transfer_memory.cpp index f2d3f8b49..74514068e 100644 --- a/src/core/hle/kernel/transfer_memory.cpp +++ b/src/core/hle/kernel/transfer_memory.cpp | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
| 14 | 14 | ||
| 15 | TransferMemory::TransferMemory(KernelCore& kernel, Memory::Memory& memory) | 15 | TransferMemory::TransferMemory(KernelCore& kernel, Core::Memory::Memory& memory) |
| 16 | : Object{kernel}, memory{memory} {} | 16 | : Object{kernel}, memory{memory} {} |
| 17 | 17 | ||
| 18 | TransferMemory::~TransferMemory() { | 18 | TransferMemory::~TransferMemory() { |
| @@ -20,7 +20,8 @@ TransferMemory::~TransferMemory() { | |||
| 20 | Reset(); | 20 | Reset(); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | std::shared_ptr<TransferMemory> TransferMemory::Create(KernelCore& kernel, Memory::Memory& memory, | 23 | std::shared_ptr<TransferMemory> TransferMemory::Create(KernelCore& kernel, |
| 24 | Core::Memory::Memory& memory, | ||
| 24 | VAddr base_address, u64 size, | 25 | VAddr base_address, u64 size, |
| 25 | MemoryPermission permissions) { | 26 | MemoryPermission permissions) { |
| 26 | std::shared_ptr<TransferMemory> transfer_memory{ | 27 | std::shared_ptr<TransferMemory> transfer_memory{ |
diff --git a/src/core/hle/kernel/transfer_memory.h b/src/core/hle/kernel/transfer_memory.h index 6e388536a..a47f57714 100644 --- a/src/core/hle/kernel/transfer_memory.h +++ b/src/core/hle/kernel/transfer_memory.h | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | union ResultCode; | 12 | union ResultCode; |
| 13 | 13 | ||
| 14 | namespace Memory { | 14 | namespace Core::Memory { |
| 15 | class Memory; | 15 | class Memory; |
| 16 | } | 16 | } |
| 17 | 17 | ||
| @@ -30,12 +30,12 @@ enum class MemoryPermission : u32; | |||
| 30 | /// | 30 | /// |
| 31 | class TransferMemory final : public Object { | 31 | class TransferMemory final : public Object { |
| 32 | public: | 32 | public: |
| 33 | explicit TransferMemory(KernelCore& kernel, Memory::Memory& memory); | 33 | explicit TransferMemory(KernelCore& kernel, Core::Memory::Memory& memory); |
| 34 | ~TransferMemory() override; | 34 | ~TransferMemory() override; |
| 35 | 35 | ||
| 36 | static constexpr HandleType HANDLE_TYPE = HandleType::TransferMemory; | 36 | static constexpr HandleType HANDLE_TYPE = HandleType::TransferMemory; |
| 37 | 37 | ||
| 38 | static std::shared_ptr<TransferMemory> Create(KernelCore& kernel, Memory::Memory& memory, | 38 | static std::shared_ptr<TransferMemory> Create(KernelCore& kernel, Core::Memory::Memory& memory, |
| 39 | VAddr base_address, u64 size, | 39 | VAddr base_address, u64 size, |
| 40 | MemoryPermission permissions); | 40 | MemoryPermission permissions); |
| 41 | 41 | ||
| @@ -112,7 +112,7 @@ private: | |||
| 112 | /// Whether or not this transfer memory instance has mapped memory. | 112 | /// Whether or not this transfer memory instance has mapped memory. |
| 113 | bool is_mapped = false; | 113 | bool is_mapped = false; |
| 114 | 114 | ||
| 115 | Memory::Memory& memory; | 115 | Core::Memory::Memory& memory; |
| 116 | }; | 116 | }; |
| 117 | 117 | ||
| 118 | } // namespace Kernel | 118 | } // namespace Kernel |