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
|
40#ifdef SMP 41#define DIGI_LOCK_INTR 42#endif 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 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 |
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);
|