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

[Xen-changelog] [xen-unstable] tools: hvmloader: Refactor MP table setup into struct bios_config



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1302612436 -3600
# Node ID 2869bb8995e2ae13b2aff5461f6b361c02df0643
# Parent  36799b6d1db21a9c1dd248d385805ccdb338a812
tools: hvmloader: Refactor MP table setup into struct bios_config

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 36799b6d1db2 -r 2869bb8995e2 tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Tue Apr 12 13:46:49 2011 +0100
+++ b/tools/firmware/hvmloader/config.h Tue Apr 12 13:47:16 2011 +0100
@@ -36,6 +36,7 @@
     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 @@
 #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 36799b6d1db2 -r 2869bb8995e2 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Tue Apr 12 13:46:49 2011 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Tue Apr 12 13:47:16 2011 +0100
@@ -385,8 +385,9 @@
     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 36799b6d1db2 -r 2869bb8995e2 tools/firmware/hvmloader/mp_tables.c
--- a/tools/firmware/hvmloader/mp_tables.c      Tue Apr 12 13:46:49 2011 +0100
+++ b/tools/firmware/hvmloader/mp_tables.c      Tue Apr 12 13:47:16 2011 +0100
@@ -259,46 +259,9 @@
     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 @@
 
     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 @@
                (uint32_t)mp_table_base);
 
     fill_mp_config_table((struct mp_config_table *)mp_table_base, length);
-    reset_bios_checksum();
 }
diff -r 36799b6d1db2 -r 2869bb8995e2 tools/firmware/hvmloader/rombios.c
--- a/tools/firmware/hvmloader/rombios.c        Tue Apr 12 13:46:49 2011 +0100
+++ b/tools/firmware/hvmloader/rombios.c        Tue Apr 12 13:47:16 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 @@
         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 @@
     .e820_setup = rombios_setup_e820,
 
     .acpi_build_tables = acpi_build_tables,
+    .create_mp_tables = rombios_create_mp_tables,
 };
 
 /*
diff -r 36799b6d1db2 -r 2869bb8995e2 tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Tue Apr 12 13:46:49 2011 +0100
+++ b/tools/firmware/hvmloader/util.h   Tue Apr 12 13:47:16 2011 +0100
@@ -185,7 +185,7 @@
 
 /* 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-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®.