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

📄 qv.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 3 页
字号:
#ifndef lintstatic char *sccsid = "@(#)qv.c	4.1	(ULTRIX)	7/2/90";#endif lint/************************************************************************ *									* *			Copyright (c) 1985-1988 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.	* *									* ************************************************************************ * * This driver provides glass tty functionality to the qvss. It is a strange * device in that it supports three subchannels. The first being the asr, * the second being a channel that intercepts the chars headed for the screen * ( like a pseudo tty ) and the third being a source of mouse state changes. * * There may be one and only one qvss in the system.  This restriction is based * on the inability to map more than one at a time.  This restriction will * exist until the kernel has shared memory services. This driver therefore * support a single unit. No attempt was made to have it service more. * * 15-Dec-89 -- Alan Frechette *	Changes to "ws_display_type" and "ws_display_units". * * 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 * * 23-May-89 -- darrell *	Removed the v_ prefix from umaddr, make cpup a global variable -- *	as part of the new cpusw. * * 08-May-89 -- rafiey (Ali Rafieymehr) *	When going to physical mode (crash dump) or closing the graphics *	device (server going down), the video could be turned *	off by the server (screen saver). Therefore we turn the video on. * * 08-May-89 - rafiey (Ali Rafieymehr) *	Resetting the  keyboard to default every time we open the device was *	creating double <CR> problem (the user had to type two <CR> instead *	of one). Also 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 qvclose routine. * *  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. * *  20-Jul-88 - Vasudev K. Bhandarkar *      Bug fix.  mouseon should be 0 at initialisation. This allows *      keyboard input to happen the very first time there is a login *      prompt on the graphics console. * *  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. * *  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. * *  2-Aug-87 - fred (Fred Canter) *      Use TANDEM mode on qvscreen for flow control of writes to *      /dev/console. * * 18-Jun-87 - rafiey (Ali Rafieymehr) *      Fixed a bug which was causing the cursor to be moved after printing *      console messages. * * 23-May-87 - Tim Burke * *	Added full TERMIO functionality to terminal subsystem. *	This involved changing the qvopen() routine to provide propper *	default settings on the first open. * * 14-May-87  -- fred (Fred Canter) *	Added QD_KERN_UNLOOP ioctl definition. This is a duplicate of *	QIOKERNUNLOOP, but is needed (currently not used in qv)! * * 16-Apr-87 - fred (Fred Canter) *	Brian Stevens's Multi-head GPX changes (yes really). * * 19-Mar-87 - fred (Fred Canter) *	Changes for X in the kernel support. * * 08-Jan-87 - rafiey (Ali Rafieymehr) * *	Added two new ioctls to turn the video on and off. These two ioctls *	are to be used for save screen. Also corrected a crt parameter for *	VR260. * * 30-Oct-86 - rafiey (Ali Rafieymehr) * *	Fixed a bug (the way "unit" was defined) in "qvioctl" routine. *	Also added "qv_open_flag" lock switch for single process access. * * 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. * * 11-Jul-86 - ricky palmer * *	Added adpt and nexus fields to DEVIOCGET code. * * 20-May-86 - ricky palmer * *	Added new DEVIOCGET ioctl request code. V2.0 * * 16-Apr-86 -- darrell *	badaddr is now called via the macro BADADDR. * * 15-Apr-86 -- afd *	Changed UMEMmap to QMEMmap and umem to qmem. * *	v_console() is now refered to as v_consputc, and there is a *	corresponding v_consgetc() (defined in /sys/vax/conf.c), which *	can point to "qvgetc()". * *	Added "qvgetc()" routine for console read.  Needed to read *	user's answer to the "root device?" prompt with a generic kernel. * * 21-Mar-86 -- pmk *	Changed DELAY to 20000, because microdelay now in real microsec. * * 18-mar-86  -- jaw	 br/cvec changed to NOT use registers. * * * 11 Mar 86 -- darrell *	Changed references to the percpu structure to the cpusw structure *	and only referenced the global cpusw once. * * 18-Mar-86 -- jaw  add routines to cpu switch for nexus/unibus addreses *		     also got rid of some globals like nexnum. *		     ka8800 cleanup. * 02 Aug 85 -- rjl *	Changed the names of the special setup routines so that the system *	can have a qvss or a qdss system console. * * 03 Jul 85 -- rjl *	Added a check for virtual mode in qvputc so that the driver *	doesn't crash while in a dump which is done in physical mode. * * 10 Apr 85 -- jg *	Well, our theory about keyboard handling was wrong; most of the *	keyboard is in autorepeat, down mode.  These changes are to make *	the qvss work the same as the Vs100, which is not necessarily *	completely correct, as some chord usage may fail.  But since we *	can't easily change the Vs100, we might as well propagate the *	problem to another device.  There are also changes for screen and *	mouse accellaration. * * 27 Mar 85 -- rjl *	MicroVAX-II systems have interval timers that interrupt at ipl4. *	Everything else is higher and thus causes us to miss clock ticks. The *	problem isn't severe except in the case of a device like this one that *	generates lots of interrupts. We aren't willing to make this change to *	all device drivers but it seems acceptable in this case. * *  3 Dec 84 -- jg *	To continue the tradition of building a better mouse trap,  this *	driver has been extended to form Vs100 style event queues.  If the *	mouse device is open, the keyboard events are intercepted and put *	into the shared memory queue.  Unfortunately, we are ending up with *	one of the longest Unix device drivers.  Sigh.... * * 20 Nov 84 -- rjl *	As a further complication this driver is required to function as the *	virtual system console. This code runs before and during auto- *	configuration and therefore is require to have a second path for setup. *	It is futher constrained to have a character output routine that *	is not dependant on the interrupt system. * */#include "qv.h"#if NQV > 0  || defined(BINARY)#include "../machine/pte.h"#include "../h/param.h"#include "../h/conf.h"#include "../h/dir.h"#include "../h/user.h"#include "../io/uba/qvioctl.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/devio.h"#include "../h/termio.h"#include "../h/exec.h"#include "../h/proc.h"#include "../machine/cpu.h"#include "../machine/mtpr.h"#include "../io/uba/ubareg.h"#include "../io/uba/ubavar.h"struct	uba_device *qvinfo[NQV];struct	qv_softc {	long	sc_flags;		/* Flags			*/	long	sc_category_flags;	/* Category flags		*/	u_long	sc_softcnt;		/* Soft error count total	*/	u_long	sc_hardcnt;		/* Hard error count total	*/	char	sc_device[DEV_SIZE];	/* Device type string		*/} qv_softc[NQV];struct	tty qv_tty[NQV*4];int	nNQV = NQV;int	nqv = NQV*4;/* * Definition of the driver for the auto-configuration program. */int	qvprobe(), qvattach(), qvkint(), qvvint();u_short qvstd[] = { 0 };struct	uba_driver qvdriver =	{ qvprobe, 0, qvattach, 0, qvstd, "qv", qvinfo };/* * Local variables for the driver. Initialized for 15' screen * so that it can be used during the boot process. */#define QVWAITPRI	(PZERO+1)#define QVSSMAJOR       35#define CONS_DEV        0x01#define GRAPHIC_DEV     0x02/* * 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)();extern struct cpusw *cpup;	/* pointer to cpusw entry *//* * qv_def_scrn is used to select the appropriate tables. 0=15 inch 1=19 inch, * 2 = vr260 19 inch *//* qvss on vr260 default now, vs100 users must use adb to change this to 0 */int qv_def_scrn = 2;	#define QVMAXEVQ	64	/* must be power of 2 */#define EVROUND(x)	((x) & (QVMAXEVQ - 1))/* * Screen parameters 15 & 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 qv_info *qv_scn;struct qv_info qv_scn_defaults[3];qvinit_scn_def(){	bzero(qv_scn_defaults,3*sizeof(struct qv_info));	qv_scn_defaults[0].max_row = 30;	qv_scn_defaults[0].max_col = 80;	qv_scn_defaults[0].max_x = 768;	qv_scn_defaults[0].max_y = 480;	qv_scn_defaults[0].max_cur_x = 768-16;	qv_scn_defaults[0].max_cur_y = 480-16;	qv_scn_defaults[0].mthreshold = 2;		qv_scn_defaults[0].mscale = 4;	qv_scn_defaults[0].min_cur_x = 0;	qv_scn_defaults[0].min_cur_y = 0;	qv_scn_defaults[1].max_row = 55;	qv_scn_defaults[1].max_col = 120;	qv_scn_defaults[1].max_x = 960;	qv_scn_defaults[1].max_y = 864;	qv_scn_defaults[1].max_cur_x = 960-16;	qv_scn_defaults[1].max_cur_y = 864-16;	qv_scn_defaults[1].mthreshold = 2;		qv_scn_defaults[1].mscale = 4;	qv_scn_defaults[1].min_cur_x = 0;	qv_scn_defaults[1].min_cur_y = 0;	qv_scn_defaults[2].max_row = 56;	qv_scn_defaults[2].max_col = 120;	qv_scn_defaults[2].max_x = 1024;	qv_scn_defaults[2].max_y = 864;	qv_scn_defaults[2].max_cur_x = 1024-16;	qv_scn_defaults[2].max_cur_y = 864-16;	qv_scn_defaults[2].mthreshold = 2;		qv_scn_defaults[2].mscale = 4;	qv_scn_defaults[2].min_cur_x = 0;	qv_scn_defaults[2].min_cur_y = 0;}/* * Screen controller initialization parameters. The definations and use * of these parameters can be found in the Motorola 68045 crtc specs. In * essence they set the display parameters for the chip. The first set is * for the 15" screen and the second is for the 19" seperate sync. There * is also a third set for a 19" composite sync monitor which we have not * tested and which is not supported. */static short qv_crt_parms[][16] = {	   { 31, 25, 27, 0142, 31, 13, 30, 31, 4, 15, 040, 0, 0, 0, 0, 0 },/* VR100*/ { 39, 30, 32, 0262, 55, 5, 54, 54, 4, 15, 040, 0, 0, 0, 0, 0 },/* VR260*/ { 39, 32, 33, 0264, 55, 5, 54, 54, 4, 15, 040, 0, 0, 0, 0, 0},};#define QVMOUSECHAN	2/* * Screen parameters */struct qv_info	*qv_scn;int maxqvmem = 254*1024 - sizeof(struct qv_info) - QVMAXEVQ*sizeof(qvEvent);/* * Keyboard state */struct qv_keyboard {	int shift;			/* state variables	*/	int cntrl;	int lock;	int hold;	char last;			/* last character	*/} qv_keyboard;short 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 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(kbdinitstring)/sizeof(short)#define TOY ((time.tv_sec * 1000) + (time.tv_usec / 1000))/* * 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)int	qv_events;int	qv_ipl_lo = 1;			/* IPL low flag 		*/int	mouseon = 0;			/* mouse channel is enabled when 1*/u_int   qv_dev_inuse = 0;               /* which minor dev's are in use */int	qv_open_flag = 0;		/* graphics device is open when not 0 */short	qv_video_off = 0;		/* video off if 0 */struct proc *rsel;			/* process waiting for select */int	qvstart(), qvputc(),  ttrstrt();/* * Keyboard translation and font tables */extern	char *q_special[],q_font[];extern	u_short	q_key[],q_shift_key[];extern	short q_cursor[];/* * See if the qvss will interrupt. */extern	int	*xinfo[];extern	int	ws_display_type;extern	int	ws_display_units;/*ARGSUSED*/qvprobe(reg, ctlr)	caddr_t reg;	int ctlr;{	register struct qvdevice *qvaddr = (struct qvdevice *)reg;	static int tvec, ovec;	/*	 * Only if QV is the graphics device.	 */	if (ws_display_type && (ws_display_type != QVSS_DTYPE))		return(0);	/*	 * Allocate the next two vectors	 */	tvec = 0360;	ovec = cvec;	/*	 * Turn on the keyboard and vertical interrupt vectors.	 */	qvaddr->qv_intcsr = 0;		/* init the interrupt controler */	qvaddr->qv_intcsr = 0x40;	/* reset irr			*/	qvaddr->qv_intcsr = 0x80;	/* specify individual vectors	*/	qvaddr->qv_intcsr = 0xc0;	/* preset autoclear data	*/	qvaddr->qv_intdata = 0xff;	/* all setup as autoclear	*/	qvaddr->qv_intcsr = 0xe0;	/* preset vector address 1	*/	qvaddr->qv_intdata = tvec;	/* give it the keyboard vector	*/	qvaddr->qv_intcsr = 0x28;	/* enable tx/rx interrupt	*/	qvaddr->qv_intcsr = 0xe1;	/* preset vector address 2	*/	qvaddr->qv_intdata = tvec+4;	/* give it the vertical sysnc	*/	qvaddr->qv_intcsr = 0x29;	/* enable			*/	qvaddr->qv_intcsr = 0xa1;	/* arm the interrupt ctrl	*/	qvaddr->qv_uartcmd = 0x15;	/* set mode pntr/enable rx/tx	*/	qvaddr->qv_uartmode = 0x17;	/* noparity, 8-bit		*/	qvaddr->qv_uartmode = 0x07;	/* 1 stop bit			*/	qvaddr->qv_uartstatus = 0x99;	/* 4800 baud xmit/recv		*/	qvaddr->qv_uartintstatus = 2;	/* enable recv interrupts	*/	qvaddr->qv_csr |= QV_INT_ENABLE | QV_CUR_MODE;	DELAY(20000);	qvaddr->qv_csr &= ~QV_INT_ENABLE;	/*	 * If the qvss did interrupt it was the second vector not	 * the first so we have to return the first so that they	 * will be setup properly	 */	if( ovec == cvec ) {		return 0;	} else		cvec = tvec;	/* can't do this until we know we have memory to write in */	qv_scn->qvaddr = qvaddr;	return (sizeof (struct qvdevice));}/* * Routine called to attach a qv. */qvattach(ui)	struct uba_device *ui;{	register struct qvdevice *qvaddr;	register i;	register int *pte;	char *qvssmem;	qvaddr = (struct qvdevice *)ui->ui_addr;	/*	 * If not the console then we have to setup the screen	 */	if( v_consputc != qvputc )		qv_setup( qvaddr );	/*	 * Map the qvss memory for use by users.	 */	qvssmem = (char *)((qvaddr->qv_csr & QV_MEM_BANK) << 7);	pte = (int *)(QMEMmap[0] + btop( qvssmem ));	for( i=0 ; i<512 ; i++, pte++ )		*pte = (*pte & ~PG_PROT) | PG_UW | PG_V;}/*ARGSUSED*/qvopen(dev, flag)	dev_t dev;{	register struct tty *tp;	register int unit, qv;	register struct qvdevice *qvaddr;	register struct uba_device *ui;	register struct qv_info *qp = qv_scn;	unit = minor(dev);	if( ( unit % 4 ) == QVMOUSECHAN ) {		if (qv_open_flag)		    return(EBUSY);		else		    qv_open_flag = 1;  /* mark the device not available */                qv_dev_inuse |= GRAPHIC_DEV;  /* graphics dev is open */        } else                qv_dev_inuse |= CONS_DEV;  /* mark console as open */	qv = unit >> 2;	if (unit >= nqv || (ui = qvinfo[qv])== 0 || ui->ui_alive == 0)		return (ENXIO);	tp = &qv_tty[unit];	if (tp->t_state&TS_XCLUDE && u.u_uid!=0)		return (EBUSY);	qvaddr = (struct qvdevice *)ui->ui_addr;	qv_scn->qvaddr = qvaddr;	tp->t_addr = (caddr_t)qvaddr;	tp->t_oproc = qvstart;	/*	 * 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))		tp->t_state |= TS_ONOCTTY;	if ((tp->t_state&TS_ISOPEN) == 0) {		ttychars(tp);

⌨️ 快捷键说明

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