|
|
1.1 root 1: /* vcuwrite.c - vcuwrite, vwritecopy */
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: * vcuwrite - write one or more characters to the vax console device
12: *------------------------------------------------------------------------
13: */
14: vcuwrite(devptr, buff, count)
15: struct devsw *devptr;
16: char *buff;
17: int count;
18: {
19: register struct tty *ttyp;
20: int ncopied;
21: PStype ps;
22:
23: if (count < 0)
24: return(SYSERR);
25: if (count == 0)
26: return(OK);
27: disable(ps);
28: ttyp = &tty[devptr->dvminor];
29: count -= (ncopied = vwritcopy(buff, ttyp, count));
30: buff += ncopied;
31: for ( ; count>0 ; count--)
32: vcuputc(devptr, *buff++);
33: restore(ps);
34: return(OK);
35: }
36:
37: /*------------------------------------------------------------------------
38: * vwritcopy - high-speed copy from user's buffer into system buffer
39: *------------------------------------------------------------------------
40: */
41: LOCAL vwritcopy(buff, ttyp, count)
42: char *buff;
43: struct tty *ttyp;
44: int count;
45: {
46: register int avail;
47: register char *cp, *qhead, *qend, *uend;
48:
49: avail = scount(ttyp->osem);
50: qhead = &ttyp->obuff[ttyp->ohead];
51: qend = &ttyp->obuff[OBUFLEN];
52: cp = buff;
53: uend = buff + count;
54: while (avail-- > 1 && cp < uend) {
55: if (*cp == NEWLINE && ttyp->ocrlf) {
56: *qhead++ = RETURN;
57: --avail;
58: if ( qhead >= qend )
59: qhead = ttyp->obuff;
60: }
61: *qhead++ = *cp++;
62: if ( qhead >= qend )
63: qhead = ttyp->obuff;
64: } /* avail decremented one*/
65: ttyp->ohead = qhead - ttyp->obuff; /* extra time when loop */
66: sreset(ttyp->osem, ++avail); /* condition fails. */
67: mtpr (VCUTXCSENBL, TXCS);
68: return(cp - buff);
69: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.