Home | History | Annotate | Line # | Download | only in ic
siopvar.h revision 1.16.2.1
      1  1.16.2.1  jdolecek /*	$NetBSD: siopvar.h,v 1.16.2.1 2002/06/23 17:46:50 jdolecek 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.16.2.1  jdolecek  *	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.5    bouyer  * 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.16.2.1  jdolecek /* Number of tag */
     36  1.16.2.1  jdolecek #define SIOP_NTAG 16
     37  1.16.2.1  jdolecek 
     38  1.16.2.1  jdolecek /*
     39  1.16.2.1  jdolecek  * xfer description of the script: tables and reselect script
     40  1.16.2.1  jdolecek  * In struct siop_common_cmd siop_xfer will point to this.
     41  1.16.2.1  jdolecek  */
     42  1.16.2.1  jdolecek struct siop_xfer {
     43  1.16.2.1  jdolecek 	struct siop_common_xfer siop_tables;
     44  1.16.2.1  jdolecek 	/* u_int32_t resel[sizeof(load_dsa) / sizeof(load_dsa[0])]; */
     45  1.16.2.1  jdolecek 	u_int32_t resel[25];
     46  1.16.2.1  jdolecek } __attribute__((__packed__));
     47  1.16.2.1  jdolecek 
     48  1.16.2.1  jdolecek /*
     49  1.16.2.1  jdolecek  * This decribes a command handled by the SCSI controller
     50  1.16.2.1  jdolecek  * These are chained in either a free list or a active list
     51  1.16.2.1  jdolecek  * We have one queue per target
     52  1.16.2.1  jdolecek  */
     53  1.16.2.1  jdolecek 
     54  1.16.2.1  jdolecek struct siop_cmd {
     55  1.16.2.1  jdolecek 	TAILQ_ENTRY (siop_cmd) next;
     56  1.16.2.1  jdolecek 	struct siop_common_cmd cmd_c;
     57  1.16.2.1  jdolecek 	struct siop_cbd *siop_cbdp; /* pointer to our siop_cbd */
     58  1.16.2.1  jdolecek 	int reselslot;
     59  1.16.2.1  jdolecek };
     60  1.16.2.1  jdolecek #define cmd_tables cmd_c.siop_tables
     61  1.16.2.1  jdolecek 
     62  1.16.2.1  jdolecek /* command block descriptors: an array of siop_cmd + an array of siop_xfer */
     63  1.16.2.1  jdolecek struct siop_cbd {
     64  1.16.2.1  jdolecek 	TAILQ_ENTRY (siop_cbd) next;
     65  1.16.2.1  jdolecek 	struct siop_cmd *cmds;
     66  1.16.2.1  jdolecek 	struct siop_xfer *xfers;
     67  1.16.2.1  jdolecek 	bus_dmamap_t xferdma; /* DMA map for this block of xfers */
     68  1.16.2.1  jdolecek };
     69  1.16.2.1  jdolecek 
     70  1.16.2.1  jdolecek /* per-tag struct */
     71  1.16.2.1  jdolecek struct siop_tag {
     72  1.16.2.1  jdolecek 	struct siop_cmd *active; /* active command */
     73  1.16.2.1  jdolecek 	u_int reseloff;
     74  1.16.2.1  jdolecek };
     75  1.16.2.1  jdolecek 
     76  1.16.2.1  jdolecek /* per lun struct */
     77  1.16.2.1  jdolecek struct siop_lun {
     78  1.16.2.1  jdolecek 	struct siop_tag siop_tag[SIOP_NTAG]; /* tag array */
     79  1.16.2.1  jdolecek 	int lun_flags; /* per-lun flags, none currently */
     80  1.16.2.1  jdolecek 	u_int reseloff;
     81  1.16.2.1  jdolecek };
     82  1.16.2.1  jdolecek 
     83  1.16.2.1  jdolecek /*
     84  1.16.2.1  jdolecek  * per target struct; siop_common_cmd->target and siop_common_softc->targets[]
     85  1.16.2.1  jdolecek  * will point to this
     86  1.16.2.1  jdolecek  */
     87  1.16.2.1  jdolecek struct siop_target {
     88  1.16.2.1  jdolecek 	struct siop_common_target target_c;
     89  1.16.2.1  jdolecek 	struct siop_lun *siop_lun[8]; /* per-lun state */
     90  1.16.2.1  jdolecek 	u_int reseloff;
     91  1.16.2.1  jdolecek 	struct siop_lunsw *lunsw;
     92  1.16.2.1  jdolecek };
     93  1.16.2.1  jdolecek 
     94  1.16.2.1  jdolecek struct siop_lunsw {
     95  1.16.2.1  jdolecek 	TAILQ_ENTRY (siop_lunsw) next;
     96  1.16.2.1  jdolecek 	u_int32_t lunsw_off; /* offset of this lun sw, from sc_scriptaddr*/
     97  1.16.2.1  jdolecek 	u_int32_t lunsw_size; /* size of this lun sw */
     98  1.16.2.1  jdolecek };
     99  1.16.2.1  jdolecek 
    100  1.16.2.1  jdolecek static __inline__ void siop_table_sync __P((struct siop_cmd *, int));
    101  1.16.2.1  jdolecek static __inline__ void
    102  1.16.2.1  jdolecek siop_table_sync(siop_cmd, ops)
    103  1.16.2.1  jdolecek 	struct siop_cmd *siop_cmd;
    104  1.16.2.1  jdolecek 	int ops;
    105  1.16.2.1  jdolecek {
    106  1.16.2.1  jdolecek 	struct siop_common_softc *sc  = siop_cmd->cmd_c.siop_sc;
    107  1.16.2.1  jdolecek 	bus_addr_t offset;
    108  1.16.2.1  jdolecek 
    109  1.16.2.1  jdolecek 	offset = siop_cmd->cmd_c.dsa -
    110  1.16.2.1  jdolecek 	    siop_cmd->siop_cbdp->xferdma->dm_segs[0].ds_addr;
    111  1.16.2.1  jdolecek 	bus_dmamap_sync(sc->sc_dmat, siop_cmd->siop_cbdp->xferdma, offset,
    112  1.16.2.1  jdolecek 	    sizeof(struct siop_xfer), ops);
    113  1.16.2.1  jdolecek }
    114  1.16.2.1  jdolecek 
    115  1.16.2.1  jdolecek 
    116       1.1    bouyer TAILQ_HEAD(cmd_list, siop_cmd);
    117       1.6    bouyer TAILQ_HEAD(cbd_list, siop_cbd);
    118      1.11    bouyer TAILQ_HEAD(lunsw_list, siop_lunsw);
    119       1.1    bouyer 
    120  1.16.2.1  jdolecek 
    121       1.1    bouyer /* Driver internal state */
    122       1.1    bouyer struct siop_softc {
    123  1.16.2.1  jdolecek 	struct siop_common_softc sc_c;
    124      1.10    bouyer 	int sc_currschedslot;		/* current scheduler slot */
    125       1.6    bouyer 	struct cbd_list cmds;		/* list of command block descriptors */
    126       1.1    bouyer 	struct cmd_list free_list;	/* cmd descr free list */
    127      1.11    bouyer 	struct lunsw_list lunsw_list;	/* lunsw free list */
    128      1.12    bouyer 	u_int32_t script_free_lo;	/* free ram offset from sc_scriptaddr */
    129      1.12    bouyer 	u_int32_t script_free_hi;	/* free ram offset from sc_scriptaddr */
    130      1.12    bouyer 	int sc_ntargets;		/* number of known targets */
    131       1.1    bouyer 	u_int32_t sc_flags;
    132       1.1    bouyer };
    133  1.16.2.1  jdolecek 
    134       1.1    bouyer /* defs for sc_flags */
    135      1.16    bouyer #define SCF_CHAN_NOSLOT	0x0001		/* channel out of sheduler slot */
    136       1.1    bouyer 
    137       1.1    bouyer void    siop_attach __P((struct siop_softc *));
    138       1.1    bouyer int	siop_intr __P((void *));
    139  1.16.2.1  jdolecek void	siop_add_dev __P((struct siop_softc *, int, int));
    140  1.16.2.1  jdolecek void	siop_del_dev __P((struct siop_softc *, int, int));
    141