Forráskód Böngészése

Kernel: Slap UNMAP_AFTER_INIT on a bunch more functions

We're now able to unmap 100 KiB of kernel text after init. :^)
Andreas Kling 4 éve
szülő
commit
2b2828ae52

+ 1 - 1
Kernel/ACPI/DynamicParser.cpp

@@ -30,7 +30,7 @@
 namespace Kernel {
 namespace ACPI {
 
-DynamicParser::DynamicParser(PhysicalAddress rsdp)
+UNMAP_AFTER_INIT DynamicParser::DynamicParser(PhysicalAddress rsdp)
     : IRQHandler(9)
     , Parser(rsdp)
 {

+ 2 - 2
Kernel/ACPI/Initialize.cpp

@@ -37,7 +37,7 @@ enum class FeatureLevel {
     Disabled,
 };
 
-static FeatureLevel determine_feature_level()
+UNMAP_AFTER_INIT static FeatureLevel determine_feature_level()
 {
     auto value = kernel_command_line().lookup("acpi").value_or("on");
     if (value == "limited")
@@ -47,7 +47,7 @@ static FeatureLevel determine_feature_level()
     return FeatureLevel::Enabled;
 }
 
-void initialize()
+UNMAP_AFTER_INIT void initialize()
 {
     auto feature_level = determine_feature_level();
     if (feature_level == FeatureLevel::Disabled)

+ 8 - 8
Kernel/ACPI/MultiProcessorParser.cpp

@@ -36,7 +36,7 @@
 
 namespace Kernel {
 
-OwnPtr<MultiProcessorParser> MultiProcessorParser::autodetect()
+UNMAP_AFTER_INIT OwnPtr<MultiProcessorParser> MultiProcessorParser::autodetect()
 {
     auto floating_pointer = find_floating_pointer();
     if (!floating_pointer.has_value())
@@ -44,7 +44,7 @@ OwnPtr<MultiProcessorParser> MultiProcessorParser::autodetect()
     return adopt_own(*new MultiProcessorParser(floating_pointer.value()));
 }
 
-MultiProcessorParser::MultiProcessorParser(PhysicalAddress floating_pointer)
+UNMAP_AFTER_INIT MultiProcessorParser::MultiProcessorParser(PhysicalAddress floating_pointer)
     : m_floating_pointer(floating_pointer)
 {
     klog() << "MultiProcessor: Floating Pointer Structure @ " << m_floating_pointer;
@@ -52,14 +52,14 @@ MultiProcessorParser::MultiProcessorParser(PhysicalAddress floating_pointer)
     parse_configuration_table();
 }
 
-void MultiProcessorParser::parse_floating_pointer_data()
+UNMAP_AFTER_INIT void MultiProcessorParser::parse_floating_pointer_data()
 {
     auto floating_pointer = map_typed<MultiProcessor::FloatingPointer>(m_floating_pointer);
     m_configuration_table = PhysicalAddress(floating_pointer->physical_address_ptr);
     dbgln("Features {}, IMCR? {}", floating_pointer->feature_info[0], (floating_pointer->feature_info[0] & (1 << 7)));
 }
 
-void MultiProcessorParser::parse_configuration_table()
+UNMAP_AFTER_INIT void MultiProcessorParser::parse_configuration_table()
 {
     auto configuration_table_length = map_typed<MultiProcessor::ConfigurationTableHeader>(m_configuration_table)->length;
     auto config_table = map_typed<MultiProcessor::ConfigurationTableHeader>(m_configuration_table, configuration_table_length);
@@ -102,7 +102,7 @@ void MultiProcessorParser::parse_configuration_table()
     }
 }
 
-Optional<PhysicalAddress> MultiProcessorParser::find_floating_pointer()
+UNMAP_AFTER_INIT Optional<PhysicalAddress> MultiProcessorParser::find_floating_pointer()
 {
     StringView signature("_MP_");
     auto mp_floating_pointer = map_ebda().find_chunk_starting_with(signature, 16);
@@ -111,7 +111,7 @@ Optional<PhysicalAddress> MultiProcessorParser::find_floating_pointer()
     return map_bios().find_chunk_starting_with(signature, 16);
 }
 
-Vector<u8> MultiProcessorParser::get_pci_bus_ids() const
+UNMAP_AFTER_INIT Vector<u8> MultiProcessorParser::get_pci_bus_ids() const
 {
     Vector<u8> pci_bus_ids;
     for (auto& entry : m_bus_entries) {
@@ -121,7 +121,7 @@ Vector<u8> MultiProcessorParser::get_pci_bus_ids() const
     return pci_bus_ids;
 }
 
-Vector<PCIInterruptOverrideMetadata> MultiProcessorParser::get_pci_interrupt_redirections()
+UNMAP_AFTER_INIT Vector<PCIInterruptOverrideMetadata> MultiProcessorParser::get_pci_interrupt_redirections()
 {
     dbgln("MultiProcessor: Get PCI IOAPIC redirections");
     Vector<PCIInterruptOverrideMetadata> overrides;
@@ -148,7 +148,7 @@ Vector<PCIInterruptOverrideMetadata> MultiProcessorParser::get_pci_interrupt_red
     return overrides;
 }
 
-PCIInterruptOverrideMetadata::PCIInterruptOverrideMetadata(u8 bus_id, u8 polarity, u8 trigger_mode, u8 source_irq, u32 ioapic_id, u16 ioapic_int_pin)
+UNMAP_AFTER_INIT PCIInterruptOverrideMetadata::PCIInterruptOverrideMetadata(u8 bus_id, u8 polarity, u8 trigger_mode, u8 source_irq, u32 ioapic_id, u16 ioapic_int_pin)
     : m_bus_id(bus_id)
     , m_polarity(polarity)
     , m_trigger_mode(trigger_mode)

+ 11 - 11
Kernel/ACPI/Parser.cpp

@@ -56,7 +56,7 @@ static PhysicalAddress search_table_in_xsdt(PhysicalAddress xsdt, const StringVi
 static PhysicalAddress search_table_in_rsdt(PhysicalAddress rsdt, const StringView& signature);
 static bool validate_table(const Structures::SDTHeader&, size_t length);
 
-void Parser::locate_static_data()
+UNMAP_AFTER_INIT void Parser::locate_static_data()
 {
     locate_main_system_description_table();
     initialize_main_system_description_table();
@@ -64,7 +64,7 @@ void Parser::locate_static_data()
     init_facs();
 }
 
-PhysicalAddress Parser::find_table(const StringView& signature)
+UNMAP_AFTER_INIT PhysicalAddress Parser::find_table(const StringView& signature)
 {
     dbgln_if(ACPI_DEBUG, "ACPI: Calling Find Table method!");
     for (auto p_sdt : m_sdt_pointers) {
@@ -78,12 +78,12 @@ PhysicalAddress Parser::find_table(const StringView& signature)
     return {};
 }
 
-void Parser::init_facs()
+UNMAP_AFTER_INIT void Parser::init_facs()
 {
     m_facs = find_table("FACS");
 }
 
-void Parser::init_fadt()
+UNMAP_AFTER_INIT void Parser::init_fadt()
 {
     klog() << "ACPI: Initializing Fixed ACPI data";
     klog() << "ACPI: Searching for the Fixed ACPI Data Table";
@@ -250,7 +250,7 @@ u8 Parser::get_table_revision(PhysicalAddress table_header)
     return map_typed<Structures::SDTHeader>(table_header)->revision;
 }
 
-void Parser::initialize_main_system_description_table()
+UNMAP_AFTER_INIT void Parser::initialize_main_system_description_table()
 {
 #if ACPI_DEBUG
     dbgln("ACPI: Checking Main SDT Length to choose the correct mapping size");
@@ -284,7 +284,7 @@ void Parser::initialize_main_system_description_table()
     }
 }
 
-void Parser::locate_main_system_description_table()
+UNMAP_AFTER_INIT void Parser::locate_main_system_description_table()
 {
     auto rsdp = map_typed<Structures::RSDPDescriptor20>(m_rsdp);
     if (rsdp->base.revision == 0) {
@@ -303,7 +303,7 @@ void Parser::locate_main_system_description_table()
     }
 }
 
-Parser::Parser(PhysicalAddress rsdp)
+UNMAP_AFTER_INIT Parser::Parser(PhysicalAddress rsdp)
     : m_rsdp(rsdp)
 {
     klog() << "ACPI: Using RSDP @ " << rsdp;
@@ -321,7 +321,7 @@ static bool validate_table(const Structures::SDTHeader& v_header, size_t length)
     return false;
 }
 
-Optional<PhysicalAddress> StaticParsing::find_rsdp()
+UNMAP_AFTER_INIT Optional<PhysicalAddress> StaticParsing::find_rsdp()
 {
     StringView signature("RSD PTR ");
     auto rsdp = map_ebda().find_chunk_starting_with(signature, 16);
@@ -330,7 +330,7 @@ Optional<PhysicalAddress> StaticParsing::find_rsdp()
     return map_bios().find_chunk_starting_with(signature, 16);
 }
 
-PhysicalAddress StaticParsing::find_table(PhysicalAddress rsdp_address, const StringView& signature)
+UNMAP_AFTER_INIT PhysicalAddress StaticParsing::find_table(PhysicalAddress rsdp_address, const StringView& signature)
 {
     // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
     ASSERT(signature.length() == 4);
@@ -348,7 +348,7 @@ PhysicalAddress StaticParsing::find_table(PhysicalAddress rsdp_address, const St
     ASSERT_NOT_REACHED();
 }
 
-static PhysicalAddress search_table_in_xsdt(PhysicalAddress xsdt_address, const StringView& signature)
+UNMAP_AFTER_INIT static PhysicalAddress search_table_in_xsdt(PhysicalAddress xsdt_address, const StringView& signature)
 {
     // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
     ASSERT(signature.length() == 4);
@@ -371,7 +371,7 @@ static bool match_table_signature(PhysicalAddress table_header, const StringView
     return !strncmp(table->h.sig, signature.characters_without_null_termination(), 4);
 }
 
-static PhysicalAddress search_table_in_rsdt(PhysicalAddress rsdt_address, const StringView& signature)
+UNMAP_AFTER_INIT static PhysicalAddress search_table_in_rsdt(PhysicalAddress rsdt_address, const StringView& signature)
 {
     // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
     ASSERT(signature.length() == 4);

+ 4 - 4
Kernel/Arch/i386/CPU.cpp

@@ -730,7 +730,7 @@ NEVER_INLINE UNMAP_AFTER_INIT void write_cr4(u32 value)
     asm volatile("movl %%eax, %%cr4" ::"a"(value));
 }
 
-static void sse_init()
+UNMAP_AFTER_INIT static void sse_init()
 {
     write_cr0((read_cr0() & 0xfffffffbu) | 0x2);
     write_cr4(read_cr4() | 0x600);
@@ -1540,7 +1540,7 @@ void Processor::assume_context(Thread& thread, u32 flags)
     ASSERT_NOT_REACHED();
 }
 
-extern "C" void pre_init_finished(void)
+extern "C" UNMAP_AFTER_INIT void pre_init_finished(void)
 {
     ASSERT(g_scheduler_lock.own_lock());
 
@@ -1553,14 +1553,14 @@ extern "C" void pre_init_finished(void)
     Scheduler::leave_on_first_switch(prev_flags);
 }
 
-extern "C" void post_init_finished(void)
+extern "C" UNMAP_AFTER_INIT void post_init_finished(void)
 {
     // We need to re-acquire the scheduler lock before a context switch
     // transfers control into the idle loop, which needs the lock held
     Scheduler::prepare_for_idle_loop();
 }
 
-void Processor::initialize_context_switching(Thread& initial_thread)
+UNMAP_AFTER_INIT void Processor::initialize_context_switching(Thread& initial_thread)
 {
     ASSERT(initial_thread.process().is_kernel_process());
 

+ 3 - 3
Kernel/CommandLine.cpp

@@ -32,7 +32,7 @@ namespace Kernel {
 static char s_cmd_line[1024];
 static CommandLine* s_the;
 
-void CommandLine::early_initialize(const char* cmd_line)
+UNMAP_AFTER_INIT void CommandLine::early_initialize(const char* cmd_line)
 {
     if (!cmd_line)
         return;
@@ -49,13 +49,13 @@ const CommandLine& kernel_command_line()
     return *s_the;
 }
 
-void CommandLine::initialize()
+UNMAP_AFTER_INIT void CommandLine::initialize()
 {
     ASSERT(!s_the);
     s_the = new CommandLine(s_cmd_line);
 }
 
-CommandLine::CommandLine(const String& string)
+UNMAP_AFTER_INIT CommandLine::CommandLine(const String& string)
     : m_string(string)
 {
     s_the = this;

+ 1 - 1
Kernel/Console.cpp

@@ -56,7 +56,7 @@ UNMAP_AFTER_INIT Console::Console()
 {
 }
 
-Console::~Console()
+UNMAP_AFTER_INIT Console::~Console()
 {
 }
 

+ 7 - 7
Kernel/DMI.cpp

@@ -42,7 +42,7 @@ namespace Kernel {
 
 AK::Singleton<DMIExpose> s_the;
 
-void DMIExpose::set_64_bit_entry_initialization_values()
+UNMAP_AFTER_INIT void DMIExpose::set_64_bit_entry_initialization_values()
 {
     klog() << "DMIExpose: SMBIOS 64bit Entry point @ " << m_entry_point;
     auto smbios_entry = map_typed<SMBIOS::EntryPoint64bit>(PhysicalAddress(m_entry_point), SMBIOS_SEARCH_AREA_SIZE);
@@ -51,7 +51,7 @@ void DMIExpose::set_64_bit_entry_initialization_values()
     m_structure_table_length = smbios_entry.ptr()->table_maximum_size;
 }
 
-void DMIExpose::set_32_bit_entry_initialization_values()
+UNMAP_AFTER_INIT void DMIExpose::set_32_bit_entry_initialization_values()
 {
     klog() << "DMIExpose: SMBIOS 32bit Entry point @ " << m_entry_point;
     auto smbios_entry = map_typed<SMBIOS::EntryPoint32bit>(PhysicalAddress(m_entry_point), SMBIOS_SEARCH_AREA_SIZE);
@@ -60,7 +60,7 @@ void DMIExpose::set_32_bit_entry_initialization_values()
     m_structure_table_length = smbios_entry.ptr()->legacy_structure.smboios_table_length;
 }
 
-void DMIExpose::initialize()
+UNMAP_AFTER_INIT void DMIExpose::initialize()
 {
     s_the.ensure_instance();
 }
@@ -79,7 +79,7 @@ size_t DMIExpose::structure_table_length() const
     return m_structure_table_length;
 }
 
-void DMIExpose::initialize_exposer()
+UNMAP_AFTER_INIT void DMIExpose::initialize_exposer()
 {
     ASSERT(!(m_entry_point.is_null()));
     if (m_using_64bit_entry_point) {
@@ -101,7 +101,7 @@ OwnPtr<KBuffer> DMIExpose::structure_table() const
     return KBuffer::try_create_with_bytes(Span<u8> { dmi_blob.ptr(), m_structure_table_length });
 }
 
-DMIExpose::DMIExpose()
+UNMAP_AFTER_INIT DMIExpose::DMIExpose()
 {
     auto entry_32bit = find_entry32bit_point();
     m_entry_point = entry_32bit.value();
@@ -117,12 +117,12 @@ DMIExpose::DMIExpose()
     initialize_exposer();
 }
 
-Optional<PhysicalAddress> DMIExpose::find_entry64bit_point()
+UNMAP_AFTER_INIT Optional<PhysicalAddress> DMIExpose::find_entry64bit_point()
 {
     return map_bios().find_chunk_starting_with("_SM3_", 16);
 }
 
-Optional<PhysicalAddress> DMIExpose::find_entry32bit_point()
+UNMAP_AFTER_INIT Optional<PhysicalAddress> DMIExpose::find_entry32bit_point()
 {
     return map_bios().find_chunk_starting_with("_SM_", 16);
 }

+ 3 - 3
Kernel/Devices/BXVGADevice.cpp

@@ -60,7 +60,7 @@ namespace Kernel {
 
 static AK::Singleton<BXVGADevice> s_the;
 
-void BXVGADevice::initialize()
+UNMAP_AFTER_INIT void BXVGADevice::initialize()
 {
     s_the.ensure_instance();
 }
@@ -70,7 +70,7 @@ BXVGADevice& BXVGADevice::the()
     return *s_the;
 }
 
-BXVGADevice::BXVGADevice()
+UNMAP_AFTER_INIT BXVGADevice::BXVGADevice()
     : BlockDevice(29, 0)
 
 {
@@ -157,7 +157,7 @@ void BXVGADevice::set_y_offset(size_t y_offset)
     set_register(VBE_DISPI_INDEX_Y_OFFSET, (u16)y_offset);
 }
 
-u32 BXVGADevice::find_framebuffer_address()
+UNMAP_AFTER_INIT u32 BXVGADevice::find_framebuffer_address()
 {
     // NOTE: The QEMU card has the same PCI ID as the Bochs one.
     static const PCI::ID bochs_vga_id = { 0x1234, 0x1111 };

+ 3 - 3
Kernel/Devices/KeyboardDevice.cpp

@@ -404,7 +404,7 @@ static const Keyboard::CharacterMapData DEFAULT_CHARACTER_MAP =
 };
 // clang-format on
 
-KeyboardDevice::KeyboardDevice()
+UNMAP_AFTER_INIT KeyboardDevice::KeyboardDevice()
     : IRQHandler(IRQ_KEYBOARD)
     , CharacterDevice(85, 1)
     , m_controller(I8042Controller::the())
@@ -412,11 +412,11 @@ KeyboardDevice::KeyboardDevice()
 {
 }
 
-KeyboardDevice::~KeyboardDevice()
+UNMAP_AFTER_INIT KeyboardDevice::~KeyboardDevice()
 {
 }
 
-bool KeyboardDevice::initialize()
+UNMAP_AFTER_INIT bool KeyboardDevice::initialize()
 {
     if (!m_controller.reset_device(I8042Controller::Device::Keyboard)) {
         dbgln("KeyboardDevice: I8042 controller failed to reset device");

+ 1 - 1
Kernel/Devices/MBVGADevice.cpp

@@ -40,7 +40,7 @@ MBVGADevice& MBVGADevice::the()
     return *s_the;
 }
 
-MBVGADevice::MBVGADevice(PhysicalAddress addr, size_t pitch, size_t width, size_t height)
+UNMAP_AFTER_INIT MBVGADevice::MBVGADevice(PhysicalAddress addr, size_t pitch, size_t width, size_t height)
     : BlockDevice(29, 0)
     , m_framebuffer_address(addr)
     , m_framebuffer_pitch(pitch)

+ 2 - 2
Kernel/Devices/MemoryDevice.cpp

@@ -33,12 +33,12 @@
 
 namespace Kernel {
 
-MemoryDevice::MemoryDevice()
+UNMAP_AFTER_INIT MemoryDevice::MemoryDevice()
     : CharacterDevice(1, 1)
 {
 }
 
-MemoryDevice::~MemoryDevice()
+UNMAP_AFTER_INIT MemoryDevice::~MemoryDevice()
 {
 }
 

+ 3 - 3
Kernel/Devices/PS2MouseDevice.cpp

@@ -51,14 +51,14 @@ namespace Kernel {
 
 static AK::Singleton<PS2MouseDevice> s_the;
 
-PS2MouseDevice::PS2MouseDevice()
+UNMAP_AFTER_INIT PS2MouseDevice::PS2MouseDevice()
     : IRQHandler(IRQ_MOUSE)
     , CharacterDevice(10, 1)
     , m_controller(I8042Controller::the())
 {
 }
 
-PS2MouseDevice::~PS2MouseDevice()
+UNMAP_AFTER_INIT PS2MouseDevice::~PS2MouseDevice()
 {
 }
 
@@ -222,7 +222,7 @@ void PS2MouseDevice::set_sample_rate(u8 rate)
     send_command(PS2MOUSE_SET_SAMPLE_RATE, rate);
 }
 
-bool PS2MouseDevice::initialize()
+UNMAP_AFTER_INIT bool PS2MouseDevice::initialize()
 {
     if (!m_controller.reset_device(I8042Controller::Device::Mouse)) {
         dbgln("PS2MouseDevice: I8042 controller failed to reset device");

+ 5 - 5
Kernel/Devices/SB16.cpp

@@ -78,18 +78,18 @@ void SB16::set_sample_rate(uint16_t hz)
 
 static AK::Singleton<SB16> s_the;
 
-SB16::SB16()
+UNMAP_AFTER_INIT SB16::SB16()
     : IRQHandler(SB16_DEFAULT_IRQ)
     , CharacterDevice(42, 42) // ### ?
 {
     initialize();
 }
 
-SB16::~SB16()
+UNMAP_AFTER_INIT SB16::~SB16()
 {
 }
 
-void SB16::detect()
+UNMAP_AFTER_INIT void SB16::detect()
 {
     IO::out8(0x226, 1);
     IO::delay(32);
@@ -102,7 +102,7 @@ void SB16::detect()
     SB16::create();
 }
 
-void SB16::create()
+UNMAP_AFTER_INIT void SB16::create()
 {
     s_the.ensure_instance();
 }
@@ -112,7 +112,7 @@ SB16& SB16::the()
     return *s_the;
 }
 
-void SB16::initialize()
+UNMAP_AFTER_INIT void SB16::initialize()
 {
     disable_irq();
 

+ 4 - 4
Kernel/Devices/SerialDevice.cpp

@@ -29,14 +29,14 @@
 
 namespace Kernel {
 
-SerialDevice::SerialDevice(int base_addr, unsigned minor)
+UNMAP_AFTER_INIT SerialDevice::SerialDevice(int base_addr, unsigned minor)
     : CharacterDevice(4, minor)
     , m_base_addr(base_addr)
 {
     initialize();
 }
 
-SerialDevice::~SerialDevice()
+UNMAP_AFTER_INIT SerialDevice::~SerialDevice()
 {
 }
 
@@ -92,7 +92,7 @@ String SerialDevice::device_name() const
     return String::formatted("ttyS{}", minor() - 64);
 }
 
-void SerialDevice::initialize()
+UNMAP_AFTER_INIT void SerialDevice::initialize()
 {
     set_interrupts(0);
     set_baud(Baud38400);
@@ -101,7 +101,7 @@ void SerialDevice::initialize()
     set_modem_control(RequestToSend | DataTerminalReady);
 }
 
-void SerialDevice::set_interrupts(char interrupt_enable)
+UNMAP_AFTER_INIT void SerialDevice::set_interrupts(char interrupt_enable)
 {
     m_interrupt_enable = interrupt_enable;
 

+ 5 - 5
Kernel/Devices/USB/UHCIController.cpp

@@ -86,7 +86,7 @@ UHCIController& UHCIController::the()
     return *s_the;
 }
 
-void UHCIController::detect()
+UNMAP_AFTER_INIT void UHCIController::detect()
 {
 #if !UHCI_ENABLED
     return;
@@ -102,7 +102,7 @@ void UHCIController::detect()
     });
 }
 
-UHCIController::UHCIController(PCI::Address address, PCI::ID id)
+UNMAP_AFTER_INIT UHCIController::UHCIController(PCI::Address address, PCI::ID id)
     : PCI::Device(address)
     , m_io_base(PCI::get_BAR4(pci_address()) & ~1)
 {
@@ -116,7 +116,7 @@ UHCIController::UHCIController(PCI::Address address, PCI::ID id)
     spawn_port_proc();
 }
 
-UHCIController::~UHCIController()
+UNMAP_AFTER_INIT UHCIController::~UHCIController()
 {
 }
 
@@ -151,7 +151,7 @@ void UHCIController::reset()
     klog() << "UHCI: Reset completed!";
 }
 
-void UHCIController::create_structures()
+UNMAP_AFTER_INIT void UHCIController::create_structures()
 {
     // Let's allocate memory for botht the QH and TD pools
     // First the QH pool and all of the Interrupt QH's
@@ -224,7 +224,7 @@ void UHCIController::create_structures()
 #endif
 }
 
-void UHCIController::setup_schedule()
+UNMAP_AFTER_INIT void UHCIController::setup_schedule()
 {
     //
     // https://github.com/alkber/minix3-usbsubsystem/blob/master/usb/uhci-hcd.c

+ 1 - 1
Kernel/Devices/VMWareBackdoor.cpp

@@ -116,7 +116,7 @@ VMWareBackdoor* VMWareBackdoor::the()
     return s_vmware_backdoor->get_instance();
 }
 
-VMWareBackdoor::VMWareBackdoor()
+UNMAP_AFTER_INIT VMWareBackdoor::VMWareBackdoor()
 {
     if (kernel_command_line().lookup("vmmouse").value_or("on") == "on")
         enable_absolute_vmmouse();

+ 2 - 2
Kernel/Interrupts/IOAPIC.cpp

@@ -45,7 +45,7 @@ enum DeliveryMode {
     External = 7
 };
 
-IOAPIC::IOAPIC(PhysicalAddress address, u32 gsi_base)
+UNMAP_AFTER_INIT IOAPIC::IOAPIC(PhysicalAddress address, u32 gsi_base)
     : m_address(address)
     , m_regs(map_typed_writable<ioapic_mmio_regs>(m_address))
     , m_gsi_base(gsi_base)
@@ -60,7 +60,7 @@ IOAPIC::IOAPIC(PhysicalAddress address, u32 gsi_base)
     mask_all_redirection_entries();
 }
 
-void IOAPIC::initialize()
+UNMAP_AFTER_INIT void IOAPIC::initialize()
 {
 }
 

+ 2 - 2
Kernel/Interrupts/PIC.cpp

@@ -87,7 +87,7 @@ void PIC::disable(const GenericInterruptHandler& handler)
     m_cached_irq_mask |= 1 << irq;
 }
 
-PIC::PIC()
+UNMAP_AFTER_INIT PIC::PIC()
 {
     initialize();
 }
@@ -203,7 +203,7 @@ void PIC::remap(u8 offset)
     enable_vector(2);
 }
 
-void PIC::initialize()
+UNMAP_AFTER_INIT void PIC::initialize()
 {
     /* ICW1 (edge triggered mode, cascading controllers, expect ICW4) */
     IO::out8(PIC0_CTL, ICW1_INIT | ICW1_ICW4);

+ 1 - 1
Kernel/Interrupts/SharedIRQHandler.cpp

@@ -34,7 +34,7 @@
 
 namespace Kernel {
 
-void SharedIRQHandler::initialize(u8 interrupt_number)
+UNMAP_AFTER_INIT void SharedIRQHandler::initialize(u8 interrupt_number)
 {
     new SharedIRQHandler(interrupt_number);
 }

+ 1 - 1
Kernel/Interrupts/SpuriousInterruptHandler.cpp

@@ -29,7 +29,7 @@
 
 namespace Kernel {
 
-void SpuriousInterruptHandler::initialize(u8 interrupt_number)
+UNMAP_AFTER_INIT void SpuriousInterruptHandler::initialize(u8 interrupt_number)
 {
     new SpuriousInterruptHandler(interrupt_number);
 }

+ 2 - 2
Kernel/KSyms.cpp

@@ -68,7 +68,7 @@ const KernelSymbol* symbolicate_kernel_address(u32 address)
     return nullptr;
 }
 
-static void load_kernel_sybols_from_data(const KBuffer& buffer)
+UNMAP_AFTER_INIT static void load_kernel_sybols_from_data(const KBuffer& buffer)
 {
     g_lowest_kernel_symbol_address = 0xffffffff;
     g_highest_kernel_symbol_address = 0;
@@ -182,7 +182,7 @@ void dump_backtrace()
     dump_backtrace_impl(ebp, g_kernel_symbols_available);
 }
 
-void load_kernel_symbol_table()
+UNMAP_AFTER_INIT void load_kernel_symbol_table()
 {
     auto result = VFS::the().open("/res/kernel.map", O_RDONLY, 0, VFS::the().root_custody());
     if (!result.is_error()) {

+ 3 - 3
Kernel/Net/E1000NetworkAdapter.cpp

@@ -179,7 +179,7 @@ static bool is_valid_device_id(u16 device_id)
     }
 }
 
-void E1000NetworkAdapter::detect()
+UNMAP_AFTER_INIT void E1000NetworkAdapter::detect()
 {
     PCI::enumerate([&](const PCI::Address& address, PCI::ID id) {
         if (address.is_null())
@@ -193,7 +193,7 @@ void E1000NetworkAdapter::detect()
     });
 }
 
-E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address address, u8 irq)
+UNMAP_AFTER_INIT E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address address, u8 irq)
     : PCI::Device(address, irq)
     , m_io_base(PCI::get_BAR1(pci_address()) & ~1)
     , m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(page_round_up(sizeof(e1000_rx_desc) * number_of_rx_descriptors + 16), "E1000 RX", Region::Access::Read | Region::Access::Write))
@@ -235,7 +235,7 @@ E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address address, u8 irq)
     enable_irq();
 }
 
-E1000NetworkAdapter::~E1000NetworkAdapter()
+UNMAP_AFTER_INIT E1000NetworkAdapter::~E1000NetworkAdapter()
 {
 }
 

+ 3 - 3
Kernel/Net/NE2000NetworkAdapter.cpp

@@ -155,7 +155,7 @@ struct [[gnu::packed]] received_packet_header {
     u16 length;
 };
 
-void NE2000NetworkAdapter::detect()
+UNMAP_AFTER_INIT void NE2000NetworkAdapter::detect()
 {
     static const auto ne2k_ids = Array<PCI::ID, 11> {
         PCI::ID { 0x10EC, 0x8029 }, // RealTek RTL-8029(AS)
@@ -182,7 +182,7 @@ void NE2000NetworkAdapter::detect()
     });
 }
 
-NE2000NetworkAdapter::NE2000NetworkAdapter(PCI::Address address, u8 irq)
+UNMAP_AFTER_INIT NE2000NetworkAdapter::NE2000NetworkAdapter(PCI::Address address, u8 irq)
     : PCI::Device(address, irq)
     , m_io_base(PCI::get_BAR0(pci_address()) & ~3)
 {
@@ -203,7 +203,7 @@ NE2000NetworkAdapter::NE2000NetworkAdapter(PCI::Address address, u8 irq)
     enable_irq();
 }
 
-NE2000NetworkAdapter::~NE2000NetworkAdapter()
+UNMAP_AFTER_INIT NE2000NetworkAdapter::~NE2000NetworkAdapter()
 {
 }
 

+ 3 - 3
Kernel/Net/RTL8139NetworkAdapter.cpp

@@ -125,7 +125,7 @@ namespace Kernel {
 #define RX_BUFFER_SIZE 32768
 #define TX_BUFFER_SIZE PACKET_SIZE_MAX
 
-void RTL8139NetworkAdapter::detect()
+UNMAP_AFTER_INIT void RTL8139NetworkAdapter::detect()
 {
     static const PCI::ID rtl8139_id = { 0x10EC, 0x8139 };
     PCI::enumerate([&](const PCI::Address& address, PCI::ID id) {
@@ -138,7 +138,7 @@ void RTL8139NetworkAdapter::detect()
     });
 }
 
-RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address address, u8 irq)
+UNMAP_AFTER_INIT RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address address, u8 irq)
     : PCI::Device(address, irq)
     , m_io_base(PCI::get_BAR0(pci_address()) & ~1)
     , m_rx_buffer(MM.allocate_contiguous_kernel_region(page_round_up(RX_BUFFER_SIZE + PACKET_SIZE_MAX), "RTL8139 RX", Region::Access::Read | Region::Access::Write))
@@ -174,7 +174,7 @@ RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address address, u8 irq)
     enable_irq();
 }
 
-RTL8139NetworkAdapter::~RTL8139NetworkAdapter()
+UNMAP_AFTER_INIT RTL8139NetworkAdapter::~RTL8139NetworkAdapter()
 {
 }
 

+ 1 - 1
Kernel/PCI/Access.cpp

@@ -54,7 +54,7 @@ bool Access::is_initialized()
     return (s_access != nullptr);
 }
 
-Access::Access()
+UNMAP_AFTER_INIT Access::Access()
 {
     s_access = this;
 }

+ 2 - 2
Kernel/PCI/IOAccess.cpp

@@ -31,7 +31,7 @@
 namespace Kernel {
 namespace PCI {
 
-void IOAccess::initialize()
+UNMAP_AFTER_INIT void IOAccess::initialize()
 {
     if (!Access::is_initialized()) {
         new IOAccess();
@@ -39,7 +39,7 @@ void IOAccess::initialize()
     }
 }
 
-IOAccess::IOAccess()
+UNMAP_AFTER_INIT IOAccess::IOAccess()
 {
     klog() << "PCI: Using I/O instructions for PCI configuration space access";
     enumerate_hardware([&](const Address& address, ID id) {

+ 3 - 3
Kernel/PCI/Initializer.cpp

@@ -37,7 +37,7 @@ namespace PCI {
 
 static bool test_pci_io();
 
-static Access::Type detect_optimal_access_type(bool mmio_allowed)
+UNMAP_AFTER_INIT static Access::Type detect_optimal_access_type(bool mmio_allowed)
 {
     if (mmio_allowed && ACPI::is_enabled() && !ACPI::Parser::the()->find_table("MCFG").is_null())
         return Access::Type::MMIO;
@@ -48,7 +48,7 @@ static Access::Type detect_optimal_access_type(bool mmio_allowed)
     PANIC("No PCI bus access method detected!");
 }
 
-void initialize()
+UNMAP_AFTER_INIT void initialize()
 {
     bool mmio_allowed = kernel_command_line().lookup("pci_mmio").value_or("off") == "on";
 
@@ -61,7 +61,7 @@ void initialize()
     });
 }
 
-bool test_pci_io()
+UNMAP_AFTER_INIT bool test_pci_io()
 {
     klog() << "Testing PCI via manual probing... ";
     u32 tmp = 0x80000000;

+ 4 - 4
Kernel/PCI/MMIOAccess.cpp

@@ -49,7 +49,7 @@ private:
 
 #define PCI_MMIO_CONFIG_SPACE_SIZE 4096
 
-DeviceConfigurationSpaceMapping::DeviceConfigurationSpaceMapping(Address device_address, const MMIOSegment& mmio_segment)
+UNMAP_AFTER_INIT DeviceConfigurationSpaceMapping::DeviceConfigurationSpaceMapping(Address device_address, const MMIOSegment& mmio_segment)
     : m_device_address(device_address)
     , m_mapped_region(MM.allocate_kernel_region(page_round_up(PCI_MMIO_CONFIG_SPACE_SIZE), "PCI MMIO Device Access", Region::Access::Read | Region::Access::Write).release_nonnull())
 {
@@ -79,7 +79,7 @@ uint8_t MMIOAccess::segment_end_bus(u32 seg) const
     return segment.value().get_end_bus();
 }
 
-void MMIOAccess::initialize(PhysicalAddress mcfg)
+UNMAP_AFTER_INIT void MMIOAccess::initialize(PhysicalAddress mcfg)
 {
     if (!Access::is_initialized()) {
         new MMIOAccess(mcfg);
@@ -89,7 +89,7 @@ void MMIOAccess::initialize(PhysicalAddress mcfg)
     }
 }
 
-MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
+UNMAP_AFTER_INIT MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
     : m_mcfg(p_mcfg)
 {
     klog() << "PCI: Using MMIO for PCI configuration space access";
@@ -131,7 +131,7 @@ MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
     });
 }
 
-Optional<VirtualAddress> MMIOAccess::get_device_configuration_space(Address address)
+UNMAP_AFTER_INIT Optional<VirtualAddress> MMIOAccess::get_device_configuration_space(Address address)
 {
     dbgln_if(PCI_DEBUG, "PCI: Getting device configuration space for {}", address);
     for (auto& mapping : m_mapped_device_regions) {

+ 1 - 1
Kernel/Random.cpp

@@ -42,7 +42,7 @@ KernelRng& KernelRng::the()
     return *s_the;
 }
 
-KernelRng::KernelRng()
+UNMAP_AFTER_INIT KernelRng::KernelRng()
 {
     bool supports_rdseed = Processor::current().has_feature(CPUFeature::RDSEED);
     bool supports_rdrand = Processor::current().has_feature(CPUFeature::RDRAND);

+ 2 - 2
Kernel/Scheduler.cpp

@@ -506,13 +506,13 @@ UNMAP_AFTER_INIT void Scheduler::initialize()
     set_idle_thread(idle_thread);
 }
 
-void Scheduler::set_idle_thread(Thread* idle_thread)
+UNMAP_AFTER_INIT void Scheduler::set_idle_thread(Thread* idle_thread)
 {
     Processor::current().set_idle_thread(*idle_thread);
     Processor::current().set_current_thread(*idle_thread);
 }
 
-Thread* Scheduler::create_ap_idle_thread(u32 cpu)
+UNMAP_AFTER_INIT Thread* Scheduler::create_ap_idle_thread(u32 cpu)
 {
     ASSERT(cpu != 0);
     // This function is called on the bsp, but creates an idle thread for another AP

+ 3 - 3
Kernel/Storage/PATADiskDevice.cpp

@@ -33,12 +33,12 @@
 
 namespace Kernel {
 
-NonnullRefPtr<PATADiskDevice> PATADiskDevice::create(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 cylinders, u16 heads, u16 spt, u16 capabilities, int major, int minor)
+UNMAP_AFTER_INIT NonnullRefPtr<PATADiskDevice> PATADiskDevice::create(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 cylinders, u16 heads, u16 spt, u16 capabilities, int major, int minor)
 {
     return adopt(*new PATADiskDevice(controller, channel, type, interface_type, cylinders, heads, spt, capabilities, major, minor));
 }
 
-PATADiskDevice::PATADiskDevice(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 cylinders, u16 heads, u16 spt, u16 capabilities, int major, int minor)
+UNMAP_AFTER_INIT PATADiskDevice::PATADiskDevice(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 cylinders, u16 heads, u16 spt, u16 capabilities, int major, int minor)
     : StorageDevice(controller, major, minor, 512, 0)
     , m_cylinders(cylinders)
     , m_heads(heads)
@@ -50,7 +50,7 @@ PATADiskDevice::PATADiskDevice(const IDEController& controller, IDEChannel& chan
 {
 }
 
-PATADiskDevice::~PATADiskDevice()
+UNMAP_AFTER_INIT PATADiskDevice::~PATADiskDevice()
 {
 }
 

+ 2 - 2
Kernel/Storage/StorageManagement.cpp

@@ -41,7 +41,7 @@ namespace Kernel {
 
 static StorageManagement* s_the;
 
-StorageManagement::StorageManagement(String boot_argument, bool force_pio)
+UNMAP_AFTER_INIT StorageManagement::StorageManagement(String boot_argument, bool force_pio)
     : m_boot_argument(boot_argument)
     , m_controllers(enumerate_controllers(force_pio))
     , m_storage_devices(enumerate_storage_devices())
@@ -195,7 +195,7 @@ bool StorageManagement::initialized()
     return (s_the != nullptr);
 }
 
-void StorageManagement::initialize(String root_device, bool force_pio)
+UNMAP_AFTER_INIT void StorageManagement::initialize(String root_device, bool force_pio)
 {
     ASSERT(!StorageManagement::initialized());
     s_the = new StorageManagement(root_device, force_pio);

+ 3 - 3
Kernel/Time/HPET.cpp

@@ -130,7 +130,7 @@ HPET& HPET::the()
     return *s_hpet;
 }
 
-bool HPET::test_and_initialize()
+UNMAP_AFTER_INIT bool HPET::test_and_initialize()
 {
     ASSERT(!HPET::initialized());
     hpet_initialized = true;
@@ -154,7 +154,7 @@ bool HPET::test_and_initialize()
     return true;
 }
 
-bool HPET::check_for_exisiting_periodic_timers()
+UNMAP_AFTER_INIT bool HPET::check_for_exisiting_periodic_timers()
 {
     auto hpet = ACPI::Parser::the()->find_table("HPET");
     if (hpet.is_null())
@@ -396,7 +396,7 @@ u64 HPET::calculate_ticks_in_nanoseconds() const
     return ((u64)registers().capabilities.main_counter_tick_period * 100ull) / ABSOLUTE_MAXIMUM_COUNTER_TICK_PERIOD;
 }
 
-HPET::HPET(PhysicalAddress acpi_hpet)
+UNMAP_AFTER_INIT HPET::HPET(PhysicalAddress acpi_hpet)
     : m_physical_acpi_hpet_table(acpi_hpet)
     , m_physical_acpi_hpet_registers(find_acpi_hpet_registers_block())
     , m_hpet_mmio_region(MM.allocate_kernel_region(m_physical_acpi_hpet_registers.page_base(), PAGE_SIZE, "HPET MMIO", Region::Access::Read | Region::Access::Write))

+ 2 - 2
Kernel/Time/HPETComparator.cpp

@@ -31,12 +31,12 @@
 
 namespace Kernel {
 
-NonnullRefPtr<HPETComparator> HPETComparator::create(u8 number, u8 irq, bool periodic_capable)
+UNMAP_AFTER_INIT NonnullRefPtr<HPETComparator> HPETComparator::create(u8 number, u8 irq, bool periodic_capable)
 {
     return adopt(*new HPETComparator(number, irq, periodic_capable));
 }
 
-HPETComparator::HPETComparator(u8 number, u8 irq, bool periodic_capable)
+UNMAP_AFTER_INIT HPETComparator::HPETComparator(u8 number, u8 irq, bool periodic_capable)
     : HardwareTimer(irq)
     , m_periodic(false)
     , m_periodic_capable(periodic_capable)

+ 1 - 1
Kernel/TimerQueue.cpp

@@ -84,7 +84,7 @@ TimerQueue& TimerQueue::the()
     return *s_the;
 }
 
-TimerQueue::TimerQueue()
+UNMAP_AFTER_INIT TimerQueue::TimerQueue()
 {
     m_ticks_per_second = TimeManagement::the().ticks_per_second();
 }