diff mbox

[FYI,10/13] hw/acpi: add AML generator function for DataTableRegion()

Message ID 1442148227-17343-11-git-send-email-lersek@redhat.com
State New
Headers show

Commit Message

Laszlo Ersek Sept. 13, 2015, 12:43 p.m. UTC
This ASL operator (and the underlying AML) enables named ACPI data tables
to be located from AML code, and to be accessed field-wise, like an
operation region. This is useful for passing down "parameter tables" to
the guest; the ACPI linker/loader can relocate pointers in them, and then
the AML code can read valid pointer values from the fields in the tables.

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 |  2 ++
 hw/acpi/aml-build.c         | 14 ++++++++++++++
 2 files changed, 16 insertions(+)
diff mbox

Patch

diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index f8f96ec..dc4d215 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -225,6 +225,8 @@  Aml *aml_io(AmlIODecode dec, uint16_t min_base, uint16_t max_base,
             uint8_t aln, uint8_t len);
 Aml *aml_operation_region(const char *name, AmlRegionSpace rs,
                           uint32_t offset, uint32_t len);
+Aml *aml_data_table_region(const char *name, Aml *sig, Aml *oem_id,
+                           Aml *oem_table_id);
 Aml *aml_irq_no_flags(uint8_t irq);
 Aml *aml_named_field(const char *name, unsigned length);
 Aml *aml_reserved_field(unsigned length);
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index a0f187e..2dd2f33 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -788,6 +788,20 @@  Aml *aml_operation_region(const char *name, AmlRegionSpace rs,
     return var;
 }
 
+/* ACPI 2.0: 17.2.4.2 Named Objects Encoding: DefDataRegion */
+Aml *aml_data_table_region(const char *name, Aml *sig, Aml *oem_id,
+                           Aml *oem_table_id)
+{
+    Aml *var = aml_alloc();
+    build_append_byte(var->buf, 0x5B); /* ExtOpPrefix */
+    build_append_byte(var->buf, 0x88); /* DataRegionOp */
+    build_append_namestring(var->buf, "%s", name);
+    aml_append(var, sig);
+    aml_append(var, oem_id);
+    aml_append(var, oem_table_id);
+    return var;
+}
+
 /* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: NamedField */
 Aml *aml_named_field(const char *name, unsigned length)
 {