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

[Xen-devel] [PATCH 4 of 4] hvmloader: reinstate datastructure shared with DSDT in SeaBIOS case



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1307027224 -3600
# Node ID 86fc2ee15d4593c16ba97a83614eeb58191162ec
# Parent  dc4a0e89997c81562f2779dfbae28a10c95c797f
hvmloader: reinstate datastructure shared with DSDT in SeaBIOS case.

I mistakenly thought that the "struct bios_info" was a ROMBIOS specific data
structure and so caused it to be populated only in the ROMBIOS case.

However it turns out that the majority of the struct's fields are actually
referenced from the ACPI DSDT and hence are needed for SeaBIOS too.

While in principal it might have been possible to continue to mix ROMBIOS and
ACPI bits in this datastructure this is, evidently, confusing but also leads to
header file dependencies from ROMBIOS->hvmloader which I had been hoping to
avoid so as to head-off future accidental re-entanglement of ROMBIOS and
hvmloader.

So instead I have split the ACPI parts into a new "struct acpi_info" which is
defined entirely within the acpi building code in hvmloader and which comes
with a big comment pointing to the DSDT interaction.

This new ACPI info is placed at 0x9F000 which is available under both ROMBIOS
and SeaBIOS. This address is in a reserved region of the E820 and is just above
the ROMBIOS stack.

The resulting "struct rombios_info" is hardly worthy of its own structure but
keep it anyway.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r dc4a0e89997c -r 86fc2ee15d45 tools/firmware/hvmloader/acpi/acpi2_0.h
--- a/tools/firmware/hvmloader/acpi/acpi2_0.h   Thu Jun 02 16:01:02 2011 +0100
+++ b/tools/firmware/hvmloader/acpi/acpi2_0.h   Thu Jun 02 16:07:04 2011 +0100
@@ -378,7 +378,6 @@ struct acpi_20_madt_intsrcovr {
 #pragma pack ()
 
 void acpi_build_tables(unsigned int physical);
-extern uint32_t madt_csum_addr, madt_lapic0_addr;
 
 #endif /* _ACPI_2_0_H_ */
 
diff -r dc4a0e89997c -r 86fc2ee15d45 tools/firmware/hvmloader/acpi/build.c
--- a/tools/firmware/hvmloader/acpi/build.c     Thu Jun 02 16:01:02 2011 +0100
+++ b/tools/firmware/hvmloader/acpi/build.c     Thu Jun 02 16:07:04 2011 +0100
@@ -25,9 +25,6 @@
 #define align16(sz)        (((sz) + 15) & ~15)
 #define fixed_strcpy(d, s) strncpy((d), (s), sizeof(d))
 
-/* MADT parameters for filling in bios_info structure for DSDT. */
-uint32_t madt_csum_addr, madt_lapic0_addr;
-
 extern struct acpi_20_rsdp Rsdp;
 extern struct acpi_20_rsdt Rsdt;
 extern struct acpi_20_xsdt Xsdt;
@@ -35,6 +32,21 @@ extern struct acpi_20_fadt Fadt;
 extern struct acpi_20_facs Facs;
 
 /*
+ * Located at ACPI_INFO_PHYSICAL_ADDRESS.
+ *
+ * This must match the Field("BIOS"....) definition in the DSDT.
+ */
+struct acpi_info {
+    uint8_t  com1_present:1;    /* 0[0] - System has COM1? */
+    uint8_t  com2_present:1;    /* 0[1] - System has COM2? */
+    uint8_t  lpt1_present:1;    /* 0[2] - System has LPT1? */
+    uint8_t  hpet_present:1;    /* 0[3] - System has HPET? */
+    uint32_t pci_min, pci_len;  /* 4, 8 - PCI I/O hole boundaries */
+    uint32_t madt_csum_addr;    /* 12   - Address of MADT checksum */
+    uint32_t madt_lapic0_addr;  /* 16   - Address of first MADT LAPIC struct */
+};
+
+/*
  * Alternative DSDTs we get linked against. A cover-all DSDT for up to the
  * implementation-defined maximum number of VCPUs, and an alternative for use
  * when a guest can only have up to 15 VCPUs.
@@ -68,7 +80,7 @@ static uint8_t battery_port_exists(void)
     return (inb(0x88) == 0x1F);
 }
 
-static struct acpi_20_madt *construct_madt(void)
+static struct acpi_20_madt *construct_madt(struct acpi_info *info)
 {
     struct acpi_20_madt           *madt;
     struct acpi_20_madt_intsrcovr *intsrcovr;
@@ -132,7 +144,7 @@ static struct acpi_20_madt *construct_ma
     io_apic->ioapic_addr = IOAPIC_BASE_ADDRESS;
 
     lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
-    madt_lapic0_addr = (uint32_t)lapic;
+    info->madt_lapic0_addr = (uint32_t)lapic;
     for ( i = 0; i < nr_processor_objects; i++ )
     {
         memset(lapic, 0, sizeof(*lapic));
@@ -150,7 +162,7 @@ static struct acpi_20_madt *construct_ma
     madt->header.length = (unsigned char *)lapic - (unsigned char *)madt;
     set_checksum(madt, offsetof(struct acpi_header, checksum),
                  madt->header.length);
-    madt_csum_addr = (uint32_t)&madt->header.checksum;
+    info->madt_csum_addr = (uint32_t)&madt->header.checksum;
 
     return madt;
 }
@@ -179,7 +191,8 @@ static struct acpi_20_hpet *construct_hp
     return hpet;
 }
 
-static int construct_secondary_tables(unsigned long *table_ptrs)
+static int construct_secondary_tables(unsigned long *table_ptrs,
+                                      struct acpi_info *info)
 {
     int nr_tables = 0;
     struct acpi_20_madt *madt;
@@ -193,7 +206,7 @@ static int construct_secondary_tables(un
     /* MADT. */
     if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
     {
-        madt = construct_madt();
+        madt = construct_madt(info);
         if (!madt) return -1;
         table_ptrs[nr_tables++] = (unsigned long)madt;
     }
@@ -253,6 +266,7 @@ static int construct_secondary_tables(un
 
 void acpi_build_tables(unsigned int physical)
 {
+    struct acpi_info *acpi_info = (struct acpi_info 
*)ACPI_INFO_PHYSICAL_ADDRESS;
     struct acpi_20_rsdp *rsdp;
     struct acpi_20_rsdt *rsdt;
     struct acpi_20_xsdt *xsdt;
@@ -316,7 +330,7 @@ void acpi_build_tables(unsigned int phys
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
 
-    nr_secondaries = construct_secondary_tables(secondary_tables);
+    nr_secondaries = construct_secondary_tables(secondary_tables, acpi_info);
     if ( nr_secondaries < 0 )
         goto oom;
 
@@ -347,7 +361,7 @@ void acpi_build_tables(unsigned int phys
                  rsdt->header.length);
 
     /*
-     * Fill in low-memory data structures: bios_info_table and RSDP.
+     * Fill in low-memory data structures: acpi_info and RSDP.
      */
     rsdp = (struct acpi_20_rsdp *)physical;
 
@@ -361,6 +375,14 @@ void acpi_build_tables(unsigned int phys
                  offsetof(struct acpi_20_rsdp, extended_checksum),
                  sizeof(struct acpi_20_rsdp));
 
+    memset(acpi_info, 0, sizeof(*acpi_info));
+    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;
+
     return;
 
 oom:
diff -r dc4a0e89997c -r 86fc2ee15d45 tools/firmware/hvmloader/acpi/dsdt.asl
--- a/tools/firmware/hvmloader/acpi/dsdt.asl    Thu Jun 02 16:01:02 2011 +0100
+++ b/tools/firmware/hvmloader/acpi/dsdt.asl    Thu Jun 02 16:07:04 2011 +0100
@@ -61,8 +61,8 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
 
     Scope (\_SB)
     {
-       /* BIOS_INFO_PHYSICAL_ADDRESS == 0xEA000 */
-       OperationRegion(BIOS, SystemMemory, 0xEA000, 24)
+       /* ACPI_INFO_PHYSICAL_ADDRESS == 0x9F000 */
+       OperationRegion(BIOS, SystemMemory, 0x9F000, 24)
        Field(BIOS, ByteAcc, NoLock, Preserve) {
            UAR1, 1,
            UAR2, 1,
diff -r dc4a0e89997c -r 86fc2ee15d45 tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Thu Jun 02 16:01:02 2011 +0100
+++ b/tools/firmware/hvmloader/config.h Thu Jun 02 16:07:04 2011 +0100
@@ -62,6 +62,7 @@ extern unsigned long pci_mem_start, pci_
 /* Memory map. */
 #define SCRATCH_PHYSICAL_ADDRESS      0x00010000
 #define HYPERCALL_PHYSICAL_ADDRESS    0x00080000
+#define ACPI_INFO_PHYSICAL_ADDRESS    0x0009F000
 #define VGABIOS_PHYSICAL_ADDRESS      0x000C0000
 #define HVMLOADER_PHYSICAL_ADDRESS    0x00100000
 
diff -r dc4a0e89997c -r 86fc2ee15d45 tools/firmware/hvmloader/rombios.c
--- a/tools/firmware/hvmloader/rombios.c        Thu Jun 02 16:01:02 2011 +0100
+++ b/tools/firmware/hvmloader/rombios.c        Thu Jun 02 16:07:04 2011 +0100
@@ -67,36 +67,21 @@ static void rombios_setup_e820(void)
 
 static void rombios_setup_bios_info(void)
 {
-    struct bios_info *bios_info;
+    struct rombios_info *info;
 
-    bios_info = (struct bios_info *)BIOS_INFO_PHYSICAL_ADDRESS;
-    memset(bios_info, 0, sizeof(*bios_info));
-    bios_info->com1_present = uart_exists(0x3f8);
-    bios_info->com2_present = uart_exists(0x2f8);
-    bios_info->lpt1_present = lpt_exists(0x378);
-    bios_info->hpet_present = hpet_exists(ACPI_HPET_ADDRESS);
-    bios_info->madt_csum_addr = madt_csum_addr;
-    bios_info->madt_lapic0_addr = madt_lapic0_addr;
+    info = (struct rombios_info *)BIOS_INFO_PHYSICAL_ADDRESS;
+    memset(info, 0, sizeof(*info));
 }
 
 static void rombios_relocate(void)
 {
     uint32_t bioshigh;
-    struct bios_info *bios_info;
+    struct rombios_info *info;
 
     bioshigh = rombios_highbios_setup();
 
-    bios_info = (struct bios_info *)BIOS_INFO_PHYSICAL_ADDRESS;
-    bios_info->bios32_entry = bioshigh;
-}
-
-static void rombios_finish_bios_info(void)
-{
-    struct bios_info *bios_info;
-
-    bios_info = (struct bios_info *)BIOS_INFO_PHYSICAL_ADDRESS;
-    bios_info->pci_min = pci_mem_start;
-    bios_info->pci_len = pci_mem_end - pci_mem_start;
+    info = (struct rombios_info *)BIOS_INFO_PHYSICAL_ADDRESS;
+    info->bios32_entry = bioshigh;
 }
 
 /*
@@ -177,7 +162,7 @@ struct bios_config rombios_config =  {
     .optionrom_end = OPTIONROM_PHYSICAL_END,
 
     .bios_info_setup = rombios_setup_bios_info,
-    .bios_info_finish = rombios_finish_bios_info,
+    .bios_info_finish = NULL,
 
     .bios_relocate = rombios_relocate,
 
diff -r dc4a0e89997c -r 86fc2ee15d45 tools/firmware/rombios/config.h
--- a/tools/firmware/rombios/config.h   Thu Jun 02 16:01:02 2011 +0100
+++ b/tools/firmware/rombios/config.h   Thu Jun 02 16:07:04 2011 +0100
@@ -27,17 +27,10 @@
 #define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */
 
 /* Located at BIOS_INFO_PHYSICAL_ADDRESS. */
-struct bios_info {
-    uint8_t  com1_present:1;    /* 0[0] - System has COM1? */
-    uint8_t  com2_present:1;    /* 0[1] - System has COM2? */
-    uint8_t  lpt1_present:1;    /* 0[2] - System has LPT1? */
-    uint8_t  hpet_present:1;    /* 0[3] - System has HPET? */
-    uint32_t pci_min, pci_len;  /* 4, 8 - PCI I/O hole boundaries */
-    uint32_t madt_csum_addr;    /* 12   - Address of MADT checksum */
-    uint32_t madt_lapic0_addr;  /* 16   - Address of first MADT LAPIC struct */
-    uint32_t bios32_entry;      /* 20   - Entry point for 32-bit BIOS */
+struct rombios_info {
+    uint32_t bios32_entry;      /* 0   - Entry point for 32-bit BIOS */
 };
-#define BIOSINFO_OFF_bios32_entry 20
+#define BIOSINFO_OFF_bios32_entry 0
 
 #endif
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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