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/ic/bhavar.h

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: bhavar.h,v 1.21 2001/05/03 20:34:54 ross Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
    9  * Simulation Facility, NASA Ames Research Center.
   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 #include <sys/queue.h>
   41 
   42 /* XXX adjust hash for large numbers of CCBs */
   43 #define CCB_HASH_SIZE   32      /* hash table size for phystokv */
   44 #define CCB_HASH_SHIFT  9
   45 #define CCB_HASH(x)     ((((long)(x))>>CCB_HASH_SHIFT) & (CCB_HASH_SIZE - 1))
   46 
   47 /*
   48  * A CCB allocation group.  Each group is a page size.  We can find
   49  * the allocation group for a CCB by truncating the CCB address to
   50  * a page boundary, and the offset from the group's DMA mapping
   51  * by taking the offset of the CCB into the page.
   52  */
   53 #define BHA_CCBS_PER_GROUP      ((PAGE_SIZE - sizeof(bus_dmamap_t)) /   \
   54                                  sizeof(struct bha_ccb))
   55 struct bha_ccb_group {
   56         bus_dmamap_t bcg_dmamap;
   57         struct bha_ccb bcg_ccbs[1];     /* determined at run-time */
   58 };
   59 
   60 #define BHA_CCB_GROUP(ccb)                                              \
   61         (struct bha_ccb_group *)(trunc_page((vaddr_t)ccb))
   62 #define BHA_CCB_OFFSET(ccb)     ((vaddr_t)(ccb) & PAGE_MASK)
   63 
   64 #define BHA_CCB_SYNC(sc, ccb, ops)                                      \
   65 do {                                                                    \
   66         struct bha_ccb_group *bcg = BHA_CCB_GROUP((ccb));               \
   67                                                                         \
   68         bus_dmamap_sync((sc)->sc_dmat, bcg->bcg_dmamap,                 \
   69             BHA_CCB_OFFSET(ccb), sizeof(struct bha_ccb), (ops));        \
   70 } while (0)
   71 
   72 /*
   73  * Offset in the DMA mapping for mailboxes.
   74  * Since all mailboxes are allocated on a single DMA'able memory
   75  * due to the hardware limitation, an offset of any mailboxes can be
   76  * calculated using same expression.
   77  */
   78 #define BHA_MBX_OFFSET(sc, mbx) ((u_long)(mbx) - (u_long)(sc)->sc_mbo)
   79 
   80 #define BHA_MBI_SYNC(sc, mbi, ops)                                      \
   81 do {                                                                    \
   82         bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_dmamap_mbox,            \
   83             BHA_MBX_OFFSET((sc), (mbi)), sizeof(struct bha_mbx_in), (ops)); \
   84 } while (0)
   85 
   86 #define BHA_MBO_SYNC(sc, mbo, ops)                                      \
   87 do {                                                                    \
   88         bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_dmamap_mbox,            \
   89             BHA_MBX_OFFSET((sc), (mbo)), sizeof(struct bha_mbx_out), (ops)); \
   90 } while (0)
   91 
   92 struct bha_softc {
   93         struct device sc_dev;
   94 
   95         bus_space_tag_t sc_iot;
   96         bus_space_handle_t sc_ioh;
   97         bus_dma_tag_t sc_dmat;
   98         bus_dmamap_t sc_dmamap_mbox;    /* maps the mailboxes */
   99         int sc_dmaflags;                /* bus-specific dma map flags */
  100         void *sc_ih;
  101 
  102         int sc_scsi_id;                 /* host adapter SCSI ID */
  103 
  104         int sc_flags;
  105 #define BHAF_WIDE               0x01    /* device is wide */
  106 #define BHAF_DIFFERENTIAL       0x02    /* device is differential */
  107 #define BHAF_ULTRA              0x04    /* device is ultra-scsi */
  108 #define BHAF_TAGGED_QUEUEING    0x08    /* device supports tagged queueing */
  109 #define BHAF_WIDE_LUN           0x10    /* device supported wide lun CCBs */
  110 #define BHAF_STRICT_ROUND_ROBIN 0x20    /* device supports strict RR mode */
  111 
  112         int sc_max_dmaseg;              /* maximum number of DMA segments */
  113         int sc_max_ccbs;                /* maximum number of CCBs (HW) */
  114         int sc_cur_ccbs;                /* current number of CCBs */
  115 
  116         int sc_disc_mask;               /* mask of targets allowing discnnct */
  117         int sc_ultra_mask;              /* mask of targets allowing ultra */
  118         int sc_fast_mask;               /* mask of targets allowing fast */
  119         int sc_sync_mask;               /* mask of targets allowing sync */
  120         int sc_wide_mask;               /* mask of targets allowing wide */
  121         int sc_tag_mask;                /* mask of targets allowing t/q'ing */
  122 
  123         /*
  124          * In and Out mailboxes.
  125          */
  126         struct bha_mbx_out *sc_mbo;
  127         struct bha_mbx_in *sc_mbi;
  128 
  129         struct bha_mbx_out *sc_cmbo;    /* Collection Mail Box out */
  130         struct bha_mbx_out *sc_tmbo;    /* Target Mail Box out */
  131 
  132         int sc_mbox_count;              /* number of mailboxes */
  133         int sc_mbofull;                 /* number of full Mail Box Out */
  134 
  135         struct bha_mbx_in *sc_tmbi;     /* Target Mail Box in */
  136 
  137         struct bha_ccb *sc_ccbhash[CCB_HASH_SIZE];
  138         TAILQ_HEAD(, bha_ccb)   sc_free_ccb,
  139                                 sc_waiting_ccb,
  140                                 sc_allocating_ccbs;
  141 
  142         struct scsipi_adapter sc_adapter;
  143         struct scsipi_channel sc_channel;
  144 
  145         char sc_model[7],
  146              sc_firmware[6];
  147 };
  148 
  149 struct bha_probe_data {
  150         int sc_irq, sc_drq;
  151 };
  152 
  153 int     bha_find __P((bus_space_tag_t, bus_space_handle_t));
  154 int     bha_inquire_config __P((bus_space_tag_t, bus_space_handle_t,
  155             struct bha_probe_data *));
  156 void    bha_attach __P((struct bha_softc *));
  157 int     bha_info __P((struct bha_softc *));
  158 int     bha_intr __P((void *));
  159 
  160 int     bha_disable_isacompat __P((struct bha_softc *));
  161 int     bha_probe_inquiry __P((bus_space_tag_t, bus_space_handle_t,
  162             struct bha_probe_data *));

Cache object: 0c6d64e8fef404b00dafa71f731fcb1a


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