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

[Xen-devel] [RFC PATCH 3/5] hvmloader: Load BIOS from where libxc left it.



---
 tools/firmware/hvmloader/config.h    |  9 +--------
 tools/firmware/hvmloader/hvmloader.c | 25 +++++++++++++------------
 tools/firmware/hvmloader/seabios.c   | 24 ++++++++++++++----------
 3 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/tools/firmware/hvmloader/config.h 
b/tools/firmware/hvmloader/config.h
index b838cf9..0ddd897 100644
--- a/tools/firmware/hvmloader/config.h
+++ b/tools/firmware/hvmloader/config.h
@@ -12,17 +12,10 @@ extern unsigned long igd_opregion_pgbase;
 struct bios_config {
     const char *name;
 
-    /* BIOS ROM image bits */
-    void *image;
-    unsigned int image_size;
-
-    /* Physical address to load at */
-    unsigned int bios_address;
-
     /* ROMS */
     void (*load_roms)(void);
 
-    void (*bios_load)(const struct bios_config *config);
+    void (*bios_load)(const struct bios_config *config, void* addr, uint32_t 
size);
 
     void (*bios_info_setup)(void);
     void (*bios_info_finish)(void);
diff --git a/tools/firmware/hvmloader/hvmloader.c 
b/tools/firmware/hvmloader/hvmloader.c
index 716d03c..04b5076 100644
--- a/tools/firmware/hvmloader/hvmloader.c
+++ b/tools/firmware/hvmloader/hvmloader.c
@@ -253,6 +253,9 @@ int main(void)
 {
     const struct bios_config *bios;
     int acpi_enabled;
+    uint8_t *bios_addr;
+    uint32_t bios_lenght;
+    const char *s;
 
     /* Initialise hypercall stubs with RET, rendering them no-ops. */
     memset((void *)HYPERCALL_PHYSICAL_ADDRESS, 0xc3 /* RET */, PAGE_SIZE);
@@ -286,16 +289,14 @@ int main(void)
         bios->create_smbios_tables();
     }
 
+    // XXX check that the values exist and are correct
+    s = xenstore_read("hvmloader/bios/address", NULL);
+    bios_addr = (uint8_t*)(uint32_t)strtoll(s, NULL, 0);
+    s = xenstore_read("hvmloader/bios/length", NULL);
+    bios_lenght = (uint32_t)strtoll(s, NULL, 0);
+
     printf("Loading %s ...\n", bios->name);
-    if ( bios->bios_load )
-        bios->bios_load(bios);
-    else
-    {
-        BUG_ON(bios->bios_address + bios->image_size >
-               HVMLOADER_PHYSICAL_ADDRESS);
-        memcpy((void *)bios->bios_address, bios->image,
-               bios->image_size);
-    }
+    bios->bios_load(bios, bios_addr, bios_lenght);
 
     if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
     {
@@ -333,9 +334,9 @@ int main(void)
     if ( SCRATCH_PHYSICAL_ADDRESS != scratch_start )
         printf(" %05x-%05lx: Scratch space\n",
                SCRATCH_PHYSICAL_ADDRESS, scratch_start);
-    printf(" %05x-%05x: Main BIOS\n",
-           bios->bios_address,
-           bios->bios_address + bios->image_size - 1);
+    /* printf(" %05x-%05x: Main BIOS\n", */
+           /* bios->bios_address, */
+           /* bios->bios_address + bios->image_size - 1); */
 
     if ( bios->e820_setup )
         bios->e820_setup();
diff --git a/tools/firmware/hvmloader/seabios.c 
b/tools/firmware/hvmloader/seabios.c
index c6b3d9f..28793ca 100644
--- a/tools/firmware/hvmloader/seabios.c
+++ b/tools/firmware/hvmloader/seabios.c
@@ -27,9 +27,6 @@
 #include "smbios_types.h"
 #include "acpi/acpi2_0.h"
 
-#define ROM_INCLUDE_SEABIOS
-#include "roms.inc"
-
 extern unsigned char dsdt_anycpu_qemu_xen[];
 extern int dsdt_anycpu_qemu_xen_len;
 
@@ -121,6 +118,7 @@ static void seabios_create_pir_tables(void)
     add_table(create_pir_tables());
 }
 
+unsigned int seabios_bios_address = 0;
 static void seabios_setup_e820(void)
 {
     struct seabios_info *info = (void *)BIOS_INFO_PHYSICAL_ADDRESS;
@@ -128,21 +126,27 @@ static void seabios_setup_e820(void)
     info->e820 = (uint32_t)e820;
 
     /* SeaBIOS reserves memory in e820 as necessary so no low reservation. */
-    info->e820_nr = build_e820_table(e820, 0, 0x100000-sizeof(seabios));
+    BUG_ON(seabios_bios_address == 0);
+    info->e820_nr = build_e820_table(e820, 0, seabios_bios_address);
     dump_e820_table(e820, info->e820_nr);
 }
 
-struct bios_config seabios_config = {
-    .name = "SeaBIOS",
+static void seabios_load(const struct bios_config *bios,
+                         void *bios_addr, uint32_t bios_lenght)
+{
+    unsigned int bios_dest = 0x100000 - bios_lenght;
+    seabios_bios_address = 0x100000 - bios_lenght;
 
-    .image = seabios,
-    .image_size = sizeof(seabios),
+    BUG_ON(bios_dest + bios_lenght > HVMLOADER_PHYSICAL_ADDRESS);
+    memcpy((void *)bios_dest, bios_addr, bios_lenght);
+}
 
-    .bios_address = 0x100000 - sizeof(seabios),
+struct bios_config seabios_config = {
+    .name = "SeaBIOS",
 
     .load_roms = NULL,
 
-    .bios_load = NULL,
+    .bios_load = seabios_load,
 
     .bios_info_setup = seabios_setup_bios_info,
     .bios_info_finish = seabios_finish_bios_info,
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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