[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] hvmloader: Simplify access to hvm_info_table.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1231422545 0
# Node ID f20e5039b168316ef717abc60d3c82a4dc9bf4f2
# Parent  1025a725d45b69be196e02b5c3478feb7df14780
hvmloader: Simplify access to hvm_info_table.

Also require the table to be present.

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/firmware/hvmloader/acpi/build.c |    4 ++--
 tools/firmware/hvmloader/hvmloader.c  |    4 ++--
 tools/firmware/hvmloader/mp_tables.c  |    4 ++--
 tools/firmware/hvmloader/smbios.c     |    2 +-
 tools/firmware/hvmloader/smp.c        |    2 +-
 tools/firmware/hvmloader/util.c       |   23 ++---------------------
 tools/firmware/hvmloader/util.h       |    6 +++---
 7 files changed, 13 insertions(+), 32 deletions(-)

diff -r 1025a725d45b -r f20e5039b168 tools/firmware/hvmloader/acpi/build.c
--- a/tools/firmware/hvmloader/acpi/build.c     Thu Jan 08 13:37:16 2009 +0000
+++ b/tools/firmware/hvmloader/acpi/build.c     Thu Jan 08 13:49:05 2009 +0000
@@ -150,7 +150,7 @@ static int construct_madt(struct acpi_20
     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(ui
     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 -r 1025a725d45b -r f20e5039b168 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Thu Jan 08 13:37:16 2009 +0000
+++ b/tools/firmware/hvmloader/hvmloader.c      Thu Jan 08 13:49:05 2009 +0000
@@ -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 -r 1025a725d45b -r f20e5039b168 tools/firmware/hvmloader/mp_tables.c
--- a/tools/firmware/hvmloader/mp_tables.c      Thu Jan 08 13:37:16 2009 +0000
+++ b/tools/firmware/hvmloader/mp_tables.c      Thu Jan 08 13:49:05 2009 +0000
@@ -155,7 +155,7 @@ static void fill_mp_config_table(struct 
     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 -r 1025a725d45b -r f20e5039b168 tools/firmware/hvmloader/smbios.c
--- a/tools/firmware/hvmloader/smbios.c Thu Jan 08 13:37:16 2009 +0000
+++ b/tools/firmware/hvmloader/smbios.c Thu Jan 08 13:49:05 2009 +0000
@@ -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 -r 1025a725d45b -r f20e5039b168 tools/firmware/hvmloader/smp.c
--- a/tools/firmware/hvmloader/smp.c    Thu Jan 08 13:37:16 2009 +0000
+++ b/tools/firmware/hvmloader/smp.c    Thu Jan 08 13:49:05 2009 +0000
@@ -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 -r 1025a725d45b -r f20e5039b168 tools/firmware/hvmloader/util.c
--- a/tools/firmware/hvmloader/util.c   Thu Jan 08 13:37:16 2009 +0000
+++ b/tools/firmware/hvmloader/util.c   Thu Jan 08 13:49:05 2009 +0000
@@ -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_
     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,30 +578,12 @@ static struct hvm_info_table *get_hvm_in
     if ( !validate_hvm_info(t) )
     {
         printf("Bad hvm info table\n");
-        return NULL;
+        BUG();
     }
 
     table = t;
 
     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)
diff -r 1025a725d45b -r f20e5039b168 tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Thu Jan 08 13:37:16 2009 +0000
+++ b/tools/firmware/hvmloader/util.h   Thu Jan 08 13:49:05 2009 +0000
@@ -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);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.