Fixed a few warnings.
[tangerine.git] / arch / ppc-chrp / efika / timer / lowlevel.h
blob178b997e1342fbecfd4ad7320082a3894cfb6ba4
1 /*
2 * lowlevel.h
4 * Created on: Sep 30, 2008
5 * Author: misc
6 */
8 #ifndef LOWLEVEL_H_
9 #define LOWLEVEL_H_
11 #include <inttypes.h>
12 #include "timer_intern.h"
14 #define TIMEBASE_FREQUENCY 33000000
16 void EClockUpdate(struct TimerBase *TimerBase);
17 void EClockSet(struct TimerBase *TimerBase);
18 void TimerSetup(struct TimerBase *TimerBase, uint32_t waste);
20 static volatile uint32_t mftbl()
22 uint32_t tb;
24 asm volatile("mftb %0":"=r"(tb));
26 return tb;
29 static inline uint64_t mftb()
31 uint32_t lo,hi,tmp;
33 do {
34 asm volatile("mftbu %0; mftb %1; mftbu %2":"=r"(hi),"=r"(lo),"=r"(tmp));
35 } while(tmp != hi);
37 return (((uint64_t)hi) << 32) | ((uint64_t)lo);
40 #endif /* LOWLEVEL_H_ */