umass_scsipi.c revision 1.1 1 /* $NetBSD: umass_scsipi.c,v 1.1 2001/12/24 13:25:52 augustss Exp $ */
2
3 /*
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart (at) augustsson.net) at
9 * Carlstedt Research & Technology.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 #include <sys/cdefs.h>
41 __KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.1 2001/12/24 13:25:52 augustss Exp $");
42
43 #include "atapibus.h"
44 #include "scsibus.h"
45
46 #include <sys/param.h>
47 #include <sys/systm.h>
48 #include <sys/kernel.h>
49 #include <sys/conf.h>
50 #include <sys/buf.h>
51 #include <sys/device.h>
52 #include <sys/ioctl.h>
53 #include <sys/malloc.h>
54
55 /* SCSI & ATAPI */
56 #include <sys/scsiio.h>
57 #include <dev/scsipi/scsi_all.h>
58 #include <dev/scsipi/scsipi_all.h>
59 #include <dev/scsipi/scsiconf.h>
60
61 #include <dev/scsipi/atapiconf.h>
62
63 #include <dev/scsipi/scsipi_disk.h>
64 #include <dev/scsipi/scsi_disk.h>
65 #include <dev/scsipi/scsi_changer.h>
66
67 #include <dev/scsipi/atapi_disk.h>
68
69 #include <sys/disk.h> /* XXX */
70 #include <dev/scsipi/sdvar.h> /* XXX */
71
72 /* USB */
73 #include <dev/usb/usb.h>
74 #include <dev/usb/usbdi.h>
75 #include <dev/usb/usbdi_util.h>
76 #include <dev/usb/usbdevs.h>
77
78 #include <dev/usb/umassvar.h>
79 #include <dev/usb/umass_scsipi.h>
80
81 struct umass_scsipi_softc {
82 struct umassbus_softc base;
83
84 struct atapi_adapter sc_atapi_adapter;
85 #define sc_adapter sc_atapi_adapter._generic
86 struct scsipi_channel sc_channel;
87 usbd_status sc_sync_status;
88 struct scsipi_sense sc_sense_cmd;
89 };
90
91
92 #define SHORT_INQUIRY_LENGTH 36 /* XXX */
93
94 #define UMASS_SCSIID_HOST 0x00
95 #define UMASS_SCSIID_DEVICE 0x01
96
97 #define UMASS_ATAPI_DRIVE 0
98
99 Static void umass_scsipi_request(struct scsipi_channel *,
100 scsipi_adapter_req_t, void *);
101 Static void umass_scsipi_minphys(struct buf *bp);
102 Static int umass_scsipi_ioctl(struct scsipi_channel *, u_long,
103 caddr_t, int, struct proc *);
104 Static int umass_scsipi_getgeom(struct scsipi_periph *periph,
105 struct disk_parms *, u_long sectors);
106
107 Static void umass_scsipi_cb(struct umass_softc *sc, void *priv,
108 int residue, int status);
109 Static void umass_scsipi_sense_cb(struct umass_softc *sc, void *priv,
110 int residue, int status);
111
112 Static struct umass_scsipi_softc *umass_scsipi_setup(struct umass_softc *sc);
113
114 Static int scsipiprint(void *aux, const char *pnp);
115
116 #if NATAPIBUS > 0
117 Static void umass_atapi_probe_device(struct atapibus_softc *, int);
118
119 const struct scsipi_bustype umass_atapi_bustype = {
120 SCSIPI_BUSTYPE_ATAPI,
121 atapi_scsipi_cmd,
122 atapi_interpret_sense,
123 atapi_print_addr,
124 scsi_kill_pending,
125 };
126 #endif
127
128
129 #if NSCSIBUS > 0
130 int
131 umass_scsi_attach(struct umass_softc *sc)
132 {
133 struct umass_scsipi_softc *scbus;
134
135 scbus = umass_scsipi_setup(sc);
136
137 scbus->sc_channel.chan_bustype = &scsi_bustype;
138 scbus->sc_channel.chan_ntargets = UMASS_SCSIID_DEVICE + 1;
139 scbus->sc_channel.chan_nluns = sc->maxlun + 1;
140 scbus->sc_channel.chan_id = UMASS_SCSIID_HOST;
141 DPRINTF(UDMASS_USB, ("%s: umass_attach_bus: SCSI\n",
142 USBDEVNAME(sc->sc_dev)));
143 scbus->base.sc_child =
144 config_found(&sc->sc_dev, &scbus->sc_channel, scsipiprint);
145
146 return (0);
147 }
148 #endif
149
150 #if NATAPIBUS > 0
151 int
152 umass_atapi_attach(struct umass_softc *sc)
153 {
154 struct umass_scsipi_softc *scbus;
155
156 scbus = umass_scsipi_setup(sc);
157 scbus->sc_atapi_adapter.atapi_probe_device = umass_atapi_probe_device;
158
159 scbus->sc_channel.chan_bustype = &umass_atapi_bustype;
160 scbus->sc_channel.chan_ntargets = 2;
161 scbus->sc_channel.chan_nluns = 1;
162
163 if (sc->sc_quirks & UMASS_QUIRK_NO_TEST_UNIT_READY)
164 scbus->sc_channel.chan_defquirks |= PQUIRK_NOTUR;
165 if (sc->sc_quirks & UMASS_QUIRK_NO_REQUEST_SENSE)
166 scbus->sc_channel.chan_defquirks |= PQUIRK_NOSENSE;
167 DPRINTF(UDMASS_USB, ("%s: umass_attach_bus: ATAPI\n",
168 USBDEVNAME(sc->sc_dev)));
169 scbus->base.sc_child =
170 config_found(&sc->sc_dev, &scbus->sc_channel, scsipiprint);
171
172 return (0);
173 }
174 #endif
175
176 Static struct umass_scsipi_softc *
177 umass_scsipi_setup(struct umass_softc *sc)
178 {
179 struct umass_scsipi_softc *scbus;
180
181 scbus = malloc(sizeof *scbus, M_DEVBUF, M_WAITOK | M_ZERO);
182 sc->bus = &scbus->base;
183
184 /* Fill in the adapter. */
185 memset(&scbus->sc_adapter, 0, sizeof(scbus->sc_adapter));
186 scbus->sc_adapter.adapt_dev = &sc->sc_dev;
187 scbus->sc_adapter.adapt_nchannels = 1;
188 scbus->sc_adapter.adapt_request = umass_scsipi_request;
189 scbus->sc_adapter.adapt_minphys = umass_scsipi_minphys;
190 scbus->sc_adapter.adapt_ioctl = umass_scsipi_ioctl;
191 scbus->sc_adapter.adapt_getgeom = umass_scsipi_getgeom;
192
193 /* Fill in the channel. */
194 memset(&scbus->sc_channel, 0, sizeof(scbus->sc_channel));
195 scbus->sc_channel.chan_adapter = &scbus->sc_adapter;
196 scbus->sc_channel.chan_channel = 0;
197 scbus->sc_channel.chan_flags = SCSIPI_CHAN_OPENINGS;
198 scbus->sc_channel.chan_openings = 1;
199 scbus->sc_channel.chan_max_periph = 1;
200
201 return (scbus);
202 }
203
204 Static int
205 scsipiprint(void *aux, const char *pnp)
206 {
207 struct scsipi_channel *chan = aux;
208
209 if (chan->chan_bustype->bustype_type == SCSIPI_BUSTYPE_SCSI) {
210 #if NSCSIBUS > 0
211 return (scsiprint(aux, pnp));
212 #else
213 if (pnp)
214 printf("scsibus at %s", pnp);
215 return (UNCONF);
216 #endif
217 } else {
218 #if NATAPIBUS > 0
219 return (atapiprint(aux, pnp));
220 #else
221 if (pnp)
222 printf("atapibus at %s", pnp);
223 return (UNCONF);
224 #endif
225 }
226 }
227
228 Static void
229 umass_scsipi_request(struct scsipi_channel *chan,
230 scsipi_adapter_req_t req, void *arg)
231 {
232 struct scsipi_adapter *adapt = chan->chan_adapter;
233 struct scsipi_periph *periph;
234 struct scsipi_xfer *xs;
235 struct umass_softc *sc = (void *)adapt->adapt_dev;
236 struct umass_scsipi_softc *scbus = (struct umass_scsipi_softc *)sc->bus;
237 struct scsipi_generic *cmd, trcmd;
238 int cmdlen;
239 int dir;
240 #ifdef UMASS_DEBUG
241 microtime(&sc->tv);
242 #endif
243 switch(req) {
244 case ADAPTER_REQ_RUN_XFER:
245 xs = arg;
246 periph = xs->xs_periph;
247 DIF(UDMASS_UPPER, periph->periph_dbflags |= SCSIPI_DEBUG_FLAGS);
248
249 DPRINTF(UDMASS_CMD, ("%s: umass_scsi_cmd: at %lu.%06lu: %d:%d "
250 "xs=%p cmd=0x%02x datalen=%d (quirks=0x%x, poll=%d)\n",
251 USBDEVNAME(sc->sc_dev), sc->tv.tv_sec, sc->tv.tv_usec,
252 periph->periph_target, periph->periph_lun,
253 xs, xs->cmd->opcode, xs->datalen,
254 periph->periph_quirks, xs->xs_control & XS_CTL_POLL));
255 #if defined(USB_DEBUG) && defined(SCSIPI_DEBUG)
256 if (umassdebug & UDMASS_SCSI)
257 show_scsipi_xs(xs);
258 else if (umassdebug & ~UDMASS_CMD)
259 show_scsipi_cmd(xs);
260 #endif
261
262 if (sc->sc_dying) {
263 xs->error = XS_DRIVER_STUFFUP;
264 goto done;
265 }
266
267 #ifdef UMASS_DEBUG
268 if (chan->chan_bustype->bustype_type == SCSIPI_BUSTYPE_ATAPI ?
269 periph->periph_target != UMASS_ATAPI_DRIVE :
270 periph->periph_target != UMASS_SCSIID_DEVICE) {
271 DPRINTF(UDMASS_SCSI, ("%s: wrong SCSI ID %d\n",
272 USBDEVNAME(sc->sc_dev),
273 periph->periph_target));
274 xs->error = XS_DRIVER_STUFFUP;
275 goto done;
276 }
277 #endif
278
279 cmd = xs->cmd;
280 cmdlen = xs->cmdlen;
281
282 /* XXX should use transform */
283
284 if (cmd->opcode == START_STOP &&
285 (sc->sc_quirks & UMASS_QUIRK_NO_START_STOP)) {
286 /*printf("%s: START_STOP\n", USBDEVNAME(sc->sc_dev));*/
287 xs->error = XS_NOERROR;
288 goto done;
289 }
290
291 if (cmd->opcode == INQUIRY &&
292 (sc->sc_quirks & UMASS_QUIRK_FORCE_SHORT_INQUIRY)) {
293 /*
294 * some drives wedge when asked for full inquiry
295 * information.
296 */
297 memcpy(&trcmd, cmd, sizeof trcmd);
298 trcmd.bytes[4] = SHORT_INQUIRY_LENGTH;
299 cmd = &trcmd;
300 }
301
302 dir = DIR_NONE;
303 if (xs->datalen) {
304 switch (xs->xs_control &
305 (XS_CTL_DATA_IN | XS_CTL_DATA_OUT)) {
306 case XS_CTL_DATA_IN:
307 dir = DIR_IN;
308 break;
309 case XS_CTL_DATA_OUT:
310 dir = DIR_OUT;
311 break;
312 }
313 }
314
315 if (xs->datalen > UMASS_MAX_TRANSFER_SIZE) {
316 printf("umass_cmd: large datalen, %d\n", xs->datalen);
317 xs->error = XS_DRIVER_STUFFUP;
318 goto done;
319 }
320
321 if (xs->xs_control & XS_CTL_POLL) {
322 /* Use sync transfer. XXX Broken! */
323 DPRINTF(UDMASS_SCSI,
324 ("umass_scsi_cmd: sync dir=%d\n", dir));
325 sc->sc_xfer_flags = USBD_SYNCHRONOUS;
326 scbus->sc_sync_status = USBD_INVAL;
327 sc->sc_methods->wire_xfer(sc, periph->periph_lun, cmd,
328 cmdlen, xs->data,
329 xs->datalen, dir,
330 xs->timeout, 0, xs);
331 sc->sc_xfer_flags = 0;
332 DPRINTF(UDMASS_SCSI, ("umass_scsi_cmd: done err=%d\n",
333 scbus->sc_sync_status));
334 switch (scbus->sc_sync_status) {
335 case USBD_NORMAL_COMPLETION:
336 xs->error = XS_NOERROR;
337 break;
338 case USBD_TIMEOUT:
339 xs->error = XS_TIMEOUT;
340 break;
341 default:
342 xs->error = XS_DRIVER_STUFFUP;
343 break;
344 }
345 goto done;
346 } else {
347 DPRINTF(UDMASS_SCSI,
348 ("umass_scsi_cmd: async dir=%d, cmdlen=%d"
349 " datalen=%d\n",
350 dir, cmdlen, xs->datalen));
351 sc->sc_methods->wire_xfer(sc, periph->periph_lun, cmd,
352 cmdlen, xs->data,
353 xs->datalen, dir,
354 xs->timeout,
355 umass_scsipi_cb, xs);
356 return;
357 }
358
359 /* Return if command finishes early. */
360 done:
361 scsipi_done(xs);
362 return;
363 default:
364 /* Not supported, nothing to do. */
365 ;
366 }
367 }
368
369 Static void
370 umass_scsipi_minphys(struct buf *bp)
371 {
372 #ifdef DIAGNOSTIC
373 if (bp->b_bcount <= 0) {
374 printf("umass_scsipi_minphys count(%ld) <= 0\n",
375 bp->b_bcount);
376 bp->b_bcount = UMASS_MAX_TRANSFER_SIZE;
377 }
378 #endif
379 if (bp->b_bcount > UMASS_MAX_TRANSFER_SIZE)
380 bp->b_bcount = UMASS_MAX_TRANSFER_SIZE;
381 minphys(bp);
382 }
383
384 int
385 umass_scsipi_ioctl(struct scsipi_channel *chan, u_long cmd, caddr_t arg,
386 int flag, struct proc *p)
387 {
388 /*struct umass_softc *sc = link->adapter_softc;*/
389 /*struct umass_scsipi_softc *scbus = sc->bus;*/
390
391 switch (cmd) {
392 #if 0
393 case SCBUSIORESET:
394 ccb->ccb_h.status = CAM_REQ_INPROG;
395 umass_reset(sc, umass_cam_cb, (void *) ccb);
396 return (0);
397 #endif
398 default:
399 return (ENOTTY);
400 }
401 }
402
403 Static int
404 umass_scsipi_getgeom(struct scsipi_periph *periph, struct disk_parms *dp,
405 u_long sectors)
406 {
407 struct umass_softc *sc =
408 (void *)periph->periph_channel->chan_adapter->adapt_dev;
409
410 /* If it's not a floppy, we don't know what to do. */
411 if (sc->sc_cmd != UMASS_CPROTO_UFI)
412 return (0);
413
414 switch (sectors) {
415 case 1440:
416 /* Most likely a single density 3.5" floppy. */
417 dp->heads = 2;
418 dp->sectors = 9;
419 dp->cyls = 80;
420 return (1);
421 case 2880:
422 /* Most likely a double density 3.5" floppy. */
423 dp->heads = 2;
424 dp->sectors = 18;
425 dp->cyls = 80;
426 return (1);
427 default:
428 return (0);
429 }
430 }
431
432 Static void
433 umass_scsipi_cb(struct umass_softc *sc, void *priv, int residue, int status)
434 {
435 struct umass_scsipi_softc *scbus = (struct umass_scsipi_softc *)sc->bus;
436 struct scsipi_xfer *xs = priv;
437 struct scsipi_periph *periph = xs->xs_periph;
438 int cmdlen;
439 int s;
440 #ifdef UMASS_DEBUG
441 struct timeval tv;
442 u_int delta;
443 microtime(&tv);
444 delta = (tv.tv_sec - sc->tv.tv_sec) * 1000000 + tv.tv_usec - sc->tv.tv_usec;
445 #endif
446
447 DPRINTF(UDMASS_CMD,("umass_scsipi_cb: at %lu.%06lu, delta=%u: xs=%p residue=%d"
448 " status=%d\n", tv.tv_sec, tv.tv_usec, delta, xs, residue, status));
449
450 xs->resid = residue;
451
452 switch (status) {
453 case STATUS_CMD_OK:
454 xs->error = XS_NOERROR;
455 break;
456
457 case STATUS_CMD_UNKNOWN:
458 /* we can't issue REQUEST SENSE */
459 if (xs->xs_periph->periph_quirks & PQUIRK_NOSENSE) {
460 /*
461 * If no residue and no other USB error,
462 * command succeeded.
463 */
464 if (residue == 0) {
465 xs->error = XS_NOERROR;
466 break;
467 }
468
469 /*
470 * Some devices return a short INQUIRY
471 * response, omitting response data from the
472 * "vendor specific data" on...
473 */
474 if (xs->cmd->opcode == INQUIRY &&
475 residue < xs->datalen) {
476 xs->error = XS_NOERROR;
477 break;
478 }
479
480 xs->error = XS_DRIVER_STUFFUP;
481 break;
482 }
483 /* FALLTHROUGH */
484 case STATUS_CMD_FAILED:
485 /* fetch sense data */
486 memset(&scbus->sc_sense_cmd, 0, sizeof(scbus->sc_sense_cmd));
487 scbus->sc_sense_cmd.opcode = REQUEST_SENSE;
488 scbus->sc_sense_cmd.byte2 = periph->periph_lun <<
489 SCSI_CMD_LUN_SHIFT;
490 scbus->sc_sense_cmd.length = sizeof(xs->sense);
491
492 cmdlen = sizeof(scbus->sc_sense_cmd);
493 if (sc->sc_cmd == UMASS_CPROTO_UFI) /* XXX */
494 cmdlen = UFI_COMMAND_LENGTH;
495 sc->sc_methods->wire_xfer(sc, periph->periph_lun,
496 &scbus->sc_sense_cmd, cmdlen,
497 &xs->sense, sizeof(xs->sense),
498 DIR_IN, xs->timeout,
499 umass_scsipi_sense_cb, xs);
500 return;
501
502 case STATUS_WIRE_FAILED:
503 xs->error = XS_RESET;
504 break;
505
506 default:
507 panic("%s: Unknown status %d in umass_scsipi_cb\n",
508 USBDEVNAME(sc->sc_dev), status);
509 }
510
511 DPRINTF(UDMASS_CMD,("umass_scsipi_cb: at %lu.%06lu: return xs->error="
512 "%d, xs->xs_status=0x%x xs->resid=%d\n",
513 tv.tv_sec, tv.tv_usec,
514 xs->error, xs->xs_status, xs->resid));
515
516 s = splbio();
517 scsipi_done(xs);
518 splx(s);
519 }
520
521 /*
522 * Finalise a completed autosense operation
523 */
524 Static void
525 umass_scsipi_sense_cb(struct umass_softc *sc, void *priv, int residue,
526 int status)
527 {
528 struct scsipi_xfer *xs = priv;
529 int s;
530
531 DPRINTF(UDMASS_CMD,("umass_scsipi_sense_cb: xs=%p residue=%d "
532 "status=%d\n", xs, residue, status));
533
534 switch (status) {
535 case STATUS_CMD_OK:
536 case STATUS_CMD_UNKNOWN:
537 /* getting sense data succeeded */
538 if (xs->cmd->opcode == INQUIRY && (xs->resid < xs->datalen ||
539 (sc->sc_quirks & UMASS_QUIRK_RS_NO_CLEAR_UA /* XXX */))) {
540 /*
541 * Some drivers return SENSE errors even after INQUIRY.
542 * The upper layer doesn't like that.
543 */
544 xs->error = XS_NOERROR;
545 break;
546 }
547 /* XXX look at residue */
548 if (residue == 0 || residue == 14)/* XXX */
549 xs->error = XS_SENSE;
550 else
551 xs->error = XS_SHORTSENSE;
552 break;
553 default:
554 DPRINTF(UDMASS_SCSI, ("%s: Autosense failed, status %d\n",
555 USBDEVNAME(sc->sc_dev), status));
556 xs->error = XS_DRIVER_STUFFUP;
557 break;
558 }
559
560 xs->xs_status |= XS_STS_DONE;
561
562 DPRINTF(UDMASS_CMD,("umass_scsipi_sense_cb: return xs->error=%d, "
563 "xs->xs_status=0x%x xs->resid=%d\n", xs->error, xs->xs_status,
564 xs->resid));
565
566 s = splbio();
567 scsipi_done(xs);
568 splx(s);
569 }
570
571 #if NATAPIBUS > 0
572 Static void
573 umass_atapi_probe_device(struct atapibus_softc *atapi, int target)
574 {
575 struct scsipi_channel *chan = atapi->sc_channel;
576 struct scsipi_periph *periph;
577 struct scsipibus_attach_args sa;
578 char vendor[33], product[65], revision[17];
579 struct scsipi_inquiry_data inqbuf;
580
581 DPRINTF(UDMASS_SCSI,("umass_atapi_probe_device: atapi=%p target=%d\n",
582 atapi, target));
583
584 if (target != UMASS_ATAPI_DRIVE) /* only probe drive 0 */
585 return;
586
587 /* skip if already attached */
588 if (scsipi_lookup_periph(chan, target, 0) != NULL)
589 return;
590
591 periph = scsipi_alloc_periph(M_NOWAIT);
592 if (periph == NULL) {
593 printf("%s: can't allocate link for drive %d\n",
594 atapi->sc_dev.dv_xname, target);
595 return;
596 }
597
598 DIF(UDMASS_UPPER, periph->periph_dbflags |= 1); /* XXX 1 */
599 periph->periph_channel = chan;
600 periph->periph_switch = &atapi_probe_periphsw;
601 periph->periph_target = target;
602 periph->periph_quirks = chan->chan_defquirks;
603
604 DPRINTF(UDMASS_SCSI, ("umass_atapi_probe_device: doing inquiry\n"));
605 /* Now go ask the device all about itself. */
606 memset(&inqbuf, 0, sizeof(inqbuf));
607 if (scsipi_inquire(periph, &inqbuf,
608 XS_CTL_DISCOVERY | XS_CTL_DATA_ONSTACK) != 0) {
609 DPRINTF(UDMASS_SCSI, ("umass_atapi_probe_device: "
610 "scsipi_inquire failed\n"));
611 free(periph, M_DEVBUF);
612 return;
613 }
614
615 scsipi_strvis(vendor, 33, inqbuf.vendor, 8);
616 scsipi_strvis(product, 65, inqbuf.product, 16);
617 scsipi_strvis(revision, 17, inqbuf.revision, 4);
618
619 sa.sa_periph = periph;
620 sa.sa_inqbuf.type = inqbuf.device;
621 sa.sa_inqbuf.removable = inqbuf.dev_qual2 & SID_REMOVABLE ?
622 T_REMOV : T_FIXED;
623 if (sa.sa_inqbuf.removable)
624 periph->periph_flags |= PERIPH_REMOVABLE;
625 sa.sa_inqbuf.vendor = vendor;
626 sa.sa_inqbuf.product = product;
627 sa.sa_inqbuf.revision = revision;
628 sa.sa_inqptr = NULL;
629
630 DPRINTF(UDMASS_SCSI, ("umass_atapi_probedev: doing atapi_probedev on "
631 "'%s' '%s' '%s'\n", vendor, product, revision));
632 atapi_probe_device(atapi, target, periph, &sa);
633 /* atapi_probe_device() frees the periph when there is no device.*/
634 }
635 #endif
636