1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief ARM Assembler Support API |
---|
5 | * |
---|
6 | * This include file attempts to address the problems |
---|
7 | * caused by incompatible flavors of assemblers and |
---|
8 | * toolsets. It primarily addresses variations in the |
---|
9 | * use of leading underscores on symbols and the requirement |
---|
10 | * that register names be preceded by a %. |
---|
11 | * |
---|
12 | * |
---|
13 | * NOTE: The spacing in the use of these macros |
---|
14 | * is critical to them working as advertised. |
---|
15 | */ |
---|
16 | |
---|
17 | /* |
---|
18 | * COPYRIGHT: |
---|
19 | * |
---|
20 | * This file is based on similar code found in newlib available |
---|
21 | * from ftp.cygnus.com. The file which was used had no copyright |
---|
22 | * notice. This file is freely distributable as long as the source |
---|
23 | * of the file is noted. This file is: |
---|
24 | * |
---|
25 | * COPYRIGHT (c) 2000 Canon Research Centre France SA. |
---|
26 | * Emmanuel Raguet, mailto:raguet@crf.canon.fr |
---|
27 | * |
---|
28 | * The license and distribution terms for this file may be |
---|
29 | * found in the file LICENSE in this distribution or at |
---|
30 | * http://www.rtems.org/license/LICENSE. |
---|
31 | * |
---|
32 | */ |
---|
33 | |
---|
34 | #ifndef _RTEMS_ASM_H |
---|
35 | #define _RTEMS_ASM_H |
---|
36 | |
---|
37 | /* |
---|
38 | * Indicate we are in an assembly file and get the basic CPU definitions. |
---|
39 | */ |
---|
40 | |
---|
41 | #ifndef ASM |
---|
42 | #define ASM |
---|
43 | #endif |
---|
44 | #include <rtems/score/cpuopts.h> |
---|
45 | #include <rtems/score/arm.h> |
---|
46 | |
---|
47 | /** |
---|
48 | * @defgroup ScoreCPUARMASM ARM Assembler Support |
---|
49 | * |
---|
50 | * @ingroup ScoreCPU |
---|
51 | * |
---|
52 | * @brief ARM Assembler Support |
---|
53 | */ |
---|
54 | /**@{**/ |
---|
55 | |
---|
56 | /* |
---|
57 | * Recent versions of GNU cpp define variables which indicate the |
---|
58 | * need for underscores and percents. If not using GNU cpp or |
---|
59 | * the version does not support this, then you will obviously |
---|
60 | * have to define these as appropriate. |
---|
61 | */ |
---|
62 | |
---|
63 | #ifndef __USER_LABEL_PREFIX__ |
---|
64 | #define __USER_LABEL_PREFIX__ _ |
---|
65 | #endif |
---|
66 | |
---|
67 | #ifndef __REGISTER_PREFIX__ |
---|
68 | #define __REGISTER_PREFIX__ |
---|
69 | #endif |
---|
70 | |
---|
71 | #include <rtems/concat.h> |
---|
72 | |
---|
73 | /* Use the right prefix for global labels. */ |
---|
74 | |
---|
75 | #define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) |
---|
76 | |
---|
77 | /* Use the right prefix for registers. */ |
---|
78 | |
---|
79 | #define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) |
---|
80 | |
---|
81 | /* |
---|
82 | * define macros for all of the registers on this CPU |
---|
83 | * |
---|
84 | * EXAMPLE: #define d0 REG (d0) |
---|
85 | */ |
---|
86 | |
---|
87 | #define r0 REG(r0) |
---|
88 | #define r1 REG(r1) |
---|
89 | #define r2 REG(r2) |
---|
90 | #define r3 REG(r3) |
---|
91 | #define r4 REG(r4) |
---|
92 | #define r5 REG(r5) |
---|
93 | #define r6 REG(r6) |
---|
94 | #define r7 REG(r7) |
---|
95 | #define r8 REG(r8) |
---|
96 | #define r9 REG(r9) |
---|
97 | #define r10 REG(r10) |
---|
98 | #define r11 REG(r11) |
---|
99 | #define r12 REG(r12) |
---|
100 | #define r13 REG(r13) |
---|
101 | #define r14 REG(r14) |
---|
102 | #define r15 REG(r15) |
---|
103 | |
---|
104 | #define CPSR REG(CPSR) |
---|
105 | |
---|
106 | #define SPSR REG(SPSR) |
---|
107 | |
---|
108 | #define NUM_IRQ_VECTOR 6 // IRQ number |
---|
109 | #define NUM_FIQ_VECTOR 7 // IRQ number |
---|
110 | // // |
---|
111 | #define CPSR_IRQ_DISABLE 0x80 // FIQ disabled when =1 |
---|
112 | #define CPSR_FIQ_DISABLE 0x40 // FIQ disabled when =1 |
---|
113 | #define CPSR_THUMB_ENABLE 0x20 // Thumb mode when =1 |
---|
114 | #define CPSR_FIQ_MODE 0x11 |
---|
115 | #define CPSR_IRQ_MODE 0x12 |
---|
116 | #define CPSR_SUPERVISOR_MODE 0x13 |
---|
117 | #define CPSR_UNDEF_MODE 0x1B |
---|
118 | |
---|
119 | #define CPSR_MODE_BITS 0x1F |
---|
120 | |
---|
121 | /* |
---|
122 | * Define macros to handle section beginning and ends. |
---|
123 | */ |
---|
124 | |
---|
125 | |
---|
126 | #define BEGIN_CODE_DCL .text |
---|
127 | #define END_CODE_DCL |
---|
128 | #define BEGIN_DATA_DCL .data |
---|
129 | #define END_DATA_DCL |
---|
130 | #define BEGIN_CODE .text |
---|
131 | #define END_CODE |
---|
132 | #define BEGIN_DATA |
---|
133 | #define END_DATA |
---|
134 | #define BEGIN_BSS |
---|
135 | #define END_BSS |
---|
136 | #define END |
---|
137 | |
---|
138 | /* |
---|
139 | * Following must be tailor for a particular flavor of the C compiler. |
---|
140 | * They may need to put underscores in front of the symbols. |
---|
141 | */ |
---|
142 | |
---|
143 | #define PUBLIC(sym) .globl SYM (sym) |
---|
144 | #define EXTERN(sym) .globl SYM (sym) |
---|
145 | |
---|
146 | #define FUNCTION_THUMB_ENTRY(name) \ |
---|
147 | .thumb; \ |
---|
148 | .thumb_func; \ |
---|
149 | .align 2; \ |
---|
150 | .globl name; \ |
---|
151 | .type name, %function; \ |
---|
152 | name: |
---|
153 | |
---|
154 | #define FUNCTION_ENTRY(name) \ |
---|
155 | .align 2; \ |
---|
156 | .globl name; \ |
---|
157 | .type name, %function; \ |
---|
158 | name: |
---|
159 | |
---|
160 | #define FUNCTION_END(name) \ |
---|
161 | .size name, . - name |
---|
162 | |
---|
163 | #if defined(ARM_MULTILIB_ARCH_V7M) |
---|
164 | #define DEFINE_FUNCTION_ARM(name) \ |
---|
165 | .thumb_func ; .globl name ; name: |
---|
166 | #elif defined(__thumb__) |
---|
167 | #define DEFINE_FUNCTION_ARM(name) \ |
---|
168 | .thumb_func ; .globl name ; name: ; bx pc ; \ |
---|
169 | .arm ; .globl name ## _arm ; name ## _arm: |
---|
170 | #else |
---|
171 | #define DEFINE_FUNCTION_ARM(name) \ |
---|
172 | .globl name ; name: ; .globl name ## _arm ; name ## _arm: |
---|
173 | #endif |
---|
174 | |
---|
175 | .macro SWITCH_FROM_THUMB_TO_ARM |
---|
176 | #ifdef __thumb__ |
---|
177 | .align 2 |
---|
178 | bx pc |
---|
179 | .arm |
---|
180 | #endif /* __thumb__ */ |
---|
181 | .endm |
---|
182 | |
---|
183 | .macro SWITCH_FROM_ARM_TO_THUMB REG |
---|
184 | #ifdef __thumb__ |
---|
185 | add \REG, pc, #1 |
---|
186 | bx \REG |
---|
187 | .thumb |
---|
188 | #endif /* __thumb__ */ |
---|
189 | .endm |
---|
190 | |
---|
191 | /** @} */ |
---|
192 | |
---|
193 | #endif /* _RTEMS_ASM_H */ |
---|