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