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

1997/1011/pc/memory.c (diff list | history)

1997/0823/sys/src/9/pc/memory.c:99,1051997/1011/sys/src/9/pc/memory.c:99,105 (short | long | prev | next)
1997/0329    
#endif /* notdef */ 
 
void 
1997/0327    
mapfree(RMap* rmap, ulong addr, int size) 
1997/1011    
mapfree(RMap* rmap, ulong addr, ulong size) 
1997/0327    
{ 
	Map *mp; 
	ulong t; 
1997/0823/sys/src/9/pc/memory.c:256,2621997/1011/sys/src/9/pc/memory.c:256,262
1997/0327    
	 * the BIOS data area. 
	 */ 
	x = PADDR(CPU0MACH+BY2PG); 
	bda = (uchar*)(KZERO|0x400); 
1997/1011    
	bda = (uchar*)KADDR(0x400); 
1997/0327    
	mapfree(&rmapram, x, ((bda[0x14]<<8)|bda[0x13])*KB-x); 
 
1997/0522    
	x = PADDR(PGROUND((ulong)end)); 
1997/0823/sys/src/9/pc/memory.c:290,2961997/1011/sys/src/9/pc/memory.c:290,296
1997/0327    
	 * be written and read correctly. The page tables are created here 
	 * on the fly, allocating from low memory as necessary. 
	 */ 
	k0 = (ulong*)KZERO; 
1997/1011    
	k0 = (ulong*)KADDR(0); 
1997/0327    
	kzero = *k0; 
	map = 0; 
	x = 0x12345678; 
1997/0823/sys/src/9/pc/memory.c:383,4291997/1011/sys/src/9/pc/memory.c:383,393
1997/0327    
		mapfree(&rmapram, map, BY2PG); 
1997/0329    
	if(pa < maxmem) 
		mapfree(&rmapupa, pa, maxmem-pa); 
1997/1011    
	if(maxmem < 0xFEC00000) 
		mapfree(&rmapupa, maxmem, 0xFEC00000-maxmem); 
1997/0327    
	*k0 = kzero; 
} 
 
static void 
upainit(void) 
{ 
	ulong addr, pa, pae, *table, *va, x; 
                 
	/* 
1997/0811    
	 * Allocate an 8MB chunk aligned to 16MB. Later can 
1997/0327    
	 * make the region selectable via conf if necessary. 
	 */ 
1997/0811    
	if((addr = mapalloc(&rmapupa, 0, 8*MB, 16*MB)) == 0) 
1997/0327    
		return; 
                 
	pa = addr; 
1997/0823    
	pae = pa+(8*MB); 
1997/0327    
	while(pa < pae){ 
		va = KADDR(pa); 
		table = &((ulong*)m->pdb)[PDX(va)]; 
		if((pa % (4*MB)) == 0 && (m->cpuiddx & 0x08)){ 
			*table = pa|PTESIZE|PTEWRITE|PTEUNCACHED|PTEVALID; 
			pa += (4*MB); 
		} 
		else{ 
			if(*table == 0){ 
				if((x = mapalloc(&rmapram, 0, BY2PG, BY2PG)) == 0) 
					break; 
				memset(KADDR(x), 0, BY2PG); 
				*table = x|PTEWRITE|PTEVALID; 
			} 
			table = (ulong*)(KZERO|PPN(*table)); 
			table[PTX(va)] = pa|PTEWRITE|PTEUNCACHED|PTEVALID; 
			pa += BY2PG; 
		} 
	} 
                 
	mapfree(&xrmapupa, addr, pa-addr); 
} 
                 
1997/0329    
                 
1997/0327    
void 
1997/0329    
meminit(ulong maxmem) 
1997/0327    
{ 
1997/0823/sys/src/9/pc/memory.c:448,4541997/1011/sys/src/9/pc/memory.c:412,417
1997/0327    
 
	umbscan(); 
1997/0329    
	ramscan(maxmem); 
1997/0327    
	upainit(); 
 
	/* 
	 * Set the conf entries describing two banks of allocatable memory. 
1997/0823/sys/src/9/pc/memory.c:477,4831997/1011/sys/src/9/pc/memory.c:440,446
1997/0327    
	ulong a; 
 
	if(a = mapalloc(&rmapumb, addr, size, align)) 
		return KZERO|a; 
1997/1011    
		return (ulong)KADDR(a); 
1997/0327    
 
	return 0; 
} 
1997/0823/sys/src/9/pc/memory.c:485,4911997/1011/sys/src/9/pc/memory.c:448,454
1997/0327    
void 
umbfree(ulong addr, int size) 
{ 
	mapfree(&rmapumb, addr & ~KZERO, size); 
1997/1011    
	mapfree(&rmapumb, PADDR(addr), size); 
1997/0329    
} 
 
ulong 
1997/0823/sys/src/9/pc/memory.c:495,5011997/1011/sys/src/9/pc/memory.c:458,464
1997/0331    
	uchar *p; 
1997/0329    
 
1997/0331    
	if(a = mapalloc(&rmapumbrw, addr, size, align)) 
1997/0329    
		return KZERO|a; 
1997/1011    
		return(ulong)KADDR(a); 
1997/0329    
 
1997/0331    
	/* 
	 * Perhaps the memory wasn't visible before 
1997/0823/sys/src/9/pc/memory.c:516,5371997/1011/sys/src/9/pc/memory.c:479,514
1997/0331    
void 
umbrwfree(ulong addr, int size) 
{ 
	mapfree(&rmapumbrw, addr & ~KZERO, size); 
1997/1011    
	mapfree(&rmapumbrw, PADDR(addr), size); 
1997/0327    
} 
 
ulong 
upamalloc(ulong addr, int size, int align) 
{ 
	ulong a; 
1997/1011    
	ulong a, ae; 
1997/0327    
 
	if(a = mapalloc(&xrmapupa, addr, size, align)) 
		return KZERO|a; 
1997/1011    
		return (ulong)KADDR(a); 
1997/0327    
 
	return 0; 
1997/1011    
	if((a = mapalloc(&rmapupa, addr, size, align)) == 0) 
		return 0; 
 
	ae = mmukmap(a, 0, size); 
 
	/* 
	 * Should check here that it was all delivered 
	 * and put it back and barf if not. 
	 */ 
	USED(ae); 
 
	/* 
	 * Be very careful this returns a PHYSICAL address. 
	 */ 
	return a; 
1997/0327    
} 
 
void 
upafree(ulong addr, int size) 
{ 
	mapfree(&xrmapupa, addr & ~KZERO, size); 
1997/1011    
	mapfree(&xrmapupa, addr, size); 
1997/0327    
} 


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