xref: /haiku/src/system/libroot/os/arch/m68k/system_time.c (revision 188b43270e2328e8b3338441969b54a159ea0daa)
1*188b4327SFrançois Revol /*
2*188b4327SFrançois Revol  * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3*188b4327SFrançois Revol  * All rights reserved. Distributed under the terms of the MIT License.
4*188b4327SFrançois Revol  */
5*188b4327SFrançois Revol 
6*188b4327SFrançois Revol #include <OS.h>
7*188b4327SFrançois Revol 
8*188b4327SFrançois Revol #include <arch_cpu.h>
9*188b4327SFrançois Revol #include <libroot_private.h>
10*188b4327SFrançois Revol #include <real_time_data.h>
11*188b4327SFrançois Revol 
12*188b4327SFrançois Revol 
13*188b4327SFrançois Revol static vint32 *sConversionFactor;
14*188b4327SFrançois Revol 
15*188b4327SFrançois Revol void
16*188b4327SFrançois Revol __ppc_setup_system_time(vint32 *cvFactor)
17*188b4327SFrançois Revol {
18*188b4327SFrançois Revol 	sConversionFactor = cvFactor;
19*188b4327SFrançois Revol }
20*188b4327SFrançois Revol 
21*188b4327SFrançois Revol 
22*188b4327SFrançois Revol bigtime_t
23*188b4327SFrançois Revol system_time(void)
24*188b4327SFrançois Revol {
25*188b4327SFrançois Revol 	uint64 timeBase = __ppc_get_time_base();
26*188b4327SFrançois Revol 
27*188b4327SFrançois Revol 	uint32 cv = *sConversionFactor;
28*188b4327SFrançois Revol 	return (timeBase >> 32) * cv + (((timeBase & 0xffffffff) * cv) >> 32);
29*188b4327SFrançois Revol }
30