From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Igor Mammedov <imammedo@redhat.com>,
Eric Auger <eric.auger@redhat.com>,
Shannon Zhao <zhaoshenglong@huawei.com>,
qemu-arm@nongnu.org
Subject: [Qemu-devel] [PULL v2 12/50] virt_arm: acpi: reuse common build_fadt()
Date: Tue, 20 Mar 2018 05:17:16 +0200 [thread overview]
Message-ID: <1521515720-612046-13-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1521515720-612046-1-git-send-email-mst@redhat.com>
From: Igor Mammedov <imammedo@redhat.com>
Extend generic build_fadt() to support rev5.1 FADT
and reuse it for 'virt' board, it would allow to
phase out usage of AcpiFadtDescriptorRev5_1 and
later ACPI_FADT_COMMON_DEF.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/acpi/acpi-defs.h | 12 ++----------
hw/acpi/aml-build.c | 23 +++++++++++++++++++++--
hw/arm/virt-acpi-build.c | 33 ++++++++++++---------------------
3 files changed, 35 insertions(+), 33 deletions(-)
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index 3fb0ace..fe15e95 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -165,16 +165,6 @@ struct AcpiFadtDescriptorRev3 {
} QEMU_PACKED;
typedef struct AcpiFadtDescriptorRev3 AcpiFadtDescriptorRev3;
-struct AcpiFadtDescriptorRev5_1 {
- ACPI_FADT_COMMON_DEF
- /* 64-bit Sleep Control register (ACPI 5.0) */
- struct AcpiGenericAddress sleep_control;
- /* 64-bit Sleep Status register (ACPI 5.0) */
- struct AcpiGenericAddress sleep_status;
-} QEMU_PACKED;
-
-typedef struct AcpiFadtDescriptorRev5_1 AcpiFadtDescriptorRev5_1;
-
typedef struct AcpiFadtData {
struct AcpiGenericAddress pm1a_cnt; /* PM1a_CNT_BLK */
struct AcpiGenericAddress pm1a_evt; /* PM1a_EVT_BLK */
@@ -192,6 +182,8 @@ typedef struct AcpiFadtData {
uint8_t rtc_century; /* CENTURY */
uint16_t plvl2_lat; /* P_LVL2_LAT */
uint16_t plvl3_lat; /* P_LVL3_LAT */
+ uint16_t arm_boot_arch; /* ARM_BOOT_ARCH */
+ uint8_t minor_ver; /* FADT Minor Version */
/*
* respective tables offsets within ACPI_BUILD_TABLE_FILE,
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 8f45298..3fa557c 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1679,7 +1679,7 @@ void build_slit(GArray *table_data, BIOSLinker *linker)
table_data->len - slit_start, 1, NULL, NULL);
}
-/* build rev1/rev3 FADT */
+/* build rev1/rev3/rev5.1 FADT */
void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,
const char *oem_id, const char *oem_table_id)
{
@@ -1755,7 +1755,14 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,
build_append_gas_from_struct(tbl, &f->reset_reg); /* RESET_REG */
build_append_int_noprefix(tbl, f->reset_val, 1); /* RESET_VALUE */
- build_append_int_noprefix(tbl, 0, 3); /* Reserved, ACPI 3.0 */
+ /* Since ACPI 5.1 */
+ if ((f->rev >= 6) || ((f->rev == 5) && f->minor_ver > 0)) {
+ build_append_int_noprefix(tbl, f->arm_boot_arch, 2); /* ARM_BOOT_ARCH */
+ /* FADT Minor Version */
+ build_append_int_noprefix(tbl, f->minor_ver, 1);
+ } else {
+ build_append_int_noprefix(tbl, 0, 3); /* Reserved upto ACPI 5.0 */
+ }
build_append_int_noprefix(tbl, 0, 8); /* X_FIRMWARE_CTRL */
/* XDSDT address to be filled by Guest linker at runtime */
@@ -1779,6 +1786,18 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,
build_append_gas_from_struct(tbl, &f->gpe0_blk); /* X_GPE0_BLK */
build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); /* X_GPE1_BLK */
+ if (f->rev <= 4) {
+ goto build_hdr;
+ }
+
+ /* SLEEP_CONTROL_REG */
+ build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0);
+ /* SLEEP_STATUS_REG */
+ build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0);
+
+ /* TODO: extra fields need to be added to support revisions above rev5 */
+ assert(f->rev == 5);
+
build_hdr:
build_header(linker, tbl, (void *)(tbl->data + fadt_start),
"FACP", tbl->len - fadt_start, f->rev, oem_id, oem_table_id);
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index b644da9..c7c6a57 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -654,39 +654,30 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
VirtMachineState *vms, unsigned dsdt_tbl_offset)
{
- int fadt_start = table_data->len;
- AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt));
- unsigned xdsdt_entry_offset = (char *)&fadt->x_dsdt - table_data->data;
- uint16_t bootflags;
+ /* ACPI v5.1 */
+ AcpiFadtData fadt = {
+ .rev = 5,
+ .minor_ver = 1,
+ .flags = 1 << ACPI_FADT_F_HW_REDUCED_ACPI,
+ .xdsdt_tbl_offset = &dsdt_tbl_offset,
+ };
switch (vms->psci_conduit) {
case QEMU_PSCI_CONDUIT_DISABLED:
- bootflags = 0;
+ fadt.arm_boot_arch = 0;
break;
case QEMU_PSCI_CONDUIT_HVC:
- bootflags = ACPI_FADT_ARM_PSCI_COMPLIANT | ACPI_FADT_ARM_PSCI_USE_HVC;
+ fadt.arm_boot_arch = ACPI_FADT_ARM_PSCI_COMPLIANT |
+ ACPI_FADT_ARM_PSCI_USE_HVC;
break;
case QEMU_PSCI_CONDUIT_SMC:
- bootflags = ACPI_FADT_ARM_PSCI_COMPLIANT;
+ fadt.arm_boot_arch = ACPI_FADT_ARM_PSCI_COMPLIANT;
break;
default:
g_assert_not_reached();
}
- /* Hardware Reduced = 1 and use PSCI 0.2+ */
- fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI);
- fadt->arm_boot_flags = cpu_to_le16(bootflags);
-
- /* ACPI v5.1 (fadt->revision.fadt->minor_revision) */
- fadt->minor_revision = 0x1;
-
- /* DSDT address to be filled by Guest linker */
- bios_linker_loader_add_pointer(linker,
- ACPI_BUILD_TABLE_FILE, xdsdt_entry_offset, sizeof(fadt->x_dsdt),
- ACPI_BUILD_TABLE_FILE, dsdt_tbl_offset);
-
- build_header(linker, table_data, (void *)(table_data->data + fadt_start),
- "FACP", table_data->len - fadt_start, 5, NULL, NULL);
+ build_fadt(table_data, linker, &fadt, NULL, NULL);
}
/* DSDT */
--
MST
next prev parent reply other threads:[~2018-03-20 3:17 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-20 3:16 [Qemu-devel] [PULL v2 00/50] virtio, vhost, pci, pc: features, cleanups Michael S. Tsirkin
2018-03-20 3:16 ` [Qemu-devel] [PULL v2 01/50] scripts/update-linux-headers: add ethtool.h and update to 4.16.0-rc4 Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 02/50] virtio-net: use 64-bit values for feature flags Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 03/50] virtio-net: add linkspeed and duplex settings to virtio-net Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 04/50] acpi: remove unused acpi-dsdt.aml Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 05/50] pc: replace pm object initialization with one-liner in acpi_get_pm_info() Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 07/50] acpi: add build_append_gas() helper for Generic Address Structure Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 06/50] acpi: reuse AcpiGenericAddress instead of Acpi20GenericAddress Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 08/50] acpi: move ACPI_PORT_SMI_CMD define to header it belongs to Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 09/50] pc: acpi: isolate FADT specific data into AcpiFadtData structure Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 10/50] pc: acpi: use build_append_foo() API to construct FADT Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 11/50] acpi: move build_fadt() from i386 specific to generic ACPI source Michael S. Tsirkin
2018-03-20 3:17 ` Michael S. Tsirkin [this message]
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 13/50] tests: acpi: don't read all fields in test_acpi_fadt_table() Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 15/50] hw/pci: remove obsolete PCIDevice->init() Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 14/50] standard-headers: update virtio_net.h Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 16/50] pc-dimm: make qmp_pc_dimm_device_list() sort devices by address Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 17/50] qmp: distinguish PC-DIMM and NVDIMM in MemoryDeviceInfoList Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 18/50] hw/acpi-build: build SRAT memory affinity structures for DIMM devices Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 19/50] tests/bios-tables-test: add test cases for DIMM proximity Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 20/50] test/acpi-test-data: add ACPI tables for dimmpxm test Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 21/50] Makefile: add target to print generated files Michael S. Tsirkin
2018-04-13 7:21 ` Markus Armbruster
2018-04-13 10:04 ` Marc-André Lureau
2018-04-13 12:51 ` Michael S. Tsirkin
2018-05-04 5:44 ` Markus Armbruster
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 22/50] migrate: Update ram_block_discard_range for shared Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 23/50] qemu_ram_block_host_offset Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 24/50] postcopy: use UFFDIO_ZEROPAGE only when available Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 25/50] postcopy: Add notifier chain Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 26/50] postcopy: Add vhost-user flag for postcopy and check it Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 27/50] vhost-user: Add 'VHOST_USER_POSTCOPY_ADVISE' message Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 28/50] libvhost-user: Support sending fds back to qemu Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 29/50] libvhost-user: Open userfaultfd Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 30/50] postcopy: Allow registering of fd handler Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 32/50] vhost+postcopy: Transmit 'listen' to slave Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 31/50] vhost+postcopy: Register shared ufd with postcopy Michael S. Tsirkin
2018-04-27 16:12 ` Peter Maydell
2018-05-02 10:58 ` Dr. David Alan Gilbert
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 33/50] postcopy+vhost-user: Split set_mem_table for postcopy Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 34/50] migration/ram: ramblock_recv_bitmap_test_byte_offset Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 35/50] libvhost-user+postcopy: Register new regions with the ufd Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 36/50] vhost+postcopy: Send address back to qemu Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 37/50] vhost+postcopy: Stash RAMBlock and offset Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 39/50] vhost+postcopy: Resolve client address Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 38/50] vhost+postcopy: Helper to send requests to source for shared pages Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 40/50] postcopy: helper for waking shared Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 41/50] postcopy: postcopy_notify_shared_wake Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 44/50] libvhost-user: mprotect & madvises for postcopy Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 42/50] vhost+postcopy: Add vhost waker Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 43/50] vhost+postcopy: Call wakeups Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 46/50] vhost+postcopy: Wire up POSTCOPY_END notify Michael S. Tsirkin
2018-03-20 3:17 ` [Qemu-devel] [PULL v2 45/50] vhost-user: Add VHOST_USER_POSTCOPY_END message Michael S. Tsirkin
2018-03-20 3:18 ` [Qemu-devel] [PULL v2 47/50] vhost: Huge page align and merge Michael S. Tsirkin
2018-03-20 3:18 ` [Qemu-devel] [PULL v2 48/50] postcopy: Allow shared memory Michael S. Tsirkin
2018-03-20 3:18 ` [Qemu-devel] [PULL v2 49/50] libvhost-user: Claim support for postcopy Michael S. Tsirkin
2018-03-20 3:18 ` [Qemu-devel] [PULL v2 50/50] postcopy shared docs Michael S. Tsirkin
2018-03-20 14:18 ` [Qemu-devel] [PULL v2 00/50] virtio, vhost, pci, pc: features, cleanups Peter Maydell
2018-03-20 14:37 ` Michael S. Tsirkin
2018-03-20 15:05 ` Michael S. Tsirkin
2018-03-20 15:41 ` Peter Maydell
2018-03-20 15:51 ` Michael S. Tsirkin
2018-03-20 15:54 ` Peter Maydell
2018-03-20 16:02 ` Michael S. Tsirkin
2018-03-20 17:18 ` Peter Maydell
2018-03-20 17:22 ` Michael S. Tsirkin
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=1521515720-612046-13-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=eric.auger@redhat.com \
--cc=imammedo@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=zhaoshenglong@huawei.com \
/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).