From 191b674b5d7dae9ed28ccc5ebcccfcd00f98c9a7 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 31 Jul 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-07-31 --- boot/rc.c | 9 ++++++++- pc/ether82543gc.c | 40 ++++++++++++++++++++++++++++++++++++++++ port/alarm.c | 1 - port/chan.c | 38 +++++++++++++++++++++++++++++--------- port/pgrp.c | 5 +---- port/portdat.h | 1 + port/portfns.h | 1 + 7 files changed, 80 insertions(+), 15 deletions(-) diff --git a/boot/rc.c b/boot/rc.c index 811d91c05acaa4bf1d1424e1d57865c2725d20bf..7084caa8cccae8aeb1e2370c6c2ddbf00dc922ba 100644 --- a/boot/rc.c +++ b/boot/rc.c @@ -2,10 +2,17 @@ #include #include <../boot/boot.h> +/* minimal rc main */ +char rcmain[] = "home=/\n" + "ifs=' \t\n'\n" + "prompt=('% ' '\t')\n" + "path=/\n"; + void configrc(Method *) { - execl("/rc", "/rc", "-m", "/rcmain", "-i", 0); + setenv("rcmain", rcmain); + execl("/rc", "/rc", "-m", "#e/rcmain", "-i", 0); fatal("rc"); } diff --git a/pc/ether82543gc.c b/pc/ether82543gc.c index 9910351a7f67fd9bfa7448808e9a7e0916417043..0c484c8100443028526149c671fc74b7d98d0746 100644 --- a/pc/ether82543gc.c +++ b/pc/ether82543gc.c @@ -316,6 +316,8 @@ typedef struct Ctlr { int tdh; /* transmit descriptor head */ int tdt; /* transmit descriptor tail */ int ett; /* early transmit threshold */ + + ulong multimask[128]; /* bit mask for multicast addresses */ } Ctlr; static Ctlr* ctlrhead; @@ -949,6 +951,42 @@ print("status1 %8.8uX\n", csr32r(ctlr, Status)); } } +static void +gc82543promiscuous(void* arg, int on) +{ + Ether *edev=arg; + Ctlr *ctlr; + ulong ctl; + + ctlr = edev->ctlr; + ctl = csr32r(ctlr, Rctl); + ctl &= ~MoMASK; /* make sure we're using bits 47:36 */ + if(on) + ctl |= Upe|Mpe; + else + ctl &= ~(Upe|Mpe); + csr32w(ctlr, Rctl, ctl); +} + +static void +gc82543multicast(void* arg, uchar *addr, int on) +{ + Ether *edev=arg; + Ctlr *ctlr; + int x; + int bit; + + ctlr = edev->ctlr; + x = addr[5]>>1; + bit = ((addr[5]&1)<<4)|(addr[4]>>4); + if(on) + ctlr->multimask[x] |= 1<multimask[x] &= ~(1<multimask[x]); +} + static int gc82543pnp(Ether* edev) { @@ -1002,6 +1040,8 @@ gc82543pnp(Ether* edev) edev->interrupt = gc82543interrupt; edev->ifstat = gc82543ifstat; edev->shutdown = gc82543shutdown; + edev->promiscuous = gc82543promiscuous; + edev->multicast = gc82543multicast; edev->arg = edev; edev->promiscuous = nil; diff --git a/port/alarm.c b/port/alarm.c index 5b7a1d88359eab47b82000d012b6671907b0683c..e8463c852f75c3059307b44daf6df822096f8171 100644 --- a/port/alarm.c +++ b/port/alarm.c @@ -14,7 +14,6 @@ alarmkproc(void*) Proc *rp; ulong now; -print("alarmkproc\n"); for(;;){ now = MACHP(0)->ticks; qlock(&alarms); diff --git a/port/chan.c b/port/chan.c index 41b72165970a89bbccefc87e5df6620366410f81..566039320e5e4d5d391e05acd040d43a17dcda0b 100644 --- a/port/chan.c +++ b/port/chan.c @@ -418,6 +418,26 @@ eqchantdqid(Chan *a, int type, int dev, Qid qid, int pathonly) return 1; } +Mhead* +newmhead(Chan *from) +{ + Mhead *mh; + int n; + + mh = smalloc(sizeof(Mhead)); + mh->ref = 1; + mh->from = from; + incref(from); + + n = from->name->len; + if(n >= sizeof(mh->fromname)) + n = sizeof(mh->fromname)-1; + memmove(mh->fromname, from->name->s, n); + mh->fromname[n] = 0; + + return mh; +} + int cmount(Chan **newp, Chan *old, int flag, char *spec) { @@ -430,8 +450,7 @@ cmount(Chan **newp, Chan *old, int flag, char *spec) if(QTDIR & (old->qid.type^(*newp)->qid.type)) error(Emount); -if(old->umh) - print("cmount old extra umh\n"); +if(old->umh)print("cmount old extra umh\n"); order = flag&MORDER; @@ -476,11 +495,7 @@ if(old->umh) * nothing mounted here yet. create a mount * head and add to the hash table. */ - m = smalloc(sizeof(Mhead)); - m->ref = 1; - m->from = old; - incref(old); - m->hash = *l; + m = newmhead(old); *l = m; /* @@ -584,7 +599,6 @@ cunmount(Chan *mnt, Chan *mounted) putmhead(m); return; } - wunlock(&pg->ns); p = &m->mount; for(f = *p; f; f = f->next) { @@ -598,15 +612,18 @@ cunmount(Chan *mnt, Chan *mounted) *l = m->hash; cclose(m->from); wunlock(&m->lock); + wunlock(&pg->ns); putmhead(m); return; } wunlock(&m->lock); + wunlock(&pg->ns); return; } p = &f->next; } wunlock(&m->lock); + wunlock(&pg->ns); error(Eunion); } @@ -1131,6 +1148,8 @@ namec(char *aname, int amode, int omode, ulong perm) m = nil; if(!nomount) domount(&c, &m); + if(c->umh != nil) + putmhead(c->umh); c->umh = m; break; @@ -1159,8 +1178,9 @@ namec(char *aname, int amode, int omode, ulong perm) case Aopen: case Acreate: if(c->umh != nil){ - print("cunique umh\n"); + print("cunique umh Open\n"); putmhead(c->umh); + c->umh = nil; } /* only save the mount head if it's a multiple element union */ diff --git a/port/pgrp.c b/port/pgrp.c index 408598f0457700f4baccc1e13fda412d4c5cb062..fa855cb60dc80c2a2d00641f9c1b588e2f9e43c1 100644 --- a/port/pgrp.c +++ b/port/pgrp.c @@ -134,10 +134,7 @@ pgrpcpy(Pgrp *to, Pgrp *from) l = tom++; for(f = from->mnthash[i]; f; f = f->hash) { rlock(&f->lock); - mh = smalloc(sizeof(Mhead)); - mh->from = f->from; - mh->ref = 1; - incref(mh->from); + mh = newmhead(f->from); *l = mh; l = &mh->hash; link = &mh->mount; diff --git a/port/portdat.h b/port/portdat.h index 211a110c4cb546513d3599cab0a8426309de4516..3c1c037f55c479e1527f5cf126896d5ea4038f89 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -250,6 +250,7 @@ struct Mount struct Mhead { + char fromname[32]; /* temporary for debugging */ Ref; RWlock lock; Chan* from; /* channel mounted upon */ diff --git a/port/portfns.h b/port/portfns.h index 2a65effca41728669dca5ef7ece7f4a09a7fec55..bd887814c5fe91ba35973db73eda255137c58186 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -182,6 +182,7 @@ Chan* namec(char*, int, int, ulong); #define nelem(x) (sizeof(x)/sizeof(x[0])) Chan* newchan(void); int newfd(Chan*); +Mhead* newmhead(Chan*); Mount* newmount(Mhead*, Chan*, int, char*); Page* newpage(int, Segment **, ulong); Pgrp* newpgrp(void);