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) 2014 Lemote Corporation.
7 * written by Huacai Chen <chenhc@lemote.com>
9 * based on arch/mips/cavium-octeon/cpu.c
10 * Copyright (C) 2009 Wind River Systems,
11 * written by Ralf Baechle <ralf@linux-mips.org>
13 #include <linux/init.h>
14 #include <linux/sched.h>
15 #include <linux/notifier.h>
16 #include <linux/ptrace.h>
20 #include <asm/current.h>
21 #include <asm/mipsregs.h>
23 static int loongson_cu2_call(struct notifier_block
*nfb
, unsigned long action
,
27 int fr
= !test_thread_flag(TIF_32BIT_FPREGS
);
32 fpu_owned
= __is_fpu_owner();
34 set_c0_status(ST0_CU1
| ST0_CU2
);
36 set_c0_status(ST0_CU1
| ST0_CU2
| ST0_FR
);
38 KSTK_STATUS(current
) |= (ST0_CU1
| ST0_CU2
);
40 KSTK_STATUS(current
) |= ST0_FR
;
42 KSTK_STATUS(current
) &= ~ST0_FR
;
43 /* If FPU is owned, we needn't init or restore fp */
45 set_thread_flag(TIF_USEDFPU
);
51 return NOTIFY_STOP
; /* Don't call default notifier */
54 return NOTIFY_OK
; /* Let default notifier send signals */
57 static int __init
loongson_cu2_setup(void)
59 return cu2_notifier(loongson_cu2_call
, 0);
61 early_initcall(loongson_cu2_setup
);