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