Deleted Added
full compact
ppbconf.h (36739) ppbconf.h (38061)
1/*-
1/*-
2 * Copyright (c) 1997 Nicolas Souchu
2 * Copyright (c) 1997, 1998 Nicolas Souchu
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright

--- 7 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright

--- 7 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: ppbconf.h,v 1.5 1997/09/01 18:39:37 bde Exp $
26 * $Id: ppbconf.h,v 1.6 1998/06/07 19:44:21 phk Exp $
27 *
28 */
29#ifndef __PPBCONF_H
30#define __PPBCONF_H
31
32#include <sys/queue.h>
33
34/*
35 * Parallel Port Bus sleep/wakeup queue.
36 */
37#define PPBPRI PZERO+8
38
39/*
27 *
28 */
29#ifndef __PPBCONF_H
30#define __PPBCONF_H
31
32#include <sys/queue.h>
33
34/*
35 * Parallel Port Bus sleep/wakeup queue.
36 */
37#define PPBPRI PZERO+8
38
39/*
40 * Parallel Port Chipset modes.
40 * Parallel Port Chipset mode masks.
41 * NIBBLE mode is supposed to be available under each other modes.
41 */
42 */
42#define PPB_AUTODETECT 0x0 /* autodetect */
43#define PPB_NIBBLE 0x1 /* standard 4 bit mode */
43#define PPB_COMPATIBLE 0x0 /* Centronics compatible mode */
44
45#define PPB_NIBBLE 0x1 /* reverse 4 bit mode */
44#define PPB_PS2 0x2 /* PS/2 byte mode */
46#define PPB_PS2 0x2 /* PS/2 byte mode */
45#define PPB_EPP 0x3 /* EPP mode, 32 bit */
46#define PPB_ECP_EPP 0x4 /* ECP in EPP mode */
47#define PPB_ECP_PS2 0x5 /* ECP in PS/2 mode */
48#define PPB_ECP 0x6 /* ECP mode */
49#define PPB_UNKNOWN 0x7 /* the last one */
47#define PPB_EPP 0x4 /* EPP mode, 32 bit */
48#define PPB_ECP 0x8 /* ECP mode */
50
49
51#define PPB_IS_EPP(mode) (mode == PPB_EPP || mode == PPB_ECP_EPP)
50#define PPB_SPP PPB_NIBBLE|PPB_PS2
52
51
52#define PPB_IS_EPP(mode) (mode & PPB_EPP)
53#define PPB_IN_EPP_MODE(dev) (PPB_IS_EPP (ppb_get_mode (dev)))
54
53#define PPB_IN_EPP_MODE(dev) (PPB_IS_EPP (ppb_get_mode (dev)))
54
55#define n(flags) (~(flags) & (flags))
56
55/*
56 * Parallel Port Chipset control bits.
57 */
58#define STROBE 0x01
59#define AUTOFEED 0x02
60#define nINIT 0x04
61#define SELECTIN 0x08
62#define IRQENABLE 0x10
63#define PCD 0x20
64
57/*
58 * Parallel Port Chipset control bits.
59 */
60#define STROBE 0x01
61#define AUTOFEED 0x02
62#define nINIT 0x04
63#define SELECTIN 0x08
64#define IRQENABLE 0x10
65#define PCD 0x20
66
67#define nSTROBE n(STROBE)
68#define nAUTOFEED n(AUTOFEED)
69#define INIT n(nINIT)
70#define nSELECTIN n(SELECTIN)
71#define nPCD n(PCD)
72
65/*
66 * Parallel Port Chipset status bits.
67 */
68#define TIMEOUT 0x01
69#define nFAULT 0x08
70#define SELECT 0x10
71#define ERROR 0x20
72#define nACK 0x40

--- 9 unchanged lines hidden (view full) ---

82 unsigned int error:1;
83 unsigned int select:1;
84 unsigned int paper_end:1;
85 unsigned int ack:1;
86 unsigned int busy:1;
87};
88
89/*
73/*
74 * Parallel Port Chipset status bits.
75 */
76#define TIMEOUT 0x01
77#define nFAULT 0x08
78#define SELECT 0x10
79#define ERROR 0x20
80#define nACK 0x40

--- 9 unchanged lines hidden (view full) ---

90 unsigned int error:1;
91 unsigned int select:1;
92 unsigned int paper_end:1;
93 unsigned int ack:1;
94 unsigned int busy:1;
95};
96
97/*
90 * How tsleep () is called in ppb_request_bus ().
98 * How tsleep() is called in ppb_request_bus().
91 */
92#define PPB_DONTWAIT 0
93#define PPB_NOINTR 0
94#define PPB_WAIT 0x1
95#define PPB_INTR 0x2
96
99 */
100#define PPB_DONTWAIT 0
101#define PPB_NOINTR 0
102#define PPB_WAIT 0x1
103#define PPB_INTR 0x2
104
97struct ppb_data; /* see below */
105/*
106 * Microsequence stuff.
107 */
108#define PPB_MS_MAXLEN 64 /* XXX according to MS_INS_MASK */
109#define PPB_MS_MAXARGS 3 /* according to MS_ARG_MASK */
98
110
111/* maximum number of mode dependent
112 * submicrosequences for in/out operations
113 */
114#define PPB_MAX_XFER 6
115
116union ppb_insarg {
117 int i;
118 char c;
119 void *p;
120 int (* f)(void *, char *);
121};
122
123struct ppb_microseq {
124 int opcode; /* microins. opcode */
125 union ppb_insarg arg[PPB_MS_MAXARGS]; /* arguments */
126};
127
128/* microseqences used for GET/PUT operations */
129struct ppb_xfer {
130 struct ppb_microseq *loop; /* the loop microsequence */
131};
132
99/*
100 * Parallel Port Bus Device structure.
101 */
133/*
134 * Parallel Port Bus Device structure.
135 */
136struct ppb_data; /* see below */
137
138struct ppb_context {
139 int valid; /* 1 if the struct is valid */
140 int mode; /* XXX chipset operating mode */
141
142 struct microseq *curpc; /* pc in curmsq */
143 struct microseq *curmsq; /* currently executed microseqence */
144};
145
146
102struct ppb_device {
103
104 int id_unit; /* unit of the device */
147struct ppb_device {
148
149 int id_unit; /* unit of the device */
150 char *name; /* name of the device */
105
151
152 ushort mode; /* current mode of the device */
153 ushort avm; /* available modes of the device */
154
155 struct ppb_context ctx; /* context of the device */
156
157 /* mode dependent get msq. If NULL,
158 * IEEE1284 code is used */
159 struct ppb_xfer
160 get_xfer[PPB_MAX_XFER];
161
162 /* mode dependent put msq. If NULL,
163 * IEEE1284 code is used */
164 struct ppb_xfer
165 put_xfer[PPB_MAX_XFER];
166
106 void (*intr)(int); /* interrupt handler */
107
108 struct ppb_data *ppb; /* link to the ppbus */
109
110 LIST_ENTRY(ppb_device) chain; /* list of devices on the bus */
111};
112
113/*
114 * Parallel Port Bus Adapter structure.
115 */
116struct ppb_adapter {
117
118 void (*intr_handler)(int);
119 void (*reset_epp_timeout)(int);
120 void (*ecp_sync)(int);
121
167 void (*intr)(int); /* interrupt handler */
168
169 struct ppb_data *ppb; /* link to the ppbus */
170
171 LIST_ENTRY(ppb_device) chain; /* list of devices on the bus */
172};
173
174/*
175 * Parallel Port Bus Adapter structure.
176 */
177struct ppb_adapter {
178
179 void (*intr_handler)(int);
180 void (*reset_epp_timeout)(int);
181 void (*ecp_sync)(int);
182
183 int (*exec_microseq)(int, struct ppb_microseq *, int *);
184
185 int (*setmode)(int, int);
186
122 void (*outsb_epp)(int, char *, int);
123 void (*outsw_epp)(int, char *, int);
124 void (*outsl_epp)(int, char *, int);
125 void (*insb_epp)(int, char *, int);
126 void (*insw_epp)(int, char *, int);
127 void (*insl_epp)(int, char *, int);
128
129 char (*r_dtr)(int);

--- 12 unchanged lines hidden (view full) ---

142};
143
144/*
145 * ppb_link structure.
146 */
147struct ppb_link {
148
149 int adapter_unit; /* unit of the adapter */
187 void (*outsb_epp)(int, char *, int);
188 void (*outsw_epp)(int, char *, int);
189 void (*outsl_epp)(int, char *, int);
190 void (*insb_epp)(int, char *, int);
191 void (*insw_epp)(int, char *, int);
192 void (*insl_epp)(int, char *, int);
193
194 char (*r_dtr)(int);

--- 12 unchanged lines hidden (view full) ---

207};
208
209/*
210 * ppb_link structure.
211 */
212struct ppb_link {
213
214 int adapter_unit; /* unit of the adapter */
150
151 int base; /* base address of the port */
152 int id_irq; /* != 0 if irq enabled */
215 int base; /* base address of the port */
216 int id_irq; /* != 0 if irq enabled */
153 int mode; /* NIBBLE, PS2, EPP, ECP */
154
155#define EPP_1_9 0x0 /* default */
156#define EPP_1_7 0x1
157
158 int epp_protocol; /* EPP protocol: 0=1.9, 1=1.7 */
159
160 struct ppb_adapter *adapter; /* link to the ppc adapter */
161 struct ppb_data *ppbus; /* link to the ppbus */
162};
163
164/*
165 * Maximum size of the PnP info string
166 */
217
218#define EPP_1_9 0x0 /* default */
219#define EPP_1_7 0x1
220
221 int epp_protocol; /* EPP protocol: 0=1.9, 1=1.7 */
222
223 struct ppb_adapter *adapter; /* link to the ppc adapter */
224 struct ppb_data *ppbus; /* link to the ppbus */
225};
226
227/*
228 * Maximum size of the PnP info string
229 */
167#define PPB_PnP_STRING_SIZE 160 /* XXX */
230#define PPB_PnP_STRING_SIZE 128 /* XXX */
168
169/*
170 * Parallel Port Bus structure.
171 */
172struct ppb_data {
173
174#define PPB_PnP_PRINTER 0
175#define PPB_PnP_MODEM 1
176#define PPB_PnP_NET 2
177#define PPB_PnP_HDC 3
178#define PPB_PnP_PCMCIA 4
179#define PPB_PnP_MEDIA 5
180#define PPB_PnP_FDC 6
181#define PPB_PnP_PORTS 7
182#define PPB_PnP_SCANNER 8
183#define PPB_PnP_DIGICAM 9
184#define PPB_PnP_UNKNOWN 10
185 int class_id; /* not a PnP device if class_id < 0 */
186
231
232/*
233 * Parallel Port Bus structure.
234 */
235struct ppb_data {
236
237#define PPB_PnP_PRINTER 0
238#define PPB_PnP_MODEM 1
239#define PPB_PnP_NET 2
240#define PPB_PnP_HDC 3
241#define PPB_PnP_PCMCIA 4
242#define PPB_PnP_MEDIA 5
243#define PPB_PnP_FDC 6
244#define PPB_PnP_PORTS 7
245#define PPB_PnP_SCANNER 8
246#define PPB_PnP_DIGICAM 9
247#define PPB_PnP_UNKNOWN 10
248 int class_id; /* not a PnP device if class_id < 0 */
249
250 ushort mode; /* IEEE 1284-1994 mode
251 * NIBBLE, PS2, EPP or ECP */
252 ushort avm; /* IEEE 1284-1994 available
253 * modes */
254
187 struct ppb_link *ppb_link; /* link to the adapter */
188 struct ppb_device *ppb_owner; /* device which owns the bus */
189 LIST_HEAD(, ppb_device) ppb_devs; /* list of devices on the bus */
190 LIST_ENTRY(ppb_data) ppb_chain; /* list of busses */
191};
192
193/*
194 * Parallel Port Bus driver structure.

--- 5 unchanged lines hidden (view full) ---

200 char *name;
201};
202
203extern struct linker_set ppbdriver_set;
204
205extern struct ppb_data *ppb_alloc_bus(void);
206extern struct ppb_data *ppb_next_bus(struct ppb_data *);
207extern struct ppb_data *ppb_lookup_bus(int);
255 struct ppb_link *ppb_link; /* link to the adapter */
256 struct ppb_device *ppb_owner; /* device which owns the bus */
257 LIST_HEAD(, ppb_device) ppb_devs; /* list of devices on the bus */
258 LIST_ENTRY(ppb_data) ppb_chain; /* list of busses */
259};
260
261/*
262 * Parallel Port Bus driver structure.

--- 5 unchanged lines hidden (view full) ---

268 char *name;
269};
270
271extern struct linker_set ppbdriver_set;
272
273extern struct ppb_data *ppb_alloc_bus(void);
274extern struct ppb_data *ppb_next_bus(struct ppb_data *);
275extern struct ppb_data *ppb_lookup_bus(int);
276extern struct ppb_data *ppb_lookup_link(int);
208
209extern int ppb_attach_device(struct ppb_device *);
210extern void ppb_remove_device(struct ppb_device *);
211extern int ppb_attachdevs(struct ppb_data *);
212
213extern int ppb_request_bus(struct ppb_device *, int);
214extern int ppb_release_bus(struct ppb_device *);
215
216extern void ppb_intr(struct ppb_link *);
217
218extern int ppb_poll_device(struct ppb_device *, int, char, char, int);
219
220extern int ppb_reset_epp_timeout(struct ppb_device *);
221extern int ppb_ecp_sync(struct ppb_device *);
222extern int ppb_get_status(struct ppb_device *, struct ppb_status *);
277
278extern int ppb_attach_device(struct ppb_device *);
279extern void ppb_remove_device(struct ppb_device *);
280extern int ppb_attachdevs(struct ppb_data *);
281
282extern int ppb_request_bus(struct ppb_device *, int);
283extern int ppb_release_bus(struct ppb_device *);
284
285extern void ppb_intr(struct ppb_link *);
286
287extern int ppb_poll_device(struct ppb_device *, int, char, char, int);
288
289extern int ppb_reset_epp_timeout(struct ppb_device *);
290extern int ppb_ecp_sync(struct ppb_device *);
291extern int ppb_get_status(struct ppb_device *, struct ppb_status *);
223extern int ppb_get_mode(struct ppb_device *);
224extern int ppb_get_epp_protocol(struct ppb_device *);
225extern int ppb_get_irq(struct ppb_device *);
226
292
293extern int ppb_set_mode(struct ppb_device *, int);
294
227/*
228 * These are defined as macros for speedup.
229 */
295/*
296 * These are defined as macros for speedup.
297 */
230#define ppb_outsb_epp(dev,buf,cnt) \
231 (*(dev)->ppb->ppb_link->adapter->outsb_epp) \
298#define ppb_get_base_addr(dev) ((dev)->ppb->ppb_link->base)
299#define ppb_get_epp_protocol(dev) ((dev)->ppb->ppb_link->epp_protocol)
300#define ppb_get_irq(dev) ((dev)->ppb->ppb_link->id_irq)
301
302#define ppb_get_mode(dev) ((dev)->mode)
303
304#define ppb_outsb_epp(dev,buf,cnt) \
305 (*(dev)->ppb->ppb_link->adapter->outsb_epp) \
232 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
306 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
233#define ppb_outsw_epp(dev,buf,cnt) \
234 (*(dev)->ppb->ppb_link->adapter->outsw_epp) \
307#define ppb_outsw_epp(dev,buf,cnt) \
308 (*(dev)->ppb->ppb_link->adapter->outsw_epp) \
235 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
309 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
236#define ppb_outsl_epp(dev,buf,cnt) \
237 (*(dev)->ppb->ppb_link->adapter->outsl_epp) \
310#define ppb_outsl_epp(dev,buf,cnt) \
311 (*(dev)->ppb->ppb_link->adapter->outsl_epp) \
238 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
312 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
239#define ppb_insb_epp(dev,buf,cnt) \
240 (*(dev)->ppb->ppb_link->adapter->insb_epp) \
313#define ppb_insb_epp(dev,buf,cnt) \
314 (*(dev)->ppb->ppb_link->adapter->insb_epp) \
241 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
315 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
242#define ppb_insw_epp(dev,buf,cnt) \
243 (*(dev)->ppb->ppb_link->adapter->insw_epp) \
316#define ppb_insw_epp(dev,buf,cnt) \
317 (*(dev)->ppb->ppb_link->adapter->insw_epp) \
244 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
318 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
245#define ppb_insl_epp(dev,buf,cnt) \
246 (*(dev)->ppb->ppb_link->adapter->insl_epp) \
319#define ppb_insl_epp(dev,buf,cnt) \
320 (*(dev)->ppb->ppb_link->adapter->insl_epp) \
247 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
248
321 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
322
249#define ppb_rdtr(dev) (*(dev)->ppb->ppb_link->adapter->r_dtr) \
323#define ppb_repp(dev) (*(dev)->ppb->ppb_link->adapter->r_epp) \
250 ((dev)->ppb->ppb_link->adapter_unit)
324 ((dev)->ppb->ppb_link->adapter_unit)
251#define ppb_rstr(dev) (*(dev)->ppb->ppb_link->adapter->r_str) \
325#define ppb_recr(dev) (*(dev)->ppb->ppb_link->adapter->r_ecr) \
252 ((dev)->ppb->ppb_link->adapter_unit)
326 ((dev)->ppb->ppb_link->adapter_unit)
253#define ppb_rctr(dev) (*(dev)->ppb->ppb_link->adapter->r_ctr) \
327#define ppb_rfifo(dev) (*(dev)->ppb->ppb_link->adapter->r_fifo) \
254 ((dev)->ppb->ppb_link->adapter_unit)
328 ((dev)->ppb->ppb_link->adapter_unit)
255#define ppb_repp(dev) (*(dev)->ppb->ppb_link->adapter->r_epp) \
329#define ppb_wepp(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_epp) \
330 ((dev)->ppb->ppb_link->adapter_unit, byte)
331#define ppb_wecr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_ecr) \
332 ((dev)->ppb->ppb_link->adapter_unit, byte)
333#define ppb_wfifo(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_fifo) \
334 ((dev)->ppb->ppb_link->adapter_unit, byte)
335
336#define ppb_rdtr(dev) (*(dev)->ppb->ppb_link->adapter->r_dtr) \
256 ((dev)->ppb->ppb_link->adapter_unit)
337 ((dev)->ppb->ppb_link->adapter_unit)
257#define ppb_recr(dev) (*(dev)->ppb->ppb_link->adapter->r_ecr) \
338#define ppb_rstr(dev) (*(dev)->ppb->ppb_link->adapter->r_str) \
258 ((dev)->ppb->ppb_link->adapter_unit)
339 ((dev)->ppb->ppb_link->adapter_unit)
259#define ppb_rfifo(dev) (*(dev)->ppb->ppb_link->adapter->r_fifo) \
340#define ppb_rctr(dev) (*(dev)->ppb->ppb_link->adapter->r_ctr) \
260 ((dev)->ppb->ppb_link->adapter_unit)
341 ((dev)->ppb->ppb_link->adapter_unit)
261
262#define ppb_wdtr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_dtr) \
342#define ppb_wdtr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_dtr) \
263 ((dev)->ppb->ppb_link->adapter_unit, byte)
343 ((dev)->ppb->ppb_link->adapter_unit, byte)
264#define ppb_wstr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_str) \
344#define ppb_wstr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_str) \
265 ((dev)->ppb->ppb_link->adapter_unit, byte)
345 ((dev)->ppb->ppb_link->adapter_unit, byte)
266#define ppb_wctr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_ctr) \
346#define ppb_wctr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_ctr) \
267 ((dev)->ppb->ppb_link->adapter_unit, byte)
347 ((dev)->ppb->ppb_link->adapter_unit, byte)
268#define ppb_wepp(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_epp) \
269 ((dev)->ppb->ppb_link->adapter_unit, byte)
270#define ppb_wecr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_ecr) \
271 ((dev)->ppb->ppb_link->adapter_unit, byte)
272#define ppb_wfifo(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_fifo) \
273 ((dev)->ppb->ppb_link->adapter_unit, byte)
274
275#endif
348
349#endif