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

[Minios-devel] [UNIKRAFT RFC PATCH 1/1] Implement gettimeofday function for Arm



From: Jianyong Wu <Jianyong.Wu@xxxxxxx>

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
Signed-off-by: Jianyong Wu <jianyong.wu@xxxxxxx>
---
 plat/common/arm/time.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/plat/common/arm/time.c b/plat/common/arm/time.c
index 583387b..e3451b1 100644
--- a/plat/common/arm/time.c
+++ b/plat/common/arm/time.c
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause */
 /*
  * Authors: Wei Chen <Wei.Chen@xxxxxxx>
+ *          Jianyong Wu <Jianyong.Wu@xxxxxxx>
  *
  * Copyright (c) 2018, Arm Ltd. All rights reserved.
  *
@@ -32,16 +33,17 @@
  * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
  */
 #include <stdlib.h>
+#include <time.h>
 #include <libfdt.h>
 #include <uk/assert.h>
 #include <uk/plat/time.h>
 #include <uk/plat/irq.h>
 #include <uk/bitops.h>
-#include <cpu.h>
+#include <arm/cpu.h>
+#include <arm/rtc.h>
 
 static uint64_t boot_ticks;
 static uint32_t counter_freq;
-extern void *_libkvmplat_dtb;
 
 /*
  * Shift factor for counter scaling multiplier; referred to as S in the
@@ -86,7 +88,8 @@ static uint32_t get_counter_frequency(void)
        fdt_freq = fdt_getprop(_libkvmplat_dtb,
                        fdt_archtimer, "clock-frequency", &len);
        if (!fdt_freq || (len <= 0)) {
-               uk_pr_info("No clock-frequency found, reading from register 
directly.\n");
+               uk_printd(DLVL_INFO,
+               "No clock-frequency found, reading from register directly.\n");
                goto endnofreq;
        }
 
@@ -172,7 +175,7 @@ static int generic_timer_init(void)
        return 0;
 }
 
-unsigned long sched_have_pending_events;
+long sched_have_pending_events;
 
 void time_block_until(__snsec until)
 {
@@ -183,10 +186,24 @@ void time_block_until(__snsec until)
                 * use busy polling for now.
                 */
                if (__uk_test_and_clear_bit(0, &sched_have_pending_events))
-                       break;
+               break;
        }
 }
 
+int gettimeofday(struct timeval *tv, void *tz)
+{
+       uint64_t nsec = ukplat_monotonic_clock();
+       tv->tv_sec = rtc_boot_seconds;
+       tv->tv_sec += ukarch_time_nsec_to_sec(nsec);
+       tv->tv_usec = ukarch_time_nsec_to_usec(ukarch_time_subsec(nsec));
+
+       if(tz != NULL) {
+               /* TODO: Timezone */
+       }
+
+       return 0;
+}
+
 /* return ns since time_init() */
 __nsec ukplat_monotonic_clock(void)
 {
-- 
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®.