a8928911f65661453b0550416a25c222aa072f64
[openocd.git] / src / target / target_type.h
1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
4 * *
5 * Copyright (C) 2007-2010 √ėyvind Harboe *
6 * oyvind.harboe@zylin.com *
7 * *
8 * Copyright (C) 2008 by Spencer Oliver *
9 * spen@spen-soft.co.uk *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
20 * *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
23 ***************************************************************************/
24
25 #ifndef OPENOCD_TARGET_TARGET_TYPE_H
26 #define OPENOCD_TARGET_TARGET_TYPE_H
27
28 #include <jim-nvp.h>
29
30 struct target;
31
32 /**
33 * This holds methods shared between all instances of a given target
34 * type. For example, all Cortex-M3 targets on a scan chain share
35 * the same method table.
36 */
37 struct target_type {
38 /**
39 * Name of this type of target. Do @b not access this
40 * field directly, use target_type_name() instead.
41 */
42 const char *name;
43 const char *deprecated_name;
44
45 /* poll current target status */
46 int (*poll)(struct target *target);
47 /* Invoked only from target_arch_state().
48 * Issue USER() w/architecture specific status. */
49 int (*arch_state)(struct target *target);
50
51 /* target request support */
52 int (*target_request_data)(struct target *target, uint32_t size, uint8_t *buffer);
53
54 /* halt will log a warning, but return ERROR_OK if the target is already halted. */
55 int (*halt)(struct target *target);
56 /* See target.c target_resume() for documentation. */
57 int (*resume)(struct target *target, int current, target_addr_t address,
58 int handle_breakpoints, int debug_execution);
59 int (*step)(struct target *target, int current, target_addr_t address,
60 int handle_breakpoints);
61 /* target reset control. assert reset can be invoked when OpenOCD and
62 * the target is out of sync.
63 *
64 * A typical example is that the target was power cycled while OpenOCD
65 * thought the target was halted or running.
66 *
67 * assert_reset() can therefore make no assumptions whatsoever about the
68 * state of the target
69 *
70 * Before assert_reset() for the target is invoked, a TRST/tms and
71 * chain validation is executed. TRST should not be asserted
72 * during target assert unless there is no way around it due to
73 * the way reset's are configured.
74 *
75 */
76 int (*assert_reset)(struct target *target);
77 /**
78 * The implementation is responsible for polling the
79 * target such that target->state reflects the
80 * state correctly.
81 *
82 * Otherwise the following would fail, as there will not
83 * be any "poll" invoked inbetween the "reset run" and
84 * "halt".
85 *
86 * reset run; halt
87 */
88 int (*deassert_reset)(struct target *target);
89 int (*soft_reset_halt)(struct target *target);
90
91 /**
92 * Target architecture for GDB.
93 *
94 * The string returned by this function will not be automatically freed;
95 * if dynamic allocation is used for this value, it must be managed by
96 * the target, ideally by caching the result for subsequent calls.
97 */
98 const char *(*get_gdb_arch)(struct target *target);
99
100 /**
101 * Target register access for GDB. Do @b not call this function
102 * directly, use target_get_gdb_reg_list() instead.
103 *
104 * Danger! this function will succeed even if the target is running
105 * and return a register list with dummy values.
106 *
107 * The reason is that GDB connection will fail without a valid register
108 * list, however it is after GDB is connected that monitor commands can
109 * be run to properly initialize the target
110 */
111 int (*get_gdb_reg_list)(struct target *target, struct reg **reg_list[],
112 int *reg_list_size, enum target_register_class reg_class);
113
114 /* target memory access
115 * size: 1 = byte (8bit), 2 = half-word (16bit), 4 = word (32bit)
116 * count: number of items of <size>
117 */
118
119 /**
120 * Target memory read callback. Do @b not call this function
121 * directly, use target_read_memory() instead.
122 */
123 int (*read_memory)(struct target *target, target_addr_t address,
124 uint32_t size, uint32_t count, uint8_t *buffer);
125 /**
126 * Target memory write callback. Do @b not call this function
127 * directly, use target_write_memory() instead.
128 */
129 int (*write_memory)(struct target *target, target_addr_t address,
130 uint32_t size, uint32_t count, const uint8_t *buffer);
131
132 /* Default implementation will do some fancy alignment to improve performance, target can override */
133 int (*read_buffer)(struct target *target, target_addr_t address,
134 uint32_t size, uint8_t *buffer);
135
136 /* Default implementation will do some fancy alignment to improve performance, target can override */
137 int (*write_buffer)(struct target *target, target_addr_t address,
138 uint32_t size, const uint8_t *buffer);
139
140 int (*checksum_memory)(struct target *target, target_addr_t address,
141 uint32_t count, uint32_t *checksum);
142 int (*blank_check_memory)(struct target *target,
143 struct target_memory_check_block *blocks, int num_blocks,
144 uint8_t erased_value);
145
146 /*
147 * target break-/watchpoint control
148 * rw: 0 = write, 1 = read, 2 = access
149 *
150 * Target must be halted while this is invoked as this
151 * will actually set up breakpoints on target.
152 *
153 * The breakpoint hardware will be set up upon adding the
154 * first breakpoint.
155 *
156 * Upon GDB connection all breakpoints/watchpoints are cleared.
157 */
158 int (*add_breakpoint)(struct target *target, struct breakpoint *breakpoint);
159 int (*add_context_breakpoint)(struct target *target, struct breakpoint *breakpoint);
160 int (*add_hybrid_breakpoint)(struct target *target, struct breakpoint *breakpoint);
161
162 /* remove breakpoint. hw will only be updated if the target
163 * is currently halted.
164 * However, this method can be invoked on unresponsive targets.
165 */
166 int (*remove_breakpoint)(struct target *target, struct breakpoint *breakpoint);
167
168 /* add watchpoint ... see add_breakpoint() comment above. */
169 int (*add_watchpoint)(struct target *target, struct watchpoint *watchpoint);
170
171 /* remove watchpoint. hw will only be updated if the target
172 * is currently halted.
173 * However, this method can be invoked on unresponsive targets.
174 */
175 int (*remove_watchpoint)(struct target *target, struct watchpoint *watchpoint);
176
177 /* Find out just hit watchpoint. After the target hits a watchpoint, the
178 * information could assist gdb to locate where the modified/accessed memory is.
179 */
180 int (*hit_watchpoint)(struct target *target, struct watchpoint **hit_watchpoint);
181
182 /**
183 * Target algorithm support. Do @b not call this method directly,
184 * use target_run_algorithm() instead.
185 */
186 int (*run_algorithm)(struct target *target, int num_mem_params,
187 struct mem_param *mem_params, int num_reg_params,
188 struct reg_param *reg_param, target_addr_t entry_point,
189 target_addr_t exit_point, int timeout_ms, void *arch_info);
190 int (*start_algorithm)(struct target *target, int num_mem_params,
191 struct mem_param *mem_params, int num_reg_params,
192 struct reg_param *reg_param, target_addr_t entry_point,
193 target_addr_t exit_point, void *arch_info);
194 int (*wait_algorithm)(struct target *target, int num_mem_params,
195 struct mem_param *mem_params, int num_reg_params,
196 struct reg_param *reg_param, target_addr_t exit_point,
197 int timeout_ms, void *arch_info);
198
199 const struct command_registration *commands;
200
201 /* called when target is created */
202 int (*target_create)(struct target *target, Jim_Interp *interp);
203
204 /* called for various config parameters */
205 /* returns JIM_CONTINUE - if option not understood */
206 /* otherwise: JIM_OK, or JIM_ERR, */
207 int (*target_jim_configure)(struct target *target, Jim_GetOptInfo *goi);
208
209 /* target commands specifically handled by the target */
210 /* returns JIM_OK, or JIM_ERR, or JIM_CONTINUE - if option not understood */
211 int (*target_jim_commands)(struct target *target, Jim_GetOptInfo *goi);
212
213 /**
214 * This method is used to perform target setup that requires
215 * JTAG access.
216 *
217 * This may be called multiple times. It is called after the
218 * scan chain is initially validated, or later after the target
219 * is enabled by a JRC. It may also be called during some
220 * parts of the reset sequence.
221 *
222 * For one-time initialization tasks, use target_was_examined()
223 * and target_set_examined(). For example, probe the hardware
224 * before setting up chip-specific state, and then set that
225 * flag so you don't do that again.
226 */
227 int (*examine)(struct target *target);
228
229 /* Set up structures for target.
230 *
231 * It is illegal to talk to the target at this stage as this fn is invoked
232 * before the JTAG chain has been examined/verified
233 * */
234 int (*init_target)(struct command_context *cmd_ctx, struct target *target);
235
236 /**
237 * Free all the resources allocated by the target.
238 *
239 * @param target The target to deinit
240 */
241 void (*deinit_target)(struct target *target);
242
243 /* translate from virtual to physical address. Default implementation is successful
244 * no-op(i.e. virtual==physical).
245 */
246 int (*virt2phys)(struct target *target, target_addr_t address, target_addr_t *physical);
247
248 /* read directly from physical memory. caches are bypassed and untouched.
249 *
250 * If the target does not support disabling caches, leaving them untouched,
251 * then minimally the actual physical memory location will be read even
252 * if cache states are unchanged, flushed, etc.
253 *
254 * Default implementation is to call read_memory.
255 */
256 int (*read_phys_memory)(struct target *target, target_addr_t phys_address,
257 uint32_t size, uint32_t count, uint8_t *buffer);
258
259 /*
260 * same as read_phys_memory, except that it writes...
261 */
262 int (*write_phys_memory)(struct target *target, target_addr_t phys_address,
263 uint32_t size, uint32_t count, const uint8_t *buffer);
264
265 int (*mmu)(struct target *target, int *enabled);
266
267 /* after reset is complete, the target can check if things are properly set up.
268 *
269 * This can be used to check if e.g. DCC memory writes have been enabled for
270 * arm7/9 targets, which they really should except in the most contrived
271 * circumstances.
272 */
273 int (*check_reset)(struct target *target);
274
275 /* get GDB file-I/O parameters from target
276 */
277 int (*get_gdb_fileio_info)(struct target *target, struct gdb_fileio_info *fileio_info);
278
279 /* pass GDB file-I/O response to target
280 */
281 int (*gdb_fileio_end)(struct target *target, int retcode, int fileio_errno, bool ctrl_c);
282
283 /* do target profiling
284 */
285 int (*profiling)(struct target *target, uint32_t *samples,
286 uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds);
287 };
288
289 #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)