From owner-freebsd-current Tue Sep 26 03:10:26 1995 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id DAA29546 for current-outgoing; Tue, 26 Sep 1995 03:10:26 -0700 Received: from hq.icb.chel.su (icb-rich-gw.icb.chel.su [193.125.10.34]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id DAA29518 for ; Tue, 26 Sep 1995 03:09:43 -0700 Received: from localhost (babkin@localhost) by hq.icb.chel.su (8.6.5/8.6.5) id PAA09998; Tue, 26 Sep 1995 15:11:14 +0500 From: "Serge A. Babkin" Message-Id: <199509261011.PAA09998@hq.icb.chel.su> Subject: Patch for Digiboard To: jkh@time.cdrom.com (Jordan K. Hubbard) Date: Tue, 26 Sep 1995 15:11:14 +0500 (GMT+0500) Cc: current@freebsd.org In-Reply-To: <8078.810180725@time.cdrom.com> from "Jordan K. Hubbard" at Sep 3, 95 07:12:05 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Content-Length: 8935 Sender: owner-current@freebsd.org Precedence: bulk I have found the Digiboard driver in -current! :-) I have applied my last changes correcting the bug in dgbselect() to it and here is the patch. Submit it please. Thank you! BTW, there is a new option "NDGBPORTS". By default it is equal to NDGB*16 and means the number of ports of all Digiboards for which the tty structures are reserved. It can be set to the real value in config-file like: options "NDGBPORTS=8" -------------------------------- cut here -------------------------- *** dgb.c Thu Sep 7 09:14:40 1995 --- dgb.c Tue Sep 26 14:56:35 1995 *************** *** 3,8 **** * - * Copyright (C) 1995 by Serge Babkin - * * Digiboard driver. * * Stage 1. "Better than nothing". --- 3,6 ---- *************** *** 12,21 **** * which is under GNU General Public License version 2 so this driver * is forced to be under GPL 2 too. * - * Serge Babkin does not guarantee that this file is totally correct - * for any given task and users of this file must accept responsibility - * for any damage that occurs from the application of this file. - * * Written by Serge Babkin, * Joint Stock Commercial Bank "Chelindbank" * (Chelyabinsk, Russia) --- 10,15 ---- *************** *** 26,31 **** --- 20,31 ---- #if NDGB > 0 + /* the overall number of ports controlled by this driver */ + + #ifndef NDGBPORTS + # define NDGBPORTS (NDGB*16) + #endif + #include #include #include *************** *** 75,133 **** #define CONTROL_INIT_STATE 0x20 #define CONTROL_LOCK_STATE 0x40 #define UNIT_MASK 0x30000 ! #define PORT_MASK 0xF #define DEV_TO_UNIT(dev) (MINOR_TO_UNIT(minor(dev))) #define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK) #define MINOR_TO_UNIT(mynor) (((mynor) & UNIT_MASK)>>16) ! #define MINOR_TO_PORT(mynor) ((mynor) & 0xF) ! ! /* ! * Input buffer watermarks. ! * The external device is asked to stop sending when the buffer exactly reaches ! * high water, or when the high level requests it. ! * The high level is notified immediately (rather than at a later clock tick) ! * when this watermark is reached. ! * The buffer size is chosen so the watermark should almost never be reached. ! * The low watermark is invisibly 0 since the buffer is always emptied all at ! * once. ! */ ! #define RS_IHIGHWATER (3 * RS_IBUFSIZE / 4) ! ! /* ! * com state bits. ! * (CS_BUSY | CS_TTGO) and (CS_BUSY | CS_TTGO | CS_ODEVREADY) must be higher ! * than the other bits so that they can be tested as a group without masking ! * off the low bits. ! * ! * The following com and tty flags correspond closely: ! * CS_BUSY = TS_BUSY (maintained by comstart() and comflush()) ! * CS_TTGO = ~TS_TTSTOP (maintained by comstart() and siostop()) ! * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam()) ! * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam()) ! * TS_FLUSH is not used. ! * XXX I think TIOCSETA doesn't clear TS_TTSTOP when it clears IXON. ! * XXX CS_*FLOW should be CF_*FLOW in com->flags (control flags not state). ! */ ! #define CS_BUSY 0x80 /* output in progress */ ! #define CS_TTGO 0x40 /* output not stopped by XOFF */ ! #define CS_ODEVREADY 0x20 /* external device h/w ready (CTS) */ ! #define CS_CHECKMSR 1 /* check of MSR scheduled */ ! #define CS_CTS_OFLOW 2 /* use CTS output flow control */ ! #define CS_DTR_OFF 0x10 /* DTR held off */ ! #define CS_ODONE 4 /* output completed */ ! #define CS_RTS_IFLOW 8 /* use RTS input flow control */ ! ! static char const * const error_desc[] = { ! #define CE_OVERRUN 0 ! "silo overflow", ! #define CE_INTERRUPT_BUF_OVERFLOW 1 ! "interrupt-level buffer overflow", ! #define CE_TTY_BUF_OVERFLOW 2 ! "tty-level buffer overflow", ! }; ! ! #define CE_NTYPES 3 ! #define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum]) /* types. XXX - should be elsewhere */ typedef u_int Port_t; /* hardware port */ --- 75,85 ---- #define CONTROL_INIT_STATE 0x20 #define CONTROL_LOCK_STATE 0x40 #define UNIT_MASK 0x30000 ! #define PORT_MASK 0x1F #define DEV_TO_UNIT(dev) (MINOR_TO_UNIT(minor(dev))) #define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK) #define MINOR_TO_UNIT(mynor) (((mynor) & UNIT_MASK)>>16) ! #define MINOR_TO_PORT(mynor) ((mynor) & PORT_MASK) /* types. XXX - should be elsewhere */ typedef u_int Port_t; /* hardware port */ *************** *** 187,194 **** u_char last_modem_status; /* last MSR read by intr handler */ u_char prev_modem_status; /* last MSR handled by high level */ - struct tty *tp; /* cross reference */ - /* Initial state. */ struct termios it_in; /* should be in struct tty */ struct termios it_out; --- 139,144 ---- *************** *** 223,228 **** --- 173,180 ---- struct dgb_softc dgb_softc[NDGB]; + struct dgb_p dgb_ports[NDGBPORTS]; + struct tty dgb_tty[NDGBPORTS]; /* * The public functions in the com module ought to be declared in a com-driver *************** *** 511,516 **** --- 463,469 ---- int nfails; ushort *pstat; int lowwater; + int nports=0; if(sc->status!=ENABLED) { DPRINT2("dbg%d: try to attach a disabled card\n",unit); *************** *** 808,850 **** return 0; } ! addr=setwin(sc,PORTBASE); ! pstat=(ushort *)(mem+addr); ! ! for(i=0; i<32 && pstat[i]; i++); ! ! if(i!=sc->numports) { ! printf("dgb%d: %d ports are shown as valid ones\n",unit,i); ! if(inumports) ! sc->numports=i; ! printf("dgb%d: %d ports will be used\n",unit,sc->numports); } ! MALLOC(sc->ports, struct dgb_p *, sizeof(struct dgb_p)*sc->numports, ! M_TTYS, M_NOWAIT); ! ! if(sc->ports==0) { ! printf("dgb%d: unable to malloc the per port structures\n",unit); ! sc->status=DISABLED; ! hidewin(sc); ! return 0; ! } ! ! bzero(sc->ports, sizeof(struct dgb_p)*sc->numports); ! MALLOC(sc->ttys, struct tty *, sizeof(struct tty)*sc->numports, ! M_TTYS, M_NOWAIT); ! if(sc->ttys==0) { ! printf("dgb%d: unable to malloc the tty structures\n",unit); ! FREE(sc->ttys, M_TTYS); ! sc->status=DISABLED; ! hidewin(sc); ! return 0; } - bzero(sc->ttys, sizeof(struct tty)*sc->numports); - /* We should now init per-port structures */ bc=(struct board_chan *)(mem + CHANSTRUCT); sc->mailbox=(struct global_data *)(mem + FEP_GLOBAL); --- 761,787 ---- return 0; } ! if(nports+sc->numports>NDGBPORTS) { ! printf("dgb%d: only %d ports are usable\n", unit, NDGBPORTS-nports); ! sc->numports=NDGBPORTS-nports; } ! /* allocate port and tty structures */ ! sc->ports=&dgb_ports[nports]; ! sc->ttys=&dgb_tty[nports]; ! nports+=sc->numports; ! addr=setwin(sc,PORTBASE); ! pstat=(ushort *)(mem+addr); ! for(i=0; inumports && pstat[i]; i++) ! if(pstat[i]) ! sc->ports[i].status=ENABLED; ! else { ! sc->ports[i].status=DISABLED; ! printf("dgb%d: port %d is broken\n", unit, i); } /* We should now init per-port structures */ bc=(struct board_chan *)(mem + CHANSTRUCT); sc->mailbox=(struct global_data *)(mem + FEP_GLOBAL); *************** *** 854,865 **** else shrinkmem=0; - for(i=0; inumports; i++, bc++) { port= &sc->ports[i]; - port->status=ENABLED; - port->tty=&sc->ttys[i]; port->unit=unit; --- 791,799 ---- *************** *** 2016,2024 **** int rw; struct proc *p; { ! if (minor(dev) & CONTROL_MASK) return (ENODEV); ! return (ttselect(dev & ~MINOR_MAGIC_MASK, rw, p)); } static void --- 1950,1974 ---- int rw; struct proc *p; { ! int mynor; ! int unit,port; ! struct dgb_softc *sc; ! int ti; ! ! mynor=minor(dev); ! ! if (mynor & CONTROL_MASK) return (ENODEV); ! ! unit=MINOR_TO_UNIT(mynor); ! port=MINOR_TO_PORT(mynor); ! ! sc=&dgb_softc[unit]; ! ! /* get index in the tty table */ ! ti= &sc->ttys[port]-dgb_tty; ! ! return (ttselect(ti, rw, p)); } static void *** dgreg.h Thu Sep 7 09:14:33 1995 --- dgreg.h Tue Sep 26 14:57:06 1995 *************** *** 3,8 **** * - * Copyright (C) 1995 by Serge Babkin - * * Digiboard driver. * * Stage 1. "Better than nothing". --- 3,6 ---- *************** *** 11,20 **** * De Jongh or * which is under GNU General Public License version 2 so this driver * is forced to be under GPL 2 too. - * - * Serge Babkin does not guarantee that this file is totally correct - * for any given task and users of this file must accept responsibility - * for any damage that occurs from the application of this file. * * Written by Serge Babkin, * Joint Stock Commercial Bank "Chelindbank" --- 9,14 ---- -------------------------------- cut here -------------------------- Serge Babkin ! (babkin@hq.icb.chel.su) ! Headquarter of Joint Stock Commercial Bank "Chelindbank" ! Chelyabinsk, Russia