#include "hw/semihosting/console.h"
#include "hw/semihosting/common-semi.h"
#include "qemu/log.h"
+#include "qemu/timer.h"
#ifdef CONFIG_USER_ONLY
#include "qemu.h"
#define TARGET_SYS_EXIT 0x18
#define TARGET_SYS_SYNCCACHE 0x19
#define TARGET_SYS_EXIT_EXTENDED 0x20
+#define TARGET_SYS_ELAPSED 0x30
+#define TARGET_SYS_TICKFREQ 0x31
/* ADP_Stopped_ApplicationExit is used for exit(0),
* anything else is implemented as exit(1) */
uint32_t ret;
uint32_t len;
GuestFD *gf;
+ int64_t elapsed;
(void) env; /* Used implicitly by arm lock_user macro */
nr = common_semi_arg(cs, 0) & 0xffffffffU;
}
gdb_exit(ret);
exit(ret);
+ case TARGET_SYS_ELAPSED:
+ elapsed = get_clock() - clock_start;
+ if (sizeof(target_ulong) == 8) {
+ SET_ARG(0, elapsed);
+ } else {
+ SET_ARG(0, (uint32_t) elapsed);
+ SET_ARG(1, (uint32_t) (elapsed >> 32));
+ }
+ return 0;
+ case TARGET_SYS_TICKFREQ:
+ /* qemu always uses nsec */
+ return 1000000000;
case TARGET_SYS_SYNCCACHE:
/*
* Clean the D-cache and invalidate the I-cache for the specified
return tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000);
}
+extern int64_t clock_start;
+
/* Warning: don't insert tracepoints into these functions, they are
also used by simpletrace backend and tracepoints would cause
an infinite recursion! */
/***********************************************************/
/* real time host monotonic timer */
+int64_t clock_start;
+
#ifdef _WIN32
int64_t clock_freq;
exit(1);
}
clock_freq = freq.QuadPart;
+ clock_start = get_clock();
}
#else
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
use_rt_clock = 1;
}
+ clock_start = get_clock();
}
#endif