Changeset 4e8de7e in rtems
- Timestamp:
- 10/07/14 15:02:29 (9 years ago)
- Branches:
- 4.11, 5, master
- Children:
- 905b656c
- Parents:
- 9073f554
- git-author:
- Joel Sherrill <joel.sherrill@…> (10/07/14 15:02:29)
- git-committer:
- Joel Sherrill <joel.sherrill@…> (10/09/14 15:11:54)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c
r9073f554 r4e8de7e 1 /* 2 * Clock Tick Device Driver1 /** 2 * @brief Clock Tick Device Driver 3 3 * 4 4 * This routine utilizes the Decrementer Register common to the PPC family. … … 6 6 * The tick frequency is directly programmed to the configured number of 7 7 * microseconds per tick. 8 * 8 */ 9 10 /* 9 11 * COPYRIGHT (c) 1989-2007. 10 12 * On-Line Applications Research Corporation (OAR). … … 18 20 */ 19 21 20 #include <rtems/system.h>21 22 #include <rtems.h> 22 23 #include <rtems/libio.h> 24 #include <rtems/clockdrv.h> 23 25 #include <stdlib.h> /* for atexit() */ 24 26 #include <assert.h> … … 40 42 * Clock ticks since initialization 41 43 */ 42 43 44 volatile uint32_t Clock_driver_ticks; 44 45 … … 46 47 * This is the value programmed into the count down timer. 47 48 */ 48 49 49 uint32_t Clock_Decrementer_value; 50 50 51 /*52 * These are set by clock driver during its init53 */54 55 rtems_device_major_number rtems_clock_major = ~0;56 rtems_device_minor_number rtems_clock_minor;57 58 51 void clockOff(void* unused) 59 52 { 60 rtems_interrupt_level l;53 rtems_interrupt_level l; 61 54 62 55 if ( ppc_cpu_is_bookE() ) { … … 65 58 rtems_interrupt_enable(l); 66 59 } else { 67 /*68 * Nothing to do as we cannot disable all interrupts and69 * the decrementer interrupt enable is MSR_EE70 */60 /* 61 * Nothing to do as we cannot disable all interrupts and 62 * the decrementer interrupt enable is MSR_EE 63 */ 71 64 } 72 65 } … … 74 67 void clockOn(void* unused) 75 68 { 76 rtems_interrupt_level l;69 rtems_interrupt_level l; 77 70 78 71 PPC_Set_decrementer( Clock_Decrementer_value ); … … 95 88 static void clockHandler(void) 96 89 { 97 98 90 #if (CLOCK_DRIVER_USE_FAST_IDLE == 1) 99 91 do { … … 127 119 void clockIsr(void *unused) 128 120 { 129 int decr; 121 int decr; 122 130 123 /* 131 124 * The driver has seen another tick. 132 125 */ 133 126 do { 134 register uint32_t flags; 135 rtems_interrupt_disable(flags); 136 __asm__ volatile ( 137 "mfdec %0; add %0, %0, %1; mtdec %0" 138 : "=&r"(decr) 139 : "r"(Clock_Decrementer_value)); 140 rtems_interrupt_enable(flags); 141 142 Clock_driver_ticks += 1; 143 144 /* 145 * Real Time Clock counter/timer is set to automatically reload. 146 */ 147 clock_handler(); 127 register uint32_t flags; 128 129 rtems_interrupt_disable(flags); 130 __asm__ volatile ( 131 "mfdec %0; add %0, %0, %1; mtdec %0" 132 : "=&r"(decr) 133 : "r"(Clock_Decrementer_value) 134 ); 135 rtems_interrupt_enable(flags); 136 137 Clock_driver_ticks += 1; 138 139 /* 140 * Real Time Clock counter/timer is set to automatically reload. 141 */ 142 clock_handler(); 148 143 } while ( decr < 0 ); 149 144 } … … 179 174 */ 180 175 clock_handler(); 181 182 176 } 183 177 184 178 int clockIsOn(void* unused) 185 179 { 186 uint32_t msr_value;180 uint32_t msr_value; 187 181 188 182 _CPU_MSR_GET( msr_value ); … … 210 204 * 211 205 */ 212 213 206 void Clock_exit( void ) 214 207 { … … 216 209 } 217 210 218 uint32_t Clock_driver_nanoseconds_since_last_tick(void)211 static uint32_t Clock_driver_nanoseconds_since_last_tick(void) 219 212 { 220 213 uint32_t clicks, tmp; … … 253 246 ) 254 247 { 255 rtems_interrupt_level l,tcr;248 rtems_interrupt_level l,tcr; 256 249 257 250 Clock_Decrementer_value = (BSP_bus_frequency/BSP_time_base_divisor)* … … 270 263 rtems_interrupt_disable(l); 271 264 272 tcr = _read_BOOKE_TCR();273 tcr |= BOOKE_TCR_ARE;274 tcr &= ~BOOKE_TCR_DIE;275 _write_BOOKE_TCR(tcr);265 tcr = _read_BOOKE_TCR(); 266 tcr |= BOOKE_TCR_ARE; 267 tcr &= ~BOOKE_TCR_DIE; 268 _write_BOOKE_TCR(tcr); 276 269 277 270 rtems_interrupt_enable(l); … … 286 279 ); 287 280 288 /* if a decrementer exception was pending, it is cleared by 281 /* 282 * If a decrementer exception was pending, it is cleared by 289 283 * executing the default (nop) handler at this point; 290 284 * The next exception will then be taken by our clock handler. … … 292 286 * the correct value. 293 287 */ 294 295 288 clock_handler = clockHandler; 296 289 if (!BSP_connect_clock_handler ()) { … … 298 291 rtems_fatal_error_occurred(1); 299 292 } 300 /* make major/minor avail to others such as shared memory driver */301 302 rtems_clock_major = major;303 rtems_clock_minor = minor;304 293 305 294 return RTEMS_SUCCESSFUL;
Note: See TracChangeset
for help on using the changeset viewer.