From 54ee00b0f6997e1c76b02ca6be2b593690d889ac Mon Sep 17 00:00:00 2001 From: Koen De Vleeschauwer Date: Wed, 13 May 2020 13:54:18 +0200 Subject: [PATCH] set semihosting sys_clock time origin --- src/target/cortexm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/target/cortexm.c b/src/target/cortexm.c index c95b52ab..4e47a23b 100644 --- a/src/target/cortexm.c +++ b/src/target/cortexm.c @@ -71,6 +71,10 @@ static target_addr cortexm_check_watch(target *t); static int cortexm_hostio_request(target *t); +#if !defined(PC_HOSTED) +static uint32_t time0_sec = UINT32_MAX; /* sys_clock time origin */ +#endif + struct cortexm_priv { ADIv5_AP_t *ap; bool stepping; @@ -1206,6 +1210,8 @@ static int cortexm_hostio_request(target *t) if (syscall == SYS_TIME) { /* SYS_TIME: time in seconds */ ret = sec; } else { /* SYS_CLOCK: time in hundredths of seconds */ + if (time0_sec > sec) time0_sec = sec; /* set sys_clock time origin */ + sec -= time0_sec; uint64_t csec64 = (sec * 1000000ull + usec)/10000ull; uint32_t csec = csec64 & 0x7fffffff; ret = csec;