Home | History | Annotate | Line # | Download | only in ic
siopvar.h revision 1.23.2.1
      1  1.23.2.1    yamt /*	$NetBSD: siopvar.h,v 1.23.2.1 2006/02/18 15:39:05 yamt Exp $	*/
      2       1.1  bouyer 
      3       1.1  bouyer /*
      4       1.1  bouyer  * Copyright (c) 2000 Manuel Bouyer.
      5       1.1  bouyer  *
      6       1.1  bouyer  * Redistribution and use in source and binary forms, with or without
      7       1.1  bouyer  * modification, are permitted provided that the following conditions
      8       1.1  bouyer  * are met:
      9       1.1  bouyer  * 1. Redistributions of source code must retain the above copyright
     10       1.1  bouyer  *    notice, this list of conditions and the following disclaimer.
     11       1.1  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     12       1.1  bouyer  *    notice, this list of conditions and the following disclaimer in the
     13       1.1  bouyer  *    documentation and/or other materials provided with the distribution.
     14       1.1  bouyer  * 3. All advertising materials mentioning features or use of this software
     15       1.1  bouyer  *    must display the following acknowledgement:
     16      1.18  bouyer  *	This product includes software developed by Manuel Bouyer.
     17       1.3  bouyer  * 4. The name of the author may not be used to endorse or promote products
     18       1.3  bouyer  *    derived from this software without specific prior written permission.
     19       1.1  bouyer  *
     20       1.5  bouyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21       1.5  bouyer  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22       1.5  bouyer  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23      1.21   perry  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24       1.5  bouyer  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25       1.5  bouyer  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26       1.5  bouyer  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27       1.5  bouyer  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28       1.5  bouyer  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29       1.5  bouyer  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30       1.1  bouyer  *
     31       1.1  bouyer  */
     32       1.1  bouyer 
     33       1.1  bouyer /* structure and definitions for the siop driver */
     34       1.1  bouyer 
     35      1.17  bouyer /* Number of tag */
     36      1.17  bouyer #define SIOP_NTAG 16
     37      1.17  bouyer 
     38      1.17  bouyer /*
     39      1.17  bouyer  * xfer description of the script: tables and reselect script
     40      1.17  bouyer  * In struct siop_common_cmd siop_xfer will point to this.
     41      1.17  bouyer  */
     42      1.17  bouyer struct siop_xfer {
     43      1.17  bouyer 	struct siop_common_xfer siop_tables;
     44      1.17  bouyer 	/* u_int32_t resel[sizeof(load_dsa) / sizeof(load_dsa[0])]; */
     45      1.17  bouyer 	u_int32_t resel[25];
     46      1.17  bouyer } __attribute__((__packed__));
     47      1.17  bouyer 
     48      1.17  bouyer /*
     49      1.19     wiz  * This describes a command handled by the SCSI controller
     50      1.17  bouyer  * These are chained in either a free list or a active list
     51      1.17  bouyer  * We have one queue per target
     52      1.17  bouyer  */
     53      1.17  bouyer 
     54      1.17  bouyer struct siop_cmd {
     55      1.17  bouyer 	TAILQ_ENTRY (siop_cmd) next;
     56      1.17  bouyer 	struct siop_common_cmd cmd_c;
     57      1.17  bouyer 	struct siop_cbd *siop_cbdp; /* pointer to our siop_cbd */
     58      1.17  bouyer 	int reselslot;
     59      1.22  bouyer 	u_int32_t saved_offset; /* offset in table after disc without sdp */
     60      1.17  bouyer };
     61      1.17  bouyer #define cmd_tables cmd_c.siop_tables
     62      1.17  bouyer 
     63      1.17  bouyer /* command block descriptors: an array of siop_cmd + an array of siop_xfer */
     64      1.17  bouyer struct siop_cbd {
     65      1.17  bouyer 	TAILQ_ENTRY (siop_cbd) next;
     66      1.17  bouyer 	struct siop_cmd *cmds;
     67      1.17  bouyer 	struct siop_xfer *xfers;
     68      1.17  bouyer 	bus_dmamap_t xferdma; /* DMA map for this block of xfers */
     69      1.17  bouyer };
     70      1.17  bouyer 
     71      1.17  bouyer /* per-tag struct */
     72      1.17  bouyer struct siop_tag {
     73      1.17  bouyer 	struct siop_cmd *active; /* active command */
     74      1.17  bouyer 	u_int reseloff;
     75      1.17  bouyer };
     76      1.17  bouyer 
     77      1.17  bouyer /* per lun struct */
     78      1.17  bouyer struct siop_lun {
     79      1.17  bouyer 	struct siop_tag siop_tag[SIOP_NTAG]; /* tag array */
     80      1.17  bouyer 	int lun_flags; /* per-lun flags, none currently */
     81      1.17  bouyer 	u_int reseloff;
     82      1.17  bouyer };
     83      1.17  bouyer 
     84      1.17  bouyer /*
     85      1.17  bouyer  * per target struct; siop_common_cmd->target and siop_common_softc->targets[]
     86      1.17  bouyer  * will point to this
     87      1.17  bouyer  */
     88      1.17  bouyer struct siop_target {
     89      1.17  bouyer 	struct siop_common_target target_c;
     90      1.17  bouyer 	struct siop_lun *siop_lun[8]; /* per-lun state */
     91      1.17  bouyer 	u_int reseloff;
     92      1.17  bouyer 	struct siop_lunsw *lunsw;
     93      1.17  bouyer };
     94      1.17  bouyer 
     95      1.17  bouyer struct siop_lunsw {
     96      1.17  bouyer 	TAILQ_ENTRY (siop_lunsw) next;
     97      1.17  bouyer 	u_int32_t lunsw_off; /* offset of this lun sw, from sc_scriptaddr*/
     98      1.17  bouyer 	u_int32_t lunsw_size; /* size of this lun sw */
     99      1.17  bouyer };
    100      1.17  bouyer 
    101  1.23.2.1    yamt static __inline void siop_table_sync(struct siop_cmd *, int);
    102  1.23.2.1    yamt static __inline void
    103      1.17  bouyer siop_table_sync(siop_cmd, ops)
    104      1.17  bouyer 	struct siop_cmd *siop_cmd;
    105      1.17  bouyer 	int ops;
    106      1.17  bouyer {
    107      1.17  bouyer 	struct siop_common_softc *sc  = siop_cmd->cmd_c.siop_sc;
    108      1.17  bouyer 	bus_addr_t offset;
    109      1.17  bouyer 
    110      1.17  bouyer 	offset = siop_cmd->cmd_c.dsa -
    111      1.17  bouyer 	    siop_cmd->siop_cbdp->xferdma->dm_segs[0].ds_addr;
    112      1.17  bouyer 	bus_dmamap_sync(sc->sc_dmat, siop_cmd->siop_cbdp->xferdma, offset,
    113      1.17  bouyer 	    sizeof(struct siop_xfer), ops);
    114      1.17  bouyer }
    115      1.17  bouyer 
    116      1.17  bouyer 
    117       1.1  bouyer TAILQ_HEAD(cmd_list, siop_cmd);
    118       1.6  bouyer TAILQ_HEAD(cbd_list, siop_cbd);
    119      1.11  bouyer TAILQ_HEAD(lunsw_list, siop_lunsw);
    120       1.1  bouyer 
    121      1.17  bouyer 
    122       1.1  bouyer /* Driver internal state */
    123       1.1  bouyer struct siop_softc {
    124      1.17  bouyer 	struct siop_common_softc sc_c;
    125      1.10  bouyer 	int sc_currschedslot;		/* current scheduler slot */
    126       1.6  bouyer 	struct cbd_list cmds;		/* list of command block descriptors */
    127       1.1  bouyer 	struct cmd_list free_list;	/* cmd descr free list */
    128      1.11  bouyer 	struct lunsw_list lunsw_list;	/* lunsw free list */
    129      1.12  bouyer 	u_int32_t script_free_lo;	/* free ram offset from sc_scriptaddr */
    130      1.12  bouyer 	u_int32_t script_free_hi;	/* free ram offset from sc_scriptaddr */
    131      1.12  bouyer 	int sc_ntargets;		/* number of known targets */
    132       1.1  bouyer 	u_int32_t sc_flags;
    133       1.1  bouyer };
    134      1.17  bouyer 
    135       1.1  bouyer /* defs for sc_flags */
    136      1.19     wiz #define SCF_CHAN_NOSLOT	0x0001		/* channel out of scheduler slot */
    137       1.1  bouyer 
    138      1.20   perry void    siop_attach(struct siop_softc *);
    139      1.20   perry int	siop_intr(void *);
    140      1.20   perry void	siop_add_dev(struct siop_softc *, int, int);
    141      1.20   perry void	siop_del_dev(struct siop_softc *, int, int);
    142