WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 09 of 15] hvmloader: refactor BIOS info setup

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 09 of 15] hvmloader: refactor BIOS info setup
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Wed, 1 Jun 2011 10:40:04 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Wed, 01 Jun 2011 02:47:52 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1306921195@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1306921195@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1306917395 -3600
# Node ID 99820702549e428fd961b160afa1dae75bc7010d
# Parent  3c920f4ec4f24e1c134749972d5762aa009ee3dc
hvmloader: refactor BIOS info setup

Currently we have ->bios_high_setup, which is called relatively early and 
returns
a cookie which is passed to ->bios_info_setup which runs towards the end and
creates the BIOS info, incorporating the cookie which (in the case of ROMBIOS)
happens to be the BIOS's high load address . This is rather ROMBIOS specific.

Refactor to have ->bios_info_setup which is called early and prepares the
bios_info, ->bios_relocate which does any necessary relocation (updating the
BIOS info as necessary) and ->bios_info_finish which finalises the info (e.g.
by calculating the checksum).

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

diff -r 3c920f4ec4f2 -r 99820702549e tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Wed Jun 01 09:36:34 2011 +0100
+++ b/tools/firmware/hvmloader/config.h Wed Jun 01 09:36:35 2011 +0100
@@ -20,8 +20,10 @@ struct bios_config {
     int load_roms;
     unsigned int optionrom_start, optionrom_end;
 
-    uint32_t (*bios_high_setup)(void);
-    void (*bios_info_setup)(uint32_t);
+    void (*bios_info_setup)(void);
+    void (*bios_info_finish)(void);
+
+    void (*bios_relocate)(void);
 
     void (*vm86_setup)(void);
     void (*e820_setup)(void);
diff -r 3c920f4ec4f2 -r 99820702549e tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Wed Jun 01 09:36:34 2011 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Wed Jun 01 09:36:35 2011 +0100
@@ -383,7 +383,6 @@ static const struct bios_config *detect_
 
 int main(void)
 {
-    uint32_t highbios = 0;
     const struct bios_config *bios;
     int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0;
     uint32_t etherboot_phys_addr = 0, option_rom_phys_addr = 0;
@@ -409,6 +408,9 @@ int main(void)
 
     perform_tests();
 
+    if (bios->bios_info_setup)
+        bios->bios_info_setup();
+
     if (bios->create_smbios_tables) {
         printf("Writing SMBIOS tables ...\n");
         bios->create_smbios_tables();
@@ -418,8 +420,8 @@ int main(void)
     memcpy((void *)bios->bios_address, bios->image,
            bios->image_size);
 
-    if (bios->bios_high_setup)
-        highbios = bios->bios_high_setup();
+    if (bios->bios_relocate)
+        bios->bios_relocate();
 
     if ( bios->create_mp_tables &&
          ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) )
@@ -505,8 +507,8 @@ int main(void)
     if (bios->e820_setup)
         bios->e820_setup();
 
-    if (bios->bios_info_setup)
-        bios->bios_info_setup(highbios);
+    if (bios->bios_info_finish)
+        bios->bios_info_finish();
 
     xenbus_shutdown();
 
diff -r 3c920f4ec4f2 -r 99820702549e tools/firmware/hvmloader/rombios.c
--- a/tools/firmware/hvmloader/rombios.c        Wed Jun 01 09:36:34 2011 +0100
+++ b/tools/firmware/hvmloader/rombios.c        Wed Jun 01 09:36:35 2011 +0100
@@ -64,7 +64,7 @@ static void rombios_setup_e820(void)
     dump_e820_table(E820, *E820_NR);
 }
 
-static void rombios_setup_bios_info(uint32_t bioshigh)
+static void rombios_setup_bios_info(void)
 {
     struct bios_info *bios_info;
 
@@ -74,11 +74,28 @@ static void rombios_setup_bios_info(uint
     bios_info->com2_present = uart_exists(0x2f8);
     bios_info->lpt1_present = lpt_exists(0x378);
     bios_info->hpet_present = hpet_exists(ACPI_HPET_ADDRESS);
+    bios_info->madt_csum_addr = madt_csum_addr;
+    bios_info->madt_lapic0_addr = madt_lapic0_addr;
+}
+
+static void rombios_relocate(void)
+{
+    uint32_t bioshigh;
+    struct bios_info *bios_info;
+
+    bioshigh = rombios_highbios_setup();
+
+    bios_info = (struct bios_info *)BIOS_INFO_PHYSICAL_ADDRESS;
+    bios_info->bios32_entry = bioshigh;
+}
+
+static void rombios_finish_bios_info(void)
+{
+    struct bios_info *bios_info;
+
+    bios_info = (struct bios_info *)BIOS_INFO_PHYSICAL_ADDRESS;
     bios_info->pci_min = pci_mem_start;
     bios_info->pci_len = pci_mem_end - pci_mem_start;
-    bios_info->madt_csum_addr = madt_csum_addr;
-    bios_info->madt_lapic0_addr = madt_lapic0_addr;
-    bios_info->bios32_entry = bioshigh;
 }
 
 /*
@@ -158,8 +175,10 @@ struct bios_config rombios_config =  {
     .optionrom_start = OPTIONROM_PHYSICAL_ADDRESS,
     .optionrom_end = OPTIONROM_PHYSICAL_END,
 
-    .bios_high_setup = rombios_highbios_setup,
     .bios_info_setup = rombios_setup_bios_info,
+    .bios_info_finish = rombios_finish_bios_info,
+
+    .bios_relocate = rombios_relocate,
 
     .vm86_setup = rombios_init_vm86_tss,
     .e820_setup = rombios_setup_e820,
diff -r 3c920f4ec4f2 -r 99820702549e tools/firmware/hvmloader/seabios.c
--- a/tools/firmware/hvmloader/seabios.c        Wed Jun 01 09:36:34 2011 +0100
+++ b/tools/firmware/hvmloader/seabios.c        Wed Jun 01 09:36:35 2011 +0100
@@ -44,6 +44,9 @@ struct bios_config seabios_config = {
     .optionrom_end = 0,
 
     .bios_info_setup = NULL,
+    .bios_info_finish = NULL,
+
+    .bios_relocate = NULL,
 
     .vm86_setup = NULL,
     .e820_setup = NULL,

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

<Prev in Thread] Current Thread [Next in Thread>