21 #define BIT_MASK(x) ((1 << (x)) - 1)
24 #define CONTROL_ST (1<<0)
25 #define CONTROL_SP (1<<1)
26 #define CONTROL_W (1<<2)
27 #define CONTROL_FC (1<<3)
28 #define CONTROL_FMT(x) (((x) << 4) & 0x30)
29 #define CONTROL_PCB(x) (((x) << 10) & 0x7c00)
32 #define STATUS_T (1<<0)
33 #define STATUS_TD (1<<1)
34 #define STATUS_W (1<<2)
35 #define STATUS_O (1<<3)
38 #define TRIGGER_TST(x) (((x) << 0) & 0xf)
39 #define TRIGGER_DST (1<<7)
40 #define TRIGGER_TSP(x) (((x) << 8) & 0xf00)
41 #define TRIGGER_DSP (1<<15)
44 "none",
"start",
"stop",
"both",
48 "full",
"branch",
"icache",
52 "sequential instruction",
64 "multicycle instruction",
73 "none",
"pc",
"load",
"store",
"exception",
"eret",
"wait",
"stop",
290 unsigned int *pos,
unsigned int count, uint32_t *value)
292 const unsigned int num_bits =
size * 8;
294 if (*pos+
count > num_bits)
304 unsigned int *pos, uint32_t *value)
341 uint32_t buffer_cur,
status;
380 const uint32_t num_bits =
size * 8;
383 unsigned int pos = 0;
384 while (pos < num_bits) {
454 (
count == 1) ?
"time" :
"times");
484 const uint32_t num_bits =
size * 8;
487 unsigned int pos = 0;
488 while (pos < num_bits) {
495 if (pc == end_of_trace) {
513 switch (trace_info->
format) {
861 if (CMD_ARGC < 2 || CMD_ARGC > 3)
870 if (strcmp(
"wrap",
CMD_ARGV[2]) == 0)
906 if (strcmp(
CMD_ARGV[0],
"enable") == 0)
908 else if (strcmp(
CMD_ARGV[0],
"disable") == 0)
926 if (strcmp(
CMD_ARGV[0],
"full") == 0)
928 else if (strcmp(
CMD_ARGV[0],
"branch") == 0)
930 else if (strcmp(
CMD_ARGV[0],
"icache") == 0)
937 if (pc_bits < 1 || pc_bits > 31) {
956 if (strcmp(
CMD_ARGV[0],
"none") == 0)
958 else if (strcmp(
CMD_ARGV[0],
"pc") == 0)
960 else if (strcmp(
CMD_ARGV[0],
"load") == 0)
962 else if (strcmp(
CMD_ARGV[0],
"store") == 0)
964 else if (strcmp(
CMD_ARGV[0],
"exception") == 0)
966 else if (strcmp(
CMD_ARGV[0],
"eret") == 0)
968 else if (strcmp(
CMD_ARGV[0],
"wait") == 0)
970 else if (strcmp(
CMD_ARGV[0],
"stop") == 0)
972 else if (strcmp(
CMD_ARGV[0],
"high") == 0)
974 else if (strcmp(
CMD_ARGV[0],
"low") == 0)
999 if (strcmp(
CMD_ARGV[0],
"none") == 0)
1001 else if (strcmp(
CMD_ARGV[0],
"pc") == 0)
1003 else if (strcmp(
CMD_ARGV[0],
"load") == 0)
1005 else if (strcmp(
CMD_ARGV[0],
"store") == 0)
1007 else if (strcmp(
CMD_ARGV[0],
"exception") == 0)
1009 else if (strcmp(
CMD_ARGV[0],
"eret") == 0)
1011 else if (strcmp(
CMD_ARGV[0],
"wait") == 0)
1013 else if (strcmp(
CMD_ARGV[0],
"stop") == 0)
1035 if (CMD_ARGC < 1 || CMD_ARGC > 2)
1038 if (strcmp(
CMD_ARGV[0],
"none") == 0)
1040 else if (strcmp(
CMD_ARGV[0],
"start") == 0)
1042 else if (strcmp(
CMD_ARGV[0],
"stop") == 0)
1044 else if (strcmp(
CMD_ARGV[0],
"both") == 0)
1064 .handler = handle_esirisc_trace_init_command,
1066 .help =
"initialize trace collection",
1071 .handler = handle_esirisc_trace_info_command,
1073 .help =
"display trace configuration",
1078 .handler = handle_esirisc_trace_status_command,
1080 .help =
"display trace collection status",
1085 .handler = handle_esirisc_trace_start_command,
1087 .help =
"start trace collection",
1092 .handler = handle_esirisc_trace_stop_command,
1094 .help =
"stop trace collection",
1099 .handler = handle_esirisc_trace_analyze_command,
1101 .usage =
"[address size]",
1102 .help =
"analyze collected trace data",
1106 .handler = handle_esirisc_trace_dump_command,
1108 .help =
"dump collected trace data to file",
1109 .usage =
"[address size] filename",
1117 .handler = handle_esirisc_trace_trigger_start_command,
1119 .help =
"configure trigger start condition",
1120 .usage =
"('none'|'pc'|'load'|'store'|'exception'|'eret'|'wait'|'stop'|'high'|'low')"
1121 " [start_data start_mask]",
1125 .handler = handle_esirisc_trace_trigger_stop_command,
1127 .help =
"configure trigger stop condition",
1128 .usage =
"('none'|'pc'|'load'|'store'|'exception'|'eret'|'wait'|'stop')"
1129 " [stop_data stop_mask]",
1133 .handler = handle_esirisc_trace_trigger_delay_command,
1135 .help =
"configure trigger start/stop delay in clock cycles",
1136 .usage =
"('none'|'start'|'stop'|'both') [cycles]",
1144 .handler = handle_esirisc_trace_buffer_command,
1146 .help =
"configure trace buffer",
1147 .usage =
"address size ['wrap']",
1151 .handler = handle_esirisc_trace_fifo_command,
1153 .help =
"configure trace FIFO",
1157 .name =
"flow_control",
1158 .handler = handle_esirisc_trace_flow_control_command,
1160 .help =
"enable or disable stalling CPU to collect trace data",
1161 .usage =
"('enable'|'disable')",
1165 .handler = handle_esirisc_trace_format_command,
1167 .help =
"configure trace format",
1168 .usage =
"('full'|'branch'|'icache') pc_bits",
1173 .help =
"eSi-Trace trigger command group",
1187 .help =
"eSi-Trace command group",
Support functions to access arbitrary bits in a byte array.
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned int first, unsigned int num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define COMMAND_PARSE_ADDRESS(in, out)
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
static struct esirisc_common * target_to_esirisc(const struct target *target)
int esirisc_jtag_read_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t *data)
int esirisc_jtag_write_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t data)
#define CSR_TRACE_BUFFER_END
#define CSR_TRACE_START_DATA
#define CSR_TRACE_TRIGGER
#define CSR_TRACE_STOP_MASK
#define CSR_TRACE_START_MASK
#define CSR_TRACE_CONTROL
#define CSR_TRACE_STOP_DATA
#define CSR_TRACE_BUFFER_START
#define CSR_TRACE_BUFFER_CUR
static int esirisc_trace_get_status(struct target *target, uint32_t *status)
static const struct command_registration esirisc_trace_trigger_any_command_handlers[]
static const char *const esirisc_trace_delay_strings[]
static const char *const esirisc_trace_ext_id_strings[]
static int esirisc_trace_stop(struct target *target)
static int esirisc_trace_start(struct target *target)
static int esirisc_trace_buf_get_pc(struct target *target, uint8_t *buffer, uint32_t size, unsigned int *pos, uint32_t *value)
static int esirisc_trace_analyze_simple(struct command_invocation *cmd, uint8_t *buffer, uint32_t size)
static int esirisc_trace_analyze(struct command_invocation *cmd, uint8_t *buffer, uint32_t size)
static int esirisc_trace_dump_buffer(struct command_invocation *cmd, const char *filename)
static int esirisc_trace_dump_memory(struct command_invocation *cmd, const char *filename, target_addr_t address, uint32_t size)
const struct command_registration esirisc_trace_command_handlers[]
static const char *const esirisc_trace_id_strings[]
static int esirisc_trace_analyze_buffer(struct command_invocation *cmd)
static const char *const esirisc_trace_trigger_strings[]
static int esirisc_trace_analyze_memory(struct command_invocation *cmd, target_addr_t address, uint32_t size)
static int esirisc_trace_read_memory(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
static int esirisc_trace_clear_status(struct target *target)
static int esirisc_trace_analyze_full(struct command_invocation *cmd, uint8_t *buffer, uint32_t size)
static int esirisc_trace_dump(struct command_invocation *cmd, const char *filename, uint8_t *buffer, uint32_t size)
static const struct command_registration esirisc_trace_exec_command_handlers[]
static const char *const esirisc_trace_format_strings[]
static int esirisc_trace_init(struct target *target)
static int esirisc_trace_buf_get_u32(uint8_t *buffer, uint32_t size, unsigned int *pos, unsigned int count, uint32_t *value)
static const struct command_registration esirisc_trace_any_command_handlers[]
static int esirisc_trace_read_buffer(struct target *target, uint8_t *buffer)
COMMAND_HANDLER(handle_esirisc_trace_init_command)
static uint32_t esirisc_trace_buffer_size(struct esirisc_trace *trace_info)
@ ESIRISC_TRACE_TRIGGER_HIGH
@ ESIRISC_TRACE_TRIGGER_STORE
@ ESIRISC_TRACE_TRIGGER_STOP
@ ESIRISC_TRACE_TRIGGER_NONE
@ ESIRISC_TRACE_TRIGGER_WAIT
@ ESIRISC_TRACE_TRIGGER_LOW
@ ESIRISC_TRACE_TRIGGER_LOAD
@ ESIRISC_TRACE_TRIGGER_ERET
@ ESIRISC_TRACE_TRIGGER_PC
@ ESIRISC_TRACE_TRIGGER_EXCEPTION
static bool esirisc_trace_is_fifo(struct esirisc_trace *trace_info)
@ ESIRISC_TRACE_FORMAT_ICACHE
@ ESIRISC_TRACE_FORMAT_FULL
@ ESIRISC_TRACE_FORMAT_BRANCH
@ ESIRISC_TRACE_EXT_ID_WAIT
@ ESIRISC_TRACE_EXT_ID_MULTICYCLE
@ ESIRISC_TRACE_EXT_ID_STOP
@ ESIRISC_TRACE_EXT_ID_END
@ ESIRISC_TRACE_EXT_ID_END_PC
@ ESIRISC_TRACE_EXT_ID_INDIRECT
@ ESIRISC_TRACE_EXT_ID_COUNT
@ ESIRISC_TRACE_EXT_ID_PC
@ ESIRISC_TRACE_EXT_ID_ERET
@ ESIRISC_TRACE_EXT_ID_EXCEPTION
@ ESIRISC_TRACE_DELAY_NONE
@ ESIRISC_TRACE_DELAY_START
@ ESIRISC_TRACE_DELAY_BOTH
@ ESIRISC_TRACE_DELAY_STOP
@ ESIRISC_TRACE_ID_EXECUTE
@ ESIRISC_TRACE_ID_BRANCH
@ ESIRISC_TRACE_ID_EXTENDED
int fileio_write(struct fileio *fileio, size_t size, const void *buffer, size_t *size_written)
int fileio_close(struct fileio *fileio)
int fileio_open(struct fileio **fileio, const char *url, enum fileio_access access_type, enum fileio_type type)
#define ERROR_BUF_TOO_SMALL
#define LOG_ERROR(expr ...)
size_t size
Size of the control block search area.
char id[RTT_CB_MAX_ID_LENGTH]
Control block identifier.
When run_command is called, a new instance will be created on the stack, filled with the proper value...
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
struct esirisc_jtag jtag_info
struct esirisc_trace trace_info
enum esirisc_trace_format format
enum esirisc_trace_trigger stop_trigger
enum esirisc_trace_trigger start_trigger
enum esirisc_trace_delay delay
target_addr_t buffer_start
int target_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Read count items of size bytes from the memory of target at the address given.
struct target * get_current_target(struct command_context *cmd_ctx)
#define ERROR_TARGET_NOT_HALTED
static const char * target_name(const struct target *target)
Returns the instance-specific name of the specified target.