|
|
@ -201,15 +201,16 @@ namespace nasa
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<ppte, pte> mem_ctx::get_pte(void* addr, bool use_hyperspace)
|
|
|
|
auto mem_ctx::get_pte(void* addr, bool use_hyperspace) -> std::pair<ppte, pte>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!dirbase || !addr)
|
|
|
|
if (!dirbase || !addr)
|
|
|
|
return {};
|
|
|
|
return { {}, {} };
|
|
|
|
|
|
|
|
|
|
|
|
pt_entries entries;
|
|
|
|
pt_entries entries;
|
|
|
|
if ((use_hyperspace ? hyperspace_entries(entries, addr) : (bool)virt_to_phys(entries, addr)))
|
|
|
|
if ((use_hyperspace ? hyperspace_entries(entries, addr) : (bool)virt_to_phys(entries, addr)))
|
|
|
|
return { entries.pt.first, entries.pt.second };
|
|
|
|
return { entries.pt.first, entries.pt.second };
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
|
|
return { {}, {} };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mem_ctx::set_pte(void* addr, const ::pte& pte, bool use_hyperspace)
|
|
|
|
void mem_ctx::set_pte(void* addr, const ::pte& pte, bool use_hyperspace)
|
|
|
@ -223,7 +224,7 @@ namespace nasa
|
|
|
|
write_phys(addr, pte);
|
|
|
|
write_phys(addr, pte);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<ppde, pde> mem_ctx::get_pde(void* addr, bool use_hyperspace)
|
|
|
|
auto mem_ctx::get_pde(void* addr, bool use_hyperspace) -> std::pair<ppde, pde>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!dirbase || !addr)
|
|
|
|
if (!dirbase || !addr)
|
|
|
|
return {};
|
|
|
|
return {};
|
|
|
@ -236,7 +237,7 @@ namespace nasa
|
|
|
|
|
|
|
|
|
|
|
|
void mem_ctx::set_pde(void* addr, const ::pde& pde, bool use_hyperspace)
|
|
|
|
void mem_ctx::set_pde(void* addr, const ::pde& pde, bool use_hyperspace)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!this->dirbase || !addr)
|
|
|
|
if (!dirbase || !addr)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (use_hyperspace)
|
|
|
|
if (use_hyperspace)
|
|
|
@ -245,7 +246,7 @@ namespace nasa
|
|
|
|
write_phys(addr, pde);
|
|
|
|
write_phys(addr, pde);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<ppdpte, pdpte> mem_ctx::get_pdpte(void* addr, bool use_hyperspace)
|
|
|
|
auto mem_ctx::get_pdpte(void* addr, bool use_hyperspace) -> std::pair<ppdpte, pdpte>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!dirbase || !addr)
|
|
|
|
if (!dirbase || !addr)
|
|
|
|
return {};
|
|
|
|
return {};
|
|
|
@ -258,7 +259,7 @@ namespace nasa
|
|
|
|
|
|
|
|
|
|
|
|
void mem_ctx::set_pdpte(void* addr, const ::pdpte& pdpte, bool use_hyperspace)
|
|
|
|
void mem_ctx::set_pdpte(void* addr, const ::pdpte& pdpte, bool use_hyperspace)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!this->dirbase || !addr)
|
|
|
|
if (!dirbase || !addr)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (use_hyperspace)
|
|
|
|
if (use_hyperspace)
|
|
|
@ -267,9 +268,9 @@ namespace nasa
|
|
|
|
write_phys(addr, pdpte);
|
|
|
|
write_phys(addr, pdpte);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<ppml4e, pml4e> mem_ctx::get_pml4e(void* addr, bool use_hyperspace)
|
|
|
|
auto mem_ctx::get_pml4e(void* addr, bool use_hyperspace) -> std::pair<ppml4e, pml4e>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!this->dirbase || !addr)
|
|
|
|
if (!dirbase || !addr)
|
|
|
|
return {};
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
|
|
pt_entries entries;
|
|
|
|
pt_entries entries;
|
|
|
@ -280,7 +281,7 @@ namespace nasa
|
|
|
|
|
|
|
|
|
|
|
|
void mem_ctx::set_pml4e(void* addr, const ::pml4e& pml4e, bool use_hyperspace)
|
|
|
|
void mem_ctx::set_pml4e(void* addr, const ::pml4e& pml4e, bool use_hyperspace)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!this->dirbase || !addr)
|
|
|
|
if (!dirbase || !addr)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (use_hyperspace)
|
|
|
|
if (use_hyperspace)
|
|
|
@ -289,7 +290,7 @@ namespace nasa
|
|
|
|
write_phys(addr, pml4e);
|
|
|
|
write_phys(addr, pml4e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<void*, void*> mem_ctx::read_virtual(void* buffer, void* addr, std::size_t size)
|
|
|
|
auto mem_ctx::read_virtual(void* buffer, void* addr, std::size_t size) -> std::pair<void*, void*>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!buffer || !addr || !size || !dirbase)
|
|
|
|
if (!buffer || !addr || !size || !dirbase)
|
|
|
|
return {};
|
|
|
|
return {};
|
|
|
@ -331,7 +332,7 @@ namespace nasa
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<void*, void*> mem_ctx::write_virtual(void* buffer, void* addr, std::size_t size)
|
|
|
|
auto mem_ctx::write_virtual(void* buffer, void* addr, std::size_t size) -> std::pair<void*, void*>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!buffer || !addr || !size || !dirbase)
|
|
|
|
if (!buffer || !addr || !size || !dirbase)
|
|
|
|
return {};
|
|
|
|
return {};
|
|
|
@ -403,7 +404,7 @@ namespace nasa
|
|
|
|
|
|
|
|
|
|
|
|
void* mem_ctx::virt_to_phys(pt_entries& entries, void* addr)
|
|
|
|
void* mem_ctx::virt_to_phys(pt_entries& entries, void* addr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!addr || !this->dirbase)
|
|
|
|
if (!addr || !dirbase)
|
|
|
|
return {};
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
|
|
const virt_addr_t virt_addr{ addr };
|
|
|
|
const virt_addr_t virt_addr{ addr };
|
|
|
|