scsiconf.c revision 1.225 1 /* $NetBSD: scsiconf.c,v 1.225 2004/08/18 11:50:59 drochner Exp $ */
2
3 /*-
4 * Copyright (c) 1998, 1999, 2004 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/cdefs.h>
58 __KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.225 2004/08/18 11:50:59 drochner Exp $");
59
60 #include <sys/param.h>
61 #include <sys/systm.h>
62 #include <sys/kernel.h>
63 #include <sys/proc.h>
64 #include <sys/kthread.h>
65 #include <sys/malloc.h>
66 #include <sys/device.h>
67 #include <sys/conf.h>
68 #include <sys/fcntl.h>
69 #include <sys/scsiio.h>
70 #include <sys/queue.h>
71 #include <sys/lock.h>
72
73 #include <dev/scsipi/scsi_all.h>
74 #include <dev/scsipi/scsipi_all.h>
75 #include <dev/scsipi/scsiconf.h>
76
77 #include "locators.h"
78
79 const struct scsipi_periphsw scsi_probe_dev = {
80 NULL,
81 NULL,
82 NULL,
83 NULL,
84 };
85
86 struct scsi_initq {
87 struct scsipi_channel *sc_channel;
88 TAILQ_ENTRY(scsi_initq) scsi_initq;
89 };
90
91 static TAILQ_HEAD(, scsi_initq) scsi_initq_head =
92 TAILQ_HEAD_INITIALIZER(scsi_initq_head);
93 static struct simplelock scsibus_interlock = SIMPLELOCK_INITIALIZER;
94
95 int scsi_probe_device __P((struct scsibus_softc *, int, int));
96
97 int scsibusmatch __P((struct device *, struct cfdata *, void *));
98 void scsibusattach __P((struct device *, struct device *, void *));
99 int scsibusactivate __P((struct device *, enum devact));
100 int scsibusdetach __P((struct device *, int flags));
101 int scsibusrescan(struct device *, const char *, const int *);
102 void scsidevdetached(struct device *, struct device *);
103
104 int scsibussubmatch __P((struct device *, struct cfdata *,
105 const locdesc_t *, void *));
106
107 CFATTACH_DECL2(scsibus, sizeof(struct scsibus_softc),
108 scsibusmatch, scsibusattach, scsibusdetach, scsibusactivate,
109 scsibusrescan, scsidevdetached);
110
111 extern struct cfdriver scsibus_cd;
112
113 dev_type_open(scsibusopen);
114 dev_type_close(scsibusclose);
115 dev_type_ioctl(scsibusioctl);
116
117 const struct cdevsw scsibus_cdevsw = {
118 scsibusopen, scsibusclose, noread, nowrite, scsibusioctl,
119 nostop, notty, nopoll, nommap, nokqfilter,
120 };
121
122 int scsibusprint __P((void *, const char *));
123 void scsibus_config __P((struct scsipi_channel *, void *));
124
125 const struct scsipi_bustype scsi_bustype = {
126 SCSIPI_BUSTYPE_SCSI,
127 scsi_scsipi_cmd,
128 scsipi_interpret_sense,
129 scsi_print_addr,
130 scsi_kill_pending,
131 };
132
133 int
134 scsiprint(aux, pnp)
135 void *aux;
136 const char *pnp;
137 {
138 struct scsipi_channel *chan = aux;
139 struct scsipi_adapter *adapt = chan->chan_adapter;
140
141 /* only "scsibus"es can attach to "scsi"s; easy. */
142 if (pnp)
143 aprint_normal("scsibus at %s", pnp);
144
145 /* don't print channel if the controller says there can be only one. */
146 if (adapt->adapt_nchannels != 1)
147 aprint_normal(" channel %d", chan->chan_channel);
148
149 return (UNCONF);
150 }
151
152 int
153 scsibusmatch(parent, cf, aux)
154 struct device *parent;
155 struct cfdata *cf;
156 void *aux;
157 {
158 struct scsipi_channel *chan = aux;
159
160 if (chan->chan_bustype->bustype_type != SCSIPI_BUSTYPE_SCSI)
161 return 0;
162
163 if (cf->cf_loc[SCSICF_CHANNEL] != chan->chan_channel &&
164 cf->cf_loc[SCSICF_CHANNEL] != SCSICF_CHANNEL_DEFAULT)
165 return (0);
166
167 return (1);
168 }
169
170 void
171 scsibusattach(parent, self, aux)
172 struct device *parent, *self;
173 void *aux;
174 {
175 struct scsibus_softc *sc = (void *) self;
176 struct scsipi_channel *chan = aux;
177 struct scsi_initq *scsi_initq;
178
179 sc->sc_channel = chan;
180 chan->chan_name = sc->sc_dev.dv_xname;
181
182 aprint_naive(": SCSI bus\n");
183 aprint_normal(": %d target%s, %d lun%s per target\n",
184 chan->chan_ntargets,
185 chan->chan_ntargets == 1 ? "" : "s",
186 chan->chan_nluns,
187 chan->chan_nluns == 1 ? "" : "s");
188
189 if (scsipi_adapter_addref(chan->chan_adapter))
190 return;
191
192 /* Initialize the channel structure first */
193 chan->chan_init_cb = scsibus_config;
194 chan->chan_init_cb_arg = sc;
195
196 scsi_initq = malloc(sizeof(struct scsi_initq), M_DEVBUF, M_WAITOK);
197 scsi_initq->sc_channel = chan;
198 TAILQ_INSERT_TAIL(&scsi_initq_head, scsi_initq, scsi_initq);
199 config_pending_incr();
200 if (scsipi_channel_init(chan)) {
201 aprint_error("%s: failed to init channel\n",
202 sc->sc_dev.dv_xname);
203 return;
204 }
205 }
206
207 void
208 scsibus_config(chan, arg)
209 struct scsipi_channel *chan;
210 void *arg;
211 {
212 struct scsibus_softc *sc = arg;
213 struct scsi_initq *scsi_initq;
214
215 #ifndef SCSI_DELAY
216 #define SCSI_DELAY 2
217 #endif
218 if ((chan->chan_flags & SCSIPI_CHAN_NOSETTLE) == 0 &&
219 SCSI_DELAY > 0) {
220 aprint_normal(
221 "%s: waiting %d seconds for devices to settle...\n",
222 sc->sc_dev.dv_xname, SCSI_DELAY);
223 /* ...an identifier we know no one will use... */
224 (void) tsleep(scsibus_config, PRIBIO,
225 "scsidly", SCSI_DELAY * hz);
226 }
227
228 /* Make sure the devices probe in scsibus order to avoid jitter. */
229 simple_lock(&scsibus_interlock);
230 for (;;) {
231 scsi_initq = TAILQ_FIRST(&scsi_initq_head);
232 if (scsi_initq->sc_channel == chan)
233 break;
234 ltsleep(&scsi_initq_head, PRIBIO, "scsi_initq", 0,
235 &scsibus_interlock);
236 }
237
238 simple_unlock(&scsibus_interlock);
239
240 scsi_probe_bus(sc, -1, -1);
241
242 simple_lock(&scsibus_interlock);
243 TAILQ_REMOVE(&scsi_initq_head, scsi_initq, scsi_initq);
244 simple_unlock(&scsibus_interlock);
245
246 free(scsi_initq, M_DEVBUF);
247 wakeup(&scsi_initq_head);
248
249 scsipi_adapter_delref(chan->chan_adapter);
250
251 config_pending_decr();
252 }
253
254 int
255 scsibussubmatch(struct device *parent, struct cfdata *cf,
256 const locdesc_t *ldesc, void *aux)
257 {
258
259 if (cf->cf_loc[SCSIBUSCF_TARGET] != SCSIBUSCF_TARGET_DEFAULT &&
260 cf->cf_loc[SCSIBUSCF_TARGET] != ldesc->locs[0])
261 return (0);
262 if (cf->cf_loc[SCSIBUSCF_LUN] != SCSIBUSCF_LUN_DEFAULT &&
263 cf->cf_loc[SCSIBUSCF_LUN] != ldesc->locs[1])
264 return (0);
265 return (config_match(parent, cf, aux));
266 }
267
268 int
269 scsibusactivate(self, act)
270 struct device *self;
271 enum devact act;
272 {
273 struct scsibus_softc *sc = (void *) self;
274 struct scsipi_channel *chan = sc->sc_channel;
275 struct scsipi_periph *periph;
276 int target, lun, error = 0, s;
277
278 s = splbio();
279 switch (act) {
280 case DVACT_ACTIVATE:
281 error = EOPNOTSUPP;
282 break;
283
284 case DVACT_DEACTIVATE:
285 for (target = 0; target < chan->chan_ntargets;
286 target++) {
287 if (target == chan->chan_id)
288 continue;
289 for (lun = 0; lun < chan->chan_nluns; lun++) {
290 periph = scsipi_lookup_periph(chan,
291 target, lun);
292 if (periph == NULL)
293 continue;
294 error = config_deactivate(periph->periph_dev);
295 if (error)
296 goto out;
297 }
298 }
299 break;
300 }
301 out:
302 splx(s);
303 return (error);
304 }
305
306 int
307 scsibusdetach(self, flags)
308 struct device *self;
309 int flags;
310 {
311 struct scsibus_softc *sc = (void *) self;
312 struct scsipi_channel *chan = sc->sc_channel;
313 struct scsipi_periph *periph;
314 int ctarget, clun;
315 struct scsipi_xfer *xs;
316 int error;
317
318
319 /*
320 * Process outstanding commands (which will never complete as the
321 * controller is gone).
322 */
323 for (ctarget = 0; ctarget < chan->chan_ntargets; ctarget++) {
324 if (ctarget == chan->chan_id)
325 continue;
326 for (clun = 0; clun < chan->chan_nluns; clun++) {
327 periph = scsipi_lookup_periph(chan, ctarget, clun);
328 if (periph == NULL)
329 continue;
330 TAILQ_FOREACH(xs, &periph->periph_xferq, device_q) {
331 callout_stop(&xs->xs_callout);
332 xs->error = XS_DRIVER_STUFFUP;
333 scsipi_done(xs);
334 }
335 }
336 }
337
338 /*
339 * Detach all of the periphs.
340 */
341 error = scsipi_target_detach(chan, -1, -1, flags);
342
343 /*
344 * Now shut down the channel.
345 * XXX only if no errors ?
346 */
347 scsipi_channel_shutdown(chan);
348 return (error);
349 }
350
351 /*
352 * Probe the requested scsi bus. It must be already set up.
353 * target and lun optionally narrow the search if not -1
354 */
355 int
356 scsi_probe_bus(sc, target, lun)
357 struct scsibus_softc *sc;
358 int target, lun;
359 {
360 struct scsipi_channel *chan = sc->sc_channel;
361 int maxtarget, mintarget, maxlun, minlun;
362 int error;
363
364 if (target == -1) {
365 maxtarget = chan->chan_ntargets - 1;
366 mintarget = 0;
367 } else {
368 if (target < 0 || target >= chan->chan_ntargets)
369 return (EINVAL);
370 maxtarget = mintarget = target;
371 }
372
373 if (lun == -1) {
374 maxlun = chan->chan_nluns - 1;
375 minlun = 0;
376 } else {
377 if (lun < 0 || lun >= chan->chan_nluns)
378 return (EINVAL);
379 maxlun = minlun = lun;
380 }
381
382 /*
383 * Some HBAs provide an abstracted view of the bus; give them an
384 * oppertunity to re-scan it before we do.
385 */
386 if (chan->chan_adapter->adapt_ioctl != NULL)
387 (*chan->chan_adapter->adapt_ioctl)(chan, SCBUSIOLLSCAN, NULL,
388 0, curproc);
389
390 if ((error = scsipi_adapter_addref(chan->chan_adapter)) != 0)
391 return (error);
392 for (target = mintarget; target <= maxtarget; target++) {
393 if (target == chan->chan_id)
394 continue;
395 for (lun = minlun; lun <= maxlun; lun++) {
396 /*
397 * See if there's a device present, and configure it.
398 */
399 if (scsi_probe_device(sc, target, lun) == 0)
400 break;
401 /* otherwise something says we should look further */
402 }
403
404 /*
405 * Now that we've discovered all of the LUNs on this
406 * I_T Nexus, update the xfer mode for all of them
407 * that we know about.
408 */
409 scsipi_set_xfer_mode(chan, target, 1);
410 }
411 scsipi_adapter_delref(chan->chan_adapter);
412 return (0);
413 }
414
415 int
416 scsibusrescan(struct device *sc, const char *ifattr, const int *locators)
417 {
418
419 KASSERT(ifattr && !strcmp(ifattr, "scsibus"));
420 KASSERT(locators);
421
422 return (scsi_probe_bus((struct scsibus_softc *)sc,
423 locators[SCSIBUSCF_TARGET], locators[SCSIBUSCF_LUN]));
424 }
425
426 void
427 scsidevdetached(struct device *sc, struct device *dev)
428 {
429 struct scsibus_softc *ssc = (struct scsibus_softc *)sc;
430 struct scsipi_channel *chan = ssc->sc_channel;
431 struct scsipi_periph *periph;
432 int target, lun;
433
434 target = dev->dv_locators[SCSIBUSCF_TARGET];
435 lun = dev->dv_locators[SCSIBUSCF_LUN];
436
437 periph = scsipi_lookup_periph(chan, target, lun);
438 KASSERT(periph->periph_dev == dev);
439
440 scsipi_remove_periph(chan, periph);
441 free(periph, M_DEVBUF);
442 }
443
444 /*
445 * Print out autoconfiguration information for a subdevice.
446 *
447 * This is a slight abuse of 'standard' autoconfiguration semantics,
448 * because 'print' functions don't normally print the colon and
449 * device information. However, in this case that's better than
450 * either printing redundant information before the attach message,
451 * or having the device driver call a special function to print out
452 * the standard device information.
453 */
454 int
455 scsibusprint(aux, pnp)
456 void *aux;
457 const char *pnp;
458 {
459 struct scsipibus_attach_args *sa = aux;
460 struct scsipi_inquiry_pattern *inqbuf;
461 u_int8_t type;
462 const char *dtype;
463 char vendor[33], product[65], revision[17];
464 int target, lun;
465
466 if (pnp != NULL)
467 aprint_normal("%s", pnp);
468
469 inqbuf = &sa->sa_inqbuf;
470
471 target = sa->sa_periph->periph_target;
472 lun = sa->sa_periph->periph_lun;
473 type = inqbuf->type & SID_TYPE;
474
475 dtype = scsipi_dtype(type);
476
477 scsipi_strvis(vendor, 33, inqbuf->vendor, 8);
478 scsipi_strvis(product, 65, inqbuf->product, 16);
479 scsipi_strvis(revision, 17, inqbuf->revision, 4);
480
481 aprint_normal(" target %d lun %d: <%s, %s, %s> %s %s",
482 target, lun, vendor, product, revision, dtype,
483 inqbuf->removable ? "removable" : "fixed");
484
485 return (UNCONF);
486 }
487
488 const struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
489 {{T_CDROM, T_REMOV,
490 "CHINON ", "CD-ROM CDS-431 ", ""}, PQUIRK_NOLUNS},
491 {{T_CDROM, T_REMOV,
492 "CHINON ", "CD-ROM CDS-435 ", ""}, PQUIRK_NOLUNS},
493 {{T_CDROM, T_REMOV,
494 "Chinon ", "CD-ROM CDS-525 ", ""}, PQUIRK_NOLUNS},
495 {{T_CDROM, T_REMOV,
496 "CHINON ", "CD-ROM CDS-535 ", ""}, PQUIRK_NOLUNS},
497 {{T_CDROM, T_REMOV,
498 "DEC ", "RRD42 (C) DEC ", ""}, PQUIRK_NOLUNS},
499 {{T_CDROM, T_REMOV,
500 "DENON ", "DRD-25X ", "V"}, PQUIRK_NOLUNS},
501 {{T_CDROM, T_REMOV,
502 "GENERIC ", "CRD-BP2 ", ""}, PQUIRK_NOLUNS},
503 {{T_CDROM, T_REMOV,
504 "HP ", "C4324/C4325 ", ""}, PQUIRK_NOLUNS},
505 {{T_CDROM, T_REMOV,
506 "IMS ", "CDD521/10 ", "2.06"}, PQUIRK_NOLUNS},
507 {{T_CDROM, T_REMOV,
508 "MATSHITA", "CD-ROM CR-5XX ", "1.0b"}, PQUIRK_NOLUNS},
509 {{T_CDROM, T_REMOV,
510 "MEDAVIS ", "RENO CD-ROMX2A ", ""}, PQUIRK_NOLUNS},
511 {{T_CDROM, T_REMOV,
512 "MEDIAVIS", "CDR-H93MV ", "1.3"}, PQUIRK_NOLUNS},
513 {{T_CDROM, T_REMOV,
514 "NEC ", "CD-ROM DRIVE:502", ""}, PQUIRK_NOLUNS},
515 {{T_CDROM, T_REMOV,
516 "NEC ", "CD-ROM DRIVE:55 ", ""}, PQUIRK_NOLUNS},
517 {{T_CDROM, T_REMOV,
518 "NEC ", "CD-ROM DRIVE:83 ", ""}, PQUIRK_NOLUNS},
519 {{T_CDROM, T_REMOV,
520 "NEC ", "CD-ROM DRIVE:84 ", ""}, PQUIRK_NOLUNS},
521 {{T_CDROM, T_REMOV,
522 "NEC ", "CD-ROM DRIVE:841", ""}, PQUIRK_NOLUNS},
523 {{T_CDROM, T_REMOV,
524 "OLYMPUS ", "CDS620E ", "1.1d"},
525 PQUIRK_NOLUNS|PQUIRK_NOSYNC|PQUIRK_NOCAPACITY},
526 {{T_CDROM, T_REMOV,
527 "PIONEER ", "CD-ROM DR-124X ", "1.01"}, PQUIRK_NOLUNS},
528 {{T_CDROM, T_REMOV,
529 "PLEXTOR ", "CD-ROM PX-4XCS ", "1.01"},
530 PQUIRK_NOLUNS|PQUIRK_NOSYNC},
531 {{T_CDROM, T_REMOV,
532 "SONY ", "CD-ROM CDU-541 ", ""}, PQUIRK_NOLUNS},
533 {{T_CDROM, T_REMOV,
534 "SONY ", "CD-ROM CDU-55S ", ""}, PQUIRK_NOLUNS},
535 {{T_CDROM, T_REMOV,
536 "SONY ", "CD-ROM CDU-561 ", ""}, PQUIRK_NOLUNS},
537 {{T_CDROM, T_REMOV,
538 "SONY ", "CD-ROM CDU-76S", ""},
539 PQUIRK_NOLUNS|PQUIRK_NOSYNC|PQUIRK_NOWIDE},
540 {{T_CDROM, T_REMOV,
541 "SONY ", "CD-ROM CDU-8003A", ""}, PQUIRK_NOLUNS},
542 {{T_CDROM, T_REMOV,
543 "SONY ", "CD-ROM CDU-8012 ", ""}, PQUIRK_NOLUNS},
544 {{T_CDROM, T_REMOV,
545 "TEAC ", "CD-ROM ", "1.06"}, PQUIRK_NOLUNS},
546 {{T_CDROM, T_REMOV,
547 "TEAC ", "CD-ROM CD-56S ", "1.0B"}, PQUIRK_NOLUNS},
548 {{T_CDROM, T_REMOV,
549 "TEXEL ", "CD-ROM ", "1.06"}, PQUIRK_NOLUNS},
550 {{T_CDROM, T_REMOV,
551 "TEXEL ", "CD-ROM DM-XX24 K", "1.09"}, PQUIRK_NOLUNS},
552 {{T_CDROM, T_REMOV,
553 "TEXEL ", "CD-ROM DM-XX24 K", "1.10"}, PQUIRK_NOLUNS},
554 {{T_CDROM, T_REMOV,
555 "TOSHIBA ", "XM-4101TASUNSLCD", ""}, PQUIRK_NOLUNS|PQUIRK_NOSYNC},
556 /* "IBM CDRM00201 !F" 0724 is an IBM OEM Toshiba XM-4101BME */
557 {{T_CDROM, T_REMOV,
558 "IBM ", "CDRM00201 !F", "0724"}, PQUIRK_NOLUNS|PQUIRK_NOSYNC},
559 {{T_CDROM, T_REMOV,
560 "ShinaKen", "CD-ROM DM-3x1S", "1.04"}, PQUIRK_NOLUNS},
561 {{T_CDROM, T_REMOV,
562 "JVC ", "R2626", ""}, PQUIRK_NOLUNS},
563 {{T_CDROM, T_REMOV,
564 "YAMAHA", "CRW8424S", ""}, PQUIRK_NOLUNS},
565 {{T_CDROM, T_REMOV,
566 "NEC ", "CD-ROM DRIVE:222", ""}, PQUIRK_NOLUNS|PQUIRK_NOSYNC},
567
568 {{T_DIRECT, T_FIXED,
569 "MICROP ", "1588-15MBSUN0669", ""}, PQUIRK_AUTOSAVE},
570 {{T_DIRECT, T_FIXED,
571 "MICROP ", "2217-15MQ1091501", ""}, PQUIRK_NOSYNCCACHE},
572 {{T_OPTICAL, T_REMOV,
573 "EPSON ", "OMD-5010 ", "3.08"}, PQUIRK_NOLUNS},
574 {{T_DIRECT, T_FIXED,
575 "ADAPTEC ", "AEC-4412BD", "1.2A"}, PQUIRK_NOMODESENSE},
576 {{T_DIRECT, T_FIXED,
577 "ADAPTEC ", "ACB-4000", ""}, PQUIRK_FORCELUNS|PQUIRK_AUTOSAVE|PQUIRK_NOMODESENSE},
578 {{T_DIRECT, T_FIXED,
579 "DEC ", "RZ55 (C) DEC", ""}, PQUIRK_AUTOSAVE},
580 {{T_DIRECT, T_FIXED,
581 "EMULEX ", "MD21/S2 ESDI", "A00"},
582 PQUIRK_FORCELUNS|PQUIRK_AUTOSAVE},
583 {{T_DIRECT, T_FIXED,
584 "MICROP", "1548-15MZ1077801", "HZ2P"}, PQUIRK_NOTAG},
585 {{T_DIRECT, T_FIXED,
586 "HP ", "C372", ""}, PQUIRK_NOTAG},
587 {{T_DIRECT, T_FIXED,
588 "IBMRAID ", "0662S", ""}, PQUIRK_AUTOSAVE},
589 {{T_DIRECT, T_FIXED,
590 "IBM ", "0663H", ""}, PQUIRK_AUTOSAVE},
591 {{T_DIRECT, T_FIXED,
592 "IBM", "0664", ""}, PQUIRK_AUTOSAVE},
593 {{T_DIRECT, T_FIXED,
594 /* improperly report DT-only sync mode */
595 "IBM ", "DXHS36D", ""},
596 PQUIRK_CAP_SYNC|PQUIRK_CAP_WIDE16},
597 {{T_DIRECT, T_FIXED,
598 "IBM ", "DXHS18Y", ""},
599 PQUIRK_CAP_SYNC|PQUIRK_CAP_WIDE16},
600 {{T_DIRECT, T_FIXED,
601 "IBM ", "H3171-S2", ""},
602 PQUIRK_NOLUNS|PQUIRK_AUTOSAVE},
603 {{T_DIRECT, T_FIXED,
604 "IBM ", "KZ-C", ""}, PQUIRK_AUTOSAVE},
605 /* Broken IBM disk */
606 {{T_DIRECT, T_FIXED,
607 "" , "DFRSS2F", ""}, PQUIRK_AUTOSAVE},
608 {{T_DIRECT, T_REMOV,
609 "MPL ", "MC-DISK- ", ""}, PQUIRK_NOLUNS},
610 {{T_DIRECT, T_FIXED,
611 "MAXTOR ", "XT-3280 ", ""}, PQUIRK_NOLUNS},
612 {{T_DIRECT, T_FIXED,
613 "MAXTOR ", "XT-4380S ", ""}, PQUIRK_NOLUNS},
614 {{T_DIRECT, T_FIXED,
615 "MAXTOR ", "MXT-1240S ", ""}, PQUIRK_NOLUNS},
616 {{T_DIRECT, T_FIXED,
617 "MAXTOR ", "XT-4170S ", ""}, PQUIRK_NOLUNS},
618 {{T_DIRECT, T_FIXED,
619 "MAXTOR ", "XT-8760S", ""}, PQUIRK_NOLUNS},
620 {{T_DIRECT, T_FIXED,
621 "MAXTOR ", "LXT-213S ", ""}, PQUIRK_NOLUNS},
622 {{T_DIRECT, T_FIXED,
623 "MAXTOR ", "LXT-213S SUN0207", ""}, PQUIRK_NOLUNS},
624 {{T_DIRECT, T_FIXED,
625 "MAXTOR ", "LXT-200S ", ""}, PQUIRK_NOLUNS},
626 {{T_DIRECT, T_FIXED,
627 "MEGADRV ", "EV1000", ""}, PQUIRK_NOMODESENSE},
628 {{T_DIRECT, T_FIXED,
629 "MICROP", "1991-27MZ", ""}, PQUIRK_NOTAG},
630 {{T_DIRECT, T_FIXED,
631 "MST ", "SnapLink ", ""}, PQUIRK_NOLUNS},
632 {{T_DIRECT, T_FIXED,
633 "NEC ", "D3847 ", "0307"}, PQUIRK_NOLUNS},
634 {{T_DIRECT, T_FIXED,
635 "QUANTUM ", "ELS85S ", ""}, PQUIRK_AUTOSAVE},
636 {{T_DIRECT, T_FIXED,
637 "QUANTUM ", "LPS525S ", ""}, PQUIRK_NOLUNS},
638 {{T_DIRECT, T_FIXED,
639 "QUANTUM ", "P105S 910-10-94x", ""}, PQUIRK_NOLUNS},
640 {{T_DIRECT, T_FIXED,
641 "QUANTUM ", "PD1225S ", ""}, PQUIRK_NOLUNS},
642 {{T_DIRECT, T_FIXED,
643 "QUANTUM ", "PD210S SUN0207", ""}, PQUIRK_NOLUNS},
644 {{T_DIRECT, T_FIXED,
645 "QUANTUM ", "ATLAS IV 9 WLS", "0A0A"}, PQUIRK_CAP_NODT},
646 {{T_DIRECT, T_FIXED,
647 "RODIME ", "RO3000S ", ""}, PQUIRK_NOLUNS},
648 {{T_DIRECT, T_FIXED,
649 "SEAGATE ", "ST125N ", ""}, PQUIRK_NOLUNS},
650 {{T_DIRECT, T_FIXED,
651 "SEAGATE ", "ST157N ", ""}, PQUIRK_NOLUNS},
652 {{T_DIRECT, T_FIXED,
653 "SEAGATE ", "ST296 ", ""}, PQUIRK_NOLUNS},
654 {{T_DIRECT, T_FIXED,
655 "SEAGATE ", "ST296N ", ""}, PQUIRK_NOLUNS},
656 {{T_DIRECT, T_FIXED,
657 "SEAGATE ", "ST318404LC ", ""}, PQUIRK_NOLUNS},
658 {{T_DIRECT, T_FIXED,
659 "SEAGATE ", "ST15150N ", ""}, PQUIRK_NOTAG},
660 {{T_DIRECT, T_FIXED,
661 "SEAGATE ", "ST19171", ""}, PQUIRK_NOMODESENSE},
662 {{T_DIRECT, T_FIXED,
663 "SEAGATE ", "ST32430N", ""}, PQUIRK_CAP_SYNC},
664 {{T_DIRECT, T_FIXED,
665 "SEAGATE ", "ST34501FC ", ""}, PQUIRK_NOMODESENSE},
666 {{T_DIRECT, T_FIXED,
667 "SEAGATE ", "SX910800N", ""}, PQUIRK_NOTAG},
668 {{T_DIRECT, T_FIXED,
669 "TOSHIBA ", "MK538FB ", "6027"}, PQUIRK_NOLUNS},
670 {{T_DIRECT, T_FIXED,
671 "MICROP ", "1924", ""}, PQUIRK_CAP_SYNC},
672 {{T_DIRECT, T_FIXED,
673 "FUJITSU ", "M2266", ""}, PQUIRK_CAP_SYNC},
674
675 {{T_DIRECT, T_REMOV,
676 "IOMEGA", "ZIP 100", "J.03"}, PQUIRK_NOLUNS},
677 {{T_DIRECT, T_REMOV,
678 "INSITE", "I325VM", ""}, PQUIRK_NOLUNS},
679
680 /* XXX: QIC-36 tape behind Emulex adapter. Very broken. */
681 {{T_SEQUENTIAL, T_REMOV,
682 " ", " ", " "}, PQUIRK_NOLUNS},
683 {{T_SEQUENTIAL, T_REMOV,
684 "EMULEX ", "MT-02 QIC ", ""}, PQUIRK_NOLUNS},
685 {{T_SEQUENTIAL, T_REMOV,
686 "CALIPER ", "CP150 ", ""}, PQUIRK_NOLUNS},
687 {{T_SEQUENTIAL, T_REMOV,
688 "EXABYTE ", "EXB-8200 ", ""}, PQUIRK_NOLUNS},
689 {{T_SEQUENTIAL, T_REMOV,
690 "SONY ", "GY-10C ", ""}, PQUIRK_NOLUNS},
691 {{T_SEQUENTIAL, T_REMOV,
692 "SONY ", "SDT-2000 ", "2.09"}, PQUIRK_NOLUNS},
693 {{T_SEQUENTIAL, T_REMOV,
694 "SONY ", "SDT-5000 ", "3."}, PQUIRK_NOSYNC|PQUIRK_NOWIDE},
695 {{T_SEQUENTIAL, T_REMOV,
696 "SONY ", "SDT-5200 ", "3."}, PQUIRK_NOLUNS},
697 {{T_SEQUENTIAL, T_REMOV,
698 "TANDBERG", " TDC 3600 ", ""}, PQUIRK_NOLUNS},
699 /* Following entry reported as a Tandberg 3600; ref. PR1933 */
700 {{T_SEQUENTIAL, T_REMOV,
701 "ARCHIVE ", "VIPER 150 21247", ""}, PQUIRK_NOLUNS},
702 /* Following entry for a Cipher ST150S; ref. PR4171 */
703 {{T_SEQUENTIAL, T_REMOV,
704 "ARCHIVE ", "VIPER 1500 21247", "2.2G"}, PQUIRK_NOLUNS},
705 {{T_SEQUENTIAL, T_REMOV,
706 "ARCHIVE ", "Python 28454-XXX", ""}, PQUIRK_NOLUNS},
707 {{T_SEQUENTIAL, T_REMOV,
708 "WANGTEK ", "5099ES SCSI", ""}, PQUIRK_NOLUNS},
709 {{T_SEQUENTIAL, T_REMOV,
710 "WANGTEK ", "5150ES SCSI", ""}, PQUIRK_NOLUNS},
711 {{T_SEQUENTIAL, T_REMOV,
712 "WANGTEK ", "SCSI-36", ""}, PQUIRK_NOLUNS},
713 {{T_SEQUENTIAL, T_REMOV,
714 "WangDAT ", "Model 1300 ", "02.4"}, PQUIRK_NOSYNC|PQUIRK_NOWIDE},
715 {{T_SEQUENTIAL, T_REMOV,
716 "WangDAT ", "Model 2600 ", "01.7"}, PQUIRK_NOSYNC|PQUIRK_NOWIDE},
717 {{T_SEQUENTIAL, T_REMOV,
718 "WangDAT ", "Model 3200 ", "02.2"}, PQUIRK_NOSYNC|PQUIRK_NOWIDE},
719 {{T_SEQUENTIAL, T_REMOV,
720 "TEAC ", "MT-2ST/N50 ", ""}, PQUIRK_NOLUNS},
721
722 {{T_SCANNER, T_FIXED,
723 "RICOH ", "IS60 ", "1R08"}, PQUIRK_NOLUNS},
724 {{T_SCANNER, T_FIXED,
725 "UMAX ", "Astra 1200S ", "V2.9"}, PQUIRK_NOLUNS},
726 {{T_SCANNER, T_FIXED,
727 "UMAX ", "Astra 1220S ", ""}, PQUIRK_NOLUNS},
728 {{T_SCANNER, T_FIXED,
729 "UMAX ", "UMAX S-6E ", "V2.0"}, PQUIRK_NOLUNS},
730 {{T_SCANNER, T_FIXED,
731 "UMAX ", "UMAX S-12 ", "V2.1"}, PQUIRK_NOLUNS},
732 {{T_SCANNER, T_FIXED,
733 "ULTIMA ", "A6000C ", ""}, PQUIRK_NOLUNS},
734 {{T_PROCESSOR, T_FIXED,
735 "SYMBIOS", "", ""}, PQUIRK_NOLUNS},
736 {{T_PROCESSOR, T_FIXED,
737 "LITRONIC", "PCMCIA ", ""}, PQUIRK_NOLUNS},
738 {{T_CHANGER, T_REMOV,
739 "SONY ", "CDL1100 ", ""}, PQUIRK_NOLUNS},
740 {{T_ENCLOSURE, T_FIXED,
741 "SUN ", "SENA ", ""}, PQUIRK_NOLUNS},
742 };
743
744 /*
745 * given a target and lun, ask the device what
746 * it is, and find the correct driver table
747 * entry.
748 */
749 int
750 scsi_probe_device(sc, target, lun)
751 struct scsibus_softc *sc;
752 int target, lun;
753 {
754 struct scsipi_channel *chan = sc->sc_channel;
755 struct scsipi_periph *periph;
756 struct scsipi_inquiry_data inqbuf;
757 struct scsi_quirk_inquiry_pattern *finger;
758 int checkdtype, priority, docontinue, quirks;
759 struct scsipibus_attach_args sa;
760 struct cfdata *cf;
761 int help[3];
762 locdesc_t *locd = (void *)&help;
763 struct device *chld;
764
765 /*
766 * Assume no more luns to search after this one.
767 * If we successfully get Inquiry data and after
768 * merging quirks we find we can probe for more
769 * luns, we will.
770 */
771 docontinue = 0;
772
773 /* Skip this slot if it is already attached. */
774 if (scsipi_lookup_periph(chan, target, lun) != NULL)
775 return (docontinue);
776
777 periph = scsipi_alloc_periph(M_NOWAIT);
778 if (periph == NULL) {
779 #ifdef DIAGNOSTIC
780 aprint_error(
781 "%s: cannot allocate periph for target %d lun %d\n",
782 sc->sc_dev.dv_xname, target, lun);
783 #endif
784 return (ENOMEM);
785 }
786 periph->periph_channel = chan;
787 periph->periph_switch = &scsi_probe_dev;
788
789 periph->periph_target = target;
790 periph->periph_lun = lun;
791 periph->periph_quirks = chan->chan_defquirks;
792
793 #ifdef SCSIPI_DEBUG
794 if (SCSIPI_DEBUG_TYPE == SCSIPI_BUSTYPE_SCSI &&
795 SCSIPI_DEBUG_TARGET == target &&
796 SCSIPI_DEBUG_LUN == lun)
797 periph->periph_dbflags |= SCSIPI_DEBUG_FLAGS;
798 #endif
799
800 /*
801 * Ask the device what it is
802 */
803
804 #ifdef SCSI_2_DEF
805 /* some devices need to be told to go to SCSI2 */
806 /* However some just explode if you tell them this.. leave it out */
807 scsi_change_def(periph, XS_CTL_DISCOVERY | XS_CTL_SILENT);
808 #endif /* SCSI_2_DEF */
809
810 /* Now go ask the device all about itself. */
811 memset(&inqbuf, 0, sizeof(inqbuf));
812 {
813 u_int8_t *extension = &inqbuf.flags1;
814 int len = 0;
815 while (len < 3)
816 extension[len++] = '\0';
817 while (len < 3 + 28)
818 extension[len++] = ' ';
819 while (len < 3 + 28 + 20)
820 extension[len++] = '\0';
821 while (len < 3 + 28 + 20 + 1)
822 extension[len++] = '\0';
823 while (len < 3 + 28 + 20 + 1 + 1)
824 extension[len++] = '\0';
825 while (len < 3 + 28 + 20 + 1 + 1 + (8*2))
826 extension[len++] = ' ';
827 }
828 if (scsipi_inquire(periph, &inqbuf,
829 XS_CTL_DISCOVERY | XS_CTL_DATA_ONSTACK | XS_CTL_SILENT) != 0)
830 goto bad;
831
832 periph->periph_type = inqbuf.device & SID_TYPE;
833 if (inqbuf.dev_qual2 & SID_REMOVABLE)
834 periph->periph_flags |= PERIPH_REMOVABLE;
835 periph->periph_version = inqbuf.version & SID_ANSII;
836
837 /*
838 * Any device qualifier that has the top bit set (qualifier&4 != 0)
839 * is vendor specific and won't match in this switch.
840 * All we do here is throw out bad/negative responses.
841 */
842 checkdtype = 0;
843 switch (inqbuf.device & SID_QUAL) {
844 case SID_QUAL_LU_PRESENT:
845 checkdtype = 1;
846 break;
847
848 case SID_QUAL_LU_NOTPRESENT:
849 case SID_QUAL_reserved:
850 case SID_QUAL_LU_NOT_SUPP:
851 goto bad;
852
853 default:
854 break;
855 }
856
857 /* Let the adapter driver handle the device separatley if it wants. */
858 if (chan->chan_adapter->adapt_accesschk != NULL &&
859 (*chan->chan_adapter->adapt_accesschk)(periph, &sa.sa_inqbuf))
860 goto bad;
861
862 if (checkdtype) {
863 switch (periph->periph_type) {
864 case T_DIRECT:
865 case T_SEQUENTIAL:
866 case T_PRINTER:
867 case T_PROCESSOR:
868 case T_WORM:
869 case T_CDROM:
870 case T_SCANNER:
871 case T_OPTICAL:
872 case T_CHANGER:
873 case T_COMM:
874 case T_IT8_1:
875 case T_IT8_2:
876 case T_STORARRAY:
877 case T_ENCLOSURE:
878 case T_SIMPLE_DIRECT:
879 case T_OPTIC_CARD_RW:
880 case T_OBJECT_STORED:
881 default:
882 break;
883 case T_NODEVICE:
884 goto bad;
885 }
886 }
887
888 sa.sa_periph = periph;
889 sa.sa_inqbuf.type = inqbuf.device;
890 sa.sa_inqbuf.removable = inqbuf.dev_qual2 & SID_REMOVABLE ?
891 T_REMOV : T_FIXED;
892 sa.sa_inqbuf.vendor = inqbuf.vendor;
893 sa.sa_inqbuf.product = inqbuf.product;
894 sa.sa_inqbuf.revision = inqbuf.revision;
895 sa.scsipi_info.scsi_version = inqbuf.version;
896 sa.sa_inqptr = &inqbuf;
897
898 finger = (struct scsi_quirk_inquiry_pattern *)scsipi_inqmatch(
899 &sa.sa_inqbuf, (caddr_t)scsi_quirk_patterns,
900 sizeof(scsi_quirk_patterns)/sizeof(scsi_quirk_patterns[0]),
901 sizeof(scsi_quirk_patterns[0]), &priority);
902
903 if (finger != NULL)
904 quirks = finger->quirks;
905 else
906 quirks = 0;
907
908 /*
909 * Determine the operating mode capabilities of the device.
910 */
911 if (periph->periph_version >= 2) {
912 if ((inqbuf.flags3 & SID_CmdQue) != 0 &&
913 (quirks & PQUIRK_NOTAG) == 0)
914 periph->periph_cap |= PERIPH_CAP_TQING;
915 if ((inqbuf.flags3 & SID_Linked) != 0)
916 periph->periph_cap |= PERIPH_CAP_LINKCMDS;
917 if ((inqbuf.flags3 & SID_Sync) != 0 &&
918 (quirks & PQUIRK_NOSYNC) == 0)
919 periph->periph_cap |= PERIPH_CAP_SYNC;
920 if ((inqbuf.flags3 & SID_WBus16) != 0 &&
921 (quirks & PQUIRK_NOWIDE) == 0)
922 periph->periph_cap |= PERIPH_CAP_WIDE16;
923 if ((inqbuf.flags3 & SID_WBus32) != 0 &&
924 (quirks & PQUIRK_NOWIDE) == 0)
925 periph->periph_cap |= PERIPH_CAP_WIDE32;
926 if ((inqbuf.flags3 & SID_SftRe) != 0)
927 periph->periph_cap |= PERIPH_CAP_SFTRESET;
928 if ((inqbuf.flags3 & SID_RelAdr) != 0)
929 periph->periph_cap |= PERIPH_CAP_RELADR;
930 /* SPC-2 */
931 if (periph->periph_version >= 3 &&
932 !(quirks & PQUIRK_CAP_NODT)){
933 /*
934 * Report ST clocking though CAP_WIDExx/CAP_SYNC.
935 * If the device only supports DT, clear these
936 * flags (DT implies SYNC and WIDE)
937 */
938 switch (inqbuf.flags4 & SID_Clocking) {
939 case SID_CLOCKING_DT_ONLY:
940 periph->periph_cap &=
941 ~(PERIPH_CAP_SYNC |
942 PERIPH_CAP_WIDE16 |
943 PERIPH_CAP_WIDE32);
944 /* FALLTHOUGH */
945 case SID_CLOCKING_SD_DT:
946 periph->periph_cap |= PERIPH_CAP_DT;
947 break;
948 default: /* ST only or invalid */
949 /* nothing to do */
950 break;
951 }
952 }
953 if (periph->periph_version >= 3) {
954 if (inqbuf.flags4 & SID_IUS)
955 periph->periph_cap |= PERIPH_CAP_IUS;
956 if (inqbuf.flags4 & SID_QAS)
957 periph->periph_cap |= PERIPH_CAP_QAS;
958 }
959 }
960 if (quirks & PQUIRK_CAP_SYNC)
961 periph->periph_cap |= PERIPH_CAP_SYNC;
962 if (quirks & PQUIRK_CAP_WIDE16)
963 periph->periph_cap |= PERIPH_CAP_WIDE16;
964
965 /*
966 * Now apply any quirks from the table.
967 */
968 periph->periph_quirks |= quirks;
969 if (periph->periph_version == 0 &&
970 (periph->periph_quirks & PQUIRK_FORCELUNS) == 0)
971 periph->periph_quirks |= PQUIRK_NOLUNS;
972
973 if ((periph->periph_quirks & PQUIRK_NOLUNS) == 0)
974 docontinue = 1;
975
976 locd->len = 2;
977 locd->locs[0] = target;
978 locd->locs[1] = lun;
979
980 if ((cf = config_search_loc(scsibussubmatch, &sc->sc_dev,
981 "scsibus", locd, &sa)) != NULL) {
982 scsipi_insert_periph(chan, periph);
983 /*
984 * XXX Can't assign periph_dev here, because we'll
985 * XXX need it before config_attach() returns. Must
986 * XXX assign it in periph driver.
987 */
988 chld = config_attach_loc(&sc->sc_dev, cf, locd, &sa,
989 scsibusprint);
990 } else {
991 scsibusprint(&sa, sc->sc_dev.dv_xname);
992 aprint_normal(" not configured\n");
993 goto bad;
994 }
995
996 return (docontinue);
997
998 bad:
999 free(periph, M_DEVBUF);
1000 return (docontinue);
1001 }
1002
1003 /****** Entry points for user control of the SCSI bus. ******/
1004
1005 int
1006 scsibusopen(dev, flag, fmt, p)
1007 dev_t dev;
1008 int flag, fmt;
1009 struct proc *p;
1010 {
1011 struct scsibus_softc *sc;
1012 int error, unit = minor(dev);
1013
1014 if (unit >= scsibus_cd.cd_ndevs ||
1015 (sc = scsibus_cd.cd_devs[unit]) == NULL)
1016 return (ENXIO);
1017
1018 if (sc->sc_flags & SCSIBUSF_OPEN)
1019 return (EBUSY);
1020
1021 if ((error = scsipi_adapter_addref(sc->sc_channel->chan_adapter)) != 0)
1022 return (error);
1023
1024 sc->sc_flags |= SCSIBUSF_OPEN;
1025
1026 return (0);
1027 }
1028
1029 int
1030 scsibusclose(dev, flag, fmt, p)
1031 dev_t dev;
1032 int flag, fmt;
1033 struct proc *p;
1034 {
1035 struct scsibus_softc *sc = scsibus_cd.cd_devs[minor(dev)];
1036
1037 scsipi_adapter_delref(sc->sc_channel->chan_adapter);
1038
1039 sc->sc_flags &= ~SCSIBUSF_OPEN;
1040
1041 return (0);
1042 }
1043
1044 int
1045 scsibusioctl(dev, cmd, addr, flag, p)
1046 dev_t dev;
1047 u_long cmd;
1048 caddr_t addr;
1049 int flag;
1050 struct proc *p;
1051 {
1052 struct scsibus_softc *sc = scsibus_cd.cd_devs[minor(dev)];
1053 struct scsipi_channel *chan = sc->sc_channel;
1054 int error;
1055
1056 /*
1057 * Enforce write permission for ioctls that change the
1058 * state of the bus. Host adapter specific ioctls must
1059 * be checked by the adapter driver.
1060 */
1061 switch (cmd) {
1062 case SCBUSIOSCAN:
1063 case SCBUSIODETACH:
1064 case SCBUSIORESET:
1065 if ((flag & FWRITE) == 0)
1066 return (EBADF);
1067 }
1068
1069 switch (cmd) {
1070 case SCBUSIOSCAN:
1071 {
1072 struct scbusioscan_args *a =
1073 (struct scbusioscan_args *)addr;
1074
1075 error = scsi_probe_bus(sc, a->sa_target, a->sa_lun);
1076 break;
1077 }
1078
1079 case SCBUSIODETACH:
1080 {
1081 struct scbusiodetach_args *a =
1082 (struct scbusiodetach_args *)addr;
1083
1084 error = scsipi_target_detach(chan, a->sa_target, a->sa_lun, 0);
1085 break;
1086 }
1087
1088
1089 case SCBUSIORESET:
1090 /* FALLTHROUGH */
1091 default:
1092 if (chan->chan_adapter->adapt_ioctl == NULL)
1093 error = ENOTTY;
1094 else
1095 error = (*chan->chan_adapter->adapt_ioctl)(chan,
1096 cmd, addr, flag, p);
1097 break;
1098 }
1099
1100 return (error);
1101 }
1102