~kris/9p

9hist

af3f84a89e3c400581bd420316684fae8646d183 — David du Colombier 27 years ago 4f8253c
Plan 9 from Bell Labs 1999-09-16
4 files changed, 77 insertions(+), 22 deletions(-)

M ip/il.c
M pc/ether589.c
M pc/etherelnk3.c
M pc/piix4smbus.c
M ip/il.c => ip/il.c +7 -0
@@ 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)

M pc/ether589.c => pc/ether589.c +41 -20
@@ 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

M pc/etherelnk3.c => pc/etherelnk3.c +28 -2
@@ 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
 */

M pc/piix4smbus.c => pc/piix4smbus.c +1 -0
@@ 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))