1 | #pragma once |
2 | |
3 | #include <uacpi/types.h> |
4 | #include <uacpi/status.h> |
5 | |
6 | #ifdef __cplusplus |
7 | extern "C" { |
8 | #endif |
9 | |
10 | typedef struct uacpi_table_identifiers { |
11 | uacpi_object_name signature; |
12 | |
13 | // if oemid[0] == 0 this field is ignored |
14 | char oemid[6]; |
15 | |
16 | // if oem_table_id[0] == 0 this field is ignored |
17 | char oem_table_id[8]; |
18 | } uacpi_table_identifiers; |
19 | |
20 | typedef struct uacpi_table { |
21 | union { |
22 | uacpi_virt_addr virt_addr; |
23 | void *ptr; |
24 | struct acpi_sdt_hdr *hdr; |
25 | }; |
26 | |
27 | // Index number used to identify this table internally |
28 | uacpi_size index; |
29 | } uacpi_table; |
30 | |
31 | /* |
32 | * Install a table from either a virtual or a physical address. |
33 | * The table is simply stored in the internal table array, and not loaded by |
34 | * the interpreter (see uacpi_table_load). |
35 | * |
36 | * The table is optionally returned via 'out_table'. |
37 | * |
38 | * Manual calls to uacpi_table_install are not subject to filtering via the |
39 | * table installation callback (if any). |
40 | */ |
41 | uacpi_status uacpi_table_install( |
42 | void*, uacpi_table *out_table |
43 | ); |
44 | uacpi_status uacpi_table_install_physical( |
45 | uacpi_phys_addr, uacpi_table *out_table |
46 | ); |
47 | |
48 | /* |
49 | * Load a previously installed table by feeding it to the interpreter. |
50 | */ |
51 | uacpi_status uacpi_table_load(uacpi_size index); |
52 | |
53 | uacpi_status uacpi_table_find_by_signature( |
54 | const uacpi_char *signature, uacpi_table *out_table |
55 | ); |
56 | uacpi_status uacpi_table_find_next_with_same_signature( |
57 | uacpi_table *in_out_table |
58 | ); |
59 | uacpi_status uacpi_table_find( |
60 | const uacpi_table_identifiers *id, uacpi_table *out_table |
61 | ); |
62 | |
63 | /* |
64 | * Returns the pointer to a sanitized internal version of FADT. |
65 | * |
66 | * The revision is guaranteed to be correct. All of the registers are converted |
67 | * to GAS format. Fields that might contain garbage are cleared. |
68 | */ |
69 | uacpi_status uacpi_table_fadt(struct acpi_fadt**); |
70 | |
71 | typedef enum uacpi_table_installation_disposition { |
72 | // Allow the table to be installed as-is |
73 | UACPI_TABLE_INSTALLATION_DISPOSITON_ALLOW = 0, |
74 | |
75 | /* |
76 | * Deny the table from being installed completely. This is useful for |
77 | * debugging various problems, e.g. AML loading bad SSDTs that cause the |
78 | * system to hang or enter an undesired state. |
79 | */ |
80 | UACPI_TABLE_INSTALLATION_DISPOSITON_DENY, |
81 | |
82 | /* |
83 | * Override the table being installed with the table at the virtual address |
84 | * returned in 'out_override_address'. |
85 | */ |
86 | UACPI_TABLE_INSTALLATION_DISPOSITON_VIRTUAL_OVERRIDE, |
87 | |
88 | /* |
89 | * Override the table being installed with the table at the physical address |
90 | * returned in 'out_override_address'. |
91 | */ |
92 | UACPI_TABLE_INSTALLATION_DISPOSITON_PHYSICAL_OVERRIDE, |
93 | } uacpi_table_installation_disposition; |
94 | |
95 | typedef uacpi_table_installation_disposition (*uacpi_table_installation_handler) |
96 | (struct acpi_sdt_hdr *hdr, uacpi_u64 *out_override_address); |
97 | |
98 | /* |
99 | * Set a handler that is invoked for each table before it gets installed. |
100 | * |
101 | * Depending on the return value, the table is either allowed to be installed |
102 | * as-is, denied, or overriden with a new one. |
103 | */ |
104 | uacpi_status uacpi_set_table_installation_handler( |
105 | uacpi_table_installation_handler handler |
106 | ); |
107 | |
108 | #ifdef __cplusplus |
109 | } |
110 | #endif |
111 | |