1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup RTEMSScoreCPUSPARCASM |
---|
5 | * |
---|
6 | * @brief This header file provides interfaces to address problems caused by |
---|
7 | * incompatible flavor of assemblers and toolsets. |
---|
8 | * |
---|
9 | * This include file attempts to address the problems |
---|
10 | * caused by incompatible flavors of assemblers and |
---|
11 | * toolsets. It primarily addresses variations in the |
---|
12 | * use of leading underscores on symbols and the requirement |
---|
13 | * that register names be preceded by a %. |
---|
14 | * |
---|
15 | * NOTE: The spacing in the use of these macros |
---|
16 | * is critical to them working as advertised. |
---|
17 | */ |
---|
18 | |
---|
19 | /* |
---|
20 | * COPYRIGHT: |
---|
21 | * |
---|
22 | * This file is based on similar code found in newlib available |
---|
23 | * from ftp.cygnus.com. The file which was used had no copyright |
---|
24 | * notice. This file is freely distributable as long as the source |
---|
25 | * of the file is noted. |
---|
26 | */ |
---|
27 | |
---|
28 | #ifndef _RTEMS_ASM_H |
---|
29 | #define _RTEMS_ASM_H |
---|
30 | |
---|
31 | /* |
---|
32 | * Indicate we are in an assembly file and get the basic CPU definitions. |
---|
33 | */ |
---|
34 | |
---|
35 | #ifndef ASM |
---|
36 | #define ASM |
---|
37 | #endif |
---|
38 | |
---|
39 | #include <rtems/score/cpuopts.h> |
---|
40 | #include <rtems/score/cpu.h> |
---|
41 | |
---|
42 | /** |
---|
43 | * @defgroup RTEMSScoreCPUSPARCASM SPARC Assembler Support |
---|
44 | * |
---|
45 | * @ingroup RTEMSScoreCPUSPARC |
---|
46 | * |
---|
47 | * @brief SPARC Assembler Support |
---|
48 | * |
---|
49 | * @{ |
---|
50 | */ |
---|
51 | |
---|
52 | /* |
---|
53 | * Recent versions of GNU cpp define variables which indicate the |
---|
54 | * need for underscores and percents. If not using GNU cpp or |
---|
55 | * the version does not support this, then you will obviously |
---|
56 | * have to define these as appropriate. |
---|
57 | */ |
---|
58 | |
---|
59 | /* XXX __USER_LABEL_PREFIX__ and __REGISTER_PREFIX__ do not work on gcc 2.7.0 */ |
---|
60 | /* XXX The following ifdef magic fixes the problem but results in a warning */ |
---|
61 | /* XXX when compiling assembly code. */ |
---|
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 | /* Use the right prefix for global labels. */ |
---|
72 | |
---|
73 | #define SYM(x) RTEMS_XCONCAT(__USER_LABEL_PREFIX__, x) |
---|
74 | |
---|
75 | /* Use the right prefix for registers. */ |
---|
76 | |
---|
77 | #define REG(x) RTEMS_XCONCAT(__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 | |
---|
132 | /** @} */ |
---|