PatchworkOS  2ca1c69
A non-POSIX operating system.
Loading...
Searching...
No Matches
evaluate.c
Go to the documentation of this file.
3
7
9{
10 if (object == NULL)
11 {
12 errno = EINVAL;
13 return NULL;
14 }
15
16 if (state == NULL)
17 {
18 aml_state_t tempState;
19 if (aml_state_init(&tempState, NULL) == ERR)
20 {
21 return NULL;
22 }
23
24 aml_object_t* result = aml_evaluate(&tempState, object, targetTypes);
25 aml_state_deinit(&tempState);
26 return result;
27 }
28
29 if (object->type & targetTypes)
30 {
31 return REF(object);
32 }
33
34 if (object->type == AML_METHOD)
35 {
36 aml_object_t* result = aml_method_invoke(state, &object->method, NULL);
37 if (result == NULL)
38 {
39 return NULL;
40 }
41 DEREF_DEFER(result);
42
43 aml_object_t* converted = NULL;
44 if (aml_convert_source(state, result, &converted, targetTypes) == ERR)
45 {
46 return NULL;
47 }
48
49 return converted;
50 }
51
52 aml_object_t* converted = NULL;
53 if (aml_convert_source(state, object, &converted, targetTypes) == ERR)
54 {
55 return NULL;
56 }
57
58 return converted;
59}
#define DEREF_DEFER(ptr)
RAII-style cleanup for scoped references.
Definition ref.h:54
#define REF(ptr)
Increment reference count.
Definition ref.h:65
#define EINVAL
Invalid argument.
Definition errno.h:142
#define errno
Error number variable.
Definition errno.h:27
#define NULL
Pointer error value.
Definition NULL.h:23
#define ERR
Integer error value.
Definition ERR.h:17
uint64_t aml_convert_source(aml_state_t *state, aml_object_t *src, aml_object_t **dest, aml_type_t allowedTypes)
Performs a "Implicit Source Operand Conversion" acording to the rules in section 19....
Definition convert.c:545
aml_object_t * aml_evaluate(aml_state_t *state, aml_object_t *object, aml_type_t targetTypes)
Evaluate an AML object.
Definition evaluate.c:8
aml_object_t * aml_method_invoke(aml_state_t *parentState, aml_method_t *method, aml_object_t **args)
Invoke a method with the given arguments.
Definition method.c:11
aml_type_t
ACPI data types.
Definition object.h:59
@ AML_METHOD
Definition object.h:77
uint64_t aml_state_init(aml_state_t *state, aml_object_t **args)
Initialize an AML state.
Definition state.c:8
void aml_state_deinit(aml_state_t *state)
Deinitialize an AML state.
Definition state.c:68
ACPI object.
Definition object.h:447
aml_method_t method
Definition object.h:460
AML State.
Definition state.h:25