[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 28/52] acpi: include PkgLength size only when req
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH v3 28/52] acpi: include PkgLength size only when requested |
Date: |
Mon, 9 Feb 2015 10:53:50 +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/aml-build.c | 20 +++++++++++++++-----
include/hw/acpi/aml-build.h | 3 ++-
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index a5d5b83..8c6b6a3 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -159,10 +159,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)) {
@@ -175,8 +175,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:
@@ -209,7 +219,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/aml-build.h b/include/hw/acpi/aml-build.h
index 3dab2b5..1c95845 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -113,7 +113,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] [PATCH v3 25/52] acpi: add aml_buffer() term, Igor Mammedov, 2015/02/09
[Qemu-devel] [PATCH v3 28/52] acpi: include PkgLength size only when requested,
Igor Mammedov <=
[Qemu-devel] [PATCH v3 24/52] pc: acpi-build: generate _S[345] packages dynamically, Igor Mammedov, 2015/02/09
[Qemu-devel] [PATCH v3 30/52] acpi: add aml_field() & aml_named_field() terms, Igor Mammedov, 2015/02/09
[Qemu-devel] [PATCH v3 27/52] acpi: add aml_io() helper, Igor Mammedov, 2015/02/09
[Qemu-devel] [PATCH v3 31/52] acpi: add aml_local() term, Igor Mammedov, 2015/02/09
[Qemu-devel] [PATCH v3 29/52] acpi: add aml_operation_region() term, Igor Mammedov, 2015/02/09
[Qemu-devel] [PATCH v3 34/52] acpi: add aml_varpackage() term, Igor Mammedov, 2015/02/09
[Qemu-devel] [PATCH v3 36/52] acpi: add aml_processor() term, Igor Mammedov, 2015/02/09