2c23a4c32336267dbb0b495089fdcb3a29ed3a4a
[AROS.git] / arch / m68k-amiga / timer / readeclock.c
blob2c23a4c32336267dbb0b495089fdcb3a29ed3a4a
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: ReadEClock() - read the base frequency of timers.
6 Lang: english
7 */
9 /*****************************************************************************
11 NAME */
12 #include <devices/timer.h>
13 #include <proto/timer.h>
14 #include <proto/exec.h>
16 #include <timer_intern.h>
18 AROS_LH1(ULONG, ReadEClock,
20 /* SYNOPSIS */
21 AROS_LHA(struct EClockVal *, dest, A0),
23 /* LOCATION */
24 struct TimerBase *, TimerBase, 10, Timer)
26 /* FUNCTION
27 ReadEClock() reads current value of E-Clock and stores
28 it in the destination EClockVal structure passed as
29 argument. It also returns the frequency of EClock of the
30 system.
32 This call is supposed to be very fast.
33 INPUTS
34 dest - Destination EClockVal
36 RESULT
37 The EClock frequency (tics/s)
39 NOTES
40 This function is safe to call from interrupts.
42 EXAMPLE
44 BUGS
46 SEE ALSO
48 INTERNALS
50 HISTORY
51 19-08-2005 schulz Implemented.
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
57 ULONG eclock, old;
59 Disable();
60 old = dest->ev_lo = TimerBase->tb_eclock.ev_lo;
61 dest->ev_hi = TimerBase->tb_eclock.ev_hi;
62 eclock = GetEClock(TimerBase);
63 Enable();
64 dest->ev_lo += eclock;
65 if (old > dest->ev_lo)
66 dest->ev_hi++;
67 return TimerBase->tb_eclock_rate;
69 AROS_LIBFUNC_EXIT
70 } /* CmpTime */