From fb49ec19c1fb6030fcc960077e82c998290d0ab8 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 17 Mar 2023 21:26:04 -0400 Subject: kernel: use KTypedAddress for addresses --- src/core/hle/kernel/board/nintendo/nx/k_memory_layout.cpp | 12 +++++++----- src/core/hle/kernel/board/nintendo/nx/k_memory_layout.h | 4 ++-- src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp | 2 +- src/core/hle/kernel/board/nintendo/nx/k_system_control.h | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src/core/hle/kernel/board/nintendo/nx') diff --git a/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.cpp b/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.cpp index 098ba6eac..24eb3f886 100644 --- a/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.cpp +++ b/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.cpp @@ -76,22 +76,24 @@ void SetupDevicePhysicalMemoryRegions(KMemoryLayout& memory_layout) { void SetupDramPhysicalMemoryRegions(KMemoryLayout& memory_layout) { const size_t intended_memory_size = KSystemControl::Init::GetIntendedMemorySize(); - const PAddr physical_memory_base_address = + const KPhysicalAddress physical_memory_base_address = KSystemControl::Init::GetKernelPhysicalBaseAddress(DramPhysicalAddress); // Insert blocks into the tree. ASSERT(memory_layout.GetPhysicalMemoryRegionTree().Insert( - physical_memory_base_address, intended_memory_size, KMemoryRegionType_Dram)); + GetInteger(physical_memory_base_address), intended_memory_size, KMemoryRegionType_Dram)); ASSERT(memory_layout.GetPhysicalMemoryRegionTree().Insert( - physical_memory_base_address, ReservedEarlyDramSize, KMemoryRegionType_DramReservedEarly)); + GetInteger(physical_memory_base_address), ReservedEarlyDramSize, + KMemoryRegionType_DramReservedEarly)); // Insert the KTrace block at the end of Dram, if KTrace is enabled. static_assert(!IsKTraceEnabled || KTraceBufferSize > 0); if constexpr (IsKTraceEnabled) { - const PAddr ktrace_buffer_phys_addr = + const KPhysicalAddress ktrace_buffer_phys_addr = physical_memory_base_address + intended_memory_size - KTraceBufferSize; ASSERT(memory_layout.GetPhysicalMemoryRegionTree().Insert( - ktrace_buffer_phys_addr, KTraceBufferSize, KMemoryRegionType_KernelTraceBuffer)); + GetInteger(ktrace_buffer_phys_addr), KTraceBufferSize, + KMemoryRegionType_KernelTraceBuffer)); } } diff --git a/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.h b/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.h index d02ee61c3..f8fee4f5b 100644 --- a/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.h +++ b/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.h @@ -3,10 +3,10 @@ #pragma once -#include "common/common_types.h" +#include "core/hle/kernel/k_typed_address.h" namespace Kernel { -constexpr inline PAddr MainMemoryAddress = 0x80000000; +constexpr inline KPhysicalAddress MainMemoryAddress = 0x80000000; } // namespace Kernel diff --git a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp index 5b8a248c8..42d1fcc28 100644 --- a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp +++ b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp @@ -61,7 +61,7 @@ size_t KSystemControl::Init::GetIntendedMemorySize() { } } -PAddr KSystemControl::Init::GetKernelPhysicalBaseAddress(u64 base_address) { +KPhysicalAddress KSystemControl::Init::GetKernelPhysicalBaseAddress(KPhysicalAddress base_address) { const size_t real_dram_size = KSystemControl::Init::GetRealMemorySize(); const size_t intended_dram_size = KSystemControl::Init::GetIntendedMemorySize(); if (intended_dram_size * 2 < real_dram_size) { diff --git a/src/core/hle/kernel/board/nintendo/nx/k_system_control.h b/src/core/hle/kernel/board/nintendo/nx/k_system_control.h index 4b717d091..b477e8193 100644 --- a/src/core/hle/kernel/board/nintendo/nx/k_system_control.h +++ b/src/core/hle/kernel/board/nintendo/nx/k_system_control.h @@ -3,7 +3,7 @@ #pragma once -#include "common/common_types.h" +#include "core/hle/kernel/k_typed_address.h" namespace Kernel::Board::Nintendo::Nx { @@ -18,7 +18,7 @@ public: // Initialization. static std::size_t GetRealMemorySize(); static std::size_t GetIntendedMemorySize(); - static PAddr GetKernelPhysicalBaseAddress(u64 base_address); + static KPhysicalAddress GetKernelPhysicalBaseAddress(KPhysicalAddress base_address); static bool ShouldIncreaseThreadResourceLimit(); static std::size_t GetApplicationPoolSize(); static std::size_t GetAppletPoolSize(); -- cgit v1.2.3