* Benson-Varian matrix printer/plotter
#define ushort unsigned short
#define vacsh vacs.vacsr.Vacsh
#define vacsl vacs.vacsr.Vacsl
#define ERROR 0100000 /* Some error has occurred */
#define NPRTIMO 01000 /* DMA timeout error */
#define NOTREADY 0400 /* Something besides NPRTIMO */
#define IENABLE 0100 /* Interrupt enable */
#define BYTEREVERSE 01 /* Reverse byte order in words */
/* vacsh command bytes */
#define VANOAUTOSTEP 0045 /* unused */
#define VAFORMFEED 0263 /* unused */
#define VASLEW 0265 /* unused */
#define VASTEP 0064 /* unused */
int va_state
; /* State: bits are commands in vcmd.h. */
struct buf rvabuf
; /* Used by physio for a buffer. */
sleep((caddr_t
)&va11
, VAPRI
);
va_ubinfo
= ubasetup(bp
, vabdp
);
va11
.va_bufp
= va_ubinfo
& 0x3ffff;
va11
.va_wc
= -(bp
->b_bcount
/2);
e
= vaerror(DONE
); /* Wait for DMA to complete */
* After printing a line of characters, VPRINTPLOT mode essentially
* reverts to VPLOT mode, plotting things until a new mode is set.
* This change is indicated by sending a VAAUTOSTEP command to
* the va. We also change va_state to reflect this effective
if (va11
.va_state
& VPRINTPLOT
) {
va11
.va_state
= (va11
.va_state
& ~VPRINTPLOT
) | VPLOT
;
VAADDR
->vacsh
= VAAUTOSTEP
;
ubafree(va_ubinfo
), va_ubinfo
= 0;
if (bp
->b_bcount
> vablock
)
physio(vastrategy
, &rvabuf
, dev
, B_WRITE
, minvaph
);
* Vaerror waits until bit or ERROR gets set, then returns non-zero if
* if it was ERROR that was set.
while ((e
= VAADDR
->vacsw
& (bit
|ERROR
)) == 0)
sleep((caddr_t
)&va11
, VAPRI
);
VAADDR
->vaba
= va11
.va_bufp
;
VAADDR
->vawc
= va11
.va_wc
;
vaioctl(dev
, cmd
, addr
, flag
)
(void) suword(addr
, va11
.va_state
);
u
.u_error
= ENOTTY
; /* Not a legal ioctl cmd. */
* Send a command code to the va, and wait for it to complete.
* If an error occurs, u.u_error is set to EIO.
* In any case, update va11.va_state.
(void) vaerror(DONE
); /* Wait for va to be ready */
/* Must turn on plot AND autostep modes. */
VAADDR
->vacsh
= VAAUTOSTEP
;
VAADDR
->vacsh
= VAPRINTPLOT
;
(va11
.va_state
& ~(VPLOT
| VPRINT
| VPRINTPLOT
)) | vcmd
;
if (vaerror(DONE
)) /* Wait for command to complete. */
timeout(vatimo
, (caddr_t
)0, HZ
/10);
#define DELAY(N) { register int d; d = N; while (--d > 0); }
if (va11
.va_state
& VPLOT
) {
VAADDR
->vacsh
= VAAUTOSTEP
;
} else if (va11
.va_state
& VPRINTPLOT
)
VAADDR
->vacsh
= VPRINTPLOT
;
VAADDR
->vacsh
= VAPRINTPLOT
;
printf("<%d>", (va_ubinfo
>>28)&0xf);
ubafree(va_ubinfo
), va_ubinfo
= 0;
/* This code belongs in vastart() */
va_ubinfo
= ubasetup(va11
.va_bp
, vabdp
);
va11
.va_bufp
= va_ubinfo
& 0x3ffff;
va11
.va_wc
= (-va11
.va_bp
->b_bcount
/2);
/* End badly placed code */