diff options
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_slab_heap.h (renamed from src/core/hle/kernel/memory/slab_heap.h) | 21 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 10 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 10 |
4 files changed, 21 insertions, 22 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d12260d9c..a2dce69a7 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -181,6 +181,7 @@ add_library(core STATIC | |||
| 181 | hle/kernel/k_scoped_scheduler_lock_and_sleep.h | 181 | hle/kernel/k_scoped_scheduler_lock_and_sleep.h |
| 182 | hle/kernel/k_shared_memory.cpp | 182 | hle/kernel/k_shared_memory.cpp |
| 183 | hle/kernel/k_shared_memory.h | 183 | hle/kernel/k_shared_memory.h |
| 184 | hle/kernel/k_slab_heap.h | ||
| 184 | hle/kernel/k_spin_lock.cpp | 185 | hle/kernel/k_spin_lock.cpp |
| 185 | hle/kernel/k_spin_lock.h | 186 | hle/kernel/k_spin_lock.h |
| 186 | hle/kernel/k_synchronization_object.cpp | 187 | hle/kernel/k_synchronization_object.cpp |
| @@ -205,7 +206,6 @@ add_library(core STATIC | |||
| 205 | hle/kernel/memory/page_heap.h | 206 | hle/kernel/memory/page_heap.h |
| 206 | hle/kernel/memory/page_table.cpp | 207 | hle/kernel/memory/page_table.cpp |
| 207 | hle/kernel/memory/page_table.h | 208 | hle/kernel/memory/page_table.h |
| 208 | hle/kernel/memory/slab_heap.h | ||
| 209 | hle/kernel/object.cpp | 209 | hle/kernel/object.cpp |
| 210 | hle/kernel/object.h | 210 | hle/kernel/object.h |
| 211 | hle/kernel/physical_core.cpp | 211 | hle/kernel/physical_core.cpp |
diff --git a/src/core/hle/kernel/memory/slab_heap.h b/src/core/hle/kernel/k_slab_heap.h index 465eaddb3..aa4471d2f 100644 --- a/src/core/hle/kernel/memory/slab_heap.h +++ b/src/core/hle/kernel/k_slab_heap.h | |||
| @@ -2,9 +2,6 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | // This file references various implementation details from Atmosphere, an open-source firmware for | ||
| 6 | // the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX. | ||
| 7 | |||
| 8 | #pragma once | 5 | #pragma once |
| 9 | 6 | ||
| 10 | #include <atomic> | 7 | #include <atomic> |
| @@ -12,17 +9,17 @@ | |||
| 12 | #include "common/assert.h" | 9 | #include "common/assert.h" |
| 13 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 14 | 11 | ||
| 15 | namespace Kernel::Memory { | 12 | namespace Kernel { |
| 16 | 13 | ||
| 17 | namespace impl { | 14 | namespace impl { |
| 18 | 15 | ||
| 19 | class SlabHeapImpl final : NonCopyable { | 16 | class KSlabHeapImpl final : NonCopyable { |
| 20 | public: | 17 | public: |
| 21 | struct Node { | 18 | struct Node { |
| 22 | Node* next{}; | 19 | Node* next{}; |
| 23 | }; | 20 | }; |
| 24 | 21 | ||
| 25 | constexpr SlabHeapImpl() = default; | 22 | constexpr KSlabHeapImpl() = default; |
| 26 | 23 | ||
| 27 | void Initialize(std::size_t size) { | 24 | void Initialize(std::size_t size) { |
| 28 | ASSERT(head == nullptr); | 25 | ASSERT(head == nullptr); |
| @@ -65,9 +62,9 @@ private: | |||
| 65 | 62 | ||
| 66 | } // namespace impl | 63 | } // namespace impl |
| 67 | 64 | ||
| 68 | class SlabHeapBase : NonCopyable { | 65 | class KSlabHeapBase : NonCopyable { |
| 69 | public: | 66 | public: |
| 70 | constexpr SlabHeapBase() = default; | 67 | constexpr KSlabHeapBase() = default; |
| 71 | 68 | ||
| 72 | constexpr bool Contains(uintptr_t addr) const { | 69 | constexpr bool Contains(uintptr_t addr) const { |
| 73 | return start <= addr && addr < end; | 70 | return start <= addr && addr < end; |
| @@ -126,7 +123,7 @@ public: | |||
| 126 | } | 123 | } |
| 127 | 124 | ||
| 128 | private: | 125 | private: |
| 129 | using Impl = impl::SlabHeapImpl; | 126 | using Impl = impl::KSlabHeapImpl; |
| 130 | 127 | ||
| 131 | Impl impl; | 128 | Impl impl; |
| 132 | uintptr_t peak{}; | 129 | uintptr_t peak{}; |
| @@ -135,9 +132,9 @@ private: | |||
| 135 | }; | 132 | }; |
| 136 | 133 | ||
| 137 | template <typename T> | 134 | template <typename T> |
| 138 | class SlabHeap final : public SlabHeapBase { | 135 | class KSlabHeap final : public KSlabHeapBase { |
| 139 | public: | 136 | public: |
| 140 | constexpr SlabHeap() : SlabHeapBase() {} | 137 | constexpr KSlabHeap() : KSlabHeapBase() {} |
| 141 | 138 | ||
| 142 | void Initialize(void* memory, std::size_t memory_size) { | 139 | void Initialize(void* memory, std::size_t memory_size) { |
| 143 | InitializeImpl(sizeof(T), memory, memory_size); | 140 | InitializeImpl(sizeof(T), memory, memory_size); |
| @@ -160,4 +157,4 @@ public: | |||
| 160 | } | 157 | } |
| 161 | }; | 158 | }; |
| 162 | 159 | ||
| 163 | } // namespace Kernel::Memory | 160 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 98b3ec712..e4de3f3bf 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -31,10 +31,10 @@ | |||
| 31 | #include "core/hle/kernel/k_resource_limit.h" | 31 | #include "core/hle/kernel/k_resource_limit.h" |
| 32 | #include "core/hle/kernel/k_scheduler.h" | 32 | #include "core/hle/kernel/k_scheduler.h" |
| 33 | #include "core/hle/kernel/k_shared_memory.h" | 33 | #include "core/hle/kernel/k_shared_memory.h" |
| 34 | #include "core/hle/kernel/k_slab_heap.h" | ||
| 34 | #include "core/hle/kernel/k_thread.h" | 35 | #include "core/hle/kernel/k_thread.h" |
| 35 | #include "core/hle/kernel/kernel.h" | 36 | #include "core/hle/kernel/kernel.h" |
| 36 | #include "core/hle/kernel/memory/memory_manager.h" | 37 | #include "core/hle/kernel/memory/memory_manager.h" |
| 37 | #include "core/hle/kernel/memory/slab_heap.h" | ||
| 38 | #include "core/hle/kernel/physical_core.h" | 38 | #include "core/hle/kernel/physical_core.h" |
| 39 | #include "core/hle/kernel/process.h" | 39 | #include "core/hle/kernel/process.h" |
| 40 | #include "core/hle/kernel/service_thread.h" | 40 | #include "core/hle/kernel/service_thread.h" |
| @@ -306,7 +306,7 @@ struct KernelCore::Impl { | |||
| 306 | Memory::MemoryPermission::Read, time_addr, time_size, "Time:SharedMemory"); | 306 | Memory::MemoryPermission::Read, time_addr, time_size, "Time:SharedMemory"); |
| 307 | 307 | ||
| 308 | // Allocate slab heaps | 308 | // Allocate slab heaps |
| 309 | user_slab_heap_pages = std::make_unique<Memory::SlabHeap<Memory::Page>>(); | 309 | user_slab_heap_pages = std::make_unique<KSlabHeap<Memory::Page>>(); |
| 310 | 310 | ||
| 311 | constexpr u64 user_slab_heap_size{0x1ef000}; | 311 | constexpr u64 user_slab_heap_size{0x1ef000}; |
| 312 | // Reserve slab heaps | 312 | // Reserve slab heaps |
| @@ -349,7 +349,7 @@ struct KernelCore::Impl { | |||
| 349 | 349 | ||
| 350 | // Kernel memory management | 350 | // Kernel memory management |
| 351 | std::unique_ptr<Memory::MemoryManager> memory_manager; | 351 | std::unique_ptr<Memory::MemoryManager> memory_manager; |
| 352 | std::unique_ptr<Memory::SlabHeap<Memory::Page>> user_slab_heap_pages; | 352 | std::unique_ptr<KSlabHeap<Memory::Page>> user_slab_heap_pages; |
| 353 | 353 | ||
| 354 | // Shared memory for services | 354 | // Shared memory for services |
| 355 | std::shared_ptr<Kernel::KSharedMemory> hid_shared_mem; | 355 | std::shared_ptr<Kernel::KSharedMemory> hid_shared_mem; |
| @@ -581,11 +581,11 @@ const Memory::MemoryManager& KernelCore::MemoryManager() const { | |||
| 581 | return *impl->memory_manager; | 581 | return *impl->memory_manager; |
| 582 | } | 582 | } |
| 583 | 583 | ||
| 584 | Memory::SlabHeap<Memory::Page>& KernelCore::GetUserSlabHeapPages() { | 584 | KSlabHeap<Memory::Page>& KernelCore::GetUserSlabHeapPages() { |
| 585 | return *impl->user_slab_heap_pages; | 585 | return *impl->user_slab_heap_pages; |
| 586 | } | 586 | } |
| 587 | 587 | ||
| 588 | const Memory::SlabHeap<Memory::Page>& KernelCore::GetUserSlabHeapPages() const { | 588 | const KSlabHeap<Memory::Page>& KernelCore::GetUserSlabHeapPages() const { |
| 589 | return *impl->user_slab_heap_pages; | 589 | return *impl->user_slab_heap_pages; |
| 590 | } | 590 | } |
| 591 | 591 | ||
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index c5b32b260..5488c962a 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -29,8 +29,7 @@ namespace Kernel { | |||
| 29 | 29 | ||
| 30 | namespace Memory { | 30 | namespace Memory { |
| 31 | class MemoryManager; | 31 | class MemoryManager; |
| 32 | template <typename T> | 32 | |
| 33 | class SlabHeap; | ||
| 34 | } // namespace Memory | 33 | } // namespace Memory |
| 35 | 34 | ||
| 36 | class ClientPort; | 35 | class ClientPort; |
| @@ -46,6 +45,9 @@ class Synchronization; | |||
| 46 | class KThread; | 45 | class KThread; |
| 47 | class TimeManager; | 46 | class TimeManager; |
| 48 | 47 | ||
| 48 | template <typename T> | ||
| 49 | class KSlabHeap; | ||
| 50 | |||
| 49 | using EmuThreadHandle = uintptr_t; | 51 | using EmuThreadHandle = uintptr_t; |
| 50 | constexpr EmuThreadHandle EmuThreadHandleInvalid{}; | 52 | constexpr EmuThreadHandle EmuThreadHandleInvalid{}; |
| 51 | constexpr EmuThreadHandle EmuThreadHandleReserved{1ULL << 63}; | 53 | constexpr EmuThreadHandle EmuThreadHandleReserved{1ULL << 63}; |
| @@ -184,10 +186,10 @@ public: | |||
| 184 | const Memory::MemoryManager& MemoryManager() const; | 186 | const Memory::MemoryManager& MemoryManager() const; |
| 185 | 187 | ||
| 186 | /// Gets the slab heap allocated for user space pages. | 188 | /// Gets the slab heap allocated for user space pages. |
| 187 | Memory::SlabHeap<Memory::Page>& GetUserSlabHeapPages(); | 189 | KSlabHeap<Memory::Page>& GetUserSlabHeapPages(); |
| 188 | 190 | ||
| 189 | /// Gets the slab heap allocated for user space pages. | 191 | /// Gets the slab heap allocated for user space pages. |
| 190 | const Memory::SlabHeap<Memory::Page>& GetUserSlabHeapPages() const; | 192 | const KSlabHeap<Memory::Page>& GetUserSlabHeapPages() const; |
| 191 | 193 | ||
| 192 | /// Gets the shared memory object for HID services. | 194 | /// Gets the shared memory object for HID services. |
| 193 | Kernel::KSharedMemory& GetHidSharedMem(); | 195 | Kernel::KSharedMemory& GetHidSharedMem(); |