aboutsummaryrefslogtreecommitdiff
path: root/pc-bios/s390-ccw/s390-time.h
diff options
context:
space:
mode:
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