1 /* $OpenBSD: comvar.h,v 1.24 2001/03/15 21:09:17 art Exp $ */ 2 /* $NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $ */ 3 4 /* 5 * Copyright (c) 1997 - 1998, Jason Downs. 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 Jason Downs for the 18 * OpenBSD system. 19 * 4. Neither the name(s) of the author(s) nor the name OpenBSD 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS 24 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 */ 35 /* 36 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 37 * 38 * Redistribution and use in source and binary forms, with or without 39 * modification, are permitted provided that the following conditions 40 * are met: 41 * 1. Redistributions of source code must retain the above copyright 42 * notice, this list of conditions and the following disclaimer. 43 * 2. Redistributions in binary form must reproduce the above copyright 44 * notice, this list of conditions and the following disclaimer in the 45 * documentation and/or other materials provided with the distribution. 46 * 3. All advertising materials mentioning features or use of this software 47 * must display the following acknowledgement: 48 * This product includes software developed by Christopher G. Demetriou 49 * for the NetBSD Project. 50 * 4. The name of the author may not be used to endorse or promote products 51 * derived from this software without specific prior written permission 52 * 53 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 54 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 55 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 56 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 57 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 58 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 62 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 63 */ 64 65 #include <sys/timeout.h> 66 67 struct commulti_attach_args { 68 int ca_slave; /* slave number */ 69 70 bus_space_tag_t ca_iot; 71 bus_space_handle_t ca_ioh; 72 int ca_iobase; 73 int ca_noien; 74 }; 75 76 #define COM_IBUFSIZE (2 * 512) 77 #define COM_IHIGHWATER ((3 * COM_IBUFSIZE) / 4) 78 79 struct com_softc { 80 struct device sc_dev; 81 void *sc_ih; 82 bus_space_tag_t sc_iot; 83 struct tty *sc_tty; 84 struct timeout sc_dtr_tmo; 85 struct timeout sc_diag_tmo; 86 87 int sc_overflows; 88 int sc_floods; 89 int sc_errors; 90 91 int sc_halt; 92 93 int sc_iobase; 94 int sc_frequency; 95 #ifdef COM_HAYESP 96 int sc_hayespbase; 97 #endif 98 99 bus_space_handle_t sc_ioh; 100 bus_space_handle_t sc_hayespioh; 101 102 u_char sc_uarttype; 103 #define COM_UART_UNKNOWN 0x00 /* unknown */ 104 #define COM_UART_8250 0x01 /* no fifo */ 105 #define COM_UART_16450 0x02 /* no fifo */ 106 #define COM_UART_16550 0x03 /* no working fifo */ 107 #define COM_UART_16550A 0x04 /* 16 byte fifo */ 108 #define COM_UART_ST16650 0x05 /* no working fifo */ 109 #define COM_UART_ST16650V2 0x06 /* 32 byte fifo */ 110 #define COM_UART_TI16750 0x07 /* 64 byte fifo */ 111 #define COM_UART_XR16850 0x10 /* 128 byte fifo */ 112 113 u_char sc_hwflags; 114 #define COM_HW_NOIEN 0x01 115 #define COM_HW_FIFO 0x02 116 #define COM_HW_HAYESP 0x04 117 #define COM_HW_CONSOLE 0x40 118 #define COM_HW_KGDB 0x80 119 u_char sc_swflags; 120 #define COM_SW_SOFTCAR 0x01 121 #define COM_SW_CLOCAL 0x02 122 #define COM_SW_CRTSCTS 0x04 123 #define COM_SW_MDMBUF 0x08 124 #define COM_SW_PPS 0x10 125 int sc_fifolen; 126 u_char sc_msr, sc_mcr, sc_lcr, sc_ier; 127 u_char sc_dtr; 128 129 u_char sc_cua; 130 131 u_char sc_initialize; /* force initialization */ 132 133 u_char *sc_ibuf, *sc_ibufp, *sc_ibufhigh, *sc_ibufend; 134 u_char sc_ibufs[2][COM_IBUFSIZE]; 135 136 /* power management hooks */ 137 int (*enable) __P((struct com_softc *)); 138 void (*disable) __P((struct com_softc *)); 139 int enabled; 140 }; 141 142 int comprobe1 __P((bus_space_tag_t, bus_space_handle_t)); 143 void cominit __P((bus_space_tag_t, bus_space_handle_t, int)); 144 int comstop __P((struct tty *, int)); 145 int comintr __P((void *)); 146 int com_detach __P((struct device *, int)); 147 int com_activate __P((struct device *, enum devact)); 148 149 #ifdef COM_HAYESP 150 int comprobeHAYESP __P((bus_space_handle_t hayespioh, struct com_softc *sc)); 151 #endif 152 void comdiag __P((void *)); 153 int comspeed __P((long, long)); 154 u_char com_cflag2lcr __P((tcflag_t)); 155 int comparam __P((struct tty *, struct termios *)); 156 void comstart __P((struct tty *)); 157 void compoll __P((void *)); 158 159 struct consdev; 160 void comcnprobe __P((struct consdev *)); 161 int comcnattach __P((bus_space_tag_t, int, int, int, tcflag_t)); 162 void comcninit __P((struct consdev *)); 163 int comcngetc __P((dev_t)); 164 void comcnputc __P((dev_t, int)); 165 void comcnpollc __P((dev_t, int)); 166 int com_common_getc __P((bus_space_tag_t, bus_space_handle_t)); 167 void com_common_putc __P((bus_space_tag_t, bus_space_handle_t, int)); 168 169 #if defined(DDB) || defined(KGDB) 170 void com_enable_debugport __P((struct com_softc *)); 171 #endif 172 173 #ifdef KGDB 174 int com_kgdb_attach __P((bus_space_tag_t, int, int, int, tcflag_t)); 175 int kgdbintr __P((void *)); 176 #endif 177 178 int comcnattach __P((bus_space_tag_t, int, int, int, tcflag_t)); 179 180 extern int comdefaultrate; 181 extern int comconsaddr; 182 extern int comconsinit; 183 extern int comconsattached; 184 extern bus_space_tag_t comconsiot; 185 extern bus_space_handle_t comconsioh; 186 extern tcflag_t comconscflag; 187