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) {
 
  456                         (
count == 1) ? 
"time" : 
"times");
 
  487     const uint32_t num_bits = 
size * 8;
 
  490     unsigned int pos = 0;
 
  491     while (pos < num_bits) {
 
  498         if (pc == end_of_trace) {
 
  516     switch (trace_info->
format) {
 
  864     if (CMD_ARGC < 2 || CMD_ARGC > 3)
 
  873         if (strcmp(
"wrap", 
CMD_ARGV[2]) == 0)
 
  909     if (strcmp(
CMD_ARGV[0], 
"enable") == 0)
 
  911     else if (strcmp(
CMD_ARGV[0], 
"disable") == 0)
 
  929     if (strcmp(
CMD_ARGV[0], 
"full") == 0)
 
  931     else if (strcmp(
CMD_ARGV[0], 
"branch") == 0)
 
  933     else if (strcmp(
CMD_ARGV[0], 
"icache") == 0)
 
  940     if (pc_bits < 1 || pc_bits > 31) {
 
  959     if (strcmp(
CMD_ARGV[0], 
"none") == 0)
 
  961     else if (strcmp(
CMD_ARGV[0], 
"pc") == 0)
 
  963     else if (strcmp(
CMD_ARGV[0], 
"load") == 0)
 
  965     else if (strcmp(
CMD_ARGV[0], 
"store") == 0)
 
  967     else if (strcmp(
CMD_ARGV[0], 
"exception") == 0)
 
  969     else if (strcmp(
CMD_ARGV[0], 
"eret") == 0)
 
  971     else if (strcmp(
CMD_ARGV[0], 
"wait") == 0)
 
  973     else if (strcmp(
CMD_ARGV[0], 
"stop") == 0)
 
  975     else if (strcmp(
CMD_ARGV[0], 
"high") == 0)
 
  977     else if (strcmp(
CMD_ARGV[0], 
"low") == 0)
 
 1002     if (strcmp(
CMD_ARGV[0], 
"none") == 0)
 
 1004     else if (strcmp(
CMD_ARGV[0], 
"pc") == 0)
 
 1006     else if (strcmp(
CMD_ARGV[0], 
"load") == 0)
 
 1008     else if (strcmp(
CMD_ARGV[0], 
"store") == 0)
 
 1010     else if (strcmp(
CMD_ARGV[0], 
"exception") == 0)
 
 1012     else if (strcmp(
CMD_ARGV[0], 
"eret") == 0)
 
 1014     else if (strcmp(
CMD_ARGV[0], 
"wait") == 0)
 
 1016     else if (strcmp(
CMD_ARGV[0], 
"stop") == 0)
 
 1038     if (CMD_ARGC < 1 || CMD_ARGC > 2)
 
 1041     if (strcmp(
CMD_ARGV[0], 
"none") == 0)
 
 1043     else if (strcmp(
CMD_ARGV[0], 
"start") == 0)
 
 1045     else if (strcmp(
CMD_ARGV[0], 
"stop") == 0)
 
 1047     else if (strcmp(
CMD_ARGV[0], 
"both") == 0)
 
 1067         .handler = handle_esirisc_trace_init_command,
 
 1069         .help = 
"initialize trace collection",
 
 1074         .handler = handle_esirisc_trace_info_command,
 
 1076         .help = 
"display trace configuration",
 
 1081         .handler = handle_esirisc_trace_status_command,
 
 1083         .help = 
"display trace collection status",
 
 1088         .handler = handle_esirisc_trace_start_command,
 
 1090         .help = 
"start trace collection",
 
 1095         .handler = handle_esirisc_trace_stop_command,
 
 1097         .help = 
"stop trace collection",
 
 1102         .handler = handle_esirisc_trace_analyze_command,
 
 1104         .usage = 
"[address size]",
 
 1105         .help = 
"analyze collected trace data",
 
 1109         .handler = handle_esirisc_trace_dump_command,
 
 1111         .help = 
"dump collected trace data to file",
 
 1112         .usage = 
"[address size] filename",
 
 1120         .handler = handle_esirisc_trace_trigger_start_command,
 
 1122         .help = 
"configure trigger start condition",
 
 1123         .usage = 
"('none'|'pc'|'load'|'store'|'exception'|'eret'|'wait'|'stop'|'high'|'low')" 
 1124                  " [start_data start_mask]",
 
 1128         .handler = handle_esirisc_trace_trigger_stop_command,
 
 1130         .help = 
"configure trigger stop condition",
 
 1131         .usage = 
"('none'|'pc'|'load'|'store'|'exception'|'eret'|'wait'|'stop')" 
 1132                  " [stop_data stop_mask]",
 
 1136         .handler = handle_esirisc_trace_trigger_delay_command,
 
 1138         .help = 
"configure trigger start/stop delay in clock cycles",
 
 1139         .usage = 
"('none'|'start'|'stop'|'both') [cycles]",
 
 1147         .handler = handle_esirisc_trace_buffer_command,
 
 1149         .help = 
"configure trace buffer",
 
 1150         .usage = 
"address size ['wrap']",
 
 1154         .handler = handle_esirisc_trace_fifo_command,
 
 1156         .help = 
"configure trace FIFO",
 
 1160         .name = 
"flow_control",
 
 1161         .handler = handle_esirisc_trace_flow_control_command,
 
 1163         .help = 
"enable or disable stalling CPU to collect trace data",
 
 1164         .usage = 
"('enable'|'disable')",
 
 1168         .handler = handle_esirisc_trace_format_command,
 
 1170         .help = 
"configure trace format",
 
 1171         .usage = 
"('full'|'branch'|'icache') pc_bits",
 
 1176         .help = 
"eSi-Trace trigger command group",
 
 1190         .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.
uint64_t buffer
Pointer to data buffer to send over SPI.
uint32_t size
Size of dw_spi_transaction::buffer.
uint32_t address
Starting address. Sector aligned.
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_TARGET_ERROR(target, fmt_str,...)
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