Message ID | 1423479254-15342-7-git-send-email-imammedo@redhat.com |
---|---|
State | New |
Headers | show |
On Mon, Feb 09, 2015 at 10:53:28AM +0000, Igor Mammedov wrote: > it replaces prebuilt SSDT table header template copying/patching > with AML API > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> I note that this changed the SSDT signature in random ways, for example, it used to be named BXPCSSDT, now it's BXPC. Pls keep using build_header, this problem will go away then. > --- > hw/i386/acpi-build.c | 26 ++++++++++++++++---------- > 1 file changed, 16 insertions(+), 10 deletions(-) > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index 553c86b..fcefa07 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -816,15 +816,15 @@ static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size) > } > > static void > -build_ssdt(GArray *table_data, GArray *linker, > +build_ssdt(Aml *table_data, > AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc, > PcPciInfo *pci, PcGuestInfo *guest_info) > { > MachineState *machine = MACHINE(qdev_get_machine()); > uint32_t nr_mem = machine->ram_slots; > unsigned acpi_cpus = guest_info->apic_id_limit; > - int ssdt_start = table_data->len; > uint8_t *ssdt_ptr; > + Aml *ssdt; > int i; > > /* The current AML generator can cover the APIC ID range [0..255], > @@ -832,9 +832,17 @@ build_ssdt(GArray *table_data, GArray *linker, > QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256); > g_assert(acpi_cpus <= ACPI_CPU_HOTPLUG_ID_LIMIT); > > - /* Copy header and patch values in the S3_ / S4_ / S5_ packages */ > - ssdt_ptr = acpi_data_push(table_data, sizeof(ssdp_misc_aml)); > - memcpy(ssdt_ptr, ssdp_misc_aml, sizeof(ssdp_misc_aml)); > + /* Init SSDT Definition Block */ > + ssdt = aml_def_block("SSDT", 1, ACPI_BUILD_APPNAME6, > + ACPI_BUILD_APPNAME4, 1, > + ACPI_BUILD_APPNAME4_HEX, 1); > + > + /* Copy misc variables and patch values in the S3_ / S4_ / S5_ packages */ > + acpi_data_push(ssdt->buf, sizeof(ssdp_misc_aml) - sizeof(AcpiTableHeader)); > + ssdt_ptr = (uint8_t *)ssdt->buf->data; > + memcpy(ssdt_ptr + sizeof(AcpiTableHeader), > + ssdp_misc_aml + sizeof(AcpiTableHeader), > + sizeof(ssdp_misc_aml) - sizeof(AcpiTableHeader)); > if (pm->s3_disabled) { > ssdt_ptr[acpi_s3_name[0]] = 'X'; > } > @@ -944,13 +952,11 @@ build_ssdt(GArray *table_data, GArray *linker, > } > } > build_package(sb_scope, op); > - build_append_array(table_data, sb_scope); > + build_append_array(ssdt->buf, sb_scope); > build_free_array(sb_scope); > } > > - build_header(linker, table_data, > - (void *)(table_data->data + ssdt_start), > - "SSDT", table_data->len - ssdt_start, 1); > + aml_append(table_data, ssdt); > } > > static void > @@ -1352,7 +1358,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) > > ssdt = tables_blob->len; > acpi_add_table(table_offsets, tables_blob); > - build_ssdt(tables_blob, tables->linker, &cpu, &pm, &misc, &pci, > + build_ssdt(tables->table_data, &cpu, &pm, &misc, &pci, > guest_info); > aml_len += tables_blob->len - ssdt; > > -- > 1.8.3.1
On Tue, 17 Feb 2015 17:42:00 +0100 "Michael S. Tsirkin" <mst@redhat.com> wrote: > On Mon, Feb 09, 2015 at 10:53:28AM +0000, Igor Mammedov wrote: > > it replaces prebuilt SSDT table header template copying/patching > > with AML API > > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > > I note that this changed the SSDT signature in random ways, > for example, it used to be named BXPCSSDT, now it's BXPC. > > Pls keep using build_header, this problem will go away then. [...] > > + /* Init SSDT Definition Block */ > > + ssdt = aml_def_block("SSDT", 1, ACPI_BUILD_APPNAME6, > > + ACPI_BUILD_APPNAME4, 1, I've missed that build_header() composes oem_table_id implicitly by merging table signature and ACPI_BUILD_APPNAME4. following should fix issue: - ACPI_BUILD_APPNAME4, 1, + "BXPCSSDT", 1, > > + ACPI_BUILD_APPNAME4_HEX, 1);
On Wed, Feb 18, 2015 at 10:57:18AM +0100, Igor Mammedov wrote: > On Tue, 17 Feb 2015 17:42:00 +0100 > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > On Mon, Feb 09, 2015 at 10:53:28AM +0000, Igor Mammedov wrote: > > > it replaces prebuilt SSDT table header template copying/patching > > > with AML API > > > > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > > > > I note that this changed the SSDT signature in random ways, > > for example, it used to be named BXPCSSDT, now it's BXPC. > > > > Pls keep using build_header, this problem will go away then. > [...] > > > + /* Init SSDT Definition Block */ > > > + ssdt = aml_def_block("SSDT", 1, ACPI_BUILD_APPNAME6, > > > + ACPI_BUILD_APPNAME4, 1, > I've missed that build_header() composes oem_table_id implicitly > by merging table signature and ACPI_BUILD_APPNAME4. > > following should fix issue: > - ACPI_BUILD_APPNAME4, 1, > + "BXPCSSDT", 1, True but that's the result of code duplication. Let's reuse build_header at step 1, and in step 2, we'll replace it with something else everywhere. > > > + ACPI_BUILD_APPNAME4_HEX, 1);
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 553c86b..fcefa07 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -816,15 +816,15 @@ static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size) } static void -build_ssdt(GArray *table_data, GArray *linker, +build_ssdt(Aml *table_data, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc, PcPciInfo *pci, PcGuestInfo *guest_info) { MachineState *machine = MACHINE(qdev_get_machine()); uint32_t nr_mem = machine->ram_slots; unsigned acpi_cpus = guest_info->apic_id_limit; - int ssdt_start = table_data->len; uint8_t *ssdt_ptr; + Aml *ssdt; int i; /* The current AML generator can cover the APIC ID range [0..255], @@ -832,9 +832,17 @@ build_ssdt(GArray *table_data, GArray *linker, QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256); g_assert(acpi_cpus <= ACPI_CPU_HOTPLUG_ID_LIMIT); - /* Copy header and patch values in the S3_ / S4_ / S5_ packages */ - ssdt_ptr = acpi_data_push(table_data, sizeof(ssdp_misc_aml)); - memcpy(ssdt_ptr, ssdp_misc_aml, sizeof(ssdp_misc_aml)); + /* Init SSDT Definition Block */ + ssdt = aml_def_block("SSDT", 1, ACPI_BUILD_APPNAME6, + ACPI_BUILD_APPNAME4, 1, + ACPI_BUILD_APPNAME4_HEX, 1); + + /* Copy misc variables and patch values in the S3_ / S4_ / S5_ packages */ + acpi_data_push(ssdt->buf, sizeof(ssdp_misc_aml) - sizeof(AcpiTableHeader)); + ssdt_ptr = (uint8_t *)ssdt->buf->data; + memcpy(ssdt_ptr + sizeof(AcpiTableHeader), + ssdp_misc_aml + sizeof(AcpiTableHeader), + sizeof(ssdp_misc_aml) - sizeof(AcpiTableHeader)); if (pm->s3_disabled) { ssdt_ptr[acpi_s3_name[0]] = 'X'; } @@ -944,13 +952,11 @@ build_ssdt(GArray *table_data, GArray *linker, } } build_package(sb_scope, op); - build_append_array(table_data, sb_scope); + build_append_array(ssdt->buf, sb_scope); build_free_array(sb_scope); } - build_header(linker, table_data, - (void *)(table_data->data + ssdt_start), - "SSDT", table_data->len - ssdt_start, 1); + aml_append(table_data, ssdt); } static void @@ -1352,7 +1358,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) ssdt = tables_blob->len; acpi_add_table(table_offsets, tables_blob); - build_ssdt(tables_blob, tables->linker, &cpu, &pm, &misc, &pci, + build_ssdt(tables->table_data, &cpu, &pm, &misc, &pci, guest_info); aml_len += tables_blob->len - ssdt;
it replaces prebuilt SSDT table header template copying/patching with AML API Signed-off-by: Igor Mammedov <imammedo@redhat.com> --- hw/i386/acpi-build.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)