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/eisa/bha_eisa.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 /*      $OpenBSD: bha_eisa.c,v 1.5 2008/06/26 05:42:14 ray Exp $        */
    2 /*      $NetBSD: bha_eisa.c,v 1.16 1998/08/15 10:10:49 mycroft Exp $    */
    3 
    4 /*-
    5  * Copyright (c) 1998 The NetBSD Foundation, Inc.
    6  * All rights reserved.
    7  *
    8  * This code is derived from software contributed to The NetBSD Foundation
    9  * by Charles M. Hannum.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   30  * POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 #include <sys/types.h>
   34 #include <sys/param.h>
   35 #include <sys/systm.h>
   36 #include <sys/device.h>
   37 
   38 #include <machine/bus.h>
   39 #include <machine/intr.h>
   40 
   41 #include <scsi/scsi_all.h>
   42 #include <scsi/scsiconf.h>
   43 
   44 #include <dev/eisa/eisavar.h>
   45 #include <dev/eisa/eisadevs.h>
   46 
   47 #include <dev/ic/bhareg.h>
   48 #include <dev/ic/bhavar.h>
   49 
   50 #define BHA_EISA_SLOT_OFFSET    0x0c80
   51 #define BHA_EISA_IOSIZE         0x0010
   52 #define BHA_ISA_IOSIZE          0x0004
   53 
   54 #define BHA_EISA_IOCONF         0x0c
   55 
   56 int     bha_eisa_address(bus_space_tag_t, bus_space_handle_t, int *);
   57 int     bha_eisa_match(struct device *, void *, void *);
   58 void    bha_eisa_attach(struct device *, struct device *, void *);
   59 
   60 struct cfattach bha_eisa_ca = {
   61         sizeof(struct bha_softc), bha_eisa_match, bha_eisa_attach
   62 };
   63 
   64 int
   65 bha_eisa_address(iot, ioh, portp)
   66         bus_space_tag_t iot;
   67         bus_space_handle_t ioh;
   68         int *portp;
   69 {
   70         int port;
   71 
   72         switch (bus_space_read_1(iot, ioh, BHA_EISA_IOCONF) & 0x07) {
   73         case 0x00:
   74                 port = 0x330;
   75                 break;
   76         case 0x01:
   77                 port = 0x334;
   78                 break;
   79         case 0x02:
   80                 port = 0x230;
   81                 break;
   82         case 0x03:
   83                 port = 0x234;
   84                 break;
   85         case 0x04:
   86                 port = 0x130;
   87                 break;
   88         case 0x05:
   89                 port = 0x134;
   90                 break;
   91         default:
   92                 return (1);
   93         }
   94 
   95         *portp = port;
   96         return (0);
   97 }
   98 
   99 /*
  100  * Check the slots looking for a board we recognise
  101  * If we find one, note its address (slot) and call
  102  * the actual probe routine to check it out.
  103  */
  104 int
  105 bha_eisa_match(parent, match, aux)
  106         struct device *parent;
  107         void *aux, *match;
  108 {
  109         struct eisa_attach_args *ea = aux;
  110         bus_space_tag_t iot = ea->ea_iot;
  111         bus_space_handle_t ioh, ioh2;
  112         int port;
  113         int rv;
  114 
  115         /* must match one of our known ID strings */
  116         if (strcmp(ea->ea_idstring, "BUS4201") &&
  117             strcmp(ea->ea_idstring, "BUS4202"))
  118                 return (0);
  119 
  120         if (bus_space_map(iot,
  121             EISA_SLOT_ADDR(ea->ea_slot) + BHA_EISA_SLOT_OFFSET, BHA_EISA_IOSIZE,
  122             0, &ioh))
  123                 return (0);
  124 
  125         if (bha_eisa_address(iot, ioh, &port) ||
  126             bus_space_map(iot, port, BHA_ISA_IOSIZE, 0, &ioh2)) {
  127                 bus_space_unmap(iot, ioh, BHA_EISA_IOSIZE);
  128                 return (0);
  129         }
  130 
  131         rv = bha_find(iot, ioh2, NULL);
  132 
  133         bus_space_unmap(iot, ioh2, BHA_ISA_IOSIZE);
  134         bus_space_unmap(iot, ioh, BHA_EISA_IOSIZE);
  135 
  136         return (rv);
  137 }
  138 
  139 /*
  140  * Attach all the sub-devices we can find
  141  */
  142 void
  143 bha_eisa_attach(parent, self, aux)
  144         struct device *parent, *self;
  145         void *aux;
  146 {
  147         struct eisa_attach_args *ea = aux;
  148         struct bha_softc *sc = (void *)self;
  149         bus_space_tag_t iot = ea->ea_iot;
  150         bus_space_handle_t ioh, ioh2;
  151         int port;
  152         struct bha_probe_data bpd;
  153         eisa_chipset_tag_t ec = ea->ea_ec;
  154         eisa_intr_handle_t ih;
  155         const char *model, *intrstr;
  156 
  157         if (!strcmp(ea->ea_idstring, "BUS4201"))
  158                 model = EISA_PRODUCT_BUS4201;
  159         else if (!strcmp(ea->ea_idstring, "BUS4202"))
  160                 model = EISA_PRODUCT_BUS4202;
  161         else
  162                 model = "unknown model!";
  163 
  164         if (bus_space_map(iot,
  165             EISA_SLOT_ADDR(ea->ea_slot) + BHA_EISA_SLOT_OFFSET, BHA_EISA_IOSIZE,
  166             0, &ioh)) {
  167                 printf(": could not map EISA slot\n");
  168                 return;
  169         }
  170 
  171         if (bha_eisa_address(iot, ioh, &port) ||
  172             bus_space_map(iot, port, BHA_ISA_IOSIZE, 0, &ioh2)) {
  173                 printf(": could not map ISA address\n");
  174                 return;
  175         }
  176 
  177         sc->sc_iot = iot;
  178         sc->sc_ioh = ioh2;
  179         sc->sc_dmat = ea->ea_dmat;
  180         if (!bha_find(iot, ioh2, &bpd)) {
  181                 printf(": bha_find failed\n");
  182                 return;
  183         }
  184 
  185         sc->sc_dmaflags = 0;
  186 
  187         if (eisa_intr_map(ec, bpd.sc_irq, &ih)) {
  188                 printf(": couldn't map interrupt (%d)\n", bpd.sc_irq);
  189                 return;
  190         }
  191         intrstr = eisa_intr_string(ec, ih);
  192         sc->sc_ih = eisa_intr_establish(ec, ih, IST_LEVEL, IPL_BIO,
  193             bha_intr, sc, sc->sc_dev.dv_xname);
  194         if (sc->sc_ih == NULL) {
  195                 printf(": couldn't establish interrupt");
  196                 if (intrstr != NULL)
  197                         printf(" at %s", intrstr);
  198                 printf("\n");
  199                 return;
  200         }
  201         printf(": %s, %s\n", intrstr, model);
  202 
  203         bha_attach(sc, &bpd);
  204 }

Cache object: 89575a9dace9500571f7cf4c9d5619ae


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