From owner-freebsd-hackers Sat Jun 29 08:24:09 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id IAA08683 for hackers-outgoing; Sat, 29 Jun 1996 08:24:09 -0700 (PDT) Received: from guardian.fortress.org (fortress.org [199.84.158.128]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id IAA08642 for ; Sat, 29 Jun 1996 08:23:55 -0700 (PDT) Received: (from andrew@localhost) by guardian.fortress.org (8.6.12/8.6.12) id LAA00927; Sat, 29 Jun 1996 11:24:08 -0400 Date: Sat, 29 Jun 1996 11:24:08 -0400 (EDT) From: Andrew Webster Reply-To: andrew@pubnix.net To: hackers@freebsd.org Subject: SWAP DCD & DSR in sio.c + Question Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk I recently got a BocaBoard 16 port box for my FreeBSD system. Much to my shock & horror, it uses 10 pin RJ45s (RJ69 expensive and hard to get), with DCD on pin 1. So I figured, there isn't much that can't be fixed with a little software, and I patched sio.c to SWAP DCD and DSR signals. The patch works by assigning the flag 0x0010 to indicate that DCD and DSR should be swapped (this is a standard option on Digiboard products, with RJ45s, it seems). So a line like sio8 at isa? port 0x100 tty flags 0x1715 would do the trick. If anyone is interested in this, the diffs from 2.1.0-STABLE are at the end of this message. What if one wanted have more than 32 sio ports on a system? Can sio.c be patched to support upto 64 ports? I created siox.c which is a clone of sio.c except that it shows up as siox in the drivers. How do I assign a different major number to it? --- cut here --- *** sio.c.orig Thu Sep 14 03:09:28 1995 --- sio.c Sat Jun 29 11:20:24 1996 *************** *** 32,37 **** --- 32,38 ---- * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 * $Id: sio.c,v 1.99.4.1 1995/09/14 07:09:28 davidg Exp $ + * Added DCD/DSR swap - aw */ #include "sio.h" *************** *** 90,95 **** --- 91,101 ---- #define COM_LOSESOUTINTS(dev) ((dev)->id_flags & 0x08) #define COM_NOFIFO(dev) ((dev)->id_flags & 0x02) #define COM_VERBOSE(dev) ((dev)->id_flags & 0x80) + #define COM_SWAPDCDDSR(dev) ((dev)->id_flags & 0x10) + + #define SWAPMASKDCD (MSR_DCD | MSR_DDCD) + #define SWAPMASKDSR (MSR_DSR | MSR_DDSR) + #define SWAPMASKDCDDSR (SWAPMASKDCD | SWAPMASKDSR) #define com_scr 7 /* scratch register for 16450-16550 (R/W) */ *************** *** 168,173 **** --- 174,180 ---- #ifdef COM_MULTIPORT bool_t multiport; /* is this unit part of a multiport device? */ #endif /* COM_MULTIPORT */ + bool_t swapdcddsr; bool_t no_irq; /* nonzero if irq is not attached */ bool_t poll; /* nonzero if polling is required */ bool_t poll_output; /* nonzero if polling for output is required */ *************** *** 422,427 **** --- 429,435 ---- } } #endif /* COM_MULTIPORT */ + if (idev->id_irq == 0) mcr_image = 0; *************** *** 695,700 **** --- 703,712 ---- outb(iobase + com_fifo, 0); determined_type: ; + if (COM_SWAPDCDDSR(isdp)) { + com->swapdcddsr = TRUE; + printf (" dsr<>dcd "); + } #ifdef COM_MULTIPORT if (COM_ISMULTIPORT(isdp)) { com->multiport = TRUE; *************** *** 766,771 **** --- 778,784 ---- int s; struct tty *tp; int unit; + u_char tmp1; mynor = minor(dev); unit = MINOR_TO_UNIT(mynor); *************** *** 871,878 **** disable_intr(); (void) inb(com->line_status_port); (void) inb(com->data_port); ! com->prev_modem_status = com->last_modem_status ! = inb(com->modem_status_port); outb(iobase + com_ier, IER_ERXRDY | IER_ETXRDY | IER_ERLS | IER_EMSC); enable_intr(); --- 884,900 ---- disable_intr(); (void) inb(com->line_status_port); (void) inb(com->data_port); ! tmp1 = inb(com->modem_status_port); ! if (com->swapdcddsr) ! com->prev_modem_status = com->last_modem_status = ! ((tmp1 & ~SWAPMASKDCDDSR) ! | ((tmp1 & SWAPMASKDCD) >> 2) ! | ((tmp1 & SWAPMASKDSR) << 2)); ! else ! com->prev_modem_status = com->last_modem_status = tmp1; ! ! ! outb(iobase + com_ier, IER_ERXRDY | IER_ETXRDY | IER_ERLS | IER_EMSC); enable_intr(); *************** *** 1118,1123 **** --- 1140,1146 ---- u_char modem_status; u_char *ioptr; u_char recv_data; + u_char tmp1; if (com->do_timestamp) /* XXX a little bloat here... */ *************** *** 1204,1210 **** } /* modem status change? (always check before doing output) */ ! modem_status = inb(com->modem_status_port); if (modem_status != com->last_modem_status) { /* * Schedule high level to handle DCD changes. Note --- 1227,1239 ---- } /* modem status change? (always check before doing output) */ ! tmp1 = inb(com->modem_status_port); ! if (com->swapdcddsr) ! modem_status = ((tmp1 & ~SWAPMASKDCDDSR) ! | ((tmp1 & SWAPMASKDCD) >> 2) ! | ((tmp1 & SWAPMASKDSR) << 2)); ! else ! modem_status = tmp1; if (modem_status != com->last_modem_status) { /* * Schedule high level to handle DCD changes. Note --- cut here --- Andrew Webster - andrew@pubnix.net - http://www.pubnix.net PubNIX Montreal - Connected to the world - Branche au monde 514-990-5911 - P.O. Box 147, Cote St-Luc, Quebec, H4V 2Y3