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:
parent
312ecc1ec3
commit
397e7db6df
@ -1,7 +1,7 @@
|
||||
/*
|
||||
** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
** Distributed under the terms of the Haiku License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <libroot_private.h>
|
||||
@ -37,6 +37,7 @@ initialize_before(image_id imageID, struct uspace_program_args const *args)
|
||||
__progname++;
|
||||
}
|
||||
|
||||
__init_time();
|
||||
__init_image(args);
|
||||
__init_dlfcn(args);
|
||||
__init_fork();
|
||||
|
@ -1,15 +1,15 @@
|
||||
SubDir OBOS_TOP src kernel libroot os arch x86 ;
|
||||
|
||||
KernelMergeObject os_arch_$(OBOS_ARCH).o :
|
||||
<$(SOURCE_GRIST)>atomic.S
|
||||
<$(SOURCE_GRIST)>byteorder.S
|
||||
<$(SOURCE_GRIST)>cpuid.S
|
||||
<$(SOURCE_GRIST)>systeminfo.c
|
||||
<$(SOURCE_GRIST)>system_time.S
|
||||
<$(SOURCE_GRIST)>thread.c
|
||||
<$(SOURCE_GRIST)>tls.c
|
||||
:
|
||||
-fPIC -DPIC
|
||||
atomic.S
|
||||
byteorder.S
|
||||
cpuid.S
|
||||
systeminfo.c
|
||||
system_time.S
|
||||
thread.c
|
||||
time.c
|
||||
tls.c
|
||||
: -fPIC -DPIC
|
||||
;
|
||||
|
||||
MergeObjectFromObjects kernel_os_arch_$(OBOS_ARCH).o :
|
||||
|
19
src/kernel/libroot/os/arch/x86/time.c
Normal file
19
src/kernel/libroot/os/arch/x86/time.c
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2004, Axel Dörfler, axeld@pinc-software.de.
|
||||
* 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, axeld@pinc-software.de. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
* Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include <string.h>
|
||||
#include "syscalls.h"
|
||||
#include "real_time_data.h"
|
||||
#include <syslog.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_info info;
|
||||
status_t err;
|
||||
|
||||
dataArea = find_area("real time data userland");
|
||||
|
||||
if (dataArea < 0) {
|
||||
printf("setup_rtc_boottime: error finding real time data area %s\n",
|
||||
strerror(dataArea));
|
||||
return dataArea;
|
||||
}
|
||||
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;
|
||||
|
||||
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;
|
||||
__arch_init_time(sRealTimeData);
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
real_time_clock(void)
|
||||
{
|
||||
if (!sBootTime && (setup_rtc_boottime()!=B_OK))
|
||||
return 0;
|
||||
return (*sBootTime + system_time()) / 1000000;
|
||||
return (sRealTimeData->boot_time + 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
|
||||
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
|
||||
set_alarm(bigtime_t when, uint32 flags)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user