1 #ifndef __ASM_POWERPC_MMU_CONTEXT_H
2 #define __ASM_POWERPC_MMU_CONTEXT_H
5 #include <linux/kernel.h>
7 #include <linux/sched.h>
8 #include <linux/spinlock.h>
10 #include <asm/cputable.h>
11 #include <asm-generic/mm_hooks.h>
12 #include <asm/cputhreads.h>
15 * Most if the context management is out of line
17 extern int init_new_context(struct task_struct
*tsk
, struct mm_struct
*mm
);
18 extern void destroy_context(struct mm_struct
*mm
);
20 extern void switch_mmu_context(struct mm_struct
*prev
, struct mm_struct
*next
);
21 extern void switch_stab(struct task_struct
*tsk
, struct mm_struct
*mm
);
22 extern void switch_slb(struct task_struct
*tsk
, struct mm_struct
*mm
);
23 extern void set_context(unsigned long id
, pgd_t
*pgd
);
25 #ifdef CONFIG_PPC_BOOK3S_64
26 static inline void mmu_context_init(void) { }
28 extern void mmu_context_init(void);
32 * switch_mm is the entry point called from the architecture independent
33 * code in kernel/sched.c
35 static inline void switch_mm(struct mm_struct
*prev
, struct mm_struct
*next
,
36 struct task_struct
*tsk
)
38 /* Mark this context has been used on the new CPU */
39 cpumask_set_cpu(smp_processor_id(), mm_cpumask(next
));
41 /* 32-bit keeps track of the current PGDIR in the thread struct */
43 tsk
->thread
.pgdir
= next
->pgd
;
44 #endif /* CONFIG_PPC32 */
46 /* 64-bit Book3E keeps track of current PGD in the PACA */
47 #ifdef CONFIG_PPC_BOOK3E_64
48 get_paca()->pgd
= next
->pgd
;
50 /* Nothing else to do if we aren't actually switching */
54 /* We must stop all altivec streams before changing the HW
58 if (cpu_has_feature(CPU_FTR_ALTIVEC
))
59 asm volatile ("dssall");
60 #endif /* CONFIG_ALTIVEC */
62 /* The actual HW switching method differs between the various
65 #ifdef CONFIG_PPC_STD_MMU_64
66 if (cpu_has_feature(CPU_FTR_SLB
))
67 switch_slb(tsk
, next
);
69 switch_stab(tsk
, next
);
71 /* Out of line for now */
72 switch_mmu_context(prev
, next
);
77 #define deactivate_mm(tsk,mm) do { } while (0)
80 * After we have set current->mm to a new value, this activates
81 * the context for the new mm so we see the new mappings.
83 static inline void activate_mm(struct mm_struct
*prev
, struct mm_struct
*next
)
87 local_irq_save(flags
);
88 switch_mm(prev
, next
, current
);
89 local_irq_restore(flags
);
92 /* We don't currently use enter_lazy_tlb() for anything */
93 static inline void enter_lazy_tlb(struct mm_struct
*mm
,
94 struct task_struct
*tsk
)
96 /* 64-bit Book3E keeps track of current PGD in the PACA */
97 #ifdef CONFIG_PPC_BOOK3E_64
98 get_paca()->pgd
= NULL
;
102 #endif /* __KERNEL__ */
103 #endif /* __ASM_POWERPC_MMU_CONTEXT_H */