lpt_mvme.c revision 1.1.2.4 1 1.1.2.4 nathanw /* $NetBSD: lpt_mvme.c,v 1.1.2.4 2002/11/11 22:10:56 nathanw Exp $ */
2 1.1.2.2 nathanw
3 1.1.2.2 nathanw /*-
4 1.1.2.2 nathanw * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
5 1.1.2.2 nathanw * All rights reserved.
6 1.1.2.2 nathanw *
7 1.1.2.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.1.2.2 nathanw * by Steve C. Woodford.
9 1.1.2.2 nathanw *
10 1.1.2.2 nathanw * Redistribution and use in source and binary forms, with or without
11 1.1.2.2 nathanw * modification, are permitted provided that the following conditions
12 1.1.2.2 nathanw * are met:
13 1.1.2.2 nathanw * 1. Redistributions of source code must retain the above copyright
14 1.1.2.2 nathanw * notice, this list of conditions and the following disclaimer.
15 1.1.2.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.2.2 nathanw * notice, this list of conditions and the following disclaimer in the
17 1.1.2.2 nathanw * documentation and/or other materials provided with the distribution.
18 1.1.2.2 nathanw * 3. All advertising materials mentioning features or use of this software
19 1.1.2.2 nathanw * must display the following acknowledgement:
20 1.1.2.2 nathanw * This product includes software developed by the NetBSD
21 1.1.2.2 nathanw * Foundation, Inc. and its contributors.
22 1.1.2.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.2.2 nathanw * contributors may be used to endorse or promote products derived
24 1.1.2.2 nathanw * from this software without specific prior written permission.
25 1.1.2.2 nathanw *
26 1.1.2.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.2.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.2.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.2.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.2.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.2.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.2.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.2.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.2.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.2.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.2.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
37 1.1.2.2 nathanw */
38 1.1.2.2 nathanw
39 1.1.2.2 nathanw /*
40 1.1.2.2 nathanw * Copyright (c) 1993, 1994 Charles M. Hannum.
41 1.1.2.2 nathanw * Copyright (c) 1990 William F. Jolitz, TeleMuse
42 1.1.2.2 nathanw * All rights reserved.
43 1.1.2.2 nathanw *
44 1.1.2.2 nathanw * Redistribution and use in source and binary forms, with or without
45 1.1.2.2 nathanw * modification, are permitted provided that the following conditions
46 1.1.2.2 nathanw * are met:
47 1.1.2.2 nathanw * 1. Redistributions of source code must retain the above copyright
48 1.1.2.2 nathanw * notice, this list of conditions and the following disclaimer.
49 1.1.2.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
50 1.1.2.2 nathanw * notice, this list of conditions and the following disclaimer in the
51 1.1.2.2 nathanw * documentation and/or other materials provided with the distribution.
52 1.1.2.2 nathanw * 3. All advertising materials mentioning features or use of this software
53 1.1.2.2 nathanw * must display the following acknowledgement:
54 1.1.2.2 nathanw * This software is a component of "386BSD" developed by
55 1.1.2.2 nathanw * William F. Jolitz, TeleMuse.
56 1.1.2.2 nathanw * 4. Neither the name of the developer nor the name "386BSD"
57 1.1.2.2 nathanw * may be used to endorse or promote products derived from this software
58 1.1.2.2 nathanw * without specific prior written permission.
59 1.1.2.2 nathanw *
60 1.1.2.2 nathanw * THIS SOFTWARE IS A COMPONENT OF 386BSD DEVELOPED BY WILLIAM F. JOLITZ
61 1.1.2.2 nathanw * AND IS INTENDED FOR RESEARCH AND EDUCATIONAL PURPOSES ONLY. THIS
62 1.1.2.2 nathanw * SOFTWARE SHOULD NOT BE CONSIDERED TO BE A COMMERCIAL PRODUCT.
63 1.1.2.2 nathanw * THE DEVELOPER URGES THAT USERS WHO REQUIRE A COMMERCIAL PRODUCT
64 1.1.2.2 nathanw * NOT MAKE USE OF THIS WORK.
65 1.1.2.2 nathanw *
66 1.1.2.2 nathanw * FOR USERS WHO WISH TO UNDERSTAND THE 386BSD SYSTEM DEVELOPED
67 1.1.2.2 nathanw * BY WILLIAM F. JOLITZ, WE RECOMMEND THE USER STUDY WRITTEN
68 1.1.2.2 nathanw * REFERENCES SUCH AS THE "PORTING UNIX TO THE 386" SERIES
69 1.1.2.2 nathanw * (BEGINNING JANUARY 1991 "DR. DOBBS JOURNAL", USA AND BEGINNING
70 1.1.2.2 nathanw * JUNE 1991 "UNIX MAGAZIN", GERMANY) BY WILLIAM F. JOLITZ AND
71 1.1.2.2 nathanw * LYNNE GREER JOLITZ, AS WELL AS OTHER BOOKS ON UNIX AND THE
72 1.1.2.2 nathanw * ON-LINE 386BSD USER MANUAL BEFORE USE. A BOOK DISCUSSING THE INTERNALS
73 1.1.2.2 nathanw * OF 386BSD ENTITLED "386BSD FROM THE INSIDE OUT" WILL BE AVAILABLE LATE 1992.
74 1.1.2.2 nathanw *
75 1.1.2.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
76 1.1.2.2 nathanw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
77 1.1.2.2 nathanw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
78 1.1.2.2 nathanw * ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER BE LIABLE
79 1.1.2.2 nathanw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
80 1.1.2.2 nathanw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
81 1.1.2.2 nathanw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
82 1.1.2.2 nathanw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
83 1.1.2.2 nathanw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
84 1.1.2.2 nathanw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
85 1.1.2.2 nathanw * SUCH DAMAGE.
86 1.1.2.2 nathanw */
87 1.1.2.2 nathanw
88 1.1.2.2 nathanw /*
89 1.1.2.2 nathanw * Device Driver for an MVME68K/MVME88K board's parallel printer port
90 1.1.2.2 nathanw * This driver attaches above the board-specific back-end.
91 1.1.2.2 nathanw */
92 1.1.2.2 nathanw
93 1.1.2.2 nathanw #include <sys/param.h>
94 1.1.2.2 nathanw #include <sys/systm.h>
95 1.1.2.2 nathanw #include <sys/proc.h>
96 1.1.2.2 nathanw #include <sys/user.h>
97 1.1.2.2 nathanw #include <sys/buf.h>
98 1.1.2.2 nathanw #include <sys/kernel.h>
99 1.1.2.2 nathanw #include <sys/ioctl.h>
100 1.1.2.2 nathanw #include <sys/uio.h>
101 1.1.2.2 nathanw #include <sys/device.h>
102 1.1.2.2 nathanw #include <sys/conf.h>
103 1.1.2.2 nathanw #include <sys/syslog.h>
104 1.1.2.2 nathanw
105 1.1.2.2 nathanw #include <machine/cpu.h>
106 1.1.2.2 nathanw #include <machine/bus.h>
107 1.1.2.2 nathanw
108 1.1.2.2 nathanw #include <dev/mvme/lptvar.h>
109 1.1.2.2 nathanw
110 1.1.2.2 nathanw
111 1.1.2.2 nathanw #define TIMEOUT hz*16 /* wait up to 16 seconds for a ready */
112 1.1.2.2 nathanw #define STEP hz/4
113 1.1.2.2 nathanw
114 1.1.2.2 nathanw #define LPTPRI (PZERO+8)
115 1.1.2.2 nathanw #define LPT_BSIZE 1024
116 1.1.2.2 nathanw
117 1.1.2.2 nathanw #if !defined(DEBUG) || !defined(notdef)
118 1.1.2.2 nathanw #define LPRINTF(a)
119 1.1.2.2 nathanw #else
120 1.1.2.2 nathanw #define LPRINTF if (lptdebug) printf a
121 1.1.2.2 nathanw int lptdebug = 1;
122 1.1.2.2 nathanw #endif
123 1.1.2.2 nathanw
124 1.1.2.2 nathanw #define LPTUNIT(s) (minor(s) & 0x0f)
125 1.1.2.2 nathanw #define LPTFLAGS(s) (minor(s) & 0xf0)
126 1.1.2.2 nathanw
127 1.1.2.2 nathanw static void lpt_wakeup __P((void *arg));
128 1.1.2.2 nathanw static int pushbytes __P((struct lpt_softc *));
129 1.1.2.2 nathanw
130 1.1.2.2 nathanw extern struct cfdriver lpt_cd;
131 1.1.2.2 nathanw
132 1.1.2.3 nathanw dev_type_open(lptopen);
133 1.1.2.3 nathanw dev_type_close(lptclose);
134 1.1.2.3 nathanw dev_type_write(lptwrite);
135 1.1.2.3 nathanw dev_type_ioctl(lptioctl);
136 1.1.2.3 nathanw
137 1.1.2.3 nathanw const struct cdevsw lpt_cdevsw = {
138 1.1.2.3 nathanw lptopen, lptclose, noread, lptwrite, lptioctl,
139 1.1.2.4 nathanw nostop, notty, nopoll, nommap, nokqfilter,
140 1.1.2.3 nathanw };
141 1.1.2.2 nathanw
142 1.1.2.2 nathanw void
143 1.1.2.2 nathanw lpt_attach_subr(sc)
144 1.1.2.2 nathanw struct lpt_softc *sc;
145 1.1.2.2 nathanw {
146 1.1.2.2 nathanw
147 1.1.2.2 nathanw sc->sc_state = 0;
148 1.1.2.2 nathanw callout_init(&sc->sc_wakeup_ch);
149 1.1.2.2 nathanw }
150 1.1.2.2 nathanw
151 1.1.2.2 nathanw /*
152 1.1.2.2 nathanw * Reset the printer, then wait until it's selected and not busy.
153 1.1.2.2 nathanw */
154 1.1.2.2 nathanw int
155 1.1.2.2 nathanw lptopen(dev, flag, mode, p)
156 1.1.2.2 nathanw dev_t dev;
157 1.1.2.2 nathanw int flag;
158 1.1.2.2 nathanw int mode;
159 1.1.2.2 nathanw struct proc *p;
160 1.1.2.2 nathanw {
161 1.1.2.2 nathanw int unit;
162 1.1.2.2 nathanw u_char flags;
163 1.1.2.2 nathanw struct lpt_softc *sc;
164 1.1.2.2 nathanw int error;
165 1.1.2.2 nathanw int spin;
166 1.1.2.2 nathanw
167 1.1.2.2 nathanw unit = LPTUNIT(dev);
168 1.1.2.2 nathanw flags = LPTFLAGS(dev);
169 1.1.2.2 nathanw
170 1.1.2.2 nathanw if (unit >= lpt_cd.cd_ndevs)
171 1.1.2.2 nathanw return (ENXIO);
172 1.1.2.2 nathanw sc = lpt_cd.cd_devs[unit];
173 1.1.2.2 nathanw if (!sc)
174 1.1.2.2 nathanw return (ENXIO);
175 1.1.2.2 nathanw
176 1.1.2.2 nathanw #ifdef DIAGNOSTIC
177 1.1.2.2 nathanw if (sc->sc_state)
178 1.1.2.2 nathanw printf("%s: stat=0x%x not zero\n", sc->sc_dev.dv_xname,
179 1.1.2.2 nathanw sc->sc_state);
180 1.1.2.2 nathanw #endif
181 1.1.2.2 nathanw
182 1.1.2.2 nathanw if (sc->sc_state)
183 1.1.2.2 nathanw return (EBUSY);
184 1.1.2.2 nathanw
185 1.1.2.2 nathanw sc->sc_state = LPT_INIT;
186 1.1.2.2 nathanw sc->sc_flags = flags;
187 1.1.2.2 nathanw LPRINTF(("%s: open: flags=0x%x\n", sc->sc_dev.dv_xname, flags));
188 1.1.2.2 nathanw
189 1.1.2.2 nathanw if ((flags & LPT_NOPRIME) == 0) {
190 1.1.2.2 nathanw /* assert Input Prime for 100 usec to start up printer */
191 1.1.2.2 nathanw (sc->sc_funcs->lf_iprime) (sc);
192 1.1.2.2 nathanw }
193 1.1.2.2 nathanw
194 1.1.2.2 nathanw /* select fast or slow strobe depending on minor device number */
195 1.1.2.2 nathanw if (flags & LPT_FAST_STROBE)
196 1.1.2.2 nathanw (sc->sc_funcs->lf_speed) (sc, LPT_STROBE_FAST);
197 1.1.2.2 nathanw else
198 1.1.2.2 nathanw (sc->sc_funcs->lf_speed) (sc, LPT_STROBE_SLOW);
199 1.1.2.2 nathanw
200 1.1.2.2 nathanw /* wait till ready (printer running diagnostics) */
201 1.1.2.2 nathanw for (spin = 0; (sc->sc_funcs->lf_notrdy) (sc, 1); spin += STEP) {
202 1.1.2.2 nathanw if (spin >= TIMEOUT) {
203 1.1.2.2 nathanw sc->sc_state = 0;
204 1.1.2.2 nathanw return (EBUSY);
205 1.1.2.2 nathanw }
206 1.1.2.2 nathanw /* wait 1/4 second, give up if we get a signal */
207 1.1.2.2 nathanw error = tsleep((caddr_t) sc, LPTPRI | PCATCH, "lptopen", STEP);
208 1.1.2.2 nathanw if (error != EWOULDBLOCK) {
209 1.1.2.2 nathanw sc->sc_state = 0;
210 1.1.2.2 nathanw return (error);
211 1.1.2.2 nathanw }
212 1.1.2.2 nathanw }
213 1.1.2.2 nathanw
214 1.1.2.2 nathanw sc->sc_inbuf = geteblk(LPT_BSIZE);
215 1.1.2.2 nathanw sc->sc_count = 0;
216 1.1.2.2 nathanw sc->sc_state = LPT_OPEN;
217 1.1.2.2 nathanw
218 1.1.2.2 nathanw if ((sc->sc_flags & LPT_NOINTR) == 0)
219 1.1.2.2 nathanw lpt_wakeup(sc);
220 1.1.2.2 nathanw
221 1.1.2.2 nathanw (sc->sc_funcs->lf_open) (sc, sc->sc_flags & LPT_NOINTR);
222 1.1.2.2 nathanw
223 1.1.2.2 nathanw LPRINTF(("%s: opened\n", sc->sc_dev.dv_xname));
224 1.1.2.2 nathanw return (0);
225 1.1.2.2 nathanw }
226 1.1.2.2 nathanw
227 1.1.2.2 nathanw void
228 1.1.2.2 nathanw lpt_wakeup(arg)
229 1.1.2.2 nathanw void *arg;
230 1.1.2.2 nathanw {
231 1.1.2.2 nathanw struct lpt_softc *sc;
232 1.1.2.2 nathanw int s;
233 1.1.2.2 nathanw
234 1.1.2.2 nathanw sc = arg;
235 1.1.2.2 nathanw
236 1.1.2.2 nathanw s = spltty();
237 1.1.2.2 nathanw lpt_intr(sc);
238 1.1.2.2 nathanw splx(s);
239 1.1.2.2 nathanw
240 1.1.2.2 nathanw callout_reset(&sc->sc_wakeup_ch, STEP, lpt_wakeup, sc);
241 1.1.2.2 nathanw }
242 1.1.2.2 nathanw
243 1.1.2.2 nathanw /*
244 1.1.2.2 nathanw * Close the device, and free the local line buffer.
245 1.1.2.2 nathanw */
246 1.1.2.2 nathanw int
247 1.1.2.2 nathanw lptclose(dev, flag, mode, p)
248 1.1.2.2 nathanw dev_t dev;
249 1.1.2.2 nathanw int flag;
250 1.1.2.2 nathanw int mode;
251 1.1.2.2 nathanw struct proc *p;
252 1.1.2.2 nathanw {
253 1.1.2.2 nathanw struct lpt_softc *sc;
254 1.1.2.2 nathanw int unit;
255 1.1.2.2 nathanw
256 1.1.2.2 nathanw unit = LPTUNIT(dev);
257 1.1.2.2 nathanw sc = lpt_cd.cd_devs[unit];
258 1.1.2.2 nathanw
259 1.1.2.2 nathanw if (sc->sc_count)
260 1.1.2.2 nathanw (void) pushbytes(sc);
261 1.1.2.2 nathanw
262 1.1.2.2 nathanw if ((sc->sc_flags & LPT_NOINTR) == 0)
263 1.1.2.2 nathanw callout_stop(&sc->sc_wakeup_ch);
264 1.1.2.2 nathanw
265 1.1.2.2 nathanw (sc->sc_funcs->lf_close) (sc);
266 1.1.2.2 nathanw
267 1.1.2.2 nathanw sc->sc_state = 0;
268 1.1.2.2 nathanw brelse(sc->sc_inbuf);
269 1.1.2.2 nathanw
270 1.1.2.2 nathanw LPRINTF(("%s: closed\n", sc->sc_dev.dv_xname));
271 1.1.2.2 nathanw return (0);
272 1.1.2.2 nathanw }
273 1.1.2.2 nathanw
274 1.1.2.2 nathanw int
275 1.1.2.2 nathanw pushbytes(sc)
276 1.1.2.2 nathanw struct lpt_softc *sc;
277 1.1.2.2 nathanw {
278 1.1.2.2 nathanw int s, error, spin, tic;
279 1.1.2.2 nathanw
280 1.1.2.2 nathanw if (sc->sc_flags & LPT_NOINTR) {
281 1.1.2.2 nathanw while (sc->sc_count > 0) {
282 1.1.2.2 nathanw spin = 0;
283 1.1.2.2 nathanw while ((sc->sc_funcs->lf_notrdy) (sc, 0)) {
284 1.1.2.2 nathanw if (++spin < sc->sc_spinmax)
285 1.1.2.2 nathanw continue;
286 1.1.2.2 nathanw tic = 0;
287 1.1.2.2 nathanw /* adapt busy-wait algorithm */
288 1.1.2.2 nathanw sc->sc_spinmax++;
289 1.1.2.2 nathanw while ((sc->sc_funcs->lf_notrdy) (sc, 1)) {
290 1.1.2.2 nathanw /* exponential backoff */
291 1.1.2.2 nathanw tic = tic + tic + 1;
292 1.1.2.2 nathanw if (tic > TIMEOUT)
293 1.1.2.2 nathanw tic = TIMEOUT;
294 1.1.2.2 nathanw error = tsleep((caddr_t) sc,
295 1.1.2.2 nathanw LPTPRI | PCATCH, "lptpsh", tic);
296 1.1.2.2 nathanw if (error != EWOULDBLOCK)
297 1.1.2.2 nathanw return (error);
298 1.1.2.2 nathanw }
299 1.1.2.2 nathanw break;
300 1.1.2.2 nathanw }
301 1.1.2.2 nathanw
302 1.1.2.2 nathanw (sc->sc_funcs->lf_wrdata) (sc, *sc->sc_cp++);
303 1.1.2.2 nathanw sc->sc_count--;
304 1.1.2.2 nathanw
305 1.1.2.2 nathanw /* adapt busy-wait algorithm */
306 1.1.2.2 nathanw if (spin * 2 + 16 < sc->sc_spinmax)
307 1.1.2.2 nathanw sc->sc_spinmax--;
308 1.1.2.2 nathanw }
309 1.1.2.2 nathanw } else {
310 1.1.2.2 nathanw while (sc->sc_count > 0) {
311 1.1.2.2 nathanw /* if the printer is ready for a char, give it one */
312 1.1.2.2 nathanw if ((sc->sc_state & LPT_OBUSY) == 0) {
313 1.1.2.2 nathanw LPRINTF(("%s: write %d\n", sc->sc_dev.dv_xname,
314 1.1.2.2 nathanw sc->sc_count));
315 1.1.2.2 nathanw s = spltty();
316 1.1.2.2 nathanw (void) lpt_intr(sc);
317 1.1.2.2 nathanw splx(s);
318 1.1.2.2 nathanw }
319 1.1.2.2 nathanw error = tsleep((caddr_t) sc, LPTPRI | PCATCH,
320 1.1.2.2 nathanw "lptwrite2", 0);
321 1.1.2.2 nathanw if (error)
322 1.1.2.2 nathanw return (error);
323 1.1.2.2 nathanw }
324 1.1.2.2 nathanw }
325 1.1.2.2 nathanw return (0);
326 1.1.2.2 nathanw }
327 1.1.2.2 nathanw
328 1.1.2.2 nathanw /*
329 1.1.2.2 nathanw * Copy a line from user space to a local buffer, then call putc to get the
330 1.1.2.2 nathanw * chars moved to the output queue.
331 1.1.2.2 nathanw */
332 1.1.2.2 nathanw int
333 1.1.2.2 nathanw lptwrite(dev, uio, flags)
334 1.1.2.2 nathanw dev_t dev;
335 1.1.2.2 nathanw struct uio *uio;
336 1.1.2.2 nathanw int flags;
337 1.1.2.2 nathanw {
338 1.1.2.2 nathanw struct lpt_softc *sc;
339 1.1.2.2 nathanw size_t n;
340 1.1.2.2 nathanw int error;
341 1.1.2.2 nathanw
342 1.1.2.2 nathanw sc = lpt_cd.cd_devs[LPTUNIT(dev)];
343 1.1.2.2 nathanw error = 0;
344 1.1.2.2 nathanw
345 1.1.2.2 nathanw while ((n = min(LPT_BSIZE, uio->uio_resid)) != 0) {
346 1.1.2.2 nathanw uiomove(sc->sc_cp = sc->sc_inbuf->b_data, n, uio);
347 1.1.2.2 nathanw sc->sc_count = n;
348 1.1.2.2 nathanw error = pushbytes(sc);
349 1.1.2.2 nathanw if (error) {
350 1.1.2.2 nathanw /*
351 1.1.2.2 nathanw * Return accurate residual if interrupted or timed
352 1.1.2.2 nathanw * out.
353 1.1.2.2 nathanw */
354 1.1.2.2 nathanw uio->uio_resid += sc->sc_count;
355 1.1.2.2 nathanw sc->sc_count = 0;
356 1.1.2.2 nathanw return (error);
357 1.1.2.2 nathanw }
358 1.1.2.2 nathanw }
359 1.1.2.2 nathanw return (0);
360 1.1.2.2 nathanw }
361 1.1.2.2 nathanw
362 1.1.2.2 nathanw /*
363 1.1.2.2 nathanw * Handle printer interrupts which occur when the printer is ready to accept
364 1.1.2.2 nathanw * another char.
365 1.1.2.2 nathanw */
366 1.1.2.2 nathanw int
367 1.1.2.2 nathanw lpt_intr(sc)
368 1.1.2.2 nathanw struct lpt_softc *sc;
369 1.1.2.2 nathanw {
370 1.1.2.2 nathanw
371 1.1.2.2 nathanw if (sc->sc_count) {
372 1.1.2.2 nathanw /* send char */
373 1.1.2.2 nathanw (sc->sc_funcs->lf_wrdata) (sc, *sc->sc_cp++);
374 1.1.2.2 nathanw sc->sc_count--;
375 1.1.2.2 nathanw sc->sc_state |= LPT_OBUSY;
376 1.1.2.2 nathanw } else
377 1.1.2.2 nathanw sc->sc_state &= ~LPT_OBUSY;
378 1.1.2.2 nathanw
379 1.1.2.2 nathanw if (sc->sc_count == 0) {
380 1.1.2.2 nathanw /* none, wake up the top half to get more */
381 1.1.2.2 nathanw wakeup((caddr_t) sc);
382 1.1.2.2 nathanw }
383 1.1.2.2 nathanw
384 1.1.2.2 nathanw return (1);
385 1.1.2.2 nathanw }
386 1.1.2.2 nathanw
387 1.1.2.2 nathanw /* ARGSUSED */
388 1.1.2.2 nathanw int
389 1.1.2.2 nathanw lptioctl(dev, cmd, data, flag, p)
390 1.1.2.2 nathanw dev_t dev;
391 1.1.2.2 nathanw u_long cmd;
392 1.1.2.2 nathanw caddr_t data;
393 1.1.2.2 nathanw int flag;
394 1.1.2.2 nathanw struct proc *p;
395 1.1.2.2 nathanw {
396 1.1.2.2 nathanw
397 1.1.2.2 nathanw return (ENODEV);
398 1.1.2.2 nathanw }
399