Mercurial > ecos
annotate packages/hal/sparclite/arch/current/src/icontext.c @ 40:a3cc6665b684 ecos-sw-1999-10-01
Merge from eCos master repository on 1999-10-01-07:47:04-BST
| author | jlarmour |
|---|---|
| date | Fri, 01 Oct 1999 13:25:47 +0000 |
| parents | ece80412419a |
| children | c38311975d4f |
| rev | line source |
|---|---|
| 2 | 1 /*============================================================================= |
| 2 // | |
| 3 // icontext.c | |
| 4 // | |
| 5 // SPARClite HAL context init function | |
| 6 // | |
| 7 //============================================================================= | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Cygnus eCos Public License | |
| 12 // Version 1.0 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://sourceware.cygnus.com/ecos | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 22 // September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Cygnus. Portions created | |
| 25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. | |
| 26 // ------------------------------------------- | |
| 27 // | |
| 28 //####COPYRIGHTEND#### | |
| 29 //============================================================================= | |
| 30 //#####DESCRIPTIONBEGIN#### | |
| 31 // | |
| 32 // Author(s): hmt | |
| 33 // Contributors: hmt | |
| 34 // Date: 1998-12-14 | |
| 35 // Purpose: HAL context initialization function | |
| 36 // Description: Initialize a HAL context for SPARClite; this is in C and out | |
| 37 // of line because there is too much of it for a simple macro. | |
| 38 // | |
| 39 //####DESCRIPTIONEND#### | |
| 40 // | |
| 41 //===========================================================================*/ | |
| 42 | |
| 43 #include <pkgconf/hal.h> | |
| 44 | |
| 45 #include <cyg/hal/hal_arch.h> // HAL header | |
| 46 | |
| 47 #include <cyg/infra/cyg_type.h> | |
| 48 | |
| 49 #include <cyg/hal/vectors.h> // SAVE_REGS_SIZE, __WINSIZE, ... | |
| 50 | |
| 51 /*---------------------------------------------------------------------------*/ | |
| 52 | |
| 53 /* We lay out the stack in the manner that the PCS demands: | |
| 54 * frame pointer -----> [top of stack] | |
| 55 * Argument spill area (6 words) | |
| 56 * Return Arg pointer | |
| 57 * Initial saved register window (i[8], l[8]) | |
| 58 * for use by program when it starts | |
| 59 * [rest of] saved register object (various) | |
| 60 * stack pointer -----> saved register window (i[8], l[8]) | |
| 61 * to allow us to be interrupted. | |
| 62 * | |
| 63 * ie. frame pointer -> | |
| 64 * struct HAL_FrameStructure | |
| 65 * stack pointer -> struct HAL_SavedRegisters | |
| 66 * | |
| 67 * and when the context "resumes" sp is incremented by 40 * 4, the size of | |
| 68 * a _struct HAL_SavedRegisters_ which points it at the extant but unused | |
| 69 * _struct HAL_FrameStructure_ as the PCS requires. The frame pointer is | |
| 70 * left pointing off the top of stack. | |
| 71 * | |
| 72 * | |
| 73 * Thus the stack is the same if created from an already executing context: | |
| 74 * | |
| 75 * frame pointer -----> | |
| 76 * [temporaries and locals] | |
| 77 * [more arguments] | |
| 78 * Argument spill area (6 words) | |
| 79 * Return Arg pointer | |
| 80 * [sp at entry]------> Previous saved register window (i[8], l[8]) | |
| 81 * for use by program when it starts | |
| 82 * [rest of] saved register object (various) | |
| 83 * stack pointer -----> saved register window (i[8], l[8]) | |
| 84 * to allow us to be interrupted. | |
| 85 */ | |
| 86 | |
| 87 CYG_ADDRESS | |
| 88 hal_thread_init_context( CYG_WORD sparg, | |
| 89 CYG_WORD thread, | |
| 90 CYG_WORD entry, | |
| 91 CYG_WORD id ) | |
| 92 { | |
| 93 register CYG_WORD fp = sparg; | |
| 94 register CYG_WORD sp = 0; | |
| 95 register HAL_SavedRegisters *regs; | |
| 96 register HAL_FrameStructure *frame; | |
| 97 int i; | |
| 98 | |
| 99 if ( 0 == (id & 0xffff0000) ) | |
| 100 id <<= 16; | |
| 101 | |
|
6
d376b777e2ce
Merge from eCos master repository on 1999-05-14-19:27:43-BST
jlarmour
parents:
2
diff
changeset
|
102 fp &= ~15; // round down to double alignment |
| 2 | 103 |
| 104 frame = (HAL_FrameStructure *)( | |
| 105 fp - sizeof( HAL_FrameStructure ) ); | |
| 106 | |
| 107 regs = (HAL_SavedRegisters *)( | |
| 108 ((CYG_WORD)frame) - sizeof(HAL_SavedRegisters) ); | |
| 109 | |
| 110 sp = (CYG_WORD)regs; | |
| 111 | |
| 112 for ( i = 0; i < 6; i++ ) { | |
| 113 frame->spill_args[i] = id | 0xa0 | i; | |
| 114 } | |
| 115 frame->composite_return_ptr = 0; | |
| 116 | |
| 117 for ( i = 0; i < 8; i++ ) { | |
| 118 frame->li.i[i] = id | ( 56 + i ); | |
| 119 frame->li.l[i] = id | ( 48 + i ); | |
| 120 regs ->li.i[i] = id | ( 24 + i ); | |
| 121 regs ->li.l[i] = id | ( 16 + i ); | |
| 122 regs ->o[i] = id | ( 8 + i ); | |
| 123 regs ->g[i] = id | ( i ); | |
| 124 } | |
| 125 | |
| 126 // first terminate the linked list on the stack in the initial | |
| 127 // (already saved) register window: | |
| 128 frame->li.i[6] = regs->li.i[6] = (cyg_uint32)fp; // frame pointer | |
| 129 frame->li.i[7] = regs->li.i[7] = (cyg_uint32)0; // no ret addr here | |
| 130 | |
| 131 // and set up other saved regs as if called from just before | |
| 132 // the entry point: | |
| 133 regs->o[7] = (entry - 8); | |
| 134 regs->o[6] = sp; | |
| 135 | |
| 136 // this is the argument that the entry point is called with | |
| 137 regs->o[0] = thread; | |
| 138 | |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
139 // this is the initial CWP and interrupt state; CWP is quite arbitrary |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
140 // really, the WIM is set up accordingly in hal_thread_load_context(). |
| 2 | 141 |
|
40
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
142 regs->g[0] = 0x0e0 + __WIN_INIT; // PIL zero, ET, S, PS and CWP set. |
| 2 | 143 |
| 144 return (CYG_ADDRESS)sp; | |
| 145 } | |
| 146 | |
| 147 // --------------------------------------------------------------------------- | |
| 148 | |
| 149 //#define THREAD_DEBUG_SERIAL_VERBOSE | |
| 150 | |
| 151 #ifdef THREAD_DEBUG_SERIAL_VERBOSE // NOT INCLUDED | |
| 152 | |
| 153 // This is unpleasant to try to debug, because these routines are called | |
| 154 // WHEN THE PROGRAM IS NOT RUNNING from the CygMon's GDB stubs - so you | |
| 155 // can't use any normal output: these little routines use the serial | |
| 156 // line directly, so are best used when debugging via Ethernet, so you | |
| 157 // just have a separate output stream to read. Nasty... | |
| 158 | |
| 159 #include <cyg/hal/hal_diag.h> | |
| 160 | |
| 161 #undef HAL_DIAG_WRITE_CHAR | |
| 162 #define HAL_DIAG_WRITE_CHAR(_c_) CYG_MACRO_START \ | |
| 163 SLEB_LED = (_c_); \ | |
| 164 HAL_DIAG_WRITE_CHAR_DIRECT( _c_ ); \ | |
| 165 CYG_MACRO_END | |
| 166 | |
| 167 static void swritec( char c ) | |
| 168 { | |
| 169 HAL_DIAG_WRITE_CHAR( c ); | |
| 170 } | |
| 171 | |
| 172 static void swrites( char *s ) | |
| 173 { | |
| 174 char c; | |
| 175 while ( 0 != (c = *s++) ) | |
| 176 HAL_DIAG_WRITE_CHAR( c ); | |
| 177 } | |
| 178 | |
| 179 static void swritex( cyg_uint32 x ) | |
| 180 { | |
| 181 int i; | |
| 182 swrites( "0x" ); | |
| 183 for ( i = 28; i >= 0; i-= 4 ) { | |
| 184 char c = "0123456789abcdef"[ 0xf & (x >> i) ]; | |
| 185 HAL_DIAG_WRITE_CHAR( c ); | |
| 186 } | |
| 187 } | |
| 188 | |
| 189 #define newline() swrites( "\n\r" ) | |
| 190 | |
| 191 static void x8( char *s, unsigned long *xp ) | |
| 192 { | |
| 193 int i; | |
| 194 for ( i = 0; i < 8; i++ ) { | |
| 195 swrites( s ); | |
| 196 swritec( '0' + i ); | |
| 197 swrites( " = " ); | |
| 198 swritex( xp[i] ); | |
| 199 if ( 3 == (i & 3) ) | |
| 200 newline(); | |
| 201 else | |
| 202 swrites( " " ); | |
| 203 } | |
| 204 } | |
| 205 | |
| 206 #endif // THREAD_DEBUG_SERIAL_VERBOSE ... NOT INCLUDED | |
| 207 | |
| 208 // --------------------------------------------------------------------------- | |
| 209 // Routines in icontext.c used here because they're quite large for | |
| 210 // the SPARClite (note param order); these are used in talking to GDB. | |
| 211 | |
| 212 enum regnames {G0 = 0, G1, G2, G3, G4, G5, G6, G7, | |
| 213 O0, O1, O2, O3, O4, O5, SP, O7, | |
| 214 L0, L1, L2, L3, L4, L5, L6, L7, | |
| 215 I0, I1, I2, I3, I4, I5, FP, I7, | |
| 216 | |
| 217 F0, F1, F2, F3, F4, F5, F6, F7, | |
| 218 F8, F9, F10, F11, F12, F13, F14, F15, | |
| 219 F16, F17, F18, F19, F20, F21, F22, F23, | |
| 220 F24, F25, F26, F27, F28, F29, F30, F31, | |
| 221 Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR}; | |
| 222 | |
| 223 typedef unsigned long target_register_t; | |
| 224 | |
| 225 void | |
| 226 cyg_hal_sparc_get_gdb_regs( void *gdb_regset, | |
| 227 HAL_SavedRegisters *eCos_regset ) | |
| 228 { | |
| 229 target_register_t *gdb = (target_register_t *)gdb_regset; | |
| 230 int reg; | |
| 231 cyg_uint32 scratch = 0; | |
| 232 cyg_uint32 *sptrap; | |
| 233 HAL_SavedWindow *trapli, *ctxli; | |
| 234 | |
| 235 if ( 0 == eCos_regset->g[0] || | |
| 236 0xc0 == (0xe0 & eCos_regset->g[0]) ) { | |
| 237 // Then it's an interrupt stack saved state: | |
| 238 // (either minimal, or a saved PSR with traps disabled) | |
| 239 // The saved register set is pretty minimal, so we have to grub | |
| 240 // around in the stack to find out some truth... | |
| 241 sptrap = (cyg_uint32 *)eCos_regset; // point to the IL save area for | |
| 242 sptrap -= 24; // the trap handler, for PC, NPC | |
| 243 trapli = (HAL_SavedWindow *)sptrap; // Get at those regs | |
| 244 | |
| 245 ctxli = (HAL_SavedWindow *)(trapli->i[6]); // (the frame pointer) | |
| 246 // and get at the interruptee's regs | |
| 247 | |
| 248 // Pick up interruptee's registers from all over the stack: | |
| 249 for ( reg = 0; reg < 8 ; reg++ ) { | |
| 250 gdb[ G0 + reg ] = eCos_regset->g[reg]; | |
| 251 gdb[ O0 + reg ] = trapli->i[reg]; | |
| 252 gdb[ L0 + reg ] = ctxli->l[reg]; | |
| 253 gdb[ I0 + reg ] = ctxli->i[reg]; | |
| 254 } | |
| 255 | |
| 256 // Clear out G0 which is always 0 (but abused in eCos_regset) | |
| 257 // and the FP regs which we do not have: | |
| 258 gdb[ G0 ] = 0; | |
| 259 for ( reg = F0; reg <= F31; reg++ ) | |
| 260 gdb[ reg ] = 0; | |
| 261 | |
| 262 // In the save context _of the trap handler_ registers are as follows: | |
| 263 // %l0 = psr (with this CWP/window-level in it) | |
| 264 // %l1 = pc | |
| 265 // %l2 = npc | |
| 266 // %l3 = vector number (1-15 for interrupts) | |
| 267 // %l4 = Y register preserved | |
| 268 gdb[ Y ] = trapli->l[4]; | |
| 269 | |
| 270 scratch = trapli->l[0]; // the PSR in the trap handler | |
|
40
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
271 #if 8 == __WINSIZE |
| 2 | 272 scratch++; // back to interupted thread's window |
|
40
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
273 scratch &=~ 0x38; // clear ET and any __WINSIZE overflow |
| 2 | 274 gdb[ PSR ] = scratch; |
| 275 gdb[ WIM ] = 1 << ((__WINBITS & (1 + scratch))); | |
|
40
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
276 #else // 6 or 7 windows only |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
277 reg = (int)(scratch & __WINBITS); |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
278 scratch &=~ (__WINBITS_MAXIMAL | 0x20); // clear ET and CWP |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
279 if ( __WINSIZE <= ++reg ) reg = 0; // back to intr'd window |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
280 gdb[ PSR ] = scratch | reg; |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
281 if ( __WINSIZE <= ++reg ) reg = 0; // good index for WIM |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
282 gdb[ WIM ] = 1 << reg; |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
283 #endif // __WINSIZE |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
284 |
| 2 | 285 // Read _a_ TBR value and ignore the current trap details: |
| 286 asm volatile ( "rd %%tbr, %0" : "=r"(scratch) : ); | |
| 287 gdb[ TBR ] = (scratch &~ 0xfff); | |
| 288 | |
| 289 gdb[ PC ] = trapli->l[1]; | |
| 290 gdb[ NPC ] = trapli->l[2]; | |
| 291 | |
| 292 gdb[ FPSR ] = 0; | |
| 293 gdb[ CPSR ] = 0; | |
| 294 | |
| 295 #ifdef THREAD_DEBUG_SERIAL_VERBOSE | |
| 296 newline(); | |
| 297 swrites( "-----------------------------------------------------" ); newline(); | |
| 298 swrites( "-------------- INTERRUPT STACK GET ------------------" ); newline(); | |
| 299 swrites( "eCos regset at " ); swritex( eCos_regset ); newline(); | |
| 300 swrites( " trapli " ); swritex( trapli ); newline(); | |
| 301 swrites( " ctxli " ); swritex( ctxli ); newline(); | |
| 302 x8( "global ", &(gdb[G0]) ); | |
| 303 x8( " in ", &(gdb[I0]) ); | |
| 304 x8( " local ", &(gdb[L0]) ); | |
| 305 x8( " out ", &(gdb[O0]) ); | |
| 306 swrites( "gdb PC = " ); swritex( gdb[ PC ] ); newline(); | |
| 307 swrites( "gdb NPC = " ); swritex( gdb[ NPC ] ); newline(); | |
| 308 swrites( "gdb PSR = " ); swritex( gdb[ PSR ] ); newline(); | |
| 309 #endif | |
| 310 | |
| 311 } | |
| 312 else { | |
| 313 // It's a synchronous context switch that led to this object. | |
| 314 // Pick up interruptee's registers from the saved context: | |
| 315 for ( reg = 0; reg < 8 ; reg++ ) { | |
| 316 #ifdef CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM | |
| 317 gdb[ G0 + reg ] = 0; | |
| 318 gdb[ O0 + reg ] = 0; | |
| 319 #else | |
| 320 gdb[ G0 + reg ] = eCos_regset->g[reg]; | |
| 321 gdb[ O0 + reg ] = eCos_regset->o[reg]; | |
| 322 #endif | |
| 323 gdb[ L0 + reg ] = eCos_regset->li.l[reg]; | |
| 324 gdb[ I0 + reg ] = eCos_regset->li.i[reg]; | |
| 325 } | |
| 326 | |
| 327 #ifdef CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM | |
| 328 // Set up the stack pointer by arithmetic and the return address | |
| 329 gdb[ SP ] = ((cyg_uint32)(eCos_regset)); | |
| 330 gdb[ O7 ] = eCos_regset->o[ 7 ]; | |
| 331 #else | |
| 332 // Clear out G0 which is always 0 (but abused in eCos_regset) | |
| 333 gdb[ G0 ] = 0; | |
| 334 #endif | |
| 335 // and clear the FP regs which we do not have: | |
| 336 for ( reg = F0; reg <= F31; reg++ ) | |
| 337 gdb[ reg ] = 0; | |
| 338 | |
| 339 gdb[ Y ] = 0; // it's not preserved. | |
| 340 | |
| 341 scratch = eCos_regset->g[ 0 ]; // the PSR in the saved context | |
| 342 gdb[ PSR ] = scratch; // return it verbatim. | |
|
40
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
343 #if 8 == __WINSIZE |
| 2 | 344 gdb[ WIM ] = 1 << ((__WINBITS & (1 + scratch))); |
|
40
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
345 #else // 6 or 7 windows only |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
346 reg = (int)(scratch & __WINBITS); |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
347 if ( __WINSIZE <= ++reg ) reg = 0; // good index for WIM |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
348 gdb[ WIM ] = 1 << reg; |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
8
diff
changeset
|
349 #endif // __WINSIZE |
| 2 | 350 |
| 351 // Read _a_ TBR value and ignore the current trap details: | |
| 352 asm volatile ( "rd %%tbr, %0" : "=r"(scratch) : ); | |
| 353 gdb[ TBR ] = (scratch &~ 0xfff); | |
| 354 | |
| 355 gdb[ PC ] = eCos_regset->o[ 7 ]; // the return address | |
| 356 gdb[ NPC ] = 4 + gdb[ PC ]; | |
| 357 | |
| 358 gdb[ FPSR ] = 0; | |
| 359 gdb[ CPSR ] = 0; | |
| 360 | |
| 361 #ifdef THREAD_DEBUG_SERIAL_VERBOSE | |
| 362 newline(); | |
| 363 swrites( "-----------------------------------------------------" ); newline(); | |
| 364 swrites( "-------------- SYNCHRONOUS SWITCH GET----------------" ); newline(); | |
| 365 swrites( "eCos regset at " ); swritex( eCos_regset ); newline(); | |
| 366 x8( "global ", &(gdb[G0]) ); | |
| 367 x8( " in ", &(gdb[I0]) ); | |
| 368 x8( " local ", &(gdb[L0]) ); | |
| 369 x8( " out ", &(gdb[O0]) ); | |
| 370 swrites( "gdb PC = " ); swritex( gdb[ PC ] ); newline(); | |
| 371 swrites( "gdb NPC = " ); swritex( gdb[ NPC ] ); newline(); | |
| 372 swrites( "gdb PSR = " ); swritex( gdb[ PSR ] ); newline(); | |
| 373 #endif | |
| 374 } | |
| 375 | |
| 376 } | |
| 377 | |
| 378 // --------------------------------------------------------------------------- | |
| 379 | |
| 380 void | |
| 381 cyg_hal_sparc_set_gdb_regs( HAL_SavedRegisters *eCos_regset, | |
| 382 void *gdb_regset ) | |
| 383 { | |
| 384 target_register_t *gdb = (target_register_t *)gdb_regset; | |
| 385 int reg; | |
| 386 cyg_uint32 scratch = 0; | |
| 387 cyg_uint32 *sptrap; | |
| 388 HAL_SavedWindow *trapli, *ctxli; | |
| 389 | |
| 390 // Guess where the eCos register set really is: | |
| 391 if ( 0 == eCos_regset->g[0] || | |
| 392 0xc0 == (0xe0 & eCos_regset->g[0]) ) { | |
| 393 // Then it's an interrupt stack saved state: | |
| 394 // (either minimal, or a saved PSR with traps disabled) | |
| 395 // The saved register set is pretty minimal, so we have to grub | |
| 396 // around in the stack to find out some truth... | |
| 397 sptrap = (cyg_uint32 *)eCos_regset; // point to the IL save area for | |
| 398 sptrap -= 24; // the trap handler, for PC, NPC | |
| 399 trapli = (HAL_SavedWindow *)sptrap; // Get at those regs | |
| 400 | |
| 401 ctxli = (HAL_SavedWindow *)(trapli->i[6]); // (the frame pointer) | |
| 402 // and get at the interruptee's regs | |
| 403 | |
| 404 scratch = eCos_regset->g[0]; | |
| 405 | |
| 406 // Put back interruptee's registers all over the stack: | |
| 407 for ( reg = 0; reg < 8 ; reg++ ) { | |
| 408 eCos_regset->g[reg] = gdb[ G0 + reg ] ; | |
| 409 trapli->i[reg] = gdb[ O0 + reg ] ; | |
| 410 ctxli->l[reg] = gdb[ L0 + reg ] ; | |
| 411 ctxli->i[reg] = gdb[ I0 + reg ] ; | |
| 412 } | |
| 413 | |
| 414 // Put back the eCos G0 which is always 0 (but abused in eCos_regset) | |
| 415 eCos_regset->g[0] = scratch; | |
| 416 | |
| 417 // In the save context _of the trap handler_ registers are as follows: | |
| 418 // %l0 = psr (with this CWP/window-level in it) | |
| 419 // %l1 = pc | |
| 420 // %l2 = npc | |
| 421 // %l3 = vector number (1-15 for interrupts) | |
| 422 // %l4 = Y register preserved | |
| 423 trapli->l[4] = gdb[ Y ]; | |
| 424 | |
| 425 // I am *not* interfering with the saved PSR, nor the TBR nor WIM. | |
| 426 | |
| 427 // put back return PC and NPC | |
| 428 trapli->l[1] = gdb[ PC ] ; | |
| 429 trapli->l[2] = gdb[ NPC ]; | |
| 430 | |
| 431 #ifdef THREAD_DEBUG_SERIAL_VERBOSE | |
| 432 newline(); | |
| 433 swrites( "-----------------------------------------------------" ); newline(); | |
| 434 swrites( "-------------- INTERRUPT STACK SET ------------------" ); newline(); | |
| 435 swrites( "eCos regset at " ); swritex( eCos_regset ); newline(); | |
| 436 swrites( " trapli " ); swritex( trapli ); newline(); | |
| 437 swrites( " ctxli " ); swritex( ctxli ); newline(); | |
| 438 x8( "global ", &(gdb[G0]) ); | |
| 439 x8( " in ", &(gdb[I0]) ); | |
| 440 x8( " local ", &(gdb[L0]) ); | |
| 441 x8( " out ", &(gdb[O0]) ); | |
| 442 swrites( "gdb PC = " ); swritex( gdb[ PC ] ); newline(); | |
| 443 swrites( "gdb NPC = " ); swritex( gdb[ NPC ] ); newline(); | |
| 444 swrites( "gdb PSR = " ); swritex( gdb[ PSR ] ); newline(); | |
| 445 #endif | |
| 446 | |
| 447 } | |
| 448 else { | |
| 449 // It's a synchronous context switch that led to this object. | |
| 450 // Pick up interruptee's registers from the saved context: | |
| 451 | |
| 452 scratch = eCos_regset->g[0]; | |
| 453 | |
| 454 for ( reg = 0; reg < 8 ; reg++ ) { | |
| 455 eCos_regset->g[reg] = gdb[ G0 + reg ]; | |
| 456 eCos_regset->o[reg] = gdb[ O0 + reg ]; | |
| 457 eCos_regset->li.l[reg] = gdb[ L0 + reg ]; | |
| 458 eCos_regset->li.i[reg] = gdb[ I0 + reg ]; | |
| 459 } | |
| 460 | |
| 461 // Put back the eCos G0 which is always 0 (but abused in eCos_regset) | |
| 462 eCos_regset->g[0] = scratch; | |
| 463 | |
| 464 // I am *not* interfering with the saved PSR, nor the TBR nor WIM. | |
| 465 | |
| 466 // The PC is in o7, altering it via GDB's PC is not on. | |
| 467 // Setting the NPC in a voluntary context is meaningless. | |
| 468 | |
| 469 #ifdef THREAD_DEBUG_SERIAL_VERBOSE | |
| 470 newline(); | |
| 471 swrites( "-----------------------------------------------------" ); newline(); | |
| 472 swrites( "-------------- SYNCHRONOUS SWITCH SET ---------------" ); newline(); | |
| 473 swrites( "eCos regset at " ); swritex( eCos_regset ); newline(); | |
| 474 x8( "global ", &(gdb[G0]) ); | |
| 475 x8( " in ", &(gdb[I0]) ); | |
| 476 x8( " local ", &(gdb[L0]) ); | |
| 477 x8( " out ", &(gdb[O0]) ); | |
| 478 swrites( "gdb PC = " ); swritex( gdb[ PC ] ); newline(); | |
| 479 swrites( "gdb NPC = " ); swritex( gdb[ NPC ] ); newline(); | |
| 480 swrites( "gdb PSR = " ); swritex( gdb[ PSR ] ); newline(); | |
| 481 #endif | |
| 482 } | |
| 483 | |
| 484 } | |
| 485 | |
| 486 /*---------------------------------------------------------------------------*/ | |
| 487 // EOF icontext.c |
