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

2002/0414/port/devpnp.c (diff list | history)

2002/0109/sys/src/9/port/devpnp.c:485,4942002/0414/sys/src/9/port/devpnp.c:485,496 (short | long | prev | next)
2001/0728    
static long 
pnpread(Chan *c, void *va, long n, vlong offset) 
{ 
2002/0414    
	ulong x; 
2001/0728    
	Card *cp; 
2001/0801    
	Pcidev *p; 
	int csn, i, tbdf; 
2002/0414    
	char buf[256], *ebuf, *w; 
2001/0809    
	char *a = va; 
2002/0414    
	int csn, i, tbdf, r; 
2001/0728    
 
	switch(TYPE(c->qid)){ 
	case Qtopdir: 
2002/0109/sys/src/9/port/devpnp.c:511,5192002/0414/sys/src/9/port/devpnp.c:513,521
2001/0809    
		qlock(&pnp); 
2001/0728    
		initiation(); 
		cmd(0x03, csn);				/* Wake up the card */ 
		for (i = 0; i < offset+9; i++)		/* 9 == skip serial + csum */ 
2002/0414    
		for(i = 0; i < offset+9; i++)		/* 9 == skip serial + csum */ 
2001/0728    
			getresbyte(pnp.rddata); 
		for (i = 0; i < n; i++) 
2002/0414    
		for(i = 0; i < n; i++) 
2001/0728    
			a[i] = getresbyte(pnp.rddata); 
		cmd(0x03, 0);					/* Wake all cards with a CSN of 0, putting this card to sleep */ 
		cmd(0x02, 0x02);				/* return cards to Wait for Key state */ 
2002/0109/sys/src/9/port/devpnp.c:531,5452002/0414/sys/src/9/port/devpnp.c:533,571
2001/0801    
		p = pcimatchtbdf(tbdf); 
		if(p == nil) 
			error(Egreg); 
2001/0809    
		sprint(up->genbuf, "class %.2x subclass %.2x piclass %.2x vid %.4x did %.4x intl %d\n", 
2002/0414    
		ebuf = buf+sizeof buf-1;	/* -1 for newline */ 
		w = seprint(buf, ebuf, "%.2x.%.2x.%.2x %.4x/%.4x %3d", 
2001/0801    
			p->ccrb, p->ccru, p->ccrp, p->vid, p->did, p->intl); 
2001/0809    
		return readstr(offset, a, n, up->genbuf); 
2002/0414    
		for(i=0; i<nelem(p->mem); i++){ 
			if(p->mem[i].size == 0) 
				continue; 
			w = seprint(w, ebuf, " %d:%.8lux %d", i, p->mem[i].bar, p->mem[i].size); 
		} 
		*w++ = '\n'; 
		*w = '\0'; 
		return readstr(offset, a, n, buf); 
2001/0801    
	case Qpciraw: 
		tbdf = MKBUS(BusPCI, 0, 0, 0)|BUSBDF((ulong)c->qid.path); 
		p = pcimatchtbdf(tbdf); 
		if(p == nil) 
			error(Egreg); 
		break; 
2002/0414    
		if(offset > 128) 
			return 0; 
		if(n+offset > 128) 
			n = 128-offset; 
		if(offset%4) 
			error(Ebadarg); 
		r = offset; 
		for(i = 0; i+4 <= n; i+=4) { 
			x = pcicfgr32(p, r); 
			a[0] = x; 
			a[1] = (x>>8); 
			a[2] = (x>>16); 
			a[3] = (x>>24); 
			a += 4; 
			r += 4; 
		} 
		return i; 
2001/0728    
	default: 
		error(Egreg); 
	} 


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