diff options
author | Leonid Yegoshin <Leonid.Yegoshin@imgtec.com> | 2013-11-07 07:48:28 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-01-13 17:40:55 -0500 |
commit | 1ac944007bede6d6f934831959b0e2b65c82d291 (patch) | |
tree | da2b1745bd4c8cd447574e7bd9b44d220b0f2f4b | |
parent | 7e22e91102c6b9df7c4ae2168910e19d2bb14cd6 (diff) |
MIPS: math-emu: Add mfhc1 & mthc1 support.
This patch adds support for the mfhc1 & mthc1 instructions to the FPU
emulator. These instructions were introduced in release 2 of the MIPS32
& MIPS64 architectures and allow access to the most significant 32 bits
of a 64-bit FP register.
[ralf@linux-mips.org: Fix ifdef hell added by original patch.]
Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/6112/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/include/uapi/asm/inst.h | 5 | ||||
-rw-r--r-- | arch/mips/math-emu/cp1emu.c | 24 |
2 files changed, 27 insertions, 2 deletions
diff --git a/arch/mips/include/uapi/asm/inst.h b/arch/mips/include/uapi/asm/inst.h index e5a676e3d3c0..0ee96563e6f0 100644 --- a/arch/mips/include/uapi/asm/inst.h +++ b/arch/mips/include/uapi/asm/inst.h | |||
@@ -98,8 +98,9 @@ enum rt_op { | |||
98 | */ | 98 | */ |
99 | enum cop_op { | 99 | enum cop_op { |
100 | mfc_op = 0x00, dmfc_op = 0x01, | 100 | mfc_op = 0x00, dmfc_op = 0x01, |
101 | cfc_op = 0x02, mtc_op = 0x04, | 101 | cfc_op = 0x02, mfhc_op = 0x03, |
102 | dmtc_op = 0x05, ctc_op = 0x06, | 102 | mtc_op = 0x04, dmtc_op = 0x05, |
103 | ctc_op = 0x06, mthc_op = 0x07, | ||
103 | bc_op = 0x08, cop_op = 0x10, | 104 | bc_op = 0x08, cop_op = 0x10, |
104 | copm_op = 0x18 | 105 | copm_op = 0x18 |
105 | }; | 106 | }; |
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c index efe008846ed0..aaf7c92f4629 100644 --- a/arch/mips/math-emu/cp1emu.c +++ b/arch/mips/math-emu/cp1emu.c | |||
@@ -878,6 +878,10 @@ static inline int cop1_64bit(struct pt_regs *xcp) | |||
878 | ctx->fpr[x & ~1] >> 32 << 32 | (u32)(si) : \ | 878 | ctx->fpr[x & ~1] >> 32 << 32 | (u32)(si) : \ |
879 | ctx->fpr[x & ~1] << 32 >> 32 | (u64)(si) << 32) | 879 | ctx->fpr[x & ~1] << 32 >> 32 | (u64)(si) << 32) |
880 | 880 | ||
881 | #define SIFROMHREG(si, x) ((si) = (int)(ctx->fpr[x] >> 32)) | ||
882 | #define SITOHREG(si, x) (ctx->fpr[x] = \ | ||
883 | ctx->fpr[x] << 32 >> 32 | (u64)(si) << 32) | ||
884 | |||
881 | #define DIFROMREG(di, x) ((di) = ctx->fpr[x & ~(cop1_64bit(xcp) == 0)]) | 885 | #define DIFROMREG(di, x) ((di) = ctx->fpr[x & ~(cop1_64bit(xcp) == 0)]) |
882 | #define DITOREG(di, x) (ctx->fpr[x & ~(cop1_64bit(xcp) == 0)] = (di)) | 886 | #define DITOREG(di, x) (ctx->fpr[x & ~(cop1_64bit(xcp) == 0)] = (di)) |
883 | 887 | ||
@@ -1055,6 +1059,25 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx, | |||
1055 | break; | 1059 | break; |
1056 | #endif | 1060 | #endif |
1057 | 1061 | ||
1062 | case mfhc_op: | ||
1063 | if (!cpu_has_mips_r2) | ||
1064 | goto sigill; | ||
1065 | |||
1066 | /* copregister rd -> gpr[rt] */ | ||
1067 | if (MIPSInst_RT(ir) != 0) { | ||
1068 | SIFROMHREG(xcp->regs[MIPSInst_RT(ir)], | ||
1069 | MIPSInst_RD(ir)); | ||
1070 | } | ||
1071 | break; | ||
1072 | |||
1073 | case mthc_op: | ||
1074 | if (!cpu_has_mips_r2) | ||
1075 | goto sigill; | ||
1076 | |||
1077 | /* copregister rd <- gpr[rt] */ | ||
1078 | SITOHREG(xcp->regs[MIPSInst_RT(ir)], MIPSInst_RD(ir)); | ||
1079 | break; | ||
1080 | |||
1058 | case mfc_op: | 1081 | case mfc_op: |
1059 | /* copregister rd -> gpr[rt] */ | 1082 | /* copregister rd -> gpr[rt] */ |
1060 | if (MIPSInst_RT(ir) != 0) { | 1083 | if (MIPSInst_RT(ir) != 0) { |
@@ -1263,6 +1286,7 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx, | |||
1263 | #endif | 1286 | #endif |
1264 | 1287 | ||
1265 | default: | 1288 | default: |
1289 | sigill: | ||
1266 | return SIGILL; | 1290 | return SIGILL; |
1267 | } | 1291 | } |
1268 | 1292 | ||