Added Check() function

This commit is contained in:
Alex 2022-11-01 19:57:15 +02:00
parent 7a7af76661
commit 00cda98a62
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
2 changed files with 36 additions and 0 deletions

View File

@ -5,6 +5,28 @@
namespace Memory
{
bool Virtual::Check(void *VirtualAddress)
{
// 0x1000 aligned
uint64_t Address = (uint64_t)VirtualAddress;
Address &= 0xFFFFFFFFFFFFF000;
debug("%#lx=>%#lx", VirtualAddress, Address);
PageMapIndexer Index = PageMapIndexer((uint64_t)Address);
PageDirectoryEntry PDE = this->Table->Entries[Index.PDP_i];
debug("%x %x %x %x %x %x %x %x %x %x %x %p-%#llx",
PDE.Value.Present, PDE.Value.ReadWrite,
PDE.Value.UserSupervisor, PDE.Value.WriteThrough,
PDE.Value.CacheDisable, PDE.Value.Accessed,
PDE.Value.Dirty, PDE.Value.PageSize,
PDE.Value.Global, PDE.Value.PageAttributeTable,
PDE.Value.ExecuteDisable, PDE.GetAddress(),
PDE.Value);
if (!PDE.GetFlag(PTFlag::P))
return false;
return true;
}
void Virtual::Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags)
{
SmartLock(this->MemoryLock);

View File

@ -389,6 +389,15 @@ namespace Memory
};
public:
/**
* @brief Check if page is present
*
* @param VirtualAddress Virtual address of the page
* @return true if page is present
* @return false if page is not present
*/
bool Check(void *VirtualAddress);
/**
* @brief Map page.
*
@ -397,6 +406,7 @@ namespace Memory
* @param Flags Flags of the page. Check PTFlag enum.
*/
void Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags);
/**
* @brief Map multiple pages.
*
@ -406,12 +416,14 @@ namespace Memory
* @param Flags Flags of the page. Check PTFlag enum.
*/
void Map(void *VirtualAddress, void *PhysicalAddress, uint64_t PageCount, uint64_t Flags);
/**
* @brief Unmap page.
*
* @param VirtualAddress Virtual address of the page.
*/
void Unmap(void *VirtualAddress);
/**
* @brief Unmap multiple pages.
*
@ -419,12 +431,14 @@ namespace Memory
* @param PageCount Number of pages.
*/
void Unmap(void *VirtualAddress, uint64_t PageCount);
/**
* @brief Construct a new Virtual object
*
* @param Table Page table. If null, it will use the current page table.
*/
Virtual(PageTable *Table = nullptr);
/**
* @brief Destroy the Virtual object
*