1 /* $OpenBSD: ucomvar.h,v 1.20 2023/10/01 15:58:11 krw Exp $ */ 2 /* $NetBSD: ucomvar.h,v 1.10 2001/12/31 12:15:21 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 * 21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #define UCOMBUSCF_PORTNO 0 35 #define UCOMBUSCF_PORTNO_DEFAULT -1 36 37 #define ucomcf_portno cf_loc[UCOMBUSCF_PORTNO] 38 #define UCOM_UNK_PORTNO UCOMBUSCF_PORTNO_DEFAULT 39 40 struct ucom_softc; 41 42 struct ucom_methods { 43 void (*ucom_get_status)(void *sc, int portno, u_char *lsr, u_char *msr); 44 void (*ucom_set)(void *sc, int portno, int reg, int onoff); 45 #define UCOM_SET_DTR 1 46 #define UCOM_SET_RTS 2 47 #define UCOM_SET_BREAK 3 48 int (*ucom_param)(void *sc, int portno, struct termios *); 49 int (*ucom_ioctl)(void *sc, int portno, u_long cmd, 50 caddr_t data, int flag, struct proc *p); 51 int (*ucom_open)(void *sc, int portno); 52 void (*ucom_close)(void *sc, int portno); 53 void (*ucom_read)(void *sc, int portno, u_char **ptr, u_int32_t *count); 54 void (*ucom_write)(void *sc, int portno, u_char *to, u_char *from, 55 u_int32_t *count); 56 }; 57 58 /* modem control register */ 59 #define UMCR_RTS 0x02 /* Request To Send */ 60 #define UMCR_DTR 0x01 /* Data Terminal Ready */ 61 62 /* line status register */ 63 #define ULSR_RCV_FIFO 0x80 64 #define ULSR_TSRE 0x40 /* Transmitter empty: byte sent */ 65 #define ULSR_TXRDY 0x20 /* Transmitter buffer empty */ 66 #define ULSR_BI 0x10 /* Break detected */ 67 #define ULSR_FE 0x08 /* Framing error: bad stop bit */ 68 #define ULSR_PE 0x04 /* Parity error */ 69 #define ULSR_OE 0x02 /* Overrun, lost incoming byte */ 70 #define ULSR_RXRDY 0x01 /* Byte ready in Receive Buffer */ 71 #define ULSR_RCV_MASK 0x1f /* Mask for incoming data or error */ 72 73 /* modem status register */ 74 /* All deltas are from the last read of the MSR. */ 75 #define UMSR_DCD 0x80 /* Current Data Carrier Detect */ 76 #define UMSR_RI 0x40 /* Current Ring Indicator */ 77 #define UMSR_DSR 0x20 /* Current Data Set Ready */ 78 #define UMSR_CTS 0x10 /* Current Clear to Send */ 79 #define UMSR_DDCD 0x08 /* DCD has changed state */ 80 #define UMSR_TERI 0x04 /* RI has toggled low to high */ 81 #define UMSR_DDSR 0x02 /* DSR has changed state */ 82 #define UMSR_DCTS 0x01 /* CTS has changed state */ 83 84 struct ucom_attach_args { 85 int portno; 86 int bulkin; 87 int bulkout; 88 struct uhidev_softc *uhidev; 89 u_int ibufsize; 90 u_int ibufsizepad; 91 u_int obufsize; 92 u_int opkthdrlen; 93 const char *info; /* attach message */ 94 struct usbd_device *device; 95 struct usbd_interface *iface; 96 const struct ucom_methods *methods; 97 void *arg; 98 }; 99 100 int ucomsubmatch(struct device *, void *, void *); 101 102 char *sysctl_ucominit(void); 103 104 int ucomprint(void *aux, const char *pnp); 105 void ucom_status_change(struct ucom_softc *); 106