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

📄 gx.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
#ifndef lintstatic char *sccsid = "@(#)gx.c	4.8      (ULTRIX)  4/4/91";#endif lint/************************************************************************ *									* *			Copyright (c) 1990 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.			* *									* *   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 * * 03-Apr-91	Sam Hsu *	Fix tablet position bug - when cursor pattern changes, position *	changes even though pointer not moved.  Needs related server *	change (pass hotspot coords to driver). * * 06-Mar-91	Sam Hsu *	EdG's "loosing events" fix - move eTail=i into loop checking *	pointer buttons (tablet and mouse).  JoelG's hack for disappearing *	cursor problem with Bt459 (turn on with each motion event). * * 06-Dec-90	Randall Brown *	Reworked how commands are sent to the keyboard so that the ioctl() *	sleeps after it has sent a mode change command until an *	ack has been returned from the keyboard.  * * 16-Jul-90	Randall Brown *	Fixed bug in keyboard interrupt routine that was hardwired to dc device. * *  4-Jul-90	Randall Brown *	Removed all hardwired references to dc device.  Now uses xcons *	driver for alternate console. * *   28-Jun-90 Sam Hsu *	Another OOPS.  Closing dev when saver is on doesn't turn saver off. * *   01-May-90 Sam Hsu *	OOPS.  Fix plane-0 VDAC ID readback for 8-plane (mask off junk). *	Reflect change in planemask also (note difference b/t 2da/low-3da!). *	Do not hold spltty for cursor load *and* readback/reloads.  Release *	spl and reacquire as needed.  Dynamically select fg/bg each time *	colormap reloaded.  Fix \n!\r while server running bug. * *   19-Apr-90 Sam Hsu *	Use GX_CONSOLE debug level for serial line shadow output.  Replace *	HWDEBUG with GX_MULTIOPEN for multiple opens on /dev/mouse. * *   04-Apr-90 Sam Hsu *	Careful not to lower spl if can be callable from elsewhere in kernel. *	KB cmds made atomic.  Pick up tablet fixes from cfb.  Switch cursor *	fg/bg yet again due to fix in RealizeCursor in GX server. *	 *   28-Mar-90 Sam Hsu *	Swap fg/bg of cursor color.  Add gx_check_vdac to read back *	vdac cmd registers & check for corruption.  Screen saver must *	save/restore cmap[].  Load cmap[] with standard black[0]/ *	white[1..255] values. Don't allow colormap loads to vdac while *	screen saver is on.  Check for 8/24-plane low/mid-3D.  Single *	pixel readspans doesn't seem to work too well - change to line. * *   07-Mar-90 Sam Hsu *	VDAC reset now available for both platforms.  Collect checks *	for "am I server?" and "server running?" into macros.  Fix *	blitc() to use _TEXT_{WIDTH|HEIGHT} when drawing.  Add panic *	check to putc().  SLU3_DEV for output to serial line only and *	don't write to graphics console when server is running (check *	return value from getPacket()). * *   26-Feb-90 Sam Hsu *	Maybe I should use opague stipple for the fonts?  Yes. *	Collect more common code (gx_ioctl).  Add fix for vdac *	reset (needs corresponding fix in ga/gq before it can be *	turned on).  Remove a bunch of unnecessary spltty()'s. * *   29-Jan-90 Sam Hsu *	Dynamic debug levels.  Reinstate mouse cursor as console *	text cursor in prep for move to Firefox console font.  Load *	default cursor with text cursor pattern.  Clean up cursor *	load (redundant setaddr's).  Remove init_vdac from init_ *	colormap.  Fix cursor readback to mask off high-byte(s). *	Would be nice if debug level could be turned on by "area" *	selectively, too. * *   25-Jan-90 Sam Hsu *	Change cursor update to blast entire pattern until it comes *	out right, or we give up.  Add some debugging to mouse events. * *   19-Dec-89 Sam Hsu *	Some changes to previous change.  Can't use gxo field, *	since it may be a process virtual address.  Move into *	this file: gx_init_stic(_gx_stic) and use STIC's Stamp *	space to set Stamp configuration blah blah blah... *	Code to figure out how many planes of Z are out there. *	More linkage vectors to allow specific drivers to do some *	action at certain times (eg, open, close, init). * *   11-Dec-89 Paul Jensen *	Support DEVIOCGET ioctl().  Don't wait forever for *	cursor to be loaded correctly. * *   11-Dec-89 Paul Jensen *	Support new Bt459 interface.  Support multiple *	levels of FDEBUG. * *   30-Nov-89 Sam Hsu *	$Header: /nfs/kodak/local/4.0-12/io/tc/RCS/gx.c,v 1.39 90/05/15 17:22:20 fhsu Exp $ *	Created.  Common routines for ga/gq drivers. * *   11-Jul-89 Randall P. Brown *		Changed all the sc->dc_tty to dc_tty. * *    9-Dec-88 Randall P. Brown *		Moved the check for scroll before printing each character * 		instead of after, and changed max_cols to be 80.  This  * 		fixes the problem of the 81st char on a line missing. *		When the keyboard is closed, the flags for shift and control * 		are cleared.  This was to fix the problem of the control *		key being stuck on shutdown. * *    1-Dec-88 Vasudev K. Bhandarkar *		 *	       Let VM determine start of shared memory location. *	       Set start of shared memory location to 0.  Don't need *	       tmpva either (temporary virtual address). * *   23-Nov-88 Randall P. Brown * *		Fixed the flow control on the xconsdev since it is now * 		a different device than the console. * *   17-Nov-88 Randall P. Brown * *		Changed names of all structs and routines to correspond * 		to name changes in dc7085cons.[ch] * *   17-Nov-88 Vasudev K. Bhandarkar *	 *		Massive cleanup.  Now use only one fontmask array. *		Use only one Colormap initialization routine. *		Introduce colorization of cursors, one vdac init *		routine, one restore color cursor routine, etc, etc. * *   10-Oct-88 Larry Palmer *		Fixed how keyboard resets are done. Call back to *		console driver to put characters out (rather than *		having a local routine. Also change where init is *		done to fix panic of no video simm in system. Couple *		of changes from Vasu to scroll correctly on startup. * *   3-Oct-88  Vasudev K. Bhandarkar *	 *		Home the cursor at the bottom of the screen.  So no *	        console messages are lost at boot time.  Do not clear *		the screen at device open and close.  devicenames are *		set to COLOR and MONO for the file command to recognize *	    	the device. * *   1-Oct-88  Ricky Palmer *	        *	        dcsc is now kmalloced.  So we have to have it declared as *		extern.  dcgetc is now recursive.  Change pmgetc to reflect *		this. See dc7085.c for dcgetc.   * *  25-Sep-88  Larry Palmer * *		Rewrite of how Xcons is done. The tty used for xconsdev is *		now the LAST tty structure in the console driver (stored in *		dc_softc). The other way was ugly and caused pmselect to *		reproduce part of the select code. This way the driver just *		uses the device specified (0,4 for pmax) and everything lines *		up. Also removed 'flow control' for xconsdev. There's no way *		this works as xconsdev is not tied to real hardware. * *  22-Sep-88  Vasudev K. Bhandarkar *	        *	       Stronger keyboard initialization to unwedge the keyboard *	       if power-up self-test fails.  Console width is now 81  *	       characters to account for an extra character for LF. *	       pmselect fixed to account for selects done on the xcons(0,4) *	       device. * *  16-Sep-88  Vasudev K. Bhandarkar *	        *	       Bug fix..  For the color device, console error messages *	       were appearing black on black, hence unreadable.  When * 	       X is running, pixels 0 and 1 are chosen as bg and fg for *	       console error messages.  Also initialize the color map *	       at open and close. * *   6-Sep-88  Vasudev K. Bhandarkar *	        *	       Several changes.  All driver routines and data structs *	       are now pm not sm.  A lot of unused globals have been *	       deleted.  Most importantly, a new global has been  *	       introduced.  This variable is now needed because the *	       shared memory is not working as advertised.  The kernel *	       cannot access it.  When this gets fixed, the frame buffer *	       variable can be reset to qp->bitmap. * *  30-Aug-88  Vasudev K. Bhandarkar * *	       Bug fix.  Xmfbpmax/Xcfbpmax now run at first invocation. *	       Deleted spurious local declaration of tcs that conflicted *	       with the global declaration. * *  22-Aug-88  Vasudev K. Bhandarkar * *	       Merge four ioctls into one.  map info, events, tcs and  *	       bitmap with one ioctl.  Assign one more page for the *	       plane mask. *	       *  17-Aug-88  Richard Hyde/Vasudev K. Bhandarkar *	        *	       Color Map initialization and fast scrolling. Ioctls *	       for color map setting. * *  12-Aug-88  Vasudev K. Bhandarkar/Gregory Depp * *	       Implemented ioctls for using shared memory.  discard *             Rich's "ifdef SLIME" code. * *  10-Aug-88  Vasudev K. Bhandarkar * *	       Console Emulation, pm_blitc, pm_putc, pm_scroll * *   4-Aug-88  Vasudev K. Bhandarkar * *	       Cursor Motion is possible.  Test ioctls to make cursor *	       motion possible * *   3-Aug-88  Rich Hyde/Phil Karlton *	        *	       Make mouse pointer visible. *              *   2-Aug-88  Richard Hyde *	 *	       Stopgap shared memory interface.  Until the real system V *	       shared memory gets installed. * *   1-Aug-88  Vasudev K. Bhandarkar *	   *	       Mouse and Keyboard self-test routines. * * 31-July-88  Vasudev K. Bhandarkar * *	       Dummy mouse and keyboard interrupt service called from *	       the serial line driver. * * 29-July-99  Vasudev K. Bhandarkar *              *             Map system space.  Initialize frame buffer through pm_init. *	       Monomap initialization. * * 28-July-99  Vasudev K. Bhandarkar/Richard Hyde *	 *	       Probe, Attach, cons_init.   *  * 19-July-88  Vasudev K. Bhandarkar *  *	       Created.  Based on the qv, qd and sm drivers. * ************************************************************************/#define _GX_C_#include "../data/gx_data.c"static short gx_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 	};static  short gx_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(gx_kbdinitstring)/sizeof(short)static int gx_bt459CR1[] = {    0xc0c0c0,			     /* cmd reg 0 */    0x000000,			     /* cmd reg 1 */    0xc2c2c2,			     /* cmd reg 2 - X-windows cursor */    0xffffff,			     /* pix rd msk */    0x000000,			     /* reserved */    0x000000,			     /* pix blink msk */    0x000000,			     /* reserved */    0x000000,			     /* ovrly rd msk */    0x000000,			     /* ovrly blink msk */    0x000000,			     /* interleave */    0x000000			     /* test */    };#define BT459CR1_SIZE	(sizeof(gx_bt459CR1)/sizeof(int))/* * Indexed by option field of %MODCL STIC register. */static char *devgetstr[] = {		/* as per gringorten */    "3M_2D",    "3M_1?",    "3M_3D",				/* 3DA_LOW */    "3M_3D",				/* 3DA_LOWZ */    "3M_3D",				/* 3DA_MID */    "3M_3D",				/* 3DA_MIDZ */    "3M_6?",    "3M_3D"				/* 3DA_HI */    };/****************************************************************** **                                                              ** ** Routine to open the graphic device.                          ** **                                                              ** ******************************************************************//*ARGSUSED*/gxopen(dev, flag)    dev_t dev;{    register int unit = minor(dev);    register struct tty *tp;    if ((consDev & GRAPHIC_DEV) == 0)	return(ENODEV);    /*     * Only one "server" (debugging code allows multiple open's, but only     * one "server" - identified by O_NDELAY open flag).     *     * nb: when multiple open()s are allowed, the device is reference     *	   counted, so close() only gets called when the last process     *	   dies!     */    if (unit == 1) {#	ifdef GX_MULTIOPEN	if ((flag & O_NDELAY) == 0) {	    register int i = gx_info_get(1);	    if (i < 0) {		return(EBUSY);	     /* no slots left */	    }	    gx_infos[i].pid = u.u_procp->p_pid;	    GX_DEBUG(GX_GAB,		     gx_printf("gxopen: slave pid %d\n", u.u_procp->p_pid);		     );	    GX_CALL(_gx_open)(dev, flag);	    return(0);	}	else#	endif gx_multiopen	{	    if (gx_openflag) {#	        ifdef GX_MULTIOPEN		if (gx_info_gone(gx_server.pid)) {		    gx_init();	     /* didn't get done yet... */		}		else#		endif gx_multiopen		{		    GX_DEBUG(GX_GAB,			     gx_printf("gxopen: server pid %d exists\n",				       gx_server.pid);			     );		    return (EBUSY);		}	    }	    gx_openflag = 1;	    gx_serverp = u.u_procp;	    if (gx_server.pid != gx_serverp->p_pid)		gx_server.shmat = 0;	    gx_server.pid = gx_serverp->p_pid;	    GX_DEBUG(GX_GAB,		     gx_printf("gxopen: server pid %d\n", gx_serverp->p_pid);		     );	}	gx_dev_inuse |= GRAPHIC_DEV; /* graphics dev is open */	gx_init_colormap();	tp = &slu.slu_tty[unit];	ttychars(tp);	tp->t_state = TS_ISOPEN|TS_CARR_ON;	tp->t_cflag = tp->t_cflag_ext = B4800;	tp->t_iflag_ext = 0;	tp->t_oflag_ext = 0;	tp->t_lflag_ext = 0;	gx_mouseon = 1;	/*	 * set up event queue for later	 */	gx_config(gxp);	GX_CALL(_gx_open)(dev, flag);	return(0);    }	    gx_dev_inuse |= CONS_DEV;    /* mark console as open */    /* set tp to the address of the console tty struct */    tp = &cdevsw[0].d_ttys[0];    if (tp->t_state&TS_XCLUDE && u.u_uid!=0)	return (EBUSY);    tp->t_addr = (caddr_t)tp;    tp->t_oproc = gxstart;    /*     * 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;    }#   ifdef O_NOCTTY    /*     * 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;#   endif O_NOCTTY    if ((tp->t_state&TS_ISOPEN) == 0) {	ttychars(tp);	tp->t_state = TS_ISOPEN|TS_CARR_ON;	tp->t_cflag = tp->t_cflag_ext = B4800;	tp->t_iflag_ext = 0;	tp->t_oflag_ext = 0;	tp->t_lflag_ext = 0;	/*	 * Ultrix defaults to a "COOKED" mode on the first	 * open, while termio defaults to a "RAW" style.	 * Base this decision by a flag set in the termio	 * emulation routine for open, or set by an explicit	 * ioctl call. 	 */	if ( flag & O_TERMIO ) {	    /*	     * Provide a termio style environment.	     * "RAW" style by default. 	     */	    tp->t_flags = RAW;   	    tp->t_iflag = 0;	    tp->t_oflag = 0;	    tp->t_cflag |= CS8|CREAD|HUPCL; 	    tp->t_lflag = 0;	    	    /*	     * Change to System V line discipline.	     */	    tp->t_line = TERMIODISC;	    	    /*	     * The following three control chars have 	     * different default values than ULTRIX.		     */	    tp->t_cc[VERASE] = '#';	    tp->t_cc[VKILL] = '@';	    tp->t_cc[VINTR] = 0177;	    tp->t_cc[VMIN] = 6;	    tp->t_cc[VTIME] = 1;	    	} else {	    /*	     * Provide a backward compatible ULTRIX 	     * environment.  "COOKED" style.		     */	    tp->t_flags = IFLAGS;	    tp->t_iflag = IFLAG;	    tp->t_oflag = OFLAG;	    tp->t_lflag = LFLAG;	    tp->t_cflag |= CFLAG;	}    }    /*     * Process line discipline specific open.

⌨️ 快捷键说明

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