sadly, omap has its own private cons. since i don't have an omap to help sort this out, the junk stays. Reference: /n/atom/patch/applied/omapconsfix Date: Wed Jun 18 20:41:43 CES 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/9/omap/devcons.c Wed Jun 18 20:41:28 2014 +++ /sys/src/9/omap/devcons.c Wed Jun 18 20:41:29 2014 @@ -5,6 +5,7 @@ #include "fns.h" #include "../port/error.h" #include "pool.h" + #include void (*consdebug)(void) = nil; @@ -100,8 +101,7 @@ */ struct { Lock lk; -// char buf[16384]; /* normal */ - char buf[256*1024]; /* for acpi debugging */ + char buf[16384]; uint n; } kmesg; @@ -145,9 +145,11 @@ { int m; char *t; + int (*qw)(Queue*, void*, int); - if(!islo()) - usewrite = 0; + qw = qwrite; + if(!islo() || !usewrite) + qw = qiwrite; /* * how many different output devices do we need? @@ -163,37 +165,25 @@ * 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) + if(kprintoq != nil && !qisclosed(kprintoq)) + qw(kprintoq, str, n); + else if(screenputs != nil) screenputs(str, n); 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); - } + qw(serialoq, str, m); + qw(serialoq, "\r\n", 2); n -= m+1; str = t+1; } else { - if(usewrite) - qwrite(serialoq, str, n); - else - qiwrite(serialoq, str, n); + qw(serialoq, str, n); break; } } @@ -246,7 +236,7 @@ for(i=0; i<1000; i++){ if(canlock(l)) return 1; - if(l->m == MACHP(m->machno)) + if(ownlock(l)) return 0; microdelay(100); } @@ -279,6 +269,7 @@ return n; } +#pragma profile 0 void panic(char *fmt, ...) { @@ -288,9 +279,8 @@ kprintoq = nil; /* don't try to write to /dev/kprint */ - if(panicking) + if(ainc(&panicking)>1) for(;;); - panicking = 1; delay(20); s = splhi(); @@ -309,6 +299,7 @@ exit(1); } +#pragma profile 1 /* libmp at least contains a few calls to sysfatal; simulate with panic */ void @@ -534,7 +525,7 @@ kbdputc(Queue*, int ch) { int i, n; - char buf[3]; + char buf[UTFmax]; Rune r; char *next; @@ -583,6 +574,7 @@ enum{ Qdir, Qbintime, + Qconfig, Qcons, Qconsctl, Qcputime, @@ -591,6 +583,7 @@ Qkprint, Qhostdomain, Qhostowner, + Qmach, Qnull, Qosversion, Qpgrpid, @@ -604,6 +597,7 @@ Qtime, Quser, Qzero, + Qdebug, }; enum @@ -614,6 +608,7 @@ static Dirtab consdir[]={ ".", {Qdir, 0, QTDIR}, 0, DMDIR|0555, "bintime", {Qbintime}, 24, 0664, + "config", {Qconfig}, 0, 0440, "cons", {Qcons}, 0, 0660, "consctl", {Qconsctl}, 0, 0220, "cputime", {Qcputime}, 6*NUMSIZE, 0444, @@ -622,6 +617,7 @@ "hostowner", {Qhostowner}, 0, 0664, "kmesg", {Qkmesg}, 0, 0440, "kprint", {Qkprint, 0, QTEXCL}, 0, DMEXCL|0440, + "mach", {Qmach}, 0, 0444, "null", {Qnull}, 0, 0666, "osversion", {Qosversion}, 0, 0444, "pgrpid", {Qpgrpid}, NUMSIZE, 0444, @@ -635,6 +631,7 @@ "time", {Qtime}, NUMSIZE+3*VLNUMSIZE, 0664, "user", {Quser}, 0, 0666, "zero", {Qzero}, 0, 0444, + "debug", {Qdebug}, 0, 0444, }; int @@ -757,6 +754,7 @@ char tmp[256]; /* must be >= 18*NUMSIZE (Qswap) */ int i, k, id, send; vlong offset = off; + extern char configfile[]; if(n <= 0) return n; @@ -765,6 +763,9 @@ case Qdir: return devdirread(c, buf, n, consdir, nelem(consdir), devgen); + case Qconfig: + return readstr((ulong)offset, buf, n, configfile); + case Qcons: qlock(&kbd); if(waserror()) { @@ -785,8 +786,11 @@ }else{ switch(ch){ case '\b': - if(kbd.x > 0) - kbd.x--; + i = kbd.x; + b = kbd.line; + while(i > 0 && (b[--i]&0xc0) == 0x80) + ; + kbd.x = i; break; case 0x15: /* ^U */ kbd.x = 0; @@ -870,6 +874,9 @@ case Quser: return readstr((ulong)offset, buf, n, up->user); + case Qmach: + return readnum((ulong)offset, buf, n, m->machno, NUMSIZE); + case Qnull: return 0; @@ -968,6 +975,16 @@ n = readstr((ulong)offset, buf, n, tmp); return n; + case Qdebug: + // s = seprint(s, e, "locks %llud\n", lockstats.locks); + // s = seprint(s, e, "glare %llud\n", lockstats.glare); + // s = seprint(s, e, "inglare %llud\n", lockstats.inglare); + // s = seprint(s, e, "qlock %llud\n", qlockstats.qlock); + // s = seprint(s, e, "qlockq %llud\n", qlockstats.qlockq); + qiostats(tmp, tmp+sizeof tmp); + return readstr(offset, buf, n, tmp); + break; + default: print("consread %#llux\n", c->qid.path); error(Egreg); @@ -992,6 +1009,10 @@ offset = off; switch((ulong)c->qid.path){ + case Qconfig: + error(Eperm); + break; + case Qcons: /* * Can't page fault in putstrn, so copy the data locally. @@ -1050,6 +1071,9 @@ case Quser: return userwrite(a, n); + case Qmach: + break; + case Qnull: break; @@ -1071,7 +1095,6 @@ rebootcmd(cb->nf-1, cb->f+1); break; case CMpanic: - *(ulong*)0=0; panic("/dev/reboot"); } poperror();