plan 9 kernel history: overview | file list | diff list

1990/03091/gnot/mmu.c (diff list | history)

gnot/mmu.c on 1990/03091
1990/03091    
#include	"u.h" 
#include	"lib.h" 
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
 
/* 
 * Called splhi, not in Running state 
 */ 
void 
mapstack(Proc *p) 
{ 
	ulong tlbvirt, tlbphys; 
 
	if(p->upage->va != (USERADDR|(p->pid&0xFFFF))) 
		panic("mapstack %d 0x%lux 0x%lux", p->pid, p->upage->pa, p->upage->va); 
	tlbvirt = USERADDR; 
	tlbphys = PPN(p->upage->pa) | PTEVALID | PTEKERNEL; 
	putkmmu(tlbvirt, tlbphys); 
	flushmmu(); 
	u = (User*)USERADDR; 
} 
 
void 
putkmmu(ulong tlbvirt, ulong tlbphys) 
{ 
	if(!(tlbvirt&KZERO)) 
		panic("putkmmu"); 
	tlbvirt &= ~KZERO; 
	KMAP[(tlbvirt&0x003FE000L)>>2] = tlbphys; 
} 
 
void 
putmmu(ulong tlbvirt, ulong tlbphys) 
{ 
	if(tlbvirt&KZERO) 
		panic("putmmu"); 
	tlbphys |= VTAG(tlbvirt)<<24; 
	UMAP[(tlbvirt&0x003FE000L)>>2] = tlbphys; 
} 
 
void 
flushmmu(void) 
{ 
	flushcpucache(); 
	*PARAM &= ~TLBFLUSH_; 
	*PARAM |= TLBFLUSH_; 
} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)