From: Andrew Waterman Date: Thu, 9 Jun 2016 03:03:03 +0000 (-0700) Subject: Add HW breakpoint test X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cacfb9ab5f4cb3359ee1ed769e7f1989409c2c1d;p=riscv-tests.git Add HW breakpoint test --- diff --git a/env b/env index e0d1ea4..2feb57e 160000 --- a/env +++ b/env @@ -1 +1 @@ -Subproject commit e0d1ea452c2a40ca47ec720e7da8c31daa317307 +Subproject commit 2feb57e3bfb9814b2b21b0dfdfbe2c7ef26db5f4 diff --git a/isa/rv64mi/Makefrag b/isa/rv64mi/Makefrag index 01f75c2..4ae8733 100644 --- a/isa/rv64mi/Makefrag +++ b/isa/rv64mi/Makefrag @@ -3,6 +3,7 @@ #----------------------------------------------------------------------- rv64mi_sc_tests = \ + breakpoint \ dirty \ csr \ mcsr \ diff --git a/isa/rv64mi/breakpoint.S b/isa/rv64mi/breakpoint.S new file mode 100644 index 0000000..39d058b --- /dev/null +++ b/isa/rv64mi/breakpoint.S @@ -0,0 +1,97 @@ +# See LICENSE for license details. + +#***************************************************************************** +# breakpoint.S +#----------------------------------------------------------------------------- +# +# Test breakpoints, if they are implemented. +# + +#include "riscv_test.h" +#include "test_macros.h" + +RVTEST_RV64M +RVTEST_CODE_BEGIN + + # Set up breakpoint to trap on M-mode fetches. + li TESTNUM, 2 + csrw tdrselect, x0 + li t0, (BPCONTROL_MATCHCOND & (BPCONTROL_MATCHCOND>>1)) | BPCONTROL_M | BPCONTROL_X + csrw tdrdata1, t0 + # Skip if breakpoint type is unsupported. + csrr t1, tdrdata1 + bne t0, t1, 2f + la t0, 1f + csrw tdrdata2, t0 +1: + # Trap handler should skip this instruction. + j fail + + # Make sure reads don't trap. + li TESTNUM, 3 + lw t0, (t0) + +2: + # Set up breakpoint to trap on M-mode reads. + li TESTNUM, 4 + li t0, (BPCONTROL_MATCHCOND & (BPCONTROL_MATCHCOND>>1)) | BPCONTROL_M | BPCONTROL_R + csrw tdrdata1, t0 + # Skip if breakpoint type is unsupported. + csrr t1, tdrdata1 + bne t0, t1, 2f + la t0, write_data + csrw tdrdata2, t0 + + # Trap handler should skip this instruction. + lw t0, (t0) + beqz t0, fail + + # Make sure writes don't trap. + li TESTNUM, 5 + sw x0, (t0) + +2: + # Set up breakpoint to trap on M-mode stores. + li TESTNUM, 6 + li t0, (BPCONTROL_MATCHCOND & (BPCONTROL_MATCHCOND>>1)) | BPCONTROL_M | BPCONTROL_W + csrw tdrdata1, t0 + # Skip if breakpoint type is unsupported. + csrr t1, tdrdata1 + bne t0, t1, 2f + + # Trap handler should skip this instruction. + la t0, write_data + sw t0, (t0) + + # Make sure store didn't succeed. + li TESTNUM, 7 + lw t0, (t0) + bnez t0, fail + +2: + TEST_PASSFAIL + +mtvec_handler: + # Only even-numbered tests should trap. + andi a0, TESTNUM, 1 + bnez a0, fail + + li a0, CAUSE_BREAKPOINT + csrr a1, mcause + bne a0, a1, fail + + csrr a0, mepc + addi a0, a0, 4 + csrw mepc, a0 + mret + +RVTEST_CODE_END + + .data +RVTEST_DATA_BEGIN + + TEST_DATA + +write_data: .word 0 + +RVTEST_DATA_END