@@ 1,7 1,7 @@
ulong bootcode[]={
0x000000107,
0x0000020fc,
- 0x000000410,
+ 0x000000418,
0x000000170,
0x000000000,
0x000002020,
@@ 29,7 29,7 @@ ulong bootcode[]={
0x061002096,
0x04a806d1e,
0x048780040,
- 0x0486e8542,
+ 0x0486e854a,
0x02f002f40,
0x0005c6100,
0x020862f2f,
@@ 59,34 59,34 @@ ulong bootcode[]={
0x000346100,
0x01ff8588f,
0x048780002,
- 0x0486e81ff,
+ 0x0486e8209,
0x06100200e,
0x04a8042e7,
0x02f40003a,
0x044df6c0a,
- 0x0486e8209,
+ 0x0486e8213,
0x061000390,
0x0588f4878,
0x00002486e,
- 0x0821b6100,
+ 0x082256100,
0x01fec2f40,
0x000444aaf,
0x000446c0a,
- 0x0486e8224,
+ 0x0486e822e,
0x061000370,
0x0588f486e,
- 0x082352f2f,
+ 0x0823f2f2f,
0x000486100,
0x00332486e,
- 0x0824a6100,
+ 0x082546100,
0x0042a2f2f,
0x000506100,
0x01f98486e,
- 0x082656100,
+ 0x0826f6100,
0x0041a422e,
- 0x084fa486f,
+ 0x08502486f,
0x0002c486e,
- 0x084fa6100,
+ 0x085026100,
0x0104e2f00,
0x02f40005c,
0x0486f0038,
@@ 94,7 94,7 @@ ulong bootcode[]={
0x061001fa4,
0x0b0af0064,
0x0670a486e,
- 0x0826c6100,
+ 0x082766100,
0x0031a588f,
0x04878001c,
0x0486f0044,
@@ 103,10 103,10 @@ ulong bootcode[]={
0x02f400070,
0x04aaf0070,
0x06e0a486e,
- 0x082766100,
+ 0x082806100,
0x002f6588f,
0x02f2f0070,
- 0x0486e84fa,
+ 0x0486e8502,
0x0486f0054,
0x06100179e,
0x04a806638,
@@ 119,23 119,23 @@ ulong bootcode[]={
0x0102f0064,
0x049c02f00,
0x02f2f008c,
- 0x0486e827f,
+ 0x0486e8289,
0x061000384,
- 0x0486e82a2,
+ 0x0486e82ac,
0x0610002ac,
0x04fef001c,
0x00c2e0001,
- 0x084fa670a,
- 0x0486e82ad,
+ 0x08502670a,
+ 0x0486e82b7,
0x061000298,
0x0588f486e,
- 0x082b66100,
+ 0x082c06100,
0x0035e1d7c,
- 0x0000284fa,
+ 0x000028502,
0x01d7c0076,
- 0x08504486f,
+ 0x0850c486f,
0x0005c486e,
- 0x084fa6100,
+ 0x085026100,
0x00f8a2f00,
0x02f40008c,
0x0486f0068,
@@ 143,7 143,7 @@ ulong bootcode[]={
0x061001ee0,
0x0b0af0094,
0x0670a486e,
- 0x082c16100,
+ 0x082cb6100,
0x00256588f,
0x04878001c,
0x0486f0074,
@@ 152,33 152,33 @@ ulong bootcode[]={
0x02f4000a0,
0x04aaf00a0,
0x06e0a486e,
- 0x082cf6100,
+ 0x082d96100,
0x00232588f,
0x02f2f00a0,
- 0x0486e84fa,
+ 0x0486e8502,
0x0486f0084,
0x0610016da,
0x04a80660a,
- 0x0486e82dc,
+ 0x0486e82e6,
0x061000214,
0x0588f0c2e,
- 0x0000384fa,
+ 0x000038502,
0x0670a486e,
- 0x082eb6100,
+ 0x082f56100,
0x00202588f,
- 0x04a6e84fe,
+ 0x04a6e8506,
0x0671c302e,
- 0x084fe48c0,
+ 0x0850648c0,
0x02f00486e,
- 0x082f86100,
- 0x002ba486e,
0x083026100,
+ 0x002ba486e,
+ 0x0830c6100,
0x001e24fef,
0x0000c486e,
- 0x0830f6100,
+ 0x083196100,
0x002a6486e,
- 0x0831d486e,
- 0x08317486f,
+ 0x08327486e,
+ 0x08321486f,
0x000946100,
0x003664878,
0x001b64878,
@@ 188,10 188,10 @@ ulong bootcode[]={
0x042e72f40,
0x000c244df,
0x06c0a486e,
- 0x083246100,
+ 0x0832e6100,
0x001a2588f,
0x02f2f00cc,
- 0x0486e832b,
+ 0x0486e8335,
0x0486f00ac,
0x061000330,
0x0486f00b0,
@@ 205,26 205,26 @@ ulong bootcode[]={
0x00e64588f,
0x0221fb280,
0x0670a486e,
- 0x0832e6100,
+ 0x083386100,
0x0015e588f,
0x02f2f00d8,
0x061001d9a,
- 0x0486e833a,
- 0x0486e8334,
+ 0x0486e8344,
+ 0x0486e833e,
0x0486f00c8,
0x0610002e4,
0x0487801b6,
0x048780001,
- 0x0486e8341,
+ 0x0486e834b,
0x061001d80,
0x04a8042e7,
0x02f4000f6,
0x044df6c0a,
- 0x0486e8349,
+ 0x0486e8353,
0x061000120,
0x0588f2f2f,
0x00100486e,
- 0x08350486f,
+ 0x0835a486f,
0x000e06100,
0x002ae486f,
0x000e46100,
@@ 237,44 237,44 @@ ulong bootcode[]={
0x061000de2,
0x0588f221f,
0x0b280670a,
- 0x0486e8353,
+ 0x0486e835d,
0x0610000dc,
0x0588f2f2f,
0x0010c6100,
0x01d18486e,
- 0x083596100,
+ 0x083636100,
0x0019a42a7,
- 0x0486e8364,
- 0x0486e8362,
+ 0x0486e836e,
+ 0x0486e836c,
0x061000dca,
0x04a806c0a,
- 0x0486e8366,
+ 0x0486e8370,
0x0610000b0,
0x0588f486e,
- 0x0836d4878,
+ 0x083774878,
0x00006486e,
- 0x0836b2f2f,
+ 0x083752f2f,
0x001386100,
0x01cfe4a80,
0x06c0a486e,
- 0x0836e6100,
+ 0x083786100,
0x0008e588f,
- 0x0486e8374,
+ 0x0486e837e,
0x061000154,
0x048780020,
- 0x0486e8542,
+ 0x0486e854a,
0x061000d48,
0x04a80671e,
0x042a7486e,
- 0x0838e486e,
- 0x08389486e,
- 0x0837d6100,
+ 0x08398486e,
+ 0x08393486e,
+ 0x083876100,
0x00d1e486e,
- 0x083a2615a,
+ 0x083ac615a,
0x04fef0164,
0x04e7542a7,
- 0x0486e839d,
- 0x0486e8391,
+ 0x0486e83a7,
+ 0x0486e839b,
0x061000d04,
0x0598f60e2,
0x048790000,
@@ 299,7 299,7 @@ ulong bootcode[]={
0x01c48486f,
0x000082f2f,
0x00050486e,
- 0x083ae4878,
+ 0x083b84878,
0x000026100,
0x0011a42a7,
0x061744fef,
@@ 307,10 307,10 @@ ulong bootcode[]={
0x0598f4281,
0x07021b081,
0x06f1e4ab6,
- 0x01d208412,
+ 0x01d20841a,
0x0660e2daf,
0x000081d20,
- 0x084127001,
+ 0x0841a7001,
0x0588f4e75,
0x052817021,
0x0b0816ee2,
@@ 320,25 320,25 @@ ulong bootcode[]={
0x042827021,
0x0b0826f18,
0x020362d20,
- 0x08412b088,
+ 0x0841ab088,
0x0660642b6,
- 0x02d208412,
+ 0x02d20841a,
0x052827021,
0x0b0826ee8,
0x0588f4e75,
0x04aaf0004,
0x0660642a7,
0x0610c588f,
- 0x0486e83da,
+ 0x0486e83e2,
0x06104588f,
0x04e75518f,
0x072204a81,
0x06d222eb6,
- 0x01d208412,
+ 0x01d20841a,
0x04a976712,
0x02f410004,
0x042b61d20,
- 0x084124eb7,
+ 0x0841a4eb7,
0x00151222f,
0x000045381,
0x04a816cde,
@@ 560,7 560,7 @@ ulong bootcode[]={
0x07209b081,
0x06e0000ea,
0x030360b20,
- 0x083c44efb,
+ 0x083cc4efb,
0x000007004,
0x0c0846604,
0x04a836d72,
@@ 686,7 686,7 @@ ulong bootcode[]={
0x0800e60b6,
0x04878ffff,
0x042a7486e,
- 0x083be6100,
+ 0x083c66100,
0x0ff3c4280,
0x04fef000c,
0x04e75598f,
@@ 1518,7 1518,7 @@ ulong bootcode[]={
0x06000fa26,
0x0101149c0,
0x02f00486e,
- 0x083f26100,
+ 0x083fa6100,
0x0edaa4280,
0x04fef000c,
0x04e753029,
@@ 1979,7 1979,7 @@ ulong bootcode[]={
0x06000fa98,
0x0101149c0,
0x02f00486e,
- 0x084006100,
+ 0x084086100,
0x0e6764280,
0x04fef000c,
0x04e754280,
@@ 2245,118 2245,120 @@ ulong bootcode[]={
0x000636f6e,
0x066696720,
0x031203136,
- 0x000236b2f,
- 0x0322f6461,
- 0x07461006f,
- 0x070656e69,
- 0x06e672023,
+ 0x0206e6f72,
+ 0x065737461,
+ 0x072740023,
0x06b2f322f,
0x064617461,
- 0x000236b2f,
- 0x0322f6374,
- 0x06c006f70,
- 0x0656e696e,
- 0x06720236b,
- 0x02f322f63,
- 0x0746c0063,
- 0x06f6e6e65,
- 0x063742068,
- 0x0656c6978,
- 0x02e626f6f,
- 0x074667300,
- 0x0636f6e6e,
- 0x065637465,
- 0x06420746f,
+ 0x0006f7065,
+ 0x06e696e67,
+ 0x020236b2f,
+ 0x0322f6461,
+ 0x074610023,
+ 0x06b2f322f,
+ 0x063746c00,
+ 0x06f70656e,
+ 0x0696e6720,
+ 0x0236b2f32,
+ 0x02f63746c,
+ 0x000636f6e,
+ 0x06e656374,
0x02068656c,
0x069782e62,
0x06f6f7466,
- 0x0730a006e,
- 0x06f702e2e,
- 0x02e007772,
- 0x069746520,
- 0x06e6f7000,
- 0x072656164,
- 0x0206e6f70,
- 0x0006e203d,
- 0x02025643b,
- 0x020627566,
+ 0x07300636f,
+ 0x06e6e6563,
+ 0x074656420,
+ 0x0746f2068,
+ 0x0656c6978,
+ 0x02e626f6f,
+ 0x07466730a,
+ 0x0006e6f70,
+ 0x02e2e2e00,
+ 0x077726974,
+ 0x065206e6f,
+ 0x070007265,
+ 0x06164206e,
+ 0x06f70006e,
0x0203d2025,
- 0x02e327820,
- 0x0252e3278,
+ 0x0643b2062,
+ 0x07566203d,
0x020252e32,
0x07820252e,
- 0x032780a00,
- 0x0666f726d,
- 0x06174206e,
- 0x06f70006e,
- 0x06f742052,
- 0x06e6f7000,
- 0x073657373,
- 0x0696f6e2e,
- 0x02e2e0077,
- 0x072697465,
- 0x020736573,
- 0x073696f6e,
- 0x000726561,
- 0x064207365,
- 0x07373696f,
- 0x06e00666f,
+ 0x032782025,
+ 0x02e327820,
+ 0x0252e3278,
+ 0x00a00666f,
0x0726d6174,
- 0x020736573,
- 0x073696f6e,
+ 0x0206e6f70,
0x0006e6f74,
- 0x020527365,
+ 0x020526e6f,
+ 0x070007365,
0x07373696f,
- 0x06e006572,
- 0x0726f7220,
- 0x025643b00,
- 0x072656d6f,
- 0x074652065,
- 0x072726f72,
- 0x000706f73,
- 0x0742e2e2e,
- 0x00023732f,
- 0x025730062,
- 0x06f6f7465,
- 0x073006372,
- 0x065617465,
- 0x000256400,
- 0x077726974,
- 0x065002373,
- 0x02f257300,
- 0x0626f6f74,
- 0x065730023,
- 0x0732f626f,
- 0x06f740063,
- 0x072656174,
- 0x065002564,
+ 0x06e2e2e2e,
0x000777269,
- 0x07465006d,
- 0x06f756e74,
- 0x02e2e2e00,
- 0x02f002f00,
- 0x062696e64,
- 0x0002f0000,
- 0x06d6f756e,
- 0x074007375,
- 0x063636573,
- 0x0730a002f,
- 0x036383032,
- 0x0302f696e,
- 0x069740069,
- 0x06e697400,
- 0x02d6d002f,
- 0x036383032,
- 0x0302f696e,
- 0x069740069,
- 0x06e697400,
- 0x02f363830,
- 0x032302f69,
- 0x06e697400,
+ 0x074652073,
+ 0x065737369,
+ 0x06f6e0072,
+ 0x065616420,
+ 0x073657373,
+ 0x0696f6e00,
+ 0x0666f726d,
+ 0x061742073,
+ 0x065737369,
+ 0x06f6e006e,
+ 0x06f742052,
+ 0x073657373,
+ 0x0696f6e00,
+ 0x06572726f,
+ 0x072202564,
+ 0x03b007265,
+ 0x06d6f7465,
+ 0x020657272,
+ 0x06f720070,
+ 0x06f73742e,
+ 0x02e2e0023,
+ 0x0732f2573,
+ 0x000626f6f,
+ 0x074657300,
+ 0x063726561,
+ 0x074650025,
+ 0x064007772,
+ 0x069746500,
+ 0x023732f25,
+ 0x07300626f,
+ 0x06f746573,
+ 0x00023732f,
0x0626f6f74,
- 0x03a202573,
- 0x03a202573,
- 0x00a000000,
+ 0x000637265,
+ 0x061746500,
+ 0x025640077,
+ 0x072697465,
+ 0x0006d6f75,
+ 0x06e742e2e,
+ 0x02e002f00,
+ 0x02f006269,
+ 0x06e64002f,
+ 0x000006d6f,
+ 0x0756e7400,
+ 0x073756363,
+ 0x06573730a,
+ 0x0002f3638,
+ 0x03032302f,
+ 0x0696e6974,
+ 0x000696e69,
+ 0x074002d6d,
+ 0x0002f3638,
+ 0x03032302f,
+ 0x0696e6974,
+ 0x000696e69,
+ 0x074002f36,
+ 0x038303230,
+ 0x02f696e69,
+ 0x07400626f,
+ 0x06f743a20,
+ 0x025733a20,
+ 0x025730a00,
0x02a2a2a00,
0x000000000,
0x001280116,
@@ 2378,6 2380,6 @@ ulong bootcode[]={
0x070653a20,
0x025640a00,
0x000000000,
- 0x0000252c,
+ 0x00002534,
0x0,
};
@@ 35,6 35,11 @@ IOQ rs232iq;
IOQ rs232oq;
struct{
+ IOQ;
+ Lock put;
+}klogq;
+
+struct{
IOQ; /* qlock to getc; interrupt putc's */
int c;
int repeat;
@@ 56,6 61,8 @@ printinit(void)
rs232iq.out = rs232iq.buf;
rs232oq.in = rs232oq.buf;
rs232oq.out = rs232oq.buf;
+ klogq.in = klogq.buf;
+ klogq.out = klogq.buf;
lineq.in = lineq.buf;
lineq.out = lineq.buf;
qlock(&kbdq); /* allocate qlock */
@@ 66,6 73,10 @@ printinit(void)
unlock(&rs232iq);
lock(&rs232oq); /* allocate lock */
unlock(&rs232oq);
+ lock(&klogq); /* allocate lock */
+ unlock(&klogq);
+ lock(&klogq.put); /* allocate lock */
+ unlock(&klogq.put);
screeninit();
}
@@ 91,7 102,16 @@ putstrn(char *str, long n)
int
cangetc(IOQ *q)
{
- return q->in != q->out;
+ int n = q->in - q->out;
+ if (n < 0)
+ n += sizeof(q->buf);
+ return n;
+}
+
+int
+canputc(IOQ *q)
+{
+ return sizeof(q->buf)-cangetc(q)-1;
}
int
@@ 124,12 144,36 @@ getc(IOQ *q)
return c;
}
-void
+int
putc(IOQ *q, int c)
{
- *q->in++ = c;
- if(q->in == q->buf+sizeof(q->buf))
- q->in = q->buf;
+ uchar *nextin;
+ if(q->in >= &q->buf[sizeof(q->buf)-1])
+ nextin = q->buf;
+ else
+ nextin = q->in+1;
+ if(nextin == q->out)
+ return -1;
+ *q->in = c;
+ q->in = nextin;
+ return 0;
+}
+
+void
+putstrk(char *str, long n)
+{
+ int s;
+
+ s = splhi();
+ lock(&klogq.put);
+ while(--n >= 0){
+ *klogq.in++ = *str++;
+ if(klogq.in == klogq.buf+sizeof(klogq.buf))
+ klogq.in = klogq.buf;
+ }
+ unlock(&klogq.put);
+ splx(s);
+ wakeup(&klogq.r);
}
int
@@ 149,6 193,17 @@ print(char *fmt, ...)
return n;
}
+int
+kprint(char *fmt, ...)
+{
+ char buf[PRINTSIZE];
+ int n;
+
+ n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf;
+ putstrk(buf, n);
+ return n;
+}
+
void
panic(char *fmt, ...)
{
@@ 202,9 257,10 @@ echo(int c)
*/
if(c == 0x14)
DEBUG();
- if(c == 0x16){
+ if(c == 0x16)
dumpqueues();
- }
+ if(c == 0x18)
+ mntdump();
if(raw.ref)
return;
if(c == 0x15)
@@ 257,9 313,7 @@ kbdclock(void)
void
rs232ichar(int c)
{
- *rs232iq.in++ = c;
- if(rs232iq.in == rs232iq.buf+sizeof(rs232iq.buf))
- rs232iq.in = rs232iq.buf;
+ putc(&rs232iq, c);
wakeup(&rs232iq.r);
}
@@ 271,6 325,7 @@ getrs232o(void)
c = getc(&rs232oq);
if(c == -1)
rs232oq.state = 0;
+ wakeup(&rs232oq.r);
return c;
}
@@ 295,6 350,7 @@ enum{
Qrs232,
Qtime,
Quser,
+ Qklog,
};
Dirtab consdir[]={
@@ 308,10 364,25 @@ Dirtab consdir[]={
"rs232", Qrs232, 0, 0600,
"time", Qtime, 12, 0600,
"user", Quser, 0, 0600,
+ "klog", Qklog, 0, 0400,
};
#define NCONS (sizeof consdir/sizeof(Dirtab))
+static int
+consgen(Chan *c, Dirtab *tab, int ntab, int i, Dir *dp)
+{
+ if(tab==0 || i>=ntab)
+ return -1;
+ tab += i;
+ devdir(c, tab->qid, tab->name, tab->length, tab->perm, dp);
+ switch(dp->qid){
+ case Qrs232:
+ dp->length = cangetc(&rs232iq); break;
+ }
+ return 1;
+}
+
ulong boottime; /* seconds since epoch at boot */
long
@@ 375,13 446,13 @@ consclone(Chan *c, Chan *nc)
int
conswalk(Chan *c, char *name)
{
- return devwalk(c, name, consdir, NCONS, devgen);
+ return devwalk(c, name, consdir, NCONS, consgen);
}
void
consstat(Chan *c, char *dp)
{
- devstat(c, dp, consdir, NCONS, devgen);
+ devstat(c, dp, consdir, NCONS, consgen);
}
Chan*
@@ 406,7 477,7 @@ consopen(Chan *c, int omode)
}
unlock(&lineq);
}
- return devopen(c, omode, consdir, NCONS, devgen);
+ return devopen(c, omode, consdir, NCONS, consgen);
}
void
@@ 437,7 508,7 @@ consread(Chan *c, void *buf, long n)
return n;
switch(c->qid&~CHDIR){
case Qdir:
- return devdirread(c, buf, n, consdir, NCONS, devgen);
+ return devdirread(c, buf, n, consdir, NCONS, consgen);
case Qrcons:
case Qcons:
@@ 538,6 609,22 @@ consread(Chan *c, void *buf, long n)
case Qnull:
return 0;
+ case Qklog:
+ qlock(&klogq);
+ if(waserror()){
+ qunlock(&klogq);
+ nexterror();
+ }
+ while(!cangetc(&klogq))
+ sleep(&klogq.r, (int(*)(void*))cangetc, &klogq);
+ for(i=0; i<n; i++){
+ if((ch=getc(&klogq)) == -1)
+ break;
+ *cbuf++ = ch;
+ }
+ qunlock(&klogq);
+ return i;
+
default:
panic("consread %lux\n", c->qid);
return 0;
@@ 573,14 660,19 @@ conswrite(Chan *c, void *va, long n)
case Qrs232:
qlock(&rs232oq);
l = n;
- while(--l >= 0)
- putc(&rs232oq, *a++);
- splhi();
- if(rs232oq.state == 0){
- rs232oq.state = 1;
- duartstartrs232o();
+ while(--l >= 0) {
+ while (putc(&rs232oq, *a) < 0)
+ sleep(&rs232oq.r, (int(*)(void*))canputc, &rs232oq);
+ a++;
+ if(rs232oq.state == 0){
+ splhi();
+ if(rs232oq.state == 0){
+ rs232oq.state = 1;
+ duartstartrs232o();
+ }
+ spllo();
+ }
}
- spllo();
qunlock(&rs232oq);
break;