tlb-mn10300.S 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. ###############################################################################
  2. #
  3. # TLB loading functions
  4. #
  5. # Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
  6. # Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  7. # Modified by David Howells (dhowells@redhat.com)
  8. #
  9. # This program is free software; you can redistribute it and/or
  10. # modify it under the terms of the GNU General Public Licence
  11. # as published by the Free Software Foundation; either version
  12. # 2 of the Licence, or (at your option) any later version.
  13. #
  14. ###############################################################################
  15. #include <linux/sys.h>
  16. #include <linux/linkage.h>
  17. #include <asm/smp.h>
  18. #include <asm/intctl-regs.h>
  19. #include <asm/frame.inc>
  20. #include <asm/page.h>
  21. #include <asm/pgtable.h>
  22. ###############################################################################
  23. #
  24. # Instruction TLB Miss handler entry point
  25. #
  26. ###############################################################################
  27. .type itlb_miss,@function
  28. ENTRY(itlb_miss)
  29. #ifdef CONFIG_GDBSTUB
  30. movm [d2,d3,a2],(sp)
  31. #else
  32. or EPSW_nAR,epsw # switch D0-D3 & A0-A3 to the alternate
  33. # register bank
  34. nop
  35. nop
  36. nop
  37. #endif
  38. #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
  39. mov (MMUCTR),d2
  40. mov d2,(MMUCTR)
  41. #endif
  42. and ~EPSW_NMID,epsw
  43. mov (IPTEU),d3
  44. mov (PTBR),a2
  45. mov d3,d2
  46. and 0xffc00000,d2
  47. lsr 20,d2
  48. mov (a2,d2),a2 # PTD *ptd = PGD[addr 31..22]
  49. btst _PAGE_VALID,a2
  50. beq itlb_miss_fault # jump if doesn't point anywhere
  51. and ~(PAGE_SIZE-1),a2
  52. mov d3,d2
  53. and 0x003ff000,d2
  54. lsr 10,d2
  55. add d2,a2
  56. mov (a2),d2 # get pte from PTD[addr 21..12]
  57. btst _PAGE_VALID,d2
  58. beq itlb_miss_fault # jump if doesn't point to a page
  59. # (might be a swap id)
  60. bset _PAGE_ACCESSED,(0,a2)
  61. and ~(xPTEL_UNUSED1|xPTEL_UNUSED2),d2
  62. itlb_miss_set:
  63. mov d2,(IPTEL) # change the TLB
  64. #ifdef CONFIG_GDBSTUB
  65. movm (sp),[d2,d3,a2]
  66. #endif
  67. rti
  68. itlb_miss_fault:
  69. mov _PAGE_VALID,d2 # force address error handler to be
  70. # invoked
  71. bra itlb_miss_set
  72. .size itlb_miss, . - itlb_miss
  73. ###############################################################################
  74. #
  75. # Data TLB Miss handler entry point
  76. #
  77. ###############################################################################
  78. .type dtlb_miss,@function
  79. ENTRY(dtlb_miss)
  80. #ifdef CONFIG_GDBSTUB
  81. movm [d2,d3,a2],(sp)
  82. #else
  83. or EPSW_nAR,epsw # switch D0-D3 & A0-A3 to the alternate
  84. # register bank
  85. nop
  86. nop
  87. nop
  88. #endif
  89. #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
  90. mov (MMUCTR),d2
  91. mov d2,(MMUCTR)
  92. #endif
  93. and ~EPSW_NMID,epsw
  94. mov (DPTEU),d3
  95. mov (PTBR),a2
  96. mov d3,d2
  97. and 0xffc00000,d2
  98. lsr 20,d2
  99. mov (a2,d2),a2 # PTD *ptd = PGD[addr 31..22]
  100. btst _PAGE_VALID,a2
  101. beq dtlb_miss_fault # jump if doesn't point anywhere
  102. and ~(PAGE_SIZE-1),a2
  103. mov d3,d2
  104. and 0x003ff000,d2
  105. lsr 10,d2
  106. add d2,a2
  107. mov (a2),d2 # get pte from PTD[addr 21..12]
  108. btst _PAGE_VALID,d2
  109. beq dtlb_miss_fault # jump if doesn't point to a page
  110. # (might be a swap id)
  111. bset _PAGE_ACCESSED,(0,a2)
  112. and ~(xPTEL_UNUSED1|xPTEL_UNUSED2),d2
  113. dtlb_miss_set:
  114. mov d2,(DPTEL) # change the TLB
  115. #ifdef CONFIG_GDBSTUB
  116. movm (sp),[d2,d3,a2]
  117. #endif
  118. rti
  119. dtlb_miss_fault:
  120. mov _PAGE_VALID,d2 # force address error handler to be
  121. # invoked
  122. bra dtlb_miss_set
  123. .size dtlb_miss, . - dtlb_miss
  124. ###############################################################################
  125. #
  126. # Instruction TLB Address Error handler entry point
  127. #
  128. ###############################################################################
  129. .type itlb_aerror,@function
  130. ENTRY(itlb_aerror)
  131. add -4,sp
  132. SAVE_ALL
  133. #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
  134. mov (MMUCTR),d1
  135. mov d1,(MMUCTR)
  136. #endif
  137. and ~EPSW_NMID,epsw
  138. add -4,sp # need to pass three params
  139. # calculate the fault code
  140. movhu (MMUFCR_IFC),d1
  141. or 0x00010000,d1 # it's an instruction fetch
  142. # determine the page address
  143. mov (IPTEU),a2
  144. mov a2,d0
  145. and PAGE_MASK,d0
  146. mov d0,(12,sp)
  147. clr d0
  148. mov d0,(IPTEL)
  149. or EPSW_IE,epsw
  150. mov fp,d0
  151. call do_page_fault[],0 # do_page_fault(regs,code,addr
  152. jmp ret_from_exception
  153. .size itlb_aerror, . - itlb_aerror
  154. ###############################################################################
  155. #
  156. # Data TLB Address Error handler entry point
  157. #
  158. ###############################################################################
  159. .type dtlb_aerror,@function
  160. ENTRY(dtlb_aerror)
  161. add -4,sp
  162. SAVE_ALL
  163. #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
  164. mov (MMUCTR),d1
  165. mov d1,(MMUCTR)
  166. #endif
  167. add -4,sp # need to pass three params
  168. and ~EPSW_NMID,epsw
  169. # calculate the fault code
  170. movhu (MMUFCR_DFC),d1
  171. # determine the page address
  172. mov (DPTEU),a2
  173. mov a2,d0
  174. and PAGE_MASK,d0
  175. mov d0,(12,sp)
  176. clr d0
  177. mov d0,(DPTEL)
  178. or EPSW_IE,epsw
  179. mov fp,d0
  180. call do_page_fault[],0 # do_page_fault(regs,code,addr
  181. jmp ret_from_exception
  182. .size dtlb_aerror, . - dtlb_aerror