Home | History | Annotate | Download | only in netboot
      1 /*
      2  *  GRUB  --  GRand Unified Bootloader
      3  *  Copyright (C) 2001,2002  Free Software Foundation, Inc.
      4  *
      5  *  This program is free software; you can redistribute it and/or modify
      6  *  it under the terms of the GNU General Public License as published by
      7  *  the Free Software Foundation; either version 2 of the License, or
      8  *  (at your option) any later version.
      9  *
     10  *  This program is distributed in the hope that it will be useful,
     11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  *  GNU General Public License for more details.
     14  *
     15  *  You should have received a copy of the GNU General Public License
     16  *  along with this program; if not, write to the Free Software
     17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18  */
     19 
     20 /* Based on "src/config.c" in etherboot-5.0.5.  */
     21 
     22 /*
     23  * This program is free software; you can redistribute it and/or
     24  * modify it under the terms of the GNU General Public License as
     25  * published by the Free Software Foundation; either version 2, or (at
     26  * your option) any later version.
     27  */
     28 
     29 #define GRUB	1
     30 #include <etherboot.h>
     31 #include <nic.h>
     32 
     33 #undef	INCLUDE_PCI
     34 #if	defined(INCLUDE_NS8390) || defined(INCLUDE_EEPRO100) || defined(INCLUDE_LANCE) || defined(INCLUDE_EPIC100) || defined(INCLUDE_TULIP) || defined(INCLUDE_OTULIP) || defined(INCLUDE_3C90X) ||  defined(INCLUDE_3C595) || defined(INCLUDE_RTL8139) || defined(INCLUDE_VIA_RHINE) || defined(INCLUDE_W89C840) || defined(INCLUDE_DAVICOM) || defined(INCLUDE_SIS900) || defined(INCLUDE_NATSEMI) || defined(INCLUDE_TLAN)
     35 	/* || others later */
     36 # define INCLUDE_PCI
     37 # include <pci.h>
     38 static unsigned short pci_ioaddrs[16];
     39 
     40 static struct pci_device pci_nic_list[] =
     41 {
     42 #ifdef	INCLUDE_NS8390
     43   { PCI_VENDOR_ID_REALTEK,	PCI_DEVICE_ID_REALTEK_8029,
     44     "Realtek 8029", 0, 0, 0, 0},
     45   { PCI_VENDOR_ID_WINBOND2,	PCI_DEVICE_ID_WINBOND2_89C940,
     46     "Winbond NE2000-PCI", 0, 0, 0, 0},
     47   { PCI_VENDOR_ID_COMPEX,	PCI_DEVICE_ID_COMPEX_RL2000,
     48     "Compex ReadyLink 2000", 0, 0, 0, 0},
     49   { PCI_VENDOR_ID_KTI,		PCI_DEVICE_ID_KTI_ET32P2,
     50     "KTI ET32P2", 0, 0, 0, 0},
     51   { PCI_VENDOR_ID_NETVIN,	PCI_DEVICE_ID_NETVIN_NV5000SC,
     52     "NetVin NV5000SC", 0, 0, 0, 0},
     53   { PCI_VENDOR_ID_HOLTEK,	PCI_DEVICE_ID_HOLTEK_HT80232,
     54     "Holtek HT80232", 0, 0, 0, 0},
     55 #endif
     56 #ifdef	INCLUDE_3C90X
     57   { PCI_VENDOR_ID_3COM,		PCI_DEVICE_ID_3COM_3C900TPO,
     58     "3Com900-TPO", 0, 0, 0, 0},
     59   { PCI_VENDOR_ID_3COM,		PCI_DEVICE_ID_3COM_3C900COMBO,
     60     "3Com900-Combo", 0, 0, 0, 0},
     61   { PCI_VENDOR_ID_3COM,		PCI_DEVICE_ID_3COM_3C905TX,
     62     "3Com905-TX", 0, 0, 0, 0},
     63   { PCI_VENDOR_ID_3COM,		PCI_DEVICE_ID_3COM_3C905T4,
     64     "3Com905-T4", 0, 0, 0, 0},
     65   { PCI_VENDOR_ID_3COM,		0x9004,
     66     "3Com900B-TPO", 0, 0, 0, 0},
     67   { PCI_VENDOR_ID_3COM,		0x9005,
     68     "3Com900B-Combo", 0, 0, 0, 0},
     69   { PCI_VENDOR_ID_3COM,		0x9006,
     70     "3Com900B-2/T", 0, 0, 0, 0},
     71   { PCI_VENDOR_ID_3COM,		0x900A,
     72     "3Com900B-FL", 0, 0, 0, 0},
     73   { PCI_VENDOR_ID_3COM,		PCI_DEVICE_ID_3COM_3C905B_TX,
     74     "3Com905B-TX", 0, 0, 0, 0},
     75   { PCI_VENDOR_ID_3COM,		0x9056,
     76     "3Com905B-T4", 0, 0, 0, 0},
     77   { PCI_VENDOR_ID_3COM,		0x905A,
     78     "3Com905B-FL", 0, 0, 0, 0},
     79   { PCI_VENDOR_ID_3COM,		PCI_DEVICE_ID_3COM_3C905C_TXM,
     80     "3Com905C-TXM", 0, 0, 0, 0},
     81   { PCI_VENDOR_ID_3COM,		0x9800,
     82     "3Com980-Cyclone", 0, 0, 0, 0},
     83   { PCI_VENDOR_ID_3COM,		0x9805,
     84     "3Com9805", 0, 0, 0, 0},
     85   { PCI_VENDOR_ID_3COM,		0x7646,
     86     "3CSOHO100-TX", 0, 0, 0, 0},
     87 #endif
     88 #ifdef	INCLUDE_3C595
     89   { PCI_VENDOR_ID_3COM,		PCI_DEVICE_ID_3COM_3C590,
     90     "3Com590", 0, 0, 0, 0},
     91   { PCI_VENDOR_ID_3COM,		PCI_DEVICE_ID_3COM_3C595,
     92     "3Com595", 0, 0, 0, 0},
     93   { PCI_VENDOR_ID_3COM,		PCI_DEVICE_ID_3COM_3C595_1,
     94     "3Com595", 0, 0, 0, 0},
     95   { PCI_VENDOR_ID_3COM,		PCI_DEVICE_ID_3COM_3C595_2,
     96     "3Com595", 0, 0, 0, 0},
     97   { PCI_VENDOR_ID_3COM,		PCI_DEVICE_ID_3COM_3C900TPO,
     98     "3Com900-TPO", 0, 0, 0, 0},
     99   { PCI_VENDOR_ID_3COM,		PCI_DEVICE_ID_3COM_3C900COMBO,
    100     "3Com900-Combo", 0, 0, 0, 0},
    101   { PCI_VENDOR_ID_3COM,		0x9004,
    102     "3Com900B-TPO", 0, 0, 0, 0},
    103   { PCI_VENDOR_ID_3COM,		0x9005,
    104     "3Com900B-Combo", 0, 0, 0, 0},
    105   { PCI_VENDOR_ID_3COM,		0x9006,
    106     "3Com900B-2/T", 0, 0, 0, 0},
    107   { PCI_VENDOR_ID_3COM,		0x900A,
    108     "3Com900B-FL", 0, 0, 0, 0},
    109   { PCI_VENDOR_ID_3COM,		0x9800,
    110     "3Com980-Cyclone", 0, 0, 0, 0},
    111   { PCI_VENDOR_ID_3COM,		0x9805,
    112     "3Com9805", 0, 0, 0, 0},
    113   { PCI_VENDOR_ID_3COM,		0x7646,
    114     "3CSOHO100-TX", 0, 0, 0, 0},
    115 #endif
    116 #ifdef	INCLUDE_EEPRO100
    117   { PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_82557,
    118     "Intel EtherExpressPro100", 0, 0, 0, 0},
    119   { PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_82559ER,
    120     "Intel EtherExpressPro100 82559ER", 0, 0, 0, 0},
    121   { PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_ID1029,
    122     "Intel EtherExpressPro100 ID1029", 0, 0, 0, 0},
    123   { PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_ID1030,
    124     "Intel Corporation 82559 InBusiness 10/100", 0, 0, 0, 0},
    125   { PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_82562,
    126     "Intel EtherExpressPro100 82562EM", 0, 0, 0, 0},
    127 #endif
    128 #ifdef	INCLUDE_EPIC100
    129   { PCI_VENDOR_ID_SMC,		PCI_DEVICE_ID_SMC_EPIC100,
    130     "SMC EtherPowerII", 0, 0, 0, 0},
    131 #endif
    132 #ifdef	INCLUDE_LANCE
    133   { PCI_VENDOR_ID_AMD,		PCI_DEVICE_ID_AMD_LANCE,
    134     "AMD Lance/PCI", 0, 0, 0, 0},
    135   { PCI_VENDOR_ID_AMD_HOMEPNA,	PCI_DEVICE_ID_AMD_HOMEPNA,
    136     "AMD Lance/HomePNA", 0, 0, 0, 0},
    137 #endif
    138 #ifdef	INCLUDE_RTL8139
    139   { PCI_VENDOR_ID_REALTEK,	PCI_DEVICE_ID_REALTEK_8139,
    140     "Realtek 8139", 0, 0, 0, 0},
    141   { PCI_VENDOR_ID_DLINK,	PCI_DEVICE_ID_DFE530TXP,
    142     "DFE530TX+/DFE538TX", 0, 0, 0, 0},
    143   { PCI_VENDOR_ID_SMC_1211,	PCI_DEVICE_ID_SMC_1211,
    144     "SMC EZ10/100", 0, 0, 0, 0},
    145 #endif
    146 #ifdef	INCLUDE_OTULIP
    147   { PCI_VENDOR_ID_DEC,		PCI_DEVICE_ID_DEC_TULIP,
    148     "Digital Tulip", 0, 0, 0, 0},
    149   { PCI_VENDOR_ID_DEC,		PCI_DEVICE_ID_DEC_TULIP_FAST,
    150     "Digital Tulip Fast", 0, 0, 0, 0},
    151   { PCI_VENDOR_ID_DEC,		PCI_DEVICE_ID_DEC_TULIP_PLUS,
    152     "Digital Tulip+", 0, 0, 0, 0},
    153   { PCI_VENDOR_ID_DEC,		PCI_DEVICE_ID_DEC_21142,
    154     "Digital Tulip 21142", 0, 0, 0, 0},
    155 #endif
    156 #ifdef	INCLUDE_TULIP
    157   { PCI_VENDOR_ID_DEC,		PCI_DEVICE_ID_DEC_TULIP,
    158     "Digital Tulip", 0, 0, 0, 0},
    159   { PCI_VENDOR_ID_DEC,		PCI_DEVICE_ID_DEC_TULIP_FAST,
    160     "Digital Tulip Fast", 0, 0, 0, 0},
    161   { PCI_VENDOR_ID_DEC,		PCI_DEVICE_ID_DEC_TULIP_PLUS,
    162     "Digital Tulip+", 0, 0, 0, 0},
    163   { PCI_VENDOR_ID_DEC,		PCI_DEVICE_ID_DEC_21142,
    164     "Digital Tulip 21142", 0, 0, 0, 0},
    165   { PCI_VENDOR_ID_MACRONIX,	PCI_DEVICE_ID_MX987x5,
    166     "Macronix MX987x5", 0, 0, 0, 0},
    167   { PCI_VENDOR_ID_LINKSYS,	PCI_DEVICE_ID_LC82C115,
    168     "LinkSys LNE100TX", 0, 0, 0, 0},
    169   { PCI_VENDOR_ID_LINKSYS,	PCI_DEVICE_ID_DEC_TULIP,
    170     "Netgear FA310TX", 0, 0, 0, 0},
    171   { PCI_VENDOR_ID_DAVICOM,	PCI_DEVICE_ID_DM9102,
    172     "Davicom 9102", 0, 0, 0, 0},
    173   { PCI_VENDOR_ID_DAVICOM,	PCI_DEVICE_ID_DM9009,
    174     "Davicom 9009", 0, 0, 0, 0},
    175   { PCI_VENDOR_ID_ADMTEK,	PCI_DEVICE_ID_ADMTEK_0985,
    176     "ADMtek Centaur-P", 0, 0, 0, 0},
    177   { PCI_VENDOR_ID_ADMTEK,	0x0981,
    178     "ADMtek AN981 Comet", 0, 0, 0, 0},
    179   { 0x125B,			0x1400,
    180     "ASIX AX88140", 0, 0, 0, 0 },
    181   { 0x11F6,			0x9881,
    182     "Compex RL100-TX", 0, 0, 0, 0 },
    183 #endif
    184 #ifdef	INCLUDE_DAVICOM
    185   { PCI_VENDOR_ID_DAVICOM,	PCI_DEVICE_ID_DM9102,
    186     "Davicom 9102", 0, 0, 0, 0},
    187   { PCI_VENDOR_ID_DAVICOM,	PCI_DEVICE_ID_DM9009,
    188     "Davicom 9009", 0, 0, 0, 0},
    189 #endif
    190 #ifdef	INCLUDE_VIA_RHINE
    191   { PCI_VENDOR_ID_VIATEC,	PCI_DEVICE_ID_VIA_VT6102,
    192     "VIA 6102", 0, 0, 0, 0},
    193   { PCI_VENDOR_ID_VIATEC,	PCI_DEVICE_ID_VIA_RHINE_I,
    194     "VIA 3043", 0, 0, 0, 0},
    195   { PCI_VENDOR_ID_VIATEC,	PCI_DEVICE_ID_VIA_86C100A,
    196     "VIA 86C100A", 0, 0, 0, 0},
    197 #endif
    198 #ifdef	INCLUDE_W89C840
    199   { PCI_VENDOR_ID_WINBOND2,	PCI_DEVICE_ID_WINBOND2_89C840,
    200     "Winbond W89C840F", 0, 0, 0, 0},
    201   { PCI_VENDOR_ID_COMPEX,	PCI_DEVICE_ID_COMPEX_RL100ATX,
    202     "Compex RL100ATX", 0, 0, 0, 0},
    203 #endif
    204 #ifdef INCLUDE_SIS900
    205   { PCI_VENDOR_ID_SIS,     	PCI_DEVICE_ID_SIS900,
    206     "SIS900", 0, 0, 0, 0},
    207   { PCI_VENDOR_ID_SIS,     	PCI_DEVICE_ID_SIS7016,
    208     "SIS7016", 0, 0, 0, 0},
    209 #endif
    210 
    211 #ifdef INCLUDE_NATSEMI
    212   { PCI_VENDOR_ID_NS,	     	PCI_DEVICE_ID_DP83815,
    213     "DP83815", 0, 0, 0, 0},
    214 #endif
    215 
    216 #ifdef INCLUDE_TLAN
    217   { PCI_VENDOR_ID_OLICOM,	PCI_DEVICE_ID_OLICOM_OC2326,
    218     "OC2326", 0, 0, 0, 0},
    219 #endif
    220 
    221   /* other PCI NICs go here */
    222   {0, 0, NULL, 0, 0, 0, 0}
    223 };
    224 #endif	/* INCLUDE_*PCI */
    225 
    226 #include <cards.h>
    227 
    228 #ifdef INCLUDE_PCI
    229 struct pci_dispatch_table
    230 {
    231   unsigned short vendor;
    232   unsigned short dev_id;
    233   struct nic *(*eth_probe) (struct nic *, unsigned short *,
    234 			    struct pci_device *);
    235 };
    236 
    237 static struct pci_dispatch_table PCI_NIC[] =
    238 {
    239 # ifdef INCLUDE_NS8390
    240   { PCI_VENDOR_ID_REALTEK,  PCI_DEVICE_ID_REALTEK_8029,    nepci_probe },
    241   { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_89C940, nepci_probe },
    242   { PCI_VENDOR_ID_COMPEX,   PCI_DEVICE_ID_COMPEX_RL2000,   nepci_probe },
    243   { PCI_VENDOR_ID_KTI,      PCI_DEVICE_ID_KTI_ET32P2,      nepci_probe },
    244   { PCI_VENDOR_ID_NETVIN,   PCI_DEVICE_ID_NETVIN_NV5000SC, nepci_probe },
    245   { PCI_VENDOR_ID_HOLTEK,   PCI_DEVICE_ID_HOLTEK_HT80232,  nepci_probe },
    246 # endif /* INCLUDE_NS8390 */
    247 # ifdef INCLUDE_3C90X
    248   { PCI_VENDOR_ID_3COM,	    PCI_DEVICE_ID_3COM_3C900TPO,   a3c90x_probe },
    249   { PCI_VENDOR_ID_3COM,     PCI_DEVICE_ID_3COM_3C900COMBO, a3c90x_probe },
    250   { PCI_VENDOR_ID_3COM,     PCI_DEVICE_ID_3COM_3C905TX,    a3c90x_probe },
    251   { PCI_VENDOR_ID_3COM,     PCI_DEVICE_ID_3COM_3C905T4,    a3c90x_probe },
    252   { PCI_VENDOR_ID_3COM,     0x9004,                        a3c90x_probe },
    253   { PCI_VENDOR_ID_3COM,     0x9005,                        a3c90x_probe },
    254   { PCI_VENDOR_ID_3COM,     0x9006,                        a3c90x_probe },
    255   { PCI_VENDOR_ID_3COM,     0x900A,                        a3c90x_probe },
    256   { PCI_VENDOR_ID_3COM,     PCI_DEVICE_ID_3COM_3C905B_TX,  a3c90x_probe },
    257   { PCI_VENDOR_ID_3COM,     0x9056,                        a3c90x_probe },
    258   { PCI_VENDOR_ID_3COM,     0x905A,                        a3c90x_probe },
    259   { PCI_VENDOR_ID_3COM,     PCI_DEVICE_ID_3COM_3C905C_TXM, a3c90x_probe },
    260   { PCI_VENDOR_ID_3COM,     0x9800,                        a3c90x_probe },
    261   { PCI_VENDOR_ID_3COM,     0x9805,                        a3c90x_probe },
    262   { PCI_VENDOR_ID_3COM,     0x7646,                        a3c90x_probe },
    263 # endif /* INCLUDE_3C90X */
    264 # ifdef	INCLUDE_3C595
    265   { PCI_VENDOR_ID_3COM,     PCI_DEVICE_ID_3COM_3C590,      t595_probe },
    266   { PCI_VENDOR_ID_3COM,     PCI_DEVICE_ID_3COM_3C595,      t595_probe },
    267   { PCI_VENDOR_ID_3COM,     PCI_DEVICE_ID_3COM_3C595_1,    t595_probe },
    268   { PCI_VENDOR_ID_3COM,     PCI_DEVICE_ID_3COM_3C595_2,    t595_probe },
    269   { PCI_VENDOR_ID_3COM,     PCI_DEVICE_ID_3COM_3C900TPO,   t595_probe },
    270   { PCI_VENDOR_ID_3COM,     PCI_DEVICE_ID_3COM_3C900COMBO, t595_probe },
    271   { PCI_VENDOR_ID_3COM,     0x9004,                        t595_probe },
    272   { PCI_VENDOR_ID_3COM,     0x9005,                        t595_probe },
    273   { PCI_VENDOR_ID_3COM,     0x9006,                        t595_probe },
    274   { PCI_VENDOR_ID_3COM,     0x900A,                        t595_probe },
    275   { PCI_VENDOR_ID_3COM,     0x9800,                        t595_probe },
    276   { PCI_VENDOR_ID_3COM,     0x9805,                        t595_probe },
    277   { PCI_VENDOR_ID_3COM,     0x7646,                        t595_probe },
    278 # endif /* INCLUDE_3C595 */
    279 # ifdef	INCLUDE_EEPRO100
    280   { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82557,     eepro100_probe },
    281   { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82559ER,   eepro100_probe },
    282   { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_ID1029,    eepro100_probe },
    283   { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_ID1030,    eepro100_probe },
    284   { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82562,     eepro100_probe },
    285 # endif /* INCLUDE_EEPRO100 */
    286 # ifdef	INCLUDE_EPIC100
    287   { PCI_VENDOR_ID_SMC,      PCI_DEVICE_ID_SMC_EPIC100,     epic100_probe },
    288 # endif /* INCLUDE_EPIC100 */
    289 # ifdef	INCLUDE_LANCE
    290   { PCI_VENDOR_ID_AMD,      PCI_DEVICE_ID_AMD_LANCE,       lancepci_probe },
    291   { PCI_VENDOR_ID_AMD_HOMEPNA, PCI_DEVICE_ID_AMD_HOMEPNA,  lancepci_probe },
    292 # endif /* INCLUDE_LANCE */
    293 # ifdef	INCLUDE_RTL8139
    294   { PCI_VENDOR_ID_REALTEK,  PCI_DEVICE_ID_REALTEK_8139,    rtl8139_probe },
    295   { PCI_VENDOR_ID_DLINK,    PCI_DEVICE_ID_DFE530TXP,       rtl8139_probe },
    296   { PCI_VENDOR_ID_SMC_1211, PCI_DEVICE_ID_SMC_1211,        rtl8139_probe },
    297 # endif /* INCLUDE_RTL8139 */
    298 # ifdef	INCLUDE_OTULIP
    299   { PCI_VENDOR_ID_DEC,      PCI_DEVICE_ID_DEC_TULIP,       otulip_probe },
    300   { PCI_VENDOR_ID_DEC,      PCI_DEVICE_ID_DEC_TULIP_FAST,  otulip_probe },
    301   { PCI_VENDOR_ID_DEC,      PCI_DEVICE_ID_DEC_TULIP_PLUS,  otulip_probe },
    302   { PCI_VENDOR_ID_DEC,      PCI_DEVICE_ID_DEC_21142,       otulip_probe },
    303 # endif /* INCLUDE_OTULIP */
    304 # ifdef	INCLUDE_TULIP
    305   { PCI_VENDOR_ID_DEC,      PCI_DEVICE_ID_DEC_TULIP,       tulip_probe },
    306   { PCI_VENDOR_ID_DEC,      PCI_DEVICE_ID_DEC_TULIP_FAST,  tulip_probe },
    307   { PCI_VENDOR_ID_DEC,      PCI_DEVICE_ID_DEC_TULIP_PLUS,  tulip_probe },
    308   { PCI_VENDOR_ID_DEC,      PCI_DEVICE_ID_DEC_21142,       tulip_probe },
    309   { PCI_VENDOR_ID_MACRONIX, PCI_DEVICE_ID_MX987x5,         tulip_probe },
    310   { PCI_VENDOR_ID_LINKSYS,  PCI_DEVICE_ID_LC82C115,        tulip_probe },
    311   { PCI_VENDOR_ID_LINKSYS,  PCI_DEVICE_ID_DEC_TULIP,       tulip_probe },
    312   { PCI_VENDOR_ID_DAVICOM,  PCI_DEVICE_ID_DM9102,          tulip_probe },
    313   { PCI_VENDOR_ID_DAVICOM,  PCI_DEVICE_ID_DM9009,          tulip_probe },
    314   { PCI_VENDOR_ID_ADMTEK,   PCI_DEVICE_ID_ADMTEK_0985,     tulip_probe },
    315   { PCI_VENDOR_ID_ADMTEK,   0x0981,                        tulip_probe },
    316   { 0x125B,                 0x1400,                        tulip_probe },
    317   { 0x11F6,                 0x9881,                        tulip_probe },
    318 # endif /* INCLUDE_TULIP */
    319 # ifdef INCLUDE_DAVICOM
    320   { PCI_VENDOR_ID_DAVICOM,   PCI_DEVICE_ID_DM9102,           davicom_probe },
    321   { PCI_VENDOR_ID_DAVICOM,   PCI_DEVICE_ID_DM9009,           davicom_probe },
    322 # endif /* INCLUDE_DAVICOM */
    323 # ifdef	INCLUDE_VIA_RHINE
    324   { PCI_VENDOR_ID_VIATEC,   PCI_DEVICE_ID_VIA_VT6102,      rhine_probe },
    325   { PCI_VENDOR_ID_VIATEC,   PCI_DEVICE_ID_VIA_RHINE_I,     rhine_probe },
    326   { PCI_VENDOR_ID_VIATEC,   PCI_DEVICE_ID_VIA_86C100A,     rhine_probe },
    327 # endif /* INCLUDE_VIA_RHINE */
    328 # ifdef INCLUDE_W89C840
    329   { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_89C840, w89c840_probe },
    330   { PCI_VENDOR_ID_COMPEX,   PCI_DEVICE_ID_COMPEX_RL100ATX, w89c840_probe },
    331 # endif /* INCLUDE_W89C840 */
    332 # ifdef INCLUDE_SIS900
    333   { PCI_VENDOR_ID_SIS,      PCI_DEVICE_ID_SIS900,          sis900_probe },
    334   { PCI_VENDOR_ID_SIS,      PCI_DEVICE_ID_SIS7016,         sis900_probe },
    335 # endif /* INCLUDE_SIS900 */
    336 # ifdef INCLUDE_NATSEMI
    337   { PCI_VENDOR_ID_NS,       PCI_DEVICE_ID_DP83815,         natsemi_probe },
    338 # endif /* INCLUDE_NATSEMI */
    339 # ifdef INCLUDE_TLAN
    340   { PCI_VENDOR_ID_OLICOM,   PCI_DEVICE_ID_OLICOM_OC2326,   tlan_probe },
    341 # endif /* INCLUDE_TLAN */
    342   { 0,                      0,                             0 }
    343 };
    344 #endif /* GRUB && INCLUDE_PCI */
    345 
    346 struct dispatch_table
    347 {
    348   const char	*nic_name;
    349 #ifdef	INCLUDE_PCI
    350   struct nic	*(*eth_probe) (struct nic *, unsigned short *,
    351 			       struct pci_device *);
    352 #else
    353   struct nic	*(*eth_probe) (struct nic *, unsigned short *);
    354 #endif	/* INCLUDE_PCI */
    355   unsigned short	*probe_ioaddrs;		/* for probe overrides */
    356 };
    357 
    358 /*
    359  *	NIC probing is in order of appearance in this table.
    360  *	If for some reason you want to change the order,
    361  *	just rearrange the entries (bracketed by the #ifdef/#endif)
    362  */
    363 static struct dispatch_table	NIC[] =
    364 {
    365 #ifdef	INCLUDE_RTL8139
    366   { "RTL8139", rtl8139_probe, pci_ioaddrs },
    367 #endif
    368 #ifdef INCLUDE_SIS900
    369   { "SIS900", sis900_probe, pci_ioaddrs },
    370 #endif
    371 #ifdef INCLUDE_NATSEMI
    372   { "NATSEMI", natsemi_probe, pci_ioaddrs },
    373 #endif
    374 #ifdef	INCLUDE_WD
    375   { "WD", wd_probe, 0 },
    376 #endif
    377 #ifdef	INCLUDE_3C503
    378   { "3C503", t503_probe, 0 },
    379 #endif
    380 #ifdef	INCLUDE_NE
    381   { "NE*000", ne_probe, 0 },
    382 #endif
    383 #ifdef	INCLUDE_3C509
    384   { "3C5x9", t509_probe, 0 },
    385 #endif
    386 #ifdef	INCLUDE_3C529
    387   { "3C5x9", t529_probe, 0 },
    388 #endif
    389 #ifdef	INCLUDE_3C595
    390   { "3C595", t595_probe, pci_ioaddrs },
    391 #endif
    392 #ifdef	INCLUDE_3C90X
    393   { "3C90X", a3c90x_probe, pci_ioaddrs },
    394 #endif
    395 #ifdef	INCLUDE_EEPRO
    396   { "EEPRO", eepro_probe, 0 },
    397 #endif
    398 #ifdef	INCLUDE_EEPRO100
    399   { "EEPRO100", eepro100_probe, pci_ioaddrs },
    400 #endif
    401 #ifdef	INCLUDE_EPIC100
    402   { "EPIC100", epic100_probe, pci_ioaddrs },
    403 #endif
    404 #ifdef	INCLUDE_OTULIP
    405   { "OTulip", otulip_probe, pci_ioaddrs },
    406 #endif
    407 #ifdef	INCLUDE_TULIP
    408   { "Tulip", tulip_probe, pci_ioaddrs },
    409 #endif
    410 #ifdef	INCLUDE_DAVICOM
    411   { "DAVICOM", davicom_probe, pci_ioaddrs },
    412 #endif
    413 #ifdef	INCLUDE_CS89X0
    414   { "CS89x0", cs89x0_probe, 0 },
    415 #endif
    416 #ifdef	INCLUDE_NE2100
    417   { "NE2100", ne2100_probe, 0 },
    418 #endif
    419 #ifdef	INCLUDE_NI6510
    420   { "NI6510", ni6510_probe, 0 },
    421 #endif
    422 #ifdef	INCLUDE_SK_G16
    423   { "SK_G16", SK_probe, 0 },
    424 #endif
    425 #ifdef	INCLUDE_3C507
    426   { "3C507", t507_probe, 0 },
    427 #endif
    428 #ifdef	INCLUDE_NI5010
    429   { "NI5010", ni5010_probe, 0 },
    430 #endif
    431 #ifdef	INCLUDE_NI5210
    432   { "NI5210", ni5210_probe, 0 },
    433 #endif
    434 #ifdef	INCLUDE_EXOS205
    435   { "EXOS205", exos205_probe, 0 },
    436 #endif
    437 #ifdef	INCLUDE_SMC9000
    438   { "SMC9000", smc9000_probe, 0 },
    439 #endif
    440 #ifdef	INCLUDE_TIARA
    441   { "TIARA", tiara_probe, 0 },
    442 #endif
    443 #ifdef	INCLUDE_DEPCA
    444   { "DEPCA", depca_probe, 0 },
    445 #endif
    446 #ifdef	INCLUDE_NS8390
    447   { "NE2000/PCI", nepci_probe, pci_ioaddrs },
    448 #endif
    449 #ifdef	INCLUDE_LANCE
    450   { "LANCE/PCI", lancepci_probe, pci_ioaddrs },
    451 #endif
    452 #ifdef	INCLUDE_VIA_RHINE
    453   { "VIA 86C100", rhine_probe, pci_ioaddrs },
    454 #endif
    455 #ifdef	INCLUDE_W89C840
    456   { "W89C840F", w89c840_probe, pci_ioaddrs },
    457 #endif
    458 #ifdef	INCLUDE_TLAN
    459   { "Olicom 2326", tlan_probe, pci_ioaddrs },
    460 #endif
    461   /* this entry must always be last to mark the end of list */
    462   { 0, 0, 0 }
    463 };
    464 
    465 #define	NIC_TABLE_SIZE	(sizeof (NIC) / sizeof (NIC[0]))
    466 
    467 static int
    468 eth_dummy (struct nic *dummy)
    469 {
    470   return 0;
    471 }
    472 
    473 static char	packet[ETH_FRAME_LEN];
    474 
    475 struct nic	nic =
    476 {
    477   (void (*) (struct nic *)) eth_dummy,	/* reset */
    478   eth_dummy,				/* poll */
    479   (void (*) (struct nic *, const char *,
    480 	     unsigned int, unsigned int,
    481 	     const char *)) eth_dummy,	/* transmit */
    482   (void (*) (struct nic *)) eth_dummy,	/* disable */
    483 #ifdef	T503_AUI
    484   1,					/* aui */
    485 #else
    486   0,					/* no aui */
    487 #endif
    488   &rom,					/* rom_info */
    489   arptable[ARP_CLIENT].node,		/* node_addr */
    490   packet,				/* packet */
    491   0,				/* packetlen */
    492   0,				/* priv_data */
    493 };
    494 
    495 void
    496 eth_reset (void)
    497 {
    498   (*nic.reset) (&nic);
    499 }
    500 
    501 int
    502 eth_probe (void)
    503 {
    504   struct pci_device	*p;
    505   const struct dispatch_table	*t;
    506   static int probed = 0;
    507 
    508   /* If already probed, don't try to probe it any longer.  */
    509   if (probed)
    510     return 1;
    511 
    512   /* Clear the ready flag.  */
    513   network_ready = 0;
    514   /* Clear the ARP table.  */
    515   grub_memset ((char *) arptable, 0,
    516 	       MAX_ARP * sizeof (struct arptable_t));
    517 
    518   p = 0;
    519 
    520 #ifdef	INCLUDE_PCI
    521   /* In GRUB, the ROM info is initialized here.  */
    522   rom = *((struct rom_info *) ROM_INFO_LOCATION);
    523 
    524   eth_pci_init(pci_nic_list);
    525   pci_ioaddrs[0] = 0;
    526   pci_ioaddrs[1] = 0;
    527   /* at this point we have a list of possible PCI candidates
    528      we just pick the first one with a non-zero ioaddr */
    529   for (p = pci_nic_list; p->vendor != 0; ++p)
    530     {
    531       if (p->ioaddr != 0)
    532 	{
    533 	  pci_ioaddrs[0] = p->ioaddr;
    534 	  break;
    535 	}
    536     }
    537 #endif
    538 
    539   etherboot_printf("Probing...");
    540 
    541 #ifdef INCLUDE_PCI
    542   if (p->vendor)
    543     {
    544       struct pci_dispatch_table *pt;
    545 
    546       for (pt = PCI_NIC; pt->eth_probe != 0; pt++)
    547 	if (p->vendor == pt->vendor && p->dev_id == pt->dev_id)
    548 	  {
    549 	    etherboot_printf ("[%s]", p->name);
    550 	    if ((pt->eth_probe) (&nic, pci_ioaddrs, p))
    551 	      {
    552 		probed = 1;
    553 		return 1;
    554 	      }
    555 	  }
    556     }
    557 #endif /* INCLUDE_PCI */
    558 
    559   for (t = NIC; t->nic_name != 0; ++t)
    560     {
    561       etherboot_printf("[%s]", t->nic_name);
    562 #ifdef	INCLUDE_PCI
    563       if ((*t->eth_probe) (&nic, t->probe_ioaddrs, p))
    564 	{
    565 	  probed = 1;
    566 	  return 1;
    567 	}
    568 #else
    569       if ((*t->eth_probe) (&nic, t->probe_ioaddrs))
    570 	{
    571 	  probed = 1;
    572 	  return 1;
    573 	}
    574 #endif	/* INCLUDE_PCI */
    575     }
    576 
    577   return 0;
    578 }
    579 
    580 int
    581 eth_poll (void)
    582 {
    583   return ((*nic.poll) (&nic));
    584 }
    585 
    586 void
    587 eth_transmit (const char *d, unsigned int t, unsigned int s, const void *p)
    588 {
    589   (*nic.transmit) (&nic, d, t, s, p);
    590   if (t == IP)
    591     twiddle ();
    592 }
    593 
    594 void
    595 eth_disable (void)
    596 {
    597   (*nic.disable) (&nic);
    598 }
    599