xref: /csrg-svn/sys/vax/stand/mba.c (revision 323)
1*323Sbill /*	mba.c	1.1	06/28/80	*/
2*323Sbill 
3*323Sbill #include "../h/param.h"
4*323Sbill #include "../h/inode.h"
5*323Sbill #include "../h/pte.h"
6*323Sbill #include "../h/mba.h"
7*323Sbill #include "../h/mtpr.h"
8*323Sbill #include "../h/vm.h"
9*323Sbill #include "saio.h"
10*323Sbill 
11*323Sbill /*
12*323Sbill  * startup routine for MBA controllers.
13*323Sbill  */
14*323Sbill #define	MBAWCOM	0x30
15*323Sbill #define	MBARCOM	0x38
16*323Sbill #define	GO	01
17*323Sbill 
18*323Sbill mbastart(io, adcr, func)
19*323Sbill register struct iob *io;
20*323Sbill int *adcr;
21*323Sbill {
22*323Sbill 	register int i;
23*323Sbill 	int npf;
24*323Sbill 	unsigned v;
25*323Sbill 	register struct pte *pte;
26*323Sbill 	int o;
27*323Sbill 	int vaddr;
28*323Sbill 	extern int mbanum[], *mbaloc[];
29*323Sbill 	register struct mba_regs *mbap;
30*323Sbill 
31*323Sbill 	mbap = (struct mba_regs *)mbaloc[mbanum[io->i_unit]];
32*323Sbill 	pte = (struct pte *)mbap;
33*323Sbill 	pte += (MBA_MAP + 128*4)/4;
34*323Sbill 	v = btop(io->i_ma);
35*323Sbill 	o = (int)io->i_ma & PGOFSET;
36*323Sbill 	npf = btoc(io->i_cc + o);
37*323Sbill 	vaddr = (128 << 9) | o;
38*323Sbill 	v &= 0x1fffff;		/* drop to physical addr */
39*323Sbill 	while (--npf >= 0)
40*323Sbill 		*(int *)pte++ = v++ | PG_V;
41*323Sbill 	mbap->mba_sr = -1;	/* clear status (error) bits */
42*323Sbill 	mbap->mba_bcr = -io->i_cc;
43*323Sbill 	mbap->mba_var = vaddr;
44*323Sbill 	if (func == READ)
45*323Sbill 		*adcr = MBARCOM | GO;
46*323Sbill 	else if (func == WRITE) {
47*323Sbill 		*adcr = MBAWCOM | GO;
48*323Sbill 	}
49*323Sbill }
50