config.c 20 KB

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