mips 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. // Mips support
  2. defn acidinit() // Called after all the init modules are loaded
  3. {
  4. bplist = {};
  5. bpfmt = 'X';
  6. srcpath = {
  7. "./",
  8. "/sys/src/libc/port/",
  9. "/sys/src/libc/9sys/",
  10. "/sys/src/libc/mips/"
  11. };
  12. srcfiles = {}; // list of loaded files
  13. srctext = {}; // the text of the files
  14. }
  15. defn stk() // trace
  16. {
  17. _stk(*PC, *SP, linkreg(0), 0);
  18. }
  19. defn lstk() // trace with locals
  20. {
  21. _stk(*PC, *SP, linkreg(0), 1);
  22. }
  23. defn gpr() // print general purpose registers
  24. {
  25. print("R1\t", *R1, " R2\t", *R2, " R3\t", *R3, "\n");
  26. print("R4\t", *R4, " R5\t", *R5, " R6\t", *R6, "\n");
  27. print("R7\t", *R7, " R8\t", *R8, " R9\t", *R9, "\n");
  28. print("R10\t", *R10, " R11\t", *R11, " R12\t", *R12, "\n");
  29. print("R13\t", *R13, " R14\t", *R14, " R15\t", *R15, "\n");
  30. print("R16\t", *R16, " R17\t", *R17, " R18\t", *R18, "\n");
  31. print("R19\t", *R19, " R20\t", *R20, " R21\t", *R21, "\n");
  32. print("R22\t", *R22, " R23\t", *R23, " R24\t", *R24, "\n");
  33. print("R25\t", *R25, " R26\t", *R26, " R27\t", *R27, "\n");
  34. print("R28\t", *R28, " R29\t", *SP, " R30\t", *R30, "\n");
  35. print("R31\t", *R31, "\n");
  36. }
  37. defn Fpr()
  38. {
  39. print("F0\t", *fmt(F0, 'G'), "\tF2\t", *fmt(F2, 'G'), "\n");
  40. print("F4\t", *fmt(F4, 'G'), "\tF6\t", *fmt(F6, 'G'), "\n");
  41. print("F8\t", *fmt(F8, 'G'), "\tF10\t", *fmt(F10, 'G'), "\n");
  42. print("F12\t", *fmt(F12, 'G'), "\tF14\t", *fmt(F14, 'G'), "\n");
  43. print("F16\t", *fmt(F16, 'G'), "\tF18\t", *fmt(F18, 'G'), "\n");
  44. print("F20\t", *fmt(F20, 'G'), "\tF22\t", *fmt(F22, 'G'), "\n");
  45. print("F24\t", *fmt(F24, 'G'), "\tF26\t", *fmt(F26, 'G'), "\n");
  46. print("F28\t", *fmt(F28, 'G'), "\tF30\t", *fmt(F30, 'G'), "\n");
  47. }
  48. defn fpr()
  49. {
  50. print("F0\t", *fmt(F0, 'g'), "\tF1\t", *fmt(F1, 'g'), "\n");
  51. print("F2\t", *fmt(F2, 'g'), "\tF3\t", *fmt(F3, 'g'), "\n");
  52. print("F4\t", *fmt(F4, 'g'), "\tF5\t", *fmt(F5, 'g'), "\n");
  53. print("F6\t", *fmt(F6, 'g'), "\tF7\t", *fmt(F7, 'g'), "\n");
  54. print("F8\t", *fmt(F8, 'g'), "\tF9\t", *fmt(F9, 'g'), "\n");
  55. print("F10\t", *fmt(F10, 'g'), "\tF11\t", *fmt(F11, 'g'), "\n");
  56. print("F12\t", *fmt(F12, 'g'), "\tF13\t", *fmt(F13, 'g'), "\n");
  57. print("F14\t", *fmt(F14, 'g'), "\tF15\t", *fmt(F15, 'g'), "\n");
  58. print("F16\t", *fmt(F16, 'g'), "\tF17\t", *fmt(F17, 'g'), "\n");
  59. print("F18\t", *fmt(F18, 'g'), "\tF19\t", *fmt(F19, 'g'), "\n");
  60. print("F20\t", *fmt(F20, 'g'), "\tF21\t", *fmt(F21, 'g'), "\n");
  61. print("F22\t", *fmt(F22, 'g'), "\tF23\t", *fmt(F23, 'g'), "\n");
  62. print("F24\t", *fmt(F24, 'g'), "\tF25\t", *fmt(F25, 'g'), "\n");
  63. print("F26\t", *fmt(F26, 'g'), "\tF27\t", *fmt(F27, 'g'), "\n");
  64. print("F28\t", *fmt(F28, 'g'), "\tF29\t", *fmt(F29, 'g'), "\n");
  65. print("F30\t", *fmt(F30, 'g'), "\tF31\t", *fmt(F31, 'g'), "\n");
  66. }
  67. defn spr() // print special processor registers
  68. {
  69. local pc, link, cause;
  70. pc = *PC;
  71. print("PC\t", pc, " ", fmt(pc, 'a'), " ");
  72. pfl(pc);
  73. link = *R31;
  74. print("SP\t", *SP, "\tLINK\t", link, " ", fmt(link, 'a'), " ");
  75. pfl(link);
  76. cause = *CAUSE;
  77. print("STATUS\t", *STATUS, "\tCAUSE\t", cause, " ", reason(cause), "\n");
  78. print("TLBVIR\t", *TLBVIRT, "\tBADVADR\t", *BADVADDR, "\n");
  79. print("HI\t", *HI, "\tLO\t", *LO, "\n");
  80. }
  81. defn regs() // print all registers
  82. {
  83. spr();
  84. gpr();
  85. }
  86. defn pstop(pid)
  87. {
  88. local l, pc;
  89. pc = *PC;
  90. print(pid,": ", reason(*CAUSE), "\t");
  91. print(fmt(pc, 'a'), "\t", fmt(pc, 'i'), "\n");
  92. if notes then {
  93. if notes[0] != "sys: breakpoint" then {
  94. print("Notes pending:\n");
  95. l = notes;
  96. while l do {
  97. print("\t", head l, "\n");
  98. l = tail l;
  99. }
  100. }
  101. }
  102. }
  103. sizeofUreg = 152;
  104. aggr Ureg
  105. {
  106. 'X' 0 status;
  107. 'X' 4 pc;
  108. {
  109. 'X' 8 sp;
  110. 'X' 8 usp;
  111. };
  112. 'X' 12 cause;
  113. 'X' 16 badvaddr;
  114. 'X' 20 tlbvirt;
  115. 'X' 24 hi;
  116. 'X' 28 lo;
  117. 'X' 32 r31;
  118. 'X' 36 r30;
  119. 'X' 40 r28;
  120. 'X' 44 r27;
  121. 'X' 48 r26;
  122. 'X' 52 r25;
  123. 'X' 56 r24;
  124. 'X' 60 r23;
  125. 'X' 64 r22;
  126. 'X' 68 r21;
  127. 'X' 72 r20;
  128. 'X' 76 r19;
  129. 'X' 80 r18;
  130. 'X' 84 r17;
  131. 'X' 88 r16;
  132. 'X' 92 r15;
  133. 'X' 96 r14;
  134. 'X' 100 r13;
  135. 'X' 104 r12;
  136. 'X' 108 r11;
  137. 'X' 112 r10;
  138. 'X' 116 r9;
  139. 'X' 120 r8;
  140. 'X' 124 r7;
  141. 'X' 128 r6;
  142. 'X' 132 r5;
  143. 'X' 136 r4;
  144. 'X' 140 r3;
  145. 'X' 144 r2;
  146. 'X' 148 r1;
  147. };
  148. defn
  149. Ureg(addr) {
  150. complex Ureg addr;
  151. print(" status ", addr.status, "\n");
  152. print(" pc ", addr.pc, "\n");
  153. print(" sp ", addr.sp, "\n");
  154. print(" cause ", addr.cause, "\n");
  155. print(" badvaddr ", addr.badvaddr, "\n");
  156. print(" tlbvirt ", addr.tlbvirt, "\n");
  157. print(" hi ", addr.hi, "\n");
  158. print(" lo ", addr.lo, "\n");
  159. print(" r31 ", addr.r31, "\n");
  160. print(" r30 ", addr.r30, "\n");
  161. print(" r28 ", addr.r28, "\n");
  162. print(" r27 ", addr.r27, "\n");
  163. print(" r26 ", addr.r26, "\n");
  164. print(" r25 ", addr.r25, "\n");
  165. print(" r24 ", addr.r24, "\n");
  166. print(" r23 ", addr.r23, "\n");
  167. print(" r22 ", addr.r22, "\n");
  168. print(" r21 ", addr.r21, "\n");
  169. print(" r20 ", addr.r20, "\n");
  170. print(" r19 ", addr.r19, "\n");
  171. print(" r18 ", addr.r18, "\n");
  172. print(" r17 ", addr.r17, "\n");
  173. print(" r16 ", addr.r16, "\n");
  174. print(" r15 ", addr.r15, "\n");
  175. print(" r14 ", addr.r14, "\n");
  176. print(" r13 ", addr.r13, "\n");
  177. print(" r12 ", addr.r12, "\n");
  178. print(" r11 ", addr.r11, "\n");
  179. print(" r10 ", addr.r10, "\n");
  180. print(" r9 ", addr.r9, "\n");
  181. print(" r8 ", addr.r8, "\n");
  182. print(" r7 ", addr.r7, "\n");
  183. print(" r6 ", addr.r6, "\n");
  184. print(" r5 ", addr.r5, "\n");
  185. print(" r4 ", addr.r4, "\n");
  186. print(" r3 ", addr.r3, "\n");
  187. print(" r2 ", addr.r2, "\n");
  188. print(" r1 ", addr.r1, "\n");
  189. };
  190. defn linkreg(addr)
  191. {
  192. complex Ureg addr;
  193. return addr.r31\X;
  194. }
  195. print("/sys/lib/acid/mips");