hvmloader: Simplify access to hvm_info_table.
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 8 Jan 2009 13:49:05 +0000 (13:49 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 8 Jan 2009 13:49:05 +0000 (13:49 +0000)
Also require the table to be present.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
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

index b779c763932a61b39dd09c54de598a532f4d437d..657b7662dd38fa1ff217e7b5053ce11f0b899509 100644 (file)
@@ -150,7 +150,7 @@ static int construct_madt(struct acpi_20_madt *madt)
     offset += sizeof(*io_apic);
 
     lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
-    for ( i = 0; i < get_vcpu_nr(); i++ )
+    for ( i = 0; i < hvm_info->nr_vcpus; i++ )
     {
         memset(lapic, 0, sizeof(*lapic));
         lapic->type    = ACPI_PROCESSOR_LOCAL_APIC;
@@ -201,7 +201,7 @@ static int construct_secondary_tables(uint8_t *buf, unsigned long *table_ptrs)
     uint16_t *tis_hdr;
 
     /* MADT. */
-    if ( (get_vcpu_nr() > 1) || get_apic_mode() )
+    if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
     {
         madt = (struct acpi_20_madt *)&buf[offset];
         offset += construct_madt(madt);
index 54fa9196b69e3bcfd4c3b34761580913dae74832..463c1cc561304cef0b1c044f6e9fa11f1d555765 100644 (file)
@@ -604,7 +604,7 @@ int main(void)
     apic_setup();
     pci_setup();
 
-    if ( (get_vcpu_nr() > 1) || get_apic_mode() )
+    if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
         create_mp_tables();
 
     switch ( virtual_vga )
@@ -640,7 +640,7 @@ int main(void)
     option_rom_phys_addr = etherboot_phys_addr + etherboot_sz;
     option_rom_sz = pci_load_option_roms(option_rom_phys_addr);
 
-    if ( get_acpi_enabled() )
+    if ( hvm_info->acpi_enabled )
     {
         printf("Loading ACPI ...\n");
         acpi_build_tables();
index 2c42f6e4b469d4793d11c06188174396be87c272..ad09edafa0d83d5d089d8a7fbdf3b89fd992f3a2 100644 (file)
@@ -155,7 +155,7 @@ static void fill_mp_config_table(struct mp_config_table *mpct, int length)
     int vcpu_nr, i;
     uint8_t checksum;
 
-    vcpu_nr = get_vcpu_nr();
+    vcpu_nr = hvm_info->nr_vcpus;
 
     /* fill in the MP configuration table signature, "PCMP" */
     mpct->signature[0] = 'P';
@@ -317,7 +317,7 @@ void create_mp_tables(void)
     char *p;
     int vcpu_nr, i, length;
 
-    vcpu_nr = get_vcpu_nr();
+    vcpu_nr = hvm_info->nr_vcpus;
 
     printf("Creating MP tables ...\n");
 
index f68a7b4475f82c06b4b8a6ef142efe7907a22bb4..a73a64d4795ef8c813a7984899a48087a449c01d 100644 (file)
@@ -229,7 +229,7 @@ hvm_write_smbios_tables(void)
 
     /* SCRATCH_PHYSICAL_ADDRESS is a safe large memory area for scratch. */
     len = write_smbios_tables((void *)SCRATCH_PHYSICAL_ADDRESS,
-                              get_vcpu_nr(), get_memsize(),
+                              hvm_info->nr_vcpus, get_memsize(),
                               uuid, xen_version_str,
                               xen_major_version, xen_minor_version);
     if ( len > SMBIOS_MAXIMUM_SIZE )
index f64f73e3f0d6515711404c34fc2dfebba6c420fb..76d1c280403c315f09c189697074a512f3babd91 100644 (file)
@@ -121,7 +121,7 @@ static void boot_cpu(unsigned int cpu)
 
 void smp_initialise(void)
 {
-    unsigned int i, nr_cpus = get_vcpu_nr();
+    unsigned int i, nr_cpus = hvm_info->nr_vcpus;
 
     memcpy((void *)AP_BOOT_EIP, ap_boot_start, ap_boot_end - ap_boot_start);
 
index 6a1d47a61b5ac1b1637f63ba1bd81be2aef2c275..9889f619b8b76e55f268a9f5159b8392467d12ee 100644 (file)
@@ -25,7 +25,6 @@
 #include <stdint.h>
 #include <xen/xen.h>
 #include <xen/memory.h>
-#include <xen/hvm/hvm_info_table.h>
 
 void wrmsr(uint32_t idx, uint64_t v)
 {
@@ -566,7 +565,7 @@ static int validate_hvm_info(struct hvm_info_table *t)
     return (sum == 0);
 }
 
-static struct hvm_info_table *get_hvm_info_table(void)
+struct hvm_info_table *get_hvm_info_table(void)
 {
     static struct hvm_info_table *table;
     struct hvm_info_table *t;
@@ -579,7 +578,7 @@ static struct hvm_info_table *get_hvm_info_table(void)
     if ( !validate_hvm_info(t) )
     {
         printf("Bad hvm info table\n");
-        return NULL;
+        BUG();
     }
 
     table = t;
@@ -587,24 +586,6 @@ static struct hvm_info_table *get_hvm_info_table(void)
     return table;
 }
 
-int get_vcpu_nr(void)
-{
-    struct hvm_info_table *t = get_hvm_info_table();
-    return (t ? t->nr_vcpus : 1);
-}
-
-int get_acpi_enabled(void)
-{
-    struct hvm_info_table *t = get_hvm_info_table();
-    return (t ? t->acpi_enabled : 1);
-}
-
-int get_apic_mode(void)
-{
-    struct hvm_info_table *t = get_hvm_info_table();
-    return (t ? t->apic_mode : 1);
-}
-
 uint16_t get_cpu_mhz(void)
 {
     struct xen_add_to_physmap xatp;
index 81f0e4f4c44d3f77bebb0f5ce75c33dbcc29cd34..faa5c8dabcdfd2e5bf42dabd9e080db35ada11ed 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <stdarg.h>
 #include <stdint.h>
+#include <xen/hvm/hvm_info_table.h>
 
 #undef offsetof
 #define offsetof(t, m) ((unsigned long)&((t *)0)->m)
@@ -103,9 +104,8 @@ static inline void cpu_relax(void)
 })
 
 /* HVM-builder info. */
-int get_vcpu_nr(void);
-int get_acpi_enabled(void);
-int get_apic_mode(void);
+struct hvm_info_table *get_hvm_info_table(void);
+#define hvm_info (get_hvm_info_table())
 
 /* String and memory functions */
 int strcmp(const char *cs, const char *ct);