004573fb09492a0633379bcb0fa4241c45e46c04
[dragonfly.git] / share / man / man4 / ppbus.4
1 .\" Copyright (c) 1998, 1999 Nicolas Souchu
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD: src/share/man/man4/ppbus.4,v 1.14.2.5 2001/08/17 13:08:39 ru Exp $
26 .\"
27 .Dd March 1, 1998
28 .Dt PPBUS 4
29 .Os
30 .Sh NAME
31 .Nm ppbus
32 .Nd Parallel Port Bus system
33 .Sh SYNOPSIS
34 .Cd "device ppbus"
35 .Cd "options DEBUG_1284"
36 .Pp
37 .Cd "device vpo"
38 .Pp
39 .Cd "device lpt"
40 .Cd "device plip"
41 .Cd "device ppi"
42 .Cd "device pps"
43 .Cd "device lpbb"
44 .Sh DESCRIPTION
45 The
46 .Em ppbus
47 system provides a uniform, modular and architecture-independent
48 system for the implementation of drivers to control various parallel devices,
49 and to utilize different parallel port chipsets.
50 .Sh DEVICE DRIVERS
51 In order to write new drivers or port existing drivers, the ppbus system
52 provides the following facilities:
53 .Bl -bullet -offset indent
54 .It
55 architecture-independent macros or functions to access parallel ports
56 .It
57 mechanism to allow various devices to share the same parallel port
58 .It
59 a user interface named
60 .Xr ppi 4
61 that allows parallel port access from outside the kernel without conflicting
62 with kernel-in drivers.
63 .El
64 .Ss Developing new drivers
65 The ppbus system has been designed to support the development of standard
66 and non-standard software:
67 .Pp
68 .Bl -column "Driver" -compact
69 .It Em Driver Ta Em Description
70 .It Sy vpo Ta "VPI0 parallel to Adaptec AIC-7110 SCSI controller driver" .
71 It uses standard and non-standard parallel port accesses.
72 .It Sy ppi Ta "Parallel port interface for general I/O"
73 .It Sy pps Ta "Pulse per second Timing Interface"
74 .It Sy lpbb Ta "Philips official parallel port I2C bit-banging interface"
75 .El
76 .Ss Porting existing drivers
77 Another approach to the ppbus system is to port existing drivers.
78 Various drivers have already been ported:
79 .Pp
80 .Bl -column "Driver" -compact
81 .It Em Driver Ta Em Description
82 .It Sy lpt Ta "lpt printer driver"
83 .It Sy plip Ta "lp parallel network interface driver"
84 .El
85 .Pp
86 ppbus should let you port any other software even from other operating systems
87 that provide similar services.
88 .Sh PARALLEL PORT CHIPSETS
89 Parallel port chipset support is provided by
90 .Xr ppc 4 .
91 .Pp
92 The ppbus system provides functions and macros to allocate a new
93 parallel port bus, then initialize it and upper peripheral device drivers.
94 .Pp
95 ppc makes chipset detection and initialization and then calls ppbus attach
96 functions to initialize the ppbus system.
97 .Sh PARALLEL PORT MODEL
98 The logical parallel port model chosen for the ppbus system is the PC's
99 parallel port model.
100 Consequently, for the i386 implementation of ppbus,
101 most of the services provided by ppc are macros for
102 .Fn inb
103 and
104 .Fn outb
105 calls.
106 But, for an other architecture, accesses to one of our logical
107 registers (data, status, control...) may require more than one I/O access.
108 .Ss Description
109 The parallel port may operate in the following modes:
110 .Bl -bullet -offset indent
111 .It
112 compatible mode, also called Centronics mode
113 .It
114 bidirectional 8/4-bits mode, also called NIBBLE mode
115 .It
116 byte mode, also called PS/2 mode
117 .It
118 Extended Capability Port mode, ECP
119 .It
120 Enhanced Parallel Port mode, EPP
121 .It
122 mixed ECP+EPP or ECP+PS/2 modes
123 .El
124 .Ss Compatible mode
125 This mode defines the protocol used by most PCs to transfer data to a printer.
126 In this mode, data is placed on the port's data lines, the printer status is
127 checked for no errors and that it is not busy, and then a data Strobe is
128 generated by the software to clock the data to the printer.
129 .Pp
130 Many I/O controllers have implemented a mode that uses a FIFO buffer to
131 transfer data with the Compatibility mode protocol.
132 This mode is referred to as
133 "Fast Centronics" or "Parallel Port FIFO mode".
134 .Ss Bidirectional mode
135 The NIBBLE mode is the most common way to get reverse channel data from a
136 printer or peripheral.
137 Combined with the standard host to printer mode, it
138 provides a complete bidirectional channel.
139 .Pp
140 In this mode, outputs are 8-bits long.
141 Inputs are accomplished by reading
142 4 of the 8 bits of the status register.
143 .Ss Byte mode
144 In this mode, the data register is used either for outputs and inputs.
145 Then,
146 any transfer is 8-bits long.
147 .Ss Extended Capability Port mode
148 The ECP protocol was proposed as an advanced mode for communication with
149 printer and scanner type peripherals.
150 Like the EPP protocol, ECP mode provides
151 for a high performance bidirectional communication path between the host
152 adapter and the peripheral.
153 .Pp
154 ECP protocol features include:
155 .Bl -item -offset indent
156 .It
157 Run_Length_Encoding (RLE) data compression for host adapters
158 .It
159 FIFOs for both the forward and reverse channels
160 .It
161 DMA as well as programmed I/O for the host register interface.
162 .El
163 .Ss Enhanced Parallel Port mode
164 The EPP protocol was originally developed as a means to provide a high
165 performance parallel port link that would still be compatible with the
166 standard parallel port.
167 .Pp
168 The EPP mode has two types of cycle: address and data.
169 What makes the
170 difference at hardware level is the strobe of the byte placed on the data
171 lines.
172 Data are strobed with nAutofeed, addresses are strobed with
173 nSelectin signals.
174 .Pp
175 A particularity of the ISA implementation of the EPP protocol is that an
176 EPP cycle fits in an ISA cycle.
177 In this fashion, parallel port peripherals can
178 operate at close to the same performance levels as an equivalent ISA plug-in
179 card.
180 .Pp
181 At software level, you may implement the protocol you wish, using data and
182 address cycles as you want.
183 This is for the IEEE1284 compatible part.
184 Then,
185 peripheral vendors may implement protocol handshake with the following
186 status lines: PError, nFault and Select.
187 Try to know how these lines toggle
188 with your peripheral, allowing the peripheral to request more data, stop the
189 transfer and so on.
190 .Pp
191 At any time, the peripheral may interrupt the host with the nAck signal without
192 disturbing the current transfer.
193 .Ss Mixed modes
194 Some manufacturers, like SMC, have implemented chipsets that support mixed
195 modes.
196 With such chipsets, mode switching is available at any time by
197 accessing the extended control register.
198 .Sh IEEE1284-1994 Standard
199 .Ss Background
200 This standard is also named "IEEE Standard Signaling Method for a
201 Bidirectional Parallel Peripheral Interface for Personal Computers". It
202 defines a signaling method for asynchronous, fully interlocked, bidirectional
203 parallel communications between hosts and printers or other peripherals.
204 It
205 also specifies a format for a peripheral identification string and a method of
206 returning this string to the host outside of the bidirectional data stream.
207 .Pp
208 This standard is architecture independent and only specifies dialog handshake
209 at signal level.
210 One should refer to architecture specific documentation in
211 order to manipulate machine dependent registers, mapped memory or other
212 methods to control these signals.
213 .Pp
214 The IEEE1284 protocol is fully oriented with all supported parallel port
215 modes.
216 The computer acts as master and the peripheral as slave.
217 .Pp
218 Any transfer is defined as a finite state automate.
219 It allows software to
220 properly manage the fully interlocked scheme of the signaling method.
221 The compatible mode is supported "as is" without any negotiation because it
222 is compatible.
223 Any other mode must be firstly negotiated by the host to check
224 it is supported by the peripheral, then to enter one of the forward idle
225 states.
226 .Pp
227 At any time, the slave may want to send data to the host.
228 This is only
229 possible from forward idle states (nibble, byte, ecp...).
230 So, the
231 host must have previously negotiated to permit the peripheral to
232 request transfer.
233 Interrupt lines may be dedicated to the requesting signals
234 to prevent time consuming polling methods.
235 .Pp
236 But peripheral requests are only a hint to the master host.
237 If the host
238 accepts the transfer, it must firstly negotiate the reverse mode and then
239 starts the transfer.
240 At any time during reverse transfer, the host may
241 terminate the transfer or the slave may drive wires to signal that no more
242 data is available.
243 .Ss Implementation
244 IEEE1284 Standard support has been implemented at the top of the ppbus system
245 as a set of procedures that perform high level functions like negotiation,
246 termination, transfer in any mode without bothering you with low level
247 characteristics of the standard.
248 .Pp
249 IEEE1284 interacts with the ppbus system as least as possible.
250 That means
251 you still have to request the ppbus when you want to access it, the negotiate
252 function doesn't do it for you.
253 And of course, release it later.
254 .Sh ARCHITECTURE
255 .Ss adapter, ppbus and device layers
256 First, there is the
257 .Em adapter
258 layer, the lowest of the ppbus system.
259 It provides
260 chipset abstraction throw a set of low level functions that maps the logical
261 model to the underlying hardware.
262 .Pp
263 Secondly, there is the
264 .Em ppbus
265 layer that provides functions to:
266 .Bl -enum -offset indent
267 .It
268 share the parallel port bus among the daisy-chain like connected devices
269 .It
270 manage devices linked to ppbus
271 .It
272 propose an arch-independent interface to access the hardware layer.
273 .El
274 .Pp
275 Finally, the
276 .Em device
277 layer gathers the parallel peripheral device drivers.
278 .Ss Parallel modes management
279 We have to differentiate operating modes at various ppbus system layers.
280 Actually, ppbus and adapter operating modes on one hands and for each
281 one, current and available modes are separated.
282 .Pp
283 With this level of abstraction a particular chipset may commute from any
284 native mode the any other mode emulated with extended modes without
285 disturbing upper layers.
286 For example, most chipsets support NIBBLE mode as
287 native and emulated with ECP and/or EPP.
288 .Pp
289 This architecture should support IEEE1284-1994 modes.
290 .Sh FEATURES
291 .Ss The boot process
292 The boot process starts with the probe phasis of the
293 .Xr ppc 4
294 driver during ISA bus (PC architecture) initialization.
295 During attachment of
296 the ppc driver, a new ppbus structure is allocated, then probe and attachment
297 for this new bus node are called.
298 .Pp
299 ppbus attachment tries to detect any PnP parallel peripheral (according to
300 .%T "Plug and Play Parallel Port Devices"
301 draft from (c)1993-4 Microsoft Corporation)
302 then probes and attaches known device drivers.
303 .Pp
304 During probe, device drivers are supposed to request the ppbus and try to
305 set their operating mode.
306 This mode will be saved in the context structure and
307 returned each time the driver requests the ppbus.
308 .Ss Bus allocation and interrupts
309 ppbus allocation is mandatory not to corrupt I/O of other devices.
310 An other
311 usage of ppbus allocation is to reserve the port and receive incoming
312 interrupts.
313 .Pp
314 High level interrupt handlers are connected to the ppbus system thanks to the
315 newbus
316 .Fn BUS_SETUP_INTR
317 and
318 .Fn BUS_TEARDOWN_INTR
319 functions.
320 But, in order to attach a handler, drivers must
321 own the bus.
322 Consequently, a ppbus request is mandatory in order to call the above
323 functions (see existing drivers for more info). Note that the interrupt handler
324 is automatically released when the ppbus is released.
325 .Ss Microsequences
326 .Em Microsequences
327 is a general purpose mechanism to allow fast low-level
328 manipulation of the parallel port.
329 Microsequences may be used to do either
330 standard (in IEEE1284 modes) or non-standard transfers.
331 The philosophy of
332 microsequences is to avoid the overhead of the ppbus layer and do most of
333 the job at adapter level.
334 .Pp
335 A microsequence is an array of opcodes and parameters.
336 Each opcode codes an
337 operation (opcodes are described in
338 .Xr microseq 9 ) .
339 Standard I/O operations are implemented at ppbus level whereas basic I/O
340 operations and microseq language are coded at adapter level for efficiency.
341 .Pp
342 As an example, the
343 .Xr vpo 4
344 driver uses microsequences to implement:
345 .Bl -bullet -offset indent
346 .It
347 a modified version of the NIBBLE transfer mode
348 .It
349 various I/O sequences to initialize, select and allocate the peripheral
350 .El
351 .Sh SEE ALSO
352 .Xr lpt 4 ,
353 .Xr plip 4 ,
354 .Xr ppc 4 ,
355 .Xr ppi 4 ,
356 .Xr vpo 4
357 .Sh HISTORY
358 The
359 .Nm
360 manual page first appeared in
361 .Fx 3.0 .
362 .Sh AUTHORS
363 This
364 manual page was written by
365 .An Nicolas Souchu .