File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / d / demand / subs.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:24:19 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v12b, v121, HEAD
Power 6/32 Unix version 1.2b


#include "definitions"

extern long r_no, pt_base, ctlblk;
long dummy;

/* To get value of base registers */
mfpr(sr)
long sr;
{
	asm("mfpr 4(fp),_dummy");
	return(dummy);
}

/* This routine modify the valid,protection bits (bit 27-31) of PTE
   in any Page table. Input parameter :
	reg_no     : contain a number specify one of the following :
		     SBR,SLR,P0BR,P0LR,P1BR,P1LR,P2BR,P2LR
	old_pte    : pointer to location to save original PTE
		     (This could be used to read any PTE when pvbits_msk = 0)
	which1     : PTE no; 0,1,2...X
	pvbits_msk : bit 27-31 of PTE 
*/
fixpv_pte(reg_no,which1,old_pte,pvbits_msk)
long reg_no, *old_pte, which1, pvbits_msk;
{	
	long *st_base;

	r_no = reg_no;

/*	asm("mfpr _r_no,_pt_base"); */		/* Get base address  */
	pt_base = mfpr(r_no);

	st_base = (long *)pt_base;
	st_base += which1;
	*old_pte = *st_base;			/* Save original PTE */
	/* Mask access and valid bits off */
	*st_base = (*st_base) & (~(PTE_PROT | PTE_V));
	*st_base = (*st_base)|(pvbits_msk);  	/* Set V,protection bits */
	asm("mtpr $0,$TBIA");		/* Invalidate translation buffers */
}

/* This routine modify the modify,used,uncachable bits (22-24) of PTE
   in any Page table. Input parameter :
	reg_no     : contain a number specify one of the following :
		     SBR,SLR,P0BR,P0LR,P1BR,P1LR,P2BR,P2LR
	old_pte    : pointer to location to save original PTE
		     (This could be used to read any PTE when pvbits_msk = 0)
	which1     : PTE no; 0,1,2...X
	pvbits_msk : bits 22-24 of PTE; if mask < 0 then just read back PTE. 
*/
fixmuc_pte(reg_no,which1,old_pte,pvbits_msk)
long reg_no, *old_pte, which1, pvbits_msk;
{	
	long *st_base;

	r_no = reg_no;

/*	asm("mfpr _r_no,_pt_base"); */		/* Get base address  */
	pt_base = mfpr(r_no);

	st_base = (long *)pt_base;
	st_base += which1;
	*old_pte = *st_base;			/* Save original PTE */
	if (pvbits_msk < 0) return;
	*st_base=(*st_base)&(~(PTE_UC|PTE_M|PTE_U)); /* Mask NC,M,U bit off */
	*st_base = (*st_base)|(pvbits_msk);  
	asm("mtpr $0,$TBIA");		/* Invalidate translation buffers */
}

/* This routine modify the page frame number (bit 0-21) of PTE
   in any Page table. Input parameter :
	reg_no     : contain a number specify one of the following :
		     SBR,SLR,P0BR,P0LR,P1BR,P1LR,P2BR,P2LR
	old_pte    : pointer to location to save original PTE
		     (This could be used to read any PTE when pvbits_msk = 0)
	which1     : PTE no; 0,1,2...X
	pfn	   : New page frame no. (bit 0 thru 19 of pfn )
*/
fixpfn_pte(reg_no,which1,old_pte,pfn)
long reg_no, *old_pte, which1, pfn;
{	
	long *st_base;

	r_no = reg_no;

/*	asm("mfpr _r_no,_pt_base"); */		/* Get base address  */
	pt_base = mfpr(r_no);

	st_base = (long *)pt_base;
	st_base += which1;
	*old_pte = *st_base;			/* Save original PTE */
	*st_base = (*st_base)&(~PTE_PFN); 	/* Mask PFN off */
	*st_base = (*st_base)|(pfn & PTE_PFN);  /* Set new PFN */
	*st_base = (*st_base)&0xff7fffff;  	/* Set PTE_M bit off */
	asm("mtpr $0,$TBIA");		/* Invalidate translation buffers */
	asm("mtpr $0,$PADC");		/* Purge all data cache */
}

/* This routine saved a vector in SCB and set it to a new one
   input parameters :
	which1 : Vector no; 0,1,2,..X
	saved_vec : pointer to a location to saved original vector
	new_vec   : address of new handler
	stack     : 'K' or 'k' : service on Kernel stack
		    otherwise  : service on Interrupt stack
*/


set_handler(which1,saved_vec,new_vec)
long which1, *saved_vec, new_vec; 
{	long *st_base;

	asm("movab _scb,_ctlblk");
	st_base = (long *)ctlblk;	/* address of SCB is at page 2 */
	st_base += which1;
	*saved_vec = *st_base;		/* Save original vector */
	*st_base = new_vec;
}


/* This routine write the who page of memory with "value"
   Inpur parameters :
	space	: Has 1 of these values (0,1,2,3) correspond to
		  P0, P1, P2, System space respectively.
	page_no	: Virtual page no. to be written
	value   : Value to be written
	v_type	: | 0 : value is used to write in all locations.
		  | 1 : value is the start value and is incremented
		  |     for next locations.
*/

write_pg(space,page_no,value,v_type)
long space, page_no, value, v_type;
{
	long *lptr;
	int ix;

	lptr = (long *)(((space & 0x3)<<30)|((page_no & 0xfffff)<<PGSHIFT));
	for (ix=0;ix<NBPG;ix += 4)
		{
		  *lptr++ = value;
		  if (v_type) value += 4;
		}
}

/* This routine read the who page of memory .
   Inpur parameters :
	space	: Has 1 of these values (0,1,2,3) correspond to
		  P0, P1, P2, System space respectively.
	page_no	: Virtual page no. to be read.
	start_dst : pointer to array of longwords.
*/

read_pg(space,page_no,start_dst)
long space, page_no, *start_dst;
{
	long *lptr;
	int ix;

	lptr = (long *)(((space & 0x3)<<30)|((page_no & 0xfffff)<<PGSHIFT));
	for (ix=0;ix<NBPG;ix += 4)
		  *start_dst++ = *lptr++ ;
}


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.