scsipi_ioctl.c revision 1.25.2.2 1 1.25.2.2 thorpej /* $NetBSD: scsipi_ioctl.c,v 1.25.2.2 1997/08/27 23:33:28 thorpej Exp $ */
2 1.25.2.2 thorpej
3 1.25.2.2 thorpej /*
4 1.25.2.2 thorpej * Copyright (c) 1994 Charles Hannum. All rights reserved.
5 1.25.2.2 thorpej *
6 1.25.2.2 thorpej * Redistribution and use in source and binary forms, with or without
7 1.25.2.2 thorpej * modification, are permitted provided that the following conditions
8 1.25.2.2 thorpej * are met:
9 1.25.2.2 thorpej * 1. Redistributions of source code must retain the above copyright
10 1.25.2.2 thorpej * notice, this list of conditions and the following disclaimer.
11 1.25.2.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
12 1.25.2.2 thorpej * notice, this list of conditions and the following disclaimer in the
13 1.25.2.2 thorpej * documentation and/or other materials provided with the distribution.
14 1.25.2.2 thorpej * 3. All advertising materials mentioning features or use of this software
15 1.25.2.2 thorpej * must display the following acknowledgement:
16 1.25.2.2 thorpej * This product includes software developed by Charles Hannum.
17 1.25.2.2 thorpej * 4. The name of the author may not be used to endorse or promote products
18 1.25.2.2 thorpej * derived from this software without specific prior written permission.
19 1.25.2.2 thorpej *
20 1.25.2.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.25.2.2 thorpej * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.25.2.2 thorpej * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.25.2.2 thorpej * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.25.2.2 thorpej * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.25.2.2 thorpej * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.25.2.2 thorpej * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.25.2.2 thorpej * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.25.2.2 thorpej * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.25.2.2 thorpej * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.25.2.2 thorpej */
31 1.25.2.2 thorpej
32 1.25.2.2 thorpej /*
33 1.25.2.2 thorpej * Contributed by HD Associates (hd (at) world.std.com).
34 1.25.2.2 thorpej * Copyright (c) 1992, 1993 HD Associates
35 1.25.2.2 thorpej *
36 1.25.2.2 thorpej * Berkeley style copyright.
37 1.25.2.2 thorpej */
38 1.25.2.2 thorpej
39 1.25.2.2 thorpej #include <sys/types.h>
40 1.25.2.2 thorpej #include <sys/errno.h>
41 1.25.2.2 thorpej #include <sys/param.h>
42 1.25.2.2 thorpej #include <sys/systm.h>
43 1.25.2.2 thorpej #include <sys/malloc.h>
44 1.25.2.2 thorpej #include <sys/buf.h>
45 1.25.2.2 thorpej #include <sys/proc.h>
46 1.25.2.2 thorpej #include <sys/device.h>
47 1.25.2.2 thorpej #include <sys/fcntl.h>
48 1.25.2.2 thorpej
49 1.25.2.2 thorpej #include <dev/scsipi/scsipi_all.h>
50 1.25.2.2 thorpej #include <dev/scsipi/scsi_all.h>
51 1.25.2.2 thorpej #include <dev/scsipi/scsipiconf.h>
52 1.25.2.2 thorpej #include <dev/scsipi/scsiconf.h>
53 1.25.2.2 thorpej #include <sys/scsiio.h>
54 1.25.2.2 thorpej #include "scsibus.h"
55 1.25.2.2 thorpej #include "atapibus.h"
56 1.25.2.2 thorpej
57 1.25.2.2 thorpej struct scsi_ioctl {
58 1.25.2.2 thorpej LIST_ENTRY(scsi_ioctl) si_list;
59 1.25.2.2 thorpej struct buf si_bp;
60 1.25.2.2 thorpej struct uio si_uio;
61 1.25.2.2 thorpej struct iovec si_iov;
62 1.25.2.2 thorpej scsireq_t si_screq;
63 1.25.2.2 thorpej struct scsipi_link *si_sc_link;
64 1.25.2.2 thorpej };
65 1.25.2.2 thorpej
66 1.25.2.2 thorpej LIST_HEAD(, scsi_ioctl) si_head;
67 1.25.2.2 thorpej
68 1.25.2.2 thorpej struct scsi_ioctl *si_get __P((void));
69 1.25.2.2 thorpej void si_free __P((struct scsi_ioctl *));
70 1.25.2.2 thorpej struct scsi_ioctl *si_find __P((struct buf *));
71 1.25.2.2 thorpej void scsistrategy __P((struct buf *));
72 1.25.2.2 thorpej
73 1.25.2.2 thorpej struct scsi_ioctl *
74 1.25.2.2 thorpej si_get()
75 1.25.2.2 thorpej {
76 1.25.2.2 thorpej struct scsi_ioctl *si;
77 1.25.2.2 thorpej int s;
78 1.25.2.2 thorpej
79 1.25.2.2 thorpej si = malloc(sizeof(struct scsi_ioctl), M_TEMP, M_WAITOK);
80 1.25.2.2 thorpej bzero(si, sizeof(struct scsi_ioctl));
81 1.25.2.2 thorpej s = splbio();
82 1.25.2.2 thorpej LIST_INSERT_HEAD(&si_head, si, si_list);
83 1.25.2.2 thorpej splx(s);
84 1.25.2.2 thorpej return (si);
85 1.25.2.2 thorpej }
86 1.25.2.2 thorpej
87 1.25.2.2 thorpej void
88 1.25.2.2 thorpej si_free(si)
89 1.25.2.2 thorpej struct scsi_ioctl *si;
90 1.25.2.2 thorpej {
91 1.25.2.2 thorpej int s;
92 1.25.2.2 thorpej
93 1.25.2.2 thorpej s = splbio();
94 1.25.2.2 thorpej LIST_REMOVE(si, si_list);
95 1.25.2.2 thorpej splx(s);
96 1.25.2.2 thorpej free(si, M_TEMP);
97 1.25.2.2 thorpej }
98 1.25.2.2 thorpej
99 1.25.2.2 thorpej struct scsi_ioctl *
100 1.25.2.2 thorpej si_find(bp)
101 1.25.2.2 thorpej struct buf *bp;
102 1.25.2.2 thorpej {
103 1.25.2.2 thorpej struct scsi_ioctl *si;
104 1.25.2.2 thorpej int s;
105 1.25.2.2 thorpej
106 1.25.2.2 thorpej s = splbio();
107 1.25.2.2 thorpej for (si = si_head.lh_first; si != 0; si = si->si_list.le_next)
108 1.25.2.2 thorpej if (bp == &si->si_bp)
109 1.25.2.2 thorpej break;
110 1.25.2.2 thorpej splx(s);
111 1.25.2.2 thorpej return (si);
112 1.25.2.2 thorpej }
113 1.25.2.2 thorpej
114 1.25.2.2 thorpej /*
115 1.25.2.2 thorpej * We let the user interpret his own sense in the generic scsi world.
116 1.25.2.2 thorpej * This routine is called at interrupt time if the SCSI_USER bit was set
117 1.25.2.2 thorpej * in the flags passed to scsi_scsipi_cmd(). No other completion processing
118 1.25.2.2 thorpej * takes place, even if we are running over another device driver.
119 1.25.2.2 thorpej * The lower level routines that call us here, will free the xs and restart
120 1.25.2.2 thorpej * the device's queue if such exists.
121 1.25.2.2 thorpej */
122 1.25.2.2 thorpej void
123 1.25.2.2 thorpej scsipi_user_done(xs)
124 1.25.2.2 thorpej struct scsipi_xfer *xs;
125 1.25.2.2 thorpej {
126 1.25.2.2 thorpej struct buf *bp;
127 1.25.2.2 thorpej struct scsi_ioctl *si;
128 1.25.2.2 thorpej scsireq_t *screq;
129 1.25.2.2 thorpej struct scsipi_link *sc_link;
130 1.25.2.2 thorpej
131 1.25.2.2 thorpej bp = xs->bp;
132 1.25.2.2 thorpej if (!bp) { /* ALL user requests must have a buf */
133 1.25.2.2 thorpej xs->sc_link->sc_print_addr(xs->sc_link);
134 1.25.2.2 thorpej printf("User command with no buf\n");
135 1.25.2.2 thorpej return;
136 1.25.2.2 thorpej }
137 1.25.2.2 thorpej si = si_find(bp);
138 1.25.2.2 thorpej if (!si) {
139 1.25.2.2 thorpej xs->sc_link->sc_print_addr(xs->sc_link);
140 1.25.2.2 thorpej printf("User command with no ioctl\n");
141 1.25.2.2 thorpej return;
142 1.25.2.2 thorpej }
143 1.25.2.2 thorpej screq = &si->si_screq;
144 1.25.2.2 thorpej sc_link = si->si_sc_link;
145 1.25.2.2 thorpej SC_DEBUG(xs->sc_link, SDEV_DB2, ("user-done\n"));
146 1.25.2.2 thorpej
147 1.25.2.2 thorpej screq->retsts = 0;
148 1.25.2.2 thorpej screq->status = xs->status;
149 1.25.2.2 thorpej switch (xs->error) {
150 1.25.2.2 thorpej case XS_NOERROR:
151 1.25.2.2 thorpej SC_DEBUG(sc_link, SDEV_DB3, ("no error\n"));
152 1.25.2.2 thorpej screq->datalen_used = xs->datalen - xs->resid; /* probably rubbish */
153 1.25.2.2 thorpej screq->retsts = SCCMD_OK;
154 1.25.2.2 thorpej break;
155 1.25.2.2 thorpej case XS_SENSE:
156 1.25.2.2 thorpej SC_DEBUG(sc_link, SDEV_DB3, ("have sense\n"));
157 1.25.2.2 thorpej screq->senselen_used = min(sizeof(xs->sense.scsi_sense), SENSEBUFLEN);
158 1.25.2.2 thorpej bcopy(&xs->sense.scsi_sense, screq->sense, screq->senselen);
159 1.25.2.2 thorpej screq->retsts = SCCMD_SENSE;
160 1.25.2.2 thorpej break;
161 1.25.2.2 thorpej case XS_DRIVER_STUFFUP:
162 1.25.2.2 thorpej sc_link->sc_print_addr(sc_link);
163 1.25.2.2 thorpej printf("host adapter code inconsistency\n");
164 1.25.2.2 thorpej screq->retsts = SCCMD_UNKNOWN;
165 1.25.2.2 thorpej break;
166 1.25.2.2 thorpej case XS_TIMEOUT:
167 1.25.2.2 thorpej SC_DEBUG(sc_link, SDEV_DB3, ("timeout\n"));
168 1.25.2.2 thorpej screq->retsts = SCCMD_TIMEOUT;
169 1.25.2.2 thorpej break;
170 1.25.2.2 thorpej case XS_BUSY:
171 1.25.2.2 thorpej SC_DEBUG(sc_link, SDEV_DB3, ("busy\n"));
172 1.25.2.2 thorpej screq->retsts = SCCMD_BUSY;
173 1.25.2.2 thorpej break;
174 1.25.2.2 thorpej default:
175 1.25.2.2 thorpej sc_link->sc_print_addr(sc_link);
176 1.25.2.2 thorpej printf("unknown error category from host adapter code\n");
177 1.25.2.2 thorpej screq->retsts = SCCMD_UNKNOWN;
178 1.25.2.2 thorpej break;
179 1.25.2.2 thorpej }
180 1.25.2.2 thorpej biodone(bp); /* we're waiting on it in scsi_strategy() */
181 1.25.2.2 thorpej }
182 1.25.2.2 thorpej
183 1.25.2.2 thorpej
184 1.25.2.2 thorpej /* Pseudo strategy function
185 1.25.2.2 thorpej * Called by scsipi_do_ioctl() via physio/physstrat if there is to
186 1.25.2.2 thorpej * be data transfered, and directly if there is no data transfer.
187 1.25.2.2 thorpej *
188 1.25.2.2 thorpej * Should I reorganize this so it returns to physio instead
189 1.25.2.2 thorpej * of sleeping in scsiio_scsipi_cmd? Is there any advantage, other
190 1.25.2.2 thorpej * than avoiding the probable duplicate wakeup in iodone? [PD]
191 1.25.2.2 thorpej *
192 1.25.2.2 thorpej * No, seems ok to me... [JRE]
193 1.25.2.2 thorpej * (I don't see any duplicate wakeups)
194 1.25.2.2 thorpej *
195 1.25.2.2 thorpej * Can't be used with block devices or raw_read/raw_write directly
196 1.25.2.2 thorpej * from the cdevsw/bdevsw tables because they couldn't have added
197 1.25.2.2 thorpej * the screq structure. [JRE]
198 1.25.2.2 thorpej */
199 1.25.2.2 thorpej void
200 1.25.2.2 thorpej scsistrategy(bp)
201 1.25.2.2 thorpej struct buf *bp;
202 1.25.2.2 thorpej {
203 1.25.2.2 thorpej struct scsi_ioctl *si;
204 1.25.2.2 thorpej scsireq_t *screq;
205 1.25.2.2 thorpej struct scsipi_link *sc_link;
206 1.25.2.2 thorpej int error;
207 1.25.2.2 thorpej int flags = 0;
208 1.25.2.2 thorpej int s;
209 1.25.2.2 thorpej
210 1.25.2.2 thorpej si = si_find(bp);
211 1.25.2.2 thorpej if (!si) {
212 1.25.2.2 thorpej printf("user_strat: No ioctl\n");
213 1.25.2.2 thorpej error = EINVAL;
214 1.25.2.2 thorpej goto bad;
215 1.25.2.2 thorpej }
216 1.25.2.2 thorpej screq = &si->si_screq;
217 1.25.2.2 thorpej sc_link = si->si_sc_link;
218 1.25.2.2 thorpej SC_DEBUG(sc_link, SDEV_DB2, ("user_strategy\n"));
219 1.25.2.2 thorpej
220 1.25.2.2 thorpej /*
221 1.25.2.2 thorpej * We're in trouble if physio tried to break up the transfer.
222 1.25.2.2 thorpej */
223 1.25.2.2 thorpej if (bp->b_bcount != screq->datalen) {
224 1.25.2.2 thorpej sc_link->sc_print_addr(sc_link);
225 1.25.2.2 thorpej printf("physio split the request.. cannot proceed\n");
226 1.25.2.2 thorpej error = EIO;
227 1.25.2.2 thorpej goto bad;
228 1.25.2.2 thorpej }
229 1.25.2.2 thorpej
230 1.25.2.2 thorpej if (screq->timeout == 0) {
231 1.25.2.2 thorpej error = EINVAL;
232 1.25.2.2 thorpej goto bad;
233 1.25.2.2 thorpej }
234 1.25.2.2 thorpej
235 1.25.2.2 thorpej if (screq->cmdlen > sizeof(struct scsipi_generic)) {
236 1.25.2.2 thorpej sc_link->sc_print_addr(sc_link);
237 1.25.2.2 thorpej printf("cmdlen too big\n");
238 1.25.2.2 thorpej error = EFAULT;
239 1.25.2.2 thorpej goto bad;
240 1.25.2.2 thorpej }
241 1.25.2.2 thorpej
242 1.25.2.2 thorpej if (screq->flags & SCCMD_READ)
243 1.25.2.2 thorpej flags |= SCSI_DATA_IN;
244 1.25.2.2 thorpej if (screq->flags & SCCMD_WRITE)
245 1.25.2.2 thorpej flags |= SCSI_DATA_OUT;
246 1.25.2.2 thorpej if (screq->flags & SCCMD_TARGET)
247 1.25.2.2 thorpej flags |= SCSI_TARGET;
248 1.25.2.2 thorpej if (screq->flags & SCCMD_ESCAPE)
249 1.25.2.2 thorpej flags |= SCSI_ESCAPE;
250 1.25.2.2 thorpej
251 1.25.2.2 thorpej error = sc_link->scsipi_cmd(sc_link, (struct scsipi_generic *)screq->cmd,
252 1.25.2.2 thorpej screq->cmdlen, (u_char *)bp->b_data, screq->datalen,
253 1.25.2.2 thorpej 0, /* user must do the retries *//* ignored */
254 1.25.2.2 thorpej screq->timeout, bp, flags | SCSI_USER | SCSI_NOSLEEP);
255 1.25.2.2 thorpej
256 1.25.2.2 thorpej /* because there is a bp, scsi_scsipi_cmd will return immediatly */
257 1.25.2.2 thorpej if (error)
258 1.25.2.2 thorpej goto bad;
259 1.25.2.2 thorpej
260 1.25.2.2 thorpej SC_DEBUG(sc_link, SDEV_DB3, ("about to sleep\n"));
261 1.25.2.2 thorpej s = splbio();
262 1.25.2.2 thorpej while ((bp->b_flags & B_DONE) == 0)
263 1.25.2.2 thorpej tsleep(bp, PRIBIO, "scistr", 0);
264 1.25.2.2 thorpej splx(s);
265 1.25.2.2 thorpej SC_DEBUG(sc_link, SDEV_DB3, ("back from sleep\n"));
266 1.25.2.2 thorpej
267 1.25.2.2 thorpej return;
268 1.25.2.2 thorpej
269 1.25.2.2 thorpej bad:
270 1.25.2.2 thorpej bp->b_flags |= B_ERROR;
271 1.25.2.2 thorpej bp->b_error = error;
272 1.25.2.2 thorpej biodone(bp);
273 1.25.2.2 thorpej }
274 1.25.2.2 thorpej
275 1.25.2.2 thorpej /*
276 1.25.2.2 thorpej * Something (e.g. another driver) has called us
277 1.25.2.2 thorpej * with an sc_link for a target/lun/adapter, and a scsi
278 1.25.2.2 thorpej * specific ioctl to perform, better try.
279 1.25.2.2 thorpej * If user-level type command, we must still be running
280 1.25.2.2 thorpej * in the context of the calling process
281 1.25.2.2 thorpej */
282 1.25.2.2 thorpej int
283 1.25.2.2 thorpej scsipi_do_ioctl(sc_link, dev, cmd, addr, flag, p)
284 1.25.2.2 thorpej struct scsipi_link *sc_link;
285 1.25.2.2 thorpej dev_t dev;
286 1.25.2.2 thorpej u_long cmd;
287 1.25.2.2 thorpej caddr_t addr;
288 1.25.2.2 thorpej int flag;
289 1.25.2.2 thorpej struct proc *p;
290 1.25.2.2 thorpej {
291 1.25.2.2 thorpej int error;
292 1.25.2.2 thorpej
293 1.25.2.2 thorpej SC_DEBUG(sc_link, SDEV_DB2, ("scsipi_do_ioctl(0x%lx)\n", cmd));
294 1.25.2.2 thorpej
295 1.25.2.2 thorpej /* Check for the safe-ness of this request. */
296 1.25.2.2 thorpej switch (cmd) {
297 1.25.2.2 thorpej case SCIOCIDENTIFY:
298 1.25.2.2 thorpej break;
299 1.25.2.2 thorpej case SCIOCCOMMAND:
300 1.25.2.2 thorpej if ((((scsireq_t *)addr)->flags & SCCMD_READ) == 0 &&
301 1.25.2.2 thorpej (flag & FWRITE) == 0)
302 1.25.2.2 thorpej return EBADF;
303 1.25.2.2 thorpej break;
304 1.25.2.2 thorpej default:
305 1.25.2.2 thorpej if ((flag & FWRITE) == 0)
306 1.25.2.2 thorpej return EBADF;
307 1.25.2.2 thorpej }
308 1.25.2.2 thorpej
309 1.25.2.2 thorpej switch(cmd) {
310 1.25.2.2 thorpej case SCIOCCOMMAND: {
311 1.25.2.2 thorpej scsireq_t *screq = (scsireq_t *)addr;
312 1.25.2.2 thorpej struct scsi_ioctl *si;
313 1.25.2.2 thorpej int len;
314 1.25.2.2 thorpej
315 1.25.2.2 thorpej si = si_get();
316 1.25.2.2 thorpej si->si_screq = *screq;
317 1.25.2.2 thorpej si->si_sc_link = sc_link;
318 1.25.2.2 thorpej len = screq->datalen;
319 1.25.2.2 thorpej if (len) {
320 1.25.2.2 thorpej si->si_iov.iov_base = screq->databuf;
321 1.25.2.2 thorpej si->si_iov.iov_len = len;
322 1.25.2.2 thorpej si->si_uio.uio_iov = &si->si_iov;
323 1.25.2.2 thorpej si->si_uio.uio_iovcnt = 1;
324 1.25.2.2 thorpej si->si_uio.uio_resid = len;
325 1.25.2.2 thorpej si->si_uio.uio_offset = 0;
326 1.25.2.2 thorpej si->si_uio.uio_segflg = UIO_USERSPACE;
327 1.25.2.2 thorpej si->si_uio.uio_rw =
328 1.25.2.2 thorpej (screq->flags & SCCMD_READ) ? UIO_READ : UIO_WRITE;
329 1.25.2.2 thorpej si->si_uio.uio_procp = p;
330 1.25.2.2 thorpej error = physio(scsistrategy, &si->si_bp, dev,
331 1.25.2.2 thorpej (screq->flags & SCCMD_READ) ? B_READ : B_WRITE,
332 1.25.2.2 thorpej sc_link->adapter->scsipi_minphys, &si->si_uio);
333 1.25.2.2 thorpej } else {
334 1.25.2.2 thorpej /* if no data, no need to translate it.. */
335 1.25.2.2 thorpej si->si_bp.b_flags = 0;
336 1.25.2.2 thorpej si->si_bp.b_data = 0;
337 1.25.2.2 thorpej si->si_bp.b_bcount = 0;
338 1.25.2.2 thorpej si->si_bp.b_dev = dev;
339 1.25.2.2 thorpej si->si_bp.b_proc = p;
340 1.25.2.2 thorpej scsistrategy(&si->si_bp);
341 1.25.2.2 thorpej error = si->si_bp.b_error;
342 1.25.2.2 thorpej }
343 1.25.2.2 thorpej *screq = si->si_screq;
344 1.25.2.2 thorpej si_free(si);
345 1.25.2.2 thorpej return error;
346 1.25.2.2 thorpej }
347 1.25.2.2 thorpej case SCIOCDEBUG: {
348 1.25.2.2 thorpej int level = *((int *)addr);
349 1.25.2.2 thorpej
350 1.25.2.2 thorpej SC_DEBUG(sc_link, SDEV_DB3, ("debug set to %d\n", level));
351 1.25.2.2 thorpej sc_link->flags &= ~SDEV_DBX; /* clear debug bits */
352 1.25.2.2 thorpej if (level & 1)
353 1.25.2.2 thorpej sc_link->flags |= SDEV_DB1;
354 1.25.2.2 thorpej if (level & 2)
355 1.25.2.2 thorpej sc_link->flags |= SDEV_DB2;
356 1.25.2.2 thorpej if (level & 4)
357 1.25.2.2 thorpej sc_link->flags |= SDEV_DB3;
358 1.25.2.2 thorpej if (level & 8)
359 1.25.2.2 thorpej sc_link->flags |= SDEV_DB4;
360 1.25.2.2 thorpej return 0;
361 1.25.2.2 thorpej }
362 1.25.2.2 thorpej #if NSCSIBUS > 0
363 1.25.2.2 thorpej case SCIOCREPROBE: {
364 1.25.2.2 thorpej struct scsi_addr *sca = (struct scsi_addr *)addr;
365 1.25.2.2 thorpej if (sca->type != TYPE_SCSI) {
366 1.25.2.2 thorpej return ENODEV;
367 1.25.2.2 thorpej }
368 1.25.2.2 thorpej return scsi_probe_busses(sca->addr.scsi.scbus, sca->addr.scsi.target,
369 1.25.2.2 thorpej sca->addr.scsi.lun);
370 1.25.2.2 thorpej }
371 1.25.2.2 thorpej #endif
372 1.25.2.2 thorpej case SCIOCRECONFIG:
373 1.25.2.2 thorpej case SCIOCDECONFIG:
374 1.25.2.2 thorpej return EINVAL;
375 1.25.2.2 thorpej case SCIOCIDENTIFY: {
376 1.25.2.2 thorpej struct scsi_addr *sca = (struct scsi_addr *)addr;
377 1.25.2.2 thorpej if (sc_link->type == BUS_SCSI) {
378 1.25.2.2 thorpej sca->type = TYPE_SCSI;
379 1.25.2.2 thorpej sca->addr.scsi.scbus = sc_link->scsipi_scsi.scsibus;
380 1.25.2.2 thorpej sca->addr.scsi.target = sc_link->scsipi_scsi.target;
381 1.25.2.2 thorpej sca->addr.scsi.lun = sc_link->scsipi_scsi.lun;
382 1.25.2.2 thorpej return 0;
383 1.25.2.2 thorpej }
384 1.25.2.2 thorpej if (sc_link->type == BUS_ATAPI) {
385 1.25.2.2 thorpej sca->type = TYPE_ATAPI;
386 1.25.2.2 thorpej sca->addr.atapi.atbus = sc_link->scsipi_atapi.atapibus;
387 1.25.2.2 thorpej sca->addr.atapi.drive = sc_link->scsipi_atapi.drive;
388 1.25.2.2 thorpej return 0;
389 1.25.2.2 thorpej }
390 1.25.2.2 thorpej return ENXIO;
391 1.25.2.2 thorpej }
392 1.25.2.2 thorpej default:
393 1.25.2.2 thorpej return ENOTTY;
394 1.25.2.2 thorpej }
395 1.25.2.2 thorpej
396 1.25.2.2 thorpej #ifdef DIAGNOSTIC
397 1.25.2.2 thorpej panic("scsipi_do_ioctl: impossible");
398 1.25.2.2 thorpej #endif
399 1.25.2.2 thorpej }
400