|
15 | 15 | #include <asm/asm.h> |
16 | 16 | #include <asm/asmmacro.h> |
17 | 17 | #include <asm/errno.h> |
| 18 | +#include <asm/export.h> |
18 | 19 | #include <asm/fpregdef.h> |
19 | 20 | #include <asm/mipsregs.h> |
20 | 21 | #include <asm/asm-offsets.h> |
|
34 | 35 | .previous |
35 | 36 | .endm |
36 | 37 |
|
| 38 | +/* |
| 39 | + * Save a thread's fp context. |
| 40 | + */ |
| 41 | +LEAF(_save_fp) |
| 42 | +EXPORT_SYMBOL(_save_fp) |
| 43 | +#if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2) || \ |
| 44 | + defined(CONFIG_CPU_MIPS32_R6) |
| 45 | + mfc0 t0, CP0_STATUS |
| 46 | +#endif |
| 47 | + fpu_save_double a0 t0 t1 # clobbers t1 |
| 48 | + jr ra |
| 49 | + END(_save_fp) |
| 50 | + |
| 51 | +/* |
| 52 | + * Restore a thread's fp context. |
| 53 | + */ |
| 54 | +LEAF(_restore_fp) |
| 55 | +#if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2) || \ |
| 56 | + defined(CONFIG_CPU_MIPS32_R6) |
| 57 | + mfc0 t0, CP0_STATUS |
| 58 | +#endif |
| 59 | + fpu_restore_double a0 t0 t1 # clobbers t1 |
| 60 | + jr ra |
| 61 | + END(_restore_fp) |
| 62 | + |
| 63 | +#ifdef CONFIG_CPU_HAS_MSA |
| 64 | + |
| 65 | +/* |
| 66 | + * Save a thread's MSA vector context. |
| 67 | + */ |
| 68 | +LEAF(_save_msa) |
| 69 | +EXPORT_SYMBOL(_save_msa) |
| 70 | + msa_save_all a0 |
| 71 | + jr ra |
| 72 | + END(_save_msa) |
| 73 | + |
| 74 | +/* |
| 75 | + * Restore a thread's MSA vector context. |
| 76 | + */ |
| 77 | +LEAF(_restore_msa) |
| 78 | + msa_restore_all a0 |
| 79 | + jr ra |
| 80 | + END(_restore_msa) |
| 81 | + |
| 82 | +LEAF(_init_msa_upper) |
| 83 | + msa_init_all_upper |
| 84 | + jr ra |
| 85 | + END(_init_msa_upper) |
| 86 | + |
| 87 | +#endif |
| 88 | + |
| 89 | +/* |
| 90 | + * Load the FPU with signalling NANS. This bit pattern we're using has |
| 91 | + * the property that no matter whether considered as single or as double |
| 92 | + * precision represents signaling NANS. |
| 93 | + * |
| 94 | + * The value to initialize fcr31 to comes in $a0. |
| 95 | + */ |
| 96 | + |
| 97 | + .set push |
| 98 | + SET_HARDFLOAT |
| 99 | + |
| 100 | +LEAF(_init_fpu) |
| 101 | + mfc0 t0, CP0_STATUS |
| 102 | + li t1, ST0_CU1 |
| 103 | + or t0, t1 |
| 104 | + mtc0 t0, CP0_STATUS |
| 105 | + enable_fpu_hazard |
| 106 | + |
| 107 | + ctc1 a0, fcr31 |
| 108 | + |
| 109 | + li t1, -1 # SNaN |
| 110 | + |
| 111 | +#ifdef CONFIG_64BIT |
| 112 | + sll t0, t0, 5 |
| 113 | + bgez t0, 1f # 16 / 32 register mode? |
| 114 | + |
| 115 | + dmtc1 t1, $f1 |
| 116 | + dmtc1 t1, $f3 |
| 117 | + dmtc1 t1, $f5 |
| 118 | + dmtc1 t1, $f7 |
| 119 | + dmtc1 t1, $f9 |
| 120 | + dmtc1 t1, $f11 |
| 121 | + dmtc1 t1, $f13 |
| 122 | + dmtc1 t1, $f15 |
| 123 | + dmtc1 t1, $f17 |
| 124 | + dmtc1 t1, $f19 |
| 125 | + dmtc1 t1, $f21 |
| 126 | + dmtc1 t1, $f23 |
| 127 | + dmtc1 t1, $f25 |
| 128 | + dmtc1 t1, $f27 |
| 129 | + dmtc1 t1, $f29 |
| 130 | + dmtc1 t1, $f31 |
| 131 | +1: |
| 132 | +#endif |
| 133 | + |
| 134 | +#ifdef CONFIG_CPU_MIPS32 |
| 135 | + mtc1 t1, $f0 |
| 136 | + mtc1 t1, $f1 |
| 137 | + mtc1 t1, $f2 |
| 138 | + mtc1 t1, $f3 |
| 139 | + mtc1 t1, $f4 |
| 140 | + mtc1 t1, $f5 |
| 141 | + mtc1 t1, $f6 |
| 142 | + mtc1 t1, $f7 |
| 143 | + mtc1 t1, $f8 |
| 144 | + mtc1 t1, $f9 |
| 145 | + mtc1 t1, $f10 |
| 146 | + mtc1 t1, $f11 |
| 147 | + mtc1 t1, $f12 |
| 148 | + mtc1 t1, $f13 |
| 149 | + mtc1 t1, $f14 |
| 150 | + mtc1 t1, $f15 |
| 151 | + mtc1 t1, $f16 |
| 152 | + mtc1 t1, $f17 |
| 153 | + mtc1 t1, $f18 |
| 154 | + mtc1 t1, $f19 |
| 155 | + mtc1 t1, $f20 |
| 156 | + mtc1 t1, $f21 |
| 157 | + mtc1 t1, $f22 |
| 158 | + mtc1 t1, $f23 |
| 159 | + mtc1 t1, $f24 |
| 160 | + mtc1 t1, $f25 |
| 161 | + mtc1 t1, $f26 |
| 162 | + mtc1 t1, $f27 |
| 163 | + mtc1 t1, $f28 |
| 164 | + mtc1 t1, $f29 |
| 165 | + mtc1 t1, $f30 |
| 166 | + mtc1 t1, $f31 |
| 167 | + |
| 168 | +#if defined(CONFIG_CPU_MIPS32_R2) || defined(CONFIG_CPU_MIPS32_R6) |
| 169 | + .set push |
| 170 | + .set MIPS_ISA_LEVEL_RAW |
| 171 | + .set fp=64 |
| 172 | + sll t0, t0, 5 # is Status.FR set? |
| 173 | + bgez t0, 1f # no: skip setting upper 32b |
| 174 | + |
| 175 | + mthc1 t1, $f0 |
| 176 | + mthc1 t1, $f1 |
| 177 | + mthc1 t1, $f2 |
| 178 | + mthc1 t1, $f3 |
| 179 | + mthc1 t1, $f4 |
| 180 | + mthc1 t1, $f5 |
| 181 | + mthc1 t1, $f6 |
| 182 | + mthc1 t1, $f7 |
| 183 | + mthc1 t1, $f8 |
| 184 | + mthc1 t1, $f9 |
| 185 | + mthc1 t1, $f10 |
| 186 | + mthc1 t1, $f11 |
| 187 | + mthc1 t1, $f12 |
| 188 | + mthc1 t1, $f13 |
| 189 | + mthc1 t1, $f14 |
| 190 | + mthc1 t1, $f15 |
| 191 | + mthc1 t1, $f16 |
| 192 | + mthc1 t1, $f17 |
| 193 | + mthc1 t1, $f18 |
| 194 | + mthc1 t1, $f19 |
| 195 | + mthc1 t1, $f20 |
| 196 | + mthc1 t1, $f21 |
| 197 | + mthc1 t1, $f22 |
| 198 | + mthc1 t1, $f23 |
| 199 | + mthc1 t1, $f24 |
| 200 | + mthc1 t1, $f25 |
| 201 | + mthc1 t1, $f26 |
| 202 | + mthc1 t1, $f27 |
| 203 | + mthc1 t1, $f28 |
| 204 | + mthc1 t1, $f29 |
| 205 | + mthc1 t1, $f30 |
| 206 | + mthc1 t1, $f31 |
| 207 | +1: .set pop |
| 208 | +#endif /* CONFIG_CPU_MIPS32_R2 || CONFIG_CPU_MIPS32_R6 */ |
| 209 | +#else |
| 210 | + .set MIPS_ISA_ARCH_LEVEL_RAW |
| 211 | + dmtc1 t1, $f0 |
| 212 | + dmtc1 t1, $f2 |
| 213 | + dmtc1 t1, $f4 |
| 214 | + dmtc1 t1, $f6 |
| 215 | + dmtc1 t1, $f8 |
| 216 | + dmtc1 t1, $f10 |
| 217 | + dmtc1 t1, $f12 |
| 218 | + dmtc1 t1, $f14 |
| 219 | + dmtc1 t1, $f16 |
| 220 | + dmtc1 t1, $f18 |
| 221 | + dmtc1 t1, $f20 |
| 222 | + dmtc1 t1, $f22 |
| 223 | + dmtc1 t1, $f24 |
| 224 | + dmtc1 t1, $f26 |
| 225 | + dmtc1 t1, $f28 |
| 226 | + dmtc1 t1, $f30 |
| 227 | +#endif |
| 228 | + jr ra |
| 229 | + END(_init_fpu) |
| 230 | + |
| 231 | + .set pop /* SET_HARDFLOAT */ |
| 232 | + |
37 | 233 | .set noreorder |
38 | 234 |
|
39 | 235 | /** |
|
0 commit comments