Kernel: Add helpers to validate memory addresses
This commit is contained in:
parent
424b069d55
commit
047f445651
@ -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;
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user