escvar.h revision 1.1.6.2 1 1.1.6.2 thorpej /* $NetBSD: escvar.h,v 1.1.6.2 2002/01/10 19:36:33 thorpej Exp $ */
2 1.1.6.2 thorpej
3 1.1.6.2 thorpej /*
4 1.1.6.2 thorpej * Copyright (c) 1995 Daniel Widenfalk
5 1.1.6.2 thorpej *
6 1.1.6.2 thorpej * Redistribution and use in source and binary forms, with or without
7 1.1.6.2 thorpej * modification, are permitted provided that the following conditions
8 1.1.6.2 thorpej * are met:
9 1.1.6.2 thorpej * 1. Redistributions of source code must retain the above copyright
10 1.1.6.2 thorpej * notice, this list of conditions and the following disclaimer.
11 1.1.6.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
12 1.1.6.2 thorpej * notice, this list of conditions and the following disclaimer in the
13 1.1.6.2 thorpej * documentation and/or other materials provided with the distribution.
14 1.1.6.2 thorpej * 3. All advertising materials mentioning features or use of this software
15 1.1.6.2 thorpej * must display the following acknowledgement:
16 1.1.6.2 thorpej * This product includes software developed by Daniel Widenfalk
17 1.1.6.2 thorpej * for the NetBSD Project.
18 1.1.6.2 thorpej * 4. The name of the author may not be used to endorse or promote products
19 1.1.6.2 thorpej * derived from this software without specific prior written permission
20 1.1.6.2 thorpej *
21 1.1.6.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1.6.2 thorpej * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1.6.2 thorpej * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1.6.2 thorpej * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1.6.2 thorpej * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1.6.2 thorpej * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1.6.2 thorpej * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1.6.2 thorpej * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1.6.2 thorpej * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1.6.2 thorpej * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1.6.2 thorpej */
32 1.1.6.2 thorpej
33 1.1.6.2 thorpej #ifndef _ESCVAR_H_
34 1.1.6.2 thorpej #define _ESCVAR_H_
35 1.1.6.2 thorpej
36 1.1.6.2 thorpej #ifndef _ESCREG_H_
37 1.1.6.2 thorpej #include <acorn32/podulebus/escreg.h>
38 1.1.6.2 thorpej #endif
39 1.1.6.2 thorpej
40 1.1.6.2 thorpej /*
41 1.1.6.2 thorpej * MAXCHAIN is the anticipated maximum number of chain blocks needed. This
42 1.1.6.2 thorpej * assumes that we are NEVER requested to transfer more than MAXPHYS bytes.
43 1.1.6.2 thorpej */
44 1.1.6.2 thorpej #define MAXCHAIN (MAXPHYS/NBPG+2)
45 1.1.6.2 thorpej
46 1.1.6.2 thorpej /*
47 1.1.6.2 thorpej * Maximum number of requests standing by. Could be anything, but I think 9
48 1.1.6.2 thorpej * looks nice :-) NOTE: This does NOT include requests already started!
49 1.1.6.2 thorpej */
50 1.1.6.2 thorpej #define MAXPENDING 9 /* 7 IDs + 2 extra */
51 1.1.6.2 thorpej
52 1.1.6.2 thorpej /*
53 1.1.6.2 thorpej * DMA chain block. If flg == ESC_CHAIN_PRG or flg == ESC_CHAIN_BUMP then
54 1.1.6.2 thorpej * ptr is a VIRTUAL adress. If flg == ESC_CHAIN_DMA then ptr is a PHYSICAL
55 1.1.6.2 thorpej * adress.
56 1.1.6.2 thorpej */
57 1.1.6.2 thorpej struct esc_dma_chain {
58 1.1.6.2 thorpej vm_offset_t ptr;
59 1.1.6.2 thorpej u_short len;
60 1.1.6.2 thorpej short flg;
61 1.1.6.2 thorpej };
62 1.1.6.2 thorpej #define ESC_CHAIN_DMA 0x00
63 1.1.6.2 thorpej #define ESC_CHAIN_BUMP 0x01
64 1.1.6.2 thorpej #define ESC_CHAIN_PRG 0x02
65 1.1.6.2 thorpej
66 1.1.6.2 thorpej
67 1.1.6.2 thorpej /*
68 1.1.6.2 thorpej * This struct contains the necessary info for a pending request. Pointer to
69 1.1.6.2 thorpej * a scsipi_xfer struct.
70 1.1.6.2 thorpej */
71 1.1.6.2 thorpej struct esc_pending {
72 1.1.6.2 thorpej TAILQ_ENTRY(esc_pending) link;
73 1.1.6.2 thorpej struct scsipi_xfer *xs;
74 1.1.6.2 thorpej };
75 1.1.6.2 thorpej
76 1.1.6.2 thorpej /*
77 1.1.6.2 thorpej * nexus contains all active data for one SCSI unit. Parts of the info in this
78 1.1.6.2 thorpej * struct survives between scsi commands.
79 1.1.6.2 thorpej */
80 1.1.6.2 thorpej struct nexus {
81 1.1.6.2 thorpej struct scsipi_xfer *xs; /* Pointer to request */
82 1.1.6.2 thorpej
83 1.1.6.2 thorpej u_char ID; /* ID message to be sent */
84 1.1.6.2 thorpej u_char clen; /* scsi command length + */
85 1.1.6.2 thorpej u_char cbuf[14]; /* the actual command bytes */
86 1.1.6.2 thorpej
87 1.1.6.2 thorpej struct esc_dma_chain dma[MAXCHAIN]; /* DMA chain blocks */
88 1.1.6.2 thorpej short max_link; /* Maximum used of above */
89 1.1.6.2 thorpej short cur_link; /* Currently handled block */
90 1.1.6.2 thorpej
91 1.1.6.2 thorpej u_char *buf; /* Virtual adress of data */
92 1.1.6.2 thorpej int len; /* Bytes left to transfer */
93 1.1.6.2 thorpej
94 1.1.6.2 thorpej vm_offset_t dma_buf; /* Current DMA adress */
95 1.1.6.2 thorpej int dma_len; /* Current DMA length */
96 1.1.6.2 thorpej
97 1.1.6.2 thorpej vm_offset_t dma_blk_ptr; /* Current chain adress */
98 1.1.6.2 thorpej int dma_blk_len; /* Current chain length */
99 1.1.6.2 thorpej u_char dma_blk_flg; /* Current chain flags */
100 1.1.6.2 thorpej
101 1.1.6.2 thorpej u_char state; /* Nexus state, see below */
102 1.1.6.2 thorpej u_short flags; /* Nexus flags, see below */
103 1.1.6.2 thorpej
104 1.1.6.2 thorpej short period; /* Sync period to request */
105 1.1.6.2 thorpej u_char offset; /* Sync offset to request */
106 1.1.6.2 thorpej
107 1.1.6.2 thorpej u_char syncper; /* FAS216 variable storage */
108 1.1.6.2 thorpej u_char syncoff; /* FAS216 variable storage */
109 1.1.6.2 thorpej u_char config3; /* FAS216 variable storage */
110 1.1.6.2 thorpej
111 1.1.6.2 thorpej u_char lun_unit; /* (Lun<<4) | Unit of nexus */
112 1.1.6.2 thorpej u_char status; /* Status byte from unit*/
113 1.1.6.2 thorpej
114 1.1.6.2 thorpej };
115 1.1.6.2 thorpej
116 1.1.6.2 thorpej /* SCSI nexus_states */
117 1.1.6.2 thorpej #define ESC_NS_IDLE 0 /* Nexus idle */
118 1.1.6.2 thorpej #define ESC_NS_SELECTED 1 /* Last command was a SELECT command */
119 1.1.6.2 thorpej #define ESC_NS_DATA_IN 2 /* Last command was a TRANSFER_INFO */
120 1.1.6.2 thorpej /* command during a data in phase */
121 1.1.6.2 thorpej #define ESC_NS_DATA_OUT 3 /* Last command was a TRANSFER_INFO */
122 1.1.6.2 thorpej /* command during a data out phase */
123 1.1.6.2 thorpej #define ESC_NS_STATUS 4 /* We have send a COMMAND_COMPLETE */
124 1.1.6.2 thorpej /* command and are awaiting status */
125 1.1.6.2 thorpej #define ESC_NS_MSG_IN 5 /* Last phase was MESSAGE IN */
126 1.1.6.2 thorpej #define ESC_NS_MSG_OUT 6 /* Last phase was MESSAGE OUT */
127 1.1.6.2 thorpej #define ESC_NS_SVC 7 /* We have sent the command */
128 1.1.6.2 thorpej #define ESC_NS_DISCONNECTING 8 /* We have received a disconnect msg */
129 1.1.6.2 thorpej #define ESC_NS_DISCONNECTED 9 /* We are disconnected */
130 1.1.6.2 thorpej #define ESC_NS_RESELECTED 10 /* We was reselected */
131 1.1.6.2 thorpej #define ESC_NS_DONE 11 /* Done. Prephsase to FINISHED */
132 1.1.6.2 thorpej #define ESC_NS_FINISHED 12 /* Realy done. Call scsi_done */
133 1.1.6.2 thorpej #define ESC_NS_RESET 13 /* We are reseting this unit */
134 1.1.6.2 thorpej
135 1.1.6.2 thorpej /* SCSI nexus flags */
136 1.1.6.2 thorpej #define ESC_NF_UNIT_BUSY 0x0001 /* Unit is not available */
137 1.1.6.2 thorpej
138 1.1.6.2 thorpej #define ESC_NF_SELECT_ME 0x0002 /* Nexus is set up, waiting for bus */
139 1.1.6.2 thorpej
140 1.1.6.2 thorpej #define ESC_NF_HAS_MSG 0x0010 /* We have received a complete msg */
141 1.1.6.2 thorpej
142 1.1.6.2 thorpej #define ESC_NF_DO_SDTR 0x0020 /* We should send a SDTR */
143 1.1.6.2 thorpej #define ESC_NF_SDTR_SENT 0x0040 /* We have sent a SDTR */
144 1.1.6.2 thorpej #define ESC_NF_SYNC_TESTED 0x0080 /* We have negotiated sync */
145 1.1.6.2 thorpej
146 1.1.6.2 thorpej #define ESC_NF_RESET 0x0100 /* Reset this nexus */
147 1.1.6.2 thorpej #define ESC_NF_IMMEDIATE 0x0200 /* We are operating from escicmd */
148 1.1.6.2 thorpej
149 1.1.6.2 thorpej #define ESC_NF_RETRY_SELECT 0x1000 /* Selection needs retrying */
150 1.1.6.2 thorpej
151 1.1.6.2 thorpej #define ESC_NF_DEBUG 0x8000 /* As it says: DEBUG */
152 1.1.6.2 thorpej
153 1.1.6.2 thorpej struct esc_softc {
154 1.1.6.2 thorpej struct device sc_dev; /* System required struct */
155 1.1.6.2 thorpej struct scsipi_channel sc_channel; /* For sub devices */
156 1.1.6.2 thorpej struct scsipi_adapter sc_adapter;
157 1.1.6.2 thorpej irqhandler_t sc_ih; /* Interrupt chain struct */
158 1.1.6.2 thorpej
159 1.1.6.2 thorpej TAILQ_HEAD(,esc_pending) sc_xs_pending;
160 1.1.6.2 thorpej TAILQ_HEAD(,esc_pending) sc_xs_free;
161 1.1.6.2 thorpej struct esc_pending sc_xs_store[MAXPENDING];
162 1.1.6.2 thorpej
163 1.1.6.2 thorpej esc_regmap_p sc_esc; /* FAS216 Address */
164 1.1.6.2 thorpej void *sc_spec; /* Board-specific data */
165 1.1.6.2 thorpej
166 1.1.6.2 thorpej u_char *sc_bump_va; /* Bumpbuf virtual adr */
167 1.1.6.2 thorpej vm_offset_t sc_bump_pa; /* Bumpbuf physical adr */
168 1.1.6.2 thorpej int sc_bump_sz; /* Bumpbuf size */
169 1.1.6.2 thorpej
170 1.1.6.2 thorpej /* Configuration registers, must be set BEFORE escinitialize */
171 1.1.6.2 thorpej u_char sc_clock_freq;
172 1.1.6.2 thorpej u_short sc_timeout;
173 1.1.6.2 thorpej u_char sc_host_id;
174 1.1.6.2 thorpej u_char sc_config_flags;
175 1.1.6.2 thorpej
176 1.1.6.2 thorpej /* Generic DMA functions */
177 1.1.6.2 thorpej int (*sc_setup_dma)();
178 1.1.6.2 thorpej int (*sc_build_dma_chain)();
179 1.1.6.2 thorpej int (*sc_need_bump)();
180 1.1.6.2 thorpej
181 1.1.6.2 thorpej /* Generic Led data */
182 1.1.6.2 thorpej int sc_led_status;
183 1.1.6.2 thorpej void (*sc_led)();
184 1.1.6.2 thorpej
185 1.1.6.2 thorpej /* Nexus list */
186 1.1.6.2 thorpej struct nexus sc_nexus[8];
187 1.1.6.2 thorpej struct nexus *sc_cur_nexus;
188 1.1.6.2 thorpej struct nexus *sc_sel_nexus;
189 1.1.6.2 thorpej
190 1.1.6.2 thorpej /* Current transfer data */
191 1.1.6.2 thorpej u_char *sc_buf; /* va */
192 1.1.6.2 thorpej int sc_len;
193 1.1.6.2 thorpej
194 1.1.6.2 thorpej vm_offset_t sc_dma_buf; /* pa */
195 1.1.6.2 thorpej int sc_dma_len;
196 1.1.6.2 thorpej vm_offset_t sc_dma_blk_ptr;
197 1.1.6.2 thorpej int sc_dma_blk_len;
198 1.1.6.2 thorpej short sc_dma_blk_flg;
199 1.1.6.2 thorpej
200 1.1.6.2 thorpej struct esc_dma_chain *sc_chain; /* Current DMA chain */
201 1.1.6.2 thorpej short sc_max_link;
202 1.1.6.2 thorpej short sc_cur_link;
203 1.1.6.2 thorpej
204 1.1.6.2 thorpej /* Interrupt registers */
205 1.1.6.2 thorpej u_char sc_status;
206 1.1.6.2 thorpej u_char sc_interrupt;
207 1.1.6.2 thorpej u_char sc_resel[2];
208 1.1.6.2 thorpej
209 1.1.6.2 thorpej u_char sc_units_disconnected;
210 1.1.6.2 thorpej
211 1.1.6.2 thorpej /* Storage for FAS216 config registers (current values) */
212 1.1.6.2 thorpej u_char sc_config1;
213 1.1.6.2 thorpej u_char sc_config2;
214 1.1.6.2 thorpej u_char sc_config3;
215 1.1.6.2 thorpej u_char sc_config4;
216 1.1.6.2 thorpej u_char sc_clock_conv_fact;
217 1.1.6.2 thorpej u_char sc_timeout_val;
218 1.1.6.2 thorpej u_char sc_clock_period;
219 1.1.6.2 thorpej
220 1.1.6.2 thorpej u_char sc_msg_in[7];
221 1.1.6.2 thorpej u_char sc_msg_in_len;
222 1.1.6.2 thorpej
223 1.1.6.2 thorpej u_char sc_msg_out[7];
224 1.1.6.2 thorpej u_char sc_msg_out_len;
225 1.1.6.2 thorpej
226 1.1.6.2 thorpej u_char sc_unit;
227 1.1.6.2 thorpej u_char sc_lun;
228 1.1.6.2 thorpej u_char sc_flags;
229 1.1.6.2 thorpej };
230 1.1.6.2 thorpej
231 1.1.6.2 thorpej #define ESC_DMA_READ 0
232 1.1.6.2 thorpej #define ESC_DMA_WRITE 1
233 1.1.6.2 thorpej #define ESC_DMA_CLEAR 2
234 1.1.6.2 thorpej
235 1.1.6.2 thorpej /* sc_flags */
236 1.1.6.2 thorpej #define ESC_ACTIVE 0x01
237 1.1.6.2 thorpej #define ESC_DONT_WAIT 0x02
238 1.1.6.2 thorpej
239 1.1.6.2 thorpej /* SCSI Selection modes */
240 1.1.6.2 thorpej #define ESC_SELECT 0x00 /* Normal selection: No sync, no resel */
241 1.1.6.2 thorpej #define ESC_SELECT_R 0x01 /* Reselection allowed */
242 1.1.6.2 thorpej #define ESC_SELECT_S 0x02 /* Synchronous transfer allowed */
243 1.1.6.2 thorpej #define ESC_SELECT_I 0x04 /* Selection for escicmd */
244 1.1.6.2 thorpej #define ESC_SELECT_K 0x08 /* Send a BUS DEVICE RESET message (Kill) */
245 1.1.6.2 thorpej
246 1.1.6.2 thorpej /* Nice abbreviations of the above */
247 1.1.6.2 thorpej #define ESC_SELECT_RS (ESC_SELECT_R|ESC_SELECT_S)
248 1.1.6.2 thorpej #define ESC_SELECT_RI (ESC_SELECT_R|ESC_SELECT_I)
249 1.1.6.2 thorpej #define ESC_SELECT_SI (ESC_SELECT_S|ESC_SELECT_I)
250 1.1.6.2 thorpej #define ESC_SELECT_RSI (ESC_SELECT_R|ESC_SELECT_S|ESC_SELECT_I)
251 1.1.6.2 thorpej
252 1.1.6.2 thorpej /* sc_config_flags */
253 1.1.6.2 thorpej #define ESC_NO_SYNCH 0x01 /* Disable synchronous transfer */
254 1.1.6.2 thorpej #define ESC_NO_DMA 0x02 /* Do not use DMA! EVER! */
255 1.1.6.2 thorpej #define ESC_NO_RESELECT 0x04 /* Do not allow relesection */
256 1.1.6.2 thorpej #define ESC_SLOW_CABLE 0x08 /* Cable is "unsafe" for fast scsi-2 */
257 1.1.6.2 thorpej #define ESC_SLOW_START 0x10 /* There are slow starters on the bus */
258 1.1.6.2 thorpej
259 1.1.6.2 thorpej void escinitialize __P((struct esc_softc *sc));
260 1.1.6.2 thorpej void esc_minphys __P((struct buf *bp));
261 1.1.6.2 thorpej void esc_scsi_request __P((struct scsipi_channel *,
262 1.1.6.2 thorpej scsipi_adapter_req_t, void *));
263 1.1.6.2 thorpej void escintr __P((struct esc_softc *dev));
264 1.1.6.2 thorpej
265 1.1.6.2 thorpej #endif /* _ESCVAR_H_ */
266