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