Plan 9 from Bell Labs 1990-03-15
12 files changed, 424 insertions(+), 474 deletions(-) M gnot/boot.c M gnot/boot.h M gnot/devdk.c M gnot/devincon.c M gnot/fault.c M gnot/proc.c M gnot/sturp.c M gnot/sysproc.c M gnot/trap.c M port/devdk.c M port/sturp.c M power/devhs.c
M gnot/boot.c => gnot/boot.c +0 -19
@@ 19,16 19,6 @@ main(int argc, char *argv[]) open("#c/cons", OWRITE); open("#c/cons", OWRITE); fd = open("#c/user", 0); if(fd < 0) error("#c/user"); n = read(fd, buf, sizeof buf-1); if(n < 0) error("can't read #c/user; please reboot"); buf[n] = 0; print("hello %s!\n", buf); close(fd); /* * grab the incon, * push the dk multiplexor onto it, @@ 39,7 29,6 @@ main(int argc, char *argv[]) error("opening #i/ctl"); sendmsg(cfd, "push dkmux"); sendmsg(cfd, "config 1 16"); print("dkmux configured\n"); /* * open a datakit channel and call ken via r70, leave the @@ 51,18 40,10 @@ main(int argc, char *argv[]) cfd = open("#k/2/ctl", 2); if(cfd < 0) error("opening #k/2/ctl"); print("#k/2/ctl open\n"); sendmsg(cfd, "connect r70.nonet!bootes!fs"); print("connected to r70.nonet!bootes!fs\n"); close(cfd); /* for(;;){ print("ding\n"); sleep(10000); } /**/ /* * talk to the file server */
M gnot/boot.h => gnot/boot.h +271 -322
@@ 1,279 1,252 @@ ulong bootcode[]={ 0x00000107, 0x0000207a, 0x00000464, 0x0000200e, 0x00000404, 0x00000130, 0x00000000, 0x00002020, 0x00000000, 0x00000000, 0x2f012f00, 0x4feffff0, 0x2c7c0000, 0xdffe610c, 0xdffe486f, 0x00142f2f, 0x0014610c, 0x2f006100, 0x04ce4fef, 0x000c4e75, 0x045a4fef, 0x001c4e75, 0x4fefffc8, 0x42a7486e, 0x81126100, 0x20444878, 0x1fd04878, 0x0001486e, 0x811a6100, 0x20384878, 0x1fc44878, 0x0001486e, 0x81226100, 0x202c42a7, 0x486e812a, 0x61002022, 0x2f400050, 0x4aaf0050, 0x1fb84878, 0x0002486e, 0x812a6100, 0x1fac2f40, 0x00544aaf, 0x00546c0a, 0x486e8131, 0x6100038e, 0x588f486e, 0x81402f2f, 0x00586100, 0x0350486e, 0x814b2f2f, 0x00606100, 0x03444878, 0x0002486e, 0x81576100, 0x1f744a80, 0x42e72f40, 0x006a44df, 0x6c0a486e, 0x81326100, 0x0404588f, 0x4878001b, 0x486f002c, 0x2f2f0058, 0x61002004, 0x240042e7, 0x2f40005a, 0x44df6c0e, 0x486e813a, 0x610003de, 0x242f005c, 0x588f4237, 0x29200034, 0x486f0034, 0x486e815c, 0x61000496, 0x2f2f0064, 0x61001fac, 0x81616100, 0x0354588f, 0x48780002, 0x486e8167, 0x61001fbe, 0x486e8173, 0x61001f52, 0x2f400074, 0x4aaf0074, 0x6c0a486e, 0x816e6100, 0x03a0588f, 0x486e817d, 0x817c6100, 0x0334588f, 0x486e818d, 0x2f2f0078, 0x61000362, 0x486e8188, 0x2f2f0080, 0x61000356, 0x486e8194, 0x6100044e, 0x48780002, 0x486e81a6, 0x61001f7e, 0x4a8042e7, 0x2f40008e, 0x44df6c0a, 0x486e81b0, 0x6100035e, 0x588f4878, 0x0002486e, 0x81c26100, 0x1f5c4a80, 0x42e72f40, 0x009a44df, 0x6c0a486e, 0x81cb6100, 0x033c588f, 0x486e81dc, 0x61000402, 0x486e81eb, 0x2f2f00a0, 0x610002f6, 0x486e8207, 0x486e81a9, 0x610003ee, 0x2f2f00a8, 0x2f2f0080, 0x61001f04, 0x486e8229, 0x486e81cb, 0x610003de, 0x422e854e, 0x486f0084, 0x486e854e, 0x422e84ee, 0x486f005c, 0x486e84ee, 0x61000fba, 0x2f002f40, 0x00b4486f, 0x00902f2f, 0x00bc6100, 0x008c486f, 0x00682f2f, 0x00946100, 0x1f04b0af, 0x00bc670a, 0x486e8230, 0x0094670a, 0x486e81d2, 0x610002de, 0x588f4878, 0x001c486f, 0x009c2f2f, 0x00c86100, 0x00742f2f, 0x00a06100, 0x1ede2f40, 0x00c84aaf, 0x00c86e0a, 0x486e823a, 0x00a04aaf, 0x00a06e0a, 0x486e81dc, 0x610002ba, 0x588f2f2f, 0x00c8486e, 0x854e486f, 0x00ac6100, 0x00a0486e, 0x84ee486f, 0x00846100, 0x170a4a80, 0x6638102f, 0x00b349c0, 0x008b49c0, 0x2f00102f, 0x00b649c0, 0x008e49c0, 0x2f00102f, 0x00b949c0, 0x009149c0, 0x2f00102f, 0x00bc49c0, 0x009449c0, 0x2f002f2f, 0x00e4486e, 0x82436100, 0x00bc486e, 0x81e56100, 0x0348486e, 0x82666100, 0x82086100, 0x02704fef, 0x001c0c2e, 0x0001854e, 0x000184ee, 0x670a486e, 0x82716100, 0x82136100, 0x025c588f, 0x486e827a, 0x486e821c, 0x61000322, 0x1d7c0002, 0x854e1d7c, 0x00768558, 0x486f00b4, 0x486e854e, 0x84ee1d7c, 0x007684f8, 0x486f008c, 0x486e84ee, 0x61000ef6, 0x2f002f40, 0x00e4486f, 0x00c02f2f, 0x00ec6100, 0x00bc486f, 0x00982f2f, 0x00c46100, 0x1e40b0af, 0x00ec670a, 0x486e8285, 0x00c4670a, 0x486e8227, 0x6100021a, 0x588f4878, 0x001c486f, 0x00cc2f2f, 0x00f86100, 0x00a42f2f, 0x00d06100, 0x1e1a2f40, 0x00f84aaf, 0x00f86e0a, 0x486e8293, 0x00d04aaf, 0x00d06e0a, 0x486e8235, 0x610001f6, 0x588f2f2f, 0x00f8486e, 0x854e486f, 0x00dc6100, 0x00d0486e, 0x84ee486f, 0x00b46100, 0x16464a80, 0x660a486e, 0x82a06100, 0x82426100, 0x01d8588f, 0x0c2e0003, 0x854e670a, 0x486e82af, 0x84ee670a, 0x486e8251, 0x610001c6, 0x588f4a6e, 0x8552671c, 0x302e8552, 0x84f2671c, 0x302e84f2, 0x48c02f00, 0x486e82bc, 0x486e825e, 0x6100027e, 0x486e82c6, 0x486e8268, 0x610001a6, 0x4fef000c, 0x486e82d3, 0x486e8275, 0x6100026a, 0x486e82e1, 0x486e82db, 0x486f00ec, 0x486e8283, 0x486e827d, 0x486f00c4, 0x6100032a, 0x487801b6, 0x48780001, 0x486f00f8, 0x486f00d0, 0x61001d6e, 0x4a8042e7, 0x2f40011a, 0x2f4000f2, 0x44df6c0a, 0x486e82e8, 0x486e828a, 0x61000166, 0x588f2f2f, 0x0124486e, 0x82ef486f, 0x01046100, 0x00fc486e, 0x8291486f, 0x00dc6100, 0x02f4486f, 0x01086100, 0x00e06100, 0x0dea588f, 0x2f00486f, 0x010c2f2f, 0x012c6100, 0x00e42f2f, 0x01046100, 0x1d542f00, 0x486f0118, 0x486f00f0, 0x61000dd0, 0x588f221f, 0xb280670a, 0x486e82f2, 0x486e8294, 0x61000122, 0x588f2f2f, 0x01306100, 0x01086100, 0x1d06486e, 0x82fe486e, 0x82f8486f, 0x01206100, 0x82a0486e, 0x829a486f, 0x00f86100, 0x02a84878, 0x01b64878, 0x0001486e, 0x83056100, 0x82a76100, 0x1cec4a80, 0x42e72f40, 0x014e44df, 0x012644df, 0x6c0a486e, 0x830d6100, 0x82af6100, 0x00e4588f, 0x2f2f0158, 0x486e8314, 0x486f0138, 0x2f2f0130, 0x486e82b6, 0x486f0110, 0x61000272, 0x486f013c, 0x486f0114, 0x61000d68, 0x588f2f00, 0x486f0140, 0x2f2f0160, 0x486f0118, 0x2f2f0138, 0x61001cd2, 0x2f00486f, 0x014c6100, 0x01246100, 0x0d4e588f, 0x221fb280, 0x670a486e, 0x83176100, 0x82b96100, 0x00a0588f, 0x2f2f0164, 0x2f2f013c, 0x61001c84, 0x486e831d, 0x486e82bf, 0x6100015e, 0x42a7486e, 0x8328486e, 0x83266100, 0x82ca486e, 0x82c86100, 0x0d364a80, 0x6c08486e, 0x832a6174, 0x82cc6174, 0x588f486e, 0x83314878, 0x82d34878, 0x0006486e, 0x832f2f2f, 0x01906100, 0x82d12f2f, 0x01686100, 0x1c664a80, 0x6c08486e, 0x83326154, 0x82d46154, 0x588f486e, 0x83386100, 0x82da6100, 0x011c42a7, 0x486e834d, 0x486e8341, 0x486e82ef, 0x486e82e3, 0x61000cc8, 0x486e8352, 0x486e82f4, 0x61364fef, 0x01b04e75, 0x01884e75, 0x598f2f2f, 0x000c6100, 0x0cc62f00, @@ 291,7 264,7 @@ ulong bootcode[]={ 0x61001bf0, 0x486f0008, 0x2f2f0050, 0x486e835e, 0x486e8300, 0x48780002, 0x6100011a, 0x42a76174, @@ 300,9 273,9 @@ ulong bootcode[]={ 0x42817021, 0xb0816f1e, 0x4ab61d20, 0x8466660e, 0x8406660e, 0x2daf0008, 0x1d208466, 0x1d208406, 0x7001588f, 0x4e755281, 0x7021b081, @@ 312,25 285,25 @@ ulong bootcode[]={ 0x00084282, 0x7021b082, 0x6f182036, 0x2d208466, 0x2d208406, 0xb0886606, 0x42b62d20, 0x84665282, 0x84065282, 0x7021b082, 0x6ee8588f, 0x4e754aaf, 0x00046606, 0x42a7610c, 0x588f486e, 0x83ae6104, 0x834e6104, 0x588f4e75, 0x518f7220, 0x4a816d22, 0x2eb61d20, 0x84664a97, 0x84064a97, 0x67122f41, 0x000442b6, 0x1d208466, 0x1d208406, 0x4eb70151, 0x222f0004, 0x53814a81, @@ 540,7 513,7 @@ ulong bootcode[]={ 0x7209b081, 0x6e0000ea, 0x30360b20, 0x83984efb, 0x83384efb, 0x00007004, 0xc0846604, 0x4a836d72, @@ 666,7 639,7 @@ ulong bootcode[]={ 0x801260b6, 0x4878ffff, 0x42a7486e, 0x83726100, 0x83126100, 0xff3c4280, 0x4fef000c, 0x4e75598f, @@ 1110,7 1083,7 @@ ulong bootcode[]={ 0x7227b001, 0x6e0005e8, 0x30360b20, 0x83c64efb, 0x83664efb, 0x00002008, 0x90af000c, 0x588f4e75, @@ 1488,7 1461,7 @@ ulong bootcode[]={ 0x00186000, 0xfa261011, 0x49c02f00, 0x486e837a, 0x486e831a, 0x6100ee02, 0x42804fef, 0x000c4e75, @@ 1599,7 1572,7 @@ ulong bootcode[]={ 0x057e7227, 0xb0016e00, 0x05763036, 0x0b208416, 0x0b2083b6, 0x4efb0000, 0x202f0008, 0xd0af0010, @@ 1949,7 1922,7 @@ ulong bootcode[]={ 0x00186000, 0xfa981011, 0x49c02f00, 0x486e8388, 0x486e8328, 0x6100e6ce, 0x42804fef, 0x000c4e75, @@ 2092,19 2065,19 @@ ulong bootcode[]={ 0x00000000, 0x00000000, 0x000d0000, 0x2a640000, 0x2a7a0000, 0x2aa00000, 0x2abe0000, 0x2ac20000, 0x2ad20000, 0x2af00000, 0x2b0a0000, 0x2b0e0000, 0x2b2c0000, 0x2f3a0000, 0x2f600000, 0x2f860000, 0x29f80000, 0x2a0e0000, 0x2a340000, 0x2a520000, 0x2a560000, 0x2a660000, 0x2a840000, 0x2a9e0000, 0x2aa20000, 0x2ac00000, 0x2ece0000, 0x2ef40000, 0x2f1a0000, 0x00000000, 0x00000000, 0x00000000, @@ 2159,152 2132,128 @@ ulong bootcode[]={ 0x2f636f6e, 0x73002363, 0x2f636f6e, 0x73002363, 0x2f757365, 0x72002363, 0x2f757365, 0x72006361, 0x6e277420, 0x72656164, 0x2023632f, 0x75736572, 0x3b20706c, 0x65617365, 0x20726562, 0x6f6f7400, 0x68656c6c, 0x6f202573, 0x210a0023, 0x692f6374, 0x6c006f70, 0x656e696e, 0x67202369, 0x73002369, 0x2f63746c, 0x00707573, 0x6820646b, 0x6d757800, 0x636f6e66, 0x69672031, 0x20313600, 0x646b6d75, 0x7820636f, 0x6e666967, 0x75726564, 0x0a00236b, 0x2f322f64, 0x61746100, 0x6f70656e, 0x696e6720, 0x236b2f32, 0x2f646174, 0x6100236b, 0x2f322f63, 0x746c006f, 0x70656e69, 0x6e672023, 0x006f7065, 0x6e696e67, 0x2023692f, 0x63746c00, 0x70757368, 0x20646b6d, 0x75780063, 0x6f6e6669, 0x67203120, 0x31360023, 0x6b2f322f, 0x64617461, 0x006f7065, 0x6e696e67, 0x20236b2f, 0x322f6461, 0x74610023, 0x6b2f322f, 0x63746c00, 0x6f70656e, 0x696e6720, 0x236b2f32, 0x2f63746c, 0x206f7065, 0x6e0a0063, 0x6f6e6e65, 0x63742072, 0x37302e6e, 0x6f6e6574, 0x21626f6f, 0x74657321, 0x66730063, 0x6f6e6e65, 0x63746564, 0x20746f20, 0x7237302e, 0x6e6f6e65, 0x7421626f, 0x6f746573, 0x2166730a, 0x006e6f70, 0x2e2e2e00, 0x77726974, 0x65206e6f, 0x70007265, 0x6164206e, 0x6f70006e, 0x00636f6e, 0x6e656374, 0x20723730, 0x2e6e6f6e, 0x65742162, 0x6f6f7465, 0x73216673, 0x00636f6e, 0x6e656374, 0x65642074, 0x6f207237, 0x302e6e6f, 0x6e657421, 0x626f6f74, 0x65732166, 0x730a006e, 0x6f702e2e, 0x2e007772, 0x69746520, 0x6e6f7000, 0x72656164, 0x206e6f70, 0x006e203d, 0x2025643b, 0x20627566, 0x203d2025, 0x643b2062, 0x7566203d, 0x20252e32, 0x7820252e, 0x32782025, 0x2e327820, 0x252e3278, 0x0a00666f, 0x726d6174, 0x206e6f70, 0x006e6f74, 0x20526e6f, 0x70007365, 0x7373696f, 0x6e2e2e2e, 0x00777269, 0x74652073, 0x65737369, 0x6f6e0072, 0x65616420, 0x73657373, 0x696f6e00, 0x20252e32, 0x7820252e, 0x32780a00, 0x666f726d, 0x61742073, 0x65737369, 0x6f6e006e, 0x6174206e, 0x6f70006e, 0x6f742052, 0x6e6f7000, 0x73657373, 0x696f6e00, 0x6572726f, 0x72202564, 0x3b007265, 0x6d6f7465, 0x20657272, 0x6f720070, 0x6f73742e, 0x2e2e0023, 0x732f2573, 0x00626f6f, 0x74657300, 0x63726561, 0x74650025, 0x64007772, 0x69746500, 0x23732f25, 0x7300626f, 0x6f746573, 0x696f6e2e, 0x2e2e0077, 0x72697465, 0x20736573, 0x73696f6e, 0x00726561, 0x64207365, 0x7373696f, 0x6e00666f, 0x726d6174, 0x20736573, 0x73696f6e, 0x006e6f74, 0x20527365, 0x7373696f, 0x6e006572, 0x726f7220, 0x25643b00, 0x72656d6f, 0x74652065, 0x72726f72, 0x00706f73, 0x742e2e2e, 0x0023732f, 0x25730062, 0x6f6f7465, 0x73006372, 0x65617465, 0x00256400, 0x77726974, 0x65002373, 0x2f257300, 0x626f6f74, 0x00637265, 0x61746500, 0x25640077, 0x72697465, 0x006d6f75, 0x6e742e2e, 0x2e002f00, 0x2f006269, 0x6e64002f, 0x00006d6f, 0x756e7400, 0x73756363, 0x6573730a, 0x002f3638, 0x3032302f, 0x696e6974, 0x00696e69, 0x74002f36, 0x38303230, 0x2f696e69, 0x7400626f, 0x6f743a20, 0x25733a20, 0x25730a00, 0x00000000, 0x65730023, 0x732f626f, 0x6f740063, 0x72656174, 0x65002564, 0x00777269, 0x7465006d, 0x6f756e74, 0x2e2e2e00, 0x2f002f00, 0x62696e64, 0x002f0000, 0x6d6f756e, 0x74007375, 0x63636573, 0x730a002f, 0x36383032, 0x302f696e, 0x69740069, 0x6e697400, 0x2f363830, 0x32302f69, 0x6e697400, 0x626f6f74, 0x3a202573, 0x3a202573, 0x0a000000, 0x00002a2a, 0x2a000000, 0x00006261, @@ 2367,6 2316,6 @@ ulong bootcode[]={ 0x0162010a, 0x00be005a, 0x001c0000, 0x00024fe, 0x0002432, 0x, };
M gnot/devdk.c => gnot/devdk.c +7 -8
@@ 287,7 287,7 @@ dkmuxiput(Queue *q, Block *bp) line = bp->rptr[0] | (bp->rptr[1]<<8); bp->rptr += 2; if(line<0 || line>=dp->lines){ print("dkmuxiput bad line %d\n", line); DPRINT("dkmuxiput bad line %d\n", line); freeb(bp); return; } @@ 297,12 297,12 @@ dkmuxiput(Queue *q, Block *bp) if(lp->rq) PUTNEXT(lp->rq, bp); else{ print("dkmuxiput unopened line %d\n", line); DPRINT("dkmuxiput unopened line %d\n", line); freeb(bp); } qunlock(lp); } else { print("dkmuxiput unopened line %d\n", line); DPRINT("dkmuxiput unopened line %d\n", line); freeb(bp); } } @@ 412,6 412,8 @@ dkoput(Queue *q, Block *bp) if(bp->base && bp->rptr - bp->base >= 2) bp->rptr -= 2; else panic("dkoput"); bp->rptr[0] = line; bp->rptr[1] = line>>8; @@ 574,14 576,12 @@ dkattach(char *spec) { Chan *c; Dk *dp; print("attach\n"); /* * find a multiplexor with the same name */ for(dp = dk; dp < &dk[Ndk]; dp++){ qlock(dp); print("name %s %lux\n", dp->name, dp->wq); if(dp->wq && strcmp(spec, dp->name)==0) { dp->ref++; qunlock(dp); @@ 593,7 593,6 @@ print("name %s %lux\n", dp->name, dp->wq); error(0, Enoifc); c = devattach('k', spec); c->dev = dp - dk; print("attach done\n"); return c; } @@ 1115,13 1114,13 @@ dklisten(Chan *c) * for the call to come in on). */ if(!canqlock(lp)){ print("DKbusy1\n"); DPRINT("DKbusy1\n"); dkanswer(c, lineno, DKbusy); continue; } else { if(lp->state != Lclosed){ qunlock(lp); print("DKbusy2 %ux\n", lp->state); DPRINT("DKbusy2 %ux\n", lp->state); dkanswer(c, lineno, DKbusy); continue; }
M gnot/devincon.c => gnot/devincon.c +121 -103
@@ 13,13 13,16 @@ typedef struct Device Device; #define NOW (MACHP(0)->ticks*MS2HZ) static int SpEcIaL; #define MICROSECOND SpEcIaL = 0 #define DPRINT if(0) enum { Minstation= 2, /* lowest station # to poll */ Maxstation= 15, /* highest station # to poll */ Nincon= 1, /* number of incons */ Nraw= 1024, /* size of raw input buffer */ Nin= 32, /* size of raw input buffer */ }; /* @@ 58,13 61,13 @@ struct Incon { Rendez kr; /* input kernel process */ ushort chan; /* current input channel */ Queue *rq; /* read queue */ uchar buf[1024]; /* bytes being collected */ uchar *wptr; /* pointer into buf */ int kstarted; /* true if kernel process started */ ushort raw[Nraw]; ushort *rp; ushort *wp; /* input blocks */ Block *inb[Nin]; ushort wi; ushort ri; /* statistics */ @@ 131,18 134,22 @@ Qinfo inconinfo = { nullput, inconoput, inconstopen, inconstclose, "incon" }; * set the incon parameters */ void inconset(Incon *ip, int cnt, int delay) inconset(Incon *ip, int cnt, int del) { Device *dev; if (cnt<1 || cnt>14 || delay<1 || delay>15) if (cnt<1 || cnt>14 || del<1 || del>15) error(0, Ebadarg); dev = ip->dev; dev->cmd = sel_rcv_cnt | INCON_RUN; MICROSECOND; *(uchar *)&dev->data_cntl = cnt; MICROSECOND; dev->cmd = sel_rcv_tim | INCON_RUN; *(uchar *)&dev->data_cntl = delay; MICROSECOND; *(uchar *)&dev->data_cntl = del; MICROSECOND; dev->cmd = INCON_RUN | ENABLE_IRQ; } @@ 253,12 260,13 @@ inconreset(void) incon[0].dev = INCON; incon[0].state = Selected; incon[0].rp = incon[0].wp = incon[0].raw; incon[0].ri = incon[0].wi = 0; inconset(&incon[0], 8, 9); for(i=1; i<Nincon; i++){ incon[i].dev = INCON+i; incon[i].state = Dead; incon[i].dev->cmd = INCON_STOP; incon[i].rp = incon[i].wp = incon[i].raw; incon[i].ri = incon[i].wi = 0; } } @@ 551,6 559,7 @@ inconoput(Queue *q, Block *bp) } DPRINT("CTL|%uo->\n", ctl); dev->cdata = ctl; MICROSECOND; } dev->cdata = 0; @@ 567,29 576,7 @@ notempty(void *arg) Incon *ip; ip = (Incon *)arg; return ip->wp!=ip->rp; } /* * fill a block with what is currently buffered and send it upstream */ static void upstream(Incon *ip, unsigned int ctl) { int n; Block *bp; n = ip->wptr - ip->buf; bp = allocb(3 + n); bp->wptr[0] = ip->chan; bp->wptr[1] = ip->chan>>8; bp->wptr[2] = ctl; if(n) memcpy(&bp->wptr[3], ip->buf, n); bp->wptr += 3 + n; bp->flags |= S_DELIM; PUTNEXT(ip->rq, bp); ip->wptr = ip->buf; return ip->ri!=ip->wi; } /* @@ 599,17 586,27 @@ static void inconkproc(void *arg) { Incon *ip; unsigned int c; uchar *lim; ushort *p, *e; Block *bp; int i; ip = (Incon *)arg; ip->kstarted = 1; ip->wptr = ip->buf; e = &ip->raw[Nraw]; /* * create a number of blocks for input */ for(i = 0; i < Nin; i++){ bp = ip->inb[i] = allocb(128); bp->wptr += 3; } for(;;){ /* * sleep if input fifo empty */ sleep(&ip->kr, notempty, ip); /* * die if the device is closed */ qlock(ip); @@ 621,96 618,117 @@ inconkproc(void *arg) } /* * sleep if input fifo empty * send blocks upstream and stage new blocks */ while(!notempty(ip)) sleep(&ip->kr, notempty, ip); p = ip->rp; while(ip->ri != ip->wi){ PUTNEXT(ip->rq, ip->inb[ip->ri]); bp = ip->inb[ip->ri] = allocb(128); bp->wptr += 3; ip->ri = (ip->ri+1)%Nin; } qunlock(ip); } } /* * drop an input packet on the floor */ static void droppacket(Device *dev) { int i; int c; for(i = 0; i < 17; i++){ c = dev->data_cntl; if(c==0) break; } } /* * advance the queue. if we've run out of staged input blocks, * drop the packet and return 0. otherwise return the next input * block to fill. */ static Block * nextin(Incon *ip, unsigned int c) { Block *bp = ip->inb[ip->wi]; bp->base[0] = ip->chan; bp->base[1] = ip->chan>>8; bp->base[2] = c; ip->wi = (ip->wi + 1) % Nin; if(((ip->wi+1)%Nin) == ip->ri){ droppacket(ip->dev); return 0; } return ip->inb[ip->wi]; } /* * read the packets from the device into the staged input blocks. * we have to do this at interrupt tevel to turn off the interrupts. */ static void rdpackets(Incon *ip) { Block *bp; unsigned int c; Device *dev; dev = ip->dev; while(!(dev->status & RCV_EMPTY)){ bp = ip->inb[ip->wi]; if(((ip->wi+1)%Nin) == ip->ri || bp==0){ c = dev->data_cntl; droppacket(dev); continue; } /* * get channel number */ c = (*p++)>>8; if(p == e) p = ip->raw; c = (dev->data_cntl)>>8; DPRINT("<-CH|%uo\n", c); if(ip->chan != c){ if(ip->wptr - ip->buf != 0) upstream(ip, 0); if(bp->wptr - bp->rptr > 3){ bp = nextin(ip, 0); if(bp == 0) continue; } ip->chan = c; } /* * null byte marks end of packet */ for(lim = &ip->buf[sizeof ip->buf];;){ if((c=*p++)&1) { for(;;){ if((c=dev->data_cntl)&1) { /* * data byte, put in local buffer */ c = *ip->wptr++ = c>>8; c = *bp->wptr++ = c>>8; DPRINT("<-%uo\n", c); if(ip->wptr >= lim) upstream(ip, 0); if(bp->wptr >= bp->lim){ bp = nextin(ip, 0); if(bp == 0) continue; } } else if (c>>=8) { /* * control byte ends block */ DPRINT("<-CTL|%uo\n", c); upstream(ip, c); bp = nextin(ip, c); if(bp == 0) continue; } else { /* end of packet */ break; } if(p == e) p = ip->raw; } ip->rp = p; qunlock(ip); } } /* * read the packets from the device into the raw input buffer. * we have to do this at interrupt tevel to turn off the interrupts. */ static rdpackets(Incon *ip) { Device *dev; unsigned int c; ushort *p, *e; int n; dev = ip->dev; while(!(dev->status & RCV_EMPTY)){ n = ip->rp - ip->wp; if(n <= 0) n += Nraw; if(n < 19){ /* * no room in the raw queue, throw it away */ c = (dev->data_cntl)>>8; for(c=0;c<18;c++){ if(dev->data_cntl == 0) break; } } else { /* * put packet in the raw queue */ p = ip->wp; e = &ip->raw[Nraw]; *p++ = dev->data_cntl; if(p == e) p = ip->raw; do { *p++ = c = dev->data_cntl; if(p == e) p = ip->raw; } while(c); ip->wp = p; } } wakeup(&ip->kr);
M gnot/fault.c => gnot/fault.c +1 -1
@@ 89,12 89,12 @@ fault(Ureg *ur, FFrame *f) if(s == 0){ if(addr>USTKTOP){ cant: u->p->state = MMUing; if(user){ pprint("user %s error addr=0x%lux\n", read? "read" : "write", badvaddr); pprint("status=0x%lux pc=0x%lux sp=0x%lux\n", ur->sr, ur->pc, ur->sp); pexit("Suicide", 0); } u->p->state = MMUing; dumpregs(ur); panic("fault"); exit();
M gnot/proc.c => gnot/proc.c +0 -2
@@ 172,8 172,6 @@ loop: unlock(&pidalloc); if(p->pid == 0) panic("pidalloc"); print("allocate process %d\n", p->pid); DEBUG(); return p; } unlock(&procalloc);
M gnot/sturp.c => gnot/sturp.c +3 -2
@@ 12,7 12,7 @@ enum { Nmask= 0x7, }; #define DPRINT print #define DPRINT if(0) typedef struct Urp Urp; @@ 782,6 782,7 @@ initoutput(Urp *up, int window) qlock(&up->xl[i]); if(up->xb[i]) freeb(up->xb[i]); up->xb[i] = 0; qunlock(&up->xl[i]); } @@ 825,7 826,7 @@ urpkproc(void *arg) Urp *up; up = (Urp *)arg; print("urpkproc started\n"); DPRINT("urpkproc started\n"); for(;;){ if(up->state & (HUNGUP|CLOSING)){
M gnot/sysproc.c => gnot/sysproc.c +0 -1
@@ 174,7 174,6 @@ sysexec(ulong *arg) } if(!indir) strcpy(elem, u->elem); print("offset %lux\n", tc->offset); n = (*devtab[tc->type].read)(tc, &exec, sizeof(Exec)); if(n < 2){ print("short read\n");
M gnot/trap.c => gnot/trap.c +0 -2
@@ 278,8 278,6 @@ syscall(Ureg *aur) ur->r0 = ret; notify(ur); } {ulong *arg=(ulong*)(sp+BY2WD); if(ret==-1)print("syscall %d(%lux %lux %lux) returns error %d\n", r0, arg[0], arg[1], arg[2], u->error.code);} return ret; }
M port/devdk.c => port/devdk.c +10 -8
@@ 112,7 112,7 @@ struct Line { /* * a dkmux dk. one exists for every stream that a * dkmux line disilpline is pushed onto. * dkmux line discipline is pushed onto. */ struct Dk { QLock; @@ 284,9 284,10 @@ dkmuxiput(Queue *q, Block *bp) return; } line = *bp->rptr++ | (*bp->rptr++<<8); line = bp->rptr[0] | (bp->rptr[1]<<8); bp->rptr += 2; if(line<0 || line>=dp->lines){ print("dkmuxiput bad line %d\n", line); DPRINT("dkmuxiput bad line %d\n", line); freeb(bp); return; } @@ 296,12 297,12 @@ dkmuxiput(Queue *q, Block *bp) if(lp->rq) PUTNEXT(lp->rq, bp); else{ print("dkmuxiput unopened line %d\n", line); DPRINT("dkmuxiput unopened line %d\n", line); freeb(bp); } qunlock(lp); } else { print("dkmuxiput unopened line %d\n", line); DPRINT("dkmuxiput unopened line %d\n", line); freeb(bp); } } @@ 411,6 412,8 @@ dkoput(Queue *q, Block *bp) if(bp->base && bp->rptr - bp->base >= 2) bp->rptr -= 2; else panic("dkoput"); bp->rptr[0] = line; bp->rptr[1] = line>>8; @@ 590,7 593,6 @@ dkattach(char *spec) error(0, Enoifc); c = devattach('k', spec); c->dev = dp - dk; return c; } @@ 1112,13 1114,13 @@ dklisten(Chan *c) * for the call to come in on). */ if(!canqlock(lp)){ print("DKbusy1\n"); DPRINT("DKbusy1\n"); dkanswer(c, lineno, DKbusy); continue; } else { if(lp->state != Lclosed){ qunlock(lp); print("DKbusy2 %ux\n", lp->state); DPRINT("DKbusy2 %ux\n", lp->state); dkanswer(c, lineno, DKbusy); continue; }
M port/sturp.c => port/sturp.c +8 -4
@@ 123,6 123,8 @@ urpopen(Queue *q, Stream *s) int i; char name[128]; DPRINT("urpopen\n"); /* * find a free urp structure */ @@ 379,7 381,7 @@ urpiput(Queue *q, Block *bp) case 0: break; case ENQ: print("rENQ\n"); print("rENQ %uo %uo\n", up->lastecho, ACK+up->iseq); urpstat.enqsr++; sendctl(up, up->lastecho); sendctl(up, ACK+up->iseq); @@ 443,19 445,19 @@ urpiput(Queue *q, Block *bp) if(up->trx != 3){ urpstat.rjtrs++; flushinput(up); print("sREJ\n"); print("sREJ1 %d\n", up->iseq); sendctl(up, up->lastecho = REJ+up->iseq); break; } else if(q->len != up->trbuf[1] + (up->trbuf[2]<<8)){ urpstat.rjpks++; flushinput(up); print("sREJ\n"); print("sREJ2 %d\n", up->iseq); sendctl(up, up->lastecho = REJ+up->iseq); break; } else if(i != ((up->iseq+1)&Nmask)) { urpstat.rjseq++; flushinput(up); print("sREJ\n"); print("sREJ3 %d %d\n", i, up->iseq); sendctl(up, up->lastecho = REJ+up->iseq); break; } @@ 780,6 782,7 @@ initoutput(Urp *up, int window) qlock(&up->xl[i]); if(up->xb[i]) freeb(up->xb[i]); up->xb[i] = 0; qunlock(&up->xl[i]); } @@ 823,6 826,7 @@ urpkproc(void *arg) Urp *up; up = (Urp *)arg; DPRINT("urpkproc started\n"); for(;;){ if(up->state & (HUNGUP|CLOSING)){
M power/devhs.c => power/devhs.c +3 -2