1#pragma once
2
3#include <uacpi/internal/context.h>
4#include <uacpi/internal/interpreter.h>
5#include <uacpi/types.h>
6#include <uacpi/status.h>
7#include <uacpi/tables.h>
8
9enum uacpi_table_origin {
10 UACPI_TABLE_ORIGIN_FIRMWARE_VIRTUAL = 0,
11 UACPI_TABLE_ORIGIN_FIRMWARE_PHYSICAL,
12
13 UACPI_TABLE_ORIGIN_HOST_VIRTUAL,
14 UACPI_TABLE_ORIGIN_HOST_PHYSICAL,
15};
16
17struct uacpi_installed_table {
18 uacpi_object_name signature;
19 uacpi_phys_addr phys_addr;
20 union {
21 void *ptr;
22 struct acpi_sdt_hdr *hdr;
23 };
24 uacpi_u32 length;
25
26#define UACPI_TABLE_LOADED (1 << 0)
27 uacpi_u8 flags;
28 uacpi_u8 origin;
29};
30
31uacpi_status uacpi_initialize_tables(void);
32
33uacpi_status uacpi_check_table_signature(void *table, const uacpi_char *expect);
34uacpi_status uacpi_verify_table_checksum(void *table, uacpi_size size);
35
36uacpi_status uacpi_table_install_physical_with_origin(
37 uacpi_phys_addr phys, enum uacpi_table_origin origin, uacpi_table *out_table
38);
39uacpi_status uacpi_table_install_with_origin(
40 void *virt, enum uacpi_table_origin origin, uacpi_table *out_table
41);
42
43void uacpi_table_mark_as_loaded(uacpi_size idx);
44
45uacpi_status uacpi_table_load_with_cause(
46 uacpi_size idx, enum uacpi_table_load_cause cause
47);
48
49enum uacpi_table_iteration_decision {
50 UACPI_TABLE_ITERATION_DECISION_CONTINUE,
51 UACPI_TABLE_ITERATION_DECISION_BREAK,
52};
53typedef enum uacpi_table_iteration_decision (*uacpi_table_iteration_callback)
54 (void *user, struct uacpi_installed_table *tbl, uacpi_size idx);
55
56uacpi_status uacpi_for_each_table(
57 uacpi_size base_idx, uacpi_table_iteration_callback, void *user
58);
59
60typedef uacpi_bool (*uacpi_table_match_callback)
61 (struct uacpi_installed_table *tbl);
62
63uacpi_status uacpi_table_match(
64 uacpi_size base_idx, uacpi_table_match_callback, uacpi_table *out_table
65);
66
67#define UACPI_PRI_TBL_HDR "'%.4s' (OEM ID '%.6s' OEM Table ID '%.8s')"
68#define UACPI_FMT_TBL_HDR(hdr) (hdr)->signature, (hdr)->oemid, (hdr)->oem_table_id
69