X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fjtag%2Fdrivers%2Fulink.c;h=550df1c93f1d66c11c7c909827f5cd099447bac1;hp=94f6c31534df78c39f1c332ab8d9935e65a9a98a;hb=ebf2d733409e140cb220d95eb3a915fed14d69a4;hpb=f684252b2530d86f3a8330940105b86c770231f1 diff --git a/src/jtag/drivers/ulink.c b/src/jtag/drivers/ulink.c index 94f6c31534..550df1c93f 100644 --- a/src/jtag/drivers/ulink.c +++ b/src/jtag/drivers/ulink.c @@ -13,9 +13,7 @@ * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * along with this program. If not, see . * ***************************************************************************/ #ifdef HAVE_CONFIG_H @@ -26,7 +24,7 @@ #include #include #include -#include +#include #include "OpenULINK/include/msgtypes.h" /** USB Vendor ID of ULINK device in unconfigured state (no firmware loaded @@ -123,14 +121,14 @@ enum ulink_delay_type { * The last command sets #needs_postprocessing to true. */ struct ulink_cmd { - uint8_t id; /* /< ULINK command ID */ + uint8_t id; /**< ULINK command ID */ - uint8_t *payload_out; /* /< OUT direction payload data */ - uint8_t payload_out_size; /* /< OUT direction payload size for this command */ + uint8_t *payload_out; /**< OUT direction payload data */ + uint8_t payload_out_size; /**< OUT direction payload size for this command */ - uint8_t *payload_in_start; /* /< Pointer to first element of IN payload array */ - uint8_t *payload_in; /* /< Pointer where IN payload shall be stored */ - uint8_t payload_in_size;/* /< IN direction payload size for this command */ + uint8_t *payload_in_start; /**< Pointer to first element of IN payload array */ + uint8_t *payload_in; /**< Pointer where IN payload shall be stored */ + uint8_t payload_in_size; /**< IN direction payload size for this command */ /** Indicates if this command needs post-processing */ bool needs_postprocessing; @@ -141,7 +139,7 @@ struct ulink_cmd { /** Pointer to corresponding OpenOCD command for post-processing */ struct jtag_command *cmd_origin; - struct ulink_cmd *next; /* /< Pointer to next command (linked list) */ + struct ulink_cmd *next; /**< Pointer to next command (linked list) */ }; /** Describes one driver instance */ @@ -150,15 +148,15 @@ struct ulink { struct libusb_device_handle *usb_device_handle; enum ulink_type type; - int delay_scan_in; /* /< Delay value for SCAN_IN commands */ - int delay_scan_out; /* /< Delay value for SCAN_OUT commands */ - int delay_scan_io; /* /< Delay value for SCAN_IO commands */ - int delay_clock_tck; /* /< Delay value for CLOCK_TMS commands */ - int delay_clock_tms; /* /< Delay value for CLOCK_TCK commands */ + int delay_scan_in; /**< Delay value for SCAN_IN commands */ + int delay_scan_out; /**< Delay value for SCAN_OUT commands */ + int delay_scan_io; /**< Delay value for SCAN_IO commands */ + int delay_clock_tck; /**< Delay value for CLOCK_TMS commands */ + int delay_clock_tms; /**< Delay value for CLOCK_TCK commands */ - int commands_in_queue; /* /< Number of commands in queue */ - struct ulink_cmd *queue_start; /* /< Pointer to first command in queue */ - struct ulink_cmd *queue_end; /* /< Pointer to last command in queue */ + int commands_in_queue; /**< Number of commands in queue */ + struct ulink_cmd *queue_start; /**< Pointer to first command in queue */ + struct ulink_cmd *queue_end; /**< Pointer to last command in queue */ }; /**************************** Function Prototypes *****************************/ @@ -169,9 +167,9 @@ int ulink_usb_close(struct ulink **device); /* ULINK MCU (Cypress EZ-USB) specific functions */ int ulink_cpu_reset(struct ulink *device, unsigned char reset_bit); -int ulink_load_firmware_and_renumerate(struct ulink **device, char *filename, +int ulink_load_firmware_and_renumerate(struct ulink **device, const char *filename, uint32_t delay); -int ulink_load_firmware(struct ulink *device, char *filename); +int ulink_load_firmware(struct ulink *device, const char *filename); int ulink_write_firmware_section(struct ulink *device, struct image *firmware_image, int section_index); @@ -193,6 +191,7 @@ int ulink_execute_queued_commands(struct ulink *device, int timeout); const char *ulink_cmd_id_string(uint8_t id); void ulink_print_command(struct ulink_cmd *ulink_cmd); void ulink_print_queue(struct ulink *device); +static int ulink_calculate_frequency(enum ulink_delay_type type, int delay, long *f); #endif int ulink_append_scan_cmd(struct ulink *device, @@ -225,7 +224,6 @@ int ulink_append_test_cmd(struct ulink *device); /* OpenULINK TCK frequency helper functions */ int ulink_calculate_delay(enum ulink_delay_type type, long f, int *delay); -int ulink_calculate_frequency(enum ulink_delay_type type, int delay, long *f); /* Interface between OpenULINK and OpenOCD */ static void ulink_set_end_state(tap_state_t endstate); @@ -362,7 +360,7 @@ int ulink_cpu_reset(struct ulink *device, unsigned char reset_bit) * @return on failure: ERROR_FAIL */ int ulink_load_firmware_and_renumerate(struct ulink **device, - char *filename, uint32_t delay) + const char *filename, uint32_t delay) { int ret; @@ -397,7 +395,7 @@ int ulink_load_firmware_and_renumerate(struct ulink **device, * @return on success: ERROR_OK * @return on failure: ERROR_FAIL */ -int ulink_load_firmware(struct ulink *device, char *filename) +int ulink_load_firmware(struct ulink *device, const char *filename) { struct image ulink_firmware_image; int ret, i; @@ -461,9 +459,6 @@ int ulink_write_firmware_section(struct ulink *device, LOG_DEBUG("section %02i at addr 0x%04x (size 0x%04x)", section_index, addr, size); - if (data == NULL) - return ERROR_FAIL; - /* Copy section contents to local buffer */ ret = image_read_section(firmware_image, section_index, 0, size, data, &size_read); @@ -517,8 +512,8 @@ void ulink_print_signal_states(uint8_t input_signals, uint8_t output_signals) (input_signals & SIGNAL_TDO ? 1 : 0), (output_signals & SIGNAL_TMS ? 1 : 0), (output_signals & SIGNAL_TCK ? 1 : 0), - (output_signals & SIGNAL_TRST ? 0 : 1),/* TRST and RESET are inverted */ - (output_signals & SIGNAL_RESET ? 0 : 1)); /* by hardware */ + (output_signals & SIGNAL_TRST ? 0 : 1), /* Inverted by hardware */ + (output_signals & SIGNAL_RESET ? 0 : 1)); /* Inverted by hardware */ } /**************** OpenULINK command generation helper functions ***************/ @@ -1372,6 +1367,7 @@ int ulink_calculate_delay(enum ulink_delay_type type, long f, int *delay) return ERROR_OK; } +#ifdef _DEBUG_JTAG_IO_ /** * Calculate frequency for a given delay value. * @@ -1386,7 +1382,7 @@ int ulink_calculate_delay(enum ulink_delay_type type, long f, int *delay) * @return on success: ERROR_OK * @return on failure: ERROR_FAIL */ -int ulink_calculate_frequency(enum ulink_delay_type type, int delay, long *f) +static int ulink_calculate_frequency(enum ulink_delay_type type, int delay, long *f) { float t, f_float, f_rounded; @@ -1435,6 +1431,7 @@ int ulink_calculate_frequency(enum ulink_delay_type type, int delay, long *f) return ERROR_OK; } +#endif /******************* Interface between OpenULINK and OpenOCD ******************/ @@ -2069,7 +2066,7 @@ static int ulink_khz(int khz, int *jtag_speed) } #ifdef _DEBUG_JTAG_IO_ - long f_tck, f_tms, f_scan_in, f_scan_out, f_scan_io; + long f_tck = 0, f_tms = 0, f_scan_in = 0, f_scan_out = 0, f_scan_io = 0; ulink_calculate_frequency(DELAY_CLOCK_TCK, ulink_handle->delay_clock_tck, &f_tck); @@ -2284,7 +2281,7 @@ COMMAND_HANDLER(ulink_download_firmware_handler) LOG_INFO("Downloading ULINK firmware image %s", CMD_ARGV[0]); /* Download firmware image in CMD_ARGV[0] */ - ret = ulink_load_firmware_and_renumerate(&ulink_handle, (char *)CMD_ARGV[0], + ret = ulink_load_firmware_and_renumerate(&ulink_handle, CMD_ARGV[0], ULINK_RENUMERATION_DELAY); return ret;