From dc800599337a1c54853cae527e934cb74ffbb9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sat, 6 Nov 2004 17:34:39 +0000 Subject: [PATCH] first real_time_clock impl todo : setup_rtc_area should be called on startup git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9810 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/os/time.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/kernel/libroot/os/time.c b/src/kernel/libroot/os/time.c index d27d8a9e00..500c5af4b0 100644 --- a/src/kernel/libroot/os/time.c +++ b/src/kernel/libroot/os/time.c @@ -7,11 +7,35 @@ #include #include "syscalls.h" +static area_id sCloneRtcArea; +static volatile bigtime_t *sBootTime = NULL; + + +status_t +setup_rtc_area() +{ + area_id rtcArea = find_area("rtc_region"); + if (rtcArea < 0) { + printf("setup_rtc_area: error finding rtc_region %s\n", + strerror(rtcArea)); + } + sCloneRtcArea = clone_area("cloned_rtc_region", (void**)&sBootTime, + B_ANY_ADDRESS, B_READ_AREA, rtcArea); + if (sCloneRtcArea < 0) { + printf("setup_rtc_area: error cloning rtc_region\n"); + return sCloneRtcArea; + } + + return B_OK; +} + uint32 real_time_clock(void) { - // ToDo: real_time_clock() + if (!sBootTime) + setup_rtc_area(); + //return (*sBootTime + system_time()) / 1000000; return 0; } @@ -26,7 +50,9 @@ set_real_time_clock(uint32 secs) bigtime_t real_time_clock_usecs(void) { - // ToDo: real_time_clock_usecs() + if (!sBootTime) + setup_rtc_area(); + //return *sBootTime + system_time(); return 0; }