xref: /original-bsd/sys/vax/stand/uba.c (revision 57530171)
1 /*
2  * Copyright (c) 1982, 1986 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)uba.c	7.3 (Berkeley) 02/22/88
7  */
8 
9 #include "../machine/pte.h"
10 
11 #include "param.h"
12 #include "inode.h"
13 #include "vm.h"
14 #include "fs.h"
15 
16 #include "../vax/cpu.h"
17 #include "../vaxuba/ubareg.h"
18 
19 #include "saio.h"
20 #include "savax.h"
21 
22 /*
23  * Note... this routine does not
24  * really allocate; unless bdp == 2
25  * you always get the same space.
26  * When bdp == 2 you get some other space.
27  */
28 ubasetup(io, bdp)
29 	register struct iob *io;
30 	int bdp;
31 {
32 	int npf;
33 	unsigned int v;
34 	register struct pte *pte;
35 	int o, temp, reg;
36 	static int lastreg = 128+64;
37 
38 	v = btop(io->i_ma);
39 	o = (int)io->i_ma & PGOFSET;
40 	npf = btoc(io->i_cc + o) +1;
41 	if (bdp == 2) {
42 		reg = lastreg;
43 		lastreg += npf;
44 		bdp = 0;
45 	} else
46 		reg = 0;
47 	pte = &ubauba(io->i_adapt)->uba_map[reg];
48 	temp = (bdp << 21) | UBAMR_MRV;
49 	if (bdp && (o & 01))
50 		temp |= UBAMR_BO;
51 	v &= 0x1fffff;			/* drop to physical addr */
52 	while (--npf != 0)
53 		*(int *)pte++ = v++ | temp;
54 	*(int *)pte++ = 0;
55 	return ((bdp << 28) | (reg << 9) | o);
56 }
57 
58 ubafree(io, mr)
59 	struct iob *io;
60 	int mr;
61 {
62 	register int bdp;
63 
64 	bdp = (mr >> 28) & 0x0f;
65 	if (bdp == 0)
66 		return;
67 	switch (cpu) {
68 
69 #if VAX8200
70 	case VAX_8200:
71 		UBA_PURGEBUA(ubauba(io->i_adapt), bdp);
72 		break;
73 #endif
74 
75 	case VAX_8600:
76 	case VAX_780:
77 		ubauba(io->i_adapt)->uba_dpr[bdp] |= UBADPR_BNE;
78 		break;
79 
80 	case VAX_750:
81 		ubauba(io->i_adapt)->uba_dpr[bdp] |=
82 		     UBADPR_PURGE|UBADPR_NXM|UBADPR_UCE;
83 		break;
84 
85 	default:
86 		break;
87 	}
88 }
89