mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Added Check() function
This commit is contained in:
parent
7a7af76661
commit
00cda98a62
@ -5,6 +5,28 @@
|
|||||||
|
|
||||||
namespace Memory
|
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)
|
void Virtual::Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags)
|
||||||
{
|
{
|
||||||
SmartLock(this->MemoryLock);
|
SmartLock(this->MemoryLock);
|
||||||
|
@ -389,6 +389,15 @@ namespace Memory
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
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.
|
* @brief Map page.
|
||||||
*
|
*
|
||||||
@ -397,6 +406,7 @@ namespace Memory
|
|||||||
* @param Flags Flags of the page. Check PTFlag enum.
|
* @param Flags Flags of the page. Check PTFlag enum.
|
||||||
*/
|
*/
|
||||||
void Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags);
|
void Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Map multiple pages.
|
* @brief Map multiple pages.
|
||||||
*
|
*
|
||||||
@ -406,12 +416,14 @@ namespace Memory
|
|||||||
* @param Flags Flags of the page. Check PTFlag enum.
|
* @param Flags Flags of the page. Check PTFlag enum.
|
||||||
*/
|
*/
|
||||||
void Map(void *VirtualAddress, void *PhysicalAddress, uint64_t PageCount, uint64_t Flags);
|
void Map(void *VirtualAddress, void *PhysicalAddress, uint64_t PageCount, uint64_t Flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Unmap page.
|
* @brief Unmap page.
|
||||||
*
|
*
|
||||||
* @param VirtualAddress Virtual address of the page.
|
* @param VirtualAddress Virtual address of the page.
|
||||||
*/
|
*/
|
||||||
void Unmap(void *VirtualAddress);
|
void Unmap(void *VirtualAddress);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Unmap multiple pages.
|
* @brief Unmap multiple pages.
|
||||||
*
|
*
|
||||||
@ -419,12 +431,14 @@ namespace Memory
|
|||||||
* @param PageCount Number of pages.
|
* @param PageCount Number of pages.
|
||||||
*/
|
*/
|
||||||
void Unmap(void *VirtualAddress, uint64_t PageCount);
|
void Unmap(void *VirtualAddress, uint64_t PageCount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Construct a new Virtual object
|
* @brief Construct a new Virtual object
|
||||||
*
|
*
|
||||||
* @param Table Page table. If null, it will use the current page table.
|
* @param Table Page table. If null, it will use the current page table.
|
||||||
*/
|
*/
|
||||||
Virtual(PageTable *Table = nullptr);
|
Virtual(PageTable *Table = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroy the Virtual object
|
* @brief Destroy the Virtual object
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user