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

1992/0408/pc/devether.c (diff list | history)

1992/0407/sys/src/9/pc/devether.c:32,371992/0408/sys/src/9/pc/devether.c:32,40 (short | long | prev | next)
1992/0404    
	NPktype		= 9,		/* types/interface */ 
}; 
 
1992/0408    
#define NEXT(x, l)	((((x)+1)%(l)) == 0 ? 6: (((x)+1)%(l))) 
#define PREV(x, l)	(((x)-1) == 5 ? (l-1): ((x)-1)) 
 
1992/0404    
/* 
 * register offsets from IObase 
 */ 
1992/0407/sys/src/9/pc/devether.c:389,3941992/0408/sys/src/9/pc/devether.c:392,398
1992/0404    
			outb(cp->iobase+Tcr, 0x20);	/* LB0 */ 
			outb(cp->iobase+Cr, 0x22);	/* Page0, RD2|STA */ 
			cp->ovw = 1; 
1992/0408    
			cp->overflows++; 
1992/0404    
		} 
		/* 
		 * we have received packets. 
1992/0407/sys/src/9/pc/devether.c:423,4301992/0408/sys/src/9/pc/devether.c:427,434
1992/0404    
	outb(cp->iobase+Rbcr1, 0); 
	outb(cp->iobase+Rcr, 0x04);		/* AB */ 
	outb(cp->iobase+Tcr, 0x20);		/* LB0 */ 
	outb(cp->iobase+Bnry, 6); 
	cp->bnry = 6; 
1992/0408    
	outb(cp->iobase+Bnry, cp->bnry); 
1992/0407    
	cp->ring = (Ring*)(KZERO|RAMbase); 
1992/0404    
	outb(cp->iobase+Pstart, 6);		/* 6*256 */ 
	outb(cp->iobase+Pstop, 32);		/* 8*1024/256 */ 
1992/0407/sys/src/9/pc/devether.c:434,4411992/0408/sys/src/9/pc/devether.c:438,445
1992/0404    
	outb(cp->iobase+Cr, 0x61);		/* Page1, RD2|STP */ 
	for(i = 0; i < sizeof(cp->ea); i++) 
		outb(cp->iobase+Par0+i, cp->ea[i]); 
	outb(cp->iobase+Curr, 6);		/* 6*256 */ 
	cp->curr = 6; 
1992/0408    
	cp->curr = cp->bnry+1; 
	outb(cp->iobase+Curr, cp->curr); 
1992/0404    
 
	outb(cp->iobase+Cr, 0x22);		/* Page0, RD2|STA */ 
	outb(cp->iobase+Tpsr, 0); 
1992/0407/sys/src/9/pc/devether.c:449,4591992/0408/sys/src/9/pc/devether.c:453,462
1992/0403    
	int i; 
 
1992/0404    
	cp->iobase = IObase; 
	init(cp); 
1992/0403    
	setvec(Ethervec, intr); 
                 
1992/0404    
	for(i = 0; i < sizeof(cp->ea); i++) 
		cp->ea[i] = inb(cp->iobase+EA+i); 
1992/0408    
	init(cp); 
	setvec(Ethervec, intr); 
1992/0404    
	memset(cp->ba, 0xFF, sizeof(cp->ba)); 
1992/0403    
 
1992/0404    
	cp->net.name = "ether"; 
1992/0407/sys/src/9/pc/devether.c:530,5361992/0408/sys/src/9/pc/devether.c:533,539
1992/0403    
{ 
1992/0404    
	Ctlr *cp = arg; 
1992/0403    
 
1992/0404    
	return cp->bnry != cp->curr; 
1992/0408    
	return NEXT(cp->bnry, 32) != cp->curr; 
1992/0403    
} 
 
static void 
1992/0407/sys/src/9/pc/devether.c:558,5741992/0408/sys/src/9/pc/devether.c:561,580
1992/0404    
			etherup(cp, (Etherpkt*)bp->rptr, BLEN(bp)); 
			freeb(bp); 
		} 
1992/0408    
 
1992/0406    
		/* 
		 * process any received packets 
		 */ 
1992/0407    
		cp->bnry = inb(cp->iobase+Bnry); 
		while(cp->bnry != cp->curr){ 
			rp = &cp->ring[cp->bnry]; 
1992/0408    
		bnry = NEXT(cp->bnry, 32); 
		while(bnry != cp->curr){ 
			rp = &cp->ring[bnry]; 
1992/0406    
			cp->inpackets++; 
1992/0407    
			etherup(cp, (Etherpkt*)rp->data, ((rp->len1<<8)+rp->len0)-4); 
			cp->bnry = rp->next; 
1992/0408    
			bnry = rp->next; 
			cp->bnry = PREV(bnry, 32); 
1992/0407    
			outb(cp->iobase+Bnry, cp->bnry); 
1992/0406    
		} 
1992/0408    
 
1992/0406    
		/* 
		 * if we idled input because of overflow, 
		 * restart 


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