hvmloader: decide which SSDTs to install in hvmloader
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>
Tue, 9 Aug 2016 15:30:56 +0000 (17:30 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 9 Aug 2016 15:30:56 +0000 (17:30 +0200)
With that, xenstore_read() won't need to be done in ACPI code

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
tools/firmware/hvmloader/acpi/build.c
tools/firmware/hvmloader/acpi/libacpi.h
tools/firmware/hvmloader/util.c

index daa92485b131e08608645234bb6206efbb30f222..e5a63bc1819f3487b331098ab8929925fd168097 100644 (file)
@@ -72,11 +72,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;
@@ -338,6 +333,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;
@@ -371,7 +367,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;
@@ -379,7 +375,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;
@@ -389,7 +385,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;
@@ -574,7 +570,8 @@ void acpi_build_tables(const 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;
 
index 05ee6f9fa98f67a875b7689afd545cb4af278111..c2da152d8efe3328782d2f35b1a1bb447258e2b4 100644 (file)
 #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;
index 0bfb37224d3a616365a107bb86d6cc7d9eeeac5f..f01a3fde3ba9b0d06a8bb93fe6ed8d1fa06887da 100644 (file)
@@ -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;