All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0 of 4] hvmloader: ACPI clean/fix-ups
@ 2011-06-02 15:07 Ian Campbell
  2011-06-02 15:07 ` [PATCH 1 of 4] hvmloader: reduce minimum allocation alignment from 1024 bytes to 16 Ian Campbell
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ian Campbell @ 2011-06-02 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

The following cleans up the allocation of ACPI tables a bit and
reinstates the shared data-structure between hvmloader and the DSDT in
the SeaBIOS case.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1 of 4] hvmloader: reduce minimum allocation alignment from 1024 bytes to 16
  2011-06-02 15:07 [PATCH 0 of 4] hvmloader: ACPI clean/fix-ups Ian Campbell
@ 2011-06-02 15:07 ` Ian Campbell
  2011-06-02 15:07 ` [PATCH 2 of 4] hvmloader: allocate ACPI tables as we go Ian Campbell
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ian Campbell @ 2011-06-02 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1307026837 -3600
# Node ID 1f07d98d624ec828bd6483425adf204521175833
# Parent  f7493e7dd9daa6b25bade1f027702d2e61c326bb
hvmloader: reduce minimum allocation alignment from 1024 bytes to 16.

1024 bytes create a lot of wastage when the majority of allocations are of BIOS
table data structures which are generally happy with much lower alignment. I
conservatively chose 16 bytes.

Most callers pass 0 for the alignment anyway, for the rombios high code
allocation I kept it 1024 byte aligned since it was the only case that didn't
seem obviously ok with a smaller alignment.

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

diff -r f7493e7dd9da -r 1f07d98d624e tools/firmware/hvmloader/32bitbios_support.c
--- a/tools/firmware/hvmloader/32bitbios_support.c	Thu Jun 02 15:09:24 2011 +0100
+++ b/tools/firmware/hvmloader/32bitbios_support.c	Thu Jun 02 16:00:37 2011 +0100
@@ -67,7 +67,7 @@ static uint32_t relocate_32bitbios(char 
      */
     reloc_size = reloc_off;
     printf("%d bytes of ROMBIOS high-memory extensions:\n", reloc_size);
-    highbiosarea = mem_alloc(reloc_size, 0);
+    highbiosarea = mem_alloc(reloc_size, 1024);
     BUG_ON(highbiosarea == NULL);
     printf("  Relocating to 0x%x-0x%x ... ",
            (uint32_t)&highbiosarea[0],
diff -r f7493e7dd9da -r 1f07d98d624e tools/firmware/hvmloader/util.c
--- a/tools/firmware/hvmloader/util.c	Thu Jun 02 15:09:24 2011 +0100
+++ b/tools/firmware/hvmloader/util.c	Thu Jun 02 16:00:37 2011 +0100
@@ -312,9 +312,9 @@ void *mem_alloc(uint32_t size, uint32_t 
     xen_pfn_t mfn;
     uint32_t s, e;
 
-    /* Align to at least one kilobyte. */
-    if ( align < 1024 )
-        align = 1024;
+    /* Align to at least 16 bytes. */
+    if ( align < 16 )
+        align = 16;
 
     s = (reserve + align) & ~(align - 1);
     e = s + size - 1;
@@ -366,9 +366,9 @@ void *scratch_alloc(uint32_t size, uint3
 {
     uint32_t s, e;
 
-    /* Align to at least one kilobyte. */
-    if ( align < 1024 )
-        align = 1024;
+    /* Align to at least 16 bytes. */
+    if ( align < 16 )
+        align = 16;
 
     s = (scratch_start + align - 1) & ~(align - 1);
     e = s + size - 1;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2 of 4] hvmloader: allocate ACPI tables as we go
  2011-06-02 15:07 [PATCH 0 of 4] hvmloader: ACPI clean/fix-ups Ian Campbell
  2011-06-02 15:07 ` [PATCH 1 of 4] hvmloader: reduce minimum allocation alignment from 1024 bytes to 16 Ian Campbell
@ 2011-06-02 15:07 ` Ian Campbell
  2011-06-02 15:07 ` [PATCH 3 of 4] hvmloader: removed unused/incorrect define Ian Campbell
  2011-06-02 15:07 ` [PATCH 4 of 4] hvmloader: reinstate datastructure shared with DSDT in SeaBIOS case Ian Campbell
  3 siblings, 0 replies; 5+ messages in thread
From: Ian Campbell @ 2011-06-02 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1307026861 -3600
# Node ID 34a70784084d146ea4ddc5d4a63eade67a6045f6
# Parent  1f07d98d624ec828bd6483425adf204521175833
hvmloader: allocate ACPI tables as we go

Rather than building the tables twice, once purely to figure out the size, just
allocate each individual table as we go.

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

diff -r 1f07d98d624e -r 34a70784084d tools/firmware/hvmloader/acpi/build.c
--- a/tools/firmware/hvmloader/acpi/build.c	Thu Jun 02 16:00:37 2011 +0100
+++ b/tools/firmware/hvmloader/acpi/build.c	Thu Jun 02 16:01:01 2011 +0100
@@ -68,12 +68,21 @@ static uint8_t battery_port_exists(void)
     return (inb(0x88) == 0x1F);
 }
 
-static int construct_madt(struct acpi_20_madt *madt)
+static struct acpi_20_madt *construct_madt(void)
 {
+    struct acpi_20_madt           *madt;
     struct acpi_20_madt_intsrcovr *intsrcovr;
     struct acpi_20_madt_ioapic    *io_apic;
     struct acpi_20_madt_lapic     *lapic;
-    int i, offset = 0;
+    int i, sz;
+
+    sz  = sizeof(struct acpi_20_madt);
+    sz += sizeof(struct acpi_20_madt_intsrcovr) * 16;
+    sz += sizeof(struct acpi_20_madt_ioapic);
+    sz += sizeof(struct acpi_20_madt_lapic) * nr_processor_objects;
+
+    madt = mem_alloc(sz, 16);
+    if (!madt) return NULL;
 
     memset(madt, 0, sizeof(*madt));
     madt->header.signature    = ACPI_2_0_MADT_SIGNATURE;
@@ -85,7 +94,6 @@ static int construct_madt(struct acpi_20
     madt->header.creator_revision = ACPI_CREATOR_REVISION;
     madt->lapic_addr = LAPIC_BASE_ADDRESS;
     madt->flags      = ACPI_PCAT_COMPAT;
-    offset += sizeof(*madt);
 
     intsrcovr = (struct acpi_20_madt_intsrcovr *)(madt + 1);
     for ( i = 0; i < 16; i++ )
@@ -113,7 +121,6 @@ static int construct_madt(struct acpi_20
             continue;
         }
 
-        offset += sizeof(*intsrcovr);
         intsrcovr++;
     }
 
@@ -123,7 +130,6 @@ static int construct_madt(struct acpi_20
     io_apic->length      = sizeof(*io_apic);
     io_apic->ioapic_id   = IOAPIC_ID;
     io_apic->ioapic_addr = IOAPIC_BASE_ADDRESS;
-    offset += sizeof(*io_apic);
 
     lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
     madt_lapic0_addr = (uint32_t)lapic;
@@ -138,20 +144,23 @@ static int construct_madt(struct acpi_20
         lapic->flags = ((i < hvm_info->nr_vcpus) &&
                         test_bit(i, hvm_info->vcpu_online)
                         ? ACPI_LOCAL_APIC_ENABLED : 0);
-        offset += sizeof(*lapic);
         lapic++;
     }
 
-    madt->header.length = offset;
-    set_checksum(madt, offsetof(struct acpi_header, checksum), offset);
+    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;
 
-    return align16(offset);
+    return madt;
 }
 
-static int construct_hpet(struct acpi_20_hpet *hpet)
+static struct acpi_20_hpet *construct_hpet(void)
 {
-    int offset;
+    struct acpi_20_hpet *hpet;
+
+    hpet = mem_alloc(sizeof(*hpet), 16);
+    if (!hpet) return NULL;
 
     memset(hpet, 0, sizeof(*hpet));
     hpet->header.signature    = ACPI_2_0_HPET_SIGNATURE;
@@ -163,20 +172,20 @@ static int construct_hpet(struct acpi_20
     hpet->header.creator_revision = ACPI_CREATOR_REVISION;
     hpet->timer_block_id      = 0x8086a201;
     hpet->addr.address        = ACPI_HPET_ADDRESS;
-    offset = sizeof(*hpet);
 
-    hpet->header.length = offset;
-    set_checksum(hpet, offsetof(struct acpi_header, checksum), offset);
-
-    return offset;
+    hpet->header.length = sizeof(*hpet);
+    set_checksum(hpet, offsetof(struct acpi_header, checksum),
+                 hpet->header.length = sizeof(*hpet));
+    return hpet;
 }
 
-static int construct_secondary_tables(uint8_t *buf, unsigned long *table_ptrs)
+static int construct_secondary_tables(unsigned long *table_ptrs)
 {
-    int offset = 0, nr_tables = 0;
+    int nr_tables = 0;
     struct acpi_20_madt *madt;
     struct acpi_20_hpet *hpet;
     struct acpi_20_tcpa *tcpa;
+    unsigned char *ssdt;
     static const uint16_t tis_signature[] = {0x0001, 0x0001, 0x0001};
     uint16_t *tis_hdr;
     void *lasa;
@@ -184,22 +193,23 @@ static int construct_secondary_tables(ui
     /* MADT. */
     if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
     {
-        madt = (struct acpi_20_madt *)&buf[offset];
-        offset += construct_madt(madt);
+        madt = construct_madt();
+        if (!madt) return -1;
         table_ptrs[nr_tables++] = (unsigned long)madt;
     }
 
     /* HPET. Always included in DSDT, so always include it here too. */
     /* (And it's unconditionally required by Windows SVVP tests.) */
-    hpet = (struct acpi_20_hpet *)&buf[offset];
-    offset += construct_hpet(hpet);
+    hpet = construct_hpet();
+    if (!hpet) return -1;
     table_ptrs[nr_tables++] = (unsigned long)hpet;
 
-    if ( battery_port_exists() ) 
+    if ( battery_port_exists() )
     {
-        table_ptrs[nr_tables++] = (unsigned long)&buf[offset];
-        memcpy(&buf[offset], ssdt_pm, sizeof(ssdt_pm));
-        offset += align16(sizeof(ssdt_pm));
+        ssdt = mem_alloc(sizeof(ssdt_pm), 16);
+        if (!ssdt) return -1;
+        memcpy(ssdt, ssdt_pm, sizeof(ssdt_pm));
+        table_ptrs[nr_tables++] = (unsigned long)ssdt;
     }
 
     /* TPM TCPA and SSDT. */
@@ -208,13 +218,14 @@ static int construct_secondary_tables(ui
          (tis_hdr[1] == tis_signature[1]) &&
          (tis_hdr[2] == tis_signature[2]) )
     {
-        memcpy(&buf[offset], ssdt_tpm, sizeof(ssdt_tpm));
-        table_ptrs[nr_tables++] = (unsigned long)&buf[offset];
-        offset += align16(sizeof(ssdt_tpm));
+        ssdt = mem_alloc(sizeof(ssdt_tpm), 16);
+        if (!ssdt) return -1;
+        memcpy(ssdt, ssdt_tpm, sizeof(ssdt_tpm));
+        table_ptrs[nr_tables++] = (unsigned long)ssdt;
 
-        tcpa = (struct acpi_20_tcpa *)&buf[offset];
+        tcpa = mem_alloc(sizeof(struct acpi_20_tcpa), 16);
+        if (!tcpa) return -1;
         memset(tcpa, 0, sizeof(*tcpa));
-        offset += align16(sizeof(*tcpa));
         table_ptrs[nr_tables++] = (unsigned long)tcpa;
 
         tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE;
@@ -225,7 +236,7 @@ static int construct_secondary_tables(ui
         tcpa->header.oem_revision = ACPI_OEM_REVISION;
         tcpa->header.creator_id   = ACPI_CREATOR_ID;
         tcpa->header.creator_revision = ACPI_CREATOR_REVISION;
-        if ( (lasa = mem_alloc(ACPI_2_0_TCPA_LAML_SIZE, 0)) != NULL )
+        if ( (lasa = mem_alloc(ACPI_2_0_TCPA_LAML_SIZE, 16)) != NULL )
         {
             tcpa->lasa = virt_to_phys(lasa);
             tcpa->laml = ACPI_2_0_TCPA_LAML_SIZE;
@@ -237,12 +248,10 @@ static int construct_secondary_tables(ui
     }
 
     table_ptrs[nr_tables] = 0;
-    return align16(offset);
+    return nr_tables;
 }
 
-static void __acpi_build_tables(unsigned int physical,
-                                uint8_t *buf,
-                                int *low_sz, int *high_sz)
+void acpi_build_tables(unsigned int physical)
 {
     struct acpi_20_rsdp *rsdp;
     struct acpi_20_rsdt *rsdt;
@@ -252,27 +261,28 @@ static void __acpi_build_tables(unsigned
     struct acpi_20_facs *facs;
     unsigned char       *dsdt;
     unsigned long        secondary_tables[16];
-    int                  offset = 0, i;
+    int                  nr_secondaries, i;
 
     /*
      * Fill in high-memory data structures, starting at @buf.
      */
 
-    facs = (struct acpi_20_facs *)&buf[offset];
+    facs = mem_alloc(sizeof(struct acpi_20_facs), 16);
+    if (!facs) goto oom;
     memcpy(facs, &Facs, sizeof(struct acpi_20_facs));
-    offset += align16(sizeof(struct acpi_20_facs));
 
-    dsdt = (unsigned char *)&buf[offset];
     if ( hvm_info->nr_vcpus <= 15 )
     {
+        dsdt = mem_alloc(dsdt_15cpu_len, 16);
+        if (!dsdt) goto oom;
         memcpy(dsdt, &dsdt_15cpu, dsdt_15cpu_len);
-        offset += align16(dsdt_15cpu_len);
         nr_processor_objects = 15;
     }
     else
     {
+        dsdt = mem_alloc(dsdt_anycpu_len, 16);
+        if (!dsdt) goto oom;
         memcpy(dsdt, &dsdt_anycpu, dsdt_anycpu_len);
-        offset += align16(dsdt_anycpu_len);
         nr_processor_objects = HVM_MAX_VCPUS;
     }
 
@@ -284,9 +294,9 @@ static void __acpi_build_tables(unsigned
      * compatible revision 1 FADT that is linked with the RSDT. Refer to:
      *     http://www.acpi.info/presentations/S01USMOBS169_OS%20new.ppt
      */
-    fadt_10 = (struct acpi_10_fadt *)&buf[offset];
+    fadt_10 = mem_alloc(sizeof(struct acpi_10_fadt), 16);
+    if (!fadt_10) goto oom;
     memcpy(fadt_10, &Fadt, sizeof(struct acpi_10_fadt));
-    offset += align16(sizeof(struct acpi_10_fadt));
     fadt_10->header.length = sizeof(struct acpi_10_fadt);
     fadt_10->header.revision = ACPI_1_0_FADT_REVISION;
     fadt_10->dsdt          = (unsigned long)dsdt;
@@ -295,9 +305,9 @@ static void __acpi_build_tables(unsigned
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_10_fadt));
 
-    fadt = (struct acpi_20_fadt *)&buf[offset];
+    fadt = mem_alloc(sizeof(struct acpi_20_fadt), 16);
+    if (!fadt) goto oom;
     memcpy(fadt, &Fadt, sizeof(struct acpi_20_fadt));
-    offset += align16(sizeof(struct acpi_20_fadt));
     fadt->dsdt   = (unsigned long)dsdt;
     fadt->x_dsdt = (unsigned long)dsdt;
     fadt->firmware_ctrl   = (unsigned long)facs;
@@ -306,42 +316,42 @@ static void __acpi_build_tables(unsigned
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
 
-    offset += construct_secondary_tables(&buf[offset], secondary_tables);
+    nr_secondaries = construct_secondary_tables(secondary_tables);
+    if ( nr_secondaries < 0 )
+        goto oom;
 
-    xsdt = (struct acpi_20_xsdt *)&buf[offset];
+    xsdt = mem_alloc(sizeof(struct acpi_20_xsdt)+
+                     sizeof(uint64_t)*nr_secondaries,
+                     16);
+    if (!xsdt) goto oom;
     memcpy(xsdt, &Xsdt, sizeof(struct acpi_header));
     xsdt->entry[0] = (unsigned long)fadt;
     for ( i = 0; secondary_tables[i]; i++ )
         xsdt->entry[i+1] = secondary_tables[i];
     xsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint64_t);
-    offset += align16(xsdt->header.length);
     set_checksum(xsdt,
                  offsetof(struct acpi_header, checksum),
                  xsdt->header.length);
 
-    rsdt = (struct acpi_20_rsdt *)&buf[offset];
+    rsdt = mem_alloc(sizeof(struct acpi_20_rsdt)+
+                     sizeof(uint32_t)*nr_secondaries,
+                     16);
+    if (!rsdt) goto oom;
     memcpy(rsdt, &Rsdt, sizeof(struct acpi_header));
     rsdt->entry[0] = (unsigned long)fadt_10;
     for ( i = 0; secondary_tables[i]; i++ )
         rsdt->entry[i+1] = secondary_tables[i];
     rsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint32_t);
-    offset += align16(rsdt->header.length);
     set_checksum(rsdt,
                  offsetof(struct acpi_header, checksum),
                  rsdt->header.length);
 
-    *high_sz = offset;
-
     /*
      * Fill in low-memory data structures: bios_info_table and RSDP.
      */
-    buf = (uint8_t *)physical;
-    offset = 0;
-
-    rsdp = (struct acpi_20_rsdp *)&buf[offset];
+    rsdp = (struct acpi_20_rsdp *)physical;
 
     memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp));
-    offset += align16(sizeof(struct acpi_20_rsdp));
     rsdp->rsdt_address = (unsigned long)rsdt;
     rsdp->xsdt_address = (unsigned long)xsdt;
     set_checksum(rsdp,
@@ -351,27 +361,11 @@ static void __acpi_build_tables(unsigned
                  offsetof(struct acpi_20_rsdp, extended_checksum),
                  sizeof(struct acpi_20_rsdp));
 
-    *low_sz = offset;
-}
+    return;
 
-void acpi_build_tables(unsigned int physical)
-{
-    int high_sz, low_sz;
-    uint8_t *buf;
+oom:
+    printf("unable to build ACPI tables: out of memory\n");
 
-    /* Find out size of high-memory ACPI data area. */
-    buf = (uint8_t *)&_end;
-    __acpi_build_tables(physical, buf, &low_sz, &high_sz);
-    memset(buf, 0, high_sz);
-
-    /* Allocate data area and set up ACPI tables there. */
-    buf = mem_alloc(high_sz, 0);
-    __acpi_build_tables(physical, buf, &low_sz, &high_sz);
-
-    printf(" - Lo data: %08x-%08x\n"
-           " - Hi data: %08lx-%08lx\n",
-           physical, physical + low_sz - 1,
-           (unsigned long)buf, (unsigned long)buf + high_sz - 1);
 }
 
 /*

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3 of 4] hvmloader: removed unused/incorrect define
  2011-06-02 15:07 [PATCH 0 of 4] hvmloader: ACPI clean/fix-ups Ian Campbell
  2011-06-02 15:07 ` [PATCH 1 of 4] hvmloader: reduce minimum allocation alignment from 1024 bytes to 16 Ian Campbell
  2011-06-02 15:07 ` [PATCH 2 of 4] hvmloader: allocate ACPI tables as we go Ian Campbell
@ 2011-06-02 15:07 ` Ian Campbell
  2011-06-02 15:07 ` [PATCH 4 of 4] hvmloader: reinstate datastructure shared with DSDT in SeaBIOS case Ian Campbell
  3 siblings, 0 replies; 5+ messages in thread
From: Ian Campbell @ 2011-06-02 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1307026862 -3600
# Node ID dc4a0e89997c81562f2779dfbae28a10c95c797f
# Parent  34a70784084d146ea4ddc5d4a63eade67a6045f6
hvmloader: removed unused/incorrect define.

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

diff -r 34a70784084d -r dc4a0e89997c tools/firmware/hvmloader/acpi/acpi2_0.h
--- a/tools/firmware/hvmloader/acpi/acpi2_0.h	Thu Jun 02 16:01:01 2011 +0100
+++ b/tools/firmware/hvmloader/acpi/acpi2_0.h	Thu Jun 02 16:01:02 2011 +0100
@@ -98,11 +98,6 @@ struct acpi_20_rsdp {
 };
 
 /*
- * The maximum number of entrys in RSDT or XSDT.
- */
-#define ACPI_MAX_NUM_TABLES 5
-
-/*
  * Root System Description Table (RSDT).
  */
 struct acpi_20_rsdt {

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 4 of 4] hvmloader: reinstate datastructure shared with DSDT in SeaBIOS case
  2011-06-02 15:07 [PATCH 0 of 4] hvmloader: ACPI clean/fix-ups Ian Campbell
                   ` (2 preceding siblings ...)
  2011-06-02 15:07 ` [PATCH 3 of 4] hvmloader: removed unused/incorrect define Ian Campbell
@ 2011-06-02 15:07 ` Ian Campbell
  3 siblings, 0 replies; 5+ messages in thread
From: Ian Campbell @ 2011-06-02 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# 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@citrix.com>

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-06-02 15:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-02 15:07 [PATCH 0 of 4] hvmloader: ACPI clean/fix-ups Ian Campbell
2011-06-02 15:07 ` [PATCH 1 of 4] hvmloader: reduce minimum allocation alignment from 1024 bytes to 16 Ian Campbell
2011-06-02 15:07 ` [PATCH 2 of 4] hvmloader: allocate ACPI tables as we go Ian Campbell
2011-06-02 15:07 ` [PATCH 3 of 4] hvmloader: removed unused/incorrect define Ian Campbell
2011-06-02 15:07 ` [PATCH 4 of 4] hvmloader: reinstate datastructure shared with DSDT in SeaBIOS case Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.