--- xinu/sys/ttywrite.c 2018/04/24 17:39:04 1.1 +++ xinu/sys/ttywrite.c 2018/04/24 17:40:00 1.1.1.2 @@ -4,32 +4,40 @@ #include #include #include -#include +/* set up macros for appropriate SLU as spec. by SLUCHIP: + if SLUCHIP==6850, #include slu6850.h, #define TTYWRITE ttywrite6850, etc. + if SLUCHIP==7201, #include slu7201.h, #define TTYWRITE ttywrite7201, etc. + if SLUCHIP undef.,#include slu.h, #define TTYWRITE ttywrite (orig. case) + similarly sluaccess.h, other TTY fns */ +#include /*------------------------------------------------------------------------ * ttywrite - write one or more characters to a tty device *------------------------------------------------------------------------ */ -ttywrite(devptr, buff, count) -struct devsw *devptr; -char *buff; -int count; +TTYWRITE(devptr,buff,count) + register struct devsw *devptr; + register char *buff; + register int count; { + register struct csr *cptr; register struct tty *ttyp; - int ncopied; - PStype ps; + int avail; - if (count < 0) - return(SYSERR); - if (count == 0) - return(OK); - disable(ps); ttyp = &tty[devptr->dvminor]; - count -= (ncopied = writcopy(buff, ttyp, count)); - buff += ncopied; - for ( ; count>0 ; count--) - ttyputc(devptr, *buff++); - restore(ps); + cptr = (struct csr *)devptr->dvcsr; + + disable(); + if ( (avail=scount(ttyp->osem)) > count) { + writcopy(buff, ttyp, count); + } else { + writcopy(buff, ttyp, avail); + buff += avail; + for (count-=avail ; count>0 ; count--) + TTYPUTC(devptr, *buff++); + } + slutenable(cptr); /* enable transmitter ints */ + restore(); return(OK); } @@ -38,31 +46,20 @@ int count; *------------------------------------------------------------------------ */ LOCAL writcopy(buff, ttyp, count) -char *buff; -struct tty *ttyp; -int count; + register char *buff; + register struct tty *ttyp; + register int count; { - register int avail; - register char *cp, *qhead, *qend, *uend; + register char *qhead, *qend, *uend; - avail = scount(ttyp->osem); qhead = &ttyp->obuff[ttyp->ohead]; qend = &ttyp->obuff[OBUFLEN]; - cp = buff; uend = buff + count; - while (avail-- > 1 && cp < uend) { - if (*cp == NEWLINE && ttyp->ocrlf) { - *qhead++ = RETURN; - --avail; - if ( qhead >= qend ) - qhead = ttyp->obuff; - } - *qhead++ = *cp++; + while (buff < uend) { + *qhead++ = *buff++; if ( qhead >= qend ) qhead = ttyp->obuff; - } /* avail decremented one*/ - ttyp->ohead = qhead - ttyp->obuff; /* extra time when loop */ - sreset(ttyp->osem, ++avail); /* condition fails. */ - (ttyp->ioaddr)->ctstat = SLUENABLE; - return(cp - buff); + } + ttyp->ohead = qhead - ttyp->obuff; + sreset(ttyp->osem, scount(ttyp->osem)-count); }