tlb_nohash_low.S 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * This file contains low-level functions for performing various
  3. * types of TLB invalidations on various processors with no hash
  4. * table.
  5. *
  6. * This file implements the following functions for all no-hash
  7. * processors. Some aren't implemented for some variants. Some
  8. * are inline in tlbflush.h
  9. *
  10. * - tlbil_va
  11. * - tlbil_pid
  12. * - tlbil_all
  13. * - tlbivax_bcast (not yet)
  14. *
  15. * Code mostly moved over from misc_32.S
  16. *
  17. * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  18. *
  19. * Partially rewritten by Cort Dougan (cort@cs.nmt.edu)
  20. * Paul Mackerras, Kumar Gala and Benjamin Herrenschmidt.
  21. *
  22. * This program is free software; you can redistribute it and/or
  23. * modify it under the terms of the GNU General Public License
  24. * as published by the Free Software Foundation; either version
  25. * 2 of the License, or (at your option) any later version.
  26. *
  27. */
  28. #include <asm/reg.h>
  29. #include <asm/page.h>
  30. #include <asm/cputable.h>
  31. #include <asm/mmu.h>
  32. #include <asm/ppc_asm.h>
  33. #include <asm/asm-offsets.h>
  34. #include <asm/processor.h>
  35. #if defined(CONFIG_40x)
  36. /*
  37. * 40x implementation needs only tlbil_va
  38. */
  39. _GLOBAL(_tlbil_va)
  40. /* We run the search with interrupts disabled because we have to change
  41. * the PID and I don't want to preempt when that happens.
  42. */
  43. mfmsr r5
  44. mfspr r6,SPRN_PID
  45. wrteei 0
  46. mtspr SPRN_PID,r4
  47. tlbsx. r3, 0, r3
  48. mtspr SPRN_PID,r6
  49. wrtee r5
  50. bne 1f
  51. sync
  52. /* There are only 64 TLB entries, so r3 < 64, which means bit 25 is
  53. * clear. Since 25 is the V bit in the TLB_TAG, loading this value
  54. * will invalidate the TLB entry. */
  55. tlbwe r3, r3, TLB_TAG
  56. isync
  57. 1: blr
  58. #elif defined(CONFIG_8xx)
  59. /*
  60. * Nothing to do for 8xx, everything is inline
  61. */
  62. #elif defined(CONFIG_44x)
  63. /*
  64. * 440 implementation uses tlbsx/we for tlbil_va and a full sweep
  65. * of the TLB for everything else.
  66. */
  67. _GLOBAL(_tlbil_va)
  68. mfspr r5,SPRN_MMUCR
  69. rlwimi r5,r4,0,24,31 /* Set TID */
  70. /* We have to run the search with interrupts disabled, even critical
  71. * and debug interrupts (in fact the only critical exceptions we have
  72. * are debug and machine check). Otherwise an interrupt which causes
  73. * a TLB miss can clobber the MMUCR between the mtspr and the tlbsx. */
  74. mfmsr r4
  75. lis r6,(MSR_EE|MSR_CE|MSR_ME|MSR_DE)@ha
  76. addi r6,r6,(MSR_EE|MSR_CE|MSR_ME|MSR_DE)@l
  77. andc r6,r4,r6
  78. mtmsr r6
  79. mtspr SPRN_MMUCR,r5
  80. tlbsx. r3, 0, r3
  81. mtmsr r4
  82. bne 1f
  83. sync
  84. /* There are only 64 TLB entries, so r3 < 64,
  85. * which means bit 22, is clear. Since 22 is
  86. * the V bit in the TLB_PAGEID, loading this
  87. * value will invalidate the TLB entry.
  88. */
  89. tlbwe r3, r3, PPC44x_TLB_PAGEID
  90. isync
  91. 1: blr
  92. _GLOBAL(_tlbil_all)
  93. _GLOBAL(_tlbil_pid)
  94. li r3,0
  95. sync
  96. /* Load high watermark */
  97. lis r4,tlb_44x_hwater@ha
  98. lwz r5,tlb_44x_hwater@l(r4)
  99. 1: tlbwe r3,r3,PPC44x_TLB_PAGEID
  100. addi r3,r3,1
  101. cmpw 0,r3,r5
  102. ble 1b
  103. isync
  104. blr
  105. #elif defined(CONFIG_FSL_BOOKE)
  106. /*
  107. * FSL BookE implementations. Currently _pid and _all are the
  108. * same. This will change when tlbilx is actually supported and
  109. * performs invalidate-by-PID. This change will be driven by
  110. * mmu_features conditional
  111. */
  112. /*
  113. * Flush MMU TLB on the local processor
  114. */
  115. _GLOBAL(_tlbil_pid)
  116. _GLOBAL(_tlbil_all)
  117. #define MMUCSR0_TLBFI (MMUCSR0_TLB0FI | MMUCSR0_TLB1FI | \
  118. MMUCSR0_TLB2FI | MMUCSR0_TLB3FI)
  119. li r3,(MMUCSR0_TLBFI)@l
  120. mtspr SPRN_MMUCSR0, r3
  121. 1:
  122. mfspr r3,SPRN_MMUCSR0
  123. andi. r3,r3,MMUCSR0_TLBFI@l
  124. bne 1b
  125. msync
  126. isync
  127. blr
  128. /*
  129. * Flush MMU TLB for a particular address, but only on the local processor
  130. * (no broadcast)
  131. */
  132. _GLOBAL(_tlbil_va)
  133. mfmsr r10
  134. wrteei 0
  135. slwi r4,r4,16
  136. mtspr SPRN_MAS6,r4 /* assume AS=0 for now */
  137. tlbsx 0,r3
  138. mfspr r4,SPRN_MAS1 /* check valid */
  139. andis. r3,r4,MAS1_VALID@h
  140. beq 1f
  141. rlwinm r4,r4,0,1,31
  142. mtspr SPRN_MAS1,r4
  143. tlbwe
  144. msync
  145. isync
  146. 1: wrtee r10
  147. blr
  148. #elif
  149. #error Unsupported processor type !
  150. #endif