]> xenbits.xensource.com Git - xen.git/commitdiff
tools: hvmloader: Refactor VM86 and E820 setup into struct bios_config
authorIan Campbell <ian.campbell@citrix.com>
Tue, 12 Apr 2011 12:46:20 +0000 (13:46 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 12 Apr 2011 12:46:20 +0000 (13:46 +0100)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
tools/firmware/hvmloader/config.h
tools/firmware/hvmloader/hvmloader.c
tools/firmware/hvmloader/rombios.c

index 3d0683414d90c2a10352bf0592b65c623f4b346d..4aa59a1509e5caa1e1bd61e7ff915e9dd5d9486b 100644 (file)
@@ -31,6 +31,9 @@ struct bios_config {
 
     uint32_t (*bios_high_setup)(void);
     void (*bios_info_setup)(uint32_t);
+
+    void (*vm86_setup)(void);
+    void (*e820_setup)(void);
 };
 
 extern struct bios_config rombios_config;
@@ -62,9 +65,6 @@ extern unsigned long pci_mem_start, pci_mem_end;
 #define ROMBIOS_MAXOFFSET      0x0000FFFF
 #define ROMBIOS_END            (ROMBIOS_BEGIN + ROMBIOS_SIZE)
 
-#include "e820.h"
-#include "../rombios/config.h"
-
 #define SCRATCH_PHYSICAL_ADDRESS      0x00010000
 #define HYPERCALL_PHYSICAL_ADDRESS    0x00080000
 
index 0426a42054d93e436e65340a0010c1dd20045760..232941fd365e834d4c2d271575e0c46362f75f50 100644 (file)
@@ -338,24 +338,6 @@ static void cmos_write_memory_size(void)
     cmos_outb(0x35, (uint8_t)( alt_mem >> 8));
 }
 
-/*
- * 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 
- * in the interrupt redirection bitmap, so all zeros will do.
- */
-static void init_vm86_tss(void)
-{
-    void *tss;
-    struct xen_hvm_param p;
-
-    tss = mem_alloc(128, 128);
-    memset(tss, 0, 128);
-    p.domid = DOMID_SELF;
-    p.index = HVM_PARAM_VM86_TSS;
-    p.value = virt_to_phys(tss);
-    hypercall_hvm_op(HVMOP_set_param, &p);
-    printf("vm86 TSS at %08lx\n", virt_to_phys(tss));
-}
 
 static const struct bios_config *detect_bios(void)
 {
@@ -454,7 +436,8 @@ int main(void)
         hypercall_hvm_op(HVMOP_set_param, &p);
     }
 
-    init_vm86_tss();
+    if (bios->vm86_setup)
+        bios->vm86_setup();
 
     cmos_write_memory_size();
 
@@ -479,8 +462,8 @@ int main(void)
            bios->bios_address,
            bios->bios_address + bios->image_size - 1);
 
-    *E820_NR = build_e820_table(E820);
-    dump_e820_table(E820, *E820_NR);
+    if (bios->e820_setup)
+        bios->e820_setup();
 
     if (bios->bios_info_setup)
         bios->bios_info_setup(highbios);
index 7d88425730a489eef6532437050acf4b55ccc47e..688a2bfa495138dad0fb6aa33afc69e84dd8c7ff 100644 (file)
 #include "util.h"
 #include "hypercall.h"
 
+#include <xen/hvm/params.h>
 #include <xen/hvm/ioreq.h>
 #include <xen/memory.h>
 
 #define ROM_INCLUDE_ROMBIOS
 #include "roms.inc"
 
+/*
+ * 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 
+ * in the interrupt redirection bitmap, so all zeros will do.
+ */
+static void rombios_init_vm86_tss(void)
+{
+    void *tss;
+    struct xen_hvm_param p;
+
+    tss = mem_alloc(128, 128);
+    memset(tss, 0, 128);
+    p.domid = DOMID_SELF;
+    p.index = HVM_PARAM_VM86_TSS;
+    p.value = virt_to_phys(tss);
+    hypercall_hvm_op(HVMOP_set_param, &p);
+    printf("vm86 TSS at %08lx\n", virt_to_phys(tss));
+}
+
+static void rombios_setup_e820(void)
+{
+    *E820_NR = build_e820_table(E820);
+    dump_e820_table(E820, *E820_NR);
+}
+
 static void rombios_setup_bios_info(uint32_t bioshigh)
 {
     struct bios_info *bios_info;
@@ -301,6 +327,9 @@ struct bios_config rombios_config =  {
 
     .bios_high_setup = rombios_highbios_setup,
     .bios_info_setup = rombios_setup_bios_info,
+
+    .vm86_setup = rombios_init_vm86_tss,
+    .e820_setup = rombios_setup_e820,
 };
 
 /*