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

📄 fg.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
	register int *ptep;		/* page table entry pointer */        register struct _vs_event *vep;        register struct tty *tp;	register struct tchip *fgtchip;	register struct dchip *fgdchip;	register struct achip *fgachip;	register struct fbic *fgfbic;	register int unit = minor(dev);        struct fgmap *fg;               /* pointer to device map struct */	struct prgkbd *cmdbuf;        struct prg_cursor *curs;        struct _vs_cursor *pos;	struct	fgcurstabupd *cur;	int	i;	int	s;	int	error;/* * service the Firefox device ioctl commands */	switch (cmd) {	    case FG_MAPDEVICE:		fg = (struct fgmap *) &fgmap;		bcopy(fg, data, sizeof(struct fgmap));		break;/* * give user write access to the event queue */            case FG_MAPEVENT:		fgflags.mapped |= MAPEQ;                ptep = (int *) ((VTOP(eq_header) * 4)                                + (mfpr(SBR) | 0x80000000));                /* allow user write to 1K event queue */                *ptep++ = (*ptep & ~PG_PROT) | PG_UW | PG_V;                *ptep = (*ptep & ~PG_PROT) | PG_UW | PG_V;                mtpr(TBIA, 0);                  /* clr CPU translation buf */                /* return event queue address */                *(int *)data = (int) eq_header;                break;	    case FG_GETEVENT:	/* extract the oldest event from event queue */		if (ISEMPTY(eq_header)) {		    vep = (struct _vs_event *) data;		    vep->vse_device = VSE_NULL;		    break;		}		vep = (struct _vs_event *) GETBEGIN(eq_header);		s = spl6();		GETEND(eq_header);		splx(s);		bcopy(vep, data, sizeof(struct _vs_event));		break;	    case FG_VIDEOON:		/* turn on the video */        	fgtchip = (struct tchip *) fgmap.tchip;		fgtchip->tchip_csr |= TCHIP_UNBLANK;		break;	    case FG_VIDEOOFF:		/* turn off the video */        	fgtchip = (struct tchip *) fgmap.tchip;		fgtchip->tchip_csr &= ~TCHIP_UNBLANK;		break;	    case FG_INITACHIP:		/* initialize achip */        	fgachip = (struct achip *) fgmap.achip;		fg_init_achip(fgachip);		break;	    case FG_INITDCHIP:		/* initialize dchip */        	fgdchip = (struct dchip *) fgmap.dchip;		fg_init_dchip(fgdchip);		break;	    case FG_INITTCHIP:		/* initialize tchip */        	fgtchip = (struct tchip *) fgmap.tchip;		fg_init_tchip(fgtchip);		break;            case FG_POSCURSOR:          /* position the mouse cursor */		pos = (struct _vs_cursor *) data;		fg_pos_cursor (pos->x, pos->y);		eq_header->curs_pos.x = pos->x;		eq_header->curs_pos.y = pos->y;		fgcurstab.x = pos->x;		fgcurstab.y = pos->y;		break;            case FG_PRGCURSOR:		/* set the cursor acceleration factor */                curs = (struct prg_cursor *) data;                s = spl6();                fgflags.curs_acc = curs->acc_factor;                fgflags.curs_thr = curs->threshold;                splx(s);                break;            case FG_PRGKBD:  /* pass caller's programming commands to LK201 */                cmdbuf = (struct prgkbd *)data;     /* pnt to kbd cmd buf */                fg_key_out (cmdbuf->cmd);/* * Send param1? */                if (cmdbuf->cmd & LAST_PARAM)                    break;                fg_key_out (cmdbuf->param1);/* * Send param2? */                if (cmdbuf->param1 & LAST_PARAM)                    break;                fg_key_out (cmdbuf->param2);                break;            case FG_KERN_LOOP:          /* redirect kernel messages */                fgflags.kernel_loop = -1;                break;            case FG_KERN_UNLOOP:        /* don't redirect kernel messages */                fgflags.kernel_loop = 0;                break;	    case FG_RESET:	/* init driver variables */		fg_init_shared();	/* init shared memory */		fg_clr_screen();		break;	    case FG_SET:	/* init driver variables */		fg_init_shared();	/* init shared memory */		break;	    case FG_CLRSCRN:	/* clear the screen */		fg_clr_screen();		break;	    case FG_WTCURSOR:	/* load a cursor */		fg_load_cursor(data);		break;	    case FG_HALTGVAX:	/* halt the GVAX */		fgfbic = (struct fbic *) fgmap.fbic;		if ((fgfbic->fbic_fbicsr & BIT_13) == 0) {		  fgfbic->fbic_fbicsr &= ~HALTCPU;   /* for pass 2 chips */		  fgfbic->fbic_fbicsr |= HALT_ENB;   /* enable halt */		  fgfbic->fbic_fbicsr &= ~BIT_13;    /* clear bit 13 */		  fgfbic->fbic_fbicsr |= HALTCPU;    /* halt CPU */		  DELAY(100);			   /* wait for bit 13 */		}		break;	    case FG_UNHALTGVAX:	/* unhalt the GVAX */		fgfbic = (struct fbic *) fgmap.fbic;		fgfbic->fbic_fbicsr &= ~HALTCPU;   /* unhalt CPU */		fgfbic->fbic_fbicsr &= ~BIT_13;    /* clear bit 13 */		DELAY(100);			   /* wait for bit 13 */		break;	    case FG_GETTIMING:	/* get tchip value */		fg_get_tchip(data);		break;	    case FG_SETTIMING:	/* set tchip value */		fg_set_tchip(data);		break;	    case FG_GETCOMMAREA:	/* get common area (shared memory) */				fg_init_comm_area(data, 1); /* Initialize both common area and descriptor */		break;	    case FG_SETCURSTAB:	/* update fgcurstab */		cur = (struct fgcurstabupd *) data;		if (cur->flags & UPDATE_X)			fgcurstab.x = cur->x;		if (cur->flags & UPDATE_Y)			fgcurstab.y = cur->y;		if (cur->flags & UPDATE_HOTX)			fgcurstab.hot_x = cur->hot_x;		if (cur->flags & UPDATE_HOTY)			fgcurstab.hot_y = cur->hot_y;		eq_header->curs_pos.x = fgcurstab.x;		eq_header->curs_pos.y = fgcurstab.y;		fgcurstab.XY.coords.pat_x =			fgcurstab.x - fgcurstab.hot_x + fg_wc_offset;		fgcurstab.XY.coords.pat_y = fgcurstab.y - fgcurstab.hot_y;/* load new cursor position */		fg_comm_area->XY_position = fgcurstab.XY.position;/* request position update */		fg_comm_area->Lego.XY_position = 1;/* request pattern color update */		fg_comm_area->Lego.color = 1;/* request pattern update */		fg_comm_area->Lego.pattern = 1;/* request cursor update */		fg_comm_area->HG_flags.cursor_update = 1;		break;	    case FG_SETFGPIXEL:	/* update fgcurstab */		fg_fgpixel = *data;		break;	    case FG_SETBGPIXEL:	/* update fgcurstab */		fg_bgpixel = *data;		break;	    default:		if ((unit == 2) && (major(dev) == CONSOLEMAJOR))		  tp = &sm_tty;		else		  tp = &fc_tty[unit];		error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag);		if (error >= 0)		  return(error);				error = ttioctl(tp, cmd, data, flag);		if (error >= 0)		  return(error);	        /* if error = -1 then ioctl does not exist */		if (u.u_procp->p_progenv == A_POSIX) 			return (EINVAL);		return (ENOTTY);		    		break;			}	return(0);}fg_get_tchip(tchip_info)fg_timinginfo *tchip_info;{/* Get the value of the tchip registers */	register struct tchip *fgtchip;        fgtchip = (struct tchip *) fgmap.tchip;	tchip_info->csr = fgtchip->tchip_csr;	tchip_info->pipe = tchip_info->csr >> 13;	tchip_info->interrupt = fgtchip->tchip_int_reg;	tchip_info->display_x = fgtchip->tchip_x_start;	tchip_info->display_y = fgtchip->tchip_y_start;	tchip_info->table_x = fgtchip->tchip_table_x_start;	tchip_info->table_y = fgtchip->tchip_table_y_start;	tchip_info->table_width = fgtchip->tchip_table_cntl_reg & TIMING_WIDTH_MASK;	tchip_info->table_L1 = (fgtchip->tchip_table_cntl_reg & TIMING_TL1_MASK)			>> TIMING_TL1_OFF;	tchip_info->table_L2 = (fgtchip->tchip_table_cntl_reg & TIMING_TL2_MASK)			>> TIMING_TL2_OFF;	tchip_info->VBS = fgtchip->tchip_mon_cntl_reg0 & TIMING_XBS_MASK;	tchip_info->VBF = fgtchip->tchip_mon_cntl_reg1 & TIMING_XBS_MASK;	tchip_info->VSS = fgtchip->tchip_mon_cntl_reg2 & TIMING_XBS_MASK;	tchip_info->VSF = fgtchip->tchip_mon_cntl_reg3 & TIMING_XBS_MASK;	tchip_info->HBS = fgtchip->tchip_mon_cntl_reg4 & TIMING_XBS_MASK;	tchip_info->HBF = fgtchip->tchip_mon_cntl_reg5 & TIMING_XBS_MASK;	tchip_info->HSS = ((fgtchip->tchip_mon_cntl_reg0 >> TIMING_HI_OFF) |		((fgtchip->tchip_mon_cntl_reg1 & TIMING_HI_MASK) >> 6)) & 0x1ff;	tchip_info->HSF = ((fgtchip->tchip_mon_cntl_reg2 >> TIMING_HI_OFF) |		((fgtchip->tchip_mon_cntl_reg3 & TIMING_HI_MASK) >> 6)) & 0x1ff;	tchip_info->HS2 = ((fgtchip->tchip_mon_cntl_reg4 >> TIMING_HI_OFF) |		((fgtchip->tchip_mon_cntl_reg5 & TIMING_HI_MASK) >> 6)) & 0x1ff;	tchip_info->PVI = fgtchip->tchip_vertical_int;}fg_set_tchip(tchip_info)fg_timinginfo *tchip_info;{/* Set the value of the tchip registers */	register struct tchip *fgtchip;        fgtchip = (struct tchip *) fgmap.tchip;	fgtchip->tchip_x_start = tchip_info->display_x;	fgtchip->tchip_y_start = tchip_info->display_y;	fgtchip->tchip_table_x_start = tchip_info->table_x;	fgtchip->tchip_table_y_start = tchip_info->table_y;	fgtchip->tchip_table_cntl_reg = tchip_info->table_width |		tchip_info->table_L1 << TIMING_TL1_OFF |		tchip_info->table_L2 << TIMING_TL2_OFF;	fgtchip->tchip_mon_cntl_reg0 = tchip_info->VBS |		((tchip_info->HSS & 0x1f) << TIMING_HI_OFF);	fgtchip->tchip_mon_cntl_reg1 = tchip_info->VBF |		((tchip_info->HSS >> 5) << TIMING_HI_OFF);	fgtchip->tchip_mon_cntl_reg2 = tchip_info->VSS |		((tchip_info->HSF & 0x1f) << TIMING_HI_OFF);	fgtchip->tchip_mon_cntl_reg3 = tchip_info->VSF |		((tchip_info->HSF >> 5) << TIMING_HI_OFF);	fgtchip->tchip_mon_cntl_reg4 = tchip_info->HBS |		((tchip_info->HS2 & 0x1f) << TIMING_HI_OFF);	fgtchip->tchip_mon_cntl_reg5 = tchip_info->HBF |		((tchip_info->HS2 >> 5) << TIMING_HI_OFF);	fgtchip->tchip_vertical_int = tchip_info->PVI;	fgtchip->tchip_int_reg = tchip_info->interrupt;	fgtchip->tchip_csr = tchip_info->csr | tchip_info->pipe << 13;}/****************************************************************** **                                                              ** ** ADDER interrupt routine.                                     ** **                                                              ** ******************************************************************/fgaint(fg)register int fg;{}/****************************************************************** **                                                              ** ** Sync. interrupt routine.                                     ** **                                                              ** ******************************************************************/fgvint(fg)	int fg;{}/****************************************************************** **                                                              ** ** Graphic device input interrupt Routine.                      ** **                                                              ** ******************************************************************/fgiint(ch)register int ch;{	register struct _vs_event *vep;	register struct fginput *eqh;	register struct color_cursor *sgcursor;	struct mouse_report *new_rep;	struct tty *tp;	register int unit;	register u_short c;	register int i, j;	u_short data;	char	wakeup_flag = 0;	/* flag to do a select wakeup call */	int	cnt;/* * Mouse state info */	static char temp, old_switch, new_switch;	eqh = eq_header;	unit = (ch>>8)&03;	new_rep = &current_rep;	tp = &fc_tty[unit];/* * If graphic device is turned on */   if (fg_mouseon == 1) {  	cnt = 0;	while (cnt++ == 0) {/* * Pick up LK-201 input (if any) */	    if (unit == 0) {/* event queue full ? */		if (ISFULL(eqh) == TRUE) {/*		    mprintf("\nfg0: fgiint: event queue overflow");*/		    return(0);		}/* * Get a character. */		data = ch & 0xff;/* * Check for various keyboard errors */		if( data == LK_POWER_ERROR || data == LK_KDOWN_ERROR ||	    	    data == LK_INPUT_ERROR || data == LK_OUTPUT_ERROR) {			mprintf("\nfg0: fgiint: keyboard error, code = %x",data);			return(0);		}		if (data < LK_LOWEST) 		    	return(0);		++wakeup_flag;		/* request a select wakeup call */		vep = PUTBEGIN(eqh);		PUTEND(eqh);		vep->vse_direction = VSE_KBTRAW;		vep->vse_type = VSE_BUTTON;		vep->vse_device = VSE_DKB;		vep->vse_x = eqh->curs_pos.x;		vep->vse_y = eqh->curs_pos.y;		vep->vse_time = TOY;		vep->vse_key = data;	    }/* * Pick up the mouse input (if any) */	    if ((unit == 1) && (sm_pointer_id == MOUSE_ID)) {/* event queue full ? */		if (ISFULL(eqh) == TRUE) {/*		    mprintf("\nfg0: fgiint: event queue overflow");*/		    return(0);		}/* * see if mouse position has changed */		if( new_rep->dx != 0 || new_rep->dy != 0) {/* * Check to see if we have to accelerate the mouse *

⌨️ 快捷键说明

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