[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 04/23] acpi/hvmloader: Decide which SSDTs to install in hvmloader



With that, xenstore_read() won't need to be done in ACPI code

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 tools/firmware/hvmloader/acpi/build.c   | 15 ++++++---------
 tools/firmware/hvmloader/acpi/libacpi.h |  4 ++++
 tools/firmware/hvmloader/util.c         | 12 ++++++++++++
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/tools/firmware/hvmloader/acpi/build.c 
b/tools/firmware/hvmloader/acpi/build.c
index df104a3..a5750eb 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -70,11 +70,6 @@ static void set_checksum(
     p[checksum_offset] = -sum;
 }
 
-static uint8_t battery_port_exists(void)
-{
-    return (inb(0x88) == 0x1F);
-}
-
 static struct acpi_20_madt *construct_madt(struct acpi_info *info)
 {
     struct acpi_20_madt           *madt;
@@ -336,6 +331,7 @@ static int construct_passthrough_tables(unsigned long 
*table_ptrs,
 }
 
 static int construct_secondary_tables(unsigned long *table_ptrs,
+                                      struct acpi_config *config,
                                       struct acpi_info *info)
 {
     int nr_tables = 0;
@@ -369,7 +365,7 @@ static int construct_secondary_tables(unsigned long 
*table_ptrs,
     if (!waet) return -1;
     table_ptrs[nr_tables++] = (unsigned long)waet;
 
-    if ( battery_port_exists() )
+    if ( config->table_flags & ACPI_HAS_SSDT_PM )
     {
         ssdt = mem_alloc(sizeof(ssdt_pm), 16);
         if (!ssdt) return -1;
@@ -377,7 +373,7 @@ static int construct_secondary_tables(unsigned long 
*table_ptrs,
         table_ptrs[nr_tables++] = (unsigned long)ssdt;
     }
 
-    if ( !strncmp(xenstore_read("platform/acpi_s3", "1"), "1", 1) )
+    if ( config->table_flags & ACPI_HAS_SSDT_S3 )
     {
         ssdt = mem_alloc(sizeof(ssdt_s3), 16);
         if (!ssdt) return -1;
@@ -387,7 +383,7 @@ static int construct_secondary_tables(unsigned long 
*table_ptrs,
         printf("S3 disabled\n");
     }
 
-    if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1) )
+    if ( config->table_flags & ACPI_HAS_SSDT_S4 )
     {
         ssdt = mem_alloc(sizeof(ssdt_s4), 16);
         if (!ssdt) return -1;
@@ -572,7 +568,8 @@ void acpi_build_tables(struct acpi_config *config)
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
 
-    nr_secondaries = construct_secondary_tables(secondary_tables, acpi_info);
+    nr_secondaries = construct_secondary_tables(secondary_tables,
+                 config, acpi_info);
     if ( nr_secondaries < 0 )
         goto oom;
 
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h 
b/tools/firmware/hvmloader/acpi/libacpi.h
index 4cbd41e..f397a93 100644
--- a/tools/firmware/hvmloader/acpi/libacpi.h
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -24,6 +24,10 @@
 #define ACPI_HAS_COM2        (1<<1)
 #define ACPI_HAS_LPT1        (1<<2)
 #define ACPI_HAS_HPET        (1<<3)
+#define ACPI_HAS_SSDT_PM     (1<<4)
+#define ACPI_HAS_SSDT_S3     (1<<5)
+#define ACPI_HAS_SSDT_S4     (1<<6)
+
 
 struct acpi_config {
     const unsigned char *dsdt_anycpu;
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index e8ce12b..61fc211 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -859,6 +859,11 @@ int hpet_exists(unsigned long hpet_base)
     return ((hpet_id >> 16) == 0x8086);
 }
 
+static uint8_t battery_port_exists(void)
+{
+    return (inb(0x88) == 0x1F);
+}
+
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical)
 {
@@ -895,6 +900,13 @@ void hvmloader_acpi_build_tables(struct acpi_config 
*config,
             config->vm_gid[1] = strtoll(end+1, NULL, 0);
     }
 
+    if ( battery_port_exists() )
+        config->table_flags |= ACPI_HAS_SSDT_PM;
+    if ( !strncmp(xenstore_read("platform/acpi_s3", "1"), "1", 1)  )
+        config->table_flags |= ACPI_HAS_SSDT_S3;
+    if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
+        config->table_flags |= ACPI_HAS_SSDT_S4;
+
     config->rsdp = physical;
     config->infop = ACPI_INFO_PHYSICAL_ADDRESS;
 
-- 
1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.