2005-02-04 05:10:35 +03:00
|
|
|
/* $NetBSD: siopvar.h,v 1.20 2005/02/04 02:10:37 perry Exp $ */
|
2000-04-21 21:56:58 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2000 Manuel Bouyer.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
2002-04-24 00:41:13 +04:00
|
|
|
* This product includes software developed by Manuel Bouyer.
|
2000-04-27 18:06:57 +04:00
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
2000-04-21 21:56:58 +04:00
|
|
|
*
|
2000-05-15 11:48:24 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2000-04-21 21:56:58 +04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* structure and definitions for the siop driver */
|
|
|
|
|
2002-04-20 04:15:54 +04:00
|
|
|
/* Number of tag */
|
|
|
|
#define SIOP_NTAG 16
|
|
|
|
|
|
|
|
/*
|
|
|
|
* xfer description of the script: tables and reselect script
|
|
|
|
* In struct siop_common_cmd siop_xfer will point to this.
|
|
|
|
*/
|
|
|
|
struct siop_xfer {
|
|
|
|
struct siop_common_xfer siop_tables;
|
|
|
|
/* u_int32_t resel[sizeof(load_dsa) / sizeof(load_dsa[0])]; */
|
|
|
|
u_int32_t resel[25];
|
|
|
|
} __attribute__((__packed__));
|
|
|
|
|
|
|
|
/*
|
2003-11-02 14:07:44 +03:00
|
|
|
* This describes a command handled by the SCSI controller
|
2002-04-20 04:15:54 +04:00
|
|
|
* These are chained in either a free list or a active list
|
|
|
|
* We have one queue per target
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct siop_cmd {
|
|
|
|
TAILQ_ENTRY (siop_cmd) next;
|
|
|
|
struct siop_common_cmd cmd_c;
|
|
|
|
struct siop_cbd *siop_cbdp; /* pointer to our siop_cbd */
|
|
|
|
int reselslot;
|
|
|
|
};
|
|
|
|
#define cmd_tables cmd_c.siop_tables
|
|
|
|
|
|
|
|
/* command block descriptors: an array of siop_cmd + an array of siop_xfer */
|
|
|
|
struct siop_cbd {
|
|
|
|
TAILQ_ENTRY (siop_cbd) next;
|
|
|
|
struct siop_cmd *cmds;
|
|
|
|
struct siop_xfer *xfers;
|
|
|
|
bus_dmamap_t xferdma; /* DMA map for this block of xfers */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* per-tag struct */
|
|
|
|
struct siop_tag {
|
|
|
|
struct siop_cmd *active; /* active command */
|
|
|
|
u_int reseloff;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* per lun struct */
|
|
|
|
struct siop_lun {
|
|
|
|
struct siop_tag siop_tag[SIOP_NTAG]; /* tag array */
|
|
|
|
int lun_flags; /* per-lun flags, none currently */
|
|
|
|
u_int reseloff;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* per target struct; siop_common_cmd->target and siop_common_softc->targets[]
|
|
|
|
* will point to this
|
|
|
|
*/
|
|
|
|
struct siop_target {
|
|
|
|
struct siop_common_target target_c;
|
|
|
|
struct siop_lun *siop_lun[8]; /* per-lun state */
|
|
|
|
u_int reseloff;
|
|
|
|
struct siop_lunsw *lunsw;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct siop_lunsw {
|
|
|
|
TAILQ_ENTRY (siop_lunsw) next;
|
|
|
|
u_int32_t lunsw_off; /* offset of this lun sw, from sc_scriptaddr*/
|
|
|
|
u_int32_t lunsw_size; /* size of this lun sw */
|
|
|
|
};
|
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
static __inline__ void siop_table_sync(struct siop_cmd *, int);
|
2002-04-20 04:15:54 +04:00
|
|
|
static __inline__ void
|
|
|
|
siop_table_sync(siop_cmd, ops)
|
|
|
|
struct siop_cmd *siop_cmd;
|
|
|
|
int ops;
|
|
|
|
{
|
|
|
|
struct siop_common_softc *sc = siop_cmd->cmd_c.siop_sc;
|
|
|
|
bus_addr_t offset;
|
|
|
|
|
|
|
|
offset = siop_cmd->cmd_c.dsa -
|
|
|
|
siop_cmd->siop_cbdp->xferdma->dm_segs[0].ds_addr;
|
|
|
|
bus_dmamap_sync(sc->sc_dmat, siop_cmd->siop_cbdp->xferdma, offset,
|
|
|
|
sizeof(struct siop_xfer), ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-21 21:56:58 +04:00
|
|
|
TAILQ_HEAD(cmd_list, siop_cmd);
|
2000-05-23 21:08:07 +04:00
|
|
|
TAILQ_HEAD(cbd_list, siop_cbd);
|
2000-10-18 21:06:52 +04:00
|
|
|
TAILQ_HEAD(lunsw_list, siop_lunsw);
|
2000-04-21 21:56:58 +04:00
|
|
|
|
2002-04-20 04:15:54 +04:00
|
|
|
|
2000-04-21 21:56:58 +04:00
|
|
|
/* Driver internal state */
|
|
|
|
struct siop_softc {
|
2002-04-20 04:15:54 +04:00
|
|
|
struct siop_common_softc sc_c;
|
2000-10-06 20:39:04 +04:00
|
|
|
int sc_currschedslot; /* current scheduler slot */
|
2000-05-23 21:08:07 +04:00
|
|
|
struct cbd_list cmds; /* list of command block descriptors */
|
2000-04-21 21:56:58 +04:00
|
|
|
struct cmd_list free_list; /* cmd descr free list */
|
2000-10-18 21:06:52 +04:00
|
|
|
struct lunsw_list lunsw_list; /* lunsw free list */
|
2000-10-23 18:56:16 +04:00
|
|
|
u_int32_t script_free_lo; /* free ram offset from sc_scriptaddr */
|
|
|
|
u_int32_t script_free_hi; /* free ram offset from sc_scriptaddr */
|
|
|
|
int sc_ntargets; /* number of known targets */
|
2000-04-21 21:56:58 +04:00
|
|
|
u_int32_t sc_flags;
|
|
|
|
};
|
2002-04-20 04:15:54 +04:00
|
|
|
|
2000-04-21 21:56:58 +04:00
|
|
|
/* defs for sc_flags */
|
2003-11-02 14:07:44 +03:00
|
|
|
#define SCF_CHAN_NOSLOT 0x0001 /* channel out of scheduler slot */
|
2000-04-21 21:56:58 +04:00
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
void siop_attach(struct siop_softc *);
|
|
|
|
int siop_intr(void *);
|
|
|
|
void siop_add_dev(struct siop_softc *, int, int);
|
|
|
|
void siop_del_dev(struct siop_softc *, int, int);
|