riscv: Add commands for setting timeouts
parent
25eedb94a5
commit
3ec1772c96
|
@ -154,7 +154,6 @@ typedef enum slot {
|
|||
/*** Info about the core being debugged. ***/
|
||||
|
||||
#define DBUS_ADDRESS_UNKNOWN 0xffff
|
||||
#define WALL_CLOCK_TIMEOUT 2
|
||||
|
||||
// gdb's register list is defined in riscv_gdb_reg_names gdb/riscv-tdep.c in
|
||||
// its source tree. We must interpret the numbers the same here.
|
||||
|
@ -730,8 +729,9 @@ static int wait_for_debugint_clear(struct target *target, bool ignore_first)
|
|||
if (!bits.interrupt) {
|
||||
return ERROR_OK;
|
||||
}
|
||||
if (time(NULL) - start > WALL_CLOCK_TIMEOUT) {
|
||||
LOG_ERROR("Timed out waiting for debug int to clear.");
|
||||
if (time(NULL) - start > riscv_command_timeout_sec) {
|
||||
LOG_ERROR("Timed out waiting for debug int to clear."
|
||||
"Increase timeout with riscv set_command_timeout_sec.");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
}
|
||||
|
@ -1016,8 +1016,9 @@ static int wait_for_state(struct target *target, enum target_state state)
|
|||
if (target->state == state) {
|
||||
return ERROR_OK;
|
||||
}
|
||||
if (time(NULL) - start > WALL_CLOCK_TIMEOUT) {
|
||||
LOG_ERROR("Timed out waiting for state %d.", state);
|
||||
if (time(NULL) - start > riscv_command_timeout_sec) {
|
||||
LOG_ERROR("Timed out waiting for state %d. "
|
||||
"Increase timeout with riscv set_command_timeout_sec.", state);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
}
|
||||
|
@ -1174,8 +1175,9 @@ static int full_step(struct target *target, bool announce)
|
|||
return result;
|
||||
if (target->state != TARGET_DEBUG_RUNNING)
|
||||
break;
|
||||
if (time(NULL) - start > WALL_CLOCK_TIMEOUT) {
|
||||
LOG_ERROR("Timed out waiting for step to complete.");
|
||||
if (time(NULL) - start > riscv_command_timeout_sec) {
|
||||
LOG_ERROR("Timed out waiting for step to complete."
|
||||
"Increase timeout with riscv set_command_timeout_sec");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
}
|
||||
|
@ -1471,6 +1473,7 @@ static int init_target(struct command_context *cmd_ctx,
|
|||
riscv_info_t *generic_info = (riscv_info_t *) target->arch_info;
|
||||
generic_info->get_register = get_register;
|
||||
generic_info->set_register = set_register;
|
||||
|
||||
generic_info->version_specific = calloc(1, sizeof(riscv011_info_t));
|
||||
if (!generic_info->version_specific)
|
||||
return ERROR_FAIL;
|
||||
|
|
|
@ -122,9 +122,6 @@ typedef enum slot {
|
|||
|
||||
/*** Info about the core being debugged. ***/
|
||||
|
||||
#define WALL_CLOCK_TIMEOUT 2
|
||||
#define WALL_CLOCK_RESET_TIMEOUT 30
|
||||
|
||||
struct trigger {
|
||||
uint64_t address;
|
||||
uint32_t length;
|
||||
|
@ -563,7 +560,7 @@ static int wait_for_idle(struct target *target, uint32_t *abstractcs)
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (time(NULL) - start > WALL_CLOCK_TIMEOUT) {
|
||||
if (time(NULL) - start > riscv_command_timeout_sec) {
|
||||
info->cmderr = get_field(*abstractcs, DMI_ABSTRACTCS_CMDERR);
|
||||
if (info->cmderr != CMDERR_NONE) {
|
||||
const char *errors[8] = {
|
||||
|
@ -580,7 +577,9 @@ static int wait_for_idle(struct target *target, uint32_t *abstractcs)
|
|||
errors[info->cmderr], *abstractcs);
|
||||
}
|
||||
|
||||
LOG_ERROR("Timed out waiting for busy to go low. (abstractcs=0x%x)",
|
||||
LOG_ERROR("Timed out after %ds waiting for busy to go low. (abstractcs=0x%x)"
|
||||
"Increase the timeout with riscv set_command_timeout_sec.",
|
||||
riscv_command_timeout_sec,
|
||||
*abstractcs);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
@ -1894,9 +1893,11 @@ void riscv013_reset_current_hart(struct target *target)
|
|||
if (get_field(dmstatus, DMI_DMSTATUS_ALLHALTED)) {
|
||||
break;
|
||||
}
|
||||
if (time(NULL) - start > WALL_CLOCK_RESET_TIMEOUT) {
|
||||
if (time(NULL) - start > riscv_reset_timeout_sec) {
|
||||
LOG_ERROR("Hart didn't halt coming out of reset in %ds; "
|
||||
"dmstatus=0x%x", WALL_CLOCK_RESET_TIMEOUT, dmstatus);
|
||||
"dmstatus=0x%x"
|
||||
"Increase the timeout with riscv set_reset_timeout_sec.",
|
||||
riscv_reset_timeout_sec, dmstatus);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,7 +150,6 @@ typedef enum slot {
|
|||
/*** Info about the core being debugged. ***/
|
||||
|
||||
#define DBUS_ADDRESS_UNKNOWN 0xffff
|
||||
#define WALL_CLOCK_TIMEOUT 2
|
||||
|
||||
// gdb's register list is defined in riscv_gdb_reg_names gdb/riscv-tdep.c in
|
||||
// its source tree. We must interpret the numbers the same here.
|
||||
|
@ -195,6 +194,12 @@ struct trigger {
|
|||
int unique_id;
|
||||
};
|
||||
|
||||
/* Wall-clock timeout for a command/access. Settable via RISC-V Target commands.*/
|
||||
int riscv_command_timeout_sec = DEFAULT_COMMAND_TIMEOUT_SEC;
|
||||
|
||||
/* Wall-clock timeout after reset. Settable via RISC-V Target commands.*/
|
||||
int riscv_reset_timeout_sec = DEFAULT_RESET_TIMEOUT_SEC;
|
||||
|
||||
static uint32_t dtmcontrol_scan(struct target *target, uint32_t out)
|
||||
{
|
||||
struct scan_field field;
|
||||
|
@ -1617,7 +1622,7 @@ COMMAND_HANDLER(riscv_test_compliance) {
|
|||
|
||||
if (CMD_ARGC > 0) {
|
||||
LOG_ERROR("Command does not take any parameters.");
|
||||
return ERROR_FAIL;
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (r->test_compliance) {
|
||||
|
@ -1626,16 +1631,65 @@ COMMAND_HANDLER(riscv_test_compliance) {
|
|||
LOG_ERROR("This target does not support this command (may implement an older version of the spec).");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(riscv_set_command_timeout_sec) {
|
||||
|
||||
if (CMD_ARGC != 1) {
|
||||
LOG_ERROR("Command takes exactly 1 parameter");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
int timeout = atoi(CMD_ARGV[0]);
|
||||
if (timeout <= 0){
|
||||
LOG_ERROR("%s is not a valid integer argument for command.", CMD_ARGV[0]);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
riscv_command_timeout_sec = timeout;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(riscv_set_reset_timeout_sec) {
|
||||
|
||||
if (CMD_ARGC != 1) {
|
||||
LOG_ERROR("Command takes exactly 1 parameter");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
int timeout = atoi(CMD_ARGV[0]);
|
||||
if (timeout <= 0){
|
||||
LOG_ERROR("%s is not a valid integer argument for command.", CMD_ARGV[0]);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
riscv_reset_timeout_sec = timeout;
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
static const struct command_registration riscv_exec_command_handlers[] = {
|
||||
{
|
||||
.name = "test_compliance",
|
||||
.handler = riscv_test_compliance,
|
||||
.mode = COMMAND_EXEC,
|
||||
.usage = "",
|
||||
.usage = "riscv test_compliance",
|
||||
.help = "Runs a basic compliance test suite against the RISC-V Debug Spec."
|
||||
},
|
||||
{
|
||||
.name = "set_command_timeout_sec",
|
||||
.handler = riscv_set_command_timeout_sec,
|
||||
.mode = COMMAND_ANY,
|
||||
.usage = "riscv set_command_timeout_sec [sec]",
|
||||
.help = "Set the wall-clock timeout (in seconds) for individual commands"
|
||||
},
|
||||
{
|
||||
.name = "set_reset_timeout_sec",
|
||||
.handler = riscv_set_reset_timeout_sec,
|
||||
.mode = COMMAND_ANY,
|
||||
.usage = "riscv set_reset_timeout_sec [sec]",
|
||||
.help = "Set the wall-clock timeout (in seconds) after reset is deasserted"
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@ struct riscv_program;
|
|||
#define RISCV_MAX_TRIGGERS 32
|
||||
#define RISCV_MAX_HWBPS 16
|
||||
|
||||
#define DEFAULT_COMMAND_TIMEOUT_SEC 2
|
||||
#define DEFAULT_RESET_TIMEOUT_SEC 30
|
||||
|
||||
extern struct target_type riscv011_target;
|
||||
extern struct target_type riscv013_target;
|
||||
|
||||
|
@ -104,6 +107,12 @@ typedef struct {
|
|||
int (*test_compliance)(struct target *target);
|
||||
} riscv_info_t;
|
||||
|
||||
/* Wall-clock timeout for a command/access. Settable via RISC-V Target commands.*/
|
||||
extern int riscv_command_timeout_sec;
|
||||
|
||||
/* Wall-clock timeout after reset. Settable via RISC-V Target commands.*/
|
||||
extern int riscv_reset_timeout_sec;
|
||||
|
||||
/* Everything needs the RISC-V specific info structure, so here's a nice macro
|
||||
* that provides that. */
|
||||
static inline riscv_info_t *riscv_info(const struct target *target) __attribute__((unused));
|
||||
|
|
Loading…
Reference in New Issue