aml-build.h (661875e948ece4723ebe4e7628060c27cad06df1) | aml-build.h (0f2707e4e733614f2cd566e7210c1cff6f3b5b42) |
---|---|
1#ifndef HW_ACPI_GEN_UTILS_H 2#define HW_ACPI_GEN_UTILS_H 3 4#include <stdint.h> 5#include <glib.h> 6#include "qemu/compiler.h" 7 | 1#ifndef HW_ACPI_GEN_UTILS_H 2#define HW_ACPI_GEN_UTILS_H 3 4#include <stdint.h> 5#include <glib.h> 6#include "qemu/compiler.h" 7 |
8typedef enum { 9 AML_NO_OPCODE = 0,/* has only data */ 10 AML_OPCODE, /* has opcode optionally followed by data */ 11 AML_PACKAGE, /* has opcode and uses PkgLength for its length */ 12 AML_EXT_PACKAGE, /* ame as AML_PACKAGE but also has 'ExOpPrefix' */ 13 AML_BUFFER, /* data encoded as 'DefBuffer' */ 14 AML_RES_TEMPLATE, /* encoded as ResourceTemplate macro */ 15} AmlBlockFlags; 16 17struct Aml { 18 GArray *buf; 19 20 /*< private >*/ 21 uint8_t op; 22 AmlBlockFlags block_flags; 23}; 24typedef struct Aml Aml; 25 26/** 27 * init_aml_allocator: 28 * 29 * Called for initializing API allocator which allow to use 30 * AML API. 31 * Returns: toplevel container which accumulates all other 32 * AML elements for a table. 33 */ 34Aml *init_aml_allocator(void); 35 36/** 37 * free_aml_allocator: 38 * 39 * Releases all elements used by AML API, frees associated memory 40 * and invalidates AML allocator. After this call @init_aml_allocator 41 * should be called again if AML API is to be used again. 42 */ 43void free_aml_allocator(void); 44 45/** 46 * aml_append: 47 * @parent_ctx: context to which @child element is added 48 * @child: element that is copied into @parent_ctx context 49 * 50 * Joins Aml elements together and helps to construct AML tables 51 * Examle of usage: 52 * Aml *table = aml_def_block("SSDT", ...); 53 * Aml *sb = aml_scope("\_SB"); 54 * Aml *dev = aml_device("PCI0"); 55 * 56 * aml_append(dev, aml_name_decl("HID", aml_eisaid("PNP0A03"))); 57 * aml_append(sb, dev); 58 * aml_append(table, sb); 59 */ 60void aml_append(Aml *parent_ctx, Aml *child); 61 62/* other helpers */ |
|
8GArray *build_alloc_array(void); 9void build_free_array(GArray *array); 10void build_prepend_byte(GArray *array, uint8_t val); 11void build_append_byte(GArray *array, uint8_t val); 12void build_append_array(GArray *array, GArray *val); 13 14void GCC_FMT_ATTR(2, 3) 15build_append_namestring(GArray *array, const char *format, ...); 16 17void build_prepend_package_length(GArray *package); 18void build_package(GArray *package, uint8_t op); 19void build_append_value(GArray *table, uint32_t value, int size); 20void build_append_int(GArray *table, uint32_t value); 21void build_extop_package(GArray *package, uint8_t op); 22 23#endif | 63GArray *build_alloc_array(void); 64void build_free_array(GArray *array); 65void build_prepend_byte(GArray *array, uint8_t val); 66void build_append_byte(GArray *array, uint8_t val); 67void build_append_array(GArray *array, GArray *val); 68 69void GCC_FMT_ATTR(2, 3) 70build_append_namestring(GArray *array, const char *format, ...); 71 72void build_prepend_package_length(GArray *package); 73void build_package(GArray *package, uint8_t op); 74void build_append_value(GArray *table, uint32_t value, int size); 75void build_append_int(GArray *table, uint32_t value); 76void build_extop_package(GArray *package, uint8_t op); 77 78#endif |