1
0
Fork 0
forked from suyu/suyu

hle: kernel: Migrate PageHeap/PageTable to KPageHeap/KPageTable.

This commit is contained in:
bunnei 2021-02-12 17:58:31 -08:00
parent b1e27890e8
commit 93e20867b0
24 changed files with 131 additions and 147 deletions

View file

@ -173,7 +173,11 @@ add_library(core STATIC
hle/kernel/k_memory_manager.cpp hle/kernel/k_memory_manager.cpp
hle/kernel/k_memory_manager.h hle/kernel/k_memory_manager.h
hle/kernel/k_page_bitmap.h hle/kernel/k_page_bitmap.h
hle/kernel/k_page_heap.cpp
hle/kernel/k_page_heap.h
hle/kernel/k_page_linked_list.h hle/kernel/k_page_linked_list.h
hle/kernel/k_page_table.cpp
hle/kernel/k_page_table.h
hle/kernel/k_priority_queue.h hle/kernel/k_priority_queue.h
hle/kernel/k_readable_event.cpp hle/kernel/k_readable_event.cpp
hle/kernel/k_readable_event.h hle/kernel/k_readable_event.h
@ -202,10 +206,6 @@ add_library(core STATIC
hle/kernel/kernel.cpp hle/kernel/kernel.cpp
hle/kernel/kernel.h hle/kernel/kernel.h
hle/kernel/memory_types.h hle/kernel/memory_types.h
hle/kernel/memory/page_heap.cpp
hle/kernel/memory/page_heap.h
hle/kernel/memory/page_table.cpp
hle/kernel/memory/page_table.h
hle/kernel/object.cpp hle/kernel/object.cpp
hle/kernel/object.h hle/kernel/object.h
hle/kernel/physical_core.cpp hle/kernel/physical_core.cpp

View file

@ -21,7 +21,7 @@ std::size_t KMemoryManager::Impl::Initialize(Pool new_pool, u64 start_address, u
const auto ref_count_size{(size / PageSize) * sizeof(u16)}; const auto ref_count_size{(size / PageSize) * sizeof(u16)};
const auto optimize_map_size{(Common::AlignUp((size / PageSize), 64) / 64) * sizeof(u64)}; const auto optimize_map_size{(Common::AlignUp((size / PageSize), 64) / 64) * sizeof(u64)};
const auto manager_size{Common::AlignUp(optimize_map_size + ref_count_size, PageSize)}; const auto manager_size{Common::AlignUp(optimize_map_size + ref_count_size, PageSize)};
const auto page_heap_size{Memory::PageHeap::CalculateManagementOverheadSize(size)}; const auto page_heap_size{KPageHeap::CalculateManagementOverheadSize(size)};
const auto total_metadata_size{manager_size + page_heap_size}; const auto total_metadata_size{manager_size + page_heap_size};
ASSERT(manager_size <= total_metadata_size); ASSERT(manager_size <= total_metadata_size);
ASSERT(Common::IsAligned(total_metadata_size, PageSize)); ASSERT(Common::IsAligned(total_metadata_size, PageSize));
@ -59,7 +59,7 @@ VAddr KMemoryManager::AllocateAndOpenContinuous(std::size_t num_pages, std::size
std::lock_guard lock{pool_locks[pool_index]}; std::lock_guard lock{pool_locks[pool_index]};
// Choose a heap based on our page size request // Choose a heap based on our page size request
const s32 heap_index{Memory::PageHeap::GetAlignedBlockIndex(num_pages, align_pages)}; const s32 heap_index{KPageHeap::GetAlignedBlockIndex(num_pages, align_pages)};
// Loop, trying to iterate from each block // Loop, trying to iterate from each block
// TODO (bunnei): Support multiple managers // TODO (bunnei): Support multiple managers
@ -72,7 +72,7 @@ VAddr KMemoryManager::AllocateAndOpenContinuous(std::size_t num_pages, std::size
} }
// If we allocated more than we need, free some // If we allocated more than we need, free some
const auto allocated_pages{Memory::PageHeap::GetBlockNumPages(heap_index)}; const auto allocated_pages{KPageHeap::GetBlockNumPages(heap_index)};
if (allocated_pages > num_pages) { if (allocated_pages > num_pages) {
chosen_manager.Free(allocated_block + num_pages * PageSize, allocated_pages - num_pages); chosen_manager.Free(allocated_block + num_pages * PageSize, allocated_pages - num_pages);
} }
@ -94,7 +94,7 @@ ResultCode KMemoryManager::Allocate(KPageLinkedList& page_list, std::size_t num_
std::lock_guard lock{pool_locks[pool_index]}; std::lock_guard lock{pool_locks[pool_index]};
// Choose a heap based on our page size request // Choose a heap based on our page size request
const s32 heap_index{Memory::PageHeap::GetBlockIndex(num_pages)}; const s32 heap_index{KPageHeap::GetBlockIndex(num_pages)};
if (heap_index < 0) { if (heap_index < 0) {
return ResultOutOfMemory; return ResultOutOfMemory;
} }
@ -113,7 +113,7 @@ ResultCode KMemoryManager::Allocate(KPageLinkedList& page_list, std::size_t num_
// Keep allocating until we've allocated all our pages // Keep allocating until we've allocated all our pages
for (s32 index{heap_index}; index >= 0 && num_pages > 0; index--) { for (s32 index{heap_index}; index >= 0 && num_pages > 0; index--) {
const auto pages_per_alloc{Memory::PageHeap::GetBlockNumPages(index)}; const auto pages_per_alloc{KPageHeap::GetBlockNumPages(index)};
while (num_pages >= pages_per_alloc) { while (num_pages >= pages_per_alloc) {
// Allocate a block // Allocate a block

View file

@ -10,14 +10,12 @@
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/memory/page_heap.h" #include "core/hle/kernel/k_page_heap.h"
#include "core/hle/result.h" #include "core/hle/result.h"
namespace Kernel { namespace Kernel {
class KPageLinkedList;
}
namespace Kernel { class KPageLinkedList;
class KMemoryManager final : NonCopyable { class KMemoryManager final : NonCopyable {
public: public:
@ -84,7 +82,7 @@ private:
using RefCount = u16; using RefCount = u16;
private: private:
Memory::PageHeap heap; KPageHeap heap;
Pool pool{}; Pool pool{};
public: public:

View file

@ -2,16 +2,13 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
// This file references various implementation details from Atmosphere, an open-source firmware for
// the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX.
#include "core/core.h" #include "core/core.h"
#include "core/hle/kernel/memory/page_heap.h" #include "core/hle/kernel/k_page_heap.h"
#include "core/memory.h" #include "core/memory.h"
namespace Kernel::Memory { namespace Kernel {
void PageHeap::Initialize(VAddr address, std::size_t size, std::size_t metadata_size) { void KPageHeap::Initialize(VAddr address, std::size_t size, std::size_t metadata_size) {
// Check our assumptions // Check our assumptions
ASSERT(Common::IsAligned((address), PageSize)); ASSERT(Common::IsAligned((address), PageSize));
ASSERT(Common::IsAligned(size, PageSize)); ASSERT(Common::IsAligned(size, PageSize));
@ -32,7 +29,7 @@ void PageHeap::Initialize(VAddr address, std::size_t size, std::size_t metadata_
} }
} }
VAddr PageHeap::AllocateBlock(s32 index, bool random) { VAddr KPageHeap::AllocateBlock(s32 index, bool random) {
const std::size_t needed_size{blocks[index].GetSize()}; const std::size_t needed_size{blocks[index].GetSize()};
for (s32 i{index}; i < static_cast<s32>(MemoryBlockPageShifts.size()); i++) { for (s32 i{index}; i < static_cast<s32>(MemoryBlockPageShifts.size()); i++) {
@ -48,13 +45,13 @@ VAddr PageHeap::AllocateBlock(s32 index, bool random) {
return 0; return 0;
} }
void PageHeap::FreeBlock(VAddr block, s32 index) { void KPageHeap::FreeBlock(VAddr block, s32 index) {
do { do {
block = blocks[index++].PushBlock(block); block = blocks[index++].PushBlock(block);
} while (block != 0); } while (block != 0);
} }
void PageHeap::Free(VAddr addr, std::size_t num_pages) { void KPageHeap::Free(VAddr addr, std::size_t num_pages) {
// Freeing no pages is a no-op // Freeing no pages is a no-op
if (num_pages == 0) { if (num_pages == 0) {
return; return;
@ -104,16 +101,16 @@ void PageHeap::Free(VAddr addr, std::size_t num_pages) {
} }
} }
std::size_t PageHeap::CalculateManagementOverheadSize(std::size_t region_size) { std::size_t KPageHeap::CalculateManagementOverheadSize(std::size_t region_size) {
std::size_t overhead_size = 0; std::size_t overhead_size = 0;
for (std::size_t i = 0; i < MemoryBlockPageShifts.size(); i++) { for (std::size_t i = 0; i < MemoryBlockPageShifts.size(); i++) {
const std::size_t cur_block_shift{MemoryBlockPageShifts[i]}; const std::size_t cur_block_shift{MemoryBlockPageShifts[i]};
const std::size_t next_block_shift{ const std::size_t next_block_shift{
(i != MemoryBlockPageShifts.size() - 1) ? MemoryBlockPageShifts[i + 1] : 0}; (i != MemoryBlockPageShifts.size() - 1) ? MemoryBlockPageShifts[i + 1] : 0};
overhead_size += PageHeap::Block::CalculateManagementOverheadSize( overhead_size += KPageHeap::Block::CalculateManagementOverheadSize(
region_size, cur_block_shift, next_block_shift); region_size, cur_block_shift, next_block_shift);
} }
return Common::AlignUp(overhead_size, PageSize); return Common::AlignUp(overhead_size, PageSize);
} }
} // namespace Kernel::Memory } // namespace Kernel

View file

@ -2,9 +2,6 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
// This file references various implementation details from Atmosphere, an open-source firmware for
// the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX.
#pragma once #pragma once
#include <array> #include <array>
@ -18,9 +15,9 @@
#include "core/hle/kernel/k_page_bitmap.h" #include "core/hle/kernel/k_page_bitmap.h"
#include "core/hle/kernel/memory_types.h" #include "core/hle/kernel/memory_types.h"
namespace Kernel::Memory { namespace Kernel {
class PageHeap final : NonCopyable { class KPageHeap final : NonCopyable {
public: public:
static constexpr s32 GetAlignedBlockIndex(std::size_t num_pages, std::size_t align_pages) { static constexpr s32 GetAlignedBlockIndex(std::size_t num_pages, std::size_t align_pages) {
const auto target_pages{std::max(num_pages, align_pages)}; const auto target_pages{std::max(num_pages, align_pages)};
@ -148,7 +145,7 @@ private:
}; };
public: public:
PageHeap() = default; KPageHeap() = default;
constexpr VAddr GetAddress() const { constexpr VAddr GetAddress() const {
return heap_address; return heap_address;
@ -193,4 +190,4 @@ private:
std::vector<u64> metadata; std::vector<u64> metadata;
}; };
} // namespace Kernel::Memory } // namespace Kernel

View file

@ -10,16 +10,16 @@
#include "core/hle/kernel/k_memory_block.h" #include "core/hle/kernel/k_memory_block.h"
#include "core/hle/kernel/k_memory_block_manager.h" #include "core/hle/kernel/k_memory_block_manager.h"
#include "core/hle/kernel/k_page_linked_list.h" #include "core/hle/kernel/k_page_linked_list.h"
#include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/k_resource_limit.h" #include "core/hle/kernel/k_resource_limit.h"
#include "core/hle/kernel/k_scoped_resource_reservation.h" #include "core/hle/kernel/k_scoped_resource_reservation.h"
#include "core/hle/kernel/k_system_control.h" #include "core/hle/kernel/k_system_control.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/memory/page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/kernel/svc_results.h" #include "core/hle/kernel/svc_results.h"
#include "core/memory.h" #include "core/memory.h"
namespace Kernel::Memory { namespace Kernel {
namespace { namespace {
@ -58,11 +58,11 @@ constexpr std::size_t GetSizeInRange(const KMemoryInfo& info, VAddr start, VAddr
} // namespace } // namespace
PageTable::PageTable(Core::System& system) : system{system} {} KPageTable::KPageTable(Core::System& system) : system{system} {}
ResultCode PageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, ResultCode KPageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_type,
bool enable_aslr, VAddr code_addr, std::size_t code_size, bool enable_aslr, VAddr code_addr,
KMemoryManager::Pool pool) { std::size_t code_size, KMemoryManager::Pool pool) {
const auto GetSpaceStart = [this](KAddressSpaceInfo::Type type) { const auto GetSpaceStart = [this](KAddressSpaceInfo::Type type) {
return KAddressSpaceInfo::GetAddressSpaceStart(address_space_width, type); return KAddressSpaceInfo::GetAddressSpaceStart(address_space_width, type);
@ -271,7 +271,7 @@ ResultCode PageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_t
return InitializeMemoryLayout(start, end); return InitializeMemoryLayout(start, end);
} }
ResultCode PageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryState state, ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryState state,
KMemoryPermission perm) { KMemoryPermission perm) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
@ -295,7 +295,7 @@ ResultCode PageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryS
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::MapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) { ResultCode KPageTable::MapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
const std::size_t num_pages{size / PageSize}; const std::size_t num_pages{size / PageSize};
@ -332,7 +332,7 @@ ResultCode PageTable::MapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std::
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::UnmapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) { ResultCode KPageTable::UnmapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
if (!size) { if (!size) {
@ -363,7 +363,7 @@ ResultCode PageTable::UnmapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
void PageTable::MapPhysicalMemory(KPageLinkedList& page_linked_list, VAddr start, VAddr end) { void KPageTable::MapPhysicalMemory(KPageLinkedList& page_linked_list, VAddr start, VAddr end) {
auto node{page_linked_list.Nodes().begin()}; auto node{page_linked_list.Nodes().begin()};
PAddr map_addr{node->GetAddress()}; PAddr map_addr{node->GetAddress()};
std::size_t src_num_pages{node->GetNumPages()}; std::size_t src_num_pages{node->GetNumPages()};
@ -395,7 +395,7 @@ void PageTable::MapPhysicalMemory(KPageLinkedList& page_linked_list, VAddr start
}); });
} }
ResultCode PageTable::MapPhysicalMemory(VAddr addr, std::size_t size) { ResultCode KPageTable::MapPhysicalMemory(VAddr addr, std::size_t size) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
std::size_t mapped_size{}; std::size_t mapped_size{};
@ -443,7 +443,7 @@ ResultCode PageTable::MapPhysicalMemory(VAddr addr, std::size_t size) {
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::UnmapPhysicalMemory(VAddr addr, std::size_t size) { ResultCode KPageTable::UnmapPhysicalMemory(VAddr addr, std::size_t size) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
const VAddr end_addr{addr + size}; const VAddr end_addr{addr + size};
@ -480,7 +480,7 @@ ResultCode PageTable::UnmapPhysicalMemory(VAddr addr, std::size_t size) {
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::UnmapMemory(VAddr addr, std::size_t size) { ResultCode KPageTable::UnmapMemory(VAddr addr, std::size_t size) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
const VAddr end_addr{addr + size}; const VAddr end_addr{addr + size};
@ -516,7 +516,7 @@ ResultCode PageTable::UnmapMemory(VAddr addr, std::size_t size) {
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::Map(VAddr dst_addr, VAddr src_addr, std::size_t size) { ResultCode KPageTable::Map(VAddr dst_addr, VAddr src_addr, std::size_t size) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
KMemoryState src_state{}; KMemoryState src_state{};
@ -555,7 +555,7 @@ ResultCode PageTable::Map(VAddr dst_addr, VAddr src_addr, std::size_t size) {
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::Unmap(VAddr dst_addr, VAddr src_addr, std::size_t size) { ResultCode KPageTable::Unmap(VAddr dst_addr, VAddr src_addr, std::size_t size) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
KMemoryState src_state{}; KMemoryState src_state{};
@ -597,7 +597,7 @@ ResultCode PageTable::Unmap(VAddr dst_addr, VAddr src_addr, std::size_t size) {
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_list, ResultCode KPageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_list,
KMemoryPermission perm) { KMemoryPermission perm) {
VAddr cur_addr{addr}; VAddr cur_addr{addr};
@ -619,7 +619,7 @@ ResultCode PageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_li
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::MapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state, ResultCode KPageTable::MapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state,
KMemoryPermission perm) { KMemoryPermission perm) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
@ -641,7 +641,7 @@ ResultCode PageTable::MapPages(VAddr addr, KPageLinkedList& page_linked_list, KM
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::SetCodeMemoryPermission(VAddr addr, std::size_t size, ResultCode KPageTable::SetCodeMemoryPermission(VAddr addr, std::size_t size,
KMemoryPermission perm) { KMemoryPermission perm) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
@ -689,13 +689,13 @@ ResultCode PageTable::SetCodeMemoryPermission(VAddr addr, std::size_t size,
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
KMemoryInfo PageTable::QueryInfoImpl(VAddr addr) { KMemoryInfo KPageTable::QueryInfoImpl(VAddr addr) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
return block_manager->FindBlock(addr).GetMemoryInfo(); return block_manager->FindBlock(addr).GetMemoryInfo();
} }
KMemoryInfo PageTable::QueryInfo(VAddr addr) { KMemoryInfo KPageTable::QueryInfo(VAddr addr) {
if (!Contains(addr, 1)) { if (!Contains(addr, 1)) {
return {address_space_end, 0 - address_space_end, KMemoryState::Inaccessible, return {address_space_end, 0 - address_space_end, KMemoryState::Inaccessible,
KMemoryPermission::None, KMemoryAttribute::None, KMemoryPermission::None}; KMemoryPermission::None, KMemoryAttribute::None, KMemoryPermission::None};
@ -704,7 +704,7 @@ KMemoryInfo PageTable::QueryInfo(VAddr addr) {
return QueryInfoImpl(addr); return QueryInfoImpl(addr);
} }
ResultCode PageTable::ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm) { ResultCode KPageTable::ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
KMemoryState state{}; KMemoryState state{};
@ -722,7 +722,7 @@ ResultCode PageTable::ReserveTransferMemory(VAddr addr, std::size_t size, KMemor
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::ResetTransferMemory(VAddr addr, std::size_t size) { ResultCode KPageTable::ResetTransferMemory(VAddr addr, std::size_t size) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
KMemoryState state{}; KMemoryState state{};
@ -739,7 +739,7 @@ ResultCode PageTable::ResetTransferMemory(VAddr addr, std::size_t size) {
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::SetMemoryAttribute(VAddr addr, std::size_t size, KMemoryAttribute mask, ResultCode KPageTable::SetMemoryAttribute(VAddr addr, std::size_t size, KMemoryAttribute mask,
KMemoryAttribute value) { KMemoryAttribute value) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
@ -761,13 +761,13 @@ ResultCode PageTable::SetMemoryAttribute(VAddr addr, std::size_t size, KMemoryAt
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::SetHeapCapacity(std::size_t new_heap_capacity) { ResultCode KPageTable::SetHeapCapacity(std::size_t new_heap_capacity) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
heap_capacity = new_heap_capacity; heap_capacity = new_heap_capacity;
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultVal<VAddr> PageTable::SetHeapSize(std::size_t size) { ResultVal<VAddr> KPageTable::SetHeapSize(std::size_t size) {
if (size > heap_region_end - heap_region_start) { if (size > heap_region_end - heap_region_start) {
return ResultOutOfMemory; return ResultOutOfMemory;
@ -818,7 +818,7 @@ ResultVal<VAddr> PageTable::SetHeapSize(std::size_t size) {
return MakeResult<VAddr>(heap_region_start); return MakeResult<VAddr>(heap_region_start);
} }
ResultVal<VAddr> PageTable::AllocateAndMapMemory(std::size_t needed_num_pages, std::size_t align, ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages, std::size_t align,
bool is_map_only, VAddr region_start, bool is_map_only, VAddr region_start,
std::size_t region_num_pages, KMemoryState state, std::size_t region_num_pages, KMemoryState state,
KMemoryPermission perm, PAddr map_addr) { KMemoryPermission perm, PAddr map_addr) {
@ -852,7 +852,7 @@ ResultVal<VAddr> PageTable::AllocateAndMapMemory(std::size_t needed_num_pages, s
return MakeResult<VAddr>(addr); return MakeResult<VAddr>(addr);
} }
ResultCode PageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) { ResultCode KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
KMemoryPermission perm{}; KMemoryPermission perm{};
@ -875,7 +875,7 @@ ResultCode PageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) {
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size) { ResultCode KPageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
KMemoryPermission perm{}; KMemoryPermission perm{};
@ -898,13 +898,13 @@ ResultCode PageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size)
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::InitializeMemoryLayout(VAddr start, VAddr end) { ResultCode KPageTable::InitializeMemoryLayout(VAddr start, VAddr end) {
block_manager = std::make_unique<KMemoryBlockManager>(start, end); block_manager = std::make_unique<KMemoryBlockManager>(start, end);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
bool PageTable::IsRegionMapped(VAddr address, u64 size) { bool KPageTable::IsRegionMapped(VAddr address, u64 size) {
return CheckMemoryState(address, size, KMemoryState::All, KMemoryState::Free, return CheckMemoryState(address, size, KMemoryState::All, KMemoryState::Free,
KMemoryPermission::Mask, KMemoryPermission::None, KMemoryPermission::Mask, KMemoryPermission::None,
KMemoryAttribute::Mask, KMemoryAttribute::None, KMemoryAttribute::Mask, KMemoryAttribute::None,
@ -912,7 +912,7 @@ bool PageTable::IsRegionMapped(VAddr address, u64 size) {
.IsError(); .IsError();
} }
bool PageTable::IsRegionContiguous(VAddr addr, u64 size) const { bool KPageTable::IsRegionContiguous(VAddr addr, u64 size) const {
auto start_ptr = system.Memory().GetPointer(addr); auto start_ptr = system.Memory().GetPointer(addr);
for (u64 offset{}; offset < size; offset += PageSize) { for (u64 offset{}; offset < size; offset += PageSize) {
if (start_ptr != system.Memory().GetPointer(addr + offset)) { if (start_ptr != system.Memory().GetPointer(addr + offset)) {
@ -923,7 +923,7 @@ bool PageTable::IsRegionContiguous(VAddr addr, u64 size) const {
return true; return true;
} }
void PageTable::AddRegionToPages(VAddr start, std::size_t num_pages, void KPageTable::AddRegionToPages(VAddr start, std::size_t num_pages,
KPageLinkedList& page_linked_list) { KPageLinkedList& page_linked_list) {
VAddr addr{start}; VAddr addr{start};
while (addr < start + (num_pages * PageSize)) { while (addr < start + (num_pages * PageSize)) {
@ -936,7 +936,7 @@ void PageTable::AddRegionToPages(VAddr start, std::size_t num_pages,
} }
} }
VAddr PageTable::AllocateVirtualMemory(VAddr start, std::size_t region_num_pages, VAddr KPageTable::AllocateVirtualMemory(VAddr start, std::size_t region_num_pages,
u64 needed_num_pages, std::size_t align) { u64 needed_num_pages, std::size_t align) {
if (is_aslr_enabled) { if (is_aslr_enabled) {
UNIMPLEMENTED(); UNIMPLEMENTED();
@ -945,7 +945,7 @@ VAddr PageTable::AllocateVirtualMemory(VAddr start, std::size_t region_num_pages
IsKernel() ? 1 : 4); IsKernel() ? 1 : 4);
} }
ResultCode PageTable::Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& page_group, ResultCode KPageTable::Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& page_group,
OperationType operation) { OperationType operation) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
@ -970,7 +970,7 @@ ResultCode PageTable::Operate(VAddr addr, std::size_t num_pages, const KPageLink
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm, ResultCode KPageTable::Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm,
OperationType operation, PAddr map_addr) { OperationType operation, PAddr map_addr) {
std::lock_guard lock{page_table_lock}; std::lock_guard lock{page_table_lock};
@ -997,7 +997,7 @@ ResultCode PageTable::Operate(VAddr addr, std::size_t num_pages, KMemoryPermissi
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
constexpr VAddr PageTable::GetRegionAddress(KMemoryState state) const { constexpr VAddr KPageTable::GetRegionAddress(KMemoryState state) const {
switch (state) { switch (state) {
case KMemoryState::Free: case KMemoryState::Free:
case KMemoryState::Kernel: case KMemoryState::Kernel:
@ -1032,7 +1032,7 @@ constexpr VAddr PageTable::GetRegionAddress(KMemoryState state) const {
} }
} }
constexpr std::size_t PageTable::GetRegionSize(KMemoryState state) const { constexpr std::size_t KPageTable::GetRegionSize(KMemoryState state) const {
switch (state) { switch (state) {
case KMemoryState::Free: case KMemoryState::Free:
case KMemoryState::Kernel: case KMemoryState::Kernel:
@ -1067,7 +1067,7 @@ constexpr std::size_t PageTable::GetRegionSize(KMemoryState state) const {
} }
} }
constexpr bool PageTable::CanContain(VAddr addr, std::size_t size, KMemoryState state) const { constexpr bool KPageTable::CanContain(VAddr addr, std::size_t size, KMemoryState state) const {
const VAddr end{addr + size}; const VAddr end{addr + size};
const VAddr last{end - 1}; const VAddr last{end - 1};
const VAddr region_start{GetRegionAddress(state)}; const VAddr region_start{GetRegionAddress(state)};
@ -1109,9 +1109,10 @@ constexpr bool PageTable::CanContain(VAddr addr, std::size_t size, KMemoryState
} }
} }
constexpr ResultCode PageTable::CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask, constexpr ResultCode KPageTable::CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask,
KMemoryState state, KMemoryPermission perm_mask, KMemoryState state, KMemoryPermission perm_mask,
KMemoryPermission perm, KMemoryAttribute attr_mask, KMemoryPermission perm,
KMemoryAttribute attr_mask,
KMemoryAttribute attr) const { KMemoryAttribute attr) const {
// Validate the states match expectation // Validate the states match expectation
if ((info.state & state_mask) != state) { if ((info.state & state_mask) != state) {
@ -1127,7 +1128,7 @@ constexpr ResultCode PageTable::CheckMemoryState(const KMemoryInfo& info, KMemor
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode PageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm, ResultCode KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm,
KMemoryAttribute* out_attr, VAddr addr, std::size_t size, KMemoryAttribute* out_attr, VAddr addr, std::size_t size,
KMemoryState state_mask, KMemoryState state, KMemoryState state_mask, KMemoryState state,
KMemoryPermission perm_mask, KMemoryPermission perm, KMemoryPermission perm_mask, KMemoryPermission perm,
@ -1186,4 +1187,4 @@ ResultCode PageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermissio
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
} // namespace Kernel::Memory } // namespace Kernel

View file

@ -19,14 +19,12 @@ class System;
} }
namespace Kernel { namespace Kernel {
class KMemoryBlockManager; class KMemoryBlockManager;
}
namespace Kernel::Memory { class KPageTable final : NonCopyable {
class PageTable final : NonCopyable {
public: public:
explicit PageTable(Core::System& system); explicit KPageTable(Core::System& system);
ResultCode InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, bool enable_aslr, ResultCode InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, bool enable_aslr,
VAddr code_addr, std::size_t code_size, VAddr code_addr, std::size_t code_size,
@ -278,4 +276,4 @@ private:
Core::System& system; Core::System& system;
}; };
} // namespace Kernel::Memory } // namespace Kernel

View file

@ -4,10 +4,10 @@
#include "common/assert.h" #include "common/assert.h"
#include "core/core.h" #include "core/core.h"
#include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/k_scoped_resource_reservation.h" #include "core/hle/kernel/k_scoped_resource_reservation.h"
#include "core/hle/kernel/k_shared_memory.h" #include "core/hle/kernel/k_shared_memory.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/memory/page_table.h"
namespace Kernel { namespace Kernel {
@ -21,8 +21,7 @@ KSharedMemory::~KSharedMemory() {
std::shared_ptr<KSharedMemory> KSharedMemory::Create( std::shared_ptr<KSharedMemory> KSharedMemory::Create(
KernelCore& kernel, Core::DeviceMemory& device_memory, Process* owner_process, KernelCore& kernel, Core::DeviceMemory& device_memory, Process* owner_process,
KPageLinkedList&& page_list, KMemoryPermission owner_permission, KPageLinkedList&& page_list, KMemoryPermission owner_permission,
KMemoryPermission user_permission, PAddr physical_address, std::size_t size, KMemoryPermission user_permission, PAddr physical_address, std::size_t size, std::string name) {
std::string name) {
const auto resource_limit = kernel.GetSystemResourceLimit(); const auto resource_limit = kernel.GetSystemResourceLimit();
KScopedResourceReservation memory_reservation(resource_limit, LimitableResource::PhysicalMemory, KScopedResourceReservation memory_reservation(resource_limit, LimitableResource::PhysicalMemory,

View file

@ -15,13 +15,13 @@
#include "core/file_sys/program_metadata.h" #include "core/file_sys/program_metadata.h"
#include "core/hle/kernel/code_set.h" #include "core/hle/kernel/code_set.h"
#include "core/hle/kernel/k_memory_block_manager.h" #include "core/hle/kernel/k_memory_block_manager.h"
#include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/k_resource_limit.h" #include "core/hle/kernel/k_resource_limit.h"
#include "core/hle/kernel/k_scheduler.h" #include "core/hle/kernel/k_scheduler.h"
#include "core/hle/kernel/k_scoped_resource_reservation.h" #include "core/hle/kernel/k_scoped_resource_reservation.h"
#include "core/hle/kernel/k_slab_heap.h" #include "core/hle/kernel/k_slab_heap.h"
#include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/k_thread.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/memory/page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/kernel/svc_results.h" #include "core/hle/kernel/svc_results.h"
#include "core/hle/lock.h" #include "core/hle/lock.h"
@ -464,9 +464,9 @@ bool Process::IsSignaled() const {
} }
Process::Process(Core::System& system) Process::Process(Core::System& system)
: KSynchronizationObject{system.Kernel()}, : KSynchronizationObject{system.Kernel()}, page_table{std::make_unique<KPageTable>(system)},
page_table{std::make_unique<Memory::PageTable>(system)}, handle_table{system.Kernel()}, handle_table{system.Kernel()}, address_arbiter{system}, condition_var{system},
address_arbiter{system}, condition_var{system}, state_lock{system.Kernel()}, system{system} {} state_lock{system.Kernel()}, system{system} {}
Process::~Process() = default; Process::~Process() = default;

View file

@ -29,16 +29,13 @@ class ProgramMetadata;
namespace Kernel { namespace Kernel {
class KernelCore; class KernelCore;
class KPageTable;
class KResourceLimit; class KResourceLimit;
class KThread; class KThread;
class TLSPage; class TLSPage;
struct CodeSet; struct CodeSet;
namespace Memory {
class PageTable;
}
enum class MemoryRegion : u16 { enum class MemoryRegion : u16 {
APPLICATION = 1, APPLICATION = 1,
SYSTEM = 2, SYSTEM = 2,
@ -104,12 +101,12 @@ public:
} }
/// Gets a reference to the process' page table. /// Gets a reference to the process' page table.
Memory::PageTable& PageTable() { KPageTable& PageTable() {
return *page_table; return *page_table;
} }
/// Gets const a reference to the process' page table. /// Gets const a reference to the process' page table.
const Memory::PageTable& PageTable() const { const KPageTable& PageTable() const {
return *page_table; return *page_table;
} }
@ -385,7 +382,7 @@ private:
ResultCode AllocateMainThreadStack(std::size_t stack_size); ResultCode AllocateMainThreadStack(std::size_t stack_size);
/// Memory manager for this process /// Memory manager for this process
std::unique_ptr<Memory::PageTable> page_table; std::unique_ptr<KPageTable> page_table;
/// Current status of the process /// Current status of the process
ProcessStatus status{}; ProcessStatus status{};

View file

@ -7,7 +7,7 @@
#include "common/bit_util.h" #include "common/bit_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/process_capability.h" #include "core/hle/kernel/process_capability.h"
#include "core/hle/kernel/svc_results.h" #include "core/hle/kernel/svc_results.h"
@ -69,7 +69,7 @@ u32 GetFlagBitOffset(CapabilityType type) {
ResultCode ProcessCapabilities::InitializeForKernelProcess(const u32* capabilities, ResultCode ProcessCapabilities::InitializeForKernelProcess(const u32* capabilities,
std::size_t num_capabilities, std::size_t num_capabilities,
Memory::PageTable& page_table) { KPageTable& page_table) {
Clear(); Clear();
// Allow all cores and priorities. // Allow all cores and priorities.
@ -82,7 +82,7 @@ ResultCode ProcessCapabilities::InitializeForKernelProcess(const u32* capabiliti
ResultCode ProcessCapabilities::InitializeForUserProcess(const u32* capabilities, ResultCode ProcessCapabilities::InitializeForUserProcess(const u32* capabilities,
std::size_t num_capabilities, std::size_t num_capabilities,
Memory::PageTable& page_table) { KPageTable& page_table) {
Clear(); Clear();
return ParseCapabilities(capabilities, num_capabilities, page_table); return ParseCapabilities(capabilities, num_capabilities, page_table);
@ -108,7 +108,7 @@ void ProcessCapabilities::InitializeForMetadatalessProcess() {
ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities, ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities,
std::size_t num_capabilities, std::size_t num_capabilities,
Memory::PageTable& page_table) { KPageTable& page_table) {
u32 set_flags = 0; u32 set_flags = 0;
u32 set_svc_bits = 0; u32 set_svc_bits = 0;
@ -155,7 +155,7 @@ ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities,
} }
ResultCode ProcessCapabilities::ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, ResultCode ProcessCapabilities::ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits,
u32 flag, Memory::PageTable& page_table) { u32 flag, KPageTable& page_table) {
const auto type = GetCapabilityType(flag); const auto type = GetCapabilityType(flag);
if (type == CapabilityType::Unset) { if (type == CapabilityType::Unset) {
@ -293,12 +293,12 @@ ResultCode ProcessCapabilities::HandleSyscallFlags(u32& set_svc_bits, u32 flags)
} }
ResultCode ProcessCapabilities::HandleMapPhysicalFlags(u32 flags, u32 size_flags, ResultCode ProcessCapabilities::HandleMapPhysicalFlags(u32 flags, u32 size_flags,
Memory::PageTable& page_table) { KPageTable& page_table) {
// TODO(Lioncache): Implement once the memory manager can handle this. // TODO(Lioncache): Implement once the memory manager can handle this.
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode ProcessCapabilities::HandleMapIOFlags(u32 flags, Memory::PageTable& page_table) { ResultCode ProcessCapabilities::HandleMapIOFlags(u32 flags, KPageTable& page_table) {
// TODO(Lioncache): Implement once the memory manager can handle this. // TODO(Lioncache): Implement once the memory manager can handle this.
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }

View file

@ -12,9 +12,7 @@ union ResultCode;
namespace Kernel { namespace Kernel {
namespace Memory { class KPageTable;
class PageTable;
}
/// The possible types of programs that may be indicated /// The possible types of programs that may be indicated
/// by the program type capability descriptor. /// by the program type capability descriptor.
@ -90,7 +88,7 @@ public:
/// otherwise, an error code upon failure. /// otherwise, an error code upon failure.
/// ///
ResultCode InitializeForKernelProcess(const u32* capabilities, std::size_t num_capabilities, ResultCode InitializeForKernelProcess(const u32* capabilities, std::size_t num_capabilities,
Memory::PageTable& page_table); KPageTable& page_table);
/// Initializes this process capabilities instance for a userland process. /// Initializes this process capabilities instance for a userland process.
/// ///
@ -103,7 +101,7 @@ public:
/// otherwise, an error code upon failure. /// otherwise, an error code upon failure.
/// ///
ResultCode InitializeForUserProcess(const u32* capabilities, std::size_t num_capabilities, ResultCode InitializeForUserProcess(const u32* capabilities, std::size_t num_capabilities,
Memory::PageTable& page_table); KPageTable& page_table);
/// Initializes this process capabilities instance for a process that does not /// Initializes this process capabilities instance for a process that does not
/// have any metadata to parse. /// have any metadata to parse.
@ -189,7 +187,7 @@ private:
/// @return RESULT_SUCCESS if no errors occur, otherwise an error code. /// @return RESULT_SUCCESS if no errors occur, otherwise an error code.
/// ///
ResultCode ParseCapabilities(const u32* capabilities, std::size_t num_capabilities, ResultCode ParseCapabilities(const u32* capabilities, std::size_t num_capabilities,
Memory::PageTable& page_table); KPageTable& page_table);
/// Attempts to parse a capability descriptor that is only represented by a /// Attempts to parse a capability descriptor that is only represented by a
/// single flag set. /// single flag set.
@ -204,7 +202,7 @@ private:
/// @return RESULT_SUCCESS if no errors occurred, otherwise an error code. /// @return RESULT_SUCCESS if no errors occurred, otherwise an error code.
/// ///
ResultCode ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, u32 flag, ResultCode ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, u32 flag,
Memory::PageTable& page_table); KPageTable& page_table);
/// Clears the internal state of this process capability instance. Necessary, /// Clears the internal state of this process capability instance. Necessary,
/// to have a sane starting point due to us allowing running executables without /// to have a sane starting point due to us allowing running executables without
@ -228,10 +226,10 @@ private:
ResultCode HandleSyscallFlags(u32& set_svc_bits, u32 flags); ResultCode HandleSyscallFlags(u32& set_svc_bits, u32 flags);
/// Handles flags related to mapping physical memory pages. /// Handles flags related to mapping physical memory pages.
ResultCode HandleMapPhysicalFlags(u32 flags, u32 size_flags, Memory::PageTable& page_table); ResultCode HandleMapPhysicalFlags(u32 flags, u32 size_flags, KPageTable& page_table);
/// Handles flags related to mapping IO pages. /// Handles flags related to mapping IO pages.
ResultCode HandleMapIOFlags(u32 flags, Memory::PageTable& page_table); ResultCode HandleMapIOFlags(u32 flags, KPageTable& page_table);
/// Handles flags related to the interrupt capability flags. /// Handles flags related to the interrupt capability flags.
ResultCode HandleInterruptFlags(u32 flags); ResultCode HandleInterruptFlags(u32 flags);

View file

@ -29,6 +29,7 @@
#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_event.h"
#include "core/hle/kernel/k_memory_block.h" #include "core/hle/kernel/k_memory_block.h"
#include "core/hle/kernel/k_memory_layout.h" #include "core/hle/kernel/k_memory_layout.h"
#include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_readable_event.h"
#include "core/hle/kernel/k_resource_limit.h" #include "core/hle/kernel/k_resource_limit.h"
#include "core/hle/kernel/k_scheduler.h" #include "core/hle/kernel/k_scheduler.h"
@ -39,7 +40,6 @@
#include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/k_thread.h"
#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/k_writable_event.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/memory/page_table.h"
#include "core/hle/kernel/physical_core.h" #include "core/hle/kernel/physical_core.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/kernel/svc.h" #include "core/hle/kernel/svc.h"
@ -67,8 +67,8 @@ constexpr bool IsValidAddressRange(VAddr address, u64 size) {
// Helper function that performs the common sanity checks for svcMapMemory // Helper function that performs the common sanity checks for svcMapMemory
// and svcUnmapMemory. This is doable, as both functions perform their sanitizing // and svcUnmapMemory. This is doable, as both functions perform their sanitizing
// in the same order. // in the same order.
ResultCode MapUnmapMemorySanityChecks(const Memory::PageTable& manager, VAddr dst_addr, ResultCode MapUnmapMemorySanityChecks(const KPageTable& manager, VAddr dst_addr, VAddr src_addr,
VAddr src_addr, u64 size) { u64 size) {
if (!Common::Is4KBAligned(dst_addr)) { if (!Common::Is4KBAligned(dst_addr)) {
LOG_ERROR(Kernel_SVC, "Destination address is not aligned to 4KB, 0x{:016X}", dst_addr); LOG_ERROR(Kernel_SVC, "Destination address is not aligned to 4KB, 0x{:016X}", dst_addr);
return ResultInvalidAddress; return ResultInvalidAddress;

View file

@ -2,9 +2,9 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/k_resource_limit.h" #include "core/hle/kernel/k_resource_limit.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/memory/page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/kernel/transfer_memory.h" #include "core/hle/kernel/transfer_memory.h"
#include "core/hle/result.h" #include "core/hle/result.h"

View file

@ -11,8 +11,8 @@
#include "common/scope_exit.h" #include "common/scope_exit.h"
#include "core/core.h" #include "core/core.h"
#include "core/hle/ipc_helpers.h" #include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/k_system_control.h" #include "core/hle/kernel/k_system_control.h"
#include "core/hle/kernel/memory/page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/kernel/svc_results.h" #include "core/hle/kernel/svc_results.h"
#include "core/hle/service/ldr/ldr.h" #include "core/hle/service/ldr/ldr.h"
@ -287,8 +287,7 @@ public:
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
} }
bool ValidateRegionForMap(Kernel::Memory::PageTable& page_table, VAddr start, bool ValidateRegionForMap(Kernel::KPageTable& page_table, VAddr start, std::size_t size) const {
std::size_t size) const {
constexpr std::size_t padding_size{4 * Kernel::PageSize}; constexpr std::size_t padding_size{4 * Kernel::PageSize};
const auto start_info{page_table.QueryInfo(start - 1)}; const auto start_info{page_table.QueryInfo(start - 1)};
@ -309,7 +308,7 @@ public:
return (start + size + padding_size) <= (end_info.GetAddress() + end_info.GetSize()); return (start + size + padding_size) <= (end_info.GetAddress() + end_info.GetSize());
} }
VAddr GetRandomMapRegion(const Kernel::Memory::PageTable& page_table, std::size_t size) const { VAddr GetRandomMapRegion(const Kernel::KPageTable& page_table, std::size_t size) const {
VAddr addr{}; VAddr addr{};
const std::size_t end_pages{(page_table.GetAliasCodeRegionSize() - size) >> const std::size_t end_pages{(page_table.GetAliasCodeRegionSize() - size) >>
Kernel::PageBits}; Kernel::PageBits};

View file

@ -12,8 +12,8 @@
#include "core/file_sys/control_metadata.h" #include "core/file_sys/control_metadata.h"
#include "core/file_sys/patch_manager.h" #include "core/file_sys/patch_manager.h"
#include "core/file_sys/romfs_factory.h" #include "core/file_sys/romfs_factory.h"
#include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/memory/page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/filesystem/filesystem.h"
#include "core/loader/deconstructed_rom_directory.h" #include "core/loader/deconstructed_rom_directory.h"

View file

@ -10,7 +10,7 @@
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/hle/kernel/code_set.h" #include "core/hle/kernel/code_set.h"
#include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/loader/elf.h" #include "core/loader/elf.h"
#include "core/memory.h" #include "core/memory.h"

View file

@ -6,7 +6,7 @@
#include "core/file_sys/kernel_executable.h" #include "core/file_sys/kernel_executable.h"
#include "core/file_sys/program_metadata.h" #include "core/file_sys/program_metadata.h"
#include "core/hle/kernel/code_set.h" #include "core/hle/kernel/code_set.h"
#include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/loader/kip.h" #include "core/loader/kip.h"
#include "core/memory.h" #include "core/memory.h"

View file

@ -15,8 +15,8 @@
#include "core/file_sys/romfs_factory.h" #include "core/file_sys/romfs_factory.h"
#include "core/file_sys/vfs_offset.h" #include "core/file_sys/vfs_offset.h"
#include "core/hle/kernel/code_set.h" #include "core/hle/kernel/code_set.h"
#include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/k_thread.h"
#include "core/hle/kernel/memory/page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/filesystem/filesystem.h"
#include "core/loader/nro.h" #include "core/loader/nro.h"

View file

@ -15,8 +15,8 @@
#include "core/core.h" #include "core/core.h"
#include "core/file_sys/patch_manager.h" #include "core/file_sys/patch_manager.h"
#include "core/hle/kernel/code_set.h" #include "core/hle/kernel/code_set.h"
#include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/k_thread.h"
#include "core/hle/kernel/memory/page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/loader/nso.h" #include "core/loader/nso.h"
#include "core/memory.h" #include "core/memory.h"

View file

@ -16,7 +16,7 @@
#include "core/arm/arm_interface.h" #include "core/arm/arm_interface.h"
#include "core/core.h" #include "core/core.h"
#include "core/device_memory.h" #include "core/device_memory.h"
#include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/physical_memory.h" #include "core/hle/kernel/physical_memory.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/memory.h" #include "core/memory.h"

View file

@ -10,7 +10,7 @@
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/core_timing_util.h" #include "core/core_timing_util.h"
#include "core/hardware_properties.h" #include "core/hardware_properties.h"
#include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/service/hid/controllers/npad.h" #include "core/hle/service/hid/controllers/npad.h"
#include "core/hle/service/hid/hid.h" #include "core/hle/service/hid/hid.h"

View file

@ -17,7 +17,7 @@
#include "core/arm/arm_interface.h" #include "core/arm/arm_interface.h"
#include "core/core.h" #include "core/core.h"
#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/hle_ipc.h"
#include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/result.h" #include "core/hle/result.h"
#include "core/memory.h" #include "core/memory.h"

View file

@ -6,7 +6,7 @@
#include "common/assert.h" #include "common/assert.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/core.h" #include "core/core.h"
#include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/memory.h" #include "core/memory.h"
#include "video_core/gpu.h" #include "video_core/gpu.h"