From 5281772f43e0574fa0e21858c15711758ebda9d8 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 14 Mar 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-03-14 --- pc/ether2114x.c | 60 ++++++++++++++++++++++++++---------------------- pc/ether79c970.c | 4 +++- pc/ether82557.c | 1 + pc/etherelnk3.c | 1 + pc/fns.h | 1 + pc/pci.c | 15 ++++++++++-- 6 files changed, 51 insertions(+), 31 deletions(-) diff --git a/pc/ether2114x.c b/pc/ether2114x.c index d4d316ca960b02c809a25230d44090700d84db42..c32c146f09d6f36e10dc45f1e34c688298b4614a 100644 --- a/pc/ether2114x.c +++ b/pc/ether2114x.c @@ -873,6 +873,7 @@ typephymode(Ctlr* ctlr, uchar* block, int wait) ctlr->ttm |= *p<<8; debug("mc %4.4uX nway %4.4uX fdx %4.4uX ttm %4.4uX\n", mc, nway, ctlr->fdx, ctlr->ttm); + USED(mc); phyx = block[2]; ctlr->curphyad = ctlr->phy[phyx]; @@ -1247,6 +1248,7 @@ debug("sct 0x%uX medium 0x%uX k %d curk %d phy %d\n", miir(ctlr, k, 1); debug("phy%d: index %d oui %uX reg1 %uX\n", x, k, oui, miir(ctlr, k, 1)); + USED(oui); } ctlr->phy[x] = k; } @@ -1263,52 +1265,53 @@ dec2114xpci(void) { Ctlr *ctlr; Pcidev *p; - int cfdd; + int x; p = nil; while(p = pcimatch(p, 0x1011, 0)){ switch(p->did){ default: - break; + continue; case 0x0019: /* 21143 */ /* * Exit sleep mode. */ - cfdd = pcicfgr32(p, 0x40); - cfdd &= ~0xc0000000; - pcicfgw32(p, 0x40, cfdd); + x = pcicfgr32(p, 0x40); + x &= ~0xc0000000; + pcicfgw32(p, 0x40, x); /*FALLTHROUGH*/ case 0x0009: /* 21140 */ - ctlr = malloc(sizeof(Ctlr)); - /* - * bar[0] is the I/O port register address and - * bar[1] is the memory-mapped register address. - */ - ctlr->port = p->mem[0].bar & ~0x01; - ctlr->pcidev = p; + break; + } - /* - * Some cards (e.g. ANA-6910FX) seem to need the Ps bit - * set or they don't always work right after a hardware - * reset. - */ - csr32w(ctlr, 6, Mbo|Ps); - softreset(ctlr); + /* + * bar[0] is the I/O port register address and + * bar[1] is the memory-mapped register address. + */ + ctlr = malloc(sizeof(Ctlr)); + ctlr->port = p->mem[0].bar & ~0x01; + ctlr->pcidev = p; - if(srom(ctlr)){ - free(ctlr); - break; - } + /* + * Some cards (e.g. ANA-6910FX) seem to need the Ps bit + * set or they don't always work right after a hardware + * reset. + */ + csr32w(ctlr, 6, Mbo|Ps); + softreset(ctlr); - if(ctlrhead != nil) - ctlrtail->next = ctlr; - else - ctlrhead = ctlr; - ctlrtail = ctlr; + if(srom(ctlr)){ + free(ctlr); break; } + + if(ctlrhead != nil) + ctlrtail->next = ctlr; + else + ctlrhead = ctlr; + ctlrtail = ctlr; } } @@ -1392,6 +1395,7 @@ reset(Ether* ether) */ ctlr->nrdr = Nrde; ctlr->ntdr = Ntde; + pcisetbme(ctlr->pcidev); ctlrinit(ether); /* diff --git a/pc/ether79c970.c b/pc/ether79c970.c index 761692edd7436bc27a4d2006696b0496fdb4859b..9779e971808f2735b774c6a02e9745873a50c313 100644 --- a/pc/ether79c970.c +++ b/pc/ether79c970.c @@ -446,8 +446,10 @@ amd79c970pci(void) Pcidev *p; p = nil; - while(p = pcimatch(p, 0x1022, 0x2000)) + while(p = pcimatch(p, 0x1022, 0x2000)){ amd79c970adapter(&adapter, p->mem[0].bar & ~0x01, p->intl, p->tbdf); + pcisetbme(p); + } } static int diff --git a/pc/ether82557.c b/pc/ether82557.c index 7afede8c16a3acb971b192e0affc0eec2f7aaa20..8bbbc2dc608c228126da33e30b4b3f3a661fe761 100644 --- a/pc/ether82557.c +++ b/pc/ether82557.c @@ -906,6 +906,7 @@ i82557pci(void) * bar[2] is for the flash ROM (1MB). */ i82557adapter(&adapter, p->mem[1].bar & ~0x01, p->intl, p->tbdf); + pcisetbme(p); } } diff --git a/pc/etherelnk3.c b/pc/etherelnk3.c index 7e5945cdb2f65da0c9122c96f50fce0d0014a13e..58d988302c64cfb0cf60e432d4a23f0208d26410 100644 --- a/pc/etherelnk3.c +++ b/pc/etherelnk3.c @@ -1396,6 +1396,7 @@ tcm59Xpci(void) ; tcmadapter(port, irq, p->tbdf); + pcisetbme(p); } } diff --git a/pc/fns.h b/pc/fns.h index ff0553ca75dcba8928910ec2b4e4929e9cc4a745..095eaafd9db9bb4bbd5045f9e3998ecc13ca993d 100644 --- a/pc/fns.h +++ b/pc/fns.h @@ -82,6 +82,7 @@ void pcihinv(Pcidev*); Pcidev* pcimatch(Pcidev*, int, int); Pcidev* pcimatchtbdf(int); void pcireset(void); +void pcisetbme(Pcidev*); PCMmap* pcmmap(int, ulong, int, int); int pcmspecial(char*, ISAConf*); void pcmspecialclose(int); diff --git a/pc/pci.c b/pc/pci.c index edf7676b6ffc59bc9e6f55f011d26678b88be37c..2768f789ee8c5b6d6524e57f129daa2319f18420 100644 --- a/pc/pci.c +++ b/pc/pci.c @@ -669,7 +669,18 @@ pcireset(void) pcicfginit(); for(p = pcilist; p != nil; p = p->list){ - pcr = pcicfgr16(p, PciPSR); - pcicfgw16(p, PciPSR, pcr & ~0x04); + pcr = pcicfgr16(p, PciPCR); + pcr &= ~0x0004; + pcicfgw16(p, PciPCR, pcr); } } + +void +pcisetbme(Pcidev* p) +{ + int pcr; + + pcr = pcicfgr16(p, PciPCR); + pcr |= 0x0004; + pcicfgw16(p, PciPCR, pcr); +}