scsiconf.c revision 1.104 1 /* $NetBSD: scsiconf.c,v 1.104 1998/08/05 16:29:05 drochner Exp $ */
2
3 /*
4 * Copyright (c) 1994 Charles Hannum. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
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.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Charles Hannum.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /*
33 * Originally written by Julian Elischer (julian (at) tfs.com)
34 * for TRW Financial Systems for use under the MACH(2.5) operating system.
35 *
36 * TRW Financial Systems, in accordance with their agreement with Carnegie
37 * Mellon University, makes this software available to CMU to distribute
38 * or use in any manner that they see fit as long as this message is kept with
39 * the software. For this reason TFS also grants any other persons or
40 * organisations permission to use or modify this software.
41 *
42 * TFS supplies this software to be publicly redistributed
43 * on the understanding that TFS is not responsible for the correct
44 * functioning of this software in any circumstances.
45 *
46 * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
47 */
48
49 #include <sys/types.h>
50 #include <sys/param.h>
51 #include <sys/systm.h>
52 #include <sys/malloc.h>
53 #include <sys/device.h>
54
55 #include <dev/scsipi/scsi_all.h>
56 #include <dev/scsipi/scsipi_all.h>
57 #include <dev/scsipi/scsiconf.h>
58
59 #include "locators.h"
60
61 #if 0
62 #if NCALS > 0
63 { T_PROCESSOR, T_FIXED, 1,
64 0, 0, 0 },
65 #endif /* NCALS */
66 #if NBLL > 0
67 { T_PROCESSOR, T_FIXED, 1,
68 "AEG ", "READER ", "V1.0" },
69 #endif /* NBLL */
70 #if NKIL > 0
71 { T_SCANNER, T_FIXED, 0,
72 "KODAK ", "IL Scanner 900 ", 0 },
73 #endif /* NKIL */
74 #endif
75
76 /*
77 * Declarations
78 */
79 void scsi_probedev __P((struct scsibus_softc *, int, int));
80 int scsi_probe_bus __P((int bus, int target, int lun));
81
82 struct scsipi_device probe_switch = {
83 NULL,
84 NULL,
85 NULL,
86 NULL,
87 };
88
89 #ifdef __BROKEN_INDIRECT_CONFIG
90 int scsibusmatch __P((struct device *, void *, void *));
91 #else
92 int scsibusmatch __P((struct device *, struct cfdata *, void *));
93 #endif
94 void scsibusattach __P((struct device *, struct device *, void *));
95 #ifdef __BROKEN_INDIRECT_CONFIG
96 int scsibussubmatch __P((struct device *, void *, void *));
97 #else
98 int scsibussubmatch __P((struct device *, struct cfdata *, void *));
99 #endif
100
101 struct cfattach scsibus_ca = {
102 sizeof(struct scsibus_softc), scsibusmatch, scsibusattach
103 };
104
105 extern struct cfdriver scsibus_cd;
106
107 int scsibusprint __P((void *, const char *));
108
109
110 int
111 scsiprint(aux, pnp)
112 void *aux;
113 const char *pnp;
114 {
115 struct scsipi_link *l = aux;
116
117 /* only "scsibus"es can attach to "scsi"s; easy. */
118 if (pnp)
119 printf("scsibus at %s", pnp);
120
121 /* don't print channel if the controller says there can be only one. */
122 if (l->scsipi_scsi.channel != SCSI_CHANNEL_ONLY_ONE)
123 printf(" channel %d", l->scsipi_scsi.channel);
124
125 return (UNCONF);
126 }
127
128 int
129 #ifdef __BROKEN_INDIRECT_CONFIG
130 scsibusmatch(parent, match, aux)
131 #else
132 scsibusmatch(parent, cf, aux)
133 #endif
134 struct device *parent;
135 #ifdef __BROKEN_INDIRECT_CONFIG
136 void *match;
137 #else
138 struct cfdata *cf;
139 #endif
140 void *aux;
141 {
142 #ifdef __BROKEN_INDIRECT_CONFIG
143 struct cfdata *cf = match;
144 #endif
145 struct scsipi_link *l = aux;
146 int channel;
147
148 /*
149 * Allow single-channel controllers to specify their channel
150 * in a special way, so that it's not printed.
151 */
152 channel = (l->scsipi_scsi.channel != SCSI_CHANNEL_ONLY_ONE) ?
153 l->scsipi_scsi.channel : 0;
154
155 if (cf->cf_loc[SCSICF_CHANNEL] != channel &&
156 cf->cf_loc[SCSICF_CHANNEL] != SCSICF_CHANNEL_DEFAULT)
157 return (0);
158
159 return (1);
160 }
161
162 /*
163 * The routine called by the adapter boards to get all their
164 * devices configured in.
165 */
166 void
167 scsibusattach(parent, self, aux)
168 struct device *parent, *self;
169 void *aux;
170 {
171 struct scsibus_softc *sb = (struct scsibus_softc *)self;
172 struct scsipi_link *sc_link_proto = aux;
173 size_t nbytes;
174 int i;
175
176 sc_link_proto->scsipi_scsi.scsibus = sb->sc_dev.dv_unit;
177 sc_link_proto->scsipi_cmd = scsi_scsipi_cmd;
178 sc_link_proto->scsipi_interpret_sense = scsi_interpret_sense;
179 sc_link_proto->sc_print_addr = scsi_print_addr;
180
181 sb->adapter_link = sc_link_proto;
182 sb->sc_maxtarget = sc_link_proto->scsipi_scsi.max_target;
183 printf(": %d targets\n", sb->sc_maxtarget + 1);
184
185 /* Initialize shared data. */
186 scsipi_init();
187
188 nbytes = sb->sc_maxtarget * sizeof(struct scsipi_link **);
189 sb->sc_link = (struct scsipi_link ***)malloc(nbytes, M_DEVBUF,
190 M_NOWAIT);
191 if (sb->sc_link == NULL)
192 panic("scsibusattach: can't allocate target links");
193
194 nbytes = 8 * sizeof(struct scsipi_link *);
195 for (i = 0; i <= sb->sc_maxtarget; i++) {
196 sb->sc_link[i] = (struct scsipi_link **)malloc(nbytes,
197 M_DEVBUF, M_NOWAIT);
198 if (sb->sc_link[i] == NULL)
199 panic("scsibusattach: can't allocate lun links");
200 bzero(sb->sc_link[i], nbytes);
201 }
202
203 #if defined(SCSI_DELAY) && SCSI_DELAY > 2
204 printf("%s: waiting for scsi devices to settle\n",
205 sb->sc_dev.dv_xname);
206 #else /* SCSI_DELAY > 2 */
207 #undef SCSI_DELAY
208 #define SCSI_DELAY 2
209 #endif /* SCSI_DELAY */
210 delay(1000000 * SCSI_DELAY);
211
212 scsi_probe_bus(sb->sc_dev.dv_unit, -1, -1);
213 }
214
215 int
216 #ifdef __BROKEN_INDIRECT_CONFIG
217 scsibussubmatch(parent, match, aux)
218 #else
219 scsibussubmatch(parent, cf, aux)
220 #endif
221 struct device *parent;
222 #ifdef __BROKEN_INDIRECT_CONFIG
223 void *match;
224 #else
225 struct cfdata *cf;
226 #endif
227 void *aux;
228 {
229 #ifdef __BROKEN_INDIRECT_CONFIG
230 struct cfdata *cf = match;
231 #endif
232 struct scsipibus_attach_args *sa = aux;
233 struct scsipi_link *sc_link = sa->sa_sc_link;
234
235 if (cf->cf_loc[SCSIBUSCF_TARGET] != SCSIBUSCF_TARGET_DEFAULT &&
236 cf->cf_loc[SCSIBUSCF_TARGET] != sc_link->scsipi_scsi.target)
237 return (0);
238 if (cf->cf_loc[SCSIBUSCF_LUN] != SCSIBUSCF_LUN_DEFAULT &&
239 cf->cf_loc[SCSIBUSCF_LUN] != sc_link->scsipi_scsi.lun)
240 return (0);
241 return ((*cf->cf_attach->ca_match)(parent, cf, aux));
242 }
243
244 /*
245 * Probe the requested scsi bus. It must be already set up.
246 * -1 requests all set up scsi busses.
247 * target and lun optionally narrow the search if not -1
248 */
249 int
250 scsi_probe_busses(bus, target, lun)
251 int bus, target, lun;
252 {
253
254 if (bus == -1) {
255 for (bus = 0; bus < scsibus_cd.cd_ndevs; bus++)
256 if (scsibus_cd.cd_devs[bus])
257 scsi_probe_bus(bus, target, lun);
258 return (0);
259 } else
260 return (scsi_probe_bus(bus, target, lun));
261 }
262
263 /*
264 * Probe the requested scsi bus. It must be already set up.
265 * target and lun optionally narrow the search if not -1
266 */
267 int
268 scsi_probe_bus(bus, target, lun)
269 int bus, target, lun;
270 {
271 struct scsibus_softc *scsi;
272 int maxtarget, mintarget, maxlun, minlun;
273 u_int8_t scsi_addr;
274
275 if (bus < 0 || bus >= scsibus_cd.cd_ndevs)
276 return (ENXIO);
277 scsi = scsibus_cd.cd_devs[bus];
278 if (scsi == NULL)
279 return (ENXIO);
280
281 scsi_addr = scsi->adapter_link->scsipi_scsi.adapter_target;
282
283 if (target == -1) {
284 maxtarget = scsi->sc_maxtarget;
285 mintarget = 0;
286 } else {
287 if (target < 0 || target > scsi->sc_maxtarget)
288 return (EINVAL);
289 maxtarget = mintarget = target;
290 }
291
292 if (lun == -1) {
293 maxlun = 7;
294 minlun = 0;
295 } else {
296 if (lun < 0 || lun > 7)
297 return (EINVAL);
298 maxlun = minlun = lun;
299 }
300
301 for (target = mintarget; target <= maxtarget; target++) {
302 if (target == scsi_addr)
303 continue;
304 for (lun = minlun; lun <= maxlun; lun++) {
305 /*
306 * See if there's a device present, and configure it.
307 */
308 scsi_probedev(scsi, target, lun);
309 if ((scsi->moreluns & (1 << target)) == 0)
310 break;
311 /* otherwise something says we should look further */
312 }
313 }
314 return (0);
315 }
316
317 /*
318 * Print out autoconfiguration information for a subdevice.
319 *
320 * This is a slight abuse of 'standard' autoconfiguration semantics,
321 * because 'print' functions don't normally print the colon and
322 * device information. However, in this case that's better than
323 * either printing redundant information before the attach message,
324 * or having the device driver call a special function to print out
325 * the standard device information.
326 */
327 int
328 scsibusprint(aux, pnp)
329 void *aux;
330 const char *pnp;
331 {
332 struct scsipibus_attach_args *sa = aux;
333 struct scsipi_inquiry_pattern *inqbuf;
334 u_int8_t type;
335 char *dtype, *qtype;
336 char vendor[33], product[65], revision[17];
337 int target, lun;
338
339 if (pnp != NULL)
340 printf("%s", pnp);
341
342 inqbuf = &sa->sa_inqbuf;
343
344 target = sa->sa_sc_link->scsipi_scsi.target;
345 lun = sa->sa_sc_link->scsipi_scsi.lun;
346
347 type = inqbuf->type & SID_TYPE;
348
349 /*
350 * Figure out basic device type and qualifier.
351 */
352 dtype = 0;
353 switch (inqbuf->type & SID_QUAL) {
354 case SID_QUAL_LU_OK:
355 qtype = "";
356 break;
357
358 case SID_QUAL_LU_OFFLINE:
359 qtype = " offline";
360 break;
361
362 case SID_QUAL_RSVD:
363 case SID_QUAL_BAD_LU:
364 panic("scsibusprint: impossible qualifier");
365
366 default:
367 qtype = "";
368 dtype = "vendor-unique";
369 break;
370 }
371 if (dtype == 0)
372 dtype = scsipi_dtype(type);
373
374 scsipi_strvis(vendor, 33, inqbuf->vendor, 8);
375 scsipi_strvis(product, 65, inqbuf->product, 16);
376 scsipi_strvis(revision, 17, inqbuf->revision, 4);
377
378 printf(" targ %d lun %d: <%s, %s, %s> SCSI%d %d/%s %s%s",
379 target, lun, vendor, product, revision,
380 sa->scsipi_info.scsi_version & SID_ANSII, type, dtype,
381 inqbuf->removable ? "removable" : "fixed", qtype);
382
383 return (UNCONF);
384 }
385
386 struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
387 {{T_CDROM, T_REMOV,
388 "CHINON ", "CD-ROM CDS-431 ", ""}, SDEV_NOLUNS},
389 {{T_CDROM, T_REMOV,
390 "Chinon ", "CD-ROM CDS-525 ", ""}, SDEV_NOLUNS},
391 {{T_CDROM, T_REMOV,
392 "CHINON ", "CD-ROM CDS-535 ", ""}, SDEV_NOLUNS},
393 {{T_CDROM, T_REMOV,
394 "DEC ", "RRD42 (C) DEC ", ""}, SDEV_NOLUNS},
395 {{T_CDROM, T_REMOV,
396 "DENON ", "DRD-25X ", "V"}, SDEV_NOLUNS},
397 {{T_CDROM, T_REMOV,
398 "HP ", "C4324/C4325 ", ""}, SDEV_NOLUNS},
399 {{T_CDROM, T_REMOV,
400 "IMS ", "CDD521/10 ", "2.06"}, SDEV_NOLUNS},
401 {{T_CDROM, T_REMOV,
402 "MATSHITA", "CD-ROM CR-5XX ", "1.0b"}, SDEV_NOLUNS},
403 {{T_CDROM, T_REMOV,
404 "MEDAVIS ", "RENO CD-ROMX2A ", ""}, SDEV_NOLUNS},
405 {{T_CDROM, T_REMOV,
406 "MEDIAVIS", "CDR-H93MV ", "1.3"}, SDEV_NOLUNS},
407 {{T_CDROM, T_REMOV,
408 "NEC ", "CD-ROM DRIVE:55 ", ""}, SDEV_NOLUNS},
409 {{T_CDROM, T_REMOV,
410 "NEC ", "CD-ROM DRIVE:83 ", ""}, SDEV_NOLUNS},
411 {{T_CDROM, T_REMOV,
412 "NEC ", "CD-ROM DRIVE:84 ", ""}, SDEV_NOLUNS},
413 {{T_CDROM, T_REMOV,
414 "NEC ", "CD-ROM DRIVE:841", ""}, SDEV_NOLUNS},
415 {{T_CDROM, T_REMOV,
416 "PIONEER ", "CD-ROM DR-124X ", "1.01"}, SDEV_NOLUNS},
417 {{T_CDROM, T_REMOV,
418 "SONY ", "CD-ROM CDU-541 ", ""}, SDEV_NOLUNS},
419 {{T_CDROM, T_REMOV,
420 "SONY ", "CD-ROM CDU-55S ", ""}, SDEV_NOLUNS},
421 {{T_CDROM, T_REMOV,
422 "SONY ", "CD-ROM CDU-8003A", ""}, SDEV_NOLUNS},
423 {{T_CDROM, T_REMOV,
424 "SONY ", "CD-ROM CDU-8012 ", ""}, SDEV_NOLUNS},
425 {{T_CDROM, T_REMOV,
426 "TEAC ", "CD-ROM ", "1.06"}, SDEV_NOLUNS},
427 {{T_CDROM, T_REMOV,
428 "TEAC ", "CD-ROM CD-56S ", "1.0B"}, SDEV_NOLUNS},
429 {{T_CDROM, T_REMOV,
430 "TEXEL ", "CD-ROM ", "1.06"}, SDEV_NOLUNS},
431 {{T_CDROM, T_REMOV,
432 "TEXEL ", "CD-ROM DM-XX24 K", "1.10"}, SDEV_NOLUNS},
433 {{T_CDROM, T_REMOV,
434 "TOSHIBA ", "XM-4101TASUNSLCD", "1755"}, SDEV_NOLUNS},
435 {{T_CDROM, T_REMOV,
436 "ShinaKen", "CD-ROM DM-3x1S", "1.04"}, SDEV_NOLUNS},
437 {{T_CDROM, T_REMOV,
438 "JVC ", "R2626 ", "1.55"}, SDEV_NOLUNS},
439 {{T_DIRECT, T_FIXED,
440 "MICROP ", "1588-15MBSUN0669", ""}, SDEV_AUTOSAVE},
441 {{T_OPTICAL, T_REMOV,
442 "EPSON ", "OMD-5010 ", "3.08"}, SDEV_NOLUNS},
443
444 {{T_DIRECT, T_FIXED,
445 "DEC ", "RZ55 (C) DEC", ""}, SDEV_AUTOSAVE},
446 {{T_DIRECT, T_FIXED,
447 "EMULEX ", "MD21/S2 ESDI", "A00"}, SDEV_FORCELUNS|SDEV_AUTOSAVE},
448 /* Gives non-media hardware failure in response to start-unit command */
449 {{T_DIRECT, T_FIXED,
450 "HITACHI", "DK515C", "CP16"}, SDEV_NOSTARTUNIT},
451 {{T_DIRECT, T_FIXED,
452 "HITACHI", "DK515C", "CP15"}, SDEV_NOSTARTUNIT},
453 {{T_DIRECT, T_FIXED,
454 "IBMRAID ", "0662S", ""}, SDEV_AUTOSAVE},
455 {{T_DIRECT, T_FIXED,
456 "IBM ", "0663H", ""}, SDEV_AUTOSAVE},
457 {{T_DIRECT, T_FIXED,
458 "IBM", "0664", ""}, SDEV_AUTOSAVE},
459 {{T_DIRECT, T_FIXED,
460 "IBM ", "H3171-S2", ""}, SDEV_NOLUNS|SDEV_AUTOSAVE},
461 {{T_DIRECT, T_FIXED,
462 "IBM ", "KZ-C", ""}, SDEV_AUTOSAVE},
463 /* Broken IBM disk */
464 {{T_DIRECT, T_FIXED,
465 "" , "DFRSS2F", ""}, SDEV_AUTOSAVE},
466 {{T_DIRECT, T_REMOV,
467 "MPL ", "MC-DISK- ", ""}, SDEV_NOLUNS},
468 {{T_DIRECT, T_FIXED,
469 "MAXTOR ", "XT-3280 ", ""}, SDEV_NOLUNS},
470 {{T_DIRECT, T_FIXED,
471 "MAXTOR ", "XT-4380S ", ""}, SDEV_NOLUNS},
472 {{T_DIRECT, T_FIXED,
473 "MAXTOR ", "MXT-1240S ", ""}, SDEV_NOLUNS},
474 {{T_DIRECT, T_FIXED,
475 "MAXTOR ", "XT-4170S ", ""}, SDEV_NOLUNS},
476 {{T_DIRECT, T_FIXED,
477 "MAXTOR ", "XT-8760S", ""}, SDEV_NOLUNS},
478 {{T_DIRECT, T_FIXED,
479 "MAXTOR ", "LXT-213S ", ""}, SDEV_NOLUNS},
480 {{T_DIRECT, T_FIXED,
481 "MAXTOR ", "LXT-213S SUN0207", ""}, SDEV_NOLUNS},
482 {{T_DIRECT, T_FIXED,
483 "MAXTOR ", "LXT-200S ", ""}, SDEV_NOLUNS},
484 {{T_DIRECT, T_FIXED,
485 "MEGADRV ", "EV1000", ""}, SDEV_NOMODESENSE},
486 {{T_DIRECT, T_FIXED,
487 "MST ", "SnapLink ", ""}, SDEV_NOLUNS},
488 {{T_DIRECT, T_FIXED,
489 "NEC ", "D3847 ", "0307"}, SDEV_NOLUNS},
490 {{T_DIRECT, T_FIXED,
491 "QUANTUM ", "ELS85S ", ""}, SDEV_AUTOSAVE},
492 {{T_DIRECT, T_FIXED,
493 "QUANTUM ", "LPS525S ", ""}, SDEV_NOLUNS},
494 {{T_DIRECT, T_FIXED,
495 "QUANTUM ", "P105S 910-10-94x", ""}, SDEV_NOLUNS},
496 {{T_DIRECT, T_FIXED,
497 "QUANTUM ", "PD1225S ", ""}, SDEV_NOLUNS},
498 {{T_DIRECT, T_FIXED,
499 "QUANTUM ", "PD210S SUN0207", ""}, SDEV_NOLUNS},
500 {{T_DIRECT, T_FIXED,
501 "RODIME ", "RO3000S ", ""}, SDEV_NOLUNS},
502 {{T_DIRECT, T_FIXED,
503 "SEAGATE ", "ST125N ", ""}, SDEV_NOLUNS},
504 {{T_DIRECT, T_FIXED,
505 "SEAGATE ", "ST157N ", ""}, SDEV_NOLUNS},
506 {{T_DIRECT, T_FIXED,
507 "SEAGATE ", "ST296 ", ""}, SDEV_NOLUNS},
508 {{T_DIRECT, T_FIXED,
509 "SEAGATE ", "ST296N ", ""}, SDEV_NOLUNS},
510 {{T_DIRECT, T_FIXED,
511 "SEAGATE ", "ST19171FC", ""}, SDEV_NOMODESENSE},
512 {{T_DIRECT, T_FIXED,
513 "SEAGATE ", "ST34501FC ", ""}, SDEV_NOMODESENSE},
514 {{T_DIRECT, T_FIXED,
515 "TOSHIBA ", "MK538FB ", "6027"}, SDEV_NOLUNS},
516 {{T_DIRECT, T_REMOV,
517 "iomega", "jaz 1GB", ""}, SDEV_NOMODESENSE},
518 {{T_DIRECT, T_REMOV,
519 "IOMEGA", "ZIP 100", ""}, SDEV_NOMODESENSE},
520 /* Letting the motor run kills floppy drives and disks quite fast. */
521 {{T_DIRECT, T_REMOV,
522 "TEAC", "FC-1", ""}, SDEV_NOSTARTUNIT},
523
524 /* XXX: QIC-36 tape behind Emulex adapter. Very broken. */
525 {{T_SEQUENTIAL, T_REMOV,
526 " ", " ", " "}, SDEV_NOLUNS},
527 {{T_SEQUENTIAL, T_REMOV,
528 "CALIPER ", "CP150 ", ""}, SDEV_NOLUNS},
529 {{T_SEQUENTIAL, T_REMOV,
530 "EXABYTE ", "EXB-8200 ", ""}, SDEV_NOLUNS},
531 {{T_SEQUENTIAL, T_REMOV,
532 "SONY ", "GY-10C ", ""}, SDEV_NOLUNS},
533 {{T_SEQUENTIAL, T_REMOV,
534 "SONY ", "SDT-2000 ", "2.09"}, SDEV_NOLUNS},
535 {{T_SEQUENTIAL, T_REMOV,
536 "SONY ", "SDT-5000 ", "3."}, SDEV_NOSYNCWIDE},
537 {{T_SEQUENTIAL, T_REMOV,
538 "SONY ", "SDT-5200 ", "3."}, SDEV_NOLUNS},
539 {{T_SEQUENTIAL, T_REMOV,
540 "TANDBERG", " TDC 3600 ", ""}, SDEV_NOLUNS},
541 /* Following entry reported as a Tandberg 3600; ref. PR1933 */
542 {{T_SEQUENTIAL, T_REMOV,
543 "ARCHIVE ", "VIPER 150 21247", ""}, SDEV_NOLUNS},
544 /* Following entry for a Cipher ST150S; ref. PR4171 */
545 {{T_SEQUENTIAL, T_REMOV,
546 "ARCHIVE ", "VIPER 1500 21247", "2.2G"}, SDEV_NOLUNS},
547 {{T_SEQUENTIAL, T_REMOV,
548 "ARCHIVE ", "Python 28454-XXX", ""}, SDEV_NOLUNS},
549 {{T_SEQUENTIAL, T_REMOV,
550 "WANGTEK ", "5099ES SCSI", ""}, SDEV_NOLUNS},
551 {{T_SEQUENTIAL, T_REMOV,
552 "WANGTEK ", "5150ES SCSI", ""}, SDEV_NOLUNS},
553 {{T_SEQUENTIAL, T_REMOV,
554 "WangDAT ", "Model 1300 ", "02.4"}, SDEV_NOSYNCWIDE},
555 {{T_SEQUENTIAL, T_REMOV,
556 "WangDAT ", "Model 2600 ", "01.7"}, SDEV_NOSYNCWIDE},
557 {{T_SEQUENTIAL, T_REMOV,
558 "WangDAT ", "Model 3200 ", "02.2"}, SDEV_NOSYNCWIDE},
559
560 {{T_SCANNER, T_FIXED,
561 "RICOH ", "IS60 ", "1R08"}, SDEV_NOLUNS},
562 {{T_SCANNER, T_FIXED,
563 "UMAX ", "Astra 1200S ", "V2.9"}, SDEV_NOLUNS},
564 {{T_SCANNER, T_FIXED,
565 "UMAX ", "Astra 1220S ", "V1.2"}, SDEV_NOLUNS},
566 {{T_SCANNER, T_FIXED,
567 "UMAX ", "UMAX S-6E ", "V2.0"}, SDEV_NOLUNS},
568 {{T_SCANNER, T_FIXED,
569 "UMAX ", "UMAX S-12 ", "V2.1"}, SDEV_NOLUNS},
570
571 {{T_PROCESSOR, T_FIXED,
572 "LITRONIC", "PCMCIA ", ""}, SDEV_NOLUNS},
573 };
574
575 /*
576 * given a target and lun, ask the device what
577 * it is, and find the correct driver table
578 * entry.
579 */
580 void
581 scsi_probedev(scsi, target, lun)
582 struct scsibus_softc *scsi;
583 int target, lun;
584 {
585 struct scsipi_link *sc_link;
586 static struct scsipi_inquiry_data inqbuf;
587 struct scsi_quirk_inquiry_pattern *finger;
588 int checkdtype, priority;
589 struct scsipibus_attach_args sa;
590 struct cfdata *cf;
591
592 /* Skip this slot if it is already attached. */
593 if (scsi->sc_link[target][lun] != NULL)
594 return;
595
596 sc_link = malloc(sizeof(*sc_link), M_DEVBUF, M_NOWAIT);
597 *sc_link = *scsi->adapter_link;
598 sc_link->scsipi_scsi.target = target;
599 sc_link->scsipi_scsi.lun = lun;
600 sc_link->device = &probe_switch;
601
602 /*
603 * Ask the device what it is
604 */
605 #if defined(SCSIDEBUG) && DEBUGTYPE == BUS_SCSI
606 if (target == DEBUGTARGET && lun == DEBUGLUN)
607 sc_link->flags |= DEBUGLEVEL;
608 #endif /* SCSIDEBUG */
609
610 (void) scsipi_test_unit_ready(sc_link,
611 SCSI_AUTOCONF | SCSI_IGNORE_ILLEGAL_REQUEST |
612 SCSI_IGNORE_NOT_READY | SCSI_IGNORE_MEDIA_CHANGE);
613
614 #ifdef SCSI_2_DEF
615 /* some devices need to be told to go to SCSI2 */
616 /* However some just explode if you tell them this.. leave it out */
617 scsi_change_def(sc_link, SCSI_AUTOCONF | SCSI_SILENT);
618 #endif /* SCSI_2_DEF */
619
620 /* Now go ask the device all about itself. */
621 bzero(&inqbuf, sizeof(inqbuf));
622 if (scsipi_inquire(sc_link, &inqbuf, SCSI_AUTOCONF) != 0)
623 goto bad;
624
625 {
626 int len = inqbuf.additional_length;
627 while (len < 3)
628 inqbuf.unused[len++] = '\0';
629 while (len < 3 + 28)
630 inqbuf.unused[len++] = ' ';
631 }
632
633 sa.sa_sc_link = sc_link;
634 sa.sa_inqbuf.type = inqbuf.device;
635 sa.sa_inqbuf.removable = inqbuf.dev_qual2 & SID_REMOVABLE ?
636 T_REMOV : T_FIXED;
637 sa.sa_inqbuf.vendor = inqbuf.vendor;
638 sa.sa_inqbuf.product = inqbuf.product;
639 sa.sa_inqbuf.revision = inqbuf.revision;
640 sa.scsipi_info.scsi_version = inqbuf.version;
641
642 finger = (struct scsi_quirk_inquiry_pattern *)scsipi_inqmatch(
643 &sa.sa_inqbuf, (caddr_t)scsi_quirk_patterns,
644 sizeof(scsi_quirk_patterns)/sizeof(scsi_quirk_patterns[0]),
645 sizeof(scsi_quirk_patterns[0]), &priority);
646 if (priority != 0)
647 sc_link->quirks |= finger->quirks;
648 if ((inqbuf.version & SID_ANSII) == 0 &&
649 (sc_link->quirks & SDEV_FORCELUNS) == 0)
650 sc_link->quirks |= SDEV_NOLUNS;
651 sc_link->scsipi_scsi.scsi_version = inqbuf.version;
652
653 if ((sc_link->quirks & SDEV_NOLUNS) == 0)
654 scsi->moreluns |= (1 << target);
655
656 /*
657 * note what BASIC type of device it is
658 */
659 if ((inqbuf.dev_qual2 & SID_REMOVABLE) != 0)
660 sc_link->flags |= SDEV_REMOVABLE;
661
662 /*
663 * Any device qualifier that has the top bit set (qualifier&4 != 0)
664 * is vendor specific and won't match in this switch.
665 * All we do here is throw out bad/negative responses.
666 */
667 checkdtype = 0;
668 switch (inqbuf.device & SID_QUAL) {
669 case SID_QUAL_LU_OK:
670 case SID_QUAL_LU_OFFLINE:
671 checkdtype = 1;
672 break;
673
674 case SID_QUAL_RSVD:
675 case SID_QUAL_BAD_LU:
676 goto bad;
677
678 default:
679 break;
680 }
681 if (checkdtype)
682 switch (inqbuf.device & SID_TYPE) {
683 case T_DIRECT:
684 case T_SEQUENTIAL:
685 case T_PRINTER:
686 case T_PROCESSOR:
687 case T_WORM:
688 case T_CDROM:
689 case T_SCANNER:
690 case T_OPTICAL:
691 case T_CHANGER:
692 case T_COMM:
693 case T_IT8_1:
694 case T_IT8_2:
695 case T_STORARRAY:
696 case T_ENCLOSURE:
697 default:
698 break;
699 case T_NODEVICE:
700 goto bad;
701 }
702
703 if ((cf = config_search(scsibussubmatch, (struct device *)scsi,
704 &sa)) != NULL) {
705 scsi->sc_link[target][lun] = sc_link;
706 config_attach((struct device *)scsi, cf, &sa, scsibusprint);
707 } else {
708 scsibusprint(&sa, scsi->sc_dev.dv_xname);
709 printf(" not configured\n");
710 goto bad;
711 }
712
713 return;
714
715 bad:
716 free(sc_link, M_DEVBUF);
717 return;
718 }
719