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