mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 17:52:34 -10:00
This will allow turning this class into a templated base class. Don't move expand_to_page_boundaries() inline since it will only be implemented by one subclass. Additionally, this function uses page_round_up() from MemoryManager.h. Including this header in VirtualRange.h would result in a circular include.
24 lines
606 B
C++
24 lines
606 B
C++
/*
|
|
* Copyright (c) 2018-2021, Andreas Kling <[email protected]>
|
|
* Copyright (c) 2021, Leon Albrecht <[email protected]>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/Memory/MemoryManager.h>
|
|
#include <Kernel/Memory/VirtualRange.h>
|
|
|
|
namespace Kernel::Memory {
|
|
|
|
ErrorOr<VirtualRange> VirtualRange::expand_to_page_boundaries(FlatPtr address, size_t size)
|
|
{
|
|
if ((address + size) < address)
|
|
return EINVAL;
|
|
|
|
auto base = VirtualAddress { address }.page_base();
|
|
auto end = TRY(page_round_up(address + size));
|
|
return VirtualRange { base, end - base.get() };
|
|
}
|
|
|
|
}
|