Files
Sönke Holz 25538bf0f0 Kernel/Memory: Move some VirtualRange functions inline
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.
2026-09-18 17:25:42 +02:00

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() };
}
}