Changeset 4a238002 in rtems for c/src/lib/libcpu/sh/sh7032/clock
- Timestamp:
- 11/18/99 21:22:58 (23 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 97c465c
- Parents:
- 5503d75
- Location:
- c/src/lib/libcpu/sh/sh7032/clock
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libcpu/sh/sh7032/clock/Makefile.in
r5503d75 r4a238002 41 41 42 42 DEFINES += 43 CPPFLAGS += -DMHZ=$(MHZ)43 CPPFLAGS += 44 44 CFLAGS += $(CFLAGS_OS_V) 45 45 -
c/src/lib/libcpu/sh/sh7032/clock/ckinit.c
r5503d75 r4a238002 30 30 #include <rtems/score/sh_io.h> 31 31 #include <rtems/score/sh.h> 32 #include <rtems/score/cpu_isps.h> 33 #include <rtems/score/iosh7030.h> 34 35 #define _ITU_COUNTER0_MICROSECOND (MHZ/4) 32 #include <rtems/score/ispsh7032.h> 33 #include <rtems/score/iosh7032.h> 36 34 37 35 #ifndef CLOCKPRIO … … 39 37 #endif 40 38 39 #define I_CLK_PHI_1 0 40 #define I_CLK_PHI_2 1 41 #define I_CLK_PHI_4 2 42 #define I_CLK_PHI_8 3 43 44 /* 45 * Set I_CLK_PHI to one of the I_CLK_PHI_X values from above to choose 46 * a PHI/X clock rate. 47 */ 48 49 #define I_CLK_PHI I_CLK_PHI_4 50 #define CLOCK_SCALE (1<<I_CLK_PHI) 51 41 52 #define ITU0_STARTMASK 0xfe 42 53 #define ITU0_SYNCMASK 0xfe 43 54 #define ITU0_MODEMASK 0xfe 44 #define ITU0_TCRMASK 0x2255 #define ITU0_TCRMASK (0x20 | I_CLK_PHI) 45 56 #define ITU_STAT_MASK 0xf8 46 57 #define ITU0_IRQMASK 0xfe … … 50 61 51 62 /* 63 * clicks_per_tick := clicks_per_sec * usec_per_tick 64 * 65 * This is a very expensive function ;-) 66 * 67 * Below are two variants: 68 * 1. A variant applying integer arithmetics, only. 69 * 2. A variant applying floating point arithmetics 70 * 71 * The floating point variant pulls in the fmath routines when linking, 72 * resulting in slightly larger executables for applications that do not 73 * apply fmath otherwise. However, the imath variant is significantly slower 74 * than the fmath variant and more complex. 75 * 76 * Assuming that most applications will not use fmath, but are critical 77 * in memory size constraints, we apply the integer variant. 78 * 79 * To the sake of simplicity, we might abandon one of both variants in 80 * future. 81 */ 82 static unsigned int sh_clicks_per_tick( 83 unsigned int clicks_per_sec, 84 unsigned int usec_per_tick ) 85 { 86 #if 1 87 unsigned int clicks_per_tick = 0 ; 88 89 unsigned int b = clicks_per_sec ; 90 unsigned int c = 1000000 ; 91 unsigned int d = 1 ; 92 unsigned int a = ( ( b / c ) * usec_per_tick ) / d; 93 94 clicks_per_tick += a ; 95 96 while ( ( b %= c ) > 0 ) 97 { 98 c /= 10 ; 99 d *= 10 ; 100 a = ( ( b / c ) * usec_per_tick ) / d ; 101 clicks_per_tick += a ; 102 } 103 return clicks_per_tick ; 104 #else 105 double fclicks_per_tick = 106 ((double) clicks_per_sec * (double) usec_per_tick) / 1000000.0 ; 107 return (unsigned32) fclicks_per_tick ; 108 #endif 109 } 110 111 /* 52 112 * The interrupt vector number associated with the clock tick device 53 113 * driver. … … 101 161 * bump the number of clock driver ticks since initialization 102 162 * 103 104 163 * determine if it is time to announce the passing of tick as configured 105 164 * to RTEMS through the rtems_clock_tick directive … … 138 197 { 139 198 unsigned8 temp8 = 0; 199 unsigned32 microseconds_per_tick ; 200 unsigned32 cclicks_per_tick ; 201 unsigned16 Clock_limit ; 140 202 141 203 /* … … 144 206 145 207 Clock_driver_ticks = 0; 146 Clock_isrs_const = rtems_configuration_get_microseconds_per_tick() / 10000; 208 209 if ( rtems_configuration_get_microseconds_per_tick() != 0 ) 210 microseconds_per_tick = rtems_configuration_get_microseconds_per_tick() ; 211 else 212 microseconds_per_tick = 10000 ; /* 10000 us */ 213 214 /* clock clicks per tick */ 215 cclicks_per_tick = 216 sh_clicks_per_tick( 217 rtems_cpu_configuration_get_clicks_per_second() / CLOCK_SCALE, 218 microseconds_per_tick ); 219 220 Clock_isrs_const = cclicks_per_tick >> 16 ; 221 if ( ( cclicks_per_tick | 0xffff ) > 0 ) 222 Clock_isrs_const++ ; 223 Clock_limit = cclicks_per_tick / Clock_isrs_const ; 147 224 Clock_isrs = Clock_isrs_const; 148 225 … … 192 269 193 270 /* set counter limits */ 194 write16( _ITU_COUNTER0_MICROSECOND * rtems_configuration_get_microseconds_per_tick(), 195 ITU_GRA0); 271 write16( Clock_limit, ITU_GRA0); 196 272 197 273 /* start counter */
Note: See TracChangeset
for help on using the changeset viewer.