From f5ad1d6a6710ce07d869d61ec72bb3827ce6ee64 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 8 Apr 1997 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1997-04-08 --- carrera/devether.c | 3 +++ carrera/devrtc.c | 3 +++ ip/devip.c | 3 +++ ip/kio.c | 4 ++-- pc/archgeneric.c | 2 -- pc/devastar.c | 5 ++++- pc/devata.c | 3 +++ pc/devether.c | 3 +++ pc/devfloppy.c | 3 +++ pc/devi82365.c | 3 +++ pc/devlpt.c | 3 +++ pc/devrtc.c | 3 +++ pc/devvga.c | 3 +++ port/chan.c | 4 ++-- port/dev.c | 22 ++++++++-------------- port/devXXX.c | 3 +++ port/devaudio.c | 3 +++ port/devcons.c | 3 +++ port/devdup.c | 3 +++ port/devenv.c | 3 +++ port/devkprof.c | 3 +++ port/devlance.c | 3 +++ port/devmnt.c | 14 ++++++++++---- port/devmouse.c | 3 +++ port/devns16552.c | 3 +++ port/devpipe.c | 3 +++ port/devproc.c | 3 +++ port/devroot.c | 3 +++ port/devsd.c | 3 +++ port/devsrv.c | 3 +++ port/devssl.c | 3 +++ port/devtinyfs.c | 3 +++ port/portdat.h | 4 +++- port/sysfile.c | 6 +++--- port/sysproc.c | 2 +- 35 files changed, 111 insertions(+), 30 deletions(-) diff --git a/carrera/devether.c b/carrera/devether.c index 405ffacb23990b781b9a85d4f76981dc41c1be08..79e23907f0da879eb7a6f5e0000273e634e1782c 100644 --- a/carrera/devether.c +++ b/carrera/devether.c @@ -836,6 +836,9 @@ parseether(uchar *to, char *from) } Dev etherdevtab = { + 'l', + "ether", + etherreset, devinit, etherattach, diff --git a/carrera/devrtc.c b/carrera/devrtc.c index 246dcb437c21fac49d629e9737b865b088542eb4..3b54482a0c685a157a5956cf8b6193ad57a392eb 100644 --- a/carrera/devrtc.c +++ b/carrera/devrtc.c @@ -293,6 +293,9 @@ rtcwrite(Chan *c, void *buf, long n, ulong offset) } Dev rtcdevtab = { + 'r', + "rtc", + rtcreset, devinit, rtcattach, diff --git a/ip/devip.c b/ip/devip.c index e84395105b64bf225b754b31fd8e07cde48a457d..add08890128760d38c0f46971597cd3d3a3d5c95 100644 --- a/ip/devip.c +++ b/ip/devip.c @@ -712,6 +712,9 @@ ipbwrite(Chan* c, Block* bp, ulong offset) } Dev ipdevtab = { + 'I', + "ip", + ipreset, ipinit, ipattach, diff --git a/ip/kio.c b/ip/kio.c index 6f683ba1c894f790c430639a9201816d4217ad0a..3c958be89637add0e070157552c5ea007d927847 100644 --- a/ip/kio.c +++ b/ip/kio.c @@ -71,7 +71,7 @@ kread(int fd, void *va, long n) if(dir && c->mnt) n = unionread(c, va, n); - else if(devchar[c->type] != L'M') + else if(devtab[c->type]->dc != L'M') n = devtab[c->type]->read(c, va, n, c->offset); else n = mntread9p(c, va, n, c->offset); @@ -106,7 +106,7 @@ kseek(int fd, int offset, int whence) if(c->qid.path & CHDIR) error(Eisdir); - if(devchar[c->type] == '|') + if(devtab[c->type]->dc == '|') error(Eisstream); off = 0; diff --git a/pc/archgeneric.c b/pc/archgeneric.c index bc825fee5cc516a25861fba581ba323ddbea58a2..6f237494d0a9a185587523baac67814a718837fb 100644 --- a/pc/archgeneric.c +++ b/pc/archgeneric.c @@ -57,8 +57,6 @@ static X86type x86type[] = { 5, 2, 23, "P54C", }, { 5, 3, 23, "P24T", }, { 5, 4, 23, "P55C MMX", }, - { 5, 5, 23, "PODDX4", }, - { 5, 6, 23, "PODP5", }, { 5, 7, 23, "P54C VRT", }, { 6, 1, 16, "PentiumPro", },/* determined by trial and error */ diff --git a/pc/devastar.c b/pc/devastar.c index 495ceeff6b1f4f8595510de0369d95e1e402a38e..4336b4e30000ee7ecfad6c5e076e8e511471c9b5 100644 --- a/pc/devastar.c +++ b/pc/devastar.c @@ -378,7 +378,7 @@ astargen(Chan *c, Dirtab *tab, int ntab, int i, Dir *db) db->mtime = kerndate; memmove(db->uid, eve, NAMELEN); memmove(db->gid, eve, NAMELEN); - db->type = devchar[c->type]; + db->type = devtab[c->type]->dc; db->dev = c->dev; if(c->flag&CMSG) db->mode |= CHMOUNT; @@ -1236,6 +1236,9 @@ astarwstat(Chan *c, char *dp) } Dev astardevtab = { + 'G', + "astar", + astarreset, devinit, astarattach, diff --git a/pc/devata.c b/pc/devata.c index cbdec314112b19e14fad0de86d58417324f6dcce..9441ed8d3e02c1629c5629ca3b9658c09cb3e7c3 100644 --- a/pc/devata.c +++ b/pc/devata.c @@ -1912,6 +1912,9 @@ atapiintr(Controller *cp) } Dev atadevtab = { + 'H', + "ata", + devreset, devinit, ataattach, diff --git a/pc/devether.c b/pc/devether.c index e8b51b2f195b7c58763df0f84abf4a14b6c9613f..cc1c555e96c38e9ee44c0c7aea5683e6cf775a7d 100644 --- a/pc/devether.c +++ b/pc/devether.c @@ -386,6 +386,9 @@ etherreset(void) } Dev etherdevtab = { + 'l', + "ether", + etherreset, devinit, etherattach, diff --git a/pc/devfloppy.c b/pc/devfloppy.c index b1b30b6690119b75e1b8051c596ce0263f74f054..149ce55f190b3c3e910c47be820c9f9549d0b15f 100644 --- a/pc/devfloppy.c +++ b/pc/devfloppy.c @@ -1003,6 +1003,9 @@ floppyintr(Ureg *ur) } Dev floppydevtab = { + 'f', + "floppy", + floppyreset, devinit, floppyattach, diff --git a/pc/devi82365.c b/pc/devi82365.c index d1df0737618a96307b806e1d28820a5864c037fe..187f50a75393e4a3eee0b49aee8bf6b7247b5e25 100644 --- a/pc/devi82365.c +++ b/pc/devi82365.c @@ -877,6 +877,9 @@ i82365write(Chan *c, void *a, long n, ulong offset) } Dev i82365devtab = { + 'y', + "i82365", + i82365reset, devinit, i82365attach, diff --git a/pc/devlpt.c b/pc/devlpt.c index 6a2c1e934064988d071b7b575cc8f8f9407f5216..fd668053a66dfd92686ef739534b4476711e89d2 100644 --- a/pc/devlpt.c +++ b/pc/devlpt.c @@ -193,6 +193,9 @@ lptintr(Ureg *ur, void *arg) } Dev lptdevtab = { + 'L', + "lpt", + devreset, devinit, lptattach, diff --git a/pc/devrtc.c b/pc/devrtc.c index 6c83773483ca245f83a5f85e840e7a8f2809ac56..af3929321fe0354cfa877ae8146ce7000d861166 100644 --- a/pc/devrtc.c +++ b/pc/devrtc.c @@ -277,6 +277,9 @@ rtcwrite(Chan* c, void* buf, long n, ulong offset) } Dev rtcdevtab = { + 'r', + "rtc", + devreset, devinit, rtcattach, diff --git a/pc/devvga.c b/pc/devvga.c index 3bb0ac6043f1d9ab123cc8225ba4924bdca675e0..b914e3e008e901df26d8d0c61579e1f0a6bf64f1 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -410,6 +410,9 @@ vgawrite(Chan *c, void *buf, long n, ulong offset) } Dev vgadevtab = { + 'v', + "vga", + vgareset, vgainit, vgaattach, diff --git a/port/chan.c b/port/chan.c index 86f16168275185f70dd1fecd66062c5081fc666a..8fae0a5ccb0920f02cc9d8af761e9d59705a7831 100644 --- a/port/chan.c +++ b/port/chan.c @@ -55,7 +55,7 @@ chandevreset(void) { int i; - for(i=0; devchar[i]; i++) + for(i=0; devtab[i] != nil; i++) devtab[i]->reset(); } @@ -64,7 +64,7 @@ chandevinit(void) { int i; - for(i=0; devchar[i]; i++) + for(i=0; devtab[i] != nil; i++) devtab[i]->init(); } diff --git a/port/dev.c b/port/dev.c index e112b1fc42ea62daa7d88067bbb52b82a166405f..97c83370436bdb41d8c74ba0eaa706be9174319e 100644 --- a/port/dev.c +++ b/port/dev.c @@ -10,22 +10,16 @@ extern ulong kerndate; int devno(int c, int user) { - Rune *s; int i; - s = devchar; - i = 0; - while(*s){ - if(c == *s) + for(i = 0; devtab[i] != nil; i++) { + if(devtab[i]->dc == c) return i; - i++; - s++; } + if(user == 0) + panic("devno %C 0x%ux", c, c); - if(user) - return -1; - panic("devno %C 0x%ux", c, c); - return 0; + return -1; } void @@ -33,7 +27,7 @@ devdir(Chan *c, Qid qid, char *n, long length, char *user, long perm, Dir *db) { strcpy(db->name, n); db->qid = qid; - db->type = devchar[c->type]; + db->type = devtab[c->type]->dc; db->dev = c->dev; if(qid.path & CHDIR) db->mode = CHDIR|perm; @@ -89,7 +83,7 @@ Chan* devclone(Chan *c, Chan *nc) { if(c->flag & COPEN) - panic("clone of open file type %C\n", devchar[c->type]); + panic("clone of open file type %C\n", devtab[c->type]->dc); if(nc == 0) nc = newchan(); @@ -158,7 +152,7 @@ devstat(Chan *c, char *db, Dirtab *tab, int ntab, Devgen *gen) } print("%s %s: devstat %C %lux\n", up->text, up->user, - devchar[c->type], c->qid.path); + devtab[c->type]->dc, c->qid.path); error(Enonexist); case 0: diff --git a/port/devXXX.c b/port/devXXX.c index 1bf8852bcd6aa6d61bdd8ab053ede41fbf107f61..7c77a4a4f7a93dbe1923c231484162539956269b 100644 --- a/port/devXXX.c +++ b/port/devXXX.c @@ -129,6 +129,9 @@ XXXbwrite(Chan* c, Block* bp, ulong offset) /* default in dev.c */ } Dev XXXdevtab = { /* defaults in dev.c */ + 'X', + "XXX", + XXXreset, /* devreset */ XXXinit, /* devinit */ XXXattach, diff --git a/port/devaudio.c b/port/devaudio.c index 45eaffb245d453f5b19501461cc72ac43408f0ad..a6f6d21d3b9abb7a02e9a745e2a3d4243959522c 100644 --- a/port/devaudio.c +++ b/port/devaudio.c @@ -921,6 +921,9 @@ swab(uchar *a) } Dev audiodevtab = { + 'A', + "audio", + devreset, audioinit, audioattach, diff --git a/port/devcons.c b/port/devcons.c index 2bc18217586e202e872f9f210c1d16100fe84eef..3d12046395b6d57bcd9b22c6d8108cab4c506f58 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -828,6 +828,9 @@ setterm(char *f) } Dev consdevtab = { + 'c', + "cons", + devreset, consinit, consattach, diff --git a/port/devdup.c b/port/devdup.c index 951c44482b0a841ab90d57b60237907c6291dfe4..7c8db30e0fdaede8a6bc865538b02843f7decab0 100644 --- a/port/devdup.c +++ b/port/devdup.c @@ -85,6 +85,9 @@ dupwrite(Chan*, void*, long, ulong) } Dev dupdevtab = { + 'd', + "dup", + devreset, devinit, dupattach, diff --git a/port/devenv.c b/port/devenv.c index f4fa7f830388c6f11d996d2b12c135b4a40c2c9e..3ee2f56ed1fe51d1b8d8b7e7b576ec9c09ded620 100644 --- a/port/devenv.c +++ b/port/devenv.c @@ -231,6 +231,9 @@ envwrite(Chan *c, void *a, long n, ulong offset) } Dev envdevtab = { + 'e', + "env", + devreset, devinit, envattach, diff --git a/port/devkprof.c b/port/devkprof.c index 098bbf39a80e0ef97d31746958523e7e406420cf..c44c0a2311591fff606b99ab30f7b11ff12b81c6 100644 --- a/port/devkprof.c +++ b/port/devkprof.c @@ -169,6 +169,9 @@ kprofwrite(Chan *c, char *a, long n, ulong) } Dev kprofdevtab = { + 'T', + "kprof", + devreset, kprofinit, kprofattach, diff --git a/port/devlance.c b/port/devlance.c index 1693b0fac46d65761164c95e7d5db277b1d41e51..a9a97502ac536c262c57f85143ddff0950f737c6 100644 --- a/port/devlance.c +++ b/port/devlance.c @@ -546,6 +546,9 @@ parseether(uchar *to, char *from) } Dev lancedevtab = { + 'l', + "lance", + lancereset, lanceinit, lanceattach, diff --git a/port/devmnt.c b/port/devmnt.c index 9250031b61cf6e599d81286f7cdfe3264f53818c..40e1635b44f15bf12a0a810f2ba34354627db195 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -668,7 +668,7 @@ mountio(Mnt *m, Mntrpc *r) nexterror(); } else { - if(devchar[m->c->type] == L'M'){ + if(devtab[m->c->type]->dc == L'M'){ if(mnt9prdwr(Twrite, m->c, r->rpc, n, 0) != n) error(Emountrpc); }else{ @@ -718,7 +718,7 @@ mntrpcread(Mnt *m, Mntrpc *r) } r->reply.type = 0; r->reply.tag = 0; - if(devchar[m->c->type] == L'M') + if(devtab[m->c->type]->dc == L'M') n = mnt9prdwr(Tread, m->c, r->rpc, MAXRPC, 0); else n = devtab[m->c->type]->read(m->c, r->rpc, MAXRPC, 0); @@ -940,8 +940,11 @@ mntchk(Chan *c) void mntdirfix(uchar *dirbuf, Chan *c) { - dirbuf[DIRLEN-4] = devchar[c->type]>>0; - dirbuf[DIRLEN-3] = devchar[c->type]>>8; + int r; + + r = devtab[c->type]->dc; + dirbuf[DIRLEN-4] = r>>0; + dirbuf[DIRLEN-3] = r>>8; dirbuf[DIRLEN-2] = c->dev; dirbuf[DIRLEN-1] = c->dev>>8; } @@ -1055,6 +1058,9 @@ mntrepl(char *buf) } Dev mntdevtab = { + 'm', + "mnt", + mntreset, devinit, mntattach, diff --git a/port/devmouse.c b/port/devmouse.c index 158e65d1ba6f878a65e762bea86647340c8943bb..574b56ae53e14af102e7a854a3f2b18c96d22dfc 100644 --- a/port/devmouse.c +++ b/port/devmouse.c @@ -288,6 +288,9 @@ mousewrite(Chan *c, void *va, long n, ulong) } Dev mousedevtab = { + 'm', + "mouse", + mousereset, mouseinit, mouseattach, diff --git a/port/devns16552.c b/port/devns16552.c index f2a14905b0c3f29595148ce976887acf4a77e61d..fc88420725eaacc7b76f08c6e51dd06a20fe6126 100644 --- a/port/devns16552.c +++ b/port/devns16552.c @@ -942,6 +942,9 @@ ns16552wstat(Chan *c, char *dp) } Dev ns16552devtab = { + 't', + "ns16552", + ns16552reset, devinit, ns16552attach, diff --git a/port/devpipe.c b/port/devpipe.c index 781963c7b9444da36d3a44b58bbf2c38edee2d15..19c81f62d241cda0113b0e703d31c948b72223af 100644 --- a/port/devpipe.c +++ b/port/devpipe.c @@ -349,6 +349,9 @@ pipebwrite(Chan *c, Block *bp, ulong) } Dev pipedevtab = { + '|', + "pipe", + devreset, pipeinit, pipeattach, diff --git a/port/devproc.c b/port/devproc.c index b7da7fb4c1107d530e28f65ae59ab19f0247c0bd..5962be1ff13307f69b49fb82ff4600096f9e036f 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -619,6 +619,9 @@ procwrite(Chan *c, void *va, long n, ulong offset) } Dev procdevtab = { + 'p', + "proc", + devreset, procinit, procattach, diff --git a/port/devroot.c b/port/devroot.c index 0b289ee0a69bb77c4877f65416483cdff0c5d4c2..69ca9b9e7ced0838c97415513c417cb3130bae7d 100644 --- a/port/devroot.c +++ b/port/devroot.c @@ -213,6 +213,9 @@ rootwrite(Chan *c, void *buf, long n, ulong) } Dev rootdevtab = { + '/', + "root", + rootreset, devinit, rootattach, diff --git a/port/devsd.c b/port/devsd.c index bf484ea1df7bd829f038f8af75c65e0ca9a8a3ad..3140d172f25babcf2659eb8f2de5dda9aca88dbd 100644 --- a/port/devsd.c +++ b/port/devsd.c @@ -252,6 +252,9 @@ sdwrite(Chan *c, char *a, long n, ulong offset) } Dev sddevtab = { + 'w', + "sd", + devreset, sdinit, sdattach, diff --git a/port/devsrv.c b/port/devsrv.c index c2c8230799a109f46fe524eb42faf6d507ef2f87..99004e5138b2368b593a158428db06a6bc6b12fd 100644 --- a/port/devsrv.c +++ b/port/devsrv.c @@ -249,6 +249,9 @@ srvwrite(Chan *c, void *va, long n, ulong) } Dev srvdevtab = { + 's', + "srv", + devreset, srvinit, srvattach, diff --git a/port/devssl.c b/port/devssl.c index f670861b562f8c67481762e9f41b612e9bfbd56f..a3e1a5551237f87fa8cc9e0c7f80c8c76393c3ad 100644 --- a/port/devssl.c +++ b/port/devssl.c @@ -879,6 +879,9 @@ out: } Dev ssldevtab = { + 'D', + "ssl", + devreset, sslinit, sslattach, diff --git a/port/devtinyfs.c b/port/devtinyfs.c index c8d568347dee978f549548ef2e9b6e7800a30bec..48e75d15a29c099b541499a09fa4c9682abf4856 100644 --- a/port/devtinyfs.c +++ b/port/devtinyfs.c @@ -872,6 +872,9 @@ tinyfswrite(Chan *c, void *a, long n, ulong offset) } Dev tinyfsdevtab = { + 'U', + "tinyfs", + tinyfsreset, devinit, tinyfsattach, diff --git a/port/portdat.h b/port/portdat.h index 94d4dbacfceeb30667d05ae48c488109fcc17311..6bb8196b253834b72a16c544377331605b578615 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -166,6 +166,9 @@ struct Chan struct Dev { + int dc; + char* name; + void (*reset)(void); void (*init)(void); Chan* (*attach)(char*); @@ -620,7 +623,6 @@ enum extern Conf conf; extern char* conffile; extern int cpuserver; -extern Rune* devchar; extern Dev* devtab[]; extern char eve[]; extern char hostdomain[]; diff --git a/port/sysfile.c b/port/sysfile.c index 0ffdffeaa9f59dcda1bd94715cc0c8a2fd4944ac..ea5dede0ea97edf55f9308ead2b321ad5864b94f 100644 --- a/port/sysfile.c +++ b/port/sysfile.c @@ -317,7 +317,7 @@ sysread9p(ulong *arg) if(dir && c->mnt) n = unionread(c, (void*)arg[1], n); - else if(devchar[c->type] != L'M') + else if(devtab[c->type]->dc != L'M') n = devtab[c->type]->read(c, (void*)arg[1], n, c->offset); else n = mntread9p(c, (void*)arg[1], n, c->offset); @@ -386,7 +386,7 @@ syswrite9p(ulong *arg) if(c->qid.path & CHDIR) error(Eisdir); - if(devchar[c->type] != L'M') + if(devtab[c->type]->dc != L'M') n = devtab[c->type]->write(c, (void*)arg[1], arg[2], c->offset); else n = mntwrite9p(c, (void*)arg[1], arg[2], c->offset); @@ -440,7 +440,7 @@ sysseek(ulong *arg) if(c->qid.path & CHDIR) error(Eisdir); - if(devchar[c->type] == '|') + if(devtab[c->type]->dc == '|') error(Eisstream); off = 0; diff --git a/port/sysproc.c b/port/sysproc.c index 811554a3db5aecc9817761c781c4b0932d483f3f..88bccbe55565f2cc32b285a62cf9dfb00d944859 100644 --- a/port/sysproc.c +++ b/port/sysproc.c @@ -397,7 +397,7 @@ sysexec(ulong *arg) /* * '/' processes are higher priority (hack to make /ip more responsive). */ - if(devchar[tc->type] == L'/') + if(devtab[tc->type]->dc == L'/') up->basepri = PriRoot; up->priority = up->basepri; poperror();