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