From 7046cddb1b07083d23f9f62592790f2f9174a470 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 28 Oct 1999 16:01:41 +0000 Subject: Patch rtems-rc-19991011-3.diff from Ralf Corsepius. --- c/src/lib/libbsp/sh/gensh1/include/bsp.h | 33 +++++++++++++++++++++++++- c/src/lib/libbsp/sh/gensh1/startup/Makefile.in | 2 +- c/src/lib/libcpu/sh/sh7032/clock/Makefile.in | 2 +- c/src/lib/libcpu/sh/sh7032/timer/Makefile.in | 2 +- 4 files changed, 35 insertions(+), 4 deletions(-) (limited to 'c/src/lib') diff --git a/c/src/lib/libbsp/sh/gensh1/include/bsp.h b/c/src/lib/libbsp/sh/gensh1/include/bsp.h index 8f676d07fe..8422599b42 100644 --- a/c/src/lib/libbsp/sh/gensh1/include/bsp.h +++ b/c/src/lib/libbsp/sh/gensh1/include/bsp.h @@ -68,8 +68,39 @@ extern "C" { #define Lower_tm27_intr() /* Constants */ +#ifndef MHZ +#error Missing MHZ +#endif + +/* + * Simple spin delay in microsecond units for device drivers. + * This is very dependent on the clock speed of the target. + * + * Since we don't have a real time clock, this is a very rough + * approximation, assuming that each cycle of the delay loop takes + * approx. 4 machine cycles. + * + * e.g.: MHZ = 20 => 5e-8 secs per instruction + * => 4 * 5e-8 secs per delay loop + */ + +#define delay( microseconds ) \ +{ register unsigned int _delay = (microseconds) * (MHZ / 4 ); \ + asm volatile ( \ +"0: add #-1,%0\n \ + nop\n \ + cmp/pl %0\n \ + bt 0b\ + nop" \ + :: "r" (_delay) ); \ +} -#define MHZ 20 +/* + * For backward compatibility only. + * Do not rely on them being present in future + */ +#define CPU_delay( microseconds ) delay( microseconds ) +#define sh_deley( microseconds ) delay( microseconds ) /* * Defined in the linker script 'linkcmds' diff --git a/c/src/lib/libbsp/sh/gensh1/startup/Makefile.in b/c/src/lib/libbsp/sh/gensh1/startup/Makefile.in index c2eca457b9..3d03489ca3 100644 --- a/c/src/lib/libbsp/sh/gensh1/startup/Makefile.in +++ b/c/src/lib/libbsp/sh/gensh1/startup/Makefile.in @@ -47,7 +47,7 @@ $(INSTALLDIRS): # DEFINES += -CPPFLAGS += +CPPFLAGS += $(BSP_CPPFLAGS) CFLAGS += LD_PATHS += diff --git a/c/src/lib/libcpu/sh/sh7032/clock/Makefile.in b/c/src/lib/libcpu/sh/sh7032/clock/Makefile.in index 5617ae594e..c9bd2ac92d 100644 --- a/c/src/lib/libcpu/sh/sh7032/clock/Makefile.in +++ b/c/src/lib/libcpu/sh/sh7032/clock/Makefile.in @@ -40,7 +40,7 @@ INSTALL_CHANGE = @INSTALL_CHANGE@ # DEFINES += -CPPFLAGS += +CPPFLAGS += -DMHZ=$(MHZ) CFLAGS += $(CFLAGS_OS_V) LD_PATHS += diff --git a/c/src/lib/libcpu/sh/sh7032/timer/Makefile.in b/c/src/lib/libcpu/sh/sh7032/timer/Makefile.in index ce19bbb25c..735ef3961d 100644 --- a/c/src/lib/libcpu/sh/sh7032/timer/Makefile.in +++ b/c/src/lib/libcpu/sh/sh7032/timer/Makefile.in @@ -40,7 +40,7 @@ INSTALL_CHANGE = @INSTALL_CHANGE@ # DEFINES += -CPPFLAGS += +CPPFLAGS += -DMHZ=$(MHZ) CFLAGS += LD_PATHS += -- cgit v1.2.3