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

[Xen-devel] [PATCH v2 02/23] acpi/hvmloader: Allow acpi_build_tables() callers specify acpi_info values



By doing this we can move hvmloader-private interfaces (such as
uart_exists(), lpt_exists() etc.) out of the ACPI builder. This will
help us with allowing to call the builder from places other than
hvmloader.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
---
v2:
* Keep struct acpi_info private to build.c and instead pass information
  necessary to set its fields via acpi_config's flags.

 tools/firmware/hvmloader/acpi/acpi2_0.h |  9 -----
 tools/firmware/hvmloader/acpi/build.c   | 34 +++++++++---------
 tools/firmware/hvmloader/acpi/libacpi.h | 63 +++++++++++++++++++++++++++++++++
 tools/firmware/hvmloader/ovmf.c         |  2 +-
 tools/firmware/hvmloader/seabios.c      |  1 +
 tools/firmware/hvmloader/util.c         | 26 +++++++++++++-
 6 files changed, 106 insertions(+), 29 deletions(-)
 create mode 100644 tools/firmware/hvmloader/acpi/libacpi.h

diff --git a/tools/firmware/hvmloader/acpi/acpi2_0.h 
b/tools/firmware/hvmloader/acpi/acpi2_0.h
index 6fa3452..775eb7a 100644
--- a/tools/firmware/hvmloader/acpi/acpi2_0.h
+++ b/tools/firmware/hvmloader/acpi/acpi2_0.h
@@ -448,15 +448,6 @@ struct acpi_20_slit {
 
 #pragma pack ()
 
-struct acpi_config {
-    unsigned char *dsdt_anycpu;
-    int dsdt_anycpu_len;
-    unsigned char *dsdt_15cpu;
-    int dsdt_15cpu_len;
-};
-
-void acpi_build_tables(struct acpi_config *config, unsigned int physical);
-
 #endif /* _ACPI_2_0_H_ */
 
 /*
diff --git a/tools/firmware/hvmloader/acpi/build.c 
b/tools/firmware/hvmloader/acpi/build.c
index 8be9b90..f251c05 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -14,6 +14,7 @@
  */
 
 #include "acpi2_0.h"
+#include "libacpi.h"
 #include "ssdt_s3.h"
 #include "ssdt_s4.h"
 #include "ssdt_tpm.h"
@@ -356,7 +357,7 @@ static int construct_secondary_tables(unsigned long 
*table_ptrs,
     }
 
     /* HPET. */
-    if ( hpet_exists(ACPI_HPET_ADDRESS) )
+    if ( info->hpet_present )
     {
         hpet = construct_hpet();
         if (!hpet) return -1;
@@ -491,7 +492,7 @@ static int new_vm_gid(struct acpi_info *acpi_info)
     return 1;
 }
 
-void acpi_build_tables(struct acpi_config *config, unsigned int physical)
+void acpi_build_tables(struct acpi_config *config)
 {
     struct acpi_info *acpi_info;
     struct acpi_20_rsdp *rsdp;
@@ -504,10 +505,19 @@ void acpi_build_tables(struct acpi_config *config, 
unsigned int physical)
     unsigned long        secondary_tables[ACPI_MAX_SECONDARY_TABLES];
     int                  nr_secondaries, i;
 
-    /* Allocate and initialise the acpi info area. */
-    mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1);
-    acpi_info = (struct acpi_info *)ACPI_INFO_PHYSICAL_ADDRESS;
+    acpi_info = (struct acpi_info *)config->infop;
     memset(acpi_info, 0, sizeof(*acpi_info));
+    acpi_info->com1_present = !!(config->table_flags & ACPI_HAS_COM1);
+    acpi_info->com2_present = !!(config->table_flags & ACPI_HAS_COM2);
+    acpi_info->lpt1_present = !!(config->table_flags & ACPI_HAS_LPT1);
+    acpi_info->hpet_present = !!(config->table_flags & ACPI_HAS_HPET);
+    acpi_info->pci_min = config->pci_start;
+    acpi_info->pci_len = config->pci_len;
+    if ( config->pci_hi_len )
+    {
+        acpi_info->pci_hi_min = config->pci_hi_start;
+        acpi_info->pci_hi_len = config->pci_hi_len;
+    }
 
     /*
      * Fill in high-memory data structures, starting at @buf.
@@ -601,7 +611,7 @@ void acpi_build_tables(struct acpi_config *config, unsigned 
int physical)
     /*
      * Fill in low-memory data structures: acpi_info and RSDP.
      */
-    rsdp = (struct acpi_20_rsdp *)physical;
+    rsdp = (struct acpi_20_rsdp *)config->rsdp;
 
     memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp));
     rsdp->rsdt_address = (unsigned long)rsdt;
@@ -616,18 +626,6 @@ void acpi_build_tables(struct acpi_config *config, 
unsigned int physical)
     if ( !new_vm_gid(acpi_info) )
         goto oom;
 
-    acpi_info->com1_present = uart_exists(0x3f8);
-    acpi_info->com2_present = uart_exists(0x2f8);
-    acpi_info->lpt1_present = lpt_exists(0x378);
-    acpi_info->hpet_present = hpet_exists(ACPI_HPET_ADDRESS);
-    acpi_info->pci_min = pci_mem_start;
-    acpi_info->pci_len = pci_mem_end - pci_mem_start;
-    if ( pci_hi_mem_end > pci_hi_mem_start )
-    {
-        acpi_info->pci_hi_min = pci_hi_mem_start;
-        acpi_info->pci_hi_len = pci_hi_mem_end - pci_hi_mem_start;
-    }
-
     return;
 
 oom:
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h 
b/tools/firmware/hvmloader/acpi/libacpi.h
new file mode 100644
index 0000000..5e0f400
--- /dev/null
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * libacpi.h
+ * 
+ * libacpi interfaces
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ */
+
+
+#ifndef __LIBACPI_H__
+#define __LIBACPI_H__
+
+#define ACPI_HAS_COM1        (1<<0)
+#define ACPI_HAS_COM2        (1<<1)
+#define ACPI_HAS_LPT1        (1<<2)
+#define ACPI_HAS_HPET        (1<<3)
+
+struct acpi_config {
+    const unsigned char *dsdt_anycpu;
+    unsigned int dsdt_anycpu_len;
+    const unsigned char *dsdt_15cpu;
+    unsigned int dsdt_15cpu_len;
+
+    /* PCI I/O hole */
+    uint32_t pci_start, pci_len;
+    uint64_t pci_hi_start, pci_hi_len;
+
+    uint32_t table_flags;
+
+    /*
+     * Address where acpi_info should be placed.
+     * This must match the OperationRegion(BIOS, SystemMemory, ....)
+     * definition in the DSDT
+     */
+    unsigned int infop;
+
+    /* RSDP address */
+    unsigned int rsdp;
+};
+
+void acpi_build_tables(struct acpi_config *config);
+
+#endif /* __LIBACPI_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/tools/firmware/hvmloader/ovmf.c b/tools/firmware/hvmloader/ovmf.c
index 1c8a71b..b4bcc93 100644
--- a/tools/firmware/hvmloader/ovmf.c
+++ b/tools/firmware/hvmloader/ovmf.c
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "smbios_types.h"
-#include "acpi/acpi2_0.h"
+#include "acpi/libacpi.h"
 #include "apic_regs.h"
 #include "../rombios/config.h"
 #include "util.h"
diff --git a/tools/firmware/hvmloader/seabios.c 
b/tools/firmware/hvmloader/seabios.c
index 3d046fd..5c9a351 100644
--- a/tools/firmware/hvmloader/seabios.c
+++ b/tools/firmware/hvmloader/seabios.c
@@ -26,6 +26,7 @@
 
 #include "smbios_types.h"
 #include "acpi/acpi2_0.h"
+#include "acpi/libacpi.h"
 
 extern unsigned char dsdt_anycpu_qemu_xen[];
 extern int dsdt_anycpu_qemu_xen_len;
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index 9af29b1..7de2fb6 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -22,6 +22,7 @@
 #include "hypercall.h"
 #include "ctype.h"
 #include "acpi/acpi2_0.h"
+#include "acpi/libacpi.h"
 #include <stdint.h>
 #include <xen/xen.h>
 #include <xen/memory.h>
@@ -860,7 +861,30 @@ int hpet_exists(unsigned long hpet_base)
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical)
 {
-    acpi_build_tables(config, physical);
+    /* Allocate and initialise the acpi info area. */
+    mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1);
+
+    if ( uart_exists(0x3f8)  )
+        config->table_flags |= ACPI_HAS_COM1;
+    if (  uart_exists(0x2f8) )
+        config->table_flags |= ACPI_HAS_COM2;
+    if ( lpt_exists(0x378) )
+        config->table_flags |= ACPI_HAS_LPT1;
+    if (  hpet_exists(ACPI_HPET_ADDRESS) )
+        config->table_flags |= ACPI_HAS_HPET;
+
+    config->pci_start = pci_mem_start;
+    config->pci_len = pci_mem_end - pci_mem_start;
+    if ( pci_hi_mem_end > pci_hi_mem_start )
+    {
+        config->pci_hi_start = pci_hi_mem_start;
+        config->pci_hi_len = pci_hi_mem_end - pci_hi_mem_start;
+    }
+
+    config->rsdp = physical;
+    config->infop = ACPI_INFO_PHYSICAL_ADDRESS;
+
+    acpi_build_tables(config);
 }
 
 /*
-- 
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®.