RTEMS
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 /* Use the right prefix for global labels. */
70 
71 #define SYM(x) RTEMS_XCONCAT(__USER_LABEL_PREFIX__, x)
72 
73 /* Use the right prefix for registers. */
74 
75 #define REG(x) RTEMS_XCONCAT(__REGISTER_PREFIX__, x)
76 
77 /*
78  * define macros for all of the registers on this CPU
79  *
80  * EXAMPLE: #define d0 REG (d0)
81  */
82 
83 /*
84  * Define macros to handle section beginning and ends.
85  */
86 
87 
88 #define BEGIN_CODE_DCL .text
89 #define END_CODE_DCL
90 #define BEGIN_DATA_DCL .data
91 #define END_DATA_DCL
92 #define BEGIN_CODE .text
93 #define END_CODE
94 #define BEGIN_DATA
95 #define END_DATA
96 #define BEGIN_BSS
97 #define END_BSS
98 #define END
99 
100 /*
101  * Following must be tailor for a particular flavor of the C compiler.
102  * They may need to put underscores in front of the symbols.
103  */
104 
105 #define PUBLIC(sym) .globl SYM (sym)
106 #define EXTERN(sym) .globl SYM (sym)
107 
108 /*
109  * Entry for traps which jump to a programmer-specified trap handler.
110  */
111 
112 #define TRAP(_vector, _handler) \
113  mov %psr, %l0 ; \
114  sethi %hi(_handler), %l4 ; \
115  jmp %l4+%lo(_handler); \
116  mov _vector, %l3
117 
118 /*
119  * Used for the reset trap to avoid a supervisor instruction
120  */
121 
122 #define RTRAP(_vector, _handler) \
123  mov %g0, %l0 ; \
124  sethi %hi(_handler), %l4 ; \
125  jmp %l4+%lo(_handler); \
126  mov _vector, %l3
127 
128 #endif
129 
SPARC CPU Department Source.