power (3045B)
1 // Power PC support 2 3 defn acidinit() // Called after all the init modules are loaded 4 { 5 bplist = {}; 6 bpfmt = 'X'; 7 8 srcpath = { 9 "./", 10 "/sys/src/libc/port/", 11 "/sys/src/libc/9sys/", 12 "/sys/src/libc/power/" 13 }; 14 15 srcfiles = {}; // list of loaded files 16 srctext = {}; // the text of the files 17 } 18 19 defn stk() // trace 20 { 21 _stk(*PC, *SP, linkreg(0), 0); 22 } 23 24 defn lstk() // trace with locals 25 { 26 _stk(*PC, *SP, linkreg(0), 1); 27 } 28 29 defn gpr() // print general purpose registers 30 { 31 print("SP\t", *SP, " R2\t", *R2, " R3\t", *R3, "\n"); 32 print("R4\t", *R4, " R5\t", *R5, " R6\t", *R6, "\n"); 33 print("R7\t", *R7, " R8\t", *R8, " R9\t", *R9, "\n"); 34 print("R10\t", *R10, " R11\t", *R11, " R12\t", *R12, "\n"); 35 print("R13\t", *R13, " R14\t", *R14, " R15\t", *R15, "\n"); 36 print("R16\t", *R16, " R17\t", *R17, " R18\t", *R18, "\n"); 37 print("R19\t", *R19, " R20\t", *R20, " R21\t", *R21, "\n"); 38 print("R22\t", *R22, " R23\t", *R23, " R24\t", *R24, "\n"); 39 print("R25\t", *R25, " R26\t", *R26, " R27\t", *R27, "\n"); 40 print("R28\t", *R28, " R29\t", *R29, " R30\t", *R30, "\n"); 41 print("R31\t", *R31, "\n"); 42 } 43 44 defn Fpr() 45 { 46 fpr(); 47 } 48 49 defn fpr() 50 { 51 print("F0\t", *fmt(F0, 'G'), "\tF1\t", *fmt(F1, 'G'), "\n"); 52 print("F2\t", *fmt(F2, 'G'), "\tF3\t", *fmt(F3, 'G'), "\n"); 53 print("F4\t", *fmt(F4, 'G'), "\tF5\t", *fmt(F5, 'G'), "\n"); 54 print("F6\t", *fmt(F6, 'G'), "\tF7\t", *fmt(F7, 'G'), "\n"); 55 print("F8\t", *fmt(F8, 'G'), "\tF9\t", *fmt(F9, 'G'), "\n"); 56 print("F10\t", *fmt(F10, 'G'), "\tF11\t", *fmt(F11, 'G'), "\n"); 57 print("F12\t", *fmt(F12, 'G'), "\tF13\t", *fmt(F13, 'G'), "\n"); 58 print("F14\t", *fmt(F14, 'G'), "\tF15\t", *fmt(F15, 'G'), "\n"); 59 print("F16\t", *fmt(F16, 'G'), "\tF17\t", *fmt(F17, 'G'), "\n"); 60 print("F18\t", *fmt(F18, 'G'), "\tF19\t", *fmt(F19, 'G'), "\n"); 61 print("F20\t", *fmt(F20, 'G'), "\tF21\t", *fmt(F21, 'G'), "\n"); 62 print("F22\t", *fmt(F22, 'G'), "\tF23\t", *fmt(F23, 'G'), "\n"); 63 print("F24\t", *fmt(F24, 'G'), "\tF25\t", *fmt(F25, 'G'), "\n"); 64 print("F26\t", *fmt(F26, 'G'), "\tF27\t", *fmt(F27, 'G'), "\n"); 65 print("F28\t", *fmt(F28, 'G'), "\tF29\t", *fmt(F29, 'G'), "\n"); 66 print("F30\t", *fmt(F30, 'G'), "\tF31\t", *fmt(F31, 'G'), "\n"); 67 } 68 69 defn spr() // print special processor registers 70 { 71 local pc, link, cause; 72 73 pc = *PC; 74 print("PC\t", pc, " ", fmt(pc, 'a'), " "); 75 pfl(pc); 76 77 link = *R31; 78 print("SP\t", *SP, "\tLINK\t", link, " ", fmt(link, 'a'), " "); 79 pfl(link); 80 81 cause = *CAUSE; 82 print("SRR1\t", *SRR1, "\tCAUSE\t", cause, " ", reason(cause), "\n"); 83 print("LR\t", *LR, "\tCR\t", *CR, "\n"); 84 85 print("XER\t", *XER, "\tCTR\t", *CTR, "\n"); 86 } 87 88 defn regs() // print all registers 89 { 90 spr(); 91 gpr(); 92 } 93 94 defn pstop(pid) 95 { 96 local l, pc; 97 98 pc = *PC; 99 100 print(pid,": ", reason(*CAUSE), "\t"); 101 print(fmt(pc, 'a'), "\t", fmt(pc, 'i'), "\n"); 102 103 if notes then { 104 if notes[0] != "sys: breakpoint" then { 105 print("Notes pending:\n"); 106 l = notes; 107 while l do { 108 print("\t", head l, "\n"); 109 l = tail l; 110 } 111 } 112 } 113 } 114 115 defn linkreg(addr) 116 { 117 return *LR; 118 } 119 120 print(acidfile);