@@ -824,7 +824,7 @@ build_ssdt(Aml *table_data,
uint32_t nr_mem = machine->ram_slots;
unsigned acpi_cpus = guest_info->apic_id_limit;
uint8_t *ssdt_ptr;
- Aml *ssdt;
+ Aml *ssdt, *sb_scope;
int i;
/* The current AML generator can cover the APIC ID range [0..255],
@@ -861,15 +861,11 @@ build_ssdt(Aml *table_data,
ACPI_BUILD_SET_LE(ssdt_ptr, sizeof(ssdp_misc_aml),
ssdt_mctrl_nr_slots[0], 32, nr_mem);
+ sb_scope = aml_scope("_SB");
{
- GArray *sb_scope = build_alloc_array();
- uint8_t op = 0x10; /* ScopeOp */
-
- build_append_namestring(sb_scope, "_SB");
-
/* build Processor object for each processor */
for (i = 0; i < acpi_cpus; i++) {
- uint8_t *proc = acpi_data_push(sb_scope, ACPI_PROC_SIZEOF);
+ uint8_t *proc = acpi_data_push(sb_scope->buf, ACPI_PROC_SIZEOF);
memcpy(proc, ACPI_PROC_AML, ACPI_PROC_SIZEOF);
proc[ACPI_PROC_OFFSET_CPUHEX] = acpi_get_hex(i >> 4);
proc[ACPI_PROC_OFFSET_CPUHEX+1] = acpi_get_hex(i);
@@ -881,11 +877,12 @@ build_ssdt(Aml *table_data,
* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...}
*/
/* Arg0 = Processor ID = APIC ID */
- build_append_notify_method(sb_scope, "NTFY", "CP%0.02X", acpi_cpus);
+ build_append_notify_method(sb_scope->buf, "NTFY",
+ "CP%0.02X", acpi_cpus);
/* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })" */
- build_append_byte(sb_scope, 0x08); /* NameOp */
- build_append_namestring(sb_scope, "CPON");
+ build_append_byte(sb_scope->buf, 0x08); /* NameOp */
+ build_append_namestring(sb_scope->buf, "CPON");
{
GArray *package = build_alloc_array();
@@ -910,7 +907,7 @@ build_ssdt(Aml *table_data,
}
build_package(package, op);
- build_append_array(sb_scope, package);
+ build_append_array(sb_scope->buf, package);
build_free_array(package);
}
@@ -919,7 +916,7 @@ build_ssdt(Aml *table_data,
/* build memory devices */
for (i = 0; i < nr_mem; i++) {
char id[3];
- uint8_t *mem = acpi_data_push(sb_scope, ACPI_MEM_SIZEOF);
+ uint8_t *mem = acpi_data_push(sb_scope->buf, ACPI_MEM_SIZEOF);
snprintf(id, sizeof(id), "%02X", i);
memcpy(mem, ACPI_MEM_AML, ACPI_MEM_SIZEOF);
@@ -930,7 +927,7 @@ build_ssdt(Aml *table_data,
/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ...
*/
- build_append_notify_method(sb_scope,
+ build_append_notify_method(sb_scope->buf,
stringify(MEMORY_SLOT_NOTIFY_METHOD),
"MP%0.02X", nr_mem);
}
@@ -947,13 +944,11 @@ build_ssdt(Aml *table_data,
if (bus) {
/* Scan all PCI buses. Generate tables to support hotplug. */
- build_append_pci_bus_devices(sb_scope, bus,
+ build_append_pci_bus_devices(sb_scope->buf, bus,
pm->pcihp_bridge_en);
}
}
- build_package(sb_scope, op);
- build_append_array(ssdt->buf, sb_scope);
- build_free_array(sb_scope);
+ aml_append(ssdt, sb_scope);
}
aml_append(table_data, ssdt);
prepares for incremental conversion of SSDT contents to AML API Signed-off-by: Igor Mammedov <imammedo@redhat.com> --- hw/i386/acpi-build.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-)