/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */1/******************************************************************************2*3* Name: acobject.h - Definition of union acpi_operand_object (Internal object only)4*5* Copyright (C) 2000 - 2025, Intel Corp.6*7*****************************************************************************/89#ifndef _ACOBJECT_H10#define _ACOBJECT_H1112/* acpisrc:struct_defs -- for acpisrc conversion */1314/*15* The union acpi_operand_object is used to pass AML operands from the dispatcher16* to the interpreter, and to keep track of the various handlers such as17* address space handlers and notify handlers. The object is a constant18* size in order to allow it to be cached and reused.19*20* Note: The object is optimized to be aligned and will not work if it is21* byte-packed.22*/23#if ACPI_MACHINE_WIDTH == 6424#pragma pack(8)25#else26#pragma pack(4)27#endif2829/*******************************************************************************30*31* Common Descriptors32*33******************************************************************************/3435/*36* Common area for all objects.37*38* descriptor_type is used to differentiate between internal descriptors, and39* must be in the same place across all descriptors40*41* Note: The descriptor_type and Type fields must appear in the identical42* position in both the struct acpi_namespace_node and union acpi_operand_object43* structures.44*/45#define ACPI_OBJECT_COMMON_HEADER \46union acpi_operand_object *next_object; /* Objects linked to parent NS node */\47u8 descriptor_type; /* To differentiate various internal objs */\48u8 type; /* acpi_object_type */\49u16 reference_count; /* For object deletion management */\50u8 flags51/*52* Note: There are 3 bytes available here before the53* next natural alignment boundary (for both 32/64 cases)54*/5556/* Values for Flag byte above */5758#define AOPOBJ_AML_CONSTANT 0x01 /* Integer is an AML constant */59#define AOPOBJ_STATIC_POINTER 0x02 /* Data is part of an ACPI table, don't delete */60#define AOPOBJ_DATA_VALID 0x04 /* Object is initialized and data is valid */61#define AOPOBJ_OBJECT_INITIALIZED 0x08 /* Region is initialized */62#define AOPOBJ_REG_CONNECTED 0x10 /* _REG was run */63#define AOPOBJ_SETUP_COMPLETE 0x20 /* Region setup is complete */64#define AOPOBJ_INVALID 0x40 /* Host OS won't allow a Region address */6566/******************************************************************************67*68* Basic data types69*70*****************************************************************************/7172struct acpi_object_common {73ACPI_OBJECT_COMMON_HEADER;74};7576struct acpi_object_integer {77ACPI_OBJECT_COMMON_HEADER;78u8 fill[3]; /* Prevent warning on some compilers */79u64 value;80};8182/*83* Note: The String and Buffer object must be identical through the84* pointer and length elements. There is code that depends on this.85*86* Fields common to both Strings and Buffers87*/88#define ACPI_COMMON_BUFFER_INFO(_type) \89_type *pointer; \90u32 length9192/* Null terminated, ASCII characters only */9394struct acpi_object_string {95ACPI_OBJECT_COMMON_HEADER;96ACPI_COMMON_BUFFER_INFO(char); /* String in AML stream or allocated string */97};9899struct acpi_object_buffer {100ACPI_OBJECT_COMMON_HEADER;101ACPI_COMMON_BUFFER_INFO(u8); /* Buffer in AML stream or allocated buffer */102u32 aml_length;103u8 *aml_start;104struct acpi_namespace_node *node; /* Link back to parent node */105};106107struct acpi_object_package {108ACPI_OBJECT_COMMON_HEADER;109struct acpi_namespace_node *node; /* Link back to parent node */110union acpi_operand_object **elements; /* Array of pointers to acpi_objects */111u8 *aml_start;112u32 aml_length;113u32 count; /* # of elements in package */114};115116/******************************************************************************117*118* Complex data types119*120*****************************************************************************/121122struct acpi_object_event {123ACPI_OBJECT_COMMON_HEADER;124acpi_semaphore os_semaphore; /* Actual OS synchronization object */125};126127struct acpi_object_mutex {128ACPI_OBJECT_COMMON_HEADER;129u8 sync_level; /* 0-15, specified in Mutex() call */130u16 acquisition_depth; /* Allow multiple Acquires, same thread */131acpi_mutex os_mutex; /* Actual OS synchronization object */132acpi_thread_id thread_id; /* Current owner of the mutex */133struct acpi_thread_state *owner_thread; /* Current owner of the mutex */134union acpi_operand_object *prev; /* Link for list of acquired mutexes */135union acpi_operand_object *next; /* Link for list of acquired mutexes */136struct acpi_namespace_node *node; /* Containing namespace node */137u8 original_sync_level; /* Owner's original sync level (0-15) */138};139140struct acpi_object_region {141ACPI_OBJECT_COMMON_HEADER;142u8 space_id;143struct acpi_namespace_node *node; /* Containing namespace node */144union acpi_operand_object *handler; /* Handler for region access */145union acpi_operand_object *next;146acpi_physical_address address;147u32 length;148void *pointer; /* Only for data table regions */149};150151struct acpi_object_method {152ACPI_OBJECT_COMMON_HEADER;153u8 info_flags;154u8 param_count;155u8 sync_level;156union acpi_operand_object *mutex;157union acpi_operand_object *node;158u8 *aml_start;159union {160acpi_internal_method implementation;161union acpi_operand_object *handler;162} dispatch;163164u32 aml_length;165acpi_owner_id owner_id;166u8 thread_count;167};168169/* Flags for info_flags field above */170171#define ACPI_METHOD_MODULE_LEVEL 0x01 /* Method is actually module-level code */172#define ACPI_METHOD_INTERNAL_ONLY 0x02 /* Method is implemented internally (_OSI) */173#define ACPI_METHOD_SERIALIZED 0x04 /* Method is serialized */174#define ACPI_METHOD_SERIALIZED_PENDING 0x08 /* Method is to be marked serialized */175#define ACPI_METHOD_IGNORE_SYNC_LEVEL 0x10 /* Method was auto-serialized at table load time */176#define ACPI_METHOD_MODIFIED_NAMESPACE 0x20 /* Method modified the namespace */177178/******************************************************************************179*180* Objects that can be notified. All share a common notify_info area.181*182*****************************************************************************/183184/*185* Common fields for objects that support ASL notifications186*/187#define ACPI_COMMON_NOTIFY_INFO \188union acpi_operand_object *notify_list[2]; /* Handlers for system/device notifies */\189union acpi_operand_object *handler /* Handler for Address space */190191/* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */192193struct acpi_object_notify_common {194ACPI_OBJECT_COMMON_HEADER;195ACPI_COMMON_NOTIFY_INFO;196};197198struct acpi_object_device {199ACPI_OBJECT_COMMON_HEADER;200ACPI_COMMON_NOTIFY_INFO;201struct acpi_gpe_block_info *gpe_block;202};203204struct acpi_object_power_resource {205ACPI_OBJECT_COMMON_HEADER;206ACPI_COMMON_NOTIFY_INFO;207u32 system_level;208u32 resource_order;209};210211struct acpi_object_processor {212ACPI_OBJECT_COMMON_HEADER;213214/* The next two fields take advantage of the 3-byte space before NOTIFY_INFO */215216u8 proc_id;217u8 length;218ACPI_COMMON_NOTIFY_INFO;219acpi_io_address address;220};221222struct acpi_object_thermal_zone {223ACPI_OBJECT_COMMON_HEADER;224ACPI_COMMON_NOTIFY_INFO;225};226227/******************************************************************************228*229* Fields. All share a common header/info field.230*231*****************************************************************************/232233/*234* Common bitfield for the field objects235* "Field Datum" -- a datum from the actual field object236* "Buffer Datum" -- a datum from a user buffer, read from or to be written to the field237*/238#define ACPI_COMMON_FIELD_INFO \239u8 field_flags; /* Access, update, and lock bits */\240u8 attribute; /* From access_as keyword */\241u8 access_byte_width; /* Read/Write size in bytes */\242struct acpi_namespace_node *node; /* Link back to parent node */\243u32 bit_length; /* Length of field in bits */\244u32 base_byte_offset; /* Byte offset within containing object */\245u32 value; /* Value to store into the Bank or Index register */\246u8 start_field_bit_offset;/* Bit offset within first field datum (0-63) */\247u8 access_length /* For serial regions/fields */248249250/* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */251252struct acpi_object_field_common {253ACPI_OBJECT_COMMON_HEADER;254ACPI_COMMON_FIELD_INFO;255union acpi_operand_object *region_obj; /* Parent Operation Region object (REGION/BANK fields only) */256};257258struct acpi_object_region_field {259ACPI_OBJECT_COMMON_HEADER;260ACPI_COMMON_FIELD_INFO;261u16 resource_length;262union acpi_operand_object *region_obj; /* Containing op_region object */263u8 *resource_buffer; /* resource_template for serial regions/fields */264u16 pin_number_index; /* Index relative to previous Connection/Template */265u8 *internal_pcc_buffer; /* Internal buffer for fields associated with PCC */266};267268struct acpi_object_bank_field {269ACPI_OBJECT_COMMON_HEADER;270ACPI_COMMON_FIELD_INFO;271union acpi_operand_object *region_obj; /* Containing op_region object */272union acpi_operand_object *bank_obj; /* bank_select Register object */273};274275struct acpi_object_index_field {276ACPI_OBJECT_COMMON_HEADER;277ACPI_COMMON_FIELD_INFO;278279/*280* No "RegionObj" pointer needed since the Index and Data registers281* are each field definitions unto themselves.282*/283union acpi_operand_object *index_obj; /* Index register */284union acpi_operand_object *data_obj; /* Data register */285};286287/* The buffer_field is different in that it is part of a Buffer, not an op_region */288289struct acpi_object_buffer_field {290ACPI_OBJECT_COMMON_HEADER;291ACPI_COMMON_FIELD_INFO;292u8 is_create_field; /* Special case for objects created by create_field() */293union acpi_operand_object *buffer_obj; /* Containing Buffer object */294};295296/******************************************************************************297*298* Objects for handlers299*300*****************************************************************************/301302struct acpi_object_notify_handler {303ACPI_OBJECT_COMMON_HEADER;304struct acpi_namespace_node *node; /* Parent device */305u32 handler_type; /* Type: Device/System/Both */306acpi_notify_handler handler; /* Handler address */307void *context;308union acpi_operand_object *next[2]; /* Device and System handler lists */309};310311struct acpi_object_addr_handler {312ACPI_OBJECT_COMMON_HEADER;313u8 space_id;314u8 handler_flags;315acpi_adr_space_handler handler;316struct acpi_namespace_node *node; /* Parent device */317void *context;318acpi_mutex context_mutex;319acpi_adr_space_setup setup;320union acpi_operand_object *region_list; /* Regions using this handler */321union acpi_operand_object *next;322};323324/* Flags for address handler (handler_flags) */325326#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED 0x01327328/******************************************************************************329*330* Special internal objects331*332*****************************************************************************/333334/*335* The Reference object is used for these opcodes:336* Arg[0-6], Local[0-7], index_op, name_op, ref_of_op, load_op, load_table_op, debug_op337* The Reference.Class differentiates these types.338*/339struct acpi_object_reference {340ACPI_OBJECT_COMMON_HEADER;341u8 class; /* Reference Class */342u8 target_type; /* Used for Index Op */343u8 resolved; /* Reference has been resolved to a value */344void *object; /* name_op=>HANDLE to obj, index_op=>union acpi_operand_object */345struct acpi_namespace_node *node; /* ref_of or Namepath */346union acpi_operand_object **where; /* Target of Index */347u8 *index_pointer; /* Used for Buffers and Strings */348u8 *aml; /* Used for deferred resolution of the ref */349u32 value; /* Used for Local/Arg/Index/ddb_handle */350};351352/* Values for Reference.Class above */353354typedef enum {355ACPI_REFCLASS_LOCAL = 0, /* Method local */356ACPI_REFCLASS_ARG = 1, /* Method argument */357ACPI_REFCLASS_REFOF = 2, /* Result of ref_of() TBD: Split to Ref/Node and Ref/operand_obj? */358ACPI_REFCLASS_INDEX = 3, /* Result of Index() */359ACPI_REFCLASS_TABLE = 4, /* ddb_handle - Load(), load_table() */360ACPI_REFCLASS_NAME = 5, /* Reference to a named object */361ACPI_REFCLASS_DEBUG = 6, /* Debug object */362363ACPI_REFCLASS_MAX = 6364} ACPI_REFERENCE_CLASSES;365366/*367* Extra object is used as additional storage for types that368* have AML code in their declarations (term_args) that must be369* evaluated at run time.370*371* Currently: Region and field_unit types372*/373struct acpi_object_extra {374ACPI_OBJECT_COMMON_HEADER;375struct acpi_namespace_node *method_REG; /* _REG method for this region (if any) */376struct acpi_namespace_node *scope_node;377void *region_context; /* Region-specific data */378u8 *aml_start;379u32 aml_length;380};381382/* Additional data that can be attached to namespace nodes */383384struct acpi_object_data {385ACPI_OBJECT_COMMON_HEADER;386acpi_object_handler handler;387void *pointer;388};389390/* Structure used when objects are cached for reuse */391392struct acpi_object_cache_list {393ACPI_OBJECT_COMMON_HEADER;394union acpi_operand_object *next; /* Link for object cache and internal lists */395};396397/******************************************************************************398*399* union acpi_operand_object descriptor - a giant union of all of the above400*401*****************************************************************************/402403union acpi_operand_object {404struct acpi_object_common common;405struct acpi_object_integer integer;406struct acpi_object_string string;407struct acpi_object_buffer buffer;408struct acpi_object_package package;409struct acpi_object_event event;410struct acpi_object_method method;411struct acpi_object_mutex mutex;412struct acpi_object_region region;413struct acpi_object_notify_common common_notify;414struct acpi_object_device device;415struct acpi_object_power_resource power_resource;416struct acpi_object_processor processor;417struct acpi_object_thermal_zone thermal_zone;418struct acpi_object_field_common common_field;419struct acpi_object_region_field field;420struct acpi_object_buffer_field buffer_field;421struct acpi_object_bank_field bank_field;422struct acpi_object_index_field index_field;423struct acpi_object_notify_handler notify;424struct acpi_object_addr_handler address_space;425struct acpi_object_reference reference;426struct acpi_object_extra extra;427struct acpi_object_data data;428struct acpi_object_cache_list cache;429430/*431* Add namespace node to union in order to simplify code that accepts both432* ACPI_OPERAND_OBJECTs and ACPI_NAMESPACE_NODEs. The structures share433* a common descriptor_type field in order to differentiate them.434*/435struct acpi_namespace_node node;436};437438/******************************************************************************439*440* union acpi_descriptor - objects that share a common descriptor identifier441*442*****************************************************************************/443444/* Object descriptor types */445446#define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */447#define ACPI_DESC_TYPE_STATE 0x02448#define ACPI_DESC_TYPE_STATE_UPDATE 0x03449#define ACPI_DESC_TYPE_STATE_PACKAGE 0x04450#define ACPI_DESC_TYPE_STATE_CONTROL 0x05451#define ACPI_DESC_TYPE_STATE_RPSCOPE 0x06452#define ACPI_DESC_TYPE_STATE_PSCOPE 0x07453#define ACPI_DESC_TYPE_STATE_WSCOPE 0x08454#define ACPI_DESC_TYPE_STATE_RESULT 0x09455#define ACPI_DESC_TYPE_STATE_NOTIFY 0x0A456#define ACPI_DESC_TYPE_STATE_THREAD 0x0B457#define ACPI_DESC_TYPE_WALK 0x0C458#define ACPI_DESC_TYPE_PARSER 0x0D459#define ACPI_DESC_TYPE_OPERAND 0x0E460#define ACPI_DESC_TYPE_NAMED 0x0F461#define ACPI_DESC_TYPE_MAX 0x0F462463struct acpi_common_descriptor {464void *common_pointer;465u8 descriptor_type; /* To differentiate various internal objs */466};467468union acpi_descriptor {469struct acpi_common_descriptor common;470union acpi_operand_object object;471struct acpi_namespace_node node;472union acpi_parse_object op;473};474475#pragma pack()476477#endif /* _ACOBJECT_H */478479480