From b58239e4c03c440ac89b36c9de917224a8439332 Mon Sep 17 00:00:00 2001 From: Zachary T Welch Date: Sat, 21 Nov 2009 10:20:56 -0800 Subject: [PATCH] jtag: remove useless forward declarations Removes some more useless forward declarations from a few JTAG drivers. Moves interface and bit-bang structure defitions below their callbacks. --- src/jtag/arm-jtag-ew.c | 30 ++++++------------ src/jtag/dummy.c | 69 +++++++++++++++++------------------------- src/jtag/jlink.c | 32 +++++++------------- src/jtag/presto.c | 56 ++++++++++++---------------------- src/jtag/usbprog.c | 29 +++++------------- 5 files changed, 76 insertions(+), 140 deletions(-) diff --git a/src/jtag/arm-jtag-ew.c b/src/jtag/arm-jtag-ew.c index 18b353ac..46dacc6d 100644 --- a/src/jtag/arm-jtag-ew.c +++ b/src/jtag/arm-jtag-ew.c @@ -55,14 +55,6 @@ static uint8_t usb_in_buffer[ARMJTAGEW_IN_BUFFER_SIZE]; static uint8_t usb_out_buffer[ARMJTAGEW_OUT_BUFFER_SIZE]; -/* External interface functions */ -static int armjtagew_execute_queue(void); -static int armjtagew_speed(int speed); -static int armjtagew_khz(int khz, int *jtag_speed); -static int armjtagew_register_commands(struct command_context *cmd_ctx); -static int armjtagew_init(void); -static int armjtagew_quit(void); - /* Queue command functions */ static void armjtagew_end_state(tap_state_t state); static void armjtagew_state_move(void); @@ -105,18 +97,6 @@ static struct armjtagew* armjtagew_handle; /***************************************************************************/ /* External interface implementation */ -struct jtag_interface armjtagew_interface = -{ - .name = "arm-jtag-ew", - .execute_queue = armjtagew_execute_queue, - .speed = armjtagew_speed, - .khz = armjtagew_khz, - .register_commands = armjtagew_register_commands, - .init = armjtagew_init, - .quit = armjtagew_quit -}; - - static int armjtagew_execute_queue(void) { struct jtag_command *cmd = jtag_command_queue; @@ -529,6 +509,16 @@ static int armjtagew_register_commands(struct command_context *cmd_ctx) return ERROR_OK; } +struct jtag_interface armjtagew_interface = { + .name = "arm-jtag-ew", + .execute_queue = &armjtagew_execute_queue, + .speed = &armjtagew_speed, + .khz = &armjtagew_khz, + .register_commands = &armjtagew_register_commands, + .init = &armjtagew_init, + .quit = &armjtagew_quit, + }; + /***************************************************************************/ /* ARM-JTAG-EW tap functions */ diff --git a/src/jtag/dummy.c b/src/jtag/dummy.c index 324ea7e9..05167900 100644 --- a/src/jtag/dummy.c +++ b/src/jtag/dummy.c @@ -35,45 +35,6 @@ static int clock_count; /* count clocks in any stable state, only stable static uint32_t dummy_data; -static int dummy_speed(int speed); -static int dummy_register_commands(struct command_context *cmd_ctx); -static int dummy_init(void); -static int dummy_quit(void); -static int dummy_khz(int khz, int *jtag_speed); -static int dummy_speed_div(int speed, int *khz); - - -/* The dummy driver is used to easily check the code path - * where the target is unresponsive. - */ -struct jtag_interface dummy_interface = -{ - .name = "dummy", - - .execute_queue = bitbang_execute_queue, - - .speed = dummy_speed, - .register_commands = dummy_register_commands, - .khz = dummy_khz, - .speed_div = dummy_speed_div, - - .init = dummy_init, - .quit = dummy_quit, -}; - -static int dummy_read(void); -static void dummy_write(int tck, int tms, int tdi); -static void dummy_reset(int trst, int srst); -static void dummy_led(int on); - -static struct bitbang_interface dummy_bitbang = -{ - .read = dummy_read, - .write = dummy_write, - .reset = dummy_reset, - .blink = dummy_led -}; - static int dummy_read(void) { int data = 1 & dummy_data; @@ -129,6 +90,18 @@ static void dummy_reset(int trst, int srst) LOG_DEBUG("reset to: %s", tap_state_name(dummy_state)); } +static void dummy_led(int on) +{ +} + +static struct bitbang_interface dummy_bitbang = { + .read = &dummy_read, + .write = &dummy_write, + .reset = &dummy_reset, + .blink = &dummy_led, + }; + + static int dummy_khz(int khz, int *jtag_speed) { if (khz == 0) @@ -178,7 +151,19 @@ static int dummy_quit(void) return ERROR_OK; } -static void dummy_led(int on) -{ -} +/* The dummy driver is used to easily check the code path + * where the target is unresponsive. + */ +struct jtag_interface dummy_interface = { + .name = "dummy", + + .execute_queue = &bitbang_execute_queue, + + .speed = &dummy_speed, + .register_commands = &dummy_register_commands, + .khz = &dummy_khz, + .speed_div = &dummy_speed_div, + .init = &dummy_init, + .quit = &dummy_quit, + }; diff --git a/src/jtag/jlink.c b/src/jtag/jlink.c index dbbddb86..ebc9acd2 100644 --- a/src/jtag/jlink.c +++ b/src/jtag/jlink.c @@ -82,15 +82,6 @@ static uint8_t usb_emu_result_buffer[JLINK_EMU_RESULT_BUFFER_SIZE]; /* max speed 12MHz v5.0 jlink */ #define JLINK_MAX_SPEED 12000 -/* External interface functions */ -static int jlink_execute_queue(void); -static int jlink_speed(int speed); -static int jlink_speed_div(int speed, int* khz); -static int jlink_khz(int khz, int *jtag_speed); -static int jlink_register_commands(struct command_context *cmd_ctx); -static int jlink_init(void); -static int jlink_quit(void); - /* Queue command functions */ static void jlink_end_state(tap_state_t state); static void jlink_state_move(void); @@ -134,18 +125,6 @@ static struct jlink* jlink_handle; /***************************************************************************/ /* External interface implementation */ -struct jtag_interface jlink_interface = -{ - .name = "jlink", - .execute_queue = jlink_execute_queue, - .speed = jlink_speed, - .speed_div = jlink_speed_div, - .khz = jlink_khz, - .register_commands = jlink_register_commands, - .init = jlink_init, - .quit = jlink_quit -}; - static void jlink_execute_runtest(struct jtag_command *cmd) { DEBUG_JTAG_IO("runtest %i cycles, end in %i", @@ -661,6 +640,17 @@ static int jlink_register_commands(struct command_context *cmd_ctx) return ERROR_OK; } +struct jtag_interface jlink_interface = { + .name = "jlink", + .execute_queue = &jlink_execute_queue, + .speed = &jlink_speed, + .speed_div = &jlink_speed_div, + .khz = &jlink_khz, + .register_commands = &jlink_register_commands, + .init = &jlink_init, + .quit = &jlink_quit, + }; + /***************************************************************************/ /* J-Link tap functions */ diff --git a/src/jtag/presto.c b/src/jtag/presto.c index 1d6bc1db..437e2c08 100644 --- a/src/jtag/presto.c +++ b/src/jtag/presto.c @@ -39,42 +39,6 @@ #error "BUG: either FTD2XX and LIBFTDI has to be used" #endif -static int presto_jtag_speed(int speed); -static int presto_jtag_khz(int khz, int *jtag_speed); -static int presto_jtag_speed_div(int speed, int *khz); -static int presto_jtag_register_commands(struct command_context *cmd_ctx); -static int presto_jtag_init(void); -static int presto_jtag_quit(void); - -struct jtag_interface presto_interface = -{ - .name = "presto", - .execute_queue = bitq_execute_queue, - .speed = presto_jtag_speed, - .khz = presto_jtag_khz, - .speed_div = presto_jtag_speed_div, - .register_commands = presto_jtag_register_commands, - .init = presto_jtag_init, - .quit = presto_jtag_quit, -}; - -static int presto_bitq_out(int tms, int tdi, int tdo_req); -static int presto_bitq_flush(void); -static int presto_bitq_sleep(unsigned long us); -static int presto_bitq_reset(int trst, int srst); -static int presto_bitq_in_rdy(void); -static int presto_bitq_in(void); - -static struct bitq_interface presto_bitq = -{ - .out = presto_bitq_out, - .flush = presto_bitq_flush, - .sleep = presto_bitq_sleep, - .reset = presto_bitq_reset, - .in_rdy = presto_bitq_in_rdy, - .in = presto_bitq_in, -}; - /* -------------------------------------------------------------------------- */ #define FT_DEVICE_NAME_LEN 64 @@ -699,6 +663,15 @@ static int presto_bitq_reset(int trst, int srst) return 0; } +static struct bitq_interface presto_bitq = { + .out = &presto_bitq_out, + .flush = &presto_bitq_flush, + .sleep = &presto_bitq_sleep, + .reset = &presto_bitq_reset, + .in_rdy = &presto_bitq_in_rdy, + .in = &presto_bitq_in, + }; + /* -------------------------------------------------------------------------- */ static int presto_jtag_khz(int khz, int *jtag_speed) @@ -807,3 +780,14 @@ static int presto_jtag_quit(void) return ERROR_OK; } + +struct jtag_interface presto_interface = { + .name = "presto", + .execute_queue = &bitq_execute_queue, + .speed = &presto_jtag_speed, + .khz = &presto_jtag_khz, + .speed_div = &presto_jtag_speed_div, + .register_commands = &presto_jtag_register_commands, + .init = &presto_jtag_init, + .quit = &presto_jtag_quit, + }; diff --git a/src/jtag/usbprog.c b/src/jtag/usbprog.c index 10dfe061..e8c0eadf 100644 --- a/src/jtag/usbprog.c +++ b/src/jtag/usbprog.c @@ -49,28 +49,12 @@ #define TCK_BIT 2 #define TMS_BIT 1 -static int usbprog_execute_queue(void); -static int usbprog_speed(int speed); -static int usbprog_register_commands(struct command_context *cmd_ctx); -static int usbprog_init(void); -static int usbprog_quit(void); - static void usbprog_end_state(tap_state_t state); static void usbprog_state_move(void); static void usbprog_path_move(struct pathmove_command *cmd); static void usbprog_runtest(int num_cycles); static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size); -struct jtag_interface usbprog_interface = -{ - .name = "usbprog", - .execute_queue = usbprog_execute_queue, - .speed = usbprog_speed, - .register_commands = usbprog_register_commands, - .init = usbprog_init, - .quit = usbprog_quit -}; - #define UNKOWN_COMMAND 0x00 #define PORT_DIRECTION 0x01 #define PORT_SET 0x02 @@ -120,11 +104,6 @@ static int usbprog_speed(int speed) return ERROR_OK; } -static int usbprog_register_commands(struct command_context *cmd_ctx) -{ - return ERROR_OK; -} - static int usbprog_execute_queue(void) { struct jtag_command *cmd = jtag_command_queue; /* currently processed command */ @@ -688,3 +667,11 @@ static void usbprog_jtag_tms_send(struct usbprog_jtag *usbprog_jtag) tms_chain_index = 0; } } + +struct jtag_interface usbprog_interface = { + .name = "usbprog", + .execute_queue = &usbprog_execute_queue, + .speed = &usbprog_speed, + .init = &usbprog_init, + .quit = &usbprog_quit + }; -- 2.39.5