[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] Etherboot for E100 NIC
Yosuke Iwamatsu writes ("[Xen-devel] [PATCH] Etherboot for E100 NIC"): > Currently, Xen has the etherboot rom for hvm guests, > which only supports rtl8139 nic device model. > This patch is intended to support etherboot for e100 nic by: > - adding etherboot rom for e100 nic (provided by rom-o-matic.net). > - making hvmloader scan pci devices, find the first nic device > and load the corresponding etherboot rom. Following on from the changes recently made to build etherboot ourselves from source, I've adapted Yosuke Iwamatsu's idea to work in this context. The result is below and appears to work. The set of supported NICs can be adjusted by changing the setting of NICS in tools/firmware/etherboot/Makefile. The added file tools/firmware/etherboot/make-eb-rom-list needs to have chmod +x run on it before committing. Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@xxxxxxxxxxxxx> diff -r 71e9c5d41023 .hgignore --- a/.hgignore Thu Jan 31 14:14:23 2008 +0000 +++ b/.hgignore Thu Jan 31 15:45:21 2008 +0000 @@ -105,6 +105,8 @@ ^tools/firmware/.*\.bin$ ^tools/firmware/.*\.sym$ ^tools/firmware/.*bios/.*bios.*\.txt$ +^tools/firmware/etherboot/eb-roms\.h$ +^tools/firmware/etherboot/eb-rom-list\.h$ ^tools/firmware/etherboot/etherboot-5 ^tools/firmware/etherboot/etherboot-build ^tools/firmware/etherboot/.*\.zrom\.h$ diff -r 71e9c5d41023 tools/firmware/etherboot/Makefile --- a/tools/firmware/etherboot/Makefile Thu Jan 31 14:14:23 2008 +0000 +++ b/tools/firmware/etherboot/Makefile Thu Jan 31 15:45:26 2008 +0000 @@ -9,14 +9,24 @@ T=etherboot-$(EB_VERSION).tar.gz T=etherboot-$(EB_VERSION).tar.gz E=etherboot-build -TARGETS=eb-rtl8139.zrom.h +NICS = rtl8139 eepro100 + +TARGETS= eb-rom-list.h eb-roms.h $(ROM_ZHS) + +ROM_ZHS= $(addprefix eb-, $(addsuffix .zrom.h, $(NICS))) all: $(TARGETS) eb-%.zrom.h: $E/src/Config $(MAKE) -C $E/src bin/$*.zrom - ../hvmloader/mkhex etherboot <$E/src/bin/$*.zrom >$@.new + ../hvmloader/mkhex etherboot_$* <$E/src/bin/$*.zrom >$@.new mv -f $@.new $@ + +eb-rom-list.h: make-eb-rom-list $E/src/bin/Roms + ./$^ $(NICS) >$@.new && mv -f $@.new $@ + +eb-roms.h: eb-rom-list.h $(ROM_ZHS) + cat $^ >$@.new && mv -f $@.new $@ $E/src/Config: $T Config rm -rf $D $E @@ -44,7 +54,10 @@ eb-%.zrom.h: $E/src/Config mv Config.new Config mv $D $E +$E/src/bin/Roms: $E/src/Config + $(MAKE) -C $E/src bin/Roms + clean: - rm -rf $D $E *.zrom.h *~ + rm -rf $D $E *.zrom.h $(TARGETS) *~ .PHONY: all clean diff -r 71e9c5d41023 tools/firmware/hvmloader/Makefile --- a/tools/firmware/hvmloader/Makefile Thu Jan 31 14:14:23 2008 +0000 +++ b/tools/firmware/hvmloader/Makefile Thu Jan 31 14:15:33 2008 +0000 @@ -55,7 +55,7 @@ roms.h: ../rombios/BIOS-bochs-latest ../ sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin >> roms.h sh ./mkhex vgabios_cirrusvga ../vgabios/VGABIOS-lgpl-latest.cirrus.bin >> roms.h sh ./mkhex vmxassist ../vmxassist/vmxassist.bin >> roms.h - cat ../etherboot/eb-rtl8139.zrom.h >> roms.h + cat ../etherboot/eb-roms.h >> roms.h sh ./mkhex extboot ../extboot/extboot.bin >> roms.h .PHONY: clean diff -r 71e9c5d41023 tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Thu Jan 31 14:14:23 2008 +0000 +++ b/tools/firmware/hvmloader/hvmloader.c Thu Jan 31 14:30:52 2008 +0000 @@ -368,6 +368,58 @@ static int must_load_extboot(void) return (inb(0x404) == 1); } +/* + * Scan the PCI bus for the first NIC supported by etherboot, and copy + * the corresponding rom data to *copy_rom_dest. On return *sz_r + * is the length of the selected rom found, or 0 if no NIC found. + */ +static void scan_etherboot_nic(void *copy_rom_dest, int *sz_r) +{ + static struct etherboots_table_entry { + char *name; + void *etherboot_rom; + int etherboot_sz; + uint16_t vendor, device; + } etherboots_table[] = { +#define ETHERBOOT_ROM(name, vendor, device) \ + { #name, etherboot_##name, sizeof(etherboot_##name), vendor, device }, + ETHERBOOT_ROM_LIST + { 0 } + }; + + uint32_t devfn; + uint16_t class, vendor_id, device_id; + struct etherboots_table_entry *eb; + + for ( devfn = 0; devfn < 128; devfn++ ) + { + class = pci_readw(devfn, PCI_CLASS_DEVICE); + vendor_id = pci_readw(devfn, PCI_VENDOR_ID); + device_id = pci_readw(devfn, PCI_DEVICE_ID); + + if ( (vendor_id == 0xffff) && (device_id == 0xffff) ) + continue; + + if ( class != 0x0200 ) /* Not a NIC */ + continue; + + for (eb = etherboots_table; + eb->name; + eb++) + if (eb->vendor == vendor_id && + eb->device == device_id) + goto found; + } + /* not found: */ + *sz_r = 0; + return; + + found: + memcpy(copy_rom_dest, eb->etherboot_rom, eb->etherboot_sz); + *sz_r = eb->etherboot_sz; + printf("Using etherboot_%s ...\n", eb->name); +} + /* Replace possibly erroneous memory-size CMOS fields with correct values. */ static void cmos_write_memory_size(void) { @@ -446,9 +498,7 @@ int main(void) if ( must_load_nic() ) { printf("Loading ETHERBOOT ...\n"); - memcpy((void *)ETHERBOOT_PHYSICAL_ADDRESS, - etherboot, sizeof(etherboot)); - etherboot_sz = sizeof(etherboot); + scan_etherboot_nic((void*)ETHERBOOT_PHYSICAL_ADDRESS, ðerboot_sz); } if ( must_load_extboot() ) diff -r 71e9c5d41023 tools/firmware/etherboot/make-eb-rom-list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/firmware/etherboot/make-eb-rom-list Thu Jan 31 14:02:22 2008 +0000 @@ -0,0 +1,11 @@ +#!/bin/sh +set -e +roms=$1; shift +echo "/* autogenerated - do not edit */" +echo "#define ETHERBOOT_ROM_LIST \\" +for nic in "$@"; do + makerom=`grep "^MAKEROM_ID_$nic *= *-p *" <$roms` + echo " ETHERBOOT_ROM($nic,${makerom#*-p}) \\" +done +echo +echo "/*end.*/" _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |