source: umon/main/cpu/arm/vectors_arm.S @ 6e6815e

Last change on this file since 6e6815e was 6e6815e, checked in by Ben Gras <beng@…>, on Jun 20, 2016 at 3:24:20 PM

ARM: save and print exception context

Debugging aid. Prints nice exception context info like:

R0 = 0x00000000 R8 = 0x402fe8b0
R1 = 0x402ffd80 R9 = 0x40309b15
R2 = 0x00000800 R10 = 0x00000000
R3 = 0x402ffd40 R11 = 0x00000000
R4 = 0x402ffd40 R12 = 0x402fdd38
R5 = 0x402ffd80 SP = 0x40309694
R6 = 0x00000003 LR = 0x402fa348
R7 = 0x00000800 PC = 0x402f8614
VEC = 0x00000003

Data structures, definitions and code taken from RTEMS.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/**************************************************************************
2 *
3 * Copyright (c) 2013 Alcatel-Lucent
4 *
5 * Alcatel Lucent licenses this file to You under the Apache License,
6 * Version 2.0 (the "License"); you may not use this file except in
7 * compliance with the License.  A copy of the License is contained the
8 * file LICENSE at the top level of this repository.
9 * You may also obtain a copy of the License at:
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 **************************************************************************
20 *
21 * vectors_arm.S
22 *
23 * Minimalist exception handlers...
24 * Catch the exception, call generic handler with exception-specific id.
25 *
26 * Original author:     Ed Sutter (ed.sutter@alcatel-lucent.com)
27 *
28 */
29
30#define _ASSEMBLY_ 1
31
32#include "arm.h"
33
34#define MORE_CONTEXT_SIZE \
35  (ARM_EXCEPTION_FRAME_SIZE - ARM_EXCEPTION_FRAME_REGISTER_SP_OFFSET)
36
37#define EXCEPTIONSAVE(n)         \
38        sub     sp, #MORE_CONTEXT_SIZE   ; \
39        stmdb   sp!, {r0-r12}    ; \
40        mov     r4, #(n)         ; \
41         ; \
42        b       save_more_context        ; \
43
44.global undefined_instruction
45.global software_interrupt
46.global abort_prefetch
47.global abort_data
48.global not_assigned
49.global interrupt_request
50.global fast_interrupt_request
51
52undefined_instruction:
53EXCEPTIONSAVE(EXCTYPE_UNDEF)
54
55software_interrupt:
56EXCEPTIONSAVE(EXCTYPE_SWI)
57
58abort_prefetch:
59EXCEPTIONSAVE(EXCTYPE_ABORTP)
60
61abort_data:
62EXCEPTIONSAVE(EXCTYPE_ABORTD)
63
64not_assigned:
65EXCEPTIONSAVE(EXCTYPE_NOTASSGN)
66
67interrupt_request:
68EXCEPTIONSAVE(EXCTYPE_IRQ)
69
70fast_interrupt_request:
71EXCEPTIONSAVE(EXCTYPE_FIRQ)
72
73/* This code gratefully taken from RTEMS */
74
75save_more_context:
76        /* Save more context */
77        mov     r2, lr
78        mrs     r3, spsr
79        mrs     r7, cpsr
80        orr     r5, r3, #ARM_PSR_I
81        bic     r5, #ARM_PSR_T
82        msr     cpsr, r5
83        mov     r0, sp
84        mov     r1, lr
85        msr     cpsr, r7
86        mov     r5, #0
87        add     r6, sp, #ARM_EXCEPTION_FRAME_REGISTER_SP_OFFSET
88        stm     r6, {r0-r5}
89
90        /* Argument for high level handler */
91        mov     r0, sp
92
93        /* Clear VFP context pointer */
94        add     r3, sp, #ARM_EXCEPTION_FRAME_VFP_CONTEXT_OFFSET
95        mov     r1, #0
96        str     r1, [r3]
97
98        /* Call high level handler */
99        b umon_exception
100
101        /* Just in case */
102twiddle:
103        b       twiddle
104
Note: See TracBrowser for help on using the repository browser.