Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * Copyright (C) 1996, 1998 by Ralf Baechle
0007  *
0008  * Multi-arch abstraction and asm macros for easier reading:
0009  * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
0010  *
0011  * Further modifications to make this work:
0012  * Copyright (c) 1998 Harald Koerfgen
0013  */
0014 #include <asm/asm.h>
0015 #include <asm/asmmacro.h>
0016 #include <asm/errno.h>
0017 #include <asm/export.h>
0018 #include <asm/fpregdef.h>
0019 #include <asm/mipsregs.h>
0020 #include <asm/asm-offsets.h>
0021 #include <asm/regdef.h>
0022 
0023 #define EX(a,b)                         \
0024 9:  a,##b;                          \
0025     .section __ex_table,"a";                \
0026     PTR_WD  9b,fault;                   \
0027     .previous
0028 
0029 #define EX2(a,b)                        \
0030 9:  a,##b;                          \
0031     .section __ex_table,"a";                \
0032     PTR_WD  9b,fault;                   \
0033     PTR_WD  9b+4,fault;                 \
0034     .previous
0035 
0036     .set    mips1
0037 
0038 /*
0039  * Save a thread's fp context.
0040  */
0041 LEAF(_save_fp)
0042 EXPORT_SYMBOL(_save_fp)
0043     fpu_save_single a0, t1          # clobbers t1
0044     jr  ra
0045     END(_save_fp)
0046 
0047 /*
0048  * Restore a thread's fp context.
0049  */
0050 LEAF(_restore_fp)
0051     fpu_restore_single a0, t1       # clobbers t1
0052     jr  ra
0053     END(_restore_fp)
0054 
0055     .set    noreorder
0056 
0057 /**
0058  * _save_fp_context() - save FP context from the FPU
0059  * @a0 - pointer to fpregs field of sigcontext
0060  * @a1 - pointer to fpc_csr field of sigcontext
0061  *
0062  * Save FP context, including the 32 FP data registers and the FP
0063  * control & status register, from the FPU to signal context.
0064  */
0065 LEAF(_save_fp_context)
0066     .set    push
0067     SET_HARDFLOAT
0068     li  v0, 0                   # assume success
0069     cfc1    t1, fcr31
0070     EX2(s.d $f0, 0(a0))
0071     EX2(s.d $f2, 16(a0))
0072     EX2(s.d $f4, 32(a0))
0073     EX2(s.d $f6, 48(a0))
0074     EX2(s.d $f8, 64(a0))
0075     EX2(s.d $f10, 80(a0))
0076     EX2(s.d $f12, 96(a0))
0077     EX2(s.d $f14, 112(a0))
0078     EX2(s.d $f16, 128(a0))
0079     EX2(s.d $f18, 144(a0))
0080     EX2(s.d $f20, 160(a0))
0081     EX2(s.d $f22, 176(a0))
0082     EX2(s.d $f24, 192(a0))
0083     EX2(s.d $f26, 208(a0))
0084     EX2(s.d $f28, 224(a0))
0085     EX2(s.d $f30, 240(a0))
0086     jr  ra
0087      EX(sw  t1, (a1))
0088     .set    pop
0089     END(_save_fp_context)
0090 
0091 /**
0092  * _restore_fp_context() - restore FP context to the FPU
0093  * @a0 - pointer to fpregs field of sigcontext
0094  * @a1 - pointer to fpc_csr field of sigcontext
0095  *
0096  * Restore FP context, including the 32 FP data registers and the FP
0097  * control & status register, from signal context to the FPU.
0098  */
0099 LEAF(_restore_fp_context)
0100     .set    push
0101     SET_HARDFLOAT
0102     li  v0, 0                   # assume success
0103     EX(lw t0, (a1))
0104     EX2(l.d $f0, 0(a0))
0105     EX2(l.d $f2, 16(a0))
0106     EX2(l.d $f4, 32(a0))
0107     EX2(l.d $f6, 48(a0))
0108     EX2(l.d $f8, 64(a0))
0109     EX2(l.d $f10, 80(a0))
0110     EX2(l.d $f12, 96(a0))
0111     EX2(l.d $f14, 112(a0))
0112     EX2(l.d $f16, 128(a0))
0113     EX2(l.d $f18, 144(a0))
0114     EX2(l.d $f20, 160(a0))
0115     EX2(l.d $f22, 176(a0))
0116     EX2(l.d $f24, 192(a0))
0117     EX2(l.d $f26, 208(a0))
0118     EX2(l.d $f28, 224(a0))
0119     EX2(l.d $f30, 240(a0))
0120     jr  ra
0121      ctc1   t0, fcr31
0122     .set    pop
0123     END(_restore_fp_context)
0124     .set    reorder
0125 
0126     .type   fault, @function
0127     .ent    fault
0128 fault:  li  v0, -EFAULT
0129     jr  ra
0130     .end    fault