xref: /openbmc/qemu/include/hw/acpi/aml-build.h (revision 39b6dbd8d7bbaa864ce42dcdcffe79313de9f2d6)
119934e0eSIgor Mammedov #ifndef HW_ACPI_GEN_UTILS_H
219934e0eSIgor Mammedov #define HW_ACPI_GEN_UTILS_H
319934e0eSIgor Mammedov 
419934e0eSIgor Mammedov #include <glib.h>
5658c2718SShannon Zhao #include "hw/acpi/acpi-defs.h"
6658c2718SShannon Zhao 
7658c2718SShannon Zhao /* Reserve RAM space for tables: add another order of magnitude. */
8658c2718SShannon Zhao #define ACPI_BUILD_TABLE_MAX_SIZE         0x200000
9658c2718SShannon Zhao 
10658c2718SShannon Zhao #define ACPI_BUILD_APPNAME6 "BOCHS "
11658c2718SShannon Zhao #define ACPI_BUILD_APPNAME4 "BXPC"
12658c2718SShannon Zhao 
13658c2718SShannon Zhao #define ACPI_BUILD_TABLE_FILE "etc/acpi/tables"
14658c2718SShannon Zhao #define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"
15658c2718SShannon Zhao #define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log"
1619934e0eSIgor Mammedov 
17f294ecbcSIgor Mammedov #define AML_NOTIFY_METHOD "NTFY"
18f294ecbcSIgor Mammedov 
190f2707e4SIgor Mammedov typedef enum {
200f2707e4SIgor Mammedov     AML_NO_OPCODE = 0,/* has only data */
210f2707e4SIgor Mammedov     AML_OPCODE,       /* has opcode optionally followed by data */
220f2707e4SIgor Mammedov     AML_PACKAGE,      /* has opcode and uses PkgLength for its length */
2356521fb8SMichael S. Tsirkin     AML_EXT_PACKAGE,  /* Same as AML_PACKAGE but also has 'ExOpPrefix' */
240f2707e4SIgor Mammedov     AML_BUFFER,       /* data encoded as 'DefBuffer' */
250f2707e4SIgor Mammedov     AML_RES_TEMPLATE, /* encoded as ResourceTemplate macro */
260f2707e4SIgor Mammedov } AmlBlockFlags;
270f2707e4SIgor Mammedov 
280f2707e4SIgor Mammedov struct Aml {
290f2707e4SIgor Mammedov     GArray *buf;
300f2707e4SIgor Mammedov 
310f2707e4SIgor Mammedov     /*< private >*/
320f2707e4SIgor Mammedov     uint8_t op;
330f2707e4SIgor Mammedov     AmlBlockFlags block_flags;
340f2707e4SIgor Mammedov };
350f2707e4SIgor Mammedov typedef struct Aml Aml;
360f2707e4SIgor Mammedov 
3752fa397cSIgor Mammedov typedef enum {
38a23b8872SIgor Mammedov     AML_COMPATIBILITY = 0,
39a23b8872SIgor Mammedov     AML_TYPEA = 1,
40a23b8872SIgor Mammedov     AML_TYPEB = 2,
41a23b8872SIgor Mammedov     AML_TYPEF = 3,
42a23b8872SIgor Mammedov } AmlDmaType;
43a23b8872SIgor Mammedov 
44a23b8872SIgor Mammedov typedef enum {
45a23b8872SIgor Mammedov     AML_NOTBUSMASTER = 0,
46a23b8872SIgor Mammedov     AML_BUSMASTER = 1,
47a23b8872SIgor Mammedov } AmlDmaBusMaster;
48a23b8872SIgor Mammedov 
49a23b8872SIgor Mammedov typedef enum {
50a23b8872SIgor Mammedov     AML_TRANSFER8 = 0,
51a23b8872SIgor Mammedov     AML_TRANSFER8_16 = 1,
52a23b8872SIgor Mammedov     AML_TRANSFER16 = 2,
53a23b8872SIgor Mammedov } AmlTransferSize;
54a23b8872SIgor Mammedov 
55a23b8872SIgor Mammedov typedef enum {
56ff80dc7fSShannon Zhao     AML_DECODE10 = 0,
57ff80dc7fSShannon Zhao     AML_DECODE16 = 1,
5852fa397cSIgor Mammedov } AmlIODecode;
5952fa397cSIgor Mammedov 
6031127938SIgor Mammedov typedef enum {
61ff80dc7fSShannon Zhao     AML_ANY_ACC = 0,
62ff80dc7fSShannon Zhao     AML_BYTE_ACC = 1,
63ff80dc7fSShannon Zhao     AML_WORD_ACC = 2,
64ff80dc7fSShannon Zhao     AML_DWORD_ACC = 3,
65ff80dc7fSShannon Zhao     AML_QWORD_ACC = 4,
66ff80dc7fSShannon Zhao     AML_BUFFER_ACC = 5,
67af509897SZhu Guihua } AmlAccessType;
68af509897SZhu Guihua 
69af509897SZhu Guihua typedef enum {
7036de884aSIgor Mammedov     AML_NOLOCK = 0,
7136de884aSIgor Mammedov     AML_LOCK = 1,
7236de884aSIgor Mammedov } AmlLockRule;
7336de884aSIgor Mammedov 
7436de884aSIgor Mammedov typedef enum {
75ff80dc7fSShannon Zhao     AML_PRESERVE = 0,
76ff80dc7fSShannon Zhao     AML_WRITE_AS_ONES = 1,
77ff80dc7fSShannon Zhao     AML_WRITE_AS_ZEROS = 2,
78af509897SZhu Guihua } AmlUpdateRule;
79214ae59fSIgor Mammedov 
80214ae59fSIgor Mammedov typedef enum {
81ff80dc7fSShannon Zhao     AML_SYSTEM_MEMORY = 0X00,
82ff80dc7fSShannon Zhao     AML_SYSTEM_IO = 0X01,
83e4db2798SIgor Mammedov     AML_PCI_CONFIG = 0X02,
8431127938SIgor Mammedov } AmlRegionSpace;
8531127938SIgor Mammedov 
866ece7053SIgor Mammedov typedef enum {
87ff80dc7fSShannon Zhao     AML_MEMORY_RANGE = 0,
88ff80dc7fSShannon Zhao     AML_IO_RANGE = 1,
89ff80dc7fSShannon Zhao     AML_BUS_NUMBER_RANGE = 2,
906ece7053SIgor Mammedov } AmlResourceType;
916ece7053SIgor Mammedov 
926ece7053SIgor Mammedov typedef enum {
93ff80dc7fSShannon Zhao     AML_SUB_DECODE = 1 << 1,
94ff80dc7fSShannon Zhao     AML_POS_DECODE = 0
956ece7053SIgor Mammedov } AmlDecode;
966ece7053SIgor Mammedov 
976ece7053SIgor Mammedov typedef enum {
98ff80dc7fSShannon Zhao     AML_MAX_FIXED = 1 << 3,
99ff80dc7fSShannon Zhao     AML_MAX_NOT_FIXED = 0,
1006ece7053SIgor Mammedov } AmlMaxFixed;
1016ece7053SIgor Mammedov 
1026ece7053SIgor Mammedov typedef enum {
103ff80dc7fSShannon Zhao     AML_MIN_FIXED = 1 << 2,
104ff80dc7fSShannon Zhao     AML_MIN_NOT_FIXED = 0
1056ece7053SIgor Mammedov } AmlMinFixed;
1066ece7053SIgor Mammedov 
1076ece7053SIgor Mammedov /*
1086ece7053SIgor Mammedov  * ACPI 1.0b: Table 6-26 I/O Resource Flag (Resource Type = 1) Definitions
1096ece7053SIgor Mammedov  * _RNG field definition
1106ece7053SIgor Mammedov  */
1116ece7053SIgor Mammedov typedef enum {
112ff80dc7fSShannon Zhao     AML_ISA_ONLY = 1,
113ff80dc7fSShannon Zhao     AML_NON_ISA_ONLY = 2,
114ff80dc7fSShannon Zhao     AML_ENTIRE_RANGE = 3,
1156ece7053SIgor Mammedov } AmlISARanges;
1166ece7053SIgor Mammedov 
1176ece7053SIgor Mammedov /*
1186ece7053SIgor Mammedov  * ACPI 1.0b: Table 6-25 Memory Resource Flag (Resource Type = 0) Definitions
1196ece7053SIgor Mammedov  * _MEM field definition
1206ece7053SIgor Mammedov  */
1216ece7053SIgor Mammedov typedef enum {
122ff80dc7fSShannon Zhao     AML_NON_CACHEABLE = 0,
123ff80dc7fSShannon Zhao     AML_CACHEABLE = 1,
124ff80dc7fSShannon Zhao     AML_WRITE_COMBINING = 2,
125ff80dc7fSShannon Zhao     AML_PREFETCHABLE = 3,
126ff80dc7fSShannon Zhao } AmlCacheable;
1276ece7053SIgor Mammedov 
1286ece7053SIgor Mammedov /*
1296ece7053SIgor Mammedov  * ACPI 1.0b: Table 6-25 Memory Resource Flag (Resource Type = 0) Definitions
1306ece7053SIgor Mammedov  * _RW field definition
1316ece7053SIgor Mammedov  */
1326ece7053SIgor Mammedov typedef enum {
133ff80dc7fSShannon Zhao     AML_READ_ONLY = 0,
134ff80dc7fSShannon Zhao     AML_READ_WRITE = 1,
1356ece7053SIgor Mammedov } AmlReadAndWrite;
1366ece7053SIgor Mammedov 
137205d1d1cSShannon Zhao /*
138205d1d1cSShannon Zhao  * ACPI 5.0: Table 6-187 Extended Interrupt Descriptor Definition
139205d1d1cSShannon Zhao  * Interrupt Vector Flags Bits[0] Consumer/Producer
140205d1d1cSShannon Zhao  */
141205d1d1cSShannon Zhao typedef enum {
142205d1d1cSShannon Zhao     AML_CONSUMER_PRODUCER = 0,
143205d1d1cSShannon Zhao     AML_CONSUMER = 1,
144205d1d1cSShannon Zhao } AmlConsumerAndProducer;
145205d1d1cSShannon Zhao 
146205d1d1cSShannon Zhao /*
147205d1d1cSShannon Zhao  * ACPI 5.0: Table 6-187 Extended Interrupt Descriptor Definition
148205d1d1cSShannon Zhao  * _HE field definition
149205d1d1cSShannon Zhao  */
150205d1d1cSShannon Zhao typedef enum {
151205d1d1cSShannon Zhao     AML_LEVEL = 0,
152205d1d1cSShannon Zhao     AML_EDGE = 1,
153205d1d1cSShannon Zhao } AmlLevelAndEdge;
154205d1d1cSShannon Zhao 
155205d1d1cSShannon Zhao /*
156205d1d1cSShannon Zhao  * ACPI 5.0: Table 6-187 Extended Interrupt Descriptor Definition
157205d1d1cSShannon Zhao  * _LL field definition
158205d1d1cSShannon Zhao  */
159205d1d1cSShannon Zhao typedef enum {
160205d1d1cSShannon Zhao     AML_ACTIVE_HIGH = 0,
161205d1d1cSShannon Zhao     AML_ACTIVE_LOW = 1,
162205d1d1cSShannon Zhao } AmlActiveHighAndLow;
163205d1d1cSShannon Zhao 
164205d1d1cSShannon Zhao /*
165205d1d1cSShannon Zhao  * ACPI 5.0: Table 6-187 Extended Interrupt Descriptor Definition
166205d1d1cSShannon Zhao  * _SHR field definition
167205d1d1cSShannon Zhao  */
168205d1d1cSShannon Zhao typedef enum {
169205d1d1cSShannon Zhao     AML_EXCLUSIVE = 0,
170205d1d1cSShannon Zhao     AML_SHARED = 1,
171205d1d1cSShannon Zhao     AML_EXCLUSIVE_AND_WAKE = 2,
172205d1d1cSShannon Zhao     AML_SHARED_AND_WAKE = 3,
173205d1d1cSShannon Zhao } AmlShared;
174205d1d1cSShannon Zhao 
1754dbfc881SXiao Guangrong /* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: MethodFlags */
1764dbfc881SXiao Guangrong typedef enum {
1774dbfc881SXiao Guangrong     AML_NOTSERIALIZED = 0,
1784dbfc881SXiao Guangrong     AML_SERIALIZED = 1,
1794dbfc881SXiao Guangrong } AmlSerializeFlag;
1804dbfc881SXiao Guangrong 
1814ecdc746SShannon Zhao /*
1824ecdc746SShannon Zhao  * ACPI 5.0: Table 6-189 GPIO Connection Descriptor Definition
1834ecdc746SShannon Zhao  * GPIO Connection Type
1844ecdc746SShannon Zhao  */
1854ecdc746SShannon Zhao typedef enum {
1864ecdc746SShannon Zhao     AML_INTERRUPT_CONNECTION = 0,
1874ecdc746SShannon Zhao     AML_IO_CONNECTION = 1,
1884ecdc746SShannon Zhao } AmlGpioConnectionType;
1894ecdc746SShannon Zhao 
1904ecdc746SShannon Zhao /*
1914ecdc746SShannon Zhao  * ACPI 5.0: Table 6-189 GPIO Connection Descriptor Definition
1924ecdc746SShannon Zhao  * _PPI field definition
1934ecdc746SShannon Zhao  */
1944ecdc746SShannon Zhao typedef enum {
1954ecdc746SShannon Zhao     AML_PULL_DEFAULT = 0,
1964ecdc746SShannon Zhao     AML_PULL_UP = 1,
1974ecdc746SShannon Zhao     AML_PULL_DOWN = 2,
1984ecdc746SShannon Zhao     AML_PULL_NONE = 3,
1994ecdc746SShannon Zhao } AmlPinConfig;
2004ecdc746SShannon Zhao 
201658c2718SShannon Zhao typedef
202658c2718SShannon Zhao struct AcpiBuildTables {
203658c2718SShannon Zhao     GArray *table_data;
204658c2718SShannon Zhao     GArray *rsdp;
205658c2718SShannon Zhao     GArray *tcpalog;
206658c2718SShannon Zhao     GArray *linker;
207658c2718SShannon Zhao } AcpiBuildTables;
208658c2718SShannon Zhao 
2090f2707e4SIgor Mammedov /**
2100f2707e4SIgor Mammedov  * init_aml_allocator:
2110f2707e4SIgor Mammedov  *
2120f2707e4SIgor Mammedov  * Called for initializing API allocator which allow to use
2130f2707e4SIgor Mammedov  * AML API.
2140f2707e4SIgor Mammedov  * Returns: toplevel container which accumulates all other
2150f2707e4SIgor Mammedov  * AML elements for a table.
2160f2707e4SIgor Mammedov  */
2170f2707e4SIgor Mammedov Aml *init_aml_allocator(void);
2180f2707e4SIgor Mammedov 
2190f2707e4SIgor Mammedov /**
2200f2707e4SIgor Mammedov  * free_aml_allocator:
2210f2707e4SIgor Mammedov  *
2220f2707e4SIgor Mammedov  * Releases all elements used by AML API, frees associated memory
2230f2707e4SIgor Mammedov  * and invalidates AML allocator. After this call @init_aml_allocator
2240f2707e4SIgor Mammedov  * should be called again if AML API is to be used again.
2250f2707e4SIgor Mammedov  */
2260f2707e4SIgor Mammedov void free_aml_allocator(void);
2270f2707e4SIgor Mammedov 
2280f2707e4SIgor Mammedov /**
2290f2707e4SIgor Mammedov  * aml_append:
2300f2707e4SIgor Mammedov  * @parent_ctx: context to which @child element is added
2310f2707e4SIgor Mammedov  * @child: element that is copied into @parent_ctx context
2320f2707e4SIgor Mammedov  *
2330f2707e4SIgor Mammedov  * Joins Aml elements together and helps to construct AML tables
2340f2707e4SIgor Mammedov  * Examle of usage:
2350f2707e4SIgor Mammedov  *   Aml *table = aml_def_block("SSDT", ...);
2367824df38SGal Hammer  *   Aml *sb = aml_scope("\\_SB");
2370f2707e4SIgor Mammedov  *   Aml *dev = aml_device("PCI0");
2380f2707e4SIgor Mammedov  *
2390f2707e4SIgor Mammedov  *   aml_append(dev, aml_name_decl("HID", aml_eisaid("PNP0A03")));
2400f2707e4SIgor Mammedov  *   aml_append(sb, dev);
2410f2707e4SIgor Mammedov  *   aml_append(table, sb);
2420f2707e4SIgor Mammedov  */
2430f2707e4SIgor Mammedov void aml_append(Aml *parent_ctx, Aml *child);
2440f2707e4SIgor Mammedov 
2453c054bd5SIgor Mammedov /* non block AML object primitives */
2463c054bd5SIgor Mammedov Aml *aml_name(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
2473c054bd5SIgor Mammedov Aml *aml_name_decl(const char *name, Aml *val);
248b25af5adSIgor Mammedov Aml *aml_return(Aml *val);
249295a515dSIgor Mammedov Aml *aml_int(const uint64_t val);
2507193f3a6SIgor Mammedov Aml *aml_arg(int pos);
251f411199dSIgor Mammedov Aml *aml_to_integer(Aml *arg);
2526d5ea945SIgor Mammedov Aml *aml_to_hexstring(Aml *src, Aml *dst);
25325c1432eSIgor Mammedov Aml *aml_to_buffer(Aml *src, Aml *dst);
254c263b3f7SIgor Mammedov Aml *aml_store(Aml *val, Aml *target);
2555530427fSIgor Mammedov Aml *aml_and(Aml *arg1, Aml *arg2, Aml *dst);
256ca3df95dSIgor Mammedov Aml *aml_or(Aml *arg1, Aml *arg2, Aml *dst);
257df241999SIgor Mammedov Aml *aml_lor(Aml *arg1, Aml *arg2);
258a57dddddSMarcel Apfelbaum Aml *aml_shiftleft(Aml *arg1, Aml *count);
259c360639aSIgor Mammedov Aml *aml_shiftright(Aml *arg1, Aml *count, Aml *dst);
26096396e28SMarcel Apfelbaum Aml *aml_lless(Aml *arg1, Aml *arg2);
26120ca5208SIgor Mammedov Aml *aml_add(Aml *arg1, Aml *arg2, Aml *dst);
2627059eb42SIgor Mammedov Aml *aml_subtract(Aml *arg1, Aml *arg2, Aml *dst);
263af39d536SMarcel Apfelbaum Aml *aml_increment(Aml *arg);
2647059eb42SIgor Mammedov Aml *aml_decrement(Aml *arg);
265928b8996SMarcel Apfelbaum Aml *aml_index(Aml *arg1, Aml *idx);
26634189453SIgor Mammedov Aml *aml_notify(Aml *arg1, Aml *arg2);
2677b38ba9cSIgor Mammedov Aml *aml_call0(const char *method);
2683f3992b7SIgor Mammedov Aml *aml_call1(const char *method, Aml *arg1);
2693f3992b7SIgor Mammedov Aml *aml_call2(const char *method, Aml *arg1, Aml *arg2);
2703f3992b7SIgor Mammedov Aml *aml_call3(const char *method, Aml *arg1, Aml *arg2, Aml *arg3);
2713f3992b7SIgor Mammedov Aml *aml_call4(const char *method, Aml *arg1, Aml *arg2, Aml *arg3, Aml *arg4);
27237d0e980SShannon Zhao Aml *aml_gpio_int(AmlConsumerAndProducer con_and_pro,
27337d0e980SShannon Zhao                   AmlLevelAndEdge edge_level,
27437d0e980SShannon Zhao                   AmlActiveHighAndLow active_level, AmlShared shared,
27537d0e980SShannon Zhao                   AmlPinConfig pin_config, uint16_t debounce_timeout,
27637d0e980SShannon Zhao                   const uint32_t pin_list[], uint32_t pin_count,
27737d0e980SShannon Zhao                   const char *resource_source_name,
27837d0e980SShannon Zhao                   const uint8_t *vendor_data, uint16_t vendor_data_len);
279dc17ab1dSShannon Zhao Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,
280dc17ab1dSShannon Zhao                         AmlReadAndWrite read_and_write);
281205d1d1cSShannon Zhao Aml *aml_interrupt(AmlConsumerAndProducer con_and_pro,
282205d1d1cSShannon Zhao                    AmlLevelAndEdge level_and_edge,
283205d1d1cSShannon Zhao                    AmlActiveHighAndLow high_and_low, AmlShared shared,
28445fcf539SIgor Mammedov                    uint32_t *irq_list, uint8_t irq_count);
28552fa397cSIgor Mammedov Aml *aml_io(AmlIODecode dec, uint16_t min_base, uint16_t max_base,
28652fa397cSIgor Mammedov             uint8_t aln, uint8_t len);
28731127938SIgor Mammedov Aml *aml_operation_region(const char *name, AmlRegionSpace rs,
28831127938SIgor Mammedov                           uint32_t offset, uint32_t len);
28970560453SIgor Mammedov Aml *aml_irq_no_flags(uint8_t irq);
290214ae59fSIgor Mammedov Aml *aml_named_field(const char *name, unsigned length);
291e2ea299bSIgor Mammedov Aml *aml_reserved_field(unsigned length);
292b8a5d689SIgor Mammedov Aml *aml_local(int num);
293d5e5830fSIgor Mammedov Aml *aml_string(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
294ea7df04aSShannon Zhao Aml *aml_lnot(Aml *arg);
29515e44e56SIgor Mammedov Aml *aml_equal(Aml *arg1, Aml *arg2);
296dabad78bSIgor Mammedov Aml *aml_lgreater(Aml *arg1, Aml *arg2);
2972d3f667dSIgor Mammedov Aml *aml_lgreater_equal(Aml *arg1, Aml *arg2);
2983dd15643SIgor Mammedov Aml *aml_processor(uint8_t proc_id, uint32_t pblk_addr, uint8_t pblk_len,
2993dd15643SIgor Mammedov                    const char *name_format, ...) GCC_FMT_ATTR(4, 5);
300a7891dacSIgor Mammedov Aml *aml_eisaid(const char *str);
3016ece7053SIgor Mammedov Aml *aml_word_bus_number(AmlMinFixed min_fixed, AmlMaxFixed max_fixed,
3026ece7053SIgor Mammedov                          AmlDecode dec, uint16_t addr_gran,
3036ece7053SIgor Mammedov                          uint16_t addr_min, uint16_t addr_max,
3046ece7053SIgor Mammedov                          uint16_t addr_trans, uint16_t len);
3056ece7053SIgor Mammedov Aml *aml_word_io(AmlMinFixed min_fixed, AmlMaxFixed max_fixed,
3066ece7053SIgor Mammedov                  AmlDecode dec, AmlISARanges isa_ranges,
3076ece7053SIgor Mammedov                  uint16_t addr_gran, uint16_t addr_min,
3086ece7053SIgor Mammedov                  uint16_t addr_max, uint16_t addr_trans,
3096ece7053SIgor Mammedov                  uint16_t len);
310616ef329SShannon Zhao Aml *aml_dword_io(AmlMinFixed min_fixed, AmlMaxFixed max_fixed,
311616ef329SShannon Zhao                  AmlDecode dec, AmlISARanges isa_ranges,
312616ef329SShannon Zhao                  uint32_t addr_gran, uint32_t addr_min,
313616ef329SShannon Zhao                  uint32_t addr_max, uint32_t addr_trans,
314616ef329SShannon Zhao                  uint32_t len);
3156ece7053SIgor Mammedov Aml *aml_dword_memory(AmlDecode dec, AmlMinFixed min_fixed,
316ff80dc7fSShannon Zhao                       AmlMaxFixed max_fixed, AmlCacheable cacheable,
3176ece7053SIgor Mammedov                       AmlReadAndWrite read_and_write,
3186ece7053SIgor Mammedov                       uint32_t addr_gran, uint32_t addr_min,
3196ece7053SIgor Mammedov                       uint32_t addr_max, uint32_t addr_trans,
3206ece7053SIgor Mammedov                       uint32_t len);
3216ece7053SIgor Mammedov Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed,
322ff80dc7fSShannon Zhao                       AmlMaxFixed max_fixed, AmlCacheable cacheable,
3236ece7053SIgor Mammedov                       AmlReadAndWrite read_and_write,
3246ece7053SIgor Mammedov                       uint64_t addr_gran, uint64_t addr_min,
3256ece7053SIgor Mammedov                       uint64_t addr_max, uint64_t addr_trans,
3266ece7053SIgor Mammedov                       uint64_t len);
327a23b8872SIgor Mammedov Aml *aml_dma(AmlDmaType typ, AmlDmaBusMaster bm, AmlTransferSize sz,
328a23b8872SIgor Mammedov              uint8_t channel);
3290073518dSIgor Mammedov Aml *aml_sleep(uint64_t msec);
3303c054bd5SIgor Mammedov 
3312ef7c27bSIgor Mammedov /* Block AML object primitives */
3322ef7c27bSIgor Mammedov Aml *aml_scope(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
333be06ebd0SIgor Mammedov Aml *aml_device(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
3344dbfc881SXiao Guangrong Aml *aml_method(const char *name, int arg_count, AmlSerializeFlag sflag);
33532acac9eSIgor Mammedov Aml *aml_if(Aml *predicate);
336467b07dfSShannon Zhao Aml *aml_else(void);
33768e6b0afSMarcel Apfelbaum Aml *aml_while(Aml *predicate);
3383bfa74a7SIgor Mammedov Aml *aml_package(uint8_t num_elements);
339ed8b5847SShannon Zhao Aml *aml_buffer(int buffer_size, uint8_t *byte_list);
340ad4a80bcSIgor Mammedov Aml *aml_resource_template(void);
34136de884aSIgor Mammedov Aml *aml_field(const char *name, AmlAccessType type, AmlLockRule lock,
34236de884aSIgor Mammedov                AmlUpdateRule rule);
3436e1db3f2SXiao Guangrong Aml *aml_mutex(const char *name, uint8_t sync_level);
3446e1db3f2SXiao Guangrong Aml *aml_acquire(Aml *mutex, uint16_t timeout);
3456e1db3f2SXiao Guangrong Aml *aml_release(Aml *mutex);
34667a5c0faSIgor Mammedov Aml *aml_alias(const char *source_object, const char *alias_object);
347*39b6dbd8SXiao Guangrong Aml *aml_create_field(Aml *srcbuf, Aml *bit_index, Aml *num_bits,
348*39b6dbd8SXiao Guangrong                       const char *name);
349ed8176a3SShannon Zhao Aml *aml_create_dword_field(Aml *srcbuf, Aml *index, const char *name);
3507e192a38SIgor Mammedov Aml *aml_create_qword_field(Aml *srcbuf, Aml *index, const char *name);
351a678508eSIgor Mammedov Aml *aml_varpackage(uint32_t num_elements);
352b930fb9dSShannon Zhao Aml *aml_touuid(const char *uuid);
353e1f776c4SShannon Zhao Aml *aml_unicode(const char *str);
35495cb0661SXiao Guangrong Aml *aml_derefof(Aml *arg);
35552483d14SXiao Guangrong Aml *aml_sizeof(Aml *arg);
3562ef7c27bSIgor Mammedov 
357658c2718SShannon Zhao void
358658c2718SShannon Zhao build_header(GArray *linker, GArray *table_data,
3598870ca0eSXiao Guangrong              AcpiTableHeader *h, const char *sig, int len, uint8_t rev,
36037ad223cSLaszlo Ersek              const char *oem_id, const char *oem_table_id);
361658c2718SShannon Zhao void *acpi_data_push(GArray *table_data, unsigned size);
362658c2718SShannon Zhao unsigned acpi_data_len(GArray *table);
363658c2718SShannon Zhao void acpi_add_table(GArray *table_offsets, GArray *table_data);
364658c2718SShannon Zhao void acpi_build_tables_init(AcpiBuildTables *tables);
365658c2718SShannon Zhao void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre);
366243bdb79SShannon Zhao void
36751513558SLaszlo Ersek build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets,
36851513558SLaszlo Ersek            const char *oem_id, const char *oem_table_id);
369658c2718SShannon Zhao 
37019934e0eSIgor Mammedov #endif
371