25 #define XT_NIBSWAP8(V) \
26 ((((V) & 0x0F) << 4) \
27 | (((V) & 0xF0) >> 4))
29 #define XT_NIBSWAP16(V) \
30 ((((V) & 0x000F) << 12) \
31 | (((V) & 0x00F0) << 4) \
32 | (((V) & 0x0F00) >> 4) \
33 | (((V) & 0xF000) >> 12))
35 #define XT_NIBSWAP24(V) \
36 ((((V) & 0x00000F) << 20) \
37 | (((V) & 0x0000F0) << 12) \
38 | (((V) & 0x000F00) << 4) \
39 | (((V) & 0x00F000) >> 4) \
40 | (((V) & 0x0F0000) >> 12) \
41 | (((V) & 0xF00000) >> 20))
47 #define _XT_INS_FORMAT_RSR(X, OPCODE, SR, T) \
48 (XT_ISBE(X) ? (XT_NIBSWAP24(OPCODE) \
49 | (((T) & 0x0F) << 16) \
50 | (((SR) & 0xFF) << 8)) << 8 \
52 | (((SR) & 0xFF) << 8) \
53 | (((T) & 0x0F) << 4))
55 #define _XT_INS_FORMAT_RRR(X, OPCODE, ST, R) \
56 (XT_ISBE(X) ? (XT_NIBSWAP24(OPCODE) \
57 | ((XT_NIBSWAP8((ST) & 0xFF)) << 12) \
58 | (((R) & 0x0F) << 8)) << 8 \
60 | (((ST) & 0xFF) << 4) \
61 | (((R) & 0x0F) << 12))
63 #define _XT_INS_FORMAT_RRRN(X, OPCODE, S, T, IMM4) \
64 (XT_ISBE(X) ? (XT_NIBSWAP16(OPCODE) \
65 | (((T) & 0x0F) << 8) \
66 | (((S) & 0x0F) << 4) \
67 | ((IMM4) & 0x0F)) << 16 \
69 | (((T) & 0x0F) << 4) \
70 | (((S) & 0x0F) << 8) \
71 | (((IMM4) & 0x0F) << 12))
73 #define _XT_INS_FORMAT_RRI8(X, OPCODE, R, S, T, IMM8) \
74 (XT_ISBE(X) ? (XT_NIBSWAP24(OPCODE) \
75 | (((T) & 0x0F) << 16) \
76 | (((S) & 0x0F) << 12) \
77 | (((R) & 0x0F) << 8) \
78 | ((IMM8) & 0xFF)) << 8 \
80 | (((IMM8) & 0xFF) << 16) \
81 | (((R) & 0x0F) << 12) \
82 | (((S) & 0x0F) << 8) \
83 | (((T) & 0x0F) << 4))
85 #define _XT_INS_FORMAT_RRI4(X, OPCODE, IMM4, R, S, T) \
86 (XT_ISBE(X) ? (XT_NIBSWAP24(OPCODE) \
87 | (((T) & 0x0F) << 16) \
88 | (((S) & 0x0F) << 12) \
89 | (((R) & 0x0F) << 8)) << 8 \
92 | (((IMM4) & 0x0F) << 20) \
93 | (((R) & 0x0F) << 12) \
94 | (((S) & 0x0F) << 8) \
95 | (((T) & 0x0F) << 4))
100 #define XT_INS_RFDO(X) (XT_ISBE(X) ? 0x000e1f << 8 : 0xf1e000)
102 #define XT_INS_RFDD(X) (XT_ISBE(X) ? 0x010e1f << 8 : 0xf1e010)
105 #define XT_INS_LDDR32P(X, S) (XT_ISBE(X) ? (0x0E0700 | ((S) << 12)) << 8 : (0x0070E0 | ((S) << 8)))
107 #define XT_INS_SDDR32P(X, S) (XT_ISBE(X) ? (0x0F0700 | ((S) << 12)) << 8 : (0x0070F0 | ((S) << 8)))
110 #define XT_INS_L32I(X, S, T, IMM8) _XT_INS_FORMAT_RRI8(X, 0x002002, 0, S, T, IMM8)
112 #define XT_INS_L16UI(X, S, T, IMM8) _XT_INS_FORMAT_RRI8(X, 0x001002, 0, S, T, IMM8)
114 #define XT_INS_L8UI(X, S, T, IMM8) _XT_INS_FORMAT_RRI8(X, 0x000002, 0, S, T, IMM8)
117 #define XT_INS_S32I(X, S, T, IMM8) _XT_INS_FORMAT_RRI8(X, 0x006002, 0, S, T, IMM8)
119 #define XT_INS_S16I(X, S, T, IMM8) _XT_INS_FORMAT_RRI8(X, 0x005002, 0, S, T, IMM8)
121 #define XT_INS_S8I(X, S, T, IMM8) _XT_INS_FORMAT_RRI8(X, 0x004002, 0, S, T, IMM8)
124 #define XT_INS_IHI(X, S, IMM8) _XT_INS_FORMAT_RRI8(X, 0x0070E2, 0, S, 0, IMM8)
125 #define XT_INS_DHWBI(X, S, IMM8) _XT_INS_FORMAT_RRI8(X, 0x007052, 0, S, 0, IMM8)
126 #define XT_INS_DHWB(X, S, IMM8) _XT_INS_FORMAT_RRI8(X, 0x007042, 0, S, 0, IMM8)
127 #define XT_INS_ISYNC(X) (XT_ISBE(X) ? 0x000200 << 8 : 0x002000)
130 #define XT_INS_JX(X, S) (XT_ISBE(X) ? (0x050000 | ((S) << 12)) : (0x0000a0 | ((S) << 8)))
131 #define XT_INS_CALL0(X, IMM18) (XT_ISBE(X) ? (0x500000 | ((IMM18) & 0x3ffff)) : (0x000005 | (((IMM18) & 0x3ffff) << 6)))
134 #define XT_INS_RSR(X, SR, T) _XT_INS_FORMAT_RSR(X, 0x030000, SR, T)
136 #define XT_INS_WSR(X, SR, T) _XT_INS_FORMAT_RSR(X, 0x130000, SR, T)
138 #define XT_INS_XSR(X, SR, T) _XT_INS_FORMAT_RSR(X, 0x610000, SR, T)
141 #define XT_INS_ROTW(X, N) (XT_ISBE(X) ? ((0x000804) | (((N) & 15) << 16)) << 8 : ((0x408000) | (((N) & 15) << 4)))
144 #define XT_INS_RUR(X, UR, T) _XT_INS_FORMAT_RRR(X, 0xE30000, UR, T)
146 #define XT_INS_WUR(X, UR, T) _XT_INS_FORMAT_RSR(X, 0xF30000, UR, T)
149 #define XT_INS_RFR(X, FR, T) _XT_INS_FORMAT_RRR(X, 0xFA0000, ((FR << 4) | 0x4), T)
151 #define XT_INS_WFR(X, FR, T) _XT_INS_FORMAT_RRR(X, 0xFA0000, ((T << 4) | 0x5), FR)
153 #define XT_INS_L32E(X, R, S, T) _XT_INS_FORMAT_RRI4(X, 0x090000, 0, R, S, T)
154 #define XT_INS_S32E(X, R, S, T) _XT_INS_FORMAT_RRI4(X, 0x490000, 0, R, S, T)
155 #define XT_INS_L32E_S32E_MASK(X) (XT_ISBE(X) ? 0xF000FF << 8 : 0xFF000F)
157 #define XT_INS_RFWO(X) (XT_ISBE(X) ? 0x004300 << 8 : 0x003400)
158 #define XT_INS_RFWU(X) (XT_ISBE(X) ? 0x005300 << 8 : 0x003500)
159 #define XT_INS_RFWO_RFWU_MASK(X) (XT_ISBE(X) ? 0xFFFFFF << 8 : 0xFFFFFF)
162 #define XT_INS_PPTLB(X, S, T) _XT_INS_FORMAT_RRR(X, 0x500000, ((S) << 4) | (T), 0xD)
164 #define XT_TLB1_ACC_SHIFT 8
165 #define XT_TLB1_ACC_MSK 0xF
167 #define XT_WATCHPOINTS_NUM_MAX 2
172 #define XT_SR_DDR (xtensa_regs[XT_REG_IDX_DDR].reg_num)
173 #define XT_SR_PS (xtensa_regs[XT_REG_IDX_PS].reg_num)
174 #define XT_SR_WB (xtensa_regs[XT_REG_IDX_WINDOWBASE].reg_num)
175 #define XT_REG_A0 (xtensa_regs[XT_REG_IDX_AR0].reg_num)
176 #define XT_REG_A3 (xtensa_regs[XT_REG_IDX_AR3].reg_num)
177 #define XT_REG_A4 (xtensa_regs[XT_REG_IDX_AR4].reg_num)
179 #define XT_PS_REG_NUM (0xe6U)
180 #define XT_EPS_REG_NUM_BASE (0xc0U)
181 #define XT_EPC_REG_NUM_BASE (0xb0U)
182 #define XT_PC_REG_NUM_VIRTUAL (0xffU)
183 #define XT_PC_DBREG_NUM_BASE (0x20U)
184 #define XT_NX_IBREAKC_BASE (0xc0U)
186 #define XT_SW_BREAKPOINTS_MAX_NUM 32
187 #define XT_HW_IBREAK_MAX_NUM 2
188 #define XT_HW_DBREAK_MAX_NUM 2
378 for (
unsigned int i = 0; i < mem->
count; i++) {
380 if (address >= region->
base && address < (region->
base + region->
size))
440 if (strncmp(
reg->
name,
"?0x", 3) == 0) {
441 unsigned int regnum = strtoul(
reg->
name + 1,
NULL, 0);
442 LOG_WARNING(
"Read unknown register 0x%04x ignored", regnum);
455 assert(
reg->
size <= 64 &&
"up to 64-bit regs are supported only!");
460 if (strncmp(
reg->
name,
"?0x", 3) == 0) {
461 unsigned int regnum = strtoul(
reg->
name + 1,
NULL, 0);
462 LOG_WARNING(
"Write unknown register 0x%04x ignored", regnum);
476 LOG_DEBUG(
"scratch_ars mapping: a3/%s, a4/%s",
506 LOG_ERROR(
"Error: can't convert register %d to non-windowbased register!", reg_idx);
524 reg_list[reg_idx].
dirty =
true;
534 const int max_oplen = 64;
535 if ((oplen > 0) && (oplen <= max_oplen)) {
536 uint8_t ops_padded[max_oplen];
537 memcpy(ops_padded, ops, oplen);
538 memset(ops_padded + oplen, 0, max_oplen - oplen);
539 unsigned int oplenw =
DIV_ROUND_UP(oplen,
sizeof(uint32_t));
540 for (int32_t i = oplenw - 1; i > 0; i--)
559 for (
int i = 0; i <= 1; i++) {
611 (woe_sr ==
XT_SR_PS) ?
"PS" :
"WB", res);
618 (woe_sr ==
XT_SR_PS) ?
"PS.WOE" :
"WB.S", *woe, woe_dis);
637 (woe_sr ==
XT_SR_PS) ?
"PS.WOE" :
"WB", woe);
668 bool scratch_reg_dirty =
false, delay_cpenable =
false;
671 bool preserve_a3 =
false;
677 bool restore_ms =
false;
683 for (
unsigned int i = 0; i < reg_list_size; i++) {
686 if (reg_list[i].dirty) {
690 scratch_reg_dirty =
true;
692 delay_cpenable =
true;
702 if (reg_list[i].
exist) {
718 }
else if (i == ms_idx) {
730 reg_list[i].
dirty =
false;
734 if (scratch_reg_dirty)
736 if (delay_cpenable) {
777 if (reg_list[i].dirty && reg_list[j].dirty) {
778 if (memcmp(reg_list[i].value, reg_list[j].value,
sizeof(
xtensa_reg_val_t)) != 0) {
779 bool show_warning =
true;
788 "Warning: Both A%d [0x%08" PRIx32
789 "] as well as its underlying physical register "
790 "(AR%d) [0x%08" PRIx32
"] are dirty and differ in value",
801 for (
unsigned int i = 0; i < 16; i++) {
822 for (
unsigned int i = 0; i < 16; i++) {
823 if (i + j < xtensa->core_config->aregs_num) {
828 if (reg_list[realadr].dirty) {
832 "Writing back reg %s value %08" PRIX32
", num =%i",
840 reg_list[realadr].
dirty =
false;
894 LOG_ERROR(
"XTensa core not configured; is xtensa-core-openocd.cfg missing?");
931 uint32_t dsr_data = 0x00110000;
958 uint8_t dcr_buf[
sizeof(uint32_t)];
1020 int res, needclear = 0, needimprclear = 0;
1033 "DSR (%08" PRIX32
") indicates DIR instruction generated an exception!",
1040 "DSR (%08" PRIX32
") indicates DIR instruction generated an overrun!",
1216 unsigned int ms_idx = reg_list_size;
1219 uint8_t a0_buf[4], a3_buf[4], ms_buf[4];
1260 goto xtensa_fetch_all_regs_done;
1269 for (
unsigned int i = 0; i < 16; i++) {
1270 if (i + j < xtensa->core_config->aregs_num) {
1298 LOG_ERROR(
"Failed to read ARs (%d)!", res);
1299 goto xtensa_fetch_all_regs_done;
1323 for (
unsigned int i = 0; i < reg_list_size; i++) {
1327 bool reg_fetched =
true;
1329 switch (rlist[ridx].
type) {
1348 reg_fetched =
false;
1357 reg_fetched =
false;
1364 reg_fetched =
false;
1378 goto xtensa_fetch_all_regs_done;
1384 for (
unsigned int i = 0; i < reg_list_size; i++) {
1395 goto xtensa_fetch_all_regs_done;
1405 windowbase =
buf_get_u32(regvals[wb_idx].buf, 0, 32);
1411 for (
unsigned int i = 0; i < reg_list_size; i++) {
1421 buf_cpy(regvals[realadr].buf, reg_list[i].value, reg_list[i].
size);
1432 LOG_INFO(
"Register %s: 0x%X", reg_list[i].
name, regval);
1438 }
else if (i == ms_idx) {
1444 reg_list[i].
dirty = is_dirty;
1446 reg_list[i].
valid =
true;
1450 reg_list[i].
valid =
true;
1453 reg_list[i].
valid =
false;
1483 xtensa_fetch_all_regs_done:
1490 struct reg **reg_list[],
1495 unsigned int num_regs;
1499 LOG_ERROR(
"reg_class %d unhandled; 'xtgregs' not found", reg_class);
1508 LOG_DEBUG(
"reg_class=%i, num_regs=%d", (
int)reg_class, num_regs);
1510 *reg_list = calloc(num_regs,
sizeof(
struct reg *));
1514 *reg_list_size = num_regs;
1516 assert((num_regs <= xtensa->
total_regs_num) &&
"contiguous regmap size internal error!");
1517 for (
unsigned int i = 0; i < num_regs; i++)
1522 for (
unsigned int i = 0; i < num_regs; i++)
1532 LOG_ERROR(
"eps_dbglevel_idx not set\n");
1537 LOG_DEBUG(
"SPARSE GDB reg 0x%x getting EPS%d 0x%x",
1553 LOG_ERROR(
"SPARSE GDB reg list full (size %d)", k);
1596 int handle_breakpoints,
1597 int debug_execution)
1603 "current=%d address=" TARGET_ADDR_FMT ", handle_breakpoints=%i, debug_execution=%i)",
1615 if (address && !current) {
1676 int handle_breakpoints,
1677 int debug_execution)
1692 if (!debug_execution)
1726 const uint32_t icount_val = -2;
1730 bool ps_lowered =
false;
1733 current, address, handle_breakpoints);
1751 LOG_TARGET_DEBUG(
target,
"oldps=%" PRIx32
", oldpc=%" PRIx32
" dbg_cause=%" PRIx32
" exc_cause=%" PRIx32,
1789 "disabling IRQs while stepping is not implemented w/o high prio IRQs option!");
1804 "Single-stepping to get past instruction that triggered the watchpoint...");
1819 uint32_t newps = (oldps & ~0xf) | (icountlvl - 1);
1822 "Lowering PS.INTLEVEL to allow stepping: %s <- 0x%08" PRIx32
" (was 0x%08" PRIx32
")",
1869 "Timed out waiting for target to finish stepping. dsr=0x%08" PRIx32,
1880 "cur_ps=%" PRIx32
", cur_pc=%" PRIx32
" dbg_cause=%" PRIx32
" exc_cause=%" PRIx32,
1893 LOG_DEBUG(
"Stepping out of window exception, PC=%" PRIX32, cur_pc);
1895 address = oldpc + 3;
1899 if (oldpc == cur_pc)
1903 LOG_DEBUG(
"Stepped from %" PRIX32
" to %" PRIX32, oldpc, cur_pc);
1909 LOG_DEBUG(
"Done stepping, PC=%" PRIX32, cur_pc);
1920 LOG_DEBUG(
"Restoring %s after stepping: 0x%08" PRIx32,
1952 if ((r2_start >= r1_start) && (r2_start < r1_end))
1954 if ((r2_end > r1_start) && (r2_end <= r1_end))
1968 target_addr_t ov_start = r1_start < r2_start ? r2_start : r1_start;
1970 return ov_end - ov_start;
1985 while (adr_pos < adr_end) {
1992 assert(overlap_size != 0);
1993 adr_pos += overlap_size;
2022 unsigned int alloc_bytes =
ALIGN_UP(addrend_al - addrstart_al,
sizeof(uint32_t));
2023 albuff = calloc(alloc_bytes, 1);
2026 addrend_al - addrstart_al);
2038 for (
unsigned int i = 0; adr != addrend_al; i +=
sizeof(uint32_t), adr +=
sizeof(uint32_t))
2044 for (
unsigned int i = 0; adr != addrend_al; i +=
sizeof(uint32_t), adr +=
sizeof(uint32_t)) {
2075 buf_bswap32(albuff, albuff, addrend_al - addrstart_al);
2103 bool fill_head_tail =
false;
2121 if (addrstart_al == address && addrend_al == address + (
size *
count)) {
2124 albuff = malloc(addrend_al - addrstart_al);
2127 albuff = (uint8_t *)
buffer;
2129 fill_head_tail =
true;
2130 albuff = malloc(addrend_al - addrstart_al);
2134 addrend_al - addrstart_al);
2142 if (fill_head_tail) {
2165 &albuff[addrend_al - addrstart_al - 4]);
2170 LOG_ERROR(
"Error issuing unaligned memory write context instruction(s): %d", res);
2177 bool swapped_w0 =
false;
2183 if ((addrend_al - addrstart_al - 4 == 0) && swapped_w0) {
2186 buf_bswap32(&albuff[addrend_al - addrstart_al - 4],
2187 &albuff[addrend_al - addrstart_al - 4], 4);
2197 buf_bswap32(albuff, fill_head_tail ? albuff :
buffer, addrend_al - addrstart_al);
2204 for (
unsigned int i = 0; adr != addrend_al; i +=
sizeof(uint32_t), adr +=
sizeof(uint32_t)) {
2214 for (
unsigned int i = 0; adr != addrend_al; i +=
sizeof(uint32_t), adr +=
sizeof(uint32_t)) {
2248 if (issue_ihi || issue_dhwbi) {
2251 uint32_t linesize =
MIN(ilinesize, dlinesize);
2255 while ((adr + off) < addrend_al) {
2277 "Error queuing cache writeback/invaldate instruction(s): %d",
2282 "Error issuing cache writeback/invaldate instruction(s): %d",
2342 "DSR has changed: was 0x%08" PRIx32
" now 0x%08" PRIx32,
2381 ", debug_reason=%08" PRIx32
", oldstate=%08" PRIx32,
2424 LOG_INFO(
"Detected end of trace.");
2446 unsigned int same_ic_line = ((address & (icache_line_size - 1)) +
size) <= icache_line_size;
2447 unsigned int same_dc_line = ((address & (dcache_line_size - 1)) +
size) <= dcache_line_size;
2450 if (
size > icache_line_size)
2453 if (issue_ihi || issue_dhwbi) {
2461 issue_ihi, issue_dhwbi, address);
2464 if (!same_dc_line) {
2473 if (!same_ic_line) {
2485 LOG_ERROR(
"Error issuing cache invaldate instruction(s): %d", ret);
2503 if (!same_dc_line) {
2669 " not supported by hardware.",
2677 dbreakcval |=
BIT(30);
2679 dbreakcval |=
BIT(31);
2681 dbreakcval |=
BIT(30) |
BIT(31);
2713 int num_mem_params,
struct mem_param *mem_params,
2714 int num_reg_params,
struct reg_param *reg_params,
2721 bool usr_ps =
false;
2737 if (!algorithm_info) {
2738 LOG_ERROR(
"BUG: arch_info not specified");
2749 for (
int i = 0; i < num_mem_params; i++) {
2753 mem_params[i].
value);
2759 for (
int i = 0; i < num_reg_params; i++) {
2760 if (reg_params[i].
size > 32) {
2761 LOG_ERROR(
"BUG: not supported register size (%d)", reg_params[i].
size);
2766 LOG_ERROR(
"BUG: register '%s' not found", reg_params[i].reg_name);
2770 LOG_ERROR(
"BUG: register '%s' size doesn't match reg_params[i].size", reg_params[i].reg_name);
2773 if (memcmp(reg_params[i].reg_name,
"ps", 3)) {
2777 assert(reg_id < xtensa->core_cache->num_regs &&
"Attempt to access non-existing reg!");
2804 int num_mem_params,
struct mem_param *mem_params,
2805 int num_reg_params,
struct reg_param *reg_params,
2833 if (exit_point && pc != exit_point) {
2838 for (
int i = 0; i < num_reg_params; i++) {
2842 LOG_ERROR(
"BUG: register '%s' not found", reg_params[i].reg_name);
2846 LOG_ERROR(
"BUG: register '%s' size doesn't match reg_params[i].size", reg_params[i].reg_name);
2854 for (
int i = 0; i < num_mem_params; i++) {
2874 LOG_DEBUG(
"Skip restoring register %s: 0x%8.8" PRIx32
" -> 0x%8.8" PRIx32,
2883 LOG_DEBUG(
"restoring register %s: 0x%8.8" PRIx32
" -> 0x%8.8" PRIx32,
2888 LOG_DEBUG(
"restoring register %s: 0x%8.8" PRIx64
" -> 0x%8.8" PRIx64,
2906 LOG_ERROR(
"Failed to write dirty regs (%d)!", retval);
2912 int num_mem_params,
struct mem_param *mem_params,
2913 int num_reg_params,
struct reg_param *reg_params,
2915 unsigned int timeout_ms,
void *
arch_info)
2918 num_mem_params, mem_params,
2919 num_reg_params, reg_params,
2920 entry_point, exit_point,
2925 num_mem_params, mem_params,
2926 num_reg_params, reg_params,
2927 exit_point, timeout_ms,
2938 unsigned int last_dbreg_num = 0;
2947 LOG_ERROR(
"Failed to alloc reg cache!");
2954 struct reg *reg_list = calloc(reg_list_size,
sizeof(
struct reg));
2960 unsigned int didx = 0;
2961 for (
unsigned int whichlist = 0; whichlist < 2; whichlist++) {
2964 for (
unsigned int i = 0; i < listsize; i++, didx++) {
2966 reg_list[didx].
name = rlist[i].
name;
2967 reg_list[didx].
size = 32;
2968 reg_list[didx].
value = calloc(1, 4 );
2969 if (!reg_list[didx].value) {
2970 LOG_ERROR(
"Failed to alloc reg list value!");
2973 reg_list[didx].
dirty =
false;
2974 reg_list[didx].
valid =
false;
2982 "POPULATE %-16s list %d exist %d, idx %d, type %d, dbreg_num 0x%04x",
2983 reg_list[didx].
name,
2985 reg_list[didx].
exist,
3017 LOG_ERROR(
"Failed to alloc empty reg list value!");
3042 "POPULATE contiguous regs list: %-16s, dbreg_num 0x%04x",
3056 LOG_ERROR(
"Failed to alloc mem for algorithm context backup!");
3063 LOG_ERROR(
"Failed to alloc mem for algorithm context!");
3074 for (
unsigned int i = 0; i < reg_list_size; i++)
3075 free(reg_list[i].
value);
3100 while (opstr && (*opstr ==
':')) {
3102 unsigned int oplen = strtoul(opstr + 1, &opstr, 16);
3108 while ((i < oplen) && opstr && (*opstr ==
':'))
3109 ops[i++] = strtoul(opstr + 1, &opstr, 16);
3116 sprintf(insn_buf,
"Exec %d-byte TIE sequence: ", oplen);
3117 for (i = 0; i < oplen; i++)
3118 sprintf(insn_buf + strlen(insn_buf),
"%02x:", ops[i]);
3129 bool iswrite = (packet[0] ==
'Q');
3137 LOG_ERROR(
"Spill location not specified. Try 'target remote <host>:3333 &spill_location0'");
3139 goto xtensa_gdbqc_qxtreg_fail;
3143 uint32_t regnum = strtoul(packet + 6, &delim, 16);
3144 if (*delim !=
':') {
3147 goto xtensa_gdbqc_qxtreg_fail;
3149 uint32_t reglen = strtoul(delim + 1, &delim, 16);
3150 if (*delim !=
':') {
3153 goto xtensa_gdbqc_qxtreg_fail;
3157 LOG_DEBUG(
"TIE reg 0x%08" PRIx32
" %s (%d bytes)", regnum, iswrite ?
"write" :
"read", reglen);
3161 goto xtensa_gdbqc_qxtreg_fail;
3174 goto xtensa_gdbqc_qxtreg_fail;
3179 char *valbuf = strchr(delim,
'=');
3180 if (!(valbuf && (*valbuf ==
'='))) {
3183 goto xtensa_gdbqc_qxtreg_fail;
3186 while (*valbuf && *(valbuf + 1)) {
3187 char bytestr[3] = { 0, 0, 0 };
3188 strncpy(bytestr, valbuf, 2);
3189 regbuf[b++] = strtoul(bytestr,
NULL, 16);
3195 goto xtensa_gdbqc_qxtreg_fail;
3198 reglen / memop_size, regbuf);
3202 goto xtensa_gdbqc_qxtreg_fail;
3228 strcpy(*response_p,
"OK");
3237 for (i = 0; i < reglen; i++)
3238 sprintf(*response_p + 2 * i,
"%02x", regbuf[i]);
3239 *(*response_p + 2 * i) =
'\0';
3250 goto xtensa_gdbqc_qxtreg_fail;
3255 goto xtensa_gdbqc_qxtreg_fail;
3259 xtensa_gdbqc_qxtreg_fail:
3260 strcpy(*response_p,
xt_qerr[error].chrval);
3268 if (!packet || !response_p) {
3274 if (strncmp(packet,
"qxtn", 4) == 0) {
3275 strcpy(*response_p,
"OpenOCD");
3277 }
else if (strncasecmp(packet,
"qxtgdbversion=", 14) == 0) {
3279 }
else if ((strncmp(packet,
"Qxtsis=", 7) == 0) || (strncmp(packet,
"Qxtsds=", 7) == 0)) {
3291 strcpy(*response_p,
"OK");
3293 }
else if ((strncmp(packet,
"Qxtiram=", 8) == 0) || (strncmp(packet,
"Qxtirom=", 8) == 0)) {
3297 unsigned int base = 0,
size = 0, i;
3298 char *pkt = (
char *)&packet[7];
3301 size = strtoul(pkt, &pkt, 16);
3303 base = strtoul(pkt, &pkt, 16);
3305 for (i = 0; i < memp->
count; i++) {
3309 if (i == memp->
count) {
3314 for (i = 0; i < 11; i++) {
3316 strtoul(pkt, &pkt, 16);
3318 }
while (pkt && (pkt[0] ==
','));
3319 strcpy(*response_p,
"OK");
3321 }
else if (strncmp(packet,
"Qxtexcmlvl=", 11) == 0) {
3323 unsigned int excm_level = strtoul(&packet[11],
NULL, 0);
3327 strcpy(*response_p,
"OK");
3329 }
else if ((strncmp(packet,
"Qxtl2cs=", 8) == 0) ||
3330 (strncmp(packet,
"Qxtl2ca=", 8) == 0) ||
3331 (strncmp(packet,
"Qxtdensity=", 11) == 0)) {
3332 strcpy(*response_p,
"OK");
3334 }
else if (strncmp(packet,
"Qxtspill=", 9) == 0) {
3336 uint32_t spill_loc = strtoul(packet + 9, &delim, 16);
3337 if (*delim !=
':') {
3340 goto xtensa_gdb_query_custom_fail;
3350 goto xtensa_gdb_query_custom_fail;
3353 strcpy(*response_p,
"OK");
3355 }
else if (strncasecmp(packet,
"qxtreg", 6) == 0) {
3357 }
else if ((strncmp(packet,
"qTStatus", 8) == 0) ||
3358 (strncmp(packet,
"qxtftie", 7) == 0) ||
3359 (strncmp(packet,
"qxtstie", 7) == 0)) {
3361 strcpy(*response_p,
"");
3367 strcpy(*response_p,
"");
3370 xtensa_gdb_query_custom_fail:
3371 strcpy(*response_p,
xt_qerr[error].chrval);
3385 LOG_ERROR(
"Xtensa configuration alloc failed\n");
3402 LOG_ERROR(
"Xtensa scratch AR alloc failed\n");
3426 LOG_ERROR(
"Failed to alloc memory for HW breakpoints!");
3432 LOG_ERROR(
"Failed to alloc memory for HW watchpoints!");
3439 LOG_ERROR(
"Failed to alloc memory for SW breakpoints!");
3458 for (
unsigned int i = 0; i < cache->
num_regs; i++) {
3494 LOG_ERROR(
"Failed to queue OCDDCR_ENABLEOCD clear operation!");
3500 LOG_ERROR(
"Failed to clear OCDDCR_ENABLEOCD!");
3533 unsigned int parm_len = strlen(parm);
3534 if ((parm_len >= 64) || (parm_len & 1)) {
3535 command_print(
CMD,
"Invalid parameter length (%d): must be even, < 64 characters", parm_len);
3541 unsigned int oplen = parm_len / 2;
3542 char encoded_byte[3] = { 0, 0, 0 };
3543 for (
unsigned int i = 0; i < oplen; i++) {
3544 encoded_byte[0] = *parm++;
3545 encoded_byte[1] = *parm++;
3546 ops[i] = strtoul(encoded_byte,
NULL, 16);
3604 const char *core_name =
CMD_ARGV[0];
3605 if (strcasecmp(core_name,
"LX") == 0) {
3607 }
else if (strcasecmp(core_name,
"NX") == 0) {
3624 if ((val < min) || (val > max)) {
3625 LOG_ERROR(
"xtopt %s (%d) out of range [%d..%d]\n", opt, val, min, max);
3637 const char *opt_name =
CMD_ARGV[0];
3639 if (strcasecmp(opt_name,
"arnum") == 0) {
3643 }
else if (strcasecmp(opt_name,
"windowed") == 0) {
3647 }
else if (strcasecmp(opt_name,
"cpenable") == 0) {
3651 }
else if (strcasecmp(opt_name,
"exceptions") == 0) {
3655 }
else if (strcasecmp(opt_name,
"intnum") == 0) {
3660 }
else if (strcasecmp(opt_name,
"hipriints") == 0) {
3664 }
else if (strcasecmp(opt_name,
"excmlevel") == 0) {
3672 }
else if (strcasecmp(opt_name,
"intlevels") == 0) {
3685 }
else if (strcasecmp(opt_name,
"debuglevel") == 0) {
3695 }
else if (strcasecmp(opt_name,
"ibreaknum") == 0) {
3699 }
else if (strcasecmp(opt_name,
"dbreaknum") == 0) {
3703 }
else if (strcasecmp(opt_name,
"tracemem") == 0) {
3708 }
else if (strcasecmp(opt_name,
"tracememrev") == 0) {
3712 }
else if (strcasecmp(opt_name,
"perfcount") == 0) {
3736 bool is_dcache =
false;
3741 const char *mem_name =
CMD_ARGV[0];
3742 if (strcasecmp(mem_name,
"icache") == 0) {
3744 }
else if (strcasecmp(mem_name,
"dcache") == 0) {
3747 }
else if (strcasecmp(mem_name,
"l2cache") == 0) {
3749 }
else if (strcasecmp(mem_name,
"l2addr") == 0) {
3751 }
else if (strcasecmp(mem_name,
"iram") == 0) {
3754 }
else if (strcasecmp(mem_name,
"dram") == 0) {
3757 }
else if (strcasecmp(mem_name,
"sram") == 0) {
3760 }
else if (strcasecmp(mem_name,
"irom") == 0) {
3763 }
else if (strcasecmp(mem_name,
"drom") == 0) {
3766 }
else if (strcasecmp(mem_name,
"srom") == 0) {
3770 command_print(
CMD,
"xtmem types: <icache|dcache|l2cache|l2addr|iram|irom|dram|drom|sram|srom>\n");
3788 memcfgp->
access = mem_access;
3808 unsigned int minsegsize = strtoul(
CMD_ARGV[1],
NULL, 0);
3812 if ((nfgseg > 32)) {
3815 }
else if (minsegsize & (minsegsize - 1)) {
3818 }
else if (lockable > 1) {
3821 }
else if (execonly > 1) {
3846 unsigned int nirefillentries = strtoul(
CMD_ARGV[0],
NULL, 0);
3847 unsigned int ndrefillentries = strtoul(
CMD_ARGV[1],
NULL, 0);
3848 if ((nirefillentries != 16) && (nirefillentries != 32)) {
3851 }
else if ((ndrefillentries != 16) && (ndrefillentries != 32)) {
3874 if ((numregs <= 0) || (numregs > UINT16_MAX)) {
3879 command_print(
CMD,
"xtregs (%d) must be larger than numgenregs (%d) (if xtregfmt specified)",
3889 LOG_ERROR(
"Failed to allocate xtensa->optregs!");
3902 LOG_ERROR(
"Failed to allocate xtensa->contiguous_regs_desc!");
3909 if (regnum > UINT16_MAX) {
3916 command_print(
CMD,
"'xtreg %s 0x%04x': Too many registers (%d expected, %d core %d extended)",
3927 bool is_extended_reg =
true;
3934 is_extended_reg =
false;
3940 if (is_extended_reg) {
3970 if ((strcmp(rptr->
name,
"mmid") == 0) || (strcmp(rptr->
name,
"eraccess") == 0) ||
3971 (strcmp(rptr->
name,
"ddr") == 0) || (strncmp(rptr->
name,
"intset", 6) == 0) ||
3972 (strncmp(rptr->
name,
"intclear", 8) == 0) || (strcmp(rptr->
name,
"mesrclr") == 0))
3984 if (strcmp(rptr->
name,
"ibreakc0") == 0)
3986 else if (strcmp(rptr->
name,
"wb") == 0)
3988 else if (strcmp(rptr->
name,
"ms") == 0)
3990 else if (strcmp(rptr->
name,
"ievec") == 0)
3992 else if (strcmp(rptr->
name,
"ieextern") == 0)
3994 else if (strcmp(rptr->
name,
"mesr") == 0)
3996 else if (strcmp(rptr->
name,
"mesrclr") == 0)
4009 }
else if (strcmp(rptr->
name,
"cpenable") == 0) {
4016 assert((running_reg_count <= xtensa->total_regs_num) &&
"contiguous register address internal error!");
4020 LOG_DEBUG(
"Added %s register %-16s: 0x%04x/0x%02x t%d (%d of %d)",
4021 is_extended_reg ?
"config-specific" :
"core",
4038 if (!strcasecmp(
CMD_ARGV[0],
"sparse")) {
4040 }
else if (!strcasecmp(
CMD_ARGV[0],
"contiguous")) {
4044 if ((numgregs <= 0) ||
4047 command_print(
CMD,
"xtregfmt: if specified, numgregs (%d) must be <= numregs (%d)",
4086 if (CMD_ARGC < 2 || CMD_ARGC > 6)
4089 unsigned int counter_id = strtoul(
CMD_ARGV[0],
NULL, 0);
4111 if (
config.kernelcnt > 1) {
4119 if (
config.tracelevel > 7) {
4125 if (
config.tracelevel == -1)
4143 int counter_id = -1;
4152 unsigned int counter_start = (counter_id < 0) ? 0 : counter_id;
4154 for (
unsigned int counter = counter_start; counter < counter_end; ++counter) {
4155 char result_buf[128] = { 0 };
4156 size_t result_pos = snprintf(result_buf,
sizeof(result_buf),
"Counter %d: ", counter);
4161 snprintf(result_buf + result_pos,
sizeof(result_buf) - result_pos,
4164 result.
overflow ?
" (overflow)" :
"");
4200 if (!strcasecmp(
CMD_ARGV[0],
"off"))
4202 else if (!strcasecmp(
CMD_ARGV[0],
"on"))
4225 for (
unsigned int i = 0; i <
CMD_ARGC; i++) {
4226 if (!strcasecmp(
CMD_ARGV[0],
"none")) {
4228 }
else if (!strcasecmp(
CMD_ARGV[i],
"BreakIn")) {
4230 }
else if (!strcasecmp(
CMD_ARGV[i],
"BreakOut")) {
4232 }
else if (!strcasecmp(
CMD_ARGV[i],
"RunStallIn")) {
4234 }
else if (!strcasecmp(
CMD_ARGV[i],
"DebugModeOut")) {
4236 }
else if (!strcasecmp(
CMD_ARGV[i],
"BreakInOut")) {
4238 }
else if (!strcasecmp(
CMD_ARGV[i],
"RunStall")) {
4244 "use either BreakInOut, None or RunStall as arguments, or any combination of BreakIn, BreakOut, RunStallIn and DebugModeOut.");
4312 .after_is_words =
false
4316 for (
unsigned int i = 0; i <
CMD_ARGC; i++) {
4327 }
else if (!strcasecmp(
CMD_ARGV[i],
"ins")) {
4329 }
else if (!strcasecmp(
CMD_ARGV[i],
"words")) {
4394 uint32_t memsz, wmem;
4416 if ((trace_config.
addr &
4425 command_print(
CMD,
"Real trace is many times longer than that (overflow)");
4429 command_print(
CMD,
"Real trace is %d words, but the start has been truncated.", trc_sz);
4433 uint8_t *tracemem = malloc(memsz * 4);
4444 int f = open(fname, O_WRONLY | O_CREAT | O_TRUNC, 0666);
4450 if (write(f, tracemem, memsz * 4) != (
int)memsz * 4)
4453 command_print(
CMD,
"Written %d bytes of trace data to %s", memsz * 4, fname);
4456 bool is_all_zeroes =
true;
4457 for (
unsigned int i = 0; i < memsz * 4; i++) {
4458 if (tracemem[i] != 0) {
4459 is_all_zeroes =
false;
4467 "WARNING: File written is all zeroes. Are you sure you enabled trace memory?");
4475 command_print(
CMD,
"Command takes exactly 1 parameter.Need filename to dump to as output!");
4486 .handler = xtensa_cmd_xtdef,
4488 .help =
"Configure Xtensa core type",
4493 .handler = xtensa_cmd_xtopt,
4495 .help =
"Configure Xtensa core option",
4496 .usage =
"<name> <value>",
4500 .handler = xtensa_cmd_xtmem,
4502 .help =
"Configure Xtensa memory/cache option",
4503 .usage =
"<type> [parameters]",
4507 .handler = xtensa_cmd_xtmmu,
4509 .help =
"Configure Xtensa MMU option",
4510 .usage =
"<NIREFILLENTRIES> <NDREFILLENTRIES> <IVARWAY56> <DVARWAY56>",
4514 .handler = xtensa_cmd_xtmpu,
4516 .help =
"Configure Xtensa MPU option",
4517 .usage =
"<num FG seg> <min seg size> <lockable> <executeonly>",
4521 .handler = xtensa_cmd_xtreg,
4523 .help =
"Configure Xtensa register",
4524 .usage =
"<regname> <regnum>",
4528 .handler = xtensa_cmd_xtreg,
4530 .help =
"Configure number of Xtensa registers",
4531 .usage =
"<numregs>",
4535 .handler = xtensa_cmd_xtregfmt,
4537 .help =
"Configure format of Xtensa register map",
4538 .usage =
"<contiguous|sparse> [numgregs]",
4541 .name =
"set_permissive",
4542 .handler = xtensa_cmd_permissive_mode,
4544 .help =
"When set to 1, enable Xtensa permissive mode (fewer client-side checks)",
4549 .handler = xtensa_cmd_mask_interrupts,
4551 .help =
"mask Xtensa interrupts at step",
4552 .usage =
"['on'|'off']",
4556 .handler = xtensa_cmd_smpbreak,
4558 .help =
"Set the way the CPU chains OCD breaks",
4559 .usage =
"[none|breakinout|runstall] | [BreakIn] [BreakOut] [RunStallIn] [DebugModeOut]",
4563 .handler = xtensa_cmd_dm_rw,
4565 .help =
"Xtensa DM read/write",
4566 .usage =
"addr [value]"
4569 .name =
"perfmon_enable",
4570 .handler = xtensa_cmd_perfmon_enable,
4572 .help =
"Enable and start performance counter",
4573 .usage =
"<counter_id> <select> [mask] [kernelcnt] [tracelevel]",
4576 .name =
"perfmon_dump",
4577 .handler = xtensa_cmd_perfmon_dump,
4579 .help =
"Dump performance counter value. If no argument specified, dumps all counters.",
4580 .usage =
"[counter_id]",
4583 .name =
"tracestart",
4584 .handler = xtensa_cmd_tracestart,
4587 "Tracing: Set up and start a trace. Optionally set stop trigger address and amount of data captured after.",
4588 .usage =
"[pc <pcval>/[maskbitcount]] [after <n> [ins|words]]",
4591 .name =
"tracestop",
4592 .handler = xtensa_cmd_tracestop,
4594 .help =
"Tracing: Stop current trace as started by the tracestart command",
4598 .name =
"tracedump",
4599 .handler = xtensa_cmd_tracedump,
4601 .help =
"Tracing: Dump trace memory to a files. One file per core.",
4602 .usage =
"<outfile>",
4606 .handler = xtensa_cmd_exe,
4608 .help =
"Xtensa stub execution",
4609 .usage =
"<ascii-encoded hexadecimal instruction bytes>",
4618 .help =
"Xtensa command group",
void * buf_cpy(const void *from, void *_to, unsigned int size)
Copies size bits out of from and into to.
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.
static void buf_set_u32(uint8_t *_buffer, unsigned int first, unsigned int num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
static uint64_t buf_get_u64(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 64-bit word.
#define WATCHPOINT_IGNORE_DATA_VALUE_MASK
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 CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#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 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.
#define ERROR_COMMAND_ARGUMENT_INVALID
static uint16_t direction
static struct device_config config
#define LOG_TARGET_INFO(target, fmt_str,...)
#define LOG_TARGET_WARNING(target, fmt_str,...)
#define LOG_WARNING(expr ...)
#define LOG_TARGET_ERROR(target, fmt_str,...)
#define LOG_TARGET_DEBUG(target, fmt_str,...)
#define LOG_ERROR(expr ...)
#define LOG_LEVEL_IS(FOO)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
struct reg * register_get_by_name(struct reg_cache *first, const char *name, bool search_all)
struct reg_cache ** register_get_last_cache_p(struct reg_cache **first)
void register_unlink_cache(struct reg_cache **cache_p, const struct reg_cache *cache)
void register_cache_invalidate(struct reg_cache *cache)
Marks the contents of the register cache as invalid (and clean).
target_addr_t addr
Start address to search for the control block.
size_t size
Size of the control block search area.
enum breakpoint_type type
int(* get)(struct reg *reg)
const struct reg_arch_type * type
enum target_debug_reason debug_reason
enum target_endianness endianness
struct reg_cache * reg_cache
bool examined
Indicates whether this target has been examined.
enum target_debug_reason ctx_debug_reason
Used internally to backup and restore core state.
enum xtensa_mode core_mode
User can set this to specify which core mode algorithm should be run in.
struct xtensa_cache_config dcache
struct xtensa_debug_config debug
struct xtensa_tracing_config trace
struct xtensa_local_mem_config irom
struct xtensa_local_mem_config drom
struct xtensa_mpu_config mpu
enum xtensa_type core_type
struct xtensa_cache_config icache
struct xtensa_local_mem_config iram
struct xtensa_high_prio_irq_config high_irq
struct xtensa_mmu_config mmu
struct xtensa_irq_config irq
struct xtensa_local_mem_config dram
struct xtensa_local_mem_config sram
struct xtensa_local_mem_config srom
struct xtensa_power_status power_status
const struct xtensa_power_ops * pwr_ops
struct xtensa_core_status core_status
struct xtensa_local_mem_region_config regions[XT_LOCAL_MEM_REGIONS_NUM_MAX]
uint8_t itlb_entries_count
uint8_t dtlb_entries_count
int(* queue_reg_write)(struct xtensa_debug_module *dm, enum xtensa_dm_pwr_reg reg, uint32_t data)
register write.
enum xtensa_reg_flags flags
enum xtensa_reg_type type
uint8_t insn[XT_ISNS_SZ_MAX]
struct breakpoint * oocd_bp
Represents a generic Xtensa core.
struct watchpoint ** hw_wps
uint8_t come_online_probes_num
struct xtensa_reg_desc ** contiguous_regs_desc
unsigned int total_regs_num
struct xtensa_debug_module dbg_mod
char qpkt_resp[XT_QUERYPKT_RESP_MAX]
struct reg ** contiguous_regs_list
unsigned int eps_dbglevel_idx
void ** algo_context_backup
struct xtensa_sw_breakpoint * sw_brps
unsigned int genpkt_regs_num
enum xtensa_stepping_isr_mode stepping_isr_mode
struct reg_cache * core_cache
unsigned int core_regs_num
struct xtensa_keyval_info scratch_ars[XT_AR_SCRATCH_NUM]
struct xtensa_reg_desc * optregs
uint32_t nx_reg_idx[XT_NX_REG_IDX_NUM]
struct breakpoint ** hw_brps
unsigned int common_magic
struct xtensa_config * core_config
int target_call_event_callbacks(struct target *target, enum target_event event)
int target_halt(struct target *target)
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
int target_wait_state(struct target *target, enum target_state state, unsigned int ms)
struct target * get_current_target(struct command_context *cmd_ctx)
uint32_t target_buffer_get_u32(struct target *target, const uint8_t *buffer)
#define ERROR_TARGET_NOT_HALTED
static bool target_was_examined(const struct target *target)
static const char * target_name(const struct target *target)
Returns the instance-specific name of the specified target.
#define ERROR_TARGET_NOT_EXAMINED
#define ERROR_TARGET_TIMEOUT
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
static void target_set_examined(struct target *target)
Sets the examined flag for the given target.
#define ERROR_TARGET_FAILURE
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
static void buf_bswap32(uint8_t *dst, const uint8_t *src, size_t len)
Byte-swap buffer 32-bit.
int xtensa_gdb_query_custom(struct target *target, const char *packet, char **response_p)
#define XT_INS_RSR(X, SR, T)
static int xtensa_core_reg_set(struct reg *reg, uint8_t *buf)
static bool xtensa_memory_op_validate_range(struct xtensa *xtensa, target_addr_t address, size_t size, int access)
Check if the address gets to memory regions, and its access mode.
void xtensa_reg_set_deep_relgen(struct target *target, enum xtensa_reg_id a_idx, xtensa_reg_val_t value)
static COMMAND_HELPER(xtensa_cmd_exe_do, struct target *target)
#define XT_INS_L32E(X, R, S, T)
static void xtensa_mark_register_dirty(struct xtensa *xtensa, enum xtensa_reg_id reg_idx)
#define XT_INS_SDDR32P(X, S)
static bool xtensa_reg_is_readable(int flags, int cpenable)
static enum xtensa_reg_id xtensa_canonical_to_windowbase_offset(struct xtensa *xtensa, enum xtensa_reg_id reg_idx, int windowbase)
#define XT_INS_IHI(X, S, IMM8)
int xtensa_breakpoint_add(struct target *target, struct breakpoint *breakpoint)
#define XT_HW_DBREAK_MAX_NUM
#define XT_WATCHPOINTS_NUM_MAX
void xtensa_target_deinit(struct target *target)
static const bool xtensa_extra_debug_log
int xtensa_watchpoint_add(struct target *target, struct watchpoint *watchpoint)
static int xtensa_queue_pwr_reg_write(struct xtensa *xtensa, unsigned int reg, uint32_t data)
static enum xtensa_reg_id xtensa_windowbase_offset_to_canonical(struct xtensa *xtensa, enum xtensa_reg_id reg_idx, int windowbase)
static bool xtensa_cmd_xtopt_legal_val(char *opt, int val, int min, int max)
#define XT_INS_WFR(X, FR, T)
const char * xtensa_get_gdb_arch(const struct target *target)
uint32_t xtensa_cause_get(struct target *target)
#define XT_INS_RUR(X, UR, T)
xtensa_mem_region_type
Types of memory used at xtensa target.
int xtensa_do_step(struct target *target, int current, target_addr_t address, int handle_breakpoints)
#define XT_INS_ROTW(X, N)
static bool xtensa_pc_in_winexc(struct target *target, target_addr_t pc)
int xtensa_smpbreak_read(struct xtensa *xtensa, uint32_t *val)
int xtensa_poll(struct target *target)
int xtensa_prepare_resume(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
#define XT_HW_IBREAK_MAX_NUM
int xtensa_halt(struct target *target)
static const struct command_registration xtensa_any_command_handlers[]
static void xtensa_reg_set_value(struct reg *reg, xtensa_reg_val_t value)
int xtensa_breakpoint_remove(struct target *target, struct breakpoint *breakpoint)
static bool xtensa_scratch_regs_fixup(struct xtensa *xtensa, struct reg *reg_list, int i, int j, int a_idx, int ar_idx)
int xtensa_read_buffer(struct target *target, target_addr_t address, uint32_t count, uint8_t *buffer)
int xtensa_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
int xtensa_step(struct target *target, int current, target_addr_t address, int handle_breakpoints)
int xtensa_target_init(struct command_context *cmd_ctx, struct target *target)
static bool xtensa_region_ar_exec(struct target *target, target_addr_t start, target_addr_t end)
int xtensa_checksum_memory(struct target *target, target_addr_t address, uint32_t count, uint32_t *checksum)
#define XT_TLB1_ACC_SHIFT
#define XT_SW_BREAKPOINTS_MAX_NUM
const struct command_registration xtensa_command_handlers[]
int xtensa_smpbreak_set(struct target *target, uint32_t set)
static bool xtensa_memory_regions_overlap(target_addr_t r1_start, target_addr_t r1_end, target_addr_t r2_start, target_addr_t r2_end)
Returns true if two ranges are overlapping.
int xtensa_examine(struct target *target)
static void xtensa_free_reg_cache(struct target *target)
int xtensa_start_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, target_addr_t entry_point, target_addr_t exit_point, void *arch_info)
int xtensa_init_arch_info(struct target *target, struct xtensa *xtensa, const struct xtensa_debug_module_config *dm_cfg)
int xtensa_fetch_all_regs(struct target *target)
#define XT_INS_CALL0(X, IMM18)
int xtensa_resume(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
#define XT_INS_L32E_S32E_MASK(X)
int xtensa_watchpoint_remove(struct target *target, struct watchpoint *watchpoint)
void xtensa_cause_reset(struct target *target)
int xtensa_write_buffer(struct target *target, target_addr_t address, uint32_t count, const uint8_t *buffer)
static void xtensa_window_state_restore(struct target *target, uint32_t woe)
xtensa_mpu_access_type
Types of access rights for MPU option The first block is kernel RWX ARs; the second block is user rwx...
static void xtensa_queue_exec_ins(struct xtensa *xtensa, uint32_t ins)
static bool xtensa_is_icacheable(struct xtensa *xtensa, target_addr_t address)
static int xtensa_window_state_save(struct target *target, uint32_t *woe)
static bool xtensa_is_cacheable(const struct xtensa_cache_config *cache, const struct xtensa_local_mem_config *mem, target_addr_t address)
int xtensa_smpbreak_write(struct xtensa *xtensa, uint32_t set)
int xtensa_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
static const struct xtensa_keyval_info xt_qerr[XT_QERR_NUM]
static int xtensa_imprecise_exception_occurred(struct target *target)
void xtensa_reg_set(struct target *target, enum xtensa_reg_id reg_id, xtensa_reg_val_t value)
void xtensa_cause_clear(struct target *target)
#define XT_INS_L32I(X, S, T, IMM8)
COMMAND_HANDLER(xtensa_cmd_exe)
int xtensa_smpbreak_get(struct target *target, uint32_t *val)
struct xtensa_reg_desc xtensa_regs[XT_NUM_REGS]
static int xtensa_core_reg_get(struct reg *reg)
#define XT_INS_PPTLB(X, S, T)
int xtensa_core_status_check(struct target *target)
#define XT_INS_RFR(X, FR, T)
static int xtensa_update_instruction(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
static int32_t xtensa_gdbqc_parse_exec_tie_ops(struct target *target, char *opstr)
#define XT_INS_S32E(X, R, S, T)
int xtensa_do_resume(struct target *target)
#define XT_PC_REG_NUM_VIRTUAL
int xtensa_wakeup(struct target *target)
static xtensa_reg_val_t xtensa_reg_get_value(struct reg *reg)
int xtensa_mmu_is_enabled(struct target *target, int *enabled)
static void xtensa_imprecise_exception_clear(struct target *target)
#define XT_INS_DHWBI(X, S, IMM8)
static const struct reg_arch_type xtensa_reg_type
static bool xtensa_is_stopped(struct target *target)
static int xtensa_gdbqc_qxtreg(struct target *target, const char *packet, char **response_p)
static int xtensa_write_dirty_registers(struct target *target)
void xtensa_set_permissive_mode(struct target *target, bool state)
#define XT_PC_DBREG_NUM_BASE
#define XT_INS_WUR(X, UR, T)
int xtensa_deassert_reset(struct target *target)
int xtensa_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
static const struct xtensa_local_mem_config * xtensa_get_mem_config(struct xtensa *xtensa, enum xtensa_mem_region_type type)
Gets a config for the specific mem type.
static int xtensa_sw_breakpoint_add(struct target *target, struct breakpoint *breakpoint, struct xtensa_sw_breakpoint *sw_bp)
static int xtensa_sw_breakpoint_remove(struct target *target, struct xtensa_sw_breakpoint *sw_bp)
static const struct xtensa_local_mem_region_config * xtensa_target_memory_region_find(struct xtensa *xtensa, target_addr_t address)
Returns a corresponding xtensa_local_mem_region_config from the xtensa target for a given address Ret...
int xtensa_soft_reset_halt(struct target *target)
#define XT_EPS_REG_NUM_BASE
static bool xtensa_is_dcacheable(struct xtensa *xtensa, target_addr_t address)
int xtensa_assert_reset(struct target *target)
#define XT_INS_S32I(X, S, T, IMM8)
#define XT_INS_LDDR32P(X, S)
#define XT_EPC_REG_NUM_BASE
static void xtensa_queue_exec_ins_wide(struct xtensa *xtensa, uint8_t *ops, uint8_t oplen)
static target_addr_t xtensa_get_overlap_size(target_addr_t r1_start, target_addr_t r1_end, target_addr_t r2_start, target_addr_t r2_end)
Returns a size of overlapped region of two ranges.
#define XT_INS_DHWB(X, S, IMM8)
int xtensa_run_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, target_addr_t entry_point, target_addr_t exit_point, unsigned int timeout_ms, void *arch_info)
static const struct xtensa_local_mem_region_config * xtensa_memory_region_find(const struct xtensa_local_mem_config *mem, target_addr_t address)
Extracts an exact xtensa_local_mem_region_config from xtensa_local_mem_config for a given address Ret...
static int xtensa_build_reg_cache(struct target *target)
#define XT_INS_WSR(X, SR, T)
#define XT_INS_RFWO_RFWU_MASK(X)
xtensa_reg_val_t xtensa_reg_get(struct target *target, enum xtensa_reg_id reg_id)
int xtensa_wait_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, target_addr_t exit_point, unsigned int timeout_ms, void *arch_info)
Waits for an algorithm in the target.
Holds the interface to Xtensa cores.
#define XT_MEM_ACCESS_READ
#define XT_PS_RING_GET(_v_)
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)
#define XT_MEM_ACCESS_WRITE
#define XT_MESRCLR_IMPR_EXC_MSK
#define XT_INS_BREAK(X, S, T)
#define XT_INS_BREAKN(X, IMM4)
#define XT_QUERYPKT_RESP_MAX
#define XTENSA_COMMON_MAGIC
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_start(struct xtensa_debug_module *dm, struct xtensa_trace_start_config *cfg)
int xtensa_dm_trace_stop(struct xtensa_debug_module *dm, bool pto_enable)
int xtensa_dm_write(struct xtensa_debug_module *dm, uint32_t addr, uint32_t val)
int xtensa_dm_power_status_read(struct xtensa_debug_module *dm, uint32_t clear)
int xtensa_dm_poll(struct xtensa_debug_module *dm)
int xtensa_dm_perfmon_enable(struct xtensa_debug_module *dm, int counter_id, const struct xtensa_perfmon_config *config)
void xtensa_dm_deinit(struct xtensa_debug_module *dm)
int xtensa_dm_trace_config_read(struct xtensa_debug_module *dm, struct xtensa_trace_config *config)
int xtensa_dm_trace_data_read(struct xtensa_debug_module *dm, uint8_t *dest, uint32_t size)
int xtensa_dm_core_status_clear(struct xtensa_debug_module *dm, xtensa_dsr_t bits)
int xtensa_dm_core_status_read(struct xtensa_debug_module *dm)
int xtensa_dm_queue_enable(struct xtensa_debug_module *dm)
int xtensa_dm_init(struct xtensa_debug_module *dm, const struct xtensa_debug_module_config *cfg)
int xtensa_dm_read(struct xtensa_debug_module *dm, uint32_t addr, uint32_t *val)
int xtensa_dm_perfmon_dump(struct xtensa_debug_module *dm, int counter_id, struct xtensa_perfmon_result *out_result)
#define PWRSTAT_DEBUGWASRESET(x)
#define TRAXADDR_TWRAP_SHIFT
#define OCDDCR_DEBUGMODEOUTEN
static void xtensa_dm_power_status_cache(struct xtensa_debug_module *dm)
#define XTENSA_MAX_PERF_COUNTERS
#define OCDDSR_DEBUGPENDTRAX
#define OCDDSR_STOPCAUSE_IB
#define OCDDCR_BREAKOUTEN
#define OCDDCR_STEPREQUEST
#define OCDDSR_DEBUGPENDHOST
#define OCDDSR_STOPCAUSE_DB1
#define OCDDSR_STOPCAUSE_BN
static void xtensa_dm_queue_tdi_idle(struct xtensa_debug_module *dm)
static bool xtensa_dm_core_was_reset(struct xtensa_debug_module *dm)
#define OCDDSR_DEBUGINTTRAX
static xtensa_dsr_t xtensa_dm_core_status_get(struct xtensa_debug_module *dm)
#define OCDDSR_EXECEXCEPTION
#define OCDDSR_STOPCAUSE_B1
static bool xtensa_dm_is_powered(struct xtensa_debug_module *dm)
#define PWRCTL_CORERESET(x)
#define TRAXADDR_TWRAP_MASK
#define OCDDSR_STOPCAUSE_SHIFT
#define OCDDSR_STOPCAUSE_DB0
#define XTENSA_MAX_PERF_SELECT
#define OCDDSR_DEBUGINTBREAK
static bool xtensa_dm_tap_was_reset(struct xtensa_debug_module *dm)
#define PWRCTL_MEMWAKEUP(x)
#define OCDDSR_STOPCAUSE_B
#define PWRCTL_JTAGDEBUGUSE(x)
static int xtensa_dm_queue_execute(struct xtensa_debug_module *dm)
#define PWRCTL_COREWAKEUP(x)
#define OCDDSR_DEBUGPENDBREAK
static bool xtensa_dm_is_online(struct xtensa_debug_module *dm)
#define OCDDSR_STOPCAUSE_DI
#define OCDDSR_DEBUGINTHOST
#define PWRSTAT_COREWASRESET(x)
#define OCDDCR_DEBUGINTERRUPT
#define PWRCTL_DEBUGWAKEUP(x)
#define OCDDSR_EXECOVERRUN
#define XTENSA_STOPMASK_DISABLED
#define OCDDCR_RUNSTALLINEN
#define XTENSA_MAX_PERF_MASK
#define OCDDSR_STOPCAUSE_SS
#define TRAXADDR_TADDR_MASK
@ XT_REG_IDX_IBREAKENABLE
uint32_t xtensa_reg_val_t
#define XT_MK_REG_DESC(n, r, t, f)