xref: /csrg-svn/sys/vax/stand/uba.c (revision 9186)
1*9186Ssam /*	uba.c	4.7	82/11/13	*/
2328Sbill 
3328Sbill #include "../h/param.h"
4328Sbill #include "../h/inode.h"
5328Sbill #include "../h/pte.h"
6328Sbill #include "../h/vm.h"
77447Sroot #include "../h/fs.h"
8*9186Ssam 
9*9186Ssam #include "../vax/cpu.h"
10*9186Ssam #include "../vaxuba/ubareg.h"
11*9186Ssam 
12328Sbill #include "saio.h"
133263Swnj #include "savax.h"
14328Sbill 
153345Swnj /*
163345Swnj  * Note... this routine does not
173345Swnj  * really allocate; unless bdp == 2
183345Swnj  * you always get the same space.
193345Swnj  * When bdp == 2 you get some other space.
203345Swnj  */
21328Sbill ubasetup(io, bdp)
223263Swnj 	register struct iob *io;
233263Swnj 	int bdp;
24328Sbill {
25328Sbill 	int npf;
26328Sbill 	unsigned v;
27328Sbill 	register struct pte *pte;
283345Swnj 	int o, temp, reg;
294868Sroot 	static int lastreg = 128+64;
30328Sbill 
314868Sroot 	v = btop(io->i_ma);
324868Sroot 	o = (int)io->i_ma & PGOFSET;
334868Sroot 	npf = btoc(io->i_cc + o) +1;
343345Swnj 	if (bdp == 2) {
354868Sroot 		reg = lastreg;
364868Sroot 		lastreg += npf;
373345Swnj 		bdp = 0;
383345Swnj 	} else
393345Swnj 		reg = 0;
403345Swnj 	pte = &ubauba(io->i_unit)->uba_map[reg];
413263Swnj 	temp = (bdp << 21) | UBAMR_MRV;
42328Sbill 	if (bdp && (o & 01))
433263Swnj 		temp |= UBAMR_BO;
44328Sbill 	v &= 0x1fffff;			/* drop to physical addr */
45328Sbill 	while (--npf != 0)
46328Sbill 		*(int *)pte++ = v++ | temp;
47328Sbill 	*(int *)pte++ = 0;
483345Swnj 	return ((bdp << 28) | (reg << 9) | o);
49328Sbill }
50328Sbill 
513263Swnj ubafree(io, mr)
523263Swnj 	struct iob *io;
53328Sbill 	int mr;
54328Sbill {
553263Swnj 	register int bdp;
56328Sbill 
57328Sbill 	bdp = (mr >> 28) & 0x0f;
583263Swnj 	if (bdp == 0)
593263Swnj 		return;
603263Swnj 	switch (cpu) {
613263Swnj 
623263Swnj 	case VAX_780:
633263Swnj 		ubauba(io->i_unit)->uba_dpr[bdp] |= UBADPR_BNE;
643263Swnj 		break;
653263Swnj 
663263Swnj 	case VAX_750:
673263Swnj 		ubauba(io->i_unit)->uba_dpr[bdp] |=
683263Swnj 		     UBADPR_PURGE|UBADPR_NXM|UBADPR_UCE;
693263Swnj 		break;
707447Sroot 	case VAX_730:
713345Swnj 		break;
723263Swnj 	}
73328Sbill }
74