📄 fs87synchinterf.c
字号:
*----------------------------------------------------------------------------* *----------------------------------------------------------------------------* * DESCRIPTION * * Synchronous function interface to FSS * -Sends REQ message to FS * -Returns FS_OK or error code * *----------------------------------------------------------------------------* **************************************************************************)S*/#undef PROCEDURE_NUMBER#define PROCEDURE_NUMBER 4s32 Fs87_04Rename(const fssPath *pp_OldName, const fssPath *pp_NewName){ s32 vl_return; s32 vl_ErrCode; u8 vl_SemName; /* Reserve message space */ t_FsCmdRename * pl_Rename = (t_FsCmdRename*) MC_FS_GET_MEMORY( sizeof(t_FsCmdRename) ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_CONSUME(FSS_SEM2); /* Determine the calling process in order to determine what semaphore to consume */ vl_SemName= Fs87_30DetermineSem(); if (vl_SemName == NIL) { MC_FS_STATUS( pl_Rename ) = FS_EINVAL; } else { MC_FS_STATUS( pl_Rename ) = FS_OK; } /* Send message to PROCESS_FSS */ if ( MC_FS_STATUS( pl_Rename ) == FS_OK ) { /* Fill message with input parameters */ pl_Rename->p_OldName = pp_OldName; pl_Rename->p_NewName = pp_NewName; /* Send message by setting operation and return command identifier */ MC_FS_MA_SEND_CMD_MSG_TO_FS( FS_NO_ACK, (void*)pl_Rename, FS_CMD_RENAME_REQ ); /* Consume Semaphore */ MC_RTK_SEM_CONSUME( vl_SemName ); } /* Set the updated err/ok code to corresponding process' global variable */ vl_ErrCode = MC_FS_STATUS( pl_Rename ); Fs87_31SetErrorCode( vl_ErrCode ); /* if the operation is not successful, return an error */ if ( MC_FS_STATUS( pl_Rename ) != FS_OK ) { vl_return = FS_ERROR; } else { vl_return = FS_OK; } /* Free message space */ MC_FS_FREE_MEMORY( pl_Rename ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_PRODUCE(FSS_SEM2); return( vl_return );}/*S(*************************************************************************** * Semantic name : Fs87_05Setvbuf() * Object : setvbuf Synchronous POSIX API * Finite state machine : * Event : * Transition : *----------------------------------------------------------------------------* * * Input parameters : * ------------------- * pp_Stream - file handle * vp_BuffMode - buffer to associate with file * vp_Size - size of the buffer * * Output parameters : * ------------------- * Return * * * Used variables : * ------------------- * GLOBAL: * * * Used procedures : * ------------------- * -MC_FS_MA_SEND_CMD_MSG_TO_FS *----------------------------------------------------------------------------* *----------------------------------------------------------------------------* * DESCRIPTION * * Synchronous function interface to FSS * -Sends REQ message to FS * -Returns FS_OK or error code * *----------------------------------------------------------------------------* **************************************************************************)S*/#undef PROCEDURE_NUMBER#define PROCEDURE_NUMBER 5s32 Fs87_05Setvbuf(t_fssFILE *pp_Stream, ascii *pp_Buff, s32 vp_BuffMode, t_fss_size_t vp_Size){ s32 vl_return; s32 vl_ErrCode; u8 vl_SemName; /* Reserve message space */ t_FsCmdSetVBuff * pl_SetVBuff = (t_FsCmdSetVBuff*) MC_FS_GET_MEMORY( sizeof(t_FsCmdSetVBuff) ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_CONSUME(FSS_SEM2); /* Determine the calling process in order to determine what semaphore to consume */ vl_SemName= Fs87_30DetermineSem(); if (vl_SemName == NIL) { MC_FS_STATUS( pl_SetVBuff ) = FS_EINVAL; } else { MC_FS_STATUS( pl_SetVBuff ) = FS_OK; } /* Send message to PROCESS_FSS */ if ( MC_FS_STATUS( pl_SetVBuff ) == FS_OK ) { /* Fill message with input parameters */ pl_SetVBuff->p_Stream = pp_Stream; pl_SetVBuff->p_Buff = pp_Buff; pl_SetVBuff->v_BuffMode = vp_BuffMode; pl_SetVBuff->v_Size = vp_Size; /* Send message by setting operation and return command identifier */ MC_FS_MA_SEND_CMD_MSG_TO_FS( FS_NO_ACK, (void*)pl_SetVBuff, FS_CMD_SETVBUFF_REQ ); /* Consume Semaphore */ MC_RTK_SEM_CONSUME( vl_SemName ); } /* Set the updated err/ok code to corresponding process' global variable */ vl_ErrCode = MC_FS_STATUS( pl_SetVBuff ); Fs87_31SetErrorCode( vl_ErrCode ); /* if the operation is not successful, return an error */ if ( MC_FS_STATUS( pl_SetVBuff ) != FS_OK ) { vl_return = FS_ERROR; } else { vl_return = FS_OK; } /* Free message space */ MC_FS_FREE_MEMORY( pl_SetVBuff ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_PRODUCE(FSS_SEM2); return( vl_return );}/*S(*************************************************************************** * Semantic name : Fs87_06Ftell() * Object : Ftell Synchronous POSIX API * Finite state machine : * Event : * Transition : *----------------------------------------------------------------------------* * * Input parameters : * ------------------- * pp_Stream - file handle * * Output parameters : * ------------------- * Return * * * Used variables : * ------------------- * GLOBAL: * * * Used procedures : * ------------------- * -MC_FS_MA_SEND_CMD_MSG_TO_FS *----------------------------------------------------------------------------* *----------------------------------------------------------------------------* * DESCRIPTION * * Synchronous function interface to FSS * -Sends REQ message to FS * -Returns file position or error code * *----------------------------------------------------------------------------* **************************************************************************)S*/#undef PROCEDURE_NUMBER#define PROCEDURE_NUMBER 6s32 Fs87_06Ftell(t_fssFILE *pp_Stream){ s32 vl_return; s32 vl_ErrCode; u8 vl_SemName; /* Reserve message space */ t_FsCmdFTell * pl_FTell = (t_FsCmdFTell*) MC_FS_GET_MEMORY( sizeof(t_FsCmdFTell) ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_CONSUME(FSS_SEM2); /* Determine the calling process in order to determine what semaphore to consume */ vl_SemName= Fs87_30DetermineSem(); if (vl_SemName == NIL) { MC_FS_STATUS( pl_FTell ) = FS_EINVAL; } else { MC_FS_STATUS( pl_FTell ) = FS_OK; } /* Send message to PROCESS_FSS */ if ( MC_FS_STATUS( pl_FTell ) == FS_OK ) { /* Fill message with input parameters */ pl_FTell->p_Stream = pp_Stream; /* Send message by setting operation and return command identifier */ MC_FS_MA_SEND_CMD_MSG_TO_FS( FS_NO_ACK, (void*)pl_FTell, FS_CMD_FTELL_REQ ); /* Consume Semaphore */ MC_RTK_SEM_CONSUME( vl_SemName ); } /* Set the updated err/ok code to corresponding process' global variable */ vl_ErrCode = MC_FS_STATUS( pl_FTell ); Fs87_31SetErrorCode( vl_ErrCode ); /* if the operation is not successful, return an error */ if ( MC_FS_STATUS( pl_FTell ) != FS_OK ) { vl_return = FS_ERROR; } else { vl_return = pl_FTell->v_StreamPosition; } /* Free message space */ MC_FS_FREE_MEMORY( pl_FTell ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_PRODUCE(FSS_SEM2); return( vl_return );}/*S(*************************************************************************** * Semantic name : Fs87_07Fseek() * Object : Fseek Synchronous POSIX API * Finite state machine : * Event : * Transition : *----------------------------------------------------------------------------* * * Input parameters : * ------------------- * pp_Stream - file handle * vp_Offset - offset in the file * vp_Whence - mode of file position * * Output parameters : * ------------------- * Return * * * Used variables : * ------------------- * GLOBAL: * * * Used procedures : * ------------------- * -MC_FS_MA_SEND_CMD_MSG_TO_FS *----------------------------------------------------------------------------* *----------------------------------------------------------------------------* * DESCRIPTION * * Synchronous function interface to FSS * -Sends REQ message to FS * -Returns FS_OK or error code * *----------------------------------------------------------------------------* **************************************************************************)S*/#undef PROCEDURE_NUMBER#define PROCEDURE_NUMBER 7s32 Fs87_07Fseek(t_fssFILE *pp_Stream, t_fss_size_t vp_Offset, s32 vp_Whence){ s32 vl_return; s32 vl_ErrCode; u8 vl_SemName; /* Reserve message space */ t_FsCmdFSeek * pl_FSeek = (t_FsCmdFSeek*) MC_FS_GET_MEMORY( sizeof(t_FsCmdFSeek) ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_CONSUME(FSS_SEM2); /* Determine the calling process in order to determine what semaphore to consume */ vl_SemName= Fs87_30DetermineSem(); if (vl_SemName == NIL) { MC_FS_STATUS( pl_FSeek ) = FS_EINVAL; } else { MC_FS_STATUS( pl_FSeek ) = FS_OK; } /* Send message to PROCESS_FSS */ if ( MC_FS_STATUS( pl_FSeek ) == FS_OK ) { /* Fill message with input parameters */ pl_FSeek->p_Stream = pp_Stream; pl_FSeek->v_Offset = vp_Offset; pl_FSeek->v_Whence = vp_Whence; /* Send message by setting operation and return command identifier */ MC_FS_MA_SEND_CMD_MSG_TO_FS( FS_NO_ACK, (void*)pl_FSeek, FS_CMD_FSEEK_REQ ); /* Consume Semaphore */ MC_RTK_SEM_CONSUME( vl_SemName ); } /* Set the updated err/ok code to corresponding process' global variable */ vl_ErrCode = MC_FS_STATUS( pl_FSeek ); Fs87_31SetErrorCode( vl_ErrCode ); /* if the operation is not successful, return an error */ if ( MC_FS_STATUS( pl_FSeek ) != FS_OK ) { vl_return = FS_ERROR; } else { vl_return = FS_OK; } /* Free message space */ MC_FS_FREE_MEMORY( pl_FSeek ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_PRODUCE(FSS_SEM2); return( vl_return );}/*S(*************************************************************************** * Semantic name : Fs87_08Rewind() * Object : Rewind Synchronous POSIX API * Finite state machine : * Event : * Transition : *----------------------------------------------------------------------------* * * Input parameters : * ------------------- * pp_Stream - file handle * * Output parameters : * ------------------- * Return : None * * * Used variables : * ------------------- * GLOBAL: * * * Used procedures : * ------------------- * -MC_FS_MA_SEND_CMD_MSG_TO_FS *----------------------------------------------------------------------------* *----------------------------------------------------------------------------* * DESCRIPTION * * Synchronous function interface to FSS * -Sends REQ message to FS * -Returns FS_OK or error code *----------------------------------------------------------------------------* **************************************************************************)S*/#undef PROCEDURE_NUMBER#define PROCEDURE_NUMBER 8s32 Fs87_08Rewind(t_fssFILE *pp_Stream){ u8 vl_SemName; s32 vl_ErrCode; s32 vl_return; /* Reserve message space */ t_FsCmdRewind * pl_Rewind = (t_FsCmdRewind*) MC_FS_GET_MEMORY( sizeof(t_FsCmdRewind) ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_CONSUME(FSS_SEM2); /* Determine the calling process in order to determine what semaphore to consume */ vl_SemName= Fs87_30DetermineSem(); if (vl_SemName == NIL) { MC_FS_STATUS( pl_Rewind ) = FS_EINVAL; } else { MC_FS_STATUS( pl_Rewind ) = FS_OK; } /* Send message to PROCESS_FSS */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -