xref: /csrg-svn/sys/vax/stand/uba.c (revision 45803)
123246Smckusick /*
235052Skarels  * Copyright (c) 1982, 1986, 1988 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*45803Sbostic  *	@(#)uba.c	7.6 (Berkeley) 12/16/90
723246Smckusick  */
8328Sbill 
9*45803Sbostic #include "sys/param.h"
10*45803Sbostic #include "sys/vm.h"
119186Ssam 
12*45803Sbostic #include "../include/pte.h"
13*45803Sbostic #include "../include/cpu.h"
14*45803Sbostic #include "../uba/ubareg.h"
159186Ssam 
16*45803Sbostic #include "stand/saio.h"
173263Swnj #include "savax.h"
18328Sbill 
193345Swnj /*
203345Swnj  * Note... this routine does not
213345Swnj  * really allocate; unless bdp == 2
223345Swnj  * you always get the same space.
233345Swnj  * When bdp == 2 you get some other space.
243345Swnj  */
ubasetup(io,bdp)25328Sbill ubasetup(io, bdp)
263263Swnj 	register struct iob *io;
273263Swnj 	int bdp;
28328Sbill {
29328Sbill 	int npf;
3033532Sbostic 	unsigned int v;
31328Sbill 	register struct pte *pte;
323345Swnj 	int o, temp, reg;
334868Sroot 	static int lastreg = 128+64;
34328Sbill 
354868Sroot 	v = btop(io->i_ma);
364868Sroot 	o = (int)io->i_ma & PGOFSET;
374868Sroot 	npf = btoc(io->i_cc + o) +1;
383345Swnj 	if (bdp == 2) {
394868Sroot 		reg = lastreg;
404868Sroot 		lastreg += npf;
413345Swnj 		bdp = 0;
423345Swnj 	} else
433345Swnj 		reg = 0;
4433532Sbostic 	pte = &ubauba(io->i_adapt)->uba_map[reg];
453263Swnj 	temp = (bdp << 21) | UBAMR_MRV;
46328Sbill 	if (bdp && (o & 01))
473263Swnj 		temp |= UBAMR_BO;
48328Sbill 	v &= 0x1fffff;			/* drop to physical addr */
49328Sbill 	while (--npf != 0)
50328Sbill 		*(int *)pte++ = v++ | temp;
51328Sbill 	*(int *)pte++ = 0;
523345Swnj 	return ((bdp << 28) | (reg << 9) | o);
53328Sbill }
54328Sbill 
553263Swnj ubafree(io, mr)
563263Swnj 	struct iob *io;
57328Sbill 	int mr;
58328Sbill {
593263Swnj 	register int bdp;
60328Sbill 
61328Sbill 	bdp = (mr >> 28) & 0x0f;
623263Swnj 	if (bdp == 0)
633263Swnj 		return;
643263Swnj 	switch (cpu) {
653263Swnj 
6633408Skarels #if VAX8200
6733408Skarels 	case VAX_8200:
6833532Sbostic 		UBA_PURGEBUA(ubauba(io->i_adapt), bdp);
6933408Skarels 		break;
7033408Skarels #endif
7133408Skarels 
7235052Skarels #if VAX780 || VAX8600
7324154Sbloom 	case VAX_8600:
743263Swnj 	case VAX_780:
7533532Sbostic 		ubauba(io->i_adapt)->uba_dpr[bdp] |= UBADPR_BNE;
763263Swnj 		break;
7735052Skarels #endif
783263Swnj 
7935052Skarels #if VAX750
803263Swnj 	case VAX_750:
8133532Sbostic 		ubauba(io->i_adapt)->uba_dpr[bdp] |=
823263Swnj 		     UBADPR_PURGE|UBADPR_NXM|UBADPR_UCE;
833263Swnj 		break;
8435052Skarels #endif
8533408Skarels 
8633408Skarels 	default:
873345Swnj 		break;
883263Swnj 	}
89328Sbill }
90