2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2003 Ralf Baechle
8 #ifndef _ASM_ASMMACRO_H
9 #define _ASM_ASMMACRO_H
11 #include <asm/hazards.h>
12 #include <asm/asm-offsets.h>
16 #include <asm/asmmacro-32.h>
19 #include <asm/asmmacro-64.h>
22 #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_CPU_MIPSR6)
23 .macro local_irq_enable reg
=t0
28 .macro local_irq_disable reg
=t0
33 .macro local_irq_enable reg
=t0
40 .macro local_irq_disable reg
=t0
42 lw
\reg
, TI_PRE_COUNT($
28)
44 sw
\reg
, TI_PRE_COUNT($
28)
52 lw
\reg
, TI_PRE_COUNT($
28)
54 sw
\reg
, TI_PRE_COUNT($
28)
57 #endif /* CONFIG_CPU_MIPSR2 */
59 .macro fpu_save_16even thread tmp
=t0
63 sdc1 $f0
, THREAD_FPR0(\thread
)
64 sdc1 $f2
, THREAD_FPR2(\thread
)
65 sdc1 $f4
, THREAD_FPR4(\thread
)
66 sdc1 $f6
, THREAD_FPR6(\thread
)
67 sdc1 $f8
, THREAD_FPR8(\thread
)
68 sdc1 $f10
, THREAD_FPR10(\thread
)
69 sdc1 $f12
, THREAD_FPR12(\thread
)
70 sdc1 $f14
, THREAD_FPR14(\thread
)
71 sdc1 $f16
, THREAD_FPR16(\thread
)
72 sdc1 $f18
, THREAD_FPR18(\thread
)
73 sdc1 $f20
, THREAD_FPR20(\thread
)
74 sdc1 $f22
, THREAD_FPR22(\thread
)
75 sdc1 $f24
, THREAD_FPR24(\thread
)
76 sdc1 $f26
, THREAD_FPR26(\thread
)
77 sdc1 $f28
, THREAD_FPR28(\thread
)
78 sdc1 $f30
, THREAD_FPR30(\thread
)
79 sw
\tmp
, THREAD_FCR31(\thread
)
83 .macro fpu_save_16odd thread
87 sdc1 $f1
, THREAD_FPR1(\thread
)
88 sdc1 $f3
, THREAD_FPR3(\thread
)
89 sdc1 $f5
, THREAD_FPR5(\thread
)
90 sdc1 $f7
, THREAD_FPR7(\thread
)
91 sdc1 $f9
, THREAD_FPR9(\thread
)
92 sdc1 $f11
, THREAD_FPR11(\thread
)
93 sdc1 $f13
, THREAD_FPR13(\thread
)
94 sdc1 $f15
, THREAD_FPR15(\thread
)
95 sdc1 $f17
, THREAD_FPR17(\thread
)
96 sdc1 $f19
, THREAD_FPR19(\thread
)
97 sdc1 $f21
, THREAD_FPR21(\thread
)
98 sdc1 $f23
, THREAD_FPR23(\thread
)
99 sdc1 $f25
, THREAD_FPR25(\thread
)
100 sdc1 $f27
, THREAD_FPR27(\thread
)
101 sdc1 $f29
, THREAD_FPR29(\thread
)
102 sdc1 $f31
, THREAD_FPR31(\thread
)
106 .macro fpu_save_double thread status tmp
107 #if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2) || \
108 defined(CONFIG_CPU_MIPS32_R6)
111 fpu_save_16odd
\thread
114 fpu_save_16even
\thread
\tmp
117 .macro fpu_restore_16even thread tmp
=t0
120 lw
\tmp
, THREAD_FCR31(\thread
)
121 ldc1 $f0
, THREAD_FPR0(\thread
)
122 ldc1 $f2
, THREAD_FPR2(\thread
)
123 ldc1 $f4
, THREAD_FPR4(\thread
)
124 ldc1 $f6
, THREAD_FPR6(\thread
)
125 ldc1 $f8
, THREAD_FPR8(\thread
)
126 ldc1 $f10
, THREAD_FPR10(\thread
)
127 ldc1 $f12
, THREAD_FPR12(\thread
)
128 ldc1 $f14
, THREAD_FPR14(\thread
)
129 ldc1 $f16
, THREAD_FPR16(\thread
)
130 ldc1 $f18
, THREAD_FPR18(\thread
)
131 ldc1 $f20
, THREAD_FPR20(\thread
)
132 ldc1 $f22
, THREAD_FPR22(\thread
)
133 ldc1 $f24
, THREAD_FPR24(\thread
)
134 ldc1 $f26
, THREAD_FPR26(\thread
)
135 ldc1 $f28
, THREAD_FPR28(\thread
)
136 ldc1 $f30
, THREAD_FPR30(\thread
)
140 .macro fpu_restore_16odd thread
144 ldc1 $f1
, THREAD_FPR1(\thread
)
145 ldc1 $f3
, THREAD_FPR3(\thread
)
146 ldc1 $f5
, THREAD_FPR5(\thread
)
147 ldc1 $f7
, THREAD_FPR7(\thread
)
148 ldc1 $f9
, THREAD_FPR9(\thread
)
149 ldc1 $f11
, THREAD_FPR11(\thread
)
150 ldc1 $f13
, THREAD_FPR13(\thread
)
151 ldc1 $f15
, THREAD_FPR15(\thread
)
152 ldc1 $f17
, THREAD_FPR17(\thread
)
153 ldc1 $f19
, THREAD_FPR19(\thread
)
154 ldc1 $f21
, THREAD_FPR21(\thread
)
155 ldc1 $f23
, THREAD_FPR23(\thread
)
156 ldc1 $f25
, THREAD_FPR25(\thread
)
157 ldc1 $f27
, THREAD_FPR27(\thread
)
158 ldc1 $f29
, THREAD_FPR29(\thread
)
159 ldc1 $f31
, THREAD_FPR31(\thread
)
163 .macro fpu_restore_double thread status tmp
164 #if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2) || \
165 defined(CONFIG_CPU_MIPS32_R6)
167 bgez
\tmp
, 10f
# 16 register mode?
169 fpu_restore_16odd
\thread
172 fpu_restore_16even
\thread
\tmp
175 #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_CPU_MIPSR6)
176 .macro _EXT rd
, rs
, p
, s
179 #else /* !CONFIG_CPU_MIPSR2 || !CONFIG_CPU_MIPSR6 */
180 .macro _EXT rd
, rs
, p
, s
182 andi
\rd
, \rd
, (1 << \s
) - 1
184 #endif /* !CONFIG_CPU_MIPSR2 || !CONFIG_CPU_MIPSR6 */
187 * Temporary until all gas have MT ASE support
190 .word
0x41600bc1 | (\reg
<< 16)
194 .word
0x41600be1 | (\reg
<< 16)
198 .word
0x41600001 | (\reg
<< 16)
202 .word
0x41600021 | (\reg
<< 16)
205 .macro MFTR rt
=0, rd
=0, u
=0, sel
=0
206 .word
0x41000000 | (\rt
<< 16) | (\rd
<< 11) | (\u
<< 5) | (\sel
)
209 .macro MTTR rt
=0, rd
=0, u
=0, sel
=0
210 .word
0x41800000 | (\rt
<< 16) | (\rd
<< 11) | (\u
<< 5) | (\sel
)
213 #ifdef TOOLCHAIN_SUPPORTS_MSA
214 /* preprocessor replaces the fp in ".set fp=64" with $30 otherwise */
217 .macro _cfcmsa rd
, cs
226 .macro _ctcmsa cd
, rs
235 .macro ld_b wd
, off
, base
239 ld
.b $w\wd
, \
off(\base
)
243 .macro ld_h wd
, off
, base
247 ld
.h $w\wd
, \
off(\base
)
251 .macro ld_w wd
, off
, base
255 ld
.w $w\wd
, \
off(\base
)
259 .macro ld_d wd
, off
, base
264 ld
.d $w\wd
, \
off(\base
)
268 .macro st_b wd
, off
, base
272 st
.b $w\wd
, \
off(\base
)
276 .macro st_h wd
, off
, base
280 st
.h $w\wd
, \
off(\base
)
284 .macro st_w wd
, off
, base
288 st
.w $w\wd
, \
off(\base
)
292 .macro st_d wd
, off
, base
297 st
.d $w\wd
, \
off(\base
)
301 .macro copy_u_w ws
, n
306 copy_u
.w $
1, $w\ws
[\n]
310 .macro copy_u_d ws
, n
315 copy_u
.d $
1, $w\ws
[\n]
319 .macro insert_w wd
, n
324 insert
.w $w\wd
[\n], $
1
328 .macro insert_d wd
, n
333 insert
.d $w\wd
[\n], $
1
338 #ifdef CONFIG_CPU_MICROMIPS
339 #define CFC_MSA_INSN 0x587e0056
340 #define CTC_MSA_INSN 0x583e0816
341 #define LDB_MSA_INSN 0x58000807
342 #define LDH_MSA_INSN 0x58000817
343 #define LDW_MSA_INSN 0x58000827
344 #define LDD_MSA_INSN 0x58000837
345 #define STB_MSA_INSN 0x5800080f
346 #define STH_MSA_INSN 0x5800081f
347 #define STW_MSA_INSN 0x5800082f
348 #define STD_MSA_INSN 0x5800083f
349 #define COPY_UW_MSA_INSN 0x58f00056
350 #define COPY_UD_MSA_INSN 0x58f80056
351 #define INSERT_W_MSA_INSN 0x59300816
352 #define INSERT_D_MSA_INSN 0x59380816
354 #define CFC_MSA_INSN 0x787e0059
355 #define CTC_MSA_INSN 0x783e0819
356 #define LDB_MSA_INSN 0x78000820
357 #define LDH_MSA_INSN 0x78000821
358 #define LDW_MSA_INSN 0x78000822
359 #define LDD_MSA_INSN 0x78000823
360 #define STB_MSA_INSN 0x78000824
361 #define STH_MSA_INSN 0x78000825
362 #define STW_MSA_INSN 0x78000826
363 #define STD_MSA_INSN 0x78000827
364 #define COPY_UW_MSA_INSN 0x78f00059
365 #define COPY_UD_MSA_INSN 0x78f80059
366 #define INSERT_W_MSA_INSN 0x79300819
367 #define INSERT_D_MSA_INSN 0x79380819
371 * Temporary until all toolchains in use include MSA support.
373 .macro _cfcmsa rd
, cs
378 .word CFC_MSA_INSN
| (\cs
<< 11)
383 .macro _ctcmsa cd
, rs
388 .word CTC_MSA_INSN
| (\cd
<< 6)
392 .macro ld_b wd
, off
, base
397 .word LDB_MSA_INSN
| (\wd
<< 6)
401 .macro ld_h wd
, off
, base
406 .word LDH_MSA_INSN
| (\wd
<< 6)
410 .macro ld_w wd
, off
, base
415 .word LDW_MSA_INSN
| (\wd
<< 6)
419 .macro ld_d wd
, off
, base
424 .word LDD_MSA_INSN
| (\wd
<< 6)
428 .macro st_b wd
, off
, base
433 .word STB_MSA_INSN
| (\wd
<< 6)
437 .macro st_h wd
, off
, base
442 .word STH_MSA_INSN
| (\wd
<< 6)
446 .macro st_w wd
, off
, base
451 .word STW_MSA_INSN
| (\wd
<< 6)
455 .macro st_d wd
, off
, base
460 .word STD_MSA_INSN
| (\wd
<< 6)
464 .macro copy_u_w ws
, n
469 .word COPY_UW_MSA_INSN
| (\n << 16) | (\ws
<< 11)
473 .macro copy_u_d ws
, n
478 .word COPY_UD_MSA_INSN
| (\n << 16) | (\ws
<< 11)
482 .macro insert_w wd
, n
486 .word INSERT_W_MSA_INSN
| (\n << 16) | (\wd
<< 6)
490 .macro insert_d wd
, n
494 .word INSERT_D_MSA_INSN
| (\n << 16) | (\wd
<< 6)
499 .macro msa_save_all thread
500 st_d
0, THREAD_FPR0
, \thread
501 st_d
1, THREAD_FPR1
, \thread
502 st_d
2, THREAD_FPR2
, \thread
503 st_d
3, THREAD_FPR3
, \thread
504 st_d
4, THREAD_FPR4
, \thread
505 st_d
5, THREAD_FPR5
, \thread
506 st_d
6, THREAD_FPR6
, \thread
507 st_d
7, THREAD_FPR7
, \thread
508 st_d
8, THREAD_FPR8
, \thread
509 st_d
9, THREAD_FPR9
, \thread
510 st_d
10, THREAD_FPR10
, \thread
511 st_d
11, THREAD_FPR11
, \thread
512 st_d
12, THREAD_FPR12
, \thread
513 st_d
13, THREAD_FPR13
, \thread
514 st_d
14, THREAD_FPR14
, \thread
515 st_d
15, THREAD_FPR15
, \thread
516 st_d
16, THREAD_FPR16
, \thread
517 st_d
17, THREAD_FPR17
, \thread
518 st_d
18, THREAD_FPR18
, \thread
519 st_d
19, THREAD_FPR19
, \thread
520 st_d
20, THREAD_FPR20
, \thread
521 st_d
21, THREAD_FPR21
, \thread
522 st_d
22, THREAD_FPR22
, \thread
523 st_d
23, THREAD_FPR23
, \thread
524 st_d
24, THREAD_FPR24
, \thread
525 st_d
25, THREAD_FPR25
, \thread
526 st_d
26, THREAD_FPR26
, \thread
527 st_d
27, THREAD_FPR27
, \thread
528 st_d
28, THREAD_FPR28
, \thread
529 st_d
29, THREAD_FPR29
, \thread
530 st_d
30, THREAD_FPR30
, \thread
531 st_d
31, THREAD_FPR31
, \thread
536 sw $
1, THREAD_MSA_CSR(\thread
)
540 .macro msa_restore_all thread
544 lw $
1, THREAD_MSA_CSR(\thread
)
547 ld_d
0, THREAD_FPR0
, \thread
548 ld_d
1, THREAD_FPR1
, \thread
549 ld_d
2, THREAD_FPR2
, \thread
550 ld_d
3, THREAD_FPR3
, \thread
551 ld_d
4, THREAD_FPR4
, \thread
552 ld_d
5, THREAD_FPR5
, \thread
553 ld_d
6, THREAD_FPR6
, \thread
554 ld_d
7, THREAD_FPR7
, \thread
555 ld_d
8, THREAD_FPR8
, \thread
556 ld_d
9, THREAD_FPR9
, \thread
557 ld_d
10, THREAD_FPR10
, \thread
558 ld_d
11, THREAD_FPR11
, \thread
559 ld_d
12, THREAD_FPR12
, \thread
560 ld_d
13, THREAD_FPR13
, \thread
561 ld_d
14, THREAD_FPR14
, \thread
562 ld_d
15, THREAD_FPR15
, \thread
563 ld_d
16, THREAD_FPR16
, \thread
564 ld_d
17, THREAD_FPR17
, \thread
565 ld_d
18, THREAD_FPR18
, \thread
566 ld_d
19, THREAD_FPR19
, \thread
567 ld_d
20, THREAD_FPR20
, \thread
568 ld_d
21, THREAD_FPR21
, \thread
569 ld_d
22, THREAD_FPR22
, \thread
570 ld_d
23, THREAD_FPR23
, \thread
571 ld_d
24, THREAD_FPR24
, \thread
572 ld_d
25, THREAD_FPR25
, \thread
573 ld_d
26, THREAD_FPR26
, \thread
574 ld_d
27, THREAD_FPR27
, \thread
575 ld_d
28, THREAD_FPR28
, \thread
576 ld_d
29, THREAD_FPR29
, \thread
577 ld_d
30, THREAD_FPR30
, \thread
578 ld_d
31, THREAD_FPR31
, \thread
581 .macro msa_init_upper wd
590 .macro msa_init_all_upper
630 #endif /* _ASM_ASMMACRO_H */