mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 21:08:12 +00:00
Kernel: Move sys$munmap functionality into a helper method
This commit is contained in:
parent
b9d693665b
commit
95c2166ca9
5 changed files with 123 additions and 94 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <AK/Vector.h>
|
||||
#include <Kernel/Arch/x86/CPU.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
#include <Kernel/VM/Range.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
@ -35,4 +36,21 @@ Range Range::intersect(const Range& other) const
|
|||
return Range(new_base, (new_end - new_base).get());
|
||||
}
|
||||
|
||||
KResultOr<Range> Range::expand_to_page_boundaries(FlatPtr address, size_t size)
|
||||
{
|
||||
if (page_round_up_would_wrap(size))
|
||||
return EINVAL;
|
||||
|
||||
if ((address + size) < address)
|
||||
return EINVAL;
|
||||
|
||||
if (page_round_up_would_wrap(address + size))
|
||||
return EINVAL;
|
||||
|
||||
auto base = VirtualAddress { address }.page_base();
|
||||
auto end = page_round_up(address + size);
|
||||
|
||||
return Range { base, end - base.get() };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue