1 /* $NetBSD: scsiconf.c,v 1.93 1997/10/03 02:04:17 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@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@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 "CHINON ", "CD-ROM CDS-535 ", ""}, SDEV_NOLUNS}, 392 {{T_CDROM, T_REMOV, 393 "DENON ", "DRD-25X ", "V"}, SDEV_NOLUNS}, 394 {{T_CDROM, T_REMOV, 395 "HP ", "C4324/C4325 ", ""}, SDEV_NOLUNS}, 396 {{T_CDROM, T_REMOV, 397 "IMS ", "CDD521/10 ", "2.06"}, SDEV_NOLUNS}, 398 {{T_CDROM, T_REMOV, 399 "MATSHITA", "CD-ROM CR-5XX ", "1.0b"}, SDEV_NOLUNS}, 400 {{T_CDROM, T_REMOV, 401 "MEDAVIS ", "RENO CD-ROMX2A ", ""}, SDEV_NOLUNS}, 402 {{T_CDROM, T_REMOV, 403 "MEDIAVIS", "CDR-H93MV ", "1.3"}, SDEV_NOLUNS}, 404 {{T_CDROM, T_REMOV, 405 "NEC ", "CD-ROM DRIVE:55 ", ""}, SDEV_NOLUNS}, 406 {{T_CDROM, T_REMOV, 407 "NEC ", "CD-ROM DRIVE:83 ", ""}, SDEV_NOLUNS}, 408 {{T_CDROM, T_REMOV, 409 "NEC ", "CD-ROM DRIVE:84 ", ""}, SDEV_NOLUNS}, 410 {{T_CDROM, T_REMOV, 411 "NEC ", "CD-ROM DRIVE:841", ""}, SDEV_NOLUNS}, 412 {{T_CDROM, T_REMOV, 413 "PIONEER ", "CD-ROM DR-124X ", "1.01"}, SDEV_NOLUNS}, 414 {{T_CDROM, T_REMOV, 415 "SONY ", "CD-ROM CDU-541 ", ""}, SDEV_NOLUNS}, 416 {{T_CDROM, T_REMOV, 417 "SONY ", "CD-ROM CDU-55S ", ""}, SDEV_NOLUNS}, 418 {{T_CDROM, T_REMOV, 419 "SONY ", "CD-ROM CDU-8003A", ""}, SDEV_NOLUNS}, 420 {{T_CDROM, T_REMOV, 421 "SONY ", "CD-ROM CDU-8012 ", ""}, SDEV_NOLUNS}, 422 {{T_CDROM, T_REMOV, 423 "TEAC ", "CD-ROM ", "1.06"}, SDEV_NOLUNS}, 424 {{T_CDROM, T_REMOV, 425 "TEAC ", "CD-ROM CD-56S ", "1.0B"}, SDEV_NOLUNS}, 426 {{T_CDROM, T_REMOV, 427 "TEXEL ", "CD-ROM ", "1.06"}, SDEV_NOLUNS}, 428 {{T_CDROM, T_REMOV, 429 "TEXEL ", "CD-ROM DM-XX24 K", "1.10"}, SDEV_NOLUNS}, 430 {{T_CDROM, T_REMOV, 431 "TOSHIBA ", "XM-4101TASUNSLCD", "1755"}, SDEV_NOLUNS}, 432 {{T_CDROM, T_REMOV, 433 "ShinaKen", "CD-ROM DM-3x1S", "1.04"}, 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 ", "KZ-C", ""}, SDEV_AUTOSAVE}, 456 /* Broken IBM disk */ 457 {{T_DIRECT, T_FIXED, 458 "" , "DFRSS2F", ""}, SDEV_AUTOSAVE}, 459 {{T_DIRECT, T_REMOV, 460 "MPL ", "MC-DISK- ", ""}, SDEV_NOLUNS}, 461 {{T_DIRECT, T_FIXED, 462 "MAXTOR ", "XT-3280 ", ""}, SDEV_NOLUNS}, 463 {{T_DIRECT, T_FIXED, 464 "MAXTOR ", "XT-4380S ", ""}, SDEV_NOLUNS}, 465 {{T_DIRECT, T_FIXED, 466 "MAXTOR ", "MXT-1240S ", ""}, SDEV_NOLUNS}, 467 {{T_DIRECT, T_FIXED, 468 "MAXTOR ", "XT-4170S ", ""}, SDEV_NOLUNS}, 469 {{T_DIRECT, T_FIXED, 470 "MAXTOR ", "XT-8760S", ""}, SDEV_NOLUNS}, 471 {{T_DIRECT, T_FIXED, 472 "MAXTOR ", "LXT-213S ", ""}, SDEV_NOLUNS}, 473 {{T_DIRECT, T_FIXED, 474 "MAXTOR ", "LXT-213S SUN0207", ""}, SDEV_NOLUNS}, 475 {{T_DIRECT, T_FIXED, 476 "MAXTOR ", "LXT-200S ", ""}, SDEV_NOLUNS}, 477 {{T_DIRECT, T_FIXED, 478 "MEGADRV ", "EV1000", ""}, SDEV_NOMODESENSE}, 479 {{T_DIRECT, T_FIXED, 480 "MST ", "SnapLink ", ""}, SDEV_NOLUNS}, 481 {{T_DIRECT, T_FIXED, 482 "NEC ", "D3847 ", "0307"}, SDEV_NOLUNS}, 483 {{T_DIRECT, T_FIXED, 484 "QUANTUM ", "LPS525S ", ""}, SDEV_NOLUNS}, 485 {{T_DIRECT, T_FIXED, 486 "QUANTUM ", "P105S 910-10-94x", ""}, SDEV_NOLUNS}, 487 {{T_DIRECT, T_FIXED, 488 "QUANTUM ", "PD1225S ", ""}, SDEV_NOLUNS}, 489 {{T_DIRECT, T_FIXED, 490 "QUANTUM ", "PD210S SUN0207", ""}, SDEV_NOLUNS}, 491 {{T_DIRECT, T_FIXED, 492 "RODIME ", "RO3000S ", ""}, SDEV_NOLUNS}, 493 {{T_DIRECT, T_FIXED, 494 "SEAGATE ", "ST125N ", ""}, SDEV_NOLUNS}, 495 {{T_DIRECT, T_FIXED, 496 "SEAGATE ", "ST157N ", ""}, SDEV_NOLUNS}, 497 {{T_DIRECT, T_FIXED, 498 "SEAGATE ", "ST296 ", ""}, SDEV_NOLUNS}, 499 {{T_DIRECT, T_FIXED, 500 "SEAGATE ", "ST296N ", ""}, SDEV_NOLUNS}, 501 {{T_DIRECT, T_FIXED, 502 "SEAGATE ", "ST19171FC ", ""}, SDEV_NOMODESENSE}, 503 {{T_DIRECT, T_FIXED, 504 "SEAGATE ", "ST34501FC ", ""}, SDEV_NOMODESENSE}, 505 {{T_DIRECT, T_FIXED, 506 "TOSHIBA ", "MK538FB ", "6027"}, SDEV_NOLUNS}, 507 {{T_DIRECT, T_REMOV, 508 "iomega", "jaz 1GB", ""}, SDEV_NOMODESENSE}, 509 {{T_DIRECT, T_REMOV, 510 "IOMEGA", "ZIP 100", ""}, SDEV_NOMODESENSE}, 511 /* Letting the motor run kills floppy drives and disks quite fast. */ 512 {{T_DIRECT, T_REMOV, 513 "TEAC", "FC-1", ""}, SDEV_NOSTARTUNIT}, 514 515 /* XXX: QIC-36 tape behind Emulex adapter. Very broken. */ 516 {{T_SEQUENTIAL, T_REMOV, 517 " ", " ", " "}, SDEV_NOLUNS}, 518 {{T_SEQUENTIAL, T_REMOV, 519 "CALIPER ", "CP150 ", ""}, SDEV_NOLUNS}, 520 {{T_SEQUENTIAL, T_REMOV, 521 "EXABYTE ", "EXB-8200 ", ""}, SDEV_NOLUNS}, 522 {{T_SEQUENTIAL, T_REMOV, 523 "SONY ", "GY-10C ", ""}, SDEV_NOLUNS}, 524 {{T_SEQUENTIAL, T_REMOV, 525 "SONY ", "SDT-2000 ", "2.09"}, SDEV_NOLUNS}, 526 {{T_SEQUENTIAL, T_REMOV, 527 "SONY ", "SDT-5000 ", "3."}, SDEV_NOSYNCWIDE}, 528 {{T_SEQUENTIAL, T_REMOV, 529 "SONY ", "SDT-5200 ", "3."}, SDEV_NOLUNS}, 530 {{T_SEQUENTIAL, T_REMOV, 531 "TANDBERG", " TDC 3600 ", ""}, SDEV_NOLUNS}, 532 /* Following entry reported as a Tandberg 3600; ref. PR1933 */ 533 {{T_SEQUENTIAL, T_REMOV, 534 "ARCHIVE ", "VIPER 150 21247", ""}, SDEV_NOLUNS}, 535 /* Following entry for a Cipher ST150S; ref. PR4171 */ 536 {{T_SEQUENTIAL, T_REMOV, 537 "ARCHIVE ", "VIPER 1500 21247", "2.2G"}, SDEV_NOLUNS}, 538 {{T_SEQUENTIAL, T_REMOV, 539 "ARCHIVE ", "Python 28454-XXX", ""}, SDEV_NOLUNS}, 540 {{T_SEQUENTIAL, T_REMOV, 541 "WANGTEK ", "5099ES SCSI", ""}, SDEV_NOLUNS}, 542 {{T_SEQUENTIAL, T_REMOV, 543 "WANGTEK ", "5150ES SCSI", ""}, SDEV_NOLUNS}, 544 {{T_SEQUENTIAL, T_REMOV, 545 "WangDAT ", "Model 1300 ", "02.4"}, SDEV_NOSYNCWIDE}, 546 {{T_SEQUENTIAL, T_REMOV, 547 "WangDAT ", "Model 2600 ", "01.7"}, SDEV_NOSYNCWIDE}, 548 {{T_SEQUENTIAL, T_REMOV, 549 "WangDAT ", "Model 3200 ", "02.2"}, SDEV_NOSYNCWIDE}, 550 551 {{T_SCANNER, T_FIXED, 552 "UMAX ", "UMAX S-6E ", "V2.0"}, SDEV_NOLUNS}, 553 554 {{T_PROCESSOR, T_FIXED, 555 "LITRONIC", "PCMCIA ", ""}, SDEV_NOLUNS}, 556 }; 557 558 /* 559 * given a target and lu, ask the device what 560 * it is, and find the correct driver table 561 * entry. 562 */ 563 void 564 scsi_probedev(scsi, target, lun) 565 struct scsibus_softc *scsi; 566 int target, lun; 567 { 568 struct scsipi_link *sc_link; 569 static struct scsipi_inquiry_data inqbuf; 570 struct scsi_quirk_inquiry_pattern *finger; 571 int checkdtype, priority; 572 struct scsipibus_attach_args sa; 573 struct cfdata *cf; 574 575 /* Skip this slot if it is already attached. */ 576 if (scsi->sc_link[target][lun] != NULL) 577 return; 578 579 sc_link = malloc(sizeof(*sc_link), M_DEVBUF, M_NOWAIT); 580 *sc_link = *scsi->adapter_link; 581 sc_link->scsipi_scsi.target = target; 582 sc_link->scsipi_scsi.lun = lun; 583 sc_link->device = &probe_switch; 584 585 /* 586 * Ask the device what it is 587 */ 588 #if defined(SCSIDEBUG) && DEBUGTYPE == BUS_SCSI 589 if (target == DEBUGTARGET && lun == DEBUGLUN) 590 sc_link->flags |= DEBUGLEVEL; 591 #endif /* SCSIDEBUG */ 592 593 (void) scsipi_test_unit_ready(sc_link, 594 SCSI_AUTOCONF | SCSI_IGNORE_ILLEGAL_REQUEST | 595 SCSI_IGNORE_NOT_READY | SCSI_IGNORE_MEDIA_CHANGE); 596 597 #ifdef SCSI_2_DEF 598 /* some devices need to be told to go to SCSI2 */ 599 /* However some just explode if you tell them this.. leave it out */ 600 scsi_change_def(sc_link, SCSI_AUTOCONF | SCSI_SILENT); 601 #endif /* SCSI_2_DEF */ 602 603 /* Now go ask the device all about itself. */ 604 bzero(&inqbuf, sizeof(inqbuf)); 605 if (scsipi_inquire(sc_link, &inqbuf, SCSI_AUTOCONF) != 0) 606 goto bad; 607 608 { 609 int len = inqbuf.additional_length; 610 while (len < 3) 611 inqbuf.unused[len++] = '\0'; 612 while (len < 3 + 28) 613 inqbuf.unused[len++] = ' '; 614 } 615 616 sa.sa_sc_link = sc_link; 617 sa.sa_inqbuf.type = inqbuf.device; 618 sa.sa_inqbuf.removable = inqbuf.dev_qual2 & SID_REMOVABLE ? 619 T_REMOV : T_FIXED; 620 sa.sa_inqbuf.vendor = inqbuf.vendor; 621 sa.sa_inqbuf.product = inqbuf.product; 622 sa.sa_inqbuf.revision = inqbuf.revision; 623 sa.scsipi_info.scsi_version = inqbuf.version; 624 625 finger = (struct scsi_quirk_inquiry_pattern *)scsipi_inqmatch( 626 &sa.sa_inqbuf, (caddr_t)scsi_quirk_patterns, 627 sizeof(scsi_quirk_patterns)/sizeof(scsi_quirk_patterns[0]), 628 sizeof(scsi_quirk_patterns[0]), &priority); 629 if (priority != 0) 630 sc_link->quirks |= finger->quirks; 631 if ((inqbuf.version & SID_ANSII) == 0 && 632 (sc_link->quirks & SDEV_FORCELUNS) == 0) 633 sc_link->quirks |= SDEV_NOLUNS; 634 sc_link->scsipi_scsi.scsi_version = inqbuf.version; 635 636 if ((sc_link->quirks & SDEV_NOLUNS) == 0) 637 scsi->moreluns |= (1 << target); 638 639 /* 640 * note what BASIC type of device it is 641 */ 642 if ((inqbuf.dev_qual2 & SID_REMOVABLE) != 0) 643 sc_link->flags |= SDEV_REMOVABLE; 644 645 /* 646 * Any device qualifier that has the top bit set (qualifier&4 != 0) 647 * is vendor specific and won't match in this switch. 648 * All we do here is throw out bad/negative responses. 649 */ 650 checkdtype = 0; 651 switch (inqbuf.device & SID_QUAL) { 652 case SID_QUAL_LU_OK: 653 case SID_QUAL_LU_OFFLINE: 654 checkdtype = 1; 655 break; 656 657 case SID_QUAL_RSVD: 658 case SID_QUAL_BAD_LU: 659 goto bad; 660 661 default: 662 break; 663 } 664 if (checkdtype) 665 switch (inqbuf.device & SID_TYPE) { 666 case T_DIRECT: 667 case T_SEQUENTIAL: 668 case T_PRINTER: 669 case T_PROCESSOR: 670 case T_WORM: 671 case T_CDROM: 672 case T_SCANNER: 673 case T_OPTICAL: 674 case T_CHANGER: 675 case T_COMM: 676 case T_IT8_1: 677 case T_IT8_2: 678 case T_STORARRAY: 679 case T_ENCLOSURE: 680 default: 681 break; 682 case T_NODEVICE: 683 goto bad; 684 } 685 686 if ((cf = config_search(scsibussubmatch, (struct device *)scsi, 687 &sa)) != NULL) { 688 scsi->sc_link[target][lun] = sc_link; 689 config_attach((struct device *)scsi, cf, &sa, scsibusprint); 690 } else { 691 scsibusprint(&sa, scsi->sc_dev.dv_xname); 692 printf(" not configured\n"); 693 goto bad; 694 } 695 696 return; 697 698 bad: 699 free(sc_link, M_DEVBUF); 700 return; 701 } 702