patch-2.3.16 linux/include/asm-ppc/mmu_context.h

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

diff -u --recursive --new-file v2.3.15/linux/include/asm-ppc/mmu_context.h linux/include/asm-ppc/mmu_context.h
@@ -20,15 +20,15 @@
  */
 
 #ifdef CONFIG_8xx
-#define NO_CONTEXT      16
-#define LAST_CONTEXT    15
+#define NO_CONTEXT      	16
+#define LAST_CONTEXT    	15
 #define MUNGE_CONTEXT(n)        (n)
 
 #else
 
 /* PPC 6xx, 7xx CPUs */
-#define NO_CONTEXT      0
-#define LAST_CONTEXT    0xfffff
+#define NO_CONTEXT      	0
+#define LAST_CONTEXT    	0xfffff
 
 /*
  * Allocating context numbers this way tends to spread out
@@ -41,18 +41,25 @@
 extern atomic_t next_mmu_context;
 extern void mmu_context_overflow(void);
 
-#ifndef CONFIG_8xx
+/*
+ * Set the current MMU context.
+ * On 32-bit PowerPCs (other than the 8xx embedded chips), this is done by
+ * loading up the segment registers for the user part of the address space.
+ */
 extern void set_context(int context);
-#else
-#define set_context(context)    do { } while (0)
+
+#ifdef CONFIG_8xx
+extern inline void mmu_context_overflow(void)
+{
+	atomic_set(&next_mmu_context, -1);
+}
 #endif
 
 /*
  * Get a new mmu context for task tsk if necessary.
  */
-#define get_mmu_context(tsk)					\
+#define get_mmu_context(mm)					\
 do { 								\
-	struct mm_struct *mm = (tsk)->mm;			\
 	if (mm->context == NO_CONTEXT) {			\
 		if (atomic_read(&next_mmu_context) == LAST_CONTEXT)		\
 			mmu_context_overflow();			\
@@ -63,21 +70,30 @@
 /*
  * Set up the context for a new address space.
  */
-#define init_new_context(mm)	((mm)->context = NO_CONTEXT)
+#define init_new_context(tsk,mm)	((mm)->context = NO_CONTEXT)
 
 /*
  * We're finished using the context for an address space.
  */
 #define destroy_context(mm)     do { } while (0)
 
+static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
+			     struct task_struct *tsk, int cpu)
+{
+	tsk->thread.pgdir = next->pgd;
+	get_mmu_context(next);
+	set_context(next->context);
+}
+
 /*
  * After we have set current->mm to a new value, this activates
  * the context for the new mm so we see the new mappings.
  */
-extern inline void activate_context(struct task_struct *tsk)
+static inline void activate_mm(struct mm_struct *active_mm, struct mm_struct *mm)
 {
-	get_mmu_context(tsk);
-	set_context(tsk->mm->context);
+	current->thread.pgdir = mm->pgd;
+	get_mmu_context(mm);
+	set_context(mm->context);
 }
 
 /*

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)