48 lines
1.2 KiB
C
48 lines
1.2 KiB
C
// SPDX-License-Identifier: ISC
|
|
|
|
#define pr_fmt(fmt) "acpi: " fmt
|
|
|
|
#include <zinnia/acpi.h>
|
|
#include <zinnia/alloc.h>
|
|
#include <zinnia/cmdline.h>
|
|
#include <zinnia/percpu.h>
|
|
#include <zinnia/print.h>
|
|
#include <zinnia/types.h>
|
|
#include <uacpi/status.h>
|
|
#include <uacpi/tables.h>
|
|
#include <uacpi/uacpi.h>
|
|
|
|
phys_t acpi_rsdp_addr = 0;
|
|
|
|
static char table_buf[0x1000];
|
|
|
|
static bool use_acpi = true;
|
|
void use_acpi_option(bool use) {
|
|
use_acpi = use;
|
|
}
|
|
CMDLINE_OPTION("acpi", "Enable ACPI firmware subsystem", use_acpi_option);
|
|
|
|
[[__init]]
|
|
static bool acpi_stage_init(struct boot_info* info) {
|
|
if (!use_acpi) {
|
|
log_warn("ACPI disabled on the command line!\n");
|
|
return false;
|
|
}
|
|
|
|
if (!info->rsdp) {
|
|
log_warn("No RSDP was passed, unable to start ACPI subsystem!\n");
|
|
return false;
|
|
}
|
|
acpi_rsdp_addr = info->rsdp;
|
|
|
|
if (uacpi_setup_early_table_access(table_buf, sizeof(table_buf)) != UACPI_STATUS_OK) {
|
|
log_err("Failed to set up early table access!\n");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
INIT_TASK(acpi_stage, "dev.acpi", acpi_stage_init);
|
|
INIT_DEPENDS(acpi_stage, mem_stage);
|
|
INIT_ENTAILS(acpi_stage, percpu_stage);
|