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

[Xen-devel] [RFC PATCH v2 08/16] hvmloader: Locate the BIOS blob



The BIOS can be found in one of the entry of the modlist of the
hvm_start_info struct. The order of the modules are define by the command
line option "modules".

The found BIOS blob is not loaded by this patch, but only passed as
argument to bios_load() function. It is going to be used by the next few
patches.

Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 tools/firmware/hvmloader/config.h    |  2 +-
 tools/firmware/hvmloader/hvmloader.c | 34 +++++++++++++++++++++++++++++++++-
 tools/firmware/hvmloader/ovmf.c      |  3 ++-
 3 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/tools/firmware/hvmloader/config.h 
b/tools/firmware/hvmloader/config.h
index b838cf9..c4539cc 100644
--- a/tools/firmware/hvmloader/config.h
+++ b/tools/firmware/hvmloader/config.h
@@ -22,7 +22,7 @@ struct bios_config {
     /* 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 9df12ac..02d7f96 100644
--- a/tools/firmware/hvmloader/hvmloader.c
+++ b/tools/firmware/hvmloader/hvmloader.c
@@ -309,11 +309,39 @@ void cmdline_parser(const char *the_cmdline)
     }
 }
 
+const struct hvm_modlist_entry *get_module_entry(
+    const struct hvm_start_info *info,
+    const char *name)
+{
+    const char *p = module_list_order;
+    const char *q;
+    unsigned name_length = strlen(name);
+    unsigned current_module_nr = 0;
+    const struct hvm_modlist_entry *modlist =
+        (struct hvm_modlist_entry *)info->modlist_paddr;
+
+    if ( !module_list_order )
+        return NULL;
+
+    for ( ; *p && current_module_nr < info->nr_modules; p++ )
+    {
+        for ( q = p; *q && *q != ','; q++ )
+            ;
+        if ( !strncmp(name, p, max_t(unsigned, name_length, q - p)) )
+            return &modlist[current_module_nr];
+        p = q;
+        current_module_nr++;
+    }
+    printf("module '%s' not found\n", name);
+    return NULL;
+}
+
 int main(void)
 {
     const struct bios_config *bios;
     int acpi_enabled;
     const struct hvm_start_info *hvmlite_start_info;
+    const struct hvm_modlist_entry *bios_module;
 
     /* Load hvmlite start info pointer from ebx. */
     asm volatile ( "mov %%ebx,%0" : "=r" (hvmlite_start_info) );
@@ -353,9 +381,13 @@ int main(void)
         bios->create_smbios_tables();
     }
 
+    // XXX check that the values exist and are correct
+    bios_module = get_module_entry(hvmlite_start_info, "bios");
+    BUG_ON(!bios_module);
+
     printf("Loading %s ...\n", bios->name);
     if ( bios->bios_load )
-        bios->bios_load(bios);
+        bios->bios_load(bios, (void*)(bios_module->paddr), bios_module->size);
     else
     {
         BUG_ON(bios->bios_address + bios->image_size >
diff --git a/tools/firmware/hvmloader/ovmf.c b/tools/firmware/hvmloader/ovmf.c
index bb3da93..2be9752 100644
--- a/tools/firmware/hvmloader/ovmf.c
+++ b/tools/firmware/hvmloader/ovmf.c
@@ -93,7 +93,8 @@ static void ovmf_finish_bios_info(void)
     info->checksum = -checksum;
 }
 
-static void ovmf_load(const struct bios_config *config)
+static void ovmf_load(const struct bios_config *config,
+                      void *bios_addr, uint32_t bios_length)
 {
     xen_pfn_t mfn;
     uint64_t addr = OVMF_BEGIN;
-- 
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®.