/*------------------------------------------------------------------------ * ttyputc - write one character to a tty device *------------------------------------------------------------------------ */ int ttyputc(struct devsw *devptr, unsigned char ch) { STATWORD ps; struct tty *iptr; iptr = &tty[devptr->dvminor]; if ( ch==NEWLINE && iptr->ocrlf ) ttyputc(devptr,RETURN); disable(ps); wait(iptr->osem); /* wait for space in queue */ iptr->obuff[iptr->ohead++] = ch; ++iptr->ocnt; if (iptr->ohead >= OBUFLEN) iptr->ohead = 0; *USART[iptr->unit].UCSRB |= (1<<UDRIE0); /*ttyostart(iptr);*/ restore(ps); return(OK); }
//------------------------------------------------------------------------ // ttywrite - write one or more characters to a tty device //------------------------------------------------------------------------ int ttywrite(struct devsw *devptr, char *buff, int count) { struct tty *ttyp; int ncopied; int ps; if (count < 0) return SYSERR; if (count == 0) return OK; ps = disable(); ttyp = &tty[devptr->minor]; count -= (ncopied = writecopy(buff, ttyp, count)); buff += ncopied; for (; count > 0; count--) ttyputc(devptr, *buff++); restore(ps); return OK; }
/*------------------------------------------------------------------------ * ttywrite - write one or more characters to a tty device *------------------------------------------------------------------------ */ int ttywrite(struct devsw *devptr, unsigned char *buff, int count) { STATWORD ps; register struct tty *ttyp; int ncopied; 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); return(OK); }