Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Milkymist MMU ITLB test

By: a guest on Jul 21st, 2012  |  syntax: C  |  size: 6.59 KB  |  hits: 3  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void itlb_miss_handler(void)
  2. {
  3.         unsigned int vaddr, paddr;
  4. //      unsigned int vaddr;
  5.         unsigned int EA;
  6.         unsigned int PSW;
  7.  
  8.         asm volatile("mv %0, ea": "=r"(EA) :: );
  9.         asm volatile("rcsr %0, itlbma" : "=r"(vaddr) :: );
  10. // If the following line is commented, then EA == itlb_miss_handler and upon eret we are doomed. If it is un-commented, then EA has a correct value and everything goes fine !
  11. //      asm volatile("rcsr %0, PSW" : "=r"(PSW) :: );
  12.  
  13.         printf("ea == 0x%08X\n", EA);
  14. //      printf("Address 0x%08X caused an ITLB page fault\n", vaddr);
  15. //      printf("PSW == 0x%08X\n", PSW);
  16. //      asm volatile("mv EA, %0" :: "r"(vaddr) : );
  17.  
  18.         paddr = get_mmu_mapping_for(vaddr);
  19.         if (paddr == A_BAD_ADDR)
  20.         {
  21.                 puts("No such mapping !");
  22.                 puts("Unrecoverable ITLB page fault !");
  23.                 panic();
  24.         }
  25.  
  26.         if (!is_itlb_mapping(vaddr))
  27.         {
  28.                 puts("Mapping not in ITLB");
  29.                 panic();
  30.         }
  31.  
  32. //      printf("Refilling ITLB with mapping 0x%08X->0x%08X\n", vaddr, paddr);
  33.         mmu_itlb_map(vaddr, paddr);
  34. }
  35.  
  36.  
  37. With "asm volatile("rcsr %0, PSW" : "=r"(PSW) :: );" un-commented:
  38.  
  39.  
  40. yann@debian:~/dev/milkymist-mmu/tools$ ./flterm --port /dev/ttyUSB0
  41. [FLTERM] Starting...
  42.  
  43. BIOS> itlbtest
  44. stack == 0x47FFFEE8
  45. f() is located at 0x00865a80
  46. Mapping f() into virtual memory at 0x44004000 [physical == 0x44005000]
  47. mapping 0x00860000->0x00860000 in slot 29 [0x446617d8]
  48. mapping 0x00861000->0x00861000 in slot 28 [0x446617cc]
  49. mapping 0x00862000->0x00862000 in slot 27 [0x446617c0]
  50. mapping 0x00863000->0x00863000 in slot 26 [0x446617b4]
  51. mapping 0x00864000->0x00864000 in slot 25 [0x446617a8]
  52. mapping 0x00865000->0x00865000 in slot 24 [0x4466179c]
  53. mapping 0x00866000->0x00866000 in slot 23 [0x44661790]
  54. mapping 0x00867000->0x00867000 in slot 22 [0x44661784]
  55. mapping 0x00868000->0x00868000 in slot 21 [0x44661778]
  56. mapping 0x00869000->0x00869000 in slot 20 [0x4466176c]
  57. mapping 0x0086A000->0x0086A000 in slot 19 [0x44661760]
  58. mapping 0x0086B000->0x0086B000 in slot 18 [0x44661754]
  59. mapping 0x0086C000->0x0086C000 in slot 17 [0x44661748]
  60. mapping 0x0086D000->0x0086D000 in slot 16 [0x4466173c]
  61. mapping 0x0086E000->0x0086E000 in slot 15 [0x44661730]
  62. mapping 0x0086F000->0x0086F000 in slot 14 [0x44661724]
  63. mapping 0x00870000->0x00870000 in slot 13 [0x44661718]
  64. mapping 0x00871000->0x00871000 in slot 12 [0x4466170c]
  65. mapping 0x00872000->0x00872000 in slot 11 [0x44661700]
  66. mapping 0x00873000->0x00873000 in slot 10 [0x446616f4]
  67. mapping 0x00874000->0x00874000 in slot 9 [0x446616e8]
  68. mapping 0x47FFF000->0x47FFF000 in slot 8 [0x446616dc]
  69. Already mapped, updating metadata !
  70. Mapping DONE
  71. Printing MMU mappings :
  72.  
  73.  
  74. [8] 0x47FFF000 -> 0x47FFF000: DTLB
  75. [9] 0x00874000 -> 0x00874000: ITLB  DTLB
  76. [10] 0x00873000 -> 0x00873000: ITLB  DTLB
  77. [11] 0x00872000 -> 0x00872000: ITLB  DTLB
  78. [12] 0x00871000 -> 0x00871000: ITLB  DTLB
  79. [13] 0x00870000 -> 0x00870000: ITLB  DTLB
  80. [14] 0x0086F000 -> 0x0086F000: ITLB  DTLB
  81. [15] 0x0086E000 -> 0x0086E000: ITLB  DTLB
  82. [16] 0x0086D000 -> 0x0086D000: ITLB  DTLB
  83. [17] 0x0086C000 -> 0x0086C000: ITLB  DTLB
  84. [18] 0x0086B000 -> 0x0086B000: ITLB  DTLB
  85. [19] 0x0086A000 -> 0x0086A000: ITLB  DTLB
  86. [20] 0x00869000 -> 0x00869000: ITLB  DTLB
  87. [21] 0x00868000 -> 0x00868000: ITLB  DTLB
  88. [22] 0x00867000 -> 0x00867000: ITLB  DTLB
  89. [23] 0x00866000 -> 0x00866000: ITLB  DTLB
  90. [24] 0x00865000 -> 0x00865000: ITLB  DTLB
  91. [25] 0x00864000 -> 0x00864000: ITLB  DTLB
  92. [26] 0x00863000 -> 0x00863000: ITLB  DTLB
  93. [27] 0x00862000 -> 0x00862000: ITLB  DTLB
  94. [28] 0x00861000 -> 0x00861000: ITLB  DTLB
  95. [29] 0x00860000 -> 0x00860000: ITLB  DTLB
  96. Instruction and Data caches have been invalidated
  97. ea == 0x00865A80
  98. @ea == 0x00866FE8
  99. ea == 0x00866FF8
  100. ea == 0x0086830C
  101. totolol
  102.  
  103.  
  104. test 5 � abcd
  105.  
  106. Call DONE
  107. BIOS>
  108.  
  109. It works nicely.
  110.  
  111. With "asm volatile("rcsr %0, PSW" : "=r"(PSW) :: );" commented:
  112.  
  113.  
  114. BIOS> itlbtest
  115. stack == 0x47FFFEE8
  116. f() is located at 0x00865a7c
  117. Mapping f() into virtual memory at 0x44004000 [physical == 0x44005000]
  118. mapping 0x00860000->0x00860000 in slot 29 [0x446617d8]
  119. mapping 0x00861000->0x00861000 in slot 28 [0x446617cc]
  120. mapping 0x00862000->0x00862000 in slot 27 [0x446617c0]
  121. mapping 0x00863000->0x00863000 in slot 26 [0x446617b4]
  122. mapping 0x00864000->0x00864000 in slot 25 [0x446617a8]
  123. mapping 0x00865000->0x00865000 in slot 24 [0x4466179c]
  124. mapping 0x00866000->0x00866000 in slot 23 [0x44661790]
  125. mapping 0x00867000->0x00867000 in slot 22 [0x44661784]
  126. mapping 0x00868000->0x00868000 in slot 21 [0x44661778]
  127. mapping 0x00869000->0x00869000 in slot 20 [0x4466176c]
  128. mapping 0x0086A000->0x0086A000 in slot 19 [0x44661760]
  129. mapping 0x0086B000->0x0086B000 in slot 18 [0x44661754]
  130. mapping 0x0086C000->0x0086C000 in slot 17 [0x44661748]
  131. mapping 0x0086D000->0x0086D000 in slot 16 [0x4466173c]
  132. mapping 0x0086E000->0x0086E000 in slot 15 [0x44661730]
  133. mapping 0x0086F000->0x0086F000 in slot 14 [0x44661724]
  134. mapping 0x00870000->0x00870000 in slot 13 [0x44661718]
  135. mapping 0x00871000->0x00871000 in slot 12 [0x4466170c]
  136. mapping 0x00872000->0x00872000 in slot 11 [0x44661700]
  137. mapping 0x00873000->0x00873000 in slot 10 [0x446616f4]
  138. mapping 0x00874000->0x00874000 in slot 9 [0x446616e8]
  139. mapping 0x47FFF000->0x47FFF000 in slot 8 [0x446616dc]
  140. Already mapped, updating metadata !
  141. Mapping DONE
  142. Printing MMU mappings :
  143.  
  144.  
  145. [8] 0x47FFF000 -> 0x47FFF000: DTLB
  146. [9] 0x00874000 -> 0x00874000: ITLB  DTLB
  147. [10] 0x00873000 -> 0x00873000: ITLB  DTLB
  148. [11] 0x00872000 -> 0x00872000: ITLB  DTLB
  149. [12] 0x00871000 -> 0x00871000: ITLB  DTLB
  150. [13] 0x00870000 -> 0x00870000: ITLB  DTLB
  151. [14] 0x0086F000 -> 0x0086F000: ITLB  DTLB
  152. [15] 0x0086E000 -> 0x0086E000: ITLB  DTLB
  153. [16] 0x0086D000 -> 0x0086D000: ITLB  DTLB
  154. [17] 0x0086C000 -> 0x0086C000: ITLB  DTLB
  155. [18] 0x0086B000 -> 0x0086B000: ITLB  DTLB
  156. [19] 0x0086A000 -> 0x0086A000: ITLB  DTLB
  157. [20] 0x00869000 -> 0x00869000: ITLB  DTLB
  158. [21] 0x00868000 -> 0x00868000: ITLB  DTLB
  159. [22] 0x00867000 -> 0x00867000: ITLB  DTLB
  160. [23] 0x00866000 -> 0x00866000: ITLB  DTLB
  161. [24] 0x00865000 -> 0x00865000: ITLB  DTLB
  162. [25] 0x00864000 -> 0x00864000: ITLB  DTLB
  163. [26] 0x00863000 -> 0x00863000: ITLB  DTLB
  164. [27] 0x00862000 -> 0x00862000: ITLB  DTLB
  165. [28] 0x00861000 -> 0x00861000: ITLB  DTLB
  166. [29] 0x00860000 -> 0x00860000: ITLB  DTLB
  167. Instruction and Data caches have been invalidated
  168. ea == 0x00865A7C
  169. @ea == 0x00866FE4
  170. ea == 0x00860120
  171. ea == 0x00860120
  172. ea == 0x00860120
  173. ea == 0x00860120
  174. ea == 0x00860120
  175. ea == 0x00860120
  176. ea == 0x00860120
  177. ea == 0x00860120
  178. ea == 0x00860120
  179. ea == 0x00860120
  180. ea == 0x00860120
  181. ea == 0x00860120