cp1emu.c (cd8ee345e8affceaa3f846012db7eb799a6d918f) cp1emu.c (85c51c511d6373d4bc859458fd3f130015db31a5)
1/*
2 * cp1emu.c: a MIPS coprocessor 1 (fpu) instruction emulator
3 *
4 * MIPS floating point support
5 * Copyright (C) 1994-2000 Algorithmics Ltd.
6 *
7 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
8 * Copyright (C) 2000 MIPS Technologies, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * quite nasty because emulation of some non-COP1 instructions is
31 * required, e.g. in branch delay slots.
32 *
33 * Note if you know that you won't have an fpu, then you'll get much
34 * better performance by compiling with -msoft-float!
35 */
36#include <linux/sched.h>
37#include <linux/debugfs.h>
1/*
2 * cp1emu.c: a MIPS coprocessor 1 (fpu) instruction emulator
3 *
4 * MIPS floating point support
5 * Copyright (C) 1994-2000 Algorithmics Ltd.
6 *
7 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
8 * Copyright (C) 2000 MIPS Technologies, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * quite nasty because emulation of some non-COP1 instructions is
31 * required, e.g. in branch delay slots.
32 *
33 * Note if you know that you won't have an fpu, then you'll get much
34 * better performance by compiling with -msoft-float!
35 */
36#include <linux/sched.h>
37#include <linux/debugfs.h>
38#include <linux/percpu-defs.h>
38#include <linux/perf_event.h>
39
40#include <asm/branch.h>
41#include <asm/inst.h>
42#include <asm/ptrace.h>
43#include <asm/signal.h>
44#include <asm/uaccess.h>
45

--- 15 unchanged lines hidden (view full) ---

61static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
62 mips_instruction);
63
64#if __mips >= 4 && __mips != 32
65static int fpux_emu(struct pt_regs *,
66 struct mips_fpu_struct *, mips_instruction, void *__user *);
67#endif
68
39#include <linux/perf_event.h>
40
41#include <asm/branch.h>
42#include <asm/inst.h>
43#include <asm/ptrace.h>
44#include <asm/signal.h>
45#include <asm/uaccess.h>
46

--- 15 unchanged lines hidden (view full) ---

62static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
63 mips_instruction);
64
65#if __mips >= 4 && __mips != 32
66static int fpux_emu(struct pt_regs *,
67 struct mips_fpu_struct *, mips_instruction, void *__user *);
68#endif
69
69/* Further private data for which no space exists in mips_fpu_struct */
70
71#ifdef CONFIG_DEBUG_FS
72DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
73#endif
74
75/* Control registers */
76
77#define FPCREG_RID 0 /* $0 = revision id */
78#define FPCREG_CSR 31 /* $31 = csr */
79
80/* Determine rounding mode from the RM bits of the FCSR */
81#define modeindex(v) ((v) & FPU_CSR_RM)
82

--- 2070 unchanged lines hidden (view full) ---

2153
2154 /* SIGILL indicates a non-fpu instruction */
2155 if (sig == SIGILL && xcp->cp0_epc != oldepc)
2156 /* but if epc has advanced, then ignore it */
2157 sig = 0;
2158
2159 return sig;
2160}
70/* Control registers */
71
72#define FPCREG_RID 0 /* $0 = revision id */
73#define FPCREG_CSR 31 /* $31 = csr */
74
75/* Determine rounding mode from the RM bits of the FCSR */
76#define modeindex(v) ((v) & FPU_CSR_RM)
77

--- 2070 unchanged lines hidden (view full) ---

2148
2149 /* SIGILL indicates a non-fpu instruction */
2150 if (sig == SIGILL && xcp->cp0_epc != oldepc)
2151 /* but if epc has advanced, then ignore it */
2152 sig = 0;
2153
2154 return sig;
2155}
2161
2162#ifdef CONFIG_DEBUG_FS
2163
2164static int fpuemu_stat_get(void *data, u64 *val)
2165{
2166 int cpu;
2167 unsigned long sum = 0;
2168 for_each_online_cpu(cpu) {
2169 struct mips_fpu_emulator_stats *ps;
2170 local_t *pv;
2171 ps = &per_cpu(fpuemustats, cpu);
2172 pv = (void *)ps + (unsigned long)data;
2173 sum += local_read(pv);
2174 }
2175 *val = sum;
2176 return 0;
2177}
2178DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");
2179
2180extern struct dentry *mips_debugfs_dir;
2181static int __init debugfs_fpuemu(void)
2182{
2183 struct dentry *d, *dir;
2184
2185 if (!mips_debugfs_dir)
2186 return -ENODEV;
2187 dir = debugfs_create_dir("fpuemustats", mips_debugfs_dir);
2188 if (!dir)
2189 return -ENOMEM;
2190
2191#define FPU_STAT_CREATE(M) \
2192 do { \
2193 d = debugfs_create_file(#M , S_IRUGO, dir, \
2194 (void *)offsetof(struct mips_fpu_emulator_stats, M), \
2195 &fops_fpuemu_stat); \
2196 if (!d) \
2197 return -ENOMEM; \
2198 } while (0)
2199
2200 FPU_STAT_CREATE(emulated);
2201 FPU_STAT_CREATE(loads);
2202 FPU_STAT_CREATE(stores);
2203 FPU_STAT_CREATE(cp1ops);
2204 FPU_STAT_CREATE(cp1xops);
2205 FPU_STAT_CREATE(errors);
2206
2207 return 0;
2208}
2209__initcall(debugfs_fpuemu);
2210#endif