[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] hvm: Etherboot for E100 NIC



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1201796615 0
# Node ID 42369d21641d6297dc369441c3bfd355880d28c0
# Parent  71e9c5d41023e4066cea8767c573a62f05b45115
hvm: Etherboot for E100 NIC
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@xxxxxxxxxxxxx>
---
 .hgignore                                 |    2 
 tools/firmware/etherboot/Makefile         |   21 ++++++--
 tools/firmware/etherboot/make-eb-rom-list |   11 ++++
 tools/firmware/hvmloader/Makefile         |    2 
 tools/firmware/hvmloader/hvmloader.c      |   77 +++++++++++++++++++-----------
 5 files changed, 81 insertions(+), 32 deletions(-)

diff -r 71e9c5d41023 -r 42369d21641d .hgignore
--- a/.hgignore Thu Jan 31 14:14:23 2008 +0000
+++ b/.hgignore Thu Jan 31 16:23:35 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 -r 42369d21641d 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 16:23:35 2008 +0000
@@ -9,16 +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
 
-all: $(TARGETS)
+ROM_ZHS = $(addprefix eb-, $(addsuffix .zrom.h, $(NICS)))
+
+all: eb-roms.h
 
 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 $@
 
-$E/src/Config: $T Config
+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
        tar zxf $T
        cat Config >>$D/src/Config
@@ -44,7 +52,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 eb-rom-list.h eb-roms.h *~
 
 .PHONY: all clean
diff -r 71e9c5d41023 -r 42369d21641d 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 16:23:35 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.*/"
diff -r 71e9c5d41023 -r 42369d21641d 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 16:23:35 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 -r 42369d21641d 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 16:23:35 2008 +0000
@@ -345,27 +345,58 @@ static void pci_setup(void)
     }
 }
 
+static int must_load_extboot(void)
+{
+    return (inb(0x404) == 1);
+}
+
 /*
- * If the network card is in the boot order, load the Etherboot option ROM.
- * Read the boot order bytes from CMOS and check if any of them are 0x4.
+ * 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 must_load_nic(void) 
-{
-    uint8_t boot_order;
-
-    /* Read CMOS register 0x3d (boot choices 0 and 1). */
-    boot_order = cmos_inb(0x3d);
-    if ( ((boot_order & 0xf) == 0x4) || ((boot_order & 0xf0) == 0x40) ) 
-        return 1;
-
-    /* Read CMOS register 0x38 (boot choice 2 and FDD test flag). */
-    boot_order = cmos_inb(0x38);
-    return ((boot_order & 0xf0) == 0x40);
-}
-
-static int must_load_extboot(void)
-{
-    return (inb(0x404) == 1);
+static int scan_etherboot_nic(void *copy_rom_dest)
+{
+    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;
+    }
+
+    return 0;
+
+ found:
+    printf("Loading %s Etherboot PXE ROM ...\n", eb->name);
+    memcpy(copy_rom_dest, eb->etherboot_rom, eb->etherboot_sz);
+    return eb->etherboot_sz;
 }
 
 /* Replace possibly erroneous memory-size CMOS fields with correct values. */
@@ -443,13 +474,7 @@ int main(void)
         vgabios_sz = sizeof(vgabios_stdvga);
     }
 
-    if ( must_load_nic() )
-    {
-        printf("Loading ETHERBOOT ...\n");
-        memcpy((void *)ETHERBOOT_PHYSICAL_ADDRESS,
-               etherboot, sizeof(etherboot));
-        etherboot_sz = sizeof(etherboot);
-    }
+    etherboot_sz = scan_etherboot_nic((void*)ETHERBOOT_PHYSICAL_ADDRESS);
 
     if ( must_load_extboot() )
     {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.