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

Cache object: cfef900ea644b4bd243481ef1fe02752


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