diff options
author | Igor Mammedov <imammedo@redhat.com> | 2015-02-18 19:14:21 +0000 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-02-26 13:04:11 +0100 |
commit | 295a515df0df655a902df6ebfc301096a3ee88ed (patch) | |
tree | f969dee4342b66a437658c94b3b311db0d6daed7 /hw/acpi | |
parent | 3c054bd51a132a69e5180f8c6ffa9d46724e4a50 (diff) |
acpi: add aml_int() term
* factor out ACPI const int packing out of build_append_value()
and rename build_append_value() to build_append_int_noprefix()
it will be reused for adding a plain integer value into AML.
will be used by is aml_processor() and CRS macro helpers
* extend build_append_int{_noprefix}() to support 64-bit values
it will be used PCI for generating 64bit _CRS entries
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/acpi')
-rw-r--r-- | hw/acpi/aml-build.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index cb00a1ba80..aaa80e575c 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -218,44 +218,34 @@ void build_extop_package(GArray *package, uint8_t op) build_prepend_byte(package, 0x5B); /* ExtOpPrefix */ } -void build_append_value(GArray *table, uint32_t value, int size) +static void build_append_int_noprefix(GArray *table, uint64_t value, int size) { - uint8_t prefix; int i; - switch (size) { - case 1: - prefix = 0x0A; /* BytePrefix */ - break; - case 2: - prefix = 0x0B; /* WordPrefix */ - break; - case 4: - prefix = 0x0C; /* DWordPrefix */ - break; - default: - assert(0); - return; - } - build_append_byte(table, prefix); for (i = 0; i < size; ++i) { build_append_byte(table, value & 0xFF); value = value >> 8; } } -void build_append_int(GArray *table, uint32_t value) +void build_append_int(GArray *table, uint64_t value) { if (value == 0x00) { build_append_byte(table, 0x00); /* ZeroOp */ } else if (value == 0x01) { build_append_byte(table, 0x01); /* OneOp */ } else if (value <= 0xFF) { - build_append_value(table, value, 1); + build_append_byte(table, 0x0A); /* BytePrefix */ + build_append_int_noprefix(table, value, 1); } else if (value <= 0xFFFF) { - build_append_value(table, value, 2); + build_append_byte(table, 0x0B); /* WordPrefix */ + build_append_int_noprefix(table, value, 2); + } else if (value <= 0xFFFFFFFF) { + build_append_byte(table, 0x0C); /* DWordPrefix */ + build_append_int_noprefix(table, value, 4); } else { - build_append_value(table, value, 4); + build_append_byte(table, 0x0E); /* QWordPrefix */ + build_append_int_noprefix(table, value, 8); } } @@ -366,6 +356,17 @@ Aml *aml_scope(const char *name_format, ...) } /* + * ACPI 1.0b: 16.2.3 Data Objects Encoding: + * encodes: ByteConst, WordConst, DWordConst, QWordConst, ZeroOp, OneOp + */ +Aml *aml_int(const uint64_t val) +{ + Aml *var = aml_alloc(); + build_append_int(var->buf, val); + return var; +} + +/* * helper to construct NameString, which returns Aml object * for using with aml_append or other aml_* terms */ |