1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Generic Xtensa target *
5 * Copyright (C) 2019 Espressif Systems Ltd. *
6 * Author: Alexey Gerenkov <alexey@espressif.com> *
7 ***************************************************************************/
9 #ifndef OPENOCD_TARGET_XTENSA_H
10 #define OPENOCD_TARGET_XTENSA_H
13 #include <target/target.h>
14 #include <target/breakpoints.h>
15 #include "xtensa_regs.h"
16 #include "xtensa_debug_module.h"
20 * Holds the interface to Xtensa cores.
23 #define XT_ISNS_SZ_MAX 3
25 #define XT_PS_RING(_v_) ((uint32_t)((_v_) & 0x3) << 6)
26 #define XT_PS_RING_MSK (0x3 << 6)
27 #define XT_PS_RING_GET(_v_) (((_v_) >> 6) & 0x3)
28 #define XT_PS_CALLINC_MSK (0x3 << 16)
29 #define XT_PS_OWB_MSK (0xF << 8)
31 #define XT_LOCAL_MEM_REGIONS_NUM_MAX 8
33 #define XT_AREGS_NUM_MAX 64
34 #define XT_USER_REGS_NUM_MAX 256
36 #define XT_MEM_ACCESS_NONE 0x0
37 #define XT_MEM_ACCESS_READ 0x1
38 #define XT_MEM_ACCESS_WRITE 0x2
40 enum xtensa_mem_err_detect
{
41 XT_MEM_ERR_DETECT_NONE
,
42 XT_MEM_ERR_DETECT_PARITY
,
43 XT_MEM_ERR_DETECT_ECC
,
46 struct xtensa_cache_config
{
51 enum xtensa_mem_err_detect mem_err_check
;
54 struct xtensa_local_mem_region_config
{
57 enum xtensa_mem_err_detect mem_err_check
;
61 struct xtensa_local_mem_config
{
63 struct xtensa_local_mem_region_config regions
[XT_LOCAL_MEM_REGIONS_NUM_MAX
];
66 struct xtensa_mmu_config
{
68 uint8_t itlb_entries_count
;
69 uint8_t dtlb_entries_count
;
74 struct xtensa_exception_config
{
79 struct xtensa_irq_config
{
84 struct xtensa_high_prio_irq_config
{
90 struct xtensa_debug_config
{
98 struct xtensa_tracing_config
{
101 bool reversed_mem_access
;
104 struct xtensa_timer_irq_config
{
109 struct xtensa_config
{
116 uint8_t miscregs_num
;
125 uint16_t user_regs_num
;
126 const struct xtensa_user_reg_desc
*user_regs
;
127 int (*fetch_user_regs
)(struct target
*target
);
128 int (*queue_write_dirty_user_regs
)(struct target
*target
);
129 struct xtensa_cache_config icache
;
130 struct xtensa_cache_config dcache
;
131 struct xtensa_local_mem_config irom
;
132 struct xtensa_local_mem_config iram
;
133 struct xtensa_local_mem_config drom
;
134 struct xtensa_local_mem_config dram
;
135 struct xtensa_local_mem_config uram
;
136 struct xtensa_local_mem_config xlmi
;
137 struct xtensa_mmu_config mmu
;
138 struct xtensa_exception_config exc
;
139 struct xtensa_irq_config irq
;
140 struct xtensa_high_prio_irq_config high_irq
;
141 struct xtensa_timer_irq_config tim_irq
;
142 struct xtensa_debug_config debug
;
143 struct xtensa_tracing_config trace
;
144 unsigned int gdb_general_regs_num
;
145 const unsigned int *gdb_regs_mapping
;
148 typedef uint32_t xtensa_insn_t
;
150 enum xtensa_stepping_isr_mode
{
151 XT_STEPPING_ISR_OFF
, /* interrupts are disabled during stepping */
152 XT_STEPPING_ISR_ON
, /* interrupts are enabled during stepping */
155 /* Only supported in cores with in-CPU MMU. None of Espressif chips as of now. */
161 XT_MODE_ANY
/* special value to run algorithm in current core mode */
164 struct xtensa_sw_breakpoint
{
165 struct breakpoint
*oocd_bp
;
167 uint8_t insn
[XT_ISNS_SZ_MAX
];
168 /* original insn size */
169 uint8_t insn_sz
; /* 2 or 3 bytes */
172 #define XTENSA_COMMON_MAGIC 0x54E4E555U
175 * Represents a generic Xtensa core.
178 unsigned int common_magic
;
179 const struct xtensa_config
*core_config
;
180 struct xtensa_debug_module dbg_mod
;
181 struct reg_cache
*core_cache
;
182 unsigned int regs_num
;
183 /* An array of pointers to buffers to backup registers' values while algo is run on target.
184 * Size is 'regs_num'. */
185 void **algo_context_backup
;
186 struct target
*target
;
188 enum xtensa_stepping_isr_mode stepping_isr_mode
;
189 struct breakpoint
**hw_brps
;
190 struct watchpoint
**hw_wps
;
191 struct xtensa_sw_breakpoint
*sw_brps
;
193 bool permissive_mode
; /* bypass memory checks */
194 bool suppress_dsr_errors
;
196 /* Sometimes debug module's 'powered' bit is cleared after reset, but get set after some
197 * time.This is the number of polling periods after which core is considered to be powered
198 * off (marked as unexamined) if the bit retains to be cleared (e.g. if core is disabled by
199 * SW running on target).*/
200 uint8_t come_online_probes_num
;
201 bool regs_fetched
; /* true after first register fetch completed successfully */
204 static inline struct xtensa
*target_to_xtensa(struct target
*target
)
207 struct xtensa
*xtensa
= target
->arch_info
;
208 assert(xtensa
->common_magic
== XTENSA_COMMON_MAGIC
);
212 int xtensa_init_arch_info(struct target
*target
,
213 struct xtensa
*xtensa
,
214 const struct xtensa_config
*cfg
,
215 const struct xtensa_debug_module_config
*dm_cfg
);
216 int xtensa_target_init(struct command_context
*cmd_ctx
, struct target
*target
);
217 void xtensa_target_deinit(struct target
*target
);
219 static inline bool xtensa_addr_in_mem(const struct xtensa_local_mem_config
*mem
, uint32_t addr
)
221 for (unsigned int i
= 0; i
< mem
->count
; i
++) {
222 if (addr
>= mem
->regions
[i
].base
&&
223 addr
< mem
->regions
[i
].base
+ mem
->regions
[i
].size
)
229 static inline bool xtensa_data_addr_valid(struct target
*target
, uint32_t addr
)
231 struct xtensa
*xtensa
= target_to_xtensa(target
);
233 if (xtensa_addr_in_mem(&xtensa
->core_config
->drom
, addr
))
235 if (xtensa_addr_in_mem(&xtensa
->core_config
->dram
, addr
))
237 if (xtensa_addr_in_mem(&xtensa
->core_config
->uram
, addr
))
242 int xtensa_core_status_check(struct target
*target
);
244 int xtensa_examine(struct target
*target
);
245 int xtensa_wakeup(struct target
*target
);
246 int xtensa_smpbreak_set(struct target
*target
, uint32_t set
);
247 int xtensa_smpbreak_get(struct target
*target
, uint32_t *val
);
248 int xtensa_smpbreak_write(struct xtensa
*xtensa
, uint32_t set
);
249 int xtensa_smpbreak_read(struct xtensa
*xtensa
, uint32_t *val
);
250 xtensa_reg_val_t
xtensa_reg_get(struct target
*target
, enum xtensa_reg_id reg_id
);
251 void xtensa_reg_set(struct target
*target
, enum xtensa_reg_id reg_id
, xtensa_reg_val_t value
);
252 int xtensa_fetch_all_regs(struct target
*target
);
253 int xtensa_get_gdb_reg_list(struct target
*target
,
254 struct reg
**reg_list
[],
256 enum target_register_class reg_class
);
257 int xtensa_poll(struct target
*target
);
258 void xtensa_on_poll(struct target
*target
);
259 int xtensa_halt(struct target
*target
);
260 int xtensa_resume(struct target
*target
,
262 target_addr_t address
,
263 int handle_breakpoints
,
264 int debug_execution
);
265 int xtensa_prepare_resume(struct target
*target
,
267 target_addr_t address
,
268 int handle_breakpoints
,
269 int debug_execution
);
270 int xtensa_do_resume(struct target
*target
);
271 int xtensa_step(struct target
*target
, int current
, target_addr_t address
, int handle_breakpoints
);
272 int xtensa_do_step(struct target
*target
, int current
, target_addr_t address
, int handle_breakpoints
);
273 int xtensa_mmu_is_enabled(struct target
*target
, int *enabled
);
274 int xtensa_read_memory(struct target
*target
, target_addr_t address
, uint32_t size
, uint32_t count
, uint8_t *buffer
);
275 int xtensa_read_buffer(struct target
*target
, target_addr_t address
, uint32_t count
, uint8_t *buffer
);
276 int xtensa_write_memory(struct target
*target
,
277 target_addr_t address
,
280 const uint8_t *buffer
);
281 int xtensa_write_buffer(struct target
*target
, target_addr_t address
, uint32_t count
, const uint8_t *buffer
);
282 int xtensa_checksum_memory(struct target
*target
, target_addr_t address
, uint32_t count
, uint32_t *checksum
);
283 int xtensa_assert_reset(struct target
*target
);
284 int xtensa_deassert_reset(struct target
*target
);
285 int xtensa_breakpoint_add(struct target
*target
, struct breakpoint
*breakpoint
);
286 int xtensa_breakpoint_remove(struct target
*target
, struct breakpoint
*breakpoint
);
287 int xtensa_watchpoint_add(struct target
*target
, struct watchpoint
*watchpoint
);
288 int xtensa_watchpoint_remove(struct target
*target
, struct watchpoint
*watchpoint
);
289 void xtensa_set_permissive_mode(struct target
*target
, bool state
);
290 int xtensa_fetch_user_regs_u32(struct target
*target
);
291 int xtensa_queue_write_dirty_user_regs_u32(struct target
*target
);
292 const char *xtensa_get_gdb_arch(struct target
*target
);
295 COMMAND_HELPER(xtensa_cmd_permissive_mode_do
, struct xtensa
*xtensa
);
296 COMMAND_HELPER(xtensa_cmd_mask_interrupts_do
, struct xtensa
*xtensa
);
297 COMMAND_HELPER(xtensa_cmd_smpbreak_do
, struct target
*target
);
298 COMMAND_HELPER(xtensa_cmd_perfmon_dump_do
, struct xtensa
*xtensa
);
299 COMMAND_HELPER(xtensa_cmd_perfmon_enable_do
, struct xtensa
*xtensa
);
300 COMMAND_HELPER(xtensa_cmd_tracestart_do
, struct xtensa
*xtensa
);
301 COMMAND_HELPER(xtensa_cmd_tracestop_do
, struct xtensa
*xtensa
);
302 COMMAND_HELPER(xtensa_cmd_tracedump_do
, struct xtensa
*xtensa
, const char *fname
);
304 extern const struct reg_arch_type xtensa_user_reg_u32_type
;
305 extern const struct reg_arch_type xtensa_user_reg_u128_type
;
306 extern const struct command_registration xtensa_command_handlers
[];
308 #endif /* OPENOCD_TARGET_XTENSA_H */
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)