📄 fs87synchinterf.c
字号:
if ( MC_FS_STATUS( pl_Rewind ) == FS_OK ) { /* Fill message with input parameters */ pl_Rewind->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_Rewind, FS_CMD_REWIND_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_Rewind ); Fs87_31SetErrorCode( vl_ErrCode ); /* if the operation is not successful, return an error */ if ( MC_FS_STATUS( pl_Rewind ) != FS_OK ) { vl_return = FS_ERROR; } else { vl_return = FS_OK; } /* Free message space */ MC_FS_FREE_MEMORY( pl_Rewind ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_PRODUCE(FSS_SEM2); return( vl_return );} /*S(*************************************************************************** * Semantic name : Fs87_09Stat() * Object : Stat Synchronous POSIX API * Finite state machine : * Event : * Transition : *----------------------------------------------------------------------------* * * Input parameters : * ------------------- * pp_Path - file name with path * * Output parameters : * ------------------- * pp_FileInfo - file inormation * * * 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 pointer to a buffer containing information requested or * an error code * *----------------------------------------------------------------------------* **************************************************************************)S*/#undef PROCEDURE_NUMBER#define PROCEDURE_NUMBER 9s32 Fs87_09Stat(const fssPath *pp_Path, t_fss_stat *pp_FileInfo){ s32 vl_return; s32 vl_ErrCode; u8 vl_SemName; /* Reserve message space */ t_FsCmdStat * pl_Stat = (t_FsCmdStat*) MC_FS_GET_MEMORY( sizeof(t_FsCmdStat) ); /* 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_Stat ) = FS_EINVAL; } else { MC_FS_STATUS( pl_Stat ) = FS_OK; } /* Send message to PROCESS_FSS */ if ( MC_FS_STATUS( pl_Stat ) == FS_OK ) { /* Fill message with input parameters */ pl_Stat->p_Path = pp_Path; pl_Stat->p_FileInfo = pp_FileInfo; /* Send message by setting operation and return command identifier */ MC_FS_MA_SEND_CMD_MSG_TO_FS( FS_NO_ACK, (void*)pl_Stat, FS_CMD_STAT_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_Stat ); Fs87_31SetErrorCode( vl_ErrCode ); /* if the operation is not successful, return an error */ if ( MC_FS_STATUS( pl_Stat ) != FS_OK ) { vl_return = FS_ERROR; } else { vl_return = FS_OK; } /* Free message space */ MC_FS_FREE_MEMORY( pl_Stat ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_PRODUCE(FSS_SEM2); return( vl_return );} /*S(*************************************************************************** * Semantic name : Fs87_9Fflush() * Object : Fflush 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 FS_OK or an error code * *----------------------------------------------------------------------------* **************************************************************************)S*/#undef PROCEDURE_NUMBER#define PROCEDURE_NUMBER 10s32 Fs87_10Fflush(t_fssFILE *pp_Stream){ s32 vl_return; s32 vl_ErrCode; u8 vl_SemName; /* Reserve message space */ t_FsCmdFFlush * pl_FFlush = (t_FsCmdFFlush*) MC_FS_GET_MEMORY( sizeof(t_FsCmdFFlush) ); /* 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_FFlush ) = FS_EINVAL; } else { MC_FS_STATUS( pl_FFlush ) = FS_OK; } /* Send message to PROCESS_FSS */ if ( MC_FS_STATUS( pl_FFlush ) == FS_OK ) { /* Fill message with input parameters */ pl_FFlush->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_FFlush, FS_CMD_FFLUSH_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_FFlush ); Fs87_31SetErrorCode( vl_ErrCode ); /* if the operation is not successful, return an error */ if ( MC_FS_STATUS( pl_FFlush ) != FS_OK ) { vl_return = EOF; } else { vl_return = FS_OK; } /* Free message space */ MC_FS_FREE_MEMORY( pl_FFlush ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_PRODUCE(FSS_SEM2); return( vl_return );} /*S(*************************************************************************** * Semantic name : Fs87_11Feof() * Object : Feof 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 FS_OK or an error code * *----------------------------------------------------------------------------* **************************************************************************)S*/#undef PROCEDURE_NUMBER#define PROCEDURE_NUMBER 11s32 Fs87_11Feof(t_fssFILE *pp_Stream){ s32 vl_return; s32 vl_ErrCode; u8 vl_SemName; /* Reserve message space */ t_FsCmdFeof * pl_Feof = (t_FsCmdFeof*) MC_FS_GET_MEMORY( sizeof(t_FsCmdFeof) ); /* 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_Feof) = FS_EINVAL; } else { MC_FS_STATUS( pl_Feof ) = FS_OK; } /* Send message to PROCESS_FSS */ if ( MC_FS_STATUS( pl_Feof ) == FS_OK ) { /* Fill message with input parameters */ pl_Feof->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_Feof, FS_CMD_FEOF_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_Feof ); Fs87_31SetErrorCode( vl_ErrCode ); /* if the operation is not successful, return an error */ if ( MC_FS_STATUS( pl_Feof ) != FS_OK ) { vl_return = FS_ERROR; } else { vl_return = FS_OK; } /* Free message space */ MC_FS_FREE_MEMORY( pl_Feof ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_PRODUCE(FSS_SEM2); return( vl_return );} /*S(*************************************************************************** * Semantic name : Fs87_12Fwrite() * Object : Fwrite Synchronous POSIX API * Finite state machine : * Event : * Transition : *----------------------------------------------------------------------------* * * Input parameters : * ------------------- * pp_Buff - contain the data to write * vp_ElementSize - size of one element * vp_NumberOfElements - no. of elements * 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 number of elements written or an error code * *----------------------------------------------------------------------------* **************************************************************************)S*/#undef PROCEDURE_NUMBER#define PROCEDURE_NUMBER 12t_fss_size_t Fs87_12Fwrite(const void *pp_Buff, t_fss_size_t vp_ElementSize, t_fss_size_t vp_NumberOfElements, t_fssFILE *pp_Stream){ s32 vl_return; s32 vl_ErrCode; u8 vl_SemName; /* Reserve message space */ t_FsCmdFWrite * pl_FWrite = (t_FsCmdFWrite*) MC_FS_GET_MEMORY( sizeof(t_FsCmdFWrite) ); /* 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_FWrite ) = FS_EINVAL; } else { MC_FS_STATUS( pl_FWrite ) = FS_OK; } /* Send message to PROCESS_FSS */ if ( MC_FS_STATUS( pl_FWrite ) == FS_OK ) { /* Fill message with input parameters */ pl_FWrite->p_Stream = pp_Stream; pl_FWrite->p_SrceBuff = pp_Buff; pl_FWrite->v_ElementSize = vp_ElementSize; pl_FWrite->v_NumberOfElements = vp_NumberOfElements; pl_FWrite->v_NoDelayFlag = FALSE; /* Send message by setting operation and return command identifier */ MC_FS_MA_SEND_CMD_MSG_TO_FS( FS_NO_ACK, (void*)pl_FWrite, FS_CMD_FWRITE_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_FWrite ); Fs87_31SetErrorCode( vl_ErrCode ); /* if the operation is not successful, return an error otherwise the no. of bytes written */ if ( MC_FS_STATUS( pl_FWrite ) != FS_OK ) { vl_return = FS_ERROR; } else { vl_return = (s32)pl_FWrite->v_NumbOfElementsWritten; } /* Free message space */ MC_FS_FREE_MEMORY( pl_FWrite ); /* tcmc_BRC */ MC_FSS_FLASH_SEM_PRODUCE(FSS_SEM2); return( vl_return );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -