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/cacvar.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: cacvar.h,v 1.21 2016/09/27 03:33:32 pgoyette Exp $     */
    2 
    3 /*-
    4  * Copyright (c) 2000 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Andrew Doran.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 #ifndef _IC_CACVAR_H_
   33 #define _IC_CACVAR_H_
   34 
   35 #include <sys/mutex.h>
   36 #include <sys/condvar.h>
   37 
   38 #include <dev/sysmon/sysmonvar.h>
   39 #include <sys/envsys.h>
   40 
   41 #define CAC_MAX_CCBS    256
   42 #define CAC_MAX_XFER    (0xffff * 512)
   43 #define CAC_SG_SIZE     32
   44 
   45 #define cac_inb(sc, port) \
   46         bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh, port)
   47 #define cac_inw(sc, port) \
   48         bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, port)
   49 #define cac_inl(sc, port) \
   50         bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, port)
   51 #define cac_outb(sc, port, val) \
   52         bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh, port, val)
   53 #define cac_outw(sc, port, val) \
   54         bus_space_write_2((sc)->sc_iot, (sc)->sc_ioh, port, val)
   55 #define cac_outl(sc, port, val) \
   56         bus_space_write_4((sc)->sc_iot, (sc)->sc_ioh, port, val)
   57 
   58 /*
   59  * Stupid macros to deal with alignment/endianness issues.
   60  */
   61 
   62 #define CAC_GET1(x)                                                     \
   63         (((u_char *)&(x))[0])
   64 #define CAC_GET2(x)                                                     \
   65         (((u_char *)&(x))[0] | (((u_char *)&(x))[1] << 8))
   66 #define CAC_GET4(x)                                                     \
   67         ((((u_char *)&(x))[0] | (((u_char *)&(x))[1] << 8)) |           \
   68         (((u_char *)&(x))[2] << 16 | (((u_char *)&(x))[3] << 24)))
   69 
   70 struct cac_softc;
   71 struct cac_ccb;
   72 
   73 struct cac_context {
   74         void            (*cc_handler)(device_t, void *, int);
   75         device_t        cc_dv;
   76         void            *cc_context;
   77 };
   78 
   79 struct cac_ccb {
   80         /* Data the controller will touch - 276 bytes */
   81         struct cac_hdr  ccb_hdr;
   82         struct cac_req  ccb_req;
   83         struct cac_sgb  ccb_seg[CAC_SG_SIZE];
   84 
   85         /* Data the controller won't touch */
   86         int             ccb_flags;
   87         int             ccb_datasize;
   88         paddr_t         ccb_paddr;
   89         bus_dmamap_t    ccb_dmamap_xfer;
   90         SIMPLEQ_ENTRY(cac_ccb) ccb_chain;
   91         struct cac_context ccb_context;
   92 };
   93 
   94 #define CAC_CCB_DATA_IN         0x0001  /* Map describes inbound xfer */
   95 #define CAC_CCB_DATA_OUT        0x0002  /* Map describes outbound xfer */
   96 #define CAC_CCB_ACTIVE          0x0004  /* Command submitted to controller */
   97 
   98 struct cac_linkage {
   99         struct  cac_ccb *(*cl_completed)(struct cac_softc *);
  100         int     (*cl_fifo_full)(struct cac_softc *);
  101         void    (*cl_intr_enable)(struct cac_softc *, int);
  102         int     (*cl_intr_pending)(struct cac_softc *);
  103         void    (*cl_submit)(struct cac_softc *, struct cac_ccb *);
  104 };
  105 
  106 struct cac_softc {
  107         device_t                sc_dev;
  108         kmutex_t                sc_mutex;
  109         bus_space_tag_t         sc_iot;
  110         bus_space_handle_t      sc_ioh;
  111         bus_dma_tag_t           sc_dmat;
  112         bus_dmamap_t            sc_dmamap;
  113         int                     sc_nunits;
  114         uint64_t                sc_unitmask;
  115         void                    *sc_ih;
  116         void *                  sc_ccbs;
  117         paddr_t                 sc_ccbs_paddr;
  118         SIMPLEQ_HEAD(, cac_ccb) sc_ccb_free;
  119         SIMPLEQ_HEAD(, cac_ccb) sc_ccb_queue;
  120         kcondvar_t              sc_ccb_cv;
  121         struct cac_linkage      sc_cl;
  122 
  123         /* scsi ioctl from sd device */
  124         int                     (*sc_ioctl)(device_t, u_long, void *);
  125 
  126         struct sysmon_envsys    *sc_sme;
  127         envsys_data_t           *sc_sensor;
  128 };
  129 
  130 /* XXX These have to become spinlocks in case of fine SMP */
  131 #define CAC_LOCK(sc) splbio()
  132 #define CAC_UNLOCK(sc, lock) splx(lock)
  133 typedef int cac_lock_t;
  134 
  135 struct cac_attach_args {
  136         int             caca_unit;
  137 };
  138 
  139 int     cac_cmd(struct cac_softc *, int, void *, int, int, int, int,
  140                 struct cac_context *);
  141 int     cac_init(struct cac_softc *, const char *, int);
  142 int     cac_rescan(device_t, const char *, const int *);
  143 int     cac_intr(void *);
  144 
  145 extern const struct     cac_linkage cac_l0;
  146 
  147 #endif  /* !_IC_CACVAR_H_ */

Cache object: 3c93486a8751263670182c971a2bc90b


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