summaryrefslogtreecommitdiffstats
path: root/src/kernel/math/math_emulate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/math/math_emulate.c')
-rw-r--r--src/kernel/math/math_emulate.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/kernel/math/math_emulate.c b/src/kernel/math/math_emulate.c
new file mode 100644
index 0000000..825e528
--- /dev/null
+++ b/src/kernel/math/math_emulate.c
@@ -0,0 +1,42 @@
1/*
2 * linux/kernel/math/math_emulate.c
3 *
4 * (C) 1991 Linus Torvalds
5 */
6
7/*
8 * This directory should contain the math-emulation code.
9 * Currently only results in a signal.
10 */
11
12#include <signal.h>
13
14#include <linux/sched.h>
15#include <linux/kernel.h>
16#include <asm/segment.h>
17
18void math_emulate(long edi, long esi, long ebp, long sys_call_ret,
19 long eax,long ebx,long ecx,long edx,
20 unsigned short fs,unsigned short es,unsigned short ds,
21 unsigned long eip,unsigned short cs,unsigned long eflags,
22 unsigned short ss, unsigned long esp)
23{
24 unsigned char first, second;
25
26/* 0x0007 means user code space */
27 if (cs != 0x000F) {
28 printk("math_emulate: %04x:%08x\n\r",cs,eip);
29 panic("Math emulation needed in kernel");
30 }
31 first = get_fs_byte((char *)((*&eip)++));
32 second = get_fs_byte((char *)((*&eip)++));
33 printk("%04x:%08x %02x %02x\n\r",cs,eip-2,first,second);
34 current->signal |= 1<<(SIGFPE-1);
35}
36
37void math_error(void)
38{
39 __asm__("fnclex");
40 if (last_task_used_math)
41 last_task_used_math->signal |= 1<<(SIGFPE-1);
42}