From: Keir Fraser Date: Thu, 8 Jan 2009 13:49:05 +0000 (+0000) Subject: hvmloader: Simplify access to hvm_info_table. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14014^2~90 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=54562e0cdf3849e813686a5cf32321300caa2e8f;p=xen.git hvmloader: Simplify access to hvm_info_table. Also require the table to be present. Signed-off-by: Keir Fraser --- diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c index b779c76393..657b7662dd 100644 --- a/tools/firmware/hvmloader/acpi/build.c +++ b/tools/firmware/hvmloader/acpi/build.c @@ -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); diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index 54fa9196b6..463c1cc561 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -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(); diff --git a/tools/firmware/hvmloader/mp_tables.c b/tools/firmware/hvmloader/mp_tables.c index 2c42f6e4b4..ad09edafa0 100644 --- a/tools/firmware/hvmloader/mp_tables.c +++ b/tools/firmware/hvmloader/mp_tables.c @@ -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"); diff --git a/tools/firmware/hvmloader/smbios.c b/tools/firmware/hvmloader/smbios.c index f68a7b4475..a73a64d479 100644 --- a/tools/firmware/hvmloader/smbios.c +++ b/tools/firmware/hvmloader/smbios.c @@ -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 ) diff --git a/tools/firmware/hvmloader/smp.c b/tools/firmware/hvmloader/smp.c index f64f73e3f0..76d1c28040 100644 --- a/tools/firmware/hvmloader/smp.c +++ b/tools/firmware/hvmloader/smp.c @@ -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); diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index 6a1d47a61b..9889f619b8 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -25,7 +25,6 @@ #include #include #include -#include 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; diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h index 81f0e4f4c4..faa5c8dabc 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -3,6 +3,7 @@ #include #include +#include #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);