source: rtems/cpukit/score/cpu/arm/arm_exc_abort.S @ e47a3b7

Last change on this file since e47a3b7 was e47a3b7, checked in by Joel Sherrill <joel@…>, on 02/16/22 at 22:54:29

score/cpu/arm: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSScoreCPUARM
7 *
8 * @brief ARM data and prefetch abort exception prologue and epilogue.
9 */
10
11/*
12 * Copyright (c) 2009
13 * embedded brains GmbH
14 * Obere Lagerstr. 30
15 * D-82178 Puchheim
16 * Germany
17 * <rtems@embedded-brains.de>
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions
21 * are met:
22 * 1. Redistributions of source code must retain the above copyright
23 *    notice, this list of conditions and the following disclaimer.
24 * 2. Redistributions in binary form must reproduce the above copyright
25 *    notice, this list of conditions and the following disclaimer in the
26 *    documentation and/or other materials provided with the distribution.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
32 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#ifdef HAVE_CONFIG_H
42#include "config.h"
43#endif
44
45#include <rtems/asm.h>
46
47#ifdef ARM_MULTILIB_ARCH_V4
48
49.extern _ARM_Exception_default
50
51.globl _ARMV4_Exception_data_abort_set_handler
52.globl _ARMV4_Exception_data_abort
53
54.globl _ARMV4_Exception_prefetch_abort_set_handler
55.globl _ARMV4_Exception_prefetch_abort
56
57.section ".bss"
58
59data_abort_handler:
60.long 0
61
62prefetch_abort_handler:
63.long 0
64
65.section ".text"
66
67#ifdef __thumb__
68        .thumb_func
69#endif
70
71_ARMV4_Exception_data_abort_set_handler:
72        ldr     r1, =data_abort_handler
73        str     r0, [r1]
74#ifdef __thumb__
75        bx      lr
76#else
77        mov     pc, lr
78#endif
79
80#ifdef __thumb__
81        .thumb_func
82#endif
83
84_ARMV4_Exception_prefetch_abort_set_handler:
85        ldr     r1, =prefetch_abort_handler
86        str     r0, [r1]
87#ifdef __thumb__
88        bx      lr
89#else
90        mov     pc, lr
91#endif
92
93.arm
94
95_ARMV4_Exception_prefetch_abort:
96
97        /* Save context and load handler */
98        sub     sp, #20
99        stmdb   sp!, {r0-r12}
100        mov     r4, #3
101        ldr     r6, =prefetch_abort_handler
102
103        b       save_more_context
104
105_ARMV4_Exception_data_abort:
106
107        /* Save context and load handler */
108        sub     sp, #20
109        stmdb   sp!, {r0-r12}
110        mov     r4, #4
111        ldr     r6, =data_abort_handler
112
113save_more_context:
114
115        /* Save more context */
116        mov     r2, lr
117        mrs     r3, spsr
118        mrs     r7, cpsr
119        orr     r5, r3, #ARM_PSR_I
120        bic     r5, #ARM_PSR_T
121        msr     cpsr, r5
122        mov     r0, sp
123        mov     r1, lr
124        msr     cpsr, r7
125        add     r5, sp, #72
126        stmdb   r5!, {r0-r4}
127
128        /* Call high level handler */
129        ldr     r2, [r6]
130        cmp     r2, #0
131        ldreq   r2, =_ARM_Exception_default
132        mov     r0, sp
133#ifndef __thumb__
134        mov     lr, pc
135        mov     pc, r2
136#else /* __thumb__ */
137        SWITCH_FROM_ARM_TO_THUMB        r1
138        bl      call_handler
139        SWITCH_FROM_THUMB_TO_ARM
140#endif /* __thumb__ */
141
142        /* Restore context */
143        ldmia   r5!, {r0-r4}
144        mov     lr, r2
145        msr     spsr, r3
146        ldmia   sp!, {r0-r12}
147        add     sp, #20
148
149        /* Return from interrupt */
150        subs    pc, lr, #8
151
152#ifdef __thumb__
153.thumb
154call_handler:
155        bx      r2
156#endif /* __thumb__ */
157
158#endif /* ARM_MULTILIB_ARCH_V4 */
Note: See TracBrowser for help on using the repository browser.