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