cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From 99ac82bfa364eef3e6aa27a12d4eb5e23c7ccfb1 Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <99ac82bfa364eef3e6aa27a12d4eb5e23c7ccfb1.1387298827.git.minovotn@redhat.com>
0a122b
In-Reply-To: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
0a122b
References: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
0a122b
From: "Michael S. Tsirkin" <mst@redhat.com>
0a122b
Date: Tue, 17 Dec 2013 15:19:02 +0100
0a122b
Subject: [PATCH 46/56] acpi: add interface to access user-installed tables
0a122b
0a122b
RH-Author: Michael S. Tsirkin <mst@redhat.com>
0a122b
Message-id: <1387293161-4085-47-git-send-email-mst@redhat.com>
0a122b
Patchwork-id: 56353
0a122b
O-Subject: [PATCH qemu-kvm RHEL7.0 v2 46/57] acpi: add interface to access user-installed tables
0a122b
Bugzilla: 1034876
0a122b
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
0a122b
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
0a122b
Also add a new API to install builtin tables, so
0a122b
that we can distinguish between the two.
0a122b
0a122b
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
0a122b
(cherry picked from commit 60de1163d5b5013fe964ac0792e9a64a823e73a3)
0a122b
---
0a122b
 include/hw/acpi/acpi.h |  4 ++++
0a122b
 hw/acpi/core.c         | 40 ++++++++++++++++++++++++++++++++++++++++
0a122b
 2 files changed, 44 insertions(+)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 hw/acpi/core.c         | 40 ++++++++++++++++++++++++++++++++++++++++
0a122b
 include/hw/acpi/acpi.h |  4 ++++
0a122b
 2 files changed, 44 insertions(+)
0a122b
0a122b
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
0a122b
index 42eeace..3352d17 100644
0a122b
--- a/hw/acpi/core.c
0a122b
+++ b/hw/acpi/core.c
0a122b
@@ -309,6 +309,46 @@ out:
0a122b
     error_propagate(errp, err);
0a122b
 }
0a122b
 
0a122b
+static bool acpi_table_builtin = false;
0a122b
+
0a122b
+void acpi_table_add_builtin(const QemuOpts *opts, Error **errp)
0a122b
+{
0a122b
+    acpi_table_builtin = true;
0a122b
+    acpi_table_add(opts, errp);
0a122b
+}
0a122b
+
0a122b
+unsigned acpi_table_len(void *current)
0a122b
+{
0a122b
+    struct acpi_table_header *hdr = current - sizeof(hdr->_length);
0a122b
+    return hdr->_length;
0a122b
+}
0a122b
+
0a122b
+static
0a122b
+void *acpi_table_hdr(void *h)
0a122b
+{
0a122b
+    struct acpi_table_header *hdr = h;
0a122b
+    return &hdr->sig;
0a122b
+}
0a122b
+
0a122b
+uint8_t *acpi_table_first(void)
0a122b
+{
0a122b
+    if (acpi_table_builtin || !acpi_tables) {
0a122b
+        return NULL;
0a122b
+    }
0a122b
+    return acpi_table_hdr(acpi_tables + ACPI_TABLE_PFX_SIZE);
0a122b
+}
0a122b
+
0a122b
+uint8_t *acpi_table_next(uint8_t *current)
0a122b
+{
0a122b
+    uint8_t *next = current + acpi_table_len(current);
0a122b
+
0a122b
+    if (next - acpi_tables >= acpi_tables_len) {
0a122b
+        return NULL;
0a122b
+    } else {
0a122b
+        return acpi_table_hdr(next);
0a122b
+    }
0a122b
+}
0a122b
+
0a122b
 static void acpi_notify_wakeup(Notifier *notifier, void *data)
0a122b
 {
0a122b
     ACPIREGS *ar = container_of(notifier, ACPIREGS, wakeup);
0a122b
diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h
0a122b
index 635be7b..bb7136d 100644
0a122b
--- a/include/hw/acpi/acpi.h
0a122b
+++ b/include/hw/acpi/acpi.h
0a122b
@@ -165,6 +165,10 @@ extern int acpi_enabled;
0a122b
 extern char unsigned *acpi_tables;
0a122b
 extern size_t acpi_tables_len;
0a122b
 
0a122b
+uint8_t *acpi_table_first(void);
0a122b
+uint8_t *acpi_table_next(uint8_t *current);
0a122b
+unsigned acpi_table_len(void *current);
0a122b
 void acpi_table_add(const QemuOpts *opts, Error **errp);
0a122b
+void acpi_table_add_builtin(const QemuOpts *opts, Error **errp);
0a122b
 
0a122b
 #endif /* !QEMU_HW_ACPI_H */
0a122b
-- 
0a122b
1.7.11.7
0a122b