#
#include "mmr.h"
# define BIGSEG 077400

/*what string*/
char *__mmrwht "@(#)mmr_setup.c	1.7";
char *__mmrmmr MMRWHAT;
/* procedure to set up memory management registers*/

mmr_setup(mmr, base, size, access)
	struct space_mmr *mmr;  /* pointer to the mmrs to set up*/
	unsigned int base;      /* par value for reg 0*/
	unsigned int size;      /* size of the hunk */
	int access;             /* access field for pdr setup*/
{
	int i;                  /* loop cntr for registers*/
	unsigned int resid;     /* remaining part of hunk not yet mapped*/

	resid = size;           /* start with all of it*/
	access &= 07;   /*mask off low 3 bits*/
	for (i=0; i <= 7; i++)  {
		mmr->par[i] = base;
		if (resid <= 8192) {
			mmr->pdr[i] = ((resid/64) << 8) | access;
			access = 0;     /* for remaining registers */
			resid = 0;      /* nothing left*/
			base = 0;       /* defensively set them to 0*/
		}

		else {
			mmr -> pdr[i] = BIGSEG | access;
			resid -= 8192;
			base += 0200;  /*par incr for 4096 word seg*/
		}
       }
}
