From af3f84a89e3c400581bd420316684fae8646d183 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 16 Sep 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-09-16 --- ip/il.c | 7 ++++++ pc/ether589.c | 61 +++++++++++++++++++++++++++++++++---------------- pc/etherelnk3.c | 30 ++++++++++++++++++++++-- pc/piix4smbus.c | 1 + 4 files changed, 77 insertions(+), 22 deletions(-) diff --git a/ip/il.c b/ip/il.c index 229374ab6257eb85b9394a73934d4ead9ac0929b..e6123f89f6d27d131fef08e61ddaa57158c89880 100644 --- a/ip/il.c +++ b/ip/il.c @@ -669,6 +669,12 @@ _ilprocess(Conv *s, Ilhdr *h, Block *bp) ilpullup(s); } break; + case Ildata: + if(ack == ic->start) { + ic->state = Ilestablished; + goto established; + } + break; case Ilclose: if(ack == ic->start) ilhangup(s, "remote close"); @@ -677,6 +683,7 @@ _ilprocess(Conv *s, Ilhdr *h, Block *bp) freeblist(bp); break; case Ilestablished: + established: switch(h->iltype) { case Ilsync: if(id != ic->rstart) diff --git a/pc/ether589.c b/pc/ether589.c index f04e3403656ae3048ba49fe628b0db1b93fd57b2..fb90a0df3247b4d7661ca594fcd6ced5b9295d87 100644 --- a/pc/ether589.c +++ b/pc/ether589.c @@ -111,8 +111,11 @@ configASIC(Ether* ether, int port, int xcvr) static int reset(Ether* ether) { - int slot; + int i, slot; int port; + enum { WantAny, Want10BT, Want10B2 }; + int want; + char *p; if(ether->irq == 0) ether->irq = 10; @@ -128,30 +131,48 @@ reset(Ether* ether) return -1; } - /* try configuring as a 10BaseT */ - if(configASIC(ether, port, xcvr10BaseT) < 0){ - pcmspecialclose(slot); - iofree(port); - return -1; + /* + * Allow user to specify desired media in plan9.ini + */ + want = WantAny; + for(i = 0; i < ether->nopt; i++){ + if(cistrncmp(ether->opt[i], "media=", 6) != 0) + continue; + p = ether->opt[i]+6; + if(cistrcmp(p, "10base2") == 0) + want = Want10B2; + else if(cistrcmp(p, "10baseT") == 0) + want = Want10BT; } - delay(100); - COMMAND(port, SelectRegisterWindow, Wdiagnostic); - if(ins(port+MediaStatus) & linkBeatDetect){ - COMMAND(port, SelectRegisterWindow, Wop); - print("#l%d: xcvr10BaseT %s\n", ether->ctlrno, ether->type); - return 0; + + /* try configuring as a 10BaseT */ + if(want==WantAny || want==Want10BT){ + if(configASIC(ether, port, xcvr10BaseT) < 0){ + pcmspecialclose(slot); + iofree(port); + return -1; + } + delay(100); + COMMAND(port, SelectRegisterWindow, Wdiagnostic); + if((ins(port+MediaStatus)&linkBeatDetect) || want==Want10BT){ + COMMAND(port, SelectRegisterWindow, Wop); + print("#l%d: xcvr10BaseT %s\n", ether->ctlrno, ether->type); + return 0; + } } /* try configuring as a 10base2 */ - COMMAND(port, GlobalReset, 0); - if(configASIC(ether, port, xcvr10Base2) < 0){ - pcmspecialclose(slot); - iofree(port); - return -1; + if(want==WantAny || want==Want10B2){ + COMMAND(port, GlobalReset, 0); + if(configASIC(ether, port, xcvr10Base2) < 0){ + pcmspecialclose(slot); + iofree(port); + return -1; + } + print("#l%d: xcvr10Base2 %s\n", ether->ctlrno, ether->type); + return 0; } - print("#l%d: xcvr10Base2 %s\n", ether->ctlrno, ether->type); - - return 0; + return -1; /* not reached */ } void diff --git a/pc/etherelnk3.c b/pc/etherelnk3.c index e40a2b20222a02ddeeb1d0c2f1d402ee3b3697f9..534ebd465bd08d54416a63dbf4cdfec20971fc6f 100644 --- a/pc/etherelnk3.c +++ b/pc/etherelnk3.c @@ -1584,11 +1584,23 @@ static struct xxx { }; #endif /* notdef */ +static struct { + char *name; + int avail; + int xcvr; +} media[] = { + "10BaseT", base10TAvailable, xcvr10BaseT, + "10Base2", coaxAvailable, xcvr10Base2, + "100BaseTX", baseTXAvailable, xcvr100BaseTX, + "100BaseFX", baseFXAvailable, xcvr100BaseFX, + "aui", auiAvailable, xcvrAui, + "mii", miiConnector, xcvrMii +}; + static int autoselect(int port, int xcvr, int is9) { int media, x; - USED(xcvr); /* @@ -1671,12 +1683,13 @@ eepromdata(int port, int offset) int etherelnk3reset(Ether* ether) { - int anar, anlpar, busmaster, did, i, phyaddr, port, rxearly, rxstatus9, x, xcvr; + int anar, anlpar, busmaster, did, i, j, phyaddr, port, rxearly, rxstatus9, x, xcvr; Block *bp, **bpp; Adapter *ap; uchar ea[Eaddrlen]; Ctlr *ctlr; static int scandone; + char *p; /* * Scan for adapter on PCI, EISA and finally @@ -1780,6 +1793,19 @@ etherelnk3reset(Ether* ether) * of the 3C59[05], don't use busmastering at 10Mbps. */ XCVRDEBUG("reset: xcvr %uX\n", xcvr); + + /* + * Allow user to specify desired media in plan9.ini + */ + for(i = 0; i < ether->nopt; i++){ + if(cistrncmp(ether->opt[i], "media=", 6) != 0) + continue; + p = ether->opt[i]+6; + for(j = 0; j < nelem(media); j++) + if(cistrcmp(p, media[j].name) == 0) + xcvr = media[j].xcvr; + } + /* * forgive me, but i am weak */ diff --git a/pc/piix4smbus.c b/pc/piix4smbus.c index bf44528bb1b863ab24b972b6631472d1eda46e57..524c60aec6db7a06471c3c9c0d70a6439758db65 100644 --- a/pc/piix4smbus.c +++ b/pc/piix4smbus.c @@ -133,6 +133,7 @@ transact(SMBus *s, int type, int addr, int cmd, uchar *data) outb(s->base+Hostcontrol, Start|proto[type].proto); // wait for completion + status = 0; for(tries = 0; tries < 1000000; tries++){ status = inb(s->base+Hoststatus); if(status & (Failed|Bus_error|Dev_error|Host_complete))