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/aacvar.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: aacvar.h,v 1.8.24.2 2008/10/03 09:12:16 jdc Exp $      */
    2 
    3 /*-
    4  * Copyright (c) 2002 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  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *        This product includes software developed by the NetBSD
   21  *        Foundation, Inc. and its contributors.
   22  * 4. Neither the name of The NetBSD Foundation nor the names of its
   23  *    contributors may be used to endorse or promote products derived
   24  *    from this software without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36  * POSSIBILITY OF SUCH DAMAGE.
   37  */
   38 
   39 /*-
   40  * Copyright (c) 2000 Michael Smith
   41  * Copyright (c) 2000 BSDi
   42  * Copyright (c) 2000 Niklas Hallqvist
   43  * All rights reserved.
   44  *
   45  * Redistribution and use in source and binary forms, with or without
   46  * modification, are permitted provided that the following conditions
   47  * are met:
   48  * 1. Redistributions of source code must retain the above copyright
   49  *    notice, this list of conditions and the following disclaimer.
   50  * 2. Redistributions in binary form must reproduce the above copyright
   51  *    notice, this list of conditions and the following disclaimer in the
   52  *    documentation and/or other materials provided with the distribution.
   53  *
   54  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   55  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   56  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   57  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   58  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   59  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   60  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   61  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   62  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   63  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   64  * SUCH DAMAGE.
   65  *
   66  *      from FreeBSD: aacvar.h,v 1.1 2000/09/13 03:20:34 msmith Exp
   67  *      via OpenBSD: aacvar.h,v 1.2 2002/03/14 01:26:53 millert Exp
   68  */
   69 
   70 #ifndef _PCI_AACVAR_H_
   71 #define _PCI_AACVAR_H_
   72 
   73 /* Debugging */
   74 #ifdef AAC_DEBUG
   75 #define AAC_DPRINTF(mask, args) if ((aac_debug & (mask)) != 0) printf args
   76 #define AAC_D_INTR      0x01
   77 #define AAC_D_MISC      0x02
   78 #define AAC_D_CMD       0x04
   79 #define AAC_D_QUEUE     0x08
   80 #define AAC_D_IO        0x10
   81 extern int aac_debug;
   82 
   83 #define AAC_PRINT_FIB(sc, fib)  aac_print_fib((sc), (fib), __FUNCTION__)
   84 #else
   85 #define AAC_DPRINTF(mask, args)
   86 #define AAC_PRINT_FIB(sc, fib)
   87 #endif
   88 
   89 struct aac_code_lookup {
   90         const char      *string;
   91         u_int32_t code;
   92 };
   93 
   94 extern const struct      aac_code_lookup aac_command_status_table[];
   95 extern const struct      aac_code_lookup aac_container_types[];
   96 
   97 struct aac_softc;
   98 
   99 /*
  100  * We allocate a small set of FIBs for the adapter to use to send us messages.
  101  */
  102 #define AAC_ADAPTER_FIBS        8
  103 
  104 /*
  105  * FIBs are allocated in page-size chunks and can grow up to the 512
  106  * limit imposed by the hardware.
  107  * XXX -- There should be some way to allocate these as-needed without
  108  *        allocating them at interrupt time.  For now, though, allocate
  109  *        all that we'll ever need up-front.
  110  */
  111 #define AAC_PREALLOCATE_FIBS(sc)        ((sc)->sc_max_fibs)
  112 
  113 /*
  114  * Firmware messages are passed in the printf buffer.
  115  */
  116 #define AAC_PRINTF_BUFSIZE      256
  117 
  118 /*
  119  * We wait this many seconds for the adapter to come ready if it is still
  120  * booting.
  121  */
  122 #define AAC_BOOT_TIMEOUT        (3 * 60)
  123 
  124 /*
  125  * Wait this long for a lost interrupt to get detected.
  126  */
  127 #define AAC_WATCH_TIMEOUT       10000           /* 10000 * 1ms = 10s */
  128 
  129 /*
  130  * Timeout for immediate commands.
  131  */
  132 #define AAC_IMMEDIATE_TIMEOUT   30
  133 
  134 /*
  135  * Delay 20ms after the qnotify in sync operations.  Experimentally deduced.
  136  */
  137 #define AAC_SYNC_DELAY          20000
  138 
  139 /*
  140  * sc->sc_max_sgs is the number of scatter-gather elements we can fit
  141  * in one block I/O request (64-bit or 32-bit, depending) FIB, or the
  142  * maximum number that the firmware will accept.  We subtract one to
  143  * deal with requests that do not start on an even page boundary.
  144  */
  145 #define AAC_MAX_XFER(sc)        (((sc)->sc_max_sgs - 1) * PAGE_SIZE)
  146 
  147 /*
  148  * Fixed sector size.
  149  */
  150 #define AAC_SECTOR_SIZE         512
  151 
  152 /*
  153  * Number of CCBs to reserve for control operations.
  154  */
  155 #define AAC_NCCBS_RESERVE       8
  156 
  157 /*
  158  * Quirk listings.
  159  */
  160 #define AAC_QUIRK_PERC2QC       (1 << 0)        /* Dell PERC 2QC */
  161 #define AAC_QUIRK_SG_64BIT      (1 << 4)        /* Use 64-bit S/G addresses */
  162 #define AAC_QUIRK_4GB_WINDOW    (1 << 5)        /* Device can access host mem
  163                                                  * in 2GB-4GB range */
  164 #define AAC_QUIRK_NO4GB         (1 << 6)        /* Can't access host mem >2GB */
  165 #define AAC_QUIRK_256FIBS       (1 << 7)        /* Can only handle 256 cmds */
  166 #define AAC_QUIRK_BROKEN_MMAP   (1 << 8)        /* Broken HostPhysMemPages */
  167 #define AAC_QUIRK_NEW_COMM      (1 << 11)       /* New comm. i/f supported */
  168 #define AAC_QUIRK_RAW_IO        (1 << 12)       /* Raw I/O interface */
  169 #define AAC_QUIRK_ARRAY_64BIT   (1 << 13)       /* 64-bit array size */
  170 #define AAC_QUIRK_LBA_64BIT     (1 << 14)       /* 64-bit LBA support */
  171 
  172 
  173 /*
  174  * We gather a number of adapter-visible items into a single structure.
  175  *
  176  * The ordering of this structure may be important; we copy the Linux driver:
  177  *
  178  * Adapter FIBs
  179  * Init struct
  180  * Queue headers (Comm Area)
  181  * Printf buffer
  182  *
  183  * In addition, we add:
  184  * Sync Fib
  185  */
  186 struct aac_common {
  187         /* fibs for the controller to send us messages */
  188         struct aac_fib ac_fibs[AAC_ADAPTER_FIBS];
  189 
  190         /* the init structure */
  191         struct aac_adapter_init ac_init;
  192 
  193         /* arena within which the queue structures are kept */
  194         u_int8_t ac_qbuf[sizeof(struct aac_queue_table) + AAC_QUEUE_ALIGN];
  195 
  196         /* buffer for text messages from the controller */
  197         char    ac_printf[AAC_PRINTF_BUFSIZE];
  198 
  199         /* fib for synchronous commands */
  200         struct aac_fib ac_sync_fib;
  201 };
  202 
  203 struct aac_ccb;
  204 
  205 /*
  206  * Interface operations
  207  */
  208 struct aac_interface {
  209         int     (*aif_get_fwstatus)(struct aac_softc *);
  210         void    (*aif_qnotify)(struct aac_softc *, int);
  211         int     (*aif_get_istatus)(struct aac_softc *);
  212         void    (*aif_set_istatus)(struct aac_softc *, int);
  213         void    (*aif_set_mailbox)(struct aac_softc *, u_int32_t,
  214                                    u_int32_t, u_int32_t, u_int32_t, u_int32_t);
  215         uint32_t (*aif_get_mailbox)(struct aac_softc *, int);
  216         void    (*aif_set_interrupts)(struct aac_softc *, int);
  217         int     (*aif_send_command)(struct aac_softc *, struct aac_ccb *);
  218         int     (*aif_get_outb_queue)(struct aac_softc *);
  219         void    (*aif_set_outb_queue)(struct aac_softc *, int);
  220 };
  221 
  222 #define AAC_GET_FWSTATUS(sc)            ((sc)->sc_if.aif_get_fwstatus(sc))
  223 #define AAC_QNOTIFY(sc, qbit) \
  224         ((sc)->sc_if.aif_qnotify((sc), (qbit)))
  225 #define AAC_GET_ISTATUS(sc)             ((sc)->sc_if.aif_get_istatus(sc))
  226 #define AAC_CLEAR_ISTATUS(sc, mask) \
  227         ((sc)->sc_if.aif_set_istatus((sc), (mask)))
  228 #define AAC_SET_MAILBOX(sc, command, arg0, arg1, arg2, arg3) \
  229         do {                                                            \
  230                 ((sc)->sc_if.aif_set_mailbox((sc), (command), (arg0),   \
  231                     (arg1), (arg2), (arg3)));                           \
  232         } while(0)
  233 #define AAC_GET_MAILBOX(sc, mb)         ((sc)->sc_if.aif_get_mailbox(sc, mb))
  234 #define AAC_GET_MAILBOXSTATUS(sc)       (AAC_GET_MAILBOX(sc, 0))
  235 #define AAC_MASK_INTERRUPTS(sc) \
  236         ((sc)->sc_if.aif_set_interrupts((sc), 0))
  237 #define AAC_UNMASK_INTERRUPTS(sc) \
  238         ((sc)->sc_if.aif_set_interrupts((sc), 1))
  239 #define AAC_SEND_COMMAND(sc, cm) \
  240         ((sc)->sc_if.aif_send_command((sc), cm))
  241 #define AAC_GET_OUTB_QUEUE(sc) \
  242         ((sc)->sc_if.aif_get_outb_queue((sc)))
  243 #define AAC_SET_OUTB_QUEUE(sc, idx) \
  244         ((sc)->sc_if.aif_set_outb_queue((sc), (idx)))
  245 
  246 #define AAC_SETREG4(sc, reg, val) \
  247         bus_space_write_4((sc)->sc_memt, (sc)->sc_memh, (reg), (val))
  248 #define AAC_GETREG4(sc, reg) \
  249         bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, (reg))
  250 #define AAC_SETREG2(sc, reg, val) \
  251         bus_space_write_2((sc)->sc_memt, (sc)->sc_memh, (reg), (val))
  252 #define AAC_GETREG2(sc, reg) \
  253         bus_space_read_2((sc)->sc_memt, (sc)->sc_memh, (reg))
  254 #define AAC_SETREG1(sc, reg, val) \
  255         bus_space_write_1((sc)->sc_memt, (sc)->sc_memh, (reg), (val))
  256 #define AAC_GETREG1(sc, reg) \
  257         bus_space_read_1((sc)->sc_memt, (sc)->sc_memh, (reg))
  258 
  259 struct aac_fibmap {
  260         TAILQ_ENTRY(aac_fibmap) fm_link;
  261         struct aac_fib          *fm_fibs;
  262         bus_dma_segment_t       fm_fibseg;
  263         bus_dmamap_t            fm_fibmap;
  264         struct aac_ccb          *fm_ccbs;
  265 };
  266 
  267 /*
  268  * A command control block, one for each corresponding command index
  269  * of the controller.
  270  */
  271 struct aac_ccb {
  272         SIMPLEQ_ENTRY(aac_ccb)  ac_chain;
  273 
  274         struct aac_fib          *ac_fib;
  275         struct aac_fibmap       *ac_fibmap;
  276         bus_addr_t              ac_fibphys;
  277         bus_dmamap_t            ac_dmamap_xfer;
  278 
  279         void                    *ac_data;
  280         size_t                  ac_datalen;
  281         u_int                   ac_flags;
  282 
  283         void                    (*ac_intr)(struct aac_ccb *);
  284         struct device           *ac_device;
  285         void                    *ac_context;
  286 };
  287 #define AAC_CCB_MAPPED          0x01
  288 #define AAC_CCB_COMPLETED       0x02
  289 #define AAC_CCB_DATA_IN         0x04
  290 #define AAC_CCB_DATA_OUT        0x08
  291 
  292 struct aac_drive {
  293         u_int   hd_present;
  294         u_int   hd_devtype;
  295         u_int64_t       hd_size;
  296 };
  297 
  298 /*
  299  * Per-controller structure.
  300  */
  301 struct aac_softc {
  302         struct device           sc_dv;
  303         void                    *sc_ih;
  304         bus_space_tag_t         sc_memt;
  305         bus_space_handle_t      sc_memh;
  306         bus_dma_tag_t           sc_dmat;
  307         bus_size_t              sc_regsize;
  308 
  309         struct FsaRevision      sc_revision;
  310         int                     sc_hwif;
  311         int                     sc_quirks;
  312         struct aac_interface    sc_if;
  313 
  314         u_int32_t               sc_max_fibs;
  315         u_int32_t               sc_max_fibs_alloc;
  316         u_int32_t               sc_max_sectors;
  317         u_int32_t               sc_max_fib_size;
  318         u_int32_t               sc_max_sgs;
  319 
  320         u_int32_t               sc_total_fibs;
  321         TAILQ_HEAD(,aac_fibmap) sc_fibmap_tqh;
  322 
  323         struct aac_common       *sc_common;
  324         bus_dma_segment_t       sc_common_seg;
  325         bus_dmamap_t            sc_common_dmamap;
  326         struct aac_fib          *sc_aif_fib;
  327 
  328         struct aac_ccb          *sc_ccbs;
  329         SIMPLEQ_HEAD(, aac_ccb) sc_ccb_free;
  330         SIMPLEQ_HEAD(, aac_ccb) sc_ccb_queue;
  331         SIMPLEQ_HEAD(, aac_ccb) sc_ccb_complete;
  332 
  333         struct aac_queue_table  *sc_queues;
  334         struct aac_queue_entry  *sc_qentries[AAC_QUEUE_COUNT];
  335         struct aac_drive        sc_hdr[AAC_MAX_CONTAINERS];
  336         int                     sc_nunits;
  337         int                     sc_flags;
  338         uint32_t                sc_supported_options;
  339 
  340         /* Set by parent */
  341         int                     (*sc_intr_set)(struct aac_softc *,
  342                                                 int (*)(void *), void *);
  343 };
  344 #define AAC_HWIF_I960RX         0
  345 #define AAC_HWIF_STRONGARM      1
  346 #define AAC_HWIF_FALCON         2
  347 #define AAC_HWIF_RKT            3
  348 #define AAC_HWIF_UNKNOWN        -1
  349 
  350 #define AAC_ONLINE              2
  351 
  352 struct aac_attach_args {
  353         int             aaca_unit;
  354 };
  355 
  356 int     aac_attach(struct aac_softc *);
  357 void    aac_ccb_enqueue(struct aac_softc *, struct aac_ccb *);
  358 void    aac_ccb_free(struct aac_softc *, struct aac_ccb *);
  359 struct aac_ccb *aac_ccb_alloc(struct aac_softc *, int);
  360 int     aac_ccb_map(struct aac_softc *, struct aac_ccb *);
  361 int     aac_ccb_poll(struct aac_softc *, struct aac_ccb *, int);
  362 int     aac_ccb_submit(struct aac_softc *, struct aac_ccb *);
  363 void    aac_ccb_unmap(struct aac_softc *, struct aac_ccb *);
  364 const char      *aac_describe_code(const struct aac_code_lookup *, u_int32_t);
  365 int     aac_intr(void *);
  366 
  367 #endif  /* !_PCI_AACVAR_H_ */

Cache object: ca13eed7fb90b557abf4ee5e93d3aa38


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