summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Liam2023-10-11 09:44:49 -0400
committerGravatar Liam2023-10-20 02:34:15 -0400
commit22afa2c7a39e11ccbe572e600a5a863cd323f2b0 (patch)
tree517d3d8a730140c12e7f6cbbeed6d37a508bd6bc
parentMerge pull request #11822 from german77/no-name (diff)
downloadyuzu-22afa2c7a39e11ccbe572e600a5a863cd323f2b0.tar.gz
yuzu-22afa2c7a39e11ccbe572e600a5a863cd323f2b0.tar.xz
yuzu-22afa2c7a39e11ccbe572e600a5a863cd323f2b0.zip
kernel: reshuffle ini1 size, add slab clear note
-rw-r--r--src/core/hle/kernel/init/init_slab_setup.cpp9
-rw-r--r--src/core/hle/kernel/initial_process.h4
-rw-r--r--src/core/hle/kernel/k_memory_layout.h6
-rw-r--r--src/core/hle/kernel/k_memory_manager.cpp9
4 files changed, 18 insertions, 10 deletions
diff --git a/src/core/hle/kernel/init/init_slab_setup.cpp b/src/core/hle/kernel/init/init_slab_setup.cpp
index 1f2db673c..a0e20bbbb 100644
--- a/src/core/hle/kernel/init/init_slab_setup.cpp
+++ b/src/core/hle/kernel/init/init_slab_setup.cpp
@@ -106,7 +106,7 @@ static_assert(KernelPageBufferAdditionalSize ==
106/// memory. 106/// memory.
107static KPhysicalAddress TranslateSlabAddrToPhysical(KMemoryLayout& memory_layout, 107static KPhysicalAddress TranslateSlabAddrToPhysical(KMemoryLayout& memory_layout,
108 KVirtualAddress slab_addr) { 108 KVirtualAddress slab_addr) {
109 slab_addr -= GetInteger(memory_layout.GetSlabRegionAddress()); 109 slab_addr -= memory_layout.GetSlabRegion().GetAddress();
110 return GetInteger(slab_addr) + Core::DramMemoryMap::SlabHeapBase; 110 return GetInteger(slab_addr) + Core::DramMemoryMap::SlabHeapBase;
111} 111}
112 112
@@ -196,7 +196,12 @@ void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) {
196 auto& kernel = system.Kernel(); 196 auto& kernel = system.Kernel();
197 197
198 // Get the start of the slab region, since that's where we'll be working. 198 // Get the start of the slab region, since that's where we'll be working.
199 KVirtualAddress address = memory_layout.GetSlabRegionAddress(); 199 const KMemoryRegion& slab_region = memory_layout.GetSlabRegion();
200 KVirtualAddress address = slab_region.GetAddress();
201
202 // Clear the slab region.
203 // TODO: implement access to kernel VAs.
204 // std::memset(device_ptr, 0, slab_region.GetSize());
200 205
201 // Initialize slab type array to be in sorted order. 206 // Initialize slab type array to be in sorted order.
202 std::array<KSlabType, KSlabType_Count> slab_types; 207 std::array<KSlabType, KSlabType_Count> slab_types;
diff --git a/src/core/hle/kernel/initial_process.h b/src/core/hle/kernel/initial_process.h
index 82195f4f7..2c95269fc 100644
--- a/src/core/hle/kernel/initial_process.h
+++ b/src/core/hle/kernel/initial_process.h
@@ -19,4 +19,8 @@ static inline KPhysicalAddress GetInitialProcessBinaryPhysicalAddress() {
19 MainMemoryAddress); 19 MainMemoryAddress);
20} 20}
21 21
22static inline size_t GetInitialProcessBinarySize() {
23 return InitialProcessBinarySizeMax;
24}
25
22} // namespace Kernel 26} // namespace Kernel
diff --git a/src/core/hle/kernel/k_memory_layout.h b/src/core/hle/kernel/k_memory_layout.h
index 54a71df56..c8122644f 100644
--- a/src/core/hle/kernel/k_memory_layout.h
+++ b/src/core/hle/kernel/k_memory_layout.h
@@ -137,11 +137,9 @@ public:
137 return GetStackTopAddress(core_id, KMemoryRegionType_KernelMiscExceptionStack); 137 return GetStackTopAddress(core_id, KMemoryRegionType_KernelMiscExceptionStack);
138 } 138 }
139 139
140 KVirtualAddress GetSlabRegionAddress() const { 140 const KMemoryRegion& GetSlabRegion() const {
141 return Dereference(GetVirtualMemoryRegionTree().FindByType(KMemoryRegionType_KernelSlab)) 141 return Dereference(GetVirtualMemoryRegionTree().FindByType(KMemoryRegionType_KernelSlab));
142 .GetAddress();
143 } 142 }
144
145 const KMemoryRegion& GetDeviceRegion(KMemoryRegionType type) const { 143 const KMemoryRegion& GetDeviceRegion(KMemoryRegionType type) const {
146 return Dereference(GetPhysicalMemoryRegionTree().FindFirstDerived(type)); 144 return Dereference(GetPhysicalMemoryRegionTree().FindFirstDerived(type));
147 } 145 }
diff --git a/src/core/hle/kernel/k_memory_manager.cpp b/src/core/hle/kernel/k_memory_manager.cpp
index 74d8169e0..637558e10 100644
--- a/src/core/hle/kernel/k_memory_manager.cpp
+++ b/src/core/hle/kernel/k_memory_manager.cpp
@@ -119,7 +119,8 @@ void KMemoryManager::Initialize(KVirtualAddress management_region, size_t manage
119 // Free each region to its corresponding heap. 119 // Free each region to its corresponding heap.
120 size_t reserved_sizes[MaxManagerCount] = {}; 120 size_t reserved_sizes[MaxManagerCount] = {};
121 const KPhysicalAddress ini_start = GetInitialProcessBinaryPhysicalAddress(); 121 const KPhysicalAddress ini_start = GetInitialProcessBinaryPhysicalAddress();
122 const KPhysicalAddress ini_end = ini_start + InitialProcessBinarySizeMax; 122 const size_t ini_size = GetInitialProcessBinarySize();
123 const KPhysicalAddress ini_end = ini_start + ini_size;
123 const KPhysicalAddress ini_last = ini_end - 1; 124 const KPhysicalAddress ini_last = ini_end - 1;
124 for (const auto& it : m_system.Kernel().MemoryLayout().GetPhysicalMemoryRegionTree()) { 125 for (const auto& it : m_system.Kernel().MemoryLayout().GetPhysicalMemoryRegionTree()) {
125 if (it.IsDerivedFrom(KMemoryRegionType_DramUserPool)) { 126 if (it.IsDerivedFrom(KMemoryRegionType_DramUserPool)) {
@@ -137,13 +138,13 @@ void KMemoryManager::Initialize(KVirtualAddress management_region, size_t manage
137 } 138 }
138 139
139 // Open/reserve the ini memory. 140 // Open/reserve the ini memory.
140 manager.OpenFirst(ini_start, InitialProcessBinarySizeMax / PageSize); 141 manager.OpenFirst(ini_start, ini_size / PageSize);
141 reserved_sizes[it.GetAttributes()] += InitialProcessBinarySizeMax; 142 reserved_sizes[it.GetAttributes()] += ini_size;
142 143
143 // Free memory after the ini to the heap. 144 // Free memory after the ini to the heap.
144 if (ini_last != cur_last) { 145 if (ini_last != cur_last) {
145 ASSERT(cur_end != 0); 146 ASSERT(cur_end != 0);
146 manager.Free(ini_end, cur_end - ini_end); 147 manager.Free(ini_end, (cur_end - ini_end) / PageSize);
147 } 148 }
148 } else { 149 } else {
149 // Ensure there's no partial overlap with the ini image. 150 // Ensure there's no partial overlap with the ini image.