📄 fs84lowlayer.c
字号:
/*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 5t_LayerCommunication * Fs84_05GetCommunicationStructPtr(void){ return (s_LowLayerDataBaseStruct.p_TabLayerCommunication[MC_RTK_CURRENT_TASK] );}/**//*P(***************************************************************************//* Procedure name : Fs84_06SetCommunicationStructPtr() *//* Object : Sets the communication structure pointer *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* t_LayerCommunication * pp_LayerCom : pointer on the communication *//* structure *//* *//* Output parameters : *//* ------------------- *//* none *//* *//* Used variables : *//* ------------------- *//* *//* *//* Used procedures : *//* ------------------- *//* *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* Sets the pointer on the communication structure of the thread *//* ( This function is only to use from the FS internal thread switch *//* because at internal thread switch the pointer must be set after *//* run of the switch ) *//* *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 6void Fs84_06SetCommunicationStructPtr(t_LayerCommunication * pp_LayerCom ){ s_LowLayerDataBaseStruct.p_TabLayerCommunication[MC_RTK_CURRENT_TASK] = pp_LayerCom;}/**//*P(***************************************************************************//* Procedure name : Fs84_07LLCallLowerLayer() *//* Object : Call a command of a lower layer associated to the volume *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* u16 vp_Oper : Code of the operation to execute *//* structure *//* void* pp_Param : Pointer on structure containing input and output *//* of the command *//* *//* Output parameters : *//* ------------------- *//* none *//* *//* Used variables : *//* ------------------- *//* *//* *//* Used procedures : *//* ------------------- *//* *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* Runs the command corresponding to the operation "vp_Oper" of the *//* lower layer by passing in parameter the structure *//* pointed by pp_Param *//* *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 7void Fs84_07LLCallLowerLayer( u16 vp_Oper, void* pp_Param ){ t_LayerCommunication * pl_LayerCom; t_FunctionAndLevel * pl_FctLevel; t_InterLayer * pl_Interlayer; t_Layer * pl_Layer; /* Pointer in stack of communication structure */ /* Load communication pointer of the running entity */ pl_LayerCom = s_LowLayerDataBaseStruct.p_TabLayerCommunication[MC_RTK_CURRENT_TASK]; /* Point on courant level's interlayer info */ pl_Interlayer = pl_LayerCom->p_CurrentInterLayer; /* If debug mode verify if command exist */#ifdef DEBUG /* Verify if operation ID less than number of commands */ if ( vp_Oper >= pl_Interlayer->v_NbrCommands ) { FS_EXCPTHANDLER( FS_BLOCKED , FS_ERR_BAD_OPER_ID ); return; }#endif /* Load function level table address */ pl_FctLevel = (pl_Interlayer->p_TabFctLevel) + vp_Oper; /* Verify if function exist for this volume */ FS_TEST_FCT_EXIST( pl_FctLevel ); /* If function has nothing to do for this volume return */ if ( pl_FctLevel->p_Fct == FS_FCT_NOTHING_TO_DO ) return; /* Place command ID in FS header parameters structure */ ((t_fs_llGeneric*)pp_Param)->v_Operation = vp_Oper; /* Push old levels data in communication structure's stack */ /*---------------------------------------------------------*/ pl_Layer = &pl_LayerCom->a_Layer[pl_LayerCom->v_NbrStackEntries++]; pl_Layer->p_Interlayer = pl_LayerCom->p_CurrentInterLayer; { register t_InterLayer * pl_NewCtxInterlayer; /* Point on new levels interlayer structure */ /*------------------------------------------*/ pl_NewCtxInterlayer = pl_LayerCom->p_CurrentInterLayer - (pl_Interlayer->v_Level - pl_FctLevel->v_Level); pl_LayerCom->p_CurrentInterLayer = pl_NewCtxInterlayer - 1; /* Call low layer's function */ /*----------------------------*/ /* Call lower layer */ (pl_FctLevel->p_Fct)( pl_NewCtxInterlayer->p_LayerContext, pp_Param ); } /* Test if all MUTEXes freed */ /*---------------------------*/ FS_TEST_ALL_MUTEX_LEVEL_FREE(pl_LayerComm) /* Restore current data poped from stack */ /*---------------------------------------*/ /* Push pointer on current layer in interlayer table */ pl_LayerCom->p_CurrentInterLayer = pl_Layer->p_Interlayer; /* Decrement stack pointer */ pl_LayerCom->v_NbrStackEntries--;}/**//*P(***************************************************************************//* Procedure name : Fs84_08GetNewVolume() *//* Object : Gets a new volume to open *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* none *//* *//* Output parameters : *//* ------------------- *//* t_fsVolStruct * : Pointer on volume structure *//* *//* Used variables : *//* ------------------- *//* *//* *//* Used procedures : *//* ------------------- *//* *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* Begin to open a new volume, for this creates the new volume *//* structure attach it the interlayer table *//* *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 8void * Fs84_08GetNewVolume(void){ s16 vl_VolID; t_fsVolStruct * pl_VolStruct; t_InterLayer * pl_Interlayer; u8 vl_NbrMaxLevelLayers = s_LowLayerDataBaseStruct.v_NbrMaxLevelLayers; u8 i; /* Gets a new volume id */ vl_VolID = MC_FS_VD_GET_NEW_VOL_ID; /* Gets a new volume structure */ pl_VolStruct = ( t_fsVolStruct *) MC_FS_GET_MEMORY(sizeof(t_fsVolStruct) + sizeof (t_VolIOBuffMngt)); /* Clear the structure */ memset(pl_VolStruct, 0, sizeof(t_fsVolStruct) + sizeof (t_VolIOBuffMngt)); /* Update pointer on IO buffer management configuration */ pl_VolStruct->p_IOBuffMngt = ((u8*)(pl_VolStruct)) + sizeof(t_fsVolStruct); /* Place volume id in volume structure */ pl_VolStruct->v_VolID = vl_VolID; /* Reserve the interlayer communication table */ pl_Interlayer = ( t_InterLayer *) MC_FS_GET_MEMORY ( sizeof ( t_InterLayer ) * vl_NbrMaxLevelLayers ); pl_VolStruct->p_LayerCommunication = (void*)pl_Interlayer; /* Fill this structure with default values */ for ( i = 0; i< vl_NbrMaxLevelLayers; i++ ) { pl_Interlayer[i].v_NbrCommands = 0; pl_Interlayer[i].v_Level = i; pl_Interlayer[i].p_LayerContext = 0; pl_Interlayer[i].p_TabFctLevel = 0; pl_Interlayer[i].v_NbrLayers = 1; } /* Return volume structure */ return ((void*)pl_VolStruct);}/**//*P(***************************************************************************//* Procedure name : Fs84_09AddedLayerToVol() *//* Object : Added a new layer to the volume *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* t_fsVolStruct * pp_VolStruct: structure of the volume under mounting *//* u16 vp_NbrCmds : Number of commands of the just higher layer *//* void * pp_LayerContext: Context of the mounted layer *//* *//* Output parameters : *//* ------------------- *//* u8: Level of the mounted layer *//* *//* Used variables : *//* ------------------- *//* *//* *//* Used procedures : *//* ------------------- *//* *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* Added a new layer to the volume under mounting *//* Get dynamically memory to place the function level table needed *//* for interlayer communication and initialize it *//* *//*----------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -