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
This commit is contained in:
Jérôme Duval 2004-11-06 17:37:00 +00:00
parent dc80059933
commit d104cdcbae
1 changed files with 17 additions and 8 deletions

View File

@ -11,8 +11,10 @@
#include <arch/real_time_clock.h> #include <arch/real_time_clock.h>
#include <real_time_clock.h> #include <real_time_clock.h>
#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. */ /** Write the system time to CMOS. */
@ -22,7 +24,7 @@ rtc_system_to_hw(void)
{ {
uint32 seconds; uint32 seconds;
seconds = (sBootTime + system_time()) / 1000000; seconds = (*sBootTime + system_time()) / 1000000;
arch_rtc_set_hw_time(seconds); arch_rtc_set_hw_time(seconds);
} }
@ -42,7 +44,7 @@ rtc_hw_to_system(void)
bigtime_t bigtime_t
rtc_boot_time(void) rtc_boot_time(void)
{ {
return sBootTime; return *sBootTime;
} }
@ -51,9 +53,9 @@ rtc_print(void)
{ {
uint32 currentTime; uint32 currentTime;
currentTime = (sBootTime + system_time()) / 1000000; currentTime = (*sBootTime + system_time()) / 1000000;
dprintf("system_time: %Ld\n", system_time()); 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); dprintf("current_time: %lu\n", currentTime);
} }
@ -79,6 +81,13 @@ rtc_init(kernel_args *ka)
//dprintf("rtc_init: entry\n"); //dprintf("rtc_init: entry\n");
add_debugger_command("rtc", &rtc_debug, "Set and test the real-time clock"); 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(); rtc_hw_to_system();
return B_OK; return B_OK;
@ -92,7 +101,7 @@ rtc_init(kernel_args *ka)
void void
set_real_time_clock(uint32 currentTime) set_real_time_clock(uint32 currentTime)
{ {
sBootTime = currentTime * 1000000LL - system_time(); *sBootTime = currentTime * 1000000LL - system_time();
rtc_system_to_hw(); rtc_system_to_hw();
} }
@ -101,7 +110,7 @@ uint32
real_time_clock(void) real_time_clock(void)
{ {
// ToDo: implement me - they might be used directly from libroot/os/time.c // 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) real_time_clock_usecs(void)
{ {
// ToDo: implement me - they might be used directly from libroot/os/time.c // ToDo: implement me - they might be used directly from libroot/os/time.c
return sBootTime + system_time(); return *sBootTime + system_time();
} }