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

[Xen-devel] [PATCH 16 of 19] tools: hvmloader: Refactor MP table setup into struct bios_config



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1302603807 -3600
# Node ID 7bddcc4cfc8789cffe511b0b38645479d8d3490d
# Parent  63da98f210b0f708a6bd2f85bc03de8826655784
tools: hvmloader: Refactor MP table setup into struct bios_config

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 63da98f210b0 -r 7bddcc4cfc87 tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Tue Apr 12 11:19:18 2011 +0100
+++ b/tools/firmware/hvmloader/config.h Tue Apr 12 11:23:27 2011 +0100
@@ -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_
 #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
 
diff -r 63da98f210b0 -r 7bddcc4cfc87 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Tue Apr 12 11:19:18 2011 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Tue Apr 12 11:23:27 2011 +0100
@@ -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 )
     {
diff -r 63da98f210b0 -r 7bddcc4cfc87 tools/firmware/hvmloader/mp_tables.c
--- a/tools/firmware/hvmloader/mp_tables.c      Tue Apr 12 11:19:18 2011 +0100
+++ b/tools/firmware/hvmloader/mp_tables.c      Tue Apr 12 11:23:27 2011 +0100
@@ -259,46 +259,9 @@ static void fill_mpfps(struct mp_floatin
     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)
+/* create_mp_tables - creates MP tables for the guest based upon config data */
+void create_mp_tables(void *mp_table_base)
 {
-    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 *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();
 }
diff -r 63da98f210b0 -r 7bddcc4cfc87 tools/firmware/hvmloader/rombios.c
--- a/tools/firmware/hvmloader/rombios.c        Tue Apr 12 11:19:18 2011 +0100
+++ b/tools/firmware/hvmloader/rombios.c        Tue Apr 12 11:23:27 2011 +0100
@@ -37,6 +37,11 @@
 #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,
 };
 
 /*
diff -r 63da98f210b0 -r 7bddcc4cfc87 tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Tue Apr 12 11:19:18 2011 +0100
+++ b/tools/firmware/hvmloader/util.h   Tue Apr 12 11:23:27 2011 +0100
@@ -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);

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


 


Rackspace

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