diff options
author | Andreas Kling <kling@serenityos.org> | 2022-04-05 12:40:31 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-05 13:45:10 +0200 |
commit | f8d798b667bf946b76b05dac60afb26a3102b7bb (patch) | |
tree | 313175137db9c28e6b3e1ea4323d1b5f3ea73736 /Kernel/Memory | |
parent | e0da8da6574be1575864f38b3cd8670a3cb8326e (diff) | |
download | serenity-f8d798b667bf946b76b05dac60afb26a3102b7bb.zip |
Kernel: Move allocate_unbacked_region_anywhere() to MemoryManager
This didn't need to be in RegionTree, and since it's specific to kernel
VM anyway, let's move it to MemoryManager.
Diffstat (limited to 'Kernel/Memory')
-rw-r--r-- | Kernel/Memory/MemoryManager.cpp | 7 | ||||
-rw-r--r-- | Kernel/Memory/MemoryManager.h | 1 | ||||
-rw-r--r-- | Kernel/Memory/RegionTree.cpp | 7 | ||||
-rw-r--r-- | Kernel/Memory/RegionTree.h | 2 |
4 files changed, 8 insertions, 9 deletions
diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp index 627bce7cb0..b7c75fc72b 100644 --- a/Kernel/Memory/MemoryManager.cpp +++ b/Kernel/Memory/MemoryManager.cpp @@ -1242,4 +1242,11 @@ ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::create_identity_mapped_reg return region; } +ErrorOr<NonnullOwnPtr<Region>> MemoryManager::allocate_unbacked_region_anywhere(size_t size, size_t alignment) +{ + auto region = TRY(Region::create_unbacked()); + TRY(m_region_tree.place_anywhere(*region, RandomizeVirtualAddress::No, size, alignment)); + return region; +} + } diff --git a/Kernel/Memory/MemoryManager.h b/Kernel/Memory/MemoryManager.h index 4f8d1fc357..e49b95e532 100644 --- a/Kernel/Memory/MemoryManager.h +++ b/Kernel/Memory/MemoryManager.h @@ -188,6 +188,7 @@ public: ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region(size_t, StringView name, Region::Access access, AllocationStrategy strategy = AllocationStrategy::Reserve, Region::Cacheable = Region::Cacheable::Yes); ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region(PhysicalAddress, size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes); ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region_with_vmobject(VMObject&, size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes); + ErrorOr<NonnullOwnPtr<Region>> allocate_unbacked_region_anywhere(size_t size, size_t alignment); ErrorOr<NonnullOwnPtr<Region>> create_identity_mapped_region(PhysicalAddress, size_t); struct SystemMemoryInfo { diff --git a/Kernel/Memory/RegionTree.cpp b/Kernel/Memory/RegionTree.cpp index f512a25677..81d1fffe7c 100644 --- a/Kernel/Memory/RegionTree.cpp +++ b/Kernel/Memory/RegionTree.cpp @@ -129,13 +129,6 @@ ErrorOr<VirtualRange> RegionTree::allocate_range_randomized(size_t size, size_t return allocate_range_anywhere(size, alignment); } -ErrorOr<NonnullOwnPtr<Region>> RegionTree::allocate_unbacked_anywhere(size_t size, size_t alignment) -{ - auto region = TRY(Region::create_unbacked()); - TRY(place_anywhere(*region, RandomizeVirtualAddress::No, size, alignment)); - return region; -} - ErrorOr<void> RegionTree::place_anywhere(Region& region, RandomizeVirtualAddress randomize_virtual_address, size_t size, size_t alignment) { SpinlockLocker locker(m_lock); diff --git a/Kernel/Memory/RegionTree.h b/Kernel/Memory/RegionTree.h index 50623ee02f..93f6047bfb 100644 --- a/Kernel/Memory/RegionTree.h +++ b/Kernel/Memory/RegionTree.h @@ -40,8 +40,6 @@ public: VirtualRange total_range() const { return m_total_range; } - ErrorOr<NonnullOwnPtr<Region>> allocate_unbacked_anywhere(size_t size, size_t alignment = PAGE_SIZE); - ErrorOr<void> place_anywhere(Region&, RandomizeVirtualAddress, size_t size, size_t alignment = PAGE_SIZE); ErrorOr<void> place_specifically(Region&, VirtualRange const&); |