PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
statement.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <stdint.h>
6
7typedef struct aml_state aml_state_t;
8typedef struct aml_object aml_object_t;
9typedef struct aml_term_list_ctx aml_term_list_ctx_t;
10
11/**
12 * @brief Statement Opcodes Encoding
13 * @defgroup modules_acpi_aml_encoding_statement Statement Opcodes
14 * @ingroup modules_acpi_aml
15 *
16 * @see Section 20.2.5.3 of the ACPI specification for more details.
17 *
18 * @{
19 */
20
21/**
22 * @brief Reads a Predicate structure from the AML byte stream.
23 *
24 * A Predicate structure is defined as `Predicate := TermArg => Integer`.
25 *
26 * @param ctx The context of the TermList that this structure is part of.
27 * @param out The destination buffer to store the integer value of the Predicate.
28 * @return On success, `0`. On failure, `ERR` and `errno` is set.
29 */
31
32/**
33 * @brief Reads a DefElse structure from the AML byte stream.
34 *
35 * A DefElse structure is defined as `DefElse := Nothing | <elseop pkglength termlist>`.
36 *
37 * @see Section 19.6.39 of the ACPI specification for more details.
38 *
39 * @param ctx The context of the TermList that this structure is part of.
40 * @param shouldExecute Whether the TermList should be executed or skipped.
41 * @return On success, `0`. On failure, `ERR` and `errno` is set.
42 */
43uint64_t aml_def_else_read(aml_term_list_ctx_t* ctx, bool shouldExecute);
44
45/**
46 * @brief Reads an DefIfElse structure from the AML byte stream.
47 *
48 * A DefIfElse structure is defined as `DefIfElse := IfOp PkgLength Predicate TermList DefElse`.
49 *
50 * Note that the the DefIfElse structure is also used for normal If statements, just without a "Else" part, this is
51 * because the DefElse part is optional.
52 *
53 * @see Section 19.6.60 of the ACPI specification for more details.
54 *
55 * @param ctx The context of the TermList that this structure is part of.
56 * @return On success, `0`. On failure, `ERR` and `errno` is set.
57 */
59
60/**
61 * @brief Reads a DefNoop structure from the AML byte stream.
62 *
63 * A DefNoop structure is defined as `DefNoop := NoopOp`.
64 *
65 * A Noop does nothing.
66 *
67 * @param state Pointer to the current AML state.
68 * @return On success, `0`. On failure, `ERR` and `errno` is set.
69 */
71
72/**
73 * @brief Reads an ArgObject structure from the AML byte stream.
74 *
75 * An ArgObject structure is defined as `ArgObject := TermArg => DataRefObject`.
76 *
77 * @see Section 19.6.119 of the ACPI specification for more details.
78 *
79 * @param ctx The context of the TermList that this structure is part of.
80 * @return On success, the ArgObject. On failure, `NULL` and `errno` is set.
81 */
83
84/**
85 * @brief Reads a DefReturn structure from the AML byte stream.
86 *
87 * A DefReturn structure is defined as `DefReturn := ReturnOp ArgObject`.
88 *
89 * @see Section 19.6.120 of the ACPI specification for more details.
90 *
91 * @param ctx The context of the TermList that this structure is part of.
92 * @return On success, `0`. On failure, `ERR` and `errno` is set.
93 */
95
96/**
97 * @brief Reads a DefBreak structure from the AML byte stream.
98 *
99 * A DefBreak structure is defined as `DefBreak := BreakOp`.
100 *
101 * @see Section 19.6.8 of the ACPI specification for more details.
102 *
103 * @param state Pointer to the current AML state.
104 * @return On success, `0`. On failure, `ERR` and `errno` is set.
105 */
107
108/**
109 * @brief Reads a DefContinue structure from the AML byte stream.
110 *
111 * A DefContinue structure is defined as `DefContinue := ContinueOp`.
112 *
113 * @see Section 19.6.16 of the ACPI specification for more details.
114 *
115 * @param state Pointer to the current AML state.
116 * @return On success, `0`. On failure, `ERR` and `errno` is set.
117 */
119
120/**
121 * @brief Reads a DefRelease structure from the AML byte stream.
122 *
123 * A DefRelease structure is defined as `DefRelease := ReleaseOp MutexObject`.
124 *
125 * @see Section 19.6.117 of the ACPI specification for more details.
126 *
127 * @param ctx The context of the TermList that this structure is part of.
128 * @return On success, `0`. On failure, `ERR` and `errno` is set.
129 */
131
132/**
133 * @brief Reads a DefWhile structure from the AML byte stream.
134 *
135 * A DefWhile structure is defined as `DefWhile := WhileOp PkgLength Predicate TermList`.
136 *
137 * The While statement works by evaluating the Predicate, if it is a non-zero integer, the TermList following the
138 * Predicate is executed, then the Predicate is evaluated again, this continues until the Predicate evaluates to zero.
139 *
140 * @see Section 19.6.158 of the ACPI specification for more details.
141 *
142 * @param ctx The context of the TermList that this structure is part of.
143 * @return On success, `0`. On failure, `ERR` and `errno` is set.
144 */
146
147/**
148 * @brief Reads an StatementOpcode structure from the AML byte stream.
149 *
150 * A StatementOpcode structure is defined as `StatementOpcode := DefBreak | DefBreakPoint | DefContinue | DefFatal |
151 * DefIfElse | DefNoop | DefNotify | DefRelease | DefReset | DefReturn | DefSignal | DefSleep | DefStall | DefWhile`.
152 *
153 * Currently unimplemented Opcodes are:
154 * - `DefBreakPoint`
155 * - `DefFatal`
156 * - `DefNotify`
157 * - `DefReset`
158 * - `DefSignal`
159 * - `DefSleep`
160 * - `DefStall`
161 *
162 * @param ctx The context of the TermList that this structure is part of.
163 * @return On success, `0`. On failure, `ERR` and `errno` is set.
164 */
166
167/** @} */
uint64_t aml_def_continue_read(aml_term_list_ctx_t *ctx)
Reads a DefContinue structure from the AML byte stream.
Definition statement.c:201
uint64_t aml_predicate_read(aml_term_list_ctx_t *ctx, aml_uint_t *out)
Reads a Predicate structure from the AML byte stream.
Definition statement.c:12
uint64_t aml_def_break_read(aml_term_list_ctx_t *ctx)
Reads a DefBreak structure from the AML byte stream.
Definition statement.c:189
uint64_t aml_def_noop_read(aml_term_list_ctx_t *ctx)
Reads a DefNoop structure from the AML byte stream.
Definition statement.c:117
aml_object_t * aml_arg_object_read(aml_term_list_ctx_t *ctx)
Reads an ArgObject structure from the AML byte stream.
Definition statement.c:128
uint64_t aml_statement_opcode_read(aml_term_list_ctx_t *ctx)
Reads an StatementOpcode structure from the AML byte stream.
Definition statement.c:285
uint64_t aml_def_if_else_read(aml_term_list_ctx_t *ctx)
Reads an DefIfElse structure from the AML byte stream.
Definition statement.c:56
uint64_t aml_def_return_read(aml_term_list_ctx_t *ctx)
Reads a DefReturn structure from the AML byte stream.
Definition statement.c:140
uint64_t aml_def_else_read(aml_term_list_ctx_t *ctx, bool shouldExecute)
Reads a DefElse structure from the AML byte stream.
Definition statement.c:22
uint64_t aml_def_release_read(aml_term_list_ctx_t *ctx)
Reads a DefRelease structure from the AML byte stream.
Definition statement.c:162
uint64_t aml_def_while_read(aml_term_list_ctx_t *ctx)
Reads a DefWhile structure from the AML byte stream.
Definition statement.c:213
uint64_t aml_uint_t
AML Integer type.
Definition integer.h:20
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
ACPI object.
Definition object.h:447
AML State.
Definition state.h:25
Context for reading a TermList.
Definition term.h:37