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

1994/0406/power/mmu.c (diff list | history)

1993/0812/sys/src/9/power/mmu.c:7,201994/0406/sys/src/9/power/mmu.c:7,23 (short | long | prev | next)
1990/0227    
void 
1993/0501    
mmuswitch(Proc *p) 
1990/0227    
{ 
1994/0406    
	int tp; 
 
1991/0705    
	if(p->newtlb) { 
		memset(p->pidonmach, 0, sizeof p->pidonmach); 
		p->newtlb = 0; 
	} 
1993/0501    
	if(p->pidonmach[m->machno] == 0) 
		newtlbpid(p); 
1994/0406    
	tp = p->pidonmach[m->machno]; 
	if(tp == 0) 
		tp = newtlbpid(p); 
1991/0705    
 
1993/0501    
	putcontext(p->pidonmach[m->machno]); 
1994/0406    
	putcontext(tp); 
1990/0227    
} 
 
1991/0507    
void 
1993/0812/sys/src/9/power/mmu.c:30,631994/0406/sys/src/9/power/mmu.c:33,59
1990/0227    
newtlbpid(Proc *p) 
{ 
1991/0425    
	int i, s; 
1990/0227    
	Proc *sp; 
1991/0425    
	char *h; 
1994/0406    
	Proc **h; 
1991/0426    
 
1991/0425    
	s = m->lastpid; 
	if(s >= NTLBPID) 
		s = 1; 
	i = s; 
1991/0501    
	h = m->pidhere; 
	do{ 
1994/0406    
	i = m->lastpid; 
	h = m->pidproc; 
	for(s = 0; s < NTLBPID; s++) { 
1991/0501    
		i++; 
		if(i >= NTLBPID) 
			i = 1; 
	}while(h[i] && i != s); 
                 
1991/0425    
	if(i == s){ 
1991/0426    
		i++; 
		if(i >= NTLBPID) 
			i = 1; 
1994/0406    
		if(h[i] == 0) 
			break; 
1991/0425    
	} 
1994/0406    
 
1991/0501    
	if(h[i]) 
		purgetlb(i); 
1994/0406    
	if(h[i] != 0) 
		panic("newtlb"); 
1992/1130    
 
1990/0227    
	sp = m->pidproc[i]; 
1991/0501    
	if(sp && sp->pidonmach[m->machno] == i) 
		sp->pidonmach[m->machno] = 0; 
1991/0430    
	m->pidproc[i] = p; 
	p->pidonmach[m->machno] = i; 
1991/0501    
	m->lastpid = i; 
1994/0406    
 
1990/0227    
	return i; 
} 
 
1993/0812/sys/src/9/power/mmu.c:73,791994/0406/sys/src/9/power/mmu.c:69,75
1993/0812    
	if(*ctl == PG_TXTFLUSH) { 
1991/0705    
		dcflush((void*)pg->pa, BY2PG); 
		icflush((void*)pg->pa, BY2PG); 
1993/0806    
		*ctl &= ~PG_TXTFLUSH; 
1994/0406    
		*ctl = PG_NOFLUSH; 
1991/0705    
	} 
 
1993/0501    
	tp = up->pidonmach[m->machno]; 
1993/0812/sys/src/9/power/mmu.c:83,1361994/0406/sys/src/9/power/mmu.c:79,128
1990/0227    
	tlbvirt |= PTEPID(tp); 
1991/0425    
	putstlb(tlbvirt, tlbphys); 
1990/0227    
	puttlb(tlbvirt, tlbphys); 
	m->pidhere[tp] = 1; 
	spllo(); 
} 
 
void 
purgetlb(int pid) 
1994/0406    
purgetlb(int tlbpid) 
1990/0227    
{ 
1991/0425    
	Softtlb *entry, *etab; 
1991/0501    
	char *pidhere; 
1994/0406    
	int i, mno; 
1991/0430    
	Proc *sp, **pidproc; 
	int i, rpid, mno; 
1991/0501    
	char dead[NTLBPID]; 
1994/0406    
	Softtlb *entry, *etab; 
1990/0227    
 
1991/0425    
	m->tlbpurge++; 
1994/0406    
 
1991/0501    
	/* 
	 * find all pid entries that are no longer used by processes 
	 */ 
	mno = m->machno; 
	pidproc = m->pidproc; 
	memset(dead, 0, sizeof dead); 
	for(i=1; i<NTLBPID; i++){ 
1994/0406    
	for(i=1; i<NTLBPID; i++) { 
1991/0501    
		sp = pidproc[i]; 
		if(!sp || sp->pidonmach[mno] != i){ 
1994/0406    
		if(sp && sp->pidonmach[mno] != i) 
1991/0501    
			pidproc[i] = 0; 
			dead[i] = 1; 
		} 
	} 
	dead[pid] = 1; 
1994/0406    
 
1991/0501    
	/* 
	 * clean out all dead pids from the stlb; 
1992/1130    
	 * garbage collect pids with no entries 
1994/0406    
	 * shoot down the one we want 
1991/0501    
	 */ 
1991/0426    
	memset(m->pidhere, 0, sizeof m->pidhere); 
1991/0501    
	pidhere = m->pidhere; 
1994/0406    
	sp = pidproc[tlbpid]; 
	if(sp != 0) 
		sp->pidonmach[mno] = 0; 
	pidproc[tlbpid] = 0; 
 
	/* 
	 * clean out all dead tlbpids from the stlb; 
	 */ 
1991/0425    
	entry = m->stb; 
	etab = &entry[STLBSIZE]; 
	for(; entry < etab; entry++){ 
		rpid = TLBPID(entry->virt); 
1991/0501    
		if(dead[rpid]) 
1994/0406    
	for(etab = &entry[STLBSIZE]; entry < etab; entry++) 
		if(pidproc[TLBPID(entry->virt)] == 0) 
1991/0425    
			entry->virt = 0; 
1991/0501    
		else 
			pidhere[rpid] = 1; 
1990/0227    
	} 
1994/0406    
 
1991/0501    
	/* 
	 * clean up the hardware 
	 */ 
1991/0430    
	for(i=TLBROFF; i<NTLB; i++) 
1991/0501    
		if(!pidhere[TLBPID(gettlbvirt(i))]) 
1994/0406    
		if(pidproc[TLBPID(gettlbvirt(i))] == 0) 
1991/0430    
			puttlbx(i, KZERO | PTEPID(i), 0); 
1990/0227    
} 
 


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