aboutsummaryrefslogtreecommitdiff
path: root/tests/acpi-utils.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-12-21 14:06:01 +0000
committerPeter Maydell <peter.maydell@linaro.org>2018-12-21 14:06:01 +0000
commit15763776bfc1017adfded6afaebe220bca582923 (patch)
tree260d01eeb5f1637122c31c7c7e066c39d6d8664f /tests/acpi-utils.c
parent41e2c56ed95db328a4e24c5756312c0158de71ce (diff)
parent47748bbba24d4f4680b77da3dc5b4da531cd17d4 (diff)
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
pci, pc, virtio: fixes, features VTD fixes IR and split irqchip are now the default for Q35 ACPI refactoring hotplug refactoring new names for virtio devices multiple pcie link width/speeds PCI fixes Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Thu 20 Dec 2018 18:26:03 GMT # gpg: using RSA key 281F0DB8D28D5469 # gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" # gpg: aka "Michael S. Tsirkin <mst@redhat.com>" # Primary key fingerprint: 0270 606B 6F3C DF3D 0B17 0970 C350 3912 AFBE 8E67 # Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA 8A0D 281F 0DB8 D28D 5469 * remotes/mst/tags/for_upstream: (44 commits) x86-iommu: turn on IR by default if proper x86-iommu: switch intr_supported to OnOffAuto type q35: set split kernel irqchip as default pci: Adjust PCI config limit based on bus topology spapr_pci: perform unplug via the hotplug handler pci/shpc: perform unplug via the hotplug handler pci: Reuse pci-bridge hotplug handler handlers for pcie-pci-bridge pci/pcie: perform unplug via the hotplug handler pci/pcihp: perform unplug via the hotplug handler pci/pcihp: overwrite hotplug handler recursively from the start pci/pcihp: perform check for bus capability in pre_plug handler s390x/pci: rename hotplug handler callbacks pci/shpc: rename hotplug handler callbacks pci/pcie: rename hotplug handler callbacks hw/i386: Remove deprecated machines pc-0.10 and pc-0.11 hw: acpi: Remove AcpiRsdpDescriptor and fix tests hw: acpi: Export and share the ARM RSDP build hw: arm: Support both legacy and current RSDP build hw: arm: Convert the RSDP build to the buid_append_foo() API hw: arm: Carry RSDP specific data through AcpiRsdpData ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/acpi-utils.c')
-rw-r--r--tests/acpi-utils.c50
1 files changed, 39 insertions, 11 deletions
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index 6dc8ca1a8c..17abcc43a4 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -15,7 +15,6 @@
#include "qemu/osdep.h"
#include <glib/gstdio.h>
#include "qemu-common.h"
-#include "hw/smbios/smbios.h"
#include "qemu/bitmap.h"
#include "acpi-utils.h"
#include "boot-sector.h"
@@ -52,15 +51,44 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
return off;
}
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr,
- AcpiRsdpDescriptor *rsdp_table)
+uint32_t acpi_get_rsdt_address(uint8_t *rsdp_table)
{
- ACPI_READ_FIELD(qts, rsdp_table->signature, addr);
- ACPI_ASSERT_CMP64(rsdp_table->signature, "RSD PTR ");
-
- ACPI_READ_FIELD(qts, rsdp_table->checksum, addr);
- ACPI_READ_ARRAY(qts, rsdp_table->oem_id, addr);
- ACPI_READ_FIELD(qts, rsdp_table->revision, addr);
- ACPI_READ_FIELD(qts, rsdp_table->rsdt_physical_address, addr);
- ACPI_READ_FIELD(qts, rsdp_table->length, addr);
+ uint32_t rsdt_physical_address;
+
+ memcpy(&rsdt_physical_address, &rsdp_table[16 /* RsdtAddress offset */], 4);
+ return le32_to_cpu(rsdt_physical_address);
+}
+
+uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
+{
+ uint64_t xsdt_physical_address;
+ uint8_t revision = rsdp_table[15 /* Revision offset */];
+
+ /* We must have revision 2 if we're looking for an XSDT pointer */
+ g_assert(revision == 2);
+
+ memcpy(&xsdt_physical_address, &rsdp_table[24 /* XsdtAddress offset */], 8);
+ return le64_to_cpu(xsdt_physical_address);
+}
+
+void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
+{
+ uint8_t revision;
+
+ /* Read mandatory revision 0 table data (20 bytes) first */
+ qtest_memread(qts, addr, rsdp_table, 20);
+ revision = rsdp_table[15 /* Revision offset */];
+
+ switch (revision) {
+ case 0: /* ACPI 1.0 RSDP */
+ break;
+ case 2: /* ACPI 2.0+ RSDP */
+ /* Read the rest of the RSDP table */
+ qtest_memread(qts, addr + 20, rsdp_table + 20, 16);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+
+ ACPI_ASSERT_CMP64(*((uint64_t *)(rsdp_table)), "RSD PTR ");
}