plan 9 kernel history: overview | file list | diff list

2002/0403/pc/devether.c (diff list | history)

2002/0314/sys/src/9/pc/devether.c:343,4292002/0403/sys/src/9/pc/devether.c:343,462 (short | long | prev | next)
1997/0327    
	return 0; 
} 
 
static void 
1992/0424    
etherreset(void) 
2002/0403    
static Ether* 
etherprobe(int cardno, int ctlrno) 
1992/0424    
{ 
2002/0403    
	int i; 
1997/0327    
	Ether *ether; 
1993/1113    
	int i, n, ctlrno; 
2001/0527    
	char name[32], buf[128]; 
2002/0403    
	char buf[128], name[32]; 
1992/0410    
 
1997/0327    
	for(ether = 0, ctlrno = 0; ctlrno < MaxEther; ctlrno++){ 
		if(ether == 0) 
			ether = malloc(sizeof(Ether)); 
		memset(ether, 0, sizeof(Ether)); 
		ether->ctlrno = ctlrno; 
		ether->tbdf = BUSUNKNOWN; 
		ether->mbps = 10; 
2000/0921    
		ether->minmtu = ETHERMINTU; 
		ether->maxmtu = ETHERMAXTU; 
1997/0327    
		if(isaconfig("ether", ctlrno, ether) == 0) 
1993/1113    
			continue; 
		for(n = 0; cards[n].type; n++){ 
1997/0327    
			if(cistrcmp(cards[n].type, ether->type)) 
2002/0403    
	ether = malloc(sizeof(Ether)); 
	memset(ether, 0, sizeof(Ether)); 
	ether->ctlrno = ctlrno; 
	ether->tbdf = BUSUNKNOWN; 
	ether->mbps = 10; 
	ether->minmtu = ETHERMINTU; 
	ether->maxmtu = ETHERMAXTU; 
 
	if(cardno < 0){ 
		if(isaconfig("ether", ctlrno, ether) == 0){ 
			free(ether); 
			return nil; 
		} 
		for(cardno = 0; cards[cardno].type; cardno++){ 
			if(cistrcmp(cards[cardno].type, ether->type)) 
1993/1113    
				continue; 
1997/0327    
			for(i = 0; i < ether->nopt; i++){ 
				if(strncmp(ether->opt[i], "ea=", 3)) 
					continue; 
				if(parseether(ether->ea, ðer->opt[i][3]) == -1) 
2002/0403    
				if(parseether(ether->ea, ðer->opt[i][3])) 
1997/0327    
					memset(ether->ea, 0, Eaddrlen); 
			}	 
			if(cards[n].reset(ether)) 
1993/1113    
				break; 
2002/0403    
			} 
			break; 
		} 
	} 
1992/1222    
 
			/* 
			 * IRQ2 doesn't really exist, it's used to gang the interrupt 
			 * controllers together. A device set to IRQ2 will appear on 
			 * the second interrupt controller as IRQ9. 
			 */ 
1997/0327    
			if(ether->irq == 2) 
				ether->irq = 9; 
1999/0819    
			snprint(name, sizeof(name), "ether%d", ctlrno); 
2002/0403    
	if(cardno >= MaxEther || cards[cardno].type == nil){ 
		free(ether); 
		return nil; 
	} 
	if(cards[cardno].reset(ether) < 0){ 
		free(ether); 
		return nil; 
	} 
2000/0817    
 
2001/1130    
			/* 
			 * If ether->irq is 0, it is a hack to indicate no interrupt 
			 * used by ethersink. 
2000/0817    
			 */ 
2001/1130    
			if(ether->irq > 0) 
2000/0817    
				intrenable(ether->irq, ether->interrupt, ether, ether->tbdf, name); 
2002/0403    
	/* 
	 * IRQ2 doesn't really exist, it's used to gang the interrupt 
	 * controllers together. A device set to IRQ2 will appear on 
	 * the second interrupt controller as IRQ9. 
	 */ 
	if(ether->irq == 2) 
		ether->irq = 9; 
	snprint(name, sizeof(name), "ether%d", ctlrno); 
1993/0212    
 
1998/0825    
			i = sprint(buf, "#l%d: %s: %dMbps port 0x%luX irq %lud", 
1997/0327    
				ctlrno, ether->type, ether->mbps, ether->port, ether->irq); 
			if(ether->mem) 
1997/1101    
				i += sprint(buf+i, " addr 0x%luX", PADDR(ether->mem)); 
1997/0327    
			if(ether->size) 
				i += sprint(buf+i, " size 0x%luX", ether->size); 
			i += sprint(buf+i, ": %2.2uX%2.2uX%2.2uX%2.2uX%2.2uX%2.2uX", 
				ether->ea[0], ether->ea[1], ether->ea[2], 
				ether->ea[3], ether->ea[4], ether->ea[5]); 
			sprint(buf+i, "\n"); 
			print(buf); 
2002/0403    
	/* 
	 * If ether->irq is 0, it is a hack to indicate no interrupt 
	 * used by ethersink. 
	 */ 
	if(ether->irq > 0) 
		intrenable(ether->irq, ether->interrupt, ether, ether->tbdf, name); 
1993/0212    
 
2000/0921    
			if(ether->mbps >= 100){ 
1997/0327    
				netifinit(ether, name, Ntypes, 256*1024); 
				if(ether->oq == 0) 
					ether->oq = qopen(256*1024, 1, 0, 0); 
			} 
			else{ 
1998/0218    
				netifinit(ether, name, Ntypes, 65*1024); 
1997/0327    
				if(ether->oq == 0) 
1998/0218    
					ether->oq = qopen(65*1024, 1, 0, 0); 
1997/0327    
			} 
1997/1105    
			if(ether->oq == 0) 
				panic("etherreset %s", name); 
1997/0327    
			ether->alen = Eaddrlen; 
			memmove(ether->addr, ether->ea, Eaddrlen); 
			memset(ether->bcast, 0xFF, Eaddrlen); 
2002/0403    
	i = sprint(buf, "#l%d: %s: %dMbps port 0x%luX irq %lud", 
		ctlrno, cards[cardno].type, ether->mbps, ether->port, ether->irq); 
	if(ether->mem) 
		i += sprint(buf+i, " addr 0x%luX", PADDR(ether->mem)); 
	if(ether->size) 
		i += sprint(buf+i, " size 0x%luX", ether->size); 
	i += sprint(buf+i, ": %2.2uX%2.2uX%2.2uX%2.2uX%2.2uX%2.2uX", 
		ether->ea[0], ether->ea[1], ether->ea[2], 
		ether->ea[3], ether->ea[4], ether->ea[5]); 
	sprint(buf+i, "\n"); 
	print(buf); 
1992/0410    
 
1997/0327    
			etherxx[ctlrno] = ether; 
			ether = 0; 
1993/1120    
			break; 
2002/0403    
	if(ether->mbps >= 100){ 
		netifinit(ether, name, Ntypes, 256*1024); 
		if(ether->oq == 0) 
			ether->oq = qopen(256*1024, 1, 0, 0); 
	} 
	else{ 
		netifinit(ether, name, Ntypes, 65*1024); 
		if(ether->oq == 0) 
			ether->oq = qopen(65*1024, 1, 0, 0); 
	} 
	if(ether->oq == 0) 
		panic("etherreset %s", name); 
	ether->alen = Eaddrlen; 
	memmove(ether->addr, ether->ea, Eaddrlen); 
	memset(ether->bcast, 0xFF, Eaddrlen); 
 
	return ether; 
} 
 
static void 
etherreset(void) 
{ 
	Ether *ether; 
	int cardno, ctlrno; 
 
	for(ctlrno = 0; ctlrno < MaxEther; ctlrno++){ 
		if((ether = etherprobe(-1, ctlrno)) == nil) 
			continue; 
		etherxx[ctlrno] = ether; 
	} 
 
	cardno = ctlrno = 0; 
	while(cards[cardno].type != nil && ctlrno < MaxEther){ 
		if(etherxx[ctlrno] != nil){ 
			ctlrno++; 
			continue; 
1993/1113    
		} 
2002/0403    
		if((ether = etherprobe(cardno, ctlrno)) == nil){ 
			cardno++; 
			continue; 
		} 
		etherxx[ctlrno] = ether; 
		ctlrno++; 
1992/0403    
	} 
1997/0327    
	if(ether) 
		free(ether); 
1992/0403    
} 
1997/0327    
 
2002/0109    
static void 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)