diff options
author | Megan Wachs <megan@sifive.com> | 2018-04-19 10:36:52 -0700 |
---|---|---|
committer | Megan Wachs <megan@sifive.com> | 2018-04-19 10:36:52 -0700 |
commit | debf2b040a98202105aeae733e7dfe4d43c0f8eb (patch) | |
tree | 44e8fdafa7c266212ea2b79d70ae28d2a7ddc942 | |
parent | ac953c71c0bcf7a2fcc17080ae199ad91c677353 (diff) | |
download | riscv-openocd-debf2b040a98202105aeae733e7dfe4d43c0f8eb.zip riscv-openocd-debf2b040a98202105aeae733e7dfe4d43c0f8eb.tar.gz riscv-openocd-debf2b040a98202105aeae733e7dfe4d43c0f8eb.tar.bz2 |
riscv-compliance: correct the HALTSUM0/HALTSUM1 checks
-rw-r--r-- | src/target/riscv/riscv-013.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 92f290b..f1b14c7 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -3100,15 +3100,16 @@ int riscv013_test_compliance(struct target *target) } - /* HALTSUM -- TODO: More than 32 harts */ + /* HALTSUM -- TODO: More than 32 harts. Would need to loop over this to set hartsel */ /* TODO: HALTSUM2, HALTSUM3 */ + /* HALTSUM0 */ uint32_t expected_haltsum0 = 0; - for (int i = 0; i < riscv_count_harts(target); i += 32) - expected_haltsum0 |= (1 << (i / 32)); + for (int i = 0; i < MIN(riscv_count_harts(target), 32); i ++) + expected_haltsum0 |= (1 << i); dmi_read(target, &testvar_read, DMI_HALTSUM0); COMPLIANCE_TEST(testvar_read == expected_haltsum0, - "HALTSUM0 should report summary of 32 halted harts"); + "HALTSUM0 should report summary of up to 32 halted harts"); dmi_write(target, DMI_HALTSUM0, 0xffffffff); dmi_read(target, &testvar_read, DMI_HALTSUM0); @@ -3118,26 +3119,22 @@ int riscv013_test_compliance(struct target *target) dmi_read(target, &testvar_read, DMI_HALTSUM0); COMPLIANCE_TEST(testvar_read == expected_haltsum0, "HALTSUM0 should be R/O"); - for (int i = 0; i < 32/*TODO: riscv_count_harts(target)*/; i += 32) { - /* TODO: Set hartsel for i > 32 harts. */ - dmi_read(target, &testvar_read, DMI_HALTSUM1); - uint32_t haltsum1_expected = (((i + 1) * 32) <= riscv_count_harts(target)) ? - 0xFFFFFFFFU : - ((1U << (riscv_count_harts(target) % 32)) - 1); - COMPLIANCE_TEST(testvar_read == haltsum1_expected, - "HALTSUM1 should report summary of 1024 halted harts"); - - /* Just have to check this once */ - if (i == 0) { - dmi_write(target, DMI_HALTSUM1, 0xffffffff); - dmi_read(target, &testvar_read, DMI_HALTSUM1); - COMPLIANCE_TEST(testvar_read == haltsum1_expected, "HALTSUM1 should be R/O"); - - dmi_write(target, DMI_HALTSUM1, 0x0); - dmi_read(target, &testvar_read, DMI_HALTSUM1); - COMPLIANCE_TEST(testvar_read == haltsum1_expected, "HALTSUM1 should be R/O"); - } - } + /* HALTSUM1 */ + uint32_t expected_haltsum1 = 0; + for (int i = 0; i < MIN(riscv_count_harts(target), 1024); i +=32) + expected_haltsum1 |= (1 << (i/32)); + + dmi_read(target, &testvar_read, DMI_HALTSUM1); + COMPLIANCE_TEST(testvar_read == expected_haltsum1, + "HALTSUM1 should report summary of up to 1024 halted harts"); + + dmi_write(target, DMI_HALTSUM1, 0xffffffff); + dmi_read(target, &testvar_read, DMI_HALTSUM1); + COMPLIANCE_TEST(testvar_read == expected_haltsum1, "HALTSUM1 should be R/O"); + + dmi_write(target, DMI_HALTSUM1, 0x0); + dmi_read(target, &testvar_read, DMI_HALTSUM1); + COMPLIANCE_TEST(testvar_read == expected_haltsum1, "HALTSUM1 should be R/O"); /* TODO: HAWINDOWSEL */ |