#include "algorithm.h"
#include "command.h"
-#include "replacements.h"
-
struct reg_s;
struct trace_s;
struct command_context_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 */
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.
* count: number of items of <size>
*/
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);
/* 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);
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;
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);
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);