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/mca/mca.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: mca.c,v 1.13 2003/01/01 00:10:21 thorpej Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
    5  * Copyright (c) 1996-1999 Scott D. Telford.
    6  * All rights reserved.
    7  *
    8  * This code is derived from software contributed to The NetBSD Foundation
    9  * by Scott Telford <s.telford@ed.ac.uk>.
   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  * 3. All advertising materials mentioning features or use of this software
   20  *    must display the following acknowledgement:
   21  *      This product includes software developed by the NetBSD
   22  *      Foundation, Inc. and its contributors.
   23  * 4. Neither the name of The NetBSD Foundation nor the names of its
   24  *    contributors may be used to endorse or promote products derived
   25  *    from this software without specific prior written permission.
   26  *
   27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   37  * POSSIBILITY OF SUCH DAMAGE.
   38  */
   39 
   40 /*
   41  * MCA Bus device
   42  */
   43 
   44 #include <sys/cdefs.h>
   45 __KERNEL_RCSID(0, "$NetBSD: mca.c,v 1.13 2003/01/01 00:10:21 thorpej Exp $");
   46 
   47 #include <sys/param.h>
   48 #include <sys/systm.h>
   49 #include <sys/device.h>
   50 
   51 #include <machine/bus.h>
   52 
   53 #include <dev/mca/mcareg.h>
   54 #include <dev/mca/mcavar.h>
   55 #include <dev/mca/mcadevs.h>
   56 
   57 int     mca_match __P((struct device *, struct cfdata *, void *));
   58 void    mca_attach __P((struct device *, struct device *, void *));
   59 
   60 CFATTACH_DECL(mca, sizeof(struct device),
   61     mca_match, mca_attach, NULL, NULL);
   62 
   63 int     mca_submatch __P((struct device *, struct cfdata *, void *));
   64 int     mca_print __P((void *, const char *));
   65 
   66 int
   67 mca_match(parent, cf, aux)
   68         struct device *parent;
   69         struct cfdata *cf;
   70         void *aux;
   71 {
   72         struct mcabus_attach_args *mba = aux;
   73 
   74         if (strcmp(mba->mba_busname, cf->cf_name))
   75                 return (0);
   76 
   77         /* sanity (only mca0 supported currently) */
   78         if (mba->mba_bus < 0 || mba->mba_bus > 0)
   79                 return (0);
   80 
   81         /* XXX check other indicators? */
   82 
   83         return (1);
   84 }
   85 
   86 int
   87 mca_print(aux, pnp)
   88         void *aux;
   89         const char *pnp;
   90 {
   91         register struct mca_attach_args *ma = aux;
   92         char devinfo[256];
   93 
   94         if (pnp) {
   95                 mca_devinfo(ma->ma_id, devinfo);
   96                 aprint_normal("%s slot %d: %s", pnp, ma->ma_slot + 1, devinfo);
   97         }
   98 
   99         /*
  100          * Print "configured" for Memory Extension boards - there is no
  101          * meaningfull driver for them, they "just work".
  102          */
  103         switch(ma->ma_id) {
  104         case MCA_PRODUCT_HRAM: case MCA_PRODUCT_IQRAM: case MCA_PRODUCT_MICRAM:
  105         case MCA_PRODUCT_ASTRAM: case MCA_PRODUCT_KINGRAM:
  106         case MCA_PRODUCT_KINGRAM8: case MCA_PRODUCT_KINGRAM16:
  107         case MCA_PRODUCT_KINGRAM609: case MCA_PRODUCT_HYPRAM:
  108         case MCA_PRODUCT_QRAM1: case MCA_PRODUCT_QRAM2: case MCA_PRODUCT_EVERAM:
  109         case MCA_PRODUCT_BOCARAM: case MCA_PRODUCT_IBMRAM1:
  110         case MCA_PRODUCT_IBMRAM2: case MCA_PRODUCT_IBMRAM3:
  111         case MCA_PRODUCT_IBMRAM4: case MCA_PRODUCT_IBMRAM5:
  112         case MCA_PRODUCT_IBMRAM6: case MCA_PRODUCT_IBMRAM7:
  113                 aprint_normal(": memory configured\n");
  114                 return (QUIET);
  115         default:
  116                 return (UNCONF);
  117         }
  118 }
  119 
  120 int
  121 mca_submatch(parent, cf, aux)
  122         struct device *parent;
  123         struct cfdata *cf;
  124         void *aux;
  125 {
  126         struct mca_attach_args *ma = aux;
  127 
  128         if (cf->mcacf_slot != MCA_UNKNOWN_SLOT &&
  129             cf->mcacf_slot != ma->ma_slot)
  130                 return 0;
  131         return (config_match(parent, cf, aux));
  132 }
  133 
  134 void
  135 mca_attach(parent, self, aux)
  136         struct device *parent, *self;
  137         void *aux;
  138 {
  139         struct mcabus_attach_args *mba = aux;
  140         bus_space_tag_t iot, memt;
  141         bus_dma_tag_t dmat;
  142         mca_chipset_tag_t mc;
  143         int slot;
  144 
  145         mca_attach_hook(parent, self, mba);
  146         printf("\n");
  147 
  148         iot = mba->mba_iot;
  149         memt = mba->mba_memt;
  150         mc = mba->mba_mc;
  151         dmat = mba->mba_dmat;
  152 
  153         /*
  154          * Search for and attach subdevices.
  155          *
  156          * NB: In the adapter setup register, slots are numbered from 0,
  157          * but officially they are numbered from 1.
  158          * We use the former convention internally and the latter for text
  159          * messages and in config files.
  160          */
  161 
  162         for (slot = 0; slot < MCA_MAX_SLOTS; slot++) {
  163                 struct mca_attach_args ma;
  164                 int reg;
  165 
  166                 ma.ma_iot = iot;
  167                 ma.ma_memt = memt;
  168                 ma.ma_dmat = dmat;
  169                 ma.ma_mc = mc;
  170                 ma.ma_slot = slot;
  171 
  172                 for(reg = 0; reg < 8; reg++)
  173                         ma.ma_pos[reg]=mca_conf_read(mc, slot, reg);
  174 
  175                 ma.ma_id = ma.ma_pos[0] + (ma.ma_pos[1] << 8);
  176                 if (ma.ma_id == 0xffff) /* no adapter here */
  177                         continue;
  178 
  179                 if (ma.ma_pos[2] & MCA_POS2_ENABLE
  180                     || mca_match_disabled(ma.ma_id))
  181                         config_found_sm(self, &ma, mca_print, mca_submatch);
  182                 else {
  183                         mca_print(&ma, self->dv_xname);
  184                         printf(" disabled\n");
  185                 }
  186         }
  187 }

Cache object: 67e023fe6afa612a32a1d3c07ef02211


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