25 #define XTENSA_APPTRACE_CTRL_REG XDMREG_DELAYCNT
26 #define XTENSA_APPTRACE_BLOCK_ID_MSK 0x7FUL
27 #define XTENSA_APPTRACE_BLOCK_ID_MAX XTENSA_APPTRACE_BLOCK_ID_MSK
30 #define XTENSA_APPTRACE_STAT_REG XDMREG_TRIGGERPC
32 #define XTENSA_APPTRACE_BLOCK_LEN_MSK 0x7FFFUL
33 #define XTENSA_APPTRACE_BLOCK_LEN(_l_) ((_l_) & XTENSA_APPTRACE_BLOCK_LEN_MSK)
34 #define XTENSA_APPTRACE_BLOCK_LEN_GET(_v_) ((_v_) & XTENSA_APPTRACE_BLOCK_LEN_MSK)
35 #define XTENSA_APPTRACE_BLOCK_ID(_id_) (((_id_) & XTENSA_APPTRACE_BLOCK_ID_MSK) << 15)
36 #define XTENSA_APPTRACE_BLOCK_ID_GET(_v_) (((_v_) >> 15) & XTENSA_APPTRACE_BLOCK_ID_MSK)
37 #define XTENSA_APPTRACE_HOST_DATA BIT(22)
38 #define XTENSA_APPTRACE_HOST_CONNECT BIT(23)
45 const uint8_t *bufs[],
69 uint32_t max_trace_block_sz;
73 LOG_ERROR(
"Failed to read TRAX status (%d)!", res);
80 LOG_ERROR(
"Failed to read TRAX config (%d)!", res);
83 LOG_DEBUG(
"ctrl=0x%" PRIx32
" memadrstart=0x%" PRIx32
" memadrend=0x%" PRIx32
" traxadr=0x%" PRIx32,
89 return max_trace_block_sz;
128 for (
unsigned int i =
size / 4; i != 0; i--) {
144 for (
unsigned int i = 0; i <
size / 4; i++) {
167 uint8_t unal_bytes[4];
293 LOG_ERROR(
"Failed to activate SW debug (%d)!", res);
303 LOG_ERROR(
"Failed to activate SW debug (%d)!", res);
310 uint32_t buf_sz[],
const uint8_t *bufs[])
313 uint32_t cached_bytes = 0, total_sz = 0;
314 uint8_t cached_data8[
sizeof(uint32_t)] = { 0 };
315 uint32_t cached_data32 = 0;
319 for (uint32_t i = 0; i < bufs_num; i++)
320 total_sz += buf_sz[i];
322 cached_bytes =
sizeof(uint32_t) - (total_sz & 0x3UL);
326 for (uint32_t i = bufs_num; i > 0; i--) {
327 uint32_t bsz = buf_sz[i - 1];
328 const uint8_t *cur_buf = &bufs[i - 1][bsz];
329 uint32_t bytes_to_cache;
333 if ((cached_bytes + bsz) <
sizeof(uint32_t))
334 bytes_to_cache = bsz;
336 bytes_to_cache =
sizeof(uint32_t) - cached_bytes;
337 memcpy(&cached_data8[
sizeof(uint32_t) - cached_bytes - bytes_to_cache],
338 cur_buf - bytes_to_cache,
341 cached_bytes += bytes_to_cache;
342 if (cached_bytes <
sizeof(uint32_t))
347 bsz -= bytes_to_cache;
348 cur_buf -= bytes_to_cache;
349 memset(cached_data8, 0x00,
sizeof(cached_data8));
353 for (
unsigned int k = bsz; k >=
sizeof(uint32_t); k -=
sizeof(uint32_t)) {
358 cur_buf -=
sizeof(uint32_t);
361 bytes_to_cache = bsz & 0x3UL;
362 if (bytes_to_cache > 0) {
363 if (bytes_to_cache + cached_bytes >=
sizeof(uint32_t)) {
365 uint32_t to_copy =
sizeof(uint32_t) - cached_bytes;
366 memcpy(&cached_data8[0], cur_buf - to_copy, to_copy);
373 memset(cached_data8, 0x00,
sizeof(cached_data8));
375 to_copy = bytes_to_cache + cached_bytes -
sizeof(uint32_t);
376 memcpy(&cached_data8[
sizeof(uint32_t) - to_copy], cur_buf - to_copy, to_copy);
377 cached_bytes = to_copy;
380 memcpy(&cached_data8[
sizeof(uint32_t) - cached_bytes - bytes_to_cache],
381 cur_buf - bytes_to_cache,
383 cached_bytes += bytes_to_cache;
391 uint32_t buf_sz[],
const uint8_t *bufs[])
394 uint32_t cached_bytes = 0;
395 uint8_t cached_data8[4] = { 0 };
396 uint32_t cached_data32 = 0;
403 for (
unsigned int i = 0; i < bufs_num; i++) {
404 uint32_t bsz = buf_sz[i];
405 const uint8_t *cur_buf = bufs[i];
406 uint32_t bytes_to_cache;
410 if ((cached_bytes + bsz) <
sizeof(uint32_t))
411 bytes_to_cache = bsz;
413 bytes_to_cache =
sizeof(uint32_t) - cached_bytes;
414 memcpy(&cached_data8[cached_bytes], cur_buf, bytes_to_cache);
415 cached_bytes += bytes_to_cache;
416 if (cached_bytes <
sizeof(uint32_t))
422 bsz -= bytes_to_cache;
423 cur_buf += bytes_to_cache;
424 memset(cached_data8, 0x00,
sizeof(cached_data8));
428 for (
unsigned int k = 0; (k +
sizeof(uint32_t)) <= bsz; k +=
sizeof(uint32_t)) {
433 cur_buf +=
sizeof(uint32_t);
436 bytes_to_cache = bsz & 0x3UL;
437 if (bytes_to_cache > 0) {
438 if (bytes_to_cache + cached_bytes >=
sizeof(uint32_t)) {
439 memcpy(&cached_data8[0], cur_buf,
sizeof(uint32_t) - cached_bytes);
446 memset(cached_data8, 0x00,
sizeof(cached_data8));
447 cur_buf +=
sizeof(uint32_t) - cached_bytes;
448 cached_bytes = bytes_to_cache + cached_bytes -
sizeof(uint32_t);
449 memcpy(&cached_data8[0], cur_buf, cached_bytes);
451 memcpy(&cached_data8[cached_bytes], cur_buf, bytes_to_cache);
452 cached_bytes += bytes_to_cache;
469 const uint8_t *bufs[],
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.
int esp_apptrace_usr_block_write(const struct esp32_apptrace_hw *hw, struct target *target, uint32_t block_id, const uint8_t *data, uint32_t size)
#define XTENSA_APPTRACE_STAT_REG
#define XTENSA_APPTRACE_BLOCK_LEN(_l_)
int esp_xtensa_apptrace_data_read(struct target *target, uint32_t size, uint8_t *buffer, uint32_t block_id, bool ack)
static int esp_xtensa_apptrace_leave_crit_section_stop(struct target *target)
int esp_xtensa_apptrace_status_reg_write(struct target *target, uint32_t stat)
int esp_xtensa_apptrace_data_len_read(struct target *target, uint32_t *block_id, uint32_t *len)
#define XTENSA_APPTRACE_HOST_DATA
int esp_xtensa_apptrace_status_reg_read(struct target *target, uint32_t *stat)
static int esp_xtensa_apptrace_queue_reverse_write(struct target *target, uint32_t bufs_num, uint32_t buf_sz[], const uint8_t *bufs[])
uint32_t esp_xtensa_apptrace_usr_block_max_size_get(struct target *target)
#define XTENSA_APPTRACE_HOST_CONNECT
#define XTENSA_APPTRACE_BLOCK_LEN_GET(_v_)
struct esp32_apptrace_hw esp_xtensa_apptrace_hw
static int esp_xtensa_apptrace_buffs_write(struct target *target, uint32_t bufs_num, uint32_t buf_sz[], const uint8_t *bufs[], uint32_t block_id, bool ack, bool data)
static int esp_xtensa_apptrace_data_reverse_read(struct xtensa *xtensa, uint32_t size, uint8_t *buffer, uint8_t *unal_bytes)
#define XTENSA_APPTRACE_BLOCK_ID_GET(_v_)
static int esp_xtensa_apptrace_queue_normal_write(struct target *target, uint32_t bufs_num, uint32_t buf_sz[], const uint8_t *bufs[])
int esp_xtensa_apptrace_ctrl_reg_read(struct target *target, uint32_t *block_id, uint32_t *len, bool *conn)
int esp_xtensa_apptrace_ctrl_reg_write(struct target *target, uint32_t block_id, uint32_t len, bool conn, bool data)
static int esp_xtensa_swdbg_activate(struct target *target, int enab)
#define XTENSA_APPTRACE_BLOCK_ID_MAX
uint32_t esp_xtensa_apptrace_block_max_size_get(struct target *target)
int esp_xtensa_apptrace_usr_block_write(struct target *target, uint32_t block_id, const uint8_t *data, uint32_t size)
#define XTENSA_APPTRACE_CTRL_REG
static int esp_xtensa_apptrace_data_normal_read(struct xtensa *xtensa, uint32_t size, uint8_t *buffer, uint8_t *unal_bytes)
static int esp_xtensa_apptrace_leave_crit_section_start(struct target *target)
#define XTENSA_APPTRACE_BLOCK_ID(_id_)
static struct jaylink_connection conn
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
size_t size
Size of the control block search area.
struct xtensa_tracing_config trace
Represents a generic Xtensa core.
struct xtensa_debug_module dbg_mod
struct xtensa_config * core_config
uint32_t target_buffer_get_u32(struct target *target, const uint8_t *buffer)
static const char * target_name(const struct target *target)
Returns the instance-specific name of the specified target.
Holds the interface to Xtensa cores.
static struct xtensa * target_to_xtensa(struct target *target)
static int xtensa_queue_dbg_reg_write(struct xtensa *xtensa, enum xtensa_dm_reg reg, uint32_t data)
static int xtensa_queue_dbg_reg_read(struct xtensa *xtensa, enum xtensa_dm_reg reg, uint8_t *data)
int xtensa_dm_trace_status_read(struct xtensa_debug_module *dm, struct xtensa_trace_status *status)
int xtensa_dm_trace_config_read(struct xtensa_debug_module *dm, struct xtensa_trace_config *config)
static void xtensa_dm_queue_tdi_idle(struct xtensa_debug_module *dm)
#define OCDDCR_DEBUGSWACTIVE
static int xtensa_dm_queue_execute(struct xtensa_debug_module *dm)