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/exec/score/cpu/sh/rtems/score/sh.h | 25 ------------------- 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 +- cpukit/score/cpu/sh/rtems/score/sh.h | 25 ------------------- make/custom/gensh1.cfg | 13 ++++++++-- 7 files changed, 46 insertions(+), 56 deletions(-) diff --git a/c/src/exec/score/cpu/sh/rtems/score/sh.h b/c/src/exec/score/cpu/sh/rtems/score/sh.h index 03d9077d3e..96e10bfb1b 100644 --- a/c/src/exec/score/cpu/sh/rtems/score/sh.h +++ b/c/src/exec/score/cpu/sh/rtems/score/sh.h @@ -148,31 +148,6 @@ static inline unsigned int sh_swap_u16( #define CPU_swap_u32( value ) sh_swap_u32( value ) #define CPU_swap_u16( value ) sh_swap_u16( value ) -/* - * 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 sh_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 CPU_delay( microseconds ) sh_delay( microseconds ) - extern unsigned int sh_set_irq_priority( unsigned int irq, unsigned int prio ); 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 += diff --git a/cpukit/score/cpu/sh/rtems/score/sh.h b/cpukit/score/cpu/sh/rtems/score/sh.h index 03d9077d3e..96e10bfb1b 100644 --- a/cpukit/score/cpu/sh/rtems/score/sh.h +++ b/cpukit/score/cpu/sh/rtems/score/sh.h @@ -148,31 +148,6 @@ static inline unsigned int sh_swap_u16( #define CPU_swap_u32( value ) sh_swap_u32( value ) #define CPU_swap_u16( value ) sh_swap_u16( value ) -/* - * 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 sh_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 CPU_delay( microseconds ) sh_delay( microseconds ) - extern unsigned int sh_set_irq_priority( unsigned int irq, unsigned int prio ); diff --git a/make/custom/gensh1.cfg b/make/custom/gensh1.cfg index 9961f08c8e..b5d98630e2 100644 --- a/make/custom/gensh1.cfg +++ b/make/custom/gensh1.cfg @@ -8,7 +8,7 @@ # $Id$ # -MHZ:=20 +MHZ=20 include $(RTEMS_ROOT)/make/custom/default.cfg @@ -18,11 +18,18 @@ RTEMS_CPU_MODEL=sh7032 # This is the actual bsp directory used during the build process. RTEMS_BSP_FAMILY=gensh1 +# BSP specific preprocessor flags. +# These should only be used in BSP dependent directories. +BSP_CPPFLAGS=-DMHZ=$(MHZ) + # # This contains the compiler options necessary to select the CPU model # and (hopefully) optimize for it. # -CPU_CFLAGS=-m1 +# HACK: We have to append BSP_CPPFLAGS to CPU_CFLAGS, because +# per BSP and per CPU CPPFLAGS are not (yet?) supported +CPU_CFLAGS=-m1 $(BSP_CPPFLAGS) +# CPU_CFLAGS=-m1 # debug flags: typically none, but we use -O1 as it produces better code CFLAGS_DEBUG_V = -O1 @@ -31,6 +38,8 @@ CFLAGS_DEBUG_V = -O1 # -O4 is ok for RTEMS CFLAGS_OPTIMIZE_V = -O4 +CPPFLAGS+=$(BSP_CPPFLAGS) + # This section makes the target dependent options file. # NDEBUG (C library) -- cgit v1.2.3