]> xenbits.xensource.com Git - xen.git/commitdiff
tools: hvmloader: add bios_config data structure
authorIan Campbell <ian.campbell@citrix.com>
Tue, 12 Apr 2011 12:44:38 +0000 (13:44 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 12 Apr 2011 12:44:38 +0000 (13:44 +0100)
For now abstract away the actual ROM bits themselves and the various
load addresses.

Create a rombios.c to contain the ROMBIOS specific parts. ROMBIOS is
still statically selected for the time being.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
tools/firmware/hvmloader/Makefile
tools/firmware/hvmloader/config.h
tools/firmware/hvmloader/hvmloader.c
tools/firmware/hvmloader/rombios.c [new file with mode: 0644]

index 1192812fa854192fe5022f60e464cb6f4de3effb..87c8d0e32405dca14d23cfcc47f79bd7776f5a47 100644 (file)
@@ -37,7 +37,11 @@ endif
 
 CIRRUSVGA_DEBUG ?= n
 
-ROMBIOS_ROM   := ../rombios/BIOS-bochs-latest
+ROMBIOS_DIR := ../rombios
+ifneq ($(ROMBIOS_DIR),)
+OBJS += rombios.o
+ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest
+endif
 
 STDVGA_ROM    := ../vgabios/VGABIOS-lgpl-latest.bin
 ifeq ($(CIRRUSVGA_DEBUG),y)
@@ -62,17 +66,25 @@ roms.inc: $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) ../etherboot/eb-roms.h
        echo "/* Autogenerated file. DO NOT EDIT */" > roms.inc
 
 ifneq ($(ROMBIOS_ROM),)
+       echo "#ifdef ROM_INCLUDE_ROMBIOS" >> roms.inc
        sh ./mkhex rombios $(ROMBIOS_ROM) >> roms.inc
+       echo "#endif" >> roms.inc
 endif
 
 ifneq ($(STDVGA_ROM),)
+       echo "#ifdef ROM_INCLUDE_VGABIOS" >> roms.inc
        sh ./mkhex vgabios_stdvga $(STDVGA_ROM) >> roms.inc
+       echo "#endif" >> roms.inc
 endif
 ifneq ($(CIRRUSVGA_ROM),)
+       echo "#ifdef ROM_INCLUDE_VGABIOS" >> roms.inc
        sh ./mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> roms.inc
+       echo "#endif" >> roms.inc
 endif
 
+       echo "#ifdef ROM_INCLUDE_ETHERBOOT" >> roms.inc
        cat ../etherboot/eb-roms.h >> roms.inc
+       echo "#endif" >> roms.inc
 
 .PHONY: clean
 clean: subdirs-clean
index e7abe3b690f01adcfe71c6c375e4f09eabcdcb7f..39732396ea160bdbe36794f22510188bbca5a89b 100644 (file)
@@ -3,6 +3,28 @@
 
 #include <stdint.h>
 
+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;
+
+    /* SMBIOS */
+    unsigned int smbios_start, smbios_end;
+
+    /* Option ROMs */
+    unsigned int optionrom_start, optionrom_end;
+
+    /* ACPI tables */
+    unsigned int acpi_start;
+};
+
+extern struct bios_config rombios_config;
+
 #define PAGE_SHIFT 12
 #define PAGE_SIZE  (1ul << PAGE_SHIFT)
 
@@ -39,3 +61,13 @@ extern unsigned long pci_mem_start, pci_mem_end;
 #define VGABIOS_PHYSICAL_ADDRESS      0x000C0000
 
 #endif /* __HVMLOADER_CONFIG_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index 09bc5a331252a26ae9b348d53a5ba3e35cbe3501..9768afc8a5ad9cfa7cb9a76a57916e3f7b78d68f 100644 (file)
@@ -32,6 +32,8 @@
 #include <xen/hvm/ioreq.h>
 #include <xen/memory.h>
 
+#define ROM_INCLUDE_VGABIOS
+#define ROM_INCLUDE_ETHERBOOT
 #include "roms.inc"
 
 asm (
@@ -583,10 +585,15 @@ static void init_vm86_tss(void)
     printf("vm86 TSS at %08lx\n", virt_to_phys(tss));
 }
 
+static const struct bios_config *detect_bios(void)
+{
+    return &rombios_config;
+}
+
 int main(void)
 {
-    int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0;
-    int smbios_sz;
+    const struct bios_config *bios;
+    int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0, smbios_sz = 0;
     uint32_t etherboot_phys_addr, option_rom_phys_addr, bios32_addr;
     struct bios_info *bios_info;
 
@@ -594,9 +601,13 @@ int main(void)
 
     init_hypercalls();
 
+    xenbus_setup();
+
+    bios = detect_bios();
+    printf("System requested %s\n", bios->name);
+
     printf("CPU speed is %u MHz\n", get_cpu_mhz());
 
-    xenbus_setup();
     apic_setup();
     pci_setup();
 
@@ -604,13 +615,16 @@ int main(void)
 
     perform_tests();
 
-    printf("Writing SMBIOS tables ...\n");
-    smbios_sz = hvm_write_smbios_tables(SCRATCH_PHYSICAL_ADDRESS,
-                                        SMBIOS_PHYSICAL_ADDRESS,
-                                        SMBIOS_PHYSICAL_END);
+    if (bios->smbios_start) {
+        printf("Writing SMBIOS tables ...\n");
+        smbios_sz = hvm_write_smbios_tables(SCRATCH_PHYSICAL_ADDRESS,
+                                            bios->smbios_start,
+                                            bios->smbios_end);
+    }
 
-    printf("Loading ROMBIOS ...\n");
-    memcpy((void *)ROMBIOS_PHYSICAL_ADDRESS, rombios, sizeof(rombios));
+    printf("Loading %s ...\n", bios->name);
+    memcpy((void *)bios->bios_address, bios->image,
+           bios->image_size);
     bios32_addr = highbios_setup();
 
     if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
@@ -641,13 +655,13 @@ int main(void)
     }
 
     etherboot_phys_addr = VGABIOS_PHYSICAL_ADDRESS + vgabios_sz;
-    if ( etherboot_phys_addr < OPTIONROM_PHYSICAL_ADDRESS )
-        etherboot_phys_addr = OPTIONROM_PHYSICAL_ADDRESS;
-    etherboot_sz = scan_etherboot_nic(OPTIONROM_PHYSICAL_END,
+    if ( etherboot_phys_addr < bios->optionrom_start )
+        etherboot_phys_addr = bios->optionrom_start;
+    etherboot_sz = scan_etherboot_nic(bios->optionrom_end,
                                       etherboot_phys_addr);
 
     option_rom_phys_addr = etherboot_phys_addr + etherboot_sz;
-    option_rom_sz = pci_load_option_roms(OPTIONROM_PHYSICAL_END,
+    option_rom_sz = pci_load_option_roms(bios->optionrom_end,
                                          option_rom_phys_addr);
 
     if ( hvm_info->acpi_enabled )
@@ -659,7 +673,7 @@ int main(void)
         };
 
         printf("Loading ACPI ...\n");
-        acpi_build_tables(ACPI_PHYSICAL_ADDRESS);
+        acpi_build_tables(bios->acpi_start);
         hypercall_hvm_op(HVMOP_set_param, &p);
     }
 
@@ -682,11 +696,11 @@ int main(void)
                option_rom_phys_addr + option_rom_sz - 1);
     if ( smbios_sz )
         printf(" %05x-%05x: SMBIOS tables\n",
-               SMBIOS_PHYSICAL_ADDRESS,
-               SMBIOS_PHYSICAL_ADDRESS + smbios_sz - 1);
+               bios->smbios_start,
+               bios->smbios_start + smbios_sz - 1);
     printf(" %05x-%05x: Main BIOS\n",
-           ROMBIOS_PHYSICAL_ADDRESS,
-           ROMBIOS_PHYSICAL_ADDRESS + sizeof(rombios) - 1);
+           bios->bios_address,
+           bios->bios_address + bios->image_size - 1);
 
     *E820_NR = build_e820_table(E820);
     dump_e820_table(E820, *E820_NR);
@@ -705,7 +719,7 @@ int main(void)
 
     xenbus_shutdown();
 
-    printf("Invoking ROMBIOS ...\n");
+    printf("Invoking %s ...\n", bios->name);
     return 0;
 }
 
diff --git a/tools/firmware/hvmloader/rombios.c b/tools/firmware/hvmloader/rombios.c
new file mode 100644 (file)
index 0000000..fbd85cd
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * HVM ROMBIOS support.
+ *
+ * Leendert van Doorn, leendert@watson.ibm.com
+ * Copyright (c) 2005, International Business Machines Corporation.
+ * Copyright (c) 2006, Keir Fraser, XenSource Inc.
+ * Copyright (c) 2011, Citrix Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "config.h"
+
+#include "../rombios/config.h"
+
+#define ROM_INCLUDE_ROMBIOS
+#include "roms.inc"
+
+//BUILD_BUG_ON(sizeof(rombios) > (0x00100000U - ROMBIOS_PHYSICAL_ADDRESS));
+
+struct bios_config rombios_config =  {
+    .name = "ROMBIOS",
+
+    .image = rombios,
+    .image_size = sizeof(rombios),
+
+    .bios_address = ROMBIOS_PHYSICAL_ADDRESS,
+
+    .smbios_start = SMBIOS_PHYSICAL_ADDRESS,
+    .smbios_end = SMBIOS_PHYSICAL_END,
+
+    .optionrom_start = OPTIONROM_PHYSICAL_ADDRESS,
+    .optionrom_end = OPTIONROM_PHYSICAL_END,
+
+    .acpi_start = ACPI_PHYSICAL_ADDRESS,
+
+};
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */