src/ssx/ppc405/ppc405_core.c
// The tickless kernel timer mechanism for PPC405
//
// This routine must be called from an SSX_NONCRITICAL critical section.
//
// Tickless timeouts are provided by programming the PIT timer based on when
// the next timeout will occur.  If the timeout is for the end of time there's
// nothing to do - SSX does not use auto-reload mode so no more PIT interrupts
// will be arriving.  Otherwise, if the timeout is longer than the 32-bit PIT
// timer can handle, we simply schedule the timeout for 2**32 - 1 and
// __ssx_timer_handler() will keep rescheduling it until it finally occurs.
// If the \a timeout is in the past, we schedule the PIT interrupt for 1 tick
// in the future in accordance with the SSX specification.
The tickless kernel timer mechanism for PPC405
This routine must be called from an SSX_NONCRITICAL critical section.

Tickless timeouts are provided by programming the PIT timer based on when
the next timeout will occur.  If the timeout is for the end of time there's
nothing to do - SSX does not use auto-reload mode so no more PIT interrupts
will be arriving.  Otherwise, if the timeout is longer than the 32-bit PIT
timer can handle, we simply schedule the timeout for 2**32 - 1 and
ssx_timer_handler() will keep rescheduling it until it finally occurs.
If the \a timeout is in the past, we schedule the PIT interrupt for 1 tick
in the future in accordance with the SSX specification.
The tickless kernel timer mechanism for PPC405 This routine must be called from an SSX_NONCRITICAL critical section . Tickless timeouts are provided by programming the PIT timer based on when the next timeout will occur . If the timeout is for the end of time there ' s nothing to do - SSX does not use auto - reload mode so no more PIT interrupts will be arriving . Otherwise if the timeout is longer than the 32 - bit PIT timer can handle we simply schedule the timeout for 2 ** 32 - 1 and ssx_timer_handler () will keep rescheduling it until it finally occurs . If the \ a timeout is in the past we schedule the PIT interrupt for 1 tick in the future in accordance with the SSX specification .
void
__ssx_schedule_hardware_timeout(SsxTimebase timeout)
{
    SsxTimebase now;
    uint32_t pit;
    if (timeout != SSX_TIMEBASE_MAX)
    {
        now = ssx_timebase_get();
        if (timeout <= now)
        {
            pit = 1;
        }
        else if ((timeout - now) > 0xffffffff)
        {
            pit = 0xffffffff;
        }
        else
        {
            pit = timeout - now;
        }
        mtspr(SPRN_PIT, pit);
#if APPCFG_USE_EXT_TIMEBASE_FOR_TRACE
        ppc405_64bit_ext_timebase = ssx_ext_timebase_get();
#endif 
    }
}
void __ssx_schedule_hardware_timeout ( SsxTimebase timeout ) { SsxTimebase now ; uint32_t pit ; if ( timeout != SSX_TIMEBASE_MAX ) { now = ssx_timebase_get ( ) ; if ( timeout <= now ) { pit = 1 ; } else if ( ( timeout - now ) > 0xffffffff ) { pit = 0xffffffff ; } else { pit = timeout - now ; } mtspr ( SPRN_PIT , pit ) ; #if APPCFG_USE_EXT_TIMEBASE_FOR_TRACE ppc405_64bit_ext_timebase = ssx_ext_timebase_get ( ) ; #endif } }
The tickless kernel timer mechanism for PPC405
This routine must be called from an SSX_NONCRITICAL critical section.
The tickless kernel timer mechanism for PPC405 This routine must be called from an SSX_NONCRITICAL critical section .
/* APPCFG_USE_EXT_TIMEBASE_FOR_TRACE */