📄 sg.c
字号:
#ifndef lintstatic char *sccsid = "@(#)sg.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: * * 23-Feb-90 -- sekhar * Merged Joe Martin's fix for 3.1 cld. When copying user PTEs, * check for page crossing and reevaluate vtopte. * * 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. * * 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) * 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 sgclose routine. * * 08-May-89 -- rafiey (Ali Rafieymehr) * Fixed a bug in mapping pages for color_buf. The driver was not * mapping enough pages to be used by color_buf on eight plane * machines. * * 08-May-89 - rafiey (for Fred Canter) * Fix stray interrupts thru SCB vector 0x1fc caused by polling * with interrupts enabled while sending characters to * the keyboard in sg_key_out(). * * 08-May-89 -- rafiey (Ali Rafieymehr) * The input interrupt routine (sgiint) was printing error messages when * the event queue was full (in high IPL). These error messages are not * really usefull. The solution is to increase the size of the event * queue (this should be done in the next release). For now there is no * need to print the error messages, therefore the "overflow" print * statements are commented out. * * 16-Feb-89 - Mark Parenti * * Remove xinfo and xoutput. They were xos remnants. * * 13-Sep-88 - Ali Rafieymehr * * Fixed a bug which was causing the "select" not to work for * alternate console. * * 17-Aug-88 - Ali Rafieymehr * * Fixed a bug in wait_status() routine. We were not waiting long enough * for the vertical sync. status bit to be set. * * 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. * * 14-July-88 - Vasudev K. Bhandarkar * * Changed TOY from 16 bits to 32 bits. X11 server needs 32-bits * of detail associated with event time stamps. * * 13-Jun-88 -- rafiey (Ali Rafieymehr) * Fixed the tablet problem. Tablet wasn't initialized correctly. * * 07-Mar-88 -- vasudev (Vasudev K. Bhandarkar) * X11 changes. Made the GPX accessible to user processes, such * as the X11 server. * * 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. * * 28-Oct-87 -- Ali Rafieymehr * Changed the logic for turning the video on/off for the 8 plane. * Turning video on/off didn't work with the new board. * * 12-Oct-87 - Tim Burke * Modified driver to provide 8-bit support to the console port. To do * this characters are defined in the remainder of the first 15 rows of * off screen memory as well as in next 15 rows. * * 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. * * 18-Aug-87 -- Ali Rafieymehr * Included the 8 plane support. Also modified "sg_save()" and * "sg_restore()" to save and restore color maps during "halt" * and "continue" process. Fixed a bug in the sgclose() routine. * It was not changing the cursor and color maps when X was killed. * * 4-Aug-87 -- Ali Rafieymehr * Moved sg_next_fifo declaration from "../qdddx/globals.h" to * "../vaxuba/sguser.h". * * 3-Aug-87 -- Ali Rafieymehr * Fixed a bug which was causing the system to hang if we tried * to continue after the system was halted by pressing the halt * switch. * * 1-Aug-87 -- Fred Canter * Use TANDEM mode on sgscreen for flow control of writes to * /dev/console. * * 27-Jul-87 -- Fred Canter * Fix devioget bus and interface types. * * 9-Jun-87 -- Ali Rafieymehr * Corrected the value for the cursor color (during power up). * * 3-Jun-87 -- 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. * * 22-May-87 -- Ali Rafieymehr * Corrected type of a variable and value loaded into the cbcsr * register of the FCC. * * 14-May-87 -- Ali Rafieymehr * Changed the interrupt routine to write directly to the FIFO * rather than copying to the buffer first. * * 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. * Removed unused variable (nsg) and tty struct (sg_tty). * * 21-Apr-87 - Brian Stevens * keep VSYNC on when graphics device is open, save color mapping work. * * 16-Apr-87 fred (Fred Canter) * Brian Steven's Multi-head GPX support (yes really). * * 19-Mar-87 rafiey (Ali Rafieymehr) * Fix putc so crash dumps work on color VAXstar. * Fix screen strangess. * * 19-Mar-87 fred (Fred Canter for Ali Rafieymehr) * Added X in the kernel support for color VAXstar. * * 02-Mar-87 rafiey (Ali Rafieymehr) * The video being turned off wasn't fixed correctly before. * * 11-Feb-87 rafiey (Ali Rafieymehr) * Fixed a bug which was not turning the video on. Cleaned the code * to include ioctls for the color support, and changed the chip * select due to change of the hardware document and more cleanup. * * 07-Jan-87 rafiey (Ali Rafieymehr) * Added the cursor to the driver and did some cleanup. * * 13-Dec-86 rafiey (Ali Rafieymehr) * Converted the first pass color driver in to a semi-working * version, which runs of the prototype VAXstar color board. * * 3-Sep-86 fred (Fred Canter) * Make sure probe fails if CPU not a VAXstation 2200. * Select video interrupt source (instead of sh driver). * * 2-Jul-86 rafiey (Ali Rafieymehr) * Changed SGMAJOR to 50 and removed unused code. * * 18-Jun-86 rafiey (Ali Rafieymehr) * Created this VAXstar color driver. * Derived from qd.c. * **********************************************************************/#if NSG > 0 || defined(BINARY)#include "../data/sg_data.c" /* include external references to data file *//* * Following allow sgputc 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_PHYSADDER 0x3c000000#define VS_PHYSFCC 0x3c000200#define VS_PHYSVDAC 0x3c000300#define VS_PHYSCURSOR 0x3c000400int sg_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 *//* * VAXstar (color option) register address offsets from start of VAXstar (color) * address space. */#define ADDER 0x0000 /* ADDER chip address */#define FCC 0x0200 /* Fifo Compression Chip address */#define VDAC 0x0300 /* Video DAC address */#define CUR 0x0400 /* CURsor chip address */#define VRBACK 0x0500 /* Video ReadBACK address */#define FIFORAM 0x8000 /* FIFO/template RAM *//* * general defines */#define SGPRIOR (PZERO-1) /* must be negative */#define FALSE 0#define TRUE 1#define CHAR_S 0xc7#define CHAR_Q 0xc1struct uba_device *sgdinfo[NSG];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[];/* * macro to create a system virtual page number from system virtual adrs */#define VTOP(x) (((int)x & ~0xC0000000) >> PGSHIFT) /* convert address */ /* to system page # *//* * Definition of the driver for the auto-configuration program. */int sgprobe(), sgattach(), sgfint(), sgaint(), sgiint();u_short sgstd[] = { 0 };struct uba_driver sgdriver = { sgprobe, 0, sgattach, 0, sgstd, "sg", sgdinfo };struct sg_fifo_space SG_bufmap[];/* * 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 CONSOLEMAJOR 0#define SG_MAJOR 50/* * Keyboard state */struct sg_keyboard { int shift; /* state variables */ int cntrl; int lock; int hold; char last; /* last character */} sg_keyboard;short sg_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 sg_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(sg_kbdinitstring)/sizeof(short)#define TOY ((time.tv_sec * 1000) + (time.tv_usec / 1000))int sg_ipl_lo = 1; /* IPL low flag */extern u_short sm_pointer_id; /* id of pointer device (mouse,tablet)-ss.c */u_short sg_mouseon = 0; /* Mouse is enable when 1 */u_short sg_open = 0; /* graphics device is open when 1 */u_short sg_cur_reg = 0; /* Register to keep track of cursor register bits*/u_short sg_vdac_reg = 0; /* Register to keep track of vdac mode register */u_short sgdebug = 0; /* Debug is enable when #0 */char *sg_fifo_addr;char *sg_ptr;u_short req_length;short *sg_int_flag;short *change_section; /* flag to indicate we are changing FIFO section */u_short *sg_next_fifo;u_short nbytes_req, nbytes_left;extern u_long scr_ram_addr; /* system scratch RAM phys. address defined */ /* in ss.c */short sg_num_planes;u_short sgsave_regs[5]; /* Used by sg_save() , sg_restore() routines */ /* to save and restore some hardware regs. */struct adder *sg_addr; /* Used by sg_save() , sg_restore() routines */struct fcc *sg_fcc; /* Used by sg_save() , sg_restore() routines */struct vdac *sg_vdac; /* Used by sg_save() routine */struct nb4_regs *sgsys_scr_ram; /* Used by sg_save() , sg_restore() routines */short *vdac_address; /* Used by sg_save() routine */short sg_colormaps[256*4];short sg_red_save = 0;short sg_green_save = 0;short sg_blue_save = 0;short colormaps_index = 0;short num_colormaps;short sg_counter1 = 0;short sg_counter2;short sg_video_off = 0;#define REBOOT_IN_PROG 0x10#define CPMBX_REBOOT (0x2<<2)struct proc *rsel; /* process waiting for select */int sgstart(), sgputc(), sggetc(), ttrstrt();long sg_save(), sg_restore();/* * Keyboard translation and font tables */extern char *q_special[],q_font[];extern u_short q_key[],q_shift_key[];#define FONT_OFFSET ((MAX_SCREEN_X/CHAR_WIDTH)*CHAR_HEIGHT)extern struct nexus nexus[];/* * Default cursor (plane A and plane B) * */unsigned short def_cur[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. ** ** ** ******************************************************************/extern int ws_display_type;extern int ws_display_units;sgprobe(reg) caddr_t reg;{ register struct nb_regs *sgaddr = (struct nb_regs *)nexus; register struct nb3_regs *sgaddr3 = (struct nb3_regs *)sgmem; register struct fcc *sgfcc; register struct vdac *sgvdac;/* * Only on a VAXstation 2200 (not MicroVAX 2000) * Also on a CVAXstar. * TODO: MULTU bit meaning changed, may use ARCHID bits */ if (((cpu != VAXSTAR) && (cpu != C_VAXSTAR)) || (vs_cfgtst&VS_MULTU)) return(0);/* * Only if color option present */ if ((vs_cfgtst&VS_VIDOPT) == 0) return(0);/* * Only if SG is the graphics device. */ if (ws_display_type && (ws_display_type != SG_DTYPE)) return(0); sgaddr->nb_vdc_sel = 1; /* select color option interrupts */ sgaddr->nb_int_reqclr = SINT_VF; sgaddr->nb_int_msk |= SINT_VF; if (v_consputc != sgputc) { sgbase = (caddr_t) ((u_long)sgaddr3); sgmap.adder = sgbase + ADDER; sgmap.fcc = sgbase + FCC; sgmap.vdac = sgbase + VDAC; sgmap.cur = sgbase + CUR; sgmap.vrback = sgbase + VRBACK; sgmap.fiforam = sgbase + FIFORAM; sgvdac = (struct vdac *) sgmap.vdac; sg_vdac_reg = 0x47; sgvdac-> mode = sg_vdac_reg; cursor.x = 0; cursor.y = 0; sg_init_shared(); /* init shared memory */ } sgfcc = (struct fcc *) sgmap.fcc;/* * Initialize the FCC by issuing HALT command (bits 9, 10 cbcsr to zero) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -