From aabb31d5710038b682c06945de4c94b3c612d936 Mon Sep 17 00:00:00 2001 From: zwelch Date: Tue, 9 Jun 2009 08:41:29 +0000 Subject: Add jtag_event_handler_t: - Define the function signature used by the JTAG event callback mechanism. - Provide Doxygen block for new type, including TODO for its return value. git-svn-id: svn://svn.berlios.de/openocd/trunk@2168 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/jtag/core.c | 4 ++-- src/jtag/jtag.h | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'src/jtag') diff --git a/src/jtag/core.c b/src/jtag/core.c index d45fd67e..54ee757c 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -201,7 +201,7 @@ const char *jtag_tap_name(const jtag_tap_t *tap) } -int jtag_register_event_callback(int (*callback)(enum jtag_event event, void *priv), void *priv) +int jtag_register_event_callback(jtag_event_handler_t callback, void *priv) { jtag_event_callback_t **callbacks_p = &jtag_event_callbacks; @@ -225,7 +225,7 @@ int jtag_register_event_callback(int (*callback)(enum jtag_event event, void *pr return ERROR_OK; } -int jtag_unregister_event_callback(int (*callback)(enum jtag_event event, void *priv)) +int jtag_unregister_event_callback(jtag_event_handler_t callback) { jtag_event_callback_t **callbacks_p = &jtag_event_callbacks; diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index f0196690..f7b215b3 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -248,9 +248,22 @@ int jtag_get_trst(void); /// @returns The current state of SRST. int jtag_get_srst(void); +/** + * Defines the function signature requide for JTAG event callback + * functions, which are added with jtag_register_event_callback() + * and removed jtag_unregister_event_callback(). + * @param event The event to handle. + * @param prive A pointer to data that was passed to + * jtag_register_event_callback(). + * @returns Must return ERROR_OK on success, or an error code on failure. + * + * @todo Change to return void or define a use for its return code. + */ +typedef int (*jtag_event_handler_t)(enum jtag_event event, void* priv); + typedef struct jtag_event_callback_s { - int (*callback)(enum jtag_event event, void* priv); + jtag_event_handler_t callback; void* priv; struct jtag_event_callback_s* next; } jtag_event_callback_t; @@ -609,8 +622,8 @@ extern void jtag_check_value_mask(scan_field_t *field, u8 *value, u8 *mask); extern void jtag_sleep(u32 us); extern int jtag_call_event_callbacks(enum jtag_event event); -extern int jtag_register_event_callback(int (* callback)(enum jtag_event event, void* priv), void* priv); -extern int jtag_unregister_event_callback(int (*callback)(enum jtag_event event, void *priv)); +extern int jtag_register_event_callback(jtag_event_handler_t f, void *x); +extern int jtag_unregister_event_callback(jtag_event_handler_t f); /* * The JTAG subsystem defines a number of error codes, -- cgit v1.2.3