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

2000/0921/bitsy/mmu.c (diff list | history)

2000/0920/sys/src/9/bitsy/mmu.c:91,1042000/0921/sys/src/9/bitsy/mmu.c:91,111 (short | long | prev | next)
2000/0907    
} 
 
/* 
2000/0920    
 *  map special use space 
2000/0921    
 *  map special space, assume that the space isn't already mapped 
2000/0907    
 */ 
ulong* 
2000/0909    
mapspecial(ulong physaddr, int len) 
2000/0907    
{ 
	ulong *t; 
2000/0909    
	ulong virtaddr, i; 
2000/0921    
	ulong virtaddr, i, base, end, off, entry, candidate; 
2000/0907    
 
2000/0921    
	base = physaddr & ~(BY2PG-1); 
	end = (physaddr+len-1) & ~(BY2PG-1); 
	if(len > 128*1024) 
		usemeg = 1; 
	off = 0; 
	candidate = 0; 
 
2000/0907    
	/* first see if we've mapped it somewhere, the first hole means we're done */ 
2000/0909    
	for(virtaddr = REGZERO; virtaddr < REGTOP; virtaddr += OneMeg){ 
		if((l1table[virtaddr>>20] & L1TypeMask) != L1PageTable){ 
2000/0920/sys/src/9/bitsy/mmu.c:105,1182000/0921/sys/src/9/bitsy/mmu.c:112,145
2000/0907    
			/* create a page table and break */ 
			t = xspanalloc(BY2PG, 1024, 0); 
			memzero(t, BY2PG, 0); 
2000/0909    
			l1table[virtaddr>>20] = L1PageTable | L1Domain0 | (((ulong)t) & L1PTBaseMask); 
2000/0921    
			l1table[virtaddr>>20] = L1PageTable | L1Domain0 | 
						(((ulong)t) & L1PTBaseMask); 
2000/0907    
			break; 
		} 
2000/0909    
		t = (ulong*)(l1table[virtaddr>>20] & L1PTBaseMask); 
2000/0907    
		for(i = 0; i < OneMeg; i += BY2PG){ 
2000/0920    
			if((t[(virtaddr+i)>>20] & L2TypeMask) != L2SmallPage) 
2000/0921    
			entry = t[(virtaddr+i)>>20]; 
 
			/* first hole means nothing left, add map */ 
			if((entry & L2TypeMask) != L2SmallPage) 
2000/0907    
				break; 
2000/0920    
			                 
2000/0921    
 
			if(candidate == 0){ 
				/* look for start of range */ 
				if((entry & L2PageBaseMask) != base) 
					continue; 
				candidate = virtaddr+i; 
			} else { 
				/* look for contiunued range */ 
				if((entry & L2PageBaseMask) != base + off) 
					candidate = 0; 
					continue; 
				} 
			} 
 
			/* if we're at the end of the range, area is already mapped */ 
			if((entry & L2PageBaseMask) == end) 
				return candidate + (physaddr-base); 
2000/0907    
		} 
		if(i < OneMeg){ 
2000/0909    
			virtaddr += i; 


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