Mercurial > ecos
annotate packages/hal/sparclite/arch/current/src/vec_xvsr.S @ 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 | 443894e2e912 |
| children | c38311975d4f |
| rev | line source |
|---|---|
| 2 | 1 /*=========================================================================== |
| 2 // | |
| 3 // vec_xvsr.S | |
| 4 // | |
| 5 // SPARClite vectors: exception vector service routine | |
| 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: 1999-02-20 | |
| 35 // Purpose: SPARClite vector code | |
| 36 // Description: see vectors.S; this is the default vector service routine | |
| 37 // for exceptions. | |
| 38 // | |
| 39 //####DESCRIPTIONEND#### | |
| 40 // | |
| 41 //=========================================================================*/ | |
| 42 | |
| 43 !----------------------------------------------------------------------------- | |
| 44 | |
| 45 .file "vec_xvsr.S" | |
| 46 | |
| 47 !---------------------------------------------------------------------------- | |
| 48 | |
| 49 #include <pkgconf/system.h> | |
| 50 #include <pkgconf/hal.h> | |
| 51 | |
| 52 #ifdef CYGPKG_KERNEL | |
| 53 # include <pkgconf/kernel.h> | |
| 54 #endif | |
| 55 | |
| 56 !------------------------------------------------------------------------ | |
| 57 | |
| 58 #include <cyg/hal/vectors.h> | |
| 59 | |
| 60 #define DELAYS_AFTER_WRPSR_SAME_WINDOW | |
| 61 #define DELAYS_AFTER_WRWIM | |
| 62 | |
| 63 !------------------------------------------------------------------------ | |
| 64 | |
| 65 .text | |
| 66 | |
| 67 !--------------------------------------------------------------------------- | |
| 68 ! default exception handler VSR, which calls the appropriate ISR after | |
| 69 ! interrupt masking - much the same as the interrupt VSR but does not lock | |
| 70 ! scheduler or call interrupt_end(). | |
| 71 | |
| 72 .global hal_default_exception_vsr | |
| 73 hal_default_exception_vsr: | |
| 74 ! here,locals have been set up as follows: | |
| 75 ! %l0 = psr (with this CWP/window-level in it) | |
| 76 ! %l1 = pc | |
| 77 ! %l2 = npc | |
| 78 ! %l3 = vector number (16-25 for traps) | |
| 79 ! and we are in our own register window, though it is likely that | |
| 80 ! the next one will need to be saved before we can use it: | |
| 81 ! ie. this one is the invalid register window. | |
| 82 | |
| 83 ! must establish a safe stack before re-enabling interrupts + traps | |
| 84 and %l0, __WINBITS, %l7 ! CWP extracted | |
|
40
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
85 ! no inc/dec here, so no need for special measures for not-8-windows |
| 2 | 86 mov 1, %l6 |
| 87 sll %l6, %l7, %l6 ! 1 << CWP | |
| 88 rd %wim, %l5 | |
| 89 cmp %l5, %l6 ! are they the same? | |
| 90 bne 1f ! No, so the stack is OK as is. | |
| 91 | |
| 92 ! now do by hand an overflow trap, effectively | |
| 93 mov %g1, %l7 ! (DELAY SLOT) | |
| 94 srl %l5, 1, %l5 | |
| 95 sll %l6, __WINSIZE-1, %l6 | |
| 96 or %l6, %l5, %g1 ! new WIM in %g1 so we can get it | |
| 97 ! within the save: | |
| 98 save ! Slip into next window | |
| 99 mov %g1, %wim ! Install the new wim | |
| 100 ! (invalidates current window!) | |
| 101 #ifdef DELAYS_AFTER_WRWIM | |
| 102 nop | |
| 103 nop | |
| 104 nop | |
| 105 #endif | |
| 106 | |
| 107 std %l0, [%sp + 0 * 4] ! save L & I registers | |
| 108 std %l2, [%sp + 2 * 4] | |
| 109 std %l4, [%sp + 4 * 4] | |
| 110 std %l6, [%sp + 6 * 4] | |
| 111 | |
| 112 std %i0, [%sp + 8 * 4] | |
| 113 std %i2, [%sp + 10 * 4] | |
| 114 std %i4, [%sp + 12 * 4] | |
| 115 std %i6, [%sp + 14 * 4] | |
| 116 | |
| 117 restore ! Go back to trap window. | |
| 118 mov %l7, %g1 ! Restore %g1 | |
| 119 | |
| 120 1: ! now save away the regs we must preserve | |
| 121 sub %fp, 32 * 4, %sp | |
| 122 ! save a maximal context regardless: see also | |
| 123 ! CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT | |
| 124 std %l0, [%sp + 0 * 4] ! save L & I registers | |
| 125 std %l2, [%sp + 2 * 4] | |
| 126 std %l4, [%sp + 4 * 4] | |
| 127 std %l6, [%sp + 6 * 4] | |
| 128 | |
| 129 std %i0, [%sp + 8 * 4] | |
| 130 std %i2, [%sp + 10 * 4] | |
| 131 std %i4, [%sp + 12 * 4] | |
| 132 std %i6, [%sp + 14 * 4] | |
| 133 | |
| 134 st %g1, [%sp + 17 * 4] ! save G registers | |
| 135 std %g2, [%sp + 18 * 4] | |
| 136 std %g4, [%sp + 20 * 4] | |
| 137 std %g6, [%sp + 22 * 4] | |
| 138 | |
| 139 ! no point whatsoever in saving O registers | |
| 140 | |
| 141 ! and save the CWP in %g0 save place | |
| 142 st %l0, [%sp + 16 * 4] | |
| 143 | |
| 144 sub %sp, 24 * 4, %sp ! fresh frame including | |
| 145 ! arg spill area for callees | |
| 146 | |
| 147 ! do not lock the scheduler | |
| 148 | |
| 149 ! HELP_GDB_WITH_BACKTRACE | |
| 150 mov %i7, %l5 ! preserve it JIC | |
| 151 mov %l1, %i7 ! bogus return link here | |
| 152 | |
| 153 ! and we must preserve the Y register (multiply/divide auxiliary) | |
| 154 ! over these calls; we will keep it in %l4 which is otherwise unused. | |
| 155 rd %y, %l4 | |
| 156 | |
| 157 ! Now we can reenable traps (preserving interrupt level) | |
| 158 or %l0, 0x0e0, %l7 ! set ET (+S,PS), preserve PIL | |
| 159 wr %l7, %psr ! and enable! | |
| 160 #ifdef DELAYS_AFTER_WRPSR_SAME_WINDOW | |
| 161 nop | |
| 162 nop | |
| 163 nop | |
| 164 #endif | |
| 165 ! now call the XSR and so on with the appropriate args: | |
| 166 ! ie. | |
| 167 ! isr_retcode = (*(hal_interrupt_handlers[ vector ])) | |
| 168 ! ( vector, hal_interrupt_data[ vector ], stackp ); | |
| 169 | |
| 170 ! from hal_arch.h | |
| 171 !// ISR tables | |
| 172 !CYG_ADDRESS hal_interrupt_handlers[CYGNUM_HAL_ISR_COUNT]; | |
| 173 !CYG_ADDRWORD hal_interrupt_data[CYGNUM_HAL_ISR_COUNT]; | |
| 174 !CYG_ADDRESS hal_interrupt_objects[CYGNUM_HAL_ISR_COUNT]; | |
| 175 | |
| 176 mov %l3, %o0 | |
| 177 sll %l3, 2, %l3 ! %l3 to a word offset | |
| 178 sethi %hi(hal_interrupt_data), %l7 | |
| 179 or %l7, %lo(hal_interrupt_data), %l7 | |
| 180 ld [ %l7 + %l3 ], %o1 ! data | |
| 181 add %sp, 24 * 4, %o2 ! stackpointer of saved regset | |
| 182 | |
| 183 sethi %hi(hal_interrupt_handlers), %l7 | |
| 184 or %l7, %lo(hal_interrupt_handlers), %l7 | |
| 185 ld [ %l7 + %l3 ], %l6 | |
| 186 call %l6 | |
| 187 nop | |
| 188 | |
| 189 ! do not call _interrupt_end() | |
| 190 | |
| 191 ! restore the Y register having done our callouts to C | |
| 192 wr %l4, %y | |
| 193 | |
| 194 ! We can reinstall the original CWP here; even if interrupt_end() | |
| 195 ! performed a reschedule (ie. yield/resume pair) we will be in the | |
| 196 ! same window. The window is preserved by reschedule precisely | |
| 197 ! because it is impossible atomically to disable traps here without | |
| 198 ! involving a CWP living in a register for a time when other | |
| 199 ! interrupts may occur. | |
| 200 | |
| 201 ! disable traps (using the saved psr is fastest way) | |
| 202 wr %l0, %psr ! restores flags, disables traps, same PIL. | |
| 203 #ifdef DELAYS_AFTER_WRPSR_SAME_WINDOW | |
| 204 nop | |
| 205 nop | |
| 206 nop | |
| 207 #endif | |
| 208 ! HELP_GDB_WITH_BACKTRACE | |
| 209 mov %l5, %i7 ! restore (unused) return link | |
| 210 | |
| 211 ! and restore other saved regs | |
| 212 add %sp, 24 * 4, %sp ! undo fresh frame | |
| 213 ! restore a maximal context regardless: see also | |
| 214 ! CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT | |
| 215 ldd [%sp + 0 * 4], %l0 ! restore L & I registers | |
| 216 ldd [%sp + 2 * 4], %l2 ! to support the handler | |
| 217 ldd [%sp + 4 * 4], %l4 ! having messed with them. | |
| 218 ldd [%sp + 6 * 4], %l6 | |
| 219 | |
| 220 ldd [%sp + 8 * 4], %i0 | |
| 221 ldd [%sp + 10 * 4], %i2 | |
| 222 ldd [%sp + 12 * 4], %i4 | |
| 223 ldd [%sp + 14 * 4], %i6 | |
| 224 | |
| 225 ld [%sp + 17 * 4], %g1 ! and G registers | |
| 226 ldd [%sp + 18 * 4], %g2 | |
| 227 ldd [%sp + 20 * 4], %g4 | |
| 228 ldd [%sp + 22 * 4], %g6 | |
| 229 ! no point whatsoever in loading back O registers. | |
| 230 | |
| 231 ! Now test for window underflow here and fix up if needs be. | |
| 232 ! | |
| 233 ! Why? interrupt_end() might have yielded us, when only | |
| 234 ! its own frame was restored; its own return to us caused a | |
| 235 ! window underflow trap, as would our return to interruptee | |
| 236 ! unless we deal with it now. | |
| 237 | |
| 238 add %l0, 1, %l7 ! interruptee~s CWP plus noise | |
| 239 and %l7, __WINBITS, %l7 ! CWP only | |
|
40
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
240 #if 8 == __WINSIZE |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
241 ! it is in range already |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
242 #else // expect 5 or 6 or 7 windows |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
243 cmp %l7, __WINSIZE |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
244 bge,a 567f ! taken: do delay slot, handle overflow |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
245 mov 0, %l7 ! only if .ge. above |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
246 567: |
|
a3cc6665b684
Merge from eCos master repository on 1999-10-01-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
247 #endif |
| 2 | 248 mov 1, %l6 |
| 249 sll %l6, %l7, %l6 ! 1 << CWP | |
| 250 rd %wim, %l5 | |
| 251 cmp %l5, %l6 ! are they the same? | |
| 252 bne 2f ! No, so the stack is OK as is. | |
| 253 | |
| 254 ! now do by hand an underflow trap, effectively | |
| 255 sll %l5, 1, %l5 ! Rotate wim left | |
| 256 srl %l6, __WINSIZE-1, %l6 | |
| 257 wr %l5, %l6, %wim | |
| 258 #ifdef DELAYS_AFTER_WRWIM | |
| 259 nop ! are these delays needed? | |
| 260 nop ! (following restore uses wim) | |
| 261 nop | |
| 262 #endif | |
| 263 restore ! Interruptee~s window | |
| 264 ldd [%sp + 0 * 4], %l0 ! restore L & I registers | |
| 265 ldd [%sp + 2 * 4], %l2 | |
| 266 ldd [%sp + 4 * 4], %l4 | |
| 267 ldd [%sp + 6 * 4], %l6 | |
| 268 | |
| 269 ldd [%sp + 8 * 4], %i0 | |
| 270 ldd [%sp + 10 * 4], %i2 | |
| 271 ldd [%sp + 12 * 4], %i4 | |
| 272 ldd [%sp + 14 * 4], %i6 | |
| 273 save ! Back to trap window | |
| 274 | |
| 275 2: ! restore the condition codes, PSR and PIL and return from trap. | |
| 276 wr %l0, %psr ! restores flags, disables traps, and old PIL | |
| 277 #ifdef DELAYS_AFTER_WRPSR_SAME_WINDOW | |
| 278 nop | |
| 279 nop | |
| 280 nop | |
| 281 #endif | |
| 282 jmpl %l1, %g0 | |
| 283 rett %l2 | |
| 284 | |
| 285 | |
| 286 ! end of vec_xvsr.S |
