revert between 56095 -> 55830 in arch
[AROS.git] / arch / m68k-amiga / timer / getuptime.c
blob4c38b13d6704f70a21cbde58a9d580666bb5c734
1 /*
2 Copyright © 2018-2019, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: GetUpTime() - Get time since machine was powered on.
6 Lang: english
7 */
8 #include <proto/exec.h>
10 #define DEBUG 0
11 #include <aros/debug.h>
13 #include <timer_intern.h>
15 #include <devices/timer.h>
16 #include <proto/timer.h>
18 /* See rom/timer/getuptime.c for documentation */
20 AROS_LH1(void, GetUpTime,
21 AROS_LHA(struct timeval *, dest, A0),
22 struct Device *, TimerBase, 12, Timer)
24 AROS_LIBFUNC_INIT
26 struct TimerBase *timerBase = (struct TimerBase *)TimerBase;
27 ULONG tb_eclock_to_usec;
29 Disable();
30 tb_eclock_to_usec = timerBase->tb_eclock_to_usec + GetEClock(timerBase);
31 Enable();
32 dest->tv_secs = timerBase->tb_Elapsed.tv_secs;
33 dest->tv_micro = (ULONG)(((long long)tb_eclock_to_usec * timerBase->tb_eclock_micro_mult) >> 16);
35 // can only overflow once, e-clock interrupts happen more than once a second
36 if (dest->tv_micro >= 1000000) {
37 dest->tv_micro -= 1000000;
38 dest->tv_secs++;
40 D(bug("uptime=%d/%d\n", dest->tv_secs, dest->tv_micro));
42 AROS_LIBFUNC_EXIT
43 } /* GetUpTime */