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

📄 sm.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 4 页
字号:
#ifndef lintstatic char *sccsid = "@(#)sm.c	4.1	(ULTRIX)	7/2/90";#endif lint/************************************************************************ *									* *			Copyright (c) 1985-1989 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.	* *									* ************************************************************************//*********************************************************************** * * Modification History: * * 15-Dec-89 -- Alan Frechette *	Changes to "ws_display_type" and "ws_display_units". * * 04-Nov-89 -- Fred Canter *	Remove the waitef spin loop (which syncs cursor loading with the *	vertical end of frame interrupt) via adb hook sm_waitef_on. * * 23-Jul-89 -- Randall Brown *	In the default case of an ioctl() call, check the return value *	from ttioctl() to see if the cmd was invalid.  If it was, return *	an error. * * 24-May-89	darrell *	Changed the #include for cpuconf.h to find it in it's new home -- *	sys/machine/common/cpuconf.h * * 08-May-89 -- rafiey (Ali Rafieymehr) *	When going to physical mode (crash dump) the video could be turned *	off by the server (screen saver). Therefore we turn the video on. * * 08-May-89 -- rafiey (Ali Rafieymehr) *	When going to single user mode, the keys would behave as if the *	<Ctrl> was also pressed. We now clear the flags for shift and *	control in smclose routine. * * 08-May-89 - rafiey (for Fred Canter) *	Fix stray interrupts thru SCB vector 0x1fc caused by polling *	with interrupts enabled while waiting for video EOF and *	sending characters to the keyboard in sm_key_out(). * * 13-Sep-88 - Ali Rafieymehr * *	Fixed a bug which was causing the "select" not to work for *	alternate console. * * 05-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. * * 16-Jul-88 -- fred (Fred Canter) *	Bug fix for cursor loading (replaced original code, only way it works). * *  14-Jul-88 - Vasudev K. Bhandarkar *     *      Removed references to VAX assembler linked-list manipulation *      instructions.  Removed references to the data structures that *      that these instructions manipulated.  Change the millisec *      timestamp to accept TOY.  Remove all timers. * * 13-Jun-88 -- rafiey (Ali Rafieymehr) *	Fixed the tablet problem. Tablet wasn't initialized correctly. * * 07-Jun-88 - Fred Canter *	Temp bug fix for cursor loading. Spin loop in waitef too short. * * 15-Feb-88 - Fred Canter *	Changes for VAX420 (CVAXstar/PVAX) support. * *  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. *	- Addition of LPASS8 to local mode word for 8-bit canonical support. * * 12-Oct-87 - Tim Burke *	Modified driver to provide 8-bit support to the console port.   *	Function keys now set the 9-th bit in the key code. * *  21-Jun-87 - Tim Burke * *      Added full TERMIO functionality to terminal subsystem. *      Changed open routine to setup propper default settings if the line *      is not being used as a graphics device.  Added defines of defaults. * *   1-Aug-87 -- fred (Fred Canter) *	Use TANDEM mode on smsceen for flow control of writes to *	/dev/console. *	Also changed all cprintf to mprintf for consistency with sg.c. * *  18-Jun-87 -- Rafiey (Ali Rafieymehr) *	If X is in kernel then let X load the cursor by using ioctl. If *	X is in the kernel then we won't enable end-of-frame interrupt. *	Also fixed the bug which was causing the cursor to be moved after *	printing console messages. * *  3-Jun-87  -- fred (Fred Canter) *	Fixed a bug in the hold screen code. It was changing the *	TTSTART/TTSTOP bits in tp->t_state on hold screen and *	CTRL/S and CTRL/Q. * * 14-May-87  -- fred (Fred Canter) *	Added QD_KERN_UNLOOP ioctl definition. This is a duplicate of *	QIOKERNUNLOOP, but is needed! * *  14-May-87 -- Fred Canter *	Bug fix to allow xcons to work (loop kernel messages to *	login window), pass sm_tty to ioctl(), not ss_tty. *	Changed default kern_loop state to on. * *  16-Apr-87 -- Fred Canter *	Multi-head GPX changes (yes really). * *  19-Mar-87 -- Fred Canter *	Added X in the kernel support. *	Fixed the TODO in ALi's last changes (13-Dec). * *  13-Dec-86 -- Rafiey (Ali Rafieymehr) *	Don't allow sm to config if sg present. * TODO: not the correct thing to do, but can't fix it *	 until new color hardware arrives -- Fred * *  16-Oct-86 -- fred (Fred Canter) *	Fix structure name collision (sminfo) with system code. *	Changed it to smdinfo (what it should have been originally). * *   4-Sep-86 -- rafiey (Ali Rafieymehr) *	Added hold screen key support for when X is running. * *  30-Aug-86 -- fred (Fred Canter) *	Ali Rafieymehr added smscreen support (console message window). *	Removed smread and smwrite routines. *	Final devioctl support. *	Several bux fixes by Ali. *	Ali added hold screen key support and exclusive open. *	Fixed console putc in physical mode (for crash dump). * *  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. * *  14-Aug-86  rafiey (Ali Rafieymehr) *	Several driver improvements and add tablet support. * *   5-Aug-86  rafiey (Ali Rafieymehr) *	Major changes for real VAXstar bitmap graphics driver. * *   2-Jul-86  rafiey (Ali Rafieymehr) *	Changed SMMAJOR to 49 and removed unused code. * *  18-Jun-86  rafiey (Ali Rafieymehr) *	Created this VAXstar monochrome display driver. *	Derived from qv.c. * **********************************************************************/#include "sm.h"#if NSM > 0  || defined(BINARY)#include "../h/devio.h"#include "../machine/pte.h"#include "../h/param.h"#include "../h/conf.h"#include "../h/dir.h"#include "../h/user.h"#include "../io/uba/smioctl.h"#include "../h/tty.h"#include "../h/map.h"#include "../h/buf.h"#include "../h/vm.h"#include "../h/bk.h"#include "../h/clist.h"#include "../h/file.h"#include "../h/uio.h"#include "../h/kernel.h"#include "../../machine/common/cpuconf.h"#include "../h/exec.h"#include "../h/proc.h"#include "../machine/cpu.h"#include "../machine/mtpr.h"#include "../io/uba/pdma.h"#include "../io/uba/ubareg.h"#include "../io/uba/ubavar.h"/* * Following allow smputc to function in * the CPU in physical mode (during crash dump). * One way transition, can't go back to virtual. */ #define	VS_PHYSNEXUS	0x20080000#define	VS_PHYSBITMAP	0x30000000#define	VS_PHYSCURSOR	0x200c0000int	sm_physmode = 0;/* * Definitions needed to access the VAXstar SLU. * Couldn't include sreg.h (too many compiler errors). */#define	sscsr	nb_sercsr#define	ssrbuf	nb_serrbuf_lpr#define	sslpr	nb_serrbuf_lpr#define	sstcr	nb_sertcr.c[0]#define	sstbuf	nb_sermsr_tdr.c[0]#define	SS_TRDY		0x8000		/* Transmit ready */#define	SS_RDONE	0x80		/* Receiver done		*/#define SS_PE		0x1000		/* Parity error			*/#define SS_FE		0x2000		/* Framing error		*/#define SS_DO		0x4000		/* Data overrun error		*/#define	SINT_ST		0100		/* SLU xmit interrupt bit	*/struct	uba_device *smdinfo[NSM];struct	mouse_report last_rep;extern	struct	mouse_report current_rep;	/* now in ss.c */extern	struct	tty	sm_tty;			/* now in ss.c */extern	struct	tty	ss_tty[];int	nNSM = NSM;int	nsm = NSM*4;/* * Definition of the driver for the auto-configuration program. */int	smprobe(), smattach(), smkint(), smvint();u_short	smstd[] = { 0 };struct	uba_driver smdriver =	{ smprobe, 0, smattach, 0, smstd, "sm", smdinfo };/* * Local variables for the driver. Initialized for 19" screen * so that it can be used during the boot process. *//* * v_consputc is the switch that is used to redirect the console cnputc to the * virtual console vputc. * v_consgetc is the switch that is used to redirect the console getchar to the * virtual console vgetc. */extern (*v_consputc)();extern (*v_consgetc)();#define SMMAXEVQ	64	/* must be power of 2 */#define EVROUND(x)	((x) & (SMMAXEVQ - 1))#define TABLET_RES	2#define	CONSOLEMAJOR	0#define SM_MAJOR        49#define CONS_DEV	0x01#define GRAPHIC_DEV	0x02/* * Screen parameters for the 19 inch monitors. These determine the max size in * pixel and character units for the display and cursor positions. * Notice that the mouse defaults to original square algorithm, but X * will change to its defaults once implemented. */struct sm_info sm_scn_defaults;sminit_scn_def(){	bzero(&sm_scn_defaults,sizeof(struct sm_info));	sm_scn_defaults.max_row = 56;	sm_scn_defaults.max_col = 120;	sm_scn_defaults.max_x = 1024;	sm_scn_defaults.max_y = 864;	sm_scn_defaults.max_cur_x = 1023;	sm_scn_defaults.max_cur_y = 863;	sm_scn_defaults.version = 11;	sm_scn_defaults.mthreshold = 4;		sm_scn_defaults.mscale = 2;	sm_scn_defaults.min_cur_x = -15;	sm_scn_defaults.min_cur_y = -15;}/* * Screen parameters */struct sm_info  *sm_scn; /* why isn't this indexed by minor device #  XXX */	/* * Keyboard state */struct sm_keyboard {	int shift;			/* state variables	*/	int cntrl;	int lock;	int hold;	char last;			/* last character	*/} sm_keyboard;short sm_divdefaults[15] = { LK_DOWN,	/* 0 doesn't exist */	LK_AUTODOWN, LK_AUTODOWN, LK_AUTODOWN, LK_DOWN,	LK_UPDOWN,   LK_UPDOWN,   LK_AUTODOWN, LK_AUTODOWN, 	LK_AUTODOWN, LK_AUTODOWN, LK_AUTODOWN, LK_AUTODOWN, 	LK_DOWN, LK_AUTODOWN };short sm_kbdinitstring[] = {		/* reset any random keyboard stuff */	LK_AR_ENABLE,			/* we want autorepeat by default */	LK_CL_ENABLE,			/* keyclick */	0x84,				/* keyclick volume */	LK_KBD_ENABLE,			/* the keyboard itself */	LK_BELL_ENABLE,			/* keyboard bell */	0x84,				/* bell volume */	LK_LED_DISABLE,			/* keyboard leds */	LED_ALL };#define KBD_INIT_LENGTH	sizeof(sm_kbdinitstring)/sizeof(short)#define TOY ((time.tv_sec * 1000) + (time.tv_usec / 1000))int	sm_events;int	sm_ipl_lo = 1;		/* IPL low flag			*/extern	u_short	sm_pointer_id;	/* id of pointer device (mouse,tablet)-ss.c */int	sm_mouseon = 0;        	/* Mouse is enable when 1 */int	cur_reg = 0;		/* Register to keep track of cursor register bits*/int	monochrome = -1;	/* using VR260 when 0 */u_int	sm_dev_inuse = 0;	/* which minor dev's are in use */u_short	sm_kern_loop;		/* redirect kernel console messages to the  */ 				/* alternate console if -1 */int	open_flag = 0;		/* graphics device is open when 1 */unsigned short sm_cursor[32];	/* the value of current cursor */int	smtime_since_input = 0;	/* number of miliseconds since last input */int	sm_time_limit = 0;struct proc *rsel;			/* process waiting for select */int	smstart(), smputc(), smgetc(), ttrstrt();/* * Keyboard translation and font tables */extern  char *q_special[],q_font[];extern  u_short q_key[],q_shift_key[];extern	struct	nexus	nexus[];/* * Default cursor (plane A and plane B) * */unsigned  short def_cursor[32] = { /* plane A */ 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 	      0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF,/* plane B */ 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF,              0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF	};/* * ULTRIX settings for first open.		   */#define IFLAGS	(EVENP|ECHO|XTABS|CRMOD)/* * Termio flags will be set to these default values in non-termio mode to * provide a backward compatible ULTRIX environment.  */#define IFLAG (BRKINT|IGNPAR|ISTRIP|IXON|IXANY|ICRNL)#define OFLAG (OPOST|TAB3|ONLCR)#define LFLAG (ISIG|ICANON|ECHO)#define CFLAG (PARENB|CREAD|CS7|CLOCAL)/****************************************************************** **                                                              ** ** Routine to see if the graphic device will interrupt.         ** **                                                              ** ******************************************************************//* * These variables identify the type of * graphics device (set in ??cons_init(). */extern	int	ws_display_type;extern	int	ws_display_units;smprobe(reg)	caddr_t reg;{	register struct nb_regs *smaddr = (struct nb_regs *)nexus;/* * Only on a VAXstation 2200 (not MicroVAX 2000). * Also on CVAXstar. * TODO: watchout for MULTU bit meaning change! */	if (((cpu != VAXSTAR) && (cpu != C_VAXSTAR)) ||	    (vs_cfgtst&VS_MULTU) ||	    (vs_cfgtst&VS_VIDOPT))		return(0);/* * Only if monochrome display controller present. */	if ((vs_cfgtst&VS_CURTEST) == 0)		return(0);/* * Only if SM is the graphics device. */	if (ws_display_type && (ws_display_type != SM_DTYPE))		return(0);/* Enable video end-of-frame interrupt */	smaddr->nb_vdc_sel = 0;	smaddr->nb_int_msk |= SINT_VF;	DELAY(20000);  /* wait  *//* Disable video end-of-frame interrupt */	smaddr->nb_int_msk &= ~SINT_VF;	return(8);}/****************************************************************** **                                                              ** ** Routine to attach to the graphic device.                     ** **                                                              ** ******************************************************************/smattach(ui)	struct uba_device *ui;{	register int *pte;	register struct sm_info *qp = sm_scn;	int	 i;/* * init the "latest mouse report" structure */	last_rep.state = 0;	last_rep.dx = 0;	last_rep.dy = 0;	last_rep.bytcnt = 0;	sm_keyboard.hold = 0; /* "Hold Screen" key is pressed if 1 *//* * set the flag not to redirect kernel console messages to the alternate * console. * Changed default to kern_loop on - 5/14/87 -- Fred Canter */	sm_kern_loop = -1;/* * Do the following only for the monochrome display. */	if (monochrome != -1 ) {/* * Map the bitmap for use by users. */	    pte = (int *)(NMEMmap[0]);	    for( i=0 ; i<256 ; i++, pte++ )		*pte = (*pte & ~PG_PROT) | PG_UW | PG_V;/* * Clear out the cursor (this is not cursor ram, this area will be used by * the X system. We do this because we didn't want to change the device * dependent portion of X for the qvss. */	    for (i = 0; i < 32; i++) {	    	qp->cursorbits[i] = 0;		sm_cursor[i] = 0;	    }	}}/****************************************************************** **                                                              ** ** Routine to open the graphic device.                          ** **                                                              ** ******************************************************************/extern struct pdma sspdma[];extern	int ssparam();/*ARGSUSED*/smopen(dev, flag)	dev_t dev;{	register int unit = minor(dev);	register struct tty *tp;	register struct nb_regs *smiaddr = (struct nb_regs *)nexus;	register struct sm_info *qp = sm_scn;/* * The graphics device can be open only by one person  */	if (unit == 1) {	    if (open_flag != 0)		return(EBUSY);	    else		open_flag = 1;            sm_dev_inuse |= GRAPHIC_DEV;  /* graphics dev is open */	} else            sm_dev_inuse |= CONS_DEV;  /* mark console as open */	if ((unit == 2) && (major(dev) == CONSOLEMAJOR))	    tp = &sm_tty;	else	    tp = &ss_tty[unit];	if (tp->t_state&TS_XCLUDE && u.u_uid!=0)	    return (EBUSY);        sm_scn->smaddr = smiaddr;	tp->t_addr = (caddr_t)&sspdma[unit];	tp->t_oproc = smstart;	/*---------------------------------------------------------------------	* Look at the compatibility mode to specify correct default parameters	* and to insure only standard specified functionality. */	if ((u.u_procp->p_progenv == A_SYSV) || 		(u.u_procp->p_progenv == A_POSIX)) {		flag |= O_TERMIO;		tp->t_line = TERMIODISC;	}	/*	 * Set state bit to tell tty.c not to assign this line as the 	 * controlling terminal for the process which opens this line.	 */	if ((flag & O_NOCTTY) && (u.u_procp->p_progenv == A_POSIX))

⌨️ 快捷键说明

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