?? qd.c
字號(hào):
if ((minor_dev & 0x03) == 2) { /*----------------- * unlock driver */ if (one_only[unit] != 1) return(EBUSY); else one_only[unit] = 0; /*---------------------------- * re-protect device memory */ if (qdflags[unit].mapped & MAPDEV) { /*---------------- * TEMPLATE RAM */ mapix = VTOP((int)qd->template) - VTOP(qmem[0]); ptep = (int *)(QMEMmap[0] + mapix); for (i = VTOP(TMPSIZE); i > 0; --i) *ptep++ = (*ptep & ~PG_PROT) | PG_V | PG_KW; /*--------- * ADDER */ mapix = VTOP((int)qd->adder) - VTOP(qmem[0]); ptep = (int *)(QMEMmap[0] + mapix); for (i = VTOP(REGSIZE); i > 0; --i) *ptep++ = (*ptep & ~PG_PROT) | PG_V | PG_KW; /*-------------- * COLOR MAPS */ mapix = VTOP((int)qd->red) - VTOP(qmem[0]); ptep = (int *)(QMEMmap[0] + mapix); for (i = VTOP(CLRSIZE); i > 0; --i) *ptep++ = (*ptep & ~PG_PROT) | PG_V | PG_KW; } /*---------------------------------------------------- * re-protect DMA buffer and free the map registers */ if (qdflags[unit].mapped & MAPDMA) { dga = (struct dga *) qdmap[unit].dga; adder = (struct adder *) qdmap[unit].adder; dga->csr &= ~DMA_IE; dga->csr &= ~0x0600; /* kill DMA */ adder->command = CANCEL; /* if DMA was running, flush spurious intrpt */ if (dga->bytcnt_lo != 0) { dga->bytcnt_lo = 0; dga->bytcnt_hi = 0; DMA_SETIGNORE(DMAheader[unit]); dga->csr |= DMA_IE; dga->csr &= ~DMA_IE; } ptep = (int *) ((VTOP(DMAheader[unit]*4)) + (mfpr(SBR)|0x80000000)); for (i = (DMAbuf_size >> PGSHIFT); i > 0; --i) *ptep++ = (*ptep & ~PG_PROT) | PG_V | PG_KW; ubarelse(0, &Qbus_unmap[unit]); } /*--------------------------------------- * re-protect 1K (2 pages) event queue */ if (qdflags[unit].mapped & MAPEQ) { ptep = (int *) ((VTOP(eq_header[unit])*4) + (mfpr(SBR)|0x80000000)); *ptep++ = (*ptep & ~PG_PROT) | PG_KW | PG_V; *ptep = (*ptep & ~PG_PROT) | PG_KW | PG_V; } /*------------------------------------------------------------ * re-protect scroll param area and disable scroll intrpts */ if (qdflags[unit].mapped & MAPSCR) { ptep = (int *) ((VTOP(scroll[unit]) * 4) + (mfpr(SBR) | 0x80000000)); /* re-protect 512 scroll param area */ *ptep = (*ptep & ~PG_PROT) | PG_KW | PG_V; adder = (struct adder *) qdmap[unit].adder; qdflags[unit].adder_ie &= ~FRAME_SYNC; adder->interrupt_enable = qdflags[unit].adder_ie; } /*----------------------------------------------------------- * re-protect color map write buffer area and kill intrpts */ if (qdflags[unit].mapped & MAPCOLOR) { ptep = (int *) ((VTOP(color_buf[unit]) * 4) + (mfpr(SBR) | 0x80000000)); *ptep++ = (*ptep & ~PG_PROT) | PG_KW | PG_V; *ptep = (*ptep & ~PG_PROT) | PG_KW | PG_V; color_buf[unit]->status = 0; adder = (struct adder *) qdmap[unit].adder; qdflags[unit].adder_ie &= ~VSYNC; adder->interrupt_enable = qdflags[unit].adder_ie; } /*----------------------------------- * flag that everthing is unmapped */ mtpr(TBIA, 0); /* smash CPU's translation buf */ qdflags[unit].mapped = 0; /* flag everything now unmapped */ qdflags[unit].inuse &= ~GRAPHIC_DEV; qdflags[unit].curs_acc = ACC_OFF; qdflags[unit].curs_thr = 128; /*--------------------- * restore the console */ dga = (struct dga *) qdmap[unit].dga; adder = (struct adder *) qdmap[unit].adder; dga->csr &= ~DMA_IE; dga->csr &= ~0x0600; /* halt the DMA! (just in case...) */ dga->csr |= DMA_ERR; /* clear error condition */ adder->command = CANCEL; /* if DMA was running, flush spurious intrpt */ if (dga->bytcnt_lo != 0) { dga->bytcnt_lo = 0; dga->bytcnt_hi = 0; DMA_SETIGNORE(DMAheader[unit]); dga->csr |= DMA_IE; dga->csr &= ~DMA_IE; } init_shared(unit); /* init shared memory */ setup_dragon(unit); /* init ADDER/VIPER */ ldcursor(unit, cons_cursor); /* load default cursor map */ setup_input(unit); /* init the DUART */ ldfont(unit); cursor[unit].x = 0; cursor[unit].y = 0; /* shut off the mouse rcv intrpt and turn on kbd intrpts */ duart = (struct duart *) qdmap[unit].duart; qdflags[unit].duart_imask &= ~(0x20); qdflags[unit].duart_imask |= 0x02; duart->imask = qdflags[unit].duart_imask; /*----------------------------------------- * shut off interrupts if all is closed */ if (!(qdflags[unit].inuse & (CONS_DEV | ALTCONS_DEV))) { dga = (struct dga *) qdmap[unit].dga; dga->csr &= ~(GLOBAL_IE | DMA_IE); } }/*----------------------------------------------------* if this is the console or the alternate console */ else { tp = &qd_tty[minor_dev]; (*linesw[tp->t_line].l_close)(tp); ttyclose(tp); 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; qdflags[unit].inuse &= ~CONS_DEV; q_keyboard.cntrl = q_keyboard.shift = 0; /*------------------------------------------------- * if graphics device is closed, kill interrupts */ if (!(qdflags[unit].inuse & GRAPHIC_DEV)) { dga = (struct dga *) qdmap[unit].dga; dga->csr &= ~(GLOBAL_IE | DMA_IE); } }/*--------* exit */ return(0);} /* qdclose *//***************************************************************** qdioctl()... provide QDSS control services******************************************************************* calling convention: qdioctl(dev, cmd, datap, flags);** where: dev - the major/minor device number* cmd - the user-passed command argument* datap - ptr to user input buff (128 bytes max)* flags - "f_flags" from "struct file" in file.h*** - here is the format for the input "cmd" argument** 31 29 28 23 22 16 15 8 7 0* +----------------------------------------------------------------+* |I/O type| | buff length | device ID char | user command |* +----------------------------------------------------------------+** Return data is in the data buffer pointed to by "datap" input spec**********************/qdioctl(dev, cmd, datap, flags)dev_t dev;int cmd;caddr_t datap;int flags;{ register int *ptep; /* page table entry pointer */ register int mapix; /* QMEMmap[] page table index */ register struct _vs_event *event; register struct tty *tp; struct qdmap *qd; /* pointer to device map struct */ struct dga *dga; /* Gate Array reg structure pntr */ struct duart *duart; /* DUART reg structure pointer */ struct adder *adder; /* ADDER reg structure pointer */ struct prgkbd *cmdbuf; struct prg_cursor *curs; struct _vs_cursor *pos; u_int unit = minor(dev) >> 2; /* number of caller's QDSS */ u_int minor_dev = minor(dev); struct uba_device *ui = qdinfo[unit]; struct qd_softc *sc = &qd_softc[ui->ui_unit]; struct devget *devget; int error; int s; int i; /* SIGNED index */ int sbr; /* SBR variable (you silly boy) */ u_int ix; short status; short *shortp; /* generic pointer to a short */ char *chrp; /* generic character pointer */ short *temp; /* a pointer to template RAM *//*-----------------------------------------* service graphic device ioctl commands */ switch (cmd) { /*------------------------------------------------- * extract the oldest event from the event queue */ case QD_GETEVENT: if (ISEMPTY(eq_header[unit])) { event = (struct _vs_event *) datap; event->vse_device = VSE_NULL; break; } event = (struct _vs_event *) GETBEGIN(eq_header[unit]); s = spl5(); GETEND(eq_header[unit]); splx(s); bcopy(event, datap, sizeof(struct _vs_event)); break; /*------------------------------------------------------- * init the dragon stuff, DUART, and driver variables */ case QD_RESET: init_shared(unit); /* init shared memory */ setup_dragon(unit); /* init the ADDER/VIPER stuff */ clear_qd_screen(unit); ldcursor(unit, cons_cursor); /* load default cursor map */ ldfont(unit); /* load the console font */ setup_input(unit); /* init the DUART */ break; /*---------------------------------------- * init the DUART and driver variables */ case QD_SET: init_shared(unit); setup_input(unit); break; /*--------------------------------------------------------------- * clear the QDSS screen. (NOTE that this reinits the dragon) */ case QD_CLRSCRN: setup_dragon(unit); clear_qd_screen(unit); break; /*------------------------------------ * load a cursor into template RAM */ case QD_WTCURSOR: ldcursor(unit, datap); break; case QD_RDCURSOR: temp = (short *) qdmap[unit].template; /* cursor is 32 WORDS from the end of the 8k WORD... * ...template space */ temp += (8 * 1024) - 32; for (i = 0; i < 32; ++i, datap += sizeof(short)) *(short *)datap = *temp++; break; /*------------------------------ * position the mouse cursor */ case QD_POSCURSOR: dga = (struct dga *) qdmap[unit].dga; pos = (struct _vs_cursor *) datap; s = spl5(); dga->x_cursor = TRANX(pos->x); dga->y_cursor = TRANY(pos->y); eq_header[unit]->curs_pos.x = pos->x; eq_header[unit]->curs_pos.y = pos->y; splx(s); break; /*-------------------------------------- * set the cursor acceleration factor */ case QD_PRGCURSOR: curs = (struct prg_cursor *) datap; s = spl5(); qdflags[unit].curs_acc = curs->acc_factor; qdflags[unit].curs_thr = curs->threshold; splx(s); break; /*--------------------------------------- * enable 'user write' to device pages */ case QD_MAPDEVICE: /*-------------- * init stuff */ qdflags[unit].mapped |= MAPDEV; qd = (struct qdmap *) &qdmap[unit]; /*------------------------------------- * enable user write to template RAM */ mapix = VTOP((int)qd->template) - VTOP(qmem[0]); ptep = (int *)(QMEMmap[0] + mapix); for (i = VTOP(TMPSIZE); i > 0; --i) *ptep++ = (*ptep & ~PG_PROT) | PG_UW | PG_V; /*---------------------------------- * enable user write to registers */ mapix = VTOP((int)qd->adder) - VTOP(qmem[0]); ptep = (int *)(QMEMmap[0] + mapix); for (i = VTOP(REGSIZE); i > 0; --i) *ptep++ = (*ptep & ~PG_PROT) | PG_UW | PG_V; /*----------------------------------- * enable user write to color maps */ mapix = VTOP((int)qd->red) - VTOP(qmem[0]); ptep = (int *)(QMEMmap[0] + mapix); for (i = VTOP(CLRSIZE); i > 0; --i) *ptep++ = (*ptep & ~PG_PROT) | PG_UW | PG_V; /*------------------------------ * enable user write to DUART */ mapix = VTOP((int)qd->duart) - VTOP(qmem[0]); ptep = (int *)(QMEMmap[0] + mapix); *ptep = (*ptep & ~PG_PROT) | PG_UW | PG_V; /* duart page */ mtpr(TBIA, 0); /* smash CPU's translation buffer */ /*------------------------------------------ * stuff qdmap structure in return buffer */ bcopy(qd, datap, sizeof(struct qdmap)); break; /*------------------------------------- * do setup for DMA by user process */ case QD_MAPIOBUF: /*------------------------------------------------ * set 'user write enable' bits for DMA buffer */ qdflags[unit].mapped |= MAPDMA; ptep = (int *) ((VTOP(DMAheader[unit]) * 4) + (mfpr(SBR) | 0x80000000)); for (i = (DMAbuf_size >> PGSHIFT); i > 0; --i) *ptep++ = (*ptep & ~PG_PROT) | PG_UW | PG_V; mtpr(TBIA, 0); /* clr CPU translation buf */ /*------------------------------------- * set up QBUS map registers for DMA */ DMAheader[unit]->QBAreg = uballoc(0, DMAheader[unit], DMAbuf_size, 0); if (DMAheader[unit]->QBAreg == 0) mprintf("\nqd%d: qdioctl: QBA setup error", unit); Qbus_unmap[unit] = DMAheader[unit]->QBAreg; DMAheader[unit]->QBAreg &= 0x3FFFF; /*---------------------- * return I/O buf adr */ *(int *)datap = (int) DMAheader[unit]; break; /*---------------------------------------------------------------- * map the shared scroll param area and enable scroll interpts */ case QD_MAPSCROLL: qdflags[unit].mapped |= MAPSCR; ptep = (int *) ((VTOP(scroll[unit]) * 4) + (mfpr(SBR) | 0x80000000));
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -