feature (acpi): implemented acpi table lookup
This commit is contained in:
parent
148dfe5a62
commit
ed977586a5
|
@ -4,7 +4,21 @@
|
||||||
#define NOX_ACPI_H
|
#define NOX_ACPI_H
|
||||||
|
|
||||||
#include "boot/boot_info.h"
|
#include "boot/boot_info.h"
|
||||||
|
#include "utils/string.h"
|
||||||
|
|
||||||
void acpi_init(boot_info_T* boot_info);
|
typedef struct {
|
||||||
|
char signature [4];
|
||||||
|
uint32_t length;
|
||||||
|
uint8_t revision;
|
||||||
|
uint8_t checksum;
|
||||||
|
char oem_id [6];
|
||||||
|
char oem_table_id [8];
|
||||||
|
uint32_t oem_revision;
|
||||||
|
uint32_t creator_id;
|
||||||
|
uint32_t creator_revision;
|
||||||
|
} __attribute__((packed)) acpi_sdt_header_T;
|
||||||
|
|
||||||
|
void acpi_init (boot_info_T* boot_info);
|
||||||
|
acpi_sdt_header_T* acpi_find_table (acpi_sdt_header_T* xsdt, string_t table_id);
|
||||||
|
|
||||||
#endif //NOX_ACPI_H
|
#endif //NOX_ACPI_H
|
||||||
|
|
|
@ -3,10 +3,12 @@
|
||||||
#include "drivers/acpi/acpi.h"
|
#include "drivers/acpi/acpi.h"
|
||||||
#include "drivers/acpi/rsdp.h"
|
#include "drivers/acpi/rsdp.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
#include "utils/memory.h"
|
||||||
|
|
||||||
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);
|
||||||
rsdp_descriptor_v1_T* rsdp = boot_info->rsdp;
|
rsdp_descriptor_v1_T* rsdp = boot_info->rsdp;
|
||||||
|
|
||||||
switch (rsdp->revision) {
|
switch (rsdp->revision) {
|
||||||
case 0: {
|
case 0: {
|
||||||
log(LOG_INFO, " Version: 1.0");
|
log(LOG_INFO, " Version: 1.0");
|
||||||
|
@ -20,6 +22,8 @@ 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
acpi_find_table(((rsdp_descriptor_v2_T*)boot_info->rsdp)->xsdt_address, "FACP");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
@ -27,4 +31,19 @@ void acpi_init(boot_info_T* boot_info) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
acpi_sdt_header_T* acpi_find_table(acpi_sdt_header_T* xsdt, string_t table_id) {
|
||||||
|
uint32_t num_entries = (xsdt->length - sizeof(acpi_sdt_header_T)) / 8;
|
||||||
|
|
||||||
|
uint64_t* sdt_list = (uint64_t*)&xsdt[1];
|
||||||
|
|
||||||
|
for (int i = 0; i < num_entries; i++) {
|
||||||
|
acpi_sdt_header_T* sdt = (acpi_sdt_header_T*)(sdt_list[i]);
|
||||||
|
if (!memory_compare(sdt->signature, (void*)table_id, 4)) continue;
|
||||||
|
return sdt;
|
||||||
|
}
|
||||||
|
|
||||||
|
log(LOG_WARNING, "<ACPI> table '%.4' not found (no matching xsdt entry)");
|
||||||
|
return NULL;
|
||||||
}
|
}
|
Loading…
Reference in New Issue