1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #ifndef __ASM_ASM_H
17 #define __ASM_ASM_H
18
19 #include <linux/config.h>
20 #include <asm/regdef.h>
21 #include <asm/fpregdef.h>
22
23 #ifndef CAT
24 #ifdef __STDC__
25 #define __CAT(str1,str2) str1##str2
26 #else
27 #define __CAT(str1,str2) str1str2
28 #endif
29 #define CAT(str1,str2) __CAT(str1,str2)
30 #endif
31
32
33
34
35 #if __mips == 3
36 #define PTR .quad
37 #define PTRSIZE 8
38 #define PTRLOG 3
39 #define lp ld
40 #else
41 #define PTR .word
42 #define PTRSIZE 4
43 #define PTRLOG 2
44 #define lp lw
45 #endif
46
47
48
49
50 #ifdef __ELF__
51 #define TYPE(symbol,_type) \
52 .type symbol,@_type
53 #define SIZE(symbol,_size) \
54 .size symbol,_size
55 #else
56 #define TYPE(symbol,type)
57 #define SIZE(symbol,size)
58 #endif
59
60
61
62
63
64 #ifdef __PIC__
65 #define CPRESTORE(register) \
66 .cprestore register
67 #define CPADD(register) \
68 .cpadd register
69 #define CPLOAD(register) \
70 .cpload register
71 #else
72 #define CPRESTORE(register)
73 #define CPADD(register)
74 #define CPLOAD(register)
75 #endif
76
77
78
79
80 #define LEAF(symbol) \
81 .globl symbol; \
82 .align 2; \
83 TYPE(symbol,function); \
84 .ent symbol,0; \
85 symbol: .frame sp,0,ra
86
87
88
89
90 #define NESTED(symbol, framesize, rpc) \
91 .globl symbol; \
92 .align 2; \
93 TYPE(symbol,function); \
94 .ent symbol,0; \
95 symbol: .frame sp, framesize, rpc
96
97
98
99
100 #define END(function) \
101 .end function; \
102 SIZE(function,.-function)
103
104
105
106
107 #define EXPORT(symbol) \
108 .globl symbol; \
109 symbol:
110
111
112
113
114 #define ABS(symbol,value) \
115 .globl symbol; \
116 symbol = value
117
118 #define PANIC(msg) \
119 la a0,8f; \
120 jal panic; \
121 nop; \
122 9: b 9b; \
123 nop; \
124 TEXT(msg)
125
126
127
128
129 #define PRINT(string) \
130 la a0,8f; \
131 jal printk; \
132 nop; \
133 TEXT(string)
134
135 #define TEXT(msg) \
136 .data; \
137 8: .asciiz msg; \
138 .text
139
140
141
142
143 #define TTABLE(string) \
144 .text; \
145 .word 1f; \
146 .data; \
147 1: .asciz string; \
148 .text;
149
150
151
152
153
154
155
156
157
158 #define CLI \
159 mfc0 AT,CP0_STATUS; \
160 li t0,ST0_CU0|0x1f; \
161 or AT,t0; \
162 xori AT,0x1f; \
163 mtc0 AT,CP0_STATUS; \
164
165
166
167
168
169
170
171
172
173 #define STI \
174 mfc0 AT,CP0_STATUS; \
175 li t0,ST0_CU0|0x1f; \
176 or AT,t0; \
177 xori AT,0x1e; \
178 mtc0 AT,CP0_STATUS; \
179
180
181
182
183 #ifndef __R4000__
184 #define NOP nop
185 #else
186 #define NOP
187 #endif
188
189
190
191
192 #if defined (CONFIG_CPU_R3000)
193 #define ERET rfe
194 #elif defined (CONFIG_CPU_R4X00) || defined (CONFIG_CPU_R4600)
195 #define ERET \
196 .set mips3; \
197 eret; \
198 .set mips0
199 #else
200 #error "Implement ERET macro!"
201 #endif
202
203
204
205
206
207 #if defined (CONFIG_CPU_R8000) || defined(CONFIG_CPU_R10000)
208 #define PREF(hint,addr) \
209 pref hint,addr
210 #define PREFX(hint,addr) \
211 prefx hint,addr
212 #else
213 #define PREF
214 #define PREFX
215 #endif
216
217
218
219
220
221 #if defined (CONFIG_CPU_R8000) || defined (CONFIG_CPU_R10000)
222 #define MOVN(rd,rs,rt) \
223 movn rd,rs,rt
224 #define MOVZ(rd,rs,rt) \
225 movz rd,rs,rt
226 #elif defined (CONFIG_CPU_R4000) || defined (CONFIG_CPU_R6000)
227 #define MOVN(rd,rs,rt) \
228 bnezl rt,9f \
229 move rd,rs \
230 9:
231 #define MOVZ(rd,rs,rt) \
232 beqzl rt,9f \
233 movz rd,rt \
234 9:
235 #else
236 #define MOVN(rd,rs,rt) \
237 beqz rt,9f \
238 nop \
239 move rd,rs \
240 9:
241 #define MOVZ(rd,rs,rt) \
242 bneqz rt,9f \
243 nop \
244 movz rd,rt \
245 9:
246 #endif
247
248 #endif