From 0030f035bee4a5df56e217db1b71036f4d95925a Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 19 Apr 2023 21:50:30 +0300 Subject: [PATCH] Kernel: Rename MMU::{un,}allocate... to MMU::{un,}map This is more appropriate name for the behaviour :D --- kernel/arch/i386/MMU.cpp | 12 ++++++------ kernel/arch/x86_64/MMU.cpp | 12 ++++++------ kernel/include/kernel/Memory/MMU.h | 8 ++++---- kernel/kernel/ACPI.cpp | 14 +++++++------- kernel/kernel/APIC.cpp | 4 ++-- kernel/kernel/Memory/Heap.cpp | 6 +++--- kernel/kernel/Process.cpp | 2 +- kernel/kernel/Terminal/VesaTerminalDriver.cpp | 4 ++-- kernel/kernel/kernel.cpp | 4 ++-- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/kernel/arch/i386/MMU.cpp b/kernel/arch/i386/MMU.cpp index 87a409fbbb..a902655ba9 100644 --- a/kernel/arch/i386/MMU.cpp +++ b/kernel/arch/i386/MMU.cpp @@ -69,7 +69,7 @@ MMU::MMU() asm volatile("movl %0, %%cr3" :: "r"(m_highest_paging_struct)); } -void MMU::allocate_page(uintptr_t address, uint8_t flags) +void MMU::map_page(uintptr_t address, uint8_t flags) { #if MMU_DEBUG_PRINT dprintln("AllocatePage(0x{8H})", address); @@ -96,15 +96,15 @@ void MMU::allocate_page(uintptr_t address, uint8_t flags) asm volatile("invlpg (%0)" :: "r"(address) : "memory"); } -void MMU::allocate_range(uintptr_t address, ptrdiff_t size, uint8_t flags) +void MMU::map_range(uintptr_t address, ptrdiff_t size, uint8_t flags) { uintptr_t s_page = address & PAGE_MASK; uintptr_t e_page = (address + size - 1) & PAGE_MASK; for (uintptr_t page = s_page; page <= e_page; page += PAGE_SIZE) - allocate_page(page, flags); + map_page(page, flags); } -void MMU::unallocate_page(uintptr_t address) +void MMU::unmap_page(uintptr_t address) { #if MMU_DEBUG_PRINT dprintln("UnAllocatePage(0x{8H})", address & PAGE_MASK); @@ -129,10 +129,10 @@ void MMU::unallocate_page(uintptr_t address) asm volatile("invlpg (%0)" :: "r"(address & PAGE_MASK) : "memory"); } -void MMU::unallocate_range(uintptr_t address, ptrdiff_t size) +void MMU::unmap_range(uintptr_t address, ptrdiff_t size) { uintptr_t s_page = address & PAGE_MASK; uintptr_t e_page = (address + size - 1) & PAGE_MASK; for (uintptr_t page = s_page; page <= e_page; page += PAGE_SIZE) - unallocate_page(page); + unmap_page(page); } diff --git a/kernel/arch/x86_64/MMU.cpp b/kernel/arch/x86_64/MMU.cpp index 387328f2cd..b912164399 100644 --- a/kernel/arch/x86_64/MMU.cpp +++ b/kernel/arch/x86_64/MMU.cpp @@ -88,7 +88,7 @@ MMU::~MMU() kfree(pml4); } -void MMU::allocate_page(uintptr_t address, uint8_t flags) +void MMU::map_page(uintptr_t address, uint8_t flags) { ASSERT((address >> 48) == 0); @@ -140,15 +140,15 @@ void MMU::allocate_page(uintptr_t address, uint8_t flags) asm volatile("invlpg (%0)" :: "r"(address) : "memory"); } -void MMU::allocate_range(uintptr_t address, ptrdiff_t size, uint8_t flags) +void MMU::map_range(uintptr_t address, ptrdiff_t size, uint8_t flags) { uintptr_t s_page = address & PAGE_MASK; uintptr_t e_page = (address + size - 1) & PAGE_MASK; for (uintptr_t page = s_page; page <= e_page; page += PAGE_SIZE) - allocate_page(page, flags); + map_page(page, flags); } -void MMU::unallocate_page(uintptr_t address) +void MMU::unmap_page(uintptr_t address) { ASSERT((address >> 48) == 0); @@ -188,10 +188,10 @@ cleanup_done: asm volatile("invlpg (%0)" :: "r"(address) : "memory"); } -void MMU::unallocate_range(uintptr_t address, ptrdiff_t size) +void MMU::unmap_range(uintptr_t address, ptrdiff_t size) { uintptr_t s_page = address & PAGE_MASK; uintptr_t e_page = (address + size - 1) & PAGE_MASK; for (uintptr_t page = s_page; page <= e_page; page += PAGE_SIZE) - unallocate_page(page); + unmap_page(page); } diff --git a/kernel/include/kernel/Memory/MMU.h b/kernel/include/kernel/Memory/MMU.h index a6e3c4dc58..a8503b7f53 100644 --- a/kernel/include/kernel/Memory/MMU.h +++ b/kernel/include/kernel/Memory/MMU.h @@ -20,11 +20,11 @@ public: MMU(); ~MMU(); - void allocate_page(uintptr_t, uint8_t); - void allocate_range(uintptr_t, ptrdiff_t, uint8_t); + void map_page(uintptr_t, uint8_t); + void map_range(uintptr_t, ptrdiff_t, uint8_t); - void unallocate_page(uintptr_t); - void unallocate_range(uintptr_t, ptrdiff_t); + void unmap_page(uintptr_t); + void unmap_range(uintptr_t, ptrdiff_t); private: uint64_t* m_highest_paging_struct; diff --git a/kernel/kernel/ACPI.cpp b/kernel/kernel/ACPI.cpp index ee169fe9e6..8c25800ae3 100644 --- a/kernel/kernel/ACPI.cpp +++ b/kernel/kernel/ACPI.cpp @@ -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 {}; diff --git a/kernel/kernel/APIC.cpp b/kernel/kernel/APIC.cpp index 29e6c602f2..413b84ed53 100644 --- a/kernel/kernel/APIC.cpp +++ b/kernel/kernel/APIC.cpp @@ -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); } diff --git a/kernel/kernel/Memory/Heap.cpp b/kernel/kernel/Memory/Heap.cpp index 9c295e5b06..2b869aeec0 100644 --- a/kernel/kernel/Memory/Heap.cpp +++ b/kernel/kernel/Memory/Heap.cpp @@ -36,7 +36,7 @@ namespace Kernel::Memory m_list_pages = BAN::Math::div_round_up(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; } } diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index bd8e5d0c66..0730e9bcd5 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -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 diff --git a/kernel/kernel/Terminal/VesaTerminalDriver.cpp b/kernel/kernel/Terminal/VesaTerminalDriver.cpp index 9d6c7be603..ec45f0e71f 100644 --- a/kernel/kernel/Terminal/VesaTerminalDriver.cpp +++ b/kernel/kernel/Terminal/VesaTerminalDriver.cpp @@ -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) diff --git a/kernel/kernel/kernel.cpp b/kernel/kernel/kernel.cpp index f28920a495..ba5d508b85 100644 --- a/kernel/kernel/kernel.cpp +++ b/kernel/kernel/kernel.cpp @@ -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)); }