From 8ef8e8ede9aac10608142ad4cc31b6ba82b0a770 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 23 May 2014 09:48:56 +0200 Subject: [PATCH] rtc: document current interface Issue #1148 --- repos/os/include/rtc_session/rtc_session.h | 3 +++ repos/os/src/drivers/rtc/x86/main.cc | 3 ++- repos/ports/src/app/seoul/main.cc | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/repos/os/include/rtc_session/rtc_session.h b/repos/os/include/rtc_session/rtc_session.h index 9eeb3d81db..fb5a33a884 100644 --- a/repos/os/include/rtc_session/rtc_session.h +++ b/repos/os/include/rtc_session/rtc_session.h @@ -25,6 +25,9 @@ namespace Rtc { { static const char *service_name() { return "Rtc"; } + /** + * Get microseconds elapsed since 1.1.1970 UTC. + */ virtual Genode::uint64_t get_current_time() = 0; GENODE_RPC(Rpc_get_current_time, Genode::uint64_t, get_current_time); diff --git a/repos/os/src/drivers/rtc/x86/main.cc b/repos/os/src/drivers/rtc/x86/main.cc index f24180c020..d3e02afde3 100644 --- a/repos/os/src/drivers/rtc/x86/main.cc +++ b/repos/os/src/drivers/rtc/x86/main.cc @@ -214,7 +214,8 @@ static uint64_t get_rtc_time(void) PDBG("Date:%02d.%02d.%04d Time:%02d:%02d:%02d\n", day, mon, year, hour, min, sec); - return mktime(day, mon, year, hour, min, sec) * 1000000UL; + /* return microseconds */ + return mktime(day, mon, year, hour, min, sec) * 1000000ULL; } diff --git a/repos/ports/src/app/seoul/main.cc b/repos/ports/src/app/seoul/main.cc index 05c01916d7..d24c1a1bac 100644 --- a/repos/ports/src/app/seoul/main.cc +++ b/repos/ports/src/app/seoul/main.cc @@ -1121,9 +1121,10 @@ class Machine : public StaticReceiver return true; } } - msg.wallclocktime = _rtc->get_current_time(); + /* get_current_time is in microseconds */ + msg.wallclocktime = _rtc->get_current_time() / 1000000U * MessageTime::FREQUENCY; Logging::printf("Got time %llx\n", msg.wallclocktime); - msg.timestamp = _unsynchronized_motherboard.clock()->clock(1000000U); + msg.timestamp = _unsynchronized_motherboard.clock()->clock(MessageTime::FREQUENCY); *Genode::Thread_base::myself()->utcb() = utcb_backup;