From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Cc: Alexander Graf <agraf@suse.de>,
Aurelien Jarno <aurelien@aurel32.net>,
Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH 1/5] target-s390x: add a tod2time function
Date: Mon, 18 May 2015 23:42:25 +0200 [thread overview]
Message-ID: <1431985349-11226-2-git-send-email-aurelien@aurel32.net> (raw)
In-Reply-To: <1431985349-11226-1-git-send-email-aurelien@aurel32.net>
Add a tod2time function similar to the time2tod one, instead of open
coding the conversion.
Cc: Alexander Graf <agraf@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-s390x/cpu.h | 5 +++++
target-s390x/misc_helper.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 8135dda..28aa39d 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -970,6 +970,11 @@ static inline uint64_t time2tod(uint64_t ns) {
return (ns << 9) / 125;
}
+/* Converts s390's clock format to ns */
+static inline uint64_t tod2time(uint64_t t) {
+ return (t * 125) >> 9;
+}
+
static inline void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32_t param,
uint64_t param64)
{
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index e1007fa..230bafd 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -294,7 +294,7 @@ void HELPER(sckc)(CPUS390XState *env, uint64_t time)
/* difference between now and then */
time -= clock_value(env);
/* nanoseconds */
- time = (time * 125) >> 9;
+ time = tod2time(time);
timer_mod(env->tod_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + time);
}
@@ -314,7 +314,7 @@ void HELPER(spt)(CPUS390XState *env, uint64_t time)
}
/* nanoseconds */
- time = (time * 125) >> 9;
+ time = tod2time(time);
timer_mod(env->cpu_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + time);
}
--
2.1.4
next prev parent reply other threads:[~2015-05-18 21:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 21:42 [Qemu-devel] [PATCH 0/5] Clean and improve time related helpers Aurelien Jarno
2015-05-18 21:42 ` Aurelien Jarno [this message]
2015-05-18 21:42 ` [Qemu-devel] [PATCH 2/5] target-s390x: simplify SCKC helper Aurelien Jarno
2015-05-18 21:42 ` [Qemu-devel] [PATCH 3/5] target-s390x: streamline STCK helper Aurelien Jarno
2015-05-18 21:42 ` [Qemu-devel] [PATCH 4/5] target-s390x: implement STCKC helper Aurelien Jarno
2015-05-18 21:42 ` [Qemu-devel] [PATCH 5/5] target-s390x: implement STPT helper Aurelien Jarno
2015-05-25 22:02 ` [Qemu-devel] [PATCH 0/5] Clean and improve time related helpers Alexander Graf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431985349-11226-2-git-send-email-aurelien@aurel32.net \
--to=aurelien@aurel32.net \
--cc=agraf@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).