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

1991/0608/port/fault.c (diff list | history)

1991/0607/sys/src/9/port/fault.c:9,151991/0608/sys/src/9/port/fault.c:9,15 (short | long | prev | next)
1990/1212    
int 
fault(ulong addr, int read) 
1990/0227    
{ 
1991/0607    
	ulong mmuvirt, mmuphys, uncache = 0, n; 
1991/0608    
	ulong mmuvirt, mmuphys, n; 
1990/0227    
	Seg *s; 
	PTE *opte, *pte, *npte; 
	Orig *o; 
1991/0607/sys/src/9/port/fault.c:71,771991/0608/sys/src/9/port/fault.c:71,76
1991/0607    
					unlock(o); 
					return -1; 
				} 
				uncache = PTEUNCACHED; 
1991/0606    
			} 
			else 
				pte->page = newpage(0, o, addr); 
1991/0607/sys/src/9/port/fault.c:116,1271991/0608/sys/src/9/port/fault.c:115,133
1990/0227    
			} 
		} 
	} 
	/* 
1990/1212    
	 * Copy on reference (conf.copymode==1) or write (conf.copymode==0) 
1990/0227    
	 */ 
1991/0607    
	if((o->flag & (OWRPERM|OSHARED))==OWRPERM && (conf.copymode || !read) 
1991/0608    
 
	if(o->flag&OSHARED) { 
		/* BUG: Does not cover enough flag options to shared data */ 
		mmuphys = PTERONLY; 
		if(o->flag & OWRPERM) 
			mmuphys = PTEWRITE; 
	} 
	else if((o->flag&OWRPERM) && (conf.copymode || !read) 
1990/0227    
	&& ((head && ((o->flag&OPURE) || o->nproc>1)) 
	    || (!head && pte->page->ref>1))){ 
1991/0608    
		/* 
		 * Copy on reference (conf.copymode==1) or write (conf.copymode==0) 
		 */ 
1991/0607    
 
		if(!(o->flag&OISMEM)) 
			panic("copy on ref/wr to non memory"); 
1991/0607/sys/src/9/port/fault.c:199,2071991/0608/sys/src/9/port/fault.c:205,217
1991/0607    
					mmuphys = PTEWRITE; 
1990/0227    
	} 
	mmuvirt = addr; 
1991/0607    
	mmuphys |= PPN(pte->page->pa) | PTEVALID | uncache; 
	if(o->flag&OISMEM) 
1991/0608    
 
	/* Non memory is always uncached */ 
	if(o->flag&OISMEM) { 
		mmuphys |= PPN(pte->page->pa) | PTEVALID; 
1991/0607    
		usepage(pte->page, 1); 
1991/0608    
	}else 
		mmuphys |= PPN(pte->page->pa) | PTEVALID | PTEUNCACHED; 
1991/0607    
 
1990/0227    
	if(pte->page->va != addr) 
		panic("wrong addr in tail %lux %lux", pte->page->va, addr); 
1991/0607/sys/src/9/port/fault.c:216,2211991/0608/sys/src/9/port/fault.c:226,235
1991/0425    
		m->tlbfault++; 
1991/0607    
 
1990/0227    
	putmmu(mmuvirt, mmuphys); 
1991/0608    
/* 
	if(s - u->p->seg == LSEG) 
		print("%d: f %lux v %lux p %lux\n", u->p->pid, o->flag, mmuvirt, mmuphys); 
*/ 
1990/1212    
	return 0; 
1990/0227    
} 
 


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