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
16
17extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
18extern void destroy_context(struct mm_struct *mm);
19
20extern void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next);
21extern void switch_stab(struct task_struct *tsk, struct mm_struct *mm);
22extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm);
23extern void set_context(unsigned long id, pgd_t *pgd);
24
25#ifdef CONFIG_PPC_BOOK3S_64
26static inline void mmu_context_init(void) { }
27#else
28extern void mmu_context_init(void);
29#endif
30
31
32
33
34
35static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
36 struct task_struct *tsk)
37{
38
39 cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
40
41
42#ifdef CONFIG_PPC32
43 tsk->thread.pgdir = next->pgd;
44#endif
45
46
47#ifdef CONFIG_PPC_BOOK3E_64
48 get_paca()->pgd = next->pgd;
49#endif
50
51 if (prev == next)
52 return;
53
54
55
56
57#ifdef CONFIG_ALTIVEC
58 if (cpu_has_feature(CPU_FTR_ALTIVEC))
59 asm volatile ("dssall");
60#endif
61
62
63
64
65#ifdef CONFIG_PPC_STD_MMU_64
66 if (cpu_has_feature(CPU_FTR_SLB))
67 switch_slb(tsk, next);
68 else
69 switch_stab(tsk, next);
70#else
71
72 switch_mmu_context(prev, next);
73#endif
74
75}
76
77#define deactivate_mm(tsk,mm) do { } while (0)
78
79
80
81
82
83static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
84{
85 unsigned long flags;
86
87 local_irq_save(flags);
88 switch_mm(prev, next, current);
89 local_irq_restore(flags);
90}
91
92
93static inline void enter_lazy_tlb(struct mm_struct *mm,
94 struct task_struct *tsk)
95{
96
97#ifdef CONFIG_PPC_BOOK3E_64
98 get_paca()->pgd = NULL;
99#endif
100}
101
102#endif
103#endif
104