1 /* $OpenBSD: ucomvar.h,v 1.6 2001/05/03 02:20:33 aaron Exp $ */ 2 /* $NetBSD: ucomvar.h,v 1.8 2000/09/03 19:15:45 augustss Exp $ */ 3 4 /* 5 * Copyright (c) 1999 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Lennart Augustsson (lennart@augustsson.net) at 10 * Carlstedt Research & Technology. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. All advertising materials mentioning features or use of this software 21 * must display the following acknowledgement: 22 * This product includes software developed by the NetBSD 23 * Foundation, Inc. and its contributors. 24 * 4. Neither the name of The NetBSD Foundation nor the names of its 25 * contributors may be used to endorse or promote products derived 26 * from this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 29 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 32 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 * POSSIBILITY OF SUCH DAMAGE. 39 */ 40 41 42 /* Macros to clear/set/test flags. */ 43 #define SET(t, f) (t) |= (f) 44 #define CLR(t, f) (t) &= ~(f) 45 #define ISSET(t, f) ((t) & (f)) 46 47 #if defined(__NetBSD__) 48 #include "locators.h" 49 #endif 50 51 #define ucomcf_portno cf_loc[UCOMBUSCF_PORTNO] 52 #define UCOM_UNK_PORTNO UCOMBUSCF_PORTNO_DEFAULT 53 54 struct ucom_softc; 55 56 struct ucom_methods { 57 void (*ucom_get_status)(void *sc, int portno, u_char *lsr, u_char *msr); 58 void (*ucom_set)(void *sc, int portno, int reg, int onoff); 59 #define UCOM_SET_DTR 1 60 #define UCOM_SET_RTS 2 61 #define UCOM_SET_BREAK 3 62 int (*ucom_param)(void *sc, int portno, struct termios *); 63 int (*ucom_ioctl)(void *sc, int portno, u_long cmd, 64 caddr_t data, int flag, struct proc *p); 65 int (*ucom_open)(void *sc, int portno); 66 void (*ucom_close)(void *sc, int portno); 67 void (*ucom_read)(void *sc, int portno, u_char **ptr, u_int32_t *count); 68 void (*ucom_write)(void *sc, int portno, u_char *to, u_char *from, 69 u_int32_t *count); 70 }; 71 72 /* modem control register */ 73 #define UMCR_RTS 0x02 /* Request To Send */ 74 #define UMCR_DTR 0x01 /* Data Terminal Ready */ 75 76 /* line status register */ 77 #define ULSR_RCV_FIFO 0x80 78 #define ULSR_TSRE 0x40 /* Transmitter empty: byte sent */ 79 #define ULSR_TXRDY 0x20 /* Transmitter buffer empty */ 80 #define ULSR_BI 0x10 /* Break detected */ 81 #define ULSR_FE 0x08 /* Framing error: bad stop bit */ 82 #define ULSR_PE 0x04 /* Parity error */ 83 #define ULSR_OE 0x02 /* Overrun, lost incoming byte */ 84 #define ULSR_RXRDY 0x01 /* Byte ready in Receive Buffer */ 85 #define ULSR_RCV_MASK 0x1f /* Mask for incoming data or error */ 86 87 /* modem status register */ 88 /* All deltas are from the last read of the MSR. */ 89 #define UMSR_DCD 0x80 /* Current Data Carrier Detect */ 90 #define UMSR_RI 0x40 /* Current Ring Indicator */ 91 #define UMSR_DSR 0x20 /* Current Data Set Ready */ 92 #define UMSR_CTS 0x10 /* Current Clear to Send */ 93 #define UMSR_DDCD 0x08 /* DCD has changed state */ 94 #define UMSR_TERI 0x04 /* RI has toggled low to high */ 95 #define UMSR_DDSR 0x02 /* DSR has changed state */ 96 #define UMSR_DCTS 0x01 /* CTS has changed state */ 97 98 struct ucom_attach_args { 99 int portno; 100 int bulkin; 101 int bulkout; 102 u_int ibufsize; 103 u_int ibufsizepad; 104 u_int obufsize; 105 u_int opkthdrlen; 106 const char *info; /* attach message */ 107 usbd_device_handle device; 108 usbd_interface_handle iface; 109 struct ucom_methods *methods; 110 void *arg; 111 }; 112 113 int ucomprint(void *aux, const char *pnp); 114 #if defined(__OpenBSD__) 115 int ucomsubmatch(struct device *parent, void *cf, void *aux); 116 #else 117 int ucomsubmatch(struct device *parent, struct cfdata *cf, void *aux); 118 #endif 119 void ucom_status_change(struct ucom_softc *); 120