summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/init
diff options
context:
space:
mode:
authorGravatar Liam2023-03-17 21:26:04 -0400
committerGravatar Liam2023-03-22 09:35:16 -0400
commitfb49ec19c1fb6030fcc960077e82c998290d0ab8 (patch)
treeaa5f53cbbfc2b255923bcf362ee0009938ed8187 /src/core/hle/kernel/init
parentMerge pull request #9955 from liamwhite/color-blend-equation (diff)
downloadyuzu-fb49ec19c1fb6030fcc960077e82c998290d0ab8.tar.gz
yuzu-fb49ec19c1fb6030fcc960077e82c998290d0ab8.tar.xz
yuzu-fb49ec19c1fb6030fcc960077e82c998290d0ab8.zip
kernel: use KTypedAddress for addresses
Diffstat (limited to 'src/core/hle/kernel/init')
-rw-r--r--src/core/hle/kernel/init/init_slab_setup.cpp21
1 files changed, 11 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 5e4090e2b..1f2db673c 100644
--- a/src/core/hle/kernel/init/init_slab_setup.cpp
+++ b/src/core/hle/kernel/init/init_slab_setup.cpp
@@ -4,7 +4,6 @@
4#include "common/alignment.h" 4#include "common/alignment.h"
5#include "common/assert.h" 5#include "common/assert.h"
6#include "common/common_funcs.h" 6#include "common/common_funcs.h"
7#include "common/common_types.h"
8#include "core/core.h" 7#include "core/core.h"
9#include "core/device_memory.h" 8#include "core/device_memory.h"
10#include "core/hardware_properties.h" 9#include "core/hardware_properties.h"
@@ -30,6 +29,7 @@
30#include "core/hle/kernel/k_thread.h" 29#include "core/hle/kernel/k_thread.h"
31#include "core/hle/kernel/k_thread_local_page.h" 30#include "core/hle/kernel/k_thread_local_page.h"
32#include "core/hle/kernel/k_transfer_memory.h" 31#include "core/hle/kernel/k_transfer_memory.h"
32#include "core/hle/kernel/k_typed_address.h"
33 33
34namespace Kernel::Init { 34namespace Kernel::Init {
35 35
@@ -104,17 +104,18 @@ static_assert(KernelPageBufferAdditionalSize ==
104 104
105/// Helper function to translate from the slab virtual address to the reserved location in physical 105/// Helper function to translate from the slab virtual address to the reserved location in physical
106/// memory. 106/// memory.
107static PAddr TranslateSlabAddrToPhysical(KMemoryLayout& memory_layout, VAddr slab_addr) { 107static KPhysicalAddress TranslateSlabAddrToPhysical(KMemoryLayout& memory_layout,
108 slab_addr -= memory_layout.GetSlabRegionAddress(); 108 KVirtualAddress slab_addr) {
109 return slab_addr + Core::DramMemoryMap::SlabHeapBase; 109 slab_addr -= GetInteger(memory_layout.GetSlabRegionAddress());
110 return GetInteger(slab_addr) + Core::DramMemoryMap::SlabHeapBase;
110} 111}
111 112
112template <typename T> 113template <typename T>
113VAddr InitializeSlabHeap(Core::System& system, KMemoryLayout& memory_layout, VAddr address, 114KVirtualAddress InitializeSlabHeap(Core::System& system, KMemoryLayout& memory_layout,
114 size_t num_objects) { 115 KVirtualAddress address, size_t num_objects) {
115 116
116 const size_t size = Common::AlignUp(sizeof(T) * num_objects, alignof(void*)); 117 const size_t size = Common::AlignUp(sizeof(T) * num_objects, alignof(void*));
117 VAddr start = Common::AlignUp(address, alignof(T)); 118 KVirtualAddress start = Common::AlignUp(GetInteger(address), alignof(T));
118 119
119 // This should use the virtual memory address passed in, but currently, we do not setup the 120 // This should use the virtual memory address passed in, but currently, we do not setup the
120 // kernel virtual memory layout. Instead, we simply map these at a region of physical memory 121 // kernel virtual memory layout. Instead, we simply map these at a region of physical memory
@@ -195,7 +196,7 @@ void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) {
195 auto& kernel = system.Kernel(); 196 auto& kernel = system.Kernel();
196 197
197 // 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.
198 VAddr address = memory_layout.GetSlabRegionAddress(); 199 KVirtualAddress address = memory_layout.GetSlabRegionAddress();
199 200
200 // Initialize slab type array to be in sorted order. 201 // Initialize slab type array to be in sorted order.
201 std::array<KSlabType, KSlabType_Count> slab_types; 202 std::array<KSlabType, KSlabType_Count> slab_types;
@@ -228,7 +229,7 @@ void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) {
228 } 229 }
229 230
230 // Track the gaps, so that we can free them to the unused slab tree. 231 // Track the gaps, so that we can free them to the unused slab tree.
231 VAddr gap_start = address; 232 KVirtualAddress gap_start = address;
232 size_t gap_size = 0; 233 size_t gap_size = 0;
233 234
234 for (size_t i = 0; i < slab_gaps.size(); i++) { 235 for (size_t i = 0; i < slab_gaps.size(); i++) {
@@ -280,7 +281,7 @@ void KPageBufferSlabHeap::Initialize(Core::System& system) {
280 // Allocate memory for the slab. 281 // Allocate memory for the slab.
281 constexpr auto AllocateOption = KMemoryManager::EncodeOption( 282 constexpr auto AllocateOption = KMemoryManager::EncodeOption(
282 KMemoryManager::Pool::System, KMemoryManager::Direction::FromFront); 283 KMemoryManager::Pool::System, KMemoryManager::Direction::FromFront);
283 const PAddr slab_address = 284 const KPhysicalAddress slab_address =
284 kernel.MemoryManager().AllocateAndOpenContinuous(num_pages, 1, AllocateOption); 285 kernel.MemoryManager().AllocateAndOpenContinuous(num_pages, 1, AllocateOption);
285 ASSERT(slab_address != 0); 286 ASSERT(slab_address != 0);
286 287