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$ 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 plip0 42.Ar myaddress hisaddress 43.Op Fl link0 44.Pp 45.Cd "device ppbus" 46.Cd "device plip" 47.Cd "device ppc" 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.Fx 78mode (LPIP). 79This is the simpler of the two modes 80and therefore slightly more efficient. 81.It Cm link0 82Use Crynwr/Linux compatible mode (CLPIP). 83This mode has a simulated Ethernet 84packet header, and is easier to interface to other types of equipment. 85.El 86.Pp 87The interface MTU defaults to 1500, but may be set to any value. 88Both ends 89of the link must be configured with the same MTU. 90.Ss Cable Connections 91The cable connecting the two parallel ports should be wired as follows: 92.Bd -literal 93 Pin Pin Description 94 2 15 Data0 -> ERROR* 95 3 13 Data1 -> SLCT 96 4 12 Data2 -> PE 97 5 10 Data3 -> ACK* 98 6 11 Data4 -> BUSY 99 15 2 ERROR* -> Data0 100 13 3 SLCT -> Data1 101 12 4 PE -> Data2 102 10 5 ACK* -> Data3 103 11 6 BUSY -> Data4 104 18-25 18-25 Ground 105.Ed 106.Pp 107Cables with this wiring are widely available as 'Laplink' cables, and 108are often coloured yellow. 109.Pp 110The connections are symmetric, and provide 5 lines in each direction (four 111data plus one handshake). 112The two modes use the same wiring, but make a 113different choice of which line to use as handshake. 114.Ss FreeBSD LPIP mode 115The signal lines are used as follows: 116.Bl -tag -width dataxxxx(Pinxx) 117.It Em Data0 (Pin 2) 118Data out, bit 0. 119.It Em Data1 (Pin 3) 120Data out, bit 1. 121.It Em Data2 (Pin 4) 122Data out, bit 2. 123.It Em Data3 (Pin 5) 124Handshake out. 125.It Em Data4 (Pin 6) 126Data out, bit 3. 127.It Em ERROR* (pin 15) 128Data in, bit 0. 129.It Em SLCT (pin 13) 130Data in, bit 1. 131.It Em PE (pin 12) 132Data in, bit 2. 133.It Em BUSY (pin 11) 134Data in, bit 3. 135.It Em ACK* (pin 10) 136Handshake in. 137.El 138.Pp 139When idle, all data lines are at zero. 140Each byte is signalled in four steps: 141sender writes the 4 most significant bits and raises the handshake line; 142receiver reads the 4 bits and raises its handshake to acknowledge; 143sender places the 4 least significant bits on the data lines and lowers 144the handshake; receiver reads the data and lowers its handshake. 145.Pp 146The packet format has a two-byte header, comprising the fixed values 0x08, 1470x00, immediately followed by the IP header and data. 148.Pp 149The start of a packet is indicated by simply signalling the first byte 150of the header. 151The end of the packet is indicated by inverting 152the data lines (i.e., writing the ones-complement of the previous nibble 153to be transmitted) without changing the state of the handshake. 154.Pp 155Note that the end-of-packet marker assumes that the handshake signal and 156the data-out bits can be written in a single instruction - otherwise 157certain byte values in the packet data would falsely be interpreted 158as end-of-packet. 159This is not a problem for the PC printer port, 160but requires care when implementing this protocol on other equipment. 161.Ss Crynwr/Linux CLPIP mode 162The signal lines are used as follows: 163.Bl -tag -width dataxxxx(Pinxx) 164.It Em Data0 (Pin 2) 165Data out, bit 0. 166.It Em Data1 (Pin 3) 167Data out, bit 1. 168.It Em Data2 (Pin 4) 169Data out, bit 2. 170.It Em Data3 (Pin 5) 171Data out, bit 3. 172.It Em Data4 (Pin 6) 173Handshake out. 174.It Em ERROR* (pin 15) 175Data in, bit 0. 176.It Em SLCT (pin 13) 177Data in, bit 1. 178.It Em PE (pin 12) 179Data in, bit 2. 180.It Em ACK* (pin 10) 181Data in, bit 3. 182.It Em BUSY (pin 11) 183Handshake in. 184.El 185.Pp 186When idle, all data lines are at zero. 187Each byte is signalled in four steps: 188sender writes the 4 least significant bits and raises the handshake line; 189receiver reads the 4 bits and raises its handshake to acknowledge; 190sender places the 4 most significant bits on the data lines and lowers 191the handshake; receiver reads the data and lowers its handshake. 192[Note that this is the opposite nibble order to LPIP mode]. 193.Pp 194Packet format is: 195.Bd -literal 196Length (least significant byte) 197Length (most significant byte) 19812 bytes of supposed MAC addresses (ignored by FreeBSD). 199Fixed byte 0x08 200Fixed byte 0x00 201<IP datagram> 202Checksum byte. 203.Ed 204.Pp 205The length includes the 14 header bytes, but not the length bytes themselves 206nor the checksum byte. 207.Pp 208The checksum is a simple arithmetic sum of all the bytes (again, including 209the header but not checksum or length bytes). 210.Fx 211calculates 212outgoing checksums, but does not validate incoming ones. 213.Pp 214The start of packet has to be signalled specially, since the line chosen 215for handshake-in cannot be used to generate an interrupt. 216The sender writes the value 0x08 to the data lines, and waits for the receiver 217to respond by writing 0x01 to its data lines. 218The sender then starts 219signalling the first byte of the packet (the length byte). 220.Pp 221End of packet is deduced from the packet length and is not signalled 222specially (although the data lines are restored to the zero, idle 223state to avoid spuriously indicating the start of the next packet). 224.Sh SEE ALSO 225.Xr ppbus 4 , 226.Xr ppc 4 , 227.Xr ifconfig 8 228.Sh BUGS 229Busy-waiting loops are used while handshaking bytes, (and worse still when 230waiting for the receiving system to respond to an interrupt for the start 231of a packet). 232Hence a fast system talking to a slow one will consume 233excessive amounts of CPU. 234This is unavoidable in the case of CLPIP mode 235due to the choice of handshake lines; it could theoretically be improved 236in the case of LPIP mode. 237.Pp 238Polling timeouts are controlled by counting loop iterations rather than 239timers, and so are dependent on CPU speed. 240This is somewhat stabilised 241by the need to perform (slow) ISA bus cycles to actually read the port. 242