aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm26/nwfpe/fpmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm26/nwfpe/fpmodule.c')
-rw-r--r--arch/arm26/nwfpe/fpmodule.c180
1 files changed, 0 insertions, 180 deletions
diff --git a/arch/arm26/nwfpe/fpmodule.c b/arch/arm26/nwfpe/fpmodule.c
deleted file mode 100644
index a8fad92eb44f..000000000000
--- a/arch/arm26/nwfpe/fpmodule.c
+++ /dev/null
@@ -1,180 +0,0 @@
1
2/*
3 NetWinder Floating Point Emulator
4 (c) Rebel.com, 1998-1999
5 (c) Philip Blundell, 1998-1999
6
7 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/
23
24#include "fpa11.h"
25
26#include <linux/module.h>
27#include <linux/version.h>
28
29/* XXX */
30#include <linux/errno.h>
31#include <linux/types.h>
32#include <linux/kernel.h>
33#include <linux/signal.h>
34#include <linux/sched.h>
35#include <linux/init.h>
36/* XXX */
37
38#include "softfloat.h"
39#include "fpopcode.h"
40#include "fpmodule.h"
41#include "fpa11.inl"
42
43/* kernel symbols required for signal handling */
44typedef struct task_struct* PTASK;
45
46#ifdef MODULE
47void fp_send_sig(unsigned long sig, PTASK p, int priv);
48
49MODULE_AUTHOR("Scott Bambrough <scottb@rebel.com>");
50MODULE_DESCRIPTION("NWFPE floating point emulator");
51
52#else
53#define fp_send_sig send_sig
54#define kern_fp_enter fp_enter
55
56extern char fpe_type[];
57#endif
58
59/* kernel function prototypes required */
60void fp_setup(void);
61
62/* external declarations for saved kernel symbols */
63extern void (*kern_fp_enter)(void);
64
65/* Original value of fp_enter from kernel before patched by fpe_init. */
66static void (*orig_fp_enter)(void);
67
68/* forward declarations */
69extern void nwfpe_enter(void);
70
71#ifdef MODULE
72/*
73 * Return 0 if we can be unloaded. This can only happen if
74 * kern_fp_enter is still pointing at nwfpe_enter
75 */
76static int fpe_unload(void)
77{
78 return (kern_fp_enter == nwfpe_enter) ? 0 : 1;
79}
80#endif
81
82static int __init fpe_init(void)
83{
84 if (sizeof(FPA11) > sizeof(union fp_state)) {
85 printk(KERN_ERR "nwfpe: bad structure size\n");
86 return -EINVAL;
87 }
88
89 if (sizeof(FPREG) != 12) {
90 printk(KERN_ERR "nwfpe: bad register size\n");
91 return -EINVAL;
92 }
93
94#ifdef MODULE
95 if (!mod_member_present(&__this_module, can_unload))
96 return -EINVAL;
97 __this_module.can_unload = fpe_unload;
98#else
99 if (fpe_type[0] && strcmp(fpe_type, "nwfpe"))
100 return 0;
101#endif
102
103 /* Display title, version and copyright information. */
104 printk(KERN_WARNING "NetWinder Floating Point Emulator V0.95 "
105 "(c) 1998-1999 Rebel.com\n");
106
107 /* Save pointer to the old FP handler and then patch ourselves in */
108 orig_fp_enter = kern_fp_enter;
109 kern_fp_enter = nwfpe_enter;
110
111 return 0;
112}
113
114static void __exit fpe_exit(void)
115{
116 /* Restore the values we saved earlier. */
117 kern_fp_enter = orig_fp_enter;
118}
119
120/*
121ScottB: November 4, 1998
122
123Moved this function out of softfloat-specialize into fpmodule.c.
124This effectively isolates all the changes required for integrating with the
125Linux kernel into fpmodule.c. Porting to NetBSD should only require modifying
126fpmodule.c to integrate with the NetBSD kernel (I hope!).
127
128[1/1/99: Not quite true any more unfortunately. There is Linux-specific
129code to access data in user space in some other source files at the
130moment (grep for get_user / put_user calls). --philb]
131
132float_exception_flags is a global variable in SoftFloat.
133
134This function is called by the SoftFloat routines to raise a floating
135point exception. We check the trap enable byte in the FPSR, and raise
136a SIGFPE exception if necessary. If not the relevant bits in the
137cumulative exceptions flag byte are set and we return.
138*/
139
140void float_raise(signed char flags)
141{
142 register unsigned int fpsr, cumulativeTraps;
143
144#ifdef CONFIG_DEBUG_USER
145 printk(KERN_DEBUG "NWFPE: %s[%d] takes exception %08x at %p from %08x\n",
146 current->comm, current->pid, flags,
147 __builtin_return_address(0), GET_USERREG()[15]);
148#endif
149
150 /* Keep SoftFloat exception flags up to date. */
151 float_exception_flags |= flags;
152
153 /* Read fpsr and initialize the cumulativeTraps. */
154 fpsr = readFPSR();
155 cumulativeTraps = 0;
156
157 /* For each type of exception, the cumulative trap exception bit is only
158 set if the corresponding trap enable bit is not set. */
159 if ((!(fpsr & BIT_IXE)) && (flags & BIT_IXC))
160 cumulativeTraps |= BIT_IXC;
161 if ((!(fpsr & BIT_UFE)) && (flags & BIT_UFC))
162 cumulativeTraps |= BIT_UFC;
163 if ((!(fpsr & BIT_OFE)) && (flags & BIT_OFC))
164 cumulativeTraps |= BIT_OFC;
165 if ((!(fpsr & BIT_DZE)) && (flags & BIT_DZC))
166 cumulativeTraps |= BIT_DZC;
167 if ((!(fpsr & BIT_IOE)) && (flags & BIT_IOC))
168 cumulativeTraps |= BIT_IOC;
169
170 /* Set the cumulative exceptions flags. */
171 if (cumulativeTraps)
172 writeFPSR(fpsr | cumulativeTraps);
173
174 /* Raise an exception if necessary. */
175 if (fpsr & (flags << 16))
176 fp_send_sig(SIGFPE, current, 1);
177}
178
179module_init(fpe_init);
180module_exit(fpe_exit);