source: rtems/cpukit/score/cpu/arm/rtems/asm.h @ 78623bce

4.104.115
Last change on this file since 78623bce was 78623bce, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 04/08/10 at 10:13:46

add/adapt documentation

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