source: rtems/c/src/exec/score/cpu/arm/cpu_asm.S @ 08330bf

4.104.114.84.95
Last change on this file since 08330bf was 08330bf, checked in by Joel Sherrill <joel.sherrill@…>, on 07/27/00 at 01:04:11

Port of RTEMS to the ARM processor family by Eric Valette
<valette@…> and Emmanuel Raguet <raguet@…>
of Canon CRF - Communication Dept. This port includes a
basic BSP that is sufficient to link hello world.

  • Property mode set to 100644
File size: 4.8 KB
Line 
1/*  cpu_asm.s
2 *
3 *  This file contains all assembly code for the ARM implementation
4 *  of RTEMS.
5 *
6 *  COPYRIGHT (c) 2000 Canon Research Centre France SA.
7 *  Emmanuel Raguet, mailto:raguet@crf.canon.fr
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 */
14
15#include <asm.h>
16
17/*
18 * Format of ARM Register structure
19 */
20
21.set REG_R0,  0
22.set REG_R1,  4
23.set REG_R2,  8
24.set REG_R3,  12
25.set REG_R4,  16
26.set REG_R5,  20
27.set REG_R6,  24
28.set REG_R7,  28
29.set REG_R8,  32
30.set REG_R9,  36
31.set REG_R10, 40
32.set REG_FP,  44
33.set REG_IP,  48
34.set REG_SP,  52
35.set REG_LR,  56
36.set REG_PC,  60
37.set SIZE_REGS,   REG_PC + 4
38
39/*
40 *  void _CPU_Context_switch( run_context, heir_context )
41 *
42 *  This routine performs a normal non-FP context.
43 *
44 * R0 = run_context    R1 = heir_context
45 *     
46 */
47
48        .globl _CPU_Context_switch
49
50_CPU_Context_switch:
51        str     r2,  [r0, #REG_R2]
52        str     r3,  [r0, #REG_R3]
53        str     r4,  [r0, #REG_R4]
54        str     r5,  [r0, #REG_R5]
55        str     r6,  [r0, #REG_R6]
56        str     r7,  [r0, #REG_R7]
57        str     r8,  [r0, #REG_R8]
58        str     r9,  [r0, #REG_R9]
59        str     r10, [r0, #REG_R10]
60        str     sp,  [r0, #REG_SP]
61        str     lr,  [r0, #REG_PC]
62       
63        ldr     r2,  [r1, #REG_R2]
64        ldr     r3,  [r1, #REG_R3]
65        ldr     r4,  [r1, #REG_R4]
66        ldr     r5,  [r1, #REG_R5]
67        ldr     r6,  [r1, #REG_R6]
68        ldr     r7,  [r1, #REG_R7]
69        ldr     r8,  [r1, #REG_R8]
70        ldr     r9,  [r1, #REG_R9]
71        ldr     r10, [r1, #REG_R10]
72        ldr     sp,  [r1, #REG_SP]
73        ldr     lr,  [r1, #REG_PC]
74        mov     pc, lr
75
76/*
77 *  NOTE: May be unnecessary to reload some registers.
78 */
79
80/*
81 *  void _CPU_Context_restore( new_context )
82 *
83 *  This routine performs a normal non-FP context.
84 */
85        .globl _CPU_Context_restore
86
87_CPU_Context_restore:
88
89        ldr     r2,  [r0, #REG_R2]
90        ldr     r3,  [r0, #REG_R3]
91        ldr     r4,  [r0, #REG_R4]
92        ldr     r5,  [r0, #REG_R5]
93        ldr     r6,  [r0, #REG_R6]
94        ldr     r7,  [r0, #REG_R7]
95        ldr     r8,  [r0, #REG_R8]
96        ldr     r9,  [r0, #REG_R9]
97        ldr     r10, [r0, #REG_R10]
98        ldr     sp,  [r0, #REG_SP]
99        ldr     lr,  [r0, #REG_PC]
100        mov     pc,  lr
101
102
103        .globl _Exception_Handler_Undef_Swi
104_Exception_Handler_Undef_Swi:
105        sub     r13,r13,#SIZE_REGS
106        str     r0,  [r13, #REG_R0]
107        str     r1,  [r13, #REG_R1]
108        str     r2,  [r13, #REG_R2]
109        str     r3,  [r13, #REG_R3]
110        str     r4,  [r13, #REG_R4]
111        str     r5,  [r13, #REG_R5]
112        str     r6,  [r13, #REG_R6]
113        str     r7,  [r13, #REG_R7]
114        str     r8,  [r13, #REG_R8]
115        str     r9,  [r13, #REG_R9]
116        str     r10, [r13, #REG_R10]
117        str     fp,  [r13, #REG_FP]
118        str     ip,  [r13, #REG_IP]
119        str     sp,  [r13, #REG_SP]
120        str     lr,  [r13, #REG_LR]
121        mrs     r0,  cpsr               /* read the status */
122        and     r0,  r0,#0x1f           /* we keep the mode as exception number */
123        str     r0,  [r13, #REG_PC]     /* we store it in a free place */
124        mov     r0,  r13                /* put frame address in r0 (C arg 1) */
125
126        ldr     r1, =_currentExcHandler
127        ldr     lr, =_go_back_1
128        ldr     pc,[r1]                         /* call handler  */
129_go_back_1:
130        ldr     r0,  [r13, #REG_R0]
131        ldr     r1,  [r13, #REG_R1]
132        ldr     r2,  [r13, #REG_R2]
133        ldr     r3,  [r13, #REG_R3]
134        ldr     r4,  [r13, #REG_R4]
135        ldr     r5,  [r13, #REG_R5]
136        ldr     r6,  [r13, #REG_R6]
137        ldr     r7,  [r13, #REG_R7]
138        ldr     r8,  [r13, #REG_R8]
139        ldr     r9,  [r13, #REG_R9]
140        ldr     r10, [r13, #REG_R10]
141        ldr     fp,  [r13, #REG_FP]
142        ldr     ip,  [r13, #REG_IP]
143        ldr     sp,  [r13, #REG_SP]
144        ldr     lr,  [r13, #REG_LR]
145        add     r13,r13,#SIZE_REGS
146        movs    pc,r14                          /* return  */
147
148        .globl _Exception_Handler_Abort
149_Exception_Handler_Abort:
150        sub     r13,r13,#SIZE_REGS
151        str     r0,  [r13, #REG_R0]
152        str     r1,  [r13, #REG_R1]
153        str     r2,  [r13, #REG_R2]
154        str     r3,  [r13, #REG_R3]
155        str     r4,  [r13, #REG_R4]
156        str     r5,  [r13, #REG_R5]
157        str     r6,  [r13, #REG_R6]
158        str     r7,  [r13, #REG_R7]
159        str     r8,  [r13, #REG_R8]
160        str     r9,  [r13, #REG_R9]
161        str     r10, [r13, #REG_R10]
162        str     sp,  [r13, #REG_FP]
163        str     lr,  [r13, #REG_IP]
164        str     lr,  [r13, #REG_SP]
165        str     lr,  [r13, #REG_LR]
166        mrs     r0,  cpsr               /* read the status */
167        and     r0,  r0,#0x1f           /* we keep the mode as exception number */
168        str     r0,  [r13, #REG_PC]     /* we store it in a free place */
169        mov     r0,  r13                /* put frame address in ro (C arg 1) */
170       
171        ldr     r1, =_currentExcHandler
172        ldr     lr, =_go_back_2
173        ldr     pc,[r1]                         /* call handler  */
174_go_back_2:
175        ldr     r0,  [r13, #REG_R0]
176        ldr     r1,  [r13, #REG_R1]
177        ldr     r2,  [r13, #REG_R2]
178        ldr     r3,  [r13, #REG_R3]
179        ldr     r4,  [r13, #REG_R4]
180        ldr     r5,  [r13, #REG_R5]
181        ldr     r6,  [r13, #REG_R6]
182        ldr     r7,  [r13, #REG_R7]
183        ldr     r8,  [r13, #REG_R8]
184        ldr     r9,  [r13, #REG_R9]
185        ldr     r10, [r13, #REG_R10]
186        ldr     sp,  [r13, #REG_FP]
187        ldr     lr,  [r13, #REG_IP]
188        ldr     lr,  [r13, #REG_SP]
189        ldr     lr,  [r13, #REG_LR]
190        add     r13,r13,#SIZE_REGS
191        subs    pc,r14,#4                       /* return */
192       
193
Note: See TracBrowser for help on using the repository browser.