[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 23/47] acpi: include PkgLength size only when requeste
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [RFC 23/47] acpi: include PkgLength size only when requested |
Date: |
Fri, 19 Dec 2014 02:02:18 +0000 |
Named/Reserved{Field} definition uses PkgLength [1] encoding to specify
field length, however it doesn't include size of PkgLength field itself,
while other block objects that have explicit length of its body account
for PkgLength size while encoding it [2].
This special casing isn't mentioned in ACPI spec, but that's what 'iasl'
compiles NamedField to so add extra argument to build_prepend_pkg_length()
to allow it handle the case.
--
1. ACPI Spec 5.0, 20.2.5.2 Named Objects Encoding, page 822
2. ACPI Spec 5.0, 5.4 Definition Block Encoding
Signed-off-by: Igor Mammedov <address@hidden>
---
hw/acpi/acpi_gen_utils.c | 20 +++++++++++++++-----
include/hw/acpi/acpi_gen_utils.h | 3 ++-
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/hw/acpi/acpi_gen_utils.c b/hw/acpi/acpi_gen_utils.c
index e9b2606..37d59d0 100644
--- a/hw/acpi/acpi_gen_utils.c
+++ b/hw/acpi/acpi_gen_utils.c
@@ -142,10 +142,10 @@ enum {
PACKAGE_LENGTH_4BYTE_SHIFT = 20,
};
-void build_prepend_package_length(GArray *package)
+void
+build_prepend_package_length(GArray *package, unsigned length, bool incl_self)
{
uint8_t byte;
- unsigned length = package->len;
unsigned length_bytes;
if (length + 1 < (1 << PACKAGE_LENGTH_1BYTE_SHIFT)) {
@@ -158,8 +158,18 @@ void build_prepend_package_length(GArray *package)
length_bytes = 4;
}
- /* PkgLength is the length of the inclusive length of the data. */
- length += length_bytes;
+ /*
+ * NamedField uses PkgLength encoding but it doesn't include length
+ * of PkgLength itself.
+ */
+ if (incl_self) {
+ /*
+ * PkgLength is the length of the inclusive length of the data
+ * and PkgLength's length itself when used for terms with
+ * explitit length.
+ */
+ length += length_bytes;
+ }
switch (length_bytes) {
case 1:
@@ -192,7 +202,7 @@ void build_prepend_package_length(GArray *package)
void build_package(GArray *package, uint8_t op)
{
- build_prepend_package_length(package);
+ build_prepend_package_length(package, package->len, true);
build_prepend_byte(package, op);
}
diff --git a/include/hw/acpi/acpi_gen_utils.h b/include/hw/acpi/acpi_gen_utils.h
index 91575f1..176596e 100644
--- a/include/hw/acpi/acpi_gen_utils.h
+++ b/include/hw/acpi/acpi_gen_utils.h
@@ -66,7 +66,8 @@ void build_append_array(GArray *array, GArray *val);
void GCC_FMT_ATTR(2, 3)
build_append_namestring(GArray *array, const char *format, ...);
-void build_prepend_package_length(GArray *package);
+void
+build_prepend_package_length(GArray *package, unsigned length, bool incl_self);
void build_package(GArray *package, uint8_t op);
void build_append_value(GArray *table, uint64_t value, int size);
void build_append_int(GArray *table, uint64_t value);
--
1.8.3.1
- [Qemu-devel] [RFC 17/47] acpi: add acpi_package() term, (continued)
- [Qemu-devel] [RFC 17/47] acpi: add acpi_package() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 18/47] pc: acpi-build: drop unsupported PM1b_CNT.SLP_TYP, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 19/47] pc: acpi-build: generate _S[345] packages dynamically, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 20/47] acpi: add acpi_buffer() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 21/47] acpi: add acpi_resource_template() helper, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 22/47] acpi: add acpi_io() helper, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 25/47] acpi: add acpi_field() & acpi_named_field() terms, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 24/47] acpi: add acpi_operation_region() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 26/47] acpi: add acpi_local0() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 28/47] pc: acpi-build: generate pvpanic device description dynamically, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 23/47] acpi: include PkgLength size only when requested,
Igor Mammedov <=
- [Qemu-devel] [RFC 30/47] acpi: add acpi_equal() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 29/47] acpi: add acpi_varpackage() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 33/47] pc: acpi-build: drop template patching and CPU hotplug objects dynamically, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 31/47] acpi: add acpi_processor() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 32/47] acpi: add acpi_eisaid() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 27/47] acpi: add acpi_string() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 36/47] pc: acpi-build: drop template patching and memory hotplug objects dynamically, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 35/47] acpi: add acpi_reserved_field() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 34/47] pc: acpi-build: create CPU hotplug IO region dynamically, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 37/47] pc: acpi-build: create memory hotplug IO region dynamically, Igor Mammedov, 2014/12/18