📄 ss.c
字号:
*/ nxp = (char *)cpup->umaddr(0,0); nxaccess (nxp, QMEMmap[0], QMEMSIZEVS); nxp = (char *)NMEMVAXSTAR; if (cpu == C_VAXSTAR) { nxaccess (nxp, NMEMmap[0], NMEMSIZECVS); } else nxaccess (nxp, NMEMmap[0], NMEMSIZEVS); /* * TODO: * Following is place holder for color driver * Why map device if it is not present? */ nxp = (char *)SGMEMVAXSTAR; nxaccess (nxp, SGMEMmap[0], SGMEMSIZEVS); nxp = (char *)SHMEMVAXSTAR; nxaccess (nxp, SHMEMmap[0], SHMEMSIZEVS); ssaddr = (struct nb_regs *)nexus; /* * Map CVAXstar 2nd level cache data storage * Map CVAXstar SCSI registers */ if (cpu == C_VAXSTAR) { nxp = (char *)SZMEMCVAXSTAR; nxaccess (nxp, SZMEMmap[0], SZMEMSIZECVS); nxp = (char *)CVSCACHEADDR; nxaccess (nxp, CVSCACHEmap[0], CVSCACHESIZE); nxp = (char *)CVSEDDBADDR; nxaccess (nxp, CVSEDDBmap[0], CVSEDDBSIZE); /* NOTE: extended mode must always be enabled! */ ((struct nb1_regs *)qmem)->nb_stc_mode = (char)cvs_exmode_on; } /* * Calculate the physical address of system scratch RAM and * map the first three pages (used by the color driver). */ scr_ram_addr = (ssaddr->nb_scr[3] & 0x3FC) << 22; scr_ram_addr |= ((ssaddr->nb_scr[2] & 0x3FC) << 14); scr_ram_addr |= ((ssaddr->nb_scr[1] & 0x3FC) << 6); scr_ram_addr |= ((ssaddr->nb_scr[0] & 0x3FC) >> 2); nxp = (char *)scr_ram_addr; nxaccess (nxp, SGSYSmap[0], 3); /* * Determine console device and inititialize it. * If L3CON is set use the diagnostic console, * if not use the console_id from NVR or the CFGTST register MULTU bit, * if console_id says unknown we guess based on the * VIDOPT and CURTEST bits in the configuration register. * Order of precedence is: * Diagnostic console on SLU port 3 (BCC08 cable). * Terminal on SLU port 0 (if MULTU bit set). * Keyboard on SLU port 0 (color video, MULTU bit clear). * Keyboard on SLU port 0 (base monochrome video, MULTU bit clear). * The BCC08 cable enables halt on break. * * The VAXstar SLU is always present and must always be * initialized, even if the console is the bitmap or color * display. So, we inititialize it here. */ ssaddr->sscsr = SS_CLR; for(i=0; i<100000; i++) if((ssaddr->sscsr&SS_CLR) == 0) break; ssaddr->nb_int_msk &= ~(SINT_ST|SINT_SR); ssaddr->nb_int_reqclr = (SINT_ST|SINT_SR); ssaddr->sscsr = SS_MSE; i = (SS_RE | SS_B9600 | BITS8); if(vs_cfgtst&VS_L3CON) i |= 0x3; /* diag. console on line 3 */ ssaddr->sslpr = i; cdevsw[0] = cdevsw[SS_MAJOR]; constype = (ssaddr->nb_console_id >> 2) & 0xff; if ((vs_cfgtst&VS_L3CON) || (vs_cfgtst&VS_MULTU)) { v_consputc = ssputc; v_consgetc = ssgetc; } else { switch(constype) { case VS_CID_COLOR: sgcons_init(); break; case VS_CID_BITMAP: smcons_init(); break; case VS_CID_UNKNOWN: /* FALLTHROUGH */ default: if(vs_cfgtst&VS_VIDOPT) sgcons_init(); else if(vs_cfgtst&VS_CURTEST) smcons_init(); else { v_consputc = ssputc; v_consgetc = ssgetc; } break; } } vs_safe2print = 1; return(1);}/* * VAXstar SLU (dzq like) console putc routine. * Calls ss_putc() to output each character. */ssputc(c) register int c;{ ss_putc(c); if (c == '\n') ss_putc('\r');}/* * This routine outputs one character to the console * on line 0 or 3 depending on the state of L3CON * in the VAXstar configuration and test register. * Characters must be printed without disturbing * output in progress on other lines! * This routines works with the SLU in interrupt or * non-interrupt mode of operation. * Characters are output as follows: * spl5, remember if console line active. * set console line tcr bit. * wait for TRDY on console line (save status if wrong line). * start output of character. * wait for output complete. * if any lines were active, set their tcr bits, * otherwise clear the xmit ready interrupt. * *//* * Physical address of VAXstar "fake" nexus. * Used to access SLU and interrupt cntlr registers * when the machine is on physical mode (during crash dump). */#define VS_PHYSNEXUS 0x20080000ss_putc(c) register int c;{ register struct nb_regs *ssaddr; int s, tcr, ln, tln, timo; int physmode; if( (mfpr(MAPEN) & 1) == 0 ) { physmode = 1; ssaddr = (struct nb_regs *)VS_PHYSNEXUS; } else { /* * I/O space not mapped yet, can't print. */ if (vs_safe2print == 0) return; physmode = 0; ssaddr = (struct nb_regs *)nexus; } if(physmode == 0) s = spl5(); tln = (vs_cfgtst&VS_L3CON) ? 0x3 : 0x0; tcr = (ssaddr->sstcr & (1<<tln)); ssaddr->sstcr |= (1<<tln); while (1) { timo = 1000000; while ((ssaddr->sscsr&SS_TRDY) == 0) if(--timo == 0) break; if(timo == 0) break; ln = (ssaddr->sscsr>>8) & 3; if (ln != tln) { tcr |= (1 << ln); ssaddr->sstcr &= ~(1 << ln); continue; } ssaddr->sstbuf = c&0xff; while (1) { while ((ssaddr->sscsr&SS_TRDY) == 0) ; ln = (ssaddr->sscsr>>8) & 3; if (ln != tln) { tcr |= (1 << ln); ssaddr->sstcr &= ~(1 << ln); continue; } break; } break; } ssaddr->sstcr &= ~(1<<tln); if (tcr == 0) ssaddr->nb_int_reqclr = SINT_ST; else ssaddr->sstcr |= tcr; if(physmode == 0) splx(s);}/* * This routine operates on the following assumptions: * 1. putc must have happened first, so SLU already inited. * 2. getc will happed before slu reveive interrupt enabled so * don't need to worry about int_req or int_msk registers. */ssgetc(){ register struct nb_regs *ssaddr = (struct nb_regs *)nexus; register int c, line; /* * Line number we expect input from. */ if(vs_cfgtst&VS_L3CON) line = 3; else line = 0; while (1) { while ((ssaddr->sscsr&SS_RDONE) == 0) ; c = ssaddr->ssrbuf; if(((c >> 8) & 3) != line) /* wrong line mumber */ continue; if(c&(SS_DO|SS_FE|SS_PE)) /* error */ continue; break; } return(c & 0xff);}/* * Modem Control Routines *//* * * Function: * * ss_cd_drop * * Functional description: * * Determine if carrier has dropped. If so call ss_tty_drop to terminate * the connection. * * Arguements: * * register struct tty *tp - terminal pointer ( for terminal attributes ) * * Return value: * * none * */ss_cd_drop(tp)register struct tty *tp;{ register struct nb_regs *ssaddr = (struct nb_regs *)nexus; if ((tp->t_state&TS_CARR_ON) && ((ssaddr->ssmsr&SS_RCD) == 0)) {# ifdef DEBUG if (ssdebug) cprintf("ss_cd: no CD, tp=%x\n", tp);# endif DEBUG ss_tty_drop(tp); return; } ssmodem |= MODEM_CD;# ifdef DEBUG if (ssdebug) cprintf("ss_cd: CD is up, tp=%x\n", tp);# endif DEBUG}/* * * Function: * * ss_dsr_check * * Functional description: * * DSR must be asserted for a connection to be established. Here we either * start or terminate a connection on the basis of DSR. * * Arguements: * * register struct tty *tp - terminal pointer ( for terminal attributes ) * * Return value: * * none * */ss_dsr_check(tp)register struct tty *tp;{ register struct nb_regs *ssaddr = (struct nb_regs *)nexus;# ifdef DEBUG if (ssdebug) { cprintf("ss_dsr_check0: tp=%x\n", tp); PRINT_SIGNALS(); }# endif DEBUG if (ssmodem&MODEM_DSR_START) { ssmodem &= ~MODEM_DSR_START; /* * If ssdsr is set look for DSR|CTS|CD, otherwise look * for CD|CTS only. * * If cpu is PVAX then don't bother looking at CD or CTS, * just let the connection continue. */ if (ssdsr) { if ((!ss_modem_ctl) || ((ssaddr->ssmsr&SS_XMIT) == SS_XMIT)) ss_start_tty(tp); } else { if ((ssaddr->ssmsr&SS_NODSR) == SS_NODSR) ss_start_tty(tp); } return; } if ((tp->t_state&TS_CARR_ON)==0) ss_tty_drop(tp);}/* * * Function: * * ss_cd_down * * Functional description: * * Determine whether or not carrier has been down for > 2 sec. * * Arguements: * * register struct tty *tp - terminal pointer ( for terminal attributes ) * * Return value: * * 1 - if carrier was down for > 2 sec. * 0 - if carrier down <= 2 sec. * */ss_cd_down(tp)struct tty *tp;{ int msecs; msecs = 1000000 * (time.tv_sec - sstimestamp.tv_sec) + (time.tv_usec - sstimestamp.tv_usec); if (msecs > 2000000){# ifdef DEBUG if (ssdebug) cprintf("ss_cd_down: msecs > 20000000\n");# endif DEBUG return(1); } else{# ifdef DEBUG if (ssdebug) cprintf("ss_cd_down: msecs < 20000000\n");# endif DEBUG return(0); }}/* * * Function: * * ss_tty_drop * * Functional description: * * Terminate a connection. * * Arguements: * * register struct tty *tp - terminal pointer ( for terminal attributes ) * * Return value: * * none * */ss_tty_drop(tp)struct tty *tp;{ register struct nb_regs *ssaddr = (struct nb_regs *)nexus; if (tp->t_flags&NOHANG) return;# ifdef DEBUG if (ssdebug) cprintf("ss_tty_drop: unit=%d\n",minor(tp->t_dev));# endif DEBUG /* * Notify any processes waiting to open this line. Useful in the * case of a false start. */ ssmodem = MODEM_BADCALL; 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); ssaddr->ssdtr &= ~(SS_RDTR|SS_RRTS);}/* * * Function: * * ss_start_tty * * Functional description: * * Establish a connection. * * Arguements: * * register struct tty *tp - terminal pointer ( for terminal attributes ) * * Return value: * * none * */ss_start_tty(tp) register struct tty *tp;{ tp->t_state &= ~(TS_ONDELAY); tp->t_state |= TS_CARR_ON;# ifdef DEBUG if (ssdebug) cprintf("ss_start_tty: tp=%x\n", tp);# endif DEBUG if (ssmodem&MODEM_DSR) untimeout(ss_dsr_check, tp); ssmodem |= MODEM_CD|MODEM_CTS|MODEM_DSR; sstimestamp.tv_sec = sstimestamp.tv_usec = 0; wakeup((caddr_t)&tp->t_rawq);}ssbaudrate(speed)register int speed;{ if (ss_valid_speeds & (1 << speed)) return (1); else return (0);}void sssetbreak(tp)register struct tty *tp;{ wakeup((caddr_t)&tp->t_dev);}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -