PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
data.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <stdbool.h>
6#include <stdint.h>
7
8typedef struct aml_object aml_object_t;
9typedef struct aml_package aml_package_t;
10typedef struct aml_term_list_ctx aml_term_list_ctx_t;
11
12/**
13 * @brief Data Objects Encoding
14 * @defgroup modules_acpi_aml_encoding_data Data Objects
15 * @ingroup modules_acpi_aml
16 *
17 * @see Section 20.2.3 of the ACPI specification for more details.
18 *
19 * @{
20 */
21
22/**
23 * @brief Read a ByteData structure from the AML stream.
24 *
25 * A ByteData structure is defined as `ByteData := 0x00 - 0xFF`.
26 *
27 * @param ctx The context of the TermList that this structure is part of.
28 * @param out Output pointer where the byte value will be stored.
29 * @return On success, `0`. On failure, `ERR` and `errno` is set.
30 */
32
33/**
34 * @brief Read a WordData structure from the AML stream.
35 *
36 * A WordData structure is defined as `WordData := ByteData[0:7] ByteData[8:15]`.
37 *
38 * @param ctx The context of the TermList that this structure is part of.
39 * @param out Output pointer where the word value will be stored.
40 * @return On success, `0`. On failure, `ERR` and `errno` is set.
41 */
43
44/**
45 * @brief Read a DWordData structure from the AML stream.
46 *
47 * A DWordData structure is defined as `DWordData := WordData[0:15] WordData[16:31]`.
48 *
49 * @param ctx The context of the TermList that this structure is part of.
50 * @param out Output pointer where the dword value will be stored.
51 * @return On success, `0`. On failure, `ERR` and `errno` is set.
52 */
54
55/**
56 * @brief Read a QWordData structure from the AML stream.
57 *
58 * A QWordData structure is defined as `QWordData := DWordData[0:31] DWordData[32:63]`.
59 *
60 * @param ctx The context of the TermList that this structure is part of.
61 * @param out Output pointer to the qword value will be stored.
62 * @return On success, `0`. On failure, `ERR` and `errno` is set.
63 */
65
66/**
67 * @brief Read a ByteConst structure from the AML stream.
68 *
69 * A ByteConst structure is defined as `ByteConst := BytePrefix ByteData`.
70 *
71 * @param ctx The context of the TermList that this structure is part of.
72 * @param out Output pointer to the byte value will be stored.
73 * @return On success, `0`. On failure, `ERR` and `errno` is set.
74 */
76
77/**
78 * @brief Read a WordConst structure from the AML stream.
79 *
80 * A WordConst structure is defined as `WordConst := WordPrefix WordData`.
81 *
82 * @param ctx The context of the TermList that this structure is part of.
83 * @param out Output pointer to the word value will be stored.
84 * @return On success, `0`. On failure, `ERR` and `errno` is set.
85 */
87
88/**
89 * @brief Read a DWordConst structure from the AML stream.
90 *
91 * A DWordConst structure is defined as `DwordConst := DWordPrefix DWordData`.
92 *
93 * @param ctx The context of the TermList that this structure is part of.
94 * @param out Output pointer to the dword value will be stored.
95 * @return On success, `0`. On failure, `ERR` and `errno` is set.
96 */
98
99/**
100 * @brief Read a QWordConst structure from the AML stream.
101 *
102 * A QWordConst structure is defined as `QWordConst := QWordPrefix QWordData`.
103 *
104 * @param ctx The context of the TermList that this structure is part of.
105 * @param out Output pointer to the qword value will be stored.
106 * @return On success, `0`. On failure, `ERR` and `errno` is set.
107 */
109
110/**
111 * @brief Read a ConstObj structure from the AML stream.
112 *
113 * A ConstObj structure is defined as `ConstObj := ZeroOp | OneOp | OnesOp`.
114 *
115 * @see Sections 19.6.98, 19.6.99 and 19.6.156 for more details.
116 *
117 * @param ctx The context of the TermList that this structure is part of.
118 * @param out Output pointer to the object to store the result.
119 * @return On success, `0`. On failure, `ERR` and `errno` is set.
120 */
122
123/**
124 * @brief Read a String structure from the AML stream.
125 *
126 * A String structure is defined as `String := StringPrefix AsciiCharList NullChar`.
127 *
128 * AsciiCharList is defined as a sequence of ASCII characters in the range 0x01 to 0x7F, and NullChar is defined as
129 * 0x00.
130 *
131 * @param ctx The context of the TermList that this structure is part of.
132 * @param out Output pointer to the object to store the result.
133 * @return On success, `0`. On failure, `ERR` and `errno` is set.
134 */
136
137/**
138 * @brief Read a RevisionOp structure from the AML stream.
139 *
140 * A RevisionOp structure is defined as `RevisionOp := RevisionOp`.
141 *
142 * @see Section 19.6.121 of the ACPI specification for more details.
143 *
144 * @param ctx The context of the TermList that this structure is part of.
145 * @param out Output pointer to the object to store the result.
146 * @return On success, `0`. On failure, `ERR` and `errno` is set.
147 */
149
150/**
151 * @brief Read a ComputationalData structure from the AML stream.
152 *
153 * A ComputationalData structure is defined as `ComputationalData := ByteConst | WordConst | DWordConst | QWordConst |
154 * String | ConstObj | RevisionOp | DefBuffer`.
155 *
156 * @param ctx The context of the TermList that this structure is part of.
157 * @param out Output pointer to the object to store the result.
158 * @return On success, `0`. On failure, `ERR` and `errno` is set.
159 */
161
162/**
163 * @brief Read a NumElements structure from the AML stream.
164 *
165 * A NumElements structure is defined as `NumElements := ByteData`.
166 *
167 * @param ctx The context of the TermList that this structure is part of.
168 * @param out Output pointer to the integer to be filled with the number of elements.
169 * @return On success, `0`. On failure, `ERR` and `errno` is set.
170 */
172
173/**
174 * @brief Read a PackageElement structure from the AML stream.
175 *
176 * A PackageElement structure is defined as `PackageElement := DataRefObject | NameString`.
177 *
178 * @see Section 19.6.102 of the ACPI specification for more details.
179 *
180 * @param ctx The context of the TermList that this structure is part of.
181 * @param out Pointer to the object to initialize with the read element.
182 * @return On success, `0`. On failure, `ERR` and `errno` is set.
183 */
185
186/**
187 * @brief Read a PackageElementList structure from the AML stream.
188 *
189 * A PackageElementList structure is defined as PackageElementList := Nothing | <packageelement packageelementlist>`.
190 *
191 * @param ctx The context of the TermList that this structure is part of.
192 * @param package Pointer to the package to fill with the read elements.
193 * @param end Pointer to the end of the PackageElementList.
194 * @return On success, `0`. On failure, `ERR` and `errno` is set.
195 */
197
198/**
199 * @brief Reads a DefPackage structure from the AML byte stream.
200 *
201 * A DefPackage structure is defined as `DefPackage := PackageOp PkgLength NumElements PackageElementList`.
202 *
203 * @see Section 19.6.102 of the ACPI specification for more details.
204 *
205 * @param ctx The context of the TermList that this structure is part of.
206 * @param out Output pointer to the object to store the result.
207 * @return On success, `0`. On failure, `ERR` and `errno` is set.
208 */
210
211/**
212 * @brief Read a VarNumElements structure from the AML stream.
213 *
214 * A VarNumElements structure is defined as `VarNumElements := TermArg => Integer`.
215 *
216 * @param ctx The context of the TermList that this structure is part of.
217 * @param out Output pointer to the integer to be filled with the number of elements.
218 * @return On success, `0`. On failure, `ERR` and `errno` is set.
219 */
221
222/**
223 * @brief Reads a DefVarPackage structure from the AML byte stream.
224 *
225 * A DefVarPackage structure is defined as `DefVarPackage := VarPackageOp PkgLength VarNumElements PackageElementList`.
226 *
227 * @see Section 19.6.103 of the ACPI specification for more details.
228 *
229 * @param ctx The context of the TermList that this structure is part of.
230 * @param out Output pointer to the object to store the result.
231 * @return On success, `0`. On failure, `ERR` and `errno` is set.
232 */
234
235/**
236 * @brief Read a DataObject structure from the AML stream.
237 *
238 * A DataObject structure is defined as `DataObject := ComputationalData | DefPackage | DefVarPackage`.
239 *
240 * @param ctx The context of the TermList that this structure is part of.
241 * @param out Output pointer to the object to store the result.
242 * @return On success, `0`. On failure, `ERR` and `errno` is set.
243 */
245
246/**
247 * @brief Read a DataRefObject structure from the AML stream.
248 *
249 * A DataRefObject structure is defined as `DataRefObject := DataObject | ObjectReference`.
250 *
251 * @todo Implement ObjectReference handling... somehow. I honestly have no clue what the spec wants you to do here. But
252 * everything seems to work fine by only reading DataObjects for now.
253 *
254 * @param ctx The context of the TermList that this structure is part of.
255 * @param out Output pointer to the object to store the result.
256 * @return On success, `0`. On failure, `ERR` and `errno` is set.
257 */
259
260/** @} */
uint64_t aml_package_element_read(aml_term_list_ctx_t *ctx, aml_object_t *out)
Read a PackageElement structure from the AML stream.
Definition data.c:345
uint64_t aml_def_package_read(aml_term_list_ctx_t *ctx, aml_object_t *out)
Reads a DefPackage structure from the AML byte stream.
Definition data.c:407
uint64_t aml_byte_data_read(aml_term_list_ctx_t *ctx, uint8_t *out)
Read a ByteData structure from the AML stream.
Definition data.c:16
uint64_t aml_data_ref_object_read(aml_term_list_ctx_t *ctx, aml_object_t *out)
Read a DataRefObject structure from the AML stream.
Definition data.c:529
uint64_t aml_qword_data_read(aml_term_list_ctx_t *ctx, uint64_t *out)
Read a QWordData structure from the AML stream.
Definition data.c:54
uint64_t aml_dword_data_read(aml_term_list_ctx_t *ctx, uint32_t *out)
Read a DWordData structure from the AML stream.
Definition data.c:42
uint64_t aml_package_element_list_read(aml_term_list_ctx_t *ctx, aml_package_t *package, const uint8_t *end)
Read a PackageElementList structure from the AML stream.
Definition data.c:387
uint64_t aml_word_data_read(aml_term_list_ctx_t *ctx, uint16_t *out)
Read a WordData structure from the AML stream.
Definition data.c:30
uint64_t aml_def_var_package_read(aml_term_list_ctx_t *ctx, aml_object_t *out)
Reads a DefVarPackage structure from the AML byte stream.
Definition data.c:460
uint64_t aml_dword_const_read(aml_term_list_ctx_t *ctx, uint32_t *out)
Read a DWordConst structure from the AML stream.
Definition data.c:88
uint64_t aml_byte_const_read(aml_term_list_ctx_t *ctx, uint8_t *out)
Read a ByteConst structure from the AML stream.
Definition data.c:66
uint64_t aml_data_object_read(aml_term_list_ctx_t *ctx, aml_object_t *out)
Read a DataObject structure from the AML stream.
Definition data.c:501
uint64_t aml_word_const_read(aml_term_list_ctx_t *ctx, uint16_t *out)
Read a WordConst structure from the AML stream.
Definition data.c:77
uint64_t aml_def_var_num_elements_read(aml_term_list_ctx_t *ctx, aml_uint_t *out)
Read a VarNumElements structure from the AML stream.
Definition data.c:449
uint64_t aml_num_elements_read(aml_term_list_ctx_t *ctx, uint8_t *out)
Read a NumElements structure from the AML stream.
Definition data.c:304
uint64_t aml_const_obj_read(aml_term_list_ctx_t *ctx, aml_object_t *out)
Read a ConstObj structure from the AML stream.
Definition data.c:110
uint64_t aml_string_read(aml_term_list_ctx_t *ctx, aml_object_t *out)
Read a String structure from the AML stream.
Definition data.c:144
uint64_t aml_qword_const_read(aml_term_list_ctx_t *ctx, uint64_t *out)
Read a QWordConst structure from the AML stream.
Definition data.c:99
uint64_t aml_revision_op_read(aml_term_list_ctx_t *ctx, aml_object_t *out)
Read a RevisionOp structure from the AML stream.
Definition data.c:183
uint64_t aml_computational_data_read(aml_term_list_ctx_t *ctx, aml_object_t *out)
Read a ComputationalData structure from the AML stream.
Definition data.c:199
uint64_t aml_uint_t
AML Integer type.
Definition integer.h:20
__UINT32_TYPE__ uint32_t
Definition stdint.h:15
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
__UINT8_TYPE__ uint8_t
Definition stdint.h:11
__UINT16_TYPE__ uint16_t
Definition stdint.h:13
ACPI object.
Definition object.h:447
Data for a package object.
Definition object.h:359
Context for reading a TermList.
Definition term.h:37