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

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



Hi Wei,

On 10.08.2018 09:08, Wei Chen wrote:
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.

does the timer implementation this change during runtime or can you settle on one specific timer implementation during compile time? Why not providing a different C file that implements your ARM timer? We could avoid the indirection and save the timeops struct.


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,
+};


Thanks,

Simon

_______________________________________________
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®.