projects
/
fw
/
openocd
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
jtag: clarify jtag->init() and jtag->quit() definitions
[fw/openocd]
/
src
/
jtag
/
core.c
diff --git
a/src/jtag/core.c
b/src/jtag/core.c
index b89530946a6647eb6d86233ee55d292c5a0b0150..4c5d37a749b0e7f25e8480f47dc00088d394ebef 100644
(file)
--- a/
src/jtag/core.c
+++ b/
src/jtag/core.c
@@
-129,6
+129,9
@@
static int jtag_speed = 0;
static struct jtag_interface *jtag = NULL;
static struct jtag_interface *jtag = NULL;
+
+const struct swd_driver *swd = NULL;
+
/* configuration */
struct jtag_interface *jtag_interface = NULL;
/* configuration */
struct jtag_interface *jtag_interface = NULL;
@@
-213,7
+216,7
@@
void jtag_tap_add(struct jtag_tap *t)
}
/* returns a pointer to the n-th device in the scan chain */
}
/* returns a pointer to the n-th device in the scan chain */
-st
atic inline st
ruct jtag_tap *jtag_tap_by_position(unsigned n)
+struct jtag_tap *jtag_tap_by_position(unsigned n)
{
struct jtag_tap *t = jtag_all_taps();
{
struct jtag_tap *t = jtag_all_taps();
@@
-296,28
+299,24
@@
int jtag_register_event_callback(jtag_event_handler_t callback, void *priv)
int jtag_unregister_event_callback(jtag_event_handler_t callback, void *priv)
{
int jtag_unregister_event_callback(jtag_event_handler_t callback, void *priv)
{
- struct jtag_event_callback **callbacks_p;
- struct jtag_event_callback **next;
+ struct jtag_event_callback **p = &jtag_event_callbacks, *temp;
if (callback == NULL)
{
return ERROR_INVALID_ARGUMENTS;
}
if (callback == NULL)
{
return ERROR_INVALID_ARGUMENTS;
}
- for (callbacks_p = &jtag_event_callbacks;
- *callbacks_p != NULL;
- callbacks_p = next)
+ while (*p)
{
{
- next = &((*callbacks_p)->next);
-
- if ((*callbacks_p)->priv != priv)
- continue;
-
- if ((*callbacks_p)->callback == callback)
+ if (((*p)->priv != priv) || ((*p)->callback != callback))
{
{
-
free(*callbacks_p)
;
-
*callbacks_p = *next
;
+
p = &(*p)->next
;
+
continue
;
}
}
+
+ temp = *p;
+ *p = (*p)->next;
+ free(temp);
}
return ERROR_OK;
}
return ERROR_OK;
@@
-696,7
+695,7
@@
void jtag_add_reset(int req_tlr_or_trst, int req_srst)
retval = jtag_execute_queue();
if (retval != ERROR_OK) {
retval = jtag_execute_queue();
if (retval != ERROR_OK) {
- LOG_ERROR("TRST/SRST error
%d", retval
);
+ LOG_ERROR("TRST/SRST error
"
);
return;
}
}
return;
}
}
@@
-872,9
+871,16
@@
static int jtag_reset_callback(enum jtag_event event, void *priv)
return ERROR_OK;
}
return ERROR_OK;
}
+/* sleep at least us microseconds. When we sleep more than 1000ms we
+ * do an alive sleep, i.e. keep GDB alive. Note that we could starve
+ * GDB if we slept for <1000ms many times.
+ */
void jtag_sleep(uint32_t us)
{
void jtag_sleep(uint32_t us)
{
- alive_sleep(us/1000);
+ if (us < 1000)
+ usleep(us);
+ else
+ alive_sleep((us+999)/1000);
}
/* Maximum number of enabled JTAG devices we expect in the scan chain,
}
/* Maximum number of enabled JTAG devices we expect in the scan chain,
@@
-1362,12
+1368,13
@@
int adapter_init(struct command_context *cmd_ctx)
return ERROR_JTAG_INVALID_INTERFACE;
}
return ERROR_JTAG_INVALID_INTERFACE;
}
- jtag = jtag_interface;
- if (jtag_interface->init() != ERROR_OK)
+ int retval;
+ retval = jtag_interface->init();
+ if (retval != ERROR_OK)
{
{
- jtag = NULL;
- return ERROR_JTAG_INIT_FAILED;
+ return retval;
}
}
+ jtag = jtag_interface;
/* LEGACY SUPPORT ... adapter drivers must declare what
* transports they allow. Until they all do so, assume
/* LEGACY SUPPORT ... adapter drivers must declare what
* transports they allow. Until they all do so, assume
@@
-1377,7
+1384,7
@@
int adapter_init(struct command_context *cmd_ctx)
LOG_ERROR("Adapter driver '%s' did not declare "
"which transports it allows; assuming "
"JTAG-only", jtag->name);
LOG_ERROR("Adapter driver '%s' did not declare "
"which transports it allows; assuming "
"JTAG-only", jtag->name);
-
int
retval = allow_transports(cmd_ctx, jtag_only);
+ retval = allow_transports(cmd_ctx, jtag_only);
if (retval != ERROR_OK)
return retval;
}
if (retval != ERROR_OK)
return retval;
}
@@
-1385,7
+1392,7
@@
int adapter_init(struct command_context *cmd_ctx)
int requested_khz = jtag_get_speed_khz();
int actual_khz = requested_khz;
int jtag_speed_var;
int requested_khz = jtag_get_speed_khz();
int actual_khz = requested_khz;
int jtag_speed_var;
-
int
retval = jtag_get_speed(&jtag_speed_var);
+ retval = jtag_get_speed(&jtag_speed_var);
if (retval != ERROR_OK)
return retval;
retval = jtag_get_speed_readable(&actual_khz);
if (retval != ERROR_OK)
return retval;
retval = jtag_get_speed_readable(&actual_khz);