SYNOPSIS

The bpp driver provides a general-purpose bi-directional interface to parallel devices. It supports a variety of output (printer) and input (scanner) devices, using programmable
timing relationships between the various handshake signals.

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 configuration is BPP_ACK_BUSY_HS for read handshake, BPP_ACK_HS for write handshake, 1 microsecond for all setup times and strobe widths, and 60 seconds for both timeouts. This configuration (in the write mode) drives many common personal computer
parallel printers with Centronics-type interfaces. The application should use the BPPIOC_SETPARMS 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 BPPIOC_GETERR 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 BPPIOC_TESTIO 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 BPPIOC_GETERR ioctl request. Subsequent read(2) calls may fail with ENXIO if the error condition is not rectified. The captured register information will be overwritten
each time an attempted transfer or a BPPIOC_TESTIO ioctl request.

If the read_handshake element of the bpp_transfer_parms structure (see below) is set to BPP_CLEAR_MEM or BPP_SET_MEM, 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 SLCT_IN or AFX pin be set to tell the scanner the direction of the transfer. The AFX line is set when the read_handshake element of the bpp_transfer_parms structure is set to BPP_HSCAN_HS, otherwise the SLCT_IN 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.

The argument is a pointer to a bpp_transfer_parms structure. See below for a description of the elements of this structure. If a parameter is out of range, EINVAL
is returned.

BPPIOC_GETPARMS

Get current transfer parameters.

The argument is a pointer to a bpp_transfer_parms 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).

BPPIOC_SETOUTPINS

Set output pin values.

The argument is a pointer to a bpp_pins structure. See below for a description of the elements of this structure. If a parameter is out of range, EINVAL
is returned.

BPPIOC_GETOUTPINS

Read output pin values. The argument is a pointer to a bpp_pins structure. See below for a description of the elements of this structure.

BPPIOC_GETERR

Get last error status.

The argument is a pointer to a bpp_error_status structure. See below for a description of the elements of this structure. This structure indicates 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
BPPIOC_TESTIO ioctl request. Note: The bits in the pin_status element indicate whether the associated pin is active, not the actual polarity.
The application can check transfer readiness without attempting another transfer using the BPPIOC_TESTIO ioctl. Note: The timeout_occurred
and bus_error fields will never be set by the BPPIOC_TESTIO ioctl, only by an actual failed transfer.

BPPIOC_TESTIO

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 information is captured. The captured
status can be retrieved using the BPPIOC_GETERR ioctl call. Note that the timeout_occurred and bus_error fields will never
be set by this ioctl.

The read_setup_time field controls the time between dstrb falling edge to bsy rising edge if the read_handshake field is set to BPP_NO_HS or BPP_ACK_HS. It controls the time between dstrb falling edge to ack rising edge if the read_handshake field is set to BPP_ACK_HS or BPP_ACK_BUSY_HS. It controls the time between ack falling edge to dstrb rising edge if the read_handshake field is set to BPP_XSCAN_HS.

The read_strobe_width field controls the time between ack rising edge and ack falling edge if the read_handshake field is set to BPP_NO_HS or BPP_ACK_BUSY_HS. It controls the time between dstrb rising edge to dstrb falling edge if the read_handshake field is set to BPP_XSCAN_HS.

The values allowed for the write_handshake field are duplicates of the definitions for the read_handshake field. Note that some of these handshake definitions
are only valid in one mode or the other.

The write_setup_time field controls the time between data valid to dstrb rising edge for all values of the write_handshake field.

The write_strobe_width field controls the time between dstrb rising edge and dstrb falling edge if the write_handshake field is not set to BPP_VPRINT_HS or BPP_VPLOT_HS. It controls the minimum time between dstrb rising edge to dstrb falling edge if the write_handshake field is set to BPP_VPRINT_HS or BPP_VPLOT_HS.

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 BPPIOC_SETPARMS ioctl is attempted with an out of range value in the bpp_transfer_parms structure. A BPPIOC_SETOUTPINS 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 BPPIOC_TESTIO 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.