From owner-p4-projects@FreeBSD.ORG Sat Jul 26 20:12:08 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3F8CE37B404; Sat, 26 Jul 2003 20:12:08 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CB5F637B401 for ; Sat, 26 Jul 2003 20:12:07 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 594E943F93 for ; Sat, 26 Jul 2003 20:12:07 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h6R3C70U044562 for ; Sat, 26 Jul 2003 20:12:07 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h6R3C6Br044559 for perforce@freebsd.org; Sat, 26 Jul 2003 20:12:06 -0700 (PDT) Date: Sat, 26 Jul 2003 20:12:06 -0700 (PDT) Message-Id: <200307270312.h6R3C6Br044559@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 35068 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jul 2003 03:12:09 -0000 http://perforce.freebsd.org/chv.cgi?CH=35068 Change 35068 by marcel@marcel_nfs on 2003/07/26 20:11:07 o Add delta bit to the signals. o Add a description for getsig & setsig. o Implement getsig and setsig properly for ns8250. Affected files ... .. //depot/projects/uart/dev/uart/uart_bus.h#10 edit .. //depot/projects/uart/dev/uart/uart_core.c#10 edit .. //depot/projects/uart/dev/uart/uart_dev_ns8250.c#10 edit .. //depot/projects/uart/dev/uart/uart_if.m#6 edit Differences ... ==== //depot/projects/uart/dev/uart/uart_bus.h#10 (text+ko) ==== @@ -50,16 +50,24 @@ #define UART_STAT_OVERRUN 0x0400 #define UART_STAT_PARERR 0x0800 -/* Modem and line signals */ +/* Modem and line signals. */ #define UART_SIG_DTR 0x0001 #define UART_SIG_RTS 0x0002 -#define UART_SIG_DCR 0x0100 -#define UART_SIG_CTS 0x0200 -#define UART_SIG_DCD 0x0400 -#define UART_SIG_RI 0x0800 +#define UART_SIG_DSR 0x0004 +#define UART_SIG_CTS 0x0008 +#define UART_SIG_DCD 0x0010 +#define UART_SIG_RI 0x0020 +#define UART_SIG_DDTR 0x0100 +#define UART_SIG_DRTS 0x0200 +#define UART_SIG_DDSR 0x0400 +#define UART_SIG_DCTS 0x0800 +#define UART_SIG_DDCD 0x1000 +#define UART_SIG_DRI 0x2000 -#define UART_SIGMASK_DTE 0x00FF -#define UART_SIGMASK_DCE 0xFF00 +#define UART_SIGMASK_DTE 0x0003 +#define UART_SIGMASK_DCE 0x003c +#define UART_SIGMASK_STATE 0x003f +#define UART_SIGMASK_DELTA 0x3f00 /* * UART class & instance (=softc) ==== //depot/projects/uart/dev/uart/uart_core.c#10 (text+ko) ==== @@ -510,7 +510,8 @@ } else tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; - UART_SETSIG(sc, UART_SIG_DTR|UART_SIG_RTS); + UART_SETSIG(sc, UART_SIG_DDTR | UART_SIG_DRTS | + UART_SIG_DTR | UART_SIG_RTS); } error = (*linesw[tp->t_line].l_open)(dev, tp); ==== //depot/projects/uart/dev/uart/uart_dev_ns8250.c#10 (text+ko) ==== @@ -317,8 +317,7 @@ uint8_t fcr; uint8_t lcr; uint8_t mcr; - uint8_t signals; - uint8_t sigchg; + int signals; }; static int ns8250_bus_attach(struct uart_softc *); @@ -352,6 +351,13 @@ .uc_rclk = 1843200 }; +#define SIGCHG(c, i, s, d) \ + if (c) { \ + i |= (i & s) ? s : s | d; \ + } else { \ + i = (i & s) ? (i & ~s) | d : i; \ + } + static int ns8250_bus_attach(struct uart_softc *sc) { @@ -367,8 +373,11 @@ uart_setreg(bas, REG_IER, IER_ERXRDY | IER_ETXRDY | IER_ERLS | IER_EMSC); uart_barrier(bas); - ns8250->signals = uart_getreg(bas, REG_MSR) >> 4; - ns8250->sigchg = 0; + if (ns8250->mcr & MCR_DTR) + ns8250->signals |= UART_SIG_DTR; + if (ns8250->mcr & MCR_RTS) + ns8250->signals |= UART_SIG_RTS; + ns8250_bus_getsig(sc); return (0); } @@ -394,14 +403,17 @@ ns8250_bus_getsig(struct uart_softc *sc) { struct ns8250_softc *ns8250 = (struct ns8250_softc*)sc; - struct uart_bas *bas; - uint8_t sig; + uint8_t msr; + int sig; - bas = &sc->sc_bas; - sig = uart_getreg(bas, REG_MSR) >> 4; - ns8250->sigchg |= ns8250->signals ^ sig; - ns8250->signals = sig; - return ((ns8250->sigchg << 4) | ns8250->signals); + msr = uart_getreg(&sc->sc_bas, REG_MSR); + sig = ns8250->signals; + SIGCHG(msr & MSR_DSR, sig, UART_SIG_DSR, UART_SIG_DDSR); + SIGCHG(msr & MSR_CTS, sig, UART_SIG_CTS, UART_SIG_DCTS); + SIGCHG(msr & MSR_DCD, sig, UART_SIG_DCD, UART_SIG_DDCD); + SIGCHG(msr & MSR_RI, sig, UART_SIG_RI, UART_SIG_DRI); + ns8250->signals = sig & ~UART_SIGMASK_DELTA; + return (sig); } static int @@ -409,8 +421,8 @@ { struct ns8250_softc *ns8250 = (struct ns8250_softc*)sc; struct uart_bas *bas; - int ipend; - uint8_t lsr, sig; + int ipend, sig; + uint8_t lsr; bas = &sc->sc_bas; ipend = 0; @@ -423,11 +435,11 @@ ipend |= UART_IPEND_RXREADY; if (lsr & LSR_TEMT) ipend |= UART_IPEND_TXIDLE; - sig = uart_getreg(bas, REG_MSR) >> 4; - ns8250->sigchg |= ns8250->signals ^ sig; - ns8250->signals = sig; - if (ns8250->sigchg) + sig = ns8250_bus_getsig(sc); + if (sig & UART_SIGMASK_DELTA) { + ns8250->signals = sig; /* restore delta bits. */ ipend |= UART_IPEND_SIGCHG; + } return (ipend); } @@ -567,7 +579,6 @@ uint8_t lsr; bas = &sc->sc_bas; - while (!uart_rx_full(sc)) { lsr = uart_getreg(bas, REG_LSR); if ((lsr & LSR_RXRDY) == 0) @@ -585,7 +596,23 @@ static int ns8250_bus_setsig(struct uart_softc *sc, int sig) { + struct ns8250_softc *ns8250 = (struct ns8250_softc*)sc; + if (sig & UART_SIG_DDTR) { + SIGCHG(sig & UART_SIG_DTR, ns8250->signals, UART_SIG_DTR, + UART_SIG_DDTR); + } + if (sig & UART_SIG_DRTS) { + SIGCHG(sig & UART_SIG_DTR, ns8250->signals, UART_SIG_DTR, + UART_SIG_DDTR); + } + ns8250->mcr &= ~(MCR_DTR|MCR_RTS); + if (ns8250->signals & UART_SIG_DTR) + ns8250->mcr |= MCR_DTR; + if (ns8250->signals & UART_SIG_RTS) + ns8250->mcr |= MCR_RTS; + uart_setreg(&sc->sc_bas, REG_MCR, ns8250->mcr); + uart_barrier(&sc->sc_bas); return (0); } @@ -596,7 +623,6 @@ int xc; bas = &sc->sc_bas; - while (!uart_tx_empty(sc)) { if ((uart_getreg(bas, REG_LSR) & LSR_THRE) == 0) break; ==== //depot/projects/uart/dev/uart/uart_if.m#6 (text+ko) ==== @@ -54,7 +54,12 @@ }; # getsig() - get line and modem signals. -# XXX needs explanation. +# This method retrieves the DTE and DCE signals and their corresponding +# delta bits. The delta bits include those corresponding to DTE signals +# when they were changed by a call to setsig. The delta bits maintained +# by the hardware driver are cleared as a side-effect. A second call to +# this function will have not have any delta bits set, unless there was +# a change in the signals in the mean time. METHOD int getsig { struct uart_softc *this; }; @@ -86,7 +91,10 @@ }; # setsig() - set line and modem signals. -# XXX needs explanation. +# This method allows changing DTE signals. The DTE delta bits indicate which +# signals are to be changed and the DTE bits themselves indicate whether to +# set or clear the signals. A subsequent call to getsig will return with the +# DTE delta bits set of those DTE signals that did change by this method. METHOD int setsig { struct uart_softc *this; int sig;