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/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 /*      $NetBSD: eisa.c,v 1.49 2021/08/07 16:19:10 thorpej Exp $        */
    2 
    3 /*
    4  * Copyright (c) 1995, 1996 Christopher G. Demetriou
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. All advertising materials mentioning features or use of this software
   16  *    must display the following acknowledgement:
   17  *      This product includes software developed by Christopher G. Demetriou
   18  *      for the NetBSD Project.
   19  * 4. The name of the author may not be used to endorse or promote products
   20  *    derived from this software without specific prior written permission
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   32  */
   33 
   34 /*
   35  * EISA Bus device
   36  *
   37  * Makes sure an EISA bus is present, and finds and attaches devices
   38  * living on it.
   39  */
   40 
   41 #include <sys/cdefs.h>
   42 __KERNEL_RCSID(0, "$NetBSD: eisa.c,v 1.49 2021/08/07 16:19:10 thorpej Exp $");
   43 
   44 #include "opt_eisaverbose.h"
   45 
   46 #include <sys/param.h>
   47 #include <sys/systm.h>
   48 #include <sys/device.h>
   49 
   50 #include <sys/bus.h>
   51 
   52 #include <dev/eisa/eisareg.h>
   53 #include <dev/eisa/eisavar.h>
   54 #include <dev/eisa/eisadevs.h>
   55 
   56 #include "locators.h"
   57 
   58 static int      eisamatch(device_t, cfdata_t, void *);
   59 static void     eisaattach(device_t, device_t, void *);
   60 
   61 CFATTACH_DECL_NEW(eisa, 0,
   62     eisamatch, eisaattach, NULL, NULL);
   63 
   64 static int      eisaprint(void *, const char *);
   65 static void     eisa_devinfo(const char *, char *, size_t);
   66 
   67 static int
   68 eisamatch(device_t parent, cfdata_t cf,
   69     void *aux)
   70 {
   71         /* XXX check other indicators */
   72 
   73         return (1);
   74 }
   75 
   76 static int
   77 eisaprint(void *aux, const char *pnp)
   78 {
   79         struct eisa_attach_args *ea = aux;
   80         char devinfo[256];
   81 
   82         if (pnp) {
   83                 eisa_devinfo(ea->ea_idstring, devinfo, sizeof(devinfo));
   84                 aprint_normal("%s at %s", devinfo, pnp);
   85         }
   86         aprint_normal(" slot %d", ea->ea_slot);
   87         return (UNCONF);
   88 }
   89 
   90 static void
   91 eisaattach(device_t parent, device_t self, void *aux)
   92 {
   93         struct eisabus_attach_args *eba = aux;
   94         bus_space_tag_t iot, memt;
   95         bus_dma_tag_t dmat;
   96         eisa_chipset_tag_t ec;
   97         int slot, maxnslots;
   98 
   99         eisa_attach_hook(parent, self, eba);
  100         printf("\n");
  101 
  102         iot = eba->eba_iot;
  103         memt = eba->eba_memt;
  104         ec = eba->eba_ec;
  105         dmat = eba->eba_dmat;
  106 
  107         /*
  108          * Search for and attach subdevices.
  109          *
  110          * Slot 0 is the "motherboard" slot, and the code attaching
  111          * the EISA bus should have already attached an ISA bus there.
  112          */
  113         maxnslots = eisa_maxslots(ec);
  114         for (slot = 1; slot < maxnslots; slot++) {
  115                 struct eisa_attach_args ea;
  116                 u_int slotaddr;
  117                 bus_space_handle_t slotioh;
  118                 int i;
  119                 int locs[EISACF_NLOCS];
  120 
  121                 ea.ea_iot = iot;
  122                 ea.ea_memt = memt;
  123                 ea.ea_ec = ec;
  124                 ea.ea_dmat = dmat;
  125                 ea.ea_slot = slot;
  126                 slotaddr = EISA_SLOT_ADDR(slot);
  127 
  128                 /*
  129                  * Get a mapping for the whole slot-specific address
  130                  * space.  If we can't, assume nothing's there but warn
  131                  * about it.
  132                  */
  133                 if (bus_space_map(iot, slotaddr, EISA_SLOT_SIZE, 0, &slotioh)) {
  134                         aprint_error_dev(self,
  135                             "can't map I/O space for slot %d\n", slot);
  136                         continue;
  137                 }
  138 
  139                 /* Get the vendor ID bytes */
  140                 for (i = 0; i < EISA_NVIDREGS; i++)
  141                         ea.ea_vid[i] = bus_space_read_1(iot, slotioh,
  142                             EISA_SLOTOFF_VID + i);
  143 
  144                 /* Check for device existence */
  145                 if (EISA_VENDID_NODEV(ea.ea_vid)) {
  146 #if 0
  147                         printf("no device at %s slot %d\n", device_xname(self),
  148                             slot);
  149                         printf("\t(0x%x, 0x%x)\n", ea.ea_vid[0], ea.ea_vid[1]);
  150 #endif
  151                         bus_space_unmap(iot, slotioh, EISA_SLOT_SIZE);
  152                         continue;
  153                 }
  154 
  155                 /* And check that the firmware didn't biff something badly */
  156                 if (EISA_VENDID_IDDELAY(ea.ea_vid)) {
  157                         printf("%s slot %d not configured by BIOS?\n",
  158                             device_xname(self), slot);
  159                         bus_space_unmap(iot, slotioh, EISA_SLOT_SIZE);
  160                         continue;
  161                 }
  162 
  163                 /* Get the product ID bytes */
  164                 for (i = 0; i < EISA_NPIDREGS; i++)
  165                         ea.ea_pid[i] = bus_space_read_1(iot, slotioh,
  166                             EISA_SLOTOFF_PID + i);
  167 
  168                 /* Create the ID string from the vendor and product IDs */
  169                 ea.ea_idstring[0] = EISA_VENDID_0(ea.ea_vid);
  170                 ea.ea_idstring[1] = EISA_VENDID_1(ea.ea_vid);
  171                 ea.ea_idstring[2] = EISA_VENDID_2(ea.ea_vid);
  172                 ea.ea_idstring[3] = EISA_PRODID_0(ea.ea_pid);
  173                 ea.ea_idstring[4] = EISA_PRODID_1(ea.ea_pid);
  174                 ea.ea_idstring[5] = EISA_PRODID_2(ea.ea_pid);
  175                 ea.ea_idstring[6] = EISA_PRODID_3(ea.ea_pid);
  176                 ea.ea_idstring[7] = '\0';               /* sanity */
  177 
  178                 /* We no longer need the I/O handle; free it. */
  179                 bus_space_unmap(iot, slotioh, EISA_SLOT_SIZE);
  180 
  181                 locs[EISACF_SLOT] = slot;
  182 
  183                 /* Attach matching device. */
  184                 config_found(self, &ea, eisaprint,
  185                     CFARGS(.submatch = config_stdsubmatch,
  186                            .locators = locs));
  187         }
  188 }
  189 
  190 int
  191 eisa_compatible_match(const struct eisa_attach_args * const ea,
  192     const struct device_compatible_entry *dce)
  193 {
  194         const char *idstring = ea->ea_idstring;
  195 
  196         return device_compatible_pmatch(&idstring, 1, dce);
  197 }
  198 
  199 const struct device_compatible_entry *
  200 eisa_compatible_lookup(const struct eisa_attach_args * const ea,
  201     const struct device_compatible_entry *dce)
  202 {
  203         const char *idstring = ea->ea_idstring;
  204 
  205         return device_compatible_plookup(&idstring, 1, dce);
  206 }
  207 
  208 #ifdef EISAVERBOSE
  209 /*
  210  * Descriptions of of known vendors and devices ("products").
  211  */
  212 struct eisa_knowndev {
  213         int     flags;
  214         const char *id, *name;
  215 };
  216 #define EISA_KNOWNDEV_NOPROD    0x01            /* match on vendor only */
  217 
  218 #include <dev/eisa/eisadevs_data.h>
  219 #endif  /* EISAVEBSOSE */
  220 
  221 void
  222 eisa_devinfo(const char *id, char *cp, size_t l)
  223 {
  224 #ifdef EISAVERBOSE
  225         const char *name;
  226         const struct eisa_knowndev *edp;
  227         int match, onlyvendor;
  228 
  229         onlyvendor = 0;
  230         name = NULL;
  231 
  232         /* find the device in the table, if possible. */
  233         for (edp = eisa_knowndevs; edp->id != NULL; edp++) {
  234                 if ((edp->flags & EISA_KNOWNDEV_NOPROD) != 0)
  235                         match = (strncmp(edp->id, id, 3) == 0);
  236                 else
  237                         match = (strcmp(edp->id, id) == 0);
  238                 if (match) {
  239                         name = edp->name;
  240                         onlyvendor = (edp->flags & EISA_KNOWNDEV_NOPROD) != 0;
  241                         break;
  242                 }
  243         }
  244 
  245         if (name == NULL)
  246                 snprintf(cp, l, "unknown device %s", id);
  247         else if (onlyvendor)
  248                 snprintf(cp, l, "unknown %s device %s", name, id);
  249         else
  250                 snprintf(cp, l, "%s", name);
  251 #else   /* EISAVERBOSE */
  252 
  253         snprintf(cp, l, "device %s", id);
  254 #endif  /* EISAVERBOSE */
  255 }

Cache object: 5f0bef697656f5d5644b09d893739852


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