Exemple #1
0
/* |------------------+------------------------------------------------------------| */
EXPORT StatusType WaitEvent ( EventMaskType Mask )
{
	StatusType ercd = E_OK;
    uint8 flgid;
    OS_EXT_VALIDATE((0 == knl_taskindp),E_OS_CALLEVEL);
    OS_EXT_VALIDATE((INVALID_RESOURCE == knl_tcb_resque[knl_curtsk]),E_OS_RESOURCE);
    flgid = knl_tcb_flgid[knl_curtsk];
    OS_EXT_VALIDATE((flgid != INVALID_FLAG),E_OS_ACCESS);

    BEGIN_CRITICAL_SECTION();
    if((knl_fcb_set[flgid] & Mask) == NO_EVENT)
    {
    	knl_fcb_wait[flgid] = Mask;
        knl_tcb_state[knl_curtsk] = WAITING;
        //release internal resource or for Non-Preemtable Task
        ReleaseInternalResource();
        knl_search_schedtsk();
    }
    END_CRITICAL_SECTION();
    //re-get internal resource or for Non-Preemtable task
    GetInternalResource();
OS_VALIDATE_ERROR_EXIT()
    OsErrorProcess1(WaitEvent,mask,Mask);
	return ercd;
}
Exemple #2
0
/* |------------------+---------------------------------------------------------| */
EXPORT StatusType ClearEvent( EventMaskType Mask )
{
	StatusType ercd = E_OK;
	uint8 flgid;
	OS_EXT_VALIDATE((0 == knl_taskindp),E_OS_CALLEVEL);
	flgid = knl_tcb_flgid[knl_curtsk];
	OS_EXT_VALIDATE((flgid != INVALID_FLAG),E_OS_ACCESS);

	BEGIN_DISABLE_INTERRUPT();
	knl_fcb_set[flgid] &= ~Mask;
	END_DISABLE_INTERRUPT();
OS_VALIDATE_ERROR_EXIT()
	OsErrorProcess1(ClearEvent,mask,Mask);
	return ercd;
}
Exemple #3
0
/* |------------------+--------------------------------------------------------------| */
EXPORT StatusType GetEvent  ( TaskType TaskID , EventMaskRefType Event )
{
	StatusType ercd = E_OK;
	uint8 flgid;
	OS_EXT_VALIDATE((TaskID < cfgOS_TASK_NUM),E_OS_ID);
	flgid = knl_tcb_flgid[TaskID];
	OS_EXT_VALIDATE((flgid != INVALID_FLAG),E_OS_ACCESS);
	OS_EXT_VALIDATE((SUSPENDED != knl_tcb_state[TaskID]),E_OS_STATE);

	BEGIN_DISABLE_INTERRUPT();
	*Event = knl_fcb_set[flgid];
	END_DISABLE_INTERRUPT();
OS_VALIDATE_ERROR_EXIT()
	OsErrorProcess2(GetEvent,tskid,TaskID,p_mask,Event);
	return ercd;
}
Exemple #4
0
/* |------------------+-----------------------------------------------------------------| */
StatusType SetAbsAlarm ( AlarmType AlarmID , TickType Start ,TickType Cycle )
{
	StatusType ercd = E_OK;
	CounterType counter;
	OS_EXT_VALIDATE((AlarmID < cfgOS_ALARM_NUM),E_OS_ID);
	OS_STD_VALIDATE((ALARM_STOPPED == knl_acb_value[AlarmID]),E_OS_STATE);
	counter = knl_acb_counter[AlarmID];
	OS_EXT_VALIDATE((knl_ccb_max[counter] >= Start),E_OS_VALUE);
	OS_EXT_VALIDATE((knl_ccb_max[counter] >= Cycle),E_OS_VALUE);
	OS_EXT_VALIDATE(((0u == Cycle)||(knl_ccb_min[counter] <= Cycle)),E_OS_VALUE);
	BEGIN_DISABLE_INTERRUPT();
	knl_acb_value[AlarmID] = Start;
	knl_acb_period[AlarmID] = Cycle;
	knl_alarm_insert(AlarmID);
	END_DISABLE_INTERRUPT();
OS_VALIDATE_ERROR_EXIT()
	OsErrorProcess3(SetAbsAlarm,almid,AlarmID,start,Start,cycle,Cycle);
	return ercd;
}
Exemple #5
0
/* |------------------+-----------------------------------------------------------| */
StatusType GetResource (ResourceType ResID)
{
	StatusType ercd = E_OK;
	OS_EXT_VALIDATE((0 == knl_taskindp),E_OS_CALLEVEL); //add as share resource with ISR was not supported
	OS_EXT_VALIDATE((ResID < cfgOS_S_RES_NUM),E_OS_ID);
	OS_EXT_VALIDATE((INVALID_PRIORITY == knl_rcb_tskpri[ResID]),E_OS_ACCESS);
    OS_EXT_VALIDATE((knl_rcb_priority[ResID] >= knl_tcb_ipriority[knl_curtsk]),E_OS_ACCESS);

    BEGIN_DISABLE_INTERRUPT();
    knl_rcb_tskpri[ResID] = knl_tcb_curpri[knl_curtsk];  // save task old priority
    if(knl_rcb_priority[ResID] > knl_tcb_ipriority[knl_curtsk])
    {
    	knl_tcb_curpri[knl_curtsk] = knl_rcb_priority[ResID];
    }
    // Insert it at task resource queue head
    knl_rcb_next[ResID] = knl_tcb_resque[knl_curtsk];
    knl_tcb_resque[knl_curtsk] = ResID;
    END_DISABLE_INTERRUPT();
OS_VALIDATE_ERROR_EXIT()
    OsErrorProcess1(GetResource,resid,ResID);
	return ercd;
}
Exemple #6
0
/* |------------------+------------------------------------------------------------| */
StatusType ReleaseResource ( ResourceType ResID )
{
	StatusType ercd = E_OK;
	OS_EXT_VALIDATE((0 == knl_taskindp),E_OS_CALLEVEL); //add as share resource with ISR was not supported
	OS_EXT_VALIDATE((ResID < cfgOS_S_RES_NUM),E_OS_ID);
	OS_EXT_VALIDATE(knl_tcb_resque[knl_curtsk] == ResID,E_OS_NOFUNC);
    OS_EXT_VALIDATE((knl_rcb_priority[ResID] >= knl_tcb_ipriority[knl_curtsk]),E_OS_ACCESS);

    BEGIN_CRITICAL_SECTION();
    knl_tcb_curpri[knl_curtsk] = knl_rcb_tskpri[ResID];
    // remove it at head
    knl_tcb_resque[knl_curtsk] = knl_rcb_next[ResID];
    knl_rcb_tskpri[ResID] = INVALID_PRIORITY;
    if(knl_tcb_curpri[knl_curtsk] > knl_rdyque.top_pri)
    {
        knl_preempt();
    }
    END_CRITICAL_SECTION();
OS_VALIDATE_ERROR_EXIT()
    OsErrorProcess1(ReleaseResource,resid,ResID);
	return ercd;
}
Exemple #7
0
EXPORT StatusType osekSetEvent  ( TaskType TaskID , EventMaskType Mask )
#endif
{
	StatusType ercd = E_OK;
	uint8 flgid ;
	OS_EXT_VALIDATE((TaskID < cfgOS_TASK_NUM),E_OS_ID);
	flgid = knl_tcb_flgid[TaskID];
	OS_EXT_VALIDATE((flgid != INVALID_FLAG),E_OS_ACCESS);
	OS_EXT_VALIDATE((SUSPENDED != knl_tcb_state[TaskID]),E_OS_STATE);

	BEGIN_CRITICAL_SECTION();
	knl_fcb_set[flgid] |= Mask;
	if((knl_fcb_set[flgid] & knl_fcb_wait[flgid]) != NO_EVENT)
	{
		knl_fcb_wait[flgid] = NO_EVENT;
		knl_tcb_state[TaskID] = READY;
		knl_make_runnable(TaskID);
	}
	END_CRITICAL_SECTION();
OS_VALIDATE_ERROR_EXIT()
	OsErrorProcess2(SetEvent,tskid,TaskID,mask,Mask);
	return ercd;
}
Exemple #8
0
/* |------------------+------------------------------------------------------------------| */
StatusType GetAlarmBase ( AlarmType AlarmID, AlarmBaseRefType Info )
{
	StatusType ercd = E_OK;
	CounterType counter;
    OS_EXT_VALIDATE((AlarmID < cfgOS_ALARM_NUM),E_OS_ID);
    counter = knl_acb_counter[AlarmID];
    Info->maxallowedvalue = knl_ccb_max[counter];
    Info->mincycle = knl_ccb_min[counter];
    Info->ticksperbase = knl_ccb_tpb[counter];

OS_VALIDATE_ERROR_EXIT()
    OsErrorProcess2(GetAlarmBase,almid,AlarmID,p_info,Info);
    return ercd;
}
Exemple #9
0
/* |------------------+-------------------------------------------------------------| */
StatusType CancelAlarm ( AlarmType AlarmID )
{
    StatusType ercd = E_OK;
    OS_EXT_VALIDATE((AlarmID < cfgOS_ALARM_NUM),E_OS_ID);
	OS_STD_VALIDATE((ALARM_STOPPED != knl_acb_value[AlarmID]),E_OS_NOFUNC);

	BEGIN_DISABLE_INTERRUPT();
	knl_alarm_remove(AlarmID);
	knl_acb_value[AlarmID] = ALARM_STOPPED;
	END_DISABLE_INTERRUPT();
OS_VALIDATE_ERROR_EXIT()
	OsErrorProcess1(SetAbsAlarm,almid,AlarmID);
	return ercd;
}
/** @req OS399 */
StatusType IncrementCounter( CounterType counter_id ) {
    StatusType rv = E_OK;
    OsCounterType *cPtr;
    uint32_t flags;
#if (OS_SC3==STD_ON) || (OS_SC4==STD_ON)
    OsTaskVarType *currPcbPtr;
#endif

    OS_VALIDATE( IsCounterValid(counter_id), E_OS_ID );
    cPtr = Os_CounterGet(counter_id);

    OS_VALIDATE( !( ( cPtr->type != COUNTER_TYPE_SOFT ) ||
                    ( counter_id >= OS_COUNTER_CNT )), E_OS_ID );

#if (OS_SC3==STD_ON) || (OS_SC4==STD_ON)
    currPcbPtr = Os_SysTaskGetCurr();

    if( currPcbPtr->constPtr->applOwnerId != cPtr->applOwnerId ) {
        /* @req SWS_Os_00056 */
        APPL_CHECK_STATE(cPtr->applOwnerId);
        APPL_CHECK_ACCESS(currPcbPtr->constPtr->applOwnerId, cPtr->accessingApplMask);


#if (OS_CORE_CNT > 1)
        OS_EXT_VALIDATE( Os_ApplGetCore(cPtr->applOwnerId) != GetCoreID(), E_OS_ACCESS );
#endif
    }
#endif

    Irq_Save(flags);

    /** @req OS286 */
    cPtr->val = Os_CounterAdd( cPtr->val, Os_CounterGetMaxValue(cPtr), 1 );

#if OS_ALARM_CNT!=0
    Os_AlarmCheck(cPtr);
#endif
#if OS_SCHTBL_CNT!=0
    Os_SchTblCheck(cPtr);
#endif

    Irq_Restore(flags);

    /** @req OS321 */
    COUNTER_STD_END;
}
Exemple #11
0
/* |------------------+------------------------------------------------------------------| */
StatusType GetAlarm ( AlarmType AlarmID ,TickRefType Tick )
{
	StatusType ercd = E_OK;
    CounterType counter;
    OS_EXT_VALIDATE((AlarmID < cfgOS_ALARM_NUM),E_OS_ID);
    OS_STD_VALIDATE((ALARM_STOPPED != knl_acb_value[AlarmID]),E_OS_NOFUNC);
    counter = knl_acb_counter[AlarmID];

    BEGIN_DISABLE_INTERRUPT();
    if(knl_ccb_value[counter] <  knl_acb_value[AlarmID])
    {
        *Tick = knl_acb_value[AlarmID] - knl_ccb_value[counter];
    }
    else
    {
        *Tick = knl_ccb_max[counter]*2 + 1- knl_ccb_value[counter] + knl_acb_value[AlarmID];
    }
    END_DISABLE_INTERRUPT();

OS_VALIDATE_ERROR_EXIT()
    OsErrorProcess2(GetAlarm,almid,AlarmID,p_tick,Tick);
    return ercd;
}