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/wd33c93var.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: wd33c93var.h,v 1.4 2006/10/01 22:02:55 bjh21 Exp $     */
    2 
    3 /*
    4  * Copyright (c) 1990 The Regents of the University of California.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to Berkeley by
    8  * Van Jacobson of Lawrence Berkeley Laboratory.
    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. Neither the name of the University nor the names of its contributors
   19  *    may be used to endorse or promote products derived from this software
   20  *    without specific prior written permission.
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   32  * SUCH DAMAGE.
   33  *
   34  *  @(#)scsivar.h   7.1 (Berkeley) 5/8/90
   35  */
   36 #ifndef _SBICVAR_H_
   37 #define _SBICVAR_H_
   38 #include <sys/callout.h>
   39 #include <sys/malloc.h>
   40 
   41 #define SBIC_NTARG      8
   42 #define SBIC_NLUN       8
   43 #define SBIC_NTAGS      256
   44 
   45 #define SBIC_MAX_MSGLEN 8
   46 
   47 #define SBIC_ABORT_TIMEOUT      2000    /* time to wait for abort */
   48 #define SBIC_SENSE_TIMEOUT      1000    /* time to wait for sense */
   49 
   50 /*
   51  * ACB. Holds additional information for each SCSI command Comments: We
   52  * need a separate scsi command block because we may need to overwrite it
   53  * with a request sense command.  Basically, we refrain from fiddling with
   54  * the scsi_xfer struct (except do the expected updating of return values).
   55  * We'll generally update: xs->{flags,resid,error,sense,status} and
   56  * occasionally xs->retries.
   57  */
   58 struct wd33c93_acb {
   59         TAILQ_ENTRY(wd33c93_acb) chain;
   60         struct scsipi_xfer *xs;         /* SCSI xfer ctrl block from above */
   61         int     flags;                  /* Status */
   62 #define ACB_FREE        0x00
   63 #define ACB_ACTIVE      0x01
   64 #define ACB_READY       0x02            /* ACB is on ready list */
   65 #define ACB_DONE        0x04
   66 #define ACB_SENSE       0x08            /* ACB Requesting sense */
   67 #define ACB_COMPLETE    0x10            /* Disconnected at end of xfer */
   68 #define ACB_RESET       0x20            /* Require Reset */
   69 #define ACB_ABORT       0x40            /* Require Abort */
   70 
   71         int     timeout;
   72         struct scsipi_generic cmd;      /* SCSI command block */
   73         int     clen;
   74         char    *daddr;                 /* kva for data */
   75         size_t  dleft;                  /* bytes remaining */
   76         u_char  tag_type;               /* TAG Type (0x20-0x22, 0=No Tags) */
   77         u_char  tag_id;                 /* TAG id number */
   78 };
   79 
   80 /*
   81  * Some info about each (possible) target on the SCSI bus.  This should
   82  * probably have been a "per target+lunit" structure, but we'll leave it at
   83  * this for now.  Is there a way to reliably hook it up to sc->fordriver??
   84  */
   85 
   86 struct wd33c93_linfo {
   87         LIST_ENTRY(wd33c93_linfo)       link;
   88         time_t  last_used;
   89         int     lun;
   90         int     used;                   /* # slots in use */
   91         u_char  state;
   92 #define L_STATE_IDLE    0
   93 #define L_STATE_BUSY    1
   94 #define L_STATE_ESTAT   2
   95         struct wd33c93_acb      *untagged;
   96         struct wd33c93_acb      *queued[SBIC_NTAGS];
   97 };
   98 
   99 struct wd33c93_tinfo {
  100         int     cmds;                   /* # of commands processed */
  101         int     dconns;                 /* # of disconnects */
  102 
  103         u_char  flags;
  104 #define T_NEED_RESET    0x01            /* Should send a BUS_DEV_RESET */
  105 #define T_NEGOTIATE     0x02            /* (Re)Negotiate synchronous options */
  106 #define T_BUSY          0x04            /* Target is busy */
  107 #define T_SYNCMODE      0x08            /* SYNC mode has been negotiated */
  108 #define T_NOSYNC        0x10            /* Force ASYNC mode */
  109 #define T_NODISC        0x20            /* Don't allow disconnect */
  110 #define T_TAG           0x40            /* Turn on TAG QUEUEs */
  111 #define T_WANTSYNC      0x80            /* Negotiatious should aim for sync */
  112         u_char  period;                 /* Period suggestion */
  113         u_char  offset;                 /* Offset suggestion */
  114         struct wd33c93_linfo *lun[SBIC_NLUN]; /* LUN list for this target */
  115 } tinfo_t;
  116 
  117 /* Look up a lun in a tinfo */
  118 #define TINFO_LUN(t, l)         ((t)->lun[(l)])
  119 
  120 struct wd33c93_softc {
  121         struct device   sc_dev;
  122 
  123         struct scsipi_channel sc_channel; /* proto for sub devices */
  124         struct scsipi_adapter sc_adapter;
  125         struct device *sc_child;        /* attached scsibus, if any */
  126         struct callout sc_watchdog;
  127         void    *sc_driver;             /* driver specific field */
  128 
  129         int     target;                 /* Currently active target */
  130         int     lun;                    /* Currently active LUN */
  131 
  132         /* WD33c93 registers */
  133         bus_space_tag_t         sc_regt;
  134         bus_space_handle_t      sc_regh;
  135 
  136 
  137         /* Data about the current nexus (updated for every cmd switch) */
  138         caddr_t sc_daddr;               /* Current data pointer */
  139         size_t  sc_dleft;               /* Data left to transfer */
  140         ssize_t sc_tcnt;                /* number of bytes transfered */
  141 
  142         /* Lists of command blocks */
  143         TAILQ_HEAD(acb_list, wd33c93_acb) ready_list;
  144 
  145         struct wd33c93_acb       *sc_nexus;     /* current command */
  146         struct wd33c93_tinfo sc_tinfo[8];
  147 
  148         u_short sc_state;
  149         u_short sc_status;
  150         int     sc_disc;                /* current # of active nexus's */
  151         int     sc_flags;
  152 
  153         /* Message stuff */
  154         u_short sc_msgify;              /* Last IDENTIFY message */
  155         u_short sc_msgout;              /* Current message out */
  156         u_short sc_msgpriq;             /* mesg_out queue (bitmap) */
  157         u_short sc_msgoutq;             /* mesg_out queue */
  158 
  159         u_char  sc_imsg[SBIC_MAX_MSGLEN];
  160         u_char  sc_omsg[SBIC_MAX_MSGLEN];
  161         u_char  sc_imsglen;
  162         u_char  sc_omsglen;
  163 
  164         /* Static hardware attributes supplied by attachment */
  165         int     sc_id;                  /* SCSI ID for controller */
  166         int     sc_clkfreq;             /* wd33c93 clk freq * 10 MHz */
  167         uint8_t sc_dmamode;             /* One of SBIC_CTL_*DMA */
  168 
  169         /* Static hardware attributes derived by wd33c93_attach() */
  170         int     sc_chip;                /* Chip variation */
  171         int     sc_rev;                 /* Chip revision */
  172         int     sc_cfflags;             /* Copy of config flags */
  173         int     sc_maxxfer;             /* Maximum transfer size */
  174         uint8_t sc_maxoffset;           /* Maximum sync ofset (bytes) */
  175         uint8_t sc_syncperiods[7];      /* Sync transfer periods (4ns units) */
  176 
  177         int  (*sc_dmasetup) (struct wd33c93_softc *, caddr_t *,
  178                                             size_t *, int, size_t *);
  179         int  (*sc_dmago) (struct wd33c93_softc *);
  180         void (*sc_dmastop) (struct wd33c93_softc *);
  181         void (*sc_reset) (struct wd33c93_softc *);
  182 };
  183 
  184 /* values for sc_flags */
  185 #define SBICF_SELECTED          0x01    /* bus is in selected state. */
  186 #define SBICF_NODMA             0x02    /* Polled transfer */
  187 #define SBICF_INDMA             0x04    /* DMA I/O in progress */
  188 #define SBICF_SYNCNEGO          0x08    /* Sync negotiation in progress */
  189 #define SBICF_ABORTING          0x10    /* Aborting */
  190 
  191 /* values for sc_state */
  192 #define SBIC_UNINITIALIZED      0       /* Driver not initialized */
  193 #define SBIC_IDLE               1       /* waiting for something to do */
  194 #define SBIC_SELECTING          2       /* SCSI command is arbiting */
  195 #define SBIC_RESELECTED         3       /* Has been reselected */
  196 #define SBIC_IDENTIFIED         4       /* Has gotten IFY but not TAG */
  197 #define SBIC_CONNECTED          5       /* Actively using the SCSI bus */
  198 #define SBIC_DISCONNECT         6       /* MSG_DISCONNECT received */
  199 #define SBIC_CMDCOMPLETE        7       /* MSG_CMDCOMPLETE received */
  200 #define SBIC_ERROR              8       /* Error has occurred */
  201 #define SBIC_SELTIMEOUT         9       /* Select Timeout */
  202 #define SBIC_CLEANING           10      /* Scrubbing ACB's */
  203 #define SBIC_BUSRESET           11      /* SCSI RST has been issued */
  204 
  205 /* values for sc_msgout */
  206 #define SEND_DEV_RESET          0x0001
  207 #define SEND_PARITY_ERROR       0x0002
  208 #define SEND_INIT_DET_ERR       0x0004
  209 #define SEND_REJECT             0x0008
  210 #define SEND_IDENTIFY           0x0010
  211 #define SEND_ABORT              0x0020
  212 #define SEND_WDTR               0x0040
  213 #define SEND_SDTR               0x0080
  214 #define SEND_TAG                0x0100
  215 
  216 /* WD33c93 chipset revisions - values for sc_rev */
  217 #define SBIC_CHIP_UNKNOWN       0
  218 #define SBIC_CHIP_WD33C93       1
  219 #define SBIC_CHIP_WD33C93A      2
  220 #define SBIC_CHIP_WD33C93B      3
  221 
  222 #define SBIC_CHIP_LIST          {"UNKNOWN", "WD33C93", "WD33C93A", "WD33C93B"}
  223 
  224 /*
  225  * States returned by our state machine
  226  */
  227 #define SBIC_STATE_ERROR        -1
  228 #define SBIC_STATE_DONE         0
  229 #define SBIC_STATE_RUNNING      1
  230 #define SBIC_STATE_DISCONNECT   2
  231 
  232 #define DEBUG_ACBS      0x01
  233 #define DEBUG_INTS      0x02
  234 #define DEBUG_CMDS      0x04
  235 #define DEBUG_MISC      0x08
  236 #define DEBUG_TRAC      0x10
  237 #define DEBUG_RSEL      0x20
  238 #define DEBUG_PHASE     0x40
  239 #define DEBUG_DMA       0x80
  240 #define DEBUG_CCMDS     0x100
  241 #define DEBUG_MSGS      0x200
  242 #define DEBUG_TAGS      0x400
  243 #define DEBUG_SYNC      0x800
  244 
  245 #ifdef DEBUG
  246 extern int wd33c93_debug_flags;
  247 #define SBIC_DEBUG(level, str)                                          \
  248         do {                                                            \
  249                 if (wd33c93_debug & __CONCAT(DEBUG_,level))             \
  250                          printf str;                                    \
  251         } while (0)
  252 #else
  253 #define SBIC_DEBUG(level, str)
  254 #endif
  255 
  256 struct buf;
  257 struct scsipi_xfer;
  258 
  259 void wd33c93_scsi_request (struct scsipi_channel *,
  260                                 scsipi_adapter_req_t, void *);
  261 void wd33c93_attach (struct wd33c93_softc *);
  262 int  wd33c93_intr (struct wd33c93_softc *);
  263 
  264 #endif /* _SBICVAR_H_ */

Cache object: 9f1127522051d74a1219438a4054b5e1


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