X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Ftarget%2Ftarget.h;h=3d9d8e9f90c348afcd0efde88b4788026be0c0b3;hb=17fa4de8541ac12fad2ce836aa61d22dbf1642c8;hp=a664dc34bcb0a007bd09c559045d62c5dc8f4bed;hpb=03f329604635db3299e139510e75fea7deb0f4bd;p=fw%2Fopenocd diff --git a/src/target/target.h b/src/target/target.h index a664dc34b..3d9d8e9f9 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -30,8 +30,6 @@ #include "algorithm.h" #include "command.h" -#include "replacements.h" - struct reg_s; struct trace_s; struct command_context_s; @@ -111,6 +109,12 @@ typedef struct target_type_s { char *name; + /** + * Indicates whether this target has been examined. + * + * Do @b not access this field directly, use target_was_examined() + * target_set_examined(), and target_reset_examined(). + */ int examined; /* poll current target status */ @@ -147,7 +151,9 @@ typedef struct target_type_s int (*soft_reset_halt_imp)(struct target_s *target); int (*soft_reset_halt)(struct target_s *target); - /* target register access for gdb. + /** + * Target register access for GDB. Do @b not call this function + * directly, use target_get_gdb_reg_list() instead. * * Danger! this function will succeed even if the target is running * and return a register list with dummy values. @@ -163,11 +169,23 @@ typedef struct target_type_s * count: number of items of */ int (*read_memory_imp)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); + /** + * Target memory read callback. Do @b not call this function + * directly, use target_read_memory() instead. + */ int (*read_memory)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); int (*write_memory_imp)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); + /** + * Target memory write callback. Do @b not call this function + * directly, use target_write_memory() instead. + */ int (*write_memory)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); - /* write target memory in multiples of 4 byte, optimized for writing large quantities of data */ + /** + * Write target memory in multiples of 4 bytes, optimized for + * writing large quantities of data. Do @b not call this + * function directly, use target_bulk_write_memory() instead. + */ int (*bulk_write_memory)(struct target_s *target, u32 address, u32 count, u8 *buffer); int (*checksum_memory)(struct target_s *target, u32 address, u32 count, u32* checksum); @@ -198,6 +216,10 @@ typedef struct target_type_s /* target algorithm support */ 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); + /** + * Target algorithm support. Do @b not call this method directly, + * use target_run_algorithm() instead. + */ 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); int (*register_commands)(struct command_context_s *cmd_ctx); @@ -320,8 +342,6 @@ enum target_event TARGET_EVENT_GDB_FLASH_WRITE_END, }; -extern const Jim_Nvp nvp_target_event[]; - struct target_event_action_s { enum target_event event; Jim_Obj *body; @@ -373,7 +393,67 @@ extern int target_call_timer_callbacks_now(void); extern target_t* get_current_target(struct command_context_s *cmd_ctx); extern int get_num_by_target(target_t *query_target); -extern target_t* get_target_by_num(int num); +extern target_t *get_target(const char *id); + +/// @returns @c true if the target has been examined. +extern bool target_was_examined(struct target_s *target); +/// Sets the @c examined flag for the given target. +extern void target_set_examined(struct target_s *target); +/// Reset the @c examined flag for the given target. +extern void target_reset_examined(struct target_s *target); + +/** + * Obtain the registers for GDB. + * + * This routine is a wrapper for target->type->get_gdb_reg_list. + */ +extern int target_get_gdb_reg_list(struct target_s *target, + struct reg_s **reg_list[], int *reg_list_size); + +/** + * Step the target. + * + * This routine is a wrapper for target->type->step. + */ +int target_step(struct target_s *target, + int current, u32 address, int handle_breakpoints); +/** + * Run an algorithm on the @a target given. + * + * This routine is a wrapper for target->type->run_algorithm. + */ +extern int target_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); + +/** + * Read @count items of @a size bytes from the memory of @a target at + * the @a address given. + * + * This routine is a wrapper for target->type->read_memory. + */ +extern int target_read_memory(struct target_s *target, + u32 address, u32 size, u32 count, u8 *buffer); +/** + * Write @count items of @a size bytes to the memory of @a target at + * the @a address given. + * + * This routine is wrapper for target->type->write_memory. + */ +extern int target_write_memory(struct target_s *target, + u32 address, u32 size, u32 count, u8 *buffer); + +/** + * Write @count items of 4 bytes to the memory of @a target at + * the @a address given. Because it operates only on whole words, + * this should be faster than target_write_memory(). + * + * This routine is wrapper for target->type->bulk_write_memory. + */ +extern int target_bulk_write_memory(struct target_s *target, + u32 address, u32 count, u8 *buffer); extern int target_write_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer); extern int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer); @@ -403,9 +483,9 @@ extern target_t *all_targets; extern target_event_callback_t *target_event_callbacks; extern target_timer_callback_t *target_timer_callbacks; -extern u32 target_buffer_get_u32(target_t *target, u8 *buffer); -extern u16 target_buffer_get_u16(target_t *target, u8 *buffer); -extern u8 target_buffer_get_u8 (target_t *target, u8 *buffer); +extern u32 target_buffer_get_u32(target_t *target, const u8 *buffer); +extern u16 target_buffer_get_u16(target_t *target, const u8 *buffer); +extern u8 target_buffer_get_u8 (target_t *target, const u8 *buffer); extern void target_buffer_set_u32(target_t *target, u8 *buffer, u32 value); extern void target_buffer_set_u16(target_t *target, u8 *buffer, u16 value); extern void target_buffer_set_u8 (target_t *target, u8 *buffer, u8 value);