ia64/xen-unstable
changeset 16960:42369d21641d
hvm: Etherboot for E100 NIC
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Thu Jan 31 16:23:35 2008 +0000 (2008-01-31) |
parents | 71e9c5d41023 |
children | 17cce0554151 |
files | .hgignore tools/firmware/etherboot/Makefile tools/firmware/etherboot/make-eb-rom-list tools/firmware/hvmloader/Makefile tools/firmware/hvmloader/hvmloader.c |
line diff
1.1 --- a/.hgignore Thu Jan 31 14:14:23 2008 +0000 1.2 +++ b/.hgignore Thu Jan 31 16:23:35 2008 +0000 1.3 @@ -105,6 +105,8 @@ 1.4 ^tools/firmware/.*\.bin$ 1.5 ^tools/firmware/.*\.sym$ 1.6 ^tools/firmware/.*bios/.*bios.*\.txt$ 1.7 +^tools/firmware/etherboot/eb-roms\.h$ 1.8 +^tools/firmware/etherboot/eb-rom-list\.h$ 1.9 ^tools/firmware/etherboot/etherboot-5 1.10 ^tools/firmware/etherboot/etherboot-build 1.11 ^tools/firmware/etherboot/.*\.zrom\.h$
2.1 --- a/tools/firmware/etherboot/Makefile Thu Jan 31 14:14:23 2008 +0000 2.2 +++ b/tools/firmware/etherboot/Makefile Thu Jan 31 16:23:35 2008 +0000 2.3 @@ -9,16 +9,24 @@ D=etherboot-$(EB_VERSION) 2.4 T=etherboot-$(EB_VERSION).tar.gz 2.5 E=etherboot-build 2.6 2.7 -TARGETS=eb-rtl8139.zrom.h 2.8 +NICS = rtl8139 eepro100 2.9 2.10 -all: $(TARGETS) 2.11 +ROM_ZHS = $(addprefix eb-, $(addsuffix .zrom.h, $(NICS))) 2.12 + 2.13 +all: eb-roms.h 2.14 2.15 eb-%.zrom.h: $E/src/Config 2.16 $(MAKE) -C $E/src bin/$*.zrom 2.17 - ../hvmloader/mkhex etherboot <$E/src/bin/$*.zrom >$@.new 2.18 + ../hvmloader/mkhex etherboot_$* <$E/src/bin/$*.zrom >$@.new 2.19 mv -f $@.new $@ 2.20 2.21 -$E/src/Config: $T Config 2.22 +eb-rom-list.h: make-eb-rom-list $E/src/bin/Roms 2.23 + ./$^ $(NICS) >$@.new && mv -f $@.new $@ 2.24 + 2.25 +eb-roms.h: eb-rom-list.h $(ROM_ZHS) 2.26 + cat $^ >$@.new && mv -f $@.new $@ 2.27 + 2.28 +$E/src/Config: $T Config 2.29 rm -rf $D $E 2.30 tar zxf $T 2.31 cat Config >>$D/src/Config 2.32 @@ -44,7 +52,10 @@ eb-%.zrom.h: $E/src/Config 2.33 mv Config.new Config 2.34 mv $D $E 2.35 2.36 +$E/src/bin/Roms: $E/src/Config 2.37 + $(MAKE) -C $E/src bin/Roms 2.38 + 2.39 clean: 2.40 - rm -rf $D $E *.zrom.h *~ 2.41 + rm -rf $D $E *.zrom.h eb-rom-list.h eb-roms.h *~ 2.42 2.43 .PHONY: all clean
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/tools/firmware/etherboot/make-eb-rom-list Thu Jan 31 16:23:35 2008 +0000 3.3 @@ -0,0 +1,11 @@ 3.4 +#!/bin/sh 3.5 +set -e 3.6 +roms=$1; shift 3.7 +echo "/* autogenerated - do not edit */" 3.8 +echo "#define ETHERBOOT_ROM_LIST \\" 3.9 +for nic in "$@"; do 3.10 + makerom=`grep "^MAKEROM_ID_$nic *= *-p *" <$roms` 3.11 + echo " ETHERBOOT_ROM($nic,${makerom#*-p}) \\" 3.12 +done 3.13 +echo 3.14 +echo "/*end.*/"
4.1 --- a/tools/firmware/hvmloader/Makefile Thu Jan 31 14:14:23 2008 +0000 4.2 +++ b/tools/firmware/hvmloader/Makefile Thu Jan 31 16:23:35 2008 +0000 4.3 @@ -55,7 +55,7 @@ roms.h: ../rombios/BIOS-bochs-latest ../ 4.4 sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin >> roms.h 4.5 sh ./mkhex vgabios_cirrusvga ../vgabios/VGABIOS-lgpl-latest.cirrus.bin >> roms.h 4.6 sh ./mkhex vmxassist ../vmxassist/vmxassist.bin >> roms.h 4.7 - cat ../etherboot/eb-rtl8139.zrom.h >> roms.h 4.8 + cat ../etherboot/eb-roms.h >> roms.h 4.9 sh ./mkhex extboot ../extboot/extboot.bin >> roms.h 4.10 4.11 .PHONY: clean
5.1 --- a/tools/firmware/hvmloader/hvmloader.c Thu Jan 31 14:14:23 2008 +0000 5.2 +++ b/tools/firmware/hvmloader/hvmloader.c Thu Jan 31 16:23:35 2008 +0000 5.3 @@ -345,29 +345,60 @@ static void pci_setup(void) 5.4 } 5.5 } 5.6 5.7 -/* 5.8 - * If the network card is in the boot order, load the Etherboot option ROM. 5.9 - * Read the boot order bytes from CMOS and check if any of them are 0x4. 5.10 - */ 5.11 -static int must_load_nic(void) 5.12 -{ 5.13 - uint8_t boot_order; 5.14 - 5.15 - /* Read CMOS register 0x3d (boot choices 0 and 1). */ 5.16 - boot_order = cmos_inb(0x3d); 5.17 - if ( ((boot_order & 0xf) == 0x4) || ((boot_order & 0xf0) == 0x40) ) 5.18 - return 1; 5.19 - 5.20 - /* Read CMOS register 0x38 (boot choice 2 and FDD test flag). */ 5.21 - boot_order = cmos_inb(0x38); 5.22 - return ((boot_order & 0xf0) == 0x40); 5.23 -} 5.24 - 5.25 static int must_load_extboot(void) 5.26 { 5.27 return (inb(0x404) == 1); 5.28 } 5.29 5.30 +/* 5.31 + * Scan the PCI bus for the first NIC supported by etherboot, and copy 5.32 + * the corresponding rom data to *copy_rom_dest. Returns the length of the 5.33 + * selected rom, or 0 if no NIC found. 5.34 + */ 5.35 +static int scan_etherboot_nic(void *copy_rom_dest) 5.36 +{ 5.37 + static struct etherboots_table_entry { 5.38 + char *name; 5.39 + void *etherboot_rom; 5.40 + int etherboot_sz; 5.41 + uint16_t vendor, device; 5.42 + } etherboots_table[] = { 5.43 +#define ETHERBOOT_ROM(name, vendor, device) \ 5.44 + { #name, etherboot_##name, sizeof(etherboot_##name), vendor, device }, 5.45 + ETHERBOOT_ROM_LIST 5.46 + { 0 } 5.47 + }; 5.48 + 5.49 + uint32_t devfn; 5.50 + uint16_t class, vendor_id, device_id; 5.51 + struct etherboots_table_entry *eb; 5.52 + 5.53 + for ( devfn = 0; devfn < 128; devfn++ ) 5.54 + { 5.55 + class = pci_readw(devfn, PCI_CLASS_DEVICE); 5.56 + vendor_id = pci_readw(devfn, PCI_VENDOR_ID); 5.57 + device_id = pci_readw(devfn, PCI_DEVICE_ID); 5.58 + 5.59 + if ( (vendor_id == 0xffff) && (device_id == 0xffff) ) 5.60 + continue; 5.61 + 5.62 + if ( class != 0x0200 ) /* Not a NIC */ 5.63 + continue; 5.64 + 5.65 + for ( eb = etherboots_table; eb->name; eb++ ) 5.66 + if (eb->vendor == vendor_id && 5.67 + eb->device == device_id) 5.68 + goto found; 5.69 + } 5.70 + 5.71 + return 0; 5.72 + 5.73 + found: 5.74 + printf("Loading %s Etherboot PXE ROM ...\n", eb->name); 5.75 + memcpy(copy_rom_dest, eb->etherboot_rom, eb->etherboot_sz); 5.76 + return eb->etherboot_sz; 5.77 +} 5.78 + 5.79 /* Replace possibly erroneous memory-size CMOS fields with correct values. */ 5.80 static void cmos_write_memory_size(void) 5.81 { 5.82 @@ -443,13 +474,7 @@ int main(void) 5.83 vgabios_sz = sizeof(vgabios_stdvga); 5.84 } 5.85 5.86 - if ( must_load_nic() ) 5.87 - { 5.88 - printf("Loading ETHERBOOT ...\n"); 5.89 - memcpy((void *)ETHERBOOT_PHYSICAL_ADDRESS, 5.90 - etherboot, sizeof(etherboot)); 5.91 - etherboot_sz = sizeof(etherboot); 5.92 - } 5.93 + etherboot_sz = scan_etherboot_nic((void*)ETHERBOOT_PHYSICAL_ADDRESS); 5.94 5.95 if ( must_load_extboot() ) 5.96 {