tlb-pteaex.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * arch/sh/mm/tlb-pteaex.c
  3. *
  4. * TLB operations for SH-X3 CPUs featuring PTE ASID Extensions.
  5. *
  6. * Copyright (C) 2009 Paul Mundt
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/mm.h>
  14. #include <linux/io.h>
  15. #include <asm/system.h>
  16. #include <asm/mmu_context.h>
  17. #include <asm/cacheflush.h>
  18. void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte)
  19. {
  20. unsigned long flags, pteval, vpn;
  21. /*
  22. * Handle debugger faulting in for debugee.
  23. */
  24. if (vma && current->active_mm != vma->vm_mm)
  25. return;
  26. local_irq_save(flags);
  27. /* Set PTEH register */
  28. vpn = address & MMU_VPN_MASK;
  29. __raw_writel(vpn, MMU_PTEH);
  30. /* Set PTEAEX */
  31. __raw_writel(get_asid(), MMU_PTEAEX);
  32. pteval = pte.pte_low;
  33. /* Set PTEA register */
  34. #ifdef CONFIG_X2TLB
  35. /*
  36. * For the extended mode TLB this is trivial, only the ESZ and
  37. * EPR bits need to be written out to PTEA, with the remainder of
  38. * the protection bits (with the exception of the compat-mode SZ
  39. * and PR bits, which are cleared) being written out in PTEL.
  40. */
  41. __raw_writel(pte.pte_high, MMU_PTEA);
  42. #endif
  43. /* Set PTEL register */
  44. pteval &= _PAGE_FLAGS_HARDWARE_MASK; /* drop software flags */
  45. #ifdef CONFIG_CACHE_WRITETHROUGH
  46. pteval |= _PAGE_WT;
  47. #endif
  48. /* conveniently, we want all the software flags to be 0 anyway */
  49. __raw_writel(pteval, MMU_PTEL);
  50. /* Load the TLB */
  51. asm volatile("ldtlb": /* no output */ : /* no input */ : "memory");
  52. local_irq_restore(flags);
  53. }
  54. /*
  55. * While SH-X2 extended TLB mode splits out the memory-mapped I/UTLB
  56. * data arrays, SH-X3 cores with PTEAEX split out the memory-mapped
  57. * address arrays. In compat mode the second array is inaccessible, while
  58. * in extended mode, the legacy 8-bit ASID field in address array 1 has
  59. * undefined behaviour.
  60. */
  61. void local_flush_tlb_one(unsigned long asid, unsigned long page)
  62. {
  63. jump_to_uncached();
  64. __raw_writel(page, MMU_UTLB_ADDRESS_ARRAY | MMU_PAGE_ASSOC_BIT);
  65. __raw_writel(asid, MMU_UTLB_ADDRESS_ARRAY2 | MMU_PAGE_ASSOC_BIT);
  66. __raw_writel(page, MMU_ITLB_ADDRESS_ARRAY | MMU_PAGE_ASSOC_BIT);
  67. __raw_writel(asid, MMU_ITLB_ADDRESS_ARRAY2 | MMU_PAGE_ASSOC_BIT);
  68. back_to_cached();
  69. }
  70. void local_flush_tlb_all(void)
  71. {
  72. unsigned long flags, status;
  73. int i;
  74. /*
  75. * Flush all the TLB.
  76. */
  77. local_irq_save(flags);
  78. jump_to_uncached();
  79. status = __raw_readl(MMUCR);
  80. status = ((status & MMUCR_URB) >> MMUCR_URB_SHIFT);
  81. if (status == 0)
  82. status = MMUCR_URB_NENTRIES;
  83. for (i = 0; i < status; i++)
  84. __raw_writel(0x0, MMU_UTLB_ADDRESS_ARRAY | (i << 8));
  85. for (i = 0; i < 4; i++)
  86. __raw_writel(0x0, MMU_ITLB_ADDRESS_ARRAY | (i << 8));
  87. back_to_cached();
  88. ctrl_barrier();
  89. local_irq_restore(flags);
  90. }