aboutsummaryrefslogtreecommitdiff
path: root/hw/acpi/aml-build.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/acpi/aml-build.c')
-rw-r--r--hw/acpi/aml-build.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 876cada4b2..6242908d6c 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -112,7 +112,7 @@ build_append_namestringv(GArray *array, const char *format, va_list ap)
switch (seg_count) {
case 1:
if (!*s) {
- build_append_byte(array, 0x0); /* NullName */
+ build_append_byte(array, 0x00); /* NullName */
} else {
build_append_nameseg(array, s);
}
@@ -141,6 +141,7 @@ build_append_namestringv(GArray *array, const char *format, va_list ap)
g_strfreev(segs);
}
+GCC_FMT_ATTR(2, 3)
static void build_append_namestring(GArray *array, const char *format, ...)
{
va_list ap;
@@ -335,26 +336,29 @@ static void build_buffer(GArray *array, uint8_t op)
void aml_append(Aml *parent_ctx, Aml *child)
{
+ GArray *buf = build_alloc_array();
+ build_append_array(buf, child->buf);
+
switch (child->block_flags) {
case AML_OPCODE:
build_append_byte(parent_ctx->buf, child->op);
break;
case AML_EXT_PACKAGE:
- build_extop_package(child->buf, child->op);
+ build_extop_package(buf, child->op);
break;
case AML_PACKAGE:
- build_package(child->buf, child->op);
+ build_package(buf, child->op);
break;
case AML_RES_TEMPLATE:
- build_append_byte(child->buf, 0x79); /* EndTag */
+ build_append_byte(buf, 0x79); /* EndTag */
/*
* checksum operations are treated as succeeded if checksum
* field is zero. [ACPI Spec 1.0b, 6.4.2.8 End Tag]
*/
- build_append_byte(child->buf, 0);
+ build_append_byte(buf, 0);
/* fall through, to pack resources in buffer */
case AML_BUFFER:
- build_buffer(child->buf, child->op);
+ build_buffer(buf, child->op);
break;
case AML_NO_OPCODE:
break;
@@ -362,7 +366,8 @@ void aml_append(Aml *parent_ctx, Aml *child)
assert(0);
break;
}
- build_append_array(parent_ctx->buf, child->buf);
+ build_append_array(parent_ctx->buf, buf);
+ build_free_array(buf);
}
/* ACPI 1.0b: 16.2.5.1 Namespace Modifier Objects Encoding: DefScope */
@@ -444,7 +449,7 @@ Aml *aml_and(Aml *arg1, Aml *arg2)
Aml *var = aml_opcode(0x7B /* AndOp */);
aml_append(var, arg1);
aml_append(var, arg2);
- build_append_int(var->buf, 0x00 /* NullNameOp */);
+ build_append_byte(var->buf, 0x00 /* NullNameOp */);
return var;
}
@@ -542,7 +547,6 @@ Aml *aml_equal(Aml *arg1, Aml *arg2)
Aml *var = aml_opcode(0x93 /* LequalOp */);
aml_append(var, arg1);
aml_append(var, arg2);
- build_append_int(var->buf, 0x00); /* NullNameOp */
return var;
}