ReactOS 0.4.16-dev-1946-g52006dd
uacpi.h
Go to the documentation of this file.
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#define UACPI_MAJOR 2
9#define UACPI_MINOR 1
10#define UACPI_PATCH 1
11
12#ifdef UACPI_REDUCED_HARDWARE
13#define UACPI_MAKE_STUB_FOR_REDUCED_HARDWARE(fn, ret) \
14 UACPI_NO_UNUSED_PARAMETER_WARNINGS_BEGIN \
15 static inline fn { return ret; } \
16 UACPI_NO_UNUSED_PARAMETER_WARNINGS_END
17
18#define UACPI_STUB_IF_REDUCED_HARDWARE(fn) \
19 UACPI_MAKE_STUB_FOR_REDUCED_HARDWARE(fn,)
20#define UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE(fn) \
21 UACPI_MAKE_STUB_FOR_REDUCED_HARDWARE(fn, UACPI_STATUS_COMPILED_OUT)
22#define UACPI_ALWAYS_OK_FOR_REDUCED_HARDWARE(fn) \
23 UACPI_MAKE_STUB_FOR_REDUCED_HARDWARE(fn, UACPI_STATUS_OK)
24#else
25
26#define UACPI_STUB_IF_REDUCED_HARDWARE(fn) fn;
27#define UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE(fn) fn;
28#define UACPI_ALWAYS_OK_FOR_REDUCED_HARDWARE(fn) fn;
29#endif
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/*
36 * Set up early access to the table subsystem. What this means is:
37 * - uacpi_table_find() and similar API becomes usable before the call to
38 * uacpi_initialize().
39 * - No kernel API besides logging and map/unmap will be invoked at this stage,
40 * allowing for heap and scheduling to still be fully offline.
41 * - The provided 'temporary_buffer' will be used as a temporary storage for the
42 * internal metadata about the tables (list, reference count, addresses,
43 * sizes, etc).
44 * - The 'temporary_buffer' is replaced with a normal heap buffer allocated via
45 * uacpi_kernel_alloc() after the call to uacpi_initialize() and can therefore
46 * be reclaimed by the kernel.
47 *
48 * The approximate overhead per table is 56 bytes, so a buffer of 4096 bytes
49 * yields about 73 tables in terms of capacity. uACPI also has an internal
50 * static buffer for tables, "UACPI_STATIC_TABLE_ARRAY_LEN", which is configured
51 * as 16 descriptors in length by default.
52 *
53 * This function is used to initialize the barebones mode, see
54 * UACPI_BAREBONES_MODE in config.h for more information.
55 */
58);
59
60/*
61 * Bad table checksum should be considered a fatal error
62 * (table load is fully aborted in this case)
63 */
64#define UACPI_FLAG_BAD_CSUM_FATAL (1ull << 0)
65
66/*
67 * Unexpected table signature should be considered a fatal error
68 * (table load is fully aborted in this case)
69 */
70#define UACPI_FLAG_BAD_TBL_SIGNATURE_FATAL (1ull << 1)
71
72/*
73 * Force uACPI to use RSDT even for later revisions
74 */
75#define UACPI_FLAG_BAD_XSDT (1ull << 2)
76
77/*
78 * If this is set, ACPI mode is not entered during the call to
79 * uacpi_initialize. The caller is expected to enter it later at their own
80 * discretion by using uacpi_enter_acpi_mode().
81 */
82#define UACPI_FLAG_NO_ACPI_MODE (1ull << 3)
83
84/*
85 * Don't create the \_OSI method when building the namespace.
86 * Only enable this if you're certain that having this method breaks your AML
87 * blob, a more atomic/granular interface management is available via osi.h
88 */
89#define UACPI_FLAG_NO_OSI (1ull << 4)
90
91/*
92 * Validate table checksums at installation time instead of first use.
93 * Note that this makes uACPI map the entire table at once, which not all
94 * hosts are able to handle at early init.
95 */
96#define UACPI_FLAG_PROACTIVE_TBL_CSUM (1ull << 5)
97
98#ifndef UACPI_BAREBONES_MODE
99
100/*
101 * Initializes the uACPI subsystem, iterates & records all relevant RSDT/XSDT
102 * tables. Enters ACPI mode.
103 *
104 * 'flags' is any combination of UACPI_FLAG_* above
105 */
107
108/*
109 * Parses & executes all of the DSDT/SSDT tables.
110 * Initializes the event subsystem.
111 */
113
114/*
115 * Initializes all the necessary objects in the namespaces by calling
116 * _STA/_INI etc.
117 */
119
120// Returns the current subsystem initialization level
122
123/*
124 * Evaluate an object within the namespace and get back its value.
125 * Either root or path must be valid.
126 * A value of NULL for 'parent' implies uacpi_namespace_root() relative
127 * lookups, unless 'path' is already absolute.
128 */
132);
135);
136
137/*
138 * Same as uacpi_eval() but without a return value.
139 */
143);
146);
147
148/*
149 * Same as uacpi_eval, but the return value type is validated against
150 * the 'ret_mask'. UACPI_STATUS_TYPE_MISMATCH is returned on error.
151 */
156);
160);
161
162/*
163 * A shorthand for uacpi_eval_typed with UACPI_OBJECT_INTEGER_BIT.
164 */
167 const uacpi_object_array *args, uacpi_u64 *out_value
168);
171);
172
173/*
174 * A shorthand for uacpi_eval_typed with
175 * UACPI_OBJECT_BUFFER_BIT | UACPI_OBJECT_STRING_BIT
176 *
177 * Use uacpi_object_get_string_or_buffer to retrieve the resulting buffer data.
178 */
182);
185);
186
187/*
188 * A shorthand for uacpi_eval_typed with UACPI_OBJECT_STRING_BIT.
189 *
190 * Use uacpi_object_get_string to retrieve the resulting buffer data.
191 */
195);
198);
199
200/*
201 * A shorthand for uacpi_eval_typed with UACPI_OBJECT_BUFFER_BIT.
202 *
203 * Use uacpi_object_get_buffer to retrieve the resulting buffer data.
204 */
208);
211);
212
213/*
214 * A shorthand for uacpi_eval_typed with UACPI_OBJECT_PACKAGE_BIT.
215 *
216 * Use uacpi_object_get_package to retrieve the resulting object array.
217 */
221);
224);
225
226/*
227 * Get the bitness of the currently loaded AML code according to the DSDT.
228 *
229 * Returns either 32 or 64.
230 */
232
233/*
234 * Helpers for entering & leaving ACPI mode. Note that ACPI mode is entered
235 * automatically during the call to uacpi_initialize().
236 */
239)
242)
243
244/*
245 * Attempt to acquire the global lock for 'timeout' milliseconds.
246 * 0xFFFF implies infinite wait.
247 *
248 * On success, 'out_seq' is set to a unique sequence number for the current
249 * acquire transaction. This number is used for validation during release.
250 */
253
254#endif // !UACPI_BAREBONES_MODE
255
256/*
257 * Reset the global uACPI state by freeing all internally allocated data
258 * structures & resetting any global variables. After this call, uACPI must be
259 * re-initialized from scratch to be used again.
260 *
261 * This is called by uACPI automatically if a fatal error occurs during a call
262 * to uacpi_initialize/uacpi_namespace_load etc. in order to prevent accidental
263 * use of partially uninitialized subsystems.
264 */
265void uacpi_state_reset(void);
266
267#ifdef __cplusplus
268}
269#endif
size_t uacpi_size
Definition: types.h:37
uint32_t uacpi_u32
Definition: types.h:21
uint64_t uacpi_u64
Definition: types.h:22
char uacpi_char
Definition: types.h:44
uint16_t uacpi_u16
Definition: types.h:20
uint8_t uacpi_u8
Definition: types.h:19
uacpi_status
Definition: status.h:10
uacpi_object_type_bits
Definition: types.h:128
uacpi_init_level
Definition: types.h:58
return ret
Definition: mutex.c:146
uacpi_status uacpi_acquire_global_lock(uacpi_u16 timeout, uacpi_u32 *out_seq)
Definition: mutex.c:149
r parent
Definition: btrfs.c:3010
GLbitfield flags
Definition: glext.h:7161
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
Definition: match.c:390
Definition: dhcpd.h:248
uacpi_status uacpi_enter_acpi_mode(void)
Definition: uacpi.c:282
uacpi_status uacpi_leave_acpi_mode(void)
Definition: uacpi.c:287
uacpi_status uacpi_eval_simple_string(uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object **ret)
Definition: uacpi.c:942
uacpi_status uacpi_eval_simple(uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object **ret)
Definition: uacpi.c:777
uacpi_status uacpi_namespace_load(void)
Definition: uacpi.c:427
void uacpi_state_reset(void)
Definition: uacpi.c:123
uacpi_status uacpi_release_global_lock(uacpi_u32 seq)
Definition: mutex.c:178
#define UACPI_ALWAYS_ERROR_FOR_REDUCED_HARDWARE(fn)
Definition: uacpi.h:27
uacpi_status uacpi_eval_string(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **ret)
Definition: uacpi.c:932
uacpi_init_level uacpi_get_current_init_level(void)
Definition: uacpi.c:300
uacpi_u32 * out_seq
Definition: uacpi.h:251
uacpi_status uacpi_eval_simple_buffer(uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object **ret)
Definition: uacpi.c:961
#define UACPI_ALWAYS_OK_FOR_REDUCED_HARDWARE(fn)
Definition: uacpi.h:28
uacpi_status uacpi_eval_integer(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_u64 *out_value)
Definition: uacpi.c:882
uacpi_status uacpi_namespace_initialize(void)
Definition: uacpi.c:610
uacpi_status uacpi_get_aml_bitness(uacpi_u8 *out_bitness)
Definition: uacpi.c:989
uacpi_status uacpi_eval(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **ret)
Definition: uacpi.c:699
uacpi_status uacpi_initialize(uacpi_u64 flags)
Definition: uacpi.c:305
uacpi_status uacpi_eval_buffer_or_string(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **ret)
Definition: uacpi.c:909
uacpi_status uacpi_execute(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args)
Definition: uacpi.c:784
uacpi_status uacpi_eval_simple_integer(uacpi_namespace_node *parent, const uacpi_char *path, uacpi_u64 *out_value)
Definition: uacpi.c:902
uacpi_status uacpi_execute_simple(uacpi_namespace_node *parent, const uacpi_char *path)
Definition: uacpi.c:792
uacpi_status uacpi_eval_buffer(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **ret)
Definition: uacpi.c:951
uacpi_status uacpi_eval_simple_typed(uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object_type_bits ret_mask, uacpi_object **ret)
Definition: uacpi.c:874
uacpi_status uacpi_eval_package(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object **ret)
Definition: uacpi.c:970
uacpi_status uacpi_eval_typed(uacpi_namespace_node *parent, const uacpi_char *path, const uacpi_object_array *args, uacpi_object_type_bits ret_mask, uacpi_object **ret)
Definition: uacpi.c:844
uacpi_status uacpi_eval_simple_buffer_or_string(uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object **ret)
Definition: uacpi.c:921
uacpi_status uacpi_setup_early_table_access(void *temporary_buffer, uacpi_size buffer_size)
Definition: tables.c:199
uacpi_status uacpi_eval_simple_package(uacpi_namespace_node *parent, const uacpi_char *path, uacpi_object **ret)
Definition: uacpi.c:980