mcr/mrc interface work. Implemented for arm926ejs and arm720t. mcr/mrc commands added.
[openocd.git] / src / target / target_type.h
blob83baa2526a3fe60f45222f6322d20e15d55a9b87
1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
4 * *
5 * Copyright (C) 2007,2008,2009 Ø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, write to the *
23 * Free Software Foundation, Inc., *
24 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 ***************************************************************************/
26 #ifndef TARGET_TYPE_H
27 #define TARGET_TYPE_H
29 #include "types.h"
31 struct target_s;
33 struct target_type_s
35 /**
36 * Name of the target. Do @b not access this field directly, use
37 * target_get_name() instead.
39 char *name;
41 /**
42 * Indicates whether this target has been examined.
44 * Do @b not access this field directly, use target_was_examined()
45 * target_set_examined(), and target_reset_examined().
47 int examined;
49 /* poll current target status */
50 int (*poll)(struct target_s *target);
51 /* Invoked only from target_arch_state().
52 * Issue USER() w/architecture specific status. */
53 int (*arch_state)(struct target_s *target);
55 /* target request support */
56 int (*target_request_data)(struct target_s *target, uint32_t size, uint8_t *buffer);
58 /* halt will log a warning, but return ERROR_OK if the target is already halted. */
59 int (*halt)(struct target_s *target);
60 int (*resume)(struct target_s *target, int current, uint32_t address, int handle_breakpoints, int debug_execution);
61 int (*step)(struct target_s *target, int current, uint32_t address, int handle_breakpoints);
63 /* target reset control. assert reset can be invoked when OpenOCD and
64 * the target is out of sync.
66 * A typical example is that the target was power cycled while OpenOCD
67 * thought the target was halted or running.
69 * assert_reset() can therefore make no assumptions whatsoever about the
70 * state of the target
72 * Before assert_reset() for the target is invoked, a TRST/tms and
73 * chain validation is executed. TRST should not be asserted
74 * during target assert unless there is no way around it due to
75 * the way reset's are configured.
78 int (*assert_reset)(struct target_s *target);
79 int (*deassert_reset)(struct target_s *target);
80 int (*soft_reset_halt_imp)(struct target_s *target);
81 int (*soft_reset_halt)(struct target_s *target);
83 /**
84 * Target register access for GDB. Do @b not call this function
85 * directly, use target_get_gdb_reg_list() instead.
87 * Danger! this function will succeed even if the target is running
88 * and return a register list with dummy values.
90 * The reason is that GDB connection will fail without a valid register
91 * list, however it is after GDB is connected that monitor commands can
92 * be run to properly initialize the target
94 int (*get_gdb_reg_list)(struct target_s *target, struct reg_s **reg_list[], int *reg_list_size);
96 /* target memory access
97 * size: 1 = byte (8bit), 2 = half-word (16bit), 4 = word (32bit)
98 * count: number of items of <size>
100 int (*read_memory_imp)(struct target_s *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
102 * Target memory read callback. Do @b not call this function
103 * directly, use target_read_memory() instead.
105 int (*read_memory)(struct target_s *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
106 int (*write_memory_imp)(struct target_s *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
108 * Target memory write callback. Do @b not call this function
109 * directly, use target_write_memory() instead.
111 int (*write_memory)(struct target_s *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
114 * Write target memory in multiples of 4 bytes, optimized for
115 * writing large quantities of data. Do @b not call this
116 * function directly, use target_bulk_write_memory() instead.
118 int (*bulk_write_memory)(struct target_s *target, uint32_t address, uint32_t count, uint8_t *buffer);
120 int (*checksum_memory)(struct target_s *target, uint32_t address, uint32_t count, uint32_t* checksum);
121 int (*blank_check_memory)(struct target_s *target, uint32_t address, uint32_t count, uint32_t* blank);
124 * target break-/watchpoint control
125 * rw: 0 = write, 1 = read, 2 = access
127 * Target must be halted while this is invoked as this
128 * will actually set up breakpoints on target.
130 * The breakpoint hardware will be set up upon adding the first breakpoint.
132 * Upon GDB connection all breakpoints/watchpoints are cleared.
134 int (*add_breakpoint)(struct target_s *target, breakpoint_t *breakpoint);
136 /* remove breakpoint. hw will only be updated if the target is currently halted.
137 * However, this method can be invoked on unresponsive targets.
139 int (*remove_breakpoint)(struct target_s *target, breakpoint_t *breakpoint);
140 int (*add_watchpoint)(struct target_s *target, watchpoint_t *watchpoint);
141 /* remove watchpoint. hw will only be updated if the target is currently halted.
142 * However, this method can be invoked on unresponsive targets.
144 int (*remove_watchpoint)(struct target_s *target, watchpoint_t *watchpoint);
146 /* target algorithm support */
147 int (*run_algorithm_imp)(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, uint32_t entry_point, uint32_t exit_point, int timeout_ms, void *arch_info);
149 * Target algorithm support. Do @b not call this method directly,
150 * use target_run_algorithm() instead.
152 int (*run_algorithm)(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, uint32_t entry_point, uint32_t exit_point, int timeout_ms, void *arch_info);
154 int (*register_commands)(struct command_context_s *cmd_ctx);
156 /* called when target is created */
157 int (*target_create)(struct target_s *target, Jim_Interp *interp);
159 /* called for various config parameters */
160 /* returns JIM_CONTINUE - if option not understood */
161 /* otherwise: JIM_OK, or JIM_ERR, */
162 int (*target_jim_configure)(struct target_s *target, Jim_GetOptInfo *goi);
164 /* target commands specifically handled by the target */
165 /* returns JIM_OK, or JIM_ERR, or JIM_CONTINUE - if option not understood */
166 int (*target_jim_commands)(struct target_s *target, Jim_GetOptInfo *goi);
168 /* invoked after JTAG chain has been examined & validated. During
169 * this stage the target is examined and any additional setup is
170 * performed.
172 * invoked every time after the jtag chain has been validated/examined
174 int (*examine)(struct target_s *target);
175 /* Set up structures for target.
177 * It is illegal to talk to the target at this stage as this fn is invoked
178 * before the JTAG chain has been examined/verified
179 * */
180 int (*init_target)(struct command_context_s *cmd_ctx, struct target_s *target);
181 int (*quit)(void);
183 /* translate from virtual to physical address. Default implementation is successful
184 * no-op(i.e. virtual==physical).
186 int (*virt2phys)(struct target_s *target, uint32_t address, uint32_t *physical);
188 /* read directly from physical memory. caches are bypassed and untouched.
190 * If the target does not support disabling caches, leaving them untouched,
191 * then minimally the actual physical memory location will be read even
192 * if cache states are unchanged, flushed, etc.
194 * Default implementation is to call read_memory.
196 int (*read_phys_memory)(struct target_s *target, uint32_t phys_address, uint32_t size, uint32_t count, uint8_t *buffer);
199 * same as read_phys_memory, except that it writes...
201 int (*write_phys_memory)(struct target_s *target, uint32_t phys_address, uint32_t size, uint32_t count, uint8_t *buffer);
203 int (*mmu)(struct target_s *target, int *enabled);
205 /* Read coprocessor - arm specific. Default implementation returns error. */
206 int (*mrc)(struct target_s *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t CRn, uint32_t CRm, uint32_t *value);
208 /* Write coprocessor. Default implementation returns error. */
209 int (*mcr)(struct target_s *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t CRn, uint32_t CRm, uint32_t value);
212 #endif // TARGET_TYPE_H