First, fix the timeval_ms() implementation to not have K&R but ANSI
argument semantics by adding a missing void.
timeval_ms() returns an int64_t, not uint64_t or long long. Consistently
use int64_t for variables and PRI*64 as format string.
While at it, change a few related variables to bool for clarity.
Note that timeval_ms() may return a negative error code, but not a
single caller checks for that.
Change-Id: I27cf83e75b3e9a8913f6c43e98a281bea77aac13
Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-on: http://openocd.zylin.com/3499
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
26 files changed:
- long long endtime = timeval_ms() + timeout_ms;
+ int64_t endtime = timeval_ms() + timeout_ms;
while (1) {
target_read_u8(target, ADUC702x_FLASH + ADUC702x_FLASH_FEESTA, &v);
if ((v & 4) == 0)
while (1) {
target_read_u8(target, ADUC702x_FLASH + ADUC702x_FLASH_FEESTA, &v);
if ((v & 4) == 0)
- long long endtime = timeval_ms() + timeout_ms;
+ int64_t endtime = timeval_ms() + timeout_ms;
while (1) {
target_read_u32(target, ADUCM360_FLASH_BASE+ADUCM360_FLASH_FEESTA, &v);
if ((v & 0x00000001) == 0)
while (1) {
target_read_u32(target, ADUCM360_FLASH_BASE+ADUCM360_FLASH_FEESTA, &v);
if ((v & 0x00000001) == 0)
- long long ms_now, ms_end;
+ int64_t ms_now, ms_end;
/* default */
if (status)
/* default */
if (status)
- long long ms_now, ms_end;
+ int64_t ms_now, ms_end;
/* default */
if (status)
/* default */
if (status)
- long long ms_now, ms_end;
+ int64_t ms_now, ms_end;
static int jtagspi_wait(struct flash_bank *bank, int timeout_ms)
{
uint32_t status;
static int jtagspi_wait(struct flash_bank *bank, int timeout_ms)
{
uint32_t status;
- long long t0 = timeval_ms();
- long long dt;
+ int64_t t0 = timeval_ms();
+ int64_t dt;
do {
dt = timeval_ms() - t0;
jtagspi_read_status(bank, &status);
if ((status & SPIFLASH_BSY_BIT) == 0) {
do {
dt = timeval_ms() - t0;
jtagspi_read_status(bank, &status);
if ((status & SPIFLASH_BSY_BIT) == 0) {
- LOG_DEBUG("waited %lld ms", dt);
+ LOG_DEBUG("waited %" PRId64 " ms", dt);
return ERROR_OK;
}
alive_sleep(1);
return ERROR_OK;
}
alive_sleep(1);
{
struct jtagspi_flash_bank *info = bank->driver_priv;
int retval;
{
struct jtagspi_flash_bank *info = bank->driver_priv;
int retval;
- long long t0 = timeval_ms();
+ int64_t t0 = timeval_ms();
retval = jtagspi_write_enable(bank);
if (retval != ERROR_OK)
return retval;
jtagspi_cmd(bank, info->dev->chip_erase_cmd, NULL, NULL, 0);
retval = jtagspi_wait(bank, bank->num_sectors*JTAGSPI_MAX_TIMEOUT);
retval = jtagspi_write_enable(bank);
if (retval != ERROR_OK)
return retval;
jtagspi_cmd(bank, info->dev->chip_erase_cmd, NULL, NULL, 0);
retval = jtagspi_wait(bank, bank->num_sectors*JTAGSPI_MAX_TIMEOUT);
- LOG_INFO("took %lld ms", timeval_ms() - t0);
+ LOG_INFO("took %" PRId64 " ms", timeval_ms() - t0);
{
struct jtagspi_flash_bank *info = bank->driver_priv;
int retval;
{
struct jtagspi_flash_bank *info = bank->driver_priv;
int retval;
- long long t0 = timeval_ms();
+ int64_t t0 = timeval_ms();
retval = jtagspi_write_enable(bank);
if (retval != ERROR_OK)
return retval;
jtagspi_cmd(bank, info->dev->erase_cmd, &bank->sectors[sector].offset, NULL, 0);
retval = jtagspi_wait(bank, JTAGSPI_MAX_TIMEOUT);
retval = jtagspi_write_enable(bank);
if (retval != ERROR_OK)
return retval;
jtagspi_cmd(bank, info->dev->erase_cmd, &bank->sectors[sector].offset, NULL, 0);
retval = jtagspi_wait(bank, JTAGSPI_MAX_TIMEOUT);
- LOG_INFO("sector %d took %lld ms", sector, timeval_ms() - t0);
+ LOG_INFO("sector %d took %" PRId64 " ms", sector, timeval_ms() - t0);
* and the controller is idle. */
static int poll_ssp_busy(struct target *target, uint32_t ssp_base, int timeout)
{
* and the controller is idle. */
static int poll_ssp_busy(struct target *target, uint32_t ssp_base, int timeout)
{
uint32_t value;
int retval;
uint32_t value;
int retval;
{
uint32_t status;
int retval;
{
uint32_t status;
int retval;
endtime = timeval_ms() + timeout;
do {
endtime = timeval_ms() + timeout;
do {
/* timeout in ms */
static int poll_tff(struct target *target, uint32_t io_base, int timeout)
{
/* timeout in ms */
static int poll_tff(struct target *target, uint32_t io_base, int timeout)
{
if (SMI_READ_REG(SMI_SR) & SMI_TFF)
return ERROR_OK;
if (SMI_READ_REG(SMI_SR) & SMI_TFF)
return ERROR_OK;
{
uint32_t status;
int retval;
{
uint32_t status;
int retval;
endtime = timeval_ms() + timeout;
do {
endtime = timeval_ms() + timeout;
do {
return retval;
if (!busy) {
return retval;
if (!busy) {
- long long then = timeval_ms();
- while (timeval_ms() - then < (long long)duration) {
+ int64_t then = timeval_ms();
+ while (timeval_ms() - then < (int64_t)duration) {
target_call_timer_callbacks_now();
usleep(1000);
}
target_call_timer_callbacks_now();
usleep(1000);
}
static FILE *log_output;
static struct log_callback *log_callbacks;
static FILE *log_output;
static struct log_callback *log_callbacks;
-static long long last_time;
-static long long current_time;
+static int64_t last_time;
+static int64_t current_time;
static const char * const log_strings[5] = {
"User : ",
static const char * const log_strings[5] = {
"User : ",
if (strlen(string) > 0) {
if (debug_level >= LOG_LVL_DEBUG) {
/* print with count and time information */
if (strlen(string) > 0) {
if (debug_level >= LOG_LVL_DEBUG) {
/* print with count and time information */
- int t = (int)(timeval_ms()-start);
+ int64_t t = timeval_ms() - start;
#ifdef _DEBUG_FREE_SPACE_
struct mallinfo info;
info = mallinfo();
#endif
#ifdef _DEBUG_FREE_SPACE_
struct mallinfo info;
info = mallinfo();
#endif
- fprintf(log_output, "%s%d %d %s:%d %s()"
+ fprintf(log_output, "%s%d %" PRId64 " %s:%d %s()"
#ifdef _DEBUG_FREE_SPACE_
" %d"
#endif
#ifdef _DEBUG_FREE_SPACE_
" %d"
#endif
if (gdb_actual_connections)
LOG_WARNING("keep_alive() was not invoked in the "
"1000ms timelimit. GDB alive packet not "
if (gdb_actual_connections)
LOG_WARNING("keep_alive() was not invoked in the "
"1000ms timelimit. GDB alive packet not "
- "sent! (%lld). Workaround: increase "
+ "sent! (%" PRId64 "). Workaround: increase "
"\"set remotetimeout\" in GDB",
current_time-last_time);
else
LOG_DEBUG("keep_alive() was not invoked in the "
"\"set remotetimeout\" in GDB",
current_time-last_time);
else
LOG_DEBUG("keep_alive() was not invoked in the "
- "1000ms timelimit (%lld). This may cause "
+ "1000ms timelimit (%" PRId64 "). This may cause "
"trouble with GDB connections.",
current_time-last_time);
}
"trouble with GDB connections.",
current_time-last_time);
}
/* simple and low overhead fetching of ms counter. Use only
* the difference between ms counters returned from this fn.
*/
/* simple and low overhead fetching of ms counter. Use only
* the difference between ms counters returned from this fn.
*/
+int64_t timeval_ms(void)
{
struct timeval now;
int retval = gettimeofday(&now, NULL);
{
struct timeval now;
int retval = gettimeofday(&now, NULL);
static int aice_pipe_read(void *buffer, int count)
{
int n;
static int aice_pipe_read(void *buffer, int count)
{
int n;
if ((i % 30) == 0)
keep_alive();
if ((i % 30) == 0)
keep_alive();
if (i == aice_count_to_check_dbger)
then = timeval_ms();
if (i >= aice_count_to_check_dbger) {
if (i == aice_count_to_check_dbger)
then = timeval_ms();
if (i >= aice_count_to_check_dbger) {
if (AICE_TARGET_HALTED == state)
break;
if (AICE_TARGET_HALTED == state)
break;
if (i == 30)
then = timeval_ms();
if (i == 30)
then = timeval_ms();
LOG_USER("Waiting for srst assert + deassert for at most %dms", timeout_ms);
int asserted_yet;
LOG_USER("Waiting for srst assert + deassert for at most %dms", timeout_ms);
int asserted_yet;
- long long then = timeval_ms();
+ int64_t then = timeval_ms();
while (jtag_srst_asserted(&asserted_yet) == ERROR_OK) {
if ((timeval_ms() - then) > timeout_ms) {
LOG_ERROR("Timed out");
while (jtag_srst_asserted(&asserted_yet) == ERROR_OK) {
if ((timeval_ms() - then) > timeout_ms) {
LOG_ERROR("Timed out");
static void waitSRST(bool asserted)
{
bool first = true;
static void waitSRST(bool asserted)
{
bool first = true;
- long long start = 0;
- long total = 0;
+ int64_t start = 0;
+ int64_t total = 0;
const char *mode = asserted ? "assert" : "deassert";
for (;; ) {
const char *mode = asserted ? "assert" : "deassert";
for (;; ) {
keep_alive();
if (total > 5000) {
keep_alive();
if (total > 5000) {
- LOG_ERROR("SRST took too long to %s: %dms", mode, (int)total);
+ LOG_ERROR("SRST took too long to %s: %" PRId64 "ms", mode, total);
#define SVF_MAX_NUM_OF_OPTIONS 5
int command_num = 0;
int ret = ERROR_OK;
#define SVF_MAX_NUM_OF_OPTIONS 5
int command_num = 0;
int ret = ERROR_OK;
- long long time_measure_ms;
+ int64_t time_measure_ms;
int time_measure_s, time_measure_m;
/* use NULL to indicate a "plain" svf file which accounts for
int time_measure_s, time_measure_m;
/* use NULL to indicate a "plain" svf file which accounts for
time_measure_s %= 60;
if (time_measure_ms < 1000)
command_print(CMD_CTX,
time_measure_s %= 60;
if (time_measure_ms < 1000)
command_print(CMD_CTX,
- "\r\nTime used: %dm%ds%lldms ",
+ "\r\nTime used: %dm%ds%" PRId64 "ms ",
time_measure_m,
time_measure_s,
time_measure_ms);
time_measure_m,
time_measure_s,
time_measure_ms);
int retval;
struct dap_cmd *el, *tmp, *prev = NULL;
int found_wait = 0;
int retval;
struct dap_cmd *el, *tmp, *prev = NULL;
int found_wait = 0;
LIST_HEAD(replay_list);
/* make sure all queued transactions are complete */
LIST_HEAD(replay_list);
/* make sure all queued transactions are complete */
if (i == 1000)
then = timeval_ms();
if (i >= 1000) {
if (i == 1000)
then = timeval_ms();
if (i >= 1000) {
if (i == 1000)
then = timeval_ms();
if (i >= 1000) {
if (i == 1000)
then = timeval_ms();
if (i >= 1000) {
if (i == 1000)
then = timeval_ms();
if (i == 1000)
then = timeval_ms();
JTAG_DEBUG("DTR Ready %d nRetry %d", Ready, nRetry);
JTAG_DEBUG("DTR Ready %d nRetry %d", Ready, nRetry);
if (i == 1000)
then = timeval_ms();
if (i == 1000)
then = timeval_ms();
JTAG_DEBUG("DTR Data %08x Ready %d nRetry %d",
(unsigned) Data, Ready, nRetry);
JTAG_DEBUG("DTR Data %08x Ready %d nRetry %d",
(unsigned) Data, Ready, nRetry);
if (i == 1000)
then = timeval_ms();
if (i == 1000)
then = timeval_ms();
JTAG_DEBUG("DTR Data %08x Ready %d nRetry %d",
(unsigned) Data, Ready, nRetry);
JTAG_DEBUG("DTR Data %08x Ready %d nRetry %d",
(unsigned) Data, Ready, nRetry);
if (i == 1000)
then = timeval_ms();
if (i == 1000)
then = timeval_ms();
if (i_n == 1000)
then = timeval_ms();
if (i_n == 1000)
then = timeval_ms();
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- long long then = timeval_ms();
+ int64_t then = timeval_ms();
int timeout;
while (!(timeout = ((timeval_ms()-then) > 1000))) {
if (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1) == 0) {
int timeout;
while (!(timeout = ((timeval_ms()-then) > 1000))) {
if (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1) == 0) {
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- long long then = timeval_ms();
- int timeout;
+ int64_t then = timeval_ms();
+ bool timeout;
while (!(timeout = ((timeval_ms()-then) > 1000))) {
/* read debug status register */
embeddedice_read_reg(dbg_stat);
while (!(timeout = ((timeval_ms()-then) > 1000))) {
/* read debug status register */
embeddedice_read_reg(dbg_stat);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- long long then = timeval_ms();
- int timeout;
+ int64_t then = timeval_ms();
+ bool timeout;
while (!(timeout = ((timeval_ms()-then) > 1000))) {
if (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1) == 0) {
embeddedice_read_reg(dbg_stat);
while (!(timeout = ((timeval_ms()-then) > 1000))) {
if (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1) == 0) {
embeddedice_read_reg(dbg_stat);
jtag_add_dr_scan(jtag_info->tap, 4, fields, TAP_IDLE);
jtag_add_dr_scan(jtag_info->tap, 4, fields, TAP_IDLE);
- long long then = timeval_ms();
+ int64_t then = timeval_ms();
for (;;) {
/* rescan with NOP, to wait for the access to complete */
for (;;) {
/* rescan with NOP, to wait for the access to complete */
jtag_add_dr_scan(jtag_info->tap, 4, fields, TAP_IDLE);
jtag_add_dr_scan(jtag_info->tap, 4, fields, TAP_IDLE);
- long long then = timeval_ms();
+ int64_t then = timeval_ms();
for (;;) {
/* rescan with NOP, to wait for the access to complete */
for (;;) {
/* rescan with NOP, to wait for the access to complete */
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- long long then = timeval_ms();
+ int64_t then = timeval_ms();
int timeout;
while (!(timeout = ((timeval_ms()-then) > 1000))) {
if (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1) == 0) {
int timeout;
while (!(timeout = ((timeval_ms()-then) > 1000))) {
if (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1) == 0) {
static int wait_for_pracc_rw(struct mips_ejtag *ejtag_info, uint32_t *ctrl)
{
uint32_t ejtag_ctrl;
static int wait_for_pracc_rw(struct mips_ejtag *ejtag_info, uint32_t *ctrl)
{
uint32_t ejtag_ctrl;
- long long then = timeval_ms();
+ int64_t then = timeval_ms();
/* wait for the PrAcc to become "1" */
mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL);
/* wait for the PrAcc to become "1" */
mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL);
if (ejtag_ctrl & EJTAG_CTRL_PRACC)
break;
if (ejtag_ctrl & EJTAG_CTRL_PRACC)
break;
- int timeout = timeval_ms() - then;
+ int64_t timeout = timeval_ms() - then;
if (timeout > 1000) {
LOG_DEBUG("DEBUGMODULE: No memory access in progress!");
return ERROR_JTAG_DEVICE_ERROR;
if (timeout > 1000) {
LOG_DEBUG("DEBUGMODULE: No memory access in progress!");
return ERROR_JTAG_DEVICE_ERROR;
if (target->state == TARGET_HALTED)
target->halt_issued = false;
else {
if (target->state == TARGET_HALTED)
target->halt_issued = false;
else {
- long long t = timeval_ms() - target->halt_issued_time;
+ int64_t t = timeval_ms() - target->halt_issued_time;
if (t > DEFAULT_HALT_TIMEOUT) {
target->halt_issued = false;
LOG_INFO("Halt timed out, wake up GDB.");
if (t > DEFAULT_HALT_TIMEOUT) {
target->halt_issued = false;
LOG_INFO("Halt timed out, wake up GDB.");
if (powerRestored)
runPowerRestore = 1;
if (powerRestored)
runPowerRestore = 1;
- long long current = timeval_ms();
- static long long lastPower;
- int waitMore = lastPower + 2000 > current;
+ int64_t current = timeval_ms();
+ static int64_t lastPower;
+ bool waitMore = lastPower + 2000 > current;
if (powerDropout && !waitMore) {
runPowerDropout = 1;
lastPower = current;
if (powerDropout && !waitMore) {
runPowerDropout = 1;
lastPower = current;
int srstDeasserted;
srstDeasserted = prevSrstAsserted && !srstAsserted;
int srstDeasserted;
srstDeasserted = prevSrstAsserted && !srstAsserted;
- static long long lastSrst;
+ static int64_t lastSrst;
waitMore = lastSrst + 2000 > current;
if (srstDeasserted && !waitMore) {
runSrstDeasserted = 1;
waitMore = lastSrst + 2000 > current;
if (srstDeasserted && !waitMore) {
runSrstDeasserted = 1;
int target_wait_state(struct target *target, enum target_state state, int ms)
{
int retval;
int target_wait_state(struct target *target, enum target_state state, int ms)
{
int retval;
- long long then = 0, cur;
- int once = 1;
+ int64_t then = 0, cur;
+ bool once = true;
for (;;) {
retval = target_poll(target);
for (;;) {
retval = target_poll(target);
break;
cur = timeval_ms();
if (once) {
break;
cur = timeval_ms();
if (once) {
then = timeval_ms();
LOG_DEBUG("waiting for target %s...",
Jim_Nvp_value2name_simple(nvp_target_state, state)->name);
then = timeval_ms();
LOG_DEBUG("waiting for target %s...",
Jim_Nvp_value2name_simple(nvp_target_state, state)->name);
return ERROR_FAIL;
}
int i;
return ERROR_FAIL;
}
int i;
+ int64_t ms = timeval_ms();
int size = 0;
int retval = ERROR_OK;
for (i = 0; i < fastload_num; i++) {
int size = 0;
int retval = ERROR_OK;
for (i = 0; i < fastload_num; i++) {
size += fastload[i].length;
}
if (retval == ERROR_OK) {
size += fastload[i].length;
}
if (retval == ERROR_OK) {
- int after = timeval_ms();
+ int64_t after = timeval_ms();
command_print(CMD_CTX, "Loaded image %f kBytes/s", (float)(size/1024.0)/((float)(after-ms)/1000.0));
}
return retval;
command_print(CMD_CTX, "Loaded image %f kBytes/s", (float)(size/1024.0)/((float)(after-ms)/1000.0));
}
return retval;
int display; /* display async info in telnet session. Do not display
* lots of halted/resumed info when stepping in debugger. */
bool halt_issued; /* did we transition to halted state? */
int display; /* display async info in telnet session. Do not display
* lots of halted/resumed info when stepping in debugger. */
bool halt_issued; /* did we transition to halted state? */
- long long halt_issued_time; /* Note time when halt was issued */
+ int64_t halt_issued_time; /* Note time when halt was issued */
bool dbgbase_set; /* By default the debug base is not set */
uint32_t dbgbase; /* Really a Cortex-A specific option, but there is no
bool dbgbase_set; /* By default the debug base is not set */
uint32_t dbgbase; /* Really a Cortex-A specific option, but there is no
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)