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/i386/isa/bs/bsfunc.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 /*      $NecBSD: bsfunc.h,v 1.1 1997/07/18 09:19:03 kmatsuda Exp $      */
    2 /*      $NetBSD$        */
    3 /*
    4  * [NetBSD for NEC PC98 series]
    5  *  Copyright (c) 1994, 1995, 1996 NetBSD/pc98 porting staff.
    6  *  All rights reserved.
    7  * 
    8  *  Redistribution and use in source and binary forms, with or without
    9  *  modification, are permitted provided that the following conditions
   10  *  are met:
   11  *  1. Redistributions of source code must retain the above copyright
   12  *     notice, this list of conditions and the following disclaimer.
   13  *  2. Redistributions in binary form must reproduce the above copyright
   14  *     notice, this list of conditions and the following disclaimer in the
   15  *     documentation and/or other materials provided with the distribution.
   16  *  3. The name of the author may not be used to endorse or promote products
   17  *     derived from this software without specific prior written permission.
   18  * 
   19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   22  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
   23  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   28  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 /*
   32  * Copyright (c) 1994, 1995, 1996 Naofumi HONDA.  All rights reserved.
   33  */
   34 
   35 /**************************************************
   36  * FUNC
   37  **************************************************/
   38 /* timeout */
   39 void bstimeout __P((void *));
   40 
   41 /* ctrl setup */
   42 void bs_setup_ctrl __P((struct targ_info *, u_int, u_int));
   43 struct targ_info *bs_init_target_info __P((struct bs_softc *, int));
   44 
   45 /* msg op */
   46 int bs_send_msg __P((struct targ_info *, u_int, struct msgbase *, int));
   47 struct ccb *bs_request_sense __P((struct targ_info *));
   48 
   49 /* sync msg op */
   50 int bs_start_syncmsg __P((struct targ_info *, struct ccb *, int));
   51 int bs_send_syncmsg __P((struct targ_info *));
   52 int bs_analyze_syncmsg __P((struct targ_info *, struct ccb *));
   53 
   54 /* reset device */
   55 void bs_scsibus_start __P((struct bs_softc *));
   56 void bs_reset_nexus __P((struct bs_softc *));
   57 struct ccb *bs_force_abort __P((struct targ_info *));
   58 void bs_reset_device __P((struct targ_info *));
   59 
   60 /* ccb */
   61 struct ccb *bs_make_internal_ccb __P((struct targ_info *, u_int, u_int8_t *, u_int, u_int8_t *, u_int, u_int, int));
   62 struct ccb *bs_make_msg_ccb __P((struct targ_info *, u_int, struct ccb *, struct msgbase *, u_int));
   63 
   64 /* misc funcs */
   65 void bs_printf __P((struct targ_info *, char *, char *));
   66 void bs_panic __P((struct bs_softc *, u_char *));
   67 
   68 /* misc debug */
   69 u_int bsr __P((u_int));
   70 u_int bsw __P((u_int, int));
   71 void bs_debug_print_all __P((struct bs_softc *));
   72 void bs_debug_print __P((struct bs_softc *, struct targ_info *));
   73 
   74 /**************************************************
   75  * TARG FLAGS
   76  *************************************************/
   77 static BS_INLINE int bs_check_sat __P((struct targ_info *));
   78 static BS_INLINE int bs_check_smit __P((struct targ_info *));
   79 static BS_INLINE int bs_check_disc __P((struct targ_info *));
   80 static BS_INLINE int bs_check_link __P((struct targ_info *, struct ccb *));
   81 static BS_INLINE u_int8_t bs_identify_msg __P((struct targ_info *));
   82 static BS_INLINE void bs_targ_flags __P((struct targ_info *, struct ccb *));
   83 
   84 static BS_INLINE int
   85 bs_check_disc(ti)
   86         struct targ_info *ti;
   87 {
   88 
   89         return (ti->ti_flags & BSDISC);
   90 }
   91 
   92 static BS_INLINE int
   93 bs_check_sat(ti)
   94         struct targ_info *ti;
   95 {
   96 
   97         return (ti->ti_flags & BSSAT);
   98 }
   99 
  100 static BS_INLINE int
  101 bs_check_smit(ti)
  102         struct targ_info *ti;
  103 {
  104 
  105         return (ti->ti_flags & BSSMIT);
  106 }
  107 
  108 static BS_INLINE int
  109 bs_check_link(ti, cb)
  110         struct targ_info *ti;
  111         struct ccb *cb;
  112 {
  113         struct ccb *nextcb;
  114 
  115         return ((ti->ti_flags & BSLINK) &&
  116                 (nextcb = cb->ccb_chain.tqe_next) &&
  117                 (nextcb->flags & BSLINK));
  118 }
  119 
  120 static BS_INLINE u_int8_t
  121 bs_identify_msg(ti)
  122         struct targ_info *ti;
  123 {
  124 
  125         return ((bs_check_disc(ti) ? 0xc0 : 0x80) | ti->ti_lun);
  126 }
  127 
  128 static BS_INLINE void
  129 bs_targ_flags(ti, cb)
  130         struct targ_info *ti;
  131         struct ccb *cb;
  132 {
  133         u_int cmf = (u_int) bshw_cmd[cb->cmd[0]];
  134 
  135         cb->flags |= ((cmf & (BSSAT | BSSMIT | BSLINK)) | BSDISC);
  136         cb->flags &= ti->ti_mflags;
  137 
  138         if (cb->datalen < DEV_BSIZE)
  139                 cb->flags &= ~BSSMIT;
  140         if (cb->flags & BSFORCEIOPOLL)
  141                 cb->flags &= ~(BSLINK | BSSMIT | BSSAT | BSDISC);
  142 }
  143 
  144 /**************************************************
  145  * QUEUE OP
  146  **************************************************/
  147 static BS_INLINE void bs_hostque_init __P((struct bs_softc *));
  148 static BS_INLINE void bs_hostque_head __P((struct bs_softc *, struct targ_info *));
  149 static BS_INLINE void bs_hostque_tail __P((struct bs_softc *, struct targ_info *));
  150 static BS_INLINE void bs_hostque_delete __P((struct bs_softc *, struct targ_info *));
  151 
  152 static BS_INLINE void
  153 bs_hostque_init(bsc)
  154         struct bs_softc *bsc;
  155 {
  156 
  157         TAILQ_INIT(&bsc->sc_sttab);
  158         TAILQ_INIT(&bsc->sc_titab);
  159 }
  160 
  161 static BS_INLINE void
  162 bs_hostque_head(bsc, ti)
  163         struct bs_softc *bsc;
  164         struct targ_info *ti;
  165 {
  166 
  167         if (ti->ti_flags & BSQUEUED) {
  168                 TAILQ_REMOVE(&bsc->sc_sttab, ti, ti_wchain);
  169         } else {
  170                 ti->ti_flags |= BSQUEUED;
  171         }
  172         TAILQ_INSERT_HEAD(&bsc->sc_sttab, ti, ti_wchain);
  173 }
  174 
  175 static BS_INLINE void
  176 bs_hostque_tail(bsc, ti)
  177         struct bs_softc *bsc;
  178         struct targ_info *ti;
  179 {
  180 
  181         if (ti->ti_flags & BSQUEUED) {
  182                 TAILQ_REMOVE(&bsc->sc_sttab, ti, ti_wchain);
  183         } else {
  184                 ti->ti_flags |= BSQUEUED;
  185         }
  186         TAILQ_INSERT_TAIL(&bsc->sc_sttab, ti, ti_wchain);
  187 }
  188 
  189 static BS_INLINE void
  190 bs_hostque_delete(bsc, ti)
  191         struct bs_softc *bsc;
  192         struct targ_info *ti;
  193 {
  194 
  195         if (ti->ti_flags & BSQUEUED)
  196         {
  197                 ti->ti_flags &= ~BSQUEUED;
  198                 TAILQ_REMOVE(&bsc->sc_sttab, ti, ti_wchain);
  199         }
  200 }
  201 
  202 /*************************************************************
  203  * TIMEOUT
  204  ************************************************************/
  205 static BS_INLINE void bs_start_timeout __P((struct bs_softc *));
  206 static BS_INLINE void bs_terminate_timeout __P((struct bs_softc *));
  207 
  208 static BS_INLINE void
  209 bs_start_timeout(bsc)
  210         struct bs_softc *bsc;
  211 {
  212 
  213         if ((bsc->sc_flags & BSSTARTTIMEOUT) == 0)
  214         {
  215                 bsc->sc_flags |= BSSTARTTIMEOUT;
  216                 timeout(bstimeout, bsc, BS_TIMEOUT_INTERVAL);
  217         }
  218 }
  219 
  220 static BS_INLINE void
  221 bs_terminate_timeout(bsc)
  222         struct bs_softc *bsc;
  223 {
  224 
  225         if (bsc->sc_flags & BSSTARTTIMEOUT)
  226         {
  227                 untimeout(bstimeout, bsc);
  228                 bsc->sc_flags &= ~BSSTARTTIMEOUT;
  229         }
  230 }

Cache object: 1fcce92d961bcab35aa753dbed78d5b0


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