Skip to content

Commit

Permalink
vr4300: Implement break instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1187 committed May 27, 2020
1 parent fe81d08 commit fa73cbe
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
14 changes: 13 additions & 1 deletion vr4300/fault.c
Expand Up @@ -469,7 +469,19 @@ void VR4300_SYSC(struct vr4300 *vr4300) {

vr4300_ex_fault(vr4300, VR4300_FAULT_SYSC);
vr4300_exception_prolog(vr4300, common, &cause, &status, &epc);
vr4300_exception_epilogue(vr4300, (cause & ~0xFF) | 0x20,
vr4300_exception_epilogue(vr4300, (cause & ~0xFF) | (8 << 2),
status, epc, 0x180);
}

// BRPT: Breakpoint exception
void VR4300_BRPT(struct vr4300 *vr4300) {
struct vr4300_latch *common = &vr4300->pipeline.exdc_latch.common;
uint32_t cause, status;
uint64_t epc;

vr4300_ex_fault(vr4300, VR4300_FAULT_BRPT);
vr4300_exception_prolog(vr4300, common, &cause, &status, &epc);
vr4300_exception_epilogue(vr4300, (cause & ~0xFF) | (9 << 2),
status, epc, 0x180);
}

Expand Down
1 change: 1 addition & 0 deletions vr4300/fault.h
Expand Up @@ -25,6 +25,7 @@ enum vr4300_fault_id {

extern const char *vr4300_fault_mnemonics[NUM_VR4300_FAULTS];

cen64_cold void VR4300_BRPT(struct vr4300 *vr4300);
cen64_cold void VR4300_CPU(struct vr4300 *vr4300);
cen64_cold void VR4300_DADE(struct vr4300 *vr4300);
cen64_cold void VR4300_DCB(struct vr4300 *vr4300);
Expand Down
9 changes: 9 additions & 0 deletions vr4300/functions.c
Expand Up @@ -405,6 +405,15 @@ int VR4300_BGTZ_BGTZL_BLEZ_BLEZL(
return 0;
}

//
// BREAK
//
int VR4300_BREAK(struct vr4300 *vr4300,
uint32_t unused(iw), uint64_t unused(rs), uint64_t unused(rt)) {
VR4300_BRPT(vr4300);
return 1;
}

//
// CACHE
//
Expand Down
2 changes: 1 addition & 1 deletion vr4300/opcodes_priv.h
Expand Up @@ -54,7 +54,7 @@
#define BLTZAL VR4300_BUILD_OP(BLTZAL, BGEZAL_BGEZALL_BLTZAL_BLTZALL, INFO2(BRANCH, NEEDRS))
#define BLTZALL VR4300_BUILD_OP(BLTZALL, BGEZAL_BGEZALL_BLTZAL_BLTZALL, INFO2(BRANCH, NEEDRS))
#define BLTZL VR4300_BUILD_OP(BLTZL, BGEZ_BGEZL_BLTZ_BLTZL, INFO2(BRANCH, NEEDRS))
#define BREAK VR4300_BUILD_OP(BREAK, INVALID, INFO1(NONE))
#define BREAK VR4300_BUILD_OP(BREAK, BREAK, INFO1(NONE))
#define DADD VR4300_BUILD_OP(DADD, DADD_DSUB, INFO2(NEEDRS, NEEDRT))
#define DADDI VR4300_BUILD_OP(DADDI, DADDI_DSUBI, INFO1(NEEDRS))
#define DADDIU VR4300_BUILD_OP(DADDIU, DADDIU_DSUBIU, INFO1(NEEDRS))
Expand Down

0 comments on commit fa73cbe

Please sign in to comment.