📄 fg.c
字号:
fg_config(); fgachip = (struct achip *) fgmap.achip; fgdchip = (struct dchip *) fgmap.dchip; fgtchip = (struct tchip *) fgmap.tchip; fg_init_achip(fgachip); fg_init_dchip(fgdchip); fg_init_tchip(fgtchip); fg_clip(0, 0, 2047, 2047); fg_clr_screen(); fgtchip->tchip_csr |= TCHIP_UNBLANK; fg_init_shared(); }/* Darrell said we don't need next two lines */ cvec = 0x248; br = 0x14; return(sizeof(int));}/****************************************************************** ** ** ** Routine to attach to the graphic device. ** ** ** ******************************************************************/fgattach(ui) struct uba_device *ui;{ register int *pte; int i;/* * init "fgflags" */ fgflags.inuse = 0; /* init inuse variable EARLY! */ fgflags.mapped = 0; fgflags.kernel_loop = -1; /* default is now kern_loop on */ fgflags.curs_acc = ACC_OFF; fgflags.curs_thr = 128; fgflags.tab_res = 2; /* default tablet resolution factor */ fgflags.duart_imask = 0; /* init shadow variables *//* * init structures used in kbd/mouse interrupt routine. This code must * come after the "sg_init_shared()" routine has run since that routine inits * the eq_header structure used here. *//* init the "latest mouse report" structure */ last_rep.state = 0; last_rep.dx = 0; last_rep.dy = 0; last_rep.bytcnt = 0;/* init the event queue (except mouse position) */ eq_header->header.events = (struct _vs_event *) ((int)eq_header + sizeof(struct fginput)); eq_header->header.size = MAXEVENTS; eq_header->header.head = 0; eq_header->header.tail = 0;/* init single process access lock switch */ fg_open = 0;/* * Map the bitmap for use by users. */ pte = (int *)(FGMEMmap[0]); for( i=0 ; i<65536 ; i++, pte++ ) *pte = (*pte & ~PG_PROT) | PG_UW | PG_V; pte = (int *)(FGCTSIXSmap); *pte = (*pte & ~PG_PROT) | PG_UW | PG_V;}/****************************************************************** ** ** ** Routine to open the graphic device. ** ** ** ******************************************************************/extern struct pdma fcpdma[];extern int ssparam();/*ARGSUSED*/fgopen(dev, flag) dev_t dev; int flag;{ register int unit = minor(dev); register struct tty *tp; register struct nb_regs *sgiaddr = (struct nb_regs *)nexus;/* * The graphics device can be open only by one person */ if (unit == 1) {if (fgdebug) mprintf("Open mouse fgmouse = %d unit = %d\n",fg_mouseon,unit); if (fg_open != 0) return(EBUSY); else fg_open = 1; fgflags.inuse |= GRAPHIC_DEV; /* graphics dev is open */ } else { fgflags.inuse |= CONS_DEV; /* mark console as open */ } if ((unit == 2) && (major(dev) == CONSOLEMAJOR)) tp = &sm_tty; else tp = &fc_tty[unit]; if (tp->t_state&TS_XCLUDE && u.u_uid!=0) return (EBUSY); tp->t_addr = (caddr_t)&fcpdma[unit]; tp->t_oproc = fgstart; /*--------------------------------------------------------------------- * 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; } 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; if( unit == 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; } } else { tp->t_flags = RAW; tp->t_iflag = 0; tp->t_oflag = 0; tp->t_cflag |= CS8|CREAD|HUPCL; tp->t_lflag = 0; } if(tp != &sm_tty) fcparam(unit); else tp->t_iflag |= IXOFF; /* flow control for qconsole */ }/* * Process line discipline specific open if its not the mouse. */ if (unit != 1) return ((*linesw[tp->t_line].l_open)(dev, tp)); else { fg_mouseon = 1;if (fgdebug)mprintf("Exiting from open fg_mouse = %d Unit = %d\n",fg_mouseon, unit); return(0); }}/****************************************************************** ** ** ** Routine to close the graphic device. ** ** ** ******************************************************************//*ARGSUSED*/fgclose(dev, flag) dev_t dev; int flag;{ register struct tty *tp; register int unit = minor(dev); register struct achip *fgachip; register struct dchip *fgdchip; register struct tchip *fgtchip; register struct fbic *fgfbic; unit = minor(dev); if (fgdebug) mprintf("Close Unit = %d mouse = %d\n",unit, fg_mouseon); if ((unit == 2) && (major(dev) == CONSOLEMAJOR)) tp = &sm_tty; else tp = &fc_tty[unit];/* * If unit is not the mouse call the line disc. otherwise clear the state * flag, and put the keyboard into down/up. */ if( unit != 1 ){ (*linesw[tp->t_line].l_close)(tp); ttyclose(tp); fgflags.inuse &= ~CONS_DEV; fg_keyboard.cntrl = fg_keyboard.shift = 0; } else { fg_mouseon = 0; if (fg_open != 1) return(EBUSY); else fg_open = 0; /* mark the graphics device available */ fgflags.inuse &= ~GRAPHIC_DEV;/* * should setup the hardware again */ fgachip = (struct achip *) fgmap.achip; fgdchip = (struct dchip *) fgmap.dchip; fgtchip = (struct tchip *) fgmap.tchip; 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 GVAX */ DELAY(100); /* wait for bit 13 */ }#ifndef XX_NOINIT_LEGSS fg_init_achip(fgachip); fg_init_dchip(fgdchip); fg_init_tchip(fgtchip);#endif XX_NOINIT_LEGSS fg_clip(0, 0, 2047, 2047); fg_clr_screen(); fgtchip->tchip_csr |= TCHIP_UNBLANK; fg_init_shared(); cursor.x = 0; cursor.y = 0; } tp->t_state = 0; /* Remove termio flags that do not map */ tp->t_iflag &= ~TERMIO_ONLY_IFLAG; tp->t_oflag &= ~TERMIO_ONLY_OFLAG; tp->t_cflag &= ~TERMIO_ONLY_CFLAG; tp->t_lflag &= ~TERMIO_ONLY_LFLAG;if (fgdebug)mprintf("Exiting Close Unit = %d mouse = %d\n",unit, fg_mouseon);}/****************************************************************** ** ** ** Routine to read from the graphic device. ** ** ** ******************************************************************/extern fg_strategy();fgread(dev, uio)dev_t dev;struct uio *uio;{ register struct tty *tp; register int minor_dev; register int unit; minor_dev = minor(dev); unit = (minor_dev >> 2) & 0x07;/* If this is the console... */ if ((minor_dev & 0x03) != 1 && fgflags.inuse & CONS_DEV) { if ((minor_dev == 2) && (major(dev) == CONSOLEMAJOR)) tp = &sm_tty; else tp = &fc_tty[minor_dev]; return ((*linesw[tp->t_line].l_read)(tp, uio)); }/* * else this must be a FIFO xfer from user space */}/****************************************************************** ** ** ** Routine to write to the graphic device. ** ** ** ******************************************************************/extern fg_strategy();fgwrite(dev, uio) dev_t dev; struct uio *uio;{ register struct tty *tp; register int minor_dev; register int unit; minor_dev = minor(dev); unit = (minor_dev >> 2) & 0x07;/* If this is the console... */ if ((minor_dev & 0x03) != 1 && fgflags.inuse & CONS_DEV) { if ((minor_dev == 2) && (major(dev) == CONSOLEMAJOR)) tp = &sm_tty; else tp = &fc_tty[minor_dev]; return ((*linesw[tp->t_line].l_write)(tp, uio)); }/* * else this must be a FIFO xfer from user space *//* else if (sgflags.inuse & GRAPHIC_DEV) { return (physio(sg_strategy, &sgbuf[unit], dev, B_WRITE, minphys, uio)); }*/}/****************************************************************** ** ** ** Strategy routine to do FIFO ** ** ** ******************************************************************/fg_strategy(bp)register struct buf *bp;{}/****************************************************************** ** ** ** Mouse activity select routine. ** ** ** ******************************************************************/fgselect(dev, rw)dev_t dev;{ register int s = spl6(); register int unit = minor(dev); register struct tty *tp; switch(rw) { case FREAD: /* event available */ if (unit == 1) { if(!(ISEMPTY(eq_header))) { splx(s); return(1); } rsel = u.u_procp; fgflags.selmask |= SEL_READ; splx(s); return(0); } else { tp = &sm_tty; if (ttnread(tp)) { splx(s); return(1); } tp->t_rsel = u.u_procp; splx(s); return(0); } case FWRITE: /* FIFO done? */ if (unit == 1) { rsel = u.u_procp; fgflags.selmask |= SEL_WRITE; splx(s); return(0); } else { tp = &sm_tty; if (tp->t_outq.c_cc <= TTLOWAT(tp)) { splx(s); return(1); } tp->t_wsel = u.u_procp; splx(s); return(0); } }}/****************************************************************** ** ** ** Graphic device ioctl routine. ** ** ** ******************************************************************//*ARGSUSED*/fgioctl(dev, cmd, data, flag) dev_t dev; int cmd; register caddr_t data;{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -