X11R4 patch for SCO XENIX (part03)

Chain Lee chain at paul.rutgers.edu
Mon Jan 7 13:23:09 AEST 1991


*** X11R4.ORIG/mit/server/ddx/xenix/vga/xenixTty.c	Sun Jan  6 01:03:10 1991
--- X11R4/mit/server/ddx/xenix/vga/xenixTty.c	Thu Dec 13 20:50:49 1990
***************
*** 0 ****
--- 1,41 ----
+ /*
+  * xenixTty.c
+  */
+ 
+ #include <sys/types.h>
+ #include <sys/vtkd.h>
+ #include <sgtty.h>
+ 
+ int
+ set_tty(file)
+ int	file;
+ {
+     set_mode(file,RAW,ECHO,0);
+     ioctl(file, KDSKBMODE, K_RAW);
+ }
+ 
+ int
+ reset_tty(file)
+ int	file;
+ {
+     ioctl(file, KDSKBMODE, K_XLATE);
+     set_mode(file,ECHO,RAW,0);
+ }
+ 
+ static int
+ set_mode(file,on,off,speed)
+ int	file;
+ int	on;
+ int	off;
+ {
+     struct sgttyb buff;
+ 
+     gtty(file,&buff);
+     buff.sg_flags |= on;
+     buff.sg_flags &= ~off;
+     if (speed)
+ 	buff.sg_ispeed = buff.sg_ospeed = speed;
+     stty(file,&buff);
+     return(0);
+ }
+ 
*** X11R4.ORIG/mit/server/ddx/xenix/vga/xenixInit.c	Sun Jan  6 01:03:12 1991
--- X11R4/mit/server/ddx/xenix/vga/xenixInit.c	Sun Dec  9 18:54:39 1990
***************
*** 0 ****
--- 1,425 ----
+ /*
+  * xenixInit.c			Modified for Xenix by Chain Lee 08/90
+  */
+ 
+ /*-
+  *
+  * Copyright (c) 1987 by the Regents of the University of California
+  *
+  * Permission to use, copy, modify, and distribute this
+  * software and its documentation for any purpose and without
+  * fee is hereby granted, provided that the above copyright
+  * notice appear in all copies.  The University of California
+  * makes no representations about the suitability of this
+  * software for any purpose.  It is provided "as is" without
+  * express or implied warranty.
+  *
+  *
+  */
+ 
+ /************************************************************
+ Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+ 
+                     All Rights Reserved
+ 
+ Permission  to  use,  copy,  modify,  and  distribute   this
+ software  and  its documentation for any purpose and without
+ fee is hereby granted, provided that the above copyright no-
+ tice  appear  in all copies and that both that copyright no-
+ tice and this permission notice appear in  supporting  docu-
+ mentation,  and  that the names of Sun or MIT not be used in
+ advertising or publicity pertaining to distribution  of  the
+ software  without specific prior written permission. Sun and
+ M.I.T. make no representations about the suitability of this
+ software for any purpose. It is provided "as is" without any
+ express or implied warranty.
+ 
+ SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+ INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+ NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+ PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+ THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ 
+ ********************************************************/
+ 
+ #include    "xenix.h"
+ #include    <servermd.h>
+ #include    "dixstruct.h"
+ #include    "dix.h"
+ #include    "opaque.h"
+ #include    "mipointer.h"
+ 
+ extern int xenixMouseProc(), xenixKbdProc();
+ extern Bool xenixVGAProbe(), xenixVGACreate();
+ 
+ extern void ProcessInputEvents();
+ extern void SetInputCheck();
+ 
+ extern char *strncpy();
+ extern GCPtr CreateScratchGC();
+ 
+ #define	XDEVICE	"XDEVICE"
+ 
+ int xenixEventPending = 0;	 /* For use with SetInputCheck */
+ static int autoRepeatHandlersInstalled;	/* FALSE each time InitOutput called */
+ 
+ static Bool xenixDevsProbed = FALSE;
+ Bool xenixSupportsDepth8 = FALSE;
+ unsigned long xenixGeneration = 0;
+ 
+ extern int xenixCheckEvent();
+ 
+ static void
+ xenixBlock(blockData, pptv, pReadmask)
+ int	*blockData;
+ int	*pptv;
+ int	*pReadmask;
+ {
+ 	if (xenixCheckEvent())
+ 		xenixEventPending = 1;
+ }
+ static void
+ xenixWakeup(blockData, pptv, pReadmask)
+ int	*blockData;
+ int	*pptv;
+ int	*pReadmask;
+ {
+ 	/* nothing */
+ }
+ 
+ xenixFbDataRec xenixFbData[] = {
+     xenixVGAProbe,  	"/dev/vga",	    xenixVGACreate,
+     xenixVGAProbe,  	"/dev/vga",	    xenixVGACreate,
+ };
+ 
+ #define NUMSCREENS (sizeof(xenixFbData)/sizeof(xenixFbData[0]))
+ #define NUMDEVICES  2
+ 
+ fbFd xenixFbs[NUMDEVICES];
+ 
+ static PixmapFormatRec	formats[] = {
+     1, 1, BITMAP_SCANLINE_PAD,	/* 1-bit deep */
+     8, 8, BITMAP_SCANLINE_PAD,	/* 8-bit deep */
+ };
+ #define NUMFORMATS	(sizeof formats)/(sizeof formats[0])
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * InitOutput --
+  *	Initialize screenInfo for all actually accessible framebuffers.
+  *	The
+  *
+  * Results:
+  *	screenInfo init proc field set
+  *
+  * Side Effects:
+  *	None
+  *
+  *-----------------------------------------------------------------------
+  */
+ 
+ InitOutput(pScreenInfo, argc, argv)
+     ScreenInfo 	  *pScreenInfo;
+     int     	  argc;
+     char    	  **argv;
+ {
+     int     	  i, n, dev;
+     int		  nonBlockConsole = 1;
+     static int	  setup_on_exit = 0;
+     int		  devStart = 1;
+ 
+     if (!monitorResolution)
+ 	monitorResolution = 90;
+     for (i = 1; i < argc; i++) {
+ 	if (!strcmp(argv[i],"-debug"))
+ 	    nonBlockConsole = 0;
+ 	else if (!strcmp(argv[i],"-mono"))
+ 	    devStart = 0;
+     }
+ 
+     pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+     pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+     pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+     pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+ 
+     pScreenInfo->numPixmapFormats = NUMFORMATS;
+     for (i=0; i< NUMFORMATS; i++)
+         pScreenInfo->formats[i] = formats[i];
+ 
+     autoRepeatHandlersInstalled = FALSE;
+ 
+     if (!xenixDevsProbed)
+     {
+ 	n = 0;
+ 	for (i = NUMSCREENS, dev = devStart; --i > 0; dev++) {
+ 	    if ((*xenixFbData[dev].probeProc)(pScreenInfo, n, dev, argc, argv))
+ 		n++;
+ 	    else
+ 		xenixFbData[dev].createProc = (Bool(*)()) NULL;
+ 	}
+         xenixDevsProbed = TRUE;
+ 	if (n == 0)
+ 	    return;
+     }
+     if (!xenixSupportsDepth8)
+ 	pScreenInfo->numPixmapFormats--;
+     for (i = NUMSCREENS, dev = devStart; --i > 0; dev++) {
+ 	if (xenixFbData[dev].createProc)
+ 	    (*xenixFbData[dev].createProc)(pScreenInfo, argc, argv);
+     }
+     xenixGeneration = serverGeneration;
+     xenixInitCursor();
+ }
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * InitInput --
+  *	Initialize all supported input devices...what else is there
+  *	besides pointer and keyboard?
+  *
+  * Results:
+  *	None.
+  *
+  * Side Effects:
+  *	Two DeviceRec's are allocated and registered as the system pointer
+  *	and keyboard devices.
+  *
+  *-----------------------------------------------------------------------
+  */
+ /*ARGSUSED*/
+ InitInput(argc, argv)
+     int     	  argc;
+     char    	  **argv;
+ {
+     DevicePtr p, k;
+     static int  zero = 0;
+     
+     p = AddInputDevice(xenixMouseProc, TRUE);
+     k = AddInputDevice(xenixKbdProc, TRUE);
+     if (!p || !k)
+ 	FatalError("failed to create input devices in InitInput");
+ 
+     RegisterPointerDevice(p);
+     RegisterKeyboardDevice(k);
+     miRegisterPointerDevice(screenInfo.screens[0], p);
+ 
+     if (RegisterBlockAndWakeupHandlers(xenixBlock, xenixWakeup, 0) == FALSE)
+     	ErrorF("InitInput: RegisterBlockAndWakeupHandlers() failed\n");
+ 
+     SetInputCheck (&zero, &xenixEventPending);
+ }
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixScreenInit --
+  *	Things which must be done for all types of frame buffers...
+  *	Should be called last of all.
+  *
+  * Results:
+  *	TRUE if successful, else FALSE
+  *
+  * Side Effects:
+  *	Both a BlockHandler and a WakeupHandler are installed for the
+  *	first screen.  Together, these handlers implement autorepeat
+  *	keystrokes on the Xenix.
+  *
+  *-----------------------------------------------------------------------
+  */
+ Bool
+ xenixScreenInit (pScreen)
+     ScreenPtr	  pScreen;
+ {
+     extern void   xenixBlockHandler();
+     extern void   xenixWakeupHandler();
+     static ScreenPtr autoRepeatScreen;
+ 
+     extern miPointerCursorFuncRec   xenixPointerCursorFuncs;
+ 
+     /*
+      *	Block/Unblock handlers
+      */
+ 
+     if (autoRepeatHandlersInstalled == FALSE) {
+ 	autoRepeatScreen = pScreen;
+ 	autoRepeatHandlersInstalled = TRUE;
+     }
+ 
+     if (pScreen == autoRepeatScreen) {
+         pScreen->BlockHandler = xenixBlockHandler;
+         pScreen->WakeupHandler = xenixWakeupHandler;
+     }
+ 
+     miDCInitialize (pScreen, &xenixPointerCursorFuncs);
+ 
+     return TRUE;
+ }
+ 
+ 
+ extern char *getenv();
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * nthdev --
+  *	Return the nth device in a colon-separated list of devices.
+  *	n is 0-origin.
+  *
+  * Results:
+  *	A pointer to a STATIC string which is the device name.
+  *
+  * Side Effects:
+  *	None.
+  *
+  *-----------------------------------------------------------------------
+  */
+ static char *
+ nthdev (dList, n)
+     register char    *dList;	    /* Colon-separated device names */
+     int	    n;	  	    /* Device number wanted */
+ {
+     char *result;
+     static char returnstring[100];
+ 
+     while (n--) {
+ 	while (*dList && *dList != ':') {
+ 	    dList++;
+ 	}
+     }
+     if (*dList) {
+ 	register char *cp = dList;
+ 
+ 	while (*cp && *cp != ':') {
+ 	    cp++;
+ 	}
+ 	result = returnstring;
+ 	strncpy (result, dList, cp - dList);
+ 	result[cp - dList] = '\0';
+     } else {
+ 	result = (char *)0;
+     }
+     return (result);
+ }
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixOpenFrameBuffer --
+  *	Open a frame buffer according to several rules. If running under
+  *	overview and we're set up for it, use the device given in the
+  *	PARENT envariable and note that the screen is under overview.
+  *	Else find the device to use by looking in the xenixFbData table,
+  *	an XDEVICE envariable, a -dev switch or using /dev/fb if trying
+  *	to open screen 0 and all else has failed.
+  *
+  * Results:
+  *	The fd of the framebuffer.
+  *
+  * Side Effects:
+  *
+  *-----------------------------------------------------------------------
+  */
+ int
+ xenixOpenFrameBuffer(expect, index, fbNum, argc, argv)
+     int	    	  expect;   	/* The expected type of framebuffer */
+     int	    	  fbNum;    	/* Index into the xenixFbData array */
+     int	    	  index;    	/* Screen index */
+     int	    	  argc;	    	/* Command-line arguments... */
+     char	  **argv;   	/* ... */
+ {
+     char       	  *name=(char *)0;
+     int           i;	    	/* Index into argument list */
+     int           fd = -1;	    	/* Descriptor to device */
+     static int	  devFbUsed=FALSE;  /* true if /dev/fb has been used for a */
+     	    	  	    	    /* screen already */
+     static Bool	  inited = FALSE;
+     static char	  *xdevice; 	/* string of devices to use from environ */
+     static char	  *devsw;   	/* string of devices from args */
+     int		  type;
+ 
+     if (!inited) {
+ 	xdevice = devsw = (char *)NULL;
+ 
+ 	xdevice = getenv (XDEVICE);
+ 	/*
+ 	 * Look for an argument of the form -dev <device-string>
+ 	 * If such a one is found place the <device-string> in devsw.
+ 	 */
+ 	for (i = 1; i < argc; i++) {
+ 	    if ((strcmp(argv[i], "-dev") == 0) && (i + 1 < argc)) {
+ 		devsw = argv[i+1];
+ 		break;
+ 	    }
+ 	}
+ 	inited = TRUE;
+     }
+ 
+     /*
+      * Attempt to find a file name for the frame buffer 
+      */
+ 
+     /*
+      * First see if any device was given on the command line.
+      * If one was and the device is both readable and writeable,
+      * set 'name' to it, else set it to NULL.
+      */
+     if (devsw == (char *)NULL ||
+ 	(name = nthdev (devsw, index)) == (char *)NULL ||
+ 	(access (name, R_OK | W_OK) != 0) ||
+ 	(strcmp(name, xenixFbData[fbNum].devName) != 0)) {
+ 	    name = (char *)NULL;
+     }
+ 	    
+     /*
+      * If we still don't have a device for this screen, check the
+      * environment variable for one. If one was given, stick its
+      * path in name and check its accessibility. If it's not
+      * properly accessible, then reset the name to NULL to force the
+      * checking of the xenixFbData array.
+      */
+     if (devsw == (char *)NULL && name == (char *)NULL &&
+ 	xdevice != (char *)NULL &&
+ 	(name = nthdev(xdevice, index)) != (char *)NULL &&
+ 	(access (name, R_OK | W_OK) != 0)) {
+ 	    name = (char *)NULL;
+     }
+ 
+     /*
+      * Take the device given in the frame buffer description
+      * and see if it exists and is accessible. If it does/is,
+      * we will use it, as long as no other device was given.
+      */
+     if (devsw == (char *)NULL && name == (char *)NULL &&
+ 	access(xenixFbData[fbNum].devName, (R_OK | W_OK)) == 0) {
+ 	    name = xenixFbData[fbNum].devName;
+     }
+ 
+     /*
+      * If we still have nothing and have yet to use "/dev/vga" for
+      * a screen, default the name to be "/dev/vga"
+      */
+     if (devsw == (char *)NULL && name == (char *)NULL && !devFbUsed) {
+ 	name = "/dev/vga";
+     }
+ 
+     if (name) {
+ 	fd = open(name, O_RDWR, 0);
+         if (fd < 0) {
+ 	    return (-1);
+ 	} 
+ 	/* init screen here */
+     }
+ 
+     if (name && strcmp (name, "/dev/vga") == 0) {
+ 	devFbUsed = TRUE;
+     }
+ 
+     return (fd);
+ }
+ 
+ /*****************************************************************************/
+ 
+ void
+ xenixInitCursor()
+ {
+ }
*** X11R4.ORIG/mit/server/ddx/xenix/vga/xenix.h	Sun Jan  6 01:03:15 1991
--- X11R4/mit/server/ddx/xenix/vga/xenix.h	Mon Dec 10 00:32:22 1990
***************
*** 0 ****
--- 1,241 ----
+ /*
+  * xenix.h			Modified for Xenix by Chain Lee 08/90
+  */
+ 
+ /*-
+  * sun.h --
+  *	Internal declarations for the sun ddx interface
+  *
+  * Copyright (c) 1987 by the Regents of the University of California
+  *
+  * Permission to use, copy, modify, and distribute this
+  * software and its documentation for any purpose and without
+  * fee is hereby granted, provided that the above copyright
+  * notice appear in all copies.  The University of California
+  * makes no representations about the suitability of this
+  * software for any purpose.  It is provided "as is" without
+  * express or implied warranty.
+  *
+  *	"$XConsortium: sun.h,v 5.7 89/12/06 09:37:35 rws Exp $ SPRITE (Berkeley)"
+  */
+ 
+ #ifndef _XENIX_H_
+ #define _XENIX_H_
+ 
+ #include    <errno.h>
+ extern int  errno;
+ #include    <sys/param.h>
+ #include    <sys/types.h>
+ #include    <sys/select.h>
+ #include    <sys/file.h>
+ #include    <sys/fcntl.h>
+ #include    <sys/signal.h>
+ #include    <unistd.h>
+ 
+ #include    <sys/termio.h>
+ #include    <sys/machdep.h>
+ #include    <sys/sysmacros.h>
+ 
+ #define	    PGSIZE	ctob(1)
+ 
+ #include    <sys/event.h>
+ #include    <mouse.h>
+ #include    <sys/vtkd.h>
+ 
+ #include    "xenixDevInfo.h"
+ 
+ #include    "X.h"
+ #include    "Xproto.h"
+ #include    "scrnintstr.h"
+ #include    "screenint.h"
+ #ifdef NEED_EVENTS
+ #include    "inputstr.h"
+ #endif NEED_EVENTS
+ #include    "input.h"
+ #include    "cursorstr.h"
+ #include    "cursor.h"
+ #include    "pixmapstr.h"
+ #include    "pixmap.h"
+ #include    "windowstr.h"
+ #include    "gc.h"
+ #include    "gcstruct.h"
+ #include    "regionstr.h"
+ #include    "colormap.h"
+ #include    "miscstruct.h"
+ #include    "dix.h"
+ #include    "mfb.h"
+ #include    "mi.h"
+ 
+ /*
+  * MAXEVENTS is the maximum number of events the mouse and keyboard functions
+  * will read on a given call to their GetEvents vectors.
+  */
+ #define MAXEVENTS 	32
+ 
+ KeybdCtrl	  *ctrl;    	    	/* Current control structure (for
+  					 * keyclick, bell duration, auto-
+  					 * repeat, etc.) */
+ 
+ typedef	struct kbPrivate {
+     int		  type;			/* Type	of keyboard */
+     void	  (*ProcessEvent)();	/* Function to process an event	*/
+     void	  (*DoneEvents)();	/* Function called when	all events */
+ 					/* have	been handled. */
+     pointer	  devPrivate;		/* Private to keyboard device */
+     int		  offset;		/* to be added to device keycodes */
+     KeybdCtrl	  *ctrl;		/* Current control structure (for
+ 					 * keyclick, bell duration, auto-
+ 					 * repeat, etc.) */
+ } KbPrivRec, *KbPrivPtr;
+ 
+ #define	MIN_KEYCODE	8	/* necessary to avoid the mouse buttons */
+ 
+ typedef	struct ptrPrivate {
+     void	  (*ProcessEvent)();	/* Function to process an event	*/
+     void	  (*DoneEvents)();	/* When	all the	events have been */
+ 					/* handled, this function will be */
+ 					/* called. */
+     short	  x,			/* Current X coordinate	of pointer */
+ 		  y;			/* Current Y coordinate	*/
+     pointer	  devPrivate;		/* Field private to device */
+ } PtrPrivRec, *PtrPrivPtr;
+ 
+ 
+ /*
+  * Cursor-private data
+  *	screenBits	saves the contents of the screen before the cursor
+  *	    	  	was placed in the frame buffer.
+  *	source	  	a bitmap for placing the foreground pixels down
+  *	srcGC	  	a GC for placing the foreground pixels down.
+  *	    	  	Prevalidated for the cursor's screen.
+  *	invSource 	a bitmap for placing the background pixels down.
+  *	invSrcGC  	a GC for placing the background pixels down.
+  *	    	  	Also prevalidated for the cursor's screen Pixmap.
+  *	temp	  	a temporary pixmap for low-flicker cursor motion --
+  *	    	  	exists to avoid the overhead of creating a pixmap
+  *	    	  	whenever the cursor must be moved.
+  *	fg, bg	  	foreground and background pixels. For a color display,
+  *	    	  	these are allocated once and the rgb values changed
+  *	    	  	when the cursor is recolored.
+  *	scrX, scrY	the coordinate on the screen of the upper-left corner
+  *	    	  	of screenBits.
+  *	state	  	one of CR_IN, CR_OUT and CR_XING to track whether the
+  *	    	  	cursor is in or out of the frame buffer or is in the
+  *	    	  	process of going from one state to the other.
+  */
+ typedef enum {
+     CR_IN,		/* Cursor in frame buffer */
+     CR_OUT,		/* Cursor out of frame buffer */
+     CR_XING	  	/* Cursor in flux */
+ } CrState;
+ 
+ typedef struct crPrivate {
+     PixmapPtr  	        screenBits; /* Screen before cursor put down */
+     PixmapPtr  	        source;     /* Cursor source (foreground bits) */
+     GCPtr   	  	srcGC;	    /* Foreground GC */
+     PixmapPtr  	        invSource;  /* Cursor source inverted (background) */
+     GCPtr   	  	invSrcGC;   /* Background GC */
+     PixmapPtr  	        temp;	    /* Temporary pixmap for merging screenBits
+ 				     * and the sources. Saves creation time */
+     Pixel   	  	fg; 	    /* Foreground color */
+     Pixel   	  	bg; 	    /* Background color */
+     int	    	  	scrX,	    /* Screen X coordinate of screenBits */
+ 			scrY;	    /* Screen Y coordinate of screenBits */
+     CrState		state;      /* Current state of the cursor */
+ } CrPrivRec, *CrPrivPtr;
+ 
+ /*
+  * Frame-buffer-private info.
+  *	fd  	  	file opened to the frame buffer device.
+  *	info	  	description of the frame buffer -- type, height, depth,
+  *	    	  	width, etc.
+  *	fb  	  	pointer to the mapped image of the frame buffer. Used
+  *	    	  	by the driving routines for the specific frame buffer
+  *	    	  	type.
+  *	mapped	  	flag set true by the driver when the frame buffer has
+  *	    	  	been mapped in.
+  *	parent	  	set true if the frame buffer is actually a SunWindows
+  *	    	  	window.
+  *	fbPriv	  	Data private to the frame buffer type.
+  */
+ typedef struct {
+     pointer 	  	fb; 	    /* Frame buffer itself */
+     Bool    	  	mapped;	    /* TRUE if frame buffer already mapped */
+     int	    	  	fd; 	    /* Descriptor open to frame buffer */
+     int			fb_width;
+     int			fb_height;
+     int			fb_size;
+     void		(*EnterLeave)();    /* screen switch */
+     pointer 	  	fbPriv;	    /* Frame-buffer-dependent data */
+ } fbFd;
+ 
+ extern Bool xenixSupportsDepth8;
+ extern unsigned long xenixGeneration;
+ 
+ typedef struct _xenixFbDataRec {
+     Bool    (*probeProc)();	/* probe procedure for this fb */
+     char    *devName;		/* device filename */
+     Bool    (*createProc)();	/* create procedure for this fb */
+ } xenixFbDataRec;
+ 
+ extern xenixFbDataRec xenixFbData[];
+ /*
+  * Cursor functions
+  */
+ extern void 	  xenixInitCursor();
+ 
+ /*
+  * Initialization
+  */
+ extern Bool 	  xenixScreenInit();
+ extern int  	  xenixOpenFrameBuffer();
+ 
+ extern fbFd 	  xenixFbs[];
+ 
+ extern int  	  lastEventTime;    /* Time (in ms.) of last event */
+ extern void 	  SetTimeSinceLastInputEvent();
+ 
+ extern int monitorResolution;
+ 
+ #define AUTOREPEAT_INITIATE	(200)		/* milliseconds */
+ #define AUTOREPEAT_DELAY	(50)		/* milliseconds */
+ /*
+  * We signal autorepeat events with the unique Firm_event
+  * id AUTOREPEAT_EVENTID.
+  * Because inputevent ie_code is set to Firm_event ids in
+  * sunKbdProcessEventSunWin, and ie_code is short whereas
+  * Firm_event id is u_short, we use 0x7fff.
+  */
+ #define AUTOREPEAT_EVENTID      (0x7fff)        /* AutoRepeat Firm_event id */
+ 
+ extern int	autoRepeatKeyDown;		/* TRUE if key down */
+ extern int	autoRepeatReady;		/* TRUE if time out */
+ extern int	autoRepeatDebug;		/* TRUE if debugging */
+ extern long	autoRepeatInitiate;
+ extern long 	autoRepeatDelay;
+ extern struct timeval autoRepeatLastKeyDownTv;
+ extern struct timeval autoRepeatDeltaTv;
+ 
+ #define tvminus(tv, tv1, tv2)	/* tv = tv1 - tv2 */ \
+ 		if ((tv1).tv_usec < (tv2).tv_usec) { \
+ 			(tv1).tv_usec += 1000000; \
+ 			(tv1).tv_sec -= 1; \
+ 		} \
+ 		(tv).tv_usec = (tv1).tv_usec - (tv2).tv_usec; \
+ 		(tv).tv_sec = (tv1).tv_sec - (tv2).tv_sec;
+ 
+ #define tvplus(tv, tv1, tv2)	/* tv = tv1 + tv2 */ \
+ 		(tv).tv_sec = (tv1).tv_sec + (tv2).tv_sec; \
+ 		(tv).tv_usec = (tv1).tv_usec + (tv2).tv_usec; \
+ 		if ((tv).tv_usec > 1000000) { \
+ 			(tv).tv_usec -= 1000000; \
+ 			(tv).tv_sec += 1; \
+ 		}
+ 
+ /*-
+  * TVTOMILLI(tv)
+  *	Given a struct timeval, convert its time into milliseconds...
+  */
+ #define TVTOMILLI(tv)	(((tv).tv_usec/1000)+((tv).tv_sec*1000))
+ 
+ #endif _XENIX_H_
*** X11R4.ORIG/mit/server/ddx/xenix/vga/xenixDevInfo.h	Sun Jan  6 01:03:18 1991
--- X11R4/mit/server/ddx/xenix/vga/xenixDevInfo.h	Sun Dec  9 18:49:07 1990
***************
*** 0 ****
--- 1,34 ----
+ /*
+  * devinfo.h					By Chain Lee 08/90
+  */
+ 
+ #define	FBTYPE_HERCULES		1		/* 720 x 348 */
+ #define	FBTYPE_CGA		2		/* 640 x 200 */
+ #define	FBTYPE_EGA		3		/* 640 x 350 */
+ #define	FBTYPE_VGA		4		/* 640 x 480 */
+ #define	FBTYPE_VGA1		4		/* 640 x 480 */
+ #define	FBTYPE_VGA2		5		/* 800 x 600 */
+ #define	FBTYPE_VGA3		6		/* 1024 x 600 */
+ #define	FBTYPE_VGA4		7		/* 1204 x 768 */
+ #define	FBTYPE_VGA5		8		/* 640 x 480 color */
+ 
+ #define	HERCULES_FBWIDTH	720
+ #define	HERCULES_FBHEIGHT	348
+ #define	HERCULES_FBSIZE		(1024 * 32)
+ 
+ #define	VGA1_FBWIDTH		640
+ #define	VGA1_FBHEIGHT		480
+ #define	VGA1_FBSIZE		((640 * 480) >> 3)
+ 
+ #define	VGA2_FBWIDTH		800
+ #define	VGA2_FBHEIGHT		600
+ #define	VGA2_FBSIZE		((800 * 600) >> 3)
+ 
+ #define	VGA3_FBWIDTH		1024
+ #define	VGA3_FBHEIGHT		600
+ #define	VGA3_FBSIZE		((1024 * 600) >> 3)
+ 
+ /****************************************************************************/
+ 
+ #define	KBTYPE_IBMAT		2
+ 
*** X11R4.ORIG/mit/server/ddx/xenix/vga/xenixVGA.c	Sun Jan  6 01:03:20 1991
--- X11R4/mit/server/ddx/xenix/vga/xenixVGA.c	Sun Jan  6 00:17:16 1991
***************
*** 0 ****
--- 1,289 ----
+ /*
+  * xenixVGA.c			Modified for Xenix by Chain Lee 08/90
+  */
+ 
+ /*-
+  *
+  * Copyright (c) 1987 by the Regents of the University of California
+  * Copyright (c) 1987 by Adam de Boor, UC Berkeley
+  *
+  * Permission to use, copy, modify, and distribute this
+  * software and its documentation for any purpose and without
+  * fee is hereby granted, provided that the above copyright
+  * notice appear in all copies.  The University of California
+  * makes no representations about the suitability of this
+  * software for any purpose.  It is provided "as is" without
+  * express or implied warranty.
+  *
+  *
+  */
+ 
+ /************************************************************
+ Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+ 
+                     All Rights Reserved
+ 
+ Permission  to  use,  copy,  modify,  and  distribute   this
+ software  and  its documentation for any purpose and without
+ fee is hereby granted, provided that the above copyright no-
+ tice  appear  in all copies and that both that copyright no-
+ tice and this permission notice appear in  supporting  docu-
+ mentation,  and  that the names of Sun or MIT not be used in
+ advertising or publicity pertaining to distribution  of  the
+ software  without specific prior written permission. Sun and
+ M.I.T. make no representations about the suitability of this
+ software for any purpose. It is provided "as is" without any
+ express or implied warranty.
+ 
+ SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+ INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+ NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+ PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+ THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ 
+ ********************************************************/
+ 
+ #include    "xenix.h"
+ #include    "resource.h"
+ 
+ typedef struct vga {
+     uchar_t	image[VGA1_FBSIZE];          /* Pixel buffer */
+ } VGARec, *VGAPtr;
+ 
+ static int  xenixVGAScreenIndex;
+ static	int	xenixVGAFd;
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixVGASaveScreen --
+  *	Disable the video on the frame buffer to save the screen.
+  *
+  * Results:
+  *	None.
+  *
+  * Side Effects:
+  *	Video enable state changes.
+  *
+  *-----------------------------------------------------------------------
+  */
+ static Bool
+ xenixVGASaveScreen (pScreen, on)
+     ScreenPtr	  pScreen;
+     Bool    	  on;
+ {
+     int         state = on;
+ /*
+     if (on != SCREEN_SAVER_ON) {
+ 	SetTimeSinceLastInputEvent();
+ 	state = FBVIDEO_ON;
+     } else {
+ 	state = FBVIDEO_OFF;
+     }
+ */
+     /* */
+     return TRUE;
+ }
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixVGACloseScreen --
+  *	called to ensure video is enabled when server exits.
+  *
+  * Results:
+  *	Screen is unsaved.
+  *
+  * Side Effects:
+  *	None
+  *
+  *-----------------------------------------------------------------------
+  */
+ /*ARGSUSED*/
+ static Bool
+ xenixVGACloseScreen(i, pScreen)
+     int		i;
+     ScreenPtr	pScreen;
+ {
+     Bool    ret;
+ 
+     pScreen->CloseScreen = (Bool (*)()) pScreen->devPrivates[xenixVGAScreenIndex].ptr;
+     ret = (*pScreen->CloseScreen) (i, pScreen);
+     (void) (*pScreen->SaveScreen) (pScreen, SCREEN_SAVER_OFF);
+     return ret;
+ }
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixVGAInit --
+  *	Attempt to find and initialize a VGA framebuffer
+  *
+  * Results:
+  *	None
+  *
+  * Side Effects:
+  *	Most of the elements of the ScreenRec are filled in.  The
+  *	video is enabled for the frame buffer...
+  *
+  *-----------------------------------------------------------------------
+  */
+ /*ARGSUSED*/
+ static Bool
+ xenixVGAInit (index, pScreen, argc, argv)
+     int	    	  index;    	/* The index of pScreen in the ScreenInfo */
+     ScreenPtr	  pScreen;  	/* The Screen to initialize */
+     int	    	  argc;	    	/* The number of the Server's arguments. */
+     char    	  **argv;   	/* The arguments themselves. Don't change! */
+ {
+     if (!mfbScreenInit(pScreen,
+ 		       xenixFbs[index].fb,
+ 		       xenixFbs[index].fb_width,
+ 		       xenixFbs[index].fb_height,
+ 		       monitorResolution, monitorResolution,
+ 		       xenixFbs[index].fb_width))
+ 	return (FALSE);
+ 
+     pScreen->devPrivates[xenixVGAScreenIndex].ptr = (pointer) pScreen->CloseScreen;
+ 
+     pScreen->CloseScreen = xenixVGACloseScreen;
+     pScreen->SaveScreen = xenixVGASaveScreen;
+     pScreen->whitePixel = 1;
+     pScreen->blackPixel = 0;
+ 
+     /*
+      * Enable video output...? 
+      */
+     (void) xenixVGASaveScreen(pScreen, SCREEN_SAVER_FORCER);
+ 
+     return (xenixScreenInit(pScreen) && mfbCreateDefColormap(pScreen));
+ }
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixVGAProbe --
+  *	Attempt to find and initialize a VGA framebuffer
+  *
+  * Results:
+  *	None
+  *
+  * Side Effects:
+  *	Memory is allocated for the frame buffer and the buffer is mapped. 
+  *
+  *-----------------------------------------------------------------------
+  */
+ 
+ /*ARGSUSED*/
+ Bool
+ xenixVGAProbe(pScreenInfo, index, fbNum, argc, argv)
+     ScreenInfo	  *pScreenInfo;	/* The screenInfo struct */
+     int	    	  index;    	/* The index of pScreen in the ScreenInfo */
+     int	    	  fbNum;    	/* Index into the xenixFbData array */
+     int	    	  argc;	    	/* The number of the Server's arguments. */
+     char    	  **argv;   	/* The arguments themselves. Don't change! */
+ {
+     int         fd;
+     caddr_t	mapaddr;
+ 
+     if ((fd = xenixOpenFrameBuffer(0, index, fbNum, argc, argv)) < 0)
+ 	return FALSE;
+ 
+     xenixVGAFd = fd;
+ 
+     if (ioctl(fd, SW_VGA11, 0) < 0)
+     	ErrorF("xenixVGAProbe: cannot switch to VGA graphics mode\n");
+ 
+     if ((mapaddr = (caddr_t) ioctl(fd, MAPCONS, 0)) < 0) 
+     	ErrorF("xenixVGAProbe: cannot map VGA\n");
+ 
+     xenixInitVid(mapaddr);
+ 
+     xenixFbs[index].fb = (pointer)mapaddr;
+     xenixFbs[index].fd = fd;
+     xenixFbs[index].fb_width = VGA1_FBWIDTH;
+     xenixFbs[index].fb_height = VGA1_FBHEIGHT;
+     xenixFbs[index].fb_size = VGA1_FBSIZE;
+     xenixFbs[index].EnterLeave = (void(*)()) NULL;
+     return TRUE;
+ }
+ 
+ Bool
+ xenixVGACreate(pScreenInfo, argc, argv)
+     ScreenInfo	  *pScreenInfo;
+     int	    	  argc;
+     char    	  **argv;
+ {
+     if (xenixGeneration != serverGeneration)
+     {
+ 	xenixVGAScreenIndex = AllocateScreenPrivateIndex();
+ 	if (xenixVGAScreenIndex < 0)
+ 	    return FALSE;
+     }
+     return (AddScreen(xenixVGAInit, argc, argv) >= 0);
+ }
+ 
+ 
+ static int xenixConsoleXMode;
+ static	void vga_save(), vga_restore();
+ 
+ void
+ xenixSwitchConsoleMode()
+ {
+     if (xenixConsoleXMode) {
+ 	vga_save();
+ 	ioctl(xenixVGAFd, SW_VGA80x25, 0);
+ 	reset_tty(0);
+     	xenixConsoleXMode = 0;
+     } else {
+     	ioctl(xenixVGAFd, SW_VGA11, 0);
+     	vga_restore();
+     	set_tty(0);
+     	xenixConsoleXMode = 1;
+     }
+ }
+ 
+ static	uchar_t	*xenixVGAFb;
+ static	VGARec	VGASaveFb;
+ 
+ /*
+  * Set up the graphics multiscreen stuff and call another
+  * routine to set up card.
+  */
+ xenixInitVid(a)
+ uchar_t	*a;
+ {
+ 	struct vt_mode smode;
+ 
+ 	xenixVGAFb = a;
+ 	xenixConsoleXMode = 1;
+ 	return;
+ }
+ 
+ static void
+ vga_save()
+ {
+ 	uchar_t *p, *q;
+ 	int	i;
+ 
+ 	i = VGA1_FBSIZE;
+ 	p = (uchar_t *) &VGASaveFb;
+ 	q = (uchar_t *) xenixVGAFb;
+ 
+ 	while (i--)
+ 		*p++ = *q++;
+ }
+ 
+ static void
+ vga_restore()
+ {
+ 	uchar_t *p, *q;
+ 	int	i;
+ 
+ 	i = VGA1_FBSIZE;
+ 	p = (uchar_t *) &VGASaveFb;
+ 	q = (uchar_t *) xenixVGAFb;
+ 
+ 	while (i--)
+ 		*q++ = *p++;
+ }
+ 



More information about the Alt.sources mailing list