1 /* $OpenBSD: pccomvar.h,v 1.19 2006/12/28 20:50:21 miod Exp $ */
2 /* $NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $ */
3
4 /*
5 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Christopher G. Demetriou
18 * for the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /* XXX - should be shared among com.c and pccom.c */
35 struct commulti_attach_args {
36 int ca_slave; /* slave number */
37
38 bus_space_tag_t ca_iot;
39 bus_space_handle_t ca_ioh;
40 int ca_iobase;
41 int ca_noien;
42 };
43
44 struct com_softc {
45 struct device sc_dev;
46 void *sc_ih;
47 bus_space_tag_t sc_iot;
48 struct tty *sc_tty;
49 struct timeout sc_dtr_tmo;
50 struct timeout sc_diag_tmo;
51
52 int sc_overflows;
53 int sc_floods;
54 int sc_errors;
55
56 int sc_halt;
57
58 int sc_iobase;
59 int sc_frequency;
60
61 bus_space_handle_t sc_ioh;
62 bus_space_handle_t sc_hayespioh;
63
64 u_char sc_uarttype;
65 #define COM_UART_UNKNOWN 0x00 /* unknown */
66 #define COM_UART_8250 0x01 /* no fifo */
67 #define COM_UART_16450 0x02 /* no fifo */
68 #define COM_UART_16550 0x03 /* no working fifo */
69 #define COM_UART_16550A 0x04 /* 16 byte fifo */
70 #define COM_UART_ST16650 0x05 /* no working fifo */
71 #define COM_UART_ST16650V2 0x06 /* 32 byte fifo */
72 #define COM_UART_TI16750 0x07 /* 64 byte fifo */
73 #define COM_UART_ST16C654 0x08 /* 64 bytes fifo */
74 #define COM_UART_XR16850 0x10 /* 128 byte fifo */
75 #define COM_UART_OX16C950 0x12 /* 128 byte fifo */
76 u_char sc_uartrev;
77
78 u_char sc_hwflags;
79 #define COM_HW_NOIEN 0x01
80 #define COM_HW_FIFO 0x02
81 #define COM_HW_CONSOLE 0x40
82 #define COM_HW_KGDB 0x80
83 u_char sc_swflags;
84 #define COM_SW_SOFTCAR 0x01
85 #define COM_SW_CLOCAL 0x02
86 #define COM_SW_CRTSCTS 0x04
87 #define COM_SW_MDMBUF 0x08
88 int sc_fifolen;
89 u_char sc_msr, sc_mcr, sc_lcr, sc_ier;
90 u_char sc_dtr;
91
92 u_char sc_cua;
93
94 u_char sc_initialize; /* force initialization */
95
96 #define RBUFSIZE 512
97 #define RBUFMASK 511
98 u_int sc_rxget;
99 volatile u_int sc_rxput;
100 u_char sc_rxbuf[RBUFSIZE];
101 u_char *sc_tba;
102 int sc_tbc;
103
104 /* power management hooks */
105 int (*enable)(struct com_softc *);
106 void (*disable)(struct com_softc *);
107 int enabled;
108 };
109
110 int comprobe1(bus_space_tag_t, bus_space_handle_t);
111 void cominit(bus_space_tag_t, bus_space_handle_t, int);
112 int comstop(struct tty *, int);
113 int comintr(void *);
114 int com_detach(struct device *, int);
115 int com_activate(struct device *, enum devact);
116
117 void comdiag(void *);
118 int comspeed(long, long);
119 int comparam(struct tty *, struct termios *);
120 void comstart(struct tty *);
121 void comsoft(void);
122 int comhwiflow(struct tty *, int);
123 void com_raisedtr(void *);
124
125 struct consdev;
126 void comcnprobe(struct consdev *);
127 void comcninit(struct consdev *);
128 int comcngetc(dev_t);
129 void comcnputc(dev_t, int);
130 void comcnpollc(dev_t, int);
131 int com_common_getc(bus_space_tag_t, bus_space_handle_t);
132 void com_common_putc(bus_space_tag_t, bus_space_handle_t, int);
133
134 #if defined(DDB) || defined(KGDB)
135 void com_enable_debugport(struct com_softc *);
136 #endif /* DDB || KGDB */
137
138 #ifdef KGDB
139 extern bus_space_tag_t com_kgdb_iot;
140 extern bus_addr_t com_kgdb_addr;
141
142 int com_kgdb_attach(bus_space_tag_t, bus_addr_t, int, int, tcflag_t);
143 int kgdbintr(void *);
144 #endif /* KGDB */
145
146 void com_attach_subr(struct com_softc *);
147
148 extern bus_addr_t comconsaddr;
149 extern int comconsinit;
150 extern int comconsattached;
151 extern bus_space_tag_t comconsiot;
152 extern bus_space_handle_t comconsioh;
153 extern tcflag_t comconscflag;