mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:37:34 +00:00
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.
This commit is contained in:
parent
e0da8da657
commit
f8d798b667
5 changed files with 9 additions and 10 deletions
|
@ -354,7 +354,7 @@ struct KmallocGlobalData {
|
||||||
void enable_expansion()
|
void enable_expansion()
|
||||||
{
|
{
|
||||||
// FIXME: This range can be much bigger on 64-bit, but we need to figure something out for 32-bit.
|
// FIXME: This range can be much bigger on 64-bit, but we need to figure something out for 32-bit.
|
||||||
auto reserved_region = MUST(MM.region_tree().allocate_unbacked_anywhere(64 * MiB, 1 * MiB));
|
auto reserved_region = MUST(MM.allocate_unbacked_region_anywhere(64 * MiB, 1 * MiB));
|
||||||
|
|
||||||
expansion_data = KmallocGlobalData::ExpansionData {
|
expansion_data = KmallocGlobalData::ExpansionData {
|
||||||
.virtual_range = reserved_region->range(),
|
.virtual_range = reserved_region->range(),
|
||||||
|
|
|
@ -1242,4 +1242,11 @@ ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::create_identity_mapped_reg
|
||||||
return region;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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(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(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_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);
|
ErrorOr<NonnullOwnPtr<Region>> create_identity_mapped_region(PhysicalAddress, size_t);
|
||||||
|
|
||||||
struct SystemMemoryInfo {
|
struct SystemMemoryInfo {
|
||||||
|
|
|
@ -129,13 +129,6 @@ ErrorOr<VirtualRange> RegionTree::allocate_range_randomized(size_t size, size_t
|
||||||
return allocate_range_anywhere(size, alignment);
|
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)
|
ErrorOr<void> RegionTree::place_anywhere(Region& region, RandomizeVirtualAddress randomize_virtual_address, size_t size, size_t alignment)
|
||||||
{
|
{
|
||||||
SpinlockLocker locker(m_lock);
|
SpinlockLocker locker(m_lock);
|
||||||
|
|
|
@ -40,8 +40,6 @@ public:
|
||||||
|
|
||||||
VirtualRange total_range() const { return m_total_range; }
|
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_anywhere(Region&, RandomizeVirtualAddress, size_t size, size_t alignment = PAGE_SIZE);
|
||||||
ErrorOr<void> place_specifically(Region&, VirtualRange const&);
|
ErrorOr<void> place_specifically(Region&, VirtualRange const&);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue