Kernel: Remove unnecessary usages of PageTableScope

This should be used as few times as possible since it calls 'cli'
This commit is contained in:
Bananymous 2023-05-29 21:10:48 +03:00
parent e640344d7a
commit 278b873e89
3 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,4 @@
#include <kernel/Memory/FixedWidthAllocator.h> #include <kernel/Memory/FixedWidthAllocator.h>
#include <kernel/Memory/PageTableScope.h>
namespace Kernel namespace Kernel
{ {
@ -229,7 +228,8 @@ namespace Kernel
if (allocator == nullptr) if (allocator == nullptr)
return BAN::Error::from_errno(ENOMEM); return BAN::Error::from_errno(ENOMEM);
PageTableScope _(m_page_table); m_page_table.lock();
ASSERT(m_page_table.is_page_free(0)); ASSERT(m_page_table.is_page_free(0));
for (node* node = m_used_list; node; node = node->next) for (node* node = m_used_list; node; node = node->next)
@ -257,6 +257,8 @@ namespace Kernel
m_page_table.unmap_page(0); m_page_table.unmap_page(0);
m_page_table.invalidate(0); m_page_table.invalidate(0);
m_page_table.unlock();
return allocator; return allocator;
} }

View File

@ -1,6 +1,4 @@
#include <kernel/Memory/GeneralAllocator.h> #include <kernel/Memory/GeneralAllocator.h>
#include <kernel/Memory/PageTableScope.h>
#include <kernel/Process.h>
namespace Kernel namespace Kernel
{ {
@ -68,7 +66,8 @@ namespace Kernel
if (allocator == nullptr) if (allocator == nullptr)
return BAN::Error::from_errno(ENOMEM); return BAN::Error::from_errno(ENOMEM);
PageTableScope _(m_page_table); m_page_table.lock();
ASSERT(m_page_table.is_page_free(0)); ASSERT(m_page_table.is_page_free(0));
for (auto& allocation : m_allocations) for (auto& allocation : m_allocations)
@ -100,6 +99,8 @@ namespace Kernel
m_page_table.unmap_page(0); m_page_table.unmap_page(0);
m_page_table.invalidate(0); m_page_table.invalidate(0);
m_page_table.unlock();
return allocator; return allocator;
} }

View File

@ -1,5 +1,4 @@
#include <kernel/Memory/Heap.h> #include <kernel/Memory/Heap.h>
#include <kernel/Memory/PageTableScope.h>
#include <kernel/Memory/VirtualRange.h> #include <kernel/Memory/VirtualRange.h>
namespace Kernel namespace Kernel
@ -78,7 +77,8 @@ namespace Kernel
{ {
VirtualRange* result = create(page_table, vaddr(), size(), flags()); VirtualRange* result = create(page_table, vaddr(), size(), flags());
PageTableScope _(m_page_table); m_page_table.lock();
ASSERT(m_page_table.is_page_free(0)); ASSERT(m_page_table.is_page_free(0));
for (size_t i = 0; i < result->m_physical_pages.size(); i++) for (size_t i = 0; i < result->m_physical_pages.size(); i++)
{ {
@ -89,6 +89,8 @@ namespace Kernel
m_page_table.unmap_page(0); m_page_table.unmap_page(0);
m_page_table.invalidate(0); m_page_table.invalidate(0);
m_page_table.unlock();
return result; return result;
} }