Brought the userland time initialization into more or less final shape:
- renamed setup_rtc_boottime() to __init_time() - __init_time() is now initialized at libroot.so startup - introduced new __arch_init_time() that does the arch dependent stuff, for now it just sets the system_time() conversion factor (that's the part that will change later on) - os/time.c now keeps a pointer to the real_time_data around, not only to the boot time - maybe we'll it for other stuff as well later. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9995 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2003-2004, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2003-2004, Axel Dörfler, [email protected].
|
||||||
** Distributed under the terms of the Haiku License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <libroot_private.h>
|
#include <libroot_private.h>
|
||||||
@@ -37,6 +37,7 @@ initialize_before(image_id imageID, struct uspace_program_args const *args)
|
|||||||
__progname++;
|
__progname++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__init_time();
|
||||||
__init_image(args);
|
__init_image(args);
|
||||||
__init_dlfcn(args);
|
__init_dlfcn(args);
|
||||||
__init_fork();
|
__init_fork();
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
SubDir OBOS_TOP src kernel libroot os arch x86 ;
|
SubDir OBOS_TOP src kernel libroot os arch x86 ;
|
||||||
|
|
||||||
KernelMergeObject os_arch_$(OBOS_ARCH).o :
|
KernelMergeObject os_arch_$(OBOS_ARCH).o :
|
||||||
<$(SOURCE_GRIST)>atomic.S
|
atomic.S
|
||||||
<$(SOURCE_GRIST)>byteorder.S
|
byteorder.S
|
||||||
<$(SOURCE_GRIST)>cpuid.S
|
cpuid.S
|
||||||
<$(SOURCE_GRIST)>systeminfo.c
|
systeminfo.c
|
||||||
<$(SOURCE_GRIST)>system_time.S
|
system_time.S
|
||||||
<$(SOURCE_GRIST)>thread.c
|
thread.c
|
||||||
<$(SOURCE_GRIST)>tls.c
|
time.c
|
||||||
:
|
tls.c
|
||||||
-fPIC -DPIC
|
: -fPIC -DPIC
|
||||||
;
|
;
|
||||||
|
|
||||||
MergeObjectFromObjects kernel_os_arch_$(OBOS_ARCH).o :
|
MergeObjectFromObjects kernel_os_arch_$(OBOS_ARCH).o :
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2004, Axel Dörfler, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <libroot_private.h>
|
||||||
|
#include <real_time_data.h>
|
||||||
|
#include <arch_cpu.h>
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
__arch_init_time(struct real_time_data *data)
|
||||||
|
{
|
||||||
|
// ToDo: this should only store a pointer to that value
|
||||||
|
// ToDo: this function should not clobber the global name space
|
||||||
|
setup_system_time(data->system_time_conversion_factor);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,48 +1,54 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2002-2003, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2002-2004, Axel Dörfler, [email protected].
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "syscalls.h"
|
#include <syslog.h>
|
||||||
#include "real_time_data.h"
|
|
||||||
|
|
||||||
static volatile bigtime_t *sBootTime = NULL;
|
#include <libroot_private.h>
|
||||||
|
#include <real_time_data.h>
|
||||||
|
#include <syscalls.h>
|
||||||
|
|
||||||
static status_t
|
|
||||||
setup_rtc_boottime()
|
static struct real_time_data sRealTimeDefaults = {
|
||||||
|
0,
|
||||||
|
100000
|
||||||
|
};
|
||||||
|
static struct real_time_data *sRealTimeData;
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
__init_time(void)
|
||||||
{
|
{
|
||||||
area_id dataArea;
|
area_id dataArea;
|
||||||
area_info info;
|
area_info info;
|
||||||
status_t err;
|
|
||||||
|
|
||||||
dataArea = find_area("real time data userland");
|
dataArea = find_area("real time data userland");
|
||||||
|
if (dataArea < 0 || get_area_info(dataArea, &info) < B_OK) {
|
||||||
|
syslog(LOG_ERR, "error finding real time data area: %s\n", strerror(dataArea));
|
||||||
|
sRealTimeData = &sRealTimeDefaults;
|
||||||
|
} else
|
||||||
|
sRealTimeData = (struct real_time_data *)info.address;
|
||||||
|
|
||||||
if (dataArea < 0) {
|
__arch_init_time(sRealTimeData);
|
||||||
printf("setup_rtc_boottime: error finding real time data area %s\n",
|
|
||||||
strerror(dataArea));
|
|
||||||
return dataArea;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = get_area_info(dataArea, &info);
|
|
||||||
if (err < B_OK) {
|
|
||||||
printf("setup_rtc_boottime: error getting real time data info\n");
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
sBootTime = &(((struct real_time_data *)info.address)->boot_time);
|
|
||||||
return B_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
real_time_clock(void)
|
real_time_clock(void)
|
||||||
{
|
{
|
||||||
if (!sBootTime && (setup_rtc_boottime()!=B_OK))
|
return (sRealTimeData->boot_time + system_time()) / 1000000;
|
||||||
return 0;
|
}
|
||||||
return (*sBootTime + system_time()) / 1000000;
|
|
||||||
|
|
||||||
|
bigtime_t
|
||||||
|
real_time_clock_usecs(void)
|
||||||
|
{
|
||||||
|
return sRealTimeData->boot_time + system_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -53,15 +59,6 @@ set_real_time_clock(uint32 secs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bigtime_t
|
|
||||||
real_time_clock_usecs(void)
|
|
||||||
{
|
|
||||||
if (!sBootTime && (setup_rtc_boottime() != B_OK))
|
|
||||||
return 0;
|
|
||||||
return *sBootTime + system_time();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
set_timezone(char *timezone)
|
set_timezone(char *timezone)
|
||||||
{
|
{
|
||||||
@@ -70,17 +67,6 @@ set_timezone(char *timezone)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// ToDo: currently defined in atomic.S - but should be in its own file time.S
|
|
||||||
bigtime_t
|
|
||||||
system_time(void)
|
|
||||||
{
|
|
||||||
// time since booting in microseconds
|
|
||||||
return sys_system_time();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
bigtime_t
|
bigtime_t
|
||||||
set_alarm(bigtime_t when, uint32 flags)
|
set_alarm(bigtime_t when, uint32 flags)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user