mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:47:44 +00:00
Kernel: Rename Range => VirtualRange
...and also RangeAllocator => VirtualRangeAllocator. This clarifies that the ranges we're dealing with are *virtual* memory ranges and not anything else.
This commit is contained in:
parent
93d98d4976
commit
cd5faf4e42
39 changed files with 207 additions and 207 deletions
48
Kernel/Memory/VirtualRangeAllocator.h
Normal file
48
Kernel/Memory/VirtualRangeAllocator.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RedBlackTree.h>
|
||||
#include <AK/Traits.h>
|
||||
#include <Kernel/Memory/VirtualRange.h>
|
||||
#include <Kernel/SpinLock.h>
|
||||
|
||||
namespace Kernel::Memory {
|
||||
|
||||
class VirtualRangeAllocator {
|
||||
public:
|
||||
VirtualRangeAllocator();
|
||||
~VirtualRangeAllocator() = default;
|
||||
|
||||
void initialize_with_range(VirtualAddress, size_t);
|
||||
void initialize_from_parent(VirtualRangeAllocator const&);
|
||||
|
||||
Optional<VirtualRange> allocate_anywhere(size_t, size_t alignment = PAGE_SIZE);
|
||||
Optional<VirtualRange> allocate_specific(VirtualAddress, size_t);
|
||||
Optional<VirtualRange> allocate_randomized(size_t, size_t alignment);
|
||||
void deallocate(VirtualRange const&);
|
||||
|
||||
void dump() const;
|
||||
|
||||
bool contains(VirtualRange const& range) const { return m_total_range.contains(range); }
|
||||
|
||||
private:
|
||||
void carve_at_iterator(auto&, VirtualRange const&);
|
||||
|
||||
RedBlackTree<FlatPtr, VirtualRange> m_available_ranges;
|
||||
VirtualRange m_total_range;
|
||||
mutable SpinLock<u8> m_lock;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
template<>
|
||||
struct Traits<Kernel::Memory::VirtualRange> : public GenericTraits<Kernel::Memory::VirtualRange> {
|
||||
static constexpr bool is_trivial() { return true; }
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue