aboutsummaryrefslogtreecommitdiff
path: root/pc-bios/s390-ccw/s390-time.h
diff options
context:
space:
mode:
authorJanosch Frank <frankja@linux.ibm.com>2020-06-24 03:52:16 -0400
committerThomas Huth <thuth@redhat.com>2020-07-02 09:59:24 +0200
commite70bc57ba0c982944cf5b71f293122dbb2b462f4 (patch)
tree321592e044555c165be7882079708e502a9a84f8 /pc-bios/s390-ccw/s390-time.h
parent8c6cc7b9df36e0ca6f562a46f2afd883b6dc6867 (diff)
downloadqemu-e70bc57ba0c982944cf5b71f293122dbb2b462f4.zip
qemu-e70bc57ba0c982944cf5b71f293122dbb2b462f4.tar.gz
qemu-e70bc57ba0c982944cf5b71f293122dbb2b462f4.tar.bz2
pc-bios: s390x: Consolidate timing functions into time.h
Let's consolidate timing related functions into one header. Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Acked-by: Thomas Huth <thuth@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Message-Id: <20200624075226.92728-3-frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'pc-bios/s390-ccw/s390-time.h')
-rw-r--r--pc-bios/s390-ccw/s390-time.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/pc-bios/s390-ccw/s390-time.h b/pc-bios/s390-ccw/s390-time.h
new file mode 100644
index 0000000..ed6d982
--- /dev/null
+++ b/pc-bios/s390-ccw/s390-time.h
@@ -0,0 +1,23 @@
+#ifndef TIME_H
+#define TIME_H
+
+static inline u64 get_clock(void)
+{
+ u64 r;
+
+ asm volatile("stck %0" : "=Q" (r) : : "cc");
+ return r;
+}
+
+static inline u64 get_time_ms(void)
+{
+ /* Bit 51 is incremented each microsecond */
+ return (get_clock() >> 12) / 1000;
+}
+
+static inline u64 get_time_seconds(void)
+{
+ return get_time_ms() / 1000;
+}
+
+#endif