From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: imammedo@redhat.com, dgilbert@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH 1/4] pc: append ssdt-misc.dsl to the DSDT
Date: Wed, 24 Dec 2014 14:12:40 +0100 [thread overview]
Message-ID: <1419426766-1593-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1419426766-1593-1-git-send-email-pbonzini@redhat.com>
This part of the ACPI tables can vary in size across machine types, but
does not depend on the command-line. It is an SSDT just because it is
the same for i440fx and Q35, and making it an SSDT made the code a bit
simpler. However, it also complicates backwards compatibility, so
merge it with the DSDT.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/i386/acpi-build.c | 54 ++++++++++++++++++++++++++++++++++------------------
1 file changed, 35 insertions(+), 19 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index a4d0c0c..c8088f1 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1061,26 +1061,17 @@ static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size)
}
}
-static void
-build_ssdt(GArray *table_data, GArray *linker,
- AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
- PcPciInfo *pci, PcGuestInfo *guest_info)
+static size_t
+append_ssdt_misc(GArray *table_data, AcpiPmInfo *pm, AcpiMiscInfo *misc,
+ PcPciInfo *pci)
{
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;
+ size_t size = sizeof(ssdp_misc_aml) - sizeof(AcpiTableHeader);
uint8_t *ssdt_ptr;
- int i;
-
- /* The current AML generator can cover the APIC ID range [0..255],
- * inclusive, for VCPU hotplug. */
- 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));
+ ssdt_ptr = g_memdup(ssdp_misc_aml, sizeof(ssdp_misc_aml));
if (pm->s3_disabled) {
ssdt_ptr[acpi_s3_name[0]] = 'X';
}
@@ -1099,6 +1090,29 @@ build_ssdt(GArray *table_data, GArray *linker,
ACPI_BUILD_SET_LE(ssdt_ptr, sizeof(ssdp_misc_aml),
ssdt_mctrl_nr_slots[0], 32, nr_mem);
+ memcpy(acpi_data_push(table_data, size),
+ ssdt_ptr + sizeof(AcpiTableHeader), size);
+ g_free(ssdt_ptr);
+ return size;
+}
+
+static void
+build_ssdt(GArray *table_data, GArray *linker,
+ AcpiCpuInfo *cpu, AcpiPmInfo *pm, 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;
+ int i;
+
+ acpi_data_push(table_data, sizeof(AcpiTableHeader));
+
+ /* The current AML generator can cover the APIC ID range [0..255],
+ * inclusive, for VCPU hotplug. */
+ QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256);
+ g_assert(acpi_cpus <= ACPI_CPU_HOTPLUG_ID_LIMIT);
+
{
GArray *sb_scope = build_alloc_array();
uint8_t op = 0x10; /* ScopeOp */
@@ -1423,18 +1437,21 @@ build_dmar_q35(GArray *table_data, GArray *linker)
}
static void
-build_dsdt(GArray *table_data, GArray *linker, AcpiMiscInfo *misc)
+build_dsdt(GArray *table_data, GArray *linker, AcpiPmInfo *pm,
+ AcpiMiscInfo *misc, PcPciInfo *pci)
{
AcpiTableHeader *dsdt;
+ size_t ssdt_misc_size;
assert(misc->dsdt_code && misc->dsdt_size);
dsdt = acpi_data_push(table_data, misc->dsdt_size);
memcpy(dsdt, misc->dsdt_code, misc->dsdt_size);
+ ssdt_misc_size = append_ssdt_misc(table_data, pm, misc, pci);
memset(dsdt, 0, sizeof *dsdt);
build_header(linker, table_data, dsdt, "DSDT",
- misc->dsdt_size, 1);
+ misc->dsdt_size + ssdt_misc_size, 1);
}
/* Build final rsdt table */
@@ -1591,7 +1608,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
/* DSDT is pointed to by FADT */
dsdt = tables->table_data->len;
- build_dsdt(tables->table_data, tables->linker, &misc);
+ build_dsdt(tables->table_data, tables->linker, &pm, &misc, &pci);
/* Count the size of the DSDT and SSDT, we will need it for legacy
* sizing of ACPI tables.
@@ -1604,8 +1621,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
ssdt = tables->table_data->len;
acpi_add_table(table_offsets, tables->table_data);
- build_ssdt(tables->table_data, tables->linker, &cpu, &pm, &misc, &pci,
- guest_info);
+ build_ssdt(tables->table_data, tables->linker, &cpu, &pm, guest_info);
aml_len += tables->table_data->len - ssdt;
acpi_add_table(table_offsets, tables->table_data);
--
1.8.3.1
next prev parent reply other threads:[~2014-12-24 13:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-24 13:12 [Qemu-devel] [PATCH 0/4] acpi: move common parts of the SSDT to the DSDT (and preview of things to come) Paolo Bonzini
2014-12-24 13:12 ` Paolo Bonzini [this message]
2014-12-24 13:12 ` [Qemu-devel] [PATCH 2/4] pc: rename ssdt-misc to dsdt-common Paolo Bonzini
2014-12-24 13:12 ` [Qemu-devel] [PATCH 3/4] pc: move common parts of the DSDT " Paolo Bonzini
2014-12-24 13:12 ` [Qemu-devel] [PATCH 4/4] pc: merge DSDT common parts into acpi-dsdt-common.dsl Paolo Bonzini
2014-12-24 13:12 ` [Qemu-devel] [PATCH 5/4] pc: introduce new ACPI table sizing algorithm Paolo Bonzini
2014-12-24 13:12 ` [Qemu-devel] [PATCH 6/4] pc: clean up pre-2.1 compatibility code Paolo Bonzini
2014-12-24 13:12 ` [Qemu-devel] [PATCH 7/4] pc: go back to smaller ACPI tables Paolo Bonzini
2014-12-24 13:17 ` [Qemu-devel] [PATCH 0/4] acpi: move common parts of the SSDT to the DSDT (and preview of things to come) Paolo Bonzini
2014-12-24 14:19 ` Michael S. Tsirkin
2014-12-24 14:43 ` Paolo Bonzini
2014-12-24 16:15 ` Michael S. Tsirkin
2015-01-19 12:22 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1419426766-1593-2-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=dgilbert@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).