+/*
+ * Write to target memory using the virtual address.
+ *
+ * Note that this fn is used to implement software breakpoints. Targets
+ * can implement support for software breakpoints to memory marked as read
+ * only by making this fn write to ram even if it is read only(MMU or
+ * MPUs).
+ *
+ * It is sufficient to implement for writing a single word(16 or 32 in
+ * ARM32/16 bit case) to write the breakpoint to ram.
+ *
+ * The target should also take care of "other things" to make sure that
+ * software breakpoints can be written using this function. E.g.
+ * when there is a separate instruction and data cache, this fn must
+ * make sure that the instruction cache is synced up to the potential
+ * code change that can happen as a result of the memory write(typically
+ * by invalidating the cache).
+ *
+ * The high level wrapper fn in target.c will break down this memory write
+ * request to multiple write requests to the target driver to e.g. guarantee
+ * that writing 4 bytes to an aligned address happens with a single 32 bit
+ * write operation, thus making this fn suitable to e.g. write to special
+ * peripheral registers which do not support byte operations.
+ */
+int target_write_buffer(struct target_s *target,
+ uint32_t address, uint32_t size, uint8_t *buffer);
+int target_read_buffer(struct target_s *target,
+ uint32_t address, uint32_t size, uint8_t *buffer);
+int target_checksum_memory(struct target_s *target,
+ uint32_t address, uint32_t size, uint32_t* crc);
+int target_blank_check_memory(struct target_s *target,
+ uint32_t address, uint32_t size, uint32_t* blank);
+int target_wait_state(target_t *target, enum target_state state, int ms);
+
+/** Return the *name* of this targets current state */
+const char *target_state_name( target_t *target );
+
+/* DANGER!!!!!
+ *
+ * if "area" passed in to target_alloc_working_area() points to a memory
+ * location that goes out of scope (e.g. a pointer on the stack), then
+ * the caller of target_alloc_working_area() is responsible for invoking
+ * target_free_working_area() before "area" goes out of scope.
+ *
+ * target_free_all_working_areas() will NULL out the "area" pointer
+ * upon resuming or resetting the CPU.
+ *
+ */
+int target_alloc_working_area(struct target_s *target,
+ uint32_t size, struct working_area **area);
+int target_free_working_area(struct target_s *target, struct working_area *area);
+int target_free_working_area_restore(struct target_s *target,
+ struct working_area *area, int restore);
+void target_free_all_working_areas(struct target_s *target);
+void target_free_all_working_areas_restore(struct target_s *target, int restore);
+
+extern target_t *all_targets;
+
+extern struct target_event_callback *target_event_callbacks;
+extern struct target_timer_callback *target_timer_callbacks;
+
+uint32_t target_buffer_get_u32(target_t *target, const uint8_t *buffer);
+uint16_t target_buffer_get_u16(target_t *target, const uint8_t *buffer);
+uint8_t target_buffer_get_u8 (target_t *target, const uint8_t *buffer);
+void target_buffer_set_u32(target_t *target, uint8_t *buffer, uint32_t value);
+void target_buffer_set_u16(target_t *target, uint8_t *buffer, uint16_t value);
+void target_buffer_set_u8 (target_t *target, uint8_t *buffer, uint8_t value);
+
+int target_read_u32(struct target_s *target, uint32_t address, uint32_t *value);
+int target_read_u16(struct target_s *target, uint32_t address, uint16_t *value);
+int target_read_u8(struct target_s *target, uint32_t address, uint8_t *value);
+int target_write_u32(struct target_s *target, uint32_t address, uint32_t value);
+int target_write_u16(struct target_s *target, uint32_t address, uint16_t value);
+int target_write_u8(struct target_s *target, uint32_t address, uint8_t value);