StatusType Schedule(void)
#endif /* KOS_MEMORY_MAPPING */
{
    SAVE_SERVICE_CONTEXT(OSServiceId_Schedule, NULL, NULL, NULL);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK);
    ASSERT_CURR_TASK_OCCUPIES_NO_RESOURCES();
    ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL();
/*    ASSERT_TASK_HAS_NO_SHARED_STACK();    */

/*
**       Standard-Status:
**              – E_OK – no error.
**       Extended-Status:
**              – E_OS_CALLEVEL – a call at the interrupt level.
**              – E_OS_RESOURCE - calling task occupies resources.
*/
#if defined(OS_USE_INTERNAL_RESOURCES)

    if (OS_TaskConf[OsCurrentTID].InternalResource != INTERNAL_RES_NONE) {
#if defined(OS_SCHED_POLICY_NON) ||  defined(OS_SCHED_POLICY_MIX)
        OS_UNLOCK_INTERNAL_RESOURCE();
#endif
        OS_FORCE_SCHEDULE_FROM_TASK_LEVEL();
    }

#endif
    CLEAR_SERVICE_CONTEXT();
    return E_OK;
}
StatusType OsTask_Activate(TaskType TaskID)
#endif /* KOS_MEMORY_MAPPING */
{
    SAVE_SERVICE_CONTEXT(OSServiceId_ActivateTask, TaskID, NULL, NULL);

    ASSERT_VALID_TASKID(TaskID);
    ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL();
    ASSERT_VALID_CALLEVEL(OS_CL_TASK | OS_CL_ISR2);
    WARN_IF_TO_MANY_ACTIVATIONS(TaskID);

    DISABLE_ALL_OS_INTERRUPTS();
    OS_TASK_INCR_ACTIVATIONS(TaskID);

#if defined(OS_BCC2) || defined(OS_ECC2)

    if (OS_IS_TASK_SUSPENDED(TaskID)) {
#endif
    OS_TASK_CLEAR_ALL_EVENTS(TaskID);
    OsTask_Init(TaskID, FALSE);
    OsTask_Ready(TaskID);
#if     defined(OS_BCC2) || defined(OS_ECC2)
}


#endif
    ENABLE_ALL_OS_INTERRUPTS();

    CLEAR_SERVICE_CONTEXT();
    return E_OK;
}
Ejemplo n.º 3
0
StatusType OsTask_Activate(TaskType TaskID)
#endif /* KOS_MEMORY_MAPPING */
{
    Os_SaveServiceContext(OSServiceId_ActivateTask, TaskID, NULL, NULL);

    ASSERT_VALID_TASKID(TaskID);
    ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL();
    ASSERT_VALID_CALLEVEL(OS_CL_TASK | OS_CL_ISR2);
    WARN_IF_TO_MANY_ACTIVATIONS(TaskID);

    OsPort_DisableAllOsInterrupts();

    OsTask_IncrActivations(TaskID);

#if defined(OS_BCC2) || defined(OS_ECC2)

    if (OsTask_IsSuspended(TaskID)) {
#endif
        OsTask_ClearAllEvents(TaskID);
        OsTask_Init(TaskID, FALSE);
        OsTask_Ready(TaskID);
#if defined(OS_BCC2) || defined(OS_ECC2)
    }

#endif
    OsPort_EnableAllOsInterrupts();

    Os_ClearServiceContext();
    return E_OK;
}
StatusType GetTaskState(TaskType TaskID, TaskStateRefType State)
#endif /* KOS_MEMORY_MAPPING */
{
/*
**      "Within a full-preemptive system, calling this operating system
**      service only provides a meaningful result if the task runs in an
**      interrupt disabling state at the time of calling. When a call is made
**      from a task in a full-preemptive system, the result may already be
**      incorrect at the time of evaluation."
*/
    /* State is mot known @ this point!!! */
    SAVE_SERVICE_CONTEXT(OSServiceId_GetTaskState, TaskID, /*State*/ NULL, NULL);
    ASSERT_VALID_TASKID(TaskID);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK | OS_CL_ISR2 | OS_CL_ERROR_HOOK |
                          OS_CL_PRE_TASK_HOOK | OS_CL_POST_TASK_HOOK | OS_CL_PROTECTION_HOOK);

    DISABLE_ALL_OS_INTERRUPTS();
    *State = OS_TCB[TaskID].State;
    ENABLE_ALL_OS_INTERRUPTS();
/*
**      Standard-Status:
**              – E_OK – no error.
**      Extended-Status:
**               – E_OS_ID – the task identifier is invalid.
*/

    CLEAR_SERVICE_CONTEXT();
    return E_OK;
}
Ejemplo n.º 5
0
StatusType Schedule(void)
#endif /* KOS_MEMORY_MAPPING */
{
    Os_SaveServiceContext(OSServiceId_Schedule, NULL, NULL, NULL);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK);
    ASSERT_CURR_TASK_OCCUPIES_NO_RESOURCES();
    ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL();
/*    ASSERT_TASK_HAS_NO_SHARED_STACK();    */

/*
**       Standard-Status:
**              – E_OK – no error.
**       Extended-Status:
**              – E_OS_CALLEVEL – a call at the interrupt level.
**              – E_OS_RESOURCE - calling task occupies resources.
*/
#if defined(OS_USE_INTERNAL_RESOURCES)

    if (OS_TaskConf[Os_CurrentTID].InternalResource != INTERNAL_RES_NONE) {
#if defined(OS_SCHED_POLICY_NON) ||  defined(OS_SCHED_POLICY_MIX)
        OsTask_UnlockInternalResource();
#endif
        OsExec_ForceScheduleFromTaskLevel();
    }

#endif
    Os_ClearServiceContext();
    return E_OK;
}
Ejemplo n.º 6
0
StatusType ChainTask(TaskType TaskID)
#endif /* KOS_MEMORY_MAPPING */
{
    Os_SaveServiceContext(OSServiceId_ChainTask, TaskID, NULL, NULL);

    ASSERT_VALID_TASKID(TaskID);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK);
    ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL();
    ASSERT_CURR_TASK_OCCUPIES_NO_RESOURCES();

    if (TaskID != Os_CurrentTID) {
        WARN_IF_TO_MANY_ACTIVATIONS(TaskID);
    }

    OsPort_DisableAllOsInterrupts();
    OsTask_UnlockInternalResource();
    OsTask_DecrActivations(Os_CurrentTID);
    OsTask_Suspend(Os_CurrentTID);

    OsTask_IncrActivations(TaskID);
    OsTask_ClearAllEvents(TaskID);
    OsTask_Init(TaskID, ((TaskID == Os_CurrentTID) ? TRUE : FALSE));
    OsTask_Ready(TaskID);

    ASSERT(OS_TCB[Os_CurrentTID].State == SUSPENDED);

    OsPort_EnableAllOsInterrupts();

    OsExec_StartHighestReadyTask();

    Os_ClearServiceContext();
    return E_OK;
}
StatusType SetAbsAlarm(AlarmType AlarmID, TickType start, TickType cycle)
#endif /* KOS_MEMORY_MAPPING */
{
/*
**      Standard-Status:
**              – E_OK – no error.
**              – E_OS_STATE – the alarm is already in use.
**      Extended-Status:
**              – E_OS_ID – the alarm identifier is invalid.
**              – E_OS_VALUE - an alarm initialization value is outside of
**                the admissible limits (lower than zero or greater than the
**                maximum allowed value of the counter), or alarm cycle
**                value is unequal to 0 and outside of the admissible
**                counter limits (less than the minimum cycle value of the
**                counter or greater than the maximum allowed value of
**                the counter).
*/
    TickType CurrentCounterValue;

    SAVE_SERVICE_CONTEXT(OSServiceId_SetAbsAlarm, AlarmID, start, cycle);
    ASSERT_VALID_ALARMID(AlarmID);
    WARN_IF_ALARM_IS_RUNNING(AlarmID);
    ASSERT_VALID_ALARM_VALUES(AlarmID, start, cycle);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK | OS_CL_ISR2);

    DISABLE_ALL_OS_INTERRUPTS();

    CurrentCounterValue = Os_CounterValues[OS_AlarmConf[AlarmID].AttachedCounter];

    if (start == CurrentCounterValue) {
        OS_AlarmValue[AlarmID].ExpireCounter   = (TickType)0;
        OS_AlarmValue[AlarmID].CycleCounter    = cycle;
        OsAlm_StartAlarm(AlarmID);

        OsAlm_NotifyAlarm(AlarmID);
        OS_COND_SCHEDULE_FROM_TASK_LEVEL();
    } else {
        if (start > CurrentCounterValue) {
            OS_AlarmValue[AlarmID].ExpireCounter = start - CurrentCounterValue;
        } else {
            OS_AlarmValue[AlarmID].ExpireCounter =
                Os_CounterDefs[OS_AlarmConf[AlarmID].AttachedCounter].CounterParams.maxallowedvalue -
                (CurrentCounterValue + start + ((TickType)1)
                );
        }

        OS_AlarmValue[AlarmID].CycleCounter = cycle;
        OsAlm_StartAlarm(AlarmID);
    }

    ENABLE_ALL_OS_INTERRUPTS();

    CLEAR_SERVICE_CONTEXT();
    return E_OK;
}
StatusType GetAlarmBase(AlarmType AlarmID, AlarmBaseRefType Info)
#endif /* KOS_MEMORY_MAPPING */
{
/*
**      Standard-Status:
**              – E_OK – no error.
**
**      Extended-Status:
**              – E_OS_ID – the alarm identifier is invalid.
**      OSCallErrorHookAndReturn(E_OS_ID);
*/
    SAVE_SERVICE_CONTEXT(OSServiceId_GetAlarmBase, AlarmID, Info, NULL);
    ASSERT_VALID_ALARMID(AlarmID);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK | OS_CL_ISR2 | OS_CL_ERROR_HOOK | OS_CL_PRE_TASK_HOOK | OS_CL_POST_TASK_HOOK);

    CLEAR_SERVICE_CONTEXT();
    return GetCounterInfo(OS_AlarmConf[AlarmID].AttachedCounter, (CtrInfoRefType)Info);
}
StatusType ChainTask(TaskType TaskID)
#endif /* KOS_MEMORY_MAPPING */
{
/*
**      Terminates running Task and activates another, enforces Rescheduling.
**
**       Standard-Status:
**              – No return to call level.
**              – E_OS_LIMIT – too many activations of <TaskID>.
**       Extended-Status:
**              – E_OS_ID – the task identifier is invalid.
**              – E_OS_RESOURCE – the calling task still occupies resources.
**              – E_OS_CALLEVEL – a call at the interrupt level.
*/
    SAVE_SERVICE_CONTEXT(OSServiceId_ChainTask, TaskID, NULL, NULL);

    ASSERT_VALID_TASKID(TaskID);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK);
    ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL();
    ASSERT_CURR_TASK_OCCUPIES_NO_RESOURCES();

    if (TaskID != OsCurrentTID) {
        WARN_IF_TO_MANY_ACTIVATIONS(TaskID);
    }

    DISABLE_ALL_OS_INTERRUPTS();
    OS_UNLOCK_INTERNAL_RESOURCE();
    OS_TASK_DECR_ACTIVATIONS(OsCurrentTID);
    OsTask_Suspend(OsCurrentTID);

    OS_TASK_INCR_ACTIVATIONS(TaskID);
    OS_TASK_CLEAR_ALL_EVENTS(TaskID);
    OsTask_Init(TaskID, ((TaskID == OsCurrentTID) ? TRUE : FALSE));
    OsTask_Ready(TaskID);

    ASSERT(OS_TCB[OsCurrentTID].State == SUSPENDED);

    ENABLE_ALL_OS_INTERRUPTS();

    OsExec_StartHighestReadyTask();

    CLEAR_SERVICE_CONTEXT();
    return E_OK;
}
StatusType GetAlarm(AlarmType AlarmID, TickRefType Tick)
#endif /* KOS_MEMORY_MAPPING */
{
/*
**      Standard:r
**              – E_OK – no error.
**              – E_OS_NOFUNC – the alarm is not in use.
**      Extended-Status:
**              – E_OS_ID – the alarm identifier is invalid.
*/
    SAVE_SERVICE_CONTEXT(OSServiceId_GetAlarm, AlarmID, Tick, NULL);
    ASSERT_VALID_ALARMID(AlarmID);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK | OS_CL_ISR2 | OS_CL_ERROR_HOOK | OS_CL_PRE_TASK_HOOK | OS_CL_POST_TASK_HOOK);
    WARN_IF_ALARM_IS_NOT_RUNNING(AlarmID);

    DISABLE_ALL_OS_INTERRUPTS();
    *Tick = OS_AlarmValue[AlarmID].ExpireCounter;
    ENABLE_ALL_OS_INTERRUPTS();

    CLEAR_SERVICE_CONTEXT();
    return E_OK;
}
StatusType CancelAlarm(AlarmType AlarmID)
#endif /* KOS_MEMORY_MAPPING */
{
/*
**      Standard-Status:
**              – E_OK – no error.
**              – E_OS_NOFUNC – the alarm is not in use.
**      Extended-Status:
**              – E_OS_ID – the alarm identifier is invalid.
**
*/
    SAVE_SERVICE_CONTEXT(OSServiceId_CancelAlarm, AlarmID, NULL, NULL);
    ASSERT_VALID_ALARMID(AlarmID);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK | OS_CL_ISR2);
    WARN_IF_ALARM_IS_NOT_RUNNING(AlarmID);

    DISABLE_ALL_OS_INTERRUPTS();
    OsAlm_StopAlarm(AlarmID);
    ENABLE_ALL_OS_INTERRUPTS();

    CLEAR_SERVICE_CONTEXT();
    return E_OK;
}
StatusType SetRelAlarm(AlarmType AlarmID, TickType increment, TickType cycle)
#endif /* KOS_MEMORY_MAPPING */
{
/*
**      Standard-Status:
**              – E_OK – no error.
**              – E_OS_STATE – the alarm is already in use.
**      Extended-Status:
**              – E_OS_ID – the alarm identifier is invalid.
**              – E_OS_VALUE - an alarm initialization value is outside of
**                the admissible limits (lower than zero or greater than the
**                maximum allowed value of the counter), or alarm cycle
**                value is unequal to 0 and outside of the admissible
**                counter limits (less than the minimum cycle value of the
**                counter or greater than the maximum allowed value of
**                the counter).
*/
    SAVE_SERVICE_CONTEXT(OSServiceId_SetRelAlarm, AlarmID, increment, cycle);
    ASSERT_VALID_ALARMID(AlarmID);
    WARN_IF_ALARM_IS_RUNNING(AlarmID);
    ASSERT_VALID_ALARM_VALUES(AlarmID, increment, cycle);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK | OS_CL_ISR2);

    if (increment == (TickType)0) { /* todo: in 'ASSERT_VALID_ALARM_VALUES' einbauen!!! */
        CLEAR_SERVICE_CONTEXT();
        return E_OS_VALUE;          /*  !REQ!AS!OS!OS304!  */
    }

    DISABLE_ALL_OS_INTERRUPTS();
    OS_AlarmValue[AlarmID].ExpireCounter   = increment;
    OS_AlarmValue[AlarmID].CycleCounter    = cycle;
    OsAlm_StartAlarm(AlarmID);  /*    OS_AlarmValue[AlarmID].State=ALM_RUNNING; */
    ENABLE_ALL_OS_INTERRUPTS();

    CLEAR_SERVICE_CONTEXT();
    return E_OK;
}
StatusType TerminateTask(void)
#endif /* KOS_MEMORY_MAPPING */
{
/*
**      Standard-Status: no return to Calllevel.
**      Extended-Status:
**              – E_OS_RESOURCE – the task still occupies resources.
**              – E_OS_CALLEVEL – a call at the interrupt level.
**
*/
    SAVE_SERVICE_CONTEXT(OSServiceId_TerminateTask, NULL, NULL, NULL);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK);
    ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL();
    ASSERT_CURR_TASK_OCCUPIES_NO_RESOURCES();

    DISABLE_ALL_OS_INTERRUPTS();
    OS_TASK_DECR_ACTIVATIONS(OsCurrentTID);
    OsTask_Suspend(OsCurrentTID);

#if defined(OS_BCC2) || defined(OS_ECC2)

    if (OsCurrentTCB->Activations > 0) {  /* ???  */
        OS_TASK_CLEAR_ALL_EVENTS(OsCurrentTID);
        OsTask_Init(OsCurrentTID, TRUE);
        OsTask_Ready(OsCurrentTID);
    }

#endif

    OS_UNLOCK_INTERNAL_RESOURCE();
    ENABLE_ALL_OS_INTERRUPTS();

    OsExec_StartHighestReadyTask();

    CLEAR_SERVICE_CONTEXT();
    return E_OK; /* never reached */
}
Ejemplo n.º 14
0
StatusType TerminateTask(void)
#endif /* KOS_MEMORY_MAPPING */
{
/*
**      Standard-Status: no return to Calllevel.
**      Extended-Status:
**              – E_OS_RESOURCE – the task still occupies resources.
**              – E_OS_CALLEVEL – a call at the interrupt level.
**
*/
    Os_SaveServiceContext(OSServiceId_TerminateTask, NULL, NULL, NULL);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK);
    ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL();
    ASSERT_CURR_TASK_OCCUPIES_NO_RESOURCES();

    OsPort_DisableAllOsInterrupts();
    OsTask_DecrActivations(Os_CurrentTID);
    OsTask_Suspend(Os_CurrentTID);

#if defined(OS_BCC2) || defined(OS_ECC2)

    if (Os_CurrentTCB->Activations > 0) {  /* ???  */
        OsTask_ClearAllEvents(Os_CurrentTID);
        OsTask_Init(Os_CurrentTID, TRUE);
        OsTask_Ready(Os_CurrentTID);
    }

#endif

    OsTask_UnlockInternalResource();
    OsPort_EnableAllOsInterrupts();

    OsExec_StartHighestReadyTask();

    Os_ClearServiceContext();
    return E_OK; /* never reached */
}
StatusType GetTaskID(TaskRefType TaskID)
#endif /* KOS_MEMORY_MAPPING */
{
/*
    "If no task currently running, the service returns INVALID_TASK
    constant."
    Hinweis zur Test-Prozedur: alle Tasks beenden, so dass nur noch
    die IdleTask läuft und dann aus einer ISR 'GetTaskID' aufrufen!

 */
    /* TaskID ist not known at this point!!! */
    SAVE_SERVICE_CONTEXT(OSServiceId_GetTaskID, /*TaskID*/ NULL, NULL, NULL);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK | OS_CL_ISR2 | OS_CL_ERROR_HOOK |
                          OS_CL_PRE_TASK_HOOK | OS_CL_POST_TASK_HOOK | OS_CL_PROTECTION_HOOK);

/*    ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL(); */

    DISABLE_ALL_OS_INTERRUPTS();
    *TaskID = OsCurrentTID;
    ENABLE_ALL_OS_INTERRUPTS();

    CLEAR_SERVICE_CONTEXT();
    return E_OK;
}
Ejemplo n.º 16
0
StatusType GetTaskID(TaskRefType TaskID)
#endif /* KOS_MEMORY_MAPPING */
{
/*
    "If no task currently running, the service returns INVALID_TASK
    constant."
    Hinweis zur Test-Prozedur: alle Tasks beenden, so dass nur noch
    die IdleTask läuft und dann aus einer ISR 'GetTaskID' aufrufen!

 */
    /* TaskID ist not known at this point!!! */
    Os_SaveServiceContext(OSServiceId_GetTaskID, /*TaskID*/ NULL, NULL, NULL);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK | OS_CL_ISR2 | OS_CL_ERROR_HOOK |
                          OS_CL_PRE_TASK_HOOK | OS_CL_POST_TASK_HOOK | OS_CL_PROTECTION_HOOK);

/*    ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL(); */

    OsPort_DisableAllOsInterrupts();
    *TaskID = Os_CurrentTID;
    OsPort_EnableAllOsInterrupts();

    Os_ClearServiceContext();
    return E_OK;
}