| plan 9 kernel history: overview | file list | diff list |
2000/0726/alphapc/devarch.c (diff list | history)
| 2000/0726/sys/src/9/alphapc/devarch.c:27,50 – 2001/0727/sys/src/9/alphapc/devarch.c:27,96 (short | long | prev | next) | ||
| 2000/0401 | } iomap; enum { | |
| 2001/0727 | Qdir = 0, Qioalloc = 1, | |
| 2000/0401 | Qiob, Qiow, Qiol, | |
| 2001/0727 | Qbase, Qmax = 16, | |
| 2000/0401 | }; | |
| 2001/0727 | typedef long Rdwrfn(Chan*, void*, long, vlong); static Rdwrfn *readfn[Qmax]; static Rdwrfn *writefn[Qmax]; static Dirtab archdir[] = { ".", { Qdir, 0, QTDIR }, 0, 0555, | |
| 2000/0401 | "ioalloc", { Qioalloc, 0 }, 0, 0444, "iob", { Qiob, 0 }, 0, 0660, "iow", { Qiow, 0 }, 0, 0660, "iol", { Qiol, 0 }, 0, 0660, | |
| 2001/0727 | Lock archwlock; /* the lock is only for changing archdir */ int narchdir = Qbase; | |
| 2000/0401 | ||
| 2001/0727 | /* * Add a file to the #P listing. Once added, you can't delete it. * You can't add a file with the same name as one already there, * and you get a pointer to the Dirtab entry so you can do things * like change the Qid version. Changing the Qid path is disallowed. */ Dirtab* addarchfile(char *name, int perm, Rdwrfn *rdfn, Rdwrfn *wrfn) { int i; Dirtab d; Dirtab *dp; memset(&d, 0, sizeof d); strcpy(d.name, name); d.perm = perm; lock(&archwlock); if(narchdir >= Qmax){ unlock(&archwlock); return nil; } for(i=0; i<narchdir; i++) if(strcmp(archdir[i].name, name) == 0){ unlock(&archwlock); return nil; } d.qid.path = narchdir; archdir[narchdir] = d; readfn[narchdir] = rdfn; writefn[narchdir] = wrfn; dp = &archdir[narchdir++]; unlock(&archwlock); return dp; } | |
| 2000/0401 | void ioinit(void) { | |
| 2000/0726/sys/src/9/alphapc/devarch.c:59,66 – 2001/0727/sys/src/9/alphapc/devarch.c:105,110 | ||
| 2000/0726 | ioalloc(0x20000, 1, 0, "dummy"); | |
| 2000/0401 | } | |
| 2000/0726/sys/src/9/alphapc/devarch.c:115,121 – 2001/0727/sys/src/9/alphapc/devarch.c:159,165 | ||
| 2000/0401 | m->tag[sizeof(m->tag)-1] = 0; *l = m; | |
| 2001/0727 | archdir[0].qid.vers++; | |
| 2000/0401 | unlock(&iomap); return m->start; | |
| 2000/0726/sys/src/9/alphapc/devarch.c:138,144 – 2001/0727/sys/src/9/alphapc/devarch.c:182,188 | ||
| 2000/0401 | if((*l)->start > port) break; } | |
| 2001/0727 | archdir[0].qid.vers++; | |
| 2000/0401 | unlock(&iomap); } | |
| 2000/0726/sys/src/9/alphapc/devarch.c:175,196 – 2001/0727/sys/src/9/alphapc/devarch.c:219,240 | ||
| 2000/0401 | return devattach('P', spec); } | |
| 2001/0727 | Walkqid* archwalk(Chan* c, Chan *nc, char** name, int nname) | |
| 2000/0401 | { | |
| 2001/0727 | return devwalk(c, nc, name, nname, archdir, narchdir, devgen); | |
| 2000/0401 | } | |
| 2001/0727 | static int archstat(Chan* c, uchar* dp, int n) | |
| 2000/0401 | { | |
| 2001/0727 | return devstat(c, dp, n, archdir, narchdir, devgen); | |
| 2000/0401 | } static Chan* archopen(Chan* c, int omode) { | |
| 2001/0727 | return devopen(c, omode, archdir, nelem(archdir), devgen); | |
| 2000/0401 | } static void | |
| 2000/0726/sys/src/9/alphapc/devarch.c:206,222 – 2001/0727/sys/src/9/alphapc/devarch.c:250,266 | ||
| 2000/0401 | static long archread(Chan *c, void *a, long n, vlong offset) { | |
| 2001/0727 | char buf[Linelen+1], *p; | |
| 2000/0401 | int port; ushort *sp; ulong *lp; | |
| 2001/0727 | IOMap *m; Rdwrfn *fn; | |
| 2000/0401 |
| |
| 2001/0727 | switch((ulong)c->qid.path){ | |
| 2000/0401 | case Qdir: | |
| 2001/0727 | return devdirread(c, a, n, archdir, nelem(archdir), devgen); | |
| 2000/0401 | case Qiob: port = offset; | |
| 2000/0726/sys/src/9/alphapc/devarch.c:248,260 – 2001/0727/sys/src/9/alphapc/devarch.c:292,300 | ||
| 2000/0401 | case Qioalloc: break; | |
| 2001/0727 | if(c->qid.path < narchdir && (fn = readfn[c->qid.path])) return fn(c, a, n, offset); | |
| 2000/0401 | error(Eperm); break; } | |
| 2000/0726/sys/src/9/alphapc/devarch.c:281,292 – 2001/0727/sys/src/9/alphapc/devarch.c:321,333 | ||
| 2000/0401 | static long archwrite(Chan *c, void *a, long n, vlong offset) { | |
| 2001/0727 | char *p; | |
| 2000/0401 | int port; ushort *sp; ulong *lp; | |
| 2001/0727 | Rdwrfn *fn; | |
| 2000/0401 |
| |
| 2001/0727 | switch((ulong)c->qid.path){ | |
| 2000/0401 | case Qiob: p = a; | |
| 2000/0726/sys/src/9/alphapc/devarch.c:316,321 – 2001/0727/sys/src/9/alphapc/devarch.c:357,364 | ||
| 2000/0401 | return n*4; default: | |
| 2001/0727 | if(c->qid.path < narchdir && (fn = writefn[c->qid.path])) return fn(c, a, n, offset); | |
| 2000/0401 | error(Eperm); break; } | |
| 2000/0726/sys/src/9/alphapc/devarch.c:329,335 – 2001/0727/sys/src/9/alphapc/devarch.c:372,377 | ||
| 2000/0401 | devreset, devinit, archattach, | |
| 2000/0726/sys/src/9/alphapc/devarch.c:366,387 – 2001/0727/sys/src/9/alphapc/devarch.c:408,413 | ||
| 2000/0401 | }; void | |
| 2000/0726/sys/src/9/alphapc/devarch.c:419,425 – 2001/0727/sys/src/9/alphapc/devarch.c:445,451 | ||
| 2000/0401 | } static long | |
| 2001/0727 | cputyperead(Chan*, void *a, long n, vlong offset) | |
| 2000/0401 | { char str[32], *cputype; ulong mhz, maj; | |
| 2000/0726/sys/src/9/alphapc/devarch.c:434,437 – 2001/0727/sys/src/9/alphapc/devarch.c:460,481 | ||
| 2000/0401 | snprint(str, sizeof(str), "%s %lud\n", cputype, mhz); return readstr(offset, a, n, str); | |
| 2001/0727 | } void archinit(void) { PCArch **p; arch = 0; for(p = knownarch; *p; p++){ if((*p)->ident && (*p)->ident() == 0){ arch = *p; break; } } if(arch == 0) arch = &archgeneric; addarchfile("cputype", 0444, cputyperead, nil); | |
| 2000/0401 | } | |