home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / KERNEL-S / V1.2 / LINUX-1.2 / LINUX-1 / linux / drivers / net / Space.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-12  |  10.3 KB  |  327 lines

  1. /*
  2.  * INET        An implementation of the TCP/IP protocol suite for the LINUX
  3.  *        operating system.  INET is implemented using the  BSD Socket
  4.  *        interface as the means of communication with the user level.
  5.  *
  6.  *        Holds initial configuration information for devices.
  7.  *
  8.  * NOTE:    This file is a nice idea, but its current format does not work
  9.  *        well for drivers that support multiple units, like the SLIP
  10.  *        driver.  We should actually have only one pointer to a driver
  11.  *        here, with the driver knowing how many units it supports.
  12.  *        Currently, the SLIP driver abuses the "base_addr" integer
  13.  *        field of the 'device' structure to store the unit number...
  14.  *        -FvK
  15.  *
  16.  * Version:    @(#)Space.c    1.0.7    08/12/93
  17.  *
  18.  * Authors:    Ross Biro, <bir7@leland.Stanford.Edu>
  19.  *        Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  20.  *        Donald J. Becker, <becker@super.org>
  21.  *
  22.  *        This program is free software; you can redistribute it and/or
  23.  *        modify it under the terms of the GNU General Public License
  24.  *        as published by the Free Software Foundation; either version
  25.  *        2 of the License, or (at your option) any later version.
  26.  */
  27. #include <linux/config.h>
  28. #include <linux/netdevice.h>
  29. #include <linux/errno.h>
  30.  
  31. #define    NEXT_DEV    NULL
  32.  
  33.  
  34. /* A unified ethernet device probe.  This is the easiest way to have every
  35.    ethernet adaptor have the name "eth[0123...]".
  36.    */
  37.  
  38. extern int ultra_probe(struct device *dev);
  39. extern int wd_probe(struct device *dev);
  40. extern int el2_probe(struct device *dev);
  41. extern int ne_probe(struct device *dev);
  42. extern int hp_probe(struct device *dev);
  43. extern int hp_plus_probe(struct device *dev);
  44. extern int znet_probe(struct device *);
  45. extern int express_probe(struct device *);
  46. extern int el3_probe(struct device *);
  47. extern int at1500_probe(struct device *);
  48. extern int at1700_probe(struct device *);
  49. extern int depca_probe(struct device *);
  50. extern int apricot_probe(struct device *);
  51. extern int ewrk3_probe(struct device *);
  52. extern int de4x5_probe(struct device *);
  53. extern int el1_probe(struct device *);
  54. #if    defined(CONFIG_WAVELAN)
  55. extern int wavelan_probe(struct device *);
  56. #endif    /* defined(CONFIG_WAVELAN) */
  57. extern int el16_probe(struct device *);
  58. extern int elplus_probe(struct device *);
  59. extern int ac3200_probe(struct device *);
  60. extern int e2100_probe(struct device *);
  61. extern int ni52_probe(struct device *);
  62. extern int ni65_probe(struct device *);
  63. extern int SK_init(struct device *);
  64.  
  65. /* Detachable devices ("pocket adaptors") */
  66. extern int atp_init(struct device *);
  67. extern int de600_probe(struct device *);
  68. extern int de620_probe(struct device *);
  69.  
  70. static int
  71. ethif_probe(struct device *dev)
  72. {
  73.     short base_addr = dev->base_addr;
  74.  
  75.     if (base_addr < 0  ||  base_addr == 1)
  76.     return 1;        /* ENXIO */
  77.  
  78.     if (1
  79. #if defined(CONFIG_ULTRA)
  80.     && ultra_probe(dev)
  81. #endif
  82. #if defined(CONFIG_WD80x3) || defined(WD80x3)
  83.     && wd_probe(dev)
  84. #endif
  85. #if defined(CONFIG_EL2) || defined(EL2)    /* 3c503 */
  86.     && el2_probe(dev)
  87. #endif
  88. #if defined(CONFIG_NE2000) || defined(NE2000)
  89.     && ne_probe(dev)
  90. #endif
  91. #if defined(CONFIG_HPLAN) || defined(HPLAN)
  92.     && hp_probe(dev)
  93. #endif
  94. #if defined(CONFIG_HPLAN_PLUS)
  95.     && hp_plus_probe(dev)
  96. #endif
  97. #ifdef CONFIG_AT1500
  98.     && at1500_probe(dev)
  99. #endif
  100. #ifdef CONFIG_AT1700
  101.     && at1700_probe(dev)
  102. #endif
  103. #ifdef CONFIG_EL3        /* 3c509 */
  104.     && el3_probe(dev)
  105. #endif
  106. #ifdef CONFIG_ZNET        /* Zenith Z-Note and some IBM Thinkpads. */
  107.     && znet_probe(dev)
  108. #endif
  109. #ifdef CONFIG_EEXPRESS        /* Intel EtherExpress */
  110.     && express_probe(dev)
  111. #endif
  112. #ifdef CONFIG_DEPCA        /* DEC DEPCA */
  113.     && depca_probe(dev)
  114. #endif
  115. #ifdef CONFIG_EWRK3             /* DEC EtherWORKS 3 */
  116.         && ewrk3_probe(dev)
  117. #endif
  118. #ifdef CONFIG_DE4X5             /* DEC DE425, DE434, DE435 adapters */
  119.         && de4x5_probe(dev)
  120. #endif
  121. #ifdef CONFIG_APRICOT        /* Apricot I82596 */
  122.     && apricot_probe(dev)
  123. #endif
  124. #ifdef CONFIG_EL1        /* 3c501 */
  125.     && el1_probe(dev)
  126. #endif
  127. #if    defined(CONFIG_WAVELAN)    /* WaveLAN */
  128.     && wavelan_probe(dev)
  129. #endif    /* defined(CONFIG_WAVELAN) */
  130. #ifdef CONFIG_EL16        /* 3c507 */
  131.     && el16_probe(dev)
  132. #endif
  133. #ifdef CONFIG_ELPLUS        /* 3c505 */
  134.     && elplus_probe(dev)
  135. #endif
  136. #ifdef CONFIG_AC3200        /* Ansel Communications EISA 3200. */
  137.     && ac3200_probe(dev)
  138. #endif
  139. #ifdef CONFIG_E2100        /* Cabletron E21xx series. */
  140.     && e2100_probe(dev)
  141. #endif
  142. #ifdef CONFIG_DE600        /* D-Link DE-600 adapter */
  143.     && de600_probe(dev)
  144. #endif
  145. #ifdef CONFIG_DE620        /* D-Link DE-620 adapter */
  146.     && de620_probe(dev)
  147. #endif
  148. #if defined(CONFIG_SK_G16)
  149.     && SK_init(dev)
  150. #endif
  151. #ifdef CONFIG_NI52
  152.     && ni52_probe(dev)
  153. #endif
  154. #ifdef CONFIG_NI65
  155.     && ni65_probe(dev)
  156. #endif
  157.     && 1 ) {
  158.     return 1;    /* -ENODEV or -EAGAIN would be more accurate. */
  159.     }
  160.     return 0;
  161. }
  162.  
  163.  
  164.  
  165. /* Run-time ATtachable (Pocket) devices have a different (not "eth#") name. */
  166. #ifdef CONFIG_ATP        /* AT-LAN-TEC (RealTek) pocket adaptor. */
  167. static struct device atp_dev = {
  168.     "atp0", 0, 0, 0, 0, 0, 0, 0, 0, 0, NEXT_DEV, atp_init, /* ... */ };
  169. #   undef NEXT_DEV
  170. #   define NEXT_DEV    (&atp_dev)
  171. #endif
  172.  
  173. /* The first device defaults to I/O base '0', which means autoprobe. */
  174. #ifndef ETH0_ADDR
  175. # define ETH0_ADDR 0
  176. #endif
  177. #ifndef ETH0_IRQ
  178. # define ETH0_IRQ 0
  179. #endif
  180. /* "eth0" defaults to autoprobe (== 0), other use a base of 0xffe0 (== -0x20),
  181.    which means "don't probe".  These entries exist to only to provide empty
  182.    slots which may be enabled at boot-time. */
  183.  
  184. static struct device eth3_dev = {
  185.     "eth3", 0,0,0,0,0xffe0 /* I/O base*/, 0,0,0,0, NEXT_DEV, ethif_probe };
  186. static struct device eth2_dev = {
  187.     "eth2", 0,0,0,0,0xffe0 /* I/O base*/, 0,0,0,0, ð3_dev, ethif_probe };
  188. static struct device eth1_dev = {
  189.     "eth1", 0,0,0,0,0xffe0 /* I/O base*/, 0,0,0,0, ð2_dev, ethif_probe };
  190.  
  191. static struct device eth0_dev = {
  192.     "eth0", 0, 0, 0, 0, ETH0_ADDR, ETH0_IRQ, 0, 0, 0, ð1_dev, ethif_probe };
  193.  
  194. #   undef NEXT_DEV
  195. #   define NEXT_DEV    (ð0_dev)
  196.  
  197. #if defined(PLIP) || defined(CONFIG_PLIP)
  198.     extern int plip_init(struct device *);
  199.     static struct device plip2_dev = {
  200.     "plip2", 0, 0, 0, 0, 0x278, 2, 0, 0, 0, NEXT_DEV, plip_init, };
  201.     static struct device plip1_dev = {
  202.     "plip1", 0, 0, 0, 0, 0x378, 7, 0, 0, 0, &plip2_dev, plip_init, };
  203.     static struct device plip0_dev = {
  204.     "plip0", 0, 0, 0, 0, 0x3BC, 5, 0, 0, 0, &plip1_dev, plip_init, };
  205. #   undef NEXT_DEV
  206. #   define NEXT_DEV    (&plip0_dev)
  207. #endif  /* PLIP */
  208.  
  209. #if defined(SLIP) || defined(CONFIG_SLIP)
  210.     extern int slip_init(struct device *);
  211.     
  212. #ifdef SL_SLIP_LOTS
  213.  
  214.     static struct device slip15_dev={"sl15",0,0,0,0,15,0,0,0,0,NEXT_DEV,slip_init};
  215.     static struct device slip14_dev={"sl14",0,0,0,0,14,0,0,0,0,&slip15_dev,slip_init};
  216.     static struct device slip13_dev={"sl13",0,0,0,0,13,0,0,0,0,&slip14_dev,slip_init};
  217.     static struct device slip12_dev={"sl12",0,0,0,0,12,0,0,0,0,&slip13_dev,slip_init};
  218.     static struct device slip11_dev={"sl11",0,0,0,0,11,0,0,0,0,&slip12_dev,slip_init};
  219.     static struct device slip10_dev={"sl10",0,0,0,0,10,0,0,0,0,&slip11_dev,slip_init};
  220.     static struct device slip9_dev={"sl9",0,0,0,0,9,0,0,0,0,&slip10_dev,slip_init};
  221.     static struct device slip8_dev={"sl8",0,0,0,0,8,0,0,0,0,&slip9_dev,slip_init};
  222.     static struct device slip7_dev={"sl7",0,0,0,0,7,0,0,0,0,&slip8_dev,slip_init};
  223.     static struct device slip6_dev={"sl6",0,0,0,0,6,0,0,0,0,&slip7_dev,slip_init};
  224.     static struct device slip5_dev={"sl5",0,0,0,0,5,0,0,0,0,&slip6_dev,slip_init};
  225.     static struct device slip4_dev={"sl4",0,0,0,0,4,0,0,0,0,&slip5_dev,slip_init};
  226. #   undef    NEXT_DEV
  227. #   define    NEXT_DEV    (&slip4_dev)
  228. #endif    /* SL_SLIP_LOTS */
  229.     
  230.     static struct device slip3_dev = {
  231.     "sl3",            /* Internal SLIP driver, channel 3    */
  232.     0x0,            /* recv memory end            */
  233.     0x0,            /* recv memory start            */
  234.     0x0,            /* memory end                */
  235.     0x0,            /* memory start                */
  236.     0x3,            /* base I/O address            */
  237.     0,            /* IRQ                    */
  238.     0, 0, 0,        /* flags                */
  239.     NEXT_DEV,        /* next device                */
  240.     slip_init        /* slip_init should set up the rest    */
  241.     };
  242.     static struct device slip2_dev = {
  243.     "sl2",            /* Internal SLIP driver, channel 2    */
  244.     0x0,            /* recv memory end            */
  245.     0x0,            /* recv memory start            */
  246.     0x0,            /* memory end                */
  247.     0x0,            /* memory start                */
  248.     0x2,            /* base I/O address            */
  249.     0,            /* IRQ                    */
  250.     0, 0, 0,        /* flags                */
  251.     &slip3_dev,        /* next device                */
  252.     slip_init        /* slip_init should set up the rest    */
  253.     };
  254.     static struct device slip1_dev = {
  255.     "sl1",            /* Internal SLIP driver, channel 1    */
  256.     0x0,            /* recv memory end            */
  257.     0x0,            /* recv memory start            */
  258.     0x0,            /* memory end                */
  259.     0x0,            /* memory start                */
  260.     0x1,            /* base I/O address            */
  261.     0,            /* IRQ                    */
  262.     0, 0, 0,        /* flags                */
  263.     &slip2_dev,        /* next device                */
  264.     slip_init        /* slip_init should set up the rest    */
  265.     };
  266.     static struct device slip0_dev = {
  267.     "sl0",            /* Internal SLIP driver, channel 0    */
  268.     0x0,            /* recv memory end            */
  269.     0x0,            /* recv memory start            */
  270.     0x0,            /* memory end                */
  271.     0x0,            /* memory start                */
  272.     0x0,            /* base I/O address            */
  273.     0,            /* IRQ                    */
  274.     0, 0, 0,        /* flags                */
  275.     &slip1_dev,        /* next device                */
  276.     slip_init        /* slip_init should set up the rest    */
  277.     };
  278. #   undef    NEXT_DEV
  279. #   define    NEXT_DEV    (&slip0_dev)
  280. #endif    /* SLIP */
  281.   
  282. #if defined(CONFIG_PPP)
  283. extern int ppp_init(struct device *);
  284. static struct device ppp3_dev = {
  285.     "ppp3", 0x0, 0x0, 0x0, 0x0, 3, 0, 0, 0, 0, NEXT_DEV,  ppp_init, };
  286. static struct device ppp2_dev = {
  287.     "ppp2", 0x0, 0x0, 0x0, 0x0, 2, 0, 0, 0, 0, &ppp3_dev, ppp_init, };
  288. static struct device ppp1_dev = {
  289.     "ppp1", 0x0, 0x0, 0x0, 0x0, 1, 0, 0, 0, 0, &ppp2_dev, ppp_init, };
  290. static struct device ppp0_dev = {
  291.     "ppp0", 0x0, 0x0, 0x0, 0x0, 0, 0, 0, 0, 0, &ppp1_dev, ppp_init, };
  292. #undef NEXT_DEV
  293. #define NEXT_DEV (&ppp0_dev)
  294. #endif   /* PPP */
  295.  
  296. #ifdef CONFIG_ARCNET
  297.     extern int arcnet_probe(struct device *dev);
  298.     static struct device arcnet_dev = {
  299.     "arc0", 0x0, 0x0, 0x0, 0x0, 0, 0, 0, 0, 0, NEXT_DEV, arcnet_probe, };
  300. #   undef    NEXT_DEV
  301. #   define    NEXT_DEV    (&arcnet_dev)
  302. #endif
  303.  
  304. #ifdef CONFIG_DUMMY
  305.     extern int dummy_init(struct device *dev);
  306.     static struct device dummy_dev = {
  307.     "dummy", 0x0, 0x0, 0x0, 0x0, 0, 0, 0, 0, 0, NEXT_DEV, dummy_init, };
  308. #   undef    NEXT_DEV
  309. #   define    NEXT_DEV    (&dummy_dev)
  310. #endif
  311.  
  312. extern int loopback_init(struct device *dev);
  313. struct device loopback_dev = {
  314.     "lo",            /* Software Loopback interface        */
  315.     0x0,            /* recv memory end            */
  316.     0x0,            /* recv memory start            */
  317.     0x0,            /* memory end                */
  318.     0x0,            /* memory start                */
  319.     0,            /* base I/O address            */
  320.     0,            /* IRQ                    */
  321.     0, 0, 0,        /* flags                */
  322.     NEXT_DEV,        /* next device                */
  323.     loopback_init        /* loopback_init should set up the rest    */
  324. };
  325.  
  326. struct device *dev_base = &loopback_dev;
  327.