PatchworkOS
Loading...
Searching...
No Matches
Object

Object. More...

Data Structures

struct  aml_buffer_obj_t
 Data for a buffer object. More...
 
struct  aml_buffer_field_obj_t
 Data for a buffer field object. More...
 
struct  aml_event_obj_t
 Data placeholder for an event object. More...
 
struct  aml_field_unit_obj_t
 Data for a field unit object. More...
 
struct  aml_integer_obj_t
 Data for an integer object. More...
 
struct  aml_integer_constant_obj_t
 Data for an integer constant object. More...
 
struct  aml_method_obj_t
 Data for a method object. More...
 
struct  aml_mutex_obj_t
 Data for a mutex object. More...
 
struct  aml_object_reference_obj_t
 Data for an object reference object. More...
 
struct  aml_opregion_obj_t
 Data for an operation region object. More...
 
struct  aml_package_obj_t
 Data for a package object. More...
 
struct  aml_power_resource_obj_t
 
struct  aml_processor_obj_t
 Data for a processor object. More...
 
struct  aml_string_obj_t
 Data for a string object. More...
 
struct  aml_alias_obj_t
 Data for an alias object. More...
 
struct  aml_unresolved_obj_t
 Data for an unresolved object. More...
 
struct  aml_arg_obj_t
 Data for an argument object. More...
 
struct  aml_local_obj_t
 Data for a local variable object. More...
 
struct  aml_object_t
 ACPI object. More...
 

Macros

#define AML_SMALL_BUFFER_SIZE   32
 Size of buffers used for small objects optimization.
 
#define AML_SMALL_STRING_SIZE   AML_SMALL_BUFFER_SIZE
 Size of string buffers used for small objects optimization, not including the null terminator.
 
#define AML_SMALL_PACKAGE_SIZE   4
 Size of package element arrays used for small objects optimization.
 
#define AML_OBJECT_CACHE_SIZE   64
 Amount of objects to store in the cache before freeing them instead.
 
#define AML_OBJECT_ID_NONE   0
 Value for an invalid object id.
 
#define AML_OBJECT_COMMON_HEADER
 Common header for all AML objects.
 

Typedefs

typedef uint64_t aml_object_id_t
 Object id type.
 
typedef aml_object_t *(* aml_method_implementation_t) (aml_method_obj_t *method, aml_object_t **args, uint64_t argCount)
 Method Implementation function type.
 

Enumerations

enum  aml_type_t {
  AML_UNINITIALIZED = 0 ,
  AML_BUFFER = 1 << 0 ,
  AML_BUFFER_FIELD = 1 << 1 ,
  AML_DEBUG_OBJECT = 1 << 2 ,
  AML_DEVICE = 1 << 3 ,
  AML_EVENT = 1 << 4 ,
  AML_FIELD_UNIT = 1 << 5 ,
  AML_INTEGER = 1 << 6 ,
  AML_METHOD = 1 << 8 ,
  AML_MUTEX = 1 << 9 ,
  AML_OBJECT_REFERENCE = 1 << 10 ,
  AML_OPERATION_REGION = 1 << 11 ,
  AML_PACKAGE = 1 << 12 ,
  AML_POWER_RESOURCE = 1 << 13 ,
  AML_PROCESSOR = 1 << 14 ,
  AML_RAW_DATA_BUFFER = 1 << 15 ,
  AML_STRING = 1 << 16 ,
  AML_THERMAL_ZONE = 1 << 17 ,
  AML_ALIAS = 1 << 18 ,
  AML_UNRESOLVED = 1 << 19 ,
  AML_PREDEFINED_SCOPE = 1 << 20 ,
  AML_ARG = 1 << 21 ,
  AML_LOCAL = 1 << 22 ,
  AML_COMPUTATIONAL_DATA_OBJECTS = AML_INTEGER | AML_STRING | AML_BUFFER ,
  AML_DATA_OBJECTS = AML_COMPUTATIONAL_DATA_OBJECTS | AML_PACKAGE ,
  AML_DATA_REF_OBJECTS = AML_DATA_OBJECTS | AML_OBJECT_REFERENCE ,
  AML_NAMESPACES ,
  AML_ALL_TYPES ,
  AML_TYPE_AMOUNT = 20
}
 ACPI data types. More...
 
enum  aml_object_flags_t {
  AML_OBJECT_NONE = 0 ,
  AML_OBJECT_ROOT = 1 << 0 ,
  AML_OBJECT_NAMED = 1 << 1 ,
  AML_OBJECT_EXCEPTION_ON_USE = 1 << 2 ,
  AML_OBJECT_EXPOSED_IN_SYSFS = 1 << 3
}
 Flags for ACPI objects. More...
 
enum  aml_field_unit_obj_type_t {
  AML_FIELD_UNIT_NONE ,
  AML_FIELD_UNIT_FIELD ,
  AML_FIELD_UNIT_INDEX_FIELD ,
  AML_FIELD_UNIT_BANK_FIELD
}
 Field Unit types. More...
 

Functions

uint64_t aml_object_get_total_count (void)
 Get the total amount of allocated ACPI objects.
 
aml_object_taml_object_new (void)
 Allocate a new ACPI object.
 
void aml_object_clear (aml_object_t *object)
 Clear the data of a object, setting its type to AML_UNINITIALIZED.
 
uint64_t aml_object_count_children (aml_object_t *parent)
 Recursively count how many children an object has.
 
uint64_t aml_object_set_bits_at (aml_object_t *object, aml_bit_size_t bitOffset, aml_bit_size_t bitSize, uint8_t *in)
 Store bits into a object at the specified bit offset and size.
 
uint64_t aml_object_get_bits_at (aml_object_t *object, aml_bit_size_t bitOffset, aml_bit_size_t bitSize, uint8_t *out)
 Retrieve bits from a object at the specified bit offset and size.
 
void aml_object_exception_check (aml_object_t *object, aml_state_t *state)
 Check if a object has the AML_OBJECT_EXCEPTION_ON_USE flag set and raise an exception if it is.
 
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.
 
uint64_t aml_buffer_set_empty (aml_object_t *object, uint64_t length)
 Set a object as an empty buffer with the given length.
 
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_debug_object_set (aml_object_t *object)
 Set a object as a debug object.
 
uint64_t aml_device_set (aml_object_t *object)
 Set a object as a device or bus.
 
uint64_t aml_event_set (aml_object_t *object)
 Set a object as an event.
 
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_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_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.
 
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.
 
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.
 
aml_method_obj_taml_method_find (const uint8_t *addr)
 Find the method which contains the provided address in its AML bytecode range.
 
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_object_reference_set (aml_object_t *object, aml_object_t *target)
 Set a object as an ObjectReference to the given target object.
 
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_package_set (aml_object_t *object, uint64_t length)
 Set a object as a package with the given number of elements.
 
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_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_string_set_empty (aml_object_t *object, uint64_t length)
 Set a object as an empty string with the given length.
 
uint64_t aml_string_set (aml_object_t *object, const char *str)
 Set a object as a string with the given value.
 
uint64_t aml_string_resize (aml_string_obj_t *string, uint64_t newLength)
 Resize a string object to the new length.
 
uint64_t aml_thermal_zone_set (aml_object_t *object)
 Set a object as a thermal zone.
 
uint64_t aml_alias_set (aml_object_t *object, aml_object_t *target)
 Set a object as an alias to the given target object.
 
aml_object_taml_alias_obj_traverse (aml_alias_obj_t *alias)
 Traverse an alias object to get the target object.
 
uint64_t aml_unresolved_set (aml_object_t *object, const aml_name_string_t *nameString, aml_object_t *from, aml_patch_up_resolve_callback_t callback)
 Set a object as an unresolved reference with the given namestring and starting point.
 
uint64_t aml_predefined_scope_set (aml_object_t *object)
 Set a object as a predefined scope with the given name.
 
uint64_t aml_arg_set (aml_object_t *object, aml_object_t *value)
 Set a object as an argument with the given target object.
 
uint64_t aml_local_set (aml_object_t *object)
 Set a object as a empty local variable.
 

Detailed Description

Object.

Macro Definition Documentation

◆ AML_OBJECT_CACHE_SIZE

#define AML_OBJECT_CACHE_SIZE   64

Amount of objects to store in the cache before freeing them instead.

Definition at line 45 of file object.h.

◆ AML_OBJECT_COMMON_HEADER

#define AML_OBJECT_COMMON_HEADER
Value:
ref_t ref; \
aml_name_t name; \
map_entry_t mapEntry; \
list_entry_t listEntry; \
list_t children; \
list_entry_t siblingsEntry; \
aml_object_t* parent; \
aml_type_t type; \
dentry_t* dir
static char id[MAX_NAME]
Definition dwm.c:20
uint32_t aml_name_t
Name type.
Definition namespace.h:101
aml_type_t
ACPI data types.
Definition object.h:57
aml_object_flags_t
Flags for ACPI objects.
Definition object.h:123
uint64_t aml_object_id_t
Object id type.
Definition object.h:146
Namespace overlay.
Definition namespace.h:87
ACPI object.
Definition object.h:425
Directory entry structure.
Definition dentry.h:83
A entry in a doubly linked list.
Definition list.h:38
A doubly linked list.
Definition list.h:51
Map entry structure.
Definition map.h:57
Reference counting structure.
Definition ref.h:30

Common header for all AML objects.

Members:

  • ref Reference count for the object.
  • id The unique id of the object.
  • name The name of the object.
  • mapEntry Entry for the namespace map member.
  • listEntry Entry for the namespace objects member or the object cache list.
  • overlay The overlay this object is part of, NULL if part of the global namespace or unanamed.
  • children List of children, children hold references to the parent, parent does not hold references to children.
  • siblingsEntry Entry for the parent's children member.
  • parent Pointer to the parent object, NULL if root or unnamed.
  • flags Flags for the object, see aml_object_flags_t for more details.
  • type The type of the object, see aml_type_t for more details.
  • dir Sysfs directory for the object, only valid if flags has AML_OBJECT_EXPOSED_IN_SYSFS set.

Definition at line 192 of file object.h.

◆ AML_OBJECT_ID_NONE

#define AML_OBJECT_ID_NONE   0

Value for an invalid object id.

Definition at line 151 of file object.h.

◆ AML_SMALL_BUFFER_SIZE

#define AML_SMALL_BUFFER_SIZE   32

Size of buffers used for small objects optimization.

Definition at line 30 of file object.h.

◆ AML_SMALL_PACKAGE_SIZE

#define AML_SMALL_PACKAGE_SIZE   4

Size of package element arrays used for small objects optimization.

Definition at line 40 of file object.h.

◆ AML_SMALL_STRING_SIZE

#define AML_SMALL_STRING_SIZE   AML_SMALL_BUFFER_SIZE

Size of string buffers used for small objects optimization, not including the null terminator.

Definition at line 35 of file object.h.

Typedef Documentation

◆ aml_method_implementation_t

aml_method_implementation_t

Method Implementation function type.

Definition at line 173 of file object.h.

◆ aml_object_id_t

Object id type.

Used in a namespace in combination with a childs name to generate a hash to locate the child in the namespace.

Definition at line 146 of file object.h.

Enumeration Type Documentation

◆ aml_field_unit_obj_type_t

Field Unit types.

Since the ACPI spec does not differentiate between "objects" of type Field, IndexField and BankField, instead just calling them all FieldUnits, we use this enum to differentiate between different FieldUnit types, even if it might be cleaner to use aml_type_t for this.

Enumerator
AML_FIELD_UNIT_NONE 
AML_FIELD_UNIT_FIELD 
AML_FIELD_UNIT_INDEX_FIELD 
AML_FIELD_UNIT_BANK_FIELD 

Definition at line 161 of file object.h.

◆ aml_object_flags_t

Flags for ACPI objects.

Enumerator
AML_OBJECT_NONE 

No flags.

AML_OBJECT_ROOT 

Is the root object.

AML_OBJECT_NAMED 

Appears in the namespace tree. Will be set in aml_object_add().

AML_OBJECT_EXCEPTION_ON_USE 

The first time this object is used an exception will be raised. This is used such that when a method fails to implicitly or explicitly return a value the "synthetic" return value will raise an exception when used.

Any copy of an object with this flag will also have this flag set.

AML_OBJECT_EXPOSED_IN_SYSFS 

The object is exposed in sysfs. Will be set in aml_namespace_expose().

Definition at line 122 of file object.h.

◆ aml_type_t

enum aml_type_t

ACPI data types.

Note that objects can obviously only have one type but we use bitflags here to make it easier to define groups of types.

See also
Section 19.3.5 table 19.5 of the ACPI specification for more details.
Enumerator
AML_UNINITIALIZED 
AML_BUFFER 
AML_BUFFER_FIELD 
AML_DEBUG_OBJECT 
AML_DEVICE 
AML_EVENT 
AML_FIELD_UNIT 
AML_INTEGER 
AML_METHOD 

The spec does defined a separate Integer Constant type, but the spec seems very inconsistent about how to actually use it or even what it is. In 19.3.5 its "Created by the ASL terms 'Zero', 'One', 'Ones', and 'Revision'.". But in 19.6.102 the package creation example referes to a normal number "0x3400" as an Integer Constant. And there are also unanswered questions about what happens if a named object is created as an Integer Constant. The ACPICA tests seem to just treat even the result of 'Zero/One/Ones' as a normal Integer. I could go on. So unless ive missed something obvious, we just pretend it doesn't exist and treat it as a normal Integer.

AML_MUTEX 
AML_OBJECT_REFERENCE 
AML_OPERATION_REGION 
AML_PACKAGE 
AML_POWER_RESOURCE 
AML_PROCESSOR 
AML_RAW_DATA_BUFFER 
AML_STRING 
AML_THERMAL_ZONE 
AML_ALIAS 

Not in the spec, used internally to represent Aliases.

AML_UNRESOLVED 

Not in the spec, used internally to represent unresolved references.

AML_PREDEFINED_SCOPE 

Not in the spec, used internally to represent _SB, _GPE, etc.

AML_ARG 

Not in the spec, used internally to represent method arguments.

AML_LOCAL 

Not in the spec, used internally to represent method local variables.

AML_COMPUTATIONAL_DATA_OBJECTS 

All data types that can be retrieved from a ComputationalData object (section 20.2.3).

AML_DATA_OBJECTS 

All data types that can be retrieved from a DataObject (section 20.2.3).

You could also define it as static data, as in not stored in some firmware register or similar.

AML_DATA_REF_OBJECTS 

All data types that can be retrived from a DataRefObject (section 20.2.3).

AML_NAMESPACES 

All data types that can contain named objects, packages contain unnamed objects only and are excluded.

AML_ALL_TYPES 

All data types.

AML_TYPE_AMOUNT 

Not a type, just the amount of types.

Definition at line 56 of file object.h.

Function Documentation

◆ aml_alias_obj_traverse()

aml_object_t * aml_alias_obj_traverse ( aml_alias_obj_t alias)

Traverse an alias object to get the target object.

If the target is also an alias, it will be traversed recursively until a non-alias object is found.

Parameters
aliasPointer to the alias object to traverse.
Returns
On success, a reference to the target object. On failure, NULL and errno is set.

Definition at line 1114 of file object.c.

References aml_object_t::alias, AML_ALIAS, CONTAINER_OF, DEREF, next, NULL, REF, and aml_alias_obj_t::target.

Referenced by aml_namespace_find_child().

◆ aml_alias_set()

uint64_t aml_alias_set ( aml_object_t object,
aml_object_t target 
)

Set a object as an alias to the given target object.

This is used to implement the DefAlias structure.

Parameters
objectPointer to the object to initialize.
targetPointer to the target object the alias will point to.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 1096 of file object.c.

References AML_ALIAS, aml_object_check_clear(), EINVAL, ERR, errno, NULL, and REF.

Referenced by aml_def_alias_read().

◆ aml_arg_set()

uint64_t aml_arg_set ( aml_object_t object,
aml_object_t value 
)

Set a object as an argument with the given target object.

Parameters
objectPointer to the object to initialize.
valuePointer to the object the argument will point to, can be NULL.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 1179 of file object.c.

References AML_ARG, aml_object_check_clear(), EINVAL, ERR, errno, NULL, and REF.

Referenced by aml_state_init().

◆ aml_buffer_field_set()

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.

Parameters
objectPointer to the object to initialize.
targetPointer to the object to create the buffer field from, must be AML_BUFFER or AML_STRING.
bitOffsetBit offset within the buffer.
bitSizeSize of the field in bits.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 537 of file object.c.

References AML_BUFFER, AML_BUFFER_FIELD, aml_object_check_clear(), AML_STRING, EINVAL, ERR, errno, NULL, and REF.

Referenced by aml_def_create_bit_field_read(), aml_def_create_field_read(), aml_def_create_field_read_helper(), and aml_def_index_read().

◆ aml_buffer_set()

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.

Parameters
objectPointer to the object to initialize.
bufferPointer to the buffer.
bytesToCopyNumber of bytes to copy from buffer to the object, the rest will be zeroed.
lengthThe total length of the buffer.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 520 of file object.c.

References aml_buffer_set_empty(), aml_object_t::buffer, buffer, aml_buffer_obj_t::content, EINVAL, ERR, errno, memcpy(), and NULL.

Referenced by aml_copy_data_and_type(), aml_def_buffer_read(), and aml_integer_to_buffer().

◆ aml_buffer_set_empty()

uint64_t aml_buffer_set_empty ( aml_object_t object,
uint64_t  length 
)

Set a object as an empty buffer with the given length.

Parameters
objectPointer to the object to initialize.
lengthLength of the buffer will also be the capacity.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 487 of file object.c.

References AML_BUFFER, aml_object_check_clear(), AML_SMALL_BUFFER_SIZE, aml_object_t::buffer, aml_buffer_obj_t::content, EINVAL, ERR, errno, malloc(), memset(), and NULL.

Referenced by aml_buffer_field_load(), aml_buffer_set(), aml_concat_buffer(), aml_concat_integer(), aml_field_unit_load(), and aml_string_to_buffer().

◆ aml_debug_object_set()

uint64_t aml_debug_object_set ( aml_object_t object)

Set a object as a debug object.

Parameters
objectPointer to the object to initialize.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 564 of file object.c.

References AML_DEBUG_OBJECT, aml_object_check_clear(), EINVAL, ERR, errno, and NULL.

Referenced by aml_debug_obj_read().

◆ aml_device_set()

uint64_t aml_device_set ( aml_object_t object)

Set a object as a device or bus.

Parameters
objectPointer to the object to initialize.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 581 of file object.c.

References AML_DEVICE, aml_object_check_clear(), EINVAL, ERR, errno, and NULL.

Referenced by aml_def_device_read().

◆ aml_event_set()

uint64_t aml_event_set ( aml_object_t object)

Set a object as an event.

Parameters
objectPointer to the object to initialize.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 598 of file object.c.

References AML_EVENT, aml_object_check_clear(), EINVAL, ERR, errno, and NULL.

Referenced by aml_def_event_read().

◆ aml_field_unit_bank_field_set()

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.

Parameters
objectPointer to the object to initialize.
opregionPointer to the operation region.
bankPointer to the bank field.
bankValueValue to write to the bank object to select the bank structure.
flagsFlags for the field unit.
bitOffsetBit offset within the operation region.
bitSizeSize of the field in bits.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 669 of file object.c.

References AML_FIELD_UNIT, AML_FIELD_UNIT_BANK_FIELD, aml_integer_set(), aml_object_check_clear(), aml_object_new(), aml_field_unit_obj_t::bank, DEREF, EINVAL, ERR, errno, aml_object_t::fieldUnit, NULL, and REF.

Referenced by aml_name_field_read().

◆ aml_field_unit_field_set()

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.

Parameters
objectPointer to the object to initialize.
opregionPointer to the operation region.
flagsFlags for the field unit.
bitOffsetBit offset within the operation region.
bitSizeSize of the field in bits.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 615 of file object.c.

References AML_FIELD_UNIT, AML_FIELD_UNIT_FIELD, aml_object_check_clear(), EINVAL, ERR, errno, NULL, and REF.

Referenced by aml_name_field_read().

◆ aml_field_unit_index_field_set()

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.

Parameters
objectPointer to the object to initialize.
indexPointer to the index field.
dataPointer to the data field.
flagsFlags for the field unit.
bitOffsetBit offset within the operation region.
bitSizeSize of the field in bits.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 642 of file object.c.

References AML_FIELD_UNIT, AML_FIELD_UNIT_INDEX_FIELD, aml_object_check_clear(), data, EINVAL, ERR, errno, NULL, and REF.

Referenced by aml_name_field_read().

◆ aml_integer_set()

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.

Parameters
objectPointer to the object to initialize.
valueThe integer value to set.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 708 of file object.c.

References AML_INTEGER, aml_integer_ones(), aml_object_check_clear(), EINVAL, ERR, errno, and NULL.

Referenced by aml_buffer_field_load(), aml_buffer_to_integer(), aml_computational_data_read(), aml_const_obj_read(), aml_convert_to_integer(), aml_copy_data_and_type(), aml_def_acquire_read(), aml_def_add_read(), aml_def_and_read(), aml_def_cond_ref_of_read(), aml_def_decrement_read(), aml_def_divide_read(), aml_def_find_set_left_bit_read(), aml_def_find_set_right_bit_read(), aml_def_increment_read(), aml_def_land_read(), aml_def_lequal_read(), aml_def_lgreater_equal_read(), aml_def_lgreater_read(), aml_def_lless_equal_read(), aml_def_lless_read(), aml_def_lnot_equal_read(), aml_def_lnot_read(), aml_def_lor_read(), aml_def_match_read(), aml_def_mod_read(), aml_def_multiply_read(), aml_def_nand_read(), aml_def_nor_read(), aml_def_not_read(), aml_def_object_type_read(), aml_def_or_read(), aml_def_shift_left_read(), aml_def_shift_right_read(), aml_def_size_of_read(), aml_def_subtract_read(), aml_def_timer_read(), aml_def_to_bcd_read(), aml_def_xor_read(), aml_field_unit_bank_field_set(), aml_field_unit_load(), aml_generic_field_read_at(), aml_generic_field_write_at(), aml_osi_implementation(), aml_rev_implementation(), aml_revision_op_read(), aml_state_result_get(), and aml_string_to_integer().

◆ aml_local_set()

uint64_t aml_local_set ( aml_object_t object)

Set a object as a empty local variable.

Parameters
objectPointer to the object to initialize.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 1204 of file object.c.

References AML_LOCAL, aml_object_check_clear(), aml_object_new(), EINVAL, ERR, errno, aml_object_t::local, NULL, and aml_local_obj_t::value.

Referenced by aml_local_obj_read().

◆ aml_method_find()

aml_method_obj_t * aml_method_find ( const uint8_t addr)

Find the method which contains the provided address in its AML bytecode range.

Parameters
addrThe address to search for.
Returns
On success, a reference to the found method object. On failure, NULL and errno is set.

Definition at line 794 of file object.c.

References aml_method_find_recursive(), aml_namespace_get_root(), DEREF_DEFER, EINVAL, errno, and NULL.

Referenced by aml_debug_error().

◆ aml_method_set()

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.

Parameters
objectPointer to the object to initialize.
flagsFlags for the method.
startPointer to the start of the method's AML bytecode.
endPointer to the end of the method's AML bytecode.
implementationPointer to a C function that will execute the method, or NULL if the method is a normal AML method.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 732 of file object.c.

References AML_METHOD, aml_mutex_id_init(), aml_object_check_clear(), EINVAL, ERR, errno, aml_object_t::method, aml_method_obj_t::mutex, NULL, and start().

Referenced by aml_def_method_read(), and aml_predefined_init().

◆ aml_mutex_set()

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.

Parameters
objectPointer to the object to initialize.
syncLevelThe synchronization level of the mutex (0-15).
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 812 of file object.c.

References AML_MUTEX, aml_mutex_id_init(), aml_object_check_clear(), EINVAL, ERR, errno, aml_mutex_obj_t::mutex, aml_object_t::mutex, and NULL.

Referenced by aml_def_mutex_read(), and aml_predefined_init().

◆ aml_object_clear()

void aml_object_clear ( aml_object_t object)

Clear the data of a object, setting its type to AML_UNINITIALIZED.

Parameters
objectPointer to the object to clear.

Definition at line 87 of file object.c.

References aml_object_t::alias, AML_ALIAS, AML_ARG, AML_BUFFER, AML_BUFFER_FIELD, AML_DEBUG_OBJECT, AML_DEVICE, AML_EVENT, AML_FIELD_UNIT, AML_FIELD_UNIT_BANK_FIELD, AML_FIELD_UNIT_FIELD, AML_FIELD_UNIT_INDEX_FIELD, AML_INTEGER, AML_LOCAL, AML_METHOD, AML_MUTEX, aml_mutex_id_deinit(), aml_namespace_remove(), AML_NAMESPACES, AML_OBJECT_REFERENCE, AML_OPERATION_REGION, AML_PACKAGE, aml_patch_up_remove_unresolved(), AML_POWER_RESOURCE, AML_PREDEFINED_SCOPE, AML_PROCESSOR, AML_SMALL_BUFFER_SIZE, AML_SMALL_PACKAGE_SIZE, AML_SMALL_STRING_SIZE, AML_STRING, AML_THERMAL_ZONE, AML_UNINITIALIZED, AML_UNRESOLVED, aml_object_t::arg, aml_field_unit_obj_t::bank, aml_field_unit_obj_t::bankValue, aml_object_t::buffer, aml_object_t::bufferField, aml_buffer_obj_t::content, aml_string_obj_t::content, aml_field_unit_obj_t::data, DEREF, aml_package_obj_t::elements, aml_field_unit_obj_t::fieldType, aml_object_t::fieldUnit, free(), aml_unresolved_obj_t::from, aml_field_unit_obj_t::index, aml_buffer_obj_t::length, aml_package_obj_t::length, aml_string_obj_t::length, LIST_FOR_EACH_SAFE, aml_object_t::local, aml_object_t::method, aml_method_obj_t::mutex, aml_mutex_obj_t::mutex, aml_object_t::mutex, NULL, aml_object_t::objectReference, aml_field_unit_obj_t::opregion, aml_object_t::package, panic(), aml_object_t::string, aml_buffer_field_obj_t::target, aml_object_reference_obj_t::target, aml_alias_obj_t::target, aml_object_t::unresolved, aml_arg_obj_t::value, and aml_local_obj_t::value.

Referenced by aml_buffer_field_load(), aml_copy_data_and_type(), aml_def_package_read(), aml_def_var_package_read(), aml_generic_field_read_at(), aml_generic_field_write_at(), aml_object_check_clear(), aml_object_free(), and aml_package_element_list_read().

◆ aml_object_count_children()

uint64_t aml_object_count_children ( aml_object_t parent)

Recursively count how many children an object has.

This will also count package elements, any cached byteFields, etc. All objects that are owned by the parent object will be counted.

Parameters
parentPointer to the parent object.
Returns
The total amount of children the object has.

Definition at line 264 of file object.c.

References AML_FIELD_UNIT, AML_NAMESPACES, aml_object_count_children(), AML_PACKAGE, aml_field_unit_obj_t::bankValue, count, aml_package_obj_t::elements, aml_object_t::fieldUnit, aml_package_obj_t::length, LIST_FOR_EACH, NULL, and aml_object_t::package.

Referenced by aml_object_count_children().

◆ aml_object_exception_check()

void aml_object_exception_check ( aml_object_t object,
aml_state_t state 
)

Check if a object has the AML_OBJECT_EXCEPTION_ON_USE flag set and raise an exception if it is.

This will also clear the flag so the exception is only raised once.

Parameters
objectPointer to the object to check.
stateThe current AML state, used to raise the exception.

Definition at line 461 of file object.c.

References AML_EXCEPTION_RAISE, AML_OBJECT_EXCEPTION_ON_USE, and AML_PARSE.

Referenced by aml_term_arg_read().

◆ aml_object_get_bits_at()

uint64_t aml_object_get_bits_at ( aml_object_t object,
aml_bit_size_t  bitOffset,
aml_bit_size_t  bitSize,
uint8_t out 
)

Retrieve bits from a object at the specified bit offset and size.

Only supports Integers, Strings and Buffers.

If a out of bounds access is attempted, the bits that are out of bounds will be read as zero.

All objects, Intergers, Strings and Buffers are read from as if they were little-endian Integers.

Parameters
objectPointer to the object to extract bits from.
bitOffsetThe bit offset within the object's data to start extracting from.
bitSizeThe number of bits to store, out must be large enough to hold this many bits.
outPointer to a buffer where the extracted bits will be stored.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 399 of file object.c.

References AML_BUFFER, aml_copy_bits(), AML_INTEGER, aml_integer_bit_size(), aml_integer_ones(), AML_STRING, aml_string_obj_t::content, EINVAL, ERR, errno, memset(), NULL, and aml_object_t::string.

Referenced by aml_buffer_field_load(), aml_buffer_field_store(), and aml_field_unit_access().

◆ aml_object_get_total_count()

uint64_t aml_object_get_total_count ( void  )

Get the total amount of allocated ACPI objects.

Returns
The total amount of allocated ACPI objects.

Definition at line 24 of file object.c.

References totalObjects.

◆ aml_object_new()

aml_object_t * aml_object_new ( void  )

Allocate a new ACPI object.

There is no aml_object_free() instead always use DEREF() to free an object, since objects are reference counted.

You could also use DEREF_DEFER() to dereference the object when the current scope ends.

Returns
On success, a pointer to the new object. On failure, NULL and errno is set.

Definition at line 54 of file object.c.

References AML_NAME_UNDEFINED, aml_object_free(), AML_OBJECT_NONE, AML_UNINITIALIZED, calloc(), CONTAINER_OF_SAFE, list_entry_init(), list_init(), list_is_empty(), list_pop(), map_entry_init(), newObjectId, NULL, objectsCache, ref_init(), and totalObjects.

Referenced by aml_convert(), aml_convert_source(), aml_convert_to_buffer(), aml_convert_to_decimal_string(), aml_convert_to_hex_string(), aml_convert_to_integer(), aml_copy_object(), aml_create_predefined_scope(), aml_debug_obj_read(), aml_def_acquire_read(), aml_def_add_read(), aml_def_alias_read(), aml_def_and_read(), aml_def_concat_read(), aml_def_cond_ref_of_read(), aml_def_create_bit_field_read(), aml_def_create_field_read(), aml_def_create_field_read_helper(), aml_def_data_region_read(), aml_def_decrement_read(), aml_def_device_read(), aml_def_divide_read(), aml_def_event_read(), aml_def_find_set_left_bit_read(), aml_def_find_set_right_bit_read(), aml_def_increment_read(), aml_def_index_read(), aml_def_land_read(), aml_def_lequal_read(), aml_def_lgreater_equal_read(), aml_def_lgreater_read(), aml_def_lless_equal_read(), aml_def_lless_read(), aml_def_lnot_equal_read(), aml_def_lnot_read(), aml_def_lor_read(), aml_def_match_read(), aml_def_method_read(), aml_def_mod_read(), aml_def_multiply_read(), aml_def_mutex_read(), aml_def_name_read(), aml_def_nand_read(), aml_def_nor_read(), aml_def_not_read(), aml_def_object_type_read(), aml_def_opregion_read(), aml_def_or_read(), aml_def_power_res_read(), aml_def_processor_read(), aml_def_ref_of_read(), aml_def_shift_left_read(), aml_def_shift_right_read(), aml_def_size_of_read(), aml_def_subtract_read(), aml_def_thermal_zone_read(), aml_def_timer_read(), aml_def_to_bcd_read(), aml_def_to_string_read(), aml_def_xor_read(), aml_expression_opcode_read(), aml_field_unit_bank_field_set(), aml_generic_field_read_at(), aml_generic_field_write_at(), aml_init(), aml_local_obj_read(), aml_local_set(), aml_name_field_read(), aml_os_implementation(), aml_osi_implementation(), aml_package_set(), aml_predefined_init(), aml_rev_implementation(), aml_state_init(), aml_state_result_get(), aml_store(), and aml_term_arg_read().

◆ aml_object_reference_set()

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.

Parameters
objectPointer to the object to initialize.
targetPointer to the target object the ObjectReference will point to.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 831 of file object.c.

References aml_object_check_clear(), AML_OBJECT_REFERENCE, EINVAL, ERR, errno, NULL, and REF.

Referenced by aml_copy_data_and_type(), aml_def_cond_ref_of_read(), aml_def_index_read(), aml_def_ref_of_read(), and aml_package_element_handle_name().

◆ aml_object_set_bits_at()

uint64_t aml_object_set_bits_at ( aml_object_t object,
aml_bit_size_t  bitOffset,
aml_bit_size_t  bitSize,
uint8_t in 
)

Store bits into a object at the specified bit offset and size.

Only supports Integers, Strings and Buffers.

If a out of bounds access is attempted, the bits that are out of bounds will be ignored.

All objects, Intergers, Strings and Buffers are writen to as if they were little-endian Integers.

Parameters
objectPointer to the object to store bits into.
bitOffsetThe bit offset within the object's data to start storing to.
bitSizeThe number of bits to store, in must be large enough to hold this many bits.
inPointer to a buffer containing the bits to store.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 338 of file object.c.

References AML_BUFFER, aml_copy_bits(), AML_INTEGER, aml_integer_bit_size(), aml_integer_ones(), AML_STRING, aml_string_obj_t::content, data, EINVAL, ERR, errno, NULL, and aml_object_t::string.

Referenced by aml_buffer_field_load(), aml_buffer_field_store(), and aml_field_unit_access().

◆ aml_operation_region_set()

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.

Parameters
objectPointer to the object to initialize.
spaceThe address space of the operation region.
offsetThe offset within the address space.
lengthThe length of the operation region.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 849 of file object.c.

References aml_object_check_clear(), AML_OPERATION_REGION, EINVAL, ERR, errno, and NULL.

Referenced by aml_def_data_region_read(), and aml_def_opregion_read().

◆ aml_package_set()

uint64_t aml_package_set ( aml_object_t object,
uint64_t  length 
)

Set a object as a package with the given number of elements.

Parameters
objectPointer to the object to initialize.
lengthNumber of elements the package will be able to hold.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 869 of file object.c.

References aml_object_check_clear(), aml_object_new(), AML_PACKAGE, AML_SMALL_PACKAGE_SIZE, DEREF, EINVAL, aml_package_obj_t::elements, ERR, errno, free(), malloc(), memset(), NULL, and aml_object_t::package.

Referenced by aml_copy_data_and_type(), aml_def_package_read(), and aml_def_var_package_read().

◆ aml_power_resource_set()

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.

Parameters
objectPointer to the object to initialize.
systemLevelThe system level of the power resource.
resourceOrderThe resource order of the power resource.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 915 of file object.c.

References aml_object_check_clear(), AML_POWER_RESOURCE, EINVAL, ERR, errno, and NULL.

Referenced by aml_def_power_res_read().

◆ aml_predefined_scope_set()

uint64_t aml_predefined_scope_set ( aml_object_t object)

Set a object as a predefined scope with the given name.

This is used to implement predefined scopes like _SB, _GPE, etc.

Parameters
objectPointer to the object to initialize.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 1162 of file object.c.

References aml_object_check_clear(), AML_PREDEFINED_SCOPE, EINVAL, ERR, errno, and NULL.

Referenced by aml_create_predefined_scope(), and aml_init().

◆ aml_processor_set()

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.

Parameters
objectPointer to the object to initialize.
procIdThe processor ID.
pblkAddrThe pblk address.
pblkLenThe length of the pblk.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 935 of file object.c.

References aml_object_check_clear(), AML_PROCESSOR, EINVAL, ERR, errno, and NULL.

Referenced by aml_def_processor_read().

◆ aml_string_resize()

uint64_t aml_string_resize ( aml_string_obj_t string,
uint64_t  newLength 
)

Resize a string object to the new length.

If the new length is greater than the current length, the new bytes will be initialized to zero.

Parameters
stringPointer to the string object to resize.
newLengthThe new length of the string, not including the null terminator.
Returns
On success, the new length of the string. On failure, ERR and errno is set.

Definition at line 1005 of file object.c.

References AML_SMALL_STRING_SIZE, aml_string_obj_t::content, EINVAL, ERR, errno, free(), aml_string_obj_t::length, malloc(), memcpy(), memset(), NULL, and aml_string_obj_t::smallString.

Referenced by aml_string_prepare().

◆ aml_string_set()

uint64_t aml_string_set ( aml_object_t object,
const char *  str 
)

Set a object as a string with the given value.

Parameters
objectPointer to the object to initialize.
strPointer to the string.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 988 of file object.c.

References aml_string_set_empty(), aml_string_obj_t::content, EINVAL, ERR, errno, memcpy(), NULL, aml_object_t::string, and strlen().

Referenced by aml_copy_data_and_type(), aml_os_implementation(), and aml_string_read().

◆ aml_string_set_empty()

uint64_t aml_string_set_empty ( aml_object_t object,
uint64_t  length 
)

Set a object as an empty string with the given length.

The string will be initalized with zero chars and be null terminated.

Parameters
objectPointer to the object to initialize.
lengthLength of the string, not including the null terminator.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 955 of file object.c.

References aml_object_check_clear(), AML_SMALL_STRING_SIZE, AML_STRING, aml_string_obj_t::content, EINVAL, ERR, errno, malloc(), memset(), NULL, and aml_object_t::string.

Referenced by aml_concat_other_types(), aml_concat_string(), aml_convert_to_decimal_string(), aml_convert_to_hex_string(), aml_def_to_string_read(), aml_string_prepare(), and aml_string_set().

◆ aml_thermal_zone_set()

uint64_t aml_thermal_zone_set ( aml_object_t object)

Set a object as a thermal zone.

Parameters
objectPointer to the object to initialize.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 1079 of file object.c.

References aml_object_check_clear(), AML_THERMAL_ZONE, EINVAL, ERR, errno, and NULL.

Referenced by aml_def_thermal_zone_read().

◆ aml_unresolved_set()

uint64_t aml_unresolved_set ( aml_object_t object,
const aml_name_string_t nameString,
aml_object_t from,
aml_patch_up_resolve_callback_t  callback 
)

Set a object as an unresolved reference with the given namestring and starting point.

The object will be resolved later by calling aml_patch_up_resolve_all().

Parameters
objectPointer to the object to initialize.
nameStringPointer to the namestring representing the path to the target object.
fromPointer to the object to start the search from, can be NULL to start from the root.
callbackPointer to a callback function that will be called when a matching object is found
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 1135 of file object.c.

References aml_object_check_clear(), aml_patch_up_add_unresolved(), AML_UNINITIALIZED, AML_UNRESOLVED, EINVAL, ERR, errno, aml_unresolved_obj_t::nameString, NULL, REF, and aml_object_t::unresolved.

Referenced by aml_package_element_read().