aboutsummaryrefslogtreecommitdiff
path: root/target/s390x/misc_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'target/s390x/misc_helper.c')
-rw-r--r--target/s390x/misc_helper.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c
index 52262f62df..ee67c1fa0c 100644
--- a/target/s390x/misc_helper.c
+++ b/target/s390x/misc_helper.c
@@ -30,6 +30,7 @@
#include "exec/cpu_ldst.h"
#include "qapi/error.h"
#include "tcg_s390x.h"
+#include "s390-tod.h"
#if !defined(CONFIG_USER_ONLY)
#include "sysemu/cpus.h"
@@ -76,8 +77,28 @@ uint64_t HELPER(stpt)(CPUS390XState *env)
#endif
}
-#ifndef CONFIG_USER_ONLY
+/* Store Clock */
+uint64_t HELPER(stck)(CPUS390XState *env)
+{
+#ifdef CONFIG_USER_ONLY
+ struct timespec ts;
+ uint64_t ns;
+
+ clock_gettime(CLOCK_REALTIME, &ts);
+ ns = ts.tv_sec * NANOSECONDS_PER_SECOND + ts.tv_nsec;
+
+ return TOD_UNIX_EPOCH + time2tod(ns);
+#else
+ S390TODState *td = s390_get_todstate();
+ S390TODClass *tdc = S390_TOD_GET_CLASS(td);
+ S390TOD tod;
+ tdc->get(td, &tod, &error_abort);
+ return tod.low;
+#endif
+}
+
+#ifndef CONFIG_USER_ONLY
/* SCLP service call */
uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2)
{
@@ -138,17 +159,6 @@ void HELPER(spx)(CPUS390XState *env, uint64_t a1)
tlb_flush_page(cs, TARGET_PAGE_SIZE);
}
-/* Store Clock */
-uint64_t HELPER(stck)(CPUS390XState *env)
-{
- S390TODState *td = s390_get_todstate();
- S390TODClass *tdc = S390_TOD_GET_CLASS(td);
- S390TOD tod;
-
- tdc->get(td, &tod, &error_abort);
- return tod.low;
-}
-
static void update_ckc_timer(CPUS390XState *env)
{
S390TODState *td = s390_get_todstate();