static void echoscreen(char *buf, int n) { char *e, *p; char ebuf[128]; int x; p = ebuf; e = ebuf + sizeof(ebuf) - 4; while(n-- > 0){ if(p >= e){ screenputs(ebuf, p - ebuf); p = ebuf; } x = *buf++; if(x == 0x15){ *p++ = '^'; *p++ = 'U'; *p++ = '\n'; } else *p++ = x; } if(p != ebuf) screenputs(ebuf, p - ebuf); }
/* * Print a string on the console. Convert \n to \r\n for serial * line consoles. Locking of the queues is left up to the screen * or uart code. Multi-line messages to serial consoles may get * interspersed with other messages. */ static void putstrn0(char *str, int n, int usewrite) { if(!islo()) usewrite = 0; /* * how many different output devices do we need? */ kmesgputs(str, n); /* * if someone is reading /dev/kprint, * put the message there. * if not and there's an attached bit mapped display, * put the message there. * * if there's a serial line being used as a console, * put the message there. */ if(kprintoq != nil && !qisclosed(kprintoq)){ if(usewrite) qwrite(kprintoq, str, n); else qiwrite(kprintoq, str, n); }else if(screenputs != nil) screenputs(str, n); uartputs(str, n); #if 0 // Plan 9 VX if(serialoq == nil){ uartputs(str, n); return; } while(n > 0) { t = memchr(str, '\n', n); if(t && !kbd.raw) { m = t-str; if(usewrite){ qwrite(serialoq, str, m); qwrite(serialoq, "\r\n", 2); } else { qiwrite(serialoq, str, m); qiwrite(serialoq, "\r\n", 2); } n -= m+1; str = t+1; } else { if(usewrite) qwrite(serialoq, str, n); else qiwrite(serialoq, str, n); break; } } #endif }
void echo(Rune r, char *buf, int n) { if (kbd.raw) return; if (r == '\n') { if (printq) qiwrite(printq, "\r", 1); } else if (r == 0x15) { buf = "^U\n"; n = 3; } if (consoleprint && screenputs != NULL) screenputs(buf, n); if (printq) qiwrite(printq, buf, n); }
int iprint(char *fmt, ...) { int n, s; va_list arg; char buf[PRINTSIZE]; s = splhi(); va_start(arg, fmt); n = vseprint(buf, buf+sizeof(buf), fmt, arg) - buf; va_end(arg); if(screenputs != nil && iprintscreenputs) screenputs(buf, n); uartputs(buf, n); splx(s); return n; }
int iprint(char *fmt, ...) { int8_t s = 0; int n, locked; va_list arg; char buf[PRINTSIZE]; disable_irqsave(&s); va_start(arg, fmt); n = vsnprintf(buf, sizeof(buf), fmt, arg); va_end(arg); locked = iprintcanlock(&iprintlock); if (screenputs != NULL && iprintscreenputs) screenputs(buf, n); #if 0 uartputs(buf, n); #endif if (locked) spin_unlock(&iprintlock); enable_irqsave(&s); return n; }
/* * Print a string on the console. Convert \n to \r\n for serial * line consoles. Locking of the queues is left up to the screen * or uart code. Multi-line messages to serial consoles may get * interspersed with other messages. */ static void putstrn0(char *str, int n, int usewrite) { int m; char *t; char buf[PRINTSIZE + 2]; ERRSTACK(1); /* * if kprint is open, put the message there, otherwise * if there's an attached bit mapped display, * put the message there. */ m = consoleprint; if (canrlock(&(&kprintq)->rwlock)) { if (kprintq.q != NULL) { if (waserror()) { runlock(&(&kprintq)->rwlock); nexterror(); } if (usewrite) qwrite(kprintq.q, str, n); else qiwrite(kprintq.q, str, n); poperror(); m = 0; } runlock(&(&kprintq)->rwlock); } if (m && screenputs != NULL) screenputs(str, n); /* * if there's a serial line being used as a console, * put the message there. */ if (serwrite != NULL) { serwrite(str, n); return; } if (printq == 0) return; while (n > 0) { t = memchr(str, '\n', n); if (t && !kbd.raw) { m = t - str; if (m > sizeof(buf) - 2) m = sizeof(buf) - 2; memmove(buf, str, m); buf[m] = '\r'; buf[m + 1] = '\n'; if (usewrite) qwrite(printq, buf, m + 2); else qiwrite(printq, buf, m + 2); str = t + 1; n -= m + 1; } else { if (usewrite) qwrite(printq, str, n); else qiwrite(printq, str, n); break; } } }