mmu_context_32.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_SH_MMU_CONTEXT_32_H
  3. #define __ASM_SH_MMU_CONTEXT_32_H
  4. /*
  5. * Destroy context related info for an mm_struct that is about
  6. * to be put to rest.
  7. */
  8. static inline void destroy_context(struct mm_struct *mm)
  9. {
  10. /* Do nothing */
  11. }
  12. #ifdef CONFIG_CPU_HAS_PTEAEX
  13. static inline void set_asid(unsigned long asid)
  14. {
  15. __raw_writel(asid, MMU_PTEAEX);
  16. }
  17. static inline unsigned long get_asid(void)
  18. {
  19. return __raw_readl(MMU_PTEAEX) & MMU_CONTEXT_ASID_MASK;
  20. }
  21. #else
  22. static inline void set_asid(unsigned long asid)
  23. {
  24. unsigned long __dummy;
  25. __asm__ __volatile__ ("mov.l %2, %0\n\t"
  26. "and %3, %0\n\t"
  27. "or %1, %0\n\t"
  28. "mov.l %0, %2"
  29. : "=&r" (__dummy)
  30. : "r" (asid), "m" (__m(MMU_PTEH)),
  31. "r" (0xffffff00));
  32. }
  33. static inline unsigned long get_asid(void)
  34. {
  35. unsigned long asid;
  36. __asm__ __volatile__ ("mov.l %1, %0"
  37. : "=r" (asid)
  38. : "m" (__m(MMU_PTEH)));
  39. asid &= MMU_CONTEXT_ASID_MASK;
  40. return asid;
  41. }
  42. #endif /* CONFIG_CPU_HAS_PTEAEX */
  43. /* MMU_TTB is used for optimizing the fault handling. */
  44. static inline void set_TTB(pgd_t *pgd)
  45. {
  46. __raw_writel((unsigned long)pgd, MMU_TTB);
  47. }
  48. static inline pgd_t *get_TTB(void)
  49. {
  50. return (pgd_t *)__raw_readl(MMU_TTB);
  51. }
  52. #endif /* __ASM_SH_MMU_CONTEXT_32_H */