power64 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // power64
  2. // incomplete until there are processes to debug
  3. defn acidinit() // Called after all the init modules are loaded
  4. {
  5. bplist = {};
  6. bpfmt = 'X';
  7. srcpath = {
  8. "./",
  9. "/sys/src/libc/port/",
  10. "/sys/src/libc/9sys/",
  11. "/sys/src/libc/power64/"
  12. };
  13. srcfiles = {}; // list of loaded files
  14. srctext = {}; // the text of the files
  15. }
  16. defn stk() // trace
  17. {
  18. _stk(*PC, *SP, linkreg(0), 0);
  19. }
  20. defn lstk() // trace with locals
  21. {
  22. _stk(*PC, *SP, linkreg(0), 1);
  23. }
  24. defn gpr() // print general purpose registers
  25. {
  26. print("R0 ", *R0, "\n");
  27. print("SP ", *SP, "\n");
  28. print("R2 ", *R2, "\n");
  29. print("R3 ", *R3, "\n");
  30. print("R4 ", *R4, "\n");
  31. print("R5 ", *R5, "\n");
  32. print("R6 ", *R6, "\n");
  33. print("R7 ", *R7, "\n");
  34. print("R8 ", *R8, "\n");
  35. print("R9 ", *R9, "\n");
  36. print("R10 ", *R10, "\n");
  37. print("R11 ", *R11, "\n");
  38. print("R12 ", *R12, "\n");
  39. print("R13 ", *R13, "\n");
  40. print("R14 ", *R14, "\n");
  41. print("R15 ", *R15, "\n");
  42. print("R16 ", *R16, "\n");
  43. print("R17 ", *R17, "\n");
  44. print("R18 ", *R18, "\n");
  45. print("R19 ", *R19, "\n");
  46. print("R20 ", *R20, "\n");
  47. print("R21 ", *R21, "\n");
  48. print("R22 ", *R22, "\n");
  49. print("R23 ", *R23, "\n");
  50. print("R24 ", *R24, "\n");
  51. print("R25 ", *R25, "\n");
  52. print("R26 ", *R26, "\n");
  53. print("R27 ", *R27, "\n");
  54. print("R28 ", *R28, "\n");
  55. print("R29 ", *R29, "\n");
  56. print("R30 ", *R30, "\n");
  57. print("R31 ", *R31, "\n");
  58. }
  59. defn Fpr()
  60. {
  61. fpr();
  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 spr() // print special processor registers
  83. {
  84. local pc, link, cause;
  85. pc = *PC;
  86. print("PC\t", pc, " ", fmt(pc, 'a'), " ");
  87. pfl(pc);
  88. link = *R31;
  89. print("SP\t", *SP, "\tLINK\t", link, " ", fmt(link, 'a'), " ");
  90. pfl(link);
  91. cause = *CAUSE;
  92. print("SRR1\t", *SRR1, "\tCAUSE\t", cause, " ", reason(cause), "\n");
  93. print("LR\t", *LR, "\tCR\t", *CR, "\n");
  94. print("XER\t", *XER, "\tCTR\t", *CTR, "\n");
  95. }
  96. defn regs() // print all registers
  97. {
  98. spr();
  99. gpr();
  100. }
  101. defn pstop(pid)
  102. {
  103. local l, pc;
  104. pc = *PC;
  105. print(pid,": ", reason(*CAUSE), "\t");
  106. print(fmt(pc, 'a'), "\t", fmt(pc, 'i'), "\n");
  107. if notes then {
  108. if notes[0] != "sys: breakpoint" then {
  109. print("Notes pending:\n");
  110. l = notes;
  111. while l do {
  112. print("\t", head l, "\n");
  113. l = tail l;
  114. }
  115. }
  116. }
  117. }
  118. defn linkreg(addr)
  119. {
  120. return *LR;
  121. }
  122. print("/sys/lib/acid/power64");