tlb-mn10300.S 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. #if ((_PAGE_ACCESSED & 0xffffff00) == 0)
  61. bset _PAGE_ACCESSED,(0,a2)
  62. #elif ((_PAGE_ACCESSED & 0xffff00ff) == 0)
  63. bset +(_PAGE_ACCESSED >> 8),(1,a2)
  64. #else
  65. #error "_PAGE_ACCESSED value is out of range"
  66. #endif
  67. and ~xPTEL2_UNUSED1,d2
  68. itlb_miss_set:
  69. mov d2,(IPTEL2) # change the TLB
  70. #ifdef CONFIG_GDBSTUB
  71. movm (sp),[d2,d3,a2]
  72. #endif
  73. rti
  74. itlb_miss_fault:
  75. mov _PAGE_VALID,d2 # force address error handler to be
  76. # invoked
  77. bra itlb_miss_set
  78. .size itlb_miss, . - itlb_miss
  79. ###############################################################################
  80. #
  81. # Data TLB Miss handler entry point
  82. #
  83. ###############################################################################
  84. .type dtlb_miss,@function
  85. ENTRY(dtlb_miss)
  86. #ifdef CONFIG_GDBSTUB
  87. movm [d2,d3,a2],(sp)
  88. #else
  89. or EPSW_nAR,epsw # switch D0-D3 & A0-A3 to the alternate
  90. # register bank
  91. nop
  92. nop
  93. nop
  94. #endif
  95. #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
  96. mov (MMUCTR),d2
  97. mov d2,(MMUCTR)
  98. #endif
  99. and ~EPSW_NMID,epsw
  100. mov (DPTEU),d3
  101. mov (PTBR),a2
  102. mov d3,d2
  103. and 0xffc00000,d2
  104. lsr 20,d2
  105. mov (a2,d2),a2 # PTD *ptd = PGD[addr 31..22]
  106. btst _PAGE_VALID,a2
  107. beq dtlb_miss_fault # jump if doesn't point anywhere
  108. and ~(PAGE_SIZE-1),a2
  109. mov d3,d2
  110. and 0x003ff000,d2
  111. lsr 10,d2
  112. add d2,a2
  113. mov (a2),d2 # get pte from PTD[addr 21..12]
  114. btst _PAGE_VALID,d2
  115. beq dtlb_miss_fault # jump if doesn't point to a page
  116. # (might be a swap id)
  117. #if ((_PAGE_ACCESSED & 0xffffff00) == 0)
  118. bset _PAGE_ACCESSED,(0,a2)
  119. #elif ((_PAGE_ACCESSED & 0xffff00ff) == 0)
  120. bset +(_PAGE_ACCESSED >> 8),(1,a2)
  121. #else
  122. #error "_PAGE_ACCESSED value is out of range"
  123. #endif
  124. and ~xPTEL2_UNUSED1,d2
  125. dtlb_miss_set:
  126. mov d2,(DPTEL2) # change the TLB
  127. #ifdef CONFIG_GDBSTUB
  128. movm (sp),[d2,d3,a2]
  129. #endif
  130. rti
  131. dtlb_miss_fault:
  132. mov _PAGE_VALID,d2 # force address error handler to be
  133. # invoked
  134. bra dtlb_miss_set
  135. .size dtlb_miss, . - dtlb_miss
  136. ###############################################################################
  137. #
  138. # Instruction TLB Address Error handler entry point
  139. #
  140. ###############################################################################
  141. .type itlb_aerror,@function
  142. ENTRY(itlb_aerror)
  143. add -4,sp
  144. SAVE_ALL
  145. #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
  146. mov (MMUCTR),d1
  147. mov d1,(MMUCTR)
  148. #endif
  149. and ~EPSW_NMID,epsw
  150. add -4,sp # need to pass three params
  151. # calculate the fault code
  152. movhu (MMUFCR_IFC),d1
  153. or 0x00010000,d1 # it's an instruction fetch
  154. # determine the page address
  155. mov (IPTEU),d0
  156. and PAGE_MASK,d0
  157. mov d0,(12,sp)
  158. clr d0
  159. mov d0,(IPTEL2)
  160. or EPSW_IE,epsw
  161. mov fp,d0
  162. call do_page_fault[],0 # do_page_fault(regs,code,addr
  163. jmp ret_from_exception
  164. .size itlb_aerror, . - itlb_aerror
  165. ###############################################################################
  166. #
  167. # Data TLB Address Error handler entry point
  168. #
  169. ###############################################################################
  170. .type dtlb_aerror,@function
  171. ENTRY(dtlb_aerror)
  172. add -4,sp
  173. SAVE_ALL
  174. #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
  175. mov (MMUCTR),d1
  176. mov d1,(MMUCTR)
  177. #endif
  178. add -4,sp # need to pass three params
  179. and ~EPSW_NMID,epsw
  180. # calculate the fault code
  181. movhu (MMUFCR_DFC),d1
  182. # determine the page address
  183. mov (DPTEU),a2
  184. mov a2,d0
  185. and PAGE_MASK,d0
  186. mov d0,(12,sp)
  187. clr d0
  188. mov d0,(DPTEL2)
  189. or EPSW_IE,epsw
  190. mov fp,d0
  191. call do_page_fault[],0 # do_page_fault(regs,code,addr
  192. jmp ret_from_exception
  193. .size dtlb_aerror, . - dtlb_aerror