Macpaul Lin | 273d11e | 2011-12-01 12:32:10 +0800 | [diff] [blame] | 1 | #include <linux/linkage.h> |
Robin Getz | f19fd87 | 2009-12-21 16:35:48 -0500 | [diff] [blame] | 2 | |
| 3 | /* save stack context for non-local goto |
| 4 | * int kgdb_setjmp(long *buf) |
| 5 | */ |
| 6 | |
| 7 | ENTRY(_kgdb_setjmp) |
| 8 | [--SP] = p0; /* Save P0 */ |
| 9 | p0 = r0; |
| 10 | r0 = [SP++]; /* Load P0 into R0 */ |
| 11 | |
| 12 | [p0 + 0x00] = r0; /* GP address registers */ |
| 13 | [p0 + 0x04] = p1; |
| 14 | [p0 + 0x08] = p2; |
| 15 | [p0 + 0x0C] = p3; |
| 16 | [p0 + 0x10] = p4; |
| 17 | [p0 + 0x14] = p5; |
| 18 | [p0 + 0x18] = FP; /* frame pointer */ |
| 19 | [p0 + 0x1C] = SP; /* stack pointer */ |
| 20 | |
| 21 | [p0 + 0x20] = p0; /* data regs */ |
| 22 | [p0 + 0x24] = r1; |
| 23 | [p0 + 0x28] = r2; |
| 24 | [p0 + 0x2C] = r3; |
| 25 | [p0 + 0x30] = r4; |
| 26 | [p0 + 0x34] = r5; |
| 27 | [p0 + 0x38] = r6; |
| 28 | [p0 + 0x3C] = r7; |
| 29 | |
| 30 | r0 = ASTAT; [p0 + 0x40] = r0; |
| 31 | |
| 32 | /* loop counters */ |
| 33 | r0 = LC0; [p0 + 0x44] = r0; |
| 34 | r0 = LC1; [p0 + 0x48] = r0; |
| 35 | |
| 36 | /* Accumulator */ |
| 37 | r0 = A0.w; [p0 + 0x4C] = r0; |
| 38 | r0.l = A0.x; [p0 + 0x50] = r0; |
| 39 | r0 = A1.w; [p0 + 0x54] = r0; |
| 40 | r0.l = A1.x; [p0 + 0x58] = r0; |
| 41 | |
| 42 | /* index registers */ |
| 43 | r0 = i0; [p0 + 0x5C] = r0; |
| 44 | r0 = i1; [p0 + 0x60] = r0; |
| 45 | r0 = i2; [p0 + 0x64] = r0; |
| 46 | r0 = i3; [p0 + 0x68] = r0; |
| 47 | |
| 48 | /* modifier registers */ |
| 49 | r0 = m0; [p0 + 0x6C] = r0; |
| 50 | r0 = m1; [p0 + 0x70] = r0; |
| 51 | r0 = m2; [p0 + 0x74] = r0; |
| 52 | r0 = m3; [p0 + 0x78] = r0; |
| 53 | |
| 54 | /* length registers */ |
| 55 | r0 = l0; [p0 + 0x7C] = r0; |
| 56 | r0 = l1; [p0 + 0x80] = r0; |
| 57 | r0 = l2; [p0 + 0x84] = r0; |
| 58 | r0 = l3; [p0 + 0x88] = r0; |
| 59 | |
| 60 | /* base registers */ |
| 61 | r0 = b0; [p0 + 0x8C] = r0; |
| 62 | r0 = b1; [p0 + 0x90] = r0; |
| 63 | r0 = b2; [p0 + 0x94] = r0; |
| 64 | r0 = b3; [p0 + 0x98] = r0; |
| 65 | |
| 66 | /* store return address */ |
| 67 | r0 = RETS; [p0 + 0x9C] = r0; |
| 68 | |
| 69 | R0 = 0; |
| 70 | RTS; |
| 71 | ENDPROC(_kgdb_setjmp) |
| 72 | |
| 73 | /* |
| 74 | * non-local jump to a saved stack context |
| 75 | * longjmp(long *buf, int val) |
| 76 | */ |
| 77 | |
| 78 | ENTRY(_kgdb_longjmp) |
| 79 | p0 = r0; |
| 80 | r0 = [p0 + 0x00]; |
| 81 | [--sp] = r0; |
| 82 | |
| 83 | /* GP address registers - skip p0 for now*/ |
| 84 | p1 = [p0 + 0x04]; |
| 85 | p2 = [p0 + 0x08]; |
| 86 | p3 = [p0 + 0x0C]; |
| 87 | p4 = [p0 + 0x10]; |
| 88 | p5 = [p0 + 0x14]; |
| 89 | /* frame pointer */ |
| 90 | fp = [p0 + 0x18]; |
| 91 | /* stack pointer */ |
| 92 | r0 = [sp++]; |
| 93 | sp = [p0 + 0x1C]; |
| 94 | [--sp] = r0; |
| 95 | [--sp] = r1; |
| 96 | |
| 97 | /* data regs */ |
| 98 | r0 = [p0 + 0x20]; |
| 99 | r1 = [p0 + 0x24]; |
| 100 | r2 = [p0 + 0x28]; |
| 101 | r3 = [p0 + 0x2C]; |
| 102 | r4 = [p0 + 0x30]; |
| 103 | r5 = [p0 + 0x34]; |
| 104 | r6 = [p0 + 0x38]; |
| 105 | r7 = [p0 + 0x3C]; |
| 106 | |
| 107 | r0 = [p0 + 0x40]; ASTAT = r0; |
| 108 | |
| 109 | /* loop counters */ |
| 110 | r0 = [p0 + 0x44]; LC0 = r0; |
| 111 | r0 = [p0 + 0x48]; LC1 = r0; |
| 112 | |
| 113 | /* Accumulator */ |
| 114 | r0 = [p0 + 0x4C]; A0.w = r0; |
| 115 | r0 = [p0 + 0x50]; A0.x = r0; |
| 116 | r0 = [p0 + 0x54]; A1.w = r0; |
| 117 | r0 = [p0 + 0x58]; A1.x = r0; |
| 118 | |
| 119 | /* index registers */ |
| 120 | r0 = [p0 + 0x5C]; i0 = r0; |
| 121 | r0 = [p0 + 0x60]; i1 = r0; |
| 122 | r0 = [p0 + 0x64]; i2 = r0; |
| 123 | r0 = [p0 + 0x68]; i3 = r0; |
| 124 | |
| 125 | /* modifier registers */ |
| 126 | r0 = [p0 + 0x6C]; m0 = r0; |
| 127 | r0 = [p0 + 0x70]; m1 = r0; |
| 128 | r0 = [p0 + 0x74]; m2 = r0; |
| 129 | r0 = [p0 + 0x78]; m3 = r0; |
| 130 | |
| 131 | /* length registers */ |
| 132 | r0 = [p0 + 0x7C]; l0 = r0; |
| 133 | r0 = [p0 + 0x80]; l1 = r0; |
| 134 | r0 = [p0 + 0x84]; l2 = r0; |
| 135 | r0 = [p0 + 0x88]; l3 = r0; |
| 136 | |
| 137 | /* base registers */ |
| 138 | r0 = [p0 + 0x8C]; b0 = r0; |
| 139 | r0 = [p0 + 0x90]; b1 = r0; |
| 140 | r0 = [p0 + 0x94]; b2 = r0; |
| 141 | r0 = [p0 + 0x98]; b3 = r0; |
| 142 | |
| 143 | /* store return address */ |
| 144 | r0 = [p0 + 0x9C]; RETS = r0; |
| 145 | |
| 146 | /* fixup R0 & P0 */ |
| 147 | r0 = [sp++]; |
| 148 | p0 = [sp++]; |
| 149 | CC = R0 == 0; |
| 150 | IF !CC JUMP .Lfinished; |
| 151 | R0 = 1; |
| 152 | .Lfinished: |
| 153 | RTS; |
| 154 | ENDPROC(_kgdb_longjmp) |