Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 1 | /* |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 2 | * entry.h - routines for context saving and restoring (for interrupts/exceptions) |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 3 | * |
Aubrey Li | 314d22f | 2007-04-05 18:31:18 +0800 | [diff] [blame] | 4 | * Copyright (c) 2005-2007 Analog Devices Inc. |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 5 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
Aubrey Li | 314d22f | 2007-04-05 18:31:18 +0800 | [diff] [blame] | 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
| 22 | * MA 02110-1301 USA |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 23 | */ |
| 24 | |
| 25 | #ifndef __BLACKFIN_ENTRY_H |
| 26 | #define __BLACKFIN_ENTRY_H |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 27 | #ifdef __ASSEMBLY__ |
| 28 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 29 | #define SAVE_ALL_INT save_context_no_interrupts |
| 30 | #define SAVE_ALL_SYS save_context_no_interrupts |
| 31 | #define SAVE_CONTEXT save_context_with_interrupts |
| 32 | |
| 33 | #define RESTORE_ALL restore_context_no_interrupts |
| 34 | #define RESTORE_ALL_SYS restore_context_no_interrupts |
| 35 | #define RESTORE_CONTEXT restore_context_with_interrupts |
| 36 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 37 | /* |
| 38 | * Code to save processor context. |
| 39 | * We even save the register which are preserved by a function call |
| 40 | * - r4, r5, r6, r7, p3, p4, p5 |
| 41 | */ |
| 42 | .macro save_context_with_interrupts |
| 43 | [--sp] = R0; |
| 44 | [--sp] = ( R7:0, P5:0 ); |
| 45 | [--sp] = fp; |
| 46 | [--sp] = usp; |
| 47 | |
| 48 | [--sp] = i0; |
| 49 | [--sp] = i1; |
| 50 | [--sp] = i2; |
| 51 | [--sp] = i3; |
| 52 | |
| 53 | [--sp] = m0; |
| 54 | [--sp] = m1; |
| 55 | [--sp] = m2; |
| 56 | [--sp] = m3; |
| 57 | |
| 58 | [--sp] = l0; |
| 59 | [--sp] = l1; |
| 60 | [--sp] = l2; |
| 61 | [--sp] = l3; |
| 62 | |
| 63 | [--sp] = b0; |
| 64 | [--sp] = b1; |
| 65 | [--sp] = b2; |
| 66 | [--sp] = b3; |
| 67 | [--sp] = a0.x; |
| 68 | [--sp] = a0.w; |
| 69 | [--sp] = a1.x; |
| 70 | [--sp] = a1.w; |
| 71 | |
| 72 | [--sp] = LC0; |
| 73 | [--sp] = LC1; |
| 74 | [--sp] = LT0; |
| 75 | [--sp] = LT1; |
| 76 | [--sp] = LB0; |
| 77 | [--sp] = LB1; |
| 78 | |
| 79 | [--sp] = ASTAT; |
| 80 | |
| 81 | [--sp] = r0; /* Skip reserved */ |
| 82 | [--sp] = RETS; |
| 83 | [--sp] = RETI; |
| 84 | [--sp] = RETX; |
| 85 | [--sp] = RETN; |
| 86 | [--sp] = RETE; |
| 87 | [--sp] = SEQSTAT; |
| 88 | [--sp] = SYSCFG; |
Robin Getz | 230d001 | 2009-12-21 16:35:48 -0500 | [diff] [blame] | 89 | #ifdef CONFIG_CMD_KGDB |
| 90 | p0.l = lo(IPEND) |
| 91 | p0.h = hi(IPEND) |
| 92 | r0 = [p0]; |
| 93 | #endif |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 94 | [--sp] = r0; /* Skip IPEND as well. */ |
| 95 | .endm |
| 96 | |
| 97 | .macro save_context_no_interrupts |
| 98 | [--sp] = R0; |
| 99 | [--sp] = ( R7:0, P5:0 ); |
| 100 | [--sp] = fp; |
| 101 | [--sp] = usp; |
| 102 | |
| 103 | [--sp] = i0; |
| 104 | [--sp] = i1; |
| 105 | [--sp] = i2; |
| 106 | [--sp] = i3; |
| 107 | |
| 108 | [--sp] = m0; |
| 109 | [--sp] = m1; |
| 110 | [--sp] = m2; |
| 111 | [--sp] = m3; |
| 112 | |
| 113 | [--sp] = l0; |
| 114 | [--sp] = l1; |
| 115 | [--sp] = l2; |
| 116 | [--sp] = l3; |
| 117 | |
| 118 | [--sp] = b0; |
| 119 | [--sp] = b1; |
| 120 | [--sp] = b2; |
| 121 | [--sp] = b3; |
| 122 | [--sp] = a0.x; |
| 123 | [--sp] = a0.w; |
| 124 | [--sp] = a1.x; |
| 125 | [--sp] = a1.w; |
| 126 | |
| 127 | [--sp] = LC0; |
| 128 | [--sp] = LC1; |
| 129 | [--sp] = LT0; |
| 130 | [--sp] = LT1; |
| 131 | [--sp] = LB0; |
| 132 | [--sp] = LB1; |
| 133 | |
| 134 | [--sp] = ASTAT; |
| 135 | |
| 136 | [--sp] = r0; /* Skip reserved */ |
| 137 | [--sp] = RETS; |
| 138 | r0 = RETI; |
| 139 | [--sp] = r0; |
| 140 | [--sp] = RETX; |
| 141 | [--sp] = RETN; |
| 142 | [--sp] = RETE; |
| 143 | [--sp] = SEQSTAT; |
| 144 | [--sp] = SYSCFG; |
Robin Getz | 230d001 | 2009-12-21 16:35:48 -0500 | [diff] [blame] | 145 | #ifdef CONFIG_CMD_KGDB |
| 146 | p0.l = lo(IPEND) |
| 147 | p0.h = hi(IPEND) |
| 148 | r0 = [p0]; |
| 149 | #endif |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 150 | [--sp] = r0; /* Skip IPEND as well. */ |
| 151 | .endm |
| 152 | |
| 153 | .macro restore_context_no_interrupts |
| 154 | sp += 4; |
| 155 | SYSCFG = [sp++]; |
| 156 | SEQSTAT = [sp++]; |
| 157 | RETE = [sp++]; |
| 158 | RETN = [sp++]; |
| 159 | RETX = [sp++]; |
| 160 | r0 = [sp++]; |
| 161 | RETI = r0; |
| 162 | RETS = [sp++]; |
| 163 | |
| 164 | sp += 4; |
| 165 | |
| 166 | ASTAT = [sp++]; |
| 167 | |
| 168 | LB1 = [sp++]; |
| 169 | LB0 = [sp++]; |
| 170 | LT1 = [sp++]; |
| 171 | LT0 = [sp++]; |
| 172 | LC1 = [sp++]; |
| 173 | LC0 = [sp++]; |
| 174 | |
| 175 | a1.w = [sp++]; |
| 176 | a1.x = [sp++]; |
| 177 | a0.w = [sp++]; |
| 178 | a0.x = [sp++]; |
| 179 | b3 = [sp++]; |
| 180 | b2 = [sp++]; |
| 181 | b1 = [sp++]; |
| 182 | b0 = [sp++]; |
| 183 | |
| 184 | l3 = [sp++]; |
| 185 | l2 = [sp++]; |
| 186 | l1 = [sp++]; |
| 187 | l0 = [sp++]; |
| 188 | |
| 189 | m3 = [sp++]; |
| 190 | m2 = [sp++]; |
| 191 | m1 = [sp++]; |
| 192 | m0 = [sp++]; |
| 193 | |
| 194 | i3 = [sp++]; |
| 195 | i2 = [sp++]; |
| 196 | i1 = [sp++]; |
| 197 | i0 = [sp++]; |
| 198 | |
| 199 | sp += 4; |
| 200 | fp = [sp++]; |
| 201 | |
| 202 | ( R7 : 0, P5 : 0) = [ SP ++ ]; |
| 203 | sp += 4; |
| 204 | .endm |
| 205 | |
| 206 | .macro restore_context_with_interrupts |
| 207 | sp += 4; |
| 208 | SYSCFG = [sp++]; |
| 209 | SEQSTAT = [sp++]; |
| 210 | RETE = [sp++]; |
| 211 | RETN = [sp++]; |
| 212 | RETX = [sp++]; |
| 213 | RETI = [sp++]; |
| 214 | RETS = [sp++]; |
| 215 | |
| 216 | sp += 4; |
| 217 | |
| 218 | ASTAT = [sp++]; |
| 219 | |
| 220 | LB1 = [sp++]; |
| 221 | LB0 = [sp++]; |
| 222 | LT1 = [sp++]; |
| 223 | LT0 = [sp++]; |
| 224 | LC1 = [sp++]; |
| 225 | LC0 = [sp++]; |
| 226 | |
| 227 | a1.w = [sp++]; |
| 228 | a1.x = [sp++]; |
| 229 | a0.w = [sp++]; |
| 230 | a0.x = [sp++]; |
| 231 | b3 = [sp++]; |
| 232 | b2 = [sp++]; |
| 233 | b1 = [sp++]; |
| 234 | b0 = [sp++]; |
| 235 | |
| 236 | l3 = [sp++]; |
| 237 | l2 = [sp++]; |
| 238 | l1 = [sp++]; |
| 239 | l0 = [sp++]; |
| 240 | |
| 241 | m3 = [sp++]; |
| 242 | m2 = [sp++]; |
| 243 | m1 = [sp++]; |
| 244 | m0 = [sp++]; |
| 245 | |
| 246 | i3 = [sp++]; |
| 247 | i2 = [sp++]; |
| 248 | i1 = [sp++]; |
| 249 | i0 = [sp++]; |
| 250 | |
| 251 | sp += 4; |
| 252 | fp = [sp++]; |
| 253 | |
| 254 | ( R7 : 0, P5 : 0) = [ SP ++ ]; |
| 255 | sp += 4; |
| 256 | .endm |
| 257 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 258 | #endif |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 259 | #endif |