use COMMAND_HANDLER macro to define all commands
[fw/openocd] / src / jtag / vsllink.c
index 1f1b86705621f8c73cca256fb2cb669013c5d4f5..decca16c61eecb1fad46c6a35696d922309f2859 100644 (file)
@@ -176,23 +176,6 @@ typedef struct
 static int pending_scan_results_length;
 static pending_scan_result_t pending_scan_results_buffer[MAX_PENDING_SCAN_RESULTS];
 
-/* External interface functions */
-static int vsllink_execute_queue(void);
-static int vsllink_speed(int speed);
-static int vsllink_khz(int khz, int *jtag_speed);
-static int vsllink_speed_div(int jtag_speed, int *khz);
-static int vsllink_register_commands(struct command_context_s *cmd_ctx);
-static int vsllink_init(void);
-static int vsllink_quit(void);
-
-/* CLI command handler functions */
-static int vsllink_handle_usb_vid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-static int vsllink_handle_usb_pid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-static int vsllink_handle_usb_bulkin_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-static int vsllink_handle_usb_bulkout_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-static int vsllink_handle_usb_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-static int vsllink_handle_mode_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-
 /* Queue command functions */
 static void vsllink_end_state(tap_state_t state);
 static void vsllink_state_move_dma(void);
@@ -255,21 +238,6 @@ static int last_tms;
 
 static vsllink_jtag_t* vsllink_jtag_handle = NULL;
 
-/***************************************************************************/
-/* External interface implementation */
-
-jtag_interface_t vsllink_interface =
-{
-       .name = "vsllink",
-       .execute_queue = vsllink_execute_queue,
-       .speed = vsllink_speed,
-       .khz = vsllink_khz,
-       .speed_div = vsllink_speed_div,
-       .register_commands = vsllink_register_commands,
-       .init = vsllink_init,
-       .quit = vsllink_quit
-};
-
 static void reset_command_pointer(void)
 {
        if (vsllink_mode == VSLLINK_MODE_NORMAL)
@@ -1357,25 +1325,7 @@ static void vsllink_simple_command(uint8_t command)
        }
 }
 
-static int vsllink_register_commands(struct command_context_s *cmd_ctx)
-{
-       register_command(cmd_ctx, NULL, "vsllink_usb_vid", vsllink_handle_usb_vid_command,
-                                       COMMAND_CONFIG, NULL);
-       register_command(cmd_ctx, NULL, "vsllink_usb_pid", vsllink_handle_usb_pid_command,
-                                       COMMAND_CONFIG, NULL);
-       register_command(cmd_ctx, NULL, "vsllink_usb_bulkin", vsllink_handle_usb_bulkin_command,
-                                       COMMAND_CONFIG, NULL);
-       register_command(cmd_ctx, NULL, "vsllink_usb_bulkout", vsllink_handle_usb_bulkout_command,
-                                       COMMAND_CONFIG, NULL);
-       register_command(cmd_ctx, NULL, "vsllink_usb_interface", vsllink_handle_usb_interface_command,
-                                       COMMAND_CONFIG, NULL);
-       register_command(cmd_ctx, NULL, "vsllink_mode", vsllink_handle_mode_command,
-                                       COMMAND_CONFIG, NULL);
-
-       return ERROR_OK;
-}
-
-static int vsllink_handle_mode_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+COMMAND_HANDLER(vsllink_handle_mode_command)
 {
        if (argc != 1) {
                LOG_ERROR("parameter error, should be one parameter for VID");
@@ -1399,7 +1349,7 @@ static int vsllink_handle_mode_command(struct command_context_s *cmd_ctx, char *
        return ERROR_OK;
 }
 
-static int vsllink_handle_usb_vid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+COMMAND_HANDLER(vsllink_handle_usb_vid_command)
 {
        if (argc != 1)
        {
@@ -1411,7 +1361,7 @@ static int vsllink_handle_usb_vid_command(struct command_context_s *cmd_ctx, cha
        return ERROR_OK;
 }
 
-static int vsllink_handle_usb_pid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+COMMAND_HANDLER(vsllink_handle_usb_pid_command)
 {
        if (argc != 1)
        {
@@ -1422,7 +1372,7 @@ static int vsllink_handle_usb_pid_command(struct command_context_s *cmd_ctx, cha
        return ERROR_OK;
 }
 
-static int vsllink_handle_usb_bulkin_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+COMMAND_HANDLER(vsllink_handle_usb_bulkin_command)
 {
        if (argc != 1)
        {
@@ -1437,7 +1387,7 @@ static int vsllink_handle_usb_bulkin_command(struct command_context_s *cmd_ctx,
        return ERROR_OK;
 }
 
-static int vsllink_handle_usb_bulkout_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+COMMAND_HANDLER(vsllink_handle_usb_bulkout_command)
 {
        if (argc != 1)
        {
@@ -1445,14 +1395,14 @@ static int vsllink_handle_usb_bulkout_command(struct command_context_s *cmd_ctx,
                return ERROR_OK;
        }
 
-       COMMAND_PARSE_NUMBER(u8, args[0], vsllink_usb_bulkin);
+       COMMAND_PARSE_NUMBER(u8, args[0], vsllink_usb_bulkout);
 
        vsllink_usb_bulkout &= ~0x80;
 
        return ERROR_OK;
 }
 
-static int vsllink_handle_usb_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+COMMAND_HANDLER(vsllink_handle_usb_interface_command)
 {
        if (argc != 1)
        {
@@ -1932,3 +1882,38 @@ static void vsllink_debug_buffer(uint8_t *buffer, int length)
        }
 }
 #endif // _DEBUG_USB_COMMS_ || _DEBUG_JTAG_IO_
+
+static int vsllink_register_commands(struct command_context_s *cmd_ctx)
+{
+       register_command(cmd_ctx, NULL, "vsllink_usb_vid",
+                       vsllink_handle_usb_vid_command, COMMAND_CONFIG,
+                       NULL);
+       register_command(cmd_ctx, NULL, "vsllink_usb_pid",
+                       vsllink_handle_usb_pid_command, COMMAND_CONFIG,
+                       NULL);
+       register_command(cmd_ctx, NULL, "vsllink_usb_bulkin",
+                       vsllink_handle_usb_bulkin_command, COMMAND_CONFIG,
+                       NULL);
+       register_command(cmd_ctx, NULL, "vsllink_usb_bulkout",
+                       vsllink_handle_usb_bulkout_command, COMMAND_CONFIG,
+                       NULL);
+       register_command(cmd_ctx, NULL, "vsllink_usb_interface",
+                       vsllink_handle_usb_interface_command, COMMAND_CONFIG,
+                       NULL);
+       register_command(cmd_ctx, NULL, "vsllink_mode",
+                       vsllink_handle_mode_command, COMMAND_CONFIG,
+                       NULL);
+
+       return ERROR_OK;
+}
+
+jtag_interface_t vsllink_interface = {
+               .name = "vsllink",
+               .register_commands = &vsllink_register_commands,
+               .init = &vsllink_init,
+               .quit = &vsllink_quit,
+               .khz = &vsllink_khz,
+               .speed = &vsllink_speed,
+               .speed_div = &vsllink_speed_div,
+               .execute_queue = &vsllink_execute_queue,
+       };