PatchworkOS  321f6ec
A non-POSIX operating system.
Loading...
Searching...
No Matches
term.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;
8
9/**
10 * @brief Term Objects Encoding
11 * @defgroup modules_acpi_aml_encoding_term Term Objects
12 * @ingroup modules_acpi_aml
13 *
14 * @see Section 20.2.5 of the ACPI specification for more details.
15 *
16 * @{
17 */
18
19/**
20 * @brief Stop reason.
21 * @enum aml_stop_reason_t
22 */
23typedef enum
24{
25 AML_STOP_REASON_NONE, ///< No stop reason, continue execution or has reached the end of the TermList
26 AML_STOP_REASON_RETURN, ///< A Return statement was hit
27 AML_STOP_REASON_BREAK, ///< A Break statement was hit
28 AML_STOP_REASON_CONTINUE, ///< A Continue statement was hit
30
31/**
32 * @brief Context for reading a TermList.
33 *
34 * This structure is used to keep track of the state while reading a TermList from the AML byte stream.
35 */
45
46/**
47 * @brief Reads an TermArg structure from the AML byte stream.
48 *
49 * A TermArg is defined as `TermArg := ExpressionOpcode | DataObject | ArgObj | LocalObj`.
50 *
51 * @param ctx The context of the TermList that this structure is part of.
52 * @param allowedTypes Bitmask of allowed types for the TermArg, the will be evaluated to one of these types.
53 * @return On success, the TermArg object. On failure, `NULL` and `errno` is set.
54 */
56
57/**
58 * @brief Wrapper around `aml_term_arg_read()` that converts the result to an integer.
59 *
60 * @param ctx The context of the TermList that this structure is part of.
61 * @param out The output buffer to store the integer value of the TermArg.
62 * @return On success, `0`. On failure, `ERR` and `errno` is set.
63 */
65
66/**
67 * @brief Wrapper around `aml_term_arg_read()` that converts the result to a string.
68 *
69 * @param ctx The context of the TermList that this structure is part of.
70 * @return On success, the string. On failure, `NULL` and `errno` is set.
71 */
73
74/**
75 * @brief Wrapper around `aml_term_arg_read()` that converts the result to a buffer.
76 *
77 * @param ctx The context of the TermList that this structure is part of.
78 * @return On success, the buffer. On failure, `NULL` and `errno` is set.
79 */
81
82/**
83 * @brief Wrapper around `aml_term_arg_read()` that converts the result to a package.
84 *
85 * @param ctx The context of the TermList that this structure is part of.
86 * @return On success, the package. On failure, `NULL` and `errno` is set.
87 */
89
90/**
91 * @brief Reads an Object structure from the AML byte stream.
92 *
93 * An Object is defined as `Object := NameSpaceModifierObj | NamedObj`.
94 *
95 * @param ctx The context of the TermList that this structure is part of.
96 * @return On success, `0`. On failure, `ERR` and `errno` is set.
97 */
99
100/**
101 * @brief Reads a TermObj structure from the AML byte stream.
102 *
103 * A TermObj is defined as `TermObj := Object | StatementOpcode | ExpressionOpcode`.
104 *
105 * @param ctx The context of the TermList that this structure is part of.
106 * @return On success, `0`. On failure, `ERR` and `errno` is set.
107 */
109
110/**
111 * @brief Reads a TermList structure from the AML byte stream.
112 *
113 * A TermList structure is defined as `TermList := Nothing | <termobj termlist>`.
114 *
115 * This is the biggest "structure" in AML, and the entry point for AML execution.
116 *
117 * Will not advance the parent TermLists current pointer.
118 *
119 * @param state Pointer to the current AML state.
120 * @param scope The location in the namespace from which names will be resolved.
121 * @param start Pointer to the start of the TermList in the AML byte stream.
122 * @param end Pointer to the end of the TermList in the AML byte stream.
123 * @param parentCtx The previous TermList context, or `NULL` if this is the top-level TermList, used to propagate stop
124 * reasons.
125 * @return On success, `0`. On failure, `ERR` and `errno` is set.
126 */
127uint64_t aml_term_list_read(aml_state_t* state, aml_object_t* scope, const uint8_t* start, const uint8_t* end,
128 aml_term_list_ctx_t* parentCtx);
129
130/** @} */
aml_string_t * aml_term_arg_read_string(aml_term_list_ctx_t *ctx)
Wrapper around aml_term_arg_read() that converts the result to a string.
Definition term.c:86
aml_object_t * aml_term_arg_read(aml_term_list_ctx_t *ctx, aml_type_t allowedTypes)
Reads an TermArg structure from the AML byte stream.
Definition term.c:19
uint64_t aml_term_arg_read_integer(aml_term_list_ctx_t *ctx, aml_uint_t *out)
Wrapper around aml_term_arg_read() that converts the result to an integer.
Definition term.c:70
aml_package_t * aml_term_arg_read_package(aml_term_list_ctx_t *ctx)
Wrapper around aml_term_arg_read() that converts the result to a package.
Definition term.c:114
uint64_t aml_object_read(aml_term_list_ctx_t *ctx)
Reads an Object structure from the AML byte stream.
Definition term.c:128
uint64_t aml_term_obj_read(aml_term_list_ctx_t *ctx)
Reads a TermObj structure from the AML byte stream.
Definition term.c:146
uint64_t aml_term_list_read(aml_state_t *state, aml_object_t *scope, const uint8_t *start, const uint8_t *end, aml_term_list_ctx_t *parentCtx)
Reads a TermList structure from the AML byte stream.
Definition term.c:189
aml_buffer_t * aml_term_arg_read_buffer(aml_term_list_ctx_t *ctx)
Wrapper around aml_term_arg_read() that converts the result to a buffer.
Definition term.c:100
aml_stop_reason_t
Stop reason.
Definition term.h:24
@ AML_STOP_REASON_BREAK
A Break statement was hit.
Definition term.h:27
@ AML_STOP_REASON_CONTINUE
A Continue statement was hit.
Definition term.h:28
@ AML_STOP_REASON_RETURN
A Return statement was hit.
Definition term.h:26
@ AML_STOP_REASON_NONE
No stop reason, continue execution or has reached the end of the TermList.
Definition term.h:25
uint64_t aml_uint_t
AML Integer type.
Definition integer.h:20
aml_type_t
ACPI data types.
Definition object.h:59
static void start()
Definition main.c:542
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
__UINT8_TYPE__ uint8_t
Definition stdint.h:11
Data for a buffer object.
Definition object.h:213
ACPI object.
Definition object.h:447
Data for a package object.
Definition object.h:359
AML State.
Definition state.h:25
Data for a string object.
Definition object.h:390
Context for reading a TermList.
Definition term.h:37
aml_object_t * scope
Definition term.h:39
aml_state_t * state
Definition term.h:38
const uint8_t * start
Definition term.h:40
const uint8_t * end
Definition term.h:41
const uint8_t * current
Definition term.h:42
aml_stop_reason_t stopReason
Definition term.h:43