Julian Pidancet
2012-Feb-11 20:39 UTC
[PATCH v3 0/5] hvmloader: Make ROM dependencies optional
This patch set mainly allows the user to build a seabios or rombios only version of hvmloader. In addition, when building a seabios only hvmloader, Option ROMs like vgabios and etherboot are no longer required, and therefore can be disabled from the build. Dependency on the bcc compiler can also be avoided the same way. v2: Separate patches for separate issues Introduced config option to select which NIC to build ROM for Fixed initial patch to build multiple etherboot ROMs in hvmloader Option ROMs are keyed off wether or not rombios is enabled, rather than on an individual basis Introduced config options to select support for rombios/seabios v3: Fix mkhex script to take several file arguments on the command line Reorganize hvmloader option ROM loading code to make it optionnal, and make bios->load_roms a callback that the BIOS support code has to implement if option ROM loading is desired. Cosmetic change in tools/firmware/Makefile in the way seabios-dir is created. Julian Pidancet (5): hvmloader: Only compile 32bitbios_support.c when rombios is enabled hvmloader: Allow the mkhex command to take several file arguments firmware: Use mkhex from hvmloader directory for etherboot ROMs hvmloader: Move option ROM loading into a separate optionnal file firmware: Introduce CONFIG_ROMBIOS and CONFIG_SEABIOS options Config.mk | 5 + tools/firmware/Makefile | 18 ++-- tools/firmware/etherboot/Config | 2 - tools/firmware/etherboot/Makefile | 13 +-- tools/firmware/hvmloader/Makefile | 39 ++++--- tools/firmware/hvmloader/config.h | 3 +- tools/firmware/hvmloader/hvmloader.c | 218 +-------------------------------- tools/firmware/hvmloader/mkhex | 3 +- tools/firmware/hvmloader/option_rom.h | 7 + tools/firmware/hvmloader/optionroms.c | 189 ++++++++++++++++++++++++++++ tools/firmware/hvmloader/rombios.c | 63 +++++++++- tools/firmware/hvmloader/seabios.c | 5 +- 12 files changed, 302 insertions(+), 263 deletions(-) create mode 100644 tools/firmware/hvmloader/optionroms.c -- Julian Pidancet
Julian Pidancet
2012-Feb-11 20:39 UTC
[PATCH v3 1/5] hvmloader: Only compile 32bitbios_support.c when rombios is enabled
32bitbios_support.c only contains code specific to rombios, and should not be built-in when building hvmloader for SeaBIOS only (as for rombios.c). Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com> --- tools/firmware/hvmloader/Makefile | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile index 41a4369..e82146a 100644 --- a/tools/firmware/hvmloader/Makefile +++ b/tools/firmware/hvmloader/Makefile @@ -29,7 +29,7 @@ LOADADDR = 0x100000 CFLAGS += $(CFLAGS_xeninclude) OBJS = hvmloader.o mp_tables.o util.o smbios.o -OBJS += 32bitbios_support.o smp.o cacheattr.o xenbus.o +OBJS += smp.o cacheattr.o xenbus.o OBJS += e820.o pci.o pir.o ctype.o ifeq ($(debug),y) OBJS += tests.o @@ -39,7 +39,7 @@ CIRRUSVGA_DEBUG ?= n ROMBIOS_DIR := ../rombios ifneq ($(ROMBIOS_DIR),) -OBJS += rombios.o +OBJS += 32bitbios_support.o rombios.o CFLAGS += -DENABLE_ROMBIOS ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest endif -- Julian Pidancet
Julian Pidancet
2012-Feb-11 20:39 UTC
[PATCH v3 2/5] hvmloader: Allow the mkhex command to take several file arguments
Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com> --- tools/firmware/hvmloader/mkhex | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/tools/firmware/hvmloader/mkhex b/tools/firmware/hvmloader/mkhex index 4517e36..cb21257 100755 --- a/tools/firmware/hvmloader/mkhex +++ b/tools/firmware/hvmloader/mkhex @@ -21,6 +21,7 @@ # echo "unsigned $1[] = {" -od -v -t x $2 | sed ''s/^[0-9]* */0x/'' | sed ''s/ */, 0x/g'' | sed ''s/$/,/'' | sed ''s/0x,//'' | sed ''s/^[0-9]*,//'' +shift +od -v -t x $@ | sed ''s/^[0-9]* */0x/'' | sed ''s/ */, 0x/g'' | sed ''s/$/,/'' | sed ''s/0x,//'' | sed ''s/^[0-9]*,//'' echo "};" -- Julian Pidancet
Julian Pidancet
2012-Feb-11 20:39 UTC
[PATCH v3 3/5] firmware: Use mkhex from hvmloader directory for etherboot ROMs
To remain consistent with how other ROMs are built into hvmloader, call mkhex on etherboot ROMs from the hvmloader directory, instead of the etherboot directory. In other words, eb-roms.h is not used any more. Introduce ETHERBOOT_NICS config option to choose which ROMs should be built (kept rtl8139 and 8086100e per default as before). Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com> --- Config.mk | 2 ++ tools/firmware/etherboot/Config | 2 -- tools/firmware/etherboot/Makefile | 13 +++---------- tools/firmware/hvmloader/Makefile | 9 ++++++--- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Config.mk b/Config.mk index e2dc4b9..42508b8 100644 --- a/Config.mk +++ b/Config.mk @@ -222,6 +222,8 @@ endif QEMU_UPSTREAM_REVISION ?= master SEABIOS_UPSTREAM_TAG ?= rel-1.6.3.1 +ETHERBOOT_NICS ?= rtl8139 8086100e + # Specify which qemu-dm to use. This may be `ioemu'' to use the old # Mercurial in-tree version, or a local directory, or a git URL. # CONFIG_QEMU ?= `pwd`/$(XEN_ROOT)/../qemu-xen.git diff --git a/tools/firmware/etherboot/Config b/tools/firmware/etherboot/Config index 143914f..69963b9 100644 --- a/tools/firmware/etherboot/Config +++ b/tools/firmware/etherboot/Config @@ -1,6 +1,4 @@ -NICS = rtl8139 8086100e - CFLAGS += -UPXE_DHCP_STRICT CFLAGS += -DPXE_DHCP_STRICT diff --git a/tools/firmware/etherboot/Makefile b/tools/firmware/etherboot/Makefile index c09140e..a195888 100644 --- a/tools/firmware/etherboot/Makefile +++ b/tools/firmware/etherboot/Makefile @@ -17,23 +17,16 @@ IPXE_TARBALL_URL := $(XEN_EXTFILES_URL)/ipxe-git-$(IPXE_GIT_TAG).tar.gz D=ipxe T=ipxe.tar.gz -ROMS = $(addprefix $D/src/bin/, $(addsuffix .rom, $(NICS))) +ROMS = $(addprefix $D/src/bin/, $(addsuffix .rom, $(ETHERBOOT_NICS))) .NOTPARALLEL: .PHONY: all -all: eb-roms.h +all: $(ROMS) %.rom: $D/src/arch/i386/Makefile $(MAKE) -C $D/src bin/$(*F).rom -eb-roms.h.new: $(ROMS) - cat $^ | ../hvmloader/mkhex etherboot >$@ - -eb-roms.h: Config - $(MAKE) NO_WERROR=1 $@.new - mv -f $@.new $@ - $T: if ! wget -O _$T $(IPXE_TARBALL_URL); then \ $(GIT) clone $(IPXE_GIT_URL) $D.git; \ @@ -56,7 +49,7 @@ $D/src/bin/NIC: $D/src/arch/i386/Makefile .PHONY: clean clean: - rm -rf $D $D.git *~ eb-roms.h _$T $T + rm -rf $D $D.git *~ _$T $T .PHONY: distclean distclean: clean diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile index e82146a..1ea32db 100644 --- a/tools/firmware/hvmloader/Makefile +++ b/tools/firmware/hvmloader/Makefile @@ -58,6 +58,8 @@ else CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.bin endif +ETHERBOOT_ROMS := $(addprefix ../etherboot/ipxe/src/bin/, $(addsuffix .rom, $(ETHERBOOT_NICS))) + .PHONY: all all: subdirs-all $(MAKE) hvmloader @@ -70,7 +72,7 @@ hvmloader: $(OBJS) acpi/acpi.a $(OBJCOPY) hvmloader.tmp hvmloader rm -f hvmloader.tmp -roms.inc: $(ROMBIOS_ROM) $(SEABIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) ../etherboot/eb-roms.h +roms.inc: $(ROMBIOS_ROM) $(SEABIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS) echo "/* Autogenerated file. DO NOT EDIT */" > $@.new ifneq ($(ROMBIOS_ROM),) @@ -95,10 +97,11 @@ ifneq ($(CIRRUSVGA_ROM),) sh ./mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> $@.new echo "#endif" >> $@.new endif - +ifneq ($(ETHERBOOT_ROMS),) echo "#ifdef ROM_INCLUDE_ETHERBOOT" >> $@.new - cat ../etherboot/eb-roms.h >> $@.new + sh ./mkhex etherboot $(ETHERBOOT_ROMS) >> $@.new echo "#endif" >> $@.new +endif mv $@.new $@ -- Julian Pidancet
Julian Pidancet
2012-Feb-11 20:39 UTC
[PATCH v3 4/5] hvmloader: Move option ROM loading into a separate optionnal file
Make load_rom field in struct bios_config an optionnal callback rather than a boolean value. It allow BIOS specific code to implement it''s own option ROM loading methods. Facilities to scan PCI devices, extract an deploy ROMs are moved into a separate file that can be compiled optionnaly. Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com> --- tools/firmware/hvmloader/Makefile | 2 +- tools/firmware/hvmloader/config.h | 3 +- tools/firmware/hvmloader/hvmloader.c | 218 +-------------------------------- tools/firmware/hvmloader/option_rom.h | 7 + tools/firmware/hvmloader/optionroms.c | 189 ++++++++++++++++++++++++++++ tools/firmware/hvmloader/rombios.c | 63 +++++++++- tools/firmware/hvmloader/seabios.c | 5 +- 7 files changed, 259 insertions(+), 228 deletions(-) create mode 100644 tools/firmware/hvmloader/optionroms.c diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile index 1ea32db..5a5ee41 100644 --- a/tools/firmware/hvmloader/Makefile +++ b/tools/firmware/hvmloader/Makefile @@ -39,7 +39,7 @@ CIRRUSVGA_DEBUG ?= n ROMBIOS_DIR := ../rombios ifneq ($(ROMBIOS_DIR),) -OBJS += 32bitbios_support.o rombios.o +OBJS += optionroms.o 32bitbios_support.o rombios.o CFLAGS += -DENABLE_ROMBIOS ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest endif diff --git a/tools/firmware/hvmloader/config.h b/tools/firmware/hvmloader/config.h index 9cac9c1..1f80263 100644 --- a/tools/firmware/hvmloader/config.h +++ b/tools/firmware/hvmloader/config.h @@ -18,8 +18,7 @@ struct bios_config { unsigned int bios_address; /* ROMS */ - int load_roms; - unsigned int optionrom_start, optionrom_end; + void (*load_roms)(void); void (*bios_load)(const struct bios_config *config); diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index f120ffe..ad50189 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -24,16 +24,11 @@ #include "hypercall.h" #include "config.h" #include "pci_regs.h" -#include "option_rom.h" #include "apic_regs.h" #include "acpi/acpi2_0.h" #include <xen/version.h> #include <xen/hvm/params.h> -#define ROM_INCLUDE_VGABIOS -#define ROM_INCLUDE_ETHERBOOT -#include "roms.inc" - asm ( " .text \n" " .globl _start \n" @@ -147,169 +142,6 @@ static void init_hypercalls(void) printf("Detected Xen v%u.%u%s\n", eax >> 16, eax & 0xffff, extraversion); } -/* - * Scan the list of Option ROMs at @roms for one which supports - * PCI (@vendor_id, @device_id) found at slot @devfn. If one is found, - * copy it to @dest and return its size rounded up to a multiple 2kB. This - * function will not copy ROMs beyond address option_rom_end. - */ -#define round_option_rom(x) (((x) + 2047) & ~2047) -static int scan_option_rom( - unsigned int option_rom_end, - uint8_t devfn, uint16_t vendor_id, uint16_t device_id, - void *roms, uint32_t dest) -{ - struct option_rom_header *rom; - struct option_rom_pnp_header *pnph; - struct option_rom_pci_header *pcih; - uint8_t csum; - int i; - - static uint32_t orom_ids[64]; - static int nr_roms; - - /* Avoid duplicate ROMs. */ - for ( i = 0; i < nr_roms; i++ ) - if ( orom_ids[i] == (vendor_id | ((uint32_t)device_id << 16)) ) - return 0; - - rom = roms; - for ( ; ; ) - { - /* Invalid signature means we''re out of option ROMs. */ - if ( strncmp((char *)rom->signature, "\x55\xaa", 2) || - (rom->rom_size == 0) ) - break; - - /* Invalid checksum means we''re out of option ROMs. */ - csum = 0; - for ( i = 0; i < (rom->rom_size * 512); i++ ) - csum += ((uint8_t *)rom)[i]; - if ( csum != 0 ) - break; - - /* Check the PCI PnP header (if any) for a match. */ - pcih = (struct option_rom_pci_header *) - ((char *)rom + rom->pci_header_offset); - if ( (rom->pci_header_offset != 0) && - !strncmp((char *)pcih->signature, "PCIR", 4) && - (pcih->vendor_id == vendor_id) && - (pcih->device_id == device_id) ) - goto found; - - rom = (struct option_rom_header *) - ((char *)rom + rom->rom_size * 512); - } - - return 0; - - found: - /* Find the PnP expansion header (if any). */ - pnph = ((rom->expansion_header_offset != 0) - ? ((struct option_rom_pnp_header *) - ((char *)rom + rom->expansion_header_offset)) - : ((struct option_rom_pnp_header *)NULL)); - while ( (pnph != NULL) && strncmp((char *)pnph->signature, "$PnP", 4) ) - pnph = ((pnph->next_header_offset != 0) - ? ((struct option_rom_pnp_header *) - ((char *)rom + pnph->next_header_offset)) - : ((struct option_rom_pnp_header *)NULL)); - - printf("Loading PCI Option ROM ...\n"); - if ( (pnph != NULL) && (pnph->manufacturer_name_offset != 0) ) - printf(" - Manufacturer: %s\n", - (char *)rom + pnph->manufacturer_name_offset); - if ( (pnph != NULL) && (pnph->product_name_offset != 0) ) - printf(" - Product name: %s\n", - (char *)rom + pnph->product_name_offset); - - if ( (dest + rom->rom_size * 512 + 1) > option_rom_end ) - { - printf("Option ROM size %x exceeds available space\n", - rom->rom_size * 512); - return 0; - } - - orom_ids[nr_roms++] = vendor_id | ((uint32_t)device_id << 16); - memcpy((void *)dest, rom, rom->rom_size * 512); - *(uint8_t *)(dest + rom->rom_size * 512) = devfn; - return round_option_rom(rom->rom_size * 512 + 1); -} - -/* - * Scan the PCI bus for the first NIC supported by etherboot, and copy - * the corresponding rom data to *copy_rom_dest. Returns the length of the - * selected rom, or 0 if no NIC found. - */ -static int scan_etherboot_nic(unsigned int option_rom_end, - uint32_t copy_rom_dest) -{ - uint16_t class, vendor_id, device_id, devfn; - int rom_size = 0; - - for ( devfn = 0; (devfn < 256) && !rom_size; devfn++ ) - { - class = pci_readw(devfn, PCI_CLASS_DEVICE); - vendor_id = pci_readw(devfn, PCI_VENDOR_ID); - device_id = pci_readw(devfn, PCI_DEVICE_ID); - - /* We''re only interested in NICs. */ - if ( (vendor_id != 0xffff) && - (device_id != 0xffff) && - (class == 0x0200) ) - rom_size = scan_option_rom( - option_rom_end, - devfn, vendor_id, device_id, etherboot, copy_rom_dest); - } - - return rom_size; -} - -/* - * Scan the PCI bus for the devices that have an option ROM, and copy - * the corresponding rom data to rom_phys_addr. - */ -static int pci_load_option_roms(unsigned int option_rom_end, - uint32_t rom_base_addr) -{ - uint32_t option_rom_addr, rom_phys_addr = rom_base_addr; - uint16_t vendor_id, device_id, devfn, class; - - for ( devfn = 0; devfn < 256; devfn++ ) - { - class = pci_readb(devfn, PCI_CLASS_DEVICE + 1); - vendor_id = pci_readw(devfn, PCI_VENDOR_ID); - device_id = pci_readw(devfn, PCI_DEVICE_ID); - - if ( (vendor_id == 0xffff) && (device_id == 0xffff) ) - continue; - - /* - * Currently only scan options from mass storage devices and serial - * bus controller (Fibre Channel included). - */ - if ( (class != 0x1) && (class != 0xc) ) - continue; - - option_rom_addr = pci_readl(devfn, PCI_ROM_ADDRESS); - if ( !option_rom_addr ) - continue; - - /* Ensure Expansion Bar is enabled before copying */ - pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr | 0x1); - - rom_phys_addr += scan_option_rom( - option_rom_end, - devfn, vendor_id, device_id, - (void *)(option_rom_addr & ~2047), rom_phys_addr); - - /* Restore the default original value of Expansion Bar */ - pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr); - } - - return rom_phys_addr - rom_base_addr; -} - /* Replace possibly erroneous memory-size CMOS fields with correct values. */ static void cmos_write_memory_size(void) { @@ -421,8 +253,6 @@ static void acpi_enable_sci(void) int main(void) { 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; int acpi_enabled; /* Initialise hypercall stubs with RET, rendering them no-ops. */ @@ -471,41 +301,7 @@ int main(void) } if ( bios->load_roms ) - { - switch ( virtual_vga ) - { - case VGA_cirrus: - printf("Loading Cirrus VGABIOS ...\n"); - memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, - vgabios_cirrusvga, sizeof(vgabios_cirrusvga)); - vgabios_sz = round_option_rom(sizeof(vgabios_cirrusvga)); - break; - case VGA_std: - printf("Loading Standard VGABIOS ...\n"); - memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, - vgabios_stdvga, sizeof(vgabios_stdvga)); - vgabios_sz = round_option_rom(sizeof(vgabios_stdvga)); - break; - case VGA_pt: - printf("Loading VGABIOS of passthroughed gfx ...\n"); - vgabios_sz = round_option_rom( - (*(uint8_t *)(VGABIOS_PHYSICAL_ADDRESS+2)) * 512); - break; - default: - printf("No emulated VGA adaptor ...\n"); - break; - } - - etherboot_phys_addr = VGABIOS_PHYSICAL_ADDRESS + vgabios_sz; - 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(bios->optionrom_end, - option_rom_phys_addr); - } + bios->load_roms(); acpi_enabled = !strncmp(xenstore_read("platform/acpi", "1"), "1", 1); @@ -536,18 +332,6 @@ int main(void) if ( SCRATCH_PHYSICAL_ADDRESS != scratch_start ) printf(" %05x-%05lx: Scratch space\n", SCRATCH_PHYSICAL_ADDRESS, scratch_start); - if ( vgabios_sz ) - printf(" %05x-%05x: VGA BIOS\n", - VGABIOS_PHYSICAL_ADDRESS, - VGABIOS_PHYSICAL_ADDRESS + vgabios_sz - 1); - if ( etherboot_sz ) - printf(" %05x-%05x: Etherboot ROM\n", - etherboot_phys_addr, - etherboot_phys_addr + etherboot_sz - 1); - if ( option_rom_sz ) - printf(" %05x-%05x: PCI Option ROMs\n", - option_rom_phys_addr, - option_rom_phys_addr + option_rom_sz - 1); printf(" %05x-%05x: Main BIOS\n", bios->bios_address, bios->bios_address + bios->image_size - 1); diff --git a/tools/firmware/hvmloader/option_rom.h b/tools/firmware/hvmloader/option_rom.h index f0c7ec4..1ada3e2 100644 --- a/tools/firmware/hvmloader/option_rom.h +++ b/tools/firmware/hvmloader/option_rom.h @@ -47,6 +47,13 @@ struct option_rom_pci_header { uint16_t reserved; } __attribute__ ((packed)); +#define round_option_rom(x) (((x) + 2047) & ~2047) +int scan_etherboot_nic(unsigned int option_rom_end, + uint32_t copy_rom_dest, + void *etherboot_rom); +int pci_load_option_roms(unsigned int option_rom_end, + uint32_t rom_base_addr); + #endif /* __HVMLOADER_OPTION_ROM_H__ */ /* diff --git a/tools/firmware/hvmloader/optionroms.c b/tools/firmware/hvmloader/optionroms.c new file mode 100644 index 0000000..e35aebc --- /dev/null +++ b/tools/firmware/hvmloader/optionroms.c @@ -0,0 +1,189 @@ +/* + * optionroms.c: Option ROM loading support. + * + * Leendert van Doorn, leendert@watson.ibm.com + * Copyright (c) 2005, International Business Machines Corporation. + * + * Copyright (c) 2006, Keir Fraser, XenSource 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 "option_rom.h" +#include "util.h" +#include "pci_regs.h" + +/* + * Scan the list of Option ROMs at @roms for one which supports + * PCI (@vendor_id, @device_id) found at slot @devfn. If one is found, + * copy it to @dest and return its size rounded up to a multiple 2kB. This + * function will not copy ROMs beyond address option_rom_end. + */ +static int scan_option_rom( + unsigned int option_rom_end, + uint8_t devfn, uint16_t vendor_id, uint16_t device_id, + void *roms, uint32_t dest) +{ + struct option_rom_header *rom; + struct option_rom_pnp_header *pnph; + struct option_rom_pci_header *pcih; + uint8_t csum; + int i; + + static uint32_t orom_ids[64]; + static int nr_roms; + + /* Avoid duplicate ROMs. */ + for ( i = 0; i < nr_roms; i++ ) + if ( orom_ids[i] == (vendor_id | ((uint32_t)device_id << 16)) ) + return 0; + + rom = roms; + for ( ; ; ) + { + /* Invalid signature means we''re out of option ROMs. */ + if ( strncmp((char *)rom->signature, "\x55\xaa", 2) || + (rom->rom_size == 0) ) + break; + + /* Invalid checksum means we''re out of option ROMs. */ + csum = 0; + for ( i = 0; i < (rom->rom_size * 512); i++ ) + csum += ((uint8_t *)rom)[i]; + if ( csum != 0 ) + break; + + /* Check the PCI PnP header (if any) for a match. */ + pcih = (struct option_rom_pci_header *) + ((char *)rom + rom->pci_header_offset); + if ( (rom->pci_header_offset != 0) && + !strncmp((char *)pcih->signature, "PCIR", 4) && + (pcih->vendor_id == vendor_id) && + (pcih->device_id == device_id) ) + goto found; + + rom = (struct option_rom_header *) + ((char *)rom + rom->rom_size * 512); + } + + return 0; + + found: + /* Find the PnP expansion header (if any). */ + pnph = ((rom->expansion_header_offset != 0) + ? ((struct option_rom_pnp_header *) + ((char *)rom + rom->expansion_header_offset)) + : ((struct option_rom_pnp_header *)NULL)); + while ( (pnph != NULL) && strncmp((char *)pnph->signature, "$PnP", 4) ) + pnph = ((pnph->next_header_offset != 0) + ? ((struct option_rom_pnp_header *) + ((char *)rom + pnph->next_header_offset)) + : ((struct option_rom_pnp_header *)NULL)); + + printf("Loading PCI Option ROM ...\n"); + if ( (pnph != NULL) && (pnph->manufacturer_name_offset != 0) ) + printf(" - Manufacturer: %s\n", + (char *)rom + pnph->manufacturer_name_offset); + if ( (pnph != NULL) && (pnph->product_name_offset != 0) ) + printf(" - Product name: %s\n", + (char *)rom + pnph->product_name_offset); + + if ( (dest + rom->rom_size * 512 + 1) > option_rom_end ) + { + printf("Option ROM size %x exceeds available space\n", + rom->rom_size * 512); + return 0; + } + + orom_ids[nr_roms++] = vendor_id | ((uint32_t)device_id << 16); + memcpy((void *)dest, rom, rom->rom_size * 512); + *(uint8_t *)(dest + rom->rom_size * 512) = devfn; + return round_option_rom(rom->rom_size * 512 + 1); +} + +/* + * Scan the PCI bus for the first NIC supported by etherboot, and copy + * the corresponding rom data to *copy_rom_dest. Returns the length of the + * selected rom, or 0 if no NIC found. + */ +int scan_etherboot_nic(unsigned int option_rom_end, + uint32_t copy_rom_dest, + void *etherboot_rom) +{ + uint16_t class, vendor_id, device_id, devfn; + int rom_size = 0; + + for ( devfn = 0; (devfn < 256) && !rom_size; devfn++ ) + { + class = pci_readw(devfn, PCI_CLASS_DEVICE); + vendor_id = pci_readw(devfn, PCI_VENDOR_ID); + device_id = pci_readw(devfn, PCI_DEVICE_ID); + + /* We''re only interested in NICs. */ + if ( (vendor_id != 0xffff) && + (device_id != 0xffff) && + (class == 0x0200) ) + rom_size = scan_option_rom( + option_rom_end, + devfn, vendor_id, device_id, etherboot_rom, copy_rom_dest); + } + + return rom_size; +} + +/* + * Scan the PCI bus for the devices that have an option ROM, and copy + * the corresponding rom data to rom_phys_addr. + */ +int pci_load_option_roms(unsigned int option_rom_end, + uint32_t rom_base_addr) +{ + uint32_t option_rom_addr, rom_phys_addr = rom_base_addr; + uint16_t vendor_id, device_id, devfn, class; + + for ( devfn = 0; devfn < 256; devfn++ ) + { + class = pci_readb(devfn, PCI_CLASS_DEVICE + 1); + vendor_id = pci_readw(devfn, PCI_VENDOR_ID); + device_id = pci_readw(devfn, PCI_DEVICE_ID); + + if ( (vendor_id == 0xffff) && (device_id == 0xffff) ) + continue; + + /* + * Currently only scan options from mass storage devices and serial + * bus controller (Fibre Channel included). + */ + if ( (class != 0x1) && (class != 0xc) ) + continue; + + option_rom_addr = pci_readl(devfn, PCI_ROM_ADDRESS); + if ( !option_rom_addr ) + continue; + + /* Ensure Expansion Bar is enabled before copying */ + pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr | 0x1); + + rom_phys_addr += scan_option_rom( + option_rom_end, + devfn, vendor_id, device_id, + (void *)(option_rom_addr & ~2047), rom_phys_addr); + + /* Restore the default original value of Expansion Bar */ + pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr); + } + + return rom_phys_addr - rom_base_addr; +} diff --git a/tools/firmware/hvmloader/rombios.c b/tools/firmware/hvmloader/rombios.c index d5831aa..e0d4182 100644 --- a/tools/firmware/hvmloader/rombios.c +++ b/tools/firmware/hvmloader/rombios.c @@ -29,10 +29,13 @@ #include "pci_regs.h" #include "util.h" #include "hypercall.h" +#include "option_rom.h" #include <xen/hvm/params.h> #define ROM_INCLUDE_ROMBIOS +#define ROM_INCLUDE_VGABIOS +#define ROM_INCLUDE_ETHERBOOT #include "roms.inc" #define ROMBIOS_BEGIN 0x000F0000 @@ -64,6 +67,61 @@ static void rombios_setup_bios_info(void) memset(info, 0, sizeof(*info)); } +static void rombios_load_roms(void) +{ + int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0; + uint32_t etherboot_phys_addr = 0, option_rom_phys_addr = 0; + + switch ( virtual_vga ) + { + case VGA_cirrus: + printf("Loading Cirrus VGABIOS ...\n"); + memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, + vgabios_cirrusvga, sizeof(vgabios_cirrusvga)); + vgabios_sz = round_option_rom(sizeof(vgabios_cirrusvga)); + break; + case VGA_std: + printf("Loading Standard VGABIOS ...\n"); + memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, + vgabios_stdvga, sizeof(vgabios_stdvga)); + vgabios_sz = round_option_rom(sizeof(vgabios_stdvga)); + break; + case VGA_pt: + printf("Loading VGABIOS of passthroughed gfx ...\n"); + vgabios_sz = round_option_rom( + (*(uint8_t *)(VGABIOS_PHYSICAL_ADDRESS+2)) * 512); + break; + default: + printf("No emulated VGA adaptor ...\n"); + break; + } + + 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, + etherboot_phys_addr, + etherboot); + + option_rom_phys_addr = etherboot_phys_addr + etherboot_sz; + option_rom_sz = pci_load_option_roms(OPTIONROM_PHYSICAL_END, + option_rom_phys_addr); + + printf("Option ROMs:\n"); + if ( vgabios_sz ) + printf(" %05x-%05x: VGA BIOS\n", + VGABIOS_PHYSICAL_ADDRESS, + VGABIOS_PHYSICAL_ADDRESS + vgabios_sz - 1); + if ( etherboot_sz ) + printf(" %05x-%05x: Etherboot ROM\n", + etherboot_phys_addr, + etherboot_phys_addr + etherboot_sz - 1); + if ( option_rom_sz ) + printf(" %05x-%05x: PCI Option ROMs\n", + option_rom_phys_addr, + option_rom_phys_addr + option_rom_sz - 1); +} + static void rombios_load(const struct bios_config *config) { uint32_t bioshigh; @@ -158,10 +216,7 @@ struct bios_config rombios_config = { .bios_address = ROMBIOS_PHYSICAL_ADDRESS, - .load_roms = 1, - - .optionrom_start = OPTIONROM_PHYSICAL_ADDRESS, - .optionrom_end = OPTIONROM_PHYSICAL_END, + .load_roms = rombios_load_roms, .bios_load = rombios_load, diff --git a/tools/firmware/hvmloader/seabios.c b/tools/firmware/hvmloader/seabios.c index 3045157..15ddf35 100644 --- a/tools/firmware/hvmloader/seabios.c +++ b/tools/firmware/hvmloader/seabios.c @@ -143,10 +143,7 @@ struct bios_config seabios_config = { .bios_address = SEABIOS_PHYSICAL_ADDRESS, - .load_roms = 0, - - .optionrom_start = 0, - .optionrom_end = 0, + .load_roms = NULL, .bios_load = NULL, -- Julian Pidancet
Julian Pidancet
2012-Feb-11 20:39 UTC
[PATCH v3 5/5] firmware: Introduce CONFIG_ROMBIOS and CONFIG_SEABIOS options
This patch introduces configuration options allowing to built either a rombios only or a seabios only hvmloader. Building option ROMs like vgabios or etherboot is only enabled for a rombios hvmloader, since SeaBIOS takes care or extracting option ROMs itself from the PCI devices (these option ROMs are provided by the device model and do not need to be built in hvmloader). The Makefile in tools/firmware/ now only checks for bcc if rombios is enabled. These two configuration options are left on by default to remain compatible. Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com> --- Config.mk | 3 +++ tools/firmware/Makefile | 18 ++++++++++-------- tools/firmware/hvmloader/Makefile | 32 +++++++++++++++++++------------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/Config.mk b/Config.mk index 42508b8..a43596c 100644 --- a/Config.mk +++ b/Config.mk @@ -224,6 +224,9 @@ SEABIOS_UPSTREAM_TAG ?= rel-1.6.3.1 ETHERBOOT_NICS ?= rtl8139 8086100e +CONFIG_ROMBIOS ?= y +CONFIG_SEABIOS ?= y + # Specify which qemu-dm to use. This may be `ioemu'' to use the old # Mercurial in-tree version, or a local directory, or a git URL. # CONFIG_QEMU ?= `pwd`/$(XEN_ROOT)/../qemu-xen.git diff --git a/tools/firmware/Makefile b/tools/firmware/Makefile index c3ec9a0..5d40bcd 100644 --- a/tools/firmware/Makefile +++ b/tools/firmware/Makefile @@ -5,19 +5,20 @@ include $(XEN_ROOT)/tools/Rules.mk TARGET := hvmloader/hvmloader INST_DIR := $(DESTDIR)$(XENFIRMWAREDIR) -SUBDIRS :-SUBDIRS += seabios-dir -SUBDIRS += rombios -SUBDIRS += vgabios -SUBDIRS += etherboot -SUBDIRS += hvmloader +SUBDIRS-y :+SUBDIRS-$(CONFIG_SEABIOS) += seabios-dir +SUBDIRS-$(CONFIG_ROMBIOS) += rombios +SUBDIRS-$(CONFIG_ROMBIOS) += vgabios +SUBDIRS-$(CONFIG_ROMBIOS) += etherboot +SUBDIRS-y += hvmloader seabios-dir: GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(SEABIOS_UPSTREAM_URL) $(SEABIOS_UPSTREAM_TAG) seabios-dir cp seabios-config seabios-dir/.config; .PHONY: all -all: seabios-dir +all: $(SUBDIRS-y) +ifeq ($(CONFIG_ROMBIOS),y) @set -e; if [ $$((`( bcc -v 2>&1 | grep version || echo 0.0.0 ) | cut -d'' '' -f 3 | awk -F. ''{ printf "0x%02x%02x%02x", $$1, $$2, $$3}''`)) -lt $$((0x00100e)) ] ; then \ echo "==========================================================================="; \ echo "Require dev86 rpm or bin86 & bcc debs version >= 0.16.14 to build firmware!"; \ @@ -25,7 +26,8 @@ all: seabios-dir echo "==========================================================================="; \ false ; \ fi - $(MAKE) subdirs-$@; \ +endif + $(MAKE) subdirs-$@ .PHONY: install diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile index 5a5ee41..175dba6 100644 --- a/tools/firmware/hvmloader/Makefile +++ b/tools/firmware/hvmloader/Makefile @@ -38,27 +38,33 @@ endif CIRRUSVGA_DEBUG ?= n ROMBIOS_DIR := ../rombios -ifneq ($(ROMBIOS_DIR),) -OBJS += optionroms.o 32bitbios_support.o rombios.o -CFLAGS += -DENABLE_ROMBIOS -ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest -endif - SEABIOS_DIR := ../seabios-dir -ifneq ($(SEABIOS_DIR),) -OBJS += seabios.o -CFLAGS += -DENABLE_SEABIOS -SEABIOS_ROM := $(SEABIOS_DIR)/out/bios.bin -endif +ifeq ($(CONFIG_ROMBIOS),y) STDVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.bin ifeq ($(CIRRUSVGA_DEBUG),y) CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.debug.bin else CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.bin endif - ETHERBOOT_ROMS := $(addprefix ../etherboot/ipxe/src/bin/, $(addsuffix .rom, $(ETHERBOOT_NICS))) +endif + +ROMS := + +ifeq ($(CONFIG_ROMBIOS),y) +OBJS += optionroms.o 32bitbios_support.o rombios.o +CFLAGS += -DENABLE_ROMBIOS +ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest +ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS) +endif + +ifeq ($(CONFIG_SEABIOS),y) +OBJS += seabios.o +CFLAGS += -DENABLE_SEABIOS +SEABIOS_ROM := $(SEABIOS_DIR)/out/bios.bin +ROMS += $(SEABIOS_ROM) +endif .PHONY: all all: subdirs-all @@ -72,7 +78,7 @@ hvmloader: $(OBJS) acpi/acpi.a $(OBJCOPY) hvmloader.tmp hvmloader rm -f hvmloader.tmp -roms.inc: $(ROMBIOS_ROM) $(SEABIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS) +roms.inc: $(ROMS) echo "/* Autogenerated file. DO NOT EDIT */" > $@.new ifneq ($(ROMBIOS_ROM),) -- Julian Pidancet
Ian Campbell
2012-Feb-13 11:51 UTC
Re: [PATCH v3 1/5] hvmloader: Only compile 32bitbios_support.c when rombios is enabled
On Sat, 2012-02-11 at 20:39 +0000, Julian Pidancet wrote:> 32bitbios_support.c only contains code specific to rombios, and should > not be built-in when building hvmloader for SeaBIOS only (as for > rombios.c). > > Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>Acked-by: Ian Campbell <ian.campbell@citrix.com> I acked this patch last time too -- please collate Acks in repostings where no substantial change has been made to a patch so reviewers can save the effort. Ian.> --- > tools/firmware/hvmloader/Makefile | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile > index 41a4369..e82146a 100644 > --- a/tools/firmware/hvmloader/Makefile > +++ b/tools/firmware/hvmloader/Makefile > @@ -29,7 +29,7 @@ LOADADDR = 0x100000 > CFLAGS += $(CFLAGS_xeninclude) > > OBJS = hvmloader.o mp_tables.o util.o smbios.o > -OBJS += 32bitbios_support.o smp.o cacheattr.o xenbus.o > +OBJS += smp.o cacheattr.o xenbus.o > OBJS += e820.o pci.o pir.o ctype.o > ifeq ($(debug),y) > OBJS += tests.o > @@ -39,7 +39,7 @@ CIRRUSVGA_DEBUG ?= n > > ROMBIOS_DIR := ../rombios > ifneq ($(ROMBIOS_DIR),) > -OBJS += rombios.o > +OBJS += 32bitbios_support.o rombios.o > CFLAGS += -DENABLE_ROMBIOS > ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest > endif
Ian Campbell
2012-Feb-13 11:51 UTC
Re: [PATCH v3 2/5] hvmloader: Allow the mkhex command to take several file arguments
On Sat, 2012-02-11 at 20:39 +0000, Julian Pidancet wrote:> Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>Acked-by: Ian Campbell <ian.campbell@citrix.com>> --- > tools/firmware/hvmloader/mkhex | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > diff --git a/tools/firmware/hvmloader/mkhex b/tools/firmware/hvmloader/mkhex > index 4517e36..cb21257 100755 > --- a/tools/firmware/hvmloader/mkhex > +++ b/tools/firmware/hvmloader/mkhex > @@ -21,6 +21,7 @@ > # > > echo "unsigned $1[] = {" > -od -v -t x $2 | sed ''s/^[0-9]* */0x/'' | sed ''s/ */, 0x/g'' | sed ''s/$/,/'' | sed ''s/0x,//'' | sed ''s/^[0-9]*,//'' > +shift > +od -v -t x $@ | sed ''s/^[0-9]* */0x/'' | sed ''s/ */, 0x/g'' | sed ''s/$/,/'' | sed ''s/0x,//'' | sed ''s/^[0-9]*,//'' > echo "};" >
Ian Campbell
2012-Feb-13 11:52 UTC
Re: [PATCH v3 3/5] firmware: Use mkhex from hvmloader directory for etherboot ROMs
On Sat, 2012-02-11 at 20:39 +0000, Julian Pidancet wrote:> To remain consistent with how other ROMs are built into hvmloader, > call mkhex on etherboot ROMs from the hvmloader directory, instead of > the etherboot directory. In other words, eb-roms.h is not used any more. > > Introduce ETHERBOOT_NICS config option to choose which ROMs should be > built (kept rtl8139 and 8086100e per default as before). > > Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>Acked-by: Ian Campbell <ian.campbell@citrix.com>> --- > Config.mk | 2 ++ > tools/firmware/etherboot/Config | 2 -- > tools/firmware/etherboot/Makefile | 13 +++---------- > tools/firmware/hvmloader/Makefile | 9 ++++++--- > 4 files changed, 11 insertions(+), 15 deletions(-) > > diff --git a/Config.mk b/Config.mk > index e2dc4b9..42508b8 100644 > --- a/Config.mk > +++ b/Config.mk > @@ -222,6 +222,8 @@ endif > QEMU_UPSTREAM_REVISION ?= master > SEABIOS_UPSTREAM_TAG ?= rel-1.6.3.1 > > +ETHERBOOT_NICS ?= rtl8139 8086100e > + > # Specify which qemu-dm to use. This may be `ioemu'' to use the old > # Mercurial in-tree version, or a local directory, or a git URL. > # CONFIG_QEMU ?= `pwd`/$(XEN_ROOT)/../qemu-xen.git > diff --git a/tools/firmware/etherboot/Config b/tools/firmware/etherboot/Config > index 143914f..69963b9 100644 > --- a/tools/firmware/etherboot/Config > +++ b/tools/firmware/etherboot/Config > @@ -1,6 +1,4 @@ > > -NICS = rtl8139 8086100e > - > CFLAGS += -UPXE_DHCP_STRICT > CFLAGS += -DPXE_DHCP_STRICT > > diff --git a/tools/firmware/etherboot/Makefile b/tools/firmware/etherboot/Makefile > index c09140e..a195888 100644 > --- a/tools/firmware/etherboot/Makefile > +++ b/tools/firmware/etherboot/Makefile > @@ -17,23 +17,16 @@ IPXE_TARBALL_URL := $(XEN_EXTFILES_URL)/ipxe-git-$(IPXE_GIT_TAG).tar.gz > D=ipxe > T=ipxe.tar.gz > > -ROMS = $(addprefix $D/src/bin/, $(addsuffix .rom, $(NICS))) > +ROMS = $(addprefix $D/src/bin/, $(addsuffix .rom, $(ETHERBOOT_NICS))) > > .NOTPARALLEL: > > .PHONY: all > -all: eb-roms.h > +all: $(ROMS) > > %.rom: $D/src/arch/i386/Makefile > $(MAKE) -C $D/src bin/$(*F).rom > > -eb-roms.h.new: $(ROMS) > - cat $^ | ../hvmloader/mkhex etherboot >$@ > - > -eb-roms.h: Config > - $(MAKE) NO_WERROR=1 $@.new > - mv -f $@.new $@ > - > $T: > if ! wget -O _$T $(IPXE_TARBALL_URL); then \ > $(GIT) clone $(IPXE_GIT_URL) $D.git; \ > @@ -56,7 +49,7 @@ $D/src/bin/NIC: $D/src/arch/i386/Makefile > > .PHONY: clean > clean: > - rm -rf $D $D.git *~ eb-roms.h _$T $T > + rm -rf $D $D.git *~ _$T $T > > .PHONY: distclean > distclean: clean > diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile > index e82146a..1ea32db 100644 > --- a/tools/firmware/hvmloader/Makefile > +++ b/tools/firmware/hvmloader/Makefile > @@ -58,6 +58,8 @@ else > CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.bin > endif > > +ETHERBOOT_ROMS := $(addprefix ../etherboot/ipxe/src/bin/, $(addsuffix .rom, $(ETHERBOOT_NICS))) > + > .PHONY: all > all: subdirs-all > $(MAKE) hvmloader > @@ -70,7 +72,7 @@ hvmloader: $(OBJS) acpi/acpi.a > $(OBJCOPY) hvmloader.tmp hvmloader > rm -f hvmloader.tmp > > -roms.inc: $(ROMBIOS_ROM) $(SEABIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) ../etherboot/eb-roms.h > +roms.inc: $(ROMBIOS_ROM) $(SEABIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS) > echo "/* Autogenerated file. DO NOT EDIT */" > $@.new > > ifneq ($(ROMBIOS_ROM),) > @@ -95,10 +97,11 @@ ifneq ($(CIRRUSVGA_ROM),) > sh ./mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> $@.new > echo "#endif" >> $@.new > endif > - > +ifneq ($(ETHERBOOT_ROMS),) > echo "#ifdef ROM_INCLUDE_ETHERBOOT" >> $@.new > - cat ../etherboot/eb-roms.h >> $@.new > + sh ./mkhex etherboot $(ETHERBOOT_ROMS) >> $@.new > echo "#endif" >> $@.new > +endif > > mv $@.new $@ >
Ian Campbell
2012-Feb-13 11:53 UTC
Re: [PATCH v3 4/5] hvmloader: Move option ROM loading into a separate optionnal file
On Sat, 2012-02-11 at 20:39 +0000, Julian Pidancet wrote:> Make load_rom field in struct bios_config an optionnal callback rather > than a boolean value. It allow BIOS specific code to implement it''s own > option ROM loading methods. > > Facilities to scan PCI devices, extract an deploy ROMs are moved into > a separate file that can be compiled optionnaly. > > Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>Presuming this to be mostly code motion I didn''t review in depth but: Acked-by: Ian Campbell <ian.campbell@citrix.com>> --- > tools/firmware/hvmloader/Makefile | 2 +- > tools/firmware/hvmloader/config.h | 3 +- > tools/firmware/hvmloader/hvmloader.c | 218 +-------------------------------- > tools/firmware/hvmloader/option_rom.h | 7 + > tools/firmware/hvmloader/optionroms.c | 189 ++++++++++++++++++++++++++++ > tools/firmware/hvmloader/rombios.c | 63 +++++++++- > tools/firmware/hvmloader/seabios.c | 5 +- > 7 files changed, 259 insertions(+), 228 deletions(-) > create mode 100644 tools/firmware/hvmloader/optionroms.c > > diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile > index 1ea32db..5a5ee41 100644 > --- a/tools/firmware/hvmloader/Makefile > +++ b/tools/firmware/hvmloader/Makefile > @@ -39,7 +39,7 @@ CIRRUSVGA_DEBUG ?= n > > ROMBIOS_DIR := ../rombios > ifneq ($(ROMBIOS_DIR),) > -OBJS += 32bitbios_support.o rombios.o > +OBJS += optionroms.o 32bitbios_support.o rombios.o > CFLAGS += -DENABLE_ROMBIOS > ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest > endif > diff --git a/tools/firmware/hvmloader/config.h b/tools/firmware/hvmloader/config.h > index 9cac9c1..1f80263 100644 > --- a/tools/firmware/hvmloader/config.h > +++ b/tools/firmware/hvmloader/config.h > @@ -18,8 +18,7 @@ struct bios_config { > unsigned int bios_address; > > /* ROMS */ > - int load_roms; > - unsigned int optionrom_start, optionrom_end; > + void (*load_roms)(void); > > void (*bios_load)(const struct bios_config *config); > > diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c > index f120ffe..ad50189 100644 > --- a/tools/firmware/hvmloader/hvmloader.c > +++ b/tools/firmware/hvmloader/hvmloader.c > @@ -24,16 +24,11 @@ > #include "hypercall.h" > #include "config.h" > #include "pci_regs.h" > -#include "option_rom.h" > #include "apic_regs.h" > #include "acpi/acpi2_0.h" > #include <xen/version.h> > #include <xen/hvm/params.h> > > -#define ROM_INCLUDE_VGABIOS > -#define ROM_INCLUDE_ETHERBOOT > -#include "roms.inc" > - > asm ( > " .text \n" > " .globl _start \n" > @@ -147,169 +142,6 @@ static void init_hypercalls(void) > printf("Detected Xen v%u.%u%s\n", eax >> 16, eax & 0xffff, extraversion); > } > > -/* > - * Scan the list of Option ROMs at @roms for one which supports > - * PCI (@vendor_id, @device_id) found at slot @devfn. If one is found, > - * copy it to @dest and return its size rounded up to a multiple 2kB. This > - * function will not copy ROMs beyond address option_rom_end. > - */ > -#define round_option_rom(x) (((x) + 2047) & ~2047) > -static int scan_option_rom( > - unsigned int option_rom_end, > - uint8_t devfn, uint16_t vendor_id, uint16_t device_id, > - void *roms, uint32_t dest) > -{ > - struct option_rom_header *rom; > - struct option_rom_pnp_header *pnph; > - struct option_rom_pci_header *pcih; > - uint8_t csum; > - int i; > - > - static uint32_t orom_ids[64]; > - static int nr_roms; > - > - /* Avoid duplicate ROMs. */ > - for ( i = 0; i < nr_roms; i++ ) > - if ( orom_ids[i] == (vendor_id | ((uint32_t)device_id << 16)) ) > - return 0; > - > - rom = roms; > - for ( ; ; ) > - { > - /* Invalid signature means we''re out of option ROMs. */ > - if ( strncmp((char *)rom->signature, "\x55\xaa", 2) || > - (rom->rom_size == 0) ) > - break; > - > - /* Invalid checksum means we''re out of option ROMs. */ > - csum = 0; > - for ( i = 0; i < (rom->rom_size * 512); i++ ) > - csum += ((uint8_t *)rom)[i]; > - if ( csum != 0 ) > - break; > - > - /* Check the PCI PnP header (if any) for a match. */ > - pcih = (struct option_rom_pci_header *) > - ((char *)rom + rom->pci_header_offset); > - if ( (rom->pci_header_offset != 0) && > - !strncmp((char *)pcih->signature, "PCIR", 4) && > - (pcih->vendor_id == vendor_id) && > - (pcih->device_id == device_id) ) > - goto found; > - > - rom = (struct option_rom_header *) > - ((char *)rom + rom->rom_size * 512); > - } > - > - return 0; > - > - found: > - /* Find the PnP expansion header (if any). */ > - pnph = ((rom->expansion_header_offset != 0) > - ? ((struct option_rom_pnp_header *) > - ((char *)rom + rom->expansion_header_offset)) > - : ((struct option_rom_pnp_header *)NULL)); > - while ( (pnph != NULL) && strncmp((char *)pnph->signature, "$PnP", 4) ) > - pnph = ((pnph->next_header_offset != 0) > - ? ((struct option_rom_pnp_header *) > - ((char *)rom + pnph->next_header_offset)) > - : ((struct option_rom_pnp_header *)NULL)); > - > - printf("Loading PCI Option ROM ...\n"); > - if ( (pnph != NULL) && (pnph->manufacturer_name_offset != 0) ) > - printf(" - Manufacturer: %s\n", > - (char *)rom + pnph->manufacturer_name_offset); > - if ( (pnph != NULL) && (pnph->product_name_offset != 0) ) > - printf(" - Product name: %s\n", > - (char *)rom + pnph->product_name_offset); > - > - if ( (dest + rom->rom_size * 512 + 1) > option_rom_end ) > - { > - printf("Option ROM size %x exceeds available space\n", > - rom->rom_size * 512); > - return 0; > - } > - > - orom_ids[nr_roms++] = vendor_id | ((uint32_t)device_id << 16); > - memcpy((void *)dest, rom, rom->rom_size * 512); > - *(uint8_t *)(dest + rom->rom_size * 512) = devfn; > - return round_option_rom(rom->rom_size * 512 + 1); > -} > - > -/* > - * Scan the PCI bus for the first NIC supported by etherboot, and copy > - * the corresponding rom data to *copy_rom_dest. Returns the length of the > - * selected rom, or 0 if no NIC found. > - */ > -static int scan_etherboot_nic(unsigned int option_rom_end, > - uint32_t copy_rom_dest) > -{ > - uint16_t class, vendor_id, device_id, devfn; > - int rom_size = 0; > - > - for ( devfn = 0; (devfn < 256) && !rom_size; devfn++ ) > - { > - class = pci_readw(devfn, PCI_CLASS_DEVICE); > - vendor_id = pci_readw(devfn, PCI_VENDOR_ID); > - device_id = pci_readw(devfn, PCI_DEVICE_ID); > - > - /* We''re only interested in NICs. */ > - if ( (vendor_id != 0xffff) && > - (device_id != 0xffff) && > - (class == 0x0200) ) > - rom_size = scan_option_rom( > - option_rom_end, > - devfn, vendor_id, device_id, etherboot, copy_rom_dest); > - } > - > - return rom_size; > -} > - > -/* > - * Scan the PCI bus for the devices that have an option ROM, and copy > - * the corresponding rom data to rom_phys_addr. > - */ > -static int pci_load_option_roms(unsigned int option_rom_end, > - uint32_t rom_base_addr) > -{ > - uint32_t option_rom_addr, rom_phys_addr = rom_base_addr; > - uint16_t vendor_id, device_id, devfn, class; > - > - for ( devfn = 0; devfn < 256; devfn++ ) > - { > - class = pci_readb(devfn, PCI_CLASS_DEVICE + 1); > - vendor_id = pci_readw(devfn, PCI_VENDOR_ID); > - device_id = pci_readw(devfn, PCI_DEVICE_ID); > - > - if ( (vendor_id == 0xffff) && (device_id == 0xffff) ) > - continue; > - > - /* > - * Currently only scan options from mass storage devices and serial > - * bus controller (Fibre Channel included). > - */ > - if ( (class != 0x1) && (class != 0xc) ) > - continue; > - > - option_rom_addr = pci_readl(devfn, PCI_ROM_ADDRESS); > - if ( !option_rom_addr ) > - continue; > - > - /* Ensure Expansion Bar is enabled before copying */ > - pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr | 0x1); > - > - rom_phys_addr += scan_option_rom( > - option_rom_end, > - devfn, vendor_id, device_id, > - (void *)(option_rom_addr & ~2047), rom_phys_addr); > - > - /* Restore the default original value of Expansion Bar */ > - pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr); > - } > - > - return rom_phys_addr - rom_base_addr; > -} > - > /* Replace possibly erroneous memory-size CMOS fields with correct values. */ > static void cmos_write_memory_size(void) > { > @@ -421,8 +253,6 @@ static void acpi_enable_sci(void) > int main(void) > { > 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; > int acpi_enabled; > > /* Initialise hypercall stubs with RET, rendering them no-ops. */ > @@ -471,41 +301,7 @@ int main(void) > } > > if ( bios->load_roms ) > - { > - switch ( virtual_vga ) > - { > - case VGA_cirrus: > - printf("Loading Cirrus VGABIOS ...\n"); > - memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, > - vgabios_cirrusvga, sizeof(vgabios_cirrusvga)); > - vgabios_sz = round_option_rom(sizeof(vgabios_cirrusvga)); > - break; > - case VGA_std: > - printf("Loading Standard VGABIOS ...\n"); > - memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, > - vgabios_stdvga, sizeof(vgabios_stdvga)); > - vgabios_sz = round_option_rom(sizeof(vgabios_stdvga)); > - break; > - case VGA_pt: > - printf("Loading VGABIOS of passthroughed gfx ...\n"); > - vgabios_sz = round_option_rom( > - (*(uint8_t *)(VGABIOS_PHYSICAL_ADDRESS+2)) * 512); > - break; > - default: > - printf("No emulated VGA adaptor ...\n"); > - break; > - } > - > - etherboot_phys_addr = VGABIOS_PHYSICAL_ADDRESS + vgabios_sz; > - 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(bios->optionrom_end, > - option_rom_phys_addr); > - } > + bios->load_roms(); > > acpi_enabled = !strncmp(xenstore_read("platform/acpi", "1"), "1", 1); > > @@ -536,18 +332,6 @@ int main(void) > if ( SCRATCH_PHYSICAL_ADDRESS != scratch_start ) > printf(" %05x-%05lx: Scratch space\n", > SCRATCH_PHYSICAL_ADDRESS, scratch_start); > - if ( vgabios_sz ) > - printf(" %05x-%05x: VGA BIOS\n", > - VGABIOS_PHYSICAL_ADDRESS, > - VGABIOS_PHYSICAL_ADDRESS + vgabios_sz - 1); > - if ( etherboot_sz ) > - printf(" %05x-%05x: Etherboot ROM\n", > - etherboot_phys_addr, > - etherboot_phys_addr + etherboot_sz - 1); > - if ( option_rom_sz ) > - printf(" %05x-%05x: PCI Option ROMs\n", > - option_rom_phys_addr, > - option_rom_phys_addr + option_rom_sz - 1); > printf(" %05x-%05x: Main BIOS\n", > bios->bios_address, > bios->bios_address + bios->image_size - 1); > diff --git a/tools/firmware/hvmloader/option_rom.h b/tools/firmware/hvmloader/option_rom.h > index f0c7ec4..1ada3e2 100644 > --- a/tools/firmware/hvmloader/option_rom.h > +++ b/tools/firmware/hvmloader/option_rom.h > @@ -47,6 +47,13 @@ struct option_rom_pci_header { > uint16_t reserved; > } __attribute__ ((packed)); > > +#define round_option_rom(x) (((x) + 2047) & ~2047) > +int scan_etherboot_nic(unsigned int option_rom_end, > + uint32_t copy_rom_dest, > + void *etherboot_rom); > +int pci_load_option_roms(unsigned int option_rom_end, > + uint32_t rom_base_addr); > + > #endif /* __HVMLOADER_OPTION_ROM_H__ */ > > /* > diff --git a/tools/firmware/hvmloader/optionroms.c b/tools/firmware/hvmloader/optionroms.c > new file mode 100644 > index 0000000..e35aebc > --- /dev/null > +++ b/tools/firmware/hvmloader/optionroms.c > @@ -0,0 +1,189 @@ > +/* > + * optionroms.c: Option ROM loading support. > + * > + * Leendert van Doorn, leendert@watson.ibm.com > + * Copyright (c) 2005, International Business Machines Corporation. > + * > + * Copyright (c) 2006, Keir Fraser, XenSource 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 "option_rom.h" > +#include "util.h" > +#include "pci_regs.h" > + > +/* > + * Scan the list of Option ROMs at @roms for one which supports > + * PCI (@vendor_id, @device_id) found at slot @devfn. If one is found, > + * copy it to @dest and return its size rounded up to a multiple 2kB. This > + * function will not copy ROMs beyond address option_rom_end. > + */ > +static int scan_option_rom( > + unsigned int option_rom_end, > + uint8_t devfn, uint16_t vendor_id, uint16_t device_id, > + void *roms, uint32_t dest) > +{ > + struct option_rom_header *rom; > + struct option_rom_pnp_header *pnph; > + struct option_rom_pci_header *pcih; > + uint8_t csum; > + int i; > + > + static uint32_t orom_ids[64]; > + static int nr_roms; > + > + /* Avoid duplicate ROMs. */ > + for ( i = 0; i < nr_roms; i++ ) > + if ( orom_ids[i] == (vendor_id | ((uint32_t)device_id << 16)) ) > + return 0; > + > + rom = roms; > + for ( ; ; ) > + { > + /* Invalid signature means we''re out of option ROMs. */ > + if ( strncmp((char *)rom->signature, "\x55\xaa", 2) || > + (rom->rom_size == 0) ) > + break; > + > + /* Invalid checksum means we''re out of option ROMs. */ > + csum = 0; > + for ( i = 0; i < (rom->rom_size * 512); i++ ) > + csum += ((uint8_t *)rom)[i]; > + if ( csum != 0 ) > + break; > + > + /* Check the PCI PnP header (if any) for a match. */ > + pcih = (struct option_rom_pci_header *) > + ((char *)rom + rom->pci_header_offset); > + if ( (rom->pci_header_offset != 0) && > + !strncmp((char *)pcih->signature, "PCIR", 4) && > + (pcih->vendor_id == vendor_id) && > + (pcih->device_id == device_id) ) > + goto found; > + > + rom = (struct option_rom_header *) > + ((char *)rom + rom->rom_size * 512); > + } > + > + return 0; > + > + found: > + /* Find the PnP expansion header (if any). */ > + pnph = ((rom->expansion_header_offset != 0) > + ? ((struct option_rom_pnp_header *) > + ((char *)rom + rom->expansion_header_offset)) > + : ((struct option_rom_pnp_header *)NULL)); > + while ( (pnph != NULL) && strncmp((char *)pnph->signature, "$PnP", 4) ) > + pnph = ((pnph->next_header_offset != 0) > + ? ((struct option_rom_pnp_header *) > + ((char *)rom + pnph->next_header_offset)) > + : ((struct option_rom_pnp_header *)NULL)); > + > + printf("Loading PCI Option ROM ...\n"); > + if ( (pnph != NULL) && (pnph->manufacturer_name_offset != 0) ) > + printf(" - Manufacturer: %s\n", > + (char *)rom + pnph->manufacturer_name_offset); > + if ( (pnph != NULL) && (pnph->product_name_offset != 0) ) > + printf(" - Product name: %s\n", > + (char *)rom + pnph->product_name_offset); > + > + if ( (dest + rom->rom_size * 512 + 1) > option_rom_end ) > + { > + printf("Option ROM size %x exceeds available space\n", > + rom->rom_size * 512); > + return 0; > + } > + > + orom_ids[nr_roms++] = vendor_id | ((uint32_t)device_id << 16); > + memcpy((void *)dest, rom, rom->rom_size * 512); > + *(uint8_t *)(dest + rom->rom_size * 512) = devfn; > + return round_option_rom(rom->rom_size * 512 + 1); > +} > + > +/* > + * Scan the PCI bus for the first NIC supported by etherboot, and copy > + * the corresponding rom data to *copy_rom_dest. Returns the length of the > + * selected rom, or 0 if no NIC found. > + */ > +int scan_etherboot_nic(unsigned int option_rom_end, > + uint32_t copy_rom_dest, > + void *etherboot_rom) > +{ > + uint16_t class, vendor_id, device_id, devfn; > + int rom_size = 0; > + > + for ( devfn = 0; (devfn < 256) && !rom_size; devfn++ ) > + { > + class = pci_readw(devfn, PCI_CLASS_DEVICE); > + vendor_id = pci_readw(devfn, PCI_VENDOR_ID); > + device_id = pci_readw(devfn, PCI_DEVICE_ID); > + > + /* We''re only interested in NICs. */ > + if ( (vendor_id != 0xffff) && > + (device_id != 0xffff) && > + (class == 0x0200) ) > + rom_size = scan_option_rom( > + option_rom_end, > + devfn, vendor_id, device_id, etherboot_rom, copy_rom_dest); > + } > + > + return rom_size; > +} > + > +/* > + * Scan the PCI bus for the devices that have an option ROM, and copy > + * the corresponding rom data to rom_phys_addr. > + */ > +int pci_load_option_roms(unsigned int option_rom_end, > + uint32_t rom_base_addr) > +{ > + uint32_t option_rom_addr, rom_phys_addr = rom_base_addr; > + uint16_t vendor_id, device_id, devfn, class; > + > + for ( devfn = 0; devfn < 256; devfn++ ) > + { > + class = pci_readb(devfn, PCI_CLASS_DEVICE + 1); > + vendor_id = pci_readw(devfn, PCI_VENDOR_ID); > + device_id = pci_readw(devfn, PCI_DEVICE_ID); > + > + if ( (vendor_id == 0xffff) && (device_id == 0xffff) ) > + continue; > + > + /* > + * Currently only scan options from mass storage devices and serial > + * bus controller (Fibre Channel included). > + */ > + if ( (class != 0x1) && (class != 0xc) ) > + continue; > + > + option_rom_addr = pci_readl(devfn, PCI_ROM_ADDRESS); > + if ( !option_rom_addr ) > + continue; > + > + /* Ensure Expansion Bar is enabled before copying */ > + pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr | 0x1); > + > + rom_phys_addr += scan_option_rom( > + option_rom_end, > + devfn, vendor_id, device_id, > + (void *)(option_rom_addr & ~2047), rom_phys_addr); > + > + /* Restore the default original value of Expansion Bar */ > + pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr); > + } > + > + return rom_phys_addr - rom_base_addr; > +} > diff --git a/tools/firmware/hvmloader/rombios.c b/tools/firmware/hvmloader/rombios.c > index d5831aa..e0d4182 100644 > --- a/tools/firmware/hvmloader/rombios.c > +++ b/tools/firmware/hvmloader/rombios.c > @@ -29,10 +29,13 @@ > #include "pci_regs.h" > #include "util.h" > #include "hypercall.h" > +#include "option_rom.h" > > #include <xen/hvm/params.h> > > #define ROM_INCLUDE_ROMBIOS > +#define ROM_INCLUDE_VGABIOS > +#define ROM_INCLUDE_ETHERBOOT > #include "roms.inc" > > #define ROMBIOS_BEGIN 0x000F0000 > @@ -64,6 +67,61 @@ static void rombios_setup_bios_info(void) > memset(info, 0, sizeof(*info)); > } > > +static void rombios_load_roms(void) > +{ > + int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0; > + uint32_t etherboot_phys_addr = 0, option_rom_phys_addr = 0; > + > + switch ( virtual_vga ) > + { > + case VGA_cirrus: > + printf("Loading Cirrus VGABIOS ...\n"); > + memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, > + vgabios_cirrusvga, sizeof(vgabios_cirrusvga)); > + vgabios_sz = round_option_rom(sizeof(vgabios_cirrusvga)); > + break; > + case VGA_std: > + printf("Loading Standard VGABIOS ...\n"); > + memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, > + vgabios_stdvga, sizeof(vgabios_stdvga)); > + vgabios_sz = round_option_rom(sizeof(vgabios_stdvga)); > + break; > + case VGA_pt: > + printf("Loading VGABIOS of passthroughed gfx ...\n"); > + vgabios_sz = round_option_rom( > + (*(uint8_t *)(VGABIOS_PHYSICAL_ADDRESS+2)) * 512); > + break; > + default: > + printf("No emulated VGA adaptor ...\n"); > + break; > + } > + > + 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, > + etherboot_phys_addr, > + etherboot); > + > + option_rom_phys_addr = etherboot_phys_addr + etherboot_sz; > + option_rom_sz = pci_load_option_roms(OPTIONROM_PHYSICAL_END, > + option_rom_phys_addr); > + > + printf("Option ROMs:\n"); > + if ( vgabios_sz ) > + printf(" %05x-%05x: VGA BIOS\n", > + VGABIOS_PHYSICAL_ADDRESS, > + VGABIOS_PHYSICAL_ADDRESS + vgabios_sz - 1); > + if ( etherboot_sz ) > + printf(" %05x-%05x: Etherboot ROM\n", > + etherboot_phys_addr, > + etherboot_phys_addr + etherboot_sz - 1); > + if ( option_rom_sz ) > + printf(" %05x-%05x: PCI Option ROMs\n", > + option_rom_phys_addr, > + option_rom_phys_addr + option_rom_sz - 1); > +} > + > static void rombios_load(const struct bios_config *config) > { > uint32_t bioshigh; > @@ -158,10 +216,7 @@ struct bios_config rombios_config = { > > .bios_address = ROMBIOS_PHYSICAL_ADDRESS, > > - .load_roms = 1, > - > - .optionrom_start = OPTIONROM_PHYSICAL_ADDRESS, > - .optionrom_end = OPTIONROM_PHYSICAL_END, > + .load_roms = rombios_load_roms, > > .bios_load = rombios_load, > > diff --git a/tools/firmware/hvmloader/seabios.c b/tools/firmware/hvmloader/seabios.c > index 3045157..15ddf35 100644 > --- a/tools/firmware/hvmloader/seabios.c > +++ b/tools/firmware/hvmloader/seabios.c > @@ -143,10 +143,7 @@ struct bios_config seabios_config = { > > .bios_address = SEABIOS_PHYSICAL_ADDRESS, > > - .load_roms = 0, > - > - .optionrom_start = 0, > - .optionrom_end = 0, > + .load_roms = NULL, > > .bios_load = NULL, > > -- > Julian Pidancet >
Ian Campbell
2012-Feb-13 11:55 UTC
Re: [PATCH v3 5/5] firmware: Introduce CONFIG_ROMBIOS and CONFIG_SEABIOS options
On Sat, 2012-02-11 at 20:39 +0000, Julian Pidancet wrote:> This patch introduces configuration options allowing to built either > a rombios only or a seabios only hvmloader. > > Building option ROMs like vgabios or etherboot is only enabled for > a rombios hvmloader, since SeaBIOS takes care or extracting option > ROMs itself from the PCI devices (these option ROMs are provided > by the device model and do not need to be built in hvmloader). > > The Makefile in tools/firmware/ now only checks for bcc if rombios > is enabled. > > These two configuration options are left on by default to remain > compatible. > > Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>Acked-by: Ian Campbell <ian.campbell@citrix.com>
Keir Fraser
2012-Feb-13 12:51 UTC
Re: [PATCH v3 0/5] hvmloader: Make ROM dependencies optional
On 11/02/2012 20:39, "Julian Pidancet" <julian.pidancet@gmail.com> wrote:> This patch set mainly allows the user to build a seabios or rombios only > version of hvmloader. > In addition, when building a seabios only hvmloader, Option ROMs like > vgabios and etherboot are no longer required, and therefore can be disabled > from the build. Dependency on the bcc compiler can also be avoided the > same way.Applied, but I wonder why we still have the rombios support? Could we switch over to seabios for 4.2 and get rid of the crufty old rombios code entirely? -- Keir> v2: Separate patches for separate issues > Introduced config option to select which NIC to build ROM for > Fixed initial patch to build multiple etherboot ROMs in hvmloader > Option ROMs are keyed off wether or not rombios is enabled, rather than > on an individual basis > Introduced config options to select support for rombios/seabios > > v3: Fix mkhex script to take several file arguments on the command line > Reorganize hvmloader option ROM loading code to make it optionnal, and > make bios->load_roms a callback that the BIOS support code has to implement > if option ROM loading is desired. > Cosmetic change in tools/firmware/Makefile in the way seabios-dir is > created. > > Julian Pidancet (5): > hvmloader: Only compile 32bitbios_support.c when rombios is enabled > hvmloader: Allow the mkhex command to take several file arguments > firmware: Use mkhex from hvmloader directory for etherboot ROMs > hvmloader: Move option ROM loading into a separate optionnal file > firmware: Introduce CONFIG_ROMBIOS and CONFIG_SEABIOS options > > Config.mk | 5 + > tools/firmware/Makefile | 18 ++-- > tools/firmware/etherboot/Config | 2 - > tools/firmware/etherboot/Makefile | 13 +-- > tools/firmware/hvmloader/Makefile | 39 ++++--- > tools/firmware/hvmloader/config.h | 3 +- > tools/firmware/hvmloader/hvmloader.c | 218 > +-------------------------------- > tools/firmware/hvmloader/mkhex | 3 +- > tools/firmware/hvmloader/option_rom.h | 7 + > tools/firmware/hvmloader/optionroms.c | 189 ++++++++++++++++++++++++++++ > tools/firmware/hvmloader/rombios.c | 63 +++++++++- > tools/firmware/hvmloader/seabios.c | 5 +- > 12 files changed, 302 insertions(+), 263 deletions(-) > create mode 100644 tools/firmware/hvmloader/optionroms.c
Ian Campbell
2012-Feb-13 12:56 UTC
Re: [PATCH v3 0/5] hvmloader: Make ROM dependencies optional
On Mon, 2012-02-13 at 12:51 +0000, Keir Fraser wrote:> On 11/02/2012 20:39, "Julian Pidancet" <julian.pidancet@gmail.com> wrote: > > > This patch set mainly allows the user to build a seabios or rombios only > > version of hvmloader. > > In addition, when building a seabios only hvmloader, Option ROMs like > > vgabios and etherboot are no longer required, and therefore can be disabled > > from the build. Dependency on the bcc compiler can also be avoided the > > same way. > > Applied, but I wonder why we still have the rombios support? Could we switch > over to seabios for 4.2 and get rid of the crufty old rombios code entirely?We still use ROMBIOS with the traditional qemu-xen tree, I think we have to do that for compatibility with existing guests, for the same reason as we need to continue to support that traditional qemu-xen tree. Post 4.2 we will be switching the default qemu to the upstream tree which uses SeaBIOS at which point the old-qemu+ROMBIOS combo becomes legacy/frozen etc. We don''t support new-qemu+ROMBIOS nor old-qemu +SEABIOS. Ian.> > -- Keir > > > v2: Separate patches for separate issues > > Introduced config option to select which NIC to build ROM for > > Fixed initial patch to build multiple etherboot ROMs in hvmloader > > Option ROMs are keyed off wether or not rombios is enabled, rather than > > on an individual basis > > Introduced config options to select support for rombios/seabios > > > > v3: Fix mkhex script to take several file arguments on the command line > > Reorganize hvmloader option ROM loading code to make it optionnal, and > > make bios->load_roms a callback that the BIOS support code has to implement > > if option ROM loading is desired. > > Cosmetic change in tools/firmware/Makefile in the way seabios-dir is > > created. > > > > Julian Pidancet (5): > > hvmloader: Only compile 32bitbios_support.c when rombios is enabled > > hvmloader: Allow the mkhex command to take several file arguments > > firmware: Use mkhex from hvmloader directory for etherboot ROMs > > hvmloader: Move option ROM loading into a separate optionnal file > > firmware: Introduce CONFIG_ROMBIOS and CONFIG_SEABIOS options > > > > Config.mk | 5 + > > tools/firmware/Makefile | 18 ++-- > > tools/firmware/etherboot/Config | 2 - > > tools/firmware/etherboot/Makefile | 13 +-- > > tools/firmware/hvmloader/Makefile | 39 ++++--- > > tools/firmware/hvmloader/config.h | 3 +- > > tools/firmware/hvmloader/hvmloader.c | 218 > > +-------------------------------- > > tools/firmware/hvmloader/mkhex | 3 +- > > tools/firmware/hvmloader/option_rom.h | 7 + > > tools/firmware/hvmloader/optionroms.c | 189 ++++++++++++++++++++++++++++ > > tools/firmware/hvmloader/rombios.c | 63 +++++++++- > > tools/firmware/hvmloader/seabios.c | 5 +- > > 12 files changed, 302 insertions(+), 263 deletions(-) > > create mode 100644 tools/firmware/hvmloader/optionroms.c > >
Keir Fraser
2012-Feb-13 13:09 UTC
Re: [PATCH v3 0/5] hvmloader: Make ROM dependencies optional
On 13/02/2012 12:56, "Ian Campbell" <Ian.Campbell@citrix.com> wrote:> On Mon, 2012-02-13 at 12:51 +0000, Keir Fraser wrote: >> On 11/02/2012 20:39, "Julian Pidancet" <julian.pidancet@gmail.com> wrote: >> >>> This patch set mainly allows the user to build a seabios or rombios only >>> version of hvmloader. >>> In addition, when building a seabios only hvmloader, Option ROMs like >>> vgabios and etherboot are no longer required, and therefore can be disabled >>> from the build. Dependency on the bcc compiler can also be avoided the >>> same way. >> >> Applied, but I wonder why we still have the rombios support? Could we switch >> over to seabios for 4.2 and get rid of the crufty old rombios code entirely? > > We still use ROMBIOS with the traditional qemu-xen tree, I think we have > to do that for compatibility with existing guests, for the same reason > as we need to continue to support that traditional qemu-xen tree.So guests that were installed with old qemu need to always boot with old qemu? Because if the compatibility issue is only with saved guests, then we don''t need to keep old ROMBIOS around as it lives in saved-guest memory. -- Keir> Post 4.2 we will be switching the default qemu to the upstream tree > which uses SeaBIOS at which point the old-qemu+ROMBIOS combo becomes > legacy/frozen etc. We don''t support new-qemu+ROMBIOS nor old-qemu > +SEABIOS. > > Ian. > >> >> -- Keir >> >>> v2: Separate patches for separate issues >>> Introduced config option to select which NIC to build ROM for >>> Fixed initial patch to build multiple etherboot ROMs in hvmloader >>> Option ROMs are keyed off wether or not rombios is enabled, rather than >>> on an individual basis >>> Introduced config options to select support for rombios/seabios >>> >>> v3: Fix mkhex script to take several file arguments on the command line >>> Reorganize hvmloader option ROM loading code to make it optionnal, and >>> make bios->load_roms a callback that the BIOS support code has to implement >>> if option ROM loading is desired. >>> Cosmetic change in tools/firmware/Makefile in the way seabios-dir is >>> created. >>> >>> Julian Pidancet (5): >>> hvmloader: Only compile 32bitbios_support.c when rombios is enabled >>> hvmloader: Allow the mkhex command to take several file arguments >>> firmware: Use mkhex from hvmloader directory for etherboot ROMs >>> hvmloader: Move option ROM loading into a separate optionnal file >>> firmware: Introduce CONFIG_ROMBIOS and CONFIG_SEABIOS options >>> >>> Config.mk | 5 + >>> tools/firmware/Makefile | 18 ++-- >>> tools/firmware/etherboot/Config | 2 - >>> tools/firmware/etherboot/Makefile | 13 +-- >>> tools/firmware/hvmloader/Makefile | 39 ++++--- >>> tools/firmware/hvmloader/config.h | 3 +- >>> tools/firmware/hvmloader/hvmloader.c | 218 >>> +-------------------------------- >>> tools/firmware/hvmloader/mkhex | 3 +- >>> tools/firmware/hvmloader/option_rom.h | 7 + >>> tools/firmware/hvmloader/optionroms.c | 189 ++++++++++++++++++++++++++++ >>> tools/firmware/hvmloader/rombios.c | 63 +++++++++- >>> tools/firmware/hvmloader/seabios.c | 5 +- >>> 12 files changed, 302 insertions(+), 263 deletions(-) >>> create mode 100644 tools/firmware/hvmloader/optionroms.c >> >> > >
Ian Campbell
2012-Feb-13 13:35 UTC
Re: [PATCH v3 0/5] hvmloader: Make ROM dependencies optional
On Mon, 2012-02-13 at 13:09 +0000, Keir Fraser wrote:> On 13/02/2012 12:56, "Ian Campbell" <Ian.Campbell@citrix.com> wrote: > > > On Mon, 2012-02-13 at 12:51 +0000, Keir Fraser wrote: > >> On 11/02/2012 20:39, "Julian Pidancet" <julian.pidancet@gmail.com> wrote: > >> > >>> This patch set mainly allows the user to build a seabios or rombios only > >>> version of hvmloader. > >>> In addition, when building a seabios only hvmloader, Option ROMs like > >>> vgabios and etherboot are no longer required, and therefore can be disabled > >>> from the build. Dependency on the bcc compiler can also be avoided the > >>> same way. > >> > >> Applied, but I wonder why we still have the rombios support? Could we switch > >> over to seabios for 4.2 and get rid of the crufty old rombios code entirely? > > > > We still use ROMBIOS with the traditional qemu-xen tree, I think we have > > to do that for compatibility with existing guests, for the same reason > > as we need to continue to support that traditional qemu-xen tree. > > So guests that were installed with old qemu need to always boot with old > qemu?That''s the claim at least WRT guests like Windows where we aren''t confident in the ability to change "motherboard" under its feet. I think we''ve basically just taken the conservative decision to put qemu-xen-traditional+ROMBIOS into "deep freeze" and keep supporting them due to lack of concrete evidence and because "deep freeze" means (or should mean) very low effort. If there were evidence that this kind of BIOS+motherboard upgrade doesn''t make guests unhappy then it''s an easy position to undo. Ian.
Maybe Matching Threads
- [PATCH RFC] hvmloader: Make ROM dependencies optional
- [PATCH v2 0/3] hvmloader: Make ROM dependencies optional
- [PATCH] Automatically select 0xe9 as default debug port if configured for Xen
- [RFC] kvmtool: add support for modern virtio-pci
- [RFC] kvmtool: add support for modern virtio-pci