* LP-11 Line printer driver
* This driver is only set up to handle one printer;
* thats all our user-level spoolers can handle anyways right now.
* This driver has been modified to work on printers where
* leaving IENABLE set would cause continuous interrupts.
#define flags lpio.lp_flags
#define ejline lpio.lp_ejline
#define indent lpio.lp_indent
#define maxcol lpio.lp_maxcol
#define skpline lpio.lp_skpline
#define OPEN 1 /* device is open */
#define TOUT 2 /* timeout is active */
#define MOD 4 /* device state has been modified */
#define ASLP 8 /* awaiting draining of printer */
if (lp11
.state
&OPEN
|| LPADDR
->lpsr
&ERROR
) {
if ((lp11
.state
&TOUT
) == 0) {
timeout(lptout
, 0, 10*HZ
);
while (n
= min(BSIZE
, u
.u_count
)) {
cp
= lp11
.inbuf
->b_un
.b_addr
;
register int logcol
, physcol
;
logcol
= lp11
.indent
+ ((logcol
-lp11
.indent
+8) & ~7);
if (lp11
.physline
>= lp11
.ejline
)
if (lp11
.physline
== 0 && (lp11
.flags
&SAVEPAPER
))
if (lp11
.flags
& SKIPFOLD
) {
for (i
= 0; i
< lp11
.skpline
; i
++)
if (logcol
< lp11
.maxcol
) {
while (logcol
> physcol
) {
if (logcol
> 1000) /* ignore long lines */
if (lp11
.outq
.c_cc
>= LPHWAT
) {
while (lp11
.outq
.c_cc
>= LPHWAT
) {
lp11
.state
|= ASLP
; /* must be ERROR */
sleep((caddr_t
)&lp11
, LPPRI
);
while (putc(c
, &lp11
.outq
))
sleep((caddr_t
)&lbolt
, LPPRI
);
LPADDR
->lpsr
&= ~IENABLE
;
while ((LPADDR
->lpsr
&DONE
) && lpchar
>= 0) {
if (lp11
.outq
.c_cc
> 0 && (LPADDR
->lpsr
&ERROR
)==0)
LPADDR
->lpsr
|= IENABLE
; /* ok and more to do later */
if (n
>LPLWAT
&& lp11
.outq
.c_cc
<=LPLWAT
&& lp11
.state
&ASLP
) {
wakeup((caddr_t
)&lp11
); /* top half should go on */
if ((lp11
.state
&MOD
) != 0) {
lp11
.state
&= ~MOD
; /* something happened */
timeout(lptout
, 0, 2*HZ
); /* so don't sweat */
if ((lp11
.state
&OPEN
) == 0) {
lp11
.state
&= ~TOUT
; /* no longer open */
if (lp11
.outq
.c_cc
&& (*sr
&DONE
) && (*sr
&ERROR
)==0)
lpintr(); /* ready to go */
timeout(lptout
, 0, 10*HZ
);
lpioctl(dev
, cmd
, addr
, flag
)
copyout((caddr_t
)&lp11
.lpio
, addr
, sizeof (lp11
.lpio
));
m
= copyin(addr
, (caddr_t
)&lpio
, sizeof (lpio
));
if (lpio
.lp_indent
<= 0 || lpio
.lp_indent
>= lpio
.lp_maxcol
||
lpio
.lp_ejline
<= 2 || lpio
.lp_ejline
<= lpio
.lp_skpline
||
lpio
.lp_skpline
< 0 || lpio
.lp_maxcol
<= 10)