⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ss.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
#ifndef lintstatic char *sccsid = "@(#)ss.c	4.2	(ULTRIX)	8/13/90";#endif lint/************************************************************************ *									* *			Copyright (c) 1985-89 by			* *		Digital Equipment Corporation, Maynard, MA		* *			All rights reserved.				* *									* *   This software is furnished under a license and may be used and	* *   copied  only  in accordance with the terms of such license and	* *   with the  inclusion  of  the  above  copyright  notice.   This	* *   software  or  any  other copies thereof may not be provided or	* *   otherwise made available to any other person.  No title to and	* *   ownership of the software is hereby transferred.			* *									* *   This software is  derived  from  software  received  from  the	* *   University    of   California,   Berkeley,   and   from   Bell	* *   Laboratories.  Use, duplication, or disclosure is  subject  to	* *   restrictions  under  license  agreements  with  University  of	* *   California and with AT&T.						* *									* *   The information in this software is subject to change  without	* *   notice  and should not be construed as a commitment by Digital	* *   Equipment Corporation.						* *									* *   Digital assumes no responsibility for the use  or  reliability	* *   of its software on equipment which is not supplied by Digital.	* *									* ************************************************************************/#include "ss.h"#if NSS > 0 || defined(BINARY)/* *  VAXstar serial line unit driver * *  Modification History: * *  6-Jul-1990  - Kuo-Hsiung Hsieh *      Fixed data corrupted problem due to setting break condition *      on a transmission line.  On DC type of chip, a specific delay *      period has to be imposed on the transmission line if the next *      thing to transmit is a break condition.  Data could be corrupted *      even though TRDY bit may say it is ready to send the next * 	character. * * 31-Oct-89 - Randall Brown * *	Added the support to allow the device to determine if baudrate is  *	supported before it is set in the tty data structures. * * 15-Aug-89 - Randall Brown * *	Changed all references of TCSADFLUSH to TCSAFLUSH  * * 21-Jul-89 - Randall Brown * *	Moved default open and default close code to tty.c and call it *	using tty_def_open() and tty_def_close().  In the close routine, *	don't clear the baudrate so that subsequent opens will keep the *	present attributes.  This only applies to a Berkeley environment. * * 12-Jun-89 - dws *	Added trusted path support. * * 23-May-89 - darrell *	Removed the v_ from the fields of the cpusw structure, and globally *	defined cpup -- as part of the new cpusw. * * 09-May-89 - gmm (v3.1 merge) *	Set modem control on for TMII (MicroVAX 3100) * *  8-May-89	Giles Atkinson *    Expand mapped part of system scratch RAM to 3 pages to allow peek *    at version numbers. *    Changed major device numbers to use cons_maj.h * * 05-Mar-89 - Fred Canter *	Fix stray interrupts thru SCB vector 0x1fc caused by polling *	for RDONE with interrupts enabled in the receive interrupt *	routine. * * 25-Jan-89 - Randall Brown * *	Changed cd_drop to look at LNOHANG.  Changed close routine to look *	at HUPCL. * * 28-Sep-88 - Fred Canter *	Clean up comments. * * 28-Sep-88 - Randall Brown * *	Fixed a bug in ssxint so that the transmitter interrupt will be *	acknowledged when the terminal is in the stop state. * * 13-Sep-88 - Ali Rafieymehr * *	Fixed a bug which was causing the "select" not to work for *	alternate console. * * 02-Sep-88 - Tim Burke * *	Return EINVAL instead of ENOTTY for POSIX programs on invalid ioctls. * * 19-Aug-88 - Randall Brown * *	Added modem support for the PVAX.  The PVAX only gives DSR to * 	cpu, therefore CD and CTS are ignored. * * 18-Aug-88 - Tim Burke * *	If PARMRK is set and a BREAK occurs, return '\0377','\0','\0'. * * 5-Aug-88 - Tim Burke * *	Return the 2 character sequence 0377, 0377 upon receipt of a valid *	0377 character only when PARMRK is set under the termio line disc. * * 07-Jun-88 - Fred Canter *	Back out last change (hardware changed their mind). * * 06-Jun-88 - Fred Canter *	Use different address for SCSI/SCSI controller. * * 19-May-88 - Fred Canter *	Additional virtual address mapping for SCSI support *	and using extended I/O mode for CVAXstar/PVAX. * * 16-May-88 - Tim Burke * 	Call param routine for setting of local mode word because it can  * 	affect bit size and parity. * * 15-Feb-88 - Fred Canter *	Changes for VAX420 (CVAXstar/PVAX) support. * * 29-Jan-88 - Tim Burke *	Changed most softCAR[unit&LINEMASK] references to use the CLOCAL *	bit of the control flags to determine if the line is set to be a *	modem line or a direct connect.  The setting of softCAR[] remains *	to allow one to set default settings for device open. * *  1-Dec-87 - Tim Burke * *	Added support for both System V termio(7) and POSIX termios(7).  These *	changes also include support for 8-bit canonical processing.  Changes *	involve: * *	- Default settings on first open depend on mode of open.  For termio *	  opens the defaults are "RAW" style, while non-termio opens default *	  to the traditional "cooked" style. *	- The driver now represents its terminal attributes and special  *	  characters in the POSIX termios data structure.  This contrasts the *	  original approach of storing attributes and special chars in the *	  t_flags, ltchars and tchars. *	- New termio ioctls: TCSANOW, TCSADRAIN, TCSADFLUSH, TCSETA, TESETAW, *	  TCSETAF.	 *	- Addition of LPASS8 to local mode word for 8-bit canonical support. * *  8-Sep-87 - Ricky Palmer (rsp) * *	Defined LINEMASK and added to code where appropriate in particular *	the DEVIOCGET code. * *  3-Aug-87 - rafiey (Ali Rafieymehr) *      Mapped system scratch RAM which is used by the VAXstar color *      driver. * * 14-May-87 - fred (Fred Canter) *	Never allow open of /dev/tty00 (conflicts with /dev/console). *	Don't allow open of /dev/tty01 on VAXstation 2000 *	(conflicts with mouse). *	Bug fix to allow xcons to work (loop kernel messages to *	login window), was not calling graphics driver ioctl routine. * * 20-Mar-87 - Tim Burke * *	Added full TERMIO functionality to terminal subsystem. * * 11-Feb-87 - rafiey (Ali Rafieymehr) *	Changed the driver to call read/write routines of the color driver *	for reads/writes. * * 28-Jan-87 - Tim Burke * *	Added the capability to ignore the "DSR" modem signal.  This is being *	done to allow modems that do not follow DEC Standard 52 to still  *	function as they would have prior to the addition of DECSTD52 code *	into the drivers.  If the driver is setup to ignore "DSR" then it will *	not be following DECSTD52.  To follow DECSTD52 set ssdsr to "1", to *	ignore "DSR" set ssdsr to be "0"; * *  07-Jan-87 - rafiey (Ali Rafieymehr) *	Corrected the value of the color option in ubareg.h, therefore *	uncommented the two cases in sscons_init which were previously *	commented out. * *  16-Dec-86 - fred (Fred Canter) *	Changes for removal of DEV_MODEV_OFF devioctl flag. * *  11-Dec-86 - fred (Fred Canter) *	Bug fix: devio soft error count not incremented correctly *		 on any line other than zero. *	Bug fix: Sign extension of intr char during framing error *		 caused false silo overflow error indication. * *   2-Dec-86 - fred (Fred Canter) *	Fix rlogin hanging if console is diagnostic terminal *	on the printer port (BCC08 cable). *	Change minor device to 3 in ssselect(). * *   4-Nov-86 - fred (Fred Canter) *	Disable support for silo alarm mode on VAXstar. *	It causes input silo overrun errors when using tip. * *   4-Nov-86 - tim  (Tim Burke) *	Clear TS_TSTOP on close to prevent line hanging if *	in stop state. * *  18-Sept-86 - tim  (Tim Burke) *	Lower ipl level upon receipt of a badcall on modem line.  This is *	done to insure that future interrupts get serviced. * *  30-Aug-86 -- fred (Fred Canter) *	Merged in Tim Burke's final dec standard 52 modem support changes. *	Fixed console putc to work in physical mode (for crash dump). *	Change for dummy sgcons_init and smcons_init routines. * *  26-Aug-86 -- rsp (Ricky Palmer) *	Cleaned up devioctl code to (1) zero out devget structure *	upon entry and (2) use strlen instead of fixed storage *	for bcopy's. * *  24-Aug-86  -- fred (Fred Canter) and rafiey (Ali Rafieymehr) *	Support for smscreen (console message window). *	Allow uses to change softCAR only on line 2 (modem control line). *	Finish DEVIOCTL support. *	Remove ssreset() and other general cleanup. *	Hardwire critical line parameters into the driver stty in *	users' .profile can't make the line inoperative. * *  14-Aug-86  -- fred (Fred Canter) *	general cleanup, Tim's dec standard 52 stuff, *	no silo mode if graphics device present, *	complete redesign of ssputc(). * *   5-Aug-86  -- fred (Fred Canter) *	Major changes, bug fixes, and passing characters to the *	bitmap graphics driver (sm.c). * *  24-Jul-86  -- tim  (Tim Burke) *	Added full DEC Standard 52 support.  Most changes occured in the  *	ssscan , ssopen, and ssclose routines to track modem signal status. *      Added the following modem control routines: *      ss_cd_drop, ss_dsr_check, ss_cd_down, ss_tty_drop, ss_start_tty. * *   2-Jul-86  -- fred (Fred Canter) *	Removed DZ32 code, changed from 8 to 4 lines per unit, *	moved ssconsinit(), ssputc(), & ssgetc() from cons.c to ss.c, *	other improvements. * *  18-Jun-86  -- fred (Fred Canter) *	Created this file (derived from dz.c). */#include "../data/ss_data.c"int ssdebug = 0;/** Driver information for auto-configuration stuff.*/int	ssprobe(), ssattach(), ssrint();int	ss_cd_drop(), ss_dsr_check(), ss_cd_down(), ss_tty_drop(); /* Modem */u_short	ssstd[] = { 0 };struct	uba_driver ssdriver ={ ssprobe, 0, ssattach, 0, ssstd, "ss", ssinfo };int	ssstart(), ssxint(), ssdma(), ssbaudrate();int	ttrstrt();int	ssact;void 	sssetbreak();/* * Graphics device driver entry points. * Used to call graphics device driver as needed. */extern	(*vs_gdopen)();extern	(*vs_gdclose)();extern	(*vs_gdread)();extern	(*vs_gdwrite)();extern	(*vs_gdselect)();extern	(*vs_gdkint)();extern	(*vs_gdioctl)();extern	(*vs_gdstop)();#define	FASTTIMER	(hz/30)		/* rate to drain silos, when in use */#define MODEM_UNIT	2		/* Modem control only on unit 2     */#define LINEMASK        0x03            /* line unit mask */int	sssilos;			/* mask of SLU's with silo in use */int	sstimerintvl;			/* time interval for sstimer */int	sshighrate = 100;		/* silo on if sschars > sshighrate */int	sslowrate = 75;			/* silo off if ssrate < sslowrate *//** The SLU doesn't interrupt on carrier transitions, so* we have to use a timer to watch it.*/char	ss_timer;		/* timer started? */char	ss_speeds[] ={ 0,020,021,022,023,024,0,025,026,027,030,032,034,036,037,0 };/* minumum delay value for setting a break condition.  If we set * a break condition without delaying this minimum interval, we * might corrupt character which is still in the shift register. * The delay values are calculated based on the following equation; * 12 (bits/char) * 100 (hz) / baudrate + 2 (safety factor). */u_char	ss_delay[] ={ 0,26,18,13,11,10,0,6,4,3,3,3,2,2,2,0 };short	ss_valid_speeds = 0x7fbf; /* 0,1,1,1, 1,1,1,1, 1,0,1,1, 1,1,1,1 */u_char sscan_previous;		/* Used to detect modem transitions */extern	struct	nexus	nexus[];struct	tty		sm_tty;extern struct cpusw *cpup;	/* pointer to cpusw entry */#ifdef DEBUG#define PRINT_SIGNALS() { cprintf("Modem signals: "); \	if (ssaddr->ssmsr&SS_RDSR) cprintf(" DSR "); \	if (ssaddr->ssmsr&SS_RCTS) cprintf(" CTS "); \	if (ssaddr->ssmsr&SS_RCD) cprintf(" CD "); \	cprintf("\n"); } \/*	cprintf("ssaddr->ssmsr %x : %x\n", &(ssaddr->ssmsr), ssaddr->ssmsr);*/#endif DEBUGextern int cpu_sub_subtype;ssprobe(reg)	caddr_t reg;{	register struct nb_regs *ssaddr = (struct nb_regs *)nexus;	/*	 * ONLY on a VAXstation 2000 or MicroVAX 2000	 * or CVAXstar.	 */	if ((cpu != VAXSTAR) && (cpu != C_VAXSTAR)) {	    return(0);	}	if ( (cpu != C_VAXSTAR) || (cpu_sub_subtype == SB_TMII) ) { /* if not a PVAX then set modem_ctl on */	    ss_modem_ctl = 1;	}#ifdef lint	ssrint(0); ssxint((struct tty *)0);#endif	ssaddr->nb_int_msk |= SINT_ST;	ssaddr->sstcr = 0x8;		/*  enable line 3 */	DELAY(100000);	ssaddr->sstcr = 0;	ssaddr->nb_int_msk &= ~SINT_ST;	ssaddr->nb_int_reqclr = SINT_ST;	if (cvec && cvec != 0x200)		cvec -= 4;	return (1);	/* 1 not sizeof anything, just says probe succeeded */}ssattach(ui)	register struct uba_device *ui;{	register struct pdma *pdp = &sspdma[ui->ui_unit*4];	register struct tty *tp = &ss_tty[ui->ui_unit*4];	register int cntr;	register struct nb_regs *ssaddr = (struct nb_regs *)nexus;	extern ssscan();	for (cntr = 0; cntr < 4; cntr++) {		/* dzdevice looks wrong, but see vaxuba/pdma.h for reason */		pdp->p_addr = (struct dzdevice *)&ssaddr->sscsr;		pdp->p_arg = (int)tp;		pdp->p_fcn = ssxint;		pdp++, tp++;	}	sssoftCAR[ui->ui_unit] = ui->ui_flags;	ssdefaultCAR[ui->ui_unit] = ui->ui_flags;	ssmodem = 0; 	if (ss_timer == 0) {		ss_timer++;		timeout(ssscan, (caddr_t)0, hz);		sstimerintvl = FASTTIMER;	}}/*ARGSUSED*/ssopen(dev, flag)	dev_t dev;{	register struct nb_regs *ssaddr = (struct nb_regs *)nexus;	register struct tty *tp;	register int unit;	register int maj;	int inuse;  /*hold state of inuse bit while blocked waiting for carr*/	maj = major(dev);	/*	 * If a diagnostic console is attached to SLU line 3,	 * don't allow open of the printer port (also line 3).	 * This could cause lpr to write to the console.	 */	if((vs_cfgtst&VS_L3CON) && (maj == SS_MAJOR)) {		if((minor(dev)&LINEMASK) == 3)			return (ENXIO);	}	unit = minor(dev);	if((vs_cfgtst&VS_L3CON) &&	   (maj == CONSOLE_MAJOR) &&	   ((unit&LINEMASK) == 0))		unit |= 3;	/* diag console on SLU line 3 */	if (unit >= ss_cnt || sspdma[unit].p_addr == 0)		return (ENXIO);	/* 	 * Never allow open of device 45/0 (/dev/tty00) 	 * because it conflicts with 0/0 (/dev/console). 	 */ 	if ((unit == 0) && (maj == SS_MAJOR)) 		return (ENXIO); 	/* 	 * If the console is a graphics device (VAXstation 2000), 	 * don't allow open of device 45/1 (/dev/tty01) 	 * because it conflicts with 0/1 (graphics pointer device). 	 */ 	if (vs_gdopen && (unit == 1) && (maj == SS_MAJOR)) 		return (ENXIO); 	/*	/*	 * Call the graphics device open routine	 * if there is one and the open if for the fancy tube.	 */	if ((vs_gdopen && (unit <= 1)) || (vs_gdopen && (unit == 2) &&	    (maj == CONSOLE_MAJOR)))		return((*vs_gdopen)(dev, flag));	tp = &ss_tty[unit];	if (tp->t_state&TS_XCLUDE && u.u_uid != 0){		return (EBUSY);	}	while (tp->t_state&TS_CLOSING) { /* let DTR stay down for awhile */		sleep((caddr_t)&tp->t_rawq, TTIPRI);	}	tp->t_addr = (caddr_t)&sspdma[unit];	tp->t_oproc = ssstart;	tp->t_baudrate = ssbaudrate;	tty_def_open(tp, dev, flag, (sssoftCAR[unit>>2]&(1<<(unit&LINEMASK))));	if ((tp->t_state & TS_ISOPEN) == 0) {		if (unit == MODEM_UNIT)			ssmodem = MODEM_DSR_START;		if((maj == CONSOLE_MAJOR) && ((minor(dev)&3) == 0)) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -