kernel: add KPageTableBase

Co-authored-by: Kelebek1 <eeeedddccc@hotmail.co.uk>
This commit is contained in:
Liam
2023-10-22 21:16:38 -04:00
parent 2f9487cd38
commit 2a255b2d61
31 changed files with 7202 additions and 4877 deletions

View File

@ -6,6 +6,7 @@
#include <atomic>
#include "common/common_types.h"
#include "common/typed_address.h"
#include "common/virtual_buffer.h"
namespace Common {
@ -100,9 +101,9 @@ struct PageTable {
PageTable(PageTable&&) noexcept = default;
PageTable& operator=(PageTable&&) noexcept = default;
bool BeginTraversal(TraversalEntry& out_entry, TraversalContext& out_context,
u64 address) const;
bool ContinueTraversal(TraversalEntry& out_entry, TraversalContext& context) const;
bool BeginTraversal(TraversalEntry* out_entry, TraversalContext* out_context,
Common::ProcessAddress address) const;
bool ContinueTraversal(TraversalEntry* out_entry, TraversalContext* context) const;
/**
* Resizes the page table to be able to accommodate enough pages within
@ -117,6 +118,16 @@ struct PageTable {
return current_address_space_width_in_bits;
}
bool GetPhysicalAddress(Common::PhysicalAddress* out_phys_addr,
Common::ProcessAddress virt_addr) const {
if (virt_addr > (1ULL << this->GetAddressSpaceBits())) {
return false;
}
*out_phys_addr = backing_addr[virt_addr / page_size] + GetInteger(virt_addr);
return true;
}
/**
* Vector of memory pointers backing each page. An entry can only be non-null if the
* corresponding attribute element is of type `Memory`.