The real_time_data structure contains an architecture specific

substructure now (that's the only member actually). The system time
offset is therefore accessed via architecture specific accessor
functions.
Note, that this commit breaks the PPC build. Since I want to rename at
least one file I've already changed, I can't avoid that.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15835 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2006-01-04 02:17:59 +00:00
parent 3a6add495c
commit 09bb4e9ac5
13 changed files with 101 additions and 43 deletions
+4 -9
View File
@@ -1,5 +1,5 @@
/*
** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Copyright 2003, Axel D�fler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
@@ -7,16 +7,11 @@
.text
// ToDo: note, this function absolutely doesn't do what it should do.
// It only reads out the time base register, but it doesn't compute
// the real system time from its value.
// To do so, the kernel has to provide the appropriate system dependent
// conversion factors.
/* uint64 system_time(void)
/* int64 __ppc_get_time_base(void)
* r3/r4
*/
FUNCTION(system_time):
FUNCTION(__ppc_get_time_base):
/* get TB (time base) register */
carry: mftbu %r3
mftb %r4
mftbu %r5 // read the upper half again
+10 -4
View File
@@ -3,15 +3,21 @@
* Distributed under the terms of the MIT License.
*/
#include <OS.h>
#include <arch_cpu.h>
#include <libroot_private.h>
#include <real_time_data.h>
#include <arch_cpu.h>
void
__arch_init_time(struct real_time_data *data)
__arch_init_time(struct real_time_data *data, bool setDefaults)
{
// TODO: Implement!
}
if (setDefaults) {
data->arch_data.data[0].system_time_offset = 0;
data->arch_data.system_time_conversion_factor = 1000000000LL;
data->arch_data.version = 0;
}
__ppc_setup_system_time(&data->arch_data.system_time_conversion_factor);
}
+1 -1
View File
@@ -11,7 +11,7 @@
cv_factor:
.word 0
FUNCTION(setup_system_time):
FUNCTION(__x86_setup_system_time):
movl 4(%esp),%eax
movl %eax,cv_factor
ret
+14 -3
View File
@@ -10,10 +10,21 @@
void
__arch_init_time(struct real_time_data *data)
__arch_init_time(struct real_time_data *data, bool setDefaults)
{
if (setDefaults) {
data->arch_data.system_time_offset = 0;
data->arch_data.system_time_conversion_factor = 100000;
}
// 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);
__x86_setup_system_time(data->arch_data.system_time_conversion_factor);
}
bigtime_t
__arch_get_system_time_offset(struct real_time_data *data)
{
return atomic_get64(&data->arch_data.system_time_offset);
}
+7 -7
View File
@@ -14,16 +14,14 @@
#include <syscalls.h>
static struct real_time_data sRealTimeDefaults = {
0,
100000
};
static struct real_time_data sRealTimeDefaults;
static struct real_time_data *sRealTimeData;
void
__init_time(void)
{
bool setDefaults = false;
area_id dataArea;
area_info info;
@@ -31,24 +29,26 @@ __init_time(void)
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;
setDefaults = true;
} else
sRealTimeData = (struct real_time_data *)info.address;
__arch_init_time(sRealTimeData);
__arch_init_time(sRealTimeData, setDefaults);
}
uint32
real_time_clock(void)
{
return (sRealTimeData->system_time_offset + system_time()) / 1000000;
return (__arch_get_system_time_offset(sRealTimeData) + system_time())
/ 1000000;
}
bigtime_t
real_time_clock_usecs(void)
{
return sRealTimeData->system_time_offset + system_time();
return __arch_get_system_time_offset(sRealTimeData) + system_time();
}