scsi.c revision 1.2.6.2 1 1.2.6.2 wiz /* $NetBSD: scsi.c,v 1.2.6.2 2001/08/20 12:20:06 wiz Exp $ */
2 1.2.6.2 wiz
3 1.2.6.2 wiz /*
4 1.2.6.2 wiz * This is reported to fix some odd failures when disklabeling
5 1.2.6.2 wiz * SCSI disks in SYS_INST.
6 1.2.6.2 wiz */
7 1.2.6.2 wiz #define SLOWSCSI
8 1.2.6.2 wiz
9 1.2.6.2 wiz /*
10 1.2.6.2 wiz * Copyright (c) 1988 University of Utah.
11 1.2.6.2 wiz * Copyright (c) 1990, 1993
12 1.2.6.2 wiz * The Regents of the University of California. All rights reserved.
13 1.2.6.2 wiz *
14 1.2.6.2 wiz * This code is derived from software contributed to Berkeley by
15 1.2.6.2 wiz * Van Jacobson of Lawrence Berkeley Laboratory and the Systems
16 1.2.6.2 wiz * Programming Group of the University of Utah Computer Science Department.
17 1.2.6.2 wiz *
18 1.2.6.2 wiz * Redistribution and use in source and binary forms, with or without
19 1.2.6.2 wiz * modification, are permitted provided that the following conditions
20 1.2.6.2 wiz * are met:
21 1.2.6.2 wiz * 1. Redistributions of source code must retain the above copyright
22 1.2.6.2 wiz * notice, this list of conditions and the following disclaimer.
23 1.2.6.2 wiz * 2. Redistributions in binary form must reproduce the above copyright
24 1.2.6.2 wiz * notice, this list of conditions and the following disclaimer in the
25 1.2.6.2 wiz * documentation and/or other materials provided with the distribution.
26 1.2.6.2 wiz * 3. All advertising materials mentioning features or use of this software
27 1.2.6.2 wiz * must display the following acknowledgement:
28 1.2.6.2 wiz * This product includes software developed by the University of
29 1.2.6.2 wiz * California, Berkeley and its contributors.
30 1.2.6.2 wiz * 4. Neither the name of the University nor the names of its contributors
31 1.2.6.2 wiz * may be used to endorse or promote products derived from this software
32 1.2.6.2 wiz * without specific prior written permission.
33 1.2.6.2 wiz *
34 1.2.6.2 wiz * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
35 1.2.6.2 wiz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 1.2.6.2 wiz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 1.2.6.2 wiz * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
38 1.2.6.2 wiz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 1.2.6.2 wiz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40 1.2.6.2 wiz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 1.2.6.2 wiz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42 1.2.6.2 wiz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43 1.2.6.2 wiz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 1.2.6.2 wiz * SUCH DAMAGE.
45 1.2.6.2 wiz *
46 1.2.6.2 wiz * from: Utah $Hdr: scsi.c 1.3 90/01/27$
47 1.2.6.2 wiz *
48 1.2.6.2 wiz * @(#)scsi.c 8.1 (Berkeley) 6/10/93
49 1.2.6.2 wiz */
50 1.2.6.2 wiz
51 1.2.6.2 wiz /*
52 1.2.6.2 wiz * SCSI bus driver for standalone programs.
53 1.2.6.2 wiz */
54 1.2.6.2 wiz
55 1.2.6.2 wiz #include <sys/param.h>
56 1.2.6.2 wiz #include <sys/reboot.h>
57 1.2.6.2 wiz
58 1.2.6.2 wiz #include <lib/libsa/stand.h>
59 1.2.6.2 wiz
60 1.2.6.2 wiz #define _IOCTL_
61 1.2.6.2 wiz #include <hp300/dev/scsireg.h>
62 1.2.6.2 wiz
63 1.2.6.2 wiz #include <hp300/stand/common/device.h>
64 1.2.6.2 wiz #include <hp300/stand/common/scsivar.h>
65 1.2.6.2 wiz #include <hp300/stand/common/samachdep.h>
66 1.2.6.2 wiz
67 1.2.6.2 wiz struct scsi_softc scsi_softc[NSCSI];
68 1.2.6.2 wiz
69 1.2.6.2 wiz void scsireset();
70 1.2.6.2 wiz int scsi_cmd_wait = 50000; /* use the "real" driver init_wait value */
71 1.2.6.2 wiz int scsi_data_wait = 50000; /* use the "real" driver init_wait value */
72 1.2.6.2 wiz
73 1.2.6.2 wiz scsiinit()
74 1.2.6.2 wiz {
75 1.2.6.2 wiz extern struct hp_hw sc_table[];
76 1.2.6.2 wiz register struct hp_hw *hw;
77 1.2.6.2 wiz register struct scsi_softc *hs;
78 1.2.6.2 wiz register int i, addr;
79 1.2.6.2 wiz static int waitset = 0;
80 1.2.6.2 wiz
81 1.2.6.2 wiz i = 0;
82 1.2.6.2 wiz for (hw = sc_table; i < NSCSI && hw < &sc_table[MAXCTLRS]; hw++) {
83 1.2.6.2 wiz if (!HW_ISSCSI(hw))
84 1.2.6.2 wiz continue;
85 1.2.6.2 wiz hs = &scsi_softc[i];
86 1.2.6.2 wiz hs->sc_addr = hw->hw_kva;
87 1.2.6.2 wiz scsireset(i);
88 1.2.6.2 wiz if (howto & RB_ASKNAME)
89 1.2.6.2 wiz printf("scsi%d at sc%d\n", i, hw->hw_sc);
90 1.2.6.2 wiz hw->hw_pa = (caddr_t) i; /* XXX for autoconfig */
91 1.2.6.2 wiz hs->sc_alive = 1;
92 1.2.6.2 wiz i++;
93 1.2.6.2 wiz }
94 1.2.6.2 wiz /*
95 1.2.6.2 wiz * Adjust the wait values
96 1.2.6.2 wiz */
97 1.2.6.2 wiz if (!waitset) {
98 1.2.6.2 wiz scsi_cmd_wait *= cpuspeed;
99 1.2.6.2 wiz scsi_data_wait *= cpuspeed;
100 1.2.6.2 wiz waitset = 1;
101 1.2.6.2 wiz }
102 1.2.6.2 wiz }
103 1.2.6.2 wiz
104 1.2.6.2 wiz scsialive(unit)
105 1.2.6.2 wiz register int unit;
106 1.2.6.2 wiz {
107 1.2.6.2 wiz if (unit >= NSCSI || scsi_softc[unit].sc_alive == 0)
108 1.2.6.2 wiz return (0);
109 1.2.6.2 wiz return (1);
110 1.2.6.2 wiz }
111 1.2.6.2 wiz
112 1.2.6.2 wiz void
113 1.2.6.2 wiz scsireset(unit)
114 1.2.6.2 wiz register int unit;
115 1.2.6.2 wiz {
116 1.2.6.2 wiz volatile register struct scsidevice *hd;
117 1.2.6.2 wiz register struct scsi_softc *hs;
118 1.2.6.2 wiz u_int i;
119 1.2.6.2 wiz
120 1.2.6.2 wiz hs = &scsi_softc[unit];
121 1.2.6.2 wiz hd = (struct scsidevice *)hs->sc_addr;
122 1.2.6.2 wiz hd->scsi_id = 0xFF;
123 1.2.6.2 wiz DELAY(100);
124 1.2.6.2 wiz /*
125 1.2.6.2 wiz * Disable interrupts then reset the FUJI chip.
126 1.2.6.2 wiz */
127 1.2.6.2 wiz hd->scsi_csr = 0;
128 1.2.6.2 wiz hd->scsi_sctl = SCTL_DISABLE | SCTL_CTRLRST;
129 1.2.6.2 wiz hd->scsi_scmd = 0;
130 1.2.6.2 wiz hd->scsi_tmod = 0;
131 1.2.6.2 wiz hd->scsi_pctl = 0;
132 1.2.6.2 wiz hd->scsi_temp = 0;
133 1.2.6.2 wiz hd->scsi_tch = 0;
134 1.2.6.2 wiz hd->scsi_tcm = 0;
135 1.2.6.2 wiz hd->scsi_tcl = 0;
136 1.2.6.2 wiz hd->scsi_ints = 0;
137 1.2.6.2 wiz
138 1.2.6.2 wiz /*
139 1.2.6.2 wiz * Configure the FUJI chip with its SCSI address, all
140 1.2.6.2 wiz * interrupts enabled & appropriate parity.
141 1.2.6.2 wiz */
142 1.2.6.2 wiz i = (~hd->scsi_hconf) & 0x7;
143 1.2.6.2 wiz hs->sc_scsi_addr = 1 << i;
144 1.2.6.2 wiz hd->scsi_bdid = i;
145 1.2.6.2 wiz if (hd->scsi_hconf & HCONF_PARITY)
146 1.2.6.2 wiz hd->scsi_sctl = SCTL_DISABLE | SCTL_ABRT_ENAB |
147 1.2.6.2 wiz SCTL_SEL_ENAB | SCTL_RESEL_ENAB |
148 1.2.6.2 wiz SCTL_INTR_ENAB | SCTL_PARITY_ENAB;
149 1.2.6.2 wiz else
150 1.2.6.2 wiz hd->scsi_sctl = SCTL_DISABLE | SCTL_ABRT_ENAB |
151 1.2.6.2 wiz SCTL_SEL_ENAB | SCTL_RESEL_ENAB |
152 1.2.6.2 wiz SCTL_INTR_ENAB;
153 1.2.6.2 wiz hd->scsi_sctl &=~ SCTL_DISABLE;
154 1.2.6.2 wiz }
155 1.2.6.2 wiz
156 1.2.6.2 wiz
157 1.2.6.2 wiz int
158 1.2.6.2 wiz scsiabort(hs, hd)
159 1.2.6.2 wiz register struct scsi_softc *hs;
160 1.2.6.2 wiz volatile register struct scsidevice *hd;
161 1.2.6.2 wiz {
162 1.2.6.2 wiz printf("scsi%d error: scsiabort\n", hs - scsi_softc);
163 1.2.6.2 wiz
164 1.2.6.2 wiz scsireset(hs - scsi_softc);
165 1.2.6.2 wiz DELAY(1000000);
166 1.2.6.2 wiz }
167 1.2.6.2 wiz
168 1.2.6.2 wiz static int
169 1.2.6.2 wiz issue_select(hd, target, our_addr)
170 1.2.6.2 wiz volatile register struct scsidevice *hd;
171 1.2.6.2 wiz u_char target, our_addr;
172 1.2.6.2 wiz {
173 1.2.6.2 wiz if (hd->scsi_ssts & (SSTS_INITIATOR|SSTS_TARGET|SSTS_BUSY))
174 1.2.6.2 wiz return (1);
175 1.2.6.2 wiz
176 1.2.6.2 wiz if (hd->scsi_ints & INTS_DISCON)
177 1.2.6.2 wiz hd->scsi_ints = INTS_DISCON;
178 1.2.6.2 wiz
179 1.2.6.2 wiz hd->scsi_pctl = 0;
180 1.2.6.2 wiz hd->scsi_temp = (1 << target) | our_addr;
181 1.2.6.2 wiz /* select timeout is hardcoded to 2ms */
182 1.2.6.2 wiz hd->scsi_tch = 0;
183 1.2.6.2 wiz hd->scsi_tcm = 32;
184 1.2.6.2 wiz hd->scsi_tcl = 4;
185 1.2.6.2 wiz
186 1.2.6.2 wiz hd->scsi_scmd = SCMD_SELECT;
187 1.2.6.2 wiz return (0);
188 1.2.6.2 wiz }
189 1.2.6.2 wiz
190 1.2.6.2 wiz static int
191 1.2.6.2 wiz wait_for_select(hd)
192 1.2.6.2 wiz volatile register struct scsidevice *hd;
193 1.2.6.2 wiz {
194 1.2.6.2 wiz register int wait;
195 1.2.6.2 wiz u_char ints;
196 1.2.6.2 wiz
197 1.2.6.2 wiz wait = scsi_data_wait;
198 1.2.6.2 wiz while ((ints = hd->scsi_ints) == 0) {
199 1.2.6.2 wiz if (--wait < 0)
200 1.2.6.2 wiz return (1);
201 1.2.6.2 wiz DELAY(1);
202 1.2.6.2 wiz }
203 1.2.6.2 wiz hd->scsi_ints = ints;
204 1.2.6.2 wiz return (!(hd->scsi_ssts & SSTS_INITIATOR));
205 1.2.6.2 wiz }
206 1.2.6.2 wiz
207 1.2.6.2 wiz static int
208 1.2.6.2 wiz ixfer_start(hd, len, phase, wait)
209 1.2.6.2 wiz volatile register struct scsidevice *hd;
210 1.2.6.2 wiz int len;
211 1.2.6.2 wiz u_char phase;
212 1.2.6.2 wiz register int wait;
213 1.2.6.2 wiz {
214 1.2.6.2 wiz
215 1.2.6.2 wiz hd->scsi_tch = len >> 16;
216 1.2.6.2 wiz hd->scsi_tcm = len >> 8;
217 1.2.6.2 wiz hd->scsi_tcl = len;
218 1.2.6.2 wiz hd->scsi_pctl = phase;
219 1.2.6.2 wiz hd->scsi_tmod = 0; /*XXX*/
220 1.2.6.2 wiz hd->scsi_scmd = SCMD_XFR | SCMD_PROG_XFR;
221 1.2.6.2 wiz
222 1.2.6.2 wiz /* wait for xfer to start or svc_req interrupt */
223 1.2.6.2 wiz while ((hd->scsi_ssts & SSTS_BUSY) == 0) {
224 1.2.6.2 wiz if (hd->scsi_ints || --wait < 0)
225 1.2.6.2 wiz return (0);
226 1.2.6.2 wiz DELAY(1);
227 1.2.6.2 wiz }
228 1.2.6.2 wiz return (1);
229 1.2.6.2 wiz }
230 1.2.6.2 wiz
231 1.2.6.2 wiz static int
232 1.2.6.2 wiz ixfer_out(hd, len, buf)
233 1.2.6.2 wiz volatile register struct scsidevice *hd;
234 1.2.6.2 wiz int len;
235 1.2.6.2 wiz register u_char *buf;
236 1.2.6.2 wiz {
237 1.2.6.2 wiz register int wait = scsi_data_wait;
238 1.2.6.2 wiz
239 1.2.6.2 wiz for (; len > 0; --len) {
240 1.2.6.2 wiz while (hd->scsi_ssts & SSTS_DREG_FULL) {
241 1.2.6.2 wiz if (hd->scsi_ints || --wait < 0)
242 1.2.6.2 wiz return (len);
243 1.2.6.2 wiz DELAY(1);
244 1.2.6.2 wiz }
245 1.2.6.2 wiz hd->scsi_dreg = *buf++;
246 1.2.6.2 wiz }
247 1.2.6.2 wiz return (0);
248 1.2.6.2 wiz }
249 1.2.6.2 wiz
250 1.2.6.2 wiz static int
251 1.2.6.2 wiz ixfer_in(hd, len, buf)
252 1.2.6.2 wiz volatile register struct scsidevice *hd;
253 1.2.6.2 wiz int len;
254 1.2.6.2 wiz register u_char *buf;
255 1.2.6.2 wiz {
256 1.2.6.2 wiz register int wait = scsi_data_wait;
257 1.2.6.2 wiz
258 1.2.6.2 wiz for (; len > 0; --len) {
259 1.2.6.2 wiz while (hd->scsi_ssts & SSTS_DREG_EMPTY) {
260 1.2.6.2 wiz if (hd->scsi_ints || --wait < 0) {
261 1.2.6.2 wiz while (! (hd->scsi_ssts & SSTS_DREG_EMPTY)) {
262 1.2.6.2 wiz *buf++ = hd->scsi_dreg;
263 1.2.6.2 wiz --len;
264 1.2.6.2 wiz }
265 1.2.6.2 wiz return (len);
266 1.2.6.2 wiz }
267 1.2.6.2 wiz DELAY(1);
268 1.2.6.2 wiz }
269 1.2.6.2 wiz *buf++ = hd->scsi_dreg;
270 1.2.6.2 wiz }
271 1.2.6.2 wiz return (len);
272 1.2.6.2 wiz }
273 1.2.6.2 wiz
274 1.2.6.2 wiz static int
275 1.2.6.2 wiz scsiicmd(hs, target, cbuf, clen, buf, len, xferphase)
276 1.2.6.2 wiz struct scsi_softc *hs;
277 1.2.6.2 wiz int target;
278 1.2.6.2 wiz u_char *cbuf;
279 1.2.6.2 wiz int clen;
280 1.2.6.2 wiz u_char *buf;
281 1.2.6.2 wiz int len;
282 1.2.6.2 wiz u_char xferphase;
283 1.2.6.2 wiz {
284 1.2.6.2 wiz volatile register struct scsidevice *hd =
285 1.2.6.2 wiz (struct scsidevice *)hs->sc_addr;
286 1.2.6.2 wiz u_char phase, ints;
287 1.2.6.2 wiz register int wait;
288 1.2.6.2 wiz
289 1.2.6.2 wiz /* select the SCSI bus (it's an error if bus isn't free) */
290 1.2.6.2 wiz if (issue_select(hd, target, hs->sc_scsi_addr))
291 1.2.6.2 wiz return (-2);
292 1.2.6.2 wiz if (wait_for_select(hd))
293 1.2.6.2 wiz return (-2);
294 1.2.6.2 wiz /*
295 1.2.6.2 wiz * Wait for a phase change (or error) then let the device
296 1.2.6.2 wiz * sequence us through the various SCSI phases.
297 1.2.6.2 wiz */
298 1.2.6.2 wiz hs->sc_stat = -1;
299 1.2.6.2 wiz phase = CMD_PHASE;
300 1.2.6.2 wiz while (1) {
301 1.2.6.2 wiz wait = scsi_cmd_wait;
302 1.2.6.2 wiz switch (phase) {
303 1.2.6.2 wiz
304 1.2.6.2 wiz case CMD_PHASE:
305 1.2.6.2 wiz if (ixfer_start(hd, clen, phase, wait))
306 1.2.6.2 wiz if (ixfer_out(hd, clen, cbuf))
307 1.2.6.2 wiz goto abort;
308 1.2.6.2 wiz phase = xferphase;
309 1.2.6.2 wiz break;
310 1.2.6.2 wiz
311 1.2.6.2 wiz case DATA_IN_PHASE:
312 1.2.6.2 wiz if (len <= 0)
313 1.2.6.2 wiz goto abort;
314 1.2.6.2 wiz wait = scsi_data_wait;
315 1.2.6.2 wiz if (ixfer_start(hd, len, phase, wait) ||
316 1.2.6.2 wiz !(hd->scsi_ssts & SSTS_DREG_EMPTY))
317 1.2.6.2 wiz ixfer_in(hd, len, buf);
318 1.2.6.2 wiz phase = STATUS_PHASE;
319 1.2.6.2 wiz break;
320 1.2.6.2 wiz
321 1.2.6.2 wiz case DATA_OUT_PHASE:
322 1.2.6.2 wiz if (len <= 0)
323 1.2.6.2 wiz goto abort;
324 1.2.6.2 wiz wait = scsi_data_wait;
325 1.2.6.2 wiz if (ixfer_start(hd, len, phase, wait))
326 1.2.6.2 wiz if (ixfer_out(hd, len, buf))
327 1.2.6.2 wiz goto abort;
328 1.2.6.2 wiz phase = STATUS_PHASE;
329 1.2.6.2 wiz break;
330 1.2.6.2 wiz
331 1.2.6.2 wiz case STATUS_PHASE:
332 1.2.6.2 wiz wait = scsi_data_wait;
333 1.2.6.2 wiz if (ixfer_start(hd, sizeof(hs->sc_stat), phase, wait) ||
334 1.2.6.2 wiz !(hd->scsi_ssts & SSTS_DREG_EMPTY))
335 1.2.6.2 wiz ixfer_in(hd, sizeof(hs->sc_stat), &hs->sc_stat);
336 1.2.6.2 wiz phase = MESG_IN_PHASE;
337 1.2.6.2 wiz break;
338 1.2.6.2 wiz
339 1.2.6.2 wiz case MESG_IN_PHASE:
340 1.2.6.2 wiz if (ixfer_start(hd, sizeof(hs->sc_msg), phase, wait) ||
341 1.2.6.2 wiz !(hd->scsi_ssts & SSTS_DREG_EMPTY)) {
342 1.2.6.2 wiz ixfer_in(hd, sizeof(hs->sc_msg), &hs->sc_msg);
343 1.2.6.2 wiz hd->scsi_scmd = SCMD_RST_ACK;
344 1.2.6.2 wiz }
345 1.2.6.2 wiz phase = BUS_FREE_PHASE;
346 1.2.6.2 wiz break;
347 1.2.6.2 wiz
348 1.2.6.2 wiz case BUS_FREE_PHASE:
349 1.2.6.2 wiz goto out;
350 1.2.6.2 wiz
351 1.2.6.2 wiz default:
352 1.2.6.2 wiz printf("scsi%d: unexpected scsi phase %d\n",
353 1.2.6.2 wiz hs - scsi_softc, phase);
354 1.2.6.2 wiz goto abort;
355 1.2.6.2 wiz }
356 1.2.6.2 wiz #ifdef SLOWSCSI
357 1.2.6.2 wiz /*
358 1.2.6.2 wiz * XXX we have weird transient problems with booting from
359 1.2.6.2 wiz * slow scsi disks on fast machines. I have never been
360 1.2.6.2 wiz * able to pin the problem down, but a large delay here
361 1.2.6.2 wiz * seems to always work.
362 1.2.6.2 wiz */
363 1.2.6.2 wiz DELAY(1000);
364 1.2.6.2 wiz #endif
365 1.2.6.2 wiz /* wait for last command to complete */
366 1.2.6.2 wiz while ((ints = hd->scsi_ints) == 0) {
367 1.2.6.2 wiz if (--wait < 0)
368 1.2.6.2 wiz goto abort;
369 1.2.6.2 wiz DELAY(1);
370 1.2.6.2 wiz }
371 1.2.6.2 wiz hd->scsi_ints = ints;
372 1.2.6.2 wiz if (ints & INTS_SRV_REQ)
373 1.2.6.2 wiz phase = hd->scsi_psns & PHASE;
374 1.2.6.2 wiz else if (ints & INTS_DISCON)
375 1.2.6.2 wiz goto out;
376 1.2.6.2 wiz else if ((ints & INTS_CMD_DONE) == 0)
377 1.2.6.2 wiz goto abort;
378 1.2.6.2 wiz }
379 1.2.6.2 wiz abort:
380 1.2.6.2 wiz scsiabort(hs, hd);
381 1.2.6.2 wiz out:
382 1.2.6.2 wiz return (hs->sc_stat);
383 1.2.6.2 wiz }
384 1.2.6.2 wiz
385 1.2.6.2 wiz int
386 1.2.6.2 wiz scsi_test_unit_rdy(ctlr, slave)
387 1.2.6.2 wiz int ctlr, slave;
388 1.2.6.2 wiz {
389 1.2.6.2 wiz register struct scsi_softc *hs = &scsi_softc[ctlr];
390 1.2.6.2 wiz static struct scsi_cdb6 cdb = { CMD_TEST_UNIT_READY };
391 1.2.6.2 wiz
392 1.2.6.2 wiz return (scsiicmd(hs, slave, &cdb, sizeof(cdb), (u_char *)0, 0,
393 1.2.6.2 wiz STATUS_PHASE));
394 1.2.6.2 wiz }
395 1.2.6.2 wiz
396 1.2.6.2 wiz int
397 1.2.6.2 wiz scsi_request_sense(ctlr, slave, buf, len)
398 1.2.6.2 wiz int ctlr, slave;
399 1.2.6.2 wiz u_char *buf;
400 1.2.6.2 wiz unsigned len;
401 1.2.6.2 wiz {
402 1.2.6.2 wiz register struct scsi_softc *hs = &scsi_softc[ctlr];
403 1.2.6.2 wiz static struct scsi_cdb6 cdb = { CMD_REQUEST_SENSE };
404 1.2.6.2 wiz
405 1.2.6.2 wiz cdb.len = len;
406 1.2.6.2 wiz return (scsiicmd(hs, slave, &cdb, sizeof(cdb), buf, len,
407 1.2.6.2 wiz DATA_IN_PHASE));
408 1.2.6.2 wiz }
409 1.2.6.2 wiz
410 1.2.6.2 wiz int
411 1.2.6.2 wiz scsi_read_capacity(ctlr, slave, buf, len)
412 1.2.6.2 wiz int ctlr, slave;
413 1.2.6.2 wiz u_char *buf;
414 1.2.6.2 wiz unsigned len;
415 1.2.6.2 wiz {
416 1.2.6.2 wiz register struct scsi_softc *hs = &scsi_softc[ctlr];
417 1.2.6.2 wiz static struct scsi_cdb10 cdb = { CMD_READ_CAPACITY };
418 1.2.6.2 wiz
419 1.2.6.2 wiz return (scsiicmd(hs, slave, &cdb, sizeof(cdb), buf, len,
420 1.2.6.2 wiz DATA_IN_PHASE));
421 1.2.6.2 wiz }
422 1.2.6.2 wiz
423 1.2.6.2 wiz int
424 1.2.6.2 wiz scsi_tt_read(ctlr, slave, buf, len, blk, nblk)
425 1.2.6.2 wiz int ctlr, slave;
426 1.2.6.2 wiz u_char *buf;
427 1.2.6.2 wiz u_int len;
428 1.2.6.2 wiz daddr_t blk;
429 1.2.6.2 wiz u_int nblk;
430 1.2.6.2 wiz {
431 1.2.6.2 wiz register struct scsi_softc *hs = &scsi_softc[ctlr];
432 1.2.6.2 wiz struct scsi_cdb10 cdb;
433 1.2.6.2 wiz
434 1.2.6.2 wiz bzero(&cdb, sizeof(cdb));
435 1.2.6.2 wiz cdb.cmd = CMD_READ_EXT;
436 1.2.6.2 wiz cdb.lbah = blk >> 24;
437 1.2.6.2 wiz cdb.lbahm = blk >> 16;
438 1.2.6.2 wiz cdb.lbalm = blk >> 8;
439 1.2.6.2 wiz cdb.lbal = blk;
440 1.2.6.2 wiz cdb.lenh = nblk >> (8 + DEV_BSHIFT);
441 1.2.6.2 wiz cdb.lenl = nblk >> DEV_BSHIFT;
442 1.2.6.2 wiz return (scsiicmd(hs, slave, &cdb, sizeof(cdb), buf, len,
443 1.2.6.2 wiz DATA_IN_PHASE));
444 1.2.6.2 wiz }
445 1.2.6.2 wiz
446 1.2.6.2 wiz int
447 1.2.6.2 wiz scsi_tt_write(ctlr, slave, buf, len, blk, nblk)
448 1.2.6.2 wiz int ctlr, slave;
449 1.2.6.2 wiz u_char *buf;
450 1.2.6.2 wiz u_int len;
451 1.2.6.2 wiz daddr_t blk;
452 1.2.6.2 wiz u_int nblk;
453 1.2.6.2 wiz {
454 1.2.6.2 wiz register struct scsi_softc *hs = &scsi_softc[ctlr];
455 1.2.6.2 wiz struct scsi_cdb10 cdb;
456 1.2.6.2 wiz
457 1.2.6.2 wiz bzero(&cdb, sizeof(cdb));
458 1.2.6.2 wiz cdb.cmd = CMD_WRITE_EXT;
459 1.2.6.2 wiz cdb.lbah = blk >> 24;
460 1.2.6.2 wiz cdb.lbahm = blk >> 16;
461 1.2.6.2 wiz cdb.lbalm = blk >> 8;
462 1.2.6.2 wiz cdb.lbal = blk;
463 1.2.6.2 wiz cdb.lenh = nblk >> (8 + DEV_BSHIFT);
464 1.2.6.2 wiz cdb.lenl = nblk >> DEV_BSHIFT;
465 1.2.6.2 wiz return (scsiicmd(hs, slave, &cdb, sizeof(cdb), buf, len,
466 1.2.6.2 wiz DATA_OUT_PHASE));
467 1.2.6.2 wiz }
468