74 LOG_ERR(
"invalid XSDT signature\n");
85 LOG_ERR(
"invalid RSDP signature\n");
91 LOG_ERR(
"invalid RSDP checksum\n");
97 LOG_ERR(
"invalid extended RSDP checksum\n");
108 LOG_ERR(
"invalid extended RSDP checksum\n");
124 if (cachedTable ==
NULL)
126 LOG_ERR(
"failed to allocate memory for ACPI table\n");
134 LOG_ERR(
"failed to allocate memory for ACPI table cache\n");
153 for (
uint64_t i = 0; i < amountOfTablesInXsdt; i++)
171 LOG_ERR(
"failed to find FACP table\n");
177 LOG_ERR(
"failed to cache DSDT table\n");
190 if (handler->init(table) ==
ERR)
213 panic(
NULL,
"failed to load ACPI tables from XSDT\n");
218 panic(
NULL,
"failed to load ACPI tables from FADT\n");
240 panic(
NULL,
"failed to create ACPI tables sysfs directory");
270 LOG_ERR(
"invalid signature length\n");
#define MAX_PATH
Maximum length of filepaths.
#define assert(expression)
#define FADT_GET()
Type safe way to get the FADT table.
void acpi_tables_init(rsdp_t *rsdp)
Initialize ACPI tables and call their init handlers.
sdt_header_t * acpi_tables_lookup(const char *signature, uint64_t n)
Lookup the n'th table matching the signature.
void acpi_tables_expose(void)
Expose ACPI tables to sysfs.
#define RSDP_CURRENT_REVISION
The expected value of the revision field in the RSDP structure.
dentry_t * acpi_get_sysfs_root(void)
Retrieve the sysfs root directory for ACPI.
#define SDT_OEM_ID_LENGTH
The length of the OEM ID field in the SDT header structure.
#define RSDP_V1_LENGTH
Length of the RSDP structure for ACPI version 1.0.
bool acpi_is_checksum_valid(void *table, uint64_t length)
Check if the sum of all bytes in a table is 0.
#define SDT_SIGNATURE_LENGTH
The length of the signature field in the SDT header structure.
#define RSDP_SIGNATURE_LENGTH
Length of the signature field in the RSDP structure.
#define BUFFER_READ(buffer, count, offset, src, size)
Helper macros for implementing file operations dealing with simple buffers.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
#define LOG_ERR(format,...)
#define LOG_INFO(format,...)
#define PML_LOWER_TO_HIGHER(addr)
Converts an address from the lower half to the higher half.
#define DEREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define EINVAL
Invalid argument.
#define errno
Error number variable.
#define NULL
Pointer error value.
#define ERR
Integer error value.
EFI_PHYSICAL_ADDRESS buffer
_PUBLIC int snprintf(char *_RESTRICT s, size_t n, const char *_RESTRICT format,...)
_PUBLIC void * realloc(void *ptr, size_t size)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
_PUBLIC int memcmp(const void *s1, const void *s2, size_t n)
_PUBLIC void * memcpy(void *_RESTRICT s1, const void *_RESTRICT s2, size_t n)
_PUBLIC size_t strlen(const char *s)
dentry_t * file
The sysfs file representing the table.
ACPI System Description Table handler.
Directory entry structure.
Fixed ACPI Description Table.
File operations structure.
uint64_t(* read)(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
Root System Description Pointer.
char signature[RSDP_SIGNATURE_LENGTH]
Extended System Description Table.
dentry_t * sysfs_dir_new(dentry_t *parent, const char *name, const inode_ops_t *inodeOps, void *private)
Create a new directory inside a mounted SysFS instance.
dentry_t * sysfs_file_new(dentry_t *parent, const char *name, const inode_ops_t *inodeOps, const file_ops_t *fileOps, void *private)
Create a new file inside a mounted SysFS instance.
static uint64_t acpi_table_read(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
static bool acpi_is_xsdt_valid(xsdt_t *xsdt)
static uint64_t acpi_tables_push(sdt_header_t *table)
static uint64_t acpi_tables_load_from_fadt(void)
const acpi_sdt_handler_t _acpiSdtHandlersEnd[]
static uint64_t ssdtAmount
static uint64_t tableAmount
static dentry_t * tablesDir
static acpi_cached_table_t * cachedTables
const acpi_sdt_handler_t _acpiSdtHandlersStart[]
static file_ops_t tableFileOps
static bool acpi_is_table_valid(sdt_header_t *table)
static bool acpi_is_rsdp_valid(rsdp_t *rsdp)
static uint64_t acpi_tables_load_from_xsdt(xsdt_t *xsdt)
static uint64_t acpi_tables_init_handlers(sdt_header_t *table)