xref: /csrg-svn/sys/vax/stand/uba.c (revision 7447)
1 /*	uba.c	4.6	82/07/15	*/
2 
3 #include "../h/param.h"
4 #include "../h/inode.h"
5 #include "../h/cpu.h"
6 #include "../h/pte.h"
7 #include "../h/ubareg.h"
8 #include "../h/vm.h"
9 #include "../h/fs.h"
10 #include "saio.h"
11 #include "savax.h"
12 
13 /*
14  * Note... this routine does not
15  * really allocate; unless bdp == 2
16  * you always get the same space.
17  * When bdp == 2 you get some other space.
18  */
19 ubasetup(io, bdp)
20 	register struct iob *io;
21 	int bdp;
22 {
23 	int npf;
24 	unsigned v;
25 	register struct pte *pte;
26 	int o, temp, reg;
27 	static int lastreg = 128+64;
28 
29 	v = btop(io->i_ma);
30 	o = (int)io->i_ma & PGOFSET;
31 	npf = btoc(io->i_cc + o) +1;
32 	if (bdp == 2) {
33 		reg = lastreg;
34 		lastreg += npf;
35 		bdp = 0;
36 	} else
37 		reg = 0;
38 	pte = &ubauba(io->i_unit)->uba_map[reg];
39 	temp = (bdp << 21) | UBAMR_MRV;
40 	if (bdp && (o & 01))
41 		temp |= UBAMR_BO;
42 	v &= 0x1fffff;			/* drop to physical addr */
43 	while (--npf != 0)
44 		*(int *)pte++ = v++ | temp;
45 	*(int *)pte++ = 0;
46 	return ((bdp << 28) | (reg << 9) | o);
47 }
48 
49 ubafree(io, mr)
50 	struct iob *io;
51 	int mr;
52 {
53 	register int bdp;
54 
55 	bdp = (mr >> 28) & 0x0f;
56 	if (bdp == 0)
57 		return;
58 	switch (cpu) {
59 
60 	case VAX_780:
61 		ubauba(io->i_unit)->uba_dpr[bdp] |= UBADPR_BNE;
62 		break;
63 
64 	case VAX_750:
65 		ubauba(io->i_unit)->uba_dpr[bdp] |=
66 		     UBADPR_PURGE|UBADPR_NXM|UBADPR_UCE;
67 		break;
68 	case VAX_730:
69 		break;
70 	}
71 }
72