xref: /csrg-svn/sys/vax/stand/uba.c (revision 7447)
1*7447Sroot /*	uba.c	4.6	82/07/15	*/
2328Sbill 
3328Sbill #include "../h/param.h"
4328Sbill #include "../h/inode.h"
53263Swnj #include "../h/cpu.h"
6328Sbill #include "../h/pte.h"
73263Swnj #include "../h/ubareg.h"
8328Sbill #include "../h/vm.h"
9*7447Sroot #include "../h/fs.h"
10328Sbill #include "saio.h"
113263Swnj #include "savax.h"
12328Sbill 
133345Swnj /*
143345Swnj  * Note... this routine does not
153345Swnj  * really allocate; unless bdp == 2
163345Swnj  * you always get the same space.
173345Swnj  * When bdp == 2 you get some other space.
183345Swnj  */
19328Sbill ubasetup(io, bdp)
203263Swnj 	register struct iob *io;
213263Swnj 	int bdp;
22328Sbill {
23328Sbill 	int npf;
24328Sbill 	unsigned v;
25328Sbill 	register struct pte *pte;
263345Swnj 	int o, temp, reg;
274868Sroot 	static int lastreg = 128+64;
28328Sbill 
294868Sroot 	v = btop(io->i_ma);
304868Sroot 	o = (int)io->i_ma & PGOFSET;
314868Sroot 	npf = btoc(io->i_cc + o) +1;
323345Swnj 	if (bdp == 2) {
334868Sroot 		reg = lastreg;
344868Sroot 		lastreg += npf;
353345Swnj 		bdp = 0;
363345Swnj 	} else
373345Swnj 		reg = 0;
383345Swnj 	pte = &ubauba(io->i_unit)->uba_map[reg];
393263Swnj 	temp = (bdp << 21) | UBAMR_MRV;
40328Sbill 	if (bdp && (o & 01))
413263Swnj 		temp |= UBAMR_BO;
42328Sbill 	v &= 0x1fffff;			/* drop to physical addr */
43328Sbill 	while (--npf != 0)
44328Sbill 		*(int *)pte++ = v++ | temp;
45328Sbill 	*(int *)pte++ = 0;
463345Swnj 	return ((bdp << 28) | (reg << 9) | o);
47328Sbill }
48328Sbill 
493263Swnj ubafree(io, mr)
503263Swnj 	struct iob *io;
51328Sbill 	int mr;
52328Sbill {
533263Swnj 	register int bdp;
54328Sbill 
55328Sbill 	bdp = (mr >> 28) & 0x0f;
563263Swnj 	if (bdp == 0)
573263Swnj 		return;
583263Swnj 	switch (cpu) {
593263Swnj 
603263Swnj 	case VAX_780:
613263Swnj 		ubauba(io->i_unit)->uba_dpr[bdp] |= UBADPR_BNE;
623263Swnj 		break;
633263Swnj 
643263Swnj 	case VAX_750:
653263Swnj 		ubauba(io->i_unit)->uba_dpr[bdp] |=
663263Swnj 		     UBADPR_PURGE|UBADPR_NXM|UBADPR_UCE;
673263Swnj 		break;
68*7447Sroot 	case VAX_730:
693345Swnj 		break;
703263Swnj 	}
71328Sbill }
72