[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCHv5 24/46] plat/kvm: Introduce a time_ops for different architectures


  • To: <minios-devel@xxxxxxxxxxxxxxxxxxxx>, <simon.kuenzer@xxxxxxxxx>
  • From: Wei Chen <wei.chen@xxxxxxx>
  • Date: Fri, 10 Aug 2018 07:08:14 +0000
  • Authentication-results: spf=fail (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=arm.com;
  • Cc: Kaly.Xin@xxxxxxx, nd@xxxxxxx, wei.chen@xxxxxxx
  • Delivery-date: Fri, 10 Aug 2018 07:10:28 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Nodisclaimer: True
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:99

Different architectures have different timer implementation. In
order to avoid using too many #ifdef, we introduce this time_ops
for different architectures to implement arch_timer_ops.

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
---
 include/uk/plat/time.h | 8 ++++++++
 plat/kvm/time.c        | 7 ++++---
 plat/kvm/tscclock.c    | 6 ++++++
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/include/uk/plat/time.h b/include/uk/plat/time.h
index 202e0f9..2aacfce 100644
--- a/include/uk/plat/time.h
+++ b/include/uk/plat/time.h
@@ -47,6 +47,14 @@ void ukplat_time_fini(void);
 
 __nsec ukplat_monotonic_clock(void);
 
+struct ukplat_time_ops {
+       int (*init)(void);
+       __u64 (*monotonic)(void);
+       __u64 (*epochoffset)(void);
+};
+
+extern struct ukplat_time_ops arch_timer_ops;
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/plat/kvm/time.c b/plat/kvm/time.c
index 1fb48bf..eb8bfc2 100644
--- a/plat/kvm/time.c
+++ b/plat/kvm/time.c
@@ -31,17 +31,18 @@
 #include <kvm/tscclock.h>
 #include <uk/assert.h>
 
+struct ukplat_time_ops *time_ops = &arch_timer_ops;
 
 /* return ns since time_init() */
 __nsec ukplat_monotonic_clock(void)
 {
-       return tscclock_monotonic();
+       return time_ops->monotonic();
 }
 
 /* return wall time in nsecs */
 __nsec ukplat_clock_wall(void)
 {
-       return tscclock_monotonic() + tscclock_epochoffset();
+       return time_ops->monotonic() + time_ops->epochoffset();
 }
 
 static int timer_handler(void *arg __unused)
@@ -59,7 +60,7 @@ void ukplat_time_init(void)
        if (rc < 0)
                UK_CRASH("Failed to register timer interrupt handler\n");
 
-       rc = tscclock_init();
+       rc = time_ops->init();
        if (rc < 0)
                UK_CRASH("Failed to initialize TSCCLOCK\n");
 }
diff --git a/plat/kvm/tscclock.c b/plat/kvm/tscclock.c
index 8961659..990902b 100644
--- a/plat/kvm/tscclock.c
+++ b/plat/kvm/tscclock.c
@@ -358,3 +358,9 @@ void time_block_until(__snsec until)
                        break;
        }
 }
+
+struct ukplat_time_ops arch_timer_ops = {
+       .init = tscclock_init,
+       .monotonic = tscclock_monotonic,
+       .epochoffset = tscclock_epochoffset,
+};
-- 
2.17.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.