summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-07-17 04:30:47 -0700
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-07-17 18:38:28 +0430
commitd879709ec78d75e8d0ab80a0d67d0b778876a732 (patch)
tree5e23eaf74f6b9f8e46537e3ae89a746c52a55b2d
parent399be9bcc391bb53a3dcbcd2cc17fd92ed48c8f6 (diff)
downloadserenity-d879709ec78d75e8d0ab80a0d67d0b778876a732.zip
Kernel: Convert the PhysicalPage bool parameter to an enum
-rw-r--r--Kernel/Bus/PCI/WindowedMMIOAccess.cpp2
-rw-r--r--Kernel/VM/AnonymousVMObject.cpp2
-rw-r--r--Kernel/VM/MemoryManager.cpp2
-rw-r--r--Kernel/VM/PageDirectory.cpp8
-rw-r--r--Kernel/VM/PhysicalPage.cpp6
-rw-r--r--Kernel/VM/PhysicalPage.h11
6 files changed, 18 insertions, 13 deletions
diff --git a/Kernel/Bus/PCI/WindowedMMIOAccess.cpp b/Kernel/Bus/PCI/WindowedMMIOAccess.cpp
index ef1503553f..77da10c148 100644
--- a/Kernel/Bus/PCI/WindowedMMIOAccess.cpp
+++ b/Kernel/Bus/PCI/WindowedMMIOAccess.cpp
@@ -23,7 +23,7 @@ UNMAP_AFTER_INIT DeviceConfigurationSpaceMapping::DeviceConfigurationSpaceMappin
PhysicalAddress segment_lower_addr = mmio_segment.get_paddr();
PhysicalAddress device_physical_mmio_space = segment_lower_addr.offset(
PCI_MMIO_CONFIG_SPACE_SIZE * m_device_address.function() + (PCI_MMIO_CONFIG_SPACE_SIZE * PCI_MAX_FUNCTIONS_PER_DEVICE) * m_device_address.device() + (PCI_MMIO_CONFIG_SPACE_SIZE * PCI_MAX_FUNCTIONS_PER_DEVICE * PCI_MAX_DEVICES_PER_BUS) * (m_device_address.bus() - mmio_segment.get_start_bus()));
- m_mapped_region->physical_page_slot(0) = PhysicalPage::create(device_physical_mmio_space, false);
+ m_mapped_region->physical_page_slot(0) = PhysicalPage::create(device_physical_mmio_space, MayReturnToFreeList::No);
m_mapped_region->remap();
}
diff --git a/Kernel/VM/AnonymousVMObject.cpp b/Kernel/VM/AnonymousVMObject.cpp
index 0d40fc02c5..841f9f390f 100644
--- a/Kernel/VM/AnonymousVMObject.cpp
+++ b/Kernel/VM/AnonymousVMObject.cpp
@@ -106,7 +106,7 @@ AnonymousVMObject::AnonymousVMObject(PhysicalAddress paddr, size_t size)
{
VERIFY(paddr.page_base() == paddr);
for (size_t i = 0; i < page_count(); ++i)
- physical_pages()[i] = PhysicalPage::create(paddr.offset(i * PAGE_SIZE), false);
+ physical_pages()[i] = PhysicalPage::create(paddr.offset(i * PAGE_SIZE), MayReturnToFreeList::No);
}
AnonymousVMObject::AnonymousVMObject(PhysicalPage& page)
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
index 4ea7b171a9..92f85c022e 100644
--- a/Kernel/VM/MemoryManager.cpp
+++ b/Kernel/VM/MemoryManager.cpp
@@ -475,7 +475,7 @@ UNMAP_AFTER_INIT void MemoryManager::initialize_physical_pages()
auto pt_paddr = page_tables_base.offset(pt_index * PAGE_SIZE);
auto physical_page_index = PhysicalAddress::physical_page_index(pt_paddr.get());
auto& physical_page_entry = m_physical_page_entries[physical_page_index];
- auto physical_page = adopt_ref(*new (&physical_page_entry.allocated.physical_page) PhysicalPage(false));
+ auto physical_page = adopt_ref(*new (&physical_page_entry.allocated.physical_page) PhysicalPage(MayReturnToFreeList::No));
auto result = kernel_page_tables.set(virtual_page_array_current_page & ~0x1fffff, move(physical_page));
VERIFY(result == AK::HashSetResult::InsertedNewEntry);
diff --git a/Kernel/VM/PageDirectory.cpp b/Kernel/VM/PageDirectory.cpp
index 671ffb8266..8f96e8cf45 100644
--- a/Kernel/VM/PageDirectory.cpp
+++ b/Kernel/VM/PageDirectory.cpp
@@ -47,7 +47,7 @@ UNMAP_AFTER_INIT void PageDirectory::allocate_kernel_directory()
#if ARCH(X86_64)
PhysicalAddress boot_pml4t_paddr(virtual_to_low_physical((FlatPtr)boot_pml4t));
dmesgln("MM: boot_pml4t @ {}", boot_pml4t_paddr);
- m_pml4t = PhysicalPage::create(boot_pml4t_paddr, false);
+ m_pml4t = PhysicalPage::create(boot_pml4t_paddr, MayReturnToFreeList::No);
#endif
PhysicalAddress boot_pdpt_paddr(virtual_to_low_physical((FlatPtr)boot_pdpt));
PhysicalAddress boot_pd0_paddr(virtual_to_low_physical((FlatPtr)boot_pd0));
@@ -55,9 +55,9 @@ UNMAP_AFTER_INIT void PageDirectory::allocate_kernel_directory()
dmesgln("MM: boot_pdpt @ {}", boot_pdpt_paddr);
dmesgln("MM: boot_pd0 @ {}", boot_pd0_paddr);
dmesgln("MM: boot_pd3 @ {}", boot_pd3_paddr);
- m_directory_table = PhysicalPage::create(boot_pdpt_paddr, false);
- m_directory_pages[0] = PhysicalPage::create(boot_pd0_paddr, false);
- m_directory_pages[3] = PhysicalPage::create(boot_pd3_paddr, false);
+ m_directory_table = PhysicalPage::create(boot_pdpt_paddr, MayReturnToFreeList::No);
+ m_directory_pages[0] = PhysicalPage::create(boot_pd0_paddr, MayReturnToFreeList::No);
+ m_directory_pages[3] = PhysicalPage::create(boot_pd3_paddr, MayReturnToFreeList::No);
}
PageDirectory::PageDirectory(const RangeAllocator* parent_range_allocator)
diff --git a/Kernel/VM/PhysicalPage.cpp b/Kernel/VM/PhysicalPage.cpp
index 6591db0160..bc215c6b5d 100644
--- a/Kernel/VM/PhysicalPage.cpp
+++ b/Kernel/VM/PhysicalPage.cpp
@@ -10,13 +10,13 @@
namespace Kernel {
-NonnullRefPtr<PhysicalPage> PhysicalPage::create(PhysicalAddress paddr, bool may_return_to_freelist)
+NonnullRefPtr<PhysicalPage> PhysicalPage::create(PhysicalAddress paddr, MayReturnToFreeList may_return_to_freelist)
{
auto& physical_page_entry = MM.get_physical_page_entry(paddr);
return adopt_ref(*new (&physical_page_entry.allocated.physical_page) PhysicalPage(may_return_to_freelist));
}
-PhysicalPage::PhysicalPage(bool may_return_to_freelist)
+PhysicalPage::PhysicalPage(MayReturnToFreeList may_return_to_freelist)
: m_may_return_to_freelist(may_return_to_freelist)
{
}
@@ -29,7 +29,7 @@ PhysicalAddress PhysicalPage::paddr() const
void PhysicalPage::free_this()
{
auto paddr = MM.get_physical_address(*this);
- if (m_may_return_to_freelist) {
+ if (m_may_return_to_freelist == MayReturnToFreeList::Yes) {
auto& this_as_freelist_entry = MM.get_physical_page_entry(paddr).freelist;
this->~PhysicalPage(); // delete in place
this_as_freelist_entry.next_index = -1;
diff --git a/Kernel/VM/PhysicalPage.h b/Kernel/VM/PhysicalPage.h
index f91277070a..ab22be3534 100644
--- a/Kernel/VM/PhysicalPage.h
+++ b/Kernel/VM/PhysicalPage.h
@@ -11,6 +11,11 @@
namespace Kernel {
+enum class MayReturnToFreeList : bool {
+ No,
+ Yes
+};
+
class PhysicalPage {
AK_MAKE_NONCOPYABLE(PhysicalPage);
AK_MAKE_NONMOVABLE(PhysicalPage);
@@ -31,7 +36,7 @@ public:
free_this();
}
- static NonnullRefPtr<PhysicalPage> create(PhysicalAddress, bool may_return_to_freelist = true);
+ static NonnullRefPtr<PhysicalPage> create(PhysicalAddress, MayReturnToFreeList may_return_to_freelist = MayReturnToFreeList::Yes);
u32 ref_count() const { return m_ref_count.load(AK::memory_order_consume); }
@@ -39,13 +44,13 @@ public:
bool is_lazy_committed_page() const;
private:
- explicit PhysicalPage(bool may_return_to_freelist = true);
+ explicit PhysicalPage(MayReturnToFreeList may_return_to_freelist);
~PhysicalPage() = default;
void free_this();
Atomic<u32> m_ref_count { 1 };
- bool m_may_return_to_freelist { true };
+ MayReturnToFreeList m_may_return_to_freelist { MayReturnToFreeList::Yes };
};
struct PhysicalPageEntry {