1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 06:57:45 +00:00

Kernel: Make and use KERNEL_BASE

This is to make the 0xc0000000 less a magic number, and will make it
easier in the future to move the Kernel around
This commit is contained in:
Hendiadyoin1 2021-06-28 18:43:18 +02:00 committed by Andreas Kling
parent 8b44aa7885
commit 65566d6868
7 changed files with 12 additions and 9 deletions

View file

@ -717,7 +717,7 @@ RefPtr<PhysicalPage> MemoryManager::allocate_supervisor_physical_page()
return {};
}
fast_u32_fill((u32*)page->paddr().offset(0xc0000000).as_ptr(), 0, PAGE_SIZE / sizeof(u32));
fast_u32_fill((u32*)page->paddr().offset(KERNEL_BASE).as_ptr(), 0, PAGE_SIZE / sizeof(u32));
++m_super_physical_pages_used;
return page;
}

View file

@ -40,12 +40,12 @@ constexpr FlatPtr page_round_down(FlatPtr x)
inline FlatPtr low_physical_to_virtual(FlatPtr physical)
{
return physical + 0xc0000000;
return physical + KERNEL_BASE;
}
inline FlatPtr virtual_to_low_physical(FlatPtr virtual_)
{
return virtual_ - 0xc0000000;
return virtual_ - KERNEL_BASE;
}
enum class UsedMemoryRangeType {
@ -260,7 +260,7 @@ void VMObject::for_each_region(Callback callback)
inline bool is_user_address(VirtualAddress vaddr)
{
return vaddr.get() < 0xc0000000;
return vaddr.get() < KERNEL_BASE;
}
inline bool is_user_range(VirtualAddress vaddr, size_t size)

View file

@ -37,7 +37,7 @@ extern "C" PageDirectoryEntry boot_pd3[1024];
UNMAP_AFTER_INIT PageDirectory::PageDirectory()
{
m_range_allocator.initialize_with_range(VirtualAddress(0xc2000000), 0x2f000000);
m_range_allocator.initialize_with_range(VirtualAddress(KERNEL_BASE + 0x02000000), 0x2f000000);
m_identity_range_allocator.initialize_with_range(VirtualAddress(FlatPtr(0x00000000)), 0x00200000);
// Adopt the page tables already set up by boot.S
@ -89,7 +89,7 @@ PageDirectory::PageDirectory(const RangeAllocator* parent_range_allocator)
m_directory_pages[2] = MM.allocate_user_physical_page();
if (!m_directory_pages[2])
return;
// Share the top 1 GiB of kernel-only mappings (>=3GiB or >=0xc0000000)
// Share the top 1 GiB of kernel-only mappings (>=3GiB or >=KERNEL_BASE)
m_directory_pages[3] = MM.kernel_page_directory().m_directory_pages[3];
#if ARCH(X86_64)

View file

@ -13,6 +13,7 @@
#include <Kernel/Arch/x86/PageFault.h>
#include <Kernel/Heap/SlabAllocator.h>
#include <Kernel/KString.h>
#include <Kernel/Sections.h>
#include <Kernel/VM/PageFaultResponse.h>
#include <Kernel/VM/PurgeablePageRanges.h>
#include <Kernel/VM/RangeAllocator.h>
@ -87,7 +88,7 @@ public:
void set_mmap(bool mmap) { m_mmap = mmap; }
bool is_user() const { return !is_kernel(); }
bool is_kernel() const { return vaddr().get() < 0x00800000 || vaddr().get() >= 0xc0000000; }
bool is_kernel() const { return vaddr().get() < 0x00800000 || vaddr().get() >= KERNEL_BASE; }
PageFaultResponse handle_fault(const PageFault&, ScopedSpinLock<RecursiveSpinLock>&);