|
|
1.1 root 1: /* ttywrite.c - ttywrite, writcopy */
2:
3: #include <conf.h>
4: #include <kernel.h>
5: #include <tty.h>
6: #include <io.h>
1.1.1.2 ! root 7: /* set up macros for appropriate SLU as spec. by SLUCHIP:
! 8: if SLUCHIP==6850, #include slu6850.h, #define TTYWRITE ttywrite6850, etc.
! 9: if SLUCHIP==7201, #include slu7201.h, #define TTYWRITE ttywrite7201, etc.
! 10: if SLUCHIP undef.,#include slu.h, #define TTYWRITE ttywrite (orig. case)
! 11: similarly sluaccess.h, other TTY fns */
! 12: #include <sluinclude.h>
1.1 root 13:
14: /*------------------------------------------------------------------------
15: * ttywrite - write one or more characters to a tty device
16: *------------------------------------------------------------------------
17: */
1.1.1.2 ! root 18: TTYWRITE(devptr,buff,count)
! 19: register struct devsw *devptr;
! 20: register char *buff;
! 21: register int count;
1.1 root 22: {
1.1.1.2 ! root 23: register struct csr *cptr;
1.1 root 24: register struct tty *ttyp;
1.1.1.2 ! root 25: int avail;
1.1 root 26:
27: ttyp = &tty[devptr->dvminor];
1.1.1.2 ! root 28: cptr = (struct csr *)devptr->dvcsr;
! 29:
! 30: disable();
! 31: if ( (avail=scount(ttyp->osem)) > count) {
! 32: writcopy(buff, ttyp, count);
! 33: } else {
! 34: writcopy(buff, ttyp, avail);
! 35: buff += avail;
! 36: for (count-=avail ; count>0 ; count--)
! 37: TTYPUTC(devptr, *buff++);
! 38: }
! 39: slutenable(cptr); /* enable transmitter ints */
! 40: restore();
1.1 root 41: return(OK);
42: }
43:
44: /*------------------------------------------------------------------------
45: * writcopy - high-speed copy from user's buffer into system buffer
46: *------------------------------------------------------------------------
47: */
48: LOCAL writcopy(buff, ttyp, count)
1.1.1.2 ! root 49: register char *buff;
! 50: register struct tty *ttyp;
! 51: register int count;
1.1 root 52: {
1.1.1.2 ! root 53: register char *qhead, *qend, *uend;
1.1 root 54:
55: qhead = &ttyp->obuff[ttyp->ohead];
56: qend = &ttyp->obuff[OBUFLEN];
57: uend = buff + count;
1.1.1.2 ! root 58: while (buff < uend) {
! 59: *qhead++ = *buff++;
1.1 root 60: if ( qhead >= qend )
61: qhead = ttyp->obuff;
1.1.1.2 ! root 62: }
! 63: ttyp->ohead = qhead - ttyp->obuff;
! 64: sreset(ttyp->osem, scount(ttyp->osem)-count);
1.1 root 65: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.