Kernel: Rename MMU::{un,}allocate... to MMU::{un,}map

This is more appropriate name for the behaviour :D
This commit is contained in:
Bananymous
2023-04-19 21:50:30 +03:00
parent c26529ae86
commit 0030f035be
9 changed files with 33 additions and 33 deletions

View File

@@ -105,8 +105,8 @@ namespace Kernel
if (rsdp->revision >= 2)
{
const XSDT* xsdt = (const XSDT*)rsdp->xsdt_address;
MMU::get().allocate_page((uintptr_t)xsdt, MMU::Flags::Present);
BAN::ScopeGuard _([xsdt] { MMU::get().unallocate_page((uintptr_t)xsdt); });
MMU::get().map_page((uintptr_t)xsdt, MMU::Flags::Present);
BAN::ScopeGuard _([xsdt] { MMU::get().unmap_page((uintptr_t)xsdt); });
if (memcmp(xsdt->signature, "XSDT", 4) != 0)
return BAN::Error::from_error_code(ErrorCode::ACPI_RootInvalid);
@@ -120,8 +120,8 @@ namespace Kernel
else
{
const RSDT* rsdt = (const RSDT*)(uintptr_t)rsdp->rsdt_address;
MMU::get().allocate_page((uintptr_t)rsdt, MMU::Flags::Present);
BAN::ScopeGuard _([rsdt] { MMU::get().unallocate_page((uintptr_t)rsdt); });
MMU::get().map_page((uintptr_t)rsdt, MMU::Flags::Present);
BAN::ScopeGuard _([rsdt] { MMU::get().unmap_page((uintptr_t)rsdt); });
if (memcmp(rsdt->signature, "RSDT", 4) != 0)
return BAN::Error::from_error_code(ErrorCode::ACPI_RootInvalid);
@@ -133,13 +133,13 @@ namespace Kernel
m_entry_count = (rsdt->length - sizeof(SDTHeader)) / 4;
}
MMU::get().allocate_range(m_header_table, m_entry_count * m_entry_size, MMU::Flags::Present);
MMU::get().map_range(m_header_table, m_entry_count * m_entry_size, MMU::Flags::Present);
for (uint32_t i = 0; i < m_entry_count; i++)
{
auto* header = get_header_from_index(i);
MMU::get().allocate_page((uintptr_t)header, MMU::Flags::Present);
MMU::get().allocate_range((uintptr_t)header, header->length, MMU::Flags::Present);
MMU::get().map_page((uintptr_t)header, MMU::Flags::Present);
MMU::get().map_range((uintptr_t)header, header->length, MMU::Flags::Present);
}
return {};

View File

@@ -144,10 +144,10 @@ APIC* APIC::create()
return nullptr;
}
MMU::get().allocate_page(apic->m_local_apic, MMU::Flags::ReadWrite | MMU::Flags::Present);
MMU::get().map_page(apic->m_local_apic, MMU::Flags::ReadWrite | MMU::Flags::Present);
for (auto& io_apic : apic->m_io_apics)
{
MMU::get().allocate_page(io_apic.address, MMU::Flags::ReadWrite | MMU::Flags::Present);
MMU::get().map_page(io_apic.address, MMU::Flags::ReadWrite | MMU::Flags::Present);
io_apic.max_redirs = io_apic.read(IOAPIC_MAX_REDIRS);
}

View File

@@ -36,7 +36,7 @@ namespace Kernel::Memory
m_list_pages = BAN::Math::div_round_up<uint64_t>(m_total_pages * sizeof(node), PAGE_SIZE);
m_reservable_pages = m_total_pages - m_list_pages;
MMU::get().allocate_range(m_start, m_list_pages * PAGE_SIZE, MMU::Flags::ReadWrite | MMU::Flags::Present);
MMU::get().map_range(m_start, m_list_pages * PAGE_SIZE, MMU::Flags::ReadWrite | MMU::Flags::Present);
// Initialize page list so that every page points to the next one
node* page_list = (node*)m_start;
@@ -164,7 +164,7 @@ namespace Kernel::Memory
{
if (paddr_t page = range.reserve_page(); page != PhysicalRange::invalid)
{
MMU::get().allocate_page(page, flags);
MMU::get().map_page(page, flags);
return page;
}
}
@@ -177,7 +177,7 @@ namespace Kernel::Memory
{
if (range.contains(addr))
{
MMU::get().unallocate_page(addr);
MMU::get().unmap_page(addr);
return;
}
}

View File

@@ -44,7 +44,7 @@ namespace Kernel
[](void* entry_func)
{
Thread& current = Thread::current();
MMU::get().allocate_range(current.stack_base(), current.stack_size(), MMU::Flags::UserSupervisor | MMU::Flags::ReadWrite | MMU::Flags::Present);
MMU::get().map_range(current.stack_base(), current.stack_size(), MMU::Flags::UserSupervisor | MMU::Flags::ReadWrite | MMU::Flags::Present);
current.jump_userspace((uintptr_t)entry_func);
ASSERT_NOT_REACHED();
}, (void*)entry

View File

@@ -34,7 +34,7 @@ VesaTerminalDriver* VesaTerminalDriver::create()
return nullptr;
}
MMU::get().allocate_range(framebuffer.addr, framebuffer.pitch * framebuffer.height, MMU::Flags::UserSupervisor | MMU::Flags::ReadWrite | MMU::Flags::Present);
MMU::get().map_range(framebuffer.addr, framebuffer.pitch * framebuffer.height, MMU::Flags::UserSupervisor | MMU::Flags::ReadWrite | MMU::Flags::Present);
auto* driver = new VesaTerminalDriver(
framebuffer.width,
@@ -51,7 +51,7 @@ VesaTerminalDriver* VesaTerminalDriver::create()
VesaTerminalDriver::~VesaTerminalDriver()
{
MMU::get().unallocate_range(m_address, m_pitch * m_height);
MMU::get().unmap_range(m_address, m_pitch * m_height);
}
void VesaTerminalDriver::set_pixel(uint32_t offset, Color color)

View File

@@ -212,8 +212,8 @@ static void jump_userspace()
{
using namespace Kernel;
MMU::get().allocate_range((uintptr_t)&g_userspace_start, (uintptr_t)&g_userspace_end - (uintptr_t)&g_userspace_start, MMU::Flags::UserSupervisor | MMU::Flags::Present);
MMU::get().allocate_range((uintptr_t)&g_rodata_start, (uintptr_t)&g_rodata_end - (uintptr_t)&g_rodata_start, MMU::Flags::UserSupervisor | MMU::Flags::Present);
MMU::get().map_range((uintptr_t)&g_userspace_start, (uintptr_t)&g_userspace_end - (uintptr_t)&g_userspace_start, MMU::Flags::UserSupervisor | MMU::Flags::Present);
MMU::get().map_range((uintptr_t)&g_rodata_start, (uintptr_t)&g_rodata_end - (uintptr_t)&g_rodata_start, MMU::Flags::UserSupervisor | MMU::Flags::Present);
MUST(Process::create_userspace(userspace_entry));
}