1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 14:25:06 +00:00

Kernel: Move kernel above the 3GB virtual address mark

The kernel and its static data structures are no longer identity-mapped
in the bottom 8MB of the address space, but instead move above 3GB.

The first 8MB above 3GB are pseudo-identity-mapped to the bottom 8MB of
the physical address space. But things don't have to stay this way!

Thanks to Jesse who made an earlier attempt at this, it was really easy
to get device drivers working once the page tables were in place! :^)

Fixes #734.
This commit is contained in:
Andreas Kling 2020-01-17 19:59:20 +01:00
parent cee597a728
commit e362b56b4f
17 changed files with 325 additions and 125 deletions

View file

@ -229,7 +229,7 @@ extern "C" int __cxa_atexit(void (*)(void*), void*, void*)
extern u32 __stack_chk_guard;
u32 __stack_chk_guard;
extern "C" [[noreturn]] void init(u32 physical_address_for_kernel_page_tables)
extern "C" [[noreturn]] void init()
{
// this is only used one time, directly below here. we can't use this part
// of libc at this point in the boot process, or we'd just pull strstr in
@ -247,7 +247,8 @@ extern "C" [[noreturn]] void init(u32 physical_address_for_kernel_page_tables)
// process on live hardware.
//
// note: it must be the first option in the boot cmdline.
if (multiboot_info_ptr->cmdline && bad_prefix_check(reinterpret_cast<const char*>(multiboot_info_ptr->cmdline), "serial_debug"))
u32 cmdline = low_physical_to_virtual(multiboot_info_ptr->cmdline);
if (cmdline && bad_prefix_check(reinterpret_cast<const char*>(cmdline), "serial_debug"))
set_serial_debug(true);
detect_cpu_features();
@ -256,14 +257,16 @@ extern "C" [[noreturn]] void init(u32 physical_address_for_kernel_page_tables)
slab_alloc_init();
// must come after kmalloc_init because we use AK_MAKE_ETERNAL in KParams
new KParams(String(reinterpret_cast<const char*>(multiboot_info_ptr->cmdline)));
new KParams(String(reinterpret_cast<const char*>(cmdline)));
bool text_debug = KParams::the().has("text_debug");
bool complete_acpi_disable = KParams::the().has("noacpi");
bool dynamic_acpi_disable = KParams::the().has("noacpi_aml");
bool pci_mmio_disable = KParams::the().has("nopci_mmio");
MemoryManager::initialize(physical_address_for_kernel_page_tables);
complete_acpi_disable = true;
MemoryManager::initialize();
if (complete_acpi_disable) {
ACPIParser::initialize_limited();