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

[Xen-changelog] [xen master] acpi/hvmloader: allow acpi_build_tables() callers specify acpi_info values



commit c15eea2a1e719577af83bddf793a3a5329ce395d
Author:     Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
AuthorDate: Tue Aug 9 17:28:59 2016 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Aug 9 17:29:42 2016 +0200

    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>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 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(-)

diff --git a/tools/firmware/hvmloader/acpi/acpi2_0.h 
b/tools/firmware/hvmloader/acpi/acpi2_0.h
index 78eb43d..87a558a 100644
--- a/tools/firmware/hvmloader/acpi/acpi2_0.h
+++ b/tools/firmware/hvmloader/acpi/acpi2_0.h
@@ -451,15 +451,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 c3e8dc2..1908b91 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -16,6 +16,7 @@
  */
 
 #include "acpi2_0.h"
+#include "libacpi.h"
 #include "ssdt_s3.h"
 #include "ssdt_s4.h"
 #include "ssdt_tpm.h"
@@ -358,7 +359,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;
@@ -493,7 +494,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(const struct acpi_config *config)
 {
     struct acpi_info *acpi_info;
     struct acpi_20_rsdp *rsdp;
@@ -506,10 +507,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.
@@ -603,7 +613,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;
@@ -618,18 +628,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..b6b48be
--- /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(const 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 74fec56..e7d0785 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 9f66a79..2fbc3af 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"
 
 #define ROM_INCLUDE_SEABIOS
 #include "roms.inc"
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index 4accab6..35b84ea 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);
 }
 
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#master

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

 


Rackspace

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