diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/kernel/init/init_slab_setup.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/core/hle/kernel/init/init_slab_setup.cpp b/src/core/hle/kernel/init/init_slab_setup.cpp index 7b363eb1e..1f2db673c 100644 --- a/src/core/hle/kernel/init/init_slab_setup.cpp +++ b/src/core/hle/kernel/init/init_slab_setup.cpp @@ -4,17 +4,18 @@ #include "common/alignment.h" #include "common/assert.h" #include "common/common_funcs.h" -#include "common/common_types.h" #include "core/core.h" #include "core/device_memory.h" #include "core/hardware_properties.h" #include "core/hle/kernel/init/init_slab_setup.h" #include "core/hle/kernel/k_code_memory.h" #include "core/hle/kernel/k_debug.h" +#include "core/hle/kernel/k_device_address_space.h" #include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_event_info.h" #include "core/hle/kernel/k_memory_layout.h" #include "core/hle/kernel/k_memory_manager.h" +#include "core/hle/kernel/k_object_name.h" #include "core/hle/kernel/k_page_buffer.h" #include "core/hle/kernel/k_port.h" #include "core/hle/kernel/k_process.h" @@ -28,9 +29,13 @@ #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/k_thread_local_page.h" #include "core/hle/kernel/k_transfer_memory.h" +#include "core/hle/kernel/k_typed_address.h" namespace Kernel::Init { +// For macro convenience. +using KThreadLockInfo = KThread::LockWithPriorityInheritanceInfo; + #define SLAB_COUNT(CLASS) kernel.SlabResourceCounts().num_##CLASS #define FOREACH_SLAB_TYPE(HANDLER, ...) \ @@ -43,14 +48,17 @@ namespace Kernel::Init { HANDLER(KSharedMemoryInfo, (SLAB_COUNT(KSharedMemory) * 8), ##__VA_ARGS__) \ HANDLER(KTransferMemory, (SLAB_COUNT(KTransferMemory)), ##__VA_ARGS__) \ HANDLER(KCodeMemory, (SLAB_COUNT(KCodeMemory)), ##__VA_ARGS__) \ + HANDLER(KDeviceAddressSpace, (SLAB_COUNT(KDeviceAddressSpace)), ##__VA_ARGS__) \ HANDLER(KSession, (SLAB_COUNT(KSession)), ##__VA_ARGS__) \ HANDLER(KThreadLocalPage, \ (SLAB_COUNT(KProcess) + (SLAB_COUNT(KProcess) + SLAB_COUNT(KThread)) / 8), \ ##__VA_ARGS__) \ + HANDLER(KObjectName, (SLAB_COUNT(KObjectName)), ##__VA_ARGS__) \ HANDLER(KResourceLimit, (SLAB_COUNT(KResourceLimit)), ##__VA_ARGS__) \ HANDLER(KEventInfo, (SLAB_COUNT(KThread) + SLAB_COUNT(KDebug)), ##__VA_ARGS__) \ HANDLER(KDebug, (SLAB_COUNT(KDebug)), ##__VA_ARGS__) \ - HANDLER(KSecureSystemResource, (SLAB_COUNT(KProcess)), ##__VA_ARGS__) + HANDLER(KSecureSystemResource, (SLAB_COUNT(KProcess)), ##__VA_ARGS__) \ + HANDLER(KThreadLockInfo, (SLAB_COUNT(KThread)), ##__VA_ARGS__) namespace { @@ -96,17 +104,18 @@ static_assert(KernelPageBufferAdditionalSize == /// Helper function to translate from the slab virtual address to the reserved location in physical /// memory. -static PAddr TranslateSlabAddrToPhysical(KMemoryLayout& memory_layout, VAddr slab_addr) { - slab_addr -= memory_layout.GetSlabRegionAddress(); - return slab_addr + Core::DramMemoryMap::SlabHeapBase; +static KPhysicalAddress TranslateSlabAddrToPhysical(KMemoryLayout& memory_layout, + KVirtualAddress slab_addr) { + slab_addr -= GetInteger(memory_layout.GetSlabRegionAddress()); + return GetInteger(slab_addr) + Core::DramMemoryMap::SlabHeapBase; } template <typename T> -VAddr InitializeSlabHeap(Core::System& system, KMemoryLayout& memory_layout, VAddr address, - size_t num_objects) { +KVirtualAddress InitializeSlabHeap(Core::System& system, KMemoryLayout& memory_layout, + KVirtualAddress address, size_t num_objects) { const size_t size = Common::AlignUp(sizeof(T) * num_objects, alignof(void*)); - VAddr start = Common::AlignUp(address, alignof(T)); + KVirtualAddress start = Common::AlignUp(GetInteger(address), alignof(T)); // This should use the virtual memory address passed in, but currently, we do not setup the // kernel virtual memory layout. Instead, we simply map these at a region of physical memory @@ -127,7 +136,7 @@ VAddr InitializeSlabHeap(Core::System& system, KMemoryLayout& memory_layout, VAd } size_t CalculateSlabHeapGapSize() { - constexpr size_t KernelSlabHeapGapSize = 2_MiB - 320_KiB; + constexpr size_t KernelSlabHeapGapSize = 2_MiB - 356_KiB; static_assert(KernelSlabHeapGapSize <= KernelSlabHeapGapsSizeMax); return KernelSlabHeapGapSize; } @@ -187,7 +196,7 @@ void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) { auto& kernel = system.Kernel(); // Get the start of the slab region, since that's where we'll be working. - VAddr address = memory_layout.GetSlabRegionAddress(); + KVirtualAddress address = memory_layout.GetSlabRegionAddress(); // Initialize slab type array to be in sorted order. std::array<KSlabType, KSlabType_Count> slab_types; @@ -220,7 +229,7 @@ void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) { } // Track the gaps, so that we can free them to the unused slab tree. - VAddr gap_start = address; + KVirtualAddress gap_start = address; size_t gap_size = 0; for (size_t i = 0; i < slab_gaps.size(); i++) { @@ -272,7 +281,7 @@ void KPageBufferSlabHeap::Initialize(Core::System& system) { // Allocate memory for the slab. constexpr auto AllocateOption = KMemoryManager::EncodeOption( KMemoryManager::Pool::System, KMemoryManager::Direction::FromFront); - const PAddr slab_address = + const KPhysicalAddress slab_address = kernel.MemoryManager().AllocateAndOpenContinuous(num_pages, 1, AllocateOption); ASSERT(slab_address != 0); |