power 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Power PC 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/power/"
  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("SP\t", *SP, " 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 Fpr()
  38. {
  39. fpr();
  40. }
  41. defn fpr()
  42. {
  43. print("F0\t", *fmt(F0, 'G'), "\tF1\t", *fmt(F1, 'G'), "\n");
  44. print("F2\t", *fmt(F2, 'G'), "\tF3\t", *fmt(F3, 'G'), "\n");
  45. print("F4\t", *fmt(F4, 'G'), "\tF5\t", *fmt(F5, 'G'), "\n");
  46. print("F6\t", *fmt(F6, 'G'), "\tF7\t", *fmt(F7, 'G'), "\n");
  47. print("F8\t", *fmt(F8, 'G'), "\tF9\t", *fmt(F9, 'G'), "\n");
  48. print("F10\t", *fmt(F10, 'G'), "\tF11\t", *fmt(F11, 'G'), "\n");
  49. print("F12\t", *fmt(F12, 'G'), "\tF13\t", *fmt(F13, 'G'), "\n");
  50. print("F14\t", *fmt(F14, 'G'), "\tF15\t", *fmt(F15, 'G'), "\n");
  51. print("F16\t", *fmt(F16, 'G'), "\tF17\t", *fmt(F17, 'G'), "\n");
  52. print("F18\t", *fmt(F18, 'G'), "\tF19\t", *fmt(F19, 'G'), "\n");
  53. print("F20\t", *fmt(F20, 'G'), "\tF21\t", *fmt(F21, 'G'), "\n");
  54. print("F22\t", *fmt(F22, 'G'), "\tF23\t", *fmt(F23, 'G'), "\n");
  55. print("F24\t", *fmt(F24, 'G'), "\tF25\t", *fmt(F25, 'G'), "\n");
  56. print("F26\t", *fmt(F26, 'G'), "\tF27\t", *fmt(F27, 'G'), "\n");
  57. print("F28\t", *fmt(F28, 'G'), "\tF29\t", *fmt(F29, 'G'), "\n");
  58. print("F30\t", *fmt(F30, 'G'), "\tF31\t", *fmt(F31, 'G'), "\n");
  59. }
  60. defn spr() // print special processor registers
  61. {
  62. local pc, link, cause;
  63. pc = *PC;
  64. print("PC\t", pc, " ", fmt(pc, 'a'), " ");
  65. pfl(pc);
  66. link = *R31;
  67. print("SP\t", *SP, "\tLINK\t", link, " ", fmt(link, 'a'), " ");
  68. pfl(link);
  69. cause = *CAUSE;
  70. print("SRR1\t", *SRR1, "\tCAUSE\t", cause, " ", reason(cause), "\n");
  71. print("LR\t", *LR, "\tCR\t", *CR, "\n");
  72. print("XER\t", *XER, "\tCTR\t", *CTR, "\n");
  73. }
  74. defn regs() // print all registers
  75. {
  76. spr();
  77. gpr();
  78. }
  79. defn pstop(pid)
  80. {
  81. local l, pc;
  82. pc = *PC;
  83. print(pid,": ", reason(*CAUSE), "\t");
  84. print(fmt(pc, 'a'), "\t", fmt(pc, 'i'), "\n");
  85. if notes then {
  86. if notes[0] != "sys: breakpoint" then {
  87. print("Notes pending:\n");
  88. l = notes;
  89. while l do {
  90. print("\t", head l, "\n");
  91. l = tail l;
  92. }
  93. }
  94. }
  95. }
  96. defn linkreg(addr)
  97. {
  98. return *LR;
  99. }
  100. print("/sys/lib/acid/power");