source: rtems/c/src/lib/libbsp/arm/shared/abort/abort.c @ 991fdb33

4.115
Last change on this file since 991fdb33 was 96a9f4c, checked in by Alan Cudmore <alan.cudmore@…>, on 11/12/14 at 13:00:05

ARM removed shared/abort from several ARM BSPs

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 *  ARM CPU Dependent Source
3 *
4 *  If you want a small footprint RTEMS, pls use simple_abort.c
5 */
6
7/*
8 *  COPYRIGHT (c) 2007 Ray Xu.
9 *  mailto: Rayx at gmail dot com
10 *
11 *  COPYRIGHT (c) 2000 Canon Research Centre France SA.
12 *  Emmanuel Raguet, mailto:raguet@crf.canon.fr
13 *
14 *  Copyright (c) 2002 Advent Networks, Inc
15 *      Jay Monkman <jmonkman@adventnetworks.com>
16 *
17 *  The license and distribution terms for this file may be
18 *  found in the file LICENSE in this distribution or at
19 *  http://www.rtems.org/license/LICENSE.
20 *
21 */
22
23#include <rtems/system.h>
24#include <rtems.h>
25#include <rtems/bspIo.h>
26#include "abort.h"
27
28uint32_t g_data_abort_cnt = 0;
29/*this is a big overhead for MCU only got 16K RAM*/
30uint32_t g_data_abort_insn_list[1024];
31
32
33char *_print_full_context_mode2txt[0x20]={
34  [0x0]="user",  /* User */
35  [0x1]="fiq",   /* FIQ - Fast Interrupt Request */
36  [0x2]="irq",   /* IRQ - Interrupt Request */
37  [0x3]="super", /* Supervisor */
38  [0x7]="abort", /* Abort */
39  [0xb]="undef", /* Undefined */
40  [0xf]="system" /* System */
41};
42
43void _print_full_context(uint32_t spsr)
44{
45    char *mode;
46    uint32_t prev_sp,prev_lr,cpsr,arm_switch_reg;
47    int i;
48
49    printk("active thread thread 0x%08x\n", rtems_task_self());
50
51    mode=_print_full_context_mode2txt[spsr&0x1f];
52    if(!mode) mode="unknown";
53
54    __asm__ volatile (ARM_SWITCH_TO_ARM
55              " MRS  %[cpsr], cpsr \n"
56              " ORR  %[arm_switch_reg], %[spsr], #0xc0 \n"
57              " MSR  cpsr_c, %[arm_switch_reg] \n"
58              " MOV  %[prev_sp], sp \n"
59              " MOV  %[prev_lr], lr \n"
60              " MSR  cpsr_c, %[cpsr] \n"
61              ARM_SWITCH_BACK
62              : [arm_switch_reg] "=&r" (arm_switch_reg), [prev_sp] "=&r" (prev_sp), [prev_lr] "=&r" (prev_lr),
63                [cpsr] "=&r" (cpsr)
64              : [spsr] "r" (spsr)
65              : "cc");
66
67    printk("Previous sp=0x%08x lr=0x%08x and actual cpsr=%08x\n",
68           prev_sp, prev_lr, cpsr);
69
70    for(i=0;i<48;){
71        printk(" 0x%08x",((uint32_t*)prev_sp)[i++]);
72        if((i%6) == 0)
73            printk("\n");
74    }
75
76}
77
78
79/* This function is supposed to figure out what caused the
80 * data abort, do that, then return.
81 *
82 * All unhandled instructions cause the system to hang.
83 */
84
85void do_data_abort(
86  uint32_t insn,
87  uint32_t spsr,
88  Context_Control *ctx
89)
90{
91    /* Clarify, which type is correct, CPU_Exception_frame or Context_Control */
92    uint8_t               decode;
93    uint8_t               insn_type;
94    rtems_interrupt_level level;
95
96    g_data_abort_insn_list[g_data_abort_cnt & 0x3ff] = ctx->register_lr - 8;
97    g_data_abort_cnt++;
98
99    decode = ((insn >> 20) & 0xff);
100
101    insn_type = decode & INSN_MASK;
102    switch(insn_type) {
103    case INSN_STM1:
104        printk("\n\nINSN_STM1\n");
105        break;
106    case INSN_STM2:
107        printk("\n\nINSN_STM2\n");
108        break;
109    case INSN_STR:
110        printk("\n\nINSN_STR\n");
111        break;
112    case INSN_STRB:
113        printk("\n\nINSN_STRB\n");
114        break;
115    case INSN_LDM1:
116        printk("\n\nINSN_LDM1\n");
117        break;
118    case INSN_LDM23:
119        printk("\n\nINSN_LDM23\n");
120        break;
121    case INSN_LDR:
122        printk("\n\nINSN_LDR\n");
123        break;
124    case INSN_LDRB:
125        printk("\n\nINSN_LDRB\n");
126        break;
127    default:
128        printk("\n\nUnrecognized instruction\n");
129        break;
130    }
131
132    printk("data_abort at address 0x%x, instruction: 0x%x,   spsr = 0x%x\n",
133           ctx->register_lr - 8, insn, spsr);
134
135    _print_full_context(spsr);
136
137    /* disable interrupts, wait forever */
138    rtems_interrupt_disable(level);
139    (void) level; /* avoid set but unused warning */
140
141    while(1) {
142        continue;
143    }
144}
145
Note: See TracBrowser for help on using the repository browser.