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>,
	Juan Quintela <quintela@redhat.com>,
	dgilbert@redhat.com, Anthony Liguori <aliguori@amazon.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PULL 59/96] pc: acpi-build: use aml_scope() for \_SB scope
Date: Wed, 18 Feb 2015 22:49:49 +0100	[thread overview]
Message-ID: <1424295164-4774-60-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1424295164-4774-1-git-send-email-mst@redhat.com>

From: Igor Mammedov <imammedo@redhat.com>

prepares for incremental conversion of SSDT content to AML API

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/acpi-build.c | 39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 5e4b333..c66fe56 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -923,17 +923,18 @@ build_ssdt(GArray *table_data, GArray *linker,
     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;
     uint8_t *ssdt_ptr;
+    Aml *ssdt, *sb_scope;
     int i;
 
+    ssdt = init_aml_allocator();
     /* 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));
+    ssdt_ptr = acpi_data_push(ssdt->buf, sizeof(ssdp_misc_aml));
     memcpy(ssdt_ptr, ssdp_misc_aml, sizeof(ssdp_misc_aml));
     if (pm->s3_disabled) {
         ssdt_ptr[acpi_s3_name[0]] = 'X';
@@ -953,15 +954,11 @@ 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);
 
+    sb_scope = aml_scope("_SB");
     {
-        GArray *sb_scope = build_alloc_array();
-        uint8_t op = 0x10; /* ScopeOp */
-
-        build_append_namestring(sb_scope, "_SB");
-
         /* build Processor object for each processor */
         for (i = 0; i < acpi_cpus; i++) {
-            uint8_t *proc = acpi_data_push(sb_scope, ACPI_PROC_SIZEOF);
+            uint8_t *proc = acpi_data_push(sb_scope->buf, ACPI_PROC_SIZEOF);
             memcpy(proc, ACPI_PROC_AML, ACPI_PROC_SIZEOF);
             proc[ACPI_PROC_OFFSET_CPUHEX] = acpi_get_hex(i >> 4);
             proc[ACPI_PROC_OFFSET_CPUHEX+1] = acpi_get_hex(i);
@@ -973,11 +970,12 @@ build_ssdt(GArray *table_data, GArray *linker,
          *   Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...}
          */
         /* Arg0 = Processor ID = APIC ID */
-        build_append_notify_method(sb_scope, "NTFY", "CP%0.02X", acpi_cpus);
+        build_append_notify_method(sb_scope->buf, "NTFY",
+                                   "CP%0.02X", acpi_cpus);
 
         /* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })" */
-        build_append_byte(sb_scope, 0x08); /* NameOp */
-        build_append_namestring(sb_scope, "CPON");
+        build_append_byte(sb_scope->buf, 0x08); /* NameOp */
+        build_append_namestring(sb_scope->buf, "CPON");
 
         {
             GArray *package = build_alloc_array();
@@ -1002,7 +1000,7 @@ build_ssdt(GArray *table_data, GArray *linker,
             }
 
             build_package(package, op);
-            build_append_array(sb_scope, package);
+            build_append_array(sb_scope->buf, package);
             build_free_array(package);
         }
 
@@ -1011,7 +1009,7 @@ build_ssdt(GArray *table_data, GArray *linker,
             /* build memory devices */
             for (i = 0; i < nr_mem; i++) {
                 char id[3];
-                uint8_t *mem = acpi_data_push(sb_scope, ACPI_MEM_SIZEOF);
+                uint8_t *mem = acpi_data_push(sb_scope->buf, ACPI_MEM_SIZEOF);
 
                 snprintf(id, sizeof(id), "%02X", i);
                 memcpy(mem, ACPI_MEM_AML, ACPI_MEM_SIZEOF);
@@ -1022,7 +1020,7 @@ build_ssdt(GArray *table_data, GArray *linker,
             /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
              *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ...
              */
-            build_append_notify_method(sb_scope,
+            build_append_notify_method(sb_scope->buf,
                                        stringify(MEMORY_SLOT_NOTIFY_METHOD),
                                        "MP%0.02X", nr_mem);
         }
@@ -1046,17 +1044,18 @@ build_ssdt(GArray *table_data, GArray *linker,
                                              build_pci_bus_end, &hotplug_state);
             }
 
-            build_append_array(sb_scope, hotplug_state.device_table);
+            build_append_array(sb_scope->buf, hotplug_state.device_table);
             build_pci_bus_state_cleanup(&hotplug_state);
         }
-        build_package(sb_scope, op);
-        build_append_array(table_data, sb_scope);
-        build_free_array(sb_scope);
+        aml_append(ssdt, sb_scope);
     }
 
+    /* copy AML table into ACPI tables blob and patch header there */
+    g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
     build_header(linker, table_data,
-                 (void *)(table_data->data + ssdt_start),
-                 "SSDT", table_data->len - ssdt_start, 1);
+        (void *)(table_data->data + table_data->len - ssdt->buf->len),
+        "SSDT", ssdt->buf->len, 1);
+    free_aml_allocator();
 }
 
 static void
-- 
MST

  parent reply	other threads:[~2015-02-18 21:49 UTC|newest]

Thread overview: 111+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-18 21:43 [Qemu-devel] [PULL 00/96] pci, pc, virtio fixes and cleanups Michael S. Tsirkin
2015-02-18 21:44 ` [Qemu-devel] [PULL 01/96] acpi-build: fix memory leak with bridge hp off Michael S. Tsirkin
2015-02-18 21:44 ` [Qemu-devel] [PULL 02/96] bios linker: validate pointer within table Michael S. Tsirkin
2015-02-18 21:44 ` [Qemu-devel] [PULL 03/96] acpi: move generic aml building helpers into dedictated file Michael S. Tsirkin
2015-02-18 21:44 ` [Qemu-devel] [PULL 04/96] acpi: add build_append_namestring() helper Michael S. Tsirkin
2015-02-18 21:44 ` [Qemu-devel] [PULL 05/96] acpi: drop min-bytes in build_package() Michael S. Tsirkin
2015-02-18 21:44 ` [Qemu-devel] [PULL 06/96] pci: Convert core to realize Michael S. Tsirkin
2015-02-18 21:44 ` [Qemu-devel] [PULL 07/96] pci: Permit incremental conversion of device models " Michael S. Tsirkin
2015-02-18 21:44 ` [Qemu-devel] [PULL 08/96] pci: Trivial device model conversions " Michael S. Tsirkin
2015-02-18 21:44 ` [Qemu-devel] [PULL 09/96] pcnet: pcnet_common_init() always returns 0, change to void Michael S. Tsirkin
2015-02-18 21:45 ` [Qemu-devel] [PULL 10/96] pcnet: Convert to realize Michael S. Tsirkin
2015-02-18 21:45 ` [Qemu-devel] [PULL 11/96] serial-pci: " Michael S. Tsirkin
2015-02-18 21:45 ` [Qemu-devel] [PULL 12/96] ide/ich: " Michael S. Tsirkin
2015-02-18 21:45 ` [Qemu-devel] [PULL 13/96] cirrus-vga: " Michael S. Tsirkin
2015-02-18 21:45 ` [Qemu-devel] [PULL 14/96] qxl: " Michael S. Tsirkin
2015-02-18 21:45 ` [Qemu-devel] [PULL 15/96] pci-assign: " Michael S. Tsirkin
2015-02-18 21:45 ` [Qemu-devel] [PULL 16/96] qdev: Don't exit when running into bad -global Michael S. Tsirkin
2015-02-18 21:45 ` [Qemu-devel] [PULL 17/96] acpi, pc: Add hotunplug request cb for pc machine Michael S. Tsirkin
2015-02-18 21:45 ` [Qemu-devel] [PULL 18/96] acpi, ich9: Add hotunplug request cb for ich9 Michael S. Tsirkin
2015-02-18 21:45 ` [Qemu-devel] [PULL 19/96] acpi, pc: Add unplug cb for pc machine Michael S. Tsirkin
2015-02-18 21:46 ` [Qemu-devel] [PULL 20/96] acpi, ich9: Add unplug cb for ich9 Michael S. Tsirkin
2015-02-18 21:46 ` [Qemu-devel] [PULL 21/96] acpi, piix4: Add unplug cb for piix4 Michael S. Tsirkin
2015-02-18 21:46 ` [Qemu-devel] [PULL 22/96] vl.c: Fix error messages when parsing maxmem parameters Michael S. Tsirkin
2015-02-18 21:46 ` [Qemu-devel] [PULL 23/96] pc: memory: Validate alignment of maxram_size to page size Michael S. Tsirkin
2015-02-18 21:46 ` [Qemu-devel] [PULL 24/96] acpi: update RSDP on guest access Michael S. Tsirkin
2015-02-18 21:46 ` [Qemu-devel] [PULL 25/96] pc: acpi-build: update linker " Michael S. Tsirkin
2015-02-18 21:46 ` [Qemu-devel] [PULL 26/96] pc: acpi-build: migrate RSDP table Michael S. Tsirkin
2015-02-18 21:46 ` [Qemu-devel] [PULL 27/96] exec: round up size on MR resize Michael S. Tsirkin
2015-02-18 21:46 ` [Qemu-devel] [PULL 28/96] acpi-build: fix ACPI RAM management Michael S. Tsirkin
2015-02-18 21:46 ` [Qemu-devel] [PULL 29/96] acpi: has_immutable_rsdp->!rsdp_in_ram Michael S. Tsirkin
2015-02-18 21:47 ` [Qemu-devel] [PULL 30/96] acpi-build: simplify rsdp management for legacy Michael S. Tsirkin
2015-02-18 21:47 ` [Qemu-devel] [PULL 31/96] scripts/update-linux-headers.sh: pull virtio hdrs Michael S. Tsirkin
2015-02-18 21:47 ` [Qemu-devel] [PULL 32/96] include: import virtio headers from linux 4.0 Michael S. Tsirkin
2015-02-18 21:47 ` [Qemu-devel] [PULL 33/96] virtio: use standard virtio_ring.h Michael S. Tsirkin
2015-02-18 21:47 ` [Qemu-devel] [PULL 34/96] virtio: use standard-headers Michael S. Tsirkin
2015-02-18 21:47 ` [Qemu-devel] [PULL 35/96] virtio-balloon: use standard headers Michael S. Tsirkin
2015-02-18 21:47 ` [Qemu-devel] [PULL 36/96] virtio-9p: " Michael S. Tsirkin
2015-02-18 21:47 ` [Qemu-devel] [PULL 37/96] virtio-blk: switch to standard-headers Michael S. Tsirkin
2015-02-18 21:47 ` [Qemu-devel] [PULL 38/96] virtio-net,tap: use standard-headers Michael S. Tsirkin
2015-02-18 21:48 ` [Qemu-devel] [PULL 39/96] virtio-rng: " Michael S. Tsirkin
2015-02-18 21:48 ` [Qemu-devel] [PULL 40/96] virtio-scsi: " Michael S. Tsirkin
2015-03-11  7:14   ` Fam Zheng
2015-03-11  8:31     ` Michael S. Tsirkin
2015-03-11  9:48       ` Paolo Bonzini
2015-03-11 12:25         ` Michael S. Tsirkin
2015-02-18 21:48 ` [Qemu-devel] [PULL 41/96] virtio-serial: switch to standard-headers Michael S. Tsirkin
2015-02-18 21:48 ` [Qemu-devel] [PULL 42/96] update-linux-headers: use standard-headers Michael S. Tsirkin
2015-02-18 21:48 ` [Qemu-devel] [PULL 43/96] linux-headers: " Michael S. Tsirkin
2015-02-18 21:48 ` [Qemu-devel] [PULL 00/96] pci, pc, virtio fixes and cleanups Michael S. Tsirkin
2015-02-18 22:03   ` Michael S. Tsirkin
2015-02-19  7:58     ` Michael S. Tsirkin
2015-02-19  8:23     ` Peter Maydell
2015-02-18 21:48 ` [Qemu-devel] [PULL 44/96] virtio-pci: use standard headers Michael S. Tsirkin
2015-02-18 21:48 ` [Qemu-devel] [PULL 45/96] scripts: add arch specific standard-headers Michael S. Tsirkin
2015-02-18 21:48 ` [Qemu-devel] [PULL 46/96] standard-headers: add s390 virtio headers Michael S. Tsirkin
2015-02-18 21:48 ` [Qemu-devel] [PULL 47/96] s390: use standard headers Michael S. Tsirkin
2015-02-18 21:48 ` [Qemu-devel] [PULL 48/96] virtio: cull virtio_bus_set_vdev_features Michael S. Tsirkin
2015-02-18 21:48 ` [Qemu-devel] [PULL 49/96] virtio: feature bit manipulation helpers Michael S. Tsirkin
2015-02-18 21:49 ` [Qemu-devel] [PULL 50/96] virtio: add feature checking helpers Michael S. Tsirkin
2015-02-18 21:49 ` [Qemu-devel] [PULL 51/96] acpi-build: skip hotplugged bridges Michael S. Tsirkin
2015-02-18 21:49 ` [Qemu-devel] [PULL 52/96] pc: acpi: use local var for accessing ACPI tables blob in acpi_build() Michael S. Tsirkin
2015-02-18 21:49 ` [Qemu-devel] [PULL 53/96] update-linux-headers.sh: s/__inline__/inline/ Michael S. Tsirkin
2015-02-18 21:49 ` [Qemu-devel] [PULL 54/96] virtio-serial-bus.c: drop virtio_ids.h Michael S. Tsirkin
2015-02-18 21:49 ` [Qemu-devel] [PULL 55/96] standard-headers: include stdint.h Michael S. Tsirkin
2015-02-18 21:49 ` [Qemu-devel] [PULL 56/96] virtio_ring.h: s/__inline__/inline/ Michael S. Tsirkin
2015-02-18 21:49 ` [Qemu-devel] [PULL 57/96] acpi: introduce AML composer aml_append() Michael S. Tsirkin
2015-02-18 21:49 ` [Qemu-devel] [PULL 58/96] acpi: add aml_scope() term Michael S. Tsirkin
2015-02-18 21:49 ` Michael S. Tsirkin [this message]
2015-02-18 21:49 ` [Qemu-devel] [PULL 60/96] acpi: add aml_device() term Michael S. Tsirkin
2015-02-18 21:50 ` [Qemu-devel] [PULL 61/96] acpi: add aml_method() term Michael S. Tsirkin
2015-02-18 21:50 ` [Qemu-devel] [PULL 62/96] acpi: add aml_if() term Michael S. Tsirkin
2015-02-18 21:50 ` [Qemu-devel] [PULL 63/96] acpi: add aml_name() & aml_name_decl() term Michael S. Tsirkin
2015-02-18 21:50 ` [Qemu-devel] [PULL 64/96] acpi: add aml_int() term Michael S. Tsirkin
2015-02-18 21:50 ` [Qemu-devel] [PULL 65/96] acpi: add aml_return() term Michael S. Tsirkin
2015-02-18 21:50 ` [Qemu-devel] [PULL 66/96] acpi: add aml_arg() term Michael S. Tsirkin
2015-02-18 21:50 ` [Qemu-devel] [PULL 67/96] acpi: add aml_store() term Michael S. Tsirkin
2015-02-18 21:50 ` [Qemu-devel] [PULL 68/96] acpi: add aml_and() term Michael S. Tsirkin
2015-02-18 21:50 ` [Qemu-devel] [PULL 69/96] acpi: add aml_notify() term Michael S. Tsirkin
2015-02-18 21:50 ` [Qemu-devel] [PULL 70/96] acpi: add aml_call1(), aml_call2(), aml_call3(), aml_call4() helpers Michael S. Tsirkin
2015-02-18 21:50 ` [Qemu-devel] [PULL 71/96] acpi: add aml_package() term Michael S. Tsirkin
2015-02-18 21:50 ` [Qemu-devel] [PULL 72/96] pc: acpi-build: generate _S[345] packages dynamically Michael S. Tsirkin
2015-02-18 21:51 ` [Qemu-devel] [PULL 73/96] acpi: add aml_buffer() term Michael S. Tsirkin
2015-02-18 21:51 ` [Qemu-devel] [PULL 74/96] acpi: add aml_resource_template() helper Michael S. Tsirkin
2015-02-18 21:51 ` [Qemu-devel] [PULL 75/96] acpi: add aml_io() helper Michael S. Tsirkin
2015-02-18 21:51 ` [Qemu-devel] [PULL 76/96] acpi: include PkgLength size only when requested Michael S. Tsirkin
2015-02-18 21:51 ` [Qemu-devel] [PULL 77/96] acpi: add aml_operation_region() term Michael S. Tsirkin
2015-02-18 21:51 ` [Qemu-devel] [PULL 78/96] acpi: add aml_field() & aml_named_field() terms Michael S. Tsirkin
2015-02-18 21:51 ` [Qemu-devel] [PULL 79/96] acpi: add aml_local() term Michael S. Tsirkin
2015-02-18 21:51 ` [Qemu-devel] [PULL 80/96] acpi: add aml_string() term Michael S. Tsirkin
2015-02-18 21:51 ` [Qemu-devel] [PULL 81/96] pc: acpi-build: generate pvpanic device description dynamically Michael S. Tsirkin
2015-02-18 21:51 ` [Qemu-devel] [PULL 82/96] acpi: add aml_varpackage() term Michael S. Tsirkin
2015-02-18 21:51 ` [Qemu-devel] [PULL 83/96] acpi: add aml_equal() term Michael S. Tsirkin
2015-02-18 21:51 ` [Qemu-devel] [PULL 84/96] acpi: add aml_processor() term Michael S. Tsirkin
2015-02-18 21:52 ` [Qemu-devel] [PULL 85/96] acpi: add aml_eisaid() term Michael S. Tsirkin
2015-02-18 21:52 ` [Qemu-devel] [PULL 86/96] pc: acpi-build: drop template patching and CPU hotplug objects dynamically Michael S. Tsirkin
2015-02-18 21:52 ` [Qemu-devel] [PULL 87/96] pc: acpi-build: create CPU hotplug IO region dynamically Michael S. Tsirkin
2015-02-18 21:52 ` [Qemu-devel] [PULL 88/96] acpi: add aml_reserved_field() term Michael S. Tsirkin
2015-02-18 21:52 ` [Qemu-devel] [PULL 89/96] pc: acpi-build: drop template patching and memory hotplug objects dynamically Michael S. Tsirkin
2015-02-18 21:52 ` [Qemu-devel] [PULL 90/96] pc: acpi-build: create memory hotplug IO region dynamically Michael S. Tsirkin
2015-02-18 21:52 ` [Qemu-devel] [PULL 91/96] acpi: add aml_word_bus_number(), aml_word_io(), aml_dword_memory(), aml_qword_memory() terms Michael S. Tsirkin
2015-02-18 21:52 ` [Qemu-devel] [PULL 92/96] pc: pcihp: expose MMIO base and len as properties Michael S. Tsirkin
2015-02-18 21:52 ` [Qemu-devel] [PULL 93/96] pc: acpi-build: reserve PCIHP MMIO resources Michael S. Tsirkin
2015-02-18 21:52 ` [Qemu-devel] [PULL 94/96] acpi: update generated hex files Michael S. Tsirkin
2015-02-18 21:53 ` [Qemu-devel] [PULL 95/96] acpi: drop unused generated files Michael S. Tsirkin
2015-02-18 21:53 ` [Qemu-devel] [PULL 96/96] acpi-test: update expected files Michael S. Tsirkin
2015-02-24 16:47 ` [Qemu-devel] [PULL 00/96] pci, pc, virtio fixes and cleanups Michael S. Tsirkin
2015-02-26 11:17 ` Peter Maydell
2015-02-26 11:41   ` Michael S. Tsirkin
2015-02-26 11:59     ` Peter Maydell
2015-02-26 12:06       ` Michael S. Tsirkin
2015-02-26 11:53   ` 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=1424295164-4774-60-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=dgilbert@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=rth@twiddle.net \
    /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).