|
PatchworkOS
2ca1c69
A non-POSIX operating system.
|
Object. More...
Object.
Data Structures | |
| struct | aml_buffer_t |
| Data for a buffer object. More... | |
| struct | aml_buffer_field_t |
| Data for a buffer field object. More... | |
| struct | aml_device_t |
| Data for a device object. More... | |
| struct | aml_event_t |
| Data placeholder for an event object. More... | |
| struct | aml_field_unit_t |
| Data for a field unit object. More... | |
| struct | aml_integer_t |
| Data for an integer object. More... | |
| struct | aml_integer_constant_t |
| Data for an integer constant object. More... | |
| struct | aml_method_t |
| Data for a method object. More... | |
| struct | aml_mutex_t |
| Data for a mutex object. More... | |
| struct | aml_object_reference_t |
| Data for an object reference object. More... | |
| struct | aml_opregion_t |
| Data for an operation region object. More... | |
| struct | aml_package_t |
| Data for a package object. More... | |
| struct | aml_power_resource_t |
| struct | aml_processor_t |
| Data for a processor object. More... | |
| struct | aml_string_t |
| Data for a string object. More... | |
| struct | aml_alias_t |
| Data for an alias object. More... | |
| struct | aml_unresolved_t |
| Data for an unresolved object. More... | |
| struct | aml_arg_t |
| Data for an argument object. More... | |
| struct | aml_local_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_t *method, aml_object_t **args, uint64_t argCount) |
| Method Implementation function type. | |
Functions | |
| uint64_t | aml_object_get_total_count (void) |
| Get the total amount of allocated ACPI objects. | |
| aml_object_t * | aml_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. | |
| uint64_t | aml_buffer_resize (aml_buffer_t *buffer, uint64_t newLength) |
| Resize a buffer object to the new length. | |
| 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_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_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_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_t *index, aml_field_unit_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_t *opregion, aml_field_unit_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_uint_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_t * | aml_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_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_t * | aml_alias_traverse (aml_alias_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. | |
| #define AML_SMALL_BUFFER_SIZE 32 |
| #define AML_SMALL_STRING_SIZE AML_SMALL_BUFFER_SIZE |
| #define AML_SMALL_PACKAGE_SIZE 4 |
| #define AML_OBJECT_CACHE_SIZE 64 |
| #define AML_OBJECT_ID_NONE 0 |
| #define AML_OBJECT_COMMON_HEADER |
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. | aml_method_implementation_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.
| enum 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_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 |
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 | |
| uint64_t aml_object_get_total_count | ( | void | ) |
| 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.
NULL and errno is set. Definition at line 62 of file object.c.
| void aml_object_clear | ( | aml_object_t * | object | ) |
| 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.
| parent | Pointer to the parent object. |
Definition at line 277 of file object.c.
| 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.
| object | Pointer to the object to store bits into. |
| bitOffset | The bit offset within the object's data to start storing to. |
| bitSize | The number of bits to store, in must be large enough to hold this many bits. |
| in | Pointer to a buffer containing the bits to store. |
0. On failure, ERR and errno is set. Definition at line 351 of file object.c.
| 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.
| object | Pointer to the object to extract bits from. |
| bitOffset | The bit offset within the object's data to start extracting from. |
| bitSize | The number of bits to store, out must be large enough to hold this many bits. |
| out | Pointer to a buffer where the extracted bits will be stored. |
0. On failure, ERR and errno is set. Definition at line 412 of file object.c.
| uint64_t aml_buffer_resize | ( | aml_buffer_t * | buffer, |
| uint64_t | newLength | ||
| ) |
Resize a buffer object to the new length.
If the new length is greater than the current length, the new bytes will be zeroed.
| buffer | Pointer to the buffer object to resize. |
| newLength | The new length of the buffer. |
0. On failure, ERR and errno is set. Definition at line 490 of file object.c.
| uint64_t aml_buffer_set_empty | ( | aml_object_t * | object, |
| uint64_t | length | ||
| ) |
Set a object as an empty buffer with the given length.
| object | Pointer to the object to initialize. |
| length | Length of the buffer will also be the capacity. |
0. On failure, ERR and errno is set. Definition at line 533 of file object.c.
| 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.
| object | Pointer to the object to initialize. |
| buffer | Pointer to the buffer. |
| bytesToCopy | Number of bytes to copy from buffer to the object, the rest will be zeroed. |
| length | The total length of the buffer. |
0. On failure, ERR and errno is set. Definition at line 576 of file object.c.
| 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.
| object | Pointer to the object to initialize. |
| target | Pointer to the object to create the buffer field from, must be AML_BUFFER or AML_STRING. |
| bitOffset | Bit offset within the buffer. |
| bitSize | Size of the field in bits. |
0. On failure, ERR and errno is set. Definition at line 594 of file object.c.
| uint64_t aml_debug_object_set | ( | aml_object_t * | object | ) |
| uint64_t aml_device_set | ( | aml_object_t * | object | ) |
| uint64_t aml_event_set | ( | aml_object_t * | object | ) |
| uint64_t aml_field_unit_field_set | ( | aml_object_t * | object, |
| aml_opregion_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.
| object | Pointer to the object to initialize. |
| opregion | Pointer to the operation region. |
| flags | Flags for the field unit. |
| bitOffset | Bit offset within the operation region. |
| bitSize | Size of the field in bits. |
0. On failure, ERR and errno is set. Definition at line 680 of file object.c.
| uint64_t aml_field_unit_index_field_set | ( | aml_object_t * | object, |
| aml_field_unit_t * | index, | ||
| aml_field_unit_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.
| object | Pointer to the object to initialize. |
| index | Pointer to the index field. |
| data | Pointer to the data field. |
| flags | Flags for the field unit. |
| bitOffset | Bit offset within the operation region. |
| bitSize | Size of the field in bits. |
0. On failure, ERR and errno is set. Definition at line 707 of file object.c.
| uint64_t aml_field_unit_bank_field_set | ( | aml_object_t * | object, |
| aml_opregion_t * | opregion, | ||
| aml_field_unit_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.
| object | Pointer to the object to initialize. |
| opregion | Pointer to the operation region. |
| bank | Pointer to the bank field. |
| bankValue | Value to write to the bank object to select the bank structure. |
| flags | Flags for the field unit. |
| bitOffset | Bit offset within the operation region. |
| bitSize | Size of the field in bits. |
0. On failure, ERR and errno is set. Definition at line 734 of file object.c.
| uint64_t aml_integer_set | ( | aml_object_t * | object, |
| aml_uint_t | value | ||
| ) |
Set a object as an integer with the given value and bit width.
| object | Pointer to the object to initialize. |
| value | The integer value to set. |
0. On failure, ERR and errno is set. Definition at line 772 of file object.c.
| 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.
| object | Pointer to the object to initialize. |
| flags | Flags for the method. |
| start | Pointer to the start of the method's AML bytecode. |
| end | Pointer to the end of the method's AML bytecode. |
| implementation | Pointer to a C function that will execute the method, or NULL if the method is a normal AML method. |
0. On failure, ERR and errno is set. Definition at line 796 of file object.c.
| aml_method_t * aml_method_find | ( | const uint8_t * | addr | ) |
Find the method which contains the provided address in its AML bytecode range.
| addr | The address to search for. |
NULL and errno is set. Definition at line 858 of file object.c.
| 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.
| object | Pointer to the object to initialize. |
| syncLevel | The synchronization level of the mutex (0-15). |
0. On failure, ERR and errno is set. Definition at line 876 of file object.c.
| 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.
| object | Pointer to the object to initialize. |
| target | Pointer to the target object the ObjectReference will point to. |
0. On failure, ERR and errno is set. Definition at line 895 of file object.c.
| 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.
| object | Pointer to the object to initialize. |
| space | The address space of the operation region. |
| offset | The offset within the address space. |
| length | The length of the operation region. |
0. On failure, ERR and errno is set. Definition at line 920 of file object.c.
| uint64_t aml_package_set | ( | aml_object_t * | object, |
| uint64_t | length | ||
| ) |
Set a object as a package with the given number of elements.
| object | Pointer to the object to initialize. |
| length | Number of elements the package will be able to hold. |
0. On failure, ERR and errno is set. Definition at line 940 of file object.c.
| 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.
| object | Pointer to the object to initialize. |
| systemLevel | The system level of the power resource. |
| resourceOrder | The resource order of the power resource. |
0. On failure, ERR and errno is set. Definition at line 986 of file object.c.
| 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.
| object | Pointer to the object to initialize. |
| procId | The processor ID. |
| pblkAddr | The pblk address. |
| pblkLen | The length of the pblk. |
0. On failure, ERR and errno is set. Definition at line 1006 of file object.c.
| 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.
| object | Pointer to the object to initialize. |
| length | Length of the string, not including the null terminator. |
0. On failure, ERR and errno is set. Definition at line 1026 of file object.c.
| uint64_t aml_string_set | ( | aml_object_t * | object, |
| const char * | str | ||
| ) |
Set a object as a string with the given value.
| object | Pointer to the object to initialize. |
| str | Pointer to the string. |
0. On failure, ERR and errno is set. Definition at line 1068 of file object.c.
| uint64_t aml_string_resize | ( | aml_string_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.
| string | Pointer to the string object to resize. |
| newLength | The new length of the string, not including the null terminator. |
ERR and errno is set. Definition at line 1085 of file object.c.
| uint64_t aml_thermal_zone_set | ( | aml_object_t * | object | ) |
| 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.
| object | Pointer to the object to initialize. |
| target | Pointer to the target object the alias will point to. |
0. On failure, ERR and errno is set. Definition at line 1153 of file object.c.
| aml_object_t * aml_alias_traverse | ( | aml_alias_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.
| alias | Pointer to the alias object to traverse. |
NULL and errno is set. Definition at line 1171 of file object.c.
| 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().
| object | Pointer to the object to initialize. |
| nameString | Pointer to the namestring representing the path to the target object. |
| from | Pointer to the object to start the search from, can be NULL to start from the root. |
| callback | Pointer to a callback function that will be called when a matching object is found |
0. On failure, ERR and errno is set. Definition at line 1192 of file object.c.
| 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.
| object | Pointer to the object to initialize. |
0. On failure, ERR and errno is set. Definition at line 1219 of file object.c.
| uint64_t aml_arg_set | ( | aml_object_t * | object, |
| aml_object_t * | value | ||
| ) |
Set a object as an argument with the given target object.
| object | Pointer to the object to initialize. |
| value | Pointer to the object the argument will point to, can be NULL. |
0. On failure, ERR and errno is set. Definition at line 1236 of file object.c.
| uint64_t aml_local_set | ( | aml_object_t * | object | ) |