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