diff --git a/fsw/cfe-core/src/es/cfe_es_api.c b/fsw/cfe-core/src/es/cfe_es_api.c index cb5545ca0..54d3b24b8 100644 --- a/fsw/cfe-core/src/es/cfe_es_api.c +++ b/fsw/cfe-core/src/es/cfe_es_api.c @@ -848,7 +848,7 @@ int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) /* ** Function: CFE_ES_GetAppName - See API and header file for details */ -int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, uint32 BufferLength) +int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t BufferLength) { int32 Result; CFE_ES_AppRecord_t *AppRecPtr; @@ -890,7 +890,7 @@ int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, uint32 BufferL /* ** Function: CFE_ES_GetLibName - See API and header file for details */ -int32 CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, uint32 BufferLength) +int32 CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, size_t BufferLength) { int32 Result; CFE_ES_LibRecord_t *LibRecPtr; @@ -932,7 +932,7 @@ int32 CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, uint32 BufferL /* ** Function: CFE_ES_GetTaskName - See API and header file for details */ -int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, uint32 BufferLength) +int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, size_t BufferLength) { int32 Result; osal_id_t OsalId; @@ -1217,9 +1217,9 @@ int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, - uint32 *StackPtr, - uint32 StackSize, - uint32 Priority, + CFE_ES_StackPointer_t StackPtr, + size_t StackSize, + CFE_ES_TaskPriority_Atom_t Priority, uint32 Flags) { @@ -1283,14 +1283,6 @@ int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, ParentTaskId = AppRecPtr->MainTaskId; if ( CFE_ES_ResourceID_Equal(TaskId, ParentTaskId) ) { - /* - ** Truncate the priority if needed - */ - if ( Priority > 255 ) - { - Priority = 255; - } - /* ** Step 2: Create the new task using the OS API call */ @@ -1614,7 +1606,7 @@ int32 CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) /* ** Function: CFE_ES_CalculateCRC - See API and header file for details */ -uint32 CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputCRC, uint32 TypeCRC) +uint32 CFE_ES_CalculateCRC(const void *DataPtr, size_t DataLength, uint32 InputCRC, uint32 TypeCRC) { uint32 i; int16 Index; @@ -1701,7 +1693,7 @@ uint32 CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputC ** Purpose: Allocate a data block for a Critical Data Store. ** */ -int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, CFE_ES_CDS_Offset_t BlockSize, const char *Name) +int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, size_t BlockSize, const char *Name) { int32 Status; size_t NameLen; @@ -1763,7 +1755,7 @@ int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, CFE_ES_CDS_Offset_t B if (Status < 0) { /* Translate AppID of caller into App Name */ - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); CFE_EVS_SendEventWithAppID(CFE_ES_CDS_REGISTER_ERR_EID, CFE_EVS_EventType_ERROR, @@ -1821,7 +1813,7 @@ CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_ResourceID_t *BlockIdPtr, const c * Purpose: Obtain CDS Block Name from ID * See full API description in header file */ -CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_ResourceID_t BlockId, uint32 BufferLength) +CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_ResourceID_t BlockId, size_t BufferLength) { CFE_Status_t Status; CFE_ES_CDS_RegRec_t *RegRecPtr; @@ -2072,7 +2064,7 @@ int32 CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char * Purpose: Obtain Counter Name from ID * See full API description in header file */ -CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_ResourceID_t CounterId, uint32 BufferLength) +CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_ResourceID_t CounterId, size_t BufferLength) { CFE_ES_GenCounterRecord_t *CountRecPtr; CFE_Status_t Status; @@ -2137,6 +2129,7 @@ int32 CFE_ES_LibID_ToIndex(CFE_ES_ResourceID_t LibId, uint32 *Idx) int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx) { osal_id_t OsalID; + osal_index_t OsalIndex; if (!CFE_ES_ResourceID_IsDefined(TaskID)) { @@ -2144,11 +2137,13 @@ int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx) } OsalID = CFE_ES_ResourceID_ToOSAL(TaskID); - if (OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, OsalID, Idx) != OS_SUCCESS) + if (OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, OsalID, &OsalIndex) != OS_SUCCESS) { return CFE_ES_ERR_RESOURCEID_NOT_VALID; } + *Idx = OsalIndex; + return CFE_SUCCESS; } diff --git a/fsw/cfe-core/src/es/cfe_es_apps.c b/fsw/cfe-core/src/es/cfe_es_apps.c index d0b1bbb0d..eeaa5350e 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.c +++ b/fsw/cfe-core/src/es/cfe_es_apps.c @@ -267,9 +267,9 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) const char *AppName; const char *EntryPoint; const char *EntryType; - unsigned int Priority; - unsigned int StackSize; - unsigned int ExceptionAction; + unsigned long PriorityIn; + unsigned long StackSizeIn; + unsigned long ExceptionActionIn; CFE_ES_ResourceID_t ApplicationId; int32 CreateStatus = CFE_ES_ERR_APP_CREATE; @@ -298,10 +298,13 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) * * This permissive parsing should not be relied upon, as it may become more strict again in * future CFE revisions. + * + * Also note that this uses "unsigned long" as that is the defined output type of strtoul(). + * It will be converted to the correct type later. */ - Priority = strtoul(TokenList[4], NULL, 0); - StackSize = strtoul(TokenList[5], NULL, 0); - ExceptionAction = strtoul(TokenList[7], NULL, 0); + PriorityIn = strtoul(TokenList[4], NULL, 0); + StackSizeIn = strtoul(TokenList[5], NULL, 0); + ExceptionActionIn = strtoul(TokenList[7], NULL, 0); if(strcmp(EntryType,"CFE_APP")==0) { @@ -314,14 +317,27 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) ** 1 ( Processor reset ). If it's non-zero, assume it means ** reset CPU. */ - if ( ExceptionAction > CFE_ES_ExceptionAction_RESTART_APP ) - ExceptionAction = CFE_ES_ExceptionAction_PROC_RESTART; + if ( ExceptionActionIn > CFE_ES_ExceptionAction_RESTART_APP ) + { + ExceptionActionIn = CFE_ES_ExceptionAction_PROC_RESTART; + } + + /* + * Task priority cannot be bigger than OS_MAX_TASK_PRIORITY + */ + if ( PriorityIn > OS_MAX_TASK_PRIORITY ) + { + PriorityIn = OS_MAX_TASK_PRIORITY; + } + /* ** Now create the application */ CreateStatus = CFE_ES_AppCreate(&ApplicationId, FileName, - EntryPoint, AppName, (uint32) Priority, - (uint32) StackSize, (uint32) ExceptionAction ); + EntryPoint, AppName, + PriorityIn, + StackSizeIn, + ExceptionActionIn); } else if(strcmp(EntryType,"CFE_LIB")==0) { @@ -522,7 +538,7 @@ int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_Res StatusCode = OS_TaskCreate(&OsalTaskId, /* task id */ StartParams->BasicInfo.Name, /* task name */ CFE_ES_AppEntryPoint, /* task function pointer */ - NULL, /* stack pointer (allocate) */ + OSAL_TASK_STACK_ALLOCATE, /* stack pointer (allocate) */ StartParams->StackSize, /* stack size */ StartParams->Priority, /* task priority */ OS_FP_ENABLED); /* task options */ @@ -589,9 +605,9 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, const char *FileName, const char *EntryPointName, const char *AppName, - uint32 Priority, - uint32 StackSize, - uint32 ExceptionAction) + CFE_ES_TaskPriority_Atom_t Priority, + size_t StackSize, + CFE_ES_ExceptionAction_Enum_t ExceptionAction) { CFE_Status_t Status; CFE_ES_ResourceID_t MainTaskId; @@ -1556,7 +1572,7 @@ void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg) { CFE_ES_CleanupState_t *CleanState; int32 Status; - uint32 ObjType; + osal_objtype_t ObjType; bool ObjIsValid; CleanState = (CFE_ES_CleanupState_t *)arg; @@ -1750,7 +1766,7 @@ void CFE_ES_CopyModuleBasicInfo(const CFE_ES_ModuleLoadParams_t *ParamsPtr, CFE_ void CFE_ES_CopyModuleStatusInfo(const CFE_ES_ModuleLoadStatus_t *StatusPtr, CFE_ES_AppInfo_t *AppInfoPtr) { AppInfoPtr->ModuleId = StatusPtr->ModuleId; - CFE_SB_SET_MEMADDR(AppInfoPtr->StartAddress, StatusPtr->EntryAddress); + AppInfoPtr->StartAddress = CFE_ES_MEMADDRESS_C(StatusPtr->EntryAddress); } /* @@ -1781,12 +1797,16 @@ void CFE_ES_CopyModuleAddressInfo(osal_id_t ModuleId, CFE_ES_AppInfo_t *AppInfoP memset(&ModuleInfo, 0, sizeof(ModuleInfo)); } - CFE_SB_SET_MEMADDR(AppInfoPtr->CodeAddress, ModuleInfo.addr.code_address); - CFE_SB_SET_MEMADDR(AppInfoPtr->CodeSize, ModuleInfo.addr.code_size); - CFE_SB_SET_MEMADDR(AppInfoPtr->DataAddress, ModuleInfo.addr.data_address); - CFE_SB_SET_MEMADDR(AppInfoPtr->DataSize, ModuleInfo.addr.data_size); - CFE_SB_SET_MEMADDR(AppInfoPtr->BSSAddress, ModuleInfo.addr.bss_address); - CFE_SB_SET_MEMADDR(AppInfoPtr->BSSSize, ModuleInfo.addr.bss_size); + /* + * Convert the internal size and address to the telemetry format. + * (The telemetry format may be a different bitwidth than the native processor) + */ + AppInfoPtr->CodeAddress = CFE_ES_MEMADDRESS_C(ModuleInfo.addr.code_address); + AppInfoPtr->CodeSize = CFE_ES_MEMOFFSET_C(ModuleInfo.addr.code_size); + AppInfoPtr->DataAddress = CFE_ES_MEMADDRESS_C(ModuleInfo.addr.data_address); + AppInfoPtr->DataSize = CFE_ES_MEMOFFSET_C(ModuleInfo.addr.data_size); + AppInfoPtr->BSSAddress = CFE_ES_MEMADDRESS_C(ModuleInfo.addr.bss_address); + AppInfoPtr->BSSSize = CFE_ES_MEMOFFSET_C(ModuleInfo.addr.bss_size); } diff --git a/fsw/cfe-core/src/es/cfe_es_apps.h b/fsw/cfe-core/src/es/cfe_es_apps.h index e9aaa7562..3be90f7cd 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.h +++ b/fsw/cfe-core/src/es/cfe_es_apps.h @@ -117,8 +117,8 @@ typedef struct /* * Extra information the pertains to applications only, not libraries. */ - cpusize StackSize; - uint16 Priority; + size_t StackSize; + CFE_ES_TaskPriority_Atom_t Priority; CFE_ES_ExceptionAction_Enum_t ExceptionAction; } CFE_ES_AppStartParams_t; @@ -227,9 +227,9 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, const char *FileName, const char *EntryPointName, const char *AppName, - uint32 Priority, - uint32 StackSize, - uint32 ExceptionAction); + CFE_ES_TaskPriority_Atom_t Priority, + size_t StackSize, + CFE_ES_ExceptionAction_Enum_t ExceptionAction); /* ** Internal function to load a a new cFE shared Library */ diff --git a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c b/fsw/cfe-core/src/es/cfe_es_backgroundtask.c index 0f111a810..28653956c 100644 --- a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c +++ b/fsw/cfe-core/src/es/cfe_es_backgroundtask.c @@ -43,7 +43,7 @@ #define CFE_ES_BACKGROUND_SEM_NAME "ES_BG_SEM" #define CFE_ES_BACKGROUND_CHILD_NAME "ES_BG_TASK" -#define CFE_ES_BACKGROUND_CHILD_STACK_PTR NULL +#define CFE_ES_BACKGROUND_CHILD_STACK_PTR CFE_ES_TASK_STACK_ALLOCATE #define CFE_ES_BACKGROUND_CHILD_STACK_SIZE CFE_PLATFORM_ES_PERF_CHILD_STACK_SIZE #define CFE_ES_BACKGROUND_CHILD_PRIORITY CFE_PLATFORM_ES_PERF_CHILD_PRIORITY #define CFE_ES_BACKGROUND_CHILD_FLAGS 0 diff --git a/fsw/cfe-core/src/es/cfe_es_cds.c b/fsw/cfe-core/src/es/cfe_es_cds.c index be9efc862..6d1485f81 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds.c +++ b/fsw/cfe-core/src/es/cfe_es_cds.c @@ -61,7 +61,8 @@ int32 CFE_ES_CDS_EarlyInit(void) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; - CFE_ES_CDS_Offset_t MinRequiredSize; + uint32 PlatformSize; + size_t MinRequiredSize; int32 Status; CFE_ES_Global.CDSIsAvailable = false; @@ -77,8 +78,9 @@ int32 CFE_ES_CDS_EarlyInit(void) CDS->LastCDSBlockId = CFE_ES_ResourceID_FromInteger(CFE_ES_CDSBLOCKID_BASE); - /* Get CDS size from OS BSP */ - Status = CFE_PSP_GetCDSSize(&CDS->TotalSize); + /* Get CDS size from PSP. Note that the PSP interface + * uses "uint32" for size here. */ + Status = CFE_PSP_GetCDSSize(&PlatformSize); if (Status != CFE_PSP_SUCCESS) { /* Error getting the size of the CDS from the BSP */ @@ -87,7 +89,7 @@ int32 CFE_ES_CDS_EarlyInit(void) } /* Always truncate the size to the nearest 4 byte boundary */ - CDS->TotalSize &= 0xfffffffc; + CDS->TotalSize = PlatformSize & 0xfffffffc; /* Compute the minimum size required for the CDS with the current configuration of the cFE */ MinRequiredSize = CDS_RESERVED_MIN_SIZE; @@ -200,8 +202,7 @@ CFE_ES_CDS_RegRec_t* CFE_ES_LocateCDSBlockRecordByID(CFE_ES_ResourceID_t BlockID * NOTE: For complete prolog information, see 'cfe_es_cds.h' */ /*******************************************************************/ -int32 CFE_ES_CDS_CacheFetch(CFE_ES_CDS_AccessCache_t *Cache, - CFE_ES_CDS_Offset_t Offset, CFE_ES_CDS_Offset_t Size) +int32 CFE_ES_CDS_CacheFetch(CFE_ES_CDS_AccessCache_t *Cache, size_t Offset, size_t Size) { int32 Status; @@ -269,7 +270,7 @@ int32 CFE_ES_CDS_CacheFlush(CFE_ES_CDS_AccessCache_t *Cache) * NOTE: For complete prolog information, see 'cfe_es_cds.h' */ /*******************************************************************/ -int32 CFE_ES_CDS_CachePreload(CFE_ES_CDS_AccessCache_t *Cache, const void *Source, CFE_ES_CDS_Offset_t Offset, CFE_ES_CDS_Offset_t Size) +int32 CFE_ES_CDS_CachePreload(CFE_ES_CDS_AccessCache_t *Cache, const void *Source, size_t Offset, size_t Size) { int32 Status; @@ -305,15 +306,15 @@ int32 CFE_ES_CDS_CachePreload(CFE_ES_CDS_AccessCache_t *Cache, const void *Sourc ** NOTE: For complete prolog information, see 'cfe_es_cds.h' ********************************************************************/ -int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, CFE_ES_CDS_Offset_t UserBlockSize, const char *Name, bool CriticalTbl) +int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, const char *Name, bool CriticalTbl) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; int32 Status; int32 RegUpdateStatus; CFE_ES_CDS_RegRec_t *RegRecPtr; - CFE_ES_MemOffset_t BlockOffset; - CFE_ES_MemOffset_t OldBlockSize; - CFE_ES_MemOffset_t NewBlockSize; + size_t BlockOffset; + size_t OldBlockSize; + size_t NewBlockSize; CFE_ES_ResourceID_t PendingBlockId; bool IsNewEntry; bool IsNewOffset; @@ -469,8 +470,8 @@ int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, CFE_ES_CDS_Offset_t Us int32 CFE_ES_ValidateCDS(void) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; - CFE_ES_CDS_Offset_t TrailerOffset; - const CFE_ES_CDS_Offset_t SIG_CDS_SIZE = { CFE_ES_CDS_SIGNATURE_LEN }; + size_t TrailerOffset; + const size_t SIG_CDS_SIZE = { CFE_ES_CDS_SIGNATURE_LEN }; int32 Status; /* Perform 2 checks to validate the CDS Memory Pool */ @@ -519,7 +520,7 @@ int32 CFE_ES_ValidateCDS(void) int32 CFE_ES_ClearCDS(void) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; - CFE_ES_CDS_Offset_t RemainSize; + size_t RemainSize; int32 Status; /* Clear the CDS to ensure everything is gone */ @@ -564,7 +565,7 @@ int32 CFE_ES_ClearCDS(void) int32 CFE_ES_InitCDSSignatures(void) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; - CFE_ES_CDS_Offset_t SigOffset; + size_t SigOffset; int32 Status; /* Initialize the Validity Check strings */ @@ -668,7 +669,7 @@ void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_ResourceI { char AppName[OS_MAX_API_NAME]; - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); /* Ensure that AppName is null terminated */ AppName[OS_MAX_API_NAME-1] = '\0'; @@ -844,7 +845,7 @@ int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices) CFE_ES_ResourceID_t AppId; uint32 i; char LogMessage[CFE_ES_MAX_SYSLOG_MSG_SIZE]; - CFE_ES_MemOffset_t OldBlockSize; + size_t OldBlockSize; LogMessage[0] = 0; diff --git a/fsw/cfe-core/src/es/cfe_es_cds.h b/fsw/cfe-core/src/es/cfe_es_cds.h index 2f3ac1a63..5b6ff3132 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds.h +++ b/fsw/cfe-core/src/es/cfe_es_cds.h @@ -89,9 +89,12 @@ /* * Absolute Maximum Block size conceivably supportable by the implementation. * User-defined platform limits (in cfe_platform_cfg.h) may be lower, - * but this is a hard limit to avoid overflow of CFE_ES_CDS_Offset_t. + * but this is a hard limit to avoid overflow of a 32 bit integer. + * + * This ensures the size is safe for a PSP that uses 32 bit CDS offsets. + * (It is not anticipated that a CDS would need to exceed this size) */ -#define CDS_ABS_MAX_BLOCK_SIZE ((1 << ((8 * sizeof(CFE_ES_CDS_Offset_t))-2)) - sizeof(CFE_ES_CDS_BlockHeader_t)) +#define CDS_ABS_MAX_BLOCK_SIZE ((size_t)(1 << 30) - sizeof(CFE_ES_CDS_BlockHeader_t)) @@ -113,8 +116,8 @@ typedef struct * less than this. */ CFE_ES_ResourceID_t BlockID; /**< Abstract ID associated with this CDS block */ - CFE_ES_CDS_Offset_t BlockOffset; /**< Start offset of the block in CDS memory */ - CFE_ES_CDS_Offset_t BlockSize; /**< Size, in bytes, of the CDS memory block */ + size_t BlockOffset; /**< Start offset of the block in CDS memory */ + size_t BlockSize; /**< Size, in bytes, of the CDS memory block */ char Name[CFE_MISSION_ES_CDS_MAX_FULL_NAME_LEN]; bool Table; /**< \brief Flag that indicates whether CDS contains a Critical Table */ } CFE_ES_CDS_RegRec_t; @@ -140,10 +143,10 @@ typedef union CFE_ES_CDS_AccessCacheData typedef struct CFE_ES_CDS_AccessCache { - CFE_ES_CDS_AccessCacheData_t Data; /**< Cached data (varies in size) */ - CFE_ES_CDS_Offset_t Offset; /**< The offset where Data is cached from */ - CFE_ES_CDS_Offset_t Size; /**< The size of cached Data */ - int32 AccessStatus; /**< The PSP status of the last read/write from CDS memory */ + CFE_ES_CDS_AccessCacheData_t Data; /**< Cached data (varies in size) */ + size_t Offset; /**< The offset where Data is cached from */ + size_t Size; /**< The size of cached Data */ + int32 AccessStatus; /**< The PSP status of the last read/write from CDS memory */ } CFE_ES_CDS_AccessCache_t; /** @@ -168,8 +171,8 @@ typedef struct CFE_ES_CDS_AccessCache_t Cache; osal_id_t GenMutex; /**< \brief Mutex that controls access to CDS and registry */ - CFE_ES_CDS_Offset_t TotalSize; /**< \brief Total size of the CDS as reported by BSP */ - CFE_ES_CDS_Offset_t DataSize; /**< \brief Size of actual user data pool */ + size_t TotalSize; /**< \brief Total size of the CDS as reported by BSP */ + size_t DataSize; /**< \brief Size of actual user data pool */ CFE_ES_ResourceID_t LastCDSBlockId; /**< \brief Last issued CDS block ID */ CFE_ES_CDS_RegRec_t Registry[CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES]; /**< \brief CDS Registry (Local Copy) */ } CFE_ES_CDS_Instance_t; @@ -221,7 +224,7 @@ typedef struct CFE_ES_CDS_PersistentTrailer * @returns #CFE_SUCCESS on success, or appropriate error code. */ int32 CFE_ES_CDS_CacheFetch(CFE_ES_CDS_AccessCache_t *Cache, - CFE_ES_CDS_Offset_t Offset, CFE_ES_CDS_Offset_t Size); + size_t Offset, size_t Size); /** @@ -264,7 +267,7 @@ int32 CFE_ES_CDS_CacheFlush(CFE_ES_CDS_AccessCache_t *Cache); * @returns #CFE_SUCCESS on success, or appropriate error code. */ int32 CFE_ES_CDS_CachePreload(CFE_ES_CDS_AccessCache_t *Cache, const void *Source, - CFE_ES_CDS_Offset_t Offset, CFE_ES_CDS_Offset_t Size); + size_t Offset, size_t Size); /** * @brief Get the registry array index correlating with a CDS block ID @@ -383,7 +386,7 @@ static inline bool CFE_ES_CDSBlockRecordIsMatch(const CFE_ES_CDS_RegRec_t *CDSBl * @param[in] CDSBlockRecPtr pointer to registry table entry * @returns Usable size of the CDS */ -static inline CFE_ES_MemOffset_t CFE_ES_CDSBlockRecordGetUserSize(const CFE_ES_CDS_RegRec_t *CDSBlockRecPtr) +static inline size_t CFE_ES_CDSBlockRecordGetUserSize(const CFE_ES_CDS_RegRec_t *CDSBlockRecPtr) { return (CDSBlockRecPtr->BlockSize - sizeof(CFE_ES_CDS_BlockHeader_t)); } diff --git a/fsw/cfe-core/src/es/cfe_es_cds_mempool.c b/fsw/cfe-core/src/es/cfe_es_cds_mempool.c index 53b9bf51c..a3acfc3a9 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds_mempool.c +++ b/fsw/cfe-core/src/es/cfe_es_cds_mempool.c @@ -58,7 +58,7 @@ -const CFE_ES_MemOffset_t CFE_ES_CDSMemPoolDefSize[CFE_ES_CDS_NUM_BLOCK_SIZES] = +const size_t CFE_ES_CDSMemPoolDefSize[CFE_ES_CDS_NUM_BLOCK_SIZES] = { CFE_PLATFORM_ES_CDS_MAX_BLOCK_SIZE, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_16, @@ -90,19 +90,14 @@ const CFE_ES_MemOffset_t CFE_ES_CDSMemPoolDefSize[CFE_ES_CDS_NUM_BLOCK_SIZES] = ** This is a bridge between the generic pool implementation and the CDS cache. */ int32 CFE_ES_CDS_PoolRetrieve(CFE_ES_GenPoolRecord_t *GenPoolRecPtr, - CFE_ES_MemOffset_t Offset, + size_t Offset, CFE_ES_GenPoolBD_t **BdPtr) { CFE_ES_CDS_Instance_t *CDS = (CFE_ES_CDS_Instance_t *)GenPoolRecPtr; - CFE_ES_CDS_Offset_t CDSOffset; - CFE_ES_CDS_Offset_t CDSSize; - /* Type conversions */ - CDSOffset = Offset; - CDSSize = sizeof(CFE_ES_GenPoolBD_t); *BdPtr = &CDS->Cache.Data.Desc; - return CFE_ES_CDS_CacheFetch(&CDS->Cache, CDSOffset, CDSSize); + return CFE_ES_CDS_CacheFetch(&CDS->Cache, Offset, sizeof(CFE_ES_GenPoolBD_t)); } /* @@ -111,13 +106,12 @@ int32 CFE_ES_CDS_PoolRetrieve(CFE_ES_GenPoolRecord_t *GenPoolRecPtr, ** This is a bridge between the generic pool implementation and the CDS cache. */ int32 CFE_ES_CDS_PoolCommit(CFE_ES_GenPoolRecord_t *GenPoolRecPtr, - CFE_ES_MemOffset_t Offset, + size_t Offset, const CFE_ES_GenPoolBD_t *BdPtr) { CFE_ES_CDS_Instance_t *CDS = (CFE_ES_CDS_Instance_t *)GenPoolRecPtr; - CFE_ES_CDS_CachePreload(&CDS->Cache, BdPtr, Offset, - sizeof(CFE_ES_GenPoolBD_t)); + CFE_ES_CDS_CachePreload(&CDS->Cache, BdPtr, Offset, sizeof(CFE_ES_GenPoolBD_t)); return CFE_ES_CDS_CacheFlush(&CDS->Cache); } @@ -131,12 +125,12 @@ int32 CFE_ES_CDS_PoolCommit(CFE_ES_GenPoolRecord_t *GenPoolRecPtr, ** where it is not possible to have contention writing into the syslog. ** Therefore the use of CFE_ES_SysLogWrite_Unsync() is acceptable */ -int32 CFE_ES_CreateCDSPool(CFE_ES_CDS_Offset_t CDSPoolSize, CFE_ES_CDS_Offset_t StartOffset) +int32 CFE_ES_CreateCDSPool(size_t CDSPoolSize, size_t StartOffset) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; int32 Status; - CFE_ES_MemOffset_t SizeCheck; - CFE_ES_MemOffset_t ActualSize; + size_t SizeCheck; + size_t ActualSize; SizeCheck = CFE_ES_GenPoolCalcMinSize(CFE_ES_CDS_NUM_BLOCK_SIZES, CFE_ES_CDSMemPoolDefSize, 1); ActualSize = CDSPoolSize; @@ -173,7 +167,7 @@ int32 CFE_ES_CreateCDSPool(CFE_ES_CDS_Offset_t CDSPoolSize, CFE_ES_CDS_Offset_t ** where it is not possible to have contention writing into the syslog. ** Therefore the use of CFE_ES_SysLogWrite_Unsync() is acceptable */ -int32 CFE_ES_RebuildCDSPool(CFE_ES_CDS_Offset_t CDSPoolSize, CFE_ES_CDS_Offset_t StartOffset) +int32 CFE_ES_RebuildCDSPool(size_t CDSPoolSize, size_t StartOffset) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; int32 Status; @@ -212,9 +206,9 @@ int32 CFE_ES_CDSBlockWrite(CFE_ES_CDSHandle_t Handle, const void *DataToWrite) CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; char LogMessage[CFE_ES_MAX_SYSLOG_MSG_SIZE]; int32 Status; - CFE_ES_MemOffset_t BlockSize; - CFE_ES_CDS_Offset_t UserDataSize; - CFE_ES_CDS_Offset_t UserDataOffset; + size_t BlockSize; + size_t UserDataSize; + size_t UserDataOffset; CFE_ES_CDS_RegRec_t *CDSRegRecPtr; /* Ensure the the log message is an empty string in case it is never written to */ @@ -311,9 +305,9 @@ int32 CFE_ES_CDSBlockRead(void *DataRead, CFE_ES_CDSHandle_t Handle) char LogMessage[CFE_ES_MAX_SYSLOG_MSG_SIZE]; int32 Status; uint32 CrcOfCDSData; - CFE_ES_MemOffset_t BlockSize; - CFE_ES_CDS_Offset_t UserDataSize; - CFE_ES_CDS_Offset_t UserDataOffset; + size_t BlockSize; + size_t UserDataSize; + size_t UserDataOffset; CFE_ES_CDS_RegRec_t *CDSRegRecPtr; /* Validate the handle before doing anything */ @@ -352,7 +346,7 @@ int32 CFE_ES_CDSBlockRead(void *DataRead, CFE_ES_CDSHandle_t Handle) /* Read the header */ Status = CFE_ES_CDS_CacheFetch(&CDS->Cache, CDSRegRecPtr->BlockOffset, - (CFE_ES_CDS_Offset_t){sizeof(CFE_ES_CDS_BlockHeader_t)} ); + sizeof(CFE_ES_CDS_BlockHeader_t)); if (Status == CFE_SUCCESS) { @@ -400,10 +394,14 @@ int32 CFE_ES_CDSBlockRead(void *DataRead, CFE_ES_CDSHandle_t Handle) ** Purpose: ** */ -uint32 CFE_ES_CDSReqdMinSize(uint32 MaxNumBlocksToSupport) +size_t CFE_ES_CDSReqdMinSize(uint32 MaxNumBlocksToSupport) { - return CFE_ES_GenPoolCalcMinSize(CFE_ES_CDS_NUM_BLOCK_SIZES, + size_t ReqSize; + + ReqSize = CFE_ES_GenPoolCalcMinSize(CFE_ES_CDS_NUM_BLOCK_SIZES, CFE_ES_CDSMemPoolDefSize, MaxNumBlocksToSupport); + + return ReqSize; } diff --git a/fsw/cfe-core/src/es/cfe_es_cds_mempool.h b/fsw/cfe-core/src/es/cfe_es_cds_mempool.h index cbe0bcb11..abacf5a7e 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds_mempool.h +++ b/fsw/cfe-core/src/es/cfe_es_cds_mempool.h @@ -69,15 +69,14 @@ ** \return #CFE_SUCCESS \copydoc CFE_SUCCESS ** ******************************************************************************/ -int32 CFE_ES_CreateCDSPool(CFE_ES_CDS_Offset_t CDSPoolSize, CFE_ES_CDS_Offset_t StartOffset); +int32 CFE_ES_CreateCDSPool(size_t CDSPoolSize, size_t StartOffset); - -int32 CFE_ES_RebuildCDSPool(CFE_ES_CDS_Offset_t CDSPoolSize, CFE_ES_CDS_Offset_t StartOffset); +int32 CFE_ES_RebuildCDSPool(size_t CDSPoolSize, size_t StartOffset); int32 CFE_ES_CDSBlockWrite(CFE_ES_CDSHandle_t Handle, const void *DataToWrite); int32 CFE_ES_CDSBlockRead(void *DataRead, CFE_ES_CDSHandle_t Handle); -uint32 CFE_ES_CDSReqdMinSize(uint32 MaxNumBlocksToSupport); +size_t CFE_ES_CDSReqdMinSize(uint32 MaxNumBlocksToSupport); #endif /* _cfe_es_cds_mempool_ */ diff --git a/fsw/cfe-core/src/es/cfe_es_generic_pool.c b/fsw/cfe-core/src/es/cfe_es_generic_pool.c index cbf451cbf..d8b76bcb1 100644 --- a/fsw/cfe-core/src/es/cfe_es_generic_pool.c +++ b/fsw/cfe-core/src/es/cfe_es_generic_pool.c @@ -60,7 +60,7 @@ ** Local Helper function to find the appropriate bucket given a requested block size **--------------------------------------------------------------------------------------- */ -uint16 CFE_ES_GenPoolFindBucket(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_MemOffset_t ReqSize) +uint16 CFE_ES_GenPoolFindBucket(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t ReqSize) { uint16 Index; @@ -110,12 +110,12 @@ CFE_ES_GenPoolBucket_t *CFE_ES_GenPoolGetBucketState(CFE_ES_GenPoolRecord_t *Poo **--------------------------------------------------------------------------------------- */ int32 CFE_ES_GenPoolRecyclePoolBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, uint16 BucketId, - CFE_ES_MemOffset_t NewSize, CFE_ES_MemOffset_t *BlockOffsetPtr) + size_t NewSize, size_t *BlockOffsetPtr) { CFE_ES_GenPoolBucket_t *BucketPtr; - CFE_ES_MemOffset_t DescOffset; - CFE_ES_MemOffset_t BlockOffset; - CFE_ES_MemOffset_t NextOffset; + size_t DescOffset; + size_t BlockOffset; + size_t NextOffset; CFE_ES_GenPoolBD_t *BdPtr; uint16 RecycleBucketId; int32 Status; @@ -174,12 +174,12 @@ int32 CFE_ES_GenPoolRecyclePoolBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, uint16 **--------------------------------------------------------------------------------------- */ int32 CFE_ES_GenPoolCreatePoolBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, uint16 BucketId, - CFE_ES_MemOffset_t NewSize, CFE_ES_MemOffset_t *BlockOffsetPtr) + size_t NewSize, size_t *BlockOffsetPtr) { CFE_ES_GenPoolBucket_t *BucketPtr; - CFE_ES_MemOffset_t DescOffset; - CFE_ES_MemOffset_t BlockOffset; - CFE_ES_MemOffset_t NextTailPosition; + size_t DescOffset; + size_t BlockOffset; + size_t NextTailPosition; CFE_ES_GenPoolBD_t *BdPtr; int32 Status; @@ -253,11 +253,11 @@ int32 CFE_ES_GenPoolCreatePoolBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, uint16 B */ int32 CFE_ES_GenPoolInitialize( CFE_ES_GenPoolRecord_t *PoolRecPtr, - CFE_ES_MemOffset_t StartOffset, - CFE_ES_MemOffset_t PoolSize, - CFE_ES_MemOffset_t AlignSize, + size_t StartOffset, + size_t PoolSize, + size_t AlignSize, uint16 NumBlockSizes, - const CFE_ES_MemOffset_t *BlockSizeList, + const size_t *BlockSizeList, CFE_ES_PoolRetrieve_Func_t RetrieveFunc, CFE_ES_PoolCommit_Func_t CommitFunc) { @@ -350,12 +350,12 @@ int32 CFE_ES_GenPoolInitialize( ** ES Internal API - See Prototype for full API description **--------------------------------------------------------------------------------------- */ -CFE_ES_MemOffset_t CFE_ES_GenPoolCalcMinSize(uint16 NumBlockSizes, - const CFE_ES_MemOffset_t *BlockSizeList, +size_t CFE_ES_GenPoolCalcMinSize(uint16 NumBlockSizes, + const size_t *BlockSizeList, uint32 NumBlocks) { uint16 BucketId; - CFE_ES_MemOffset_t MinBlockSize; + size_t MinBlockSize; MinBlockSize = 0; @@ -386,8 +386,8 @@ CFE_ES_MemOffset_t CFE_ES_GenPoolCalcMinSize(uint16 NumBlockSizes, **--------------------------------------------------------------------------------------- */ int32 CFE_ES_GenPoolGetBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, - CFE_ES_MemOffset_t *BlockOffsetPtr, - CFE_ES_MemOffset_t ReqSize ) + size_t *BlockOffsetPtr, + size_t ReqSize ) { int32 Status; uint16 BucketId; @@ -421,10 +421,10 @@ int32 CFE_ES_GenPoolGetBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, **--------------------------------------------------------------------------------------- */ int32 CFE_ES_GenPoolGetBlockSize(CFE_ES_GenPoolRecord_t *PoolRecPtr, - CFE_ES_MemOffset_t *BlockSizePtr, - CFE_ES_MemOffset_t BlockOffset) + size_t *BlockSizePtr, + size_t BlockOffset) { - CFE_ES_MemOffset_t DescOffset; + size_t DescOffset; CFE_ES_GenPoolBucket_t *BucketPtr; CFE_ES_GenPoolBD_t *BdPtr; int32 Status; @@ -470,10 +470,10 @@ int32 CFE_ES_GenPoolGetBlockSize(CFE_ES_GenPoolRecord_t *PoolRecPtr, **--------------------------------------------------------------------------------------- */ int32 CFE_ES_GenPoolPutBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, - CFE_ES_MemOffset_t *BlockSizePtr, - CFE_ES_MemOffset_t BlockOffset) + size_t *BlockSizePtr, + size_t BlockOffset) { - CFE_ES_MemOffset_t DescOffset; + size_t DescOffset; CFE_ES_GenPoolBucket_t *BucketPtr; CFE_ES_GenPoolBD_t *BdPtr; int32 Status; @@ -530,8 +530,8 @@ int32 CFE_ES_GenPoolPutBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, int32 CFE_ES_GenPoolRebuild(CFE_ES_GenPoolRecord_t *PoolRecPtr) { int32 Status; - CFE_ES_MemOffset_t DescOffset; - CFE_ES_MemOffset_t BlockOffset; + size_t DescOffset; + size_t BlockOffset; CFE_ES_GenPoolBucket_t *BucketPtr; CFE_ES_GenPoolBD_t *BdPtr; uint16 BucketId; @@ -660,11 +660,11 @@ void CFE_ES_GenPoolGetUsage(CFE_ES_GenPoolRecord_t *PoolRecPtr, { if (TotalSizeBuf != NULL) { - *TotalSizeBuf = PoolRecPtr->PoolTotalSize; + *TotalSizeBuf = CFE_ES_MEMOFFSET_C(PoolRecPtr->PoolTotalSize); } if (FreeSizeBuf != NULL) { - *FreeSizeBuf = PoolRecPtr->PoolMaxOffset - PoolRecPtr->TailPosition; + *FreeSizeBuf = CFE_ES_MEMOFFSET_C(PoolRecPtr->PoolMaxOffset - PoolRecPtr->TailPosition); } } @@ -718,7 +718,7 @@ void CFE_ES_GenPoolGetBucketUsage(CFE_ES_GenPoolRecord_t *PoolRecPtr, uint16 Buc if (BlockStatsBuf != NULL) { BlockStatsBuf->NumCreated = BucketPtr->AllocationCount; - BlockStatsBuf->BlockSize = BucketPtr->BlockSize; + BlockStatsBuf->BlockSize = CFE_ES_MEMOFFSET_C(BucketPtr->BlockSize); BlockStatsBuf->NumFree = BucketPtr->ReleaseCount - BucketPtr->RecycleCount; } } diff --git a/fsw/cfe-core/src/es/cfe_es_generic_pool.h b/fsw/cfe-core/src/es/cfe_es_generic_pool.h index 6439f686c..2796ed1eb 100644 --- a/fsw/cfe-core/src/es/cfe_es_generic_pool.h +++ b/fsw/cfe-core/src/es/cfe_es_generic_pool.h @@ -62,15 +62,15 @@ typedef struct CFE_ES_GenPoolBD { uint16 CheckBits; /**< Set to a fixed bit pattern after init */ uint16 Allocated; /**< Set to a bit pattern depending on allocation state */ - CFE_ES_MemOffset_t ActualSize; /**< The actual requested size of the block */ - CFE_ES_MemOffset_t NextOffset; /**< The offset of the next descriptor in the free stack */ + size_t ActualSize; /**< The actual requested size of the block */ + size_t NextOffset; /**< The offset of the next descriptor in the free stack */ } CFE_ES_GenPoolBD_t; typedef struct CFE_ES_GenPoolBucket { - CFE_ES_MemOffset_t BlockSize; - CFE_ES_MemOffset_t FirstOffset; /**< Top of the "free stack" of buffers which have been returned */ + size_t BlockSize; + size_t FirstOffset; /**< Top of the "free stack" of buffers which have been returned */ uint32 AllocationCount; /**< Total number of buffers of this block size that exist (initial get) */ uint32 ReleaseCount; /**< Total number of buffers that have been released (put back) */ uint32 RecycleCount; /**< Total number of buffers that have been recycled (get after put) */ @@ -90,8 +90,7 @@ typedef struct CFE_ES_GenPoolRecord CFE_ES_GenPoolRecord_t; * pointer to the data instead of copying it. */ typedef int32 (*CFE_ES_PoolRetrieve_Func_t)(CFE_ES_GenPoolRecord_t *PoolRecPtr, - CFE_ES_MemOffset_t Offset, - CFE_ES_GenPoolBD_t **BdPtr); + size_t Offset, CFE_ES_GenPoolBD_t **BdPtr); /** * \brief Function to commit a buffer descriptor to the pool storage @@ -101,8 +100,7 @@ typedef int32 (*CFE_ES_PoolRetrieve_Func_t)(CFE_ES_GenPoolRecord_t *PoolRecPtr, * storage. It may be a no-op for memory mapped pools. */ typedef int32 (*CFE_ES_PoolCommit_Func_t)(CFE_ES_GenPoolRecord_t *PoolRecPtr, - CFE_ES_MemOffset_t Offset, - const CFE_ES_GenPoolBD_t *BdPtr); + size_t Offset, const CFE_ES_GenPoolBD_t *BdPtr); /** @@ -110,10 +108,10 @@ typedef int32 (*CFE_ES_PoolCommit_Func_t)(CFE_ES_GenPoolRecord_t *PoolRecPtr, */ struct CFE_ES_GenPoolRecord { - CFE_ES_MemOffset_t PoolTotalSize; /**< Total size of the pool area, in bytes */ - CFE_ES_MemOffset_t PoolMaxOffset; /**< End offset (position) of the pool */ - CFE_ES_MemOffset_t AlignMask; /**< Alignment mask applied to all new allocations */ - CFE_ES_MemOffset_t TailPosition; /**< Current high watermark of the pool, end of last allocation */ + size_t PoolTotalSize; /**< Total size of the pool area, in bytes */ + size_t PoolMaxOffset; /**< End offset (position) of the pool */ + size_t AlignMask; /**< Alignment mask applied to all new allocations */ + size_t TailPosition; /**< Current high watermark of the pool, end of last allocation */ CFE_ES_PoolRetrieve_Func_t Retrieve; /**< Function to access a buffer descriptor in the pool storage */ CFE_ES_PoolCommit_Func_t Commit; /**< Function to commit a buffer descriptor to the pool storage */ @@ -148,11 +146,11 @@ struct CFE_ES_GenPoolRecord * \return #CFE_SUCCESS, or error code \ref CFEReturnCodes */ int32 CFE_ES_GenPoolInitialize(CFE_ES_GenPoolRecord_t *PoolRecPtr, - CFE_ES_MemOffset_t StartOffset, - CFE_ES_MemOffset_t PoolSize, - CFE_ES_MemOffset_t AlignSize, + size_t StartOffset, + size_t PoolSize, + size_t AlignSize, uint16 NumBlockSizes, - const CFE_ES_MemOffset_t *BlockSizeList, + const size_t *BlockSizeList, CFE_ES_PoolRetrieve_Func_t RetrieveFunc, CFE_ES_PoolCommit_Func_t CommitFunc); @@ -169,8 +167,8 @@ int32 CFE_ES_GenPoolInitialize(CFE_ES_GenPoolRecord_t *PoolRecPtr, * \return #CFE_SUCCESS, or error code \ref CFEReturnCodes */ int32 CFE_ES_GenPoolGetBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, - CFE_ES_MemOffset_t *BlockOffsetPtr, - CFE_ES_MemOffset_t ReqSize); + size_t *BlockOffsetPtr, + size_t ReqSize); /** * \brief Returns a block to the pool @@ -185,8 +183,8 @@ int32 CFE_ES_GenPoolGetBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, * \return #CFE_SUCCESS, or error code \ref CFEReturnCodes */ int32 CFE_ES_GenPoolPutBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, - CFE_ES_MemOffset_t *BlockSizePtr, - CFE_ES_MemOffset_t BlockOffset); + size_t *BlockSizePtr, + size_t BlockOffset); /** * \brief Rebuild list of free blocks in pool @@ -221,8 +219,8 @@ int32 CFE_ES_GenPoolRebuild(CFE_ES_GenPoolRecord_t *PoolRecPtr); * \return #CFE_SUCCESS, or error code \ref CFEReturnCodes */ int32 CFE_ES_GenPoolGetBlockSize(CFE_ES_GenPoolRecord_t *PoolRecPtr, - CFE_ES_MemOffset_t *BlockSizePtr, - CFE_ES_MemOffset_t BlockOffset); + size_t *BlockSizePtr, + size_t BlockOffset); /** * \brief Validate a pool structure @@ -238,9 +236,16 @@ bool CFE_ES_GenPoolValidateState(const CFE_ES_GenPoolRecord_t *PoolRecPtr); /** * \brief Query basic usage of the pool structure * + * Obtain basic pool usage info for telemetry/statistics reporting. + * * \param[in] PoolRecPtr Pointer to pool structure * \param[out] FreeSizeBuf Buffer to store free size * \param[out] TotalSizeBuf Buffer to store total size + * + * \note This function is intended for telemetry purposes, so it + * uses the message size type (CFE_ES_MemOffset_t) rather + * than size_t, to be compatible with the type used in telemetry + * messages. */ void CFE_ES_GenPoolGetUsage(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_MemOffset_t *FreeSizeBuf, @@ -248,6 +253,8 @@ void CFE_ES_GenPoolGetUsage(CFE_ES_GenPoolRecord_t *PoolRecPtr, /** * \brief Query counters associated with the pool structure + * + * Obtain pool counters for telemetry/statistics reporting. * * \param[in] PoolRecPtr Pointer to pool structure * \param[out] NumBucketsBuf Buffer to store bucket count @@ -262,6 +269,8 @@ void CFE_ES_GenPoolGetCounts(CFE_ES_GenPoolRecord_t *PoolRecPtr, /** * \brief Query bucket-specific usage of the pool structure * + * Obtain pool per-bucket stats for telemetry/statistics reporting. + * * If the bucket number is not valid, this sets all output values to zero. * * \param[in] PoolRecPtr Pointer to pool structure @@ -288,8 +297,8 @@ void CFE_ES_GenPoolGetBucketUsage(CFE_ES_GenPoolRecord_t *PoolRecPtr, uint16 Buc * * \return Minimum size required for requested number of blocks. */ -CFE_ES_MemOffset_t CFE_ES_GenPoolCalcMinSize(uint16 NumBlockSizes, - const CFE_ES_MemOffset_t *BlockSizeList, +size_t CFE_ES_GenPoolCalcMinSize(uint16 NumBlockSizes, + const size_t *BlockSizeList, uint32 NumBlocks); #endif /* _cfe_es_generic_pool_ */ diff --git a/fsw/cfe-core/src/es/cfe_es_mempool.c b/fsw/cfe-core/src/es/cfe_es_mempool.c index d1d4d8042..9ccda8337 100644 --- a/fsw/cfe-core/src/es/cfe_es_mempool.c +++ b/fsw/cfe-core/src/es/cfe_es_mempool.c @@ -61,7 +61,7 @@ ** Type Definitions */ -const CFE_ES_MemOffset_t CFE_ES_MemPoolDefSize[CFE_PLATFORM_ES_POOL_MAX_BUCKETS] = +const size_t CFE_ES_MemPoolDefSize[CFE_PLATFORM_ES_POOL_MAX_BUCKETS] = { CFE_PLATFORM_ES_MAX_BLOCK_SIZE, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_16, @@ -87,7 +87,7 @@ const CFE_ES_MemOffset_t CFE_ES_MemPoolDefSize[CFE_PLATFORM_ES_POOL_MAX_BUCKETS] ** Functions */ -int32 CFE_ES_MemPoolDirectRetrieve(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_MemOffset_t Offset, +int32 CFE_ES_MemPoolDirectRetrieve(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t Offset, CFE_ES_GenPoolBD_t **BdPtr) { cpuaddr DataAddress; @@ -99,7 +99,7 @@ int32 CFE_ES_MemPoolDirectRetrieve(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_Me return CFE_SUCCESS; } -int32 CFE_ES_MemPoolDirectCommit(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_MemOffset_t Offset, +int32 CFE_ES_MemPoolDirectCommit(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t Offset, const CFE_ES_GenPoolBD_t *BdPtr) { return CFE_SUCCESS; @@ -136,7 +136,7 @@ CFE_ES_MemPoolRecord_t* CFE_ES_LocateMemPoolRecordByID(CFE_ES_MemHandle_t PoolID */ int32 CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, - CFE_ES_MemOffset_t Size ) + size_t Size ) { return CFE_ES_PoolCreateEx(PoolID, MemPtr, Size, CFE_PLATFORM_ES_POOL_MAX_BUCKETS, &CFE_ES_MemPoolDefSize[0],CFE_ES_NO_MUTEX); @@ -147,7 +147,7 @@ int32 CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, */ int32 CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, - CFE_ES_MemOffset_t Size ) + size_t Size ) { return CFE_ES_PoolCreateEx(PoolID, MemPtr, Size, CFE_PLATFORM_ES_POOL_MAX_BUCKETS, &CFE_ES_MemPoolDefSize[0],CFE_ES_USE_MUTEX); @@ -156,16 +156,16 @@ int32 CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, - CFE_ES_MemOffset_t Size, + size_t Size, uint16 NumBlockSizes, - const CFE_ES_MemOffset_t *BlockSizes, - uint16 UseMutex ) + const size_t *BlockSizes, + bool UseMutex ) { int32 Status; CFE_ES_MemHandle_t PendingID; CFE_ES_MemPoolRecord_t *PoolRecPtr; - CFE_ES_MemOffset_t Alignment; - CFE_ES_MemOffset_t MinimumSize; + size_t Alignment; + size_t MinimumSize; char MutexName[OS_MAX_API_NAME]; /* Sanity Check inputs */ @@ -182,13 +182,6 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, return(CFE_ES_BAD_ARGUMENT); } - if ((UseMutex != CFE_ES_USE_MUTEX) && (UseMutex != CFE_ES_NO_MUTEX)) - { - CFE_ES_WriteToSysLog("CFE_ES:poolCreate Invalid Mutex Usage Option (%d), must be %d or %d\n", - UseMutex, CFE_ES_NO_MUTEX, CFE_ES_USE_MUTEX); - return(CFE_ES_BAD_ARGUMENT); - } - /* * Use default block sizes if not specified */ @@ -399,12 +392,12 @@ int32 CFE_ES_PoolDelete(CFE_ES_MemHandle_t PoolID) */ int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, CFE_ES_MemHandle_t Handle, - CFE_ES_MemOffset_t Size ) + size_t Size ) { int32 Status; CFE_ES_MemHandle_t AppId; CFE_ES_MemPoolRecord_t *PoolRecPtr; - CFE_ES_MemOffset_t DataOffset; + size_t DataOffset; PoolRecPtr = CFE_ES_LocateMemPoolRecordByID(Handle); @@ -466,8 +459,8 @@ int32 CFE_ES_GetPoolBufInfo(CFE_ES_MemHandle_t Handle, { int32 Status; CFE_ES_MemPoolRecord_t *PoolRecPtr; - CFE_ES_MemOffset_t DataOffset; - CFE_ES_MemOffset_t DataSize; + size_t DataOffset; + size_t DataSize; PoolRecPtr = CFE_ES_LocateMemPoolRecordByID(Handle); @@ -519,8 +512,8 @@ int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t Handle, uint32 * BufPtr) { CFE_ES_MemPoolRecord_t *PoolRecPtr; - CFE_ES_MemOffset_t DataSize; - CFE_ES_MemOffset_t DataOffset; + size_t DataSize; + size_t DataOffset; int32 Status; PoolRecPtr = CFE_ES_LocateMemPoolRecordByID(Handle); diff --git a/fsw/cfe-core/src/es/cfe_es_perf.c b/fsw/cfe-core/src/es/cfe_es_perf.c index c85a22555..518e4b55f 100644 --- a/fsw/cfe-core/src/es/cfe_es_perf.c +++ b/fsw/cfe-core/src/es/cfe_es_perf.c @@ -229,7 +229,8 @@ int32 CFE_ES_StopPerfDataCmd(const CFE_ES_StopPerfData_t *data) /* Copy out the string, using default if unspecified */ CFE_SB_MessageStringGet(PerfDumpState->DataFileName, CmdPtr->DataFileName, - CFE_PLATFORM_ES_DEFAULT_PERF_DUMP_FILENAME, OS_MAX_PATH_LEN, sizeof(CmdPtr->DataFileName)); + CFE_PLATFORM_ES_DEFAULT_PERF_DUMP_FILENAME, + sizeof(PerfDumpState->DataFileName), sizeof(CmdPtr->DataFileName)); PerfDumpState->PendingState = CFE_ES_PerfDumpState_INIT; CFE_ES_BackgroundWakeup(); @@ -273,7 +274,7 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) CFE_ES_PerfDumpGlobal_t *State = (CFE_ES_PerfDumpGlobal_t *)Arg; int32 Status; CFE_FS_Header_t FileHdr; - uint32 BlockSize; + size_t BlockSize; /* * each time this background job is re-entered after a time delay, diff --git a/fsw/cfe-core/src/es/cfe_es_perf.h b/fsw/cfe-core/src/es/cfe_es_perf.h index 38e53d848..74cd370e6 100644 --- a/fsw/cfe-core/src/es/cfe_es_perf.h +++ b/fsw/cfe-core/src/es/cfe_es_perf.h @@ -114,7 +114,7 @@ typedef struct uint32 WorkCredit; /* accumulator based on the passage of time */ uint32 StateCounter; /* number of blocks/items left in current state */ uint32 DataPos; /* last position within the Perf Log */ - uint32 FileSize; /* Total file size, for progress reporing in telemetry */ + size_t FileSize; /* Total file size, for progress reporing in telemetry */ } CFE_ES_PerfDumpGlobal_t; /* diff --git a/fsw/cfe-core/src/es/cfe_es_task.c b/fsw/cfe-core/src/es/cfe_es_task.c index 75af1e6e9..eeb0669d6 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.c +++ b/fsw/cfe-core/src/es/cfe_es_task.c @@ -664,8 +664,8 @@ int32 CFE_ES_HousekeepingCmd(const CFE_SB_CmdHdr_t *data) CFE_ES_TaskData.HkPacket.Payload.CommandCounter = CFE_ES_TaskData.CommandCounter; CFE_ES_TaskData.HkPacket.Payload.CommandErrorCounter = CFE_ES_TaskData.CommandErrorCounter; - CFE_ES_TaskData.HkPacket.Payload.SysLogBytesUsed = CFE_ES_ResetDataPtr->SystemLogEndIdx; - CFE_ES_TaskData.HkPacket.Payload.SysLogSize = CFE_PLATFORM_ES_SYSTEM_LOG_SIZE; + CFE_ES_TaskData.HkPacket.Payload.SysLogBytesUsed = CFE_ES_MEMOFFSET_C(CFE_ES_ResetDataPtr->SystemLogEndIdx); + CFE_ES_TaskData.HkPacket.Payload.SysLogSize = CFE_ES_MEMOFFSET_C(CFE_PLATFORM_ES_SYSTEM_LOG_SIZE); CFE_ES_TaskData.HkPacket.Payload.SysLogEntries = CFE_ES_ResetDataPtr->SystemLogEntryNum; CFE_ES_TaskData.HkPacket.Payload.SysLogMode = CFE_ES_ResetDataPtr->SystemLogMode; @@ -729,19 +729,20 @@ int32 CFE_ES_HousekeepingCmd(const CFE_SB_CmdHdr_t *data) stat = OS_HeapGetInfo(&HeapProp); - if(stat == OS_SUCCESS) - { - CFE_ES_TaskData.HkPacket.Payload.HeapBytesFree = HeapProp.free_bytes; - CFE_ES_TaskData.HkPacket.Payload.HeapBlocksFree = HeapProp.free_blocks; - CFE_ES_TaskData.HkPacket.Payload.HeapMaxBlockSize = HeapProp.largest_free_block; - } - else + /* + * If retrieving info from OSAL was not successful, + * zero out the property struct, so all sizes will + * in turn be reported in telemetry as 0. + */ + if(stat != OS_SUCCESS) { - CFE_ES_TaskData.HkPacket.Payload.HeapBytesFree = 0; - CFE_ES_TaskData.HkPacket.Payload.HeapBlocksFree = 0; - CFE_ES_TaskData.HkPacket.Payload.HeapMaxBlockSize = 0; + memset(&HeapProp, 0, sizeof(HeapProp)); } + CFE_ES_TaskData.HkPacket.Payload.HeapBytesFree = CFE_ES_MEMOFFSET_C(HeapProp.free_bytes); + CFE_ES_TaskData.HkPacket.Payload.HeapBlocksFree = CFE_ES_MEMOFFSET_C(HeapProp.free_blocks); + CFE_ES_TaskData.HkPacket.Payload.HeapMaxBlockSize = CFE_ES_MEMOFFSET_C(HeapProp.largest_free_block); + /* ** Send housekeeping telemetry packet. */ @@ -867,13 +868,13 @@ int32 CFE_ES_StartAppCmd(const CFE_ES_StartApp_t *data) /* Create local copies of all input strings and ensure null termination */ FilenameLen = CFE_SB_MessageStringGet(LocalFile, (char *)cmd->AppFileName, NULL, - OS_MAX_PATH_LEN, sizeof(cmd->AppFileName)); + sizeof(LocalFile), sizeof(cmd->AppFileName)); AppEntryLen = CFE_SB_MessageStringGet(LocalEntryPt, (char *)cmd->AppEntryPoint, NULL, - OS_MAX_API_NAME, sizeof(cmd->AppEntryPoint)); + sizeof(LocalEntryPt), sizeof(cmd->AppEntryPoint)); AppNameLen = CFE_SB_MessageStringGet(LocalAppName, (char *)cmd->Application, NULL, - OS_MAX_API_NAME, sizeof(cmd->Application)); + sizeof(LocalAppName), sizeof(cmd->Application)); /* ** Verify command parameters @@ -968,7 +969,8 @@ int32 CFE_ES_StopAppCmd(const CFE_ES_StopApp_t *data) CFE_ES_ResourceID_t AppID; int32 Result; - CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, OS_MAX_API_NAME, sizeof(cmd->Application)); + CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, + sizeof(LocalApp), sizeof(cmd->Application)); Result = CFE_ES_GetAppIDByName(&AppID, LocalApp); @@ -1021,7 +1023,8 @@ int32 CFE_ES_RestartAppCmd(const CFE_ES_RestartApp_t *data) CFE_ES_ResourceID_t AppID; int32 Result; - CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, OS_MAX_API_NAME, sizeof(cmd->Application)); + CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, + sizeof(LocalApp), sizeof(cmd->Application)); Result = CFE_ES_GetAppIDByName(&AppID, LocalApp); @@ -1071,8 +1074,10 @@ int32 CFE_ES_ReloadAppCmd(const CFE_ES_ReloadApp_t *data) CFE_ES_ResourceID_t AppID; int32 Result; - CFE_SB_MessageStringGet(LocalFileName, (char *)cmd->AppFileName, NULL, sizeof(LocalFileName), sizeof(cmd->AppFileName)); - CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, sizeof(LocalApp), sizeof(cmd->Application)); + CFE_SB_MessageStringGet(LocalFileName, (char *)cmd->AppFileName, NULL, + sizeof(LocalFileName), sizeof(cmd->AppFileName)); + CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, + sizeof(LocalApp), sizeof(cmd->Application)); Result = CFE_ES_GetAppIDByName(&AppID, LocalApp); @@ -1122,7 +1127,8 @@ int32 CFE_ES_QueryOneCmd(const CFE_ES_QueryOne_t *data) CFE_ES_ResourceID_t ResourceID; int32 Result; - CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, OS_MAX_API_NAME, sizeof(cmd->Application)); + CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, + sizeof(LocalApp), sizeof(cmd->Application)); Result = CFE_ES_GetAppIDByName(&ResourceID, LocalApp); if (Result == CFE_ES_ERR_NAME_NOT_FOUND) @@ -1196,8 +1202,8 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAll_t *data) /* ** Copy the commanded filename into local buffer to ensure size limitation and to allow for modification */ - CFE_SB_MessageStringGet(QueryAllFilename, (char *)CmdPtr->FileName, - CFE_PLATFORM_ES_DEFAULT_APP_LOG_FILE, OS_MAX_PATH_LEN, sizeof(CmdPtr->FileName)); + CFE_SB_MessageStringGet(QueryAllFilename, (char *)CmdPtr->FileName, CFE_PLATFORM_ES_DEFAULT_APP_LOG_FILE, + sizeof(QueryAllFilename), sizeof(CmdPtr->FileName)); /* * Collect list of active resource IDs. @@ -1354,8 +1360,8 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasks_t *data) /* ** Copy the commanded filename into local buffer to ensure size limitation and to allow for modification */ - CFE_SB_MessageStringGet(QueryAllFilename, (char *)CmdPtr->FileName, - CFE_PLATFORM_ES_DEFAULT_TASK_LOG_FILE, OS_MAX_PATH_LEN, sizeof(CmdPtr->FileName)); + CFE_SB_MessageStringGet(QueryAllFilename, (char *)CmdPtr->FileName, CFE_PLATFORM_ES_DEFAULT_TASK_LOG_FILE, + sizeof(QueryAllFilename), sizeof(CmdPtr->FileName)); /* * Collect list of active task IDs. @@ -1548,8 +1554,8 @@ int32 CFE_ES_WriteSyslogCmd(const CFE_ES_WriteSyslog_t *data) int32 Stat; char LogFilename[OS_MAX_PATH_LEN]; - CFE_SB_MessageStringGet(LogFilename, (char *)CmdPtr->FileName, - CFE_PLATFORM_ES_DEFAULT_SYSLOG_FILE, OS_MAX_PATH_LEN, sizeof(CmdPtr->FileName)); + CFE_SB_MessageStringGet(LogFilename, (char *)CmdPtr->FileName, CFE_PLATFORM_ES_DEFAULT_SYSLOG_FILE, + sizeof(LogFilename), sizeof(CmdPtr->FileName)); Stat = CFE_ES_SysLogDump(LogFilename); @@ -1641,10 +1647,10 @@ int32 CFE_ES_WriteERLogCmd(const CFE_ES_WriteERLog_t *data) /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -bool CFE_ES_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength) +bool CFE_ES_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, size_t ExpectedLength) { bool result = true; - uint16 ActualLength = CFE_SB_GetTotalMsgLength(Msg); + size_t ActualLength = CFE_SB_GetTotalMsgLength(Msg); /* ** Verify the command packet length @@ -1730,7 +1736,7 @@ int32 CFE_ES_DeleteCDSCmd(const CFE_ES_DeleteCDS_t *data) char LocalCdsName[CFE_MISSION_ES_CDS_MAX_FULL_NAME_LEN]; CFE_SB_MessageStringGet(LocalCdsName, (char *)cmd->CdsName, NULL, - CFE_MISSION_ES_CDS_MAX_FULL_NAME_LEN, sizeof(cmd->CdsName)); + sizeof(LocalCdsName), sizeof(cmd->CdsName)); Status = CFE_ES_DeleteCDS(LocalCdsName, false); @@ -1847,7 +1853,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistry_t *data) /* Copy the commanded filename into local buffer to ensure size limitation and to allow for modification */ CFE_SB_MessageStringGet(DumpFilename, CmdPtr->DumpFilename, CFE_PLATFORM_ES_DEFAULT_CDS_REG_DUMP_FILE, - OS_MAX_PATH_LEN, sizeof(CmdPtr->DumpFilename)); + sizeof(DumpFilename), sizeof(CmdPtr->DumpFilename)); /* Create a new dump file, overwriting anything that may have existed previously */ Status = OS_OpenCreate(&FileDescriptor, DumpFilename, @@ -1875,7 +1881,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistry_t *data) { /* Fill CDS Registry Dump Record with relevant information */ memset(&DumpRecord, 0, sizeof(DumpRecord)); - DumpRecord.Size = CFE_ES_CDSBlockRecordGetUserSize(RegRecPtr); + DumpRecord.Size = CFE_ES_MEMOFFSET_C(CFE_ES_CDSBlockRecordGetUserSize(RegRecPtr)); DumpRecord.Handle = CFE_ES_CDSBlockRecordGetID(RegRecPtr); DumpRecord.Table = RegRecPtr->Table; strncpy(DumpRecord.Name, RegRecPtr->Name, sizeof(DumpRecord.Name)-1); @@ -1949,7 +1955,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistry_t *data) /* a byte count discrepancy has been*/ /* detected during the file write */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void CFE_ES_FileWriteByteCntErr(const char *Filename,uint32 Requested,uint32 Actual) +void CFE_ES_FileWriteByteCntErr(const char *Filename,size_t Requested,size_t Actual) { CFE_EVS_SendEvent(CFE_ES_FILEWRITE_ERR_EID,CFE_EVS_EventType_ERROR, diff --git a/fsw/cfe-core/src/es/cfe_es_task.h b/fsw/cfe-core/src/es/cfe_es_task.h index 83e142ac8..199da59c2 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.h +++ b/fsw/cfe-core/src/es/cfe_es_task.h @@ -204,8 +204,8 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistry_t *data); ** Message Handler Helper Functions */ bool CFE_ES_ValidateHandle(CFE_ES_MemHandle_t Handle); -bool CFE_ES_VerifyCmdLength(CFE_SB_MsgPtr_t msg, uint16 ExpectedLength); -void CFE_ES_FileWriteByteCntErr(const char *Filename,uint32 Requested,uint32 Actual); +bool CFE_ES_VerifyCmdLength(CFE_SB_MsgPtr_t msg, size_t ExpectedLength); +void CFE_ES_FileWriteByteCntErr(const char *Filename,size_t Requested,size_t Actual); /*************************************************************************/ diff --git a/fsw/cfe-core/src/evs/cfe_evs_log.c b/fsw/cfe-core/src/evs/cfe_evs_log.c index 28519d7bd..e6c091203 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_log.c +++ b/fsw/cfe-core/src/evs/cfe_evs_log.c @@ -169,7 +169,7 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFile_t *data) { /* Copy the commanded filename into local buffer to ensure size limitation and to allow for modification */ CFE_SB_MessageStringGet(LogFilename, (const char *)CmdPtr->LogFilename, CFE_PLATFORM_EVS_DEFAULT_LOG_FILE, - OS_MAX_PATH_LEN, sizeof(CmdPtr->LogFilename)); + sizeof(LogFilename), sizeof(CmdPtr->LogFilename)); /* Create the log file */ Result = OS_OpenCreate(&LogFileHandle, LogFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.c b/fsw/cfe-core/src/evs/cfe_evs_task.c index e5baec3cb..b8bc9f701 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.c +++ b/fsw/cfe-core/src/evs/cfe_evs_task.c @@ -54,7 +54,7 @@ CFE_EVS_GlobalData_t CFE_EVS_GlobalData; ** Local function prototypes. */ void CFE_EVS_ProcessGroundCommand ( CFE_SB_MsgPtr_t EVS_MsgPtr ); -bool CFE_EVS_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength); +bool CFE_EVS_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, size_t ExpectedLength); /* Function Definitions */ @@ -486,7 +486,7 @@ void CFE_EVS_ProcessGroundCommand ( CFE_SB_MsgPtr_t EVS_MsgPtr ) case CFE_EVS_SET_FILTER_CC: - if (CFE_EVS_VerifyCmdLength(EVS_MsgPtr, (uint16) sizeof(CFE_EVS_SetFilter_t))) + if (CFE_EVS_VerifyCmdLength(EVS_MsgPtr, sizeof(CFE_EVS_SetFilter_t))) { Status = CFE_EVS_SetFilterCmd((CFE_EVS_SetFilter_t*)EVS_MsgPtr); } @@ -608,10 +608,10 @@ void CFE_EVS_ProcessGroundCommand ( CFE_SB_MsgPtr_t EVS_MsgPtr ) ** Assumptions and Notes: ** */ -bool CFE_EVS_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength) +bool CFE_EVS_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, size_t ExpectedLength) { bool result = true; - uint16 ActualLength = CFE_SB_GetTotalMsgLength(Msg); + size_t ActualLength = CFE_SB_GetTotalMsgLength(Msg); /* ** Verify the command packet length @@ -786,7 +786,8 @@ int32 CFE_EVS_SetFilterCmd(const CFE_EVS_SetFilter_t *data) * Althgouh EVS_GetApplicationInfo() does not require a null terminated argument, * the value is passed to EVS_SendEvent which does require termination (normal C string) */ - CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, OS_MAX_API_NAME, sizeof(CmdPtr->AppName)); + CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, + sizeof(LocalName), sizeof(CmdPtr->AppName)); /* Retreive application data */ Status = EVS_GetApplicationInfo(&AppDataPtr, LocalName); @@ -1116,7 +1117,8 @@ int32 CFE_EVS_EnableAppEventTypeCmd(const CFE_EVS_EnableAppEventType_t *data) * Althgouh EVS_GetApplicationInfo() does not require a null terminated argument, * the value is passed to EVS_SendEvent which does require termination (normal C string) */ - CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, OS_MAX_API_NAME, sizeof(CmdPtr->AppName)); + CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, + sizeof(LocalName), sizeof(CmdPtr->AppName)); /* Retrieve application data */ Status = EVS_GetApplicationInfo(&AppDataPtr, LocalName); @@ -1190,7 +1192,8 @@ int32 CFE_EVS_DisableAppEventTypeCmd(const CFE_EVS_DisableAppEventType_t *data) * Althgouh EVS_GetApplicationInfo() does not require a null terminated argument, * the value is passed to EVS_SendEvent which does require termination (normal C string) */ - CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, OS_MAX_API_NAME, sizeof(CmdPtr->AppName)); + CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, + sizeof(LocalName), sizeof(CmdPtr->AppName)); /* Retreive application data */ Status = EVS_GetApplicationInfo(&AppDataPtr, LocalName); @@ -1263,7 +1266,8 @@ int32 CFE_EVS_EnableAppEventsCmd(const CFE_EVS_EnableAppEvents_t *data) * Althgouh EVS_GetApplicationInfo() does not require a null terminated argument, * the value is passed to EVS_SendEvent which does require termination (normal C string) */ - CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, OS_MAX_API_NAME, sizeof(CmdPtr->AppName)); + CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, + sizeof(LocalName), sizeof(CmdPtr->AppName)); /* Retrieve application data */ Status = EVS_GetApplicationInfo(&AppDataPtr, LocalName); @@ -1321,7 +1325,8 @@ int32 CFE_EVS_DisableAppEventsCmd(const CFE_EVS_DisableAppEvents_t *data) * Althgouh EVS_GetApplicationInfo() does not require a null terminated argument, * the value is passed to EVS_SendEvent which does require termination (normal C string) */ - CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, OS_MAX_API_NAME, sizeof(CmdPtr->AppName)); + CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, + sizeof(LocalName), sizeof(CmdPtr->AppName)); /* Retreive application data */ Status = EVS_GetApplicationInfo(&AppDataPtr, LocalName); @@ -1380,7 +1385,8 @@ int32 CFE_EVS_ResetAppCounterCmd(const CFE_EVS_ResetAppCounter_t *data) * Althgouh EVS_GetApplicationInfo() does not require a null terminated argument, * the value is passed to EVS_SendEvent which does require termination (normal C string) */ - CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, OS_MAX_API_NAME, sizeof(CmdPtr->AppName)); + CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, + sizeof(LocalName), sizeof(CmdPtr->AppName)); /* Retreive application data */ Status = EVS_GetApplicationInfo(&AppDataPtr, LocalName); @@ -1440,7 +1446,8 @@ int32 CFE_EVS_ResetFilterCmd(const CFE_EVS_ResetFilter_t *data) * Althgouh EVS_GetApplicationInfo() does not require a null terminated argument, * the value is passed to EVS_SendEvent which does require termination (normal C string) */ - CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, OS_MAX_API_NAME, sizeof(CmdPtr->AppName)); + CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, + sizeof(LocalName), sizeof(CmdPtr->AppName)); /* Retreive application data */ Status = EVS_GetApplicationInfo(&AppDataPtr, LocalName); @@ -1513,7 +1520,8 @@ int32 CFE_EVS_ResetAllFiltersCmd(const CFE_EVS_ResetAllFilters_t *data) * Althgouh EVS_GetApplicationInfo() does not require a null terminated argument, * the value is passed to EVS_SendEvent which does require termination (normal C string) */ - CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, OS_MAX_API_NAME, sizeof(CmdPtr->AppName)); + CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, + sizeof(LocalName), sizeof(CmdPtr->AppName)); /* Retreive application data */ Status = EVS_GetApplicationInfo(&AppDataPtr, LocalName); @@ -1575,7 +1583,8 @@ int32 CFE_EVS_AddEventFilterCmd(const CFE_EVS_AddEventFilter_t *data) * Althgouh EVS_GetApplicationInfo() does not require a null terminated argument, * the value is passed to EVS_SendEvent which does require termination (normal C string) */ - CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, OS_MAX_API_NAME, sizeof(CmdPtr->AppName)); + CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, + sizeof(LocalName), sizeof(CmdPtr->AppName)); /* Retreive application data */ Status = EVS_GetApplicationInfo(&AppDataPtr, LocalName); @@ -1667,7 +1676,8 @@ int32 CFE_EVS_DeleteEventFilterCmd(const CFE_EVS_DeleteEventFilter_t *data) * Althgouh EVS_GetApplicationInfo() does not require a null terminated argument, * the value is passed to EVS_SendEvent which does require termination (normal C string) */ - CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, OS_MAX_API_NAME, sizeof(CmdPtr->AppName)); + CFE_SB_MessageStringGet(LocalName, (char *)CmdPtr->AppName, NULL, + sizeof(LocalName), sizeof(CmdPtr->AppName)); /* Retreive application data */ Status = EVS_GetApplicationInfo(&AppDataPtr, LocalName); @@ -1747,7 +1757,7 @@ int32 CFE_EVS_WriteAppDataFileCmd(const CFE_EVS_WriteAppDataFile_t *data) /* Copy the commanded filename into local buffer to ensure size limitation and to allow for modification */ CFE_SB_MessageStringGet(LocalName, CmdPtr->AppDataFilename, CFE_PLATFORM_EVS_DEFAULT_APP_DATA_FILE, - OS_MAX_PATH_LEN, sizeof(CmdPtr->AppDataFilename)); + sizeof(LocalName), sizeof(CmdPtr->AppDataFilename)); /* Create Application Data File */ Result = OS_OpenCreate(&FileHandle, LocalName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); @@ -1781,7 +1791,8 @@ int32 CFE_EVS_WriteAppDataFileCmd(const CFE_EVS_WriteAppDataFile_t *data) memset(&AppDataFile, 0, sizeof(CFE_EVS_AppDataFile_t)); /* Copy application data to application file data record */ - CFE_ES_GetAppName(AppDataFile.AppName, EVS_AppDataGetID(AppDataPtr), OS_MAX_API_NAME); + CFE_ES_GetAppName(AppDataFile.AppName, EVS_AppDataGetID(AppDataPtr), + sizeof(AppDataFile.AppName)); AppDataFile.ActiveFlag = AppDataPtr->ActiveFlag; AppDataFile.EventCount = AppDataPtr->EventCount; AppDataFile.EventTypesActiveFlag = AppDataPtr->EventTypesActiveFlag; diff --git a/fsw/cfe-core/src/evs/cfe_evs_utils.c b/fsw/cfe-core/src/evs/cfe_evs_utils.c index 906d808b0..905df42eb 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_utils.c +++ b/fsw/cfe-core/src/evs/cfe_evs_utils.c @@ -194,7 +194,7 @@ int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_t CallerID AppDataPtr->UnregAppID = CallerID; /* Get the name of the "not registered" app */ - CFE_ES_GetAppName(AppName, CallerID, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, CallerID, sizeof(AppName)); /* Send the "not registered" event */ EVS_SendEvent(CFE_EVS_ERR_UNREGISTERED_EVS_APP, CFE_EVS_EventType_ERROR, @@ -300,7 +300,7 @@ bool EVS_IsFiltered (EVS_AppData_t *AppDataPtr, uint16 EventID, uint16 EventType /* Is it time to lock this filter? */ if (FilterPtr->Count == CFE_EVS_MAX_FILTER_COUNT) { - CFE_ES_GetAppName(AppName, EVS_AppDataGetID(AppDataPtr), OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, EVS_AppDataGetID(AppDataPtr), sizeof(AppName)); EVS_SendEvent(CFE_EVS_FILTER_MAX_EID, CFE_EVS_EventType_INFORMATION, "Max filter count reached, AppName = %s, EventID = 0x%08x: Filter locked until reset", diff --git a/fsw/cfe-core/src/inc/cfe_es.h b/fsw/cfe-core/src/inc/cfe_es.h index 3e35221a3..28457d0bf 100644 --- a/fsw/cfe-core/src/inc/cfe_es.h +++ b/fsw/cfe-core/src/inc/cfe_es.h @@ -115,8 +115,22 @@ #define CFE_ES_CDS_BAD_HANDLE CFE_ES_RESOURCEID_UNDEFINED /** \} */ -#define CFE_ES_NO_MUTEX 0 /**< \brief Indicates that the memory pool selection will not use a semaphore */ -#define CFE_ES_USE_MUTEX 1 /**< \brief Indicates that the memory pool selection will use a semaphore */ +#define CFE_ES_NO_MUTEX false /**< \brief Indicates that the memory pool selection will not use a semaphore */ +#define CFE_ES_USE_MUTEX true /**< \brief Indicates that the memory pool selection will use a semaphore */ + +/** \name Task Stack Constants */ +/** \{ */ + +/** + * \brief Indicates that the stack for the child task should be dynamically allocated. + * + * This value may be supplied as the Stack Pointer argument to CFE_ES_ChildTaskCreate() + * to indicate that the stack should be dynamically allocated. + */ +#define CFE_ES_TASK_STACK_ALLOCATE NULL /* aka OS_TASK_STACK_ALLOCATE in proposed OSAL change */ +/** \} */ + + /*****************************************************************************/ @@ -130,6 +144,13 @@ typedef void (*CFE_ES_ChildTaskMainFuncPtr_t)(void); /**< \brief Required Prototype of Child Task Main Functions */ typedef int32 (*CFE_ES_LibraryEntryFuncPtr_t)(CFE_ES_ResourceID_t LibId); /**< \brief Required Prototype of Library Initialization Functions */ +/** + * @brief Type for the stack pointer of tasks. + * + * This type is used in the CFE ES task API. + */ +typedef void* CFE_ES_StackPointer_t; /* aka osal_stackptr_t in proposed OSAL change */ + /** * \brief Pool Alignement * @@ -782,7 +803,7 @@ CFE_Status_t CFE_ES_GetLibIDByName(CFE_ES_ResourceID_t *LibIdPtr, const char *Li ** \sa #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppInfo ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, uint32 BufferLength); +CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t BufferLength); /*****************************************************************************/ /** @@ -812,7 +833,7 @@ CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, uint32 ** \sa #CFE_ES_GetLibIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, uint32 BufferLength); +CFE_Status_t CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, size_t BufferLength); /*****************************************************************************/ /** @@ -984,6 +1005,8 @@ CFE_Status_t CFE_ES_RegisterChildTask(void); ** ** \param[in] StackPtr A pointer to the location where the child task's stack pointer should start. ** NOTE: Not all underlying operating systems support this parameter. +** The CFE_ES_TASK_STACK_ALLOCATE constant may be passed to indicate that the +** stack should be dynamically allocated. ** ** \param[in] StackSize The number of bytes to allocate for the new task's stack. ** @@ -1003,9 +1026,9 @@ CFE_Status_t CFE_ES_RegisterChildTask(void); CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, - uint32 *StackPtr, - uint32 StackSize, - uint32 Priority, + CFE_ES_StackPointer_t StackPtr, + size_t StackSize, + CFE_ES_TaskPriority_Atom_t Priority, uint32 Flags); /*****************************************************************************/ @@ -1061,7 +1084,7 @@ CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_ResourceID_t *TaskIdPtr, const char * ** \sa #CFE_ES_GetTaskIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, uint32 BufferLength); +CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, size_t BufferLength); /*****************************************************************************/ /** @@ -1161,7 +1184,7 @@ CFE_Status_t CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) OS_PRINTF(1,2) ** \return The result of the CRC calculation on the specified memory block, or error code \ref CFEReturnCodes ** ******************************************************************************/ -uint32 CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputCRC, uint32 TypeCRC); +uint32 CFE_ES_CalculateCRC(const void *DataPtr, size_t DataLength, uint32 InputCRC, uint32 TypeCRC); /*****************************************************************************/ /** @@ -1218,7 +1241,7 @@ void CFE_ES_ProcessAsyncEvent(void); ** \sa #CFE_ES_CopyToCDS, #CFE_ES_RestoreFromCDS ** ******************************************************************************/ -CFE_Status_t CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, CFE_ES_CDS_Offset_t BlockSize, const char *Name); +CFE_Status_t CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, size_t BlockSize, const char *Name); /*****************************************************************************/ /** @@ -1273,7 +1296,7 @@ CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_ResourceID_t *BlockIdPtr, const c ** \sa #CFE_ES_GetCDSBlockIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_ResourceID_t BlockId, uint32 BufferLength); +CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_ResourceID_t BlockId, size_t BufferLength); /*****************************************************************************/ @@ -1362,7 +1385,7 @@ CFE_Status_t CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Han ** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats ** ******************************************************************************/ -CFE_Status_t CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, CFE_ES_MemOffset_t Size); +CFE_Status_t CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, size_t Size); /*****************************************************************************/ /** @@ -1391,7 +1414,7 @@ CFE_Status_t CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, C ** \sa #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats ** ******************************************************************************/ -CFE_Status_t CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, CFE_ES_MemOffset_t Size); +CFE_Status_t CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, size_t Size); /*****************************************************************************/ /** @@ -1431,10 +1454,10 @@ CFE_Status_t CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, CFE_ES ******************************************************************************/ CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, - CFE_ES_MemOffset_t Size, + size_t Size, uint16 NumBlockSizes, - const CFE_ES_MemOffset_t *BlockSizes, - uint16 UseMutex ); + const size_t *BlockSizes, + bool UseMutex ); /*****************************************************************************/ @@ -1485,7 +1508,7 @@ int32 CFE_ES_PoolDelete(CFE_ES_MemHandle_t PoolID); ** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats, #CFE_ES_GetPoolBufInfo ** ******************************************************************************/ -int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, CFE_ES_MemHandle_t PoolID, CFE_ES_MemOffset_t Size); +int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, CFE_ES_MemHandle_t PoolID, size_t Size); /*****************************************************************************/ /** @@ -1792,7 +1815,7 @@ CFE_Status_t CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, con ** \sa #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_ResourceID_t CounterId, uint32 BufferLength); +CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_ResourceID_t CounterId, size_t BufferLength); /**@}*/ diff --git a/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h b/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h index a230b7c90..d03927dad 100644 --- a/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h +++ b/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h @@ -364,10 +364,20 @@ typedef CFE_ES_ResourceID_t CFE_ES_MemHandle_t; typedef CFE_ES_ResourceID_t CFE_ES_CDSHandle_t; /** - * @brief Type used for memory sizes and offsets + * @brief Type used for task priority in CFE ES as + * including the commands/telemetry messages. + * + * @note the valid range is only 0-255 (same as OSAL) but + * a wider type is used for backward compatibility + * in binary formats of messages. + */ +typedef uint16 CFE_ES_TaskPriority_Atom_t; + +/** + * @brief Type used for memory sizes and offsets in commands and telemetry * * For backward compatibility with existing CFE code this should be uint32, - * but pools and other data structures will be limited to 4GB in size as a result. + * but all telemetry information will be limited to 4GB in size as a result. * * On 64-bit platforms this can be a 64-bit value which will allow larger * memory objects, but this will break compatibility with existing control @@ -375,11 +385,17 @@ typedef CFE_ES_ResourceID_t CFE_ES_CDSHandle_t; * * In either case this must be an unsigned type. */ -typedef uint32 CFE_ES_MemOffset_t; +typedef uint32 CFE_ES_MemOffset_t; + +/* + * A converter macro to use when initializing an CFE_ES_MemOffset_t + * from an integer value of a different type. + */ +#define CFE_ES_MEMOFFSET_C(x) ((CFE_ES_MemOffset_t)(x)) /** - * @brief Type used for memory addresses + * @brief Type used for memory addresses in command and telemetry messages * * For backward compatibility with existing CFE code this should be uint32, * but if running on a 64-bit platform, addresses in telemetry will be @@ -396,26 +412,18 @@ typedef uint32 CFE_ES_MemOffset_t; * converts to the native "cpuaddr" type provided by OSAL. This macro * provides independence between the message representation and local * representation of a memory address. - * - * @sa #CFE_SB_SET_MEMADDR, #CFE_SB_GET_MEMADDR */ typedef uint32 CFE_ES_MemAddress_t; -/** - * @brief Type used for CDS sizes and offsets. - * - * This must match the type used in the PSP CDS API, e.g.: - * CFE_PSP_GetCDSSize() - * CFE_PSP_WriteToCDS() - * CFE_PSP_ReadFromCDS() - * - * It is defined separately from the CFE_ES_MemOffset_t as the type used in - * the PSP CDS access API may be different than the ES Pool API. +/* + * A converter macro to use when initializing an CFE_ES_MemAddress_t + * from a pointer value of a different type. * - * In either case this must be an unsigned type. + * @note on a 64 bit platform, this macro will truncate the address such + * that it will fit into a 32-bit telemetry field. Obviously, the resulting + * value is no longer usable as a memory address after this. */ -typedef uint32 CFE_ES_CDS_Offset_t; - +#define CFE_ES_MEMADDRESS_C(x) ((CFE_ES_MemAddress_t)((cpuaddr)(x) & 0xFFFFFFFF)) #endif /* CFE_EDS_ENABLED_BUILD */ diff --git a/fsw/cfe-core/src/inc/cfe_es_msg.h b/fsw/cfe-core/src/inc/cfe_es_msg.h index 5f6b71ff3..28a0efc4a 100644 --- a/fsw/cfe-core/src/inc/cfe_es_msg.h +++ b/fsw/cfe-core/src/inc/cfe_es_msg.h @@ -1169,13 +1169,13 @@ typedef struct CFE_ES_StartAppCmd_Payload char AppFileName[CFE_MISSION_MAX_PATH_LEN]; /**< \brief Full path and filename of Application's executable image */ - uint32 StackSize; /**< \brief Desired stack size for the new application */ + CFE_ES_MemOffset_t StackSize; /**< \brief Desired stack size for the new application */ - uint16 ExceptionAction; /**< \brief #CFE_ES_ExceptionAction_RESTART_APP=On exception, + CFE_ES_ExceptionAction_Enum_t ExceptionAction; /**< \brief #CFE_ES_ExceptionAction_RESTART_APP=On exception, restart Application, #CFE_ES_ExceptionAction_PROC_RESTART=On exception, perform a Processor Reset */ - uint16 Priority; /**< \brief The new Applications runtime priority. */ + CFE_ES_TaskPriority_Atom_t Priority; /**< \brief The new Applications runtime priority. */ } CFE_ES_StartAppCmd_Payload_t; @@ -1424,10 +1424,10 @@ typedef struct CFE_ES_AppInfo \brief The BSS Size of the Application */ CFE_ES_MemAddress_t StartAddress; /**< \cfetlmmnemonic \ES_STARTADDR \brief The Start Address of the Application */ - uint16 ExceptionAction; /**< \cfetlmmnemonic \ES_EXCEPTNACTN + CFE_ES_ExceptionAction_Enum_t ExceptionAction; /**< \cfetlmmnemonic \ES_EXCEPTNACTN \brief What should occur if Application has an exception (Restart Application OR Restart Processor) */ - uint16 Priority; /**< \cfetlmmnemonic \ES_PRIORITY + CFE_ES_TaskPriority_Atom_t Priority; /**< \cfetlmmnemonic \ES_PRIORITY \brief The Priority of the Application */ CFE_ES_ResourceID_t MainTaskId; /**< \cfetlmmnemonic \ES_MAINTASKID \brief The Application's Main Task ID */ @@ -1475,7 +1475,7 @@ typedef struct CFE_ES_TaskInfo typedef struct CFE_ES_CDSRegDumpRec { CFE_ES_CDSHandle_t Handle; /**< \brief Handle of CDS */ - CFE_ES_CDS_Offset_t Size; /**< \brief Size, in bytes, of the CDS memory block */ + CFE_ES_MemOffset_t Size; /**< \brief Size, in bytes, of the CDS memory block */ bool Table; /**< \brief Flag that indicates whether CDS contains a Critical Table */ char Name[CFE_MISSION_ES_CDS_MAX_FULL_NAME_LEN]; /**< \brief Processor Unique Name of CDS */ uint8 ByteAlignSpare[3]; /**< \brief Spare bytes to ensure structure size is multiple of 4 bytes */ @@ -1582,9 +1582,9 @@ typedef struct CFE_ES_HousekeepingTlm_Payload uint8 OSALMissionRevision;/**< \cfetlmmnemonic \ES_OSMISSIONREV \brief OS Abstraction Layer MissionRevision Number */ - uint32 SysLogBytesUsed; /**< \cfetlmmnemonic \ES_SYSLOGBYTEUSED + CFE_ES_MemOffset_t SysLogBytesUsed; /**< \cfetlmmnemonic \ES_SYSLOGBYTEUSED \brief Total number of bytes used in system log */ - uint32 SysLogSize; /**< \cfetlmmnemonic \ES_SYSLOGSIZE + CFE_ES_MemOffset_t SysLogSize; /**< \cfetlmmnemonic \ES_SYSLOGSIZE \brief Total size of the system log */ uint32 SysLogEntries; /**< \cfetlmmnemonic \ES_SYSLOGENTRIES \brief Number of entries in the system log */ @@ -1634,11 +1634,11 @@ typedef struct CFE_ES_HousekeepingTlm_Payload \brief Number of Entries Put Into the Performance Analyzer Log */ uint32 PerfDataToWrite; /**< \cfetlmmnemonic \ES_PERFDATA2WRITE \brief Number of Performance Analyzer Log Entries Left to be Written to Log Dump File */ - uint32 HeapBytesFree; /**< \cfetlmmnemonic \ES_HEAPBYTESFREE + CFE_ES_MemOffset_t HeapBytesFree; /**< \cfetlmmnemonic \ES_HEAPBYTESFREE \brief Number of free bytes remaining in the OS heap */ - uint32 HeapBlocksFree; /**< \cfetlmmnemonic \ES_HEAPBLKSFREE + CFE_ES_MemOffset_t HeapBlocksFree; /**< \cfetlmmnemonic \ES_HEAPBLKSFREE \brief Number of free blocks remaining in the OS heap */ - uint32 HeapMaxBlockSize; /**< \cfetlmmnemonic \ES_HEAPMAXBLK + CFE_ES_MemOffset_t HeapMaxBlockSize; /**< \cfetlmmnemonic \ES_HEAPMAXBLK \brief Number of bytes in the largest free block */ } CFE_ES_HousekeepingTlm_Payload_t; diff --git a/fsw/cfe-core/src/inc/cfe_sb.h b/fsw/cfe-core/src/inc/cfe_sb.h index 59b9ac419..607a4d24f 100644 --- a/fsw/cfe-core/src/inc/cfe_sb.h +++ b/fsw/cfe-core/src/inc/cfe_sb.h @@ -120,24 +120,6 @@ #define CFE_CLR(i,x) ((i) &= ~CFE_BIT(x)) /**< \brief Clears bit x of i */ #define CFE_TST(i,x) (((i) & CFE_BIT(x)) != 0)/**< \brief true(non zero) if bit x of i is set */ -/** - * \brief Set memory address within SB Message - * - * Macro that should be used to set memory addresses within software bus messages. - * For now this does a straight copy, but in a future revision this may translate the - * raw memory address into a "safe" integer value. This is particularly important if - * the message is to be sent off this CPU. - */ -#define CFE_SB_SET_MEMADDR(msgdst,src) msgdst = (cpuaddr)src - -/** - * \brief Get memory address from SB Message - * - * Macro that should be used to get memory addresses from software bus messages. - * This is the inverse operation of CFE_SB_SET_MEMADDR. - */ -#define CFE_SB_GET_MEMADDR(msgsrc) (cpuaddr)msgsrc - /* ** Pipe option bit fields. */ @@ -671,7 +653,7 @@ CFE_Status_t CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, CFE_SB_PipeId_t PipeId, int ** ** \sa #CFE_SB_ZeroCopyReleasePtr, #CFE_SB_ZeroCopySend **/ -CFE_SB_Msg_t *CFE_SB_ZeroCopyGetPtr(uint16 MsgSize, +CFE_SB_Msg_t *CFE_SB_ZeroCopyGetPtr(size_t MsgSize, CFE_SB_ZeroCopyHandle_t *BufferHandle); /*****************************************************************************/ @@ -820,7 +802,7 @@ CFE_Status_t CFE_SB_ZeroCopyPass(CFE_SB_Msg_t *MsgPtr, CFE_SB_ZeroCopyHandle_t B **/ void CFE_SB_InitMsg(void *MsgPtr, CFE_SB_MsgId_t MsgId, - uint16 Length, + size_t Length, bool Clear ); /*****************************************************************************/ @@ -868,7 +850,7 @@ void CFE_SB_SetMsgId(CFE_SB_MsgPtr_t MsgPtr, ** \sa #CFE_SB_SetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_SetTotalMsgLength, ** #CFE_SB_SetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_SetCmdCode, #CFE_SB_InitMsg **/ -void CFE_SB_SetUserDataLength(CFE_SB_MsgPtr_t MsgPtr,uint16 DataLength); +void CFE_SB_SetUserDataLength(CFE_SB_MsgPtr_t MsgPtr,size_t DataLength); /*****************************************************************************/ /** @@ -893,7 +875,7 @@ void CFE_SB_SetUserDataLength(CFE_SB_MsgPtr_t MsgPtr,uint16 DataLength); ** \sa #CFE_SB_SetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_GetTotalMsgLength, ** #CFE_SB_SetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_SetCmdCode, #CFE_SB_InitMsg **/ -void CFE_SB_SetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr,uint16 TotalLength); +void CFE_SB_SetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr,size_t TotalLength); /*****************************************************************************/ /** @@ -1007,7 +989,7 @@ CFE_Status_t CFE_SB_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, uint16 CmdCode); ** \return Number of characters copied or error code, see \ref CFEReturnCodes ** */ -int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, uint32 DestMaxSize, uint32 SourceMaxSize); +int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, size_t DestMaxSize, size_t SourceMaxSize); /**@}*/ /** @defgroup CFEAPIGetMessage cFE Getting Message Characteristics APIs @@ -1073,7 +1055,7 @@ CFE_SB_MsgId_t CFE_SB_GetMsgId(const CFE_SB_Msg_t *MsgPtr); ** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_GetTotalMsgLength, ** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum **/ -uint16 CFE_SB_GetUserDataLength(const CFE_SB_Msg_t *MsgPtr); +size_t CFE_SB_GetUserDataLength(const CFE_SB_Msg_t *MsgPtr); /*****************************************************************************/ /** @@ -1094,7 +1076,7 @@ uint16 CFE_SB_GetUserDataLength(const CFE_SB_Msg_t *MsgPtr); ** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_SetTotalMsgLength, ** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum **/ -uint16 CFE_SB_GetTotalMsgLength(const CFE_SB_Msg_t *MsgPtr); +size_t CFE_SB_GetTotalMsgLength(const CFE_SB_Msg_t *MsgPtr); /*****************************************************************************/ /** @@ -1182,7 +1164,7 @@ CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr); ** \return Number of characters copied or error code, see \ref CFEReturnCodes ** */ -int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, const char *DefaultString, uint32 DestMaxSize, uint32 SourceMaxSize); +int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, const char *DefaultString, size_t DestMaxSize, size_t SourceMaxSize); /**@}*/ /** @defgroup CFEAPISBChecksum cFE Checksum Control APIs diff --git a/fsw/cfe-core/src/inc/cfe_tbl.h b/fsw/cfe-core/src/inc/cfe_tbl.h index 4e29481d2..0229ba4ab 100644 --- a/fsw/cfe-core/src/inc/cfe_tbl.h +++ b/fsw/cfe-core/src/inc/cfe_tbl.h @@ -116,7 +116,7 @@ typedef enum CFE_TBL_SrcEnum /** \brief Table Info */ typedef struct CFE_TBL_Info { - uint32 Size; /**< \brief Size, in bytes, of Table */ + size_t Size; /**< \brief Size, in bytes, of Table */ uint32 NumUsers; /**< \brief Number of Apps with access to the table */ uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */ uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */ @@ -265,7 +265,7 @@ typedef struct CFE_TBL_Info **/ CFE_Status_t CFE_TBL_Register(CFE_TBL_Handle_t *TblHandlePtr, /* Returned Handle */ const char *Name, /* Application specific name */ - uint32 Size, /* Size, in bytes, of table */ + size_t Size, /* Size, in bytes, of table */ uint16 TblOptionFlags, /* Tbl Options Settings */ CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr); /* Ptr to func that validates tbl */ diff --git a/fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h b/fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h index 64c80b6de..10c05fa7b 100644 --- a/fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h +++ b/fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h @@ -32,6 +32,7 @@ /* Use the local definitions of these types */ #include "common_types.h" +#include "cfe_es_extern_typedefs.h" #include /* for CFE_MISSION_TBL_MAX_FULL_NAME_LEN */ /** @@ -69,8 +70,8 @@ typedef uint16 CFE_TBL_BufferSelect_En typedef struct CFE_TBL_File_Hdr { uint32 Reserved; /**< Future Use: NumTblSegments in File? */ - uint32 Offset; /**< Byte Offset at which load should commence */ - uint32 NumBytes; /**< Number of bytes to load into table */ + CFE_ES_MemOffset_t Offset; /**< Byte Offset at which load should commence */ + CFE_ES_MemOffset_t NumBytes; /**< Number of bytes to load into table */ char TableName[CFE_MISSION_TBL_MAX_FULL_NAME_LEN]; /**< Fully qualified name of table to load */ } CFE_TBL_File_Hdr_t; diff --git a/fsw/cfe-core/src/inc/cfe_tbl_msg.h b/fsw/cfe-core/src/inc/cfe_tbl_msg.h index b93445fea..13788037d 100644 --- a/fsw/cfe-core/src/inc/cfe_tbl_msg.h +++ b/fsw/cfe-core/src/inc/cfe_tbl_msg.h @@ -772,15 +772,15 @@ typedef struct CFE_TBL_HousekeepingTlm **/ typedef struct CFE_TBL_TblRegPacket_Payload { - uint32 Size; /**< \cfetlmmnemonic \TBL_SIZE + CFE_ES_MemOffset_t Size; /**< \cfetlmmnemonic \TBL_SIZE \brief Size, in bytes, of Table */ uint32 Crc; /**< \cfetlmmnemonic \TBL_CRC \brief Most recently calculated CRC of Table */ - cpuaddr ActiveBufferAddr; /**< \cfetlmmnemonic \TBL_ACTBUFADD + CFE_ES_MemAddress_t ActiveBufferAddr; /**< \cfetlmmnemonic \TBL_ACTBUFADD \brief Address of Active Buffer */ - cpuaddr InactiveBufferAddr; /**< \cfetlmmnemonic \TBL_IACTBUFADD + CFE_ES_MemAddress_t InactiveBufferAddr; /**< \cfetlmmnemonic \TBL_IACTBUFADD \brief Address of Inactive Buffer */ - cpuaddr ValidationFuncPtr; /**< \cfetlmmnemonic \TBL_VALFUNCPTR + CFE_ES_MemAddress_t ValidationFuncPtr; /**< \cfetlmmnemonic \TBL_VALFUNCPTR \brief Ptr to Owner App's function that validates tbl contents */ CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \cfetlmmnemonic \TBL_TIMELASTUPD \brief Time when Table was last updated */ diff --git a/fsw/cfe-core/src/inc/private/cfe_private.h b/fsw/cfe-core/src/inc/private/cfe_private.h index 727c9f62b..a2f1b0152 100644 --- a/fsw/cfe-core/src/inc/private/cfe_private.h +++ b/fsw/cfe-core/src/inc/private/cfe_private.h @@ -303,7 +303,7 @@ extern int32 CFE_TIME_CleanUpApp(CFE_ES_ResourceID_t AppId); ** \return See return codes for #CFE_ES_RegisterCDS ** ******************************************************************************/ -int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, CFE_ES_CDS_Offset_t UserBlockSize, const char *Name, bool CriticalTbl); +int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, const char *Name, bool CriticalTbl); /*****************************************************************************/ /** diff --git a/fsw/cfe-core/src/sb/cfe_sb_api.c b/fsw/cfe-core/src/sb/cfe_sb_api.c index 736fac134..6f114a14d 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_api.c +++ b/fsw/cfe-core/src/sb/cfe_sb_api.c @@ -103,7 +103,7 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * CFE_ES_GetTaskID(&TskId); /* get callers name */ - CFE_ES_GetAppName(AppName, AppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, AppId, sizeof(AppName)); /* Hardcode a NULL terminator, in case rcvd name was too long */ AppName[OS_MAX_API_NAME-1]= '\0'; @@ -1164,7 +1164,7 @@ int32 CFE_SB_SendMsgFull(CFE_SB_Msg_t *MsgPtr, CFE_SB_PipeD_t *PipeDscPtr; CFE_SBR_RouteId_t RouteId; CFE_SB_BufferD_t *BufDscPtr; - uint16 TotalMsgSize; + size_t TotalMsgSize; CFE_ES_ResourceID_t AppId; CFE_ES_ResourceID_t TskId; uint32 i; @@ -1294,7 +1294,7 @@ int32 CFE_SB_SendMsgFull(CFE_SB_Msg_t *MsgPtr, /* Copy the packet into the SB memory space */ if (CopyMode != CFE_SB_SEND_ZEROCOPY){ /* Copy the packet into the SB memory space */ - memcpy( BufDscPtr->Buffer, MsgPtr, (uint16)TotalMsgSize ); + memcpy( BufDscPtr->Buffer, MsgPtr, TotalMsgSize ); } /* For Tlm packets, increment the seq count if requested */ @@ -1583,7 +1583,7 @@ int32 CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, /* * Function: CFE_SB_ZeroCopyGetPtr - See API and header file for details */ -CFE_SB_Msg_t *CFE_SB_ZeroCopyGetPtr(uint16 MsgSize, +CFE_SB_Msg_t *CFE_SB_ZeroCopyGetPtr(size_t MsgSize, CFE_SB_ZeroCopyHandle_t *BufferHandle) { int32 stat1; @@ -1835,7 +1835,7 @@ int32 CFE_SB_ReadQueue (CFE_SB_PipeD_t *PipeDscPtr, CFE_SB_BufferD_t **Message) { int32 Status,TimeOut; - uint32 Nbytes; + size_t Nbytes; char FullName[(OS_MAX_API_NAME * 2)]; char PipeName[OS_MAX_API_NAME] = {'\0'}; diff --git a/fsw/cfe-core/src/sb/cfe_sb_buf.c b/fsw/cfe-core/src/sb/cfe_sb_buf.c index a17a6bdbe..966f16125 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_buf.c +++ b/fsw/cfe-core/src/sb/cfe_sb_buf.c @@ -57,7 +57,7 @@ ** could not be allocated. */ -CFE_SB_BufferD_t * CFE_SB_GetBufferFromPool(CFE_SB_MsgId_t MsgId, uint16 Size) { +CFE_SB_BufferD_t * CFE_SB_GetBufferFromPool(CFE_SB_MsgId_t MsgId, size_t Size) { int32 stat1; uint8 *address = NULL; CFE_SB_BufferD_t *bd = NULL; diff --git a/fsw/cfe-core/src/sb/cfe_sb_init.c b/fsw/cfe-core/src/sb/cfe_sb_init.c index 2a6d25e5f..52ee1bd61 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_init.c +++ b/fsw/cfe-core/src/sb/cfe_sb_init.c @@ -47,7 +47,7 @@ ** External Declarations */ -const CFE_ES_MemOffset_t CFE_SB_MemPoolDefSize[CFE_PLATFORM_ES_POOL_MAX_BUCKETS] = +const size_t CFE_SB_MemPoolDefSize[CFE_PLATFORM_ES_POOL_MAX_BUCKETS] = { CFE_PLATFORM_SB_MAX_BLOCK_SIZE, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_16, diff --git a/fsw/cfe-core/src/sb/cfe_sb_priv.h b/fsw/cfe-core/src/sb/cfe_sb_priv.h index efc015f79..758beca92 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_priv.h +++ b/fsw/cfe-core/src/sb/cfe_sb_priv.h @@ -116,7 +116,7 @@ typedef struct { CFE_SB_MsgId_t MsgId; uint16 UseCount; - uint32 Size; + size_t Size; void *Buffer; } CFE_SB_BufferD_t; @@ -133,7 +133,7 @@ typedef struct { typedef struct { CFE_ES_ResourceID_t AppID; - uint32 Size; + size_t Size; void *Buffer; void *Next; void *Prev; @@ -249,7 +249,7 @@ void CFE_SB_ProcessCmdPipePkt(void); void CFE_SB_ResetCounters(void); void CFE_SB_SetMsgSeqCnt(CFE_SB_MsgPtr_t MsgPtr,uint32 Count); char *CFE_SB_GetAppTskName(CFE_ES_ResourceID_t TaskId, char* FullName); -CFE_SB_BufferD_t *CFE_SB_GetBufferFromPool(CFE_SB_MsgId_t MsgId, uint16 Size); +CFE_SB_BufferD_t *CFE_SB_GetBufferFromPool(CFE_SB_MsgId_t MsgId, size_t Size); CFE_SB_BufferD_t *CFE_SB_GetBufferFromCaller(CFE_SB_MsgId_t MsgId, void *Address); CFE_SB_PipeD_t *CFE_SB_GetPipePtr(CFE_SB_PipeId_t PipeId); CFE_SB_PipeId_t CFE_SB_GetAvailPipeIdx(void); @@ -360,7 +360,7 @@ CFE_SB_DestinationD_t *CFE_SB_GetDestPtr(CFE_SBR_RouteId_t RouteId, CFE_SB_PipeI ** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, ** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum **/ -uint16 CFE_SB_MsgHdrSize(const CFE_SB_Msg_t *MsgPtr); +size_t CFE_SB_MsgHdrSize(const CFE_SB_Msg_t *MsgPtr); /* diff --git a/fsw/cfe-core/src/sb/cfe_sb_task.c b/fsw/cfe-core/src/sb/cfe_sb_task.c index 97c587186..089d1f00d 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_task.c +++ b/fsw/cfe-core/src/sb/cfe_sb_task.c @@ -323,10 +323,10 @@ int32 CFE_SB_AppInit(void){ ** Return: ** true if length is acceptable */ -bool CFE_SB_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength) +bool CFE_SB_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, size_t ExpectedLength) { bool result = true; - uint16 ActualLength = CFE_SB_GetTotalMsgLength(Msg); + size_t ActualLength = CFE_SB_GetTotalMsgLength(Msg); /* ** Verify the command packet length @@ -783,7 +783,7 @@ int32 CFE_SB_SendRoutingInfoCmd(const CFE_SB_SendRoutingInfo_t *data) ptr = &data->Payload; CFE_SB_MessageStringGet(LocalFilename, ptr->Filename, CFE_PLATFORM_SB_DEFAULT_ROUTING_FILENAME, - OS_MAX_PATH_LEN, sizeof(ptr->Filename)); + sizeof(LocalFilename), sizeof(ptr->Filename)); Stat = CFE_SB_SendRtgInfo(LocalFilename); CFE_SB_IncrCmdCtr(Stat); @@ -813,7 +813,7 @@ int32 CFE_SB_SendPipeInfoCmd(const CFE_SB_SendPipeInfo_t *data) ptr = &data->Payload; CFE_SB_MessageStringGet(LocalFilename, ptr->Filename, CFE_PLATFORM_SB_DEFAULT_PIPE_FILENAME, - OS_MAX_PATH_LEN, sizeof(ptr->Filename)); + sizeof(LocalFilename), sizeof(ptr->Filename)); Stat = CFE_SB_SendPipeInfo(LocalFilename); CFE_SB_IncrCmdCtr(Stat); @@ -843,7 +843,7 @@ int32 CFE_SB_SendMapInfoCmd(const CFE_SB_SendMapInfo_t *data) ptr = &data->Payload; CFE_SB_MessageStringGet(LocalFilename, ptr->Filename, CFE_PLATFORM_SB_DEFAULT_MAP_FILENAME, - OS_MAX_PATH_LEN, sizeof(ptr->Filename)); + sizeof(LocalFilename), sizeof(ptr->Filename)); Stat = CFE_SB_SendMapInfo(LocalFilename); diff --git a/fsw/cfe-core/src/sb/cfe_sb_util.c b/fsw/cfe-core/src/sb/cfe_sb_util.c index 6086f22b1..62cbb5f4a 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_util.c +++ b/fsw/cfe-core/src/sb/cfe_sb_util.c @@ -47,7 +47,7 @@ */ void CFE_SB_InitMsg(void *MsgPtr, CFE_SB_MsgId_t MsgId, - uint16 Length, + size_t Length, bool Clear ) { @@ -67,10 +67,9 @@ void CFE_SB_InitMsg(void *MsgPtr, ** Return: ** Size of Message Header. */ -uint16 CFE_SB_MsgHdrSize(const CFE_SB_Msg_t *MsgPtr) +size_t CFE_SB_MsgHdrSize(const CFE_SB_Msg_t *MsgPtr) { - - uint16 size = 0; + size_t size = 0; bool hassechdr = false; CFE_MSG_Type_t type = CFE_MSG_Type_Invalid; @@ -103,7 +102,7 @@ uint16 CFE_SB_MsgHdrSize(const CFE_SB_Msg_t *MsgPtr) void *CFE_SB_GetUserData(CFE_SB_MsgPtr_t MsgPtr) { uint8 *BytePtr; - uint16 HdrSize; + size_t HdrSize; BytePtr = (uint8 *)MsgPtr; HdrSize = CFE_SB_MsgHdrSize(MsgPtr); @@ -115,24 +114,25 @@ void *CFE_SB_GetUserData(CFE_SB_MsgPtr_t MsgPtr) /* * Function: CFE_SB_GetUserDataLength - See API and header file for details */ -uint16 CFE_SB_GetUserDataLength(const CFE_SB_Msg_t *MsgPtr) +size_t CFE_SB_GetUserDataLength(const CFE_SB_Msg_t *MsgPtr) { - uint32 TotalMsgSize; - uint16 HdrSize; + CFE_MSG_Size_t TotalMsgSize; + size_t HdrSize; CFE_MSG_GetSize(MsgPtr, &TotalMsgSize); HdrSize = CFE_SB_MsgHdrSize(MsgPtr); - return (TotalMsgSize - HdrSize); + return TotalMsgSize - HdrSize; }/* end CFE_SB_GetUserDataLength */ /* * Function: CFE_SB_SetUserDataLength - See API and header file for details */ -void CFE_SB_SetUserDataLength(CFE_SB_MsgPtr_t MsgPtr, uint16 DataLength) +void CFE_SB_SetUserDataLength(CFE_SB_MsgPtr_t MsgPtr, size_t DataLength) { - uint32 TotalMsgSize, HdrSize; + CFE_MSG_Size_t TotalMsgSize; + size_t HdrSize; HdrSize = CFE_SB_MsgHdrSize(MsgPtr); TotalMsgSize = HdrSize + DataLength; @@ -144,15 +144,14 @@ void CFE_SB_SetUserDataLength(CFE_SB_MsgPtr_t MsgPtr, uint16 DataLength) /* * Function: CFE_SB_GetTotalMsgLength - See API and header file for details */ -uint16 CFE_SB_GetTotalMsgLength(const CFE_SB_Msg_t *MsgPtr) +size_t CFE_SB_GetTotalMsgLength(const CFE_SB_Msg_t *MsgPtr) { CFE_MSG_Size_t size; CFE_MSG_GetSize(MsgPtr, &size); - /* Known bug that this API can't return maximum ccsds size */ - return (uint16)size; + return size; }/* end CFE_SB_GetTotalMsgLength */ @@ -160,7 +159,7 @@ uint16 CFE_SB_GetTotalMsgLength(const CFE_SB_Msg_t *MsgPtr) /* * Function: CFE_SB_SetTotalMsgLength - See API and header file for details */ -void CFE_SB_SetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr,uint16 TotalLength) +void CFE_SB_SetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr,size_t TotalLength) { CFE_MSG_SetSize(MsgPtr, TotalLength); @@ -279,7 +278,7 @@ bool CFE_SB_ValidateChecksum(CFE_SB_MsgPtr_t MsgPtr) /* * Function: CFE_SB_MessageStringGet - See API and header file for details */ -int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, const char *DefaultString, uint32 DestMaxSize, uint32 SourceMaxSize) +int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, const char *DefaultString, size_t DestMaxSize, size_t SourceMaxSize) { int32 Result; @@ -331,7 +330,7 @@ int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, /* * Function: CFE_SB_MessageStringSet - See API and header file for details */ -int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, uint32 DestMaxSize, uint32 SourceMaxSize) +int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, size_t DestMaxSize, size_t SourceMaxSize) { int32 Result; diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_api.c b/fsw/cfe-core/src/tbl/cfe_tbl_api.c index b28e72232..c032c938b 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_api.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_api.c @@ -50,7 +50,7 @@ */ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, const char *Name, - uint32 Size, + size_t Size, uint16 TblOptionFlags, CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr ) { @@ -368,7 +368,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, /* possible at this point during table registration. But we */ /* do need to handle the error case because if the function */ /* call did fail, WorkingBufferPtr would be a NULL pointer. */ - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); CFE_ES_WriteToSysLog("CFE_TBL:Register-Failed to get work buffer for '%s.%s' (ErrCode=0x%08X)\n", AppName, Name, (unsigned int)Status); } @@ -379,7 +379,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, if (Status != CFE_SUCCESS) { - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); CFE_ES_WriteToSysLog("CFE_TBL:Register-Failed to recover '%s.%s' from CDS (ErrCode=0x%08X)\n", AppName, Name, (unsigned int)Status); } @@ -422,7 +422,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, { /* If an error occurred while trying to get the previous contents registry info, */ /* Log the error in the System Log and pretend like we created a new CDS */ - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); CFE_ES_WriteToSysLog("CFE_TBL:Register-Failed to recover '%s.%s' info from CDS TblReg\n", AppName, Name); Status = CFE_SUCCESS; @@ -490,7 +490,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, *TblHandlePtr = CFE_TBL_BAD_TABLE_HANDLE; /* Translate AppID of caller into App Name */ - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); CFE_EVS_SendEventWithAppID(CFE_TBL_REGISTER_ERR_EID, CFE_EVS_EventType_ERROR, @@ -589,7 +589,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, if (Status < 0) { /* Translate AppID of caller into App Name */ - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); CFE_EVS_SendEventWithAppID(CFE_TBL_SHARE_ERR_EID, CFE_EVS_EventType_ERROR, @@ -653,7 +653,7 @@ int32 CFE_TBL_Unregister ( CFE_TBL_Handle_t TblHandle ) if (Status < 0) { /* Translate AppID of caller into App Name */ - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); CFE_EVS_SendEventWithAppID(CFE_TBL_UNREGISTER_ERR_EID, CFE_EVS_EventType_ERROR, @@ -702,7 +702,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; /* Translate AppID of caller into App Name */ - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); /* Initialize return pointer to NULL */ WorkingBufferPtr = NULL; @@ -941,7 +941,7 @@ int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ) if (Status != CFE_TBL_ERR_BAD_APP_ID) { /* Translate AppID of caller into App Name */ - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); } /* On Error conditions, notify ground of screw up */ @@ -1142,7 +1142,7 @@ int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ) AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); /* Identify the image to be validated, starting with the Inactive Buffer */ if (RegRecPtr->ValidateInactiveIndex != CFE_TBL_NO_VALIDATION_PENDING) diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c index d5334759d..e7b861fe8 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c @@ -156,7 +156,7 @@ int32 CFE_TBL_EarlyInit (void) /* Initialize memory partition and allocate shared table buffers. */ Status = CFE_ES_PoolCreate(&CFE_TBL_TaskData.Buf.PoolHdl, CFE_TBL_TaskData.Buf.Partition.Data, - CFE_PLATFORM_TBL_BUF_MEMORY_BYTES); + sizeof(CFE_TBL_TaskData.Buf.Partition)); if(Status < 0) { @@ -682,7 +682,7 @@ void CFE_TBL_FormTableName(char *FullTblName, const char *TblName, CFE_ES_Resour { char AppName[OS_MAX_API_NAME]; - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); /* Ensure that AppName is null terminated */ AppName[OS_MAX_API_NAME-1] = '\0'; diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task.c b/fsw/cfe-core/src/tbl/cfe_tbl_task.c index d1b4ffa59..8e44405a3 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task.c @@ -265,7 +265,7 @@ void CFE_TBL_TaskPipe(CFE_SB_Msg_t *MessagePtr) CFE_SB_MsgId_t MessageID = CFE_SB_GetMsgId(MessagePtr); uint16 CommandCode = CFE_SB_GetCmdCode(MessagePtr); int16 CmdIndx; - uint32 ActualLength; + size_t ActualLength; CFE_TBL_CmdProcRet_t CmdStatus = CFE_TBL_INC_ERR_CTR; /* Assume a failed command */ /* Search the Command Handler Table for a matching message */ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task.h b/fsw/cfe-core/src/tbl/cfe_tbl_task.h index 96af49979..ae1c794c2 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task.h +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task.h @@ -185,7 +185,7 @@ typedef struct typedef struct { CFE_ES_ResourceID_t OwnerAppId; /**< \brief Application ID of App that Registered Table */ - uint32 Size; /**< \brief Size, in bytes, of Table */ + size_t Size; /**< \brief Size, in bytes, of Table */ CFE_SB_MsgId_t NotificationMsgId; /**< \brief Message ID of an associated management notification message */ uint32 NotificationParam; /**< \brief Parameter of an associated management notification message */ CFE_TBL_LoadBuff_t Buffers[2]; /**< \brief Active and Inactive Buffer Pointers */ @@ -238,7 +238,7 @@ typedef struct typedef struct { CFE_TBL_DumpState_t State; /**< \brief Current state of this block of data */ - uint32 Size; /**< \brief Number of bytes to be dumped */ + size_t Size; /**< \brief Number of bytes to be dumped */ CFE_TBL_LoadBuff_t *DumpBufferPtr; /**< \brief Address where dumped data is to be stored temporarily */ CFE_TBL_RegistryRec_t *RegRecPtr; /**< \brief Ptr to dumped table's registry record */ char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Name of Table being Dumped */ @@ -253,7 +253,7 @@ typedef struct */ typedef struct { - uint32 Size; /**< \brief Size, in bytes, of Table */ + CFE_ES_MemOffset_t Size; /**< \brief Size, in bytes, of Table */ CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */ uint32 NumUsers; /**< \brief Number of applications that are sharing the table */ int32 LoadInProgress; /**< \brief Flag identifies inactive buffer and whether load in progress */ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c index 39048e696..2dd688b47 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c @@ -274,31 +274,31 @@ void CFE_TBL_GetTblRegData(void) RegRecPtr = &CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.HkTlmTblRegIndex]; - CFE_TBL_TaskData.TblRegPacket.Payload.Size = RegRecPtr->Size; - CFE_SB_SET_MEMADDR(CFE_TBL_TaskData.TblRegPacket.Payload.ActiveBufferAddr, - RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].BufferPtr); + CFE_TBL_TaskData.TblRegPacket.Payload.Size = CFE_ES_MEMOFFSET_C(RegRecPtr->Size); + CFE_TBL_TaskData.TblRegPacket.Payload.ActiveBufferAddr = + CFE_ES_MEMADDRESS_C(RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].BufferPtr); if (RegRecPtr->DoubleBuffered) { /* For a double buffered table, the inactive is the other allocated buffer */ - CFE_SB_SET_MEMADDR(CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr, - RegRecPtr->Buffers[(1U-RegRecPtr->ActiveBufferIndex)].BufferPtr); + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = + CFE_ES_MEMADDRESS_C(RegRecPtr->Buffers[(1U-RegRecPtr->ActiveBufferIndex)].BufferPtr); } else { /* Check to see if an inactive buffer has currently been allocated to the single buffered table */ if (RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS) { - CFE_SB_SET_MEMADDR(CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr, - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr); + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = + CFE_ES_MEMADDRESS_C(CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr); } else { - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = 0; + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); } } - CFE_SB_SET_MEMADDR(CFE_TBL_TaskData.TblRegPacket.Payload.ValidationFuncPtr, RegRecPtr->ValidationFuncPtr); + CFE_TBL_TaskData.TblRegPacket.Payload.ValidationFuncPtr = CFE_ES_MEMADDRESS_C(RegRecPtr->ValidationFuncPtr); CFE_TBL_TaskData.TblRegPacket.Payload.TimeOfLastUpdate = RegRecPtr->TimeOfLastUpdate; CFE_TBL_TaskData.TblRegPacket.Payload.TableLoadedOnce = RegRecPtr->TableLoadedOnce; CFE_TBL_TaskData.TblRegPacket.Payload.LoadPending = RegRecPtr->LoadPending; @@ -382,7 +382,7 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_Load_t *data) /* Make sure all strings are null terminated before attempting to process them */ CFE_SB_MessageStringGet(LoadFilename, (char *)CmdPtr->LoadFilename, NULL, - OS_MAX_PATH_LEN, sizeof(CmdPtr->LoadFilename)); + sizeof(LoadFilename), sizeof(CmdPtr->LoadFilename)); /* Try to open the specified table file */ Status = OS_OpenCreate(&FileDescriptor, LoadFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY); @@ -588,10 +588,10 @@ int32 CFE_TBL_DumpCmd(const CFE_TBL_Dump_t *data) /* Make sure all strings are null terminated before attempting to process them */ CFE_SB_MessageStringGet(DumpFilename, (char *)CmdPtr->DumpFilename, NULL, - OS_MAX_PATH_LEN, sizeof(CmdPtr->DumpFilename)); + sizeof(DumpFilename), sizeof(CmdPtr->DumpFilename)); CFE_SB_MessageStringGet(TableName, (char *)CmdPtr->TableName, NULL, - CFE_TBL_MAX_FULL_NAME_LEN, sizeof(CmdPtr->TableName)); + sizeof(TableName), sizeof(CmdPtr->TableName)); /* Before doing anything, lets make sure the table that is to be dumped exists */ RegIndex = CFE_TBL_FindTableInRegistry(TableName); @@ -730,7 +730,7 @@ int32 CFE_TBL_DumpCmd(const CFE_TBL_Dump_t *data) ** NOTE: For complete prolog information, see prototype above ********************************************************************/ -CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *TableName, const void *DumpDataAddr, uint32 TblSizeInBytes) +CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *TableName, const void *DumpDataAddr, size_t TblSizeInBytes) { CFE_TBL_CmdProcRet_t ReturnCode = CFE_TBL_INC_ERR_CTR; /* Assume failure */ bool FileExistedPrev = false; @@ -769,8 +769,8 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *T /* Initialize the Table Image Header for the Dump File */ strncpy(TblFileHeader.TableName, TableName, sizeof(TblFileHeader.TableName)-1); TblFileHeader.TableName[sizeof(TblFileHeader.TableName)-1] = 0; - TblFileHeader.Offset = 0; - TblFileHeader.NumBytes = TblSizeInBytes; + TblFileHeader.Offset = CFE_ES_MEMOFFSET_C(0); + TblFileHeader.NumBytes = CFE_ES_MEMOFFSET_C(TblSizeInBytes); TblFileHeader.Reserved = 0; /* Determine if this is a little endian processor */ @@ -795,7 +795,7 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *T DumpDataAddr, TblSizeInBytes); - if (Status == (int32)TblSizeInBytes) + if (Status == TblSizeInBytes) { if (FileExistedPrev) { @@ -878,7 +878,7 @@ int32 CFE_TBL_ValidateCmd(const CFE_TBL_Validate_t *data) /* Make sure all strings are null terminated before attempting to process them */ CFE_SB_MessageStringGet(TableName, (char *)CmdPtr->TableName, NULL, - CFE_TBL_MAX_FULL_NAME_LEN, sizeof(CmdPtr->TableName)); + sizeof(TableName), sizeof(CmdPtr->TableName)); /* Before doing anything, lets make sure the table that is to be dumped exists */ RegIndex = CFE_TBL_FindTableInRegistry(TableName); @@ -1034,7 +1034,7 @@ int32 CFE_TBL_ActivateCmd(const CFE_TBL_Activate_t *data) /* Make sure all strings are null terminated before attempting to process them */ CFE_SB_MessageStringGet(TableName, (char *)CmdPtr->TableName, NULL, - CFE_TBL_MAX_FULL_NAME_LEN, sizeof(CmdPtr->TableName)); + sizeof(TableName), sizeof(CmdPtr->TableName)); /* Before doing anything, lets make sure the table that is to be dumped exists */ RegIndex = CFE_TBL_FindTableInRegistry(TableName); @@ -1133,7 +1133,7 @@ int32 CFE_TBL_DumpRegistryCmd(const CFE_TBL_DumpRegistry_t *data) /* Copy the commanded filename into local buffer to ensure size limitation and to allow for modification */ CFE_SB_MessageStringGet(DumpFilename, (char *)CmdPtr->DumpFilename, CFE_PLATFORM_TBL_DEFAULT_REG_DUMP_FILE, - OS_MAX_PATH_LEN, sizeof(CmdPtr->DumpFilename)); + sizeof(DumpFilename), sizeof(CmdPtr->DumpFilename)); /* Check to see if the dump file already exists */ Status = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY); @@ -1172,7 +1172,7 @@ int32 CFE_TBL_DumpRegistryCmd(const CFE_TBL_DumpRegistry_t *data) (RegRecPtr->HeadOfAccessList != CFE_TBL_END_OF_LIST)) { /* Fill Registry Dump Record with relevant information */ - DumpRecord.Size = RegRecPtr->Size; + DumpRecord.Size = CFE_ES_MEMOFFSET_C(RegRecPtr->Size); DumpRecord.TimeOfLastUpdate = RegRecPtr->TimeOfLastUpdate; DumpRecord.LoadInProgress = RegRecPtr->LoadInProgress; DumpRecord.ValidationFunc = (RegRecPtr->ValidationFuncPtr != NULL); @@ -1310,7 +1310,7 @@ int32 CFE_TBL_SendRegistryCmd(const CFE_TBL_SendRegistry_t *data) /* Make sure all strings are null terminated before attempting to process them */ CFE_SB_MessageStringGet(TableName, (char *)CmdPtr->TableName, NULL, - CFE_TBL_MAX_FULL_NAME_LEN, sizeof(CmdPtr->TableName)); + sizeof(TableName), sizeof(CmdPtr->TableName)); /* Before doing anything, lets make sure the table registry entry that is to be telemetered exists */ RegIndex = CFE_TBL_FindTableInRegistry(TableName); @@ -1360,7 +1360,7 @@ int32 CFE_TBL_DeleteCDSCmd(const CFE_TBL_DeleteCDS_t *data) /* Make sure all strings are null terminated before attempting to process them */ CFE_SB_MessageStringGet(TableName, (char *)CmdPtr->TableName, NULL, - CFE_TBL_MAX_FULL_NAME_LEN, sizeof(CmdPtr->TableName)); + sizeof(TableName), sizeof(CmdPtr->TableName)); /* Before doing anything, lets make sure the table is no longer in the registry */ /* This would imply that the owning application has been terminated and that it */ @@ -1456,7 +1456,7 @@ int32 CFE_TBL_AbortLoadCmd(const CFE_TBL_AbortLoad_t *data) /* Make sure all strings are null terminated before attempting to process them */ CFE_SB_MessageStringGet(TableName, (char *)CmdPtr->TableName, NULL, - CFE_TBL_MAX_FULL_NAME_LEN, sizeof(CmdPtr->TableName)); + sizeof(TableName), sizeof(CmdPtr->TableName)); /* Before doing anything, lets make sure the table registry entry that is to be telemetered exists */ RegIndex = CFE_TBL_FindTableInRegistry(TableName); diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h index c2f4f1aeb..f95fa43c5 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h @@ -73,7 +73,7 @@ typedef enum typedef struct { CFE_SB_MsgId_t MsgId; /**< \brief Acceptable Message ID */ uint32 CmdCode; /**< \brief Acceptable Command Code (if necessary) */ - uint32 ExpectedLength; /**< \brief Expected Message Length (in bytes) including message header */ + size_t ExpectedLength; /**< \brief Expected Message Length (in bytes) including message header */ CFE_TBL_MsgProcFuncPtr_t MsgProcFuncPtr; /**< \brief Pointer to function to handle message */ CFE_TBL_MsgType_t MsgTypes; /**< \brief Message Type (i.e. - with/without Cmd Code) */ } CFE_TBL_CmdHandlerTblRec_t; @@ -329,7 +329,7 @@ int32 CFE_TBL_AbortLoadCmd(const CFE_TBL_AbortLoad_t *data); ** \retval #CFE_TBL_INC_CMD_CTR \copydoc CFE_TBL_INC_CMD_CTR ******************************************************************************/ extern CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *TableName, - const void *DumpDataAddr, uint32 TblSizeInBytes); + const void *DumpDataAddr, size_t TblSizeInBytes); /*****************************************************************************/ /** diff --git a/fsw/cfe-core/src/time/cfe_time_task.c b/fsw/cfe-core/src/time/cfe_time_task.c index 0f7ef3a50..a080c516a 100644 --- a/fsw/cfe-core/src/time/cfe_time_task.c +++ b/fsw/cfe-core/src/time/cfe_time_task.c @@ -427,10 +427,10 @@ int32 CFE_TIME_TaskInit(void) ** Return: ** true if length is acceptable */ -bool CFE_TIME_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength) +bool CFE_TIME_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, size_t ExpectedLength) { bool result = true; - uint16 ActualLength = CFE_SB_GetTotalMsgLength(Msg); + size_t ActualLength = CFE_SB_GetTotalMsgLength(Msg); /* ** Verify the command packet length diff --git a/fsw/cfe-core/src/time/cfe_time_utils.h b/fsw/cfe-core/src/time/cfe_time_utils.h index d89f19350..bb0ee47f5 100644 --- a/fsw/cfe-core/src/time/cfe_time_utils.h +++ b/fsw/cfe-core/src/time/cfe_time_utils.h @@ -62,7 +62,7 @@ */ #define CFE_TIME_TASK_TONE_NAME "TIME_TONE_TASK" #define CFE_TIME_TASK_1HZ_NAME "TIME_1HZ_TASK" -#define CFE_TIME_TASK_STACK_PTR 0 +#define CFE_TIME_TASK_STACK_PTR CFE_ES_TASK_STACK_ALLOCATE #define CFE_TIME_TASK_FLAGS 0 /* diff --git a/fsw/cfe-core/unit-test/es_UT.c b/fsw/cfe-core/unit-test/es_UT.c index b0416ad2a..1fb73a022 100644 --- a/fsw/cfe-core/unit-test/es_UT.c +++ b/fsw/cfe-core/unit-test/es_UT.c @@ -42,6 +42,18 @@ #define ES_UT_CDS_BLOCK_SIZE 16 +/* + * A size which meets the minimum CDS size + * requirements for the implementation, but + * not much larger. + */ +#define ES_UT_CDS_SMALL_TEST_SIZE (56 * 1024) + +/* + * A size which has room for actual allocations + */ +#define ES_UT_CDS_LARGE_TEST_SIZE (128 * 1024) + extern CFE_ES_PerfData_t *Perf; extern CFE_ES_Global_t CFE_ES_Global; extern CFE_ES_TaskData_t CFE_ES_TaskData; @@ -261,7 +273,7 @@ void ES_UT_SetupSingleAppId(CFE_ES_AppType_Enum_t AppType, CFE_ES_AppState_Enum_ CFE_ES_AppRecord_t *LocalAppPtr; CFE_ES_TaskRecord_t *LocalTaskPtr; - OS_TaskCreate(&UtOsalId, "UT", NULL, NULL, 0, 0, 0); + OS_TaskCreate(&UtOsalId, "UT", NULL, OSAL_TASK_STACK_ALLOCATE, 0, 0, 0); UtTaskId = CFE_ES_ResourceID_FromOSAL(UtOsalId); UtAppId = CFE_ES_Global.LastAppId; CFE_ES_Global.LastAppId = CFE_ES_ResourceID_FromInteger( @@ -302,6 +314,9 @@ void ES_UT_SetupSingleAppId(CFE_ES_AppType_Enum_t AppType, CFE_ES_AppState_Enum_ if (AppType == CFE_ES_AppType_EXTERNAL) { ++CFE_ES_Global.RegisteredExternalApps; + + OS_ModuleLoad(&UtOsalId, NULL, NULL, 0); + LocalAppPtr->ModuleInfo.ModuleId = UtOsalId; } ++CFE_ES_Global.RegisteredTasks; } @@ -320,7 +335,7 @@ void ES_UT_SetupChildTaskId(const CFE_ES_AppRecord_t *ParentApp, const char *Tas UtAppId = CFE_ES_AppRecordGetID(ParentApp); - OS_TaskCreate(&UtOsalId, "C", NULL, NULL, 0, 0, 0); + OS_TaskCreate(&UtOsalId, "C", NULL, OSAL_TASK_STACK_ALLOCATE, 0, 0, 0); UtTaskId = CFE_ES_ResourceID_FromOSAL(UtOsalId); LocalTaskPtr = CFE_ES_LocateTaskRecordByID(UtTaskId); @@ -373,20 +388,20 @@ void ES_UT_SetupSingleLibId(const char *LibName, CFE_ES_LibRecord_t **OutLibRec) ++CFE_ES_Global.RegisteredLibs; } -int32 ES_UT_PoolDirectRetrieve(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_MemOffset_t Offset, +int32 ES_UT_PoolDirectRetrieve(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t Offset, CFE_ES_GenPoolBD_t **BdPtr) { *BdPtr = (CFE_ES_GenPoolBD_t*)((void*)&UT_MemPoolDirectBuffer.Data[Offset]); return CFE_SUCCESS; } -int32 ES_UT_PoolDirectCommit(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_MemOffset_t Offset, +int32 ES_UT_PoolDirectCommit(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t Offset, const CFE_ES_GenPoolBD_t *BdPtr) { return CFE_SUCCESS; } -int32 ES_UT_PoolIndirectRetrieve(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_MemOffset_t Offset, +int32 ES_UT_PoolIndirectRetrieve(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t Offset, CFE_ES_GenPoolBD_t **BdPtr) { memcpy(&UT_MemPoolIndirectBuffer.BD, &UT_MemPoolIndirectBuffer.Data[Offset], sizeof(CFE_ES_GenPoolBD_t)); @@ -394,14 +409,14 @@ int32 ES_UT_PoolIndirectRetrieve(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_MemO return CFE_SUCCESS; } -int32 ES_UT_PoolIndirectCommit(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_MemOffset_t Offset, +int32 ES_UT_PoolIndirectCommit(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t Offset, const CFE_ES_GenPoolBD_t *BdPtr) { memcpy(&UT_MemPoolIndirectBuffer.Data[Offset], BdPtr, sizeof(CFE_ES_GenPoolBD_t)); return CFE_SUCCESS; } -int32 ES_UT_CDSPoolRetrieve(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_MemOffset_t Offset, +int32 ES_UT_CDSPoolRetrieve(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t Offset, CFE_ES_GenPoolBD_t **BdPtr) { static CFE_ES_GenPoolBD_t BdBuf; @@ -410,7 +425,7 @@ int32 ES_UT_CDSPoolRetrieve(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_MemOffset return CFE_PSP_ReadFromCDS(&BdBuf, Offset, sizeof(BdBuf)); } -int32 ES_UT_CDSPoolCommit(CFE_ES_GenPoolRecord_t *PoolRecPtr, CFE_ES_MemOffset_t Offset, +int32 ES_UT_CDSPoolCommit(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t Offset, const CFE_ES_GenPoolBD_t *BdPtr) { return CFE_PSP_WriteToCDS(BdPtr, Offset, sizeof(*BdPtr)); @@ -468,13 +483,13 @@ void ES_UT_SetupCDSGlobal(uint32 CDS_Size) } -void ES_UT_SetupSingleCDSRegistry(const char *CDSName, CFE_ES_MemOffset_t BlockSize, bool IsTable, +void ES_UT_SetupSingleCDSRegistry(const char *CDSName, size_t BlockSize, bool IsTable, CFE_ES_CDS_RegRec_t **OutRegRec) { CFE_ES_CDS_RegRec_t *LocalRegRecPtr; CFE_ES_ResourceID_t UtCDSID; CFE_ES_GenPoolBD_t LocalBD; - uint32 UT_CDS_BufferSize; + size_t UT_CDS_BufferSize; /* first time this is done, set up the global */ @@ -554,7 +569,7 @@ int32 ES_UT_SetupOSCleanupHook(void *UserObj, int32 StubRetcode, */ if (CallCount == 0) { - OS_TaskCreate(&ObjList[0], NULL, NULL, NULL, 0, 0, 0); + OS_TaskCreate(&ObjList[0], NULL, NULL, OSAL_TASK_STACK_ALLOCATE, 0, 0, 0); OS_QueueCreate(&ObjList[1], NULL, 0, 0, 0); OS_MutSemCreate(&ObjList[2], NULL, 0); OS_BinSemCreate(&ObjList[3], NULL, 0, 0); @@ -1494,7 +1509,6 @@ void TestApps(void) UtAppRecPtr->StartParams.Priority = 255; UtAppRecPtr->StartParams.StackSize = 8192; UtAppRecPtr->StartParams.ExceptionAction = 0; - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_EXIT; Id = CFE_ES_AppRecordGetID(UtAppRecPtr); @@ -1511,7 +1525,6 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_EXIT; UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_ProcessControlRequest(Id); UT_Report(__FILE__, __LINE__, @@ -1527,7 +1540,6 @@ void TestApps(void) UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_DELETE; UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_ProcessControlRequest(Id); UT_Report(__FILE__, __LINE__, @@ -1543,7 +1555,6 @@ void TestApps(void) UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RESTART; UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_ProcessControlRequest(Id); UT_Report(__FILE__, __LINE__, @@ -1558,7 +1569,6 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RESTART; - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UT_SetForceFail(UT_KEY(OS_TaskCreate), OS_ERROR); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_ProcessControlRequest(Id); @@ -1574,7 +1584,6 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RELOAD; - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_ProcessControlRequest(Id); @@ -1590,7 +1599,6 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RELOAD; - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UT_SetForceFail(UT_KEY(OS_TaskCreate), OS_ERROR); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_ProcessControlRequest(Id); @@ -1614,7 +1622,6 @@ void TestApps(void) UtAppRecPtr->StartParams.Priority = 255; UtAppRecPtr->StartParams.StackSize = 8192; UtAppRecPtr->StartParams.ExceptionAction = 0; - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_ERROR; Id = CFE_ES_AppRecordGetID(UtAppRecPtr); @@ -1632,7 +1639,6 @@ void TestApps(void) UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_ERROR; - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_ProcessControlRequest(Id); UT_Report(__FILE__, __LINE__, @@ -1655,7 +1661,6 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_DELETE; - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_ProcessControlRequest(Id); UT_Report(__FILE__, __LINE__, @@ -1678,7 +1683,6 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RESTART; - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_ProcessControlRequest(Id); UT_Report(__FILE__, __LINE__, @@ -1701,7 +1705,6 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RELOAD; - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_ProcessControlRequest(Id); UT_Report(__FILE__, __LINE__, @@ -1726,7 +1729,6 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_EXCEPTION; - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_ProcessControlRequest(Id); UT_Report(__FILE__, __LINE__, @@ -1795,7 +1797,6 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); ES_UT_SetupForOSCleanup(); - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UT_SetForceFail(UT_KEY(OS_TaskDelete), OS_ERROR); UT_SetForceFail(UT_KEY(OS_close), OS_ERROR); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); @@ -1809,7 +1810,6 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, NULL); ES_UT_SetupForOSCleanup(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemDelete), 1, OS_ERROR); @@ -1824,7 +1824,6 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UT_SetDeferredRetcode(UT_KEY(OS_ModuleUnload), 1, OS_ERROR); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, @@ -1837,7 +1836,6 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, @@ -2009,12 +2007,10 @@ void TestApps(void) ES_ResetUnitTest(); /* Setup an entry which will be deleted */ ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); /* Setup a second entry which will NOT be deleted */ ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); ES_UT_SetupMemPoolId(&UtPoolRecPtr); UtPoolRecPtr->OwnerAppID = CFE_ES_AppRecordGetID(UtAppRecPtr); - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); /* Associate a child task with the app to be deleted */ ES_UT_SetupChildTaskId(UtAppRecPtr, NULL, NULL); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); @@ -2037,7 +2033,6 @@ void TestApps(void) ES_ResetUnitTest(); /* Setup an entry which will be deleted */ ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); ES_UT_SetupMemPoolId(&UtPoolRecPtr); UtPoolRecPtr->OwnerAppID = CFE_ES_AppRecordGetID(UtAppRecPtr); UtPoolRecPtr->PoolID = CFE_ES_ResourceID_FromInteger(99999); /* Mismatch */ @@ -2058,10 +2053,8 @@ void TestApps(void) /* Setup an entry which will be deleted */ ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); /* Setup a second entry which will NOT be deleted */ ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); /* Associate a child task with the app to be deleted */ ES_UT_SetupChildTaskId(UtAppRecPtr, NULL, NULL); @@ -2116,9 +2109,6 @@ void TestApps(void) /* Setup an entry which will be deleted */ ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, &UtTaskRecPtr); - - OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, "UT", - "ut-module", 0); Id = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, CFE_ES_CleanUpApp(Id) == CFE_SUCCESS && @@ -2385,19 +2375,19 @@ void TestGenericPool(void) { CFE_ES_GenPoolRecord_t Pool1; CFE_ES_GenPoolRecord_t Pool2; - CFE_ES_MemOffset_t Offset1; - CFE_ES_MemOffset_t Offset2; - CFE_ES_MemOffset_t Offset3; - CFE_ES_MemOffset_t Offset4; - CFE_ES_MemOffset_t OffsetEnd; - CFE_ES_MemOffset_t BlockSize; + size_t Offset1; + size_t Offset2; + size_t Offset3; + size_t Offset4; + size_t OffsetEnd; + size_t BlockSize; CFE_ES_MemOffset_t FreeSize; CFE_ES_MemOffset_t TotalSize; uint16 NumBlocks; uint32 CountBuf; uint32 ErrBuf; CFE_ES_BlockStats_t BlockStats; - static const CFE_ES_MemOffset_t UT_POOL_BLOCK_SIZES[CFE_PLATFORM_ES_POOL_MAX_BUCKETS] = + static const size_t UT_POOL_BLOCK_SIZES[CFE_PLATFORM_ES_POOL_MAX_BUCKETS] = { /* * These are intentionally in a mixed order @@ -2871,7 +2861,7 @@ void TestTask(void) memset(CmdBuf.StartAppCmd.Payload.Application, 'x', sizeof(CmdBuf.StartAppCmd.Payload.Application)); CmdBuf.StartAppCmd.Payload.Priority = 160; - CmdBuf.StartAppCmd.Payload.StackSize = 8192; + CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(8192); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CFE_ES_StartApp_t), UT_TPID_CFE_ES_CMD_START_APP_CC); @@ -2900,7 +2890,7 @@ void TestTask(void) strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "appName", sizeof(CmdBuf.StartAppCmd.Payload.Application)); CmdBuf.StartAppCmd.Payload.Priority = 160; - CmdBuf.StartAppCmd.Payload.StackSize = 12096; + CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(12096); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CFE_ES_StartApp_t), UT_TPID_CFE_ES_CMD_START_APP_CC); @@ -2919,7 +2909,7 @@ void TestTask(void) strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "appName", sizeof(CmdBuf.StartAppCmd.Payload.Application)); CmdBuf.StartAppCmd.Payload.Priority = 160; - CmdBuf.StartAppCmd.Payload.StackSize = 12096; + CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(12096); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CFE_ES_StartApp_t), UT_TPID_CFE_ES_CMD_START_APP_CC); @@ -2938,7 +2928,7 @@ void TestTask(void) strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "", sizeof(CmdBuf.StartAppCmd.Payload.Application)); CmdBuf.StartAppCmd.Payload.Priority = 160; - CmdBuf.StartAppCmd.Payload.StackSize = 12096; + CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(12096); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CFE_ES_StartApp_t), UT_TPID_CFE_ES_CMD_START_APP_CC); @@ -2957,7 +2947,7 @@ void TestTask(void) strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "appName", sizeof(CmdBuf.StartAppCmd.Payload.Application)); CmdBuf.StartAppCmd.Payload.Priority = 160; - CmdBuf.StartAppCmd.Payload.StackSize = 12096; + CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(12096); CmdBuf.StartAppCmd.Payload.ExceptionAction = 255; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CFE_ES_StartApp_t), UT_TPID_CFE_ES_CMD_START_APP_CC); @@ -2976,7 +2966,7 @@ void TestTask(void) strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "appName", sizeof(CmdBuf.StartAppCmd.Payload.Application)); CmdBuf.StartAppCmd.Payload.Priority = 160; - CmdBuf.StartAppCmd.Payload.StackSize = 0; + CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(0); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CFE_ES_StartApp_t), UT_TPID_CFE_ES_CMD_START_APP_CC); @@ -2995,7 +2985,7 @@ void TestTask(void) strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "appName", sizeof(CmdBuf.StartAppCmd.Payload.Application)); CmdBuf.StartAppCmd.Payload.Priority = 1000; - CmdBuf.StartAppCmd.Payload.StackSize = 12096; + CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(12096); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CFE_ES_StartApp_t), UT_TPID_CFE_ES_CMD_START_APP_CC); @@ -3753,7 +3743,7 @@ void TestTask(void) sizeof(CmdBuf.StartAppCmd.Payload.Application)); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_PROC_RESTART; CmdBuf.StartAppCmd.Payload.Priority = 160; - CmdBuf.StartAppCmd.Payload.StackSize = CFE_PLATFORM_ES_DEFAULT_STACK_SIZE; + CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(CFE_PLATFORM_ES_DEFAULT_STACK_SIZE); UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CFE_ES_StartApp_t), UT_TPID_CFE_ES_CMD_START_APP_CC); UT_Report(__FILE__, __LINE__, @@ -5390,7 +5380,7 @@ void TestGenericCounterAPI(void) void TestCDS() { - uint32 CdsSize; + size_t CdsSize; uint8 *CdsPtr; char CDSName[CFE_MISSION_ES_CDS_MAX_FULL_NAME_LEN + 4]; CFE_ES_CDSHandle_t CDSHandle; @@ -5470,7 +5460,7 @@ void TestCDS() /* Test CDS registering with a write CDS failure */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, "UT", NULL, NULL); - ES_UT_SetupCDSGlobal(50000); + ES_UT_SetupCDSGlobal(ES_UT_CDS_SMALL_TEST_SIZE); UT_SetDeferredRetcode(UT_KEY(CFE_PSP_WriteToCDS), 2, OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_ES_RegisterCDS(&CDSHandle, @@ -5482,7 +5472,7 @@ void TestCDS() /* Test successful CDS registering */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, "UT", NULL, NULL); - ES_UT_SetupCDSGlobal(50000); + ES_UT_SetupCDSGlobal(ES_UT_CDS_SMALL_TEST_SIZE); UT_Report(__FILE__, __LINE__, CFE_ES_RegisterCDS(&CDSHandle, 4, "Name") == CFE_SUCCESS, "CFE_ES_RegisterCDS", @@ -5525,7 +5515,7 @@ void TestCDS() /* Test CDS registering with all the CDS registries taken */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, "UT", NULL, NULL); - ES_UT_SetupCDSGlobal(50000); + ES_UT_SetupCDSGlobal(ES_UT_CDS_SMALL_TEST_SIZE); /* Set all the CDS registries to 'taken' */ UtCDSRegRecPtr = CFE_ES_Global.CDSVars.Registry; @@ -5579,7 +5569,7 @@ void TestCDS() /* Test CDS registering using a name longer than the maximum allowed */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, "UT", NULL, NULL); - ES_UT_SetupCDSGlobal(50000); + ES_UT_SetupCDSGlobal(ES_UT_CDS_SMALL_TEST_SIZE); for (i = 0; i < CFE_MISSION_ES_CDS_MAX_NAME_LENGTH + 1; i++) { @@ -5748,7 +5738,7 @@ void TestCDS() * To prepare for the rebuild tests, set up a clean area in PSP mem, * and make a registry entry. */ - ES_UT_SetupCDSGlobal(50000); + ES_UT_SetupCDSGlobal(ES_UT_CDS_SMALL_TEST_SIZE); ES_UT_SetupSingleCDSRegistry("UT", 8, false, &UtCDSRegRecPtr); UtAssert_NONZERO(UtCDSRegRecPtr->BlockOffset); UtAssert_NONZERO(UtCDSRegRecPtr->BlockSize); @@ -5807,7 +5797,7 @@ void TestCDS() /* * To prepare for the rebuild tests, set up a clean area in PSP mem */ - ES_UT_SetupCDSGlobal(128 * 1024); + ES_UT_SetupCDSGlobal(ES_UT_CDS_LARGE_TEST_SIZE); /* Test CDS initialization where rebuilding the CDS is successful */ ES_ResetUnitTest(); @@ -5871,9 +5861,9 @@ void TestCDSMempool(void) CFE_ES_CDS_RegRec_t *UtCdsRegRecPtr; int Data; CFE_ES_ResourceID_t BlockHandle; - CFE_ES_CDS_Offset_t SavedSize; - CFE_ES_CDS_Offset_t SavedOffset; - uint8 *CdsPtr; + size_t SavedSize; + size_t SavedOffset; + uint8 *CdsPtr; UtPrintf("Begin Test CDS memory pool"); @@ -5898,7 +5888,7 @@ void TestCDSMempool(void) * a freed block in the pool. Then attempt to rebuild. */ ES_ResetUnitTest(); - ES_UT_SetupCDSGlobal(50000); + ES_UT_SetupCDSGlobal(ES_UT_CDS_SMALL_TEST_SIZE); SavedSize = CFE_ES_Global.CDSVars.TotalSize; SavedOffset = CFE_ES_Global.CDSVars.Pool.TailPosition; ES_UT_SetupSingleCDSRegistry("UT", sizeof(Data) + sizeof(CFE_ES_CDS_BlockHeader_t), @@ -5939,7 +5929,7 @@ void TestCDSMempool(void) /* Test CDS block access */ ES_ResetUnitTest(); - ES_UT_SetupCDSGlobal(50000); + ES_UT_SetupCDSGlobal(ES_UT_CDS_SMALL_TEST_SIZE); ES_UT_SetupSingleCDSRegistry("UT", sizeof(Data) + sizeof(CFE_ES_CDS_BlockHeader_t), false, &UtCdsRegRecPtr); BlockHandle = CFE_ES_CDSBlockRecordGetID(UtCdsRegRecPtr); @@ -6045,7 +6035,7 @@ void TestESMempool(void) uint32 *addressp2 = NULL; /* Pool 2 buffer address */ CFE_ES_MemPoolRecord_t *PoolPtr; CFE_ES_MemPoolStats_t Stats; - CFE_ES_MemOffset_t BlockSizes[CFE_PLATFORM_ES_POOL_MAX_BUCKETS+2]; + size_t BlockSizes[CFE_PLATFORM_ES_POOL_MAX_BUCKETS+2]; CFE_ES_GenPoolBD_t *BdPtr; uint32 i; @@ -6265,17 +6255,6 @@ void TestESMempool(void) "CFE_ES_PoolCreateEx", "Use default block sizes when none are given"); - /* Test initializing a pre-allocated pool using an invalid mutex option */ - UT_Report(__FILE__, __LINE__, - CFE_ES_PoolCreateEx(&PoolID1, - Buffer1, - sizeof(Buffer1), - CFE_PLATFORM_ES_POOL_MAX_BUCKETS - 2, - BlockSizes, - 2) == CFE_ES_BAD_ARGUMENT, - "CFE_ES_PoolCreateEx", - "Invalid mutex option"); - /* * Test creating a memory pool after the limit reached (no slots) */ diff --git a/fsw/cfe-core/unit-test/tbl_UT.c b/fsw/cfe-core/unit-test/tbl_UT.c index e395262f4..8c332b694 100644 --- a/fsw/cfe-core/unit-test/tbl_UT.c +++ b/fsw/cfe-core/unit-test/tbl_UT.c @@ -89,6 +89,21 @@ static const UT_TaskPipeDispatchId_t UT_TPID_CFE_TBL_CMD_INVALID_CC = CFE_TBL_RegistryRec_t Original[CFE_PLATFORM_TBL_MAX_NUM_TABLES]; +/* + * UT helper routines + */ +void UT_TBL_SetupHeader(CFE_TBL_File_Hdr_t *TblFileHeader, size_t Offset, size_t NumBytes) +{ + TblFileHeader->Offset = CFE_ES_MEMOFFSET_C(Offset); + TblFileHeader->NumBytes = CFE_ES_MEMOFFSET_C(NumBytes); + + if (UT_Endianess == UT_LITTLE_ENDIAN) + { + CFE_TBL_ByteSwapUint32(&TblFileHeader->Offset); + CFE_TBL_ByteSwapUint32(&TblFileHeader->NumBytes); + } +} + /* ** Functions */ @@ -984,36 +999,36 @@ void Test_CFE_TBL_GetTblRegData(void) /* Test using a double buffered table */ UT_InitData(); - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = '\0'; + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.HkTlmTblRegIndex].DoubleBuffered = true; CFE_TBL_GetTblRegData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr != '\0', + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr != 0, "CFE_TBL_GetTblRegData", "Double buffered table"); /* Test using a single buffered table and the buffer is inactive */ UT_InitData(); - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = '\0'; + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.HkTlmTblRegIndex].DoubleBuffered = false; CFE_TBL_TaskData. Registry[CFE_TBL_TaskData.HkTlmTblRegIndex]. LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; CFE_TBL_GetTblRegData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr != '\0', + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr != 0, "CFE_TBL_GetTblRegData", "Single buffered table - inactive buffer"); /* Test with no inactive buffer */ UT_InitData(); - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = '\0'; + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); CFE_TBL_TaskData. Registry[CFE_TBL_TaskData.HkTlmTblRegIndex].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; CFE_TBL_GetTblRegData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr == '\0', + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr == 0, "CFE_TBL_GetTblRegData", "No inactive buffer"); } @@ -1474,14 +1489,8 @@ void Test_CFE_TBL_LoadCmd(void) * indicates) */ UT_InitData(); - TblFileHeader.Offset = 0; + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t)); CFE_TBL_TaskData.Registry[0].TableLoadedOnce = true; - TblFileHeader.NumBytes = sizeof(CFE_TBL_File_Hdr_t); - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - } CFE_TBL_TaskData.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t); CFE_TBL_TaskData.Registry[0].LoadInProgress = @@ -1499,12 +1508,7 @@ void Test_CFE_TBL_LoadCmd(void) /* Test with no extra byte => successful load */ UT_InitData(); - TblFileHeader.NumBytes = sizeof(CFE_TBL_File_Hdr_t); - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t)); UT_SetDeferredRetcode(UT_KEY(OS_read), 3, 0); strncpy((char *)TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, @@ -1519,7 +1523,7 @@ void Test_CFE_TBL_LoadCmd(void) /* Test with differing amount of data from header's claim */ UT_InitData(); - TblFileHeader.NumBytes = sizeof(CFE_TBL_File_Hdr_t); + TblFileHeader.NumBytes = CFE_ES_MEMOFFSET_C(sizeof(CFE_TBL_File_Hdr_t)); if (UT_Endianess == UT_LITTLE_ENDIAN) { @@ -1561,12 +1565,7 @@ void Test_CFE_TBL_LoadCmd(void) /* Test with table header indicating data beyond size of the table */ UT_InitData(); - TblFileHeader.NumBytes = sizeof(CFE_TBL_File_Hdr_t); - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t)); CFE_TBL_TaskData.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t) - 1; strncpy((char *)TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, @@ -1581,12 +1580,7 @@ void Test_CFE_TBL_LoadCmd(void) /* Test with table header indicating no data in the file */ UT_InitData(); - TblFileHeader.NumBytes = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, 0); strncpy((char *)TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, sizeof(TblFileHeader.TableName)); @@ -1602,14 +1596,7 @@ void Test_CFE_TBL_LoadCmd(void) * is non-zero */ UT_InitData(); - TblFileHeader.NumBytes = 1; - TblFileHeader.Offset = 1; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 1, 1); CFE_TBL_TaskData.Registry[0].TableLoadedOnce = false; @@ -1629,14 +1616,7 @@ void Test_CFE_TBL_LoadCmd(void) * is zero */ UT_InitData(); - TblFileHeader.NumBytes = 1; - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, 1); CFE_TBL_TaskData.Registry[0].TableLoadedOnce = false; @@ -2547,14 +2527,8 @@ void Test_CFE_TBL_Share(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table4", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -2735,14 +2709,7 @@ void Test_CFE_TBL_Load(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t) - 1; - TblFileHeader.Offset = 1; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 1, sizeof(UT_Table1_t)-1); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -2788,14 +2755,7 @@ void Test_CFE_TBL_Load(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.NotUT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -2836,14 +2796,7 @@ void Test_CFE_TBL_Load(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy(TblFileHeader.TableName, "ut_cfe_tbl.NotUT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -3849,13 +3802,10 @@ void Test_CFE_TBL_TblMod(void) FileHeader.TimeSubSeconds = 104; strncpy((char *)File.TblHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(File.TblHeader.TableName)); - File.TblHeader.NumBytes = sizeof(UT_Table1_t); - File.TblHeader.Offset = 0; + UT_TBL_SetupHeader(&File.TblHeader, 0, sizeof(UT_Table1_t)); if (UT_Endianess == UT_LITTLE_ENDIAN) { - CFE_TBL_ByteSwapUint32(&File.TblHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&File.TblHeader.Offset); File.TblData.TblElement1 = 0x04030201; File.TblData.TblElement2 = 0x08070605; } @@ -3936,14 +3886,7 @@ void Test_CFE_TBL_TblMod(void) FileHeader.TimeSubSeconds = 104; strncpy((char *)File.TblHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(File.TblHeader.TableName)); - File.TblHeader.NumBytes = sizeof(UT_Table1_t); - File.TblHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&File.TblHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&File.TblHeader.Offset); - } + UT_TBL_SetupHeader(&File.TblHeader, 0, sizeof(UT_Table1_t)); File.TblData.TblElement1 = 0x04030201; File.TblData.TblElement2 = 0x08070605; @@ -4087,14 +4030,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 1; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 1, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4115,14 +4051,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4144,15 +4073,8 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } - + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); +// UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); UT_SetDeferredRetcode(UT_KEY(OS_read), 2, sizeof(UT_Table1_t) - 1); @@ -4174,14 +4096,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.NotUT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4201,14 +4116,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4228,14 +4136,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t) - 1; - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)-1); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4256,14 +4157,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t) - 1; - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)-1); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4316,14 +4210,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG - 1; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t) - 1; - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)-1); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4346,14 +4233,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t) - 1; - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)-1); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4493,14 +4373,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4521,14 +4394,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4549,14 +4415,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4577,14 +4436,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4608,14 +4460,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4655,14 +4500,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4703,14 +4541,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4753,14 +4584,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4834,14 +4658,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); diff --git a/fsw/cfe-core/unit-test/ut_support.c b/fsw/cfe-core/unit-test/ut_support.c index b3de436ee..b23d5ba6d 100644 --- a/fsw/cfe-core/unit-test/ut_support.c +++ b/fsw/cfe-core/unit-test/ut_support.c @@ -382,8 +382,8 @@ void UT_ClearEventHistory(void) static bool UT_CheckEventHistoryFromFunc(UT_EntryKey_t Func, uint16 EventIDToSearchFor) { bool Result = false; - uint32 Position; - uint32 MaxSize; + size_t Position; + size_t MaxSize; uint16 *EvBuf; UT_GetDataBuffer(Func, (void**)&EvBuf, &MaxSize, &Position); @@ -421,8 +421,8 @@ bool UT_EventIsInHistory(uint16 EventIDToSearchFor) uint16 UT_GetNumEventsSent(void) { uint16 Total = 0; - uint32 Position; - uint32 MaxSize; + size_t Position; + size_t MaxSize; void *EvBuf; UT_GetDataBuffer(UT_KEY(CFE_EVS_SendEvent), &EvBuf, &MaxSize, &Position); @@ -438,11 +438,11 @@ uint16 UT_GetNumEventsSent(void) /* ** Display the contents of a packet */ -void UT_DisplayPkt(CFE_SB_MsgPtr_t ptr, uint32 size) +void UT_DisplayPkt(CFE_SB_MsgPtr_t ptr, size_t size) { uint8 *BytePtr = (uint8 *) ptr; - uint32 i; - uint32 BufSize = UT_MAX_MESSAGE_LENGTH; + size_t i; + size_t BufSize = UT_MAX_MESSAGE_LENGTH; char DisplayMsg[UT_MAX_MESSAGE_LENGTH]; char *msgPtr = DisplayMsg; diff --git a/fsw/cfe-core/unit-test/ut_support.h b/fsw/cfe-core/unit-test/ut_support.h index 60bfa2a1b..6d766fb50 100644 --- a/fsw/cfe-core/unit-test/ut_support.h +++ b/fsw/cfe-core/unit-test/ut_support.h @@ -572,7 +572,7 @@ uint16 UT_GetNumEventsSent(void); ** This function does not return a value. ** ******************************************************************************/ -void UT_DisplayPkt(CFE_SB_MsgPtr_t ptr, uint32 size); +void UT_DisplayPkt(CFE_SB_MsgPtr_t ptr, size_t size); /*****************************************************************************/ /** diff --git a/fsw/cfe-core/ut-stubs/ut_es_stubs.c b/fsw/cfe-core/ut-stubs/ut_es_stubs.c index e0212fff1..6bd242975 100644 --- a/fsw/cfe-core/ut-stubs/ut_es_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_es_stubs.c @@ -108,13 +108,13 @@ ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, - const char *TaskName, - CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, - uint32 *StackPtr, - uint32 StackSize, - uint32 Priority, - uint32 Flags) +CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, + const char *TaskName, + CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, + CFE_ES_StackPointer_t StackPtr, + size_t StackSize, + CFE_ES_TaskPriority_Atom_t Priority, + uint32 Flags) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_CreateChildTask), TaskIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_ES_CreateChildTask), TaskName); @@ -157,8 +157,8 @@ int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) int32 status; CFE_ES_ResourceID_t *IdBuff; - uint32 BuffSize; - uint32 Position; + size_t BuffSize; + size_t Position; status = UT_DEFAULT_IMPL(CFE_ES_GetAppID); @@ -189,8 +189,8 @@ int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) int32 status; CFE_ES_ResourceID_t *IdBuff; - uint32 BuffSize; - uint32 Position; + size_t BuffSize; + size_t Position; status = UT_DEFAULT_IMPL(CFE_ES_GetTaskID); @@ -241,8 +241,8 @@ int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), AppIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), AppName); - uint32 UserBuffSize; - uint32 BuffPosition; + size_t UserBuffSize; + size_t BuffPosition; const char *NameBuff; CFE_ES_ResourceID_t *IdBuff; int32 status; @@ -297,14 +297,14 @@ int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) ** Returns CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, uint32 BufferLength) +CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t BufferLength) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppName), AppName); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetAppName), AppId); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetAppName), BufferLength); - uint32 UserBuffSize; - uint32 BuffPosition; + size_t UserBuffSize; + size_t BuffPosition; const char *NameBuff; int32 status; @@ -451,9 +451,7 @@ int32 CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) ** value (0xffffffff if Size exceeds maximum value allowed). ** ******************************************************************************/ -int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, - CFE_ES_MemHandle_t PoolID, - CFE_ES_MemOffset_t Size) +int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, CFE_ES_MemHandle_t PoolID, size_t Size) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetPoolBuf), BufPtr); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetPoolBuf), PoolID); @@ -466,9 +464,9 @@ int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, uint8 Bytes[CFE_UT_ES_POOL_STATIC_BLOCK_SIZE]; } Buffer; - uint32 PoolSize; - uint32 PositionStart; - uint32 PositionEnd; + size_t PoolSize; + size_t PositionStart; + size_t PositionEnd; void *PoolPtr; cpuaddr BufAddrStart; cpuaddr BufAddrEnd; @@ -561,7 +559,7 @@ int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, ** Returns either a user-defined status flag or OS_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, CFE_ES_MemOffset_t Size) +CFE_Status_t CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, size_t Size) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreate), PoolID); UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreate), MemPtr); @@ -594,9 +592,7 @@ int32 CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, CFE_ES_MemOff ** Returns OS_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, - uint8 *MemPtr, - CFE_ES_MemOffset_t Size) +CFE_Status_t CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, size_t Size) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreateNoSem), PoolID); UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreateNoSem), MemPtr); @@ -634,12 +630,12 @@ int32 CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, - uint8 *MemPtr, - CFE_ES_MemOffset_t Size, - uint16 NumBlockSizes, - const CFE_ES_MemOffset_t *BlockSizes, - uint16 UseMutex ) +CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, + uint8 *MemPtr, + size_t Size, + uint16 NumBlockSizes, + const size_t *BlockSizes, + bool UseMutex ) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreateEx), PoolID); UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreateEx), MemPtr); @@ -777,10 +773,7 @@ void CFE_ES_PerfLogAdd(uint32 Marker, uint32 EntryExit) ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -uint32 CFE_ES_CalculateCRC(const void *DataPtr, - uint32 DataLength, - uint32 InputCRC, - uint32 TypeCRC) +uint32 CFE_ES_CalculateCRC(const void *DataPtr, size_t DataLength, uint32 InputCRC, uint32 TypeCRC) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_CalculateCRC), DataPtr); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_CalculateCRC), DataLength); @@ -889,7 +882,7 @@ void CFE_ES_ExitApp(uint32 ExitStatus) int32 CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t Handle, void *DataToCopy) { int32 status; - uint32 CdsBufferSize; + size_t CdsBufferSize; UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_CopyToCDS), Handle); UT_Stub_RegisterContext(UT_KEY(CFE_ES_CopyToCDS), DataToCopy); @@ -931,7 +924,7 @@ int32 CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t Handle, void *DataToCopy) int32 CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle) { int32 status; - uint32 CdsBufferSize; + size_t CdsBufferSize; UT_Stub_RegisterContext(UT_KEY(CFE_ES_RestoreFromCDS), RestoreToMemory); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_RestoreFromCDS), Handle); @@ -971,7 +964,7 @@ int32 CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle) ** ******************************************************************************/ int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, - CFE_ES_CDS_Offset_t UserBlockSize, + size_t UserBlockSize, const char *Name, bool CriticalTbl) { @@ -1112,7 +1105,7 @@ bool CFE_ES_RunLoop(uint32 *ExitStatus) return UT_DEFAULT_IMPL(CFE_ES_RunLoop) != 0; } -int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, CFE_ES_CDS_Offset_t BlockSize, const char *Name) +CFE_Status_t CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, size_t BlockSize, const char *Name) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_RegisterCDS), HandlePtr); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_RegisterCDS), BlockSize); diff --git a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c b/fsw/cfe-core/ut-stubs/ut_sb_stubs.c index eff6d89cf..9302d01f1 100644 --- a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_sb_stubs.c @@ -61,7 +61,7 @@ static CFE_SB_StubMsg_MetaData_t* CFE_SB_StubMsg_GetMetaData(const CFE_SB_Msg_t { CFE_SB_StubMsg_MetaData_t* MetaPtr; CFE_SB_StubMsg_MetaData_t DefaultMeta; - uint32 MetaSize; + size_t MetaSize; UT_EntryKey_t MsgKey = (UT_EntryKey_t)MsgPtr; UT_GetDataBuffer(MsgKey, (void**)&MetaPtr, &MetaSize, NULL); @@ -218,8 +218,8 @@ int32 CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GetPipeName), PipeNameSize); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GetPipeName), PipeId); - uint32 UserBuffSize; - uint32 BuffPosition; + size_t UserBuffSize; + size_t BuffPosition; const char *NameBuff; int32 status; @@ -378,10 +378,10 @@ CFE_SB_MsgId_t CFE_SB_GetMsgId(const CFE_SB_Msg_t *MsgPtr) ** This function does not return a value. ** ******************************************************************************/ -void CFE_SB_InitMsg(void *MsgPtr, +void CFE_SB_InitMsg(void *MsgPtr, CFE_SB_MsgId_t MsgId, - uint16 Length, - bool Clear) + size_t Length, + bool Clear ) { UT_Stub_RegisterContext(UT_KEY(CFE_SB_InitMsg), MsgPtr); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_InitMsg), MsgId); @@ -730,7 +730,7 @@ void CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) ** Returns a user-defined status value, UT_SB_TotalMsgLen. ** ******************************************************************************/ -uint16 CFE_SB_GetTotalMsgLength(const CFE_SB_Msg_t *MsgPtr) +size_t CFE_SB_GetTotalMsgLength(const CFE_SB_Msg_t *MsgPtr) { UT_Stub_RegisterContext(UT_KEY(CFE_SB_GetTotalMsgLength), MsgPtr); @@ -780,7 +780,7 @@ int32 CFE_SB_CleanUpApp(uint32 AppId) ** See function prototype for full description ** */ -int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, const char *DefaultString, uint32 DestMaxSize, uint32 SourceMaxSize) +int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, const char *DefaultString, size_t DestMaxSize, size_t SourceMaxSize) { UT_Stub_RegisterContext(UT_KEY(CFE_SB_MessageStringGet), DestStringPtr); UT_Stub_RegisterContext(UT_KEY(CFE_SB_MessageStringGet), SourceStringPtr); @@ -827,7 +827,7 @@ int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, ** See function prototype for full description ** */ -int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, uint32 DestMaxSize, uint32 SourceMaxSize) +int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, size_t DestMaxSize, size_t SourceMaxSize) { UT_Stub_RegisterContext(UT_KEY(CFE_SB_MessageStringSet), DestStringPtr); UT_Stub_RegisterContext(UT_KEY(CFE_SB_MessageStringSet), SourceStringPtr); @@ -943,7 +943,7 @@ void *CFE_SB_GetUserData(CFE_SB_MsgPtr_t MsgPtr) return Result; } -void CFE_SB_SetTotalMsgLength (CFE_SB_MsgPtr_t MsgPtr,uint16 TotalLength) +void CFE_SB_SetTotalMsgLength (CFE_SB_MsgPtr_t MsgPtr,size_t TotalLength) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetTotalMsgLength), MsgPtr); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetTotalMsgLength), TotalLength); @@ -1000,7 +1000,7 @@ int32 CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptPtr) return status; } -uint16 CFE_SB_GetUserDataLength(const CFE_SB_Msg_t *MsgPtr) +size_t CFE_SB_GetUserDataLength(const CFE_SB_Msg_t *MsgPtr) { UT_Stub_RegisterContext(UT_KEY(CFE_SB_GetUserDataLength), MsgPtr); @@ -1049,7 +1049,7 @@ int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) return status; } -void CFE_SB_SetUserDataLength(CFE_SB_MsgPtr_t MsgPtr, uint16 DataLength) +void CFE_SB_SetUserDataLength(CFE_SB_MsgPtr_t MsgPtr, size_t DataLength) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetUserDataLength), MsgPtr); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetUserDataLength), DataLength); @@ -1070,7 +1070,7 @@ int32 CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) return status; } -CFE_SB_Msg_t* CFE_SB_ZeroCopyGetPtr(uint16 MsgSize, CFE_SB_ZeroCopyHandle_t *BufferHandle) +CFE_SB_Msg_t* CFE_SB_ZeroCopyGetPtr(size_t MsgSize, CFE_SB_ZeroCopyHandle_t *BufferHandle) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_ZeroCopyGetPtr), MsgSize); UT_Stub_RegisterContext(UT_KEY(CFE_SB_ZeroCopyGetPtr), BufferHandle); diff --git a/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c b/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c index b0befc23c..582f29e01 100644 --- a/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c @@ -102,7 +102,7 @@ int32 CFE_TBL_CleanUpApp(uint32 AppId) int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, /* Returned Handle */ const char *Name, /* Application specific name */ - uint32 Size, /* Size, in bytes, of table */ + size_t Size, /* Size, in bytes, of table */ uint16 TblOptionFlags, /* Tbl Options Settings */ CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr ) /* Ptr to func that validates tbl */ {