mmu_context.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * linux/include/asm-arm/mmu_context.h
  3. *
  4. * Copyright (C) 1996 Russell King.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Changelog:
  11. * 27-06-1996 RMK Created
  12. */
  13. #ifndef __ASM_ARM_MMU_CONTEXT_H
  14. #define __ASM_ARM_MMU_CONTEXT_H
  15. #include <asm/proc-fns.h>
  16. #if __LINUX_ARM_ARCH__ >= 6
  17. /*
  18. * On ARMv6, we have the following structure in the Context ID:
  19. *
  20. * 31 7 0
  21. * +-------------------------+-----------+
  22. * | process ID | ASID |
  23. * +-------------------------+-----------+
  24. * | context ID |
  25. * +-------------------------------------+
  26. *
  27. * The ASID is used to tag entries in the CPU caches and TLBs.
  28. * The context ID is used by debuggers and trace logic, and
  29. * should be unique within all running processes.
  30. */
  31. #define ASID_BITS 8
  32. #define ASID_MASK ((~0) << ASID_BITS)
  33. extern unsigned int cpu_last_asid;
  34. void __init_new_context(struct task_struct *tsk, struct mm_struct *mm);
  35. void __new_context(struct mm_struct *mm);
  36. static inline void check_context(struct mm_struct *mm)
  37. {
  38. if (unlikely((mm->context.id ^ cpu_last_asid) >> ASID_BITS))
  39. __new_context(mm);
  40. }
  41. #define init_new_context(tsk,mm) (__init_new_context(tsk,mm),0)
  42. #else
  43. #define check_context(mm) do { } while (0)
  44. #define init_new_context(tsk,mm) 0
  45. #endif
  46. #define destroy_context(mm) do { } while(0)
  47. /*
  48. * This is called when "tsk" is about to enter lazy TLB mode.
  49. *
  50. * mm: describes the currently active mm context
  51. * tsk: task which is entering lazy tlb
  52. * cpu: cpu number which is entering lazy tlb
  53. *
  54. * tsk->mm will be NULL
  55. */
  56. static inline void
  57. enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
  58. {
  59. }
  60. /*
  61. * This is the actual mm switch as far as the scheduler
  62. * is concerned. No registers are touched. We avoid
  63. * calling the CPU specific function when the mm hasn't
  64. * actually changed.
  65. */
  66. static inline void
  67. switch_mm(struct mm_struct *prev, struct mm_struct *next,
  68. struct task_struct *tsk)
  69. {
  70. unsigned int cpu = smp_processor_id();
  71. if (prev != next) {
  72. cpu_set(cpu, next->cpu_vm_mask);
  73. check_context(next);
  74. cpu_switch_mm(next->pgd, next);
  75. cpu_clear(cpu, prev->cpu_vm_mask);
  76. }
  77. }
  78. #define deactivate_mm(tsk,mm) do { } while (0)
  79. #define activate_mm(prev,next) switch_mm(prev, next, NULL)
  80. #endif