]> git.sur5r.net Git - openocd/blob - src/target/target_type.h
Transform 'u8' to 'uint8_t' in src/target
[openocd] / src / target / target_type.h
1 #ifndef TARGET_TYPE_H
2 #define TARGET_TYPE_H
3
4 #include "types.h"
5
6 struct target_s;
7
8 struct target_type_s
9 {
10         /**
11          * Name of the target.  Do @b not access this field directly, use
12          * target_get_name() instead.
13          */
14         char *name;
15
16         /**
17          * Indicates whether this target has been examined.
18          *
19          * Do @b not access this field directly, use target_was_examined()
20          * target_set_examined(), and target_reset_examined().
21          */
22         int examined;
23
24         /* poll current target status */
25         int (*poll)(struct target_s *target);
26         /* Invoked only from target_arch_state().
27          * Issue USER() w/architecture specific status.  */
28         int (*arch_state)(struct target_s *target);
29
30         /* target request support */
31         int (*target_request_data)(struct target_s *target, u32 size, uint8_t *buffer);
32
33         /* halt will log a warning, but return ERROR_OK if the target is already halted. */
34         int (*halt)(struct target_s *target);
35         int (*resume)(struct target_s *target, int current, u32 address, int handle_breakpoints, int debug_execution);
36         int (*step)(struct target_s *target, int current, u32 address, int handle_breakpoints);
37
38         /* target reset control. assert reset can be invoked when OpenOCD and
39          * the target is out of sync.
40          *
41          * A typical example is that the target was power cycled while OpenOCD
42          * thought the target was halted or running.
43          *
44          * assert_reset() can therefore make no assumptions whatsoever about the
45          * state of the target
46          *
47          * Before assert_reset() for the target is invoked, a TRST/tms and
48          * chain validation is executed. TRST should not be asserted
49          * during target assert unless there is no way around it due to
50          * the way reset's are configured.
51          *
52          */
53         int (*assert_reset)(struct target_s *target);
54         int (*deassert_reset)(struct target_s *target);
55         int (*soft_reset_halt_imp)(struct target_s *target);
56         int (*soft_reset_halt)(struct target_s *target);
57
58         /**
59          * Target register access for GDB.  Do @b not call this function
60          * directly, use target_get_gdb_reg_list() instead.
61          *
62          * Danger! this function will succeed even if the target is running
63          * and return a register list with dummy values.
64          *
65          * The reason is that GDB connection will fail without a valid register
66          * list, however it is after GDB is connected that monitor commands can
67          * be run to properly initialize the target
68          */
69         int (*get_gdb_reg_list)(struct target_s *target, struct reg_s **reg_list[], int *reg_list_size);
70
71         /* target memory access
72         * size: 1 = byte (8bit), 2 = half-word (16bit), 4 = word (32bit)
73         * count: number of items of <size>
74         */
75         int (*read_memory_imp)(struct target_s *target, u32 address, u32 size, u32 count, uint8_t *buffer);
76         /**
77          * Target memory read callback.  Do @b not call this function
78          * directly, use target_read_memory() instead.
79          */
80         int (*read_memory)(struct target_s *target, u32 address, u32 size, u32 count, uint8_t *buffer);
81         int (*write_memory_imp)(struct target_s *target, u32 address, u32 size, u32 count, uint8_t *buffer);
82         /**
83          * Target memory write callback.  Do @b not call this function
84          * directly, use target_write_memory() instead.
85          */
86         int (*write_memory)(struct target_s *target, u32 address, u32 size, u32 count, uint8_t *buffer);
87
88         /**
89          * Write target memory in multiples of 4 bytes, optimized for
90          * writing large quantities of data.  Do @b not call this
91          * function directly, use target_bulk_write_memory() instead.
92          */
93         int (*bulk_write_memory)(struct target_s *target, u32 address, u32 count, uint8_t *buffer);
94
95         int (*checksum_memory)(struct target_s *target, u32 address, u32 count, u32* checksum);
96         int (*blank_check_memory)(struct target_s *target, u32 address, u32 count, u32* blank);
97
98         /*
99          * target break-/watchpoint control
100          * rw: 0 = write, 1 = read, 2 = access
101          *
102          * Target must be halted while this is invoked as this
103          * will actually set up breakpoints on target.
104          *
105          * The breakpoint hardware will be set up upon adding the first breakpoint.
106          *
107          * Upon GDB connection all breakpoints/watchpoints are cleared.
108          */
109         int (*add_breakpoint)(struct target_s *target, breakpoint_t *breakpoint);
110
111         /* remove breakpoint. hw will only be updated if the target is currently halted.
112          * However, this method can be invoked on unresponsive targets.
113          */
114         int (*remove_breakpoint)(struct target_s *target, breakpoint_t *breakpoint);
115         int (*add_watchpoint)(struct target_s *target, watchpoint_t *watchpoint);
116         /* remove watchpoint. hw will only be updated if the target is currently halted.
117          * However, this method can be invoked on unresponsive targets.
118          */
119         int (*remove_watchpoint)(struct target_s *target, watchpoint_t *watchpoint);
120
121         /* target algorithm support */
122         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, u32 entry_point, u32 exit_point, int timeout_ms, void *arch_info);
123         /**
124          * Target algorithm support.  Do @b not call this method directly,
125          * use target_run_algorithm() instead.
126          */
127         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, u32 entry_point, u32 exit_point, int timeout_ms, void *arch_info);
128
129         int (*register_commands)(struct command_context_s *cmd_ctx);
130
131         /* called when target is created */
132         int (*target_create)( struct target_s *target, Jim_Interp *interp );
133
134         /* called for various config parameters */
135         /* returns JIM_CONTINUE - if option not understood */
136         /* otherwise: JIM_OK, or JIM_ERR, */
137         int (*target_jim_configure)( struct target_s *target, Jim_GetOptInfo *goi );
138
139         /* target commands specifically handled by the target */
140         /* returns JIM_OK, or JIM_ERR, or JIM_CONTINUE - if option not understood */
141         int (*target_jim_commands)( struct target_s *target, Jim_GetOptInfo *goi );
142
143         /* invoked after JTAG chain has been examined & validated. During
144          * this stage the target is examined and any additional setup is
145          * performed.
146          *
147          * invoked every time after the jtag chain has been validated/examined
148          */
149         int (*examine)(struct target_s *target);
150         /* Set up structures for target.
151          *
152          * It is illegal to talk to the target at this stage as this fn is invoked
153          * before the JTAG chain has been examined/verified
154          * */
155         int (*init_target)(struct command_context_s *cmd_ctx, struct target_s *target);
156         int (*quit)(void);
157
158         int (*virt2phys)(struct target_s *target, u32 address, u32 *physical);
159         int (*mmu)(struct target_s *target, int *enabled);
160
161 };
162
163 #endif // TARGET_TYPE_H