source: rtems/cpukit/score/cpu/epiphany/epiphany-exception-handler.S @ 5c6edee

5
Last change on this file since 5c6edee was 9819425, checked in by Sebastian Huber <sebastian.huber@…>, on 01/31/18 at 07:02:21

epiphany: Fixes for GCC 7.3

GCC 7.3 defines USER_LABEL_PREFIX to nothing.

  • Property mode set to 100644
File size: 6.9 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreCPU
5 *
6 * @brief Epiphany exception support implementation.
7 */
8
9/*
10 * Copyright (c) 2015 University of York.
11 * Hesham ALMatary <hmka501@york.ac.uk>
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 *    notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 *    notice, this list of conditions and the following disclaimer in the
20 *    documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#ifdef HAVE_CONFIG_H
36#include "config.h"
37#endif
38
39#include <rtems/score/cpu.h>
40
41#include <rtems/asm.h>
42#include <rtems/score/percpu.h>
43
44EXTERN(bsp_start_vector_table_begin)
45EXTERN(_Thread_Dispatch)
46PUBLIC(_ISR_Handler)
47
48.section .text, "ax"
49.align 4
50TYPE_FUNC(_ISR_Handler)
51SYM(_ISR_Handler):
52  /* Reserve space for CPU_Exception_frame */
53  sub sp, sp, #(CPU_EXCEPTION_FRAME_SIZE)
54
55  str r0,  [sp]
56  str r1,  [sp,1]
57  str r2,  [sp,2]
58  str r3,  [sp,3]
59  str r4,  [sp,4]
60  str r5,  [sp,5]
61  str r6,  [sp,6]
62  str r7,  [sp,7]
63  str r8,  [sp,8]
64  str r9,  [sp,9]
65  str r10, [sp,10]
66  str fp,  [sp,11]
67  str r12, [sp,12]
68
69  /* Save interrupted task stack pointer */
70  add r1, sp, #(CPU_EXCEPTION_FRAME_SIZE + 8)
71  str r1,[sp,13]
72
73  str lr,  [sp,14]
74  str r15, [sp,15]
75  str r16, [sp,16]
76  str r17, [sp,17]
77  str r18, [sp,18]
78  str r19, [sp,19]
79  str r20, [sp,20]
80  str r21, [sp,21]
81  str r22, [sp,22]
82  str r23, [sp,23]
83  str r24, [sp,24]
84  str r25, [sp,25]
85  str r26, [sp,26]
86  str r27, [sp,27]
87  str r28, [sp,28]
88  str r29, [sp,29]
89  str r30, [sp,30]
90  str r31, [sp,31]
91  str r32, [sp,32]
92  str r33, [sp,33]
93  str r34, [sp,34]
94  str r35, [sp,35]
95  str r36, [sp,36]
96  str r37, [sp,37]
97  str r38, [sp,38]
98  str r39, [sp,39]
99  str r40, [sp,40]
100  str r41, [sp,41]
101  str r42, [sp,42]
102  str r43, [sp,43]
103  str r44, [sp,44]
104  str r45, [sp,45]
105  str r46, [sp,46]
106  str r47, [sp,47]
107  str r48, [sp,48]
108  str r49, [sp,49]
109  str r50, [sp,50]
110  str r51, [sp,51]
111  str r52, [sp,52]
112  str r53, [sp,53]
113  str r54, [sp,54]
114  str r55, [sp,55]
115  str r56, [sp,56]
116  str r57, [sp,57]
117  str r58, [sp,58]
118  str r59, [sp,59]
119  str r60, [sp,60]
120  str r61, [sp,61]
121  /* r62 and r63 are saved from start.S interrupt entry
122   * and hold vector number and _ISR_Handler address repsectively.
123   */
124
125  /* Save status register */
126  movfs r1,status
127  str r1, [sp,62]
128
129  /* Save config register */
130  movfs r1,config
131  str r1, [sp,63]
132
133  /* Save interrupt return address register */
134  movfs r1,iret
135  str r1, [sp,64]
136
137  mov  r33, %low(_Per_CPU_Information)
138  movt r33, %high(_Per_CPU_Information)
139
140       add  r6, r33, #(PER_CPU_ISR_NEST_LEVEL)
141       add  r8, r33, #(PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL)
142
143  /* Increment nesting level and disable thread dispatch */
144  ldr  r5, [r6]
145  ldr  r7, [r8]
146  add  r5, r5, #1
147  add  r7, r7, #1
148  str  r5, [r6]
149  str  r7, [r8]
150
151  /* Keep sp (Exception frame address) in r32 - Callee saved */
152  mov  r32, sp
153
154  /* Keep _Per_CPU_Information address in r33 - Callee saved */
155  mov  r33, r18
156
157  /* Call the exception handler from vector table.
158   * First function arg for C handler is vector number,
159   * and the second is a pointer to exception frame.
160   */
161  mov  r0,  r62
162  mov  r1,  sp
163
164  mov  r27, r62
165  lsl  r27, r27, #2
166  mov  r26, %low(bsp_start_vector_table_begin)
167  movt r15, #0
168  add  r27, r27, r26
169  ldr  r27, [r27]
170
171  /* Do not switch stacks if we are in a nested interrupt. At
172   * this point r5 should be holding ISR_NEST_LEVEL value.
173   */
174  sub  r37, r5, #1
175  bgtu jump_to_c_handler
176
177  /* Switch to RTEMS dedicated interrupt stack */
178  add     sp, r18, #(PER_CPU_INTERRUPT_STACK_HIGH)
179  ldr     sp, [sp]
180
181jump_to_c_handler:
182  jalr r27
183
184  /* Switch back to the interrupted task stack */
185  mov  sp, r32
186
187  /* Get the address of _Per_CPU_Information */
188  mov r18, r33
189
190  /* Decrement nesting level and enable multitasking */
191  add  r6, r18, #(PER_CPU_ISR_NEST_LEVEL)
192       add  r8, r18, #(PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL)
193
194  ldr     r5, [r6]
195  ldr     r7, [r8]
196  sub     r5, r5, #1
197  sub     r7, r7, #1
198  str     r5, [r6]
199  str     r7, [r8]
200
201  /* Check if _ISR_Nest_level > 0 */
202  sub     r37, r5, #0
203  bgtu    exception_frame_restore
204
205  /* Check if _Thread_Dispatch_disable_level > 0 */
206  sub     r37, r7, #0
207  bgtu    exception_frame_restore
208
209  /* Check if dispatch needed */
210  add     r31, r18, #(PER_CPU_DISPATCH_NEEDED)
211  ldr     r31, [r31]
212
213  sub     r35, r31, #0
214  beq     exception_frame_restore
215
216  mov     r35, %low(_Thread_Dispatch)
217  movt    r35, %high(_Thread_Dispatch)
218  jalr    r35
219
220exception_frame_restore:
221
222  ldr r1,  [sp,1]
223  ldr r2,  [sp,2]
224  ldr r3,  [sp,3]
225  ldr r4,  [sp,4]
226  ldr r5,  [sp,5]
227  ldr r6,  [sp,6]
228  ldr r7,  [sp,7]
229  ldr r8,  [sp,8]
230  ldr r9,  [sp,9]
231  ldr r10, [sp,10]
232  ldr fp,  [sp,11]
233  ldr r12, [sp,12]
234  ldr lr,  [sp,14]
235  ldr r15, [sp,15]
236  ldr r16, [sp,16]
237  ldr r17, [sp,17]
238  ldr r18, [sp,18]
239  ldr r19, [sp,19]
240  ldr r20, [sp,20]
241  ldr r21, [sp,21]
242  ldr r22, [sp,22]
243  ldr r23, [sp,23]
244  ldr r24, [sp,24]
245  ldr r25, [sp,25]
246  ldr r26, [sp,26]
247  ldr r27, [sp,27]
248  ldr r28, [sp,28]
249  ldr r29, [sp,29]
250  ldr r30, [sp,30]
251  ldr r31, [sp,31]
252  ldr r32, [sp,32]
253  ldr r34, [sp,34]
254  ldr r36, [sp,36]
255  ldr r38, [sp,38]
256  ldr r39, [sp,39]
257  ldr r40, [sp,40]
258  ldr r41, [sp,41]
259  ldr r42, [sp,42]
260  ldr r43, [sp,43]
261  ldr r44, [sp,44]
262  ldr r45, [sp,45]
263  ldr r46, [sp,46]
264  ldr r47, [sp,47]
265  ldr r48, [sp,48]
266  ldr r49, [sp,49]
267  ldr r50, [sp,50]
268  ldr r51, [sp,51]
269  ldr r52, [sp,52]
270  ldr r53, [sp,53]
271  ldr r54, [sp,54]
272  ldr r55, [sp,55]
273  ldr r56, [sp,56]
274  ldr r57, [sp,57]
275  ldr r58, [sp,58]
276  ldr r59, [sp,59]
277  ldr r60, [sp,60]
278  ldr r61, [sp,61]
279
280  /* Restore status register */
281  ldr r0,[sp,62]
282  movts status, r0
283
284  /* Restore config register */
285  ldr r0, [sp,63]
286  movts config, r0
287
288  /* Restore interrupt return address register */
289  ldr   r0, [sp,64]
290  movts iret, r0
291
292  ldr r0,[sp]
293
294  /* Restore interrupted task's stack pointer */
295  ldr sp, [sp,13]
296
297  /* r62 and r63 are saved from start.S interrupt entry
298   * and hold vector number and _ISR_Handler address repsectively.
299   */
300  ldr r62, [sp, -8]
301  ldr r63, [sp, -4]
302
303  /* return from interrupt */
304  rti
Note: See TracBrowser for help on using the repository browser.