mmu_context.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef __PPC64_MMU_CONTEXT_H
  2. #define __PPC64_MMU_CONTEXT_H
  3. #include <linux/config.h>
  4. #include <linux/kernel.h>
  5. #include <linux/mm.h>
  6. #include <asm/mmu.h>
  7. #include <asm/cputable.h>
  8. /*
  9. * Copyright (C) 2001 PPC 64 Team, IBM Corp
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * as published by the Free Software Foundation; either version
  14. * 2 of the License, or (at your option) any later version.
  15. */
  16. /*
  17. * Every architecture must define this function. It's the fastest
  18. * way of searching a 140-bit bitmap where the first 100 bits are
  19. * unlikely to be set. It's guaranteed that at least one of the 140
  20. * bits is cleared.
  21. */
  22. static inline int sched_find_first_bit(unsigned long *b)
  23. {
  24. if (unlikely(b[0]))
  25. return __ffs(b[0]);
  26. if (unlikely(b[1]))
  27. return __ffs(b[1]) + 64;
  28. return __ffs(b[2]) + 128;
  29. }
  30. static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
  31. {
  32. }
  33. #define NO_CONTEXT 0
  34. #define MAX_CONTEXT (0x100000-1)
  35. extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
  36. extern void destroy_context(struct mm_struct *mm);
  37. extern void switch_stab(struct task_struct *tsk, struct mm_struct *mm);
  38. extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm);
  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. {
  46. if (!cpu_isset(smp_processor_id(), next->cpu_vm_mask))
  47. cpu_set(smp_processor_id(), next->cpu_vm_mask);
  48. /* No need to flush userspace segments if the mm doesnt change */
  49. if (prev == next)
  50. return;
  51. #ifdef CONFIG_ALTIVEC
  52. if (cpu_has_feature(CPU_FTR_ALTIVEC))
  53. asm volatile ("dssall");
  54. #endif /* CONFIG_ALTIVEC */
  55. if (cpu_has_feature(CPU_FTR_SLB))
  56. switch_slb(tsk, next);
  57. else
  58. switch_stab(tsk, next);
  59. }
  60. #define deactivate_mm(tsk,mm) do { } while (0)
  61. /*
  62. * After we have set current->mm to a new value, this activates
  63. * the context for the new mm so we see the new mappings.
  64. */
  65. static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
  66. {
  67. unsigned long flags;
  68. local_irq_save(flags);
  69. switch_mm(prev, next, current);
  70. local_irq_restore(flags);
  71. }
  72. #endif /* __PPC64_MMU_CONTEXT_H */