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

1990/1231/power/main.c (diff list | history)

1990/1229/sys/src/9/power/main.c:39,561990/1231/sys/src/9/power/main.c:39,45 (short | long | prev | next)
1990/0826    
 */ 
int ioid; 
 
1990/1228    
/* 
1990/1229    
 *  lance memory allocation 
1990/1228    
 */ 
1990/1229    
ushort	*lancelmem;	/* next free lance mem as seen by lance */ 
ushort	*lancehmem;	/* next free lance mem as seen by host */ 
ushort	*lancehend; 
1990/1228    
 
1990/1229    
/* 
 *  next free lance memory map 
 */ 
int	lancemap; 
1990/1228    
                 
1990/11211    
char	user[NAMELEN] = "bootes"; 
 
1990/0227    
void 
1990/1229/sys/src/9/power/main.c:192,2181990/1231/sys/src/9/power/main.c:181,186
1990/0227    
	 */ 
1990/0907    
	*IO2SETMASK = 0xff; 
1990/1228    
 
	/* 
	 *  reset the lance. 
	 *  run through all lance memory to set parity. 
	 */ 
	if(ioid >= IO3R1){ 
		MODEREG->promenet |= 1; 
		MODEREG->promenet &= ~1; 
		for(sp = LANCE3RAM; sp < LANCE3END; sp += 2) 
			*sp = 0; 
1990/1229    
		lancehmem = LANCE3RAM; 
		lancehend = LANCE3END; 
		lancelmem = (ushort*)0x800000; 
1990/1228    
	} else { 
		MODEREG->promenet &= ~1; 
		MODEREG->promenet |= 1; 
		for(sp = LANCERAM; sp < LANCEEND; sp += 1) 
			*sp = 0; 
1990/1229    
		lancehmem = LANCERAM; 
		lancehend = LANCEEND; 
		lancelmem = (ushort*)0; 
1990/1228    
	} 
} 
 
1990/0227    
void 
1990/1229/sys/src/9/power/main.c:734,8131990/1231/sys/src/9/power/main.c:702,800
1990/1229    
} 
 
/* 
 *  get our ether addr out of the non-volatile ram 
1990/1231    
 *  setup the IO2 lance, io buffers are in lance memory 
1990/1229    
 */ 
void 
lanceeaddr(uchar *ea) 
1990/1231    
lanceIO2setup(Lance *lp) 
1990/1229    
{ 
	ea[0] = LANCEID[20]>>8; 
	ea[1] = LANCEID[16]>>8; 
	ea[2] = LANCEID[12]>>8; 
	ea[3] = LANCEID[8]>>8; 
	ea[4] = LANCEID[4]>>8; 
	ea[5] = LANCEID[0]>>8; 
1990/1231    
	ushort *sp; 
 
	/* 
	 *  reset lance and set parity on its memory 
	 */ 
	MODEREG->promenet &= ~1; 
	MODEREG->promenet |= 1; 
	for(sp = LANCERAM; sp < LANCEEND; sp += 1) 
		*sp = 0; 
 
	lp->sep = 1; 
	lp->lanceram = LANCERAM; 
	lp->lm = (Lancemem*)0; 
 
	/* 
	 *  Allocate space in lance memory for the io buffers. 
	 *  Start at 4k to avoid the initialization block and 
	 *  descriptor rings. 
	 */ 
	lp->lrp = (Etherpkt*)(4*1024); 
	lp->ltp = lp->lrp + lp->nrrb; 
	lp->rp = (Etherpkt*)(((ulong)LANCERAM) + (ulong)lp->lrp); 
	lp->tp = lp->rp + lp->nrrb; 
1990/1229    
} 
 
/* 
 *  allocate command memory for the initialization block 
 *  and descriptor rings. 
 * 
 *  pass back the host's address of the memory, the lance's address 
 *  of the memory, and the span (in shorts) of each short as seen 
 *  by the host.  The latter is only for a peculiarity of the SGI IO3. 
 *  It is normally 1. 
1990/1231    
 *  setup the IO3 lance, io buffers are in host memory mapped to 
 *  lance address space 
1990/1229    
 */ 
void 
lancectlmem(ushort **hostaddr, ushort **lanceaddr, int *sep, int len) 
1990/1231    
lanceIO3setup(Lance *lp) 
1990/1229    
{ 
	len = (len + sizeof(ushort) - 1)/sizeof(ushort); 
	if(ioid >= IO3R1) 
		*sep = 4; 
	else 
		*sep = 1; 
	if(len+lancehmem > lancehend) 
		panic("lancecmdmem"); 
	*lanceaddr = lancelmem; 
	*hostaddr = lancehmem; 
	lancelmem += len; 
	lancehmem += len; 
1990/1231    
	ulong x, y; 
	int index; 
	ushort *sp; 
	int len; 
 
	/* 
	 *  reset lance and set parity on its memory 
	 */ 
	MODEREG->promenet |= 1; 
	MODEREG->promenet &= ~1; 
	for(sp = LANCE3RAM; sp < LANCE3END; sp += 2) 
		*sp = 0; 
 
	lp->sep = 4; 
	lp->lanceram = LANCE3RAM; 
	lp->lm = (Lancemem*)0x800000; 
 
	/* 
	 *  allocate some host memory for buffers and map it into lance 
	 *  space 
	 */ 
	len = (lp->nrrb + lp->ntrb)*sizeof(Etherpkt); 
	lp->rp = (Etherpkt*)ialloc(len , 1); 
	lp->tp = lp->rp + lp->nrrb; 
	x = (ulong)lp->rp; 
	lp->lrp = (Etherpkt*)(x & 0xFFF); 
	lp->ltp = lp->lrp + lp->nrrb; 
	index = LANCEINDEX; 
	for(y = x+len; x < y; x += 0x1000){ 
		*WRITEMAP = (index<<16) | (x>>12)&0xFFFF; 
		index++; 
	} 
1990/1229    
} 
 
/* 
 *  allocate packet buffer memory for the lance. 
 * 
 *  pass back the host's address of the memory and the lance's address 
 *  of the memory. 
1990/1231    
 *  set up the lance 
1990/1229    
 */ 
void 
lancepktmem(ushort **hostaddr, ushort **lanceaddr, int len) 
1990/1231    
lancesetup(Lance *lp) 
1990/1229    
{ 
	ulong x; 
	ulong y; 
                 
	if(ioid >= IO3R1){ 
		/* 
		 *  allocate some host mempry and map it into lance 
		 *  space 
		 */ 
		*hostaddr = (ushort*)ialloc(len, 1); 
		x = (ulong)*hostaddr; 
		*lanceaddr = (ushort*)((lancemap<<12) | (x & 0xFFF)); 
		for(y = x; y < x+len; y += 0x1000){ 
			*WRITEMAP = ((0x1E00+lancemap)<<16) | (y>>12)&0xFFFF; 
			lancemap++; 
		} 
	} else { 
		/* 
		 *  allocate lance memory 
		 */ 
		len = (len + sizeof(ushort) - 1)/sizeof(ushort); 
		if(len+lancehmem > lancehend) 
			panic("lancecmdmem"); 
		*lanceaddr = lancelmem; 
		*hostaddr = lancehmem; 
		lancelmem += len; 
		lancehmem += len; 
	} 
1990/1231    
	lp->rap = LANCERAP; 
	lp->rdp = LANCERDP; 
	lp->ea[0] = LANCEID[20]>>8; 
	lp->ea[1] = LANCEID[16]>>8; 
	lp->ea[2] = LANCEID[12]>>8; 
	lp->ea[3] = LANCEID[8]>>8; 
	lp->ea[4] = LANCEID[4]>>8; 
	lp->ea[5] = LANCEID[0]>>8; 
	lp->lognrrb = 7; 
	lp->logntrb = 7; 
	lp->nrrb = 1<<lp->lognrrb; 
	lp->ntrb = 1<<lp->logntrb; 
	if(ioid >= IO3R1) 
		lanceIO3setup(lp); 
	else 
		lanceIO2setup(lp); 
1990/1229    
} 
 
void 


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