]> git.proxmox.com Git - qemu.git/commitdiff
acpi: add interface to access user-installed tables
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 7 Oct 2013 11:41:40 +0000 (14:41 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 14 Oct 2013 14:48:53 +0000 (17:48 +0300)
Also add a new API to install builtin tables, so
that we can distinguish between the two.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/acpi/core.c
include/hw/acpi/acpi.h

index 7467b88e27c5256e36eda6ab73c70a9e9f6a73f2..4d25d8eff087cb76ba9b2075083f83138cf3cf73 100644 (file)
@@ -309,6 +309,46 @@ out:
     error_propagate(errp, err);
 }
 
+static bool acpi_table_builtin = false;
+
+void acpi_table_add_builtin(const QemuOpts *opts, Error **errp)
+{
+    acpi_table_builtin = true;
+    acpi_table_add(opts, errp);
+}
+
+unsigned acpi_table_len(void *current)
+{
+    struct acpi_table_header *hdr = current - sizeof(hdr->_length);
+    return hdr->_length;
+}
+
+static
+void *acpi_table_hdr(void *h)
+{
+    struct acpi_table_header *hdr = h;
+    return &hdr->sig;
+}
+
+uint8_t *acpi_table_first(void)
+{
+    if (acpi_table_builtin || !acpi_tables) {
+        return NULL;
+    }
+    return acpi_table_hdr(acpi_tables + ACPI_TABLE_PFX_SIZE);
+}
+
+uint8_t *acpi_table_next(uint8_t *current)
+{
+    uint8_t *next = current + acpi_table_len(current);
+
+    if (next - acpi_tables >= acpi_tables_len) {
+        return NULL;
+    } else {
+        return acpi_table_hdr(next);
+    }
+}
+
 static void acpi_notify_wakeup(Notifier *notifier, void *data)
 {
     ACPIREGS *ar = container_of(notifier, ACPIREGS, wakeup);
index 51733d33903f2a329df59e59de29fe91b7a9d2dd..6bbcb1750dbabbed33622e1d04f5e29c8fc14657 100644 (file)
@@ -165,6 +165,10 @@ extern int acpi_enabled;
 extern char unsigned *acpi_tables;
 extern size_t acpi_tables_len;
 
+uint8_t *acpi_table_first(void);
+uint8_t *acpi_table_next(uint8_t *current);
+unsigned acpi_table_len(void *current);
 void acpi_table_add(const QemuOpts *opts, Error **errp);
+void acpi_table_add_builtin(const QemuOpts *opts, Error **errp);
 
 #endif /* !QEMU_HW_ACPI_H */