From f4556d99e243df58fb887d67b389d5b0a8767c57 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 6 Mar 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-03-06 --- port/devip.c | 3 + port/tcpinput.c | 2 + power/boot.c | 46 +-------- power/devbit3.c | 244 ---------------------------------------------- power/devhotrod.c | 12 +-- 5 files changed, 12 insertions(+), 295 deletions(-) delete mode 100644 power/devbit3.c diff --git a/port/devip.c b/port/devip.c index b947764b6a140cb021ea7e89c65c7bfcada72c04..b198d6bc92afe4884145ad4e0772331c281e70fe 100644 --- a/port/devip.c +++ b/port/devip.c @@ -173,6 +173,7 @@ ipincoming(Ipconv *base, Ipconv *from) /* current user becomes owner */ netown(new->net, new->index, u->p->user, 0); new->ref = 1; + new->newcon = 0; qunlock(new); return new; } @@ -643,7 +644,9 @@ iplisten(Chan *c) new = base; for(etab = &base[conf.ip]; new < etab; new++) { if(new->newcon) { + qlock(s); s->curlog--; + qunlock(s); new->newcon = 0; qunlock(&s->listenq); return new - base; diff --git a/port/tcpinput.c b/port/tcpinput.c index 6eeef0e998ac0d7f7bfc053a91314c15a985476d..c55bb05f5726847eade3eb7bf8b67117fcf3a100 100644 --- a/port/tcpinput.c +++ b/port/tcpinput.c @@ -85,7 +85,9 @@ tcp_input(Ipconv *ipc, Block *bp) if(new == 0) goto clear; + qlock(s); s->curlog++; + qunlock(s); new->psrc = seg.dest; new->pdst = seg.source; new->dst = source; diff --git a/power/boot.c b/power/boot.c index 26917f53b9c54b46fcda554a4a9b8044949ae63c..8e94f350485ea52a965652c478541a2a4cc6ef82 100644 --- a/power/boot.c +++ b/power/boot.c @@ -2,7 +2,7 @@ #include #include -#define DEFSYS "bit!bootes" +#define DEFSYS "cyc!bootes" #define DEFFILE "/mips/9" Fcall hdr; @@ -153,47 +153,7 @@ dkdial(char *arg) int hotdial(char *arg) { - int fd; - char srvdir[100]; - Waitmsg m; - - return open("#H/hotrod", ORDWR); - - /* - * The killer: gotta get a hotrodboot running, so dial up - * on datakit and load it. - */ - fd = dkdial(arg); - if(fd < 0) - return -1; - if(!preamble(fd)){ - close(fd); - return -1; - } - /* - * use /dev; it's local - */ - if(mount(fd, "/dev", MREPL, "", "") < 0) - error("mount"); - switch(fork()){ - case 0: - /* - * child: get hotrodboot running - */ - execl("/dev/mips/bin/hotrodboot", "hotrodboot", "/dev/hobbit/hot", 0); - error("execl hotrodboot"); - case -1: - error("fork"); - } - /* - * parent: wait, then sleep a while - */ - wait(&m); - if(m.msg[0]) - error(m.msg); - fprint(2, "sleep 3 seconds\n"); - sleep(3*1000); - fprint(2, "go for it....\n"); + USED(arg); return open("#H/hotrod", ORDWR); } @@ -278,7 +238,7 @@ boot(int ask) fd = -1; if(strncmp(sys, "bit!", 4) == 0) fd = bitdial(&sys[4]); - else if(strncmp(sys, "hot!", 4) == 0) + else if(strncmp(sys, "cyc!", 4) == 0) fd = hotdial(&sys[4]); else if(strncmp(sys, "dk!", 3) == 0) fd = dkdial(&sys[3]); diff --git a/power/devbit3.c b/power/devbit3.c deleted file mode 100644 index 792ba199b294f0bf27999159c059e2874b32c857..0000000000000000000000000000000000000000 --- a/power/devbit3.c +++ /dev/null @@ -1,244 +0,0 @@ -#include "u.h" -#include "lib.h" -#include "mem.h" -#include "dat.h" -#include "fns.h" -#include "../port/error.h" -#include "devtab.h" - -#include "io.h" - -static struct -{ - QLock; - QLock buflock; - 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.path != CHDIR) - return 0; - if(strcmp(name, "bit3") == 0){ - c->qid.path = 1; - return 1; - } - return 0; -} - -void -bit3stat(Chan *c, char *dp) -{ - USED(c, dp); - print("bit3stat\n"); - error(Egreg); -} - -Chan* -bit3open(Chan *c, int omode) -{ - Bit3msg *bp; - - bp = &((User*)(u->p->upage->pa|KZERO))->kbit3; - if(c->qid.path!=1 || omode!=ORDWR) - error(Eperm); - qlock(&bit3); - if(bit3.open){ - qunlock(&bit3); - error(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) -{ - USED(c, name, omode, perm); - error(Eperm); -} - -void -bit3close(Chan *c) -{ - USED(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, ulong offset) -{ - Bit3msg *bp; - int docpy; - long i; - - switch(c->qid.path){ - case 1: - if(n > sizeof bit3.buf) - error(Egreg); - if((((ulong)buf)&(KSEGM|3)) == KSEG0){ - /* - * use supplied buffer, no need to lock for reply - */ - bp = &((User*)(u->p->upage->pa|KZERO))->kbit3; - bp->rcount = 0; - qlock(&bit3); - bit3send(bp, READ, buf, n); - qunlock(&bit3); - for(i=0; i<10*1000*1000; i++){ - n = bp->rcount; - 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); - }else{ - /* - * use bit3 buffer. lock the buffer till the reply - */ - bp = &((User*)(u->p->upage->pa|KZERO))->ubit3; - bp->rcount = 0; - qlock(&bit3.buflock); - qlock(&bit3); - bit3send(bp, READ, bit3.buf, n); - qunlock(&bit3); - for(i=0; i<10*1000*1000; i++){ - n = bp->rcount; - 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(); - } - } - qunlock(&bit3.buflock); - pexit("Suicide", 0); - } - } - error(Egreg); - return 0; -} - -long -bit3write(Chan *c, void *buf, long n, ulong offset) -{ - Bit3msg *bp; - - switch(c->qid.path){ - case 1: - if(n > sizeof bit3.buf) - error(Egreg); - if((((ulong)buf)&(KSEGM|3)) == KSEG0){ - bp = &((User*)(u->p->upage->pa|KZERO))->kbit3; - qlock(&bit3); - bit3send(bp, WRITE, buf, n); - qunlock(&bit3); - }else{ - bp = &((User*)(u->p->upage->pa|KZERO))->ubit3; - qlock(&bit3.buflock); - qlock(&bit3); - memmove(bit3.buf, buf, n); - bit3send(bp, WRITE, bit3.buf, n); - do; while(*BIT3ADDR); - qunlock(&bit3); - qunlock(&bit3.buflock); - } - return n; - } - error(Egreg); - return 0; -} - -void -bit3remove(Chan *c) -{ - USED(c); - error(Eperm); -} - -void -bit3wstat(Chan *c, char *dp) -{ - USED(c, dp); - error(Eperm); -} diff --git a/power/devhotrod.c b/power/devhotrod.c index 6903f7026d727515781b31ab6c07048c0b8dd4fc..8a138c786dc86649fa7599b92a092c2372efb222 100644 --- a/power/devhotrod.c +++ b/power/devhotrod.c @@ -12,14 +12,10 @@ #include "../../fs/cyc/comm.h" -/* - * If 1, ENABCKSUM causes data transfers to have checksums - */ -#define ENABCKSUM 0 - typedef struct Commrod Commrod; -enum{ +enum +{ Vmevec= 0xd2, /* vme vector for interrupts */ Intlevel= 5, /* level to interrupt on */ Qdir= 0, /* Qid's */ @@ -368,7 +364,7 @@ hotrodwrite(Chan *c, void *buf, long n, ulong offset) mp->cmd = Uwrite; mp->param[0] = MP2VME(buf); mp->param[1] = n; - mp->param[2] = hotsum(buf, n, ENABCKSUM); + mp->param[2] = 0; hmp = hotsend(hp, mp); hotwait(hmp); }else{ @@ -382,7 +378,7 @@ hotrodwrite(Chan *c, void *buf, long n, ulong offset) mp->cmd = Uwrite; mp->param[0] = MP2VME(hp->buf); mp->param[1] = n; - mp->param[2] = hotsum((ulong*)hp->buf, n, ENABCKSUM); + mp->param[2] = 0; hmp = hotsend(hp, mp); hotwait(hmp); qunlock(&hp->buflock);