1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2005 by Dominic Rath *
5 * Dominic.Rath@gmx.de *
7 * Copyright (C) 2007-2010 Øyvind Harboe *
8 * oyvind.harboe@zylin.com *
10 * Copyright (C) 2008 by Spencer Oliver *
11 * spen@spen-soft.co.uk *
12 ***************************************************************************/
14 #ifndef OPENOCD_TARGET_TARGET_TYPE_H
15 #define OPENOCD_TARGET_TARGET_TYPE_H
17 #include <helper/jim-nvp.h>
22 * This holds methods shared between all instances of a given target
23 * type. For example, all Cortex-M3 targets on a scan chain share
24 * the same method table.
28 * Name of this type of target. Do @b not access this
29 * field directly, use target_type_name() instead.
33 /* poll current target status */
34 int (*poll
)(struct target
*target
);
35 /* Invoked only from target_arch_state().
36 * Issue USER() w/architecture specific status. */
37 int (*arch_state
)(struct target
*target
);
39 /* target request support */
40 int (*target_request_data
)(struct target
*target
, uint32_t size
, uint8_t *buffer
);
42 /* halt will log a warning, but return ERROR_OK if the target is already halted. */
43 int (*halt
)(struct target
*target
);
44 /* See target.c target_resume() for documentation. */
45 int (*resume
)(struct target
*target
, int current
, target_addr_t address
,
46 int handle_breakpoints
, int debug_execution
);
47 int (*step
)(struct target
*target
, int current
, target_addr_t address
,
48 int handle_breakpoints
);
49 /* target reset control. assert reset can be invoked when OpenOCD and
50 * the target is out of sync.
52 * A typical example is that the target was power cycled while OpenOCD
53 * thought the target was halted or running.
55 * assert_reset() can therefore make no assumptions whatsoever about the
58 * Before assert_reset() for the target is invoked, a TRST/tms and
59 * chain validation is executed. TRST should not be asserted
60 * during target assert unless there is no way around it due to
61 * the way reset's are configured.
64 int (*assert_reset
)(struct target
*target
);
66 * The implementation is responsible for polling the
67 * target such that target->state reflects the
70 * Otherwise the following would fail, as there will not
71 * be any "poll" invoked between the "reset run" and
76 int (*deassert_reset
)(struct target
*target
);
77 int (*soft_reset_halt
)(struct target
*target
);
80 * Target architecture for GDB.
82 * The string returned by this function will not be automatically freed;
83 * if dynamic allocation is used for this value, it must be managed by
84 * the target, ideally by caching the result for subsequent calls.
86 const char *(*get_gdb_arch
)(const struct target
*target
);
89 * Target register access for GDB. Do @b not call this function
90 * directly, use target_get_gdb_reg_list() instead.
92 * Danger! this function will succeed even if the target is running
93 * and return a register list with dummy values.
95 * The reason is that GDB connection will fail without a valid register
96 * list, however it is after GDB is connected that monitor commands can
97 * be run to properly initialize the target
99 int (*get_gdb_reg_list
)(struct target
*target
, struct reg
**reg_list
[],
100 int *reg_list_size
, enum target_register_class reg_class
);
103 * Same as get_gdb_reg_list, but doesn't read the register values.
105 int (*get_gdb_reg_list_noread
)(struct target
*target
,
106 struct reg
**reg_list
[], int *reg_list_size
,
107 enum target_register_class reg_class
);
109 /* target memory access
110 * size: 1 = byte (8bit), 2 = half-word (16bit), 4 = word (32bit)
111 * count: number of items of <size>
115 * Target memory read callback. Do @b not call this function
116 * directly, use target_read_memory() instead.
118 int (*read_memory
)(struct target
*target
, target_addr_t address
,
119 uint32_t size
, uint32_t count
, uint8_t *buffer
);
121 * Target memory write callback. Do @b not call this function
122 * directly, use target_write_memory() instead.
124 int (*write_memory
)(struct target
*target
, target_addr_t address
,
125 uint32_t size
, uint32_t count
, const uint8_t *buffer
);
127 /* Default implementation will do some fancy alignment to improve performance, target can override */
128 int (*read_buffer
)(struct target
*target
, target_addr_t address
,
129 uint32_t size
, uint8_t *buffer
);
131 /* Default implementation will do some fancy alignment to improve performance, target can override */
132 int (*write_buffer
)(struct target
*target
, target_addr_t address
,
133 uint32_t size
, const uint8_t *buffer
);
135 int (*checksum_memory
)(struct target
*target
, target_addr_t address
,
136 uint32_t count
, uint32_t *checksum
);
137 int (*blank_check_memory
)(struct target
*target
,
138 struct target_memory_check_block
*blocks
, int num_blocks
,
139 uint8_t erased_value
);
142 * target break-/watchpoint control
143 * rw: 0 = write, 1 = read, 2 = access
145 * Target must be halted while this is invoked as this
146 * will actually set up breakpoints on target.
148 * The breakpoint hardware will be set up upon adding the
151 * Upon GDB connection all breakpoints/watchpoints are cleared.
153 int (*add_breakpoint
)(struct target
*target
, struct breakpoint
*breakpoint
);
154 int (*add_context_breakpoint
)(struct target
*target
, struct breakpoint
*breakpoint
);
155 int (*add_hybrid_breakpoint
)(struct target
*target
, struct breakpoint
*breakpoint
);
157 /* remove breakpoint. hw will only be updated if the target
158 * is currently halted.
159 * However, this method can be invoked on unresponsive targets.
161 int (*remove_breakpoint
)(struct target
*target
, struct breakpoint
*breakpoint
);
163 /* add watchpoint ... see add_breakpoint() comment above. */
164 int (*add_watchpoint
)(struct target
*target
, struct watchpoint
*watchpoint
);
166 /* remove watchpoint. hw will only be updated if the target
167 * is currently halted.
168 * However, this method can be invoked on unresponsive targets.
170 int (*remove_watchpoint
)(struct target
*target
, struct watchpoint
*watchpoint
);
172 /* Find out just hit watchpoint. After the target hits a watchpoint, the
173 * information could assist gdb to locate where the modified/accessed memory is.
175 int (*hit_watchpoint
)(struct target
*target
, struct watchpoint
**hit_watchpoint
);
178 * Target algorithm support. Do @b not call this method directly,
179 * use target_run_algorithm() instead.
181 int (*run_algorithm
)(struct target
*target
, int num_mem_params
,
182 struct mem_param
*mem_params
, int num_reg_params
,
183 struct reg_param
*reg_param
, target_addr_t entry_point
,
184 target_addr_t exit_point
, unsigned int timeout_ms
, void *arch_info
);
185 int (*start_algorithm
)(struct target
*target
, int num_mem_params
,
186 struct mem_param
*mem_params
, int num_reg_params
,
187 struct reg_param
*reg_param
, target_addr_t entry_point
,
188 target_addr_t exit_point
, void *arch_info
);
189 int (*wait_algorithm
)(struct target
*target
, int num_mem_params
,
190 struct mem_param
*mem_params
, int num_reg_params
,
191 struct reg_param
*reg_param
, target_addr_t exit_point
,
192 unsigned int timeout_ms
, void *arch_info
);
194 const struct command_registration
*commands
;
196 /* called when target is created */
197 int (*target_create
)(struct target
*target
, Jim_Interp
*interp
);
199 /* called for various config parameters */
200 /* returns JIM_CONTINUE - if option not understood */
201 /* otherwise: JIM_OK, or JIM_ERR, */
202 int (*target_jim_configure
)(struct target
*target
, struct jim_getopt_info
*goi
);
204 /* target commands specifically handled by the target */
205 /* returns JIM_OK, or JIM_ERR, or JIM_CONTINUE - if option not understood */
206 int (*target_jim_commands
)(struct target
*target
, struct jim_getopt_info
*goi
);
209 * This method is used to perform target setup that requires
212 * This may be called multiple times. It is called after the
213 * scan chain is initially validated, or later after the target
214 * is enabled by a JRC. It may also be called during some
215 * parts of the reset sequence.
217 * For one-time initialization tasks, use target_was_examined()
218 * and target_set_examined(). For example, probe the hardware
219 * before setting up chip-specific state, and then set that
220 * flag so you don't do that again.
222 int (*examine
)(struct target
*target
);
224 /* Set up structures for target.
226 * It is illegal to talk to the target at this stage as this fn is invoked
227 * before the JTAG chain has been examined/verified
229 int (*init_target
)(struct command_context
*cmd_ctx
, struct target
*target
);
232 * Free all the resources allocated by the target.
234 * WARNING: deinit_target is called unconditionally regardless the target has
235 * ever been examined/initialised or not.
236 * If a problem has prevented establishing JTAG/SWD/... communication
238 * if the target was created with -defer-examine flag and has never been
240 * then it is not possible to communicate with the target.
242 * If you need to talk to the target during deinit, first check if
243 * target_was_examined()!
245 * @param target The target to deinit
247 void (*deinit_target
)(struct target
*target
);
249 /* translate from virtual to physical address. Default implementation is successful
250 * no-op(i.e. virtual==physical).
252 int (*virt2phys
)(struct target
*target
, target_addr_t address
, target_addr_t
*physical
);
254 /* read directly from physical memory. caches are bypassed and untouched.
256 * If the target does not support disabling caches, leaving them untouched,
257 * then minimally the actual physical memory location will be read even
258 * if cache states are unchanged, flushed, etc.
260 * Default implementation is to call read_memory.
262 int (*read_phys_memory
)(struct target
*target
, target_addr_t phys_address
,
263 uint32_t size
, uint32_t count
, uint8_t *buffer
);
266 * same as read_phys_memory, except that it writes...
268 int (*write_phys_memory
)(struct target
*target
, target_addr_t phys_address
,
269 uint32_t size
, uint32_t count
, const uint8_t *buffer
);
271 int (*mmu
)(struct target
*target
, int *enabled
);
273 /* after reset is complete, the target can check if things are properly set up.
275 * This can be used to check if e.g. DCC memory writes have been enabled for
276 * arm7/9 targets, which they really should except in the most contrived
279 int (*check_reset
)(struct target
*target
);
281 /* get GDB file-I/O parameters from target
283 int (*get_gdb_fileio_info
)(struct target
*target
, struct gdb_fileio_info
*fileio_info
);
285 /* pass GDB file-I/O response to target
287 int (*gdb_fileio_end
)(struct target
*target
, int retcode
, int fileio_errno
, bool ctrl_c
);
289 /* Parse target-specific GDB query commands.
290 * The string pointer "response_p" is always assigned by the called function
291 * to a pointer to a NULL-terminated string, even when the function returns
292 * an error. The string memory is not freed by the caller, so this function
293 * must pay attention for possible memory leaks if the string memory is
294 * dynamically allocated.
296 int (*gdb_query_custom
)(struct target
*target
, const char *packet
, char **response_p
);
298 /* do target profiling
300 int (*profiling
)(struct target
*target
, uint32_t *samples
,
301 uint32_t max_num_samples
, uint32_t *num_samples
, uint32_t seconds
);
303 /* Return the number of address bits this target supports. This will
304 * typically be 32 for 32-bit targets, and 64 for 64-bit targets. If not
305 * implemented, it's assumed to be 32. */
306 unsigned (*address_bits
)(struct target
*target
);
308 /* Return the number of system bus data bits this target supports. This
309 * will typically be 32 for 32-bit targets, and 64 for 64-bit targets. If
310 * not implemented, it's assumed to be 32. */
311 unsigned int (*data_bits
)(struct target
*target
);
314 extern struct target_type aarch64_target
;
315 extern struct target_type arcv2_target
;
316 extern struct target_type arm11_target
;
317 extern struct target_type arm720t_target
;
318 extern struct target_type arm7tdmi_target
;
319 extern struct target_type arm920t_target
;
320 extern struct target_type arm926ejs_target
;
321 extern struct target_type arm946e_target
;
322 extern struct target_type arm966e_target
;
323 extern struct target_type arm9tdmi_target
;
324 extern struct target_type armv8r_target
;
325 extern struct target_type avr32_ap7k_target
;
326 extern struct target_type avr_target
;
327 extern struct target_type cortexa_target
;
328 extern struct target_type cortexm_target
;
329 extern struct target_type cortexr4_target
;
330 extern struct target_type dragonite_target
;
331 extern struct target_type dsp563xx_target
;
332 extern struct target_type dsp5680xx_target
;
333 extern struct target_type esirisc_target
;
334 extern struct target_type esp32s2_target
;
335 extern struct target_type esp32s3_target
;
336 extern struct target_type esp32_target
;
337 extern struct target_type fa526_target
;
338 extern struct target_type feroceon_target
;
339 extern struct target_type hla_target
;
340 extern struct target_type ls1_sap_target
;
341 extern struct target_type mem_ap_target
;
342 extern struct target_type mips_m4k_target
;
343 extern struct target_type mips_mips64_target
;
344 extern struct target_type or1k_target
;
345 extern struct target_type quark_d20xx_target
;
346 extern struct target_type quark_x10xx_target
;
347 extern struct target_type riscv_target
;
348 extern struct target_type stm8_target
;
349 extern struct target_type testee_target
;
350 extern struct target_type xscale_target
;
351 extern struct target_type xtensa_chip_target
;
353 #endif /* OPENOCD_TARGET_TARGET_TYPE_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)