46 if (*operand1 ==
NULL)
54 if (*operand2 ==
NULL)
82 if (*operand1 ==
NULL)
90 if (*operand2 ==
NULL)
110 if (*operand ==
NULL)
129 if (*operand ==
NULL)
155 if (*operand ==
NULL)
223 if (*termarg ==
NULL)
230 if (*simplename ==
NULL)
250 if (*supername ==
NULL)
269 if (*termarg ==
NULL)
276 if (*supername ==
NULL)
342 for (; i < argCount; i++)
663 if (remainderDest ==
NULL)
671 if (quotientDest ==
NULL)
1103 if (termArg ==
NULL)
1182 if (buffPkgStrObj ==
NULL)
1211 switch (buffPkgStrObj->type)
1217 if (index >= package->length)
1219 AML_DEBUG_ERROR(ctx,
"Index out of bounds for package (length %llu, index %llu)", package->length, index);
1234 AML_DEBUG_ERROR(ctx,
"Index out of bounds for buffer (length %llu, index %llu)",
1241 if (byteField ==
NULL)
1262 AML_DEBUG_ERROR(ctx,
"Index out of bounds for string (length %llu, index %llu)",
1269 if (byteField ==
NULL)
1287 AML_DEBUG_ERROR(ctx,
"Invalid type, expected buffer, package or string but got '%s'",
1607 if (acquireResult ==
ERR)
1827 for (
uint64_t i = 0; i < length; i++)
1946 switch (object->type)
1955 sizeObject = object;
1959 if (sizeObject ==
NULL)
1966 switch (sizeObject->type)
2343 if (searchPkg ==
NULL)
2358 if (object1 ==
NULL)
2373 if (object2 ==
NULL)
2397 if (element ==
NULL)
#define assert(expression)
uint64_t aml_concat(aml_state_t *state, aml_object_t *source1, aml_object_t *source2, aml_object_t *result)
Concatenates two objects according to the rules in section 19.6.12 of the ACPI specification.
static uint64_t aml_op_operand_read(aml_term_list_ctx_t *ctx, aml_token_num_t expectedOp, aml_type_t allowedTypes, aml_object_t **operand)
static uint64_t aml_op_termarg_supername_read(aml_term_list_ctx_t *ctx, aml_token_num_t expectedOp, aml_type_t allowedTypes, aml_object_t **termarg, aml_object_t **supername)
static uint64_t aml_op_operand_shiftcount_target_read(aml_term_list_ctx_t *ctx, aml_token_num_t expectedOp, aml_type_t allowedTypes, aml_object_t **operand, aml_integer_t *shiftCount, aml_object_t **target)
static uint64_t aml_op_operand_target_read(aml_term_list_ctx_t *ctx, aml_token_num_t expectedOp, aml_type_t allowedTypes, aml_object_t **operand, aml_object_t **target)
static uint64_t aml_op_data_data_target_read(aml_term_list_ctx_t *ctx, aml_token_num_t expectedOp, aml_object_t **data1, aml_object_t **data2, aml_object_t **target)
static uint64_t aml_op_termarg_simplename_read(aml_term_list_ctx_t *ctx, aml_token_num_t expectedOp, aml_type_t allowedTypes, aml_object_t **termarg, aml_object_t **simplename)
static uint64_t aml_op_operand_operand_read(aml_term_list_ctx_t *ctx, aml_token_num_t expectedOp, aml_type_t allowedTypes, aml_object_t **operand1, aml_object_t **operand2)
static uint64_t aml_op_operand_operand_target_read(aml_term_list_ctx_t *ctx, aml_token_num_t expectedOp, aml_type_t allowedTypes, aml_object_t **operand1, aml_object_t **operand2, aml_object_t **target)
static uint64_t aml_op_supername_read(aml_term_list_ctx_t *ctx, aml_token_num_t expectedOp, aml_object_t **supername)
static bool aml_match_compare(aml_state_t *state, aml_object_t *obj1, aml_object_t *obj2, aml_match_opcode_t op)
aml_integer_t aml_compare_not(aml_integer_t value)
Perform a logical NOT operation on an integer value.
aml_integer_t aml_compare(aml_object_t *a, aml_object_t *b, aml_compare_operation_t operation)
Compare two ACPI objects.
@ AML_COMPARE_GREATER_EQUAL
@ AML_COMPARE_OR
Section 19.6.80, integer only.
@ AML_COMPARE_LESS
Section 19.6.73.
@ AML_COMPARE_GREATER
Section 19.6.71.
@ AML_COMPARE_EQUAL
Section 19.6.70.
@ AML_COMPARE_AND
Section 19.6.69, integer only.
uint64_t aml_convert_to_decimal_string(aml_state_t *state, aml_object_t *src, aml_object_t **dest)
Converts a Integer, String or Buffer source object to a String destination object in decimal format.
uint64_t aml_convert_result(aml_state_t *state, aml_object_t *result, aml_object_t *target)
Performs a "Implicit Result Object Conversion" acording to the rules in section 19....
uint64_t aml_convert_integer_to_bcd(aml_integer_t value, aml_integer_t *out)
Converts an integer to its Binary-Coded Decimal (BCD) representation.
uint64_t aml_convert_to_buffer(aml_state_t *state, aml_object_t *src, aml_object_t **dest)
Converts a Integer, String or Buffer source object to a Buffer destination object.
uint64_t aml_convert_to_hex_string(aml_state_t *state, aml_object_t *src, aml_object_t **dest)
Converts a Integer, String or Buffer source object to a String destination object in hexadecimal form...
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....
uint64_t aml_convert_to_integer(aml_state_t *state, aml_object_t *src, aml_object_t **dest)
Converts a Integer, String or Buffer source object to an Integer destination object.
uint64_t aml_copy_object(aml_state_t *state, aml_object_t *src, aml_object_t *dest)
Copies the data from the source object to the destination object.
#define AML_DEBUG_ERROR(ctx, format,...)
Macro to simplify calling aml_debug_error() with the current function name.
#define AML_MAX_ARGS
Maximum number of arguments that can be passed to a method.
uint64_t aml_def_package_read(aml_term_list_ctx_t *ctx, aml_object_t *out)
Reads a DefPackage structure from the AML byte stream.
uint64_t aml_byte_data_read(aml_term_list_ctx_t *ctx, uint8_t *out)
Read a ByteData structure from the AML stream.
uint64_t aml_word_data_read(aml_term_list_ctx_t *ctx, uint16_t *out)
Read a WordData structure from the AML stream.
uint64_t aml_def_var_package_read(aml_term_list_ctx_t *ctx, aml_object_t *out)
Reads a DefVarPackage structure from the AML byte stream.
aml_object_t * aml_debug_obj_read(aml_term_list_ctx_t *ctx)
Reads a DebugObj structure from the AML byte stream.
uint64_t aml_divisor_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads a Divisor structure from the AML byte stream.
uint64_t aml_def_buffer_read(aml_term_list_ctx_t *ctx, aml_object_t *out)
Reads a DefBuffer structure from the AML byte stream.
aml_object_t * aml_def_acquire_read(aml_term_list_ctx_t *ctx)
Reads a DefAcquire structure from the AML byte stream.
uint64_t aml_term_arg_list_read(aml_term_list_ctx_t *ctx, uint64_t argCount, aml_term_arg_list_t *out)
Reads a TermArgList structure from the AML byte stream.
aml_object_t * aml_def_to_string_read(aml_term_list_ctx_t *ctx)
Reads a DefToString structure from the AML byte stream.
uint64_t aml_shift_count_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads a ShiftCount structure from the AML byte stream.
aml_object_t * aml_def_add_read(aml_term_list_ctx_t *ctx)
Reads a DefAdd structure from the AML byte stream.
uint64_t aml_timeout_read(aml_term_list_ctx_t *ctx, uint16_t *out)
Reads a Timeout structure from the AML byte stream.
aml_object_t * aml_def_increment_read(aml_term_list_ctx_t *ctx)
Reads a DefIncrement structure from the AML byte stream.
aml_object_t * aml_def_concat_read(aml_term_list_ctx_t *ctx)
Reads a DefConcat structure from the AML byte stream.
aml_object_t * aml_def_land_read(aml_term_list_ctx_t *ctx)
Reads a DefLAnd structure from the AML byte stream.
aml_object_t * aml_def_to_hex_string_read(aml_term_list_ctx_t *ctx)
Reads a DefToHexString structure from the AML byte stream.
aml_object_t * aml_def_find_set_left_bit_read(aml_term_list_ctx_t *ctx)
Reads a DefFindSetLeftBit structure from the AML byte stream.
aml_object_t * aml_def_match_read(aml_term_list_ctx_t *ctx)
Reads a DefMatch structure from the AML byte stream.
aml_object_t * aml_def_cond_ref_of_read(aml_term_list_ctx_t *ctx)
Reads a DefCondRefOf structure from the AML byte stream.
aml_object_t * aml_def_to_integer_read(aml_term_list_ctx_t *ctx)
Reads a DefToInteger structure from the AML byte stream.
aml_object_t * aml_mutex_object_read(aml_term_list_ctx_t *ctx)
Reads a MutexObject structure from the AML byte stream.
aml_object_t * aml_def_lgreater_equal_read(aml_term_list_ctx_t *ctx)
Reads a DefLGreaterEqual structure from the AML byte stream.
aml_object_t * aml_def_object_type_read(aml_term_list_ctx_t *ctx)
Reads a DefObjectType structure from the AML byte stream.
aml_object_t * aml_def_to_decimal_string_read(aml_term_list_ctx_t *ctx)
Reads a DefToDecimalString structure from the AML byte stream.
uint64_t aml_index_value_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads an IndexValue structure from the AML byte stream.
aml_object_t * aml_def_size_of_read(aml_term_list_ctx_t *ctx)
Reads a DefSizeOf structure from the AML byte stream.
aml_object_t * aml_def_decrement_read(aml_term_list_ctx_t *ctx)
Reads a DefDecrement structure from the AML byte stream.
aml_object_t * aml_remainder_read(aml_term_list_ctx_t *ctx)
Reads a Remainder structure from the AML byte stream.
aml_object_t * aml_def_lor_read(aml_term_list_ctx_t *ctx)
Reads a DefLOr structure from the AML byte stream.
aml_object_t * aml_def_copy_object_read(aml_term_list_ctx_t *ctx)
Reads a DefCopyObject structure from the AML byte stream.
aml_object_t * aml_def_nor_read(aml_term_list_ctx_t *ctx)
Reads a DefNOr structure from the AML byte stream.
aml_object_t * aml_data_read(aml_term_list_ctx_t *ctx)
Reads a Data structure from the AML byte stream.
aml_object_t * aml_def_xor_read(aml_term_list_ctx_t *ctx)
Reads a DefXOr structure from the AML byte stream.
aml_package_obj_t * aml_search_pkg_read(aml_term_list_ctx_t *ctx)
Reads a SearchPkg structure from the AML byte stream.
aml_object_t * aml_def_multiply_read(aml_term_list_ctx_t *ctx)
Reads a DefMultiply structure from the AML byte stream.
aml_object_t * aml_def_to_bcd_read(aml_term_list_ctx_t *ctx)
Reads a DefToBcd structure from the AML byte stream.
aml_object_t * aml_expression_opcode_read(aml_term_list_ctx_t *ctx)
Reads an ExpressionOpcode structure from the AML byte stream.
aml_object_t * aml_def_lnot_read(aml_term_list_ctx_t *ctx)
Reads a DefLNot structure from the AML byte stream.
uint64_t aml_length_arg_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads a LengthArg structure from the AML byte stream.
aml_object_t * aml_operand_read(aml_term_list_ctx_t *ctx, aml_type_t allowedTypes)
Reads an Operand structure from the AML byte stream.
aml_object_t * aml_def_nand_read(aml_term_list_ctx_t *ctx)
Reads a DefNAnd structure from the AML byte stream.
uint64_t aml_start_index_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads a StartIndex structure from the AML byte stream.
uint64_t aml_match_opcode_read(aml_term_list_ctx_t *ctx, aml_match_opcode_t *out)
Reads a MatchOpcode structure from the AML byte stream.
aml_object_t * aml_def_store_read(aml_term_list_ctx_t *ctx)
Reads a DefStore structure from the AML byte stream.
aml_object_t * aml_def_shift_right_read(aml_term_list_ctx_t *ctx)
Reads a DefShiftRight structure from the AML byte stream.
aml_object_t * aml_def_lequal_read(aml_term_list_ctx_t *ctx)
Reads a DefLEqual structure from the AML byte stream.
aml_object_t * aml_def_shift_left_read(aml_term_list_ctx_t *ctx)
Reads a DefShiftLeft structure from the AML byte stream.
uint64_t aml_buffer_size_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads a BufferSize structure from the AML byte stream.
aml_object_t * aml_def_lless_equal_read(aml_term_list_ctx_t *ctx)
Reads a DefLLessEqual structure from the AML byte stream.
aml_object_t * aml_def_lless_read(aml_term_list_ctx_t *ctx)
Reads a DefLLess structure from the AML byte stream.
aml_object_t * aml_def_subtract_read(aml_term_list_ctx_t *ctx)
Reads a DefSubtract structure from the AML byte stream.
aml_object_t * aml_def_timer_read(aml_term_list_ctx_t *ctx)
Reads a DefTimer structure from the AML byte stream.
aml_object_t * aml_reference_type_opcode_read(aml_term_list_ctx_t *ctx)
aml_object_t * aml_def_mod_read(aml_term_list_ctx_t *ctx)
Reads a DefMod structure from the AML byte stream.
aml_object_t * aml_obj_reference_read(aml_term_list_ctx_t *ctx)
Reads an ObjReference structure from the AML byte stream.
aml_object_t * aml_def_and_read(aml_term_list_ctx_t *ctx)
Reads a DefAnd structure from the AML byte stream.
aml_object_t * aml_quotient_read(aml_term_list_ctx_t *ctx)
Reads a Quotient structure from the AML byte stream.
uint64_t aml_dividend_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads a Dividend structure from the AML byte stream.
aml_object_t * aml_def_to_buffer_read(aml_term_list_ctx_t *ctx)
Reads a DefToBuffer structure from the AML byte stream.
aml_object_t * aml_def_not_read(aml_term_list_ctx_t *ctx)
Reads a DefNot structure from the AML byte stream.
aml_object_t * aml_def_lgreater_read(aml_term_list_ctx_t *ctx)
Reads a DefLGreater structure from the AML byte stream.
aml_object_t * aml_method_invocation_read(aml_term_list_ctx_t *ctx)
Reads a MethodInvocation structure from the AML byte stream.
aml_match_opcode_t
Match opcodes for DefMatch.
aml_object_t * aml_def_lnot_equal_read(aml_term_list_ctx_t *ctx)
Reads a DefLNotEqual structure from the AML byte stream.
aml_object_t * aml_buff_pkg_str_obj_read(aml_term_list_ctx_t *ctx)
Reads a BuffPkgStrObj structure from the AML byte stream.
aml_object_t * aml_def_index_read(aml_term_list_ctx_t *ctx)
Reads a DefIndex structure from the AML byte stream.
aml_object_t * aml_def_divide_read(aml_term_list_ctx_t *ctx)
Reads a DefDivide structure from the AML byte stream.
aml_object_t * aml_def_deref_of_read(aml_term_list_ctx_t *ctx)
Reads a DefDerefOf structure from the AML byte stream.
aml_object_t * aml_def_or_read(aml_term_list_ctx_t *ctx)
Reads a DefOr structure from the AML byte stream.
aml_object_t * aml_def_find_set_right_bit_read(aml_term_list_ctx_t *ctx)
Reads a DefFindSetRightBit structure from the AML byte stream.
aml_object_t * aml_def_ref_of_read(aml_term_list_ctx_t *ctx)
Reads a DefRefOf structure from the AML byte stream.
aml_object_t * aml_name_string_read_and_resolve(aml_term_list_ctx_t *ctx)
Reads the next data as a NameString structure from the AML bytecode stream and resolves it to a objec...
aml_object_t * aml_simple_name_read_and_resolve(aml_term_list_ctx_t *ctx)
Reads a SimpleName structure from the AML byte stream and resolves it to a object.
aml_object_t * aml_super_name_read_and_resolve(aml_term_list_ctx_t *ctx)
Reads a SuperName structure from the AML byte stream and resolves it to a object.
uint64_t aml_target_read_and_resolve(aml_term_list_ctx_t *ctx, aml_object_t **out)
Reads a Target structure from the AML byte stream and resolves it to a object.
uint32_t aml_pkg_length_t
PkgLength structure.
uint64_t aml_pkg_length_read(aml_term_list_ctx_t *ctx, aml_pkg_length_t *out)
Reads a PkgLength structure from the AML byte stream.
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.
uint64_t aml_term_arg_read_integer(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Wrapper around aml_term_arg_read() that converts the result to an integer.
aml_package_obj_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.
aml_buffer_obj_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.
#define AML_EXCEPTION_RAISE(state, code)
Macro to raise an AML exception with the current function name.
uint8_t aml_integer_bit_size(void) PURE_FUNC
Get the bit size of an AML integer.
uint64_t aml_integer_t
AML Integer type.
#define AML_TRUE
AML Boolean true value.
aml_integer_t aml_integer_ones(void) PURE_FUNC
Get a mask with all bits set for the current AML integer size.
aml_object_t * aml_method_evaluate(aml_state_t *parentState, aml_method_obj_t *method, aml_object_t **args)
Evaluate a method with the given arguments.
uint64_t aml_mutex_acquire(aml_mutex_id_t *mutex, aml_sync_level_t syncLevel, clock_t timeout)
Acquire a mutex, blocking until it is available or the timeout is reached.
#define AML_NAME_TO_STRING(name)
Macro to convert an aml_name_t to a stack allocated string.
aml_object_t * aml_namespace_find_by_path(aml_namespace_overlay_t *overlay, aml_object_t *start, const char *path)
Find an object in the namespace heirarchy by a path string.
uint64_t aml_object_reference_set(aml_object_t *object, aml_object_t *target)
Set a object as an ObjectReference to the given target object.
aml_type_t
ACPI data types.
uint64_t aml_integer_set(aml_object_t *object, aml_integer_t value)
Set a object as an integer with the given value and bit width.
aml_object_t * aml_object_new(void)
Allocate a new ACPI object.
uint64_t aml_buffer_field_set(aml_object_t *object, aml_object_t *target, aml_bit_size_t bitOffset, aml_bit_size_t bitSize)
Set a object as a buffer field with the given buffer, bit offset and bit size.
uint64_t aml_string_set_empty(aml_object_t *object, uint64_t length)
Set a object as an empty string with the given length.
uint64_t aml_buffer_set(aml_object_t *object, const uint8_t *buffer, uint64_t bytesToCopy, uint64_t length)
Set a object as a buffer with the given content.
@ AML_ARG
Not in the spec, used internally to represent method arguments.
@ AML_COMPUTATIONAL_DATA_OBJECTS
@ AML_LOCAL
Not in the spec, used internally to represent method local variables.
void aml_state_result_set(aml_state_t *state, aml_object_t *result)
Set the result object of the state.
uint64_t aml_store(aml_state_t *state, aml_object_t *src, aml_object_t *dest)
Store the value from the source object into the target object.
const char * aml_type_to_string(aml_type_t type)
Convert an aml data type to a string.
aml_token_num_t
Token numbers.
static uint64_t aml_token_expect(aml_term_list_ctx_t *ctx, aml_token_num_t expected)
Reads a token from the AML stream and verifies it matches the expected token.
static const aml_token_props_t * aml_token_lookup(aml_token_num_t num)
Lookup token properties.
static void aml_token_peek(aml_term_list_ctx_t *ctx, aml_token_t *out)
Attempt to read a token from the AML stream, without advancing the instruction pointer.
@ AML_FIND_SET_RIGHT_BIT_OP
@ AML_TO_DECIMAL_STRING_OP
@ AML_FIND_SET_LEFT_BIT_OP
@ AML_TOKEN_TYPE_NAME
Is a Name Object (section 20.2.2).
clock_t timer_uptime(void)
Time since boot.
#define DEREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define REF(ptr)
Increment reference count.
#define DEREF(ptr)
Decrement reference count.
#define EINVAL
Invalid argument.
#define ENOSYS
Function not implemented.
#define errno
Error number variable.
#define EILSEQ
Illegal byte sequence.
#define NULL
Pointer error value.
#define ERR
Integer error value.
__UINT64_TYPE__ clock_t
A nanosecond time.
aml_object_t * value
The object that was passed as the argument.
Data for a buffer object.
aml_object_t * value
The value of the local variable.
uint8_t argCount
Amount of arguments (0-7)
aml_method_flags_t methodFlags
aml_object_reference_obj_t objectReference
aml_integer_obj_t integer
aml_package_obj_t package
Data for a package object.
aml_namespace_overlay_t overlay
Holds any named objects created during parsing.
aml_object_t * args[AML_MAX_ARGS+1]
Context for reading a TermList.
const aml_token_props_t * props