Changeset 6e6815e in umon for main/cpu/arm/vectors_arm.S


Ignore:
Timestamp:
Jun 20, 2016, 3:24:20 PM (3 years ago)
Author:
Ben Gras <beng@…>
Branches:
master
Parents:
696ee75
git-author:
Ben Gras <beng@…> (06/20/16 15:24:20)
git-committer:
Ben Gras <beng@…> (06/20/16 15:45:45)
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/cpu/arm/vectors_arm.S

    r696ee75 r6e6815e  
    2828 */
    2929
     30#define _ASSEMBLY_ 1
     31
    3032#include "arm.h"
    3133
     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
    3244.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
    3352undefined_instruction:
    34 mov r1, #EXCTYPE_UNDEF
    35 b umon_exception
     53EXCEPTIONSAVE(EXCTYPE_UNDEF)
    3654
    37 .global software_interrupt
    3855software_interrupt:
    39 mov r1, #EXCTYPE_SWI
    40 b umon_exception
     56EXCEPTIONSAVE(EXCTYPE_SWI)
    4157
    42 .global abort_prefetch
    4358abort_prefetch:
    44 mov r1, #EXCTYPE_ABORTP
    45 b umon_exception
     59EXCEPTIONSAVE(EXCTYPE_ABORTP)
    4660
    47 .global abort_data
    4861abort_data:
    49 mov r1, #EXCTYPE_ABORTD
    50 b umon_exception
     62EXCEPTIONSAVE(EXCTYPE_ABORTD)
    5163
    52 .global not_assigned
    5364not_assigned:
    54 mov r1, #EXCTYPE_NOTASSGN
    55 b umon_exception
     65EXCEPTIONSAVE(EXCTYPE_NOTASSGN)
    5666
    57 .global interrupt_request
    5867interrupt_request:
    59 mov r1, #EXCTYPE_IRQ
    60 b umon_exception
     68EXCEPTIONSAVE(EXCTYPE_IRQ)
    6169
    62 .global fast_interrupt_request
    6370fast_interrupt_request:
    64 mov r1, #EXCTYPE_FIRQ
    65 b umon_exception
     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 TracChangeset for help on using the changeset viewer.