1.\" -*- nroff -*- 2.\" 3.\" Copyright (c) 1996 A.R.Gordon, andrew.gordon@net-tel.co.uk 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" Id: man4.i386/lp.4,v 1.9 1999/02/14 12:06:16 nsouch Exp 31.\" $FreeBSD: src/share/man/man4/lp.4,v 1.5.2.3 2000/12/29 10:18:00 ru Exp $ 32.\" 33.Dd March 4, 1996 34.Dt LP 4 35.Os 36.Sh NAME 37.Nm lp 38.Nd printer port Internet Protocol driver 39.Sh SYNOPSIS 40.Nm ifconfig 41.Ar lp0 42.Ar myaddress hisaddress 43.Op Fl link0 44.Pp 45.Cd "device ppbus" 46.Cd "device plip" 47.Cd "device ppc0 at isa? port? irq 7" 48.Sh DESCRIPTION 49The 50.Nm 51driver allows a PC parallel printer port to be used as a 52point-to-point network interface between two similarly configured systems. 53Data is transferred 4 bits at a time, using the printer status lines for 54input: hence there is no requirement for special bidirectional hardware 55and any standard AT-compatible printer port with working interrupts may be used. 56.Pp 57During the boot process, for each 58.Nm plip 59device which is probed and has an interrupt assigned, a corresponding 60.Nm network 61device is created. 62.Pp 63Configuring an 64.Nm 65device with 66.Xr ifconfig 8 67causes the corresponding 68.Nm parallel port bus 69to be reserved for PLIP until the network interface is configured 'down'. 70.Pp 71The communication protocol is selected by the 72.Cm link0 73flag: 74.Bl -tag -width Fl 75.It Fl link0 76(default) Use 77.Dx 78mode (LPIP). This is the simpler of the two modes 79and therefore slightly more efficient. 80.It Cm link0 81Use Crynwr/Linux compatible mode (CLPIP). This mode has a simulated ethernet 82packet header, and is easier to interface to other types of equipment. 83.El 84.Pp 85The interface MTU defaults to 1500, but may be set to any value. Both ends 86of the link must be configured with the same MTU. 87.Ss Cable Connections 88The cable connecting the two parallel ports should be wired as follows: 89.Bd -literal 90 Pin Pin Description 91 2 15 Data0 -> ERROR* 92 3 13 Data1 -> SLCT 93 4 12 Data2 -> PE 94 5 10 Data3 -> ACK* 95 6 11 Data4 -> BUSY 96 15 2 ERROR* -> Data0 97 13 3 SLCT -> Data1 98 12 4 PE -> Data2 99 10 5 ACK* -> Data3 100 11 6 BUSY -> Data4 101 18-25 18-25 Ground 102.Ed 103.Pp 104Cables with this wiring are widely available as 'Laplink' cables, and 105are often coloured yellow. 106.Pp 107The connections are symmetric, and provide 5 lines in each direction (four 108data plus one handshake). The two modes use the same wiring, but make a 109different choice of which line to use as handshake. 110.Ss LPIP mode 111The signal lines are used as follows: 112.Bl -tag -width dataxxxx(Pinxx) 113.It Em Data0 (Pin 2) 114Data out, bit 0. 115.It Em Data1 (Pin 3) 116Data out, bit 1. 117.It Em Data2 (Pin 4) 118Data out, bit 2. 119.It Em Data3 (Pin 5) 120Handshake out. 121.It Em Data4 (Pin 6) 122Data out, bit 3. 123.It Em ERROR* (pin 15) 124Data in, bit 0. 125.It Em SLCT (pin 13) 126Data in, bit 1. 127.It Em PE (pin 12) 128Data in, bit 2. 129.It Em BUSY (pin 11) 130Data in, bit 3. 131.It Em ACK* (pin 10) 132Handshake in. 133.El 134.Pp 135When idle, all data lines are at zero. Each byte is signalled in four steps: 136sender writes the 4 most significant bits and raises the handshake line; 137receiver reads the 4 bits and raises its handshake to acknowledge; 138sender places the 4 least significant bits on the data lines and lowers 139the handshake; receiver reads the data and lowers its handshake. 140.Pp 141The packet format has a two-byte header, comprising the fixed values 0x08, 1420x00, immediately followed by the IP header and data. 143.Pp 144The start of a packet is indicated by simply signalling the first byte 145of the header. The end of the packet is indicated by inverting 146the data lines (ie. writing the ones-complement of the previous nibble 147to be transmitted) without changing the state of the handshake. 148.Pp 149Note that the end-of-packet marker assumes that the handshake signal and 150the data-out bits can be written in a single instruction - otherwise 151certain byte values in the packet data would falsely be interpreted 152as end-of-packet. This is not a problem for the PC printer port, 153but requires care when implementing this protocol on other equipment. 154.Ss Crynwr/Linux CLPIP mode 155The signal lines are used as follows: 156.Bl -tag -width dataxxxx(Pinxx) 157.It Em Data0 (Pin 2) 158Data out, bit 0. 159.It Em Data1 (Pin 3) 160Data out, bit 1. 161.It Em Data2 (Pin 4) 162Data out, bit 2. 163.It Em Data3 (Pin 5) 164Data out, bit 3. 165.It Em Data4 (Pin 6) 166Handshake out. 167.It Em ERROR* (pin 15) 168Data in, bit 0. 169.It Em SLCT (pin 13) 170Data in, bit 1. 171.It Em PE (pin 12) 172Data in, bit 2. 173.It Em ACK* (pin 10) 174Data in, bit 3. 175.It Em BUSY (pin 11) 176Handshake in. 177.El 178.Pp 179When idle, all data lines are at zero. Each byte is signalled in four steps: 180sender writes the 4 least significant bits and raises the handshake line; 181receiver reads the 4 bits and raises its handshake to acknowledge; 182sender places the 4 most significant bits on the data lines and lowers 183the handshake; receiver reads the data and lowers its handshake. 184[Note that this is the opposite nibble order to LPIP mode]. 185.Pp 186Packet format is: 187.Bd -literal 188Length (least significant byte) 189Length (most significant byte) 19012 bytes of supposed MAC addresses (ignored by 191.Dx Ns ). 192Fixed byte 0x08 193Fixed byte 0x00 194<IP datagram> 195Checksum byte. 196.Ed 197.Pp 198The length includes the 14 header bytes, but not the length bytes themselves 199nor the checksum byte. 200.Pp 201The checksum is a simple arithmetic sum of all the bytes (again, including 202the header but not checksum or length bytes). 203.Dx 204calculates 205outgoing checksums, but does not validate incoming ones. 206.Pp 207The start of packet has to be signalled specially, since the line chosen 208for handshake-in cannot be used to generate an interrupt. The sender 209writes the value 0x08 to the data lines, and waits for the receiver 210to respond by writing 0x01 to its data lines. The sender then starts 211signalling the first byte of the packet (the length byte). 212.Pp 213End of packet is deduced from the packet length and is not signalled 214specially (although the data lines are restored to the zero, idle 215state to avoid spuriously indicating the start of the next packet). 216.Sh SEE ALSO 217.Xr ppbus 4 , 218.Xr ppc 4 , 219.Xr ifconfig 8 220.Sh BUGS 221Busy-waiting loops are used while handshaking bytes, (and worse still when 222waiting for the receiving system to respond to an interrupt for the start 223of a packet). Hence a fast system talking to a slow one will consume 224excessive amounts of CPU. This is unavoidable in the case of CLPIP mode 225due to the choice of handshake lines; it could theoretically be improved 226in the case of LPIP mode. 227.Pp 228Polling timeouts are controlled by counting loop iterations rather than 229timers, and so are dependent on CPU speed. This is somewhat stabilised 230by the need to perform (slow) ISA bus cycles to actually read the port. 231