mmu_context_64.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef __ASM_SH_MMU_CONTEXT_64_H
  2. #define __ASM_SH_MMU_CONTEXT_64_H
  3. /*
  4. * sh64-specific mmu_context interface.
  5. *
  6. * Copyright (C) 2000, 2001 Paolo Alberelli
  7. * Copyright (C) 2003 - 2007 Paul Mundt
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file "COPYING" in the main directory of this archive
  11. * for more details.
  12. */
  13. #include <cpu/registers.h>
  14. #include <asm/cacheflush.h>
  15. #define SR_ASID_MASK 0xffffffffff00ffffULL
  16. #define SR_ASID_SHIFT 16
  17. /*
  18. * Destroy context related info for an mm_struct that is about
  19. * to be put to rest.
  20. */
  21. static inline void destroy_context(struct mm_struct *mm)
  22. {
  23. /* Well, at least free TLB entries */
  24. flush_tlb_mm(mm);
  25. }
  26. static inline unsigned long get_asid(void)
  27. {
  28. unsigned long long sr;
  29. asm volatile ("getcon " __SR ", %0\n\t"
  30. : "=r" (sr));
  31. sr = (sr >> SR_ASID_SHIFT) & MMU_CONTEXT_ASID_MASK;
  32. return (unsigned long) sr;
  33. }
  34. /* Set ASID into SR */
  35. static inline void set_asid(unsigned long asid)
  36. {
  37. unsigned long long sr, pc;
  38. asm volatile ("getcon " __SR ", %0" : "=r" (sr));
  39. sr = (sr & SR_ASID_MASK) | (asid << SR_ASID_SHIFT);
  40. /*
  41. * It is possible that this function may be inlined and so to avoid
  42. * the assembler reporting duplicate symbols we make use of the
  43. * gas trick of generating symbols using numerics and forward
  44. * reference.
  45. */
  46. asm volatile ("movi 1, %1\n\t"
  47. "shlli %1, 28, %1\n\t"
  48. "or %0, %1, %1\n\t"
  49. "putcon %1, " __SR "\n\t"
  50. "putcon %0, " __SSR "\n\t"
  51. "movi 1f, %1\n\t"
  52. "ori %1, 1 , %1\n\t"
  53. "putcon %1, " __SPC "\n\t"
  54. "rte\n"
  55. "1:\n\t"
  56. : "=r" (sr), "=r" (pc) : "0" (sr));
  57. }
  58. /* arch/sh/kernel/cpu/sh5/entry.S */
  59. extern unsigned long switch_and_save_asid(unsigned long new_asid);
  60. /* No spare register to twiddle, so use a software cache */
  61. extern pgd_t *mmu_pdtp_cache;
  62. #define set_TTB(pgd) (mmu_pdtp_cache = (pgd))
  63. #define get_TTB() (mmu_pdtp_cache)
  64. #endif /* __ASM_SH_MMU_CONTEXT_64_H */