[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 76/96] acpi: include PkgLength size only when request
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 76/96] acpi: include PkgLength size only when requested |
Date: |
Wed, 18 Feb 2015 22:51:17 +0100 |
From: Igor Mammedov <address@hidden>
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>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
include/hw/acpi/aml-build.h | 3 ++-
hw/acpi/aml-build.c | 20 +++++++++++++++-----
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 298e2ef..b7f491e 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -99,7 +99,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_int(GArray *table, uint64_t value);
void build_extop_package(GArray *package, uint8_t op);
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index d7edda1..cc883cc 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -158,10 +158,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)) {
@@ -174,8 +174,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:
@@ -208,7 +218,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);
}
--
MST
- [Qemu-devel] [PULL 66/96] acpi: add aml_arg() term, (continued)
- [Qemu-devel] [PULL 66/96] acpi: add aml_arg() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 67/96] acpi: add aml_store() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 68/96] acpi: add aml_and() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 69/96] acpi: add aml_notify() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 70/96] acpi: add aml_call1(), aml_call2(), aml_call3(), aml_call4() helpers, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 71/96] acpi: add aml_package() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 72/96] pc: acpi-build: generate _S[345] packages dynamically, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 73/96] acpi: add aml_buffer() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 74/96] acpi: add aml_resource_template() helper, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 75/96] acpi: add aml_io() helper, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 76/96] acpi: include PkgLength size only when requested,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 77/96] acpi: add aml_operation_region() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 78/96] acpi: add aml_field() & aml_named_field() terms, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 80/96] acpi: add aml_string() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 79/96] acpi: add aml_local() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 81/96] pc: acpi-build: generate pvpanic device description dynamically, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 82/96] acpi: add aml_varpackage() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 83/96] acpi: add aml_equal() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 84/96] acpi: add aml_processor() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 85/96] acpi: add aml_eisaid() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 86/96] pc: acpi-build: drop template patching and CPU hotplug objects dynamically, Michael S. Tsirkin, 2015/02/18