The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/ex/if_ex_isa.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2000 Matthew N. Dodd
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  *      $FreeBSD: stable/4/sys/dev/ex/if_ex_isa.c 73590 2001-03-05 05:33:20Z imp $
   27  */
   28 
   29 #include <sys/param.h>
   30 #include <sys/systm.h>
   31 #include <sys/kernel.h>
   32 #include <sys/socket.h>
   33 
   34 #include <sys/module.h>
   35 #include <sys/bus.h>
   36 
   37 #include <machine/bus.h>
   38 #include <machine/resource.h>
   39 #include <sys/rman.h>
   40 
   41 #include <net/if.h>
   42 #include <net/if_arp.h>
   43 #include <net/if_media.h> 
   44 
   45 
   46 #include <isa/isavar.h>
   47 #include <isa/pnpvar.h>
   48 
   49 #include <dev/ex/if_exreg.h>
   50 #include <dev/ex/if_exvar.h>
   51 
   52 /* Bus Front End Functions */
   53 static void     ex_isa_identify __P((driver_t *, device_t));
   54 static int      ex_isa_probe    __P((device_t));
   55 static int      ex_isa_attach   __P((device_t));
   56 
   57 #if 0
   58 static  void    ex_pnp_wakeup   (void *);
   59 
   60 SYSINIT(ex_pnpwakeup, SI_SUB_CPU, SI_ORDER_ANY, ex_pnp_wakeup, NULL);
   61 #endif
   62 
   63 static device_method_t ex_methods[] = {
   64         /* Device interface */
   65         DEVMETHOD(device_identify,      ex_isa_identify),
   66         DEVMETHOD(device_probe,         ex_isa_probe),
   67         DEVMETHOD(device_attach,        ex_isa_attach),
   68 
   69         { 0, 0 }
   70 };
   71 
   72 static driver_t ex_driver = {
   73         "ex",
   74         ex_methods,
   75         sizeof(struct ex_softc),
   76 };
   77 
   78 devclass_t ex_devclass;
   79 
   80 DRIVER_MODULE(ex, isa, ex_driver, ex_devclass, 0, 0);
   81 
   82 static struct isa_pnp_id ex_ids[] = {
   83         { 0x3110d425,   NULL }, /* INT1031 */
   84         { 0x3010d425,   NULL }, /* INT1030 */
   85         { 0,            NULL },
   86 };
   87 
   88 #if 0
   89 #define EX_PNP_WAKE             0x279
   90 
   91 static u_int8_t ex_pnp_wake_seq[] =
   92                         { 0x6A, 0xB5, 0xDA, 0xED, 0xF6, 0xFB, 0x7D, 0xBE,
   93                           0xDF, 0x6F, 0x37, 0x1B, 0x0D, 0x86, 0xC3, 0x61,
   94                           0xB0, 0x58, 0x2C, 0x16, 0x8B, 0x45, 0xA2, 0xD1,
   95                           0xE8, 0x74, 0x3A, 0x9D, 0xCE, 0xE7, 0x73, 0x43 };
   96 
   97 static void
   98 ex_pnp_wakeup (void * dummy)
   99 {
  100         int     tmp;
  101 
  102         if (bootverbose)
  103                 printf("ex_pnp_wakeup()\n");
  104 
  105         outb(EX_PNP_WAKE, 0);
  106         outb(EX_PNP_WAKE, 0);
  107         for (tmp = 0; tmp < 32; tmp++) {
  108                 outb(EX_PNP_WAKE, ex_pnp_wake_seq[tmp]);
  109         }
  110 }
  111 #endif
  112 
  113 /*
  114  * Non-destructive identify.
  115  */
  116 static void
  117 ex_isa_identify (driver_t *driver, device_t parent)
  118 {
  119         device_t        child;
  120         u_int32_t       ioport;
  121         u_char          enaddr[6];
  122         u_int           irq;
  123         int             tmp;
  124         const char *    desc;
  125 
  126         if (bootverbose)
  127                 printf("ex_isa_identify()\n");
  128 
  129         for (ioport = 0x200; ioport < 0x3a0; ioport += 0x10) {
  130 
  131                 /* No board found at address */
  132                 if (!look_for_card(ioport)) {
  133                         continue;
  134                 }
  135 
  136                 if (bootverbose)
  137                         printf("ex: Found card at 0x%03x!\n", ioport);
  138 
  139                 /* Board in PnP mode */
  140                 if (eeprom_read(ioport, EE_W0) & EE_W0_PNP) {
  141                         /* Reset the card. */
  142                         outb(ioport + CMD_REG, Reset_CMD);
  143                         DELAY(500);
  144                         if (bootverbose)
  145                                 printf("ex: card at 0x%03x in PnP mode!\n", ioport);
  146                         continue;
  147                 }
  148 
  149                 bzero(enaddr, sizeof(enaddr));
  150 
  151                 /* Reset the card. */
  152                 outb(ioport + CMD_REG, Reset_CMD);
  153                 DELAY(400);
  154 
  155                 ex_get_address(ioport, enaddr);
  156                 tmp = eeprom_read(ioport, EE_W1) & EE_W1_INT_SEL;
  157 
  158                 /* work out which set of irq <-> internal tables to use */
  159                 if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) {
  160                         irq  = plus_ee2irqmap[tmp];
  161                         desc = "Intel Pro/10+";
  162                 } else {
  163                         irq = ee2irqmap[tmp];
  164                         desc = "Intel Pro/10";
  165                 }
  166 
  167                 child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "ex", -1);
  168                 device_set_desc_copy(child, desc);
  169                 device_set_driver(child, driver);
  170                 bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1);
  171                 bus_set_resource(child, SYS_RES_IOPORT, 0, ioport, EX_IOSIZE);
  172 
  173                 if (bootverbose)
  174                         printf("ex: Adding board at 0x%03x, irq %d\n", ioport, irq);
  175         }
  176 
  177         return;
  178 }
  179 
  180 static int
  181 ex_isa_probe(device_t dev)
  182 {
  183         u_int           iobase;
  184         u_int           irq;
  185         char *          irq2ee;
  186         u_char *        ee2irq;
  187         u_char          enaddr[6];
  188         int             tmp;
  189         int             error;
  190 
  191         /* Check isapnp ids */
  192         error = ISA_PNP_PROBE(device_get_parent(dev), dev, ex_ids);
  193 
  194         /* If the card had a PnP ID that didn't match any we know about */
  195         if (error == ENXIO) {
  196                 return(error);
  197         }
  198 
  199         /* If we had some other problem. */
  200         if (!(error == 0 || error == ENOENT)) {
  201                 return(error);
  202         }
  203 
  204         iobase = bus_get_resource_start(dev, SYS_RES_IOPORT, 0);
  205         if (!iobase) {
  206                 printf("ex: no iobase?\n");
  207                 return(ENXIO);
  208         }
  209 
  210         if (!look_for_card(iobase)) {
  211                 printf("ex: no card found at 0x%03x\n", iobase);
  212                 return(ENXIO);
  213         }
  214 
  215         if (bootverbose)
  216                 printf("ex: ex_isa_probe() found card at 0x%03x\n", iobase);
  217 
  218         /*
  219          * Reset the card.
  220          */
  221         outb(iobase + CMD_REG, Reset_CMD);
  222         DELAY(800);
  223 
  224         ex_get_address(iobase, enaddr);
  225 
  226         /* work out which set of irq <-> internal tables to use */
  227         if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) {
  228                 irq2ee = plus_irq2eemap;
  229                 ee2irq = plus_ee2irqmap;
  230         } else {
  231                 irq2ee = irq2eemap;
  232                 ee2irq = ee2irqmap;
  233         }
  234 
  235         tmp = eeprom_read(iobase, EE_W1) & EE_W1_INT_SEL;
  236         irq = bus_get_resource_start(dev, SYS_RES_IRQ, 0);
  237 
  238         if (irq > 0) {
  239                 /* This will happen if board is in PnP mode. */
  240                 if (ee2irq[tmp] != irq) {
  241                         printf("ex: WARNING: board's EEPROM is configured"
  242                                 " for IRQ %d, using %d\n",
  243                                 ee2irq[tmp], irq);
  244                 }
  245         } else {
  246                 irq = ee2irq[tmp];
  247                 bus_set_resource(dev, SYS_RES_IRQ, 0, irq, 1);
  248         }
  249 
  250         if (irq == 0) {
  251                 printf("ex: invalid IRQ.\n");
  252                 return(ENXIO);
  253         }
  254 
  255         return(0);
  256 }
  257 
  258 static int
  259 ex_isa_attach(device_t dev)
  260 {
  261         struct ex_softc *       sc = device_get_softc(dev);
  262         int                     error = 0;
  263         u_int16_t               temp;
  264 
  265         sc->dev = dev;
  266         sc->ioport_rid = 0;
  267         sc->irq_rid = 0;
  268 
  269         if ((error = ex_alloc_resources(dev)) != 0) {
  270                 device_printf(dev, "ex_alloc_resources() failed!\n");
  271                 goto bad;
  272         }
  273 
  274         /*
  275          * Fill in several fields of the softc structure:
  276          *      - I/O base address.
  277          *      - Hardware Ethernet address.
  278          *      - IRQ number (if not supplied in config file, read it from EEPROM).
  279          *      - Connector type.
  280          */
  281         sc->iobase = rman_get_start(sc->ioport);
  282         sc->irq_no = rman_get_start(sc->irq);
  283 
  284         ex_get_address(sc->iobase, sc->arpcom.ac_enaddr);
  285 
  286         temp = eeprom_read(sc->iobase, EE_W0);
  287         device_printf(sc->dev, "%s config, %s bus, ",
  288                 (temp & EE_W0_PNP) ? "PnP" : "Manual",
  289                 (temp & EE_W0_BUS16) ? "16-bit" : "8-bit");
  290 
  291         temp = eeprom_read(sc->iobase, EE_W6);
  292         printf("board id 0x%03x, stepping 0x%01x\n",
  293                 (temp & EE_W6_BOARD_MASK) >> EE_W6_BOARD_SHIFT,
  294                 temp & EE_W6_STEP_MASK);
  295 
  296         if ((error = ex_attach(dev)) != 0) {
  297                 device_printf(dev, "ex_attach() failed!\n");
  298                 goto bad;
  299         }
  300 
  301         error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET,
  302                                 ex_intr, (void *)sc, &sc->ih);
  303         if (error) {
  304                 device_printf(dev, "bus_setup_intr() failed!\n");
  305                 goto bad;
  306         }
  307 
  308         return(0);
  309 bad:
  310         ex_release_resources(dev);
  311         return (error);
  312 }

Cache object: 6a74fd561da5509343ffa5e0a25763e5


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.