mmu_context.h 2.4 KB

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