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/osiopvar.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 /*      $OpenBSD: osiopvar.h,v 1.12 2020/07/22 13:16:04 krw Exp $       */
    2 /*      $NetBSD: osiopvar.h,v 1.3 2002/05/14 02:58:35 matt Exp $        */
    3 
    4 /*
    5  * Copyright (c) 2001 Izumi Tsutsui.  All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. The name of the author may not be used to endorse or promote products
   16  *    derived from this software without specific prior written permission.
   17  *
   18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   28  */
   29 
   30 /*
   31  * Copyright (c) 1990 The Regents of the University of California.
   32  * All rights reserved.
   33  *
   34  * This code is derived from software contributed to Berkeley by
   35  * Van Jacobson of Lawrence Berkeley Laboratory.
   36  *
   37  * Redistribution and use in source and binary forms, with or without
   38  * modification, are permitted provided that the following conditions
   39  * are met:
   40  * 1. Redistributions of source code must retain the above copyright
   41  *    notice, this list of conditions and the following disclaimer.
   42  * 2. Redistributions in binary form must reproduce the above copyright
   43  *    notice, this list of conditions and the following disclaimer in the
   44  *    documentation and/or other materials provided with the distribution.
   45  * 3. Neither the name of the University nor the names of its contributors
   46  *    may be used to endorse or promote products derived from this software
   47  *    without specific prior written permission.
   48  *
   49  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   50  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   51  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   52  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   53  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   54  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   55  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   56  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   57  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   58  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   59  * SUCH DAMAGE.
   60  *
   61  *      @(#)siopvar.h   7.1 (Berkeley) 5/8/90
   62  */
   63 
   64 #define osiop_read_1(sc, reg)                                   \
   65     bus_space_read_1((sc)->sc_bst, (sc)->sc_reg, reg)
   66 #define osiop_write_1(sc, reg, val)                             \
   67     bus_space_write_1((sc)->sc_bst, (sc)->sc_reg, reg, val)
   68 
   69 #define osiop_read_4(sc, reg)                                   \
   70     bus_space_read_4((sc)->sc_bst, (sc)->sc_reg, reg)
   71 #define osiop_write_4(sc, reg, val)                             \
   72     bus_space_write_4((sc)->sc_bst, (sc)->sc_reg, reg, val)     
   73         
   74 /*
   75  * The largest single request will be MAXPHYS bytes which will require
   76  * at most MAXPHYS/NBPG+1 chain elements to describe, i.e. if none of
   77  * the buffer pages are physically contiguous (MAXPHYS/NBPG) and the
   78  * buffer is not page aligned (+1).
   79  */
   80 /* XXX This should be (MAXPHYS / NBPG + 1), but hardcoded in script */
   81 #define OSIOP_NSG       (16 + 1)
   82 #if MAXPHYS > (PAGE_SIZE * (OSIOP_NSG - 1))
   83 #define OSIOP_MAX_XFER  (PAGE_SIZE * (OSIOP_NSG - 1))
   84 #else
   85 #define OSIOP_MAX_XFER  MAXPHYS
   86 #endif
   87 
   88 #define OSIOP_NTGT 8
   89 #define OSIOP_NACB 32   /* XXX (PAGE_SIZE / sizeof(osiop_ds)) is better? */
   90 
   91 /*
   92  * Data Structure for SCRIPTS program
   93  */
   94 typedef struct buf_table {
   95         u_int32_t count;
   96         u_int32_t addr;
   97 } buf_table_t;
   98 
   99 struct osiop_ds {
  100         u_int32_t scsi_addr;            /* SCSI ID & sync */
  101         u_int32_t pad1;
  102         buf_table_t id;                 /* Identify message */
  103         buf_table_t cmd;                /* SCSI command */
  104         buf_table_t status;             /* Status */
  105         buf_table_t msg;                /* Message */
  106         buf_table_t msgin;              /* Message in */
  107         buf_table_t extmsg;             /* Extended message in */
  108         buf_table_t synmsg;             /* Sync transfer request */
  109         buf_table_t data[OSIOP_NSG];    /* DMA S/G buffers */
  110 
  111         u_int8_t msgout[8];
  112         u_int8_t msgbuf[8];
  113         u_int8_t stat[8];
  114 
  115         struct scsi_generic scsi_cmd;   /* DMA'able copy of xs->cmd */
  116         u_int32_t pad[1+3];             /* pad to 256 bytes */
  117 } __packed;
  118 
  119 /* status can hold the SCSI_* status values, and 2 additional values: */
  120 #define SCSI_OSIOP_NOCHECK      0xfe    /* don't check the scsi status */
  121 #define SCSI_OSIOP_NOSTATUS     0xff    /* device didn't report status */
  122 
  123 #define MSG_INVALID             0xff    /* dummy value for message buffer */
  124 
  125 #define OSIOP_DSOFF(x)          offsetof(struct osiop_ds, x)
  126 #define OSIOP_DSIDOFF           OSIOP_DSOFF(msgout[0])
  127 #define OSIOP_DSMSGOFF          OSIOP_DSOFF(msgbuf[0])
  128 #define OSIOP_DSMSGINOFF        OSIOP_DSOFF(msgbuf[1])
  129 #define OSIOP_DSEXTMSGOFF       OSIOP_DSOFF(msgbuf[2])
  130 #define OSIOP_DSSYNMSGOFF       OSIOP_DSOFF(msgbuf[3])
  131 #define OSIOP_DSSTATOFF         OSIOP_DSOFF(stat[0])
  132 #define OSIOP_DSCMDOFF          OSIOP_DSOFF(scsi_cmd)
  133 
  134 /*
  135  * ACB. Holds additional information for each SCSI command Comments:
  136  * Basicly, we refrain from fiddling with the scsi_xfer struct
  137  * (except do the expected updating of return values).
  138  * We'll generally update: xs->{flags,resid,error,status} and
  139  * occasionally xs->retries.
  140  */
  141 struct osiop_acb {
  142         TAILQ_ENTRY(osiop_acb) chain;
  143         struct scsi_xfer *xs;   /* SCSI xfer ctrl block from upper layer */
  144         struct osiop_softc *sc; /* points back to our adapter */
  145 
  146         bus_dmamap_t datadma;   /* DMA map for data transfer */
  147 
  148         struct osiop_ds *ds;    /* data structure for this acb */
  149         bus_size_t dsoffset;    /* offset of data structure for this acb */
  150 
  151         int     xsflags;        /* copy of xs->flags */
  152         int     datalen;
  153         void *data;             /* transfer data buffer ptr */
  154 
  155         bus_addr_t curaddr;     /* current transfer data buffer */
  156         bus_size_t curlen;      /* current transfer data length */
  157 
  158         int status;             /* status of this acb */
  159 /* status defs */
  160 #define ACB_S_FREE      0       /* cmd slot is free */
  161 #define ACB_S_READY     1       /* cmd slot is waiting for processing */
  162 #define ACB_S_ACTIVE    2       /* cmd slot is being processed */
  163 #define ACB_S_DONE      3       /* cmd slot has been processed */
  164 
  165         int flags;              /* cmd slot flags */
  166 #define ACB_F_TIMEOUT   0x01    /* command timeout */
  167 #define ACB_F_AUTOSENSE 0x02    /* request sense due to SCSI_CHECK */
  168 
  169         u_int8_t intstat;       /* buffer to save sc_flags on disconnect */
  170 };
  171 
  172 /*
  173  * Some info about each (possible) target on the SCSI bus.  This should
  174  * probably have been a "per target+lunit" structure, but we'll leave it at
  175  * this for now.  Is there a way to reliably hook it up to sc->fordriver??
  176  */
  177 struct osiop_tinfo {
  178         int cmds;               /* number of commands processed */
  179         int senses;             /* number of sense requests */
  180         int dconns;             /* number of disconnects */
  181         int touts;              /* number of timeouts */
  182         int perrs;              /* number of parity errors */
  183         int lubusy;             /* What local units/subr. are busy? */
  184         int period;             /* Period suggestion */
  185         int offset;             /* Offset suggestion */
  186         int flags;              /* misc flags per each target */
  187 #define TI_NOSYNC       0x01    /* disable sync xfer on this target */
  188 #define TI_NODISC       0x02    /* disable disconnect on this target */
  189         int state;              /* negotiation state */
  190         u_int8_t sxfer;         /* value for SXFER reg */
  191         u_int8_t sbcl;          /* value for SBCL reg */
  192 };
  193 
  194 struct osiop_softc {
  195         struct device sc_dev;
  196 
  197         bus_space_tag_t sc_bst;         /* bus space tag */
  198         bus_space_handle_t sc_reg;      /* register I/O handle */
  199 
  200         bus_dma_tag_t sc_dmat;          /* bus dma tag */
  201         bus_dmamap_t sc_scrdma;         /* script dma map */
  202         bus_dmamap_t sc_dsdma;          /* script data dma map */
  203 
  204         u_int32_t *sc_script;           /* ptr to script memory */
  205         struct osiop_ds *sc_ds;         /* ptr to data structure memory */
  206 
  207         int sc_id;                      /* adapter SCSI id */
  208         int sc_active;                  /* number of active I/O's */
  209 
  210         struct osiop_acb *sc_nexus;     /* current command */
  211         struct osiop_acb *sc_acb;       /* the real command blocks */
  212 
  213         /* Lists of command blocks */
  214         TAILQ_HEAD(acb_list, osiop_acb) free_list,
  215                                         ready_list,
  216                                         nexus_list;
  217         struct mutex free_list_mtx;
  218 
  219         struct scsi_iopool  sc_iopool;
  220 
  221         struct osiop_tinfo sc_tinfo[OSIOP_NTGT];
  222 
  223         int sc_clock_freq;
  224         int sc_tcp[4];
  225         int sc_flags;
  226 #define OSIOP_INTSOFF   0x80    /* Interrupts turned off */
  227 #define OSIOP_INTDEFER  0x40    /* MD interrupt has been deferred */
  228 #define OSIOP_NODMA     0x02    /* No DMA transfer */
  229 #define OSIOP_ALIVE     0x01    /* controller initialized */
  230 
  231         int sc_cfflags;                 /* copy of config flags */
  232 
  233         int sc_minsync;
  234 
  235         u_int8_t sc_dstat;
  236         u_int8_t sc_sstat0;
  237         u_int8_t sc_sstat1;
  238         u_int8_t sc_istat;
  239         u_int8_t sc_dcntl;
  240         u_int8_t sc_ctest7;
  241         u_int8_t sc_dmode;
  242         u_int8_t sc_sien;
  243         u_int8_t sc_dien;
  244 };
  245 
  246 /* negotiation states */
  247 #define NEG_INIT        0       /* Initial negotiate state */
  248 #define NEG_SYNC        NEG_INIT /* Negotiate synch transfers */
  249 #define NEG_WAITS       1       /* Waiting for synch negotiation response */
  250 #define NEG_DONE        2       /* Wide and/or sync negotiation done */
  251 
  252 void osiop_attach(struct osiop_softc *);
  253 void osiop_intr(struct osiop_softc *);

Cache object: 1e81e2f3098cc94d9cb019ae9ff9fae9


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