## diffname power/devbit3.c 1990/0324 ## diff -e /dev/null /n/bootesdump/1990/0324/sys/src/9/mips/devbit3.c 0a #include "u.h" #include "lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "errno.h" #include "devtab.h" #include "io.h" static struct { QLock; int open; char buf[10*1024]; }bit3; #define BIT3ADDR ((Bit3msg**)(KZERO+0x7C)) #define BIT3HOLD ((ulong*)(KZERO+0x78)) #define BIT3INTR ((char*)(UNCACHED|0x17c12001)) enum { RESET, READ, WRITE, }; void bit3send(Bit3msg *bp, ulong cmd, void *addr, ulong count) { do; while(*BIT3ADDR); bp->cmd = cmd; bp->addr = (ulong)addr; bp->count = count; *BIT3ADDR = bp; wbflush(); do; while(*BIT3HOLD); *BIT3INTR = 0x20; } void bit3reset(void) { *BIT3HOLD = 0; *BIT3ADDR = 0; qlock(&bit3); qunlock(&bit3); } void bit3init(void) { } Chan* bit3attach(char *spec) { return devattach('3', spec); } Chan* bit3clone(Chan *c, Chan *nc) { return devclone(c, nc); } int bit3walk(Chan *c, char *name) { if(c->qid != CHDIR) return 0; if(strcmp(name, "bit3") == 0){ c->qid = 1; return 1; } return 0; } void bit3stat(Chan *c, char *dp) { print("bit3stat\n"); error(0, Egreg); } Chan* bit3open(Chan *c, int omode) { Bit3msg *bp; bp = &((User*)(u->p->upage->pa|KZERO))->bit3; if(c->qid!=1 || omode!=ORDWR) error(0, Eperm); qlock(&bit3); if(bit3.open){ qunlock(&bit3); error(0, Einuse); } bit3send(bp, RESET, 0, 0); bit3.open = 1; qunlock(&bit3); c->mode = openmode(omode); c->flag |= COPEN; c->offset = 0; return c; } void bit3create(Chan *c, char *name, int omode, ulong perm) { error(0, Eperm); } void bit3close(Chan *c) { qlock(&bit3); bit3.open = 0; qunlock(&bit3); } /* * Read and write use physical addresses if they can, which they usually can. * Most I/O is from devmnt, which has local buffers. Therefore just check * that buf is in KSEG0 and is at an even address. The only killer is that * DMA counts from the bit3 device are mod 256, so devmnt must use oversize * buffers. */ long bit3read(Chan *c, void *buf, long n) { Bit3msg *bp; int docpy; bp = &((User*)(u->p->upage->pa|KZERO))->bit3; bp->rcount = 0; switch(c->qid){ case 1: if(n > sizeof bit3.buf) error(0, Egreg); docpy = 0; qlock(&bit3); if((((ulong)buf)&(KSEGM|3)) == KSEG0) bit3send(bp, READ, buf, n); else{ bit3send(bp, READ, bit3.buf, n); docpy = 1; } qunlock(&bit3); do n = bp->rcount; while(n == 0); if(docpy) memcpy(buf, bit3.buf, n); return n; } error(0, Egreg); return 0; } long bit3write(Chan *c, void *buf, long n) { Bit3msg *bp; bp = &((User*)(u->p->upage->pa|KZERO))->bit3; switch(c->qid){ case 1: if(n > sizeof bit3.buf) error(0, Egreg); qlock(&bit3); if((((ulong)buf)&(KSEGM|3)) == KSEG0) bit3send(bp, WRITE, buf, n); else{ memcpy(bit3.buf, buf, n); bit3send(bp, WRITE, bit3.buf, n); } qunlock(&bit3); return n; } error(0, Egreg); return 0; } void bit3remove(Chan *c) { error(0, Eperm); } void bit3wstat(Chan *c, char *dp) { error(0, Eperm); } void bit3userstr(Error *e, char *buf) { consuserstr(e, buf); } void bit3errstr(Error *e, char *buf) { rooterrstr(e, buf); } . ## diffname power/devbit3.c 1990/06061 ## diff -e /n/bootesdump/1990/0324/sys/src/9/mips/devbit3.c /n/bootesdump/1990/06061/sys/src/9/mips/devbit3.c 180d 178a qunlock(&bit3); qunlock(&bit3.buflock); . 176c qunlock(&bit3); }else{ qlock(&bit3.buflock); qlock(&bit3); . 173,174c if((((ulong)buf)&(KSEGM|3)) == KSEG0){ qlock(&bit3); . 156a qunlock(&bit3.buflock); } . 149,155c qunlock(&bit3); do n = bp->rcount; while(n == 0); . 147c qunlock(&bit3); do n = bp->rcount; while(n == 0); }else{ /* * use bit3 buffer. lock the buffer till the reply */ qlock(&bit3.buflock); qlock(&bit3); . 143,145c if((((ulong)buf)&(KSEGM|3)) == KSEG0){ /* * use supplied buffer, no need to lock for reply */ qlock(&bit3); . 13a QLock buflock; . ## diffname power/devbit3.c 1990/0608 ## diff -e /n/bootesdump/1990/06061/sys/src/9/mips/devbit3.c /n/bootesdump/1990/0608/sys/src/9/mips/devbit3.c 193a . 192a do; while(*BIT3ADDR); . 189a . 188a bp = &((User*)(u->p->upage->pa|KZERO))->ubit3; . 184a bp = &((User*)(u->p->upage->pa|KZERO))->kbit3; . 179d 165a . 158a . 157a bp = &((User*)(u->p->upage->pa|KZERO))->ubit3; bp->rcount = 0; . 147a bp = &((User*)(u->p->upage->pa|KZERO))->kbit3; bp->rcount = 0; . 138,139d 93c bp = &((User*)(u->p->upage->pa|KZERO))->kbit3; . ## diffname power/devbit3.c 1990/11211 ## diff -e /n/bootesdump/1990/0608/sys/src/9/mips/devbit3.c /n/bootesdump/1990/11211/sys/src/9/mips/devbit3.c 219,231c error(Eperm); . 213c error(Eperm); . 206c error(Egreg); . 186c error(Egreg); . 183c switch(c->qid.path){ . 174c error(Egreg); . 141c error(Egreg); . 138c switch(c->qid.path){ . 113c error(Eperm); . 99c error(Einuse); . 94,95c if(c->qid.path!=1 || omode!=ORDWR) error(Eperm); . 85c error(Egreg); . 75c c->qid.path = 1; . 72c if(c->qid.path != CHDIR) . ## diffname power/devbit3.c 1990/1122 ## diff -e /n/bootesdump/1990/11211/sys/src/9/mips/devbit3.c /n/bootesdump/1990/1122/sys/src/9/mips/devbit3.c 169d 161d 153a qunlock(&bit3.buflock); /* BUG */ . 147a qlock(&bit3.buflock); /* BUG */ . ## diffname power/devbit3.c 1990/1123 ## diff -e /n/bootesdump/1990/1122/sys/src/9/mips/devbit3.c /n/bootesdump/1990/1123/sys/src/9/mips/devbit3.c 155d 148d ## diffname power/devbit3.c 1991/0318 ## diff -e /n/bootesdump/1991/0201/sys/src/9/mips/devbit3.c /n/bootesdump/1991/0318/sys/src/9/power/devbit3.c 195c memmove(bit3.buf, buf, n); . 167c memmove(buf, bit3.buf, n); . ## diffname power/devbit3.c 1991/0411 ## diff -e /n/bootesdump/1991/0318/sys/src/9/power/devbit3.c /n/bootesdump/1991/0411/sys/src/9/power/devbit3.c 177c bit3write(Chan *c, void *buf, long n, ulong offset) . 133c bit3read(Chan *c, void *buf, long n, ulong offset) . ## diffname power/devbit3.c 1991/0421 ## diff -e /n/bootesdump/1991/0411/sys/src/9/power/devbit3.c /n/bootesdump/1991/0421/sys/src/9/power/devbit3.c 68a Chan* bit3clwalk(Chan *c, char *name) { return devclwalk(c, name); } . ## diffname power/devbit3.c 1991/0425 ## diff -e /n/bootesdump/1991/0421/sys/src/9/power/devbit3.c /n/bootesdump/1991/0425/sys/src/9/power/devbit3.c 40a . 32a . ## diffname power/devbit3.c 1991/0427 ## diff -e /n/bootesdump/1991/0425/sys/src/9/power/devbit3.c /n/bootesdump/1991/0427/sys/src/9/power/devbit3.c 71,76d ## diffname power/devbit3.c 1991/0430 ## diff -e /n/bootesdump/1991/0427/sys/src/9/power/devbit3.c /n/bootesdump/1991/0430/sys/src/9/power/devbit3.c 40a m->spinlock += entry - MACHP(0)->ticks; . 33a entry = MACHP(0)->ticks; . 32a int entry; . ## diffname power/devbit3.c 1991/0501 ## diff -e /n/bootesdump/1991/0430/sys/src/9/power/devbit3.c /n/bootesdump/1991/0501/sys/src/9/power/devbit3.c 171a m->spinlock += MACHP(0)->ticks - t0; . 168a t0 = MACHP(0)->ticks; . 158a m->spinlock += MACHP(0)->ticks - t0; . 155a t0 = MACHP(0)->ticks; . 141a ulong t0; . 43d 33,35d ## diffname power/devbit3.c 1991/1112 ## diff -e /n/bootesdump/1991/0501/sys/src/9/power/devbit3.c /n/bootesdump/1991/1112/sys/src/9/power/devbit3.c 172d 168d 157d 153d 138d ## diffname power/devbit3.c 1991/1209 ## diff -e /n/bootesdump/1991/1112/sys/src/9/power/devbit3.c /n/bootesdump/1991/1209/sys/src/9/power/devbit3.c 217a USED(c, dp); . 211a USED(c); . 200d 194d 171d 169a pexit("Suicide", 0); . 167,168c if(n != 0){ memmove(buf, bit3.buf, n); qunlock(&bit3.buflock); return n; } if(i > 5*1000*1000){ u->p->psstate = "Bit3wait"; while(waserror()) ; tsleep(&u->p->sleep, return0, 0, 1000); poperror(); } } . 165c for(i=0; i<10*1000*1000; i++){ . 154c if(n != 0) return n; if(i > 5*1000*1000){ u->p->psstate = "Bit3wait"; while(waserror()) ; tsleep(&u->p->sleep, return0, 0, 1000); poperror(); } } pexit("Suicide", 0); . 152c for(i=0; i<10*1000*1000; i++){ . 137a long i; . 119a USED(c); . 113a USED(c, name, omode, perm); . 84a USED(c, dp); . ## diffname power/devbit3.c 1992/0111 ## diff -e /n/bootesdump/1991/1209/sys/src/9/power/devbit3.c /n/bootesdump/1992/0111/sys/src/9/power/devbit3.c 6c #include "../port/error.h" . ## diffname power/devbit3.c 1992/0306 # deleted ## diff -e /n/bootesdump/1992/0111/sys/src/9/power/devbit3.c /n/bootesdump/1992/0306/sys/src/9/power/devbit3.c 1,244d