1 | #pragma once |
2 | |
3 | #include <uacpi/types.h> |
4 | #include <uacpi/status.h> |
5 | #include <uacpi/kernel_api.h> |
6 | #include <uacpi/namespace.h> |
7 | |
8 | #ifdef UACPI_REDUCED_HARDWARE |
9 | #define UACPI_MAKE_STUB_FOR_REDUCED_HARDWARE(fn, ret) \ |
10 | UACPI_NO_UNUSED_PARAMETER_WARNINGS_BEGIN \ |
11 | static inline fn { return ret; } \ |
12 | UACPI_NO_UNUSED_PARAMETER_WARNINGS_END |
13 | |
14 | #define UACPI_STUB_IF_REDUCED_HARDWARE(fn) \ |
15 | UACPI_MAKE_STUB_FOR_REDUCED_HARDWARE(fn,) |
16 | #define UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE(fn) \ |
17 | UACPI_MAKE_STUB_FOR_REDUCED_HARDWARE(fn, UACPI_STATUS_COMPILED_OUT) |
18 | #define UACPI_ALWAYS_OK_FOR_REDUCED_HARDWARE(fn) \ |
19 | UACPI_MAKE_STUB_FOR_REDUCED_HARDWARE(fn, UACPI_STATUS_OK) |
20 | #else |
21 | |
22 | #define UACPI_STUB_IF_REDUCED_HARDWARE(fn) fn; |
23 | #define UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE(fn) fn; |
24 | #define UACPI_ALWAYS_OK_FOR_REDUCED_HARDWARE(fn) fn; |
25 | #endif |
26 | |
27 | #ifdef __cplusplus |
28 | extern "C" { |
29 | #endif |
30 | |
31 | typedef struct uacpi_init_params { |
32 | // Physical address of the RSDP structure. |
33 | uacpi_phys_addr rsdp; |
34 | |
35 | // Initial log level, all logs above this level are discarded |
36 | uacpi_log_level log_level; |
37 | |
38 | /* |
39 | * Bad table checksum should be considered a fatal error |
40 | * (table load is fully aborted in this case) |
41 | */ |
42 | #define UACPI_FLAG_BAD_CSUM_FATAL (1 << 0) |
43 | |
44 | /* |
45 | * Unexpected table signature should be considered a fatal error |
46 | * (table load is fully aborted in this case) |
47 | */ |
48 | #define UACPI_FLAG_BAD_TBL_SIGNATURE_FATAL (1 << 1) |
49 | |
50 | /* |
51 | * Force uACPI to use RSDT even for later revisions |
52 | */ |
53 | #define UACPI_FLAG_BAD_XSDT (1 << 2) |
54 | |
55 | /* |
56 | * If this is set, ACPI mode is not entered during the call to |
57 | * uacpi_initialize. The caller is expected to enter it later at thier own |
58 | * discretion by using uacpi_enter_acpi_mode(). |
59 | */ |
60 | #define UACPI_FLAG_NO_ACPI_MODE (1 << 3) |
61 | |
62 | /* |
63 | * Don't create the \_OSI method when building the namespace. |
64 | * Only enable this if you're certain that having this method breaks your AML |
65 | * blob, a more atomic/granular interface management is available via osi.h |
66 | */ |
67 | #define UACPI_FLAG_NO_OSI (1 << 4) |
68 | uacpi_u64 flags; |
69 | } uacpi_init_params; |
70 | |
71 | /* |
72 | * Initializes the uACPI subsystem, iterates & records all relevant RSDT/XSDT |
73 | * tables. Enters ACPI mode. |
74 | */ |
75 | uacpi_status uacpi_initialize(const struct uacpi_init_params*); |
76 | |
77 | /* |
78 | * Parses & executes all of the DSDT/SSDT tables. |
79 | * Initializes the event subsystem. |
80 | */ |
81 | uacpi_status uacpi_namespace_load(void); |
82 | |
83 | /* |
84 | * Initializes all the necessary objects in the namespaces by calling |
85 | * _STA/_INI etc. |
86 | */ |
87 | uacpi_status uacpi_namespace_initialize(void); |
88 | |
89 | /* |
90 | * Evaluate an object within the namespace and get back its value. |
91 | * Either root or path must be valid. |
92 | * A value of NULL for 'parent' implies uacpi_namespace_root() relative |
93 | * lookups, unless 'path' is already absolute. |
94 | */ |
95 | uacpi_status uacpi_eval(uacpi_namespace_node *parent, const uacpi_char *path, |
96 | const uacpi_args *args, uacpi_object **ret); |
97 | |
98 | /* |
99 | * Same as uacpi_eval, but the return value type is validated against |
100 | * the 'ret_mask'. UACPI_STATUS_TYPE_MISMATCH is returned on error. |
101 | */ |
102 | uacpi_status uacpi_eval_typed( |
103 | uacpi_namespace_node *parent, const uacpi_char *path, |
104 | const uacpi_args *args, uacpi_u32 ret_mask, uacpi_object **ret |
105 | ); |
106 | |
107 | /* |
108 | * A shorthand for uacpi_eval_typed with UACPI_OBJECT_INTEGER_BIT. |
109 | */ |
110 | uacpi_status uacpi_eval_integer( |
111 | uacpi_namespace_node *parent, const uacpi_char *path, |
112 | const uacpi_args *args, uacpi_u64 *out_value |
113 | ); |
114 | |
115 | /* |
116 | * Helpers for entering & leaving ACPI mode. Note that ACPI mode is entered |
117 | * automatically during the call to uacpi_initialize(). |
118 | */ |
119 | UACPI_ALWAYS_OK_FOR_REDUCED_HARDWARE( |
120 | uacpi_status uacpi_enter_acpi_mode(void) |
121 | ) |
122 | UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE( |
123 | uacpi_status uacpi_leave_acpi_mode(void) |
124 | ) |
125 | |
126 | /* |
127 | * Attempt to acquire the global lock for 'timeout' milliseconds. |
128 | * 0xFFFF implies infinite wait. |
129 | * |
130 | * On success, 'out_seq' is set to a unique sequence number for the current |
131 | * acquire transaction. This number is used for validation during release. |
132 | */ |
133 | uacpi_status uacpi_acquire_global_lock(uacpi_u16 timeout, uacpi_u32 *out_seq); |
134 | uacpi_status uacpi_release_global_lock(uacpi_u32 seq); |
135 | |
136 | #ifdef __cplusplus |
137 | } |
138 | #endif |
139 | |