mmu_context.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 <linux/compiler.h>
  16. #include <asm/cacheflush.h>
  17. #include <asm/proc-fns.h>
  18. #if __LINUX_ARM_ARCH__ >= 6
  19. /*
  20. * On ARMv6, we have the following structure in the Context ID:
  21. *
  22. * 31 7 0
  23. * +-------------------------+-----------+
  24. * | process ID | ASID |
  25. * +-------------------------+-----------+
  26. * | context ID |
  27. * +-------------------------------------+
  28. *
  29. * The ASID is used to tag entries in the CPU caches and TLBs.
  30. * The context ID is used by debuggers and trace logic, and
  31. * should be unique within all running processes.
  32. */
  33. #define ASID_BITS 8
  34. #define ASID_MASK ((~0) << ASID_BITS)
  35. extern unsigned int cpu_last_asid;
  36. void __init_new_context(struct task_struct *tsk, struct mm_struct *mm);
  37. void __new_context(struct mm_struct *mm);
  38. static inline void check_context(struct mm_struct *mm)
  39. {
  40. if (unlikely((mm->context.id ^ cpu_last_asid) >> ASID_BITS))
  41. __new_context(mm);
  42. }
  43. #define init_new_context(tsk,mm) (__init_new_context(tsk,mm),0)
  44. #else
  45. #define check_context(mm) do { } while (0)
  46. #define init_new_context(tsk,mm) 0
  47. #endif
  48. #define destroy_context(mm) do { } while(0)
  49. /*
  50. * This is called when "tsk" is about to enter lazy TLB mode.
  51. *
  52. * mm: describes the currently active mm context
  53. * tsk: task which is entering lazy tlb
  54. * cpu: cpu number which is entering lazy tlb
  55. *
  56. * tsk->mm will be NULL
  57. */
  58. static inline void
  59. enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
  60. {
  61. }
  62. /*
  63. * This is the actual mm switch as far as the scheduler
  64. * is concerned. No registers are touched. We avoid
  65. * calling the CPU specific function when the mm hasn't
  66. * actually changed.
  67. */
  68. static inline void
  69. switch_mm(struct mm_struct *prev, struct mm_struct *next,
  70. struct task_struct *tsk)
  71. {
  72. unsigned int cpu = smp_processor_id();
  73. if (prev != next) {
  74. cpu_set(cpu, next->cpu_vm_mask);
  75. check_context(next);
  76. cpu_switch_mm(next->pgd, next);
  77. if (cache_is_vivt())
  78. cpu_clear(cpu, prev->cpu_vm_mask);
  79. }
  80. }
  81. #define deactivate_mm(tsk,mm) do { } while (0)
  82. #define activate_mm(prev,next) switch_mm(prev, next, NULL)
  83. #endif