blob: 9c8eb2017d5b4be09e5465c3fb25e7d77fe671d3 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Adrian Bunkb00dc832008-05-19 16:52:27 -07002/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * VISsave.S: Code for saving FPU register state for
4 * VIS routines. One should not call this directly,
5 * but use macros provided in <asm/visasm.h>.
6 *
7 * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
8 */
9
Sam Ravnborg73958c62015-08-07 20:34:12 +020010#include <linux/linkage.h>
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <asm/asi.h>
13#include <asm/page.h>
14#include <asm/ptrace.h>
15#include <asm/visasm.h>
16#include <asm/thread_info.h>
Al Virod3867f042016-01-16 21:39:30 -050017#include <asm/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 /* On entry: %o5=current FPRS value, %g7 is callers address */
20 /* May clobber %o5, %g1, %g2, %g3, %g7, %icc, %xcc */
21
22 /* Nothing special need be done here to handle pre-emption, this
23 * FPU save/restore mechanism is already preemption safe.
24 */
Sam Ravnborg73958c62015-08-07 20:34:12 +020025 .text
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 .align 32
Sam Ravnborg73958c62015-08-07 20:34:12 +020027ENTRY(VISenter)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 ldub [%g6 + TI_FPDEPTH], %g1
29 brnz,a,pn %g1, 1f
30 cmp %g1, 1
31 stb %g0, [%g6 + TI_FPSAVED]
32 stx %fsr, [%g6 + TI_XFSR]
339: jmpl %g7 + %g0, %g0
34 nop
351: bne,pn %icc, 2f
36
37 srl %g1, 1, %g1
38vis1: ldub [%g6 + TI_FPSAVED], %g3
39 stx %fsr, [%g6 + TI_XFSR]
40 or %g3, %o5, %g3
41 stb %g3, [%g6 + TI_FPSAVED]
42 rd %gsr, %g3
43 clr %g1
44 ba,pt %xcc, 3f
45
46 stx %g3, [%g6 + TI_GSR]
472: add %g6, %g1, %g3
David S. Miller44922152015-08-06 19:13:25 -070048 mov FPRS_DU | FPRS_DL | FPRS_FEF, %o5
49 sll %g1, 3, %g1
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 stb %o5, [%g3 + TI_FPSAVED]
51 rd %gsr, %g2
52 add %g6, %g1, %g3
53 stx %g2, [%g3 + TI_GSR]
54
55 add %g6, %g1, %g2
56 stx %fsr, [%g2 + TI_XFSR]
57 sll %g1, 5, %g1
583: andcc %o5, FPRS_DL|FPRS_DU, %g0
59 be,pn %icc, 9b
60 add %g6, TI_FPREGS, %g2
61 andcc %o5, FPRS_DL, %g0
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63 be,pn %icc, 4f
64 add %g6, TI_FPREGS+0x40, %g3
David S. Millerba6399332005-10-07 13:30:49 -070065 membar #Sync
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 stda %f0, [%g2 + %g1] ASI_BLK_P
67 stda %f16, [%g3 + %g1] ASI_BLK_P
David S. Millerba6399332005-10-07 13:30:49 -070068 membar #Sync
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 andcc %o5, FPRS_DU, %g0
70 be,pn %icc, 5f
714: add %g1, 128, %g1
David S. Millerba6399332005-10-07 13:30:49 -070072 membar #Sync
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 stda %f32, [%g2 + %g1] ASI_BLK_P
74
75 stda %f48, [%g3 + %g1] ASI_BLK_P
765: membar #Sync
David S. Millerb445e262005-06-27 15:42:04 -070077 ba,pt %xcc, 80f
78 nop
79
80 .align 32
8180: jmpl %g7 + %g0, %g0
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 nop
Sam Ravnborg73958c62015-08-07 20:34:12 +020083ENDPROC(VISenter)
Al Virod3867f042016-01-16 21:39:30 -050084EXPORT_SYMBOL(VISenter)