mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 23:23:13 +00:00
2004-05-22 Till Strauman <strauman@slac.stanford.edu>
PR 619/bsps * mpc6xx/clock/c_clock.c: The PPC decrementer must be reloaded on each clock tick. Currently, this is done by just reloading a fixed value. The attached patch takes into account the time that elapsed since the decrementer crossed zero in order to adjust the value to be re-loaded. Without the patch, the effective system clock cycle is increased by the exception handler latency.
This commit is contained in:
@@ -1,3 +1,13 @@
|
|||||||
|
2004-05-22 Till Strauman <strauman@slac.stanford.edu>
|
||||||
|
|
||||||
|
PR 619/bsps
|
||||||
|
* mpc6xx/clock/c_clock.c: The PPC decrementer must be reloaded on each
|
||||||
|
clock tick. Currently, this is done by just reloading a fixed value.
|
||||||
|
The attached patch takes into account the time that elapsed since the
|
||||||
|
decrementer crossed zero in order to adjust the value to be
|
||||||
|
re-loaded. Without the patch, the effective system clock cycle is
|
||||||
|
increased by the exception handler latency.
|
||||||
|
|
||||||
2003-09-04 Joel Sherrill <joel@OARcorp.com>
|
2003-09-04 Joel Sherrill <joel@OARcorp.com>
|
||||||
|
|
||||||
* mpc6xx/clock/c_clock.c, mpc6xx/clock/c_clock.h,
|
* mpc6xx/clock/c_clock.c, mpc6xx/clock/c_clock.h,
|
||||||
|
|||||||
@@ -73,21 +73,23 @@ void clockOn(void* unused)
|
|||||||
* Return values: NONE
|
* Return values: NONE
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void clockIsr()
|
void clockIsr()
|
||||||
{
|
{
|
||||||
|
int decr;
|
||||||
/*
|
/*
|
||||||
* The driver has seen another tick.
|
* The driver has seen another tick.
|
||||||
*/
|
*/
|
||||||
|
do {
|
||||||
PPC_Set_decrementer( Clock_Decrementer_value );
|
asm volatile ("mfdec %0; add %0, %0, %1; mtdec %0":"=r"(decr):"r"(Clock_Decrementer_value));
|
||||||
|
|
||||||
Clock_driver_ticks += 1;
|
Clock_driver_ticks += 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Real Time Clock counter/timer is set to automatically reload.
|
* Real Time Clock counter/timer is set to automatically reload.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rtems_clock_tick();
|
rtems_clock_tick();
|
||||||
|
} while ( decr < 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int clockIsOn(void* unused)
|
int clockIsOn(void* unused)
|
||||||
@@ -144,6 +146,18 @@ rtems_device_driver Clock_initialize(
|
|||||||
Clock_Decrementer_value = (BSP_bus_frequency/BSP_time_base_divisor)*
|
Clock_Decrementer_value = (BSP_bus_frequency/BSP_time_base_divisor)*
|
||||||
(rtems_configuration_get_microseconds_per_tick()/1000);
|
(rtems_configuration_get_microseconds_per_tick()/1000);
|
||||||
|
|
||||||
|
/* set the decrementer now, prior to installing the handler
|
||||||
|
* so no interrupts will happen in a while.
|
||||||
|
*/
|
||||||
|
PPC_Set_decrementer( (unsigned)-1 );
|
||||||
|
|
||||||
|
/* if a decrementer exception was pending, it is cleared by
|
||||||
|
* executing the default (nop) handler at this point;
|
||||||
|
* The next exception will then be taken by our clock handler.
|
||||||
|
* Clock handler installation initializes the decrementer to
|
||||||
|
* the correct value.
|
||||||
|
*/
|
||||||
|
|
||||||
if (!BSP_connect_clock_handler ()) {
|
if (!BSP_connect_clock_handler ()) {
|
||||||
printk("Unable to initialize system clock\n");
|
printk("Unable to initialize system clock\n");
|
||||||
rtems_fatal_error_occurred(1);
|
rtems_fatal_error_occurred(1);
|
||||||
@@ -190,10 +204,7 @@ rtems_device_driver Clock_control(
|
|||||||
clockIsr();
|
clockIsr();
|
||||||
else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
|
else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
|
||||||
{
|
{
|
||||||
if (!BSP_connect_clock_handler ()) {
|
Clock_initialize(major, minor, 0);
|
||||||
printk("Error installing clock interrupt handler!\n");
|
|
||||||
rtems_fatal_error_occurred(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
|
|||||||
Reference in New Issue
Block a user