Kernel: Add helpers to validate memory addresses

This commit is contained in:
apio 2022-11-19 18:38:47 +01:00
parent 424b069d55
commit 047f445651
2 changed files with 18 additions and 0 deletions

View File

@ -184,6 +184,21 @@ namespace MemoryManager
return {};
}
bool validate_readable_page(u64 address)
{
auto rc = MMU::get_flags(address);
if (rc.has_error()) return false;
return true;
}
bool validate_writable_page(u64 address)
{
auto rc = MMU::get_flags(address);
if (rc.has_error()) return false;
if (rc.release_value() & MMU::ReadWrite) return true;
return false;
}
u64 free()
{
return free_mem;

View File

@ -17,6 +17,9 @@ namespace MemoryManager
Result<void> remap(u64 address, usize count, int flags);
Result<void> remap_unaligned(u64 address, usize count, int flags);
bool validate_readable_page(u64 address);
bool validate_writable_page(u64 address);
u64 free();
u64 used();
u64 reserved();