9p: Optimize TCREATE by eliminating a redundant fid clone.
[pandora-kernel.git] / arch / powerpc / include / asm / mmu_context.h
1 #ifndef __ASM_POWERPC_MMU_CONTEXT_H
2 #define __ASM_POWERPC_MMU_CONTEXT_H
3 #ifdef __KERNEL__
4
5 #include <linux/kernel.h>
6 #include <linux/mm.h>
7 #include <linux/sched.h>
8 #include <linux/spinlock.h>
9 #include <asm/mmu.h>    
10 #include <asm/cputable.h>
11 #include <asm-generic/mm_hooks.h>
12 #include <asm/cputhreads.h>
13
14 /*
15  * Most if the context management is out of line
16  */
17 extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
18 extern void destroy_context(struct mm_struct *mm);
19
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);
24
25 #ifdef CONFIG_PPC_BOOK3S_64
26 extern int __init_new_context(void);
27 extern void __destroy_context(int context_id);
28 static inline void mmu_context_init(void) { }
29 #else
30 extern void mmu_context_init(void);
31 #endif
32
33 /*
34  * switch_mm is the entry point called from the architecture independent
35  * code in kernel/sched.c
36  */
37 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
38                              struct task_struct *tsk)
39 {
40         /* Mark this context has been used on the new CPU */
41         cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
42
43         /* 32-bit keeps track of the current PGDIR in the thread struct */
44 #ifdef CONFIG_PPC32
45         tsk->thread.pgdir = next->pgd;
46 #endif /* CONFIG_PPC32 */
47
48         /* 64-bit Book3E keeps track of current PGD in the PACA */
49 #ifdef CONFIG_PPC_BOOK3E_64
50         get_paca()->pgd = next->pgd;
51 #endif
52         /* Nothing else to do if we aren't actually switching */
53         if (prev == next)
54                 return;
55
56         /* We must stop all altivec streams before changing the HW
57          * context
58          */
59 #ifdef CONFIG_ALTIVEC
60         if (cpu_has_feature(CPU_FTR_ALTIVEC))
61                 asm volatile ("dssall");
62 #endif /* CONFIG_ALTIVEC */
63
64         /* The actual HW switching method differs between the various
65          * sub architectures.
66          */
67 #ifdef CONFIG_PPC_STD_MMU_64
68         if (cpu_has_feature(CPU_FTR_SLB))
69                 switch_slb(tsk, next);
70         else
71                 switch_stab(tsk, next);
72 #else
73         /* Out of line for now */
74         switch_mmu_context(prev, next);
75 #endif
76
77 }
78
79 #define deactivate_mm(tsk,mm)   do { } while (0)
80
81 /*
82  * After we have set current->mm to a new value, this activates
83  * the context for the new mm so we see the new mappings.
84  */
85 static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
86 {
87         unsigned long flags;
88
89         local_irq_save(flags);
90         switch_mm(prev, next, current);
91         local_irq_restore(flags);
92 }
93
94 /* We don't currently use enter_lazy_tlb() for anything */
95 static inline void enter_lazy_tlb(struct mm_struct *mm,
96                                   struct task_struct *tsk)
97 {
98         /* 64-bit Book3E keeps track of current PGD in the PACA */
99 #ifdef CONFIG_PPC_BOOK3E_64
100         get_paca()->pgd = NULL;
101 #endif
102 }
103
104 #endif /* __KERNEL__ */
105 #endif /* __ASM_POWERPC_MMU_CONTEXT_H */