1 | /* asm.h |
---|
2 | * |
---|
3 | * This include file attempts to address the problems |
---|
4 | * caused by incompatible flavors of assemblers and |
---|
5 | * toolsets. It primarily addresses variations in the |
---|
6 | * use of leading underscores on symbols and the requirement |
---|
7 | * that register names be preceded by a %. |
---|
8 | * |
---|
9 | * |
---|
10 | * NOTE: The spacing in the use of these macros |
---|
11 | * is critical to them working as advertised. |
---|
12 | * |
---|
13 | * COPYRIGHT: |
---|
14 | * |
---|
15 | * This file is based on similar code found in newlib available |
---|
16 | * from ftp.cygnus.com. The file which was used had no copyright |
---|
17 | * notice. This file is freely distributable as long as the source |
---|
18 | * of the file is noted. |
---|
19 | * |
---|
20 | * $Id$ |
---|
21 | */ |
---|
22 | |
---|
23 | #ifndef __SPARC_ASM_h |
---|
24 | #define __SPARC_ASM_h |
---|
25 | |
---|
26 | /* |
---|
27 | * Indicate we are in an assembly file and get the basic CPU definitions. |
---|
28 | */ |
---|
29 | |
---|
30 | #define ASM |
---|
31 | |
---|
32 | #include <rtems/score/targopts.h> |
---|
33 | #include <rtems/score/cpu.h> |
---|
34 | |
---|
35 | /* |
---|
36 | * Recent versions of GNU cpp define variables which indicate the |
---|
37 | * need for underscores and percents. If not using GNU cpp or |
---|
38 | * the version does not support this, then you will obviously |
---|
39 | * have to define these as appropriate. |
---|
40 | */ |
---|
41 | |
---|
42 | /* XXX __USER_LABEL_PREFIX__ and __REGISTER_PREFIX__ do not work on gcc 2.7.0 */ |
---|
43 | /* XXX The following ifdef magic fixes the problem but results in a warning */ |
---|
44 | /* XXX when compiling assembly code. */ |
---|
45 | #undef __USER_LABEL_PREFIX__ |
---|
46 | #ifndef __USER_LABEL_PREFIX__ |
---|
47 | #define __USER_LABEL_PREFIX__ _ |
---|
48 | #endif |
---|
49 | |
---|
50 | #ifndef __REGISTER_PREFIX__ |
---|
51 | #define __REGISTER_PREFIX__ |
---|
52 | #endif |
---|
53 | |
---|
54 | /* ANSI concatenation macros. */ |
---|
55 | |
---|
56 | #define CONCAT1(a, b) CONCAT2(a, b) |
---|
57 | #define CONCAT2(a, b) a ## b |
---|
58 | |
---|
59 | /* Use the right prefix for global labels. */ |
---|
60 | |
---|
61 | #define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) |
---|
62 | |
---|
63 | /* Use the right prefix for registers. */ |
---|
64 | |
---|
65 | #define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) |
---|
66 | |
---|
67 | /* |
---|
68 | * define macros for all of the registers on this CPU |
---|
69 | * |
---|
70 | * EXAMPLE: #define d0 REG (d0) |
---|
71 | */ |
---|
72 | |
---|
73 | /* |
---|
74 | * Define macros to handle section beginning and ends. |
---|
75 | */ |
---|
76 | |
---|
77 | |
---|
78 | #define BEGIN_CODE_DCL .text |
---|
79 | #define END_CODE_DCL |
---|
80 | #define BEGIN_DATA_DCL .data |
---|
81 | #define END_DATA_DCL |
---|
82 | #define BEGIN_CODE .text |
---|
83 | #define END_CODE |
---|
84 | #define BEGIN_DATA |
---|
85 | #define END_DATA |
---|
86 | #define BEGIN_BSS |
---|
87 | #define END_BSS |
---|
88 | #define END |
---|
89 | |
---|
90 | /* |
---|
91 | * Following must be tailor for a particular flavor of the C compiler. |
---|
92 | * They may need to put underscores in front of the symbols. |
---|
93 | */ |
---|
94 | |
---|
95 | #define PUBLIC(sym) .globl SYM (sym) |
---|
96 | #define EXTERN(sym) .globl SYM (sym) |
---|
97 | |
---|
98 | /* |
---|
99 | * Entry for traps which jump to a programmer-specified trap handler. |
---|
100 | */ |
---|
101 | |
---|
102 | #define TRAP(_vector, _handler) \ |
---|
103 | mov %psr, %l0 ; \ |
---|
104 | sethi %hi(_handler), %l4 ; \ |
---|
105 | jmp %l4+%lo(_handler); \ |
---|
106 | mov _vector, %l3 |
---|
107 | |
---|
108 | /* |
---|
109 | * Used for the reset trap for ERC32 to avoid a supervisor instruction |
---|
110 | */ |
---|
111 | |
---|
112 | #define RTRAP(_vector, _handler) \ |
---|
113 | mov %g0, %l0 ; \ |
---|
114 | sethi %hi(_handler), %l4 ; \ |
---|
115 | jmp %l4+%lo(_handler); \ |
---|
116 | mov _vector, %l3 |
---|
117 | |
---|
118 | #endif |
---|
119 | /* end of include file */ |
---|
120 | |
---|
121 | |
---|