Devices bpp(7D)
NAME
bpp - bi-directional parallel port driver
SYNOPSIS
SUNW,bpp@slot,offset:bppn
DESCRIPTION
The bpp driver provides a general-purpose bi-directional
interface to parallel devices. It supports a variety of out-
put (printer) and input (scanner) devices, using programm-
able timing relationships between the various handshake sig-
nals.
APLICATION PROGRAMING INTERFACE
The bpp driver is an exclusive-use device. If the device
has already been opened, subsequent opens fail with EBUSY.
Default Operation
Each time the bpp device is opened, the default configura-
tion is BPACKBUSYHS for read handshake, BPACKHS for
write handshake, 1 microsecond for all setup times and
strobe widths, and 60 seconds for both timeouts. This confi-
guration (in the write mode) drives many common personal
computer parallel printers with Centronics-type interfaces.
The application should use the BPIOCSETPARMS ioctl
request to configure the bpp for the particular device which
is attached, if necessary.
Write Operation
If a failure or error condition occurs during a write(2),
the number of bytes successfully written is returned (short
write). Note that errno will not be set. The contents of
certain status bits will be captured at the time of the
error, and can be retrieved by the application program,
using the BPIOCGETER ioctl request. Subsequent write(2)
calls may fail with the system error ENXIO if the error
condition is not rectified. The captured status information
will be overwritten each time an attempted transfer or a
BPIOCTESTIO ioctl request occurs.
Read Operations
If a failure or error condition occurs during a read(2), the
number of bytes successfully read is returned (short read).
Note that errno will not be set. The contents of certain
status bits will be captured at the time of the error, and
can be retrieved by the application, using the BPIOCGETER
ioctl request. Subsequent read(2) calls may fail with ENXIO
if the error condition is not rectified. The captured regis-
ter information will be overwritten each time an attempted
transfer or a BPIOCTESTIO ioctl request.
SunOS 5.11 Last change: 22 Aug 1994 1
Devices bpp(7D)
If the readhandshake element of the bpptransferparms
structure (see below) is set to BPCLEARMEM or
BPSETMEM, zeroes or ones, respectively, are written into
the user buffer.
Read/Write Operation
When the driver is opened for reading and writing, it is
assumed that scanning will take place, as scanners are the
only devices supported by this mode. Most scanners require
that the SLCTIN or AFX pin be set to tell the scanner the
direction of the transfer. The AFX line is set when the
readhandshake element of the bpptransferparms structure
is set to BPHSCANHS, otherwise the SLCTIN pin is set.
Normally, scanning starts by writing a command to the
scanner, at which time the pin is set. When the scan data
is read back, the pin is reset.
IOCTLS
The following ioctl requests are supported:
BPIOCSETPARMS Set transfer parameters.
The argument is a pointer to a
bpptransferparms structure. See below
for a description of the elements of
this structure. If a parameter is out
of range, EINVAL is returned.
BPIOCGETPARMS Get current transfer parameters.
The argument is a pointer to a
bpptransferparms structure. See below
for a description of the elements of
this structure. If no parameters have
been configured since the device was
opened, the contents of the structure
will be the default conditions of the
parameters (see Default Operation
above).
BPIOCSETOUTPINS Set output pin values.
The argument is a pointer to a
bpppins structure. See below for a
description of the elements of this
structure. If a parameter is out of
range, EINVAL is returned.
SunOS 5.11 Last change: 22 Aug 1994 2
Devices bpp(7D)
BPIOCGETOUTPINS Read output pin values. The argument is
a pointer to a bpppins structure. See
below for a description of the elements
of this structure.
BPIOCGETER Get last error status.
The argument is a pointer to a
bpperrorstatus structure. See below
for a description of the elements of
this structure. This structure indi-
cates the status of all the appropriate
status bits at the time of the most
recent error condition during a read(2)
or write(2) call, or the status of the
bits at the most recent BPIOCTESTIO
ioctl request. Note: The bits in the
pinstatus element indicate whether the
associated pin is active, not the
actual polarity. The application can
check transfer readiness without
attempting another transfer using the
BPIOCTESTIO ioctl. Note: The
timeoutoccurred and buserror fields
will never be set by the BPIOCTESTIO
ioctl, only by an actual failed
transfer.
BPIOCTESTIO Test transfer readiness.
This command checks to see if a read or
write transfer would succeed based on
pin status, opened mode, and handshake
selected. If a handshake would succeed,
0 is returned. If a transfer would
fail, -1 is returned, and errno is set
to EIO, and the error status informa-
tion is captured. The captured status
can be retrieved using the
BPIOCGETER ioctl call. Note that
the timeoutoccurred and buserror
fields will never be set by this ioctl.
Transfer Parameters Structure
This structure is defined in .
struct bpptransferparms {
enum handshaket
readhandshake; /* parallel port read handshake mode */
SunOS 5.11 Last change: 22 Aug 1994 3
Devices bpp(7D)
int readsetuptime; /* DS register - in nanoseconds */
int readstrobewidth; /* DSW register - in nanoseconds */
int readtimeout; /*
* wait this many seconds
* before aborting a transfer
*/
enum handshaket
writehandshake; /* parallel port write handshake mode */
int writesetuptime; /* DS register - in nanoseconds */
int writestrobewidth; /* DSW register - in nanoseconds */
int writetimeout; /*
* wait this many seconds
* before aborting a transfer
*/
};
/* Values for readhandshake and writehandshake fields */
enum handshaket {
BPNOHS, /* no handshake pins */
BPACKHS, /* handshake controlled by ACK line */
BPBUSYHS, /* handshake controlled by BSY line */
BPACKBUSYHS, /*
* handshake controlled by ACK and BSY lines
* readhandshake only!
*/
BPXSCANHS, /* xerox scanner mode,
* readhandshake only!
*/
BPHSCANHS, /*
* HP scanjet scanner mode
* readhandshake only!
*/
BPCLEARMEM, /* write 0's to memory,
* readhandshake only!
*/
BPSETMEM, /* write 1's to memory,
* readhandshake only!
*/
/* The following handshakes are RESERVED. Do not use. */
BPVPRINTHS, /* valid only in read/write mode */
BPVPLOTHS /* valid only in read/write mode */
};
The readsetuptime field controls the time between dstrb
falling edge to bsy rising edge if the readhandshake field
is set to BPNOHS or BPACKHS. It controls the time
between dstrb falling edge to ack rising edge if the
readhandshake field is set to BPACKHS or
BPACKBUSYHS. It controls the time between ack falling
edge to dstrb rising edge if the readhandshake field is set
to BPXSCANHS.
SunOS 5.11 Last change: 22 Aug 1994 4
Devices bpp(7D)
The readstrobewidth field controls the time between ack
rising edge and ack falling edge if the readhandshake field
is set to BPNOHS or BPACKBUSYHS. It controls the time
between dstrb rising edge to dstrb falling edge if the
readhandshake field is set to BPXSCANHS.
The values allowed for the writehandshake field are dupli-
cates of the definitions for the readhandshake field. Note
that some of these handshake definitions are only valid in
one mode or the other.
The writesetuptime field controls the time between data
valid to dstrb rising edge for all values of the
writehandshake field.
The writestrobewidth field controls the time between
dstrb rising edge and dstrb falling edge if the
writehandshake field is not set to BPVPRINTHS or
BPVPLOTHS. It controls the minimum time between dstrb
rising edge to dstrb falling edge if the writehandshake
field is set to BPVPRINTHS or BPVPLOTHS.
Transfer Pins Structure
This structure is defined in .
struct bpppins {
uchart outputregpins; /* pins in POR register */
uchart inputregpins; /* pins in PIR register */
};
/* Values for outputregpins field */
#define BPSLCTINPIN 0x01 /* Select in pin */
#define BPAFXPIN 0x02 /* Auto feed pin */
#define BPINITPIN 0x04 /* Initialize pin */
#define BPV1PIN 0x08 /* reserved pin 1 */
#define BPV2PI 0x10 /* reserved pin 2 */
#define BPV3PIN 0x20 /* reserved pin 3 */
#define BPERPIN 0x01 /* Error pin */
#define BPSLCTPIN 0x02 /* Select pin */
#define BPEPIN 0x04 /* Paper empty pin */
Error Pins Structure
This structure is defined in the include file
.
struct bpperrorstatus {
char timeoutoccurred; /* 1 if a timeout occurred */
char buserror; /* 1 if an SBus bus error */
SunOS 5.11 Last change: 22 Aug 1994 5
Devices bpp(7D)
uchart pinstatus; /*
* status of pins which could
* cause an error
*/
};
/* Values for pinstatus field */
#define BPERER 0x01 /* Error pin active */
#define BPSLCTER 0x02 /* Select pin active */
#define BPER 0x04 /* Paper empty pin active */
#define BPSLCTINER 0x10 /* Select in pin active */
#define BPBUSYER 0x40 /* Busy pin active */
ERORS
EBADF The device is opened for write-only access and a
read is attempted, or the device is opened for
read-only access and a write is attempted.
EBUSY The device has been opened and another open is
attempted. An attempt has been made to unload the
driver while one of the units is open.
EINVAL A BPIOCSETPARMS ioctl is attempted with an out
of range value in the bpptransferparms struc-
ture. A BPIOCSETOUTPINS ioctl is attempted with
an invalid value in the pins structure. An ioctl
is attempted with an invalid value in the command
argument. An invalid command argument is received
during modload(1M) or modunload(1M).
EIO The driver encountered an SBus bus error when
attempting an access.
A read or write does not complete properly, due to
a peripheral error or a transfer timeout.
A BPIOCTESTIO ioctl call is attempted while a
condition exists which would prevent a transfer
(such as a peripheral error).
ENXIO The driver has received an open request for a
unit for which the attach failed. The driver has
received a read or write request for a unit number
greater than the number of units available. The
driver has received a write request for a unit
which has an active peripheral error.
SunOS 5.11 Last change: 22 Aug 1994 6
Devices bpp(7D)
FILES
/dev/bppn bi-directional parallel port devices
SEE ALSO
ioctl(2), read(2), write(2), sbus(4)
SunOS 5.11 Last change: 22 Aug 1994 7
|