* Copyright (c) 1982, 1990 The Regents of the University of California.
* Redistribution is only permitted until one year after the first shipment
* of 4.4BSD by the Regents. Otherwise, redistribution and use in source and
* binary forms are permitted provided that: (1) source distributions retain
* this entire copyright notice and comment, and (2) distributions including
* binaries display the following acknowledgement: This product includes
* software developed by the University of California, Berkeley and its
* contributors'' in the documentation or other materials provided with the
* distribution and in all advertising materials mentioning features or use
* of this software. Neither the name of the University nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* @(#)ppi.c 7.1 (Berkeley) 5/8/90
* Printer/Plotter HPIB interface
int ppiattach(), ppistart();
struct driver ppidriver
= {
ppiattach
, "ppi", ppistart
,
register struct hp_device
*hd
;
register struct ppi_softc
*sc
= &ppi_softc
[hd
->hp_unit
];
* XXX: the printer/plotter doesn't seem to really return
* an ID but this will at least prevent us from mistaking
* a cs80 disk or tape for a ppi device.
if (hpibid(hd
->hp_ctlr
, hd
->hp_slave
) & 0x200)
sc
->sc_flags
= PPIF_ALIVE
;
sc
->sc_dq
.dq_ctlr
= hd
->hp_ctlr
;
sc
->sc_dq
.dq_unit
= hd
->hp_unit
;
sc
->sc_dq
.dq_slave
= hd
->hp_slave
;
sc
->sc_dq
.dq_driver
= &ppidriver
;
register int unit
= UNIT(dev
);
register struct ppi_softc
*sc
= &ppi_softc
[unit
];
if (unit
>= NPPI
|| (sc
->sc_flags
& PPIF_ALIVE
) == 0)
if (sc
->sc_flags
& PPIF_OPEN
)
sc
->sc_flags
|= PPIF_OPEN
;
register int unit
= UNIT(dev
);
register struct ppi_softc
*sc
= &ppi_softc
[unit
];
sc
->sc_flags
&= ~PPIF_OPEN
;
wakeup(&ppi_softc
[unit
]);
return (ppirw(dev
, uio
, UIO_READ
));
return (ppirw(dev
, uio
, UIO_WRITE
));
register struct uio
*uio
;
register struct ppi_softc
*sc
= &ppi_softc
[UNIT(dev
)];
register int s
, len
, cnt
;
len
= MIN(CLBYTES
, uio
->uio_resid
);
cp
= (char *)malloc(len
, M_TEMP
, M_WAITOK
);
while (uio
->uio_resid
> 0) {
len
= MIN(CLBYTES
, uio
->uio_resid
);
error
= uiomove(cp
, len
, uio
);
if (hpibreq(&sc
->sc_dq
) == 0)
cnt
= hpibsend(sc
->sc_hd
->hp_ctlr
, sc
->sc_hd
->hp_slave
,
cnt
= hpibrecv(sc
->sc_hd
->hp_ctlr
, sc
->sc_hd
->hp_slave
,
error
= uiomove(cp
, cnt
, uio
);
uio
->uio_resid
+= len
- cnt
;