hvmloader: refactor BIOS info setup
authorIan Campbell <ian.campbell@citrix.com>
Wed, 1 Jun 2011 15:47:04 +0000 (16:47 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 1 Jun 2011 15:47:04 +0000 (16:47 +0100)
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@citrix.com>
tools/firmware/hvmloader/config.h
tools/firmware/hvmloader/hvmloader.c
tools/firmware/hvmloader/rombios.c
tools/firmware/hvmloader/seabios.c

index afce05bbb17d09e49b46c1557406cb9d7c97336b..2ef5d6da1839e7c9aaa54649c2d774578ed051b6 100644 (file)
@@ -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);
index 89407964e7e8e5a9b208460913c9d375c1d59314..401d381b2387053b78dff87c0eed9ec430a98a2e 100644 (file)
@@ -383,7 +383,6 @@ static const struct bios_config *detect_bios(void)
 
 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();
 
index b4006263afac94775833f0a88c97871a02c576bf..a3b566781532f8a3934457aa980373bcdc9b7995 100644 (file)
@@ -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,13 +74,30 @@ static void rombios_setup_bios_info(uint32_t bioshigh)
     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->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;
+}
+
+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;
+}
+
 /*
  * find_mp_table_start - searchs through BIOS memory for '___HVMMP' signature
  *
@@ -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,
index 53cc01ed63d2edf5ad39390a487ac66c80f62c2f..0bc1975c22c6c3406feeacb9f6b190a1c9c0f4f4 100644 (file)
@@ -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,