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/i386/eisa/if_vx_eisa.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp>
    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  * 3. Neither the name of the author nor the names of any co-contributors
   14  *    may be used to endorse or promote products derived from this software
   15  *    without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  */
   30 
   31 #include "eisa.h"
   32 #if NEISA > 0
   33 
   34 #include "vx.h"
   35 #if NVX > 0
   36 
   37 #include <sys/param.h>
   38 #include <sys/systm.h>
   39 #include <sys/kernel.h>
   40 #include <sys/socket.h>
   41 
   42 #include <net/if.h>
   43 #include <net/if_arp.h>
   44 
   45 #include <i386/eisa/eisaconf.h>
   46 
   47 #include <dev/vx/if_vxreg.h>
   48 
   49 #define EISA_DEVICE_ID_3COM_3C592       0x506d5920
   50 #define EISA_DEVICE_ID_3COM_3C597_TX    0x506d5970
   51 #define EISA_DEVICE_ID_3COM_3C597_T4    0x506d5971
   52 #define EISA_DEVICE_ID_3COM_3C597_MII   0x506d5972
   53 
   54 
   55 #define VX_EISA_SLOT_OFFSET             0x0c80
   56 #define VX_EISA_IOSIZE                  0x000a
   57 #define VX_RESOURCE_CONFIG              0x0008
   58 
   59 
   60 static const char *vx_match __P((eisa_id_t type));
   61 static int vx_eisa_probe __P((void));
   62 static int vx_eisa_attach __P((struct eisa_device *));
   63 
   64 static struct eisa_driver vx_eisa_driver = {
   65     "vx",
   66     vx_eisa_probe,
   67     vx_eisa_attach,
   68      /* shutdown */ NULL,
   69     &vx_count
   70 };
   71 
   72 DATA_SET(eisadriver_set, vx_eisa_driver);
   73 
   74 static const char*
   75 vx_match(type)
   76     eisa_id_t       type;
   77 {
   78     switch (type) {
   79       case EISA_DEVICE_ID_3COM_3C592:
   80         return "3Com 3C592 Network Adapter";
   81         break;
   82       case EISA_DEVICE_ID_3COM_3C597_TX:
   83         return "3Com 3C597-TX Network Adapter";
   84         break;
   85       case EISA_DEVICE_ID_3COM_3C597_T4:
   86         return "3Com 3C597-T4 Network Adapter";
   87         break;
   88       case EISA_DEVICE_ID_3COM_3C597_MII:
   89         return "3Com 3C597-MII Network Adapter";
   90         break;
   91       default:
   92         break;
   93     }
   94     return (NULL);
   95 }
   96 
   97 static int
   98 vx_eisa_probe(void)
   99 {
  100     u_long          iobase;
  101     struct eisa_device *e_dev = NULL;
  102     int             count;
  103 
  104     count = 0;
  105     while ((e_dev = eisa_match_dev(e_dev, vx_match))) {
  106         u_long          port;
  107 
  108         port = e_dev->ioconf.slot * EISA_SLOT_SIZE;
  109         iobase = port + VX_EISA_SLOT_OFFSET;
  110 
  111         eisa_add_iospace(e_dev, iobase, VX_EISA_IOSIZE, RESVADDR_NONE);
  112         eisa_add_iospace(e_dev, port, VX_IOSIZE, RESVADDR_NONE);
  113 
  114         /* Set irq */
  115         eisa_add_intr(e_dev, inw(iobase + VX_RESOURCE_CONFIG) >> 12);
  116         eisa_registerdev(e_dev, &vx_eisa_driver);
  117         count++;
  118     }
  119     return count;
  120 }
  121 
  122 static int
  123 vx_eisa_attach(e_dev)
  124     struct eisa_device *e_dev;
  125 {
  126     struct vx_softc *sc;
  127     int             unit = e_dev->unit;
  128     int             irq;
  129     resvaddr_t     *ioport;
  130     resvaddr_t     *eisa_ioport;
  131     u_char          level_intr;
  132 
  133     if (TAILQ_FIRST(&e_dev->ioconf.irqs) == NULL)
  134         return (-1);
  135 
  136     irq = TAILQ_FIRST(&e_dev->ioconf.irqs)->irq_no;
  137 
  138     ioport = e_dev->ioconf.ioaddrs.lh_first;
  139 
  140     if (!ioport)
  141         return -1;
  142 
  143     eisa_ioport = ioport->links.le_next;
  144 
  145     if (!eisa_ioport)
  146         return -1;
  147 
  148     eisa_reg_start(e_dev);
  149     if (eisa_reg_iospace(e_dev, ioport))
  150         return -1;
  151 
  152     if (eisa_reg_iospace(e_dev, eisa_ioport))
  153         return -1;
  154 
  155     if ((sc = vxalloc(unit)) == NULL)
  156         return -1;
  157 
  158     sc->vx_io_addr = ioport->addr;
  159 
  160     level_intr = FALSE;
  161 
  162     if (eisa_reg_intr(e_dev, irq, vxintr, (void *) sc, &net_imask,
  163                        /* shared == */ level_intr)) {
  164         vxfree(sc);
  165         return -1;
  166     }
  167     eisa_reg_end(e_dev);
  168 
  169     /* Now the registers are availible through the lower ioport */
  170 
  171     vxattach(sc);
  172 
  173     if (eisa_enable_intr(e_dev, irq)) {
  174         vxfree(sc);
  175         eisa_release_intr(e_dev, irq, vxintr);
  176         return -1;
  177     }
  178     return 0;
  179 }
  180 
  181 #endif  /* NVX > 0 */
  182 #endif  /* NEISA > 0 */

Cache object: 8bc15a7fdce1f67447103156e439a39b


[ 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.