diff options
| author | 2022-03-11 16:11:57 -0800 | |
|---|---|---|
| committer | 2022-03-14 18:14:54 -0700 | |
| commit | a25cd4bb4bb00949d0f51ebde093e04639e3bb85 (patch) | |
| tree | c775c4690b24b1632cf6c3a5a591e6dfe1ee0417 /src | |
| parent | core: hle: kernel: k_page_buffer: Add KThreadLocalPage primitive. (diff) | |
| download | yuzu-a25cd4bb4bb00949d0f51ebde093e04639e3bb85.tar.gz yuzu-a25cd4bb4bb00949d0f51ebde093e04639e3bb85.tar.xz yuzu-a25cd4bb4bb00949d0f51ebde093e04639e3bb85.zip | |
core: hle: kernel: Update init_slab_heap, use device memory, and add KThreadLocalPage and KPageBuffer.
- Refreshes our slab initialization code to latest known behavior.
- Moves all guest kernel slabs into emulated device memory.
- Adds KThreadLocalPage and KPageBuffer, which we will use for accurate TLS management.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/init/init_slab_setup.cpp | 101 | ||||
| -rw-r--r-- | src/core/hle/kernel/init/init_slab_setup.h | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 27 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 14 |
4 files changed, 92 insertions, 55 deletions
diff --git a/src/core/hle/kernel/init/init_slab_setup.cpp b/src/core/hle/kernel/init/init_slab_setup.cpp index 36fc0944a..4e60f0829 100644 --- a/src/core/hle/kernel/init/init_slab_setup.cpp +++ b/src/core/hle/kernel/init/init_slab_setup.cpp | |||
| @@ -7,19 +7,23 @@ | |||
| 7 | #include "common/common_funcs.h" | 7 | #include "common/common_funcs.h" |
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/device_memory.h" | ||
| 10 | #include "core/hardware_properties.h" | 11 | #include "core/hardware_properties.h" |
| 11 | #include "core/hle/kernel/init/init_slab_setup.h" | 12 | #include "core/hle/kernel/init/init_slab_setup.h" |
| 12 | #include "core/hle/kernel/k_code_memory.h" | 13 | #include "core/hle/kernel/k_code_memory.h" |
| 13 | #include "core/hle/kernel/k_event.h" | 14 | #include "core/hle/kernel/k_event.h" |
| 14 | #include "core/hle/kernel/k_memory_layout.h" | 15 | #include "core/hle/kernel/k_memory_layout.h" |
| 15 | #include "core/hle/kernel/k_memory_manager.h" | 16 | #include "core/hle/kernel/k_memory_manager.h" |
| 17 | #include "core/hle/kernel/k_page_buffer.h" | ||
| 16 | #include "core/hle/kernel/k_port.h" | 18 | #include "core/hle/kernel/k_port.h" |
| 17 | #include "core/hle/kernel/k_process.h" | 19 | #include "core/hle/kernel/k_process.h" |
| 18 | #include "core/hle/kernel/k_resource_limit.h" | 20 | #include "core/hle/kernel/k_resource_limit.h" |
| 19 | #include "core/hle/kernel/k_session.h" | 21 | #include "core/hle/kernel/k_session.h" |
| 20 | #include "core/hle/kernel/k_shared_memory.h" | 22 | #include "core/hle/kernel/k_shared_memory.h" |
| 23 | #include "core/hle/kernel/k_shared_memory_info.h" | ||
| 21 | #include "core/hle/kernel/k_system_control.h" | 24 | #include "core/hle/kernel/k_system_control.h" |
| 22 | #include "core/hle/kernel/k_thread.h" | 25 | #include "core/hle/kernel/k_thread.h" |
| 26 | #include "core/hle/kernel/k_thread_local_page.h" | ||
| 23 | #include "core/hle/kernel/k_transfer_memory.h" | 27 | #include "core/hle/kernel/k_transfer_memory.h" |
| 24 | 28 | ||
| 25 | namespace Kernel::Init { | 29 | namespace Kernel::Init { |
| @@ -32,9 +36,13 @@ namespace Kernel::Init { | |||
| 32 | HANDLER(KEvent, (SLAB_COUNT(KEvent)), ##__VA_ARGS__) \ | 36 | HANDLER(KEvent, (SLAB_COUNT(KEvent)), ##__VA_ARGS__) \ |
| 33 | HANDLER(KPort, (SLAB_COUNT(KPort)), ##__VA_ARGS__) \ | 37 | HANDLER(KPort, (SLAB_COUNT(KPort)), ##__VA_ARGS__) \ |
| 34 | HANDLER(KSharedMemory, (SLAB_COUNT(KSharedMemory)), ##__VA_ARGS__) \ | 38 | HANDLER(KSharedMemory, (SLAB_COUNT(KSharedMemory)), ##__VA_ARGS__) \ |
| 39 | HANDLER(KSharedMemoryInfo, (SLAB_COUNT(KSharedMemory) * 8), ##__VA_ARGS__) \ | ||
| 35 | HANDLER(KTransferMemory, (SLAB_COUNT(KTransferMemory)), ##__VA_ARGS__) \ | 40 | HANDLER(KTransferMemory, (SLAB_COUNT(KTransferMemory)), ##__VA_ARGS__) \ |
| 36 | HANDLER(KCodeMemory, (SLAB_COUNT(KCodeMemory)), ##__VA_ARGS__) \ | 41 | HANDLER(KCodeMemory, (SLAB_COUNT(KCodeMemory)), ##__VA_ARGS__) \ |
| 37 | HANDLER(KSession, (SLAB_COUNT(KSession)), ##__VA_ARGS__) \ | 42 | HANDLER(KSession, (SLAB_COUNT(KSession)), ##__VA_ARGS__) \ |
| 43 | HANDLER(KThreadLocalPage, \ | ||
| 44 | (SLAB_COUNT(KProcess) + (SLAB_COUNT(KProcess) + SLAB_COUNT(KThread)) / 8), \ | ||
| 45 | ##__VA_ARGS__) \ | ||
| 38 | HANDLER(KResourceLimit, (SLAB_COUNT(KResourceLimit)), ##__VA_ARGS__) | 46 | HANDLER(KResourceLimit, (SLAB_COUNT(KResourceLimit)), ##__VA_ARGS__) |
| 39 | 47 | ||
| 40 | namespace { | 48 | namespace { |
| @@ -50,38 +58,46 @@ enum KSlabType : u32 { | |||
| 50 | // Constexpr counts. | 58 | // Constexpr counts. |
| 51 | constexpr size_t SlabCountKProcess = 80; | 59 | constexpr size_t SlabCountKProcess = 80; |
| 52 | constexpr size_t SlabCountKThread = 800; | 60 | constexpr size_t SlabCountKThread = 800; |
| 53 | constexpr size_t SlabCountKEvent = 700; | 61 | constexpr size_t SlabCountKEvent = 900; |
| 54 | constexpr size_t SlabCountKInterruptEvent = 100; | 62 | constexpr size_t SlabCountKInterruptEvent = 100; |
| 55 | constexpr size_t SlabCountKPort = 256 + 0x20; // Extra 0x20 ports over Nintendo for homebrew. | 63 | constexpr size_t SlabCountKPort = 384; |
| 56 | constexpr size_t SlabCountKSharedMemory = 80; | 64 | constexpr size_t SlabCountKSharedMemory = 80; |
| 57 | constexpr size_t SlabCountKTransferMemory = 200; | 65 | constexpr size_t SlabCountKTransferMemory = 200; |
| 58 | constexpr size_t SlabCountKCodeMemory = 10; | 66 | constexpr size_t SlabCountKCodeMemory = 10; |
| 59 | constexpr size_t SlabCountKDeviceAddressSpace = 300; | 67 | constexpr size_t SlabCountKDeviceAddressSpace = 300; |
| 60 | constexpr size_t SlabCountKSession = 933; | 68 | constexpr size_t SlabCountKSession = 1133; |
| 61 | constexpr size_t SlabCountKLightSession = 100; | 69 | constexpr size_t SlabCountKLightSession = 100; |
| 62 | constexpr size_t SlabCountKObjectName = 7; | 70 | constexpr size_t SlabCountKObjectName = 7; |
| 63 | constexpr size_t SlabCountKResourceLimit = 5; | 71 | constexpr size_t SlabCountKResourceLimit = 5; |
| 64 | constexpr size_t SlabCountKDebug = Core::Hardware::NUM_CPU_CORES; | 72 | constexpr size_t SlabCountKDebug = Core::Hardware::NUM_CPU_CORES; |
| 65 | constexpr size_t SlabCountKAlpha = 1; | 73 | constexpr size_t SlabCountKIoPool = 1; |
| 66 | constexpr size_t SlabCountKBeta = 6; | 74 | constexpr size_t SlabCountKIoRegion = 6; |
| 67 | 75 | ||
| 68 | constexpr size_t SlabCountExtraKThread = 160; | 76 | constexpr size_t SlabCountExtraKThread = 160; |
| 69 | 77 | ||
| 78 | /// Helper function to translate from the slab virtual address to the reserved location in physical | ||
| 79 | /// memory. | ||
| 80 | static PAddr TranslateSlabAddrToPhysical(KMemoryLayout& memory_layout, VAddr slab_addr) { | ||
| 81 | slab_addr -= memory_layout.GetSlabRegionAddress(); | ||
| 82 | return slab_addr + Core::DramMemoryMap::SlabHeapBase; | ||
| 83 | } | ||
| 84 | |||
| 70 | template <typename T> | 85 | template <typename T> |
| 71 | VAddr InitializeSlabHeap(Core::System& system, KMemoryLayout& memory_layout, VAddr address, | 86 | VAddr InitializeSlabHeap(Core::System& system, KMemoryLayout& memory_layout, VAddr address, |
| 72 | size_t num_objects) { | 87 | size_t num_objects) { |
| 73 | // TODO(bunnei): This is just a place holder. We should initialize the appropriate KSlabHeap for | ||
| 74 | // kernel object type T with the backing kernel memory pointer once we emulate kernel memory. | ||
| 75 | 88 | ||
| 76 | const size_t size = Common::AlignUp(sizeof(T) * num_objects, alignof(void*)); | 89 | const size_t size = Common::AlignUp(sizeof(T) * num_objects, alignof(void*)); |
| 77 | VAddr start = Common::AlignUp(address, alignof(T)); | 90 | VAddr start = Common::AlignUp(address, alignof(T)); |
| 78 | 91 | ||
| 79 | // This is intentionally empty. Once KSlabHeap is fully implemented, we can replace this with | 92 | // This should use the virtual memory address passed in, but currently, we do not setup the |
| 80 | // the pointer to emulated memory to pass along. Until then, KSlabHeap will just allocate/free | 93 | // kernel virtual memory layout. Instead, we simply map these at a region of physical memory |
| 81 | // host memory. | 94 | // that we reserve for the slab heaps. |
| 82 | void* backing_kernel_memory{}; | 95 | // TODO(bunnei): Fix this once we support the kernel virtual memory layout. |
| 83 | 96 | ||
| 84 | if (size > 0) { | 97 | if (size > 0) { |
| 98 | void* backing_kernel_memory{ | ||
| 99 | system.DeviceMemory().GetPointer(TranslateSlabAddrToPhysical(memory_layout, start))}; | ||
| 100 | |||
| 85 | const KMemoryRegion* region = memory_layout.FindVirtual(start + size - 1); | 101 | const KMemoryRegion* region = memory_layout.FindVirtual(start + size - 1); |
| 86 | ASSERT(region != nullptr); | 102 | ASSERT(region != nullptr); |
| 87 | ASSERT(region->IsDerivedFrom(KMemoryRegionType_KernelSlab)); | 103 | ASSERT(region->IsDerivedFrom(KMemoryRegionType_KernelSlab)); |
| @@ -109,8 +125,8 @@ KSlabResourceCounts KSlabResourceCounts::CreateDefault() { | |||
| 109 | .num_KObjectName = SlabCountKObjectName, | 125 | .num_KObjectName = SlabCountKObjectName, |
| 110 | .num_KResourceLimit = SlabCountKResourceLimit, | 126 | .num_KResourceLimit = SlabCountKResourceLimit, |
| 111 | .num_KDebug = SlabCountKDebug, | 127 | .num_KDebug = SlabCountKDebug, |
| 112 | .num_KAlpha = SlabCountKAlpha, | 128 | .num_KIoPool = SlabCountKIoPool, |
| 113 | .num_KBeta = SlabCountKBeta, | 129 | .num_KIoRegion = SlabCountKIoRegion, |
| 114 | }; | 130 | }; |
| 115 | } | 131 | } |
| 116 | 132 | ||
| @@ -121,6 +137,12 @@ void InitializeSlabResourceCounts(KernelCore& kernel) { | |||
| 121 | } | 137 | } |
| 122 | } | 138 | } |
| 123 | 139 | ||
| 140 | size_t CalculateSlabHeapGapSize() { | ||
| 141 | constexpr size_t KernelSlabHeapGapSize = 2_MiB - 296_KiB; | ||
| 142 | static_assert(KernelSlabHeapGapSize <= KernelSlabHeapGapsSizeMax); | ||
| 143 | return KernelSlabHeapGapSize; | ||
| 144 | } | ||
| 145 | |||
| 124 | size_t CalculateTotalSlabHeapSize(const KernelCore& kernel) { | 146 | size_t CalculateTotalSlabHeapSize(const KernelCore& kernel) { |
| 125 | size_t size = 0; | 147 | size_t size = 0; |
| 126 | 148 | ||
| @@ -136,11 +158,34 @@ size_t CalculateTotalSlabHeapSize(const KernelCore& kernel) { | |||
| 136 | #undef ADD_SLAB_SIZE | 158 | #undef ADD_SLAB_SIZE |
| 137 | 159 | ||
| 138 | // Add the reserved size. | 160 | // Add the reserved size. |
| 139 | size += KernelSlabHeapGapsSize; | 161 | size += CalculateSlabHeapGapSize(); |
| 140 | 162 | ||
| 141 | return size; | 163 | return size; |
| 142 | } | 164 | } |
| 143 | 165 | ||
| 166 | void InitializeKPageBufferSlabHeap(Core::System& system) { | ||
| 167 | auto& kernel = system.Kernel(); | ||
| 168 | |||
| 169 | const auto& counts = kernel.SlabResourceCounts(); | ||
| 170 | const size_t num_pages = | ||
| 171 | counts.num_KProcess + counts.num_KThread + (counts.num_KProcess + counts.num_KThread) / 8; | ||
| 172 | const size_t slab_size = num_pages * PageSize; | ||
| 173 | |||
| 174 | // Reserve memory from the system resource limit. | ||
| 175 | ASSERT(kernel.GetSystemResourceLimit()->Reserve(LimitableResource::PhysicalMemory, slab_size)); | ||
| 176 | |||
| 177 | // Allocate memory for the slab. | ||
| 178 | constexpr auto AllocateOption = KMemoryManager::EncodeOption( | ||
| 179 | KMemoryManager::Pool::System, KMemoryManager::Direction::FromFront); | ||
| 180 | const PAddr slab_address = | ||
| 181 | kernel.MemoryManager().AllocateAndOpenContinuous(num_pages, 1, AllocateOption); | ||
| 182 | ASSERT(slab_address != 0); | ||
| 183 | |||
| 184 | // Initialize the slabheap. | ||
| 185 | KPageBuffer::InitializeSlabHeap(kernel, system.DeviceMemory().GetPointer(slab_address), | ||
| 186 | slab_size); | ||
| 187 | } | ||
| 188 | |||
| 144 | void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) { | 189 | void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) { |
| 145 | auto& kernel = system.Kernel(); | 190 | auto& kernel = system.Kernel(); |
| 146 | 191 | ||
| @@ -160,13 +205,13 @@ void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) { | |||
| 160 | } | 205 | } |
| 161 | 206 | ||
| 162 | // Create an array to represent the gaps between the slabs. | 207 | // Create an array to represent the gaps between the slabs. |
| 163 | const size_t total_gap_size = KernelSlabHeapGapsSize; | 208 | const size_t total_gap_size = CalculateSlabHeapGapSize(); |
| 164 | std::array<size_t, slab_types.size()> slab_gaps; | 209 | std::array<size_t, slab_types.size()> slab_gaps; |
| 165 | for (size_t i = 0; i < slab_gaps.size(); i++) { | 210 | for (auto& slab_gap : slab_gaps) { |
| 166 | // Note: This is an off-by-one error from Nintendo's intention, because GenerateRandomRange | 211 | // Note: This is an off-by-one error from Nintendo's intention, because GenerateRandomRange |
| 167 | // is inclusive. However, Nintendo also has the off-by-one error, and it's "harmless", so we | 212 | // is inclusive. However, Nintendo also has the off-by-one error, and it's "harmless", so we |
| 168 | // will include it ourselves. | 213 | // will include it ourselves. |
| 169 | slab_gaps[i] = KSystemControl::GenerateRandomRange(0, total_gap_size); | 214 | slab_gap = KSystemControl::GenerateRandomRange(0, total_gap_size); |
| 170 | } | 215 | } |
| 171 | 216 | ||
| 172 | // Sort the array, so that we can treat differences between values as offsets to the starts of | 217 | // Sort the array, so that we can treat differences between values as offsets to the starts of |
| @@ -177,13 +222,21 @@ void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) { | |||
| 177 | } | 222 | } |
| 178 | } | 223 | } |
| 179 | 224 | ||
| 180 | for (size_t i = 0; i < slab_types.size(); i++) { | 225 | // Track the gaps, so that we can free them to the unused slab tree. |
| 226 | VAddr gap_start = address; | ||
| 227 | size_t gap_size = 0; | ||
| 228 | |||
| 229 | for (size_t i = 0; i < slab_gaps.size(); i++) { | ||
| 181 | // Add the random gap to the address. | 230 | // Add the random gap to the address. |
| 182 | address += (i == 0) ? slab_gaps[0] : slab_gaps[i] - slab_gaps[i - 1]; | 231 | const auto cur_gap = (i == 0) ? slab_gaps[0] : slab_gaps[i] - slab_gaps[i - 1]; |
| 232 | address += cur_gap; | ||
| 233 | gap_size += cur_gap; | ||
| 183 | 234 | ||
| 184 | #define INITIALIZE_SLAB_HEAP(NAME, COUNT, ...) \ | 235 | #define INITIALIZE_SLAB_HEAP(NAME, COUNT, ...) \ |
| 185 | case KSlabType_##NAME: \ | 236 | case KSlabType_##NAME: \ |
| 186 | address = InitializeSlabHeap<NAME>(system, memory_layout, address, COUNT); \ | 237 | if (COUNT > 0) { \ |
| 238 | address = InitializeSlabHeap<NAME>(system, memory_layout, address, COUNT); \ | ||
| 239 | } \ | ||
| 187 | break; | 240 | break; |
| 188 | 241 | ||
| 189 | // Initialize the slabheap. | 242 | // Initialize the slabheap. |
| @@ -192,7 +245,13 @@ void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) { | |||
| 192 | FOREACH_SLAB_TYPE(INITIALIZE_SLAB_HEAP) | 245 | FOREACH_SLAB_TYPE(INITIALIZE_SLAB_HEAP) |
| 193 | // If we somehow get an invalid type, abort. | 246 | // If we somehow get an invalid type, abort. |
| 194 | default: | 247 | default: |
| 195 | UNREACHABLE(); | 248 | UNREACHABLE_MSG("Unknown slab type: {}", slab_types[i]); |
| 249 | } | ||
| 250 | |||
| 251 | // If we've hit the end of a gap, free it. | ||
| 252 | if (gap_start + gap_size != address) { | ||
| 253 | gap_start = address; | ||
| 254 | gap_size = 0; | ||
| 196 | } | 255 | } |
| 197 | } | 256 | } |
| 198 | } | 257 | } |
diff --git a/src/core/hle/kernel/init/init_slab_setup.h b/src/core/hle/kernel/init/init_slab_setup.h index a8f7e0918..f54b67d02 100644 --- a/src/core/hle/kernel/init/init_slab_setup.h +++ b/src/core/hle/kernel/init/init_slab_setup.h | |||
| @@ -32,12 +32,13 @@ struct KSlabResourceCounts { | |||
| 32 | size_t num_KObjectName; | 32 | size_t num_KObjectName; |
| 33 | size_t num_KResourceLimit; | 33 | size_t num_KResourceLimit; |
| 34 | size_t num_KDebug; | 34 | size_t num_KDebug; |
| 35 | size_t num_KAlpha; | 35 | size_t num_KIoPool; |
| 36 | size_t num_KBeta; | 36 | size_t num_KIoRegion; |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | void InitializeSlabResourceCounts(KernelCore& kernel); | 39 | void InitializeSlabResourceCounts(KernelCore& kernel); |
| 40 | size_t CalculateTotalSlabHeapSize(const KernelCore& kernel); | 40 | size_t CalculateTotalSlabHeapSize(const KernelCore& kernel); |
| 41 | void InitializeKPageBufferSlabHeap(Core::System& system); | ||
| 41 | void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout); | 42 | void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout); |
| 42 | 43 | ||
| 43 | } // namespace Kernel::Init | 44 | } // namespace Kernel::Init |
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 71bd466cf..b543f4083 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -76,7 +76,7 @@ struct KernelCore::Impl { | |||
| 76 | // Initialize kernel memory and resources. | 76 | // Initialize kernel memory and resources. |
| 77 | InitializeSystemResourceLimit(kernel, system.CoreTiming()); | 77 | InitializeSystemResourceLimit(kernel, system.CoreTiming()); |
| 78 | InitializeMemoryLayout(); | 78 | InitializeMemoryLayout(); |
| 79 | InitializePageSlab(); | 79 | Init::InitializeKPageBufferSlabHeap(system); |
| 80 | InitializeSchedulers(); | 80 | InitializeSchedulers(); |
| 81 | InitializeSuspendThreads(); | 81 | InitializeSuspendThreads(); |
| 82 | InitializePreemption(kernel); | 82 | InitializePreemption(kernel); |
| @@ -660,22 +660,6 @@ struct KernelCore::Impl { | |||
| 660 | time_phys_addr, time_size, "Time:SharedMemory"); | 660 | time_phys_addr, time_size, "Time:SharedMemory"); |
| 661 | } | 661 | } |
| 662 | 662 | ||
| 663 | void InitializePageSlab() { | ||
| 664 | // Allocate slab heaps | ||
| 665 | user_slab_heap_pages = | ||
| 666 | std::make_unique<KSlabHeap<Page>>(KSlabHeap<Page>::AllocationType::Guest); | ||
| 667 | |||
| 668 | // TODO(ameerj): This should be derived, not hardcoded within the kernel | ||
| 669 | constexpr u64 user_slab_heap_size{0x3de000}; | ||
| 670 | // Reserve slab heaps | ||
| 671 | ASSERT( | ||
| 672 | system_resource_limit->Reserve(LimitableResource::PhysicalMemory, user_slab_heap_size)); | ||
| 673 | // Initialize slab heap | ||
| 674 | user_slab_heap_pages->Initialize( | ||
| 675 | system.DeviceMemory().GetPointer(Core::DramMemoryMap::SlabHeapBase), | ||
| 676 | user_slab_heap_size); | ||
| 677 | } | ||
| 678 | |||
| 679 | KClientPort* CreateNamedServicePort(std::string name) { | 663 | KClientPort* CreateNamedServicePort(std::string name) { |
| 680 | auto search = service_interface_factory.find(name); | 664 | auto search = service_interface_factory.find(name); |
| 681 | if (search == service_interface_factory.end()) { | 665 | if (search == service_interface_factory.end()) { |
| @@ -756,7 +740,6 @@ struct KernelCore::Impl { | |||
| 756 | 740 | ||
| 757 | // Kernel memory management | 741 | // Kernel memory management |
| 758 | std::unique_ptr<KMemoryManager> memory_manager; | 742 | std::unique_ptr<KMemoryManager> memory_manager; |
| 759 | std::unique_ptr<KSlabHeap<Page>> user_slab_heap_pages; | ||
| 760 | 743 | ||
| 761 | // Shared memory for services | 744 | // Shared memory for services |
| 762 | Kernel::KSharedMemory* hid_shared_mem{}; | 745 | Kernel::KSharedMemory* hid_shared_mem{}; |
| @@ -1031,14 +1014,6 @@ const KMemoryManager& KernelCore::MemoryManager() const { | |||
| 1031 | return *impl->memory_manager; | 1014 | return *impl->memory_manager; |
| 1032 | } | 1015 | } |
| 1033 | 1016 | ||
| 1034 | KSlabHeap<Page>& KernelCore::GetUserSlabHeapPages() { | ||
| 1035 | return *impl->user_slab_heap_pages; | ||
| 1036 | } | ||
| 1037 | |||
| 1038 | const KSlabHeap<Page>& KernelCore::GetUserSlabHeapPages() const { | ||
| 1039 | return *impl->user_slab_heap_pages; | ||
| 1040 | } | ||
| 1041 | |||
| 1042 | Kernel::KSharedMemory& KernelCore::GetHidSharedMem() { | 1017 | Kernel::KSharedMemory& KernelCore::GetHidSharedMem() { |
| 1043 | return *impl->hid_shared_mem; | 1018 | return *impl->hid_shared_mem; |
| 1044 | } | 1019 | } |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index c1254b18d..d4306d5ef 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -43,6 +43,7 @@ class KHandleTable; | |||
| 43 | class KLinkedListNode; | 43 | class KLinkedListNode; |
| 44 | class KMemoryLayout; | 44 | class KMemoryLayout; |
| 45 | class KMemoryManager; | 45 | class KMemoryManager; |
| 46 | class KPageBuffer; | ||
| 46 | class KPort; | 47 | class KPort; |
| 47 | class KProcess; | 48 | class KProcess; |
| 48 | class KResourceLimit; | 49 | class KResourceLimit; |
| @@ -52,6 +53,7 @@ class KSession; | |||
| 52 | class KSharedMemory; | 53 | class KSharedMemory; |
| 53 | class KSharedMemoryInfo; | 54 | class KSharedMemoryInfo; |
| 54 | class KThread; | 55 | class KThread; |
| 56 | class KThreadLocalPage; | ||
| 55 | class KTransferMemory; | 57 | class KTransferMemory; |
| 56 | class KWorkerTaskManager; | 58 | class KWorkerTaskManager; |
| 57 | class KWritableEvent; | 59 | class KWritableEvent; |
| @@ -239,12 +241,6 @@ public: | |||
| 239 | /// Gets the virtual memory manager for the kernel. | 241 | /// Gets the virtual memory manager for the kernel. |
| 240 | const KMemoryManager& MemoryManager() const; | 242 | const KMemoryManager& MemoryManager() const; |
| 241 | 243 | ||
| 242 | /// Gets the slab heap allocated for user space pages. | ||
| 243 | KSlabHeap<Page>& GetUserSlabHeapPages(); | ||
| 244 | |||
| 245 | /// Gets the slab heap allocated for user space pages. | ||
| 246 | const KSlabHeap<Page>& GetUserSlabHeapPages() const; | ||
| 247 | |||
| 248 | /// Gets the shared memory object for HID services. | 244 | /// Gets the shared memory object for HID services. |
| 249 | Kernel::KSharedMemory& GetHidSharedMem(); | 245 | Kernel::KSharedMemory& GetHidSharedMem(); |
| 250 | 246 | ||
| @@ -336,6 +332,10 @@ public: | |||
| 336 | return slab_heap_container->writeable_event; | 332 | return slab_heap_container->writeable_event; |
| 337 | } else if constexpr (std::is_same_v<T, KCodeMemory>) { | 333 | } else if constexpr (std::is_same_v<T, KCodeMemory>) { |
| 338 | return slab_heap_container->code_memory; | 334 | return slab_heap_container->code_memory; |
| 335 | } else if constexpr (std::is_same_v<T, KPageBuffer>) { | ||
| 336 | return slab_heap_container->page_buffer; | ||
| 337 | } else if constexpr (std::is_same_v<T, KThreadLocalPage>) { | ||
| 338 | return slab_heap_container->thread_local_page; | ||
| 339 | } | 339 | } |
| 340 | } | 340 | } |
| 341 | 341 | ||
| @@ -397,6 +397,8 @@ private: | |||
| 397 | KSlabHeap<KTransferMemory> transfer_memory; | 397 | KSlabHeap<KTransferMemory> transfer_memory; |
| 398 | KSlabHeap<KWritableEvent> writeable_event; | 398 | KSlabHeap<KWritableEvent> writeable_event; |
| 399 | KSlabHeap<KCodeMemory> code_memory; | 399 | KSlabHeap<KCodeMemory> code_memory; |
| 400 | KSlabHeap<KPageBuffer> page_buffer; | ||
| 401 | KSlabHeap<KThreadLocalPage> thread_local_page; | ||
| 400 | }; | 402 | }; |
| 401 | 403 | ||
| 402 | std::unique_ptr<SlabHeapContainer> slab_heap_container; | 404 | std::unique_ptr<SlabHeapContainer> slab_heap_container; |