From d104cdcbaec7afe721cb9fb35a830a7f50a17862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sat, 6 Nov 2004 17:37:00 +0000 Subject: [PATCH] Moved sBootTime to an area, so that userland can clone it git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9811 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/real_time_clock.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/kernel/core/real_time_clock.c b/src/kernel/core/real_time_clock.c index 7ef1e1adac..a1a5ffe688 100644 --- a/src/kernel/core/real_time_clock.c +++ b/src/kernel/core/real_time_clock.c @@ -11,8 +11,10 @@ #include #include +#define RTC_REGION_SIZE B_PAGE_SIZE -static bigtime_t sBootTime; +static bigtime_t *sBootTime; +static region_id sRtcArea; /** Write the system time to CMOS. */ @@ -22,7 +24,7 @@ rtc_system_to_hw(void) { uint32 seconds; - seconds = (sBootTime + system_time()) / 1000000; + seconds = (*sBootTime + system_time()) / 1000000; arch_rtc_set_hw_time(seconds); } @@ -42,7 +44,7 @@ rtc_hw_to_system(void) bigtime_t rtc_boot_time(void) { - return sBootTime; + return *sBootTime; } @@ -51,9 +53,9 @@ rtc_print(void) { uint32 currentTime; - currentTime = (sBootTime + system_time()) / 1000000; + currentTime = (*sBootTime + system_time()) / 1000000; dprintf("system_time: %Ld\n", system_time()); - dprintf("boot_time: %Ld\n", sBootTime); + dprintf("boot_time: %Ld\n", *sBootTime); dprintf("current_time: %lu\n", currentTime); } @@ -79,6 +81,13 @@ rtc_init(kernel_args *ka) //dprintf("rtc_init: entry\n"); add_debugger_command("rtc", &rtc_debug, "Set and test the real-time clock"); + sRtcArea = create_area("rtc_region", (void**)&sBootTime, B_ANY_KERNEL_ADDRESS, + RTC_REGION_SIZE, B_NO_LOCK, B_READ_AREA); + if (sRtcArea < 0) { + panic("rtc_init: error creating rtc region\n"); + return B_NO_MEMORY; + } + rtc_hw_to_system(); return B_OK; @@ -92,7 +101,7 @@ rtc_init(kernel_args *ka) void set_real_time_clock(uint32 currentTime) { - sBootTime = currentTime * 1000000LL - system_time(); + *sBootTime = currentTime * 1000000LL - system_time(); rtc_system_to_hw(); } @@ -101,7 +110,7 @@ uint32 real_time_clock(void) { // ToDo: implement me - they might be used directly from libroot/os/time.c - return (sBootTime + system_time()) / 1000000; + return (*sBootTime + system_time()) / 1000000; } @@ -109,7 +118,7 @@ bigtime_t real_time_clock_usecs(void) { // ToDo: implement me - they might be used directly from libroot/os/time.c - return sBootTime + system_time(); + return *sBootTime + system_time(); }