diff options
author | Shannon Booth <shannon.ml.booth@gmail.com> | 2020-03-22 13:12:45 +1300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-22 01:22:32 +0100 |
commit | 81adefef27283d6d0f0bcd88099e4f1076317ace (patch) | |
tree | 3005a4ff98c750c465feed5a255c5085461cd645 | |
parent | d0629d0a8c92544ed9c8707a36191fbbc6996620 (diff) | |
download | serenity-81adefef27283d6d0f0bcd88099e4f1076317ace.zip |
Kernel: Run clang-format on files
Let's rip off the band-aid
-rw-r--r-- | Kernel/ACPI/ACPIDynamicParser.cpp | 114 | ||||
-rw-r--r-- | Kernel/ACPI/ACPIDynamicParser.h | 42 | ||||
-rw-r--r-- | Kernel/ACPI/ACPIParser.cpp | 140 | ||||
-rw-r--r-- | Kernel/ACPI/ACPIStaticParser.cpp | 716 | ||||
-rw-r--r-- | Kernel/ACPI/ACPIStaticParser.h | 70 | ||||
-rw-r--r-- | Kernel/ACPI/DMIDecoder.h | 2692 | ||||
-rw-r--r-- | Kernel/ACPI/Definitions.h | 580 | ||||
-rw-r--r-- | Kernel/ACPI/MultiProcessorParser.h | 300 | ||||
-rw-r--r-- | Kernel/Arch/i386/CPU.cpp | 8 | ||||
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 1 | ||||
-rw-r--r-- | Kernel/Interrupts/APIC.cpp | 276 | ||||
-rw-r--r-- | Kernel/Interrupts/APIC.h | 8 | ||||
-rw-r--r-- | Kernel/Interrupts/SpuriousInterruptHandler.h | 2 | ||||
-rw-r--r-- | Kernel/KParams.h | 2 | ||||
-rw-r--r-- | Kernel/Net/E1000NetworkAdapter.h | 2 | ||||
-rw-r--r-- | Kernel/Net/IPv4.h | 2 | ||||
-rw-r--r-- | Kernel/Net/NetworkAdapter.h | 2 | ||||
-rw-r--r-- | Kernel/Net/Routing.h | 3 | ||||
-rw-r--r-- | Kernel/Net/Socket.h | 1 | ||||
-rw-r--r-- | Kernel/PCI/Access.cpp | 184 | ||||
-rw-r--r-- | Kernel/PCI/Definitions.h | 250 | ||||
-rw-r--r-- | Kernel/PerformanceEventBuffer.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscall.cpp | 88 | ||||
-rw-r--r-- | Kernel/Syscall.h | 520 | ||||
-rw-r--r-- | Kernel/VM/PhysicalPage.cpp | 2 |
25 files changed, 3002 insertions, 3005 deletions
diff --git a/Kernel/ACPI/ACPIDynamicParser.cpp b/Kernel/ACPI/ACPIDynamicParser.cpp index 458131ecde..3f70bf6ce6 100644 --- a/Kernel/ACPI/ACPIDynamicParser.cpp +++ b/Kernel/ACPI/ACPIDynamicParser.cpp @@ -29,70 +29,70 @@ namespace Kernel { namespace ACPI { - void DynamicParser::initialize(PhysicalAddress rsdp) - { - if (!StaticParser::is_initialized()) { - new DynamicParser(rsdp); - } +void DynamicParser::initialize(PhysicalAddress rsdp) +{ + if (!StaticParser::is_initialized()) { + new DynamicParser(rsdp); } - void DynamicParser::initialize_without_rsdp() - { - if (!StaticParser::is_initialized()) { - new DynamicParser(); - } +} +void DynamicParser::initialize_without_rsdp() +{ + if (!StaticParser::is_initialized()) { + new DynamicParser(); } +} - DynamicParser::DynamicParser() - : IRQHandler(9) - , StaticParser() +DynamicParser::DynamicParser() + : IRQHandler(9) + , StaticParser() - { - klog() << "ACPI: Dynamic Parsing Enabled, Can parse AML"; - } - DynamicParser::DynamicParser(PhysicalAddress rsdp) - : IRQHandler(9) - , StaticParser(rsdp) - { - klog() << "ACPI: Dynamic Parsing Enabled, Can parse AML"; - } +{ + klog() << "ACPI: Dynamic Parsing Enabled, Can parse AML"; +} +DynamicParser::DynamicParser(PhysicalAddress rsdp) + : IRQHandler(9) + , StaticParser(rsdp) +{ + klog() << "ACPI: Dynamic Parsing Enabled, Can parse AML"; +} - void DynamicParser::handle_irq(const RegisterState&) - { - // FIXME: Implement IRQ handling of ACPI signals! - ASSERT_NOT_REACHED(); - } +void DynamicParser::handle_irq(const RegisterState&) +{ + // FIXME: Implement IRQ handling of ACPI signals! + ASSERT_NOT_REACHED(); +} - void DynamicParser::enable_aml_interpretation() - { - // FIXME: Implement AML Interpretation - ASSERT_NOT_REACHED(); - } - void DynamicParser::enable_aml_interpretation(File&) - { - // FIXME: Implement AML Interpretation - ASSERT_NOT_REACHED(); - } - void DynamicParser::enable_aml_interpretation(u8*, u32) - { - // FIXME: Implement AML Interpretation - ASSERT_NOT_REACHED(); - } - void DynamicParser::disable_aml_interpretation() - { - // FIXME: Implement AML Interpretation - ASSERT_NOT_REACHED(); - } - void DynamicParser::try_acpi_shutdown() - { - // FIXME: Implement AML Interpretation to perform ACPI shutdown - ASSERT_NOT_REACHED(); - } +void DynamicParser::enable_aml_interpretation() +{ + // FIXME: Implement AML Interpretation + ASSERT_NOT_REACHED(); +} +void DynamicParser::enable_aml_interpretation(File&) +{ + // FIXME: Implement AML Interpretation + ASSERT_NOT_REACHED(); +} +void DynamicParser::enable_aml_interpretation(u8*, u32) +{ + // FIXME: Implement AML Interpretation + ASSERT_NOT_REACHED(); +} +void DynamicParser::disable_aml_interpretation() +{ + // FIXME: Implement AML Interpretation + ASSERT_NOT_REACHED(); +} +void DynamicParser::try_acpi_shutdown() +{ + // FIXME: Implement AML Interpretation to perform ACPI shutdown + ASSERT_NOT_REACHED(); +} - void DynamicParser::build_namespace() - { - // FIXME: Implement AML Interpretation to build the ACPI namespace - ASSERT_NOT_REACHED(); - } +void DynamicParser::build_namespace() +{ + // FIXME: Implement AML Interpretation to build the ACPI namespace + ASSERT_NOT_REACHED(); +} } } diff --git a/Kernel/ACPI/ACPIDynamicParser.h b/Kernel/ACPI/ACPIDynamicParser.h index f2f86e6695..0918fecfbf 100644 --- a/Kernel/ACPI/ACPIDynamicParser.h +++ b/Kernel/ACPI/ACPIDynamicParser.h @@ -35,30 +35,30 @@ namespace Kernel { namespace ACPI { - class DynamicParser final : public IRQHandler - , StaticParser { - public: - static void initialize(PhysicalAddress rsdp); - static void initialize_without_rsdp(); +class DynamicParser final : public IRQHandler + , StaticParser { +public: + static void initialize(PhysicalAddress rsdp); + static void initialize_without_rsdp(); - virtual void enable_aml_interpretation() override; - virtual void enable_aml_interpretation(File& dsdt_file) override; - virtual void enable_aml_interpretation(u8* physical_dsdt, u32 dsdt_payload_legnth) override; - virtual void disable_aml_interpretation() override; - virtual void try_acpi_shutdown() override; - virtual bool can_shutdown() override { return true; } - virtual const char* purpose() const override { return "ACPI Parser"; } + virtual void enable_aml_interpretation() override; + virtual void enable_aml_interpretation(File& dsdt_file) override; + virtual void enable_aml_interpretation(u8* physical_dsdt, u32 dsdt_payload_legnth) override; + virtual void disable_aml_interpretation() override; + virtual void try_acpi_shutdown() override; + virtual bool can_shutdown() override { return true; } + virtual const char* purpose() const override { return "ACPI Parser"; } - protected: - DynamicParser(); - explicit DynamicParser(PhysicalAddress); +protected: + DynamicParser(); + explicit DynamicParser(PhysicalAddress); - private: - void build_namespace(); - // ^IRQHandler - virtual void handle_irq(const RegisterState&) override; +private: + void build_namespace(); + // ^IRQHandler + virtual void handle_irq(const RegisterState&) override; - OwnPtr<Region> m_acpi_namespace; - }; + OwnPtr<Region> m_acpi_namespace; +}; } } diff --git a/Kernel/ACPI/ACPIParser.cpp b/Kernel/ACPI/ACPIParser.cpp index 42ef0a1d33..03e68b3603 100644 --- a/Kernel/ACPI/ACPIParser.cpp +++ b/Kernel/ACPI/ACPIParser.cpp @@ -28,85 +28,85 @@ namespace Kernel { namespace ACPI { - static Parser* s_acpi_parser; +static Parser* s_acpi_parser; - Parser& Parser::the() - { - ASSERT(s_acpi_parser != nullptr); - return *s_acpi_parser; - } +Parser& Parser::the() +{ + ASSERT(s_acpi_parser != nullptr); + return *s_acpi_parser; +} - void Parser::initialize_limited() - { - if (!Parser::is_initialized()) { - s_acpi_parser = new Parser(false); - } +void Parser::initialize_limited() +{ + if (!Parser::is_initialized()) { + s_acpi_parser = new Parser(false); } +} - bool Parser::is_initialized() - { - return (s_acpi_parser != nullptr); - } +bool Parser::is_initialized() +{ + return (s_acpi_parser != nullptr); +} - Parser::Parser(bool usable) - { - if (usable) { - klog() << "ACPI: Setting up a functional parser"; - } else { - klog() << "ACPI: Limited Initialization. Vital functions are disabled by a request"; - } - s_acpi_parser = this; +Parser::Parser(bool usable) +{ + if (usable) { + klog() << "ACPI: Setting up a functional parser"; + } else { + klog() << "ACPI: Limited Initialization. Vital functions are disabled by a request"; } + s_acpi_parser = this; +} - PhysicalAddress Parser::find_table(const char*) - { - klog() << "ACPI: Requested to search for a table, Abort!"; - return {}; - } +PhysicalAddress Parser::find_table(const char*) +{ + klog() << "ACPI: Requested to search for a table, Abort!"; + return {}; +} - void Parser::try_acpi_reboot() - { - klog() << "ACPI: Cannot invoke reboot!"; - } +void Parser::try_acpi_reboot() +{ + klog() << "ACPI: Cannot invoke reboot!"; +} - void Parser::try_acpi_shutdown() - { - klog() << "ACPI: Cannot invoke shutdown!"; - } +void Parser::try_acpi_shutdown() +{ + klog() << "ACPI: Cannot invoke shutdown!"; +} - void Parser::enable_aml_interpretation() - { - klog() << "ACPI: No AML Interpretation Allowed"; - ASSERT_NOT_REACHED(); - } - void Parser::enable_aml_interpretation(File&) - { - klog() << "ACPI: No AML Interpretation Allowed"; - ASSERT_NOT_REACHED(); - } - void Parser::enable_aml_interpretation(u8*, u32) - { - klog() << "ACPI: No AML Interpretation Allowed"; - ASSERT_NOT_REACHED(); - } - void Parser::disable_aml_interpretation() - { - klog() << "ACPI Limited: No AML Interpretation Allowed"; - ASSERT_NOT_REACHED(); - } - const FADTFlags::HardwareFeatures& Parser::hardware_features() const - { - klog() << "ACPI Limited: Hardware features cannot be obtained"; - ASSERT_NOT_REACHED(); - } - const FADTFlags::x86_Specific_Flags& Parser::x86_specific_flags() const - { - klog() << "ACPI Limited: x86 specific features cannot be obtained"; - ASSERT_NOT_REACHED(); - } - bool Parser::is_operable() - { - return false; - } +void Parser::enable_aml_interpretation() +{ + klog() << "ACPI: No AML Interpretation Allowed"; + ASSERT_NOT_REACHED(); +} +void Parser::enable_aml_interpretation(File&) +{ + klog() << "ACPI: No AML Interpretation Allowed"; + ASSERT_NOT_REACHED(); +} +void Parser::enable_aml_interpretation(u8*, u32) +{ + klog() << "ACPI: No AML Interpretation Allowed"; + ASSERT_NOT_REACHED(); +} +void Parser::disable_aml_interpretation() +{ + klog() << "ACPI Limited: No AML Interpretation Allowed"; + ASSERT_NOT_REACHED(); +} +const FADTFlags::HardwareFeatures& Parser::hardware_features() const +{ + klog() << "ACPI Limited: Hardware features cannot be obtained"; + ASSERT_NOT_REACHED(); +} +const FADTFlags::x86_Specific_Flags& Parser::x86_specific_flags() const +{ + klog() << "ACPI Limited: x86 specific features cannot be obtained"; + ASSERT_NOT_REACHED(); +} +bool Parser::is_operable() +{ + return false; +} } } diff --git a/Kernel/ACPI/ACPIStaticParser.cpp b/Kernel/ACPI/ACPIStaticParser.cpp index da813e4164..9325be5f50 100644 --- a/Kernel/ACPI/ACPIStaticParser.cpp +++ b/Kernel/ACPI/ACPIStaticParser.cpp @@ -35,448 +35,448 @@ namespace Kernel { namespace ACPI { - void StaticParser::initialize(PhysicalAddress rsdp) - { - if (!Parser::is_initialized()) { - new StaticParser(rsdp); - } +void StaticParser::initialize(PhysicalAddress rsdp) +{ + if (!Parser::is_initialized()) { + new StaticParser(rsdp); } - void StaticParser::initialize_without_rsdp() - { - if (!Parser::is_initialized()) { - new StaticParser(); - } +} +void StaticParser::initialize_without_rsdp() +{ + if (!Parser::is_initialized()) { + new StaticParser(); } +} - bool StaticParser::is_initialized() - { - return Parser::is_initialized(); - } +bool StaticParser::is_initialized() +{ + return Parser::is_initialized(); +} - void StaticParser::locate_static_data() - { - locate_main_system_description_table(); - initialize_main_system_description_table(); - init_fadt(); - init_facs(); - } +void StaticParser::locate_static_data() +{ + locate_main_system_description_table(); + initialize_main_system_description_table(); + init_fadt(); + init_facs(); +} - PhysicalAddress StaticParser::find_table(const char* sig) - { +PhysicalAddress StaticParser::find_table(const char* sig) +{ #ifdef ACPI_DEBUG - dbg() << "ACPI: Calling Find Table method!"; + dbg() << "ACPI: Calling Find Table method!"; #endif - for (auto p_sdt : m_sdt_pointers) { - auto region = MM.allocate_kernel_region(p_sdt.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser Tables Finding", Region::Access::Read); - auto* sdt = (const Structures::SDTHeader*)region->vaddr().offset(p_sdt.offset_in_page()).as_ptr(); + for (auto p_sdt : m_sdt_pointers) { + auto region = MM.allocate_kernel_region(p_sdt.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser Tables Finding", Region::Access::Read); + auto* sdt = (const Structures::SDTHeader*)region->vaddr().offset(p_sdt.offset_in_page()).as_ptr(); #ifdef ACPI_DEBUG - dbg() << "ACPI: Examining Table @ P " << physical_sdt_ptr; + dbg() << "ACPI: Examining Table @ P " << physical_sdt_ptr; #endif - if (!strncmp(sdt->sig, sig, 4)) { + if (!strncmp(sdt->sig, sig, 4)) { #ifdef ACPI_DEBUG - dbg() << "ACPI: Found Table @ P " << physical_sdt_ptr; + dbg() << "ACPI: Found Table @ P " << physical_sdt_ptr; #endif - return p_sdt; - } + return p_sdt; } - return {}; } + return {}; +} - void StaticParser::init_facs() - { - m_facs = find_table("FACS"); - } +void StaticParser::init_facs() +{ + m_facs = find_table("FACS"); +} - const FADTFlags::HardwareFeatures& StaticParser::hardware_features() const - { - return m_hardware_flags; - } - const FADTFlags::x86_Specific_Flags& StaticParser::x86_specific_flags() const - { - return m_x86_specific_flags; - } +const FADTFlags::HardwareFeatures& StaticParser::hardware_features() const +{ + return m_hardware_flags; +} +const FADTFlags::x86_Specific_Flags& StaticParser::x86_specific_flags() const +{ + return m_x86_specific_flags; +} - void StaticParser::init_fadt() - { - klog() << "ACPI: Initializing Fixed ACPI data"; - klog() << "ACPI: Searching for the Fixed ACPI Data Table"; +void StaticParser::init_fadt() +{ + klog() << "ACPI: Initializing Fixed ACPI data"; + klog() << "ACPI: Searching for the Fixed ACPI Data Table"; - m_fadt = find_table("FACP"); - ASSERT(!m_fadt.is_null()); + m_fadt = find_table("FACP"); + ASSERT(!m_fadt.is_null()); - auto checkup_region = MM.allocate_kernel_region(m_fadt.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read); - auto* sdt = (const Structures::FADT*)checkup_region->vaddr().offset(m_fadt.offset_in_page()).as_ptr(); + auto checkup_region = MM.allocate_kernel_region(m_fadt.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read); + auto* sdt = (const Structures::FADT*)checkup_region->vaddr().offset(m_fadt.offset_in_page()).as_ptr(); #ifdef ACPI_DEBUG - dbg() << "ACPI: FADT @ V " << sdt << ", P " << (void*)fadt.as_ptr(); + dbg() << "ACPI: FADT @ V " << sdt << ", P " << (void*)fadt.as_ptr(); #endif - klog() << "ACPI: Fixed ACPI data, Revision " << sdt->h.revision << ", Length " << sdt->h.length << " bytes"; - klog() << "ACPI: DSDT " << PhysicalAddress(sdt->dsdt_ptr); - m_x86_specific_flags.cmos_rtc_not_present = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::CMOS_RTC_Not_Present); - m_x86_specific_flags.keyboard_8042 = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::PS2_8042); - m_x86_specific_flags.legacy_devices = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::Legacy_Devices); - m_x86_specific_flags.msi_not_supported = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::MSI_Not_Supported); - m_x86_specific_flags.vga_not_present = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::VGA_Not_Present); - - m_hardware_flags.cpu_software_sleep = (sdt->flags & (u32)FADTFlags::FeatureFlags::CPU_SW_SLP); - m_hardware_flags.docking_capability = (sdt->flags & (u32)FADTFlags::FeatureFlags::DCK_CAP); - m_hardware_flags.fix_rtc = (sdt->flags & (u32)FADTFlags::FeatureFlags::FIX_RTC); - m_hardware_flags.force_apic_cluster_model = (sdt->flags & (u32)FADTFlags::FeatureFlags::FORCE_APIC_CLUSTER_MODEL); - m_hardware_flags.force_apic_physical_destination_mode = (sdt->flags & (u32)FADTFlags::FeatureFlags::FORCE_APIC_PHYSICAL_DESTINATION_MODE); - m_hardware_flags.hardware_reduced_acpi = (sdt->flags & (u32)FADTFlags::FeatureFlags::HW_REDUCED_ACPI); - m_hardware_flags.headless = (sdt->flags & (u32)FADTFlags::FeatureFlags::HEADLESS); - m_hardware_flags.low_power_s0_idle_capable = (sdt->flags & (u32)FADTFlags::FeatureFlags::LOW_POWER_S0_IDLE_CAPABLE); - m_hardware_flags.multiprocessor_c2 = (sdt->flags & (u32)FADTFlags::FeatureFlags::P_LVL2_UP); - m_hardware_flags.pci_express_wake = (sdt->flags & (u32)FADTFlags::FeatureFlags::PCI_EXP_WAK); - m_hardware_flags.power_button = (sdt->flags & (u32)FADTFlags::FeatureFlags::PWR_BUTTON); - m_hardware_flags.processor_c1 = (sdt->flags & (u32)FADTFlags::FeatureFlags::PROC_C1); - m_hardware_flags.remote_power_on_capable = (sdt->flags & (u32)FADTFlags::FeatureFlags::REMOTE_POWER_ON_CAPABLE); - m_hardware_flags.reset_register_supported = (sdt->flags & (u32)FADTFlags::FeatureFlags::RESET_REG_SUPPORTED); - m_hardware_flags.rtc_s4 = (sdt->flags & (u32)FADTFlags::FeatureFlags::RTC_s4); - m_hardware_flags.s4_rtc_status_valid = (sdt->flags & (u32)FADTFlags::FeatureFlags::S4_RTC_STS_VALID); - m_hardware_flags.sealed_case = (sdt->flags & (u32)FADTFlags::FeatureFlags::SEALED_CASE); - m_hardware_flags.sleep_button = (sdt->flags & (u32)FADTFlags::FeatureFlags::SLP_BUTTON); - m_hardware_flags.timer_value_extension = (sdt->flags & (u32)FADTFlags::FeatureFlags::TMR_VAL_EXT); - m_hardware_flags.use_platform_clock = (sdt->flags & (u32)FADTFlags::FeatureFlags::USE_PLATFORM_CLOCK); - m_hardware_flags.wbinvd = (sdt->flags & (u32)FADTFlags::FeatureFlags::WBINVD); - m_hardware_flags.wbinvd_flush = (sdt->flags & (u32)FADTFlags::FeatureFlags::WBINVD_FLUSH); - } + klog() << "ACPI: Fixed ACPI data, Revision " << sdt->h.revision << ", Length " << sdt->h.length << " bytes"; + klog() << "ACPI: DSDT " << PhysicalAddress(sdt->dsdt_ptr); + m_x86_specific_flags.cmos_rtc_not_present = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::CMOS_RTC_Not_Present); + m_x86_specific_flags.keyboard_8042 = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::PS2_8042); + m_x86_specific_flags.legacy_devices = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::Legacy_Devices); + m_x86_specific_flags.msi_not_supported = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::MSI_Not_Supported); + m_x86_specific_flags.vga_not_present = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::VGA_Not_Present); + + m_hardware_flags.cpu_software_sleep = (sdt->flags & (u32)FADTFlags::FeatureFlags::CPU_SW_SLP); + m_hardware_flags.docking_capability = (sdt->flags & (u32)FADTFlags::FeatureFlags::DCK_CAP); + m_hardware_flags.fix_rtc = (sdt->flags & (u32)FADTFlags::FeatureFlags::FIX_RTC); + m_hardware_flags.force_apic_cluster_model = (sdt->flags & (u32)FADTFlags::FeatureFlags::FORCE_APIC_CLUSTER_MODEL); + m_hardware_flags.force_apic_physical_destination_mode = (sdt->flags & (u32)FADTFlags::FeatureFlags::FORCE_APIC_PHYSICAL_DESTINATION_MODE); + m_hardware_flags.hardware_reduced_acpi = (sdt->flags & (u32)FADTFlags::FeatureFlags::HW_REDUCED_ACPI); + m_hardware_flags.headless = (sdt->flags & (u32)FADTFlags::FeatureFlags::HEADLESS); + m_hardware_flags.low_power_s0_idle_capable = (sdt->flags & (u32)FADTFlags::FeatureFlags::LOW_POWER_S0_IDLE_CAPABLE); + m_hardware_flags.multiprocessor_c2 = (sdt->flags & (u32)FADTFlags::FeatureFlags::P_LVL2_UP); + m_hardware_flags.pci_express_wake = (sdt->flags & (u32)FADTFlags::FeatureFlags::PCI_EXP_WAK); + m_hardware_flags.power_button = (sdt->flags & (u32)FADTFlags::FeatureFlags::PWR_BUTTON); + m_hardware_flags.processor_c1 = (sdt->flags & (u32)FADTFlags::FeatureFlags::PROC_C1); + m_hardware_flags.remote_power_on_capable = (sdt->flags & (u32)FADTFlags::FeatureFlags::REMOTE_POWER_ON_CAPABLE); + m_hardware_flags.reset_register_supported = (sdt->flags & (u32)FADTFlags::FeatureFlags::RESET_REG_SUPPORTED); + m_hardware_flags.rtc_s4 = (sdt->flags & (u32)FADTFlags::FeatureFlags::RTC_s4); + m_hardware_flags.s4_rtc_status_valid = (sdt->flags & (u32)FADTFlags::FeatureFlags::S4_RTC_STS_VALID); + m_hardware_flags.sealed_case = (sdt->flags & (u32)FADTFlags::FeatureFlags::SEALED_CASE); + m_hardware_flags.sleep_button = (sdt->flags & (u32)FADTFlags::FeatureFlags::SLP_BUTTON); + m_hardware_flags.timer_value_extension = (sdt->flags & (u32)FADTFlags::FeatureFlags::TMR_VAL_EXT); + m_hardware_flags.use_platform_clock = (sdt->flags & (u32)FADTFlags::FeatureFlags::USE_PLATFORM_CLOCK); + m_hardware_flags.wbinvd = (sdt->flags & (u32)FADTFlags::FeatureFlags::WBINVD); + m_hardware_flags.wbinvd_flush = (sdt->flags & (u32)FADTFlags::FeatureFlags::WBINVD_FLUSH); +} - bool StaticParser::can_reboot() - { - auto region = MM.allocate_kernel_region(m_fadt.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read); - auto* fadt = (const Structures::FADT*)region->vaddr().offset(m_fadt.offset_in_page()).as_ptr(); - if (fadt->h.revision < 2) - return false; - return m_hardware_flags.reset_register_supported; - } +bool StaticParser::can_reboot() +{ + auto region = MM.allocate_kernel_region(m_fadt.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read); + auto* fadt = (const Structures::FADT*)region->vaddr().offset(m_fadt.offset_in_page()).as_ptr(); + if (fadt->h.revision < 2) + return false; + return m_hardware_flags.reset_register_supported; +} - void StaticParser::access_generic_address(const Structures::GenericAddressStructure& structure, u32 value) - { - switch (structure.address_space) { - case (u8)GenericAddressStructure::AddressSpace::SystemIO: { - IOAddress address(structure.address); - dbg() << "ACPI: Sending value 0x" << String::format("%x", value) << " to " << address; - switch (structure.access_size) { - case (u8)GenericAddressStructure::AccessSize::QWord: { - dbg() << "Trying to send QWord to IO port"; - ASSERT_NOT_REACHED(); - break; - } - case (u8)GenericAddressStructure::AccessSize::Undefined: { - dbg() << "ACPI Warning: Unknown access size " << structure.access_size; - ASSERT(structure.bit_width != (u8)GenericAddressStructure::BitWidth::QWord); - ASSERT(structure.bit_width != (u8)GenericAddressStructure::BitWidth::Undefined); - dbg() << "ACPI: Bit Width - " << structure.bit_width << " bits"; - address.out(value, structure.bit_width); - break; - } - default: - address.out(value, (8 << (structure.access_size - 1))); - break; - } - return; +void StaticParser::access_generic_address(const Structures::GenericAddressStructure& structure, u32 value) +{ + switch (structure.address_space) { + case (u8)GenericAddressStructure::AddressSpace::SystemIO: { + IOAddress address(structure.address); + dbg() << "ACPI: Sending value 0x" << String::format("%x", value) << " to " << address; + switch (structure.access_size) { + case (u8)GenericAddressStructure::AccessSize::QWord: { + dbg() << "Trying to send QWord to IO port"; + ASSERT_NOT_REACHED(); + break; + } + case (u8)GenericAddressStructure::AccessSize::Undefined: { + dbg() << "ACPI Warning: Unknown access size " << structure.access_size; + ASSERT(structure.bit_width != (u8)GenericAddressStructure::BitWidth::QWord); + ASSERT(structure.bit_width != (u8)GenericAddressStructure::BitWidth::Undefined); + dbg() << "ACPI: Bit Width - " << structure.bit_width << " bits"; + address.out(value, structure.bit_width); + break; + } + default: + address.out(value, (8 << (structure.access_size - 1))); + break; + } + return; + } + case (u8)GenericAddressStructure::AddressSpace::SystemMemory: { + auto p_reg = PhysicalAddress(structure.address); + auto p_region = MM.allocate_kernel_region(p_reg.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read); + dbg() << "ACPI: Sending value 0x" << String::format("%x", value) << " to " << p_reg; + switch (structure.access_size) { + case (u8)GenericAddressStructure::AccessSize::Byte: { + auto* reg = (volatile u8*)p_region->vaddr().offset(p_reg.offset_in_page()).as_ptr(); + (*reg) = value; + break; + } + case (u8)GenericAddressStructure::AccessSize::Word: { + auto* reg = (volatile u16*)p_region->vaddr().offset(p_reg.offset_in_page()).as_ptr(); + (*reg) = value; + break; } - case (u8)GenericAddressStructure::AddressSpace::SystemMemory: { - auto p_reg = PhysicalAddress(structure.address); - auto p_region = MM.allocate_kernel_region(p_reg.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read); - dbg() << "ACPI: Sending value 0x" << String::format("%x", value) << " to " << p_reg; - switch (structure.access_size) { - case (u8)GenericAddressStructure::AccessSize::Byte: { - auto* reg = (volatile u8*)p_region->vaddr().offset(p_reg.offset_in_page()).as_ptr(); - (*reg) = value; - break; - } - case (u8)GenericAddressStructure::AccessSize::Word: { - auto* reg = (volatile u16*)p_region->vaddr().offset(p_reg.offset_in_page()).as_ptr(); - (*reg) = value; - break; - } - case (u8)GenericAddressStructure::AccessSize::DWord: { - auto* reg = (volatile u32*)p_region->vaddr().offset(p_reg.offset_in_page()).as_ptr(); - (*reg) = value; - break; - } - case (u8)GenericAddressStructure::AccessSize::QWord: { - auto* reg = (volatile u64*)p_region->vaddr().offset(p_reg.offset_in_page()).as_ptr(); - (*reg) = value; - break; - } - default: - ASSERT_NOT_REACHED(); - } - return; + case (u8)GenericAddressStructure::AccessSize::DWord: { + auto* reg = (volatile u32*)p_region->vaddr().offset(p_reg.offset_in_page()).as_ptr(); + (*reg) = value; + break; } - case (u8)GenericAddressStructure::AddressSpace::PCIConfigurationSpace: { - // According to the ACPI specification 6.2, page 168, PCI addresses must be confined to devices on Segment group 0, bus 0. - auto pci_address = PCI::Address(0, 0, ((structure.address >> 24) & 0xFF), ((structure.address >> 16) & 0xFF)); - dbg() << "ACPI: Sending value 0x" << String::format("%x", value) << " to " << pci_address; - u32 offset_in_pci_address = structure.address & 0xFFFF; - if (structure.access_size == (u8)GenericAddressStructure::AccessSize::QWord) { - dbg() << "Trying to send QWord to PCI configuration space"; - ASSERT_NOT_REACHED(); - } - ASSERT(structure.access_size != (u8)GenericAddressStructure::AccessSize::Undefined); - PCI::raw_access(pci_address, offset_in_pci_address, (1 << (structure.access_size - 1)), value); - return; + case (u8)GenericAddressStructure::AccessSize::QWord: { + auto* reg = (volatile u64*)p_region->vaddr().offset(p_reg.offset_in_page()).as_ptr(); + (*reg) = value; + break; } default: ASSERT_NOT_REACHED(); } + return; + } + case (u8)GenericAddressStructure::AddressSpace::PCIConfigurationSpace: { + // According to the ACPI specification 6.2, page 168, PCI addresses must be confined to devices on Segment group 0, bus 0. + auto pci_address = PCI::Address(0, 0, ((structure.address >> 24) & 0xFF), ((structure.address >> 16) & 0xFF)); + dbg() << "ACPI: Sending value 0x" << String::format("%x", value) << " to " << pci_address; + u32 offset_in_pci_address = structure.address & 0xFFFF; + if (structure.access_size == (u8)GenericAddressStructure::AccessSize::QWord) { + dbg() << "Trying to send QWord to PCI configuration space"; + ASSERT_NOT_REACHED(); + } + ASSERT(structure.access_size != (u8)GenericAddressStructure::AccessSize::Undefined); + PCI::raw_access(pci_address, offset_in_pci_address, (1 << (structure.access_size - 1)), value); + return; + } + default: ASSERT_NOT_REACHED(); } + ASSERT_NOT_REACHED(); +} - bool StaticParser::validate_reset_register() - { - // According to the ACPI spec 6.2, page 152, The reset register can only be located in I/O bus, PCI bus or memory-mapped. - auto region = MM.allocate_kernel_region(m_fadt.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read); - auto* fadt = (const Structures::FADT*)region->vaddr().offset(m_fadt.offset_in_page()).as_ptr(); - return (fadt->reset_reg.address_space == (u8)GenericAddressStructure::AddressSpace::PCIConfigurationSpace || fadt->reset_reg.address_space == (u8)GenericAddressStructure::AddressSpace::SystemMemory || fadt->reset_reg.address_space == (u8)GenericAddressStructure::AddressSpace::SystemIO); - } +bool StaticParser::validate_reset_register() +{ + // According to the ACPI spec 6.2, page 152, The reset register can only be located in I/O bus, PCI bus or memory-mapped. + auto region = MM.allocate_kernel_region(m_fadt.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read); + auto* fadt = (const Structures::FADT*)region->vaddr().offset(m_fadt.offset_in_page()).as_ptr(); + return (fadt->reset_reg.address_space == (u8)GenericAddressStructure::AddressSpace::PCIConfigurationSpace || fadt->reset_reg.address_space == (u8)GenericAddressStructure::AddressSpace::SystemMemory || fadt->reset_reg.address_space == (u8)GenericAddressStructure::AddressSpace::SystemIO); +} - void StaticParser::try_acpi_reboot() - { - InterruptDisabler disabler; - if (!can_reboot()) { - klog() << "ACPI: Reboot, Not supported!"; - return; - } +void StaticParser::try_acpi_reboot() +{ + InterruptDisabler disabler; + if (!can_reboot()) { + klog() << "ACPI: Reboot, Not supported!"; + return; + } #ifdef ACPI_DEBUG - dbg() << "ACPI: Rebooting, Probing FADT (" << m_fadt << ")"; + dbg() << "ACPI: Rebooting, Probing FADT (" << m_fadt << ")"; #endif - auto region = MM.allocate_kernel_region(m_fadt.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read); - auto* fadt = (const Structures::FADT*)region->vaddr().offset(m_fadt.offset_in_page()).as_ptr(); - ASSERT(validate_reset_register()); - access_generic_address(fadt->reset_reg, fadt->reset_value); - for (;;) - ; - } + auto region = MM.allocate_kernel_region(m_fadt.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read); + auto* fadt = (const Structures::FADT*)region->vaddr().offset(m_fadt.offset_in_page()).as_ptr(); + ASSERT(validate_reset_register()); + access_generic_address(fadt->reset_reg, fadt->reset_value); + for (;;) + ; +} - void StaticParser::try_acpi_shutdown() - { - klog() << "ACPI: Shutdown is not supported with the current configuration, Abort!"; - } +void StaticParser::try_acpi_shutdown() +{ + klog() << "ACPI: Shutdown is not supported with the current configuration, Abort!"; +} - size_t StaticParser::get_table_size(PhysicalAddress table_header) - { - InterruptDisabler disabler; +size_t StaticParser::get_table_size(PhysicalAddress table_header) +{ + InterruptDisabler disabler; #ifdef ACPI_DEBUG - dbg() << "ACPI: Checking SDT Length"; + dbg() << "ACPI: Checking SDT Length"; #endif - auto region = MM.allocate_kernel_region(table_header.page_base(), (PAGE_SIZE * 2), "ACPI get_table_size()", Region::Access::Read); - auto* sdt = (volatile Structures::SDTHeader*)region->vaddr().offset(table_header.offset_in_page()).as_ptr(); - return sdt->length; - } + auto region = MM.allocate_kernel_region(table_header.page_base(), (PAGE_SIZE * 2), "ACPI get_table_size()", Region::Access::Read); + auto* sdt = (volatile Structures::SDTHeader*)region->vaddr().offset(table_header.offset_in_page()).as_ptr(); + return sdt->length; +} - u8 StaticParser::get_table_revision(PhysicalAddress table_header) - { - InterruptDisabler disabler; +u8 StaticParser::get_table_revision(PhysicalAddress table_header) +{ + InterruptDisabler disabler; #ifdef ACPI_DEBUG - dbg() << "ACPI: Checking SDT Revision"; + dbg() << "ACPI: Checking SDT Revision"; #endif - auto region = MM.allocate_kernel_region(table_header.page_base(), (PAGE_SIZE * 2), "ACPI get_table_revision()", Region::Access::Read); - auto* sdt = (volatile Structures::SDTHeader*)region->vaddr().offset(table_header.offset_in_page()).as_ptr(); - return sdt->revision; - } + auto region = MM.allocate_kernel_region(table_header.page_base(), (PAGE_SIZE * 2), "ACPI get_table_revision()", Region::Access::Read); + auto* sdt = (volatile Structures::SDTHeader*)region->vaddr().offset(table_header.offset_in_page()).as_ptr(); + return sdt->revision; +} - void StaticParser::initialize_main_system_description_table() - { +void StaticParser::initialize_main_system_description_table() +{ #ifdef ACPI_DEBUG - dbg() << "ACPI: Checking Main SDT Length to choose the correct mapping size"; + dbg() << "ACPI: Checking Main SDT Length to choose the correct mapping size"; #endif - ASSERT(!m_main_system_description_table.is_null()); - auto length = get_table_size(m_main_system_description_table); - auto revision = get_table_revision(m_main_system_description_table); - - auto main_sdt_region = MM.allocate_kernel_region(m_main_system_description_table.page_base(), PAGE_ROUND_UP(length) + PAGE_SIZE, "ACPI Static Parser Initialization", Region::Access::Read, false, true); - auto* sdt = (volatile Structures::SDTHeader*)main_sdt_region->vaddr().offset(m_main_system_description_table.offset_in_page()).as_ptr(); - klog() << "ACPI: Main Description Table valid? " << StaticParsing::validate_table(const_cast<Structures::SDTHeader&>(*sdt), length); - - if (m_xsdt_supported) { - volatile auto* xsdt = (volatile Structures::XSDT*)sdt; - klog() << "ACPI: Using XSDT, Enumerating tables @ " << m_main_system_description_table; - klog() << "ACPI: XSDT Revision " << revision << ", Total length - " << length; + ASSERT(!m_main_system_description_table.is_null()); + auto length = get_table_size(m_main_system_description_table); + auto revision = get_table_revision(m_main_system_description_table); + + auto main_sdt_region = MM.allocate_kernel_region(m_main_system_description_table.page_base(), PAGE_ROUND_UP(length) + PAGE_SIZE, "ACPI Static Parser Initialization", Region::Access::Read, false, true); + auto* sdt = (volatile Structures::SDTHeader*)main_sdt_region->vaddr().offset(m_main_system_description_table.offset_in_page()).as_ptr(); + klog() << "ACPI: Main Description Table valid? " << StaticParsing::validate_table(const_cast<Structures::SDTHeader&>(*sdt), length); + + if (m_xsdt_supported) { + volatile auto* xsdt = (volatile Structures::XSDT*)sdt; + klog() << "ACPI: Using XSDT, Enumerating tables @ " << m_main_system_description_table; + klog() << "ACPI: XSDT Revision " << revision << ", Total length - " << length; #ifdef ACPI_DEBUG - dbg() << "ACPI: XSDT pointer @ V " << xsdt; + dbg() << "ACPI: XSDT pointer @ V " << xsdt; #endif - for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u64)); i++) { + for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u64)); i++) { #ifdef ACPI_DEBUG - dbg() << "ACPI: Found new table [" << i << "], @ V 0x" << String::format("%x", &xsdt->table_ptrs[i]) << " - P 0x" << String::format("%x", xsdt->table_ptrs[i]); + dbg() << "ACPI: Found new table [" << i << "], @ V 0x" << String::format("%x", &xsdt->table_ptrs[i]) << " - P 0x" << String::format("%x", xsdt->table_ptrs[i]); #endif - m_sdt_pointers.append(PhysicalAddress(xsdt->table_ptrs[i])); - } - } else { - volatile auto* rsdt = (volatile Structures::RSDT*)sdt; - klog() << "ACPI: Using RSDT, Enumerating tables @ " << m_main_system_description_table; - klog() << "ACPI: RSDT Revision " << revision << ", Total length - " << length; + m_sdt_pointers.append(PhysicalAddress(xsdt->table_ptrs[i])); + } + } else { + volatile auto* rsdt = (volatile Structures::RSDT*)sdt; + klog() << "ACPI: Using RSDT, Enumerating tables @ " << m_main_system_description_table; + klog() << "ACPI: RSDT Revision " << revision << ", Total length - " << length; #ifdef ACPI_DEBUG - dbg() << "ACPI: RSDT pointer @ V " << rsdt; + dbg() << "ACPI: RSDT pointer @ V " << rsdt; #endif - for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) { + for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) { #ifdef ACPI_DEBUG - dbg() << "ACPI: Found new table [" << i << "], @ V 0x" << String::format("%x", &rsdt->table_ptrs[i]) << " - P 0x" << String::format("%x", rsdt->table_ptrs[i]); + dbg() << "ACPI: Found new table [" << i << "], @ V 0x" << String::format("%x", &rsdt->table_ptrs[i]) << " - P 0x" << String::format("%x", rsdt->table_ptrs[i]); #endif - m_sdt_pointers.append(PhysicalAddress(rsdt->table_ptrs[i])); - } + m_sdt_pointers.append(PhysicalAddress(rsdt->table_ptrs[i])); } } +} - void StaticParser::locate_main_system_description_table() - { - auto rsdp_region = MM.allocate_kernel_region(m_rsdp.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser Initialization", Region::Access::Read, false, true); - volatile auto* rsdp = (Structures::RSDPDescriptor20*)rsdp_region->vaddr().offset(m_rsdp.offset_in_page()).as_ptr(); - if (rsdp->base.revision == 0) { - m_xsdt_supported = false; - } else if (rsdp->base.revision >= 2) { - if (rsdp->xsdt_ptr != (u64) nullptr) { - m_xsdt_supported = true; - } else { - m_xsdt_supported = false; - } - } - if (!m_xsdt_supported) { - m_main_system_description_table = PhysicalAddress(rsdp->base.rsdt_ptr); +void StaticParser::locate_main_system_description_table() +{ + auto rsdp_region = MM.allocate_kernel_region(m_rsdp.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser Initialization", Region::Access::Read, false, true); + volatile auto* rsdp = (Structures::RSDPDescriptor20*)rsdp_region->vaddr().offset(m_rsdp.offset_in_page()).as_ptr(); + if (rsdp->base.revision == 0) { + m_xsdt_supported = false; + } else if (rsdp->base.revision >= 2) { + if (rsdp->xsdt_ptr != (u64) nullptr) { + m_xsdt_supported = true; } else { - m_main_system_description_table = PhysicalAddress(rsdp->xsdt_ptr); + m_xsdt_supported = false; } } - - StaticParser::StaticParser() - : Parser(true) - , m_rsdp(StaticParsing::search_rsdp()) - { - if (!m_rsdp.is_null()) { - klog() << "ACPI: Using RSDP @ " << m_rsdp; - m_operable = true; - locate_static_data(); - } else { - m_operable = false; - klog() << "ACPI: Disabled, due to RSDP being absent"; - } + if (!m_xsdt_supported) { + m_main_system_description_table = PhysicalAddress(rsdp->base.rsdt_ptr); + } else { + m_main_system_description_table = PhysicalAddress(rsdp->xsdt_ptr); } +} - StaticParser::StaticParser(PhysicalAddress rsdp) - : Parser(true) - , m_rsdp(rsdp) - { - klog() << "ACPI: Using RSDP @ " << rsdp; +StaticParser::StaticParser() + : Parser(true) + , m_rsdp(StaticParsing::search_rsdp()) +{ + if (!m_rsdp.is_null()) { + klog() << "ACPI: Using RSDP @ " << m_rsdp; m_operable = true; locate_static_data(); + } else { + m_operable = false; + klog() << "ACPI: Disabled, due to RSDP being absent"; } +} + +StaticParser::StaticParser(PhysicalAddress rsdp) + : Parser(true) + , m_rsdp(rsdp) +{ + klog() << "ACPI: Using RSDP @ " << rsdp; + m_operable = true; + locate_static_data(); +} - PhysicalAddress StaticParsing::search_rsdp_in_ebda(u16 ebda_segment) - { - auto rsdp_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)(ebda_segment << 4))), PAGE_ROUND_UP(1024), "ACPI Static Parser RSDP Finding #1", Region::Access::Read, false, true); - char* p_rsdp_str = (char*)(PhysicalAddress(ebda_segment << 4).as_ptr()); - for (char* rsdp_str = (char*)rsdp_region->vaddr().offset(offset_in_page((u32)(ebda_segment << 4))).as_ptr(); rsdp_str < (char*)(rsdp_region->vaddr().offset(offset_in_page((u32)(ebda_segment << 4))).get() + 1024); rsdp_str += 16) { +PhysicalAddress StaticParsing::search_rsdp_in_ebda(u16 ebda_segment) +{ + auto rsdp_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)(ebda_segment << 4))), PAGE_ROUND_UP(1024), "ACPI Static Parser RSDP Finding #1", Region::Access::Read, false, true); + char* p_rsdp_str = (char*)(PhysicalAddress(ebda_segment << 4).as_ptr()); + for (char* rsdp_str = (char*)rsdp_region->vaddr().offset(offset_in_page((u32)(ebda_segment << 4))).as_ptr(); rsdp_str < (char*)(rsdp_region->vaddr().offset(offset_in_page((u32)(ebda_segment << 4))).get() + 1024); rsdp_str += 16) { #ifdef ACPI_DEBUG - dbg() << "ACPI: Looking for RSDP in EBDA @ V " << (void*)rsdp_str << ", P " << (void*)p_rsdp_str; + dbg() << "ACPI: Looking for RSDP in EBDA @ V " << (void*)rsdp_str << ", P " << (void*)p_rsdp_str; #endif - if (!strncmp("RSD PTR ", rsdp_str, strlen("RSD PTR "))) - return PhysicalAddress((FlatPtr)p_rsdp_str); - p_rsdp_str += 16; - } - return {}; + if (!strncmp("RSD PTR ", rsdp_str, strlen("RSD PTR "))) + return PhysicalAddress((FlatPtr)p_rsdp_str); + p_rsdp_str += 16; } + return {}; +} - PhysicalAddress StaticParsing::search_rsdp_in_bios_area() - { - auto rsdp_region = MM.allocate_kernel_region(PhysicalAddress(0xE0000), PAGE_ROUND_UP(0xFFFFF - 0xE0000), "ACPI Static Parser RSDP Finding #2", Region::Access::Read, false, true); - char* p_rsdp_str = (char*)(PhysicalAddress(0xE0000).as_ptr()); - for (char* rsdp_str = (char*)rsdp_region->vaddr().offset(offset_in_page((u32)(0xE0000))).as_ptr(); rsdp_str < (char*)(rsdp_region->vaddr().offset(offset_in_page((u32)(0xE0000))).get() + (0xFFFFF - 0xE0000)); rsdp_str += 16) { +PhysicalAddress StaticParsing::search_rsdp_in_bios_area() +{ + auto rsdp_region = MM.allocate_kernel_region(PhysicalAddress(0xE0000), PAGE_ROUND_UP(0xFFFFF - 0xE0000), "ACPI Static Parser RSDP Finding #2", Region::Access::Read, false, true); + char* p_rsdp_str = (char*)(PhysicalAddress(0xE0000).as_ptr()); + for (char* rsdp_str = (char*)rsdp_region->vaddr().offset(offset_in_page((u32)(0xE0000))).as_ptr(); rsdp_str < (char*)(rsdp_region->vaddr().offset(offset_in_page((u32)(0xE0000))).get() + (0xFFFFF - 0xE0000)); rsdp_str += 16) { #ifdef ACPI_DEBUG - dbg() << "ACPI: Looking for RSDP in BIOS ROM area @ V " << (void*)rsdp_str << ", P " << (void*)p_rsdp_str; + dbg() << "ACPI: Looking for RSDP in BIOS ROM area @ V " << (void*)rsdp_str << ", P " << (void*)p_rsdp_str; #endif - if (!strncmp("RSD PTR ", rsdp_str, strlen("RSD PTR "))) - return PhysicalAddress((FlatPtr)p_rsdp_str); - p_rsdp_str += 16; - } - return {}; + if (!strncmp("RSD PTR ", rsdp_str, strlen("RSD PTR "))) + return PhysicalAddress((FlatPtr)p_rsdp_str); + p_rsdp_str += 16; } + return {}; +} - inline bool StaticParsing::validate_table(Structures::SDTHeader& v_header, size_t length) - { - u8 checksum = 0; - auto* sdt = (u8*)&v_header; - for (size_t i = 0; i < length; i++) - checksum += sdt[i]; - if (checksum == 0) - return true; - return false; - } +inline bool StaticParsing::validate_table(Structures::SDTHeader& v_header, size_t length) +{ + u8 checksum = 0; + auto* sdt = (u8*)&v_header; + for (size_t i = 0; i < length; i++) + checksum += sdt[i]; + if (checksum == 0) + return true; + return false; +} - PhysicalAddress StaticParsing::search_rsdp() - { - PhysicalAddress rsdp; - auto region = MM.allocate_kernel_region(PhysicalAddress(0), PAGE_SIZE, "ACPI RSDP Searching", Region::Access::Read); - u16 ebda_seg = (u16) * ((uint16_t*)((region->vaddr().get() & PAGE_MASK) + 0x40e)); - klog() << "ACPI: Probing EBDA, Segment 0x" << String::format("%x", ebda_seg); - - rsdp = search_rsdp_in_ebda(ebda_seg); - if (!rsdp.is_null()) - return rsdp; - return search_rsdp_in_bios_area(); - } +PhysicalAddress StaticParsing::search_rsdp() +{ + PhysicalAddress rsdp; + auto region = MM.allocate_kernel_region(PhysicalAddress(0), PAGE_SIZE, "ACPI RSDP Searching", Region::Access::Read); + u16 ebda_seg = (u16) * ((uint16_t*)((region->vaddr().get() & PAGE_MASK) + 0x40e)); + klog() << "ACPI: Probing EBDA, Segment 0x" << String::format("%x", ebda_seg); + + rsdp = search_rsdp_in_ebda(ebda_seg); + if (!rsdp.is_null()) + return rsdp; + return search_rsdp_in_bios_area(); +} - PhysicalAddress StaticParsing::search_table(PhysicalAddress rsdp, const char* signature) - { - // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables. - // FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length. +PhysicalAddress StaticParsing::search_table(PhysicalAddress rsdp, const char* signature) +{ + // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables. + // FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length. - ASSERT(strlen(signature) == 4); - auto rsdp_region = MM.allocate_kernel_region(rsdp.page_base(), (PAGE_SIZE * 2), "ACPI Static Parsing search_table()", Region::Access::Read, false, true); - volatile auto* rsdp_ptr = (Structures::RSDPDescriptor20*)rsdp_region->vaddr().offset(rsdp.offset_in_page()).as_ptr(); - if (rsdp_ptr->base.revision == 0) { - return search_table_in_rsdt(PhysicalAddress(rsdp_ptr->base.rsdt_ptr), signature); - } - if (rsdp_ptr->base.revision >= 2) { - if (rsdp_ptr->xsdt_ptr != (u64) nullptr) - return search_table_in_xsdt(PhysicalAddress(rsdp_ptr->xsdt_ptr), signature); - return search_table_in_rsdt(PhysicalAddress(rsdp_ptr->base.rsdt_ptr), signature); - } - ASSERT_NOT_REACHED(); + ASSERT(strlen(signature) == 4); + auto rsdp_region = MM.allocate_kernel_region(rsdp.page_base(), (PAGE_SIZE * 2), "ACPI Static Parsing search_table()", Region::Access::Read, false, true); + volatile auto* rsdp_ptr = (Structures::RSDPDescriptor20*)rsdp_region->vaddr().offset(rsdp.offset_in_page()).as_ptr(); + if (rsdp_ptr->base.revision == 0) { + return search_table_in_rsdt(PhysicalAddress(rsdp_ptr->base.rsdt_ptr), signature); + } + if (rsdp_ptr->base.revision >= 2) { + if (rsdp_ptr->xsdt_ptr != (u64) nullptr) + return search_table_in_xsdt(PhysicalAddress(rsdp_ptr->xsdt_ptr), signature); + return search_table_in_rsdt(PhysicalAddress(rsdp_ptr->base.rsdt_ptr), signature); } + ASSERT_NOT_REACHED(); +} - PhysicalAddress StaticParsing::search_table_in_xsdt(PhysicalAddress xsdt, const char* signature) - { - // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables. - // FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length. - - ASSERT(strlen(signature) == 4); - auto main_sdt_region = MM.allocate_kernel_region(xsdt.page_base(), PAGE_SIZE, "ACPI Static Parsing search_table_in_xsdt()", Region::Access::Read, false, true); - auto* xsdt_ptr = (volatile Structures::XSDT*)main_sdt_region->vaddr().offset(xsdt.offset_in_page()).as_ptr(); - for (u32 i = 0; i < ((xsdt_ptr->h.length - sizeof(Structures::SDTHeader)) / sizeof(u64)); i++) { - if (match_table_signature(PhysicalAddress((FlatPtr)xsdt_ptr->table_ptrs[i]), signature)) - return PhysicalAddress((FlatPtr)xsdt_ptr->table_ptrs[i]); - } - return {}; +PhysicalAddress StaticParsing::search_table_in_xsdt(PhysicalAddress xsdt, const char* signature) +{ + // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables. + // FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length. + + ASSERT(strlen(signature) == 4); + auto main_sdt_region = MM.allocate_kernel_region(xsdt.page_base(), PAGE_SIZE, "ACPI Static Parsing search_table_in_xsdt()", Region::Access::Read, false, true); + auto* xsdt_ptr = (volatile Structures::XSDT*)main_sdt_region->vaddr().offset(xsdt.offset_in_page()).as_ptr(); + for (u32 i = 0; i < ((xsdt_ptr->h.length - sizeof(Structures::SDTHeader)) / sizeof(u64)); i++) { + if (match_table_signature(PhysicalAddress((FlatPtr)xsdt_ptr->table_ptrs[i]), signature)) + return PhysicalAddress((FlatPtr)xsdt_ptr->table_ptrs[i]); } + return {}; +} - bool StaticParsing::match_table_signature(PhysicalAddress table_header, const char* signature) - { - // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables. - // FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length. +bool StaticParsing::match_table_signature(PhysicalAddress table_header, const char* signature) +{ + // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables. + // FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length. - ASSERT(strlen(signature) == 4); - auto main_sdt_region = MM.allocate_kernel_region(table_header.page_base(), PAGE_SIZE, "ACPI Static Parsing match_table_signature()", Region::Access::Read, false, true); - auto* table_ptr = (volatile Structures::RSDT*)main_sdt_region->vaddr().offset(table_header.offset_in_page()).as_ptr(); - return !strncmp(const_cast<const char*>(table_ptr->h.sig), signature, 4); - } + ASSERT(strlen(signature) == 4); + auto main_sdt_region = MM.allocate_kernel_region(table_header.page_base(), PAGE_SIZE, "ACPI Static Parsing match_table_signature()", Region::Access::Read, false, true); + auto* table_ptr = (volatile Structures::RSDT*)main_sdt_region->vaddr().offset(table_header.offset_in_page()).as_ptr(); + return !strncmp(const_cast<const char*>(table_ptr->h.sig), signature, 4); +} - PhysicalAddress StaticParsing::search_table_in_rsdt(PhysicalAddress rsdt, const char* signature) - { - // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables. - // FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length. - ASSERT(strlen(signature) == 4); +PhysicalAddress StaticParsing::search_table_in_rsdt(PhysicalAddress rsdt, const char* signature) +{ + // FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables. + // FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length. + ASSERT(strlen(signature) == 4); - auto main_sdt_region = MM.allocate_kernel_region(rsdt.page_base(), PAGE_SIZE, "ACPI Static Parsing search_table_in_rsdt()", Region::Access::Read, false, true); - auto* rsdt_ptr = (volatile Structures::RSDT*)main_sdt_region->vaddr().offset(rsdt.offset_in_page()).as_ptr(); + auto main_sdt_region = MM.allocate_kernel_region(rsdt.page_base(), PAGE_SIZE, "ACPI Static Parsing search_table_in_rsdt()", Region::Access::Read, false, true); + auto* rsdt_ptr = (volatile Structures::RSDT*)main_sdt_region->vaddr().offset(rsdt.offset_in_page()).as_ptr(); - for (u32 i = 0; i < ((rsdt_ptr->h.length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) { - if (match_table_signature(PhysicalAddress((FlatPtr)rsdt_ptr->table_ptrs[i]), signature)) - return PhysicalAddress((FlatPtr)rsdt_ptr->table_ptrs[i]); - } - return {}; + for (u32 i = 0; i < ((rsdt_ptr->h.length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) { + if (match_table_signature(PhysicalAddress((FlatPtr)rsdt_ptr->table_ptrs[i]), signature)) + return PhysicalAddress((FlatPtr)rsdt_ptr->table_ptrs[i]); } + return {}; +} } } diff --git a/Kernel/ACPI/ACPIStaticParser.h b/Kernel/ACPI/ACPIStaticParser.h index 62129a33bf..ba56baa9fe 100644 --- a/Kernel/ACPI/ACPIStaticParser.h +++ b/Kernel/ACPI/ACPIStaticParser.h @@ -32,48 +32,48 @@ namespace Kernel { namespace ACPI { - class StaticParser : Parser { - public: - static void initialize(PhysicalAddress rsdp); - static void initialize_without_rsdp(); - static bool is_initialized(); +class StaticParser : Parser { +public: + static void initialize(PhysicalAddress rsdp); + static void initialize_without_rsdp(); + static bool is_initialized(); - virtual PhysicalAddress find_table(const char* sig) override; - virtual void try_acpi_reboot() override; - virtual bool can_reboot() override; - virtual bool can_shutdown() override { return false; } - virtual void try_acpi_shutdown() override; - virtual bool is_operable() override { return m_operable; } + virtual PhysicalAddress find_table(const char* sig) override; + virtual void try_acpi_reboot() override; + virtual bool can_reboot() override; + virtual bool can_shutdown() override { return false; } + virtual void try_acpi_shutdown() override; + virtual bool is_operable() override { return m_operable; } - virtual const FADTFlags::HardwareFeatures& hardware_features() const override; - virtual const FADTFlags::x86_Specific_Flags& x86_specific_flags() const override; + virtual const FADTFlags::HardwareFeatures& hardware_features() const override; + virtual const FADTFlags::x86_Specific_Flags& x86_specific_flags() const override; - protected: - StaticParser(); - explicit StaticParser(PhysicalAddress); +protected: + StaticParser(); + explicit StaticParser(PhysicalAddress); - private: - void locate_static_data(); - void locate_main_system_description_table(); - void initialize_main_system_description_table(); - size_t get_table_size(PhysicalAddress); - u8 get_table_revision(PhysicalAddress); - void init_fadt(); - void init_facs(); +private: + void locate_static_data(); + void locate_main_system_description_table(); + void initialize_main_system_description_table(); + size_t get_table_size(PhysicalAddress); + u8 get_table_revision(PhysicalAddress); + void init_fadt(); + void init_facs(); - bool validate_reset_register(); - void access_generic_address(const Structures::GenericAddressStructure&, u32 value); + bool validate_reset_register(); + void access_generic_address(const Structures::GenericAddressStructure&, u32 value); - PhysicalAddress m_rsdp; - PhysicalAddress m_main_system_description_table; + PhysicalAddress m_rsdp; + PhysicalAddress m_main_system_description_table; - Vector<PhysicalAddress> m_sdt_pointers; - PhysicalAddress m_fadt; - PhysicalAddress m_facs; + Vector<PhysicalAddress> m_sdt_pointers; + PhysicalAddress m_fadt; + PhysicalAddress m_facs; - bool m_xsdt_supported; - FADTFlags::HardwareFeatures m_hardware_flags; - FADTFlags::x86_Specific_Flags m_x86_specific_flags; - }; + bool m_xsdt_supported; + FADTFlags::HardwareFeatures m_hardware_flags; + FADTFlags::x86_Specific_Flags m_x86_specific_flags; +}; } } diff --git a/Kernel/ACPI/DMIDecoder.h b/Kernel/ACPI/DMIDecoder.h index 0e43bd50de..675e2748cf 100644 --- a/Kernel/ACPI/DMIDecoder.h +++ b/Kernel/ACPI/DMIDecoder.h @@ -36,1352 +36,1352 @@ namespace Kernel { namespace SMBIOS { - struct [[gnu::packed]] LegacyEntryPoint32bit - { - char legacy_sig[5]; - u8 checksum2; - u16 smboios_table_length; - u32 smbios_table_ptr; - u16 smbios_tables_count; - u8 smbios_bcd_revision; - }; - - struct [[gnu::packed]] EntryPoint32bit - { - char sig[4]; - u8 checksum; - u8 length; - u8 major_version; - u8 minor_version; - u16 maximum_structure_size; - u8 implementation_revision; - char formatted_area[5]; - LegacyEntryPoint32bit legacy_structure; - }; - - struct [[gnu::packed]] EntryPoint64bit - { - char sig[5]; - u8 checksum; - u8 length; - u8 major_version; - u8 minor_version; - u8 document_revision; - u8 revision; - u8 reserved; - u32 table_maximum_size; - u64 table_ptr; - }; - - struct [[gnu::packed]] TableHeader - { - u8 type; - u8 length; - u16 handle; - }; - - enum class TableType { - BIOSInfo = 0, - SysInfo = 1, - ModuleInfo = 2, - SysEnclosure = 3, - ProcessorInfo = 4, - CacheInfo = 7, - PortConnectorInfo = 8, - SystemSlots = 9, - OEMStrings = 11, - SysConfigOptions = 12, - BIOSLanguageInfo = 13, - GroupAssociations = 14, - SysEventLog = 15, - PhysicalMemoryArray = 16, - MemoryDevice = 17, - MemoryErrorInfo32Bit = 18, - MemoryArrayMappedAddress = 19, - MemoryDeviceMappedAddress = 20, - BuiltinPointingDevice = 21, - PortableBattery = 22, - SysReset = 23, - HardwareSecurity = 24, - SysPowerControls = 25, - VoltageProbe = 26, - CoolingDevice = 27, - TemperatureProbe = 28, - ElectricalCurrentProbe = 29, - OutOfBandRemoteAccess = 30, - SystemBootInfo = 32, - MemoryErrorInfo64Bit = 33, - ManagementDevice = 34, - ManagementDeviceComponent = 35, - ManagementDeviceThresholdData = 36, - MemoryChannel = 37, - IPMIDeviceInfo = 38, - SysPowerSupply = 39, - AdditionalInfo = 40, - OnboardDevicesExtendedInfo = 41, - ManagementControllerHostInterface = 42, - TPMDevice = 43, - ProcessorAdditionalInfo = 44, - Inactive = 126, - EndOfTable = 127 - }; - - struct [[gnu::packed]] BIOSInfo - { // Type 0 - TableHeader h; - u8 bios_vendor_str_number; - u8 bios_version_str_number; - u16 bios_segment; - u8 bios_release_date_str_number; - u8 bios_rom_size; - u64 bios_characteristics; - u8 ext_bios_characteristics[]; - }; - - enum class BIOSCharacteristics { - Unknown = (1 << 2), - NotSupported = (1 << 3), - ISA_support = (1 << 4), - MCA_support = (1 << 5), - EISA_support = (1 << 6), - PCI_support = (1 << 7), - PCMCIA_support = (1 << 8), - PnP_support = (1 << 9), - APM_support = (1 << 10), - UpgradeableBIOS = (1 << 11), - Shadowing_BIOS = (1 << 12), - VL_VESA_support = (1 << 13), - ESCD_support = (1 << 14), - CD_boot_support = (1 << 15), - select_boot_support = (1 << 16), - BIOS_ROM_socketed = (1 << 17), - PCMCIA_boot_support = (1 << 18), - EDD_spec_support = (1 << 19), - floppy_nec98_1200k_support = (1 << 20), - floppy_toshiba_1200k_support = (1 << 21), - floppy_360k_support = (1 << 22), - floppy_1200k_services_support = (1 << 23), - floppy_720k_services_support = (1 << 24), - floppy_2880k_services_support = (1 << 25), - int5_print_screen_support = (1 << 26), - int9_8042_keyboard_support = (1 << 27), - int14_serial_support = (1 << 28), - int17_printer_support = (1 << 29), - int10_video_support = (1 << 30), - nec_pc98 = (1 << 31) - }; - - struct [[gnu::packed]] ExtBIOSInfo - { - u8 bios_major_release; - u8 bios_minor_release; - u8 embedded_controller_firmware_major_release; - u8 embedded_controller_firmware_minor_release; - u16 ext_bios_rom_size; - }; - - struct [[gnu::packed]] SysInfo - { // Type 1 - TableHeader h; - u8 manufacturer_str_number; - u8 product_name_str_number; - u8 version_str_number; - u8 serial_number_str_number; - u64 uuid[2]; - u8 wake_up_type; - u8 sku_str_number; - u8 family_str_number; - }; - - enum class WakeUpType { - Reserved = 0, - Other = 1, - Unknown = 2, - APM_TIMER = 3, - MODEM_RING = 4, - LAN_REMOTE = 5, - POWER_SWTCH = 6, - PCI_PME = 7, - AC_RESTORE = 8, - }; - - struct [[gnu::packed]] ModuleInfo - { // Type 2 - TableHeader h; - u8 manufacturer_str_number; - u8 product_name_str_number; - u8 version_str_number; - u8 serial_number_str_number; - u8 asset_tag_str_number; - u8 feature_flags; - u8 chassis_location; - u16 chassis_handle; - u8 board_type; - u8 contained_object_handles_count; - u16 contained_object_handles[]; - }; - - enum class BoardType { - Unkown = 0x1, - Other = 0x2, - Server_Blade = 0x3, - Connectivity_Switch = 0x4, - System_Management_Module = 0x5, - Processor_Module = 0x6, - IO_Module = 0x7, - Memory_Module = 0x8, - Daughter_Board = 0x9, - Motherboard = 0xA, - Processor_Memory_Module = 0xB, - Processor_IO_Module = 0xC, - Interconnect_Board = 0xD, - }; - - struct [[gnu::packed]] SysEnclosure - { // Type 3 - TableHeader h; - u8 manufacturer_str_number; - u8 type; - u8 version_str_number; - u8 serial_number_str_number; - u8 asset_tag_str_number; - u8 boot_up_state; - u8 power_supply_state; - u8 thermal_state; - u8 security_status; - u32 vendor_specific_info; - u8 height; - u8 power_cords_number; - u8 contained_element_count; - u8 contained_element_record_length; - }; - - struct [[gnu::packed]] ExtSysEnclosure - { - u8 sku_str_number; - }; - - enum class SysEnclosureType { - Other = 0x1, - Unknown = 0x2, - Desktop = 0x3, - Low_Profile_Desktop = 0x4, - Pizza_Box = 0x5, - Mini_Tower = 0x6, - Tower = 0x7, - Portable = 0x8, - Laptop = 0x9, - Notebook = 0xA, - Hand_Held = 0xB, - Docking_Station = 0xC, - AIO = 0xD, - Sub_Notebook = 0xE, - Space_Saving = 0xF, - Lunch_Box = 0x10, - Main_Server_Chassis = 0x11, - Expansion_Chassis = 0x12, - Sub_Chassis = 0x13, - Bus_Expansion_Chassis = 0x14, - Peripheral_Chassis = 0x15, - RAID_Chassis = 0x16, - Rack_MOunt_Chassis = 0x17, - Sealed_case_PC = 0x18, - Multi_System_Chasis = 0x19, - Compact_PCI = 0x1A, - Advanced_TCA = 0x1B, - Blade = 0x1C, - Blade_Enclosure = 0x1D, - Tablet = 0x1E, - Convertible = 0x1F, - Detachable = 0x20, - IoT_Gateway = 0x21, - Embedded_PC = 0x22, - Mini_PC = 0x23, - Stick_PC = 0x24, - }; - - enum class SysEnclosureState { - Other = 0x1, - Unknown = 0x2, - Safe = 0x3, - Warning = 0x4, - Critical = 0x5, - Non_Recoverable = 0x6, - }; - - enum class SysEnclosureSecurityStatus { - Other = 0x1, - Unknown = 0x2, - None = 0x3, - External_Interface_Locked_Out = 0x4, - External_Interface_Enabled = 0x5, - }; - - struct [[gnu::packed]] SysEnclosureContainedElement - { - u8 type; - u8 min_contained_element_count; - u8 max_contained_element_count; - }; - - struct [[gnu::packed]] ProcessorInfo - { // Type 4 - TableHeader h; - u8 socket_designation_str_number; - u8 processor_type; - u8 processor_family; - u8 processor_manufacturer_str_number; - u64 processor_id; - u8 processor_version_str_number; - u8 voltage; - u16 external_clock; - u16 max_speed; - u16 current_speed; - u8 status; - u8 processor_upgrade; - u16 l1_cache_handle; - u16 l2_cache_handle; - u16 l3_cache_handle; - u8 serial_number_str_number; - u8 asset_tag_str_number; - u8 part_number_str_number; - u8 core_count; - u8 core_enabled; - u8 thread_count; - u16 processor_characteristics; - u16 processor_family2; - u16 core_count2; - u16 core_enabled2; - u16 thread_count2; - }; - - enum class ProcessorType { - Other = 0x1, - Unknown = 0x2, - Central_Processor = 0x3, - Math_Processor = 0x4, - DSP_Processor = 0x5, - Video_Processor = 0x6, - }; - - enum class ProcessorUpgrade { - Other = 0x1, - Unknown = 0x2, - Daughter_Board = 0x3, - ZIF_Socket = 0x4, - Replaceable_Piggy_Back = 0x5, - None = 0x6, - LIF_Sokcet = 0x7, - Slot_1 = 0x8, - Slot_2 = 0x9, - Socket_370_pin = 0xA, - Slot_A = 0xB, - Slot_M = 0xC, - Socket_423 = 0xD, - Socket_A_462 = 0xE, - Socket_478 = 0xF, - Socket_754 = 0x10, - Socket_940 = 0x11, - Socket_939 = 0x12, - Socket_mPGA604 = 0x13, - Socket_LGA771 = 0x14, - Socket_LGA775 = 0x15, - Socket_S1 = 0x16, - Socket_AM2 = 0x17, - Socket_F_1207 = 0x18, - Socket_LGA1366 = 0x19, - Socket_G34 = 0x1A, - Socket_AM3 = 0x1B, - Socket_C32 = 0x1C, - Socket_LGA1156 = 0x1D, - Socket_LGA1567 = 0x1E, - Socket_PGA988A = 0x1F, - Socket_BGA1288 = 0x20, - Socket_rPGA988B = 0x21, - Socket_BGA1023 = 0x22, - Socket_BGA1224 = 0x23, - Socket_LGA1155 = 0x24, - Socket_LGA1356 = 0x25, - Socket_LGA2011 = 0x26, - Socket_FS1 = 0x27, - Socket_FS2 = 0x28, - Socket_FM1 = 0x29, - Socket_FM2 = 0x2A, - Socket_LGA2011_3 = 0x2B, - Socket_LGA1356_3 = 0x2C, - Socket_LGA1150 = 0x2D, - Socket_BGA1168 = 0x2E, - Socket_BGA1234 = 0x2F, - Socket_BGA1364 = 0x30, - Socket_AM4 = 0x31, - Socket_LGA1151 = 0x32, - Socket_BGA1356 = 0x33, - Socket_BGA1440 = 0x34, - Socket_BGA1515 = 0x35, - Socket_LGA3647_1 = 0x36, - Socket_SP3 = 0x37, - Socket_SP3r2 = 0x38, - Socket_LGA2066 = 0x39, - Socket_BGA1392 = 0x3A, - Socket_BGA1510 = 0x3B, - Socket_BGA1528 = 0x3C - }; - - struct [[gnu::packed]] CacheInfo - { // Type 7 - TableHeader h; - u8 socket_designation_str_number; - u16 cache_config; - u16 max_cache_size; - u16 installed_size; - u16 supported_sram_type; - u16 current_sram_type; - u8 cache_speed; - u8 error_correction_type; - u8 system_cache_type; - u8 associativity; - u32 max_cache_size2; - u32 installed_size2; - }; - - struct [[gnu::packed]] PortConnectorInfo - { // Type 8 - TableHeader h; - u8 internal_reference_designator_str_number; - u8 internal_connector_type; - u8 external_reference_designator_str_number; - u8 external_connector_type; - u8 port_type; - }; - - enum class ConnectorType { - None = 0x0, - Centronics = 0x1, - Mini_Centronics = 0x2, - Proprietary = 0x3, - DB_25_pin_male = 0x4, - DB_25_pin_female = 0x5, - DB_15_pin_male = 0x6, - DB_15_pin_female = 0x7, - DB_9_pin_male = 0x8, - DB_9_pin_female = 0x9, - RJ_11 = 0xA, - RJ_45 = 0xB, - MiniSCSI_50_pin = 0xC, - MiniDIN = 0xD, - MicroDIN = 0xE, - PS2 = 0xF, - Infrared = 0x10, - HP_HIL = 0x11, - AccessBus_USB = 0x12, - SSA_SCSI = 0x13, - Circular_DIN8_male = 0x14, - Circular_DIN8_female = 0x15, - OnBoard_IDE = 0x16, - OnBoard_Floppy = 0x17, - Dual_Inline_9pin = 0x18, - Dual_Inline_25pin = 0x19, - Dual_Inline_50pin = 0x1A, - Dual_Inline_68pin = 0x1B, - OnBoard_SoundInput_CDROM = 0x1C, - Mini_Centronics_Type14 = 0x1D, - Mini_Centronics_Type26 = 0x1E, - Mini_Jack_Headphones = 0x1F, - BNC = 0x20, - Connector_1394 = 0x21, - SAS_SATA_Plug_Receptacle = 0x22, - USB_TypeC_Receptacle = 0x23, - PC98 = 0xA0, - PC98_Hireso = 0xA1, - PC_H98 = 0xA2, - PC98_Note = 0xA3, - PC98_Full = 0xA4, - Other = 0xFF - }; - - enum class PortType { - None = 0x0, - Parallel_Port_XT_AT_Compatible = 0x1, - Parallel_Port_PS2 = 0x2, - Parallel_Port_ECP = 0x3, - Parallel_Port_EPP = 0x4, - Parallel_Port_ECP_EPP = 0x5, - Serial_Port_XT_AT_Compatible = 0x6, - Serial_Port_16450_Compatible = 0x7, - Serial_Port_16550_Compatible = 0x8, - Serial_Port_16550A_Compatible = 0x9, - SCSI_Port = 0xA, - MIDI_Port = 0xB, - Joy_Stick_Port = 0xC, - Keyboard_Port = 0xD, - Mouse_Port = 0xE, - SSA_SCSI = 0xF, - USB = 0x10, - FireWire = 0x11, - PCMCIA_Type1 = 0x12, - PCMCIA_Type2 = 0x13, - PCMCIA_Type3 = 0x14, - Cardbus = 0x15, - AccessBus_Port = 0x16, - SCSI_2 = 0x17, - SCSI_Wide = 0x18, - PC98 = 0x19, - PC98_Hireso = 0x1A, - PC_H98 = 0x1B, - Video_Port = 0x1C, - Audio_Port = 0x1D, - Modem_Port = 0x1E, - Network_Port = 0x1F, - SATA = 0x20, - SAS = 0x21, - MFDP = 0x22, - Thunderbolt = 0x23, - Intel_8251_Compatible = 0xA0, - Intel_8251_FIFO_Compatible = 0xA1, - Other = 0xFF - }; - - struct [[gnu::packed]] SystemSlotPeerGroup - { - u16 segment_group_number; - u8 bus_number; - u8 device_function_number; - u8 data_bus_width; - }; - - struct [[gnu::packed]] SystemSlots - { // Type 9 - TableHeader h; - u8 slot_designation_str_number; - u8 slot_type; - u8 slot_data_bus_width; - u8 current_stage; - u8 slot_length; - u16 slot_id; - u8 slot_characteristics_1; - u8 slot_characteristics_2; - u16 segment_group_number; - u8 bus_number; - u8 device_function_number; - u8 data_bus_width; - u8 peer_grouping_count; - SystemSlotPeerGroup peer_groups[]; - }; - - enum class SlotType { - Other = 0x1, - Unknown = 0x2, - ISA = 0x3, - MCA = 0x4, - EISA = 0x5, - PCI = 0x6, - PCMCIA = 0x7, - VL_VESA = 0x8, - Proprietary = 0x9, - Processor_Card_Slot = 0xA, - Proprietary_Memory_Card_Slot = 0xB, - IO_Riser_Card_Slot = 0xC, - NuBus = 0xD, - PCI_66MHZ_Capable = 0xE, - AGP = 0xF, - AGP_2X = 0x10, - AGP_4X = 0x11, - PCI_X = 0x12, - AGP_8X = 0x13, - M_Dot_2_Socket_1_DP = 0x14, - M_Dot_2_Socket_1_SD = 0x15, - M_Dot_2_Socket_2 = 0x16, - M_Dot_2_Socket_3 = 0x17, - MXM_Type1 = 0x18, - MXM_Type2 = 0x19, - MXM_Type3_Standard = 0x1A, - MXM_Type3_HE = 0x1B, - MXM_Type4 = 0x1C, - MXM_3_Type_A = 0x1D, - MXM_3_Type_B = 0x1E, - PCI_Express_Gen2 = 0x1F, - PCI_Express_Gen3 = 0x20, - PCI_Express_Mini_52pin_Type1 = 0x21, - PCI_Express_Mini_52pin_Type2 = 0x22, - PCI_Express_Mini_76pin = 0x23, - CXL_Flexbus_1_0 = 0x30, - PC98_C20 = 0xA0, - PC98_C24 = 0xA1, - PC98_E = 0xA2, - PC98_Local_Bus = 0xA3, - PC98_Card = 0xA4, - PCI_Express = 0xA5, - PCI_Express_x1 = 0xA6, - PCI_Express_x2 = 0xA7, - PCI_Express_x4 = 0xA8, - PCI_Express_x8 = 0xA9, - PCI_Express_x16 = 0xAA, - PCI_Express_Gen_2 = 0xAB, - PCI_Express_Gen_2_x1 = 0xAC, - PCI_Express_Gen_2_x2 = 0xAD, - PCI_Express_Gen_2_x4 = 0xAE, - PCI_Express_Gen_2_x8 = 0xAF, - PCI_Express_Gen_2_x16 = 0xB0, - PCI_Express_Gen_3 = 0xB1, - PCI_Express_Gen_3_x1 = 0xB2, - PCI_Express_Gen_3_x2 = 0xB3, - PCI_Express_Gen_3_x4 = 0xB4, - PCI_Express_Gen_3_x8 = 0xB5, - PCI_Express_Gen_3_x16 = 0xB6, - PCI_Express_Gen_4 = 0xB8, - PCI_Express_Gen_4_x1 = 0xB9, - PCI_Express_Gen_4_x2 = 0xBA, - PCI_Express_Gen_4_x4 = 0xBB, - PCI_Express_Gen_4_x8 = 0xBC, - PCI_Express_Gen_4_x16 = 0xBD - }; - - enum class SlotDataBusWidth { - Other = 0x1, - Unknown = 0x2, - _8_bit = 0x3, - _16_bit = 0x4, - _32_bit = 0x5, - _64_bit = 0x6, - _128_bit = 0x7, - _1x_x1 = 0x8, - _2x_x2 = 0x9, - _4x_x4 = 0xA, - _8x_x8 = 0xB, - _12x_x12 = 0xC, - _16x_x16 = 0xD, - _32x_x32 = 0xE - }; - - enum class SlotCurrentUsage { - Other = 0x1, - Unknown = 0x2, - Available = 0x3, - In_Use = 0x4, - Unavailable = 0x5 - }; - - enum class SlotLength { - Other = 0x1, - Unknown = 0x2, - Short_Length = 0x3, - Long_Length = 0x4, - _2_5_Drive_Form_Factor = 0x5, - _3_5_Drive_Form_Factor = 0x6 - }; - - enum class SlotCharacteristics1 { - Unknown = (1 << 0), - Provides_5volt = (1 << 1), - Provides_3_3volt = (1 << 2), - Shared_Slot = (1 << 3), - Support_PC_Card_16 = (1 << 4), - Support_CardBus = (1 << 5), - Support_Zoom_Video = (1 << 6), - Support_Modem_Ring_Resume = (1 << 7) - }; - - enum class SlotCharacteristics2 { - Support_PCI_PME = (1 << 0), - Support_Hot_Plug = (1 << 1), - Support_SMBus = (1 << 2), - Support_Bifurcation = (1 << 3), - }; - - struct [[gnu::packed]] OEMStrings - { // Type 11 - TableHeader h; - u8 strings_count; - }; - - struct [[gnu::packed]] SysConfigOptions - { // Type 12 - TableHeader h; - u8 strings_count; - }; - - struct [[gnu::packed]] BIOSLanguageInfo - { // Type 13 - TableHeader h; - u8 installable_langs_counts; - u8 flags; - u8 reserved[15]; - u8 current_lang_str_number; // String number (one-based) of the currently installed language - }; - - struct [[gnu::packed]] GroupAssociations - { // Type 14 - TableHeader h; - u8 group_name_str_number; - u8 item_type; - u16 item_handle; - }; - - struct [[gnu::packed]] SysEventLog - { // Type 15 - TableHeader h; - u16 log_area_length; - u16 log_header_start_offset; - u16 log_data_start_offset; - u8 access_method; - u8 log_status; - u32 log_change_token; - u32 access_method_address; - u8 log_header_format; - u8 supported_log_type_descriptors_count; - u8 log_type_descriptor_length; - u8 supported_event_log_type_descriptor_list[]; - }; - - struct [[gnu::packed]] PhysicalMemoryArray - { // Type 16 - TableHeader h; - u8 location; - u8 use; - u8 memory_error_correction; - u32 max_capacity; - u16 memory_error_info_handle; - u16 memory_devices_count; - u64 ext_max_capacity; - }; - - enum class MemoryArrayLocation { - Other = 0x1, - Unknown = 0x2, - Motherboard = 0x3, - ISA_addon_card = 0x4, - EISA_addon_card = 0x5, - PCI_addon_card = 0x6, - MCA_addon_card = 0x7, - PCMCIA_addon_card = 0x8, - Proprietary_addon_card = 0x9, - NuBus = 0xA, - PC98_C20_addon_card = 0xA0, - PC98_C24_addon_card = 0xA1, - PC98_E_addon_card = 0xA2, - PC98_Local_Bus_addon_card = 0xA3, - CXL_Flexbus_1_0_addon_card = 0xA4 - }; - - enum class MemoryArrayUse { - Other = 0x1, - Unknown = 0x2, - System_Memory = 0x3, - Video_Memory = 0x4, - Flash_Memory = 0x5, - Non_Volatile_RAM = 0x6, - Cache_Memory = 0x7 - }; - - enum class MemoryArrayErrorCorrectionType { - Other = 0x1, - Unknown = 0x2, - None = 0x3, - Parity = 0x4, - SingleBit_ECC = 0x5, - MultiBit_ECC = 0x6, - CRC = 0x7 - }; - - struct [[gnu::packed]] MemoryDevice - { // Type 17 - TableHeader h; - u16 physical_memory_array_handle; - u16 memory_error_info_handle; - u16 total_width; - u16 data_width; - u16 size; - u8 form_factor; - u8 device_set; - u8 device_locator_str_number; - u8 bank_locator_str_number; - u8 memory_type; - u16 type_detail; - u16 speed; - u8 manufacturer_str_number; - u8 serial_number_str_number; - u8 asset_tag_str_number; - u8 part_number_str_number; - u8 attributes; - u32 ext_size; - u16 configured_memory_speed; - u16 min_voltage; - u16 max_voltage; - u16 configured_voltage; - u8 memory_technology; - u16 memory_operating_mode_capability; - u8 firmware_version_str_number; - u16 module_manufacturer_id; - u16 module_product_id; - u16 memory_subsystem_controller_manufacturer_id; - u16 memory_subsystem_controller_product_id; - u64 non_volatile_size; - u64 volatile_size; - u64 cache_size; - u64 logical_size; - u32 ext_speed; - u32 ext_configured_memory_speed; - }; - - enum class MemoryDeviceFormFactor { - Other = 0x1, - Unknown = 0x2, - SIMM = 0x3, - SIP = 0x4, - Chip = 0x5, - DIP = 0x6, - ZIP = 0x7, - ProprietaryCard = 0x8, - DIMM = 0x9, - TSOP = 0xA, - Chips_Row = 0xB, - RIMM = 0xC, - SODIMM = 0xD, - SRIMM = 0xE, - FB_DIMM = 0xF, - Die = 0x10 - }; - - enum class MemoryDeviceType { - Other = 0x1, - Unknown = 0x2, - DRAM = 0x3, - EDRAM = 0x4, - VRAM = 0x5, - SRAM = 0x6, - RAM = 0x7, - ROM = 0x8, - FLASH = 0x9, - EEPROM = 0xA, - FEPROM = 0xB, - EPROM = 0xC, - CDRAM = 0xD, - _3DRAM = 0xE, - SDRAM = 0xF, - SGRAM = 0x10, - RDRAM = 0x11, - DDR = 0x12, - DDR2 = 0x13, - DDR2_FB_DIMM = 0x14, - DDR3 = 0x18, - FBD2 = 0x19, - DDR4 = 0x1A, - LPDDR = 0x1B, - LPDDR2 = 0x1C, - LPDDR3 = 0x1D, - LPDDR4 = 0x1E, - Logical_Non_Volatile_Device = 0x1F, - HBM = 0x20, // (High Bandwidth Memory) - HBM2 = 0x21, // (High Bandwidth Memory Generation 2) - }; - - enum class MemoryDeviceTypeDetail { - Other = (1 << 1), - Unknown = (1 << 2), - Fast_paged = (1 << 3), - Static_Column = (1 << 4), - Pseudo_Static = (1 << 5), - RAMBUS = (1 << 6), - Synchronous = (1 << 7), - CMOS = (1 << 8), - EDO = (1 << 9), - Window_DRAM = (1 << 10), - Cache_DRAM = (1 << 11), - Non_volatile = (1 << 12), - Registered_Buffered = (1 << 13), - Unbuffered_Unregistered = (1 << 14), - LRDIMM = (1 << 15) - }; - - enum class MemoryDeviceTechnology { - Other = 0x1, - Unknown = 0x2, - DRAM = 0x3, - NVDIMM_N = 0x4, - NVDIMM_F = 0x5, - NVDIMM_P = 0x6, - Intel_Optane_DC_Persistent_Memory = 0x7 - }; - - enum class MemoryDeviceOperatingModeCapability { - Other = (1 << 1), - Unknown = (1 << 2), - Volatile_Memory = (1 << 3), - Byte_accessible_persistent_memory = (1 << 4), - Block_accessible_persistent_memory = (1 << 5), - }; - - struct MemoryErrorInfo32Bit { // Type 18 - TableHeader h; - u8 error_type; - u8 error_granularity; - u8 error_operation; - u32 vendor_syndrome; - u32 memory_array_error_address; - u32 device_error_address; - u32 error_resolution; - }; - - enum class MemoryErrorType { - Other = 0x1, - Unknown = 0x2, - OK = 0x3, - Bad_read = 0x4, - Parity_error = 0x5, - SingleBit_error = 0x6, - DoubleBit_error = 0x7, - MultiBit_error = 0x8, - Nibble_error = 0x9, - Checksum_error = 0xA, - CRC_error = 0xB, - Corrected_SingleBit_error = 0xC, - Corrected_error = 0xD, - Uncorrectable_error = 0xE - }; - - enum class MemoryErrorGranularity { - Other = 0x1, - Unknown = 0x2, - Device_level = 0x3, - Memory_partition_level = 0x4 - }; - - enum class MemoryErrorOperation { - Other = 0x1, - Unknown = 0x2, - Read = 0x3, - Write = 0x4, - Partial_Write = 0x5 - }; - - struct [[gnu::packed]] MemoryArrayMappedAddress - { // Type 19 - TableHeader h; - u32 starting_address; - u32 ending_address; - u16 memory_array_handle; - u8 partition_width; - u64 ext_starting_address; - u64 ext_ending_address; - }; - - struct [[gnu::packed]] MemoryDeviceMappedAddress - { // Type 20 - TableHeader h; - u32 starting_address; - u32 ending_address; - u16 memory_device_handle; - u16 memory_array_mapped_handle; - u8 partition_row_position; - u8 interleave_position; - u8 interleaved_data_depth; - u64 ext_starting_address; - u64 ext_ending_address; - }; - - struct [[gnu::packed]] BuiltinPointingDevice - { // Type 21 - TableHeader h; - u8 type; - u8 interface; - u8 buttons_count; - }; - - enum class PointingDeviceType { - Other = 0x1, - Unknown = 0x2, - Mouse = 0x3, - Track_Ball = 0x4, - Track_Point = 0x5, - Glide_Point = 0x6, - Touch_Pad = 0x7, - Touch_Screen = 0x8, - Optical_Sensor = 0x9 - }; - - enum class PointingDeviceInterface { - Other = 0x1, - Unknown = 0x2, - Serial = 0x3, - PS2 = 0x4, - Infrared = 0x5, - HP_HIL = 0x6, - Bus_mouse = 0x7, - AppleDesktopBus = 0x8, - Bus_mouse_DB9 = 0xA0, - Bus_mouse_microDIN = 0xA1, - USB = 0xA2 - }; - - struct [[gnu::packed]] PortableBattery - { // Type 22 - TableHeader h; - u8 location_str_number; - u8 manufacturer_str_number; - u8 manufacture_date_str_number; - u8 serial_number_str_number; - u8 device_name_str_number; - u8 device_chemistry; - u16 design_capacity; - u16 design_voltage; - u8 sbds_version_number; - u8 max_error_battery_data; - u16 sbds_serial_number; - u16 sbds_manufacture_date; - u8 sbds_device_chemistry_str_number; - u8 design_capacity_multiplier; - u32 oem_specific; - }; - - enum class PortableBatteryChemistry { - Other = 0x1, - Unknown = 0x2, - Lead_Acid = 0x3, - Nickel_Cadmium = 0x4, - Nickel_metal_hydride = 0x5, - Lithium_ion = 0x6, - Zinc_air = 0x7, - Lithium_polymer = 0x8 - }; - - struct [[gnu::packed]] SysReset - { // Type 23 - TableHeader h; - u8 capabilities; - u16 reset_count; - u16 reset_limit; - u16 timer_interval; - u16 timeout; - }; - - struct [[gnu::packed]] HardwareSecurity - { // Type 24 - TableHeader h; - u8 hardware_security_settings; - }; - - struct [[gnu::packed]] SysPowerControls - { // Type 25 - TableHeader h; - u8 next_scheduled_power_on_month; - u8 next_scheduled_power_on_day_of_month; - u8 next_scheduled_power_on_hour; - u8 next_scheduled_power_on_minute; - u8 next_scheduled_power_on_second; - }; - - struct [[gnu::packed]] VoltageProbe - { // Type 26 - TableHeader h; - u8 description_str_number; - u8 location_and_status; - u16 max_value; - u16 min_value; - u16 resolution; - u16 tolerance; - u16 accuracy; - u32 oem_defined; - u16 nominal_value; - }; - - struct [[gnu::packed]] CoolingDevice - { // Type 27 - TableHeader h; - u16 temperature_probe_handle; - u8 device_type_and_status; - u8 cooling_unit_group; - u32 oem_defined; - u16 nominal_speed; - u8 description_str_number; - }; - - struct [[gnu::packed]] TemperatureProbe - { // Type 28 - TableHeader h; - u8 description_str_number; - u8 location_and_status; - u16 max_value; - u16 min_value; - u16 resolution; - u16 tolerance; - u16 accuracy; - u32 oem_defined; - u16 nominal_value; - }; - - struct [[gnu::packed]] ElectricalCurrentProbe - { // Type 29 - TableHeader h; - u8 description_str_number; - u8 location_and_status; - u16 max_value; - u16 min_value; - u16 resolution; - u16 tolerance; - u16 accuracy; - u32 oem_defined; - u16 nominal_value; - }; - - struct [[gnu::packed]] OutOfBandRemoteAccess - { // Type 30 - TableHeader h; - u8 manufacturer_name_str_number; - u8 connections; - }; - - struct [[gnu::packed]] SystemBootInfo - { // Type 32 - TableHeader h; - u8 reserved[6]; - u8 boot_status[10]; - }; - - struct [[gnu::packed]] MemoryErrorInfo64Bit - { // Type 33 - TableHeader h; - u8 error_type; - u8 error_granularity; - u8 error_operation; - u32 vendor_syndrome; - u64 memory_array_error_address; - u64 device_error_address; - u32 error_resolution; - }; - - struct [[gnu::packed]] ManagementDevice - { // Type 34 - TableHeader h; - u8 description_str_number; - u8 type; - u32 address; - u8 address_type; - }; - - enum class ManagementDeviceType { - Other = 0x1, - Unknown = 0x2, - LM75 = 0x3, - LM78 = 0x4, - LM79 = 0x5, - LM80 = 0x6, - LM81 = 0x7, - ADM9240 = 0x8, - DS1780 = 0x9, - Maxim_1617 = 0xA, - GL518SM = 0xB, // Genesys GL518SM - W83781D = 0xC, // Winbond W83781D - HT82H791 = 0xD // Holtek HT82H791 - }; - - enum class ManagementDeviceAddressType { - Other = 0x1, - Unknown = 0x2, - IO_Port = 0x3, - Memory = 0x4, - SMBus = 0x5 - }; - - struct [[gnu::packed]] ManagementDeviceComponent - { // Type 35 - TableHeader h; - u8 description_str_number; - u16 management_device_handle; - u16 component_handle; - u16 threshold_handle; - }; - - struct [[gnu::packed]] ManagementDeviceThresholdData - { // Type 36 - TableHeader h; - u16 lower_threshold_non_critical; - u16 upper_threshold_non_critical; - u16 lower_threshold_critical; - u16 upper_threshold_critical; - u16 lower_threshold_non_recoverable; - u16 upper_threshold_non_recoverable; - }; - - struct [[gnu::packed]] MemoryDeviceDescriptor - { - u8 device_load; - u16 device_handle; - }; - - struct [[gnu::packed]] MemoryChannel - { // Type 37 - TableHeader h; - u8 channel_type; - u8 memory_device_count; - MemoryDeviceDescriptor memory_devices_descriptors[]; - }; - - enum class MemroryChannelType { - Other = 0x1, - Unknown = 0x2, - RamBus = 0x3, - SyncLink = 0x4 - }; - - struct [[gnu::packed]] IPMIDeviceInfo - { // Type 38 - TableHeader h; - u8 interface_type; - u8 ipmi_spec_revision; - u8 i2c_slave_address; - u8 nv_storage_device_address; - u64 base_address; - u8 base_address_modifier; - u8 interrupt_number; - }; - - enum class IPMIDeviceInfoBMCInterfaceType { - Unknown = 0x1, - KCS = 0x2, // KCS: Keyboard Controller Style - SMIC = 0x3, // SMIC: Server Management Interface Chip - BT = 0x4, // BT: Block Transfer - SSIF = 0x5 // SSIF: SMBus System Interface - }; - - struct [[gnu::packed]] SysPowerSupply - { // Type 39 - TableHeader h; - u8 power_unit_group; - u8 location_str_number; - u8 device_name_str_number; - u8 manufacturer_str_number; - u8 serial_number_str_number; - u8 asset_tag_number_str_number; - u8 model_part_number_str_number; - u8 revision_level_str_number; - u16 max_power_capacity; - u16 power_supply_characteristics; - u16 input_voltage_probe_handle; - u16 cooling_device_handle; - u16 input_current_probe_handle; - }; - - struct [[gnu::packed]] AdditionalInfoEntry - { - u8 entry_length; - u16 referenced_handle; - u8 referenced_offset; - u8 string_number; - u8 value[]; - }; - - struct [[gnu::packed]] AdditionalInfo - { // Type 40 - TableHeader h; - u8 additional_info_entries_count; - AdditionalInfoEntry entries[]; - }; - - struct [[gnu::packed]] OnboardDevicesExtendedInfo - { // Type 41 - TableHeader h; - u8 reference_designation_str_number; - u8 device_type; - u8 device_type_instance; - u16 segment_group_number; - u8 bus_number; - u8 device_function_number; - }; - - enum class OnboardDeviceType { - Other = 0x1, - Unknown = 0x2, - Video = 0x3, - SCSI_Controller = 0x4, - Ethernet = 0x5, - Token_Ring = 0x6, - Sound = 0x7, - PATA_Controller = 0x8, - SATA_Controller = 0x9, - SAS_Controller = 0xA - }; - - struct [[gnu::packed]] ManagementControllerHostInterface - { // Type 42 - TableHeader h; - u8 interface_type; - u8 interface_type_specific_data_length; - u8 interface_type_specific_data[]; - }; - - struct [[gnu::packed]] ProtocolRecordData - { - u8 protocol_type; - u8 protocol_type_specific_data_length; - u8 protocol_type_specific_data[]; - }; - - struct [[gnu::packed]] ExtManagementControllerHostInterface - { // Type 42 Ext - u8 protocol_records_count; - ProtocolRecordData protocol_records[]; - }; - - enum class ManagementControllerHostInterfaceProtocolType { - IPMI = 0x2, - MCTP = 0x3, - RedfishOverIP = 0x4 - }; - - struct [[gnu::packed]] TPMDevice - { // Type 43 - TableHeader h; - char vendor_id[4]; - u8 major_spec_version; - u8 minor_spec_version; - u32 firmware_version_1; - u32 firmware_version_2; - u8 description_str_number; - u64 characteristics; - u32 oem_defined; - }; - - enum class TPMDeviceCharacteristics { - Characteristics_not_supported = (1 << 2), - Family_Configurable_1 = (1 << 3), // Family configurable via firmware update; for example, switching between TPM 1.2 and TPM 2.0. - Family_Configurable_2 = (1 << 4), // Family configurable via platform software support, such as BIOS Setup; for example, switching between TPM 1.2 and TPM 2.0. - Family_Configurable_3 = (1 << 5), // Family configurable via OEM proprietary mechanism; for example, switching between TPM 1.2 and TPM 2.0. - }; - - struct [[gnu::packed]] ProcessorSpecificBlock - { - u8 block_length; - u8 processor_type; - u8 processor_specific_data[]; - }; - - struct [[gnu::packed]] ProcessorAdditionalInfo - { // Type 44 - TableHeader h; - u16 referenced_handle; - ProcessorSpecificBlock blocks[]; - }; - - enum class ProcessorArchitectureType { - IA32 = 0x1, - x86_64 = 0x2, - Itanium = 0x3, - ARM32bit = 0x4, - ARM64bit = 0x5, - RISC_V_32bit = 0x6, - RISC_V_64bit = 0x7, - RISC_V_128bit = 0x8 - }; - - struct [[gnu::packed]] Inactive - { // Type 126 - TableHeader h; - }; - - struct [[gnu::packed]] EndOfTable - { // Type 127 - TableHeader h; - }; +struct [[gnu::packed]] LegacyEntryPoint32bit +{ + char legacy_sig[5]; + u8 checksum2; + u16 smboios_table_length; + u32 smbios_table_ptr; + u16 smbios_tables_count; + u8 smbios_bcd_revision; +}; + +struct [[gnu::packed]] EntryPoint32bit +{ + char sig[4]; + u8 checksum; + u8 length; + u8 major_version; + u8 minor_version; + u16 maximum_structure_size; + u8 implementation_revision; + char formatted_area[5]; + LegacyEntryPoint32bit legacy_structure; +}; + +struct [[gnu::packed]] EntryPoint64bit +{ + char sig[5]; + u8 checksum; + u8 length; + u8 major_version; + u8 minor_version; + u8 document_revision; + u8 revision; + u8 reserved; + u32 table_maximum_size; + u64 table_ptr; +}; + +struct [[gnu::packed]] TableHeader +{ + u8 type; + u8 length; + u16 handle; +}; + +enum class TableType { + BIOSInfo = 0, + SysInfo = 1, + ModuleInfo = 2, + SysEnclosure = 3, + ProcessorInfo = 4, + CacheInfo = 7, + PortConnectorInfo = 8, + SystemSlots = 9, + OEMStrings = 11, + SysConfigOptions = 12, + BIOSLanguageInfo = 13, + GroupAssociations = 14, + SysEventLog = 15, + PhysicalMemoryArray = 16, + MemoryDevice = 17, + MemoryErrorInfo32Bit = 18, + MemoryArrayMappedAddress = 19, + MemoryDeviceMappedAddress = 20, + BuiltinPointingDevice = 21, + PortableBattery = 22, + SysReset = 23, + HardwareSecurity = 24, + SysPowerControls = 25, + VoltageProbe = 26, + CoolingDevice = 27, + TemperatureProbe = 28, + ElectricalCurrentProbe = 29, + OutOfBandRemoteAccess = 30, + SystemBootInfo = 32, + MemoryErrorInfo64Bit = 33, + ManagementDevice = 34, + ManagementDeviceComponent = 35, + ManagementDeviceThresholdData = 36, + MemoryChannel = 37, + IPMIDeviceInfo = 38, + SysPowerSupply = 39, + AdditionalInfo = 40, + OnboardDevicesExtendedInfo = 41, + ManagementControllerHostInterface = 42, + TPMDevice = 43, + ProcessorAdditionalInfo = 44, + Inactive = 126, + EndOfTable = 127 +}; + +struct [[gnu::packed]] BIOSInfo +{ // Type 0 + TableHeader h; + u8 bios_vendor_str_number; + u8 bios_version_str_number; + u16 bios_segment; + u8 bios_release_date_str_number; + u8 bios_rom_size; + u64 bios_characteristics; + u8 ext_bios_characteristics[]; +}; + +enum class BIOSCharacteristics { + Unknown = (1 << 2), + NotSupported = (1 << 3), + ISA_support = (1 << 4), + MCA_support = (1 << 5), + EISA_support = (1 << 6), + PCI_support = (1 << 7), + PCMCIA_support = (1 << 8), + PnP_support = (1 << 9), + APM_support = (1 << 10), + UpgradeableBIOS = (1 << 11), + Shadowing_BIOS = (1 << 12), + VL_VESA_support = (1 << 13), + ESCD_support = (1 << 14), + CD_boot_support = (1 << 15), + select_boot_support = (1 << 16), + BIOS_ROM_socketed = (1 << 17), + PCMCIA_boot_support = (1 << 18), + EDD_spec_support = (1 << 19), + floppy_nec98_1200k_support = (1 << 20), + floppy_toshiba_1200k_support = (1 << 21), + floppy_360k_support = (1 << 22), + floppy_1200k_services_support = (1 << 23), + floppy_720k_services_support = (1 << 24), + floppy_2880k_services_support = (1 << 25), + int5_print_screen_support = (1 << 26), + int9_8042_keyboard_support = (1 << 27), + int14_serial_support = (1 << 28), + int17_printer_support = (1 << 29), + int10_video_support = (1 << 30), + nec_pc98 = (1 << 31) +}; + +struct [[gnu::packed]] ExtBIOSInfo +{ + u8 bios_major_release; + u8 bios_minor_release; + u8 embedded_controller_firmware_major_release; + u8 embedded_controller_firmware_minor_release; + u16 ext_bios_rom_size; +}; + +struct [[gnu::packed]] SysInfo +{ // Type 1 + TableHeader h; + u8 manufacturer_str_number; + u8 product_name_str_number; + u8 version_str_number; + u8 serial_number_str_number; + u64 uuid[2]; + u8 wake_up_type; + u8 sku_str_number; + u8 family_str_number; +}; + +enum class WakeUpType { + Reserved = 0, + Other = 1, + Unknown = 2, + APM_TIMER = 3, + MODEM_RING = 4, + LAN_REMOTE = 5, + POWER_SWTCH = 6, + PCI_PME = 7, + AC_RESTORE = 8, +}; + +struct [[gnu::packed]] ModuleInfo +{ // Type 2 + TableHeader h; + u8 manufacturer_str_number; + u8 product_name_str_number; + u8 version_str_number; + u8 serial_number_str_number; + u8 asset_tag_str_number; + u8 feature_flags; + u8 chassis_location; + u16 chassis_handle; + u8 board_type; + u8 contained_object_handles_count; + u16 contained_object_handles[]; +}; + +enum class BoardType { + Unkown = 0x1, + Other = 0x2, + Server_Blade = 0x3, + Connectivity_Switch = 0x4, + System_Management_Module = 0x5, + Processor_Module = 0x6, + IO_Module = 0x7, + Memory_Module = 0x8, + Daughter_Board = 0x9, + Motherboard = 0xA, + Processor_Memory_Module = 0xB, + Processor_IO_Module = 0xC, + Interconnect_Board = 0xD, +}; + +struct [[gnu::packed]] SysEnclosure +{ // Type 3 + TableHeader h; + u8 manufacturer_str_number; + u8 type; + u8 version_str_number; + u8 serial_number_str_number; + u8 asset_tag_str_number; + u8 boot_up_state; + u8 power_supply_state; + u8 thermal_state; + u8 security_status; + u32 vendor_specific_info; + u8 height; + u8 power_cords_number; + u8 contained_element_count; + u8 contained_element_record_length; +}; + +struct [[gnu::packed]] ExtSysEnclosure +{ + u8 sku_str_number; +}; + +enum class SysEnclosureType { + Other = 0x1, + Unknown = 0x2, + Desktop = 0x3, + Low_Profile_Desktop = 0x4, + Pizza_Box = 0x5, + Mini_Tower = 0x6, + Tower = 0x7, + Portable = 0x8, + Laptop = 0x9, + Notebook = 0xA, + Hand_Held = 0xB, + Docking_Station = 0xC, + AIO = 0xD, + Sub_Notebook = 0xE, + Space_Saving = 0xF, + Lunch_Box = 0x10, + Main_Server_Chassis = 0x11, + Expansion_Chassis = 0x12, + Sub_Chassis = 0x13, + Bus_Expansion_Chassis = 0x14, + Peripheral_Chassis = 0x15, + RAID_Chassis = 0x16, + Rack_MOunt_Chassis = 0x17, + Sealed_case_PC = 0x18, + Multi_System_Chasis = 0x19, + Compact_PCI = 0x1A, + Advanced_TCA = 0x1B, + Blade = 0x1C, + Blade_Enclosure = 0x1D, + Tablet = 0x1E, + Convertible = 0x1F, + Detachable = 0x20, + IoT_Gateway = 0x21, + Embedded_PC = 0x22, + Mini_PC = 0x23, + Stick_PC = 0x24, +}; + +enum class SysEnclosureState { + Other = 0x1, + Unknown = 0x2, + Safe = 0x3, + Warning = 0x4, + Critical = 0x5, + Non_Recoverable = 0x6, +}; + +enum class SysEnclosureSecurityStatus { + Other = 0x1, + Unknown = 0x2, + None = 0x3, + External_Interface_Locked_Out = 0x4, + External_Interface_Enabled = 0x5, +}; + +struct [[gnu::packed]] SysEnclosureContainedElement +{ + u8 type; + u8 min_contained_element_count; + u8 max_contained_element_count; +}; + +struct [[gnu::packed]] ProcessorInfo +{ // Type 4 + TableHeader h; + u8 socket_designation_str_number; + u8 processor_type; + u8 processor_family; + u8 processor_manufacturer_str_number; + u64 processor_id; + u8 processor_version_str_number; + u8 voltage; + u16 external_clock; + u16 max_speed; + u16 current_speed; + u8 status; + u8 processor_upgrade; + u16 l1_cache_handle; + u16 l2_cache_handle; + u16 l3_cache_handle; + u8 serial_number_str_number; + u8 asset_tag_str_number; + u8 part_number_str_number; + u8 core_count; + u8 core_enabled; + u8 thread_count; + u16 processor_characteristics; + u16 processor_family2; + u16 core_count2; + u16 core_enabled2; + u16 thread_count2; +}; + +enum class ProcessorType { + Other = 0x1, + Unknown = 0x2, + Central_Processor = 0x3, + Math_Processor = 0x4, + DSP_Processor = 0x5, + Video_Processor = 0x6, +}; + +enum class ProcessorUpgrade { + Other = 0x1, + Unknown = 0x2, + Daughter_Board = 0x3, + ZIF_Socket = 0x4, + Replaceable_Piggy_Back = 0x5, + None = 0x6, + LIF_Sokcet = 0x7, + Slot_1 = 0x8, + Slot_2 = 0x9, + Socket_370_pin = 0xA, + Slot_A = 0xB, + Slot_M = 0xC, + Socket_423 = 0xD, + Socket_A_462 = 0xE, + Socket_478 = 0xF, + Socket_754 = 0x10, + Socket_940 = 0x11, + Socket_939 = 0x12, + Socket_mPGA604 = 0x13, + Socket_LGA771 = 0x14, + Socket_LGA775 = 0x15, + Socket_S1 = 0x16, + Socket_AM2 = 0x17, + Socket_F_1207 = 0x18, + Socket_LGA1366 = 0x19, + Socket_G34 = 0x1A, + Socket_AM3 = 0x1B, + Socket_C32 = 0x1C, + Socket_LGA1156 = 0x1D, + Socket_LGA1567 = 0x1E, + Socket_PGA988A = 0x1F, + Socket_BGA1288 = 0x20, + Socket_rPGA988B = 0x21, + Socket_BGA1023 = 0x22, + Socket_BGA1224 = 0x23, + Socket_LGA1155 = 0x24, + Socket_LGA1356 = 0x25, + Socket_LGA2011 = 0x26, + Socket_FS1 = 0x27, + Socket_FS2 = 0x28, + Socket_FM1 = 0x29, + Socket_FM2 = 0x2A, + Socket_LGA2011_3 = 0x2B, + Socket_LGA1356_3 = 0x2C, + Socket_LGA1150 = 0x2D, + Socket_BGA1168 = 0x2E, + Socket_BGA1234 = 0x2F, + Socket_BGA1364 = 0x30, + Socket_AM4 = 0x31, + Socket_LGA1151 = 0x32, + Socket_BGA1356 = 0x33, + Socket_BGA1440 = 0x34, + Socket_BGA1515 = 0x35, + Socket_LGA3647_1 = 0x36, + Socket_SP3 = 0x37, + Socket_SP3r2 = 0x38, + Socket_LGA2066 = 0x39, + Socket_BGA1392 = 0x3A, + Socket_BGA1510 = 0x3B, + Socket_BGA1528 = 0x3C +}; + +struct [[gnu::packed]] CacheInfo +{ // Type 7 + TableHeader h; + u8 socket_designation_str_number; + u16 cache_config; + u16 max_cache_size; + u16 installed_size; + u16 supported_sram_type; + u16 current_sram_type; + u8 cache_speed; + u8 error_correction_type; + u8 system_cache_type; + u8 associativity; + u32 max_cache_size2; + u32 installed_size2; +}; + +struct [[gnu::packed]] PortConnectorInfo +{ // Type 8 + TableHeader h; + u8 internal_reference_designator_str_number; + u8 internal_connector_type; + u8 external_reference_designator_str_number; + u8 external_connector_type; + u8 port_type; +}; + +enum class ConnectorType { + None = 0x0, + Centronics = 0x1, + Mini_Centronics = 0x2, + Proprietary = 0x3, + DB_25_pin_male = 0x4, + DB_25_pin_female = 0x5, + DB_15_pin_male = 0x6, + DB_15_pin_female = 0x7, + DB_9_pin_male = 0x8, + DB_9_pin_female = 0x9, + RJ_11 = 0xA, + RJ_45 = 0xB, + MiniSCSI_50_pin = 0xC, + MiniDIN = 0xD, + MicroDIN = 0xE, + PS2 = 0xF, + Infrared = 0x10, + HP_HIL = 0x11, + AccessBus_USB = 0x12, + SSA_SCSI = 0x13, + Circular_DIN8_male = 0x14, + Circular_DIN8_female = 0x15, + OnBoard_IDE = 0x16, + OnBoard_Floppy = 0x17, + Dual_Inline_9pin = 0x18, + Dual_Inline_25pin = 0x19, + Dual_Inline_50pin = 0x1A, + Dual_Inline_68pin = 0x1B, + OnBoard_SoundInput_CDROM = 0x1C, + Mini_Centronics_Type14 = 0x1D, + Mini_Centronics_Type26 = 0x1E, + Mini_Jack_Headphones = 0x1F, + BNC = 0x20, + Connector_1394 = 0x21, + SAS_SATA_Plug_Receptacle = 0x22, + USB_TypeC_Receptacle = 0x23, + PC98 = 0xA0, + PC98_Hireso = 0xA1, + PC_H98 = 0xA2, + PC98_Note = 0xA3, + PC98_Full = 0xA4, + Other = 0xFF +}; + +enum class PortType { + None = 0x0, + Parallel_Port_XT_AT_Compatible = 0x1, + Parallel_Port_PS2 = 0x2, + Parallel_Port_ECP = 0x3, + Parallel_Port_EPP = 0x4, + Parallel_Port_ECP_EPP = 0x5, + Serial_Port_XT_AT_Compatible = 0x6, + Serial_Port_16450_Compatible = 0x7, + Serial_Port_16550_Compatible = 0x8, + Serial_Port_16550A_Compatible = 0x9, + SCSI_Port = 0xA, + MIDI_Port = 0xB, + Joy_Stick_Port = 0xC, + Keyboard_Port = 0xD, + Mouse_Port = 0xE, + SSA_SCSI = 0xF, + USB = 0x10, + FireWire = 0x11, + PCMCIA_Type1 = 0x12, + PCMCIA_Type2 = 0x13, + PCMCIA_Type3 = 0x14, + Cardbus = 0x15, + AccessBus_Port = 0x16, + SCSI_2 = 0x17, + SCSI_Wide = 0x18, + PC98 = 0x19, + PC98_Hireso = 0x1A, + PC_H98 = 0x1B, + Video_Port = 0x1C, + Audio_Port = 0x1D, + Modem_Port = 0x1E, + Network_Port = 0x1F, + SATA = 0x20, + SAS = 0x21, + MFDP = 0x22, + Thunderbolt = 0x23, + Intel_8251_Compatible = 0xA0, + Intel_8251_FIFO_Compatible = 0xA1, + Other = 0xFF +}; + +struct [[gnu::packed]] SystemSlotPeerGroup +{ + u16 segment_group_number; + u8 bus_number; + u8 device_function_number; + u8 data_bus_width; +}; + +struct [[gnu::packed]] SystemSlots +{ // Type 9 + TableHeader h; + u8 slot_designation_str_number; + u8 slot_type; + u8 slot_data_bus_width; + u8 current_stage; + u8 slot_length; + u16 slot_id; + u8 slot_characteristics_1; + u8 slot_characteristics_2; + u16 segment_group_number; + u8 bus_number; + u8 device_function_number; + u8 data_bus_width; + u8 peer_grouping_count; + SystemSlotPeerGroup peer_groups[]; +}; + +enum class SlotType { + Other = 0x1, + Unknown = 0x2, + ISA = 0x3, + MCA = 0x4, + EISA = 0x5, + PCI = 0x6, + PCMCIA = 0x7, + VL_VESA = 0x8, + Proprietary = 0x9, + Processor_Card_Slot = 0xA, + Proprietary_Memory_Card_Slot = 0xB, + IO_Riser_Card_Slot = 0xC, + NuBus = 0xD, + PCI_66MHZ_Capable = 0xE, + AGP = 0xF, + AGP_2X = 0x10, + AGP_4X = 0x11, + PCI_X = 0x12, + AGP_8X = 0x13, + M_Dot_2_Socket_1_DP = 0x14, + M_Dot_2_Socket_1_SD = 0x15, + M_Dot_2_Socket_2 = 0x16, + M_Dot_2_Socket_3 = 0x17, + MXM_Type1 = 0x18, + MXM_Type2 = 0x19, + MXM_Type3_Standard = 0x1A, + MXM_Type3_HE = 0x1B, + MXM_Type4 = 0x1C, + MXM_3_Type_A = 0x1D, + MXM_3_Type_B = 0x1E, + PCI_Express_Gen2 = 0x1F, + PCI_Express_Gen3 = 0x20, + PCI_Express_Mini_52pin_Type1 = 0x21, + PCI_Express_Mini_52pin_Type2 = 0x22, + PCI_Express_Mini_76pin = 0x23, + CXL_Flexbus_1_0 = 0x30, + PC98_C20 = 0xA0, + PC98_C24 = 0xA1, + PC98_E = 0xA2, + PC98_Local_Bus = 0xA3, + PC98_Card = 0xA4, + PCI_Express = 0xA5, + PCI_Express_x1 = 0xA6, + PCI_Express_x2 = 0xA7, + PCI_Express_x4 = 0xA8, + PCI_Express_x8 = 0xA9, + PCI_Express_x16 = 0xAA, + PCI_Express_Gen_2 = 0xAB, + PCI_Express_Gen_2_x1 = 0xAC, + PCI_Express_Gen_2_x2 = 0xAD, + PCI_Express_Gen_2_x4 = 0xAE, + PCI_Express_Gen_2_x8 = 0xAF, + PCI_Express_Gen_2_x16 = 0xB0, + PCI_Express_Gen_3 = 0xB1, + PCI_Express_Gen_3_x1 = 0xB2, + PCI_Express_Gen_3_x2 = 0xB3, + PCI_Express_Gen_3_x4 = 0xB4, + PCI_Express_Gen_3_x8 = 0xB5, + PCI_Express_Gen_3_x16 = 0xB6, + PCI_Express_Gen_4 = 0xB8, + PCI_Express_Gen_4_x1 = 0xB9, + PCI_Express_Gen_4_x2 = 0xBA, + PCI_Express_Gen_4_x4 = 0xBB, + PCI_Express_Gen_4_x8 = 0xBC, + PCI_Express_Gen_4_x16 = 0xBD +}; + +enum class SlotDataBusWidth { + Other = 0x1, + Unknown = 0x2, + _8_bit = 0x3, + _16_bit = 0x4, + _32_bit = 0x5, + _64_bit = 0x6, + _128_bit = 0x7, + _1x_x1 = 0x8, + _2x_x2 = 0x9, + _4x_x4 = 0xA, + _8x_x8 = 0xB, + _12x_x12 = 0xC, + _16x_x16 = 0xD, + _32x_x32 = 0xE +}; + +enum class SlotCurrentUsage { + Other = 0x1, + Unknown = 0x2, + Available = 0x3, + In_Use = 0x4, + Unavailable = 0x5 +}; + +enum class SlotLength { + Other = 0x1, + Unknown = 0x2, + Short_Length = 0x3, + Long_Length = 0x4, + _2_5_Drive_Form_Factor = 0x5, + _3_5_Drive_Form_Factor = 0x6 +}; + +enum class SlotCharacteristics1 { + Unknown = (1 << 0), + Provides_5volt = (1 << 1), + Provides_3_3volt = (1 << 2), + Shared_Slot = (1 << 3), + Support_PC_Card_16 = (1 << 4), + Support_CardBus = (1 << 5), + Support_Zoom_Video = (1 << 6), + Support_Modem_Ring_Resume = (1 << 7) +}; + +enum class SlotCharacteristics2 { + Support_PCI_PME = (1 << 0), + Support_Hot_Plug = (1 << 1), + Support_SMBus = (1 << 2), + Support_Bifurcation = (1 << 3), +}; + +struct [[gnu::packed]] OEMStrings +{ // Type 11 + TableHeader h; + u8 strings_count; +}; + +struct [[gnu::packed]] SysConfigOptions +{ // Type 12 + TableHeader h; + u8 strings_count; +}; + +struct [[gnu::packed]] BIOSLanguageInfo +{ // Type 13 + TableHeader h; + u8 installable_langs_counts; + u8 flags; + u8 reserved[15]; + u8 current_lang_str_number; // String number (one-based) of the currently installed language +}; + +struct [[gnu::packed]] GroupAssociations +{ // Type 14 + TableHeader h; + u8 group_name_str_number; + u8 item_type; + u16 item_handle; +}; + +struct [[gnu::packed]] SysEventLog +{ // Type 15 + TableHeader h; + u16 log_area_length; + u16 log_header_start_offset; + u16 log_data_start_offset; + u8 access_method; + u8 log_status; + u32 log_change_token; + u32 access_method_address; + u8 log_header_format; + u8 supported_log_type_descriptors_count; + u8 log_type_descriptor_length; + u8 supported_event_log_type_descriptor_list[]; +}; + +struct [[gnu::packed]] PhysicalMemoryArray +{ // Type 16 + TableHeader h; + u8 location; + u8 use; + u8 memory_error_correction; + u32 max_capacity; + u16 memory_error_info_handle; + u16 memory_devices_count; + u64 ext_max_capacity; +}; + +enum class MemoryArrayLocation { + Other = 0x1, + Unknown = 0x2, + Motherboard = 0x3, + ISA_addon_card = 0x4, + EISA_addon_card = 0x5, + PCI_addon_card = 0x6, + MCA_addon_card = 0x7, + PCMCIA_addon_card = 0x8, + Proprietary_addon_card = 0x9, + NuBus = 0xA, + PC98_C20_addon_card = 0xA0, + PC98_C24_addon_card = 0xA1, + PC98_E_addon_card = 0xA2, + PC98_Local_Bus_addon_card = 0xA3, + CXL_Flexbus_1_0_addon_card = 0xA4 +}; + +enum class MemoryArrayUse { + Other = 0x1, + Unknown = 0x2, + System_Memory = 0x3, + Video_Memory = 0x4, + Flash_Memory = 0x5, + Non_Volatile_RAM = 0x6, + Cache_Memory = 0x7 +}; + +enum class MemoryArrayErrorCorrectionType { + Other = 0x1, + Unknown = 0x2, + None = 0x3, + Parity = 0x4, + SingleBit_ECC = 0x5, + MultiBit_ECC = 0x6, + CRC = 0x7 +}; + +struct [[gnu::packed]] MemoryDevice +{ // Type 17 + TableHeader h; + u16 physical_memory_array_handle; + u16 memory_error_info_handle; + u16 total_width; + u16 data_width; + u16 size; + u8 form_factor; + u8 device_set; + u8 device_locator_str_number; + u8 bank_locator_str_number; + u8 memory_type; + u16 type_detail; + u16 speed; + u8 manufacturer_str_number; + u8 serial_number_str_number; + u8 asset_tag_str_number; + u8 part_number_str_number; + u8 attributes; + u32 ext_size; + u16 configured_memory_speed; + u16 min_voltage; + u16 max_voltage; + u16 configured_voltage; + u8 memory_technology; + u16 memory_operating_mode_capability; + u8 firmware_version_str_number; + u16 module_manufacturer_id; + u16 module_product_id; + u16 memory_subsystem_controller_manufacturer_id; + u16 memory_subsystem_controller_product_id; + u64 non_volatile_size; + u64 volatile_size; + u64 cache_size; + u64 logical_size; + u32 ext_speed; + u32 ext_configured_memory_speed; +}; + +enum class MemoryDeviceFormFactor { + Other = 0x1, + Unknown = 0x2, + SIMM = 0x3, + SIP = 0x4, + Chip = 0x5, + DIP = 0x6, + ZIP = 0x7, + ProprietaryCard = 0x8, + DIMM = 0x9, + TSOP = 0xA, + Chips_Row = 0xB, + RIMM = 0xC, + SODIMM = 0xD, + SRIMM = 0xE, + FB_DIMM = 0xF, + Die = 0x10 +}; + +enum class MemoryDeviceType { + Other = 0x1, + Unknown = 0x2, + DRAM = 0x3, + EDRAM = 0x4, + VRAM = 0x5, + SRAM = 0x6, + RAM = 0x7, + ROM = 0x8, + FLASH = 0x9, + EEPROM = 0xA, + FEPROM = 0xB, + EPROM = 0xC, + CDRAM = 0xD, + _3DRAM = 0xE, + SDRAM = 0xF, + SGRAM = 0x10, + RDRAM = 0x11, + DDR = 0x12, + DDR2 = 0x13, + DDR2_FB_DIMM = 0x14, + DDR3 = 0x18, + FBD2 = 0x19, + DDR4 = 0x1A, + LPDDR = 0x1B, + LPDDR2 = 0x1C, + LPDDR3 = 0x1D, + LPDDR4 = 0x1E, + Logical_Non_Volatile_Device = 0x1F, + HBM = 0x20, // (High Bandwidth Memory) + HBM2 = 0x21, // (High Bandwidth Memory Generation 2) +}; + +enum class MemoryDeviceTypeDetail { + Other = (1 << 1), + Unknown = (1 << 2), + Fast_paged = (1 << 3), + Static_Column = (1 << 4), + Pseudo_Static = (1 << 5), + RAMBUS = (1 << 6), + Synchronous = (1 << 7), + CMOS = (1 << 8), + EDO = (1 << 9), + Window_DRAM = (1 << 10), + Cache_DRAM = (1 << 11), + Non_volatile = (1 << 12), + Registered_Buffered = (1 << 13), + Unbuffered_Unregistered = (1 << 14), + LRDIMM = (1 << 15) +}; + +enum class MemoryDeviceTechnology { + Other = 0x1, + Unknown = 0x2, + DRAM = 0x3, + NVDIMM_N = 0x4, + NVDIMM_F = 0x5, + NVDIMM_P = 0x6, + Intel_Optane_DC_Persistent_Memory = 0x7 +}; + +enum class MemoryDeviceOperatingModeCapability { + Other = (1 << 1), + Unknown = (1 << 2), + Volatile_Memory = (1 << 3), + Byte_accessible_persistent_memory = (1 << 4), + Block_accessible_persistent_memory = (1 << 5), +}; + +struct MemoryErrorInfo32Bit { // Type 18 + TableHeader h; + u8 error_type; + u8 error_granularity; + u8 error_operation; + u32 vendor_syndrome; + u32 memory_array_error_address; + u32 device_error_address; + u32 error_resolution; +}; + +enum class MemoryErrorType { + Other = 0x1, + Unknown = 0x2, + OK = 0x3, + Bad_read = 0x4, + Parity_error = 0x5, + SingleBit_error = 0x6, + DoubleBit_error = 0x7, + MultiBit_error = 0x8, + Nibble_error = 0x9, + Checksum_error = 0xA, + CRC_error = 0xB, + Corrected_SingleBit_error = 0xC, + Corrected_error = 0xD, + Uncorrectable_error = 0xE +}; + +enum class MemoryErrorGranularity { + Other = 0x1, + Unknown = 0x2, + Device_level = 0x3, + Memory_partition_level = 0x4 +}; + +enum class MemoryErrorOperation { + Other = 0x1, + Unknown = 0x2, + Read = 0x3, + Write = 0x4, + Partial_Write = 0x5 +}; + +struct [[gnu::packed]] MemoryArrayMappedAddress +{ // Type 19 + TableHeader h; + u32 starting_address; + u32 ending_address; + u16 memory_array_handle; + u8 partition_width; + u64 ext_starting_address; + u64 ext_ending_address; +}; + +struct [[gnu::packed]] MemoryDeviceMappedAddress +{ // Type 20 + TableHeader h; + u32 starting_address; + u32 ending_address; + u16 memory_device_handle; + u16 memory_array_mapped_handle; + u8 partition_row_position; + u8 interleave_position; + u8 interleaved_data_depth; + u64 ext_starting_address; + u64 ext_ending_address; +}; + +struct [[gnu::packed]] BuiltinPointingDevice +{ // Type 21 + TableHeader h; + u8 type; + u8 interface; + u8 buttons_count; +}; + +enum class PointingDeviceType { + Other = 0x1, + Unknown = 0x2, + Mouse = 0x3, + Track_Ball = 0x4, + Track_Point = 0x5, + Glide_Point = 0x6, + Touch_Pad = 0x7, + Touch_Screen = 0x8, + Optical_Sensor = 0x9 +}; + +enum class PointingDeviceInterface { + Other = 0x1, + Unknown = 0x2, + Serial = 0x3, + PS2 = 0x4, + Infrared = 0x5, + HP_HIL = 0x6, + Bus_mouse = 0x7, + AppleDesktopBus = 0x8, + Bus_mouse_DB9 = 0xA0, + Bus_mouse_microDIN = 0xA1, + USB = 0xA2 +}; + +struct [[gnu::packed]] PortableBattery +{ // Type 22 + TableHeader h; + u8 location_str_number; + u8 manufacturer_str_number; + u8 manufacture_date_str_number; + u8 serial_number_str_number; + u8 device_name_str_number; + u8 device_chemistry; + u16 design_capacity; + u16 design_voltage; + u8 sbds_version_number; + u8 max_error_battery_data; + u16 sbds_serial_number; + u16 sbds_manufacture_date; + u8 sbds_device_chemistry_str_number; + u8 design_capacity_multiplier; + u32 oem_specific; +}; + +enum class PortableBatteryChemistry { + Other = 0x1, + Unknown = 0x2, + Lead_Acid = 0x3, + Nickel_Cadmium = 0x4, + Nickel_metal_hydride = 0x5, + Lithium_ion = 0x6, + Zinc_air = 0x7, + Lithium_polymer = 0x8 +}; + +struct [[gnu::packed]] SysReset +{ // Type 23 + TableHeader h; + u8 capabilities; + u16 reset_count; + u16 reset_limit; + u16 timer_interval; + u16 timeout; +}; + +struct [[gnu::packed]] HardwareSecurity +{ // Type 24 + TableHeader h; + u8 hardware_security_settings; +}; + +struct [[gnu::packed]] SysPowerControls +{ // Type 25 + TableHeader h; + u8 next_scheduled_power_on_month; + u8 next_scheduled_power_on_day_of_month; + u8 next_scheduled_power_on_hour; + u8 next_scheduled_power_on_minute; + u8 next_scheduled_power_on_second; +}; + +struct [[gnu::packed]] VoltageProbe +{ // Type 26 + TableHeader h; + u8 description_str_number; + u8 location_and_status; + u16 max_value; + u16 min_value; + u16 resolution; + u16 tolerance; + u16 accuracy; + u32 oem_defined; + u16 nominal_value; +}; + +struct [[gnu::packed]] CoolingDevice +{ // Type 27 + TableHeader h; + u16 temperature_probe_handle; + u8 device_type_and_status; + u8 cooling_unit_group; + u32 oem_defined; + u16 nominal_speed; + u8 description_str_number; +}; + +struct [[gnu::packed]] TemperatureProbe +{ // Type 28 + TableHeader h; + u8 description_str_number; + u8 location_and_status; + u16 max_value; + u16 min_value; + u16 resolution; + u16 tolerance; + u16 accuracy; + u32 oem_defined; + u16 nominal_value; +}; + +struct [[gnu::packed]] ElectricalCurrentProbe +{ // Type 29 + TableHeader h; + u8 description_str_number; + u8 location_and_status; + u16 max_value; + u16 min_value; + u16 resolution; + u16 tolerance; + u16 accuracy; + u32 oem_defined; + u16 nominal_value; +}; + +struct [[gnu::packed]] OutOfBandRemoteAccess +{ // Type 30 + TableHeader h; + u8 manufacturer_name_str_number; + u8 connections; +}; + +struct [[gnu::packed]] SystemBootInfo +{ // Type 32 + TableHeader h; + u8 reserved[6]; + u8 boot_status[10]; +}; + +struct [[gnu::packed]] MemoryErrorInfo64Bit +{ // Type 33 + TableHeader h; + u8 error_type; + u8 error_granularity; + u8 error_operation; + u32 vendor_syndrome; + u64 memory_array_error_address; + u64 device_error_address; + u32 error_resolution; +}; + +struct [[gnu::packed]] ManagementDevice +{ // Type 34 + TableHeader h; + u8 description_str_number; + u8 type; + u32 address; + u8 address_type; +}; + +enum class ManagementDeviceType { + Other = 0x1, + Unknown = 0x2, + LM75 = 0x3, + LM78 = 0x4, + LM79 = 0x5, + LM80 = 0x6, + LM81 = 0x7, + ADM9240 = 0x8, + DS1780 = 0x9, + Maxim_1617 = 0xA, + GL518SM = 0xB, // Genesys GL518SM + W83781D = 0xC, // Winbond W83781D + HT82H791 = 0xD // Holtek HT82H791 +}; + +enum class ManagementDeviceAddressType { + Other = 0x1, + Unknown = 0x2, + IO_Port = 0x3, + Memory = 0x4, + SMBus = 0x5 +}; + +struct [[gnu::packed]] ManagementDeviceComponent +{ // Type 35 + TableHeader h; + u8 description_str_number; + u16 management_device_handle; + u16 component_handle; + u16 threshold_handle; +}; + +struct [[gnu::packed]] ManagementDeviceThresholdData +{ // Type 36 + TableHeader h; + u16 lower_threshold_non_critical; + u16 upper_threshold_non_critical; + u16 lower_threshold_critical; + u16 upper_threshold_critical; + u16 lower_threshold_non_recoverable; + u16 upper_threshold_non_recoverable; +}; + +struct [[gnu::packed]] MemoryDeviceDescriptor +{ + u8 device_load; + u16 device_handle; +}; + +struct [[gnu::packed]] MemoryChannel +{ // Type 37 + TableHeader h; + u8 channel_type; + u8 memory_device_count; + MemoryDeviceDescriptor memory_devices_descriptors[]; +}; + +enum class MemroryChannelType { + Other = 0x1, + Unknown = 0x2, + RamBus = 0x3, + SyncLink = 0x4 +}; + +struct [[gnu::packed]] IPMIDeviceInfo +{ // Type 38 + TableHeader h; + u8 interface_type; + u8 ipmi_spec_revision; + u8 i2c_slave_address; + u8 nv_storage_device_address; + u64 base_address; + u8 base_address_modifier; + u8 interrupt_number; +}; + +enum class IPMIDeviceInfoBMCInterfaceType { + Unknown = 0x1, + KCS = 0x2, // KCS: Keyboard Controller Style + SMIC = 0x3, // SMIC: Server Management Interface Chip + BT = 0x4, // BT: Block Transfer + SSIF = 0x5 // SSIF: SMBus System Interface +}; + +struct [[gnu::packed]] SysPowerSupply +{ // Type 39 + TableHeader h; + u8 power_unit_group; + u8 location_str_number; + u8 device_name_str_number; + u8 manufacturer_str_number; + u8 serial_number_str_number; + u8 asset_tag_number_str_number; + u8 model_part_number_str_number; + u8 revision_level_str_number; + u16 max_power_capacity; + u16 power_supply_characteristics; + u16 input_voltage_probe_handle; + u16 cooling_device_handle; + u16 input_current_probe_handle; +}; + +struct [[gnu::packed]] AdditionalInfoEntry +{ + u8 entry_length; + u16 referenced_handle; + u8 referenced_offset; + u8 string_number; + u8 value[]; +}; + +struct [[gnu::packed]] AdditionalInfo +{ // Type 40 + TableHeader h; + u8 additional_info_entries_count; + AdditionalInfoEntry entries[]; +}; + +struct [[gnu::packed]] OnboardDevicesExtendedInfo +{ // Type 41 + TableHeader h; + u8 reference_designation_str_number; + u8 device_type; + u8 device_type_instance; + u16 segment_group_number; + u8 bus_number; + u8 device_function_number; +}; + +enum class OnboardDeviceType { + Other = 0x1, + Unknown = 0x2, + Video = 0x3, + SCSI_Controller = 0x4, + Ethernet = 0x5, + Token_Ring = 0x6, + Sound = 0x7, + PATA_Controller = 0x8, + SATA_Controller = 0x9, + SAS_Controller = 0xA +}; + +struct [[gnu::packed]] ManagementControllerHostInterface +{ // Type 42 + TableHeader h; + u8 interface_type; + u8 interface_type_specific_data_length; + u8 interface_type_specific_data[]; +}; + +struct [[gnu::packed]] ProtocolRecordData +{ + u8 protocol_type; + u8 protocol_type_specific_data_length; + u8 protocol_type_specific_data[]; +}; + +struct [[gnu::packed]] ExtManagementControllerHostInterface +{ // Type 42 Ext + u8 protocol_records_count; + ProtocolRecordData protocol_records[]; +}; + +enum class ManagementControllerHostInterfaceProtocolType { + IPMI = 0x2, + MCTP = 0x3, + RedfishOverIP = 0x4 +}; + +struct [[gnu::packed]] TPMDevice +{ // Type 43 + TableHeader h; + char vendor_id[4]; + u8 major_spec_version; + u8 minor_spec_version; + u32 firmware_version_1; + u32 firmware_version_2; + u8 description_str_number; + u64 characteristics; + u32 oem_defined; +}; + +enum class TPMDeviceCharacteristics { + Characteristics_not_supported = (1 << 2), + Family_Configurable_1 = (1 << 3), // Family configurable via firmware update; for example, switching between TPM 1.2 and TPM 2.0. + Family_Configurable_2 = (1 << 4), // Family configurable via platform software support, such as BIOS Setup; for example, switching between TPM 1.2 and TPM 2.0. + Family_Configurable_3 = (1 << 5), // Family configurable via OEM proprietary mechanism; for example, switching between TPM 1.2 and TPM 2.0. +}; + +struct [[gnu::packed]] ProcessorSpecificBlock +{ + u8 block_length; + u8 processor_type; + u8 processor_specific_data[]; +}; + +struct [[gnu::packed]] ProcessorAdditionalInfo +{ // Type 44 + TableHeader h; + u16 referenced_handle; + ProcessorSpecificBlock blocks[]; +}; + +enum class ProcessorArchitectureType { + IA32 = 0x1, + x86_64 = 0x2, + Itanium = 0x3, + ARM32bit = 0x4, + ARM64bit = 0x5, + RISC_V_32bit = 0x6, + RISC_V_64bit = 0x7, + RISC_V_128bit = 0x8 +}; + +struct [[gnu::packed]] Inactive +{ // Type 126 + TableHeader h; +}; + +struct [[gnu::packed]] EndOfTable +{ // Type 127 + TableHeader h; +}; } class DMIDecoder { diff --git a/Kernel/ACPI/Definitions.h b/Kernel/ACPI/Definitions.h index 0113dfafa3..e2cefe532d 100644 --- a/Kernel/ACPI/Definitions.h +++ b/Kernel/ACPI/Definitions.h @@ -35,315 +35,315 @@ namespace Kernel { namespace ACPI { - namespace FADTFlags { - enum class FeatureFlags : u32 { - WBINVD = 1 << 0, - WBINVD_FLUSH = 1 << 1, - PROC_C1 = 1 << 2, - P_LVL2_UP = 1 << 3, - PWR_BUTTON = 1 << 4, - SLP_BUTTON = 1 << 5, - FIX_RTC = 1 << 6, - RTC_s4 = 1 << 7, - TMR_VAL_EXT = 1 << 8, - DCK_CAP = 1 << 9, - RESET_REG_SUPPORTED = 1 << 10, - SEALED_CASE = 1 << 11, - HEADLESS = 1 << 12, - CPU_SW_SLP = 1 << 13, - PCI_EXP_WAK = 1 << 14, - USE_PLATFORM_CLOCK = 1 << 15, - S4_RTC_STS_VALID = 1 << 16, - REMOTE_POWER_ON_CAPABLE = 1 << 17, - FORCE_APIC_CLUSTER_MODEL = 1 << 18, - FORCE_APIC_PHYSICAL_DESTINATION_MODE = 1 << 19, - HW_REDUCED_ACPI = 1 << 20, - LOW_POWER_S0_IDLE_CAPABLE = 1 << 21 - }; +namespace FADTFlags { +enum class FeatureFlags : u32 { + WBINVD = 1 << 0, + WBINVD_FLUSH = 1 << 1, + PROC_C1 = 1 << 2, + P_LVL2_UP = 1 << 3, + PWR_BUTTON = 1 << 4, + SLP_BUTTON = 1 << 5, + FIX_RTC = 1 << 6, + RTC_s4 = 1 << 7, + TMR_VAL_EXT = 1 << 8, + DCK_CAP = 1 << 9, + RESET_REG_SUPPORTED = 1 << 10, + SEALED_CASE = 1 << 11, + HEADLESS = 1 << 12, + CPU_SW_SLP = 1 << 13, + PCI_EXP_WAK = 1 << 14, + USE_PLATFORM_CLOCK = 1 << 15, + S4_RTC_STS_VALID = 1 << 16, + REMOTE_POWER_ON_CAPABLE = 1 << 17, + FORCE_APIC_CLUSTER_MODEL = 1 << 18, + FORCE_APIC_PHYSICAL_DESTINATION_MODE = 1 << 19, + HW_REDUCED_ACPI = 1 << 20, + LOW_POWER_S0_IDLE_CAPABLE = 1 << 21 +}; - enum class IA_PC_Flags : u8 { - Legacy_Devices = 1 << 0, - PS2_8042 = 1 << 1, - VGA_Not_Present = 1 << 2, - MSI_Not_Supported = 1 << 3, - PCIe_ASPM_Controls = 1 << 4, - CMOS_RTC_Not_Present = 1 << 5 - }; +enum class IA_PC_Flags : u8 { + Legacy_Devices = 1 << 0, + PS2_8042 = 1 << 1, + VGA_Not_Present = 1 << 2, + MSI_Not_Supported = 1 << 3, + PCIe_ASPM_Controls = 1 << 4, + CMOS_RTC_Not_Present = 1 << 5 +}; - struct [[gnu::packed]] HardwareFeatures - { - bool wbinvd : 1; - bool wbinvd_flush : 1; - bool processor_c1 : 1; - bool multiprocessor_c2 : 1; - bool power_button : 1; - bool sleep_button : 1; - bool fix_rtc : 1; - bool rtc_s4 : 1; - bool timer_value_extension : 1; - bool docking_capability : 1; - bool reset_register_supported : 1; - bool sealed_case : 1; - bool headless : 1; - bool cpu_software_sleep : 1; - bool pci_express_wake : 1; - bool use_platform_clock : 1; - bool s4_rtc_status_valid : 1; - bool remote_power_on_capable : 1; - bool force_apic_cluster_model : 1; - bool force_apic_physical_destination_mode : 1; - bool hardware_reduced_acpi : 1; - bool low_power_s0_idle_capable : 1; - }; - struct [[gnu::packed]] x86_Specific_Flags - { - bool legacy_devices : 1; - bool keyboard_8042 : 1; - bool vga_not_present : 1; - bool msi_not_supported : 1; - bool cmos_rtc_not_present : 1; - }; - }; +struct [[gnu::packed]] HardwareFeatures +{ + bool wbinvd : 1; + bool wbinvd_flush : 1; + bool processor_c1 : 1; + bool multiprocessor_c2 : 1; + bool power_button : 1; + bool sleep_button : 1; + bool fix_rtc : 1; + bool rtc_s4 : 1; + bool timer_value_extension : 1; + bool docking_capability : 1; + bool reset_register_supported : 1; + bool sealed_case : 1; + bool headless : 1; + bool cpu_software_sleep : 1; + bool pci_express_wake : 1; + bool use_platform_clock : 1; + bool s4_rtc_status_valid : 1; + bool remote_power_on_capable : 1; + bool force_apic_cluster_model : 1; + bool force_apic_physical_destination_mode : 1; + bool hardware_reduced_acpi : 1; + bool low_power_s0_idle_capable : 1; +}; +struct [[gnu::packed]] x86_Specific_Flags +{ + bool legacy_devices : 1; + bool keyboard_8042 : 1; + bool vga_not_present : 1; + bool msi_not_supported : 1; + bool cmos_rtc_not_present : 1; +}; +}; - namespace GenericAddressStructure { - enum class AddressSpace { - SystemMemory = 0, - SystemIO = 1, - PCIConfigurationSpace = 2, - EmbeddedController = 3, - SMBus = 4, - PCC = 0xA, - FunctionalFixedHardware = 0x7F - }; - enum class AccessSize { - Undefined = 0, - Byte = 1, - Word = 2, - DWord = 3, - QWord = 4 - }; - enum class BitWidth { - Undefined = 0, - Byte = 8, - Word = 16, - DWord = 32, - QWord = 64 - }; - } +namespace GenericAddressStructure { +enum class AddressSpace { + SystemMemory = 0, + SystemIO = 1, + PCIConfigurationSpace = 2, + EmbeddedController = 3, + SMBus = 4, + PCC = 0xA, + FunctionalFixedHardware = 0x7F +}; +enum class AccessSize { + Undefined = 0, + Byte = 1, + Word = 2, + DWord = 3, + QWord = 4 +}; +enum class BitWidth { + Undefined = 0, + Byte = 8, + Word = 16, + DWord = 32, + QWord = 64 +}; +} - namespace Structures { - struct [[gnu::packed]] RSDPDescriptor - { - char sig[8]; - u8 checksum; - char oem_id[6]; - u8 revision; - u32 rsdt_ptr; - }; +namespace Structures { +struct [[gnu::packed]] RSDPDescriptor +{ + char sig[8]; + u8 checksum; + char oem_id[6]; + u8 revision; + u32 rsdt_ptr; +}; - struct [[gnu::packed]] RSDPDescriptor20 - { - RSDPDescriptor base; - u32 length; - u64 xsdt_ptr; - u8 ext_checksum; - u8 reserved[3]; - }; +struct [[gnu::packed]] RSDPDescriptor20 +{ + RSDPDescriptor base; + u32 length; + u64 xsdt_ptr; + u8 ext_checksum; + u8 reserved[3]; +}; - struct [[gnu::packed]] SDTHeader - { - char sig[4]; - u32 length; - u8 revision; - u8 checksum; - char oem_id[6]; - char oem_table_id[8]; - u32 oem_revision; - u32 creator_id; - u32 creator_revision; - }; +struct [[gnu::packed]] SDTHeader +{ + char sig[4]; + u32 length; + u8 revision; + u8 checksum; + char oem_id[6]; + char oem_table_id[8]; + u32 oem_revision; + u32 creator_id; + u32 creator_revision; +}; - struct [[gnu::packed]] RSDT - { - SDTHeader h; - u32 table_ptrs[]; - }; +struct [[gnu::packed]] RSDT +{ + SDTHeader h; + u32 table_ptrs[]; +}; - struct [[gnu::packed]] XSDT - { - SDTHeader h; - u64 table_ptrs[]; - }; +struct [[gnu::packed]] XSDT +{ + SDTHeader h; + u64 table_ptrs[]; +}; - struct [[gnu::packed]] GenericAddressStructure - { - u8 address_space; - u8 bit_width; - u8 bit_offset; - u8 access_size; - u64 address; - }; +struct [[gnu::packed]] GenericAddressStructure +{ + u8 address_space; + u8 bit_width; + u8 bit_offset; + u8 access_size; + u64 address; +}; - struct [[gnu::packed]] HPET - { - SDTHeader h; - u8 hardware_revision_id; - u8 attributes; - u16 pci_vendor_id; - GenericAddressStructure event_timer_block; - u8 hpet_number; - u16 mininum_clock_tick; - u8 page_protection; - }; +struct [[gnu::packed]] HPET +{ + SDTHeader h; + u8 hardware_revision_id; + u8 attributes; + u16 pci_vendor_id; + GenericAddressStructure event_timer_block; + u8 hpet_number; + u16 mininum_clock_tick; + u8 page_protection; +}; - struct [[gnu::packed]] FADT - { - SDTHeader h; - u32 firmware_ctrl; - u32 dsdt_ptr; - u8 reserved; - u8 preferred_pm_profile; - u16 sci_int; - u32 smi_cmd; - u8 acpi_enable_value; - u8 acpi_disable_value; - u8 s4bios_req; - u8 pstate_cnt; - u32 PM1a_EVT_BLK; - u32 PM1b_EVT_BLK; - u32 PM1a_CNT_BLK; - u32 PM1b_CNT_BLK; - u32 PM2_CNT_BLK; - u32 PM_TMR_BLK; - u32 GPE0_BLK; - u32 GPE1_BLK; - u8 PM1_EVT_LEN; - u8 PM1_CNT_LEN; - u8 PM2_CNT_LEN; - u8 PM_TMR_LEN; - u8 GPE0_BLK_LEN; - u8 GPE1_BLK_LEN; - u8 GPE1_BASE; - u8 cst_cnt; - u16 P_LVL2_LAT; - u16 P_LVL3_LAT; - u16 flush_size; - u16 flush_stride; - u8 duty_offset; - u8 duty_width; - u8 day_alrm; - u8 mon_alrm; - u8 century; - u16 ia_pc_boot_arch_flags; - u8 reserved2; - u32 flags; - GenericAddressStructure reset_reg; - u8 reset_value; - u16 arm_boot_arch; - u8 fadt_minor_version; - u64 x_firmware_ctrl; - u64 x_dsdt; - GenericAddressStructure x_pm1a_evt_blk; - GenericAddressStructure x_pm1b_evt_blk; - GenericAddressStructure x_pm1a_cnt_blk; - GenericAddressStructure x_pm1b_cnt_blk; - GenericAddressStructure x_pm2_cnt_blk; - GenericAddressStructure x_pm_tmr_blk; - GenericAddressStructure x_gpe0_blk; - GenericAddressStructure x_gpe1_blk; - GenericAddressStructure sleep_control; - GenericAddressStructure sleep_status; - u64 hypervisor_vendor_identity; - }; - enum class MADTEntryType { - LocalAPIC = 0x0, - IOAPIC = 0x1, - InterruptSourceOverride = 0x2, - NMI_Source = 0x3, - LocalAPIC_NMI = 0x4, - LocalAPIC_Address_Override = 0x5, - IO_SAPIC = 0x6, - Local_SAPIC = 0x7, - Platform_interrupt_Sources = 0x8, - Local_x2APIC = 0x9, - Local_x2APIC_NMI = 0xA, - GIC_CPU = 0xB, - GIC_Distributor = 0xC, - GIC_MSI = 0xD, - GIC_Redistrbutor = 0xE, - GIC_Interrupt_Translation = 0xF - }; +struct [[gnu::packed]] FADT +{ + SDTHeader h; + u32 firmware_ctrl; + u32 dsdt_ptr; + u8 reserved; + u8 preferred_pm_profile; + u16 sci_int; + u32 smi_cmd; + u8 acpi_enable_value; + u8 acpi_disable_value; + u8 s4bios_req; + u8 pstate_cnt; + u32 PM1a_EVT_BLK; + u32 PM1b_EVT_BLK; + u32 PM1a_CNT_BLK; + u32 PM1b_CNT_BLK; + u32 PM2_CNT_BLK; + u32 PM_TMR_BLK; + u32 GPE0_BLK; + u32 GPE1_BLK; + u8 PM1_EVT_LEN; + u8 PM1_CNT_LEN; + u8 PM2_CNT_LEN; + u8 PM_TMR_LEN; + u8 GPE0_BLK_LEN; + u8 GPE1_BLK_LEN; + u8 GPE1_BASE; + u8 cst_cnt; + u16 P_LVL2_LAT; + u16 P_LVL3_LAT; + u16 flush_size; + u16 flush_stride; + u8 duty_offset; + u8 duty_width; + u8 day_alrm; + u8 mon_alrm; + u8 century; + u16 ia_pc_boot_arch_flags; + u8 reserved2; + u32 flags; + GenericAddressStructure reset_reg; + u8 reset_value; + u16 arm_boot_arch; + u8 fadt_minor_version; + u64 x_firmware_ctrl; + u64 x_dsdt; + GenericAddressStructure x_pm1a_evt_blk; + GenericAddressStructure x_pm1b_evt_blk; + GenericAddressStructure x_pm1a_cnt_blk; + GenericAddressStructure x_pm1b_cnt_blk; + GenericAddressStructure x_pm2_cnt_blk; + GenericAddressStructure x_pm_tmr_blk; + GenericAddressStructure x_gpe0_blk; + GenericAddressStructure x_gpe1_blk; + GenericAddressStructure sleep_control; + GenericAddressStructure sleep_status; + u64 hypervisor_vendor_identity; +}; +enum class MADTEntryType { + LocalAPIC = 0x0, + IOAPIC = 0x1, + InterruptSourceOverride = 0x2, + NMI_Source = 0x3, + LocalAPIC_NMI = 0x4, + LocalAPIC_Address_Override = 0x5, + IO_SAPIC = 0x6, + Local_SAPIC = 0x7, + Platform_interrupt_Sources = 0x8, + Local_x2APIC = 0x9, + Local_x2APIC_NMI = 0xA, + GIC_CPU = 0xB, + GIC_Distributor = 0xC, + GIC_MSI = 0xD, + GIC_Redistrbutor = 0xE, + GIC_Interrupt_Translation = 0xF +}; - struct [[gnu::packed]] MADTEntryHeader - { - u8 type; - u8 length; - }; +struct [[gnu::packed]] MADTEntryHeader +{ + u8 type; + u8 length; +}; - namespace MADTEntries { - struct [[gnu::packed]] IOAPIC - { - MADTEntryHeader h; - u8 ioapic_id; - u8 reserved; - u32 ioapic_address; - u32 gsi_base; - }; +namespace MADTEntries { +struct [[gnu::packed]] IOAPIC +{ + MADTEntryHeader h; + u8 ioapic_id; + u8 reserved; + u32 ioapic_address; + u32 gsi_base; +}; - struct [[gnu::packed]] InterruptSourceOverride - { - MADTEntryHeader h; - u8 bus; - u8 source; - u32 global_system_interrupt; - u16 flags; - }; - } +struct [[gnu::packed]] InterruptSourceOverride +{ + MADTEntryHeader h; + u8 bus; + u8 source; + u32 global_system_interrupt; + u16 flags; +}; +} - struct [[gnu::packed]] MADT - { - SDTHeader h; - u32 lapic_address; - u32 flags; - MADTEntryHeader entries[]; - }; +struct [[gnu::packed]] MADT +{ + SDTHeader h; + u32 lapic_address; + u32 flags; + MADTEntryHeader entries[]; +}; - struct [[gnu::packed]] AMLTable - { - SDTHeader h; - char aml_code[]; - }; +struct [[gnu::packed]] AMLTable +{ + SDTHeader h; + char aml_code[]; +}; - struct [[gnu::packed]] PCI_MMIO_Descriptor - { - u64 base_addr; - u16 seg_group_number; - u8 start_pci_bus; - u8 end_pci_bus; - u32 reserved; - }; +struct [[gnu::packed]] PCI_MMIO_Descriptor +{ + u64 base_addr; + u16 seg_group_number; + u8 start_pci_bus; + u8 end_pci_bus; + u32 reserved; +}; - struct [[gnu::packed]] MCFG - { - SDTHeader header; - u64 reserved; - PCI_MMIO_Descriptor descriptors[]; - }; - } +struct [[gnu::packed]] MCFG +{ + SDTHeader header; + u64 reserved; + PCI_MMIO_Descriptor descriptors[]; +}; +} - class StaticParser; - class DynamicParser; - class Parser; +class StaticParser; +class DynamicParser; +class Parser; - namespace StaticParsing { - PhysicalAddress search_rsdp_in_ebda(u16 ebda_segment); - PhysicalAddress search_rsdp_in_bios_area(); - PhysicalAddress search_rsdp(); - bool match_table_signature(PhysicalAddress table_header, const char*); - PhysicalAddress search_table(PhysicalAddress rsdp, const char*); - PhysicalAddress search_table_in_xsdt(PhysicalAddress xsdt, const char*); - PhysicalAddress search_table_in_rsdt(PhysicalAddress rsdt, const char*); - inline bool validate_table(Structures::SDTHeader&, size_t length); - }; +namespace StaticParsing { +PhysicalAddress search_rsdp_in_ebda(u16 ebda_segment); +PhysicalAddress search_rsdp_in_bios_area(); +PhysicalAddress search_rsdp(); +bool match_table_signature(PhysicalAddress table_header, const char*); +PhysicalAddress search_table(PhysicalAddress rsdp, const char*); +PhysicalAddress search_table_in_xsdt(PhysicalAddress xsdt, const char*); +PhysicalAddress search_table_in_rsdt(PhysicalAddress rsdt, const char*); +inline bool validate_table(Structures::SDTHeader&, size_t length); +}; } } diff --git a/Kernel/ACPI/MultiProcessorParser.h b/Kernel/ACPI/MultiProcessorParser.h index 1d035f749d..1acbe610e4 100644 --- a/Kernel/ACPI/MultiProcessorParser.h +++ b/Kernel/ACPI/MultiProcessorParser.h @@ -34,156 +34,156 @@ namespace Kernel { namespace MultiProcessor { - struct [[gnu::packed]] FloatingPointer - { - char sig[4]; - u32 physical_address_ptr; - u8 length; - u8 specification_revision; - u8 checksum; - u8 feature_info[5]; - }; - - struct [[gnu::packed]] EntryHeader - { - u8 entry_type; - }; - - struct [[gnu::packed]] ConfigurationTableHeader - { - char sig[4]; - u16 length; - u8 specification_revision; - u8 checksum; - char oem_id[8]; - char product_id[12]; - u32 oem_table_ptr; - u16 oem_table_size; - u16 entry_count; - u32 local_apic_address; - u16 ext_table_length; - u8 ext_table_checksum; - u8 reserved; - EntryHeader entries[]; - }; - - enum class ConfigurationTableEntryType { - Processor = 0, - Bus = 1, - IOAPIC = 2, - IO_Interrupt_Assignment = 3, - Local_Interrupt_Assignment = 4, - SystemAddressSpaceMapping = 128, - BusHierarchyDescriptor = 129, - CompatibilityBusAddressSpaceModifier = 130 - }; - - enum class ConfigurationTableEntryLength { - Processor = 20, - Bus = 8, - IOAPIC = 8, - IO_Interrupt_Assignment = 8, - Local_Interrupt_Assignment = 8, - SystemAddressSpaceMapping = 20, - BusHierarchyDescriptor = 8, - CompatibilityBusAddressSpaceModifier = 8 - }; - - struct [[gnu::packed]] ExtEntryHeader - { - u8 entry_type; - u8 entry_length; - }; - - struct [[gnu::packed]] ProcessorEntry - { - EntryHeader h; - u8 local_apic_id; - u8 local_apic_version; - u8 cpu_flags; - u32 cpu_signature; - u32 feature_flags; - u8 reserved[8]; - }; - - struct [[gnu::packed]] BusEntry - { - EntryHeader h; - u8 bus_id; - char bus_type[6]; - }; - - struct [[gnu::packed]] IOAPICEntry - { - EntryHeader h; - u8 ioapic_id; - u8 ioapic_version; - u8 ioapic_flags; - u32 ioapic_address; - }; - - enum class InterruptType { - INT = 0, - NMI = 1, - SMI = 2, - ExtINT = 3, - }; - - struct [[gnu::packed]] IOInterruptAssignmentEntry - { - EntryHeader h; - u8 interrupt_type; - u8 polarity; - u8 trigger_mode; - u8 source_bus_id; - u8 source_bus_irq; - u8 destination_ioapic_id; - u8 destination_ioapic_intin_pin; - }; - - struct [[gnu::packed]] LocalInterruptAssignmentEntry - { - EntryHeader h; - u8 interrupt_type; - u8 polarity; - u8 trigger_mode; - u8 source_bus_id; - u8 source_bus_irq; - u8 destination_lapic_id; - u8 destination_lapic_lintin_pin; - }; - - enum class SystemAddressType { - IO = 0, - Memory = 1, - Prefetch = 2, - }; - - struct [[gnu::packed]] SystemAddressSpaceMappingEntry - { - ExtEntryHeader h; - u8 bus_id; - u8 address_type; - u64 address_base; - u64 length; - }; - - struct [[gnu::packed]] BusHierarchyDescriptorEntry - { - ExtEntryHeader h; - u8 bus_id; - u8 bus_info; - u8 parent_bus; - u8 reserved[3]; - }; - - struct [[gnu::packed]] CompatibilityBusAddressSpaceModifierEntry - { - ExtEntryHeader h; - u8 bus_id; - u8 address_modifier; - u32 predefined_range_list; - }; +struct [[gnu::packed]] FloatingPointer +{ + char sig[4]; + u32 physical_address_ptr; + u8 length; + u8 specification_revision; + u8 checksum; + u8 feature_info[5]; +}; + +struct [[gnu::packed]] EntryHeader +{ + u8 entry_type; +}; + +struct [[gnu::packed]] ConfigurationTableHeader +{ + char sig[4]; + u16 length; + u8 specification_revision; + u8 checksum; + char oem_id[8]; + char product_id[12]; + u32 oem_table_ptr; + u16 oem_table_size; + u16 entry_count; + u32 local_apic_address; + u16 ext_table_length; + u8 ext_table_checksum; + u8 reserved; + EntryHeader entries[]; +}; + +enum class ConfigurationTableEntryType { + Processor = 0, + Bus = 1, + IOAPIC = 2, + IO_Interrupt_Assignment = 3, + Local_Interrupt_Assignment = 4, + SystemAddressSpaceMapping = 128, + BusHierarchyDescriptor = 129, + CompatibilityBusAddressSpaceModifier = 130 +}; + +enum class ConfigurationTableEntryLength { + Processor = 20, + Bus = 8, + IOAPIC = 8, + IO_Interrupt_Assignment = 8, + Local_Interrupt_Assignment = 8, + SystemAddressSpaceMapping = 20, + BusHierarchyDescriptor = 8, + CompatibilityBusAddressSpaceModifier = 8 +}; + +struct [[gnu::packed]] ExtEntryHeader +{ + u8 entry_type; + u8 entry_length; +}; + +struct [[gnu::packed]] ProcessorEntry +{ + EntryHeader h; + u8 local_apic_id; + u8 local_apic_version; + u8 cpu_flags; + u32 cpu_signature; + u32 feature_flags; + u8 reserved[8]; +}; + +struct [[gnu::packed]] BusEntry +{ + EntryHeader h; + u8 bus_id; + char bus_type[6]; +}; + +struct [[gnu::packed]] IOAPICEntry +{ + EntryHeader h; + u8 ioapic_id; + u8 ioapic_version; + u8 ioapic_flags; + u32 ioapic_address; +}; + +enum class InterruptType { + INT = 0, + NMI = 1, + SMI = 2, + ExtINT = 3, +}; + +struct [[gnu::packed]] IOInterruptAssignmentEntry +{ + EntryHeader h; + u8 interrupt_type; + u8 polarity; + u8 trigger_mode; + u8 source_bus_id; + u8 source_bus_irq; + u8 destination_ioapic_id; + u8 destination_ioapic_intin_pin; +}; + +struct [[gnu::packed]] LocalInterruptAssignmentEntry +{ + EntryHeader h; + u8 interrupt_type; + u8 polarity; + u8 trigger_mode; + u8 source_bus_id; + u8 source_bus_irq; + u8 destination_lapic_id; + u8 destination_lapic_lintin_pin; +}; + +enum class SystemAddressType { + IO = 0, + Memory = 1, + Prefetch = 2, +}; + +struct [[gnu::packed]] SystemAddressSpaceMappingEntry +{ + ExtEntryHeader h; + u8 bus_id; + u8 address_type; + u64 address_base; + u64 length; +}; + +struct [[gnu::packed]] BusHierarchyDescriptorEntry +{ + ExtEntryHeader h; + u8 bus_id; + u8 bus_info; + u8 parent_bus; + u8 reserved[3]; +}; + +struct [[gnu::packed]] CompatibilityBusAddressSpaceModifierEntry +{ + ExtEntryHeader h; + u8 bus_id; + u8 address_modifier; + u32 predefined_range_list; +}; } diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp index 69e4b1db53..f0b92fd44b 100644 --- a/Kernel/Arch/i386/CPU.cpp +++ b/Kernel/Arch/i386/CPU.cpp @@ -261,10 +261,10 @@ void page_fault_handler(RegisterState regs) } dbg() << "Unrecoverable page fault, " - << (regs.exception_code & PageFaultFlags::ReservedBitViolation ? "reserved bit violation / " : "") - << (regs.exception_code & PageFaultFlags::InstructionFetch ? "instruction fetch / " : "") - << (regs.exception_code & PageFaultFlags::Write ? "write to" : "read from") - << " address " << VirtualAddress(fault_address); + << (regs.exception_code & PageFaultFlags::ReservedBitViolation ? "reserved bit violation / " : "") + << (regs.exception_code & PageFaultFlags::InstructionFetch ? "instruction fetch / " : "") + << (regs.exception_code & PageFaultFlags::Write ? "write to" : "read from") + << " address " << VirtualAddress(fault_address); u32 malloc_scrub_pattern = explode_byte(MALLOC_SCRUB_BYTE); u32 free_scrub_pattern = explode_byte(FREE_SCRUB_BYTE); u32 kmalloc_scrub_pattern = explode_byte(KMALLOC_SCRUB_BYTE); diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index df9a22207a..765e7e4bbf 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -329,7 +329,6 @@ Optional<KBuffer> procfs$pid_vm(InodeIdentifier identifier) pagemap_builder.append('P'); } region_object.add("pagemap", pagemap_builder.to_string()); - } array.finish(); return builder.build(); diff --git a/Kernel/Interrupts/APIC.cpp b/Kernel/Interrupts/APIC.cpp index 05eb0a95c3..6bf3a1aacb 100644 --- a/Kernel/Interrupts/APIC.cpp +++ b/Kernel/Interrupts/APIC.cpp @@ -54,177 +54,177 @@ namespace Kernel { namespace APIC { - class ICRReg { - u32 m_reg { 0 }; - - public: - enum DeliveryMode { - Fixed = 0x0, - LowPriority = 0x1, - SMI = 0x2, - NMI = 0x4, - INIT = 0x5, - StartUp = 0x6, - }; - enum DestinationMode { - Physical = 0x0, - Logical = 0x0, - }; - enum Level { - DeAssert = 0x0, - Assert = 0x1 - }; - enum class TriggerMode { - Edge = 0x0, - Level = 0x1, - }; - enum DestinationShorthand { - NoShorthand = 0x0, - Self = 0x1, - AllIncludingSelf = 0x2, - AllExcludingSelf = 0x3, - }; - - ICRReg(u8 vector, DeliveryMode delivery_mode, DestinationMode destination_mode, Level level, TriggerMode trigger_mode, DestinationShorthand destination) - : m_reg(vector | (delivery_mode << 8) | (destination_mode << 11) | (level << 14) | (static_cast<u32>(trigger_mode) << 15) | (destination << 18)) - { - } - - u32 low() const { return m_reg; } - u32 high() const { return 0; } +class ICRReg { + u32 m_reg { 0 }; + +public: + enum DeliveryMode { + Fixed = 0x0, + LowPriority = 0x1, + SMI = 0x2, + NMI = 0x4, + INIT = 0x5, + StartUp = 0x6, + }; + enum DestinationMode { + Physical = 0x0, + Logical = 0x0, + }; + enum Level { + DeAssert = 0x0, + Assert = 0x1 + }; + enum class TriggerMode { + Edge = 0x0, + Level = 0x1, + }; + enum DestinationShorthand { + NoShorthand = 0x0, + Self = 0x1, + AllIncludingSelf = 0x2, + AllExcludingSelf = 0x3, }; - static volatile u8* g_apic_base = nullptr; - - static PhysicalAddress get_base() + ICRReg(u8 vector, DeliveryMode delivery_mode, DestinationMode destination_mode, Level level, TriggerMode trigger_mode, DestinationShorthand destination) + : m_reg(vector | (delivery_mode << 8) | (destination_mode << 11) | (level << 14) | (static_cast<u32>(trigger_mode) << 15) | (destination << 18)) { - u32 lo, hi; - MSR msr(APIC_BASE_MSR); - msr.get(lo, hi); - return PhysicalAddress(lo & 0xfffff000); } - static void set_base(const PhysicalAddress& base) - { - u32 hi = 0; - u32 lo = base.get() | 0x800; - MSR msr(APIC_BASE_MSR); - msr.set(lo, hi); - } + u32 low() const { return m_reg; } + u32 high() const { return 0; } +}; - static void write_register(u32 offset, u32 value) - { - auto lapic_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)g_apic_base)), PAGE_SIZE, "LAPIC Write Access", Region::Access::Read | Region::Access::Write, false, true); - auto* lapic = (volatile u32*)lapic_region->vaddr().offset(offset_in_page((u32)g_apic_base)).offset(offset).as_ptr(); - *lapic = value; - } +static volatile u8* g_apic_base = nullptr; - static u32 read_register(u32 offset) - { - auto lapic_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)g_apic_base)), PAGE_SIZE, "LAPIC Read Access", Region::Access::Read, false, true); - auto* lapic = (volatile u32*)lapic_region->vaddr().offset(offset_in_page((u32)g_apic_base)).offset(offset).as_ptr(); - return *lapic; - } +static PhysicalAddress get_base() +{ + u32 lo, hi; + MSR msr(APIC_BASE_MSR); + msr.get(lo, hi); + return PhysicalAddress(lo & 0xfffff000); +} - static void write_icr(const ICRReg& icr) - { - write_register(APIC_REG_ICR_HIGH, icr.high()); - write_register(APIC_REG_ICR_LOW, icr.low()); - } +static void set_base(const PhysicalAddress& base) +{ + u32 hi = 0; + u32 lo = base.get() | 0x800; + MSR msr(APIC_BASE_MSR); + msr.set(lo, hi); +} + +static void write_register(u32 offset, u32 value) +{ + auto lapic_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)g_apic_base)), PAGE_SIZE, "LAPIC Write Access", Region::Access::Read | Region::Access::Write, false, true); + auto* lapic = (volatile u32*)lapic_region->vaddr().offset(offset_in_page((u32)g_apic_base)).offset(offset).as_ptr(); + *lapic = value; +} + +static u32 read_register(u32 offset) +{ + auto lapic_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)g_apic_base)), PAGE_SIZE, "LAPIC Read Access", Region::Access::Read, false, true); + auto* lapic = (volatile u32*)lapic_region->vaddr().offset(offset_in_page((u32)g_apic_base)).offset(offset).as_ptr(); + return *lapic; +} + +static void write_icr(const ICRReg& icr) +{ + write_register(APIC_REG_ICR_HIGH, icr.high()); + write_register(APIC_REG_ICR_LOW, icr.low()); +} #define APIC_LVT_MASKED (1 << 16) #define APIC_LVT_TRIGGER_LEVEL (1 << 14) #define APIC_LVT(iv, dm) ((iv & 0xff) | ((dm & 0x7) << 8)) - asm( - ".globl apic_ap_start \n" - ".type apic_ap_start, @function \n" - "apic_ap_start: \n" - ".set begin_apic_ap_start, . \n" - " jmp apic_ap_start\n" // TODO: implement - ".set end_apic_ap_start, . \n" - "\n" - ".globl apic_ap_start_size \n" - "apic_ap_start_size: \n" - ".word end_apic_ap_start - begin_apic_ap_start \n"); - - extern "C" void apic_ap_start(void); - extern "C" u16 apic_ap_start_size; - - void eoi() - { - write_register(APIC_REG_EOI, 0x0); - } +asm( + ".globl apic_ap_start \n" + ".type apic_ap_start, @function \n" + "apic_ap_start: \n" + ".set begin_apic_ap_start, . \n" + " jmp apic_ap_start\n" // TODO: implement + ".set end_apic_ap_start, . \n" + "\n" + ".globl apic_ap_start_size \n" + "apic_ap_start_size: \n" + ".word end_apic_ap_start - begin_apic_ap_start \n"); + +extern "C" void apic_ap_start(void); +extern "C" u16 apic_ap_start_size; + +void eoi() +{ + write_register(APIC_REG_EOI, 0x0); +} - bool init() - { - if (!MSR::have()) - return false; +bool init() +{ + if (!MSR::have()) + return false; - // check if we support local apic - CPUID id(1); - if ((id.edx() & (1 << 9)) == 0) - return false; + // check if we support local apic + CPUID id(1); + if ((id.edx() & (1 << 9)) == 0) + return false; - PhysicalAddress apic_base = get_base(); - klog() << "Initializing APIC, base: " << apic_base; - set_base(apic_base); + PhysicalAddress apic_base = get_base(); + klog() << "Initializing APIC, base: " << apic_base; + set_base(apic_base); - g_apic_base = apic_base.as_ptr(); + g_apic_base = apic_base.as_ptr(); - return true; - } + return true; +} - void enable_bsp() - { - // FIXME: Ensure this method can only be executed by the BSP. - enable(0); - } +void enable_bsp() +{ + // FIXME: Ensure this method can only be executed by the BSP. + enable(0); +} - void enable(u32 cpu) - { - klog() << "Enabling local APIC for cpu #" << cpu; +void enable(u32 cpu) +{ + klog() << "Enabling local APIC for cpu #" << cpu; - // dummy read, apparently to avoid a bug in old CPUs. - read_register(APIC_REG_SIV); - // set spurious interrupt vector - write_register(APIC_REG_SIV, IRQ_APIC_SPURIOUS | 0x100); + // dummy read, apparently to avoid a bug in old CPUs. + read_register(APIC_REG_SIV); + // set spurious interrupt vector + write_register(APIC_REG_SIV, IRQ_APIC_SPURIOUS | 0x100); - // local destination mode (flat mode) - write_register(APIC_REG_DF, 0xf0000000); + // local destination mode (flat mode) + write_register(APIC_REG_DF, 0xf0000000); - // set destination id (note that this limits it to 8 cpus) - write_register(APIC_REG_LD, 0); + // set destination id (note that this limits it to 8 cpus) + write_register(APIC_REG_LD, 0); - SpuriousInterruptHandler::initialize(IRQ_APIC_SPURIOUS); + SpuriousInterruptHandler::initialize(IRQ_APIC_SPURIOUS); - write_register(APIC_REG_LVT_TIMER, APIC_LVT(0, 0) | APIC_LVT_MASKED); - write_register(APIC_REG_LVT_THERMAL, APIC_LVT(0, 0) | APIC_LVT_MASKED); - write_register(APIC_REG_LVT_PERFORMANCE_COUNTER, APIC_LVT(0, 0) | APIC_LVT_MASKED); - write_register(APIC_REG_LVT_LINT0, APIC_LVT(0, 7) | APIC_LVT_MASKED); - write_register(APIC_REG_LVT_LINT1, APIC_LVT(0, 0) | APIC_LVT_TRIGGER_LEVEL); - write_register(APIC_REG_LVT_ERR, APIC_LVT(0, 0) | APIC_LVT_MASKED); + write_register(APIC_REG_LVT_TIMER, APIC_LVT(0, 0) | APIC_LVT_MASKED); + write_register(APIC_REG_LVT_THERMAL, APIC_LVT(0, 0) | APIC_LVT_MASKED); + write_register(APIC_REG_LVT_PERFORMANCE_COUNTER, APIC_LVT(0, 0) | APIC_LVT_MASKED); + write_register(APIC_REG_LVT_LINT0, APIC_LVT(0, 7) | APIC_LVT_MASKED); + write_register(APIC_REG_LVT_LINT1, APIC_LVT(0, 0) | APIC_LVT_TRIGGER_LEVEL); + write_register(APIC_REG_LVT_ERR, APIC_LVT(0, 0) | APIC_LVT_MASKED); - write_register(APIC_REG_TPR, 0); + write_register(APIC_REG_TPR, 0); - if (cpu != 0) { - static volatile u32 foo = 0; + if (cpu != 0) { + static volatile u32 foo = 0; - // INIT - write_icr(ICRReg(0, ICRReg::INIT, ICRReg::Physical, ICRReg::Assert, ICRReg::TriggerMode::Edge, ICRReg::AllExcludingSelf)); + // INIT + write_icr(ICRReg(0, ICRReg::INIT, ICRReg::Physical, ICRReg::Assert, ICRReg::TriggerMode::Edge, ICRReg::AllExcludingSelf)); - for (foo = 0; foo < 0x800000; foo++) - ; // TODO: 10 millisecond delay + for (foo = 0; foo < 0x800000; foo++) + ; // TODO: 10 millisecond delay - for (int i = 0; i < 2; i++) { - // SIPI - write_icr(ICRReg(0x08, ICRReg::StartUp, ICRReg::Physical, ICRReg::Assert, ICRReg::TriggerMode::Edge, ICRReg::AllExcludingSelf)); // start execution at P8000 + for (int i = 0; i < 2; i++) { + // SIPI + write_icr(ICRReg(0x08, ICRReg::StartUp, ICRReg::Physical, ICRReg::Assert, ICRReg::TriggerMode::Edge, ICRReg::AllExcludingSelf)); // start execution at P8000 - for (foo = 0; foo < 0x80000; foo++) - ; // TODO: 200 microsecond delay - } + for (foo = 0; foo < 0x80000; foo++) + ; // TODO: 200 microsecond delay } } +} } diff --git a/Kernel/Interrupts/APIC.h b/Kernel/Interrupts/APIC.h index f5ccb5ade1..42fddb55be 100644 --- a/Kernel/Interrupts/APIC.h +++ b/Kernel/Interrupts/APIC.h @@ -32,10 +32,10 @@ namespace Kernel { namespace APIC { - void enable_bsp(); - void eoi(); - bool init(); - void enable(u32 cpu); +void enable_bsp(); +void eoi(); +bool init(); +void enable(u32 cpu); } diff --git a/Kernel/Interrupts/SpuriousInterruptHandler.h b/Kernel/Interrupts/SpuriousInterruptHandler.h index b4ad7ebd9a..24c24903d6 100644 --- a/Kernel/Interrupts/SpuriousInterruptHandler.h +++ b/Kernel/Interrupts/SpuriousInterruptHandler.h @@ -30,8 +30,8 @@ #include <AK/OwnPtr.h> #include <AK/Types.h> #include <Kernel/Arch/i386/CPU.h> -#include <Kernel/Interrupts/IRQController.h> #include <Kernel/Interrupts/GenericInterruptHandler.h> +#include <Kernel/Interrupts/IRQController.h> namespace Kernel { diff --git a/Kernel/KParams.h b/Kernel/KParams.h index 2ef144620b..fff1e59e3e 100644 --- a/Kernel/KParams.h +++ b/Kernel/KParams.h @@ -26,8 +26,8 @@ #pragma once -#include <AK/String.h> #include <AK/HashMap.h> +#include <AK/String.h> class KParams { AK_MAKE_ETERNAL diff --git a/Kernel/Net/E1000NetworkAdapter.h b/Kernel/Net/E1000NetworkAdapter.h index 25af6f44ba..952bc873ea 100644 --- a/Kernel/Net/E1000NetworkAdapter.h +++ b/Kernel/Net/E1000NetworkAdapter.h @@ -29,9 +29,9 @@ #include <AK/OwnPtr.h> #include <Kernel/Interrupts/IRQHandler.h> #include <Kernel/Net/NetworkAdapter.h> -#include <LibBareMetal/IO.h> #include <Kernel/PCI/Access.h> #include <Kernel/PCI/Device.h> +#include <LibBareMetal/IO.h> namespace Kernel { diff --git a/Kernel/Net/IPv4.h b/Kernel/Net/IPv4.h index 534e065c19..8d7322b1de 100644 --- a/Kernel/Net/IPv4.h +++ b/Kernel/Net/IPv4.h @@ -26,10 +26,10 @@ #pragma once -#include <AK/String.h> #include <AK/Assertions.h> #include <AK/IPv4Address.h> #include <AK/NetworkOrdered.h> +#include <AK/String.h> #include <AK/Types.h> namespace Kernel { diff --git a/Kernel/Net/NetworkAdapter.h b/Kernel/Net/NetworkAdapter.h index 4e875eb8b1..a787e96380 100644 --- a/Kernel/Net/NetworkAdapter.h +++ b/Kernel/Net/NetworkAdapter.h @@ -30,8 +30,8 @@ #include <AK/Function.h> #include <AK/SinglyLinkedList.h> #include <AK/Types.h> -#include <AK/Weakable.h> #include <AK/WeakPtr.h> +#include <AK/Weakable.h> #include <Kernel/KBuffer.h> #include <Kernel/Net/ARP.h> #include <Kernel/Net/ICMP.h> diff --git a/Kernel/Net/Routing.h b/Kernel/Net/Routing.h index e12276d5b1..40d61bcf6b 100644 --- a/Kernel/Net/Routing.h +++ b/Kernel/Net/Routing.h @@ -30,8 +30,7 @@ namespace Kernel { -struct RoutingDecision -{ +struct RoutingDecision { RefPtr<NetworkAdapter> adapter; MACAddress next_hop; diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h index ca2ad471cc..5e4feecdba 100644 --- a/Kernel/Net/Socket.h +++ b/Kernel/Net/Socket.h @@ -126,7 +126,6 @@ public: virtual ssize_t write(FileDescription&, const u8*, ssize_t) override final; virtual String absolute_path(const FileDescription&) const override = 0; - bool has_receive_timeout() const { return m_receive_timeout.tv_sec || m_receive_timeout.tv_usec; } const timeval& receive_timeout() const { return m_receive_timeout; } diff --git a/Kernel/PCI/Access.cpp b/Kernel/PCI/Access.cpp index c9e8cf2aa6..4a11948fb5 100644 --- a/Kernel/PCI/Access.cpp +++ b/Kernel/PCI/Access.cpp @@ -108,103 +108,103 @@ void PCI::Access::disable_bus_mastering(Address address) namespace PCI { - void enumerate_all(Function<void(Address, ID)> callback) - { - PCI::Access::the().enumerate_all(callback); - } - - void raw_access(Address address, u32 field, size_t access_size, u32 value) - { - ASSERT(access_size != 0); - if (access_size == 1) { - PCI::Access::the().write8_field(address, field, value); - return; - } - if (access_size == 2) { - PCI::Access::the().write16_field(address, field, value); - return; - } - if (access_size == 4) { - PCI::Access::the().write32_field(address, field, value); - return; - } - ASSERT_NOT_REACHED(); - } +void enumerate_all(Function<void(Address, ID)> callback) +{ + PCI::Access::the().enumerate_all(callback); +} - ID get_id(Address address) - { - return PCI::Access::the().get_id(address); +void raw_access(Address address, u32 field, size_t access_size, u32 value) +{ + ASSERT(access_size != 0); + if (access_size == 1) { + PCI::Access::the().write8_field(address, field, value); + return; } - - void enable_interrupt_line(Address address) - { - PCI::Access::the().enable_interrupt_line(address); + if (access_size == 2) { + PCI::Access::the().write16_field(address, field, value); + return; } - void disable_interrupt_line(Address address) - { - PCI::Access::the().disable_interrupt_line(address); + if (access_size == 4) { + PCI::Access::the().write32_field(address, field, value); + return; } + ASSERT_NOT_REACHED(); +} - u8 get_interrupt_line(Address address) - { - return PCI::Access::the().get_interrupt_line(address); - } - u32 get_BAR0(Address address) - { - return PCI::Access::the().get_BAR0(address); - } - u32 get_BAR1(Address address) - { - return PCI::Access::the().get_BAR1(address); - } - u32 get_BAR2(Address address) - { - return PCI::Access::the().get_BAR2(address); - } - u32 get_BAR3(Address address) - { - return PCI::Access::the().get_BAR3(address); - } - u32 get_BAR4(Address address) - { - return PCI::Access::the().get_BAR4(address); - } - u32 get_BAR5(Address address) - { - return PCI::Access::the().get_BAR5(address); - } - u8 get_revision_id(Address address) - { - return PCI::Access::the().get_revision_id(address); - } - u8 get_subclass(Address address) - { - return PCI::Access::the().get_subclass(address); - } - u8 get_class(Address address) - { - return PCI::Access::the().get_class(address); - } - u16 get_subsystem_id(Address address) - { - return PCI::Access::the().get_subsystem_id(address); - } - u16 get_subsystem_vendor_id(Address address) - { - return PCI::Access::the().get_subsystem_vendor_id(address); - } - void enable_bus_mastering(Address address) - { - PCI::Access::the().enable_bus_mastering(address); - } - void disable_bus_mastering(Address address) - { - PCI::Access::the().disable_bus_mastering(address); - } - size_t get_BAR_Space_Size(Address address, u8 bar_number) - { - return PCI::Access::the().get_BAR_Space_Size(address, bar_number); - } +ID get_id(Address address) +{ + return PCI::Access::the().get_id(address); +} + +void enable_interrupt_line(Address address) +{ + PCI::Access::the().enable_interrupt_line(address); +} +void disable_interrupt_line(Address address) +{ + PCI::Access::the().disable_interrupt_line(address); +} + +u8 get_interrupt_line(Address address) +{ + return PCI::Access::the().get_interrupt_line(address); +} +u32 get_BAR0(Address address) +{ + return PCI::Access::the().get_BAR0(address); +} +u32 get_BAR1(Address address) +{ + return PCI::Access::the().get_BAR1(address); +} +u32 get_BAR2(Address address) +{ + return PCI::Access::the().get_BAR2(address); +} +u32 get_BAR3(Address address) +{ + return PCI::Access::the().get_BAR3(address); +} +u32 get_BAR4(Address address) +{ + return PCI::Access::the().get_BAR4(address); +} +u32 get_BAR5(Address address) +{ + return PCI::Access::the().get_BAR5(address); +} +u8 get_revision_id(Address address) +{ + return PCI::Access::the().get_revision_id(address); +} +u8 get_subclass(Address address) +{ + return PCI::Access::the().get_subclass(address); +} +u8 get_class(Address address) +{ + return PCI::Access::the().get_class(address); +} +u16 get_subsystem_id(Address address) +{ + return PCI::Access::the().get_subsystem_id(address); +} +u16 get_subsystem_vendor_id(Address address) +{ + return PCI::Access::the().get_subsystem_vendor_id(address); +} +void enable_bus_mastering(Address address) +{ + PCI::Access::the().enable_bus_mastering(address); +} +void disable_bus_mastering(Address address) +{ + PCI::Access::the().disable_bus_mastering(address); +} +size_t get_BAR_Space_Size(Address address, u8 bar_number) +{ + return PCI::Access::the().get_BAR_Space_Size(address, bar_number); +} } } diff --git a/Kernel/PCI/Definitions.h b/Kernel/PCI/Definitions.h index a943d8a80c..0b2aead57d 100644 --- a/Kernel/PCI/Definitions.h +++ b/Kernel/PCI/Definitions.h @@ -68,134 +68,134 @@ namespace Kernel { //#define PCI_DEBUG 1 namespace PCI { - struct ID { - u16 vendor_id { 0 }; - u16 device_id { 0 }; - - bool is_null() const { return !vendor_id && !device_id; } - - bool operator==(const ID& other) const - { - return vendor_id == other.vendor_id && device_id == other.device_id; - } - bool operator!=(const ID& other) const - { - return vendor_id != other.vendor_id || device_id != other.device_id; - } - }; - - struct Address { - public: - Address() {} - Address(u16 seg) - : m_seg(seg) - , m_bus(0) - , m_slot(0) - , m_function(0) - { - } - Address(u16 seg, u8 bus, u8 slot, u8 function) - : m_seg(seg) - , m_bus(bus) - , m_slot(slot) - , m_function(function) - { - } - - Address(const Address& address) - : m_seg(address.seg()) - , m_bus(address.bus()) - , m_slot(address.slot()) - , m_function(address.function()) - { - } - - bool is_null() const { return !m_bus && !m_slot && !m_function; } - operator bool() const { return !is_null(); } - - u16 seg() const { return m_seg; } - u8 bus() const { return m_bus; } - u8 slot() const { return m_slot; } - u8 function() const { return m_function; } - - u32 io_address_for_field(u8 field) const - { - return 0x80000000u | (m_bus << 16u) | (m_slot << 11u) | (m_function << 8u) | (field & 0xfc); - } - - protected: - u32 m_seg { 0 }; - u8 m_bus { 0 }; - u8 m_slot { 0 }; - u8 m_function { 0 }; - }; - - inline const LogStream& operator<<(const LogStream& stream, const Address value) +struct ID { + u16 vendor_id { 0 }; + u16 device_id { 0 }; + + bool is_null() const { return !vendor_id && !device_id; } + + bool operator==(const ID& other) const + { + return vendor_id == other.vendor_id && device_id == other.device_id; + } + bool operator!=(const ID& other) const + { + return vendor_id != other.vendor_id || device_id != other.device_id; + } +}; + +struct Address { +public: + Address() {} + Address(u16 seg) + : m_seg(seg) + , m_bus(0) + , m_slot(0) + , m_function(0) + { + } + Address(u16 seg, u8 bus, u8 slot, u8 function) + : m_seg(seg) + , m_bus(bus) + , m_slot(slot) + , m_function(function) { - return stream << "PCI [" << String::format("%w", value.seg()) << ":" << String::format("%b", value.bus()) << ":" << String::format("%b", value.slot()) << "." << String::format("%b", value.function()) << "]"; } - struct ChangeableAddress : public Address { - ChangeableAddress() - : Address(0) - { - } - explicit ChangeableAddress(u16 seg) - : Address(seg) - { - } - ChangeableAddress(u16 seg, u8 bus, u8 slot, u8 function) - : Address(seg, bus, slot, function) - { - } - void set_seg(u16 seg) { m_seg = seg; } - void set_bus(u8 bus) { m_bus = bus; } - void set_slot(u8 slot) { m_slot = slot; } - void set_function(u8 function) { m_function = function; } - bool operator==(const Address& address) - { - if (m_seg == address.seg() && m_bus == address.bus() && m_slot == address.slot() && m_function == address.function()) - return true; - else - return false; - } - const ChangeableAddress& operator=(const Address& address) - { - set_seg(address.seg()); - set_bus(address.bus()); - set_slot(address.slot()); - set_function(address.function()); - return *this; - } - }; - - ID get_id(PCI::Address); - void enumerate_all(Function<void(Address, ID)> callback); - void enable_interrupt_line(Address); - void disable_interrupt_line(Address); - u8 get_interrupt_line(Address); - void raw_access(Address, u32, size_t, u32); - u32 get_BAR0(Address); - u32 get_BAR1(Address); - u32 get_BAR2(Address); - u32 get_BAR3(Address); - u32 get_BAR4(Address); - u32 get_BAR5(Address); - u8 get_revision_id(Address); - u8 get_subclass(Address); - u8 get_class(Address); - u16 get_subsystem_id(Address); - u16 get_subsystem_vendor_id(Address); - size_t get_BAR_Space_Size(Address, u8); - void enable_bus_mastering(Address); - void disable_bus_mastering(Address); - - class Initializer; - class Access; - class MMIOAccess; - class IOAccess; - class MMIOSegment; - class Device; + Address(const Address& address) + : m_seg(address.seg()) + , m_bus(address.bus()) + , m_slot(address.slot()) + , m_function(address.function()) + { + } + + bool is_null() const { return !m_bus && !m_slot && !m_function; } + operator bool() const { return !is_null(); } + + u16 seg() const { return m_seg; } + u8 bus() const { return m_bus; } + u8 slot() const { return m_slot; } + u8 function() const { return m_function; } + + u32 io_address_for_field(u8 field) const + { + return 0x80000000u | (m_bus << 16u) | (m_slot << 11u) | (m_function << 8u) | (field & 0xfc); + } + +protected: + u32 m_seg { 0 }; + u8 m_bus { 0 }; + u8 m_slot { 0 }; + u8 m_function { 0 }; +}; + +inline const LogStream& operator<<(const LogStream& stream, const Address value) +{ + return stream << "PCI [" << String::format("%w", value.seg()) << ":" << String::format("%b", value.bus()) << ":" << String::format("%b", value.slot()) << "." << String::format("%b", value.function()) << "]"; +} + +struct ChangeableAddress : public Address { + ChangeableAddress() + : Address(0) + { + } + explicit ChangeableAddress(u16 seg) + : Address(seg) + { + } + ChangeableAddress(u16 seg, u8 bus, u8 slot, u8 function) + : Address(seg, bus, slot, function) + { + } + void set_seg(u16 seg) { m_seg = seg; } + void set_bus(u8 bus) { m_bus = bus; } + void set_slot(u8 slot) { m_slot = slot; } + void set_function(u8 function) { m_function = function; } + bool operator==(const Address& address) + { + if (m_seg == address.seg() && m_bus == address.bus() && m_slot == address.slot() && m_function == address.function()) + return true; + else + return false; + } + const ChangeableAddress& operator=(const Address& address) + { + set_seg(address.seg()); + set_bus(address.bus()); + set_slot(address.slot()); + set_function(address.function()); + return *this; + } +}; + +ID get_id(PCI::Address); +void enumerate_all(Function<void(Address, ID)> callback); +void enable_interrupt_line(Address); +void disable_interrupt_line(Address); +u8 get_interrupt_line(Address); +void raw_access(Address, u32, size_t, u32); +u32 get_BAR0(Address); +u32 get_BAR1(Address); +u32 get_BAR2(Address); +u32 get_BAR3(Address); +u32 get_BAR4(Address); +u32 get_BAR5(Address); +u8 get_revision_id(Address); +u8 get_subclass(Address); +u8 get_class(Address); +u16 get_subsystem_id(Address); +u16 get_subsystem_vendor_id(Address); +size_t get_BAR_Space_Size(Address, u8); +void enable_bus_mastering(Address); +void disable_bus_mastering(Address); + +class Initializer; +class Access; +class MMIOAccess; +class IOAccess; +class MMIOSegment; +class Device; } diff --git a/Kernel/PerformanceEventBuffer.cpp b/Kernel/PerformanceEventBuffer.cpp index 857ed8d7f7..b3fb92336b 100644 --- a/Kernel/PerformanceEventBuffer.cpp +++ b/Kernel/PerformanceEventBuffer.cpp @@ -25,8 +25,8 @@ */ #include <AK/JsonArraySerializer.h> -#include <AK/JsonObjectSerializer.h> #include <AK/JsonObject.h> +#include <AK/JsonObjectSerializer.h> #include <Kernel/KBufferBuilder.h> #include <Kernel/PerformanceEventBuffer.h> diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index d008591b38..f3eb90ef02 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -65,61 +65,61 @@ asm( namespace Syscall { - static int handle(RegisterState&, u32 function, u32 arg1, u32 arg2, u32 arg3); +static int handle(RegisterState&, u32 function, u32 arg1, u32 arg2, u32 arg3); - void initialize() - { - register_user_callable_interrupt_handler(0x82, syscall_asm_entry); - klog() << "Syscall: int 0x82 handler installed"; - } +void initialize() +{ + register_user_callable_interrupt_handler(0x82, syscall_asm_entry); + klog() << "Syscall: int 0x82 handler installed"; +} #pragma GCC diagnostic ignored "-Wcast-function-type" - typedef int (Process::*Handler)(u32, u32, u32); +typedef int (Process::*Handler)(u32, u32, u32); #define __ENUMERATE_REMOVED_SYSCALL(x) nullptr, #define __ENUMERATE_SYSCALL(x) reinterpret_cast<Handler>(&Process::sys$##x), - static Handler s_syscall_table[] = { - ENUMERATE_SYSCALLS - }; +static Handler s_syscall_table[] = { + ENUMERATE_SYSCALLS +}; #undef __ENUMERATE_SYSCALL #undef __ENUMERATE_REMOVED_SYSCALL - int handle(RegisterState& regs, u32 function, u32 arg1, u32 arg2, u32 arg3) - { - ASSERT_INTERRUPTS_ENABLED(); - auto& process = *Process::current; - Thread::current->did_syscall(); +int handle(RegisterState& regs, u32 function, u32 arg1, u32 arg2, u32 arg3) +{ + ASSERT_INTERRUPTS_ENABLED(); + auto& process = *Process::current; + Thread::current->did_syscall(); + + if (function == SC_exit || function == SC_exit_thread) { + // These syscalls need special handling since they never return to the caller. + cli(); + if (auto* tracer = process.tracer()) + tracer->did_syscall(function, arg1, arg2, arg3, 0); + if (function == SC_exit) + process.sys$exit((int)arg1); + else + process.sys$exit_thread((void*)arg1); + ASSERT_NOT_REACHED(); + return 0; + } + + if (function == SC_fork) + return process.sys$fork(regs); + + if (function == SC_sigreturn) + return process.sys$sigreturn(regs); - if (function == SC_exit || function == SC_exit_thread) { - // These syscalls need special handling since they never return to the caller. - cli(); - if (auto* tracer = process.tracer()) - tracer->did_syscall(function, arg1, arg2, arg3, 0); - if (function == SC_exit) - process.sys$exit((int)arg1); - else - process.sys$exit_thread((void*)arg1); - ASSERT_NOT_REACHED(); - return 0; - } - - if (function == SC_fork) - return process.sys$fork(regs); - - if (function == SC_sigreturn) - return process.sys$sigreturn(regs); - - if (function >= Function::__Count) { - dbg() << process << ": Unknown syscall %u requested (" << arg1 << ", " << arg2 << ", " << arg3 << ")"; - return -ENOSYS; - } - - if (s_syscall_table[function] == nullptr) { - dbg() << process << ": Null syscall " << function << " requested: \"" << to_string((Function)function) << "\", you probably need to rebuild this program."; - return -ENOSYS; - } - return (process.*(s_syscall_table[function]))(arg1, arg2, arg3); + if (function >= Function::__Count) { + dbg() << process << ": Unknown syscall %u requested (" << arg1 << ", " << arg2 << ", " << arg3 << ")"; + return -ENOSYS; } + if (s_syscall_table[function] == nullptr) { + dbg() << process << ": Null syscall " << function << " requested: \"" << to_string((Function)function) << "\", you probably need to rebuild this program."; + return -ENOSYS; + } + return (process.*(s_syscall_table[function]))(arg1, arg2, arg3); +} + } void syscall_handler(RegisterState& regs) diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h index 9e7dcd7b16..aa97af37e4 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -184,20 +184,20 @@ namespace Kernel { namespace Syscall { - enum Function { +enum Function { #undef __ENUMERATE_SYSCALL #undef __ENUMERATE_REMOVED_SYSCALL #define __ENUMERATE_REMOVED_SYSCALL(x) SC_##x, #define __ENUMERATE_SYSCALL(x) SC_##x, - ENUMERATE_SYSCALLS + ENUMERATE_SYSCALLS #undef __ENUMERATE_SYSCALL #undef __ENUMERATE_REMOVED_SYSCALL - __Count - }; + __Count +}; - inline constexpr const char* to_string(Function function) - { - switch (function) { +inline constexpr const char* to_string(Function function) +{ + switch (function) { #undef __ENUMERATE_SYSCALL #undef __ENUMERATE_REMOVED_SYSCALL #define __ENUMERATE_REMOVED_SYSCALL(x) \ @@ -206,267 +206,267 @@ namespace Syscall { #define __ENUMERATE_SYSCALL(x) \ case SC_##x: \ return #x; - ENUMERATE_SYSCALLS + ENUMERATE_SYSCALLS #undef __ENUMERATE_SYSCALL #undef __ENUMERATE_REMOVED_SYSCALL - default: - break; - } - return "Unknown"; + default: + break; } + return "Unknown"; +} #ifdef __serenity__ - struct StringArgument { - const char* characters { nullptr }; - size_t length { 0 }; - }; - - template<typename DataType, typename SizeType> - struct MutableBufferArgument { - DataType* data { nullptr }; - SizeType size { 0 }; - }; - - template<typename DataType, typename SizeType> - struct ImmutableBufferArgument { - const DataType* data { nullptr }; - SizeType size { 0 }; - }; - - struct StringListArgument { - StringArgument* strings { nullptr }; - size_t length { 0 }; - }; - - struct SC_mmap_params { - uint32_t addr; - uint32_t size; - uint32_t alignment; - int32_t prot; - int32_t flags; - int32_t fd; - int32_t offset; // FIXME: 64-bit off_t? - StringArgument name; - }; - - struct SC_open_params { - int dirfd; - StringArgument path; - int options; - u16 mode; - }; - - struct SC_select_params { - int nfds; - fd_set* readfds; - fd_set* writefds; - fd_set* exceptfds; - struct timeval* timeout; - }; - - struct SC_clock_nanosleep_params { - int clock_id; - int flags; - const struct timespec* requested_sleep; - struct timespec* remaining_sleep; - }; - - struct SC_sendto_params { - int sockfd; - ImmutableBufferArgument<void, size_t> data; - int flags; - const sockaddr* addr; - socklen_t addr_length; - }; - - struct SC_recvfrom_params { - int sockfd; - MutableBufferArgument<void, size_t> buffer; - int flags; - sockaddr* addr; - socklen_t* addr_length; - }; - - struct SC_getsockopt_params { - int sockfd; - int level; - int option; - void* value; - socklen_t* value_size; - }; - - struct SC_setsockopt_params { - int sockfd; - int level; - int option; - const void* value; - socklen_t value_size; - }; - - struct SC_getsockname_params { - int sockfd; - sockaddr* addr; - socklen_t* addrlen; - }; - - struct SC_getpeername_params { - int sockfd; - sockaddr* addr; - socklen_t* addrlen; - }; - - struct SC_futex_params { - i32* userspace_address; - int futex_op; - i32 val; - const timespec* timeout; - }; - - struct SC_setkeymap_params { - const char* map; - const char* shift_map; - const char* alt_map; - const char* altgr_map; - }; - - struct SC_create_thread_params { - unsigned int m_detach_state = 0; // JOINABLE or DETACHED - int m_schedule_priority = 30; // THREAD_PRIORITY_NORMAL - // FIXME: Implment guard pages in create_thread (unreadable pages at "overflow" end of stack) - // "If an implementation rounds up the value of guardsize to a multiple of {PAGESIZE}, - // a call to pthread_attr_getguardsize() specifying attr shall store in the guardsize - // parameter the guard size specified by the previous pthread_attr_setguardsize() function call" - // ... ok, if you say so posix. Guess we get to lie to people about guard page size - unsigned int m_guard_page_size = 0; // Rounded up to PAGE_SIZE - unsigned int m_reported_guard_page_size = 0; // The lie we tell callers - unsigned int m_stack_size = 4 * MB; // Default PTHREAD_STACK_MIN - void* m_stack_location = nullptr; // nullptr means any, o.w. process virtual address - }; - - struct SC_realpath_params { - StringArgument path; - MutableBufferArgument<char, size_t> buffer; - }; - - struct SC_set_mmap_name_params { - void* addr; - size_t size; - StringArgument name; - }; - - struct SC_execve_params { - StringArgument path; - StringListArgument arguments; - StringListArgument environment; - }; - - struct SC_readlink_params { - StringArgument path; - MutableBufferArgument<char, size_t> buffer; - }; - - struct SC_link_params { - StringArgument old_path; - StringArgument new_path; - }; - - struct SC_chown_params { - StringArgument path; - u32 uid; - u32 gid; - }; - - struct SC_mknod_params { - StringArgument path; - u16 mode; - u32 dev; - }; - - struct SC_symlink_params { - StringArgument target; - StringArgument linkpath; - }; - - struct SC_rename_params { - StringArgument old_path; - StringArgument new_path; - }; - - struct SC_mount_params { - StringArgument source; - StringArgument target; - StringArgument fs_type; - int flags; - }; - - struct SC_pledge_params { - StringArgument promises; - StringArgument execpromises; - }; - - struct SC_unveil_params { - StringArgument path; - StringArgument permissions; - }; - - struct SC_waitid_params { - int idtype; - int id; - struct siginfo* infop; - int options; - }; - - struct SC_stat_params { - StringArgument path; - struct stat* statbuf; - bool follow_symlinks; - }; - - void initialize(); - int sync(); - - inline u32 invoke(Function function) - { - u32 result; - asm volatile("int $0x82" - : "=a"(result) - : "a"(function) - : "memory"); - return result; - } +struct StringArgument { + const char* characters { nullptr }; + size_t length { 0 }; +}; + +template<typename DataType, typename SizeType> +struct MutableBufferArgument { + DataType* data { nullptr }; + SizeType size { 0 }; +}; + +template<typename DataType, typename SizeType> +struct ImmutableBufferArgument { + const DataType* data { nullptr }; + SizeType size { 0 }; +}; + +struct StringListArgument { + StringArgument* strings { nullptr }; + size_t length { 0 }; +}; + +struct SC_mmap_params { + uint32_t addr; + uint32_t size; + uint32_t alignment; + int32_t prot; + int32_t flags; + int32_t fd; + int32_t offset; // FIXME: 64-bit off_t? + StringArgument name; +}; + +struct SC_open_params { + int dirfd; + StringArgument path; + int options; + u16 mode; +}; + +struct SC_select_params { + int nfds; + fd_set* readfds; + fd_set* writefds; + fd_set* exceptfds; + struct timeval* timeout; +}; + +struct SC_clock_nanosleep_params { + int clock_id; + int flags; + const struct timespec* requested_sleep; + struct timespec* remaining_sleep; +}; + +struct SC_sendto_params { + int sockfd; + ImmutableBufferArgument<void, size_t> data; + int flags; + const sockaddr* addr; + socklen_t addr_length; +}; + +struct SC_recvfrom_params { + int sockfd; + MutableBufferArgument<void, size_t> buffer; + int flags; + sockaddr* addr; + socklen_t* addr_length; +}; + +struct SC_getsockopt_params { + int sockfd; + int level; + int option; + void* value; + socklen_t* value_size; +}; + +struct SC_setsockopt_params { + int sockfd; + int level; + int option; + const void* value; + socklen_t value_size; +}; + +struct SC_getsockname_params { + int sockfd; + sockaddr* addr; + socklen_t* addrlen; +}; + +struct SC_getpeername_params { + int sockfd; + sockaddr* addr; + socklen_t* addrlen; +}; + +struct SC_futex_params { + i32* userspace_address; + int futex_op; + i32 val; + const timespec* timeout; +}; + +struct SC_setkeymap_params { + const char* map; + const char* shift_map; + const char* alt_map; + const char* altgr_map; +}; + +struct SC_create_thread_params { + unsigned int m_detach_state = 0; // JOINABLE or DETACHED + int m_schedule_priority = 30; // THREAD_PRIORITY_NORMAL + // FIXME: Implment guard pages in create_thread (unreadable pages at "overflow" end of stack) + // "If an implementation rounds up the value of guardsize to a multiple of {PAGESIZE}, + // a call to pthread_attr_getguardsize() specifying attr shall store in the guardsize + // parameter the guard size specified by the previous pthread_attr_setguardsize() function call" + // ... ok, if you say so posix. Guess we get to lie to people about guard page size + unsigned int m_guard_page_size = 0; // Rounded up to PAGE_SIZE + unsigned int m_reported_guard_page_size = 0; // The lie we tell callers + unsigned int m_stack_size = 4 * MB; // Default PTHREAD_STACK_MIN + void* m_stack_location = nullptr; // nullptr means any, o.w. process virtual address +}; + +struct SC_realpath_params { + StringArgument path; + MutableBufferArgument<char, size_t> buffer; +}; + +struct SC_set_mmap_name_params { + void* addr; + size_t size; + StringArgument name; +}; + +struct SC_execve_params { + StringArgument path; + StringListArgument arguments; + StringListArgument environment; +}; + +struct SC_readlink_params { + StringArgument path; + MutableBufferArgument<char, size_t> buffer; +}; + +struct SC_link_params { + StringArgument old_path; + StringArgument new_path; +}; + +struct SC_chown_params { + StringArgument path; + u32 uid; + u32 gid; +}; + +struct SC_mknod_params { + StringArgument path; + u16 mode; + u32 dev; +}; + +struct SC_symlink_params { + StringArgument target; + StringArgument linkpath; +}; + +struct SC_rename_params { + StringArgument old_path; + StringArgument new_path; +}; + +struct SC_mount_params { + StringArgument source; + StringArgument target; + StringArgument fs_type; + int flags; +}; + +struct SC_pledge_params { + StringArgument promises; + StringArgument execpromises; +}; + +struct SC_unveil_params { + StringArgument path; + StringArgument permissions; +}; + +struct SC_waitid_params { + int idtype; + int id; + struct siginfo* infop; + int options; +}; + +struct SC_stat_params { + StringArgument path; + struct stat* statbuf; + bool follow_symlinks; +}; + +void initialize(); +int sync(); + +inline u32 invoke(Function function) +{ + u32 result; + asm volatile("int $0x82" + : "=a"(result) + : "a"(function) + : "memory"); + return result; +} - template<typename T1> - inline u32 invoke(Function function, T1 arg1) - { - u32 result; - asm volatile("int $0x82" - : "=a"(result) - : "a"(function), "d"((u32)arg1) - : "memory"); - return result; - } +template<typename T1> +inline u32 invoke(Function function, T1 arg1) +{ + u32 result; + asm volatile("int $0x82" + : "=a"(result) + : "a"(function), "d"((u32)arg1) + : "memory"); + return result; +} - template<typename T1, typename T2> - inline u32 invoke(Function function, T1 arg1, T2 arg2) - { - u32 result; - asm volatile("int $0x82" - : "=a"(result) - : "a"(function), "d"((u32)arg1), "c"((u32)arg2) - : "memory"); - return result; - } +template<typename T1, typename T2> +inline u32 invoke(Function function, T1 arg1, T2 arg2) +{ + u32 result; + asm volatile("int $0x82" + : "=a"(result) + : "a"(function), "d"((u32)arg1), "c"((u32)arg2) + : "memory"); + return result; +} - template<typename T1, typename T2, typename T3> - inline u32 invoke(Function function, T1 arg1, T2 arg2, T3 arg3) - { - u32 result; - asm volatile("int $0x82" - : "=a"(result) - : "a"(function), "d"((u32)arg1), "c"((u32)arg2), "b"((u32)arg3) - : "memory"); - return result; - } +template<typename T1, typename T2, typename T3> +inline u32 invoke(Function function, T1 arg1, T2 arg2, T3 arg3) +{ + u32 result; + asm volatile("int $0x82" + : "=a"(result) + : "a"(function), "d"((u32)arg1), "c"((u32)arg2), "b"((u32)arg3) + : "memory"); + return result; +} #endif } diff --git a/Kernel/VM/PhysicalPage.cpp b/Kernel/VM/PhysicalPage.cpp index 36cc3d5015..1c4e9ed673 100644 --- a/Kernel/VM/PhysicalPage.cpp +++ b/Kernel/VM/PhysicalPage.cpp @@ -24,9 +24,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <Kernel/Heap/kmalloc.h> #include <Kernel/VM/MemoryManager.h> #include <Kernel/VM/PhysicalPage.h> -#include <Kernel/Heap/kmalloc.h> namespace Kernel { |