revert between 56095 -> 55830 in arch
[AROS.git] / arch / ppc-chrp / efika / timer / lowlevel.h
blob963401dbc2e1b85dfd92c70caf0ffb5c5c3d16a0
1 /*
2 Copyright © 2008-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #ifndef LOWLEVEL_H_
7 #define LOWLEVEL_H_
9 #include <inttypes.h>
10 #include "timer_intern.h"
12 #define TIMEBASE_FREQUENCY 33000000
14 extern uint32_t tbc_expected;
15 extern uint32_t tbc_achieved;
16 extern int32_t corr;
18 void EClockUpdate(struct TimerBase *TimerBase);
19 void EClockSet(struct TimerBase *TimerBase);
20 void TimerSetup(struct TimerBase *TimerBase, uint32_t waste);
22 static volatile uint32_t mftbl()
24 uint32_t tb;
26 asm volatile("mftb %0":"=r"(tb));
28 return tb;
31 static inline uint64_t mftb()
33 uint32_t lo,hi,tmp;
35 do {
36 asm volatile("mftbu %0; mftb %1; mftbu %2":"=r"(hi),"=r"(lo),"=r"(tmp));
37 } while(tmp != hi);
39 return (((uint64_t)hi) << 32) | ((uint64_t)lo);
42 #endif /* LOWLEVEL_H_ */