source: rtems/cpukit/score/cpu/arm/rtems/asm.h @ 39c8fdb

4.104.11
Last change on this file since 39c8fdb was 39c8fdb, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on Jan 12, 2010 at 3:03:22 PM

add support for lpc32xx

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