hvmloader: reinstate datastructure shared with DSDT in SeaBIOS case.
authorIan Campbell <ian.campbell@citrix.com>
Fri, 3 Jun 2011 16:22:51 +0000 (17:22 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 3 Jun 2011 16:22:51 +0000 (17:22 +0100)
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@citrix.com>
tools/firmware/hvmloader/acpi/acpi2_0.h
tools/firmware/hvmloader/acpi/build.c
tools/firmware/hvmloader/acpi/dsdt.asl
tools/firmware/hvmloader/config.h
tools/firmware/hvmloader/rombios.c
tools/firmware/rombios/config.h

index 19f3cc339df4e4c3782e72431d4911e1afe6c2a4..324cd43e38ddb06d98c7328c8b1ee276e0b35895 100644 (file)
@@ -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_ */
 
index a9c1e52785693e4cb3015e63f8f9a96128d06d88..5e3198420bf7ed92525977ee4d626c01658570f3 100644 (file)
 #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;
 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
@@ -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_madt(void)
     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_madt(void)
     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_hpet(void)
     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(unsigned long *table_ptrs)
     /* 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(unsigned long *table_ptrs)
 
 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 physical)
                  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 physical)
                  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 physical)
                  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:
index ea8e324ddb63f8f298d74fad3f5ccdacf6c8335d..1bcee861515dfe0006b1b2c980fefd5f392e3755 100644 (file)
@@ -61,8 +61,8 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
 
     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,
index 6b3d35a9872b371f6b4c5259f64ab0ebc3fbad5e..d916442ce360f70a1fd92af59796d8e18467ff23 100644 (file)
@@ -62,6 +62,7 @@ extern unsigned long pci_mem_start, pci_mem_end;
 /* 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
 
index 1ebe995af9c0fa500faa56f1a070c0cce1d11e2e..137167386d64a05d529c252bbad104456e662f36 100644 (file)
@@ -67,36 +67,21 @@ static void rombios_setup_e820(void)
 
 static void rombios_setup_bios_info(void)
 {
-    struct bios_info *bios_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;
+    struct rombios_info *info;
+
+    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,
 
index cac815172e45417255a14bb9cdc7564eb51657bc..da3cbad9a54154ba058f495ef43bd934e7d0faea 100644 (file)
 #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