From 6bda4966799a26e6b78066fa2743a71f613bd0a0 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 17 May 2024 12:44:20 -0400 Subject: [PATCH] Fix #2545, migrate TBL, ES, and SB arrays to config list Utilize the compile-time generated list feature of the config module to replace hardcoded lists of items in ES, SB, and TBL. In particular this applies to the ES mempool sizes, SB mempool sizes, and the spacecraft and processor ID lists in TBL. Note that the TBL code was not in accordance with coding standards as it was (by default) compiled out via an #if directive, and thus not being tested as it should be. This fixes that, by removing the conditional compile and always testing the code. --- .../config/tool/cfeconfig_platformdata_tool.c | 2 +- modules/es/fsw/src/cfe_es_cds_mempool.c | 47 +++--- modules/es/fsw/src/cfe_es_generic_pool.c | 6 + modules/es/fsw/src/cfe_es_mempool.c | 45 +++--- modules/es/fsw/src/cfe_es_verify.h | 135 +----------------- modules/es/ut-coverage/es_UT.c | 24 ++++ .../sb/config/default_cfe_sb_internal_cfg.h | 18 ++- modules/sb/fsw/src/cfe_sb_init.c | 22 +-- modules/sb/fsw/src/cfe_sb_verify.h | 64 --------- modules/tbl/fsw/src/cfe_tbl_internal.c | 55 +++---- modules/tbl/fsw/src/cfe_tbl_verify.h | 17 --- modules/tbl/ut-coverage/tbl_UT.c | 52 +++---- 12 files changed, 152 insertions(+), 335 deletions(-) diff --git a/modules/config/tool/cfeconfig_platformdata_tool.c b/modules/config/tool/cfeconfig_platformdata_tool.c index 162b21b09..a07bfd6c7 100644 --- a/modules/config/tool/cfeconfig_platformdata_tool.c +++ b/modules/config/tool/cfeconfig_platformdata_tool.c @@ -289,4 +289,4 @@ int main(int argc, char *argv[]) } return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/modules/es/fsw/src/cfe_es_cds_mempool.c b/modules/es/fsw/src/cfe_es_cds_mempool.c index 884007493..4b95f595b 100644 --- a/modules/es/fsw/src/cfe_es_cds_mempool.c +++ b/modules/es/fsw/src/cfe_es_cds_mempool.c @@ -38,23 +38,7 @@ #include "cfe_es_module_all.h" -/*****************************************************************************/ -/* -** Type Definitions -*/ - -/*****************************************************************************/ -/* -** File Global Data -*/ - -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, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_15, - CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_14, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_13, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_12, - CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_11, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_10, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_09, - CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_08, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_07, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_06, - CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_05, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_04, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_03, - CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_02, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_01}; +#include "cfe_config.h" /*****************************************************************************/ /* @@ -103,27 +87,27 @@ int32 CFE_ES_CDS_PoolCommit(CFE_ES_GenPoolRecord_t *GenPoolRecPtr, size_t Offset *-----------------------------------------------------------------*/ int32 CFE_ES_CreateCDSPool(size_t CDSPoolSize, size_t StartOffset) { - CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; - int32 Status; - size_t SizeCheck; - size_t ActualSize; + CFE_ES_CDS_Instance_t * CDS = &CFE_ES_Global.CDSVars; + int32 Status; + size_t SizeCheck; + CFE_Config_ArrayValue_t CDSMemPoolDefSize; - SizeCheck = CFE_ES_GenPoolCalcMinSize(CFE_ES_CDS_NUM_BLOCK_SIZES, CFE_ES_CDSMemPoolDefSize, 1); - ActualSize = CDSPoolSize; + CDSMemPoolDefSize = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_ES_CDS_MEM_BLOCK_SIZE); + SizeCheck = CFE_ES_GenPoolCalcMinSize(CDSMemPoolDefSize.NumElements, CDSMemPoolDefSize.ElementPtr, 1); - if (ActualSize < SizeCheck) + if (CDSPoolSize < SizeCheck) { /* Must be able make Pool verification, block descriptor and at least one of the smallest blocks */ CFE_ES_SysLogWrite_Unsync("%s: Pool size(%lu) too small for one CDS Block, need >=%lu\n", __func__, - (unsigned long)ActualSize, (unsigned long)SizeCheck); + (unsigned long)CDSPoolSize, (unsigned long)SizeCheck); return CFE_ES_CDS_INVALID_SIZE; } Status = CFE_ES_GenPoolInitialize(&CDS->Pool, StartOffset, /* starting offset */ - ActualSize, /* total size */ + CDSPoolSize, /* total size */ 4, /* alignment */ - CFE_ES_CDS_NUM_BLOCK_SIZES, CFE_ES_CDSMemPoolDefSize, CFE_ES_CDS_PoolRetrieve, - CFE_ES_CDS_PoolCommit); + CDSMemPoolDefSize.NumElements, CDSMemPoolDefSize.ElementPtr, + CFE_ES_CDS_PoolRetrieve, CFE_ES_CDS_PoolCommit); return Status; } @@ -351,9 +335,10 @@ int32 CFE_ES_CDSBlockRead(void *DataRead, CFE_ES_CDSHandle_t Handle) *-----------------------------------------------------------------*/ size_t CFE_ES_CDSReqdMinSize(uint32 MaxNumBlocksToSupport) { - size_t ReqSize; + CFE_Config_ArrayValue_t CDSMemPoolDefSize; - ReqSize = CFE_ES_GenPoolCalcMinSize(CFE_ES_CDS_NUM_BLOCK_SIZES, CFE_ES_CDSMemPoolDefSize, MaxNumBlocksToSupport); + CDSMemPoolDefSize = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_ES_CDS_MEM_BLOCK_SIZE); - return ReqSize; + return CFE_ES_GenPoolCalcMinSize(CDSMemPoolDefSize.NumElements, CDSMemPoolDefSize.ElementPtr, + MaxNumBlocksToSupport); } diff --git a/modules/es/fsw/src/cfe_es_generic_pool.c b/modules/es/fsw/src/cfe_es_generic_pool.c index 6f6cbc3bd..fd7bd314f 100644 --- a/modules/es/fsw/src/cfe_es_generic_pool.c +++ b/modules/es/fsw/src/cfe_es_generic_pool.c @@ -240,6 +240,12 @@ int32 CFE_ES_GenPoolInitialize(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t StartO uint32 j; CFE_ES_GenPoolBucket_t *BucketPtr; + if (NumBlockSizes == 0) + { + CFE_ES_WriteToSysLog("%s: cannot create pool with 0 block sizes\n", __func__); + return CFE_ES_BAD_ARGUMENT; + } + /* * Note - being an internal/non-public API this does not need to * check the directly-supplied arguments, it is assumed they are already diff --git a/modules/es/fsw/src/cfe_es_mempool.c b/modules/es/fsw/src/cfe_es_mempool.c index c3856eed6..4d34ae143 100644 --- a/modules/es/fsw/src/cfe_es_mempool.c +++ b/modules/es/fsw/src/cfe_es_mempool.c @@ -33,6 +33,7 @@ ** Includes */ #include "cfe_es_module_all.h" +#include "cfe_config.h" #include #include @@ -53,19 +54,6 @@ } *)0) \ ->Align) -/*****************************************************************************/ -/* -** Type Definitions -*/ - -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, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_15, - CFE_PLATFORM_ES_MEM_BLOCK_SIZE_14, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_13, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_12, - CFE_PLATFORM_ES_MEM_BLOCK_SIZE_11, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_10, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_09, - CFE_PLATFORM_ES_MEM_BLOCK_SIZE_08, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_07, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_06, - CFE_PLATFORM_ES_MEM_BLOCK_SIZE_05, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_04, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_03, - CFE_PLATFORM_ES_MEM_BLOCK_SIZE_02, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_01}; - /*****************************************************************************/ /* ** Functions @@ -158,7 +146,11 @@ CFE_ES_MemPoolRecord_t *CFE_ES_LocateMemPoolRecordByID(CFE_ES_MemHandle_t PoolID *-----------------------------------------------------------------*/ CFE_Status_t CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t Size) { - return CFE_ES_PoolCreateEx(PoolID, MemPtr, Size, CFE_PLATFORM_ES_POOL_MAX_BUCKETS, &CFE_ES_MemPoolDefSize[0], + CFE_Config_ArrayValue_t MemPoolDefSize; + + MemPoolDefSize = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_ES_MEM_BLOCK_SIZE); + + return CFE_ES_PoolCreateEx(PoolID, MemPtr, Size, MemPoolDefSize.NumElements, MemPoolDefSize.ElementPtr, CFE_ES_NO_MUTEX); } @@ -170,7 +162,11 @@ CFE_Status_t CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, void *MemPtr, si *-----------------------------------------------------------------*/ CFE_Status_t CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t Size) { - return CFE_ES_PoolCreateEx(PoolID, MemPtr, Size, CFE_PLATFORM_ES_POOL_MAX_BUCKETS, &CFE_ES_MemPoolDefSize[0], + CFE_Config_ArrayValue_t MemPoolDefSize; + + MemPoolDefSize = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_ES_MEM_BLOCK_SIZE); + + return CFE_ES_PoolCreateEx(PoolID, MemPtr, Size, MemPoolDefSize.NumElements, MemPoolDefSize.ElementPtr, CFE_ES_USE_MUTEX); } @@ -190,6 +186,7 @@ CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_ size_t Alignment; size_t MinimumSize; char MutexName[OS_MAX_API_NAME]; + CFE_Config_ArrayValue_t MemPoolDefSize; /* Sanity Check inputs */ if (MemPtr == NULL || PoolID == NULL) @@ -198,10 +195,10 @@ CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_ } /* If too many sizes are specified, return an error */ - if (NumBlockSizes > CFE_PLATFORM_ES_POOL_MAX_BUCKETS) + if (NumBlockSizes > CFE_MISSION_ES_POOL_MAX_BUCKETS) { CFE_ES_WriteToSysLog("%s: Num Block Sizes (%d) greater than max (%d)\n", __func__, (int)NumBlockSizes, - CFE_PLATFORM_ES_POOL_MAX_BUCKETS); + CFE_MISSION_ES_POOL_MAX_BUCKETS); return CFE_ES_BAD_ARGUMENT; } @@ -210,10 +207,20 @@ CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_ */ if (BlockSizes == NULL) { - BlockSizes = CFE_ES_MemPoolDefSize; + MemPoolDefSize = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_ES_MEM_BLOCK_SIZE); + + BlockSizes = MemPoolDefSize.ElementPtr; if (NumBlockSizes == 0) { - NumBlockSizes = CFE_PLATFORM_ES_POOL_MAX_BUCKETS; + NumBlockSizes = MemPoolDefSize.NumElements; + } + + /* If too many sizes are specified, return an error */ + if (NumBlockSizes > MemPoolDefSize.NumElements) + { + CFE_ES_WriteToSysLog("%s: Num Block Sizes (%d) greater than max (%lu)\n", __func__, (int)NumBlockSizes, + (unsigned long)MemPoolDefSize.NumElements); + return CFE_ES_BAD_ARGUMENT; } } diff --git a/modules/es/fsw/src/cfe_es_verify.h b/modules/es/fsw/src/cfe_es_verify.h index d8895ba26..dae790c72 100644 --- a/modules/es/fsw/src/cfe_es_verify.h +++ b/modules/es/fsw/src/cfe_es_verify.h @@ -166,8 +166,8 @@ /* ** Intermediate ES Memory Pool Block Sizes */ -#if CFE_PLATFORM_ES_MAX_BLOCK_SIZE < CFE_MISSION_SB_MAX_SB_MSG_SIZE -#error CFE_PLATFORM_ES_MAX_BLOCK_SIZE must be equal to or larger than CFE_MISSION_SB_MAX_SB_MSG_SIZE! +#if CFE_MISSION_ES_POOL_MAX_BUCKETS < CFE_PLATFORM_ES_POOL_MAX_BUCKETS +#error CFE_MISSION_ES_POOL_MAX_BUCKETS must be equal to or larger than CFE_PLATFORM_ES_POOL_MAX_BUCKETS! #endif #if CFE_PLATFORM_ES_MAX_BLOCK_SIZE < CFE_PLATFORM_TBL_MAX_SNGL_TABLE_SIZE @@ -178,137 +178,6 @@ #error CFE_PLATFORM_ES_MAX_BLOCK_SIZE must be equal to or larger than CFE_PLATFORM_TBL_MAX_DBL_TABLE_SIZE! #endif -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_01 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_02 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_01 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_02 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_02 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_03 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_02 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_03 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_03 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_04 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_03 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_04 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_04 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_05 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_04 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_05 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_05 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_06 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_05 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_06 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_06 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_07 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_06 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_07 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_07 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_08 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_07 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_08 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_08 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_09 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_08 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_09 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_09 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_10 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_09 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_10 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_10 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_11 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_10 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_11 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_11 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_12 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_11 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_12 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_12 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_13 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_12 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_13 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_13 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_14 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_13 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_14 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_14 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_15 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_14 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_15 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_15 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_16 -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_15 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_16 -#endif - -#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_16 > CFE_PLATFORM_ES_MAX_BLOCK_SIZE -#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_16 must be less than CFE_PLATFORM_ES_MAX_BLOCK_SIZE -#endif - -/* -** Intermediate ES Critical Data Store Memory Pool Block Sizes -*/ -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_01 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_02 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_01 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_02 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_02 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_03 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_02 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_03 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_03 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_04 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_03 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_04 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_04 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_05 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_04 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_05 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_05 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_06 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_05 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_06 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_06 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_07 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_06 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_07 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_07 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_08 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_07 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_08 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_08 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_09 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_08 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_09 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_09 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_10 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_09 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_10 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_10 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_11 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_10 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_11 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_11 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_12 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_11 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_12 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_12 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_13 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_12 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_13 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_13 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_14 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_13 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_14 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_14 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_15 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_14 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_15 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_15 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_16 -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_15 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_16 -#endif - -#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_16 > CFE_PLATFORM_ES_CDS_MAX_BLOCK_SIZE -#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_16 must be less than CFE_PLATFORM_ES_CDS_MAX_BLOCK_SIZE -#endif - /* ** Validate task stack size... */ diff --git a/modules/es/ut-coverage/es_UT.c b/modules/es/ut-coverage/es_UT.c index 1511de87b..e848a9e3d 100644 --- a/modules/es/ut-coverage/es_UT.c +++ b/modules/es/ut-coverage/es_UT.c @@ -85,6 +85,15 @@ typedef struct CFE_ES_GMP_DirectBuffer_t UT_MemPoolDirectBuffer; CFE_ES_GMP_IndirectBuffer_t UT_MemPoolIndirectBuffer; +/* + * Memory pool block sizes used for unit test + * The platform config values are not used for UT as the test cases + * require certain sizes. A large max block and small min block + * are needed for testing size thresholds when creating pools. + */ +static const size_t UT_MemPoolSizeArray[5] = {131072, 512, 128, 32, 8}; +static const CFE_Config_ArrayValue_t UT_MemPoolAV = {5, UT_MemPoolSizeArray}; + /* Create a startup script buffer for a maximum of 5 lines * 80 chars/line */ char StartupScript[MAX_STARTUP_SCRIPT]; @@ -624,6 +633,12 @@ static int32 ES_UT_SetAppStateHook(void *UserObj, int32 StubRetcode, uint32 Call return StubRetcode; } +static void UT_ArrayConfigHandler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_Config_ArrayValue_t Val = *((const CFE_Config_ArrayValue_t *)UserObj); + UT_Stub_SetReturnValue(FuncKey, Val); +} + void UtTest_Setup(void) { UT_Init("es"); @@ -674,10 +689,19 @@ void ES_ResetUnitTest(void) * so it must be re-initialized here every time CFE_ES_Global is reset. */ CFE_ES_Global.ResetDataPtr = ES_UT_PersistentResetData; + + UT_SetHandlerFunction(UT_KEY(CFE_Config_GetArrayValue), UT_ArrayConfigHandler, (void *)&UT_MemPoolAV); + } /* end ES_ResetUnitTest() */ void TestInit(void) { + size_t SizeValue; + CFE_Config_ArrayValue_t UTAV = {1, &SizeValue}; + + SizeValue = 1; + UT_SetHandlerFunction(UT_KEY(CFE_Config_GetArrayValue), UT_ArrayConfigHandler, &UTAV); + UtPrintf("Begin Test Init"); UT_SetCDSSize(128 * 1024); diff --git a/modules/sb/config/default_cfe_sb_internal_cfg.h b/modules/sb/config/default_cfe_sb_internal_cfg.h index ef34dd381..6c1976366 100644 --- a/modules/sb/config/default_cfe_sb_internal_cfg.h +++ b/modules/sb/config/default_cfe_sb_internal_cfg.h @@ -232,6 +232,21 @@ #define CFE_PLATFORM_SB_FILTERED_EVENT8 0 #define CFE_PLATFORM_SB_FILTER_MASK8 CFE_EVS_NO_FILTER +/** +** \cfeescfg Number of block sizes in SB memory pool structure +** +** \par Description: +** The number of block sizes for the software bus memory pool +** +** \par Limits: +** Must be at least one. No specific upper limit, but the number is +** anticipated to be reasonably small (i.e. tens, not hundreds). Large +** values have not been tested. +** +** The SB block size list must correlate with this value +*/ +#define CFE_PLATFORM_SB_POOL_MAX_BUCKETS 17 + /** ** \cfeescfg Define SB Memory Pool Block Sizes ** @@ -240,8 +255,7 @@ ** ** \par Limits ** These sizes MUST be increasing and MUST be an integral multiple of 4. -** The number of block sizes defined cannot exceed -** #CFE_PLATFORM_ES_POOL_MAX_BUCKETS +** The number of block sizes defined should match #CFE_PLATFORM_SB_POOL_MAX_BUCKETS */ #define CFE_PLATFORM_SB_MEM_BLOCK_SIZE_01 8 #define CFE_PLATFORM_SB_MEM_BLOCK_SIZE_02 16 diff --git a/modules/sb/fsw/src/cfe_sb_init.c b/modules/sb/fsw/src/cfe_sb_init.c index 2ebaa5dd4..1a3b1bbd3 100644 --- a/modules/sb/fsw/src/cfe_sb_init.c +++ b/modules/sb/fsw/src/cfe_sb_init.c @@ -31,21 +31,10 @@ */ #include "cfe_sb_module_all.h" +#include "cfe_config.h" #include -/* -** External Declarations -*/ - -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, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_15, - CFE_PLATFORM_SB_MEM_BLOCK_SIZE_14, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_13, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_12, - CFE_PLATFORM_SB_MEM_BLOCK_SIZE_11, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_10, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_09, - CFE_PLATFORM_SB_MEM_BLOCK_SIZE_08, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_07, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_06, - CFE_PLATFORM_SB_MEM_BLOCK_SIZE_05, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_04, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_03, - CFE_PLATFORM_SB_MEM_BLOCK_SIZE_02, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_01}; - /*---------------------------------------------------------------- * * Implemented per public API @@ -99,11 +88,14 @@ int32 CFE_SB_EarlyInit(void) *-----------------------------------------------------------------*/ int32 CFE_SB_InitBuffers(void) { - int32 Stat = 0; + int32 Stat = 0; + CFE_Config_ArrayValue_t MemPoolDefSize; + + MemPoolDefSize = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_SB_MEM_BLOCK_SIZE); Stat = CFE_ES_PoolCreateEx(&CFE_SB_Global.Mem.PoolHdl, CFE_SB_Global.Mem.Partition.Data, - CFE_PLATFORM_SB_BUF_MEMORY_BYTES, CFE_PLATFORM_ES_POOL_MAX_BUCKETS, - &CFE_SB_MemPoolDefSize[0], CFE_ES_NO_MUTEX); + CFE_PLATFORM_SB_BUF_MEMORY_BYTES, MemPoolDefSize.NumElements, MemPoolDefSize.ElementPtr, + CFE_ES_NO_MUTEX); if (Stat != CFE_SUCCESS) { diff --git a/modules/sb/fsw/src/cfe_sb_verify.h b/modules/sb/fsw/src/cfe_sb_verify.h index 7eed2d432..101540d62 100644 --- a/modules/sb/fsw/src/cfe_sb_verify.h +++ b/modules/sb/fsw/src/cfe_sb_verify.h @@ -83,70 +83,6 @@ #error CFE_PLATFORM_SB_MAX_BLOCK_SIZE must be > or = to CFE_MISSION_SB_MAX_SB_MSG_SIZE! #endif -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_01 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_02 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_01 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_02 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_02 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_03 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_02 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_03 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_03 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_04 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_03 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_04 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_04 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_05 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_04 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_05 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_05 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_06 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_05 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_06 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_06 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_07 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_06 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_07 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_07 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_08 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_07 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_08 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_08 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_09 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_08 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_09 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_09 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_10 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_09 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_10 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_10 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_11 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_10 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_11 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_11 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_12 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_11 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_12 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_12 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_13 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_12 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_13 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_13 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_14 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_13 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_14 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_14 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_15 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_14 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_15 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_15 > CFE_PLATFORM_SB_MEM_BLOCK_SIZE_16 -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_15 must be less than CFE_PLATFORM_SB_MEM_BLOCK_SIZE_16 -#endif - -#if CFE_PLATFORM_SB_MEM_BLOCK_SIZE_16 >= CFE_PLATFORM_SB_MAX_BLOCK_SIZE -#error CFE_PLATFORM_SB_MEM_BLOCK_SIZE_16 must be less than CFE_PLATFORM_SB_MAX_BLOCK_SIZE -#endif - #if CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT < 4 #error CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT cannot be less than 4! #endif diff --git a/modules/tbl/fsw/src/cfe_tbl_internal.c b/modules/tbl/fsw/src/cfe_tbl_internal.c index fe736b0df..fc19caad3 100644 --- a/modules/tbl/fsw/src/cfe_tbl_internal.c +++ b/modules/tbl/fsw/src/cfe_tbl_internal.c @@ -31,6 +31,7 @@ ** Required header files... */ #include "cfe_tbl_module_all.h" +#include "cfe_config.h" #include #include @@ -845,16 +846,14 @@ int32 CFE_TBL_ReadHeaders(osal_id_t FileDescriptor, CFE_FS_Header_t *StdFileHead int32 OsStatus; int32 EndianCheck = 0x01020304; -#if (CFE_PLATFORM_TBL_VALID_SCID_COUNT > 0) - static uint32 ListSC[2] = {CFE_PLATFORM_TBL_VALID_SCID_1, CFE_PLATFORM_TBL_VALID_SCID_2}; - uint32 IndexSC; -#endif + const uint32 *ListPtr; + uint32 Idx; -#if (CFE_PLATFORM_TBL_VALID_PRID_COUNT > 0) - static uint32 ListPR[4] = {CFE_PLATFORM_TBL_VALID_PRID_1, CFE_PLATFORM_TBL_VALID_PRID_2, - CFE_PLATFORM_TBL_VALID_PRID_3, CFE_PLATFORM_TBL_VALID_PRID_4}; - uint32 IndexPR; -#endif + CFE_Config_ArrayValue_t ListPR; + CFE_Config_ArrayValue_t ListSC; + + ListSC = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_TBL_VALID_SCID); + ListPR = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_TBL_VALID_PRID); /* Once the file is open, read the headers to determine the target Table */ Status = CFE_FS_ReadHeader(StdFileHeaderPtr, FileDescriptor); @@ -927,51 +926,53 @@ int32 CFE_TBL_ReadHeaders(osal_id_t FileDescriptor, CFE_FS_Header_t *StdFileHead */ TblFileHeaderPtr->TableName[sizeof(TblFileHeaderPtr->TableName) - 1] = '\0'; -/* Verify Spacecraft ID contained in table file header [optional] */ -#if (CFE_PLATFORM_TBL_VALID_SCID_COUNT > 0) - if (Status == CFE_SUCCESS) + /* Verify Spacecraft ID contained in table file header [optional] */ + if (Status == CFE_SUCCESS && ListSC.NumElements != 0) { - Status = CFE_TBL_ERR_BAD_SPACECRAFT_ID; - for (IndexSC = 0; IndexSC < CFE_PLATFORM_TBL_VALID_SCID_COUNT; IndexSC++) + ListPtr = ListSC.ElementPtr; + for (Idx = 0; Idx < ListSC.NumElements; ++Idx) { - if (StdFileHeaderPtr->SpacecraftID == ListSC[IndexSC]) + if (StdFileHeaderPtr->SpacecraftID == *ListPtr) { - Status = CFE_SUCCESS; + break; } + + ++ListPtr; } - if (Status == CFE_TBL_ERR_BAD_SPACECRAFT_ID) + if (Idx == ListSC.NumElements) { + Status = CFE_TBL_ERR_BAD_SPACECRAFT_ID; CFE_EVS_SendEventWithAppID(CFE_TBL_SPACECRAFT_ID_ERR_EID, CFE_EVS_EventType_ERROR, CFE_TBL_Global.TableTaskAppId, "Unable to verify Spacecraft ID for '%s', ID = 0x%08X", LoadFilename, (unsigned int)StdFileHeaderPtr->SpacecraftID); } } -#endif -/* Verify Processor ID contained in table file header [optional] */ -#if (CFE_PLATFORM_TBL_VALID_PRID_COUNT > 0) - if (Status == CFE_SUCCESS) + /* Verify Processor ID contained in table file header [optional] */ + if (Status == CFE_SUCCESS && ListPR.NumElements != 0) { - Status = CFE_TBL_ERR_BAD_PROCESSOR_ID; - for (IndexPR = 0; IndexPR < CFE_PLATFORM_TBL_VALID_PRID_COUNT; IndexPR++) + ListPtr = ListPR.ElementPtr; + for (Idx = 0; Idx < ListPR.NumElements; ++Idx) { - if (StdFileHeaderPtr->ProcessorID == ListPR[IndexPR]) + if (StdFileHeaderPtr->ProcessorID == *ListPtr) { - Status = CFE_SUCCESS; + break; } + + ++ListPtr; } - if (Status == CFE_TBL_ERR_BAD_PROCESSOR_ID) + if (Idx == ListPR.NumElements) { + Status = CFE_TBL_ERR_BAD_PROCESSOR_ID; CFE_EVS_SendEventWithAppID(CFE_TBL_PROCESSOR_ID_ERR_EID, CFE_EVS_EventType_ERROR, CFE_TBL_Global.TableTaskAppId, "Unable to verify Processor ID for '%s', ID = 0x%08X", LoadFilename, (unsigned int)StdFileHeaderPtr->ProcessorID); } } -#endif } } } diff --git a/modules/tbl/fsw/src/cfe_tbl_verify.h b/modules/tbl/fsw/src/cfe_tbl_verify.h index ad00f2022..b102afd04 100644 --- a/modules/tbl/fsw/src/cfe_tbl_verify.h +++ b/modules/tbl/fsw/src/cfe_tbl_verify.h @@ -47,23 +47,6 @@ #error CFE_PLATFORM_TBL_MAX_CRITICAL_TABLES cannot be greater than CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES! #endif -/* -** Any modifications to the "_VALID_" limits defined below must match -** source code changes made to the function CFE_TBL_ReadHeaders() in -** the file "cfe_tbl_internal.c". -*/ -#if CFE_PLATFORM_TBL_VALID_SCID_COUNT < 0 -#error CFE_PLATFORM_TBL_VALID_SCID_COUNT must be greater than or equal to zero -#elif CFE_PLATFORM_TBL_VALID_SCID_COUNT > 2 -#error CFE_PLATFORM_TBL_VALID_SCID_COUNT must be less than or equal to 2 -#endif - -#if CFE_PLATFORM_TBL_VALID_PRID_COUNT < 0 -#error CFE_PLATFORM_TBL_VALID_PRID_COUNT must be greater than or equal to zero -#elif CFE_PLATFORM_TBL_VALID_PRID_COUNT > 4 -#error CFE_PLATFORM_TBL_VALID_PRID_COUNT must be less than or equal to 4 -#endif - /* ** Validate task stack size... */ diff --git a/modules/tbl/ut-coverage/tbl_UT.c b/modules/tbl/ut-coverage/tbl_UT.c index 3d245b005..39a487532 100644 --- a/modules/tbl/ut-coverage/tbl_UT.c +++ b/modules/tbl/ut-coverage/tbl_UT.c @@ -38,6 +38,7 @@ */ #include "tbl_UT.h" #include "cfe_core_resourceid_basevalues.h" +#include "cfe_config.h" /* ** External global variables @@ -199,6 +200,12 @@ void UT_TBL_ResetDumpCtrlState(uint32 ArrayIndex) memset(DumpCtrlPtr, 0, sizeof(*DumpCtrlPtr)); } +static void UT_ArrayConfigHandler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_Config_ArrayValue_t Val = *((const CFE_Config_ArrayValue_t *)UserObj); + UT_Stub_SetReturnValue(FuncKey, Val); +} + /* ** Functions */ @@ -1242,6 +1249,9 @@ void Test_CFE_TBL_LoadCmd(void) CFE_TBL_LoadCmd_t LoadCmd; CFE_ES_AppId_t AppID; + uint32 IdValue; + CFE_Config_ArrayValue_t UTAV = {1, &IdValue}; + CFE_ES_GetAppID(&AppID); UtPrintf("Begin Test Load Command"); @@ -1254,13 +1264,16 @@ void Test_CFE_TBL_LoadCmd(void) /* Start with a cleared global (no tables registered) */ memset(&CFE_TBL_Global, 0, sizeof(CFE_TBL_Global)); + IdValue = 0x123; + UT_SetHandlerFunction(UT_KEY(CFE_Config_GetArrayValue), UT_ArrayConfigHandler, &UTAV); + /* Set up the headers */ strncpy(StdFileHeader.Description, "FS header description", sizeof(StdFileHeader.Description) - 1); StdFileHeader.Description[sizeof(StdFileHeader.Description) - 1] = '\0'; StdFileHeader.ContentType = CFE_FS_FILE_CONTENT_ID; StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; - StdFileHeader.SpacecraftID = CFE_PLATFORM_TBL_VALID_SCID_1; - StdFileHeader.ProcessorID = CFE_PLATFORM_TBL_VALID_PRID_1; + StdFileHeader.SpacecraftID = IdValue; + StdFileHeader.ProcessorID = IdValue; /* Test response to inability to open file */ UT_InitData(); @@ -1989,9 +2002,6 @@ void Test_CFE_TBL_Share(void) UtPrintf("Begin Test Share"); - StdFileHeader.SpacecraftID = CFE_PLATFORM_TBL_VALID_SCID_1; - StdFileHeader.ProcessorID = CFE_PLATFORM_TBL_VALID_PRID_1; - /* Test response to a null table handle and null table name */ UT_InitData(); UtAssert_INT32_EQ(CFE_TBL_Share(NULL, "ut_cfe_tbl.UT_Table2"), CFE_TBL_BAD_ARGUMENT); @@ -2144,9 +2154,6 @@ void Test_CFE_TBL_Load(void) UtPrintf("Begin Test Load"); - StdFileHeader.SpacecraftID = CFE_PLATFORM_TBL_VALID_SCID_1; - StdFileHeader.ProcessorID = CFE_PLATFORM_TBL_VALID_PRID_1; - /* Set up for table load test */ UT_InitData(); UT_SetAppID(UT_TBL_APPID_1); @@ -3085,9 +3092,6 @@ void Test_CFE_TBL_TblMod(void) UtPrintf("Begin Test Table Modified"); - FileHeader.SpacecraftID = CFE_PLATFORM_TBL_VALID_SCID_1; - FileHeader.ProcessorID = CFE_PLATFORM_TBL_VALID_PRID_1; - /* Test adding a TBL API for notifying table services that the table has * been updated by the application */ @@ -3258,12 +3262,14 @@ void Test_CFE_TBL_Internal(void) CFE_TBL_File_Hdr_t TblFileHeader; osal_id_t FileDescriptor; void * TblPtr; + uint32 IdValue; + CFE_Config_ArrayValue_t UTAV = {1, &IdValue}; + + IdValue = 0x123; UtPrintf("Begin Test Internal"); - FileDescriptor = OS_OBJECT_ID_UNDEFINED; - StdFileHeader.SpacecraftID = CFE_PLATFORM_TBL_VALID_SCID_1; - StdFileHeader.ProcessorID = CFE_PLATFORM_TBL_VALID_PRID_1; + FileDescriptor = OS_OBJECT_ID_UNDEFINED; /* Test setup - register a double buffered table */ UT_InitData(); @@ -3942,13 +3948,13 @@ void Test_CFE_TBL_Internal(void) UtAssert_INT32_EQ(DumpCtrlPtr->State, CFE_TBL_DUMP_PENDING); CFE_UtAssert_RESOURCEID_EQ(RegRecPtr->OwnerAppId, UT_TBL_APPID_2); -#if (CFE_PLATFORM_TBL_VALID_SCID_COUNT > 0) /* Test CFE_TBL_ReadHeaders response to an invalid spacecraft ID */ UT_InitData(); + UT_SetHandlerFunction(UT_KEY(CFE_Config_GetArrayValue), UT_ArrayConfigHandler, &UTAV); StdFileHeader.ContentType = CFE_FS_FILE_CONTENT_ID; StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; - StdFileHeader.SpacecraftID = -1; - StdFileHeader.ProcessorID = CFE_PLATFORM_TBL_VALID_PRID_1; + StdFileHeader.SpacecraftID = ~IdValue; + StdFileHeader.ProcessorID = IdValue; strncpy(TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName) - 1); TblFileHeader.TableName[sizeof(TblFileHeader.TableName) - 1] = '\0'; TblFileHeader.NumBytes = sizeof(UT_Table1_t) - 1; @@ -3968,17 +3974,14 @@ void Test_CFE_TBL_Internal(void) CFE_TBL_ERR_BAD_SPACECRAFT_ID); CFE_UtAssert_EVENTSENT(CFE_TBL_SPACECRAFT_ID_ERR_EID); CFE_UtAssert_EVENTCOUNT(1); -#else - UtAssert_NA("*Not tested* Invalid spacecraft ID "); -#endif -#if (CFE_PLATFORM_TBL_VALID_PRID_COUNT > 0) /* Test CFE_TBL_ReadHeaders response to an invalid processor ID */ UT_InitData(); + UT_SetHandlerFunction(UT_KEY(CFE_Config_GetArrayValue), UT_ArrayConfigHandler, &UTAV); StdFileHeader.ContentType = CFE_FS_FILE_CONTENT_ID; StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; - StdFileHeader.SpacecraftID = CFE_PLATFORM_TBL_VALID_SCID_1; - StdFileHeader.ProcessorID = -1; + StdFileHeader.SpacecraftID = IdValue; + StdFileHeader.ProcessorID = ~IdValue; strncpy(TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName) - 1); TblFileHeader.TableName[sizeof(TblFileHeader.TableName) - 1] = '\0'; TblFileHeader.NumBytes = sizeof(UT_Table1_t) - 1; @@ -3998,9 +4001,6 @@ void Test_CFE_TBL_Internal(void) CFE_TBL_ERR_BAD_PROCESSOR_ID); CFE_UtAssert_EVENTSENT(CFE_TBL_PROCESSOR_ID_ERR_EID); CFE_UtAssert_EVENTCOUNT(1); -#else - UtAssert_NA("*Not tested* Invalid processor ID "); -#endif /* Test CFE_TBL_RestoreTableDataFromCDS() when failed to get a working buffer */ UT_InitData();