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