aboutsummaryrefslogtreecommitdiff
path: root/hw/acpi
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2015-02-18 19:14:33 +0000
committerMichael S. Tsirkin <mst@redhat.com>2015-02-26 13:04:14 +0100
commit19fff2d405d3bcc88fd7b860ec47797b3f7af977 (patch)
tree2bf7e7c4a984cad9d8588e8a674cc81f0d5d57f2 /hw/acpi
parent52fa397c58667080979e8aa64177c0f69b1851b7 (diff)
acpi: include PkgLength size only when requested
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 <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.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index d7edda1097..cc883ccb95 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);
}