PatchworkOS
Loading...
Searching...
No Matches
arg.c
Go to the documentation of this file.
2
7
9{
10 aml_token_t argOp;
11 aml_token_read(ctx, &argOp);
12
13 if (argOp.num < AML_ARG0_OP || argOp.num > AML_ARG6_OP)
14 {
15 AML_DEBUG_ERROR(ctx, "Invalid ArgOp %d", argOp.num);
16 return NULL;
17 }
18
19 uint64_t index = argOp.num - AML_ARG0_OP;
20 if (ctx->state->args[index] == NULL)
21 {
22 AML_DEBUG_ERROR(ctx, "Arg%d is not set", index);
23 errno = EILSEQ;
24 return NULL;
25 }
26
27 return REF(CONTAINER_OF(ctx->state->args[index], aml_object_t, arg));
28}
#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_arg_obj_read(aml_term_list_ctx_t *ctx)
Reads a ArgObj structure from the AML byte stream.
Definition arg.c:8
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_ARG0_OP
Definition token.h:103
@ AML_ARG6_OP
Definition token.h:109
#define REF(ptr)
Increment reference count.
Definition ref.h:65
#define errno
Error number variable.
Definition errno.h:27
#define EILSEQ
Illegal byte sequence.
Definition errno.h:447
#define NULL
Pointer error value.
Definition NULL.h:23
#define CONTAINER_OF(ptr, type, member)
Container of macro.
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
ACPI object.
Definition object.h:425
aml_arg_obj_t * args[AML_MAX_ARGS]
Argument variables for the method, if any.
Definition state.h:27
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