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

1991/0215/power/devhotrod.c (diff list | history)

1991/0214/sys/src/9/power/devhotrod.c:8,171991/0215/sys/src/9/power/devhotrod.c:8,17 (short | long | prev | next)
1991/0212    
#include	"fcall.h" 
1990/1013    
 
#include	"io.h" 
1991/0215    
#include	"hrod.h" 
1990/1013    
 
typedef struct Hotrod	Hotrod; 
1991/0209    
typedef struct HotQ	HotQ; 
1990/1013    
typedef struct Device	Device; 
 
enum { 
	Vmevec=		0xd2,		/* vme vector for interrupts */ 
1991/0214/sys/src/9/power/devhotrod.c:18,391991/0215/sys/src/9/power/devhotrod.c:18,27
1990/1013    
	Intlevel=	5,		/* level to interrupt on */ 
1991/0209    
	Qdir=		0,		/* Qid's */ 
	Qhotrod=	1, 
	NhotQ=		10,		/* size of communication queues */ 
1991/0215    
	NhotQ=		NRQ,		/* size of communication queues */ 
1991/0209    
	Nhotrod=	1, 
1990/1013    
}; 
 
/* 
1991/0209    
 *  The hotrod fiber interface responds to 1MB 
1990/1013    
 *  of either user or supervisor accesses at: 
 *  	0x30000000 to 0x300FFFFF  in	A32 space 
1991/0209    
 *  and	  0xB00000 to   0xBFFFFF  in	A24 space. 
 *  The second 0x40000 of this space is on-board SRAM. 
1990/1013    
 */ 
struct Device { 
1991/0209    
	ulong	mem[0x100000/sizeof(ulong)]; 
1990/1013    
}; 
1990/1018    
#define HOTROD		VMEA24SUP(Device, 0xB00000) 
1990/1013    
                 
1991/0209    
struct HotQ{ 
	ulong	i;			/* index into queue */ 
	Hotmsg	*msg[NhotQ];		/* pointer to command buffer */ 
1991/0214/sys/src/9/power/devhotrod.c:45,511991/0215/sys/src/9/power/devhotrod.c:33,39
1991/0209    
	QLock; 
1991/0212    
	QLock		buflock; 
1991/0209    
	Lock		busy; 
1990/1106    
	Device		*addr;		/* address of the device */ 
1991/0215    
	Hot		*addr;		/* address of the device */ 
1990/1106    
	int		vec;		/* vme interrupt vector */ 
1991/0209    
	HotQ		*wq;		/* write this queue to send cmds */ 
	int		wi;		/* where to write next cmd */ 
1991/0214/sys/src/9/power/devhotrod.c:59,641991/0215/sys/src/9/power/devhotrod.c:47,54
1990/1013    
 
1990/1106    
void	hotrodintr(int); 
1990/1013    
 
1991/0215    
#define	HOTROD	VMEA24SUP(Hot, 0xB00000); 
 
1991/0209    
/* 
 * Commands 
 */ 
1991/0214/sys/src/9/power/devhotrod.c:75,821991/0215/sys/src/9/power/devhotrod.c:65,73
1990/1013    
{ 
1991/0209    
print("hotsend send %d %lux %lux\n", m->cmd, m, m->param[0]); 
1991/0212    
	h->wq->msg[h->wi] = (Hotmsg*)MP2VME(m); 
1991/0209    
	while(h->wq->msg[h->wi]) 
		; 
1991/0215    
	do 
		delay(1); 
	while(h->wq->msg[h->wi]); 
1991/0209    
print("hotsend done\n"); 
	h->wi++; 
	if(h->wi >= NhotQ) 
1991/0214/sys/src/9/power/devhotrod.c:97,1051991/0215/sys/src/9/power/devhotrod.c:88,97
1991/0209    
		/* 
		 * Write queue is at end of hotrod memory 
		 */ 
		hp->wq = (HotQ*)((ulong)hp->addr+2*0x40000-sizeof(HotQ)); 
1991/0215    
		hp->wq = (HotQ*)(&hp->addr->hostrp); 
1991/0209    
		hp->vec = Vmevec+i; 
		setvmevec(hp->vec, hotrodintr); 
1991/0215    
setvmevec(0xFF, hotrodintr); 
1990/1013    
	}	 
	wbflush(); 
	delay(20); 
1991/0214/sys/src/9/power/devhotrod.c:159,1651991/0215/sys/src/9/power/devhotrod.c:151,156
1990/1013    
Chan* 
hotrodopen(Chan *c, int omode) 
{ 
1990/1106    
	Device *dp; 
	Hotrod *hp; 
1991/0212    
	Hotmsg *mp; 
1990/1106    
 
1991/0214/sys/src/9/power/devhotrod.c:186,2011991/0215/sys/src/9/power/devhotrod.c:177,184
1991/0212    
		mp->param[0] = MP2VME(&hp->rq); 
		mp->param[1] = NhotQ; 
1991/0209    
		hotsend(hp, &((User*)(u->p->upage->pa|KZERO))->khot); 
1991/0214    
		delay(1000); 
1991/0215    
		delay(100); 
1991/0214    
		print("reset\n"); 
		/* 
		 * Issue reset 
		 */ 
		mp->cmd = TEST; 
		hotsend(hp, &((User*)(u->p->upage->pa|KZERO))->khot); 
		print("ok1\n"); 
		delay(1000); 
		print("ok2\n"); 
1990/1018    
	} 
1990/1013    
	c->mode = openmode(omode); 
	c->flag |= COPEN; 
1991/0214/sys/src/9/power/devhotrod.c:233,2381991/0215/sys/src/9/power/devhotrod.c:216,222
1990/1013    
{ 
	Hotrod *hp; 
1991/0212    
	Hotmsg *mp; 
1991/0215    
	ulong l; 
1990/1013    
 
	hp = &hotrod[c->dev]; 
1991/0212    
	switch(c->qid.path){ 
1991/0214/sys/src/9/power/devhotrod.c:251,2621991/0215/sys/src/9/power/devhotrod.c:235,251
1991/0212    
			mp->param[1] = n; 
			hotsend(hp, &((User*)(u->p->upage->pa|KZERO))->khot); 
			qunlock(hp); 
1991/0215    
			l = 100*1000*000; 
1991/0212    
			do 
				n = mp->param[2]; 
			while(n == 0); 
1991/0215    
			while(n==0 && --l>0); 
			if(n == 0){ 
				print("devhotrod: give up\n"); 
				error(Egreg); 
			} 
1991/0212    
		}else{ 
			/* 
			 *  use hotrod buffer.  lock the buffer till the reply 
1991/0215    
			 *  use hotrod buffer.  lock the buffer until the reply 
1991/0212    
			 */ 
			mp = &u->uhot; 
			mp->param[2] = 0;	/* reply count */ 
1991/0214/sys/src/9/power/devhotrod.c:267,2771991/0215/sys/src/9/power/devhotrod.c:256,271
1991/0212    
			mp->param[1] = n; 
			hotsend(hp, &((User*)(u->p->upage->pa|KZERO))->uhot); 
			qunlock(hp); 
1991/0215    
			l = 100*1000*1000; 
1991/0212    
			do 
				n = mp->param[2]; 
			while(n == 0); 
1991/0215    
			while(n==0 && --l>0); 
1991/0212    
			memcpy(buf, hp->buf, n); 
			qunlock(&hp->buflock); 
1991/0215    
			if(n == 0){ 
				print("devhotrod: give up\n"); 
				error(Egreg); 
			} 
1991/0212    
		} 
		return n; 
1990/1020    
	} 
1991/0214/sys/src/9/power/devhotrod.c:344,3511991/0215/sys/src/9/power/devhotrod.c:338,347
1990/1013    
 
	print("hotrod%d interrupt\n", vec - Vmevec); 
	hp = &hotrod[vec - Vmevec]; 
1991/0215    
hp=&hotrod[0]; 
1990/1013    
	if(hp < hotrod || hp > &hotrod[Nhotrod]){ 
		print("bad hotrod vec\n"); 
		return; 
	} 
1991/0215    
	hp->addr->csr3 &= ~INT_VME; 
1990/1013    
} 


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