Change the kernel dev_t, representing a pointer to a specinfo structure,
[dragonfly.git] / sys / dev / serial / digi / digi.h
CommitLineData
561af43f
JS
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: src/sys/dev/digi/digi.h,v 1.14 2003/08/07 15:04:24 jhb Exp $
b13267a5 30 * $DragonFly: src/sys/dev/serial/digi/digi.h,v 1.2 2006/09/10 01:26:36 dillon Exp $
561af43f
JS
31 */
32
33#define W(p) (*(u_int16_t *)(p))
34#define vW(p) (*(u_int16_t volatile *)(p))
35#define D(p) (*(u_int32_t *)(p))
36#define vD(p) (*(u_int32_t volatile *)(p))
37
38#define CE_OVERRUN 0
39#define CE_INTERRUPT_BUF_OVERFLOW 1
40#define CE_TTY_BUF_OVERFLOW 2
41#define CE_NTYPES 3
42#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
43
44/*#define DIGI_INTERRUPT*/
45
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 struct callout wakeupco;
64
65 int status;
66#define ENABLED 1
67#define DIGI_DTR_OFF 2
68#define PAUSE_TX 8
69#define PAUSE_RX 16
70
71 int opencnt;
72 u_short txbufsize;
73 u_short rxbufsize;
74 volatile struct board_chan *bc;
75 struct tty *tp;
76
b13267a5 77 cdev_t dev[6];
561af43f
JS
78
79 u_char *txbuf;
80 u_char *rxbuf;
81 u_char txwin;
82 u_char rxwin;
83
84 u_char pnum; /* port number */
85
86 u_char modemfake; /* Modem values to be forced */
87 u_char mstat;
88 u_char modem; /* Force values */
89
90 int active_out; /* nonzero if the callout device is open */
91 int dtr_wait; /* time to hold DTR down on close (* 1/hz) */
92 u_int wopeners; /* # processes waiting for DCD in open() */
93
94 /*
95 * The high level of the driver never reads status registers directly
96 * because there would be too many side effects to handle conveniently.
97 * Instead, it reads copies of the registers stored here by the
98 * interrupt handler.
99 */
100 u_char last_modem_status; /* last MSR read by intr handler */
101 u_char prev_modem_status; /* last MSR handled by high level */
102
103
104 /* Initial state. */
105 struct termios it_in; /* should be in struct tty */
106 struct termios it_out;
107
108 /* Lock state. */
109 struct termios lt_in; /* should be in struct tty */
110 struct termios lt_out;
111
112 u_int do_timestamp;
113 u_int do_dcd_timestamp;
114 struct timeval dcd_timestamp;
115
116 u_long bytes_in, bytes_out;
117 u_int delta_error_counts[CE_NTYPES];
118 u_long error_counts;
119
120 tcflag_t c_iflag; /* hold true IXON/IXOFF/IXANY */
121 int lcc, lostcc, lbuf;
122 u_char send_ring;
123
124 unsigned laltpin : 1; /* Alternate pin settings locked */
125 unsigned ialtpin : 1; /* Initial alternate pin settings */
126
127 int cd; /* Depends on the altpin setting */
128 int dsr;
129};
130
131/*
132 * Map TIOCM_* values to digiboard values
133 */
134struct digi_control_signals {
135 int rts;
136 int cd;
137 int dsr;
138 int cts;
139 int ri;
140 int dtr;
141};
142
143enum digi_board_status {
144 DIGI_STATUS_NOTINIT,
145 DIGI_STATUS_ENABLED,
146 DIGI_STATUS_DISABLED
147};
148
149/* Digiboard per-board structure */
150struct digi_softc {
151 /* struct board_info */
152 device_t dev;
153
154 const char *name;
155 enum digi_board_status status;
156 u_short numports; /* number of ports on card */
157 u_int port; /* I/O port */
158 u_int wport; /* window select I/O port */
159
160 struct {
161 struct resource *mem;
162 int mrid;
163 struct resource *irq;
164 int irqrid;
165 struct resource *io;
166 int iorid;
167 void *irqHandler;
168 int unit;
b13267a5 169 cdev_t ctldev;
561af43f
JS
170 } res;
171
172 u_char *vmem; /* virtual memory address */
173 u_char *memcmd;
174 volatile u_char *memevent;
175 long pmem; /* physical memory address */
176
177 struct {
178 u_char *data;
179 size_t size;
180 } bios, fep, link;
181
182#ifdef DIGI_INTERRUPT
183 struct timeval intr_timestamp;
184#endif
185
186 struct digi_p *ports; /* pointer to array of port descriptors */
187 struct tty *ttys; /* pointer to array of TTY structures */
188 volatile struct global_data *gdata;
189 u_char window; /* saved window */
190 int win_size;
191 int win_bits;
192 int mem_size;
193 int mem_seg;
194 enum digi_model model;
195 const struct digi_control_signals *csigs;
196 int opencnt;
197 unsigned pcibus : 1; /* On a PCI bus ? */
198
199 struct callout callout; /* poll timeout handle */
200 struct callout inttest; /* int test timeout handle */
201 const char *module;
202
203 u_char *(*setwin)(struct digi_softc *_sc, unsigned _addr);
204 void (*hidewin)(struct digi_softc *_sc);
205 void (*towin)(struct digi_softc *_sc, int _win);
206#ifdef DEBUG
207 int intr_count;
208#endif
209};
210
211extern devclass_t digi_devclass;
212
213extern const struct digi_control_signals digi_xixe_signals;
214extern const struct digi_control_signals digi_normal_signals;
215
216const char *digi_errortxt(int _id);
217int digi_attach(struct digi_softc *);
218int digi_detach(device_t _dev);
219int digi_shutdown(device_t _dev);
220void digi_delay(struct digi_softc *_sc, const char *_txt,
221 u_long _timo);