mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 03:29:49 +00:00
Kernel: Move the expand_range_to_page_boundaries helper to MemoryManager
This helper can (and will) be used in more parts of the kernel besides the mmap-family of syscalls.
This commit is contained in:
parent
ff6b43734c
commit
4ca39c7110
Notes:
sideshowbarker
2024-07-17 23:13:43 +09:00
Author: https://github.com/IdanHo
Commit: 4ca39c7110
Pull-request: https://github.com/SerenityOS/serenity/pull/10674
Reviewed-by: https://github.com/bgianfo
Reviewed-by: https://github.com/linusg ✅
2 changed files with 21 additions and 21 deletions
|
@ -329,4 +329,21 @@ inline bool PhysicalPage::is_lazy_committed_page() const
|
|||
return this == &MM.lazy_committed_page();
|
||||
}
|
||||
|
||||
inline ErrorOr<Memory::VirtualRange> expand_range_to_page_boundaries(FlatPtr address, size_t size)
|
||||
{
|
||||
if (Memory::page_round_up_would_wrap(size))
|
||||
return EINVAL;
|
||||
|
||||
if ((address + size) < address)
|
||||
return EINVAL;
|
||||
|
||||
if (Memory::page_round_up_would_wrap(address + size))
|
||||
return EINVAL;
|
||||
|
||||
auto base = VirtualAddress { address }.page_base();
|
||||
auto end = Memory::page_round_up(address + size);
|
||||
|
||||
return Memory::VirtualRange { base, end - base.get() };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue