📄 cons.c
字号:
if (tp->t_state&TS_ISOPEN) { if (tp->t_iflag & ISTRIP) c &= 0177; else { c &= CHAR_MASK; /* If ISTRIP is not set a valid character of 377 * is read as 0377,0377 to avoid ambiguity with * the PARMARK sequence. */ if ((c == 0377) && (tp->t_line == TERMIODISC)) chrqueue(linesw[tp->t_line].l_rint, c, tp); } chrqueue(linesw[tp->t_line].l_rint, c, tp); }}/*ARGSUSED*/cnioctl(dev, cmd, addr, flag) dev_t dev; caddr_t addr;{ register int which = minor(dev); register struct tty *tp = &cons[which]; int error; error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, addr); if (error >= 0) return(error); error = ttioctl(tp, cmd, addr, flag);#ifdef VAX8200 if (error >= 0) { switch(cmd) { case TCSANOW: /* POSIX */ case TCSADRAIN: /* POSIX */ case TCSAFLUSH: /* POSIX */ case TCSETA: /* SVID */ case TCSETAW: /* SVID */ case TCSETAF: /* SVID */ case TIOCSETP: /* Berkeley */ case TIOCSETN: /* Berkeley */ cnparam(which); /* set speed */ break; } }#endif if (error < 0) error = ENOTTY; return (error);}/* * Got a level-20 transmission interrupt - * the LSI wants another character. First, * see if we can send something to the typewriter. * If not, try the floppy. *//*ARGSUSED*/int didsendit;cnxint(dev) dev_t dev;{ register int which = minor(dev); register struct tty *tp = &cons[which]; register int i;#if defined(VAX8600) || defined(VAX9000) if(cpu == VAX_8600 || cpu == VAX_9000) { int k; /* See if a mask update is needed... */ if(mask_update_needed) { int s = spl5(); k = mfpr(txcs[0]); if(k & TXCS_RDY) { mtpr(txcs[0], (k & ~ALLCONS)|WMASKNOW|new_mask); mask_update_needed = 0; splx(s); return; } splx(s); } /* see who interrupted us */ k = mfpr(txcs[0]); if((k&NO_LINES) == NO_LINES) return; tp = &cons[(k>>8)&0x3]; which = tp - &cons[0]; }#endif#ifdef VAX8800 if ((cpu == VAX_8800) || (cpu == VAX_8820)) { txcs8800ie=0; mtpr(TXCS, 0); /* disable transmit interrupts */ if (rx8800ie) { int rx8800_trans(); chrqueue(rx8800_trans,0, 0); return; } for(i=0;i < 3;i++) { if (tty8800rec[i] == 0 ) { tp = &cons[i]; if (tp->t_state&TS_ISOPEN) { tp->t_state &= ~TS_BUSY; if (tp->t_line) (*linesw[tp->t_line].l_start)(tp); else cnstart(tp); if (txcs8800ie) return; } } } } else {#endif /*If the line is open & no chance of it being the 780 floppy*/ if((tp->t_state&TS_ISOPEN) || (cpu == VAX_780)) { tp->t_state &= ~TS_BUSY; if (tp->t_line) (*linesw[tp->t_line].l_start)(tp); else cnstart(tp); }#ifdef VAX8800 }#endif VAX8800}int cn_cnoutput_pending;cnstart(tp) register struct tty *tp;{ register int c, s; register int which; int cnoutput(); /* Dont queue it up if we don't have to */ if (((cpu == VAX_8800) || (cpu == VAX_8820)) && txcs8800ie) return; if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) goto out; if (tp->t_outq.c_cc <= TTLOWAT(tp)) { if (tp->t_state&TS_ASLEEP) { tp->t_state &= ~TS_ASLEEP; wakeup((caddr_t)&tp->t_outq); } if (tp->t_wsel) { selwakeup(tp->t_wsel, tp->t_state & TS_WCOLL); tp->t_wsel = 0; tp->t_state &= ~TS_WCOLL; } } if (tp->t_outq.c_cc == 0) goto out; which = tp - &cons[0];#if defined(VAX8600) || defined(VAX9000) if((cpu == VAX_8600) || (cpu == VAX_9000)) { if(consid[which] == LOGIC_CONS_ID) { char *cp = tp->t_outq.c_cf; if(cpu == VAX_9000) { /* Logical console device not supported for * Aquarius. We should never even TRY to * use it (since cnopen doesn't allow * its use...) */ panic("No logical console on VAX 9000"); } /* Hunt for any valid command else throw them away */ while ((*cp != GETSTAT) && (*cp != INVAL_1) && (*cp != INVAL_2)) { if(getc(&tp->t_outq) == NULL) return; /* Peek at next character */ cp = tp->t_outq.c_cf; } } if((mfpr(txcs[0])&conson[which]) != conson[which]) { cnenable_8600_9000(conson[which], 0); return; } }#endif VAX8600 || VAX9000 if (cn_cnoutput_pending == 0) { txcs8800ie=1; cn_cnoutput_pending = 1; chrqueue(cnoutput, tp, which); } return;out:#if defined(VAX8600) || defined(VAX9000) if (cpu == VAX_8600 || cpu == VAX_9000) { which = tp - &cons[0]; if (tp->t_state & (TS_TIMEOUT|TS_BUSY)) if((tp->t_state&TS_TTSTOP) == 0) return; cndisable_8600_9000(conson[which], 0); }#endif#ifdef VAX780 /* I think this is impossible right here but I'm making sure */ if ((cpu == VAX_780) && ((tp->t_state&TS_BUSY) == 0)) { /* floppy */ conxfl(); /* so start floppy xfer */ }#endif ;}cnoutput(tp, which)register struct tty *tp;register int which;{ register int c,s,whichcons = which;#if defined(VAX8600) || defined(VAX8800) || defined(VAX9000) if (cpu == VAX_8600 || cpu == VAX_8800 || cpu == VAX_8820 || cpu == VAX_9000) whichcons = 0;#endif s = spl5(); cn_cnoutput_pending=0; if ((cpu == VAX_8800) || (cpu == VAX_8820)) { txcs8800ie=1; mtpr(TXCS,TXCS_IE); }retry: if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) goto out; if (tp->t_outq.c_cc <= TTLOWAT(tp)) { if (tp->t_state&TS_ASLEEP) { tp->t_state &= ~TS_ASLEEP; wakeup((caddr_t)&tp->t_outq); } if (tp->t_wsel) { selwakeup(tp->t_wsel, tp->t_state & TS_WCOLL); tp->t_wsel = 0; tp->t_state &= ~TS_WCOLL; } } if (tp->t_outq.c_cc == 0) goto out;#if defined(VAX8600) || defined(VAX9000) if(cpu == VAX_8600 || cpu == VAX_9000) { int k; /* We can't do anything if the console isn't ready for us * (it may not be if there's output taking place on the * other line, f'rinstance...) */ k = mfpr(txcs[0]); if((k & TXCS_RDY) == 0) { splx(s); return; } /* If this line is not enabled, then enable it. */ if((k & conson[which]) != conson[which]) { mtpr(txcs[0], k | WMASKNOW | conson[which]); splx(s); return; } /* If the console buffer that's currently available * is different than the one we're prepared to send * to, see if there's any work to do on the available * line... */ if((k & NO_LINES) != consid[which]) { which = (k >> 8) & 3; tp = &cons[which]; goto retry; } }#endif VAX8600 || VAX9000 c = getc(&tp->t_outq); if ((tp->t_lflag_ext & PRAW) || (tp->t_oflag_ext & PLITOUT) || ((tp->t_oflag & OPOST) == 0)) { tp->t_state |= TS_BUSY; c &= CHAR_MASK;#ifdef VAX8800 if ((cpu == VAX_8800) || (cpu == VAX_8820)) c |= consid8800[which];#endif VAX8800 mtpr(txdb[whichcons], c); } else if ((c & DELAY_FLAG) == 0) { if ((tp->t_cflag & CS8) != CS8) c &= 0177; else c &= CHAR_MASK; tp->t_state |= TS_BUSY;#ifdef VAX8800 if ((cpu == VAX_8800) || ( cpu == VAX_8820)) c |= consid8800[which];#endif VAX8800 mtpr(txdb[whichcons], c); } else { tp->t_state |= TS_TIMEOUT; timeout(ttrstrt, (caddr_t)tp, (c&CHAR_MASK)); }out:#if defined(VAX8600) || defined(VAX9000) if (cpu == VAX_8600 || cpu == VAX_9000) { which = tp - &cons[0]; if (tp->t_state & (TS_TIMEOUT|TS_BUSY)) { if((tp->t_state&TS_TTSTOP) == 0) { splx(s); return; } } cndisable_8600_9000(conson[which], 0); }#endif#ifdef VAX780 if ((cpu == VAX_780) && ((tp->t_state&TS_BUSY) == 0)) { /* floppy */ conxfl(); /* so start floppy xfer */ }#endif splx(s);}/* * Print a character on console. * Attempts to save and restore device * status. */cnputc(c) register int c;{ register struct tty *tp; register int loopcnt,savetxcs,s, timo,data;#if defined(VAX8600) || defined(VAX9000) int oldtxcs;#endif VAX8600 || VAX9000#if defined (MVAX) || defined (VAX3600) || defined (VAX420) || defined (VAX60) extern (*v_consputc)();#endif MVAX || VAX3600 || VAX420 || VAX60 /* * Try waiting for the console tty to come ready, * otherwise give up after a reasonable time. */#if defined (MVAX) || defined (VAX3600) || defined (VAX420) || defined (VAX60) if( v_consputc ) { s=spl7(); (*v_consputc)( c ); if( c == '\n' ) (*v_consputc)( '\r' ); } else {#endif MVAX || VAX3600 || VAX420 || VAX60 /* make sure we do not lower IPL. Raise to ipl of the console interrupt routine */ if ((s = mfpr(IPL)) < SPLTTY) { s=spl5(); }#ifdef VAX8800 if ((cpu == VAX_8800) || (cpu == VAX_8820)) { timo = 600; while (((mfpr(RXCS) & RXCS_DONE) == 0) && (timo != 0)) --timo; loopcnt=0; while (((mfpr(RXCS) & RXCS_DONE) != 0) || tty8800rec[0]==1) { if (loopcnt++ > 20) { tty8800rec[0] = 0; break; } if (mfpr(RXCS) & RXCS_DONE) { data = mfpr(RXDB); if (cold==0) ka8800requeue(data); if ((data&0xf7f) == CSTOP) tty8800rec[0] = 1; if ((data&0xf7f) == CSTART) tty8800rec[0] = 0; } timo = 10000; while((--timo)!= 0){ if ((mfpr(RXCS) & RXCS_DONE) != 0) break; } } }#endif#if defined(VAX8600) || defined(VAX9000) if(cpu == VAX_8600 || cpu == VAX_9000) { timo = 30000; while ((mfpr(TXCS)&TXCS_RDY) == 0) if(--timo == 0) break; if (c == 0) { splx(s); return; } oldtxcs = mfpr(TXCS); mtpr(TXCS, (oldtxcs|WMASKNOW|conson[0])&~TXCS_IE); timo = 30000; }#endif VAX8600 || VAX9000 timo = 30000; while ((mfpr(TXCS)&TXCS_RDY) == 0) if(--timo == 0) break; if (c == 0) { splx(s); return; } if ((cpu != VAX_8800) && (cpu != VAX_8820) ){ savetxcs = mfpr(TXCS); mtpr(TXCS, 0); } mtpr(TXDB, c&0x7f); if (c == '\n') cnputc('\r'); cnputc(0); if ((cpu != VAX_8800) && (cpu != VAX_8820) &&(cpu != VAX_8600) && (cpu != VAX_9000)) mtpr(TXCS, savetxcs);#if defined(VAX8600) || defined(VAX9000) if(cpu == VAX_8600 || cpu == VAX_9000) mtpr(TXCS, oldtxcs|WMASKNOW);#endif#if defined (MVAX) || defined (VAX3600) || defined (VAX420) || defined (VAX60) }#endif MVAX || VAX3600 || VAX420 || VAX60 /* restore IPL...*/ splx(s);}#ifdef VAX8200#define INVALSP B4800static int cn_speeds[] = { INVALSP, INVALSP, INVALSP, INVALSP, INVALSP, 0x00000000, INVALSP, 0x00000200, 0x00000400, 0x00000600, INVALSP, 0x00000800, 0x00000a00, 0x00000c00, 0x00000e00, INVALSP};cnparam(which)int which;{ register struct tty *tp = &cons[which]; if (cpu != VAX_8200) return; if (which == 0) return; /* Not brave enough to try this on the console right now! */ /* * Set speed according to input speed specification. */ if((tp->t_cflag&CBAUD) <= 0 || (tp->t_cflag&CBAUD) > 16) { tp->t_cflag &= ~CBAUD; tp->t_cflag_ext &= ~CBAUD; tp->t_cflag |= DEFAULTSPEED; tp->t_cflag_ext |= DEFAULTSPEED; } /* Match up input & output speeds */ if((tp->t_cflag&CBAUD) != (tp->t_cflag_ext&CBAUD)) { tp->t_cflag_ext &= ~CBAUD; tp->t_cflag_ext |= tp->t_cflag&CBAUD; } if(cn_speeds[(tp->t_cflag & CBAUD)] != INVALSP) { mtpr(txcs[which], ((mfpr(txcs[which])&~0xf00)| (cn_speeds[(tp->t_cflag & CBAUD)]|TXCS_BRE))); }}#endif#if defined(VAX8600) || defined(VAX9000)cnenable_8600_9000(whichcons, flags){ int s = spl5(); int k = mfpr(txcs[0]); if(k & TXCS_RDY) { mtpr(txcs[0], k | WMASKNOW | whichcons | flags); } else { /* The console isn't ready for this update yet... * Squirrel away the new value of the mask, * and we'll update it when the next interrupt * comes in. */ new_mask = (k & ALLCONS) | whichcons | flags; mask_update_needed = 1; } splx(s);}cndisable_8600_9000(whichcons, flags){ int s = spl5(); int k = mfpr(txcs[0]); if(k & TXCS_RDY) { mtpr(txcs[0], (k | WMASKNOW | flags) &~ whichcons); } else { /* The console isn't ready for this update yet... * Squirrel away the new value of the mask, * and we'll update it when the next interrupt * comes in. */ new_mask = ((k & ALLCONS) | flags) &~ whichcons; mask_update_needed = 1; } splx(s);}#endif /* VAX8600 || VAX9000 */#ifdef VAX9000/* Drop the connection on the remote console line. */cons9000_tty_drop(tp)struct tty *tp;{ if (tp->t_flags&NOHANG) return; tp->t_state &= ~(TS_CARR_ON|TS_TTSTOP|TS_BUSY|TS_ISUSP); wakeup((caddr_t)&tp->t_rawq); gsignal(tp->t_pgrp, SIGHUP); gsignal(tp->t_pgrp, SIGCONT);}#endif VAX9000
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -