From 7c848aca21eee26d8d5d56454d724caab03a0d0a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 1 May 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-05-01 --- alphapc/arch164.c | 10 ++++++++-- alphapc/clock.c | 4 ++-- alphapc/devfloppy.c | 28 +++++++++++++++++++++++++--- alphapc/dma.c | 22 +++++++++++++++------- boot/local.c | 10 +++++----- ip/il.c | 1 + pc/devastar.c | 2 +- pc/fns.h | 2 +- port/alloc.c | 20 ++++++++++++++++++++ port/chan.c | 2 +- port/debugalloc.c | 8 ++++---- port/devdraw.c | 2 +- port/devpipe.c | 2 +- port/qio.c | 6 +++--- port/qlock.c | 2 +- port/taslock.c | 16 ++++++++-------- 16 files changed, 97 insertions(+), 40 deletions(-) diff --git a/alphapc/arch164.c b/alphapc/arch164.c index 6c817623da56787dbbad4bd911fb5970a19492e2..e6a146d2855c851a6c2f85aea1ed8af22be3f69e 100644 --- a/alphapc/arch164.c +++ b/alphapc/arch164.c @@ -42,7 +42,7 @@ sginit(void) for(pa = 0; pa < 8*1024*1024; pa += BY2PG) *pte++ = ((pa>>PGSHIFT)<<1)|1; - wind[0x400/4] = ISAWINDOW|2; + wind[0x400/4] = ISAWINDOW|4|2|1; wind[0x440/4] = 0x00700000; wind[0x480/4] = PADDR(sgmap); } @@ -91,7 +91,7 @@ sginit(); core[0x8200/4] = 0x7ff; /* set config: byte/word enable, no monster window, etc. */ - core[0x140/4] = 1; + core[0x140/4] = 0x21; /* turn off mcheck on master abort. now we can probe PCI space. */ core[0x8280/4] &= ~(1<<7); @@ -101,6 +101,12 @@ sginit(); cserve(52, 4); /* enable SIO interrupt */ } +void +ciaerror(void) +{ + print("cia error 0x%luX\n", core[0x8200/4]); +} + static void corehello(void) { diff --git a/alphapc/clock.c b/alphapc/clock.c index f2622e8a61f32cb652b459dc497d23ef72163168..e7d3b041d859b8f264fcc388bda836b00d95fdb8 100644 --- a/alphapc/clock.c +++ b/alphapc/clock.c @@ -91,8 +91,8 @@ microdelay(int us) { uvlong eot; - eot = cycletimer() + (m->cpuhz/1000000)*us; - while(cycletimer() < eot) + eot = fastticks(nil) + (m->cpuhz/1000000)*us; + while(fastticks(nil) < eot) ; } diff --git a/alphapc/devfloppy.c b/alphapc/devfloppy.c index 0fc8b78a22af0ee1112ef844ca2c09ff8236215c..57410a2546cb11d147a19d81fff3992246d65a89 100644 --- a/alphapc/devfloppy.c +++ b/alphapc/devfloppy.c @@ -39,7 +39,7 @@ enum { }; #define DPRINT if(floppydebug)print -int floppydebug = 0; +int floppydebug = 1; /* * types of drive (from PC equipment byte) @@ -56,12 +56,14 @@ enum FType floppytype[] = { { "3½HD", T1440kb, 512, 18, 2, 1, 80, 0x1B, 0x54, 0, }, +/* { "3½DD", T1440kb, 512, 9, 2, 1, 80, 0x1B, 0x54, 2, }, { "3½DD", T720kb, 512, 9, 2, 1, 80, 0x1B, 0x54, 2, }, { "5¼HD", T1200kb, 512, 15, 2, 1, 80, 0x2A, 0x50, 0, }, { "5¼DD", T1200kb, 512, 9, 2, 2, 40, 0x2A, 0x50, 1, }, { "ATT3B1", T1200kb, 512, 8, 2, 2, 48, 0x2A, 0x50, 1, }, { "5¼DD", T360kb, 512, 9, 2, 1, 40, 0x2A, 0x50, 2, }, + */ }; /* @@ -533,6 +535,7 @@ floppycmd(void) microdelay(8); /* for machine independence */ } outb(Pfdata, fl.cmd[i]); +microdelay(8); /* for machine independence */ } return 0; } @@ -636,7 +639,11 @@ cmddone(void *) static void floppywait(void) { +vlong t0, t1; +t0 = fastticks(nil); tsleep(&fl.r, cmddone, 0, 5000); +t1 = fastticks(nil); +print("wait %lld ticks\n", t1-t0); if(!cmddone(0)){ floppyintr(0); fl.confused = 1; @@ -680,9 +687,22 @@ floppyrecal(FDrive *dp) return 0; } +static void +specify(void) +{ + fl.ncmd = 0; + fl.cmd[fl.ncmd++] = Fspec; + fl.cmd[fl.ncmd++] = 0; + fl.cmd[fl.ncmd++] = 1; + if(floppycmd() < 0) + return; + floppywait(); + fldump(); +} + /* * if the controller or a specific drive is in a confused state, - * reset it and get back to a kown state + * reset it and get back to a known state */ static void floppyrevive(void) @@ -774,7 +794,7 @@ floppyxfer(FDrive *dp, int cmd, void *a, long off, long n) /* retry on error (until it gets ridiculous) */ tries = 0; while(waserror()){ - if(tries++ > 20) + if(tries++ > 2/*0*/) nexterror(); DPRINT("floppyxfer: retrying\n"); /*floppyon(dp);*/ @@ -820,6 +840,8 @@ floppyxfer(FDrive *dp, int cmd, void *a, long off, long n) /* * give bus to DMA, floppyintr() will read result */ +delay(10); +print("msr 0x%2.2uX\n", inb(Pmsr)); floppywait(); dmaend(DMAchan); poperror(); diff --git a/alphapc/dma.c b/alphapc/dma.c index d91246998183ab4fe2274d61ba6a14ec26182141..9e515ed5edbfc6d78b46cf7934cd84b1e43ad986 100644 --- a/alphapc/dma.c +++ b/alphapc/dma.c @@ -85,6 +85,7 @@ dmainit(int chan, int maxtransfer) return 1; return 0; } +outb(dp->mc, 0); xp->bva = xspanalloc(maxtransfer, BY2PG, 64*1024); if(xp->bva == nil) @@ -126,14 +127,15 @@ dmasetup(int chan, void *va, long len, int isread) dp = &dma[(chan>>2)&1]; chan = chan & 3; +//print("va%lux+", va); +#define tryPCI +#ifdef notdef xp = &dp->x[chan]; /* * if this isn't kernel memory or crossing 64k boundary or above 16 meg * use the bounce buffer. */ -print("va%lux+", va); -#ifdef notdef pa = PADDR(va); if((((ulong)va)&0xF0000000) != KZERO || (pa&0xFFFF0000) != ((pa+len)&0xFFFF0000) @@ -151,9 +153,13 @@ print("va%lux+", va); } else xp->len = 0; -#else - pa = ISAWADDR(va); #endif /* notdef */ +#ifdef tryISA + pa = ISAWADDR(va); +#endif /* tryISA */ +#ifdef tryPCI + pa = PCIWADDR(va); +#endif /* tryPCI */ /* * this setup must be atomic @@ -165,12 +171,14 @@ print("va%lux+", va); outb(dp->addr[chan], pa>>dp->shift); /* set address */ outb(dp->addr[chan], pa>>(8+dp->shift)); outb(dp->page[chan], pa>>16); -//outb(0x400|dp->page[chan], pa>>24); +#ifdef tryPCI + outb(0x400|dp->page[chan], pa>>24); +#endif /* tryPCI */ outb(dp->count[chan], (len>>dp->shift)-1); /* set count */ outb(dp->count[chan], ((len>>dp->shift)-1)>>8); outb(dp->sbm, chan); /* enable the channel */ iunlock(dp); -print("pa%lux+", pa); +//print("pa%lux+", pa); return len; } @@ -215,7 +223,7 @@ i = inb(dp->addr[chan]); i |= inb(dp->addr[chan])<<8; i |= inb(dp->page[chan])<<16; i |= inb(0x400|dp->page[chan])<<24; -print("X%uX+", i); +//print("X%uX+", i); } xp = &dp->x[chan]; diff --git a/boot/local.c b/boot/local.c index 79cc7480948953f52cb0d1f26c6ff8d3df62923f..2139b7c738fa254ef057e1e25be94f21abede967 100644 --- a/boot/local.c +++ b/boot/local.c @@ -62,7 +62,7 @@ connectlocal(void) char *dev; char *args[16], **argp; - if(stat("/fs", d) < 0) + if(stat("/kfs", d) < 0) return -1; dev = disk ? disk : bootdisk; @@ -73,7 +73,7 @@ connectlocal(void) return -1; } - print("fs..."); + print("kfs..."); if(bind("#c", "/dev", MREPL) < 0) fatal("bind #c"); if(bind("#p", "/proc", MREPL) < 0) @@ -89,13 +89,13 @@ connectlocal(void) close(p[0]); close(p[1]); argp = args; - *argp++ = "fs"; + *argp++ = "kfs"; *argp++ = "-f"; *argp++ = partition; *argp++ = "-s"; *argp = 0; - exec("/fs", args); - fatal("can't exec fs"); + exec("/kfs", args); + fatal("can't exec kfs"); default: break; } diff --git a/ip/il.c b/ip/il.c index ffb57a5c1196e1c47e35f9431eaaae1cf82ce16e..3a390ea6d669027dfeebd27108d2cc26107cc90f 100644 --- a/ip/il.c +++ b/ip/il.c @@ -190,6 +190,7 @@ void iliput(Proto*, uchar*, Block*); void iladvise(Proto*, Block*, char*); int ilnextqt(Ilcb*); void ilcbinit(Ilcb*); +int later(ulong, ulong, char*); int ilcksum = 1; static int initseq = 25001; diff --git a/pc/devastar.c b/pc/devastar.c index 7f6ed1ee1e8ad598b79dc779eac20826ec3286d8..84f053b810bbc615ef36a8fc7879d612cd2f72fd 100644 --- a/pc/devastar.c +++ b/pc/devastar.c @@ -322,7 +322,7 @@ setpage(Astar *a, ulong offset) int i; if(a->pci){ - print("#G%d: setpage caller pc %luX\n", a->id, getcallerpc(a)); + print("#G%d: setpage caller pc %luX\n", a->id, getcallerpc(&a)); return; } diff --git a/pc/fns.h b/pc/fns.h index 65fa731fdfa57f2842d0add92f8a3ece59de0a09..e09aa4bd2cb9312e7468a209ad58b0cb235ade81 100644 --- a/pc/fns.h +++ b/pc/fns.h @@ -115,7 +115,7 @@ int xchgw(ushort*, int); ulong TK2MS(ulong); /* ticks to milliseconds */ #define waserror() (up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1])) -#define getcallerpc(x) (((ulong*)(&x))[-1]) +#define getcallerpc(x) (((ulong*)(x))[-1]) #define KADDR(a) ((void*)((ulong)(a)|KZERO)) #define PADDR(a) ((ulong)(a)&~KZERO) diff --git a/port/alloc.c b/port/alloc.c index 4bf2546b79c8049a0a22d1053ff13f435352e7c4..57df945ba3058cd1ec5544bc44439d172303d8d1 100644 --- a/port/alloc.c +++ b/port/alloc.c @@ -368,6 +368,11 @@ malloc(ulong size) v = poolalloc(mainmem, size); if(v != nil) memset(v, 0, size); +{ +Bhdr *h; +D2B(h, v); +B2T(h)->pad = getcallerpc(&size); +} return v; } @@ -383,6 +388,11 @@ smalloc(ulong size) tsleep(&up->sleep, return0, 0, 100); } memset(v, 0, size); +{ +Bhdr *h; +D2B(h, v); +B2T(h)->pad = getcallerpc(&size); +} return v; } @@ -394,6 +404,11 @@ mallocz(ulong size, int clr) v = poolalloc(mainmem, size); if(clr && v != nil) memset(v, 0, size); +{ +Bhdr *h; +D2B(h, v); +B2T(h)->pad = getcallerpc(&size); +} return v; } @@ -429,6 +444,11 @@ realloc(void *v, ulong size) memmove(nv, v, osize); free(v); } +{ +Bhdr *h; +D2B(h, nv); +B2T(h)->pad = getcallerpc(&size); +} return nv; } diff --git a/port/chan.c b/port/chan.c index 9ab18fd776a0aa414499b7cf16c8f8b87b9e91d8..7bcc237e46642fbbb3cf36d0105945002efc4f22 100644 --- a/port/chan.c +++ b/port/chan.c @@ -144,7 +144,7 @@ void cclose(Chan *c) { if(c->flag&CFREE) - panic("cclose %lux", getcallerpc(c)); + panic("cclose %lux", getcallerpc(&c)); if(decref(c)) return; diff --git a/port/debugalloc.c b/port/debugalloc.c index cb10ed1a960de840ad6e81c20fa1a701e25a7341..530c2373b7689513f0f7b90b4aaff140fc27660e 100644 --- a/port/debugalloc.c +++ b/port/debugalloc.c @@ -414,7 +414,7 @@ malloc(ulong size) void *v; v = poolalloc(mainmem, size); -remember(getcallerpc(size), v); +remember(getcallerpc(&size), v); if(v != nil) memset(v, 0, size); return v; @@ -427,7 +427,7 @@ smalloc(ulong size) for(;;) { v = poolalloc(mainmem, size); -remember(getcallerpc(size), v); +remember(getcallerpc(&size), v); if(v != nil) break; tsleep(&up->sleep, return0, 0, 100); @@ -442,7 +442,7 @@ mallocz(ulong size, int clr) void *v; v = poolalloc(mainmem, size); -remember(getcallerpc(size), v); +remember(getcallerpc(&size), v); if(clr && v != nil) memset(v, 0, size); return v; @@ -477,7 +477,7 @@ realloc(void *v, ulong size) return v; nv = poolalloc(mainmem, size); -remember(getcallerpc(v), nv); +remember(getcallerpc(&v), nv); if(nv != nil) { memmove(nv, v, osize); free(v); diff --git a/port/devdraw.c b/port/devdraw.c index 26928306a020095c6eb8748fb2884a1f89d4af91..9c7a412bdd2235a17e9f9d26412f88676deea3d8 100644 --- a/port/devdraw.c +++ b/port/devdraw.c @@ -1787,7 +1787,7 @@ Dev drawdevtab = { * On 8 bit displays, load the default color map */ void -drawcmap(invert){ +drawcmap(int invert){ int r, g, b, cr, cg, cb, v; int num, den; int i, j; diff --git a/port/devpipe.c b/port/devpipe.c index b3021334bd814b2183e67be8bec0a3a3adcbd047..d0acffb43e23882d4d5726e2e8661fd83c30435c 100644 --- a/port/devpipe.c +++ b/port/devpipe.c @@ -289,7 +289,7 @@ pipewrite(Chan *c, void *va, long n, vlong) Pipe *p; if(!islo()) - print("pipewrite hi %lux\n", getcallerpc(c)); + print("pipewrite hi %lux\n", getcallerpc(&c)); if(waserror()) { /* avoid notes when pipe is a mounted queue */ if((c->flag & CMSG) == 0) diff --git a/port/qio.c b/port/qio.c index 6e41ea96a2be2888b1668878f25ca9e06b0fa5b9..aec41e15e3794e7a6722682448ee762b35262fc8 100644 --- a/port/qio.c +++ b/port/qio.c @@ -242,7 +242,7 @@ padblock(Block *bp, int size) } if(bp->next) - panic("padblock 0x%uX", getcallerpc(bp)); + panic("padblock 0x%uX", getcallerpc(&bp)); n = BLEN(bp); padblockcnt++; nbp = allocb(size+n); @@ -256,7 +256,7 @@ padblock(Block *bp, int size) size = -size; if(bp->next) - panic("padblock 0x%uX", getcallerpc(bp)); + panic("padblock 0x%uX", getcallerpc(&bp)); if(bp->lim - bp->wp >= size) return bp; @@ -1105,7 +1105,7 @@ qwrite(Queue *q, void *vp, int len) uchar *p = vp; QDEBUG if(islo() == 0) - print("qwrite hi %lux\n", getcallerpc(q)); + print("qwrite hi %lux\n", getcallerpc(&q)); sofar = 0; do { diff --git a/port/qlock.c b/port/qlock.c index f26b1284266d183edd6347244744b1e9e8dd5fdd..02685246c219ed4d410b6d8616c774c29c955d28 100644 --- a/port/qlock.c +++ b/port/qlock.c @@ -37,7 +37,7 @@ rwstats.qlockq++; q->tail = mp; mp->qnext = 0; mp->state = Queueing; - up->qpc = getcallerpc(q); + up->qpc = getcallerpc(&q); unlock(&q->use); sched(); } diff --git a/port/taslock.c b/port/taslock.c index 5286970a0a59e96ed36360c7417b22b5c4bd3763..51e529a8e36cf6827b78a8a4a30a01b5e590c791 100644 --- a/port/taslock.c +++ b/port/taslock.c @@ -33,7 +33,7 @@ lock(Lock *l) int i, cansched; ulong pc, oldpri; - pc = getcallerpc(l); + pc = getcallerpc(&l); lockstats.locks++; if(tas(&l->key) == 0){ @@ -89,7 +89,7 @@ ilock(Lock *l) ulong pc, oldpri; int cansched; - pc = getcallerpc(l); + pc = getcallerpc(&l); lockstats.locks++; x = splhi(); @@ -138,7 +138,7 @@ canlock(Lock *l) if(tas(&l->key)) return 0; - l->pc = getcallerpc(l); + l->pc = getcallerpc(&l); l->p = up; l->isilock = 0; return 1; @@ -149,9 +149,9 @@ unlock(Lock *l) { if(l->key == 0) - print("unlock: not locked: pc %luX\n", getcallerpc(l)); + print("unlock: not locked: pc %luX\n", getcallerpc(&l)); if(l->isilock) - print("iunlock of lock: pc %lux, held by %lux\n", getcallerpc(l), l->pc); + print("iunlock of lock: pc %lux, held by %lux\n", getcallerpc(&l), l->pc); l->pc = 0; l->key = 0; coherence(); @@ -163,15 +163,15 @@ iunlock(Lock *l) ulong sr; if(l->key == 0) - print("iunlock: not locked: pc %luX\n", getcallerpc(l)); + print("iunlock: not locked: pc %luX\n", getcallerpc(&l)); if(!l->isilock) - print("unlock of ilock: pc %lux, held by %lux\n", getcallerpc(l), l->pc); + print("unlock of ilock: pc %lux, held by %lux\n", getcallerpc(&l), l->pc); sr = l->sr; l->pc = 0; l->key = 0; coherence(); - m->splpc = getcallerpc(l); + m->splpc = getcallerpc(&l); splxpc(sr); }