Deleted Added
full compact
digi.h (76196) digi.h (76327)
1/*-
2 * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
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
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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 *
1/*-
2 * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
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
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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 * $FreeBSD: head/sys/dev/digi/digi.h 76196 2001-05-02 01:47:34Z brian $
26 * $FreeBSD: head/sys/dev/digi/digi.h 76327 2001-05-07 11:13:11Z brian $
27 */
28
29#define W(p) (*(u_int16_t *)(p))
30#define vW(p) (*(u_int16_t volatile *)(p))
31#define D(p) (*(u_int32_t *)(p))
32#define vD(p) (*(u_int32_t volatile *)(p))
33
34#define CE_OVERRUN 0
35#define CE_INTERRUPT_BUF_OVERFLOW 1
36#define CE_TTY_BUF_OVERFLOW 2
37#define CE_NTYPES 3
38#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
39
27 */
28
29#define W(p) (*(u_int16_t *)(p))
30#define vW(p) (*(u_int16_t volatile *)(p))
31#define D(p) (*(u_int32_t *)(p))
32#define vD(p) (*(u_int32_t volatile *)(p))
33
34#define CE_OVERRUN 0
35#define CE_INTERRUPT_BUF_OVERFLOW 1
36#define CE_TTY_BUF_OVERFLOW 2
37#define CE_NTYPES 3
38#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
39
40#ifdef SMP
41#define DIGI_LOCK_INTR
42#endif
43
44/*#define DIGI_INTERRUPT*/
45
40#ifndef DEBUG
41#define DEBUG
42#endif
43
44#ifdef DEBUG
45extern unsigned digi_debug;
46#define DLOG(level, args) if (digi_debug & (level)) device_printf args
47#else
48#define DLOG(level, args)
49#endif
50
51
52struct digi_softc;
53
54/* digiboard port structure */
55struct digi_p {
56 struct digi_softc *sc;
57
58 int status;
59#define ENABLED 1
60#define DIGI_DTR_OFF 2
61#define PAUSE_TX 8
62#define PAUSE_RX 16
63
64 int opencnt;
65 ushort txbufsize;
66 ushort rxbufsize;
67 volatile struct board_chan *bc;
68 struct tty *tp;
69
70 dev_t dev[6];
71
72 u_char *txbuf;
73 u_char *rxbuf;
74 u_char txwin;
75 u_char rxwin;
76
77 u_char pnum; /* port number */
78
79 u_char modemfake; /* Modem values to be forced */
80 u_char mstat;
81 u_char modem; /* Force values */
82
83 int active_out; /* nonzero if the callout device is open */
84 int dtr_wait; /* time to hold DTR down on close (* 1/hz) */
85 u_int wopeners; /* # processes waiting for DCD in open() */
86
87 /*
88 * The high level of the driver never reads status registers directly
89 * because there would be too many side effects to handle conveniently.
90 * Instead, it reads copies of the registers stored here by the
91 * interrupt handler.
92 */
93 u_char last_modem_status; /* last MSR read by intr handler */
94 u_char prev_modem_status; /* last MSR handled by high level */
95
96
97 /* Initial state. */
98 struct termios it_in; /* should be in struct tty */
99 struct termios it_out;
100
101 /* Lock state. */
102 struct termios lt_in; /* should be in struct tty */
103 struct termios lt_out;
104
105 u_int do_timestamp;
106 u_int do_dcd_timestamp;
107 struct timeval dcd_timestamp;
108
109 u_long bytes_in, bytes_out;
110 u_int delta_error_counts[CE_NTYPES];
111 u_long error_counts;
112
113 tcflag_t c_iflag; /* hold true IXON/IXOFF/IXANY */
114 int lcc, lostcc, lbuf;
115 u_char send_ring;
116};
117
118/*
119 * Map TIOCM_* values to digiboard values
120 */
121struct digi_control_signals {
122 int rts;
123 int cd;
124 int dsr;
125 int cts;
126 int ri;
127 int dtr;
128};
129
130enum digi_board_status {
131 DIGI_STATUS_NOTINIT,
132 DIGI_STATUS_ENABLED,
133 DIGI_STATUS_DISABLED
134};
135
136/* Digiboard per-board structure */
137struct digi_softc {
138 /* struct board_info */
139 device_t dev;
140
141 const char *name;
142 enum digi_board_status status;
143 ushort numports; /* number of ports on card */
144 ushort port; /* I/O port */
145 ushort wport; /* window select I/O port */
146
147 struct {
148 struct resource *mem;
149 int mrid;
150 struct resource *irq;
151 int irqrid;
152 struct resource *io;
153 int iorid;
154 void *irqHandler;
155 int unit;
156 dev_t ctldev;
157 } res;
158
159 u_char *vmem; /* virtual memory address */
160 u_char *memcmd;
161 volatile u_char *memevent;
162 long pmem; /* physical memory address */
163
164 struct {
165 u_char *data;
166 size_t size;
167 } bios, fep, link;
168
169#ifdef DIGI_INTERRUPT
170 struct timeval intr_timestamp;
171#endif
172
173 struct digi_p *ports; /* pointer to array of port descriptors */
174 struct tty *ttys; /* pointer to array of TTY structures */
175 volatile struct global_data *gdata;
176 u_char window; /* saved window */
177 int win_size;
178 int win_bits;
179 int mem_size;
180 int mem_seg;
181 digiModel_t model;
182 const struct digi_control_signals *csigs;
183 int opencnt;
184 unsigned pcibus : 1; /* On a PCI bus ? */
185
186 struct callout_handle callout; /* poll timeout handle */
187 struct callout_handle inttest; /* int test timeout handle */
188 const char *module;
189
190 u_char *(*setwin)(struct digi_softc *_sc, unsigned _addr);
191 void (*hidewin)(struct digi_softc *_sc);
192 void (*towin)(struct digi_softc *_sc, int _win);
46#ifndef DEBUG
47#define DEBUG
48#endif
49
50#ifdef DEBUG
51extern unsigned digi_debug;
52#define DLOG(level, args) if (digi_debug & (level)) device_printf args
53#else
54#define DLOG(level, args)
55#endif
56
57
58struct digi_softc;
59
60/* digiboard port structure */
61struct digi_p {
62 struct digi_softc *sc;
63
64 int status;
65#define ENABLED 1
66#define DIGI_DTR_OFF 2
67#define PAUSE_TX 8
68#define PAUSE_RX 16
69
70 int opencnt;
71 ushort txbufsize;
72 ushort rxbufsize;
73 volatile struct board_chan *bc;
74 struct tty *tp;
75
76 dev_t dev[6];
77
78 u_char *txbuf;
79 u_char *rxbuf;
80 u_char txwin;
81 u_char rxwin;
82
83 u_char pnum; /* port number */
84
85 u_char modemfake; /* Modem values to be forced */
86 u_char mstat;
87 u_char modem; /* Force values */
88
89 int active_out; /* nonzero if the callout device is open */
90 int dtr_wait; /* time to hold DTR down on close (* 1/hz) */
91 u_int wopeners; /* # processes waiting for DCD in open() */
92
93 /*
94 * The high level of the driver never reads status registers directly
95 * because there would be too many side effects to handle conveniently.
96 * Instead, it reads copies of the registers stored here by the
97 * interrupt handler.
98 */
99 u_char last_modem_status; /* last MSR read by intr handler */
100 u_char prev_modem_status; /* last MSR handled by high level */
101
102
103 /* Initial state. */
104 struct termios it_in; /* should be in struct tty */
105 struct termios it_out;
106
107 /* Lock state. */
108 struct termios lt_in; /* should be in struct tty */
109 struct termios lt_out;
110
111 u_int do_timestamp;
112 u_int do_dcd_timestamp;
113 struct timeval dcd_timestamp;
114
115 u_long bytes_in, bytes_out;
116 u_int delta_error_counts[CE_NTYPES];
117 u_long error_counts;
118
119 tcflag_t c_iflag; /* hold true IXON/IXOFF/IXANY */
120 int lcc, lostcc, lbuf;
121 u_char send_ring;
122};
123
124/*
125 * Map TIOCM_* values to digiboard values
126 */
127struct digi_control_signals {
128 int rts;
129 int cd;
130 int dsr;
131 int cts;
132 int ri;
133 int dtr;
134};
135
136enum digi_board_status {
137 DIGI_STATUS_NOTINIT,
138 DIGI_STATUS_ENABLED,
139 DIGI_STATUS_DISABLED
140};
141
142/* Digiboard per-board structure */
143struct digi_softc {
144 /* struct board_info */
145 device_t dev;
146
147 const char *name;
148 enum digi_board_status status;
149 ushort numports; /* number of ports on card */
150 ushort port; /* I/O port */
151 ushort wport; /* window select I/O port */
152
153 struct {
154 struct resource *mem;
155 int mrid;
156 struct resource *irq;
157 int irqrid;
158 struct resource *io;
159 int iorid;
160 void *irqHandler;
161 int unit;
162 dev_t ctldev;
163 } res;
164
165 u_char *vmem; /* virtual memory address */
166 u_char *memcmd;
167 volatile u_char *memevent;
168 long pmem; /* physical memory address */
169
170 struct {
171 u_char *data;
172 size_t size;
173 } bios, fep, link;
174
175#ifdef DIGI_INTERRUPT
176 struct timeval intr_timestamp;
177#endif
178
179 struct digi_p *ports; /* pointer to array of port descriptors */
180 struct tty *ttys; /* pointer to array of TTY structures */
181 volatile struct global_data *gdata;
182 u_char window; /* saved window */
183 int win_size;
184 int win_bits;
185 int mem_size;
186 int mem_seg;
187 digiModel_t model;
188 const struct digi_control_signals *csigs;
189 int opencnt;
190 unsigned pcibus : 1; /* On a PCI bus ? */
191
192 struct callout_handle callout; /* poll timeout handle */
193 struct callout_handle inttest; /* int test timeout handle */
194 const char *module;
195
196 u_char *(*setwin)(struct digi_softc *_sc, unsigned _addr);
197 void (*hidewin)(struct digi_softc *_sc);
198 void (*towin)(struct digi_softc *_sc, int _win);
199#ifdef DIGI_LOCK_INTR
200 struct mtx intr_mutex[1];
201#endif
193#ifdef DEBUG
194 int intr_count;
195#endif
196};
197
198extern devclass_t digi_devclass;
199extern const struct digi_control_signals digi_xixe_signals;
200extern const struct digi_control_signals digi_normal_signals;
201
202const char *digi_errortxt(int _id);
203int digi_modhandler(module_t _mod, int _event, void *_arg);
204int digi_attach(struct digi_softc *);
205int digi_detach(device_t _dev);
206int digi_shutdown(device_t _dev);
202#ifdef DEBUG
203 int intr_count;
204#endif
205};
206
207extern devclass_t digi_devclass;
208extern const struct digi_control_signals digi_xixe_signals;
209extern const struct digi_control_signals digi_normal_signals;
210
211const char *digi_errortxt(int _id);
212int digi_modhandler(module_t _mod, int _event, void *_arg);
213int digi_attach(struct digi_softc *);
214int digi_detach(device_t _dev);
215int digi_shutdown(device_t _dev);