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