ia64/xen-unstable

changeset 18191:a538185695ed

hvmloader: Load ACPI tables outside BIOS area, so they are writable by
OSPM (particularly the S3 firmware_waking_vector).

TODO: rombios must enter protected mode to fetch the vector on S3 resume.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jul 29 15:10:58 2008 +0100 (2008-07-29)
parents b0ee5e8613e9
children 979e098dfb92
files tools/firmware/hvmloader/acpi/acpi2_0.h tools/firmware/hvmloader/acpi/build.c tools/firmware/hvmloader/hvmloader.c tools/firmware/hvmloader/util.h
line diff
     1.1 --- a/tools/firmware/hvmloader/acpi/acpi2_0.h	Tue Jul 29 13:27:29 2008 +0100
     1.2 +++ b/tools/firmware/hvmloader/acpi/acpi2_0.h	Tue Jul 29 15:10:58 2008 +0100
     1.3 @@ -381,7 +381,7 @@ struct acpi_20_madt_intsrcovr {
     1.4  
     1.5  #pragma pack ()
     1.6  
     1.7 -int acpi_build_tables(uint8_t *);
     1.8 +void acpi_build_tables(void);
     1.9  
    1.10  #endif /* _ACPI_2_0_H_ */
    1.11  
     2.1 --- a/tools/firmware/hvmloader/acpi/build.c	Tue Jul 29 13:27:29 2008 +0100
     2.2 +++ b/tools/firmware/hvmloader/acpi/build.c	Tue Jul 29 15:10:58 2008 +0100
     2.3 @@ -248,8 +248,7 @@ static int construct_secondary_tables(ui
     2.4      return align16(offset);
     2.5  }
     2.6  
     2.7 -/* Copy all the ACPI table to buffer. */
     2.8 -int acpi_build_tables(uint8_t *buf)
     2.9 +static void __acpi_build_tables(uint8_t *buf, int *low_sz, int *high_sz)
    2.10  {
    2.11      struct acpi_20_rsdp *rsdp;
    2.12      struct acpi_20_rsdt *rsdt;
    2.13 @@ -261,7 +260,9 @@ int acpi_build_tables(uint8_t *buf)
    2.14      unsigned long        secondary_tables[16];
    2.15      int                  offset = 0, i;
    2.16  
    2.17 -    offset += construct_bios_info_table(&buf[offset]);
    2.18 +    /*
    2.19 +     * Fill in high-memory data structures, starting at @buf.
    2.20 +     */
    2.21  
    2.22      facs = (struct acpi_20_facs *)&buf[offset];
    2.23      memcpy(facs, &Facs, sizeof(struct acpi_20_facs));
    2.24 @@ -325,7 +326,18 @@ int acpi_build_tables(uint8_t *buf)
    2.25                   offsetof(struct acpi_header, checksum),
    2.26                   rsdt->header.length);
    2.27  
    2.28 +    *high_sz = offset;
    2.29 +
    2.30 +    /*
    2.31 +     * Fill in low-memory data structures: bios_info_table and RSDP.
    2.32 +     */
    2.33 +
    2.34 +    buf = (uint8_t *)ACPI_PHYSICAL_ADDRESS;
    2.35 +    offset = 0;
    2.36 +
    2.37 +    offset += construct_bios_info_table(&buf[offset]);
    2.38      rsdp = (struct acpi_20_rsdp *)&buf[offset];
    2.39 +
    2.40      memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp));
    2.41      offset += align16(sizeof(struct acpi_20_rsdp));
    2.42      rsdp->rsdt_address = (unsigned long)rsdt;
    2.43 @@ -337,7 +349,28 @@ int acpi_build_tables(uint8_t *buf)
    2.44                   offsetof(struct acpi_20_rsdp, extended_checksum),
    2.45                   sizeof(struct acpi_20_rsdp));
    2.46  
    2.47 -    return offset;
    2.48 +    *low_sz = offset;
    2.49 +}
    2.50 +
    2.51 +void acpi_build_tables(void)
    2.52 +{
    2.53 +    int high_sz, low_sz;
    2.54 +    uint8_t *buf;
    2.55 +
    2.56 +    /* Find out size of high-memory ACPI data area. */
    2.57 +    buf = (uint8_t *)&_end;
    2.58 +    __acpi_build_tables(buf, &low_sz, &high_sz);
    2.59 +    memset(buf, 0, high_sz);
    2.60 +
    2.61 +    /* Allocate data area and set up ACPI tables there. */
    2.62 +    buf = (uint8_t *)e820_malloc(high_sz);
    2.63 +    __acpi_build_tables(buf, &low_sz, &high_sz);
    2.64 +
    2.65 +    printf(" - Lo data: %08lx-%08lx\n"
    2.66 +           " - Hi data: %08lx-%08lx\n",
    2.67 +           (unsigned long)ACPI_PHYSICAL_ADDRESS,
    2.68 +           (unsigned long)ACPI_PHYSICAL_ADDRESS + low_sz - 1,
    2.69 +           (unsigned long)buf, (unsigned long)buf + high_sz - 1);
    2.70  }
    2.71  
    2.72  /*
     3.1 --- a/tools/firmware/hvmloader/hvmloader.c	Tue Jul 29 13:27:29 2008 +0100
     3.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Tue Jul 29 15:10:58 2008 +0100
     3.3 @@ -449,7 +449,7 @@ static void init_xen_platform_io_base(vo
     3.4  
     3.5  int main(void)
     3.6  {
     3.7 -    int acpi_sz = 0, vgabios_sz = 0, etherboot_sz = 0, rombios_sz, smbios_sz;
     3.8 +    int vgabios_sz = 0, etherboot_sz = 0, rombios_sz, smbios_sz;
     3.9      int extboot_sz = 0;
    3.10  
    3.11      printf("HVM Loader\n");
    3.12 @@ -508,8 +508,7 @@ int main(void)
    3.13      if ( get_acpi_enabled() )
    3.14      {
    3.15          printf("Loading ACPI ...\n");
    3.16 -        acpi_sz = acpi_build_tables((uint8_t *)ACPI_PHYSICAL_ADDRESS);
    3.17 -        ASSERT((ACPI_PHYSICAL_ADDRESS + acpi_sz) <= 0xF0000);
    3.18 +        acpi_build_tables();
    3.19      }
    3.20  
    3.21      cmos_write_memory_size();
    3.22 @@ -531,10 +530,6 @@ int main(void)
    3.23          printf(" %05x-%05x: SMBIOS tables\n",
    3.24                 SMBIOS_PHYSICAL_ADDRESS,
    3.25                 SMBIOS_PHYSICAL_ADDRESS + smbios_sz - 1);
    3.26 -    if ( acpi_sz )
    3.27 -        printf(" %05x-%05x: ACPI tables\n",
    3.28 -               ACPI_PHYSICAL_ADDRESS,
    3.29 -               ACPI_PHYSICAL_ADDRESS + acpi_sz - 1);
    3.30      if ( rombios_sz )
    3.31          printf(" %05x-%05x: Main BIOS\n",
    3.32                 ROMBIOS_PHYSICAL_ADDRESS,
     4.1 --- a/tools/firmware/hvmloader/util.h	Tue Jul 29 13:27:29 2008 +0100
     4.2 +++ b/tools/firmware/hvmloader/util.h	Tue Jul 29 15:10:58 2008 +0100
     4.3 @@ -145,4 +145,6 @@ void smp_initialise(void);
     4.4  
     4.5  #define isdigit(c) ((c) >= '0' && (c) <= '9')
     4.6  
     4.7 +extern char _start[], _end[];
     4.8 +
     4.9  #endif /* __HVMLOADER_UTIL_H__ */