Index: c/src/lib/libbsp/arm/csb336/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/csb336/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/csb336/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -34,4 +34,6 @@
     ../../shared/bspreset.c startup/memmap.c ../../shared/bootcard.c \
     ../../shared/sbrk.c ../../shared/gnatinstallhandler.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 # console
 libbsp_a_SOURCES += console/uart.c
Index: c/src/lib/libbsp/arm/csb337/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/csb337/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/csb337/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -57,4 +57,6 @@
     startup/memmap.c ../../shared/bootcard.c ../../shared/sbrk.c \
     ../../shared/gnatinstallhandler.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 # console
 libbsp_a_SOURCES += ../../shared/console.c console/uarts.c \
Index: c/src/lib/libbsp/arm/edb7312/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/edb7312/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/edb7312/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -36,4 +36,6 @@
     ../../shared/bspclean.c ../../shared/bootcard.c ../../shared/sbrk.c \
     startup/bspreset.c ../../shared/gnatinstallhandler.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 
 # clock
Index: c/src/lib/libbsp/arm/gba/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/gba/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/gba/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -39,4 +39,6 @@
     ../../shared/gnatinstallhandler.c \
     startup/bspstart.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 # clock
 libbsp_a_SOURCES += clock/clockdrv.c
Index: c/src/lib/libbsp/arm/gdbarmsim/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/gdbarmsim/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/gdbarmsim/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -34,4 +34,6 @@
     ../../shared/bspclean.c startup/bspreset.c ../../shared/bootcard.c \
     ../../shared/sbrk.c ../../shared/gnatinstallhandler.c startup/syscalls.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 # console
 libbsp_a_SOURCES += ../../shared/console-polled.c console/console-io.c
Index: c/src/lib/libbsp/arm/gp32/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/gp32/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/gp32/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -35,4 +35,6 @@
     startup/memmap.c ../../shared/bootcard.c ../../shared/sbrk.c \
     ../../shared/gnatinstallhandler.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 # console
 libbsp_a_SOURCES += console/uart.c ../../shared/console.c \
Index: c/src/lib/libbsp/arm/gumstix/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/gumstix/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/gumstix/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -34,4 +34,6 @@
   ../../shared/gnatinstallhandler.c ../../shared/bsppretaskinghook.c \
   ../../shared/bspclean.c startup/bspstart.c startup/bspreset.c startup/memmap.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 
 #console
Index: c/src/lib/libbsp/arm/lm3s69xx/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/lm3s69xx/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/lm3s69xx/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -69,4 +69,6 @@
 libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
 libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
 libbsp_a_SOURCES += ../../shared/sbrk.c
Index: c/src/lib/libbsp/arm/lpc24xx/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/lpc24xx/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/lpc24xx/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -102,4 +102,5 @@
 	../../shared/src/stackalloc.c \
 	../../shared/src/uart-output-char.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 
 # Startup
Index: c/src/lib/libbsp/arm/lpc24xx/misc/system-clocks.c
===================================================================
--- c/src/lib/libbsp/arm/lpc24xx/misc/system-clocks.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/lpc24xx/misc/system-clocks.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -8,5 +8,5 @@
 
 /*
- * Copyright (c) 2008-2012 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2008-2014 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
@@ -20,4 +20,6 @@
  * http://www.rtems.com/license/LICENSE.
  */
+
+#include <rtems/counter.h>
 
 #include <bsp.h>
@@ -60,4 +62,11 @@
   /* Start timer */
   T1TCR = TCR_EN;
+
+  rtems_counter_initialize_converter(LPC24XX_PCLK);
+}
+
+CPU_Counter_ticks _CPU_Counter_read(void)
+{
+  return lpc24xx_timer();
 }
 
Index: c/src/lib/libbsp/arm/lpc32xx/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/lpc32xx/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/lpc32xx/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -89,4 +89,5 @@
 libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
 libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
 libbsp_a_SOURCES += ../../shared/sbrk.c
Index: c/src/lib/libbsp/arm/lpc32xx/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/arm/lpc32xx/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/lpc32xx/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -8,5 +8,5 @@
 
 /*
- * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2009-2014 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
@@ -21,13 +21,18 @@
  */
 
+#include <rtems/counter.h>
+
 #include <bsp.h>
 #include <bsp/bootcard.h>
 #include <bsp/irq-generic.h>
-#include <bsp/irq.h>
-#include <bsp/linker-symbols.h>
-#include <bsp/lpc32xx.h>
+
+CPU_Counter_ticks _CPU_Counter_read(void)
+{
+  return lpc32xx_timer();
+}
 
 void bsp_start(void)
 {
+  rtems_counter_initialize_converter(LPC32XX_PERIPH_CLK);
   bsp_interrupt_initialize();
 }
Index: c/src/lib/libbsp/arm/nds/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/nds/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/nds/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -36,4 +36,6 @@
     ../../shared/bspgetworkarea.c ../../shared/bsppredriverhook.c \
     ../../shared/bsppretaskinghook.c ../../shared/bootcard.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 startup_rel_CPPFLAGS = $(AM_CPPFLAGS) -DARM9 -I$(srcdir)/libnds/include
 startup_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
Index: c/src/lib/libbsp/arm/raspberrypi/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/raspberrypi/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/raspberrypi/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -81,4 +81,6 @@
 libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
 libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
 libbsp_a_SOURCES += ../../shared/sbrk.c
Index: c/src/lib/libbsp/arm/realview-pbx-a9/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/realview-pbx-a9/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/realview-pbx-a9/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -85,4 +85,5 @@
 libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
 libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
 libbsp_a_SOURCES += ../../shared/sbrk.c
Index: c/src/lib/libbsp/arm/rtl22xx/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/rtl22xx/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/rtl22xx/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -37,4 +37,6 @@
     ../../shared/bootcard.c ../../shared/sbrk.c \
     ../../shared/gnatinstallhandler.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 # console
 libbsp_a_SOURCES += ../../shared/console.c \
Index: c/src/lib/libbsp/arm/shared/arm-a9mpcore-clock-config.c
===================================================================
--- c/src/lib/libbsp/arm/shared/arm-a9mpcore-clock-config.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/shared/arm-a9mpcore-clock-config.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -12,4 +12,6 @@
  * http://www.rtems.com/license/LICENSE.
  */
+
+#include <rtems/counter.h>
 
 #include <bsp.h>
@@ -95,4 +97,13 @@
     | A9MPCORE_GT_CTRL_COMP_EN
     | A9MPCORE_GT_CTRL_TMR_EN;
+
+  rtems_counter_initialize_converter((uint32_t) periphclk);
+}
+
+CPU_Counter_ticks _CPU_Counter_read(void)
+{
+  volatile a9mpcore_gt *gt = A9MPCORE_GT;
+
+  return gt->cntrlower;
 }
 
Index: c/src/lib/libbsp/arm/smdk2410/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/smdk2410/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/smdk2410/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -35,4 +35,6 @@
     ../../shared/bsppredriverhook.c ../../shared/bspgetworkarea.c \
     ../../shared/gnatinstallhandler.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 # console
 libbsp_a_SOURCES += ../gp32/console/uart.c ../../shared/console.c \
Index: c/src/lib/libbsp/arm/stm32f4/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/stm32f4/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/stm32f4/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -77,4 +77,6 @@
 libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
 libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
 libbsp_a_SOURCES += ../../shared/sbrk.c
Index: c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am
===================================================================
--- c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -79,4 +79,5 @@
 libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
 libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
 libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
 libbsp_a_SOURCES += ../../shared/sbrk.c
Index: c/src/lib/libbsp/powerpc/beatnik/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/beatnik/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/beatnik/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -32,4 +32,5 @@
 #include <rtems/libcsupport.h>
 #include <rtems/bspIo.h>
+#include <rtems/counter.h>
 #include <rtems/powerpc/powerpc.h>
 /*#include <bsp/consoleIo.h>*/
@@ -338,4 +339,7 @@
 
   bsp_clicks_per_usec = BSP_bus_frequency/(BSP_time_base_divisor * 1000);
+  rtems_counter_initialize_converter(
+    BSP_bus_frequency / (BSP_time_base_divisor / 1000)
+  );
 
 #ifdef SHOW_MORE_INIT_SETTINGS
Index: c/src/lib/libbsp/powerpc/ep1a/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/ep1a/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/ep1a/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -28,4 +28,5 @@
 #include <bsp/vectors.h>
 #include <rtems/powerpc/powerpc.h>
+#include <rtems/counter.h>
 
 extern unsigned long __bss_start[], __SBSS_START__[], __SBSS_END__[];
@@ -301,4 +302,7 @@
 
   bsp_clicks_per_usec = BSP_processor_frequency/(BSP_time_base_divisor * 1000);
+  rtems_counter_initialize_converter(
+    BSP_processor_frequency / (BSP_time_base_divisor / 1000)
+  );
 
 ShowBATS();
Index: c/src/lib/libbsp/powerpc/gen5200/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/gen5200/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -96,4 +96,5 @@
 
 #include <rtems.h>
+#include <rtems/counter.h>
 
 #include <libcpu/powerpc-utility.h>
@@ -165,4 +166,5 @@
   bsp_time_base_frequency = XLB_CLOCK / 4;
   bsp_clicks_per_usec    = (XLB_CLOCK/4000000);
+  rtems_counter_initialize_converter(bsp_time_base_frequency);
 
   /* Initialize exception handler */
Index: c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -19,4 +19,6 @@
  * http://www.rtems.com/license/LICENSE.
  */
+
+#include <rtems/counter.h>
 
 #include <libchip/serial.h>
@@ -118,4 +120,5 @@
   bsp_time_base_frequency = BSP_bus_frequency / 4;
   bsp_clicks_per_usec = bsp_time_base_frequency / 1000000;
+  rtems_counter_initialize_converter(bsp_time_base_frequency);
 
   /* Initialize some console parameters */
Index: c/src/lib/libbsp/powerpc/haleakala/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/haleakala/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/haleakala/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -59,4 +59,6 @@
 #include <string.h>
 #include <fcntl.h>
+
+#include <rtems/counter.h>
 
 #include <bsp.h>
@@ -195,4 +197,5 @@
   /* timebase register ticks/microsecond = CPU Clk in MHz */
   bsp_clicks_per_usec = 400;
+  rtems_counter_initialize_converter(bsp_clicks_per_usec * 1000000);
 
   bsp_timer_internal_clock  = TRUE;
Index: c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -20,4 +20,5 @@
 #include <bsp/irq.h>
 #include <rtems/bspIo.h>
+#include <rtems/counter.h>
 #include <libcpu/cpuIdent.h>
 #include <libcpu/spr.h>
@@ -143,4 +144,5 @@
   bsp_clicks_per_usec = 1;  /* for 4MHz extclk */
 #endif
+  rtems_counter_initialize_converter(bsp_clicks_per_usec * 1000000);
 
   bsp_serial_per_sec = 10000000;
Index: c/src/lib/libbsp/powerpc/mpc55xxevb/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/mpc55xxevb/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/mpc55xxevb/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -30,4 +30,5 @@
 #include <rtems.h>
 #include <rtems/config.h>
+#include <rtems/counter.h>
 
 #include <libcpu/powerpc-utility.h>
@@ -104,4 +105,5 @@
 	/* Time reference value */
 	bsp_clicks_per_usec = bsp_clock_speed / 1000000;
+	rtems_counter_initialize_converter(bsp_clock_speed);
 
 	/* Initialize exceptions */
Index: c/src/lib/libbsp/powerpc/mpc8260ads/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/mpc8260ads/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/mpc8260ads/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -45,4 +45,5 @@
 
 #include <rtems/bspIo.h>
+#include <rtems/counter.h>
 #include <bsp/irq.h>
 #include <libcpu/cpuIdent.h>
@@ -209,4 +210,5 @@
   bsp_timer_least_valid    = 3;
   bsp_clock_speed 	   = 40000000;
+  rtems_counter_initialize_converter(bsp_clock_speed);
 
 #ifdef REV_0_2
Index: c/src/lib/libbsp/powerpc/mvme3100/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/mvme3100/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/mvme3100/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -24,4 +24,5 @@
 #include <bsp.h>
 #include <rtems/bspIo.h>
+#include <rtems/counter.h>
 #include <libcpu/spr.h>
 #include <libcpu/io.h>
@@ -385,4 +386,7 @@
 
 	bsp_clicks_per_usec = BSP_bus_frequency/(BSP_time_base_divisor * 1000);
+	rtems_counter_initialize_converter(
+		BSP_bus_frequency / (BSP_time_base_divisor / 1000)
+	);
 
 	/*
Index: c/src/lib/libbsp/powerpc/mvme5500/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/mvme5500/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/mvme5500/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -41,4 +41,5 @@
 
 #include <rtems/bspIo.h>
+#include <rtems/counter.h>
 #include <rtems/sptables.h>
 
@@ -288,4 +289,7 @@
 
   bsp_clicks_per_usec    = BSP_bus_frequency/(BSP_time_base_divisor * 1000);
+  rtems_counter_initialize_converter(
+    BSP_bus_frequency / (BSP_time_base_divisor / 1000)
+  );
 
   /*
Index: c/src/lib/libbsp/powerpc/psim/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/psim/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/psim/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -21,4 +21,5 @@
 #include <bsp/linker-symbols.h>
 #include <rtems/bspIo.h>
+#include <rtems/counter.h>
 #include <rtems/powerpc/powerpc.h>
 
@@ -93,4 +94,5 @@
   bsp_clicks_per_usec      = BSP_bus_frequency;
   BSP_time_base_divisor    = 1;
+  rtems_counter_initialize_converter(bsp_clicks_per_usec * 1000000);
 
   /*
Index: c/src/lib/libbsp/powerpc/qemuppc/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/qemuppc/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/qemuppc/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -15,4 +15,6 @@
 #include <string.h>
 #include <fcntl.h>
+
+#include <rtems/counter.h>
 
 #include <libcpu/bat.h>
@@ -80,4 +82,5 @@
   bsp_time_base_frequency  = 20000000;
   bsp_clicks_per_usec      = BSP_bus_frequency;
+  rtems_counter_initialize_converter(bsp_time_base_frequency);
 
   /*
Index: c/src/lib/libbsp/powerpc/qoriq/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/qoriq/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/qoriq/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -23,4 +23,5 @@
 #include <rtems.h>
 #include <rtems/config.h>
+#include <rtems/counter.h>
 
 #include <libchip/serial.h>
@@ -90,4 +91,5 @@
     bsp_clicks_per_usec = bsp_uboot_board_info.bi_busfreq / 8000000;
   #endif /* HAS_UBOOT */
+  rtems_counter_initialize_converter(BSP_bus_frequency / 8);
 
   /* Initialize some console parameters */
Index: c/src/lib/libbsp/powerpc/score603e/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/score603e/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/score603e/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -20,4 +20,5 @@
 #include <rtems/libcsupport.h>
 #include <rtems/bspIo.h>
+#include <rtems/counter.h>
 #include <libcpu/cpuIdent.h>
 #include <bsp/irq.h>
@@ -211,4 +212,5 @@
   #endif
   bsp_clicks_per_usec = 66 / 4;
+  rtems_counter_initialize_converter(bsp_clicks_per_usec * 1000000);
 
   #if BSP_DATA_CACHE_ENABLED
Index: c/src/lib/libbsp/powerpc/shared/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/shared/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/shared/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -20,4 +20,5 @@
 #include <bsp.h>
 #include <rtems/bspIo.h>
+#include <rtems/counter.h>
 #include <bsp/consoleIo.h>
 #include <libcpu/spr.h>
@@ -343,4 +344,7 @@
    */
   bsp_clicks_per_usec 	 = BSP_bus_frequency/(BSP_time_base_divisor * 1000);
+  rtems_counter_initialize_converter(
+    BSP_bus_frequency / (BSP_time_base_divisor / 1000)
+  );
 
   /*
Index: c/src/lib/libbsp/powerpc/ss555/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/ss555/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/ss555/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -25,4 +25,5 @@
 
 #include <rtems/bspIo.h>
+#include <rtems/counter.h>
 #include <rtems/powerpc/powerpc.h>
 
@@ -109,4 +110,5 @@
   bsp_timer_least_valid      = 0;
   bsp_timer_average_overhead = 0;
+  rtems_counter_initialize_converter(BSP_CRYSTAL_HZ / 4);
 
   /*
Index: c/src/lib/libbsp/powerpc/t32mppc/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/t32mppc/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/t32mppc/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -14,4 +14,5 @@
 
 #include <rtems/config.h>
+#include <rtems/counter.h>
 
 #include <bsp.h>
@@ -64,4 +65,6 @@
   get_ppc_cpu_revision();
 
+  rtems_counter_initialize_converter(bsp_time_base_frequency);
+
   /* Initialize exception handler */
   ppc_exc_initialize_with_vector_base(
Index: c/src/lib/libbsp/powerpc/tqm8xx/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/tqm8xx/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/tqm8xx/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -23,4 +23,5 @@
 
 #include <rtems.h>
+#include <rtems/counter.h>
 
 #include <libcpu/powerpc-utility.h>
@@ -180,4 +181,5 @@
   bsp_timer_least_valid = 3;
   bsp_timer_average_overhead = 3;
+  rtems_counter_initialize_converter(bsp_time_base_frequency);
 
   /* Initialize exception handler */
Index: c/src/lib/libbsp/powerpc/virtex/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/virtex/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/virtex/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -55,4 +55,6 @@
  */
 
+#include <rtems/counter.h>
+
 #include <bsp.h>
 #include <bsp/irq.h>
@@ -88,4 +90,6 @@
   get_ppc_cpu_revision();
 
+  rtems_counter_initialize_converter(bsp_time_base_frequency);
+
   /*
    * Initialize default raw exception handlers.
Index: c/src/lib/libbsp/powerpc/virtex4/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/virtex4/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/virtex4/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -58,4 +58,5 @@
 #include <rtems/config.h>
 #include <rtems/bspIo.h>
+#include <rtems/counter.h>
 #include <rtems/libio.h>
 #include <rtems/libcsupport.h>
@@ -200,4 +201,5 @@
   bsp_timer_average_overhead = 2;
   bsp_timer_least_valid      = 3;
+  rtems_counter_initialize_converter(bsp_clicks_per_usec * 1000000);
 
   /*
Index: c/src/lib/libbsp/powerpc/virtex5/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/virtex5/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/powerpc/virtex5/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -58,4 +58,5 @@
 #include <rtems/config.h>
 #include <rtems/bspIo.h>
+#include <rtems/counter.h>
 #include <rtems/libio.h>
 #include <rtems/libcsupport.h>
@@ -215,4 +216,7 @@
   /* Timebase register ticks/microsecond;  The application may override these */
   bsp_clicks_per_usec        = BSP_bus_frequency/(BSP_time_base_divisor * 1000);
+  rtems_counter_initialize_converter(
+    BSP_bus_frequency / (BSP_time_base_divisor / 1000)
+  );
   bsp_timer_internal_clock   = true;
   bsp_timer_average_overhead = 2;
Index: c/src/lib/libbsp/shared/cpucounterdiff.c
===================================================================
--- c/src/lib/libbsp/shared/cpucounterdiff.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
+++ c/src/lib/libbsp/shared/cpucounterdiff.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <rtems/score/cpu.h>
+
+CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
Index: c/src/lib/libbsp/shared/cpucounterread.c
===================================================================
--- c/src/lib/libbsp/shared/cpucounterread.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
+++ c/src/lib/libbsp/shared/cpucounterread.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <rtems/score/cpu.h>
+
+CPU_Counter_ticks _CPU_Counter_read( void )
+{
+  static CPU_Counter_ticks counter;
+
+  CPU_Counter_ticks snapshot;
+
+  snapshot = counter;
+  counter = snapshot + 1;
+
+  return snapshot;
+}
Index: c/src/lib/libbsp/sparc/erc32/Makefile.am
===================================================================
--- c/src/lib/libbsp/sparc/erc32/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/sparc/erc32/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -36,4 +36,5 @@
     startup/erc32mec.c startup/boardinit.S startup/bspidle.c \
     startup/bspdelay.c ../../sparc/shared/startup/early_malloc.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
 # ISR Handler
 libbsp_a_SOURCES += ../../sparc/shared/irq_asm.S
Index: c/src/lib/libbsp/sparc/leon2/Makefile.am
===================================================================
--- c/src/lib/libbsp/sparc/leon2/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/sparc/leon2/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -53,4 +53,5 @@
     ../../shared/bspinit.c startup/bspdelay.c \
     ../../sparc/shared/startup/early_malloc.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
 # ISR Handler
 libbsp_a_SOURCES += ../../sparc/shared/irq_asm.S
Index: c/src/lib/libbsp/sparc/leon3/Makefile.am
===================================================================
--- c/src/lib/libbsp/sparc/leon3/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/sparc/leon3/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -39,4 +39,5 @@
     startup/spurious.c startup/bspidle.S startup/bspdelay.c \
     ../../shared/bspinit.c ../../sparc/shared/startup/early_malloc.c
+libbsp_a_SOURCES += startup/cpucounter.c
 
 # ISR Handler
Index: c/src/lib/libbsp/sparc/leon3/include/bsp.h
===================================================================
--- c/src/lib/libbsp/sparc/leon3/include/bsp.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/sparc/leon3/include/bsp.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -210,4 +210,8 @@
 extern void BSP_shared_interrupt_mask(int irq);
 
+typedef enum {
+  LEON3_FATAL_CPU_COUNTER_INIT
+} leon3_fatal_code;
+
 #ifdef __cplusplus
 }
Index: c/src/lib/libbsp/sparc/leon3/include/leon.h
===================================================================
--- c/src/lib/libbsp/sparc/leon3/include/leon.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/sparc/leon3/include/leon.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -318,4 +318,6 @@
 void leon3_secondary_cpu_initialize(uint32_t cpu);
 
+void leon3_cpu_counter_initialize(void);
+
 void bsp_debug_uart_init(void);
 
Index: c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/sparc/leon3/startup/bspstart.c	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ c/src/lib/libbsp/sparc/leon3/startup/bspstart.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -80,4 +80,5 @@
    */
   amba_initialize();
+  leon3_cpu_counter_initialize();
 
   /* find debug UART for printk() */
Index: c/src/lib/libbsp/sparc/leon3/startup/cpucounter.c
===================================================================
--- c/src/lib/libbsp/sparc/leon3/startup/cpucounter.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
+++ c/src/lib/libbsp/sparc/leon3/startup/cpucounter.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <bsp.h>
+#include <leon.h>
+
+#include <rtems/counter.h>
+
+static volatile struct gptimer_regs *leon3_cpu_counter_gpt;
+
+void leon3_cpu_counter_initialize(void)
+{
+  struct ambapp_dev *adev;
+  int idx = 1;
+  volatile struct gptimer_regs *gpt;
+  unsigned new_prescaler = 8;
+  unsigned prescaler;
+  uint32_t frequency;
+
+  adev = (void *) ambapp_for_each(
+    &ambapp_plb,
+    OPTIONS_ALL | OPTIONS_APB_SLVS,
+    VENDOR_GAISLER,
+    GAISLER_GPTIMER,
+    ambapp_find_by_idx,
+    &idx
+  );
+  if (adev == NULL) {
+    rtems_fatal(RTEMS_FATAL_SOURCE_BSP_SPECIFIC, LEON3_FATAL_CPU_COUNTER_INIT);
+  }
+
+  gpt = (volatile struct gptimer_regs *) DEV_TO_APB(adev)->start;
+
+  prescaler = gpt->scaler_reload + 1;
+  gpt->scaler_reload = new_prescaler - 1;
+  gpt->timer[0].reload = 0xffffffff;
+  gpt->timer[0].ctrl = LEON3_GPTIMER_EN | LEON3_GPTIMER_RL
+    | LEON3_GPTIMER_LD;
+
+  leon3_cpu_counter_gpt = gpt;
+
+  /* Assume that GRMON initialized the timer to 1MHz */
+  frequency = UINT32_C(1000000) * (prescaler / new_prescaler);
+  rtems_counter_initialize_converter(frequency);
+}
+
+CPU_Counter_ticks _CPU_Counter_read(void)
+{
+  volatile struct gptimer_regs *gpt = leon3_cpu_counter_gpt;
+
+  return 0U - gpt->timer[0].value;
+}
Index: cpukit/sapi/Makefile.am
===================================================================
--- cpukit/sapi/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/sapi/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -7,4 +7,5 @@
 include_rtems_HEADERS += include/rtems/chain.h
 include_rtems_HEADERS += include/rtems/config.h
+include_rtems_HEADERS += include/rtems/counter.h
 include_rtems_HEADERS += include/rtems/extension.h
 include_rtems_HEADERS += include/rtems/extensionimpl.h
@@ -33,4 +34,7 @@
     src/fatal2.c src/fatalsrctext.c
 libsapi_a_SOURCES += src/chainsmp.c
+libsapi_a_SOURCES += src/cpucounterconverter.c
+libsapi_a_SOURCES += src/delayticks.c
+libsapi_a_SOURCES += src/delaynano.c
 libsapi_a_CPPFLAGS = $(AM_CPPFLAGS)
 
Index: cpukit/sapi/include/rtems/counter.h
===================================================================
--- cpukit/sapi/include/rtems/counter.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
+++ cpukit/sapi/include/rtems/counter.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -0,0 +1,160 @@
+/**
+ * @file
+ *
+ * @ingroup ClassicCounter
+ * 
+ * @brief Free-Running Counter and Busy Wait Delay API
+ */
+
+/*
+ * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifndef _RTEMS_SAPI_COUNTER_H
+#define _RTEMS_SAPI_COUNTER_H
+
+#include <rtems/score/cpu.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup ClassicCounter Free-Running Counter and Busy Wait Delay
+ *
+ * @ingroup ClassicRTEMS
+ *
+ * @brief Free-running counter and busy wait delay functions.
+ *
+ * The RTEMS counter is some free-running counter.  It ticks usually with a
+ * frequency close to the CPU or system bus clock.
+ *
+ * The counter can be used in case the overhead of the
+ * rtems_clock_get_uptime_nanoseconds() is too high.  The step from counter
+ * ticks to/from nanoseconds is explicit in this API unlike to
+ * rtems_clock_get_uptime_nanoseconds() which performs the conversion on each
+ * invocation.
+ *
+ * This counter works without a clock driver and during system initialization.
+ *
+ * The counter can be used to profile low-level operations like SMP locks or
+ * interrupt disabled critical sections.  The counter can act also as an
+ * entropy source for a random number generator. 
+ *
+ * The period of the counter depends on the actual hardware.
+ *
+ * @{
+ */
+
+/**
+ * @brief Unsigned integer type for counter values.
+ */
+typedef CPU_Counter_ticks rtems_counter_ticks;
+
+/**
+ * @brief Reads the current counter values.
+ *
+ * @return The current counter values.
+ */
+static inline rtems_counter_ticks rtems_counter_read( void )
+{
+  return _CPU_Counter_read();
+}
+
+/**
+ * @brief Returns the difference between the second and first CPU counter
+ * value.
+ *
+ * This operation may be carried out as a modulo operation depending on the
+ * range of the CPU counter device.
+ *
+ * @param[in] second The second CPU counter value.
+ * @param[in] first The first CPU counter value.
+ *
+ * @return Returns second minus first modulo counter period.
+ */
+static inline rtems_counter_ticks rtems_counter_difference(
+  rtems_counter_ticks second,
+  rtems_counter_ticks first
+)
+{
+  return _CPU_Counter_difference( second, first );
+}
+
+/**
+ * brief Converts counter ticks into nanoseconds.
+ *
+ * @param[in] ticks Some counter ticks.
+ *
+ * @return The nanoseconds corresponding to the counter ticks.  The value is
+ * rounded up.
+ */
+uint64_t rtems_counter_ticks_to_nanoseconds(
+  rtems_counter_ticks ticks
+);
+
+/**
+ * brief Converts nanoseconds into counter ticks.
+ *
+ * @param[in] nanoseconds Some nanoseconds.
+ *
+ * @return The counter ticks corresponding to the nanoseconds.  The value is
+ * rounded up.
+ */
+rtems_counter_ticks rtems_counter_nanoseconds_to_ticks(
+  uint32_t nanoseconds
+);
+
+/**
+ * brief Initializes the counter ticks to/from nanoseconds converter functions.
+ *
+ * This function must be used to initialize the
+ * rtems_counter_ticks_to_nanoseconds() and
+ * rtems_counter_nanoseconds_to_ticks() functions.  It should be called during
+ * system initialization by the board support package.
+ *
+ * @param[in] uint32_t frequency The current counter frequency in Hz.
+ */
+void rtems_counter_initialize_converter( uint32_t frequency );
+
+/**
+ * @brief Busy wait for some counter ticks.
+ *
+ * This function does not disable interrupts.  Thus task switches and
+ * interrupts can interfere with this busy wait may prolong the delay.  This
+ * function busy waits at least the specified time.  Due to some overhead the
+ * actual delay may be longer.
+ *
+ * @param[in] ticks The minimum busy wait time in counter ticks.
+ */
+void rtems_counter_delay_ticks( rtems_counter_ticks ticks );
+
+/**
+ * @brief Busy wait for some nanoseconds.
+ *
+ * This function does not disable interrupts.  Thus task switches and
+ * interrupts can interfere with this busy wait may prolong the delay.  This
+ * function busy waits at least the specified time.  Due to some overhead the
+ * actual delay may be longer.
+ *
+ * @param[in] nanoseconds The minimum busy wait time in nanoseconds.
+ */
+void rtems_counter_delay_nanoseconds( uint32_t nanoseconds );
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _RTEMS_SAPI_COUNTER_H */
Index: cpukit/sapi/preinstall.am
===================================================================
--- cpukit/sapi/preinstall.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/sapi/preinstall.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -40,4 +40,8 @@
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/config.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/config.h
+
+$(PROJECT_INCLUDE)/rtems/counter.h: include/rtems/counter.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/counter.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/counter.h
 
 $(PROJECT_INCLUDE)/rtems/extension.h: include/rtems/extension.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
Index: cpukit/sapi/src/cpucounterconverter.c
===================================================================
--- cpukit/sapi/src/cpucounterconverter.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
+++ cpukit/sapi/src/cpucounterconverter.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <rtems/counter.h>
+
+RTEMS_STATIC_ASSERT(sizeof(rtems_counter_ticks) <= sizeof(uint32_t), type);
+
+static uint64_t to_ns_scaler = UINT64_C(1) << 32;
+
+static uint64_t from_ns_scaler = UINT64_C(1) << 32;
+
+uint64_t rtems_counter_ticks_to_nanoseconds( rtems_counter_ticks counter )
+{
+  return (uint32_t) ((counter * to_ns_scaler) >> 32);
+}
+
+rtems_counter_ticks rtems_counter_nanoseconds_to_ticks( uint32_t nanoseconds )
+{
+  return (rtems_counter_ticks) ((nanoseconds * from_ns_scaler) >> 32);
+}
+
+void rtems_counter_initialize_converter( uint32_t frequency )
+{
+  uint64_t ns_per_s = UINT64_C(1000000000);
+
+  to_ns_scaler = ((ns_per_s << 32) + frequency - 1) / frequency;
+  from_ns_scaler = ((UINT64_C(1) << 32) * frequency + ns_per_s - 1) / ns_per_s;
+}
Index: cpukit/sapi/src/delaynano.c
===================================================================
--- cpukit/sapi/src/delaynano.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
+++ cpukit/sapi/src/delaynano.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems/counter.h>
+
+void rtems_counter_delay_nanoseconds( uint32_t nanoseconds )
+{
+  rtems_counter_ticks ticks =
+    rtems_counter_nanoseconds_to_ticks( nanoseconds );
+
+  rtems_counter_delay_ticks( ticks );
+}
Index: cpukit/sapi/src/delayticks.c
===================================================================
--- cpukit/sapi/src/delayticks.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
+++ cpukit/sapi/src/delayticks.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems/counter.h>
+
+void rtems_counter_delay_ticks( rtems_counter_ticks ticks )
+{
+  rtems_counter_ticks a = rtems_counter_read();
+  rtems_counter_ticks delta = 0;
+
+  do {
+    rtems_counter_ticks b;
+
+    ticks -= delta;
+
+    b = rtems_counter_read();
+    delta = rtems_counter_difference( b, a );
+    a = b;
+  } while ( ticks > delta );
+}
Index: cpukit/score/cpu/arm/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/arm/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/arm/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -555,4 +555,13 @@
 #endif
 }
+
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+);
 
 #if CPU_PROVIDES_IDLE_THREAD_BODY == TRUE
Index: cpukit/score/cpu/avr/Makefile.am
===================================================================
--- cpukit/score/cpu/avr/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/avr/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -163,4 +163,5 @@
 noinst_LIBRARIES = libscorecpu.a
 libscorecpu_a_SOURCES = cpu.c cpu_asm.S
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_SOURCES += avr-exception-frame-print.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
Index: cpukit/score/cpu/avr/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/avr/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/avr/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -1181,4 +1181,16 @@
   (((value&0xff) << 8) | ((value >> 8)&0xff))
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #endif /* ASM */
 
Index: cpukit/score/cpu/bfin/Makefile.am
===================================================================
--- cpukit/score/cpu/bfin/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/bfin/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -18,4 +18,5 @@
 noinst_LIBRARIES = libscorecpu.a
 libscorecpu_a_SOURCES = cpu.c cpu_asm.S
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_SOURCES += bfin-exception-frame-print.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
Index: cpukit/score/cpu/bfin/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/bfin/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/bfin/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -1281,4 +1281,16 @@
   (((value&0xff) << 8) | ((value >> 8)&0xff))
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #endif /* ASM */
 
Index: cpukit/score/cpu/h8300/Makefile.am
===================================================================
--- cpukit/score/cpu/h8300/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/h8300/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -12,4 +12,5 @@
 noinst_LIBRARIES = libscorecpu.a
 libscorecpu_a_SOURCES = cpu.c cpu_asm.S
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_SOURCES += h8300-exception-frame-print.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
Index: cpukit/score/cpu/h8300/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/h8300/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/h8300/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -1163,4 +1163,16 @@
   (((value&0xff) << 8) | ((value >> 8)&0xff))
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 /* to be provided by the BSP */
 extern void H8BD_Install_IRQ(
Index: cpukit/score/cpu/i386/Makefile.am
===================================================================
--- cpukit/score/cpu/i386/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/i386/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -16,4 +16,5 @@
 noinst_LIBRARIES = libscorecpu.a
 libscorecpu_a_SOURCES = cpu.c cpu_asm.S
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
 
Index: cpukit/score/cpu/i386/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/i386/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/i386/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -695,4 +695,16 @@
 void _CPU_Exception_frame_print( const CPU_Exception_frame *frame );
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #endif /* ASM */
 
Index: cpukit/score/cpu/lm32/Makefile.am
===================================================================
--- cpukit/score/cpu/lm32/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/lm32/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -13,4 +13,5 @@
 noinst_LIBRARIES = libscorecpu.a
 libscorecpu_a_SOURCES = cpu.c cpu_asm.S irq.c
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_SOURCES += lm32-exception-frame-print.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
Index: cpukit/score/cpu/lm32/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/lm32/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/lm32/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -1283,4 +1283,16 @@
 }
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #ifdef __cplusplus
 }
Index: cpukit/score/cpu/m32c/Makefile.am
===================================================================
--- cpukit/score/cpu/m32c/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/m32c/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -16,4 +16,5 @@
 libscorecpu_a_SOURCES = cpu.c cpu_asm.c context_switch.S context_init.c \
     varvects.S
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_SOURCES += m32c-exception-frame-print.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
Index: cpukit/score/cpu/m32c/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/m32c/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/m32c/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -1234,4 +1234,16 @@
   (((value&0xff) << 8) | ((value >> 8)&0xff))
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #ifdef __cplusplus
 }
Index: cpukit/score/cpu/m32r/Makefile.am
===================================================================
--- cpukit/score/cpu/m32r/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/m32r/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -15,4 +15,5 @@
 noinst_LIBRARIES = libscorecpu.a
 libscorecpu_a_SOURCES = cpu.c cpu_asm.c context_switch.S context_init.c
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_SOURCES += m32r-exception-frame-print.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
Index: cpukit/score/cpu/m32r/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/m32r/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/m32r/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -1275,4 +1275,16 @@
   (((value&0xff) << 8) | ((value >> 8)&0xff))
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #ifdef __cplusplus
 }
Index: cpukit/score/cpu/m68k/Makefile.am
===================================================================
--- cpukit/score/cpu/m68k/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/m68k/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -20,4 +20,5 @@
 
 libscorecpu_a_SOURCES = cpu.c cpu_asm.S
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_SOURCES += m68k-exception-frame-print.c
 libscorecpu_a_SOURCES += __m68k_read_tp.c
Index: cpukit/score/cpu/m68k/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/m68k/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/m68k/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -724,4 +724,16 @@
 );
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #if (M68K_HAS_FPSP_PACKAGE == 1)
 /*
Index: cpukit/score/cpu/mips/Makefile.am
===================================================================
--- cpukit/score/cpu/mips/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/mips/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -16,4 +16,5 @@
 noinst_LIBRARIES = libscorecpu.a
 libscorecpu_a_SOURCES = cpu.c cpu_asm.S
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
 
Index: cpukit/score/cpu/mips/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/mips/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/mips/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -1194,4 +1194,15 @@
   (((value&0xff) << 8) | ((value >> 8)&0xff))
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
 
 #endif
Index: cpukit/score/cpu/moxie/Makefile.am
===================================================================
--- cpukit/score/cpu/moxie/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/moxie/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -15,4 +15,5 @@
 noinst_LIBRARIES = libscorecpu.a
 libscorecpu_a_SOURCES = cpu.c moxie-exception-frame-print.c cpu_asm.S
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
 
Index: cpukit/score/cpu/moxie/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/moxie/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/moxie/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -1050,4 +1050,16 @@
   (((value&0xff) << 8) | ((value >> 8)&0xff))
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #ifdef __cplusplus
 }
Index: cpukit/score/cpu/nios2/Makefile.am
===================================================================
--- cpukit/score/cpu/nios2/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/nios2/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -22,4 +22,5 @@
 
 libscorecpu_a_SOURCES =
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_SOURCES += nios2-context-initialize.c
 libscorecpu_a_SOURCES += nios2-context-switch.S
Index: cpukit/score/cpu/nios2/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/nios2/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/nios2/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -365,4 +365,16 @@
   (((value&0xff) << 8) | ((value >> 8)&0xff))
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #endif /* ASM */
 
Index: cpukit/score/cpu/no_cpu/Makefile.am
===================================================================
--- cpukit/score/cpu/no_cpu/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/no_cpu/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -13,4 +13,5 @@
 noinst_LIBRARIES = libscorecpu.a
 libscorecpu_a_SOURCES = cpu.c cpu_asm.c
+libscorecpu_a_SOURCES += cpucounterread.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
 
Index: cpukit/score/cpu/no_cpu/cpucounterread.c
===================================================================
--- cpukit/score/cpu/no_cpu/cpucounterread.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
+++ cpukit/score/cpu/no_cpu/cpucounterread.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <rtems/score/cpu.h>
+
+CPU_Counter_ticks _CPU_Counter_read( void )
+{
+  static CPU_Counter_ticks counter;
+
+  CPU_Counter_ticks snapshot;
+
+  snapshot = counter;
+  counter = snapshot + 1;
+
+  return snapshot;
+}
Index: cpukit/score/cpu/no_cpu/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/no_cpu/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/no_cpu/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -1426,4 +1426,38 @@
 #define CPU_swap_u16( value ) \
   (((value&0xff) << 8) | ((value >> 8)&0xff))
+
+/**
+ * @brief Unsigned integer type for CPU counter values.
+ */
+typedef uint32_t CPU_Counter_ticks;
+
+/**
+ * @brief Returns the current CPU counter value.
+ *
+ * A CPU counter is some free-running counter.  It ticks usually with a
+ * frequency close to the CPU or system bus clock.  The board support package
+ * must ensure that this function works before the RTEMS initialization.
+ * Otherwise invalid profiling statistics will be gathered.
+ *
+ * @return The current CPU counter value.
+ */
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+/**
+ * @brief Returns the difference between the second and first CPU counter
+ * value.
+ *
+ * This operation may be carried out as a modulo operation depending on the
+ * range of the CPU counter device.
+ *
+ * @param[in] second The second CPU counter value.
+ * @param[in] first The first CPU counter value.
+ *
+ * @return Returns second minus first modulo counter period.
+ */
+CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+);
 
 #ifdef RTEMS_SMP
Index: cpukit/score/cpu/powerpc/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/powerpc/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/powerpc/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -769,4 +769,28 @@
 #define CPU_swap_u16( value ) \
   (((value&0xff) << 8) | ((value >> 8)&0xff))
+
+typedef uint32_t CPU_Counter_ticks;
+
+static inline CPU_Counter_ticks _CPU_Counter_read( void )
+{
+  CPU_Counter_ticks value;
+
+#ifdef ppc8540
+  /* Book E has no mftb */
+  __asm__ volatile( "mfspr %0, 268" : "=r" (value) );
+#else
+  __asm__ volatile( "mftb %0" : "=r" (value) );
+#endif
+
+  return value;
+}
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
 
 #endif /* ASM */
Index: cpukit/score/cpu/sh/Makefile.am
===================================================================
--- cpukit/score/cpu/sh/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/sh/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -13,4 +13,5 @@
 noinst_LIBRARIES = libscorecpu.a
 libscorecpu_a_SOURCES = cpu.c context.c
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_SOURCES += sh-exception-frame-print.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
Index: cpukit/score/cpu/sh/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/sh/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/sh/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -911,4 +911,16 @@
 void _CPU_Exception_frame_print( const CPU_Exception_frame *frame );
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #ifdef __cplusplus
 }
Index: cpukit/score/cpu/sparc/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/sparc/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/sparc/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -1270,4 +1270,16 @@
   (((value&0xff) << 8) | ((value >> 8)&0xff))
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #endif /* ASM */
 
Index: cpukit/score/cpu/sparc64/Makefile.am
===================================================================
--- cpukit/score/cpu/sparc64/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/sparc64/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -15,4 +15,5 @@
 noinst_LIBRARIES = libscorecpu.a
 libscorecpu_a_SOURCES = context.S cpu.c
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_SOURCES += sparc64-exception-frame-print.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
Index: cpukit/score/cpu/sparc64/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/sparc64/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/sparc64/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -1090,4 +1090,16 @@
   (((value&0xff) << 8) | ((value >> 8)&0xff))
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #endif /* ASM */
 
Index: cpukit/score/cpu/v850/Makefile.am
===================================================================
--- cpukit/score/cpu/v850/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/v850/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -13,4 +13,5 @@
 libscorecpu_a_SOURCES  = cpu.c
 libscorecpu_a_SOURCES += cpu_asm.S
+libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c
 libscorecpu_a_SOURCES += v850-exception-frame-print.c
 libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
Index: cpukit/score/cpu/v850/rtems/score/cpu.h
===================================================================
--- cpukit/score/cpu/v850/rtems/score/cpu.h	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ cpukit/score/cpu/v850/rtems/score/cpu.h	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -1234,4 +1234,16 @@
 }
 
+typedef uint32_t CPU_Counter_ticks;
+
+CPU_Counter_ticks _CPU_Counter_read( void );
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
+
 #ifdef __cplusplus
 }
Index: doc/cpu_supplement/general.t
===================================================================
--- doc/cpu_supplement/general.t	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ doc/cpu_supplement/general.t	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -342,4 +342,25 @@
 @end example
 
+@section CPU counter
+
+The CPU support must implement the CPU counter interface.  A CPU counter is
+some free-running counter.  It ticks usually with a frequency close to the CPU
+or system bus clock.  On some architectures the actual implementation is board
+support package dependent.  The CPU counter is used for profiling of low-level
+functions.  It is also used to implement two busy wait functions
+@code{rtems_counter_delay_ticks()} and @code{rtems_counter_delay_nanoseconds()}
+which may be used in device drivers.  It may be also used as an entropy source
+for random number generators.
+
+The CPU counter interface uses a CPU port specific unsigned integer type
+@code{CPU_Counter_ticks} to represent CPU counter values.  The CPU port must
+provide the following two functions
+
+@itemize
+@item @code{_CPU_Counter_read()} to read the current CPU counter value, and
+@item @code{_CPU_Counter_difference()} to get the difference between two CPU
+counter values.
+@end itemize
+
 @c
 @c
Index: testsuites/sptests/Makefile.am
===================================================================
--- testsuites/sptests/Makefile.am	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ testsuites/sptests/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -31,4 +31,5 @@
     spcbssched01 spcbssched02 spcbssched03 spqreslib sptimespec01 \
     spregion_err01 sppartition_err01
+SUBDIRS += spcpucounter01
 if HAS_CPLUSPLUS
 SUBDIRS += sptls02
Index: testsuites/sptests/configure.ac
===================================================================
--- testsuites/sptests/configure.ac	(revision 382ea27b6a9b2952c541ec7f600517181a4431e2)
+++ testsuites/sptests/configure.ac	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -37,4 +37,5 @@
 # Explicitly list all Makefiles here
 AC_CONFIG_FILES([Makefile
+spcpucounter01/Makefile
 sptls02/Makefile
 sptls01/Makefile
Index: testsuites/sptests/spcpucounter01/Makefile.am
===================================================================
--- testsuites/sptests/spcpucounter01/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
+++ testsuites/sptests/spcpucounter01/Makefile.am	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = spcpucounter01
+spcpucounter01_SOURCES = init.c
+
+dist_rtems_tests_DATA = spcpucounter01.scn spcpucounter01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spcpucounter01_OBJECTS)
+LINK_LIBS = $(spcpucounter01_LDLIBS)
+
+spcpucounter01$(EXEEXT): $(spcpucounter01_OBJECTS) $(spcpucounter01_DEPENDENCIES)
+	@rm -f spcpucounter01$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
Index: testsuites/sptests/spcpucounter01/init.c
===================================================================
--- testsuites/sptests/spcpucounter01/init.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
+++ testsuites/sptests/spcpucounter01/init.c	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <stdio.h>
+#include <inttypes.h>
+
+#include <rtems.h>
+#include <rtems/counter.h>
+
+#define TESTS_USE_PRINTF
+#include "tmacros.h"
+
+#define NS_PER_TICK 1000000
+
+static rtems_interval sync_with_clock_tick(void)
+{
+  rtems_interval start = rtems_clock_get_ticks_since_boot();
+  rtems_interval current;
+
+  do {
+    current = rtems_clock_get_ticks_since_boot();
+  } while (current == start);
+
+  return current;
+}
+
+static void test_converter(void)
+{
+  CPU_Counter_ticks frequency = rtems_counter_nanoseconds_to_ticks(1000000000);
+  uint64_t ns = rtems_counter_ticks_to_nanoseconds(frequency);
+
+  printf("CPU counter frequency: %" PRIu32 "Hz\n", frequency);
+  printf("nanoseconds for frequency count ticks: %" PRIu64 "\n", ns);
+
+  rtems_test_assert(ns == 1000000000);
+}
+
+static void test_delay_nanoseconds(void)
+{
+  rtems_counter_ticks start;
+  rtems_counter_ticks end;
+  rtems_counter_ticks delta;
+  double ns_per_tick = NS_PER_TICK;
+  double ns_delta;
+  rtems_interval tick;
+  int n = 10;
+  int i;
+
+  printf("test delay nanoseconds (%i times)\n", n);
+
+  for (i = 0; i < n; ++i) {
+    tick = sync_with_clock_tick();
+
+    start = rtems_counter_read();
+    rtems_counter_delay_nanoseconds(NS_PER_TICK);
+    end = rtems_counter_read();
+
+    rtems_test_assert(tick < rtems_clock_get_ticks_since_boot());
+
+    delta = rtems_counter_difference(end, start);
+    ns_delta = rtems_counter_ticks_to_nanoseconds(delta);
+
+    rtems_test_assert(ns_delta >= ns_per_tick);
+
+    printf(
+      "busy wait relative to clock tick: %f\n",
+      (ns_delta - ns_per_tick) / ns_per_tick
+    );
+  }
+}
+
+static void Init(rtems_task_argument arg)
+{
+  puts("\n\n*** TEST SPCPUCOUNTER 1 ***");
+
+  test_converter();
+  test_delay_nanoseconds();
+
+  puts("*** END OF TEST SPCPUCOUNTER 1 ***");
+
+  rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MICROSECONDS_PER_TICK (NS_PER_TICK / 1000)
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
Index: testsuites/sptests/spcpucounter01/spcpucounter01.scn
===================================================================
--- testsuites/sptests/spcpucounter01/spcpucounter01.scn	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
+++ testsuites/sptests/spcpucounter01/spcpucounter01.scn	(revision 24bf11eca11947d961cc9bb5f7d92dabff169e93)
@@ -0,0 +1,15 @@
+*** TEST SPCPUCOUNTER 1 ***
+CPU counter frequency: 25000000Hz
+nanoseconds for frequency count ticks: 1000000000
+test delay nanoseconds (10 times)
+busy wait relative to clock tick: 0.001320
+busy wait relative to clock tick: 0.001640
+busy wait relative to clock tick: 0.001320
+busy wait relative to clock tick: 0.001160
+busy wait relative to clock tick: 0.001280
+busy wait relative to clock tick: 0.001240
+busy wait relative to clock tick: 0.001280
+busy wait relative to clock tick: 0.001280
+busy wait relative to clock tick: 0.001320
+busy wait relative to clock tick: 0.001280
+*** END OF TEST SPCPUCOUNTER 1 ***
