]> xenbits.xensource.com Git - xen.git/commitdiff
tools: hvmloader: Refactor MP table setup into struct bios_config
authorIan Campbell <ian.campbell@citrix.com>
Tue, 12 Apr 2011 12:47:16 +0000 (13:47 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 12 Apr 2011 12:47:16 +0000 (13:47 +0100)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
tools/firmware/hvmloader/config.h
tools/firmware/hvmloader/hvmloader.c
tools/firmware/hvmloader/mp_tables.c
tools/firmware/hvmloader/rombios.c
tools/firmware/hvmloader/util.h

index de03f417443f1d3e3398cd67e638f7ad08e6556b..510c0170751c9422a170d762e52339b141b11f99 100644 (file)
@@ -36,6 +36,7 @@ struct bios_config {
     void (*e820_setup)(void);
 
     void (*acpi_build_tables)(unsigned int physical);
+    void (*create_mp_tables)(void);
 };
 
 extern struct bios_config rombios_config;
@@ -62,11 +63,6 @@ extern unsigned long pci_mem_start, pci_mem_end;
 #define RESERVED_MEMBASE    0xfc000000
 #define RESERVED_MEMSIZE    0x01000000
 
-#define ROMBIOS_BEGIN          0x000F0000
-#define ROMBIOS_SIZE           0x00010000
-#define ROMBIOS_MAXOFFSET      0x0000FFFF
-#define ROMBIOS_END            (ROMBIOS_BEGIN + ROMBIOS_SIZE)
-
 #define SCRATCH_PHYSICAL_ADDRESS      0x00010000
 #define HYPERCALL_PHYSICAL_ADDRESS    0x00080000
 
index b04a1f817a16f61a1f4b722d2e8b06d62bc83dd3..4fcbd9c49918aaeb1651d148b4e380e17380ddbe 100644 (file)
@@ -385,8 +385,9 @@ int main(void)
     if (bios->bios_high_setup)
         highbios = bios->bios_high_setup();
 
-    if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
-        create_mp_tables();
+    if ( bios->create_mp_tables &&
+         ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) )
+        bios->create_mp_tables();
 
     switch ( virtual_vga )
     {
index 7a79c5a1b04a8de91f31abab7f91c3ab4f31a6c7..668e8dd95e38a1d913c533cbcfc45cbb55740dd0 100644 (file)
@@ -259,46 +259,9 @@ static void fill_mpfps(struct mp_floating_pointer_struct *mpfps, uint32_t mpct)
     mpfps->checksum = -checksum;
 }
 
-
-/*
- * find_mp_table_start - searchs through BIOS memory for '___HVMMP' signature
- *
- * The '___HVMMP' signature is created by the ROMBIOS and designates a chunk
- * of space inside the ROMBIOS that is safe for us to write our MP table info
- */
-static void *get_mp_table_start(void)
-{
-    char *bios_mem;
-
-    for ( bios_mem = (char *)ROMBIOS_BEGIN; 
-          bios_mem != (char *)ROMBIOS_END; 
-          bios_mem++ )
-    {
-        if ( strncmp(bios_mem, "___HVMMP", 8) == 0)
-            return bios_mem;
-    }
-
-    return NULL;
-}
-
-
-/* recalculate the new ROMBIOS checksum after adding MP tables */
-static void reset_bios_checksum(void)
-{
-    uint32_t i;
-    uint8_t checksum;
-
-    checksum = 0;
-    for (i = 0; i < ROMBIOS_MAXOFFSET; ++i)
-        checksum += ((uint8_t *)(ROMBIOS_BEGIN))[i];
-
-    *((uint8_t *)(ROMBIOS_BEGIN + ROMBIOS_MAXOFFSET)) = -checksum;
-}
-
 /* create_mp_tables - creates MP tables for the guest based upon config data */
-void create_mp_tables(void)
+void create_mp_tables(void *mp_table_base)
 {
-    void *mp_table_base;
     char *p;
     int vcpu_nr, i, length;
     struct mp_io_intr_entry *mpiie;
@@ -307,14 +270,6 @@ void create_mp_tables(void)
 
     printf("Creating MP tables ...\n");
 
-    /* Find the 'safe' place in ROMBIOS for the MP tables. */
-    mp_table_base = get_mp_table_start();
-    if ( mp_table_base == NULL )
-    {
-        printf("Couldn't find start point for MP tables\n");
-        return;
-    }
-
     p = mp_table_base + sizeof(struct mp_config_table);
 
     for ( i = 0; i < vcpu_nr; i++ )
@@ -363,5 +318,4 @@ void create_mp_tables(void)
                (uint32_t)mp_table_base);
 
     fill_mp_config_table((struct mp_config_table *)mp_table_base, length);
-    reset_bios_checksum();
 }
index ef584d325dca6e4159b02dbb632aa3a73e006599..629a1425d4ece20d3fbcc03510546096495fdc87 100644 (file)
 #define ROM_INCLUDE_ROMBIOS
 #include "roms.inc"
 
+#define ROMBIOS_BEGIN          0x000F0000
+#define ROMBIOS_SIZE           0x00010000
+#define ROMBIOS_MAXOFFSET      0x0000FFFF
+#define ROMBIOS_END            (ROMBIOS_BEGIN + ROMBIOS_SIZE)
+
 /*
  * Set up an empty TSS area for virtual 8086 mode to use. 
  * The only important thing is that it musn't have any bits set 
@@ -303,6 +308,57 @@ static void rombios_pci_setup(void)
         pci_writew(devfn, PCI_COMMAND, cmd);
     }
 }
+
+/*
+ * find_mp_table_start - searchs through BIOS memory for '___HVMMP' signature
+ *
+ * The '___HVMMP' signature is created by the ROMBIOS and designates a chunk
+ * of space inside the ROMBIOS that is safe for us to write our MP table info
+ */
+static void *get_mp_table_start(void)
+{
+    char *bios_mem;
+
+    for ( bios_mem = (char *)ROMBIOS_BEGIN;
+          bios_mem != (char *)ROMBIOS_END;
+          bios_mem++ )
+    {
+        if ( strncmp(bios_mem, "___HVMMP", 8) == 0)
+            return bios_mem;
+    }
+
+    return NULL;
+}
+
+/* recalculate the new ROMBIOS checksum after adding MP tables */
+static void reset_bios_checksum(void)
+{
+    uint32_t i;
+    uint8_t checksum;
+
+    checksum = 0;
+    for (i = 0; i < ROMBIOS_MAXOFFSET; ++i)
+        checksum += ((uint8_t *)(ROMBIOS_BEGIN))[i];
+
+    *((uint8_t *)(ROMBIOS_BEGIN + ROMBIOS_MAXOFFSET)) = -checksum;
+}
+
+static void rombios_create_mp_tables(void)
+{
+    /* Find the 'safe' place in ROMBIOS for the MP tables. */
+    void *table = get_mp_table_start();
+
+    if ( table == NULL )
+    {
+        printf("Couldn't find start point for MP tables\n");
+        return;
+    }
+
+    create_mp_tables(table);
+
+    reset_bios_checksum();
+}
+
 //BUILD_BUG_ON(sizeof(rombios) > (0x00100000U - ROMBIOS_PHYSICAL_ADDRESS));
 
 struct bios_config rombios_config =  {
@@ -332,6 +388,7 @@ struct bios_config rombios_config =  {
     .e820_setup = rombios_setup_e820,
 
     .acpi_build_tables = acpi_build_tables,
+    .create_mp_tables = rombios_create_mp_tables,
 };
 
 /*
index 30828bb8a08aa7af2d13869bd13c6549f8f534d4..e7758ed52b2ed4cbaab2850d6da49202a10772bd 100644 (file)
@@ -185,7 +185,7 @@ uint32_t rombios_highbios_setup(void);
 
 /* Miscellaneous. */
 void cacheattr_init(void);
-void create_mp_tables(void);
+void create_mp_tables(void *table);
 int hvm_write_smbios_tables(unsigned long scratch,
                            unsigned long smbios_start,
                            unsigned long smbios_end);