# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1302612278 -3600
# Node ID 4f06dfe5d75096892404bb952e801c15b7a6f930
# Parent 560187ccaf95399b53aea5248346f1fc8cffbf7c
tools: hvmloader: add bios_config data structure
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@xxxxxxxxxx>
Acked-by: Keir Fraser <keir@xxxxxxx>
---
diff -r 560187ccaf95 -r 4f06dfe5d750 tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Tue Apr 12 13:43:45 2011 +0100
+++ b/tools/firmware/hvmloader/Makefile Tue Apr 12 13:44:38 2011 +0100
@@ -37,7 +37,11 @@
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 @@
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
diff -r 560187ccaf95 -r 4f06dfe5d750 tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Tue Apr 12 13:43:45 2011 +0100
+++ b/tools/firmware/hvmloader/config.h Tue Apr 12 13:44:38 2011 +0100
@@ -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 @@
#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:
+ */
diff -r 560187ccaf95 -r 4f06dfe5d750 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 13:43:45 2011 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 13:44:38 2011 +0100
@@ -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 @@
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 @@
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 @@
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 @@
}
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 @@
};
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 @@
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 @@
xenbus_shutdown();
- printf("Invoking ROMBIOS ...\n");
+ printf("Invoking %s ...\n", bios->name);
return 0;
}
diff -r 560187ccaf95 -r 4f06dfe5d750 tools/firmware/hvmloader/rombios.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/hvmloader/rombios.c Tue Apr 12 13:44:38 2011 +0100
@@ -0,0 +1,58 @@
+/*
+ * HVM ROMBIOS support.
+ *
+ * Leendert van Doorn, leendert@xxxxxxxxxxxxxx
+ * 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:
+ */
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|