105 if (newObject ==
NULL)
131 if (flags & (1 << 7))
133 AML_DEBUG_ERROR(ctx,
"Reserved bit 7 is set in FieldFlags '0x%x'", flags);
141 AML_DEBUG_ERROR(ctx,
"Invalid AccessType in FieldFlags '0x%x'", accessType);
148 .lockRule = (flags >> 4) & 0x1,
149 .updateRule = (flags >> 5) & 0x3,
172 if (newObject ==
NULL)
178 switch (fieldCtx->
type)
290 else if (token.
num == 0x00)
341 if (opregion ==
NULL)
368 .field.opregion = &opregion->
opregion,
471 if (opregion ==
NULL)
504 .bank.opregion = &opregion->
opregion,
527 uint8_t argCount = flags & 0x7;
528 bool isSerialized = (flags >> 3) & 0x1;
529 uint8_t syncLevel = (flags >> 4) & 0xF;
533 .isSerialized = isSerialized,
534 .syncLevel = syncLevel,
574 if (newObject ==
NULL)
654 AML_DEBUG_ERROR(ctx,
"Reserved bits are set in SyncFlags '0x%x'", flags);
686 if (newObject ==
NULL)
780 if (processor ==
NULL)
806 if (sourceBuff ==
NULL)
846 if (sourceBuff ==
NULL)
870 if (newObject ==
NULL)
896 if (sourceBuff ==
NULL)
920 if (newObject ==
NULL)
972 if (newObject ==
NULL)
1015 if (thermalZone ==
NULL)
1099 if (powerResource ==
NULL)
1142 if (sourceBuff ==
NULL)
1173 if (newObject ==
NULL)
1205 if (signature ==
NULL)
1221 if (oemTableId ==
NULL)
1242 AML_DEBUG_ERROR(ctx,
"Failed to find ACPI table with signature '%s', oemId '%s' and oemTableId '%s'",
1263 if (oemTableId->
length != 0)
1279 if (newObject ==
NULL)
#define assert(expression)
#define AML_DEBUG_ERROR(ctx, format,...)
Macro to simplify calling aml_debug_error() with the current function name.
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_dword_data_read(aml_term_list_ctx_t *ctx, uint32_t *out)
Read a DWordData 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_create_field_read(aml_term_list_ctx_t *ctx)
Reads a DefCreateField structure from the AML byte stream.
uint64_t aml_def_opregion_read(aml_term_list_ctx_t *ctx)
Reads a DefOpRegion structure from the AML byte stream.
uint8_t aml_proc_id_t
ProcID structure, deprecated in version 6.4 of the ACPI specification.
uint64_t aml_def_device_read(aml_term_list_ctx_t *ctx)
Reads a DefDevice structure from the AML byte stream.
uint64_t aml_field_flags_read(aml_term_list_ctx_t *ctx, aml_field_flags_t *out)
Reads a FieldFlags structure from the AML byte stream.
uint64_t aml_name_string_read(aml_term_list_ctx_t *ctx, aml_name_string_t *out)
Reads the next data as a NameString structure from the AML bytecode stream.
uint64_t aml_reserved_field_read(aml_term_list_ctx_t *ctx, aml_field_list_ctx_t *fieldCtx)
Reads a ReservedField structure from the AML byte stream.
uint32_t aml_pblk_addr_t
PblkAddr structure, deprecated in version 6.4 of the ACPI specification.
uint64_t aml_def_index_field_read(aml_term_list_ctx_t *ctx)
Reads a DefIndexField 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...
uint64_t aml_def_field_read(aml_term_list_ctx_t *ctx)
Reads a DefField structure from the AML byte stream.
uint64_t aml_byte_index_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads a ByteIndex structure from the AML byte stream.
aml_access_type_t
Enum for all field access types, bits 0-3 of FieldFlags.
uint64_t aml_def_create_byte_field_read(aml_term_list_ctx_t *ctx)
Reads a DefCreateByteField structure from the AML byte stream.
uint64_t aml_def_bank_field_read(aml_term_list_ctx_t *ctx)
Reads a DefBankField structure from the AML byte stream.
uint64_t aml_field_element_read(aml_term_list_ctx_t *ctx, aml_field_list_ctx_t *fieldCtx)
Reads a FieldElement structure from the AML byte stream.
uint64_t aml_sync_flags_read(aml_term_list_ctx_t *ctx, aml_sync_level_t *out)
Reads a SyncFlags structure from the AML byte stream.
uint64_t aml_def_thermal_zone_read(aml_term_list_ctx_t *ctx)
Reads a DefThermalZone structure from the AML byte stream.
uint64_t aml_region_space_read(aml_term_list_ctx_t *ctx, aml_region_space_t *out)
Reads a RegionSpace structure from the AML byte stream.
uint64_t aml_num_bits_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads a NumBits structure from the AML byte stream.
uint64_t aml_def_create_dword_field_read(aml_term_list_ctx_t *ctx)
Reads a DefCreateDWordField structure from the AML byte stream.
uint64_t aml_name_seg_read(aml_term_list_ctx_t *ctx, aml_name_seg_t **out)
Reads the next data as a NameSeg from the AML bytecode stream.
uint64_t aml_def_data_region_read(aml_term_list_ctx_t *ctx)
Reads a DefDataRegion structure from the AML byte stream.
#define AML_IS_LEAD_NAME_CHAR(token)
Check if a token is a LeadNameChar structure.
uint64_t aml_def_create_word_field_read(aml_term_list_ctx_t *ctx)
Reads a DefCreateWordField structure from the AML byte stream.
uint64_t aml_def_create_qword_field_read(aml_term_list_ctx_t *ctx)
Reads a DefCreateQWordField structure from the AML byte stream.
uint64_t aml_name_field_read(aml_term_list_ctx_t *ctx, aml_field_list_ctx_t *fieldCtx)
Reads a NamedField structure from the AML byte stream.
uint64_t aml_system_level_read(aml_term_list_ctx_t *ctx, aml_system_level_t *out)
Reads a SystemLevel structure from the AML byte stream.
uint64_t aml_def_create_bit_field_read(aml_term_list_ctx_t *ctx)
Reads a DefCreateBitField structure from the AML byte stream.
uint8_t aml_system_level_t
SystemLevel structure.
uint64_t aml_def_method_read(aml_term_list_ctx_t *ctx)
Reads a DefMethod structure from the AML byte stream.
uint64_t aml_def_event_read(aml_term_list_ctx_t *ctx)
Reads a DefEvent structure from the AML byte stream.
uint64_t aml_named_obj_read(aml_term_list_ctx_t *ctx)
Reads a NamedObj structure from the AML byte stream.
uint8_t aml_pblk_len_t
PblkLen structure, deprecated in version 6.4 of the ACPI specification.
uint64_t aml_def_mutex_read(aml_term_list_ctx_t *ctx)
Reads a DefMutex structure from the AML byte stream.
uint64_t aml_proc_id_read(aml_term_list_ctx_t *ctx, aml_proc_id_t *out)
Reads a ProcID structure from the AML byte stream. Deprecated in ACPI 6.4 but still supported.
uint64_t aml_bit_index_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads a BitIndex structure from the AML byte stream.
uint64_t aml_def_processor_read(aml_term_list_ctx_t *ctx)
Reads a DefProcessor structure from the AML byte stream. Deprecated in ACPI 6.4 but still supported.
aml_object_t * aml_source_buff_read(aml_term_list_ctx_t *ctx)
Reads a SourceBuff structure from the AML byte stream.
uint64_t aml_pblk_len_read(aml_term_list_ctx_t *ctx, aml_pblk_len_t *out)
Reads a PblkLen structure from the AML byte stream. Deprecated in ACPI 6.4 but still supported.
uint64_t aml_bank_value_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads a BankValue structure from the AML byte stream.
aml_region_space_t
Region Space Encoding.
uint64_t aml_resource_order_read(aml_term_list_ctx_t *ctx, aml_resource_order_t *out)
Reads a ResourceOrder structure from the AML byte stream.
uint64_t aml_method_flags_read(aml_term_list_ctx_t *ctx, aml_method_flags_t *out)
Reads a MethodFlags structure from the AML byte stream.
uint16_t aml_resource_order_t
ResourceOrder structure.
uint64_t aml_def_power_res_read(aml_term_list_ctx_t *ctx)
Reads a DefPowerRes structure from the AML byte stream.
uint64_t aml_region_offset_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads a RegionOffset structure from the AML byte stream.
uint64_t aml_region_len_read(aml_term_list_ctx_t *ctx, aml_integer_t *out)
Reads a RegionLen structure from the AML byte stream.
uint64_t aml_field_list_read(aml_term_list_ctx_t *ctx, aml_field_list_ctx_t *fieldCtx, const uint8_t *end)
Reads a FieldList structure from the AML byte stream.
uint64_t aml_pblk_addr_read(aml_term_list_ctx_t *ctx, aml_pblk_addr_t *out)
Reads a PblkAddr structure from the AML byte stream. Deprecated in ACPI 6.4 but still supported.
@ AML_FIELD_LIST_TYPE_FIELD
FieldList is part of a DefField.
@ AML_FIELD_LIST_TYPE_BANK_FIELD
FieldList is part of a BankField.
@ AML_FIELD_LIST_TYPE_INDEX_FIELD
FieldList is part of an IndexField.
@ AML_REGION_SYSTEM_MEMORY
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.
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.
aml_string_obj_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.
uint64_t aml_integer_t
AML Integer type.
#define AML_NAME_TO_STRING(name)
Macro to convert an aml_name_t to a stack allocated string.
uint64_t aml_namespace_add_child(aml_namespace_overlay_t *overlay, aml_object_t *parent, aml_name_t name, aml_object_t *object)
Add an child to a parent in the namespace heirarchy.
uint64_t aml_namespace_add_by_name_string(aml_namespace_overlay_t *overlay, aml_object_t *start, const aml_name_string_t *nameString, aml_object_t *object)
Add an object to the namespace heirarchy using a name string.
uint64_t aml_field_unit_field_set(aml_object_t *object, aml_opregion_obj_t *opregion, aml_field_flags_t flags, aml_bit_size_t bitOffset, aml_bit_size_t bitSize)
Set a object as a field unit of type Field.
uint64_t aml_method_set(aml_object_t *object, aml_method_flags_t flags, const uint8_t *start, const uint8_t *end, aml_method_implementation_t implementation)
Set a object as a method with the given flags and address range.
uint64_t aml_event_set(aml_object_t *object)
Set a object as an event.
uint64_t aml_device_set(aml_object_t *object)
Set a object as a device or bus.
uint64_t aml_mutex_set(aml_object_t *object, aml_sync_level_t syncLevel)
Set a object as a mutex with the given synchronization level.
uint64_t aml_power_resource_set(aml_object_t *object, aml_system_level_t systemLevel, aml_resource_order_t resourceOrder)
Set a object as a power resource with the given system level and resource order.
uint64_t aml_thermal_zone_set(aml_object_t *object)
Set a object as a thermal zone.
aml_object_t * aml_object_new(void)
Allocate a new ACPI object.
uint64_t aml_field_unit_index_field_set(aml_object_t *object, aml_field_unit_obj_t *index, aml_field_unit_obj_t *data, aml_field_flags_t flags, aml_bit_size_t bitOffset, aml_bit_size_t bitSize)
Set a object as a field unit of type IndexField.
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_processor_set(aml_object_t *object, aml_proc_id_t procId, aml_pblk_addr_t pblkAddr, aml_pblk_len_t pblkLen)
Set a object as a processor with the given ProcID, PblkAddr, and PblkLen.
uint64_t aml_operation_region_set(aml_object_t *object, aml_region_space_t space, uintptr_t offset, uint32_t length)
Set a object as an operation region with the given space, offset, and length.
uint64_t aml_field_unit_bank_field_set(aml_object_t *object, aml_opregion_obj_t *opregion, aml_field_unit_obj_t *bank, uint64_t bankValue, aml_field_flags_t flags, aml_bit_size_t bitOffset, aml_bit_size_t bitSize)
Set a object as a field unit of type BankField.
const char * aml_name_string_to_string(const aml_name_string_t *nameString)
Convert an aml NameString 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 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_CREATE_BIT_FIELD_OP
@ AML_CREATE_QWORD_FIELD_OP
@ AML_DEPRECATED_PROCESSOR_OP
@ AML_CREATE_BYTE_FIELD_OP
@ AML_CREATE_WORD_FIELD_OP
@ AML_CREATE_DWORD_FIELD_OP
sdt_header_t * acpi_tables_lookup(const char *signature, uint64_t n)
Lookup the n'th table matching the signature.
#define SDT_OEM_ID_LENGTH
The length of the OEM ID field in the SDT header structure.
#define SDT_OEM_TABLE_ID_LENGTH
The length of the OEM Table ID field in the SDT header structure.
#define SDT_SIGNATURE_LENGTH
The length of the signature field in the SDT header structure.
#define DEREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define ENOENT
No such file or directory.
#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.
static uint64_t aml_def_create_field_read_helper(aml_term_list_ctx_t *ctx, uint8_t fieldWidth, aml_token_num_t expectedOp)
_PUBLIC int strncmp(const char *s1, const char *s2, size_t n)
aml_access_type_t accessType
Context passed to lower functions by aml_field_list_read().
aml_field_unit_obj_t * bank
struct aml_field_list_ctx_t::@0::@2 field
aml_field_flags_t flags
The flags of the FieldList.
aml_bit_size_t currentOffset
The current offset within the opregion.
aml_opregion_obj_t * opregion
aml_field_unit_obj_t * index
aml_field_list_type_t type
The type of FieldList.
aml_field_unit_obj_t * bank
Used for BankField.
aml_field_unit_obj_t * index
Used for IndexField.
aml_field_unit_obj_t * data
Used for IndexField.
aml_opregion_obj_t * opregion
Used for Field and BankField.
aml_object_t * bankValue
Used for BankField.
uint8_t argCount
Amount of arguments (0-7)
aml_opregion_obj_t opregion
aml_field_unit_obj_t fieldUnit
aml_namespace_overlay_t overlay
Holds any named objects created during parsing.
Data for a string object.
Context for reading a TermList.
const aml_token_props_t * props