1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
'\" te
.\" Copyright (c) 20002 Sun Microsystems, Inc.
.\" All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH PRNIO 7I "Jan 2, 2002"
.SH NAME
prnio \- generic printer interface
.SH SYNOPSIS
.LP
.nf
\fB#include <sys/prnio.h>\fR
.fi
.SH DESCRIPTION
.sp
.LP
The \fBprnio\fR generic printer interface defines ioctl commands and data
structures for printer device drivers.
.sp
.LP
\fBprnio\fR defines and provides facilities for five basic phases of the
printing process:
.RS +4
.TP
.ie t \(bu
.el o
Identification \(em Retrieve device information/attributes
.RE
.RS +4
.TP
.ie t \(bu
.el o
Setup \(em Set device attributes
.RE
.RS +4
.TP
.ie t \(bu
.el o
Transfer \(em Transfer data to or from the device
.RE
.RS +4
.TP
.ie t \(bu
.el o
Cleanup \(em Transfer phase conclusion
.RE
.RS +4
.TP
.ie t \(bu
.el o
Abort \(em Transfer phase interruption
.RE
.sp
.LP
During the Identification phase, the application retrieves a set of device
capabilities and additional information using the \fBPRNIOC_GET_IFCAP\fR,
\fBPRNIOC_GET_STATUS\fR, \fBPRNIOC_GET_TIMEOUTS\fR, \fBPRNIOC_GET_IFINFO\fR and
\fBPRNIOC_GET_1284_DEVID\fR commands.
.sp
.LP
During the Setup phase the application sets some interface attributes and
probably resets the printer as described in the \fBPRNIOC_SET_IFCAP\fR,
\fBPRNIOC_SET_TIMEOUTS\fR and \fBPRNIOC_RESET\fR sections.
.sp
.LP
During the Transfer phase, data is transferred in a forward (host to
peripheral) or reverse direction (peripheral to host). Transfer is accomplished
using \fBwrite\fR(2) and \fBread\fR(2) system calls. For \fBprnio\fR compliant
printer drivers, forward transfer support is mandatory, while reverse transfer
support is optional. Applications can also use \fBPRNIOC_GET_STATUS\fR and
\fBPRNIOC_GET_1284_STATUS\fR commands during the transfer to monitor the device
state.
.sp
.LP
The Cleanup phase is accomplished by closing the device using \fBclose\fR(2).
Device drivers supporting \fBprnio\fR may set non-zero error code as
appropriate. Applications should explicitly \fBclose\fR(2) a device before
exiting and check \fBerrno\fR value.
.sp
.LP
The Abort phase is accomplished by interrupting the \fBwrite\fR(2) and
\fBread\fR(2) system calls. The application can perform some additional cleanup
during the Abort phase as described in \fBPRNIOC_GET_IFCAP\fR section.
.SH IOCTLS
.sp
.ne 2
.na
\fB\fBPRNIOC_GET_IFCAP\fR\fR
.ad
.RS 21n
Application can retrieve printer interface capabilities using this command. The
\fBioctl\fR(2) argument is a pointer to \fBuint_t\fR, a bit field representing
a set of properties and services provided by a printer driver. Set bit means
supported capability. The following values are defined:
.br
.in +2
\fBPRN_BIDI\fR - When this bit is set, the interface operates in a
bidirectional mode, instead of forward-only mode.
.in -2
.br
.in +2
\fBPRN_HOTPLUG\fR - If this bit is set, the interface allows device
hot-plugging.
.in -2
.br
.in +2
\fBPRN_1284_DEVID\fR - If this bit is set, the device is capable of returning
\fI1284\fR device ID (see \fBPRNIOC_GET_1284_DEVID\fR.)
.in -2
.br
.in +2
\fBPRN_1284_STATUS\fR - If this bit is set, the device driver can return device
status lines (see \fBPRNIOC_GET_1284_STATUS\fR). Some devices support this
ioctl in unidirectional mode only.
.in -2
.br
.in +2
\fBPRN_TIMEOUTS\fR - If this bit is set the peripheral may stall during the
transfer phase and the driver can timeout and return from the \fBwrite\fR(2)
and \fBread\fR(2) returning the number of bytes that have been transferred. If
\fBPRN_TIMEOUTS\fR is set, the driver supports this functionality and the
timeout values can be retrieved and modified via the \fBPRNIOC_GET_TIMEOUTS\fR
and \fBPRNIOC_SET_TIMEOUTS\fR ioctls. Otherwise, applications can implement
their own timeouts and abort phase.
.in -2
.br
.in +2
\fBPRN_STREAMS\fR - This bit impacts the application abort phase behaviour. If
the device claimed \fBPRN_STREAMS\fR capability, the application must issue an
\fBI_FLUSH\fR \fBioctl\fR(2) before \fBclose\fR(2) to dismiss the untransferred
data. Only STREAMS drivers can support this capability.
.in -2
.RE
.sp
.ne 2
.na
\fBPRNIOC_SET_IFCAP\fR
.ad
.RS 21n
This ioctl can be used to change interface capabilities. The argument is a
pointer to \fBuint_t\fR bit field that is described in detail in the
\fBPRNIOC_GET_IFCAP\fR section. Capabilities should be set one at a time;
otherwise the command will return \fBEINVAL\fR. The following capabilities can
be changed by this ioctl:
.br
.in +2
\fBPRN_BIDI\fR - When this capability is set, the interface operates in a
bidirectional mode, instead of forward-only mode. Devices that support only one
mode will not return error; applications should use \fBPRNIOC_GET_IFCAP\fR to
check if the mode was successfully changed. Because some capabilities may be
altered as a side effect of changing other capabilities, this command should be
followed by \fBPRNIOC_GET_IFCAP\fR.
.in -2
.RE
.sp
.ne 2
.na
\fBPRNIOC_GET_IFINFO\fR
.ad
.RS 21n
This command can be used to retrieve printer interface info string, which is an
arbitrary format string usually describing the bus type. The argument is a
pointer to \fBstruct prn_interface_info\fR as described below.
.RE
.sp
.in +2
.nf
struct prn_interface_info {
uint_t if_len; /* length of buffer */
uint_t if_rlen; /* actual info length */
char *if_data; /* buffer address */
};
.fi
.in -2
.sp
.LP
The application allocates a buffer and sets \fBif_data\fR and \fBif_len\fR
values to its address and length, respectively. The driver returns the string
to this buffer and sets \fBif_len\fR to its length. If \fBif_len\fR is less
that \fBif_rlen\fR, the driver must return the first \fBif_len\fR bytes of the
string. The application may then repeat the command with a bigger buffer.
.sp
.LP
Although \fBprnio\fR does not limit the contents of the interface info string,
some values are recommended and defined in <\fBsys/prnio.h\fR> by the following
macros:
.br
.in +2
\fBPRN_PARALLEL\fR - Centronics or \fIIEEE 1284\fR compatible devices
.in -2
.br
.in +2
\fBPRN_SERIAL\fR - EIA-232/EIA-485 serial ports
.in -2
.br
.in +2
\fBPRN_USB\fR - Universal Serial Bus printers
.in -2
.br
.in +2
\fBPRN_1394\fR - \fIIEEE 1394\fR peripherals
.in -2
.br
.in +2
Printer interface info string is for information only: no implications should
be made from its value.
.in -2
.sp
.ne 2
.na
\fBPRNIOC_RESET\fR
.ad
.RS 25n
Some applications may want to reset the printer state during Setup and/or
Cleanup phase using \fBPRNIOC_RESET\fR command. Reset semantics are
device-specific, and in general, applications using this command should be
aware of the printer type.
.sp
Each \fBprnio\fR compliant driver is required to accept this request, although
performed actions are completely driver-dependent. More information on the
\fBPRNIOC_RESET\fR implementation for the particular driver is available in the
corresponding man page and printer manual.
.RE
.sp
.ne 2
.na
\fBPRNIOC_GET_1284_DEVID\fR
.ad
.RS 25n
This command can be used to retrieve printer device ID as defined by \fIIEEE
1284-1994\fR.The \fBioctl\fR(2) argument is a pointer to \fBstruct
prn_1284_device_id\fR as described below.
.RE
.sp
.in +2
.nf
struct prn_1284_device_id {
uint_t id_len; /* length of buffer */
uint_t id_rlen; /* actual ID length */
char *id_data; /* buffer address */
};
.fi
.in -2
.sp
.LP
For convenience, the two-byte length field is not considered part of device ID
string and is not returned in the user buffer. Instead, \fBid_rlen\fR value
shall be set to (length - 2) by the driver, where length is the ID length field
value. If buffer length is less than \fBid_rlen\fR, the driver returns the
first \fBid_len\fR bytes of the ID.
.sp
.LP
The printer driver must return the most up-to-date value of the device ID.
.sp
.ne 2
.na
\fBPRNIOC_GET_STATUS\fR
.ad
.RS 21n
This command can be used by applications to retrieve current device status. The
argument is a pointer to \fBuint_t\fR, where the status word is returned.
Status is a combination of the following bits:
.RE
.br
.in +2
\fBPRN_ONLINE\fR - For devices that support \fBPRN_HOTPLUG\fR capability,
this bit is set when the device is online, otherwise the device is offline.
Devices without \fBPRN_HOTPLUG\fR support should always have this bit set.
.in -2
.br
.in +2
\fBPRN_READY\fR - This bit indicates if the device is ready to receive/send
data. Applications may use this bit for an outbound flow control
.in -2
.sp
.ne 2
.na
\fB\fBPRNIOC_GET_1284_STATUS\fR\fR
.ad
.RS 26n
Devices that support \fBPRN_1284_STATUS\fR capability accept this ioctl to
retrieve the device status lines defined in \fIIEEE 1284\fR for use in
Compatibility mode. The following bits may be set by the driver:
.br
.in +2
\fBPRN_1284_NOFAULT\fR - Device is not in error state
.in -2
.br
.in +2
\fBPRN_1284_SELECT\fR - Device is selected
.in -2
.br
.in +2
\fBPRN_1284_PE\fR - Paper error
.in -2
.br
.in +2
\fBPRN_1284_BUSY\fR - Device is busy
.in -2
.RE
.sp
.ne 2
.na
\fB\fBPRNIOC_GET_TIMEOUTS\fR\fR
.ad
.RS 26n
This command retrieves current transfer timeout values for the driver. The
argument is a pointer to \fBstruct prn_timeouts\fR as described below.
.RE
.sp
.in +2
.nf
struct prn_timeouts {
uint_t tmo_forward; /* forward transfer timeout */
uint_t tmo_reverse; /* reverse transfer timeout */
};
.fi
.in -2
.sp
.LP
\fBtmo_forward\fR and \fBtmo_reverse\fR define forward and reverse transfer
timeouts in seconds. This command is only valid for drivers that support
\fBPRN_TIMEOUTS\fR capability.
.sp
.ne 2
.na
\fB\fBPRNIOC_SET_TIMEOUTS\fR\fR
.ad
.RS 23n
This command sets current transfer timeout values for the driver. The
argument is a pointer to \fBstruct prn_timeouts\fR. See
\fBPRNIOC_GET_TIMEOUTS\fR for description of this structure. This command is
only valid for drivers that support \fBPRN_TIMEOUTS\fR capability.
.RE
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Architecture SPARC, IA
_
Interface Stability Evolving
.TE
.SH SEE ALSO
.sp
.LP
\fBclose\fR(2), \fBioctl\fR(2), \fBread\fR(2), \fBwrite\fR(2),
\fBattributes\fR(5), \fBecpp\fR(7D), \fBusbprn\fR(7D), \fBlp\fR(7D)
.sp
.LP
\fIIEEE Std 1284-1994\fR
|