generate_exception(ctx, EXCP_RI);
}
+/* This code generates a "reserved instruction" exception if the
+ CPU is not a MIPS R2 (or higher) CPU. */
+static inline void check_mips_r2(CPUState *env, DisasContext *ctx)
+{
+ if ((env->CP0_Config0 & (0x7 << CP0C0_AR)) < (1 << CP0C0_AR))
+ generate_exception(ctx, EXCP_RI);
+}
+
#if defined(CONFIG_USER_ONLY)
#define op_ldst(name) gen_op_##name##_raw()
#define OP_LD_TABLE(width)
}
/* CP0 (MMU and control) */
-static void gen_mfc0 (DisasContext *ctx, int reg, int sel)
+static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
{
const char *rn = "invalid";
rn = "PageMask";
break;
case 1:
+ check_mips_r2(env, ctx);
gen_op_mfc0_pagegrain();
rn = "PageGrain";
break;
case 7:
switch (sel) {
case 0:
+ check_mips_r2(env, ctx);
gen_op_mfc0_hwrena();
rn = "HWREna";
break;
rn = "Status";
break;
case 1:
+ check_mips_r2(env, ctx);
gen_op_mfc0_intctl();
rn = "IntCtl";
break;
case 2:
+ check_mips_r2(env, ctx);
gen_op_mfc0_srsctl();
rn = "SRSCtl";
break;
case 3:
+ check_mips_r2(env, ctx);
gen_op_mfc0_srsmap();
rn = "SRSMap";
break;
rn = "PRid";
break;
case 1:
+ check_mips_r2(env, ctx);
gen_op_mfc0_ebase();
rn = "EBase";
break;
generate_exception(ctx, EXCP_RI);
}
-static void gen_mtc0 (DisasContext *ctx, int reg, int sel)
+static void gen_mtc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
{
const char *rn = "invalid";
rn = "PageMask";
break;
case 1:
+ check_mips_r2(env, ctx);
gen_op_mtc0_pagegrain();
rn = "PageGrain";
break;
case 7:
switch (sel) {
case 0:
+ check_mips_r2(env, ctx);
gen_op_mtc0_hwrena();
rn = "HWREna";
break;
rn = "Status";
break;
case 1:
+ check_mips_r2(env, ctx);
gen_op_mtc0_intctl();
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "IntCtl";
break;
case 2:
+ check_mips_r2(env, ctx);
gen_op_mtc0_srsctl();
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "SRSCtl";
break;
case 3:
+ check_mips_r2(env, ctx);
gen_op_mtc0_srsmap();
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "PRid";
break;
case 1:
+ check_mips_r2(env, ctx);
gen_op_mtc0_ebase();
rn = "EBase";
break;
}
#ifdef TARGET_MIPS64
-static void gen_dmfc0 (DisasContext *ctx, int reg, int sel)
+static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
{
const char *rn = "invalid";
rn = "PageMask";
break;
case 1:
+ check_mips_r2(env, ctx);
gen_op_mfc0_pagegrain();
rn = "PageGrain";
break;
case 7:
switch (sel) {
case 0:
+ check_mips_r2(env, ctx);
gen_op_mfc0_hwrena();
rn = "HWREna";
break;
rn = "Status";
break;
case 1:
+ check_mips_r2(env, ctx);
gen_op_mfc0_intctl();
rn = "IntCtl";
break;
case 2:
+ check_mips_r2(env, ctx);
gen_op_mfc0_srsctl();
rn = "SRSCtl";
break;
case 3:
+ check_mips_r2(env, ctx);
gen_op_mfc0_srsmap(); /* shadow registers */
rn = "SRSMap";
break;
rn = "PRid";
break;
case 1:
+ check_mips_r2(env, ctx);
gen_op_mfc0_ebase();
rn = "EBase";
break;
generate_exception(ctx, EXCP_RI);
}
-static void gen_dmtc0 (DisasContext *ctx, int reg, int sel)
+static void gen_dmtc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
{
const char *rn = "invalid";
rn = "PageMask";
break;
case 1:
+ check_mips_r2(env, ctx);
gen_op_mtc0_pagegrain();
rn = "PageGrain";
break;
case 7:
switch (sel) {
case 0:
+ check_mips_r2(env, ctx);
gen_op_mtc0_hwrena();
rn = "HWREna";
break;
rn = "Status";
break;
case 1:
+ check_mips_r2(env, ctx);
gen_op_mtc0_intctl();
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "IntCtl";
break;
case 2:
+ check_mips_r2(env, ctx);
gen_op_mtc0_srsctl();
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "SRSCtl";
break;
case 3:
+ check_mips_r2(env, ctx);
gen_op_mtc0_srsmap();
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "PRid";
break;
case 1:
+ check_mips_r2(env, ctx);
gen_op_mtc0_ebase();
rn = "EBase";
break;
/* Treat as NOP */
return;
}
- gen_mfc0(ctx, rd, ctx->opcode & 0x7);
+ gen_mfc0(env, ctx, rd, ctx->opcode & 0x7);
gen_op_store_T0_gpr(rt);
opn = "mfc0";
break;
case OPC_MTC0:
GEN_LOAD_REG_TN(T0, rt);
- gen_mtc0(ctx, rd, ctx->opcode & 0x7);
+ gen_mtc0(env, ctx, rd, ctx->opcode & 0x7);
opn = "mtc0";
break;
#ifdef TARGET_MIPS64
/* Treat as NOP */
return;
}
- gen_dmfc0(ctx, rd, ctx->opcode & 0x7);
+ gen_dmfc0(env, ctx, rd, ctx->opcode & 0x7);
gen_op_store_T0_gpr(rt);
opn = "dmfc0";
break;
case OPC_DMTC0:
GEN_LOAD_REG_TN(T0, rt);
- gen_dmtc0(ctx, rd, ctx->opcode & 0x7);
+ gen_dmtc0(env,ctx, rd, ctx->opcode & 0x7);
opn = "dmtc0";
break;
#endif
}
break;
case OPC_SPECIAL3:
+ check_mips_r2(env, ctx);
op1 = MASK_SPECIAL3(ctx->opcode);
switch (op1) {
case OPC_EXT:
gen_trap(ctx, op1, rs, -1, imm);
break;
case OPC_SYNCI:
+ check_mips_r2(env, ctx);
/* treat as noop */
break;
default: /* Invalid */
gen_cp0(env, ctx, MASK_C0(ctx->opcode), rt, rd);
break;
case OPC_MFMC0:
+ check_mips_r2(env, ctx);
op2 = MASK_MFMC0(ctx->opcode);
switch (op2) {
case OPC_DI:
break;
case OPC_RDPGPR:
case OPC_WRPGPR:
- if ((env->CP0_Config0 & (0x7 << CP0C0_AR)) == (1 << CP0C0_AR)) {
- /* Shadow registers not implemented. */
- GEN_LOAD_REG_TN(T0, rt);
- GEN_STORE_TN_REG(rd, T0);
- } else {
- MIPS_INVAL("shadow register move");
- generate_exception(ctx, EXCP_RI);
- }
+ check_mips_r2(env, ctx);
+ /* Shadow registers not implemented. */
+ GEN_LOAD_REG_TN(T0, rt);
+ GEN_STORE_TN_REG(rd, T0);
break;
default:
MIPS_INVAL("cp0");
check_cp1_enabled(ctx);
op1 = MASK_CP1(ctx->opcode);
switch (op1) {
+ case OPC_MFHC1:
+ case OPC_MTHC1:
+ check_mips_r2(env, ctx);
case OPC_MFC1:
case OPC_CFC1:
case OPC_MTC1:
case OPC_DMFC1:
case OPC_DMTC1:
#endif
- case OPC_MFHC1:
- case OPC_MTHC1:
gen_cp1(ctx, op1, rt, rd);
break;
case OPC_BC1: