feature (acpi): implemented FADT

This commit is contained in:
antifallobst 2023-03-22 13:08:57 +01:00
parent ed977586a5
commit 7fe93891b0
3 changed files with 85 additions and 1 deletions

View File

@ -18,6 +18,14 @@ typedef struct {
uint32_t creator_revision; uint32_t creator_revision;
} __attribute__((packed)) acpi_sdt_header_T; } __attribute__((packed)) acpi_sdt_header_T;
typedef struct {
uint8_t address_space;
uint8_t bit_width;
uint8_t bit_offset;
uint8_t access_size;
uint64_t address;
} __attribute__((packed)) acpi_gas_T;
void acpi_init (boot_info_T* boot_info); void acpi_init (boot_info_T* boot_info);
acpi_sdt_header_T* acpi_find_table (acpi_sdt_header_T* xsdt, string_t table_id); acpi_sdt_header_T* acpi_find_table (acpi_sdt_header_T* xsdt, string_t table_id);

View File

@ -0,0 +1,68 @@
// This file is part of noxos and licensed under the MIT open source license
#ifndef NOX_FADT_H
#define NOX_FADT_H
#include "drivers/acpi/acpi.h"
typedef struct {
acpi_sdt_header_T header;
uint32_t firmware_control;
uint32_t dsdt;
uint8_t reserved;
uint8_t preferred_power_management_profile;
uint16_t sci_interrupt;
uint32_t smi_command_port;
uint8_t apci_enable;
uint8_t apci_disable;
uint8_t s4_bios_request;
uint8_t pstate_control;
uint32_t pm1a_event_block;
uint32_t pm1b_event_block;
uint32_t pm1a_control_block;
uint32_t pm1b_control_block;
uint32_t pm2_control_block;
uint32_t pm_timer_block;
uint32_t gpe0_block;
uint32_t gpe1_block;
uint8_t pm1_event_length;
uint8_t pm1_control_length;
uint8_t pm2_control_length;
uint8_t pm_timer_length;
uint8_t gpe0_length;
uint8_t gpe1_length;
uint8_t gpe1_base;
uint8_t c_state_control;
uint16_t c2_worst_latency;
uint16_t c3_worst_latency;
uint16_t flush_size;
uint16_t flush_stride;
uint8_t duty_offset;
uint8_t duty_width;
uint8_t day_alarm;
uint8_t month_alarm;
uint8_t century;
uint16_t ia_boot_architecture_flags;
uint8_t reserved_2;
uint32_t flags;
acpi_gas_T reset_register;
uint8_t reset_value;
uint8_t reserved_3[3];
uint64_t x_firmware_control;
uint64_t x_dsdt;
acpi_gas_T x_pm1a_event_block;
acpi_gas_T x_pm1b_event_block;
acpi_gas_T x_pm1a_control_block;
acpi_gas_T x_pm1b_control_block;
acpi_gas_T x_pm2_control_block;
acpi_gas_T x_pm_timer_block;
acpi_gas_T x_gpe0_block;
acpi_gas_T x_gpe1_block;
acpi_gas_T sleep_control_register;
acpi_gas_T sleep_status_register;
uint64_t hypervisor_vendor_identity;
} __attribute__((packed)) acpi_fadt_T;
extern acpi_fadt_T* g_acpi_table_fadt;
#endif //NOX_FADT_H

View File

@ -2,8 +2,12 @@
#include "drivers/acpi/acpi.h" #include "drivers/acpi/acpi.h"
#include "drivers/acpi/rsdp.h" #include "drivers/acpi/rsdp.h"
#include "drivers/acpi/fadt.h"
#include "utils/logger.h" #include "utils/logger.h"
#include "utils/memory.h" #include "utils/memory.h"
#include "utils/panic.h"
acpi_fadt_T* g_acpi_table_fadt;
void acpi_init(boot_info_T* boot_info) { void acpi_init(boot_info_T* boot_info) {
log(LOG_INFO, "Initializing ACPI - RSDP: 0x%x", boot_info->rsdp); log(LOG_INFO, "Initializing ACPI - RSDP: 0x%x", boot_info->rsdp);
@ -22,8 +26,12 @@ void acpi_init(boot_info_T* boot_info) {
if (!rsdp_descriptor_v2_verify(boot_info->rsdp)) { if (!rsdp_descriptor_v2_verify(boot_info->rsdp)) {
log(LOG_WARNING, "<ACPI> RSDP header verification failed"); log(LOG_WARNING, "<ACPI> RSDP header verification failed");
} }
g_acpi_table_fadt = (acpi_fadt_T*)acpi_find_table((acpi_sdt_header_T*)((rsdp_descriptor_v2_T*)boot_info->rsdp)->xsdt_address, "FACP");
acpi_find_table(((rsdp_descriptor_v2_T*)boot_info->rsdp)->xsdt_address, "FACP"); if (g_acpi_table_fadt == NULL) {
panic(NULL, "<ACPI> FADT table not found");
}
log(LOG_INFO, "<ACPI> found FADT at address 0x%x", g_acpi_table_fadt);
break; break;
} }
default: { default: {