From eaef57443cfcc23c8f5b1090f25fb15f413a5c5a Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sat, 6 Mar 2021 19:33:25 -0800 Subject: Kernel: Make MemoryManager API type-safe for Region::Access enum Increase type-safety moving the MemoryManager APIs which take a Region::Access to actually use that type instead of a `u8`. Eventually the actually m_access can be moved there as well, but I hit some weird bug where it wasn't using the correct operators in `set_access_bit(..)` even though it's declared (and tested). Something to fix-up later. --- Kernel/VM/Region.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Kernel/VM/Region.cpp') diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp index 403888d6d4..34faa2579d 100644 --- a/Kernel/VM/Region.cpp +++ b/Kernel/VM/Region.cpp @@ -39,7 +39,7 @@ namespace Kernel { -Region::Region(const Range& range, NonnullRefPtr vmobject, size_t offset_in_vmobject, String name, u8 access, Cacheable cacheable, bool shared) +Region::Region(const Range& range, NonnullRefPtr vmobject, size_t offset_in_vmobject, String name, Region::Access access, Cacheable cacheable, bool shared) : PurgeablePageRanges(vmobject) , m_range(range) , m_offset_in_vmobject(offset_in_vmobject) @@ -104,7 +104,7 @@ OwnPtr Region::clone(Process& new_owner) // Create a new region backed by the same VMObject. auto region = Region::create_user_accessible( - &new_owner, m_range, m_vmobject, m_offset_in_vmobject, m_name, m_access, m_cacheable ? Cacheable::Yes : Cacheable::No, m_shared); + &new_owner, m_range, m_vmobject, m_offset_in_vmobject, m_name, access(), m_cacheable ? Cacheable::Yes : Cacheable::No, m_shared); if (m_vmobject->is_anonymous()) region->copy_purgeable_page_ranges(*this); region->set_mmap(m_mmap); @@ -123,7 +123,7 @@ OwnPtr Region::clone(Process& new_owner) // Set up a COW region. The parent (this) region becomes COW as well! remap(); auto clone_region = Region::create_user_accessible( - &new_owner, m_range, vmobject_clone.release_nonnull(), m_offset_in_vmobject, m_name, m_access, m_cacheable ? Cacheable::Yes : Cacheable::No, m_shared); + &new_owner, m_range, vmobject_clone.release_nonnull(), m_offset_in_vmobject, m_name, access(), m_cacheable ? Cacheable::Yes : Cacheable::No, m_shared); if (m_vmobject->is_anonymous()) clone_region->copy_purgeable_page_ranges(*this); if (m_stack) { @@ -228,7 +228,7 @@ size_t Region::amount_shared() const return bytes; } -NonnullOwnPtr Region::create_user_accessible(Process* owner, const Range& range, NonnullRefPtr vmobject, size_t offset_in_vmobject, String name, u8 access, Cacheable cacheable, bool shared) +NonnullOwnPtr Region::create_user_accessible(Process* owner, const Range& range, NonnullRefPtr vmobject, size_t offset_in_vmobject, String name, Region::Access access, Cacheable cacheable, bool shared) { auto region = adopt_own(*new Region(range, move(vmobject), offset_in_vmobject, move(name), access, cacheable, shared)); if (owner) @@ -236,7 +236,7 @@ NonnullOwnPtr Region::create_user_accessible(Process* owner, const Range return region; } -NonnullOwnPtr Region::create_kernel_only(const Range& range, NonnullRefPtr vmobject, size_t offset_in_vmobject, String name, u8 access, Cacheable cacheable) +NonnullOwnPtr Region::create_kernel_only(const Range& range, NonnullRefPtr vmobject, size_t offset_in_vmobject, String name, Region::Access access, Cacheable cacheable) { return adopt_own(*new Region(range, move(vmobject), offset_in_vmobject, move(name), access, cacheable, false)); } -- cgit v1.2.3