summaryrefslogtreecommitdiffstats
path: root/cpukit/score/cpu/powerpc
diff options
context:
space:
mode:
authorRalf Corsepius <ralf.corsepius@rtems.org>2005-02-15 14:29:40 +0000
committerRalf Corsepius <ralf.corsepius@rtems.org>2005-02-15 14:29:40 +0000
commite6cea8899f6a2d357384aeaa99e9003ffc61f4d5 (patch)
tree7d7c71d48efa048fffc703aa533a92a48713048e /cpukit/score/cpu/powerpc
parent(CPU_Get_timebase_low, rtems_bsp_delay, rtems_bsp_delay_in_bus_cycles): Remove. (diff)
downloadrtems-e6cea8899f6a2d357384aeaa99e9003ffc61f4d5.tar.bz2
(CPU_Get_timebase_low, rtems_bsp_delay, rtems_bsp_delay_in_bus_cycles): New.
Diffstat (limited to 'cpukit/score/cpu/powerpc')
-rw-r--r--cpukit/score/cpu/powerpc/rtems/score/cpu.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/cpukit/score/cpu/powerpc/rtems/score/cpu.h b/cpukit/score/cpu/powerpc/rtems/score/cpu.h
index 57fac52df3..3c561c0ae1 100644
--- a/cpukit/score/cpu/powerpc/rtems/score/cpu.h
+++ b/cpukit/score/cpu/powerpc/rtems/score/cpu.h
@@ -115,5 +115,35 @@ static inline uint32_t CPU_swap_u32(
#endif /* ASM */
+#ifndef /* ASM */
+/*
+ * Simple spin delay in microsecond units for device drivers.
+ * This is very dependent on the clock speed of the target.
+ */
+
+#define CPU_Get_timebase_low( _value ) \
+ asm volatile( "mftb %0" : "=r" (_value) )
+
+#define rtems_bsp_delay( _microseconds ) \
+ do { \
+ uint32_t start, ticks, now; \
+ CPU_Get_timebase_low( start ) ; \
+ ticks = (_microseconds) * rtems_cpu_configuration_get_clicks_per_usec(); \
+ do \
+ CPU_Get_timebase_low( now ) ; \
+ while (now - start < ticks); \
+ } while (0)
+
+#define rtems_bsp_delay_in_bus_cycles( _cycles ) \
+ do { \
+ uint32_t start, now; \
+ CPU_Get_timebase_low( start ); \
+ do \
+ CPU_Get_timebase_low( now ); \
+ while (now - start < (_cycles)); \
+ } while (0)
+
+#endif /* ASM */
+
#endif /* _RTEMS_SCORE_CPU_H */