ia64/xen-unstable

changeset 19015:f20e5039b168

hvmloader: Simplify access to hvm_info_table.

Also require the table to be present.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 08 13:49:05 2009 +0000 (2009-01-08)
parents 1025a725d45b
children 0d119f628795
files tools/firmware/hvmloader/acpi/build.c tools/firmware/hvmloader/hvmloader.c tools/firmware/hvmloader/mp_tables.c tools/firmware/hvmloader/smbios.c tools/firmware/hvmloader/smp.c tools/firmware/hvmloader/util.c tools/firmware/hvmloader/util.h
line diff
     1.1 --- a/tools/firmware/hvmloader/acpi/build.c	Thu Jan 08 13:37:16 2009 +0000
     1.2 +++ b/tools/firmware/hvmloader/acpi/build.c	Thu Jan 08 13:49:05 2009 +0000
     1.3 @@ -150,7 +150,7 @@ static int construct_madt(struct acpi_20
     1.4      offset += sizeof(*io_apic);
     1.5  
     1.6      lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
     1.7 -    for ( i = 0; i < get_vcpu_nr(); i++ )
     1.8 +    for ( i = 0; i < hvm_info->nr_vcpus; i++ )
     1.9      {
    1.10          memset(lapic, 0, sizeof(*lapic));
    1.11          lapic->type    = ACPI_PROCESSOR_LOCAL_APIC;
    1.12 @@ -201,7 +201,7 @@ static int construct_secondary_tables(ui
    1.13      uint16_t *tis_hdr;
    1.14  
    1.15      /* MADT. */
    1.16 -    if ( (get_vcpu_nr() > 1) || get_apic_mode() )
    1.17 +    if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
    1.18      {
    1.19          madt = (struct acpi_20_madt *)&buf[offset];
    1.20          offset += construct_madt(madt);
     2.1 --- a/tools/firmware/hvmloader/hvmloader.c	Thu Jan 08 13:37:16 2009 +0000
     2.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Thu Jan 08 13:49:05 2009 +0000
     2.3 @@ -604,7 +604,7 @@ int main(void)
     2.4      apic_setup();
     2.5      pci_setup();
     2.6  
     2.7 -    if ( (get_vcpu_nr() > 1) || get_apic_mode() )
     2.8 +    if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
     2.9          create_mp_tables();
    2.10  
    2.11      switch ( virtual_vga )
    2.12 @@ -640,7 +640,7 @@ int main(void)
    2.13      option_rom_phys_addr = etherboot_phys_addr + etherboot_sz;
    2.14      option_rom_sz = pci_load_option_roms(option_rom_phys_addr);
    2.15  
    2.16 -    if ( get_acpi_enabled() )
    2.17 +    if ( hvm_info->acpi_enabled )
    2.18      {
    2.19          printf("Loading ACPI ...\n");
    2.20          acpi_build_tables();
     3.1 --- a/tools/firmware/hvmloader/mp_tables.c	Thu Jan 08 13:37:16 2009 +0000
     3.2 +++ b/tools/firmware/hvmloader/mp_tables.c	Thu Jan 08 13:49:05 2009 +0000
     3.3 @@ -155,7 +155,7 @@ static void fill_mp_config_table(struct 
     3.4      int vcpu_nr, i;
     3.5      uint8_t checksum;
     3.6  
     3.7 -    vcpu_nr = get_vcpu_nr();
     3.8 +    vcpu_nr = hvm_info->nr_vcpus;
     3.9  
    3.10      /* fill in the MP configuration table signature, "PCMP" */
    3.11      mpct->signature[0] = 'P';
    3.12 @@ -317,7 +317,7 @@ void create_mp_tables(void)
    3.13      char *p;
    3.14      int vcpu_nr, i, length;
    3.15  
    3.16 -    vcpu_nr = get_vcpu_nr();
    3.17 +    vcpu_nr = hvm_info->nr_vcpus;
    3.18  
    3.19      printf("Creating MP tables ...\n");
    3.20  
     4.1 --- a/tools/firmware/hvmloader/smbios.c	Thu Jan 08 13:37:16 2009 +0000
     4.2 +++ b/tools/firmware/hvmloader/smbios.c	Thu Jan 08 13:49:05 2009 +0000
     4.3 @@ -229,7 +229,7 @@ hvm_write_smbios_tables(void)
     4.4  
     4.5      /* SCRATCH_PHYSICAL_ADDRESS is a safe large memory area for scratch. */
     4.6      len = write_smbios_tables((void *)SCRATCH_PHYSICAL_ADDRESS,
     4.7 -                              get_vcpu_nr(), get_memsize(),
     4.8 +                              hvm_info->nr_vcpus, get_memsize(),
     4.9                                uuid, xen_version_str,
    4.10                                xen_major_version, xen_minor_version);
    4.11      if ( len > SMBIOS_MAXIMUM_SIZE )
     5.1 --- a/tools/firmware/hvmloader/smp.c	Thu Jan 08 13:37:16 2009 +0000
     5.2 +++ b/tools/firmware/hvmloader/smp.c	Thu Jan 08 13:49:05 2009 +0000
     5.3 @@ -121,7 +121,7 @@ static void boot_cpu(unsigned int cpu)
     5.4  
     5.5  void smp_initialise(void)
     5.6  {
     5.7 -    unsigned int i, nr_cpus = get_vcpu_nr();
     5.8 +    unsigned int i, nr_cpus = hvm_info->nr_vcpus;
     5.9  
    5.10      memcpy((void *)AP_BOOT_EIP, ap_boot_start, ap_boot_end - ap_boot_start);
    5.11  
     6.1 --- a/tools/firmware/hvmloader/util.c	Thu Jan 08 13:37:16 2009 +0000
     6.2 +++ b/tools/firmware/hvmloader/util.c	Thu Jan 08 13:49:05 2009 +0000
     6.3 @@ -25,7 +25,6 @@
     6.4  #include <stdint.h>
     6.5  #include <xen/xen.h>
     6.6  #include <xen/memory.h>
     6.7 -#include <xen/hvm/hvm_info_table.h>
     6.8  
     6.9  void wrmsr(uint32_t idx, uint64_t v)
    6.10  {
    6.11 @@ -566,7 +565,7 @@ static int validate_hvm_info(struct hvm_
    6.12      return (sum == 0);
    6.13  }
    6.14  
    6.15 -static struct hvm_info_table *get_hvm_info_table(void)
    6.16 +struct hvm_info_table *get_hvm_info_table(void)
    6.17  {
    6.18      static struct hvm_info_table *table;
    6.19      struct hvm_info_table *t;
    6.20 @@ -579,7 +578,7 @@ static struct hvm_info_table *get_hvm_in
    6.21      if ( !validate_hvm_info(t) )
    6.22      {
    6.23          printf("Bad hvm info table\n");
    6.24 -        return NULL;
    6.25 +        BUG();
    6.26      }
    6.27  
    6.28      table = t;
    6.29 @@ -587,24 +586,6 @@ static struct hvm_info_table *get_hvm_in
    6.30      return table;
    6.31  }
    6.32  
    6.33 -int get_vcpu_nr(void)
    6.34 -{
    6.35 -    struct hvm_info_table *t = get_hvm_info_table();
    6.36 -    return (t ? t->nr_vcpus : 1);
    6.37 -}
    6.38 -
    6.39 -int get_acpi_enabled(void)
    6.40 -{
    6.41 -    struct hvm_info_table *t = get_hvm_info_table();
    6.42 -    return (t ? t->acpi_enabled : 1);
    6.43 -}
    6.44 -
    6.45 -int get_apic_mode(void)
    6.46 -{
    6.47 -    struct hvm_info_table *t = get_hvm_info_table();
    6.48 -    return (t ? t->apic_mode : 1);
    6.49 -}
    6.50 -
    6.51  uint16_t get_cpu_mhz(void)
    6.52  {
    6.53      struct xen_add_to_physmap xatp;
     7.1 --- a/tools/firmware/hvmloader/util.h	Thu Jan 08 13:37:16 2009 +0000
     7.2 +++ b/tools/firmware/hvmloader/util.h	Thu Jan 08 13:49:05 2009 +0000
     7.3 @@ -3,6 +3,7 @@
     7.4  
     7.5  #include <stdarg.h>
     7.6  #include <stdint.h>
     7.7 +#include <xen/hvm/hvm_info_table.h>
     7.8  
     7.9  #undef offsetof
    7.10  #define offsetof(t, m) ((unsigned long)&((t *)0)->m)
    7.11 @@ -103,9 +104,8 @@ static inline void cpu_relax(void)
    7.12  })
    7.13  
    7.14  /* HVM-builder info. */
    7.15 -int get_vcpu_nr(void);
    7.16 -int get_acpi_enabled(void);
    7.17 -int get_apic_mode(void);
    7.18 +struct hvm_info_table *get_hvm_info_table(void);
    7.19 +#define hvm_info (get_hvm_info_table())
    7.20  
    7.21  /* String and memory functions */
    7.22  int strcmp(const char *cs, const char *ct);