xref: /csrg-svn/sys/vax/stand/uba.c (revision 33532)
123246Smckusick /*
229314Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
323246Smckusick  * All rights reserved.  The Berkeley software License Agreement
423246Smckusick  * specifies the terms and conditions for redistribution.
523246Smckusick  *
6*33532Sbostic  *	@(#)uba.c	7.3 (Berkeley) 02/22/88
723246Smckusick  */
8328Sbill 
99806Ssam #include "../machine/pte.h"
109806Ssam 
1133408Skarels #include "param.h"
1233408Skarels #include "inode.h"
1333408Skarels #include "vm.h"
1433408Skarels #include "fs.h"
159186Ssam 
169186Ssam #include "../vax/cpu.h"
179186Ssam #include "../vaxuba/ubareg.h"
189186Ssam 
19328Sbill #include "saio.h"
203263Swnj #include "savax.h"
21328Sbill 
223345Swnj /*
233345Swnj  * Note... this routine does not
243345Swnj  * really allocate; unless bdp == 2
253345Swnj  * you always get the same space.
263345Swnj  * When bdp == 2 you get some other space.
273345Swnj  */
28328Sbill ubasetup(io, bdp)
293263Swnj 	register struct iob *io;
303263Swnj 	int bdp;
31328Sbill {
32328Sbill 	int npf;
33*33532Sbostic 	unsigned int v;
34328Sbill 	register struct pte *pte;
353345Swnj 	int o, temp, reg;
364868Sroot 	static int lastreg = 128+64;
37328Sbill 
384868Sroot 	v = btop(io->i_ma);
394868Sroot 	o = (int)io->i_ma & PGOFSET;
404868Sroot 	npf = btoc(io->i_cc + o) +1;
413345Swnj 	if (bdp == 2) {
424868Sroot 		reg = lastreg;
434868Sroot 		lastreg += npf;
443345Swnj 		bdp = 0;
453345Swnj 	} else
463345Swnj 		reg = 0;
47*33532Sbostic 	pte = &ubauba(io->i_adapt)->uba_map[reg];
483263Swnj 	temp = (bdp << 21) | UBAMR_MRV;
49328Sbill 	if (bdp && (o & 01))
503263Swnj 		temp |= UBAMR_BO;
51328Sbill 	v &= 0x1fffff;			/* drop to physical addr */
52328Sbill 	while (--npf != 0)
53328Sbill 		*(int *)pte++ = v++ | temp;
54328Sbill 	*(int *)pte++ = 0;
553345Swnj 	return ((bdp << 28) | (reg << 9) | o);
56328Sbill }
57328Sbill 
583263Swnj ubafree(io, mr)
593263Swnj 	struct iob *io;
60328Sbill 	int mr;
61328Sbill {
623263Swnj 	register int bdp;
63328Sbill 
64328Sbill 	bdp = (mr >> 28) & 0x0f;
653263Swnj 	if (bdp == 0)
663263Swnj 		return;
673263Swnj 	switch (cpu) {
683263Swnj 
6933408Skarels #if VAX8200
7033408Skarels 	case VAX_8200:
71*33532Sbostic 		UBA_PURGEBUA(ubauba(io->i_adapt), bdp);
7233408Skarels 		break;
7333408Skarels #endif
7433408Skarels 
7524154Sbloom 	case VAX_8600:
763263Swnj 	case VAX_780:
77*33532Sbostic 		ubauba(io->i_adapt)->uba_dpr[bdp] |= UBADPR_BNE;
783263Swnj 		break;
793263Swnj 
803263Swnj 	case VAX_750:
81*33532Sbostic 		ubauba(io->i_adapt)->uba_dpr[bdp] |=
823263Swnj 		     UBADPR_PURGE|UBADPR_NXM|UBADPR_UCE;
833263Swnj 		break;
8433408Skarels 
8533408Skarels 	default:
863345Swnj 		break;
873263Swnj 	}
88328Sbill }
89