sparc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. // Sparc 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/sparc/"
  11. };
  12. srcfiles = {}; // list of loaded files
  13. srctext = {}; // the text of the files
  14. }
  15. defn stk() // trace
  16. {
  17. _stk(*PC, *R1, linkreg(0), 0);
  18. }
  19. defn lstk() // trace with locals
  20. {
  21. _stk(*PC, *R1, 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", *R29, "R30\t", *R30, "\n");
  35. print("R31\t", *R31, "\n");
  36. }
  37. defn spr() // print special processor registers
  38. {
  39. local pc;
  40. local link;
  41. local cause;
  42. pc = *PC;
  43. print("PC\t", pc, " ", fmt(pc, 'a'), " ");
  44. pfl(pc);
  45. print("PSR\t", *PSR, "\n");
  46. link = *R15;
  47. print("SP\t", *R1, "\tLINK\t\t", link, " ", fmt(link, 'a'));
  48. pfl(link);
  49. cause = *TBR;
  50. print("Y\t", *Y, "\tCAUSE\t", *Y, cause, " ", reason(cause), "\n");
  51. }
  52. defn Fpr()
  53. {
  54. print("F0\t", *fmt(F0, 'G'), "\tF2\t", *fmt(F2, 'G'), "\n");
  55. print("F4\t", *fmt(F4, 'G'), "\tF6\t", *fmt(F6, 'G'), "\n");
  56. print("F8\t", *fmt(F8, 'G'), "\tF10\t", *fmt(F10, 'G'), "\n");
  57. print("F12\t", *fmt(F12, 'G'), "\tF14\t", *fmt(F14, 'G'), "\n");
  58. print("F16\t", *fmt(F16, 'G'), "\tF18\t", *fmt(F18, 'G'), "\n");
  59. print("F20\t", *fmt(F20, 'G'), "\tF22\t", *fmt(F22, 'G'), "\n");
  60. print("F24\t", *fmt(F24, 'G'), "\tF26\t", *fmt(F26, 'G'), "\n");
  61. print("F28\t", *fmt(F28, 'G'), "\tF30\t", *fmt(F30, 'G'), "\n");
  62. }
  63. defn fpr()
  64. {
  65. print("F0\t", *fmt(F0, 'g'), "\tF1\t", *fmt(F1, 'g'), "\n");
  66. print("F2\t", *fmt(F2, 'g'), "\tF3\t", *fmt(F3, 'g'), "\n");
  67. print("F4\t", *fmt(F4, 'g'), "\tF5\t", *fmt(F5, 'g'), "\n");
  68. print("F6\t", *fmt(F6, 'g'), "\tF7\t", *fmt(F7, 'g'), "\n");
  69. print("F8\t", *fmt(F8, 'g'), "\tF9\t", *fmt(F9, 'g'), "\n");
  70. print("F10\t", *fmt(F10, 'g'), "\tF11\t", *fmt(F11, 'g'), "\n");
  71. print("F12\t", *fmt(F12, 'g'), "\tF13\t", *fmt(F13, 'g'), "\n");
  72. print("F14\t", *fmt(F14, 'g'), "\tF15\t", *fmt(F15, 'g'), "\n");
  73. print("F16\t", *fmt(F16, 'g'), "\tF17\t", *fmt(F17, 'g'), "\n");
  74. print("F18\t", *fmt(F18, 'g'), "\tF19\t", *fmt(F19, 'g'), "\n");
  75. print("F20\t", *fmt(F20, 'g'), "\tF21\t", *fmt(F21, 'g'), "\n");
  76. print("F22\t", *fmt(F22, 'g'), "\tF23\t", *fmt(F23, 'g'), "\n");
  77. print("F24\t", *fmt(F24, 'g'), "\tF25\t", *fmt(F25, 'g'), "\n");
  78. print("F26\t", *fmt(F26, 'g'), "\tF27\t", *fmt(F27, 'g'), "\n");
  79. print("F28\t", *fmt(F28, 'g'), "\tF29\t", *fmt(F29, 'g'), "\n");
  80. print("F30\t", *fmt(F30, 'g'), "\tF31\t", *fmt(F31, 'g'), "\n");
  81. }
  82. defn regs() // print all registers
  83. {
  84. spr();
  85. gpr();
  86. }
  87. defn pstop(pid)
  88. {
  89. local l;
  90. local pc;
  91. pc = *PC;
  92. print(pid,": ", reason(*TBR), "\t");
  93. print(fmt(pc, 'a'), "\t", fmt(pc, 'i'), "\n");
  94. if notes then {
  95. if notes[0] != "sys: breakpoint" then {
  96. print("Notes pending:\n");
  97. l = notes;
  98. while l do {
  99. print("\t", head l, "\n");
  100. l = tail l;
  101. }
  102. }
  103. }
  104. }
  105. aggr Ureg
  106. {
  107. 'U' 0 r0;
  108. {
  109. 'U' 4 sp;
  110. 'U' 4 usp;
  111. 'U' 4 r1;
  112. };
  113. 'U' 8 r2;
  114. 'U' 12 r3;
  115. 'U' 16 r4;
  116. 'U' 20 r5;
  117. 'U' 24 r6;
  118. 'U' 28 r7;
  119. 'U' 32 r8;
  120. 'U' 36 r9;
  121. 'U' 40 r10;
  122. 'U' 44 r11;
  123. 'U' 48 r12;
  124. 'U' 52 r13;
  125. 'U' 56 r14;
  126. 'U' 60 r15;
  127. 'U' 64 r16;
  128. 'U' 68 r17;
  129. 'U' 72 r18;
  130. 'U' 76 r19;
  131. 'U' 80 r20;
  132. 'U' 84 r21;
  133. 'U' 88 r22;
  134. 'U' 92 r23;
  135. 'U' 96 r24;
  136. 'U' 100 r25;
  137. 'U' 104 r26;
  138. 'U' 108 r27;
  139. 'U' 112 r28;
  140. 'U' 116 r29;
  141. 'U' 120 r30;
  142. 'U' 124 r31;
  143. 'U' 128 y;
  144. 'U' 132 tbr;
  145. 'U' 136 psr;
  146. 'U' 140 npc;
  147. 'U' 144 pc;
  148. 'U' 148 pad;
  149. };
  150. defn
  151. Ureg(addr) {
  152. complex Ureg addr;
  153. print(" r0 ", addr.r0, "\n");
  154. print(" sp ", addr.sp, "\n");
  155. print(" r2 ", addr.r2, "\n");
  156. print(" r3 ", addr.r3, "\n");
  157. print(" r4 ", addr.r4, "\n");
  158. print(" r5 ", addr.r5, "\n");
  159. print(" r6 ", addr.r6, "\n");
  160. print(" r7 ", addr.r7, "\n");
  161. print(" r8 ", addr.r8, "\n");
  162. print(" r9 ", addr.r9, "\n");
  163. print(" r10 ", addr.r10, "\n");
  164. print(" r11 ", addr.r11, "\n");
  165. print(" r12 ", addr.r12, "\n");
  166. print(" r13 ", addr.r13, "\n");
  167. print(" r14 ", addr.r14, "\n");
  168. print(" r15 ", addr.r15, "\n");
  169. print(" r16 ", addr.r16, "\n");
  170. print(" r17 ", addr.r17, "\n");
  171. print(" r18 ", addr.r18, "\n");
  172. print(" r19 ", addr.r19, "\n");
  173. print(" r20 ", addr.r20, "\n");
  174. print(" r21 ", addr.r21, "\n");
  175. print(" r22 ", addr.r22, "\n");
  176. print(" r23 ", addr.r23, "\n");
  177. print(" r24 ", addr.r24, "\n");
  178. print(" r25 ", addr.r25, "\n");
  179. print(" r26 ", addr.r26, "\n");
  180. print(" r27 ", addr.r27, "\n");
  181. print(" r28 ", addr.r28, "\n");
  182. print(" r29 ", addr.r29, "\n");
  183. print(" r30 ", addr.r30, "\n");
  184. print(" r31 ", addr.r31, "\n");
  185. print(" y ", addr.y, "\n");
  186. print(" tbr ", addr.tbr, "\n");
  187. print(" psr ", addr.psr, "\n");
  188. print(" npc ", addr.npc, "\n");
  189. print(" pc ", addr.pc, "\n");
  190. print(" pad ", addr.pad, "\n");
  191. };
  192. defn linkreg(addr)
  193. {
  194. complex Ureg addr;
  195. return addr.r15\X;
  196. }
  197. print("/sys/lib/acid/sparc");