PatchworkOS  321f6ec
A non-POSIX operating system.
Loading...
Searching...
No Matches
object.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/fs/sysfs.h>
4#include <kernel/utils/ref.h>
10
11#include <stdint.h>
12
13typedef struct acpi_device_cfg acpi_device_cfg_t;
14
15typedef struct aml_state aml_state_t;
16typedef struct aml_object aml_object_t;
17typedef struct aml_opregion aml_opregion_t;
18typedef struct aml_string aml_string_t;
19typedef struct aml_method aml_method_t;
20
21/**
22 * @brief Object
23 * @defgroup modules_acpi_aml_object Object
24 * @ingroup modules_acpi_aml
25 *
26 * @{
27 */
28
29/**
30 * @brief Size of buffers used for small objects optimization.
31 */
32#define AML_SMALL_BUFFER_SIZE 32
33
34/**
35 * @brief Size of string buffers used for small objects optimization, not including the null terminator.
36 */
37#define AML_SMALL_STRING_SIZE AML_SMALL_BUFFER_SIZE
38
39/**
40 * @brief Size of package element arrays used for small objects optimization.
41 */
42#define AML_SMALL_PACKAGE_SIZE 4
43
44/**
45 * @brief Amount of objects to store in the cache before freeing them instead.
46 */
47#define AML_OBJECT_CACHE_SIZE 64
48
49/**
50 * @brief ACPI data types.
51 * @enum aml_type_t
52 *
53 * Note that objects can obviously only have one type but we use bitflags here to make it easier to define groups of
54 * types.
55 *
56 * @see Section 19.3.5 table 19.5 of the ACPI specification for more details.
57 */
58typedef enum
59{
61 AML_BUFFER = 1 << 0,
64 AML_DEVICE = 1 << 3,
65 AML_EVENT = 1 << 4,
67 AML_INTEGER = 1 << 6,
68 /**
69 * The spec does defined a separate Integer Constant type, but the spec seems very inconsistent about how to
70 * actually use it or even what it is. In 19.3.5 its "Created by the ASL terms 'Zero', 'One', 'Ones', and
71 * 'Revision'.". But in 19.6.102 the package creation example referes to a normal number "0x3400" as an Integer
72 * Constant. And there are also unanswered questions about what happens if a named object is created as an Integer
73 * Constant. The ACPICA tests seem to just treat even the result of 'Zero/One/Ones' as a normal Integer. I could go
74 * on. So unless ive missed something obvious, we just pretend it doesn't exist and treat it as a normal Integer.
75 */
76 // AML_INTEGER_CONSTANT = 1 << 7,
77 AML_METHOD = 1 << 8,
78 AML_MUTEX = 1 << 9,
81 AML_PACKAGE = 1 << 12,
83 AML_PROCESSOR = 1 << 14,
85 AML_STRING = 1 << 16,
87 AML_ALIAS = 1 << 18, ///< Not in the spec, used internally to represent Aliases.
88 AML_UNRESOLVED = 1 << 19, ///< Not in the spec, used internally to represent unresolved references.
89 AML_PREDEFINED_SCOPE = 1 << 20, ///< Not in the spec, used internally to represent \_SB, \_GPE, etc.
90 AML_ARG = 1 << 21, ///< Not in the spec, used internally to represent method arguments.
91 AML_LOCAL = 1 << 22, ///< Not in the spec, used internally to represent method local variables.
92 /**
93 * All data types that can be retrieved from a ComputationalData object (section 20.2.3).
94 */
96 /**
97 * All data types that can be retrieved from a DataObject (section 20.2.3).
98 *
99 * You could also define it as static data, as in not stored in some firmware register or similar.
100 */
102 /**
103 * All data types that can be retrived from a DataRefObject (section 20.2.3).
104 */
106 /**
107 * All data types that can contain named objects, packages contain unnamed objects only and are excluded.
108 */
111 /**
112 * All data types.
113 */
117 AML_TYPE_AMOUNT = 20, ///< Not a type, just the amount of types.
118} aml_type_t;
119
120/**
121 * @brief Flags for ACPI objects.
122 * @enum aml_object_flags_t
123 */
124typedef enum
125{
126 AML_OBJECT_NONE = 0, ///< No flags.
127 AML_OBJECT_ROOT = 1 << 0, ///< Is the root object.
128 AML_OBJECT_NAMED = 1 << 1, ///< Appears in the namespace tree. Will be set in `aml_object_add()`.
129 /**
130 * The first time this object is used an exception will be raised. This is used such that when a method fails to
131 * implicitly or explicitly return a value the "synthetic" return value will raise an exception when used.
132 *
133 * Any copy of an object with this flag will also have this flag set.
134 */
136 /**
137 * The object is exposed in sysfs. Will be set in `aml_namespace_expose()`.
138 */
141
142/**
143 * @brief Object id type.
144 * @typedef aml_object_id_t
145 *
146 * Used in a namespace in combination with a childs name to generate a hash to locate the child in the namespace.
147 */
149
150/**
151 * @brief Value for an invalid object id.
152 */
153#define AML_OBJECT_ID_NONE 0
154
155/**
156 * @brief Field Unit types.
157 * @enum aml_field_unit_type_t
158 *
159 * Since the ACPI spec does not differentiate between "objects" of type Field, IndexField and BankField, instead just
160 * calling them all FieldUnits, we use this enum to differentiate between different FieldUnit types, even if it might
161 * be cleaner to use aml_type_t for this.
162 */
170
171/**
172 * @brief Method Implementation function type.
173 * @typedef aml_method_implementation_t
174 */
175typedef aml_object_t* (*aml_method_implementation_t)(aml_method_t* method, aml_object_t** args, uint64_t argCount);
176
177/**
178 * @brief Common header for all AML objects.
179 *
180 * Members:
181 * - `ref` Reference count for the object.
182 * - `id` The unique id of the object.
183 * - `name` The name of the object.
184 * - `mapEntry` Entry for the namespace `map` member.
185 * - `listEntry` Entry for the namespace `objects` member or the object cache list.
186 * - `overlay` The overlay this object is part of, `NULL` if part of the global namespace or unanamed.
187 * - `children` List of children, children hold references to the parent, parent does not hold references to children.
188 * - `siblingsEntry` Entry for the parent's `children` member.
189 * - `parent` Pointer to the parent object, `NULL` if root or unnamed.
190 * - `flags` Flags for the object, see `aml_object_flags_t` for more details.
191 * - `type` The type of the object, see `aml_type_t` for more details.
192 * - `dir` Sysfs directory for the object, only valid if `flags` has `AML_OBJECT_EXPOSED_IN_SYSFS` set.
193 */
194#define AML_OBJECT_COMMON_HEADER \
195 ref_t ref; \
196 aml_object_id_t id; \
197 aml_name_t name; \
198 map_entry_t mapEntry; \
199 list_entry_t listEntry; \
200 aml_overlay_t* overlay; \
201 list_t children; \
202 list_entry_t siblingsEntry; \
203 aml_object_t* parent; \
204 aml_object_flags_t flags; \
205 aml_type_t type; \
206 dentry_t* dir
207
208/**
209 * @brief Data for a buffer object.
210 * @struct aml_buffer_t
211 */
212typedef struct aml_buffer
213{
217 uint8_t smallBuffer[AML_SMALL_BUFFER_SIZE]; ///< Used for small object optimization.
219
220/**
221 * @brief Data for a buffer field object.
222 * @struct aml_buffer_field_t
223 */
231
232/**
233 * @brief Data for a device object.
234 * @struct aml_device_t
235 */
236typedef struct aml_device
237{
239 /**
240 * Stores various device configuration data.
241 *
242 * A device is considered properly configured when this pointer is not `NULL`, attempting to free a configured
243 * device will cause a panic.
244 *
245 * This pointer is managed by the devices system found in `devices.h` or @ref modules_acpi_devices.
246 *
247 * @see acpi_device_cfg_t for more details.
248 */
251
252/**
253 * @brief Data placeholder for an event object.
254 * @struct aml_event_t
255 *
256 * @todo Implement event object functionality.
257 */
258typedef struct aml_event
259{
262
263/**
264 * @brief Data for a field unit object.
265 * @struct aml_field_unit_t
266 */
267typedef struct aml_field_unit
268{
270 aml_field_unit_type_t fieldType; ///< The type of field unit.
271 aml_field_unit_t* index; ///< Used for IndexField.
272 aml_field_unit_t* data; ///< Used for IndexField.
273 aml_object_t* bankValue; ///< Used for BankField.
274 aml_field_unit_t* bank; ///< Used for BankField.
275 aml_opregion_t* opregion; ///< Used for Field and BankField.
276 aml_field_flags_t fieldFlags; ///< Used for Field, IndexField and BankField.
277 aml_bit_size_t bitOffset; ///< Used for Field, IndexField and BankField.
278 aml_bit_size_t bitSize; ///< Used for Field, IndexField and BankField.
280
281/**
282 * @brief Data for an integer object.
283 * @struct aml_integer_t
284 */
285typedef struct aml_integer
286{
290
291/**
292 * @brief Data for an integer constant object.
293 * @struct aml_integer_constant_t
294 */
295typedef struct aml_integer_constant
296{
300
301/**
302 * @brief Data for a method object.
303 * @struct aml_method_t
304 */
305typedef struct aml_method
306{
308 /**
309 * Pointer to the C function that will execute the method. Really just used to implement predefined the
310 * predefined method _OSI. If `implementation` is `NULL`, the method is just a normal AML method.
311 */
315 const uint8_t* end;
318
319/**
320 * @brief Data for a mutex object.
321 * @struct aml_mutex_t
322 */
329
330/**
331 * @brief Data for an object reference object.
332 * @struct aml_object_reference_t
333 */
334typedef struct aml_object_reference
335{
339
340/**
341 * @brief Data for an operation region object.
342 * @struct aml_opregion_t
343 */
351
352/**
353 * @brief Data for a package object.
354 * @struct aml_package_t
355 *
356 * Packages use an array to store the elements not a linked list since indexing is very common with packages.
357 */
358typedef struct aml_package
359{
363 aml_object_t* smallElements[AML_SMALL_PACKAGE_SIZE]; ///< Used for small object optimization.
365
372
373/**
374 * @brief Data for a processor object.
375 * @struct aml_processor_t
376 */
384
385/**
386 * @brief Data for a string object.
387 * @struct aml_string_t
388 */
389typedef struct aml_string
390{
392 char* content;
394 char smallString[AML_SMALL_STRING_SIZE + 1]; ///< Used for small object optimization.
396
397/**
398 * @brief Data for an alias object.
399 * @struct aml_alias_t
400 */
406
407/**
408 * @brief Data for an unresolved object.
409 * @struct aml_unresolved_t
410 */
411typedef struct aml_unresolved
412{
414 aml_name_string_t nameString; ///< The NameString representing the path to the target object.
415 aml_object_t* from; ///< The object to start the search from when resolving the reference.
416 aml_patch_up_resolve_callback_t callback; ///< The callback to call when a matching object is found.
418
419/**
420 * @brief Data for an argument object.
421 * @struct aml_arg_t
422 *
423 * Arguments are disgusting but the way passing arguments work is described in section 5.5.2.3 of the ACPI
424 * specification.
425 */
426typedef struct aml_arg
427{
429 aml_object_t* value; ///< The object that was passed as the argument.
430} aml_arg_t;
431
432/**
433 * @brief Data for a local variable object.
434 * @struct aml_local_t
435 */
436typedef struct aml_local
437{
439 aml_object_t* value; ///< The value of the local variable.
441
442/**
443 * @brief ACPI object.
444 * @struct aml_object_t
445 */
475
476/**
477 * @brief Get the total amount of allocated ACPI objects.
478 *
479 * @return The total amount of allocated ACPI objects.
480 */
482
483/**
484 * @brief Allocate a new ACPI object.
485 *
486 * There is no `aml_object_free()` instead always use `UNREF()` to free an object, since objects are reference counted.
487 *
488 * You could also use `UNREF_DEFER()` to dereference the object when the current scope ends.
489 *
490 * @return On success, a pointer to the new object. On failure, `NULL` and `errno` is set.
491 */
493
494/**
495 * @brief Clear the data of a object, setting its type to `AML_UNINITIALIZED`.
496 *
497 * @param object Pointer to the object to clear.
498 */
499void aml_object_clear(aml_object_t* object);
500
501/**
502 * @brief Recursively count how many children an object has.
503 *
504 * This will also count package elements, any cached byteFields, etc. All objects that are owned by the parent
505 * object will be counted.
506 *
507 * @param parent Pointer to the parent object.
508 * @return The total amount of children the object has.
509 */
511
512/**
513 * @brief Store bits into a object at the specified bit offset and size.
514 *
515 * Only supports Integers, Strings and Buffers.
516 *
517 * If a out of bounds access is attempted, the bits that are out of bounds will be ignored.
518 *
519 * All objects, Intergers, Strings and Buffers are writen to as if they were little-endian Integers.
520 *
521 * @param object Pointer to the object to store bits into.
522 * @param bitOffset The bit offset within the object's data to start storing to.
523 * @param bitSize The number of bits to store, `in` must be large enough to hold this many bits.
524 * @param in Pointer to a buffer containing the bits to store.
525 * @return On success, `0`. On failure, `ERR` and `errno` is set.
526 */
528
529/**
530 * @brief Retrieve bits from a object at the specified bit offset and size.
531 *
532 * Only supports Integers, Strings and Buffers.
533 *
534 * If a out of bounds access is attempted, the bits that are out of bounds will be read as zero.
535 *
536 * All objects, Intergers, Strings and Buffers are read from as if they were little-endian Integers.
537 *
538 * @param object Pointer to the object to extract bits from.
539 * @param bitOffset The bit offset within the object's data to start extracting from.
540 * @param bitSize The number of bits to store, `out` must be large enough to hold this many bits.
541 * @param out Pointer to a buffer where the extracted bits will be stored.
542 * @return On success, `0`. On failure, `ERR` and `errno` is set.
543 */
545
546/**
547 * @brief Resize a buffer object to the new length.
548 *
549 * If the new length is greater than the current length, the new bytes will be zeroed.
550 *
551 * @param buffer Pointer to the buffer object to resize.
552 * @param newLength The new length of the buffer.
553 * @return On success, `0`. On failure, `ERR` and `errno` is set.
554 */
556
557/**
558 * @brief Set a object as an empty buffer with the given length.
559 *
560 * @param object Pointer to the object to initialize.
561 * @param length Length of the buffer will also be the capacity.
562 * @return On success, `0`. On failure, `ERR` and `errno` is set.
563 */
565
566/**
567 * @brief Set a object as a buffer with the given content.
568 *
569 * @param object Pointer to the object to initialize.
570 * @param buffer Pointer to the buffer.
571 * @param bytesToCopy Number of bytes to copy from `buffer` to the object, the rest will be zeroed.
572 * @param length The total length of the buffer.
573 * @return On success, `0`. On failure, `ERR` and `errno` is set.
574 */
575uint64_t aml_buffer_set(aml_object_t* object, const uint8_t* buffer, uint64_t bytesToCopy, uint64_t length);
576
577/**
578 * @brief Set a object as a buffer field with the given buffer, bit offset and bit size.
579 *
580 * @param object Pointer to the object to initialize.
581 * @param target Pointer to the object to create the buffer field from, must be `AML_BUFFER` or `AML_STRING`.
582 * @param bitOffset Bit offset within the buffer.
583 * @param bitSize Size of the field in bits.
584 * @return On success, `0`. On failure, `ERR` and `errno` is set.
585 */
587 aml_bit_size_t bitSize);
588
589/**
590 * @brief Set a object as a debug object.
591 *
592 * @param object Pointer to the object to initialize.
593 * @return On success, `0`. On failure, `ERR` and `errno` is set.
594 */
596
597/**
598 * @brief Set a object as a device or bus.
599 *
600 * @param object Pointer to the object to initialize.
601 * @return On success, `0`. On failure, `ERR` and `errno` is set.
602 */
604
605/**
606 * @brief Set a object as an event.
607 *
608 * @param object Pointer to the object to initialize.
609 * @return On success, `0`. On failure, `ERR` and `errno` is set.
610 */
612
613/**
614 * @brief Set a object as a field unit of type Field.
615 *
616 * @param object Pointer to the object to initialize.
617 * @param opregion Pointer to the operation region.
618 * @param flags Flags for the field unit.
619 * @param bitOffset Bit offset within the operation region.
620 * @param bitSize Size of the field in bits.
621 * @return On success, `0`. On failure, `ERR` and `errno` is set.
622 */
624 aml_bit_size_t bitOffset, aml_bit_size_t bitSize);
625
626/**
627 * @brief Set a object as a field unit of type IndexField.
628 *
629 * @param object Pointer to the object to initialize.
630 * @param index Pointer to the index field.
631 * @param data Pointer to the data field.
632 * @param flags Flags for the field unit.
633 * @param bitOffset Bit offset within the operation region.
634 * @param bitSize Size of the field in bits.
635 * @return On success, `0`. On failure, `ERR` and `errno` is set.
636 */
639
640/**
641 * @brief Set a object as a field unit of type BankField.
642 *
643 * @param object Pointer to the object to initialize.
644 * @param opregion Pointer to the operation region.
645 * @param bank Pointer to the bank field.
646 * @param bankValue Value to write to the bank object to select the bank structure.
647 * @param flags Flags for the field unit.
648 * @param bitOffset Bit offset within the operation region.
649 * @param bitSize Size of the field in bits.
650 * @return On success, `0`. On failure, `ERR` and `errno` is set.
651 */
653 uint64_t bankValue, aml_field_flags_t flags, aml_bit_size_t bitOffset, aml_bit_size_t bitSize);
654
655/**
656 * @brief Set a object as an integer with the given value and bit width.
657 *
658 * @param object Pointer to the object to initialize.
659 * @param value The integer value to set.
660 * @return On success, `0`. On failure, `ERR` and `errno` is set.
661 */
663
664/**
665 * @brief Set a object as a method with the given flags and address range.
666 *
667 * @param object Pointer to the object to initialize.
668 * @param flags Flags for the method.
669 * @param start Pointer to the start of the method's AML bytecode.
670 * @param end Pointer to the end of the method's AML bytecode.
671 * @param implementation Pointer to a C function that will execute the method, or `NULL` if the method is a normal
672 * AML method.
673 * @return On success, `0`. On failure, `ERR` and `errno` is set.
674 */
676 aml_method_implementation_t implementation);
677
678/**
679 * @brief Find the method which contains the provided address in its AML bytecode range.
680 *
681 * @param addr The address to search for.
682 * @return On success, a reference to the found method object. On failure, `NULL` and `errno` is set.
683 */
685
686/**
687 * @brief Set a object as a mutex with the given synchronization level.
688 *
689 * @param object Pointer to the object to initialize.
690 * @param syncLevel The synchronization level of the mutex (0-15).
691 * @return On success, `0`. On failure, `ERR` and `errno` is set.
692 */
694
695/**
696 * @brief Set a object as an ObjectReference to the given target object.
697 *
698 * @param object Pointer to the object to initialize.
699 * @param target Pointer to the target object the ObjectReference will point to.
700 * @return On success, `0`. On failure, `ERR` and `errno` is set.
701 */
703
704/**
705 * @brief Set a object as an operation region with the given space, offset, and length.
706 *
707 * @param object Pointer to the object to initialize.
708 * @param space The address space of the operation region.
709 * @param offset The offset within the address space.
710 * @param length The length of the operation region.
711 * @return On success, `0`. On failure, `ERR` and `errno` is set.
712 */
714
715/**
716 * @brief Set a object as a package with the given number of elements.
717 *
718 * @param object Pointer to the object to initialize.
719 * @param length Number of elements the package will be able to hold.
720 * @return On success, `0`. On failure, `ERR` and `errno` is set.
721 */
723
724/**
725 * @brief Set a object as a power resource with the given system level and resource order.
726 *
727 * @param object Pointer to the object to initialize.
728 * @param systemLevel The system level of the power resource.
729 * @param resourceOrder The resource order of the power resource.
730 * @return On success, `0`. On failure, `ERR` and `errno` is set.
731 */
733 aml_resource_order_t resourceOrder);
734
735/**
736 * @brief Set a object as a processor with the given ProcID, PblkAddr, and PblkLen.
737 *
738 * @param object Pointer to the object to initialize.
739 * @param procId The processor ID.
740 * @param pblkAddr The pblk address.
741 * @param pblkLen The length of the pblk.
742 * @return On success, `0`. On failure, `ERR` and `errno` is set.
743 */
745 aml_pblk_len_t pblkLen);
746
747/**
748 * @brief Set a object as an empty string with the given length.
749 *
750 * The string will be initalized with zero chars and be null terminated.
751 *
752 * @param object Pointer to the object to initialize.
753 * @param length Length of the string, not including the null terminator.
754 * @return On success, `0`. On failure, `ERR` and `errno` is set.
755 */
757
758/**
759 * @brief Set a object as a string with the given value.
760 *
761 * @param object Pointer to the object to initialize.
762 * @param str Pointer to the string.
763 * @return On success, `0`. On failure, `ERR` and `errno` is set.
764 */
765uint64_t aml_string_set(aml_object_t* object, const char* str);
766
767/**
768 * @brief Resize a string object to the new length.
769 *
770 * If the new length is greater than the current length, the new bytes will be initialized to zero.
771 *
772 * @param string Pointer to the string object to resize.
773 * @param newLength The new length of the string, not including the null terminator.
774 * @return On success, the new length of the string. On failure, `ERR` and `errno` is set.
775 */
777
778/**
779 * @brief Set a object as a thermal zone.
780 *
781 * @param object Pointer to the object to initialize.
782 * @return On success, `0`. On failure, `ERR` and `errno` is set.
783 */
785
786/**
787 * @brief Set a object as an alias to the given target object.
788 *
789 * This is used to implement the DefAlias structure.
790 *
791 * @param object Pointer to the object to initialize.
792 * @param target Pointer to the target object the alias will point to.
793 * @return On success, `0`. On failure, `ERR` and `errno` is set.
794 */
796
797/**
798 * @brief Traverse an alias object to get the target object.
799 *
800 * If the target is also an alias, it will be traversed recursively until a non-alias object is found.
801 *
802 * @param alias Pointer to the alias object to traverse.
803 * @return On success, a reference to the target object. On failure, `NULL` and `errno` is set.
804 */
806
807/**
808 * @brief Set a object as an unresolved reference with the given namestring and starting point.
809 *
810 * The object will be resolved later by calling `aml_patch_up_resolve_all()`.
811 *
812 * @param object Pointer to the object to initialize.
813 * @param nameString Pointer to the namestring representing the path to the target object.
814 * @param from Pointer to the object to start the search from, can be `NULL` to start from the root.
815 * @param callback Pointer to a callback function that will be called when a matching object is found
816 * @return On success, `0`. On failure, `ERR` and `errno` is set.
817 */
820
821/**
822 * @brief Set a object as a predefined scope with the given name.
823 *
824 * This is used to implement predefined scopes like \_SB, \_GPE, etc.
825 *
826 * @param object Pointer to the object to initialize.
827 * @return On success, `0`. On failure, `ERR` and `errno` is set.
828 */
830
831/**
832 * @brief Set a object as an argument with the given target object.
833 *
834 * @param object Pointer to the object to initialize.
835 * @param value Pointer to the object the argument will point to, can be `NULL`.
836 * @return On success, `0`. On failure, `ERR` and `errno` is set.
837 */
839
840/**
841 * @brief Set a object as a empty local variable.
842 *
843 * @param object Pointer to the object to initialize.
844 * @return On success, `0`. On failure, `ERR` and `errno` is set.
845 */
847
848/** @} */
static fd_t data
Definition dwm.c:21
uint64_t aml_bit_size_t
Represents a size in bits within an opregion.
uint8_t aml_proc_id_t
ProcID structure, deprecated in version 6.4 of the ACPI specification.
Definition named.h:151
uint32_t aml_pblk_addr_t
PblkAddr structure, deprecated in version 6.4 of the ACPI specification.
Definition named.h:156
uint8_t aml_system_level_t
SystemLevel structure.
Definition named.h:166
uint8_t aml_pblk_len_t
PblkLen structure, deprecated in version 6.4 of the ACPI specification.
Definition named.h:161
uint8_t aml_sync_level_t
Definition named.h:135
aml_region_space_t
Region Space Encoding.
Definition named.h:30
uint16_t aml_resource_order_t
ResourceOrder structure.
Definition named.h:171
uint64_t aml_uint_t
AML Integer type.
Definition integer.h:20
uint64_t aml_mutex_id_t
Mutex id.
Definition mutex.h:28
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.
Definition object.c:895
uint64_t aml_buffer_resize(aml_buffer_t *buffer, uint64_t newLength)
Resize a buffer object to the new length.
Definition object.c:490
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.
Definition object.c:734
aml_method_t * aml_method_find(const uint8_t *addr)
Find the method which contains the provided address in its AML bytecode range.
Definition object.c:858
aml_type_t
ACPI data types.
Definition object.h:59
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.
Definition object.c:796
uint64_t aml_local_set(aml_object_t *object)
Set a object as a empty local variable.
Definition object.c:1261
uint64_t aml_event_set(aml_object_t *object)
Set a object as an event.
Definition object.c:663
uint64_t aml_device_set(aml_object_t *object)
Set a object as a device or bus.
Definition object.c:645
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.
Definition object.c:876
aml_field_unit_type_t
Field Unit types.
Definition object.h:164
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.
Definition object.c:986
uint64_t aml_package_set(aml_object_t *object, uint64_t length)
Set a object as a package with the given number of elements.
Definition object.c:940
#define AML_SMALL_STRING_SIZE
Size of string buffers used for small objects optimization, not including the null terminator.
Definition object.h:37
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.
Definition object.c:707
uint64_t aml_object_count_children(aml_object_t *parent)
Recursively count how many children an object has.
Definition object.c:277
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.
Definition object.c:680
uint64_t aml_thermal_zone_set(aml_object_t *object)
Set a object as a thermal zone.
Definition object.c:1136
aml_object_t * aml_object_new(void)
Allocate a new ACPI object.
Definition object.c:62
uint64_t aml_string_set(aml_object_t *object, const char *str)
Set a object as a string with the given value.
Definition object.c:1068
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.
Definition object.c:351
uint64_t aml_alias_set(aml_object_t *object, aml_object_t *target)
Set a object as an alias to the given target object.
Definition object.c:1153
uint64_t aml_arg_set(aml_object_t *object, aml_object_t *value)
Set a object as an argument with the given target object.
Definition object.c:1236
aml_object_t * aml_alias_traverse(aml_alias_t *alias)
Traverse an alias object to get the target object.
Definition object.c:1171
uint64_t aml_predefined_scope_set(aml_object_t *object)
Set a object as a predefined scope with the given name.
Definition object.c:1219
uint64_t aml_buffer_set_empty(aml_object_t *object, uint64_t length)
Set a object as an empty buffer with the given length.
Definition object.c:533
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.
Definition object.c:594
uint64_t aml_string_set_empty(aml_object_t *object, uint64_t length)
Set a object as an empty string with the given length.
Definition object.c:1026
aml_object_t *(* aml_method_implementation_t)(aml_method_t *method, aml_object_t **args, uint64_t argCount)
Method Implementation function type.
Definition object.h:175
uint64_t aml_debug_object_set(aml_object_t *object)
Set a object as a debug object.
Definition object.c:628
aml_object_flags_t
Flags for ACPI objects.
Definition object.h:125
void aml_object_clear(aml_object_t *object)
Clear the data of a object, setting its type to AML_UNINITIALIZED.
Definition object.c:96
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.
Definition object.c:412
uint64_t aml_object_id_t
Object id type.
Definition object.h:148
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.
Definition object.c:1006
#define AML_SMALL_BUFFER_SIZE
Size of buffers used for small objects optimization.
Definition object.h:32
uint64_t aml_object_get_total_count(void)
Get the total amount of allocated ACPI objects.
Definition object.c:23
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.
Definition object.c:772
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.
Definition object.c:920
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.
Definition object.c:1192
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.
Definition object.c:576
uint64_t aml_string_resize(aml_string_t *string, uint64_t newLength)
Resize a string object to the new length.
Definition object.c:1085
#define AML_SMALL_PACKAGE_SIZE
Size of package element arrays used for small objects optimization.
Definition object.h:42
@ AML_UNRESOLVED
Not in the spec, used internally to represent unresolved references.
Definition object.h:88
@ AML_METHOD
Definition object.h:77
@ AML_BUFFER_FIELD
Definition object.h:62
@ AML_PROCESSOR
Definition object.h:83
@ AML_PACKAGE
Definition object.h:81
@ AML_OBJECT_REFERENCE
Definition object.h:79
@ AML_OPERATION_REGION
Definition object.h:80
@ AML_TYPE_AMOUNT
Not a type, just the amount of types.
Definition object.h:117
@ AML_DEBUG_OBJECT
Definition object.h:63
@ AML_STRING
Definition object.h:85
@ AML_ALIAS
Not in the spec, used internally to represent Aliases.
Definition object.h:87
@ AML_ARG
Not in the spec, used internally to represent method arguments.
Definition object.h:90
@ AML_THERMAL_ZONE
Definition object.h:86
@ AML_FIELD_UNIT
Definition object.h:66
@ AML_DATA_OBJECTS
Definition object.h:101
@ AML_POWER_RESOURCE
Definition object.h:82
@ AML_COMPUTATIONAL_DATA_OBJECTS
Definition object.h:95
@ AML_DATA_REF_OBJECTS
Definition object.h:105
@ AML_EVENT
Definition object.h:65
@ AML_DEVICE
Definition object.h:64
@ AML_NAMESPACES
Definition object.h:109
@ AML_MUTEX
Definition object.h:78
@ AML_LOCAL
Not in the spec, used internally to represent method local variables.
Definition object.h:91
@ AML_ALL_TYPES
Definition object.h:114
@ AML_INTEGER
Definition object.h:67
@ AML_PREDEFINED_SCOPE
Not in the spec, used internally to represent _SB, _GPE, etc.
Definition object.h:89
@ AML_UNINITIALIZED
Definition object.h:60
@ AML_RAW_DATA_BUFFER
Definition object.h:84
@ AML_BUFFER
Definition object.h:61
@ AML_FIELD_UNIT_BANK_FIELD
Definition object.h:168
@ AML_FIELD_UNIT_NONE
Definition object.h:165
@ AML_FIELD_UNIT_FIELD
Definition object.h:166
@ AML_FIELD_UNIT_INDEX_FIELD
Definition object.h:167
@ AML_OBJECT_EXPOSED_IN_SYSFS
Definition object.h:139
@ AML_OBJECT_ROOT
Is the root object.
Definition object.h:127
@ AML_OBJECT_EXCEPTION_ON_USE
Definition object.h:135
@ AML_OBJECT_NAMED
Appears in the namespace tree. Will be set in aml_object_add().
Definition object.h:128
@ AML_OBJECT_NONE
No flags.
Definition object.h:126
uint64_t(* aml_patch_up_resolve_callback_t)(aml_state_t *state, aml_object_t *match, aml_object_t *unresolved)
Callback type for resolving a forward reference.
Definition patch_up.h:25
EFI_PHYSICAL_ADDRESS buffer
Definition mem.c:15
static const path_flag_t flags[]
Definition path.c:42
static void start()
Definition main.c:542
__UINT32_TYPE__ uint32_t
Definition stdint.h:15
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
__UINT8_TYPE__ uint8_t
Definition stdint.h:11
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:43
ACPI device configuration structure.
Definition devices.h:112
Data for an alias object.
Definition object.h:402
aml_object_t * target
Definition object.h:404
AML_OBJECT_COMMON_HEADER
Definition object.h:403
Data for an argument object.
Definition object.h:427
aml_object_t * value
The object that was passed as the argument.
Definition object.h:429
AML_OBJECT_COMMON_HEADER
Definition object.h:428
Data for a buffer field object.
Definition object.h:225
aml_object_t * target
Definition object.h:227
aml_bit_size_t bitSize
Definition object.h:229
aml_bit_size_t bitOffset
Definition object.h:228
Data for a buffer object.
Definition object.h:213
uint64_t length
Definition object.h:216
uint8_t * content
Definition object.h:215
AML_OBJECT_COMMON_HEADER
Definition object.h:214
Data for a device object.
Definition object.h:237
AML_OBJECT_COMMON_HEADER
Definition object.h:238
acpi_device_cfg_t * cfg
Definition object.h:249
Data placeholder for an event object.
Definition object.h:259
AML_OBJECT_COMMON_HEADER
Definition object.h:260
FieldFlags structure.
Definition named.h:86
Data for a field unit object.
Definition object.h:268
aml_opregion_t * opregion
Used for Field and BankField.
Definition object.h:275
aml_object_t * bankValue
Used for BankField.
Definition object.h:273
aml_bit_size_t bitSize
Used for Field, IndexField and BankField.
Definition object.h:278
aml_field_unit_t * bank
Used for BankField.
Definition object.h:274
aml_field_unit_type_t fieldType
The type of field unit.
Definition object.h:270
aml_field_flags_t fieldFlags
Used for Field, IndexField and BankField.
Definition object.h:276
aml_bit_size_t bitOffset
Used for Field, IndexField and BankField.
Definition object.h:277
aml_field_unit_t * index
Used for IndexField.
Definition object.h:271
aml_field_unit_t * data
Used for IndexField.
Definition object.h:272
Data for an integer constant object.
Definition object.h:296
Data for an integer object.
Definition object.h:286
aml_uint_t value
Definition object.h:288
AML_OBJECT_COMMON_HEADER
Definition object.h:287
Data for a local variable object.
Definition object.h:437
aml_object_t * value
The value of the local variable.
Definition object.h:439
AML_OBJECT_COMMON_HEADER
Definition object.h:438
MethodFlags structure.
Definition named.h:142
Data for a method object.
Definition object.h:306
aml_method_flags_t methodFlags
Definition object.h:313
aml_method_implementation_t implementation
Definition object.h:312
aml_mutex_id_t mutex
Definition object.h:316
const uint8_t * end
Definition object.h:315
AML_OBJECT_COMMON_HEADER
Definition object.h:307
const uint8_t * start
Definition object.h:314
Data for a mutex object.
Definition object.h:324
aml_mutex_id_t mutex
Definition object.h:327
aml_sync_level_t syncLevel
Definition object.h:326
AML_OBJECT_COMMON_HEADER
Definition object.h:325
A NameString structure.
Definition name.h:87
Data for an object reference object.
Definition object.h:335
aml_object_t * target
Definition object.h:337
ACPI object.
Definition object.h:447
aml_package_t package
Definition object.h:464
aml_field_unit_t fieldUnit
Definition object.h:457
aml_integer_t integer
Definition object.h:458
aml_unresolved_t unresolved
Definition object.h:470
AML_OBJECT_COMMON_HEADER
Definition object.h:451
aml_alias_t alias
Definition object.h:469
aml_buffer_t buffer
Definition object.h:453
aml_processor_t processor
Definition object.h:466
aml_method_t method
Definition object.h:460
aml_string_t string
Definition object.h:467
aml_opregion_t opregion
Definition object.h:463
aml_power_resource_t powerResource
Definition object.h:465
aml_mutex_t mutex
Definition object.h:461
aml_local_t local
Definition object.h:472
aml_object_reference_t objectReference
Definition object.h:462
aml_device_t device
Definition object.h:455
aml_integer_constant_t integerConstant
Definition object.h:459
aml_buffer_field_t bufferField
Definition object.h:454
aml_event_t event
Definition object.h:456
aml_arg_t arg
Definition object.h:471
Data for an operation region object.
Definition object.h:345
AML_OBJECT_COMMON_HEADER
Definition object.h:346
uint32_t length
Definition object.h:349
aml_region_space_t space
Definition object.h:347
uintptr_t offset
Definition object.h:348
Data for a package object.
Definition object.h:359
aml_object_t ** elements
Definition object.h:361
AML_OBJECT_COMMON_HEADER
Definition object.h:360
uint64_t length
Definition object.h:362
aml_resource_order_t resourceOrder
Definition object.h:370
aml_system_level_t systemLevel
Definition object.h:369
Data for a processor object.
Definition object.h:378
aml_proc_id_t procId
Definition object.h:380
aml_pblk_len_t pblkLen
Definition object.h:382
aml_pblk_addr_t pblkAddr
Definition object.h:381
AML State.
Definition state.h:25
Data for a string object.
Definition object.h:390
uint64_t length
Definition object.h:393
AML_OBJECT_COMMON_HEADER
Definition object.h:391
char * content
Definition object.h:392
Data for an unresolved object.
Definition object.h:412
aml_object_t * from
The object to start the search from when resolving the reference.
Definition object.h:415
aml_patch_up_resolve_callback_t callback
The callback to call when a matching object is found.
Definition object.h:416
aml_name_string_t nameString
The NameString representing the path to the target object.
Definition object.h:414