qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gal Hammer <ghammer@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>
Subject: [Qemu-devel] [PATCH FYI 05/13] hw/acpi: add more flexible acpi_add_table() and build_header() variants
Date: Sun, 13 Sep 2015 14:43:39 +0200	[thread overview]
Message-ID: <1442148227-17343-6-git-send-email-lersek@redhat.com> (raw)
In-Reply-To: <1442148227-17343-1-git-send-email-lersek@redhat.com>

acpi_add_table() and build_header() hardcode a number of traits that we'd
like to pass in later on, on a table-by-table basis. These are:

- The fw_cfg file name of the blob that contains the ACPI table.
  ACPI_BUILD_TABLE_FILE is hard-coded at the moment.

- The OEM Table ID field. Due to the way the DataTableRegion() operator
  works, the OEM Table ID field is our only possibility to ensure a unique
  lookup for DataTableRegion(), since we don't populate (Signature, OEM
  ID) uniquely. However, currently OEM Table ID is directly derived from
  Signature. Unicity for DataTableRegion() requires making OEM Table ID
  independent.

Expose the internals of the functions that we have now, so that callers
can control the above traits.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gal Hammer <ghammer@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 include/hw/acpi/aml-build.h |  6 +++++
 hw/acpi/aml-build.c         | 53 +++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 7518659..47d28c9 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -285,9 +285,15 @@ typedef struct BlobOffset BlobOffset;
 void
 build_header(GArray *linker, GArray *table_data,
              AcpiTableHeader *h, const char *sig, int len, uint8_t rev);
+void
+build_header2(GArray *linker, GArray *table_data, const char *blob_name,
+              AcpiTableHeader *h, const char *sig, const char *oem_table_id,
+              int len, uint8_t rev);
 void *acpi_data_push(GArray *table_data, unsigned size);
 unsigned acpi_data_len(GArray *table);
 void acpi_add_table(GArray *table_offsets, GArray *table_data);
+void acpi_add_table2(GArray *table_offsets, GArray *table_data,
+                     const char *blob_name);
 void acpi_build_tables_init(AcpiBuildTables *tables);
 void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre);
 void
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 60c7c2e..03111a3 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1139,18 +1139,48 @@ void
 build_header(GArray *linker, GArray *table_data,
              AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
 {
+    char oem_table_id[8];
+
+    memcpy(oem_table_id, ACPI_BUILD_APPNAME4, 4);
+    memcpy(oem_table_id + 4, sig, 4);
+    build_header2(linker, table_data, ACPI_BUILD_TABLE_FILE, h, sig,
+                  oem_table_id, len, rev);
+}
+
+/* Fill in the SDT header of an ACPI table, and add a linker command to update
+ * its checksum.
+ *
+ * @linker: The linker/loader command file. This will receive the checksum
+ *          update command.
+ * @table_data: The blob in which the ACPI table is embedded.
+ * @blob_name: The fw_cfg file name of the blob under which @table_data will be
+ *             exposed later.
+ * @h: Pointer to the ACPI table header. Must reside within @table_data.
+ * @sig: Signature to place into the ACPI table header. Exactly four bytes will
+ *       be copied.
+ * @oem_table_id: OEM Table ID to place into the ACPI table header. Exactly
+ *                eight bytes will be copied.
+ * @len: Length of the ACPI table, including the SDT header. This determines
+ *       the length field in the header itself, and the number of bytes the
+ *       checksum will cover.
+ * @rev: Revision to place into the ACPI table header.
+ */
+void
+build_header2(GArray *linker, GArray *table_data, const char *blob_name,
+              AcpiTableHeader *h, const char *sig, const char *oem_table_id,
+              int len, uint8_t rev)
+{
     memcpy(&h->signature, sig, 4);
     h->length = cpu_to_le32(len);
     h->revision = rev;
     memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6);
-    memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4);
-    memcpy(h->oem_table_id + 4, sig, 4);
+    memcpy(h->oem_table_id, oem_table_id, 8);
     h->oem_revision = cpu_to_le32(1);
     memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4);
     h->asl_compiler_revision = cpu_to_le32(1);
     h->checksum = 0;
     /* Checksum to be filled in by Guest linker */
-    bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
+    bios_linker_loader_add_checksum(linker, blob_name,
                                     table_data->data, h, len, &h->checksum);
 }
 
@@ -1171,8 +1201,23 @@ unsigned acpi_data_len(GArray *table)
 
 void acpi_add_table(GArray *table_offsets, GArray *table_data)
 {
+    acpi_add_table2(table_offsets, table_data, ACPI_BUILD_TABLE_FILE);
+}
+
+/* Register an ACPI table to be referenced from the RSDT.
+ *
+ * @table_offsets: The array collecting the registrations, with element type
+ *                 BlobOffset.
+ * @table_data: The blob to which the caller will append the ACPI table, after
+ *              this function returns.
+ * @blob_name: The fw_cfg file name of the blob under which @table_data will be
+ *             exposed later.
+ */
+void acpi_add_table2(GArray *table_offsets, GArray *table_data,
+                     const char *blob_name)
+{
     BlobOffset blob_offset = {
-        .blob_name = ACPI_BUILD_TABLE_FILE,
+        .blob_name = blob_name,
         .offset = cpu_to_le32(table_data->len)
     };
     g_array_append_val(table_offsets, blob_offset);
-- 
1.8.3.1

  parent reply	other threads:[~2015-09-13 12:44 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-28 20:18 [Qemu-devel] [RFC] docs: describe QEMU's VMGenID design Laszlo Ersek
2015-09-01 19:47 ` Eric Blake
2015-09-01 22:05   ` Laszlo Ersek
2015-09-01 22:22     ` Eric Blake
2015-09-07 16:30       ` Paolo Bonzini
2015-09-03 13:49 ` Michael S. Tsirkin
2015-09-03 14:24   ` Laszlo Ersek
2015-09-13 11:56 ` [Qemu-devel] Windows does not support DataTableRegion at all [was: docs: describe QEMU's VMGenID design] Laszlo Ersek
2015-09-13 12:34   ` Michael S. Tsirkin
2015-09-13 12:57     ` Laszlo Ersek
2015-09-14  8:24     ` Igor Mammedov
2015-09-14 10:24       ` Laszlo Ersek
2015-09-14 16:53         ` [Qemu-devel] [edk2] " Bill Paul
2015-09-14 17:14           ` Moore, Robert
2015-09-14 17:23             ` Walz, Michael C
2015-09-14 18:04               ` Moore, Robert
2015-09-14 18:24               ` Laszlo Ersek
2015-09-15 10:49               ` Laszlo Ersek
2015-09-14 18:20           ` Laszlo Ersek
2015-09-14 21:12             ` Bill Paul
2015-09-15 10:49               ` Laszlo Ersek
2015-09-15 13:45                 ` Moore, Robert
2015-09-15 14:29                   ` Laszlo Ersek
2015-09-13 12:43   ` [Qemu-devel] [PATCH FYI 00/13] ACPI stuff for the DataTableRegion()-based VMGenID Laszlo Ersek
2015-09-13 12:43     ` [Qemu-devel] [PATCH FYI 01/13] docs: describe QEMU's VMGenID design Laszlo Ersek
2015-09-13 12:43     ` [Qemu-devel] [PATCH FYI 02/13] hw/acpi: add i386 callbacks for injecting GPE 04 when the VMGENID changes Laszlo Ersek
2015-09-13 12:43     ` [Qemu-devel] [PATCH FYI 03/13] hw/acpi: rename "AcpiBuildTables.table_data" to "main_blob" Laszlo Ersek
2015-09-13 12:43     ` [Qemu-devel] [PATCH FYI 04/13] hw/acpi: allow RSDT entries to be relocated to various fw_cfg blobs Laszlo Ersek
2015-09-13 12:43     ` Laszlo Ersek [this message]
2015-09-13 12:43     ` [Qemu-devel] [PATCH FYI 06/13] hw/acpi: introduce ACPI_BUILD_QEMUPARAM_FILE Laszlo Ersek
2015-09-13 12:43     ` [Qemu-devel] [PATCH FYI 07/13] hw/acpi: introduce the AcpiQemuParamTable structure Laszlo Ersek
2015-09-13 12:43     ` [Qemu-devel] [PATCH FYI 08/13] hw/i386: build UEFI ACPI Data Table for VMGENID in the dedicated blob (WIP) Laszlo Ersek
2015-09-13 12:43     ` [Qemu-devel] [PATCH FYI 09/13] hw/acpi: expose more parameters for aml_method() Laszlo Ersek
2015-09-13 12:43     ` [Qemu-devel] [PATCH FYI 10/13] hw/acpi: add AML generator function for DataTableRegion() Laszlo Ersek
2015-09-13 12:43     ` [Qemu-devel] [PATCH FYI 11/13] hw/acpi: add AML generator function for AccessAs() Laszlo Ersek
2015-09-13 12:43     ` [Qemu-devel] [PATCH FYI 12/13] hw/acpi: add AML generator function for CreateQWordField() Laszlo Ersek
2015-09-13 12:43     ` [Qemu-devel] [PATCH FYI 13/13] hw/i386: generate AML for the VMGENID device (WIP) 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=1442148227-17343-6-git-send-email-lersek@redhat.com \
    --to=lersek@redhat.com \
    --cc=ghammer@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@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).