Specifications

Sample Driver Written in C
B.1 LRDRIVER Example
/* Define the line printer port CSR offsets.
* Note that the unit initialization routine determines if this unit is
* associated with a VL82C106 on system bus or on an ISA option card.
* Note also that due to the byte-laned I/O space, data read from the ISA
* LPS register (byte offset 1) must be shifted right 1 byte, and data read
* from the LPC register (byte offset 2) must be shifted right 2 bytes.
*/
/* Offsets for VL82C106 on system bus */
#define LR_COMBO_LWD 0x3bc /* line printer port data write */
#define LR_COMBO_LPS 0x3bd /* line printer port status */
#define LR_COMBO_LCW 0x3be /* line printer port control write */
/* Offsets for VL82C106 on an ISA option card */
#define LR_LPT2_PORT 0x378 /* ISA I/O address for LPT2 */
#define LR_LPT3_PORT 0x278 /* ISA I/O address for LPT3 */
/* Actual register offset is LR_LPT2_PORT or */
/* LR_LPT2_PORT plus one of the following: */
#define LR_ISA_LWD 0x0 /* line printer port data write */
#define LR_ISA_LPS 0x1 /* line printer port status */
#define LR_ISA_LCW 0x2 /* line printer port control write */
#define LR_LPT2_IRQ 7 /* Expected ISA IRQ for LPT2 */
#define LR_LPT3_IRQ 5 /* Expected ISA IRQ for LPT3 */
/* Line Printer Control Register
* Mask values are defined for each of the control bits in the LPC. This
* driver always writes a new value to the LPC when a bit needs to be set.
* A convenient way of doing this is to logically or together a subset of the
* following masks to form the new LPC value.
*/
enum lpc_masks {
LPC_M_STROBE = 0x01, /* Strobe data to printer */
LPC_M_AUTO_FEED = 0x02, /* Auto line feed enabled */
LPC_M_INIT_OFF = 0x04, /* Disable INIT signal */
LPC_M_SELECT = 0x08, /* Select printer "on line" */
LPC_M_IRQ_EN = 0x10, /* Interrupt enable */
LPC_M_DIR_READ = 0x20 /* Direction is read if set, else write */
};
/* Line Printer Status Register
* Define a structure type with bit fields that corresponds to the status
* bits. This structure type facilitates the testing of these conditions.
*/
typedef struct _lps {
unsigned int : 2; /* Reserved */
unsigned int lps_irqp : 1; /* Interrupt pending */
unsigned int lps_ok : 1; /* Ok status, i.e. no error */
unsigned int lps_online : 1; /* Select on line */
unsigned int lps_paperout : 1; /* Paper empty */
unsigned int lps_nak : 1; /* Not acknowledge */
unsigned int lps_ready : 1; /* Ready, i.e. not busy */
} LPS;
/* Define Device-Dependent Unit Control Block with extensions for LR device */
B–3