diff --git a/.github/workflows/build-documentation.yml b/.github/workflows/build-documentation.yml index 2f319de62..c0c152c94 100644 --- a/.github/workflows/build-documentation.yml +++ b/.github/workflows/build-documentation.yml @@ -80,7 +80,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4.1.7 - name: Display structure of downloaded files run: ls -R diff --git a/CHANGELOG.md b/CHANGELOG.md index fd0fcba12..1fd77ed32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## Development Build: equuleus-rc1+dev199 +- Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows +- See + +## Development Build: equuleus-rc1+dev195 +- Use string append and add newline +- Yield cpu to other tasks in SB Perf Test +- See and + +## Development Build: equuleus-rc1+dev187 +- Use proper printf format for size_t +- See + ## Development Build: equuleus-rc1+dev183 - Runtime Error in coverage-es-ALL, TestApps - add config tool for platform-specific settings diff --git a/modules/cfe_testcase/src/sb_performance_test.c b/modules/cfe_testcase/src/sb_performance_test.c index fc3135543..bf7f6c159 100644 --- a/modules/cfe_testcase/src/sb_performance_test.c +++ b/modules/cfe_testcase/src/sb_performance_test.c @@ -37,6 +37,9 @@ /* Number of messages to send during test */ uint32_t UT_BulkTestDuration = 1000; +/* Number of SB messages sent before yielding CPU (has to be power of 2 minus 1)*/ +static uint32_t UT_CpuYieldMask = 1024 - 1; + /* State structure for multicore test - shared between threads */ typedef struct UT_BulkMultiCoreSharedState { @@ -209,6 +212,13 @@ void RunSingleCmdSendRecv(void) UtAssert_UINT32_EQ(CmdPtr->Payload.Value, CmdMsg.Payload.Value); break; } + + /* Only yield CPU once in a while to avoid slowing down the test with too many context switches */ + if ((BulkCmd.SendCount & UT_CpuYieldMask) == 0) + { + /* Yield cpu to other task with same priority */ + OS_TaskDelay(0); + } } CFE_PSP_GetTime(&BulkCmd.EndTime); @@ -255,6 +265,13 @@ void RunSingleTlmSendRecv(void) UtAssert_UINT32_EQ(TlmPtr->Payload.Value, TlmMsg.Payload.Value); break; } + + /* Only yield CPU once in a while to avoid slowing down the test with too many context switches */ + if ((BulkTlm.SendCount & UT_CpuYieldMask) == 0) + { + /* Yield cpu to other task with same priority */ + OS_TaskDelay(0); + } } CFE_PSP_GetTime(&BulkTlm.EndTime); @@ -388,12 +405,19 @@ void UT_CommandTransmitterTask(void) CFE_Assert_STATUS_MUST_BE(CFE_SUCCESS); break; } + + /* Only yield CPU once in a while to avoid slowing down the test with too many context switches */ + if ((BulkCmd.SendCount & UT_CpuYieldMask) == 0) + { + /* Yield cpu to other task with same priority */ + OS_TaskDelay(0); + } } BulkCmd.XmitFinished = true; } -void UT_TelemtryTransmitterTask(void) +void UT_TelemetryTransmitterTask(void) { CFE_SB_Buffer_t * BufPtr; CFE_TEST_TestTlmMessage32_t *TlmMsgPtr; @@ -424,6 +448,13 @@ void UT_TelemtryTransmitterTask(void) CFE_Assert_STATUS_MUST_BE(CFE_SUCCESS); break; } + + /* Only yield CPU once in a while to avoid slowing down the test with too many context switches */ + if ((BulkTlm.SendCount & UT_CpuYieldMask) == 0) + { + /* Yield cpu to other task with same priority */ + OS_TaskDelay(0); + } } BulkTlm.XmitFinished = true; @@ -521,7 +552,7 @@ void TestBulkTransferMulti4(void) CFE_ES_CreateChildTask(&BulkCmd.TaskIdXmit, "CmdXmit", UT_CommandTransmitterTask, NULL, 32768, 150, 0), CFE_SUCCESS); UtAssert_INT32_EQ( - CFE_ES_CreateChildTask(&BulkTlm.TaskIdXmit, "TlmXmit", UT_TelemtryTransmitterTask, NULL, 32768, 150, 0), + CFE_ES_CreateChildTask(&BulkTlm.TaskIdXmit, "TlmXmit", UT_TelemetryTransmitterTask, NULL, 32768, 150, 0), CFE_SUCCESS); UtAssert_INT32_EQ( CFE_ES_CreateChildTask(&BulkCmd.TaskIdRecv, "CmdRecv", UT_CommandReceiverTask, NULL, 32768, 100, 0), diff --git a/modules/config/tool/CMakeLists.txt b/modules/config/tool/CMakeLists.txt index 491b2bd77..e2cf1aa4d 100644 --- a/modules/config/tool/CMakeLists.txt +++ b/modules/config/tool/CMakeLists.txt @@ -44,10 +44,15 @@ foreach(SYSVAR ${TGTSYS_LIST}) ${TEMP_ARCH_BINARY_DIR}/inc ) + # If this is an EDS build, this needs to be built after the EDS tool runs + if (CFE_EDS_ENABLED_BUILD) + add_dependencies(${OBJLIB_NAME} edstool-execute) + endif() + set(PLATFORM_DEFINE_FILE ${MISSION_BINARY_DIR}/src/${OBJLIB_NAME}.c) set(PLATFORM_LIST_FILE ${MISSION_BINARY_DIR}/src/${OBJLIB_NAME}.list) list(APPEND PLATFORM_CONFIG_LIST $) - list(APPEND PLATFORM_OBJ_NAMES "CFE_PLATFORM(${SYSVAR})") + string(APPEND PLATFORM_OBJ_NAMES "CFE_PLATFORM(${SYSVAR})\n") add_custom_command( OUTPUT ${PLATFORM_DEFINE_FILE} @@ -79,4 +84,4 @@ target_include_directories(cfeconfig_platformdata_tool PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) -add_dependencies(mission-prebuild cfeconfig_platformdata_tool) \ No newline at end of file +add_dependencies(mission-prebuild cfeconfig_platformdata_tool) 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/core_api/fsw/inc/cfe_version.h b/modules/core_api/fsw/inc/cfe_version.h index 578cad7e9..7e8c293da 100644 --- a/modules/core_api/fsw/inc/cfe_version.h +++ b/modules/core_api/fsw/inc/cfe_version.h @@ -26,7 +26,7 @@ #define CFE_VERSION_H /* Development Build Macro Definitions */ -#define CFE_BUILD_NUMBER 183 /**< @brief Development: Number of development git commits since CFE_BUILD_BASELINE */ +#define CFE_BUILD_NUMBER 199 /**< @brief Development: Number of development git commits since CFE_BUILD_BASELINE */ #define CFE_BUILD_BASELINE "equuleus-rc1" /**< @brief Development: Reference git tag for build number */ #define CFE_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */ #define CFE_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */ 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 4cffb95f4..47110cdbe 100644 --- a/modules/es/fsw/src/cfe_es_verify.h +++ b/modules/es/fsw/src/cfe_es_verify.h @@ -175,8 +175,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 @@ -187,137 +187,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 d5c6abf8b..d72c559a0 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]; @@ -644,6 +653,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"); @@ -694,10 +709,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 c02046c05..097b2b8c4 100644 --- a/modules/sb/config/default_cfe_sb_internal_cfg.h +++ b/modules/sb/config/default_cfe_sb_internal_cfg.h @@ -32,6 +32,8 @@ #ifndef CFE_SB_INTERNAL_CFG_H #define CFE_SB_INTERNAL_CFG_H +#include "cfe_mission_cfg.h" + /** ** \cfesbcfg Maximum Number of Unique Message IDs SB Routing Table can hold ** @@ -231,6 +233,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 ** @@ -239,8 +256,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_api.c b/modules/sb/fsw/src/cfe_sb_api.c index 2eb3eedee..377179f4e 100644 --- a/modules/sb/fsw/src/cfe_sb_api.c +++ b/modules/sb/fsw/src/cfe_sb_api.c @@ -1398,7 +1398,7 @@ CFE_SB_Buffer_t *CFE_SB_AllocateMessageBuffer(size_t MsgSize) if (MsgSize > CFE_MISSION_SB_MAX_SB_MSG_SIZE) { CFE_ES_GetAppName(AppName, AppId, sizeof(AppName)); - CFE_ES_WriteToSysLog("%s %s: Failed, requested size %ld larger than allowed %d\n", + CFE_ES_WriteToSysLog("%s %s: Failed, requested size %zu larger than allowed %d\n", AppName, __func__, MsgSize, CFE_MISSION_SB_MAX_SB_MSG_SIZE); return NULL; } 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_api.c b/modules/tbl/fsw/src/cfe_tbl_api.c index 73f7174d5..b7c0de62f 100644 --- a/modules/tbl/fsw/src/cfe_tbl_api.c +++ b/modules/tbl/fsw/src/cfe_tbl_api.c @@ -1096,7 +1096,6 @@ CFE_Status_t CFE_TBL_DumpToBuffer(CFE_TBL_Handle_t TblHandle) int32 Status; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; CFE_TBL_DumpControl_t *DumpCtrlPtr = NULL; - CFE_TBL_LoadBuff_t * ActiveBufPtr; Status = CFE_TBL_TxnStartFromHandle(&Txn, TblHandle, CFE_TBL_TxnContext_ACCESSOR_APP); @@ -1109,7 +1108,6 @@ CFE_Status_t CFE_TBL_DumpToBuffer(CFE_TBL_Handle_t TblHandle) { RegRecPtr = CFE_TBL_TxnRegRec(&Txn); DumpCtrlPtr = CFE_TBL_LocateDumpCtrlByID(RegRecPtr->DumpControlId); - ActiveBufPtr = CFE_TBL_GetActiveBuffer(RegRecPtr); /* Copy the contents of the active buffer to the assigned dump buffer */ Status = CFE_TBL_EncodeFromMemory(DumpCtrlPtr->DumpBufferPtr->BufferPtr, &RegRecPtr->Buffers[0], RegRecPtr); diff --git a/modules/tbl/fsw/src/cfe_tbl_internal.c b/modules/tbl/fsw/src/cfe_tbl_internal.c index 0786edc1f..1814ecf40 100644 --- a/modules/tbl/fsw/src/cfe_tbl_internal.c +++ b/modules/tbl/fsw/src/cfe_tbl_internal.c @@ -1029,16 +1029,14 @@ int32 CFE_TBL_ReadHeaders(osal_id_t FileDescriptor, CFE_FS_Header_t *StdFileHead const EdsLib_DatabaseObject_t *EDS_DB = CFE_Config_GetObjPointer(CFE_CONFIGID_MISSION_EDS_DB); -#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); @@ -1117,51 +1115,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_task_cmds.c b/modules/tbl/fsw/src/cfe_tbl_task_cmds.c index ca614ac9e..f435b9dc6 100644 --- a/modules/tbl/fsw/src/cfe_tbl_task_cmds.c +++ b/modules/tbl/fsw/src/cfe_tbl_task_cmds.c @@ -559,7 +559,6 @@ int32 CFE_TBL_DumpCmd(const CFE_TBL_DumpCmd_t *data) CFE_SB_MessageStringGet(TableName, (char *)CmdPtr->TableName, NULL, sizeof(TableName), sizeof(CmdPtr->TableName)); - SrcBufferPtr = NULL; WorkingBufferPtr = NULL; RegRecPtr = NULL; DumpCtrlPtr = NULL; @@ -589,7 +588,7 @@ int32 CFE_TBL_DumpCmd(const CFE_TBL_DumpCmd_t *data) /* If this is not a dump only table, then we can perform the dump immediately */ if (!RegRecPtr->DumpOnly) { - ReturnCode = CFE_TBL_DumpToFile(DumpFilename, TableName, SelectedBufferPtr->BufferPtr, RegRecPtr->Size); + ReturnCode = CFE_TBL_DumpToFile(DumpFilename, TableName, SelectedBufferPtr->BufferPtr); } else /* Dump Only tables need to synchronize their dumps with the owner's execution */ { 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 0d9cfb434..7021b4059 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 @@ -297,6 +298,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 */ @@ -1314,6 +1321,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"); @@ -1326,13 +1336,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(); @@ -2061,9 +2074,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); @@ -2216,9 +2226,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); @@ -3149,9 +3156,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 */ @@ -3315,12 +3319,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(); @@ -3993,13 +3999,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; @@ -4013,17 +4019,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; @@ -4037,9 +4040,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();