Add target_get_name wrapper:
[fw/openocd] / src / target / target.h
index b11e2b6b45a01df19923e3e86f73c7efe7f1b8e1..91dd1b15422f4a7dfe1ca9ba8838147bfeb6fb03 100644 (file)
@@ -107,8 +107,18 @@ typedef struct working_area_s
 
 typedef struct target_type_s
 {
+       /**
+        * Name of the target.  Do @b not access this field directly, use
+        * target_get_name() instead.
+        */
        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 */
@@ -145,7 +155,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.
@@ -167,9 +179,17 @@ typedef struct target_type_s
         */
        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);
@@ -200,6 +220,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);
@@ -375,6 +399,46 @@ 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(const char *id);
 
+/**
+ * Get the target name.
+ *
+ * This routine is a wrapper for the target->type->name field.
+ */
+extern const char *target_get_name(struct target_s *target);
+
+/// @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.
@@ -383,6 +447,24 @@ extern target_t *get_target(const char *id);
  */
 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);