blob: f761719eab653df112e0a58954ece04e459c511b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * This program is free software; you can distribute it and/or modify it
3 * under the terms of the GNU General Public License (Version 2) as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope it will be useful, but WITHOUT
7 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9 * for more details.
10 *
11 * You should have received a copy of the GNU General Public License along
12 * with this program; if not, write to the Free Software Foundation, Inc.,
13 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
14 *
Atsushi Nemotoeae89072006-05-16 01:26:03 +090015 * Further private data for which no space exists in mips_fpu_struct.
16 * This should be subsumed into the mips_fpu_struct structure as
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 * defined in processor.h as soon as the absurd wired absolute assembler
18 * offsets become dynamic at compile time.
19 *
20 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
21 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
22 */
23#ifndef _ASM_FPU_EMULATOR_H
24#define _ASM_FPU_EMULATOR_H
25
Ralf Baechlee0cc3a42014-04-28 22:34:01 +020026#include <linux/sched.h>
Ralf Baechleba3049e2008-10-28 17:38:42 +000027#include <asm/break.h>
Ralf Baechlee0cc3a42014-04-28 22:34:01 +020028#include <asm/thread_info.h>
Ralf Baechleba3049e2008-10-28 17:38:42 +000029#include <asm/inst.h>
David Daneyb6ee75e2009-11-05 11:34:26 -080030#include <asm/local.h>
Ralf Baechlee0cc3a42014-04-28 22:34:01 +020031#include <asm/processor.h>
David Daneyb6ee75e2009-11-05 11:34:26 -080032
33#ifdef CONFIG_DEBUG_FS
Ralf Baechleba3049e2008-10-28 17:38:42 +000034
Ralf Baechle4a99d1e2005-05-11 12:02:48 +000035struct mips_fpu_emulator_stats {
David Daneyb6ee75e2009-11-05 11:34:26 -080036 local_t emulated;
37 local_t loads;
38 local_t stores;
39 local_t cp1ops;
40 local_t cp1xops;
41 local_t errors;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042};
43
David Daneyb6ee75e2009-11-05 11:34:26 -080044DECLARE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
45
46#define MIPS_FPU_EMU_INC_STATS(M) \
Ralf Baechlec948aca2010-03-08 19:38:13 +010047do { \
48 preempt_disable(); \
49 __local_inc(&__get_cpu_var(fpuemustats).M); \
50 preempt_enable(); \
51} while (0)
David Daneyb6ee75e2009-11-05 11:34:26 -080052
53#else
54#define MIPS_FPU_EMU_INC_STATS(M) do { } while (0)
55#endif /* CONFIG_DEBUG_FS */
Ralf Baechle0bd5d2e2005-02-28 17:29:15 +000056
Ralf Baechleba3049e2008-10-28 17:38:42 +000057extern int mips_dsemul(struct pt_regs *regs, mips_instruction ir,
58 unsigned long cpc);
59extern int do_dsemulret(struct pt_regs *xcp);
Leonid Yegoshin102cedc2013-03-25 12:09:02 -050060extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,
61 struct mips_fpu_struct *ctx, int has_fpu,
62 void *__user *fault_addr);
63int process_fpemu_return(int sig, void __user *fault_addr);
64int mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
65 unsigned long *contpc);
Ralf Baechleba3049e2008-10-28 17:38:42 +000066
67/*
68 * Instruction inserted following the badinst to further tag the sequence
69 */
70#define BD_COOKIE 0x0000bd36 /* tne $0, $0 with baggage */
71
72/*
73 * Break instruction with special math emu break code set
74 */
75#define BREAK_MATH (0x0000000d | (BRK_MEMU << 16))
76
Ralf Baechlee0cc3a42014-04-28 22:34:01 +020077#define SIGNALLING_NAN 0x7ff800007ff80000LL
78
79static inline void fpu_emulator_init_fpu(void)
80{
81 struct task_struct *t = current;
82 int i;
83
84 t->thread.fpu.fcr31 = 0;
85
86 for (i = 0; i < 32; i++)
87 set_fpr64(&t->thread.fpu.fpr[i], 0, SIGNALLING_NAN);
88}
89
Linus Torvalds1da177e2005-04-16 15:20:36 -070090#endif /* _ASM_FPU_EMULATOR_H */