^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * License. See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 1996, 1998 by Ralf Baechle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Multi-arch abstraction and asm macros for easier reading:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Further modifications to make this work:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Copyright (c) 1998 Harald Koerfgen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/asm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/asmmacro.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <asm/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/fpregdef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <asm/mipsregs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <asm/asm-offsets.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <asm/regdef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define EX(a,b) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 9: a,##b; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) .section __ex_table,"a"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) PTR 9b,fault; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) .previous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define EX2(a,b) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 9: a,##b; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) .section __ex_table,"a"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) PTR 9b,fault; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) PTR 9b+4,fault; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) .previous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) .set mips1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * Save a thread's fp context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) LEAF(_save_fp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) EXPORT_SYMBOL(_save_fp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) fpu_save_single a0, t1 # clobbers t1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) jr ra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) END(_save_fp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * Restore a thread's fp context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) LEAF(_restore_fp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) fpu_restore_single a0, t1 # clobbers t1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) jr ra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) END(_restore_fp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) .set noreorder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * _save_fp_context() - save FP context from the FPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * @a0 - pointer to fpregs field of sigcontext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * @a1 - pointer to fpc_csr field of sigcontext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * Save FP context, including the 32 FP data registers and the FP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * control & status register, from the FPU to signal context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) LEAF(_save_fp_context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) .set push
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) SET_HARDFLOAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) li v0, 0 # assume success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) cfc1 t1, fcr31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) EX2(s.d $f0, 0(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) EX2(s.d $f2, 16(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) EX2(s.d $f4, 32(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) EX2(s.d $f6, 48(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) EX2(s.d $f8, 64(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) EX2(s.d $f10, 80(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) EX2(s.d $f12, 96(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) EX2(s.d $f14, 112(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) EX2(s.d $f16, 128(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) EX2(s.d $f18, 144(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) EX2(s.d $f20, 160(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) EX2(s.d $f22, 176(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) EX2(s.d $f24, 192(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) EX2(s.d $f26, 208(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) EX2(s.d $f28, 224(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) EX2(s.d $f30, 240(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) jr ra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) EX(sw t1, (a1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .set pop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) END(_save_fp_context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * _restore_fp_context() - restore FP context to the FPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * @a0 - pointer to fpregs field of sigcontext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * @a1 - pointer to fpc_csr field of sigcontext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * Restore FP context, including the 32 FP data registers and the FP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * control & status register, from signal context to the FPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) LEAF(_restore_fp_context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) .set push
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) SET_HARDFLOAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) li v0, 0 # assume success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) EX(lw t0, (a1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) EX2(l.d $f0, 0(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) EX2(l.d $f2, 16(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) EX2(l.d $f4, 32(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) EX2(l.d $f6, 48(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) EX2(l.d $f8, 64(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) EX2(l.d $f10, 80(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) EX2(l.d $f12, 96(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) EX2(l.d $f14, 112(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) EX2(l.d $f16, 128(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) EX2(l.d $f18, 144(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) EX2(l.d $f20, 160(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) EX2(l.d $f22, 176(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) EX2(l.d $f24, 192(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) EX2(l.d $f26, 208(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) EX2(l.d $f28, 224(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) EX2(l.d $f30, 240(a0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) jr ra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) ctc1 t0, fcr31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) .set pop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) END(_restore_fp_context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) .set reorder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) .type fault, @function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) .ent fault
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) fault: li v0, -EFAULT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) jr ra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) .end fault