Mercurial > flash_v2
annotate packages/hal/powerpc/arch/current/src/vectors.S @ 18:7253dcc42a09 ecos-sw-1999-06-25
Merge from eCos master repository on 1999-06-25-15:31:50-BST
| author | jlarmour |
|---|---|
| date | Fri, 25 Jun 1999 08:28:05 +0000 |
| parents | 4f2df4ab82c8 |
| children | 5f5102441818 |
| rev | line source |
|---|---|
| 2 | 1 ##========================================================================== |
| 0 | 2 ## |
| 3 ## vectors.S | |
| 4 ## | |
| 5 ## PowerPC exception vectors | |
| 6 ## | |
| 2 | 7 ##========================================================================== |
| 0 | 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 | |
| 2 | 25 # by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
| 0 | 26 # ------------------------------------------- |
| 27 # | |
| 28 #####COPYRIGHTEND#### | |
| 2 | 29 ##========================================================================== |
| 0 | 30 #######DESCRIPTIONBEGIN#### |
| 31 ## | |
| 2 | 32 ## Author(s): nickg, jskov |
| 33 ## Contributors: nickg, jskov | |
| 34 ## Date: 1999-02-20 | |
| 35 ## Purpose: PowerPC exception vectors | |
| 36 ## Description: This file defines the code placed into the exception | |
| 37 ## vectors. It also contains the first level default VSRs | |
| 38 ## that save and restore state for both exceptions and | |
| 39 ## interrupts. | |
| 0 | 40 ## |
| 41 ######DESCRIPTIONEND#### | |
| 42 ## | |
| 2 | 43 ##========================================================================== |
| 0 | 44 |
| 45 #include <pkgconf/hal.h> | |
| 46 | |
| 47 #ifdef CYGPKG_KERNEL | |
| 48 #include <pkgconf/kernel.h> // CYGPKG_KERNEL_INSTRUMENT | |
| 49 #endif | |
| 2 | 50 |
| 51 #define CYGARC_HAL_COMMON_EXPORT_CPU_MACROS | |
| 52 #include "cyg/hal/ppc_regs.h" | |
| 0 | 53 #include "cyg/hal/ppc.inc" |
| 54 | |
| 2 | 55 #=========================================================================== |
| 0 | 56 |
| 57 .file "vectors.S" | |
| 58 | |
| 59 .extern hal_interrupt_handlers | |
| 60 .extern hal_interrupt_data | |
| 61 .extern hal_interrupt_objects | |
| 62 | |
| 63 .extern cyg_instrument | |
| 64 | |
| 65 .extern hal_hardware_init | |
| 66 | |
| 2 | 67 #=========================================================================== |
| 0 | 68 # MSR initialization value |
| 69 # zero all bits except: | |
| 70 # FP = floating point available | |
| 71 # ME = machine check enabled | |
| 72 # IP = vectors at 0xFFFxxxxx (ROM startup only) | |
| 2 | 73 # IR = instruction address translation |
| 74 # DR = data address translation | |
| 0 | 75 # RI = recoverable interrupt |
| 76 | |
| 2 | 77 #define CYG_MSR_COMMON (MSR_FP | MSR_ME | MSR_IR | MSR_DR | MSR_RI) |
| 78 #if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_STUBS) | |
|
16
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
14
diff
changeset
|
79 # ifdef CYG_HAL_POWERPC_COPY_VECTORS |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
14
diff
changeset
|
80 # define CYG_MSR CYG_MSR_COMMON |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
14
diff
changeset
|
81 # else |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
14
diff
changeset
|
82 # define CYG_MSR (CYG_MSR_COMMON | MSR_IP) |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
14
diff
changeset
|
83 # endif |
| 0 | 84 #endif |
| 85 #ifdef CYG_HAL_STARTUP_RAM | |
| 2 | 86 #define CYG_MSR CYG_MSR_COMMON |
| 87 #endif | |
| 88 #ifdef CYG_HAL_POWERPC_SIM | |
|
14
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
10
diff
changeset
|
89 # When building for SIM, don~t enable MMU -- it~s not needed since caches |
| 2 | 90 # are disabled, and there is a runtime simulation overhead. |
| 91 #undef CYG_MSR | |
| 92 #define CYG_MSR (CYG_MSR_COMMON & ~(MSR_IR | MSR_DR)) | |
| 0 | 93 #endif |
| 94 | |
| 2 | 95 #=========================================================================== |
| 0 | 96 # If the following option is enabled, we only save registers up to R12. |
| 97 # The PowerPC ABI defines registers 13..31 as callee saved and thus we do | |
| 98 # not need to save them when calling C functions. | |
| 99 | |
| 100 #ifdef CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT | |
| 101 | |
| 2 | 102 #define MAX_SAVE_REG 12 |
| 0 | 103 |
| 104 #else | |
| 105 | |
| 106 #define MAX_SAVE_REG 31 | |
| 107 | |
| 108 #endif | |
| 109 | |
| 2 | 110 #=========================================================================== |
| 0 | 111 # Start by defining the exceptions vectors that must be placed at |
| 112 # locations 0xFFF00000 and 0x00000000. The following code will normally | |
| 113 # be located at 0xFFF00000 in the ROM. It may optionally be copied out | |
| 114 # to 0x00000000 if we want to use the RAM vectors. For this reason this code | |
| 115 # MUST BE POSITION INDEPENDENT. In RAM loaded configurations, this code may | |
| 116 # be placed at 0x00000000 during loading. | |
| 117 | |
| 118 .section ".vectors","ax" | |
| 119 | |
| 2 | 120 #--------------------------------------------------------------------------- |
| 0 | 121 # Unused first vector. |
| 122 | |
| 123 rom_vectors: | |
| 124 lwi r3,_start | |
| 125 mtlr r3 | |
| 126 blr | |
| 127 | |
| 128 .byte 0x11 | |
| 129 .byte 0x22 | |
| 130 .byte 0x33 | |
| 131 .byte 0x44 | |
| 132 | |
| 2 | 133 #--------------------------------------------------------------------------- |
| 0 | 134 # Reset vector. |
| 135 | |
| 136 .p2align 8 | |
| 137 .globl reset_vector | |
| 138 | |
| 139 reset_vector: | |
| 140 lwi r3,_start | |
| 141 mtlr r3 | |
| 142 blr | |
| 143 | |
| 2 | 144 #--------------------------------------------------------------------------- |
| 0 | 145 # Macro for generating an exception vector service routine |
| 146 | |
| 147 .macro exception_vector name | |
| 148 .p2align 8 | |
| 149 .globl __exception_\name | |
| 150 __exception_\name: | |
| 2 | 151 mtspr SPRG1,r3 # stash some work registers away |
| 152 mtspr SPRG2,r4 | |
| 153 mtspr SPRG3,r5 | |
| 0 | 154 mfcr r4 # stash CR |
| 155 li r5,__exception_\name@L # load low half of vector address | |
| 156 srwi r5,r5,6 # shift right by 6 | |
| 157 lwi r3,hal_vsr_table # table base | |
| 158 lwzx r3,r3,r5 # address of vsr | |
| 159 mflr r5 # save link register | |
| 160 mtlr r3 # put vsr address into it | |
| 161 li r3,__exception_\name@L # reload low half of vector address | |
| 162 blr # go to common code | |
| 163 .endm | |
| 164 | |
| 2 | 165 #--------------------------------------------------------------------------- |
| 0 | 166 # Define the exception vectors. |
| 167 | |
| 168 # These are the architecture defined vectors that | |
| 169 # are always present. | |
| 170 | |
| 171 exception_vector machine_check | |
| 172 exception_vector data_storage | |
| 173 exception_vector instruction_storage | |
| 174 exception_vector external | |
| 175 exception_vector alignment | |
| 2 | 176 #if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_STUBS) \ |
| 177 || defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) | |
| 0 | 178 exception_vector program |
| 2 | 179 #else |
| 180 # Provide a crude hook to the GDB exception handler in ROM. | |
| 181 # This allows the testing infrastructure to rely on breakpoints | |
| 182 # to terminate tests, even when the tests are compiled without | |
| 183 # the GDB stub. | |
| 184 # It is _not_ a generic solution to the problem; in particular it | |
| 185 # is not possible to continue after a breakpoint is hit. | |
|
18
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
186 # |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
187 # Note that for platforms where StubROM vectors are copied into RAM |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
188 # at 0x00000000, simply skipping the copy of vector 0x700 is a |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
189 # better solution. See CYGPRI_STUBROM_HAS_RAM_VECTORS below. |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
190 |
| 2 | 191 .p2align 8 |
| 192 .globl __exception_program | |
| 193 __exception_program: | |
| 194 bl _init_CPU # disable caches. | |
| 195 lwi r3,0xfff00700 # address of trap handler | |
| 196 mtlr r3 # in ROM. | |
| 197 blr # jump to it. | |
| 198 | |
| 199 #endif | |
| 0 | 200 exception_vector floatingpoint_unavailable |
| 201 exception_vector decrementer | |
| 202 exception_vector reserved_00a00 | |
| 203 exception_vector reserved_00b00 | |
| 204 exception_vector system_call | |
| 205 exception_vector trace | |
| 206 exception_vector floatingpoint_assist | |
| 207 exception_vector reserved_00f00 | |
| 208 | |
| 209 # There are some additional vectors defined | |
| 210 # on various implementations. | |
| 211 | |
| 2 | 212 #ifdef CYG_HAL_POWERPC_MPC8xx |
| 213 # MPC8xx vectors | |
| 0 | 214 |
| 215 exception_vector software_emu | |
| 216 exception_vector instruction_tlb_miss | |
| 217 exception_vector data_tlb_miss | |
| 218 exception_vector instruction_tlb_error | |
| 219 exception_vector data_tlb_error | |
| 220 exception_vector reserved_01500 | |
| 221 exception_vector reserved_01600 | |
| 222 exception_vector reserved_01700 | |
| 223 exception_vector reserved_01800 | |
| 224 exception_vector reserved_01900 | |
| 225 exception_vector reserved_01A00 | |
| 226 exception_vector reserved_01B00 | |
| 227 exception_vector data_breakpoint | |
| 228 exception_vector instruction_breakpoint | |
| 229 exception_vector peripheral_breakpoint | |
| 230 exception_vector NMI_port | |
| 231 | |
| 2 | 232 #endif |
| 0 | 233 rom_vectors_end: |
| 234 | |
| 2 | 235 #=========================================================================== |
| 236 # Real startup code. We jump here from the various reset vectors to set up | |
| 237 # the world. | |
| 0 | 238 |
| 239 .text | |
| 240 .globl _start | |
| 241 | |
| 2 | 242 _start: |
| 243 # Initialize CPU | |
| 244 bl _init_CPU | |
| 0 | 245 |
| 2 | 246 #ifdef CYG_HAL_POWERPC_MPC8xx |
| 247 # Disable special MPC8xx "development support" which | |
| 248 # suppresses trace exceptions. The CPU seems to hang, not | |
| 249 # executing from offset 0x1e00(?) as expected. | |
|
16
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
14
diff
changeset
|
250 |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
14
diff
changeset
|
251 lwi r3,0x00000007 |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
14
diff
changeset
|
252 mtspr ICTRL,r3 |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
14
diff
changeset
|
253 |
| 0 | 254 li r3,0 |
| 2 | 255 mtspr DER, r3 |
| 0 | 256 #endif |
| 257 | |
| 258 # Set up global offset table | |
| 259 lwi r2,_GLOBAL_OFFSET_TABLE_ | |
| 260 | |
| 261 # set up time base register to zero | |
| 262 xor r3,r3,r3 | |
| 2 | 263 mtspr TBL_W,r3 |
| 0 | 264 xor r4,r4,r4 |
| 2 | 265 mtspr TBU_W,r4 |
| 266 | |
| 267 # Call platform specific hardware initialization | |
| 268 # This may include memory controller initialization. It is not | |
| 269 # safe to access RAM until after this point. | |
|
16
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
14
diff
changeset
|
270 bl hal_hardware_init # this is platform dependent |
| 0 | 271 |
| 272 # set up stack | |
| 273 lwi sp,__interrupt_stack | |
| 2 | 274 mtspr SPRG0,sp # save in sprg0 for later use |
| 0 | 275 |
| 2 | 276 #if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_STUBS) |
| 0 | 277 |
| 278 # Copy data from ROM to ram | |
| 279 lwi r3,__rom_data_start # r3 = rom start | |
| 280 lwi r4,__ram_data_start # r4 = ram start | |
| 281 lwi r5,__ram_data_end # r5 = ram end | |
| 282 | |
| 283 cmplw r4,r5 # skip if no data | |
| 284 beq 2f | |
| 285 | |
| 286 1: | |
| 287 lwz r0,0(r3) # get word from ROM | |
| 288 stw r0,0(r4) # store in RAM | |
| 289 addi r3,r3,4 # increment by 1 word | |
| 290 addi r4,r4,4 # increment by 1 word | |
| 291 cmplw r4,r5 # compare | |
| 292 blt 1b # loop if not yet done | |
| 293 2: | |
|
14
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
10
diff
changeset
|
294 #endif |
| 0 | 295 |
|
14
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
10
diff
changeset
|
296 |
|
18
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
297 #ifdef CYG_HAL_POWERPC_COPY_VECTORS // only for StubRom-supported startup |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
298 |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
299 |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
300 #ifdef CYGPRI_STUBROM_HAS_RAM_VECTORS |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
301 # ifdef CYG_HAL_STARTUP_RAM |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
302 # ifndef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
303 # define CYGPRI_SKIP_BREAKPOINT_VECTOR |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
304 # endif // no stubs |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
305 # endif // RAM startup |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
306 #endif // Stubrom vectors are in RAM |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
307 |
|
14
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
10
diff
changeset
|
308 # Copy RAM exception vectors from ROM (or load place) to RAM |
| 0 | 309 lwi r3,rom_vectors # r3 = rom start |
| 310 lwi r4,0 # r4 = ram start | |
|
18
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
311 #ifdef CYGPRI_SKIP_BREAKPOINT_VECTOR |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
312 lwi r5,__exception_program # r5 = end of first leg of copy |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
313 #else |
| 0 | 314 lwi r5,rom_vectors_end # r5 = rom end |
|
18
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
315 #endif |
| 0 | 316 |
| 317 cmplw r3,r5 # skip if no vectors | |
| 318 beq 2f | |
| 319 | |
| 320 1: | |
| 321 lwz r0,0(r3) # get word from ROM | |
| 322 stw r0,0(r4) # store in RAM | |
| 323 addi r3,r3,4 # increment by 1 word | |
| 324 addi r4,r4,4 # increment by 1 word | |
| 325 cmplw r3,r5 # compare | |
| 326 blt 1b # loop if not yet done | |
| 327 2: | |
|
18
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
328 #ifdef CYGPRI_SKIP_BREAKPOINT_VECTOR |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
329 cmplwi r4,__exception_program@L |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
330 bne 3f # is it the breakpoint vector? |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
331 addi r4,r4,0x100 # if so, leave it well alone |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
332 addi r3,r3,0x100 |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
333 lwi r5,rom_vectors_end # r5 = rom end |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
334 b 1b # and do the rest of the copy |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
335 3: |
|
7253dcc42a09
Merge from eCos master repository on 1999-06-25-15:31:50-BST
jlarmour
parents:
16
diff
changeset
|
336 #endif // Skip copying the breakpoint vector |
| 0 | 337 #endif |
| 2 | 338 |
| 0 | 339 # clear BSS |
| 2 | 340 .extern __bss_start |
| 341 .extern __bss_end | |
| 0 | 342 lwi r3,__bss_start # r3 = start |
| 2 | 343 lwi r4,__bss_end # r4 = end |
| 0 | 344 li r0,0 # r0 = 0 |
| 345 cmplw r3,r4 # skip if no bss | |
| 346 beq 2f | |
| 347 | |
| 2 | 348 1: stw r0,0(r3) # store zero |
| 0 | 349 addi r3,r3,4 # increment by 1 word |
| 350 cmplw r3,r4 # compare | |
| 351 blt 1b # loop if not yet done | |
| 352 2: | |
| 353 | |
| 2 | 354 # clear SBSS |
| 355 .extern __sbss_start | |
| 356 .extern __sbss_end | |
| 357 lwi r3,__sbss_start # r3 = start | |
| 358 lwi r4,__sbss_end # r4 = end | |
| 359 cmplw r3,r4 # skip if no sbss | |
| 360 beq 2f | |
| 361 | |
| 362 1: stw r0,0(r3) # store zero | |
| 363 addi r3,r3,4 # increment by 1 word | |
| 364 cmplw r3,r4 # compare | |
| 365 blt 1b # loop if not yet done | |
| 366 2: | |
| 367 | |
| 368 # It is now safe to call C functions which may rely on initialized | |
| 369 # data. | |
| 370 | |
| 371 # Set up stack for calls to C code. | |
| 0 | 372 subi sp,sp,12 # make space on stack |
| 373 li r0,0 | |
| 374 stw r0,0(sp) # clear back chain | |
| 375 stw r0,8(sp) # zero return pc | |
| 376 stwu sp,-ppc_stack_frame_size(sp) # create new stack frame | |
| 2 | 377 |
| 378 # Initialize MMU. | |
| 379 .extern hal_MMU_init | |
| 380 bl hal_MMU_init | |
| 381 | |
| 382 # Enable MMU it so we can safely enable caches. | |
| 383 lwi r3,CYG_MSR | |
| 384 sync | |
| 385 mtmsr r3 | |
| 386 sync | |
|
14
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
10
diff
changeset
|
387 |
| 2 | 388 # Enable caches |
| 389 .extern hal_enable_caches | |
| 390 bl hal_enable_caches | |
| 0 | 391 |
| 2 | 392 # call c++ constructors |
| 0 | 393 .extern cyg_hal_invoke_constructors |
| 2 | 394 bl cyg_hal_invoke_constructors |
| 0 | 395 |
| 2 | 396 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS |
| 397 .extern initialize_stub | |
| 398 bl initialize_stub | |
| 0 | 399 #endif |
| 400 | |
| 401 .extern cyg_start | |
| 402 bl cyg_start # call cyg_start | |
| 403 9: | |
| 404 b 9b # if we return, loop | |
| 405 | |
| 2 | 406 #--------------------------------------------------------------------------- |
| 0 | 407 # This code handles the common part of all exception handlers. |
| 408 # It saves the machine state onto the stack and then calls | |
| 409 # a "C" routine to do the rest of the work. This work may result | |
| 410 # in thread switches, and changes to the saved state. When we return | |
| 411 # here the saved state is restored and execution is continued. | |
| 412 | |
| 413 .text | |
| 414 | |
| 415 .extern __default_exception_vsr | |
| 416 __default_exception_vsr: | |
| 417 | |
| 418 # We come here with all register containing their | |
| 419 # pre-exception values except: | |
| 420 # R3 = ls 16 bits of vector address | |
| 421 # R4 = saved CR | |
| 422 # R5 = saved LR | |
| 423 # LR = VSR address | |
| 424 # SPRG1 = old R3 | |
| 425 # SPRG2 = old R4 | |
| 426 # SPRG3 = old R5 | |
| 427 # SRR0 = old PC | |
| 2 | 428 # SRR1 = old MSR and the exception cause (the POW state is lost!) |
| 0 | 429 |
| 430 subi r1,r1,ppc_exception_decrement | |
| 431 # leave space for registers and | |
| 432 # a safety margin | |
| 433 | |
| 434 # First, save away some registers | |
| 435 stw r3,ppcreg_vector(r1) # stash vector | |
| 436 stw r4,ppcreg_cr(r1) # stash CR | |
| 437 stw r5,ppcreg_lr(r1) # stash LR | |
| 2 | 438 |
| 439 # Enable MMU. | |
| 440 lwi r3,CYG_MSR | |
| 441 sync | |
| 442 mtmsr r3 | |
| 443 sync | |
| 444 | |
| 445 mfspr r3,SPRG1 # save original R3 | |
| 0 | 446 stw r3,ppcreg_regs+3*4(r1) |
| 2 | 447 mfspr r4,SPRG2 # save original R4 |
| 0 | 448 stw r4,ppcreg_regs+4*4(r1) |
| 2 | 449 mfspr r5,SPRG3 # save original R5 |
| 0 | 450 stw r5,ppcreg_regs+5*4(r1) |
| 451 | |
| 452 stw r0,ppcreg_regs(r1) # save R0 | |
| 453 stw r2,ppcreg_regs+2*4(r1) # save R2 | |
| 454 | |
| 455 mr r3,r1 # recreate original R1 | |
| 456 addi r3,r3,ppc_exception_decrement | |
| 457 stw r3,ppcreg_regs+1*4(r1) # and save it in state | |
| 458 | |
| 2 | 459 # Save registers r6..r12/r31 |
| 0 | 460 .set _reg,6 |
| 461 .rept MAX_SAVE_REG+1-6 | |
| 462 stw _reg,(ppcreg_regs+_reg*4)(r1) | |
| 463 .set _reg,_reg+1 | |
| 464 .endr | |
| 465 | |
| 2 | 466 # Save registers used in vsr (r14+r15) |
| 467 stw r14,(ppcreg_regs+14*4)(r1) | |
| 468 stw r15,(ppcreg_regs+15*4)(r1) | |
| 469 | |
| 0 | 470 # get remaining CPU registers |
| 471 mfxer r3 | |
| 472 mfctr r5 | |
| 473 mfdar r6 | |
| 474 mfdsisr r7 | |
| 475 mfpvr r8 | |
| 476 mfsrr0 r9 | |
| 477 mfsrr1 r10 | |
| 478 | |
| 479 # and store them | |
| 480 stw r3,ppcreg_xer(r1) | |
| 481 stw r5,ppcreg_ctr(r1) | |
| 482 stw r6,ppcreg_dar(r1) | |
| 483 stw r7,ppcreg_dsisr(r1) | |
| 484 stw r8,ppcreg_pvr(r1) | |
| 485 stw r9,ppcreg_pc(r1) | |
| 486 stw r10,ppcreg_msr(r1) | |
| 487 | |
| 488 # The entire CPU state is now stashed on the stack, | |
| 489 # call into C to do something with it. | |
| 490 | |
| 491 mr r3,sp # R3 = register dump | |
| 492 | |
| 493 subi sp,sp,ppc_stack_frame_size # make a null frame | |
| 494 | |
| 495 li r0,0 # R0 = 0 | |
| 496 stw r0,0(sp) # backchain = 0 | |
| 497 stw r0,8(sp) # return pc = 0 | |
| 498 | |
| 499 stwu sp,-ppc_stack_frame_size(sp) # create new stack frame | |
| 500 # where C code can save LR | |
| 501 | |
| 502 lwi r5,restore_state # get return link | |
| 503 mtlr r5 # to link register | |
| 504 | |
| 2 | 505 .extern cyg_hal_exception_handler |
| 506 b cyg_hal_exception_handler # call C code, r3 = registers | |
| 0 | 507 |
| 508 # When the call returns it will go to restore_state below. | |
| 509 | |
| 510 | |
| 2 | 511 ##-------------------------------------------------------------------------- |
| 512 ## The following macros are defined depending on whether the Interrupt | |
| 513 ## system is using isr tables or chaining, and depending on the interrupt | |
| 514 ## controller in the system. | |
| 515 | |
| 516 ## Note: CYG_ISR_TABLE_SIZE must match CYG_ISR_COUNT defined in hal_intr.h. | |
| 517 | |
| 518 #ifdef CYG_HAL_POWERPC_MPC8xx | |
| 519 | |
| 520 ## First level decoding of MPC8xx SIU interrupt controller. | |
| 521 | |
| 522 #define CYG_ISR_TABLE_SIZE 59 | |
| 523 | |
| 524 # decode the interrupt | |
| 525 .macro decode_interrupt dreg,state | |
| 526 lwz \dreg,ppcreg_vector(\state) # retrieve vector number, | |
| 527 rlwinm. \dreg,\dreg,22,31,31 # isolate bit 21 | |
| 528 beq 0f # done if decrementer (vec 0) | |
| 529 lwi \dreg,CYGARC_REG_IMM_SIVEC # if external, get SIU | |
| 530 lbz \dreg,0(\dreg) # vector. | |
| 531 srwi \dreg,\dreg,2 | |
| 532 addi \dreg,\dreg,1 # Skip decrementer vector | |
| 533 0: stw \dreg,ppcreg_vector(\state) # update vector in state frame. | |
| 534 slwi \dreg,\dreg,2 # convert to byte offset. | |
| 535 .endm | |
| 536 | |
| 537 #else | |
| 538 | |
| 539 ## This is the simple version. No interrupt controller, ppcreg_vector | |
| 540 ## is updated with the decoded interrupt vector. Isr tables/chaining | |
| 541 ## use same interrupt decoder. | |
| 542 ## Bit 21 biffers between decrementer (0) and external (1). | |
| 543 | |
| 544 #define CYG_ISR_TABLE_SIZE 2 | |
| 545 | |
| 546 # decode the interrupt | |
| 547 .macro decode_interrupt dreg,state | |
| 548 lwz \dreg,ppcreg_vector(\state) # retrieve vector number, | |
| 549 rlwinm \dreg,\dreg,22,31,31 # isolate bit 21 and update | |
| 550 stw \dreg,ppcreg_vector(\state) # vector in state frame. | |
| 551 slwi \dreg,\dreg,2 # convert to word offset. | |
| 552 .endm | |
| 553 | |
| 554 #endif | |
| 555 | |
| 556 #--------------------------------------------------------------------------- | |
| 0 | 557 # Common interrupt handling code. |
| 558 | |
| 559 .extern __default_interrupt_vsr | |
| 560 __default_interrupt_vsr: | |
| 561 | |
| 562 # We come here with all register containing their | |
| 563 # pre-exception values except: | |
| 564 # R3 = ls 16 bits of vector address | |
| 565 # R4 = saved CR | |
| 566 # R5 = saved LR | |
| 567 # LR = VSR address | |
| 568 # SPRG1 = old R3 | |
| 569 # SPRG2 = old R4 | |
| 570 # SPRG3 = old R5 | |
| 571 # SRR0 = old PC | |
| 572 # SRR1 = old MSR | |
| 573 | |
| 574 | |
| 575 subi r1,r1,ppc_exception_decrement | |
| 576 # leave space for registers and | |
| 577 # a safety margin | |
| 578 | |
| 579 stw r3,ppcreg_vector(r1) # stash vector | |
| 580 stw r4,ppcreg_cr(r1) # stash CR | |
| 581 stw r5,ppcreg_lr(r1) # stash LR | |
| 582 | |
| 2 | 583 # Enable MMU. |
| 584 lwi r3,CYG_MSR | |
| 585 sync | |
| 586 mtmsr r3 | |
| 587 sync | |
| 588 | |
| 589 mfspr r3,SPRG1 # save original R3 | |
| 0 | 590 stw r3,ppcreg_regs+3*4(r1) |
| 2 | 591 mfspr r4,SPRG2 # save original R4 |
| 0 | 592 stw r4,ppcreg_regs+4*4(r1) |
| 2 | 593 mfspr r5,SPRG3 # save original R5 |
| 0 | 594 stw r5,ppcreg_regs+5*4(r1) |
| 595 | |
| 596 stw r0,ppcreg_regs(r1) # save R0 | |
| 597 stw r2,ppcreg_regs+2*4(r1) # save R2 | |
| 598 | |
| 599 mr r3,r1 # recreate original R1 | |
| 600 addi r3,r3,ppc_exception_decrement | |
| 601 stw r3,ppcreg_regs+1*4(r1) # and save it in state | |
| 602 | |
| 2 | 603 # Save registers r6..r12/r31 |
| 0 | 604 .set _reg,6 |
| 605 .rept MAX_SAVE_REG+1-6 | |
| 606 stw _reg,(ppcreg_regs+_reg*4)(r1) | |
| 607 .set _reg,_reg+1 | |
| 608 .endr | |
| 609 | |
| 2 | 610 # Save registers used in vsr (r14+r15) |
| 611 stw r14,(ppcreg_regs+14*4)(r1) | |
| 612 stw r15,(ppcreg_regs+15*4)(r1) | |
| 613 | |
| 0 | 614 # get remaining CPU registers |
| 615 mfxer r3 | |
| 616 mfctr r5 | |
| 617 mfsrr0 r6 | |
| 618 mfsrr1 r7 | |
| 619 | |
| 620 # and store them | |
| 621 stw r3,ppcreg_xer(r1) | |
| 622 stw r5,ppcreg_ctr(r1) | |
| 623 stw r6,ppcreg_pc(r1) | |
| 624 stw r7,ppcreg_msr(r1) | |
| 625 | |
| 626 # The entire CPU state is now stashed on the stack, | |
| 627 # increment the scheduler lock and call the ISR | |
| 628 # for this vector. | |
| 629 | |
| 630 #ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT | |
| 2 | 631 .extern cyg_scheduler_sched_lock |
| 632 lwi r3,cyg_scheduler_sched_lock | |
| 0 | 633 lwz r4,0(r3) |
| 634 addi r4,r4,1 | |
| 635 stw r4,0(r3) | |
| 636 #endif | |
| 637 | |
| 2 | 638 mr r14,sp # r14 = register dump |
| 0 | 639 |
| 640 #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK | |
| 641 lwi r3,__interrupt_stack # stack top | |
| 642 lwi r4,__interrupt_stack_base # stack base | |
| 643 sub. r5,sp,r4 # sp - base | |
| 644 blt 1f # if < 0 - not on istack | |
| 645 sub. r5,r3,sp # top - sp | |
| 646 bgt 2f # if > 0 - already on istack | |
| 647 | |
| 648 1: mr sp,r3 # switch to istack | |
| 649 | |
| 2 | 650 2: stwu r14,-4(sp) # save old SP on stack |
| 0 | 651 |
| 652 #endif | |
| 653 | |
| 654 subi sp,sp,ppc_stack_frame_size # make a null frame | |
| 655 | |
| 656 li r0,0 # R0 = 0 | |
| 657 stw r0,0(sp) # backchain = 0 | |
| 658 stw r0,8(sp) # return pc = 0 | |
| 659 | |
| 660 stwu sp,-ppc_stack_frame_size(sp) # create new stack frame | |
| 661 # where C code can save LR | |
| 662 | |
| 663 #if defined(CYGPKG_KERNEL_INSTRUMENT) && defined(CYGDBG_KERNEL_INSTRUMENT_INTR) | |
| 664 | |
| 665 lwi r3,0x0301 # r3 = type = INTR,RAISE | |
| 2 | 666 lwz r4,ppcreg_vector(r14) # arg1 = vector address |
| 0 | 667 srwi r4,r4,8 # arg1 = vector number |
| 668 xor r5,r5,r5 # arg2 = 0 | |
| 669 bl cyg_instrument # call instrument function | |
| 670 | |
| 671 #endif | |
| 672 | |
| 2 | 673 decode_interrupt r15,r14 # get table index |
| 674 | |
| 0 | 675 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT |
| 676 .extern cyg_hal_gdb_isr | |
| 2 | 677 lwz r3,ppcreg_pc(r14) # for serial receive irq. |
| 678 bl cyg_hal_gdb_isr # (arg1 is PC) | |
| 0 | 679 cmpwi r3,0x0000 # Call ISR proper? |
| 680 beq 2f # (r3 is 0 when skipping | |
| 681 # to avoid DSR call) | |
| 682 1: | |
| 683 #endif | |
| 684 | |
| 2 | 685 #ifdef CYGSEM_HAL_COMMON_INTERRUPTS_ALLOW_NESTING |
| 0 | 686 |
| 2 | 687 #ifdef CYG_HAL_POWERPC_MPC8xx |
| 688 # The CPM controller allows nested interrupts. However, | |
| 689 # it sits on the back of the SIU controller which has no | |
| 690 # HW support for this. In effect, SW masking of lower | |
| 691 # priority IRQs in the SIU would be required for this to work. | |
| 692 #endif | |
| 693 | |
| 694 #endif | |
| 695 | |
| 696 lwz r3,ppcreg_vector(r14) # retrieve decoded vector # | |
| 0 | 697 |
| 698 lwi r6,hal_interrupt_handlers # get interrupt handler table | |
| 699 lwzx r6,r6,r15 # load routine pointer | |
| 700 | |
| 701 lwi r4,hal_interrupt_data # get interrupt data table | |
| 702 lwzx r4,r4,r15 # load data pointer | |
| 703 # R4 = data argument | |
| 704 | |
| 705 mtctr r6 # put isr address in ctr | |
| 706 | |
| 707 bctrl # branch to ctr reg and link | |
| 708 | |
| 709 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT | |
| 710 # If interrupt was caused by GDB, the ISR call above | |
| 711 # is skipped by jumping here. | |
| 712 2: | |
| 713 #endif | |
| 714 | |
| 715 #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK | |
| 716 | |
| 717 # If we are returning from the last nested interrupt, move back | |
| 718 # to the thread stack. interrupt_end() must be called on the | |
| 719 # thread stack since it potentially causes a context switch. | |
| 720 # Since we have arranged for the top of stack location to | |
| 721 # contain the sp we need to go back to here, just pop it off | |
| 722 # and put it in SP. | |
| 723 | |
| 724 | |
| 725 lwz sp,ppc_stack_frame_size*2(sp) # sp = *sp | |
| 726 | |
| 727 subi sp,sp,ppc_stack_frame_size # make a null frame | |
| 728 | |
| 729 li r0,0 # R0 = 0 | |
| 730 stw r0,0(sp) # backchain = 0 | |
| 731 stw r0,8(sp) # return pc = 0 | |
| 732 | |
| 733 stwu sp,-ppc_stack_frame_size(sp) # create new stack frame | |
| 734 # where C code can save LR | |
| 735 #endif | |
| 736 | |
| 737 #ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT | |
| 738 | |
| 739 # We only need to call _interrupt_end() when there is a kernel | |
| 740 # present to do any tidying up. | |
| 741 | |
| 742 # on return r3 bit 1 will indicate whether a DSR is | |
| 743 # to be posted. Pass this together with a pointer to | |
| 744 # the interrupt object we have just used to the | |
| 745 # interrupt tidy up routine. | |
| 746 | |
| 2 | 747 # Note that r14 and r15 are defined to be preserved across |
| 0 | 748 # calls by the calling convention, so they still contain |
| 749 # the register dump and the vector number respectively. | |
| 2 | 750 |
| 751 # Note: The instructions restoring the msr mask out the POW bit. | |
| 752 # When eCos gets power management aware, this bit will have to be | |
| 753 # set to the correct state rather than just cleared. | |
| 0 | 754 |
| 755 lwi r4,hal_interrupt_objects # get interrupt object table | |
| 756 lwzx r4,r4,r15 # load object pointer | |
| 757 | |
| 2 | 758 lwz r6,ppcreg_msr(r14) # restore msr, including |
| 759 lis r5,0xfffe # interrupt enable. | |
| 760 andc r6,r6,r5 # mask out reserved bits | |
| 761 sync # (and POW!) | |
| 762 mtmsr r6 | |
| 763 sync | |
| 0 | 764 |
| 2 | 765 mr r5,r14 # arg3 = saved register dump |
| 0 | 766 |
| 767 .extern interrupt_end | |
| 768 bl interrupt_end # call into C to finish off | |
| 769 #endif | |
| 770 | |
| 771 restore_state: | |
| 772 # All done, restore CPU state and continue | |
| 773 | |
| 774 addi sp,sp,ppc_stack_frame_size*2 # retrieve CPU state pointer | |
| 775 | |
| 776 # get sprs we want to restore | |
| 777 lwz r3,ppcreg_cr(sp) | |
| 778 lwz r4,ppcreg_pc(sp) | |
| 779 lwz r5,ppcreg_msr(sp) | |
| 780 lwz r6,ppcreg_xer(sp) | |
| 781 lwz r7,ppcreg_lr(sp) | |
| 782 lwz r8,ppcreg_ctr(sp) | |
| 783 | |
| 784 | |
| 785 # stuff some of them into the CPU | |
| 786 mtxer r6 | |
| 787 mtlr r7 | |
| 788 mtctr r8 | |
| 789 | |
| 790 # restore R0 and R2 | |
| 791 lwz r0,ppcreg_regs(sp) | |
| 792 lwz r2,ppcreg_regs+2*4(sp) | |
| 793 | |
| 2 | 794 # Restore registers used in vsr (r14+r15) |
| 795 lwz r14,(ppcreg_regs+14*4)(r1) | |
| 796 lwz r15,(ppcreg_regs+15*4)(r1) | |
| 797 | |
| 798 # restore registers r6..r12/r31 | |
| 0 | 799 .set _reg,6 |
| 800 .rept MAX_SAVE_REG+1-6 | |
| 801 lwz _reg,(ppcreg_regs+_reg*4)(r1) | |
| 802 .set _reg,_reg+1 | |
| 803 .endr | |
| 804 | |
| 805 # Here all the registers are loaded except | |
| 806 # r1 = ppcregs | |
| 807 # r3 = ccr | |
| 808 # r4 = srr0 = pc | |
| 809 # r5 = srr1 = msr | |
| 810 | |
| 811 # We have to disable interrupts while srr0 and | |
| 812 # srr1 are loaded, since another interrupt will | |
| 813 # destroy them. | |
| 814 | |
| 815 mtcr r3 # set ccr | |
| 816 | |
| 2 | 817 lwi r3,CYG_MSR # do rest with ints disabled |
| 818 sync | |
| 0 | 819 mtmsr r3 |
| 2 | 820 sync |
| 0 | 821 |
| 822 mtsrr0 r4 # load old pc | |
| 823 mtsrr1 r5 # load old msr | |
| 824 | |
| 825 lwz r3,ppcreg_regs+3*4(r1) # load r3 value | |
| 826 lwz r4,ppcreg_regs+4*4(r1) # load r4 value | |
| 827 lwz r5,ppcreg_regs+5*4(r1) # load r5 value | |
| 828 lwz r1,ppcreg_regs+1*4(r1) # restore r1 | |
| 829 | |
| 830 sync # settle things down | |
| 831 isync | |
| 832 rfi # and return | |
| 833 | |
|
10
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
834 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
835 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
836 ##----------------------------------------------------------------------------- |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
837 ## Execute pending DSRs on the interrupt stack with interrupts enabled. |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
838 ## Note: this can only be called from code running on a thread stack |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
839 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
840 #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
841 .extern cyg_interrupt_call_pending_DSRs |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
842 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
843 FUNC_START(hal_interrupt_stack_call_pending_DSRs) |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
844 # Disable interrupts |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
845 mfmsr r4 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
846 lis r3,0 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
847 ori r3,r3,0x8000 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
848 andc r5,r4,r3 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
849 mtmsr r5 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
850 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
851 # Change to interrupt stack |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
852 mr r3,sp |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
853 lwi sp,__interrupt_stack |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
854 stwu r3,-4(sp) # store old stackptr on stack |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
855 mflr r3 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
856 stwu r3,-4(sp) # store lr on stack |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
857 stwu r4,-4(sp) # store msr values on stack |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
858 stwu r5,-4(sp) |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
859 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
860 # Set up stack for calls to C code. |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
861 subi sp,sp,12 # make space on stack |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
862 li r0,0 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
863 stw r0,0(sp) # clear back chain |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
864 stw r0,8(sp) # zero return pc |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
865 stwu sp,-ppc_stack_frame_size(sp) # create new stack frame |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
866 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
867 # Restore interrupt state |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
868 mtmsr r4 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
869 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
870 # Call into kernel which will execute DSRs |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
871 bl cyg_interrupt_call_pending_DSRs |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
872 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
873 # Unwind stack and get msr values |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
874 lwzu r5,12+ppc_stack_frame_size(sp) |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
875 lwz r4,4(sp) |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
876 lwz r3,8(sp) |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
877 mtlr r3 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
878 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
879 # Disable interrupts |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
880 mtmsr r5 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
881 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
882 # Restore original stack pointer, original interrupt state and return |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
883 lwz sp,12(sp) |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
884 mtmsr r4 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
885 |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
886 blr |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
887 #endif |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
888 |
| 2 | 889 #--------------------------------------------------------------------------- |
| 890 # Code for putting the CPU in a post-reset state; disabling MMU and caches. | |
| 891 _init_CPU: | |
| 892 #ifdef CYG_HAL_POWERPC_MPC8xx | |
| 893 lwi r3,CYGARC_REG_DC_CMD_CD | |
| 894 sync | |
| 895 mtspr CYGARC_REG_DC_CST,r3 | |
| 896 lwi r3,CYGARC_REG_IC_CMD_CD | |
| 897 isync | |
| 898 mtspr CYGARC_REG_IC_CST,r3 | |
| 899 isync | |
| 900 #endif | |
| 901 | |
| 902 # Set up MSR (disable MMU for now) | |
| 903 lwi r3,(CYG_MSR & ~(MSR_IR | MSR_DR)) | |
| 904 sync | |
| 905 mtmsr r3 | |
| 906 sync | |
| 907 blr | |
| 908 | |
| 909 #--------------------------------------------------------------------------- | |
| 0 | 910 # This table contains a VSR pointer for each defined exception. |
| 911 # All of these except 5 and 9 point to the __default_exception_vsr | |
| 912 # above, 5 and 9 point to the __default_interrupt_vsr. Entries in | |
| 913 # this table may be changed using Cyg_Interrupt::set_vsr(). | |
| 914 | |
| 915 .data | |
| 916 | |
| 917 .globl hal_vsr_table | |
| 918 hal_vsr_table: | |
| 919 # Architecture defined vectors | |
| 920 .long __default_exception_vsr # reserved | |
| 921 .long __default_exception_vsr # system reset | |
| 922 .long __default_exception_vsr # machine check | |
| 923 .long __default_exception_vsr # data storage | |
| 924 .long __default_exception_vsr # instruction storage | |
| 925 | |
| 926 .long __default_interrupt_vsr # external interrupt | |
| 927 | |
| 928 .long __default_exception_vsr # alignment | |
| 929 .long __default_exception_vsr # program | |
| 930 .long __default_exception_vsr # floating point unavailable | |
| 931 | |
| 932 .long __default_interrupt_vsr # decrementer | |
| 933 | |
| 934 .long __default_exception_vsr # reserved 0x0a00 | |
| 935 .long __default_exception_vsr # reserved 0x0b00 | |
| 936 .long __default_exception_vsr # system call | |
| 937 .long __default_exception_vsr # trace | |
| 938 .long __default_exception_vsr # floating point assist | |
| 939 .long __default_exception_vsr # reserved 0x0f00 | |
| 940 | |
| 2 | 941 #ifdef CYG_HAL_POWERPC_MPC8xx |
| 0 | 942 |
| 943 # Implementation defined vectors | |
| 944 .long __default_exception_vsr # software emulation | |
| 945 .long __default_exception_vsr # instruction TLB miss | |
| 946 .long __default_exception_vsr # data TLB miss | |
| 947 .long __default_exception_vsr # instruction TLB error | |
| 948 .long __default_exception_vsr # data TLB error | |
| 949 .long __default_exception_vsr # reserved 0x1500 | |
| 950 .long __default_exception_vsr # reserved 0x1600 | |
| 951 .long __default_exception_vsr # reserved 0x1700 | |
| 952 .long __default_exception_vsr # reserved 0x1800 | |
| 953 .long __default_exception_vsr # reserved 0x1900 | |
| 954 .long __default_exception_vsr # reserved 0x1a00 | |
| 955 .long __default_exception_vsr # reserved 0x1b00 | |
| 956 .long __default_exception_vsr # data breakpoint | |
| 957 .long __default_exception_vsr # instruction breakpoint | |
| 958 .long __default_exception_vsr # peripheral breakpoint | |
| 959 .long __default_exception_vsr # non maskable development port | |
| 960 #endif | |
| 961 | |
| 2 | 962 #--------------------------------------------------------------------------- |
| 0 | 963 # Interrupt vector tables. |
| 964 # These tables contain the isr, data and object pointers used to deliver | |
| 965 # interrupts to user code. | |
| 2 | 966 |
| 967 #if (CYG_ISR_TABLE_SIZE > 2) | |
| 0 | 968 .data |
| 2 | 969 #else |
| 970 .section ".sdata","aw" | |
| 971 #endif | |
| 0 | 972 |
|
14
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
10
diff
changeset
|
973 .extern hal_default_decrementer_isr |
| 0 | 974 .extern hal_default_isr |
| 975 | |
| 976 .globl hal_interrupt_handlers | |
| 977 hal_interrupt_handlers: | |
|
14
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
10
diff
changeset
|
978 .long hal_default_decrementer_isr |
|
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
10
diff
changeset
|
979 .rept CYG_ISR_TABLE_SIZE-1 |
| 0 | 980 .long hal_default_isr |
| 981 .endr | |
| 982 | |
| 983 .globl hal_interrupt_data | |
| 984 hal_interrupt_data: | |
| 2 | 985 .rept CYG_ISR_TABLE_SIZE |
| 0 | 986 .long 0 |
| 987 .endr | |
| 988 | |
| 989 .globl hal_interrupt_objects | |
| 990 hal_interrupt_objects: | |
| 2 | 991 .rept CYG_ISR_TABLE_SIZE |
| 0 | 992 .long 0 |
| 993 .endr | |
| 994 | |
| 2 | 995 #--------------------------------------------------------------------------- |
| 0 | 996 ## Temporary interrupt stack |
| 997 | |
| 998 .section ".bss" | |
| 999 | |
| 1000 .balign 16 | |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
1001 .global cyg_interrupt_stack_base |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
1002 cyg_interrupt_stack_base: |
| 0 | 1003 __interrupt_stack_base: |
| 1004 .rept CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE | |
| 1005 .byte 0 | |
| 1006 .endr | |
| 1007 .balign 16 | |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
1008 .global cyg_interrupt_stack |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
1009 cyg_interrupt_stack: |
| 0 | 1010 __interrupt_stack: |
| 1011 | |
| 1012 .long 0,0,0,0,0,0,0,0 | |
| 1013 | |
| 2 | 1014 #--------------------------------------------------------------------------- |
| 0 | 1015 # end of vectors.S |
