patch-2.1.44 linux/include/asm-sparc64/mmu_context.h

Next file: linux/include/asm-sparc64/page.h
Previous file: linux/include/asm-sparc64/ioctls.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.43/linux/include/asm-sparc64/mmu_context.h linux/include/asm-sparc64/mmu_context.h
@@ -1,4 +1,4 @@
-/* $Id: mmu_context.h,v 1.10 1997/05/23 09:35:55 jj Exp $ */
+/* $Id: mmu_context.h,v 1.16 1997/07/05 09:54:46 davem Exp $ */
 #ifndef __SPARC64_MMU_CONTEXT_H
 #define __SPARC64_MMU_CONTEXT_H
 
@@ -24,61 +24,36 @@
 #define CTX_VERSION_MASK	((~0UL) << CTX_VERSION_SHIFT)
 #define CTX_FIRST_VERSION	((1UL << CTX_VERSION_SHIFT) + 1UL)
 
-extern __inline__ void get_new_mmu_context(struct mm_struct *mm,
-					   unsigned long ctx)
-{
-	if((ctx & ~(CTX_VERSION_MASK)) == 0) {
-		unsigned long flags;
-		int entry;
-
-		save_and_cli(flags);
-		__asm__ __volatile__("stxa	%%g0, [%0] %1\n\t"
-				     "stxa	%%g0, [%0] %2"
-				     : /* No outputs */
-				     : "r" (TLB_TAG_ACCESS), "i" (ASI_IMMU),
-				       "i" (ASI_DMMU));
-		for(entry = 0; entry < 62; entry++) {
-			spitfire_put_dtlb_data(entry, 0x0UL);
-			spitfire_put_itlb_data(entry, 0x0UL);
-		}
-		membar("#Sync");
-		flushi(PAGE_OFFSET);
-		restore_flags(flags);
-
-		ctx = (ctx & CTX_VERSION_MASK) + CTX_FIRST_VERSION;
-		if(!ctx)
-			ctx = CTX_FIRST_VERSION;
-	}
-	tlb_context_cache = ctx + 1;
-	mm->context = ctx;
-}
+extern void get_new_mmu_context(struct mm_struct *mm, unsigned long ctx);
 
 extern __inline__ void get_mmu_context(struct task_struct *tsk)
 {
+	register unsigned long paddr asm("o5");
 	struct mm_struct *mm = tsk->mm;
 
-	if(mm						&&
-	   !(tsk->tss.flags & SPARC_FLAG_KTHREAD)	&&
+	flushw_user();
+	if(!(tsk->tss.flags & SPARC_FLAG_KTHREAD)	&&
 	   !(tsk->flags & PF_EXITING)) {
 		unsigned long ctx = tlb_context_cache;
-		register unsigned long paddr asm("o5");
-
-		flushw_user();
 		if((mm->context ^ ctx) & CTX_VERSION_MASK)
 			get_new_mmu_context(mm, ctx);
-		tsk->tss.ctx = (mm->context & 0x1fff);
-		spitfire_set_secondary_context(tsk->tss.current_ds ?
-			mm->context : 0);
-		paddr = __pa(mm->pgd);
-		__asm__ __volatile__("
-			rdpr		%%pstate, %%o4
-			wrpr		%%o4, %1, %%pstate
-			mov		%0, %%g7
-			wrpr		%%o4, 0x0, %%pstate
-		" : /* no outputs */
-		  : "r" (paddr), "i" (PSTATE_MG|PSTATE_IE)
-		  : "o4");
-	}
+
+		/* Don't worry, set_fs() will restore it... */
+		tsk->tss.ctx = (tsk->tss.current_ds ?
+				(mm->context & 0x1fff) : 0);
+	} else
+		tsk->tss.ctx = 0;
+	spitfire_set_secondary_context(tsk->tss.ctx);
+	__asm__ __volatile__("flush %g6");
+	paddr = __pa(mm->pgd);
+	__asm__ __volatile__("
+		rdpr		%%pstate, %%o4
+		wrpr		%%o4, %1, %%pstate
+		mov		%0, %%g7
+		wrpr		%%o4, 0x0, %%pstate
+	" : /* no outputs */
+	  : "r" (paddr), "i" (PSTATE_MG|PSTATE_IE)
+	  : "o4");
 }
 
 #endif /* !(__ASSEMBLY__) */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov