riscv: Add skeleton of RISC-V v013 compliance
This commit is contained in:
parent
7a4948c126
commit
95ee7975ea
|
@ -64,6 +64,7 @@ static void riscv013_fill_dmi_read_u64(struct target *target, char *buf, int a);
|
||||||
static int riscv013_dmi_write_u64_bits(struct target *target);
|
static int riscv013_dmi_write_u64_bits(struct target *target);
|
||||||
static void riscv013_fill_dmi_nop_u64(struct target *target, char *buf);
|
static void riscv013_fill_dmi_nop_u64(struct target *target, char *buf);
|
||||||
static void riscv013_reset_current_hart(struct target *target);
|
static void riscv013_reset_current_hart(struct target *target);
|
||||||
|
static int riscv013_test_compliance(struct target *target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Since almost everything can be accomplish by scanning the dbus register, all
|
* Since almost everything can be accomplish by scanning the dbus register, all
|
||||||
|
@ -728,6 +729,7 @@ static int init_target(struct command_context *cmd_ctx,
|
||||||
generic_info->fill_dmi_nop_u64 = &riscv013_fill_dmi_nop_u64;
|
generic_info->fill_dmi_nop_u64 = &riscv013_fill_dmi_nop_u64;
|
||||||
generic_info->dmi_write_u64_bits = &riscv013_dmi_write_u64_bits;
|
generic_info->dmi_write_u64_bits = &riscv013_dmi_write_u64_bits;
|
||||||
generic_info->reset_current_hart = &riscv013_reset_current_hart;
|
generic_info->reset_current_hart = &riscv013_reset_current_hart;
|
||||||
|
generic_info->test_compliance = &riscv013_test_compliance;
|
||||||
|
|
||||||
generic_info->version_specific = calloc(1, sizeof(riscv013_info_t));
|
generic_info->version_specific = calloc(1, sizeof(riscv013_info_t));
|
||||||
if (!generic_info->version_specific)
|
if (!generic_info->version_specific)
|
||||||
|
@ -2108,3 +2110,18 @@ void riscv013_clear_abstract_error(struct target *target)
|
||||||
uint32_t acs = dmi_read(target, DMI_ABSTRACTCS);
|
uint32_t acs = dmi_read(target, DMI_ABSTRACTCS);
|
||||||
dmi_write(target, DMI_ABSTRACTCS, acs);
|
dmi_write(target, DMI_ABSTRACTCS, acs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int riscv013_test_compliance(struct target *target) {
|
||||||
|
LOG_INFO("Testing Compliance against RISC-V Debug Spec v0.13");
|
||||||
|
|
||||||
|
int total_tests = 0;
|
||||||
|
int passed_tests = 0;
|
||||||
|
|
||||||
|
LOG_INFO("PASSED %d of %d TESTS\n", passed_tests, total_tests);
|
||||||
|
|
||||||
|
if (total_tests == passed_tests) {
|
||||||
|
return ERROR_OK;
|
||||||
|
} else {
|
||||||
|
return ERROR_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1246,30 +1246,30 @@ int riscv_dmi_write_u64_bits(struct target *target)
|
||||||
|
|
||||||
COMMAND_HANDLER(riscv_test_compliance) {
|
COMMAND_HANDLER(riscv_test_compliance) {
|
||||||
|
|
||||||
//struct target *target = get_current_target(CMD_CTX);
|
struct target *target = get_current_target(CMD_CTX);
|
||||||
//TODO: Create methods to check it's really RISC-V.
|
|
||||||
//struct riscv_target * riscv = (struct riscv_target*) target;
|
RISCV_INFO(r);
|
||||||
|
|
||||||
if (CMD_ARGC > 0) {
|
if (CMD_ARGC > 0) {
|
||||||
if (strcmp(CMD_ARGV[0], "foo") == 0)
|
LOG_ERROR("Command does not take any parameters.");
|
||||||
LOG_ERROR("FOO!");
|
|
||||||
if (strcmp(CMD_ARGV[0], "bar") == 0)
|
|
||||||
LOG_DEBUG("BAR!");
|
|
||||||
} else {
|
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_OK;
|
if (r->test_compliance) {
|
||||||
|
return r->test_compliance(target);
|
||||||
|
} else {
|
||||||
|
LOG_ERROR("This target does not support this command (may implement an older version of the spec).");
|
||||||
|
return ERROR_FAIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct command_registration riscv_exec_command_handlers[] = {
|
static const struct command_registration riscv_exec_command_handlers[] = {
|
||||||
{
|
{
|
||||||
.name = "riscv_test_compliance",
|
.name = "test_compliance",
|
||||||
.handler = riscv_test_compliance,
|
.handler = riscv_test_compliance,
|
||||||
.mode = COMMAND_EXEC,
|
.mode = COMMAND_EXEC,
|
||||||
.usage = "['foo'|'bar']",
|
.usage = "",
|
||||||
.help = "foos and bars"
|
.help = "Runs a basic compliance test suite against the RISC-V Debug Spec."
|
||||||
},
|
},
|
||||||
COMMAND_REGISTRATION_DONE
|
COMMAND_REGISTRATION_DONE
|
||||||
};
|
};
|
||||||
|
|
|
@ -92,6 +92,7 @@ typedef struct {
|
||||||
void (*fill_dmi_read_u64)(struct target *target, char *buf, int a);
|
void (*fill_dmi_read_u64)(struct target *target, char *buf, int a);
|
||||||
void (*fill_dmi_nop_u64)(struct target *target, char *buf);
|
void (*fill_dmi_nop_u64)(struct target *target, char *buf);
|
||||||
void (*reset_current_hart)(struct target *target);
|
void (*reset_current_hart)(struct target *target);
|
||||||
|
int (*test_compliance)(struct target *target);
|
||||||
} riscv_info_t;
|
} riscv_info_t;
|
||||||
|
|
||||||
/* Everything needs the RISC-V specific info structure, so here's a nice macro
|
/* Everything needs the RISC-V specific info structure, so here's a nice macro
|
||||||
|
|
Loading…
Reference in New Issue