qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Eduardo Habkost <ehabkost@redhat.com>,
	imammedo@redhat.com, ghammer@redhat.com, shannon.zhao@linaro.org,
	Shannon Zhao <zhaoshenglong@huawei.com>,
	pbonzini@redhat.com, lersek@redhat.com,
	Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH v2 4/4] acpi: unify rsdp generation
Date: Mon, 8 Jun 2015 20:14:43 +0200	[thread overview]
Message-ID: <1433787255-4372-5-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1433787255-4372-1-git-send-email-mst@redhat.com>

Now that both i386 and arm use v2 tables,
use common code for both.

Tested-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/hw/acpi/aml-build.h |  2 ++
 hw/acpi/aml-build.c         | 45 +++++++++++++++++++++++++++++++++++++++++++++
 hw/arm/virt-acpi-build.c    | 31 +------------------------------
 hw/i386/acpi-build.c        | 41 -----------------------------------------
 4 files changed, 48 insertions(+), 71 deletions(-)

diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 0a00402..ae169fa 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -289,5 +289,7 @@ void
 build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets);
 void
 build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets);
+GArray *
+build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt, unsigned xsdt);
 
 #endif
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index d0e52c4..9449875 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1237,3 +1237,48 @@ build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
 {
     build_sdt(table_data, linker, table_offsets, "XSDT", sizeof(uint64_t));
 }
+
+GArray *
+build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt, unsigned xsdt)
+{
+    AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp);
+
+    bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, 16,
+                             true /* fseg memory */);
+
+    memcpy(&rsdp->signature, "RSD PTR ", 8);
+    memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, 6);
+
+    rsdp->revision = 0x02;
+    rsdp->length = cpu_to_le32(sizeof *rsdp);
+
+    if (rsdt) {
+        rsdp->rsdt_physical_address = cpu_to_le32(rsdt);
+        /* Address to be filled by Guest linker */
+        bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE,
+                                       ACPI_BUILD_TABLE_FILE,
+                                       rsdp_table, &rsdp->rsdt_physical_address,
+                                       sizeof rsdp->rsdt_physical_address);
+    }
+
+    if (xsdt) {
+        rsdp->xsdt_physical_address = cpu_to_le64(xsdt);
+        bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE,
+                                       ACPI_BUILD_TABLE_FILE,
+                                       rsdp_table, &rsdp->xsdt_physical_address,
+                                       sizeof rsdp->xsdt_physical_address);
+    }
+    rsdp->checksum = 0;
+    /* Checksum to be filled by Guest linker */
+    bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE,
+                                    rsdp, rsdp, offsetof(AcpiRsdpDescriptor, length),
+                                    &rsdp->checksum);
+
+    rsdp->extended_checksum = 0;
+    /* Checksum to be filled by Guest linker */
+    bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE,
+                                    rsdp, rsdp, sizeof *rsdp,
+                                    &rsdp->extended_checksum);
+
+    return rsdp_table;
+}
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 42c8dd9..c164f65 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -304,35 +304,6 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq)
     aml_append(scope, dev);
 }
 
-/* RSDP */
-static GArray *
-build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt)
-{
-    AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp);
-
-    bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, 16,
-                             true /* fseg memory */);
-
-    memcpy(&rsdp->signature, "RSD PTR ", sizeof(rsdp->signature));
-    memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, sizeof(rsdp->oem_id));
-    rsdp->length = cpu_to_le32(sizeof(*rsdp));
-    rsdp->revision = 0x02;
-
-    /* Point to RSDT */
-    rsdp->rsdt_physical_address = cpu_to_le32(rsdt);
-    /* Address to be filled by Guest linker */
-    bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE,
-                                   ACPI_BUILD_TABLE_FILE,
-                                   rsdp_table, &rsdp->rsdt_physical_address,
-                                   sizeof rsdp->rsdt_physical_address);
-    rsdp->checksum = 0;
-    /* Checksum to be filled by Guest linker */
-    bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE,
-                                    rsdp, rsdp, sizeof *rsdp, &rsdp->checksum);
-
-    return rsdp_table;
-}
-
 static void
 build_mcfg(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
 {
@@ -532,7 +503,7 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
     build_rsdt(tables_blob, tables->linker, table_offsets);
 
     /* RSDP is in FSEG memory, so allocate it separately */
-    build_rsdp(tables->rsdp, tables->linker, rsdt);
+    build_rsdp(tables->rsdp, tables->linker, rsdt, 0);
 
     /* Cleanup memory that's no longer used. */
     g_array_free(table_offsets, true);
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 3579d18..8c6d7f5 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1592,47 +1592,6 @@ build_dsdt(GArray *table_data, GArray *linker, AcpiMiscInfo *misc)
                  misc->dsdt_size, 1);
 }
 
-static GArray *
-build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt, unsigned xsdt)
-{
-    AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp);
-
-    bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, 16,
-                             true /* fseg memory */);
-
-    memcpy(&rsdp->signature, "RSD PTR ", 8);
-    memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, 6);
-
-    rsdp->revision = 0x02;
-    rsdp->length = cpu_to_le32(sizeof *rsdp);
-
-    rsdp->rsdt_physical_address = cpu_to_le32(rsdt);
-    /* Address to be filled by Guest linker */
-    bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE,
-                                   ACPI_BUILD_TABLE_FILE,
-                                   rsdp_table, &rsdp->rsdt_physical_address,
-                                   sizeof rsdp->rsdt_physical_address);
-
-    rsdp->xsdt_physical_address = cpu_to_le64(xsdt);
-    bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE,
-                                   ACPI_BUILD_TABLE_FILE,
-                                   rsdp_table, &rsdp->xsdt_physical_address,
-                                   sizeof rsdp->xsdt_physical_address);
-    rsdp->checksum = 0;
-    /* Checksum to be filled by Guest linker */
-    bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE,
-                                    rsdp, rsdp, offsetof(AcpiRsdpDescriptor, length),
-                                    &rsdp->checksum);
-
-    rsdp->extended_checksum = 0;
-    /* Checksum to be filled by Guest linker */
-    bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE,
-                                    rsdp, rsdp, sizeof *rsdp,
-                                    &rsdp->extended_checksum);
-
-    return rsdp_table;
-}
-
 typedef
 struct AcpiBuildState {
     /* Copy of table in RAM (for patching). */
-- 
MST

  parent reply	other threads:[~2015-06-08 18:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-08 18:14 [Qemu-devel] [PATCH v2 0/4] acpi: xsdt support Michael S. Tsirkin
2015-06-08 18:14 ` [Qemu-devel] [PATCH v2 1/4] acpi: add API for 64 bit offsets Michael S. Tsirkin
2015-06-08 18:14 ` [Qemu-devel] [PATCH v2 2/4] i386/acpi: collect 64 bit offsets for xsdt Michael S. Tsirkin
2015-06-08 18:14 ` [Qemu-devel] [PATCH v2 3/4] i386/acpi: add XSDT Michael S. Tsirkin
2015-06-08 18:14 ` Michael S. Tsirkin [this message]
2015-06-09  0:08 ` [Qemu-devel] [PATCH v2 0/4] acpi: xsdt support Laszlo Ersek
2015-06-09  5:31   ` Michael S. Tsirkin
2015-06-09  6:02     ` Paolo Bonzini
2015-06-09  6:35       ` Michael S. Tsirkin
2015-06-09  6:38         ` Michael S. Tsirkin
2015-06-09  7:41           ` Laszlo Ersek
2015-06-09  8:34             ` Michael S. Tsirkin
2015-06-09 14:01               ` Laszlo Ersek
2015-06-09  9:39         ` Igor Mammedov
2015-06-09  9:10       ` Michael S. Tsirkin
2015-06-09  9:49       ` Michael S. Tsirkin
2015-06-09 14:02         ` Laszlo Ersek
2015-06-09 14:05           ` Michael S. Tsirkin
2015-08-27 14:27             ` Laszlo Ersek
2015-08-27 17:58               ` Michael S. Tsirkin
2015-08-28  6:23                 ` Laszlo Ersek

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=1433787255-4372-5-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=ghammer@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=lersek@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=shannon.zhao@linaro.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).