📄 fs84lowlayer.c
字号:
/***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 9u8 Fs84_09AddedLayerToVol( t_fsVolStruct * pp_VolStruct, u16 vp_NbrCmds, void * pp_LayerContext){ t_InterLayer * pl_Interlayer = (t_InterLayer *) pp_VolStruct->p_LayerCommunication; t_FunctionAndLevel * pl_FctLevelTab = NIL; u8 vl_Level = pl_Interlayer->v_NbrLayers; u8 vl_NbrMaxLevelLayers = s_LowLayerDataBaseStruct.v_NbrMaxLevelLayers; u8 vl_Index; /* Updates number of commands of lower layer */ if ( vl_Level != vl_NbrMaxLevelLayers) pl_Interlayer[vl_Level].v_NbrCommands = vp_NbrCmds; /* Update interlayer pointer in interlayer table */ pl_Interlayer[vl_Level].p_LayerContext = pp_LayerContext; /* Creates the function/level table and place its address in layer table */ if ( vp_NbrCmds != 0 ) pl_FctLevelTab = pl_Interlayer[vl_Level].p_TabFctLevel = ( t_FunctionAndLevel *) MC_FS_GET_MEMORY(sizeof(t_FunctionAndLevel) * vp_NbrCmds ); /* Increment number of layers for the volume for all levels in interlayer table */ for ( vl_Index = 0; vl_Index< vl_NbrMaxLevelLayers; vl_Index++ ) pl_Interlayer[vl_Index].v_NbrLayers ++; /* Fill all function addresses with FS_FCT_NOT_EXIST */ for ( vl_Index = 0 ; vl_Index < vp_NbrCmds; vl_Index++ ) { pl_FctLevelTab[vl_Index].p_Fct = (void (*)(void*,void*)) FS_FCT_NOT_EXIST; } /* Return current level of layer */ return(vl_Level);}/**//*P(***************************************************************************//* Procedure name : Fs84_10SetCommand() *//* Object : Set a new command for the new layer *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* t_fsVolStruct * pp_VolStruct: structure of the volume under mounting *//* u16 vp_CommandId : Identifier of the command *//* void (*pp_Fct)(void*,void*): Address of function to call for *//* this command *//* *//* Output parameters : *//* ------------------- *//* none *//* *//* Used variables : *//* ------------------- *//* *//* *//* Used procedures : *//* ------------------- *//* *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* Added a new command to the layer under mounting *//* The command is placed in the command/level table in index equal to *//* the command ID. *//* *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 10void Fs84_10SetCommand( t_fsVolStruct * pp_VolStruct, u16 vp_CommandId, void (*pp_Fct)(void*,void*)){ t_InterLayer * pl_Interlayer = (t_InterLayer *) pp_VolStruct->p_LayerCommunication; t_FunctionAndLevel * pl_CurrFctLevelTab; u8 vl_Level = pl_Interlayer->v_NbrLayers - 1; /* Point on current layer function/level table */ pl_CurrFctLevelTab = pl_Interlayer[vl_Level].p_TabFctLevel; /* Verify if not out of table */ if ( vp_CommandId >= pl_Interlayer[vl_Level].v_NbrCommands ) FS_EXCPTHANDLER( FS_BLOCKED , FS_ERR_BAD_OPER_ID ); /* Place function address in table and update level */ pl_CurrFctLevelTab[vp_CommandId].p_Fct = pp_Fct; pl_CurrFctLevelTab[vp_CommandId].v_Level = vl_Level;}/**//*P(***************************************************************************//* Procedure name : Fs84_11SetCmdToLowLayerCommand() *//* Object : Set a new command to a command implemented in the just *//* lower layer *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* t_fsVolStruct * pp_VolStruct: structure of the volume under mounting *//* u16 vp_CommandId : Identifier of the command *//* u16 vp_LowLayerCommandId: Identifier of the just lower layer's */ /* command *//* *//* Output parameters : *//* ------------------- *//* none *//* *//* Used variables : *//* ------------------- *//* *//* *//* Used procedures : *//* ------------------- *//* *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* Added a new command to the layer under mounting *//* The command characteristics ( addess of the function, level ) *//* are copied from a just under-layer command *//* *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 11void Fs84_11SetCmdToLowLayerCommand(t_fsVolStruct * pp_VolStruct, u16 vp_CommandId, u16 vp_LowLayerCommandId){ t_InterLayer * pl_Interlayer = ( t_InterLayer *) pp_VolStruct->p_LayerCommunication; t_FunctionAndLevel * pl_CurrFctLevelTab; t_FunctionAndLevel * pl_LowerFctLevelTab; u8 vl_Level = pl_Interlayer->v_NbrLayers - 1; /* Verify if a lower layer exist */ if ( vl_Level == 0 ) FS_EXCPTHANDLER( FS_BLOCKED , FS_EXCPT_NO_LOWER_LAYER ); /* Point on current layer function/level table */ pl_CurrFctLevelTab = pl_Interlayer[vl_Level].p_TabFctLevel; /* Point on lower layer function/level table */ pl_LowerFctLevelTab = pl_Interlayer[vl_Level-1].p_TabFctLevel; /* Verify if command id not out of table */ if ( vp_CommandId >= pl_Interlayer[vl_Level].v_NbrCommands ) FS_EXCPTHANDLER( FS_BLOCKED , FS_ERR_BAD_OPER_ID ); /* Verify if low layer command id not out of table */ if ( vp_LowLayerCommandId >= pl_Interlayer[vl_Level-1].v_NbrCommands ) FS_EXCPTHANDLER( FS_BLOCKED , FS_ERR_BAD_OPER_ID ); /* Copy lower layer structure in current layer's structure */ pl_CurrFctLevelTab[vp_CommandId].p_Fct = pl_LowerFctLevelTab[vp_LowLayerCommandId].p_Fct; pl_CurrFctLevelTab[vp_CommandId].v_Level = pl_LowerFctLevelTab[vp_LowLayerCommandId].v_Level;}/**//*P(***************************************************************************//* Procedure name : Fs84_12MountVolume() *//* Object : Mount a new volume to the FS *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* t_fsVolStruct * pp_VolStruct: structure of the volume under mounting *//* ascii * pp_VolName : Name of the new mounted volume *//* *//* Output parameters : *//* ------------------- *//* s32: Status of init runned after mount *//* *//* Used variables : *//* ------------------- *//* *//* *//* Used procedures : *//* ------------------- *//* *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* Mounts a new volume to the FS, the volume structure is inserted *//* mounted volume list *//* *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 12s32 Fs84_12MountVolume( void * pp_Volume, const fsVolName * pp_VolName ){ /* Creates communication structure */ t_LayerCommunication s_LayerCom; s32 vl_Status = FS_OK; /* Mount the FS layer to volume ( 0 functions, no context to mount ) */ /* Fs84_09AddedLayerToVol( ( t_fsVolStruct *) pp_Volume, 0, NIL ); */ /* Insert the volume sstructure in volume list */ MC_FS_VD_INSERT_NEW_VOL( (( t_fsVolStruct *) pp_Volume)->v_VolID, (fsVolName*)pp_VolName, ( t_fsVolStruct *)pp_Volume); /* Init thread on this communication structure */ MC_FS_LL_THREAD_COMM_INIT( &s_LayerCom, 0); /* Set the interlayer table pointer */ MC_FS_LL_SET_NEW_VOL(( t_fsVolStruct *) pp_Volume); /* Initialize lower layers */ MC_FS_LL_INIT( &vl_Status); return(vl_Status);}/**//*P(***************************************************************************//* Procedure name : Fs84_13UnmountVolume() *//* Object : Unmount a mounted volume *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* ascii * pp_VolName : Name of the new mounted volume *//* *//* Output parameters : *//* ------------------- *//* s32: Status of init runned after mount *//* *//* Used variables : *//* ------------------- *//* *//* *//* Used procedures : *//* ------------------- *//* *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* Unmounts a volume from the FS, the volume structure is released from the *//* mounted volume list *//* *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 13s32 Fs84_13UnmountVolume(const fsVolName * pp_VolName ){ u16 vl_VolID; s32 vl_Status = FS_OK; t_fsVolStruct *pp_Vol; /* search for volume structure in volume list */ pp_Vol = MC_FS_VD_SEARCH_VOL_BY_NAME((ascii *)pp_VolName, FSS_NAME_MAX); vl_VolID = MC_FS_VD_GET_VOL_ID(pp_Vol); /* Delete the volume structure from volume list */ MC_FS_VD_DELETE_VOL(vl_VolID, pp_Vol); return(vl_Status);}#endif /* FSS_FTR */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -