mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +00:00 
			
		
		
		
	Kernel: Slap UNMAP_AFTER_INIT on a bunch more functions
We're now able to unmap 100 KiB of kernel text after init. :^)
This commit is contained in:
		
							parent
							
								
									e920c74cae
								
							
						
					
					
						commit
						2b2828ae52
					
				
					 36 changed files with 105 additions and 105 deletions
				
			
		|  | @ -30,7 +30,7 @@ | ||||||
| namespace Kernel { | namespace Kernel { | ||||||
| namespace ACPI { | namespace ACPI { | ||||||
| 
 | 
 | ||||||
| DynamicParser::DynamicParser(PhysicalAddress rsdp) | UNMAP_AFTER_INIT DynamicParser::DynamicParser(PhysicalAddress rsdp) | ||||||
|     : IRQHandler(9) |     : IRQHandler(9) | ||||||
|     , Parser(rsdp) |     , Parser(rsdp) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -37,7 +37,7 @@ enum class FeatureLevel { | ||||||
|     Disabled, |     Disabled, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| static FeatureLevel determine_feature_level() | UNMAP_AFTER_INIT static FeatureLevel determine_feature_level() | ||||||
| { | { | ||||||
|     auto value = kernel_command_line().lookup("acpi").value_or("on"); |     auto value = kernel_command_line().lookup("acpi").value_or("on"); | ||||||
|     if (value == "limited") |     if (value == "limited") | ||||||
|  | @ -47,7 +47,7 @@ static FeatureLevel determine_feature_level() | ||||||
|     return FeatureLevel::Enabled; |     return FeatureLevel::Enabled; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void initialize() | UNMAP_AFTER_INIT void initialize() | ||||||
| { | { | ||||||
|     auto feature_level = determine_feature_level(); |     auto feature_level = determine_feature_level(); | ||||||
|     if (feature_level == FeatureLevel::Disabled) |     if (feature_level == FeatureLevel::Disabled) | ||||||
|  |  | ||||||
|  | @ -36,7 +36,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Kernel { | namespace Kernel { | ||||||
| 
 | 
 | ||||||
| OwnPtr<MultiProcessorParser> MultiProcessorParser::autodetect() | UNMAP_AFTER_INIT OwnPtr<MultiProcessorParser> MultiProcessorParser::autodetect() | ||||||
| { | { | ||||||
|     auto floating_pointer = find_floating_pointer(); |     auto floating_pointer = find_floating_pointer(); | ||||||
|     if (!floating_pointer.has_value()) |     if (!floating_pointer.has_value()) | ||||||
|  | @ -44,7 +44,7 @@ OwnPtr<MultiProcessorParser> MultiProcessorParser::autodetect() | ||||||
|     return adopt_own(*new MultiProcessorParser(floating_pointer.value())); |     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) |     : m_floating_pointer(floating_pointer) | ||||||
| { | { | ||||||
|     klog() << "MultiProcessor: Floating Pointer Structure @ " << m_floating_pointer; |     klog() << "MultiProcessor: Floating Pointer Structure @ " << m_floating_pointer; | ||||||
|  | @ -52,14 +52,14 @@ MultiProcessorParser::MultiProcessorParser(PhysicalAddress floating_pointer) | ||||||
|     parse_configuration_table(); |     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); |     auto floating_pointer = map_typed<MultiProcessor::FloatingPointer>(m_floating_pointer); | ||||||
|     m_configuration_table = PhysicalAddress(floating_pointer->physical_address_ptr); |     m_configuration_table = PhysicalAddress(floating_pointer->physical_address_ptr); | ||||||
|     dbgln("Features {}, IMCR? {}", floating_pointer->feature_info[0], (floating_pointer->feature_info[0] & (1 << 7))); |     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 configuration_table_length = map_typed<MultiProcessor::ConfigurationTableHeader>(m_configuration_table)->length; | ||||||
|     auto config_table = map_typed<MultiProcessor::ConfigurationTableHeader>(m_configuration_table, 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_"); |     StringView signature("_MP_"); | ||||||
|     auto mp_floating_pointer = map_ebda().find_chunk_starting_with(signature, 16); |     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); |     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; |     Vector<u8> pci_bus_ids; | ||||||
|     for (auto& entry : m_bus_entries) { |     for (auto& entry : m_bus_entries) { | ||||||
|  | @ -121,7 +121,7 @@ Vector<u8> MultiProcessorParser::get_pci_bus_ids() const | ||||||
|     return pci_bus_ids; |     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"); |     dbgln("MultiProcessor: Get PCI IOAPIC redirections"); | ||||||
|     Vector<PCIInterruptOverrideMetadata> overrides; |     Vector<PCIInterruptOverrideMetadata> overrides; | ||||||
|  | @ -148,7 +148,7 @@ Vector<PCIInterruptOverrideMetadata> MultiProcessorParser::get_pci_interrupt_red | ||||||
|     return overrides; |     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_bus_id(bus_id) | ||||||
|     , m_polarity(polarity) |     , m_polarity(polarity) | ||||||
|     , m_trigger_mode(trigger_mode) |     , m_trigger_mode(trigger_mode) | ||||||
|  |  | ||||||
|  | @ -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 PhysicalAddress search_table_in_rsdt(PhysicalAddress rsdt, const StringView& signature); | ||||||
| static bool validate_table(const Structures::SDTHeader&, size_t length); | 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(); |     locate_main_system_description_table(); | ||||||
|     initialize_main_system_description_table(); |     initialize_main_system_description_table(); | ||||||
|  | @ -64,7 +64,7 @@ void Parser::locate_static_data() | ||||||
|     init_facs(); |     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!"); |     dbgln_if(ACPI_DEBUG, "ACPI: Calling Find Table method!"); | ||||||
|     for (auto p_sdt : m_sdt_pointers) { |     for (auto p_sdt : m_sdt_pointers) { | ||||||
|  | @ -78,12 +78,12 @@ PhysicalAddress Parser::find_table(const StringView& signature) | ||||||
|     return {}; |     return {}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Parser::init_facs() | UNMAP_AFTER_INIT void Parser::init_facs() | ||||||
| { | { | ||||||
|     m_facs = find_table("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: Initializing Fixed ACPI data"; | ||||||
|     klog() << "ACPI: Searching for the Fixed ACPI Data Table"; |     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; |     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 | #if ACPI_DEBUG | ||||||
|     dbgln("ACPI: Checking Main SDT Length to choose the correct mapping size"); |     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); |     auto rsdp = map_typed<Structures::RSDPDescriptor20>(m_rsdp); | ||||||
|     if (rsdp->base.revision == 0) { |     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) |     : m_rsdp(rsdp) | ||||||
| { | { | ||||||
|     klog() << "ACPI: Using 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; |     return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Optional<PhysicalAddress> StaticParsing::find_rsdp() | UNMAP_AFTER_INIT Optional<PhysicalAddress> StaticParsing::find_rsdp() | ||||||
| { | { | ||||||
|     StringView signature("RSD PTR "); |     StringView signature("RSD PTR "); | ||||||
|     auto rsdp = map_ebda().find_chunk_starting_with(signature, 16); |     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); |     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.
 |     // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
 | ||||||
|     ASSERT(signature.length() == 4); |     ASSERT(signature.length() == 4); | ||||||
|  | @ -348,7 +348,7 @@ PhysicalAddress StaticParsing::find_table(PhysicalAddress rsdp_address, const St | ||||||
|     ASSERT_NOT_REACHED(); |     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.
 |     // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
 | ||||||
|     ASSERT(signature.length() == 4); |     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); |     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.
 |     // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
 | ||||||
|     ASSERT(signature.length() == 4); |     ASSERT(signature.length() == 4); | ||||||
|  |  | ||||||
|  | @ -730,7 +730,7 @@ NEVER_INLINE UNMAP_AFTER_INIT void write_cr4(u32 value) | ||||||
|     asm volatile("movl %%eax, %%cr4" ::"a"(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_cr0((read_cr0() & 0xfffffffbu) | 0x2); | ||||||
|     write_cr4(read_cr4() | 0x600); |     write_cr4(read_cr4() | 0x600); | ||||||
|  | @ -1540,7 +1540,7 @@ void Processor::assume_context(Thread& thread, u32 flags) | ||||||
|     ASSERT_NOT_REACHED(); |     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()); |     ASSERT(g_scheduler_lock.own_lock()); | ||||||
| 
 | 
 | ||||||
|  | @ -1553,14 +1553,14 @@ extern "C" void pre_init_finished(void) | ||||||
|     Scheduler::leave_on_first_switch(prev_flags); |     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
 |     // We need to re-acquire the scheduler lock before a context switch
 | ||||||
|     // transfers control into the idle loop, which needs the lock held
 |     // transfers control into the idle loop, which needs the lock held
 | ||||||
|     Scheduler::prepare_for_idle_loop(); |     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()); |     ASSERT(initial_thread.process().is_kernel_process()); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ namespace Kernel { | ||||||
| static char s_cmd_line[1024]; | static char s_cmd_line[1024]; | ||||||
| static CommandLine* s_the; | 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) |     if (!cmd_line) | ||||||
|         return; |         return; | ||||||
|  | @ -49,13 +49,13 @@ const CommandLine& kernel_command_line() | ||||||
|     return *s_the; |     return *s_the; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CommandLine::initialize() | UNMAP_AFTER_INIT void CommandLine::initialize() | ||||||
| { | { | ||||||
|     ASSERT(!s_the); |     ASSERT(!s_the); | ||||||
|     s_the = new CommandLine(s_cmd_line); |     s_the = new CommandLine(s_cmd_line); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| CommandLine::CommandLine(const String& string) | UNMAP_AFTER_INIT CommandLine::CommandLine(const String& string) | ||||||
|     : m_string(string) |     : m_string(string) | ||||||
| { | { | ||||||
|     s_the = this; |     s_the = this; | ||||||
|  |  | ||||||
|  | @ -56,7 +56,7 @@ UNMAP_AFTER_INIT Console::Console() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Console::~Console() | UNMAP_AFTER_INIT Console::~Console() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -42,7 +42,7 @@ namespace Kernel { | ||||||
| 
 | 
 | ||||||
| AK::Singleton<DMIExpose> s_the; | 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; |     klog() << "DMIExpose: SMBIOS 64bit Entry point @ " << m_entry_point; | ||||||
|     auto smbios_entry = map_typed<SMBIOS::EntryPoint64bit>(PhysicalAddress(m_entry_point), SMBIOS_SEARCH_AREA_SIZE); |     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; |     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; |     klog() << "DMIExpose: SMBIOS 32bit Entry point @ " << m_entry_point; | ||||||
|     auto smbios_entry = map_typed<SMBIOS::EntryPoint32bit>(PhysicalAddress(m_entry_point), SMBIOS_SEARCH_AREA_SIZE); |     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; |     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(); |     s_the.ensure_instance(); | ||||||
| } | } | ||||||
|  | @ -79,7 +79,7 @@ size_t DMIExpose::structure_table_length() const | ||||||
|     return m_structure_table_length; |     return m_structure_table_length; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void DMIExpose::initialize_exposer() | UNMAP_AFTER_INIT void DMIExpose::initialize_exposer() | ||||||
| { | { | ||||||
|     ASSERT(!(m_entry_point.is_null())); |     ASSERT(!(m_entry_point.is_null())); | ||||||
|     if (m_using_64bit_entry_point) { |     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 }); |     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(); |     auto entry_32bit = find_entry32bit_point(); | ||||||
|     m_entry_point = entry_32bit.value(); |     m_entry_point = entry_32bit.value(); | ||||||
|  | @ -117,12 +117,12 @@ DMIExpose::DMIExpose() | ||||||
|     initialize_exposer(); |     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); |     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); |     return map_bios().find_chunk_starting_with("_SM_", 16); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -60,7 +60,7 @@ namespace Kernel { | ||||||
| 
 | 
 | ||||||
| static AK::Singleton<BXVGADevice> s_the; | static AK::Singleton<BXVGADevice> s_the; | ||||||
| 
 | 
 | ||||||
| void BXVGADevice::initialize() | UNMAP_AFTER_INIT void BXVGADevice::initialize() | ||||||
| { | { | ||||||
|     s_the.ensure_instance(); |     s_the.ensure_instance(); | ||||||
| } | } | ||||||
|  | @ -70,7 +70,7 @@ BXVGADevice& BXVGADevice::the() | ||||||
|     return *s_the; |     return *s_the; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| BXVGADevice::BXVGADevice() | UNMAP_AFTER_INIT BXVGADevice::BXVGADevice() | ||||||
|     : BlockDevice(29, 0) |     : 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); |     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.
 |     // NOTE: The QEMU card has the same PCI ID as the Bochs one.
 | ||||||
|     static const PCI::ID bochs_vga_id = { 0x1234, 0x1111 }; |     static const PCI::ID bochs_vga_id = { 0x1234, 0x1111 }; | ||||||
|  |  | ||||||
|  | @ -404,7 +404,7 @@ static const Keyboard::CharacterMapData DEFAULT_CHARACTER_MAP = | ||||||
| }; | }; | ||||||
| // clang-format on
 | // clang-format on
 | ||||||
| 
 | 
 | ||||||
| KeyboardDevice::KeyboardDevice() | UNMAP_AFTER_INIT KeyboardDevice::KeyboardDevice() | ||||||
|     : IRQHandler(IRQ_KEYBOARD) |     : IRQHandler(IRQ_KEYBOARD) | ||||||
|     , CharacterDevice(85, 1) |     , CharacterDevice(85, 1) | ||||||
|     , m_controller(I8042Controller::the()) |     , 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)) { |     if (!m_controller.reset_device(I8042Controller::Device::Keyboard)) { | ||||||
|         dbgln("KeyboardDevice: I8042 controller failed to reset device"); |         dbgln("KeyboardDevice: I8042 controller failed to reset device"); | ||||||
|  |  | ||||||
|  | @ -40,7 +40,7 @@ MBVGADevice& MBVGADevice::the() | ||||||
|     return *s_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) |     : BlockDevice(29, 0) | ||||||
|     , m_framebuffer_address(addr) |     , m_framebuffer_address(addr) | ||||||
|     , m_framebuffer_pitch(pitch) |     , m_framebuffer_pitch(pitch) | ||||||
|  |  | ||||||
|  | @ -33,12 +33,12 @@ | ||||||
| 
 | 
 | ||||||
| namespace Kernel { | namespace Kernel { | ||||||
| 
 | 
 | ||||||
| MemoryDevice::MemoryDevice() | UNMAP_AFTER_INIT MemoryDevice::MemoryDevice() | ||||||
|     : CharacterDevice(1, 1) |     : CharacterDevice(1, 1) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| MemoryDevice::~MemoryDevice() | UNMAP_AFTER_INIT MemoryDevice::~MemoryDevice() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -51,14 +51,14 @@ namespace Kernel { | ||||||
| 
 | 
 | ||||||
| static AK::Singleton<PS2MouseDevice> s_the; | static AK::Singleton<PS2MouseDevice> s_the; | ||||||
| 
 | 
 | ||||||
| PS2MouseDevice::PS2MouseDevice() | UNMAP_AFTER_INIT PS2MouseDevice::PS2MouseDevice() | ||||||
|     : IRQHandler(IRQ_MOUSE) |     : IRQHandler(IRQ_MOUSE) | ||||||
|     , CharacterDevice(10, 1) |     , CharacterDevice(10, 1) | ||||||
|     , m_controller(I8042Controller::the()) |     , 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); |     send_command(PS2MOUSE_SET_SAMPLE_RATE, rate); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool PS2MouseDevice::initialize() | UNMAP_AFTER_INIT bool PS2MouseDevice::initialize() | ||||||
| { | { | ||||||
|     if (!m_controller.reset_device(I8042Controller::Device::Mouse)) { |     if (!m_controller.reset_device(I8042Controller::Device::Mouse)) { | ||||||
|         dbgln("PS2MouseDevice: I8042 controller failed to reset device"); |         dbgln("PS2MouseDevice: I8042 controller failed to reset device"); | ||||||
|  |  | ||||||
|  | @ -78,18 +78,18 @@ void SB16::set_sample_rate(uint16_t hz) | ||||||
| 
 | 
 | ||||||
| static AK::Singleton<SB16> s_the; | static AK::Singleton<SB16> s_the; | ||||||
| 
 | 
 | ||||||
| SB16::SB16() | UNMAP_AFTER_INIT SB16::SB16() | ||||||
|     : IRQHandler(SB16_DEFAULT_IRQ) |     : IRQHandler(SB16_DEFAULT_IRQ) | ||||||
|     , CharacterDevice(42, 42) // ### ?
 |     , CharacterDevice(42, 42) // ### ?
 | ||||||
| { | { | ||||||
|     initialize(); |     initialize(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| SB16::~SB16() | UNMAP_AFTER_INIT SB16::~SB16() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void SB16::detect() | UNMAP_AFTER_INIT void SB16::detect() | ||||||
| { | { | ||||||
|     IO::out8(0x226, 1); |     IO::out8(0x226, 1); | ||||||
|     IO::delay(32); |     IO::delay(32); | ||||||
|  | @ -102,7 +102,7 @@ void SB16::detect() | ||||||
|     SB16::create(); |     SB16::create(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void SB16::create() | UNMAP_AFTER_INIT void SB16::create() | ||||||
| { | { | ||||||
|     s_the.ensure_instance(); |     s_the.ensure_instance(); | ||||||
| } | } | ||||||
|  | @ -112,7 +112,7 @@ SB16& SB16::the() | ||||||
|     return *s_the; |     return *s_the; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void SB16::initialize() | UNMAP_AFTER_INIT void SB16::initialize() | ||||||
| { | { | ||||||
|     disable_irq(); |     disable_irq(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -29,14 +29,14 @@ | ||||||
| 
 | 
 | ||||||
| namespace Kernel { | namespace Kernel { | ||||||
| 
 | 
 | ||||||
| SerialDevice::SerialDevice(int base_addr, unsigned minor) | UNMAP_AFTER_INIT SerialDevice::SerialDevice(int base_addr, unsigned minor) | ||||||
|     : CharacterDevice(4, minor) |     : CharacterDevice(4, minor) | ||||||
|     , m_base_addr(base_addr) |     , m_base_addr(base_addr) | ||||||
| { | { | ||||||
|     initialize(); |     initialize(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| SerialDevice::~SerialDevice() | UNMAP_AFTER_INIT SerialDevice::~SerialDevice() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -92,7 +92,7 @@ String SerialDevice::device_name() const | ||||||
|     return String::formatted("ttyS{}", minor() - 64); |     return String::formatted("ttyS{}", minor() - 64); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void SerialDevice::initialize() | UNMAP_AFTER_INIT void SerialDevice::initialize() | ||||||
| { | { | ||||||
|     set_interrupts(0); |     set_interrupts(0); | ||||||
|     set_baud(Baud38400); |     set_baud(Baud38400); | ||||||
|  | @ -101,7 +101,7 @@ void SerialDevice::initialize() | ||||||
|     set_modem_control(RequestToSend | DataTerminalReady); |     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; |     m_interrupt_enable = interrupt_enable; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -86,7 +86,7 @@ UHCIController& UHCIController::the() | ||||||
|     return *s_the; |     return *s_the; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void UHCIController::detect() | UNMAP_AFTER_INIT void UHCIController::detect() | ||||||
| { | { | ||||||
| #if !UHCI_ENABLED | #if !UHCI_ENABLED | ||||||
|     return; |     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) |     : PCI::Device(address) | ||||||
|     , m_io_base(PCI::get_BAR4(pci_address()) & ~1) |     , m_io_base(PCI::get_BAR4(pci_address()) & ~1) | ||||||
| { | { | ||||||
|  | @ -116,7 +116,7 @@ UHCIController::UHCIController(PCI::Address address, PCI::ID id) | ||||||
|     spawn_port_proc(); |     spawn_port_proc(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| UHCIController::~UHCIController() | UNMAP_AFTER_INIT UHCIController::~UHCIController() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -151,7 +151,7 @@ void UHCIController::reset() | ||||||
|     klog() << "UHCI: Reset completed!"; |     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
 |     // Let's allocate memory for botht the QH and TD pools
 | ||||||
|     // First the QH pool and all of the Interrupt QH's
 |     // First the QH pool and all of the Interrupt QH's
 | ||||||
|  | @ -224,7 +224,7 @@ void UHCIController::create_structures() | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void UHCIController::setup_schedule() | UNMAP_AFTER_INIT void UHCIController::setup_schedule() | ||||||
| { | { | ||||||
|     //
 |     //
 | ||||||
|     // https://github.com/alkber/minix3-usbsubsystem/blob/master/usb/uhci-hcd.c
 |     // https://github.com/alkber/minix3-usbsubsystem/blob/master/usb/uhci-hcd.c
 | ||||||
|  |  | ||||||
|  | @ -116,7 +116,7 @@ VMWareBackdoor* VMWareBackdoor::the() | ||||||
|     return s_vmware_backdoor->get_instance(); |     return s_vmware_backdoor->get_instance(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| VMWareBackdoor::VMWareBackdoor() | UNMAP_AFTER_INIT VMWareBackdoor::VMWareBackdoor() | ||||||
| { | { | ||||||
|     if (kernel_command_line().lookup("vmmouse").value_or("on") == "on") |     if (kernel_command_line().lookup("vmmouse").value_or("on") == "on") | ||||||
|         enable_absolute_vmmouse(); |         enable_absolute_vmmouse(); | ||||||
|  |  | ||||||
|  | @ -45,7 +45,7 @@ enum DeliveryMode { | ||||||
|     External = 7 |     External = 7 | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| IOAPIC::IOAPIC(PhysicalAddress address, u32 gsi_base) | UNMAP_AFTER_INIT IOAPIC::IOAPIC(PhysicalAddress address, u32 gsi_base) | ||||||
|     : m_address(address) |     : m_address(address) | ||||||
|     , m_regs(map_typed_writable<ioapic_mmio_regs>(m_address)) |     , m_regs(map_typed_writable<ioapic_mmio_regs>(m_address)) | ||||||
|     , m_gsi_base(gsi_base) |     , m_gsi_base(gsi_base) | ||||||
|  | @ -60,7 +60,7 @@ IOAPIC::IOAPIC(PhysicalAddress address, u32 gsi_base) | ||||||
|     mask_all_redirection_entries(); |     mask_all_redirection_entries(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void IOAPIC::initialize() | UNMAP_AFTER_INIT void IOAPIC::initialize() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -87,7 +87,7 @@ void PIC::disable(const GenericInterruptHandler& handler) | ||||||
|     m_cached_irq_mask |= 1 << irq; |     m_cached_irq_mask |= 1 << irq; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| PIC::PIC() | UNMAP_AFTER_INIT PIC::PIC() | ||||||
| { | { | ||||||
|     initialize(); |     initialize(); | ||||||
| } | } | ||||||
|  | @ -203,7 +203,7 @@ void PIC::remap(u8 offset) | ||||||
|     enable_vector(2); |     enable_vector(2); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void PIC::initialize() | UNMAP_AFTER_INIT void PIC::initialize() | ||||||
| { | { | ||||||
|     /* ICW1 (edge triggered mode, cascading controllers, expect ICW4) */ |     /* ICW1 (edge triggered mode, cascading controllers, expect ICW4) */ | ||||||
|     IO::out8(PIC0_CTL, ICW1_INIT | ICW1_ICW4); |     IO::out8(PIC0_CTL, ICW1_INIT | ICW1_ICW4); | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Kernel { | namespace Kernel { | ||||||
| 
 | 
 | ||||||
| void SharedIRQHandler::initialize(u8 interrupt_number) | UNMAP_AFTER_INIT void SharedIRQHandler::initialize(u8 interrupt_number) | ||||||
| { | { | ||||||
|     new SharedIRQHandler(interrupt_number); |     new SharedIRQHandler(interrupt_number); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Kernel { | namespace Kernel { | ||||||
| 
 | 
 | ||||||
| void SpuriousInterruptHandler::initialize(u8 interrupt_number) | UNMAP_AFTER_INIT void SpuriousInterruptHandler::initialize(u8 interrupt_number) | ||||||
| { | { | ||||||
|     new SpuriousInterruptHandler(interrupt_number); |     new SpuriousInterruptHandler(interrupt_number); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -68,7 +68,7 @@ const KernelSymbol* symbolicate_kernel_address(u32 address) | ||||||
|     return nullptr; |     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_lowest_kernel_symbol_address = 0xffffffff; | ||||||
|     g_highest_kernel_symbol_address = 0; |     g_highest_kernel_symbol_address = 0; | ||||||
|  | @ -182,7 +182,7 @@ void dump_backtrace() | ||||||
|     dump_backtrace_impl(ebp, g_kernel_symbols_available); |     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()); |     auto result = VFS::the().open("/res/kernel.map", O_RDONLY, 0, VFS::the().root_custody()); | ||||||
|     if (!result.is_error()) { |     if (!result.is_error()) { | ||||||
|  |  | ||||||
|  | @ -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) { |     PCI::enumerate([&](const PCI::Address& address, PCI::ID id) { | ||||||
|         if (address.is_null()) |         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) |     : PCI::Device(address, irq) | ||||||
|     , m_io_base(PCI::get_BAR1(pci_address()) & ~1) |     , 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)) |     , 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(); |     enable_irq(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| E1000NetworkAdapter::~E1000NetworkAdapter() | UNMAP_AFTER_INIT E1000NetworkAdapter::~E1000NetworkAdapter() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -155,7 +155,7 @@ struct [[gnu::packed]] received_packet_header { | ||||||
|     u16 length; |     u16 length; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| void NE2000NetworkAdapter::detect() | UNMAP_AFTER_INIT void NE2000NetworkAdapter::detect() | ||||||
| { | { | ||||||
|     static const auto ne2k_ids = Array<PCI::ID, 11> { |     static const auto ne2k_ids = Array<PCI::ID, 11> { | ||||||
|         PCI::ID { 0x10EC, 0x8029 }, // RealTek RTL-8029(AS)
 |         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) |     : PCI::Device(address, irq) | ||||||
|     , m_io_base(PCI::get_BAR0(pci_address()) & ~3) |     , m_io_base(PCI::get_BAR0(pci_address()) & ~3) | ||||||
| { | { | ||||||
|  | @ -203,7 +203,7 @@ NE2000NetworkAdapter::NE2000NetworkAdapter(PCI::Address address, u8 irq) | ||||||
|     enable_irq(); |     enable_irq(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| NE2000NetworkAdapter::~NE2000NetworkAdapter() | UNMAP_AFTER_INIT NE2000NetworkAdapter::~NE2000NetworkAdapter() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -125,7 +125,7 @@ namespace Kernel { | ||||||
| #define RX_BUFFER_SIZE 32768 | #define RX_BUFFER_SIZE 32768 | ||||||
| #define TX_BUFFER_SIZE PACKET_SIZE_MAX | #define TX_BUFFER_SIZE PACKET_SIZE_MAX | ||||||
| 
 | 
 | ||||||
| void RTL8139NetworkAdapter::detect() | UNMAP_AFTER_INIT void RTL8139NetworkAdapter::detect() | ||||||
| { | { | ||||||
|     static const PCI::ID rtl8139_id = { 0x10EC, 0x8139 }; |     static const PCI::ID rtl8139_id = { 0x10EC, 0x8139 }; | ||||||
|     PCI::enumerate([&](const PCI::Address& address, PCI::ID id) { |     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) |     : PCI::Device(address, irq) | ||||||
|     , m_io_base(PCI::get_BAR0(pci_address()) & ~1) |     , 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)) |     , 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(); |     enable_irq(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| RTL8139NetworkAdapter::~RTL8139NetworkAdapter() | UNMAP_AFTER_INIT RTL8139NetworkAdapter::~RTL8139NetworkAdapter() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -54,7 +54,7 @@ bool Access::is_initialized() | ||||||
|     return (s_access != nullptr); |     return (s_access != nullptr); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Access::Access() | UNMAP_AFTER_INIT Access::Access() | ||||||
| { | { | ||||||
|     s_access = this; |     s_access = this; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ | ||||||
| namespace Kernel { | namespace Kernel { | ||||||
| namespace PCI { | namespace PCI { | ||||||
| 
 | 
 | ||||||
| void IOAccess::initialize() | UNMAP_AFTER_INIT void IOAccess::initialize() | ||||||
| { | { | ||||||
|     if (!Access::is_initialized()) { |     if (!Access::is_initialized()) { | ||||||
|         new IOAccess(); |         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"; |     klog() << "PCI: Using I/O instructions for PCI configuration space access"; | ||||||
|     enumerate_hardware([&](const Address& address, ID id) { |     enumerate_hardware([&](const Address& address, ID id) { | ||||||
|  |  | ||||||
|  | @ -37,7 +37,7 @@ namespace PCI { | ||||||
| 
 | 
 | ||||||
| static bool test_pci_io(); | 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()) |     if (mmio_allowed && ACPI::is_enabled() && !ACPI::Parser::the()->find_table("MCFG").is_null()) | ||||||
|         return Access::Type::MMIO; |         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!"); |     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"; |     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... "; |     klog() << "Testing PCI via manual probing... "; | ||||||
|     u32 tmp = 0x80000000; |     u32 tmp = 0x80000000; | ||||||
|  |  | ||||||
|  | @ -49,7 +49,7 @@ private: | ||||||
| 
 | 
 | ||||||
| #define PCI_MMIO_CONFIG_SPACE_SIZE 4096 | #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_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()) |     , 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(); |     return segment.value().get_end_bus(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MMIOAccess::initialize(PhysicalAddress mcfg) | UNMAP_AFTER_INIT void MMIOAccess::initialize(PhysicalAddress mcfg) | ||||||
| { | { | ||||||
|     if (!Access::is_initialized()) { |     if (!Access::is_initialized()) { | ||||||
|         new MMIOAccess(mcfg); |         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) |     : m_mcfg(p_mcfg) | ||||||
| { | { | ||||||
|     klog() << "PCI: Using MMIO for PCI configuration space access"; |     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); |     dbgln_if(PCI_DEBUG, "PCI: Getting device configuration space for {}", address); | ||||||
|     for (auto& mapping : m_mapped_device_regions) { |     for (auto& mapping : m_mapped_device_regions) { | ||||||
|  |  | ||||||
|  | @ -42,7 +42,7 @@ KernelRng& KernelRng::the() | ||||||
|     return *s_the; |     return *s_the; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| KernelRng::KernelRng() | UNMAP_AFTER_INIT KernelRng::KernelRng() | ||||||
| { | { | ||||||
|     bool supports_rdseed = Processor::current().has_feature(CPUFeature::RDSEED); |     bool supports_rdseed = Processor::current().has_feature(CPUFeature::RDSEED); | ||||||
|     bool supports_rdrand = Processor::current().has_feature(CPUFeature::RDRAND); |     bool supports_rdrand = Processor::current().has_feature(CPUFeature::RDRAND); | ||||||
|  |  | ||||||
|  | @ -506,13 +506,13 @@ UNMAP_AFTER_INIT void Scheduler::initialize() | ||||||
|     set_idle_thread(idle_thread); |     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_idle_thread(*idle_thread); | ||||||
|     Processor::current().set_current_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); |     ASSERT(cpu != 0); | ||||||
|     // This function is called on the bsp, but creates an idle thread for another AP
 |     // This function is called on the bsp, but creates an idle thread for another AP
 | ||||||
|  |  | ||||||
|  | @ -33,12 +33,12 @@ | ||||||
| 
 | 
 | ||||||
| namespace Kernel { | 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)); |     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) |     : StorageDevice(controller, major, minor, 512, 0) | ||||||
|     , m_cylinders(cylinders) |     , m_cylinders(cylinders) | ||||||
|     , m_heads(heads) |     , m_heads(heads) | ||||||
|  | @ -50,7 +50,7 @@ PATADiskDevice::PATADiskDevice(const IDEController& controller, IDEChannel& chan | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| PATADiskDevice::~PATADiskDevice() | UNMAP_AFTER_INIT PATADiskDevice::~PATADiskDevice() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -41,7 +41,7 @@ namespace Kernel { | ||||||
| 
 | 
 | ||||||
| static StorageManagement* s_the; | 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_boot_argument(boot_argument) | ||||||
|     , m_controllers(enumerate_controllers(force_pio)) |     , m_controllers(enumerate_controllers(force_pio)) | ||||||
|     , m_storage_devices(enumerate_storage_devices()) |     , m_storage_devices(enumerate_storage_devices()) | ||||||
|  | @ -195,7 +195,7 @@ bool StorageManagement::initialized() | ||||||
|     return (s_the != nullptr); |     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()); |     ASSERT(!StorageManagement::initialized()); | ||||||
|     s_the = new StorageManagement(root_device, force_pio); |     s_the = new StorageManagement(root_device, force_pio); | ||||||
|  |  | ||||||
|  | @ -130,7 +130,7 @@ HPET& HPET::the() | ||||||
|     return *s_hpet; |     return *s_hpet; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool HPET::test_and_initialize() | UNMAP_AFTER_INIT bool HPET::test_and_initialize() | ||||||
| { | { | ||||||
|     ASSERT(!HPET::initialized()); |     ASSERT(!HPET::initialized()); | ||||||
|     hpet_initialized = true; |     hpet_initialized = true; | ||||||
|  | @ -154,7 +154,7 @@ bool HPET::test_and_initialize() | ||||||
|     return true; |     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"); |     auto hpet = ACPI::Parser::the()->find_table("HPET"); | ||||||
|     if (hpet.is_null()) |     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; |     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_table(acpi_hpet) | ||||||
|     , m_physical_acpi_hpet_registers(find_acpi_hpet_registers_block()) |     , 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)) |     , 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)) | ||||||
|  |  | ||||||
|  | @ -31,12 +31,12 @@ | ||||||
| 
 | 
 | ||||||
| namespace Kernel { | 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)); |     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) |     : HardwareTimer(irq) | ||||||
|     , m_periodic(false) |     , m_periodic(false) | ||||||
|     , m_periodic_capable(periodic_capable) |     , m_periodic_capable(periodic_capable) | ||||||
|  |  | ||||||
|  | @ -84,7 +84,7 @@ TimerQueue& TimerQueue::the() | ||||||
|     return *s_the; |     return *s_the; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TimerQueue::TimerQueue() | UNMAP_AFTER_INIT TimerQueue::TimerQueue() | ||||||
| { | { | ||||||
|     m_ticks_per_second = TimeManagement::the().ticks_per_second(); |     m_ticks_per_second = TimeManagement::the().ticks_per_second(); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling