|
|
1.1 ! root 1: /* vcuiin.c -- vcuiin, verase1, veputc, vechoch */ ! 2: ! 3: #include <conf.h> ! 4: #include <kernel.h> ! 5: #include <tty.h> ! 6: #include <io.h> ! 7: #include <vcu.h> ! 8: #include <procreg.h> ! 9: ! 10: /*------------------------------------------------------------------------ ! 11: * vcuiin -- lower-half vcu device driver for input interrupts ! 12: *------------------------------------------------------------------------ ! 13: */ ! 14: INTPROC vcuiin(iptr) ! 15: register struct tty *iptr; /* pointer to tty block */ ! 16: { ! 17: register int ch, ct; ! 18: ! 19: ch = mfpr(RXDB) & VCUICHMASK; /* read char from device*/ ! 20: if (ch & VCURERMASK) ! 21: return; /* discard if error */ ! 22: if (iptr->imode == IMRAW) { ! 23: if (scount(iptr->isem) >= IBUFLEN) { ! 24: return; /* discard if no space */ ! 25: } ! 26: iptr->ibuff[iptr->ihead++] = ch; ! 27: if (iptr->ihead >= IBUFLEN) /* wrap buffer pointer */ ! 28: iptr->ihead = 0; ! 29: signal(iptr->isem); ! 30: } else { /* cbreak | cooked mode */ ! 31: if ( ch == RETURN && iptr->icrlf ) ! 32: ch = NEWLINE; ! 33: if (iptr->iintr && ch == iptr->iintrc) { ! 34: send(iptr->iintpid, INTRMSG); ! 35: veputc(ch, iptr); ! 36: return; ! 37: } ! 38: if (iptr->oflow) { ! 39: if (ch == iptr->ostart) { ! 40: iptr->oheld = FALSE; ! 41: mtpr(VCUTXCSENBL, TXCS); ! 42: return; ! 43: } ! 44: if (ch == iptr->ostop) { ! 45: iptr->oheld = TRUE; ! 46: return; ! 47: } ! 48: } ! 49: iptr->oheld = FALSE; ! 50: if (iptr->imode == IMCBREAK) { /* cbreak mode */ ! 51: if (scount(iptr->isem) >= IBUFLEN) { ! 52: veputc(iptr->ifullc,iptr); ! 53: return; ! 54: } ! 55: iptr->ibuff[iptr->ihead++] = ch; ! 56: if (iptr->ihead >= IBUFLEN) ! 57: iptr->ihead = 0; ! 58: if (iptr->iecho) ! 59: vechoch(ch,iptr); ! 60: if (scount(iptr->isem) < IBUFLEN) ! 61: signal(iptr->isem); ! 62: } else { /* cooked mode */ ! 63: if (ch == iptr->ikillc && iptr->ikill) { ! 64: iptr->ihead -= iptr->icursor; ! 65: if (iptr->ihead < 0) ! 66: iptr->ihead += IBUFLEN; ! 67: iptr->icursor = 0; ! 68: veputc(RETURN,iptr); ! 69: veputc(NEWLINE,iptr); ! 70: return; ! 71: } ! 72: if (ch == iptr->ierasec && iptr->ierase) { ! 73: if (iptr->icursor > 0) { ! 74: iptr->icursor--; ! 75: verase1(iptr); ! 76: } ! 77: return; ! 78: } ! 79: if (ch == NEWLINE || ch == RETURN || ! 80: (iptr->ieof && ch == iptr->ieofc)) { ! 81: if (iptr->iecho) { ! 82: vechoch(ch,iptr); ! 83: if (ch == iptr->ieofc) ! 84: vechoch(NEWLINE,iptr); ! 85: } ! 86: iptr->ibuff[iptr->ihead++] = ch; ! 87: if (iptr->ihead >= IBUFLEN) ! 88: iptr->ihead = 0; ! 89: ct = iptr->icursor+1; /* +1 for \n or \r*/ ! 90: iptr->icursor = 0; ! 91: signaln(iptr->isem,ct); ! 92: return; ! 93: } ! 94: ct = scount(iptr->isem); ! 95: ct = ct < 0 ? 0 : ct; ! 96: if ((ct + iptr->icursor) >= IBUFLEN-1) { ! 97: veputc(iptr->ifullc,iptr); ! 98: return; ! 99: } ! 100: if (iptr->iecho) ! 101: vechoch(ch,iptr); ! 102: iptr->icursor++; ! 103: iptr->ibuff[iptr->ihead++] = ch; ! 104: if (iptr->ihead >= IBUFLEN) ! 105: iptr->ihead = 0; ! 106: } ! 107: } ! 108: } ! 109: ! 110: /*------------------------------------------------------------------------ ! 111: * verase1 -- erase one character honoring erasing backspace ! 112: *------------------------------------------------------------------------ ! 113: */ ! 114: LOCAL verase1(iptr) ! 115: struct tty *iptr; ! 116: { ! 117: char ch; ! 118: ! 119: if (--(iptr->ihead) < 0) ! 120: iptr->ihead += IBUFLEN; ! 121: ch = iptr->ibuff[iptr->ihead]; ! 122: if (iptr->iecho) { ! 123: if (ch < BLANK || ch == 0177) { ! 124: if (iptr->evis) { ! 125: veputc(BACKSP,iptr); ! 126: if (iptr->ieback) { ! 127: veputc(BLANK,iptr); ! 128: veputc(BACKSP,iptr); ! 129: } ! 130: } ! 131: veputc(BACKSP,iptr); ! 132: if (iptr->ieback) { ! 133: veputc(BLANK,iptr); ! 134: veputc(BACKSP,iptr); ! 135: } ! 136: } else { ! 137: veputc(BACKSP,iptr); ! 138: if (iptr->ieback) { ! 139: veputc(BLANK,iptr); ! 140: veputc(BACKSP,iptr); ! 141: } ! 142: } ! 143: } else ! 144: mtpr (VCUTXCSENBL, TXCS); ! 145: } ! 146: ! 147: /*------------------------------------------------------------------------ ! 148: * vechoch -- echo a character with visual and ocrlf options ! 149: *------------------------------------------------------------------------ ! 150: */ ! 151: LOCAL vechoch(ch, iptr) ! 152: char ch; /* character to echo */ ! 153: register struct tty *iptr; /* ptr to I/O block for this dev*/ ! 154: { ! 155: if ((ch==NEWLINE||ch==RETURN)&&iptr->ecrlf) { ! 156: veputc(RETURN,iptr); ! 157: veputc(NEWLINE,iptr); ! 158: } else if ((ch<BLANK||ch==0177) && iptr->evis) { ! 159: veputc(UPARROW,iptr); ! 160: veputc(ch+0100,iptr);/* make it printable */ ! 161: } else { ! 162: veputc(ch,iptr); ! 163: } ! 164: } ! 165: ! 166: /*------------------------------------------------------------------------ ! 167: * veputc - put one character in the echo queue ! 168: *------------------------------------------------------------------------ ! 169: */ ! 170: LOCAL veputc(ch,iptr) ! 171: char ch; ! 172: register struct tty *iptr; ! 173: { ! 174: iptr->ebuff[iptr->ehead++] = ch; ! 175: if (iptr->ehead >= EBUFLEN) ! 176: iptr->ehead = 0; ! 177: mtpr(VCUTXCSENBL, TXCS); ! 178: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.