tlb-mn10300.S 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. and ~EPSW_NMID,epsw
  30. #ifdef CONFIG_GDBSTUB
  31. movm [d2,d3,a2],(sp)
  32. #else
  33. or EPSW_nAR,epsw # switch D0-D3 & A0-A3 to the alternate
  34. # register bank
  35. nop
  36. nop
  37. nop
  38. #endif
  39. mov (IPTEU),d3
  40. mov (PTBR),a2
  41. mov d3,d2
  42. and 0xffc00000,d2
  43. lsr 20,d2
  44. mov (a2,d2),a2 # PTD *ptd = PGD[addr 31..22]
  45. btst _PAGE_VALID,a2
  46. beq itlb_miss_fault # jump if doesn't point anywhere
  47. and ~(PAGE_SIZE-1),a2
  48. mov d3,d2
  49. and 0x003ff000,d2
  50. lsr 10,d2
  51. add d2,a2
  52. mov (a2),d2 # get pte from PTD[addr 21..12]
  53. btst _PAGE_VALID,d2
  54. beq itlb_miss_fault # jump if doesn't point to a page
  55. # (might be a swap id)
  56. bset _PAGE_ACCESSED,(0,a2)
  57. and ~(xPTEL_UNUSED1|xPTEL_UNUSED2),d2
  58. itlb_miss_set:
  59. mov d2,(IPTEL) # change the TLB
  60. #ifdef CONFIG_GDBSTUB
  61. movm (sp),[d2,d3,a2]
  62. #endif
  63. rti
  64. itlb_miss_fault:
  65. mov _PAGE_VALID,d2 # force address error handler to be
  66. # invoked
  67. bra itlb_miss_set
  68. .size itlb_miss, . - itlb_miss
  69. ###############################################################################
  70. #
  71. # Data TLB Miss handler entry point
  72. #
  73. ###############################################################################
  74. .type dtlb_miss,@function
  75. ENTRY(dtlb_miss)
  76. and ~EPSW_NMID,epsw
  77. #ifdef CONFIG_GDBSTUB
  78. movm [d2,d3,a2],(sp)
  79. #else
  80. or EPSW_nAR,epsw # switch D0-D3 & A0-A3 to the alternate
  81. # register bank
  82. nop
  83. nop
  84. nop
  85. #endif
  86. mov (DPTEU),d3
  87. mov (PTBR),a2
  88. mov d3,d2
  89. and 0xffc00000,d2
  90. lsr 20,d2
  91. mov (a2,d2),a2 # PTD *ptd = PGD[addr 31..22]
  92. btst _PAGE_VALID,a2
  93. beq dtlb_miss_fault # jump if doesn't point anywhere
  94. and ~(PAGE_SIZE-1),a2
  95. mov d3,d2
  96. and 0x003ff000,d2
  97. lsr 10,d2
  98. add d2,a2
  99. mov (a2),d2 # get pte from PTD[addr 21..12]
  100. btst _PAGE_VALID,d2
  101. beq dtlb_miss_fault # jump if doesn't point to a page
  102. # (might be a swap id)
  103. bset _PAGE_ACCESSED,(0,a2)
  104. and ~(xPTEL_UNUSED1|xPTEL_UNUSED2),d2
  105. dtlb_miss_set:
  106. mov d2,(DPTEL) # change the TLB
  107. #ifdef CONFIG_GDBSTUB
  108. movm (sp),[d2,d3,a2]
  109. #endif
  110. rti
  111. dtlb_miss_fault:
  112. mov _PAGE_VALID,d2 # force address error handler to be
  113. # invoked
  114. bra dtlb_miss_set
  115. .size dtlb_miss, . - dtlb_miss
  116. ###############################################################################
  117. #
  118. # Instruction TLB Address Error handler entry point
  119. #
  120. ###############################################################################
  121. .type itlb_aerror,@function
  122. ENTRY(itlb_aerror)
  123. and ~EPSW_NMID,epsw
  124. add -4,sp
  125. SAVE_ALL
  126. add -4,sp # need to pass three params
  127. # calculate the fault code
  128. movhu (MMUFCR_IFC),d1
  129. or 0x00010000,d1 # it's an instruction fetch
  130. # determine the page address
  131. mov (IPTEU),a2
  132. mov a2,d0
  133. and PAGE_MASK,d0
  134. mov d0,(12,sp)
  135. clr d0
  136. mov d0,(IPTEL)
  137. and ~EPSW_NMID,epsw
  138. or EPSW_IE,epsw
  139. mov fp,d0
  140. call do_page_fault[],0 # do_page_fault(regs,code,addr
  141. jmp ret_from_exception
  142. .size itlb_aerror, . - itlb_aerror
  143. ###############################################################################
  144. #
  145. # Data TLB Address Error handler entry point
  146. #
  147. ###############################################################################
  148. .type dtlb_aerror,@function
  149. ENTRY(dtlb_aerror)
  150. and ~EPSW_NMID,epsw
  151. add -4,sp
  152. SAVE_ALL
  153. add -4,sp # need to pass three params
  154. # calculate the fault code
  155. movhu (MMUFCR_DFC),d1
  156. # determine the page address
  157. mov (DPTEU),a2
  158. mov a2,d0
  159. and PAGE_MASK,d0
  160. mov d0,(12,sp)
  161. clr d0
  162. mov d0,(DPTEL)
  163. and ~EPSW_NMID,epsw
  164. or EPSW_IE,epsw
  165. mov fp,d0
  166. call do_page_fault[],0 # do_page_fault(regs,code,addr
  167. jmp ret_from_exception
  168. .size dtlb_aerror, . - dtlb_aerror