Commit | Line | Data |
---|---|---|
047ea784 PM |
1 | #ifndef __ASM_POWERPC_MMU_CONTEXT_H |
2 | #define __ASM_POWERPC_MMU_CONTEXT_H | |
88ced031 | 3 | #ifdef __KERNEL__ |
047ea784 | 4 | |
5e696617 BH |
5 | #include <linux/kernel.h> |
6 | #include <linux/mm.h> | |
7 | #include <linux/sched.h> | |
8 | #include <linux/spinlock.h> | |
80a7cc6c KG |
9 | #include <asm/mmu.h> |
10 | #include <asm/cputable.h> | |
11 | #include <asm-generic/mm_hooks.h> | |
5e696617 | 12 | #include <asm/cputhreads.h> |
80a7cc6c KG |
13 | |
14 | /* | |
5e696617 | 15 | * Most if the context management is out of line |
80a7cc6c | 16 | */ |
1da177e4 LT |
17 | extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm); |
18 | extern void destroy_context(struct mm_struct *mm); | |
19 | ||
5e696617 | 20 | extern void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next); |
1da177e4 LT |
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); | |
5e696617 | 23 | extern void set_context(unsigned long id, pgd_t *pgd); |
1da177e4 | 24 | |
6f0ef0f5 | 25 | #ifdef CONFIG_PPC_BOOK3S_64 |
e85a4710 AG |
26 | extern int __init_new_context(void); |
27 | extern void __destroy_context(int context_id); | |
6f0ef0f5 BH |
28 | static inline void mmu_context_init(void) { } |
29 | #else | |
c83ec269 AG |
30 | extern unsigned long __init_new_context(void); |
31 | extern void __destroy_context(unsigned long context_id); | |
6f0ef0f5 BH |
32 | extern void mmu_context_init(void); |
33 | #endif | |
34 | ||
851d2e2f THFL |
35 | extern void switch_cop(struct mm_struct *next); |
36 | extern int use_cop(unsigned long acop, struct mm_struct *mm); | |
37 | extern void drop_cop(unsigned long acop, struct mm_struct *mm); | |
38 | ||
1da177e4 LT |
39 | /* |
40 | * switch_mm is the entry point called from the architecture independent | |
41 | * code in kernel/sched.c | |
42 | */ | |
43 | static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, | |
44 | struct task_struct *tsk) | |
45 | { | |
5e696617 | 46 | /* Mark this context has been used on the new CPU */ |
56aa4129 | 47 | cpumask_set_cpu(smp_processor_id(), mm_cpumask(next)); |
5e696617 BH |
48 | |
49 | /* 32-bit keeps track of the current PGDIR in the thread struct */ | |
50 | #ifdef CONFIG_PPC32 | |
51 | tsk->thread.pgdir = next->pgd; | |
52 | #endif /* CONFIG_PPC32 */ | |
1da177e4 | 53 | |
25d21ad6 BH |
54 | /* 64-bit Book3E keeps track of current PGD in the PACA */ |
55 | #ifdef CONFIG_PPC_BOOK3E_64 | |
56 | get_paca()->pgd = next->pgd; | |
57 | #endif | |
5e696617 | 58 | /* Nothing else to do if we aren't actually switching */ |
1da177e4 LT |
59 | if (prev == next) |
60 | return; | |
61 | ||
851d2e2f THFL |
62 | #ifdef CONFIG_PPC_ICSWX |
63 | /* Switch coprocessor context only if prev or next uses a coprocessor */ | |
64 | if (prev->context.acop || next->context.acop) | |
65 | switch_cop(next); | |
66 | #endif /* CONFIG_PPC_ICSWX */ | |
67 | ||
5e696617 BH |
68 | /* We must stop all altivec streams before changing the HW |
69 | * context | |
70 | */ | |
1da177e4 LT |
71 | #ifdef CONFIG_ALTIVEC |
72 | if (cpu_has_feature(CPU_FTR_ALTIVEC)) | |
73 | asm volatile ("dssall"); | |
74 | #endif /* CONFIG_ALTIVEC */ | |
75 | ||
5e696617 BH |
76 | /* The actual HW switching method differs between the various |
77 | * sub architectures. | |
78 | */ | |
79 | #ifdef CONFIG_PPC_STD_MMU_64 | |
44ae3ab3 | 80 | if (mmu_has_feature(MMU_FTR_SLB)) |
1da177e4 LT |
81 | switch_slb(tsk, next); |
82 | else | |
83 | switch_stab(tsk, next); | |
5e696617 BH |
84 | #else |
85 | /* Out of line for now */ | |
86 | switch_mmu_context(prev, next); | |
87 | #endif | |
88 | ||
1da177e4 LT |
89 | } |
90 | ||
91 | #define deactivate_mm(tsk,mm) do { } while (0) | |
92 | ||
93 | /* | |
94 | * After we have set current->mm to a new value, this activates | |
95 | * the context for the new mm so we see the new mappings. | |
96 | */ | |
97 | static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next) | |
98 | { | |
99 | unsigned long flags; | |
100 | ||
101 | local_irq_save(flags); | |
102 | switch_mm(prev, next, current); | |
103 | local_irq_restore(flags); | |
104 | } | |
105 | ||
5e696617 BH |
106 | /* We don't currently use enter_lazy_tlb() for anything */ |
107 | static inline void enter_lazy_tlb(struct mm_struct *mm, | |
108 | struct task_struct *tsk) | |
109 | { | |
25d21ad6 BH |
110 | /* 64-bit Book3E keeps track of current PGD in the PACA */ |
111 | #ifdef CONFIG_PPC_BOOK3E_64 | |
112 | get_paca()->pgd = NULL; | |
113 | #endif | |
5e696617 BH |
114 | } |
115 | ||
88ced031 | 116 | #endif /* __KERNEL__ */ |
047ea784 | 117 | #endif /* __ASM_POWERPC_MMU_CONTEXT_H */ |