src/ssx/ssx/ssx_init.c
// Note that SSX does not rely on any static initialization of dynamic
// variables. In debugging sessions using RAM-resident SSX images it is
// assumed that the processor may be reset at any time, so we always need to
// reset everything at initialization.
Note that SSX does not rely on any static initialization of dynamic
variables. In debugging sessions using RAM-resident SSX images it is
assumed that the processor may be reset at any time, so we always need to
reset everything at initialization.
Note that SSX does not rely on any static initialization of dynamic variables . In debugging sessions using RAM - resident SSX images it is assumed that the processor may be reset at any time so we always need to reset everything at initialization .
int
ssx_initialize(SsxAddress  noncritical_stack,
               size_t      noncritical_stack_size,
               SsxAddress  critical_stack,
               size_t      critical_stack_size,
               SsxTimebase initial_timebase,
               uint32_t    timebase_frequency_hz)
{
    int rc;
    if (SSX_ERROR_CHECK_API)
    {
        SSX_ERROR_IF((noncritical_stack == 0) ||
                     (noncritical_stack_size == 0) ||
                     (critical_stack == 0) ||
                     (critical_stack_size == 0),
                     SSX_INVALID_ARGUMENT_INIT);
    }
    if (initial_timebase != SSX_TIMEBASE_CONTINUES)
    {
        __ssx_timebase_set(initial_timebase);
    }
    __ssx_timebase_frequency_hz = timebase_frequency_hz;
    __ssx_timebase_frequency_khz = timebase_frequency_hz / 1000;
    __ssx_timebase_frequency_mhz = timebase_frequency_hz / 1000000;
    __ssx_thread_machine_context_default = SSX_THREAD_MACHINE_CONTEXT_DEFAULT;
    rc = __ssx_stack_init(&noncritical_stack, &noncritical_stack_size);
    if (rc)
    {
        return rc;
    }
    __ssx_noncritical_stack = noncritical_stack;
    __ssx_noncritical_stack_size = noncritical_stack_size;
    rc = __ssx_stack_init(&critical_stack, &critical_stack_size);
    if (rc)
    {
        return rc;
    }
    __ssx_critical_stack = critical_stack;
    __ssx_critical_stack_size = critical_stack_size;
#if SSX_TIMER_SUPPORT
    ssx_deque_sentinel_create((SsxDeque*)&__ssx_time_queue);
    __ssx_time_queue.cursor = 0;
    __ssx_time_queue.next_timeout = SSX_TIMEBASE_MAX;
#endif  
#if SSX_THREAD_SUPPORT
    int i;
    for (i = 0; i <= SSX_THREADS; i++)
    {
        __ssx_priority_map[i] = 0;
    }
    __ssx_thread_queue_clear(&__ssx_run_queue);
    __ssx_current_thread = 0;
    __ssx_next_thread    = 0;
    __ssx_delayed_switch = 0;
#endif  
    return SSX_OK;
}
int ssx_initialize ( SsxAddress noncritical_stack , size_t noncritical_stack_size , SsxAddress critical_stack , size_t critical_stack_size , SsxTimebase initial_timebase , uint32_t timebase_frequency_hz ) { int rc ; if ( SSX_ERROR_CHECK_API ) { SSX_ERROR_IF ( ( noncritical_stack == 0 ) || ( noncritical_stack_size == 0 ) || ( critical_stack == 0 ) || ( critical_stack_size == 0 ) , SSX_INVALID_ARGUMENT_INIT ) ; } if ( initial_timebase != SSX_TIMEBASE_CONTINUES ) { __ssx_timebase_set ( initial_timebase ) ; } __ssx_timebase_frequency_hz = timebase_frequency_hz ; __ssx_timebase_frequency_khz = timebase_frequency_hz / 1000 ; __ssx_timebase_frequency_mhz = timebase_frequency_hz / 1000000 ; __ssx_thread_machine_context_default = SSX_THREAD_MACHINE_CONTEXT_DEFAULT ; rc = __ssx_stack_init ( & noncritical_stack , & noncritical_stack_size ) ; if ( rc ) { return rc ; } __ssx_noncritical_stack = noncritical_stack ; __ssx_noncritical_stack_size = noncritical_stack_size ; rc = __ssx_stack_init ( & critical_stack , & critical_stack_size ) ; if ( rc ) { return rc ; } __ssx_critical_stack = critical_stack ; __ssx_critical_stack_size = critical_stack_size ; #if SSX_TIMER_SUPPORT ssx_deque_sentinel_create ( ( SsxDeque * ) & __ssx_time_queue ) ; __ssx_time_queue . cursor = 0 ; __ssx_time_queue . next_timeout = SSX_TIMEBASE_MAX ; #endif #if SSX_THREAD_SUPPORT int i ; for ( i = 0 ; i <= SSX_THREADS ; i ++ ) { __ssx_priority_map [ i ] = 0 ; } __ssx_thread_queue_clear ( & __ssx_run_queue ) ; __ssx_current_thread = 0 ; __ssx_next_thread = 0 ; __ssx_delayed_switch = 0 ; #endif return SSX_OK ; }
Note that SSX does not rely on any static initialization of dynamic
variables.
Note that SSX does not rely on any static initialization of dynamic variables .
// Initialize the time queue sentinel as a circular queue, set the next // timeout and clear the cursor. /* SSX_TIMER_SUPPORT */ // Clear the priority map. The final entry [SSX_THREADS] is for the idle // thread. // Initialize the thread scheduler /* SSX_THREAD_SUPPORT */