Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for 40X in debug_test2, fixed typo #2051

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion cv32e40s/tests/programs/custom/debug_test2/debug_test2.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
#define TIMER_VAL_ADDR ((volatile uint32_t * volatile) (CV_VP_INTR_TIMER_BASE + 4))
#define DEBUG_REQ_CONTROL_REG *((volatile uint32_t * volatile) (CV_VP_DEBUG_CONTROL_BASE))

#define MARCHID_CV32E40X 0x14
#define MARCHID_CV32E40S 0x15

// __FUNCTION__ is C99 and newer, -Wpedantic flags a warning that
// this is not ISO C, thus we wrap this instatiation in a macro
// ignoring this GCC warning to avoid a long list of warnings during
Expand Down Expand Up @@ -3115,6 +3118,21 @@ void single_step_basic_dbg(void) {
uint32_t has_pmp_configured(void) {
volatile uint32_t pmpaddr0 = 0xffffffff;
volatile uint32_t pmpaddr0_backup = 0;
volatile uint32_t marchid = 0x0;

__asm__ volatile (R"(
csrrs %[marchid], marchid, zero
)":[marchid] "=r"(marchid));

// CV32E40X does not support PMP, skip test
switch (marchid) {
case (MARCHID_CV32E40X):
return 0;
break;
case (MARCHID_CV32E40S):
;; // Do nothing and continue execution
break;
}

__asm__ volatile (R"(
csrrw %[pmpaddr0_backup] , pmpaddr0, %[pmpaddr0]
Expand Down Expand Up @@ -3144,7 +3162,7 @@ uint32_t mprv_dret_to_umode(uint32_t index, uint8_t report_name) {

// Check if there are configured pmp-regions:
if (!has_pmp_configured()) {
cvprintf(V_LOW, "Skipping test: 0 PMP regions, cannot enter user mode\n");
cvprintf(V_LOW, "Skipping test: 0 PMP regions or PMP not supported, cannot enter user mode\n");
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion cv32e40s/tests/programs/custom/hello-world/hello-world.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}

/* Check MARCHID CSR: 0x4 is the value assigned by the RISC-V Foundation to CV32E40S */
/* Check MARCHID CSR: 0x15 is the value assigned by the RISC-V Foundation to CV32E40S */
if (marchid_rval != 0x15) {
printf("\tERROR: CSR MARCHID reads as 0x%x - should be 0x00000015 for CV32E40S.\n\n", marchid_rval);
return EXIT_FAILURE;
Expand Down