RTEMS  5.0.0
asm.h
Go to the documentation of this file.
1 
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.
24  */
25 
26 #ifndef _RTEMS_ASM_H
27 #define _RTEMS_ASM_H
28 
29 /*
30  * Indicate we are in an assembly file and get the basic CPU definitions.
31  */
32 
33 #ifndef ASM
34 #define ASM
35 #endif
36 
37 #include <rtems/score/cpuopts.h>
38 #include <rtems/score/cpu.h>
39 
50 /*
51  * Recent versions of GNU cpp define variables which indicate the
52  * need for underscores and percents. If not using GNU cpp or
53  * the version does not support this, then you will obviously
54  * have to define these as appropriate.
55  */
56 
57 /* XXX __USER_LABEL_PREFIX__ and __REGISTER_PREFIX__ do not work on gcc 2.7.0 */
58 /* XXX The following ifdef magic fixes the problem but results in a warning */
59 /* XXX when compiling assembly code. */
60 
61 #ifndef __USER_LABEL_PREFIX__
62 #define __USER_LABEL_PREFIX__ _
63 #endif
64 
65 #ifndef __REGISTER_PREFIX__
66 #define __REGISTER_PREFIX__
67 #endif
68 
69 #include <rtems/concat.h>
70 
71 /* Use the right prefix for global labels. */
72 
73 #define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
74 
75 /* Use the right prefix for registers. */
76 
77 #define REG(x) CONCAT1 (__REGISTER_PREFIX__, x)
78 
79 /*
80  * define macros for all of the registers on this CPU
81  *
82  * EXAMPLE: #define d0 REG (d0)
83  */
84 
85 /*
86  * Define macros to handle section beginning and ends.
87  */
88 
89 
90 #define BEGIN_CODE_DCL .text
91 #define END_CODE_DCL
92 #define BEGIN_DATA_DCL .data
93 #define END_DATA_DCL
94 #define BEGIN_CODE .text
95 #define END_CODE
96 #define BEGIN_DATA
97 #define END_DATA
98 #define BEGIN_BSS
99 #define END_BSS
100 #define END
101 
102 /*
103  * Following must be tailor for a particular flavor of the C compiler.
104  * They may need to put underscores in front of the symbols.
105  */
106 
107 #define PUBLIC(sym) .globl SYM (sym)
108 #define EXTERN(sym) .globl SYM (sym)
109 
110 /*
111  * Entry for traps which jump to a programmer-specified trap handler.
112  */
113 
114 #define TRAP(_vector, _handler) \
115  mov %psr, %l0 ; \
116  sethi %hi(_handler), %l4 ; \
117  jmp %l4+%lo(_handler); \
118  mov _vector, %l3
119 
120 /*
121  * Used for the reset trap to avoid a supervisor instruction
122  */
123 
124 #define RTRAP(_vector, _handler) \
125  mov %g0, %l0 ; \
126  sethi %hi(_handler), %l4 ; \
127  jmp %l4+%lo(_handler); \
128  mov _vector, %l3
129 
130 #endif
131