Lineprinter Device Driver Project The PC has a relatively simple parallel interface for a Centronics printer. See the distriibuted hardware descriptions. We would like to write a Xinu device driver for it, to fold it into the device-independent Xinu (essentially UNIX) i/o system call setup. Using another SAPC *as* a Parallel Printer. We can emulate a parallel printer in a SAPC equipped with a bidirectional parallel port, one which can input 8 data bits plus a handshake line. This printer emulator program is provided--it's just a standalone program, not a Xinu app. A script lptest.script shows how you can put two SAPC systems through their paces at the hardware level to communicate through the parallel cable. Summary of parallel ports on SAPCs LPT1 on all our PCs data port: (0x378) 8 bits, output only. data strobe: bit 0 of port PCR (0x37a): low->high->low for strobe signal acknowledge: bit 6 of port PSR (0x379): input only, high->low->high for acknowledge signal, initiates IRQ7 interrupt if enabled via PCR LPT2 on SAPCs 12 and 14 (for printer emulator) data port: (0x278) 8 bits, input enabled by DIR bit of PCR data strobe: bit 0 of port PCR (0x27a) acknowledge: bit 6 of port PSR (0x279) (it could interrupt on some IRQ, but we don't use interrupts in the emulator) We need a special cable between the LPT1 of the Xinu sys and LPT2 of the printer emulator system. Here is its spec: SAPC running Xinu SAPC running as printer emulator pin 1 Strobe pin 10 Acknowledge pin 2 Data bit 0 pin 23 Data bit 0, port B pin 3 Data bit 1 pin 21 Data bit 1, port B ... ... pin 9 Data bit 7 pin 9 Data bit 7, port B pin 10 Acknowledge pin 1 Strobe The minimal version of this project is straightforward and can easily be done by one person. For the minimal version, just handle printer data, and provide test program(s) showing the use of your printer driver from user-level code. Note that Xinu as provided has a file lpstubs.c that compiles to lpstubs.opc in libx.a. You need to flesh this out and load it ahead of the library. The i/o system configuration file conf.c is already set up to hold this LP device, so you only need to work on the lpstubs replacement. Copy the Makefile in $xinu/examples as a starting point. You can copy and use the assembler envelope irq7.s in $pclibsrc. See the queue subdir for a queue implementation that would be nice to use instead of the open-coded queues we see in Comer's book, for the shared data between the upper and lower halves. For partnerships. Your test programs should include multiple processes printing at the same time. The output is expected to intermix, but should all get out. You should definitely use an encapsulated queue for the data. Additional notes. 1. Don't name a function "enqueue", because Xinu has one already by this name. 2. Note that enabling LPT interrupts does *not* cause an immediate interrupt to happen, as is true with UART transmitters. LPT interrupts only happen when an ACK comes in from the printer. So you need to output a first character from the upper half. To tell which char is first, you need a Boolean variable, off when no lp data is being processed and on when it is. The semaphore count isn't quite right for this, because it says what's in the buffer, not what's in buffer+hardware. 3. You can leave LPT interrupts on all the time once the system is up, because if you run out of data you can just turn off the Boolean variable mentioned above--the hardware doesn't "remember" the interrupt. 4. Note that the standalone support library and the Xinu support library are somewhat different. Xinu uses inb and outb instead of inpt and outpt, and set_evec instead of set_intr_gate. See $xuker/../com/comoutput.c for examples of use of inb and outb.