summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/VM/MemoryManager.cpp4
-rw-r--r--Kernel/VM/PhysicalRegion.cpp19
-rw-r--r--Kernel/VM/PhysicalRegion.h1
3 files changed, 5 insertions, 19 deletions
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
index 0bbdb32405..3ed3d6b12c 100644
--- a/Kernel/VM/MemoryManager.cpp
+++ b/Kernel/VM/MemoryManager.cpp
@@ -282,10 +282,10 @@ UNMAP_AFTER_INIT void MemoryManager::parse_memory_map()
.release_nonnull());
for (auto& region : m_super_physical_regions)
- m_system_memory_info.super_physical_pages += region.finalize_capacity();
+ m_system_memory_info.super_physical_pages += region.size();
for (auto& region : m_user_physical_regions)
- m_system_memory_info.user_physical_pages += region.finalize_capacity();
+ m_system_memory_info.user_physical_pages += region.size();
register_reserved_ranges();
for (auto& range : m_reserved_memory_ranges) {
diff --git a/Kernel/VM/PhysicalRegion.cpp b/Kernel/VM/PhysicalRegion.cpp
index 2f0ed7c634..c301b18f2a 100644
--- a/Kernel/VM/PhysicalRegion.cpp
+++ b/Kernel/VM/PhysicalRegion.cpp
@@ -34,6 +34,7 @@ PhysicalRegion::PhysicalRegion(PhysicalAddress lower, PhysicalAddress upper)
: m_lower(lower)
, m_upper(upper)
{
+ m_pages = (m_upper.get() - m_lower.get()) / PAGE_SIZE;
}
void PhysicalRegion::initialize_zones()
@@ -54,13 +55,6 @@ void PhysicalRegion::initialize_zones()
make_zones(256);
}
-unsigned PhysicalRegion::finalize_capacity()
-{
- VERIFY(!m_pages);
- m_pages = (m_upper.get() - m_lower.get()) / PAGE_SIZE;
- return size();
-}
-
OwnPtr<PhysicalRegion> PhysicalRegion::try_take_pages_from_beginning(unsigned page_count)
{
VERIFY(page_count > 0);
@@ -68,16 +62,9 @@ OwnPtr<PhysicalRegion> PhysicalRegion::try_take_pages_from_beginning(unsigned pa
auto taken_lower = m_lower;
auto taken_upper = taken_lower.offset((PhysicalPtr)page_count * PAGE_SIZE);
m_lower = m_lower.offset((PhysicalPtr)page_count * PAGE_SIZE);
+ m_pages = (m_upper.get() - m_lower.get()) / PAGE_SIZE;
- // TODO: find a more elegant way to re-init the existing region
- m_pages = 0;
- finalize_capacity();
-
- auto taken_region = try_create(taken_lower, taken_upper);
- if (!taken_region)
- return {};
- taken_region->finalize_capacity();
- return taken_region;
+ return try_create(taken_lower, taken_upper);
}
NonnullRefPtrVector<PhysicalPage> PhysicalRegion::take_contiguous_free_pages(size_t count)
diff --git a/Kernel/VM/PhysicalRegion.h b/Kernel/VM/PhysicalRegion.h
index 7b5d085dea..f9adb086d1 100644
--- a/Kernel/VM/PhysicalRegion.h
+++ b/Kernel/VM/PhysicalRegion.h
@@ -25,7 +25,6 @@ public:
~PhysicalRegion();
- unsigned finalize_capacity();
void initialize_zones();
PhysicalAddress lower() const { return m_lower; }