~kris/9p

9hist

fecdad38352a753db69502bbfc7afb12f1bcdba0 — David du Colombier 25 years ago 8629013
Plan 9 from Bell Labs 2001-03-30
2 files changed, 29 insertions(+), 95 deletions(-)

M pc/ether82543gc.c
M pc/etherelnk3.c
M pc/ether82543gc.c => pc/ether82543gc.c +0 -65
@@ 344,8 344,6 @@ gc82543attach(Ether* edev)
	csr32w(ctlr, Rctl, ctl);
	ctl = csr32r(ctlr, Tctl)|Ten;
	csr32w(ctlr, Tctl, ctl);
print("ctrl %8.8uX rctl %8.8uX tclt %8.8uX\n",
    csr32r(ctlr, Ctrl), csr32r(ctlr, Rctl), csr32r(ctlr, Tctl));
}

static char* statistics[Nstatistics] = {


@@ 894,65 892,6 @@ gc82543reset(Ctlr* ctlr)
	return 0;
}

static int
mdir(Ctlr* ctlr, int p, int r)
{
	int mdic, timeo;

print("mdir %uX\n", csr32r(ctlr, Mdic));
	if(!(csr32r(ctlr, Mdic) & MDIready))
		return -1;
	csr32w(ctlr, Mdic, MDIrop|(p<<MDIpSHIFT)|(r<<MDIrSHIFT));
	for(timeo = 0; timeo < 1000; timeo++){
		microdelay(10);
		mdic = csr32r(ctlr, Mdic);
		if(mdic & MDIready)
{
print("%d/%d: t %d data %8.8uX\n", p, r, timeo, mdic);
			return mdic & MDIdMASK;
}
	}
	return -1;
}

static int
mdiw(Ctlr* ctlr, int p, int r, int d)
{
	int timeo;

	if(!(csr32r(ctlr, Mdic) & MDIready))
{
print("mdiw not ready\n");
		return -1;
}
	csr32w(ctlr, Mdic, MDIrop|(p<<MDIpSHIFT)|(r<<MDIrSHIFT)|(d & MDIdMASK));
	microdelay(1);
	for(timeo = 0; timeo < 1000; timeo++){
		if(csr32r(ctlr, Mdic) & MDIready)
			break;
		microdelay(1);
	}
print("%d/%d: t %d data %8.8uX\n", p, r, timeo, csr32r(ctlr, Mdic));
	return csr32r(ctlr, Mdic) & MDIready;
}

static int
scanphy(Ctlr* ctlr)
{
	int oui, p, x;

	for(p = 0; p < 32; p++){
		if((oui = mdir(ctlr, p, 2)) == -1 || oui == 0 || oui == 0xFFFF)
			continue;
		oui <<= 6;
		x = mdir(ctlr, p, 3);
		oui |= x>>10;
		print("phy%d: oui %uX reg1 %uX\n", p, oui, mdir(ctlr, p, 1));
		return p;
	}
	return -1;
}

static void
gc82543pci(void)
{


@@ 987,12 926,10 @@ gc82543pci(void)
		ctlr->id = (p->did<<16)|p->vid;

		ctlr->nic = KADDR(ctlr->port);
print("status0 %8.8uX\n", csr32r(ctlr, Status));
		if(gc82543reset(ctlr)){
			free(ctlr);
			continue;
		}
print("status1 %8.8uX\n", csr32r(ctlr, Status));

		if(ctlrhead != nil)
			ctlrtail->next = ctlr;


@@ 1045,8 982,6 @@ gc82543pnp(Ether* edev)
			edev->ea[2*i+1] = ctlr->eeprom[i]>>8;
		}
	}
if(ctlr->pcidev->did == 0x1004)
    scanphy(ctlr);
	gc82543init(edev);

	/*

M pc/etherelnk3.c => pc/etherelnk3.c +29 -30
@@ 6,8 6,7 @@
 *	autoSelect;
 *	PCI latency timer and master enable;
 *	errata list;
 *	rewrite all initialisation;
 *	handle the cyclone adapter.
 *	rewrite all initialisation.
 *
 * Product ID:
 *	9150 ISA	3C509[B]


@@ 1716,7 1715,8 @@ eepromdata(int port, int offset)
int
etherelnk3reset(Ether* ether)
{
	int anar, anlpar, busmaster, did, i, j, phyaddr, port, rxearly, rxstatus9, x, xcvr;
	int anar, anlpar, phyaddr, phystat, timeo, xcvr;
	int busmaster, did, i, j, port, rxearly, rxstatus9, x;
	Block *bp, **bpp;
	Adapter *ap;
	uchar ea[Eaddrlen];


@@ 1805,8 1805,9 @@ etherelnk3reset(Ether* ether)

	/*
	 * Check if the adapter's station address is to be overridden.
	 * If not, read it from the EEPROM and set in ether->ea prior to loading the
	 * station address in Wstation. The EEPROM returns 16-bits at a time.
	 * If not, read it from the EEPROM and set in ether->ea prior to
	 * loading the station address in Wstation.
	 * The EEPROM returns 16-bits at a time.
	 */
	memset(ea, 0, Eaddrlen);
	if(memcmp(ea, ether->ea, Eaddrlen) == 0){


@@ 1840,18 1841,18 @@ etherelnk3reset(Ether* ether)
				xcvr = media[j].xcvr;
	}
	
/*
 * forgive me, but i am weak
 */
if(did == 0x9055 || did == 0x9200){
   xcvr = xcvrMii;
   XCVRDEBUG("905[BC] reset ops 0x%uX\n",
	ins(port+ResetOp905B));
}
else
	if(xcvr & autoSelect)
	/*
	 * forgive me, but i am weak
	 */
	if(did == 0x9055 || did == 0x9200){
		xcvr = xcvrMii;
		txrxreset(port);
		XCVRDEBUG("905[BC] reset ops 0x%uX\n", ins(port+ResetOp905B));
	}
	else if(xcvr & autoSelect)
		xcvr = autoselect(port, xcvr, rxstatus9);
	XCVRDEBUG("autoselect returns: xcvr %uX, did 0x%uX\n", xcvr, did);

	switch(xcvr){

	case xcvrMii:


@@ 1860,21 1861,19 @@ else
		scanphy(port);
		 */
		phyaddr = 24;
for(i = 0; i < 7; i++)
    XCVRDEBUG(" %2.2uX", miir(port, phyaddr, i));
XCVRDEBUG("\n");

{	int phystat, timeo;
	for(timeo = 0; timeo < 30; timeo++){
		phystat = miir(port, phyaddr, 0x01);
		if(phystat & 0x20)
			break;
		XCVRDEBUG(" %2.2uX", phystat);
		delay(100);
	}
	XCVRDEBUG(" %2.2uX", miir(port, phyaddr, 0x01));
	XCVRDEBUG("\n");
}
		for(i = 0; i < 7; i++)
			XCVRDEBUG(" %2.2uX", miir(port, phyaddr, i));
			XCVRDEBUG("\n");

		for(timeo = 0; timeo < 30; timeo++){
			phystat = miir(port, phyaddr, 0x01);
			if(phystat & 0x20)
				break;
			XCVRDEBUG(" %2.2uX", phystat);
			delay(100);
		}
		XCVRDEBUG(" %2.2uX", miir(port, phyaddr, 0x01));
		XCVRDEBUG("\n");

		anar = miir(port, phyaddr, 0x04);
		anlpar = miir(port, phyaddr, 0x05) & 0x03E0;