diff --git a/.github/workflows/codeql-build.yml b/.github/workflows/codeql-build.yml new file mode 100644 index 000000000..28015abda --- /dev/null +++ b/.github/workflows/codeql-build.yml @@ -0,0 +1,56 @@ +name: "CodeQL Analysis" + +on: + push: + pull_request: + +env: + SIMULATION: native + ENABLE_UNIT_TESTS: true + OMIT_DEPRECATED: true + BUILDTYPE: release + +jobs: + + CodeQL-Build: + runs-on: ubuntu-18.04 + timeout-minutes: 15 + + steps: + # Checks out a copy of your repository on the ubuntu-latest machine + - name: Checkout bundle + uses: actions/checkout@v2 + with: + repository: nasa/cFS + submodules: true + + - name: Checkout submodule + uses: actions/checkout@v2 + with: + path: cfe + + - name: Check versions + run: git submodule + + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: c + queries: +security-extended, security-and-quality + + # Setup the build system + - name: Set up for build + run: | + cp ./cfe/cmake/Makefile.sample Makefile + cp -r ./cfe/cmake/sample_defs sample_defs + make prep + + # Build the code + - name: Build + run: | + make cfe-core + make native/default_cpu1/cfe-core/unit-test/ + make native/default_cpu1/cfe-core/ut-stubs/ + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 4386960f4..5e792f3aa 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -12,6 +12,7 @@ jobs: static-analysis: name: Run cppcheck runs-on: ubuntu-18.04 + timeout-minutes: 15 strategy: fail-fast: false diff --git a/README.md b/README.md index 0d9b51d9b..f7e5fb10c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Travis-CI: [![Build Status](https://travis-ci.com/nasa/cFE.svg)](https://travis-ci.com/nasa/cFE) +![Static Analysis](https://github.com/nasa/cfe/workflows/Static%20Analysis/badge.svg) # Core Flight System : Framework : Core Flight Executive @@ -10,6 +10,34 @@ The detailed cFE user's guide can be viewed at + ### Development Build: 6.8.0-rc1+dev290 - Documentation: Add Security.md with instructions to report vulnerability diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index e569f500b..e364d0f12 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -62,7 +62,7 @@ endfunction(initialize_globals) function(add_psp_module MOD_NAME MOD_SRC_FILES) # Include the PSP shared directory so it can get to cfe_psp_module.h - include_directories(${MISSION_SOURCE_DIR}/psp/fsw/shared) + include_directories(${MISSION_SOURCE_DIR}/psp/fsw/shared/inc) add_definitions(-D_CFE_PSP_MODULE_) # Create the module diff --git a/cmake/mission_defaults.cmake b/cmake/mission_defaults.cmake index 444a1138e..2f7ee42c1 100644 --- a/cmake/mission_defaults.cmake +++ b/cmake/mission_defaults.cmake @@ -16,6 +16,7 @@ set(MISSION_CORE_MODULES "psp" "msg" "sbr" + "resourceid" ) # The "MISSION_GLOBAL_APPLIST" is a set of apps/libs that will be built diff --git a/cmake/sample_defs/cpu1_platform_cfg.h b/cmake/sample_defs/cpu1_platform_cfg.h index a613f821b..66a6cf229 100644 --- a/cmake/sample_defs/cpu1_platform_cfg.h +++ b/cmake/sample_defs/cpu1_platform_cfg.h @@ -130,49 +130,29 @@ */ #define CFE_PLATFORM_SB_BUF_MEMORY_BYTES 524288 - -/** -** \cfesbcfg Maximum depth allowed when creating an SB pipe -** -** \par Description: -** The value of this constant dictates the maximum pipe depth that an -** application may request. The pipe depth is given as a paramter in the -** #CFE_SB_CreatePipe API. -** -** \par Limits -** This parameter has a lower limit of 1. There are no restrictions on the -** upper limit however, the maximum pipe depth is system dependent and should -** be verified. Pipe Depth values that are checked against this configuration -** are defined by a 16 bit data word. -*/ -#define CFE_PLATFORM_SB_MAX_PIPE_DEPTH 256 - - /** ** \cfesbcfg Highest Valid Message Id ** ** \par Description: -** The value of this constant dictates the size of the SB message map. The SB -** message map is a lookup table that provides the routing table index for -** fast access into the routing table. The default setting of 0x1FFF was chosen -** to save memory. This reduces the message map from 128Kbytes to 16Kbytes. -** See CFE_FSW_DCR 504 for more details. -** -** If this value is different in a distributed architecture some platforms may not -** be able to subscribe to messages generated on other platforms since the message id -** would exceed the mapping table's highest index. Care would have to be taken to ensure the -** constrained platform did not subscribe to message Ids that exceed -** CFE_PLATFORM_SB_HIGHEST_VALID_MSGID +** The value of this constant dictates the range of valid message ID's, from 0 +** to CFE_PLATFORM_SB_HIGHEST_VALID_MSGID (inclusive). ** -** The recommended case to to have this value the same across all mission platforms +** Altough this can be defined differently across platforms, each platform can +** only publish/subscribe to message ids within their allowable range. Typically +** this value is set the same across all mission platforms to avoid this complexity. ** ** \par Limits -** This parameter has a lower limit of 1 and an upper limit of 0xFFFF. Note -** for current implementations, V2/Extended headers assign 0xFFFFFFFF as the invalid -** message ID value, and default headers assigns 0xFFFF as the invalid value. This -** means for default headers, 0xFFFF is invalid even if you set the value -** below to it's maximum of 0xFFFF. -** The allocated message table is this size + 1 (could change based on implementaiton). +** CFE_SB_INVALID_MSG is set to the maxumum representable number of type CFE_SB_MsgId_t. +** CFE_PLATFORM_SB_HIGHEST_VALID_MSGID lower limit is 1, up to CFE_SB_INVALID_MSG_ID - 1. +** +** When using the direct message map implementation for software bus routing, this +** value is used to size the map where a value of 0x1FFF results in a 16 KBytes map +** and 0xFFFF is 128 KBytes. +** +** When using the hash implementation for software bus routing, a multiple of the +** CFE_PLATFORM_SB_MAX_MSG_IDS is used to size the message map. In that case +** the range selected here does not impact message map memory use, so it's +** resonable to use up to the full range supported by the message ID implementation. */ #define CFE_PLATFORM_SB_HIGHEST_VALID_MSGID 0x1FFF @@ -1455,20 +1435,6 @@ #define CFE_PLATFORM_EVS_MAX_EVENT_FILTERS 8 -/** -** \cfeevscfg Enable or Disable EVS Local Event Log -** -** \par Description: -** The CFE_PLATFORM_EVS_LOG_ON configuration parameter must be defined to enable EVS -** event logging. In order to disable the local event log this definition needs -** to be commented out. -** -** \par Limits -** Not Applicable -*/ -#define CFE_PLATFORM_EVS_LOG_ON - - /** ** \cfeevscfg Default Event Log Filename ** diff --git a/docs/src/cfe_es.dox b/docs/src/cfe_es.dox index b08bf4073..01f829c52 100644 --- a/docs/src/cfe_es.dox +++ b/docs/src/cfe_es.dox @@ -366,9 +366,16 @@ /** \page cfeesugapprestart Restarting an Application - The #CFE_ES_RESTART_APP_CC command is used to restart an application. - This command stops and restarts an application using the parameters - defined when the application was originally started, either through + The #CFE_ES_RESTART_APP_CC command is used to restart an application + using the same file name as the last start. + + This command checks for file existence, the application is running, + and the application is not a core app. If valid, the application restart + is requested. + + When requested, ES stops the application, unloads the object file, loads the object file + using the previous file name, and restarts an application using the parameters + defined when the application was previously started, either through the startup script or by way of the #CFE_ES_START_APP_CC command. Next: \ref cfeesugappreload
@@ -379,12 +386,11 @@ /** \page cfeesugappreload Reloading an Application - The #CFE_ES_RELOAD_APP_CC command is used to reload an application. - This command stops the application, unloads the object file, loads - the new object file specified in the command and starts the application - again using the parameters defined when the application was originally - started, either through the startup script or by way of the - #CFE_ES_START_APP_CC command. + The #CFE_ES_RELOAD_APP_CC command is used to reload an application + using a new file name. + + This command performes + the same actions as #CFE_ES_RESTART_APP_CC only using the new file. Next: \ref cfeesugapplist
Prev: \ref cfeesugapprestart
diff --git a/docs/src/cfe_sb.dox b/docs/src/cfe_sb.dox index 0afc0c21e..2dc795568 100644 --- a/docs/src/cfe_sb.dox +++ b/docs/src/cfe_sb.dox @@ -104,7 +104,7 @@ The Pipe IDs are specific to a particular processor (that is, the same ID number may refer to a different pipe on each processor). The pipe information for all pipes that have been created, may be requested at anytime by sending the - \link #CFE_SB_SEND_PIPE_INFO_CC 'Send Pipe Info' SB command \endlink. The software + \link #CFE_SB_WRITE_PIPE_INFO_CC 'Write Pipe Info' SB command \endlink. The software bus also provides a set of figures regarding capacity, current utilization and high water marks relevant to pipes. This information may be requested by sending the command to \link #CFE_SB_SEND_SB_STATS_CC dump the SB statistics packet \endlink. @@ -445,12 +445,10 @@ Quality of Service (QOS) for off-board routing and is of the type #CFE_SB_Qos_t. This structure has two members named priority and reliability. The Quality parameter is currently unused by the software bus. It is a placeholder to be used with the future software bus capability of - inter-processor communication. Although currently the software bus does not read the Quality - values, it would be best to set this parameter to the value defined as #CFE_SB_Default_Qos. - This value is set internally by the software bus with values of zero for priority and - reliability. The values of zero will correspond to low priority and low reliability. Setting - the QOS value to the #CFE_SB_Default_Qos will ensure seamless integration when the software - bus is expanded to support inter-processor communication. + inter-processor communication. Although currently the software bus does not implement quality + of service. + + A default quality of services is provided via the #CFE_SB_DEFAULT_QOS macro. Next: \ref cfesbugknwnprob
Prev: \ref cfesbugroutcntrl
@@ -569,9 +567,8 @@   The QOS parameter is currently unused by the software bus. It is a placeholder to be used with the future software bus capability of inter-processor communication. Setting - the QOS value to the SB defined #CFE_SB_Default_Qos (QOS.Priority=0,QOS.Reliability=0) - will ensure seamless integration when the software bus is expanded to support - inter-processor communication. + the QOS as #CFE_SB_DEFAULT_QOS will ensure seamless integration when the software bus + is expanded to support inter-processor communication. (Q) Can I confirm my software bus buffer was delivered?   diff --git a/docs/src/cfe_tbl.dox b/docs/src/cfe_tbl.dox index d528283d9..e0aedb8a8 100644 --- a/docs/src/cfe_tbl.dox +++ b/docs/src/cfe_tbl.dox @@ -22,45 +22,11 @@
  • \subpage cfetblugregistry
  • \subpage cfetblugtelemetry
  • \subpage cfetblugprocreset
    -
  • \subpage cfetblugdecouple
  • \subpage cfetblugfaq
    **/ -/** - \page cfetblugdecouple How To Remove cFE Table Services - - It is possible to build the CFE without including Table Services. This is only applicable if - the mission does not intend to use any CFS applications that require CFE type table services, or - if the mission intends to provide custom table services. If CFE Table Services are removed, the - CFE makefile will no longer try to make the Table Services application and the link makefile will - no longer include the Table Services object module in the CFE-CORE. Even if excluded from the build, - the Table Services source and header files will remain in the CFE source tree. - - If EXCLUDE_CFE_TBL is defined (typically in the applicable *_platform_config.h file) Executive - services will not load or shut down table services. Note this option does not effect the build - and link of table services. - - To remove table services from the build completely, remove "tbl" from the CFE_CORE_MODULES - in the cfe/fsw/cfe-core CMakeLists.txt directory (note this option also needs EXCLUDE_CFE_TBL defined - or executive services will try to load it). - - Removing Table Services reduces the size of the CFE-CORE load file and also reduces the amount - of RAM memory required to load the cFE. Each development environment will have unique savings. - The numbers from an example default linux build are as follows: - - Size of core cFE binary load file with Table Services: 963K - Size of core cFE binary load file w/o building Table services: 871K - - RAM used after loading cFE with Table Services: 153K - RAM used after loading cFE w/o loading Table Services: 144M - - Next: \ref cfetblugfaq
    - Prev: \ref cfetblugprocreset
    - Up To: \ref cfetblovr -**/ - /** \page cfetblugmanage Managing Tables @@ -344,7 +310,7 @@ contents of the table are automatically loaded into the table and the Application is notified that the table does not require additional initialization. - Next: \ref cfetblugdecouple
    + Next: \ref cfetblugfaq
    Prev: \ref cfetblugtelemetry
    Up To: \ref cfetblovr **/ @@ -441,7 +407,7 @@ - Prev: \ref cfetblugdecouple
    + Prev: \ref cfetblugprocreset
    Up To: \ref cfetblovr **/ diff --git a/fsw/cfe-core/src/es/cfe_es_api.c b/fsw/cfe-core/src/es/cfe_es_api.c index 15a3a8163..916264a1d 100644 --- a/fsw/cfe-core/src/es/cfe_es_api.c +++ b/fsw/cfe-core/src/es/cfe_es_api.c @@ -168,9 +168,10 @@ int32 CFE_ES_ResetCFE(uint32 ResetType) /* ** Function: CFE_ES_RestartApp - See API and header file for details */ -int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) +int32 CFE_ES_RestartApp(CFE_ES_AppId_t AppID) { int32 ReturnCode = CFE_SUCCESS; + os_fstat_t FileStatus; CFE_ES_AppRecord_t *AppRecPtr; AppRecPtr = CFE_ES_LocateAppRecordByID(AppID); @@ -196,9 +197,22 @@ int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) } else { - CFE_ES_SysLogWrite_Unsync("CFE_ES_RestartApp: Restart Application %s Initiated\n", - CFE_ES_AppRecordGetName(AppRecPtr)); - AppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RESTART; + /* + ** Check to see if the file exists + */ + if (OS_stat(AppRecPtr->StartParams.BasicInfo.FileName, &FileStatus) == OS_SUCCESS) + { + CFE_ES_SysLogWrite_Unsync("CFE_ES_RestartApp: Restart Application %s Initiated\n", + CFE_ES_AppRecordGetName(AppRecPtr)); + AppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RESTART; + } + else + { + CFE_ES_SysLogWrite_Unsync ("CFE_ES_RestartApp: Cannot Restart Application %s, File %s does not exist.\n", + CFE_ES_AppRecordGetName(AppRecPtr), AppRecPtr->StartParams.BasicInfo.FileName); + ReturnCode = CFE_ES_FILE_IO_ERR; + } + } CFE_ES_UnlockSharedData(__func__,__LINE__); @@ -208,7 +222,7 @@ int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID; CFE_ES_WriteToSysLog("CFE_ES_RestartApp: Invalid Application ID received, AppID = %lu\n", - CFE_ES_ResourceID_ToInteger(AppID)); + CFE_RESOURCEID_TO_ULONG(AppID)); } /* end if */ @@ -219,7 +233,7 @@ int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) /* ** Function: CFE_ES_ReloadApp - See API and header file for details */ -int32 CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName) +int32 CFE_ES_ReloadApp(CFE_ES_AppId_t AppID, const char *AppFileName) { int32 ReturnCode = CFE_SUCCESS; os_fstat_t FileStatus; @@ -278,7 +292,7 @@ int32 CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName) /* ** Function: CFE_ES_DeleteApp - See API and header file for details */ -int32 CFE_ES_DeleteApp(CFE_ES_ResourceID_t AppID) +int32 CFE_ES_DeleteApp(CFE_ES_AppId_t AppID) { int32 ReturnCode = CFE_SUCCESS; CFE_ES_AppRecord_t *AppRecPtr = CFE_ES_LocateAppRecordByID(AppID); @@ -545,7 +559,7 @@ bool CFE_ES_RunLoop(uint32 *RunStatus) */ int32 CFE_ES_WaitForSystemState(uint32 MinSystemState, uint32 TimeOutMilliseconds) { - int32 Status; + int32 Status = CFE_SUCCESS; CFE_ES_AppRecord_t *AppRecPtr; uint32 RequiredAppState; uint32 WaitTime; @@ -691,7 +705,7 @@ int32 CFE_ES_RegisterApp(void) /* ** Function: CFE_ES_GetAppIDByName - See API and header file for details */ -int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) +int32 CFE_ES_GetAppIDByName(CFE_ES_AppId_t *AppIdPtr, const char *AppName) { CFE_ES_AppRecord_t *AppRecPtr; int32 Result; @@ -711,7 +725,7 @@ int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) * in case the does not check the return code. */ Result = CFE_ES_ERR_NAME_NOT_FOUND; - *AppIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *AppIdPtr = CFE_ES_APPID_UNDEFINED; } else { @@ -728,7 +742,7 @@ int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) /* ** Function: CFE_ES_GetLibIDByName - See API and header file for details */ -int32 CFE_ES_GetLibIDByName(CFE_ES_ResourceID_t *LibIdPtr, const char *LibName) +int32 CFE_ES_GetLibIDByName(CFE_ES_LibId_t *LibIdPtr, const char *LibName) { CFE_ES_LibRecord_t *LibRecPtr; int32 Result; @@ -748,7 +762,7 @@ int32 CFE_ES_GetLibIDByName(CFE_ES_ResourceID_t *LibIdPtr, const char *LibName) * in case the does not check the return code. */ Result = CFE_ES_ERR_NAME_NOT_FOUND; - *LibIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *LibIdPtr = CFE_ES_LIBID_UNDEFINED; } else { @@ -764,7 +778,7 @@ int32 CFE_ES_GetLibIDByName(CFE_ES_ResourceID_t *LibIdPtr, const char *LibName) /* ** Function: CFE_ES_GetTaskIDByName - See API and header file for details */ -CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_ResourceID_t *TaskIdPtr, const char *TaskName) +CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName) { osal_id_t OsalId; int32 Status; @@ -780,12 +794,12 @@ CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_ResourceID_t *TaskIdPtr, const char * if (Status == OS_SUCCESS) { Result = CFE_SUCCESS; - *TaskIdPtr = CFE_ES_ResourceID_FromOSAL(OsalId); + *TaskIdPtr = CFE_ES_TaskId_FromOSAL(OsalId); } else { Result = CFE_ES_ERR_NAME_NOT_FOUND; - *TaskIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *TaskIdPtr = CFE_ES_TASKID_UNDEFINED; } return(Result); @@ -795,7 +809,7 @@ CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_ResourceID_t *TaskIdPtr, const char * /* ** Function: CFE_ES_GetAppID - See API and header file for details */ -int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) +int32 CFE_ES_GetAppID(CFE_ES_AppId_t *AppIdPtr) { CFE_ES_AppRecord_t *AppRecPtr; int32 Result; @@ -811,7 +825,7 @@ int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) } else { - *AppIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *AppIdPtr = CFE_ES_APPID_UNDEFINED; Result = CFE_ES_ERR_RESOURCEID_NOT_VALID; } @@ -824,7 +838,7 @@ int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) /* ** Function: CFE_ES_GetTaskID - See API and header file for details */ -int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) +int32 CFE_ES_GetTaskID(CFE_ES_TaskId_t *TaskIdPtr) { int32 Result; CFE_ES_TaskRecord_t *TaskRecPtr; @@ -833,7 +847,7 @@ int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) TaskRecPtr = CFE_ES_GetTaskRecordByContext(); if (TaskRecPtr == NULL) { - *TaskIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *TaskIdPtr = CFE_ES_TASKID_UNDEFINED; Result = CFE_ES_ERR_RESOURCEID_NOT_VALID; } else @@ -848,7 +862,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, size_t BufferLength) +int32 CFE_ES_GetAppName(char *AppName, CFE_ES_AppId_t AppId, size_t BufferLength) { int32 Result; CFE_ES_AppRecord_t *AppRecPtr; @@ -890,7 +904,7 @@ int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t BufferL /* ** Function: CFE_ES_GetLibName - See API and header file for details */ -int32 CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, size_t BufferLength) +int32 CFE_ES_GetLibName(char *LibName, CFE_ES_LibId_t LibId, size_t BufferLength) { int32 Result; CFE_ES_LibRecord_t *LibRecPtr; @@ -932,7 +946,7 @@ int32 CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, size_t BufferL /* ** Function: CFE_ES_GetTaskName - See API and header file for details */ -int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, size_t BufferLength) +int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_TaskId_t TaskId, size_t BufferLength) { int32 Result; osal_id_t OsalId; @@ -942,15 +956,15 @@ int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, size_t Buff return CFE_ES_BAD_ARGUMENT; } - if (!CFE_ES_ResourceID_IsDefined(TaskId)) + if (!CFE_RESOURCEID_TEST_DEFINED(TaskId)) { return CFE_ES_ERR_RESOURCEID_NOT_VALID; } /* - * Query OSAL to get the task ID + * Query OSAL to get the task name */ - OsalId = CFE_ES_ResourceID_ToOSAL(TaskId); + OsalId = CFE_ES_TaskId_ToOSAL(TaskId); Result = OS_GetResourceName(OsalId, TaskName, BufferLength); if (Result != OS_SUCCESS) @@ -965,7 +979,7 @@ int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, size_t Buff /* ** Function: CFE_ES_GetAppInfo - See API and header file for details */ -int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) +int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_AppId_t AppId) { CFE_ES_AppRecord_t *AppRecPtr; CFE_ES_TaskRecord_t *TaskRecPtr; @@ -992,13 +1006,13 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) * Log a message if called with an invalid ID. */ CFE_ES_WriteToSysLog("CFE_ES_GetAppInfo: App ID not active: %lu\n", - CFE_ES_ResourceID_ToInteger(AppId)); + CFE_RESOURCEID_TO_ULONG(AppId)); Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; } else { - AppInfo->AppId = AppId; + AppInfo->ResourceId = CFE_RESOURCEID_UNWRAP(AppId); /* make into a generic resource ID */ AppInfo->Type = AppRecPtr->Type; CFE_ES_CopyModuleBasicInfo(&AppRecPtr->StartParams.BasicInfo, AppInfo); @@ -1019,9 +1033,9 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) for (i=0; iAppId, AppId)) + CFE_RESOURCEID_TEST_EQUAL(TaskRecPtr->AppId, AppId)) { - if (CFE_ES_ResourceID_Equal(CFE_ES_TaskRecordGetID(TaskRecPtr), AppInfo->MainTaskId)) + if (CFE_RESOURCEID_TEST_EQUAL(CFE_ES_TaskRecordGetID(TaskRecPtr), AppInfo->MainTaskId)) { /* This is the main task - capture its name and execution count */ AppInfo->ExecutionCounter = TaskRecPtr->ExecutionCounter; @@ -1057,7 +1071,7 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) /* ** Function: CFE_ES_GetLibInfo - See API and header file for details */ -int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_ResourceID_t LibId) +int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_LibId_t LibId) { int32 Status; CFE_ES_LibRecord_t *LibRecPtr; @@ -1082,13 +1096,13 @@ int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_ResourceID_t LibId) * Log a message if called with an invalid ID. */ CFE_ES_SysLogWrite_Unsync("CFE_ES_GetLibInfo: Lib ID not active: %lu\n", - CFE_ES_ResourceID_ToInteger(LibId)); + CFE_RESOURCEID_TO_ULONG(LibId)); Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; } else { - LibInfo->AppId = CFE_ES_LibRecordGetID(LibRecPtr);; + LibInfo->ResourceId = CFE_RESOURCEID_UNWRAP(LibId); /* make into generic ID */ LibInfo->Type = CFE_ES_AppType_LIBRARY; CFE_ES_CopyModuleBasicInfo(&LibRecPtr->BasicInfo, LibInfo); @@ -1115,24 +1129,24 @@ int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_ResourceID_t LibId) /* ** Function: CFE_ES_GetModuleInfo - See API and header file for details */ -int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ES_ResourceID_t ResourceId) +int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ResourceId_t ResourceId) { int32 Status; - switch(CFE_ES_ResourceID_GetBase(ResourceId)) + switch(CFE_ResourceId_GetBase(ResourceId)) { case CFE_ES_APPID_BASE: - Status = CFE_ES_GetAppInfo(ModuleInfo, ResourceId); + Status = CFE_ES_GetAppInfo(ModuleInfo, CFE_ES_APPID_C(ResourceId)); break; case CFE_ES_LIBID_BASE: - Status = CFE_ES_GetLibInfo(ModuleInfo, ResourceId); + Status = CFE_ES_GetLibInfo(ModuleInfo, CFE_ES_LIBID_C(ResourceId)); break; default: /* * Log a message if called with an invalid ID. */ CFE_ES_WriteToSysLog("CFE_ES_GetModuleInfo: Resource ID not valid: %lu\n", - CFE_ES_ResourceID_ToInteger(ResourceId)); + CFE_ResourceId_ToInteger(ResourceId)); Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; break; @@ -1145,7 +1159,7 @@ int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ES_ResourceID_t Res /* ** Function: CFE_ES_GetTaskInfo - See API and header file for details */ -int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId) +int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_TaskId_t TaskId) { CFE_ES_TaskRecord_t *TaskRecPtr; CFE_ES_AppRecord_t *AppRecPtr; @@ -1168,7 +1182,7 @@ int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId /* task ID is bad */ Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; CFE_ES_SysLogWrite_Unsync("CFE_ES_GetTaskInfo: Task ID Not Active: %lu\n", - CFE_ES_ResourceID_ToInteger(TaskId)); + CFE_RESOURCEID_TO_ULONG(TaskId)); } else { @@ -1221,7 +1235,7 @@ int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId /* ** Function: CFE_ES_CreateChildTask - See API and header file for details */ -int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, +int32 CFE_ES_CreateChildTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, CFE_ES_StackPointer_t StackPtr, @@ -1234,9 +1248,8 @@ int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, CFE_ES_AppRecord_t *AppRecPtr; CFE_ES_TaskRecord_t *TaskRecPtr; int32 ReturnCode; - CFE_ES_ResourceID_t TaskId; - CFE_ES_ResourceID_t ChildTaskId; - CFE_ES_ResourceID_t ParentTaskId; + CFE_ES_TaskId_t SelfTaskId; + CFE_ES_TaskId_t LocalChildTaskId; osal_id_t OsalId; /* @@ -1286,9 +1299,8 @@ int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, ** TaskID must be the same as the Parent Task ID. */ OsalId = OS_TaskGetId(); - TaskId = CFE_ES_ResourceID_FromOSAL(OsalId); - ParentTaskId = AppRecPtr->MainTaskId; - if ( CFE_ES_ResourceID_Equal(TaskId, ParentTaskId) ) + SelfTaskId = CFE_ES_TaskId_FromOSAL(OsalId); + if ( CFE_RESOURCEID_TEST_EQUAL(SelfTaskId, AppRecPtr->MainTaskId) ) { /* ** Step 2: Create the new task using the OS API call @@ -1301,16 +1313,16 @@ int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, */ if ( Result == OS_SUCCESS ) { - ChildTaskId = CFE_ES_ResourceID_FromOSAL(OsalId); - TaskRecPtr = CFE_ES_LocateTaskRecordByID(ChildTaskId); + LocalChildTaskId = CFE_ES_TaskId_FromOSAL(OsalId); + TaskRecPtr = CFE_ES_LocateTaskRecordByID(LocalChildTaskId); - CFE_ES_TaskRecordSetUsed(TaskRecPtr, ChildTaskId); + CFE_ES_TaskRecordSetUsed(TaskRecPtr, CFE_RESOURCEID_UNWRAP(LocalChildTaskId)); TaskRecPtr->AppId = CFE_ES_AppRecordGetID(AppRecPtr); strncpy(TaskRecPtr->TaskName,TaskName,sizeof(TaskRecPtr->TaskName) - 1); TaskRecPtr->TaskName[sizeof(TaskRecPtr->TaskName) - 1] = '\0'; CFE_ES_Global.RegisteredTasks++; - *TaskIdPtr = ChildTaskId; + *TaskIdPtr = CFE_ES_TaskRecordGetID(TaskRecPtr); ReturnCode = CFE_SUCCESS; } else @@ -1382,7 +1394,7 @@ int32 CFE_ES_RegisterChildTask(void) void CFE_ES_IncrementTaskCounter(void) { CFE_ES_TaskRecord_t *TaskRecPtr; - CFE_ES_ResourceID_t TaskID; + CFE_ES_TaskId_t TaskID; /* * Note this locates a task record but intentionally does _not_ @@ -1395,7 +1407,7 @@ void CFE_ES_IncrementTaskCounter(void) * Because the global data is not locked, only minimal validation * is performed. */ - TaskID = CFE_ES_ResourceID_FromOSAL(OS_TaskGetId()); + TaskID = CFE_ES_TaskId_FromOSAL(OS_TaskGetId()); TaskRecPtr = CFE_ES_LocateTaskRecordByID(TaskID); if (TaskRecPtr != NULL) { @@ -1409,7 +1421,7 @@ void CFE_ES_IncrementTaskCounter(void) /* ** Function: CFE_ES_DeleteChildTask - See API and header file for details */ -int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) +int32 CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId) { CFE_ES_TaskRecord_t *TaskRecPtr; CFE_ES_AppRecord_t *AppRecPtr; @@ -1442,7 +1454,7 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) { if ( CFE_ES_AppRecordIsUsed(AppRecPtr) ) { - if ( CFE_ES_ResourceID_Equal(AppRecPtr->MainTaskId, TaskId) ) + if ( CFE_RESOURCEID_TEST_EQUAL(AppRecPtr->MainTaskId, TaskId) ) { /* ** Error, the task Id is an App Main Task ID @@ -1459,7 +1471,7 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) /* ** Can delete the Task */ - OsalId = CFE_ES_ResourceID_ToOSAL(TaskId); + OsalId = CFE_ES_TaskId_ToOSAL(TaskId); OSReturnCode = OS_TaskDelete(OsalId); if ( OSReturnCode == OS_SUCCESS ) { @@ -1473,13 +1485,13 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) ** Report the task delete */ CFE_ES_SysLogWrite_Unsync("CFE_ES_DeleteChildTask Task %lu Deleted\n", - CFE_ES_ResourceID_ToInteger(TaskId)); + CFE_RESOURCEID_TO_ULONG(TaskId)); ReturnCode = CFE_SUCCESS; } else { CFE_ES_SysLogWrite_Unsync("CFE_ES_DeleteChildTask Error: Error Calling OS_TaskDelete: Task %lu, RC = 0x%08X\n", - CFE_ES_ResourceID_ToInteger(TaskId), (unsigned int)OSReturnCode); + CFE_RESOURCEID_TO_ULONG(TaskId), (unsigned int)OSReturnCode); ReturnCode = CFE_ES_ERR_CHILD_TASK_DELETE; } } @@ -1489,7 +1501,7 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) ** Error: The task is a cFE Application Main task */ CFE_ES_SysLogWrite_Unsync("CFE_ES_DeleteChildTask Error: Task %lu is a cFE Main Task.\n", - CFE_ES_ResourceID_ToInteger(TaskId)); + CFE_RESOURCEID_TO_ULONG(TaskId)); ReturnCode = CFE_ES_ERR_CHILD_TASK_DELETE_MAIN_TASK; } /* end if TaskMain == false */ } @@ -1499,7 +1511,7 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) ** Task ID is not in use, so it is invalid */ CFE_ES_SysLogWrite_Unsync("CFE_ES_DeleteChildTask Error: Task ID is not active: %lu\n", - CFE_ES_ResourceID_ToInteger(TaskId)); + CFE_RESOURCEID_TO_ULONG(TaskId)); ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID; } /* end if */ @@ -1513,7 +1525,7 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) ** Task ID is invalid ( too large ) */ CFE_ES_WriteToSysLog("CFE_ES_DeleteChildTask Error: Invalid Task ID: %lu\n", - CFE_ES_ResourceID_ToInteger(TaskId)); + CFE_RESOURCEID_TO_ULONG(TaskId)); ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID; } @@ -1568,7 +1580,7 @@ void CFE_ES_ExitChildTask(void) else { CFE_ES_SysLogWrite_Unsync("CFE_ES_ExitChildTask Error: Cannot Call from a cFE App Main Task. ID = %lu\n", - CFE_ES_ResourceID_ToInteger(CFE_ES_TaskRecordGetID(TaskRecPtr))); + CFE_RESOURCEID_TO_ULONG(CFE_ES_TaskRecordGetID(TaskRecPtr))); } } else @@ -1704,13 +1716,13 @@ int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, size_t BlockSize, con { int32 Status; size_t NameLen; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; char AppName[OS_MAX_API_NAME] = {"UNKNOWN"}; char CDSName[CFE_MISSION_ES_CDS_MAX_FULL_NAME_LEN] = {""}; /* Initialize output to safe value, in case this fails */ - *CDSHandlePtr = CFE_ES_RESOURCEID_UNDEFINED; + *CDSHandlePtr = CFE_ES_CDS_BAD_HANDLE; /* Check to make sure calling application is legit */ Status = CFE_ES_GetAppID(&ThisAppId); @@ -1780,7 +1792,7 @@ int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, size_t BlockSize, con * Purpose: Obtain CDS Block ID from name * See full API description in header file */ -CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_ResourceID_t *BlockIdPtr, const char *BlockName) +CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_CDSHandle_t *BlockIdPtr, const char *BlockName) { CFE_Status_t Status; CFE_ES_CDS_RegRec_t *RegRecPtr; @@ -1805,7 +1817,7 @@ CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_ResourceID_t *BlockIdPtr, const c } else { - *BlockIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *BlockIdPtr = CFE_ES_CDS_BAD_HANDLE; Status = CFE_ES_ERR_NAME_NOT_FOUND; } @@ -1820,7 +1832,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, size_t BufferLength) +CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_CDSHandle_t BlockId, size_t BufferLength) { CFE_Status_t Status; CFE_ES_CDS_RegRec_t *RegRecPtr; @@ -1882,10 +1894,10 @@ int32 CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle) ** ** Purpose: Allocates a generic counter resource and assigns ID */ -int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName) +int32 CFE_ES_RegisterGenCounter(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName) { CFE_ES_GenCounterRecord_t *CountRecPtr; - CFE_ES_ResourceID_t PendingCounterId; + CFE_ResourceId_t PendingResourceId; int32 Status; if (CounterName == NULL || CounterIdPtr == NULL) @@ -1909,13 +1921,13 @@ int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *C { CFE_ES_SysLogWrite_Unsync("ES Startup: Duplicate Counter name '%s'\n", CounterName); Status = CFE_ES_ERR_DUPLICATE_NAME; - PendingCounterId = CFE_ES_RESOURCEID_UNDEFINED; + PendingResourceId = CFE_RESOURCEID_UNDEFINED; } else { /* scan for a free slot */ - PendingCounterId = CFE_ES_FindNextAvailableId(CFE_ES_Global.LastCounterId, CFE_PLATFORM_ES_MAX_GEN_COUNTERS, CFE_ES_CheckCounterIdSlotUsed); - CountRecPtr = CFE_ES_LocateCounterRecordByID(PendingCounterId); + PendingResourceId = CFE_ResourceId_FindNext(CFE_ES_Global.LastCounterId, CFE_PLATFORM_ES_MAX_GEN_COUNTERS, CFE_ES_CheckCounterIdSlotUsed); + CountRecPtr = CFE_ES_LocateCounterRecordByID(CFE_ES_COUNTERID_C(PendingResourceId)); if (CountRecPtr == NULL) { @@ -1928,15 +1940,15 @@ int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *C sizeof(CountRecPtr->CounterName) - 1); CountRecPtr->CounterName[sizeof(CountRecPtr->CounterName) - 1] = '\0'; CountRecPtr->Counter = 0; - CFE_ES_CounterRecordSetUsed(CountRecPtr, PendingCounterId); - CFE_ES_Global.LastCounterId = PendingCounterId; + CFE_ES_CounterRecordSetUsed(CountRecPtr, PendingResourceId); + CFE_ES_Global.LastCounterId = PendingResourceId; Status = CFE_SUCCESS; } } CFE_ES_UnlockSharedData(__func__,__LINE__); - *CounterIdPtr = PendingCounterId; + *CounterIdPtr = CFE_ES_COUNTERID_C(PendingResourceId); return Status; } @@ -1947,7 +1959,7 @@ int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *C ** Purpose: Delete a Generic Counter. ** */ -int32 CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId) +int32 CFE_ES_DeleteGenCounter(CFE_ES_CounterId_t CounterId) { CFE_ES_GenCounterRecord_t *CountRecPtr; int32 Status = CFE_ES_BAD_ARGUMENT; @@ -1975,7 +1987,7 @@ int32 CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId) ** Purpose: Increment a Generic Counter. ** */ -int32 CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId) +int32 CFE_ES_IncrementGenCounter(CFE_ES_CounterId_t CounterId) { int32 Status = CFE_ES_BAD_ARGUMENT; CFE_ES_GenCounterRecord_t *CountRecPtr; @@ -1996,7 +2008,7 @@ int32 CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId) ** Purpose: Sets a Generic Counter's count. ** */ -int32 CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count) +int32 CFE_ES_SetGenCount(CFE_ES_CounterId_t CounterId, uint32 Count) { int32 Status = CFE_ES_BAD_ARGUMENT; CFE_ES_GenCounterRecord_t *CountRecPtr; @@ -2016,7 +2028,7 @@ int32 CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count) ** Purpose: Gets the value of a Generic Counter. ** */ -int32 CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count) +int32 CFE_ES_GetGenCount(CFE_ES_CounterId_t CounterId, uint32 *Count) { int32 Status = CFE_ES_BAD_ARGUMENT; CFE_ES_GenCounterRecord_t *CountRecPtr; @@ -2031,7 +2043,7 @@ int32 CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count) return Status; } /* End of CFE_ES_GetGenCount() */ -int32 CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName) +int32 CFE_ES_GetGenCounterIDByName(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName) { CFE_ES_GenCounterRecord_t *CounterRecPtr; int32 Result; @@ -2054,7 +2066,7 @@ int32 CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char * in case the does not check the return code. */ Result = CFE_ES_ERR_NAME_NOT_FOUND; - *CounterIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *CounterIdPtr = CFE_ES_COUNTERID_UNDEFINED; } else { @@ -2074,7 +2086,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, size_t BufferLength) +CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_CounterId_t CounterId, size_t BufferLength) { CFE_ES_GenCounterRecord_t *CountRecPtr; CFE_Status_t Status; @@ -2109,10 +2121,10 @@ CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_ResourceID_t Cou * A conversion function to obtain an index value correlating to an AppID * This is a zero based value that can be used for indexing into a table. */ -int32 CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx) +int32 CFE_ES_AppID_ToIndex(CFE_ES_AppId_t AppID, uint32 *Idx) { - return CFE_ES_ResourceID_ToIndex( - CFE_ES_ResourceID_ToInteger(AppID) - CFE_ES_APPID_BASE, + return CFE_ResourceId_ToIndex(CFE_RESOURCEID_UNWRAP(AppID), + CFE_ES_APPID_BASE, CFE_PLATFORM_ES_MAX_APPLICATIONS, Idx); } @@ -2121,10 +2133,10 @@ int32 CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx) * A conversion function to obtain an index value correlating to a LibID * This is a zero based value that can be used for indexing into a table. */ -int32 CFE_ES_LibID_ToIndex(CFE_ES_ResourceID_t LibId, uint32 *Idx) +int32 CFE_ES_LibID_ToIndex(CFE_ES_LibId_t LibId, uint32 *Idx) { - return CFE_ES_ResourceID_ToIndex( - CFE_ES_ResourceID_ToInteger(LibId) - CFE_ES_LIBID_BASE, + return CFE_ResourceId_ToIndex(CFE_RESOURCEID_UNWRAP(LibId), + CFE_ES_LIBID_BASE, CFE_PLATFORM_ES_MAX_LIBRARIES, Idx); } @@ -2136,17 +2148,17 @@ int32 CFE_ES_LibID_ToIndex(CFE_ES_ResourceID_t LibId, uint32 *Idx) * Task IDs come from OSAL, so this is currently a wrapper around the OSAL converter. * This is an alias for consistency with the ES AppID paradigm. */ -int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx) +int32 CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx) { osal_id_t OsalID; osal_index_t OsalIndex; - if (!CFE_ES_ResourceID_IsDefined(TaskID)) + if (!CFE_RESOURCEID_TEST_DEFINED(TaskID)) { return CFE_ES_ERR_RESOURCEID_NOT_VALID; } - OsalID = CFE_ES_ResourceID_ToOSAL(TaskID); + OsalID = CFE_ES_TaskId_ToOSAL(TaskID); if (OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, OsalID, &OsalIndex) != OS_SUCCESS) { return CFE_ES_ERR_RESOURCEID_NOT_VALID; @@ -2161,11 +2173,11 @@ int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx) * A conversion function to obtain an index value correlating to a CounterID * This is a zero based value that can be used for indexing into a table. */ -int32 CFE_ES_CounterID_ToIndex(CFE_ES_ResourceID_t CounterId, uint32 *Idx) +int32 CFE_ES_CounterID_ToIndex(CFE_ES_CounterId_t CounterId, uint32 *Idx) { - return CFE_ES_ResourceID_ToIndex( - CFE_ES_ResourceID_ToInteger(CounterId) - CFE_ES_COUNTID_BASE, - CFE_PLATFORM_ES_MAX_GEN_COUNTERS, + return CFE_ResourceId_ToIndex(CFE_RESOURCEID_UNWRAP(CounterId), + CFE_ES_COUNTID_BASE, + CFE_PLATFORM_ES_MAX_GEN_COUNTERS, Idx); } diff --git a/fsw/cfe-core/src/es/cfe_es_apps.c b/fsw/cfe-core/src/es/cfe_es_apps.c index 0e63864e1..8e825dfb3 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.c +++ b/fsw/cfe-core/src/es/cfe_es_apps.c @@ -270,7 +270,11 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) unsigned long PriorityIn; unsigned long StackSizeIn; unsigned long ExceptionActionIn; - CFE_ES_ResourceID_t ApplicationId; + union + { + CFE_ES_AppId_t AppId; + CFE_ES_LibId_t LibId; + } IdBuf; int32 CreateStatus = CFE_ES_ERR_APP_CREATE; /* @@ -333,7 +337,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) /* ** Now create the application */ - CreateStatus = CFE_ES_AppCreate(&ApplicationId, FileName, + CreateStatus = CFE_ES_AppCreate(&IdBuf.AppId, FileName, EntryPoint, AppName, PriorityIn, StackSizeIn, @@ -346,7 +350,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) /* ** Now load the library */ - CreateStatus = CFE_ES_LoadLibrary(&ApplicationId, FileName, + CreateStatus = CFE_ES_LoadLibrary(&IdBuf.LibId, FileName, EntryPoint, AppName); } @@ -369,7 +373,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) ** **------------------------------------------------------------------------------------- */ -int32 CFE_ES_LoadModule(CFE_ES_ResourceID_t ResourceId, const CFE_ES_ModuleLoadParams_t* LoadParams, CFE_ES_ModuleLoadStatus_t *LoadStatus) +int32 CFE_ES_LoadModule(CFE_ResourceId_t ResourceId, const CFE_ES_ModuleLoadParams_t* LoadParams, CFE_ES_ModuleLoadStatus_t *LoadStatus) { osal_id_t ModuleId; cpuaddr StartAddr; @@ -383,7 +387,7 @@ int32 CFE_ES_LoadModule(CFE_ES_ResourceID_t ResourceId, const CFE_ES_ModuleLoadP if (LoadParams->FileName[0] != 0) { - switch(CFE_ES_ResourceID_GetBase(ResourceId)) + switch(CFE_ResourceId_GetBase(ResourceId)) { case CFE_ES_APPID_BASE: /* @@ -552,11 +556,11 @@ void CFE_ES_AppEntryPoint(void) ** **------------------------------------------------------------------------------------- */ -int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_ResourceID_t RefAppId, CFE_ES_ResourceID_t *TaskIdPtr) +int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_AppId_t RefAppId, CFE_ES_TaskId_t *TaskIdPtr) { CFE_ES_TaskRecord_t *TaskRecPtr; osal_id_t OsalTaskId; - CFE_ES_ResourceID_t TaskId; + CFE_ES_TaskId_t LocalTaskId; int32 StatusCode; int32 ReturnCode; @@ -580,8 +584,8 @@ int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_Res * The entry is not (yet) matching the task ID - it will be * initialized here. */ - TaskId = CFE_ES_ResourceID_FromOSAL(OsalTaskId); - TaskRecPtr = CFE_ES_LocateTaskRecordByID(TaskId); + LocalTaskId = CFE_ES_TaskId_FromOSAL(OsalTaskId); + TaskRecPtr = CFE_ES_LocateTaskRecordByID(LocalTaskId); if ( CFE_ES_TaskRecordIsUsed(TaskRecPtr) ) { CFE_ES_SysLogWrite_Unsync("ES Startup: Error: ES_TaskTable slot for ID %lx in use at task creation!\n", @@ -597,21 +601,21 @@ int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_Res TaskRecPtr->AppId = RefAppId; strncpy(TaskRecPtr->TaskName, StartParams->BasicInfo.Name, sizeof(TaskRecPtr->TaskName)-1); TaskRecPtr->TaskName[sizeof(TaskRecPtr->TaskName)-1] = 0; - CFE_ES_TaskRecordSetUsed(TaskRecPtr, TaskId); + CFE_ES_TaskRecordSetUsed(TaskRecPtr, CFE_RESOURCEID_UNWRAP(LocalTaskId)); /* ** Increment the registered Task count. */ CFE_ES_Global.RegisteredTasks++; ReturnCode = CFE_SUCCESS; - *TaskIdPtr = TaskId; + *TaskIdPtr = CFE_ES_TaskRecordGetID(TaskRecPtr); } else { CFE_ES_SysLogWrite_Unsync("ES Startup: AppCreate Error: TaskCreate %s Failed. EC = 0x%08X!\n", StartParams->BasicInfo.Name,(unsigned int)StatusCode); ReturnCode = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; - *TaskIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *TaskIdPtr = CFE_ES_TASKID_UNDEFINED; } CFE_ES_UnlockSharedData(__func__,__LINE__); @@ -630,7 +634,7 @@ int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_Res ** **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, +int32 CFE_ES_AppCreate(CFE_ES_AppId_t *ApplicationIdPtr, const char *FileName, const char *EntryPointName, const char *AppName, @@ -638,10 +642,10 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, size_t StackSize, CFE_ES_ExceptionAction_Enum_t ExceptionAction) { - CFE_Status_t Status; - CFE_ES_ResourceID_t MainTaskId; + CFE_Status_t Status; + CFE_ES_TaskId_t MainTaskId; CFE_ES_AppRecord_t *AppRecPtr; - CFE_ES_ResourceID_t PendingAppId; + CFE_ResourceId_t PendingResourceId; /* * The FileName must not be NULL @@ -688,8 +692,8 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, else { /* scan for a free slot */ - PendingAppId = CFE_ES_FindNextAvailableId(CFE_ES_Global.LastAppId, CFE_PLATFORM_ES_MAX_APPLICATIONS, CFE_ES_CheckAppIdSlotUsed); - AppRecPtr = CFE_ES_LocateAppRecordByID(PendingAppId); + PendingResourceId = CFE_ResourceId_FindNext(CFE_ES_Global.LastAppId, CFE_PLATFORM_ES_MAX_APPLICATIONS, CFE_ES_CheckAppIdSlotUsed); + AppRecPtr = CFE_ES_LocateAppRecordByID(CFE_ES_APPID_C(PendingResourceId)); if (AppRecPtr == NULL) { @@ -729,8 +733,8 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, AppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_RUN; AppRecPtr->ControlReq.AppTimerMsec = 0; - CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_ES_RESOURCEID_RESERVED); - CFE_ES_Global.LastAppId = PendingAppId; + CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_RESOURCEID_RESERVED); + CFE_ES_Global.LastAppId = PendingResourceId; Status = CFE_SUCCESS; } } @@ -749,18 +753,18 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, /* * Load the module based on StartParams configured above. */ - Status = CFE_ES_LoadModule(PendingAppId, &AppRecPtr->StartParams.BasicInfo, &AppRecPtr->ModuleInfo); + Status = CFE_ES_LoadModule(PendingResourceId, &AppRecPtr->StartParams.BasicInfo, &AppRecPtr->ModuleInfo); /* * If the Load was OK, then complete the initialization */ if (Status == CFE_SUCCESS) { - Status = CFE_ES_StartAppTask(&AppRecPtr->StartParams, PendingAppId, &MainTaskId); + Status = CFE_ES_StartAppTask(&AppRecPtr->StartParams, CFE_ES_APPID_C(PendingResourceId), &MainTaskId); } else { - MainTaskId = CFE_ES_RESOURCEID_UNDEFINED; + MainTaskId = CFE_ES_TASKID_UNDEFINED; } /* @@ -776,7 +780,7 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, * which turns this into a real/valid table entry */ AppRecPtr->MainTaskId = MainTaskId; - CFE_ES_AppRecordSetUsed(AppRecPtr, PendingAppId); + CFE_ES_AppRecordSetUsed(AppRecPtr, PendingResourceId); /* ** Increment the registered App counter. @@ -789,12 +793,12 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, * Set the table entry back to free */ CFE_ES_AppRecordSetFree(AppRecPtr); - PendingAppId = CFE_ES_RESOURCEID_UNDEFINED; + PendingResourceId = CFE_RESOURCEID_UNDEFINED; } CFE_ES_UnlockSharedData(__func__,__LINE__); - *ApplicationIdPtr = PendingAppId; + *ApplicationIdPtr = CFE_ES_APPID_C(PendingResourceId); return Status; @@ -808,7 +812,7 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, ** **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, +int32 CFE_ES_LoadLibrary(CFE_ES_LibId_t *LibraryIdPtr, const char *FileName, const char *EntryPointName, const char *LibName) @@ -816,7 +820,7 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, CFE_ES_LibraryEntryFuncPtr_t FunctionPointer; CFE_ES_LibRecord_t * LibSlotPtr; int32 Status; - CFE_ES_ResourceID_t PendingLibId; + CFE_ResourceId_t PendingResourceId; /* * The FileName must not be NULL @@ -835,7 +839,7 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, ** Allocate an ES_LibTable entry */ FunctionPointer = NULL; - PendingLibId = CFE_ES_RESOURCEID_UNDEFINED; + PendingResourceId = CFE_RESOURCEID_UNDEFINED; /* ** Find an ES AppTable entry, and set to RESERVED @@ -862,15 +866,15 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, CFE_ES_SysLogWrite_Unsync("ES Startup: Duplicate Lib name '%s'\n", LibName); if (LibSlotPtr != NULL) { - PendingLibId = CFE_ES_LibRecordGetID(LibSlotPtr); + PendingResourceId = CFE_RESOURCEID_UNWRAP(CFE_ES_LibRecordGetID(LibSlotPtr)); } Status = CFE_ES_ERR_DUPLICATE_NAME; } else { /* scan for a free slot */ - PendingLibId = CFE_ES_FindNextAvailableId(CFE_ES_Global.LastLibId, CFE_PLATFORM_ES_MAX_LIBRARIES, CFE_ES_CheckLibIdSlotUsed); - LibSlotPtr = CFE_ES_LocateLibRecordByID(PendingLibId); + PendingResourceId = CFE_ResourceId_FindNext(CFE_ES_Global.LastLibId, CFE_PLATFORM_ES_MAX_LIBRARIES, CFE_ES_CheckLibIdSlotUsed); + LibSlotPtr = CFE_ES_LocateLibRecordByID(CFE_ES_LIBID_C(PendingResourceId)); if (LibSlotPtr == NULL) { @@ -898,8 +902,8 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, LibSlotPtr->BasicInfo.EntryPoint[sizeof(LibSlotPtr->BasicInfo.EntryPoint)-1] = '\0'; } - CFE_ES_LibRecordSetUsed(LibSlotPtr, CFE_ES_RESOURCEID_RESERVED); - CFE_ES_Global.LastLibId = PendingLibId; + CFE_ES_LibRecordSetUsed(LibSlotPtr, CFE_RESOURCEID_RESERVED); + CFE_ES_Global.LastLibId = PendingResourceId; Status = CFE_SUCCESS; } } @@ -912,20 +916,20 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, */ if (Status != CFE_SUCCESS) { - *LibraryIdPtr = PendingLibId; + *LibraryIdPtr = CFE_ES_LIBID_C(PendingResourceId); return Status; } /* * Load the module based on StartParams configured above. */ - Status = CFE_ES_LoadModule(PendingLibId, &LibSlotPtr->BasicInfo, &LibSlotPtr->ModuleInfo); + Status = CFE_ES_LoadModule(PendingResourceId, &LibSlotPtr->BasicInfo, &LibSlotPtr->ModuleInfo); if (Status == CFE_SUCCESS) { FunctionPointer = (CFE_ES_LibraryEntryFuncPtr_t)LibSlotPtr->ModuleInfo.EntryAddress; if (FunctionPointer != NULL) { - Status = (*FunctionPointer)(PendingLibId); + Status = (*FunctionPointer)(CFE_ES_LIBID_C(PendingResourceId)); if (Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("ES Startup: Load Shared Library Init Error = 0x%08x\n", @@ -947,7 +951,7 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, * important - set the ID to its proper value * which turns this into a real/valid table entry */ - CFE_ES_LibRecordSetUsed(LibSlotPtr, PendingLibId); + CFE_ES_LibRecordSetUsed(LibSlotPtr, PendingResourceId); /* * Increment the registered Lib counter. @@ -957,12 +961,12 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, else { CFE_ES_LibRecordSetFree(LibSlotPtr); - PendingLibId = CFE_ES_RESOURCEID_UNDEFINED; + PendingResourceId = CFE_RESOURCEID_UNDEFINED; } CFE_ES_UnlockSharedData(__func__,__LINE__); - *LibraryIdPtr = PendingLibId; + *LibraryIdPtr = CFE_ES_LIBID_C(PendingResourceId); return(Status); @@ -982,7 +986,7 @@ bool CFE_ES_RunAppTableScan(uint32 ElapsedTime, void *Arg) CFE_ES_AppTableScanState_t *State = (CFE_ES_AppTableScanState_t *)Arg; uint32 i; CFE_ES_AppRecord_t *AppPtr; - CFE_ES_ResourceID_t AppTimeoutList[CFE_PLATFORM_ES_MAX_APPLICATIONS]; + CFE_ES_AppId_t AppTimeoutList[CFE_PLATFORM_ES_MAX_APPLICATIONS]; uint32 NumAppTimeouts; if (State->PendingAppStateChanges == 0) @@ -1104,14 +1108,14 @@ bool CFE_ES_RunAppTableScan(uint32 ElapsedTime, void *Arg) ** Purpose: This function will perform the requested control action for an application. **--------------------------------------------------------------------------------------- */ -void CFE_ES_ProcessControlRequest(CFE_ES_ResourceID_t AppId) +void CFE_ES_ProcessControlRequest(CFE_ES_AppId_t AppId) { CFE_ES_AppRecord_t *AppRecPtr; uint32 PendingControlReq; CFE_ES_AppStartParams_t OrigStartParams; CFE_Status_t CleanupStatus; CFE_Status_t StartupStatus; - CFE_ES_ResourceID_t NewAppId; + CFE_ES_AppId_t NewAppId; const char *ReqName; char MessageDetail[48]; uint16 EventID; @@ -1124,7 +1128,7 @@ void CFE_ES_ProcessControlRequest(CFE_ES_ResourceID_t AppId) EventType = 0; StartupStatus = CFE_SUCCESS; PendingControlReq = 0; - NewAppId = CFE_ES_RESOURCEID_UNDEFINED; + NewAppId = CFE_ES_APPID_UNDEFINED; AppRecPtr = CFE_ES_LocateAppRecordByID(AppId); memset(&OrigStartParams, 0, sizeof(OrigStartParams)); @@ -1309,12 +1313,12 @@ void CFE_ES_ProcessControlRequest(CFE_ES_ResourceID_t AppId) snprintf(MessageDetail, sizeof(MessageDetail), "Failed: CleanUpApp Error 0x%08X.",(unsigned int)CleanupStatus); } - else if (CFE_ES_ResourceID_IsDefined(NewAppId)) + else if (CFE_RESOURCEID_TEST_DEFINED(NewAppId)) { /* Record success message for event where app is restarted */ EventType = CFE_EVS_EventType_INFORMATION; snprintf(MessageDetail, sizeof(MessageDetail), "Completed, AppID=%lu", - CFE_ES_ResourceID_ToInteger(NewAppId)); + CFE_RESOURCEID_TO_ULONG(NewAppId)); } else { @@ -1336,12 +1340,12 @@ void CFE_ES_ProcessControlRequest(CFE_ES_ResourceID_t AppId) ** Purpose: Delete an application by cleaning up all of it's resources. **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_ES_CleanUpApp(CFE_ES_AppId_t AppId) { uint32 i; int32 Status; int32 ReturnCode; - CFE_ES_ResourceID_t TaskList[OS_MAX_TASKS]; + CFE_ES_TaskId_t TaskList[OS_MAX_TASKS]; CFE_ES_MemHandle_t PoolList[CFE_PLATFORM_ES_MAX_MEMORY_POOLS]; osal_id_t ModuleId; uint32 NumTasks; @@ -1385,12 +1389,12 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) for ( i = 0; i < OS_MAX_TASKS; i++ ) { if ( CFE_ES_TaskRecordIsUsed(TaskRecPtr) && - CFE_ES_ResourceID_Equal(TaskRecPtr->AppId, AppId)) + CFE_RESOURCEID_TEST_EQUAL(TaskRecPtr->AppId, AppId)) { TaskList[NumTasks] = CFE_ES_TaskRecordGetID(TaskRecPtr); /* Store the main task ID at index 0 (swap with whatever was there) */ - if (CFE_ES_ResourceID_Equal(TaskList[NumTasks], AppRecPtr->MainTaskId) && + if (CFE_RESOURCEID_TEST_EQUAL(TaskList[NumTasks], AppRecPtr->MainTaskId) && NumTasks != 0) { TaskList[NumTasks] = TaskList[0]; @@ -1398,7 +1402,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) } /* Mark record for removal */ - CFE_ES_TaskRecordSetUsed(TaskRecPtr, CFE_ES_RESOURCEID_RESERVED); + CFE_ES_TaskRecordSetUsed(TaskRecPtr, CFE_RESOURCEID_RESERVED); ++NumTasks; } @@ -1414,7 +1418,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) for ( i = 0; i < CFE_PLATFORM_ES_MAX_MEMORY_POOLS; i++ ) { if ( CFE_ES_MemPoolRecordIsUsed(MemPoolRecPtr) && - CFE_ES_ResourceID_Equal(MemPoolRecPtr->OwnerAppID, AppId)) + CFE_RESOURCEID_TEST_EQUAL(MemPoolRecPtr->OwnerAppID, AppId)) { PoolList[NumPools] = CFE_ES_MemPoolRecordGetID(MemPoolRecPtr); ++NumPools; @@ -1429,14 +1433,14 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) * This prevents reallocation of this slot while the remainder * of resources are freed. */ - CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_ES_RESOURCEID_RESERVED); + CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_RESOURCEID_RESERVED); ReturnCode = CFE_SUCCESS; } else { CFE_ES_SysLogWrite_Unsync("CFE_ES_CleanUpApp: AppID %lu is not valid for deletion\n", - CFE_ES_ResourceID_ToInteger(AppId)); + CFE_RESOURCEID_TO_ULONG(AppId)); ReturnCode = CFE_ES_APP_CLEANUP_ERR; } @@ -1497,7 +1501,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) if ( Status != CFE_SUCCESS ) { CFE_ES_WriteToSysLog("CFE_ES_CleanUpApp: CleanUpTaskResources for Task ID:%lu returned Error: 0x%08X\n", - CFE_ES_ResourceID_ToInteger(TaskList[i]), (unsigned int)Status); + CFE_RESOURCEID_TO_ULONG(TaskList[i]), (unsigned int)Status); ReturnCode = CFE_ES_APP_CLEANUP_ERR; } } @@ -1511,7 +1515,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) if ( Status != CFE_SUCCESS ) { CFE_ES_WriteToSysLog("CFE_ES_MemPoolCleanupApp: delete pool %lu returned Error: 0x%08X\n", - CFE_ES_ResourceID_ToInteger(PoolList[i]), (unsigned int)Status); + CFE_RESOURCEID_TO_ULONG(PoolList[i]), (unsigned int)Status); ReturnCode = CFE_ES_APP_CLEANUP_ERR; } } @@ -1539,29 +1543,13 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) */ CFE_ES_LockSharedData(__func__,__LINE__); -#ifdef jphfix - /* - * This just confirms that the main task ID associated with this app was properly - * located and deleted during the previous process. - * - * If not, display a log message about it - this indicates table corruption or a - * bug with the record keeping. - */ - if (NumTasks == 0 || !CFE_ES_ResourceID_Equal(TaskList[0], AppRecPtr->MainTaskId)) - { - CFE_ES_SysLogWrite_Unsync("CFE_ES_CleanUpApp: MainTask ID:%lu not found when deleting AppID %lu\n", - CFE_ES_ResourceID_ToInteger(AppRecPtr->MainTaskId), CFE_ES_ResourceID_ToInteger(AppId)); - ReturnCode = CFE_ES_APP_CLEANUP_ERR; - } -#endif - /* * Free all task records. */ for (i=0; i < NumTasks; ++i) { TaskRecPtr = CFE_ES_LocateTaskRecordByID(TaskList[i]); - if (CFE_ES_TaskRecordIsMatch(TaskRecPtr, CFE_ES_RESOURCEID_RESERVED)) + if (CFE_ES_TaskRecordIsMatch(TaskRecPtr, CFE_ES_TASKID_C(CFE_RESOURCEID_RESERVED))) { CFE_ES_TaskRecordSetFree(TaskRecPtr); } @@ -1570,7 +1558,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) /* * Now finally delete the record and allow re-use of the slot. */ - if (CFE_ES_AppRecordIsMatch(AppRecPtr, CFE_ES_RESOURCEID_RESERVED)) + if (CFE_ES_AppRecordIsMatch(AppRecPtr, CFE_ES_APPID_C(CFE_RESOURCEID_RESERVED))) { CFE_ES_AppRecordSetFree(AppRecPtr); } @@ -1705,14 +1693,14 @@ void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg) ** any ES global data structures. It should only clean up at the OSAL level. **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_CleanupTaskResources(CFE_ES_ResourceID_t TaskId) +int32 CFE_ES_CleanupTaskResources(CFE_ES_TaskId_t TaskId) { CFE_ES_CleanupState_t CleanState; int32 Result; osal_id_t OsalId; /* Get the Task ID for calling OSAL APIs (convert type) */ - OsalId = CFE_ES_ResourceID_ToOSAL(TaskId); + OsalId = CFE_ES_TaskId_ToOSAL(TaskId); /* ** Delete all OSAL resources that belong to this task diff --git a/fsw/cfe-core/src/es/cfe_es_apps.h b/fsw/cfe-core/src/es/cfe_es_apps.h index 82b307e02..abe038378 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.h +++ b/fsw/cfe-core/src/es/cfe_es_apps.h @@ -129,13 +129,13 @@ typedef struct */ typedef struct { - CFE_ES_ResourceID_t AppId; /* The actual AppID of this entry, or undefined */ + CFE_ES_AppId_t AppId; /* The actual AppID of this entry, or undefined */ CFE_ES_AppState_Enum_t AppState; /* Is the app running, or stopped, or waiting? */ CFE_ES_AppType_Enum_t Type; /* The type of App: CORE or EXTERNAL */ CFE_ES_AppStartParams_t StartParams; /* The start parameters for an App */ CFE_ES_ModuleLoadStatus_t ModuleInfo; /* Runtime module information */ CFE_ES_ControlReq_t ControlReq; /* The Control Request Record for External cFE Apps */ - CFE_ES_ResourceID_t MainTaskId; /* The Application's Main Task ID */ + CFE_ES_TaskId_t MainTaskId; /* The Application's Main Task ID */ } CFE_ES_AppRecord_t; @@ -146,8 +146,8 @@ typedef struct */ typedef struct { - CFE_ES_ResourceID_t TaskId; /* The actual TaskID of this entry, or undefined */ - CFE_ES_ResourceID_t AppId; /* The parent Application's App ID */ + CFE_ES_TaskId_t TaskId; /* The actual TaskID of this entry, or undefined */ + CFE_ES_AppId_t AppId; /* The parent Application's App ID */ uint32 ExecutionCounter; /* The execution counter for the Child task */ char TaskName[OS_MAX_API_NAME]; /* Task Name */ @@ -160,7 +160,7 @@ typedef struct */ typedef struct { - CFE_ES_ResourceID_t LibId; /* The actual LibID of this entry, or undefined */ + CFE_ES_LibId_t LibId; /* The actual LibID of this entry, or undefined */ CFE_ES_ModuleLoadParams_t BasicInfo; /* Basic (static) information about the module */ CFE_ES_ModuleLoadStatus_t ModuleInfo; /* Runtime information about the module */ } CFE_ES_LibRecord_t; @@ -198,7 +198,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens); ** This only loads the code and looks up relevent runtime information. ** It does not start any tasks. */ -int32 CFE_ES_LoadModule(CFE_ES_ResourceID_t ResourceId, const CFE_ES_ModuleLoadParams_t* LoadParams, CFE_ES_ModuleLoadStatus_t *LoadStatus); +int32 CFE_ES_LoadModule(CFE_ResourceId_t ResourceId, const CFE_ES_ModuleLoadParams_t* LoadParams, CFE_ES_ModuleLoadStatus_t *LoadStatus); /* ** Internal function to determine the entry point of an app. @@ -217,13 +217,13 @@ void CFE_ES_AppEntryPoint(void); /* ** Internal function to start the main task of an app. */ -int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_ResourceID_t RefAppId, CFE_ES_ResourceID_t *TaskIdPtr); +int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_AppId_t RefAppId, CFE_ES_TaskId_t *TaskIdPtr); /* ** Internal function to create/start a new cFE app ** based on the parameters passed in */ -int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, +int32 CFE_ES_AppCreate(CFE_ES_AppId_t *ApplicationIdPtr, const char *FileName, const char *EntryPointName, const char *AppName, @@ -233,22 +233,11 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, /* ** Internal function to load a a new cFE shared Library */ -int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, +int32 CFE_ES_LoadLibrary(CFE_ES_LibId_t *LibraryIdPtr, const char *FileName, const char *EntryPointName, const char *LibName); -/* -** Get Application List -*/ -int32 CFE_ES_AppGetList(uint32 AppIdArray[], uint32 ArraySize); - -/* -** Dump All application properties to a file -** Note: Do we want to specify a file here? -*/ -int32 CFE_ES_AppDumpAllInfo(void); - /* ** Scan the Application Table for actions to take */ @@ -267,17 +256,17 @@ bool CFE_ES_RunERLogDump(uint32 ElapsedTime, void *Arg); /* ** Perform the requested control action for an application */ -void CFE_ES_ProcessControlRequest(CFE_ES_ResourceID_t AppId); +void CFE_ES_ProcessControlRequest(CFE_ES_AppId_t AppId); /* ** Clean up all app resources and delete it */ -int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId); +int32 CFE_ES_CleanUpApp(CFE_ES_AppId_t AppId); /* ** Clean up all Task resources and detete the task */ -int32 CFE_ES_CleanupTaskResources(CFE_ES_ResourceID_t TaskId); +int32 CFE_ES_CleanupTaskResources(CFE_ES_TaskId_t TaskId); /* diff --git a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c b/fsw/cfe-core/src/es/cfe_es_backgroundtask.c index db2254b4c..e72be0a28 100644 --- a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c +++ b/fsw/cfe-core/src/es/cfe_es_backgroundtask.c @@ -232,7 +232,7 @@ void CFE_ES_BackgroundCleanup(void) CFE_ES_DeleteChildTask(CFE_ES_Global.BackgroundTask.TaskID); OS_BinSemDelete(CFE_ES_Global.BackgroundTask.WorkSem); - CFE_ES_Global.BackgroundTask.TaskID = CFE_ES_RESOURCEID_UNDEFINED; + CFE_ES_Global.BackgroundTask.TaskID = CFE_ES_TASKID_UNDEFINED; CFE_ES_Global.BackgroundTask.WorkSem = OS_OBJECT_ID_UNDEFINED; } diff --git a/fsw/cfe-core/src/es/cfe_es_cds.c b/fsw/cfe-core/src/es/cfe_es_cds.c index 2c6ff0248..4efd36cd8 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds.c +++ b/fsw/cfe-core/src/es/cfe_es_cds.c @@ -76,7 +76,7 @@ int32 CFE_ES_CDS_EarlyInit(void) return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } - CDS->LastCDSBlockId = CFE_ES_ResourceID_FromInteger(CFE_ES_CDSBLOCKID_BASE); + CDS->LastCDSBlockId = CFE_ResourceId_FromInteger(CFE_ES_CDSBLOCKID_BASE); /* Get CDS size from PSP. Note that the PSP interface * uses "uint32" for size here. */ @@ -161,24 +161,24 @@ int32 CFE_ES_CDS_EarlyInit(void) * NOTE: For complete prolog information, see 'cfe_es_cds.h' */ /*******************************************************************/ -int32 CFE_ES_CDSBlockID_ToIndex(CFE_ES_ResourceID_t BlockID, uint32 *Idx) +int32 CFE_ES_CDSHandle_ToIndex(CFE_ES_CDSHandle_t BlockID, uint32 *Idx) { - return CFE_ES_ResourceID_ToIndex( - CFE_ES_ResourceID_ToInteger(BlockID) - CFE_ES_CDSBLOCKID_BASE, + return CFE_ResourceId_ToIndex(CFE_RESOURCEID_UNWRAP(BlockID), + CFE_ES_CDSBLOCKID_BASE, CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES, Idx); } /*--------------------------------------------------------------------------------------- - * Function: CFE_ES_CheckCDSBlockIdSlotUsed + * Function: CFE_ES_CheckCDSHandleSlotUsed * * Purpose: Helper function, Aids in allocating a new ID by checking if * a given ID is available. Must be called while locked. *--------------------------------------------------------------------------------------- */ -bool CFE_ES_CheckCDSBlockIdSlotUsed(CFE_ES_ResourceID_t CheckId) +bool CFE_ES_CheckCDSHandleSlotUsed(CFE_ResourceId_t CheckId) { - return CFE_ES_CDSBlockRecordIsUsed(CFE_ES_LocateCDSBlockRecordByID(CheckId)); + return CFE_ES_CDSBlockRecordIsUsed(CFE_ES_LocateCDSBlockRecordByID(CFE_ES_CDSHANDLE_C(CheckId))); } /*******************************************************************/ @@ -188,13 +188,13 @@ bool CFE_ES_CheckCDSBlockIdSlotUsed(CFE_ES_ResourceID_t CheckId) * NOTE: For complete prolog information, see 'cfe_es_cds.h' */ /*******************************************************************/ -CFE_ES_CDS_RegRec_t* CFE_ES_LocateCDSBlockRecordByID(CFE_ES_ResourceID_t BlockID) +CFE_ES_CDS_RegRec_t* CFE_ES_LocateCDSBlockRecordByID(CFE_ES_CDSHandle_t BlockID) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; CFE_ES_CDS_RegRec_t *CDSRegRecPtr; uint32 Idx; - if (CFE_ES_CDSBlockID_ToIndex(BlockID, &Idx) == CFE_SUCCESS) + if (CFE_ES_CDSHandle_ToIndex(BlockID, &Idx) == CFE_SUCCESS) { CDSRegRecPtr = &CDS->Registry[Idx]; } @@ -327,7 +327,7 @@ int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, size_t BlockOffset; size_t OldBlockSize; size_t NewBlockSize; - CFE_ES_ResourceID_t PendingBlockId; + CFE_ResourceId_t PendingBlockId; bool IsNewEntry; bool IsNewOffset; @@ -354,13 +354,13 @@ int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, { /* in CDS a duplicate name is not necessarily an error, we * may reuse/resize the existing entry */ - PendingBlockId = CFE_ES_CDSBlockRecordGetID(RegRecPtr); + PendingBlockId = CFE_RESOURCEID_UNWRAP(CFE_ES_CDSBlockRecordGetID(RegRecPtr)); } else { /* scan for a free slot */ - PendingBlockId = CFE_ES_FindNextAvailableId(CDS->LastCDSBlockId, CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES, CFE_ES_CheckCDSBlockIdSlotUsed); - RegRecPtr = CFE_ES_LocateCDSBlockRecordByID(PendingBlockId); + PendingBlockId = CFE_ResourceId_FindNext(CDS->LastCDSBlockId, CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES, CFE_ES_CheckCDSHandleSlotUsed); + RegRecPtr = CFE_ES_LocateCDSBlockRecordByID(CFE_ES_CDSHANDLE_C(PendingBlockId)); if (RegRecPtr != NULL) { @@ -373,7 +373,7 @@ int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, else { Status = CFE_ES_NO_RESOURCE_IDS_AVAILABLE; - PendingBlockId = CFE_ES_RESOURCEID_UNDEFINED; + PendingBlockId = CFE_RESOURCEID_UNDEFINED; } } @@ -466,7 +466,7 @@ int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, Status = CFE_ES_CDS_ALREADY_EXISTS; } - *HandlePtr = PendingBlockId; + *HandlePtr = CFE_ES_CDSHANDLE_C(PendingBlockId); return (Status); @@ -677,7 +677,7 @@ int32 CFE_ES_UpdateCDSRegistry(void) ** NOTE: For complete prolog information, see 'cfe_es_cds.h' ********************************************************************/ -void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_ResourceID_t ThisAppId) +void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_AppId_t ThisAppId) { char AppName[OS_MAX_API_NAME]; @@ -854,7 +854,7 @@ int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices) int32 Status; CFE_ES_CDS_RegRec_t *RegRecPtr; char OwnerName[OS_MAX_API_NAME]; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; uint32 i; char LogMessage[CFE_ES_MAX_SYSLOG_MSG_SIZE]; size_t OldBlockSize; diff --git a/fsw/cfe-core/src/es/cfe_es_cds.h b/fsw/cfe-core/src/es/cfe_es_cds.h index e0564a4be..d4168f448 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds.h +++ b/fsw/cfe-core/src/es/cfe_es_cds.h @@ -115,7 +115,7 @@ typedef struct * which has a CRC, and therefore the actual user data size is * less than this. */ - CFE_ES_ResourceID_t BlockID; /**< Abstract ID associated with this CDS block */ + CFE_ES_CDSHandle_t BlockID; /**< Abstract ID associated with this CDS 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]; @@ -173,7 +173,7 @@ typedef struct osal_id_t GenMutex; /**< \brief Mutex that controls access to CDS and registry */ 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_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; @@ -280,7 +280,7 @@ int32 CFE_ES_CDS_CachePreload(CFE_ES_CDS_AccessCache_t *Cache, const void *Sourc * @returns #CFE_SUCCESS if conversion successful. @copydoc CFE_SUCCESS * #CFE_ES_ERR_RESOURCEID_NOT_VALID if block ID is outside valid range */ -int32 CFE_ES_CDSBlockID_ToIndex(CFE_ES_ResourceID_t BlockID, uint32 *Idx); +int32 CFE_ES_CDSHandle_ToIndex(CFE_ES_CDSHandle_t BlockID, uint32 *Idx); /** * @brief Get a registry record within the CDS, given a block ID/handle @@ -295,7 +295,7 @@ int32 CFE_ES_CDSBlockID_ToIndex(CFE_ES_ResourceID_t BlockID, uint32 *Idx); * @param[in] BlockID the ID/handle of the CDS block to retrieve * @returns Pointer to registry record, or NULL if ID/handle invalid. */ -CFE_ES_CDS_RegRec_t* CFE_ES_LocateCDSBlockRecordByID(CFE_ES_ResourceID_t BlockID); +CFE_ES_CDS_RegRec_t* CFE_ES_LocateCDSBlockRecordByID(CFE_ES_CDSHandle_t BlockID); /** * @brief Check if a Memory Pool record is in use or free/empty @@ -310,7 +310,7 @@ CFE_ES_CDS_RegRec_t* CFE_ES_LocateCDSBlockRecordByID(CFE_ES_ResourceID_t BlockID */ static inline bool CFE_ES_CDSBlockRecordIsUsed(const CFE_ES_CDS_RegRec_t *CDSBlockRecPtr) { - return CFE_ES_ResourceID_IsDefined(CDSBlockRecPtr->BlockID); + return CFE_RESOURCEID_TEST_DEFINED(CDSBlockRecPtr->BlockID); } /** @@ -321,7 +321,7 @@ static inline bool CFE_ES_CDSBlockRecordIsUsed(const CFE_ES_CDS_RegRec_t *CDSBlo * @param[in] CDSBlockRecPtr pointer to Pool table entry * @returns BlockID of entry */ -static inline CFE_ES_ResourceID_t CFE_ES_CDSBlockRecordGetID(const CFE_ES_CDS_RegRec_t *CDSBlockRecPtr) +static inline CFE_ES_CDSHandle_t CFE_ES_CDSBlockRecordGetID(const CFE_ES_CDS_RegRec_t *CDSBlockRecPtr) { return (CDSBlockRecPtr->BlockID); } @@ -333,11 +333,11 @@ static inline CFE_ES_ResourceID_t CFE_ES_CDSBlockRecordGetID(const CFE_ES_CDS_Re * it as being associated with the given Pool ID. * * @param[in] CDSBlockRecPtr pointer to Pool table entry - * @param[in] BlockID the Pool ID of this entry + * @param[in] PendingId the Pool ID of this entry */ -static inline void CFE_ES_CDSBlockRecordSetUsed(CFE_ES_CDS_RegRec_t *CDSBlockRecPtr, CFE_ES_ResourceID_t BlockID) +static inline void CFE_ES_CDSBlockRecordSetUsed(CFE_ES_CDS_RegRec_t *CDSBlockRecPtr, CFE_ResourceId_t PendingId) { - CDSBlockRecPtr->BlockID = BlockID; + CDSBlockRecPtr->BlockID = CFE_ES_CDSHANDLE_C(PendingId); } /** @@ -350,7 +350,7 @@ static inline void CFE_ES_CDSBlockRecordSetUsed(CFE_ES_CDS_RegRec_t *CDSBlockRec */ static inline void CFE_ES_CDSBlockRecordSetFree(CFE_ES_CDS_RegRec_t *CDSBlockRecPtr) { - CDSBlockRecPtr->BlockID = CFE_ES_RESOURCEID_UNDEFINED; + CDSBlockRecPtr->BlockID = CFE_ES_CDS_BAD_HANDLE; } /** @@ -366,9 +366,9 @@ static inline void CFE_ES_CDSBlockRecordSetFree(CFE_ES_CDS_RegRec_t *CDSBlockRec * @param[in] BlockID expected block ID * @returns true if the entry matches the given block ID */ -static inline bool CFE_ES_CDSBlockRecordIsMatch(const CFE_ES_CDS_RegRec_t *CDSBlockRecPtr, CFE_ES_ResourceID_t BlockID) +static inline bool CFE_ES_CDSBlockRecordIsMatch(const CFE_ES_CDS_RegRec_t *CDSBlockRecPtr, CFE_ES_CDSHandle_t BlockID) { - return (CDSBlockRecPtr != NULL && CFE_ES_ResourceID_Equal(CDSBlockRecPtr->BlockID, BlockID)); + return (CDSBlockRecPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(CDSBlockRecPtr->BlockID, BlockID)); } /** @@ -396,7 +396,7 @@ static inline size_t CFE_ES_CDSBlockRecordGetUserSize(const CFE_ES_CDS_RegRec_t * * Checks if a table slot is available for a potential new ID * This is a helper function intended to be used with - * CFE_ES_FindNextAvailableID() for allocating new IDs + * CFE_ResourceId_FindNext() for allocating new IDs * * As this dereferences fields within the record, global data must be * locked prior to invoking this function. @@ -404,7 +404,7 @@ static inline size_t CFE_ES_CDSBlockRecordGetUserSize(const CFE_ES_CDS_RegRec_t * @param[in] CheckId pending/candidate Block ID to check * @returns true if the table slot for the ID is occupied, false if available */ -bool CFE_ES_CheckCDSBlockIdSlotUsed(CFE_ES_ResourceID_t CheckId); +bool CFE_ES_CheckCDSHandleSlotUsed(CFE_ResourceId_t CheckId); /*****************************************************************************/ /** @@ -509,7 +509,7 @@ int32 CFE_ES_UpdateCDSRegistry(void); ** \par Assumptions, External Events, and Notes: ** Note: AppName portion will be truncated to OS_MAX_API_NAME. ** -** \param[in, out] FullCDSName pointer to character buffer of #CFE_ES_CDS_MAX_FULL_NAME_LEN size +** \param[in, out] FullCDSName pointer to character buffer of #CFE_MISSION_ES_CDS_MAX_FULL_NAME_LEN size ** that will be filled with the processor specific CDS Name. *FullCDSName is the processor specific CDS Name of the form "AppName.CDSName". ** ** \param[in] CDSName pointer to character string containing the Application's local name for @@ -519,7 +519,7 @@ int32 CFE_ES_UpdateCDSRegistry(void); ** ** ******************************************************************************/ -void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_ResourceID_t ThisAppId); +void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_AppId_t ThisAppId); /*****************************************************************************/ /** diff --git a/fsw/cfe-core/src/es/cfe_es_erlog.c b/fsw/cfe-core/src/es/cfe_es_erlog.c index 4a49a8b38..f132d918b 100644 --- a/fsw/cfe-core/src/es/cfe_es_erlog.c +++ b/fsw/cfe-core/src/es/cfe_es_erlog.c @@ -63,7 +63,7 @@ */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int32 CFE_ES_WriteToERLogWithContext( CFE_ES_LogEntryType_Enum_t EntryType, uint32 ResetType, uint32 ResetSubtype, - const char *Description, CFE_ES_ResourceID_t AppId, uint32 PspContextId) + const char *Description, CFE_ES_AppId_t AppId, uint32 PspContextId) { uint32 LogIdx; CFE_ES_ERLog_MetaData_t *EntryPtr; @@ -176,7 +176,7 @@ int32 CFE_ES_WriteToERLog( CFE_ES_LogEntryType_Enum_t EntryType, uint32 Reset { /* passing 0xFFFFFFFF as the appid avoids confusion with actual appid 0 */ return CFE_ES_WriteToERLogWithContext(EntryType, ResetType, ResetSubtype, - Description, CFE_ES_RESOURCEID_UNDEFINED, CFE_ES_ERLOG_NO_CONTEXT); + Description, CFE_ES_APPID_UNDEFINED, CFE_ES_ERLOG_NO_CONTEXT); } /* End of CFE_ES_WriteToERLog() */ @@ -359,7 +359,7 @@ bool CFE_ES_RunExceptionScan(uint32 ElapsedTime, void *Arg) */ if (OS_ObjectIdDefined(ExceptionTaskID)) { - Status = CFE_ES_GetTaskInfo( &EsTaskInfo, CFE_ES_ResourceID_FromOSAL(ExceptionTaskID) ); + Status = CFE_ES_GetTaskInfo( &EsTaskInfo, CFE_ES_TaskId_FromOSAL(ExceptionTaskID) ); /* * The App ID was found, now see if the ExceptionAction is set for a reset diff --git a/fsw/cfe-core/src/es/cfe_es_global.h b/fsw/cfe-core/src/es/cfe_es_global.h index 2e12654f7..0965ef9ea 100644 --- a/fsw/cfe-core/src/es/cfe_es_global.h +++ b/fsw/cfe-core/src/es/cfe_es_global.h @@ -65,7 +65,7 @@ */ typedef struct { - CFE_ES_ResourceID_t CounterId; /**< The actual counter ID of this entry, or undefined */ + CFE_ES_CounterId_t CounterId; /**< The actual counter ID of this entry, or undefined */ uint32 Counter; char CounterName[OS_MAX_API_NAME]; /* Counter Name */ } CFE_ES_GenCounterRecord_t; @@ -75,7 +75,7 @@ typedef struct */ typedef struct { - CFE_ES_ResourceID_t TaskID; /**< ES ID of the background task */ + CFE_ES_TaskId_t TaskID; /**< ES ID of the background task */ osal_id_t WorkSem; /**< Semaphore that is given whenever background work is pending */ uint32 NumJobsRunning; /**< Current Number of active jobs (updated by background task) */ } CFE_ES_BackgroundTaskState_t; @@ -119,20 +119,20 @@ typedef struct */ uint32 RegisteredCoreApps; uint32 RegisteredExternalApps; - CFE_ES_ResourceID_t LastAppId; + CFE_ResourceId_t LastAppId; CFE_ES_AppRecord_t AppTable[CFE_PLATFORM_ES_MAX_APPLICATIONS]; /* ** ES Shared Library Table */ uint32 RegisteredLibs; - CFE_ES_ResourceID_t LastLibId; + CFE_ResourceId_t LastLibId; CFE_ES_LibRecord_t LibTable[CFE_PLATFORM_ES_MAX_LIBRARIES]; /* ** ES Generic Counters Table */ - CFE_ES_ResourceID_t LastCounterId; + CFE_ResourceId_t LastCounterId; CFE_ES_GenCounterRecord_t CounterTable[CFE_PLATFORM_ES_MAX_GEN_COUNTERS]; /* @@ -150,7 +150,7 @@ typedef struct /* ** Memory Pools */ - CFE_ES_ResourceID_t LastMemPoolId; + CFE_ResourceId_t LastMemPoolId; CFE_ES_MemPoolRecord_t MemPoolTable[CFE_PLATFORM_ES_MAX_MEMORY_POOLS]; } CFE_ES_Global_t; diff --git a/fsw/cfe-core/src/es/cfe_es_log.h b/fsw/cfe-core/src/es/cfe_es_log.h index ebf02d67c..e52ae1c0a 100644 --- a/fsw/cfe-core/src/es/cfe_es_log.h +++ b/fsw/cfe-core/src/es/cfe_es_log.h @@ -366,6 +366,6 @@ int32 CFE_ES_WriteToERLog( CFE_ES_LogEntryType_Enum_t EntryType, uint32 Reset * \param PspContextId Identifier of extended context info stored in the PSP (if available) */ int32 CFE_ES_WriteToERLogWithContext( CFE_ES_LogEntryType_Enum_t EntryType, uint32 ResetType, uint32 ResetSubtype, - const char *Description, CFE_ES_ResourceID_t AppId, uint32 PspContextId); + const char *Description, CFE_ES_AppId_t AppId, uint32 PspContextId); #endif /* _cfe_es_log_ */ diff --git a/fsw/cfe-core/src/es/cfe_es_mempool.c b/fsw/cfe-core/src/es/cfe_es_mempool.c index 6e994aabc..5832b128d 100644 --- a/fsw/cfe-core/src/es/cfe_es_mempool.c +++ b/fsw/cfe-core/src/es/cfe_es_mempool.c @@ -108,8 +108,8 @@ int32 CFE_ES_MemPoolDirectCommit(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t Offs int32 CFE_ES_MemPoolID_ToIndex(CFE_ES_MemHandle_t PoolID, uint32 *Idx) { - return CFE_ES_ResourceID_ToIndex( - CFE_ES_ResourceID_ToInteger(PoolID) - CFE_ES_POOLID_BASE, + return CFE_ResourceId_ToIndex(CFE_RESOURCEID_UNWRAP(PoolID), + CFE_ES_POOLID_BASE, CFE_PLATFORM_ES_MAX_MEMORY_POOLS, Idx); } @@ -121,9 +121,9 @@ int32 CFE_ES_MemPoolID_ToIndex(CFE_ES_MemHandle_t PoolID, uint32 *Idx) * a given table slot is available. Must be called while locked. *--------------------------------------------------------------------------------------- */ -bool CFE_ES_CheckMemPoolSlotUsed(CFE_ES_ResourceID_t CheckId) +bool CFE_ES_CheckMemPoolSlotUsed(CFE_ResourceId_t CheckId) { - return CFE_ES_MemPoolRecordIsUsed(CFE_ES_LocateMemPoolRecordByID(CheckId)); + return CFE_ES_MemPoolRecordIsUsed(CFE_ES_LocateMemPoolRecordByID(CFE_ES_MEMHANDLE_C(CheckId))); } CFE_ES_MemPoolRecord_t* CFE_ES_LocateMemPoolRecordByID(CFE_ES_MemHandle_t PoolID) @@ -174,7 +174,7 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, bool UseMutex ) { int32 Status; - CFE_ES_MemHandle_t PendingID; + CFE_ResourceId_t PendingID; CFE_ES_MemPoolRecord_t *PoolRecPtr; size_t Alignment; size_t MinimumSize; @@ -223,8 +223,8 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, CFE_ES_LockSharedData(__func__,__LINE__); /* scan for a free slot */ - PendingID = CFE_ES_FindNextAvailableId(CFE_ES_Global.LastMemPoolId, CFE_PLATFORM_ES_MAX_MEMORY_POOLS, CFE_ES_CheckMemPoolSlotUsed); - PoolRecPtr = CFE_ES_LocateMemPoolRecordByID(PendingID); + PendingID = CFE_ResourceId_FindNext(CFE_ES_Global.LastMemPoolId, CFE_PLATFORM_ES_MAX_MEMORY_POOLS, CFE_ES_CheckMemPoolSlotUsed); + PoolRecPtr = CFE_ES_LocateMemPoolRecordByID(CFE_ES_MEMHANDLE_C(PendingID)); if (PoolRecPtr == NULL) { @@ -235,7 +235,7 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, { /* Fully clear the entry, just in case of stale data */ memset(PoolRecPtr, 0, sizeof(*PoolRecPtr)); - CFE_ES_MemPoolRecordSetUsed(PoolRecPtr, CFE_ES_RESOURCEID_RESERVED); + CFE_ES_MemPoolRecordSetUsed(PoolRecPtr, CFE_RESOURCEID_RESERVED); CFE_ES_Global.LastMemPoolId = PendingID; Status = CFE_SUCCESS; } @@ -289,7 +289,7 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, ** This is needed only because OS_MutSemCreate requires ** a unique name for each semaphore created. */ - snprintf(MutexName, OS_MAX_API_NAME, "Pool%08lX", CFE_ES_ResourceID_ToInteger(PendingID)); + snprintf(MutexName, OS_MAX_API_NAME, "Pool%08lX", CFE_ResourceId_ToInteger(PendingID)); /* create a mutex to protect this memory pool */ Status = OS_MutSemCreate(&PoolRecPtr->MutexId, MutexName, 0); @@ -322,7 +322,7 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, /* * Store the actual/correct pool ID in the record. */ - CFE_ES_MemPoolRecordSetUsed(PoolRecPtr,PendingID); + CFE_ES_MemPoolRecordSetUsed(PoolRecPtr, PendingID); } else { @@ -330,7 +330,7 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, * Free the entry that was reserved earlier */ CFE_ES_MemPoolRecordSetFree(PoolRecPtr); - PendingID = CFE_ES_RESOURCEID_UNDEFINED; + PendingID = CFE_RESOURCEID_UNDEFINED; if (Status == CFE_ES_POOL_BOUNDS_ERROR) { @@ -342,7 +342,7 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, /* * Export pool ID to caller as handle */ - *PoolID = PendingID; + *PoolID = CFE_ES_MEMHANDLE_C(PendingID); return(Status); } @@ -407,7 +407,7 @@ int32 CFE_ES_GetPoolBuf(CFE_ES_MemPoolBuf_t *BufPtr, size_t Size ) { int32 Status; - CFE_ES_MemHandle_t AppId; + CFE_ES_AppId_t AppId; CFE_ES_MemPoolRecord_t *PoolRecPtr; size_t DataOffset; @@ -418,8 +418,8 @@ int32 CFE_ES_GetPoolBuf(CFE_ES_MemPoolBuf_t *BufPtr, { CFE_ES_GetAppID(&AppId); CFE_ES_WriteToSysLog("CFE_ES:getPoolBuf err:Bad handle(0x%08lX) AppId=%lu\n", - CFE_ES_ResourceID_ToInteger(Handle), - CFE_ES_ResourceID_ToInteger(AppId)); + CFE_RESOURCEID_TO_ULONG(Handle), + CFE_RESOURCEID_TO_ULONG(AppId)); return(CFE_ES_ERR_RESOURCEID_NOT_VALID); } @@ -533,7 +533,7 @@ int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t Handle, if (!CFE_ES_MemPoolRecordIsMatch(PoolRecPtr, Handle)) { CFE_ES_WriteToSysLog("CFE_ES:putPoolBuf err:Invalid Memory Handle (0x%08lX).\n", - CFE_ES_ResourceID_ToInteger(Handle)); + CFE_RESOURCEID_TO_ULONG(Handle)); return(CFE_ES_ERR_RESOURCEID_NOT_VALID); } @@ -600,7 +600,7 @@ int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t Handle, int32 CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t Handle) { - CFE_ES_MemHandle_t AppId; + CFE_ES_AppId_t AppId; CFE_ES_MemPoolRecord_t *PoolRecPtr; uint16 NumBuckets; uint16 Idx; @@ -612,7 +612,7 @@ int32 CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, { CFE_ES_GetAppID(&AppId); CFE_ES_WriteToSysLog("CFE_ES:getMemPoolStats err:Bad handle(0x%08lX) AppId=%lu\n", - CFE_ES_ResourceID_ToInteger(Handle), CFE_ES_ResourceID_ToInteger(AppId)); + CFE_RESOURCEID_TO_ULONG(Handle), CFE_RESOURCEID_TO_ULONG(AppId)); return(CFE_ES_ERR_RESOURCEID_NOT_VALID); } diff --git a/fsw/cfe-core/src/es/cfe_es_mempool.h b/fsw/cfe-core/src/es/cfe_es_mempool.h index 247d65110..d94724faa 100644 --- a/fsw/cfe-core/src/es/cfe_es_mempool.h +++ b/fsw/cfe-core/src/es/cfe_es_mempool.h @@ -64,7 +64,7 @@ typedef struct * an ES app, but in that case the resource cannot be cleaned up if the * app exits unexpectedly. */ - CFE_ES_ResourceID_t OwnerAppID; + CFE_ES_AppId_t OwnerAppID; /** * Optional Mutex for serializing get/put operations @@ -121,7 +121,7 @@ CFE_ES_MemPoolRecord_t* CFE_ES_LocateMemPoolRecordByID(CFE_ES_MemHandle_t PoolID */ static inline bool CFE_ES_MemPoolRecordIsUsed(const CFE_ES_MemPoolRecord_t *PoolRecPtr) { - return CFE_ES_ResourceID_IsDefined(PoolRecPtr->PoolID); + return CFE_RESOURCEID_TEST_DEFINED(PoolRecPtr->PoolID); } /** @@ -144,11 +144,11 @@ static inline CFE_ES_MemHandle_t CFE_ES_MemPoolRecordGetID(const CFE_ES_MemPoolR * it as being associated with the given Pool ID. * * @param[in] PoolRecPtr pointer to Pool table entry - * @param[in] PoolID the Pool ID of this entry + * @param[in] PendingId the Pool ID of this entry */ -static inline void CFE_ES_MemPoolRecordSetUsed(CFE_ES_MemPoolRecord_t *PoolRecPtr, CFE_ES_MemHandle_t PoolID) +static inline void CFE_ES_MemPoolRecordSetUsed(CFE_ES_MemPoolRecord_t *PoolRecPtr, CFE_ResourceId_t PendingId) { - PoolRecPtr->PoolID = PoolID; + PoolRecPtr->PoolID = CFE_ES_MEMHANDLE_C(PendingId); } /** @@ -161,7 +161,7 @@ static inline void CFE_ES_MemPoolRecordSetUsed(CFE_ES_MemPoolRecord_t *PoolRecPt */ static inline void CFE_ES_MemPoolRecordSetFree(CFE_ES_MemPoolRecord_t *PoolRecPtr) { - PoolRecPtr->PoolID = CFE_ES_RESOURCEID_UNDEFINED; + PoolRecPtr->PoolID = CFE_ES_MEMHANDLE_UNDEFINED; } /** @@ -179,7 +179,7 @@ static inline void CFE_ES_MemPoolRecordSetFree(CFE_ES_MemPoolRecord_t *PoolRecPt */ static inline bool CFE_ES_MemPoolRecordIsMatch(const CFE_ES_MemPoolRecord_t *PoolRecPtr, CFE_ES_MemHandle_t PoolID) { - return (PoolRecPtr != NULL && CFE_ES_ResourceID_Equal(PoolRecPtr->PoolID, PoolID)); + return (PoolRecPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(PoolRecPtr->PoolID, PoolID)); } /** @@ -187,7 +187,7 @@ static inline bool CFE_ES_MemPoolRecordIsMatch(const CFE_ES_MemPoolRecord_t *Poo * * Checks if a table slot is available for a potential new ID * This is a helper function intended to be used with - * CFE_ES_FindNextAvailableID() for allocating new IDs + * CFE_ResourceId_FindNext() for allocating new IDs * * As this dereferences fields within the record, global data must be * locked prior to invoking this function. @@ -195,7 +195,7 @@ static inline bool CFE_ES_MemPoolRecordIsMatch(const CFE_ES_MemPoolRecord_t *Poo * @param[in] CheckId pending/candidate Pool ID to check * @returns true if the table slot for the ID is occupied, false if available */ -bool CFE_ES_CheckMemPoolSlotUsed(CFE_ES_ResourceID_t CheckId); +bool CFE_ES_CheckMemPoolSlotUsed(CFE_ResourceId_t CheckId); #endif /* _CFE_ES_MEMPOOL_H_ */ diff --git a/fsw/cfe-core/src/es/cfe_es_objtab.c b/fsw/cfe-core/src/es/cfe_es_objtab.c index 73f5cc531..88bca7540 100644 --- a/fsw/cfe-core/src/es/cfe_es_objtab.c +++ b/fsw/cfe-core/src/es/cfe_es_objtab.c @@ -98,18 +98,11 @@ CFE_ES_ObjectTable_t CFE_ES_ObjectTable[CFE_PLATFORM_ES_OBJECT_TABLE_SIZE] = }, { .ObjectType = CFE_ES_NULL_ENTRY }, -#ifndef EXCLUDE_CFE_TBL { .ObjectType = CFE_ES_FUNCTION_CALL, .ObjectName = "CFE_TBL_EarlyInit", .FuncPtrUnion.FunctionPtr = CFE_TBL_EarlyInit }, - -#else - { - .ObjectType = CFE_ES_NULL_ENTRY - }, -#endif { .ObjectType = CFE_ES_NULL_ENTRY }, @@ -173,7 +166,6 @@ CFE_ES_ObjectTable_t CFE_ES_ObjectTable[CFE_PLATFORM_ES_OBJECT_TABLE_SIZE] = { .ObjectType = CFE_ES_NULL_ENTRY }, -#ifndef EXCLUDE_CFE_TBL { .ObjectType = CFE_ES_CORE_TASK, .ObjectName = "CFE_TBL", @@ -181,11 +173,6 @@ CFE_ES_ObjectTable_t CFE_ES_ObjectTable[CFE_PLATFORM_ES_OBJECT_TABLE_SIZE] = .ObjectPriority = CFE_PLATFORM_TBL_START_TASK_PRIORITY, .ObjectSize = CFE_PLATFORM_TBL_START_TASK_STACK_SIZE }, -#else - { - .ObjectType = CFE_ES_NULL_ENTRY - }, -#endif /* ** Spare entries diff --git a/fsw/cfe-core/src/es/cfe_es_resource.c b/fsw/cfe-core/src/es/cfe_es_resource.c index 4035697dd..4af1cacea 100644 --- a/fsw/cfe-core/src/es/cfe_es_resource.c +++ b/fsw/cfe-core/src/es/cfe_es_resource.c @@ -43,92 +43,37 @@ /*********************************************************************/ /* - * CFE_ES_ResourceID_ToIndex - * + * Function: CFE_ES_TaskId_ToOSAL + * * For complete API information, see prototype in header */ -int32 CFE_ES_ResourceID_ToIndex(uint32 Serial, uint32 TableSize, uint32 *Idx) +osal_id_t CFE_ES_TaskId_ToOSAL(CFE_ES_TaskId_t id) { - if (Idx == NULL) - { - return CFE_ES_ERR_BUFFER; - } + osal_id_t Result; + unsigned long Val; - if (Serial > CFE_ES_RESOURCEID_MAX) - { - return CFE_ES_ERR_RESOURCEID_NOT_VALID; - } + Val = CFE_ResourceId_ToInteger(CFE_RESOURCEID_UNWRAP(id)); + Result = OS_ObjectIdFromInteger(Val ^ CFE_RESOURCEID_MARK); - *Idx = Serial % TableSize; - return CFE_SUCCESS; + return Result; } /*********************************************************************/ /* - * CFE_ES_ResourceID_ToOSAL - * - * For complete API information, see prototype in header - */ -osal_id_t CFE_ES_ResourceID_ToOSAL(CFE_ES_ResourceID_t id) -{ - unsigned long val = CFE_ES_ResourceID_ToInteger(id); - return OS_ObjectIdFromInteger(val); -} - -/*********************************************************************/ -/* - * CFE_ES_ResourceID_FromOSAL - * - * For complete API information, see prototype in header - */ -CFE_ES_ResourceID_t CFE_ES_ResourceID_FromOSAL(osal_id_t id) -{ - unsigned long val = OS_ObjectIdToInteger(id); - return CFE_ES_ResourceID_FromInteger(val); -} - -/*********************************************************************/ -/* - * CFE_ES_FindNextAvailableId - * + * Function: CFE_TaskId_FromOSAL + * * For complete API information, see prototype in header */ -CFE_ES_ResourceID_t CFE_ES_FindNextAvailableId(CFE_ES_ResourceID_t StartId, uint32 TableSize, bool (*CheckFunc)(CFE_ES_ResourceID_t)) +CFE_ES_TaskId_t CFE_ES_TaskId_FromOSAL(osal_id_t id) { - uint32 Serial; - uint32 Count; - uint32 ResourceType; - CFE_ES_ResourceID_t CheckId; - bool IsTaken; + CFE_ResourceId_t Result; + unsigned long Val; - ResourceType = CFE_ES_ResourceID_ToInteger(StartId); - Serial = ResourceType & CFE_ES_RESOURCEID_MAX; - ResourceType -= Serial; - Count = TableSize; - IsTaken = true; - - do - { - if (Count == 0) - { - CheckId = CFE_ES_RESOURCEID_UNDEFINED; - break; - } - - --Count; - ++Serial; - if (Serial >= CFE_ES_RESOURCEID_MAX) - { - Serial %= TableSize; - } - CheckId = CFE_ES_ResourceID_FromInteger(ResourceType + Serial); - - IsTaken = CheckFunc(CheckId); - } - while (IsTaken); + Val = OS_ObjectIdToInteger(id); + Result = CFE_ResourceId_FromInteger(Val ^ CFE_RESOURCEID_MARK); - return CheckId; + return CFE_ES_TASKID_C(Result); } /*********************************************************************/ @@ -249,7 +194,7 @@ CFE_ES_GenCounterRecord_t *CFE_ES_LocateCounterRecordByName(const char *Name) * * For complete API information, see prototype in header */ -CFE_ES_AppRecord_t *CFE_ES_LocateAppRecordByID(CFE_ES_ResourceID_t AppID) +CFE_ES_AppRecord_t *CFE_ES_LocateAppRecordByID(CFE_ES_AppId_t AppID) { CFE_ES_AppRecord_t *AppRecPtr; uint32 Idx; @@ -272,7 +217,7 @@ CFE_ES_AppRecord_t *CFE_ES_LocateAppRecordByID(CFE_ES_ResourceID_t AppID) * * For complete API information, see prototype in header */ -CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_ResourceID_t LibID) +CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_LibId_t LibID) { CFE_ES_LibRecord_t *LibRecPtr; uint32 Idx; @@ -295,7 +240,7 @@ CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_ResourceID_t LibID) * * For complete API information, see prototype in header */ -CFE_ES_TaskRecord_t *CFE_ES_LocateTaskRecordByID(CFE_ES_ResourceID_t TaskID) +CFE_ES_TaskRecord_t *CFE_ES_LocateTaskRecordByID(CFE_ES_TaskId_t TaskID) { CFE_ES_TaskRecord_t *TaskRecPtr; uint32 Idx; @@ -318,7 +263,7 @@ CFE_ES_TaskRecord_t *CFE_ES_LocateTaskRecordByID(CFE_ES_ResourceID_t TaskID) * * For complete API information, see prototype in header */ -CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_ResourceID_t CounterID) +CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_CounterId_t CounterID) { CFE_ES_GenCounterRecord_t *CounterRecPtr; uint32 Idx; @@ -347,12 +292,12 @@ CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_ResourceID_t Co CFE_ES_TaskRecord_t *CFE_ES_GetTaskRecordByContext(void) { CFE_ES_TaskRecord_t *TaskRecPtr; - CFE_ES_ResourceID_t TaskID; + CFE_ES_TaskId_t TaskID; /* ** Use the OS task ID to get the ES task record */ - TaskID = CFE_ES_ResourceID_FromOSAL(OS_TaskGetId()); + TaskID = CFE_ES_TaskId_FromOSAL(OS_TaskGetId()); TaskRecPtr = CFE_ES_LocateTaskRecordByID(TaskID); /* @@ -418,9 +363,9 @@ CFE_ES_AppRecord_t *CFE_ES_GetAppRecordByContext(void) * a given ID is available. Must be called while locked. * --------------------------------------------------------------------------------------- */ -bool CFE_ES_CheckCounterIdSlotUsed(CFE_ES_ResourceID_t CheckId) +bool CFE_ES_CheckCounterIdSlotUsed(CFE_ResourceId_t CheckId) { - return CFE_ES_CounterRecordIsUsed(CFE_ES_LocateCounterRecordByID(CheckId)); + return CFE_ES_CounterRecordIsUsed(CFE_ES_LocateCounterRecordByID(CFE_ES_COUNTERID_C(CheckId))); } /* @@ -431,9 +376,9 @@ bool CFE_ES_CheckCounterIdSlotUsed(CFE_ES_ResourceID_t CheckId) * a given ID is available. Must be called while locked. *--------------------------------------------------------------------------------------- */ -bool CFE_ES_CheckAppIdSlotUsed(CFE_ES_ResourceID_t CheckId) +bool CFE_ES_CheckAppIdSlotUsed(CFE_ResourceId_t CheckId) { - return CFE_ES_AppRecordIsUsed(CFE_ES_LocateAppRecordByID(CheckId)); + return CFE_ES_AppRecordIsUsed(CFE_ES_LocateAppRecordByID(CFE_ES_APPID_C(CheckId))); } /* @@ -444,9 +389,9 @@ bool CFE_ES_CheckAppIdSlotUsed(CFE_ES_ResourceID_t CheckId) * a given ID is available. Must be called while locked. * --------------------------------------------------------------------------------------- */ -bool CFE_ES_CheckLibIdSlotUsed(CFE_ES_ResourceID_t CheckId) +bool CFE_ES_CheckLibIdSlotUsed(CFE_ResourceId_t CheckId) { - return CFE_ES_LibRecordIsUsed(CFE_ES_LocateLibRecordByID(CheckId)); + return CFE_ES_LibRecordIsUsed(CFE_ES_LocateLibRecordByID(CFE_ES_LIBID_C(CheckId))); } diff --git a/fsw/cfe-core/src/es/cfe_es_resource.h b/fsw/cfe-core/src/es/cfe_es_resource.h index 91f2ddeca..9cbaa840d 100644 --- a/fsw/cfe-core/src/es/cfe_es_resource.h +++ b/fsw/cfe-core/src/es/cfe_es_resource.h @@ -34,8 +34,8 @@ /* ** Include Files */ -#include "cfe_resourceid.h" -#include "private/cfe_resourceid_internal.h" +#include "cfe_resourceid_api.h" +#include "private/cfe_core_resourceid_basevalues.h" #include "cfe_es_global.h" @@ -48,7 +48,7 @@ * @param[in] AppID the app ID to locate * @return pointer to App Table entry for the given app ID */ -extern CFE_ES_AppRecord_t* CFE_ES_LocateAppRecordByID(CFE_ES_ResourceID_t AppID); +extern CFE_ES_AppRecord_t* CFE_ES_LocateAppRecordByID(CFE_ES_AppId_t AppID); /** * @brief Locate the Library table entry correlating with a given Lib ID. @@ -59,7 +59,7 @@ extern CFE_ES_AppRecord_t* CFE_ES_LocateAppRecordByID(CFE_ES_ResourceID_t AppID) * @param[in] LibID the Lib ID to locate * @return pointer to Library Table entry for the given Lib ID */ -extern CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_ResourceID_t LibID); +extern CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_LibId_t LibID); /** * @brief Locate the task table entry correlating with a given task ID. @@ -70,7 +70,7 @@ extern CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_ResourceID_t LibID) * @param[in] TaskID the task ID to locate * @return pointer to Task Table entry for the given task ID */ -extern CFE_ES_TaskRecord_t* CFE_ES_LocateTaskRecordByID(CFE_ES_ResourceID_t TaskID); +extern CFE_ES_TaskRecord_t* CFE_ES_LocateTaskRecordByID(CFE_ES_TaskId_t TaskID); /** * @brief Locate the Counter table entry correlating with a given Counter ID. @@ -81,7 +81,7 @@ extern CFE_ES_TaskRecord_t* CFE_ES_LocateTaskRecordByID(CFE_ES_ResourceID_t Task * @param[in] CounterID the Counter ID to locate * @return pointer to Counter Table entry for the given Counter ID */ -extern CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_ResourceID_t CounterID); +extern CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_CounterId_t CounterID); /** * @brief Check if an app record is in use or free/empty @@ -96,7 +96,7 @@ extern CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_Resource */ static inline bool CFE_ES_AppRecordIsUsed(const CFE_ES_AppRecord_t *AppRecPtr) { - return CFE_ES_ResourceID_IsDefined(AppRecPtr->AppId); + return CFE_RESOURCEID_TEST_DEFINED(AppRecPtr->AppId); } /** @@ -107,7 +107,7 @@ static inline bool CFE_ES_AppRecordIsUsed(const CFE_ES_AppRecord_t *AppRecPtr) * @param[in] AppRecPtr pointer to app table entry * @returns AppID of entry */ -static inline CFE_ES_ResourceID_t CFE_ES_AppRecordGetID(const CFE_ES_AppRecord_t *AppRecPtr) +static inline CFE_ES_AppId_t CFE_ES_AppRecordGetID(const CFE_ES_AppRecord_t *AppRecPtr) { return AppRecPtr->AppId; } @@ -122,11 +122,11 @@ static inline CFE_ES_ResourceID_t CFE_ES_AppRecordGetID(const CFE_ES_AppRecord_t * locked prior to invoking this function. * * @param[in] AppRecPtr pointer to app table entry - * @param[in] AppID the app ID of this entry + * @param[in] PendingId the app ID of this entry */ -static inline void CFE_ES_AppRecordSetUsed(CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_ResourceID_t AppID) +static inline void CFE_ES_AppRecordSetUsed(CFE_ES_AppRecord_t *AppRecPtr, CFE_ResourceId_t PendingId) { - AppRecPtr->AppId = AppID; + AppRecPtr->AppId = CFE_ES_APPID_C(PendingId); } /** @@ -142,7 +142,7 @@ static inline void CFE_ES_AppRecordSetUsed(CFE_ES_AppRecord_t *AppRecPtr, CFE_ES */ static inline void CFE_ES_AppRecordSetFree(CFE_ES_AppRecord_t *AppRecPtr) { - AppRecPtr->AppId = CFE_ES_RESOURCEID_UNDEFINED; + AppRecPtr->AppId = CFE_ES_APPID_UNDEFINED; } /** @@ -158,9 +158,9 @@ static inline void CFE_ES_AppRecordSetFree(CFE_ES_AppRecord_t *AppRecPtr) * @param[in] AppID expected app ID * @returns true if the entry matches the given app ID */ -static inline bool CFE_ES_AppRecordIsMatch(const CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_ResourceID_t AppID) +static inline bool CFE_ES_AppRecordIsMatch(const CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_AppId_t AppID) { - return (AppRecPtr != NULL && CFE_ES_ResourceID_Equal(AppRecPtr->AppId, AppID)); + return (AppRecPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(AppRecPtr->AppId, AppID)); } /** @@ -191,7 +191,7 @@ static inline const char* CFE_ES_AppRecordGetName(const CFE_ES_AppRecord_t *AppR */ static inline bool CFE_ES_LibRecordIsUsed(const CFE_ES_LibRecord_t *LibRecPtr) { - return CFE_ES_ResourceID_IsDefined(LibRecPtr->LibId); + return CFE_RESOURCEID_TEST_DEFINED(LibRecPtr->LibId); } /** @@ -202,7 +202,7 @@ static inline bool CFE_ES_LibRecordIsUsed(const CFE_ES_LibRecord_t *LibRecPtr) * @param[in] LibRecPtr pointer to Lib table entry * @returns LibID of entry */ -static inline CFE_ES_ResourceID_t CFE_ES_LibRecordGetID(const CFE_ES_LibRecord_t *LibRecPtr) +static inline CFE_ES_LibId_t CFE_ES_LibRecordGetID(const CFE_ES_LibRecord_t *LibRecPtr) { /* * The initial implementation does not store the ID in the entry; @@ -218,11 +218,11 @@ static inline CFE_ES_ResourceID_t CFE_ES_LibRecordGetID(const CFE_ES_LibRecord_t * it as being associated with the given Lib ID. * * @param[in] LibRecPtr pointer to Lib table entry - * @param[in] LibID the Lib ID of this entry + * @param[in] PendingId the Lib ID of this entry */ -static inline void CFE_ES_LibRecordSetUsed(CFE_ES_LibRecord_t *LibRecPtr, CFE_ES_ResourceID_t LibID) +static inline void CFE_ES_LibRecordSetUsed(CFE_ES_LibRecord_t *LibRecPtr, CFE_ResourceId_t PendingId) { - LibRecPtr->LibId = LibID; + LibRecPtr->LibId = CFE_ES_LIBID_C(PendingId); } /** @@ -235,7 +235,7 @@ static inline void CFE_ES_LibRecordSetUsed(CFE_ES_LibRecord_t *LibRecPtr, CFE_ES */ static inline void CFE_ES_LibRecordSetFree(CFE_ES_LibRecord_t *LibRecPtr) { - LibRecPtr->LibId = CFE_ES_RESOURCEID_UNDEFINED; + LibRecPtr->LibId = CFE_ES_LIBID_UNDEFINED; } /** @@ -251,9 +251,9 @@ static inline void CFE_ES_LibRecordSetFree(CFE_ES_LibRecord_t *LibRecPtr) * @param[in] LibID expected Lib ID * @returns true if the entry matches the given Lib ID */ -static inline bool CFE_ES_LibRecordIsMatch(const CFE_ES_LibRecord_t *LibRecPtr, CFE_ES_ResourceID_t LibID) +static inline bool CFE_ES_LibRecordIsMatch(const CFE_ES_LibRecord_t *LibRecPtr, CFE_ES_LibId_t LibID) { - return (LibRecPtr != NULL && CFE_ES_ResourceID_Equal(LibRecPtr->LibId, LibID)); + return (LibRecPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(LibRecPtr->LibId, LibID)); } /** @@ -282,7 +282,7 @@ static inline const char* CFE_ES_LibRecordGetName(const CFE_ES_LibRecord_t *LibR * @param[in] TaskRecPtr pointer to Task table entry * @returns TaskID of entry */ -static inline CFE_ES_ResourceID_t CFE_ES_TaskRecordGetID(const CFE_ES_TaskRecord_t *TaskRecPtr) +static inline CFE_ES_TaskId_t CFE_ES_TaskRecordGetID(const CFE_ES_TaskRecord_t *TaskRecPtr) { return (TaskRecPtr->TaskId); } @@ -300,7 +300,7 @@ static inline CFE_ES_ResourceID_t CFE_ES_TaskRecordGetID(const CFE_ES_TaskRecord */ static inline bool CFE_ES_TaskRecordIsUsed(const CFE_ES_TaskRecord_t *TaskRecPtr) { - return CFE_ES_ResourceID_IsDefined(TaskRecPtr->TaskId); + return CFE_RESOURCEID_TEST_DEFINED(TaskRecPtr->TaskId); } /** @@ -313,11 +313,11 @@ static inline bool CFE_ES_TaskRecordIsUsed(const CFE_ES_TaskRecord_t *TaskRecPtr * locked prior to invoking this function. * * @param[in] TaskRecPtr pointer to Task table entry - * @param[in] TaskID the Task ID of this entry + * @param[in] PendingId the Task ID of this entry */ -static inline void CFE_ES_TaskRecordSetUsed(CFE_ES_TaskRecord_t *TaskRecPtr, CFE_ES_ResourceID_t TaskID) +static inline void CFE_ES_TaskRecordSetUsed(CFE_ES_TaskRecord_t *TaskRecPtr, CFE_ResourceId_t PendingId) { - TaskRecPtr->TaskId = TaskID; + TaskRecPtr->TaskId = CFE_ES_TASKID_C(PendingId); } /** @@ -333,7 +333,7 @@ static inline void CFE_ES_TaskRecordSetUsed(CFE_ES_TaskRecord_t *TaskRecPtr, CFE */ static inline void CFE_ES_TaskRecordSetFree(CFE_ES_TaskRecord_t *TaskRecPtr) { - TaskRecPtr->TaskId = CFE_ES_RESOURCEID_UNDEFINED; + TaskRecPtr->TaskId = CFE_ES_TASKID_UNDEFINED; } /** @@ -349,9 +349,9 @@ static inline void CFE_ES_TaskRecordSetFree(CFE_ES_TaskRecord_t *TaskRecPtr) * @param[in] TaskID The expected task ID to verify * @returns true if the entry matches the given task ID */ -static inline bool CFE_ES_TaskRecordIsMatch(const CFE_ES_TaskRecord_t *TaskRecPtr, CFE_ES_ResourceID_t TaskID) +static inline bool CFE_ES_TaskRecordIsMatch(const CFE_ES_TaskRecord_t *TaskRecPtr, CFE_ES_TaskId_t TaskID) { - return (TaskRecPtr != NULL && CFE_ES_ResourceID_Equal(TaskRecPtr->TaskId, TaskID)); + return (TaskRecPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(TaskRecPtr->TaskId, TaskID)); } /** @@ -382,7 +382,7 @@ static inline const char* CFE_ES_TaskRecordGetName(const CFE_ES_TaskRecord_t *Ta */ static inline bool CFE_ES_CounterRecordIsUsed(const CFE_ES_GenCounterRecord_t *CounterRecPtr) { - return CFE_ES_ResourceID_IsDefined(CounterRecPtr->CounterId); + return CFE_RESOURCEID_TEST_DEFINED(CounterRecPtr->CounterId); } /** @@ -393,7 +393,7 @@ static inline bool CFE_ES_CounterRecordIsUsed(const CFE_ES_GenCounterRecord_t *C * @param[in] CounterRecPtr pointer to Counter table entry * @returns CounterID of entry */ -static inline CFE_ES_ResourceID_t CFE_ES_CounterRecordGetID(const CFE_ES_GenCounterRecord_t *CounterRecPtr) +static inline CFE_ES_CounterId_t CFE_ES_CounterRecordGetID(const CFE_ES_GenCounterRecord_t *CounterRecPtr) { return CounterRecPtr->CounterId; } @@ -408,11 +408,11 @@ static inline CFE_ES_ResourceID_t CFE_ES_CounterRecordGetID(const CFE_ES_GenCoun * locked prior to invoking this function. * * @param[in] CounterRecPtr pointer to Counter table entry - * @param[in] CounterID the Counter ID of this entry + * @param[in] PendingId the Counter ID of this entry */ -static inline void CFE_ES_CounterRecordSetUsed(CFE_ES_GenCounterRecord_t *CounterRecPtr, CFE_ES_ResourceID_t CounterID) +static inline void CFE_ES_CounterRecordSetUsed(CFE_ES_GenCounterRecord_t *CounterRecPtr, CFE_ResourceId_t PendingId) { - CounterRecPtr->CounterId = CounterID; + CounterRecPtr->CounterId = CFE_ES_COUNTERID_C(PendingId); } /** @@ -428,7 +428,7 @@ static inline void CFE_ES_CounterRecordSetUsed(CFE_ES_GenCounterRecord_t *Counte */ static inline void CFE_ES_CounterRecordSetFree(CFE_ES_GenCounterRecord_t *CounterRecPtr) { - CounterRecPtr->CounterId = CFE_ES_RESOURCEID_UNDEFINED; + CounterRecPtr->CounterId = CFE_ES_COUNTERID_UNDEFINED; } /** @@ -444,9 +444,9 @@ static inline void CFE_ES_CounterRecordSetFree(CFE_ES_GenCounterRecord_t *Counte * @param[in] CounterID expected Counter ID * @returns true if the entry matches the given Counter ID */ -static inline bool CFE_ES_CounterRecordIsMatch(const CFE_ES_GenCounterRecord_t *CounterRecPtr, CFE_ES_ResourceID_t CounterID) +static inline bool CFE_ES_CounterRecordIsMatch(const CFE_ES_GenCounterRecord_t *CounterRecPtr, CFE_ES_CounterId_t CounterID) { - return (CounterRecPtr != NULL && CFE_ES_ResourceID_Equal(CounterRecPtr->CounterId, CounterID)); + return (CounterRecPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(CounterRecPtr->CounterId, CounterID)); } /** @@ -487,6 +487,59 @@ extern CFE_ES_AppRecord_t* CFE_ES_GetAppRecordByContext(void); */ extern CFE_ES_TaskRecord_t* CFE_ES_GetTaskRecordByContext(void); +/* + * OSAL <-> CFE task ID conversion + * + * CFE ES does not currently allocate its own task IDs; instead it piggybacks on top + * of the allocation that is already done by OSAL. This is partly for backward + * compatibility - historically the OSAL task IDs were used directly by CFE task APIs. + * + * This is _only_ used for tasks - for all other resource types ES should allocate + * its own identifiers independently of any other subsystem. This conversion may also + * be removed in a future version of CFE, if ES starts allocating task IDs independently + * of OSAL task IDs. + */ + +/** + * @brief Convert an ES Task ID to an OSAL task ID + * + * Task IDs created via CFE ES are also OSAL task IDs, but technically + * do refer to a different scope and therefore have a different type + * to represent them. + * + * This function facilitates converting between the types. + * + * @note With "simple" resource IDs, numeric values are the same and can be interchanged + * for backward compatibility, however they will be different when using "strict" IDs. + * New code should not assume equivalence between OSAL and ES task IDs. + * + * @sa CFE_ES_TaskId_FromOSAL + * + * @param[in] id The CFE task ID + * @returns The OSAL task ID + */ +extern osal_id_t CFE_ES_TaskId_ToOSAL(CFE_ES_TaskId_t id); + +/** + * @brief Convert an ES Task ID to an OSAL task ID + * + * Task IDs created via CFE ES are also OSAL task IDs, but technically + * do refer to a different scope and therefore have a different type + * to represent them. + * + * This function facilitates converting between the types. + * + * @note With "simple" resource IDs, numeric values are the same and can be interchanged + * for backward compatibility, however they will be different when using "strict" IDs. + * New code should not assume equivalence between OSAL and ES task IDs. + * + * @sa CFE_ES_TaskId_ToOSAL + * + * @param[in] id The OSAL task ID + * @returns The CFE task ID + */ +extern CFE_ES_TaskId_t CFE_ES_TaskId_FromOSAL(osal_id_t id); + /* * Internal functions to perform name based resource lookups * @@ -498,10 +551,10 @@ CFE_ES_LibRecord_t *CFE_ES_LocateLibRecordByName(const char *Name); CFE_ES_TaskRecord_t *CFE_ES_LocateTaskRecordByName(const char *Name); CFE_ES_GenCounterRecord_t *CFE_ES_LocateCounterRecordByName(const char *Name); -/* Availability check functions used in conjunction with CFE_ES_FindNextAvailableId() */ -bool CFE_ES_CheckAppIdSlotUsed(CFE_ES_ResourceID_t CheckId); -bool CFE_ES_CheckLibIdSlotUsed(CFE_ES_ResourceID_t CheckId); -bool CFE_ES_CheckCounterIdSlotUsed(CFE_ES_ResourceID_t CheckId); +/* Availability check functions used in conjunction with CFE_ResourceId_FindNext() */ +bool CFE_ES_CheckAppIdSlotUsed(CFE_ResourceId_t CheckId); +bool CFE_ES_CheckLibIdSlotUsed(CFE_ResourceId_t CheckId); +bool CFE_ES_CheckCounterIdSlotUsed(CFE_ResourceId_t CheckId); #endif /* CFE_ES_RESOURCE_H */ diff --git a/fsw/cfe-core/src/es/cfe_es_start.c b/fsw/cfe-core/src/es/cfe_es_start.c index 93d1627d3..5fcf246e7 100644 --- a/fsw/cfe-core/src/es/cfe_es_start.c +++ b/fsw/cfe-core/src/es/cfe_es_start.c @@ -182,10 +182,10 @@ void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const cha /* ** Initialize the Last Id */ - CFE_ES_Global.LastAppId = CFE_ES_ResourceID_FromInteger(CFE_ES_APPID_BASE); - CFE_ES_Global.LastLibId = CFE_ES_ResourceID_FromInteger(CFE_ES_LIBID_BASE); - CFE_ES_Global.LastCounterId = CFE_ES_ResourceID_FromInteger(CFE_ES_COUNTID_BASE); - CFE_ES_Global.LastMemPoolId = CFE_ES_ResourceID_FromInteger(CFE_ES_POOLID_BASE); + CFE_ES_Global.LastAppId = CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE); + CFE_ES_Global.LastLibId = CFE_ResourceId_FromInteger(CFE_ES_LIBID_BASE); + CFE_ES_Global.LastCounterId = CFE_ResourceId_FromInteger(CFE_ES_COUNTID_BASE); + CFE_ES_Global.LastMemPoolId = CFE_ResourceId_FromInteger(CFE_ES_POOLID_BASE); /* ** Indicate that the CFE core is now starting up / going multi-threaded @@ -742,8 +742,8 @@ void CFE_ES_CreateObjects(void) int32 ReturnCode; uint16 i; CFE_ES_AppRecord_t *AppRecPtr; - CFE_ES_ResourceID_t PendingAppId; - CFE_ES_ResourceID_t PendingTaskId; + CFE_ResourceId_t PendingAppId; + CFE_ES_TaskId_t PendingTaskId; CFE_ES_WriteToSysLog("ES Startup: Starting Object Creation calls.\n"); @@ -759,8 +759,8 @@ void CFE_ES_CreateObjects(void) */ CFE_ES_LockSharedData(__func__,__LINE__); - PendingAppId = CFE_ES_FindNextAvailableId(CFE_ES_Global.LastAppId, CFE_PLATFORM_ES_MAX_APPLICATIONS, CFE_ES_CheckAppIdSlotUsed); - AppRecPtr = CFE_ES_LocateAppRecordByID(PendingAppId); + PendingAppId = CFE_ResourceId_FindNext(CFE_ES_Global.LastAppId, CFE_PLATFORM_ES_MAX_APPLICATIONS, CFE_ES_CheckAppIdSlotUsed); + AppRecPtr = CFE_ES_LocateAppRecordByID(CFE_ES_APPID_C(PendingAppId)); if (AppRecPtr != NULL) { /* @@ -783,7 +783,7 @@ void CFE_ES_CreateObjects(void) AppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_RUN; AppRecPtr->ControlReq.AppTimerMsec = 0; - CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_ES_RESOURCEID_RESERVED); + CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_RESOURCEID_RESERVED); CFE_ES_Global.LastAppId = PendingAppId; } @@ -798,7 +798,7 @@ void CFE_ES_CreateObjects(void) ** Start the core app main task ** (core apps are already in memory - no loading needed) */ - ReturnCode = CFE_ES_StartAppTask(&AppRecPtr->StartParams, PendingAppId, &PendingTaskId); + ReturnCode = CFE_ES_StartAppTask(&AppRecPtr->StartParams, CFE_ES_APPID_C(PendingAppId), &PendingTaskId); /* * Finalize data in the app table entry, which must be done under lock. diff --git a/fsw/cfe-core/src/es/cfe_es_task.c b/fsw/cfe-core/src/es/cfe_es_task.c index 6fcf2b041..3f7696876 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.c +++ b/fsw/cfe-core/src/es/cfe_es_task.c @@ -272,8 +272,7 @@ int32 CFE_ES_TaskInit(void) /* ** Subscribe to Housekeeping request commands */ - Status = CFE_SB_SubscribeEx(CFE_SB_ValueToMsgId(CFE_ES_SEND_HK_MID), CFE_ES_TaskData.CmdPipe, - CFE_SB_Default_Qos, CFE_ES_LIMIT_HK); + Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_ES_SEND_HK_MID), CFE_ES_TaskData.CmdPipe); if ( Status != CFE_SUCCESS ) { CFE_ES_WriteToSysLog("ES:Cannot Subscribe to HK packet, RC = 0x%08X\n", (unsigned int)Status); @@ -283,8 +282,7 @@ int32 CFE_ES_TaskInit(void) /* ** Subscribe to ES task ground command packets */ - Status = CFE_SB_SubscribeEx(CFE_SB_ValueToMsgId(CFE_ES_CMD_MID), CFE_ES_TaskData.CmdPipe, - CFE_SB_Default_Qos, CFE_ES_LIMIT_CMD); + Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_ES_CMD_MID), CFE_ES_TaskData.CmdPipe); if ( Status != CFE_SUCCESS ) { CFE_ES_WriteToSysLog("ES:Cannot Subscribe to ES ground commands, RC = 0x%08X\n", (unsigned int)Status); @@ -846,7 +844,7 @@ int32 CFE_ES_RestartCmd(const CFE_ES_RestartCmd_t *data) int32 CFE_ES_StartAppCmd(const CFE_ES_StartAppCmd_t *data) { const CFE_ES_StartAppCmd_Payload_t *cmd = &data->Payload; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; int32 Result; int32 FilenameLen; int32 AppEntryLen; @@ -933,7 +931,7 @@ int32 CFE_ES_StartAppCmd(const CFE_ES_StartAppCmd_t *data) CFE_ES_TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_START_INF_EID, CFE_EVS_EventType_INFORMATION, "Started %s from %s, AppID = %lu", - LocalAppName, LocalFile, CFE_ES_ResourceID_ToInteger(AppID)); + LocalAppName, LocalFile, CFE_RESOURCEID_TO_ULONG(AppID)); } else { @@ -959,7 +957,7 @@ int32 CFE_ES_StopAppCmd(const CFE_ES_StopAppCmd_t *data) { const CFE_ES_AppNameCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; int32 Result; CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, @@ -1013,7 +1011,7 @@ int32 CFE_ES_RestartAppCmd(const CFE_ES_RestartAppCmd_t *data) { const CFE_ES_AppNameCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; int32 Result; CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, @@ -1064,7 +1062,7 @@ int32 CFE_ES_ReloadAppCmd(const CFE_ES_ReloadAppCmd_t *data) const CFE_ES_AppReloadCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; char LocalFileName[OS_MAX_PATH_LEN]; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; int32 Result; CFE_SB_MessageStringGet(LocalFileName, (char *)cmd->AppFileName, NULL, @@ -1117,22 +1115,27 @@ int32 CFE_ES_QueryOneCmd(const CFE_ES_QueryOneCmd_t *data) { const CFE_ES_AppNameCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; - CFE_ES_ResourceID_t ResourceID; + union + { + CFE_ES_AppId_t AppId; + CFE_ES_LibId_t LibId; + CFE_ResourceId_t ResourceID; + } IdBuf; int32 Result; CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, sizeof(LocalApp), sizeof(cmd->Application)); - Result = CFE_ES_GetAppIDByName(&ResourceID, LocalApp); + Result = CFE_ES_GetAppIDByName(&IdBuf.AppId, LocalApp); if (Result == CFE_ES_ERR_NAME_NOT_FOUND) { /* Also check for a matching library name */ - Result = CFE_ES_GetLibIDByName(&ResourceID, LocalApp); + Result = CFE_ES_GetLibIDByName(&IdBuf.LibId, LocalApp); } if (Result == CFE_SUCCESS) { - Result = CFE_ES_GetModuleInfo(&(CFE_ES_TaskData.OneAppPacket.Payload.AppInfo), ResourceID); + Result = CFE_ES_GetModuleInfo(&(CFE_ES_TaskData.OneAppPacket.Payload.AppInfo), IdBuf.ResourceID); } /* @@ -1187,7 +1190,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) CFE_ES_AppInfo_t AppInfo; const CFE_ES_FileNameCmd_Payload_t *CmdPtr = &data->Payload; char QueryAllFilename[OS_MAX_PATH_LEN]; - CFE_ES_ResourceID_t ResourceList[CFE_ES_QUERY_ALL_MAX_ENTRIES]; + CFE_ResourceId_t ResourceList[CFE_ES_QUERY_ALL_MAX_ENTRIES]; uint32 NumResources; CFE_ES_AppRecord_t *AppRecPtr; CFE_ES_LibRecord_t *LibRecPtr; @@ -1212,7 +1215,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) { if (CFE_ES_AppRecordIsUsed(AppRecPtr)) { - ResourceList[NumResources] = CFE_ES_AppRecordGetID(AppRecPtr); + ResourceList[NumResources] = CFE_RESOURCEID_UNWRAP(CFE_ES_AppRecordGetID(AppRecPtr)); ++NumResources; } ++AppRecPtr; @@ -1223,7 +1226,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) { if (CFE_ES_LibRecordIsUsed(LibRecPtr)) { - ResourceList[NumResources] = CFE_ES_LibRecordGetID(LibRecPtr); + ResourceList[NumResources] = CFE_RESOURCEID_UNWRAP(CFE_ES_LibRecordGetID(LibRecPtr)); ++NumResources; } ++LibRecPtr; @@ -1346,7 +1349,7 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) CFE_ES_TaskInfo_t TaskInfo; const CFE_ES_FileNameCmd_Payload_t *CmdPtr = &data->Payload; char QueryAllFilename[OS_MAX_PATH_LEN]; - CFE_ES_ResourceID_t TaskList[OS_MAX_TASKS]; + CFE_ES_TaskId_t TaskList[OS_MAX_TASKS]; uint32 NumTasks; CFE_ES_TaskRecord_t *TaskRecPtr; @@ -1817,14 +1820,14 @@ int32 CFE_ES_SendMemPoolStatsCmd(const CFE_ES_SendMemPoolStatsCmd_t *data) CFE_ES_TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_TLM_POOL_STATS_INFO_EID, CFE_EVS_EventType_DEBUG, "Successfully telemetered memory pool stats for 0x%08lX", - CFE_ES_ResourceID_ToInteger(Cmd->PoolHandle)); + CFE_RESOURCEID_TO_ULONG(Cmd->PoolHandle)); } else { CFE_ES_TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_INVALID_POOL_HANDLE_ERR_EID, CFE_EVS_EventType_ERROR, "Cannot telemeter memory pool stats. Illegal Handle (0x%08lX)", - CFE_ES_ResourceID_ToInteger(Cmd->PoolHandle)); + CFE_RESOURCEID_TO_ULONG(Cmd->PoolHandle)); } return CFE_SUCCESS; diff --git a/fsw/cfe-core/src/es/cfe_es_task.h b/fsw/cfe-core/src/es/cfe_es_task.h index 9b6476c0c..479799d80 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.h +++ b/fsw/cfe-core/src/es/cfe_es_task.h @@ -128,9 +128,6 @@ typedef struct /* ** ES Task initialization data (not reported in housekeeping) */ - uint8 LimitHK; - uint8 LimitCmd; - CFE_ES_BackgroundLogDumpGlobal_t BackgroundERLogDumpState; /* diff --git a/fsw/cfe-core/src/evs/cfe_evs.c b/fsw/cfe-core/src/evs/cfe_evs.c index 1d5f8a19a..f3fb70b34 100644 --- a/fsw/cfe-core/src/evs/cfe_evs.c +++ b/fsw/cfe-core/src/evs/cfe_evs.c @@ -50,12 +50,12 @@ /* ** Function: CFE_EVS_Register - See API and header file for details */ -int32 CFE_EVS_Register (void *Filters, uint16 NumEventFilters, uint16 FilterScheme) +int32 CFE_EVS_Register (const void *Filters, uint16 NumEventFilters, uint16 FilterScheme) { uint16 FilterLimit; uint16 i; int32 Status; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; CFE_EVS_BinFilter_t *AppFilters; EVS_AppData_t *AppDataPtr; @@ -89,6 +89,8 @@ int32 CFE_EVS_Register (void *Filters, uint16 NumEventFilters, uint16 FilterSche else { FilterLimit = CFE_PLATFORM_EVS_MAX_EVENT_FILTERS; + CFE_ES_WriteToSysLog("CFE_EVS_Register: Filter limit truncated to %d\n", + (int)FilterLimit); } if (Filters != NULL) @@ -126,7 +128,7 @@ int32 CFE_EVS_Register (void *Filters, uint16 NumEventFilters, uint16 FilterSche int32 CFE_EVS_Unregister(void) { int32 Status; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; EVS_AppData_t *AppDataPtr; /* Query and verify the caller's AppID */ @@ -147,7 +149,7 @@ int32 CFE_EVS_Unregister(void) int32 CFE_EVS_SendEvent (uint16 EventID, uint16 EventType, const char *Spec, ... ) { int32 Status; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; CFE_TIME_SysTime_t Time; va_list Ptr; EVS_AppData_t *AppDataPtr; @@ -181,7 +183,7 @@ int32 CFE_EVS_SendEvent (uint16 EventID, uint16 EventType, const char *Spec, ... /* ** Function: CFE_EVS_SendEventWithAppID - See API and header file for details */ -int32 CFE_EVS_SendEventWithAppID (uint16 EventID, uint16 EventType, CFE_ES_ResourceID_t AppID, const char *Spec, ... ) +int32 CFE_EVS_SendEventWithAppID (uint16 EventID, uint16 EventType, CFE_ES_AppId_t AppID, const char *Spec, ... ) { int32 Status = CFE_SUCCESS; CFE_TIME_SysTime_t Time; @@ -219,7 +221,7 @@ int32 CFE_EVS_SendEventWithAppID (uint16 EventID, uint16 EventType, CFE_ES_Resou int32 CFE_EVS_SendTimedEvent (CFE_TIME_SysTime_t Time, uint16 EventID, uint16 EventType, const char *Spec, ... ) { int32 Status; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; va_list Ptr; EVS_AppData_t *AppDataPtr; @@ -252,7 +254,7 @@ int32 CFE_EVS_ResetFilter (int16 EventID) { int32 Status; EVS_BinFilter_t *FilterPtr = NULL; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; EVS_AppData_t *AppDataPtr; /* Query and verify the caller's AppID */ @@ -289,7 +291,7 @@ int32 CFE_EVS_ResetFilter (int16 EventID) int32 CFE_EVS_ResetAllFilters ( void ) { int32 Status; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; uint32 i; EVS_AppData_t *AppDataPtr; diff --git a/fsw/cfe-core/src/evs/cfe_evs_log.c b/fsw/cfe-core/src/evs/cfe_evs_log.c index b3583b2bf..e5ae293d7 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_log.c +++ b/fsw/cfe-core/src/evs/cfe_evs_log.c @@ -54,51 +54,51 @@ void EVS_AddLog (CFE_EVS_LongEventTlm_t *EVS_PktPtr) { - if (CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled == true) + if (CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled == true) { /* Serialize access to event log control variables */ - OS_MutSemTake(CFE_EVS_GlobalData.EVS_SharedDataMutexID); + OS_MutSemTake(CFE_EVS_Global.EVS_SharedDataMutexID); - if ((CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag == true) && - (CFE_EVS_GlobalData.EVS_LogPtr->LogMode == CFE_EVS_LogMode_DISCARD)) + if ((CFE_EVS_Global.EVS_LogPtr->LogFullFlag == true) && + (CFE_EVS_Global.EVS_LogPtr->LogMode == CFE_EVS_LogMode_DISCARD)) { /* If log is full and in discard mode, just count the event */ - CFE_EVS_GlobalData.EVS_LogPtr->LogOverflowCounter++; + CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter++; } else { - if (CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag == true) + if (CFE_EVS_Global.EVS_LogPtr->LogFullFlag == true) { /* If log is full and in wrap mode, count it and store it */ - CFE_EVS_GlobalData.EVS_LogPtr->LogOverflowCounter++; + CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter++; } /* Copy the event data to the next available entry in the log */ - memcpy(&CFE_EVS_GlobalData.EVS_LogPtr->LogEntry[CFE_EVS_GlobalData.EVS_LogPtr->Next], + memcpy(&CFE_EVS_Global.EVS_LogPtr->LogEntry[CFE_EVS_Global.EVS_LogPtr->Next], EVS_PktPtr, sizeof(*EVS_PktPtr)); - CFE_EVS_GlobalData.EVS_LogPtr->Next++; + CFE_EVS_Global.EVS_LogPtr->Next++; - if (CFE_EVS_GlobalData.EVS_LogPtr->Next >= CFE_PLATFORM_EVS_LOG_MAX) + if (CFE_EVS_Global.EVS_LogPtr->Next >= CFE_PLATFORM_EVS_LOG_MAX) { /* This is important, even if we are in discard mode */ - CFE_EVS_GlobalData.EVS_LogPtr->Next = 0; + CFE_EVS_Global.EVS_LogPtr->Next = 0; } /* Log count cannot exceed the number of entries in the log */ - if (CFE_EVS_GlobalData.EVS_LogPtr->LogCount < CFE_PLATFORM_EVS_LOG_MAX) + if (CFE_EVS_Global.EVS_LogPtr->LogCount < CFE_PLATFORM_EVS_LOG_MAX) { - CFE_EVS_GlobalData.EVS_LogPtr->LogCount++; + CFE_EVS_Global.EVS_LogPtr->LogCount++; - if (CFE_EVS_GlobalData.EVS_LogPtr->LogCount == CFE_PLATFORM_EVS_LOG_MAX) + if (CFE_EVS_Global.EVS_LogPtr->LogCount == CFE_PLATFORM_EVS_LOG_MAX) { /* The full flag and log count are somewhat redundant */ - CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag = true; + CFE_EVS_Global.EVS_LogPtr->LogFullFlag = true; } } } - OS_MutSemGive(CFE_EVS_GlobalData.EVS_SharedDataMutexID); + OS_MutSemGive(CFE_EVS_Global.EVS_SharedDataMutexID); } return; @@ -120,18 +120,18 @@ void EVS_ClearLog ( void ) { /* Serialize access to event log control variables */ - OS_MutSemTake(CFE_EVS_GlobalData.EVS_SharedDataMutexID); + OS_MutSemTake(CFE_EVS_Global.EVS_SharedDataMutexID); /* Clears everything but LogMode (overwrite vs discard) */ - CFE_EVS_GlobalData.EVS_LogPtr->Next = 0; - CFE_EVS_GlobalData.EVS_LogPtr->LogCount = 0; - CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag = false; - CFE_EVS_GlobalData.EVS_LogPtr->LogOverflowCounter = 0; + CFE_EVS_Global.EVS_LogPtr->Next = 0; + CFE_EVS_Global.EVS_LogPtr->LogCount = 0; + CFE_EVS_Global.EVS_LogPtr->LogFullFlag = false; + CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter = 0; - memset(CFE_EVS_GlobalData.EVS_LogPtr->LogEntry, 0, - sizeof(CFE_EVS_GlobalData.EVS_LogPtr->LogEntry)); + memset(CFE_EVS_Global.EVS_LogPtr->LogEntry, 0, + sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry)); - OS_MutSemGive(CFE_EVS_GlobalData.EVS_SharedDataMutexID); + OS_MutSemGive(CFE_EVS_Global.EVS_SharedDataMutexID); return; @@ -159,7 +159,7 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) CFE_FS_Header_t LogFileHdr; char LogFilename[OS_MAX_PATH_LEN]; - if (CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled == false) + if (CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled == false) { EVS_SendEvent(CFE_EVS_NO_LOGWR_EID, CFE_EVS_EventType_ERROR, "Write Log Command: Event Log is Disabled"); @@ -195,13 +195,13 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) if (BytesWritten == sizeof(LogFileHdr)) { /* Serialize access to event log control variables */ - OS_MutSemTake(CFE_EVS_GlobalData.EVS_SharedDataMutexID); + OS_MutSemTake(CFE_EVS_Global.EVS_SharedDataMutexID); /* Is the log full? -- Doesn't matter if wrap mode is enabled */ - if (CFE_EVS_GlobalData.EVS_LogPtr->LogCount == CFE_PLATFORM_EVS_LOG_MAX) + if (CFE_EVS_Global.EVS_LogPtr->LogCount == CFE_PLATFORM_EVS_LOG_MAX) { /* Start with log entry that will be overwritten next (oldest) */ - LogIndex = CFE_EVS_GlobalData.EVS_LogPtr->Next; + LogIndex = CFE_EVS_Global.EVS_LogPtr->Next; } else { @@ -210,13 +210,13 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) } /* Write all the "in-use" event log entries to the file */ - for (i = 0; i < CFE_EVS_GlobalData.EVS_LogPtr->LogCount; i++) + for (i = 0; i < CFE_EVS_Global.EVS_LogPtr->LogCount; i++) { BytesWritten = OS_write(LogFileHandle, - &CFE_EVS_GlobalData.EVS_LogPtr->LogEntry[LogIndex], - sizeof(CFE_EVS_GlobalData.EVS_LogPtr->LogEntry[LogIndex])); + &CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex], + sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])); - if (BytesWritten == sizeof(CFE_EVS_GlobalData.EVS_LogPtr->LogEntry[LogIndex])) + if (BytesWritten == sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])) { LogIndex++; @@ -231,14 +231,14 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) } } - OS_MutSemGive(CFE_EVS_GlobalData.EVS_SharedDataMutexID); + OS_MutSemGive(CFE_EVS_Global.EVS_SharedDataMutexID); /* Process command handler success result */ - if (i == CFE_EVS_GlobalData.EVS_LogPtr->LogCount) + if (i == CFE_EVS_Global.EVS_LogPtr->LogCount) { EVS_SendEvent(CFE_EVS_WRLOG_EID, CFE_EVS_EventType_DEBUG, "Write Log File Command: %d event log entries written to %s", - (int)CFE_EVS_GlobalData.EVS_LogPtr->LogCount, LogFilename); + (int)CFE_EVS_Global.EVS_LogPtr->LogCount, LogFilename); Result = CFE_SUCCESS; } else @@ -274,14 +274,14 @@ int32 CFE_EVS_SetLogModeCmd(const CFE_EVS_SetLogModeCmd_t *data) const CFE_EVS_SetLogMode_Payload_t *CmdPtr = &data->Payload; int32 Status; - if (CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled == true) + if (CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled == true) { if ((CmdPtr->LogMode == CFE_EVS_LogMode_OVERWRITE) || (CmdPtr->LogMode == CFE_EVS_LogMode_DISCARD)) { /* Serialize access to event log control variables */ - OS_MutSemTake(CFE_EVS_GlobalData.EVS_SharedDataMutexID); - CFE_EVS_GlobalData.EVS_LogPtr->LogMode = CmdPtr->LogMode; - OS_MutSemGive(CFE_EVS_GlobalData.EVS_SharedDataMutexID); + OS_MutSemTake(CFE_EVS_Global.EVS_SharedDataMutexID); + CFE_EVS_Global.EVS_LogPtr->LogMode = CmdPtr->LogMode; + OS_MutSemGive(CFE_EVS_Global.EVS_SharedDataMutexID); EVS_SendEvent(CFE_EVS_LOGMODE_EID, CFE_EVS_EventType_DEBUG, "Set Log Mode Command: Log Mode = %d", (int)CmdPtr->LogMode); diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.c b/fsw/cfe-core/src/evs/cfe_evs_task.c index e47e449ae..152b8c133 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.c +++ b/fsw/cfe-core/src/evs/cfe_evs_task.c @@ -47,7 +47,7 @@ #include "private/cfe_es_resetdata_typedef.h" /* Definition of CFE_ES_ResetData_t */ /* Global Data */ -CFE_EVS_GlobalData_t CFE_EVS_GlobalData; +CFE_EVS_Global_t CFE_EVS_Global; /* @@ -74,28 +74,22 @@ bool CFE_EVS_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength); int32 CFE_EVS_EarlyInit ( void ) { -#ifdef CFE_PLATFORM_EVS_LOG_ON - int32 Status; uint32 resetAreaSize = 0; cpuaddr resetAreaAddr; CFE_ES_ResetData_t *CFE_EVS_ResetDataPtr = (CFE_ES_ResetData_t *) NULL; -#endif - - memset(&CFE_EVS_GlobalData, 0, sizeof(CFE_EVS_GlobalData_t)); + memset(&CFE_EVS_Global, 0, sizeof(CFE_EVS_Global)); /* Initialize housekeeping packet */ - CFE_MSG_Init(&CFE_EVS_GlobalData.EVS_TlmPkt.TlmHeader.Msg, CFE_SB_ValueToMsgId(CFE_EVS_HK_TLM_MID), - sizeof(CFE_EVS_GlobalData.EVS_TlmPkt)); + CFE_MSG_Init(&CFE_EVS_Global.EVS_TlmPkt.TlmHeader.Msg, CFE_SB_ValueToMsgId(CFE_EVS_HK_TLM_MID), + sizeof(CFE_EVS_Global.EVS_TlmPkt)); /* Elements stored in the hk packet that have non-zero default values */ - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode = CFE_PLATFORM_EVS_DEFAULT_MSG_FORMAT_MODE; - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort = CFE_PLATFORM_EVS_PORT_DEFAULT; - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogFullFlag = false; - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE; - -#ifdef CFE_PLATFORM_EVS_LOG_ON + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_PLATFORM_EVS_DEFAULT_MSG_FORMAT_MODE; + CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort = CFE_PLATFORM_EVS_PORT_DEFAULT; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogFullFlag = false; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE; /* Get a pointer to the CFE reset area from the BSP */ Status = CFE_PSP_GetResetArea(&resetAreaAddr, &resetAreaSize); @@ -115,10 +109,10 @@ int32 CFE_EVS_EarlyInit ( void ) { CFE_EVS_ResetDataPtr = (CFE_ES_ResetData_t *)resetAreaAddr; /* Save pointer to the EVS portion of the CFE reset area */ - CFE_EVS_GlobalData.EVS_LogPtr = &CFE_EVS_ResetDataPtr->EVS_Log; + CFE_EVS_Global.EVS_LogPtr = &CFE_EVS_ResetDataPtr->EVS_Log; /* Create semaphore to serialize access to event log */ - Status = OS_MutSemCreate(&CFE_EVS_GlobalData.EVS_SharedDataMutexID, "CFE_EVS_DataMutex", 0); + Status = OS_MutSemCreate(&CFE_EVS_Global.EVS_SharedDataMutexID, "CFE_EVS_DataMutex", 0); if (Status != OS_SUCCESS) { @@ -127,44 +121,42 @@ int32 CFE_EVS_EarlyInit ( void ) else { /* Enable access to the EVS event log */ - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled = true; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = true; /* Clear event log if power-on reset or bad contents */ if (CFE_ES_GetResetType(NULL) == CFE_PSP_RST_TYPE_POWERON) { CFE_ES_WriteToSysLog("Event Log cleared following power-on reset\n"); EVS_ClearLog(); - CFE_EVS_GlobalData.EVS_LogPtr->LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE; + CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE; } - else if (((CFE_EVS_GlobalData.EVS_LogPtr->LogMode != CFE_EVS_LogMode_OVERWRITE) && - (CFE_EVS_GlobalData.EVS_LogPtr->LogMode != CFE_EVS_LogMode_DISCARD)) || - ((CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag != false) && - (CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag != true)) || - (CFE_EVS_GlobalData.EVS_LogPtr->Next >= CFE_PLATFORM_EVS_LOG_MAX)) + else if (((CFE_EVS_Global.EVS_LogPtr->LogMode != CFE_EVS_LogMode_OVERWRITE) && + (CFE_EVS_Global.EVS_LogPtr->LogMode != CFE_EVS_LogMode_DISCARD)) || + ((CFE_EVS_Global.EVS_LogPtr->LogFullFlag != false) && + (CFE_EVS_Global.EVS_LogPtr->LogFullFlag != true)) || + (CFE_EVS_Global.EVS_LogPtr->Next >= CFE_PLATFORM_EVS_LOG_MAX)) { CFE_ES_WriteToSysLog("Event Log cleared, n=%d, c=%d, f=%d, m=%d, o=%d\n", - (int)CFE_EVS_GlobalData.EVS_LogPtr->Next, - (int)CFE_EVS_GlobalData.EVS_LogPtr->LogCount, - (int)CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag, - (int)CFE_EVS_GlobalData.EVS_LogPtr->LogMode, - (int)CFE_EVS_GlobalData.EVS_LogPtr->LogOverflowCounter); + (int)CFE_EVS_Global.EVS_LogPtr->Next, + (int)CFE_EVS_Global.EVS_LogPtr->LogCount, + (int)CFE_EVS_Global.EVS_LogPtr->LogFullFlag, + (int)CFE_EVS_Global.EVS_LogPtr->LogMode, + (int)CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter); EVS_ClearLog(); - CFE_EVS_GlobalData.EVS_LogPtr->LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE; + CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE; } else { CFE_ES_WriteToSysLog("Event Log restored, n=%d, c=%d, f=%d, m=%d, o=%d\n", - (int)CFE_EVS_GlobalData.EVS_LogPtr->Next, - (int)CFE_EVS_GlobalData.EVS_LogPtr->LogCount, - (int)CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag, - (int)CFE_EVS_GlobalData.EVS_LogPtr->LogMode, - (int)CFE_EVS_GlobalData.EVS_LogPtr->LogOverflowCounter); + (int)CFE_EVS_Global.EVS_LogPtr->Next, + (int)CFE_EVS_Global.EVS_LogPtr->LogCount, + (int)CFE_EVS_Global.EVS_LogPtr->LogFullFlag, + (int)CFE_EVS_Global.EVS_LogPtr->LogMode, + (int)CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter); } } } -#endif - return(CFE_SUCCESS); } /* End CFE_EVS_EarlyInit */ @@ -179,7 +171,7 @@ int32 CFE_EVS_EarlyInit ( void ) ** ** Assumptions and Notes: */ -int32 CFE_EVS_CleanUpApp(CFE_ES_ResourceID_t AppID) +int32 CFE_EVS_CleanUpApp(CFE_ES_AppId_t AppID) { int32 Status = CFE_SUCCESS; EVS_AppData_t *AppDataPtr; @@ -245,7 +237,7 @@ void CFE_EVS_TaskMain(void) /* Pend on receipt of packet */ Status = CFE_SB_ReceiveBuffer(&SBBufPtr, - CFE_EVS_GlobalData.EVS_CommandPipe, + CFE_EVS_Global.EVS_CommandPipe, CFE_SB_PEND_FOREVER); CFE_ES_PerfLogEntry(CFE_MISSION_EVS_MAIN_PERF_ID); @@ -280,7 +272,7 @@ void CFE_EVS_TaskMain(void) int32 CFE_EVS_TaskInit ( void ) { int32 Status; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; /* Register EVS application */ Status = CFE_ES_RegisterApp(); @@ -307,7 +299,7 @@ int32 CFE_EVS_TaskInit ( void ) } /* Create software bus command pipe */ - Status = CFE_SB_CreatePipe(&CFE_EVS_GlobalData.EVS_CommandPipe, + Status = CFE_SB_CreatePipe(&CFE_EVS_Global.EVS_CommandPipe, CFE_EVS_PIPE_DEPTH, CFE_EVS_PIPE_NAME); if (Status != CFE_SUCCESS) { @@ -316,16 +308,14 @@ int32 CFE_EVS_TaskInit ( void ) } /* Subscribe to command and telemetry requests coming in on the command pipe */ - Status = CFE_SB_SubscribeEx(CFE_SB_ValueToMsgId(CFE_EVS_CMD_MID), CFE_EVS_GlobalData.EVS_CommandPipe, - CFE_SB_Default_Qos, CFE_EVS_MSG_LIMIT); + Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_EVS_CMD_MID), CFE_EVS_Global.EVS_CommandPipe); if (Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("EVS:Subscribing to Cmds Failed:RC=0x%08X\n",(unsigned int)Status); return Status; } - Status = CFE_SB_SubscribeEx(CFE_SB_ValueToMsgId(CFE_EVS_SEND_HK_MID), CFE_EVS_GlobalData.EVS_CommandPipe, - CFE_SB_Default_Qos, CFE_EVS_MSG_LIMIT); + Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_EVS_SEND_HK_MID), CFE_EVS_Global.EVS_CommandPipe); if (Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("EVS:Subscribing to HK Request Failed:RC=0x%08X\n",(unsigned int)Status); @@ -333,7 +323,7 @@ int32 CFE_EVS_TaskInit ( void ) } /* Write the AppID to the global location, now that the rest of initialization is done */ - CFE_EVS_GlobalData.EVS_AppID = AppID; + CFE_EVS_Global.EVS_AppID = AppID; EVS_SendEvent(CFE_EVS_STARTUP_EID, CFE_EVS_EventType_INFORMATION, "cFE EVS Initialized.%s", CFE_VERSION_STRING); return CFE_SUCCESS; @@ -373,7 +363,7 @@ void CFE_EVS_ProcessCommandPacket(CFE_SB_Buffer_t *SBBufPtr) default: /* Unknown command -- should never occur */ - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.CommandErrorCounter++; + CFE_EVS_Global.EVS_TlmPkt.Payload.CommandErrorCounter++; EVS_SendEvent(CFE_EVS_ERR_MSGID_EID, CFE_EVS_EventType_ERROR, "Invalid command packet, Message ID = 0x%08X", (unsigned int)CFE_SB_MsgIdToValue(MessageID)); @@ -589,11 +579,11 @@ void CFE_EVS_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr, CFE_SB_MsgId_t MsgI if (Status == CFE_SUCCESS) { - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.CommandCounter++; + CFE_EVS_Global.EVS_TlmPkt.Payload.CommandCounter++; } else if (Status < 0) /* Negative values indicate errors */ { - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.CommandErrorCounter++; + CFE_EVS_Global.EVS_TlmPkt.Payload.CommandErrorCounter++; } return; @@ -670,7 +660,7 @@ int32 CFE_EVS_ClearLogCmd(const CFE_EVS_ClearLogCmd_t *data) { int32 Status; - if (CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled == true) + if (CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled == true) { EVS_ClearLog(); Status = CFE_SUCCESS; @@ -700,17 +690,17 @@ int32 CFE_EVS_ReportHousekeepingCmd (const CFE_MSG_CommandHeader_t *data) EVS_AppData_t *AppDataPtr; CFE_EVS_AppTlmData_t *AppTlmDataPtr; - if (CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled == true) + if (CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled == true) { /* Copy hk variables that are maintained in the event log */ - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogFullFlag = CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag; - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogMode = CFE_EVS_GlobalData.EVS_LogPtr->LogMode; - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogOverflowCounter = CFE_EVS_GlobalData.EVS_LogPtr->LogOverflowCounter; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogFullFlag = CFE_EVS_Global.EVS_LogPtr->LogFullFlag; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogMode = CFE_EVS_Global.EVS_LogPtr->LogMode; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogOverflowCounter = CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter; } /* Write event state data for registered apps to telemetry packet */ - AppDataPtr = CFE_EVS_GlobalData.AppData; - AppTlmDataPtr = CFE_EVS_GlobalData.EVS_TlmPkt.Payload.AppData; + AppDataPtr = CFE_EVS_Global.AppData; + AppTlmDataPtr = CFE_EVS_Global.EVS_TlmPkt.Payload.AppData; for (i = 0, j = 0; j < CFE_MISSION_ES_MAX_APPLICATIONS && i < CFE_PLATFORM_ES_MAX_APPLICATIONS; i++) { if ( EVS_AppDataIsUsed(AppDataPtr) ) @@ -727,14 +717,14 @@ int32 CFE_EVS_ReportHousekeepingCmd (const CFE_MSG_CommandHeader_t *data) /* Clear unused portion of event state data in telemetry packet */ for (i = j; i < CFE_MISSION_ES_MAX_APPLICATIONS; i++) { - AppTlmDataPtr->AppID = CFE_ES_RESOURCEID_UNDEFINED; + AppTlmDataPtr->AppID = CFE_ES_APPID_UNDEFINED; AppTlmDataPtr->AppEnableStatus = false; AppTlmDataPtr->AppMessageSentCounter = 0; } - CFE_SB_TimeStampMsg(&CFE_EVS_GlobalData.EVS_TlmPkt.TlmHeader.Msg); + CFE_SB_TimeStampMsg(&CFE_EVS_Global.EVS_TlmPkt.TlmHeader.Msg); - CFE_SB_TransmitMsg(&CFE_EVS_GlobalData.EVS_TlmPkt.TlmHeader.Msg, true); + CFE_SB_TransmitMsg(&CFE_EVS_Global.EVS_TlmPkt.TlmHeader.Msg, true); return CFE_STATUS_NO_COUNTER_INCREMENT; } /* End of CFE_EVS_ReportHousekeepingCmd() */ @@ -754,13 +744,13 @@ int32 CFE_EVS_ReportHousekeepingCmd (const CFE_MSG_CommandHeader_t *data) int32 CFE_EVS_ResetCountersCmd(const CFE_EVS_ResetCountersCmd_t *data) { /* Status of commands processed by EVS task */ - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.CommandCounter = 0; - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.CommandErrorCounter = 0; + CFE_EVS_Global.EVS_TlmPkt.Payload.CommandCounter = 0; + CFE_EVS_Global.EVS_TlmPkt.Payload.CommandErrorCounter = 0; /* EVS telemetry counters */ - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageSendCounter = 0; - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageTruncCounter = 0; - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.UnregisteredAppCounter = 0; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageSendCounter = 0; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageTruncCounter = 0; + CFE_EVS_Global.EVS_TlmPkt.Payload.UnregisteredAppCounter = 0; EVS_SendEvent(CFE_EVS_RSTCNT_EID, CFE_EVS_EventType_DEBUG, "Reset Counters Command Received"); @@ -877,19 +867,19 @@ int32 CFE_EVS_EnablePortsCmd(const CFE_EVS_EnablePortsCmd_t *data) /* Process command data */ if(((CmdPtr->BitMask & CFE_EVS_PORT1_BIT) >> 0) == true) { - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort |= CFE_EVS_PORT1_BIT; + CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort |= CFE_EVS_PORT1_BIT; } if(((CmdPtr->BitMask & CFE_EVS_PORT2_BIT) >>1) == true) { - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort |= CFE_EVS_PORT2_BIT; + CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort |= CFE_EVS_PORT2_BIT; } if(((CmdPtr->BitMask & CFE_EVS_PORT3_BIT) >> 2) == true) { - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort |= CFE_EVS_PORT3_BIT; + CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort |= CFE_EVS_PORT3_BIT; } if(((CmdPtr->BitMask & CFE_EVS_PORT4_BIT) >>3) == true) { - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort |= CFE_EVS_PORT4_BIT; + CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort |= CFE_EVS_PORT4_BIT; } EVS_SendEvent(CFE_EVS_ENAPORT_EID, CFE_EVS_EventType_DEBUG, @@ -933,19 +923,19 @@ int32 CFE_EVS_DisablePortsCmd(const CFE_EVS_DisablePortsCmd_t *data) /* Process command data */ if(((CmdPtr->BitMask & CFE_EVS_PORT1_BIT) >>0) == true) { - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort &= ~CFE_EVS_PORT1_BIT; + CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort &= ~CFE_EVS_PORT1_BIT; } if(((CmdPtr->BitMask & CFE_EVS_PORT2_BIT) >> 1) == true) { - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort &= ~CFE_EVS_PORT2_BIT; + CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort &= ~CFE_EVS_PORT2_BIT; } if(((CmdPtr->BitMask & CFE_EVS_PORT3_BIT) >> 2) == true) { - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort &= ~CFE_EVS_PORT3_BIT; + CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort &= ~CFE_EVS_PORT3_BIT; } if(((CmdPtr->BitMask & CFE_EVS_PORT4_BIT) >>3) == true) { - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort &= ~CFE_EVS_PORT4_BIT; + CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort &= ~CFE_EVS_PORT4_BIT; } EVS_SendEvent(CFE_EVS_DISPORT_EID, CFE_EVS_EventType_DEBUG, @@ -989,7 +979,7 @@ int32 CFE_EVS_EnableEventTypeCmd(const CFE_EVS_EnableEventTypeCmd_t *data) } else { - AppDataPtr = CFE_EVS_GlobalData.AppData; + AppDataPtr = CFE_EVS_Global.AppData; for (i = 0; i < CFE_PLATFORM_ES_MAX_APPLICATIONS; i++) { /* Make sure application is registered for event services */ @@ -1041,7 +1031,7 @@ int32 CFE_EVS_DisableEventTypeCmd(const CFE_EVS_DisableEventTypeCmd_t *data) else { - AppDataPtr = CFE_EVS_GlobalData.AppData; + AppDataPtr = CFE_EVS_Global.AppData; for (i = 0; i < CFE_PLATFORM_ES_MAX_APPLICATIONS; i++) { /* Make sure application is registered for event services */ @@ -1082,7 +1072,7 @@ int32 CFE_EVS_SetEventFormatModeCmd(const CFE_EVS_SetEventFormatModeCmd_t *data) if((CmdPtr->MsgFormat == CFE_EVS_MsgFormat_SHORT) || (CmdPtr->MsgFormat == CFE_EVS_MsgFormat_LONG)) { - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode = CmdPtr->MsgFormat; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CmdPtr->MsgFormat; EVS_SendEvent(CFE_EVS_SETEVTFMTMOD_EID, CFE_EVS_EventType_DEBUG, "Set Event Format Mode Command Received with Mode = 0x%02x", @@ -1788,7 +1778,7 @@ int32 CFE_EVS_WriteAppDataFileCmd(const CFE_EVS_WriteAppDataFileCmd_t *data) if (BytesWritten == sizeof(CFE_FS_Header_t)) { - AppDataPtr = CFE_EVS_GlobalData.AppData; + AppDataPtr = CFE_EVS_Global.AppData; for (i = 0; i < CFE_PLATFORM_ES_MAX_APPLICATIONS; i++) { /* Only have data for apps that are registered */ diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.h b/fsw/cfe-core/src/evs/cfe_evs_task.h index 40a5e3aea..079e1118f 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.h +++ b/fsw/cfe-core/src/evs/cfe_evs_task.h @@ -59,7 +59,6 @@ #define CFE_EVS_FREE_SLOT (-1) #define CFE_EVS_NO_MASK 0 #define CFE_EVS_PIPE_DEPTH 32 -#define CFE_EVS_MSG_LIMIT 4 #define CFE_EVS_MAX_EVENT_SEND_COUNT 65535 #define CFE_EVS_MAX_FILTER_COUNT 65535 #define CFE_EVS_PIPE_NAME "EVS_CMD_PIPE" @@ -88,8 +87,8 @@ typedef struct typedef struct { - CFE_ES_ResourceID_t AppID; - CFE_ES_ResourceID_t UnregAppID; + CFE_ES_AppId_t AppID; + CFE_ES_AppId_t UnregAppID; EVS_BinFilter_t BinFilters[CFE_PLATFORM_EVS_MAX_EVENT_FILTERS]; /* Array of binary filters */ @@ -124,14 +123,14 @@ typedef struct CFE_EVS_HousekeepingTlm_t EVS_TlmPkt; CFE_SB_PipeId_t EVS_CommandPipe; osal_id_t EVS_SharedDataMutexID; - CFE_ES_ResourceID_t EVS_AppID; + CFE_ES_AppId_t EVS_AppID; -} CFE_EVS_GlobalData_t; +} CFE_EVS_Global_t; /* * Global variable specific to EVS module */ -extern CFE_EVS_GlobalData_t CFE_EVS_GlobalData; +extern CFE_EVS_Global_t CFE_EVS_Global; /***************************** Function Prototypes **********************************/ diff --git a/fsw/cfe-core/src/evs/cfe_evs_utils.c b/fsw/cfe-core/src/evs/cfe_evs_utils.c index c1cb9b25d..ad80eb88a 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_utils.c +++ b/fsw/cfe-core/src/evs/cfe_evs_utils.c @@ -64,7 +64,7 @@ void EVS_OutputPort4 (char *Message); ** Assumptions and Notes: ** */ -EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_ResourceID_t AppID) +EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_AppId_t AppID) { uint32 AppIndex; EVS_AppData_t *AppDataPtr; @@ -72,7 +72,7 @@ EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_ResourceID_t AppID) if (CFE_ES_AppID_ToIndex(AppID, &AppIndex) == CFE_SUCCESS && AppIndex < CFE_PLATFORM_ES_MAX_APPLICATIONS) { - AppDataPtr = &CFE_EVS_GlobalData.AppData[AppIndex]; + AppDataPtr = &CFE_EVS_Global.AppData[AppIndex]; } else { @@ -83,9 +83,9 @@ EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_ResourceID_t AppID) } /* End EVS_GetAppDataByID */ -int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_ResourceID_t *AppIDOut) +int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_AppId_t *AppIDOut) { - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; EVS_AppData_t *AppDataPtr; int32 Status; @@ -134,7 +134,7 @@ int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_ResourceID_t *Ap int32 EVS_GetApplicationInfo (EVS_AppData_t **AppDataOut, const char *pAppName) { int32 Status; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; EVS_AppData_t *AppDataPtr; Status = CFE_ES_GetAppIDByName(&AppID, pAppName); @@ -180,15 +180,15 @@ int32 EVS_GetApplicationInfo (EVS_AppData_t **AppDataOut, const char *pAppName) ** Assumptions and Notes: ** */ -int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_t CallerID) +int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, CFE_ES_AppId_t CallerID) { char AppName[OS_MAX_API_NAME]; /* Send only one "not registered" event per application */ - if ( !CFE_ES_ResourceID_Equal(AppDataPtr->UnregAppID, CallerID) ) + if ( !CFE_RESOURCEID_TEST_EQUAL(AppDataPtr->UnregAppID, CallerID) ) { /* Increment count of "not registered" applications */ - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.UnregisteredAppCounter++; + CFE_EVS_Global.EVS_TlmPkt.Payload.UnregisteredAppCounter++; /* Indicate that "not registered" event has been sent for this app */ AppDataPtr->UnregAppID = CallerID; @@ -418,7 +418,7 @@ void EVS_GenerateEventTelemetry(EVS_AppData_t *AppDataPtr, uint16 EventID, uint1 { /* Mark character before zero terminator to indicate truncation */ LongEventTlm.Payload.Message[sizeof(LongEventTlm.Payload.Message) - 2] = CFE_EVS_MSG_TRUNCATED; - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageTruncCounter++; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageTruncCounter++; } /* Obtain task and system information */ @@ -436,12 +436,12 @@ void EVS_GenerateEventTelemetry(EVS_AppData_t *AppDataPtr, uint16 EventID, uint1 /* Send event via selected ports */ EVS_SendViaPorts(&LongEventTlm); - if (CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode == CFE_EVS_MsgFormat_LONG) + if (CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode == CFE_EVS_MsgFormat_LONG) { /* Send long event via SoftwareBus */ CFE_SB_TransmitMsg(&LongEventTlm.TlmHeader.Msg, true); } - else if (CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode == CFE_EVS_MsgFormat_SHORT) + else if (CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode == CFE_EVS_MsgFormat_SHORT) { /* * Initialize the short format event message from data that was already @@ -457,9 +457,9 @@ void EVS_GenerateEventTelemetry(EVS_AppData_t *AppDataPtr, uint16 EventID, uint1 } /* Increment message send counters (prevent rollover) */ - if (CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageSendCounter < CFE_EVS_MAX_EVENT_SEND_COUNT) + if (CFE_EVS_Global.EVS_TlmPkt.Payload.MessageSendCounter < CFE_EVS_MAX_EVENT_SEND_COUNT) { - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageSendCounter++; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageSendCounter++; } if (AppDataPtr->EventCount < CFE_EVS_MAX_EVENT_SEND_COUNT) @@ -484,7 +484,7 @@ void EVS_SendViaPorts (CFE_EVS_LongEventTlm_t *EVS_PktPtr) { char PortMessage[CFE_EVS_MAX_PORT_MSG_LENGTH]; - if (((CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT1_BIT) >> 0) == true) + if (((CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT1_BIT) >> 0) == true) { /* Copy event message to string format */ snprintf(PortMessage, CFE_EVS_MAX_PORT_MSG_LENGTH, "EVS Port1 %u/%u/%s %u: %s", (unsigned int) EVS_PktPtr->Payload.PacketID.SpacecraftID, @@ -496,7 +496,7 @@ void EVS_SendViaPorts (CFE_EVS_LongEventTlm_t *EVS_PktPtr) EVS_OutputPort1(PortMessage); } - if (((CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT2_BIT) >> 1) == true) + if (((CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT2_BIT) >> 1) == true) { /* Copy event message to string format */ snprintf(PortMessage, CFE_EVS_MAX_PORT_MSG_LENGTH, "EVS Port2 %u/%u/%s %u: %s", (unsigned int) EVS_PktPtr->Payload.PacketID.SpacecraftID, @@ -508,7 +508,7 @@ void EVS_SendViaPorts (CFE_EVS_LongEventTlm_t *EVS_PktPtr) EVS_OutputPort2(PortMessage); } - if (((CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT3_BIT) >> 2) == true) + if (((CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT3_BIT) >> 2) == true) { /* Copy event message to string format */ snprintf(PortMessage, CFE_EVS_MAX_PORT_MSG_LENGTH, "EVS Port3 %u/%u/%s %u: %s", (unsigned int) EVS_PktPtr->Payload.PacketID.SpacecraftID, @@ -520,7 +520,7 @@ void EVS_SendViaPorts (CFE_EVS_LongEventTlm_t *EVS_PktPtr) EVS_OutputPort3(PortMessage); } - if (((CFE_EVS_GlobalData.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT4_BIT) >> 3) == true) + if (((CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT4_BIT) >> 3) == true) { /* Copy event message to string format */ snprintf(PortMessage, CFE_EVS_MAX_PORT_MSG_LENGTH, "EVS Port4 %u/%u/%s %u: %s", (unsigned int) EVS_PktPtr->Payload.PacketID.SpacecraftID, @@ -629,10 +629,10 @@ int32 EVS_SendEvent (uint16 EventID, uint16 EventType, const char *Spec, ... ) * Must check that EVS_AppID is valid, which can happen if this is called * by some other thread before CFE_EVS_TaskInit() runs */ - AppDataPtr = EVS_GetAppDataByID(CFE_EVS_GlobalData.EVS_AppID); + AppDataPtr = EVS_GetAppDataByID(CFE_EVS_Global.EVS_AppID); /* Unlikely, but possible that an EVS event filter was added by command */ - if ( EVS_AppDataIsMatch(AppDataPtr, CFE_EVS_GlobalData.EVS_AppID) && + if ( EVS_AppDataIsMatch(AppDataPtr, CFE_EVS_Global.EVS_AppID) && EVS_IsFiltered(AppDataPtr, EventID, EventType) == false) { /* Get current spacecraft time */ diff --git a/fsw/cfe-core/src/evs/cfe_evs_utils.h b/fsw/cfe-core/src/evs/cfe_evs_utils.h index b995abc4f..b2ee70d84 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_utils.h +++ b/fsw/cfe-core/src/evs/cfe_evs_utils.h @@ -63,7 +63,7 @@ * @param[in] AppID AppID to find * @returns Pointer to app table entry, or NULL if ID is invalid. */ -EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_ResourceID_t AppID); +EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_AppId_t AppID); /** * @brief Obtain the context information for the currently running app @@ -74,7 +74,7 @@ EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_ResourceID_t AppID); * @param[out] AppIDOut Location to store AppID * @returns CFE_SUCCESS if successful, or relevant error code. */ -int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_ResourceID_t *AppIDOut); +int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_AppId_t *AppIDOut); /** @@ -90,7 +90,7 @@ int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_ResourceID_t *Ap */ static inline bool EVS_AppDataIsUsed(EVS_AppData_t *AppDataPtr) { - return CFE_ES_ResourceID_IsDefined(AppDataPtr->AppID); + return CFE_RESOURCEID_TEST_DEFINED(AppDataPtr->AppID); } /** @@ -101,7 +101,7 @@ static inline bool EVS_AppDataIsUsed(EVS_AppData_t *AppDataPtr) * @param[in] AppDataPtr pointer to app table entry * @returns AppID of entry */ -static inline CFE_ES_ResourceID_t EVS_AppDataGetID(EVS_AppData_t *AppDataPtr) +static inline CFE_ES_AppId_t EVS_AppDataGetID(EVS_AppData_t *AppDataPtr) { /* * The initial implementation does not store the ID in the entry; @@ -122,7 +122,7 @@ static inline CFE_ES_ResourceID_t EVS_AppDataGetID(EVS_AppData_t *AppDataPtr) * @param[in] AppDataPtr pointer to app table entry * @param[in] AppID the app ID of this entry */ -static inline void EVS_AppDataSetUsed(EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_t AppID) +static inline void EVS_AppDataSetUsed(EVS_AppData_t *AppDataPtr, CFE_ES_AppId_t AppID) { AppDataPtr->AppID = AppID; } @@ -137,7 +137,7 @@ static inline void EVS_AppDataSetUsed(EVS_AppData_t *AppDataPtr, CFE_ES_Resource */ static inline void EVS_AppDataSetFree(EVS_AppData_t *AppDataPtr) { - AppDataPtr->AppID = CFE_ES_RESOURCEID_UNDEFINED; + AppDataPtr->AppID = CFE_ES_APPID_UNDEFINED; } /** @@ -150,16 +150,16 @@ static inline void EVS_AppDataSetFree(EVS_AppData_t *AppDataPtr) * @param[in] AppID expected app ID * @returns true if the entry matches the given app ID */ -static inline bool EVS_AppDataIsMatch(EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_t AppID) +static inline bool EVS_AppDataIsMatch(EVS_AppData_t *AppDataPtr, CFE_ES_AppId_t AppID) { - return (AppDataPtr != NULL && CFE_ES_ResourceID_Equal(AppDataPtr->AppID, AppID)); + return (AppDataPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(AppDataPtr->AppID, AppID)); } int32 EVS_GetApplicationInfo(EVS_AppData_t **AppDataOut, const char *pAppName); -int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_t CallerID); +int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, CFE_ES_AppId_t CallerID); bool EVS_IsFiltered(EVS_AppData_t *AppDataPtr, uint16 EventID, uint16 EventType); diff --git a/fsw/cfe-core/src/fs/cfe_fs_api.c b/fsw/cfe-core/src/fs/cfe_fs_api.c index 83d38f9f4..4f83e5f13 100644 --- a/fsw/cfe-core/src/fs/cfe_fs_api.c +++ b/fsw/cfe-core/src/fs/cfe_fs_api.c @@ -94,7 +94,7 @@ int32 CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) CFE_TIME_SysTime_t Time; int32 Result; int32 EndianCheck = 0x01020304; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; /* ** Ensure that we are at the start of the file... @@ -109,7 +109,7 @@ int32 CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) Hdr->SpacecraftID = CFE_PSP_GetSpacecraftId(); Hdr->ProcessorID = CFE_PSP_GetProcessorId(); CFE_ES_GetAppID(&AppID); - Hdr->ApplicationID = CFE_ES_ResourceID_ToInteger(AppID); + Hdr->ApplicationID = CFE_RESOURCEID_TO_ULONG(AppID); /* Fill in length field */ diff --git a/fsw/cfe-core/src/fs/cfe_fs_priv.c b/fsw/cfe-core/src/fs/cfe_fs_priv.c index 445f22de3..b0d0785f8 100644 --- a/fsw/cfe-core/src/fs/cfe_fs_priv.c +++ b/fsw/cfe-core/src/fs/cfe_fs_priv.c @@ -45,7 +45,7 @@ ** Global data ** */ -CFE_FS_t CFE_FS; +CFE_FS_Global_t CFE_FS_Global; /****************************************************************************** ** Function: CFE_FS_EarlyInit() @@ -65,7 +65,9 @@ int32 CFE_FS_EarlyInit (void) { int32 Stat; - Stat = OS_MutSemCreate(&CFE_FS.SharedDataMutexId, "CFE_FS_SharedMutex", 0); + memset(&CFE_FS_Global, 0, sizeof(CFE_FS_Global)); + + Stat = OS_MutSemCreate(&CFE_FS_Global.SharedDataMutexId, "CFE_FS_SharedMutex", 0); if( Stat != OS_SUCCESS ) { CFE_ES_WriteToSysLog("FS Shared Data Mutex creation failed! RC=0x%08x\n",(unsigned int)Stat); @@ -92,15 +94,15 @@ int32 CFE_FS_EarlyInit (void) void CFE_FS_LockSharedData(const char *FunctionName) { int32 Status; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; - Status = OS_MutSemTake(CFE_FS.SharedDataMutexId); + Status = OS_MutSemTake(CFE_FS_Global.SharedDataMutexId); if (Status != OS_SUCCESS) { CFE_ES_GetAppID(&AppId); CFE_ES_WriteToSysLog("FS SharedData Mutex Take Err Stat=0x%x,App=%lu,Function=%s\n", - (unsigned int)Status,CFE_ES_ResourceID_ToInteger(AppId),FunctionName); + (unsigned int)Status,CFE_RESOURCEID_TO_ULONG(AppId),FunctionName); }/* end if */ @@ -124,14 +126,14 @@ void CFE_FS_LockSharedData(const char *FunctionName) void CFE_FS_UnlockSharedData(const char *FunctionName) { int32 Status; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; - Status = OS_MutSemGive(CFE_FS.SharedDataMutexId); + Status = OS_MutSemGive(CFE_FS_Global.SharedDataMutexId); if (Status != OS_SUCCESS) { CFE_ES_GetAppID(&AppId); CFE_ES_WriteToSysLog("FS SharedData Mutex Give Err Stat=0x%x,App=%lu,Function=%s\n", - (unsigned int)Status,CFE_ES_ResourceID_ToInteger(AppId),FunctionName); + (unsigned int)Status,CFE_RESOURCEID_TO_ULONG(AppId),FunctionName); }/* end if */ return; diff --git a/fsw/cfe-core/src/fs/cfe_fs_priv.h b/fsw/cfe-core/src/fs/cfe_fs_priv.h index 199791ada..c4772bad5 100644 --- a/fsw/cfe-core/src/fs/cfe_fs_priv.h +++ b/fsw/cfe-core/src/fs/cfe_fs_priv.h @@ -50,7 +50,7 @@ */ /****************************************************************************** -** Typedef: CFE_FS_t +** Typedef: CFE_FS_Global_t ** ** Purpose: ** This structure contains the FS global variables. @@ -59,7 +59,7 @@ typedef struct { osal_id_t SharedDataMutexId; -} CFE_FS_t; +} CFE_FS_Global_t; /* ** FS Function Prototypes diff --git a/fsw/cfe-core/src/inc/cfe_es.h b/fsw/cfe-core/src/inc/cfe_es.h index b42457ac6..499fe397f 100644 --- a/fsw/cfe-core/src/inc/cfe_es.h +++ b/fsw/cfe-core/src/inc/cfe_es.h @@ -43,7 +43,7 @@ #include "cfe_mission_cfg.h" #include "cfe_perfids.h" #include "cfe_error.h" -#include "cfe_resourceid.h" +#include "cfe_resourceid_api.h" /*****************************************************************************/ @@ -83,11 +83,37 @@ #define CFE_ES_APP_RESTART CFE_PSP_RST_TYPE_MAX /**< Application only was reset (extend the PSP enumeration here) */ /** \} */ +/** \name Conversions for ES resource IDs */ +/** \{ */ + +/* + * Conversion macros for each ES resource ID subtype + * + * These accept a generic/non-specific CFE_ResourceId_t value + * and convert it to the corresponding resource-specific type. + * + * These should only be used when with the resource ID constants, + * or where the code has confirmed or is determining the generic + * identifier does correspond to a resource of that type. + */ +#define CFE_ES_APPID_C(val) ((CFE_ES_AppId_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_TASKID_C(val) ((CFE_ES_TaskId_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_LIBID_C(val) ((CFE_ES_LibId_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_COUNTERID_C(val) ((CFE_ES_CounterId_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_MEMHANDLE_C(val) ((CFE_ES_MemHandle_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_CDSHANDLE_C(val) ((CFE_ES_CDSHandle_t)CFE_RESOURCEID_WRAP(val)) -/** \name Critical Data Store Macros */ +/** \} */ + +/** \name Type-specific initalizers for "undefined" resource IDs */ /** \{ */ -#define CFE_ES_CDS_BAD_HANDLE CFE_ES_RESOURCEID_UNDEFINED +#define CFE_ES_APPID_UNDEFINED CFE_ES_APPID_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_TASKID_UNDEFINED CFE_ES_TASKID_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_LIBID_UNDEFINED CFE_ES_LIBID_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_COUNTERID_UNDEFINED CFE_ES_COUNTERID_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_MEMHANDLE_UNDEFINED CFE_ES_MEMHANDLE_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_CDS_BAD_HANDLE CFE_ES_CDSHANDLE_C(CFE_RESOURCEID_UNDEFINED) /** \} */ #define CFE_ES_NO_MUTEX false /**< \brief Indicates that the memory pool selection will not use a semaphore */ @@ -117,7 +143,7 @@ ** Child Task Main Function Prototype */ 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 */ +typedef int32 (*CFE_ES_LibraryEntryFuncPtr_t)(CFE_ES_LibId_t LibId); /**< \brief Required Prototype of Library Initialization Functions */ /** * @brief Type for the stack pointer of tasks. @@ -212,7 +238,7 @@ typedef void* CFE_ES_MemPoolBuf_t; * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID */ -CFE_Status_t CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx); +CFE_Status_t CFE_ES_AppID_ToIndex(CFE_ES_AppId_t AppID, uint32 *Idx); /** * @brief Obtain an index value correlating to an ES Library ID @@ -237,7 +263,7 @@ CFE_Status_t CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx); * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID */ -int32 CFE_ES_LibID_ToIndex(CFE_ES_ResourceID_t LibID, uint32 *Idx); +int32 CFE_ES_LibID_ToIndex(CFE_ES_LibId_t LibID, uint32 *Idx); /** * @brief Obtain an index value correlating to an ES Task ID @@ -262,7 +288,7 @@ int32 CFE_ES_LibID_ToIndex(CFE_ES_ResourceID_t LibID, uint32 *Idx); * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID */ -CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx); +CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx); /** * @brief Obtain an index value correlating to an ES Counter ID @@ -287,7 +313,7 @@ CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx); * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID */ -CFE_Status_t CFE_ES_CounterID_ToIndex(CFE_ES_ResourceID_t CounterID, uint32 *Idx); +CFE_Status_t CFE_ES_CounterID_ToIndex(CFE_ES_CounterId_t CounterID, uint32 *Idx); /** @} */ @@ -359,10 +385,23 @@ CFE_Status_t CFE_ES_ResetCFE(uint32 ResetType); ** \brief Restart a single cFE Application ** ** \par Description -** This API causes a cFE Application to be stopped and restarted. +** This API causes a cFE Application to be unloaded and restarted +** from the same file name as the last start. ** ** \par Assumptions, External Events, and Notes: -** None +** The filename is checked for existance prior to load. A missing file +** will be reported and the reload operation will be aborted prior +** to unloading the app. +** +** Goes through the standard CFE_ES_CleanUpApp which unloads, +** then attempts a load using the original file name. +** +** In the event that an application cannot be reloaded due to a +** missing file or any other load issue, the application may no longer be +** restarted or reloaded when given a valid load file (the app has been +** deleted and no longer exists). To recover, the application +** may be started by loading the application via the ES_STARTAPP +** command (#CFE_ES_START_APP_CC). ** ** \param[in] AppID Identifies the application to be reset. ** @@ -371,7 +410,7 @@ CFE_Status_t CFE_ES_ResetCFE(uint32 ResetType); ** \sa #CFE_ES_ReloadApp, #CFE_ES_DeleteApp ** ******************************************************************************/ -CFE_Status_t CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID); +CFE_Status_t CFE_ES_RestartApp(CFE_ES_AppId_t AppID); /*****************************************************************************/ /** @@ -382,11 +421,17 @@ CFE_Status_t CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID); ** the specified file. ** ** \par Assumptions, External Events, and Notes: -** The specified application will be deleted before it is reloaded from the -** specified file. In the event that an application cannot be reloaded due to +** The filename is checked for existance prior to load. A missing file +** will be reported and the reload operation will be aborted prior +** to unloading the app. +** +** Goes through the standard CFE_ES_CleanUpApp which unloads, +** then attempts a load using the specified file name. +** +** In the event that an application cannot be reloaded due to ** a corrupt file, the application may no longer be reloaded when given a valid ** load file (it has been deleted and no longer exists). To recover, the -** application may be restarted by loading the application via the ES_STARTAPP +** application may be started by loading the application via the ES_STARTAPP ** command (#CFE_ES_START_APP_CC). ** ** \param[in] AppID Identifies the application to be reset. @@ -398,7 +443,7 @@ CFE_Status_t CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID); ** \sa #CFE_ES_RestartApp, #CFE_ES_DeleteApp, #CFE_ES_START_APP_CC ** ******************************************************************************/ -CFE_Status_t CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName); +CFE_Status_t CFE_ES_ReloadApp(CFE_ES_AppId_t AppID, const char *AppFileName); /*****************************************************************************/ /** @@ -417,7 +462,7 @@ CFE_Status_t CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName ** \sa #CFE_ES_RestartApp, #CFE_ES_ReloadApp ** ******************************************************************************/ -CFE_Status_t CFE_ES_DeleteApp(CFE_ES_ResourceID_t AppID); +CFE_Status_t CFE_ES_DeleteApp(CFE_ES_AppId_t AppID); /**@}*/ /** @defgroup CFEAPIESAppBehavior cFE Application Behavior APIs @@ -627,7 +672,7 @@ int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr); ** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName, #CFE_ES_GetTaskInfo ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr); +CFE_Status_t CFE_ES_GetAppID(CFE_ES_AppId_t *AppIdPtr); /*****************************************************************************/ /** @@ -650,7 +695,7 @@ CFE_Status_t CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr); ** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr); +CFE_Status_t CFE_ES_GetTaskID(CFE_ES_TaskId_t *TaskIdPtr); /*****************************************************************************/ /** @@ -675,7 +720,7 @@ CFE_Status_t CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr); ** \sa #CFE_ES_GetAppID, #CFE_ES_GetAppName, #CFE_ES_GetAppInfo ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName); +CFE_Status_t CFE_ES_GetAppIDByName(CFE_ES_AppId_t *AppIdPtr, const char *AppName); /*****************************************************************************/ /** @@ -700,7 +745,7 @@ CFE_Status_t CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *Ap ** \sa #CFE_ES_GetLibName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetLibIDByName(CFE_ES_ResourceID_t *LibIdPtr, const char *LibName); +CFE_Status_t CFE_ES_GetLibIDByName(CFE_ES_LibId_t *LibIdPtr, const char *LibName); /*****************************************************************************/ /** @@ -730,7 +775,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, size_t BufferLength); +CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_AppId_t AppId, size_t BufferLength); /*****************************************************************************/ /** @@ -760,7 +805,7 @@ CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t ** \sa #CFE_ES_GetLibIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, size_t BufferLength); +CFE_Status_t CFE_ES_GetLibName(char *LibName, CFE_ES_LibId_t LibId, size_t BufferLength); /*****************************************************************************/ /** @@ -787,7 +832,7 @@ CFE_Status_t CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, size_t ** \sa #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId); +CFE_Status_t CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_AppId_t AppId); /*****************************************************************************/ /** @@ -816,7 +861,7 @@ CFE_Status_t CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t Ap ** \sa #CFE_ES_GetTaskID, #CFE_ES_GetTaskIDByName, #CFE_ES_GetTaskName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId); +CFE_Status_t CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_TaskId_t TaskId); /*****************************************************************************/ /** @@ -849,7 +894,7 @@ CFE_Status_t CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t ** \sa #CFE_ES_GetLibIDByName, #CFE_ES_GetLibName ** ******************************************************************************/ -int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_ResourceID_t LibId); +int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_LibId_t LibId); /*****************************************************************************/ /** @@ -883,7 +928,7 @@ int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_ResourceID_t LibId); ** \sa #CFE_ES_GetLibInfo, #CFE_ES_GetAppInfo ** ******************************************************************************/ -int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ES_ResourceID_t ResourceId); +int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ResourceId_t ResourceId); /**@}*/ @@ -950,7 +995,7 @@ CFE_Status_t CFE_ES_RegisterChildTask(void); ** \sa #CFE_ES_RegisterChildTask, #CFE_ES_DeleteChildTask, #CFE_ES_ExitChildTask ** ******************************************************************************/ -CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, +CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, CFE_ES_StackPointer_t StackPtr, @@ -981,7 +1026,7 @@ CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, ** \sa #CFE_ES_GetTaskName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_ResourceID_t *TaskIdPtr, const char *TaskName); +CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName); /*****************************************************************************/ /** @@ -1011,7 +1056,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, size_t BufferLength); +CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_TaskId_t TaskId, size_t BufferLength); /*****************************************************************************/ /** @@ -1033,7 +1078,7 @@ CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, size ** \sa #CFE_ES_RegisterChildTask, #CFE_ES_CreateChildTask, #CFE_ES_ExitChildTask ** ******************************************************************************/ -CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId); +CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId); /*****************************************************************************/ /** @@ -1193,7 +1238,7 @@ CFE_Status_t CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, size_t BlockSize, ** \sa #CFE_ES_GetCDSBlockName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_ResourceID_t *BlockIdPtr, const char *BlockName); +CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_CDSHandle_t *BlockIdPtr, const char *BlockName); /*****************************************************************************/ /** @@ -1223,7 +1268,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, size_t BufferLength); +CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_CDSHandle_t BlockId, size_t BufferLength); /*****************************************************************************/ @@ -1600,7 +1645,7 @@ void CFE_ES_PerfLogAdd(uint32 Marker, uint32 EntryExit); ** \sa #CFE_ES_IncrementGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName); +CFE_Status_t CFE_ES_RegisterGenCounter(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName); /*****************************************************************************/ /** @@ -1621,7 +1666,7 @@ CFE_Status_t CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const ** \sa #CFE_ES_IncrementGenCounter, #CFE_ES_RegisterGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId); +CFE_Status_t CFE_ES_DeleteGenCounter(CFE_ES_CounterId_t CounterId); /*****************************************************************************/ /** @@ -1642,7 +1687,7 @@ CFE_Status_t CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId); ** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId); +CFE_Status_t CFE_ES_IncrementGenCounter(CFE_ES_CounterId_t CounterId); /*****************************************************************************/ /** @@ -1665,7 +1710,7 @@ CFE_Status_t CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId); ** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count); +CFE_Status_t CFE_ES_SetGenCount(CFE_ES_CounterId_t CounterId, uint32 Count); /*****************************************************************************/ /** @@ -1688,7 +1733,7 @@ CFE_Status_t CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count); ** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count); +CFE_Status_t CFE_ES_GetGenCount(CFE_ES_CounterId_t CounterId, uint32 *Count); /*****************************************************************************/ @@ -1712,7 +1757,7 @@ CFE_Status_t CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count); ** \sa #CFE_ES_GetGenCounterName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName); +CFE_Status_t CFE_ES_GetGenCounterIDByName(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName); /*****************************************************************************/ /** @@ -1742,7 +1787,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, size_t BufferLength); +CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_CounterId_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 d03927dad..36c2d1ee3 100644 --- a/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h +++ b/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h @@ -32,6 +32,7 @@ /* Use the local definitions of these types */ #include "common_types.h" +#include "cfe_resourceid_typedef.h" /** * @brief Label definitions associated with CFE_ES_LogMode_Enum_t @@ -330,23 +331,33 @@ enum CFE_ES_AppState typedef uint32 CFE_ES_AppState_Enum_t; +/** + * @brief A type for Application IDs + * + * This is the type that is used for any API accepting or returning an App ID + */ +typedef CFE_RESOURCEID_BASE_TYPE CFE_ES_AppId_t; /** - * @brief A type that provides a common, abstract identifier for - * all ES managed resources (e.g. apps, tasks, counters, etc). + * @brief A type for Task IDs * - * Fundamentally an unsigned integer but users should treat it as - * opaque, and only go through the ES API for introspection. + * This is the type that is used for any API accepting or returning a Task ID + */ +typedef CFE_RESOURCEID_BASE_TYPE CFE_ES_TaskId_t; + +/** + * @brief A type for Library IDs * - * Simple operations are provided as inline functions, which - * should alleviate the need to do direct manipulation of the value: + * This is the type that is used for any API accepting or returning a Lib ID + */ +typedef CFE_RESOURCEID_BASE_TYPE CFE_ES_LibId_t; + +/** + * @brief A type for Counter IDs * - * - Check for undefined ID value - * - Check for equality of two ID values - * - Convert ID to simple integer (typically for printing/logging) - * - Convert simple integer to ID (inverse of above) + * This is the type that is used for any API accepting or returning an Counter ID */ -typedef uint32 CFE_ES_ResourceID_t; +typedef CFE_RESOURCEID_BASE_TYPE CFE_ES_CounterId_t; /** * @brief Memory Handle type @@ -354,14 +365,14 @@ typedef uint32 CFE_ES_ResourceID_t; * Data type used to hold Handles of Memory Pools * created via CFE_ES_PoolCreate and CFE_ES_PoolCreateNoSem */ -typedef CFE_ES_ResourceID_t CFE_ES_MemHandle_t; +typedef CFE_RESOURCEID_BASE_TYPE CFE_ES_MemHandle_t; /** * @brief CDS Handle type * * Data type used to hold Handles of Critical Data Stores. See #CFE_ES_RegisterCDS */ -typedef CFE_ES_ResourceID_t CFE_ES_CDSHandle_t; +typedef CFE_RESOURCEID_BASE_TYPE CFE_ES_CDSHandle_t; /** * @brief Type used for task priority in CFE ES as diff --git a/fsw/cfe-core/src/inc/cfe_es_msg.h b/fsw/cfe-core/src/inc/cfe_es_msg.h index 7748b52df..83ba04c39 100644 --- a/fsw/cfe-core/src/inc/cfe_es_msg.h +++ b/fsw/cfe-core/src/inc/cfe_es_msg.h @@ -267,12 +267,15 @@ */ #define CFE_ES_STOP_APP_CC 5 -/** \cfeescmd Stops and Restarts an Application +/** \cfeescmd Stops, Unloads, Loads using the previous File name, and Restarts an Application ** ** \par Description -** This command halts and restarts the specified Application. -** This command does \b NOT reload the application from the onboard -** filesystem. +** This command halts and removes the specified Application +** from the system. Then it immediately loads the Application from +** the same filename last used to start. This command is +** especially useful for restarting a Command Ingest Application +** since once it has been stopped, no further commands can come in +** to restart it. ** ** \cfecmdmnemonic \ES_RESTARTAPP ** @@ -291,6 +294,7 @@ ** \par Error Conditions ** This command may fail for the following reason(s): ** - The command packet length is incorrect +** - The original file is missing ** - The specified application name is not recognized as an active application ** - The specified application is one of the cFE's Core applications (ES, EVS, SB, TBL, TIME) ** @@ -310,7 +314,7 @@ */ #define CFE_ES_RESTART_APP_CC 6 -/** \cfeescmd Stops, Unloads, Loads from a File and Restarts an Application +/** \cfeescmd Stops, Unloads, Loads from the command specfied File and Restarts an Application ** ** \par Description ** This command halts and removes the specified Application @@ -337,6 +341,7 @@ ** \par Error Conditions ** This command may fail for the following reason(s): ** - The command packet length is incorrect +** - The reload file is missing ** - The specified application name is not recognized as an active application ** - The specified application is one of the cFE's Core applications (ES, EVS, SB, TBL, TIME) ** @@ -1426,11 +1431,15 @@ typedef struct CFE_ES_DumpCDSRegistryCmd * * Structure that is used to provide information about an app. * It is primarily used for the QueryOne and QueryAll Commands. + * + * While this structure is primarily intended for Application info, + * it can also represent Library information where only a subset of + * the information applies. */ typedef struct CFE_ES_AppInfo { - CFE_ES_ResourceID_t AppId; /**< \cfetlmmnemonic \ES_APP_ID - \brief Application ID for this Application */ + CFE_ResourceId_t ResourceId; /**< \cfetlmmnemonic \ES_APP_ID + \brief Application or Library ID for this resource */ uint32 Type; /**< \cfetlmmnemonic \ES_APPTYPE \brief The type of App: CORE or EXTERNAL */ @@ -1464,7 +1473,7 @@ typedef struct CFE_ES_AppInfo (Restart Application OR Restart Processor) */ CFE_ES_TaskPriority_Atom_t Priority; /**< \cfetlmmnemonic \ES_PRIORITY \brief The Priority of the Application */ - CFE_ES_ResourceID_t MainTaskId; /**< \cfetlmmnemonic \ES_MAINTASKID + CFE_ES_TaskId_t MainTaskId; /**< \cfetlmmnemonic \ES_MAINTASKID \brief The Application's Main Task ID */ uint32 ExecutionCounter; /**< \cfetlmmnemonic \ES_MAINTASKEXECNT \brief The Application's Main Task Execution Counter */ @@ -1488,10 +1497,10 @@ typedef struct CFE_ES_AppInfo */ typedef struct CFE_ES_TaskInfo { - CFE_ES_ResourceID_t TaskId; /**< \brief Task Id */ + CFE_ES_TaskId_t TaskId; /**< \brief Task Id */ uint32 ExecutionCounter; /**< \brief Task Execution Counter */ char TaskName[CFE_MISSION_MAX_API_LEN]; /**< \brief Task Name */ - CFE_ES_ResourceID_t AppId; /**< \brief Parent Application ID */ + CFE_ES_AppId_t AppId; /**< \brief Parent Application ID */ char AppName[CFE_MISSION_MAX_API_LEN]; /**< \brief Parent Application Name */ } CFE_ES_TaskInfo_t; diff --git a/fsw/cfe-core/src/inc/cfe_evs.h b/fsw/cfe-core/src/inc/cfe_evs.h index 9b0a62517..104fc05d6 100644 --- a/fsw/cfe-core/src/inc/cfe_evs.h +++ b/fsw/cfe-core/src/inc/cfe_evs.h @@ -149,7 +149,7 @@ typedef struct CFE_EVS_BinFilter { ** \sa #CFE_EVS_Unregister ** **/ -CFE_Status_t CFE_EVS_Register (void *Filters, /* Pointer to an array of filters */ +CFE_Status_t CFE_EVS_Register (const void *Filters, /* Pointer to an array of filters */ uint16 NumFilteredEvents, /* How many elements in the array? */ uint16 FilterScheme); /* Filtering Algorithm to be implemented */ @@ -275,7 +275,7 @@ CFE_Status_t CFE_EVS_SendEvent (uint16 EventID, **/ CFE_Status_t CFE_EVS_SendEventWithAppID (uint16 EventID, uint16 EventType, - CFE_ES_ResourceID_t AppID, + CFE_ES_AppId_t AppID, const char *Spec, ... ) OS_PRINTF(4,5); diff --git a/fsw/cfe-core/src/inc/cfe_evs_events.h b/fsw/cfe-core/src/inc/cfe_evs_events.h index 2279154d2..5c3b0af93 100644 --- a/fsw/cfe-core/src/inc/cfe_evs_events.h +++ b/fsw/cfe-core/src/inc/cfe_evs_events.h @@ -541,12 +541,10 @@ ** \par Cause: ** ** This event message is generated upon receipt of a "Set Log Mode" -** command when the use of the Event Log has been disabled. To enable -** the Event Log, the cFE code must be compiled for the target with -** the \b CFE_PLATFORM_EVS_LOG_ON macro defined. The EVS task must also succeed -** during task initialization in acquiring a pointer to the cFE reset -** area and in the creation of a serializing semaphore to control -** access to the Event Log. +** command when the use of the Event Log has been disabled. The EVS task +** must succeed during task initialization in acquiring a pointer to +** the cFE reset area and in the creation of a serializing semaphore to +** control access to the Event Log. **/ #define CFE_EVS_NO_LOGSET_EID 34 @@ -558,12 +556,10 @@ ** \par Cause: ** ** This event message is generated upon receipt of a "Clear Log" -** command when the use of the Event Log has been disabled. To enable -** the Event Log, the cFE code must be compiled for the target with -** the \b CFE_PLATFORM_EVS_LOG_ON macro defined. The EVS task must also succeed -** during task initialization in acquiring a pointer to the cFE reset -** area and in the creation of a serializing semaphore to control -** access to the Event Log. +** command when the use of the Event Log has been disabled. The EVS task +** must succeed during task initialization in acquiring a pointer to +** the cFE reset area and in the creation of a serializing semaphore to +** control access to the Event Log. **/ #define CFE_EVS_NO_LOGCLR_EID 35 @@ -575,12 +571,10 @@ ** \par Cause: ** ** This event message is generated upon receipt of a "Write Log" -** command when the use of the Event Log has been disabled. To enable -** the Event Log, the cFE code must be compiled for the target with -** the \b CFE_PLATFORM_EVS_LOG_ON macro defined. The EVS task must also succeed -** during task initialization in acquiring a pointer to the cFE reset -** area and in the creation of a serializing semaphore to control -** access to the Event Log. +** command when the use of the Event Log has been disabled. The EVS task +** must succeed during task initialization in acquiring a pointer to +** the cFE reset area and in the creation of a serializing semaphore to +** control access to the Event Log. **/ #define CFE_EVS_NO_LOGWR_EID 36 diff --git a/fsw/cfe-core/src/inc/cfe_evs_msg.h b/fsw/cfe-core/src/inc/cfe_evs_msg.h index 5bbc90761..cfefb1514 100644 --- a/fsw/cfe-core/src/inc/cfe_evs_msg.h +++ b/fsw/cfe-core/src/inc/cfe_evs_msg.h @@ -1154,7 +1154,7 @@ typedef CFE_EVS_AppNameEventIDMaskCmd_t CFE_EVS_SetFilterCmd_t; /* Telemetry Message Data Formats */ /**********************************/ typedef struct CFE_EVS_AppTlmData { - CFE_ES_ResourceID_t AppID; /**< \cfetlmmnemonic \EVS_APPID + CFE_ES_AppId_t AppID; /**< \cfetlmmnemonic \EVS_APPID \brief Numerical application identifier */ uint16 AppMessageSentCounter; /**< \cfetlmmnemonic \EVS_APPMSGSENTC \brief Application message sent counter */ diff --git a/fsw/cfe-core/src/inc/cfe_fs_extern_typedefs.h b/fsw/cfe-core/src/inc/cfe_fs_extern_typedefs.h index 5a5765942..55c539e6e 100644 --- a/fsw/cfe-core/src/inc/cfe_fs_extern_typedefs.h +++ b/fsw/cfe-core/src/inc/cfe_fs_extern_typedefs.h @@ -167,7 +167,7 @@ enum CFE_FS_SubType * * * Software Bus Pipe Data Dump File which is generated in response to a - * \link #CFE_SB_SEND_PIPE_INFO_CC \SB_WRITEPIPE2FILE \endlink + * \link #CFE_SB_WRITE_PIPE_INFO_CC \SB_WRITEPIPE2FILE \endlink * command. * */ @@ -178,7 +178,7 @@ enum CFE_FS_SubType * * * Software Bus Message Routing Data Dump File which is generated in response to a - * \link #CFE_SB_SEND_ROUTING_INFO_CC \SB_WRITEROUTING2FILE \endlink + * \link #CFE_SB_WRITE_ROUTING_INFO_CC \SB_WRITEROUTING2FILE \endlink * command. * */ @@ -189,7 +189,7 @@ enum CFE_FS_SubType * * * Software Bus Message Mapping Data Dump File which is generated in response to a - * \link #CFE_SB_SEND_MAP_INFO_CC \SB_WRITEMAP2FILE \endlink + * \link #CFE_SB_WRITE_MAP_INFO_CC \SB_WRITEMAP2FILE \endlink * command. * */ diff --git a/fsw/cfe-core/src/inc/cfe_resourceid.h b/fsw/cfe-core/src/inc/cfe_resourceid.h deleted file mode 100644 index 199554539..000000000 --- a/fsw/cfe-core/src/inc/cfe_resourceid.h +++ /dev/null @@ -1,150 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/** - * \file cfe_resourceid.h - * - * Contains global prototypes and definitions related to resource - * management and related CFE resource IDs. - * - * A CFE ES Resource ID is a common way to identify CFE-managed resources such - * as apps, tasks, counters, memory pools, CDS blocks, and other entities. - */ - -#ifndef CFE_RESOURCEID_H -#define CFE_RESOURCEID_H - -/* -** Include Files -** -** The actual CFE_ES_ResourceID_t type is part of the ES global/extern typedefs, -** as the concept originated in ES and has been extended across all of CFE. -*/ -#include "cfe_es_extern_typedefs.h" - -/* -** Defines -*/ - -/** \name Resource ID predefined values */ -/** \{ */ - -/** - * @brief A resource ID value that represents an undefined/unused resource - * - * This constant may be used to initialize local variables of the - * CFE_ES_ResourceID_t type to a safe value that will not alias a valid ID. - * - * By design, this value is also the result of zeroing a CFE_ES_ResourceID_t - * type via standard functions like memset(), such that objects initialized - * using this method will also be set to safe values. - */ -#define CFE_ES_RESOURCEID_UNDEFINED ((CFE_ES_ResourceID_t){0}) - -/** - * @brief A resource ID value that represents a reserved entry - * - * This is not a valid value for any resource type, but is used to mark - * table entries that are not available for use. For instance, this may - * be used while setting up an entry initially. - */ -#define CFE_ES_RESOURCEID_RESERVED ((CFE_ES_ResourceID_t){0xFFFFFFFF}) - -/** \} */ - - -/** - * @brief Convert a resource ID to an integer. - * - * This is primarily intended for logging purposes, such was writing - * to debug console, event messages, or log files, using printf-like APIs. - * - * For compatibility with C library APIs, this returns an "unsigned long" - * type and should be used with the "%lx" format specifier in a printf - * format string. - * - * @note No assumptions should be made about the actual integer value, - * such as its base/range. It may be printed, but should not be modified - * or tested/compared using other arithmetic ops, and should never be used - * as the index to an array or table. See the related function - * CFE_ES_ResourceID_ToIndex() for cases where a zero-based array/table index - * is needed. - * - * @sa CFE_ES_ResourceID_FromInteger() - * - * @param[in] id Resource ID to convert - * @returns Integer value corresponding to ID - */ -static inline unsigned long CFE_ES_ResourceID_ToInteger(CFE_ES_ResourceID_t id) -{ - return ((unsigned long)id); -} - -/** - * @brief Convert an integer to a resource ID. - * - * This is the inverse of CFE_ES_ResourceID_ToInteger(), and reconstitutes - * the original CFE_ES_ResourceID_t value from the integer representation. - * - * This may be used, for instance, where an ID value is parsed from a text - * file or message using C library APIs such as scanf() or strtoul(). - * - * @sa CFE_ES_ResourceID_ToInteger() - * - * @param[in] Value Integer value to convert - * @returns ID value corresponding to integer - */ -static inline CFE_ES_ResourceID_t CFE_ES_ResourceID_FromInteger(unsigned long Value) -{ - return ((CFE_ES_ResourceID_t)Value); -} - -/** - * @brief Compare two Resource ID values for equality - * - * @param[in] id1 Resource ID to check - * @param[in] id2 Resource ID to check - * @returns true if id1 and id2 are equal, false otherwise. - */ -static inline bool CFE_ES_ResourceID_Equal(CFE_ES_ResourceID_t id1, CFE_ES_ResourceID_t id2) -{ - return (id1 == id2); -} - -/** - * @brief Check if a resource ID value is defined - * - * The constant #CFE_ES_RESOURCEID_UNDEFINED represents an undefined ID value, - * such that the expression: - * - * CFE_ES_ResourceID_IsDefined(CFE_ES_RESOURCEID_UNDEFINED) - * - * Always returns false. - * - * @param[in] id Resource ID to check - * @returns True if the ID may refer to a defined entity, false if invalid/undefined. - */ -static inline bool CFE_ES_ResourceID_IsDefined(CFE_ES_ResourceID_t id) -{ - return (id != 0); -} - - -#endif /* CFE_RESOURCEID_H */ diff --git a/fsw/cfe-core/src/inc/cfe_resourceid_api.h b/fsw/cfe-core/src/inc/cfe_resourceid_api.h new file mode 100644 index 000000000..6a1ef4d18 --- /dev/null +++ b/fsw/cfe-core/src/inc/cfe_resourceid_api.h @@ -0,0 +1,257 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * \file cfe_resourceid_api.h + * + * Contains global prototypes and definitions related to resource + * management and related CFE resource IDs. + * + * A CFE ES Resource ID is a common way to identify CFE-managed resources such + * as apps, tasks, counters, memory pools, CDS blocks, and other entities. + * + * Simple operations are provided as inline functions, which + * should alleviate the need to do direct manipulation of resource IDs: + * + * - Check for undefined ID value + * - Check for equality of two ID values + * - Convert ID to simple integer (typically for printing/logging) + * - Convert simple integer to ID (inverse of above) + */ + +#ifndef CFE_RESOURCEID_API_H +#define CFE_RESOURCEID_API_H + +/* + * The basic resource ID typedef + * + * This is provided via the external resourceid library + * and may be customized by the user/mission preferences. + */ +#include "cfe_resourceid_typedef.h" + +/* +** Defines +*/ + +/** \name Resource ID predefined values */ +/** \{ */ + + +/** + * @brief A resource ID value that represents an undefined/unused resource + * + * This constant may be used to initialize local variables of the + * CFE_ResourceId_t type to a safe value that will not alias a valid ID. + * + * By design, this value is also the result of zeroing a CFE_ResourceId_t + * type via standard functions like memset(), such that objects initialized + * using this method will also be set to safe values. + */ +#define CFE_RESOURCEID_UNDEFINED ((CFE_ResourceId_t) CFE_RESOURCEID_WRAP(0)) + +/** + * @brief A resource ID value that represents a reserved entry + * + * This is not a valid value for any resource type, but is used to mark + * table entries that are not available for use. For instance, this may + * be used while setting up an entry initially. + */ +#define CFE_RESOURCEID_RESERVED ((CFE_ResourceId_t) CFE_RESOURCEID_WRAP(0xFFFFFFFF)) + +/** \} */ + +/** \name Resource ID test/conversion macros and inline functions */ +/** \{ */ + + +/** + * \brief Convert a derived (app-specific) ID directly into an "unsigned long" + * + * This generic routine is implemented as a macro so it is agnostic to the actual argument type, + * and it will evaluate correctly so long as the argument type is based on the CFE_RESOURCEID_BASE_TYPE. + * + * There is no inverse of this macro, as it depends on the actual derived type desired. + * Applications needing to recreate an ID from an integer should use CFE_ResourceId_FromInteger() + * combined with a cast/conversion to the correct/intended derived type, as needed. + * + * \note This evaluates as an "unsigned long" such that it can be used in + * printf()-style functions with the "%lx" modifier without extra casting, + * as this is the most typical use-case for representing an ID as an integer. + */ +#define CFE_RESOURCEID_TO_ULONG(id) CFE_ResourceId_ToInteger(CFE_RESOURCEID_UNWRAP(id)) + +/** + * \brief Determine if a derived (app-specific) ID is defined or not + * + * This generic routine is implemented as a macro so it is agnostic to the actual argument type, + * and it will evaluate correctly so long as the argument type is based on the CFE_RESOURCEID_BASE_TYPE. + */ +#define CFE_RESOURCEID_TEST_DEFINED(id) CFE_ResourceId_IsDefined(CFE_RESOURCEID_UNWRAP(id)) + +/** + * \brief Determine if two derived (app-specific) IDs are equal + * + * This generic routine is implemented as a macro so it is agnostic to the actual argument type, + * and it will evaluate correctly so long as the argument type is based on the CFE_RESOURCEID_BASE_TYPE. + */ +#define CFE_RESOURCEID_TEST_EQUAL(id1,id2) CFE_ResourceId_Equal(CFE_RESOURCEID_UNWRAP(id1), CFE_RESOURCEID_UNWRAP(id2)) + +/** + * @brief Convert a resource ID to an integer. + * + * This is primarily intended for logging purposes, such was writing + * to debug console, event messages, or log files, using printf-like APIs. + * + * For compatibility with C library APIs, this returns an "unsigned long" + * type and should be used with the "%lx" format specifier in a printf + * format string. + * + * @note No assumptions should be made about the actual integer value, + * such as its base/range. It may be printed, but should not be modified + * or tested/compared using other arithmetic ops, and should never be used + * as the index to an array or table. See the related function + * CFE_ResourceId_ToIndex() for cases where a zero-based array/table index + * is needed. + * + * @sa CFE_ResourceId_FromInteger() + * + * @param[in] id Resource ID to convert + * @returns Integer value corresponding to ID + */ +static inline unsigned long CFE_ResourceId_ToInteger(CFE_ResourceId_t id) +{ + return ((unsigned long)CFE_RESOURCEID_UNWRAP(id)); +} + +/** + * @brief Convert an integer to a resource ID. + * + * This is the inverse of CFE_ResourceId_ToInteger(), and reconstitutes + * the original CFE_ResourceId_t value from the integer representation. + * + * This may be used, for instance, where an ID value is parsed from a text + * file or message using C library APIs such as scanf() or strtoul(). + * + * @sa CFE_ResourceId_ToInteger() + * + * @param[in] Value Integer value to convert + * @returns ID value corresponding to integer + */ +static inline CFE_ResourceId_t CFE_ResourceId_FromInteger(unsigned long Value) +{ + return ((CFE_ResourceId_t)CFE_RESOURCEID_WRAP(Value)); +} + +/** + * @brief Compare two Resource ID values for equality + * + * @param[in] id1 Resource ID to check + * @param[in] id2 Resource ID to check + * @returns true if id1 and id2 are equal, false otherwise. + */ +static inline bool CFE_ResourceId_Equal(CFE_ResourceId_t id1, CFE_ResourceId_t id2) +{ + return (CFE_RESOURCEID_UNWRAP(id1) == CFE_RESOURCEID_UNWRAP(id2)); +} + +/** + * @brief Check if a resource ID value is defined + * + * The constant #CFE_RESOURCEID_UNDEFINED represents an undefined ID value, + * such that the expression: + * + * CFE_ResourceId_IsDefined(CFE_RESOURCEID_UNDEFINED) + * + * Always returns false. + * + * @param[in] id Resource ID to check + * @returns True if the ID may refer to a defined entity, false if invalid/undefined. + */ +static inline bool CFE_ResourceId_IsDefined(CFE_ResourceId_t id) +{ + return (CFE_RESOURCEID_UNWRAP(id) != 0); +} + +/** \} */ + + +/* + * Non-inline API functions provided by the Resource ID module + */ + +/** + * @brief Get the Base value (type/category) from a resource ID value + * + * This masks out the ID serial number to obtain the base value, which is different + * for each resource type. + * + * @note The value is NOT shifted or otherwise adjusted. + * + * @param[in] ResourceId the resource ID to decode + * @returns The base value associated with that ID + */ +extern uint32 CFE_ResourceId_GetBase(CFE_ResourceId_t ResourceId); + +/** + * @brief Get the Serial Number (sequential ID) from a resource ID value + * + * This masks out the ID base value to obtain the serial number, which is different + * for each entity created. + * + * @param[in] ResourceId the resource ID to decode + * @returns The serial number associated with that ID + */ +extern uint32 CFE_ResourceId_GetSerial(CFE_ResourceId_t ResourceId); + + +/** + * @brief Locate the next resource ID which does not map to an in-use table entry + * + * This begins searching from StartId which should be the most recently issued ID + * for the resource category. This will then search for the next ID which does + * _not_ map to a table entry that is in use. That is, it does not alias any + * valid ID when converted to an array index. + * + * returns an undefined ID value if no open slots are available + * + * @param[in] StartId the last issued ID for the resource category (app, lib, etc). + * @param[in] TableSize the maximum size of the target table + * @param[in] CheckFunc a function to check if the given ID is available + * @returns Next ID value which does not map to a valid entry + * @retval #CFE_RESOURCEID_UNDEFINED if no open slots. + * + */ +extern CFE_ResourceId_t CFE_ResourceId_FindNext(CFE_ResourceId_t StartId, uint32 TableSize, bool (*CheckFunc)(CFE_ResourceId_t) ); + +/** + * @brief Internal routine to aid in converting an ES resource ID to an array index + + * @param[in] Id The resource ID + * @param[in] BaseValue The respective ID base value corresponding to the ID type + * @param[in] TableSize The actual size of the internal table (MAX index value + 1) + * @param[out] Idx The output index + * @returns Status code, CFE_SUCCESS if successful. + */ +extern int32 CFE_ResourceId_ToIndex(CFE_ResourceId_t Id, uint32 BaseValue, uint32 TableSize, uint32 *Idx); + + + +#endif /* CFE_RESOURCEID_H */ diff --git a/fsw/cfe-core/src/inc/cfe_sb.h b/fsw/cfe-core/src/inc/cfe_sb.h index e5073b506..88749ee8a 100644 --- a/fsw/cfe-core/src/inc/cfe_sb.h +++ b/fsw/cfe-core/src/inc/cfe_sb.h @@ -43,7 +43,6 @@ #include "cfe_mission_cfg.h" #include "ccsds.h" #include "cfe_time.h" -#include "cfe_resourceid.h" /* @@ -123,12 +122,18 @@ #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 Cast/Convert a generic CFE_ResourceId_t to a CFE_SB_PipeId_t + */ +#define CFE_SB_PIPEID_C(val) ((CFE_SB_PipeId_t)CFE_RESOURCEID_WRAP(val)) + + /** * \brief A CFE_SB_PipeId_t value which is always invalid * * This may be used as a safe initializer for CFE_SB_PipeId_t values */ -#define CFE_SB_INVALID_PIPE CFE_ES_RESOURCEID_UNDEFINED +#define CFE_SB_INVALID_PIPE CFE_SB_PIPEID_C(CFE_RESOURCEID_UNDEFINED) /* ** Pipe option bit fields. @@ -160,12 +165,6 @@ typedef CFE_MSG_TelemetryHeader_t CFE_SB_TlmHdr_t; #define CFE_SB_TLM_HDR_SIZE (sizeof(CFE_MSG_TelemetryHeader_t))/**< \brief Size of telemetry header */ #endif /* CFE_OMIT_DEPRECATED_6_8 */ -/** \brief CFE_SB_PipeId_t to primitive type definition -** -** Software Bus pipe identifier used in many SB APIs -*/ -typedef CFE_ES_ResourceID_t CFE_SB_PipeId_t; - #ifndef CFE_OMIT_DEPRECATED_6_8 /** \brief Pointer to an SB Message */ typedef CFE_MSG_Message_t *CFE_SB_MsgPtr_t; @@ -190,8 +189,10 @@ typedef struct { uint8 Reliability;/**< \brief Specify high(1) or low(0) message transfer reliability for off-board routing, currently unused */ }CFE_SB_Qos_t; -extern CFE_SB_Qos_t CFE_SB_Default_Qos;/**< \brief Defines a default priority and reliabilty for off-board routing */ - +#define CFE_SB_DEFAULT_QOS ((CFE_SB_Qos_t) {0}) /**< \brief Default Qos macro */ +#ifndef CFE_OMIT_DEPRECATED_6_8 +#define CFE_SB_Default_Qos CFE_SB_DEFAULT_QOS /**< \deprecated use CFE_SB_DEFAULT_QOS */ +#endif /****************** Function Prototypes **********************/ @@ -397,7 +398,7 @@ CFE_Status_t CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *Pip ** should be sent to. ** ** \param[in] Quality The requested Quality of Service (QoS) required of -** the messages. Most callers will use #CFE_SB_Default_Qos +** the messages. Most callers will use #CFE_SB_DEFAULT_QOS ** for this parameter. ** ** \param[in] MsgLim The maximum number of messages with this Message ID to @@ -421,7 +422,7 @@ CFE_Status_t CFE_SB_SubscribeEx(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, C ** \par Description ** This routine adds the specified pipe to the destination list for ** the specified message ID. This is the same as #CFE_SB_SubscribeEx -** with the Quality field set to #CFE_SB_Default_Qos and MsgLim set +** with the Quality field set to #CFE_SB_DEFAULT_QOS and MsgLim set ** to #CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT (4). ** ** \par Assumptions, External Events, and Notes: @@ -456,7 +457,7 @@ CFE_Status_t CFE_SB_Subscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); ** \par Description ** This routine adds the specified pipe to the destination list for ** the specified message ID. This is similar to #CFE_SB_SubscribeEx -** with the Quality field set to #CFE_SB_Default_Qos and MsgLim set +** with the Quality field set to #CFE_SB_DEFAULT_QOS and MsgLim set ** to #CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT, but will not report the subscription. ** Subscription Reporting is enabled for interprocessor communication ** by way of the Software Bus Network (SBN) Application. diff --git a/fsw/cfe-core/src/inc/cfe_sb_events.h b/fsw/cfe-core/src/inc/cfe_sb_events.h index 87ac2798c..a9669fb83 100644 --- a/fsw/cfe-core/src/inc/cfe_sb_events.h +++ b/fsw/cfe-core/src/inc/cfe_sb_events.h @@ -70,7 +70,7 @@ ** ** This error event message is issued when the #CFE_SB_CreatePipe API receives a bad ** argument. In this case, a bad argument is defined by the following: -** A NULL PipeIdPtr, PipeDepth = 0 and PipeDepth > cfg param #CFE_PLATFORM_SB_MAX_PIPE_DEPTH +** A NULL PipeIdPtr, PipeDepth = 0 and PipeDepth > maximum pipe depth **/ #define CFE_SB_CR_PIPE_BAD_ARG_EID 2 diff --git a/fsw/cfe-core/src/inc/cfe_sb_extern_typedefs.h b/fsw/cfe-core/src/inc/cfe_sb_extern_typedefs.h index 8eaea63e7..ae0b7fb3a 100644 --- a/fsw/cfe-core/src/inc/cfe_sb_extern_typedefs.h +++ b/fsw/cfe-core/src/inc/cfe_sb_extern_typedefs.h @@ -33,6 +33,7 @@ #include "common_types.h" #include "cfe_mission_cfg.h" +#include "cfe_resourceid_typedef.h" /** * @brief Label definitions associated with CFE_SB_QosPriority_Enum_t @@ -111,6 +112,14 @@ typedef uint32 CFE_SB_MsgId_Atom_t; */ typedef CFE_SB_MsgId_Atom_t CFE_SB_MsgId_t; +/** \brief CFE_SB_PipeId_t to primitive type definition + * + * Software Bus pipe identifier used in many SB APIs, as well as SB Telemetry messages + * and data files. + */ +typedef CFE_RESOURCEID_BASE_TYPE CFE_SB_PipeId_t; + + #endif /* CFE_EDS_ENABLED_BUILD */ #endif /* _CFE_SB_EXTERN_TYPEDEFS_H_ */ diff --git a/fsw/cfe-core/src/inc/cfe_sb_msg.h b/fsw/cfe-core/src/inc/cfe_sb_msg.h index 953f8b4a5..a9ed6f0e5 100644 --- a/fsw/cfe-core/src/inc/cfe_sb_msg.h +++ b/fsw/cfe-core/src/inc/cfe_sb_msg.h @@ -164,7 +164,7 @@ ** \cfecmdmnemonic \SB_WRITEROUTING2FILE ** ** \par Command Structure -** #CFE_SB_SendRoutingInfoCmd_t +** #CFE_SB_WriteRoutingInfoCmd_t ** ** \par Command Verification ** Successful execution of this command may be verified with the @@ -188,10 +188,8 @@ ** This command is not inherently dangerous. It will create a new ** file in the file system and could, if performed repeatedly without ** sufficient file management by the operator, fill the file system. -** -** \sa #CFE_SB_SEND_PIPE_INFO_CC, #CFE_SB_SEND_MAP_INFO_CC, #CFE_SB_WriteFileInfoCmd_t */ -#define CFE_SB_SEND_ROUTING_INFO_CC 3 +#define CFE_SB_WRITE_ROUTING_INFO_CC 3 /** \cfesbcmd Enable Software Bus Route ** @@ -211,7 +209,7 @@ ** Successful execution of this command may be verified with the ** following telemetry: ** - \b \c \SB_CMDPC - command execution counter will increment -** - View routing information #CFE_SB_SEND_ROUTING_INFO_CC to verify +** - View routing information #CFE_SB_WRITE_ROUTING_INFO_CC to verify ** enable/disable state change ** - The #CFE_SB_ENBL_RTE2_EID debug event message will be generated. All ** debug events are filtered by default. @@ -228,8 +226,6 @@ ** ** \par Criticality ** This command is not inherently dangerous. -** -** \sa #CFE_SB_SEND_ROUTING_INFO_CC, #CFE_SB_DISABLE_ROUTE_CC, #CFE_SB_RouteCmd_t */ #define CFE_SB_ENABLE_ROUTE_CC 4 @@ -249,7 +245,7 @@ ** Successful execution of this command may be verified with the ** following telemetry: ** - \b \c \SB_CMDPC - command execution counter will increment -** - View routing information #CFE_SB_SEND_ROUTING_INFO_CC to verify +** - View routing information #CFE_SB_WRITE_ROUTING_INFO_CC to verify ** enable/disable state change ** - The #CFE_SB_DSBL_RTE2_EID debug event message will be generated. All ** debug events are filtered by default. @@ -271,8 +267,6 @@ ** with #CFE_SB_CMD_MID and the SB_Cmd_Pipe would inhibit any ground ** commanding to the software bus until the processor was reset. There ** are similar problems that may occur when using this command. -** -** \sa #CFE_SB_SEND_ROUTING_INFO_CC, #CFE_SB_ENABLE_ROUTE_CC, #CFE_SB_RouteCmd_t */ #define CFE_SB_DISABLE_ROUTE_CC 5 @@ -291,7 +285,7 @@ ** \cfecmdmnemonic \SB_WRITEPIPE2FILE ** ** \par Command Structure -** #CFE_SB_SendPipeInfoCmd_t +** #CFE_SB_WritePipeInfoCmd_t ** ** \par Command Verification ** Successful execution of this command may be verified with the @@ -315,10 +309,8 @@ ** This command is not inherently dangerous. It will create a new ** file in the file system and could, if performed repeatedly without ** sufficient file management by the operator, fill the file system. -** -** \sa #CFE_SB_SEND_ROUTING_INFO_CC, #CFE_SB_SEND_MAP_INFO_CC */ -#define CFE_SB_SEND_PIPE_INFO_CC 7 +#define CFE_SB_WRITE_PIPE_INFO_CC 7 /** \cfesbcmd Write Map Info to a File ** @@ -336,7 +328,7 @@ ** \cfecmdmnemonic \SB_WRITEMAP2FILE ** ** \par Command Structure -** #CFE_SB_SendMapInfoCmd_t +** #CFE_SB_WriteMapInfoCmd_t ** ** \par Command Verification ** Successful execution of this command may be verified with the @@ -360,10 +352,8 @@ ** This command is not inherently dangerous. It will create a new ** file in the file system and could, if performed repeatedly without ** sufficient file management by the operator, fill the file system. -** -** \sa #CFE_SB_SEND_ROUTING_INFO_CC, #CFE_SB_SEND_PIPE_INFO_CC */ -#define CFE_SB_SEND_MAP_INFO_CC 8 +#define CFE_SB_WRITE_MAP_INFO_CC 8 /** \cfesbcmd Enable Subscription Reporting Command ** @@ -486,10 +476,7 @@ typedef CFE_MSG_CommandHeader_t CFE_SB_SendPrevSubsCmd_t; /** ** \brief Write File Info Command Payload ** -** This structure contains a generic definition used by three SB commands, -** 'Write Routing Info to File' #CFE_SB_SEND_ROUTING_INFO_CC, -** 'Write Pipe Info to File' #CFE_SB_SEND_PIPE_INFO_CC and -** 'Write Map Info to File' #CFE_SB_SEND_MAP_INFO_CC. +** This structure contains a generic definition used by SB commands that write to a file */ typedef struct CFE_SB_WriteFileInfoCmd_Payload { char Filename[CFE_MISSION_MAX_PATH_LEN];/**< \brief Path and Filename of data to be loaded */ @@ -506,9 +493,9 @@ typedef struct CFE_SB_WriteFileInfoCmd { /* * Create a unique typedef for each of the commands that share this format. */ -typedef CFE_SB_WriteFileInfoCmd_t CFE_SB_SendRoutingInfoCmd_t; -typedef CFE_SB_WriteFileInfoCmd_t CFE_SB_SendPipeInfoCmd_t; -typedef CFE_SB_WriteFileInfoCmd_t CFE_SB_SendMapInfoCmd_t; +typedef CFE_SB_WriteFileInfoCmd_t CFE_SB_WriteRoutingInfoCmd_t; +typedef CFE_SB_WriteFileInfoCmd_t CFE_SB_WritePipeInfoCmd_t; +typedef CFE_SB_WriteFileInfoCmd_t CFE_SB_WriteMapInfoCmd_t; /** ** \brief Enable/Disable Route Command Payload @@ -633,7 +620,7 @@ typedef struct CFE_SB_PipeDepthStats { typedef struct CFE_SB_PipeInfoEntry { CFE_SB_PipeId_t PipeId; /**< The runtime ID of the pipe */ - CFE_ES_ResourceID_t AppId; /**< The runtime ID of the application that owns the pipe */ + CFE_ES_AppId_t AppId; /**< The runtime ID of the application that owns the pipe */ char PipeName[CFE_MISSION_MAX_API_LEN]; /**< The Name of the pipe */ char AppName[CFE_MISSION_MAX_API_LEN]; /**< The Name of the application that owns the pipe */ uint16 MaxQueueDepth; /**< The allocated depth of the pipe (max capacity) */ @@ -687,7 +674,7 @@ typedef struct CFE_SB_StatsTlm_Payload { \brief Max number of SB message buffers in use */ uint32 MaxPipeDepthAllowed;/**< \cfetlmmnemonic \SB_SMMPDALW - \brief cFE Cfg Param \link #CFE_PLATFORM_SB_MAX_PIPE_DEPTH \endlink */ + \brief Maximum allowed pipe depth */ CFE_SB_PipeDepthStats_t PipeDepthStats[CFE_MISSION_SB_MAX_PIPES];/**< \cfetlmmnemonic \SB_SMPDS \brief Pipe Depth Statistics #CFE_SB_PipeDepthStats_t*/ } CFE_SB_StatsTlm_Payload_t; @@ -701,7 +688,7 @@ typedef struct CFE_SB_StatsTlm { /** ** \brief SB Routing File Entry ** -** Structure of one element of the routing information in response to #CFE_SB_SEND_ROUTING_INFO_CC +** Structure of one element of the routing information in response to #CFE_SB_WRITE_ROUTING_INFO_CC */ typedef struct CFE_SB_RoutingFileEntry { CFE_SB_MsgId_t MsgId;/**< \brief Message Id portion of the route */ @@ -716,7 +703,7 @@ typedef struct CFE_SB_RoutingFileEntry { /** ** \brief SB Map File Entry ** -** Structure of one element of the map information in response to #CFE_SB_SEND_MAP_INFO_CC +** Structure of one element of the map information in response to #CFE_SB_WRITE_MAP_INFO_CC */ typedef struct CFE_SB_MsgMapFileEntry { CFE_SB_MsgId_t MsgId;/**< \brief Message Id which has been subscribed to */ diff --git a/fsw/cfe-core/src/inc/cfe_version.h b/fsw/cfe-core/src/inc/cfe_version.h index 7eafd003c..f7bd98e01 100644 --- a/fsw/cfe-core/src/inc/cfe_version.h +++ b/fsw/cfe-core/src/inc/cfe_version.h @@ -35,7 +35,7 @@ /* Development Build Macro Definitions */ -#define CFE_BUILD_NUMBER 290 /*!< Development Build: Number of commits since baseline */ +#define CFE_BUILD_NUMBER 348 /*!< Development Build: Number of commits since baseline */ #define CFE_BUILD_BASELINE "v6.8.0-rc1" /*!< Development Build: git tag that is the base for the current development */ /* Version Macro Definitions */ diff --git a/fsw/cfe-core/src/inc/private/cfe_core_resourceid_basevalues.h b/fsw/cfe-core/src/inc/private/cfe_core_resourceid_basevalues.h new file mode 100644 index 000000000..5a5e6527f --- /dev/null +++ b/fsw/cfe-core/src/inc/private/cfe_core_resourceid_basevalues.h @@ -0,0 +1,97 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * \file cfe_core_resourceid_basevalues.h + * + * Contains CFE internal prototypes and definitions related to resource + * management and related CFE resource IDs. + * + * A CFE ES Resource ID is a common way to identify CFE-managed resources such + * as apps, tasks, counters, memory pools, CDS blocks, and other entities. + */ + +#ifndef CFE_CORE_RESOURCEID_BASEVALUES_H +#define CFE_CORE_RESOURCEID_BASEVALUES_H + +/* +** Include Files +*/ +#include "cfe_resourceid_basevalue.h" + +/** @defgroup CFEESResourceIDBase cFE Resource ID base values + * @{ + */ + + +/* + * Assign unique offsets per resource types used in CFE core apps. + * + * Applications should not use these values directly, but rather + * in conjuction with the CFE_RESOURCEID_MAKE_BASE macro provided + * by the Resource ID module. (see below) + */ +enum +{ + /* + * Note for Task ID base value -- + * This currently shares the same offset as OSAL tasks, such that + * when "simple" (non-enforcing/backward-compatible) IDs are selected, + * the CFE task IDs and the OSAL task IDs end up as the same value. + * + * The "CFE_RESOURCEID_MARK" bit still differentiates the value when + * in strict mode, so there is no overlap in that case. + */ + CFE_RESOURCEID_ES_TASKID_BASE_OFFSET = OS_OBJECT_TYPE_OS_TASK, + + /* Other ES managed resources */ + CFE_RESOURCEID_ES_APPID_BASE_OFFSET = OS_OBJECT_TYPE_USER + 1, + CFE_RESOURCEID_ES_LIBID_BASE_OFFSET = OS_OBJECT_TYPE_USER + 2, + CFE_RESOURCEID_ES_COUNTID_BASE_OFFSET = OS_OBJECT_TYPE_USER + 3, + CFE_RESOURCEID_ES_POOLID_BASE_OFFSET = OS_OBJECT_TYPE_USER + 4, + CFE_RESOURCEID_ES_CDSBLOCKID_BASE_OFFSET = OS_OBJECT_TYPE_USER + 5, + + /* SB managed resources */ + CFE_RESOURCEID_SB_PIPEID_RESOURCE_BASE_OFFSET = OS_OBJECT_TYPE_USER + 6 +}; + +/* + * Assign actual base values from the offsets above + * + * Using "enum" ensures these are resolved as integers now, as opposed at to the point of use like macros. + */ +enum +{ + /* ES managed resources */ + CFE_ES_TASKID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_ES_TASKID_BASE_OFFSET), + CFE_ES_APPID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_ES_APPID_BASE_OFFSET), + CFE_ES_LIBID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_ES_LIBID_BASE_OFFSET), + CFE_ES_COUNTID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_ES_COUNTID_BASE_OFFSET), + CFE_ES_POOLID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_ES_POOLID_BASE_OFFSET), + CFE_ES_CDSBLOCKID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_ES_CDSBLOCKID_BASE_OFFSET), + + /* SB managed resources */ + CFE_SB_PIPEID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_SB_PIPEID_RESOURCE_BASE_OFFSET) +}; + +/** @} */ + + +#endif /* CFE_CORE_RESOURCEID_BASEVALUES_H */ diff --git a/fsw/cfe-core/src/inc/private/cfe_es_erlog_typedef.h b/fsw/cfe-core/src/inc/private/cfe_es_erlog_typedef.h index c2bcfe8a5..a2193ae5c 100644 --- a/fsw/cfe-core/src/inc/private/cfe_es_erlog_typedef.h +++ b/fsw/cfe-core/src/inc/private/cfe_es_erlog_typedef.h @@ -93,7 +93,7 @@ typedef struct typedef struct { CFE_ES_ERLog_BaseInfo_t BaseInfo; /**< Core Log Data */ - CFE_ES_ResourceID_t AppID; /* The application ID */ + CFE_ES_AppId_t AppID; /* The application ID */ uint32 PspContextId; /**< Reference to context information stored in PSP */ } CFE_ES_ERLog_MetaData_t; diff --git a/fsw/cfe-core/src/inc/private/cfe_es_resetdata_typedef.h b/fsw/cfe-core/src/inc/private/cfe_es_resetdata_typedef.h index aec73b459..2c59613e0 100644 --- a/fsw/cfe-core/src/inc/private/cfe_es_resetdata_typedef.h +++ b/fsw/cfe-core/src/inc/private/cfe_es_resetdata_typedef.h @@ -37,7 +37,7 @@ #include "cfe_es_erlog_typedef.h" /* Required for CFE_ES_ERLog_t definition */ #include "cfe_es_perfdata_typedef.h" /* Required for CFE_ES_PerfData_t definition */ #include "cfe_evs_log_typedef.h" /* Required for CFE_EVS_Log_t definition */ -#include "cfe_platform_cfg.h" /* CFE_PLATFORM_EVS_LOG_ON, CFE_PLATFORM_ES_ER_LOG_ENTRIES, CFE_PLATFORM_ES_SYSTEM_LOG_SIZE */ +#include "cfe_platform_cfg.h" /* CFE_PLATFORM_ES_ER_LOG_ENTRIES, CFE_PLATFORM_ES_SYSTEM_LOG_SIZE */ /* ** Reset Variables type @@ -93,12 +93,10 @@ typedef struct */ CFE_TIME_ResetVars_t TimeResetVars; -#ifdef CFE_PLATFORM_EVS_LOG_ON /* ** EVS Log and associated variables. This needs to be preserved on a processor reset. */ CFE_EVS_Log_t EVS_Log; -#endif } CFE_ES_ResetData_t; diff --git a/fsw/cfe-core/src/inc/private/cfe_private.h b/fsw/cfe-core/src/inc/private/cfe_private.h index a2f1b0152..e3738e493 100644 --- a/fsw/cfe-core/src/inc/private/cfe_private.h +++ b/fsw/cfe-core/src/inc/private/cfe_private.h @@ -226,7 +226,7 @@ extern int32 CFE_FS_EarlyInit(void); ** the specified application from the Critical Data Store. ** ******************************************************************************/ -extern int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId); +extern int32 CFE_TBL_CleanUpApp(CFE_ES_AppId_t AppId); /*****************************************************************************/ /** @@ -238,7 +238,7 @@ extern int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId); ** that have been allocated to the specified Application. ** ******************************************************************************/ -extern int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId); +extern int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId); /*****************************************************************************/ /** @@ -250,7 +250,7 @@ extern int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId); ** that have been allocated to the specified Application. ** ******************************************************************************/ -extern int32 CFE_EVS_CleanUpApp(CFE_ES_ResourceID_t AppId); +extern int32 CFE_EVS_CleanUpApp(CFE_ES_AppId_t AppId); /*****************************************************************************/ /** @@ -262,7 +262,7 @@ extern int32 CFE_EVS_CleanUpApp(CFE_ES_ResourceID_t AppId); ** that have been allocated to the specified Application. ** ******************************************************************************/ -extern int32 CFE_TIME_CleanUpApp(CFE_ES_ResourceID_t AppId); +extern int32 CFE_TIME_CleanUpApp(CFE_ES_AppId_t AppId); /*****************************************************************************/ @@ -327,7 +327,7 @@ int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, ** \return #CFE_ES_CDS_OWNER_ACTIVE_ERR \copydoc CFE_ES_CDS_OWNER_ACTIVE_ERR ** \return #CFE_ES_ERR_NAME_NOT_FOUND \copydoc CFE_ES_ERR_NAME_NOT_FOUND ** \return Any of the return values from #CFE_ES_UpdateCDSRegistry -** \return Any of the return values from #CFE_ES_PutCDSBlock +** \return Any of the return values from #CFE_ES_GenPoolPutBlock ** ******************************************************************************/ int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices); diff --git a/fsw/cfe-core/src/inc/private/cfe_resourceid_internal.h b/fsw/cfe-core/src/inc/private/cfe_resourceid_internal.h deleted file mode 100644 index cf9969fa7..000000000 --- a/fsw/cfe-core/src/inc/private/cfe_resourceid_internal.h +++ /dev/null @@ -1,165 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/** - * \file cfe_resourceid_internal.h - * - * Contains CFE internal prototypes and definitions related to resource - * management and related CFE resource IDs. - * - * A CFE ES Resource ID is a common way to identify CFE-managed resources such - * as apps, tasks, counters, memory pools, CDS blocks, and other entities. - */ - -#ifndef CFE_RESOURCEID_INTERNAL_H -#define CFE_RESOURCEID_INTERNAL_H - -/* -** Include Files -*/ -#include "cfe_resourceid.h" -#include "osapi-idmap.h" - -/* -** Defines -*/ - -/* - * Limits/definitions related to CFE_ES_ResourceID_t values. - * - * Defining based on OSAL ID values makes this object a superset of - * the OSAL ID type, such that OSAL IDs can be represented as ES resource IDs - * and not conflict with/alias each other. - * - * NOTE: This reflects a bit if "inside knowledge" about how OSAL IDs are - * constructed. The overlap between OSAL IDs and ES IDs may not always be - * consistent, and they can diverge in a future version. - */ -#define CFE_ES_RESOURCEID_SHIFT OS_OBJECT_TYPE_SHIFT -#define CFE_ES_RESOURCEID_MAX ((1 << CFE_ES_RESOURCEID_SHIFT)-1) -#define CFE_ES_RESOURCEID_MARK (0x02000000) - -/** - * @defgroup CFEResourceIDBase Resource ID base values - * @{ - */ - -/* ES managed resources */ -#define CFE_ES_APPID_BASE (CFE_ES_RESOURCEID_MARK | ((OS_OBJECT_TYPE_USER+1) << CFE_ES_RESOURCEID_SHIFT)) -#define CFE_ES_LIBID_BASE (CFE_ES_RESOURCEID_MARK | ((OS_OBJECT_TYPE_USER+2) << CFE_ES_RESOURCEID_SHIFT)) -#define CFE_ES_COUNTID_BASE (CFE_ES_RESOURCEID_MARK | ((OS_OBJECT_TYPE_USER+3) << CFE_ES_RESOURCEID_SHIFT)) -#define CFE_ES_POOLID_BASE (CFE_ES_RESOURCEID_MARK | ((OS_OBJECT_TYPE_USER+4) << CFE_ES_RESOURCEID_SHIFT)) -#define CFE_ES_CDSBLOCKID_BASE (CFE_ES_RESOURCEID_MARK | ((OS_OBJECT_TYPE_USER+5) << CFE_ES_RESOURCEID_SHIFT)) - -/* SB managed resources */ -#define CFE_SB_PIPEID_BASE (CFE_ES_RESOURCEID_MARK | ((OS_OBJECT_TYPE_USER+6) << CFE_ES_RESOURCEID_SHIFT)) - -/** @} */ - - -/** - * @brief Get the Base value (type/category) from a resource ID value - * - * This masks out the ID serial number to obtain the base value, which is different - * for each resource type. - * - * @note The value is NOT shifted or otherwise adjusted. It should match one of the - * defined base values in @ref CFEESResourceIDBase. - * - * @param[in] ResourceId the resource ID to decode - * @returns The base value associated with that ID - */ -static inline uint32 CFE_ES_ResourceID_GetBase(CFE_ES_ResourceID_t ResourceId) -{ - uint32 ResourceType = CFE_ES_ResourceID_ToInteger(ResourceId); - return (ResourceType - (ResourceType & CFE_ES_RESOURCEID_MAX)); -} - -/** - * @brief Locate the next resource ID which does not map to an in-use table entry - * - * This begins searching from StartId which should be the most recently issued ID - * for the resource category. This will then search for the next ID which does - * _not_ map to a table entry that is in use. That is, it does not alias any - * valid ID when converted to an array index. - * - * returns an undefined ID value if no open slots are available - * - * @param[in] StartId the last issued ID for the resource category (app, lib, etc). - * @param[in] TableSize the maximum size of the target table - * @param[in] CheckFunc a function to check if the given ID is available - * @returns Next ID value which does not map to a valid entry - * @retval #CFE_ES_RESOURCEID_UNDEFINED if no open slots. - * - */ -CFE_ES_ResourceID_t CFE_ES_FindNextAvailableId(CFE_ES_ResourceID_t StartId, uint32 TableSize, bool (*CheckFunc)(CFE_ES_ResourceID_t) ); - -/** - * @brief Convert an ES Task ID to an OSAL task ID - * - * Task IDs created via CFE ES are also OSAL task IDs, but technically - * do refer to a different scope and therefore have a different type - * to represent them. - * - * This function facilitates converting between the types. - * - * @note Currently the numeric values are the same and can be interchanged - * for backward compatibility, however they may diverge in a future version. - * New code should not assume equivalence between OSAL and ES task IDs. - * - * @sa CFE_ES_ResourceID_FromOSAL - * - * @param[in] id The ES task ID - * @returns The OSAL task ID - */ -osal_id_t CFE_ES_ResourceID_ToOSAL(CFE_ES_ResourceID_t id); - -/** - * @brief Convert an ES Task ID to an OSAL task ID - * - * Task IDs created via CFE ES are also OSAL task IDs, but technically - * do refer to a different scope and therefore have a different type - * to represent them. - * - * This function facilitates converting between the types. - * - * @note Currently the numeric values are the same and can be interchanged - * for backward compatibility, however they may diverge in a future version. - * New code should not assume equivalence between OSAL and ES task IDs. - * - * @sa CFE_ES_ResourceID_ToOSAL - * - * @param[in] id The OSAL task ID - * @returns The ES task ID - */ -CFE_ES_ResourceID_t CFE_ES_ResourceID_FromOSAL(osal_id_t id); - -/** - * @brief Internal routine to aid in converting an ES resource ID to an array index - - * @param[in] Serial The resource serial number (type info masked out) - * @param[in] TableSize The size of the internal table (MAX value) - * @param[out] Idx The output index - * @returns Status code, CFE_SUCCESS if successful. - */ -int32 CFE_ES_ResourceID_ToIndex(uint32 Serial, uint32 TableSize, uint32 *Idx); - - -#endif /* CFE_RESOURCEID_H */ diff --git a/fsw/cfe-core/src/sb/cfe_sb_api.c b/fsw/cfe-core/src/sb/cfe_sb_api.c index f4a8cdcf8..772a84e53 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_api.c +++ b/fsw/cfe-core/src/sb/cfe_sb_api.c @@ -68,12 +68,13 @@ #include "cfe_psp.h" #include "cfe_error.h" #include +#include "private/cfe_core_resourceid_basevalues.h" /* * Macro to reflect size of PipeDepthStats Telemetry array - * this may or may not be the same as CFE_SB_MSG_MAX_PIPES */ -#define CFE_SB_TLM_PIPEDEPTHSTATS_SIZE (sizeof(CFE_SB.StatTlmMsg.Payload.PipeDepthStats) / sizeof(CFE_SB.StatTlmMsg.Payload.PipeDepthStats[0])) +#define CFE_SB_TLM_PIPEDEPTHSTATS_SIZE (sizeof(CFE_SB_Global.StatTlmMsg.Payload.PipeDepthStats) / sizeof(CFE_SB_Global.StatTlmMsg.Payload.PipeDepthStats[0])) /* Local structure for remove pipe callbacks */ typedef struct @@ -88,8 +89,8 @@ typedef struct */ CFE_Status_t CFE_SB_PipeId_ToIndex(CFE_SB_PipeId_t PipeID, uint32 *Idx) { - return CFE_ES_ResourceID_ToIndex( - CFE_ES_ResourceID_ToInteger(PipeID) - CFE_SB_PIPEID_BASE, + return CFE_ResourceId_ToIndex(CFE_RESOURCEID_UNWRAP(PipeID), + CFE_SB_PIPEID_BASE, CFE_PLATFORM_SB_MAX_PIPES, Idx); } @@ -99,12 +100,12 @@ CFE_Status_t CFE_SB_PipeId_ToIndex(CFE_SB_PipeId_t PipeID, uint32 *Idx) */ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName) { - CFE_ES_ResourceID_t AppId; - CFE_ES_ResourceID_t TskId; + CFE_ES_AppId_t AppId; + CFE_ES_TaskId_t TskId; osal_id_t SysQueueId; int32 Status; CFE_SB_PipeD_t *PipeDscPtr; - CFE_SB_PipeId_t PendingPipeId; + CFE_ResourceId_t PendingPipeId; uint16 PendingEventId; char FullName[(OS_MAX_API_NAME * 2)]; @@ -126,7 +127,7 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * CFE_ES_GetTaskID(&TskId); /* check input parameters */ - if((PipeIdPtr == NULL) || (Depth > CFE_PLATFORM_SB_MAX_PIPE_DEPTH) || (Depth == 0)) + if((PipeIdPtr == NULL) || (Depth > OS_QUEUE_MAX_DEPTH) || (Depth == 0)) { PendingEventId = CFE_SB_CR_PIPE_BAD_ARG_EID; Status = CFE_SB_BAD_ARGUMENT; @@ -137,8 +138,8 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * CFE_SB_LockSharedData(__func__,__LINE__); /* get first available entry in pipe table */ - PendingPipeId = CFE_ES_FindNextAvailableId(CFE_SB.LastPipeId, CFE_PLATFORM_SB_MAX_PIPES, CFE_SB_CheckPipeDescSlotUsed); - PipeDscPtr = CFE_SB_LocatePipeDescByID(PendingPipeId); + PendingPipeId = CFE_ResourceId_FindNext(CFE_SB_Global.LastPipeId, CFE_PLATFORM_SB_MAX_PIPES, CFE_SB_CheckPipeDescSlotUsed); + PipeDscPtr = CFE_SB_LocatePipeDescByID(CFE_SB_PIPEID_C(PendingPipeId)); /* if pipe table is full, send event and return error */ if(PipeDscPtr == NULL) @@ -151,8 +152,8 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * /* Fully clear the entry, just in case of stale data */ memset(PipeDscPtr, 0, sizeof(*PipeDscPtr)); - CFE_SB_PipeDescSetUsed(PipeDscPtr, CFE_ES_RESOURCEID_RESERVED); - CFE_SB.LastPipeId = PendingPipeId; + CFE_SB_PipeDescSetUsed(PipeDscPtr, CFE_RESOURCEID_RESERVED); + CFE_SB_Global.LastPipeId = PendingPipeId; } CFE_SB_UnlockSharedData(__func__,__LINE__); @@ -201,10 +202,10 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * /* Increment the Pipes in use ctr and if it's > the high water mark,*/ /* adjust the high water mark */ - CFE_SB.StatTlmMsg.Payload.PipesInUse++; - if (CFE_SB.StatTlmMsg.Payload.PipesInUse > CFE_SB.StatTlmMsg.Payload.PeakPipesInUse) + CFE_SB_Global.StatTlmMsg.Payload.PipesInUse++; + if (CFE_SB_Global.StatTlmMsg.Payload.PipesInUse > CFE_SB_Global.StatTlmMsg.Payload.PeakPipesInUse) { - CFE_SB.StatTlmMsg.Payload.PeakPipesInUse = CFE_SB.StatTlmMsg.Payload.PipesInUse; + CFE_SB_Global.StatTlmMsg.Payload.PeakPipesInUse = CFE_SB_Global.StatTlmMsg.Payload.PipesInUse; }/* end if */ } else @@ -217,7 +218,7 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * CFE_SB_PipeDescSetFree(PipeDscPtr); PipeDscPtr = NULL; } - PendingPipeId = CFE_ES_RESOURCEID_UNDEFINED; + PendingPipeId = CFE_RESOURCEID_UNDEFINED; /* * If there is a relevant error counter, increment it now @@ -226,7 +227,7 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * switch(PendingEventId) { case CFE_SB_CR_PIPE_BAD_ARG_EID: - ++CFE_SB.HKTlmMsg.Payload.CreatePipeErrorCounter; + ++CFE_SB_Global.HKTlmMsg.Payload.CreatePipeErrorCounter; break; default: /* no counter */ @@ -240,41 +241,41 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * if (Status == CFE_SUCCESS) { /* send debug event */ - CFE_EVS_SendEventWithAppID(CFE_SB_PIPE_ADDED_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_PIPE_ADDED_EID,CFE_EVS_EventType_DEBUG,CFE_SB_Global.AppId, "Pipe Created:name %s,id %d,app %s", - PipeName, (int)CFE_ES_ResourceID_ToInteger(PendingPipeId), + PipeName, (int)CFE_ResourceId_ToInteger(PendingPipeId), CFE_SB_GetAppTskName(TskId,FullName)); /* give the pipe handle to the caller */ - *PipeIdPtr = PendingPipeId; + *PipeIdPtr = CFE_SB_PIPEID_C(PendingPipeId); } else { switch(PendingEventId) { case CFE_SB_CR_PIPE_BAD_ARG_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_BAD_ARG_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_BAD_ARG_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "CreatePipeErr:Bad Input Arg:app=%s,ptr=0x%lx,depth=%d,maxdepth=%d", - CFE_SB_GetAppTskName(TskId,FullName),(unsigned long)PipeIdPtr,(int)Depth,CFE_PLATFORM_SB_MAX_PIPE_DEPTH); + CFE_SB_GetAppTskName(TskId,FullName),(unsigned long)PipeIdPtr,(int)Depth,OS_QUEUE_MAX_DEPTH); break; case CFE_SB_MAX_PIPES_MET_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_MAX_PIPES_MET_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_MAX_PIPES_MET_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "CreatePipeErr:Max Pipes(%d)In Use.app %s", CFE_PLATFORM_SB_MAX_PIPES,CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_CR_PIPE_NAME_TAKEN_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_NAME_TAKEN_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_NAME_TAKEN_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "CreatePipeErr:OS_QueueCreate failed, name taken (app=%s, name=%s)", CFE_SB_GetAppTskName(TskId,FullName), PipeName); break; case CFE_SB_CR_PIPE_NO_FREE_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_NO_FREE_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_NO_FREE_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "CreatePipeErr:OS_QueueCreate failed, no free id's (app=%s)", CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_CR_PIPE_ERR_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "CreatePipeErr:OS_QueueCreate returned %d,app %s", (int)Status,CFE_SB_GetAppTskName(TskId,FullName)); break; @@ -291,7 +292,7 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * */ int32 CFE_SB_DeletePipe(CFE_SB_PipeId_t PipeId) { - CFE_ES_ResourceID_t CallerId; + CFE_ES_AppId_t CallerId; int32 Status = 0; /* get the callers Application Id */ @@ -317,7 +318,7 @@ int32 CFE_SB_DeletePipe(CFE_SB_PipeId_t PipeId) ** Return: ** CFE_SUCCESS or cFE Error Code */ -int32 CFE_SB_DeletePipeWithAppId(CFE_SB_PipeId_t PipeId, CFE_ES_ResourceID_t AppId) +int32 CFE_SB_DeletePipeWithAppId(CFE_SB_PipeId_t PipeId, CFE_ES_AppId_t AppId) { int32 Status = 0; @@ -360,11 +361,11 @@ void CFE_SB_RemovePipeFromRoute(CFE_SBR_RouteId_t RouteId, void *ArgPtr) ** Return: ** CFE_SUCCESS or cFE Error Code */ -int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) +int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_AppId_t AppId) { CFE_SB_PipeD_t *PipeDscPtr; int32 Status; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; CFE_SB_BufferD_t *BufDscPtr; osal_id_t SysQueueId; char FullName[(OS_MAX_API_NAME * 2)]; @@ -388,7 +389,7 @@ int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) Status = CFE_SB_BAD_ARGUMENT; } /* check that the given AppId is the owner of the pipe */ - else if (!CFE_ES_ResourceID_Equal(AppId, PipeDscPtr->AppId)) + else if (!CFE_RESOURCEID_TEST_EQUAL(AppId, PipeDscPtr->AppId)) { PendingEventID = CFE_SB_DEL_PIPE_ERR2_EID; Status = CFE_SB_BAD_ARGUMENT; @@ -417,7 +418,7 @@ int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) * from trying to use this Pipe Desc slot, and also should prevents * any task from re-subscribing to this pipe. */ - CFE_SB_PipeDescSetUsed(PipeDscPtr, CFE_ES_RESOURCEID_RESERVED); + CFE_SB_PipeDescSetUsed(PipeDscPtr, CFE_RESOURCEID_RESERVED); } CFE_SB_UnlockSharedData(__func__,__LINE__); @@ -455,11 +456,11 @@ int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) if (Status == CFE_SUCCESS) { CFE_SB_PipeDescSetFree(PipeDscPtr); - --CFE_SB.StatTlmMsg.Payload.PipesInUse; + --CFE_SB_Global.StatTlmMsg.Payload.PipesInUse; } else if (PendingEventID != 0) { - CFE_SB.HKTlmMsg.Payload.CreatePipeErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CreatePipeErrorCounter++; } CFE_SB_UnlockSharedData(__func__,__LINE__); @@ -474,8 +475,8 @@ int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) */ CFE_ES_GetAppName(FullName, AppId, sizeof(FullName)); - CFE_EVS_SendEventWithAppID(CFE_SB_PIPE_DELETED_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, - "Pipe Deleted:id %d,owner %s",(int)CFE_ES_ResourceID_ToInteger(PipeId), FullName); + CFE_EVS_SendEventWithAppID(CFE_SB_PIPE_DELETED_EID,CFE_EVS_EventType_DEBUG,CFE_SB_Global.AppId, + "Pipe Deleted:id %d,owner %s",(int)CFE_RESOURCEID_TO_ULONG(PipeId), FullName); } else { @@ -486,14 +487,14 @@ int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) switch (PendingEventID) { case CFE_SB_DEL_PIPE_ERR1_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_DEL_PIPE_ERR1_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_DEL_PIPE_ERR1_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Pipe Delete Error:Bad Argument,PipedId %ld,Requestor %s", - CFE_ES_ResourceID_ToInteger(PipeId),FullName); + CFE_RESOURCEID_TO_ULONG(PipeId),FullName); break; case CFE_SB_DEL_PIPE_ERR2_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_DEL_PIPE_ERR2_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_DEL_PIPE_ERR2_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Pipe Delete Error:Caller(%s) is not the owner of pipe %ld", - FullName, CFE_ES_ResourceID_ToInteger(PipeId)); + FullName, CFE_RESOURCEID_TO_ULONG(PipeId)); break; } } @@ -509,8 +510,8 @@ int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) { CFE_SB_PipeD_t *PipeDscPtr; - CFE_ES_ResourceID_t AppID; - CFE_ES_ResourceID_t TskId; + CFE_ES_AppId_t AppID; + CFE_ES_TaskId_t TskId; uint16 PendingEventID; int32 Status; char FullName[(OS_MAX_API_NAME * 2)]; @@ -535,7 +536,7 @@ int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) Status = CFE_SB_BAD_ARGUMENT; } /* check that the caller AppId is the owner of the pipe */ - else if( !CFE_ES_ResourceID_Equal(AppID, PipeDscPtr->AppId) ) + else if( !CFE_RESOURCEID_TEST_EQUAL(AppID, PipeDscPtr->AppId) ) { PendingEventID = CFE_SB_SETPIPEOPTS_OWNER_ERR_EID; Status = CFE_SB_BAD_ARGUMENT; @@ -548,7 +549,7 @@ int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) /* If anything went wrong, increment the error counter before unlock */ if (Status != CFE_SUCCESS) { - CFE_SB.HKTlmMsg.Payload.PipeOptsErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.PipeOptsErrorCounter++; } CFE_SB_UnlockSharedData(__func__,__LINE__); @@ -559,8 +560,8 @@ int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) /* get AppID of caller for events */ CFE_ES_GetAppName(FullName, AppID, sizeof(FullName)); - CFE_EVS_SendEventWithAppID(CFE_SB_SETPIPEOPTS_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, - "Pipe opts set:id %lu,owner %s, opts=0x%02x",CFE_ES_ResourceID_ToInteger(PipeId), FullName, (unsigned int)Opts); + CFE_EVS_SendEventWithAppID(CFE_SB_SETPIPEOPTS_EID,CFE_EVS_EventType_DEBUG,CFE_SB_Global.AppId, + "Pipe opts set:id %lu,owner %s, opts=0x%02x",CFE_RESOURCEID_TO_ULONG(PipeId), FullName, (unsigned int)Opts); } else { @@ -570,14 +571,14 @@ int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) switch (PendingEventID) { case CFE_SB_SETPIPEOPTS_ID_ERR_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_SETPIPEOPTS_ID_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_SETPIPEOPTS_ID_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Pipe Opts Error:Bad Argument,PipedId %lu,Requestor %s", - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_SETPIPEOPTS_OWNER_ERR_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_SETPIPEOPTS_OWNER_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_SETPIPEOPTS_OWNER_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Pipe Opts Set Error: Caller(%s) is not the owner of pipe %lu", - CFE_SB_GetAppTskName(TskId,FullName),CFE_ES_ResourceID_ToInteger(PipeId)); + CFE_SB_GetAppTskName(TskId,FullName),CFE_RESOURCEID_TO_ULONG(PipeId)); break; } } @@ -591,7 +592,7 @@ int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) int32 CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptsPtr) { int32 Status; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; uint16 PendingEventID; CFE_SB_PipeD_t *PipeDscPtr; @@ -622,7 +623,7 @@ int32 CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptsPtr) /* If anything went wrong, increment the error counter before unlock */ if (Status != CFE_SUCCESS) { - CFE_SB.HKTlmMsg.Payload.PipeOptsErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.PipeOptsErrorCounter++; } CFE_SB_UnlockSharedData(__func__,__LINE__); @@ -630,8 +631,8 @@ int32 CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptsPtr) /* Send events after unlocking SB */ if (Status == CFE_SUCCESS) { - CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPEOPTS_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, - "Pipe opts get:id %lu, opts=0x%02x",CFE_ES_ResourceID_ToInteger(PipeId), (unsigned int)*OptsPtr); + CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPEOPTS_EID,CFE_EVS_EventType_DEBUG,CFE_SB_Global.AppId, + "Pipe opts get:id %lu, opts=0x%02x",CFE_RESOURCEID_TO_ULONG(PipeId), (unsigned int)*OptsPtr); } else { @@ -641,14 +642,14 @@ int32 CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptsPtr) switch(PendingEventID) { case CFE_SB_GETPIPEOPTS_PTR_ERR_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPEOPTS_PTR_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPEOPTS_PTR_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId, "Pipe Opts Error:Bad Argument,Requestor %s", CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_GETPIPEOPTS_ID_ERR_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPEOPTS_ID_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPEOPTS_ID_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId, "Pipe Opts Error:Bad Argument,PipedId %lu,Requestor %s", - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); break; } } @@ -662,7 +663,7 @@ int32 CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptsPtr) int32 CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t PipeId) { int32 Status; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; uint16 PendingEventID; CFE_SB_PipeD_t *PipeDscPtr; @@ -716,9 +717,9 @@ int32 CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t if (Status == CFE_SUCCESS) { CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPENAME_EID, - CFE_EVS_EventType_DEBUG,CFE_SB.AppId, + CFE_EVS_EventType_DEBUG,CFE_SB_Global.AppId, "GetPipeName name=%s id=%lu", - PipeNameBuf, CFE_ES_ResourceID_ToInteger(PipeId)); + PipeNameBuf, CFE_RESOURCEID_TO_ULONG(PipeId)); } else { @@ -728,13 +729,13 @@ int32 CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t { case CFE_SB_GETPIPENAME_NULL_PTR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPENAME_NULL_PTR_EID, CFE_EVS_EventType_ERROR, - CFE_SB.AppId, "Pipe Name Error:NullPtr,Requestor %s", + CFE_SB_Global.AppId, "Pipe Name Error:NullPtr,Requestor %s", CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_GETPIPENAME_ID_ERR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPENAME_ID_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_SB.AppId, "Pipe Id Error:Bad Argument,Id=%lu,Requestor %s", - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_SB_Global.AppId, "Pipe Id Error:Bad Argument,Id=%lu,Requestor %s", + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); break; } @@ -754,7 +755,7 @@ int32 CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) { int32 Status; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; uint32 Idx; char FullName[(OS_MAX_API_NAME * 2)]; uint16 PendingEventID; @@ -790,7 +791,7 @@ int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) if (Status == CFE_SUCCESS) { Idx = CFE_PLATFORM_SB_MAX_PIPES; - PipeDscPtr = CFE_SB.PipeTbl; + PipeDscPtr = CFE_SB_Global.PipeTbl; while(true) { if (Idx == 0) @@ -814,7 +815,7 @@ int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) if (Status != CFE_SUCCESS) { - ++CFE_SB.HKTlmMsg.Payload.GetPipeIdByNameErrorCounter; + ++CFE_SB_Global.HKTlmMsg.Payload.GetPipeIdByNameErrorCounter; } CFE_SB_UnlockSharedData(__func__,__LINE__); @@ -823,9 +824,9 @@ int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) if (Status == CFE_SUCCESS) { CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPEIDBYNAME_EID, - CFE_EVS_EventType_DEBUG,CFE_SB.AppId, + CFE_EVS_EventType_DEBUG,CFE_SB_Global.AppId, "PipeIdByName name=%s id=%lu", - PipeName, CFE_ES_ResourceID_ToInteger(*PipeIdPtr)); + PipeName, CFE_RESOURCEID_TO_ULONG(*PipeIdPtr)); } else { @@ -836,14 +837,14 @@ int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) { case CFE_SB_GETPIPEIDBYNAME_NULL_ERR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPEIDBYNAME_NULL_ERR_EID, - CFE_EVS_EventType_ERROR, CFE_SB.AppId, + CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId, "Pipe ID By Name Error:Bad Argument,Requestor %s", CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_GETPIPEIDBYNAME_NAME_ERR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPEIDBYNAME_NAME_ERR_EID, - CFE_EVS_EventType_ERROR, CFE_SB.AppId, + CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId, "Pipe ID By Name Error:Bad Argument,Requestor %s", CFE_SB_GetAppTskName(TskId,FullName)); break; @@ -864,7 +865,7 @@ int32 CFE_SB_SubscribeEx(CFE_SB_MsgId_t MsgId, CFE_SB_Qos_t Quality, uint16 MsgLim) { - return CFE_SB_SubscribeFull(MsgId,PipeId,Quality,MsgLim,(uint8)CFE_SB_GLOBAL); + return CFE_SB_SubscribeFull(MsgId,PipeId,Quality,MsgLim,(uint8)CFE_SB_MSG_GLOBAL); }/* end CFE_SB_SubscribeEx */ @@ -878,8 +879,8 @@ int32 CFE_SB_SubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, uint16 MsgLim) { - return CFE_SB_SubscribeFull(MsgId,PipeId,CFE_SB_Default_Qos,MsgLim, - (uint8)CFE_SB_LOCAL); + return CFE_SB_SubscribeFull(MsgId,PipeId,CFE_SB_DEFAULT_QOS,MsgLim, + (uint8)CFE_SB_MSG_LOCAL); }/* end CFE_SB_SubscribeLocal */ @@ -889,9 +890,9 @@ int32 CFE_SB_SubscribeLocal(CFE_SB_MsgId_t MsgId, int32 CFE_SB_Subscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) { - return CFE_SB_SubscribeFull(MsgId,PipeId,CFE_SB_Default_Qos, + return CFE_SB_SubscribeFull(MsgId,PipeId,CFE_SB_DEFAULT_QOS, (uint16)CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT, - (uint8)CFE_SB_GLOBAL); + (uint8)CFE_SB_MSG_GLOBAL); }/* end CFE_SB_Subscribe */ @@ -934,8 +935,8 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, CFE_SBR_RouteId_t RouteId; CFE_SB_PipeD_t *PipeDscPtr; int32 Status; - CFE_ES_ResourceID_t TskId; - CFE_ES_ResourceID_t AppId; + CFE_ES_TaskId_t TskId; + CFE_ES_AppId_t AppId; CFE_SB_DestinationD_t *DestPtr; uint32 DestCount; char FullName[(OS_MAX_API_NAME * 2)]; @@ -964,7 +965,7 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, PendingEventID = CFE_SB_SUB_INV_PIPE_EID; Status = CFE_SB_BAD_ARGUMENT; } - else if (!CFE_ES_ResourceID_Equal(PipeDscPtr->AppId, AppId)) + else if (!CFE_RESOURCEID_TEST_EQUAL(PipeDscPtr->AppId, AppId)) { PendingEventID = CFE_SB_SUB_INV_CALLER_EID; Status = CFE_SB_BAD_ARGUMENT; @@ -995,10 +996,10 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, { /* Increment the MsgIds in use ctr and if it's > the high water mark,*/ /* adjust the high water mark */ - CFE_SB.StatTlmMsg.Payload.MsgIdsInUse++; - if(CFE_SB.StatTlmMsg.Payload.MsgIdsInUse > CFE_SB.StatTlmMsg.Payload.PeakMsgIdsInUse) + CFE_SB_Global.StatTlmMsg.Payload.MsgIdsInUse++; + if(CFE_SB_Global.StatTlmMsg.Payload.MsgIdsInUse > CFE_SB_Global.StatTlmMsg.Payload.PeakMsgIdsInUse) { - CFE_SB.StatTlmMsg.Payload.PeakMsgIdsInUse = CFE_SB.StatTlmMsg.Payload.MsgIdsInUse; + CFE_SB_Global.StatTlmMsg.Payload.PeakMsgIdsInUse = CFE_SB_Global.StatTlmMsg.Payload.MsgIdsInUse; }/* end if */ } } @@ -1015,7 +1016,7 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, ++DestCount; /* Check if duplicate (status stays as CFE_SUCCESS) */ - if (CFE_ES_ResourceID_Equal(DestPtr->PipeId, PipeId)) + if (CFE_RESOURCEID_TEST_EQUAL(DestPtr->PipeId, PipeId)) { PendingEventID = CFE_SB_DUP_SUBSCRIP_EID; break; @@ -1055,10 +1056,10 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, /* add destination node */ CFE_SB_AddDestNode(RouteId, DestPtr); - CFE_SB.StatTlmMsg.Payload.SubscriptionsInUse++; - if(CFE_SB.StatTlmMsg.Payload.SubscriptionsInUse > CFE_SB.StatTlmMsg.Payload.PeakSubscriptionsInUse) + CFE_SB_Global.StatTlmMsg.Payload.SubscriptionsInUse++; + if(CFE_SB_Global.StatTlmMsg.Payload.SubscriptionsInUse > CFE_SB_Global.StatTlmMsg.Payload.PeakSubscriptionsInUse) { - CFE_SB.StatTlmMsg.Payload.PeakSubscriptionsInUse = CFE_SB.StatTlmMsg.Payload.SubscriptionsInUse; + CFE_SB_Global.StatTlmMsg.Payload.PeakSubscriptionsInUse = CFE_SB_Global.StatTlmMsg.Payload.SubscriptionsInUse; } } } @@ -1073,10 +1074,10 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, case CFE_SB_MAX_MSGS_MET_EID: case CFE_SB_DEST_BLK_ERR_EID: case CFE_SB_MAX_DESTS_MET_EID: - CFE_SB.HKTlmMsg.Payload.SubscribeErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.SubscribeErrorCounter++; break; case CFE_SB_DUP_SUBSCRIP_EID: - CFE_SB.HKTlmMsg.Payload.DuplicateSubscriptionsCounter++; + CFE_SB_Global.HKTlmMsg.Payload.DuplicateSubscriptionsCounter++; break; } @@ -1090,71 +1091,71 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, switch(PendingEventID) { case CFE_SB_DUP_SUBSCRIP_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_DUP_SUBSCRIP_EID,CFE_EVS_EventType_INFORMATION,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_DUP_SUBSCRIP_EID,CFE_EVS_EventType_INFORMATION,CFE_SB_Global.AppId, "Duplicate Subscription,MsgId 0x%x on %s pipe,app %s", (unsigned int)CFE_SB_MsgIdToValue(MsgId), PipeName,CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_SUB_INV_CALLER_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_SUB_INV_CALLER_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_SUB_INV_CALLER_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Subscribe Err:Caller(%s) is not the owner of pipe %lu,Msg=0x%x", - CFE_SB_GetAppTskName(TskId,FullName),CFE_ES_ResourceID_ToInteger(PipeId), + CFE_SB_GetAppTskName(TskId,FullName),CFE_RESOURCEID_TO_ULONG(PipeId), (unsigned int)CFE_SB_MsgIdToValue(MsgId)); break; case CFE_SB_SUB_INV_PIPE_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_SUB_INV_PIPE_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_SUB_INV_PIPE_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Subscribe Err:Invalid Pipe Id,Msg=0x%x,PipeId=%lu,App %s", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(PipeId), CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId), CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_DEST_BLK_ERR_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_DEST_BLK_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_DEST_BLK_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Subscribe Err:Request for Destination Blk failed for Msg 0x%x", (unsigned int)CFE_SB_MsgIdToValue(MsgId)); break; case CFE_SB_MAX_DESTS_MET_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_MAX_DESTS_MET_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_MAX_DESTS_MET_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Subscribe Err:Max Dests(%d)In Use For Msg 0x%x,pipe %s,app %s", CFE_PLATFORM_SB_MAX_DEST_PER_PKT, (unsigned int)CFE_SB_MsgIdToValue(MsgId), PipeName, CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_MAX_MSGS_MET_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_MAX_MSGS_MET_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_MAX_MSGS_MET_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Subscribe Err:Max Msgs(%d)In Use,MsgId 0x%x,pipe %s,app %s", CFE_PLATFORM_SB_MAX_MSG_IDS, (unsigned int)CFE_SB_MsgIdToValue(MsgId), PipeName, CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_SUB_ARG_ERR_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_SUB_ARG_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_SUB_ARG_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Subscribe Err:Bad Arg,MsgId 0x%x,PipeId %lu,app %s,scope %d", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName),Scope); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName),Scope); break; } } else if (Status == CFE_SUCCESS) { /* If no other event pending, send a debug event indicating success */ - CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_RCVD_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, - "Subscription Rcvd:MsgId 0x%x on %s(%lu),app %s", + CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_RCVD_EID,CFE_EVS_EventType_DEBUG,CFE_SB_Global.AppId, + "Subscription Rcvd:MsgId 0x%x on PipeId %lu,app %s", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - PipeName,CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); } - if (Status == CFE_SUCCESS && Scope == CFE_SB_GLOBAL) + if (Status == CFE_SUCCESS && Scope == CFE_SB_MSG_GLOBAL) { CFE_SB_SendSubscriptionReport(MsgId, PipeId, Quality); } if (Collisions != 0) { - CFE_EVS_SendEventWithAppID(CFE_SB_HASHCOLLISION_EID, CFE_EVS_EventType_DEBUG, CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_HASHCOLLISION_EID, CFE_EVS_EventType_DEBUG, CFE_SB_Global.AppId, "Msg hash collision: MsgId = 0x%x, collisions = %u", (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)Collisions); } @@ -1169,13 +1170,13 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, */ int32 CFE_SB_Unsubscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) { - CFE_ES_ResourceID_t CallerId; + CFE_ES_AppId_t CallerId; int32 Status = 0; /* get the callers Application Id */ CFE_ES_GetAppID(&CallerId); - Status = CFE_SB_UnsubscribeFull(MsgId, PipeId, (uint8)CFE_SB_GLOBAL,CallerId); + Status = CFE_SB_UnsubscribeFull(MsgId, PipeId, (uint8)CFE_SB_MSG_GLOBAL,CallerId); return Status; @@ -1187,13 +1188,13 @@ int32 CFE_SB_Unsubscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) */ int32 CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) { - CFE_ES_ResourceID_t CallerId; + CFE_ES_AppId_t CallerId; int32 Status = 0; /* get the callers Application Id */ CFE_ES_GetAppID(&CallerId); - Status = CFE_SB_UnsubscribeFull(MsgId, PipeId, (uint8)CFE_SB_LOCAL,CallerId); + Status = CFE_SB_UnsubscribeFull(MsgId, PipeId, (uint8)CFE_SB_MSG_LOCAL,CallerId); return Status; @@ -1224,11 +1225,11 @@ int32 CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) ******************************************************************************/ int32 CFE_SB_UnsubscribeWithAppId(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, - CFE_ES_ResourceID_t AppId) + CFE_ES_AppId_t AppId) { int32 Status = 0; - Status = CFE_SB_UnsubscribeFull(MsgId, PipeId, (uint8)CFE_SB_LOCAL, AppId); + Status = CFE_SB_UnsubscribeFull(MsgId, PipeId, (uint8)CFE_SB_MSG_LOCAL, AppId); return Status; @@ -1264,11 +1265,11 @@ int32 CFE_SB_UnsubscribeWithAppId(CFE_SB_MsgId_t MsgId, ** ******************************************************************************/ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId,CFE_SB_PipeId_t PipeId, - uint8 Scope,CFE_ES_ResourceID_t AppId) + uint8 Scope,CFE_ES_AppId_t AppId) { int32 Status; CFE_SBR_RouteId_t RouteId; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; CFE_SB_DestinationD_t *DestPtr; char FullName[(OS_MAX_API_NAME * 2)]; char PipeName[OS_MAX_API_NAME]; @@ -1293,7 +1294,7 @@ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId,CFE_SB_PipeId_t PipeId, Status = CFE_SB_BAD_ARGUMENT; } /* if given 'AppId' is not the owner of the pipe, send error event and return */ - else if (!CFE_ES_ResourceID_Equal(PipeDscPtr->AppId, AppId)) + else if (!CFE_RESOURCEID_TEST_EQUAL(PipeDscPtr->AppId, AppId)) { PendingEventID = CFE_SB_UNSUB_INV_CALLER_EID; Status = CFE_SB_BAD_ARGUMENT; @@ -1340,41 +1341,41 @@ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId,CFE_SB_PipeId_t PipeId, { case CFE_SB_UNSUB_NO_SUBS_EID: CFE_SB_GetPipeName(PipeName, sizeof(PipeName), PipeId); - CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_NO_SUBS_EID,CFE_EVS_EventType_INFORMATION,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_NO_SUBS_EID,CFE_EVS_EventType_INFORMATION,CFE_SB_Global.AppId, "Unsubscribe Err:No subs for Msg 0x%x on %s,app %s", (unsigned int)CFE_SB_MsgIdToValue(MsgId), PipeName,CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_UNSUB_INV_PIPE_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_INV_PIPE_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_INV_PIPE_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Unsubscribe Err:Invalid Pipe Id Msg=0x%x,Pipe=%lu,app=%s", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_UNSUB_INV_CALLER_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_INV_CALLER_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_INV_CALLER_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Unsubscribe Err:Caller(%s) is not the owner of pipe %lu,Msg=0x%x", - CFE_SB_GetAppTskName(TskId,FullName),CFE_ES_ResourceID_ToInteger(PipeId), + CFE_SB_GetAppTskName(TskId,FullName),CFE_RESOURCEID_TO_ULONG(PipeId), (unsigned int)CFE_SB_MsgIdToValue(MsgId)); break; case CFE_SB_UNSUB_ARG_ERR_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_ARG_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_ARG_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "UnSubscribe Err:Bad Arg,MsgId 0x%x,PipeId %lu,app %s,scope %d", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName),(int)Scope); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName),(int)Scope); break; } } else if (Status == CFE_SUCCESS) { /* if no other event pending, send a debug event for successful unsubscribe */ - CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_REMOVED_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_REMOVED_EID,CFE_EVS_EventType_DEBUG,CFE_SB_Global.AppId, "Subscription Removed:Msg 0x%x on pipe %lu,app %s", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); } return Status; @@ -1388,7 +1389,7 @@ int32 CFE_SB_TransmitMsg(CFE_MSG_Message_t *MsgPtr, bool IncrementSequenceCount int32 Status; CFE_MSG_Size_t Size = 0; CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; CFE_SB_BufferD_t *BufDscPtr; CFE_SBR_RouteId_t RouteId; @@ -1436,7 +1437,7 @@ int32 CFE_SB_TransmitMsg(CFE_MSG_Message_t *MsgPtr, bool IncrementSequenceCount { /* Increment error counter (inside lock) if not success */ CFE_SB_LockSharedData(__func__, __LINE__); - CFE_SB.HKTlmMsg.Payload.MsgSendErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.MsgSendErrorCounter++; CFE_SB_UnlockSharedData(__func__, __LINE__); } @@ -1447,7 +1448,7 @@ int32 CFE_SB_TransmitMsg(CFE_MSG_Message_t *MsgPtr, bool IncrementSequenceCount if (CFE_SB_RequestToSendEvent(TskId,CFE_SB_GET_BUF_ERR_EID_BIT) == CFE_SB_GRANTED) { - CFE_EVS_SendEventWithAppID(CFE_SB_GET_BUF_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_GET_BUF_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Send Err:Request for Buffer Failed. MsgId 0x%x,app %s,size %d", (unsigned int)CFE_SB_MsgIdToValue(MsgId), CFE_SB_GetAppTskName(TskId,FullName),(int)Size); @@ -1502,7 +1503,7 @@ int32 CFE_SB_TransmitMsgValidate(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Size_t *SizePtr, CFE_SBR_RouteId_t *RouteIdPtr) { - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; uint16 PendingEventID; int32 Status; @@ -1553,7 +1554,7 @@ int32 CFE_SB_TransmitMsgValidate(CFE_MSG_Message_t *MsgPtr, /* increment the dropped pkt cnt, send event and return success */ if(!CFE_SBR_IsValidRouteId(*RouteIdPtr)) { - CFE_SB.HKTlmMsg.Payload.NoSubscribersCounter++; + CFE_SB_Global.HKTlmMsg.Payload.NoSubscribersCounter++; PendingEventID = CFE_SB_SEND_NO_SUBS_EID; } @@ -1568,20 +1569,20 @@ int32 CFE_SB_TransmitMsgValidate(CFE_MSG_Message_t *MsgPtr, switch (PendingEventID) { case CFE_SB_SEND_BAD_ARG_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_SEND_BAD_ARG_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_SEND_BAD_ARG_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Send Err:Bad input argument,Arg 0x%lx,App %s", (unsigned long)MsgPtr,CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_SEND_INV_MSGID_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_SEND_INV_MSGID_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_SEND_INV_MSGID_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Send Err:Invalid MsgId(0x%x)in msg,App %s", (unsigned int)CFE_SB_MsgIdToValue(*MsgIdPtr), CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_MSG_TOO_BIG_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_MSG_TOO_BIG_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_MSG_TOO_BIG_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Send Err:Msg Too Big MsgId=0x%x,app=%s,size=%d,MaxSz=%d", (unsigned int)CFE_SB_MsgIdToValue(*MsgIdPtr), CFE_SB_GetAppTskName(TskId,FullName),(int)*SizePtr,CFE_MISSION_SB_MAX_SB_MSG_SIZE); @@ -1591,7 +1592,7 @@ int32 CFE_SB_TransmitMsgValidate(CFE_MSG_Message_t *MsgPtr, /* Determine if event can be sent without causing recursive event problem */ if (CFE_SB_RequestToSendEvent(TskId,CFE_SB_SEND_NO_SUBS_EID_BIT) == CFE_SB_GRANTED) { - CFE_EVS_SendEventWithAppID(CFE_SB_SEND_NO_SUBS_EID,CFE_EVS_EventType_INFORMATION,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_SEND_NO_SUBS_EID,CFE_EVS_EventType_INFORMATION,CFE_SB_Global.AppId, "No subscribers for MsgId 0x%x,sender %s", (unsigned int)CFE_SB_MsgIdToValue(*MsgIdPtr), CFE_SB_GetAppTskName(TskId,FullName)); @@ -1620,8 +1621,8 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_t RouteId, CFE_SB_MsgId_t MsgId) { - CFE_ES_ResourceID_t AppId; - CFE_ES_ResourceID_t TskId; + CFE_ES_AppId_t AppId; + CFE_ES_TaskId_t TskId; CFE_SB_DestinationD_t *DestPtr; CFE_SB_PipeD_t *PipeDscPtr; CFE_SB_EventBuf_t SBSndErr; @@ -1660,7 +1661,7 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, } if((PipeDscPtr->Opts & CFE_SB_PIPEOPTS_IGNOREMINE) != 0 && - CFE_ES_ResourceID_Equal(PipeDscPtr->AppId, AppId)) + CFE_RESOURCEID_TEST_EQUAL(PipeDscPtr->AppId, AppId)) { continue; }/* end if */ @@ -1672,7 +1673,7 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].PipeId = DestPtr->PipeId; SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_MSGID_LIM_ERR_EID; SBSndErr.EvtsToSnd++; - CFE_SB.HKTlmMsg.Payload.MsgLimitErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.MsgLimitErrorCounter++; PipeDscPtr->SendErrors++; continue; @@ -1706,7 +1707,7 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].PipeId = DestPtr->PipeId; SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_Q_FULL_ERR_EID; SBSndErr.EvtsToSnd++; - CFE_SB.HKTlmMsg.Payload.PipeOverflowErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.PipeOverflowErrorCounter++; PipeDscPtr->SendErrors++; } else @@ -1716,7 +1717,7 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_Q_WR_ERR_EID; SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].ErrStat = Status; SBSndErr.EvtsToSnd++; - CFE_SB.HKTlmMsg.Payload.InternalErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter++; PipeDscPtr->SendErrors++; }/*end if */ @@ -1750,7 +1751,7 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, CFE_ES_PerfLogEntry(CFE_MISSION_SB_MSG_LIM_PERF_ID); CFE_ES_PerfLogExit(CFE_MISSION_SB_MSG_LIM_PERF_ID); - CFE_EVS_SendEventWithAppID(CFE_SB_MSGID_LIM_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_MSGID_LIM_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Msg Limit Err,MsgId 0x%x,pipe %s,sender %s", (unsigned int)CFE_SB_MsgIdToValue(MsgId), PipeName, CFE_SB_GetAppTskName(TskId,FullName)); @@ -1769,7 +1770,7 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, CFE_ES_PerfLogEntry(CFE_MISSION_SB_PIPE_OFLOW_PERF_ID); CFE_ES_PerfLogExit(CFE_MISSION_SB_PIPE_OFLOW_PERF_ID); - CFE_EVS_SendEventWithAppID(CFE_SB_Q_FULL_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_Q_FULL_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Pipe Overflow,MsgId 0x%x,pipe %s,sender %s", (unsigned int)CFE_SB_MsgIdToValue(MsgId), PipeName, CFE_SB_GetAppTskName(TskId,FullName)); @@ -1785,7 +1786,7 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, CFE_SB_GetPipeName(PipeName, sizeof(PipeName), SBSndErr.EvtBuf[i].PipeId); - CFE_EVS_SendEventWithAppID(CFE_SB_Q_WR_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_Q_WR_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Pipe Write Err,MsgId 0x%x,pipe %s,sender %s,stat 0x%x", (unsigned int)CFE_SB_MsgIdToValue(MsgId), PipeName, CFE_SB_GetAppTskName(TskId,FullName), @@ -1825,7 +1826,7 @@ int32 CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeD_t *PipeDscPtr; CFE_SB_DestinationD_t *DestPtr; CFE_SBR_RouteId_t RouteId; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; uint16 PendingEventID; osal_id_t SysQueueId; int32 SysTimeout; @@ -2021,12 +2022,12 @@ int32 CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, { if (PendingEventID == CFE_SB_RCV_BAD_ARG_EID || PendingEventID == CFE_SB_BAD_PIPEID_EID) { - ++CFE_SB.HKTlmMsg.Payload.MsgReceiveErrorCounter; + ++CFE_SB_Global.HKTlmMsg.Payload.MsgReceiveErrorCounter; } else { /* For any other unexpected error (e.g. CFE_SB_Q_RD_ERR_EID) */ - ++CFE_SB.HKTlmMsg.Payload.InternalErrorCounter; + ++CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter; } } @@ -2041,19 +2042,19 @@ int32 CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, switch(PendingEventID) { case CFE_SB_Q_RD_ERR_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_Q_RD_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_Q_RD_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Pipe Read Err,pipe %lu,app %s,stat 0x%x", - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName),(unsigned int)RcvStatus); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName),(unsigned int)RcvStatus); break; case CFE_SB_RCV_BAD_ARG_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_RCV_BAD_ARG_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_RCV_BAD_ARG_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Rcv Err:Bad Input Arg:BufPtr 0x%lx,pipe %lu,t/o %d,app %s", - (unsigned long)BufPtr,CFE_ES_ResourceID_ToInteger(PipeId),(int)TimeOut,CFE_SB_GetAppTskName(TskId,FullName)); + (unsigned long)BufPtr,CFE_RESOURCEID_TO_ULONG(PipeId),(int)TimeOut,CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_BAD_PIPEID_EID: - CFE_EVS_SendEventWithAppID(CFE_SB_BAD_PIPEID_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_BAD_PIPEID_EID,CFE_EVS_EventType_ERROR,CFE_SB_Global.AppId, "Rcv Err:PipeId %lu does not exist,app %s", - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); break; } } @@ -2075,7 +2076,7 @@ CFE_SB_Buffer_t *CFE_SB_ZeroCopyGetPtr(size_t MsgSize, CFE_SB_ZeroCopyHandle_t *BufferHandle) { int32 stat1; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; cpuaddr address = 0; CFE_SB_ZeroCopyD_t *zcd = NULL; CFE_SB_BufferD_t *bd = NULL; @@ -2083,7 +2084,7 @@ CFE_SB_Buffer_t *CFE_SB_ZeroCopyGetPtr(size_t MsgSize, CFE_SB_LockSharedData(__func__,__LINE__); /* Allocate a new zero copy descriptor from the SB memory pool.*/ - stat1 = CFE_ES_GetPoolBuf((CFE_ES_MemPoolBuf_t*)&zcd, CFE_SB.Mem.PoolHdl, sizeof(CFE_SB_ZeroCopyD_t)); + stat1 = CFE_ES_GetPoolBuf((CFE_ES_MemPoolBuf_t*)&zcd, CFE_SB_Global.Mem.PoolHdl, sizeof(CFE_SB_ZeroCopyD_t)); if(stat1 < 0){ CFE_SB_UnlockSharedData(__func__,__LINE__); return NULL; @@ -2091,18 +2092,18 @@ CFE_SB_Buffer_t *CFE_SB_ZeroCopyGetPtr(size_t MsgSize, /* Add the size of a zero copy descriptor to the memory-in-use ctr and */ /* adjust the high water mark if needed */ - CFE_SB.StatTlmMsg.Payload.MemInUse+=stat1; - if(CFE_SB.StatTlmMsg.Payload.MemInUse > CFE_SB.StatTlmMsg.Payload.PeakMemInUse){ - CFE_SB.StatTlmMsg.Payload.PeakMemInUse = CFE_SB.StatTlmMsg.Payload.MemInUse; + CFE_SB_Global.StatTlmMsg.Payload.MemInUse+=stat1; + if(CFE_SB_Global.StatTlmMsg.Payload.MemInUse > CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse){ + CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse = CFE_SB_Global.StatTlmMsg.Payload.MemInUse; }/* end if */ /* Allocate a new buffer (from the SB memory pool) to hold the message */ - stat1 = CFE_ES_GetPoolBuf((CFE_ES_MemPoolBuf_t*)&bd, CFE_SB.Mem.PoolHdl, MsgSize + sizeof(CFE_SB_BufferD_t)); + stat1 = CFE_ES_GetPoolBuf((CFE_ES_MemPoolBuf_t*)&bd, CFE_SB_Global.Mem.PoolHdl, MsgSize + sizeof(CFE_SB_BufferD_t)); if((stat1 < 0)||(bd==NULL)){ /*deallocate the first buffer if the second buffer creation fails*/ - stat1 = CFE_ES_PutPoolBuf(CFE_SB.Mem.PoolHdl, zcd); + stat1 = CFE_ES_PutPoolBuf(CFE_SB_Global.Mem.PoolHdl, zcd); if(stat1 > 0){ - CFE_SB.StatTlmMsg.Payload.MemInUse-=stat1; + CFE_SB_Global.StatTlmMsg.Payload.MemInUse-=stat1; } CFE_SB_UnlockSharedData(__func__,__LINE__); return NULL; @@ -2110,16 +2111,16 @@ CFE_SB_Buffer_t *CFE_SB_ZeroCopyGetPtr(size_t MsgSize, /* Increment the number of buffers in use by one even though two buffers */ /* were allocated. SBBuffersInUse increments on a per-message basis */ - CFE_SB.StatTlmMsg.Payload.SBBuffersInUse++; - if(CFE_SB.StatTlmMsg.Payload.SBBuffersInUse > CFE_SB.StatTlmMsg.Payload.PeakSBBuffersInUse){ - CFE_SB.StatTlmMsg.Payload.PeakSBBuffersInUse = CFE_SB.StatTlmMsg.Payload.SBBuffersInUse; + CFE_SB_Global.StatTlmMsg.Payload.SBBuffersInUse++; + if(CFE_SB_Global.StatTlmMsg.Payload.SBBuffersInUse > CFE_SB_Global.StatTlmMsg.Payload.PeakSBBuffersInUse){ + CFE_SB_Global.StatTlmMsg.Payload.PeakSBBuffersInUse = CFE_SB_Global.StatTlmMsg.Payload.SBBuffersInUse; }/* end if */ /* Add the size of the actual buffer to the memory-in-use ctr and */ /* adjust the high water mark if needed */ - CFE_SB.StatTlmMsg.Payload.MemInUse+=stat1; - if(CFE_SB.StatTlmMsg.Payload.MemInUse > CFE_SB.StatTlmMsg.Payload.PeakMemInUse){ - CFE_SB.StatTlmMsg.Payload.PeakMemInUse = CFE_SB.StatTlmMsg.Payload.MemInUse; + CFE_SB_Global.StatTlmMsg.Payload.MemInUse+=stat1; + if(CFE_SB_Global.StatTlmMsg.Payload.MemInUse > CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse){ + CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse = CFE_SB_Global.StatTlmMsg.Payload.MemInUse; }/* end if */ /* first set ptr to actual msg buffer the same as ptr to descriptor */ @@ -2134,11 +2135,11 @@ CFE_SB_Buffer_t *CFE_SB_ZeroCopyGetPtr(size_t MsgSize, zcd->Next = NULL; /* Add this Zero Copy Descriptor to the end of the chain */ - if(CFE_SB.ZeroCopyTail != NULL){ - ((CFE_SB_ZeroCopyD_t *) CFE_SB.ZeroCopyTail)->Next = (void *)zcd; + if(CFE_SB_Global.ZeroCopyTail != NULL){ + ((CFE_SB_ZeroCopyD_t *) CFE_SB_Global.ZeroCopyTail)->Next = (void *)zcd; } - zcd->Prev = CFE_SB.ZeroCopyTail; - CFE_SB.ZeroCopyTail = (void *)zcd; + zcd->Prev = CFE_SB_Global.ZeroCopyTail; + CFE_SB_Global.ZeroCopyTail = (void *)zcd; CFE_SB_UnlockSharedData(__func__,__LINE__); @@ -2175,11 +2176,11 @@ int32 CFE_SB_ZeroCopyReleasePtr(CFE_SB_Buffer_t *Ptr2Release, if(Status == CFE_SUCCESS){ /* give the buffer back to the buffer pool */ BufAddr = CFE_ES_MEMPOOLBUF_C((cpuaddr)Ptr2Release - sizeof(CFE_SB_BufferD_t)); - Stat2 = CFE_ES_PutPoolBuf(CFE_SB.Mem.PoolHdl, BufAddr); + Stat2 = CFE_ES_PutPoolBuf(CFE_SB_Global.Mem.PoolHdl, BufAddr); if(Stat2 > 0){ /* Substract the size of the actual buffer from the Memory in use ctr */ - CFE_SB.StatTlmMsg.Payload.MemInUse-=Stat2; - CFE_SB.StatTlmMsg.Payload.SBBuffersInUse--; + CFE_SB_Global.StatTlmMsg.Payload.MemInUse-=Stat2; + CFE_SB_Global.StatTlmMsg.Payload.SBBuffersInUse--; }/* end if */ } @@ -2221,7 +2222,7 @@ int32 CFE_SB_ZeroCopyReleaseDesc(CFE_SB_Buffer_t *Ptr2Release, CFE_SB_LockSharedData(__func__,__LINE__); - Stat = CFE_ES_GetPoolBufInfo(CFE_SB.Mem.PoolHdl, zcd); + Stat = CFE_ES_GetPoolBufInfo(CFE_SB_Global.Mem.PoolHdl, zcd); if((Ptr2Release == NULL) || (Stat < 0) || (zcd->Buffer != (void *)Ptr2Release)){ CFE_SB_UnlockSharedData(__func__,__LINE__); @@ -2235,15 +2236,15 @@ int32 CFE_SB_ZeroCopyReleaseDesc(CFE_SB_Buffer_t *Ptr2Release, if(zcd->Next != NULL){ ((CFE_SB_ZeroCopyD_t *) (zcd->Next))->Prev = zcd->Prev; } - if(CFE_SB.ZeroCopyTail == (void *)zcd){ - CFE_SB.ZeroCopyTail = zcd->Prev; + if(CFE_SB_Global.ZeroCopyTail == (void *)zcd){ + CFE_SB_Global.ZeroCopyTail = zcd->Prev; } /* give the descriptor back to the buffer pool */ - Stat = CFE_ES_PutPoolBuf(CFE_SB.Mem.PoolHdl, zcd); + Stat = CFE_ES_PutPoolBuf(CFE_SB_Global.Mem.PoolHdl, zcd); if(Stat > 0){ /* Substract the size of the actual buffer from the Memory in use ctr */ - CFE_SB.StatTlmMsg.Payload.MemInUse-=Stat; + CFE_SB_Global.StatTlmMsg.Payload.MemInUse-=Stat; }/* end if */ CFE_SB_UnlockSharedData(__func__,__LINE__); @@ -2303,7 +2304,7 @@ int32 CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, { /* Increment send error counter for validation failure */ CFE_SB_LockSharedData(__func__, __LINE__); - CFE_SB.HKTlmMsg.Payload.MsgSendErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.MsgSendErrorCounter++; CFE_SB_UnlockSharedData(__func__, __LINE__); } } diff --git a/fsw/cfe-core/src/sb/cfe_sb_buf.c b/fsw/cfe-core/src/sb/cfe_sb_buf.c index 8bb1b7a83..03424e1da 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_buf.c +++ b/fsw/cfe-core/src/sb/cfe_sb_buf.c @@ -63,22 +63,22 @@ CFE_SB_BufferD_t * CFE_SB_GetBufferFromPool(CFE_SB_MsgId_t MsgId, size_t Size) { CFE_SB_BufferD_t *bd = NULL; /* Allocate a new buffer descriptor from the SB memory pool.*/ - stat1 = CFE_ES_GetPoolBuf((CFE_ES_MemPoolBuf_t*)&bd, CFE_SB.Mem.PoolHdl, Size + sizeof(CFE_SB_BufferD_t)); + stat1 = CFE_ES_GetPoolBuf((CFE_ES_MemPoolBuf_t*)&bd, CFE_SB_Global.Mem.PoolHdl, Size + sizeof(CFE_SB_BufferD_t)); if(stat1 < 0){ return NULL; } /* increment the number of buffers in use and adjust the high water mark if needed */ - CFE_SB.StatTlmMsg.Payload.SBBuffersInUse++; - if(CFE_SB.StatTlmMsg.Payload.SBBuffersInUse > CFE_SB.StatTlmMsg.Payload.PeakSBBuffersInUse){ - CFE_SB.StatTlmMsg.Payload.PeakSBBuffersInUse = CFE_SB.StatTlmMsg.Payload.SBBuffersInUse; + CFE_SB_Global.StatTlmMsg.Payload.SBBuffersInUse++; + if(CFE_SB_Global.StatTlmMsg.Payload.SBBuffersInUse > CFE_SB_Global.StatTlmMsg.Payload.PeakSBBuffersInUse){ + CFE_SB_Global.StatTlmMsg.Payload.PeakSBBuffersInUse = CFE_SB_Global.StatTlmMsg.Payload.SBBuffersInUse; }/* end if */ /* Add the size of the actual buffer to the memory-in-use ctr and */ /* adjust the high water mark if needed */ - CFE_SB.StatTlmMsg.Payload.MemInUse+=stat1; - if(CFE_SB.StatTlmMsg.Payload.MemInUse > CFE_SB.StatTlmMsg.Payload.PeakMemInUse){ - CFE_SB.StatTlmMsg.Payload.PeakMemInUse = CFE_SB.StatTlmMsg.Payload.MemInUse; + CFE_SB_Global.StatTlmMsg.Payload.MemInUse+=stat1; + if(CFE_SB_Global.StatTlmMsg.Payload.MemInUse > CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse){ + CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse = CFE_SB_Global.StatTlmMsg.Payload.MemInUse; }/* end if */ /* first set ptr to actual msg buffer the same as ptr to descriptor */ @@ -144,11 +144,11 @@ int32 CFE_SB_ReturnBufferToPool(CFE_SB_BufferD_t *bd){ int32 Stat; /* give the buf descriptor back to the buf descriptor pool */ - Stat = CFE_ES_PutPoolBuf(CFE_SB.Mem.PoolHdl, bd); + Stat = CFE_ES_PutPoolBuf(CFE_SB_Global.Mem.PoolHdl, bd); if(Stat > 0){ - CFE_SB.StatTlmMsg.Payload.SBBuffersInUse--; + CFE_SB_Global.StatTlmMsg.Payload.SBBuffersInUse--; /* Substract the size of a buffer descriptor from the Memory in use ctr */ - CFE_SB.StatTlmMsg.Payload.MemInUse-=Stat; + CFE_SB_Global.StatTlmMsg.Payload.MemInUse-=Stat; }/* end if */ return CFE_SUCCESS; @@ -236,16 +236,16 @@ CFE_SB_DestinationD_t *CFE_SB_GetDestinationBlk(void) CFE_SB_DestinationD_t *Dest = NULL; /* Allocate a new destination descriptor from the SB memory pool.*/ - Stat = CFE_ES_GetPoolBuf((CFE_ES_MemPoolBuf_t*)&Dest, CFE_SB.Mem.PoolHdl, sizeof(CFE_SB_DestinationD_t)); + Stat = CFE_ES_GetPoolBuf((CFE_ES_MemPoolBuf_t*)&Dest, CFE_SB_Global.Mem.PoolHdl, sizeof(CFE_SB_DestinationD_t)); if(Stat < 0){ return NULL; } /* Add the size of a destination descriptor to the memory-in-use ctr and */ /* adjust the high water mark if needed */ - CFE_SB.StatTlmMsg.Payload.MemInUse+=Stat; - if(CFE_SB.StatTlmMsg.Payload.MemInUse > CFE_SB.StatTlmMsg.Payload.PeakMemInUse){ - CFE_SB.StatTlmMsg.Payload.PeakMemInUse = CFE_SB.StatTlmMsg.Payload.MemInUse; + CFE_SB_Global.StatTlmMsg.Payload.MemInUse+=Stat; + if(CFE_SB_Global.StatTlmMsg.Payload.MemInUse > CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse){ + CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse = CFE_SB_Global.StatTlmMsg.Payload.MemInUse; }/* end if */ return Dest; @@ -274,10 +274,10 @@ int32 CFE_SB_PutDestinationBlk(CFE_SB_DestinationD_t *Dest) }/* end if */ /* give the destination block back to the SB memory pool */ - Stat = CFE_ES_PutPoolBuf(CFE_SB.Mem.PoolHdl, Dest); + Stat = CFE_ES_PutPoolBuf(CFE_SB_Global.Mem.PoolHdl, Dest); if(Stat > 0){ /* Substract the size of the destination block from the Memory in use ctr */ - CFE_SB.StatTlmMsg.Payload.MemInUse-=Stat; + CFE_SB_Global.StatTlmMsg.Payload.MemInUse-=Stat; }/* end if */ return CFE_SUCCESS; diff --git a/fsw/cfe-core/src/sb/cfe_sb_init.c b/fsw/cfe-core/src/sb/cfe_sb_init.c index 1ddd99e66..97a4339d4 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_init.c +++ b/fsw/cfe-core/src/sb/cfe_sb_init.c @@ -40,6 +40,7 @@ #include "cfe_psp.h" #include "cfe_error.h" #include "cfe_sb_events.h" +#include "private/cfe_core_resourceid_basevalues.h" #include @@ -87,20 +88,17 @@ int32 CFE_SB_EarlyInit (void) { int32 Stat; - /* ensure entire CFE_SB global data structure is purged first */ - memset(&CFE_SB, 0, sizeof(CFE_SB)); + /* Clear task global */ + memset(&CFE_SB_Global, 0, sizeof(CFE_SB_Global)); - CFE_SB_Default_Qos.Priority = CFE_SB_QOS_LOW_PRIORITY; - CFE_SB_Default_Qos.Reliability = CFE_SB_QOS_LOW_RELIABILITY; - - Stat = OS_MutSemCreate(&CFE_SB.SharedDataMutexId, "CFE_SB_DataMutex", 0); + Stat = OS_MutSemCreate(&CFE_SB_Global.SharedDataMutexId, "CFE_SB_DataMutex", 0); if(Stat != OS_SUCCESS){ CFE_ES_WriteToSysLog("SB shared data mutex creation failed! RC=0x%08x\n",(unsigned int)Stat); return Stat; }/* end if */ /* Initialize the state of susbcription reporting */ - CFE_SB.SubscriptionReporting = CFE_SB_DISABLE; + CFE_SB_Global.SubscriptionReporting = CFE_SB_DISABLE; /* Initialize memory partition. */ Stat = CFE_SB_InitBuffers(); @@ -116,11 +114,11 @@ int32 CFE_SB_EarlyInit (void) { CFE_SBR_Init(); /* Initialize the SB Statistics Pkt */ - CFE_MSG_Init(&CFE_SB.StatTlmMsg.Hdr.Msg, + CFE_MSG_Init(&CFE_SB_Global.StatTlmMsg.Hdr.Msg, CFE_SB_ValueToMsgId(CFE_SB_STATS_TLM_MID), - sizeof(CFE_SB.StatTlmMsg)); + sizeof(CFE_SB_Global.StatTlmMsg)); - CFE_SB.ZeroCopyTail = NULL; + CFE_SB_Global.ZeroCopyTail = NULL; return Stat; @@ -146,8 +144,8 @@ int32 CFE_SB_InitBuffers(void) { int32 Stat = 0; - Stat = CFE_ES_PoolCreateEx(&CFE_SB.Mem.PoolHdl, - CFE_SB.Mem.Partition.Data, + 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], @@ -155,7 +153,7 @@ int32 CFE_SB_InitBuffers(void) { if(Stat != CFE_SUCCESS){ CFE_ES_WriteToSysLog("PoolCreate failed for SB Buffers, gave adr 0x%lx,size %d,stat=0x%x\n", - (unsigned long)CFE_SB.Mem.Partition.Data,CFE_PLATFORM_SB_BUF_MEMORY_BYTES,(unsigned int)Stat); + (unsigned long)CFE_SB_Global.Mem.Partition.Data,CFE_PLATFORM_SB_BUF_MEMORY_BYTES,(unsigned int)Stat); return Stat; } @@ -180,7 +178,7 @@ int32 CFE_SB_InitBuffers(void) { */ void CFE_SB_InitPipeTbl(void) { - CFE_SB.LastPipeId = CFE_ES_ResourceID_FromInteger(CFE_SB_PIPEID_BASE); + CFE_SB_Global.LastPipeId = CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE); }/* end CFE_SB_InitPipeTbl */ diff --git a/fsw/cfe-core/src/sb/cfe_sb_priv.c b/fsw/cfe-core/src/sb/cfe_sb_priv.c index 71aa77d78..2a67924aa 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_priv.c +++ b/fsw/cfe-core/src/sb/cfe_sb_priv.c @@ -98,14 +98,14 @@ ** Return: ** None */ -int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId) { uint32 i; uint32 DelCount; CFE_SB_PipeD_t *PipeDscPtr; CFE_SB_PipeId_t DelList[CFE_PLATFORM_SB_MAX_PIPES]; - PipeDscPtr = CFE_SB.PipeTbl; + PipeDscPtr = CFE_SB_Global.PipeTbl; DelCount = 0; CFE_SB_LockSharedData(__func__,__LINE__); @@ -114,7 +114,7 @@ int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId) for (i = 0; i < CFE_PLATFORM_SB_MAX_PIPES; ++i) { if (CFE_SB_PipeDescIsUsed(PipeDscPtr) && - CFE_ES_ResourceID_Equal(PipeDscPtr->AppId, AppId)) + CFE_RESOURCEID_TEST_EQUAL(PipeDscPtr->AppId, AppId)) { DelList[DelCount] = CFE_SB_PipeDescGetID(PipeDscPtr); ++DelCount; @@ -154,15 +154,15 @@ int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId) void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber){ int32 Status; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; - Status = OS_MutSemTake(CFE_SB.SharedDataMutexId); + Status = OS_MutSemTake(CFE_SB_Global.SharedDataMutexId); if (Status != OS_SUCCESS) { CFE_ES_GetAppID(&AppId); CFE_ES_WriteToSysLog("SB SharedData Mutex Take Err Stat=0x%x,App=%lu,Func=%s,Line=%d\n", - (unsigned int)Status,CFE_ES_ResourceID_ToInteger(AppId),FuncName,(int)LineNumber); + (unsigned int)Status,CFE_RESOURCEID_TO_ULONG(AppId),FuncName,(int)LineNumber); }/* end if */ @@ -189,15 +189,15 @@ void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber){ void CFE_SB_UnlockSharedData(const char *FuncName, int32 LineNumber){ int32 Status; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; - Status = OS_MutSemGive(CFE_SB.SharedDataMutexId); + Status = OS_MutSemGive(CFE_SB_Global.SharedDataMutexId); if (Status != OS_SUCCESS) { CFE_ES_GetAppID(&AppId); CFE_ES_WriteToSysLog("SB SharedData Mutex Give Err Stat=0x%x,App=%lu,Func=%s,Line=%d\n", - (unsigned int)Status,CFE_ES_ResourceID_ToInteger(AppId),FuncName,(int)LineNumber); + (unsigned int)Status,CFE_RESOURCEID_TO_ULONG(AppId),FuncName,(int)LineNumber); }/* end if */ @@ -218,7 +218,7 @@ CFE_SB_DestinationD_t *CFE_SB_GetDestPtr(CFE_SBR_RouteId_t RouteId, CFE_SB_PipeI /* Check all destinations */ while(destptr != NULL) { - if( CFE_ES_ResourceID_Equal(destptr->PipeId, PipeId) ) + if( CFE_RESOURCEID_TEST_EQUAL(destptr->PipeId, PipeId) ) { break; } @@ -287,7 +287,7 @@ CFE_SB_PipeD_t *CFE_SB_LocatePipeDescByID(CFE_SB_PipeId_t PipeId) if (CFE_SB_PipeId_ToIndex(PipeId, &Idx) == CFE_SUCCESS) { - PipeDscPtr = &CFE_SB.PipeTbl[Idx]; + PipeDscPtr = &CFE_SB_Global.PipeTbl[Idx]; } else { @@ -303,9 +303,9 @@ CFE_SB_PipeD_t *CFE_SB_LocatePipeDescByID(CFE_SB_PipeId_t PipeId) * * Checks if a table slot is used or not (helper for allocating IDs) */ -bool CFE_SB_CheckPipeDescSlotUsed(CFE_SB_PipeId_t CheckId) +bool CFE_SB_CheckPipeDescSlotUsed(CFE_ResourceId_t CheckId) { - return CFE_SB_PipeDescIsUsed(CFE_SB_LocatePipeDescByID(CheckId)); + return CFE_SB_PipeDescIsUsed(CFE_SB_LocatePipeDescByID(CFE_SB_PIPEID_C(CheckId))); } /****************************************************************************** @@ -324,7 +324,7 @@ bool CFE_SB_CheckPipeDescSlotUsed(CFE_SB_PipeId_t CheckId) ** Note: With taskId, Parent App name and Child Task name can be queried from ES ** */ -char *CFE_SB_GetAppTskName(CFE_ES_ResourceID_t TaskId,char *FullName){ +char *CFE_SB_GetAppTskName(CFE_ES_TaskId_t TaskId,char *FullName){ CFE_ES_TaskInfo_t TaskInfo; CFE_ES_TaskInfo_t *ptr = &TaskInfo; @@ -374,7 +374,7 @@ char *CFE_SB_GetAppTskName(CFE_ES_ResourceID_t TaskId,char *FullName){ ** If the bit is set this function will return CFE_SB_DENIED. ** If bit is not set, this function set the bit and return CFE_SB_GRANTED. */ -uint32 CFE_SB_RequestToSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit){ +uint32 CFE_SB_RequestToSendEvent(CFE_ES_TaskId_t TaskId, uint32 Bit){ uint32 Indx; @@ -384,14 +384,14 @@ uint32 CFE_SB_RequestToSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit){ } /* if bit is set... */ - if(CFE_TST(CFE_SB.StopRecurseFlags[Indx],Bit)) + if(CFE_TST(CFE_SB_Global.StopRecurseFlags[Indx],Bit)) { return CFE_SB_DENIED; }else{ - CFE_SET(CFE_SB.StopRecurseFlags[Indx],Bit); + CFE_SET(CFE_SB_Global.StopRecurseFlags[Indx],Bit); return CFE_SB_GRANTED; }/* end if */ @@ -411,7 +411,7 @@ uint32 CFE_SB_RequestToSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit){ ** If the bit is set this function will return CFE_SB_DENIED. ** If bit is not set, this function set the bit and return CFE_SB_GRANTED. */ -void CFE_SB_FinishSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit){ +void CFE_SB_FinishSendEvent(CFE_ES_TaskId_t TaskId, uint32 Bit){ uint32 Indx; @@ -421,7 +421,7 @@ void CFE_SB_FinishSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit){ } /* clear the bit so the task may send this event again */ - CFE_CLR(CFE_SB.StopRecurseFlags[Indx],Bit); + CFE_CLR(CFE_SB_Global.StopRecurseFlags[Indx],Bit); }/* end CFE_SB_RequestToSendEvent */ /****************************************************************************** @@ -466,7 +466,7 @@ void CFE_SB_RemoveDest(CFE_SBR_RouteId_t RouteId, CFE_SB_DestinationD_t *DestPtr { CFE_SB_RemoveDestNode(RouteId, DestPtr); CFE_SB_PutDestinationBlk(DestPtr); - CFE_SB.StatTlmMsg.Payload.SubscriptionsInUse--; + CFE_SB_Global.StatTlmMsg.Payload.SubscriptionsInUse--; } /****************************************************************************** @@ -533,14 +533,14 @@ void CFE_SB_RemoveDestNode(CFE_SBR_RouteId_t RouteId, CFE_SB_DestinationD_t *Nod ** Status ** ******************************************************************************/ -int32 CFE_SB_ZeroCopyReleaseAppId(CFE_ES_ResourceID_t AppId) +int32 CFE_SB_ZeroCopyReleaseAppId(CFE_ES_AppId_t AppId) { CFE_SB_ZeroCopyD_t *prev = NULL; - CFE_SB_ZeroCopyD_t *zcd = (CFE_SB_ZeroCopyD_t *) (CFE_SB.ZeroCopyTail); + CFE_SB_ZeroCopyD_t *zcd = (CFE_SB_ZeroCopyD_t *) (CFE_SB_Global.ZeroCopyTail); while(zcd != NULL){ prev = (CFE_SB_ZeroCopyD_t *) (zcd->Prev); - if( CFE_ES_ResourceID_Equal(zcd->AppID, AppId) ) + if( CFE_RESOURCEID_TEST_EQUAL(zcd->AppID, AppId) ) { CFE_SB_ZeroCopyReleasePtr((CFE_SB_Buffer_t *) zcd->Buffer, (CFE_SB_ZeroCopyHandle_t) zcd); } diff --git a/fsw/cfe-core/src/sb/cfe_sb_priv.h b/fsw/cfe-core/src/sb/cfe_sb_priv.h index 367cdf305..23abe02ec 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_priv.h +++ b/fsw/cfe-core/src/sb/cfe_sb_priv.h @@ -43,7 +43,6 @@ #include "cfe_time.h" #include "cfe_es.h" #include "private/cfe_sbr.h" -#include "private/cfe_resourceid_internal.h" /* ** Macro Definitions @@ -60,8 +59,8 @@ #define CFE_SB_INACTIVE 0 #define CFE_SB_ACTIVE 1 -#define CFE_SB_GLOBAL 0 -#define CFE_SB_LOCAL 1 +#define CFE_SB_MSG_GLOBAL 0 +#define CFE_SB_MSG_LOCAL 1 #define CFE_SB_SEND_ZEROCOPY 0 #define CFE_SB_SEND_ONECOPY 1 @@ -83,9 +82,6 @@ #define CFE_SB_CMD_PIPE_NAME "SB_CMD_PIPE" #define CFE_SB_MAX_CFG_FILE_EVENTS_TO_FILTER 8 -#define CFE_SB_QOS_LOW_PRIORITY 0 -#define CFE_SB_QOS_LOW_RELIABILITY 0 - #define CFE_SB_PIPE_OVERFLOW (-1) #define CFE_SB_PIPE_WR_ERR (-2) #define CFE_SB_USECNT_ERR (-3) @@ -132,7 +128,7 @@ typedef struct { */ typedef struct { - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; size_t Size; void *Buffer; void *Next; @@ -151,7 +147,7 @@ typedef struct { CFE_SB_PipeId_t PipeId; uint8 Opts; uint8 Spare; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; osal_id_t SysQueueId; uint16 QueueDepth; uint16 SendErrors; @@ -175,7 +171,7 @@ typedef struct { /****************************************************************************** -** Typedef: cfe_sb_t +** Typedef: CFE_SB_Global_t ** ** Purpose: ** This structure contains the SB global variables. @@ -184,7 +180,7 @@ typedef struct { osal_id_t SharedDataMutexId; uint32 SubscriptionReporting; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; uint32 StopRecurseFlags[OS_MAX_TASKS]; void *ZeroCopyTail; CFE_SB_PipeD_t PipeTbl[CFE_PLATFORM_SB_MAX_PIPES]; @@ -194,8 +190,9 @@ typedef struct CFE_SB_MemParams_t Mem; CFE_SB_AllSubscriptionsTlm_t PrevSubMsg; CFE_EVS_BinFilter_t EventFilters[CFE_SB_MAX_CFG_FILE_EVENTS_TO_FILTER]; - CFE_SB_PipeId_t LastPipeId; -} cfe_sb_t; + CFE_SB_Qos_t Default_Qos; + CFE_ResourceId_t LastPipeId; +} CFE_SB_Global_t; /****************************************************************************** @@ -241,11 +238,11 @@ int32 CFE_SB_ReturnBufferToPool(CFE_SB_BufferD_t *bd); void CFE_SB_ProcessCmdPipePkt(CFE_SB_Buffer_t *SBBufPtr); void CFE_SB_ResetCounters(void); void CFE_SB_SetMsgSeqCnt(CFE_MSG_Message_t *MsgPtr,uint32 Count); -char *CFE_SB_GetAppTskName(CFE_ES_ResourceID_t TaskId, char* FullName); +char *CFE_SB_GetAppTskName(CFE_ES_TaskId_t TaskId, char* FullName); 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); -int32 CFE_SB_DeletePipeWithAppId(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId); -int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId); +int32 CFE_SB_DeletePipeWithAppId(CFE_SB_PipeId_t PipeId,CFE_ES_AppId_t AppId); +int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_AppId_t AppId); int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Quality, @@ -253,10 +250,10 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, uint8 Scope); int32 CFE_SB_UnsubscribeWithAppId(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, - CFE_ES_ResourceID_t AppId); + CFE_ES_AppId_t AppId); int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, - uint8 Scope, CFE_ES_ResourceID_t AppId); + uint8 Scope, CFE_ES_AppId_t AppId); int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_t RouteId, CFE_SB_MsgId_t MsgId); @@ -264,11 +261,11 @@ int32 CFE_SB_TransmitMsgValidate(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t *MsgIdPtr, CFE_MSG_Size_t *SizePtr, CFE_SBR_RouteId_t *RouteIdPtr); -int32 CFE_SB_SendRtgInfo(const char *Filename); -int32 CFE_SB_SendPipeInfo(const char *Filename); -int32 CFE_SB_SendMapInfo(const char *Filename); +int32 CFE_SB_WriteRtgInfo(const char *Filename); +int32 CFE_SB_WritePipeInfo(const char *Filename); +int32 CFE_SB_WriteMapInfo(const char *Filename); int32 CFE_SB_ZeroCopyReleaseDesc(CFE_SB_Buffer_t *Ptr2Release, CFE_SB_ZeroCopyHandle_t BufferHandle); -int32 CFE_SB_ZeroCopyReleaseAppId(CFE_ES_ResourceID_t AppId); +int32 CFE_SB_ZeroCopyReleaseAppId(CFE_ES_AppId_t AppId); void CFE_SB_IncrBufUseCnt(CFE_SB_BufferD_t *bd); void CFE_SB_DecrBufUseCnt(CFE_SB_BufferD_t *bd); int32 CFE_SB_ValidateMsgId(CFE_SB_MsgId_t MsgId); @@ -277,8 +274,8 @@ void CFE_SB_IncrCmdCtr(int32 status); void CFE_SB_FileWriteByteCntErr(const char *Filename,uint32 Requested,uint32 Actual); void CFE_SB_SetSubscriptionReporting(uint32 state); int32 CFE_SB_SendSubscriptionReport(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Quality); -uint32 CFE_SB_RequestToSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit); -void CFE_SB_FinishSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit); +uint32 CFE_SB_RequestToSendEvent(CFE_ES_TaskId_t TaskId, uint32 Bit); +void CFE_SB_FinishSendEvent(CFE_ES_TaskId_t TaskId, uint32 Bit); CFE_SB_DestinationD_t *CFE_SB_GetDestinationBlk(void); int32 CFE_SB_PutDestinationBlk(CFE_SB_DestinationD_t *Dest); @@ -369,9 +366,9 @@ int32 CFE_SB_SendHKTlmCmd(const CFE_MSG_CommandHeader_t *data); int32 CFE_SB_EnableRouteCmd(const CFE_SB_EnableRouteCmd_t *data); int32 CFE_SB_DisableRouteCmd(const CFE_SB_DisableRouteCmd_t *data); int32 CFE_SB_SendStatsCmd(const CFE_SB_SendSbStatsCmd_t *data); -int32 CFE_SB_SendRoutingInfoCmd(const CFE_SB_SendRoutingInfoCmd_t *data); -int32 CFE_SB_SendPipeInfoCmd(const CFE_SB_SendPipeInfoCmd_t *data); -int32 CFE_SB_SendMapInfoCmd(const CFE_SB_SendMapInfoCmd_t *data); +int32 CFE_SB_WriteRoutingInfoCmd(const CFE_SB_WriteRoutingInfoCmd_t *data); +int32 CFE_SB_WritePipeInfoCmd(const CFE_SB_WritePipeInfoCmd_t *data); +int32 CFE_SB_WriteMapInfoCmd(const CFE_SB_WriteMapInfoCmd_t *data); int32 CFE_SB_SendPrevSubsCmd(const CFE_SB_SendPrevSubsCmd_t *data); @@ -402,7 +399,7 @@ extern CFE_SB_PipeD_t* CFE_SB_LocatePipeDescByID(CFE_SB_PipeId_t PipeId); */ static inline bool CFE_SB_PipeDescIsUsed(const CFE_SB_PipeD_t *PipeDscPtr) { - return CFE_ES_ResourceID_IsDefined(PipeDscPtr->PipeId); + return CFE_RESOURCEID_TEST_DEFINED(PipeDscPtr->PipeId); } /** @@ -430,9 +427,9 @@ static inline CFE_SB_PipeId_t CFE_SB_PipeDescGetID(const CFE_SB_PipeD_t *PipeDsc * @param[in] PipeDscPtr pointer to Pipe table entry * @param[in] PipeID the Pipe ID of this entry */ -static inline void CFE_SB_PipeDescSetUsed(CFE_SB_PipeD_t *PipeDscPtr, CFE_SB_PipeId_t PipeID) +static inline void CFE_SB_PipeDescSetUsed(CFE_SB_PipeD_t *PipeDscPtr, CFE_ResourceId_t PendingID) { - PipeDscPtr->PipeId = PipeID; + PipeDscPtr->PipeId = CFE_SB_PIPEID_C(PendingID); } /** @@ -466,18 +463,18 @@ static inline void CFE_SB_PipeDescSetFree(CFE_SB_PipeD_t *PipeDscPtr) */ static inline bool CFE_SB_PipeDescIsMatch(const CFE_SB_PipeD_t *PipeDscPtr, CFE_SB_PipeId_t PipeID) { - return (PipeDscPtr != NULL && CFE_ES_ResourceID_Equal(PipeDscPtr->PipeId, PipeID)); + return (PipeDscPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(PipeDscPtr->PipeId, PipeID)); } -/* Availability check functions used in conjunction with CFE_ES_FindNextAvailableId() */ -bool CFE_SB_CheckPipeDescSlotUsed(CFE_SB_PipeId_t CheckId); +/* Availability check functions used in conjunction with CFE_ResourceId_FindNext() */ +bool CFE_SB_CheckPipeDescSlotUsed(CFE_ResourceId_t CheckId); /* * External variables private to the software bus module */ -extern cfe_sb_t CFE_SB; +extern CFE_SB_Global_t CFE_SB_Global; #endif /* _cfe_sb_priv_ */ /*****************************************************************************/ diff --git a/fsw/cfe-core/src/sb/cfe_sb_task.c b/fsw/cfe-core/src/sb/cfe_sb_task.c index 1c09a6fe8..623b5d205 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_task.c +++ b/fsw/cfe-core/src/sb/cfe_sb_task.c @@ -45,8 +45,7 @@ #include /* Task Globals */ -cfe_sb_t CFE_SB; -CFE_SB_Qos_t CFE_SB_Default_Qos; +CFE_SB_Global_t CFE_SB_Global; /* Local structure for file writing callbacks */ typedef struct @@ -105,7 +104,7 @@ void CFE_SB_TaskMain(void) /* Pend on receipt of packet */ Status = CFE_SB_ReceiveBuffer(&SBBufPtr, - CFE_SB.CmdPipe, + CFE_SB_Global.CmdPipe, CFE_SB_PEND_FOREVER); CFE_ES_PerfLogEntry(CFE_MISSION_SB_MAIN_PERF_ID); @@ -156,54 +155,54 @@ int32 CFE_SB_AppInit(void){ }/* end if */ /* Get the assigned Application ID for the SB Task */ - CFE_ES_GetAppID(&CFE_SB.AppId); + CFE_ES_GetAppID(&CFE_SB_Global.AppId); /* Process the platform cfg file events to be filtered */ if(CFE_PLATFORM_SB_FILTERED_EVENT1 != 0){ - CFE_SB.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT1; - CFE_SB.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK1; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT1; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK1; CfgFileEventsToFilter++; }/* end if */ if(CFE_PLATFORM_SB_FILTERED_EVENT2 != 0){ - CFE_SB.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT2; - CFE_SB.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK2; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT2; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK2; CfgFileEventsToFilter++; }/* end if */ if(CFE_PLATFORM_SB_FILTERED_EVENT3 != 0){ - CFE_SB.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT3; - CFE_SB.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK3; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT3; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK3; CfgFileEventsToFilter++; }/* end if */ if(CFE_PLATFORM_SB_FILTERED_EVENT4 != 0){ - CFE_SB.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT4; - CFE_SB.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK4; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT4; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK4; CfgFileEventsToFilter++; }/* end if */ if(CFE_PLATFORM_SB_FILTERED_EVENT5 != 0){ - CFE_SB.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT5; - CFE_SB.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK5; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT5; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK5; CfgFileEventsToFilter++; }/* end if */ if(CFE_PLATFORM_SB_FILTERED_EVENT6 != 0){ - CFE_SB.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT6; - CFE_SB.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK6; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT6; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK6; CfgFileEventsToFilter++; }/* end if */ if(CFE_PLATFORM_SB_FILTERED_EVENT7 != 0){ - CFE_SB.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT7; - CFE_SB.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK7; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT7; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK7; CfgFileEventsToFilter++; }/* end if */ if(CFE_PLATFORM_SB_FILTERED_EVENT8 != 0){ - CFE_SB.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT8; - CFE_SB.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK8; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].EventID = CFE_PLATFORM_SB_FILTERED_EVENT8; + CFE_SB_Global.EventFilters[CfgFileEventsToFilter].Mask = CFE_PLATFORM_SB_FILTER_MASK8; CfgFileEventsToFilter++; }/* end if */ @@ -215,7 +214,7 @@ int32 CFE_SB_AppInit(void){ /* Register event filter table... */ - Status = CFE_EVS_Register(CFE_SB.EventFilters, + Status = CFE_EVS_Register(CFE_SB_Global.EventFilters, CfgFileEventsToFilter, CFE_EVS_EventFilter_BINARY); if(Status != CFE_SUCCESS){ @@ -225,26 +224,26 @@ int32 CFE_SB_AppInit(void){ CFE_ES_WriteToSysLog("SB:Registered %d events for filtering\n",(int)CfgFileEventsToFilter); - CFE_MSG_Init(&CFE_SB.HKTlmMsg.Hdr.Msg, + CFE_MSG_Init(&CFE_SB_Global.HKTlmMsg.Hdr.Msg, CFE_SB_ValueToMsgId(CFE_SB_HK_TLM_MID), - sizeof(CFE_SB.HKTlmMsg)); + sizeof(CFE_SB_Global.HKTlmMsg)); - CFE_MSG_Init(&CFE_SB.PrevSubMsg.Hdr.Msg, + CFE_MSG_Init(&CFE_SB_Global.PrevSubMsg.Hdr.Msg, CFE_SB_ValueToMsgId(CFE_SB_ALLSUBS_TLM_MID), - sizeof(CFE_SB.PrevSubMsg)); + sizeof(CFE_SB_Global.PrevSubMsg)); /* Populate the fixed fields in the HK Tlm Msg */ - CFE_SB.HKTlmMsg.Payload.MemPoolHandle = CFE_SB.Mem.PoolHdl; + CFE_SB_Global.HKTlmMsg.Payload.MemPoolHandle = CFE_SB_Global.Mem.PoolHdl; /* Populate the fixed fields in the Stat Tlm Msg */ - CFE_SB.StatTlmMsg.Payload.MaxMsgIdsAllowed = CFE_PLATFORM_SB_MAX_MSG_IDS; - CFE_SB.StatTlmMsg.Payload.MaxPipesAllowed = CFE_PLATFORM_SB_MAX_PIPES; - CFE_SB.StatTlmMsg.Payload.MaxMemAllowed = CFE_PLATFORM_SB_BUF_MEMORY_BYTES; - CFE_SB.StatTlmMsg.Payload.MaxPipeDepthAllowed = CFE_PLATFORM_SB_MAX_PIPE_DEPTH; - CFE_SB.StatTlmMsg.Payload.MaxSubscriptionsAllowed = + CFE_SB_Global.StatTlmMsg.Payload.MaxMsgIdsAllowed = CFE_PLATFORM_SB_MAX_MSG_IDS; + CFE_SB_Global.StatTlmMsg.Payload.MaxPipesAllowed = CFE_PLATFORM_SB_MAX_PIPES; + CFE_SB_Global.StatTlmMsg.Payload.MaxMemAllowed = CFE_PLATFORM_SB_BUF_MEMORY_BYTES; + CFE_SB_Global.StatTlmMsg.Payload.MaxPipeDepthAllowed = OS_QUEUE_MAX_DEPTH; + CFE_SB_Global.StatTlmMsg.Payload.MaxSubscriptionsAllowed = ((CFE_PLATFORM_SB_MAX_MSG_IDS)*(CFE_PLATFORM_SB_MAX_DEST_PER_PKT)); - Status = CFE_SB_CreatePipe(&CFE_SB.CmdPipe, + Status = CFE_SB_CreatePipe(&CFE_SB_Global.CmdPipe, CFE_SB_CMD_PIPE_DEPTH, CFE_SB_CMD_PIPE_NAME); if(Status != CFE_SUCCESS){ @@ -252,21 +251,21 @@ int32 CFE_SB_AppInit(void){ return Status; }/* end if */ - Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_SB_CMD_MID),CFE_SB.CmdPipe); + Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_SB_CMD_MID),CFE_SB_Global.CmdPipe); if(Status != CFE_SUCCESS){ CFE_ES_WriteToSysLog("SB:Subscribe to Cmds Failed:RC=0x%08X\n",(unsigned int)Status); return Status; }/* end if */ - Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_SB_SEND_HK_MID),CFE_SB.CmdPipe); + Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_SB_SEND_HK_MID),CFE_SB_Global.CmdPipe); if(Status != CFE_SUCCESS){ CFE_ES_WriteToSysLog("SB:Subscribe to HK Request Failed:RC=0x%08X\n",(unsigned int)Status); return Status; }/* end if */ - Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_SB_SUB_RPT_CTRL_MID),CFE_SB.CmdPipe); + Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_SB_SUB_RPT_CTRL_MID),CFE_SB_Global.CmdPipe); if(Status != CFE_SUCCESS){ CFE_ES_WriteToSysLog("SB:Subscribe to Subscription Report Request Failed:RC=0x%08X\n",(unsigned int)Status); @@ -275,7 +274,7 @@ int32 CFE_SB_AppInit(void){ /* Ensure a ground commanded reset does not get blocked if SB mem pool */ /* becomes fully configured (DCR6772) */ - Status = CFE_ES_GetPoolBuf(&TmpPtr, CFE_SB.Mem.PoolHdl, + Status = CFE_ES_GetPoolBuf(&TmpPtr, CFE_SB_Global.Mem.PoolHdl, sizeof(CFE_ES_RestartCmd_t)); if(Status < 0){ @@ -285,7 +284,7 @@ int32 CFE_SB_AppInit(void){ /* Return mem block used on previous call,the actual memory is not needed.*/ /* The SB mem pool is now configured with a block size for the reset cmd. */ - Status = CFE_ES_PutPoolBuf(CFE_SB.Mem.PoolHdl, TmpPtr); + Status = CFE_ES_PutPoolBuf(CFE_SB_Global.Mem.PoolHdl, TmpPtr); if(Status < 0){ CFE_ES_WriteToSysLog("SB:Init error, PutPool Failed:RC=0x%08X\n",(unsigned int)Status); @@ -339,7 +338,7 @@ bool CFE_SB_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, (unsigned int)ExpectedLength); result = false; - ++CFE_SB.HKTlmMsg.Payload.CommandErrorCounter; + ++CFE_SB_Global.HKTlmMsg.Payload.CommandErrorCounter; } return(result); @@ -402,7 +401,7 @@ void CFE_SB_ProcessCmdPipePkt(CFE_SB_Buffer_t *SBBufPtr) default: CFE_EVS_SendEvent(CFE_SB_BAD_CMD_CODE_EID,CFE_EVS_EventType_ERROR, "Invalid Cmd, Unexpected Command Code %u", (unsigned int)FcnCode); - CFE_SB.HKTlmMsg.Payload.CommandErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandErrorCounter++; break; } /* end switch on cmd code */ break; @@ -432,10 +431,10 @@ void CFE_SB_ProcessCmdPipePkt(CFE_SB_Buffer_t *SBBufPtr) } break; - case CFE_SB_SEND_ROUTING_INFO_CC: - if (CFE_SB_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CFE_SB_SendRoutingInfoCmd_t))) + case CFE_SB_WRITE_ROUTING_INFO_CC: + if (CFE_SB_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CFE_SB_WriteRoutingInfoCmd_t))) { - CFE_SB_SendRoutingInfoCmd((CFE_SB_SendRoutingInfoCmd_t *)SBBufPtr); + CFE_SB_WriteRoutingInfoCmd((CFE_SB_WriteRoutingInfoCmd_t *)SBBufPtr); } break; @@ -453,24 +452,24 @@ void CFE_SB_ProcessCmdPipePkt(CFE_SB_Buffer_t *SBBufPtr) } break; - case CFE_SB_SEND_PIPE_INFO_CC: - if (CFE_SB_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CFE_SB_SendPipeInfoCmd_t))) + case CFE_SB_WRITE_PIPE_INFO_CC: + if (CFE_SB_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CFE_SB_WritePipeInfoCmd_t))) { - CFE_SB_SendPipeInfoCmd((CFE_SB_SendPipeInfoCmd_t *)SBBufPtr); + CFE_SB_WritePipeInfoCmd((CFE_SB_WritePipeInfoCmd_t *)SBBufPtr); } break; - case CFE_SB_SEND_MAP_INFO_CC: - if (CFE_SB_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CFE_SB_SendMapInfoCmd_t))) + case CFE_SB_WRITE_MAP_INFO_CC: + if (CFE_SB_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CFE_SB_WriteMapInfoCmd_t))) { - CFE_SB_SendMapInfoCmd((CFE_SB_SendMapInfoCmd_t *)SBBufPtr); + CFE_SB_WriteMapInfoCmd((CFE_SB_WriteMapInfoCmd_t *)SBBufPtr); } break; default: CFE_EVS_SendEvent(CFE_SB_BAD_CMD_CODE_EID,CFE_EVS_EventType_ERROR, "Invalid Cmd, Unexpected Command Code %u", FcnCode); - CFE_SB.HKTlmMsg.Payload.CommandErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandErrorCounter++; break; } /* end switch on cmd code */ break; @@ -479,7 +478,7 @@ void CFE_SB_ProcessCmdPipePkt(CFE_SB_Buffer_t *SBBufPtr) CFE_EVS_SendEvent(CFE_SB_BAD_MSGID_EID,CFE_EVS_EventType_ERROR, "Invalid Cmd, Unexpected Msg Id: 0x%x", (unsigned int)CFE_SB_MsgIdToValue(MessageID)); - CFE_SB.HKTlmMsg.Payload.CommandErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandErrorCounter++; break; } /* end switch on MsgId */ @@ -499,7 +498,7 @@ int32 CFE_SB_NoopCmd(const CFE_SB_NoopCmd_t *data) { CFE_EVS_SendEvent(CFE_SB_CMD0_RCVD_EID,CFE_EVS_EventType_INFORMATION, "No-op Cmd Rcvd. %s", CFE_VERSION_STRING); - CFE_SB.HKTlmMsg.Payload.CommandCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandCounter++; return CFE_SUCCESS; } @@ -567,13 +566,13 @@ int32 CFE_SB_SendHKTlmCmd(const CFE_MSG_CommandHeader_t *data) { CFE_SB_LockSharedData(__FILE__, __LINE__); - CFE_SB.HKTlmMsg.Payload.MemInUse = CFE_SB.StatTlmMsg.Payload.MemInUse; - CFE_SB.HKTlmMsg.Payload.UnmarkedMem = CFE_PLATFORM_SB_BUF_MEMORY_BYTES - CFE_SB.StatTlmMsg.Payload.PeakMemInUse; + CFE_SB_Global.HKTlmMsg.Payload.MemInUse = CFE_SB_Global.StatTlmMsg.Payload.MemInUse; + CFE_SB_Global.HKTlmMsg.Payload.UnmarkedMem = CFE_PLATFORM_SB_BUF_MEMORY_BYTES - CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse; CFE_SB_UnlockSharedData(__FILE__, __LINE__); - CFE_SB_TimeStampMsg(&CFE_SB.HKTlmMsg.Hdr.Msg); - CFE_SB_TransmitMsg(&CFE_SB.HKTlmMsg.Hdr.Msg, true); + CFE_SB_TimeStampMsg(&CFE_SB_Global.HKTlmMsg.Hdr.Msg); + CFE_SB_TransmitMsg(&CFE_SB_Global.HKTlmMsg.Hdr.Msg, true); return CFE_SUCCESS; }/* end CFE_SB_SendHKTlmCmd */ @@ -596,17 +595,17 @@ int32 CFE_SB_SendHKTlmCmd(const CFE_MSG_CommandHeader_t *data) */ void CFE_SB_ResetCounters(void){ - CFE_SB.HKTlmMsg.Payload.CommandCounter = 0; - CFE_SB.HKTlmMsg.Payload.CommandErrorCounter = 0; - CFE_SB.HKTlmMsg.Payload.NoSubscribersCounter = 0; - CFE_SB.HKTlmMsg.Payload.DuplicateSubscriptionsCounter = 0; - CFE_SB.HKTlmMsg.Payload.MsgSendErrorCounter = 0; - CFE_SB.HKTlmMsg.Payload.MsgReceiveErrorCounter = 0; - CFE_SB.HKTlmMsg.Payload.InternalErrorCounter = 0; - CFE_SB.HKTlmMsg.Payload.CreatePipeErrorCounter = 0; - CFE_SB.HKTlmMsg.Payload.SubscribeErrorCounter = 0; - CFE_SB.HKTlmMsg.Payload.PipeOverflowErrorCounter = 0; - CFE_SB.HKTlmMsg.Payload.MsgLimitErrorCounter = 0; + CFE_SB_Global.HKTlmMsg.Payload.CommandCounter = 0; + CFE_SB_Global.HKTlmMsg.Payload.CommandErrorCounter = 0; + CFE_SB_Global.HKTlmMsg.Payload.NoSubscribersCounter = 0; + CFE_SB_Global.HKTlmMsg.Payload.DuplicateSubscriptionsCounter = 0; + CFE_SB_Global.HKTlmMsg.Payload.MsgSendErrorCounter = 0; + CFE_SB_Global.HKTlmMsg.Payload.MsgReceiveErrorCounter = 0; + CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter = 0; + CFE_SB_Global.HKTlmMsg.Payload.CreatePipeErrorCounter = 0; + CFE_SB_Global.HKTlmMsg.Payload.SubscribeErrorCounter = 0; + CFE_SB_Global.HKTlmMsg.Payload.PipeOverflowErrorCounter = 0; + CFE_SB_Global.HKTlmMsg.Payload.MsgLimitErrorCounter = 0; }/* end CFE_SB_ResetCounters */ @@ -645,7 +644,7 @@ int32 CFE_SB_EnableRouteCmd(const CFE_SB_EnableRouteCmd_t *data) !CFE_SB_PipeDescIsMatch(PipeDscPtr,CmdPtr->Pipe)) { PendingEventID = CFE_SB_ENBL_RTE3_EID; - CFE_SB.HKTlmMsg.Payload.CommandErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandErrorCounter++; } else { @@ -653,13 +652,13 @@ int32 CFE_SB_EnableRouteCmd(const CFE_SB_EnableRouteCmd_t *data) if(DestPtr == NULL) { PendingEventID = CFE_SB_ENBL_RTE1_EID; - CFE_SB.HKTlmMsg.Payload.CommandErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandErrorCounter++; } else { DestPtr->Active = CFE_SB_ACTIVE; PendingEventID = CFE_SB_ENBL_RTE2_EID; - CFE_SB.HKTlmMsg.Payload.CommandCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandCounter++; } }/* end if */ @@ -672,19 +671,19 @@ int32 CFE_SB_EnableRouteCmd(const CFE_SB_EnableRouteCmd_t *data) CFE_EVS_SendEvent(CFE_SB_ENBL_RTE1_EID,CFE_EVS_EventType_ERROR, "Enbl Route Cmd:Route does not exist.Msg 0x%x,Pipe %lu", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(CmdPtr->Pipe)); + CFE_RESOURCEID_TO_ULONG(CmdPtr->Pipe)); break; case CFE_SB_ENBL_RTE3_EID: CFE_EVS_SendEvent(CFE_SB_ENBL_RTE3_EID,CFE_EVS_EventType_ERROR, "Enbl Route Cmd:Invalid Param.Msg 0x%x,Pipe %lu", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(CmdPtr->Pipe)); + CFE_RESOURCEID_TO_ULONG(CmdPtr->Pipe)); break; case CFE_SB_ENBL_RTE2_EID: CFE_EVS_SendEvent(CFE_SB_ENBL_RTE2_EID,CFE_EVS_EventType_DEBUG, "Enabling Route,Msg 0x%x,Pipe %lu", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(CmdPtr->Pipe)); + CFE_RESOURCEID_TO_ULONG(CmdPtr->Pipe)); break; } @@ -727,7 +726,7 @@ int32 CFE_SB_DisableRouteCmd(const CFE_SB_DisableRouteCmd_t *data) !CFE_SB_PipeDescIsMatch(PipeDscPtr,CmdPtr->Pipe)) { PendingEventID = CFE_SB_DSBL_RTE3_EID; - CFE_SB.HKTlmMsg.Payload.CommandErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandErrorCounter++; } else { @@ -735,13 +734,13 @@ int32 CFE_SB_DisableRouteCmd(const CFE_SB_DisableRouteCmd_t *data) if(DestPtr == NULL) { PendingEventID = CFE_SB_DSBL_RTE1_EID; - CFE_SB.HKTlmMsg.Payload.CommandErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandErrorCounter++; } else { DestPtr->Active = CFE_SB_INACTIVE; PendingEventID = CFE_SB_DSBL_RTE2_EID; - CFE_SB.HKTlmMsg.Payload.CommandCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandCounter++; } }/* end if */ @@ -755,19 +754,19 @@ int32 CFE_SB_DisableRouteCmd(const CFE_SB_DisableRouteCmd_t *data) CFE_EVS_SendEvent(CFE_SB_DSBL_RTE1_EID,CFE_EVS_EventType_ERROR, "Disable Route Cmd:Route does not exist,Msg 0x%x,Pipe %lu", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(CmdPtr->Pipe)); + CFE_RESOURCEID_TO_ULONG(CmdPtr->Pipe)); break; case CFE_SB_DSBL_RTE3_EID: CFE_EVS_SendEvent(CFE_SB_DSBL_RTE3_EID,CFE_EVS_EventType_ERROR, "Disable Route Cmd:Invalid Param.Msg 0x%x,Pipe %lu", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(CmdPtr->Pipe)); + CFE_RESOURCEID_TO_ULONG(CmdPtr->Pipe)); break; case CFE_SB_DSBL_RTE2_EID: CFE_EVS_SendEvent(CFE_SB_DSBL_RTE2_EID,CFE_EVS_EventType_DEBUG, "Route Disabled,Msg 0x%x,Pipe %lu", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(CmdPtr->Pipe)); + CFE_RESOURCEID_TO_ULONG(CmdPtr->Pipe)); break; } @@ -799,8 +798,8 @@ int32 CFE_SB_SendStatsCmd(const CFE_SB_SendSbStatsCmd_t *data) /* Collect data on pipes */ PipeDscCount = CFE_PLATFORM_SB_MAX_PIPES; PipeStatCount = CFE_MISSION_SB_MAX_PIPES; - PipeDscPtr = CFE_SB.PipeTbl; - PipeStatPtr = CFE_SB.StatTlmMsg.Payload.PipeDepthStats; + PipeDscPtr = CFE_SB_Global.PipeTbl; + PipeStatPtr = CFE_SB_Global.StatTlmMsg.Payload.PipeDepthStats; while (PipeDscCount > 0 && PipeStatCount > 0) { @@ -829,107 +828,83 @@ int32 CFE_SB_SendStatsCmd(const CFE_SB_SendSbStatsCmd_t *data) --PipeStatCount; } - CFE_SB_TimeStampMsg(&CFE_SB.StatTlmMsg.Hdr.Msg); - CFE_SB_TransmitMsg(&CFE_SB.StatTlmMsg.Hdr.Msg, true); + CFE_SB_TimeStampMsg(&CFE_SB_Global.StatTlmMsg.Hdr.Msg); + CFE_SB_TransmitMsg(&CFE_SB_Global.StatTlmMsg.Hdr.Msg, true); CFE_EVS_SendEvent(CFE_SB_SND_STATS_EID,CFE_EVS_EventType_DEBUG, "Software Bus Statistics packet sent"); - CFE_SB.HKTlmMsg.Payload.CommandCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandCounter++; return CFE_SUCCESS; }/* CFE_SB_SendStatsCmd */ /****************************************************************************** -** Function: CFE_SB_SendRoutingInfoCmd() -** -** Purpose: -** SB internal function to handle processing of 'Send Routing Info' Cmd -** -** Arguments: -** None -** -** Return: -** None -*/ -int32 CFE_SB_SendRoutingInfoCmd(const CFE_SB_SendRoutingInfoCmd_t *data) + * \brief SB internal function to handle processing of 'Write Routing Info' Cmd + * + * \param[in] data Pointer to command structure + * + * \return Execution status, see \ref CFEReturnCodes + */ +int32 CFE_SB_WriteRoutingInfoCmd(const CFE_SB_WriteRoutingInfoCmd_t *data) { - const CFE_SB_WriteFileInfoCmd_Payload_t *ptr; char LocalFilename[OS_MAX_PATH_LEN]; int32 Stat; - ptr = &data->Payload; + CFE_SB_MessageStringGet(LocalFilename, data->Payload.Filename, CFE_PLATFORM_SB_DEFAULT_ROUTING_FILENAME, + sizeof(LocalFilename), sizeof(data->Payload.Filename)); - CFE_SB_MessageStringGet(LocalFilename, ptr->Filename, CFE_PLATFORM_SB_DEFAULT_ROUTING_FILENAME, - sizeof(LocalFilename), sizeof(ptr->Filename)); - - Stat = CFE_SB_SendRtgInfo(LocalFilename); + Stat = CFE_SB_WriteRtgInfo(LocalFilename); CFE_SB_IncrCmdCtr(Stat); return CFE_SUCCESS; -}/* end CFE_SB_SendRoutingInfoCmd */ +} /****************************************************************************** -** Function: CFE_SB_SendPipeInfoCmd() -** -** Purpose: -** SB internal function to handle processing of 'Send Pipe Info' Cmd -** -** Arguments: -** None -** -** Return: -** None -*/ -int32 CFE_SB_SendPipeInfoCmd(const CFE_SB_SendPipeInfoCmd_t *data) + * \brief SB internal function to handle processing of 'Write Pipe Info' Cmd + * + * \param[in] data Pointer to command structure + * + * \return Execution status, see \ref CFEReturnCodes + */ +int32 CFE_SB_WritePipeInfoCmd(const CFE_SB_WritePipeInfoCmd_t *data) { - const CFE_SB_WriteFileInfoCmd_Payload_t *ptr; char LocalFilename[OS_MAX_PATH_LEN]; int32 Stat; - ptr = &data->Payload; + CFE_SB_MessageStringGet(LocalFilename, data->Payload.Filename, CFE_PLATFORM_SB_DEFAULT_PIPE_FILENAME, + sizeof(LocalFilename), sizeof(data->Payload.Filename)); - CFE_SB_MessageStringGet(LocalFilename, ptr->Filename, CFE_PLATFORM_SB_DEFAULT_PIPE_FILENAME, - sizeof(LocalFilename), sizeof(ptr->Filename)); - - Stat = CFE_SB_SendPipeInfo(LocalFilename); + Stat = CFE_SB_WritePipeInfo(LocalFilename); CFE_SB_IncrCmdCtr(Stat); return CFE_SUCCESS; -}/* end CFE_SB_SendPipeInfoCmd */ +} /****************************************************************************** -** Function: CFE_SB_SendMapInfoCmd() -** -** Purpose: -** SB internal function to handle processing of 'Send Map Info' Cmd -** -** Arguments: -** None -** -** Return: -** None -*/ -int32 CFE_SB_SendMapInfoCmd(const CFE_SB_SendMapInfoCmd_t *data) + * \brief SB internal function to handle processing of 'Write Map Info' Cmd + * + * \param[in] data Pointer to command structure + * + * \return Execution status, see \ref CFEReturnCodes + */ +int32 CFE_SB_WriteMapInfoCmd(const CFE_SB_WriteMapInfoCmd_t *data) { - const CFE_SB_WriteFileInfoCmd_Payload_t *ptr; char LocalFilename[OS_MAX_PATH_LEN]; int32 Stat; - ptr = &data->Payload; + CFE_SB_MessageStringGet(LocalFilename, data->Payload.Filename, CFE_PLATFORM_SB_DEFAULT_MAP_FILENAME, + sizeof(LocalFilename), sizeof(data->Payload.Filename)); - CFE_SB_MessageStringGet(LocalFilename, ptr->Filename, CFE_PLATFORM_SB_DEFAULT_MAP_FILENAME, - sizeof(LocalFilename), sizeof(ptr->Filename)); - - Stat = CFE_SB_SendMapInfo(LocalFilename); + Stat = CFE_SB_WriteMapInfo(LocalFilename); CFE_SB_IncrCmdCtr(Stat); return CFE_SUCCESS; -}/* end CFE_SB_SendMapInfoCmd */ +} /****************************************************************************** * Local callback helper for writing routing info to a file @@ -1037,7 +1012,7 @@ int32 CFE_SB_SendSubscriptionReport(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId Status = CFE_SUCCESS; - if (CFE_SB.SubscriptionReporting == CFE_SB_ENABLE) + if (CFE_SB_Global.SubscriptionReporting == CFE_SB_ENABLE) { CFE_MSG_Init(&SubRptMsg.Hdr.Msg, CFE_SB_ValueToMsgId(CFE_SB_ONESUB_TLM_MID), @@ -1049,10 +1024,10 @@ int32 CFE_SB_SendSubscriptionReport(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId SubRptMsg.Payload.SubType = CFE_SB_SUBSCRIPTION; Status = CFE_SB_TransmitMsg(&SubRptMsg.Hdr.Msg, true); - CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_RPT_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, + CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_RPT_EID,CFE_EVS_EventType_DEBUG,CFE_SB_Global.AppId, "Sending Subscription Report Msg=0x%x,Pipe=%lu,Stat=0x%x", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(PipeId),(unsigned int)Status); + CFE_RESOURCEID_TO_ULONG(PipeId),(unsigned int)Status); } return Status; @@ -1060,18 +1035,15 @@ int32 CFE_SB_SendSubscriptionReport(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId /****************************************************************************** -** Function: CFE_SB_SendRoutingInfo() -** -** Purpose: -** SB internal function to write the routing information to a file -** -** Arguments: -** Pointer to a filename -** -** Return: -** CFE_SB_FILE_IO_ERR for file I/O errors or CFE_SUCCESS -*/ -int32 CFE_SB_SendRtgInfo(const char *Filename) + * \brief SB internal function to write the routing information to a file + * + * \param[in] Filename Pointer the file name to write + * + * \return Execution status, see \ref CFEReturnCodes + * \retval #CFE_SUCCESS \copybrief CFE_SUCCESS + * \retval #CFE_SB_FILE_IO_ERR \copybrief CFE_SB_FILE_IO_ERR + */ +int32 CFE_SB_WriteRtgInfo(const char *Filename) { CFE_SB_FileWriteCallback_t args = {0}; int32 Status; @@ -1117,22 +1089,19 @@ int32 CFE_SB_SendRtgInfo(const char *Filename) return CFE_SUCCESS; } -}/* end CFE_SB_SendRtgInfo */ +} /****************************************************************************** -** Function: CFE_SB_SendPipeInfo() -** -** Purpose: -** SB internal function to write the Pipe table to a file -** -** Arguments: -** Pointer to a filename -** -** Return: -** CFE_SB_FILE_IO_ERR for file I/O errors or CFE_SUCCESS -*/ -int32 CFE_SB_SendPipeInfo(const char *Filename) + * \brief SB internal function to write the Pipe table to a file + * + * \param[in] Filename Pointer the file name to write + * + * \return Execution status, see \ref CFEReturnCodes + * \retval #CFE_SUCCESS \copybrief CFE_SUCCESS + * \retval #CFE_SB_FILE_IO_ERR \copybrief CFE_SB_FILE_IO_ERR + */ +int32 CFE_SB_WritePipeInfo(const char *Filename) { uint16 i; osal_id_t fd; @@ -1167,7 +1136,7 @@ int32 CFE_SB_SendPipeInfo(const char *Filename) /* loop through the pipe table */ CFE_SB_LockSharedData(__FILE__,__LINE__); - PipeDscPtr = CFE_SB.PipeTbl; + PipeDscPtr = CFE_SB_Global.PipeTbl; for (i=0;iScope == CFE_SB_GLOBAL) + if(destptr->Scope == CFE_SB_MSG_GLOBAL) { /* ...add entry into pkt */ - CFE_SB.PrevSubMsg.Payload.Entry[CFE_SB.PrevSubMsg.Payload.Entries].MsgId = CFE_SBR_GetMsgId(RouteId); - CFE_SB.PrevSubMsg.Payload.Entry[CFE_SB.PrevSubMsg.Payload.Entries].Qos.Priority = 0; - CFE_SB.PrevSubMsg.Payload.Entry[CFE_SB.PrevSubMsg.Payload.Entries].Qos.Reliability = 0; - CFE_SB.PrevSubMsg.Payload.Entries++; + CFE_SB_Global.PrevSubMsg.Payload.Entry[CFE_SB_Global.PrevSubMsg.Payload.Entries].MsgId = CFE_SBR_GetMsgId(RouteId); + CFE_SB_Global.PrevSubMsg.Payload.Entry[CFE_SB_Global.PrevSubMsg.Payload.Entries].Qos.Priority = 0; + CFE_SB_Global.PrevSubMsg.Payload.Entry[CFE_SB_Global.PrevSubMsg.Payload.Entries].Qos.Reliability = 0; + CFE_SB_Global.PrevSubMsg.Payload.Entries++; /* send pkt if full */ - if(CFE_SB.PrevSubMsg.Payload.Entries >= CFE_SB_SUB_ENTRIES_PER_PKT) + if(CFE_SB_Global.PrevSubMsg.Payload.Entries >= CFE_SB_SUB_ENTRIES_PER_PKT) { CFE_SB_UnlockSharedData(__func__,__LINE__); - status = CFE_SB_TransmitMsg(&CFE_SB.PrevSubMsg.Hdr.Msg, true); + status = CFE_SB_TransmitMsg(&CFE_SB_Global.PrevSubMsg.Hdr.Msg, true); CFE_EVS_SendEvent(CFE_SB_FULL_SUB_PKT_EID, CFE_EVS_EventType_DEBUG, "Full Sub Pkt %d Sent,Entries=%d,Stat=0x%x\n", - (int)CFE_SB.PrevSubMsg.Payload.PktSegment, - (int)CFE_SB.PrevSubMsg.Payload.Entries, (unsigned int)status); + (int)CFE_SB_Global.PrevSubMsg.Payload.PktSegment, + (int)CFE_SB_Global.PrevSubMsg.Payload.Entries, (unsigned int)status); CFE_SB_LockSharedData(__func__,__LINE__); - CFE_SB.PrevSubMsg.Payload.Entries = 0; - CFE_SB.PrevSubMsg.Payload.PktSegment++; + CFE_SB_Global.PrevSubMsg.Payload.Entries = 0; + CFE_SB_Global.PrevSubMsg.Payload.PktSegment++; } /* @@ -1399,8 +1364,8 @@ int32 CFE_SB_SendPrevSubsCmd(const CFE_SB_SendPrevSubsCmd_t *data) CFE_SB_LockSharedData(__func__,__LINE__); /* Initialize entry/segment tracking */ - CFE_SB.PrevSubMsg.Payload.PktSegment = 1; - CFE_SB.PrevSubMsg.Payload.Entries = 0; + CFE_SB_Global.PrevSubMsg.Payload.PktSegment = 1; + CFE_SB_Global.PrevSubMsg.Payload.Entries = 0; /* Send subcription for each route */ CFE_SBR_ForEachRouteId(CFE_SB_SendRouteSub, NULL, NULL); @@ -1408,12 +1373,12 @@ int32 CFE_SB_SendPrevSubsCmd(const CFE_SB_SendPrevSubsCmd_t *data) CFE_SB_UnlockSharedData(__func__,__LINE__); /* if pkt has any number of entries, send it as a partial pkt */ - if(CFE_SB.PrevSubMsg.Payload.Entries > 0) + if(CFE_SB_Global.PrevSubMsg.Payload.Entries > 0) { - status = CFE_SB_TransmitMsg(&CFE_SB.PrevSubMsg.Hdr.Msg, true); + status = CFE_SB_TransmitMsg(&CFE_SB_Global.PrevSubMsg.Hdr.Msg, true); CFE_EVS_SendEvent(CFE_SB_PART_SUB_PKT_EID, CFE_EVS_EventType_DEBUG, "Partial Sub Pkt %d Sent,Entries=%d,Stat=0x%x", - (int)CFE_SB.PrevSubMsg.Payload.PktSegment, (int)CFE_SB.PrevSubMsg.Payload.Entries, + (int)CFE_SB_Global.PrevSubMsg.Payload.PktSegment, (int)CFE_SB_Global.PrevSubMsg.Payload.Entries, (unsigned int)status); } @@ -1438,9 +1403,9 @@ int32 CFE_SB_SendPrevSubsCmd(const CFE_SB_SendPrevSubsCmd_t *data) void CFE_SB_IncrCmdCtr(int32 status){ if(status==CFE_SUCCESS){ - CFE_SB.HKTlmMsg.Payload.CommandCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandCounter++; }else{ - CFE_SB.HKTlmMsg.Payload.CommandErrorCounter++; + CFE_SB_Global.HKTlmMsg.Payload.CommandErrorCounter++; }/* end if */ }/* end CFE_SB_IncrCmdCtr */ @@ -1482,6 +1447,6 @@ void CFE_SB_FileWriteByteCntErr(const char *Filename,uint32 Requested,uint32 Act */ void CFE_SB_SetSubscriptionReporting(uint32 state){ - CFE_SB.SubscriptionReporting = state; + CFE_SB_Global.SubscriptionReporting = state; }/* end CFE_SB_SetSubscriptionReporting */ diff --git a/fsw/cfe-core/src/sb/cfe_sb_verify.h b/fsw/cfe-core/src/sb/cfe_sb_verify.h index b14bc92c6..f5fc750d4 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_verify.h +++ b/fsw/cfe-core/src/sb/cfe_sb_verify.h @@ -50,16 +50,12 @@ #error CFE_PLATFORM_SB_MAX_DEST_PER_PKT cannot be less than 1! #endif -#if CFE_PLATFORM_SB_MAX_PIPE_DEPTH < 1 - #error CFE_PLATFORM_SB_MAX_PIPE_DEPTH cannot be less than 1! -#endif - #if CFE_PLATFORM_SB_HIGHEST_VALID_MSGID < 1 #error CFE_PLATFORM_SB_HIGHEST_VALID_MSGID cannot be less than 1! #endif -#if CFE_PLATFORM_SB_HIGHEST_VALID_MSGID > 0xFFFF - #error CFE_PLATFORM_SB_HIGHEST_VALID_MSGID cannot be greater than 0xFFFF! +#if CFE_PLATFORM_SB_HIGHEST_VALID_MSGID > 0xFFFFFFFE + #error CFE_PLATFORM_SB_HIGHEST_VALID_MSGID cannot be > 0xFFFFFFFE #endif #if CFE_PLATFORM_SB_BUF_MEMORY_BYTES < 512 diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_api.c b/fsw/cfe-core/src/tbl/cfe_tbl_api.c index 3c5675541..6e70c020e 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_api.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_api.c @@ -61,7 +61,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, int32 Status; size_t NameLen = 0; int16 RegIndx = -1; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; char AppName[OS_MAX_API_NAME] = {"UNKNOWN"}; char TblName[CFE_TBL_MAX_FULL_NAME_LEN] = {""}; CFE_TBL_Handle_t AccessIndex; @@ -148,7 +148,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, else /* Application ID was invalid */ { CFE_ES_WriteToSysLog("CFE_TBL:Register-Bad AppId(%lu)\n", - CFE_ES_ResourceID_ToInteger(ThisAppId)); + CFE_RESOURCEID_TO_ULONG(ThisAppId)); } /* If input parameters appear acceptable, register the table */ @@ -165,10 +165,10 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, if (RegIndx != CFE_TBL_NOT_FOUND) { /* Get pointer to Registry Record Entry to speed up processing */ - RegRecPtr = &CFE_TBL_TaskData.Registry[RegIndx]; + RegRecPtr = &CFE_TBL_Global.Registry[RegIndx]; /* If this app previously owned the table, then allow them to re-register */ - if ( CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, ThisAppId) ) + if ( CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, ThisAppId) ) { /* If the new table is the same size as the old, then no need to reallocate memory */ if (Size != RegRecPtr->Size) @@ -192,15 +192,15 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, AccessIndex = RegRecPtr->HeadOfAccessList; while ((AccessIndex != CFE_TBL_END_OF_LIST) && (*TblHandlePtr == CFE_TBL_BAD_TABLE_HANDLE)) { - if ((CFE_TBL_TaskData.Handles[AccessIndex].UsedFlag == true) && - CFE_ES_ResourceID_Equal(CFE_TBL_TaskData.Handles[AccessIndex].AppId, ThisAppId) && - (CFE_TBL_TaskData.Handles[AccessIndex].RegIndex == RegIndx)) + if ((CFE_TBL_Global.Handles[AccessIndex].UsedFlag == true) && + CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_Global.Handles[AccessIndex].AppId, ThisAppId) && + (CFE_TBL_Global.Handles[AccessIndex].RegIndex == RegIndx)) { *TblHandlePtr = AccessIndex; } else { - AccessIndex = CFE_TBL_TaskData.Handles[AccessIndex].NextLink; + AccessIndex = CFE_TBL_Global.Handles[AccessIndex].NextLink; } } } @@ -210,8 +210,8 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, Status = CFE_TBL_ERR_DUPLICATE_NOT_OWNED; CFE_ES_WriteToSysLog("CFE_TBL:Register-App(%lu) Registering Duplicate Table '%s' owned by App(%lu)\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), TblName, - CFE_ES_ResourceID_ToInteger(RegRecPtr->OwnerAppId)); + CFE_RESOURCEID_TO_ULONG(ThisAppId), TblName, + CFE_RESOURCEID_TO_ULONG(RegRecPtr->OwnerAppId)); } } else /* Table not already in registry */ @@ -245,7 +245,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, if ((Status & CFE_SEVERITY_BITMASK) != CFE_SEVERITY_ERROR) { /* Get pointer to Registry Record Entry to speed up processing */ - RegRecPtr = &CFE_TBL_TaskData.Registry[RegIndx]; + RegRecPtr = &CFE_TBL_Global.Registry[RegIndx]; /* Initialize Registry Record to default settings */ CFE_TBL_InitRegistryRecord(RegRecPtr); @@ -256,12 +256,12 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, /* Allocate the memory buffer(s) for the table and inactive table, if necessary */ Status = CFE_ES_GetPoolBuf(&RegRecPtr->Buffers[0].BufferPtr, - CFE_TBL_TaskData.Buf.PoolHdl, + CFE_TBL_Global.Buf.PoolHdl, Size); if(Status < 0) { CFE_ES_WriteToSysLog("CFE_TBL:Register-1st Buf Alloc GetPool fail Stat=0x%08X MemPoolHndl=0x%08lX\n", - (unsigned int)Status, CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.Buf.PoolHdl)); + (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(CFE_TBL_Global.Buf.PoolHdl)); } else { @@ -282,12 +282,12 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, { /* Allocate memory for the dedicated secondary buffer */ Status = CFE_ES_GetPoolBuf(&RegRecPtr->Buffers[1].BufferPtr, - CFE_TBL_TaskData.Buf.PoolHdl, + CFE_TBL_Global.Buf.PoolHdl, Size); if(Status < 0) { CFE_ES_WriteToSysLog("CFE_TBL:Register-2nd Buf Alloc GetPool fail Stat=0x%08X MemPoolHndl=0x%08lX\n", - (unsigned int)Status, CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.Buf.PoolHdl)); + (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(CFE_TBL_Global.Buf.PoolHdl)); } else { @@ -328,7 +328,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, } /* Initialize the Table Access Descriptor */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[*TblHandlePtr]; + AccessDescPtr = &CFE_TBL_Global.Handles[*TblHandlePtr]; AccessDescPtr->AppId = ThisAppId; AccessDescPtr->LockFlag = false; @@ -455,7 +455,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, CritRegRecPtr->TimeOfLastUpdate.Subseconds = 0; CritRegRecPtr->TableLoadedOnce = false; - CFE_ES_CopyToCDS(CFE_TBL_TaskData.CritRegHandle, CFE_TBL_TaskData.CritReg); + CFE_ES_CopyToCDS(CFE_TBL_Global.CritRegHandle, CFE_TBL_Global.CritReg); } else { @@ -500,7 +500,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, CFE_EVS_SendEventWithAppID(CFE_TBL_REGISTER_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s Failed to Register '%s', Status=0x%08X", AppName, TblName, (unsigned int)Status); } @@ -516,7 +516,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, const char *TblName ) { int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; int16 RegIndx = CFE_TBL_NOT_FOUND; CFE_TBL_AccessDescriptor_t *AccessDescPtr = NULL; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; @@ -537,7 +537,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, if (RegIndx != CFE_TBL_NOT_FOUND) { /* Get pointer to Registry Record Entry to speed up processing */ - RegRecPtr = &CFE_TBL_TaskData.Registry[RegIndx]; + RegRecPtr = &CFE_TBL_Global.Registry[RegIndx]; /* Search Access Descriptor Array for free Descriptor */ *TblHandlePtr = CFE_TBL_FindFreeHandle(); @@ -551,7 +551,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, else { /* Initialize the Table Access Descriptor */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[*TblHandlePtr]; + AccessDescPtr = &CFE_TBL_Global.Handles[*TblHandlePtr]; AccessDescPtr->AppId = ThisAppId; AccessDescPtr->LockFlag = false; @@ -570,7 +570,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, AccessDescPtr->NextLink = RegRecPtr->HeadOfAccessList; /* Make sure the old head of the list now sees this as the head */ - CFE_TBL_TaskData.Handles[RegRecPtr->HeadOfAccessList].PrevLink = *TblHandlePtr; + CFE_TBL_Global.Handles[RegRecPtr->HeadOfAccessList].PrevLink = *TblHandlePtr; /* Make sure the Registry Record see this as the head of the list */ RegRecPtr->HeadOfAccessList = *TblHandlePtr; @@ -588,7 +588,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, else /* Application ID was invalid */ { CFE_ES_WriteToSysLog("CFE_TBL:Share-Bad AppId(%lu)\n", - CFE_ES_ResourceID_ToInteger(ThisAppId)); + CFE_RESOURCEID_TO_ULONG(ThisAppId)); } /* On Error conditions, notify ground of screw up */ @@ -599,7 +599,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, CFE_EVS_SendEventWithAppID(CFE_TBL_SHARE_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s Failed to Share '%s', Status=0x%08X", AppName, TblName, (unsigned int)Status); } @@ -614,7 +614,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, int32 CFE_TBL_Unregister ( CFE_TBL_Handle_t TblHandle ) { int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; CFE_TBL_AccessDescriptor_t *AccessDescPtr = NULL; char AppName[OS_MAX_API_NAME] = {"UNKNOWN"}; @@ -625,13 +625,13 @@ int32 CFE_TBL_Unregister ( CFE_TBL_Handle_t TblHandle ) if (Status == CFE_SUCCESS) { /* Get a pointer to the relevant Access Descriptor */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; + AccessDescPtr = &CFE_TBL_Global.Handles[TblHandle]; /* Get a pointer to the relevant entry in the registry */ - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; /* Verify that the application unregistering the table owns the table */ - if (CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, ThisAppId)) + if (CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, ThisAppId)) { /* Mark table as free, although, technically, it isn't free until the */ /* linked list of Access Descriptors has no links in it. */ @@ -652,7 +652,7 @@ int32 CFE_TBL_Unregister ( CFE_TBL_Handle_t TblHandle ) else { CFE_ES_WriteToSysLog("CFE_TBL:Unregister-App(%lu) does not have access to Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } /* On Error conditions, notify ground of screw up */ @@ -663,7 +663,7 @@ int32 CFE_TBL_Unregister ( CFE_TBL_Handle_t TblHandle ) CFE_EVS_SendEventWithAppID(CFE_TBL_UNREGISTER_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s Failed to Unregister '?', Status=0x%08X", AppName, (unsigned int)Status); } @@ -685,7 +685,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, const void *SrcDataPtr ) { int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; CFE_TBL_LoadBuff_t *WorkingBufferPtr; CFE_TBL_AccessDescriptor_t *AccessDescPtr; CFE_TBL_RegistryRec_t *RegRecPtr; @@ -698,14 +698,14 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, if (Status != CFE_SUCCESS) { CFE_EVS_SendEventWithAppID(CFE_TBL_HANDLE_ACCESS_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s: No access to Tbl Handle=%d", AppName, (int)TblHandle); return Status; } - AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[TblHandle]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; /* Translate AppID of caller into App Name */ CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); @@ -719,7 +719,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, if ((!RegRecPtr->UserDefAddr) ||(RegRecPtr->TableLoadedOnce)) { CFE_EVS_SendEventWithAppID(CFE_TBL_LOADING_A_DUMP_ONLY_ERR_EID, - CFE_EVS_EventType_ERROR, CFE_TBL_TaskData.TableTaskAppId, + CFE_EVS_EventType_ERROR, CFE_TBL_Global.TableTaskAppId, "%s: Attempted to load Dump Only Tbl '%s'", AppName, RegRecPtr->Name); return CFE_TBL_ERR_DUMP_ONLY; @@ -737,7 +737,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_SUCCESS_INF_EID, CFE_EVS_EventType_DEBUG, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "Successfully loaded '%s' from '%s'", RegRecPtr->Name, RegRecPtr->Buffers[0].DataSource); @@ -749,7 +749,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, if (RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS) { CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_IN_PROGRESS_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s: Load already in progress for '%s'", AppName, RegRecPtr->Name); return CFE_TBL_ERR_LOAD_IN_PROGRESS; @@ -761,7 +761,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, if (Status != CFE_SUCCESS) { CFE_EVS_SendEventWithAppID(CFE_TBL_NO_WORK_BUFFERS_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s: Failed to get Working Buffer (Stat=%u)", AppName, (unsigned int)Status); return Status; @@ -780,7 +780,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, /* Uninitialized tables cannot be loaded with partial table loads */ /* Partial loads can only occur on previously loaded tables. */ CFE_EVS_SendEventWithAppID(CFE_TBL_PARTIAL_LOAD_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s: Attempted to load from partial Tbl '%s' from '%s' (Stat=%u)", AppName, RegRecPtr->Name, (const char *)SrcDataPtr, (unsigned int)Status); @@ -807,7 +807,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, break; default: CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_TYPE_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s: Attempted to load from illegal source type=%d", AppName, (int)SrcType); Status = CFE_TBL_ERR_ILLEGAL_SRC_TYPE; @@ -821,7 +821,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, if (Status > CFE_SUCCESS) { CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_VAL_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s: Validation func return code invalid (Stat=%u) for '%s'", AppName, (unsigned int)Status, RegRecPtr->Name); @@ -831,7 +831,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, if (Status < 0) { CFE_EVS_SendEventWithAppID(CFE_TBL_VALIDATION_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s: Validation func reports table invalid (Stat=%u) for '%s'", AppName, (unsigned int)Status, RegRecPtr->Name); @@ -847,7 +847,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, if ((!RegRecPtr->DoubleBuffered) && (RegRecPtr->TableLoadedOnce == true)) { /* For single buffered tables, freeing entails resetting flag */ - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].Taken = false; + CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].Taken = false; } /* For double buffered tables, freeing buffer is simple */ @@ -870,7 +870,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, if (Status != CFE_SUCCESS) { CFE_EVS_SendEventWithAppID(CFE_TBL_UPDATE_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s: Failed to update '%s' (Stat=%u)", AppName, RegRecPtr->Name, (unsigned int)Status); } @@ -900,11 +900,11 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, /* to help eliminate a flood of events during a startup */ CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_SUCCESS_INF_EID, FirstTime ? CFE_EVS_EventType_DEBUG : CFE_EVS_EventType_INFORMATION, - CFE_TBL_TaskData.TableTaskAppId, "Successfully loaded '%s' from '%s'", + CFE_TBL_Global.TableTaskAppId, "Successfully loaded '%s' from '%s'", RegRecPtr->Name, RegRecPtr->LastFileLoaded); /* Save the index of the table for housekeeping telemetry */ - CFE_TBL_TaskData.LastTblUpdated = AccessDescPtr->RegIndex; + CFE_TBL_Global.LastTblUpdated = AccessDescPtr->RegIndex; } return Status; @@ -917,7 +917,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ) { int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; CFE_TBL_RegistryRec_t *RegRecPtr=NULL; CFE_TBL_AccessDescriptor_t *AccessDescPtr=NULL; char AppName[OS_MAX_API_NAME]={"UNKNOWN"}; @@ -928,21 +928,21 @@ int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ) if (Status == CFE_SUCCESS) { /* Get pointers to pertinent records in registry and handles */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[TblHandle]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; Status = CFE_TBL_UpdateInternal(TblHandle, RegRecPtr, AccessDescPtr); if (Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("CFE_TBL:Update-App(%lu) fail to update Tbl '%s' (Stat=0x%08X)\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), RegRecPtr->Name, (unsigned int)Status); + CFE_RESOURCEID_TO_ULONG(ThisAppId), RegRecPtr->Name, (unsigned int)Status); } } else { CFE_ES_WriteToSysLog("CFE_TBL:Update-App(%lu) does not have access to Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } if (Status != CFE_TBL_ERR_BAD_APP_ID) @@ -958,7 +958,7 @@ int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ) { CFE_EVS_SendEventWithAppID(CFE_TBL_UPDATE_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s Failed to Update '%s', Status=0x%08X", AppName, RegRecPtr->Name, (unsigned int)Status); } @@ -966,7 +966,7 @@ int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ) { CFE_EVS_SendEventWithAppID(CFE_TBL_UPDATE_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s Failed to Update '?', Status=0x%08X", AppName, (unsigned int)Status); } @@ -978,12 +978,12 @@ int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ) { CFE_EVS_SendEventWithAppID(CFE_TBL_UPDATE_SUCCESS_INF_EID, CFE_EVS_EventType_INFORMATION, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s Successfully Updated '%s'", AppName, RegRecPtr->Name); /* Save the index of the table for housekeeping telemetry */ - CFE_TBL_TaskData.LastTblUpdated = AccessDescPtr->RegIndex; + CFE_TBL_Global.LastTblUpdated = AccessDescPtr->RegIndex; } } @@ -998,7 +998,7 @@ int32 CFE_TBL_GetAddress( void **TblPtr, CFE_TBL_Handle_t TblHandle ) { int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; /* Assume failure at returning the table address */ *TblPtr = NULL; @@ -1017,7 +1017,7 @@ int32 CFE_TBL_GetAddress( void **TblPtr, else { CFE_ES_WriteToSysLog("CFE_TBL:GetAddress-Bad AppId=%lu\n", - CFE_ES_ResourceID_ToInteger(ThisAppId)); + CFE_RESOURCEID_TO_ULONG(ThisAppId)); } return Status; @@ -1029,7 +1029,7 @@ int32 CFE_TBL_GetAddress( void **TblPtr, int32 CFE_TBL_ReleaseAddress( CFE_TBL_Handle_t TblHandle ) { int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; /* Verify that this application has the right to perform operation */ Status = CFE_TBL_ValidateAccess(TblHandle, &ThisAppId); @@ -1037,7 +1037,7 @@ int32 CFE_TBL_ReleaseAddress( CFE_TBL_Handle_t TblHandle ) if (Status == CFE_SUCCESS) { /* Clear the lock flag */ - CFE_TBL_TaskData.Handles[TblHandle].LockFlag = false; + CFE_TBL_Global.Handles[TblHandle].LockFlag = false; /* Return any pending warning or info status indicators */ Status = CFE_TBL_GetNextNotification(TblHandle); @@ -1049,7 +1049,7 @@ int32 CFE_TBL_ReleaseAddress( CFE_TBL_Handle_t TblHandle ) else { CFE_ES_WriteToSysLog("CFE_TBL:ReleaseAddress-App(%lu) does not have access to Tbl Handle=%u\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (unsigned int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (unsigned int)TblHandle); } return Status; @@ -1064,7 +1064,7 @@ int32 CFE_TBL_GetAddresses( void **TblPtrs[], { uint16 i; int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; /* Assume failure at returning the table addresses */ for (i=0; iRegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[TblHandle]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); @@ -1170,12 +1170,12 @@ int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ) { /* Call the Application's Validation function for the appropriate shared buffer */ Status = (RegRecPtr->ValidationFuncPtr) - (CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr); + (CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr); /* Allow buffer to be activated after passing validation */ if (Status == CFE_SUCCESS) { - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].Validated = true; + CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].Validated = true; } } @@ -1183,7 +1183,7 @@ int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ) { CFE_EVS_SendEventWithAppID(CFE_TBL_VALIDATION_INF_EID, CFE_EVS_EventType_INFORMATION, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s validation successful for Inactive '%s'", AppName, RegRecPtr->Name); } @@ -1191,22 +1191,22 @@ int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ) { CFE_EVS_SendEventWithAppID(CFE_TBL_VALIDATION_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s validation failed for Inactive '%s', Status=0x%08X", AppName, RegRecPtr->Name, (unsigned int)Status); if (Status > CFE_SUCCESS) { CFE_ES_WriteToSysLog("CFE_TBL:Validate-App(%lu) Validation func return code invalid (Stat=0x%08X) for '%s'\n", - CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.TableTaskAppId), (unsigned int)Status, RegRecPtr->Name); + CFE_RESOURCEID_TO_ULONG(CFE_TBL_Global.TableTaskAppId), (unsigned int)Status, RegRecPtr->Name); } } /* Save the result of the Validation function for the Table Services Task */ - CFE_TBL_TaskData.ValidationResults[RegRecPtr->ValidateInactiveIndex].Result = Status; + CFE_TBL_Global.ValidationResults[RegRecPtr->ValidateInactiveIndex].Result = Status; /* Once validation is complete, set flags to indicate response is ready */ - CFE_TBL_TaskData.ValidationResults[RegRecPtr->ValidateInactiveIndex].State = CFE_TBL_VALIDATION_PERFORMED; + CFE_TBL_Global.ValidationResults[RegRecPtr->ValidateInactiveIndex].State = CFE_TBL_VALIDATION_PERFORMED; RegRecPtr->ValidateInactiveIndex = CFE_TBL_NO_VALIDATION_PENDING; /* Since the validation was successfully performed (although maybe not a successful result) */ @@ -1232,7 +1232,7 @@ int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ) { CFE_EVS_SendEventWithAppID(CFE_TBL_VALIDATION_INF_EID, CFE_EVS_EventType_INFORMATION, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s validation successful for Active '%s'", AppName, RegRecPtr->Name); } @@ -1240,22 +1240,22 @@ int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ) { CFE_EVS_SendEventWithAppID(CFE_TBL_VALIDATION_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s validation failed for Active '%s', Status=0x%08X", AppName, RegRecPtr->Name, (unsigned int)Status); if (Status > CFE_SUCCESS) { CFE_ES_WriteToSysLog("CFE_TBL:Validate-App(%lu) Validation func return code invalid (Stat=0x%08X) for '%s'\n", - CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.TableTaskAppId), (unsigned int)Status, RegRecPtr->Name); + CFE_RESOURCEID_TO_ULONG(CFE_TBL_Global.TableTaskAppId), (unsigned int)Status, RegRecPtr->Name); } } /* Save the result of the Validation function for the Table Services Task */ - CFE_TBL_TaskData.ValidationResults[RegRecPtr->ValidateActiveIndex].Result = Status; + CFE_TBL_Global.ValidationResults[RegRecPtr->ValidateActiveIndex].Result = Status; /* Once validation is complete, reset the flags */ - CFE_TBL_TaskData.ValidationResults[RegRecPtr->ValidateActiveIndex].State = CFE_TBL_VALIDATION_PERFORMED; + CFE_TBL_Global.ValidationResults[RegRecPtr->ValidateActiveIndex].State = CFE_TBL_VALIDATION_PERFORMED; RegRecPtr->ValidateActiveIndex = CFE_TBL_NO_VALIDATION_PENDING; /* Since the validation was successfully performed (although maybe not a successful result) */ @@ -1270,7 +1270,7 @@ int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ) else { CFE_ES_WriteToSysLog("CFE_TBL:Validate-App(%lu) does not have access to Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } return Status; @@ -1339,7 +1339,7 @@ int32 CFE_TBL_Manage( CFE_TBL_Handle_t TblHandle ) int32 CFE_TBL_GetStatus( CFE_TBL_Handle_t TblHandle ) { int32 Status ; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; CFE_TBL_RegistryRec_t *RegRecPtr; CFE_TBL_AccessDescriptor_t *AccessDescPtr; @@ -1349,8 +1349,8 @@ int32 CFE_TBL_GetStatus( CFE_TBL_Handle_t TblHandle ) if (Status == CFE_SUCCESS) { /* Get pointers to pertinent records in registry and handles */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[TblHandle]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; /* Perform validations prior to performing any updates */ if (RegRecPtr->LoadPending) @@ -1370,7 +1370,7 @@ int32 CFE_TBL_GetStatus( CFE_TBL_Handle_t TblHandle ) else { CFE_ES_WriteToSysLog("CFE_TBL:GetStatus-App(%lu) does not have access to Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } return Status; @@ -1394,7 +1394,7 @@ int32 CFE_TBL_GetInfo( CFE_TBL_Info_t *TblInfoPtr, const char *TblName ) if (RegIndx != CFE_TBL_NOT_FOUND) { /* Get pointer to Registry Record Entry to speed up processing */ - RegRecPtr = &CFE_TBL_TaskData.Registry[RegIndx]; + RegRecPtr = &CFE_TBL_Global.Registry[RegIndx]; /* Return table characteristics */ TblInfoPtr->Size = RegRecPtr->Size; @@ -1417,7 +1417,7 @@ int32 CFE_TBL_GetInfo( CFE_TBL_Info_t *TblInfoPtr, const char *TblName ) while (HandleIterator != CFE_TBL_END_OF_LIST) { NumAccessDescriptors++; - HandleIterator = CFE_TBL_TaskData.Handles[HandleIterator].NextLink; + HandleIterator = CFE_TBL_Global.Handles[HandleIterator].NextLink; } TblInfoPtr->NumUsers = NumAccessDescriptors; @@ -1447,9 +1447,9 @@ int32 CFE_TBL_DumpToBuffer( CFE_TBL_Handle_t TblHandle ) Status = CFE_TBL_GetStatus(TblHandle); if (Status == CFE_TBL_INFO_DUMP_PENDING) { - AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; - DumpCtrlPtr = &CFE_TBL_TaskData.DumpControlBlocks[RegRecPtr->DumpControlIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[TblHandle]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; + DumpCtrlPtr = &CFE_TBL_Global.DumpControlBlocks[RegRecPtr->DumpControlIndex]; /* Copy the contents of the active buffer to the assigned dump buffer */ memcpy(DumpCtrlPtr->DumpBufferPtr->BufferPtr, RegRecPtr->Buffers[0].BufferPtr, DumpCtrlPtr->Size); @@ -1481,7 +1481,7 @@ int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle ) CFE_TBL_AccessDescriptor_t *AccessDescPtr = NULL; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; CFE_TBL_Handle_t AccessIterator; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; size_t FilenameLen = 0; /* Verify that this application has the right to perform operation */ @@ -1490,8 +1490,8 @@ int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle ) if (Status == CFE_SUCCESS) { /* Get pointers to pertinent records in registry and handles */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[TblHandle]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; /* If the table is a critical table, update the appropriate CDS with the new data */ if (RegRecPtr->CriticalTable == true) @@ -1524,18 +1524,18 @@ int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle ) while (AccessIterator != CFE_TBL_END_OF_LIST) { /* Only notify *OTHER* applications that the contents have changed */ - if (!CFE_ES_ResourceID_Equal(CFE_TBL_TaskData.Handles[AccessIterator].AppId, ThisAppId)) + if (!CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_Global.Handles[AccessIterator].AppId, ThisAppId)) { - CFE_TBL_TaskData.Handles[AccessIterator].Updated = true; + CFE_TBL_Global.Handles[AccessIterator].Updated = true; } - AccessIterator = CFE_TBL_TaskData.Handles[AccessIterator].NextLink; + AccessIterator = CFE_TBL_Global.Handles[AccessIterator].NextLink; } } else { CFE_ES_WriteToSysLog("CFE_TBL:Modified-App(%lu) does not have access to Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } @@ -1551,7 +1551,7 @@ int32 CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, CFE_SB_MsgId_t MsgId, int32 Status; CFE_TBL_AccessDescriptor_t *AccessDescPtr = NULL; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; /* Verify that this application has the right to perform operation */ Status = CFE_TBL_ValidateAccess(TblHandle, &ThisAppId); @@ -1559,11 +1559,11 @@ int32 CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, CFE_SB_MsgId_t MsgId, if (Status == CFE_SUCCESS) { /* Get pointers to pertinent records in registry and handles */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[TblHandle]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; /* Verify that the calling application is the table owner */ - if (CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, ThisAppId)) + if (CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, ThisAppId)) { RegRecPtr->NotificationMsgId = MsgId; RegRecPtr->NotificationCC = CommandCode; @@ -1574,7 +1574,7 @@ int32 CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, CFE_SB_MsgId_t MsgId, { Status = CFE_TBL_ERR_NO_ACCESS; CFE_ES_WriteToSysLog("CFE_TBL:NotifyByMsg-App(%lu) does not own Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } } diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c index afaae8f5a..c50b6b116 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c @@ -70,57 +70,45 @@ int32 CFE_TBL_EarlyInit (void) uint32 j; int32 Status; + /* Clear task global */ + memset(&CFE_TBL_Global, 0, sizeof(CFE_TBL_Global)); /* Initialize the Table Registry */ for(i=0; i < CFE_PLATFORM_TBL_MAX_NUM_TABLES; i++) { - CFE_TBL_InitRegistryRecord(&CFE_TBL_TaskData.Registry[i]); + CFE_TBL_InitRegistryRecord(&CFE_TBL_Global.Registry[i]); } - /* Initialize the Table Access Descriptors */ + /* Initialize the Table Access Descriptors nonzero values */ for (i=0; iOwnerAppId = CFE_TBL_NOT_OWNED; - RegRecPtr->Size = 0; RegRecPtr->NotificationMsgId = CFE_SB_INVALID_MSG_ID; - RegRecPtr->NotificationCC = 0; - RegRecPtr->NotificationParam = 0; - RegRecPtr->Buffers[0].BufferPtr = NULL; - RegRecPtr->Buffers[0].FileCreateTimeSecs = 0; - RegRecPtr->Buffers[0].FileCreateTimeSubSecs = 0; - RegRecPtr->Buffers[0].Crc = 0; - RegRecPtr->Buffers[0].Taken = false; - RegRecPtr->Buffers[0].DataSource[0] = '\0'; - RegRecPtr->Buffers[1].BufferPtr = NULL; - RegRecPtr->Buffers[1].FileCreateTimeSecs = 0; - RegRecPtr->Buffers[1].FileCreateTimeSubSecs = 0; - RegRecPtr->Buffers[1].Crc = 0; - RegRecPtr->Buffers[1].Taken = false; - RegRecPtr->Buffers[1].DataSource[0] = '\0'; - RegRecPtr->ValidationFuncPtr = NULL; - RegRecPtr->TimeOfLastUpdate.Seconds = 0; - RegRecPtr->TimeOfLastUpdate.Subseconds = 0; RegRecPtr->HeadOfAccessList = CFE_TBL_END_OF_LIST; RegRecPtr->LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; RegRecPtr->ValidateActiveIndex = CFE_TBL_NO_VALIDATION_PENDING; RegRecPtr->ValidateInactiveIndex = CFE_TBL_NO_VALIDATION_PENDING; RegRecPtr->CDSHandle = CFE_ES_CDS_BAD_HANDLE; - RegRecPtr->CriticalTable = false; - RegRecPtr->TableLoadedOnce = false; - RegRecPtr->LoadPending = false; - RegRecPtr->DumpOnly = false; RegRecPtr->DumpControlIndex = CFE_TBL_NO_DUMP_PENDING; - RegRecPtr->UserDefAddr = false; - RegRecPtr->DoubleBuffered = false; - RegRecPtr->NotifyByMsg = false; - RegRecPtr->ActiveBufferIndex = 0; - RegRecPtr->Name[0] = '\0'; - RegRecPtr->LastFileLoaded[0] = '\0'; } /* End CFE_TBL_InitRegistryRecord */ @@ -321,7 +256,7 @@ int32 CFE_TBL_ValidateHandle(CFE_TBL_Handle_t TblHandle) else { /* Check to see if the Handle is no longer valid for this Table */ - if (CFE_TBL_TaskData.Handles[TblHandle].UsedFlag == false) + if (CFE_TBL_Global.Handles[TblHandle].UsedFlag == false) { return CFE_TBL_ERR_INVALID_HANDLE; } @@ -336,7 +271,7 @@ int32 CFE_TBL_ValidateHandle(CFE_TBL_Handle_t TblHandle) ** NOTE: For complete prolog information, see 'cfe_tbl_internal.h' ********************************************************************/ -int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t *AppIdPtr) +int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, CFE_ES_AppId_t *AppIdPtr) { int32 Status; @@ -369,15 +304,15 @@ int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t *Ap ** NOTE: For complete prolog information, see 'cfe_tbl_internal.h' ********************************************************************/ -int32 CFE_TBL_CheckAccessRights(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t ThisAppId) +int32 CFE_TBL_CheckAccessRights(CFE_TBL_Handle_t TblHandle, CFE_ES_AppId_t ThisAppId) { int32 Status = CFE_SUCCESS; - if (!CFE_ES_ResourceID_Equal(ThisAppId, CFE_TBL_TaskData.Handles[TblHandle].AppId)) + if (!CFE_RESOURCEID_TEST_EQUAL(ThisAppId, CFE_TBL_Global.Handles[TblHandle].AppId)) { /* The Table Service Task always has access rights so that tables */ /* can be manipulated via ground command */ - if (!CFE_ES_ResourceID_Equal(ThisAppId, CFE_TBL_TaskData.TableTaskAppId)) + if (!CFE_RESOURCEID_TEST_EQUAL(ThisAppId, CFE_TBL_Global.TableTaskAppId)) { Status = CFE_TBL_ERR_NO_ACCESS; } @@ -396,8 +331,8 @@ int32 CFE_TBL_CheckAccessRights(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t int32 CFE_TBL_RemoveAccessLink(CFE_TBL_Handle_t TblHandle) { int32 Status = CFE_SUCCESS; - CFE_TBL_AccessDescriptor_t *AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; - CFE_TBL_RegistryRec_t *RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + CFE_TBL_AccessDescriptor_t *AccessDescPtr = &CFE_TBL_Global.Handles[TblHandle]; + CFE_TBL_RegistryRec_t *RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; /* Lock Access to the table while we modify the linked list */ CFE_TBL_LockRegistry(); @@ -411,19 +346,19 @@ int32 CFE_TBL_RemoveAccessLink(CFE_TBL_Handle_t TblHandle) /* Update the next link, if there is one, to be the new head of the list */ if (AccessDescPtr->NextLink != CFE_TBL_END_OF_LIST) { - CFE_TBL_TaskData.Handles[AccessDescPtr->NextLink].PrevLink = CFE_TBL_END_OF_LIST; + CFE_TBL_Global.Handles[AccessDescPtr->NextLink].PrevLink = CFE_TBL_END_OF_LIST; } } else /* Access Descriptor is not the head of the list */ { /* Set the next link on the previous link to the next link of the link being removed */ - CFE_TBL_TaskData.Handles[AccessDescPtr->PrevLink].NextLink = AccessDescPtr->NextLink; + CFE_TBL_Global.Handles[AccessDescPtr->PrevLink].NextLink = AccessDescPtr->NextLink; /* If this link is not the end of the list, then complete two way linkage */ /* by setting the next link's previous link to the previous link of the link being removed */ if (AccessDescPtr->NextLink != CFE_TBL_END_OF_LIST) { - CFE_TBL_TaskData.Handles[AccessDescPtr->NextLink].PrevLink = AccessDescPtr->PrevLink; + CFE_TBL_Global.Handles[AccessDescPtr->NextLink].PrevLink = AccessDescPtr->PrevLink; } } @@ -437,25 +372,25 @@ int32 CFE_TBL_RemoveAccessLink(CFE_TBL_Handle_t TblHandle) if (RegRecPtr->UserDefAddr == false) { /* Free memory allocated to buffers */ - Status = CFE_ES_PutPoolBuf(CFE_TBL_TaskData.Buf.PoolHdl, RegRecPtr->Buffers[0].BufferPtr); + Status = CFE_ES_PutPoolBuf(CFE_TBL_Global.Buf.PoolHdl, RegRecPtr->Buffers[0].BufferPtr); RegRecPtr->Buffers[0].BufferPtr = NULL; if (Status < 0) { CFE_ES_WriteToSysLog("CFE_TBL:RemoveAccessLink-PutPoolBuf[0] Fail Stat=0x%08X, Hndl=0x%08lX, Buf=0x%08lX\n", - (unsigned int)Status, CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.Buf.PoolHdl), (unsigned long)RegRecPtr->Buffers[0].BufferPtr); + (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(CFE_TBL_Global.Buf.PoolHdl), (unsigned long)RegRecPtr->Buffers[0].BufferPtr); } /* If a double buffered table, then free the second buffer as well */ if (RegRecPtr->DoubleBuffered) { - Status = CFE_ES_PutPoolBuf(CFE_TBL_TaskData.Buf.PoolHdl, RegRecPtr->Buffers[1].BufferPtr); + Status = CFE_ES_PutPoolBuf(CFE_TBL_Global.Buf.PoolHdl, RegRecPtr->Buffers[1].BufferPtr); RegRecPtr->Buffers[1].BufferPtr = NULL; if (Status < 0) { CFE_ES_WriteToSysLog("CFE_TBL:RemoveAccessLink-PutPoolBuf[1] Fail Stat=0x%08X, Hndl=0x%08lX, Buf=0x%08lX\n", - (unsigned int)Status, CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.Buf.PoolHdl), (unsigned long)RegRecPtr->Buffers[1].BufferPtr); + (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(CFE_TBL_Global.Buf.PoolHdl), (unsigned long)RegRecPtr->Buffers[1].BufferPtr); } } else @@ -464,7 +399,7 @@ int32 CFE_TBL_RemoveAccessLink(CFE_TBL_Handle_t TblHandle) if (RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS) { /* Free the working buffer */ - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].Taken = false; + CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].Taken = false; RegRecPtr->LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; } } @@ -486,7 +421,7 @@ int32 CFE_TBL_RemoveAccessLink(CFE_TBL_Handle_t TblHandle) ********************************************************************/ -int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t ThisAppId) +int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ES_AppId_t ThisAppId) { int32 Status; CFE_TBL_AccessDescriptor_t *AccessDescPtr; @@ -498,7 +433,7 @@ int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ if (Status == CFE_SUCCESS) { /* Get a pointer to the Access Descriptor */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; + AccessDescPtr = &CFE_TBL_Global.Handles[TblHandle]; /* Verify that we are allowed access to the table */ Status = CFE_TBL_CheckAccessRights(TblHandle, ThisAppId); @@ -506,15 +441,15 @@ int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ if (Status == CFE_SUCCESS) { /* Get a pointer to the Table Registry entry */ - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; /* If table is unowned, then owner must have unregistered it when we weren't looking */ - if (CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED)) + if (CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED)) { Status = CFE_TBL_ERR_UNREGISTERED; CFE_ES_WriteToSysLog("CFE_TBL:GetAddressInternal-App(%lu) attempt to access unowned Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } else /* Table Registry Entry is valid */ { @@ -538,13 +473,13 @@ int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ else { CFE_ES_WriteToSysLog("CFE_TBL:GetAddressInternal-App(%lu) does not have access to Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } } else { CFE_ES_WriteToSysLog("CFE_TBL:GetAddressInternal-App(%lu) using invalid Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } return Status; @@ -561,8 +496,8 @@ int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ int32 CFE_TBL_GetNextNotification(CFE_TBL_Handle_t TblHandle) { int32 Status = CFE_SUCCESS; - CFE_TBL_AccessDescriptor_t *AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; - CFE_TBL_RegistryRec_t *RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + CFE_TBL_AccessDescriptor_t *AccessDescPtr = &CFE_TBL_Global.Handles[TblHandle]; + CFE_TBL_RegistryRec_t *RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; if (!RegRecPtr->TableLoadedOnce) { @@ -597,10 +532,10 @@ int16 CFE_TBL_FindTableInRegistry(const char *TblName) i++; /* Check to see if the record is currently being used */ - if ( !CFE_ES_ResourceID_Equal(CFE_TBL_TaskData.Registry[i].OwnerAppId, CFE_TBL_NOT_OWNED) ) + if ( !CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_Global.Registry[i].OwnerAppId, CFE_TBL_NOT_OWNED) ) { /* Perform a case sensitive name comparison */ - if (strcmp(TblName, CFE_TBL_TaskData.Registry[i].Name) == 0) + if (strcmp(TblName, CFE_TBL_Global.Registry[i].Name) == 0) { /* If the names match, then return the index */ RegIndx = i; @@ -628,8 +563,8 @@ int16 CFE_TBL_FindFreeRegistryEntry(void) { /* A Table Registry is only "Free" when there isn't an owner AND */ /* all other applications are not sharing or locking the table */ - if (CFE_ES_ResourceID_Equal(CFE_TBL_TaskData.Registry[i].OwnerAppId, CFE_TBL_NOT_OWNED) && - (CFE_TBL_TaskData.Registry[i].HeadOfAccessList == CFE_TBL_END_OF_LIST)) + if (CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_Global.Registry[i].OwnerAppId, CFE_TBL_NOT_OWNED) && + (CFE_TBL_Global.Registry[i].HeadOfAccessList == CFE_TBL_END_OF_LIST)) { RegIndx = i; } @@ -657,7 +592,7 @@ CFE_TBL_Handle_t CFE_TBL_FindFreeHandle(void) while ((HandleIndx == CFE_TBL_END_OF_LIST) && (i < CFE_PLATFORM_TBL_MAX_NUM_HANDLES)) { - if (CFE_TBL_TaskData.Handles[i].UsedFlag == false) + if (CFE_TBL_Global.Handles[i].UsedFlag == false) { HandleIndx = i; } @@ -678,7 +613,7 @@ CFE_TBL_Handle_t CFE_TBL_FindFreeHandle(void) ** NOTE: For complete prolog information, see 'cfe_tbl_internal.h' ********************************************************************/ -void CFE_TBL_FormTableName(char *FullTblName, const char *TblName, CFE_ES_ResourceID_t ThisAppId) +void CFE_TBL_FormTableName(char *FullTblName, const char *TblName, CFE_ES_AppId_t ThisAppId) { char AppName[OS_MAX_API_NAME]; @@ -705,7 +640,7 @@ int32 CFE_TBL_LockRegistry(void) { int32 Status; - Status = OS_MutSemTake(CFE_TBL_TaskData.RegistryMutex); + Status = OS_MutSemTake(CFE_TBL_Global.RegistryMutex); if (Status == OS_SUCCESS) { @@ -729,7 +664,7 @@ int32 CFE_TBL_UnlockRegistry(void) { int32 Status; - Status = OS_MutSemGive(CFE_TBL_TaskData.RegistryMutex); + Status = OS_MutSemGive(CFE_TBL_Global.RegistryMutex); if (Status == OS_SUCCESS) { @@ -770,7 +705,7 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, } else { - *WorkingBufferPtr = &CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress]; + *WorkingBufferPtr = &CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress]; } } else @@ -803,17 +738,17 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, AccessIterator = RegRecPtr->HeadOfAccessList; while ((AccessIterator != CFE_TBL_END_OF_LIST) && (Status == CFE_SUCCESS)) { - if ((CFE_TBL_TaskData.Handles[AccessIterator].BufferIndex == InactiveBufferIndex) && - (CFE_TBL_TaskData.Handles[AccessIterator].LockFlag)) + if ((CFE_TBL_Global.Handles[AccessIterator].BufferIndex == InactiveBufferIndex) && + (CFE_TBL_Global.Handles[AccessIterator].LockFlag)) { Status = CFE_TBL_ERR_NO_BUFFER_AVAIL; CFE_ES_WriteToSysLog("CFE_TBL:GetWorkingBuffer-Inactive Dbl Buff Locked for '%s' by AppId=%lu\n", - RegRecPtr->Name, CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.Handles[AccessIterator].AppId)); + RegRecPtr->Name, CFE_RESOURCEID_TO_ULONG(CFE_TBL_Global.Handles[AccessIterator].AppId)); } /* Move to next access descriptor in linked list */ - AccessIterator = CFE_TBL_TaskData.Handles[AccessIterator].NextLink; + AccessIterator = CFE_TBL_Global.Handles[AccessIterator].NextLink; } /* If buffer is free, then return the pointer to it */ @@ -827,7 +762,7 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, { /* Take Mutex to make sure we are not trying to grab a working buffer that some */ /* other application is also trying to grab. */ - Status = OS_MutSemTake(CFE_TBL_TaskData.WorkBufMutex); + Status = OS_MutSemTake(CFE_TBL_Global.WorkBufMutex); /* Make note of any errors but continue and hope for the best */ if (Status != OS_SUCCESS) @@ -838,7 +773,7 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, /* Determine if there are any common buffers available */ i = 0; - while ((i < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS) && (CFE_TBL_TaskData.LoadBuffs[i].Taken == true)) + while ((i < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS) && (CFE_TBL_Global.LoadBuffs[i].Taken == true)) { i++; } @@ -846,8 +781,8 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, /* If a free buffer was found, then return the address to the associated shared buffer */ if (i < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS) { - CFE_TBL_TaskData.LoadBuffs[i].Taken = true; - *WorkingBufferPtr = &CFE_TBL_TaskData.LoadBuffs[i]; + CFE_TBL_Global.LoadBuffs[i].Taken = true; + *WorkingBufferPtr = &CFE_TBL_Global.LoadBuffs[i]; RegRecPtr->LoadInProgress = i; /* Translate OS_SUCCESS into CFE_SUCCESS */ @@ -861,7 +796,7 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, } /* Allow others to obtain a shared working buffer */ - OS_MutSemGive(CFE_TBL_TaskData.WorkBufMutex); + OS_MutSemGive(CFE_TBL_Global.WorkBufMutex); } if ((*WorkingBufferPtr) != NULL && @@ -903,7 +838,7 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe if (FilenameLen > (OS_MAX_PATH_LEN-1)) { CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_FILENAME_LONG_ERR_EID, - CFE_EVS_EventType_ERROR, CFE_TBL_TaskData.TableTaskAppId, + CFE_EVS_EventType_ERROR, CFE_TBL_Global.TableTaskAppId, "%s: Filename is too long ('%s' (%lu) > %lu)", AppName, Filename, (long unsigned int)FilenameLen, (long unsigned int)OS_MAX_PATH_LEN-1); @@ -917,7 +852,7 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe if (Status < 0) { CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_ACCESS_ERR_EID, - CFE_EVS_EventType_ERROR, CFE_TBL_TaskData.TableTaskAppId, + CFE_EVS_EventType_ERROR, CFE_TBL_Global.TableTaskAppId, "%s: Unable to open file (FileDescriptor=%d)", AppName, (int)Status); @@ -938,7 +873,7 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe if (strcmp(RegRecPtr->Name, TblFileHeader.TableName) != 0) { CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_TBLNAME_MISMATCH_ERR_EID, - CFE_EVS_EventType_ERROR, CFE_TBL_TaskData.TableTaskAppId, + CFE_EVS_EventType_ERROR, CFE_TBL_Global.TableTaskAppId, "%s: Table name mismatch (exp=%s, tblfilhdr=%s)", AppName, RegRecPtr->Name, TblFileHeader.TableName); @@ -949,7 +884,7 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe if ((TblFileHeader.Offset + TblFileHeader.NumBytes) > RegRecPtr->Size) { CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_EXCEEDS_SIZE_ERR_EID, - CFE_EVS_EventType_ERROR, CFE_TBL_TaskData.TableTaskAppId, + CFE_EVS_EventType_ERROR, CFE_TBL_Global.TableTaskAppId, "%s: File reports size larger than expected (file=%lu, exp=%lu)", AppName, (long unsigned int)(TblFileHeader.Offset + TblFileHeader.NumBytes), @@ -978,7 +913,7 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe if (NumBytes != TblFileHeader.NumBytes) { CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_INCOMPLETE_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s: File load incomplete (exp=%lu, read=%lu)", AppName, (long unsigned int)TblFileHeader.NumBytes, (long unsigned int)NumBytes); @@ -994,7 +929,7 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe if (NumBytes == 1) { CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_TOO_BIG_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "%s: File load too long (file length > %lu)", AppName, (long unsigned int)TblFileHeader.NumBytes); @@ -1071,9 +1006,9 @@ int32 CFE_TBL_UpdateInternal( CFE_TBL_Handle_t TblHandle, AccessIterator = RegRecPtr->HeadOfAccessList; while (AccessIterator != CFE_TBL_END_OF_LIST) { - LockStatus = (LockStatus || CFE_TBL_TaskData.Handles[AccessIterator].LockFlag); + LockStatus = (LockStatus || CFE_TBL_Global.Handles[AccessIterator].LockFlag); - AccessIterator = CFE_TBL_TaskData.Handles[AccessIterator].NextLink; + AccessIterator = CFE_TBL_Global.Handles[AccessIterator].NextLink; } if (LockStatus) @@ -1086,34 +1021,34 @@ int32 CFE_TBL_UpdateInternal( CFE_TBL_Handle_t TblHandle, { /* To update a single buffered table requires a memcpy from working buffer */ if (RegRecPtr->Buffers[0].BufferPtr != - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr) + CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr) { memcpy(RegRecPtr->Buffers[0].BufferPtr, - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr, + CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr, RegRecPtr->Size); } /* Save source description with active buffer */ strncpy(RegRecPtr->Buffers[0].DataSource, - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].DataSource, + CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].DataSource, sizeof(RegRecPtr->Buffers[0].DataSource)-1); RegRecPtr->Buffers[0].DataSource[sizeof(RegRecPtr->Buffers[0].DataSource)-1] = 0; strncpy(RegRecPtr->LastFileLoaded, - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].DataSource, + CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].DataSource, sizeof(RegRecPtr->LastFileLoaded)-1); RegRecPtr->LastFileLoaded[sizeof(RegRecPtr->LastFileLoaded)-1] = 0; /* Save the file creation time from the loaded file into the Table Registry */ RegRecPtr->Buffers[0].FileCreateTimeSecs = - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].FileCreateTimeSecs; + CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].FileCreateTimeSecs; RegRecPtr->Buffers[0].FileCreateTimeSubSecs = - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].FileCreateTimeSubSecs; + CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].FileCreateTimeSubSecs; /* Save the previously computed CRC into the new buffer */ - RegRecPtr->Buffers[0].Crc = CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].Crc; + RegRecPtr->Buffers[0].Crc = CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].Crc; /* Free the working buffer */ - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].Taken = false; + CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].Taken = false; CFE_TBL_NotifyTblUsersOfUpdate(RegRecPtr); @@ -1151,9 +1086,9 @@ void CFE_TBL_NotifyTblUsersOfUpdate(CFE_TBL_RegistryRec_t *RegRecPtr) AccessIterator = RegRecPtr->HeadOfAccessList; while (AccessIterator != CFE_TBL_END_OF_LIST) { - CFE_TBL_TaskData.Handles[AccessIterator].Updated = true; + CFE_TBL_Global.Handles[AccessIterator].Updated = true; - AccessIterator = CFE_TBL_TaskData.Handles[AccessIterator].NextLink; + AccessIterator = CFE_TBL_Global.Handles[AccessIterator].NextLink; } } /* End of CFE_TBL_NotifyTblUsersOfUpdate() */ @@ -1191,7 +1126,7 @@ int32 CFE_TBL_ReadHeaders( osal_id_t FileDescriptor, { CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_STD_HDR_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "Unable to read std header for '%s', Status = 0x%08X", LoadFilename, (unsigned int)Status); @@ -1204,7 +1139,7 @@ int32 CFE_TBL_ReadHeaders( osal_id_t FileDescriptor, { CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_TYPE_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "File '%s' is not a cFE file type, ContentType = 0x%08X", LoadFilename, (unsigned int)StdFileHeaderPtr->ContentType); @@ -1217,7 +1152,7 @@ int32 CFE_TBL_ReadHeaders( osal_id_t FileDescriptor, { CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_SUBTYPE_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "File subtype for '%s' is wrong. Subtype = 0x%08X", LoadFilename, (unsigned int)StdFileHeaderPtr->SubType); @@ -1232,7 +1167,7 @@ int32 CFE_TBL_ReadHeaders( osal_id_t FileDescriptor, { CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_TBL_HDR_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "Unable to read tbl header for '%s', Status = 0x%08X", LoadFilename, (unsigned int)Status); @@ -1276,7 +1211,7 @@ int32 CFE_TBL_ReadHeaders( osal_id_t FileDescriptor, { CFE_EVS_SendEventWithAppID(CFE_TBL_SPACECRAFT_ID_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "Unable to verify Spacecraft ID for '%s', ID = 0x%08X", LoadFilename, (unsigned int)StdFileHeaderPtr->SpacecraftID); } @@ -1300,7 +1235,7 @@ int32 CFE_TBL_ReadHeaders( osal_id_t FileDescriptor, { CFE_EVS_SendEventWithAppID(CFE_TBL_PROCESSOR_ID_ERR_EID, CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, + CFE_TBL_Global.TableTaskAppId, "Unable to verify Processor ID for '%s', ID = 0x%08X", LoadFilename, (unsigned int)StdFileHeaderPtr->ProcessorID); } @@ -1356,7 +1291,7 @@ void CFE_TBL_ByteSwapUint32(uint32 *Uint32ToSwapPtr) ** NOTE: For complete prolog information, see 'cfe_tbl_internal.h' ********************************************************************/ -int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_TBL_CleanUpApp(CFE_ES_AppId_t AppId) { uint32 i; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; @@ -1367,11 +1302,11 @@ int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId) for (i=0; iOwnerAppId, AppId)) + if ((CFE_TBL_Global.DumpControlBlocks[i].State != CFE_TBL_DUMP_FREE) && + CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_Global.DumpControlBlocks[i].RegRecPtr->OwnerAppId, AppId)) { /* If so, then remove the dump request */ - CFE_TBL_TaskData.DumpControlBlocks[i].State = CFE_TBL_DUMP_FREE; + CFE_TBL_Global.DumpControlBlocks[i].State = CFE_TBL_DUMP_FREE; } } @@ -1379,18 +1314,18 @@ int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId) for (i=0; iRegIndex]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; /* Determine if the Application owned this particular table */ - if (CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, AppId)) + if (CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, AppId)) { /* Mark table as free, although, technically, it isn't free until the */ /* linked list of Access Descriptors has no links in it. */ @@ -1408,7 +1343,7 @@ int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId) /* memory buffers are set free as well. */ CFE_TBL_RemoveAccessLink(i); - CFE_TBL_TaskData.Handles[i].AppId = CFE_TBL_NOT_OWNED; + CFE_TBL_Global.Handles[i].AppId = CFE_TBL_NOT_OWNED; } } @@ -1432,9 +1367,9 @@ void CFE_TBL_FindCriticalTblInfo(CFE_TBL_CritRegRec_t **CritRegRecPtr, CFE_ES_CD for (i=0; iTableLoadedOnce = RegRecPtr->TableLoadedOnce; /* Update copy of Critical Table Registry in the CDS */ - Status = CFE_ES_CopyToCDS(CFE_TBL_TaskData.CritRegHandle, CFE_TBL_TaskData.CritReg); + Status = CFE_ES_CopyToCDS(CFE_TBL_Global.CritRegHandle, CFE_TBL_Global.CritReg); if (Status != CFE_SUCCESS) { @@ -1510,21 +1445,17 @@ int32 CFE_TBL_SendNotificationMsg(CFE_TBL_RegistryRec_t *RegRecPtr) /* First, determine if a message should be sent */ if (RegRecPtr->NotifyByMsg) { - /* - ** Initialize notification message packet (clear user data area)... - */ - CFE_MSG_Init(&CFE_TBL_TaskData.NotifyMsg.CmdHeader.Msg, - RegRecPtr->NotificationMsgId, - sizeof(CFE_TBL_TaskData.NotifyMsg)); + /* Set the message ID */ + CFE_MSG_SetMsgId(&CFE_TBL_Global.NotifyMsg.CmdHeader.Msg, RegRecPtr->NotificationMsgId); /* Set the command code */ - CFE_MSG_SetFcnCode(&CFE_TBL_TaskData.NotifyMsg.CmdHeader.Msg, RegRecPtr->NotificationCC); + CFE_MSG_SetFcnCode(&CFE_TBL_Global.NotifyMsg.CmdHeader.Msg, RegRecPtr->NotificationCC); /* Set the command parameter */ - CFE_TBL_TaskData.NotifyMsg.Payload.Parameter = RegRecPtr->NotificationParam; + CFE_TBL_Global.NotifyMsg.Payload.Parameter = RegRecPtr->NotificationParam; - CFE_SB_TimeStampMsg(&CFE_TBL_TaskData.NotifyMsg.CmdHeader.Msg); - Status = CFE_SB_TransmitMsg(&CFE_TBL_TaskData.NotifyMsg.CmdHeader.Msg, false); + CFE_SB_TimeStampMsg(&CFE_TBL_Global.NotifyMsg.CmdHeader.Msg); + Status = CFE_SB_TransmitMsg(&CFE_TBL_Global.NotifyMsg.CmdHeader.Msg, false); if (Status != CFE_SUCCESS) { diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.h b/fsw/cfe-core/src/tbl/cfe_tbl_internal.h index cfe1280a4..21cbfaee2 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_internal.h +++ b/fsw/cfe-core/src/tbl/cfe_tbl_internal.h @@ -41,7 +41,7 @@ /********************* Macro and Constant Type Definitions ***************************/ -#define CFE_TBL_NOT_OWNED CFE_ES_RESOURCEID_UNDEFINED +#define CFE_TBL_NOT_OWNED CFE_ES_APPID_UNDEFINED #define CFE_TBL_NOT_FOUND (-1) #define CFE_TBL_END_OF_LIST (CFE_TBL_Handle_t)0xFFFF @@ -93,7 +93,7 @@ int32 CFE_TBL_ValidateHandle(CFE_TBL_Handle_t TblHandle); ** \retval #CFE_TBL_ERR_NO_ACCESS \copydoc CFE_TBL_ERR_NO_ACCESS ** ******************************************************************************/ -int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t *AppIdPtr); +int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, CFE_ES_AppId_t *AppIdPtr); /*****************************************************************************/ /** @@ -116,7 +116,7 @@ int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t * ** \retval #CFE_TBL_ERR_NO_ACCESS \copydoc CFE_TBL_ERR_NO_ACCESS ** ******************************************************************************/ -int32 CFE_TBL_CheckAccessRights(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t ThisAppId); +int32 CFE_TBL_CheckAccessRights(CFE_TBL_Handle_t TblHandle, CFE_ES_AppId_t ThisAppId); /*****************************************************************************/ @@ -167,7 +167,7 @@ int32 CFE_TBL_RemoveAccessLink(CFE_TBL_Handle_t TblHandle); ** \retval #CFE_TBL_ERR_UNREGISTERED \copydoc CFE_TBL_ERR_UNREGISTERED ** ******************************************************************************/ -int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t ThisAppId); +int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ES_AppId_t ThisAppId); /*****************************************************************************/ @@ -262,7 +262,7 @@ CFE_TBL_Handle_t CFE_TBL_FindFreeHandle(void); ** ** ******************************************************************************/ -void CFE_TBL_FormTableName(char *FullTblName, const char *TblName, CFE_ES_ResourceID_t ThisAppId); +void CFE_TBL_FormTableName(char *FullTblName, const char *TblName, CFE_ES_AppId_t ThisAppId); /*****************************************************************************/ @@ -582,7 +582,7 @@ extern void CFE_TBL_ByteSwapUint32(uint32 *Uint32ToSwapPtr); /* ** Globals specific to the TBL module */ -extern CFE_TBL_TaskData_t CFE_TBL_TaskData; +extern CFE_TBL_Global_t CFE_TBL_Global; diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task.c b/fsw/cfe-core/src/tbl/cfe_tbl_task.c index 635ffd63b..3583e8cd3 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task.c @@ -47,7 +47,7 @@ /* ** Table task global data */ -CFE_TBL_TaskData_t CFE_TBL_TaskData; +CFE_TBL_Global_t CFE_TBL_Global; /* * Macros to assist in building the CFE_TBL_CmdHandlerTbl - @@ -124,7 +124,7 @@ void CFE_TBL_TaskMain(void) /* Pend on receipt of packet */ Status = CFE_SB_ReceiveBuffer( &SBBufPtr, - CFE_TBL_TaskData.CmdPipe, + CFE_TBL_Global.CmdPipe, CFE_SB_PEND_FOREVER); CFE_ES_PerfLogEntry(CFE_MISSION_TBL_MAIN_PERF_ID); @@ -181,7 +181,7 @@ int32 CFE_TBL_TaskInit(void) /* ** Create Software Bus message pipe */ - Status = CFE_SB_CreatePipe(&CFE_TBL_TaskData.CmdPipe, CFE_TBL_TASK_PIPE_DEPTH, CFE_TBL_TASK_PIPE_NAME); + Status = CFE_SB_CreatePipe(&CFE_TBL_Global.CmdPipe, CFE_TBL_TASK_PIPE_DEPTH, CFE_TBL_TASK_PIPE_NAME); if(Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("TBL:Error creating cmd pipe:RC=0x%08X\n",(unsigned int)Status); @@ -191,7 +191,7 @@ int32 CFE_TBL_TaskInit(void) /* ** Subscribe to Housekeeping request commands */ - Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_TBL_SEND_HK_MID), CFE_TBL_TaskData.CmdPipe); + Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_TBL_SEND_HK_MID), CFE_TBL_Global.CmdPipe); if(Status != CFE_SUCCESS) { @@ -202,7 +202,7 @@ int32 CFE_TBL_TaskInit(void) /* ** Subscribe to Table task ground command packets */ - Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_TBL_CMD_MID), CFE_TBL_TaskData.CmdPipe); + Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_TBL_CMD_MID), CFE_TBL_Global.CmdPipe); if(Status != CFE_SUCCESS) { @@ -230,23 +230,23 @@ int32 CFE_TBL_TaskInit(void) void CFE_TBL_InitData(void) { - /* Initialize Counters */ - CFE_TBL_TaskData.CommandCounter = 0; - CFE_TBL_TaskData.CommandErrorCounter = 0; - CFE_TBL_TaskData.SuccessValCounter = 0; - CFE_TBL_TaskData.FailedValCounter = 0; /* Get the assigned Application ID for the Table Services Task */ - CFE_ES_GetAppID(&CFE_TBL_TaskData.TableTaskAppId); + CFE_ES_GetAppID(&CFE_TBL_Global.TableTaskAppId); /* Initialize Packet Headers */ - CFE_MSG_Init(&CFE_TBL_TaskData.HkPacket.TlmHeader.Msg, + CFE_MSG_Init(&CFE_TBL_Global.HkPacket.TlmHeader.Msg, CFE_SB_ValueToMsgId(CFE_TBL_HK_TLM_MID), - sizeof(CFE_TBL_TaskData.HkPacket)); + sizeof(CFE_TBL_Global.HkPacket)); - CFE_MSG_Init(&CFE_TBL_TaskData.TblRegPacket.TlmHeader.Msg, + CFE_MSG_Init(&CFE_TBL_Global.TblRegPacket.TlmHeader.Msg, CFE_SB_ValueToMsgId(CFE_TBL_REG_TLM_MID), - sizeof(CFE_TBL_TaskData.TblRegPacket)); + sizeof(CFE_TBL_Global.TblRegPacket)); + + /* Message ID is set when sent, so OK as 0 here */ + CFE_MSG_Init(&CFE_TBL_Global.NotifyMsg.CmdHeader.Msg, + CFE_SB_ValueToMsgId(0), + sizeof(CFE_TBL_Global.NotifyMsg)); } /* End of CFE_TBL_InitData() */ @@ -291,11 +291,11 @@ void CFE_TBL_TaskPipe(CFE_SB_Buffer_t *SBBufPtr) { if (CmdStatus == CFE_TBL_INC_CMD_CTR) { - CFE_TBL_TaskData.CommandCounter++; + CFE_TBL_Global.CommandCounter++; } else if (CmdStatus == CFE_TBL_INC_ERR_CTR) { - CFE_TBL_TaskData.CommandErrorCounter++; + CFE_TBL_Global.CommandErrorCounter++; } } } @@ -311,7 +311,7 @@ void CFE_TBL_TaskPipe(CFE_SB_Buffer_t *SBBufPtr) (unsigned int)CommandCode); /* Update the command error counter */ - CFE_TBL_TaskData.CommandErrorCounter++; + CFE_TBL_Global.CommandErrorCounter++; } else /* CmdIndx == CFE_TBL_BAD_MSG_ID */ { diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task.h b/fsw/cfe-core/src/tbl/cfe_tbl_task.h index e2a41205b..6ad6611f0 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task.h +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task.h @@ -165,7 +165,7 @@ typedef struct */ typedef struct { - CFE_ES_ResourceID_t AppId; /**< \brief Application ID to verify access */ + CFE_ES_AppId_t AppId; /**< \brief Application ID to verify access */ int16 RegIndex; /**< \brief Index into Table Registry (a.k.a. - Global Table #) */ CFE_TBL_Handle_t PrevLink; /**< \brief Index of previous access descriptor in linked list */ CFE_TBL_Handle_t NextLink; /**< \brief Index of next access descriptor in linked list */ @@ -184,7 +184,7 @@ typedef struct */ typedef struct { - CFE_ES_ResourceID_t OwnerAppId; /**< \brief Application ID of App that Registered Table */ + CFE_ES_AppId_t OwnerAppId; /**< \brief Application ID of App that Registered 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 */ @@ -313,7 +313,7 @@ typedef struct /* ** Task initialization data (not reported in housekeeping)... */ - CFE_ES_ResourceID_t TableTaskAppId; /**< \brief Contains Table Task Application ID as assigned by OS AL */ + CFE_ES_AppId_t TableTaskAppId; /**< \brief Contains Table Task Application ID as assigned by OS AL */ int16 HkTlmTblRegIndex; /**< \brief Index of table registry entry to be telemetered with Housekeeping */ uint16 ValidationCounter; @@ -336,7 +336,7 @@ typedef struct CFE_TBL_ValidationResult_t ValidationResults[CFE_PLATFORM_TBL_MAX_NUM_VALIDATIONS]; /**< \brief Array of Table Validation Requests */ CFE_TBL_DumpControl_t DumpControlBlocks[CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS]; /**< \brief Array of Dump-Only Dump Control Blocks */ -} CFE_TBL_TaskData_t; +} CFE_TBL_Global_t; /*************************************************************************/ 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 21bd4e025..21952d79e 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c @@ -69,8 +69,8 @@ int32 CFE_TBL_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) /* ** Send housekeeping telemetry packet */ - CFE_SB_TimeStampMsg(&CFE_TBL_TaskData.HkPacket.TlmHeader.Msg); - Status = CFE_SB_TransmitMsg(&CFE_TBL_TaskData.HkPacket.TlmHeader.Msg, true); + CFE_SB_TimeStampMsg(&CFE_TBL_Global.HkPacket.TlmHeader.Msg); + Status = CFE_SB_TransmitMsg(&CFE_TBL_Global.HkPacket.TlmHeader.Msg, true); if (Status != CFE_SUCCESS) { @@ -81,26 +81,26 @@ int32 CFE_TBL_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) } /* If a table's registry entry has been requested for telemetry, then pack it and send it */ - if (CFE_TBL_TaskData.HkTlmTblRegIndex != CFE_TBL_NOT_FOUND) + if (CFE_TBL_Global.HkTlmTblRegIndex != CFE_TBL_NOT_FOUND) { CFE_TBL_GetTblRegData(); /* ** Send Table Registry Info Packet */ - CFE_SB_TimeStampMsg(&CFE_TBL_TaskData.TblRegPacket.TlmHeader.Msg); - CFE_SB_TransmitMsg(&CFE_TBL_TaskData.TblRegPacket.TlmHeader.Msg, true); + CFE_SB_TimeStampMsg(&CFE_TBL_Global.TblRegPacket.TlmHeader.Msg); + CFE_SB_TransmitMsg(&CFE_TBL_Global.TblRegPacket.TlmHeader.Msg, true); /* Once the data has been sent, clear the index so that we don't send it again and again */ - CFE_TBL_TaskData.HkTlmTblRegIndex = CFE_TBL_NOT_FOUND; + CFE_TBL_Global.HkTlmTblRegIndex = CFE_TBL_NOT_FOUND; } /* Check to see if there are any dump-only table dumps pending */ for (i=0; i < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS; i++) { - if (CFE_TBL_TaskData.DumpControlBlocks[i].State == CFE_TBL_DUMP_PERFORMED) + if (CFE_TBL_Global.DumpControlBlocks[i].State == CFE_TBL_DUMP_PERFORMED) { - DumpCtrlPtr = &CFE_TBL_TaskData.DumpControlBlocks[i]; + DumpCtrlPtr = &CFE_TBL_Global.DumpControlBlocks[i]; Status = CFE_TBL_DumpToFile(DumpCtrlPtr->DumpBufferPtr->DataSource, DumpCtrlPtr->TableName, DumpCtrlPtr->DumpBufferPtr->BufferPtr, @@ -135,7 +135,7 @@ int32 CFE_TBL_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) } /* Free the shared working buffer */ - CFE_TBL_TaskData.LoadBuffs[DumpCtrlPtr->RegRecPtr->LoadInProgress].Taken = false; + CFE_TBL_Global.LoadBuffs[DumpCtrlPtr->RegRecPtr->LoadInProgress].Taken = false; DumpCtrlPtr->RegRecPtr->LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; /* Free the Dump Control Block for later use */ @@ -162,35 +162,35 @@ void CFE_TBL_GetHkData(void) CFE_TBL_ValidationResult_t *ValPtr = NULL; /* Copy command counter data */ - CFE_TBL_TaskData.HkPacket.Payload.CommandCounter = CFE_TBL_TaskData.CommandCounter; - CFE_TBL_TaskData.HkPacket.Payload.CommandErrorCounter = CFE_TBL_TaskData.CommandErrorCounter; - CFE_TBL_TaskData.HkPacket.Payload.FailedValCounter = CFE_TBL_TaskData.FailedValCounter; - CFE_TBL_TaskData.HkPacket.Payload.NumLoadPending = 0; - CFE_TBL_TaskData.HkPacket.Payload.MemPoolHandle = CFE_TBL_TaskData.Buf.PoolHdl; + CFE_TBL_Global.HkPacket.Payload.CommandCounter = CFE_TBL_Global.CommandCounter; + CFE_TBL_Global.HkPacket.Payload.CommandErrorCounter = CFE_TBL_Global.CommandErrorCounter; + CFE_TBL_Global.HkPacket.Payload.FailedValCounter = CFE_TBL_Global.FailedValCounter; + CFE_TBL_Global.HkPacket.Payload.NumLoadPending = 0; + CFE_TBL_Global.HkPacket.Payload.MemPoolHandle = CFE_TBL_Global.Buf.PoolHdl; /* Determine the number of tables currently registered and Number of Load Pending Tables */ Count = 0; for (i=0; iCrcOfTable; - CFE_TBL_TaskData.HkPacket.Payload.LastValStatus = ValPtr->Result; - CFE_TBL_TaskData.HkPacket.Payload.ActiveBuffer = ValPtr->ActiveBuffer; + CFE_TBL_Global.HkPacket.Payload.LastValCrc = ValPtr->CrcOfTable; + CFE_TBL_Global.HkPacket.Payload.LastValStatus = ValPtr->Result; + CFE_TBL_Global.HkPacket.Payload.ActiveBuffer = ValPtr->ActiveBuffer; /* Keep track of the number of failed and successful validations */ if (ValPtr->Result == CFE_SUCCESS) { - CFE_TBL_TaskData.SuccessValCounter++; + CFE_TBL_Global.SuccessValCounter++; } else { - CFE_TBL_TaskData.FailedValCounter++; + CFE_TBL_Global.FailedValCounter++; } - CFE_SB_MessageStringSet(CFE_TBL_TaskData.HkPacket.Payload.LastValTableName, ValPtr->TableName, - sizeof(CFE_TBL_TaskData.HkPacket.Payload.LastValTableName), sizeof(ValPtr->TableName)); - CFE_TBL_TaskData.ValidationCounter++; + CFE_SB_MessageStringSet(CFE_TBL_Global.HkPacket.Payload.LastValTableName, ValPtr->TableName, + sizeof(CFE_TBL_Global.HkPacket.Payload.LastValTableName), sizeof(ValPtr->TableName)); + CFE_TBL_Global.ValidationCounter++; /* Free the Validation Response Block for next time */ ValPtr->Result = 0; @@ -236,27 +236,27 @@ void CFE_TBL_GetHkData(void) ValPtr->State = CFE_TBL_VALIDATION_FREE; } - CFE_TBL_TaskData.HkPacket.Payload.ValidationCounter = CFE_TBL_TaskData.ValidationCounter; - CFE_TBL_TaskData.HkPacket.Payload.SuccessValCounter = CFE_TBL_TaskData.SuccessValCounter; - CFE_TBL_TaskData.HkPacket.Payload.FailedValCounter = CFE_TBL_TaskData.FailedValCounter; - CFE_TBL_TaskData.HkPacket.Payload.NumValRequests = CFE_TBL_TaskData.NumValRequests; + CFE_TBL_Global.HkPacket.Payload.ValidationCounter = CFE_TBL_Global.ValidationCounter; + CFE_TBL_Global.HkPacket.Payload.SuccessValCounter = CFE_TBL_Global.SuccessValCounter; + CFE_TBL_Global.HkPacket.Payload.FailedValCounter = CFE_TBL_Global.FailedValCounter; + CFE_TBL_Global.HkPacket.Payload.NumValRequests = CFE_TBL_Global.NumValRequests; /* Validate the index of the last table updated before using it */ - if ((CFE_TBL_TaskData.LastTblUpdated >= 0) && - (CFE_TBL_TaskData.LastTblUpdated < CFE_PLATFORM_TBL_MAX_NUM_TABLES)) + if ((CFE_TBL_Global.LastTblUpdated >= 0) && + (CFE_TBL_Global.LastTblUpdated < CFE_PLATFORM_TBL_MAX_NUM_TABLES)) { /* Check to make sure the Registry Entry is still valid */ - if (!CFE_ES_ResourceID_Equal(CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.LastTblUpdated].OwnerAppId, CFE_TBL_NOT_OWNED)) + if (!CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_Global.Registry[CFE_TBL_Global.LastTblUpdated].OwnerAppId, CFE_TBL_NOT_OWNED)) { /* Get the time at the last table update */ - CFE_TBL_TaskData.HkPacket.Payload.LastUpdateTime = - CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.LastTblUpdated].TimeOfLastUpdate; + CFE_TBL_Global.HkPacket.Payload.LastUpdateTime = + CFE_TBL_Global.Registry[CFE_TBL_Global.LastTblUpdated].TimeOfLastUpdate; /* Get the table name used for the last table update */ - CFE_SB_MessageStringSet(CFE_TBL_TaskData.HkPacket.Payload.LastUpdatedTable, - CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.LastTblUpdated].Name, - sizeof(CFE_TBL_TaskData.HkPacket.Payload.LastUpdatedTable), - sizeof(CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.LastTblUpdated].Name)); + CFE_SB_MessageStringSet(CFE_TBL_Global.HkPacket.Payload.LastUpdatedTable, + CFE_TBL_Global.Registry[CFE_TBL_Global.LastTblUpdated].Name, + sizeof(CFE_TBL_Global.HkPacket.Payload.LastUpdatedTable), + sizeof(CFE_TBL_Global.Registry[CFE_TBL_Global.LastTblUpdated].Name)); } } } /* End of CFE_TBL_GetHkData() */ @@ -272,16 +272,16 @@ void CFE_TBL_GetTblRegData(void) { CFE_TBL_RegistryRec_t *RegRecPtr; - RegRecPtr = &CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.HkTlmTblRegIndex]; + RegRecPtr = &CFE_TBL_Global.Registry[CFE_TBL_Global.HkTlmTblRegIndex]; - CFE_TBL_TaskData.TblRegPacket.Payload.Size = CFE_ES_MEMOFFSET_C(RegRecPtr->Size); - CFE_TBL_TaskData.TblRegPacket.Payload.ActiveBufferAddr = + CFE_TBL_Global.TblRegPacket.Payload.Size = CFE_ES_MEMOFFSET_C(RegRecPtr->Size); + CFE_TBL_Global.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_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = + CFE_TBL_Global.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(RegRecPtr->Buffers[(1U-RegRecPtr->ActiveBufferIndex)].BufferPtr); } else @@ -289,32 +289,32 @@ void CFE_TBL_GetTblRegData(void) /* 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_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = - CFE_ES_MEMADDRESS_C(CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr); + CFE_TBL_Global.TblRegPacket.Payload.InactiveBufferAddr = + CFE_ES_MEMADDRESS_C(CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr); } else { - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); + CFE_TBL_Global.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); } } - 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; - CFE_TBL_TaskData.TblRegPacket.Payload.DumpOnly = RegRecPtr->DumpOnly; - CFE_TBL_TaskData.TblRegPacket.Payload.DoubleBuffered = RegRecPtr->DoubleBuffered; - CFE_TBL_TaskData.TblRegPacket.Payload.FileCreateTimeSecs = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTimeSecs; - CFE_TBL_TaskData.TblRegPacket.Payload.FileCreateTimeSubSecs = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTimeSubSecs; - CFE_TBL_TaskData.TblRegPacket.Payload.Crc = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].Crc; - CFE_TBL_TaskData.TblRegPacket.Payload.Critical = RegRecPtr->CriticalTable; - - CFE_SB_MessageStringSet(CFE_TBL_TaskData.TblRegPacket.Payload.Name, RegRecPtr->Name, - sizeof(CFE_TBL_TaskData.TblRegPacket.Payload.Name), sizeof(RegRecPtr->Name)); - CFE_SB_MessageStringSet(CFE_TBL_TaskData.TblRegPacket.Payload.LastFileLoaded, RegRecPtr->LastFileLoaded, - sizeof(CFE_TBL_TaskData.TblRegPacket.Payload.LastFileLoaded), sizeof(RegRecPtr->LastFileLoaded)); - CFE_ES_GetAppName(CFE_TBL_TaskData.TblRegPacket.Payload.OwnerAppName, RegRecPtr->OwnerAppId, - sizeof(CFE_TBL_TaskData.TblRegPacket.Payload.OwnerAppName)); + CFE_TBL_Global.TblRegPacket.Payload.ValidationFuncPtr = CFE_ES_MEMADDRESS_C(RegRecPtr->ValidationFuncPtr); + CFE_TBL_Global.TblRegPacket.Payload.TimeOfLastUpdate = RegRecPtr->TimeOfLastUpdate; + CFE_TBL_Global.TblRegPacket.Payload.TableLoadedOnce = RegRecPtr->TableLoadedOnce; + CFE_TBL_Global.TblRegPacket.Payload.LoadPending = RegRecPtr->LoadPending; + CFE_TBL_Global.TblRegPacket.Payload.DumpOnly = RegRecPtr->DumpOnly; + CFE_TBL_Global.TblRegPacket.Payload.DoubleBuffered = RegRecPtr->DoubleBuffered; + CFE_TBL_Global.TblRegPacket.Payload.FileCreateTimeSecs = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTimeSecs; + CFE_TBL_Global.TblRegPacket.Payload.FileCreateTimeSubSecs = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].FileCreateTimeSubSecs; + CFE_TBL_Global.TblRegPacket.Payload.Crc = RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].Crc; + CFE_TBL_Global.TblRegPacket.Payload.Critical = RegRecPtr->CriticalTable; + + CFE_SB_MessageStringSet(CFE_TBL_Global.TblRegPacket.Payload.Name, RegRecPtr->Name, + sizeof(CFE_TBL_Global.TblRegPacket.Payload.Name), sizeof(RegRecPtr->Name)); + CFE_SB_MessageStringSet(CFE_TBL_Global.TblRegPacket.Payload.LastFileLoaded, RegRecPtr->LastFileLoaded, + sizeof(CFE_TBL_Global.TblRegPacket.Payload.LastFileLoaded), sizeof(RegRecPtr->LastFileLoaded)); + CFE_ES_GetAppName(CFE_TBL_Global.TblRegPacket.Payload.OwnerAppName, RegRecPtr->OwnerAppId, + sizeof(CFE_TBL_Global.TblRegPacket.Payload.OwnerAppName)); } /* End of CFE_TBL_GetTblRegData() */ @@ -344,12 +344,12 @@ int32 CFE_TBL_NoopCmd(const CFE_TBL_NoopCmd_t *data) int32 CFE_TBL_ResetCountersCmd(const CFE_TBL_ResetCountersCmd_t *data) { - CFE_TBL_TaskData.CommandCounter = 0; - CFE_TBL_TaskData.CommandErrorCounter = 0; - CFE_TBL_TaskData.SuccessValCounter = 0; - CFE_TBL_TaskData.FailedValCounter = 0; - CFE_TBL_TaskData.NumValRequests = 0; - CFE_TBL_TaskData.ValidationCounter = 0; + CFE_TBL_Global.CommandCounter = 0; + CFE_TBL_Global.CommandErrorCounter = 0; + CFE_TBL_Global.SuccessValCounter = 0; + CFE_TBL_Global.FailedValCounter = 0; + CFE_TBL_Global.NumValRequests = 0; + CFE_TBL_Global.ValidationCounter = 0; CFE_EVS_SendEvent(CFE_TBL_RESET_INF_EID, CFE_EVS_EventType_DEBUG, @@ -406,7 +406,7 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data) else { /* Translate the registry index into a record pointer */ - RegRecPtr = &CFE_TBL_TaskData.Registry[Status]; + RegRecPtr = &CFE_TBL_Global.Registry[Status]; if (RegRecPtr->DumpOnly) { @@ -483,14 +483,14 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data) WorkingBufferPtr->Validated = (RegRecPtr->ValidationFuncPtr == NULL); /* Save file information statistics for housekeeping telemetry */ - strncpy(CFE_TBL_TaskData.HkPacket.Payload.LastFileLoaded, LoadFilename, - sizeof(CFE_TBL_TaskData.HkPacket.Payload.LastFileLoaded) - 1); - CFE_TBL_TaskData.HkPacket.Payload.LastFileLoaded[ - sizeof(CFE_TBL_TaskData.HkPacket.Payload.LastFileLoaded) - 1] = '\0'; - strncpy(CFE_TBL_TaskData.HkPacket.Payload.LastTableLoaded, TblFileHeader.TableName, - sizeof(CFE_TBL_TaskData.HkPacket.Payload.LastTableLoaded) - 1); - CFE_TBL_TaskData.HkPacket.Payload.LastTableLoaded[ - sizeof(CFE_TBL_TaskData.HkPacket.Payload.LastTableLoaded) - 1] = '\0'; + strncpy(CFE_TBL_Global.HkPacket.Payload.LastFileLoaded, LoadFilename, + sizeof(CFE_TBL_Global.HkPacket.Payload.LastFileLoaded) - 1); + CFE_TBL_Global.HkPacket.Payload.LastFileLoaded[ + sizeof(CFE_TBL_Global.HkPacket.Payload.LastFileLoaded) - 1] = '\0'; + strncpy(CFE_TBL_Global.HkPacket.Payload.LastTableLoaded, TblFileHeader.TableName, + sizeof(CFE_TBL_Global.HkPacket.Payload.LastTableLoaded) - 1); + CFE_TBL_Global.HkPacket.Payload.LastTableLoaded[ + sizeof(CFE_TBL_Global.HkPacket.Payload.LastTableLoaded) - 1] = '\0'; /* Increment successful command completion counter */ ReturnCode = CFE_TBL_INC_CMD_CTR; @@ -603,7 +603,7 @@ int32 CFE_TBL_DumpCmd(const CFE_TBL_DumpCmd_t *data) if (RegIndex != CFE_TBL_NOT_FOUND) { /* Obtain a pointer to registry information about specified table */ - RegRecPtr = &CFE_TBL_TaskData.Registry[RegIndex]; + RegRecPtr = &CFE_TBL_Global.Registry[RegIndex]; /* Determine what data is to be dumped */ if (CmdPtr->ActiveTableFlag == CFE_TBL_BufferSelect_ACTIVE) @@ -623,7 +623,7 @@ int32 CFE_TBL_DumpCmd(const CFE_TBL_DumpCmd_t *data) /* Unless this is a table whose address was defined by the owning Application. */ if ((RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS) && (!RegRecPtr->UserDefAddr)) { - DumpDataAddr = CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr; + DumpDataAddr = CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr; } else { @@ -658,7 +658,7 @@ int32 CFE_TBL_DumpCmd(const CFE_TBL_DumpCmd_t *data) /* Find a free Dump Control Block */ DumpIndex = 0; while ((DumpIndex < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS) && - (CFE_TBL_TaskData.DumpControlBlocks[DumpIndex].State != CFE_TBL_DUMP_FREE)) + (CFE_TBL_Global.DumpControlBlocks[DumpIndex].State != CFE_TBL_DUMP_FREE)) { DumpIndex++; } @@ -670,7 +670,7 @@ int32 CFE_TBL_DumpCmd(const CFE_TBL_DumpCmd_t *data) if (Status == CFE_SUCCESS) { - DumpCtrlPtr = &CFE_TBL_TaskData.DumpControlBlocks[DumpIndex]; + DumpCtrlPtr = &CFE_TBL_Global.DumpControlBlocks[DumpIndex]; DumpCtrlPtr->State = CFE_TBL_DUMP_PENDING; DumpCtrlPtr->RegRecPtr = RegRecPtr; @@ -817,9 +817,9 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *T } /* Save file information statistics for housekeeping telemetry */ - strncpy(CFE_TBL_TaskData.HkPacket.Payload.LastFileDumped, DumpFilename, - sizeof(CFE_TBL_TaskData.HkPacket.Payload.LastFileDumped)-1); - CFE_TBL_TaskData.HkPacket.Payload.LastFileDumped[sizeof(CFE_TBL_TaskData.HkPacket.Payload.LastFileDumped)-1] = 0; + strncpy(CFE_TBL_Global.HkPacket.Payload.LastFileDumped, DumpFilename, + sizeof(CFE_TBL_Global.HkPacket.Payload.LastFileDumped)-1); + CFE_TBL_Global.HkPacket.Payload.LastFileDumped[sizeof(CFE_TBL_Global.HkPacket.Payload.LastFileDumped)-1] = 0; /* Increment Successful Command Counter */ ReturnCode = CFE_TBL_INC_CMD_CTR; @@ -890,7 +890,7 @@ int32 CFE_TBL_ValidateCmd(const CFE_TBL_ValidateCmd_t *data) if (RegIndex != CFE_TBL_NOT_FOUND) { /* Obtain a pointer to registry information about specified table */ - RegRecPtr = &CFE_TBL_TaskData.Registry[RegIndex]; + RegRecPtr = &CFE_TBL_Global.Registry[RegIndex]; /* Determine what data is to be validated */ if (CmdPtr->ActiveTableFlag == CFE_TBL_BufferSelect_ACTIVE) @@ -909,7 +909,7 @@ int32 CFE_TBL_ValidateCmd(const CFE_TBL_ValidateCmd_t *data) /* For single buffered tables, the index to the inactive buffer is kept in 'LoadInProgress' */ if (RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS) { - ValidationDataPtr = CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr; + ValidationDataPtr = CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr; } else { @@ -935,7 +935,7 @@ int32 CFE_TBL_ValidateCmd(const CFE_TBL_ValidateCmd_t *data) /* Find a free Validation Response Block */ ValIndex = 0; while ((ValIndex < CFE_PLATFORM_TBL_MAX_NUM_VALIDATIONS) && - (CFE_TBL_TaskData.ValidationResults[ValIndex].State != CFE_TBL_VALIDATION_FREE)) + (CFE_TBL_Global.ValidationResults[ValIndex].State != CFE_TBL_VALIDATION_FREE)) { ValIndex++; } @@ -943,9 +943,9 @@ int32 CFE_TBL_ValidateCmd(const CFE_TBL_ValidateCmd_t *data) if (ValIndex < CFE_PLATFORM_TBL_MAX_NUM_VALIDATIONS) { /* Allocate this Validation Response Block */ - CFE_TBL_TaskData.ValidationResults[ValIndex].State = CFE_TBL_VALIDATION_PENDING; - CFE_TBL_TaskData.ValidationResults[ValIndex].Result = 0; - memcpy(CFE_TBL_TaskData.ValidationResults[ValIndex].TableName, + CFE_TBL_Global.ValidationResults[ValIndex].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[ValIndex].Result = 0; + memcpy(CFE_TBL_Global.ValidationResults[ValIndex].TableName, TableName, CFE_TBL_MAX_FULL_NAME_LEN); /* Compute the CRC on the specified table buffer */ @@ -954,8 +954,8 @@ int32 CFE_TBL_ValidateCmd(const CFE_TBL_ValidateCmd_t *data) 0, CFE_MISSION_ES_DEFAULT_CRC); - CFE_TBL_TaskData.ValidationResults[ValIndex].CrcOfTable = CrcOfTable; - CFE_TBL_TaskData.ValidationResults[ValIndex].ActiveBuffer = (CmdPtr->ActiveTableFlag != 0); + CFE_TBL_Global.ValidationResults[ValIndex].CrcOfTable = CrcOfTable; + CFE_TBL_Global.ValidationResults[ValIndex].ActiveBuffer = (CmdPtr->ActiveTableFlag != 0); /* If owner has a validation function, then notify the */ /* table owner that there is data to be validated */ @@ -981,14 +981,14 @@ int32 CFE_TBL_ValidateCmd(const CFE_TBL_ValidateCmd_t *data) } /* Maintain statistic on number of validation requests given to applications */ - CFE_TBL_TaskData.NumValRequests++; + CFE_TBL_Global.NumValRequests++; } else { /* If there isn't a validation function pointer, then the process is complete */ /* By setting this value, we are letting the Housekeeping process recognize it */ /* as data to be sent to the ground in telemetry. */ - CFE_TBL_TaskData.ValidationResults[ValIndex].State = CFE_TBL_VALIDATION_PERFORMED; + CFE_TBL_Global.ValidationResults[ValIndex].State = CFE_TBL_VALIDATION_PERFORMED; CFE_EVS_SendEvent(CFE_TBL_ASSUMED_VALID_INF_EID, CFE_EVS_EventType_INFORMATION, @@ -1046,7 +1046,7 @@ int32 CFE_TBL_ActivateCmd(const CFE_TBL_ActivateCmd_t *data) if (RegIndex != CFE_TBL_NOT_FOUND) { /* Obtain a pointer to registry information about specified table */ - RegRecPtr = &CFE_TBL_TaskData.Registry[RegIndex]; + RegRecPtr = &CFE_TBL_Global.Registry[RegIndex]; if (RegRecPtr->DumpOnly) { @@ -1064,12 +1064,12 @@ int32 CFE_TBL_ActivateCmd(const CFE_TBL_ActivateCmd_t *data) } else { - ValidationStatus = CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].Validated; + ValidationStatus = CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].Validated; } if (ValidationStatus == true) { - CFE_TBL_TaskData.Registry[RegIndex].LoadPending = true; + CFE_TBL_Global.Registry[RegIndex].LoadPending = true; /* If application requested notification by message, then do so */ if (CFE_TBL_SendNotificationMsg(RegRecPtr) == CFE_SUCCESS) @@ -1169,10 +1169,10 @@ int32 CFE_TBL_DumpRegistryCmd(const CFE_TBL_DumpRegistryCmd_t *data) while ((RegIndex < CFE_PLATFORM_TBL_MAX_NUM_TABLES) && (Status == sizeof(CFE_TBL_RegDumpRec_t))) { /* Make a pointer to simplify code look and to remove redundant indexing into registry */ - RegRecPtr = &CFE_TBL_TaskData.Registry[RegIndex]; + RegRecPtr = &CFE_TBL_Global.Registry[RegIndex]; /* Check to see if the Registry entry is empty */ - if (!CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED) || + if (!CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED) || (RegRecPtr->HeadOfAccessList != CFE_TBL_END_OF_LIST)) { /* Fill Registry Dump Record with relevant information */ @@ -1220,11 +1220,11 @@ int32 CFE_TBL_DumpRegistryCmd(const CFE_TBL_DumpRegistryCmd_t *data) while (HandleIterator != CFE_TBL_END_OF_LIST) { DumpRecord.NumUsers++; - HandleIterator = CFE_TBL_TaskData.Handles[HandleIterator].NextLink; + HandleIterator = CFE_TBL_Global.Handles[HandleIterator].NextLink; } /* Determine the name of the owning application */ - if (!CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED)) + if (!CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED)) { CFE_ES_GetAppName(DumpRecord.OwnerAppName, RegRecPtr->OwnerAppId, sizeof(DumpRecord.OwnerAppName)); } @@ -1322,7 +1322,7 @@ int32 CFE_TBL_SendRegistryCmd(const CFE_TBL_SendRegistryCmd_t *data) if (RegIndex != CFE_TBL_NOT_FOUND) { /* Change the index used to identify what data is to be telemetered */ - CFE_TBL_TaskData.HkTlmTblRegIndex = RegIndex; + CFE_TBL_Global.HkTlmTblRegIndex = RegIndex; CFE_EVS_SendEvent(CFE_TBL_TLM_REG_CMD_INF_EID, CFE_EVS_EventType_DEBUG, @@ -1376,9 +1376,9 @@ int32 CFE_TBL_DeleteCDSCmd(const CFE_TBL_DeleteCDSCmd_t *data) /* Find table in the Critical Table Registry */ for (i=0; iDoubleBuffered) { /* For single buffered tables, freeing shared buffer entails resetting flag */ - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].Taken = false; + CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].Taken = false; } /* For double buffered tables, freeing buffer is simple */ 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 ba3531cde..fb04b98af 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h @@ -101,11 +101,11 @@ extern void CFE_TBL_GetHkData(void); ** ** \par Description ** Extracts the Table Registry information for the table specified by the -** #CFE_TBL_TaskData_t::HkTlmTblRegIndex variable. It then formats the +** #CFE_TBL_Global_t::HkTlmTblRegIndex variable. It then formats the ** Registry contents into a format appropriate for downlink. ** ** \par Assumptions, External Events, and Notes: -** #CFE_TBL_TaskData_t::HkTlmTblRegIndex is assumed to be a valid index into +** #CFE_TBL_Global_t::HkTlmTblRegIndex is assumed to be a valid index into ** the Table Registry. ** ** diff --git a/fsw/cfe-core/src/time/cfe_time_api.c b/fsw/cfe-core/src/time/cfe_time_api.c index 8fecdc9ce..2bbfa92e6 100644 --- a/fsw/cfe-core/src/time/cfe_time_api.c +++ b/fsw/cfe-core/src/time/cfe_time_api.c @@ -200,42 +200,42 @@ uint16 CFE_TIME_GetClockInfo(void) /* ** Clock source set to "internal"... */ - if (CFE_TIME_TaskData.ClockSource == CFE_TIME_SourceSelect_INTERNAL) + if (CFE_TIME_Global.ClockSource == CFE_TIME_SourceSelect_INTERNAL) { StateFlags |= CFE_TIME_FLAG_SRCINT; } /* ** Clock signal set to "primary"... */ - if (CFE_TIME_TaskData.ClockSignal == CFE_TIME_ToneSignalSelect_PRIMARY) + if (CFE_TIME_Global.ClockSignal == CFE_TIME_ToneSignalSelect_PRIMARY) { StateFlags |= CFE_TIME_FLAG_SIGPRI; } /* ** Time Server is in FLYWHEEL mode... */ - if (CFE_TIME_TaskData.ServerFlyState == CFE_TIME_FlywheelState_IS_FLY) + if (CFE_TIME_Global.ServerFlyState == CFE_TIME_FlywheelState_IS_FLY) { StateFlags |= CFE_TIME_FLAG_SRVFLY; } /* ** This instance of Time Services commanded into FLYWHEEL... */ - if (CFE_TIME_TaskData.Forced2Fly) + if (CFE_TIME_Global.Forced2Fly) { StateFlags |= CFE_TIME_FLAG_CMDFLY; } /* ** One time STCF adjustment direction... */ - if (CFE_TIME_TaskData.OneTimeDirection == CFE_TIME_AdjustDirection_ADD) + if (CFE_TIME_Global.OneTimeDirection == CFE_TIME_AdjustDirection_ADD) { StateFlags |= CFE_TIME_FLAG_ADDADJ; } /* ** 1 Hz STCF adjustment direction... */ - if (CFE_TIME_TaskData.OneHzDirection == CFE_TIME_AdjustDirection_ADD) + if (CFE_TIME_Global.OneHzDirection == CFE_TIME_AdjustDirection_ADD) { StateFlags |= CFE_TIME_FLAG_ADD1HZ; } @@ -256,7 +256,7 @@ uint16 CFE_TIME_GetClockInfo(void) /* ** The tone is good */ - if (CFE_TIME_TaskData.IsToneGood == true) + if (CFE_TIME_Global.IsToneGood == true) { StateFlags |= CFE_TIME_FLAG_GDTONE; } @@ -690,7 +690,7 @@ void CFE_TIME_ExternalTone(void) int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) { int32 Status; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; uint32 AppIndex; Status = CFE_ES_GetAppID(&AppId); @@ -701,14 +701,14 @@ int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPt if (Status == CFE_SUCCESS) { - if (AppIndex >= (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0])) || - CFE_TIME_TaskData.SynchCallback[AppIndex].Ptr != NULL) + if (AppIndex >= (sizeof(CFE_TIME_Global.SynchCallback) / sizeof(CFE_TIME_Global.SynchCallback[0])) || + CFE_TIME_Global.SynchCallback[AppIndex].Ptr != NULL) { Status = CFE_TIME_TOO_MANY_SYNCH_CALLBACKS; } else { - CFE_TIME_TaskData.SynchCallback[AppIndex].Ptr = CallbackFuncPtr; + CFE_TIME_Global.SynchCallback[AppIndex].Ptr = CallbackFuncPtr; } } } @@ -723,7 +723,7 @@ int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPt int32 CFE_TIME_UnregisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) { int32 Status; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; uint32 AppIndex; Status = CFE_ES_GetAppID(&AppId); @@ -737,14 +737,14 @@ int32 CFE_TIME_UnregisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFunc return Status; } - if (AppIndex >= (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0])) || - CFE_TIME_TaskData.SynchCallback[AppIndex].Ptr != CallbackFuncPtr) + if (AppIndex >= (sizeof(CFE_TIME_Global.SynchCallback) / sizeof(CFE_TIME_Global.SynchCallback[0])) || + CFE_TIME_Global.SynchCallback[AppIndex].Ptr != CallbackFuncPtr) { Status = CFE_TIME_CALLBACK_NOT_REGISTERED; } else { - CFE_TIME_TaskData.SynchCallback[AppIndex].Ptr = NULL; + CFE_TIME_Global.SynchCallback[AppIndex].Ptr = NULL; } return Status; diff --git a/fsw/cfe-core/src/time/cfe_time_task.c b/fsw/cfe-core/src/time/cfe_time_task.c index ee81746d6..66e6bb9f0 100644 --- a/fsw/cfe-core/src/time/cfe_time_task.c +++ b/fsw/cfe-core/src/time/cfe_time_task.c @@ -40,7 +40,7 @@ /* ** Time task global data... */ -CFE_TIME_TaskData_t CFE_TIME_TaskData; +CFE_TIME_Global_t CFE_TIME_Global; /* @@ -118,7 +118,7 @@ int32 CFE_TIME_SubDelayCmd(const CFE_TIME_SubDelayCmd_t *data); int32 CFE_TIME_EarlyInit(void) { /* - ** Initialize global Time Services data... + ** Initialize global Time Services nonzero data... */ CFE_TIME_InitData(); @@ -169,7 +169,7 @@ void CFE_TIME_TaskMain(void) /* Pend on receipt of packet */ Status = CFE_SB_ReceiveBuffer(&SBBufPtr, - CFE_TIME_TaskData.CmdPipe, + CFE_TIME_Global.CmdPipe, CFE_SB_PEND_FOREVER); CFE_ES_PerfLogEntry(CFE_MISSION_TIME_MAIN_PERF_ID); @@ -216,7 +216,7 @@ int32 CFE_TIME_TaskInit(void) return Status; }/* end if */ - Status = OS_BinSemCreate(&CFE_TIME_TaskData.ToneSemaphore, + Status = OS_BinSemCreate(&CFE_TIME_Global.ToneSemaphore, CFE_TIME_SEM_TONE_NAME, CFE_TIME_SEM_VALUE, CFE_TIME_SEM_OPTIONS); @@ -226,7 +226,7 @@ int32 CFE_TIME_TaskInit(void) return Status; }/* end if */ - Status = OS_BinSemCreate(&CFE_TIME_TaskData.LocalSemaphore, + Status = OS_BinSemCreate(&CFE_TIME_Global.LocalSemaphore, CFE_TIME_SEM_1HZ_NAME, CFE_TIME_SEM_VALUE, CFE_TIME_SEM_OPTIONS); @@ -237,7 +237,7 @@ int32 CFE_TIME_TaskInit(void) }/* end if */ - Status = CFE_ES_CreateChildTask(&CFE_TIME_TaskData.ToneTaskID, + Status = CFE_ES_CreateChildTask(&CFE_TIME_Global.ToneTaskID, CFE_TIME_TASK_TONE_NAME, CFE_TIME_Tone1HzTask, CFE_TIME_TASK_STACK_PTR, @@ -251,7 +251,7 @@ int32 CFE_TIME_TaskInit(void) }/* end if */ - Status = CFE_ES_CreateChildTask(&CFE_TIME_TaskData.LocalTaskID, + Status = CFE_ES_CreateChildTask(&CFE_TIME_Global.LocalTaskID, CFE_TIME_TASK_1HZ_NAME, CFE_TIME_Local1HzTask, CFE_TIME_TASK_STACK_PTR, @@ -265,7 +265,7 @@ int32 CFE_TIME_TaskInit(void) }/* end if */ - Status = CFE_SB_CreatePipe(&CFE_TIME_TaskData.CmdPipe, CFE_TIME_TASK_PIPE_DEPTH, CFE_TIME_TASK_PIPE_NAME); + Status = CFE_SB_CreatePipe(&CFE_TIME_Global.CmdPipe, CFE_TIME_TASK_PIPE_DEPTH, CFE_TIME_TASK_PIPE_NAME); if(Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("TIME:Error creating cmd pipe:RC=0x%08X\n",(unsigned int)Status); @@ -274,7 +274,7 @@ int32 CFE_TIME_TaskInit(void) Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_TIME_SEND_HK_MID), - CFE_TIME_TaskData.CmdPipe); + CFE_TIME_Global.CmdPipe); if(Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("TIME:Error subscribing to HK Request:RC=0x%08X\n",(unsigned int)Status); @@ -287,12 +287,12 @@ int32 CFE_TIME_TaskInit(void) */ #if (CFE_PLATFORM_TIME_CFG_CLIENT == true) Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_TIME_TONE_CMD_MID), - CFE_TIME_TaskData.CmdPipe); + CFE_TIME_Global.CmdPipe); #endif #if (CFE_PLATFORM_TIME_CFG_SERVER == true) Status = CFE_SB_SubscribeLocal(CFE_SB_ValueToMsgId(CFE_TIME_TONE_CMD_MID), - CFE_TIME_TaskData.CmdPipe,4); + CFE_TIME_Global.CmdPipe,4); #endif if(Status != CFE_SUCCESS) { @@ -306,12 +306,12 @@ int32 CFE_TIME_TaskInit(void) */ #if (CFE_PLATFORM_TIME_CFG_CLIENT == true) Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_TIME_DATA_CMD_MID), - CFE_TIME_TaskData.CmdPipe); + CFE_TIME_Global.CmdPipe); #endif #if (CFE_PLATFORM_TIME_CFG_SERVER == true) Status = CFE_SB_SubscribeLocal(CFE_SB_ValueToMsgId(CFE_TIME_DATA_CMD_MID), - CFE_TIME_TaskData.CmdPipe,4); + CFE_TIME_Global.CmdPipe,4); #endif if(Status != CFE_SUCCESS) { @@ -325,12 +325,12 @@ int32 CFE_TIME_TaskInit(void) */ #if (CFE_PLATFORM_TIME_CFG_CLIENT == true) Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_TIME_1HZ_CMD_MID), - CFE_TIME_TaskData.CmdPipe); + CFE_TIME_Global.CmdPipe); #endif #if (CFE_PLATFORM_TIME_CFG_SERVER == true) Status = CFE_SB_SubscribeLocal(CFE_SB_ValueToMsgId(CFE_TIME_1HZ_CMD_MID), - CFE_TIME_TaskData.CmdPipe,4); + CFE_TIME_Global.CmdPipe,4); #endif if(Status != CFE_SUCCESS) @@ -345,7 +345,7 @@ int32 CFE_TIME_TaskInit(void) */ #if (CFE_PLATFORM_TIME_CFG_SERVER == true) Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_TIME_SEND_CMD_MID), - CFE_TIME_TaskData.CmdPipe); + CFE_TIME_Global.CmdPipe); if(Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("TIME:Error subscribing to time at the tone request data cmds:RC=0x%08X\n",(unsigned int)Status); @@ -357,7 +357,7 @@ int32 CFE_TIME_TaskInit(void) ** Subscribe to Time task ground command packets... */ Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_TIME_CMD_MID), - CFE_TIME_TaskData.CmdPipe); + CFE_TIME_Global.CmdPipe); if(Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("TIME:Error subscribing to time task gnd cmds:RC=0x%08X\n",(unsigned int)Status); @@ -378,7 +378,7 @@ int32 CFE_TIME_TaskInit(void) ** Select primary vs redundant tone interrupt signal... */ #if (CFE_PLATFORM_TIME_CFG_SIGNAL == true) - OS_SelectTone(CFE_TIME_TaskData.ClockSignal); + OS_SelectTone(CFE_TIME_Global.ClockSignal); #endif /* @@ -448,7 +448,7 @@ bool CFE_TIME_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, (unsigned int)ExpectedLength); result = false; - ++CFE_TIME_TaskData.CommandErrorCounter; + ++CFE_TIME_Global.CommandErrorCounter; } return(result); @@ -636,7 +636,7 @@ void CFE_TIME_TaskPipe(CFE_SB_Buffer_t *SBBufPtr) default: - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_CC_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid command code -- ID = 0x%X, CC = %d", (unsigned int)CFE_SB_MsgIdToValue(MessageID), @@ -691,8 +691,8 @@ int32 CFE_TIME_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) /* ** Send housekeeping telemetry packet... */ - CFE_SB_TimeStampMsg(&CFE_TIME_TaskData.HkPacket.TlmHeader.Msg); - CFE_SB_TransmitMsg(&CFE_TIME_TaskData.HkPacket.TlmHeader.Msg, true); + CFE_SB_TimeStampMsg(&CFE_TIME_Global.HkPacket.TlmHeader.Msg); + CFE_SB_TransmitMsg(&CFE_TIME_Global.HkPacket.TlmHeader.Msg, true); /* ** Note: we only increment the command execution counter when @@ -816,7 +816,7 @@ int32 CFE_TIME_ToneSendCmd(const CFE_TIME_FakeToneCmd_t *data) int32 CFE_TIME_NoopCmd(const CFE_TIME_NoopCmd_t *data) { - CFE_TIME_TaskData.CommandCounter++; + CFE_TIME_Global.CommandCounter++; CFE_EVS_SendEvent(CFE_TIME_NOOP_EID, CFE_EVS_EventType_INFORMATION, "No-op command.%s", CFE_VERSION_STRING); @@ -835,31 +835,31 @@ int32 CFE_TIME_NoopCmd(const CFE_TIME_NoopCmd_t *data) int32 CFE_TIME_ResetCountersCmd(const CFE_TIME_ResetCountersCmd_t *data) { - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; - CFE_TIME_TaskData.ToneMatchCounter = 0; - CFE_TIME_TaskData.ToneMatchErrorCounter = 0; + CFE_TIME_Global.ToneMatchCounter = 0; + CFE_TIME_Global.ToneMatchErrorCounter = 0; - CFE_TIME_TaskData.ToneSignalCounter = 0; - CFE_TIME_TaskData.ToneDataCounter = 0; + CFE_TIME_Global.ToneSignalCounter = 0; + CFE_TIME_Global.ToneDataCounter = 0; - CFE_TIME_TaskData.ToneIntCounter = 0; - CFE_TIME_TaskData.ToneIntErrorCounter = 0; - CFE_TIME_TaskData.ToneTaskCounter = 0; + CFE_TIME_Global.ToneIntCounter = 0; + CFE_TIME_Global.ToneIntErrorCounter = 0; + CFE_TIME_Global.ToneTaskCounter = 0; /* * Note: Not resetting "LastVersion" counter here, that might * disturb access to the time reference data by other tasks */ - CFE_TIME_TaskData.ResetVersionCounter = - CFE_TIME_TaskData.LastVersionCounter; + CFE_TIME_Global.ResetVersionCounter = + CFE_TIME_Global.LastVersionCounter; - CFE_TIME_TaskData.LocalIntCounter = 0; - CFE_TIME_TaskData.LocalTaskCounter = 0; + CFE_TIME_Global.LocalIntCounter = 0; + CFE_TIME_Global.LocalTaskCounter = 0; - CFE_TIME_TaskData.InternalCount = 0; - CFE_TIME_TaskData.ExternalCount = 0; + CFE_TIME_Global.InternalCount = 0; + CFE_TIME_Global.ExternalCount = 0; CFE_EVS_SendEvent(CFE_TIME_RESET_EID, CFE_EVS_EventType_DEBUG, "Reset Counters command"); @@ -877,7 +877,7 @@ int32 CFE_TIME_ResetCountersCmd(const CFE_TIME_ResetCountersCmd_t *data) int32 CFE_TIME_SendDiagnosticTlm(const CFE_TIME_SendDiagnosticCmd_t *data) { - CFE_TIME_TaskData.CommandCounter++; + CFE_TIME_Global.CommandCounter++; /* ** Collect diagnostics data from Time Services utilities... @@ -887,8 +887,8 @@ int32 CFE_TIME_SendDiagnosticTlm(const CFE_TIME_SendDiagnosticCmd_t *data) /* ** Send diagnostics telemetry packet... */ - CFE_SB_TimeStampMsg(&CFE_TIME_TaskData.DiagPacket.TlmHeader.Msg); - CFE_SB_TransmitMsg(&CFE_TIME_TaskData.DiagPacket.TlmHeader.Msg, true); + CFE_SB_TimeStampMsg(&CFE_TIME_Global.DiagPacket.TlmHeader.Msg); + CFE_SB_TransmitMsg(&CFE_TIME_Global.DiagPacket.TlmHeader.Msg, true); CFE_EVS_SendEvent(CFE_TIME_DIAG_EID, CFE_EVS_EventType_DEBUG, "Request diagnostics command"); @@ -934,13 +934,13 @@ int32 CFE_TIME_SetStateCmd(const CFE_TIME_SetStateCmd_t *data) ClockStateText = "FLYWHEEL"; } - CFE_TIME_TaskData.CommandCounter++; + CFE_TIME_Global.CommandCounter++; CFE_EVS_SendEvent(CFE_TIME_STATE_EID, CFE_EVS_EventType_INFORMATION, "Set Clock State = %s", ClockStateText); } else { - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_STATE_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid Clock State = 0x%X", (unsigned int)CommandPtr->ClockState); } @@ -974,7 +974,7 @@ int32 CFE_TIME_SetSourceCmd(const CFE_TIME_SetSourceCmd_t *data) /* ** Only systems configured to select source of time data... */ - CFE_TIME_TaskData.CommandCounter++; + CFE_TIME_Global.CommandCounter++; CFE_TIME_SetSource(CommandPtr->TimeSource); @@ -998,7 +998,7 @@ int32 CFE_TIME_SetSourceCmd(const CFE_TIME_SetSourceCmd_t *data) /* ** We want to know if disabled commands are being sent... */ - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_SOURCE_CFG_EID, CFE_EVS_EventType_ERROR, "Set Source commands invalid without CFE_PLATFORM_TIME_CFG_SOURCE set to TRUE"); @@ -1010,7 +1010,7 @@ int32 CFE_TIME_SetSourceCmd(const CFE_TIME_SetSourceCmd_t *data) /* ** Ground system database will prevent most of these errors... */ - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_SOURCE_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid Time Source = 0x%X", (unsigned int)CommandPtr->TimeSource); @@ -1044,7 +1044,7 @@ int32 CFE_TIME_SetSignalCmd(const CFE_TIME_SetSignalCmd_t *data) /* ** Only systems configured to select tone signal... */ - CFE_TIME_TaskData.CommandCounter++; + CFE_TIME_Global.CommandCounter++; CFE_TIME_SetSignal(CommandPtr->ToneSource); @@ -1068,7 +1068,7 @@ int32 CFE_TIME_SetSignalCmd(const CFE_TIME_SetSignalCmd_t *data) /* ** We want to know if disabled commands are being sent... */ - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_SIGNAL_CFG_EID, CFE_EVS_EventType_ERROR, "Set Signal commands invalid without CFE_PLATFORM_TIME_CFG_SIGNAL set to TRUE"); @@ -1080,7 +1080,7 @@ int32 CFE_TIME_SetSignalCmd(const CFE_TIME_SetSignalCmd_t *data) /* ** Ground system database will prevent most of these errors... */ - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_SIGNAL_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid Tone Source = 0x%X", (unsigned int)CommandPtr->ToneSource); @@ -1113,7 +1113,7 @@ void CFE_TIME_SetDelayImpl(const CFE_TIME_TimeCmd_Payload_t *CommandPtr, CFE_TIM CFE_TIME_SetDelay(Delay, Direction); - CFE_TIME_TaskData.CommandCounter++; + CFE_TIME_Global.CommandCounter++; CFE_EVS_SendEvent(CFE_TIME_DELAY_EID, CFE_EVS_EventType_INFORMATION, "Set Tone Delay -- secs = %u, usecs = %u, ssecs = 0x%X, dir = %d", (unsigned int)CommandPtr->Seconds, (unsigned int)CommandPtr->MicroSeconds, @@ -1124,7 +1124,7 @@ void CFE_TIME_SetDelayImpl(const CFE_TIME_TimeCmd_Payload_t *CommandPtr, CFE_TIM /* ** We want to know if disabled commands are being sent... */ - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_DELAY_CFG_EID, CFE_EVS_EventType_ERROR, "Set Delay commands invalid without CFE_PLATFORM_TIME_CFG_CLIENT set to TRUE"); @@ -1133,7 +1133,7 @@ void CFE_TIME_SetDelayImpl(const CFE_TIME_TimeCmd_Payload_t *CommandPtr, CFE_TIM } else { - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_DELAY_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid Tone Delay -- secs = %u, usecs = %u", (unsigned int)CommandPtr->Seconds, (unsigned int)CommandPtr->MicroSeconds); @@ -1184,7 +1184,7 @@ int32 CFE_TIME_SetTimeCmd(const CFE_TIME_SetTimeCmd_t *data) CFE_TIME_SetTime(NewTime); - CFE_TIME_TaskData.CommandCounter++; + CFE_TIME_Global.CommandCounter++; CFE_EVS_SendEvent(CFE_TIME_TIME_EID, CFE_EVS_EventType_INFORMATION, "Set Time -- secs = %u, usecs = %u, ssecs = 0x%X", (unsigned int)CommandPtr->Seconds, (unsigned int)CommandPtr->MicroSeconds, @@ -1194,7 +1194,7 @@ int32 CFE_TIME_SetTimeCmd(const CFE_TIME_SetTimeCmd_t *data) /* ** We want to know if disabled commands are being sent... */ - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_TIME_CFG_EID, CFE_EVS_EventType_ERROR, "Set Time commands invalid without CFE_PLATFORM_TIME_CFG_SERVER set to TRUE"); @@ -1203,7 +1203,7 @@ int32 CFE_TIME_SetTimeCmd(const CFE_TIME_SetTimeCmd_t *data) } else { - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_TIME_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid Time -- secs = %u, usecs = %u", (unsigned int)CommandPtr->Seconds, (unsigned int)CommandPtr->MicroSeconds); @@ -1243,7 +1243,7 @@ int32 CFE_TIME_SetMETCmd(const CFE_TIME_SetMETCmd_t *data) CFE_TIME_SetMET(NewMET); - CFE_TIME_TaskData.CommandCounter++; + CFE_TIME_Global.CommandCounter++; CFE_EVS_SendEvent(CFE_TIME_MET_EID, CFE_EVS_EventType_INFORMATION, "Set MET -- secs = %u, usecs = %u, ssecs = 0x%X", (unsigned int)CommandPtr->Seconds, (unsigned int)CommandPtr->MicroSeconds, @@ -1253,7 +1253,7 @@ int32 CFE_TIME_SetMETCmd(const CFE_TIME_SetMETCmd_t *data) /* ** We want to know if disabled commands are being sent... */ - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_MET_CFG_EID, CFE_EVS_EventType_ERROR, "Set MET commands invalid without CFE_PLATFORM_TIME_CFG_SERVER set to TRUE"); @@ -1262,7 +1262,7 @@ int32 CFE_TIME_SetMETCmd(const CFE_TIME_SetMETCmd_t *data) } else { - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_MET_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid MET -- secs = %u, usecs = %u", (unsigned int)CommandPtr->Seconds, (unsigned int)CommandPtr->MicroSeconds); @@ -1297,7 +1297,7 @@ int32 CFE_TIME_SetSTCFCmd(const CFE_TIME_SetSTCFCmd_t *data) CFE_TIME_SetSTCF(NewSTCF); - CFE_TIME_TaskData.CommandCounter++; + CFE_TIME_Global.CommandCounter++; CFE_EVS_SendEvent(CFE_TIME_STCF_EID, CFE_EVS_EventType_INFORMATION, "Set STCF -- secs = %u, usecs = %u, ssecs = 0x%X", (unsigned int)CommandPtr->Seconds, (unsigned int)CommandPtr->MicroSeconds, @@ -1307,7 +1307,7 @@ int32 CFE_TIME_SetSTCFCmd(const CFE_TIME_SetSTCFCmd_t *data) /* ** We want to know if disabled commands are being sent... */ - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_STCF_CFG_EID, CFE_EVS_EventType_ERROR, "Set STCF commands invalid without CFE_PLATFORM_TIME_CFG_SERVER set to TRUE"); @@ -1316,7 +1316,7 @@ int32 CFE_TIME_SetSTCFCmd(const CFE_TIME_SetSTCFCmd_t *data) } else { - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_STCF_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid STCF -- secs = %u, usecs = %u", (unsigned int)CommandPtr->Seconds, (unsigned int)CommandPtr->MicroSeconds); @@ -1344,7 +1344,7 @@ int32 CFE_TIME_SetLeapSecondsCmd(const CFE_TIME_SetLeapSecondsCmd_t *data) */ CFE_TIME_SetLeapSeconds(CommandPtr->LeapSeconds); - CFE_TIME_TaskData.CommandCounter++; + CFE_TIME_Global.CommandCounter++; CFE_EVS_SendEvent(CFE_TIME_LEAPS_EID, CFE_EVS_EventType_INFORMATION, "Set Leap Seconds = %d", (int)CommandPtr->LeapSeconds); @@ -1353,7 +1353,7 @@ int32 CFE_TIME_SetLeapSecondsCmd(const CFE_TIME_SetLeapSecondsCmd_t *data) /* ** We want to know if disabled commands are being sent... */ - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_LEAPS_CFG_EID, CFE_EVS_EventType_ERROR, "Set Leaps commands invalid without CFE_PLATFORM_TIME_CFG_SERVER set to TRUE"); @@ -1387,7 +1387,7 @@ void CFE_TIME_AdjustImpl(const CFE_TIME_TimeCmd_Payload_t *CommandPtr, CFE_TIME_ CFE_TIME_SetAdjust(Adjust, Direction); - CFE_TIME_TaskData.CommandCounter++; + CFE_TIME_Global.CommandCounter++; CFE_EVS_SendEvent(CFE_TIME_DELTA_EID, CFE_EVS_EventType_INFORMATION, "STCF Adjust -- secs = %u, usecs = %u, ssecs = 0x%X, dir[1=Pos, 2=Neg] = %d", (unsigned int)CommandPtr->Seconds, (unsigned int)CommandPtr->MicroSeconds, @@ -1398,7 +1398,7 @@ void CFE_TIME_AdjustImpl(const CFE_TIME_TimeCmd_Payload_t *CommandPtr, CFE_TIME_ /* ** We want to know if disabled commands are being sent... */ - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_DELTA_CFG_EID, CFE_EVS_EventType_ERROR, "STCF Adjust commands invalid without CFE_PLATFORM_TIME_CFG_SERVER set to TRUE"); @@ -1407,7 +1407,7 @@ void CFE_TIME_AdjustImpl(const CFE_TIME_TimeCmd_Payload_t *CommandPtr, CFE_TIME_ } else { - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_DELTA_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid STCF Adjust -- secs = %u, usecs = %u, dir[1=Pos, 2=Neg] = %d", (unsigned int)CommandPtr->Seconds, (unsigned int)CommandPtr->MicroSeconds, (int)Direction); @@ -1462,7 +1462,7 @@ void CFE_TIME_1HzAdjImpl(const CFE_TIME_OneHzAdjustmentCmd_Payload_t *CommandPtr CFE_TIME_Set1HzAdj(Adjust, Direction); - CFE_TIME_TaskData.CommandCounter++; + CFE_TIME_Global.CommandCounter++; CFE_EVS_SendEvent(CFE_TIME_1HZ_EID, CFE_EVS_EventType_INFORMATION, "STCF 1Hz Adjust -- secs = %d, ssecs = 0x%X, dir[1=Pos, 2=Neg] = %d", (int)CommandPtr->Seconds, (unsigned int)CommandPtr->Subseconds, (int)Direction); @@ -1471,7 +1471,7 @@ void CFE_TIME_1HzAdjImpl(const CFE_TIME_OneHzAdjustmentCmd_Payload_t *CommandPtr /* ** We want to know if disabled commands are being sent... */ - CFE_TIME_TaskData.CommandErrorCounter++; + CFE_TIME_Global.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_TIME_1HZ_CFG_EID, CFE_EVS_EventType_ERROR, "1Hz Adjust commands invalid without CFE_PLATFORM_TIME_CFG_SERVER set to TRUE"); diff --git a/fsw/cfe-core/src/time/cfe_time_tone.c b/fsw/cfe-core/src/time/cfe_time_tone.c index 0cc067723..1505d6a73 100644 --- a/fsw/cfe-core/src/time/cfe_time_tone.c +++ b/fsw/cfe-core/src/time/cfe_time_tone.c @@ -95,7 +95,7 @@ void CFE_TIME_ToneSend(void) ** MET seconds is the count of tone interrupts... */ #if (CFE_PLATFORM_TIME_CFG_VIRTUAL == true) - NewMET.Seconds = CFE_TIME_TaskData.VirtualMET; + NewMET.Seconds = CFE_TIME_Global.VirtualMET; #endif /* @@ -133,17 +133,17 @@ void CFE_TIME_ToneSend(void) ** Payload must be big-endian. */ - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Seconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Seconds = CFE_MAKE_BIG32(NewMET.Seconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Subseconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Subseconds = CFE_MAKE_BIG32(NewMET.Subseconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneSTCF.Seconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneSTCF.Seconds = CFE_MAKE_BIG32(Reference.AtToneSTCF.Seconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneSTCF.Subseconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneSTCF.Subseconds = CFE_MAKE_BIG32(Reference.AtToneSTCF.Subseconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneLeapSeconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneLeapSeconds = CFE_MAKE_BIG16(Reference.AtToneLeapSeconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneState = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneState = CFE_MAKE_BIG16(AtToneState); #else /* !CFE_PLATFORM_TIME_CFG_BIGENDIAN */ @@ -151,26 +151,26 @@ void CFE_TIME_ToneSend(void) /* ** Remainder of time values are unchanged... */ - CFE_TIME_Copy(&CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET, &NewMET); - CFE_TIME_Copy(&CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneSTCF, &Reference.AtToneSTCF); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneLeapSeconds = Reference.AtToneLeapSeconds; + CFE_TIME_Copy(&CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET, &NewMET); + CFE_TIME_Copy(&CFE_TIME_Global.ToneDataCmd.Payload.AtToneSTCF, &Reference.AtToneSTCF); + CFE_TIME_Global.ToneDataCmd.Payload.AtToneLeapSeconds = Reference.AtToneLeapSeconds; /* ** Current clock state is a combination of factors... */ - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneState = CFE_TIME_CalculateState(&Reference); + CFE_TIME_Global.ToneDataCmd.Payload.AtToneState = CFE_TIME_CalculateState(&Reference); #endif /* CFE_PLATFORM_TIME_CFG_BIGENDIAN */ /* ** Send "time at the tone" command data packet... */ - CFE_SB_TransmitMsg(&CFE_TIME_TaskData.ToneDataCmd.CmdHeader.Msg, false); + CFE_SB_TransmitMsg(&CFE_TIME_Global.ToneDataCmd.CmdHeader.Msg, false); /* ** Count of "time at the tone" commands sent with internal data... */ - CFE_TIME_TaskData.InternalCount++; + CFE_TIME_Global.InternalCount++; return; @@ -213,7 +213,7 @@ int32 CFE_TIME_ToneSendMET(CFE_TIME_SysTime_t NewMET) /* ** Ignore external time data if commanded to use local MET... */ - if (CFE_TIME_TaskData.ClockSource == CFE_TIME_SourceSelect_INTERNAL) + if (CFE_TIME_Global.ClockSource == CFE_TIME_SourceSelect_INTERNAL) { Result = CFE_TIME_INTERNAL_ONLY; @@ -245,8 +245,8 @@ int32 CFE_TIME_ToneSendMET(CFE_TIME_SysTime_t NewMET) /* ** Compute minimum and maximum values for valid MET... */ - MinValid = CFE_TIME_Subtract(Expected, CFE_TIME_TaskData.MaxDelta); - MaxValid = CFE_TIME_Add(Expected, CFE_TIME_TaskData.MaxDelta); + MinValid = CFE_TIME_Subtract(Expected, CFE_TIME_Global.MaxDelta); + MaxValid = CFE_TIME_Add(Expected, CFE_TIME_Global.MaxDelta); /* ** Compare new MET to minimum and maximum MET... @@ -280,37 +280,37 @@ int32 CFE_TIME_ToneSendMET(CFE_TIME_SysTime_t NewMET) /* ** Payload must be big-endian. */ - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Seconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Seconds = CFE_MAKE_BIG32(NewMET.Seconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Subseconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Subseconds = CFE_MAKE_BIG32(NewMET.Subseconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneSTCF.Seconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneSTCF.Seconds = CFE_MAKE_BIG32(Reference.AtToneSTCF.Seconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneSTCF.Subseconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneSTCF.Subseconds = CFE_MAKE_BIG32(Reference.AtToneSTCF.Subseconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneLeapSeconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneLeapSeconds = CFE_MAKE_BIG16(Reference.AtToneLeapSeconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneState = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneState = CFE_MAKE_BIG16(ClockState); #else /* !CFE_PLATFORM_TIME_CFG_BIGENDIAN */ - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET = NewMET; - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneSTCF = Reference.AtToneSTCF; - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneLeapSeconds = Reference.AtToneLeapSeconds; - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneState = ClockState; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET = NewMET; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneSTCF = Reference.AtToneSTCF; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneLeapSeconds = Reference.AtToneLeapSeconds; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneState = ClockState; #endif /* CFE_PLATFORM_TIME_CFG_BIGENDIAN */ /* ** Send "time at the tone" command data packet... */ - CFE_SB_TransmitMsg(&CFE_TIME_TaskData.ToneDataCmd.CmdHeader.Msg, false); + CFE_SB_TransmitMsg(&CFE_TIME_Global.ToneDataCmd.CmdHeader.Msg, false); /* ** Count of "time at the tone" commands sent with external data... */ - CFE_TIME_TaskData.ExternalCount++; + CFE_TIME_Global.ExternalCount++; } } @@ -356,7 +356,7 @@ int32 CFE_TIME_ToneSendGPS(CFE_TIME_SysTime_t NewTime, int16 NewLeaps) /* ** Ignore external time data if commanded to use local MET... */ - if (CFE_TIME_TaskData.ClockSource == CFE_TIME_SourceSelect_INTERNAL) + if (CFE_TIME_Global.ClockSource == CFE_TIME_SourceSelect_INTERNAL) { Result = CFE_TIME_INTERNAL_ONLY; @@ -400,8 +400,8 @@ int32 CFE_TIME_ToneSendGPS(CFE_TIME_SysTime_t NewTime, int16 NewLeaps) /* ** Compute minimum and maximum values for valid STCF... */ - MinValid = CFE_TIME_Subtract(Reference.AtToneSTCF, CFE_TIME_TaskData.MaxDelta); - MaxValid = CFE_TIME_Add(Reference.AtToneSTCF, CFE_TIME_TaskData.MaxDelta); + MinValid = CFE_TIME_Subtract(Reference.AtToneSTCF, CFE_TIME_Global.MaxDelta); + MaxValid = CFE_TIME_Add(Reference.AtToneSTCF, CFE_TIME_Global.MaxDelta); /* ** Compare new STCF to minimum and maximum STCF... @@ -434,37 +434,37 @@ int32 CFE_TIME_ToneSendGPS(CFE_TIME_SysTime_t NewTime, int16 NewLeaps) /* ** Payload must be big-endian. */ - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Seconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Seconds = CFE_MAKE_BIG32(NewMET.Seconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Subseconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Subseconds = CFE_MAKE_BIG32(NewMET.Subseconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneSTCF.Seconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneSTCF.Seconds = CFE_MAKE_BIG32(NewSTCF.Seconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneSTCF.Subseconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneSTCF.Subseconds = CFE_MAKE_BIG32(NewSTCF.Subseconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneLeapSeconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneLeapSeconds = CFE_MAKE_BIG16(NewLeaps); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneState = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneState = CFE_MAKE_BIG16(ClockState); #else /* !CFE_PLATFORM_TIME_CFG_BIGENDIAN */ - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET = NewMET; - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneSTCF = NewSTCF; - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneLeapSeconds = NewLeaps; - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneState = ClockState; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET = NewMET; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneSTCF = NewSTCF; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneLeapSeconds = NewLeaps; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneState = ClockState; #endif /* CFE_PLATFORM_TIME_CFG_BIGENDIAN */ /* ** Send "time at the tone" command data packet... */ - CFE_SB_TransmitMsg(&CFE_TIME_TaskData.ToneDataCmd.CmdHeader.Msg, false); + CFE_SB_TransmitMsg(&CFE_TIME_Global.ToneDataCmd.CmdHeader.Msg, false); /* ** Count of "time at the tone" commands sent with external data... */ - CFE_TIME_TaskData.ExternalCount++; + CFE_TIME_Global.ExternalCount++; } } @@ -507,7 +507,7 @@ int32 CFE_TIME_ToneSendTime(CFE_TIME_SysTime_t NewTime) /* ** Ignore external time data if commanded to use local MET... */ - if (CFE_TIME_TaskData.ClockSource == CFE_TIME_SourceSelect_INTERNAL) + if (CFE_TIME_Global.ClockSource == CFE_TIME_SourceSelect_INTERNAL) { Result = CFE_TIME_INTERNAL_ONLY; @@ -551,8 +551,8 @@ int32 CFE_TIME_ToneSendTime(CFE_TIME_SysTime_t NewTime) /* ** Compute minimum and maximum values for valid STCF... */ - MinValid = CFE_TIME_Subtract(Reference.AtToneSTCF, CFE_TIME_TaskData.MaxDelta); - MaxValid = CFE_TIME_Add(Reference.AtToneSTCF, CFE_TIME_TaskData.MaxDelta); + MinValid = CFE_TIME_Subtract(Reference.AtToneSTCF, CFE_TIME_Global.MaxDelta); + MaxValid = CFE_TIME_Add(Reference.AtToneSTCF, CFE_TIME_Global.MaxDelta); /* ** Compare new STCF to minimum and maximum STCF... @@ -587,37 +587,37 @@ int32 CFE_TIME_ToneSendTime(CFE_TIME_SysTime_t NewTime) ** Payload must be big-endian. */ - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Seconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Seconds = CFE_MAKE_BIG32(NewMET.Seconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Subseconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Subseconds = CFE_MAKE_BIG32(NewMET.Subseconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneSTCF.Seconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneSTCF.Seconds = CFE_MAKE_BIG32(NewSTCF.Seconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneSTCF.Subseconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneSTCF.Subseconds = CFE_MAKE_BIG32(NewSTCF.Subseconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneLeapSeconds = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneLeapSeconds = CFE_MAKE_BIG16(Reference.AtToneLeapSeconds); - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneState = + CFE_TIME_Global.ToneDataCmd.Payload.AtToneState = CFE_MAKE_BIG16(ClockState); #else /* !CFE_PLATFORM_TIME_CFG_BIGENDIAN */ - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET = NewMET; - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneSTCF = NewSTCF; - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneLeapSeconds = Reference.AtToneLeapSeconds; - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneState = ClockState; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET = NewMET; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneSTCF = NewSTCF; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneLeapSeconds = Reference.AtToneLeapSeconds; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneState = ClockState; #endif /* CFE_PLATFORM_TIME_CFG_BIGENDIAN */ /* ** Send "time at the tone" command data packet... */ - CFE_SB_TransmitMsg(&CFE_TIME_TaskData.ToneDataCmd.CmdHeader.Msg, false); + CFE_SB_TransmitMsg(&CFE_TIME_Global.ToneDataCmd.CmdHeader.Msg, false); /* ** Count of "time at the tone" commands sent with external data... */ - CFE_TIME_TaskData.ExternalCount++; + CFE_TIME_Global.ExternalCount++; } } @@ -638,7 +638,7 @@ void CFE_TIME_ToneData(const CFE_TIME_ToneDataCmd_Payload_t *ToneDataCmd) /* ** Save the time when the data packet was received... */ - CFE_TIME_TaskData.ToneDataLatch = CFE_TIME_LatchClock(); + CFE_TIME_Global.ToneDataLatch = CFE_TIME_LatchClock(); /* ** Save the data packet (may be a while before the data is used)... @@ -649,23 +649,23 @@ void CFE_TIME_ToneData(const CFE_TIME_ToneDataCmd_Payload_t *ToneDataCmd) /* ** Tone data will be big-endian, convert to platform-endian. */ - CFE_TIME_TaskData.PendingMET.Seconds = + CFE_TIME_Global.PendingMET.Seconds = CFE_MAKE_BIG32(ToneDataCmd->AtToneMET.Seconds); - CFE_TIME_TaskData.PendingMET.Subseconds = + CFE_TIME_Global.PendingMET.Subseconds = CFE_MAKE_BIG32(ToneDataCmd->AtToneMET.Subseconds); - CFE_TIME_TaskData.PendingSTCF.Seconds = + CFE_TIME_Global.PendingSTCF.Seconds = CFE_MAKE_BIG32(ToneDataCmd->AtToneSTCF.Seconds); - CFE_TIME_TaskData.PendingSTCF.Subseconds = + CFE_TIME_Global.PendingSTCF.Subseconds = CFE_MAKE_BIG32(ToneDataCmd->AtToneSTCF.Subseconds); - CFE_TIME_TaskData.PendingLeaps = CFE_MAKE_BIG16(ToneDataCmd->AtToneLeapSeconds); - CFE_TIME_TaskData.PendingState = CFE_MAKE_BIG16(ToneDataCmd->AtToneState); + CFE_TIME_Global.PendingLeaps = CFE_MAKE_BIG16(ToneDataCmd->AtToneLeapSeconds); + CFE_TIME_Global.PendingState = CFE_MAKE_BIG16(ToneDataCmd->AtToneState); #else /* !CFE_PLATFORM_TIME_CFG_BIGENDIAN */ - CFE_TIME_Copy(&CFE_TIME_TaskData.PendingMET, &ToneDataCmd->AtToneMET); - CFE_TIME_Copy(&CFE_TIME_TaskData.PendingSTCF, &ToneDataCmd->AtToneSTCF); - CFE_TIME_TaskData.PendingLeaps = ToneDataCmd->AtToneLeapSeconds; - CFE_TIME_TaskData.PendingState = ToneDataCmd->AtToneState; + CFE_TIME_Copy(&CFE_TIME_Global.PendingMET, &ToneDataCmd->AtToneMET); + CFE_TIME_Copy(&CFE_TIME_Global.PendingSTCF, &ToneDataCmd->AtToneSTCF); + CFE_TIME_Global.PendingLeaps = ToneDataCmd->AtToneLeapSeconds; + CFE_TIME_Global.PendingState = ToneDataCmd->AtToneState; #endif /* CFE_PLATFORM_TIME_CFG_BIGENDIAN */ @@ -677,8 +677,8 @@ void CFE_TIME_ToneData(const CFE_TIME_ToneDataCmd_Payload_t *ToneDataCmd) ** now start using the new data to compute time. */ #if (CFE_MISSION_TIME_AT_TONE_WAS == true) - CFE_TIME_ToneVerify(CFE_TIME_TaskData.ToneSignalLatch, - CFE_TIME_TaskData.ToneDataLatch); + CFE_TIME_ToneVerify(CFE_TIME_Global.ToneSignalLatch, + CFE_TIME_Global.ToneDataLatch); #endif /* @@ -697,7 +697,7 @@ void CFE_TIME_ToneData(const CFE_TIME_ToneDataCmd_Payload_t *ToneDataCmd) /* ** Maintain a count of tone data packets... */ - CFE_TIME_TaskData.ToneDataCounter++; + CFE_TIME_Global.ToneDataCounter++; return; @@ -749,14 +749,14 @@ void CFE_TIME_ToneSignal(void) ** now start using the new data to compute time. */ #if (CFE_MISSION_TIME_AT_TONE_WILL_BE == true) - CFE_TIME_ToneVerify(CFE_TIME_TaskData.ToneDataLatch, - CFE_TIME_TaskData.ToneSignalLatch); + CFE_TIME_ToneVerify(CFE_TIME_Global.ToneDataLatch, + CFE_TIME_Global.ToneSignalLatch); #endif /* ** Maintain a count of tone signal packets... */ - CFE_TIME_TaskData.ToneSignalCounter++; + CFE_TIME_Global.ToneSignalCounter++; return; @@ -798,14 +798,14 @@ void CFE_TIME_ToneVerify(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2) result = CFE_TIME_Compare(PrevTime1, Time1); if (result == CFE_TIME_EQUAL) { - CFE_TIME_TaskData.ToneMatchErrorCounter++; + CFE_TIME_Global.ToneMatchErrorCounter++; } else { result = CFE_TIME_Compare(PrevTime2, Time2); if (result == CFE_TIME_EQUAL) { - CFE_TIME_TaskData.ToneMatchErrorCounter++; + CFE_TIME_Global.ToneMatchErrorCounter++; } else { @@ -818,7 +818,7 @@ void CFE_TIME_ToneVerify(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2) /* ** Local clock has rolled over... */ - elapsed = CFE_TIME_Subtract(CFE_TIME_TaskData.MaxLocalClock, Time1); + elapsed = CFE_TIME_Subtract(CFE_TIME_Global.MaxLocalClock, Time1); elapsed = CFE_TIME_Add(elapsed, Time2); } else @@ -833,22 +833,22 @@ void CFE_TIME_ToneVerify(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2) ** Ensure that time between packet and tone is within limits... */ if ((elapsed.Seconds != 0) || - (elapsed.Subseconds < CFE_TIME_TaskData.MinElapsed) || - (elapsed.Subseconds > CFE_TIME_TaskData.MaxElapsed)) + (elapsed.Subseconds < CFE_TIME_Global.MinElapsed) || + (elapsed.Subseconds > CFE_TIME_Global.MaxElapsed)) { /* ** Maintain count of tone vs data packet mis-matches... */ - CFE_TIME_TaskData.ToneMatchErrorCounter++; + CFE_TIME_Global.ToneMatchErrorCounter++; } else { - CFE_TIME_TaskData.ToneMatchCounter++; + CFE_TIME_Global.ToneMatchCounter++; /* ** Skip tone packet update if commanded into "flywheel" mode... */ - if (!CFE_TIME_TaskData.Forced2Fly) + if (!CFE_TIME_Global.Forced2Fly) { /* ** Process "matching" tone and data packet... @@ -914,9 +914,9 @@ void CFE_TIME_ToneUpdate(void) ** external data and a local h/w MET - so we don't need ** to worry about updating a local MET to external time. */ - NextState->AtToneLatch = CFE_TIME_TaskData.ToneSignalLatch; + NextState->AtToneLatch = CFE_TIME_Global.ToneSignalLatch; - if (CFE_TIME_TaskData.ClockSource == CFE_TIME_SourceSelect_INTERNAL) + if (CFE_TIME_Global.ClockSource == CFE_TIME_SourceSelect_INTERNAL) { /* ** If we have been flywheeling, VirtualMET may be incorrect @@ -924,7 +924,7 @@ void CFE_TIME_ToneUpdate(void) */ if (NextState->ClockFlyState == CFE_TIME_FlywheelState_IS_FLY) { - CFE_TIME_TaskData.VirtualMET = Reference.CurrentMET.Seconds; + CFE_TIME_Global.VirtualMET = Reference.CurrentMET.Seconds; } /* @@ -933,7 +933,7 @@ void CFE_TIME_ToneUpdate(void) ** Note: It is OK to not bother with reading the h/w MET ** since we sync'ed them at the moment of the tone. */ - NextState->AtToneMET.Seconds = CFE_TIME_TaskData.VirtualMET; + NextState->AtToneMET.Seconds = CFE_TIME_Global.VirtualMET; NextState->AtToneMET.Subseconds = 0; } else @@ -942,8 +942,8 @@ void CFE_TIME_ToneUpdate(void) ** Update "time at tone" with external MET data... */ #if (CFE_PLATFORM_TIME_CFG_SRC_MET == true) - NextState->AtToneMET = CFE_TIME_TaskData.PendingMET; - CFE_TIME_TaskData.VirtualMET = CFE_TIME_TaskData.PendingMET.Seconds; + NextState->AtToneMET = CFE_TIME_Global.PendingMET; + CFE_TIME_Global.VirtualMET = CFE_TIME_Global.PendingMET.Seconds; #endif /* @@ -960,10 +960,10 @@ void CFE_TIME_ToneUpdate(void) ** set time commands... */ #if (CFE_PLATFORM_TIME_CFG_SRC_GPS == true) - NextState->AtToneMET.Seconds = CFE_TIME_TaskData.VirtualMET; + NextState->AtToneMET.Seconds = CFE_TIME_Global.VirtualMET; NextState->AtToneMET.Subseconds = 0; - NextState->AtToneSTCF = CFE_TIME_TaskData.PendingSTCF; - NextState->AtToneLeapSeconds = CFE_TIME_TaskData.PendingLeaps; + NextState->AtToneSTCF = CFE_TIME_Global.PendingSTCF; + NextState->AtToneLeapSeconds = CFE_TIME_Global.PendingLeaps; #endif /* @@ -972,9 +972,9 @@ void CFE_TIME_ToneUpdate(void) ** STCF = external time at the tone - local MET at the tone */ #if (CFE_PLATFORM_TIME_CFG_SRC_TIME == true) - NextState->AtToneMET.Seconds = CFE_TIME_TaskData.VirtualMET; + NextState->AtToneMET.Seconds = CFE_TIME_Global.VirtualMET; NextState->AtToneMET.Subseconds = 0; - NextState->AtToneSTCF = CFE_TIME_TaskData.PendingSTCF; + NextState->AtToneSTCF = CFE_TIME_Global.PendingSTCF; #endif } @@ -985,7 +985,7 @@ void CFE_TIME_ToneUpdate(void) if (NextState->ClockFlyState == CFE_TIME_FlywheelState_IS_FLY) { NextState->ClockFlyState = CFE_TIME_FlywheelState_NO_FLY; - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; NewFlywheelStatus = true; } #endif /* CFE_PLATFORM_TIME_CFG_SERVER */ @@ -994,22 +994,22 @@ void CFE_TIME_ToneUpdate(void) /* ** Set local clock latch time that matches the tone... */ - NextState->AtToneLatch = CFE_TIME_TaskData.ToneSignalLatch; + NextState->AtToneLatch = CFE_TIME_Global.ToneSignalLatch; /* ** Time clients need all the "time at the tone" command data... */ - NextState->AtToneMET = CFE_TIME_TaskData.PendingMET; - NextState->AtToneSTCF = CFE_TIME_TaskData.PendingSTCF; - NextState->AtToneLeapSeconds = CFE_TIME_TaskData.PendingLeaps; + NextState->AtToneMET = CFE_TIME_Global.PendingMET; + NextState->AtToneSTCF = CFE_TIME_Global.PendingSTCF; + NextState->AtToneLeapSeconds = CFE_TIME_Global.PendingLeaps; /* ** Convert the server clock state into its component parts... */ - if (CFE_TIME_TaskData.PendingState == CFE_TIME_ClockState_INVALID) + if (CFE_TIME_Global.PendingState == CFE_TIME_ClockState_INVALID) { NextState->ClockSetState = CFE_TIME_SetState_NOT_SET; - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; } else { @@ -1019,13 +1019,13 @@ void CFE_TIME_ToneUpdate(void) ** If the server is fly-wheel then the client must also ** report fly-wheel (even if it is not)... */ - if (CFE_TIME_TaskData.PendingState == CFE_TIME_ClockState_FLYWHEEL) + if (CFE_TIME_Global.PendingState == CFE_TIME_ClockState_FLYWHEEL) { - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; } else { - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; } } @@ -1101,15 +1101,15 @@ void CFE_TIME_Tone1HzISR(void) ** Compute elapsed time since the previous tone signal... */ Result = CFE_TIME_Compare(ToneSignalLatch, - CFE_TIME_TaskData.ToneSignalLatch); + CFE_TIME_Global.ToneSignalLatch); if (Result == CFE_TIME_A_LT_B) { /* ** Local clock has rolled over... */ - Elapsed = CFE_TIME_Subtract(CFE_TIME_TaskData.MaxLocalClock, - CFE_TIME_TaskData.ToneSignalLatch); + Elapsed = CFE_TIME_Subtract(CFE_TIME_Global.MaxLocalClock, + CFE_TIME_Global.ToneSignalLatch); Elapsed = CFE_TIME_Add(Elapsed, ToneSignalLatch); } else @@ -1117,45 +1117,45 @@ void CFE_TIME_Tone1HzISR(void) /* ** Normal case... */ - Elapsed = CFE_TIME_Subtract(ToneSignalLatch, CFE_TIME_TaskData.ToneSignalLatch); + Elapsed = CFE_TIME_Subtract(ToneSignalLatch, CFE_TIME_Global.ToneSignalLatch); } /* ** Verify that tone occurred ~1 second after previous tone... */ - if (((Elapsed.Seconds == 1) && (Elapsed.Subseconds < CFE_TIME_TaskData.ToneOverLimit)) || - ((Elapsed.Seconds == 0) && (Elapsed.Subseconds > CFE_TIME_TaskData.ToneUnderLimit))) + if (((Elapsed.Seconds == 1) && (Elapsed.Subseconds < CFE_TIME_Global.ToneOverLimit)) || + ((Elapsed.Seconds == 0) && (Elapsed.Subseconds > CFE_TIME_Global.ToneUnderLimit))) { /* ** Maintain count of valid tone signal interrupts... ** (set to zero by reset command) */ - CFE_TIME_TaskData.ToneIntCounter++; + CFE_TIME_Global.ToneIntCounter++; /* Since the tone occured ~1 seonds after the previous one, we ** can mark this tone as 'good' */ - CFE_TIME_TaskData.IsToneGood = true; + CFE_TIME_Global.IsToneGood = true; /* ** Maintain virtual MET as count of valid tone signal interrupts... ** (not set to zero by reset command) */ #if (CFE_PLATFORM_TIME_CFG_VIRTUAL == true) - CFE_TIME_TaskData.VirtualMET++; + CFE_TIME_Global.VirtualMET++; #endif /* ** Maintain virtual MET as count read from h/w MET register... */ #if (CFE_PLATFORM_TIME_CFG_VIRTUAL != true) - OS_GetLocalMET(&CFE_TIME_TaskData.VirtualMET); + OS_GetLocalMET(&CFE_TIME_Global.VirtualMET); #endif /* ** Enable tone task (we can't send a SB message from here)... */ - OS_BinSemGive(CFE_TIME_TaskData.ToneSemaphore); + OS_BinSemGive(CFE_TIME_Global.ToneSemaphore); } else { @@ -1163,18 +1163,18 @@ void CFE_TIME_Tone1HzISR(void) ** Maintain count of invalid tone signal interrupts... ** (set to zero by reset command) */ - CFE_TIME_TaskData.ToneIntErrorCounter++; + CFE_TIME_Global.ToneIntErrorCounter++; /* Since the tone didn't occur ~1 seonds after the previous one, we ** can mark this tone as 'not good' */ - CFE_TIME_TaskData.IsToneGood = false; + CFE_TIME_Global.IsToneGood = false; } /* ** Save local time latch of most recent tone signal... */ - CFE_TIME_TaskData.ToneSignalLatch = ToneSignalLatch; + CFE_TIME_Global.ToneSignalLatch = ToneSignalLatch; /* Notify registered time synchronization applications */ CFE_TIME_NotifyTimeSynchApps(); @@ -1207,7 +1207,7 @@ void CFE_TIME_Tone1HzTask(void) /* ** Pend on semaphore given by tone ISR (above)... */ - Result = OS_BinSemTake(CFE_TIME_TaskData.ToneSemaphore); + Result = OS_BinSemTake(CFE_TIME_Global.ToneSemaphore); /* Start Performance Monitoring */ CFE_ES_PerfLogEntry(CFE_MISSION_TIME_TONE1HZTASK_PERF_ID); @@ -1217,7 +1217,7 @@ void CFE_TIME_Tone1HzTask(void) /* ** Send tone signal command packet... */ - CFE_SB_TransmitMsg(&CFE_TIME_TaskData.ToneSignalCmd.CmdHeader.Msg, false); + CFE_SB_TransmitMsg(&CFE_TIME_Global.ToneSignalCmd.CmdHeader.Msg, false); #if (CFE_MISSION_TIME_CFG_FAKE_TONE == true) /* @@ -1225,13 +1225,13 @@ void CFE_TIME_Tone1HzTask(void) ** to send the tone to other time clients. ** (this is done by scheduler in non-fake mode) */ - CFE_SB_TransmitMsg(&CFE_TIME_TaskData.ToneSendCmd.CmdHeader.Msg, false); + CFE_SB_TransmitMsg(&CFE_TIME_Global.ToneSendCmd.CmdHeader.Msg, false); #endif /* ** Maintain count of tone task wake-ups... */ - CFE_TIME_TaskData.ToneTaskCounter++; + CFE_TIME_Global.ToneTaskCounter++; } /* Exit performance monitoring */ @@ -1273,21 +1273,21 @@ void CFE_TIME_Local1HzStateMachine(void) ** Apply 1Hz adjustment to STCF... */ #if (CFE_PLATFORM_TIME_CFG_SERVER == true) - if ((CFE_TIME_TaskData.OneHzAdjust.Seconds != 0) || - (CFE_TIME_TaskData.OneHzAdjust.Subseconds != 0)) + if ((CFE_TIME_Global.OneHzAdjust.Seconds != 0) || + (CFE_TIME_Global.OneHzAdjust.Subseconds != 0)) { CFE_TIME_SysTime_t NewSTCF; NextState = CFE_TIME_StartReferenceUpdate(); - if (CFE_TIME_TaskData.OneHzDirection == CFE_TIME_AdjustDirection_ADD) + if (CFE_TIME_Global.OneHzDirection == CFE_TIME_AdjustDirection_ADD) { NewSTCF = CFE_TIME_Add(NextState->AtToneSTCF, - CFE_TIME_TaskData.OneHzAdjust); + CFE_TIME_Global.OneHzAdjust); } else { NewSTCF = CFE_TIME_Subtract(NextState->AtToneSTCF, - CFE_TIME_TaskData.OneHzAdjust); + CFE_TIME_Global.OneHzAdjust); } NextState->AtToneSTCF = NewSTCF; @@ -1319,10 +1319,10 @@ void CFE_TIME_Local1HzStateMachine(void) */ NextState->ClockFlyState = CFE_TIME_FlywheelState_IS_FLY; #if (CFE_PLATFORM_TIME_CFG_SERVER == true) - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; #endif - CFE_TIME_TaskData.AutoStartFly = true; + CFE_TIME_Global.AutoStartFly = true; /* ** Force anyone currently reading time to retry... @@ -1375,12 +1375,12 @@ void CFE_TIME_Local1HzStateMachine(void) void CFE_TIME_Local1HzISR(void) { - CFE_TIME_TaskData.LocalIntCounter++; + CFE_TIME_Global.LocalIntCounter++; /* ** Enable 1Hz task (we can't send a SB message from here)... */ - OS_BinSemGive(CFE_TIME_TaskData.LocalSemaphore); + OS_BinSemGive(CFE_TIME_Global.LocalSemaphore); return; @@ -1410,7 +1410,7 @@ void CFE_TIME_Local1HzTask(void) /* ** Pend on the 1HZ semaphore (given by local 1Hz ISR)... */ - Result = OS_BinSemTake(CFE_TIME_TaskData.LocalSemaphore); + Result = OS_BinSemTake(CFE_TIME_Global.LocalSemaphore); /* Start Performance Monitoring */ CFE_ES_PerfLogEntry(CFE_MISSION_TIME_LOCAL1HZTASK_PERF_ID); @@ -1420,9 +1420,9 @@ void CFE_TIME_Local1HzTask(void) /* ** Send "info" event if we just started flywheel mode... */ - if (CFE_TIME_TaskData.AutoStartFly) + if (CFE_TIME_Global.AutoStartFly) { - CFE_TIME_TaskData.AutoStartFly = false; + CFE_TIME_Global.AutoStartFly = false; CFE_EVS_SendEvent(CFE_TIME_FLY_ON_EID, CFE_EVS_EventType_INFORMATION, @@ -1434,9 +1434,9 @@ void CFE_TIME_Local1HzTask(void) ** This used to be optional in previous CFE versions, but it is now required ** as TIME subscribes to this itself to do state machine tasks. */ - CFE_SB_TransmitMsg(&CFE_TIME_TaskData.Local1HzCmd.CmdHeader.Msg, false); + CFE_SB_TransmitMsg(&CFE_TIME_Global.Local1HzCmd.CmdHeader.Msg, false); - CFE_TIME_TaskData.LocalTaskCounter++; + CFE_TIME_Global.LocalTaskCounter++; } /* Exit performance monitoring */ @@ -1467,15 +1467,15 @@ void CFE_TIME_NotifyTimeSynchApps(void) /* ** Notify applications that have requested tone synchronization */ - if (CFE_TIME_TaskData.IsToneGood) + if (CFE_TIME_Global.IsToneGood) { - for (i=0; i < (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0])); ++i) + for (i=0; i < (sizeof(CFE_TIME_Global.SynchCallback) / sizeof(CFE_TIME_Global.SynchCallback[0])); ++i) { /* IMPORTANT: * Read the global pointer only once, since a thread could be unregistering * the same pointer in parallel with this action. */ - Func = CFE_TIME_TaskData.SynchCallback[i].Ptr; + Func = CFE_TIME_Global.SynchCallback[i].Ptr; if (Func != NULL) { Func(); diff --git a/fsw/cfe-core/src/time/cfe_time_utils.c b/fsw/cfe-core/src/time/cfe_time_utils.c index 5c6ad95be..9718fbad0 100644 --- a/fsw/cfe-core/src/time/cfe_time_utils.c +++ b/fsw/cfe-core/src/time/cfe_time_utils.c @@ -48,13 +48,13 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ volatile CFE_TIME_ReferenceState_t *CFE_TIME_StartReferenceUpdate(void) { - uint32 Version = CFE_TIME_TaskData.LastVersionCounter; + uint32 Version = CFE_TIME_Global.LastVersionCounter; volatile CFE_TIME_ReferenceState_t *CurrState; volatile CFE_TIME_ReferenceState_t *NextState; - CurrState = &CFE_TIME_TaskData.ReferenceState[Version & CFE_TIME_REFERENCE_BUF_MASK]; + CurrState = &CFE_TIME_Global.ReferenceState[Version & CFE_TIME_REFERENCE_BUF_MASK]; ++Version; - NextState = &CFE_TIME_TaskData.ReferenceState[Version & CFE_TIME_REFERENCE_BUF_MASK]; + NextState = &CFE_TIME_Global.ReferenceState[Version & CFE_TIME_REFERENCE_BUF_MASK]; NextState->StateVersion = Version; @@ -127,7 +127,7 @@ void CFE_TIME_QueryResetVars(void) if (status != CFE_PSP_SUCCESS) { /* There is something wrong with the Reset Area */ - CFE_TIME_TaskData.DataStoreStatus = CFE_TIME_RESET_AREA_BAD; + CFE_TIME_Global.DataStoreStatus = CFE_TIME_RESET_AREA_BAD; } else @@ -152,23 +152,23 @@ void CFE_TIME_QueryResetVars(void) RefState->AtToneSTCF = LocalResetVars.CurrentSTCF; RefState->AtToneDelay = LocalResetVars.CurrentDelay; RefState->AtToneLeapSeconds = LocalResetVars.LeapSeconds; - CFE_TIME_TaskData.ClockSignal = LocalResetVars.ClockSignal; + CFE_TIME_Global.ClockSignal = LocalResetVars.ClockSignal; - CFE_TIME_TaskData.DataStoreStatus = CFE_TIME_RESET_AREA_EXISTING; + CFE_TIME_Global.DataStoreStatus = CFE_TIME_RESET_AREA_EXISTING; } else { /* ** We got a blank area from the reset variables */ - CFE_TIME_TaskData.DataStoreStatus = CFE_TIME_RESET_AREA_NEW; + CFE_TIME_Global.DataStoreStatus = CFE_TIME_RESET_AREA_NEW; } } /* ** Initialize TIME to default values if no valid Reset data... */ - if (CFE_TIME_TaskData.DataStoreStatus != CFE_TIME_RESET_AREA_EXISTING) + if (CFE_TIME_Global.DataStoreStatus != CFE_TIME_RESET_AREA_EXISTING) { DefSubsMET = CFE_TIME_Micro2SubSecs(CFE_MISSION_TIME_DEF_MET_SUBS); DefSubsSTCF = CFE_TIME_Micro2SubSecs(CFE_MISSION_TIME_DEF_STCF_SUBS); @@ -178,7 +178,7 @@ void CFE_TIME_QueryResetVars(void) RefState->AtToneSTCF.Seconds = CFE_MISSION_TIME_DEF_STCF_SECS; RefState->AtToneSTCF.Subseconds = DefSubsSTCF; RefState->AtToneLeapSeconds = CFE_MISSION_TIME_DEF_LEAPS; - CFE_TIME_TaskData.ClockSignal = CFE_TIME_ToneSignalSelect_PRIMARY; + CFE_TIME_Global.ClockSignal = CFE_TIME_ToneSignalSelect_PRIMARY; RefState->AtToneDelay.Seconds = 0; RefState->AtToneDelay.Subseconds = 0; } @@ -205,7 +205,7 @@ void CFE_TIME_UpdateResetVars(const CFE_TIME_Reference_t *Reference) /* ** Update the data only if our Reset Area is valid... */ - if (CFE_TIME_TaskData.DataStoreStatus != CFE_TIME_RESET_AREA_ERROR) + if (CFE_TIME_Global.DataStoreStatus != CFE_TIME_RESET_AREA_ERROR) { /* Store all of our critical variables to a ResetVars_t @@ -217,7 +217,7 @@ void CFE_TIME_UpdateResetVars(const CFE_TIME_Reference_t *Reference) LocalResetVars.CurrentDelay = Reference->AtToneDelay; LocalResetVars.LeapSeconds = Reference->AtToneLeapSeconds; - LocalResetVars.ClockSignal = CFE_TIME_TaskData.ClockSignal; + LocalResetVars.ClockSignal = CFE_TIME_Global.ClockSignal; /* ** Get the pointer to the Reset area from the BSP @@ -236,30 +236,24 @@ void CFE_TIME_UpdateResetVars(const CFE_TIME_Reference_t *Reference) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ -/* CFE_TIME_InitData() -- initialize global time task data */ +/* CFE_TIME_InitData() -- initialize global time task nonzero data */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CFE_TIME_InitData(void) { - uint32 i = 0; + uint32 i; volatile CFE_TIME_ReferenceState_t *RefState; - - /* - ** Initialize task command execution counters... - */ - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; - CFE_TIME_TaskData.LastVersionCounter = 0; - CFE_TIME_TaskData.ResetVersionCounter = 0; + + /* Clear task global */ + memset(&CFE_TIME_Global, 0, sizeof(CFE_TIME_Global)); /* ** Initialize task configuration data... */ - memset((void*)CFE_TIME_TaskData.ReferenceState, 0, sizeof(CFE_TIME_TaskData.ReferenceState)); for (i = 0; i < CFE_TIME_REFERENCE_BUF_DEPTH; ++i) { - CFE_TIME_TaskData.ReferenceState[i].StateVersion = 0xFFFFFFFF; + CFE_TIME_Global.ReferenceState[i].StateVersion = 0xFFFFFFFF; } /* @@ -281,152 +275,102 @@ void CFE_TIME_InitData(void) RefState->ClockFlyState = CFE_TIME_FlywheelState_IS_FLY; #if (CFE_PLATFORM_TIME_CFG_SOURCE == true) - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; #else - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_INTERNAL; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_INTERNAL; #endif - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; /* ** Pending data values (from "time at tone" command data packet)... */ - CFE_TIME_TaskData.PendingMET.Seconds = 0; - CFE_TIME_TaskData.PendingMET.Subseconds = 0; - CFE_TIME_TaskData.PendingSTCF.Seconds = 0; - CFE_TIME_TaskData.PendingSTCF.Subseconds = 0; - CFE_TIME_TaskData.PendingLeaps = 0; - CFE_TIME_TaskData.PendingState = CFE_TIME_ClockState_INVALID; + CFE_TIME_Global.PendingState = CFE_TIME_ClockState_INVALID; /* - ** STCF adjustment values... + ** Nonzero adjustment values... */ - CFE_TIME_TaskData.OneTimeAdjust.Seconds = 0; - CFE_TIME_TaskData.OneTimeAdjust.Subseconds = 0; - CFE_TIME_TaskData.OneHzAdjust.Seconds = 0; - CFE_TIME_TaskData.OneHzAdjust.Subseconds = 0; - - CFE_TIME_TaskData.OneTimeDirection = CFE_TIME_AdjustDirection_ADD; - CFE_TIME_TaskData.OneHzDirection = CFE_TIME_AdjustDirection_ADD; + CFE_TIME_Global.OneTimeDirection = CFE_TIME_AdjustDirection_ADD; + CFE_TIME_Global.OneHzDirection = CFE_TIME_AdjustDirection_ADD; RefState->DelayDirection = CFE_TIME_AdjustDirection_ADD; - /* - ** Local clock latch values... - */ - CFE_TIME_TaskData.ToneSignalLatch.Seconds = 0; - CFE_TIME_TaskData.ToneSignalLatch.Subseconds = 0; - CFE_TIME_TaskData.ToneDataLatch.Seconds = 0; - CFE_TIME_TaskData.ToneDataLatch.Subseconds = 0; - /* ** Miscellaneous counters... */ - CFE_TIME_TaskData.ToneMatchCounter = 0; - CFE_TIME_TaskData.ToneMatchErrorCounter = 0; - CFE_TIME_TaskData.ToneSignalCounter = 0; - CFE_TIME_TaskData.ToneDataCounter = 0; - CFE_TIME_TaskData.ToneIntCounter = 0; - CFE_TIME_TaskData.ToneIntErrorCounter = 0; - CFE_TIME_TaskData.ToneTaskCounter = 0; - CFE_TIME_TaskData.VirtualMET = RefState->AtToneMET.Seconds; - CFE_TIME_TaskData.LocalIntCounter = 0; - CFE_TIME_TaskData.LocalTaskCounter = 0; - CFE_TIME_TaskData.InternalCount = 0; - CFE_TIME_TaskData.ExternalCount = 0; + CFE_TIME_Global.VirtualMET = RefState->AtToneMET.Seconds; /* ** Time window verification values... */ - CFE_TIME_TaskData.MinElapsed = CFE_TIME_Micro2SubSecs(CFE_MISSION_TIME_MIN_ELAPSED); - CFE_TIME_TaskData.MaxElapsed = CFE_TIME_Micro2SubSecs(CFE_MISSION_TIME_MAX_ELAPSED); + CFE_TIME_Global.MinElapsed = CFE_TIME_Micro2SubSecs(CFE_MISSION_TIME_MIN_ELAPSED); + CFE_TIME_Global.MaxElapsed = CFE_TIME_Micro2SubSecs(CFE_MISSION_TIME_MAX_ELAPSED); /* ** Range checking for external time source data... */ #if (CFE_PLATFORM_TIME_CFG_SOURCE == true) - CFE_TIME_TaskData.MaxDelta.Seconds = CFE_PLATFORM_TIME_MAX_DELTA_SECS; - CFE_TIME_TaskData.MaxDelta.Subseconds = CFE_TIME_Micro2SubSecs(CFE_PLATFORM_TIME_MAX_DELTA_SUBS); - #else - CFE_TIME_TaskData.MaxDelta.Seconds = 0; - CFE_TIME_TaskData.MaxDelta.Subseconds = 0; + CFE_TIME_Global.MaxDelta.Seconds = CFE_PLATFORM_TIME_MAX_DELTA_SECS; + CFE_TIME_Global.MaxDelta.Subseconds = CFE_TIME_Micro2SubSecs(CFE_PLATFORM_TIME_MAX_DELTA_SUBS); #endif /* ** Maximum local clock value (before roll-over)... */ - CFE_TIME_TaskData.MaxLocalClock.Seconds = CFE_PLATFORM_TIME_MAX_LOCAL_SECS; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = CFE_PLATFORM_TIME_MAX_LOCAL_SUBS; + CFE_TIME_Global.MaxLocalClock.Seconds = CFE_PLATFORM_TIME_MAX_LOCAL_SECS; + CFE_TIME_Global.MaxLocalClock.Subseconds = CFE_PLATFORM_TIME_MAX_LOCAL_SUBS; /* ** Range limits for time between tone signal interrupts... */ - CFE_TIME_TaskData.ToneOverLimit = CFE_TIME_Micro2SubSecs(CFE_PLATFORM_TIME_CFG_TONE_LIMIT); - CFE_TIME_TaskData.ToneUnderLimit = CFE_TIME_Micro2SubSecs((1000000 - CFE_PLATFORM_TIME_CFG_TONE_LIMIT)); - - /* - ** Clock state has been commanded into (CFE_TIME_ClockState_FLYWHEEL)... - */ - CFE_TIME_TaskData.Forced2Fly = false; + CFE_TIME_Global.ToneOverLimit = CFE_TIME_Micro2SubSecs(CFE_PLATFORM_TIME_CFG_TONE_LIMIT); + CFE_TIME_Global.ToneUnderLimit = CFE_TIME_Micro2SubSecs((1000000 - CFE_PLATFORM_TIME_CFG_TONE_LIMIT)); - /* - ** Clock state has just transitioned into (CFE_TIME_ClockState_FLYWHEEL)... - */ - CFE_TIME_TaskData.AutoStartFly = false; - CFE_TIME_FinishReferenceUpdate(RefState); - /* - ** Clear the Synch Callback Registry of any garbage - */ - for (i=0; i < (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0])); ++i) - { - CFE_TIME_TaskData.SynchCallback[i].Ptr = NULL; - } - /* ** Initialize housekeeping packet (clear user data area)... */ - CFE_MSG_Init(&CFE_TIME_TaskData.HkPacket.TlmHeader.Msg, + CFE_MSG_Init(&CFE_TIME_Global.HkPacket.TlmHeader.Msg, CFE_SB_ValueToMsgId(CFE_TIME_HK_TLM_MID), - sizeof(CFE_TIME_TaskData.HkPacket)); + sizeof(CFE_TIME_Global.HkPacket)); /* ** Initialize diagnostic packet (clear user data area)... */ - CFE_MSG_Init(&CFE_TIME_TaskData.DiagPacket.TlmHeader.Msg, + CFE_MSG_Init(&CFE_TIME_Global.DiagPacket.TlmHeader.Msg, CFE_SB_ValueToMsgId(CFE_TIME_DIAG_TLM_MID), - sizeof(CFE_TIME_TaskData.DiagPacket)); + sizeof(CFE_TIME_Global.DiagPacket)); /* ** Initialize "time at the tone" signal command packet... */ - CFE_MSG_Init(&CFE_TIME_TaskData.ToneSignalCmd.CmdHeader.Msg, + CFE_MSG_Init(&CFE_TIME_Global.ToneSignalCmd.CmdHeader.Msg, CFE_SB_ValueToMsgId(CFE_TIME_TONE_CMD_MID), - sizeof(CFE_TIME_TaskData.ToneSignalCmd)); + sizeof(CFE_TIME_Global.ToneSignalCmd)); /* ** Initialize "time at the tone" data command packet... */ #if (CFE_PLATFORM_TIME_CFG_SERVER == true) - CFE_MSG_Init(&CFE_TIME_TaskData.ToneDataCmd.CmdHeader.Msg, + CFE_MSG_Init(&CFE_TIME_Global.ToneDataCmd.CmdHeader.Msg, CFE_SB_ValueToMsgId(CFE_TIME_DATA_CMD_MID), - sizeof(CFE_TIME_TaskData.ToneDataCmd)); + sizeof(CFE_TIME_Global.ToneDataCmd)); #endif /* ** Initialize simulated tone send message ("fake tone" mode only)... */ #if (CFE_MISSION_TIME_CFG_FAKE_TONE == true) - CFE_MSG_Init(&CFE_TIME_TaskData.ToneSendCmd.CmdHeader.Msg, + CFE_MSG_Init(&CFE_TIME_Global.ToneSendCmd.CmdHeader.Msg, CFE_SB_ValueToMsgId(CFE_TIME_SEND_CMD_MID), - sizeof(CFE_TIME_TaskData.ToneSendCmd)); + sizeof(CFE_TIME_Global.ToneSendCmd)); #endif /* ** Initialize local 1Hz "wake-up" command packet (optional)... */ - CFE_MSG_Init(&CFE_TIME_TaskData.Local1HzCmd.CmdHeader.Msg, + CFE_MSG_Init(&CFE_TIME_Global.Local1HzCmd.CmdHeader.Msg, CFE_SB_ValueToMsgId(CFE_TIME_1HZ_CMD_MID), - sizeof(CFE_TIME_TaskData.Local1HzCmd)); + sizeof(CFE_TIME_Global.Local1HzCmd)); return; @@ -445,47 +389,47 @@ void CFE_TIME_GetHkData(const CFE_TIME_Reference_t *Reference) /* ** Get command execution counters... */ - CFE_TIME_TaskData.HkPacket.Payload.CommandCounter = CFE_TIME_TaskData.CommandCounter; - CFE_TIME_TaskData.HkPacket.Payload.CommandErrorCounter = CFE_TIME_TaskData.CommandErrorCounter; + CFE_TIME_Global.HkPacket.Payload.CommandCounter = CFE_TIME_Global.CommandCounter; + CFE_TIME_Global.HkPacket.Payload.CommandErrorCounter = CFE_TIME_Global.CommandErrorCounter; /* ** Current "as calculated" clock state... */ - CFE_TIME_TaskData.HkPacket.Payload.ClockStateAPI = (int16) CFE_TIME_CalculateState(Reference); + CFE_TIME_Global.HkPacket.Payload.ClockStateAPI = (int16) CFE_TIME_CalculateState(Reference); /* ** Current clock state flags... */ - CFE_TIME_TaskData.HkPacket.Payload.ClockStateFlags = CFE_TIME_GetClockInfo(); + CFE_TIME_Global.HkPacket.Payload.ClockStateFlags = CFE_TIME_GetClockInfo(); /* ** Leap Seconds... */ - CFE_TIME_TaskData.HkPacket.Payload.LeapSeconds = Reference->AtToneLeapSeconds; + CFE_TIME_Global.HkPacket.Payload.LeapSeconds = Reference->AtToneLeapSeconds; /* ** Current MET and STCF time values... */ - CFE_TIME_TaskData.HkPacket.Payload.SecondsMET = Reference->CurrentMET.Seconds; - CFE_TIME_TaskData.HkPacket.Payload.SubsecsMET = Reference->CurrentMET.Subseconds; + CFE_TIME_Global.HkPacket.Payload.SecondsMET = Reference->CurrentMET.Seconds; + CFE_TIME_Global.HkPacket.Payload.SubsecsMET = Reference->CurrentMET.Subseconds; - CFE_TIME_TaskData.HkPacket.Payload.SecondsSTCF = Reference->AtToneSTCF.Seconds; - CFE_TIME_TaskData.HkPacket.Payload.SubsecsSTCF = Reference->AtToneSTCF.Subseconds; + CFE_TIME_Global.HkPacket.Payload.SecondsSTCF = Reference->AtToneSTCF.Seconds; + CFE_TIME_Global.HkPacket.Payload.SubsecsSTCF = Reference->AtToneSTCF.Subseconds; /* ** 1Hz STCF adjustment values (server only)... */ #if (CFE_PLATFORM_TIME_CFG_SERVER == true) - CFE_TIME_TaskData.HkPacket.Payload.Seconds1HzAdj = CFE_TIME_TaskData.OneHzAdjust.Seconds; - CFE_TIME_TaskData.HkPacket.Payload.Subsecs1HzAdj = CFE_TIME_TaskData.OneHzAdjust.Subseconds; + CFE_TIME_Global.HkPacket.Payload.Seconds1HzAdj = CFE_TIME_Global.OneHzAdjust.Seconds; + CFE_TIME_Global.HkPacket.Payload.Subsecs1HzAdj = CFE_TIME_Global.OneHzAdjust.Subseconds; #endif /* ** Time at tone delay values (client only)... */ #if (CFE_PLATFORM_TIME_CFG_CLIENT == true) - CFE_TIME_TaskData.HkPacket.Payload.SecondsDelay = Reference->AtToneDelay.Seconds; - CFE_TIME_TaskData.HkPacket.Payload.SubsecsDelay = Reference->AtToneDelay.Subseconds; + CFE_TIME_Global.HkPacket.Payload.SecondsDelay = Reference->AtToneDelay.Seconds; + CFE_TIME_Global.HkPacket.Payload.SubsecsDelay = Reference->AtToneDelay.Subseconds; #endif @@ -511,78 +455,78 @@ void CFE_TIME_GetDiagData(void) */ CFE_TIME_GetReference(&Reference); - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.AtToneMET, &Reference.AtToneMET); - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.AtToneSTCF, &Reference.AtToneSTCF); - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.AtToneDelay, &Reference.AtToneDelay); - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.AtToneLatch, &Reference.AtToneLatch); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.AtToneMET, &Reference.AtToneMET); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.AtToneSTCF, &Reference.AtToneSTCF); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.AtToneDelay, &Reference.AtToneDelay); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.AtToneLatch, &Reference.AtToneLatch); - CFE_TIME_TaskData.DiagPacket.Payload.AtToneLeapSeconds = Reference.AtToneLeapSeconds; - CFE_TIME_TaskData.DiagPacket.Payload.ClockStateAPI = CFE_TIME_CalculateState(&Reference); + CFE_TIME_Global.DiagPacket.Payload.AtToneLeapSeconds = Reference.AtToneLeapSeconds; + CFE_TIME_Global.DiagPacket.Payload.ClockStateAPI = CFE_TIME_CalculateState(&Reference); /* ** Data values that reflect the time (right now)... */ - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.TimeSinceTone, &Reference.TimeSinceTone); - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.CurrentLatch, &Reference.CurrentLatch); - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.CurrentMET, &Reference.CurrentMET); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.TimeSinceTone, &Reference.TimeSinceTone); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.CurrentLatch, &Reference.CurrentLatch); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.CurrentMET, &Reference.CurrentMET); TempTime = CFE_TIME_CalculateTAI(&Reference); - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.CurrentTAI, &TempTime); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.CurrentTAI, &TempTime); TempTime = CFE_TIME_CalculateUTC(&Reference); - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.CurrentUTC, &TempTime); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.CurrentUTC, &TempTime); /* ** Data values used to define the current clock state... */ - CFE_TIME_TaskData.DiagPacket.Payload.ClockSetState = Reference.ClockSetState; - CFE_TIME_TaskData.DiagPacket.Payload.ClockFlyState = Reference.ClockFlyState; - CFE_TIME_TaskData.DiagPacket.Payload.ClockSource = CFE_TIME_TaskData.ClockSource; - CFE_TIME_TaskData.DiagPacket.Payload.ClockSignal = CFE_TIME_TaskData.ClockSignal; - CFE_TIME_TaskData.DiagPacket.Payload.ServerFlyState = CFE_TIME_TaskData.ServerFlyState; - CFE_TIME_TaskData.DiagPacket.Payload.Forced2Fly = (int16) CFE_TIME_TaskData.Forced2Fly; + CFE_TIME_Global.DiagPacket.Payload.ClockSetState = Reference.ClockSetState; + CFE_TIME_Global.DiagPacket.Payload.ClockFlyState = Reference.ClockFlyState; + CFE_TIME_Global.DiagPacket.Payload.ClockSource = CFE_TIME_Global.ClockSource; + CFE_TIME_Global.DiagPacket.Payload.ClockSignal = CFE_TIME_Global.ClockSignal; + CFE_TIME_Global.DiagPacket.Payload.ServerFlyState = CFE_TIME_Global.ServerFlyState; + CFE_TIME_Global.DiagPacket.Payload.Forced2Fly = (int16) CFE_TIME_Global.Forced2Fly; /* ** Clock state flags... */ - CFE_TIME_TaskData.DiagPacket.Payload.ClockStateFlags = CFE_TIME_GetClockInfo(); + CFE_TIME_Global.DiagPacket.Payload.ClockStateFlags = CFE_TIME_GetClockInfo(); /* ** STCF adjustment direction values... */ - CFE_TIME_TaskData.DiagPacket.Payload.OneTimeDirection = CFE_TIME_TaskData.OneTimeDirection; - CFE_TIME_TaskData.DiagPacket.Payload.OneHzDirection = CFE_TIME_TaskData.OneHzDirection; - CFE_TIME_TaskData.DiagPacket.Payload.DelayDirection = Reference.DelayDirection; + CFE_TIME_Global.DiagPacket.Payload.OneTimeDirection = CFE_TIME_Global.OneTimeDirection; + CFE_TIME_Global.DiagPacket.Payload.OneHzDirection = CFE_TIME_Global.OneHzDirection; + CFE_TIME_Global.DiagPacket.Payload.DelayDirection = Reference.DelayDirection; /* ** STCF adjustment values... */ - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.OneTimeAdjust, &CFE_TIME_TaskData.OneTimeAdjust); - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.OneHzAdjust, &CFE_TIME_TaskData.OneHzAdjust); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.OneTimeAdjust, &CFE_TIME_Global.OneTimeAdjust); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.OneHzAdjust, &CFE_TIME_Global.OneHzAdjust); /* ** Most recent local clock latch values... */ - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.ToneSignalLatch, &CFE_TIME_TaskData.ToneSignalLatch); - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.ToneDataLatch, &CFE_TIME_TaskData.ToneDataLatch); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.ToneSignalLatch, &CFE_TIME_Global.ToneSignalLatch); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.ToneDataLatch, &CFE_TIME_Global.ToneDataLatch); /* ** Miscellaneous counters (subject to reset command)... */ - CFE_TIME_TaskData.DiagPacket.Payload.ToneMatchCounter = CFE_TIME_TaskData.ToneMatchCounter; - CFE_TIME_TaskData.DiagPacket.Payload.ToneMatchErrorCounter = CFE_TIME_TaskData.ToneMatchErrorCounter; - CFE_TIME_TaskData.DiagPacket.Payload.ToneSignalCounter = CFE_TIME_TaskData.ToneSignalCounter; - CFE_TIME_TaskData.DiagPacket.Payload.ToneDataCounter = CFE_TIME_TaskData.ToneDataCounter; - CFE_TIME_TaskData.DiagPacket.Payload.ToneIntCounter = CFE_TIME_TaskData.ToneIntCounter; - CFE_TIME_TaskData.DiagPacket.Payload.ToneIntErrorCounter = CFE_TIME_TaskData.ToneIntErrorCounter; - CFE_TIME_TaskData.DiagPacket.Payload.ToneTaskCounter = CFE_TIME_TaskData.ToneTaskCounter; - CFE_TIME_TaskData.DiagPacket.Payload.VersionCounter = - CFE_TIME_TaskData.LastVersionCounter - CFE_TIME_TaskData.ResetVersionCounter; - CFE_TIME_TaskData.DiagPacket.Payload.LocalIntCounter = CFE_TIME_TaskData.LocalIntCounter; - CFE_TIME_TaskData.DiagPacket.Payload.LocalTaskCounter = CFE_TIME_TaskData.LocalTaskCounter; + CFE_TIME_Global.DiagPacket.Payload.ToneMatchCounter = CFE_TIME_Global.ToneMatchCounter; + CFE_TIME_Global.DiagPacket.Payload.ToneMatchErrorCounter = CFE_TIME_Global.ToneMatchErrorCounter; + CFE_TIME_Global.DiagPacket.Payload.ToneSignalCounter = CFE_TIME_Global.ToneSignalCounter; + CFE_TIME_Global.DiagPacket.Payload.ToneDataCounter = CFE_TIME_Global.ToneDataCounter; + CFE_TIME_Global.DiagPacket.Payload.ToneIntCounter = CFE_TIME_Global.ToneIntCounter; + CFE_TIME_Global.DiagPacket.Payload.ToneIntErrorCounter = CFE_TIME_Global.ToneIntErrorCounter; + CFE_TIME_Global.DiagPacket.Payload.ToneTaskCounter = CFE_TIME_Global.ToneTaskCounter; + CFE_TIME_Global.DiagPacket.Payload.VersionCounter = + CFE_TIME_Global.LastVersionCounter - CFE_TIME_Global.ResetVersionCounter; + CFE_TIME_Global.DiagPacket.Payload.LocalIntCounter = CFE_TIME_Global.LocalIntCounter; + CFE_TIME_Global.DiagPacket.Payload.LocalTaskCounter = CFE_TIME_Global.LocalTaskCounter; /* ** Miscellaneous counters (not subject to reset command)... */ - CFE_TIME_TaskData.DiagPacket.Payload.VirtualMET = CFE_TIME_TaskData.VirtualMET; + CFE_TIME_Global.DiagPacket.Payload.VirtualMET = CFE_TIME_Global.VirtualMET; /* ** Time window verification values (converted from micro-secs)... @@ -593,24 +537,24 @@ void CFE_TIME_GetDiagData(void) ** be as little as zero, and the maximum must be something less ** than a second. */ - CFE_TIME_TaskData.DiagPacket.Payload.MinElapsed = CFE_TIME_TaskData.MinElapsed; - CFE_TIME_TaskData.DiagPacket.Payload.MaxElapsed = CFE_TIME_TaskData.MaxElapsed; + CFE_TIME_Global.DiagPacket.Payload.MinElapsed = CFE_TIME_Global.MinElapsed; + CFE_TIME_Global.DiagPacket.Payload.MaxElapsed = CFE_TIME_Global.MaxElapsed; /* ** Maximum local clock value (before roll-over)... */ - CFE_TIME_Copy(&CFE_TIME_TaskData.DiagPacket.Payload.MaxLocalClock, &CFE_TIME_TaskData.MaxLocalClock); + CFE_TIME_Copy(&CFE_TIME_Global.DiagPacket.Payload.MaxLocalClock, &CFE_TIME_Global.MaxLocalClock); /* ** Tone signal tolerance limits... */ - CFE_TIME_TaskData.DiagPacket.Payload.ToneOverLimit = CFE_TIME_TaskData.ToneOverLimit; - CFE_TIME_TaskData.DiagPacket.Payload.ToneUnderLimit = CFE_TIME_TaskData.ToneUnderLimit; + CFE_TIME_Global.DiagPacket.Payload.ToneOverLimit = CFE_TIME_Global.ToneOverLimit; + CFE_TIME_Global.DiagPacket.Payload.ToneUnderLimit = CFE_TIME_Global.ToneUnderLimit; /* ** Reset Area access status... */ - CFE_TIME_TaskData.DiagPacket.Payload.DataStoreStatus = CFE_TIME_TaskData.DataStoreStatus; + CFE_TIME_Global.DiagPacket.Payload.DataStoreStatus = CFE_TIME_Global.DataStoreStatus; return; @@ -636,8 +580,8 @@ void CFE_TIME_GetReference(CFE_TIME_Reference_t *Reference) */ while (true) { - VersionCounter = CFE_TIME_TaskData.LastVersionCounter; - RefState = &CFE_TIME_TaskData.ReferenceState[VersionCounter & CFE_TIME_REFERENCE_BUF_MASK]; + VersionCounter = CFE_TIME_Global.LastVersionCounter; + RefState = &CFE_TIME_Global.ReferenceState[VersionCounter & CFE_TIME_REFERENCE_BUF_MASK]; Reference->CurrentLatch = CFE_TIME_LatchClock(); @@ -687,7 +631,7 @@ void CFE_TIME_GetReference(CFE_TIME_Reference_t *Reference) /* ** Local clock has rolled over since last tone... */ - TimeSinceTone = CFE_TIME_Subtract(CFE_TIME_TaskData.MaxLocalClock, Reference->AtToneLatch); + TimeSinceTone = CFE_TIME_Subtract(CFE_TIME_Global.MaxLocalClock, Reference->AtToneLatch); TimeSinceTone = CFE_TIME_Add(TimeSinceTone, Reference->CurrentLatch); } else @@ -789,7 +733,7 @@ int16 CFE_TIME_CalculateState(const CFE_TIME_Reference_t *Reference) ** report fly-wheel (even if it is not)... */ #if (CFE_PLATFORM_TIME_CFG_CLIENT == true) - if (CFE_TIME_TaskData.ServerFlyState == CFE_TIME_FlywheelState_IS_FLY) + if (CFE_TIME_Global.ServerFlyState == CFE_TIME_FlywheelState_IS_FLY) { ClockState = CFE_TIME_ClockState_FLYWHEEL; } @@ -836,20 +780,20 @@ void CFE_TIME_SetState(int16 NewState) */ if (NewState == CFE_TIME_ClockState_FLYWHEEL) { - CFE_TIME_TaskData.Forced2Fly = true; + CFE_TIME_Global.Forced2Fly = true; RefState->ClockFlyState = CFE_TIME_FlywheelState_IS_FLY; #if (CFE_PLATFORM_TIME_CFG_SERVER == true) - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; #endif } else if (NewState == CFE_TIME_ClockState_VALID) { - CFE_TIME_TaskData.Forced2Fly = false; + CFE_TIME_Global.Forced2Fly = false; RefState->ClockSetState = CFE_TIME_SetState_WAS_SET; } else { - CFE_TIME_TaskData.Forced2Fly = false; + CFE_TIME_Global.Forced2Fly = false; RefState->ClockSetState = CFE_TIME_SetState_NOT_SET; } @@ -872,7 +816,7 @@ void CFE_TIME_SetState(int16 NewState) #if (CFE_PLATFORM_TIME_CFG_SOURCE == true) void CFE_TIME_SetSource(int16 NewSource) { - CFE_TIME_TaskData.ClockSource = NewSource; + CFE_TIME_Global.ClockSource = NewSource; } /* End of CFE_TIME_SetSource() */ #endif /* CFE_PLATFORM_TIME_CFG_SOURCE */ @@ -890,7 +834,7 @@ void CFE_TIME_SetSignal(int16 NewSignal) /* ** Maintain current tone signal selection for telemetry... */ - CFE_TIME_TaskData.ClockSignal = NewSignal; + CFE_TIME_Global.ClockSignal = NewSignal; } /* End of CFE_TIME_SetSignal() */ #endif /* CFE_PLATFORM_TIME_CFG_SIGNAL */ @@ -996,7 +940,7 @@ void CFE_TIME_SetMET(CFE_TIME_SysTime_t NewMET) ** Update reference values used to compute current time... */ RefState->AtToneMET = NewMET; - CFE_TIME_TaskData.VirtualMET = NewMET.Seconds; + CFE_TIME_Global.VirtualMET = NewMET.Seconds; RefState->AtToneLatch = CFE_TIME_LatchClock(); /* @@ -1083,8 +1027,8 @@ void CFE_TIME_SetAdjust(CFE_TIME_SysTime_t NewAdjust, int16 Direction) RefState = CFE_TIME_StartReferenceUpdate(); - CFE_TIME_TaskData.OneTimeAdjust = NewAdjust; - CFE_TIME_TaskData.OneTimeDirection = Direction; + CFE_TIME_Global.OneTimeAdjust = NewAdjust; + CFE_TIME_Global.OneTimeDirection = Direction; if (Direction == CFE_TIME_AdjustDirection_ADD) { @@ -1120,8 +1064,8 @@ void CFE_TIME_Set1HzAdj(CFE_TIME_SysTime_t NewAdjust, int16 Direction) /* ** Store values for 1Hz adjustment... */ - CFE_TIME_TaskData.OneHzAdjust = NewAdjust; - CFE_TIME_TaskData.OneHzDirection = Direction; + CFE_TIME_Global.OneHzAdjust = NewAdjust; + CFE_TIME_Global.OneHzDirection = Direction; } /* End of CFE_TIME_Set1HzAdj() */ #endif /* CFE_PLATFORM_TIME_CFG_SERVER */ @@ -1133,7 +1077,7 @@ void CFE_TIME_Set1HzAdj(CFE_TIME_SysTime_t NewAdjust, int16 Direction) /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 CFE_TIME_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_TIME_CleanUpApp(CFE_ES_AppId_t AppId) { int32 Status; uint32 AppIndex; @@ -1143,9 +1087,9 @@ int32 CFE_TIME_CleanUpApp(CFE_ES_ResourceID_t AppId) { /* Do nothing */ } - else if (AppIndex < (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0]))) + else if (AppIndex < (sizeof(CFE_TIME_Global.SynchCallback) / sizeof(CFE_TIME_Global.SynchCallback[0]))) { - CFE_TIME_TaskData.SynchCallback[AppIndex].Ptr = NULL; + CFE_TIME_Global.SynchCallback[AppIndex].Ptr = NULL; } else { diff --git a/fsw/cfe-core/src/time/cfe_time_utils.h b/fsw/cfe-core/src/time/cfe_time_utils.h index 84a4c4f0d..2e52298bd 100644 --- a/fsw/cfe-core/src/time/cfe_time_utils.h +++ b/fsw/cfe-core/src/time/cfe_time_utils.h @@ -301,8 +301,8 @@ typedef struct /* ** Interrupt task ID's... */ - CFE_ES_ResourceID_t LocalTaskID; - CFE_ES_ResourceID_t ToneTaskID; + CFE_ES_TaskId_t LocalTaskID; + CFE_ES_TaskId_t ToneTaskID; /* ** Maximum difference from expected for external time sources... @@ -327,12 +327,12 @@ typedef struct */ CFE_TIME_SynchCallbackRegEntry_t SynchCallback[CFE_PLATFORM_ES_MAX_APPLICATIONS]; -} CFE_TIME_TaskData_t; +} CFE_TIME_Global_t; /* ** Time task global data (from "cfe_time_task.c")... */ -extern CFE_TIME_TaskData_t CFE_TIME_TaskData; +extern CFE_TIME_Global_t CFE_TIME_Global; /*************************************************************************/ @@ -424,7 +424,7 @@ volatile CFE_TIME_ReferenceState_t *CFE_TIME_StartReferenceUpdate(void); */ static inline void CFE_TIME_FinishReferenceUpdate(volatile CFE_TIME_ReferenceState_t *NextState) { - CFE_TIME_TaskData.LastVersionCounter = NextState->StateVersion; + CFE_TIME_Global.LastVersionCounter = NextState->StateVersion; } /* @@ -434,8 +434,8 @@ static inline void CFE_TIME_FinishReferenceUpdate(volatile CFE_TIME_ReferenceSta */ static inline volatile CFE_TIME_ReferenceState_t *CFE_TIME_GetReferenceState(void) { - return &CFE_TIME_TaskData.ReferenceState - [CFE_TIME_TaskData.LastVersionCounter & CFE_TIME_REFERENCE_BUF_MASK]; + return &CFE_TIME_Global.ReferenceState + [CFE_TIME_Global.LastVersionCounter & CFE_TIME_REFERENCE_BUF_MASK]; } /* diff --git a/fsw/cfe-core/unit-test/es_UT.c b/fsw/cfe-core/unit-test/es_UT.c index 483a8ea43..629abd399 100644 --- a/fsw/cfe-core/unit-test/es_UT.c +++ b/fsw/cfe-core/unit-test/es_UT.c @@ -224,39 +224,55 @@ static const UT_TaskPipeDispatchId_t UT_TPID_CFE_ES_SEND_HK = /* ** Functions */ -CFE_ES_ResourceID_t ES_UT_MakeAppIdForIndex(uint32 ArrayIdx) +CFE_ResourceId_t ES_UT_MakeAppIdForIndex(uint32 ArrayIdx) { /* UT hack - make up AppID values in a manner similar to FSW. * Real apps should never do this. */ - return CFE_ES_ResourceID_FromInteger(ArrayIdx + CFE_ES_APPID_BASE); + return CFE_ResourceId_FromInteger(ArrayIdx + CFE_ES_APPID_BASE); } -CFE_ES_ResourceID_t ES_UT_MakeTaskIdForIndex(uint32 ArrayIdx) +CFE_ResourceId_t ES_UT_MakeTaskIdForIndex(uint32 ArrayIdx) { /* UT hack - make up TaskID values in a manner similar to FSW. * Real apps should never do this. */ - return CFE_ES_ResourceID_FromInteger(ArrayIdx + 0x40010000); + uint32 Base; + + /* The base to use depends on whether STRICT mode is enabled or not */ +#ifndef CFE_RESOURCEID_STRICT //_MODE + Base = CFE_ES_TASKID_BASE; +#else + Base = 0x40010000; /* note this is NOT the same as the normal OSAL task ID base */ +#endif + + return CFE_ResourceId_FromInteger(ArrayIdx + Base); } -CFE_ES_ResourceID_t ES_UT_MakeLibIdForIndex(uint32 ArrayIdx) +CFE_ResourceId_t ES_UT_MakeLibIdForIndex(uint32 ArrayIdx) { /* UT hack - make up LibID values in a manner similar to FSW. * Real apps should never do this. */ - return CFE_ES_ResourceID_FromInteger(ArrayIdx + CFE_ES_LIBID_BASE); + return CFE_ResourceId_FromInteger(ArrayIdx + CFE_ES_LIBID_BASE); +} + +CFE_ResourceId_t ES_UT_MakeCounterIdForIndex(uint32 ArrayIdx) +{ + /* UT hack - make up CounterID values in a manner similar to FSW. + * Real apps should never do this. */ + return CFE_ResourceId_FromInteger(ArrayIdx + CFE_ES_COUNTID_BASE); } -CFE_ES_MemHandle_t ES_UT_MakePoolIdForIndex(uint32 ArrayIdx) +CFE_ResourceId_t ES_UT_MakePoolIdForIndex(uint32 ArrayIdx) { /* UT hack - make up PoolID values in a manner similar to FSW. * Real apps should never do this. */ - return CFE_ES_ResourceID_FromInteger(ArrayIdx + CFE_ES_POOLID_BASE); + return CFE_ResourceId_FromInteger(ArrayIdx + CFE_ES_POOLID_BASE); } -CFE_ES_ResourceID_t ES_UT_MakeCDSIdForIndex(uint32 ArrayIdx) +CFE_ResourceId_t ES_UT_MakeCDSIdForIndex(uint32 ArrayIdx) { /* UT hack - make up CDSID values in a manner similar to FSW. * Real apps should never do this. */ - return CFE_ES_ResourceID_FromInteger(ArrayIdx + CFE_ES_CDSBLOCKID_BASE); + return CFE_ResourceId_FromInteger(ArrayIdx + CFE_ES_CDSBLOCKID_BASE); } /* @@ -268,23 +284,23 @@ void ES_UT_SetupSingleAppId(CFE_ES_AppType_Enum_t AppType, CFE_ES_AppState_Enum_ const char *AppName, CFE_ES_AppRecord_t **OutAppRec, CFE_ES_TaskRecord_t **OutTaskRec) { osal_id_t UtOsalId; - CFE_ES_ResourceID_t UtTaskId; - CFE_ES_ResourceID_t UtAppId; + CFE_ResourceId_t UtTaskId; + CFE_ResourceId_t UtAppId; CFE_ES_AppRecord_t *LocalAppPtr; CFE_ES_TaskRecord_t *LocalTaskPtr; OS_TaskCreate(&UtOsalId, "UT", NULL, OSAL_TASK_STACK_ALLOCATE, 0, 0, 0); - UtTaskId = CFE_ES_ResourceID_FromOSAL(UtOsalId); + UtTaskId = CFE_RESOURCEID_UNWRAP(CFE_ES_TaskId_FromOSAL(UtOsalId)); UtAppId = CFE_ES_Global.LastAppId; - CFE_ES_Global.LastAppId = CFE_ES_ResourceID_FromInteger( - CFE_ES_ResourceID_ToInteger(UtAppId) + 1); + CFE_ES_Global.LastAppId = CFE_ResourceId_FromInteger( + CFE_ResourceId_ToInteger(UtAppId) + 1); - LocalTaskPtr = CFE_ES_LocateTaskRecordByID(UtTaskId); - LocalAppPtr = CFE_ES_LocateAppRecordByID(UtAppId); + LocalTaskPtr = CFE_ES_LocateTaskRecordByID(CFE_ES_TASKID_C(UtTaskId)); + LocalAppPtr = CFE_ES_LocateAppRecordByID(CFE_ES_APPID_C(UtAppId)); CFE_ES_TaskRecordSetUsed(LocalTaskPtr, UtTaskId); CFE_ES_AppRecordSetUsed(LocalAppPtr, UtAppId); - LocalTaskPtr->AppId = UtAppId; - LocalAppPtr->MainTaskId = UtTaskId; + LocalTaskPtr->AppId = CFE_ES_AppRecordGetID(LocalAppPtr); + LocalAppPtr->MainTaskId = CFE_ES_TaskRecordGetID(LocalTaskPtr); LocalAppPtr->AppState = AppState; LocalAppPtr->Type = AppType; @@ -329,17 +345,17 @@ void ES_UT_SetupSingleAppId(CFE_ES_AppType_Enum_t AppType, CFE_ES_AppState_Enum_ void ES_UT_SetupChildTaskId(const CFE_ES_AppRecord_t *ParentApp, const char *TaskName, CFE_ES_TaskRecord_t **OutTaskRec) { osal_id_t UtOsalId; - CFE_ES_ResourceID_t UtTaskId; - CFE_ES_ResourceID_t UtAppId; + CFE_ES_TaskId_t UtTaskId; + CFE_ES_AppId_t UtAppId; CFE_ES_TaskRecord_t *LocalTaskPtr; UtAppId = CFE_ES_AppRecordGetID(ParentApp); OS_TaskCreate(&UtOsalId, "C", NULL, OSAL_TASK_STACK_ALLOCATE, 0, 0, 0); - UtTaskId = CFE_ES_ResourceID_FromOSAL(UtOsalId); + UtTaskId = CFE_ES_TaskId_FromOSAL(UtOsalId); LocalTaskPtr = CFE_ES_LocateTaskRecordByID(UtTaskId); - CFE_ES_TaskRecordSetUsed(LocalTaskPtr, UtTaskId); + CFE_ES_TaskRecordSetUsed(LocalTaskPtr, CFE_RESOURCEID_UNWRAP(UtTaskId)); LocalTaskPtr->AppId = UtAppId; if (TaskName) @@ -363,14 +379,14 @@ void ES_UT_SetupChildTaskId(const CFE_ES_AppRecord_t *ParentApp, const char *Tas */ void ES_UT_SetupSingleLibId(const char *LibName, CFE_ES_LibRecord_t **OutLibRec) { - CFE_ES_ResourceID_t UtLibId; + CFE_ResourceId_t UtLibId; CFE_ES_LibRecord_t *LocalLibPtr; UtLibId = CFE_ES_Global.LastLibId; - CFE_ES_Global.LastLibId = CFE_ES_ResourceID_FromInteger( - CFE_ES_ResourceID_ToInteger(UtLibId) + 1); + CFE_ES_Global.LastLibId = CFE_ResourceId_FromInteger( + CFE_ResourceId_ToInteger(UtLibId) + 1); - LocalLibPtr = CFE_ES_LocateLibRecordByID(UtLibId); + LocalLibPtr = CFE_ES_LocateLibRecordByID(CFE_ES_LIBID_C(UtLibId)); CFE_ES_LibRecordSetUsed(LocalLibPtr, UtLibId); if (LibName) @@ -433,15 +449,15 @@ int32 ES_UT_CDSPoolCommit(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t Offset, void ES_UT_SetupMemPoolId(CFE_ES_MemPoolRecord_t **OutPoolRecPtr) { - CFE_ES_MemHandle_t UtPoolID; + CFE_ResourceId_t UtPoolID; CFE_ES_MemPoolRecord_t *LocalPoolRecPtr; UtPoolID = CFE_ES_Global.LastMemPoolId; - CFE_ES_Global.LastMemPoolId = CFE_ES_ResourceID_FromInteger( - CFE_ES_ResourceID_ToInteger(UtPoolID) + 1); + CFE_ES_Global.LastMemPoolId = CFE_ResourceId_FromInteger( + CFE_ResourceId_ToInteger(UtPoolID) + 1); - LocalPoolRecPtr = CFE_ES_LocateMemPoolRecordByID(UtPoolID); + LocalPoolRecPtr = CFE_ES_LocateMemPoolRecordByID(CFE_ES_MEMHANDLE_C(UtPoolID)); /* in order to validate the size must be nonzero */ LocalPoolRecPtr->Pool.PoolTotalSize = sizeof(UT_MemPoolDirectBuffer.Data); @@ -487,7 +503,7 @@ void ES_UT_SetupSingleCDSRegistry(const char *CDSName, size_t BlockSize, bool Is CFE_ES_CDS_RegRec_t **OutRegRec) { CFE_ES_CDS_RegRec_t *LocalRegRecPtr; - CFE_ES_ResourceID_t UtCDSID; + CFE_ResourceId_t UtCDSID; CFE_ES_GenPoolBD_t LocalBD; size_t UT_CDS_BufferSize; @@ -520,10 +536,10 @@ void ES_UT_SetupSingleCDSRegistry(const char *CDSName, size_t BlockSize, bool Is } UtCDSID = CFE_ES_Global.CDSVars.LastCDSBlockId; - CFE_ES_Global.CDSVars.LastCDSBlockId = CFE_ES_ResourceID_FromInteger( - CFE_ES_ResourceID_ToInteger(UtCDSID) + 1); + CFE_ES_Global.CDSVars.LastCDSBlockId = CFE_ResourceId_FromInteger( + CFE_ResourceId_ToInteger(UtCDSID) + 1); - LocalRegRecPtr = CFE_ES_LocateCDSBlockRecordByID(UtCDSID); + LocalRegRecPtr = CFE_ES_LocateCDSBlockRecordByID(CFE_ES_CDSHANDLE_C(UtCDSID)); if (CDSName != NULL) { strncpy(LocalRegRecPtr->Name, CDSName, @@ -664,11 +680,11 @@ void ES_ResetUnitTest(void) /* ** Initialize the Last Id */ - CFE_ES_Global.LastAppId = CFE_ES_ResourceID_FromInteger(CFE_ES_APPID_BASE); - CFE_ES_Global.LastLibId = CFE_ES_ResourceID_FromInteger(CFE_ES_LIBID_BASE); - CFE_ES_Global.LastCounterId = CFE_ES_ResourceID_FromInteger(CFE_ES_COUNTID_BASE); - CFE_ES_Global.LastMemPoolId = CFE_ES_ResourceID_FromInteger(CFE_ES_POOLID_BASE); - CFE_ES_Global.CDSVars.LastCDSBlockId = CFE_ES_ResourceID_FromInteger(CFE_ES_CDSBLOCKID_BASE); + CFE_ES_Global.LastAppId = CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE); + CFE_ES_Global.LastLibId = CFE_ResourceId_FromInteger(CFE_ES_LIBID_BASE); + CFE_ES_Global.LastCounterId = CFE_ResourceId_FromInteger(CFE_ES_COUNTID_BASE); + CFE_ES_Global.LastMemPoolId = CFE_ResourceId_FromInteger(CFE_ES_POOLID_BASE); + CFE_ES_Global.CDSVars.LastCDSBlockId = CFE_ResourceId_FromInteger(CFE_ES_CDSBLOCKID_BASE); } /* end ES_ResetUnitTest() */ @@ -1037,13 +1053,8 @@ void TestStartupErrorPaths(void) /* Test reading the object table where all app slots are taken */ ES_ResetUnitTest(); - AppRecPtr = CFE_ES_Global.AppTable; - for (j = 0; j < CFE_PLATFORM_ES_MAX_APPLICATIONS; j++) - { - CFE_ES_AppRecordSetUsed(AppRecPtr, ES_UT_MakeAppIdForIndex(j)); - ++AppRecPtr; - } + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); CFE_ES_CreateObjects(); UT_Report(__FILE__, __LINE__, UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_NO_FREE_CORE_APP_SLOTS]) == 5, @@ -1052,13 +1063,7 @@ void TestStartupErrorPaths(void) /* Test reading the object table with a NULL function pointer */ ES_ResetUnitTest(); - AppRecPtr = CFE_ES_Global.AppTable; - for (j = 0; j < CFE_PLATFORM_ES_MAX_APPLICATIONS; j++) - { - CFE_ES_AppRecordSetUsed(AppRecPtr, ES_UT_MakeAppIdForIndex(j)); - ++AppRecPtr; - } - + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); CFE_ES_ObjectTable[1].ObjectType = CFE_ES_FUNCTION_CALL; CFE_ES_CreateObjects(); UT_Report(__FILE__, __LINE__, @@ -1142,15 +1147,23 @@ void TestStartupErrorPaths(void) CFE_ES_AppState_LATE_INIT, "CFE_ES_WaitForSystemState", "Min System State is CFE_ES_SystemState_APPS_INIT"); + + /* Test success */ + ES_ResetUnitTest(); + /* This prep is necessary so GetAppId works */ + ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppType_CORE, NULL, &AppRecPtr, NULL); + CFE_ES_Global.SystemState = CFE_ES_SystemState_CORE_READY; + ASSERT(CFE_ES_WaitForSystemState(CFE_ES_SystemState_CORE_READY, 0)); + } void TestApps(void) { int NumBytes; int Return; - int j; CFE_ES_AppInfo_t AppInfo; - CFE_ES_ResourceID_t Id; + CFE_ES_AppId_t AppId; + CFE_ES_TaskId_t TaskId; CFE_ES_TaskRecord_t *UtTaskRecPtr; CFE_ES_AppRecord_t *UtAppRecPtr; CFE_ES_MemPoolRecord_t *UtPoolRecPtr; @@ -1258,7 +1271,7 @@ void TestApps(void) /* Test application loading and creation with a task creation failure */ ES_ResetUnitTest(); UT_SetDefaultReturnValue(UT_KEY(OS_TaskCreate), OS_ERROR); - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename", "EntryPoint", "AppName", @@ -1270,7 +1283,7 @@ void TestApps(void) /* Test application creation with NULL file name */ ES_ResetUnitTest(); - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, NULL, "EntryPoint", "AppName", @@ -1285,7 +1298,7 @@ void TestApps(void) /* Test application creation with name too long */ memset(NameBuffer, 'x', sizeof(NameBuffer)-1); NameBuffer[sizeof(NameBuffer)-1] = 0; - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", NameBuffer, @@ -1300,7 +1313,7 @@ void TestApps(void) /* Test successful application loading and creation */ ES_ResetUnitTest(); - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", "AppName", @@ -1313,7 +1326,7 @@ void TestApps(void) "Application load/create; successful"); /* Test application loading of the same name again */ - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", "AppName", @@ -1328,7 +1341,7 @@ void TestApps(void) /* Test application loading and creation where the file cannot be loaded */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_ModuleLoad), 1, -1); - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", "AppName2", @@ -1340,14 +1353,8 @@ void TestApps(void) /* Test application loading and creation where all app slots are taken */ ES_ResetUnitTest(); - UtAppRecPtr = CFE_ES_Global.AppTable; - for (j = 0; j < CFE_PLATFORM_ES_MAX_APPLICATIONS; j++) - { - CFE_ES_AppRecordSetUsed(UtAppRecPtr, ES_UT_MakeAppIdForIndex(j)); - ++UtAppRecPtr; - } - - Return = CFE_ES_AppCreate(&Id, + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", "AppName", @@ -1360,12 +1367,18 @@ void TestApps(void) "CFE_ES_AppCreate", "No free application slots available"); + /* Check operation of the CFE_ES_CheckAppIdSlotUsed() helper function */ + CFE_ES_Global.AppTable[1].AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(1)); + CFE_ES_Global.AppTable[2].AppId = CFE_ES_APPID_UNDEFINED; + UtAssert_True(CFE_ES_CheckAppIdSlotUsed(ES_UT_MakeAppIdForIndex(1)), "App Slot Used"); + UtAssert_True(!CFE_ES_CheckAppIdSlotUsed(ES_UT_MakeAppIdForIndex(2)), "App Slot Unused"); + /* Test application loading and creation where the entry point symbol * cannot be found */ ES_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_ModuleSymbolLookup), 1, -1); - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", "AppName", @@ -1382,7 +1395,7 @@ void TestApps(void) ES_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_ModuleSymbolLookup), 1, -1); UT_SetDeferredRetcode(UT_KEY(OS_ModuleUnload), 1, -1); - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", "AppName", @@ -1399,7 +1412,7 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, &UtTaskRecPtr); - UtTaskRecPtr->AppId = CFE_ES_RESOURCEID_UNDEFINED; + UtTaskRecPtr->AppId = CFE_ES_APPID_UNDEFINED; UtAssert_NULL(CFE_ES_GetAppRecordByContext()); /* Test scanning and acting on the application table where the timer @@ -1464,8 +1477,8 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppControlRequest = 0x12345; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_PCR_ERR2_EID), "CFE_ES_ProcessControlRequest", @@ -1485,8 +1498,8 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_EXIT; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_EXIT_APP_INF_EID), "CFE_ES_ProcessControlRequest", @@ -1499,8 +1512,8 @@ 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); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_EXIT_APP_ERR_EID), "CFE_ES_ProcessControlRequest", @@ -1514,8 +1527,8 @@ void TestApps(void) UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_DELETE; UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_STOP_ERR3_EID), "CFE_ES_ProcessControlRequest", @@ -1529,8 +1542,8 @@ void TestApps(void) UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RESTART; UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_RESTART_APP_ERR4_EID), "CFE_ES_ProcessControlRequest", @@ -1545,8 +1558,8 @@ void TestApps(void) CFE_ES_RunStatus_SYS_RESTART; OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UT_SetDefaultReturnValue(UT_KEY(OS_TaskCreate), OS_ERROR); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_RESTART_APP_ERR3_EID), "CFE_ES_ProcessControlRequest", @@ -1560,8 +1573,8 @@ void TestApps(void) UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RELOAD; UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_RELOAD_APP_ERR4_EID), "CFE_ES_ProcessControlRequest", @@ -1576,8 +1589,8 @@ void TestApps(void) CFE_ES_RunStatus_SYS_RELOAD; OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UT_SetDefaultReturnValue(UT_KEY(OS_TaskCreate), OS_ERROR); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_RELOAD_APP_ERR3_EID), "CFE_ES_ProcessControlRequest", @@ -1599,8 +1612,8 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_ERROR; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_ERREXIT_APP_INF_EID), "CFE_ES_ProcessControlRequest", @@ -1614,8 +1627,8 @@ void TestApps(void) UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_ERROR; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_ERREXIT_APP_ERR_EID), "CFE_ES_ProcessControlRequest", @@ -1635,8 +1648,8 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_DELETE; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_STOP_INF_EID), "CFE_ES_ProcessControlRequest", @@ -1656,8 +1669,8 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RESTART; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_RESTART_APP_INF_EID), "CFE_ES_ProcessControlRequest", @@ -1677,8 +1690,8 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RELOAD; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_RELOAD_APP_INF_EID), "CFE_ES_ProcessControlRequest", @@ -1700,8 +1713,8 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_EXCEPTION; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_PCR_ERR1_EID), "CFE_ES_ProcessControlRequest", @@ -1710,9 +1723,9 @@ void TestApps(void) /* Test populating the application information structure with data */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_GetAppInfo(&AppInfo, Id) == CFE_SUCCESS, + CFE_ES_GetAppInfo(&AppInfo, AppId) == CFE_SUCCESS, "CFE_ES_GetAppInfo", "Get application information; successful"); @@ -1721,9 +1734,9 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_GetAppInfo(NULL, Id) == CFE_ES_ERR_BUFFER, + CFE_ES_GetAppInfo(NULL, AppId) == CFE_ES_ERR_BUFFER, "CFE_ES_GetAppInfo", "Null application information pointer"); @@ -1732,10 +1745,10 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_AppRecordSetFree(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_GetAppInfo(&AppInfo, Id) == CFE_ES_ERR_RESOURCEID_NOT_VALID, + CFE_ES_GetAppInfo(&AppInfo, AppId) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetAppInfo", "Application ID not active"); @@ -1743,9 +1756,9 @@ void TestApps(void) * application ID value greater than the maximum allowed */ ES_ResetUnitTest(); - Id = ES_UT_MakeAppIdForIndex(99999); + AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(99999)); UT_Report(__FILE__, __LINE__, - CFE_ES_GetAppInfo(&AppInfo, Id) == CFE_ES_ERR_RESOURCEID_NOT_VALID, + CFE_ES_GetAppInfo(&AppInfo, AppId) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetAppInfo", "Application ID exceeds maximum"); @@ -1754,10 +1767,10 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_SetDeferredRetcode(UT_KEY(OS_ModuleInfo), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_GetAppInfo(&AppInfo, Id) == CFE_SUCCESS, + CFE_ES_GetAppInfo(&AppInfo, AppId) == CFE_SUCCESS, "CFE_ES_GetAppInfo", "Module not found"); @@ -1771,9 +1784,9 @@ void TestApps(void) OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UT_SetDefaultReturnValue(UT_KEY(OS_TaskDelete), OS_ERROR); UT_SetDefaultReturnValue(UT_KEY(OS_close), OS_ERROR); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_ES_APP_CLEANUP_ERR, + CFE_ES_CleanUpApp(AppId) == CFE_ES_APP_CLEANUP_ERR, "CFE_ES_CleanUpApp", "Task OS delete and close failure"); @@ -1785,9 +1798,9 @@ void TestApps(void) 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); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_ES_APP_CLEANUP_ERR, + CFE_ES_CleanUpApp(AppId) == CFE_ES_APP_CLEANUP_ERR, "CFE_ES_CleanUpApp", "Task mutex delete failure"); @@ -1797,9 +1810,9 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); UT_SetDeferredRetcode(UT_KEY(OS_ModuleUnload), 1, OS_ERROR); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_ES_APP_CLEANUP_ERR, + CFE_ES_CleanUpApp(AppId) == CFE_ES_APP_CLEANUP_ERR, "CFE_ES_CleanUpApp", "Module unload failure"); @@ -1809,9 +1822,9 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_ES_APP_CLEANUP_ERR, + CFE_ES_CleanUpApp(AppId) == CFE_ES_APP_CLEANUP_ERR, "CFE_ES_CleanUpApp", "EVS application cleanup failure"); @@ -1821,10 +1834,10 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); ES_UT_SetupForOSCleanup(); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_SetDeferredRetcode(UT_KEY(OS_MutSemDelete), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == + CFE_ES_CleanupTaskResources(TaskId) == CFE_ES_MUT_SEM_DELETE_ERR, "CFE_ES_CleanupTaskResources", "Mutex delete failure"); @@ -1835,10 +1848,10 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); ES_UT_SetupForOSCleanup(); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_SetDeferredRetcode(UT_KEY(OS_BinSemDelete), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == + CFE_ES_CleanupTaskResources(TaskId) == CFE_ES_BIN_SEM_DELETE_ERR, "CFE_ES_CleanupTaskResources", "Binary semaphore delete failure"); @@ -1850,9 +1863,9 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); ES_UT_SetupForOSCleanup(); UT_SetDeferredRetcode(UT_KEY(OS_CountSemDelete), 1, OS_ERROR); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == + CFE_ES_CleanupTaskResources(TaskId) == CFE_ES_COUNT_SEM_DELETE_ERR, "CFE_ES_CleanupTaskResources", "Counting semaphore failure"); @@ -1864,9 +1877,9 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); ES_UT_SetupForOSCleanup(); UT_SetDeferredRetcode(UT_KEY(OS_QueueDelete), 1, OS_ERROR); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == + CFE_ES_CleanupTaskResources(TaskId) == CFE_ES_QUEUE_DELETE_ERR, "CFE_ES_CleanupTaskResources", "Queue delete failure"); @@ -1876,14 +1889,14 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); ES_UT_SetupForOSCleanup(); /* Just set OS_TimerDelete to fail. There is no requirement * that the code call OS_TimerGetInfo first. */ UT_SetDeferredRetcode(UT_KEY(OS_TimerDelete), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == + CFE_ES_CleanupTaskResources(TaskId) == CFE_ES_TIMER_DELETE_ERR, "CFE_ES_CleanupTaskResources", "Timer delete failure"); @@ -1893,12 +1906,12 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); ES_UT_SetupForOSCleanup(); UT_SetDeferredRetcode(UT_KEY(OS_TimerGetInfo), 1, OS_ERROR); UT_SetDefaultReturnValue(UT_KEY(OS_close), OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) != CFE_SUCCESS, + CFE_ES_CleanupTaskResources(TaskId) != CFE_SUCCESS, "CFE_ES_CleanupTaskResources", "File close failure"); @@ -1907,21 +1920,21 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_SetDeferredRetcode(UT_KEY(OS_TimerGetInfo), 1, OS_ERROR); UT_SetDefaultReturnValue(UT_KEY(OS_TaskDelete), OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == CFE_ES_TASK_DELETE_ERR, + CFE_ES_CleanupTaskResources(TaskId) == CFE_ES_TASK_DELETE_ERR, "CFE_ES_CleanupTaskResources", "Task delete failure"); /* Test successfully cleaning up the OS resources for a task */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_SetDeferredRetcode(UT_KEY(OS_TimerGetInfo), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == CFE_SUCCESS, + CFE_ES_CleanupTaskResources(TaskId) == CFE_SUCCESS, "CFE_ES_CleanupTaskResources", "Clean up task OS resources; successful"); @@ -1985,9 +1998,9 @@ void TestApps(void) UtPoolRecPtr->OwnerAppID = CFE_ES_AppRecordGetID(UtAppRecPtr); /* Associate a child task with the app to be deleted */ ES_UT_SetupChildTaskId(UtAppRecPtr, NULL, NULL); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_SUCCESS, + CFE_ES_CleanUpApp(AppId) == CFE_SUCCESS, "CFE_ES_CleanUpApp", "Main task ID matches task ID, nominal"); UT_Report(__FILE__, __LINE__, @@ -2007,10 +2020,10 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); ES_UT_SetupMemPoolId(&UtPoolRecPtr); UtPoolRecPtr->OwnerAppID = CFE_ES_AppRecordGetID(UtAppRecPtr); - UtPoolRecPtr->PoolID = CFE_ES_ResourceID_FromInteger(99999); /* Mismatch */ - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + UtPoolRecPtr->PoolID = CFE_ES_MEMHANDLE_C(CFE_ResourceId_FromInteger(99999)); /* Mismatch */ + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_ES_APP_CLEANUP_ERR, + CFE_ES_CleanUpApp(AppId) == CFE_ES_APP_CLEANUP_ERR, "CFE_ES_CleanUpApp", "Mem Pool delete error"); UT_Report(__FILE__, __LINE__, @@ -2034,9 +2047,9 @@ void TestApps(void) UtAppRecPtr->MainTaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_SetDefaultReturnValue(UT_KEY(OS_TaskDelete), OS_ERROR); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_ES_APP_CLEANUP_ERR, + CFE_ES_CleanUpApp(AppId) == CFE_ES_APP_CLEANUP_ERR, "CFE_ES_CleanUpApp", "Main task ID doesn't match task ID, CFE_ES_APP_CLEANUP_ERR"); UT_Report(__FILE__, __LINE__, @@ -2057,10 +2070,10 @@ void TestApps(void) /* switch the main task association (makes it wrong) */ UtAppRecPtr->MainTaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_SUCCESS, + CFE_ES_CleanUpApp(AppId) == CFE_SUCCESS, "CFE_ES_CleanUpApp", "Application ID mismatch; core application"); @@ -2081,9 +2094,9 @@ void TestApps(void) /* Setup an entry which will be deleted */ ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, &UtTaskRecPtr); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_SUCCESS && + CFE_ES_CleanUpApp(AppId) == CFE_SUCCESS && !CFE_ES_TaskRecordIsUsed(UtTaskRecPtr) && CFE_ES_Global.RegisteredExternalApps == 0, "CFE_ES_CleanUpApp", @@ -2095,7 +2108,7 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, &UtTaskRecPtr); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_SetDeferredRetcode(UT_KEY(OS_MutSemGetInfo), 1, OS_ERROR); UT_SetDeferredRetcode(UT_KEY(OS_BinSemGetInfo), 1, OS_ERROR); UT_SetDeferredRetcode(UT_KEY(OS_CountSemGetInfo), 1, OS_ERROR); @@ -2103,64 +2116,48 @@ void TestApps(void) UT_SetDeferredRetcode(UT_KEY(OS_TimerGetInfo), 1, OS_ERROR); UT_SetDeferredRetcode(UT_KEY(OS_FDGetInfo), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == CFE_SUCCESS, + CFE_ES_CleanupTaskResources(TaskId) == CFE_SUCCESS, "CFE_ES_CleanupTaskResources", "Get OS information failures"); } -static bool ES_UT_CheckIdSlotUsed(CFE_ES_ResourceID_t Id) -{ - return UT_DEFAULT_IMPL(ES_UT_CheckIdSlotUsed) != 0; -} - - void TestResourceID(void) { /* * Test cases for generic resource ID functions which are * not sufficiently covered by other app/lib tests. + * + * Most of the Resource ID functions have been moved to a separate module and that module + * has its own unit test which tests these APIs. + * + * This is mainly to exercise the conversion of CFE ES task IDs to OSAL task IDs and vice versa. + * The conversion is only implemented for tasks, because this is the only resource type where + * there is overlap between OSAL and CFE (they both have task records). */ - CFE_ES_ResourceID_t Id; - CFE_ES_ResourceID_t LastId; - uint32 Count; - - /* Call CFE_ES_FindNextAvailableId() using an invalid resource type */ - ES_ResetUnitTest(); - UT_SetDefaultReturnValue(UT_KEY(ES_UT_CheckIdSlotUsed), 1); - Id = CFE_ES_FindNextAvailableId(CFE_ES_RESOURCEID_UNDEFINED, 5, ES_UT_CheckIdSlotUsed); - UtAssert_True(!CFE_ES_ResourceID_IsDefined(Id), "CFE_ES_FindNextAvailableId() on undefined resource type"); - - /* Verify that CFE_ES_FindNextAvailableId() does not repeat until CFE_ES_RESOURCEID_MAX is reached */ - UT_SetDefaultReturnValue(UT_KEY(ES_UT_CheckIdSlotUsed), 0); - LastId = CFE_ES_Global.LastAppId; - Count = CFE_ES_RESOURCEID_MAX-1; - while (Count > 0) - { - Id = CFE_ES_FindNextAvailableId(LastId, CFE_PLATFORM_ES_MAX_APPLICATIONS, ES_UT_CheckIdSlotUsed); - if (CFE_ES_ResourceID_ToInteger(Id) - CFE_ES_ResourceID_ToInteger(LastId) != 1) - { - /* Numbers should be incrementing by 1 each time, never decreasing */ - break; - } + CFE_ES_TaskId_t cfe_id1, cfe_id2; + osal_id_t osal_id; - LastId = Id; - --Count; - } - UtAssert_True(Count == 0, "CFE_ES_FindNextAvailableId() allocate all resource ID space"); + /* + * In this function the actual values may or may not change, + * depending on whether strict/simple mode is in use. However + * converting to and from should result in the original value + * either way. + */ + UT_SetDefaultReturnValue(UT_KEY(OS_IdentifyObject), OS_OBJECT_TYPE_OS_TASK); + cfe_id1 = CFE_ES_TASKID_C(ES_UT_MakeTaskIdForIndex(0)); + osal_id = CFE_ES_TaskId_ToOSAL(cfe_id1); + cfe_id2 = CFE_ES_TaskId_FromOSAL(osal_id); + UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(cfe_id1, cfe_id2), "CFE_ES_TaskId_ToOSAL()/FromOSAL(): before=%lx, after=%lx", + CFE_RESOURCEID_TO_ULONG(cfe_id1), CFE_RESOURCEID_TO_ULONG(cfe_id2)); - /* Now verify that CFE_ES_FindNextAvailableId() recycles the first item again */ - Id = CFE_ES_FindNextAvailableId(LastId, CFE_PLATFORM_ES_MAX_APPLICATIONS, ES_UT_CheckIdSlotUsed); - UtAssert_True(CFE_ES_ResourceID_IsDefined(Id), "CFE_ES_FindNextAvailableId() after wrap"); - UtAssert_True(CFE_ES_ResourceID_ToInteger(Id) < (CFE_ES_APPID_BASE + CFE_PLATFORM_ES_MAX_APPLICATIONS), "CFE_ES_FindNextAvailableId() wrap ID"); } void TestLibs(void) { CFE_ES_LibRecord_t *UtLibRecPtr; char LongLibraryName[sizeof(UtLibRecPtr->BasicInfo.Name)+1]; - CFE_ES_ResourceID_t Id; - uint32 j; + CFE_ES_LibId_t Id; int32 Return; /* Test shared library loading and initialization where the initialization @@ -2231,7 +2228,7 @@ void TestLibs(void) Return == CFE_ES_ERR_DUPLICATE_NAME, "CFE_ES_LoadLibrary", "Duplicate"); - UtAssert_True(CFE_ES_ResourceID_Equal(Id, CFE_ES_LibRecordGetID(UtLibRecPtr)), + UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(Id, CFE_ES_LibRecordGetID(UtLibRecPtr)), "CFE_ES_LoadLibrary() returned previous ID"); /* Test shared library loading and initialization where the library @@ -2275,14 +2272,7 @@ void TestLibs(void) * library slots available */ ES_ResetUnitTest(); - UtLibRecPtr = CFE_ES_Global.LibTable; - for (j = 0; j < CFE_PLATFORM_ES_MAX_LIBRARIES; j++) - { - CFE_ES_LibRecordSetUsed(UtLibRecPtr, - ES_UT_MakeLibIdForIndex(j)); - ++UtLibRecPtr; - } - + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); Return = CFE_ES_LoadLibrary(&Id, "filename", "EntryPoint", @@ -2293,6 +2283,11 @@ void TestLibs(void) "CFE_ES_LoadLibrary", "No free library slots"); + /* check operation of the CFE_ES_CheckLibIdSlotUsed() function */ + CFE_ES_Global.LibTable[1].LibId = CFE_ES_LIBID_C(ES_UT_MakeLibIdForIndex(1)); + CFE_ES_Global.LibTable[2].LibId = CFE_ES_LIBID_UNDEFINED; + UtAssert_True(CFE_ES_CheckLibIdSlotUsed(ES_UT_MakeLibIdForIndex(1)), "Lib Slot Used"); + UtAssert_True(!CFE_ES_CheckLibIdSlotUsed(ES_UT_MakeLibIdForIndex(2)), "Lib Slot Unused"); /* * Test public Name+ID query/lookup API */ @@ -2302,8 +2297,8 @@ void TestLibs(void) UtAssert_INT32_EQ(CFE_ES_GetLibName(LongLibraryName, Id, sizeof(LongLibraryName)), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(&Id, "Nonexistent"), CFE_ES_ERR_NAME_NOT_FOUND); UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(&Id, LongLibraryName), CFE_SUCCESS); - UtAssert_True(CFE_ES_ResourceID_Equal(Id, CFE_ES_LibRecordGetID(UtLibRecPtr)), "Library IDs Match"); - UtAssert_INT32_EQ(CFE_ES_GetLibName(LongLibraryName, CFE_ES_RESOURCEID_UNDEFINED, sizeof(LongLibraryName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(Id, CFE_ES_LibRecordGetID(UtLibRecPtr)), "Library IDs Match"); + UtAssert_INT32_EQ(CFE_ES_GetLibName(LongLibraryName, CFE_ES_LIBID_UNDEFINED, sizeof(LongLibraryName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); UtAssert_INT32_EQ(CFE_ES_GetLibName(NULL, Id, sizeof(LongLibraryName)), CFE_ES_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(&Id, NULL), CFE_ES_BAD_ARGUMENT); } @@ -2726,7 +2721,7 @@ void TestTask(void) /* Test task main process loop with a HK packet subscribe failure */ ES_ResetUnitTest(); - UT_SetDeferredRetcode(UT_KEY(CFE_SB_SubscribeEx), 1, -3); + UT_SetDeferredRetcode(UT_KEY(CFE_SB_Subscribe), 1, -3); UT_Report(__FILE__, __LINE__, CFE_ES_TaskInit() == -3, "CFE_ES_TaskInit", @@ -2734,7 +2729,7 @@ void TestTask(void) /* Test task main process loop with a ground command subscribe failure */ ES_ResetUnitTest(); - UT_SetDeferredRetcode(UT_KEY(CFE_SB_SubscribeEx), 2, -4); + UT_SetDeferredRetcode(UT_KEY(CFE_SB_Subscribe), 2, -4); UT_Report(__FILE__, __LINE__, CFE_ES_TaskInit() == -4, "CFE_ES_TaskInit", @@ -3040,6 +3035,21 @@ void TestTask(void) "CFE_ES_RestartAppCmd", "Restart application initiated"); + /* Test app restart with failed file check */ + ES_ResetUnitTest(); + memset(&CmdBuf, 0, sizeof(CmdBuf)); + UT_SetDefaultReturnValue(UT_KEY(OS_stat), OS_ERROR); + ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, "CFE_ES", NULL, NULL); + strncpy(CmdBuf.RestartAppCmd.Payload.Application, "CFE_ES", + sizeof(CmdBuf.RestartAppCmd.Payload.Application)); + CmdBuf.RestartAppCmd.Payload.Application[sizeof(CmdBuf.RestartAppCmd.Payload.Application) - 1] = '\0'; + UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.RestartAppCmd), + UT_TPID_CFE_ES_CMD_RESTART_APP_CC); + UT_Report(__FILE__, __LINE__, + UT_EventIsInHistory(CFE_ES_RESTART_APP_ERR1_EID), + "CFE_ES_RestartAppCmd", + "Restart application failed"); + /* Test app restart with a bad app name */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); @@ -3053,10 +3063,10 @@ void TestTask(void) "CFE_ES_RestartAppCmd", "Restart application bad name"); - /* Test failed app restart */ + /* Test failed app restart, core app */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_WAITING, "CFE_ES", NULL, NULL); + ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, "CFE_ES", NULL, NULL); strncpy(CmdBuf.RestartAppCmd.Payload.Application, "CFE_ES", sizeof(CmdBuf.RestartAppCmd.Payload.Application) - 1); CmdBuf.RestartAppCmd.Payload.Application[sizeof(CmdBuf.RestartAppCmd.Payload.Application) - 1] = '\0'; @@ -3067,6 +3077,20 @@ void TestTask(void) "CFE_ES_RestartAppCmd", "Restart application failed"); + /* Test failed app restart, not running */ + ES_ResetUnitTest(); + memset(&CmdBuf, 0, sizeof(CmdBuf)); + ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_WAITING, "CFE_ES", NULL, NULL); + strncpy(CmdBuf.RestartAppCmd.Payload.Application, "CFE_ES", + sizeof(CmdBuf.RestartAppCmd.Payload.Application)); + CmdBuf.RestartAppCmd.Payload.Application[sizeof(CmdBuf.RestartAppCmd.Payload.Application) - 1] = '\0'; + UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.RestartAppCmd), + UT_TPID_CFE_ES_CMD_RESTART_APP_CC); + UT_Report(__FILE__, __LINE__, + UT_EventIsInHistory(CFE_ES_RESTART_APP_ERR1_EID), + "CFE_ES_RestartAppCmd", + "Restart application failed"); + /* Test successful app reload */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); @@ -3084,6 +3108,24 @@ void TestTask(void) "CFE_ES_ReloadAppCmd", "Reload application initiated"); + /* Test app reload with missing file */ + ES_ResetUnitTest(); + memset(&CmdBuf, 0, sizeof(CmdBuf)); + UT_SetDefaultReturnValue(UT_KEY(OS_stat), OS_ERROR); + ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, "CFE_ES", NULL, NULL); + strncpy(CmdBuf.ReloadAppCmd.Payload.AppFileName, "New_Name", + sizeof(CmdBuf.ReloadAppCmd.Payload.AppFileName)); + CmdBuf.ReloadAppCmd.Payload.AppFileName[sizeof(CmdBuf.ReloadAppCmd.Payload.AppFileName) - 1] = '\0'; + strncpy(CmdBuf.ReloadAppCmd.Payload.Application, "CFE_ES", + sizeof(CmdBuf.ReloadAppCmd.Payload.Application)); + CmdBuf.ReloadAppCmd.Payload.Application[sizeof(CmdBuf.ReloadAppCmd.Payload.Application) - 1] = '\0'; + UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.ReloadAppCmd), + UT_TPID_CFE_ES_CMD_RELOAD_APP_CC); + UT_Report(__FILE__, __LINE__, + UT_EventIsInHistory(CFE_ES_RELOAD_APP_ERR1_EID), + "CFE_ES_ReloadAppCmd", + "Reload application failed"); + /* Test app reload with a bad app name */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); @@ -3097,12 +3139,26 @@ void TestTask(void) "CFE_ES_ReloadAppCmd", "Reload application bad name"); - /* Test failed app reload */ + /* Test failed app reload, core app */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_WAITING, "CFE_ES", NULL, NULL); + ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, "CFE_ES", NULL, NULL); strncpy(CmdBuf.ReloadAppCmd.Payload.Application, "CFE_ES", - sizeof(CmdBuf.ReloadAppCmd.Payload.Application) - 1); + sizeof(CmdBuf.ReloadAppCmd.Payload.Application)); + CmdBuf.ReloadAppCmd.Payload.Application[sizeof(CmdBuf.ReloadAppCmd.Payload.Application) - 1] = '\0'; + UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.ReloadAppCmd), + UT_TPID_CFE_ES_CMD_RELOAD_APP_CC); + UT_Report(__FILE__, __LINE__, + UT_EventIsInHistory(CFE_ES_RELOAD_APP_ERR1_EID), + "CFE_ES_ReloadAppCmd", + "Reload application failed"); + + /* Test failed app reload, not RUNNING */ + ES_ResetUnitTest(); + memset(&CmdBuf, 0, sizeof(CmdBuf)); + ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_WAITING, "CFE_ES", NULL, NULL); + strncpy(CmdBuf.ReloadAppCmd.Payload.Application, "CFE_ES", + sizeof(CmdBuf.ReloadAppCmd.Payload.Application)); CmdBuf.ReloadAppCmd.Payload.Application[sizeof(CmdBuf.ReloadAppCmd.Payload.Application) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.ReloadAppCmd), UT_TPID_CFE_ES_CMD_RELOAD_APP_CC); @@ -3482,7 +3538,7 @@ void TestTask(void) ES_ResetUnitTest(); UT_SetDefaultReturnValue(UT_KEY(CFE_PSP_Exception_GetCount), 1); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, &UtTaskRecPtr); - UT_ContextTask = CFE_ES_ResourceID_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); + UT_ContextTask = CFE_ES_TaskId_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); UT_SetDataBuffer(UT_KEY(CFE_PSP_Exception_GetSummary), &UT_ContextTask, sizeof(UT_ContextTask), false); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_RUN; UtAppRecPtr->StartParams.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; @@ -3503,7 +3559,7 @@ void TestTask(void) ES_ResetUnitTest(); UT_SetDefaultReturnValue(UT_KEY(CFE_PSP_Exception_GetCount), 1); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, &UtTaskRecPtr); - UT_ContextTask = CFE_ES_ResourceID_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); + UT_ContextTask = CFE_ES_TaskId_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); UT_SetDataBuffer(UT_KEY(CFE_PSP_Exception_GetSummary), &UT_ContextTask, sizeof(UT_ContextTask), false); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_RUN; UtAppRecPtr->StartParams.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; @@ -4471,8 +4527,8 @@ void TestAPI(void) uint8 Data[12]; uint32 ResetType; uint32 *ResetTypePtr; - CFE_ES_ResourceID_t AppId; - CFE_ES_ResourceID_t TaskId; + CFE_ES_AppId_t AppId; + CFE_ES_TaskId_t TaskId; uint32 RunStatus; CFE_ES_TaskInfo_t TaskInfo; CFE_ES_AppInfo_t AppInfo; @@ -4527,7 +4583,7 @@ void TestAPI(void) /* Test restarting an app that doesn't exist */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_STOPPED, NULL, &UtAppRecPtr, NULL); - AppId = ES_UT_MakeAppIdForIndex(CFE_PLATFORM_ES_MAX_APPLICATIONS-1); /* Should be within range, but not used */ + AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(CFE_PLATFORM_ES_MAX_APPLICATIONS-1)); /* Should be within range, but not used */ UT_Report(__FILE__, __LINE__, CFE_ES_RestartApp(AppId) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_RestartApp", @@ -4535,7 +4591,7 @@ void TestAPI(void) /* Test restarting an app with an ID out of range (high) */ ES_ResetUnitTest(); - AppId = ES_UT_MakeAppIdForIndex(99999); + AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(99999)); UT_Report(__FILE__, __LINE__, CFE_ES_RestartApp(AppId) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_RestartApp", @@ -4708,7 +4764,7 @@ void TestAPI(void) /* Test getting the app name with a bad app ID */ ES_ResetUnitTest(); - AppId = ES_UT_MakeAppIdForIndex(99999); + AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(99999)); UT_Report(__FILE__, __LINE__, CFE_ES_GetAppName(AppName, AppId, sizeof(AppName)) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetAppName", @@ -4717,7 +4773,7 @@ void TestAPI(void) /* Test getting the app name with that app ID out of range */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, "UT", NULL, NULL); - AppId = ES_UT_MakeAppIdForIndex(99999); + AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(99999)); UT_Report(__FILE__, __LINE__, CFE_ES_GetAppName(AppName, AppId, @@ -4782,7 +4838,7 @@ void TestAPI(void) /* Test getting task information using the task ID with invalid task ID */ ES_ResetUnitTest(); - TaskId = CFE_ES_RESOURCEID_UNDEFINED; + TaskId = CFE_ES_TASKID_UNDEFINED; UT_Report(__FILE__, __LINE__, CFE_ES_GetTaskInfo(&TaskInfo, TaskId) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetTaskInfo", @@ -4878,7 +4934,7 @@ void TestAPI(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); ES_UT_SetupChildTaskId(UtAppRecPtr, NULL, &UtTaskRecPtr); - TestObjId = CFE_ES_ResourceID_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); + TestObjId = CFE_ES_TaskId_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId), OS_ObjectIdToInteger(TestObjId)); /* Set context to that of child */ Return = CFE_ES_CreateChildTask(&TaskId, "TaskName", @@ -4957,7 +5013,7 @@ void TestAPI(void) /* Test deleting a child task with the task ID out of range */ ES_ResetUnitTest(); - TaskId = CFE_ES_RESOURCEID_UNDEFINED; + TaskId = CFE_ES_TASKID_UNDEFINED; UT_Report(__FILE__, __LINE__, CFE_ES_DeleteChildTask(TaskId) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_DeleteChildTask", @@ -4967,7 +5023,7 @@ void TestAPI(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); ES_UT_SetupChildTaskId(UtAppRecPtr, NULL, &UtTaskRecPtr); - TestObjId = CFE_ES_ResourceID_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); + TestObjId = CFE_ES_TaskId_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId), OS_ObjectIdToInteger(TestObjId)); /* Set context to that of child */ CFE_ES_ExitChildTask(); UT_Report(__FILE__, __LINE__, @@ -5179,7 +5235,7 @@ void TestAPI(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, "UT", &UtAppRecPtr, &UtTaskRecPtr); TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); - UtAssert_INT32_EQ(CFE_ES_GetTaskName(AppName, CFE_ES_RESOURCEID_UNDEFINED, sizeof(AppName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_INT32_EQ(CFE_ES_GetTaskName(AppName, CFE_ES_TASKID_UNDEFINED, sizeof(AppName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); UtAssert_INT32_EQ(CFE_ES_GetTaskName(NULL, TaskId, sizeof(AppName)), CFE_ES_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_ES_GetTaskName(AppName, TaskId, sizeof(AppName)), CFE_SUCCESS); UT_SetDeferredRetcode(UT_KEY(OS_GetResourceName), 1, OS_ERROR); @@ -5194,8 +5250,8 @@ void TestAPI(void) void TestGenericCounterAPI(void) { char CounterName[11]; - CFE_ES_ResourceID_t CounterId; - CFE_ES_ResourceID_t CounterId2; + CFE_ES_CounterId_t CounterId; + CFE_ES_CounterId_t CounterId2; uint32 CounterCount; int i; @@ -5230,11 +5286,20 @@ void TestGenericCounterAPI(void) "Register maximum number of counters"); /* Test registering a generic counter after the maximum are registered */ + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_ES_RegisterGenCounter(&CounterId, "Counter999") == CFE_ES_NO_RESOURCE_IDS_AVAILABLE, "CFE_ES_RegisterGenCounter", "Maximum number of counters exceeded"); + UT_ResetState(UT_KEY(CFE_ResourceId_FindNext)); + + /* Check operation of the CFE_ES_CheckCounterIdSlotUsed() helper function */ + CFE_ES_Global.CounterTable[1].CounterId = CFE_ES_COUNTERID_C(ES_UT_MakeCounterIdForIndex(1)); + CFE_ES_Global.CounterTable[2].CounterId = CFE_ES_COUNTERID_UNDEFINED; + UtAssert_True(CFE_ES_CheckCounterIdSlotUsed(ES_UT_MakeCounterIdForIndex(1)), "Counter Slot Used"); + UtAssert_True(!CFE_ES_CheckCounterIdSlotUsed(ES_UT_MakeCounterIdForIndex(2)), "Counter Slot Unused"); + /* Test getting a registered generic counter that doesn't exist */ UT_Report(__FILE__, __LINE__, @@ -5252,7 +5317,7 @@ void TestGenericCounterAPI(void) /* Test deleting a registered generic counter that doesn't exist */ UT_Report(__FILE__, __LINE__, - CFE_ES_DeleteGenCounter(CFE_ES_RESOURCEID_UNDEFINED) == CFE_ES_BAD_ARGUMENT, + CFE_ES_DeleteGenCounter(CFE_ES_COUNTERID_UNDEFINED) == CFE_ES_BAD_ARGUMENT, "CFE_ES_DeleteGenCounter", "Cannot delete counter that does not exist"); @@ -5272,7 +5337,7 @@ void TestGenericCounterAPI(void) /* Test incrementing a generic counter that doesn't exist */ UT_Report(__FILE__, __LINE__, - CFE_ES_IncrementGenCounter(CFE_ES_RESOURCEID_UNDEFINED) + CFE_ES_IncrementGenCounter(CFE_ES_COUNTERID_UNDEFINED) == CFE_ES_BAD_ARGUMENT, "CFE_ES_IncrementGenCounter", "Bad counter ID"); @@ -5285,7 +5350,7 @@ void TestGenericCounterAPI(void) /* Test getting a generic counter value for a counter that doesn't exist */ UT_Report(__FILE__, __LINE__, - CFE_ES_GetGenCount(CFE_ES_RESOURCEID_UNDEFINED, &CounterCount) == CFE_ES_BAD_ARGUMENT, + CFE_ES_GetGenCount(CFE_ES_COUNTERID_UNDEFINED, &CounterCount) == CFE_ES_BAD_ARGUMENT, "CFE_ES_GetGenCount", "Bad counter ID"); @@ -5298,7 +5363,7 @@ void TestGenericCounterAPI(void) /* Test setting a generic counter value for a counter that doesn't exist */ UT_Report(__FILE__, __LINE__, - CFE_ES_SetGenCount(CFE_ES_RESOURCEID_UNDEFINED, 5) == CFE_ES_BAD_ARGUMENT, + CFE_ES_SetGenCount(CFE_ES_COUNTERID_UNDEFINED, 5) == CFE_ES_BAD_ARGUMENT, "CFE_ES_SetGenCount", "Bad counter ID"); @@ -5379,8 +5444,8 @@ void TestGenericCounterAPI(void) UtAssert_INT32_EQ(CFE_ES_GetGenCounterName(CounterName, CounterId, sizeof(CounterName)), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_GetGenCounterIDByName(&CounterId2, "Nonexistent"), CFE_ES_ERR_NAME_NOT_FOUND); UtAssert_INT32_EQ(CFE_ES_GetGenCounterIDByName(&CounterId2, CounterName), CFE_SUCCESS); - UtAssert_True(CFE_ES_ResourceID_Equal(CounterId, CounterId2), "Counter IDs Match"); - UtAssert_INT32_EQ(CFE_ES_GetGenCounterName(CounterName, CFE_ES_RESOURCEID_UNDEFINED, sizeof(CounterName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(CounterId, CounterId2), "Counter IDs Match"); + UtAssert_INT32_EQ(CFE_ES_GetGenCounterName(CounterName, CFE_ES_COUNTERID_UNDEFINED, sizeof(CounterName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); UtAssert_INT32_EQ(CFE_ES_GetGenCounterName(NULL, CounterId, sizeof(CounterName)), CFE_ES_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_ES_GetGenCounterIDByName(&CounterId, NULL), CFE_ES_BAD_ARGUMENT); } @@ -5525,18 +5590,18 @@ void TestCDS() ES_UT_SetupCDSGlobal(ES_UT_CDS_SMALL_TEST_SIZE); /* Set all the CDS registries to 'taken' */ - UtCDSRegRecPtr = CFE_ES_Global.CDSVars.Registry; - for (i = 0; i < CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES; i++) - { - CFE_ES_CDSBlockRecordSetUsed(UtCDSRegRecPtr, CFE_ES_RESOURCEID_RESERVED); - ++UtCDSRegRecPtr; - } - + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_ES_RegisterCDS(&CDSHandle, 4, "Name2") == CFE_ES_NO_RESOURCE_IDS_AVAILABLE, "CFE_ES_RegisterCDS", "No available entries"); + /* Check operation of the CFE_ES_CheckCDSHandleSlotUsed() helper function */ + CFE_ES_Global.CDSVars.Registry[1].BlockID = CFE_ES_CDSHANDLE_C(ES_UT_MakeCDSIdForIndex(1)); + CFE_ES_Global.CDSVars.Registry[2].BlockID = CFE_ES_CDS_BAD_HANDLE; + UtAssert_True(CFE_ES_CheckCDSHandleSlotUsed(ES_UT_MakeCDSIdForIndex(1)), "CDS Slot Used"); + UtAssert_True(!CFE_ES_CheckCDSHandleSlotUsed(ES_UT_MakeCDSIdForIndex(2)), "CDS Slot Unused"); + /* Test CDS registering using a bad app ID */ ES_ResetUnitTest(); UT_Report(__FILE__, __LINE__, @@ -5545,7 +5610,7 @@ void TestCDS() "Bad application ID"); /* Test copying to CDS with bad handle */ - CDSHandle = CFE_ES_RESOURCEID_UNDEFINED; + CDSHandle = CFE_ES_CDS_BAD_HANDLE; UT_Report(__FILE__, __LINE__, CFE_ES_CopyToCDS(CDSHandle, &TempSize) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_CopyToCDS", @@ -5856,8 +5921,8 @@ void TestCDS() UtAssert_INT32_EQ(CFE_ES_GetCDSBlockName(CDSName, CDSHandle, sizeof(CDSName)), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_GetCDSBlockIDByName(&CDSHandle, "Nonexistent"), CFE_ES_ERR_NAME_NOT_FOUND); UtAssert_INT32_EQ(CFE_ES_GetCDSBlockIDByName(&CDSHandle, CDSName), CFE_SUCCESS); - UtAssert_True(CFE_ES_ResourceID_Equal(CDSHandle, CFE_ES_CDSBlockRecordGetID(UtCDSRegRecPtr)), "CDS Handle IDs Match"); - UtAssert_INT32_EQ(CFE_ES_GetCDSBlockName(CDSName, CFE_ES_RESOURCEID_UNDEFINED, sizeof(CDSName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(CDSHandle, CFE_ES_CDSBlockRecordGetID(UtCDSRegRecPtr)), "CDS Handle IDs Match"); + UtAssert_INT32_EQ(CFE_ES_GetCDSBlockName(CDSName, CFE_ES_CDS_BAD_HANDLE, sizeof(CDSName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); UtAssert_INT32_EQ(CFE_ES_GetCDSBlockName(NULL, CDSHandle, sizeof(CDSName)), CFE_ES_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_ES_GetCDSBlockIDByName(&CDSHandle, NULL), CFE_ES_BAD_ARGUMENT); @@ -5867,7 +5932,7 @@ void TestCDSMempool(void) { CFE_ES_CDS_RegRec_t *UtCdsRegRecPtr; int Data; - CFE_ES_ResourceID_t BlockHandle; + CFE_ES_CDSHandle_t BlockHandle; size_t SavedSize; size_t SavedOffset; uint8 *CdsPtr; @@ -5924,7 +5989,7 @@ void TestCDSMempool(void) /* Test CDS block write using an invalid memory handle */ ES_ResetUnitTest(); - BlockHandle = CFE_ES_ResourceID_FromInteger(7); + BlockHandle = CFE_ES_CDSHANDLE_C(CFE_ResourceId_FromInteger(7)); UT_Report(__FILE__, __LINE__, CFE_ES_CDSBlockWrite(BlockHandle, &Data) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_CDSBlockWrite", @@ -6144,8 +6209,14 @@ void TestESMempool(void) * field is not the pool start address */ PoolPtr = CFE_ES_LocateMemPoolRecordByID(PoolID2); - PoolPtr->PoolID = CFE_ES_ResourceID_FromInteger( - CFE_ES_ResourceID_ToInteger(PoolPtr->PoolID) ^ 10); /* cause it to fail validation */ + + /* + * Intentionally corrupt the Pool ID value - whether strict or simple + * types are in use, underneath the wrapper(s) lies a uint32 eventually. + * This is intentionally a type-UNSAFE access to this value. + */ + *((uint32*)&PoolPtr->PoolID) ^= 10; /* cause it to fail validation */ + UT_Report(__FILE__, __LINE__, CFE_ES_ValidateHandle(PoolID2) == false, "CFE_ES_ValidateHandle", @@ -6166,7 +6237,7 @@ void TestESMempool(void) */ UT_Report(__FILE__, __LINE__, CFE_ES_GetMemPoolStats(&Stats, - CFE_ES_RESOURCEID_UNDEFINED) == CFE_ES_ERR_RESOURCEID_NOT_VALID, + CFE_ES_MEMHANDLE_UNDEFINED) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetMemPoolStats", "Invalid handle; not pool start address"); @@ -6189,8 +6260,8 @@ void TestESMempool(void) "CFE_ES_GetPoolBufInfo", "Invalid memory pool handle"); - PoolPtr->PoolID = CFE_ES_ResourceID_FromInteger( - CFE_ES_ResourceID_ToInteger(PoolPtr->PoolID) ^ 10); /* Repair Pool2 ID */ + /* Undo the previous memory corruption */ + *((uint32*)&PoolPtr->PoolID) ^= 10; /* Repair Pool2 ID */ /* Test returning a pool buffer using an invalid memory block */ UT_Report(__FILE__, __LINE__, @@ -6266,12 +6337,7 @@ void TestESMempool(void) * Test creating a memory pool after the limit reached (no slots) */ ES_ResetUnitTest(); - PoolPtr = CFE_ES_Global.MemPoolTable; - for (i = 0; i < CFE_PLATFORM_ES_MAX_MEMORY_POOLS; ++i) - { - CFE_ES_MemPoolRecordSetUsed(PoolPtr, CFE_ES_ResourceID_FromInteger(i + CFE_ES_POOLID_BASE)); - ++PoolPtr; - } + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_ES_PoolCreateEx(&PoolID1, Buffer1, @@ -6282,6 +6348,12 @@ void TestESMempool(void) "CFE_ES_PoolCreateEx", "Memory pool limit reached"); + /* Check operation of the CFE_ES_CheckCounterIdSlotUsed() helper function */ + CFE_ES_Global.MemPoolTable[1].PoolID = CFE_ES_MEMHANDLE_C(ES_UT_MakePoolIdForIndex(1)); + CFE_ES_Global.MemPoolTable[2].PoolID = CFE_ES_MEMHANDLE_UNDEFINED; + UtAssert_True(CFE_ES_CheckMemPoolSlotUsed(ES_UT_MakePoolIdForIndex(1)), "MemPool Slot Used"); + UtAssert_True(!CFE_ES_CheckMemPoolSlotUsed(ES_UT_MakePoolIdForIndex(2)), "MemPool Slot Unused"); + /* * Test creating a memory pool with a semaphore error */ @@ -6522,13 +6594,13 @@ void TestESMempool(void) /* Test handle validation using a null handle */ UT_Report(__FILE__, __LINE__, - CFE_ES_ValidateHandle(CFE_ES_RESOURCEID_UNDEFINED) == false, + CFE_ES_ValidateHandle(CFE_ES_MEMHANDLE_UNDEFINED) == false, "CFE_ES_ValidateHandle", "NULL handle"); /* Test returning a pool buffer using a null handle */ UT_Report(__FILE__, __LINE__, - CFE_ES_PutPoolBuf(CFE_ES_RESOURCEID_UNDEFINED, addressp2) == CFE_ES_ERR_RESOURCEID_NOT_VALID, + CFE_ES_PutPoolBuf(CFE_ES_MEMHANDLE_UNDEFINED, addressp2) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_PutPoolBuf", "NULL memory handle"); @@ -6536,14 +6608,14 @@ void TestESMempool(void) ES_ResetUnitTest(); UT_Report(__FILE__, __LINE__, CFE_ES_GetPoolBuf(&addressp2, - CFE_ES_RESOURCEID_UNDEFINED, + CFE_ES_MEMHANDLE_UNDEFINED, 256) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetPoolBuf", "NULL memory handle"); /* Test getting the size of an existing pool buffer using a null handle */ UT_Report(__FILE__, __LINE__, - CFE_ES_GetPoolBufInfo(CFE_ES_RESOURCEID_UNDEFINED, addressp1) == + CFE_ES_GetPoolBufInfo(CFE_ES_MEMHANDLE_UNDEFINED, addressp1) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetPoolBufInfo", "NULL memory handle"); @@ -6609,7 +6681,7 @@ void TestESMempool(void) /* Test getting the size of a pool buffer with an invalid memory handle */ UT_Report(__FILE__, __LINE__, - CFE_ES_PutPoolBuf(CFE_ES_RESOURCEID_UNDEFINED, + CFE_ES_PutPoolBuf(CFE_ES_MEMHANDLE_UNDEFINED, addressp1) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_PutPoolBuf", diff --git a/fsw/cfe-core/unit-test/evs_UT.c b/fsw/cfe-core/unit-test/evs_UT.c index 4173a916a..08ae7b5f7 100644 --- a/fsw/cfe-core/unit-test/evs_UT.c +++ b/fsw/cfe-core/unit-test/evs_UT.c @@ -365,10 +365,10 @@ void Test_Init(void) /* Test early initialization, clearing the event log (log mode path) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetResetType), 1, -1); - CFE_EVS_GlobalData.EVS_LogPtr->LogMode = CFE_EVS_LogMode_OVERWRITE + + CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_EVS_LogMode_OVERWRITE + CFE_EVS_LogMode_DISCARD + 1; - CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag = false; - CFE_EVS_GlobalData.EVS_LogPtr->Next = CFE_PLATFORM_EVS_LOG_MAX - 1; + CFE_EVS_Global.EVS_LogPtr->LogFullFlag = false; + CFE_EVS_Global.EVS_LogPtr->Next = CFE_PLATFORM_EVS_LOG_MAX - 1; CFE_EVS_EarlyInit(); UT_Report(__FILE__, __LINE__, UT_SyslogIsInHistory(EVS_SYSLOG_MSGS[5]), @@ -378,9 +378,9 @@ void Test_Init(void) /* Test early initialization, clearing the event log (log full path) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetResetType), 1, -1); - CFE_EVS_GlobalData.EVS_LogPtr->LogMode = CFE_EVS_LogMode_DISCARD; - CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag = 2; - CFE_EVS_GlobalData.EVS_LogPtr->Next = CFE_PLATFORM_EVS_LOG_MAX - 1; + CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_EVS_LogMode_DISCARD; + CFE_EVS_Global.EVS_LogPtr->LogFullFlag = 2; + CFE_EVS_Global.EVS_LogPtr->Next = CFE_PLATFORM_EVS_LOG_MAX - 1; CFE_EVS_EarlyInit(); UT_Report(__FILE__, __LINE__, UT_SyslogIsInHistory(EVS_SYSLOG_MSGS[5]), @@ -390,9 +390,9 @@ void Test_Init(void) /* Test early initialization, clearing the event log (next log path) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetResetType), 1, -1); - CFE_EVS_GlobalData.EVS_LogPtr->LogMode = CFE_EVS_LogMode_OVERWRITE; - CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag = true; - CFE_EVS_GlobalData.EVS_LogPtr->Next = CFE_PLATFORM_EVS_LOG_MAX; + CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_EVS_LogMode_OVERWRITE; + CFE_EVS_Global.EVS_LogPtr->LogFullFlag = true; + CFE_EVS_Global.EVS_LogPtr->Next = CFE_PLATFORM_EVS_LOG_MAX; CFE_EVS_EarlyInit(); UT_Report(__FILE__, __LINE__, UT_SyslogIsInHistory(EVS_SYSLOG_MSGS[5]), @@ -448,7 +448,7 @@ void Test_Init(void) /* Test task initialization where command subscription fails */ UT_InitData(); - UT_SetDeferredRetcode(UT_KEY(CFE_SB_SubscribeEx), 1, -1); + UT_SetDeferredRetcode(UT_KEY(CFE_SB_Subscribe), 1, -1); CFE_EVS_TaskInit(); UT_Report(__FILE__, __LINE__, UT_SyslogIsInHistory(EVS_SYSLOG_MSGS[13]), @@ -457,7 +457,7 @@ void Test_Init(void) /* Test task initialization where HK request subscription fails */ UT_InitData(); - UT_SetDeferredRetcode(UT_KEY(CFE_SB_SubscribeEx), 2, -1); + UT_SetDeferredRetcode(UT_KEY(CFE_SB_Subscribe), 2, -1); CFE_EVS_TaskInit(); UT_Report(__FILE__, __LINE__, UT_SyslogIsInHistory(EVS_SYSLOG_MSGS[14]), @@ -566,7 +566,7 @@ void Test_IllegalAppID(void) UT_Report(__FILE__, __LINE__, CFE_EVS_SendEventWithAppID(0, 0, - CFE_ES_RESOURCEID_UNDEFINED, + CFE_ES_APPID_UNDEFINED, "NULL") == CFE_EVS_APP_ILLEGAL_APP_ID, "CFE_EVS_SendEventWithAppID", "Illegal app ID"); @@ -591,7 +591,7 @@ void Test_IllegalAppID(void) UT_InitData(); UT_SetDefaultReturnValue(UT_KEY(CFE_ES_AppID_ToIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID); UT_Report(__FILE__, __LINE__, - CFE_EVS_CleanUpApp(CFE_ES_RESOURCEID_UNDEFINED) == + CFE_EVS_CleanUpApp(CFE_ES_APPID_UNDEFINED) == CFE_EVS_APP_ILLEGAL_APP_ID, "CFE_EVS_CleanUpApp", "Illegal app ID"); @@ -605,7 +605,7 @@ void Test_UnregisteredApp(void) { CFE_TIME_SysTime_t time = {0, 0}; EVS_AppData_t *AppDataPtr; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; /* Get a local ref to the "current" AppData table entry */ EVS_GetCurrentContext(&AppDataPtr, &AppID); @@ -688,7 +688,7 @@ void Test_FilterRegistration(void) CFE_EVS_BinFilter_t filter[CFE_PLATFORM_EVS_MAX_EVENT_FILTERS + 1]; EVS_BinFilter_t *FilterPtr = NULL; EVS_AppData_t *AppDataPtr; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; CFE_TIME_SysTime_t time = {0, 0}; /* Get a local ref to the "current" AppData table entry */ @@ -696,8 +696,8 @@ void Test_FilterRegistration(void) UtPrintf("Begin Test Filter Registration"); - CFE_EVS_GlobalData.EVS_AppID = AppID; - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; + CFE_EVS_Global.EVS_AppID = AppID; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; /* Test filter registration using an invalid filter option */ UT_InitData(); @@ -929,7 +929,7 @@ void Test_Format(void) .SnapshotSize = sizeof(CapturedMsg) }; EVS_AppData_t *AppDataPtr; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; UT_EVS_MSGInitData_t MsgData; CFE_MSG_Message_t *MsgSend; @@ -938,7 +938,7 @@ void Test_Format(void) UtPrintf("Begin Test Format"); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; /* Enable DEBUG message output */ UT_InitData(); @@ -1083,7 +1083,7 @@ void Test_Ports(void) UtPrintf("Begin Test Ports"); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; /* Test enabling all ports; reports implicitly via port output */ UT_InitData(); @@ -1225,11 +1225,11 @@ void Test_Logging(void) UtPrintf("Begin Test Logging"); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; /* Test setting the logging mode with logging disabled */ UT_InitData(); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled = false; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = false; memset(&CmdBuf, 0, sizeof(CmdBuf)); CmdBuf.modecmd.Payload.LogMode = 0xff; UT_EVS_DoDispatchCheckEvents(&CmdBuf.modecmd, sizeof(CmdBuf.modecmd), @@ -1241,13 +1241,13 @@ void Test_Logging(void) "Set log mode command: event log disabled"); /* Re-enable logging and set conditions to allow complete code coverage */ - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled = true; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = true; UT_SetSizeofESResetArea(sizeof(CFE_ES_ResetData_t)); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_SUCCESS); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetResetType), 1, CFE_PSP_RST_TYPE_POWERON); CFE_PSP_GetResetArea(&TempAddr, &resetAreaSize); CFE_EVS_ResetDataPtr = (CFE_ES_ResetData_t *)TempAddr; - CFE_EVS_GlobalData.EVS_LogPtr = &CFE_EVS_ResetDataPtr->EVS_Log; + CFE_EVS_Global.EVS_LogPtr = &CFE_EVS_ResetDataPtr->EVS_Log; /* Test setting the logging mode using an invalid mode */ UT_InitData(); @@ -1285,8 +1285,8 @@ void Test_Logging(void) CFE_EVS_SendEvent(0, CFE_EVS_EventType_INFORMATION, "Log overfill event discard"); UT_Report(__FILE__, __LINE__, - CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag == true && - CFE_EVS_GlobalData.EVS_LogPtr->LogMode == CFE_EVS_LogMode_DISCARD, + CFE_EVS_Global.EVS_LogPtr->LogFullFlag == true && + CFE_EVS_Global.EVS_LogPtr->LogMode == CFE_EVS_LogMode_DISCARD, "CFE_EVS_SendEvent", "Log overfill event (discard mode)"); @@ -1298,14 +1298,14 @@ void Test_Logging(void) &UT_EVS_EventBuf); CFE_EVS_SendEvent(0, CFE_EVS_EventType_INFORMATION, "Log overfill event overwrite"); UT_Report(__FILE__, __LINE__, - CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag == true && - CFE_EVS_GlobalData.EVS_LogPtr->LogMode == CFE_EVS_LogMode_OVERWRITE, + CFE_EVS_Global.EVS_LogPtr->LogFullFlag == true && + CFE_EVS_Global.EVS_LogPtr->LogMode == CFE_EVS_LogMode_OVERWRITE, "CFE_EVS_SetLogModeCmd", "Log overfill event (overwrite mode)"); /* Test writing to the log while it is disabled */ UT_InitData(); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled = false; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = false; memset(&CmdBuf, 0, sizeof(CmdBuf)); UT_EVS_DoDispatchCheckEvents(&CmdBuf.logfilecmd, sizeof(CmdBuf.logfilecmd), UT_TPID_CFE_EVS_CMD_WRITE_LOG_DATA_FILE_CC, @@ -1337,12 +1337,12 @@ void Test_Logging(void) /* Clear log for next test */ UT_InitData(); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled = true; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = true; UT_EVS_DoDispatchCheckEvents(&CmdBuf.cmd, sizeof(CmdBuf.cmd), UT_TPID_CFE_EVS_CMD_CLEAR_LOG_CC, &UT_EVS_EventBuf); UT_Report(__FILE__, __LINE__, - CFE_EVS_GlobalData.EVS_LogPtr->LogFullFlag == false, + CFE_EVS_Global.EVS_LogPtr->LogFullFlag == false, "EVS_ClearLog", "Clear log"); @@ -1354,7 +1354,7 @@ void Test_Logging(void) UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetResetType), 1, CFE_PSP_RST_TYPE_POWERON); CFE_PSP_GetResetArea(&TempAddr, &resetAreaSize); CFE_EVS_ResetDataPtr = (CFE_ES_ResetData_t *)TempAddr; - CFE_EVS_GlobalData.EVS_LogPtr = &CFE_EVS_ResetDataPtr->EVS_Log; + CFE_EVS_Global.EVS_LogPtr = &CFE_EVS_ResetDataPtr->EVS_Log; CmdBuf.modecmd.Payload.LogMode = CFE_EVS_LogMode_OVERWRITE; UT_Report(__FILE__, __LINE__, CFE_EVS_SetLogModeCmd(&CmdBuf.modecmd) == CFE_SUCCESS, @@ -1385,7 +1385,7 @@ void Test_Logging(void) /* Test successfully writing all log entries */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_SUCCESS); - CFE_EVS_GlobalData.EVS_LogPtr->LogCount = CFE_PLATFORM_EVS_LOG_MAX; + CFE_EVS_Global.EVS_LogPtr->LogCount = CFE_PLATFORM_EVS_LOG_MAX; UT_Report(__FILE__, __LINE__, CFE_EVS_WriteLogDataFileCmd(&CmdBuf.logfilecmd) == CFE_SUCCESS, "CFE_EVS_WriteLogDataFileCmd", @@ -1395,7 +1395,7 @@ void Test_Logging(void) UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OS_write), OS_ERROR); - CFE_EVS_GlobalData.EVS_LogPtr->LogCount = CFE_PLATFORM_EVS_LOG_MAX; + CFE_EVS_Global.EVS_LogPtr->LogCount = CFE_PLATFORM_EVS_LOG_MAX; UT_Report(__FILE__, __LINE__, CFE_EVS_WriteLogDataFileCmd(&CmdBuf.logfilecmd) != CFE_SUCCESS, "CFE_EVS_WriteLogDataFileCmd", @@ -1440,7 +1440,7 @@ void Test_WriteApp(void) UtPrintf("Begin Test Write App"); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; /* Enable DEBUG message output */ UT_InitData(); @@ -1545,7 +1545,7 @@ void Test_BadAppCmd(void) UtPrintf("Begin Test Bad App Command"); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; UT_InitData(); @@ -1962,7 +1962,7 @@ void Test_EventCmd(void) UtPrintf("Begin Test Event Command"); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; UT_InitData(); @@ -2205,7 +2205,7 @@ void Test_FilterCmd(void) UtPrintf("Begin Test Filter Command"); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; UT_InitData(); @@ -2649,7 +2649,7 @@ void Test_InvalidCmd(void) /* Test invalid command length with write log data command */ UT_InitData(); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled = true; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = true; UT_EVS_DoDispatchCheckEvents(&cmd, 0, UT_TPID_CFE_EVS_CMD_WRITE_LOG_DATA_FILE_CC, &UT_EVS_EventBuf); @@ -2692,7 +2692,7 @@ void Test_Misc(void) CFE_EVS_WriteLogDataFileCmd_t writelogdatacmd; } PktBuf; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; EVS_AppData_t *AppDataPtr; int i; char msg[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH + 2]; @@ -2706,8 +2706,8 @@ void Test_Misc(void) UtPrintf("Begin Test Miscellaneous"); memset(&PktBuf, 0, sizeof(PktBuf)); - CFE_EVS_GlobalData.EVS_AppID = AppID; - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; + CFE_EVS_Global.EVS_AppID = AppID; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; /* Test successful log data file write */ UT_InitData(); @@ -2731,7 +2731,7 @@ void Test_Misc(void) /* Test housekeeping report with log enabled */ UT_InitData(); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled = true; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = true; HK_SnapshotData.Count = 0; UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), UT_SoftwareBusSnapshotHook, &HK_SnapshotData); UT_CallTaskPipe(CFE_EVS_ProcessCommandPacket, &PktBuf.msg, sizeof(PktBuf.cmd), @@ -2744,7 +2744,7 @@ void Test_Misc(void) /* Test successful application cleanup */ UT_InitData(); UT_Report(__FILE__, __LINE__, - CFE_EVS_CleanUpApp(CFE_ES_RESOURCEID_UNDEFINED) == CFE_SUCCESS, + CFE_EVS_CleanUpApp(CFE_ES_APPID_UNDEFINED) == CFE_SUCCESS, "CFE_EVS_CleanUpApp", "Application cleanup - successful"); @@ -2757,7 +2757,7 @@ void Test_Misc(void) /* Test housekeeping report with log disabled */ UT_InitData(); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled = false; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = false; HK_SnapshotData.Count = 0; UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), UT_SoftwareBusSnapshotHook, &HK_SnapshotData); UT_CallTaskPipe(CFE_EVS_ProcessCommandPacket, &PktBuf.msg, sizeof(PktBuf.cmd), @@ -2771,12 +2771,12 @@ void Test_Misc(void) * at their maximum allowed values */ UT_InitData(); - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageSendCounter = + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageSendCounter = CFE_EVS_MAX_EVENT_SEND_COUNT; AppDataPtr->EventCount = CFE_EVS_MAX_EVENT_SEND_COUNT; EVS_SendEvent(0, 0, "Max Event Count"); UT_Report(__FILE__, __LINE__, - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageSendCounter == + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageSendCounter == CFE_EVS_MAX_EVENT_SEND_COUNT && AppDataPtr->EventCount == CFE_EVS_MAX_EVENT_SEND_COUNT, @@ -2794,14 +2794,14 @@ void Test_Misc(void) } msg[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH] = '\0'; - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageTruncCounter = 0; + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageTruncCounter = 0; EVS_AppDataSetUsed(AppDataPtr, AppID); AppDataPtr->ActiveFlag = true; AppDataPtr->EventTypesActiveFlag |= CFE_EVS_INFORMATION_BIT; EVS_SendEvent(0, CFE_EVS_EventType_INFORMATION, msg); UT_Report(__FILE__, __LINE__, - CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageTruncCounter == 1, + CFE_EVS_Global.EVS_TlmPkt.Payload.MessageTruncCounter == 1, "EVS_SendEvent", "Maximum message length exceeded"); } diff --git a/fsw/cfe-core/unit-test/sb_UT.c b/fsw/cfe-core/unit-test/sb_UT.c index 117c4929b..3e041c35d 100644 --- a/fsw/cfe-core/unit-test/sb_UT.c +++ b/fsw/cfe-core/unit-test/sb_UT.c @@ -40,6 +40,7 @@ */ #include "sb_UT.h" #include "cfe_msg_api.h" +#include "private/cfe_core_resourceid_basevalues.h" /* * A method to add an SB "Subtest" @@ -112,20 +113,32 @@ const CFE_SB_MsgId_t SB_UT_ALTERNATE_INVALID_MID = CFE_SB_MSGID_WRAP_VALUE(CFE_P const CFE_SB_MsgId_t SB_UT_BARE_CMD_MID3 = CFE_SB_MSGID_WRAP_VALUE(0x1003); const CFE_SB_MsgId_t SB_UT_BARE_TLM_MID3 = CFE_SB_MSGID_WRAP_VALUE(0x0003); -const CFE_SB_PipeId_t SB_UT_PIPEID_0 = { CFE_SB_PIPEID_BASE + 0 }; -const CFE_SB_PipeId_t SB_UT_PIPEID_1 = { CFE_SB_PIPEID_BASE + 1 }; -const CFE_SB_PipeId_t SB_UT_PIPEID_2 = { CFE_SB_PIPEID_BASE + 2 }; -const CFE_SB_PipeId_t SB_UT_PIPEID_3 = { CFE_SB_PIPEID_BASE + 3 }; -const CFE_SB_PipeId_t SB_UT_ALTERNATE_INVALID_PIPEID = { 0xDEADBEEF }; +#define SB_UT_PIPEID_0 CFE_SB_PIPEID_C(CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE + 0)) +#define SB_UT_PIPEID_1 CFE_SB_PIPEID_C(CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE + 1)) +#define SB_UT_PIPEID_2 CFE_SB_PIPEID_C(CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE + 2)) +#define SB_UT_PIPEID_3 CFE_SB_PIPEID_C(CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE + 3)) +#define SB_UT_ALTERNATE_INVALID_PIPEID CFE_SB_PIPEID_C(CFE_ResourceId_FromInteger(0xDEADBEEF)) + +/* + * Helper function to manufacture a fake pipe ID value that will validate + */ +CFE_ResourceId_t UT_SB_MakePipeIdForIndex(uint32 ArrayIdx) +{ + return CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE + ArrayIdx); +} /* * Helper function to "corrupt" a resource ID value in a consistent/predicatble way, * which can also be un-done easily. */ -CFE_ES_ResourceID_t UT_SB_ResourceID_Modify(CFE_ES_ResourceID_t InitialID, int32 Modifier) +CFE_ES_AppId_t UT_SB_AppID_Modify(CFE_ES_AppId_t InitialID, int32 Modifier) { - unsigned long NewValue = CFE_ES_ResourceID_ToInteger(InitialID) + Modifier; - return CFE_ES_ResourceID_FromInteger(NewValue); + CFE_ES_AppId_t TempValue = InitialID; + + /* Underneath the wrapper(s) the IDs are 32-bit integer values, so it can be cast */ + *((uint32*)&TempValue) += Modifier; + + return TempValue; } /* @@ -234,7 +247,7 @@ void Test_SB_AppInit_EVSSendEvtFail(void) EVTCNT(4); - TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe)); + TEARDOWN(CFE_SB_DeletePipe(CFE_SB_Global.CmdPipe)); } /* end Test_SB_AppInit_EVSSendEvtFail */ @@ -267,7 +280,7 @@ void Test_SB_AppInit_Sub1Fail(void) EVTSENT(CFE_SB_DEST_BLK_ERR_EID); - TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe)); + TEARDOWN(CFE_SB_DeletePipe(CFE_SB_Global.CmdPipe)); } /* end Test_SB_AppInit_Sub1Fail */ @@ -283,7 +296,7 @@ void Test_SB_AppInit_Sub2Fail(void) EVTSENT(CFE_SB_DEST_BLK_ERR_EID); - TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe)); + TEARDOWN(CFE_SB_DeletePipe(CFE_SB_Global.CmdPipe)); } /* end Test_SB_AppInit_Sub2Fail */ @@ -300,7 +313,7 @@ void Test_SB_AppInit_GetPoolFail(void) EVTCNT(4); - TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe)); + TEARDOWN(CFE_SB_DeletePipe(CFE_SB_Global.CmdPipe)); } /* end Test_SB_AppInit_GetPoolFail */ @@ -317,7 +330,7 @@ void Test_SB_AppInit_PutPoolFail(void) EVTCNT(4); - TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe)); + TEARDOWN(CFE_SB_DeletePipe(CFE_SB_Global.CmdPipe)); } /* end Test_SB_AppInit_PutPoolFail */ @@ -344,7 +357,7 @@ void Test_SB_Main_RcvErr(void) EVTSENT(CFE_SB_Q_RD_ERR_EID); - TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe)); + TEARDOWN(CFE_SB_DeletePipe(CFE_SB_Global.CmdPipe)); } /* end Test_SB_Main_RcvErr */ @@ -358,7 +371,7 @@ void Test_SB_Main_InitErr(void) EVTCNT(4); - TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe)); + TEARDOWN(CFE_SB_DeletePipe(CFE_SB_Global.CmdPipe)); } /* end Test_SB_Main_InitErr */ @@ -400,7 +413,6 @@ void Test_SB_Cmds(void) SB_UT_ADD_SUBTEST(Test_SB_Cmds_SubRptOn); SB_UT_ADD_SUBTEST(Test_SB_Cmds_SubRptOff); SB_UT_ADD_SUBTEST(Test_SB_Cmds_CmdUnexpCmdCode); - SB_UT_ADD_SUBTEST(Test_SB_Cmds_SubRptUnexpCmdCode); SB_UT_ADD_SUBTEST(Test_SB_Cmds_BadCmdLength); SB_UT_ADD_SUBTEST(Test_SB_Cmds_UnexpMsgId); } /* end Test_SB_Cmds */ @@ -471,7 +483,7 @@ void Test_SB_Cmds_Stats(void) /* For internal TransmitMsg call */ MsgId = CFE_SB_ValueToMsgId(CFE_SB_STATS_TLM_MID); - Size = sizeof(CFE_SB.StatTlmMsg); + Size = sizeof(CFE_SB_Global.StatTlmMsg); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); @@ -493,28 +505,28 @@ void Test_SB_Cmds_Stats(void) } /* end Test_SB_Cmds_Stats */ /* -** Test send routing information command using the default file name +** Test write routing information command using the default file name */ void Test_SB_Cmds_RoutingInfoDef(void) { union { - CFE_SB_Buffer_t SBBuf; - CFE_SB_SendRoutingInfoCmd_t Cmd; - } SendRoutingInfo; - CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_ROUTING_INFO_CC; + CFE_SB_Buffer_t SBBuf; + CFE_SB_WriteRoutingInfoCmd_t Cmd; + } WriteRoutingInfo; + CFE_MSG_FcnCode_t FcnCode = CFE_SB_WRITE_ROUTING_INFO_CC; CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID); - CFE_MSG_Size_t Size = sizeof(SendRoutingInfo.Cmd); + CFE_MSG_Size_t Size = sizeof(WriteRoutingInfo.Cmd); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - SendRoutingInfo.Cmd.Payload.Filename[0] = '\0'; + WriteRoutingInfo.Cmd.Payload.Filename[0] = '\0'; /* Make some routing info by calling CFE_SB_AppInit */ SETUP(CFE_SB_AppInit()); - CFE_SB_ProcessCmdPipePkt(&SendRoutingInfo.SBBuf); + CFE_SB_ProcessCmdPipePkt(&WriteRoutingInfo.SBBuf); EVTCNT(9); @@ -526,32 +538,32 @@ void Test_SB_Cmds_RoutingInfoDef(void) EVTSENT(CFE_SB_SND_RTG_EID); - TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe)); + TEARDOWN(CFE_SB_DeletePipe(CFE_SB_Global.CmdPipe)); } /* end Test_SB_Cmds_RoutingInfoDef */ /* -** Test send routing information command using a specified file name +** Test write routing information command using a specified file name */ void Test_SB_Cmds_RoutingInfoSpec(void) { union { - CFE_SB_Buffer_t SBBuf; - CFE_SB_SendRoutingInfoCmd_t Cmd; - } SendRoutingInfo; - CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_ROUTING_INFO_CC; + CFE_SB_Buffer_t SBBuf; + CFE_SB_WriteRoutingInfoCmd_t Cmd; + } WriteRoutingInfo; + CFE_MSG_FcnCode_t FcnCode = CFE_SB_WRITE_ROUTING_INFO_CC; CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID); - CFE_MSG_Size_t Size = sizeof(SendRoutingInfo.Cmd); + CFE_MSG_Size_t Size = sizeof(WriteRoutingInfo.Cmd); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - strncpy(SendRoutingInfo.Cmd.Payload.Filename, "RoutingTstFile", - sizeof(SendRoutingInfo.Cmd.Payload.Filename) - 1); - SendRoutingInfo.Cmd.Payload.Filename[sizeof(SendRoutingInfo.Cmd.Payload.Filename) - 1] = '\0'; + strncpy(WriteRoutingInfo.Cmd.Payload.Filename, "RoutingTstFile", + sizeof(WriteRoutingInfo.Cmd.Payload.Filename) - 1); + WriteRoutingInfo.Cmd.Payload.Filename[sizeof(WriteRoutingInfo.Cmd.Payload.Filename) - 1] = '\0'; - CFE_SB_ProcessCmdPipePkt(&SendRoutingInfo.SBBuf); + CFE_SB_ProcessCmdPipePkt(&WriteRoutingInfo.SBBuf); EVTCNT(1); @@ -560,30 +572,30 @@ void Test_SB_Cmds_RoutingInfoSpec(void) } /* end Test_SB_Cmds_RoutingInfoSpec */ /* -** Test send routing information command with a file creation failure +** Test write routing information command with a file creation failure */ void Test_SB_Cmds_RoutingInfoCreateFail(void) { union { - CFE_SB_Buffer_t SBBuf; - CFE_SB_SendRoutingInfoCmd_t Cmd; - } SendRoutingInfo; - CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_ROUTING_INFO_CC; + CFE_SB_Buffer_t SBBuf; + CFE_SB_WriteRoutingInfoCmd_t Cmd; + } WriteRoutingInfo; + CFE_MSG_FcnCode_t FcnCode = CFE_SB_WRITE_ROUTING_INFO_CC; CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID); - CFE_MSG_Size_t Size = sizeof(SendRoutingInfo.Cmd); + CFE_MSG_Size_t Size = sizeof(WriteRoutingInfo.Cmd); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - strncpy(SendRoutingInfo.Cmd.Payload.Filename, "RoutingTstFile", - sizeof(SendRoutingInfo.Cmd.Payload.Filename) - 1); - SendRoutingInfo.Cmd.Payload.Filename[sizeof(SendRoutingInfo.Cmd.Payload.Filename) - 1] = '\0'; + strncpy(WriteRoutingInfo.Cmd.Payload.Filename, "RoutingTstFile", + sizeof(WriteRoutingInfo.Cmd.Payload.Filename) - 1); + WriteRoutingInfo.Cmd.Payload.Filename[sizeof(WriteRoutingInfo.Cmd.Payload.Filename) - 1] = '\0'; - /* Make function CFE_SB_SendRtgInfo return CFE_SB_FILE_IO_ERR */ + /* Make function CFE_SB_WriteRtgInfo return CFE_SB_FILE_IO_ERR */ UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); - CFE_SB_ProcessCmdPipePkt(&SendRoutingInfo.SBBuf); + CFE_SB_ProcessCmdPipePkt(&WriteRoutingInfo.SBBuf); EVTCNT(1); @@ -592,13 +604,13 @@ void Test_SB_Cmds_RoutingInfoCreateFail(void) } /* end Test_SB_Cmds_RoutingInfoCreateFail */ /* -** Test send routing information command with a file header write failure +** Test write routing information command with a file header write failure */ void Test_SB_Cmds_RoutingInfoHdrFail(void) { UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1); - ASSERT_EQ(CFE_SB_SendRtgInfo("RoutingTstFile"), CFE_SB_FILE_IO_ERR); + ASSERT_EQ(CFE_SB_WriteRtgInfo("RoutingTstFile"), CFE_SB_FILE_IO_ERR); EVTCNT(1); @@ -607,7 +619,7 @@ void Test_SB_Cmds_RoutingInfoHdrFail(void) } /* end Test_SB_Cmds_RoutingInfoHdrFail */ /* -** Test send routing information command with a file write failure on +** Test write routing information command with a file write failure on ** the second write */ void Test_SB_Cmds_RoutingInfoWriteFail(void) @@ -617,7 +629,7 @@ void Test_SB_Cmds_RoutingInfoWriteFail(void) UT_SetDeferredRetcode(UT_KEY(OS_write), 2, -1); - ASSERT_EQ(CFE_SB_SendRtgInfo("RoutingTstFile"), CFE_SB_FILE_IO_ERR); + ASSERT_EQ(CFE_SB_WriteRtgInfo("RoutingTstFile"), CFE_SB_FILE_IO_ERR); EVTCNT(9); @@ -629,39 +641,39 @@ void Test_SB_Cmds_RoutingInfoWriteFail(void) EVTSENT(CFE_SB_FILEWRITE_ERR_EID); - TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe)); + TEARDOWN(CFE_SB_DeletePipe(CFE_SB_Global.CmdPipe)); } /* end Test_SB_Cmds_RoutingInfoWriteFail */ /* -** Test send pipe information command using the default file name +** Test write pipe information command using the default file name */ void Test_SB_Cmds_PipeInfoDef(void) { union { - CFE_SB_Buffer_t SBBuf; - CFE_SB_SendPipeInfoCmd_t Cmd; - } SendPipeInfo; + CFE_SB_Buffer_t SBBuf; + CFE_SB_WritePipeInfoCmd_t Cmd; + } WritePipeInfo; CFE_SB_PipeId_t PipeId1; CFE_SB_PipeId_t PipeId2; CFE_SB_PipeId_t PipeId3; uint16 PipeDepth = 10; - CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_PIPE_INFO_CC; + CFE_MSG_FcnCode_t FcnCode = CFE_SB_WRITE_PIPE_INFO_CC; CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID); - CFE_MSG_Size_t Size = sizeof(SendPipeInfo.Cmd); + CFE_MSG_Size_t Size = sizeof(WritePipeInfo.Cmd); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - SendPipeInfo.Cmd.Payload.Filename[0] = '\0'; + WritePipeInfo.Cmd.Payload.Filename[0] = '\0'; /* Create some pipe info */ SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); SETUP(CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3")); - CFE_SB_ProcessCmdPipePkt(&SendPipeInfo.SBBuf); + CFE_SB_ProcessCmdPipePkt(&WritePipeInfo.SBBuf); EVTCNT(4); @@ -675,27 +687,27 @@ void Test_SB_Cmds_PipeInfoDef(void) } /* end Test_SB_Cmds_PipeInfoDef */ /* -** Test send pipe information command using a specified file name +** Test write pipe information command using a specified file name */ void Test_SB_Cmds_PipeInfoSpec(void) { union { - CFE_SB_Buffer_t SBBuf; - CFE_SB_SendPipeInfoCmd_t Cmd; - } SendPipeInfo; - CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_PIPE_INFO_CC; + CFE_SB_Buffer_t SBBuf; + CFE_SB_WritePipeInfoCmd_t Cmd; + } WritePipeInfo; + CFE_MSG_FcnCode_t FcnCode = CFE_SB_WRITE_PIPE_INFO_CC; CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID); - CFE_MSG_Size_t Size = sizeof(SendPipeInfo.Cmd); + CFE_MSG_Size_t Size = sizeof(WritePipeInfo.Cmd); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - strncpy(SendPipeInfo.Cmd.Payload.Filename, "PipeTstFile", - sizeof(SendPipeInfo.Cmd.Payload.Filename) - 1); - SendPipeInfo.Cmd.Payload.Filename[sizeof(SendPipeInfo.Cmd.Payload.Filename) - 1] = '\0'; + strncpy(WritePipeInfo.Cmd.Payload.Filename, "PipeTstFile", + sizeof(WritePipeInfo.Cmd.Payload.Filename) - 1); + WritePipeInfo.Cmd.Payload.Filename[sizeof(WritePipeInfo.Cmd.Payload.Filename) - 1] = '\0'; - CFE_SB_ProcessCmdPipePkt(&SendPipeInfo.SBBuf); + CFE_SB_ProcessCmdPipePkt(&WritePipeInfo.SBBuf); EVTCNT(1); @@ -704,12 +716,12 @@ void Test_SB_Cmds_PipeInfoSpec(void) } /* end Test_SB_Cmds_PipeInfoSpec */ /* -** Test send pipe information command with a file creation failure +** Test write pipe information command with a file creation failure */ void Test_SB_Cmds_PipeInfoCreateFail(void) { UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); - ASSERT_EQ(CFE_SB_SendPipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR); + ASSERT_EQ(CFE_SB_WritePipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR); EVTCNT(1); @@ -718,12 +730,12 @@ void Test_SB_Cmds_PipeInfoCreateFail(void) } /* end Test_SB_Cmds_PipeInfoCreateFail */ /* -** Test send pipe information command with a file header write failure +** Test write pipe information command with a file header write failure */ void Test_SB_Cmds_PipeInfoHdrFail(void) { UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1); - ASSERT_EQ(CFE_SB_SendPipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR); + ASSERT_EQ(CFE_SB_WritePipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR); EVTCNT(1); @@ -732,7 +744,7 @@ void Test_SB_Cmds_PipeInfoHdrFail(void) } /* end Test_SB_Cmds_PipeInfoHdrFail */ /* -** Test send pipe information command with a file write failure on +** Test write pipe information command with a file write failure on ** the second write */ void Test_SB_Cmds_PipeInfoWriteFail(void) @@ -747,7 +759,7 @@ void Test_SB_Cmds_PipeInfoWriteFail(void) SETUP(CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3")); UT_SetDeferredRetcode(UT_KEY(OS_write), 2, -1); - ASSERT_EQ(CFE_SB_SendPipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR); + ASSERT_EQ(CFE_SB_WritePipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR); EVTCNT(4); @@ -762,15 +774,15 @@ void Test_SB_Cmds_PipeInfoWriteFail(void) } /* end Test_SB_Cmds_PipeInfoWriteFail */ /* -** Test send map information command using the default file name +** Test write map information command using the default file name */ void Test_SB_Cmds_MapInfoDef(void) { union { - CFE_SB_Buffer_t SBBuf; - CFE_SB_SendMapInfoCmd_t Cmd; - } SendMapInfo; + CFE_SB_Buffer_t SBBuf; + CFE_SB_WriteMapInfoCmd_t Cmd; + } WriteMapInfo; CFE_SB_PipeId_t PipeId1; CFE_SB_PipeId_t PipeId2; CFE_SB_PipeId_t PipeId3; @@ -781,14 +793,14 @@ void Test_SB_Cmds_MapInfoDef(void) CFE_SB_MsgId_t MsgId4 = SB_UT_TLM_MID5; CFE_SB_MsgId_t MsgId5 = SB_UT_TLM_MID6; uint16 PipeDepth = 10; - CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_MAP_INFO_CC; + CFE_MSG_FcnCode_t FcnCode = CFE_SB_WRITE_MAP_INFO_CC; CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID); - CFE_MSG_Size_t Size = sizeof(SendMapInfo.Cmd); + CFE_MSG_Size_t Size = sizeof(WriteMapInfo.Cmd); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - SendMapInfo.Cmd.Payload.Filename[0] = '\0'; + WriteMapInfo.Cmd.Payload.Filename[0] = '\0'; /* Create some map info */ SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); @@ -802,7 +814,7 @@ void Test_SB_Cmds_MapInfoDef(void) SETUP(CFE_SB_Subscribe(MsgId4, PipeId3)); SETUP(CFE_SB_Subscribe(MsgId5, PipeId2)); - CFE_SB_ProcessCmdPipePkt(&SendMapInfo.SBBuf); + CFE_SB_ProcessCmdPipePkt(&WriteMapInfo.SBBuf); EVTCNT(11); @@ -819,27 +831,27 @@ void Test_SB_Cmds_MapInfoDef(void) } /* end Test_SB_Cmds_MapInfoDef */ /* -** Test send map information command using a specified file name +** Test write map information command using a specified file name */ void Test_SB_Cmds_MapInfoSpec(void) { union { - CFE_SB_Buffer_t SBBuf; - CFE_SB_SendMapInfoCmd_t Cmd; - } SendMapInfo; - CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_MAP_INFO_CC; + CFE_SB_Buffer_t SBBuf; + CFE_SB_WriteMapInfoCmd_t Cmd; + } WriteMapInfo; + CFE_MSG_FcnCode_t FcnCode = CFE_SB_WRITE_MAP_INFO_CC; CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID); - CFE_MSG_Size_t Size = sizeof(SendMapInfo.Cmd); + CFE_MSG_Size_t Size = sizeof(WriteMapInfo.Cmd); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - strncpy(SendMapInfo.Cmd.Payload.Filename, "MapTstFile", - sizeof(SendMapInfo.Cmd.Payload.Filename) - 1); - SendMapInfo.Cmd.Payload.Filename[sizeof(SendMapInfo.Cmd.Payload.Filename) - 1] = '\0'; + strncpy(WriteMapInfo.Cmd.Payload.Filename, "MapTstFile", + sizeof(WriteMapInfo.Cmd.Payload.Filename) - 1); + WriteMapInfo.Cmd.Payload.Filename[sizeof(WriteMapInfo.Cmd.Payload.Filename) - 1] = '\0'; - CFE_SB_ProcessCmdPipePkt(&SendMapInfo.SBBuf); + CFE_SB_ProcessCmdPipePkt(&WriteMapInfo.SBBuf); EVTCNT(1); @@ -848,12 +860,12 @@ void Test_SB_Cmds_MapInfoSpec(void) } /* end Test_SB_Cmds_MapInfoSpec */ /* -** Test send map information command with a file creation failure +** Test write map information command with a file creation failure */ void Test_SB_Cmds_MapInfoCreateFail(void) { UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); - ASSERT_EQ(CFE_SB_SendMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR); + ASSERT_EQ(CFE_SB_WriteMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR); EVTCNT(1); @@ -862,12 +874,12 @@ void Test_SB_Cmds_MapInfoCreateFail(void) } /* end Test_SB_Cmds_MapInfoCreateFail */ /* -** Test send map information command with a file header write failure +** Test write map information command with a file header write failure */ void Test_SB_Cmds_MapInfoHdrFail(void) { UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1); - ASSERT_EQ(CFE_SB_SendMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR); + ASSERT_EQ(CFE_SB_WriteMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR); EVTCNT(1); @@ -876,7 +888,7 @@ void Test_SB_Cmds_MapInfoHdrFail(void) } /* end Test_SB_Cmds_MapInfoHdrFail */ /* -** Test send map information command with a file write failure on +** Test write map information command with a file write failure on ** the second write */ void Test_SB_Cmds_MapInfoWriteFail(void) @@ -905,7 +917,7 @@ void Test_SB_Cmds_MapInfoWriteFail(void) SETUP(CFE_SB_Subscribe(MsgId5, PipeId2)); UT_SetDeferredRetcode(UT_KEY(OS_write), 2, -1); - ASSERT_EQ(CFE_SB_SendMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR); + ASSERT_EQ(CFE_SB_WriteMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR); EVTCNT(11); @@ -1274,7 +1286,7 @@ void Test_SB_Cmds_SendHK(void) /* For internal TransmitMsg call */ MsgIdCmd = CFE_SB_ValueToMsgId(CFE_SB_HK_TLM_MID); - Size = sizeof(CFE_SB.HKTlmMsg); + Size = sizeof(CFE_SB_Global.HKTlmMsg); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgIdCmd, sizeof(MsgIdCmd), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); @@ -1338,7 +1350,7 @@ void Test_SB_Cmds_SendPrevSubs(void) /* For 3 internal TransmitMsg calls */ MsgIdCmd = CFE_SB_ValueToMsgId(CFE_SB_ALLSUBS_TLM_MID); - Size = sizeof(CFE_SB.PrevSubMsg); + Size = sizeof(CFE_SB_Global.PrevSubMsg); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgIdCmd, sizeof(MsgIdCmd), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgIdCmd, sizeof(MsgIdCmd), false); @@ -1380,7 +1392,7 @@ void Test_SB_Cmds_SendPrevSubs(void) /* For 3 internal TransmitMsg calls */ MsgIdCmd = CFE_SB_ValueToMsgId(CFE_SB_ALLSUBS_TLM_MID); - Size = sizeof(CFE_SB.PrevSubMsg); + Size = sizeof(CFE_SB_Global.PrevSubMsg); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgIdCmd, sizeof(MsgIdCmd), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgIdCmd, sizeof(MsgIdCmd), false); @@ -1486,28 +1498,6 @@ void Test_SB_Cmds_CmdUnexpCmdCode(void) } /* end Test_SB_Cmds_UnexpCmdCode */ -/* -** Test command handler response to an invalid command code -*/ -void Test_SB_Cmds_SubRptUnexpCmdCode(void) -{ - CFE_MSG_FcnCode_t FcnCode = 99; - CFE_SB_MsgId_t MsgIdCmd = CFE_SB_ValueToMsgId(CFE_SB_SUB_RPT_CTRL_MID); - - /* Second GetFcnCode is for reporting */ - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgIdCmd, sizeof(MsgIdCmd), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - - /* Use a command code known to be invalid */ - CFE_SB_ProcessCmdPipePkt((CFE_SB_Buffer_t *)NULL); - - EVTCNT(1); - - EVTSENT(CFE_SB_BAD_CMD_CODE_EID); - -} /* end Test_SB_Cmds_UnexpCmdCode */ - /* ** Test command handler response to an incorrect length */ @@ -1631,20 +1621,17 @@ void Test_CreatePipe_NullPtr(void) */ void Test_CreatePipe_ValPipeDepth(void) { - CFE_SB_PipeId_t PipeIdReturned[3]; + CFE_SB_PipeId_t PipeIdReturned[2]; - ASSERT(CFE_SB_CreatePipe(&PipeIdReturned[0], 99, "TestPipe99")); - ASSERT(CFE_SB_CreatePipe(&PipeIdReturned[1], 255, "TestPipe255")); - ASSERT(CFE_SB_CreatePipe(&PipeIdReturned[2], - CFE_PLATFORM_SB_MAX_PIPE_DEPTH, "TestPipeMaxDepth")); + ASSERT(CFE_SB_CreatePipe(&PipeIdReturned[0], 1, "TestPipeMin")); + ASSERT(CFE_SB_CreatePipe(&PipeIdReturned[1], OS_QUEUE_MAX_DEPTH, "TestPipeMax")); - EVTCNT(3); + EVTCNT(2); EVTSENT(CFE_SB_PIPE_ADDED_EID); TEARDOWN(CFE_SB_DeletePipe(PipeIdReturned[0])); TEARDOWN(CFE_SB_DeletePipe(PipeIdReturned[1])); - TEARDOWN(CFE_SB_DeletePipe(PipeIdReturned[2])); } /* end Test_CreatePipe_ValPipeDepth */ @@ -1659,7 +1646,7 @@ void Test_CreatePipe_InvalPipeDepth(void) ASSERT_EQ(CFE_SB_CreatePipe(&PipeIdReturned[0], 0, "TestPipe1"), CFE_SB_BAD_ARGUMENT); UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 1, OS_SUCCESS); ASSERT_EQ(CFE_SB_CreatePipe(&PipeIdReturned[1], - CFE_PLATFORM_SB_MAX_PIPE_DEPTH + 1, "TestPipeMaxDepPlus1"), CFE_SB_BAD_ARGUMENT); + OS_QUEUE_MAX_DEPTH + 1, "TestPipeMaxDepPlus1"), CFE_SB_BAD_ARGUMENT); UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 1, OS_SUCCESS); ASSERT_EQ(CFE_SB_CreatePipe(&PipeIdReturned[2], 0xffff, "TestPipeffff"), CFE_SB_BAD_ARGUMENT); @@ -1682,7 +1669,7 @@ void Test_CreatePipe_MaxPipes(void) /* Create maximum number of pipes + 1. Only one 'create pipe' failure * expected */ - UT_SetDeferredRetcode(UT_KEY(CFE_ES_ResourceID_ToIndex), 1+CFE_PLATFORM_SB_MAX_PIPES, -1); + UT_SetDeferredRetcode(UT_KEY(CFE_ResourceId_ToIndex), 1+CFE_PLATFORM_SB_MAX_PIPES, -1); for (i = 0; i < (CFE_PLATFORM_SB_MAX_PIPES + 1); i++) { snprintf(PipeName, sizeof(PipeName), "TestPipe%ld", (long) i); @@ -1705,6 +1692,15 @@ void Test_CreatePipe_MaxPipes(void) TEARDOWN(CFE_SB_DeletePipe(PipeIdReturned[i])); } + /* + * Also validate the CFE_SB_CheckPipeDescSlotUsed() helper function in this test, + * as it is used to determine when max pipes has been hit. + */ + CFE_SB_Global.PipeTbl[1].PipeId = CFE_SB_PIPEID_C(UT_SB_MakePipeIdForIndex(1)); + CFE_SB_Global.PipeTbl[2].PipeId = CFE_SB_INVALID_PIPE; + ASSERT_TRUE(CFE_SB_CheckPipeDescSlotUsed(UT_SB_MakePipeIdForIndex(1))); + ASSERT_TRUE(!CFE_SB_CheckPipeDescSlotUsed(UT_SB_MakePipeIdForIndex(2))); + } /* end Test_CreatePipe_MaxPipes */ /* @@ -1729,7 +1725,7 @@ void Test_CreatePipe_SamePipeName(void) /* Second call to CFE_SB_CreatePipe with same PipeName should fail */ ASSERT_EQ(CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName), CFE_SB_PIPE_CR_ERR); - ASSERT_TRUE(CFE_ES_ResourceID_Equal(PipeId, FirstPipeId)); + ASSERT_TRUE(CFE_RESOURCEID_TEST_EQUAL(PipeId, FirstPipeId)); EVTCNT(2); @@ -1818,7 +1814,7 @@ void Test_DeletePipe_InvalidPipeOwner(void) { CFE_SB_PipeId_t PipedId; CFE_SB_PipeD_t *PipeDscPtr; - CFE_ES_ResourceID_t RealOwner; + CFE_ES_AppId_t RealOwner; uint16 PipeDepth = 10; SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); @@ -1828,7 +1824,7 @@ void Test_DeletePipe_InvalidPipeOwner(void) RealOwner = PipeDscPtr->AppId; /* Choose a value that is sure not to be owner */ - PipeDscPtr->AppId = UT_SB_ResourceID_Modify(RealOwner, 1); + PipeDscPtr->AppId = UT_SB_AppID_Modify(RealOwner, 1); ASSERT_EQ(CFE_SB_DeletePipe(PipedId), CFE_SB_BAD_ARGUMENT); EVTCNT(2); @@ -1847,7 +1843,7 @@ void Test_DeletePipe_InvalidPipeOwner(void) void Test_DeletePipe_WithAppid(void) { CFE_SB_PipeId_t PipedId; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; uint16 PipeDepth = 10; SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); @@ -2001,8 +1997,8 @@ void Test_GetPipeIdByName(void) UT_SetDataBuffer( UT_KEY(OS_QueueGetIdByName), - &(CFE_SB.PipeTbl[0].SysQueueId), - sizeof(CFE_SB.PipeTbl[0].SysQueueId), + &(CFE_SB_Global.PipeTbl[0].SysQueueId), + sizeof(CFE_SB_Global.PipeTbl[0].SysQueueId), false); ASSERT(CFE_SB_GetPipeIdByName(&PipeIdOut, "TestPipe1")); @@ -2031,14 +2027,14 @@ void Test_SetPipeOpts_NotOwner(void) { CFE_SB_PipeId_t PipeID; CFE_SB_PipeD_t *PipeDscPtr; - CFE_ES_ResourceID_t OrigOwner; + CFE_ES_AppId_t OrigOwner; SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); PipeDscPtr = CFE_SB_LocatePipeDescByID(PipeID); OrigOwner = PipeDscPtr->AppId; - PipeDscPtr->AppId = UT_SB_ResourceID_Modify(OrigOwner, 1); + PipeDscPtr->AppId = UT_SB_AppID_Modify(OrigOwner, 1); ASSERT_EQ(CFE_SB_SetPipeOpts(PipeID, 0), CFE_SB_BAD_ARGUMENT); @@ -2377,7 +2373,7 @@ void Test_Subscribe_SendPrevSubs(void) /* For internal TransmitMsg call */ MsgIdCmd = CFE_SB_ValueToMsgId(CFE_SB_ALLSUBS_TLM_MID); - Size = sizeof(CFE_SB.PrevSubMsg); + Size = sizeof(CFE_SB_Global.PrevSubMsg); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgIdCmd, sizeof(MsgIdCmd), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); @@ -2439,7 +2435,7 @@ void Test_Subscribe_SubscriptionReporting(void) SETUP(CFE_SB_Unsubscribe(MsgId, PipeId)); /* Subscribe to message: LOCAL */ - ASSERT(CFE_SB_SubscribeFull(MsgId, PipeId, Quality, CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT, CFE_SB_LOCAL)); + ASSERT(CFE_SB_SubscribeFull(MsgId, PipeId, Quality, CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT, CFE_SB_MSG_LOCAL)); EVTCNT(6); @@ -2461,7 +2457,7 @@ void Test_Subscribe_InvalidPipeOwner(void) CFE_SB_PipeD_t *PipeDscPtr; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 10; - CFE_ES_ResourceID_t RealOwner; + CFE_ES_AppId_t RealOwner; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); @@ -2470,7 +2466,7 @@ void Test_Subscribe_InvalidPipeOwner(void) RealOwner = PipeDscPtr->AppId; /* Choose a value that is sure not to be owner */ - PipeDscPtr->AppId = UT_SB_ResourceID_Modify(RealOwner, 1); + PipeDscPtr->AppId = UT_SB_AppID_Modify(RealOwner, 1); CFE_SB_Subscribe(MsgId, PipeId); EVTCNT(3); @@ -2555,7 +2551,7 @@ void Test_Unsubscribe_Local(void) void Test_Unsubscribe_InvalParam(void) { CFE_SB_PipeId_t TestPipe; - CFE_ES_ResourceID_t CallerId; + CFE_ES_AppId_t CallerId; CFE_SB_PipeD_t *PipeDscPtr; uint16 PipeDepth = 50; CFE_SB_PipeId_t SavedPipeId; @@ -2569,7 +2565,7 @@ void Test_Unsubscribe_InvalParam(void) ASSERT(CFE_ES_GetAppID(&CallerId)); /* Perform test using a bad scope value */ - ASSERT_EQ(CFE_SB_UnsubscribeFull(SB_UT_FIRST_VALID_MID, TestPipe, CFE_SB_LOCAL + 1, CallerId), CFE_SB_BAD_ARGUMENT); + ASSERT_EQ(CFE_SB_UnsubscribeFull(SB_UT_FIRST_VALID_MID, TestPipe, CFE_SB_MSG_LOCAL + 1, CallerId), CFE_SB_BAD_ARGUMENT); /* Perform test using an invalid pipe ID for branch path coverage. * This situation cannot happen in normal circumstances since the @@ -2651,7 +2647,7 @@ void Test_Unsubscribe_InvalidPipeOwner(void) CFE_SB_PipeId_t PipeId; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; CFE_SB_PipeD_t *PipeDscPtr; - CFE_ES_ResourceID_t RealOwner; + CFE_ES_AppId_t RealOwner; uint16 PipeDepth = 10; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); @@ -2663,7 +2659,7 @@ void Test_Unsubscribe_InvalidPipeOwner(void) RealOwner = PipeDscPtr->AppId; /* Choose a value that is sure not be owner */ - PipeDscPtr->AppId = UT_SB_ResourceID_Modify(RealOwner, 1); + PipeDscPtr->AppId = UT_SB_AppID_Modify(RealOwner, 1); ASSERT_EQ(CFE_SB_Unsubscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); EVTCNT(3); @@ -3034,7 +3030,7 @@ void Test_TransmitMsg_MsgLimitExceeded(void) SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "MsgLimTestPipe")); /* Set maximum allowed messages on the pipe at one time to 1 */ - CFE_SB_SubscribeEx(MsgId, PipeId, CFE_SB_Default_Qos, 1); + CFE_SB_SubscribeEx(MsgId, PipeId, CFE_SB_DEFAULT_QOS, 1); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); @@ -3124,19 +3120,19 @@ void Test_TransmitMsg_ZeroCopyGetPtr(void) /* Increase the peak memory and buffers in use above the expected values in * order to exercise branch paths */ - CFE_SB.StatTlmMsg.Payload.MemInUse = 0; - CFE_SB.StatTlmMsg.Payload.PeakMemInUse = sizeof(CFE_SB_ZeroCopyD_t) + MsgSize + + CFE_SB_Global.StatTlmMsg.Payload.MemInUse = 0; + CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse = sizeof(CFE_SB_ZeroCopyD_t) + MsgSize + sizeof(CFE_SB_BufferD_t) + 1; - CFE_SB.StatTlmMsg.Payload.PeakSBBuffersInUse = - CFE_SB.StatTlmMsg.Payload.SBBuffersInUse + 2; + CFE_SB_Global.StatTlmMsg.Payload.PeakSBBuffersInUse = + CFE_SB_Global.StatTlmMsg.Payload.SBBuffersInUse + 2; ASSERT_TRUE((cpuaddr) CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl) != (cpuaddr) NULL); - ASSERT_EQ(CFE_SB.StatTlmMsg.Payload.PeakMemInUse, sizeof(CFE_SB_ZeroCopyD_t) + MsgSize + + ASSERT_EQ(CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse, sizeof(CFE_SB_ZeroCopyD_t) + MsgSize + sizeof(CFE_SB_BufferD_t) + 1); - ASSERT_EQ(CFE_SB.StatTlmMsg.Payload.MemInUse, sizeof(CFE_SB_ZeroCopyD_t) + MsgSize + + ASSERT_EQ(CFE_SB_Global.StatTlmMsg.Payload.MemInUse, sizeof(CFE_SB_ZeroCopyD_t) + MsgSize + sizeof(CFE_SB_BufferD_t)); - ASSERT_EQ(CFE_SB.StatTlmMsg.Payload.PeakSBBuffersInUse, CFE_SB.StatTlmMsg.Payload.SBBuffersInUse + 1); + ASSERT_EQ(CFE_SB_Global.StatTlmMsg.Payload.PeakSBBuffersInUse, CFE_SB_Global.StatTlmMsg.Payload.SBBuffersInUse + 1); EVTCNT(0); @@ -3572,7 +3568,7 @@ void Test_CleanupApp_API(void) CFE_SB_PipeId_t PipeId; CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl = 0; uint16 PipeDepth = 50; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; CFE_ES_GetAppID(&AppID); @@ -3581,20 +3577,20 @@ void Test_CleanupApp_API(void) CFE_SB_ZeroCopyGetPtr(PipeDepth, &ZeroCpyBufHndl); /* Set second application ID to provide complete branch path coverage */ - CFE_SB.PipeTbl[1].PipeId = SB_UT_PIPEID_1; - CFE_SB.PipeTbl[1].AppId = AppID; + CFE_SB_Global.PipeTbl[1].PipeId = SB_UT_PIPEID_1; + CFE_SB_Global.PipeTbl[1].AppId = AppID; - ASSERT_TRUE(CFE_SB.ZeroCopyTail != NULL); + ASSERT_TRUE(CFE_SB_Global.ZeroCopyTail != NULL); /* Attempt with a bad application ID first in order to get full branch path * coverage in CFE_SB_ZeroCopyReleaseAppId */ - CFE_SB_CleanUpApp(CFE_ES_RESOURCEID_UNDEFINED); + CFE_SB_CleanUpApp(CFE_ES_APPID_UNDEFINED); /* Attempt again with a valid application ID */ CFE_SB_CleanUpApp(AppID); - ASSERT_TRUE(CFE_SB.ZeroCopyTail == NULL); + ASSERT_TRUE(CFE_SB_Global.ZeroCopyTail == NULL); EVTCNT(2); @@ -3851,14 +3847,14 @@ void Test_OS_MutSem_ErrLogic(void) */ void Test_ReqToSendEvent_ErrLogic(void) { - CFE_ES_ResourceID_t TaskId; + CFE_ES_TaskId_t TaskId; uint32 Bit = 5; /* Clear task bits, then call function, which should set the bit for * the specified task */ CFE_ES_GetTaskID(&TaskId); - CFE_SB.StopRecurseFlags[0] = 0x0000; + CFE_SB_Global.StopRecurseFlags[0] = 0x0000; ASSERT_EQ(CFE_SB_RequestToSendEvent(TaskId, Bit), CFE_SB_GRANTED); /* Call the function a second time; the result should indicate that the @@ -3891,18 +3887,18 @@ void Test_CFE_SB_Buffers(void) CFE_SB_BufferD_t *bd; - CFE_SB.StatTlmMsg.Payload.MemInUse = 0; - CFE_SB.StatTlmMsg.Payload.PeakMemInUse = sizeof(CFE_SB_BufferD_t) * 4; + CFE_SB_Global.StatTlmMsg.Payload.MemInUse = 0; + CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse = sizeof(CFE_SB_BufferD_t) * 4; bd = CFE_SB_GetBufferFromPool(SB_UT_FIRST_VALID_MID, 0); - ASSERT_EQ(CFE_SB.StatTlmMsg.Payload.PeakMemInUse, sizeof(CFE_SB_BufferD_t) * 4); + ASSERT_EQ(CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse, sizeof(CFE_SB_BufferD_t) * 4); EVTCNT(0); - ExpRtn = CFE_SB.StatTlmMsg.Payload.SBBuffersInUse; + ExpRtn = CFE_SB_Global.StatTlmMsg.Payload.SBBuffersInUse; UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1); CFE_SB_ReturnBufferToPool(bd); - ASSERT_EQ(CFE_SB.StatTlmMsg.Payload.SBBuffersInUse, ExpRtn); + ASSERT_EQ(CFE_SB_Global.StatTlmMsg.Payload.SBBuffersInUse, ExpRtn); EVTCNT(0); @@ -3913,10 +3909,10 @@ void Test_CFE_SB_Buffers(void) EVTCNT(0); UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1); - CFE_SB.StatTlmMsg.Payload.MemInUse = 0; + CFE_SB_Global.StatTlmMsg.Payload.MemInUse = 0; CFE_SB_PutDestinationBlk((CFE_SB_DestinationD_t *) bd); - ASSERT_EQ(CFE_SB.StatTlmMsg.Payload.MemInUse, 0); + ASSERT_EQ(CFE_SB_Global.StatTlmMsg.Payload.MemInUse, 0); EVTCNT(0); @@ -3930,8 +3926,7 @@ void Test_CFE_SB_BadPipeInfo(void) CFE_SB_PipeId_t PipeId; CFE_SB_PipeD_t *PipeDscPtr; uint16 PipeDepth = 10; - CFE_SB_Qos_t CFE_SB_Default_Qos; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe1")); @@ -3946,7 +3941,7 @@ void Test_CFE_SB_BadPipeInfo(void) /* Reset the pipe ID and delete the pipe */ PipeDscPtr->PipeId = PipeId; - ASSERT_EQ(CFE_SB_SubscribeFull(SB_UT_FIRST_VALID_MID , PipeId, CFE_SB_Default_Qos, + ASSERT_EQ(CFE_SB_SubscribeFull(SB_UT_FIRST_VALID_MID , PipeId, CFE_SB_DEFAULT_QOS, CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT, 2), CFE_SB_BAD_ARGUMENT); EVTCNT(4); @@ -3975,7 +3970,7 @@ void Test_SB_TransmitMsgPaths_Nominal(void) /* For internal send message call */ MsgId = CFE_SB_ValueToMsgId(CFE_SB_HK_TLM_MID); - Size = sizeof(CFE_SB.HKTlmMsg); + Size = sizeof(CFE_SB_Global.HKTlmMsg); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); @@ -3984,21 +3979,21 @@ void Test_SB_TransmitMsgPaths_Nominal(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); /* Repress sending the no subscriptions event and process request */ - CFE_SB.HKTlmMsg.Payload.NoSubscribersCounter = 0; - CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_SEND_NO_SUBS_EID_BIT); + CFE_SB_Global.HKTlmMsg.Payload.NoSubscribersCounter = 0; + CFE_SB_Global.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_SEND_NO_SUBS_EID_BIT); CFE_SB_ProcessCmdPipePkt(&Housekeeping.SBBuf); /* The no subs event should not be in history but count should increment */ ASSERT_TRUE(!UT_EventIsInHistory(CFE_SB_SEND_NO_SUBS_EID)); - ASSERT_EQ(CFE_SB.HKTlmMsg.Payload.NoSubscribersCounter, 1); + ASSERT_EQ(CFE_SB_Global.HKTlmMsg.Payload.NoSubscribersCounter, 1); /* Repress get buffer error */ - CFE_SB.HKTlmMsg.Payload.MsgSendErrorCounter = 0; - CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_GET_BUF_ERR_EID_BIT); + CFE_SB_Global.HKTlmMsg.Payload.MsgSendErrorCounter = 0; + CFE_SB_Global.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_GET_BUF_ERR_EID_BIT); /* For internal send message call */ MsgId = CFE_SB_ValueToMsgId(CFE_SB_HK_TLM_MID); - Size = sizeof(CFE_SB.HKTlmMsg); + Size = sizeof(CFE_SB_Global.HKTlmMsg); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); @@ -4008,13 +4003,13 @@ void Test_SB_TransmitMsgPaths_Nominal(void) UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 1, CFE_ES_ERR_MEM_BLOCK_SIZE); CFE_SB_ProcessCmdPipePkt(&Housekeeping.SBBuf); - ASSERT_EQ(CFE_SB.HKTlmMsg.Payload.MsgSendErrorCounter, 0); + ASSERT_EQ(CFE_SB_Global.HKTlmMsg.Payload.MsgSendErrorCounter, 0); ASSERT_TRUE(!UT_EventIsInHistory(CFE_SB_GET_BUF_ERR_EID)); EVTCNT(0); - CFE_SB.StopRecurseFlags[1] = 0; + CFE_SB_Global.StopRecurseFlags[1] = 0; /* Create a message ID with the command bit set and disable reporting */ MsgId = SB_UT_CMD_MID; @@ -4050,7 +4045,7 @@ void Test_SB_TransmitMsgPaths_LimitErr(void) SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "MsgLimTestPipe")); /* Set maximum allowed messages on the pipe at one time to 1 */ - SETUP(CFE_SB_SubscribeEx(MsgId, PipeId, CFE_SB_Default_Qos, 1)); + SETUP(CFE_SB_SubscribeEx(MsgId, PipeId, CFE_SB_DEFAULT_QOS, 1)); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); @@ -4063,9 +4058,9 @@ void Test_SB_TransmitMsgPaths_LimitErr(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false); - CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_MSGID_LIM_ERR_EID_BIT); + CFE_SB_Global.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_MSGID_LIM_ERR_EID_BIT); ASSERT(CFE_SB_TransmitMsg(&TlmPkt.Hdr.Msg, true)); - CFE_SB.StopRecurseFlags[1] = 0; + CFE_SB_Global.StopRecurseFlags[1] = 0; ASSERT_TRUE(!UT_EventIsInHistory(CFE_SB_MSGID_LIM_ERR_EID)); @@ -4101,9 +4096,9 @@ void Test_SB_TransmitMsgPaths_FullErr(void) /* Tell the QueuePut stub to return OS_QUEUE_FULL on its next call */ UT_SetDeferredRetcode(UT_KEY(OS_QueuePut), 1, OS_QUEUE_FULL); - CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_Q_FULL_ERR_EID_BIT); + CFE_SB_Global.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_Q_FULL_ERR_EID_BIT); ASSERT(CFE_SB_TransmitMsg(&TlmPkt.Hdr.Msg, true)); - CFE_SB.StopRecurseFlags[1] = 0; + CFE_SB_Global.StopRecurseFlags[1] = 0; ASSERT_TRUE(!UT_EventIsInHistory(CFE_SB_Q_FULL_ERR_EID_BIT)); @@ -4131,9 +4126,9 @@ void Test_SB_TransmitMsgPaths_WriteErr(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false); - CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_Q_WR_ERR_EID_BIT); + CFE_SB_Global.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_Q_WR_ERR_EID_BIT); ASSERT(CFE_SB_TransmitMsg(&TlmPkt.Hdr.Msg, true)); - CFE_SB.StopRecurseFlags[1] = 0; + CFE_SB_Global.StopRecurseFlags[1] = 0; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); diff --git a/fsw/cfe-core/unit-test/sb_UT.h b/fsw/cfe-core/unit-test/sb_UT.h index d2acfb22b..7ebff942d 100644 --- a/fsw/cfe-core/unit-test/sb_UT.h +++ b/fsw/cfe-core/unit-test/sb_UT.h @@ -1088,22 +1088,6 @@ void Test_SB_Cmds_SubRptOff(void); ******************************************************************************/ void Test_SB_Cmds_CmdUnexpCmdCode(void); -/*****************************************************************************/ -/** -** \brief Test command handler response to an invalid command code -** -** \par Description -** This function tests the command handler response to an invalid -** command code in the CFE_SB_SUB_RPT_CTRL_MID handler -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -******************************************************************************/ -void Test_SB_Cmds_SubRptUnexpCmdCode(void); - /*****************************************************************************/ /** ** \brief Test command handler response to a bad message length diff --git a/fsw/cfe-core/unit-test/tbl_UT.c b/fsw/cfe-core/unit-test/tbl_UT.c index f27360e69..a26d524c5 100644 --- a/fsw/cfe-core/unit-test/tbl_UT.c +++ b/fsw/cfe-core/unit-test/tbl_UT.c @@ -39,12 +39,13 @@ ** Includes */ #include "tbl_UT.h" +#include "private/cfe_core_resourceid_basevalues.h" /* ** External global variables */ -extern CFE_TBL_TaskData_t CFE_TBL_TaskData; +extern CFE_TBL_Global_t CFE_TBL_Global; /* ** Global variables @@ -55,10 +56,10 @@ CFE_TBL_Handle_t App2TblHandle1; CFE_TBL_Handle_t App2TblHandle2; CFE_TBL_Handle_t ArrayOfHandles[2]; -static const CFE_ES_ResourceID_t UT_TBL_APPID_1 = { 0x02010001 }; -static const CFE_ES_ResourceID_t UT_TBL_APPID_2 = { 0x02010002 }; -static const CFE_ES_ResourceID_t UT_TBL_APPID_3 = { 0x02010003 }; -static const CFE_ES_ResourceID_t UT_TBL_APPID_10 = { 0x0201000A }; +#define UT_TBL_APPID_1 CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 1)) +#define UT_TBL_APPID_2 CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 2)) +#define UT_TBL_APPID_3 CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 3)) +#define UT_TBL_APPID_10 CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 10)) void *Tbl1Ptr = NULL; void *Tbl2Ptr = NULL; @@ -167,9 +168,9 @@ void UT_InitializeTableRegistryNames() for (i = 0; i < CFE_PLATFORM_TBL_MAX_NUM_TABLES; i++) { - snprintf(CFE_TBL_TaskData.Registry[i].Name, + snprintf(CFE_TBL_Global.Registry[i].Name, CFE_TBL_MAX_FULL_NAME_LEN, "%d", i); - CFE_TBL_TaskData.Registry[i].OwnerAppId = UT_TBL_APPID_2; + CFE_TBL_Global.Registry[i].OwnerAppId = UT_TBL_APPID_2; } } @@ -182,47 +183,47 @@ void UT_ResetTableRegistry(void) for (i = 0; i < CFE_PLATFORM_TBL_MAX_NUM_TABLES; i++) { - CFE_TBL_InitRegistryRecord(&CFE_TBL_TaskData.Registry[i]); + CFE_TBL_InitRegistryRecord(&CFE_TBL_Global.Registry[i]); } /* Initialize the table access descriptors */ for (i = 0; i < CFE_PLATFORM_TBL_MAX_NUM_HANDLES; i++) { - CFE_TBL_TaskData.Handles[i].AppId = CFE_TBL_NOT_OWNED; - CFE_TBL_TaskData.Handles[i].RegIndex = 0; - CFE_TBL_TaskData.Handles[i].PrevLink = CFE_TBL_END_OF_LIST; - CFE_TBL_TaskData.Handles[i].NextLink = CFE_TBL_END_OF_LIST; - CFE_TBL_TaskData.Handles[i].UsedFlag = false; - CFE_TBL_TaskData.Handles[i].LockFlag = false; - CFE_TBL_TaskData.Handles[i].Updated = false; - CFE_TBL_TaskData.Handles[i].BufferIndex = 0; + CFE_TBL_Global.Handles[i].AppId = CFE_TBL_NOT_OWNED; + CFE_TBL_Global.Handles[i].RegIndex = 0; + CFE_TBL_Global.Handles[i].PrevLink = CFE_TBL_END_OF_LIST; + CFE_TBL_Global.Handles[i].NextLink = CFE_TBL_END_OF_LIST; + CFE_TBL_Global.Handles[i].UsedFlag = false; + CFE_TBL_Global.Handles[i].LockFlag = false; + CFE_TBL_Global.Handles[i].Updated = false; + CFE_TBL_Global.Handles[i].BufferIndex = 0; } /* Initialize the table validation results records */ for (i = 0; i < CFE_PLATFORM_TBL_MAX_NUM_VALIDATIONS; i++) { - CFE_TBL_TaskData.ValidationResults[i].State = CFE_TBL_VALIDATION_FREE; - CFE_TBL_TaskData.ValidationResults[i].CrcOfTable = 0; - CFE_TBL_TaskData.ValidationResults[i].Result = 0; - CFE_TBL_TaskData.ValidationResults[i].ActiveBuffer = false; - CFE_TBL_TaskData.ValidationResults[i].TableName[0] = '\0'; + CFE_TBL_Global.ValidationResults[i].State = CFE_TBL_VALIDATION_FREE; + CFE_TBL_Global.ValidationResults[i].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[i].Result = 0; + CFE_TBL_Global.ValidationResults[i].ActiveBuffer = false; + CFE_TBL_Global.ValidationResults[i].TableName[0] = '\0'; } /* Initialize the dump-only table dump control blocks */ for (i = 0; i < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS; i++) { - CFE_TBL_TaskData.DumpControlBlocks[i].State = CFE_TBL_DUMP_FREE; - CFE_TBL_TaskData.DumpControlBlocks[i].DumpBufferPtr = NULL; - CFE_TBL_TaskData.DumpControlBlocks[i].Size = 0; - CFE_TBL_TaskData.DumpControlBlocks[i].TableName[0] = '\0'; + CFE_TBL_Global.DumpControlBlocks[i].State = CFE_TBL_DUMP_FREE; + CFE_TBL_Global.DumpControlBlocks[i].DumpBufferPtr = NULL; + CFE_TBL_Global.DumpControlBlocks[i].Size = 0; + CFE_TBL_Global.DumpControlBlocks[i].TableName[0] = '\0'; /* Free all shared buffers */ - CFE_TBL_TaskData.LoadBuffs[i].Taken = false; + CFE_TBL_Global.LoadBuffs[i].Taken = false; } - CFE_TBL_TaskData.ValidationCounter = 0; - CFE_TBL_TaskData.HkTlmTblRegIndex = CFE_TBL_NOT_FOUND; - CFE_TBL_TaskData.LastTblUpdated = CFE_TBL_NOT_FOUND; + CFE_TBL_Global.ValidationCounter = 0; + CFE_TBL_Global.HkTlmTblRegIndex = CFE_TBL_NOT_FOUND; + CFE_TBL_Global.LastTblUpdated = CFE_TBL_NOT_FOUND; } /* @@ -361,14 +362,14 @@ void Test_CFE_TBL_TaskInit(void) /* Test command pipe messages handler response to other errors */ /* Test command pipe messages handler response to "message type" message */ UT_InitData(); - CFE_TBL_TaskData.CommandCounter = 0; - CFE_TBL_TaskData.CommandErrorCounter = 0; + CFE_TBL_Global.CommandCounter = 0; + CFE_TBL_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TBL_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.NoArgsCmd), UT_TPID_CFE_TBL_INVALID_MID); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TBL_MID_ERR_EID) && - CFE_TBL_TaskData.CommandCounter == 0 && - CFE_TBL_TaskData.CommandErrorCounter == 0, + CFE_TBL_Global.CommandCounter == 0 && + CFE_TBL_Global.CommandErrorCounter == 0, "CFE_TBL_TaskPipe", "'Message' type message"); @@ -378,8 +379,8 @@ void Test_CFE_TBL_TaskInit(void) UT_TPID_CFE_TBL_CMD_RESET_COUNTERS_CC); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TBL_RESET_INF_EID) && - CFE_TBL_TaskData.CommandCounter == 0 && - CFE_TBL_TaskData.CommandErrorCounter == 0, + CFE_TBL_Global.CommandCounter == 0 && + CFE_TBL_Global.CommandErrorCounter == 0, "CFE_TBL_TaskPipe", "'Command' type message"); } @@ -394,7 +395,7 @@ void Test_CFE_TBL_InitData(void) /* This function has only one possible path with no return code */ UT_InitData(); CFE_TBL_InitData(); - ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_Init)), 2); + ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_Init)), 3); } /* @@ -477,7 +478,7 @@ void Test_CFE_TBL_DeleteCDSCmd(void) for (j = CFE_PLATFORM_TBL_MAX_NUM_TABLES; j < k; j++) { - snprintf(CFE_TBL_TaskData.CritReg[j - CFE_PLATFORM_TBL_MAX_NUM_TABLES].Name, + snprintf(CFE_TBL_Global.CritReg[j - CFE_PLATFORM_TBL_MAX_NUM_TABLES].Name, CFE_TBL_MAX_FULL_NAME_LEN, "%d", j); } @@ -556,7 +557,7 @@ void Test_CFE_TBL_TlmRegCmd(void) /* Registry[0].Name used because it is confirmed to be a registered * table name */ - strncpy(TlmRegCmd.Payload.TableName, CFE_TBL_TaskData.Registry[0].Name, + strncpy(TlmRegCmd.Payload.TableName, CFE_TBL_Global.Registry[0].Name, sizeof(TlmRegCmd.Payload.TableName) - 1); TlmRegCmd.Payload.TableName[sizeof(TlmRegCmd.Payload.TableName) - 1] = '\0'; UT_Report(__FILE__, __LINE__, @@ -582,7 +583,7 @@ void Test_CFE_TBL_TlmRegCmd(void) */ void Test_CFE_TBL_AbortLoadCmd(void) { - int load = (int) CFE_TBL_TaskData.Registry[0].LoadInProgress; + int load = (int) CFE_TBL_Global.Registry[0].LoadInProgress; CFE_TBL_AbortLoadCmd_t AbortLdCmd; UtPrintf("Begin Test Abort Load Command"); @@ -593,10 +594,10 @@ void Test_CFE_TBL_AbortLoadCmd(void) /* Entering the if statement with a table name that has to be in * the registry */ - strncpy(AbortLdCmd.Payload.TableName, CFE_TBL_TaskData.Registry[0].Name, + strncpy(AbortLdCmd.Payload.TableName, CFE_TBL_Global.Registry[0].Name, sizeof(AbortLdCmd.Payload.TableName) - 1); AbortLdCmd.Payload.TableName[sizeof(AbortLdCmd.Payload.TableName) - 1] = '\0'; - CFE_TBL_TaskData.Registry[0].LoadInProgress = 1; + CFE_TBL_Global.Registry[0].LoadInProgress = 1; UT_Report(__FILE__, __LINE__, CFE_TBL_AbortLoadCmd(&AbortLdCmd) == CFE_TBL_INC_CMD_CTR, @@ -605,7 +606,7 @@ void Test_CFE_TBL_AbortLoadCmd(void) /* Test when table name does exist but no table load is in progress */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; + CFE_TBL_Global.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; UT_Report(__FILE__, __LINE__, CFE_TBL_AbortLoadCmd(&AbortLdCmd) == CFE_TBL_INC_ERR_CTR, @@ -616,8 +617,8 @@ void Test_CFE_TBL_AbortLoadCmd(void) * table is dump only */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; - CFE_TBL_TaskData.Registry[0].DumpOnly = true; + CFE_TBL_Global.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; + CFE_TBL_Global.Registry[0].DumpOnly = true; UT_Report(__FILE__, __LINE__, CFE_TBL_AbortLoadCmd(&AbortLdCmd) == CFE_TBL_INC_ERR_CTR, @@ -636,17 +637,17 @@ void Test_CFE_TBL_AbortLoadCmd(void) /* Test when table is double buffered */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].DoubleBuffered = true; - CFE_TBL_TaskData.LoadBuffs[0].Taken = true; - CFE_TBL_AbortLoad(&CFE_TBL_TaskData.Registry[0]); + CFE_TBL_Global.Registry[0].DoubleBuffered = true; + CFE_TBL_Global.LoadBuffs[0].Taken = true; + CFE_TBL_AbortLoad(&CFE_TBL_Global.Registry[0]); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.LoadBuffs[0].Taken == true, + CFE_TBL_Global.LoadBuffs[0].Taken == true, "CFE_TBL_AbortLoad", "Table is double buffered"); /* Restore values for subsequent tests */ - CFE_TBL_TaskData.Registry[0].LoadInProgress = load; - CFE_TBL_TaskData.LoadBuffs[0].Taken = false; + CFE_TBL_Global.Registry[0].LoadInProgress = load; + CFE_TBL_Global.LoadBuffs[0].Taken = false; } /* @@ -654,14 +655,14 @@ void Test_CFE_TBL_AbortLoadCmd(void) */ void Test_CFE_TBL_ActivateCmd(void) { - int load = (int) CFE_TBL_TaskData.Registry[0].LoadInProgress; - uint8 dump = CFE_TBL_TaskData.Registry[0].DumpOnly; + int load = (int) CFE_TBL_Global.Registry[0].LoadInProgress; + uint8 dump = CFE_TBL_Global.Registry[0].DumpOnly; CFE_TBL_ActivateCmd_t ActivateCmd; UtPrintf("Begin Test Activate Command"); /* Enter the if statement with a table name that is in the registry */ - strncpy(ActivateCmd.Payload.TableName, CFE_TBL_TaskData.Registry[0].Name, + strncpy(ActivateCmd.Payload.TableName, CFE_TBL_Global.Registry[0].Name, sizeof(ActivateCmd.Payload.TableName) - 1); ActivateCmd.Payload.TableName[sizeof(ActivateCmd.Payload.TableName) - 1] = '\0'; @@ -669,7 +670,7 @@ void Test_CFE_TBL_ActivateCmd(void) * table */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].DumpOnly = true; + CFE_TBL_Global.Registry[0].DumpOnly = true; UT_Report(__FILE__, __LINE__, CFE_TBL_ActivateCmd(&ActivateCmd) == CFE_TBL_INC_ERR_CTR, @@ -680,9 +681,9 @@ void Test_CFE_TBL_ActivateCmd(void) * progress, and the table is double-buffered */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].DumpOnly = false; - CFE_TBL_TaskData.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; - CFE_TBL_TaskData.Registry[0].DoubleBuffered = true; + CFE_TBL_Global.Registry[0].DumpOnly = false; + CFE_TBL_Global.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; + CFE_TBL_Global.Registry[0].DoubleBuffered = true; UT_Report(__FILE__, __LINE__, CFE_TBL_ActivateCmd(&ActivateCmd) == CFE_TBL_INC_ERR_CTR, @@ -694,8 +695,8 @@ void Test_CFE_TBL_ActivateCmd(void) * progress, the table isn't double-buffered, and ValidationStatus = true */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].DoubleBuffered = false; - CFE_TBL_TaskData.LoadBuffs[CFE_TBL_TaskData.Registry[0].LoadInProgress].Validated = true; + CFE_TBL_Global.Registry[0].DoubleBuffered = false; + CFE_TBL_Global.LoadBuffs[CFE_TBL_Global.Registry[0].LoadInProgress].Validated = true; UT_Report(__FILE__, __LINE__, CFE_TBL_ActivateCmd(&ActivateCmd) == CFE_TBL_INC_CMD_CTR, @@ -707,8 +708,8 @@ void Test_CFE_TBL_ActivateCmd(void) * progress, and no notification message should be sent */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].NotifyByMsg = false; - CFE_TBL_TaskData.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; + CFE_TBL_Global.Registry[0].NotifyByMsg = false; + CFE_TBL_Global.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; UT_Report(__FILE__, __LINE__, CFE_TBL_ActivateCmd(&ActivateCmd) == CFE_TBL_INC_ERR_CTR, @@ -721,8 +722,8 @@ void Test_CFE_TBL_ActivateCmd(void) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(CFE_SB_TransmitMsg), 1, CFE_SB_INTERNAL_ERR); - CFE_TBL_TaskData.Registry[0].NotifyByMsg = true; - CFE_TBL_TaskData.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; + CFE_TBL_Global.Registry[0].NotifyByMsg = true; + CFE_TBL_Global.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; UT_Report(__FILE__, __LINE__, CFE_TBL_ActivateCmd(&ActivateCmd) == CFE_TBL_INC_CMD_CTR, @@ -741,8 +742,8 @@ void Test_CFE_TBL_ActivateCmd(void) "Table registry entry doesn't exist"); /* Restore original values */ - CFE_TBL_TaskData.Registry[0].LoadInProgress = load; - CFE_TBL_TaskData.Registry[0].DumpOnly = dump; + CFE_TBL_Global.Registry[0].LoadInProgress = load; + CFE_TBL_Global.Registry[0].DumpOnly = dump; } /* @@ -857,17 +858,17 @@ void Test_CFE_TBL_ValidateCmd(void) * have been requested */ UT_InitData(); - strncpy(ValidateCmd.Payload.TableName, CFE_TBL_TaskData.Registry[0].Name, + strncpy(ValidateCmd.Payload.TableName, CFE_TBL_Global.Registry[0].Name, sizeof(ValidateCmd.Payload.TableName) - 1); ValidateCmd.Payload.TableName[sizeof(ValidateCmd.Payload.TableName) - 1] = '\0'; ValidateCmd.Payload.ActiveTableFlag = CFE_TBL_BufferSelect_ACTIVE; - CFE_TBL_TaskData.Registry[0]. - Buffers[CFE_TBL_TaskData.Registry[0].ActiveBufferIndex]. + CFE_TBL_Global.Registry[0]. + Buffers[CFE_TBL_Global.Registry[0].ActiveBufferIndex]. BufferPtr = BuffPtr; for (i = 0; i < CFE_PLATFORM_TBL_MAX_NUM_VALIDATIONS; i++) { - CFE_TBL_TaskData.ValidationResults[i].State = + CFE_TBL_Global.ValidationResults[i].State = CFE_TBL_VALIDATION_PENDING; } @@ -882,8 +883,8 @@ void Test_CFE_TBL_ValidateCmd(void) * function pointer */ UT_InitData(); - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_FREE; - CFE_TBL_TaskData.Registry[0].ValidationFuncPtr = NULL; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_FREE; + CFE_TBL_Global.Registry[0].ValidationFuncPtr = NULL; UT_Report(__FILE__, __LINE__, CFE_TBL_ValidateCmd(&ValidateCmd) == CFE_TBL_INC_CMD_CTR, @@ -894,8 +895,8 @@ void Test_CFE_TBL_ValidateCmd(void) * exists, and the active table flag is set */ UT_InitData(); - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_FREE; - CFE_TBL_TaskData.Registry[0].ValidationFuncPtr = ValFuncPtr; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_FREE; + CFE_TBL_Global.Registry[0].ValidationFuncPtr = ValFuncPtr; ValidateCmd.Payload.ActiveTableFlag = true; UT_Report(__FILE__, __LINE__, CFE_TBL_ValidateCmd(&ValidateCmd) == @@ -909,10 +910,10 @@ void Test_CFE_TBL_ValidateCmd(void) */ UT_InitData(); ValidateCmd.Payload.ActiveTableFlag = CFE_TBL_BufferSelect_INACTIVE; - CFE_TBL_TaskData.Registry[0].DoubleBuffered = true; - CFE_TBL_TaskData.Registry[0].Buffers[1 - CFE_TBL_TaskData.Registry[0].ActiveBufferIndex].BufferPtr = BuffPtr; - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_FREE; - CFE_TBL_TaskData.Registry[0].ValidationFuncPtr = ValFuncPtr; + CFE_TBL_Global.Registry[0].DoubleBuffered = true; + CFE_TBL_Global.Registry[0].Buffers[1 - CFE_TBL_Global.Registry[0].ActiveBufferIndex].BufferPtr = BuffPtr; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_FREE; + CFE_TBL_Global.Registry[0].ValidationFuncPtr = ValFuncPtr; UT_Report(__FILE__, __LINE__, CFE_TBL_ValidateCmd(&ValidateCmd) == CFE_TBL_INC_CMD_CTR, @@ -925,11 +926,11 @@ void Test_CFE_TBL_ValidateCmd(void) * notification message should be sent */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].NotifyByMsg = false; - CFE_TBL_TaskData.Registry[0].DoubleBuffered = false; - CFE_TBL_TaskData.LoadBuffs[CFE_TBL_TaskData.Registry[0].LoadInProgress].BufferPtr = BuffPtr; - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_FREE; - CFE_TBL_TaskData.Registry[0].LoadInProgress = + CFE_TBL_Global.Registry[0].NotifyByMsg = false; + CFE_TBL_Global.Registry[0].DoubleBuffered = false; + CFE_TBL_Global.LoadBuffs[CFE_TBL_Global.Registry[0].LoadInProgress].BufferPtr = BuffPtr; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_FREE; + CFE_TBL_Global.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; UT_Report(__FILE__, __LINE__, CFE_TBL_ValidateCmd(&ValidateCmd) == @@ -944,11 +945,11 @@ void Test_CFE_TBL_ValidateCmd(void) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(CFE_SB_TransmitMsg), 1, CFE_SB_INTERNAL_ERR); - CFE_TBL_TaskData.Registry[0].NotifyByMsg = true; - CFE_TBL_TaskData.Registry[0].DoubleBuffered = false; - CFE_TBL_TaskData.LoadBuffs[CFE_TBL_TaskData.Registry[0].LoadInProgress].BufferPtr = BuffPtr; - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_FREE; - CFE_TBL_TaskData.Registry[0].LoadInProgress = + CFE_TBL_Global.Registry[0].NotifyByMsg = true; + CFE_TBL_Global.Registry[0].DoubleBuffered = false; + CFE_TBL_Global.LoadBuffs[CFE_TBL_Global.Registry[0].LoadInProgress].BufferPtr = BuffPtr; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_FREE; + CFE_TBL_Global.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; UT_Report(__FILE__, __LINE__, CFE_TBL_ValidateCmd(&ValidateCmd) == @@ -961,7 +962,7 @@ void Test_CFE_TBL_ValidateCmd(void) * load in progress) */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; + CFE_TBL_Global.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; UT_Report(__FILE__, __LINE__, CFE_TBL_ValidateCmd(&ValidateCmd) == CFE_TBL_INC_ERR_CTR, @@ -1004,36 +1005,36 @@ void Test_CFE_TBL_GetTblRegData(void) /* Test using a double buffered table */ UT_InitData(); - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); - CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.HkTlmTblRegIndex].DoubleBuffered = true; + CFE_TBL_Global.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); + CFE_TBL_Global.Registry[CFE_TBL_Global.HkTlmTblRegIndex].DoubleBuffered = true; CFE_TBL_GetTblRegData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr != 0, + CFE_TBL_Global.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 = CFE_ES_MEMADDRESS_C(0); - CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.HkTlmTblRegIndex].DoubleBuffered = false; - CFE_TBL_TaskData. - Registry[CFE_TBL_TaskData.HkTlmTblRegIndex]. + CFE_TBL_Global.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); + CFE_TBL_Global.Registry[CFE_TBL_Global.HkTlmTblRegIndex].DoubleBuffered = false; + CFE_TBL_Global. + Registry[CFE_TBL_Global.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_Global.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 = CFE_ES_MEMADDRESS_C(0); - CFE_TBL_TaskData. - Registry[CFE_TBL_TaskData.HkTlmTblRegIndex].LoadInProgress = + CFE_TBL_Global.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); + CFE_TBL_Global. + Registry[CFE_TBL_Global.HkTlmTblRegIndex].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; CFE_TBL_GetTblRegData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr == 0, + CFE_TBL_Global.TblRegPacket.Payload.InactiveBufferAddr == 0, "CFE_TBL_GetTblRegData", "No inactive buffer"); } @@ -1048,7 +1049,7 @@ void Test_CFE_TBL_GetHkData(void) int32 NumLoadPendingIndex = CFE_PLATFORM_TBL_MAX_NUM_TABLES - 1; int32 FreeSharedBuffIndex = CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS - 1; int32 ValTableIndex = CFE_PLATFORM_TBL_MAX_NUM_VALIDATIONS - 1; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; /* Get the AppID being used for UT */ CFE_ES_GetAppID(&AppID); @@ -1057,80 +1058,80 @@ void Test_CFE_TBL_GetHkData(void) for (i = 0; i < CFE_PLATFORM_TBL_MAX_NUM_TABLES; i++) { - CFE_TBL_TaskData.Registry[i].LoadPending = false; + CFE_TBL_Global.Registry[i].LoadPending = false; } /* Test raising the count of load pending tables */ UT_InitData(); - CFE_TBL_TaskData.Registry[NumLoadPendingIndex].LoadPending = true; - CFE_TBL_TaskData.Registry[NumLoadPendingIndex].OwnerAppId = AppID; + CFE_TBL_Global.Registry[NumLoadPendingIndex].LoadPending = true; + CFE_TBL_Global.Registry[NumLoadPendingIndex].OwnerAppId = AppID; CFE_TBL_GetHkData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.HkPacket.Payload.NumLoadPending == 1, + CFE_TBL_Global.HkPacket.Payload.NumLoadPending == 1, "CFE_TBL_GetHkData", "Raise load pending table count"); /* Test lowering the count of free shared buffers */ UT_InitData(); - CFE_TBL_TaskData.LoadBuffs[FreeSharedBuffIndex].Taken = true; + CFE_TBL_Global.LoadBuffs[FreeSharedBuffIndex].Taken = true; CFE_TBL_GetHkData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.HkPacket.Payload.NumFreeSharedBufs == + CFE_TBL_Global.HkPacket.Payload.NumFreeSharedBufs == CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS - 1, "CFE_TBL_GetHkData", "Lower free shared buffer count"); /* Test making a ValPtr with result = CFE_SUCCESS */ UT_InitData(); - CFE_TBL_TaskData.SuccessValCounter = 0; - CFE_TBL_TaskData.ValidationResults[ValTableIndex].State = + CFE_TBL_Global.SuccessValCounter = 0; + CFE_TBL_Global.ValidationResults[ValTableIndex].State = CFE_TBL_VALIDATION_PERFORMED; - CFE_TBL_TaskData.ValidationResults[ValTableIndex].Result = CFE_SUCCESS; + CFE_TBL_Global.ValidationResults[ValTableIndex].Result = CFE_SUCCESS; CFE_TBL_GetHkData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.SuccessValCounter == 1, + CFE_TBL_Global.SuccessValCounter == 1, "CFE_TBL_GetHkData", "ValPtr result CFE_SUCCESS"); /* Test making a ValPtr without result = CFE_SUCCESS */ UT_InitData(); - CFE_TBL_TaskData.FailedValCounter = 0; - CFE_TBL_TaskData.ValidationResults[ValTableIndex].State = + CFE_TBL_Global.FailedValCounter = 0; + CFE_TBL_Global.ValidationResults[ValTableIndex].State = CFE_TBL_VALIDATION_PERFORMED; - CFE_TBL_TaskData.ValidationResults[ValTableIndex].Result = CFE_SUCCESS - 1; + CFE_TBL_Global.ValidationResults[ValTableIndex].Result = CFE_SUCCESS - 1; CFE_TBL_GetHkData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.FailedValCounter == 1, + CFE_TBL_Global.FailedValCounter == 1, "CFE_TBL_GetHkData", "ValPtr result != CFE_SUCCESS"); /* Test with an invalid registry entry */ UT_InitData(); - CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.LastTblUpdated].OwnerAppId = CFE_TBL_NOT_OWNED; - CFE_TBL_TaskData.HkPacket.Payload.LastUpdateTime.Seconds = 19283; + CFE_TBL_Global.Registry[CFE_TBL_Global.LastTblUpdated].OwnerAppId = CFE_TBL_NOT_OWNED; + CFE_TBL_Global.HkPacket.Payload.LastUpdateTime.Seconds = 19283; CFE_TBL_GetHkData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.HkPacket.Payload.LastUpdateTime.Seconds == 19283, + CFE_TBL_Global.HkPacket.Payload.LastUpdateTime.Seconds == 19283, "CFE_TBL_GetHkData", "Invalid registry entry"); /* Test with invalid last valid table updated out of range (low) */ UT_InitData(); - CFE_TBL_TaskData.LastTblUpdated = -1; - CFE_TBL_TaskData.HkPacket.Payload.LastUpdateTime.Seconds = 12345; + CFE_TBL_Global.LastTblUpdated = -1; + CFE_TBL_Global.HkPacket.Payload.LastUpdateTime.Seconds = 12345; CFE_TBL_GetHkData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.HkPacket.Payload.LastUpdateTime.Seconds == 12345, + CFE_TBL_Global.HkPacket.Payload.LastUpdateTime.Seconds == 12345, "CFE_TBL_GetHkData", "Last valid table updated out of range (low)"); /* Test with invalid last valid table updated out of range (high) */ UT_InitData(); - CFE_TBL_TaskData.LastTblUpdated = CFE_PLATFORM_TBL_MAX_NUM_TABLES; - CFE_TBL_TaskData.HkPacket.Payload.LastUpdateTime.Seconds = 54321; + CFE_TBL_Global.LastTblUpdated = CFE_PLATFORM_TBL_MAX_NUM_TABLES; + CFE_TBL_Global.HkPacket.Payload.LastUpdateTime.Seconds = 54321; CFE_TBL_GetHkData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.HkPacket.Payload.LastUpdateTime.Seconds == 54321, + CFE_TBL_Global.HkPacket.Payload.LastUpdateTime.Seconds == 54321, "CFE_TBL_GetHkData", "Last valid table updated out of range (high)"); } @@ -1143,7 +1144,7 @@ void Test_CFE_TBL_DumpRegCmd(void) { int q; CFE_TBL_DumpRegistryCmd_t DumpRegCmd; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; /* Get the AppID being used for UT */ CFE_ES_GetAppID(&AppID); @@ -1153,7 +1154,7 @@ void Test_CFE_TBL_DumpRegCmd(void) for (q = 0; q < CFE_PLATFORM_TBL_MAX_NUM_TABLES; q++) { - CFE_TBL_TaskData.Registry[q].HeadOfAccessList = CFE_TBL_END_OF_LIST; + CFE_TBL_Global.Registry[q].HeadOfAccessList = CFE_TBL_END_OF_LIST; } /* Test with an error creating the dump file */ @@ -1180,11 +1181,11 @@ void Test_CFE_TBL_DumpRegCmd(void) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 10, sizeof(CFE_FS_Header_t)); - CFE_TBL_TaskData.Registry[0].OwnerAppId = AppID; - CFE_TBL_TaskData.Registry[0].HeadOfAccessList = CFE_TBL_END_OF_LIST; - CFE_TBL_TaskData.Registry[1].OwnerAppId = CFE_TBL_NOT_OWNED; - CFE_TBL_TaskData.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; - CFE_TBL_TaskData.Registry[0].DoubleBuffered = true; + CFE_TBL_Global.Registry[0].OwnerAppId = AppID; + CFE_TBL_Global.Registry[0].HeadOfAccessList = CFE_TBL_END_OF_LIST; + CFE_TBL_Global.Registry[1].OwnerAppId = CFE_TBL_NOT_OWNED; + CFE_TBL_Global.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; + CFE_TBL_Global.Registry[0].DoubleBuffered = true; UT_SetDeferredRetcode(UT_KEY(OS_OpenCreate), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_TBL_DumpRegistryCmd(&DumpRegCmd) == @@ -1197,7 +1198,7 @@ void Test_CFE_TBL_DumpRegCmd(void) * overwritten */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; + CFE_TBL_Global.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; UT_Report(__FILE__, __LINE__, CFE_TBL_DumpRegistryCmd(&DumpRegCmd) == CFE_TBL_INC_CMD_CTR, @@ -1209,9 +1210,9 @@ void Test_CFE_TBL_DumpRegCmd(void) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_write), 1, sizeof(CFE_TBL_RegDumpRec_t) - 1); - CFE_TBL_TaskData.Registry[0].OwnerAppId = CFE_TBL_NOT_OWNED; - CFE_TBL_TaskData.Registry[0].HeadOfAccessList = 2; - CFE_TBL_TaskData.Handles[2].NextLink = CFE_TBL_END_OF_LIST; + CFE_TBL_Global.Registry[0].OwnerAppId = CFE_TBL_NOT_OWNED; + CFE_TBL_Global.Registry[0].HeadOfAccessList = 2; + CFE_TBL_Global.Handles[2].NextLink = CFE_TBL_END_OF_LIST; UT_Report(__FILE__, __LINE__, CFE_TBL_DumpRegistryCmd(&DumpRegCmd) == CFE_TBL_INC_ERR_CTR, @@ -1239,7 +1240,7 @@ void Test_CFE_TBL_DumpCmd(void) uint8 *BuffPtr = &Buff; CFE_TBL_LoadBuff_t Load = {0}; CFE_TBL_DumpCmd_t DumpCmd; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; CFE_ES_GetAppID(&AppID); @@ -1262,28 +1263,28 @@ void Test_CFE_TBL_DumpCmd(void) * working buffer; load in progress, single-buffered */ UT_InitData(); - strncpy(CFE_TBL_TaskData.Registry[2].Name, "DumpCmdTest", - sizeof(CFE_TBL_TaskData.Registry[2].Name) - 1); - CFE_TBL_TaskData.Registry[2].Name[sizeof(CFE_TBL_TaskData.Registry[2].Name) - 1] = '\0'; - CFE_TBL_TaskData.Registry[2].OwnerAppId = AppID; - strncpy(DumpCmd.Payload.TableName, CFE_TBL_TaskData.Registry[2].Name, + strncpy(CFE_TBL_Global.Registry[2].Name, "DumpCmdTest", + sizeof(CFE_TBL_Global.Registry[2].Name) - 1); + CFE_TBL_Global.Registry[2].Name[sizeof(CFE_TBL_Global.Registry[2].Name) - 1] = '\0'; + CFE_TBL_Global.Registry[2].OwnerAppId = AppID; + strncpy(DumpCmd.Payload.TableName, CFE_TBL_Global.Registry[2].Name, sizeof(DumpCmd.Payload.TableName) - 1); DumpCmd.Payload.TableName[sizeof(DumpCmd.Payload.TableName) - 1] = '\0'; DumpCmd.Payload.ActiveTableFlag = CFE_TBL_BufferSelect_ACTIVE; - CFE_TBL_TaskData.Registry[2].Buffers[CFE_TBL_TaskData.Registry[2].ActiveBufferIndex].BufferPtr = BuffPtr; + CFE_TBL_Global.Registry[2].Buffers[CFE_TBL_Global.Registry[2].ActiveBufferIndex].BufferPtr = BuffPtr; for (i = 0; i < CFE_PLATFORM_TBL_MAX_NUM_TABLES; i++) { - CFE_TBL_TaskData.Registry[i].DumpOnly = true; + CFE_TBL_Global.Registry[i].DumpOnly = true; } - CFE_TBL_TaskData.DumpControlBlocks[2].State = CFE_TBL_DUMP_PENDING; - CFE_TBL_TaskData.DumpControlBlocks[3].State = CFE_TBL_DUMP_FREE; - CFE_TBL_TaskData.Registry[2].DumpControlIndex = CFE_TBL_NO_DUMP_PENDING; - CFE_TBL_TaskData.Registry[2].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; - CFE_TBL_TaskData.Registry[2].DoubleBuffered = false; - CFE_TBL_TaskData.LoadBuffs[CFE_TBL_TaskData.Registry[2].LoadInProgress] = Load; - CFE_TBL_TaskData.Registry[2].NotifyByMsg = true; + CFE_TBL_Global.DumpControlBlocks[2].State = CFE_TBL_DUMP_PENDING; + CFE_TBL_Global.DumpControlBlocks[3].State = CFE_TBL_DUMP_FREE; + CFE_TBL_Global.Registry[2].DumpControlIndex = CFE_TBL_NO_DUMP_PENDING; + CFE_TBL_Global.Registry[2].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; + CFE_TBL_Global.Registry[2].DoubleBuffered = false; + CFE_TBL_Global.LoadBuffs[CFE_TBL_Global.Registry[2].LoadInProgress] = Load; + CFE_TBL_Global.Registry[2].NotifyByMsg = true; UT_SetDeferredRetcode(UT_KEY(CFE_SB_TransmitMsg), 1, CFE_SB_INTERNAL_ERR); UT_Report(__FILE__, __LINE__, CFE_TBL_DumpCmd(&DumpCmd) == @@ -1298,18 +1299,18 @@ void Test_CFE_TBL_DumpCmd(void) * available */ UT_InitData(); - CFE_TBL_TaskData.DumpControlBlocks[2].State = CFE_TBL_DUMP_FREE; - CFE_TBL_TaskData.Registry[2].DumpControlIndex = CFE_TBL_NO_DUMP_PENDING; - CFE_TBL_TaskData.Registry[2].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; - CFE_TBL_TaskData.Registry[2].TableLoadedOnce = true; - CFE_TBL_TaskData.Registry[2].DoubleBuffered = false; + CFE_TBL_Global.DumpControlBlocks[2].State = CFE_TBL_DUMP_FREE; + CFE_TBL_Global.Registry[2].DumpControlIndex = CFE_TBL_NO_DUMP_PENDING; + CFE_TBL_Global.Registry[2].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; + CFE_TBL_Global.Registry[2].TableLoadedOnce = true; + CFE_TBL_Global.Registry[2].DoubleBuffered = false; for (u = 0; u < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS; u++) { - CFE_TBL_TaskData.LoadBuffs[u].Taken = true; + CFE_TBL_Global.LoadBuffs[u].Taken = true; } - CFE_TBL_TaskData.Registry[2].NotifyByMsg = true; + CFE_TBL_Global.Registry[2].NotifyByMsg = true; UT_Report(__FILE__, __LINE__, CFE_TBL_DumpCmd(&DumpCmd) == CFE_TBL_INC_ERR_CTR, @@ -1323,14 +1324,14 @@ void Test_CFE_TBL_DumpCmd(void) * dump only table dumps have been requested */ UT_InitData(); - CFE_TBL_TaskData.Registry[2].DumpControlIndex = CFE_TBL_NO_DUMP_PENDING; + CFE_TBL_Global.Registry[2].DumpControlIndex = CFE_TBL_NO_DUMP_PENDING; for (k = 0; k < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS; k++) { - CFE_TBL_TaskData.DumpControlBlocks[k].State = CFE_TBL_DUMP_PENDING; + CFE_TBL_Global.DumpControlBlocks[k].State = CFE_TBL_DUMP_PENDING; } - CFE_TBL_TaskData.Registry[2].NotifyByMsg = true; + CFE_TBL_Global.Registry[2].NotifyByMsg = true; UT_Report(__FILE__, __LINE__, CFE_TBL_DumpCmd(&DumpCmd) == CFE_TBL_INC_ERR_CTR, @@ -1344,9 +1345,9 @@ void Test_CFE_TBL_DumpCmd(void) */ UT_InitData(); DumpCmd.Payload.ActiveTableFlag = CFE_TBL_BufferSelect_INACTIVE; - CFE_TBL_TaskData.Registry[2].DoubleBuffered = true; - CFE_TBL_TaskData.Registry[2].Buffers[(1 - CFE_TBL_TaskData.Registry[2].ActiveBufferIndex)].BufferPtr = BuffPtr; - CFE_TBL_TaskData.Registry[2].DumpControlIndex = CFE_TBL_NO_DUMP_PENDING + + CFE_TBL_Global.Registry[2].DoubleBuffered = true; + CFE_TBL_Global.Registry[2].Buffers[(1 - CFE_TBL_Global.Registry[2].ActiveBufferIndex)].BufferPtr = BuffPtr; + CFE_TBL_Global.Registry[2].DumpControlIndex = CFE_TBL_NO_DUMP_PENDING + 1; UT_Report(__FILE__, __LINE__, CFE_TBL_DumpCmd(&DumpCmd) == @@ -1359,11 +1360,11 @@ void Test_CFE_TBL_DumpCmd(void) * dump only table */ UT_InitData(); - CFE_TBL_TaskData.Registry[2].DoubleBuffered = false; - CFE_TBL_TaskData.Registry[2].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; - CFE_TBL_TaskData.LoadBuffs[CFE_TBL_TaskData.Registry[2].LoadInProgress].BufferPtr = BuffPtr; - CFE_TBL_TaskData.Registry[2].DumpOnly = false; - strncpy(DumpCmd.Payload.DumpFilename, CFE_TBL_TaskData.Registry[2].LastFileLoaded, + CFE_TBL_Global.Registry[2].DoubleBuffered = false; + CFE_TBL_Global.Registry[2].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; + CFE_TBL_Global.LoadBuffs[CFE_TBL_Global.Registry[2].LoadInProgress].BufferPtr = BuffPtr; + CFE_TBL_Global.Registry[2].DumpOnly = false; + strncpy(DumpCmd.Payload.DumpFilename, CFE_TBL_Global.Registry[2].LastFileLoaded, sizeof(DumpCmd.Payload.DumpFilename) - 1); DumpCmd.Payload.DumpFilename[sizeof(DumpCmd.Payload.DumpFilename) - 1] = '\0'; UT_Report(__FILE__, __LINE__, @@ -1377,7 +1378,7 @@ void Test_CFE_TBL_DumpCmd(void) * table due to load in progress */ UT_InitData(); - CFE_TBL_TaskData.Registry[2].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; + CFE_TBL_Global.Registry[2].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; UT_Report(__FILE__, __LINE__, CFE_TBL_DumpCmd(&DumpCmd) == CFE_TBL_INC_ERR_CTR, @@ -1389,8 +1390,8 @@ void Test_CFE_TBL_DumpCmd(void) * table due to user defined address */ UT_InitData(); - CFE_TBL_TaskData.Registry[2].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; - CFE_TBL_TaskData.Registry[2].UserDefAddr = true; + CFE_TBL_Global.Registry[2].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; + CFE_TBL_Global.Registry[2].UserDefAddr = true; UT_Report(__FILE__, __LINE__, CFE_TBL_DumpCmd(&DumpCmd) == CFE_TBL_INC_ERR_CTR, @@ -1417,9 +1418,9 @@ void Test_CFE_TBL_LoadCmd(void) int i, j; CFE_TBL_File_Hdr_t TblFileHeader; CFE_FS_Header_t StdFileHeader; - CFE_TBL_LoadBuff_t BufferPtr = CFE_TBL_TaskData.LoadBuffs[0]; + CFE_TBL_LoadBuff_t BufferPtr = CFE_TBL_Global.LoadBuffs[0]; CFE_TBL_LoadCmd_t LoadCmd; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; CFE_ES_GetAppID(&AppID); @@ -1445,11 +1446,11 @@ void Test_CFE_TBL_LoadCmd(void) for (i = 0; i < CFE_PLATFORM_TBL_MAX_NUM_TABLES; i++) { - CFE_TBL_TaskData.Registry[i].OwnerAppId = CFE_TBL_NOT_OWNED; - CFE_TBL_TaskData.Registry[i].LoadPending = false; + CFE_TBL_Global.Registry[i].OwnerAppId = CFE_TBL_NOT_OWNED; + CFE_TBL_Global.Registry[i].LoadPending = false; } - strncpy(TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, + strncpy(TblFileHeader.TableName, CFE_TBL_Global.Registry[0].Name, sizeof(TblFileHeader.TableName) - 1); TblFileHeader.TableName[sizeof(TblFileHeader.TableName) - 1] = '\0'; strncpy(StdFileHeader.Description, "FS header description", @@ -1467,11 +1468,11 @@ void Test_CFE_TBL_LoadCmd(void) /* Test attempt to load a dump only table */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].OwnerAppId = AppID; + CFE_TBL_Global.Registry[0].OwnerAppId = AppID; UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); - CFE_TBL_TaskData.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t) + 1; - CFE_TBL_TaskData.Registry[0].DumpOnly = true; + CFE_TBL_Global.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t) + 1; + CFE_TBL_Global.Registry[0].DumpOnly = true; UT_Report(__FILE__, __LINE__, CFE_TBL_LoadCmd(&LoadCmd) == CFE_TBL_INC_ERR_CTR, @@ -1480,18 +1481,18 @@ void Test_CFE_TBL_LoadCmd(void) /* Test attempt to load a table with a load already pending */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].OwnerAppId = AppID; + CFE_TBL_Global.Registry[0].OwnerAppId = AppID; UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); - CFE_TBL_TaskData.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t) + 1; - CFE_TBL_TaskData.Registry[0].DumpOnly = false; - CFE_TBL_TaskData.Registry[0].LoadPending = true; + CFE_TBL_Global.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t) + 1; + CFE_TBL_Global.Registry[0].DumpOnly = false; + CFE_TBL_Global.Registry[0].LoadPending = true; UT_Report(__FILE__, __LINE__, CFE_TBL_LoadCmd(&LoadCmd) == CFE_TBL_INC_ERR_CTR, "CFE_TBL_LoadCmd", "Attempting to load a table with load already pending"); - CFE_TBL_TaskData.Registry[0].LoadPending = false; + CFE_TBL_Global.Registry[0].LoadPending = false; /* Test where the file isn't dump only and passes table checks, get a * working buffer, and there is an extra byte (more data than header @@ -1499,16 +1500,16 @@ void Test_CFE_TBL_LoadCmd(void) */ UT_InitData(); UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t)); - CFE_TBL_TaskData.Registry[0].TableLoadedOnce = true; + CFE_TBL_Global.Registry[0].TableLoadedOnce = true; - CFE_TBL_TaskData.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t); - CFE_TBL_TaskData.Registry[0].LoadInProgress = + CFE_TBL_Global.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t); + CFE_TBL_Global.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; - CFE_TBL_TaskData.Registry[0].DoubleBuffered = false; - CFE_TBL_TaskData.LoadBuffs[CFE_TBL_TaskData.Registry[0].LoadInProgress].BufferPtr = (uint8 *) &BufferPtr; + CFE_TBL_Global.Registry[0].DoubleBuffered = false; + CFE_TBL_Global.LoadBuffs[CFE_TBL_Global.Registry[0].LoadInProgress].BufferPtr = (uint8 *) &BufferPtr; UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); - CFE_TBL_TaskData.Registry[0].DumpOnly = false; + CFE_TBL_Global.Registry[0].DumpOnly = false; UT_Report(__FILE__, __LINE__, CFE_TBL_LoadCmd(&LoadCmd) == CFE_TBL_INC_ERR_CTR, @@ -1520,7 +1521,7 @@ void Test_CFE_TBL_LoadCmd(void) UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t)); UT_SetDeferredRetcode(UT_KEY(OS_read), 3, 0); - strncpy(TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, + strncpy(TblFileHeader.TableName, CFE_TBL_Global.Registry[0].Name, sizeof(TblFileHeader.TableName) - 1); TblFileHeader.TableName[sizeof(TblFileHeader.TableName) - 1] = '\0'; UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); @@ -1540,7 +1541,7 @@ void Test_CFE_TBL_LoadCmd(void) CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); } - strncpy(TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, + strncpy(TblFileHeader.TableName, CFE_TBL_Global.Registry[0].Name, sizeof(TblFileHeader.TableName) - 1); TblFileHeader.TableName[sizeof(TblFileHeader.TableName) - 1] = '\0'; UT_SetDeferredRetcode(UT_KEY(OS_read), 2, 0); @@ -1554,17 +1555,17 @@ void Test_CFE_TBL_LoadCmd(void) /* Test with no working buffers available */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; - CFE_TBL_TaskData.Registry[0].TableLoadedOnce = true; - CFE_TBL_TaskData.Registry[0].DoubleBuffered = false; - CFE_TBL_TaskData.Registry[0].Buffers[CFE_TBL_TaskData.Registry[0].ActiveBufferIndex] = BufferPtr; + CFE_TBL_Global.Registry[0].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; + CFE_TBL_Global.Registry[0].TableLoadedOnce = true; + CFE_TBL_Global.Registry[0].DoubleBuffered = false; + CFE_TBL_Global.Registry[0].Buffers[CFE_TBL_Global.Registry[0].ActiveBufferIndex] = BufferPtr; for (j = 0; j < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS; j++) { - CFE_TBL_TaskData.LoadBuffs[j].Taken = true; + CFE_TBL_Global.LoadBuffs[j].Taken = true; } - strncpy(TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, + strncpy(TblFileHeader.TableName, CFE_TBL_Global.Registry[0].Name, sizeof(TblFileHeader.TableName) - 1); TblFileHeader.TableName[sizeof(TblFileHeader.TableName) - 1] = '\0'; UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); @@ -1579,8 +1580,8 @@ void Test_CFE_TBL_LoadCmd(void) UT_InitData(); 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(TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, + CFE_TBL_Global.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t) - 1; + strncpy(TblFileHeader.TableName, CFE_TBL_Global.Registry[0].Name, sizeof(TblFileHeader.TableName) - 1); TblFileHeader.TableName[sizeof(TblFileHeader.TableName) - 1] = '\0'; UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); @@ -1595,7 +1596,7 @@ void Test_CFE_TBL_LoadCmd(void) UT_InitData(); UT_TBL_SetupHeader(&TblFileHeader, 0, 0); - strncpy(TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, + strncpy(TblFileHeader.TableName, CFE_TBL_Global.Registry[0].Name, sizeof(TblFileHeader.TableName) - 1); TblFileHeader.TableName[sizeof(TblFileHeader.TableName) - 1] = '\0'; UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); @@ -1612,10 +1613,10 @@ void Test_CFE_TBL_LoadCmd(void) UT_InitData(); UT_TBL_SetupHeader(&TblFileHeader, 1, 1); - CFE_TBL_TaskData.Registry[0].TableLoadedOnce = false; + CFE_TBL_Global.Registry[0].TableLoadedOnce = false; - CFE_TBL_TaskData.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t); - strncpy(TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, + CFE_TBL_Global.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t); + strncpy(TblFileHeader.TableName, CFE_TBL_Global.Registry[0].Name, sizeof(TblFileHeader.TableName) - 1); TblFileHeader.TableName[sizeof(TblFileHeader.TableName) - 1] = '\0'; UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); @@ -1633,10 +1634,10 @@ void Test_CFE_TBL_LoadCmd(void) UT_InitData(); UT_TBL_SetupHeader(&TblFileHeader, 0, 1); - CFE_TBL_TaskData.Registry[0].TableLoadedOnce = false; + CFE_TBL_Global.Registry[0].TableLoadedOnce = false; - CFE_TBL_TaskData.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t); - strncpy(TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, + CFE_TBL_Global.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t); + strncpy(TblFileHeader.TableName, CFE_TBL_Global.Registry[0].Name, sizeof(TblFileHeader.TableName) - 1); TblFileHeader.TableName[sizeof(TblFileHeader.TableName) - 1] = '\0'; UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); @@ -1682,13 +1683,13 @@ void Test_CFE_TBL_HousekeepingCmd(void) * to send Hk packet */ UT_InitData(); - strncpy(CFE_TBL_TaskData.DumpControlBlocks[0].TableName, - "housekeepingtest", sizeof(CFE_TBL_TaskData.DumpControlBlocks[0].TableName) - 1); - CFE_TBL_TaskData.DumpControlBlocks[0].TableName[sizeof(CFE_TBL_TaskData.DumpControlBlocks[0].TableName) - 1] = '\0'; - CFE_TBL_TaskData.DumpControlBlocks[0].Size = 10; + strncpy(CFE_TBL_Global.DumpControlBlocks[0].TableName, + "housekeepingtest", sizeof(CFE_TBL_Global.DumpControlBlocks[0].TableName) - 1); + CFE_TBL_Global.DumpControlBlocks[0].TableName[sizeof(CFE_TBL_Global.DumpControlBlocks[0].TableName) - 1] = '\0'; + CFE_TBL_Global.DumpControlBlocks[0].Size = 10; LoadInProg = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; RegRecPtr.LoadInProgress = LoadInProg; - CFE_TBL_TaskData.DumpControlBlocks[0].RegRecPtr = &RegRecPtr; + CFE_TBL_Global.DumpControlBlocks[0].RegRecPtr = &RegRecPtr; DumpBuffPtr->Taken = true; DumpBuffPtr->Validated = true; DumpBuffPtr->BufferPtr = BuffPtr; @@ -1696,16 +1697,16 @@ void Test_CFE_TBL_HousekeepingCmd(void) DumpBuffPtr->FileCreateTimeSubSecs = SubSecs; strncpy(DumpBuffPtr->DataSource, "hkSource", sizeof(DumpBuffPtr->DataSource) - 1); DumpBuffPtr->DataSource[sizeof(DumpBuffPtr->DataSource) - 1] = '\0'; - CFE_TBL_TaskData.DumpControlBlocks[0].DumpBufferPtr = DumpBuffPtr; - CFE_TBL_TaskData.DumpControlBlocks[0].State = CFE_TBL_DUMP_PERFORMED; + CFE_TBL_Global.DumpControlBlocks[0].DumpBufferPtr = DumpBuffPtr; + CFE_TBL_Global.DumpControlBlocks[0].State = CFE_TBL_DUMP_PERFORMED; for (i = 1; i < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS; i++) { - CFE_TBL_TaskData.DumpControlBlocks[i].State = CFE_TBL_DUMP_PENDING; + CFE_TBL_Global.DumpControlBlocks[i].State = CFE_TBL_DUMP_PENDING; } UT_SetDeferredRetcode(UT_KEY(CFE_SB_TransmitMsg), 1, CFE_SUCCESS - 1); - CFE_TBL_TaskData.HkTlmTblRegIndex = CFE_TBL_NOT_FOUND + 1; + CFE_TBL_Global.HkTlmTblRegIndex = CFE_TBL_NOT_FOUND + 1; UT_Report(__FILE__, __LINE__, CFE_TBL_HousekeepingCmd(NULL) == CFE_TBL_DONT_INC_CTR, "CFE_TBL_HousekeepingCmd", @@ -1713,16 +1714,16 @@ void Test_CFE_TBL_HousekeepingCmd(void) for (i = 1; i < CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS; i++) { - CFE_TBL_TaskData.DumpControlBlocks[i].State = CFE_TBL_DUMP_PENDING; + CFE_TBL_Global.DumpControlBlocks[i].State = CFE_TBL_DUMP_PENDING; } RegRecPtr.LoadInProgress = LoadInProg; - CFE_TBL_TaskData.DumpControlBlocks[0].RegRecPtr = &RegRecPtr; + CFE_TBL_Global.DumpControlBlocks[0].RegRecPtr = &RegRecPtr; /* Test response to inability to open dump file */ UT_InitData(); - CFE_TBL_TaskData.DumpControlBlocks[0].State = CFE_TBL_DUMP_PERFORMED; - CFE_TBL_TaskData.HkTlmTblRegIndex = CFE_TBL_NOT_FOUND + 1; + CFE_TBL_Global.DumpControlBlocks[0].State = CFE_TBL_DUMP_PERFORMED; + CFE_TBL_Global.HkTlmTblRegIndex = CFE_TBL_NOT_FOUND + 1; UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_TBL_HousekeepingCmd(NULL) == CFE_TBL_DONT_INC_CTR, @@ -1731,8 +1732,8 @@ void Test_CFE_TBL_HousekeepingCmd(void) /* Test response to an invalid table and a dump file create failure */ UT_InitData(); - CFE_TBL_TaskData.HkTlmTblRegIndex = CFE_TBL_NOT_FOUND; - CFE_TBL_TaskData.DumpControlBlocks[0].State = CFE_TBL_DUMP_PERFORMED; + CFE_TBL_Global.HkTlmTblRegIndex = CFE_TBL_NOT_FOUND; + CFE_TBL_Global.DumpControlBlocks[0].State = CFE_TBL_DUMP_PERFORMED; UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_TBL_HousekeepingCmd(NULL) == CFE_TBL_DONT_INC_CTR, @@ -1741,7 +1742,7 @@ void Test_CFE_TBL_HousekeepingCmd(void) /* Test response to a file time stamp failure */ UT_InitData(); - CFE_TBL_TaskData.DumpControlBlocks[0].State = CFE_TBL_DUMP_PERFORMED; + CFE_TBL_Global.DumpControlBlocks[0].State = CFE_TBL_DUMP_PERFORMED; UT_SetDeferredRetcode(UT_KEY(CFE_FS_SetTimestamp), 1, OS_SUCCESS - 1); UT_Report(__FILE__, __LINE__, CFE_TBL_HousekeepingCmd(NULL) == CFE_TBL_DONT_INC_CTR, @@ -1756,7 +1757,7 @@ void Test_CFE_TBL_ApiInit(void) { UT_ResetCDS(); CFE_TBL_EarlyInit(); - CFE_TBL_TaskData.TableTaskAppId = UT_TBL_APPID_10; + CFE_TBL_Global.TableTaskAppId = UT_TBL_APPID_10; } /* @@ -2133,7 +2134,7 @@ void Test_CFE_TBL_Register(void) /* a. Perform test */ UT_ClearEventHistory(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterCDSEx), 1, CFE_ES_CDS_ALREADY_EXISTS); - CFE_TBL_TaskData.CritReg[0].TableLoadedOnce = true; + CFE_TBL_Global.CritReg[0].TableLoadedOnce = true; RtnCode = CFE_TBL_Register(&TblHandle1, "UT_Table1", sizeof(UT_Table1_t), CFE_TBL_OPT_CRITICAL, NULL); @@ -2160,7 +2161,7 @@ void Test_CFE_TBL_Register(void) /* a. Perform test */ UT_ClearEventHistory(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterCDSEx), 1, CFE_ES_CDS_ALREADY_EXISTS); - CFE_TBL_TaskData.CritReg[0].TableLoadedOnce = false; + CFE_TBL_Global.CritReg[0].TableLoadedOnce = false; RtnCode = CFE_TBL_Register(&TblHandle1, "UT_Table1", sizeof(UT_Table1_t), CFE_TBL_OPT_CRITICAL, NULL); @@ -2220,7 +2221,7 @@ void Test_CFE_TBL_Register(void) /* Remove all entries from critical table registry */ for (i = 0; i < CFE_PLATFORM_TBL_MAX_CRITICAL_TABLES; i++) { - CFE_TBL_TaskData.CritReg[i].CDSHandle = CFE_ES_CDS_BAD_HANDLE; + CFE_TBL_Global.CritReg[i].CDSHandle = CFE_ES_CDS_BAD_HANDLE; } RtnCode = CFE_TBL_Register(&TblHandle1, "UT_Table1", @@ -2254,7 +2255,7 @@ void Test_CFE_TBL_Register(void) /* a. Perform test */ for (i = 0; i < CFE_PLATFORM_TBL_MAX_CRITICAL_TABLES; i++) { - CFE_TBL_TaskData.CritReg[i].CDSHandle = CFE_ES_RESOURCEID_UNDEFINED; + CFE_TBL_Global.CritReg[i].CDSHandle = CFE_ES_CDS_BAD_HANDLE; } RtnCode = CFE_TBL_Register(&TblHandle1, "UT_Table1", @@ -2404,7 +2405,7 @@ void Test_CFE_TBL_Register(void) /* Test attempt to register a table with UsedFlag = false */ UT_InitData(); - CFE_TBL_TaskData.Handles[0].UsedFlag = false; + CFE_TBL_Global.Handles[0].UsedFlag = false; RtnCode = CFE_TBL_Register(&TblHandle2, "UT_Table1", sizeof(UT_Table1_t), CFE_TBL_OPT_DBL_BUFFER, NULL); @@ -2417,8 +2418,8 @@ void Test_CFE_TBL_Register(void) /* Test attempt to register a table with an invalid registry index */ UT_InitData(); - CFE_TBL_TaskData.Handles[0].UsedFlag = true; - CFE_TBL_TaskData.Handles[0].RegIndex = -1; + CFE_TBL_Global.Handles[0].UsedFlag = true; + CFE_TBL_Global.Handles[0].RegIndex = -1; RtnCode = CFE_TBL_Register(&TblHandle2, "UT_Table1", sizeof(UT_Table1_t), CFE_TBL_OPT_DBL_BUFFER, NULL); @@ -2434,7 +2435,7 @@ void Test_CFE_TBL_Register(void) for (i = 0; i < CFE_PLATFORM_TBL_MAX_NUM_TABLES; i++) { - CFE_TBL_TaskData.Registry[i].HeadOfAccessList = CFE_TBL_END_OF_LIST; + CFE_TBL_Global.Registry[i].HeadOfAccessList = CFE_TBL_END_OF_LIST; } RtnCode = CFE_TBL_Register(&TblHandle2, "UT_Table1", @@ -2454,19 +2455,19 @@ void Test_CFE_TBL_Register(void) UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 1, CFE_SEVERITY_ERROR); snprintf(TblName, CFE_MISSION_TBL_MAX_NAME_LENGTH, "UT_Table%d", CFE_PLATFORM_TBL_MAX_NUM_TABLES); - CFE_TBL_TaskData.Handles[0].UsedFlag = false; + CFE_TBL_Global.Handles[0].UsedFlag = false; RtnCode = CFE_TBL_Register(&TblHandle2, TblName, sizeof(UT_Table1_t) + 1, CFE_TBL_OPT_DBL_BUFFER, NULL); - AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle2]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[TblHandle2]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; EventsCorrect = RegRecPtr->DoubleBuffered == false && RegRecPtr->ActiveBufferIndex == 0; UT_Report(__FILE__, __LINE__, RtnCode == CFE_SEVERITY_ERROR && EventsCorrect, "CFE_TBL_Register", "Register a double buffered table with pool buffer error"); - CFE_TBL_TaskData.Handles[0].UsedFlag = true; + CFE_TBL_Global.Handles[0].UsedFlag = true; } /* @@ -2638,8 +2639,8 @@ void Test_CFE_TBL_NotifyByMessage(void) /* Set up notify by message tests */ UT_InitData(); + Test_CFE_TBL_ApiInit(); UT_SetAppID(UT_TBL_APPID_1); - CFE_TBL_EarlyInit(); UT_ResetPoolBufferIndex(); RtnCode = CFE_TBL_Register(&App1TblHandle1, "NBMsg_Tbl", @@ -2664,7 +2665,7 @@ void Test_CFE_TBL_NotifyByMessage(void) * own the table handle */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].OwnerAppId = CFE_TBL_NOT_OWNED; + CFE_TBL_Global.Registry[0].OwnerAppId = CFE_TBL_NOT_OWNED; EventsCorrect = (UT_GetNumEventsSent() == 0); RtnCode = CFE_TBL_NotifyByMessage(App1TblHandle1, CFE_SB_ValueToMsgId(1), 1, 1); UT_Report(__FILE__, __LINE__, @@ -2752,8 +2753,8 @@ void Test_CFE_TBL_Load(void) UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); UT_SetDeferredRetcode(UT_KEY(OS_read), 3, 0); - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle1]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle1]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; RegRecPtr->UserDefAddr = true; RegRecPtr->TableLoadedOnce = true; RtnCode = CFE_TBL_Load(App1TblHandle1, @@ -2826,8 +2827,8 @@ void Test_CFE_TBL_Load(void) UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); UT_SetDeferredRetcode(UT_KEY(OS_read), 3, 0); - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle2]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle2]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; RegRecPtr->DoubleBuffered = true; RegRecPtr->TableLoadedOnce = true; RtnCode = CFE_TBL_Load(App1TblHandle2, @@ -2931,8 +2932,8 @@ void Test_CFE_TBL_Load(void) /* Test attempt to load a dump-only table with the table already loaded */ UT_InitData(); - AccessDescPtr = &CFE_TBL_TaskData.Handles[DumpOnlyTblHandle]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[DumpOnlyTblHandle]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; RegRecPtr->UserDefAddr = true; RegRecPtr->TableLoadedOnce = true; RtnCode = CFE_TBL_Load(DumpOnlyTblHandle, @@ -3161,7 +3162,7 @@ void Test_CFE_TBL_GetAddresses(void) * allowed to see */ UT_InitData(); - UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); + UT_SetAppID(CFE_ES_APPID_UNDEFINED); RtnCode = CFE_TBL_GetAddresses(ArrayOfPtrsToTblPtrs, 2, ArrayOfHandles); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3208,7 +3209,7 @@ void Test_CFE_TBL_Validate(void) * not allowed to see */ UT_InitData(); - UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); + UT_SetAppID(CFE_ES_APPID_UNDEFINED); RtnCode = CFE_TBL_Validate(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3263,7 +3264,7 @@ void Test_CFE_TBL_Manage(void) /* "Load" image into inactive buffer for table */ RegIndex = CFE_TBL_FindTableInRegistry("ut_cfe_tbl.UT_Table1"); - RegRecPtr = &CFE_TBL_TaskData.Registry[RegIndex]; + RegRecPtr = &CFE_TBL_Global.Registry[RegIndex]; RtnCode = CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, false); UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_ADDRESS, &TestTable1); @@ -3280,13 +3281,13 @@ void Test_CFE_TBL_Manage(void) UT_InitData(); /* Configure table for validation */ - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; - CFE_TBL_TaskData.ValidationResults[0].Result = 0; - strncpy(CFE_TBL_TaskData.ValidationResults[0].TableName, - "ut_cfe_tbl.UT_Table1", sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1); - CFE_TBL_TaskData.ValidationResults[0].TableName[sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1] = '\0'; - CFE_TBL_TaskData.ValidationResults[0].CrcOfTable = 0; - CFE_TBL_TaskData.ValidationResults[0].ActiveBuffer = false; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 0; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, + "ut_cfe_tbl.UT_Table1", sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = false; RegRecPtr->ValidateInactiveIndex = 0; /* Perform validation via manage call */ @@ -3296,7 +3297,7 @@ void Test_CFE_TBL_Manage(void) UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_SUCCESS && EventsCorrect && - CFE_TBL_TaskData.ValidationResults[0].Result == -1, + CFE_TBL_Global.ValidationResults[0].Result == -1, "CFE_TBL_Manage", "Manage table that has a failed validation pending on " "inactive buffer (valid function return code)"); @@ -3307,13 +3308,13 @@ void Test_CFE_TBL_Manage(void) UT_InitData(); /* Configure table for validation */ - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; - CFE_TBL_TaskData.ValidationResults[0].Result = 0; - strncpy(CFE_TBL_TaskData.ValidationResults[0].TableName, - "ut_cfe_tbl.UT_Table1", sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1); - CFE_TBL_TaskData.ValidationResults[0].TableName[sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1] = '\0'; - CFE_TBL_TaskData.ValidationResults[0].CrcOfTable = 0; - CFE_TBL_TaskData.ValidationResults[0].ActiveBuffer = false; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 0; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, + "ut_cfe_tbl.UT_Table1", sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = false; RegRecPtr->ValidateInactiveIndex = 0; /* Perform validation via manage call */ @@ -3323,7 +3324,7 @@ void Test_CFE_TBL_Manage(void) UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_SUCCESS && EventsCorrect && - CFE_TBL_TaskData.ValidationResults[0].Result == 1, + CFE_TBL_Global.ValidationResults[0].Result == 1, "CFE_TBL_Manage", "Manage table that has a failed validation pending on " "inactive buffer (invalid function return code)"); @@ -3334,13 +3335,13 @@ void Test_CFE_TBL_Manage(void) UT_InitData(); /* Configure table for validation */ - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; - CFE_TBL_TaskData.ValidationResults[0].Result = 1; - strncpy(CFE_TBL_TaskData.ValidationResults[0].TableName, - "ut_cfe_tbl.UT_Table1", sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1); - CFE_TBL_TaskData.ValidationResults[0].TableName[sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1] = '\0'; - CFE_TBL_TaskData.ValidationResults[0].CrcOfTable = 0; - CFE_TBL_TaskData.ValidationResults[0].ActiveBuffer = false; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 1; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, + "ut_cfe_tbl.UT_Table1", sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = false; RegRecPtr->ValidateInactiveIndex = 0; /* Perform validation via manage call */ @@ -3350,7 +3351,7 @@ void Test_CFE_TBL_Manage(void) UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_SUCCESS && EventsCorrect && - CFE_TBL_TaskData.ValidationResults[0].Result == 0, + CFE_TBL_Global.ValidationResults[0].Result == 0, "CFE_TBL_Manage", "Manage table that has a successful validation pending on " "an inactive buffer"); @@ -3361,13 +3362,13 @@ void Test_CFE_TBL_Manage(void) UT_InitData(); /* Configure table for validation */ - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; - CFE_TBL_TaskData.ValidationResults[0].Result = 0; - strncpy(CFE_TBL_TaskData.ValidationResults[0].TableName, - "ut_cfe_tbl.UT_Table1", sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1); - CFE_TBL_TaskData.ValidationResults[0].TableName[sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1] = '\0'; - CFE_TBL_TaskData.ValidationResults[0].CrcOfTable = 0; - CFE_TBL_TaskData.ValidationResults[0].ActiveBuffer = true; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 0; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, + "ut_cfe_tbl.UT_Table1", sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = true; RegRecPtr->ValidateActiveIndex = 0; /* Perform validation via manage call */ @@ -3377,7 +3378,7 @@ void Test_CFE_TBL_Manage(void) UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_SUCCESS && EventsCorrect && - CFE_TBL_TaskData.ValidationResults[0].Result == -1, + CFE_TBL_Global.ValidationResults[0].Result == -1, "CFE_TBL_Manage", "Manage table that has an unsuccessful validation pending on " "an active buffer"); @@ -3388,13 +3389,13 @@ void Test_CFE_TBL_Manage(void) UT_InitData(); /* Configure table for validation */ - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; - CFE_TBL_TaskData.ValidationResults[0].Result = 0; - strncpy(CFE_TBL_TaskData.ValidationResults[0].TableName, - "ut_cfe_tbl.UT_Table1", sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1); - CFE_TBL_TaskData.ValidationResults[0].TableName[sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1] = '\0'; - CFE_TBL_TaskData.ValidationResults[0].CrcOfTable = 0; - CFE_TBL_TaskData.ValidationResults[0].ActiveBuffer = true; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 0; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, + "ut_cfe_tbl.UT_Table1", sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = true; RegRecPtr->ValidateActiveIndex = 0; /* Perform validation via manage call */ @@ -3404,7 +3405,7 @@ void Test_CFE_TBL_Manage(void) UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_SUCCESS && EventsCorrect && - CFE_TBL_TaskData.ValidationResults[0].Result == 1, + CFE_TBL_Global.ValidationResults[0].Result == 1, "CFE_TBL_Manage", "Manage table that has an unsuccessful validation pending " "on an active buffer"); @@ -3415,13 +3416,13 @@ void Test_CFE_TBL_Manage(void) UT_InitData(); /* Configure table for validation */ - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; - CFE_TBL_TaskData.ValidationResults[0].Result = 1; - strncpy(CFE_TBL_TaskData.ValidationResults[0].TableName, - "ut_cfe_tbl.UT_Table1", sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1); - CFE_TBL_TaskData.ValidationResults[0].TableName[sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1] = '\0'; - CFE_TBL_TaskData.ValidationResults[0].CrcOfTable = 0; - CFE_TBL_TaskData.ValidationResults[0].ActiveBuffer = true; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 1; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, + "ut_cfe_tbl.UT_Table1", sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = true; RegRecPtr->ValidateActiveIndex = 0; /* Perform validation via manage call */ @@ -3431,7 +3432,7 @@ void Test_CFE_TBL_Manage(void) UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_SUCCESS && EventsCorrect && - CFE_TBL_TaskData.ValidationResults[0].Result == 0, + CFE_TBL_Global.ValidationResults[0].Result == 0, "CFE_TBL_Manage", "Manage table that has a successful validation pending on " "an active buffer"); @@ -3469,8 +3470,8 @@ void Test_CFE_TBL_Manage(void) "Process an update request on a locked table"); /* Save the previous table's information for a subsequent test */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle1]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle1]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; AccessIterator = RegRecPtr->HeadOfAccessList; /* Test unlocking a table by releasing the address */ @@ -3508,17 +3509,17 @@ void Test_CFE_TBL_Manage(void) /* Reset the current table entry pointer to a previous table in order to * exercise the path where no buffer is available */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle2]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; - CFE_TBL_TaskData.Handles[AccessIterator].NextLink = RegRecPtr->HeadOfAccessList; - CFE_TBL_TaskData.Handles[AccessIterator].AppId = UT_TBL_APPID_2; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle2]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; + CFE_TBL_Global.Handles[AccessIterator].NextLink = RegRecPtr->HeadOfAccessList; + CFE_TBL_Global.Handles[AccessIterator].AppId = UT_TBL_APPID_2; RegRecPtr->HeadOfAccessList = AccessIterator; - CFE_TBL_TaskData.Handles[AccessIterator].BufferIndex = 1; - CFE_TBL_TaskData.Handles[AccessIterator].LockFlag = true; + CFE_TBL_Global.Handles[AccessIterator].BufferIndex = 1; + CFE_TBL_Global.Handles[AccessIterator].LockFlag = true; /* Attempt to "load" image into inactive buffer for table */ RegIndex = CFE_TBL_FindTableInRegistry("ut_cfe_tbl.UT_Table2"); - RegRecPtr = &CFE_TBL_TaskData.Registry[RegIndex]; + RegRecPtr = &CFE_TBL_Global.Registry[RegIndex]; RtnCode = CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, false); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_NO_BUFFER_AVAIL, @@ -3526,20 +3527,20 @@ void Test_CFE_TBL_Manage(void) "No buffer available"); /* Reset the table information for subsequent tests */ - CFE_TBL_TaskData.Handles[AccessIterator].BufferIndex = 1; - CFE_TBL_TaskData.Handles[AccessIterator].LockFlag = false; + CFE_TBL_Global.Handles[AccessIterator].BufferIndex = 1; + CFE_TBL_Global.Handles[AccessIterator].LockFlag = false; /* Successfully "load" image into inactive buffer for table */ RtnCode = CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, false); /* Configure table for validation */ - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; - CFE_TBL_TaskData.ValidationResults[0].Result = 0; - strncpy(CFE_TBL_TaskData.ValidationResults[0].TableName, - "ut_cfe_tbl.UT_Table2", sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1); - CFE_TBL_TaskData.ValidationResults[0].TableName[sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1] = '\0'; - CFE_TBL_TaskData.ValidationResults[0].CrcOfTable = 0; - CFE_TBL_TaskData.ValidationResults[0].ActiveBuffer = false; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 0; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, + "ut_cfe_tbl.UT_Table2", sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = false; RegRecPtr->ValidateInactiveIndex = 0; /* Perform validation via manage call */ @@ -3549,7 +3550,7 @@ void Test_CFE_TBL_Manage(void) UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_SUCCESS && EventsCorrect && - CFE_TBL_TaskData.ValidationResults[0].Result == -1, + CFE_TBL_Global.ValidationResults[0].Result == -1, "CFE_TBL_Manage", "Manage table that has a failed validation pending on an " "inactive buffer (double buffered)"); @@ -3560,13 +3561,13 @@ void Test_CFE_TBL_Manage(void) UT_InitData(); /* Configure table for validation */ - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; - CFE_TBL_TaskData.ValidationResults[0].Result = 1; - strncpy(CFE_TBL_TaskData.ValidationResults[0].TableName, - "ut_cfe_tbl.UT_Table2", sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1); - CFE_TBL_TaskData.ValidationResults[0].TableName[sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1] = '\0'; - CFE_TBL_TaskData.ValidationResults[0].CrcOfTable = 0; - CFE_TBL_TaskData.ValidationResults[0].ActiveBuffer = false; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 1; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, + "ut_cfe_tbl.UT_Table2", sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = false; RegRecPtr->ValidateInactiveIndex = 0; /* Perform validation via manage call */ @@ -3576,7 +3577,7 @@ void Test_CFE_TBL_Manage(void) UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_SUCCESS && EventsCorrect && - CFE_TBL_TaskData.ValidationResults[0].Result == 0, + CFE_TBL_Global.ValidationResults[0].Result == 0, "CFE_TBL_Manage", "Manage table that has a successful validation pending on an " "inactive buffer (double buffered)"); @@ -3587,13 +3588,13 @@ void Test_CFE_TBL_Manage(void) UT_InitData(); /* Configure table for validation */ - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; - CFE_TBL_TaskData.ValidationResults[0].Result = 0; - strncpy(CFE_TBL_TaskData.ValidationResults[0].TableName, - "ut_cfe_tbl.UT_Table2", sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1); - CFE_TBL_TaskData.ValidationResults[0].TableName[sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1] = '\0'; - CFE_TBL_TaskData.ValidationResults[0].CrcOfTable = 0; - CFE_TBL_TaskData.ValidationResults[0].ActiveBuffer = true; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 0; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, + "ut_cfe_tbl.UT_Table2", sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = true; RegRecPtr->ValidateActiveIndex = 0; /* Perform validation via manage call */ @@ -3603,7 +3604,7 @@ void Test_CFE_TBL_Manage(void) UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_SUCCESS && EventsCorrect && - CFE_TBL_TaskData.ValidationResults[0].Result == -1, + CFE_TBL_Global.ValidationResults[0].Result == -1, "CFE_TBL_Manage", "Manage table that has an unsuccessful validation pending on an " "active buffer (double buffered)"); @@ -3614,13 +3615,13 @@ void Test_CFE_TBL_Manage(void) UT_InitData(); /* Configure table for validation */ - CFE_TBL_TaskData.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; - CFE_TBL_TaskData.ValidationResults[0].Result = 1; - strncpy(CFE_TBL_TaskData.ValidationResults[0].TableName, - "ut_cfe_tbl.UT_Table2", sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1); - CFE_TBL_TaskData.ValidationResults[0].TableName[sizeof(CFE_TBL_TaskData.ValidationResults[0].TableName) - 1] = '\0'; - CFE_TBL_TaskData.ValidationResults[0].CrcOfTable = 0; - CFE_TBL_TaskData.ValidationResults[0].ActiveBuffer = true; + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 1; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, + "ut_cfe_tbl.UT_Table2", sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = true; RegRecPtr->ValidateActiveIndex = 0; /* Perform validation via manage call */ @@ -3630,7 +3631,7 @@ void Test_CFE_TBL_Manage(void) UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_SUCCESS && EventsCorrect && - CFE_TBL_TaskData.ValidationResults[0].Result == 0, + CFE_TBL_Global.ValidationResults[0].Result == 0, "CFE_TBL_Manage", "Manage table that has a successful validation pending on an " "active buffer (double buffered)"); @@ -3638,21 +3639,21 @@ void Test_CFE_TBL_Manage(void) /* Test successfully processing a table dump request */ UT_InitData(); RtnCode = CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, false); - CFE_TBL_TaskData.DumpControlBlocks[0].State = CFE_TBL_DUMP_PENDING; - CFE_TBL_TaskData.DumpControlBlocks[0].RegRecPtr = RegRecPtr; + CFE_TBL_Global.DumpControlBlocks[0].State = CFE_TBL_DUMP_PENDING; + CFE_TBL_Global.DumpControlBlocks[0].RegRecPtr = RegRecPtr; /* Save the name of the desired dump filename, table name, and size for * later */ - CFE_TBL_TaskData.DumpControlBlocks[0].DumpBufferPtr = WorkingBufferPtr; - strncpy(CFE_TBL_TaskData.DumpControlBlocks[0].DumpBufferPtr->DataSource, - "MyDumpFilename", sizeof(CFE_TBL_TaskData.DumpControlBlocks[0].DumpBufferPtr->DataSource) - 1); - CFE_TBL_TaskData.DumpControlBlocks[0].DumpBufferPtr->DataSource[ - sizeof(CFE_TBL_TaskData.DumpControlBlocks[0].DumpBufferPtr->DataSource) - 1] = 0; - strncpy(CFE_TBL_TaskData.DumpControlBlocks[0].TableName, "ut_cfe_tbl.UT_Table2", - sizeof(CFE_TBL_TaskData.DumpControlBlocks[0].TableName) - 1); - CFE_TBL_TaskData.DumpControlBlocks[0].TableName[sizeof(CFE_TBL_TaskData.DumpControlBlocks[0].TableName) - 1] = 0; - CFE_TBL_TaskData.DumpControlBlocks[0].Size = RegRecPtr->Size; + CFE_TBL_Global.DumpControlBlocks[0].DumpBufferPtr = WorkingBufferPtr; + strncpy(CFE_TBL_Global.DumpControlBlocks[0].DumpBufferPtr->DataSource, + "MyDumpFilename", sizeof(CFE_TBL_Global.DumpControlBlocks[0].DumpBufferPtr->DataSource) - 1); + CFE_TBL_Global.DumpControlBlocks[0].DumpBufferPtr->DataSource[ + sizeof(CFE_TBL_Global.DumpControlBlocks[0].DumpBufferPtr->DataSource) - 1] = 0; + strncpy(CFE_TBL_Global.DumpControlBlocks[0].TableName, "ut_cfe_tbl.UT_Table2", + sizeof(CFE_TBL_Global.DumpControlBlocks[0].TableName) - 1); + CFE_TBL_Global.DumpControlBlocks[0].TableName[sizeof(CFE_TBL_Global.DumpControlBlocks[0].TableName) - 1] = 0; + CFE_TBL_Global.DumpControlBlocks[0].Size = RegRecPtr->Size; RegRecPtr->DumpControlIndex = 0; RtnCode = CFE_TBL_Manage(App1TblHandle2); EventsCorrect = (UT_GetNumEventsSent() == 0); @@ -3702,7 +3703,7 @@ void Test_CFE_TBL_Update(void) /* Test processing an update on an application with a bad ID */ UT_InitData(); - UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); + UT_SetAppID(CFE_ES_APPID_UNDEFINED); RtnCode = CFE_TBL_Update(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, @@ -3725,7 +3726,7 @@ void Test_CFE_TBL_GetStatus(void) * application is not allowed to see */ UT_InitData(); - UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); + UT_SetAppID(CFE_ES_APPID_UNDEFINED); RtnCode = CFE_TBL_GetStatus(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3738,7 +3739,7 @@ void Test_CFE_TBL_GetStatus(void) * application is not allowed to see */ UT_InitData(); - UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); + UT_SetAppID(CFE_ES_APPID_UNDEFINED); RtnCode = CFE_TBL_DumpToBuffer(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3809,8 +3810,8 @@ void Test_CFE_TBL_TblMod(void) */ /* a. Test setup */ UT_InitData(); + Test_CFE_TBL_ApiInit(); UT_SetAppID(UT_TBL_APPID_1); - CFE_TBL_EarlyInit(); UT_ResetPoolBufferIndex(); /* Test setup for CFE_TBL_Modified; register a non critical table */ @@ -3883,8 +3884,8 @@ void Test_CFE_TBL_TblMod(void) "been updated by application"); /* Save the previous table's information for a subsequent test */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle1]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle1]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; AccessIterator = RegRecPtr->HeadOfAccessList; /* Test response to adding a TBL API for notifying table services that @@ -3907,10 +3908,10 @@ void Test_CFE_TBL_TblMod(void) /* Reset the current table entry pointer to a previous table in order to * exercise the path where one of the application IDs don't match */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle1]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; - CFE_TBL_TaskData.Handles[AccessIterator].NextLink = RegRecPtr->HeadOfAccessList; - CFE_TBL_TaskData.Handles[AccessIterator].AppId = UT_TBL_APPID_2; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle1]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; + CFE_TBL_Global.Handles[AccessIterator].NextLink = RegRecPtr->HeadOfAccessList; + CFE_TBL_Global.Handles[AccessIterator].AppId = UT_TBL_APPID_2; RegRecPtr->HeadOfAccessList = AccessIterator; /* Configure for successful file read to initialize table */ @@ -4006,8 +4007,8 @@ void Test_CFE_TBL_Internal(void) /* Test successful initial load of double buffered table */ UT_InitData(); - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle2]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle2]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; strncpy(RegRecPtr->Name, "ut_cfe_tbl.UT_Table3", sizeof(RegRecPtr->Name) - 1); RegRecPtr->Name[sizeof(RegRecPtr->Name) - 1] = '\0'; @@ -4027,8 +4028,8 @@ void Test_CFE_TBL_Internal(void) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemTake), 1, OS_ERROR); - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle1]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle1]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; RtnCode = CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, false); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -4635,14 +4636,14 @@ void Test_CFE_TBL_Internal(void) UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); UT_SetDeferredRetcode(UT_KEY(OS_read), 3, 0); UT_SetDeferredRetcode(UT_KEY(CFE_ES_CopyToCDS), 2, CFE_ES_ERR_RESOURCEID_NOT_VALID); - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle2]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle2]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; for (i = 0; i < CFE_PLATFORM_TBL_MAX_CRITICAL_TABLES; i++) { - if ( CFE_ES_ResourceID_Equal(CFE_TBL_TaskData.CritReg[i].CDSHandle, RegRecPtr->CDSHandle) ) + if ( CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_Global.CritReg[i].CDSHandle, RegRecPtr->CDSHandle) ) { - CFE_TBL_TaskData.CritReg[i].CDSHandle = CFE_ES_RESOURCEID_RESERVED; + CFE_TBL_Global.CritReg[i].CDSHandle = CFE_ES_CDSHANDLE_C(CFE_RESOURCEID_RESERVED); } } @@ -4659,7 +4660,7 @@ void Test_CFE_TBL_Internal(void) /* Test unregistering a shared table */ /* a. Share table */ UT_InitData(); - CFE_TBL_TaskData.CritReg[0].CDSHandle = RegRecPtr->CDSHandle; + CFE_TBL_Global.CritReg[0].CDSHandle = RegRecPtr->CDSHandle; UT_SetAppID(UT_TBL_APPID_2); RtnCode = CFE_TBL_Share(&App2TblHandle1, "ut_cfe_tbl.UT_Table1"); UT_Report(__FILE__, __LINE__, @@ -4680,18 +4681,18 @@ void Test_CFE_TBL_Internal(void) UT_InitData(); UT_SetAppID(UT_TBL_APPID_1); UT_SetDefaultReturnValue(UT_KEY(CFE_ES_PutPoolBuf), -1); - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle1]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; - CFE_TBL_TaskData.DumpControlBlocks[3].State = CFE_TBL_DUMP_PENDING; - CFE_TBL_TaskData.DumpControlBlocks[3].RegRecPtr = RegRecPtr; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle1]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; + CFE_TBL_Global.DumpControlBlocks[3].State = CFE_TBL_DUMP_PENDING; + CFE_TBL_Global.DumpControlBlocks[3].RegRecPtr = RegRecPtr; RegRecPtr->LoadInProgress = 1; - CFE_TBL_TaskData.LoadBuffs[1].Taken = true; + CFE_TBL_Global.LoadBuffs[1].Taken = true; CFE_TBL_CleanUpApp(UT_TBL_APPID_1); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.DumpControlBlocks[3].State == + CFE_TBL_Global.DumpControlBlocks[3].State == CFE_TBL_DUMP_FREE && - CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED) && - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].Taken == + CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED) && + CFE_TBL_Global.LoadBuffs[RegRecPtr->LoadInProgress].Taken == false && RegRecPtr->LoadInProgress == CFE_TBL_NO_LOAD_IN_PROGRESS, "CFE_TBL_CleanUpApp", @@ -4735,7 +4736,7 @@ void Test_CFE_TBL_Internal(void) * the table task application ID */ UT_InitData(); - CFE_TBL_TaskData.TableTaskAppId = UT_TBL_APPID_1; + CFE_TBL_Global.TableTaskAppId = UT_TBL_APPID_1; RtnCode = CFE_TBL_CheckAccessRights(App2TblHandle1, UT_TBL_APPID_1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -4747,8 +4748,8 @@ void Test_CFE_TBL_Internal(void) * not owned but is not at the end of the list */ UT_InitData(); - CFE_TBL_TaskData.Registry[0].OwnerAppId = CFE_TBL_NOT_OWNED; - CFE_TBL_TaskData.Registry[0].HeadOfAccessList = CFE_TBL_END_OF_LIST + 1; + CFE_TBL_Global.Registry[0].OwnerAppId = CFE_TBL_NOT_OWNED; + CFE_TBL_Global.Registry[0].HeadOfAccessList = CFE_TBL_END_OF_LIST + 1; RtnCode = CFE_TBL_FindFreeRegistryEntry(); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -4793,8 +4794,8 @@ void Test_CFE_TBL_Internal(void) * be copied but a load is in progress */ UT_InitData(); - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle2]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle2]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; RegRecPtr->LoadPending = true; RegRecPtr->LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; RtnCode = CFE_TBL_UpdateInternal(App1TblHandle2, RegRecPtr, AccessDescPtr); @@ -4808,8 +4809,8 @@ void Test_CFE_TBL_Internal(void) * be copied but a load is in progress */ UT_InitData(); - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle2]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle2]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; RegRecPtr->LoadPending = true; RegRecPtr->LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; RegRecPtr->CriticalTable = false; @@ -4827,8 +4828,8 @@ void Test_CFE_TBL_Internal(void) * source and dest are not equal */ UT_InitData(); - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle2]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle2]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; RegRecPtr->LoadPending = true; RegRecPtr->LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; RegRecPtr->DoubleBuffered = false; @@ -4845,17 +4846,17 @@ void Test_CFE_TBL_Internal(void) UT_InitData(); UT_SetAppID(UT_TBL_APPID_1); UT_SetDefaultReturnValue(UT_KEY(CFE_ES_PutPoolBuf), -1); - CFE_TBL_TaskData.Handles[0].AppId = UT_TBL_APPID_1; - AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle2]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + CFE_TBL_Global.Handles[0].AppId = UT_TBL_APPID_1; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle2]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; RegRecPtr->OwnerAppId = CFE_TBL_NOT_OWNED; - CFE_TBL_TaskData.DumpControlBlocks[3].State = CFE_TBL_DUMP_PENDING; - CFE_TBL_TaskData.DumpControlBlocks[3].RegRecPtr = RegRecPtr; + CFE_TBL_Global.DumpControlBlocks[3].State = CFE_TBL_DUMP_PENDING; + CFE_TBL_Global.DumpControlBlocks[3].RegRecPtr = RegRecPtr; CFE_TBL_CleanUpApp(UT_TBL_APPID_1); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.DumpControlBlocks[3].State == + CFE_TBL_Global.DumpControlBlocks[3].State == CFE_TBL_DUMP_PENDING && - CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED), + CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED), "CFE_TBL_CleanUpApp", "Execute clean up - no dumped tables to delete, application " "doesn't own table"); diff --git a/fsw/cfe-core/unit-test/time_UT.c b/fsw/cfe-core/unit-test/time_UT.c index 91c922c53..9bc1aa8b9 100644 --- a/fsw/cfe-core/unit-test/time_UT.c +++ b/fsw/cfe-core/unit-test/time_UT.c @@ -527,7 +527,7 @@ void Test_GetTime(void) UtPrintf("Begin Test Get Time"); - CFE_TIME_TaskData.LastVersionCounter = 0x1000; + CFE_TIME_Global.LastVersionCounter = 0x1000; /* Test successfully retrieving the mission elapsed time */ UT_InitData(); @@ -666,14 +666,14 @@ void Test_GetTime(void) RefState = CFE_TIME_StartReferenceUpdate(); RefState->ClockSetState = CFE_TIME_SetState_NOT_SET; RefState->ClockFlyState = CFE_TIME_FlywheelState_NO_FLY; - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSignal = CFE_TIME_ToneSignalSelect_REDUNDANT; - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; - CFE_TIME_TaskData.Forced2Fly = false; - CFE_TIME_TaskData.OneTimeDirection = CFE_TIME_AdjustDirection_SUBTRACT; - CFE_TIME_TaskData.OneHzDirection = CFE_TIME_AdjustDirection_SUBTRACT; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSignal = CFE_TIME_ToneSignalSelect_REDUNDANT; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; + CFE_TIME_Global.Forced2Fly = false; + CFE_TIME_Global.OneTimeDirection = CFE_TIME_AdjustDirection_SUBTRACT; + CFE_TIME_Global.OneHzDirection = CFE_TIME_AdjustDirection_SUBTRACT; RefState->DelayDirection = CFE_TIME_AdjustDirection_SUBTRACT; - CFE_TIME_TaskData.IsToneGood = false; + CFE_TIME_Global.IsToneGood = false; CFE_TIME_FinishReferenceUpdate(RefState); ActFlags = CFE_TIME_GetClockInfo(); StateFlags = 0; @@ -696,13 +696,13 @@ void Test_GetTime(void) RefState->ClockFlyState = CFE_TIME_FlywheelState_IS_FLY; RefState->DelayDirection = CFE_TIME_AdjustDirection_ADD; CFE_TIME_FinishReferenceUpdate(RefState); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_INTERNAL; - CFE_TIME_TaskData.ClockSignal = CFE_TIME_ToneSignalSelect_PRIMARY; - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; - CFE_TIME_TaskData.Forced2Fly = true; - CFE_TIME_TaskData.OneTimeDirection = CFE_TIME_AdjustDirection_ADD; - CFE_TIME_TaskData.OneHzDirection = CFE_TIME_AdjustDirection_ADD; - CFE_TIME_TaskData.IsToneGood = true; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_INTERNAL; + CFE_TIME_Global.ClockSignal = CFE_TIME_ToneSignalSelect_PRIMARY; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; + CFE_TIME_Global.Forced2Fly = true; + CFE_TIME_Global.OneTimeDirection = CFE_TIME_AdjustDirection_ADD; + CFE_TIME_Global.OneHzDirection = CFE_TIME_AdjustDirection_ADD; + CFE_TIME_Global.IsToneGood = true; StateFlags = CFE_TIME_FLAG_CLKSET | CFE_TIME_FLAG_FLYING | @@ -1201,7 +1201,7 @@ void Test_RegisterSyncCallbackTrue(void) UT_InitData(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetAppID), 1, -1); - CFE_TIME_TaskData.SynchCallback[0].Ptr = NULL; + CFE_TIME_Global.SynchCallback[0].Ptr = NULL; Result = CFE_TIME_RegisterSynchCallback(&ut_time_MyCallbackFunc); UT_Report(__FILE__, __LINE__, @@ -1265,12 +1265,12 @@ void Test_ExternalTone(void) UT_InitData(); UT_SetBSP_Time(123, 0); - CFE_TIME_TaskData.ToneSignalLatch.Seconds = 0; - CFE_TIME_TaskData.ToneSignalLatch.Subseconds = 0; + CFE_TIME_Global.ToneSignalLatch.Seconds = 0; + CFE_TIME_Global.ToneSignalLatch.Subseconds = 0; CFE_TIME_ExternalTone(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneSignalLatch.Seconds == 123 && - CFE_TIME_TaskData.ToneSignalLatch.Subseconds == 0, + CFE_TIME_Global.ToneSignalLatch.Seconds == 123 && + CFE_TIME_Global.ToneSignalLatch.Subseconds == 0, "CFE_TIME_ExternalTone", "External tone"); } @@ -1294,14 +1294,14 @@ void Test_External(void) * state not set */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_NOT_SET; - CFE_TIME_TaskData.ExternalCount = 0; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_NOT_SET; + CFE_TIME_Global.ExternalCount = 0; settime.Seconds = 0; settime.Subseconds = 0; CFE_TIME_ExternalMET(settime); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ExternalCount == 1, + CFE_TIME_Global.ExternalCount == 1, "CFE_TIME_ExternalMET", "External MET - external source and clock state not set"); @@ -1309,25 +1309,25 @@ void Test_External(void) * state set and time less than the minimum */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_WAS_SET; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_WAS_SET; settime.Seconds = 0; settime.Subseconds = 0; - CFE_TIME_TaskData.InternalCount = 0; - CFE_TIME_TaskData.AtToneMET.Seconds = 10; - CFE_TIME_TaskData.AtToneMET.Subseconds = 0; - CFE_TIME_TaskData.AtToneDelay.Seconds = 0; - CFE_TIME_TaskData.AtToneDelay.Subseconds = 0; - CFE_TIME_TaskData.AtToneLatch.Seconds = 0; - CFE_TIME_TaskData.AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.MaxDelta.Seconds = 0; - CFE_TIME_TaskData.MaxDelta.Subseconds = 1; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.InternalCount = 0; + CFE_TIME_Global.AtToneMET.Seconds = 10; + CFE_TIME_Global.AtToneMET.Subseconds = 0; + CFE_TIME_Global.AtToneDelay.Seconds = 0; + CFE_TIME_Global.AtToneDelay.Subseconds = 0; + CFE_TIME_Global.AtToneLatch.Seconds = 0; + CFE_TIME_Global.AtToneLatch.Subseconds = 0; + CFE_TIME_Global.MaxDelta.Seconds = 0; + CFE_TIME_Global.MaxDelta.Subseconds = 1; + CFE_TIME_Global.MaxLocalClock.Seconds = 0; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; UT_SetBSP_Time(0, 0); CFE_TIME_ExternalMET(settime); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.InternalCount == 1, + CFE_TIME_Global.InternalCount == 1, "CFE_TIME_ExternalMET", "External MET - external source and time out of range (low)"); @@ -1335,59 +1335,59 @@ void Test_External(void) * state set and time greater than the maximum */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_WAS_SET; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_WAS_SET; settime.Seconds = 20; settime.Subseconds = 0; - CFE_TIME_TaskData.InternalCount = 0; - CFE_TIME_TaskData.AtToneMET.Seconds = 10; - CFE_TIME_TaskData.AtToneMET.Subseconds = 0; - CFE_TIME_TaskData.AtToneDelay.Seconds = 0; - CFE_TIME_TaskData.AtToneDelay.Subseconds = 0; - CFE_TIME_TaskData.AtToneLatch.Seconds = 0; - CFE_TIME_TaskData.AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.MaxDelta.Seconds = 0; - CFE_TIME_TaskData.MaxDelta.Subseconds = 1; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.InternalCount = 0; + CFE_TIME_Global.AtToneMET.Seconds = 10; + CFE_TIME_Global.AtToneMET.Subseconds = 0; + CFE_TIME_Global.AtToneDelay.Seconds = 0; + CFE_TIME_Global.AtToneDelay.Subseconds = 0; + CFE_TIME_Global.AtToneLatch.Seconds = 0; + CFE_TIME_Global.AtToneLatch.Subseconds = 0; + CFE_TIME_Global.MaxDelta.Seconds = 0; + CFE_TIME_Global.MaxDelta.Subseconds = 1; + CFE_TIME_Global.MaxLocalClock.Seconds = 0; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; UT_SetBSP_Time(0, 0); CFE_TIME_ExternalMET(settime); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.InternalCount == 1, + CFE_TIME_Global.InternalCount == 1, "CFE_TIME_ExternalMET", "External MET - external source and time out of range (high)"); /* Test setting time data from MET (external source, state set) */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_WAS_SET; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_WAS_SET; settime.Seconds = 10; settime.Subseconds = 0; - CFE_TIME_TaskData.ExternalCount = 0; - CFE_TIME_TaskData.AtToneMET.Seconds = 10; - CFE_TIME_TaskData.AtToneMET.Subseconds = 0; - CFE_TIME_TaskData.AtToneDelay.Seconds = 0; - CFE_TIME_TaskData.AtToneDelay.Subseconds = 0; - CFE_TIME_TaskData.AtToneLatch.Seconds = 0; - CFE_TIME_TaskData.AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.MaxDelta.Seconds = 0; - CFE_TIME_TaskData.MaxDelta.Subseconds = 1; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.ExternalCount = 0; + CFE_TIME_Global.AtToneMET.Seconds = 10; + CFE_TIME_Global.AtToneMET.Subseconds = 0; + CFE_TIME_Global.AtToneDelay.Seconds = 0; + CFE_TIME_Global.AtToneDelay.Subseconds = 0; + CFE_TIME_Global.AtToneLatch.Seconds = 0; + CFE_TIME_Global.AtToneLatch.Subseconds = 0; + CFE_TIME_Global.MaxDelta.Seconds = 0; + CFE_TIME_Global.MaxDelta.Subseconds = 1; + CFE_TIME_Global.MaxLocalClock.Seconds = 0; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; UT_SetBSP_Time(0, 0); CFE_TIME_ExternalMET(settime); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ExternalCount == 1, + CFE_TIME_Global.ExternalCount == 1, "CFE_TIME_ExternalMET", "External MET - external source and time in range"); /* Test setting time data from MET (internal source) */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_INTERNAL; - CFE_TIME_TaskData.InternalCount = 0; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_INTERNAL; + CFE_TIME_Global.InternalCount = 0; CFE_TIME_ExternalMET(settime); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.InternalCount == 1, + CFE_TIME_Global.InternalCount == 1, "CFE_TIME_ExternalMET", "External MET (internal source)"); #else @@ -1425,14 +1425,14 @@ void Test_External(void) * state not set */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_NOT_SET; - CFE_TIME_TaskData.ExternalCount = 0; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_NOT_SET; + CFE_TIME_Global.ExternalCount = 0; settime.Seconds = 0; settime.Subseconds = 0; CFE_TIME_ExternalGPS(settime, 0); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ExternalCount == 1, + CFE_TIME_Global.ExternalCount == 1, "CFE_TIME_ExternalGPS", "External GPS - external source and clock state not set"); @@ -1440,27 +1440,27 @@ void Test_External(void) * state set and time less than the minimum */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_WAS_SET; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_WAS_SET; settime.Seconds = 0; settime.Subseconds = 0; - CFE_TIME_TaskData.InternalCount = 0; - CFE_TIME_TaskData.AtToneMET.Seconds = 0; - CFE_TIME_TaskData.AtToneMET.Subseconds = 0; - CFE_TIME_TaskData.AtToneSTCF.Seconds = 10; - CFE_TIME_TaskData.AtToneSTCF.Subseconds = 0; - CFE_TIME_TaskData.AtToneDelay.Seconds = 0; - CFE_TIME_TaskData.AtToneDelay.Subseconds = 0; - CFE_TIME_TaskData.AtToneLatch.Seconds = 0; - CFE_TIME_TaskData.AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.MaxDelta.Seconds = 0; - CFE_TIME_TaskData.MaxDelta.Subseconds = 1; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.InternalCount = 0; + CFE_TIME_Global.AtToneMET.Seconds = 0; + CFE_TIME_Global.AtToneMET.Subseconds = 0; + CFE_TIME_Global.AtToneSTCF.Seconds = 10; + CFE_TIME_Global.AtToneSTCF.Subseconds = 0; + CFE_TIME_Global.AtToneDelay.Seconds = 0; + CFE_TIME_Global.AtToneDelay.Subseconds = 0; + CFE_TIME_Global.AtToneLatch.Seconds = 0; + CFE_TIME_Global.AtToneLatch.Subseconds = 0; + CFE_TIME_Global.MaxDelta.Seconds = 0; + CFE_TIME_Global.MaxDelta.Subseconds = 1; + CFE_TIME_Global.MaxLocalClock.Seconds = 0; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; UT_SetBSP_Time(0, 0); CFE_TIME_ExternalGPS(settime, 0); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.InternalCount == 1, + CFE_TIME_Global.InternalCount == 1, "CFE_TIME_ExternalGPS", "External GPS - external source and time out of range (low)"); @@ -1468,63 +1468,63 @@ void Test_External(void) * state set and time greater than the maximum */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_WAS_SET; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_WAS_SET; settime.Seconds = 20; settime.Subseconds = 0; - CFE_TIME_TaskData.InternalCount = 0; - CFE_TIME_TaskData.AtToneMET.Seconds = 0; - CFE_TIME_TaskData.AtToneMET.Subseconds = 0; - CFE_TIME_TaskData.AtToneSTCF.Seconds = 10; - CFE_TIME_TaskData.AtToneSTCF.Subseconds = 0; - CFE_TIME_TaskData.AtToneDelay.Seconds = 0; - CFE_TIME_TaskData.AtToneDelay.Subseconds = 0; - CFE_TIME_TaskData.AtToneLatch.Seconds = 0; - CFE_TIME_TaskData.AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.MaxDelta.Seconds = 0; - CFE_TIME_TaskData.MaxDelta.Subseconds = 1; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.InternalCount = 0; + CFE_TIME_Global.AtToneMET.Seconds = 0; + CFE_TIME_Global.AtToneMET.Subseconds = 0; + CFE_TIME_Global.AtToneSTCF.Seconds = 10; + CFE_TIME_Global.AtToneSTCF.Subseconds = 0; + CFE_TIME_Global.AtToneDelay.Seconds = 0; + CFE_TIME_Global.AtToneDelay.Subseconds = 0; + CFE_TIME_Global.AtToneLatch.Seconds = 0; + CFE_TIME_Global.AtToneLatch.Subseconds = 0; + CFE_TIME_Global.MaxDelta.Seconds = 0; + CFE_TIME_Global.MaxDelta.Subseconds = 1; + CFE_TIME_Global.MaxLocalClock.Seconds = 0; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; UT_SetBSP_Time(0, 0); CFE_TIME_ExternalGPS(settime, 0); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.InternalCount == 1, + CFE_TIME_Global.InternalCount == 1, "CFE_TIME_ExternalGPS", "External GPS - external source and time out of range (high)"); /* Test setting time data from GPS (external source, state set) */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_WAS_SET; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_WAS_SET; settime.Seconds = 10; settime.Subseconds = 0; - CFE_TIME_TaskData.ExternalCount = 0; - CFE_TIME_TaskData.AtToneMET.Seconds = 0; - CFE_TIME_TaskData.AtToneMET.Subseconds = 0; - CFE_TIME_TaskData.AtToneSTCF.Seconds = 10; - CFE_TIME_TaskData.AtToneSTCF.Subseconds = 0; - CFE_TIME_TaskData.AtToneDelay.Seconds = 0; - CFE_TIME_TaskData.AtToneDelay.Subseconds = 0; - CFE_TIME_TaskData.AtToneLatch.Seconds = 0; - CFE_TIME_TaskData.AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.MaxDelta.Seconds = 0; - CFE_TIME_TaskData.MaxDelta.Subseconds = 1; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.ExternalCount = 0; + CFE_TIME_Global.AtToneMET.Seconds = 0; + CFE_TIME_Global.AtToneMET.Subseconds = 0; + CFE_TIME_Global.AtToneSTCF.Seconds = 10; + CFE_TIME_Global.AtToneSTCF.Subseconds = 0; + CFE_TIME_Global.AtToneDelay.Seconds = 0; + CFE_TIME_Global.AtToneDelay.Subseconds = 0; + CFE_TIME_Global.AtToneLatch.Seconds = 0; + CFE_TIME_Global.AtToneLatch.Subseconds = 0; + CFE_TIME_Global.MaxDelta.Seconds = 0; + CFE_TIME_Global.MaxDelta.Subseconds = 1; + CFE_TIME_Global.MaxLocalClock.Seconds = 0; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; UT_SetBSP_Time(0, 0); CFE_TIME_ExternalGPS(settime, 0); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ExternalCount == 1, + CFE_TIME_Global.ExternalCount == 1, "CFE_TIME_ExternalGPS", "External GPS - external source and time in range"); /* Test setting time data from GPS (internal source) */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_INTERNAL; - CFE_TIME_TaskData.InternalCount = 0; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_INTERNAL; + CFE_TIME_Global.InternalCount = 0; CFE_TIME_ExternalGPS(settime, 0); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.InternalCount == 1, + CFE_TIME_Global.InternalCount == 1, "CFE_TIME_ExternalGPS", "External GPS (internal source)"); #else @@ -1562,14 +1562,14 @@ void Test_External(void) * state not set */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_NOT_SET; - CFE_TIME_TaskData.ExternalCount = 0; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_NOT_SET; + CFE_TIME_Global.ExternalCount = 0; settime.Seconds = 0; settime.Subseconds = 0; CFE_TIME_ExternalTime(settime); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ExternalCount == 1, + CFE_TIME_Global.ExternalCount == 1, "CFE_TIME_ExternalTime", "External Time - external source and clock state not set"); @@ -1577,27 +1577,27 @@ void Test_External(void) * state set and time less than the minimum */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_WAS_SET; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_WAS_SET; settime.Seconds = 0; settime.Subseconds = 0; - CFE_TIME_TaskData.InternalCount = 0; - CFE_TIME_TaskData.AtToneMET.Seconds = 0; - CFE_TIME_TaskData.AtToneMET.Subseconds = 0; - CFE_TIME_TaskData.AtToneSTCF.Seconds = 10; - CFE_TIME_TaskData.AtToneSTCF.Subseconds = 0; - CFE_TIME_TaskData.AtToneDelay.Seconds = 0; - CFE_TIME_TaskData.AtToneDelay.Subseconds = 0; - CFE_TIME_TaskData.AtToneLatch.Seconds = 0; - CFE_TIME_TaskData.AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.MaxDelta.Seconds = 0; - CFE_TIME_TaskData.MaxDelta.Subseconds = 1; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.InternalCount = 0; + CFE_TIME_Global.AtToneMET.Seconds = 0; + CFE_TIME_Global.AtToneMET.Subseconds = 0; + CFE_TIME_Global.AtToneSTCF.Seconds = 10; + CFE_TIME_Global.AtToneSTCF.Subseconds = 0; + CFE_TIME_Global.AtToneDelay.Seconds = 0; + CFE_TIME_Global.AtToneDelay.Subseconds = 0; + CFE_TIME_Global.AtToneLatch.Seconds = 0; + CFE_TIME_Global.AtToneLatch.Subseconds = 0; + CFE_TIME_Global.MaxDelta.Seconds = 0; + CFE_TIME_Global.MaxDelta.Subseconds = 1; + CFE_TIME_Global.MaxLocalClock.Seconds = 0; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; UT_SetBSP_Time(0, 0); CFE_TIME_ExternalTime(settime); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.InternalCount == 1, + CFE_TIME_Global.InternalCount == 1, "CFE_TIME_ExternalTime", "External Time - external source and time out of range (low)"); @@ -1605,63 +1605,63 @@ void Test_External(void) * state set and time greater than the maximum */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_WAS_SET; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_WAS_SET; settime.Seconds = 20; settime.Subseconds = 0; - CFE_TIME_TaskData.InternalCount = 0; - CFE_TIME_TaskData.AtToneMET.Seconds = 0; - CFE_TIME_TaskData.AtToneMET.Subseconds = 0; - CFE_TIME_TaskData.AtToneSTCF.Seconds = 10; - CFE_TIME_TaskData.AtToneSTCF.Subseconds = 0; - CFE_TIME_TaskData.AtToneDelay.Seconds = 0; - CFE_TIME_TaskData.AtToneDelay.Subseconds = 0; - CFE_TIME_TaskData.AtToneLatch.Seconds = 0; - CFE_TIME_TaskData.AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.MaxDelta.Seconds = 0; - CFE_TIME_TaskData.MaxDelta.Subseconds = 1; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.InternalCount = 0; + CFE_TIME_Global.AtToneMET.Seconds = 0; + CFE_TIME_Global.AtToneMET.Subseconds = 0; + CFE_TIME_Global.AtToneSTCF.Seconds = 10; + CFE_TIME_Global.AtToneSTCF.Subseconds = 0; + CFE_TIME_Global.AtToneDelay.Seconds = 0; + CFE_TIME_Global.AtToneDelay.Subseconds = 0; + CFE_TIME_Global.AtToneLatch.Seconds = 0; + CFE_TIME_Global.AtToneLatch.Subseconds = 0; + CFE_TIME_Global.MaxDelta.Seconds = 0; + CFE_TIME_Global.MaxDelta.Subseconds = 1; + CFE_TIME_Global.MaxLocalClock.Seconds = 0; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; UT_SetBSP_Time(0, 0); CFE_TIME_ExternalTime(settime); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.InternalCount == 1, + CFE_TIME_Global.InternalCount == 1, "CFE_TIME_ExternalTime", "External Time - external source and time out of range (high)"); /* Test setting time data from Time (external source, state set) */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_WAS_SET; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_WAS_SET; settime.Seconds = 10; settime.Subseconds = 0; - CFE_TIME_TaskData.ExternalCount = 0; - CFE_TIME_TaskData.AtToneMET.Seconds = 0; - CFE_TIME_TaskData.AtToneMET.Subseconds = 0; - CFE_TIME_TaskData.AtToneSTCF.Seconds = 10; - CFE_TIME_TaskData.AtToneSTCF.Subseconds = 0; - CFE_TIME_TaskData.AtToneDelay.Seconds = 0; - CFE_TIME_TaskData.AtToneDelay.Subseconds = 0; - CFE_TIME_TaskData.AtToneLatch.Seconds = 0; - CFE_TIME_TaskData.AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.MaxDelta.Seconds = 0; - CFE_TIME_TaskData.MaxDelta.Subseconds = 1; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.ExternalCount = 0; + CFE_TIME_Global.AtToneMET.Seconds = 0; + CFE_TIME_Global.AtToneMET.Subseconds = 0; + CFE_TIME_Global.AtToneSTCF.Seconds = 10; + CFE_TIME_Global.AtToneSTCF.Subseconds = 0; + CFE_TIME_Global.AtToneDelay.Seconds = 0; + CFE_TIME_Global.AtToneDelay.Subseconds = 0; + CFE_TIME_Global.AtToneLatch.Seconds = 0; + CFE_TIME_Global.AtToneLatch.Subseconds = 0; + CFE_TIME_Global.MaxDelta.Seconds = 0; + CFE_TIME_Global.MaxDelta.Subseconds = 1; + CFE_TIME_Global.MaxLocalClock.Seconds = 0; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; UT_SetBSP_Time(0, 0); CFE_TIME_ExternalTime(settime); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ExternalCount == 1, + CFE_TIME_Global.ExternalCount == 1, "CFE_TIME_ExternalTime", "External Time - external source and time in range"); /* Test setting time data from Time (internal source) */ UT_InitData(); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_INTERNAL; - CFE_TIME_TaskData.InternalCount = 0; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_INTERNAL; + CFE_TIME_Global.InternalCount = 0; CFE_TIME_ExternalTime(settime); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.InternalCount == 1, + CFE_TIME_Global.InternalCount == 1, "CFE_TIME_ExternalTime", "External Time (internal source)"); #else @@ -1695,7 +1695,7 @@ void Test_External(void) #endif /* Reset to normal value for subsequent tests */ - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_INTERNAL; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_INTERNAL; } /* @@ -1752,22 +1752,22 @@ void Test_PipeCmds(void) /* Test sending the time at the tone "signal" command */ UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - CFE_TIME_TaskData.ToneSignalCounter = 0; + CFE_TIME_Global.ToneSignalCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.cmd), UT_TPID_CFE_TIME_TONE_CMD); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneSignalCounter == 1, + CFE_TIME_Global.ToneSignalCounter == 1, "CFE_TIME_ToneSignalCmd", "Time at tone signal"); /* Test sending the time at the tone "data" command */ UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - CFE_TIME_TaskData.ToneDataCounter = 0; + CFE_TIME_Global.ToneDataCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.tonedatacmd), UT_TPID_CFE_TIME_DATA_CMD); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneDataCounter == 1, + CFE_TIME_Global.ToneDataCounter == 1, "CFE_TIME_ToneDataCmd", "Time at tone data"); @@ -1775,12 +1775,12 @@ void Test_PipeCmds(void) UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); UT_SetBSP_Time(123, 0); - CFE_TIME_TaskData.ToneSignalLatch.Seconds = 0; - CFE_TIME_TaskData.ToneSignalLatch.Subseconds = 0; + CFE_TIME_Global.ToneSignalLatch.Seconds = 0; + CFE_TIME_Global.ToneSignalLatch.Subseconds = 0; CFE_TIME_Tone1HzISR(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneSignalLatch.Seconds == 123 && - CFE_TIME_TaskData.ToneSignalLatch.Subseconds == 0, + CFE_TIME_Global.ToneSignalLatch.Seconds == 123 && + CFE_TIME_Global.ToneSignalLatch.Subseconds == 0, "CFE_TIME_FakeToneCmd", "Simulated time at tone signal"); @@ -1789,7 +1789,7 @@ void Test_PipeCmds(void) memset(&CmdBuf, 0, sizeof(CmdBuf)); #if (CFE_PLATFORM_TIME_CFG_SERVER == true) - count = CFE_TIME_TaskData.InternalCount; + count = CFE_TIME_Global.InternalCount; #endif UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.cmd), @@ -1798,7 +1798,7 @@ void Test_PipeCmds(void) #if (CFE_PLATFORM_TIME_CFG_SERVER == true) UT_Report(__FILE__, __LINE__, !UT_EventIsInHistory(CFE_TIME_ID_ERR_EID) && - CFE_TIME_TaskData.InternalCount == count + 1, + CFE_TIME_Global.InternalCount == count + 1, "CFE_TIME_ToneSendCmd", "Request time at tone data"); #else @@ -1938,22 +1938,22 @@ void Test_PipeCmds(void) UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); CmdBuf.signalcmd.Payload.ToneSource = CFE_TIME_ToneSignalSelect_PRIMARY; - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.signalcmd), UT_TPID_CFE_TIME_CMD_SET_SIGNAL_CC); #if (CFE_PLATFORM_TIME_CFG_SIGNAL == true) UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_SIGNAL_EID) && - CFE_TIME_TaskData.CommandCounter == 1 && - CFE_TIME_TaskData.CommandErrorCounter == 0, + CFE_TIME_Global.CommandCounter == 1 && + CFE_TIME_Global.CommandErrorCounter == 0, "CFE_TIME_SetSignalCmd", "Set tone signal source = primary"); #else UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_SIGNAL_CFG_EID) && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_SetSignalCmd", "Set tone source = primary invalid"); #endif @@ -1962,22 +1962,22 @@ void Test_PipeCmds(void) UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); CmdBuf.signalcmd.Payload.ToneSource = CFE_TIME_ToneSignalSelect_REDUNDANT; - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.signalcmd), UT_TPID_CFE_TIME_CMD_SET_SIGNAL_CC); #if (CFE_PLATFORM_TIME_CFG_SIGNAL == true) UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_SIGNAL_EID) && - CFE_TIME_TaskData.CommandCounter == 1 && - CFE_TIME_TaskData.CommandErrorCounter == 0, + CFE_TIME_Global.CommandCounter == 1 && + CFE_TIME_Global.CommandErrorCounter == 0, "CFE_TIME_SetSignalCmd", "Set tone signal source = redundant"); #else UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_SIGNAL_CFG_EID) && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_SetSignalCmd", "Set tone signal source = redundant invalid"); #endif @@ -1988,12 +1988,12 @@ void Test_PipeCmds(void) UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); CmdBuf.signalcmd.Payload.ToneSource = -1; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.signalcmd), UT_TPID_CFE_TIME_CMD_SET_SIGNAL_CC); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_SIGNAL_ERR_EID) && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_SetSignalCmd", "Invalid tone source"); @@ -2002,23 +2002,23 @@ void Test_PipeCmds(void) memset(&CmdBuf, 0, sizeof(CmdBuf)); CmdBuf.adddelaycmd.Payload.MicroSeconds = 0; CmdBuf.adddelaycmd.Payload.Seconds = 0; - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.adddelaycmd), UT_TPID_CFE_TIME_CMD_ADD_DELAY_CC); #if (CFE_PLATFORM_TIME_CFG_CLIENT == true) UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_DELAY_EID) && - CFE_TIME_TaskData.CommandCounter == 1 && - CFE_TIME_TaskData.CommandErrorCounter == 0, + CFE_TIME_Global.CommandCounter == 1 && + CFE_TIME_Global.CommandErrorCounter == 0, "CFE_TIME_SetDelayCmd", "Set tone add delay"); #else UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_DELAY_CFG_EID) && - CFE_TIME_TaskData.CommandCounter == 0 && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandCounter == 0 && + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_SetDelayCmd", "Set tone add delay invalid"); #endif @@ -2026,23 +2026,23 @@ void Test_PipeCmds(void) /* Test sending a time tone subtract delay command */ UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.subdelaycmd), UT_TPID_CFE_TIME_CMD_SUB_DELAY_CC); #if (CFE_PLATFORM_TIME_CFG_CLIENT == true) UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_DELAY_EID) && - CFE_TIME_TaskData.CommandCounter == 1 && - CFE_TIME_TaskData.CommandErrorCounter == 0, + CFE_TIME_Global.CommandCounter == 1 && + CFE_TIME_Global.CommandErrorCounter == 0, "CFE_TIME_SetDelayCmd", "Set tone subtract delay"); #else UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_DELAY_CFG_EID) && - CFE_TIME_TaskData.CommandCounter == 0 && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandCounter == 0 && + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_SetDelayCmd", "Set subtract delay invalid"); #endif @@ -2050,23 +2050,23 @@ void Test_PipeCmds(void) /* Test sending a set time command */ UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.settimecmd), UT_TPID_CFE_TIME_CMD_SET_TIME_CC); #if (CFE_PLATFORM_TIME_CFG_SERVER == true) UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_TIME_EID) && - CFE_TIME_TaskData.CommandCounter == 1 && - CFE_TIME_TaskData.CommandErrorCounter == 0, + CFE_TIME_Global.CommandCounter == 1 && + CFE_TIME_Global.CommandErrorCounter == 0, "CFE_TIME_SetTimeCmd", "Set time"); #else UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_TIME_CFG_EID) && - CFE_TIME_TaskData.CommandCounter == 0 && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandCounter == 0 && + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_SetTimeCmd", "Set time invalid"); #endif @@ -2074,23 +2074,23 @@ void Test_PipeCmds(void) /* Test sending a set MET command */ UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.setmetcmd), UT_TPID_CFE_TIME_CMD_SET_MET_CC); #if (CFE_PLATFORM_TIME_CFG_SERVER == true) UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_MET_EID) && - CFE_TIME_TaskData.CommandCounter == 1 && - CFE_TIME_TaskData.CommandErrorCounter == 0, + CFE_TIME_Global.CommandCounter == 1 && + CFE_TIME_Global.CommandErrorCounter == 0, "CFE_TIME_SetMETCmd", "Set MET"); #else UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_MET_CFG_EID) && - CFE_TIME_TaskData.CommandCounter == 0 && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandCounter == 0 && + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_SetMETCmd", "Set MET invalid"); #endif @@ -2098,23 +2098,23 @@ void Test_PipeCmds(void) /* Test sending a set STCF command */ UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.setstcfcmd), UT_TPID_CFE_TIME_CMD_SET_STCF_CC); #if (CFE_PLATFORM_TIME_CFG_SERVER == true) UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_STCF_EID) && - CFE_TIME_TaskData.CommandCounter == 1 && - CFE_TIME_TaskData.CommandErrorCounter == 0, + CFE_TIME_Global.CommandCounter == 1 && + CFE_TIME_Global.CommandErrorCounter == 0, "CFE_TIME_SetSTCFCmd", "Set STCF"); #else UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_STCF_CFG_EID) && - CFE_TIME_TaskData.CommandCounter == 0 && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandCounter == 0 && + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_SetSTCFCmd", "Set STCF invalid"); #endif @@ -2122,23 +2122,23 @@ void Test_PipeCmds(void) /* Test sending an adjust STCF positive command */ UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.addadjcmd), UT_TPID_CFE_TIME_CMD_ADD_ADJUST_CC); #if (CFE_PLATFORM_TIME_CFG_SERVER == true) UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_DELTA_EID) && - CFE_TIME_TaskData.CommandCounter == 1 && - CFE_TIME_TaskData.CommandErrorCounter == 0, + CFE_TIME_Global.CommandCounter == 1 && + CFE_TIME_Global.CommandErrorCounter == 0, "CFE_TIME_AdjustCmd", "Set STCF adjust positive"); #else UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_DELTA_CFG_EID) && - CFE_TIME_TaskData.CommandCounter == 0 && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandCounter == 0 && + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_AdjustCmd", "Set STCF adjust positive invalid"); #endif @@ -2146,23 +2146,23 @@ void Test_PipeCmds(void) /* Test sending an adjust STCF negative command */ UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.subadjcmd), UT_TPID_CFE_TIME_CMD_SUB_ADJUST_CC); #if (CFE_PLATFORM_TIME_CFG_SERVER == true) UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_DELTA_EID) && - CFE_TIME_TaskData.CommandCounter == 1 && - CFE_TIME_TaskData.CommandErrorCounter == 0, + CFE_TIME_Global.CommandCounter == 1 && + CFE_TIME_Global.CommandErrorCounter == 0, "CFE_TIME_AdjustCmd", "Set STCF adjust negative"); #else UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_DELTA_CFG_EID) && - CFE_TIME_TaskData.CommandCounter == 0 && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandCounter == 0 && + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_AdjustCmd", "Set STCF adjust negative invalid"); #endif @@ -2170,23 +2170,23 @@ void Test_PipeCmds(void) /* Test sending an adjust STCF 1 Hz positive command */ UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.add1hzadjcmd), UT_TPID_CFE_TIME_CMD_ADD_1HZ_ADJUSTMENT_CC); #if (CFE_PLATFORM_TIME_CFG_SERVER == true) UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_1HZ_EID) && - CFE_TIME_TaskData.CommandCounter == 1 && - CFE_TIME_TaskData.CommandErrorCounter == 0, + CFE_TIME_Global.CommandCounter == 1 && + CFE_TIME_Global.CommandErrorCounter == 0, "CFE_TIME_1HzAdjCmd", "Set STCF 1Hz adjust positive"); #else UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_1HZ_CFG_EID) && - CFE_TIME_TaskData.CommandCounter == 0 && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandCounter == 0 && + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_1HzAdjCmd", "Set STCF 1Hz adjust positive invalid"); #endif @@ -2194,23 +2194,23 @@ void Test_PipeCmds(void) /* Test sending an adjust STCF 1 Hz negative command */ UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.sub1hzadjcmd), UT_TPID_CFE_TIME_CMD_SUB_1HZ_ADJUSTMENT_CC); #if (CFE_PLATFORM_TIME_CFG_SERVER == true) UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_1HZ_EID) && - CFE_TIME_TaskData.CommandCounter == 1 && - CFE_TIME_TaskData.CommandErrorCounter == 0, + CFE_TIME_Global.CommandCounter == 1 && + CFE_TIME_Global.CommandErrorCounter == 0, "CFE_TIME_1HzAdjCmd", "Set STCF 1Hz adjust negative"); #else UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_1HZ_CFG_EID) && - CFE_TIME_TaskData.CommandCounter == 0 && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandCounter == 0 && + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_1HzAdjCmd", "Set STCF 1Hz adjust negative invalid"); #endif @@ -2273,8 +2273,8 @@ void Test_PipeCmds(void) /* Test sending a set leap seconds commands */ UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - CFE_TIME_TaskData.CommandCounter = 0; - CFE_TIME_TaskData.CommandErrorCounter = 0; + CFE_TIME_Global.CommandCounter = 0; + CFE_TIME_Global.CommandErrorCounter = 0; CmdBuf.leapscmd.Payload.LeapSeconds = 0; UT_CallTaskPipe(CFE_TIME_TaskPipe, &CmdBuf.message, sizeof(CmdBuf.leapscmd), UT_TPID_CFE_TIME_CMD_SET_LEAP_SECONDS_CC); @@ -2282,15 +2282,15 @@ void Test_PipeCmds(void) #if (CFE_PLATFORM_TIME_CFG_SERVER == true) UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_LEAPS_EID) && - CFE_TIME_TaskData.CommandCounter == 1 && - CFE_TIME_TaskData.CommandErrorCounter == 0, + CFE_TIME_Global.CommandCounter == 1 && + CFE_TIME_Global.CommandErrorCounter == 0, "CFE_TIME_SetLeapSecondsCmd", "Set leap seconds"); #else UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_TIME_LEAPS_CFG_EID) && - CFE_TIME_TaskData.CommandCounter == 0 && - CFE_TIME_TaskData.CommandErrorCounter == 1, + CFE_TIME_Global.CommandCounter == 0 && + CFE_TIME_Global.CommandErrorCounter == 1, "CFE_TIME_SetLeapSecondsCmd", "Set leap seconds invalid"); #endif @@ -2348,13 +2348,13 @@ void Test_ResetArea(void) /* Test successfully updating the reset area */ UT_InitData(); - CFE_TIME_TaskData.DataStoreStatus = CFE_TIME_RESET_AREA_EXISTING; - CFE_TIME_TaskData.ClockSignal = CFE_TIME_ToneSignalSelect_PRIMARY; + CFE_TIME_Global.DataStoreStatus = CFE_TIME_RESET_AREA_EXISTING; + CFE_TIME_Global.ClockSignal = CFE_TIME_ToneSignalSelect_PRIMARY; UT_GetResetDataPtr()->TimeResetVars.ClockSignal = CFE_TIME_ToneSignalSelect_REDUNDANT; CFE_TIME_UpdateResetVars(&Reference); UT_Report(__FILE__, __LINE__, UT_GetResetDataPtr()->TimeResetVars.ClockSignal == - CFE_TIME_TaskData.ClockSignal, + CFE_TIME_Global.ClockSignal, "CFE_TIME_UpdateResetVars", "Successful update"); @@ -2364,7 +2364,7 @@ void Test_ResetArea(void) CFE_TIME_ToneSignalSelect_PRIMARY); CFE_TIME_QueryResetVars(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.DataStoreStatus == + CFE_TIME_Global.DataStoreStatus == CFE_TIME_RESET_AREA_EXISTING, "CFE_TIME_QueryResetVars", "Initialize times using an existing reset area; time tone PRI"); @@ -2375,7 +2375,7 @@ void Test_ResetArea(void) CFE_TIME_ToneSignalSelect_REDUNDANT); CFE_TIME_QueryResetVars(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.DataStoreStatus == + CFE_TIME_Global.DataStoreStatus == CFE_TIME_RESET_AREA_EXISTING, "CFE_TIME_QueryResetVars", "Initialize times using an existing reset area; time tone RED"); @@ -2386,7 +2386,7 @@ void Test_ResetArea(void) CFE_TIME_ToneSignalSelect_PRIMARY); CFE_TIME_QueryResetVars(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.DataStoreStatus == CFE_TIME_RESET_AREA_BAD, + CFE_TIME_Global.DataStoreStatus == CFE_TIME_RESET_AREA_BAD, "CFE_TIME_QueryResetVars", "Reset area error"); @@ -2396,7 +2396,7 @@ void Test_ResetArea(void) CFE_TIME_ToneSignalSelect_PRIMARY); CFE_TIME_QueryResetVars(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.DataStoreStatus == CFE_TIME_RESET_AREA_NEW, + CFE_TIME_Global.DataStoreStatus == CFE_TIME_RESET_AREA_NEW, "CFE_TIME_QueryResetVars", "Initialize to default values"); @@ -2406,32 +2406,32 @@ void Test_ResetArea(void) CFE_TIME_ToneSignalSelect_REDUNDANT+1); CFE_TIME_QueryResetVars(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.DataStoreStatus == CFE_TIME_RESET_AREA_NEW, + CFE_TIME_Global.DataStoreStatus == CFE_TIME_RESET_AREA_NEW, "CFE_TIME_QueryResetVars", "Bad clock signal selection"); /* Test response to a reset area error */ UT_InitData(); - CFE_TIME_TaskData.DataStoreStatus = CFE_TIME_RESET_AREA_ERROR; - CFE_TIME_TaskData.ClockSignal = CFE_TIME_ToneSignalSelect_PRIMARY; + CFE_TIME_Global.DataStoreStatus = CFE_TIME_RESET_AREA_ERROR; + CFE_TIME_Global.ClockSignal = CFE_TIME_ToneSignalSelect_PRIMARY; UT_GetResetDataPtr()->TimeResetVars.ClockSignal = CFE_TIME_ToneSignalSelect_REDUNDANT; CFE_TIME_UpdateResetVars(&Reference); UT_Report(__FILE__, __LINE__, UT_GetResetDataPtr()->TimeResetVars.ClockSignal != - CFE_TIME_TaskData.ClockSignal, + CFE_TIME_Global.ClockSignal, "CFE_TIME_UpdateResetVars", "Reset area error"); /* Test failure to get reset area updating the reset area */ UT_InitData(); UT_SetStatusBSPResetArea(CFE_PSP_ERROR, 0, CFE_TIME_ToneSignalSelect_PRIMARY); - CFE_TIME_TaskData.DataStoreStatus = CFE_TIME_RESET_AREA_EXISTING; - CFE_TIME_TaskData.ClockSignal = CFE_TIME_ToneSignalSelect_PRIMARY; + CFE_TIME_Global.DataStoreStatus = CFE_TIME_RESET_AREA_EXISTING; + CFE_TIME_Global.ClockSignal = CFE_TIME_ToneSignalSelect_PRIMARY; UT_GetResetDataPtr()->TimeResetVars.ClockSignal = CFE_TIME_ToneSignalSelect_REDUNDANT; CFE_TIME_UpdateResetVars(&Reference); UT_Report(__FILE__, __LINE__, UT_GetResetDataPtr()->TimeResetVars.ClockSignal != - CFE_TIME_TaskData.ClockSignal, + CFE_TIME_Global.ClockSignal, "CFE_TIME_UpdateResetVars", "Get reset area fail"); } @@ -2454,7 +2454,7 @@ void Test_State(void) UT_InitData(); Reference.ClockSetState = CFE_TIME_SetState_WAS_SET; Reference.ClockFlyState = CFE_TIME_FlywheelState_NO_FLY; - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; ExpState = CFE_TIME_ClockState_VALID; UT_Report(__FILE__, __LINE__, CFE_TIME_CalculateState(&Reference) == ExpState, @@ -2467,7 +2467,7 @@ void Test_State(void) UT_InitData(); Reference.ClockSetState = CFE_TIME_SetState_WAS_SET; Reference.ClockFlyState = CFE_TIME_FlywheelState_NO_FLY; - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; #if (CFE_PLATFORM_TIME_CFG_CLIENT == true) ExpState = CFE_TIME_ClockState_FLYWHEEL; #else @@ -2527,12 +2527,12 @@ void Test_State(void) "CFE_TIME_GetStateFlags", "State data atomic update after finish"); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.ClockSignal = CFE_TIME_ToneSignalSelect_REDUNDANT; - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; - CFE_TIME_TaskData.Forced2Fly = false; - CFE_TIME_TaskData.OneTimeDirection = CFE_TIME_AdjustDirection_SUBTRACT; - CFE_TIME_TaskData.OneHzDirection = CFE_TIME_AdjustDirection_SUBTRACT; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.ClockSignal = CFE_TIME_ToneSignalSelect_REDUNDANT; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; + CFE_TIME_Global.Forced2Fly = false; + CFE_TIME_Global.OneTimeDirection = CFE_TIME_AdjustDirection_SUBTRACT; + CFE_TIME_Global.OneHzDirection = CFE_TIME_AdjustDirection_SUBTRACT; flag = CFE_TIME_GetClockInfo(); UT_Report(__FILE__, __LINE__, @@ -2543,7 +2543,7 @@ void Test_State(void) RefState = CFE_TIME_StartReferenceUpdate(); RefState->ClockFlyState = CFE_TIME_FlywheelState_IS_FLY; CFE_TIME_FinishReferenceUpdate(RefState); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_INTERNAL; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_INTERNAL; } /* @@ -2565,8 +2565,8 @@ void Test_GetReference(void) RefState->AtToneDelay.Subseconds = 0; RefState->AtToneLatch.Seconds = 10; RefState->AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 1000; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.MaxLocalClock.Seconds = 1000; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; CFE_TIME_FinishReferenceUpdate(RefState); UT_SetBSP_Time(0, 0); CFE_TIME_GetReference(&Reference); @@ -2588,8 +2588,8 @@ void Test_GetReference(void) RefState->AtToneDelay.Subseconds = 0; RefState->AtToneLatch.Seconds = 10; RefState->AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.MaxLocalClock.Seconds = 0; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; CFE_TIME_FinishReferenceUpdate(RefState); UT_SetBSP_Time(15, 0); CFE_TIME_GetReference(&Reference); @@ -2617,8 +2617,8 @@ void Test_Tone(void) int virtualSeconds = 1234567; #endif - uint32 MinElapsed = CFE_TIME_TaskData.MinElapsed; - uint32 MaxElapsed = CFE_TIME_TaskData.MaxElapsed; + uint32 MinElapsed = CFE_TIME_Global.MinElapsed; + uint32 MaxElapsed = CFE_TIME_Global.MaxElapsed; UtPrintf("Begin Test Tone"); @@ -2635,9 +2635,9 @@ void Test_Tone(void) RefState->AtToneDelay.Subseconds = 0; RefState->AtToneLatch.Seconds = 0; /* 10.00000 */ RefState->AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.VirtualMET = virtualSeconds; - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Seconds = 0; - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Subseconds = seconds; + CFE_TIME_Global.VirtualMET = virtualSeconds; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Seconds = 0; + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Subseconds = seconds; CFE_TIME_FinishReferenceUpdate(RefState); CFE_TIME_ToneSend(); @@ -2648,14 +2648,14 @@ void Test_Tone(void) #ifdef CFE_PLATFORM_TIME_CFG_BIGENDIAN UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Seconds == CFE_MAKE_BIG32(seconds) && - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Subseconds == CFE_MAKE_BIG32(0), /* yes, I know, 0 is 0 in all endians */ + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Seconds == CFE_MAKE_BIG32(seconds) && + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Subseconds == CFE_MAKE_BIG32(0), /* yes, I know, 0 is 0 in all endians */ "CFE_TIME_ToneSend", "Send tone, flywheel ON"); #else /* !CFE_PLATFORM_TIME_CFG_BIGENDIAN */ UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Seconds == seconds && - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Subseconds == 0, + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Seconds == seconds && + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Subseconds == 0, "CFE_TIME_ToneSend", "Send tone, flywheel ON"); #endif /* CFE_PLATFORM_TIME_CFG_BIGENDIAN */ @@ -2675,18 +2675,18 @@ void Test_Tone(void) #ifdef CFE_PLATFORM_TIME_CFG_BIGENDIAN UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Seconds == + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Seconds == CFE_MAKE_BIG32(virtualSeconds) && - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Subseconds == CFE_MAKE_BIG32(0), /* yes, I know, 0 is 0 in all endians */ + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Subseconds == CFE_MAKE_BIG32(0), /* yes, I know, 0 is 0 in all endians */ "CFE_TIME_ToneSend", "Send tone, flywheel OFF"); #else /* !CFE_PLATFORM_TIME_CFG_BIGENDIAN */ UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Seconds == + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Seconds == virtualSeconds && - CFE_TIME_TaskData.ToneDataCmd.Payload.AtToneMET.Subseconds == 0, + CFE_TIME_Global.ToneDataCmd.Payload.AtToneMET.Subseconds == 0, "CFE_TIME_ToneSend", "Send tone, flywheel OFF"); @@ -2718,31 +2718,31 @@ void Test_Tone(void) * to known values */ UT_InitData(); - VersionSave = CFE_TIME_TaskData.LastVersionCounter; /* Verifies 'ForcedToFly' path */ - CFE_TIME_TaskData.ToneMatchCounter = 0; - CFE_TIME_TaskData.Forced2Fly = false; /* Exercises '!ForcedToFly' path */ + VersionSave = CFE_TIME_Global.LastVersionCounter; /* Verifies 'ForcedToFly' path */ + CFE_TIME_Global.ToneMatchCounter = 0; + CFE_TIME_Global.Forced2Fly = false; /* Exercises '!ForcedToFly' path */ CFE_TIME_ToneVerify(time1, time2); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.LastVersionCounter > VersionSave && - CFE_TIME_TaskData.ToneMatchCounter == 1, + CFE_TIME_Global.LastVersionCounter > VersionSave && + CFE_TIME_Global.ToneMatchCounter == 1, "CFE_TIME_ToneVerify", "Time 1 < time 2, Forced2Fly false"); /* Test tone validation when time 1 equals the previous time 1 value */ UT_InitData(); - CFE_TIME_TaskData.ToneMatchErrorCounter = 0; + CFE_TIME_Global.ToneMatchErrorCounter = 0; CFE_TIME_ToneVerify(time1, time1); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneMatchErrorCounter == 1, + CFE_TIME_Global.ToneMatchErrorCounter == 1, "CFE_TIME_ToneVerify", "Time 1 same as previous time 1"); /* Test tone validation when time 2 equals the previous time 2 value */ UT_InitData(); - CFE_TIME_TaskData.ToneMatchErrorCounter = 0; + CFE_TIME_Global.ToneMatchErrorCounter = 0; CFE_TIME_ToneVerify(time2, time1); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneMatchErrorCounter == 1, + CFE_TIME_Global.ToneMatchErrorCounter == 1, "CFE_TIME_ToneVerify", "Time 2 same as previous time 2"); @@ -2752,12 +2752,12 @@ void Test_Tone(void) time2.Seconds = 0; time1.Subseconds = 0; time2.Subseconds = 100; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 20; /* 1000.00000 */ - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; - CFE_TIME_TaskData.ToneMatchCounter = 0; + CFE_TIME_Global.MaxLocalClock.Seconds = 20; /* 1000.00000 */ + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.ToneMatchCounter = 0; CFE_TIME_ToneVerify(time1, time2); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneMatchCounter == 1, + CFE_TIME_Global.ToneMatchCounter == 1, "CFE_TIME_ToneVerify", "Time 1 > time 2 (clock rollover)"); @@ -2769,10 +2769,10 @@ void Test_Tone(void) time2.Seconds = 11; time1.Subseconds = 0; time2.Subseconds = 0; - CFE_TIME_TaskData.ToneMatchErrorCounter = 0; + CFE_TIME_Global.ToneMatchErrorCounter = 0; CFE_TIME_ToneVerify(time2, time1); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneMatchErrorCounter == 1, + CFE_TIME_Global.ToneMatchErrorCounter == 1, "CFE_TIME_ToneVerify", "Elapsed time out of limits (seconds)"); @@ -2784,12 +2784,12 @@ void Test_Tone(void) time2.Seconds = 12; time1.Subseconds = 0; time2.Subseconds = 10; - CFE_TIME_TaskData.MinElapsed = 20; - CFE_TIME_TaskData.MaxElapsed = 30; - CFE_TIME_TaskData.ToneMatchErrorCounter = 0; + CFE_TIME_Global.MinElapsed = 20; + CFE_TIME_Global.MaxElapsed = 30; + CFE_TIME_Global.ToneMatchErrorCounter = 0; CFE_TIME_ToneVerify(time1, time2); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneMatchErrorCounter == 1, + CFE_TIME_Global.ToneMatchErrorCounter == 1, "CFE_TIME_ToneVerify", "Elapsed time out of limits (subseconds low)"); @@ -2801,17 +2801,17 @@ void Test_Tone(void) time2.Seconds = 13; time1.Subseconds = 0; time2.Subseconds = 40; - CFE_TIME_TaskData.MinElapsed = 20; - CFE_TIME_TaskData.MaxElapsed = 30; - CFE_TIME_TaskData.ToneMatchErrorCounter = 0; + CFE_TIME_Global.MinElapsed = 20; + CFE_TIME_Global.MaxElapsed = 30; + CFE_TIME_Global.ToneMatchErrorCounter = 0; CFE_TIME_ToneVerify(time1, time2); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneMatchErrorCounter == 1, + CFE_TIME_Global.ToneMatchErrorCounter == 1, "CFE_TIME_ToneVerify", "Elapsed time out of limits (subseconds high)"); - CFE_TIME_TaskData.MinElapsed = MinElapsed; - CFE_TIME_TaskData.MaxElapsed = MaxElapsed; + CFE_TIME_Global.MinElapsed = MinElapsed; + CFE_TIME_Global.MaxElapsed = MaxElapsed; time1.Seconds = 10; time1.Subseconds = 0; @@ -2822,42 +2822,42 @@ void Test_Tone(void) * false and the clock source is external */ UT_InitData(); - VersionSave = CFE_TIME_TaskData.LastVersionCounter; /* Verifies 'ForcedToFly' path */ - CFE_TIME_TaskData.ToneMatchCounter = 0; - CFE_TIME_TaskData.Forced2Fly = false; /* Exercises '!ForcedToFly' path */ - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; - CFE_TIME_TaskData.VirtualMET = 5; - CFE_TIME_TaskData.PendingMET.Seconds = CFE_TIME_TaskData.VirtualMET; + VersionSave = CFE_TIME_Global.LastVersionCounter; /* Verifies 'ForcedToFly' path */ + CFE_TIME_Global.ToneMatchCounter = 0; + CFE_TIME_Global.Forced2Fly = false; /* Exercises '!ForcedToFly' path */ + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_EXTERNAL; + CFE_TIME_Global.VirtualMET = 5; + CFE_TIME_Global.PendingMET.Seconds = CFE_TIME_Global.VirtualMET; CFE_TIME_ToneVerify(time1, time2); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.LastVersionCounter > VersionSave && - CFE_TIME_TaskData.ToneMatchCounter == 1 && - CFE_TIME_TaskData.VirtualMET == 5, + CFE_TIME_Global.LastVersionCounter > VersionSave && + CFE_TIME_Global.ToneMatchCounter == 1 && + CFE_TIME_Global.VirtualMET == 5, "CFE_TIME_ToneVerify", "Time 1 < time 2, Forced2Fly false, Clock EXTERN"); - CFE_TIME_TaskData.ClockSource = CFE_TIME_SourceSelect_INTERNAL; + CFE_TIME_Global.ClockSource = CFE_TIME_SourceSelect_INTERNAL; #if (CFE_PLATFORM_TIME_CFG_CLIENT == true) /* Test tone update using an invalid pending state */ UT_InitData(); - CFE_TIME_TaskData.PendingState = CFE_TIME_ClockState_INVALID; - CFE_TIME_TaskData.ClockSetState = CFE_TIME_SetState_WAS_SET; - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; + CFE_TIME_Global.PendingState = CFE_TIME_ClockState_INVALID; + CFE_TIME_Global.ClockSetState = CFE_TIME_SetState_WAS_SET; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_IS_FLY; CFE_TIME_ToneUpdate(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ClockSetState == CFE_TIME_SetState_NOT_SET && - CFE_TIME_TaskData.ServerFlyState == CFE_TIME_FlywheelState_NO_FLY, + CFE_TIME_Global.ClockSetState == CFE_TIME_SetState_NOT_SET && + CFE_TIME_Global.ServerFlyState == CFE_TIME_FlywheelState_NO_FLY, "CFE_TIME_ToneUpdate", "Invalid pending state"); /* Test tone update using FLYWHEEL as the pending state */ UT_InitData(); - CFE_TIME_TaskData.PendingState = CFE_TIME_ClockState_FLYWHEEL; - CFE_TIME_TaskData.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; + CFE_TIME_Global.PendingState = CFE_TIME_ClockState_FLYWHEEL; + CFE_TIME_Global.ServerFlyState = CFE_TIME_FlywheelState_NO_FLY; CFE_TIME_ToneUpdate(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ServerFlyState == CFE_TIME_FlywheelState_IS_FLY, + CFE_TIME_Global.ServerFlyState == CFE_TIME_FlywheelState_IS_FLY, "CFE_TIME_ToneUpdate", "Pending state is FLYWHEEL"); @@ -2933,18 +2933,18 @@ void Test_1Hz(void) UT_InitData(); RefState = CFE_TIME_StartReferenceUpdate(); RefState->ClockFlyState = CFE_TIME_FlywheelState_NO_FLY; - CFE_TIME_TaskData.AutoStartFly = false; + CFE_TIME_Global.AutoStartFly = false; RefState->AtToneLatch.Seconds = 1; RefState->AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.OneHzAdjust.Seconds = 1; - CFE_TIME_TaskData.OneHzAdjust.Subseconds = 0; + CFE_TIME_Global.OneHzAdjust.Seconds = 1; + CFE_TIME_Global.OneHzAdjust.Subseconds = 0; CFE_TIME_FinishReferenceUpdate(RefState); UT_SetBSP_Time(0, 0); - CFE_TIME_TaskData.MaxLocalClock.Seconds = CFE_PLATFORM_TIME_CFG_LATCH_FLY - 1; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.MaxLocalClock.Seconds = CFE_PLATFORM_TIME_CFG_LATCH_FLY - 1; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; CFE_TIME_Local1HzStateMachine(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.AutoStartFly == true, + CFE_TIME_Global.AutoStartFly == true, "CFE_TIME_Local1HzISR", "Auto start flywheel (seconds)"); @@ -2959,13 +2959,13 @@ void Test_1Hz(void) RefState->AtToneDelay.Subseconds = 0; RefState->AtToneMET.Seconds = time1.Seconds; RefState->AtToneMET.Subseconds = 0; - CFE_TIME_TaskData.OneHzAdjust.Seconds = 0; - CFE_TIME_TaskData.OneHzAdjust.Subseconds = 0; + CFE_TIME_Global.OneHzAdjust.Seconds = 0; + CFE_TIME_Global.OneHzAdjust.Subseconds = 0; RefState->AtToneLatch.Seconds = time2.Seconds; RefState->AtToneLatch.Subseconds = 0; UT_SetBSP_Time(0, 0); - CFE_TIME_TaskData.MaxLocalClock.Seconds = CFE_PLATFORM_TIME_CFG_LATCH_FLY + delSec; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.MaxLocalClock.Seconds = CFE_PLATFORM_TIME_CFG_LATCH_FLY + delSec; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; RefState->ClockFlyState = CFE_TIME_FlywheelState_IS_FLY; CFE_TIME_FinishReferenceUpdate(RefState); CFE_TIME_Local1HzStateMachine(); @@ -2982,13 +2982,13 @@ void Test_1Hz(void) * the previous one */ UT_InitData(); - CFE_TIME_TaskData.IsToneGood = true; + CFE_TIME_Global.IsToneGood = true; UT_SetBSP_Time(0, 0); - CFE_TIME_TaskData.ToneSignalLatch.Seconds = 1; - CFE_TIME_TaskData.ToneSignalLatch.Subseconds = 0; + CFE_TIME_Global.ToneSignalLatch.Seconds = 1; + CFE_TIME_Global.ToneSignalLatch.Subseconds = 0; CFE_TIME_Tone1HzISR(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.IsToneGood == false, + CFE_TIME_Global.IsToneGood == false, "CFE_TIME_Tone1HzISR", "Invalid tone signal interrupt"); @@ -2999,15 +2999,15 @@ void Test_1Hz(void) UT_InitData(); UT_SetBSP_Time(1, 0); /* Set up the sync callback table with callbacks for 3 apps */ - for (i = 0; i < (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0])); i++) + for (i = 0; i < (sizeof(CFE_TIME_Global.SynchCallback) / sizeof(CFE_TIME_Global.SynchCallback[0])); i++) { if (i < 3) { - CFE_TIME_TaskData.SynchCallback[i].Ptr = &ut_time_MyCallbackFunc; + CFE_TIME_Global.SynchCallback[i].Ptr = &ut_time_MyCallbackFunc; } else { - CFE_TIME_TaskData.SynchCallback[i].Ptr = NULL; + CFE_TIME_Global.SynchCallback[i].Ptr = NULL; } } ut_time_CallbackCalled = 0; @@ -3021,12 +3021,12 @@ void Test_1Hz(void) * second call */ UT_InitData(); - CFE_TIME_TaskData.AutoStartFly = true; - CFE_TIME_TaskData.LocalTaskCounter = 0; + CFE_TIME_Global.AutoStartFly = true; + CFE_TIME_Global.LocalTaskCounter = 0; UT_SetDeferredRetcode(UT_KEY(OS_BinSemTake), 2, OS_ERROR); CFE_TIME_Local1HzTask(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.LocalTaskCounter == 1, + CFE_TIME_Global.LocalTaskCounter == 1, "CFE_TIME_Local1HzTask", "Semaphore creation pass, then fail"); @@ -3034,49 +3034,49 @@ void Test_1Hz(void) * second call */ UT_InitData(); - CFE_TIME_TaskData.ToneTaskCounter = 0; + CFE_TIME_Global.ToneTaskCounter = 0; UT_SetDeferredRetcode(UT_KEY(OS_BinSemTake), 2, OS_ERROR); CFE_TIME_Tone1HzTask(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.ToneTaskCounter == 1, + CFE_TIME_Global.ToneTaskCounter == 1, "CFE_TIME_Tone1HzTask", "Semaphore creation pass, then fail"); /* Test the tone 1Hz task with the tone signal over the time limit */ UT_InitData(); - UT_SetBSP_Time(1, CFE_TIME_Sub2MicroSecs(CFE_TIME_TaskData.ToneOverLimit)); - CFE_TIME_TaskData.IsToneGood = true; - CFE_TIME_TaskData.MaxLocalClock.Seconds = 0; - CFE_TIME_TaskData.MaxLocalClock.Subseconds = 0; - CFE_TIME_TaskData.ToneSignalLatch.Seconds = 0; - CFE_TIME_TaskData.ToneSignalLatch.Subseconds = 0; + UT_SetBSP_Time(1, CFE_TIME_Sub2MicroSecs(CFE_TIME_Global.ToneOverLimit)); + CFE_TIME_Global.IsToneGood = true; + CFE_TIME_Global.MaxLocalClock.Seconds = 0; + CFE_TIME_Global.MaxLocalClock.Subseconds = 0; + CFE_TIME_Global.ToneSignalLatch.Seconds = 0; + CFE_TIME_Global.ToneSignalLatch.Subseconds = 0; CFE_TIME_Tone1HzISR(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.IsToneGood == false, + CFE_TIME_Global.IsToneGood == false, "CFE_TIME_Tone1HzISR", "Invalid tone signal interrupt; tolerance over limit"); /* Test the tone 1Hz task with the tone signal within the time limits */ UT_InitData(); - UT_SetBSP_Time(0, CFE_TIME_Sub2MicroSecs(CFE_TIME_TaskData.ToneUnderLimit) + 1); - CFE_TIME_TaskData.IsToneGood = false; - CFE_TIME_TaskData.ToneSignalLatch.Seconds = 0; - CFE_TIME_TaskData.ToneSignalLatch.Subseconds = 0; + UT_SetBSP_Time(0, CFE_TIME_Sub2MicroSecs(CFE_TIME_Global.ToneUnderLimit) + 1); + CFE_TIME_Global.IsToneGood = false; + CFE_TIME_Global.ToneSignalLatch.Seconds = 0; + CFE_TIME_Global.ToneSignalLatch.Subseconds = 0; CFE_TIME_Tone1HzISR(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.IsToneGood == true, + CFE_TIME_Global.IsToneGood == true, "CFE_TIME_Tone1HzISR", "Valid tone signal interrupt, tolerance in limits"); /* Test the tone 1Hz task with the tone signal under the time limit */ UT_InitData(); - UT_SetBSP_Time(0, CFE_TIME_Sub2MicroSecs(CFE_TIME_TaskData.ToneUnderLimit) - 1); - CFE_TIME_TaskData.IsToneGood = true; - CFE_TIME_TaskData.ToneSignalLatch.Seconds = 0; - CFE_TIME_TaskData.ToneSignalLatch.Subseconds = 0; + UT_SetBSP_Time(0, CFE_TIME_Sub2MicroSecs(CFE_TIME_Global.ToneUnderLimit) - 1); + CFE_TIME_Global.IsToneGood = true; + CFE_TIME_Global.ToneSignalLatch.Seconds = 0; + CFE_TIME_Global.ToneSignalLatch.Subseconds = 0; CFE_TIME_Tone1HzISR(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.IsToneGood == false, + CFE_TIME_Global.IsToneGood == false, "CFE_TIME_Tone1HzISR", "Valid tone signal interrupt, tolerance under limits"); @@ -3086,16 +3086,16 @@ void Test_1Hz(void) UT_InitData(); RefState = CFE_TIME_StartReferenceUpdate(); RefState->ClockFlyState = CFE_TIME_FlywheelState_NO_FLY; - CFE_TIME_TaskData.AutoStartFly = false; + CFE_TIME_Global.AutoStartFly = false; RefState->AtToneLatch.Seconds = 1; RefState->AtToneLatch.Subseconds = 0; - CFE_TIME_TaskData.OneHzAdjust.Seconds = 0; - CFE_TIME_TaskData.OneHzAdjust.Subseconds = 1; + CFE_TIME_Global.OneHzAdjust.Seconds = 0; + CFE_TIME_Global.OneHzAdjust.Subseconds = 1; CFE_TIME_FinishReferenceUpdate(RefState); UT_SetBSP_Time(0, 0); CFE_TIME_Local1HzStateMachine(); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.AutoStartFly == true, + CFE_TIME_Global.AutoStartFly == true, "CFE_TIME_Local1HzISR", "Auto start flywheel (subseconds)"); @@ -3105,8 +3105,8 @@ void Test_1Hz(void) UT_InitData(); RefState = CFE_TIME_StartReferenceUpdate(); RefState->ClockFlyState = CFE_TIME_FlywheelState_NO_FLY; - CFE_TIME_TaskData.OneHzAdjust.Seconds = 0; - CFE_TIME_TaskData.OneHzAdjust.Subseconds = 0; + CFE_TIME_Global.OneHzAdjust.Seconds = 0; + CFE_TIME_Global.OneHzAdjust.Subseconds = 0; CFE_TIME_FinishReferenceUpdate(RefState); UT_SetBSP_Time(1, 0); CFE_TIME_Local1HzStateMachine(); @@ -3118,8 +3118,8 @@ void Test_1Hz(void) /* Test the local 1Hz task where auto start flywheel is disabled */ UT_InitData(); - CFE_TIME_TaskData.LocalTaskCounter = 0; - CFE_TIME_TaskData.AutoStartFly = false; + CFE_TIME_Global.LocalTaskCounter = 0; + CFE_TIME_Global.AutoStartFly = false; UT_SetDeferredRetcode(UT_KEY(OS_BinSemTake), 2, OS_ERROR); CFE_TIME_Local1HzTask(); RefState = CFE_TIME_GetReferenceState(); @@ -3131,16 +3131,16 @@ void Test_1Hz(void) /* Test the CFE_TIME_Local1HzTimerCallback function */ UT_InitData(); - CFE_TIME_TaskData.LocalIntCounter = 1; + CFE_TIME_Global.LocalIntCounter = 1; RefState = CFE_TIME_StartReferenceUpdate(); RefState->ClockFlyState = CFE_TIME_FlywheelState_NO_FLY; - CFE_TIME_TaskData.OneHzAdjust.Seconds = 0; - CFE_TIME_TaskData.OneHzAdjust.Subseconds = 0; + CFE_TIME_Global.OneHzAdjust.Seconds = 0; + CFE_TIME_Global.OneHzAdjust.Subseconds = 0; CFE_TIME_FinishReferenceUpdate(RefState); UT_SetBSP_Time(0, 0); CFE_TIME_Local1HzTimerCallback(OS_ObjectIdFromInteger(123), &Arg); UT_Report(__FILE__, __LINE__, - CFE_TIME_TaskData.LocalIntCounter == 2, + CFE_TIME_Global.LocalIntCounter == 2, "CFE_TIME_Local1HzTimerCallback", "Pass through to CFE_TIME_Local1HzISR"); } @@ -3165,15 +3165,15 @@ void Test_UnregisterSynchCallback(void) /* Set up the sync callback table with callbacks for 3 apps */ - for (i = 0; i < (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0])); i++) + for (i = 0; i < (sizeof(CFE_TIME_Global.SynchCallback) / sizeof(CFE_TIME_Global.SynchCallback[0])); i++) { if (i < 3) { - CFE_TIME_TaskData.SynchCallback[i].Ptr = &ut_time_MyCallbackFunc; + CFE_TIME_Global.SynchCallback[i].Ptr = &ut_time_MyCallbackFunc; } else { - CFE_TIME_TaskData.SynchCallback[i].Ptr = NULL; + CFE_TIME_Global.SynchCallback[i].Ptr = NULL; } } @@ -3219,10 +3219,10 @@ void Test_UnregisterSynchCallback(void) /* Test tone notification with an invalid time synch application */ UT_InitData(); - CFE_TIME_TaskData.IsToneGood = true; - for (i = 0; i < (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0])); i++) + CFE_TIME_Global.IsToneGood = true; + for (i = 0; i < (sizeof(CFE_TIME_Global.SynchCallback) / sizeof(CFE_TIME_Global.SynchCallback[0])); i++) { - CFE_TIME_TaskData.SynchCallback[i].Ptr = NULL; + CFE_TIME_Global.SynchCallback[i].Ptr = NULL; } CFE_TIME_NotifyTimeSynchApps(); UT_Report(__FILE__, __LINE__, @@ -3240,7 +3240,7 @@ void Test_CleanUpApp(void) uint16 Count; int32 Status = CFE_SUCCESS; uint32 AppIndex; - CFE_ES_ResourceID_t TestAppId; + CFE_ES_AppId_t TestAppId; UtPrintf("Begin Test Cleanup App"); @@ -3248,9 +3248,9 @@ void Test_CleanUpApp(void) CFE_ES_GetAppID(&TestAppId); /* Clear out the sync callback table */ - for (i = 0; i < (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0])); i++) + for (i = 0; i < (sizeof(CFE_TIME_Global.SynchCallback) / sizeof(CFE_TIME_Global.SynchCallback[0])); i++) { - CFE_TIME_TaskData.SynchCallback[i].Ptr = NULL; + CFE_TIME_Global.SynchCallback[i].Ptr = NULL; } /* Add callbacks for 3 apps into callback registry table */ @@ -3274,9 +3274,9 @@ void Test_CleanUpApp(void) "Successful result"); Count = 0; - for (i = 0; i < (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0])); i++) + for (i = 0; i < (sizeof(CFE_TIME_Global.SynchCallback) / sizeof(CFE_TIME_Global.SynchCallback[0])); i++) { - if (CFE_TIME_TaskData.SynchCallback[i].Ptr != NULL) + if (CFE_TIME_Global.SynchCallback[i].Ptr != NULL) { ++Count; } @@ -3298,9 +3298,9 @@ void Test_CleanUpApp(void) "Successful result"); Count = 0; - for (i = 0; i < (sizeof(CFE_TIME_TaskData.SynchCallback) / sizeof(CFE_TIME_TaskData.SynchCallback[0])); i++) + for (i = 0; i < (sizeof(CFE_TIME_Global.SynchCallback) / sizeof(CFE_TIME_Global.SynchCallback[0])); i++) { - if (CFE_TIME_TaskData.SynchCallback[i].Ptr != NULL) + if (CFE_TIME_Global.SynchCallback[i].Ptr != NULL) { ++Count; } @@ -3316,7 +3316,7 @@ void Test_CleanUpApp(void) * This is effectively a no-op but here for coverage */ AppIndex = 99999; UT_SetDataBuffer(UT_KEY(CFE_ES_AppID_ToIndex), &AppIndex, sizeof(AppIndex), false); - Status = CFE_TIME_CleanUpApp(CFE_ES_RESOURCEID_UNDEFINED); + Status = CFE_TIME_CleanUpApp(CFE_ES_APPID_UNDEFINED); UT_Report(__FILE__, __LINE__, Status == CFE_TIME_CALLBACK_NOT_REGISTERED, "CFE_TIME_CleanUpApp", diff --git a/fsw/cfe-core/unit-test/ut_support.c b/fsw/cfe-core/unit-test/ut_support.c index 62a4454f1..79d123557 100644 --- a/fsw/cfe-core/unit-test/ut_support.c +++ b/fsw/cfe-core/unit-test/ut_support.c @@ -43,7 +43,7 @@ uint8 UT_Endianess; static char UT_appname[80]; static char UT_subsys[5]; -static CFE_ES_ResourceID_t UT_AppID; +static CFE_ES_AppId_t UT_AppID; static uint32 UT_LastCDSSize = 0; typedef union @@ -154,16 +154,12 @@ void UT_InitData(void) * Set up for the CFE_SB_ReceiveBuffer() call. * * The existing test cases assume that this will return success once, - * followed by a timeout response followed by a different error. + * followed by a timeout response. * * Specific test cases may provide an actual message buffer to return for * the first call, or they may override this default behavior entirely. - * - * The default behavior of the CFE_SB_ReceiveBuffer stub is to return success with a zero-ed out - * buffer returned to the caller. */ UT_SetDeferredRetcode(UT_KEY(CFE_SB_ReceiveBuffer), 2, CFE_SB_TIME_OUT); - UT_SetDeferredRetcode(UT_KEY(CFE_SB_ReceiveBuffer), 3, -1); /* * Set up CFE_ES_GetAppName() and friends @@ -275,7 +271,7 @@ int32 UT_SoftwareBusSnapshotHook(void *UserObj, int32 StubRetcode, uint32 CallCo /* ** Set the application ID returned by unit test stubs */ -void UT_SetAppID(CFE_ES_ResourceID_t AppID_in) +void UT_SetAppID(CFE_ES_AppId_t AppID_in) { UT_AppID = AppID_in; UT_SetDataBuffer(UT_KEY(CFE_ES_GetAppID), (uint8*)&UT_AppID, sizeof(UT_AppID), false); @@ -711,21 +707,21 @@ void UT_AddSubTest(void (*Test)(void), void (*Setup)(void), void (*Teardown)(voi void UT_SETUP_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) { - UtAssertEx(FnRet == CFE_SUCCESS, UTASSERT_CASETYPE_TSF, FileName, LineNum, "%s - Setup - %s returned %ld", + UtAssertEx(FnRet == CFE_SUCCESS, UTASSERT_CASETYPE_TSF, FileName, LineNum, "%s - Setup - %s returned 0x%lx", TestName, FnName, (long int)FnRet); } void UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) { - UtAssertEx(FnRet == CFE_SUCCESS, UtAssert_GetContext(), FileName, LineNum, "%s - %s returned %ld, expected CFE_SUCCESS", + UtAssertEx(FnRet == CFE_SUCCESS, UtAssert_GetContext(), FileName, LineNum, "%s - %s returned 0x%lx, expected CFE_SUCCESS", TestName, FnName, (long int)FnRet); } void UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *FnName, int32 FnRet, const char *ExpName, int32 Exp) { - UtAssertEx(FnRet == Exp, UtAssert_GetContext(), FileName, LineNum, "%s - value %ld, expected %s[%ld]", - FnName, (long)FnRet, ExpName, (long)Exp); + UtAssertEx(FnRet == Exp, UtAssert_GetContext(), FileName, LineNum, "%s - value %ld 0x%lx, expected %s[%ld 0x%lx]", + FnName, (long)FnRet, (long)FnRet, ExpName, (long)Exp, (long)Exp); } void UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName, @@ -751,7 +747,7 @@ void UT_EVTSENT_impl(const char *FileName, int LineNum, const char *TestName, co void UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) { - UtAssertEx(FnRet == CFE_SUCCESS, UTASSERT_CASETYPE_TTF, FileName, LineNum, "%s - Teardown failed (%s returned %ld)", + UtAssertEx(FnRet == CFE_SUCCESS, UTASSERT_CASETYPE_TTF, FileName, LineNum, "%s - Teardown failed (%s returned 0x%lx)", TestName, FnName, (long int)FnRet); } diff --git a/fsw/cfe-core/unit-test/ut_support.h b/fsw/cfe-core/unit-test/ut_support.h index 4619196c5..5b3e38660 100644 --- a/fsw/cfe-core/unit-test/ut_support.h +++ b/fsw/cfe-core/unit-test/ut_support.h @@ -317,7 +317,7 @@ int32 UT_SoftwareBusSnapshotHook(void *UserObj, int32 StubRetcode, uint32 CallCo ** This function does not return a value. ** ******************************************************************************/ -void UT_SetAppID(CFE_ES_ResourceID_t AppID_in); +void UT_SetAppID(CFE_ES_AppId_t AppID_in); /*****************************************************************************/ /** diff --git a/fsw/cfe-core/ut-stubs/CMakeLists.txt b/fsw/cfe-core/ut-stubs/CMakeLists.txt index f2bc4acf6..14e388a7e 100644 --- a/fsw/cfe-core/ut-stubs/CMakeLists.txt +++ b/fsw/cfe-core/ut-stubs/CMakeLists.txt @@ -19,6 +19,7 @@ add_library(ut_cfe-core_stubs STATIC ut_es_stubs.c ut_evs_stubs.c ut_msg_stubs.c + ut_resourceid_stubs.c ut_sb_stubs.c ut_tbl_stubs.c ut_time_stubs.c diff --git a/fsw/cfe-core/ut-stubs/ut_es_stubs.c b/fsw/cfe-core/ut-stubs/ut_es_stubs.c index d169ab44b..f10629b61 100644 --- a/fsw/cfe-core/ut-stubs/ut_es_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_es_stubs.c @@ -35,6 +35,7 @@ #include #include "cfe.h" #include "private/cfe_private.h" +#include "private/cfe_core_resourceid_basevalues.h" #include "utstubs.h" #include "utassert.h" @@ -64,26 +65,26 @@ * Default value to return from calls that output an App ID, if the * test case does not provide a value */ -#define CFE_UT_ES_DEFAULT_APPID ((CFE_ES_ResourceID_t){0x02010001}) +#define CFE_UT_ES_DEFAULT_APPID CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 1)) /* * Default value to return from calls that output a Task ID, if the * test case does not provide a value */ -#define CFE_UT_ES_DEFAULT_TASKID ((CFE_ES_ResourceID_t){0x02020001}) +#define CFE_UT_ES_DEFAULT_TASKID CFE_ES_TASKID_C(CFE_ResourceId_FromInteger(CFE_ES_TASKID_BASE + 1)) /* * Default value to return from calls that output a CDS ID, if the * test case does not provide a value */ -#define CFE_UT_ES_DEFAULT_CDSID ((CFE_ES_ResourceID_t){0x02050001}) +#define CFE_UT_ES_DEFAULT_CDSID CFE_ES_CDSHANDLE_C(CFE_ResourceId_FromInteger(CFE_ES_CDSBLOCKID_BASE + 1)) /* * Invalid value to output from calls as resource ID for the * calls that return failure. If subsequently used by application code, * it will likely induce a segfault or other noticeably bad behavior. */ -#define CFE_UT_ES_ID_INVALID ((CFE_ES_ResourceID_t){0xDEADBEEF}) +#define CFE_UT_ES_ID_INVALID CFE_ResourceId_FromInteger(0xDEADBEEF) /* ** Functions @@ -108,7 +109,7 @@ ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, +CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, CFE_ES_StackPointer_t StackPtr, @@ -151,12 +152,12 @@ CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) +int32 CFE_ES_GetAppID(CFE_ES_AppId_t *AppIdPtr) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppID), AppIdPtr); int32 status; - CFE_ES_ResourceID_t *IdBuff; + CFE_ES_AppId_t *IdBuff; size_t BuffSize; size_t Position; @@ -177,18 +178,18 @@ int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) if (status < 0) { - *AppIdPtr = CFE_UT_ES_ID_INVALID; + *AppIdPtr = CFE_ES_APPID_C(CFE_UT_ES_ID_INVALID); } return status; } -int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) +int32 CFE_ES_GetTaskID(CFE_ES_TaskId_t *TaskIdPtr) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetTaskID), TaskIdPtr); int32 status; - CFE_ES_ResourceID_t *IdBuff; + CFE_ES_TaskId_t *IdBuff; size_t BuffSize; size_t Position; @@ -209,7 +210,7 @@ int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) if (status < 0) { - *TaskIdPtr = CFE_UT_ES_ID_INVALID; + *TaskIdPtr = CFE_ES_TASKID_C(CFE_UT_ES_ID_INVALID); } return status; @@ -236,7 +237,7 @@ int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) ** Returns either CFE_ES_ERR_NAME_NOT_FOUND or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) +int32 CFE_ES_GetAppIDByName(CFE_ES_AppId_t *AppIdPtr, const char *AppName) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), AppIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), AppName); @@ -244,7 +245,7 @@ int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) size_t UserBuffSize; size_t BuffPosition; const char *NameBuff; - CFE_ES_ResourceID_t *IdBuff; + CFE_ES_AppId_t *IdBuff; int32 status; status = UT_DEFAULT_IMPL(CFE_ES_GetAppIDByName); @@ -274,7 +275,7 @@ int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) if (status < 0) { - *AppIdPtr = CFE_UT_ES_ID_INVALID; + *AppIdPtr = CFE_ES_APPID_C(CFE_UT_ES_ID_INVALID); } return status; @@ -297,7 +298,7 @@ int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) ** Returns CFE_SUCCESS. ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t BufferLength) +CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_AppId_t AppId, size_t BufferLength) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppName), AppName); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetAppName), AppId); @@ -824,7 +825,7 @@ uint32 CFE_ES_CalculateCRC(const void *DataPtr, size_t DataLength, uint32 InputC ** Returns CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId) +int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_TaskId_t TaskId) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetTaskInfo), TaskInfo); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetTaskInfo), TaskId); @@ -1138,7 +1139,7 @@ void CFE_ES_ExitChildTask(void) UT_DEFAULT_IMPL(CFE_ES_ExitChildTask); } -int32 CFE_ES_DeleteApp(CFE_ES_ResourceID_t AppID) +int32 CFE_ES_DeleteApp(CFE_ES_AppId_t AppID) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_DeleteApp), AppID); @@ -1149,7 +1150,7 @@ int32 CFE_ES_DeleteApp(CFE_ES_ResourceID_t AppID) return status; } -int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) +int32 CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_DeleteChildTask), TaskId); @@ -1160,7 +1161,7 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) return status; } -int32 CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId) +int32 CFE_ES_DeleteGenCounter(CFE_ES_CounterId_t CounterId) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_DeleteGenCounter), CounterId); @@ -1171,7 +1172,7 @@ int32 CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId) return status; } -int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) +int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_AppId_t AppId) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppInfo), AppInfo); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetAppInfo), AppId); @@ -1183,7 +1184,7 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) return status; } -int32 CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count) +int32 CFE_ES_GetGenCount(CFE_ES_CounterId_t CounterId, uint32 *Count) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetGenCount), CounterId); UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetGenCount), Count); @@ -1195,7 +1196,7 @@ int32 CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count) return status; } -int32 CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName) +int32 CFE_ES_GetGenCounterIDByName(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetGenCounterIDByName), CounterIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetGenCounterIDByName), CounterName); @@ -1219,7 +1220,7 @@ int32 CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t H return status; } -int32 CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId) +int32 CFE_ES_IncrementGenCounter(CFE_ES_CounterId_t CounterId) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_IncrementGenCounter), CounterId); @@ -1230,7 +1231,7 @@ int32 CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId) return status; } -int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName) +int32 CFE_ES_RegisterGenCounter(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_RegisterGenCounter), CounterIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_ES_RegisterGenCounter), CounterName); @@ -1242,7 +1243,7 @@ int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *C return status; } -int32 CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName) +int32 CFE_ES_ReloadApp(CFE_ES_AppId_t AppID, const char *AppFileName) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_ReloadApp), AppID); UT_Stub_RegisterContext(UT_KEY(CFE_ES_ReloadApp), AppFileName); @@ -1265,7 +1266,7 @@ int32 CFE_ES_ResetCFE(uint32 ResetType) return status; } -int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) +int32 CFE_ES_RestartApp(CFE_ES_AppId_t AppID) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_RestartApp), AppID); @@ -1276,7 +1277,7 @@ int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) return status; } -int32 CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count) +int32 CFE_ES_SetGenCount(CFE_ES_CounterId_t CounterId, uint32 Count) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_SetGenCount), CounterId); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_SetGenCount), Count); @@ -1288,14 +1289,14 @@ int32 CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count) return status; } -int32 CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx) +int32 CFE_ES_AppID_ToIndex(CFE_ES_AppId_t AppID, uint32 *Idx) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_AppID_ToIndex), AppID); UT_Stub_RegisterContext(UT_KEY(CFE_ES_AppID_ToIndex), Idx); int32 return_code; - *Idx = CFE_ES_ResourceID_ToInteger(AppID) & 0xFFFF; + *Idx = CFE_RESOURCEID_TO_ULONG(AppID) & 0xFFFF; return_code = UT_DEFAULT_IMPL_RC(CFE_ES_AppID_ToIndex, 1); if (return_code == 1) @@ -1312,14 +1313,14 @@ int32 CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx) return return_code; } -int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx) +int32 CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_TaskID_ToIndex), TaskID); UT_Stub_RegisterContext(UT_KEY(CFE_ES_TaskID_ToIndex), Idx); int32 return_code; - *Idx = CFE_ES_ResourceID_ToInteger(TaskID) & 0xFFFF; + *Idx = CFE_RESOURCEID_TO_ULONG(TaskID) & 0xFFFF; return_code = UT_DEFAULT_IMPL_RC(CFE_ES_TaskID_ToIndex, 1); if (return_code == 1) @@ -1335,49 +1336,3 @@ int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx) return return_code; } - -CFE_ES_ResourceID_t CFE_ES_FindNextAvailableId(CFE_ES_ResourceID_t StartId, uint32 TableSize, bool (*CheckFunc)(CFE_ES_ResourceID_t)) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_FindNextAvailableId), StartId); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_FindNextAvailableId), TableSize); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_FindNextAvailableId), CheckFunc); - - int32 return_code; - - /* Using "1" by default here produces a sequential result when called multiple times */ - return_code = UT_DEFAULT_IMPL_RC(CFE_ES_FindNextAvailableId, 1); - - if (return_code < 0) - { - return CFE_ES_RESOURCEID_UNDEFINED; - } - - /* - * The test case may set the return code to indicate the offset from the start ID - */ - return CFE_ES_ResourceID_FromInteger(CFE_ES_ResourceID_ToInteger(StartId) + return_code); -} - -int32 CFE_ES_ResourceID_ToIndex(uint32 Serial, uint32 TableSize, uint32 *Idx) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_ResourceID_ToIndex), Serial); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_ResourceID_ToIndex), TableSize); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_ResourceID_ToIndex), Idx); - - int32 return_code; - - return_code = UT_DEFAULT_IMPL(CFE_ES_ResourceID_ToIndex); - - if (return_code < 0) - { - /* fill with a very bad value that should cause a problem if used */ - *Idx = 0xDEADBEEF; - } - else if (UT_Stub_CopyToLocal(UT_KEY(CFE_ES_ResourceID_ToIndex), Idx, sizeof(*Idx)) < sizeof(*Idx)) - { - /* fill with default value if unspecified by test case */ - *Idx = Serial % TableSize; - } - - return return_code; -} diff --git a/fsw/cfe-core/ut-stubs/ut_evs_stubs.c b/fsw/cfe-core/ut-stubs/ut_evs_stubs.c index 5aa12224e..737c37b22 100644 --- a/fsw/cfe-core/ut-stubs/ut_evs_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_evs_stubs.c @@ -201,7 +201,7 @@ int32 CFE_EVS_SendTimedEvent(CFE_TIME_SysTime_t Time, ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_EVS_Register(void *Filters, +int32 CFE_EVS_Register(const void *Filters, uint16 NumFilteredEvents, uint16 FilterScheme) { @@ -241,7 +241,7 @@ int32 CFE_EVS_Register(void *Filters, ******************************************************************************/ int32 CFE_EVS_SendEventWithAppID(uint16 EventID, uint16 EventType, - CFE_ES_ResourceID_t AppID, + CFE_ES_AppId_t AppID, const char *Spec, ...) { @@ -288,7 +288,7 @@ int32 CFE_EVS_SendEventWithAppID(uint16 EventID, ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_EVS_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_EVS_CleanUpApp(CFE_ES_AppId_t AppId) { int32 status; diff --git a/fsw/cfe-core/ut-stubs/ut_resourceid_stubs.c b/fsw/cfe-core/ut-stubs/ut_resourceid_stubs.c new file mode 100644 index 000000000..8a540f4fe --- /dev/null +++ b/fsw/cfe-core/ut-stubs/ut_resourceid_stubs.c @@ -0,0 +1,121 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* + * Includes + */ +#include "osapi.h" +#include "cfe.h" +#include "utstubs.h" +#include "cfe_resourceid_api.h" +#include "cfe_resourceid_basevalue.h" + + +uint32 CFE_ResourceId_GetBase(CFE_ResourceId_t ResourceId) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_GetBase), ResourceId); + + int32 return_code; + + return_code = UT_DEFAULT_IMPL_RC(CFE_ResourceId_GetBase, -1); + + /* If a return code value was set, return it directly */ + if (return_code >= 0) + { + return (uint32)return_code; + } + + /* otherwise mimic a typical output (mask upper bits) */ + return CFE_ResourceId_ToInteger(ResourceId) & ~((uint32)CFE_RESOURCEID_MAX); +} + +uint32 CFE_ResourceId_GetSerial(CFE_ResourceId_t ResourceId) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_GetSerial), ResourceId); + + int32 return_code; + + return_code = UT_DEFAULT_IMPL_RC(CFE_ResourceId_GetSerial, -1); + + /* If a return code value was set, return it directly */ + if (return_code >= 0) + { + return (uint32)return_code; + } + + /* otherwise mimic a typical output (mask lower bits) */ + return (CFE_ResourceId_ToInteger(ResourceId) & ((uint32)CFE_RESOURCEID_MAX)); +} + +CFE_ResourceId_t CFE_ResourceId_FindNext(CFE_ResourceId_t StartId, uint32 TableSize, bool (*CheckFunc)(CFE_ResourceId_t)) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_FindNext), StartId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_FindNext), TableSize); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_FindNext), CheckFunc); + + int32 return_code; + + /* Using "1" by default here produces a sequential result when called multiple times */ + return_code = UT_DEFAULT_IMPL_RC(CFE_ResourceId_FindNext, 1); + + if (return_code < 0) + { + return CFE_RESOURCEID_UNDEFINED; + } + + /* + * The test case may set the return code to indicate the offset from the start ID + */ + return CFE_ResourceId_FromInteger(CFE_ResourceId_ToInteger(StartId) + return_code); +} + +int32 CFE_ResourceId_ToIndex(CFE_ResourceId_t Id, uint32 BaseValue, uint32 TableSize, uint32 *Idx) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToIndex), Id); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToIndex), BaseValue); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToIndex), TableSize); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToIndex), Idx); + + int32 return_code; + + return_code = UT_DEFAULT_IMPL(CFE_ResourceId_ToIndex); + + if (return_code < 0) + { + /* fill with a very bad value that should cause a problem if used */ + *Idx = 0xDEADBEEF; + } + else if (UT_Stub_CopyToLocal(UT_KEY(CFE_ResourceId_ToIndex), Idx, sizeof(*Idx)) < sizeof(*Idx)) + { + /* fill with default value if unspecified by test case */ + if (CFE_ResourceId_IsDefined(Id)) + { + *Idx = (CFE_ResourceId_ToInteger(Id) - BaseValue) % TableSize; + } + else + { + *Idx = 0xDEADBEEF; + return_code = CFE_ES_ERR_RESOURCEID_NOT_VALID; + } + } + + return return_code; +} + diff --git a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c b/fsw/cfe-core/ut-stubs/ut_sb_stubs.c index a6bf2162d..30742c081 100644 --- a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_sb_stubs.c @@ -47,16 +47,6 @@ typedef struct } CFE_SB_StubMsg_MetaData_t; - -/* -** Global variables -** -** NOTE: CFE_SB_Default_Qos is an oddball in that it is directly referenced by the code -** in other applications. Therefore the UT stub has to instantiate this in order to get -** any dependent code to link. -*/ -CFE_SB_Qos_t CFE_SB_Default_Qos; - static CFE_SB_StubMsg_MetaData_t* CFE_SB_StubMsg_GetMetaData(const CFE_MSG_Message_t *MsgPtr) { CFE_SB_StubMsg_MetaData_t* MetaPtr; @@ -866,7 +856,7 @@ size_t CFE_SB_GetTotalMsgLength(const CFE_MSG_Message_t *MsgPtr) ** This function does not return a value. ** ******************************************************************************/ -int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId) { int32 status; diff --git a/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c b/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c index c2fedd38b..f9df4806a 100644 --- a/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c @@ -91,7 +91,7 @@ void CFE_TBL_TaskMain(void) ** Returns CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_TBL_CleanUpApp(CFE_ES_AppId_t AppId) { int32 status; diff --git a/fsw/cfe-core/ut-stubs/ut_time_stubs.c b/fsw/cfe-core/ut-stubs/ut_time_stubs.c index 51a8df2c9..6d86b9625 100644 --- a/fsw/cfe-core/ut-stubs/ut_time_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_time_stubs.c @@ -171,7 +171,7 @@ CFE_TIME_SysTime_t CFE_TIME_GetTime(void) ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_TIME_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_TIME_CleanUpApp(CFE_ES_AppId_t AppId) { int32 status; diff --git a/modules/cfe_testcase/src/es_test.c b/modules/cfe_testcase/src/es_test.c index 2a8cb3784..f98f7bf2d 100644 --- a/modules/cfe_testcase/src/es_test.c +++ b/modules/cfe_testcase/src/es_test.c @@ -35,7 +35,7 @@ void ES_Test_AppId(void) { - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; char AppNameBuf[OS_MAX_API_NAME + 4]; UtAssert_INT32_EQ(CFE_ES_GetAppID(&AppId), CFE_SUCCESS); diff --git a/modules/resourceid/CMakeLists.txt b/modules/resourceid/CMakeLists.txt new file mode 100644 index 000000000..5550cb33d --- /dev/null +++ b/modules/resourceid/CMakeLists.txt @@ -0,0 +1,18 @@ +################################################################## +# +# cFE resource ID module CMake build recipe +# +################################################################## + +project(CFE_RESOURCEID C) + +# Module library +set(resourceid_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_resourceid_api.c) +add_library(resourceid STATIC ${resourceid_SOURCES}) + +target_include_directories(resourceid PUBLIC inc) + +# Add unit test coverage subdirectory +if(ENABLE_UNIT_TESTS) + add_subdirectory(unit-test-coverage) +endif(ENABLE_UNIT_TESTS) diff --git a/modules/resourceid/arch_build.cmake b/modules/resourceid/arch_build.cmake new file mode 100644 index 000000000..9d77078a7 --- /dev/null +++ b/modules/resourceid/arch_build.cmake @@ -0,0 +1,13 @@ +########################################################### +# +# Resource ID arch build setup +# +# This file is evaluated as part of the "prepare" stage +# and can be used to set up prerequisites for the build, +# such as generating header files +# +########################################################### + +# allow all other code to refer to the public API in the "inc" dir +# ideally this should use an interface library instead +include_directories(${CMAKE_CURRENT_LIST_DIR}/inc) diff --git a/modules/resourceid/mission_build.cmake b/modules/resourceid/mission_build.cmake new file mode 100644 index 000000000..31bd3e9d0 --- /dev/null +++ b/modules/resourceid/mission_build.cmake @@ -0,0 +1,32 @@ +########################################################### +# +# Resource ID mission build setup +# +# This file is evaluated as part of the "prepare" stage +# and can be used to set up prerequisites for the build, +# such as generating header files +# +########################################################### + +# Check if strict/enforcing typedef should be used +if (MISSION_RESOURCEID_MODE STREQUAL "STRICT") + set(RESOURCEID_HDR_FILE "cfe_resourceid_strict.h") +else () + set(RESOURCEID_HDR_FILE "cfe_resourceid_simple.h") +endif () + +# Generate the header definition files, use local default for this module) +generate_config_includefile( + FILE_NAME "cfe_resourceid_typedef.h" + FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/option/${RESOURCEID_HDR_FILE}" +) + +# Resource ID base value header +# Currently the "osal compatible" version is the only provided implementation, +# but missions can provide their own if desired to override this. +generate_config_includefile( + FILE_NAME "cfe_resourceid_basevalue.h" + FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/option/cfe_resourceid_osal_compatible.h" +) + +include_directories(${CMAKE_CURRENT_LIST_DIR}/inc) diff --git a/modules/resourceid/option/cfe_resourceid_osal_compatible.h b/modules/resourceid/option/cfe_resourceid_osal_compatible.h new file mode 100644 index 000000000..822dea588 --- /dev/null +++ b/modules/resourceid/option/cfe_resourceid_osal_compatible.h @@ -0,0 +1,79 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * \file cfe_resourceid_osal_compatible.h + * + * An implementation of CFE resource ID base values/limits that will be + * compatible with OSAL IDs. This is intended as a transitional tool to + * provide runtime value uniqueness, particularly when the "simple" (compatible) + * resource ID implementation is used. In this mode, compiler type checking + * is disabled, and so OSAL IDs can be silently interchanged with CFE IDs. + * + * However, by ensuring uniqueness in the runtime values, any ID handling + * errors may at least be detectable at runtime. + * + * This still works fine with the "strict" resource ID option, but is less + * important as the compiler type checking should prevent this type of error + * before the code even runs. + * + * The downside to this implementation is that it has a dependency on the + * OSAL ID structure. + */ + +#ifndef CFE_RESOURCEID_OSAL_COMPATIBLE_H +#define CFE_RESOURCEID_OSAL_COMPATIBLE_H + +/* +** Include Files +*/ +#include "cfe_resourceid_typedef.h" + +/* + * In this configuration, CFE resource IDs are tailored to not + * conflict/overlap with OSAL IDs, and are structured in a similar manner. + */ +#include "osapi-idmap.h" + +/* + * Limits/definitions related to CFE_ResourceId_t values. + * + * Defining based on OSAL ID values makes this object a superset of + * the OSAL ID type, such that OSAL IDs can be represented as resource IDs + * and not conflict with/alias each other. + * + * NOTE: This reflects a bit if "inside knowledge" about how OSAL IDs are + * constructed. The overlap between OSAL IDs and ES IDs may not always be + * consistent, and they can diverge in a future version. + */ +#define CFE_RESOURCEID_SHIFT OS_OBJECT_TYPE_SHIFT +#define CFE_RESOURCEID_MAX OS_OBJECT_INDEX_MASK + + +/** + * @brief A macro to generate a CFE resource ID base value from an offset + * + * Each CFE ID range is effectively an extension of OSAL ID ranges by + * starting at OS_OBJECT_TYPE_USER. + */ +#define CFE_RESOURCEID_MAKE_BASE(offset) (CFE_RESOURCEID_MARK | ((offset) << CFE_RESOURCEID_SHIFT)) + + +#endif /* CFE_RESOURCEID_OSAL_COMPATIBLE_H */ diff --git a/modules/resourceid/option/cfe_resourceid_simple.h b/modules/resourceid/option/cfe_resourceid_simple.h new file mode 100644 index 000000000..e92c31d9b --- /dev/null +++ b/modules/resourceid/option/cfe_resourceid_simple.h @@ -0,0 +1,64 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#ifndef CFE_RESOURCEID_SIMPLE_H +#define CFE_RESOURCEID_SIMPLE_H + +#include "common_types.h" + + +/** + * @brief A type that provides a common, abstract identifier for + * all ES managed resources (e.g. apps, tasks, counters, etc). + * + * Fundamentally an unsigned integer but users should treat it as + * opaque, and only go through the ES API for introspection. + */ +typedef uint32 CFE_ResourceId_t; + +/** + * @brief A macro providing a type for app-specific IDs + * + * Local ID types are just direct typedefs to CFE_ResourceId_t in this mode, + * this means all ID values can be interchanged. + */ +#define CFE_RESOURCEID_BASE_TYPE CFE_ResourceId_t + + +/** + * @brief A fixed bit that will be set in all CFE resource ID values + * + * In simple mode this is zero/disabled so that OSAL IDs and CFE IDs will + * have the same underlying values. This replicates historical behavior where + * CFE Task IDs and OSAL task IDs are same thing and are interchangable. + */ +#define CFE_RESOURCEID_MARK 0 + + +/* + * Wrap/Unwrap macros. + * + * In simple mode theese are a pass through/no-op as values are not + * wrapped/protected. + */ +#define CFE_RESOURCEID_WRAP(x) x +#define CFE_RESOURCEID_UNWRAP(x) x + +#endif /* CFE_RESOURCEID_SIMPLE_H */ diff --git a/modules/resourceid/option/cfe_resourceid_strict.h b/modules/resourceid/option/cfe_resourceid_strict.h new file mode 100644 index 000000000..b47185f39 --- /dev/null +++ b/modules/resourceid/option/cfe_resourceid_strict.h @@ -0,0 +1,87 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#ifndef CFE_RESOURCEID_STRICT_H +#define CFE_RESOURCEID_STRICT_H + +#include "common_types.h" + +/* + * Inform other code that the "strict mode" is enabled for resource IDs + * + * This in turn allows ES to adjust other macros/conversions as necessary + * to work with the strict type checking. + */ +#define CFE_RESOURCEID_STRICT_MODE + +/** + * @brief A type that provides a common, abstract identifier for + * all CFE managed resources (e.g. apps, tasks, counters, etc). + * + * Fundamentally an unsigned integer but users should treat it as + * opaque, and only go through the ES API for introspection. + * + */ +typedef struct +{ + uint32 id; +} CFE_ResourceId_t; + +/** + * @brief A macro to generate a basetype for app-specific IDs + * + * Resource IDs may be "wrapped" a second time to make a unique + * typedef for application-specific ID values. + * + * Defining this base type as a macro rather than a typedef is intentional + * such that every time this is used it makes an equivalent but different + * type. That is, it is a different type per the compiler type checking + * but has the same content/structure. + */ +#define CFE_RESOURCEID_BASE_TYPE \ + struct \ + { \ + CFE_ResourceId_t id; \ + } + + +/** + * @brief A fixed bit that should be set in all CFE resource ID values + * + * In strict mode this is nonzero so that OSAL IDs and CFE IDs will have + * different values. This means that CFE Task IDs will not be interchangable + * with OSAL task IDs, either in value or type. + */ +#define CFE_RESOURCEID_MARK 0x02000000 + + +/* + * Wrap/Unwrap macros. + * + * These are helpers for transparently accessing through wrapper types. + * + * These are not type-safe - Whenever possible applications should use + * the type-safe inline functions provided in cfe_resourceid.h instead. + */ +#define CFE_RESOURCEID_WRAP(x) {x} +#define CFE_RESOURCEID_UNWRAP(x) (x).id + + +#endif /* CFE_RESOURCEID_STRICT_H */ diff --git a/modules/resourceid/src/cfe_resourceid_api.c b/modules/resourceid/src/cfe_resourceid_api.c new file mode 100644 index 000000000..fd7a16718 --- /dev/null +++ b/modules/resourceid/src/cfe_resourceid_api.c @@ -0,0 +1,134 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: +** cfe_resource_api.c +** +** Purpose: +** Function definitions related to CFE resource management +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** cFE Flight Software Application Developers Guide +*/ + +/* +** Includes +*/ +#include +#include +#include + +#include "cfe.h" +#include "cfe_resourceid_api.h" +#include "cfe_resourceid_basevalue.h" + + +/*********************************************************************/ +/* + * CFE_ResourceId_GetBase + * + * For complete API information, see prototype in header + */ +uint32 CFE_ResourceId_GetBase(CFE_ResourceId_t ResourceId) +{ + return (CFE_ResourceId_ToInteger(ResourceId) & ~((uint32)CFE_RESOURCEID_MAX)); +} + +/*********************************************************************/ +/* + * CFE_ResourceId_GetSerial + * + * For complete API information, see prototype in header + */ +uint32 CFE_ResourceId_GetSerial(CFE_ResourceId_t ResourceId) +{ + return (CFE_ResourceId_ToInteger(ResourceId) & ((uint32)CFE_RESOURCEID_MAX)); +} + + +/*********************************************************************/ +/* + * CFE_ResourceId_ToIndex + * + * For complete API information, see prototype in header + */ +int32 CFE_ResourceId_ToIndex(CFE_ResourceId_t Id, uint32 BaseValue, uint32 TableSize, uint32 *Idx) +{ + uint32 Serial; + + if (Idx == NULL) + { + return CFE_ES_ERR_BUFFER; + } + + Serial = CFE_ResourceId_ToInteger(Id) - BaseValue; + + if (Serial > CFE_RESOURCEID_MAX || TableSize == 0) + { + return CFE_ES_ERR_RESOURCEID_NOT_VALID; + } + + *Idx = Serial % TableSize; + return CFE_SUCCESS; +} + +/*********************************************************************/ +/* + * CFE_ResourceId_FindNext + * + * For complete API information, see prototype in header + */ +CFE_ResourceId_t CFE_ResourceId_FindNext(CFE_ResourceId_t StartId, uint32 TableSize, bool (*CheckFunc)(CFE_ResourceId_t)) +{ + uint32 Serial; + uint32 Count; + uint32 ResourceType; + CFE_ResourceId_t CheckId; + bool IsTaken; + + ResourceType = CFE_ResourceId_GetBase(StartId); + Serial = CFE_ResourceId_GetSerial(StartId); + + Count = TableSize; + IsTaken = true; + + do + { + if (Count == 0) + { + CheckId = CFE_RESOURCEID_UNDEFINED; + break; + } + + --Count; + ++Serial; + if (Serial >= CFE_RESOURCEID_MAX) + { + Serial %= TableSize; + } + + CheckId = CFE_ResourceId_FromInteger(ResourceType + Serial); + IsTaken = CheckFunc(CheckId); + } while (IsTaken); + + return CheckId; +} diff --git a/modules/resourceid/unit-test-coverage/CMakeLists.txt b/modules/resourceid/unit-test-coverage/CMakeLists.txt new file mode 100644 index 000000000..42ca3bde8 --- /dev/null +++ b/modules/resourceid/unit-test-coverage/CMakeLists.txt @@ -0,0 +1,29 @@ +################################################################## +# +# cFE unit test build recipe +# +# This CMake file contains the recipe for building the cFE unit tests. +# It is invoked from the parent directory when unit tests are enabled. +# +################################################################## + +# Unit test object library sources, options, and includes +add_library(ut_resourceid_OBJS OBJECT ${resourceid_SOURCES}) +target_compile_options(ut_resourceid_OBJS PRIVATE ${UT_COVERAGE_COMPILE_FLAGS}) + +# Add executable +add_executable(resourceid_UT test_cfe_resourceid.c $) + +# allow direct use of the "option" headers no matter which is actually selected by mission +target_include_directories(resourceid_UT PRIVATE ${CFE_RESOURCEID_SOURCE_DIR}/option) + +# Also add the UT_COVERAGE_LINK_FLAGS to the link command +# This should enable coverage analysis on platforms that support this +target_link_libraries(resourceid_UT + ${UT_COVERAGE_LINK_FLAGS} + ut_assert) + +add_test(resourceid_UT resourceid_UT) +foreach(TGT ${INSTALL_TARGET_LIST}) + install(TARGETS resourceid_UT DESTINATION ${TGT}/${UT_INSTALL_SUBDIR}) +endforeach() diff --git a/modules/resourceid/unit-test-coverage/test_cfe_resourceid.c b/modules/resourceid/unit-test-coverage/test_cfe_resourceid.c new file mode 100644 index 000000000..df59ffeaa --- /dev/null +++ b/modules/resourceid/unit-test-coverage/test_cfe_resourceid.c @@ -0,0 +1,181 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* + * Includes + */ +#include "cfe.h" +#include "cfe_resourceid_api.h" +#include "cfe_resourceid_basevalue.h" +#include "utassert.h" +#include "utstubs.h" +#include "uttest.h" + +#define UT_RESOURCEID_BASE_OFFSET 37 +#define UT_RESOURCEID_TEST_SLOTS 149 /* oddball for test purposes */ + +static bool UT_ResourceId_CheckIdSlotUsed(CFE_ResourceId_t Id) +{ + return UT_DEFAULT_IMPL(UT_ResourceId_CheckIdSlotUsed) != 0; +} + + +void TestResourceID(void) +{ + /* + * Test cases for generic resource ID functions which are + * not sufficiently covered by other app/lib tests. + */ + CFE_ResourceId_t Id; + CFE_ResourceId_t LastId; + int32 status; + uint32 RefBase; + uint32 Count; + uint32 TestBase; + uint32 TestSerial; + uint32 RefSerial; + uint32 TestIndex; + uint32 RefIndex; + + /* Call CFE_ResourceId_FindNext() using an invalid resource type */ + UT_SetDefaultReturnValue(UT_KEY(UT_ResourceId_CheckIdSlotUsed), 1); + Id = CFE_ResourceId_FindNext(CFE_RESOURCEID_UNDEFINED, 5, UT_ResourceId_CheckIdSlotUsed); + UtAssert_True(!CFE_ResourceId_IsDefined(Id), "CFE_ResourceId_FindNext() on undefined resource type"); + + /* Verify that CFE_ResourceId_FindNext() does not repeat until CFE_RESOURCEID_MAX is reached */ + UT_SetDefaultReturnValue(UT_KEY(UT_ResourceId_CheckIdSlotUsed), 0); + RefBase = CFE_RESOURCEID_MAKE_BASE(UT_RESOURCEID_BASE_OFFSET); + LastId = CFE_ResourceId_FromInteger(RefBase); + RefIndex = 1; + RefSerial = 1; + + /* + * In this case it is useful/relevant to call CFE_ResourceId_FindNext() thousands + * of times, in order to exercise and verify the wrap capability. That is, when the + * serial number reaches CFE_RESOURCEID_MAX, it should wrap back around to the + * beginning again. + * + * Note in this loop only _failures_ are asserted, to de-clutter the log - + * otherwise thousands of success cases will be recorded. + */ + Count = CFE_RESOURCEID_MAX - 1; + while (Count > 0) + { + Id = CFE_ResourceId_FindNext(LastId, UT_RESOURCEID_TEST_SLOTS, UT_ResourceId_CheckIdSlotUsed); + if (CFE_ResourceId_ToInteger(Id) - CFE_ResourceId_ToInteger(LastId) != 1) + { + /* Numbers should be incrementing by 1 each time, never decreasing */ + UtAssert_Failed("ID increment error: got=%lx, previous=%lx", CFE_ResourceId_ToInteger(Id), + CFE_ResourceId_ToInteger(LastId)); + break; + } + + TestBase = CFE_ResourceId_GetBase(Id); + if (TestBase != RefBase) + { + UtAssert_Failed("ID base changed: id=%lx, expected=%lx, got=%lx", CFE_ResourceId_ToInteger(Id), + (unsigned long)RefBase, (unsigned long)TestBase); + } + TestSerial = CFE_ResourceId_GetSerial(Id); + if (TestSerial != RefSerial) + { + UtAssert_Failed("ID serial jump: id=%lx, previous=%lx, got=%lx", CFE_ResourceId_ToInteger(Id), + (unsigned long)RefSerial, (unsigned long)TestSerial); + } + + status = CFE_ResourceId_ToIndex(Id, RefBase, UT_RESOURCEID_TEST_SLOTS, &TestIndex); + if (status != CFE_SUCCESS) + { + UtAssert_Failed("CFE_ResourceId_ToIndex() failed: id=%lx, rc=%lx", CFE_ResourceId_ToInteger(Id), + (unsigned long)status); + } + + if (TestIndex != RefIndex) + { + UtAssert_Failed("ID index mismatch: id=%lx, expected=%lu, got=%lu", CFE_ResourceId_ToInteger(Id), + (unsigned long)RefIndex, (unsigned long)TestIndex); + } + + LastId = Id; + --Count; + + /* Adjust to next index value */ + ++RefIndex; + if (RefIndex >= UT_RESOURCEID_TEST_SLOTS) + { + RefIndex = 0; + } + ++RefSerial; + } + + UtAssert_True(Count == 0, "CFE_ResourceId_FindNext() allocated all resource ID space"); + + /* Now verify that CFE_ResourceId_FindNext() recycles the first item again */ + Id = CFE_ResourceId_FindNext(LastId, UT_RESOURCEID_TEST_SLOTS, UT_ResourceId_CheckIdSlotUsed); + UtAssert_True(CFE_ResourceId_IsDefined(Id), "CFE_ResourceId_FindNext() after wrap"); + UtAssert_True(CFE_ResourceId_ToInteger(Id) < (RefBase + UT_RESOURCEID_TEST_SLOTS), "CFE_ResourceId_FindNext() wrap ID"); + + /* + * Confirm outputs are as expected after wrapping around - + * indices should be sequential + */ + UtAssert_UINT32_EQ(CFE_ResourceId_GetBase(Id), RefBase); + + TestSerial = CFE_ResourceId_GetSerial(Id); + UtAssert_True(TestSerial < UT_RESOURCEID_TEST_SLOTS, "ID serial after wrap: id=%lx, previous=%lx, got=%lx", + CFE_ResourceId_ToInteger(Id), (unsigned long)RefSerial, (unsigned long)TestSerial); + + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, UT_RESOURCEID_TEST_SLOTS, &TestIndex), CFE_SUCCESS); + UtAssert_True(TestIndex == RefIndex, "ID index after wrap: id=%lx, expected=%lu, got=%lu", CFE_ResourceId_ToInteger(Id), + (unsigned long)RefIndex, (unsigned long)TestIndex); + + + /* + * Now check that CFE_ResourceId_FindNext() adheres to the CheckFunc. + * Have it search through 4 entries to find one available on the 5th slot. + */ + UT_SetDefaultReturnValue(UT_KEY(UT_ResourceId_CheckIdSlotUsed), true); + UT_SetDeferredRetcode(UT_KEY(UT_ResourceId_CheckIdSlotUsed), 5, false); + RefIndex = (RefIndex + 4) % UT_RESOURCEID_TEST_SLOTS; /* expected */ + RefSerial = TestSerial + 4; + + Id = CFE_ResourceId_FindNext(LastId, UT_RESOURCEID_TEST_SLOTS, UT_ResourceId_CheckIdSlotUsed); + TestSerial = CFE_ResourceId_GetSerial(Id); + UtAssert_True(TestSerial == RefSerial, "ID serial after search: id=%lx, previous=%lx, got=%lx", + CFE_ResourceId_ToInteger(Id), (unsigned long)RefSerial, (unsigned long)TestSerial); + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, UT_RESOURCEID_TEST_SLOTS, &TestIndex), CFE_SUCCESS); + UtAssert_True(TestIndex == RefIndex, "ID index after search: id=%lx, expected=%lu, got=%lu", CFE_ResourceId_ToInteger(Id), + (unsigned long)RefIndex, (unsigned long)TestIndex); + + + /* Validate off-nominal inputs */ + Id = CFE_ResourceId_FindNext(CFE_RESOURCEID_UNDEFINED, 0, NULL); + UtAssert_True(CFE_ResourceId_Equal(Id, CFE_RESOURCEID_UNDEFINED), "CFE_ResourceId_FindNext() bad input: id=%lx", + CFE_ResourceId_ToInteger(Id)); + + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, 1, NULL), CFE_ES_ERR_BUFFER); + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, 0, &TestIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, ~RefBase, 1, &TestIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID); +} + +void UtTest_Setup(void) +{ + UtTest_Add(TestResourceID, NULL, NULL, "Resource ID"); +} diff --git a/modules/sbr/src/cfe_sbr_route_unsorted.c b/modules/sbr/src/cfe_sbr_route_unsorted.c index 716cd50e4..d47aa4eb1 100644 --- a/modules/sbr/src/cfe_sbr_route_unsorted.c +++ b/modules/sbr/src/cfe_sbr_route_unsorted.c @@ -178,39 +178,28 @@ CFE_MSG_SequenceCount_t CFE_SBR_GetSequenceCounter(CFE_SBR_RouteId_t RouteId) } /****************************************************************************** - * Local helper function for throttling foreach routines - * - * Updates StartIdxPtr, EndIdxPtr and ThrottlePtr.NextIndex. Note EndIdxPtr - * must be set to maximum prior to calling. + * Interface function - see API for description */ -void CFE_SBR_Throttle(uint32 *StartIdxPtr, uint32 *EndIdxPtr, CFE_SBR_Throttle_t *ThrottlePtr) +void CFE_SBR_ForEachRouteId(CFE_SBR_CallbackPtr_t CallbackPtr, void *ArgPtr, CFE_SBR_Throttle_t *ThrottlePtr) { + CFE_SB_RouteId_Atom_t routeidx; + CFE_SB_RouteId_Atom_t startidx = 0; + CFE_SB_RouteId_Atom_t endidx = CFE_SBR_RDATA.RouteIdxTop; + + /* Update throttle settings if needed */ if (ThrottlePtr != NULL) { - *StartIdxPtr = ThrottlePtr->StartIndex; + startidx = ThrottlePtr->StartIndex; /* Return next index of zero if full range is processed */ ThrottlePtr->NextIndex = 0; - if ((*StartIdxPtr + ThrottlePtr->MaxLoop) < *EndIdxPtr) + if ((startidx + ThrottlePtr->MaxLoop) < endidx) { - *EndIdxPtr = *StartIdxPtr + ThrottlePtr->MaxLoop; - ThrottlePtr->NextIndex = *EndIdxPtr; + endidx = startidx + ThrottlePtr->MaxLoop; + ThrottlePtr->NextIndex = endidx; } } -} - -/****************************************************************************** - * Interface function - see API for description - */ -void CFE_SBR_ForEachRouteId(CFE_SBR_CallbackPtr_t CallbackPtr, void *ArgPtr, CFE_SBR_Throttle_t *ThrottlePtr) -{ - CFE_SB_RouteId_Atom_t routeidx; - CFE_SB_MsgId_Atom_t startidx = 0; - CFE_SB_MsgId_Atom_t endidx = CFE_SBR_RDATA.RouteIdxTop; - - /* Update throttle settings if needed */ - CFE_SBR_Throttle(&startidx, &endidx, ThrottlePtr); for (routeidx = startidx; routeidx < endidx; routeidx++) {