xref: /csrg-svn/sys/tahoe/vba/ik.c (revision 40735)
1 /*
2  * Copyright (c) 1986 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  *	@(#)ik.c	7.5 (Berkeley) 04/03/90
18  */
19 
20 #include "ik.h"
21 #if NIK > 0
22 /*
23  * PS300/IKON DR-11W Device Driver.
24  */
25 #include "param.h"
26 #include "buf.h"
27 #include "cmap.h"
28 #include "conf.h"
29 #include "dkstat.h"
30 #include "map.h"
31 #include "systm.h"
32 #include "user.h"
33 #include "vmmac.h"
34 #include "proc.h"
35 #include "kernel.h"
36 #include "syslog.h"
37 
38 #include "../tahoe/mtpr.h"
39 #include "../tahoe/pte.h"
40 
41 #include "../tahoevba/vbavar.h"
42 #include "../tahoevba/ikreg.h"
43 #include "../tahoevba/psreg.h"
44 #include "../tahoevba/psproto.h"
45 
46 int	ikprobe(), ikattach(), iktimer();
47 struct	vba_device *ikinfo[NIK];
48 long	ikstd[] = { 0 };
49 struct	vba_driver ikdriver = { ikprobe, 0, ikattach, 0, ikstd, "ik", ikinfo };
50 
51 #define splik()		spl4()
52 /*
53  * Devices are organized in pairs with the odd valued
54  * device being used for ``diagnostic'' purposes.  That
55  * is diagnostic devices don't get auto-attach'd and
56  * detach'd on open-close.
57  */
58 #define IKUNIT(dev)	(minor(dev) >> 1)
59 #define IKDIAG(dev)	(minor(dev) & 01)	/* is a diagnostic unit */
60 
61 struct	ik_softc {
62 	uid_t	is_uid;		/* uid of open processes */
63 	u_short is_timeout;	/* current timeout (seconds) */
64 	u_short is_error;	/* internal error codes */
65 	u_short is_flags;
66 #define IKF_ATTACHED	0x1	/* unit is attached (not used yet) */
67 	union {
68 		u_short w[2];
69 		u_long	l;
70 	} is_nameaddr;		/* address of last symbol lookup */
71 	caddr_t is_buf[PS_MAXDMA];/* i/o buffer XXX */
72 } ik_softc[NIK];
73 
74 struct	buf iktab[NIK];		/* unit command queue headers */
75 struct	buf rikbuf[NIK];	/* buffers for read/write operations */
76 struct	buf cikbuf[NIK];	/* buffers for control operations */
77 
78 /* buf overlay definitions */
79 #define b_command	b_resid
80 
81 int	ikdiotimo = PS_DIOTIMO; /* dio polling timeout */
82 int	iktimeout = PS_TIMEOUT; /* attention/dma timeout (in hz) */
83 
84 ikprobe(reg, vi)
85 	caddr_t reg;
86 	struct vba_device *vi;
87 {
88 	register int br, cvec;		/* r12, r11 */
89 	register struct ikdevice *ik;
90 
91 #ifdef lint
92 	br = 0; cvec = br; br = cvec;
93 	ikintr(0);
94 #endif
95 	if (badaddr(reg, 2))
96 		return (0);
97 	ik = (struct ikdevice *)reg;
98 	ik->ik_vec = --vi->ui_hd->vh_lastiv;
99 	/*
100 	 * Use extended non-privileged address modifier
101 	 * to avoid address overlap with 24-bit devices.
102 	 */
103 	ik->ik_mod = 0xf1;			/* address modifier */
104 	/*
105 	 * Try and reset the PS300.  Since this
106 	 * won't work if it's powered off, we
107 	 * can't use sucess/failure to decide
108 	 * if the device is present.
109 	 */
110 	br = 0;
111 	(void) psreset(ik, IKCSR_IENA);
112 	if (br == 0)				/* XXX */
113 		br = 0x18, cvec = ik->ik_vec;	/* XXX */
114 	return (sizeof (struct ikdevice));
115 }
116 
117 /*
118  * Perform a ``hard'' reset.
119  */
120 psreset(ik, iena)
121 	register struct ikdevice *ik;
122 {
123 
124 	ik->ik_csr = IKCSR_MCLR|iena;
125 	DELAY(10000);
126 	ik->ik_csr = IKCSR_FNC3|iena;
127 	if (!iena)
128 		return (dioread(ik) == PS_RESET);
129 	return (1);
130 }
131 
132 ikattach(vi)
133 	struct vba_device *vi;
134 {
135 
136 	ik_softc[vi->ui_unit].is_uid = -1;
137 }
138 
139 /*
140  * Open a PS300 and attach.  We allow multiple
141  * processes with the same uid to share a unit.
142  */
143 /*ARGSUSED*/
144 ikopen(dev, flag)
145 	dev_t dev;
146 	int flag;
147 {
148 	register int unit = IKUNIT(dev);
149 	register struct ik_softc *sc;
150 	struct vba_device *vi;
151 	struct ikdevice *ik;
152 	int reset;
153 
154 	if (unit >= NIK || (vi = ikinfo[unit]) == 0 || vi->ui_alive == 0)
155 		return (ENXIO);
156 	sc = &ik_softc[unit];
157 	if (sc->is_uid != (uid_t)-1 && sc->is_uid != u.u_uid)
158 		return (EBUSY);
159 	if (sc->is_uid == (uid_t)-1) {
160 		sc->is_timeout = 0;
161 		timeout(iktimer, (caddr_t)unit, hz);
162 		/*
163 		 * Perform PS300 attach for first process.
164 		 */
165 		if (!IKDIAG(dev)) {
166 			reset = 0;
167 		again:
168 			if (ikcommand(dev, PS_ATTACH, 1)) {
169 				/*
170 				 * If attach fails, perform a hard
171 				 * reset once, then retry the command.
172 				 */
173 				ik = (struct ikdevice *)ikinfo[unit]->ui_addr;
174 				if (!reset++ && psreset(ik, 0))
175 					goto again;
176 				untimeout(iktimer, (caddr_t)unit);
177 				return (EIO);
178 			}
179 		}
180 		sc->is_uid = u.u_uid;
181 	}
182 	return (0);
183 }
184 
185 /*ARGSUSED*/
186 ikclose(dev, flag)
187 	dev_t dev;
188 	int flag;
189 {
190 	int unit = IKUNIT(dev);
191 	register struct ik_softc *sc = &ik_softc[unit];
192 
193 	if (!IKDIAG(dev))
194 		(void) ikcommand(dev, PS_DETACH, 1);	/* auto detach */
195 	sc->is_uid = -1;
196 	untimeout(iktimer, (caddr_t)unit);
197 	return (0);
198 }
199 
200 ikread(dev, uio)
201 	dev_t dev;
202 	struct uio *uio;
203 {
204 
205 	return (ikrw(dev, uio, B_READ));
206 }
207 
208 ikwrite(dev, uio)
209 	dev_t dev;
210 	struct uio *uio;
211 {
212 
213 	return (ikrw(dev, uio, B_WRITE));
214 }
215 
216 /*
217  * Take read/write request and perform physical i/o
218  * transaction with PS300.  This involves constructing
219  * a physical i/o request vector based on the uio
220  * vector, performing the dma, and, finally, moving
221  * the data to it's final destination (because of CCI
222  * VERSAbus bogosities).
223  */
224 ikrw(dev, uio, rw)
225 	dev_t dev;
226 	register struct uio *uio;
227 	int rw;
228 {
229 	int error, unit = IKUNIT(dev), s, wrcmd;
230 	register struct buf *bp;
231 	register struct iovec *iov;
232 	register struct psalist *ap;
233 	struct ik_softc *sc = &ik_softc[unit];
234 
235 	if (unit >= NIK)
236 		return (ENXIO);
237 	bp = &rikbuf[unit];
238 	error = 0, iov = uio->uio_iov, wrcmd = PS_WRPHY;
239 	for (; !error && uio->uio_iovcnt; iov++, uio->uio_iovcnt--) {
240 		/*
241 		 * Hack way to set PS300 address w/o doing an lseek
242 		 * and specify write physical w/ refresh synchronization.
243 		 */
244 		if (iov->iov_len == 0) {
245 			if ((int)iov->iov_base&PSIO_SYNC)
246 				wrcmd = PS_WRPHY_SYNC;
247 			uio->uio_offset = (int)iov->iov_base & ~PSIO_SYNC;
248 			continue;
249 		}
250 		if (iov->iov_len > PS_MAXDMA) {
251 			sc->is_error = PSERROR_INVALBC, error = EINVAL;
252 			continue;
253 		}
254 		if ((int)uio->uio_offset&01) {
255 			sc->is_error = PSERROR_BADADDR, error = EINVAL;
256 			continue;
257 		}
258 		s = splbio();
259 		while (bp->b_flags&B_BUSY) {
260 			bp->b_flags |= B_WANTED;
261 			sleep((caddr_t)bp, PRIBIO+1);
262 		}
263 		splx(s);
264 		bp->b_flags = B_BUSY | rw;
265 		/*
266 		 * Construct address descriptor in buffer.
267 		 */
268 		ap = (struct psalist *)sc->is_buf;
269 		ap->nblocks = 1;
270 		/* work-around dr300 word swapping */
271 		ap->addr[0] = uio->uio_offset & 0xffff;
272 		ap->addr[1] = uio->uio_offset >> 16;
273 		ap->wc = (iov->iov_len + 1) >> 1;
274 		if (rw == B_WRITE) {
275 			error = copyin(iov->iov_base, (caddr_t)&ap[1],
276 			    (unsigned)iov->iov_len);
277 			if (!error)
278 				error = ikcommand(dev, wrcmd,
279 				    iov->iov_len + sizeof (*ap));
280 		} else {
281 			caddr_t cp;
282 			int len;
283 
284 			error = ikcommand(dev, PS_RDPHY, sizeof (*ap));
285 			cp = (caddr_t)&ap[1], len = iov->iov_len;
286 			for (; len > 0; len -= NBPG, cp += NBPG)
287 				mtpr(P1DC, cp);
288 			if (!error)
289 				error = copyout((caddr_t)&ap[1], iov->iov_base,
290 				    (unsigned)iov->iov_len);
291 		}
292 		(void) splbio();
293 		if (bp->b_flags&B_WANTED)
294 			wakeup((caddr_t)bp);
295 		splx(s);
296 		uio->uio_resid -= iov->iov_len;
297 		uio->uio_offset += iov->iov_len;
298 		bp->b_flags &= ~(B_BUSY|B_WANTED);
299 	}
300 	return (error);
301 }
302 
303 /*
304  * Perform a PS300 command.
305  */
306 ikcommand(dev, com, count)
307 	dev_t dev;
308 	int com, count;
309 {
310 	register struct buf *bp;
311 	register int s;
312 	int error;
313 
314 	bp = &cikbuf[IKUNIT(dev)];
315 	s = splik();
316 	while (bp->b_flags&B_BUSY) {
317 		if (bp->b_flags&B_DONE)
318 			break;
319 		bp->b_flags |= B_WANTED;
320 		sleep((caddr_t)bp, PRIBIO);
321 	}
322 	bp->b_flags = B_BUSY|B_READ;
323 	splx(s);
324 	bp->b_dev = dev;
325 	bp->b_command = com;
326 	bp->b_bcount = count;
327 	ikstrategy(bp);
328 	error = biowait(bp);
329 	if (bp->b_flags&B_WANTED)
330 		wakeup((caddr_t)bp);
331 	bp->b_flags &= B_ERROR;
332 	return (error);
333 }
334 
335 /*
336  * Physio strategy routine
337  */
338 ikstrategy(bp)
339 	register struct buf *bp;
340 {
341 	register struct buf *dp;
342 
343 	/*
344 	 * Put request at end of controller queue.
345 	 */
346 	dp = &iktab[IKUNIT(bp->b_dev)];
347 	bp->av_forw = NULL;
348 	(void) splik();
349 	if (dp->b_actf != NULL) {
350 		dp->b_actl->av_forw = bp;
351 		dp->b_actl = bp;
352 	} else
353 		dp->b_actf = dp->b_actl = bp;
354 	if (!dp->b_active)
355 		ikstart(dp);
356 	(void) spl0();
357 }
358 
359 /*
360  * Start the next command on the controller's queue.
361  */
362 ikstart(dp)
363 	register struct buf *dp;
364 {
365 	register struct buf *bp;
366 	register struct ikdevice *ik;
367 	register struct ik_softc *sc;
368 	u_short bc, csr;
369 	u_int addr;
370 	int unit;
371 
372 loop:
373 	/*
374 	 * Pull a request off the controller queue
375 	 */
376 	if ((bp = dp->b_actf) == NULL) {
377 		dp->b_active = 0;
378 		return;
379 	}
380 	/*
381 	 * Mark controller busy and process this request.
382 	 */
383 	dp->b_active = 1;
384 	unit = IKUNIT(bp->b_dev);
385 	sc = &ik_softc[unit];
386 	ik = (struct ikdevice *)ikinfo[unit]->ui_addr;
387 	switch ((int)bp->b_command) {
388 
389 	case PS_ATTACH:		/* logical unit attach */
390 	case PS_DETACH:		/* logical unit detach */
391 	case PS_LOOKUP:		/* name lookup */
392 	case PS_RDPHY:		/* physical i/o read */
393 	case PS_WRPHY:		/* physical i/o write */
394 	case PS_WRPHY_SYNC:	/* physical i/o write w/ sync */
395 		/*
396 		 * Handshake command and, optionally,
397 		 * byte count and byte swap flag.
398 		 */
399 		if (sc->is_error = diowrite(ik, (u_short)bp->b_command))
400 			goto bad;
401 		if (bp->b_command < PS_DETACH) {
402 			if (sc->is_error = diowrite(ik, (u_short)bp->b_bcount))
403 				goto bad;
404 			if (sc->is_error = diowrite(ik, (u_short)0 /* !swab */))
405 				goto bad;
406 		}
407 		/*
408 		 * Set timeout and wait for an attention interrupt.
409 		 */
410 		sc->is_timeout = iktimeout;
411 		return;
412 
413 	case PS_DMAOUT:		/* dma data host->PS300 */
414 		bc = bp->b_bcount;
415 		csr = IKCSR_CYCLE;
416 		break;
417 
418 	case PS_DMAIN:		/* dma data PS300->host */
419 		bc = bp->b_bcount;
420 		csr = IKCSR_CYCLE|IKCSR_FNC1;
421 		break;
422 
423 	default:
424 		log(LOG_ERR, "ik%d: bad cmd %x\n", unit, bp->b_command);
425 		sc->is_error = PSERROR_BADCMD;
426 		goto bad;
427 	}
428 	/* initiate dma transfer */
429 	addr = vtoph((struct proc *)0, (unsigned)sc->is_buf);
430 	ik->ik_bahi = addr >> 17;
431 	ik->ik_balo = (addr >> 1) & 0xffff;
432 	ik->ik_wc = ((bc + 1) >> 1) - 1;	/* round & convert */
433 	ik->ik_pulse = IKPULSE_RATTF|IKPULSE_RDMAF;
434 	sc->is_timeout = iktimeout;
435 	ik->ik_csr = IKCSR_IENA|IKCSR_GO|csr;
436 	return;
437 bad:
438 	bp->b_flags |= B_ERROR;
439 	dp->b_actf = bp->av_forw;		/* remove from queue */
440 	biodone(bp);
441 	goto loop;
442 }
443 
444 #define FETCHWORD(i) { \
445 	v = dioread(ik); \
446 	if (v == -1) { \
447 		sc->is_error = PSERROR_NAMETIMO; \
448 		goto bad; \
449 	} \
450 	sc->is_nameaddr.w[i] = v; \
451 }
452 
453 /*
454  * Process a device interrupt.
455  */
456 ikintr(ikon)
457 	int ikon;
458 {
459 	register struct ikdevice *ik;
460 	register struct buf *bp, *dp;
461 	struct ik_softc *sc;
462 	register u_short data;
463 	int v;
464 
465 	/* should go by controller, but for now... */
466 	if (ikinfo[ikon] == 0)
467 		return;
468 	ik = (struct ikdevice *)ikinfo[ikon]->ui_addr;
469 	/*
470 	 * Discard all non-attention interrupts.  The
471 	 * interrupts we're throwing away should all be
472 	 * associated with DMA completion.
473 	 */
474 	data = ik->ik_data;
475 	if ((ik->ik_csr&(IKCSR_ATTF|IKCSR_STATC)) != IKCSR_ATTF) {
476 		ik->ik_pulse = IKPULSE_RATTF|IKPULSE_RDMAF|IKPULSE_SIENA;
477 		return;
478 	}
479 	/*
480 	 * Fetch attention code immediately.
481 	 */
482 	ik->ik_csr = IKCSR_RATTF|IKCSR_RDMAF|IKCSR_FNC1;
483 	ik->ik_pulse = IKPULSE_FNC2;
484 	/*
485 	 * Get device and block structures, and a pointer
486 	 * to the vba_device for the device.  We receive an
487 	 * unsolicited interrupt whenever the PS300 is power
488 	 * cycled (so ignore it in that case).
489 	 */
490 	dp = &iktab[ikon];
491 	if ((bp = dp->b_actf) == NULL) {
492 		if (PS_CODE(data) != PS_RESET)		/* power failure */
493 			log(LOG_WARNING, "ik%d: spurious interrupt, code %x\n",
494 			    ikon, data);
495 		goto enable;
496 	}
497 	sc = &ik_softc[IKUNIT(bp->b_dev)];
498 	sc->is_timeout = 0;			/* disable timer */
499 	switch (PS_CODE(data)) {
500 
501 	case PS_LOOKUP:				/* name lookup */
502 		if (data == PS_LOOKUP) {	/* dma name */
503 			bp->b_command = PS_DMAOUT;
504 			goto opcont;
505 		}
506 		if (data == PS_DMAOK(PS_LOOKUP)) {
507 			/* reenable interrupt and wait for address */
508 			sc->is_timeout = iktimeout;
509 			goto enable;
510 		}
511 		/*
512 		 * Address should be present, extract it one
513 		 * word at a time from the PS300 (yech).
514 		 */
515 		if (data != PS_ADROK(PS_LOOKUP))
516 			goto bad;
517 		FETCHWORD(0);
518 		FETCHWORD(1);
519 		goto opdone;
520 
521 	case PS_WRPHY_SYNC:			/* physical i/o write w/ sync */
522 		if (data == PS_WRPHY_SYNC) {	/* start dma transfer */
523 			bp->b_command = PS_DMAOUT;
524 			goto opcont;
525 		}
526 		if (data != PS_DMAOK(PS_WRPHY_SYNC))
527 			goto bad;
528 		goto opdone;
529 
530 	case PS_WRPHY:				/* physical i/o write */
531 		if (data == PS_WRPHY) { /* start dma transfer */
532 			bp->b_command = PS_DMAOUT;
533 			goto opcont;
534 		}
535 		if (data != PS_DMAOK(PS_WRPHY))
536 			goto bad;
537 		goto opdone;
538 
539 	case PS_ATTACH:				/* attach unit */
540 	case PS_DETACH:				/* detach unit */
541 	case PS_ABORT:				/* abort code from ps300 */
542 		if (data != bp->b_command)
543 			goto bad;
544 		goto opdone;
545 
546 	case PS_RDPHY:				/* physical i/o read */
547 		if (data == PS_RDPHY) {		/* dma address list */
548 			bp->b_command = PS_DMAOUT;
549 			goto opcont;
550 		}
551 		if (data == PS_ADROK(PS_RDPHY)) {
552 			/* collect read byte count and start dma */
553 			bp->b_bcount = dioread(ik);
554 			if (bp->b_bcount == -1)
555 				goto bad;
556 			bp->b_command = PS_DMAIN;
557 			goto opcont;
558 		}
559 		if (data == PS_DMAOK(PS_RDPHY))
560 			goto opdone;
561 		goto bad;
562 	}
563 bad:
564 	sc->is_error = data;
565 	bp->b_flags |= B_ERROR;
566 opdone:
567 	dp->b_actf = bp->av_forw;		/* remove from queue */
568 	biodone(bp);
569 opcont:
570 	ikstart(dp);
571 enable:
572 	ik->ik_pulse = IKPULSE_SIENA;		/* explicitly reenable */
573 }
574 
575 /*
576  * Watchdog timer.
577  */
578 iktimer(unit)
579 	int unit;
580 {
581 	register struct ik_softc *sc = &ik_softc[unit];
582 
583 	if (sc->is_timeout && --sc->is_timeout == 0) {
584 		register struct buf *dp, *bp;
585 		int s;
586 
587 		log(LOG_ERR, "ik%d: timeout\n", unit);
588 		s = splik();
589 		/* should abort current command */
590 		dp = &iktab[unit];
591 		if (bp = dp->b_actf) {
592 			sc->is_error = PSERROR_CMDTIMO;
593 			bp->b_flags |= B_ERROR;
594 			dp->b_actf = bp->av_forw;	/* remove from queue */
595 			biodone(bp);
596 			ikstart(dp);
597 		}
598 		splx(s);
599 	}
600 	timeout(iktimer, (caddr_t)unit, hz);
601 }
602 
603 /*
604  * Handshake read from DR300.
605  */
606 dioread(ik)
607 	register struct ikdevice *ik;
608 {
609 	register int t;
610 	u_short data;
611 
612 	for (t = ikdiotimo; t > 0; t--)
613 		if ((ik->ik_csr&(IKCSR_ATTF|IKCSR_STATC)) == IKCSR_ATTF) {
614 			data = ik->ik_data;
615 			ik->ik_csr = IKCSR_RATTF|IKCSR_RDMAF|IKCSR_FNC1;
616 			ik->ik_pulse = IKPULSE_FNC2;
617 			return (data);
618 		}
619 	return (-1);
620 }
621 
622 /*
623  * Handshake write to DR300.
624  *
625  * Interrupts are enabled before completing the work
626  * so the caller should either be at splik or be
627  * prepared to take the interrupt immediately.
628  */
629 diowrite(ik, v)
630 	register struct ikdevice *ik;
631 	u_short v;
632 {
633 	register int t;
634 	register u_short csr;
635 
636 top:
637 	/*
638 	 * Deposit data and generate dr300 attention
639 	 */
640 	ik->ik_data = v;
641 	ik->ik_csr = IKCSR_RDMAF|IKCSR_RATTF;
642 	ik->ik_pulse = IKPULSE_FNC2;
643 	for (t = ikdiotimo; t > 0; t--) {
644 		csr = ik->ik_csr;
645 #define IKCSR_DONE	(IKCSR_STATA|IKCSR_STATC)
646 		if ((csr&IKCSR_DONE) == IKCSR_DONE) {
647 			/*
648 			 * Done, complete handshake by notifying dr300.
649 			 */
650 			ik->ik_csr = IKCSR_IENA;	/* ~IKCSR_FNC1 */
651 			ik->ik_pulse = IKPULSE_FNC2;
652 			return (0);
653 		}
654 		/* beware of potential deadlock with dioread */
655 		if ((csr&(IKCSR_ATTF|IKCSR_STATC)) == IKCSR_ATTF)
656 			goto top;
657 	}
658 	ik->ik_csr = IKCSR_IENA;
659 	return (PSERROR_DIOTIMO);
660 }
661 
662 /*ARGSUSED*/
663 ikioctl(dev, cmd, data, flag)
664 	dev_t dev;
665 	int cmd;
666 	caddr_t data;
667 	int flag;
668 {
669 	int error = 0, unit = IKUNIT(dev), s;
670 	register struct ik_softc *sc = &ik_softc[unit];
671 
672 	switch (cmd) {
673 
674 	case PSIOGETERROR:		/* get error code for last operation */
675 		*(int *)data = sc->is_error;
676 		break;
677 
678 	case PSIOLOOKUP: {		/* PS300 name lookup */
679 		register struct pslookup *lp = (struct pslookup *)data;
680 		register struct buf *bp;
681 
682 		if (lp->pl_len > PS_MAXNAMELEN)
683 			return (EINVAL);
684 		bp = &rikbuf[unit];
685 		s = splbio();
686 		while (bp->b_flags&B_BUSY) {
687 			bp->b_flags |= B_WANTED;
688 			sleep((caddr_t)bp, PRIBIO+1);
689 		}
690 		splx(s);
691 		bp->b_flags = B_BUSY | B_WRITE;
692 		error = copyin(lp->pl_name, (caddr_t)sc->is_buf,
693 		    (unsigned)lp->pl_len);
694 		if (error == 0) {
695 			if (lp->pl_len&1)
696 				sc->is_buf[lp->pl_len] = '\0';
697 			error = ikcommand(dev, PS_LOOKUP, lp->pl_len);
698 		}
699 		s = splbio();
700 		if (bp->b_flags&B_WANTED)
701 			wakeup((caddr_t)bp);
702 		splx(s);
703 		bp->b_flags &= ~(B_BUSY|B_WANTED);
704 		lp->pl_addr = sc->is_nameaddr.l;
705 		break;
706 	}
707 	default:
708 		return (ENOTTY);
709 	}
710 	return (error);
711 }
712 #endif
713