hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/arch/nds32/kernel/sys_nds32.c
....@@ -6,6 +6,8 @@
66
77 #include <asm/cachectl.h>
88 #include <asm/proc-fns.h>
9
+#include <asm/fpu.h>
10
+#include <asm/fp_udfiex_crtl.h>
911
1012 SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
1113 unsigned long, prot, unsigned long, flags,
....@@ -48,3 +50,35 @@
4850
4951 return 0;
5052 }
53
+
54
+SYSCALL_DEFINE2(fp_udfiex_crtl, unsigned int, cmd, unsigned int, act)
55
+{
56
+#if IS_ENABLED(CONFIG_SUPPORT_DENORMAL_ARITHMETIC)
57
+ int old_udf_iex;
58
+
59
+ if (!used_math()) {
60
+ load_fpu(&init_fpuregs);
61
+ current->thread.fpu.UDF_IEX_trap = init_fpuregs.UDF_IEX_trap;
62
+ set_used_math();
63
+ }
64
+
65
+ old_udf_iex = current->thread.fpu.UDF_IEX_trap;
66
+ act &= (FPCSR_mskUDFE | FPCSR_mskIEXE);
67
+
68
+ switch (cmd) {
69
+ case DISABLE_UDF_IEX_TRAP:
70
+ current->thread.fpu.UDF_IEX_trap &= ~act;
71
+ break;
72
+ case ENABLE_UDF_IEX_TRAP:
73
+ current->thread.fpu.UDF_IEX_trap |= act;
74
+ break;
75
+ case GET_UDF_IEX_TRAP:
76
+ break;
77
+ default:
78
+ return -EINVAL;
79
+ }
80
+ return old_udf_iex;
81
+#else
82
+ return -ENOTSUPP;
83
+#endif
84
+}