📄 fs10msgapi.c
字号:
* ------------------- * pp_ReceivedObject * * Output parameters : * ------------------- * none * * Used variables : * -------------------** Used procedure** ------------------- * - MC_RTK_CLEAR_TIMER * - MC_PCC_GET_FUNCTION* - MC_RTK_QUEUE*-----------------------------------------------------------------------------*-----------------------------------------------------------------------------* DESCRIPTION * * Put the message received into pending job list. * *-----------------------------------------------------------------------------***************************************************************************)P*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 2u8 Fs10_02InsertInJobs(t_RtkObject * pp_ReceivedObject){ switch ( pp_ReceivedObject->v_TypeOfObj ) { /* u32 vl_TimerID; */ /* It is a timer */ case RTK_OBJ_TIMER : { u32 vl_TimerID = pp_ReceivedObject->u_ReceivedObj.v_TimerID; /* Clear the timer */ MC_RTK_CLEAR_TIMER( vl_TimerID ); /* If it is the timer of the Time out timer */ if ( MC_PCC_GET_FUNCTION(vl_TimerID) == FS_CMD_TO ) { /* Decrement thread time out */ /* To added at thread implementation */ /* Call FS autoflush timers */ Fs86_11BFTimeOut(); } } break; /* It is a message */ case RTK_OBJ_MESSAGE : { u16 vl_FsCommand; /* Point on message */ t_MsgHeader *pl_ReceivedMessage = ( t_MsgHeader * ) pp_ReceivedObject->u_ReceivedObj.p_MessageAddress; t_OperationType vl_OperationType = pl_ReceivedMessage->v_OperationType;#ifdef SYNCHRONOUS_FILE_SYSTEM_FTR if ( MC_PCC_GET_TYPE(vl_OperationType) == PCC_T_IND) { u8 vl_EraseStatus; /* Check if the IND msg is sent from correct process */ if ( pl_ReceivedMessage->s_Transmitter != PROCESS_DFRG ) break; /* Check for erase status */ vl_EraseStatus = ((t_FssDelayInd* )pl_ReceivedMessage)->v_EraseStatus; if (vl_EraseStatus == FSS_ERASE_END) { /* Notify to applicatoin(s), if needed */ v_FssNoDelay--; Fs10_06SendMsgToApp(); } else { v_FssNoDelay++; }/* LMSqa03374 - 19/01/04 - tcmc_wbm */ if ( pl_ReceivedMessage != NULL ) { MC_FS_FREE_MEMORY( (u8 *)pl_ReceivedMessage ); }/* End LMSqa03374 */ break; }#endif /* SYNCHRONOUS_FILE_SYSTEM_FTR */ vl_FsCommand = MC_PCC_GET_FUNCTION(vl_OperationType); /* switch to appropriate treatement */ if ( vl_FsCommand < FS_SPECIAL_CMD ) { /* Verify if command is not out of FS range and a request */ if ( ( vl_FsCommand > FS_MAX_APPLI_CMDS ) || ( MC_PCC_GET_TYPE(vl_OperationType) != PCC_T_REQ ) ) { FS_EXCPTHANDLER( FS_BLOCKED , FS_EXCPT_BAD_OBJECT_TYPE ); return( 0 ); } else { /* Place message in JOB queue */ MC_RTK_QUEUE( &s_JobQueue, (void*) pl_ReceivedMessage ); } } /* else if ( vl_OperationType == FS_OPTYPE_RUN_THREAD) */ /* { */ /* Creates a thread destinated to lower layers the message contains: */ /* - address of the function corresponding to the thread */ /* - the address of the context to place in communication structure */ /* */ /* */ /* To complete in the future when internal threads will be implemented */ /* } */ else /* Unknow optype set a defense */ { FS_EXCPTHANDLER( FS_BLOCKED , FS_EXCPT_BAD_OBJECT_TYPE ); return( 0 ); } } break; /* Event or unknow type of object */ default : FS_EXCPTHANDLER( FS_BLOCKED , FS_EXCPT_BAD_OBJECT_TYPE ); return ( 0 ); } /* As no threads are implemented in this version no rescheduling asked */ return ( 0 );}/*P(**************************************************************************** Procedure name : Fs10_03Schedule * Object : Processes the first request FSS request wating in the queue. *-----------------------------------------------------------------------------* Input parameters : * ------------------- * u8 vp_Behaviour : If an acknoledge message is to send * void * pp_Msg: Pointer on message to finish to fill and to send * t_OperationType vp_OpType : Operation type of the message * * * Output parameters : * ------------------- * u32 : Identifier of the command * * Used variables : * ------------------- * * * Used procedures : * ------------------- * * *-----------------------------------------------------------------------------*-----------------------------------------------------------------------------* DESCRIPTION * In the first version this function runs the first job in jobs list * if a JOB is already active no new JOB is runned, no priority of * JOBs is managed.** In future versions it has create threads and to activate the highest* prioritized this by respecting a sequencial execution order for an* entity. * * *-----------------------------------------------------------------------------***************************************************************************)P*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 3void Fs10_03Schedule( void ){ t_MsgHeader * pl_MsgHeader; /* Is a JOB already active then return */ if ( v_JobActive == 1 ) return; /* If a another JOB exist extract it from JOB's queue */ pl_MsgHeader = (t_MsgHeader *)MC_RTK_DEQUEUE(&s_JobQueue); if ( pl_MsgHeader == NIL ) return; /* Run this JOB */ /*--------------*/ /* Note that a JOB is Running */ v_JobActive = 1; { u16 vl_Command = MC_PCC_GET_FUNCTION(pl_MsgHeader->v_OperationType); u8 vl_WithAck = 0;#if defined(SYNCHRONOUS_FILE_SYSTEM_FTR) u8 vl_SyncSemError = NIL; u8 vl_SyncSemaphore;/* Remove declaration to get rid of Warning Message - tcmc_wbm */ /*u8 i;*/#endif /* SYNCHRONOUS_FILE_SYSTEM_FTR */ /* Creates communication structure */ /* t_LayerCommunication s_LayerCom; */ /* Set error number to no error */ ((t_FsMsgHeader *) pl_MsgHeader)->v_ErrNumber = FS_OK; /* Run the command by giving it a pointer on received message */ ( a_FsTabFct[vl_Command] )( (void*) pl_MsgHeader );#if defined(SYNCHRONOUS_FILE_SYSTEM_FTR) /*** Syncronous Message Interface ***/ if( ((t_FsMsgHeader*) pl_MsgHeader)->v_Behavior == FS_NO_ACK ) {#if 0 /* tcmc_BRC: Do not use 3 semaphores, use only FSS_SEM1 to simulate synchronous interface over FSS */ /* Associate calling process with defined FssSemaphoreID */ for( i=0; i < FSS_SEM_LST_MAX; i++ ) { /* Determine calling process */ /* This is known from the kernel; it is equal to s_Transmitter of _REQ */ /* FSS scheduler us s_Transmitter of _REQ do determine which Semaphore is 'produced' */ if( MC_RTK_SEM_TEST_CONSUME( a_FssSem[i].v_Semaphore ) == RTK_OK ) { MC_RTK_SEM_PRODUCE( a_FssSem[i].v_Semaphore ); } else { if( a_FssSem[i].v_ProcessIdentity == pl_MsgHeader->s_Transmitter ) { vl_SyncSemaphore = a_FssSem[i].v_Semaphore; vl_SyncSemError = 1; break; } } }#else /* always produce FSS_SEM1 */ vl_SyncSemError = 1; vl_SyncSemaphore = FSS_SEM1;#endif /* tcmc_BRC */ /* Release Semaphore of Syncronous Interface */ if( vl_SyncSemError != NIL ) { /* Semaphore consumed by a calling application process is now produced */ /* The application process is not any longer blocked */ MC_RTK_SEM_PRODUCE( vl_SyncSemaphore ); /* Set FssSemaphoreID to unused in FssSemaphoreList */ /* a_FssSem[i].v_SemState = FSS_SEM_UNUSED; */ } else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -