PatchworkOS
Loading...
Searching...
No Matches
local.c
Go to the documentation of this file.
2
7
9{
10 aml_token_t localOp;
11 aml_token_read(ctx, &localOp);
12
13 if (localOp.num < AML_LOCAL0_OP || localOp.num > AML_LOCAL7_OP)
14 {
15 AML_DEBUG_ERROR(ctx, "Invalid LocalOp %d", localOp.num);
16 return NULL;
17 }
18
19 uint64_t index = localOp.num - AML_LOCAL0_OP;
20 if (ctx->state->locals[index] == NULL)
21 {
23 if (local == NULL || aml_local_set(local) == ERR)
24 {
25 if (local != NULL)
26 {
27 DEREF(local);
28 }
29 return NULL;
30 }
31 ctx->state->locals[index] = &local->local;
32 ctx->state->locals[index]->name = AML_NAME('L', 'O', 'C', '0' + index);
33 }
34
35 return REF(CONTAINER_OF(ctx->state->locals[index], aml_object_t, local));
36}
#define AML_DEBUG_ERROR(ctx, format,...)
Macro to simplify calling aml_debug_error() with the current function name.
Definition debug.h:30
aml_object_t * aml_local_obj_read(aml_term_list_ctx_t *ctx)
Reads a LocalObj structure from the AML byte stream.
Definition local.c:8
#define AML_NAME(a, b, c, d)
Macro to create an aml_name_t from 4 characters.
Definition namespace.h:112
uint64_t aml_local_set(aml_object_t *object)
Set a object as a empty local variable.
Definition object.c:1204
aml_object_t * aml_object_new(void)
Allocate a new ACPI object.
Definition object.c:54
static void aml_token_read(aml_term_list_ctx_t *ctx, aml_token_t *out)
Attempt to read a token from the AML stream.
Definition token.h:340
@ AML_LOCAL0_OP
Definition token.h:95
@ AML_LOCAL7_OP
Definition token.h:102
#define REF(ptr)
Increment reference count.
Definition ref.h:65
#define DEREF(ptr)
Decrement reference count.
Definition ref.h:80
#define NULL
Pointer error value.
Definition NULL.h:23
#define ERR
Integer error value.
Definition ERR.h:17
#define CONTAINER_OF(ptr, type, member)
Container of macro.
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
ACPI object.
Definition object.h:425
aml_local_obj_t local
Definition object.h:449
aml_local_obj_t * locals[AML_MAX_LOCALS]
Local variables for the method, if any, initialized lazily.
Definition state.h:26
Context for reading a TermList.
Definition term.h:37
aml_state_t * state
Definition term.h:38
Token.
Definition token.h:253
aml_token_num_t num
Definition token.h:254