patch-2.4.22 linux-2.4.22/arch/arm/nwfpe/fpmodule.c
Next file: linux-2.4.22/arch/arm/nwfpe/fpmodule.inl
Previous file: linux-2.4.22/arch/arm/nwfpe/fpa11_cprt.c
Back to the patch index
Back to the overall index
- Lines: 180
- Date:
2003-08-25 04:44:39.000000000 -0700
- Orig file:
linux-2.4.21/arch/arm/nwfpe/fpmodule.c
- Orig date:
2002-08-02 17:39:42.000000000 -0700
diff -urN linux-2.4.21/arch/arm/nwfpe/fpmodule.c linux-2.4.22/arch/arm/nwfpe/fpmodule.c
@@ -41,13 +41,19 @@
#include "fpa11.inl"
/* kernel symbols required for signal handling */
-typedef struct task_struct* PTASK;
+typedef struct task_struct *PTASK;
+
+#ifdef CONFIG_FPE_NWFPE_XP
+#define NWFPE_BITS "extended"
+#else
+#define NWFPE_BITS "double"
+#endif
#ifdef MODULE
void fp_send_sig(unsigned long sig, PTASK p, int priv);
#if LINUX_VERSION_CODE > 0x20115
MODULE_AUTHOR("Scott Bambrough <scottb@rebel.com>");
-MODULE_DESCRIPTION("NWFPE floating point emulator");
+MODULE_DESCRIPTION("NWFPE floating point emulator (" NWFPE_BITS " precision)");
#endif
#else
@@ -63,7 +69,7 @@
/* external declarations for saved kernel symbols */
extern void (*kern_fp_enter)(void);
-/* Original value of fp_enter from kernel before patched by fpe_init. */
+/* Original value of fp_enter from kernel before patched by fpe_init. */
static void (*orig_fp_enter)(void);
/* forward declarations */
@@ -76,46 +82,45 @@
*/
static int fpe_unload(void)
{
- return (kern_fp_enter == nwfpe_enter) ? 0 : 1;
+ return (kern_fp_enter == nwfpe_enter) ? 0 : 1;
}
#endif
static int __init fpe_init(void)
{
- if (sizeof(FPA11) > sizeof(union fp_state)) {
- printk(KERN_ERR "nwfpe: bad structure size\n");
- return -EINVAL;
- }
-
- if (sizeof(FPREG) != 12) {
- printk(KERN_ERR "nwfpe: bad register size\n");
- return -EINVAL;
- }
-
+ if (sizeof(FPA11) > sizeof(union fp_state)) {
+ printk(KERN_ERR "nwfpe: bad structure size\n");
+ return -EINVAL;
+ }
+
+ if (sizeof(FPREG) != 12) {
+ printk(KERN_ERR "nwfpe: bad register size\n");
+ return -EINVAL;
+ }
#ifdef MODULE
- if (!mod_member_present(&__this_module, can_unload))
- return -EINVAL;
- __this_module.can_unload = fpe_unload;
+ if (!mod_member_present(&__this_module, can_unload))
+ return -EINVAL;
+ __this_module.can_unload = fpe_unload;
#else
- if (fpe_type[0] && strcmp(fpe_type, "nwfpe"))
- return 0;
+ if (fpe_type[0] && strcmp(fpe_type, "nwfpe"))
+ return 0;
#endif
- /* Display title, version and copyright information. */
- printk(KERN_WARNING "NetWinder Floating Point Emulator V0.95 "
- "(c) 1998-1999 Rebel.com\n");
-
- /* Save pointer to the old FP handler and then patch ourselves in */
- orig_fp_enter = kern_fp_enter;
- kern_fp_enter = nwfpe_enter;
+ /* Display title, version and copyright information. */
+ printk(KERN_WARNING "NetWinder Floating Point Emulator V0.97 ("
+ NWFPE_BITS " precision)\n");
+
+ /* Save pointer to the old FP handler and then patch ourselves in */
+ orig_fp_enter = kern_fp_enter;
+ kern_fp_enter = nwfpe_enter;
- return 0;
+ return 0;
}
static void __exit fpe_exit(void)
{
- /* Restore the values we saved earlier. */
- kern_fp_enter = orig_fp_enter;
+ /* Restore the values we saved earlier. */
+ kern_fp_enter = orig_fp_enter;
}
/*
@@ -140,41 +145,42 @@
void float_raise(signed char flags)
{
- register unsigned int fpsr, cumulativeTraps;
-
+ register unsigned int fpsr, cumulativeTraps;
+
#ifdef CONFIG_DEBUG_USER
- printk(KERN_DEBUG "NWFPE: %s[%d] takes exception %08x at %p from %08x\n",
- current->comm, current->pid, flags,
- __builtin_return_address(0), GET_USERREG()[15]);
-#endif
-
- /* Keep SoftFloat exception flags up to date. */
- float_exception_flags |= flags;
-
- /* Read fpsr and initialize the cumulativeTraps. */
- fpsr = readFPSR();
- cumulativeTraps = 0;
-
- /* For each type of exception, the cumulative trap exception bit is only
- set if the corresponding trap enable bit is not set. */
- if ((!(fpsr & BIT_IXE)) && (flags & BIT_IXC))
- cumulativeTraps |= BIT_IXC;
- if ((!(fpsr & BIT_UFE)) && (flags & BIT_UFC))
- cumulativeTraps |= BIT_UFC;
- if ((!(fpsr & BIT_OFE)) && (flags & BIT_OFC))
- cumulativeTraps |= BIT_OFC;
- if ((!(fpsr & BIT_DZE)) && (flags & BIT_DZC))
- cumulativeTraps |= BIT_DZC;
- if ((!(fpsr & BIT_IOE)) && (flags & BIT_IOC))
- cumulativeTraps |= BIT_IOC;
-
- /* Set the cumulative exceptions flags. */
- if (cumulativeTraps)
- writeFPSR(fpsr | cumulativeTraps);
-
- /* Raise an exception if necessary. */
- if (fpsr & (flags << 16))
- fp_send_sig(SIGFPE, current, 1);
+ printk(KERN_DEBUG
+ "NWFPE: %s[%d] takes exception %08x at %p from %08x\n",
+ current->comm, current->pid, flags,
+ __builtin_return_address(0), GET_USERREG()[15]);
+#endif
+
+ /* Keep SoftFloat exception flags up to date. */
+ float_exception_flags |= flags;
+
+ /* Read fpsr and initialize the cumulativeTraps. */
+ fpsr = readFPSR();
+ cumulativeTraps = 0;
+
+ /* For each type of exception, the cumulative trap exception bit is only
+ set if the corresponding trap enable bit is not set. */
+ if ((!(fpsr & BIT_IXE)) && (flags & BIT_IXC))
+ cumulativeTraps |= BIT_IXC;
+ if ((!(fpsr & BIT_UFE)) && (flags & BIT_UFC))
+ cumulativeTraps |= BIT_UFC;
+ if ((!(fpsr & BIT_OFE)) && (flags & BIT_OFC))
+ cumulativeTraps |= BIT_OFC;
+ if ((!(fpsr & BIT_DZE)) && (flags & BIT_DZC))
+ cumulativeTraps |= BIT_DZC;
+ if ((!(fpsr & BIT_IOE)) && (flags & BIT_IOC))
+ cumulativeTraps |= BIT_IOC;
+
+ /* Set the cumulative exceptions flags. */
+ if (cumulativeTraps)
+ writeFPSR(fpsr | cumulativeTraps);
+
+ /* Raise an exception if necessary. */
+ if (fpsr & (flags << 16))
+ fp_send_sig(SIGFPE, current, 1);
}
module_init(fpe_init);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)