1 /* $NetBSD: siopvar.h,v 1.27 2009/09/04 18:40:19 tsutsui Exp $ */
4 * Copyright (c) 2000 Manuel Bouyer.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 /* structure and definitions for the siop driver */
34 * xfer description of the script: tables and reselect script
35 * In struct siop_common_cmd siop_xfer will point to this.
38 struct siop_common_xfer siop_tables
;
39 /* uint32_t resel[sizeof(load_dsa) / sizeof(load_dsa[0])]; */
44 * This describes a command handled by the SCSI controller
45 * These are chained in either a free list or a active list
46 * We have one queue per target
50 TAILQ_ENTRY (siop_cmd
) next
;
51 struct siop_common_cmd cmd_c
;
52 struct siop_cbd
*siop_cbdp
; /* pointer to our siop_cbd */
54 uint32_t saved_offset
; /* offset in table after disc without sdp */
56 #define cmd_tables cmd_c.siop_tables
58 /* command block descriptors: an array of siop_cmd + an array of siop_xfer */
60 TAILQ_ENTRY (siop_cbd
) next
;
61 struct siop_cmd
*cmds
;
62 struct siop_xfer
*xfers
;
63 bus_dmamap_t xferdma
; /* DMA map for this block of xfers */
68 struct siop_cmd
*active
; /* active command */
74 struct siop_tag siop_tag
[SIOP_NTAG
]; /* tag array */
75 int lun_flags
; /* per-lun flags, none currently */
80 * per target struct; siop_common_cmd->target and siop_common_softc->targets[]
84 struct siop_common_target target_c
;
85 struct siop_lun
*siop_lun
[8]; /* per-lun state */
87 struct siop_lunsw
*lunsw
;
91 TAILQ_ENTRY (siop_lunsw
) next
;
92 uint32_t lunsw_off
; /* offset of this lun sw, from sc_scriptaddr*/
93 uint32_t lunsw_size
; /* size of this lun sw */
96 static __inline
void siop_table_sync(struct siop_cmd
*, int);
98 siop_table_sync(struct siop_cmd
*siop_cmd
, int ops
)
100 struct siop_common_softc
*sc
= siop_cmd
->cmd_c
.siop_sc
;
103 offset
= siop_cmd
->cmd_c
.dsa
-
104 siop_cmd
->siop_cbdp
->xferdma
->dm_segs
[0].ds_addr
;
105 bus_dmamap_sync(sc
->sc_dmat
, siop_cmd
->siop_cbdp
->xferdma
, offset
,
106 sizeof(struct siop_xfer
), ops
);
110 TAILQ_HEAD(cmd_list
, siop_cmd
);
111 TAILQ_HEAD(cbd_list
, siop_cbd
);
112 TAILQ_HEAD(lunsw_list
, siop_lunsw
);
115 /* Driver internal state */
117 struct siop_common_softc sc_c
;
118 int sc_currschedslot
; /* current scheduler slot */
119 struct cbd_list cmds
; /* list of command block descriptors */
120 struct cmd_list free_list
; /* cmd descr free list */
121 struct lunsw_list lunsw_list
; /* lunsw free list */
122 uint32_t script_free_lo
; /* free ram offset from sc_scriptaddr */
123 uint32_t script_free_hi
; /* free ram offset from sc_scriptaddr */
124 int sc_ntargets
; /* number of known targets */
128 /* defs for sc_flags */
129 #define SCF_CHAN_NOSLOT 0x0001 /* channel out of scheduler slot */
131 void siop_attach(struct siop_softc
*);
132 int siop_intr(void *);
133 void siop_add_dev(struct siop_softc
*, int, int);
134 void siop_del_dev(struct siop_softc
*, int, int);