+int target_read_memory(struct target_s *target,
+ uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
+{
+ return target->type->read_memory(target, address, size, count, buffer);
+}
+
+int target_read_phys_memory(struct target_s *target,
+ uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
+{
+ return target->type->read_phys_memory(target, address, size, count, buffer);
+}
+
+int target_write_memory(struct target_s *target,
+ uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
+{
+ return target->type->write_memory(target, address, size, count, buffer);
+}
+
+int target_write_phys_memory(struct target_s *target,
+ uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
+{
+ return target->type->write_phys_memory(target, address, size, count, buffer);
+}
+
+int target_bulk_write_memory(struct target_s *target,
+ uint32_t address, uint32_t count, uint8_t *buffer)
+{
+ return target->type->bulk_write_memory(target, address, count, buffer);
+}
+
+int target_add_breakpoint(struct target_s *target,
+ struct breakpoint_s *breakpoint)
+{
+ return target->type->add_breakpoint(target, breakpoint);
+}
+int target_remove_breakpoint(struct target_s *target,
+ struct breakpoint_s *breakpoint)
+{
+ return target->type->remove_breakpoint(target, breakpoint);
+}
+
+int target_add_watchpoint(struct target_s *target,
+ struct watchpoint_s *watchpoint)
+{
+ return target->type->add_watchpoint(target, watchpoint);
+}
+int target_remove_watchpoint(struct target_s *target,
+ struct watchpoint_s *watchpoint)
+{
+ return target->type->remove_watchpoint(target, watchpoint);
+}
+
+int target_get_gdb_reg_list(struct target_s *target,
+ struct reg_s **reg_list[], int *reg_list_size)
+{
+ return target->type->get_gdb_reg_list(target, reg_list, reg_list_size);
+}
+int target_step(struct target_s *target,
+ int current, uint32_t address, int handle_breakpoints)
+{
+ return target->type->step(target, current, address, handle_breakpoints);
+}
+
+
+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,
+ uint32_t entry_point, uint32_t exit_point,
+ int timeout_ms, void *arch_info)
+{
+ return target->type->run_algorithm(target,
+ num_mem_params, mem_params, num_reg_params, reg_param,
+ entry_point, exit_point, timeout_ms, arch_info);
+}
+
+/// @returns @c true if the target has been examined.
+bool target_was_examined(struct target_s *target)
+{
+ return target->type->examined;
+}
+/// Sets the @c examined flag for the given target.
+void target_set_examined(struct target_s *target)
+{
+ target->type->examined = true;
+}
+// Reset the @c examined flag for the given target.
+void target_reset_examined(struct target_s *target)
+{
+ target->type->examined = false;
+}
+
+
+
+static int default_mrc(struct target_s *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t CRn, uint32_t CRm, uint32_t *value)
+{
+ LOG_ERROR("Not implemented");
+ return ERROR_FAIL;
+}
+
+static int default_mcr(struct target_s *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t CRn, uint32_t CRm, uint32_t value)
+{
+ LOG_ERROR("Not implemented");
+ return ERROR_FAIL;
+}
+
+static int arm_cp_check(struct target_s *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t CRn, uint32_t CRm)
+{
+ /* basic check */
+ if (!target_was_examined(target))
+ {
+ LOG_ERROR("Target not examined yet");
+ return ERROR_FAIL;
+ }
+
+ if ((cpnum <0) || (cpnum > 15))
+ {
+ LOG_ERROR("Illegal co-processor %d", cpnum);
+ return ERROR_FAIL;
+ }
+
+ return ERROR_OK;
+}
+
+int target_mrc(struct target_s *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t CRn, uint32_t CRm, uint32_t *value)
+{
+ int retval;
+
+ retval = arm_cp_check(target, cpnum, op1, op2, CRn, CRm);
+ if (retval != ERROR_OK)
+ return retval;
+
+ return target->type->mrc(target, cpnum, op1, op2, CRn, CRm, value);
+}
+
+int target_mcr(struct target_s *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t CRn, uint32_t CRm, uint32_t value)
+{
+ int retval;
+
+ retval = arm_cp_check(target, cpnum, op1, op2, CRn, CRm);
+ if (retval != ERROR_OK)
+ return retval;
+
+ return target->type->mcr(target, cpnum, op1, op2, CRn, CRm, value);
+}
+
+static int default_read_phys_memory(struct target_s *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
+{
+ int retval;
+ bool mmu;
+ retval = target->type->has_mmu(target, &mmu);
+ if (retval != ERROR_OK)
+ return retval;
+ if (mmu)
+ {
+ LOG_ERROR("Not implemented");
+ return ERROR_FAIL;
+ }
+ return target_read_memory(target, address, size, count, buffer);
+}
+
+static int default_write_phys_memory(struct target_s *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
+{
+ int retval;
+ bool mmu;
+ retval = target->type->has_mmu(target, &mmu);
+ if (retval != ERROR_OK)
+ return retval;
+ if (mmu)
+ {
+ LOG_ERROR("Not implemented");
+ return ERROR_FAIL;
+ }
+ return target_write_memory(target, address, size, count, buffer);
+}
+
+