From 96d82c53b6a4bcd4f6de1bce646e1a5394fab945 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 22 Sep 2020 12:54:24 -0400 Subject: [PATCH] Fix #894, add resource ID type Add a new typedef "CFE_ES_ResourceID_t" that can replace uint32 for all ID storage and manipulation. Initially this is just an alias to uint32 for backward compatibility. Convert all APIs that accept an ID to use the new typedef. This also reserves the value "0" as an undefined ID, and gives a separate base value for each resource type. Therefore even though the type is still uint32, the different resource IDs can still be distingushed. --- fsw/cfe-core/src/es/cfe_es_api.c | 158 +++++++++--------- fsw/cfe-core/src/es/cfe_es_apps.c | 39 ++--- fsw/cfe-core/src/es/cfe_es_apps.h | 18 +- fsw/cfe-core/src/es/cfe_es_backgroundtask.c | 2 +- fsw/cfe-core/src/es/cfe_es_cds.c | 4 +- fsw/cfe-core/src/es/cfe_es_cds.h | 2 +- fsw/cfe-core/src/es/cfe_es_erlog.c | 4 +- fsw/cfe-core/src/es/cfe_es_global.h | 125 ++++++++------ fsw/cfe-core/src/es/cfe_es_log.h | 2 +- fsw/cfe-core/src/es/cfe_es_start.c | 2 +- fsw/cfe-core/src/es/cfe_es_task.c | 11 +- fsw/cfe-core/src/es/cfe_esmempool.c | 4 +- fsw/cfe-core/src/evs/cfe_evs.c | 14 +- fsw/cfe-core/src/evs/cfe_evs_task.c | 8 +- fsw/cfe-core/src/evs/cfe_evs_task.h | 5 +- fsw/cfe-core/src/evs/cfe_evs_utils.c | 12 +- fsw/cfe-core/src/evs/cfe_evs_utils.h | 23 ++- fsw/cfe-core/src/fs/cfe_fs_api.c | 4 +- fsw/cfe-core/src/fs/cfe_fs_priv.c | 4 +- fsw/cfe-core/src/inc/cfe_error.h | 23 ++- fsw/cfe-core/src/inc/cfe_es.h | 135 +++++++++++---- fsw/cfe-core/src/inc/cfe_evs.h | 2 +- fsw/cfe-core/src/inc/cfe_evs_msg.h | 2 +- .../src/inc/private/cfe_es_erlog_typedef.h | 2 +- fsw/cfe-core/src/inc/private/cfe_private.h | 8 +- fsw/cfe-core/src/sb/cfe_sb_api.c | 64 +++---- fsw/cfe-core/src/sb/cfe_sb_priv.c | 19 ++- fsw/cfe-core/src/sb/cfe_sb_priv.h | 26 +-- fsw/cfe-core/src/tbl/cfe_tbl_api.c | 34 ++-- fsw/cfe-core/src/tbl/cfe_tbl_internal.c | 27 +-- fsw/cfe-core/src/tbl/cfe_tbl_internal.h | 10 +- fsw/cfe-core/src/tbl/cfe_tbl_task.h | 6 +- fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c | 8 +- fsw/cfe-core/src/time/cfe_time_api.c | 4 +- fsw/cfe-core/src/time/cfe_time_utils.c | 2 +- fsw/cfe-core/src/time/cfe_time_utils.h | 4 +- fsw/cfe-core/unit-test/es_UT.c | 56 ++++--- fsw/cfe-core/unit-test/evs_UT.c | 20 +-- fsw/cfe-core/unit-test/sb_UT.c | 30 ++-- fsw/cfe-core/unit-test/tbl_UT.c | 117 +++++++------ fsw/cfe-core/unit-test/time_UT.c | 25 +-- fsw/cfe-core/unit-test/ut_support.c | 6 +- fsw/cfe-core/unit-test/ut_support.h | 2 +- fsw/cfe-core/ut-stubs/ut_es_stubs.c | 54 +++--- fsw/cfe-core/ut-stubs/ut_evs_stubs.c | 2 +- modules/cfe_testcase/src/es_test.c | 2 +- 46 files changed, 627 insertions(+), 504 deletions(-) diff --git a/fsw/cfe-core/src/es/cfe_es_api.c b/fsw/cfe-core/src/es/cfe_es_api.c index 895cca897..81fcb98c7 100644 --- a/fsw/cfe-core/src/es/cfe_es_api.c +++ b/fsw/cfe-core/src/es/cfe_es_api.c @@ -167,7 +167,7 @@ int32 CFE_ES_ResetCFE(uint32 ResetType) /* ** Function: CFE_ES_RestartApp - See API and header file for details */ -int32 CFE_ES_RestartApp(uint32 AppID) +int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) { int32 ReturnCode = CFE_SUCCESS; CFE_ES_AppRecord_t *AppRecPtr; @@ -218,7 +218,7 @@ int32 CFE_ES_RestartApp(uint32 AppID) /* ** Function: CFE_ES_ReloadApp - See API and header file for details */ -int32 CFE_ES_ReloadApp(uint32 AppID, const char *AppFileName) +int32 CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName) { int32 ReturnCode = CFE_SUCCESS; os_fstat_t FileStatus; @@ -276,7 +276,7 @@ int32 CFE_ES_ReloadApp(uint32 AppID, const char *AppFileName) /* ** Function: CFE_ES_DeleteApp - See API and header file for details */ -int32 CFE_ES_DeleteApp(uint32 AppID) +int32 CFE_ES_DeleteApp(CFE_ES_ResourceID_t AppID) { int32 ReturnCode = CFE_SUCCESS; CFE_ES_AppRecord_t *AppRecPtr = CFE_ES_LocateAppRecordByID(AppID); @@ -689,7 +689,7 @@ int32 CFE_ES_RegisterApp(void) /* ** Function: CFE_ES_GetAppIDByName - See API and header file for details */ -int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) +int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) { int32 Result = CFE_ES_ERR_APPNAME; CFE_ES_AppRecord_t *AppRecPtr; @@ -699,7 +699,7 @@ int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) * ensure the output value is set to a safe value, * in case the does not check the return code. */ - *AppIdPtr = 0; + *AppIdPtr = CFE_ES_RESOURCEID_UNDEFINED; CFE_ES_LockSharedData(__func__,__LINE__); @@ -732,7 +732,7 @@ int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) /* ** Function: CFE_ES_GetAppID - See API and header file for details */ -int32 CFE_ES_GetAppID(uint32 *AppIdPtr) +int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) { int32 Result; @@ -749,7 +749,7 @@ int32 CFE_ES_GetAppID(uint32 *AppIdPtr) /* ** Function: CFE_ES_GetTaskID - See API and header file for details */ -int32 CFE_ES_GetTaskID(uint32 *TaskIdPtr) +int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) { int32 Result; CFE_ES_TaskRecord_t *TaskRecPtr; @@ -758,7 +758,7 @@ int32 CFE_ES_GetTaskID(uint32 *TaskIdPtr) TaskRecPtr = CFE_ES_GetTaskRecordByContext(); if (TaskRecPtr == NULL) { - *TaskIdPtr = 0; + *TaskIdPtr = CFE_ES_RESOURCEID_UNDEFINED; Result = CFE_ES_ERR_TASKID; } else @@ -773,7 +773,7 @@ int32 CFE_ES_GetTaskID(uint32 *TaskIdPtr) /* ** Function: CFE_ES_GetAppName - See API and header file for details */ -int32 CFE_ES_GetAppName(char *AppName, uint32 AppId, uint32 BufferLength) +int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, uint32 BufferLength) { int32 Result; CFE_ES_AppRecord_t *AppRecPtr; @@ -823,7 +823,7 @@ int32 CFE_ES_GetAppName(char *AppName, uint32 AppId, uint32 BufferLength) /* ** Function: CFE_ES_GetAppInfo - See API and header file for details */ -int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId) +int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) { int32 ReturnCode = CFE_SUCCESS; CFE_ES_AppRecord_t *AppRecPtr; @@ -843,7 +843,7 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId) if ( AppRecPtr == NULL ) { CFE_ES_WriteToSysLog("CFE_ES_GetAppInfo: App ID Invalid: %lu\n", - (unsigned long)AppId); + CFE_ES_ResourceID_ToInteger(AppId)); return CFE_ES_ERR_APPID; } @@ -866,7 +866,7 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId) /* ** Function: CFE_ES_GetTaskInfo - See API and header file for details */ -int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId) +int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId) { CFE_ES_TaskRecord_t *TaskRecPtr; int32 ReturnCode; @@ -910,7 +910,7 @@ int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId) /* ** Function: CFE_ES_CreateChildTask - See API and header file for details */ -int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, +int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, uint32 *StackPtr, @@ -923,9 +923,9 @@ int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, CFE_ES_AppRecord_t *AppRecPtr; CFE_ES_TaskRecord_t *TaskRecPtr; int32 ReturnCode; - uint32 TaskId; - uint32 ChildTaskId; - uint32 ParentTaskId; + CFE_ES_ResourceID_t TaskId; + CFE_ES_ResourceID_t ChildTaskId; + CFE_ES_ResourceID_t ParentTaskId; osal_id_t OsalId; /* @@ -977,7 +977,7 @@ int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, OsalId = OS_TaskGetId(); TaskId = CFE_ES_ResourceID_FromOSAL(OsalId); ParentTaskId = AppRecPtr->TaskInfo.MainTaskId; - if ( TaskId == ParentTaskId ) + if ( CFE_ES_ResourceID_Equal(TaskId, ParentTaskId) ) { /* ** Truncate the priority if needed @@ -1079,7 +1079,7 @@ int32 CFE_ES_RegisterChildTask(void) void CFE_ES_IncrementTaskCounter(void) { CFE_ES_TaskRecord_t *TaskRecPtr; - uint32 TaskID; + CFE_ES_ResourceID_t TaskID; /* * Note this locates a task record but intentionally does _not_ @@ -1106,7 +1106,7 @@ void CFE_ES_IncrementTaskCounter(void) /* ** Function: CFE_ES_DeleteChildTask - See API and header file for details */ -int32 CFE_ES_DeleteChildTask(uint32 TaskId) +int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) { CFE_ES_TaskRecord_t *TaskRecPtr; CFE_ES_AppRecord_t *AppRecPtr; @@ -1139,7 +1139,7 @@ int32 CFE_ES_DeleteChildTask(uint32 TaskId) { if ( CFE_ES_AppRecordIsUsed(AppRecPtr) ) { - if ( AppRecPtr->TaskInfo.MainTaskId == TaskId ) + if ( CFE_ES_ResourceID_Equal(AppRecPtr->TaskInfo.MainTaskId, TaskId) ) { /* ** Error, the task Id is an App Main Task ID @@ -1401,7 +1401,7 @@ int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, int32 BlockSize, cons { int32 Status; size_t NameLen = 0; - uint32 ThisAppId; + CFE_ES_ResourceID_t ThisAppId; char AppName[OS_MAX_API_NAME] = {"UNKNOWN"}; char CDSName[CFE_ES_CDS_MAX_FULL_NAME_LEN] = {""}; @@ -1504,10 +1504,10 @@ int32 CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle) /* end of file */ -int32 CFE_ES_RegisterGenCounter(uint32 *CounterIdPtr, const char *CounterName) +int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName) { int32 ReturnCode = CFE_ES_BAD_ARGUMENT; - uint32 CheckPtr; + CFE_ES_ResourceID_t CheckPtr; int32 Status; uint32 i; CFE_ES_GenCounterRecord_t *CountRecPtr; @@ -1524,7 +1524,8 @@ int32 CFE_ES_RegisterGenCounter(uint32 *CounterIdPtr, const char *CounterName) { strncpy(CountRecPtr->CounterName,CounterName,OS_MAX_API_NAME); CountRecPtr->Counter = 0; - CFE_ES_CounterRecordSetUsed(CountRecPtr, i); + CFE_ES_CounterRecordSetUsed(CountRecPtr, + CFE_ES_ResourceID_FromInteger(i + CFE_ES_COUNTID_BASE)); *CounterIdPtr = CFE_ES_CounterRecordGetID(CountRecPtr); break; } @@ -1547,7 +1548,7 @@ int32 CFE_ES_RegisterGenCounter(uint32 *CounterIdPtr, const char *CounterName) ** Purpose: Delete a Generic Counter. ** */ -int32 CFE_ES_DeleteGenCounter(uint32 CounterId) +int32 CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId) { CFE_ES_GenCounterRecord_t *CountRecPtr; int32 Status = CFE_ES_BAD_ARGUMENT; @@ -1575,7 +1576,7 @@ int32 CFE_ES_DeleteGenCounter(uint32 CounterId) ** Purpose: Increment a Generic Counter. ** */ -int32 CFE_ES_IncrementGenCounter(uint32 CounterId) +int32 CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId) { int32 Status = CFE_ES_BAD_ARGUMENT; CFE_ES_GenCounterRecord_t *CountRecPtr; @@ -1596,7 +1597,7 @@ int32 CFE_ES_IncrementGenCounter(uint32 CounterId) ** Purpose: Sets a Generic Counter's count. ** */ -int32 CFE_ES_SetGenCount(uint32 CounterId, uint32 Count) +int32 CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count) { int32 Status = CFE_ES_BAD_ARGUMENT; CFE_ES_GenCounterRecord_t *CountRecPtr; @@ -1616,7 +1617,7 @@ int32 CFE_ES_SetGenCount(uint32 CounterId, uint32 Count) ** Purpose: Gets the value of a Generic Counter. ** */ -int32 CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count) +int32 CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count) { int32 Status = CFE_ES_BAD_ARGUMENT; CFE_ES_GenCounterRecord_t *CountRecPtr; @@ -1631,7 +1632,7 @@ int32 CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count) return Status; } /* End of CFE_ES_GetGenCount() */ -int32 CFE_ES_GetGenCounterIDByName(uint32 *CounterIdPtr, const char *CounterName) +int32 CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName) { CFE_ES_GenCounterRecord_t *CountRecPtr; int32 Result = CFE_ES_BAD_ARGUMENT; @@ -1667,41 +1668,42 @@ int32 CFE_ES_GetGenCounterIDByName(uint32 *CounterIdPtr, const char *CounterName /* - * 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. + * A conversion function to obtain an index value correlating to a generic resource ID + * This is a zero based value that can be used as an array index. */ -int32 CFE_ES_AppID_ToIndex(uint32 AppId, uint32 *Idx) +int32 CFE_ES_ResourceID_ToIndex_Internal(uint32 Serial, uint32 TableSize, uint32 *Idx) { - if (AppId >= CFE_PLATFORM_ES_MAX_APPLICATIONS) + if (Serial > CFE_ES_RESOURCEID_MAX) { - return CFE_ES_ERR_APPID; + return CFE_ES_RESOURCE_ID_INVALID; } - /* - * Currently this is a direct/simple pass through. - * Will evolve in a future rev to make it more safe. - */ - *Idx = AppId; + *Idx = Serial % TableSize; return CFE_SUCCESS; } /* - * A conversion function to obtain an index value correlating to a LibID + * 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_LibID_ToIndex(uint32 LibId, uint32 *Idx) +int32 CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx) { - if (LibId >= CFE_PLATFORM_ES_MAX_LIBRARIES) - { - return CFE_ES_BAD_ARGUMENT; /* these do not have a dedicated error */ - } + return CFE_ES_ResourceID_ToIndex_Internal( + CFE_ES_ResourceID_ToInteger(AppID) - CFE_ES_APPID_BASE, + CFE_PLATFORM_ES_MAX_APPLICATIONS, + Idx); +} - /* - * Currently this is a direct/simple pass through. - * Will evolve in a future rev to make it more safe. - */ - *Idx = LibId; - return CFE_SUCCESS; +/* + * 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) +{ + return CFE_ES_ResourceID_ToIndex_Internal( + CFE_ES_ResourceID_ToInteger(LibId) - CFE_ES_LIBID_BASE, + CFE_PLATFORM_ES_MAX_LIBRARIES, + Idx); } /* @@ -1711,12 +1713,17 @@ int32 CFE_ES_LibID_ToIndex(uint32 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(uint32 TaskID, uint32 *Idx) +int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx) { osal_id_t OsalID; + if (!CFE_ES_ResourceID_IsDefined(TaskID)) + { + return CFE_ES_ERR_TASKID; + } + OsalID = CFE_ES_ResourceID_ToOSAL(TaskID); - if (OS_ConvertToArrayIndex(OsalID, Idx) != OS_SUCCESS) + if (OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, OsalID, Idx) != OS_SUCCESS) { return CFE_ES_ERR_TASKID; } @@ -1728,19 +1735,12 @@ int32 CFE_ES_TaskID_ToIndex(uint32 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(uint32 CounterId, uint32 *Idx) +int32 CFE_ES_CounterID_ToIndex(CFE_ES_ResourceID_t CounterId, uint32 *Idx) { - if (CounterId >= CFE_PLATFORM_ES_MAX_GEN_COUNTERS) - { - return CFE_ES_BAD_ARGUMENT; /* these do not have a dedicated error */ - } - - /* - * Currently this is a direct/simple pass through. - * Will evolve in a future rev to make it more safe. - */ - *Idx = CounterId; - return CFE_SUCCESS; + return CFE_ES_ResourceID_ToIndex_Internal( + CFE_ES_ResourceID_ToInteger(CounterId) - CFE_ES_COUNTID_BASE, + CFE_PLATFORM_ES_MAX_GEN_COUNTERS, + Idx); } /*************************************************************************************** @@ -1756,10 +1756,10 @@ int32 CFE_ES_CounterID_ToIndex(uint32 CounterId, uint32 *Idx) * Note this may result in an invalid OSAL ID if the CFE_ES_ResourceID_t did * not actually refer to an OSAL resource. */ -osal_id_t CFE_ES_ResourceID_ToOSAL(uint32 id) +osal_id_t CFE_ES_ResourceID_ToOSAL(CFE_ES_ResourceID_t id) { - unsigned long val = (uint32)id; /* type conversion */ - return OS_ObjectIdFromInteger(val); + unsigned long val = CFE_ES_ResourceID_ToInteger(id); + return OS_ObjectIdFromInteger(val ^ CFE_ES_RESOURCEID_MARK); } /** @@ -1767,10 +1767,10 @@ osal_id_t CFE_ES_ResourceID_ToOSAL(uint32 id) * * Any OSAL ID can also be represented as a CFE_ES_ResourceID_t */ -uint32 CFE_ES_ResourceID_FromOSAL(osal_id_t id) +CFE_ES_ResourceID_t CFE_ES_ResourceID_FromOSAL(osal_id_t id) { unsigned long val = OS_ObjectIdToInteger(id); - return (uint32)val; /* type conversion */ + return CFE_ES_ResourceID_FromInteger(val ^ CFE_ES_RESOURCEID_MARK); } @@ -1779,7 +1779,7 @@ uint32 CFE_ES_ResourceID_FromOSAL(osal_id_t id) * otherwise check/validate said pointer, as that would have to be done while * locked. */ -CFE_ES_AppRecord_t *CFE_ES_LocateAppRecordByID(uint32 AppID) +CFE_ES_AppRecord_t *CFE_ES_LocateAppRecordByID(CFE_ES_ResourceID_t AppID) { CFE_ES_AppRecord_t *AppRecPtr; uint32 Idx; @@ -1796,7 +1796,7 @@ CFE_ES_AppRecord_t *CFE_ES_LocateAppRecordByID(uint32 AppID) return AppRecPtr; } -extern CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(uint32 LibID) +extern CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_ResourceID_t LibID) { CFE_ES_LibRecord_t *LibRecPtr; uint32 Idx; @@ -1819,7 +1819,7 @@ extern CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(uint32 LibID) * otherwise check/validate said pointer, as that would have to be done while * locked. */ -CFE_ES_TaskRecord_t *CFE_ES_LocateTaskRecordByID(uint32 TaskID) +CFE_ES_TaskRecord_t *CFE_ES_LocateTaskRecordByID(CFE_ES_ResourceID_t TaskID) { CFE_ES_TaskRecord_t *TaskRecPtr; uint32 Idx; @@ -1836,7 +1836,7 @@ CFE_ES_TaskRecord_t *CFE_ES_LocateTaskRecordByID(uint32 TaskID) return TaskRecPtr; } -CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(uint32 CounterID) +CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_ResourceID_t CounterID) { CFE_ES_GenCounterRecord_t *CounterRecPtr; uint32 Idx; @@ -1861,7 +1861,7 @@ CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(uint32 CounterID) CFE_ES_TaskRecord_t *CFE_ES_GetTaskRecordByContext(void) { CFE_ES_TaskRecord_t *TaskRecPtr; - uint32 TaskID; + CFE_ES_ResourceID_t TaskID; /* ** Use the OS task ID to get the ES task record @@ -1927,7 +1927,7 @@ CFE_ES_AppRecord_t *CFE_ES_GetAppRecordByContext(void) ** so there are not nested calls to the ES Shared Data mutex lock. ** */ -int32 CFE_ES_GetAppIDInternal(uint32 *AppIdPtr) +int32 CFE_ES_GetAppIDInternal(CFE_ES_ResourceID_t *AppIdPtr) { CFE_ES_AppRecord_t *AppRecPtr; int32 Result; @@ -1941,7 +1941,7 @@ int32 CFE_ES_GetAppIDInternal(uint32 *AppIdPtr) } else { - *AppIdPtr = 0; + *AppIdPtr = CFE_ES_RESOURCEID_UNDEFINED; Result = CFE_ES_ERR_APPID; } @@ -1968,7 +1968,7 @@ void CFE_ES_LockSharedData(const char *FunctionName, int32 LineNumber) { int32 Status; - uint32 AppId; + CFE_ES_ResourceID_t AppId; Status = OS_MutSemTake(CFE_ES_Global.SharedDataMutex); if (Status != OS_SUCCESS) @@ -2005,7 +2005,7 @@ void CFE_ES_LockSharedData(const char *FunctionName, int32 LineNumber) void CFE_ES_UnlockSharedData(const char *FunctionName, int32 LineNumber) { int32 Status; - uint32 AppId; + CFE_ES_ResourceID_t AppId; Status = OS_MutSemGive(CFE_ES_Global.SharedDataMutex); if (Status != OS_SUCCESS) diff --git a/fsw/cfe-core/src/es/cfe_es_apps.c b/fsw/cfe-core/src/es/cfe_es_apps.c index ae8dddcb1..700336ce3 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.c +++ b/fsw/cfe-core/src/es/cfe_es_apps.c @@ -271,7 +271,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) unsigned int Priority; unsigned int StackSize; unsigned int ExceptionAction; - uint32 ApplicationId; + CFE_ES_ResourceID_t ApplicationId; int32 CreateStatus = CFE_ES_ERR_APP_CREATE; /* @@ -355,7 +355,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) ** **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr, +int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, const char *FileName, const void *EntryPointData, const char *AppName, @@ -393,7 +393,7 @@ int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr, AppSlotFound = true; memset ( AppRecPtr, 0, sizeof(CFE_ES_AppRecord_t)); /* set state EARLY_INIT for OS_TaskCreate below (indicates record is in use) */ - CFE_ES_AppRecordSetUsed(AppRecPtr, i); + CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_ES_ResourceID_FromInteger(i + CFE_ES_APPID_BASE)); break; } ++AppRecPtr; @@ -558,7 +558,7 @@ int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr, ** **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr, +int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, const char *FileName, const void *EntryPointData, const char *LibName) @@ -568,7 +568,7 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr, size_t StringLength; int32 Status; uint32 LibIndex; - uint32 PendingLibId; + CFE_ES_ResourceID_t PendingLibId; osal_id_t ModuleId; bool IsModuleLoaded; @@ -588,7 +588,7 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr, IsModuleLoaded = false; FunctionPointer = NULL; ModuleId = OS_OBJECT_ID_UNDEFINED; - PendingLibId = 0xFFFFFFFF; + PendingLibId = CFE_ES_RESOURCEID_UNDEFINED; Status = CFE_ES_ERR_LOAD_LIB; /* error that will be returned if no slots found */ CFE_ES_LockSharedData(__func__,__LINE__); LibSlotPtr = CFE_ES_Global.LibTable; @@ -610,10 +610,10 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr, break; } } - else if (PendingLibId == 0xFFFFFFFF) + else if (!CFE_ES_ResourceID_IsDefined(PendingLibId)) { /* Remember list position as possible place for new entry. */ - PendingLibId = LibIndex; + PendingLibId = CFE_ES_ResourceID_FromInteger(LibIndex + CFE_ES_LIBID_BASE); Status = CFE_SUCCESS; } else @@ -631,7 +631,7 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr, /* reserve the slot while still under lock */ strcpy(LibSlotPtr->LibName, LibName); - CFE_ES_LibRecordSetUsed(LibSlotPtr, PendingLibId); + CFE_ES_LibRecordSetUsed(LibSlotPtr, CFE_ES_RESOURCEID_RESERVED); *LibraryIdPtr = PendingLibId; } @@ -755,6 +755,7 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr, { /* Increment the counter, which needs to be done under lock */ CFE_ES_LockSharedData(__func__,__LINE__); + CFE_ES_LibRecordSetUsed(LibSlotPtr, PendingLibId); CFE_ES_Global.RegisteredLibs++; CFE_ES_UnlockSharedData(__func__,__LINE__); } @@ -902,7 +903,7 @@ void CFE_ES_ProcessControlRequest(CFE_ES_AppRecord_t *AppRecPtr) int32 Status; CFE_ES_AppStartParams_t AppStartParams; - uint32 NewAppId; + CFE_ES_ResourceID_t NewAppId; /* ** First get a copy of the Apps Start Parameters @@ -1085,11 +1086,11 @@ int32 CFE_ES_CleanUpApp(CFE_ES_AppRecord_t *AppRecPtr) { uint32 i; int32 Status; - uint32 MainTaskId; - uint32 CurrTaskId; + CFE_ES_ResourceID_t MainTaskId; + CFE_ES_ResourceID_t CurrTaskId; int32 ReturnCode = CFE_SUCCESS; CFE_ES_TaskRecord_t *TaskRecPtr; - uint32 AppId; + CFE_ES_ResourceID_t AppId; /* * Retrieve the abstract AppID for calling cleanup @@ -1142,10 +1143,10 @@ int32 CFE_ES_CleanUpApp(CFE_ES_AppRecord_t *AppRecPtr) { /* delete only CHILD tasks - not the MainTaskId, which will be deleted later (below) */ if ( CFE_ES_TaskRecordIsUsed(TaskRecPtr) && - (TaskRecPtr->AppId == AppId)) + CFE_ES_ResourceID_Equal(TaskRecPtr->AppId, AppId)) { CurrTaskId = CFE_ES_TaskRecordGetID(TaskRecPtr); - if (CurrTaskId != MainTaskId) + if (!CFE_ES_ResourceID_Equal(CurrTaskId, MainTaskId)) { Status = CFE_ES_CleanupTaskResources(CurrTaskId); if ( Status != CFE_SUCCESS ) @@ -1320,7 +1321,7 @@ void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg) ** Purpose: Clean up the OS resources associated with an individual Task **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_CleanupTaskResources(uint32 TaskId) +int32 CFE_ES_CleanupTaskResources(CFE_ES_ResourceID_t TaskId) { CFE_ES_CleanupState_t CleanState; int32 Result; @@ -1408,7 +1409,7 @@ int32 CFE_ES_GetAppInfoInternal(CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_AppInfo_t OS_module_prop_t ModuleInfo; uint32 i; CFE_ES_TaskRecord_t *TaskRecPtr; - uint32 AppId; + CFE_ES_ResourceID_t AppId; CFE_ES_LockSharedData(__func__,__LINE__); @@ -1456,8 +1457,8 @@ int32 CFE_ES_GetAppInfoInternal(CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_AppInfo_t for (i=0; iAppId == AppId && - CFE_ES_TaskRecordGetID(TaskRecPtr) != AppInfoPtr->MainTaskId ) + CFE_ES_ResourceID_Equal(TaskRecPtr->AppId, AppId) && + !CFE_ES_ResourceID_Equal(CFE_ES_TaskRecordGetID(TaskRecPtr), AppInfoPtr->MainTaskId) ) { AppInfoPtr->NumOfChildTasks++; } diff --git a/fsw/cfe-core/src/es/cfe_es_apps.h b/fsw/cfe-core/src/es/cfe_es_apps.h index 0e6e68bd9..f4a0fbdb2 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.h +++ b/fsw/cfe-core/src/es/cfe_es_apps.h @@ -90,8 +90,8 @@ typedef struct */ typedef struct { - uint32 MainTaskId; /* The Application's Main Task ID */ - char MainTaskName[OS_MAX_API_NAME]; /* The Application's Main Task ID */ + CFE_ES_ResourceID_t MainTaskId; /* The Application's Main Task ID */ + char MainTaskName[OS_MAX_API_NAME]; /* The Application's Main Task ID */ } CFE_ES_MainTaskInfo_t; @@ -101,6 +101,7 @@ typedef struct */ typedef struct { + CFE_ES_ResourceID_t AppId; /* The actual AppID of this entry, or undefined */ CFE_ES_AppState_Enum_t AppState; /* Is the app running, or stopped, or waiting? */ uint32 Type; /* The type of App: CORE or EXTERNAL */ CFE_ES_AppStartParams_t StartParams; /* The start parameters for an App */ @@ -116,9 +117,8 @@ typedef struct */ typedef struct { - bool RecordUsed; /* Is the record used(1) or available(0) */ - uint32 AppId; /* The parent Application's App ID */ - uint32 TaskId; /* Task ID */ + CFE_ES_ResourceID_t TaskId; /* The actual TaskID of this entry, or undefined */ + CFE_ES_ResourceID_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 */ @@ -131,7 +131,7 @@ typedef struct */ typedef struct { - bool RecordUsed; /* Is the record used(1) or available(0) */ + CFE_ES_ResourceID_t LibId; /* The actual LibID of this entry, or undefined */ char LibName[OS_MAX_API_NAME]; /* Library Name */ } CFE_ES_LibRecord_t; @@ -167,7 +167,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens); ** Internal function to create/start a new cFE app ** based on the parameters passed in */ -int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr, +int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, const char *FileName, const void *EntryPointData, const char *AppName, @@ -177,7 +177,7 @@ int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr, /* ** Internal function to load a a new cFE shared Library */ -int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr, +int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, const char *FileName, const void *EntryPointData, const char *LibName); @@ -221,7 +221,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_AppRecord_t *AppRecPtr); /* ** Clean up all Task resources and detete the task */ -int32 CFE_ES_CleanupTaskResources(uint32 TaskId); +int32 CFE_ES_CleanupTaskResources(CFE_ES_ResourceID_t TaskId); /* ** Populate the cFE_ES_AppInfo structure with the data for an app diff --git a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c b/fsw/cfe-core/src/es/cfe_es_backgroundtask.c index 518abb450..e715134d7 100644 --- a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c +++ b/fsw/cfe-core/src/es/cfe_es_backgroundtask.c @@ -245,7 +245,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 = 0; + CFE_ES_Global.BackgroundTask.TaskID = CFE_ES_RESOURCEID_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 40de9cc13..0fbac201b 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds.c +++ b/fsw/cfe-core/src/es/cfe_es_cds.c @@ -536,7 +536,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, uint32 ThisAppId) +void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_ResourceID_t ThisAppId) { char AppName[OS_MAX_API_NAME]; @@ -728,7 +728,7 @@ int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices) int32 RegIndx; CFE_ES_CDS_RegRec_t *RegRecPtr = NULL; char OwnerName[OS_MAX_API_NAME]; - uint32 AppId; + CFE_ES_ResourceID_t AppId; uint32 i; char LogMessage[CFE_ES_MAX_SYSLOG_MSG_SIZE]; diff --git a/fsw/cfe-core/src/es/cfe_es_cds.h b/fsw/cfe-core/src/es/cfe_es_cds.h index 7055a3b56..501a0badb 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds.h +++ b/fsw/cfe-core/src/es/cfe_es_cds.h @@ -134,7 +134,7 @@ int32 CFE_ES_UpdateCDSRegistry(void); ** ** ******************************************************************************/ -void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, uint32 ThisAppId); +void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_ResourceID_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 98bf1c975..80ab4d12a 100644 --- a/fsw/cfe-core/src/es/cfe_es_erlog.c +++ b/fsw/cfe-core/src/es/cfe_es_erlog.c @@ -62,7 +62,7 @@ */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int32 CFE_ES_WriteToERLogWithContext( CFE_ES_LogEntryType_Enum_t EntryType, uint32 ResetType, uint32 ResetSubtype, - const char *Description, uint32 AppId, uint32 PspContextId) + const char *Description, CFE_ES_ResourceID_t AppId, uint32 PspContextId) { uint32 LogIdx; CFE_ES_ERLog_MetaData_t *EntryPtr; @@ -174,7 +174,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, 0xFFFFFFFF, CFE_ES_ERLOG_NO_CONTEXT); + Description, CFE_ES_RESOURCEID_UNDEFINED, CFE_ES_ERLOG_NO_CONTEXT); } /* End of CFE_ES_WriteToERLog() */ diff --git a/fsw/cfe-core/src/es/cfe_es_global.h b/fsw/cfe-core/src/es/cfe_es_global.h index 5ba27b515..86bc9aa8b 100644 --- a/fsw/cfe-core/src/es/cfe_es_global.h +++ b/fsw/cfe-core/src/es/cfe_es_global.h @@ -54,6 +54,26 @@ ** 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) + +#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)) + /* ** Typedefs */ @@ -64,7 +84,7 @@ */ typedef struct { - bool RecordUsed; /* Is the record used(1) or available(0) ? */ + CFE_ES_ResourceID_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; @@ -74,9 +94,9 @@ typedef struct */ typedef struct { - uint32 TaskID; /**< OSAL 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_ResourceID_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; @@ -164,7 +184,7 @@ extern CFE_ES_ResetData_t *CFE_ES_ResetDataPtr; * @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(uint32 AppID); +extern CFE_ES_AppRecord_t* CFE_ES_LocateAppRecordByID(CFE_ES_ResourceID_t AppID); /** * @brief Locate the Library table entry correlating with a given Lib ID. @@ -175,7 +195,7 @@ extern CFE_ES_AppRecord_t* CFE_ES_LocateAppRecordByID(uint32 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(uint32 LibID); +extern CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_ResourceID_t LibID); /** * @brief Locate the task table entry correlating with a given task ID. @@ -186,7 +206,7 @@ extern CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(uint32 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(uint32 TaskID); +extern CFE_ES_TaskRecord_t* CFE_ES_LocateTaskRecordByID(CFE_ES_ResourceID_t TaskID); /** * @brief Locate the Counter table entry correlating with a given Counter ID. @@ -197,7 +217,7 @@ extern CFE_ES_TaskRecord_t* CFE_ES_LocateTaskRecordByID(uint32 TaskID); * @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(uint32 CounterID); +extern CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_ResourceID_t CounterID); /** * @brief Check if an app record is in use or free/empty @@ -212,7 +232,7 @@ extern CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(uint32 CounterI */ static inline bool CFE_ES_AppRecordIsUsed(const CFE_ES_AppRecord_t *AppRecPtr) { - return (AppRecPtr->AppState != CFE_ES_AppState_UNDEFINED); + return CFE_ES_ResourceID_IsDefined(AppRecPtr->AppId); } /** @@ -223,13 +243,9 @@ 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 uint32 CFE_ES_AppRecordGetID(const CFE_ES_AppRecord_t *AppRecPtr) +static inline CFE_ES_ResourceID_t CFE_ES_AppRecordGetID(const CFE_ES_AppRecord_t *AppRecPtr) { - /* - * The initial implementation does not store the ID in the entry; - * the ID is simply the zero-based index into the table. - */ - return (AppRecPtr - CFE_ES_Global.AppTable); + return AppRecPtr->AppId; } /** @@ -244,9 +260,9 @@ static inline uint32 CFE_ES_AppRecordGetID(const CFE_ES_AppRecord_t *AppRecPtr) * @param[in] AppRecPtr pointer to app table entry * @param[in] AppID the app ID of this entry */ -static inline void CFE_ES_AppRecordSetUsed(CFE_ES_AppRecord_t *AppRecPtr, uint32 AppID) +static inline void CFE_ES_AppRecordSetUsed(CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_ResourceID_t AppID) { - AppRecPtr->AppState = CFE_ES_AppState_EARLY_INIT; + AppRecPtr->AppId = AppID; } /** @@ -262,7 +278,7 @@ static inline void CFE_ES_AppRecordSetUsed(CFE_ES_AppRecord_t *AppRecPtr, uint32 */ static inline void CFE_ES_AppRecordSetFree(CFE_ES_AppRecord_t *AppRecPtr) { - AppRecPtr->AppState = CFE_ES_AppState_UNDEFINED; + AppRecPtr->AppId = CFE_ES_RESOURCEID_UNDEFINED; } /** @@ -278,10 +294,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, uint32 AppID) +static inline bool CFE_ES_AppRecordIsMatch(const CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_ResourceID_t AppID) { - return (AppRecPtr != NULL && CFE_ES_AppRecordIsUsed(AppRecPtr) && - CFE_ES_AppRecordGetID(AppRecPtr) == AppID); + return (AppRecPtr != NULL && CFE_ES_ResourceID_Equal(AppRecPtr->AppId, AppID)); } /** @@ -297,7 +312,7 @@ static inline bool CFE_ES_AppRecordIsMatch(const CFE_ES_AppRecord_t *AppRecPtr, */ static inline bool CFE_ES_LibRecordIsUsed(const CFE_ES_LibRecord_t *LibRecPtr) { - return (LibRecPtr->RecordUsed); + return CFE_ES_ResourceID_IsDefined(LibRecPtr->LibId); } /** @@ -308,13 +323,13 @@ 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 uint32 CFE_ES_LibRecordGetID(const CFE_ES_LibRecord_t *LibRecPtr) +static inline CFE_ES_ResourceID_t CFE_ES_LibRecordGetID(const CFE_ES_LibRecord_t *LibRecPtr) { /* * The initial implementation does not store the ID in the entry; * the ID is simply the zero-based index into the table. */ - return (LibRecPtr - CFE_ES_Global.LibTable); + return (LibRecPtr->LibId); } /** @@ -326,9 +341,9 @@ static inline uint32 CFE_ES_LibRecordGetID(const CFE_ES_LibRecord_t *LibRecPtr) * @param[in] LibRecPtr pointer to Lib table entry * @param[in] LibID the Lib ID of this entry */ -static inline void CFE_ES_LibRecordSetUsed(CFE_ES_LibRecord_t *LibRecPtr, uint32 LibID) +static inline void CFE_ES_LibRecordSetUsed(CFE_ES_LibRecord_t *LibRecPtr, CFE_ES_ResourceID_t LibID) { - LibRecPtr->RecordUsed = true; + LibRecPtr->LibId = LibID; } /** @@ -341,7 +356,7 @@ static inline void CFE_ES_LibRecordSetUsed(CFE_ES_LibRecord_t *LibRecPtr, uint32 */ static inline void CFE_ES_LibRecordSetFree(CFE_ES_LibRecord_t *LibRecPtr) { - LibRecPtr->RecordUsed = false; + LibRecPtr->LibId = CFE_ES_RESOURCEID_UNDEFINED; } /** @@ -357,10 +372,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, uint32 LibID) +static inline bool CFE_ES_LibRecordIsMatch(const CFE_ES_LibRecord_t *LibRecPtr, CFE_ES_ResourceID_t LibID) { - return (LibRecPtr != NULL && CFE_ES_LibRecordIsUsed(LibRecPtr) && - CFE_ES_LibRecordGetID(LibRecPtr) == LibID); + return (LibRecPtr != NULL && CFE_ES_ResourceID_Equal(LibRecPtr->LibId, LibID)); } /** @@ -374,7 +388,7 @@ static inline bool CFE_ES_LibRecordIsMatch(const CFE_ES_LibRecord_t *LibRecPtr, * @param[in] TaskRecPtr pointer to Task table entry * @returns TaskID of entry */ -static inline uint32 CFE_ES_TaskRecordGetID(const CFE_ES_TaskRecord_t *TaskRecPtr) +static inline CFE_ES_ResourceID_t CFE_ES_TaskRecordGetID(const CFE_ES_TaskRecord_t *TaskRecPtr) { return (TaskRecPtr->TaskId); } @@ -392,7 +406,7 @@ static inline uint32 CFE_ES_TaskRecordGetID(const CFE_ES_TaskRecord_t *TaskRecPt */ static inline bool CFE_ES_TaskRecordIsUsed(const CFE_ES_TaskRecord_t *TaskRecPtr) { - return (TaskRecPtr->RecordUsed); + return CFE_ES_ResourceID_IsDefined(TaskRecPtr->TaskId); } /** @@ -407,10 +421,9 @@ static inline bool CFE_ES_TaskRecordIsUsed(const CFE_ES_TaskRecord_t *TaskRecPtr * @param[in] TaskRecPtr pointer to Task table entry * @param[in] TaskID the Task ID of this entry */ -static inline void CFE_ES_TaskRecordSetUsed(CFE_ES_TaskRecord_t *TaskRecPtr, uint32 TaskID) +static inline void CFE_ES_TaskRecordSetUsed(CFE_ES_TaskRecord_t *TaskRecPtr, CFE_ES_ResourceID_t TaskID) { TaskRecPtr->TaskId = TaskID; - TaskRecPtr->RecordUsed = true; } /** @@ -426,8 +439,7 @@ static inline void CFE_ES_TaskRecordSetUsed(CFE_ES_TaskRecord_t *TaskRecPtr, uin */ static inline void CFE_ES_TaskRecordSetFree(CFE_ES_TaskRecord_t *TaskRecPtr) { - TaskRecPtr->TaskId = 0; - TaskRecPtr->RecordUsed = false; + TaskRecPtr->TaskId = CFE_ES_RESOURCEID_UNDEFINED; } /** @@ -443,10 +455,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, uint32 TaskID) +static inline bool CFE_ES_TaskRecordIsMatch(const CFE_ES_TaskRecord_t *TaskRecPtr, CFE_ES_ResourceID_t TaskID) { - return (TaskRecPtr != NULL && CFE_ES_TaskRecordIsUsed(TaskRecPtr) && - CFE_ES_TaskRecordGetID(TaskRecPtr) == TaskID); + return (TaskRecPtr != NULL && CFE_ES_ResourceID_Equal(TaskRecPtr->TaskId, TaskID)); } /** @@ -462,7 +473,7 @@ static inline bool CFE_ES_TaskRecordIsMatch(const CFE_ES_TaskRecord_t *TaskRecPt */ static inline bool CFE_ES_CounterRecordIsUsed(const CFE_ES_GenCounterRecord_t *CounterRecPtr) { - return (CounterRecPtr->RecordUsed); + return CFE_ES_ResourceID_IsDefined(CounterRecPtr->CounterId); } /** @@ -473,13 +484,9 @@ 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 uint32 CFE_ES_CounterRecordGetID(const CFE_ES_GenCounterRecord_t *CounterRecPtr) +static inline CFE_ES_ResourceID_t CFE_ES_CounterRecordGetID(const CFE_ES_GenCounterRecord_t *CounterRecPtr) { - /* - * The initial implementation does not store the ID in the entry; - * the ID is simply the zero-based index into the table. - */ - return (CounterRecPtr - CFE_ES_Global.CounterTable); + return CounterRecPtr->CounterId; } /** @@ -494,9 +501,9 @@ static inline uint32 CFE_ES_CounterRecordGetID(const CFE_ES_GenCounterRecord_t * * @param[in] CounterRecPtr pointer to Counter table entry * @param[in] CounterID the Counter ID of this entry */ -static inline void CFE_ES_CounterRecordSetUsed(CFE_ES_GenCounterRecord_t *CounterRecPtr, uint32 CounterID) +static inline void CFE_ES_CounterRecordSetUsed(CFE_ES_GenCounterRecord_t *CounterRecPtr, CFE_ES_ResourceID_t CounterID) { - CounterRecPtr->RecordUsed = true; + CounterRecPtr->CounterId = CounterID; } /** @@ -512,7 +519,7 @@ static inline void CFE_ES_CounterRecordSetUsed(CFE_ES_GenCounterRecord_t *Counte */ static inline void CFE_ES_CounterRecordSetFree(CFE_ES_GenCounterRecord_t *CounterRecPtr) { - CounterRecPtr->RecordUsed = false; + CounterRecPtr->CounterId = CFE_ES_RESOURCEID_UNDEFINED; } /** @@ -528,10 +535,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, uint32 CounterID) +static inline bool CFE_ES_CounterRecordIsMatch(const CFE_ES_GenCounterRecord_t *CounterRecPtr, CFE_ES_ResourceID_t CounterID) { - return (CounterRecPtr != NULL && CFE_ES_CounterRecordIsUsed(CounterRecPtr) && - CFE_ES_CounterRecordGetID(CounterRecPtr) == CounterID); + return (CounterRecPtr != NULL && CFE_ES_ResourceID_Equal(CounterRecPtr->CounterId, CounterID)); } /** @@ -576,7 +582,7 @@ extern CFE_ES_TaskRecord_t* CFE_ES_GetTaskRecordByContext(void); * @param[in] id The ES task ID * @returns The OSAL task ID */ -osal_id_t CFE_ES_ResourceID_ToOSAL(uint32 id); +osal_id_t CFE_ES_ResourceID_ToOSAL(CFE_ES_ResourceID_t id); /** * @brief Convert an ES Task ID to an OSAL task ID @@ -596,13 +602,22 @@ osal_id_t CFE_ES_ResourceID_ToOSAL(uint32 id); * @param[in] id The OSAL task ID * @returns The ES task ID */ -uint32 CFE_ES_ResourceID_FromOSAL(osal_id_t 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_Internal(uint32 Serial, uint32 TableSize, uint32 *Idx); /* ** Functions used to lock/unlock shared data */ -extern int32 CFE_ES_GetAppIDInternal(uint32 *AppIdPtr); +extern int32 CFE_ES_GetAppIDInternal(CFE_ES_ResourceID_t *AppIdPtr); extern void CFE_ES_LockSharedData(const char *FunctionName, int32 LineNumber); extern void CFE_ES_UnlockSharedData(const char *FunctionName, int32 LineNumber); diff --git a/fsw/cfe-core/src/es/cfe_es_log.h b/fsw/cfe-core/src/es/cfe_es_log.h index b417f8be7..147496ae3 100644 --- a/fsw/cfe-core/src/es/cfe_es_log.h +++ b/fsw/cfe-core/src/es/cfe_es_log.h @@ -365,6 +365,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, uint32 AppId, uint32 PspContextId); + const char *Description, CFE_ES_ResourceID_t AppId, uint32 PspContextId); #endif /* _cfe_es_log_ */ diff --git a/fsw/cfe-core/src/es/cfe_es_start.c b/fsw/cfe-core/src/es/cfe_es_start.c index 5335a9d91..d1025e163 100644 --- a/fsw/cfe-core/src/es/cfe_es_start.c +++ b/fsw/cfe-core/src/es/cfe_es_start.c @@ -820,7 +820,7 @@ void CFE_ES_CreateObjects(void) ** Core apps still have the notion of an init/running state ** Set the state here to mark the record as used. */ - CFE_ES_AppRecordSetUsed(AppRecPtr, j); + CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_ES_ResourceID_FromInteger(j + CFE_ES_APPID_BASE)); AppRecPtr->Type = CFE_ES_AppType_CORE; diff --git a/fsw/cfe-core/src/es/cfe_es_task.c b/fsw/cfe-core/src/es/cfe_es_task.c index 4f8122f58..cb06a023d 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.c +++ b/fsw/cfe-core/src/es/cfe_es_task.c @@ -855,7 +855,7 @@ int32 CFE_ES_RestartCmd(const CFE_ES_Restart_t *data) int32 CFE_ES_StartAppCmd(const CFE_ES_StartApp_t *data) { const CFE_ES_StartAppCmd_Payload_t *cmd = &data->Payload; - uint32 AppID = 0; + CFE_ES_ResourceID_t AppID; int32 Result; int32 FilenameLen; int32 AppEntryLen; @@ -964,7 +964,7 @@ int32 CFE_ES_StopAppCmd(const CFE_ES_StopApp_t *data) { const CFE_ES_AppNameCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; - uint32 AppID; + CFE_ES_ResourceID_t AppID; int32 Result; CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, OS_MAX_API_NAME, sizeof(cmd->Application)); @@ -1017,7 +1017,7 @@ int32 CFE_ES_RestartAppCmd(const CFE_ES_RestartApp_t *data) { const CFE_ES_AppNameCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; - uint32 AppID; + CFE_ES_ResourceID_t AppID; int32 Result; CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, OS_MAX_API_NAME, sizeof(cmd->Application)); @@ -1067,8 +1067,7 @@ int32 CFE_ES_ReloadAppCmd(const CFE_ES_ReloadApp_t *data) const CFE_ES_AppReloadCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; char LocalFileName[OS_MAX_PATH_LEN]; - - uint32 AppID; + CFE_ES_ResourceID_t AppID; int32 Result; CFE_SB_MessageStringGet(LocalFileName, (char *)cmd->AppFileName, NULL, sizeof(LocalFileName), sizeof(cmd->AppFileName)); @@ -1119,7 +1118,7 @@ int32 CFE_ES_QueryOneCmd(const CFE_ES_QueryOne_t *data) { const CFE_ES_AppNameCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; - uint32 AppID; + CFE_ES_ResourceID_t AppID; int32 Result; CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, OS_MAX_API_NAME, sizeof(cmd->Application)); diff --git a/fsw/cfe-core/src/es/cfe_esmempool.c b/fsw/cfe-core/src/es/cfe_esmempool.c index fe32f1835..de46d29aa 100644 --- a/fsw/cfe-core/src/es/cfe_esmempool.c +++ b/fsw/cfe-core/src/es/cfe_esmempool.c @@ -311,7 +311,7 @@ int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, Pool_t * PoolPtr = (Pool_t *)Handle; uint32 BlockSize; MemPoolAddr_t BlockAddr; - uint32 AppId= 0xFFFFFFFF; + CFE_ES_ResourceID_t AppId; if (PoolPtr != NULL) { @@ -629,7 +629,7 @@ uint32 CFE_ES_GetBlockSize(Pool_t *PoolPtr, uint32 Size) int32 CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t Handle) { - uint32 AppId = 0xFFFFFFFF; + CFE_ES_ResourceID_t AppId; Pool_t *PoolPtr; uint32 i; diff --git a/fsw/cfe-core/src/evs/cfe_evs.c b/fsw/cfe-core/src/evs/cfe_evs.c index aac6b7db8..1d5f8a19a 100644 --- a/fsw/cfe-core/src/evs/cfe_evs.c +++ b/fsw/cfe-core/src/evs/cfe_evs.c @@ -55,7 +55,7 @@ int32 CFE_EVS_Register (void *Filters, uint16 NumEventFilters, uint16 FilterSche uint16 FilterLimit; uint16 i; int32 Status; - uint32 AppID = CFE_EVS_UNDEF_APPID; + CFE_ES_ResourceID_t AppID; CFE_EVS_BinFilter_t *AppFilters; EVS_AppData_t *AppDataPtr; @@ -126,7 +126,7 @@ int32 CFE_EVS_Register (void *Filters, uint16 NumEventFilters, uint16 FilterSche int32 CFE_EVS_Unregister(void) { int32 Status; - uint32 AppID = CFE_EVS_UNDEF_APPID; + CFE_ES_ResourceID_t AppID; EVS_AppData_t *AppDataPtr; /* Query and verify the caller's AppID */ @@ -147,7 +147,7 @@ int32 CFE_EVS_Unregister(void) int32 CFE_EVS_SendEvent (uint16 EventID, uint16 EventType, const char *Spec, ... ) { int32 Status; - uint32 AppID = CFE_EVS_UNDEF_APPID; + CFE_ES_ResourceID_t AppID; CFE_TIME_SysTime_t Time; va_list Ptr; EVS_AppData_t *AppDataPtr; @@ -181,7 +181,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, uint32 AppID, const char *Spec, ... ) +int32 CFE_EVS_SendEventWithAppID (uint16 EventID, uint16 EventType, CFE_ES_ResourceID_t AppID, const char *Spec, ... ) { int32 Status = CFE_SUCCESS; CFE_TIME_SysTime_t Time; @@ -219,7 +219,7 @@ int32 CFE_EVS_SendEventWithAppID (uint16 EventID, uint16 EventType, uint32 AppID int32 CFE_EVS_SendTimedEvent (CFE_TIME_SysTime_t Time, uint16 EventID, uint16 EventType, const char *Spec, ... ) { int32 Status; - uint32 AppID = CFE_EVS_UNDEF_APPID; + CFE_ES_ResourceID_t AppID; va_list Ptr; EVS_AppData_t *AppDataPtr; @@ -252,7 +252,7 @@ int32 CFE_EVS_ResetFilter (int16 EventID) { int32 Status; EVS_BinFilter_t *FilterPtr = NULL; - uint32 AppID = CFE_EVS_UNDEF_APPID; + CFE_ES_ResourceID_t AppID; EVS_AppData_t *AppDataPtr; /* Query and verify the caller's AppID */ @@ -289,7 +289,7 @@ int32 CFE_EVS_ResetFilter (int16 EventID) int32 CFE_EVS_ResetAllFilters ( void ) { int32 Status; - uint32 AppID = CFE_EVS_UNDEF_APPID; + CFE_ES_ResourceID_t AppID; uint32 i; EVS_AppData_t *AppDataPtr; diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.c b/fsw/cfe-core/src/evs/cfe_evs_task.c index 928a083c0..8646e847d 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.c +++ b/fsw/cfe-core/src/evs/cfe_evs_task.c @@ -85,8 +85,6 @@ int32 CFE_EVS_EarlyInit ( void ) memset(&CFE_EVS_GlobalData, 0, sizeof(CFE_EVS_GlobalData_t)); - CFE_EVS_GlobalData.EVS_AppID = CFE_EVS_UNDEF_APPID; - /* Initialize housekeeping packet */ CFE_SB_InitMsg(&CFE_EVS_GlobalData.EVS_TlmPkt, CFE_SB_ValueToMsgId(CFE_EVS_HK_TLM_MID), sizeof(CFE_EVS_GlobalData.EVS_TlmPkt), false); @@ -181,7 +179,7 @@ int32 CFE_EVS_EarlyInit ( void ) ** ** Assumptions and Notes: */ -int32 CFE_EVS_CleanUpApp(uint32 AppID) +int32 CFE_EVS_CleanUpApp(CFE_ES_ResourceID_t AppID) { int32 Status = CFE_SUCCESS; EVS_AppData_t *AppDataPtr; @@ -282,7 +280,7 @@ void CFE_EVS_TaskMain(void) int32 CFE_EVS_TaskInit ( void ) { int32 Status; - uint32 AppID; + CFE_ES_ResourceID_t AppID; /* Register EVS application */ Status = CFE_ES_RegisterApp(); @@ -722,7 +720,7 @@ int32 CFE_EVS_ReportHousekeepingCmd (const CFE_SB_CmdHdr_t *data) /* Clear unused portion of event state data in telemetry packet */ for (i = j; i < CFE_MISSION_ES_MAX_APPLICATIONS; i++) { - AppTlmDataPtr->AppID = 0; + AppTlmDataPtr->AppID = CFE_ES_RESOURCEID_UNDEFINED; AppTlmDataPtr->AppEnableStatus = false; AppTlmDataPtr->AppMessageSentCounter = 0; } diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.h b/fsw/cfe-core/src/evs/cfe_evs_task.h index 22d8eff94..95827b5fc 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.h +++ b/fsw/cfe-core/src/evs/cfe_evs_task.h @@ -63,7 +63,6 @@ #define CFE_EVS_MAX_EVENT_SEND_COUNT 65535 #define CFE_EVS_MAX_FILTER_COUNT 65535 #define CFE_EVS_PIPE_NAME "EVS_CMD_PIPE" -#define CFE_EVS_UNDEF_APPID 0xFFFFFFFF #define CFE_EVS_MAX_PORT_MSG_LENGTH (CFE_MISSION_EVS_MAX_MESSAGE_LENGTH+OS_MAX_API_NAME+30) /* Since CFE_EVS_MAX_PORT_MSG_LENGTH is the size of the buffer that is sent to @@ -89,12 +88,12 @@ typedef struct typedef struct { + CFE_ES_ResourceID_t AppID; EVS_BinFilter_t BinFilters[CFE_PLATFORM_EVS_MAX_EVENT_FILTERS]; /* Array of binary filters */ uint8 ActiveFlag; /* Application event service active flag */ uint8 EventTypesActiveFlag; /* Application event types active flag */ uint16 EventCount; /* Application event counter */ - uint16 RegisterFlag; /* Application has registered flag */ } EVS_AppData_t; @@ -123,7 +122,7 @@ typedef struct CFE_EVS_HousekeepingTlm_t EVS_TlmPkt; CFE_SB_PipeId_t EVS_CommandPipe; osal_id_t EVS_SharedDataMutexID; - uint32 EVS_AppID; + CFE_ES_ResourceID_t EVS_AppID; } CFE_EVS_GlobalData_t; diff --git a/fsw/cfe-core/src/evs/cfe_evs_utils.c b/fsw/cfe-core/src/evs/cfe_evs_utils.c index 67a2e19fa..d13cedfbb 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 (uint32 AppID) +EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_ResourceID_t AppID) { uint32 AppIndex; EVS_AppData_t *AppDataPtr; @@ -83,9 +83,9 @@ EVS_AppData_t *EVS_GetAppDataByID (uint32 AppID) } /* End EVS_GetAppDataByID */ -int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, uint32 *AppIDOut) +int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_ResourceID_t *AppIDOut) { - uint32 AppID; + CFE_ES_ResourceID_t AppID; EVS_AppData_t *AppDataPtr; int32 Status; @@ -134,7 +134,7 @@ int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, uint32 *AppIDOut) int32 EVS_GetApplicationInfo (EVS_AppData_t **AppDataOut, const char *pAppName) { int32 Status; - uint32 AppID; + CFE_ES_ResourceID_t AppID; EVS_AppData_t *AppDataPtr; Status = CFE_ES_GetAppIDByName(&AppID, pAppName); @@ -180,7 +180,7 @@ int32 EVS_GetApplicationInfo (EVS_AppData_t **AppDataOut, const char *pAppName) ** Assumptions and Notes: ** */ -int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, uint32 AppID) +int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_t CallerID) { char AppName[OS_MAX_API_NAME]; @@ -194,7 +194,7 @@ int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, uint32 AppID) AppDataPtr->EventCount++; /* Get the name of the "not registered" app */ - CFE_ES_GetAppName(AppName, AppID, OS_MAX_API_NAME); + CFE_ES_GetAppName(AppName, CallerID, OS_MAX_API_NAME); /* Send the "not registered" event */ EVS_SendEvent(CFE_EVS_ERR_UNREGISTERED_EVS_APP, CFE_EVS_EventType_ERROR, diff --git a/fsw/cfe-core/src/evs/cfe_evs_utils.h b/fsw/cfe-core/src/evs/cfe_evs_utils.h index 8ebd6807d..b995abc4f 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 (uint32 AppID); +EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_ResourceID_t AppID); /** * @brief Obtain the context information for the currently running app @@ -74,7 +74,7 @@ EVS_AppData_t *EVS_GetAppDataByID (uint32 AppID); * @param[out] AppIDOut Location to store AppID * @returns CFE_SUCCESS if successful, or relevant error code. */ -int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, uint32 *AppIDOut); +int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_ResourceID_t *AppIDOut); /** @@ -90,7 +90,7 @@ int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, uint32 *AppIDOut); */ static inline bool EVS_AppDataIsUsed(EVS_AppData_t *AppDataPtr) { - return (AppDataPtr->RegisterFlag); + return CFE_ES_ResourceID_IsDefined(AppDataPtr->AppID); } /** @@ -101,13 +101,13 @@ static inline bool EVS_AppDataIsUsed(EVS_AppData_t *AppDataPtr) * @param[in] AppDataPtr pointer to app table entry * @returns AppID of entry */ -static inline uint32 EVS_AppDataGetID(EVS_AppData_t *AppDataPtr) +static inline CFE_ES_ResourceID_t EVS_AppDataGetID(EVS_AppData_t *AppDataPtr) { /* * The initial implementation does not store the ID in the entry; * the ID is simply the zero-based index into the table. */ - return (AppDataPtr - CFE_EVS_GlobalData.AppData); + return (AppDataPtr->AppID); } /** @@ -122,9 +122,9 @@ static inline uint32 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, uint32 AppID) +static inline void EVS_AppDataSetUsed(EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_t AppID) { - AppDataPtr->RegisterFlag = true; + AppDataPtr->AppID = AppID; } /** @@ -137,7 +137,7 @@ static inline void EVS_AppDataSetUsed(EVS_AppData_t *AppDataPtr, uint32 AppID) */ static inline void EVS_AppDataSetFree(EVS_AppData_t *AppDataPtr) { - AppDataPtr->RegisterFlag = false; + AppDataPtr->AppID = CFE_ES_RESOURCEID_UNDEFINED; } /** @@ -150,17 +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, uint32 AppID) +static inline bool EVS_AppDataIsMatch(EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_t AppID) { - return (AppDataPtr != NULL && EVS_AppDataIsUsed(AppDataPtr) && - EVS_AppDataGetID(AppDataPtr) == AppID); + return (AppDataPtr != NULL && CFE_ES_ResourceID_Equal(AppDataPtr->AppID, AppID)); } int32 EVS_GetApplicationInfo(EVS_AppData_t **AppDataOut, const char *pAppName); -int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, uint32 AppID); +int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_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 8e7c6cfca..83d38f9f4 100644 --- a/fsw/cfe-core/src/fs/cfe_fs_api.c +++ b/fsw/cfe-core/src/fs/cfe_fs_api.c @@ -94,6 +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; /* ** Ensure that we are at the start of the file... @@ -107,7 +108,8 @@ 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((uint32 *)&(Hdr->ApplicationID)); + CFE_ES_GetAppID(&AppID); + Hdr->ApplicationID = CFE_ES_ResourceID_ToInteger(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 0ec0415f3..445f22de3 100644 --- a/fsw/cfe-core/src/fs/cfe_fs_priv.c +++ b/fsw/cfe-core/src/fs/cfe_fs_priv.c @@ -92,7 +92,7 @@ int32 CFE_FS_EarlyInit (void) void CFE_FS_LockSharedData(const char *FunctionName) { int32 Status; - uint32 AppId = 0; + CFE_ES_ResourceID_t AppId; Status = OS_MutSemTake(CFE_FS.SharedDataMutexId); if (Status != OS_SUCCESS) @@ -124,7 +124,7 @@ void CFE_FS_LockSharedData(const char *FunctionName) void CFE_FS_UnlockSharedData(const char *FunctionName) { int32 Status; - uint32 AppId = 0; + CFE_ES_ResourceID_t AppId; Status = OS_MutSemGive(CFE_FS.SharedDataMutexId); if (Status != OS_SUCCESS) diff --git a/fsw/cfe-core/src/inc/cfe_error.h b/fsw/cfe-core/src/inc/cfe_error.h index 2080191e7..aa5b06d89 100644 --- a/fsw/cfe-core/src/inc/cfe_error.h +++ b/fsw/cfe-core/src/inc/cfe_error.h @@ -449,7 +449,7 @@ /** * @brief Task ID Error * - * Occurs when the Task ID passed into #CFE_ES_GetTaskInfo is invalid. + * Occurs when the Task ID passed into a task-related API is invalid. * */ #define CFE_ES_ERR_TASKID ((int32)0xc4000016) @@ -633,6 +633,27 @@ */ #define CFE_ES_ERR_SYS_LOG_TRUNCATED ((int32)0x44000029) + +/** + * @brief Resource ID is not valid + * + * This error indicates that the passed in resource identifier + * (App ID, Lib ID, Counter ID, etc) did not validate. + * + */ +#define CFE_ES_RESOURCE_ID_INVALID ((int32)0xc400002A) + +/** + * @brief Resource ID is not available + * + * This error indicates that the maximum resource identifiers + * (App ID, Lib ID, Counter ID, etc) has already been reached + * and a new ID cannot be allocated. + * + */ +#define CFE_ES_NO_RESOURCE_IDS_AVAILABLE ((int32)0xc400002B) + + /** * @brief Not Implemented * diff --git a/fsw/cfe-core/src/inc/cfe_es.h b/fsw/cfe-core/src/inc/cfe_es.h index 72fea6d98..368cd3c9e 100644 --- a/fsw/cfe-core/src/inc/cfe_es.h +++ b/fsw/cfe-core/src/inc/cfe_es.h @@ -107,6 +107,44 @@ */ typedef cpuaddr CFE_ES_MemHandle_t; +/** + * @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. + * + * Simple operations are provided as inline functions, which + * should alleviate the need to do direct manipulation of the value: + * + * - 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) + */ +typedef uint32 CFE_ES_ResourceID_t; + +/** + * @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 initialzed + * 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. * @@ -129,9 +167,9 @@ typedef cpuaddr CFE_ES_MemHandle_t; * @param[in] id Resource ID to convert * @returns Integer value corresponding to ID */ -static inline unsigned long CFE_ES_ResourceID_ToInteger(uint32 id) +static inline unsigned long CFE_ES_ResourceID_ToInteger(CFE_ES_ResourceID_t id) { - return (id); + return ((unsigned long)id); } /** @@ -148,11 +186,40 @@ static inline unsigned long CFE_ES_ResourceID_ToInteger(uint32 id) * @param[in] Value Integer value to convert * @returns ID value corresponding to integer */ -static inline uint32 CFE_ES_ResourceID_FromInteger(unsigned long Value) +static inline CFE_ES_ResourceID_t CFE_ES_ResourceID_FromInteger(unsigned long Value) { - return (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); +} /** * @brief Obtain an index value correlating to an ES Application ID @@ -176,7 +243,7 @@ static inline uint32 CFE_ES_ResourceID_FromInteger(unsigned long Value) * @return Execution status, see @ref CFEReturnCodes * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS */ -int32 CFE_ES_AppID_ToIndex(uint32 AppID, uint32 *Idx); +int32 CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx); /** * @brief Obtain an index value correlating to an ES Library ID @@ -200,7 +267,7 @@ int32 CFE_ES_AppID_ToIndex(uint32 AppID, uint32 *Idx); * @return Execution status, see @ref CFEReturnCodes * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS */ -int32 CFE_ES_LibID_ToIndex(uint32 LibID, uint32 *Idx); +int32 CFE_ES_LibID_ToIndex(CFE_ES_ResourceID_t LibID, uint32 *Idx); /** * @brief Obtain an index value correlating to an ES Task ID @@ -224,7 +291,7 @@ int32 CFE_ES_LibID_ToIndex(uint32 LibID, uint32 *Idx); * @return Execution status, see @ref CFEReturnCodes * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS */ -int32 CFE_ES_TaskID_ToIndex(uint32 TaskID, uint32 *Idx); +int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx); /** * \brief Application Information @@ -234,7 +301,7 @@ int32 CFE_ES_TaskID_ToIndex(uint32 TaskID, uint32 *Idx); */ typedef struct CFE_ES_AppInfo { - uint32 AppId; /**< \cfetlmmnemonic \ES_APP_ID + CFE_ES_ResourceID_t AppId; /**< \cfetlmmnemonic \ES_APP_ID \brief Application ID for this Application */ uint32 Type; /**< \cfetlmmnemonic \ES_APPTYPE \brief The type of App: CORE or EXTERNAL */ @@ -271,7 +338,7 @@ typedef struct CFE_ES_AppInfo (Restart Application OR Restart Processor) */ uint16 Priority; /**< \cfetlmmnemonic \ES_PRIORITY \brief The Priority of the Application */ - uint32 MainTaskId; /**< \cfetlmmnemonic \ES_MAINTASKID + CFE_ES_ResourceID_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 */ @@ -287,11 +354,11 @@ typedef struct CFE_ES_AppInfo */ typedef struct CFE_ES_TaskInfo { - uint32 TaskId; /**< \brief Task Id */ + CFE_ES_ResourceID_t TaskId; /**< \brief Task Id */ uint32 ExecutionCounter; /**< \brief Task Execution Counter */ - uint8 TaskName[OS_MAX_API_NAME]; /**< \brief Task Name */ - uint32 AppId; /**< \brief Parent Application ID */ - uint8 AppName[OS_MAX_API_NAME]; /**< \brief Parent Application Name */ + char TaskName[OS_MAX_API_NAME]; /**< \brief Task Name */ + CFE_ES_ResourceID_t AppId; /**< \brief Parent Application ID */ + char AppName[OS_MAX_API_NAME]; /**< \brief Parent Application Name */ } CFE_ES_TaskInfo_t; @@ -345,7 +412,7 @@ typedef struct CFE_ES_CDSRegDumpRec ** 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)(uint32 LibId); /**< \brief Required Prototype of Library Initialization Functions */ +typedef int32 (*CFE_ES_LibraryEntryFuncPtr_t)(CFE_ES_ResourceID_t LibId); /**< \brief Required Prototype of Library Initialization Functions */ /** * \brief Pool Alignement @@ -455,7 +522,7 @@ int32 CFE_ES_ResetCFE(uint32 ResetType); ** \sa #CFE_ES_ReloadApp, #CFE_ES_DeleteApp ** ******************************************************************************/ -int32 CFE_ES_RestartApp(uint32 AppID); +int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID); /*****************************************************************************/ /** @@ -482,7 +549,7 @@ int32 CFE_ES_RestartApp(uint32 AppID); ** \sa #CFE_ES_RestartApp, #CFE_ES_DeleteApp, #CFE_ES_START_APP_CC ** ******************************************************************************/ -int32 CFE_ES_ReloadApp(uint32 AppID, const char *AppFileName); +int32 CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName); /*****************************************************************************/ /** @@ -501,7 +568,7 @@ int32 CFE_ES_ReloadApp(uint32 AppID, const char *AppFileName); ** \sa #CFE_ES_RestartApp, #CFE_ES_ReloadApp ** ******************************************************************************/ -int32 CFE_ES_DeleteApp(uint32 AppID); +int32 CFE_ES_DeleteApp(CFE_ES_ResourceID_t AppID); /**@}*/ /** @defgroup CFEAPIESAppBehavior cFE Application Behavior APIs @@ -699,7 +766,8 @@ int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr); ** \par Assumptions, External Events, and Notes: ** NOTE: \b All tasks associated with the Application would return the same Application ID. ** -** \param[in] AppIdPtr Pointer to variable that is to receive the Application's ID. *AppIdPtr is the application ID of the calling Application. +** \param[out] AppIdPtr Pointer to variable that is to receive the Application's ID. +** *AppIdPtr will be set to the application ID of the calling Application. ** ** ** \return Execution status, see \ref CFEReturnCodes @@ -710,7 +778,7 @@ int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr); ** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName, #CFE_ES_GetTaskInfo ** ******************************************************************************/ -int32 CFE_ES_GetAppID(uint32 *AppIdPtr); +int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr); /*****************************************************************************/ /** @@ -732,7 +800,7 @@ int32 CFE_ES_GetAppID(uint32 *AppIdPtr); ** \retval #CFE_ES_ERR_TASKID \copybrief CFE_ES_ERR_TASKID ** ******************************************************************************/ -int32 CFE_ES_GetTaskID(uint32 *TaskIdPtr); +int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr); /*****************************************************************************/ /** @@ -745,8 +813,7 @@ int32 CFE_ES_GetTaskID(uint32 *TaskIdPtr); ** \par Assumptions, External Events, and Notes: ** None ** -** \param[in] AppIdPtr Pointer to variable that is to receive the Application's ID. *AppIdPtr is the application ID of the calling Application. -** +** \param[out] AppIdPtr Pointer to variable that is to receive the Application's ID. ** \param[in] AppName Pointer to null terminated character string containing an Application name. ** ** @@ -758,7 +825,7 @@ int32 CFE_ES_GetTaskID(uint32 *TaskIdPtr); ** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppID, #CFE_ES_GetAppName, #CFE_ES_GetTaskInfo ** ******************************************************************************/ -int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName); +int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName); /*****************************************************************************/ /** @@ -790,7 +857,7 @@ int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName); ** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetTaskInfo ** ******************************************************************************/ -int32 CFE_ES_GetAppName(char *AppName, uint32 AppId, uint32 BufferLength); +int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, uint32 BufferLength); /*****************************************************************************/ /** @@ -819,7 +886,7 @@ int32 CFE_ES_GetAppName(char *AppName, uint32 AppId, uint32 BufferLength); ** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName ** ******************************************************************************/ -int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId); +int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId); /*****************************************************************************/ /** @@ -848,7 +915,7 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId); ** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName ** ******************************************************************************/ -int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId); +int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId); /**@}*/ /** @defgroup CFEAPIESChildTask cFE Child Task APIs @@ -912,7 +979,7 @@ int32 CFE_ES_RegisterChildTask(void); ** \sa #CFE_ES_RegisterChildTask, #CFE_ES_DeleteChildTask, #CFE_ES_ExitChildTask ** ******************************************************************************/ -int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, +int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, uint32 *StackPtr, @@ -940,7 +1007,7 @@ int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, ** \sa #CFE_ES_RegisterChildTask, #CFE_ES_CreateChildTask, #CFE_ES_ExitChildTask ** ******************************************************************************/ -int32 CFE_ES_DeleteChildTask(uint32 TaskId); +int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId); /*****************************************************************************/ /** @@ -1421,7 +1488,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 ** ******************************************************************************/ -int32 CFE_ES_RegisterGenCounter(uint32 *CounterIdPtr, const char *CounterName); +int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName); /*****************************************************************************/ /** @@ -1442,7 +1509,7 @@ int32 CFE_ES_RegisterGenCounter(uint32 *CounterIdPtr, const char *CounterName); ** \sa #CFE_ES_IncrementGenCounter, #CFE_ES_RegisterGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -int32 CFE_ES_DeleteGenCounter(uint32 CounterId); +int32 CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId); /*****************************************************************************/ /** @@ -1463,7 +1530,7 @@ int32 CFE_ES_DeleteGenCounter(uint32 CounterId); ** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -int32 CFE_ES_IncrementGenCounter(uint32 CounterId); +int32 CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId); /*****************************************************************************/ /** @@ -1486,7 +1553,7 @@ int32 CFE_ES_IncrementGenCounter(uint32 CounterId); ** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -int32 CFE_ES_SetGenCount(uint32 CounterId, uint32 Count); +int32 CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count); /*****************************************************************************/ /** @@ -1509,7 +1576,7 @@ int32 CFE_ES_SetGenCount(uint32 CounterId, uint32 Count); ** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -int32 CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count); +int32 CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count); /*****************************************************************************/ @@ -1532,7 +1599,7 @@ int32 CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count); ** ** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCount ******************************************************************************/ -int32 CFE_ES_GetGenCounterIDByName(uint32 *CounterIdPtr, const char *CounterName); +int32 CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName); /**@}*/ #endif /* _cfe_es_ */ diff --git a/fsw/cfe-core/src/inc/cfe_evs.h b/fsw/cfe-core/src/inc/cfe_evs.h index 3e0f77188..0eeb977bd 100644 --- a/fsw/cfe-core/src/inc/cfe_evs.h +++ b/fsw/cfe-core/src/inc/cfe_evs.h @@ -265,7 +265,7 @@ int32 CFE_EVS_SendEvent (uint16 EventID, **/ int32 CFE_EVS_SendEventWithAppID (uint16 EventID, uint16 EventType, - uint32 AppID, + CFE_ES_ResourceID_t AppID, const char *Spec, ... ) OS_PRINTF(4,5); diff --git a/fsw/cfe-core/src/inc/cfe_evs_msg.h b/fsw/cfe-core/src/inc/cfe_evs_msg.h index e8d4cb416..23e7cda08 100644 --- a/fsw/cfe-core/src/inc/cfe_evs_msg.h +++ b/fsw/cfe-core/src/inc/cfe_evs_msg.h @@ -1127,7 +1127,7 @@ typedef CFE_EVS_AppNameEventIDMaskCmd_t CFE_EVS_SetFilter_t; /* Telemetry Message Data Formats */ /**********************************/ typedef struct CFE_EVS_AppTlmData { - uint32 AppID; /**< \cfetlmmnemonic \EVS_APPID + CFE_ES_ResourceID_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/private/cfe_es_erlog_typedef.h b/fsw/cfe-core/src/inc/private/cfe_es_erlog_typedef.h index b93fba5d4..c2bcfe8a5 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 */ - uint32 AppID; /* The application ID */ + CFE_ES_ResourceID_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_private.h b/fsw/cfe-core/src/inc/private/cfe_private.h index 11f38014b..5f6096737 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(uint32 AppId); +extern int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId); /*****************************************************************************/ /** @@ -238,7 +238,7 @@ extern int32 CFE_TBL_CleanUpApp(uint32 AppId); ** that have been allocated to the specified Application. ** ******************************************************************************/ -extern int32 CFE_SB_CleanUpApp(uint32 AppId); +extern int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId); /*****************************************************************************/ /** @@ -250,7 +250,7 @@ extern int32 CFE_SB_CleanUpApp(uint32 AppId); ** that have been allocated to the specified Application. ** ******************************************************************************/ -extern int32 CFE_EVS_CleanUpApp(uint32 AppId); +extern int32 CFE_EVS_CleanUpApp(CFE_ES_ResourceID_t AppId); /*****************************************************************************/ /** @@ -262,7 +262,7 @@ extern int32 CFE_EVS_CleanUpApp(uint32 AppId); ** that have been allocated to the specified Application. ** ******************************************************************************/ -extern int32 CFE_TIME_CleanUpApp(uint32 AppId); +extern int32 CFE_TIME_CleanUpApp(CFE_ES_ResourceID_t AppId); /*****************************************************************************/ diff --git a/fsw/cfe-core/src/sb/cfe_sb_api.c b/fsw/cfe-core/src/sb/cfe_sb_api.c index 15703b57c..8c80eeef8 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_api.c +++ b/fsw/cfe-core/src/sb/cfe_sb_api.c @@ -80,8 +80,8 @@ */ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName) { - uint32 AppId = 0xFFFFFFFF; - uint32 TskId = 0; + CFE_ES_ResourceID_t AppId; + CFE_ES_ResourceID_t TskId; osal_id_t SysQueueId; int32 Status; CFE_SB_PipeId_t OriginalPipeIdParamValue = (PipeIdPtr == NULL) ? 0 : (*PipeIdPtr); @@ -210,7 +210,7 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * */ int32 CFE_SB_DeletePipe(CFE_SB_PipeId_t PipeId) { - uint32 CallerId = 0xFFFFFFFF; + CFE_ES_ResourceID_t CallerId; int32 Status = 0; /* get the callers Application Id */ @@ -236,7 +236,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, uint32 AppId) +int32 CFE_SB_DeletePipeWithAppId(CFE_SB_PipeId_t PipeId, CFE_ES_ResourceID_t AppId) { int32 Status = 0; @@ -263,12 +263,13 @@ int32 CFE_SB_DeletePipeWithAppId(CFE_SB_PipeId_t PipeId, uint32 AppId) ** Return: ** CFE_SUCCESS or cFE Error Code */ -int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,uint32 AppId) +int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) { uint8 PipeTblIdx; int32 RtnFromVal,Stat; - uint32 Owner,i; - uint32 TskId = 0; + CFE_ES_ResourceID_t Owner; + uint32 i; + CFE_ES_ResourceID_t TskId; CFE_SB_Msg_t *PipeMsgPtr; CFE_SB_DestinationD_t *DestPtr = NULL; char FullName[(OS_MAX_API_NAME * 2)]; @@ -295,7 +296,8 @@ int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,uint32 AppId) Owner = CFE_SB.PipeTbl[PipeTblIdx].AppId; /* check that the given AppId is the owner of the pipe */ - if(AppId != Owner){ + if( !CFE_ES_ResourceID_Equal(AppId, Owner) ) + { CFE_SB.HKTlmMsg.Payload.CreatePipeErrorCounter++; CFE_SB_UnlockSharedData(__func__,__LINE__); CFE_EVS_SendEventWithAppID(CFE_SB_DEL_PIPE_ERR2_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, @@ -391,7 +393,10 @@ int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) { uint8 PipeTblIdx = 0; int32 RtnFromVal = 0; - uint32 Owner = 0, AppID = 0, TskId = 0, Status = 0; + CFE_ES_ResourceID_t Owner; + CFE_ES_ResourceID_t AppID; + CFE_ES_ResourceID_t TskId; + int32 Status; char FullName[(OS_MAX_API_NAME * 2)]; Status = CFE_ES_GetAppID(&AppID); @@ -428,7 +433,8 @@ int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) /* check that the given AppId is the owner of the pipe */ Owner = CFE_SB.PipeTbl[PipeTblIdx].AppId; - if(AppID != Owner){ + if( !CFE_ES_ResourceID_Equal(AppID, Owner) ) + { CFE_SB.HKTlmMsg.Payload.PipeOptsErrorCounter++; CFE_SB_UnlockSharedData(__func__,__LINE__); CFE_EVS_SendEventWithAppID(CFE_SB_SETPIPEOPTS_OWNER_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, @@ -462,7 +468,7 @@ int32 CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptsPtr) { uint8 PipeTblIdx = 0; int32 RtnFromVal = 0; - uint32 TskId = 0; + CFE_ES_ResourceID_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; /* get TaskId of caller for events */ @@ -508,7 +514,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){ OS_queue_prop_t queue_prop; int32 Status = CFE_SUCCESS; - uint32 TskId = 0; + CFE_ES_ResourceID_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; if(PipeNameBuf == NULL || PipeNameSize == 0) { @@ -539,6 +545,7 @@ int32 CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t "GetPipeName name=%s id=%d", PipeNameBuf, PipeId); } else{ + CFE_ES_GetTaskID(&TskId); CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPENAME_ID_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB.AppId, "Pipe Id Error:Bad Argument,Id=%d,Requestor %s", PipeId,CFE_SB_GetAppTskName(TskId,FullName)); @@ -560,7 +567,7 @@ int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) uint8 PipeTblIdx = 0; int32 Status = CFE_SUCCESS; int32 RtnFromVal = 0; - uint32 TskId = 0; + CFE_ES_ResourceID_t TskId; osal_id_t QueueId; char FullName[(OS_MAX_API_NAME * 2)]; @@ -725,8 +732,8 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, CFE_SB_RouteEntry_t* RoutePtr; int32 Stat; CFE_SB_MsgKey_t MsgKey; - uint32 TskId = 0; - uint32 AppId = 0xFFFFFFFF; + CFE_ES_ResourceID_t TskId; + CFE_ES_ResourceID_t AppId; uint8 PipeIdx; CFE_SB_DestinationD_t *DestBlkPtr = NULL; char FullName[(OS_MAX_API_NAME * 2)]; @@ -755,7 +762,7 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, }/* end if */ /* check that the requestor is the owner of the pipe */ - if(CFE_SB.PipeTbl[PipeIdx].AppId != AppId){ + if( !CFE_ES_ResourceID_Equal(CFE_SB.PipeTbl[PipeIdx].AppId, AppId)){ CFE_SB.HKTlmMsg.Payload.SubscribeErrorCounter++; CFE_SB_UnlockSharedData(__func__,__LINE__); CFE_EVS_SendEventWithAppID(CFE_SB_SUB_INV_CALLER_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, @@ -917,7 +924,7 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, */ int32 CFE_SB_Unsubscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) { - uint32 CallerId = 0xFFFFFFFF; + CFE_ES_ResourceID_t CallerId; int32 Status = 0; /* get the callers Application Id */ @@ -935,7 +942,7 @@ 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) { - uint32 CallerId = 0xFFFFFFFF; + CFE_ES_ResourceID_t CallerId; int32 Status = 0; /* get the callers Application Id */ @@ -972,7 +979,7 @@ 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, - uint32 AppId) + CFE_ES_ResourceID_t AppId) { int32 Status = 0; @@ -1012,13 +1019,13 @@ 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,uint32 AppId) + uint8 Scope,CFE_ES_ResourceID_t AppId) { CFE_SB_MsgKey_t MsgKey; CFE_SB_MsgRouteIdx_t RouteIdx; CFE_SB_RouteEntry_t* RoutePtr; uint32 PipeIdx; - uint32 TskId = 0; + CFE_ES_ResourceID_t TskId; CFE_SB_DestinationD_t *DestPtr = NULL; char FullName[(OS_MAX_API_NAME * 2)]; @@ -1040,7 +1047,8 @@ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId,CFE_SB_PipeId_t PipeId, }/* end if */ /* if given 'AppId' is not the owner of the pipe, send error event and return */ - if(CFE_SB.PipeTbl[PipeIdx].AppId != AppId){ + if( !CFE_ES_ResourceID_Equal(CFE_SB.PipeTbl[PipeIdx].AppId, AppId) ) + { CFE_SB_UnlockSharedData(__func__,__LINE__); CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_INV_CALLER_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Unsubscribe Err:Caller(%s) is not the owner of pipe %d,Msg=0x%x", @@ -1189,7 +1197,7 @@ int32 CFE_SB_SendMsgFull(CFE_SB_Msg_t *MsgPtr, CFE_SB_BufferD_t *BufDscPtr; uint16 TotalMsgSize; CFE_SB_MsgRouteIdx_t RtgTblIdx; - uint32 TskId = 0; + CFE_ES_ResourceID_t TskId; uint32 i; char FullName[(OS_MAX_API_NAME * 2)]; CFE_SB_EventBuf_t SBSndErr; @@ -1350,11 +1358,11 @@ int32 CFE_SB_SendMsgFull(CFE_SB_Msg_t *MsgPtr, if(PipeDscPtr->Opts & CFE_SB_PIPEOPTS_IGNOREMINE) { - uint32 AppId = 0xFFFFFFFF; + CFE_ES_ResourceID_t AppId; CFE_ES_GetAppID(&AppId); - if(PipeDscPtr->AppId == AppId) + if( CFE_ES_ResourceID_Equal(PipeDscPtr->AppId, AppId) ) { continue; } @@ -1509,7 +1517,7 @@ int32 CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, CFE_SB_BufferD_t *Message; CFE_SB_PipeD_t *PipeDscPtr; CFE_SB_DestinationD_t *DestPtr = NULL; - uint32 TskId = 0; + CFE_ES_ResourceID_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; /* get task id for events */ @@ -1628,7 +1636,7 @@ CFE_SB_Msg_t *CFE_SB_ZeroCopyGetPtr(uint16 MsgSize, CFE_SB_ZeroCopyHandle_t *BufferHandle) { int32 stat1; - uint32 AppId = 0xFFFFFFFF; + CFE_ES_ResourceID_t AppId; cpuaddr address = 0; CFE_SB_ZeroCopyD_t *zcd = NULL; CFE_SB_BufferD_t *bd = NULL; @@ -1871,7 +1879,7 @@ int32 CFE_SB_ZeroCopyPass(CFE_SB_Msg_t *MsgPtr, */ int32 CFE_SB_ReadQueue (CFE_SB_PipeD_t *PipeDscPtr, - uint32 TskId, + CFE_ES_ResourceID_t TskId, CFE_SB_TimeOut_t Time_Out, CFE_SB_BufferD_t **Message) { diff --git a/fsw/cfe-core/src/sb/cfe_sb_priv.c b/fsw/cfe-core/src/sb/cfe_sb_priv.c index 0cad3d4f4..1e75bca5f 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_priv.c +++ b/fsw/cfe-core/src/sb/cfe_sb_priv.c @@ -122,14 +122,14 @@ void CFE_SB_InitIdxStack(void) ** Return: ** None */ -int32 CFE_SB_CleanUpApp(uint32 AppId){ +int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId){ uint32 i; /* loop through the pipe table looking for pipes owned by AppId */ for(i=0;iPrev); - if(zcd->AppID == AppId){ + if( CFE_ES_ResourceID_Equal(zcd->AppID, AppId) ) + { CFE_SB_ZeroCopyReleasePtr((CFE_SB_Msg_t *) zcd->Buffer, (CFE_SB_ZeroCopyHandle_t) zcd); } zcd = prev; diff --git a/fsw/cfe-core/src/sb/cfe_sb_priv.h b/fsw/cfe-core/src/sb/cfe_sb_priv.h index 8a410a3a3..f0a3bdcfd 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_priv.h +++ b/fsw/cfe-core/src/sb/cfe_sb_priv.h @@ -211,7 +211,7 @@ typedef struct { */ typedef struct { - uint32 AppID; + CFE_ES_ResourceID_t AppID; uint32 Size; void *Buffer; void *Next; @@ -248,7 +248,7 @@ typedef struct { char AppName[OS_MAX_API_NAME]; uint8 Opts; uint8 Spare; - uint32 AppId; + CFE_ES_ResourceID_t AppId; osal_id_t SysQueueId; uint32 LastSender; uint16 QueueDepth; @@ -283,8 +283,8 @@ typedef struct { osal_id_t SharedDataMutexId; uint32 SubscriptionReporting; uint32 SenderReporting; - uint32 AppId; - uint32 StopRecurseFlags[CFE_PLATFORM_ES_MAX_APPLICATIONS]; + CFE_ES_ResourceID_t AppId; + uint32 StopRecurseFlags[OS_MAX_TASKS]; void *ZeroCopyTail; CFE_SB_PipeD_t PipeTbl[CFE_PLATFORM_SB_MAX_PIPES]; CFE_SB_HousekeepingTlm_t HKTlmMsg; @@ -346,7 +346,7 @@ CFE_SB_MsgKey_t CFE_SB_ConvertMsgIdtoMsgKey(CFE_SB_MsgId_t MsgId); void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber); void CFE_SB_UnlockSharedData(const char *FuncName, int32 LineNumber); void CFE_SB_ReleaseBuffer (CFE_SB_BufferD_t *bd, CFE_SB_DestinationD_t *dest); -int32 CFE_SB_ReadQueue(CFE_SB_PipeD_t *PipeDscPtr,uint32 TskId, +int32 CFE_SB_ReadQueue(CFE_SB_PipeD_t *PipeDscPtr,CFE_ES_ResourceID_t TskId, CFE_SB_TimeOut_t Time_Out,CFE_SB_BufferD_t **Message ); int32 CFE_SB_WriteQueue(CFE_SB_PipeD_t *pd,uint32 TskId, const CFE_SB_BufferD_t *bd,CFE_SB_MsgId_t MsgId ); @@ -359,14 +359,14 @@ void CFE_SB_SetRoutingTblIdx(CFE_SB_MsgKey_t MsgKey, CFE_SB_MsgRouteIdx_t Valu CFE_SB_RouteEntry_t* CFE_SB_GetRoutePtrFromIdx(CFE_SB_MsgRouteIdx_t RouteIdx); void CFE_SB_ResetCounters(void); void CFE_SB_SetMsgSeqCnt(CFE_SB_MsgPtr_t MsgPtr,uint32 Count); -char *CFE_SB_GetAppTskName(uint32 TaskId, char* FullName); +char *CFE_SB_GetAppTskName(CFE_ES_ResourceID_t TaskId, char* FullName); CFE_SB_BufferD_t *CFE_SB_GetBufferFromPool(CFE_SB_MsgId_t MsgId, uint16 Size); CFE_SB_BufferD_t *CFE_SB_GetBufferFromCaller(CFE_SB_MsgId_t MsgId, void *Address); CFE_SB_PipeD_t *CFE_SB_GetPipePtr(CFE_SB_PipeId_t PipeId); CFE_SB_PipeId_t CFE_SB_GetAvailPipeIdx(void); CFE_SB_DestinationD_t *CFE_SB_GetDestPtr (CFE_SB_MsgKey_t MsgKey, CFE_SB_PipeId_t PipeId); -int32 CFE_SB_DeletePipeWithAppId(CFE_SB_PipeId_t PipeId,uint32 AppId); -int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,uint32 AppId); +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_SubscribeFull(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Quality, @@ -374,16 +374,16 @@ 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, - uint32 AppId); + CFE_ES_ResourceID_t AppId); int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, - uint8 Scope, uint32 AppId); + uint8 Scope, CFE_ES_ResourceID_t AppId); int32 CFE_SB_SendMsgFull(CFE_SB_Msg_t *MsgPtr, uint32 TlmCntIncrements, uint32 CopyMode); int32 CFE_SB_SendRtgInfo(const char *Filename); int32 CFE_SB_SendPipeInfo(const char *Filename); int32 CFE_SB_SendMapInfo(const char *Filename); int32 CFE_SB_ZeroCopyReleaseDesc(CFE_SB_Msg_t *Ptr2Release, CFE_SB_ZeroCopyHandle_t BufferHandle); -int32 CFE_SB_ZeroCopyReleaseAppId(uint32 AppId); +int32 CFE_SB_ZeroCopyReleaseAppId(CFE_ES_ResourceID_t AppId); int32 CFE_SB_DecrBufUseCnt(CFE_SB_BufferD_t *bd); int32 CFE_SB_ValidateMsgId(CFE_SB_MsgId_t MsgId); int32 CFE_SB_ValidatePipeId(CFE_SB_PipeId_t PipeId); @@ -391,8 +391,8 @@ void CFE_SB_IncrCmdCtr(int32 status); void CFE_SB_FileWriteByteCntErr(const char *Filename,uint32 Requested,uint32 Actual); void CFE_SB_SetSubscriptionReporting(uint32 state); uint32 CFE_SB_FindGlobalMsgIdCnt(void); -uint32 CFE_SB_RequestToSendEvent(uint32 TaskId, uint32 Bit); -void CFE_SB_FinishSendEvent(uint32 TaskId, uint32 Bit); +uint32 CFE_SB_RequestToSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit); +void CFE_SB_FinishSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit); CFE_SB_DestinationD_t *CFE_SB_GetDestinationBlk(void); int32 CFE_SB_PutDestinationBlk(CFE_SB_DestinationD_t *Dest); int32 CFE_SB_AddDest(CFE_SB_RouteEntry_t *RouteEntry, CFE_SB_DestinationD_t *NewNode); diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_api.c b/fsw/cfe-core/src/tbl/cfe_tbl_api.c index 84aee00d8..ec0deba04 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; - uint32 ThisAppId; + CFE_ES_ResourceID_t ThisAppId; char AppName[OS_MAX_API_NAME] = {"UNKNOWN"}; char TblName[CFE_TBL_MAX_FULL_NAME_LEN] = {""}; CFE_TBL_Handle_t AccessIndex; @@ -168,7 +168,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, RegRecPtr = &CFE_TBL_TaskData.Registry[RegIndx]; /* If this app previously owned the table, then allow them to re-register */ - if (RegRecPtr->OwnerAppId == ThisAppId) + if ( CFE_ES_ResourceID_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) @@ -193,7 +193,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, while ((AccessIndex != CFE_TBL_END_OF_LIST) && (*TblHandlePtr == CFE_TBL_BAD_TABLE_HANDLE)) { if ((CFE_TBL_TaskData.Handles[AccessIndex].UsedFlag == true) && - (CFE_TBL_TaskData.Handles[AccessIndex].AppId == ThisAppId) && + CFE_ES_ResourceID_Equal(CFE_TBL_TaskData.Handles[AccessIndex].AppId, ThisAppId) && (CFE_TBL_TaskData.Handles[AccessIndex].RegIndex == RegIndx)) { *TblHandlePtr = AccessIndex; @@ -510,7 +510,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, const char *TblName ) { int32 Status; - uint32 ThisAppId; + CFE_ES_ResourceID_t ThisAppId; int16 RegIndx = CFE_TBL_NOT_FOUND; CFE_TBL_AccessDescriptor_t *AccessDescPtr = NULL; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; @@ -608,7 +608,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, int32 CFE_TBL_Unregister ( CFE_TBL_Handle_t TblHandle ) { int32 Status; - uint32 ThisAppId; + CFE_ES_ResourceID_t ThisAppId; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; CFE_TBL_AccessDescriptor_t *AccessDescPtr = NULL; char AppName[OS_MAX_API_NAME] = {"UNKNOWN"}; @@ -625,7 +625,7 @@ int32 CFE_TBL_Unregister ( CFE_TBL_Handle_t TblHandle ) RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; /* Verify that the application unregistering the table owns the table */ - if (RegRecPtr->OwnerAppId == ThisAppId) + if (CFE_ES_ResourceID_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. */ @@ -679,7 +679,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, const void *SrcDataPtr ) { int32 Status; - uint32 ThisAppId; + CFE_ES_ResourceID_t ThisAppId; CFE_TBL_LoadBuff_t *WorkingBufferPtr; CFE_TBL_AccessDescriptor_t *AccessDescPtr; CFE_TBL_RegistryRec_t *RegRecPtr; @@ -910,7 +910,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ) { int32 Status; - uint32 ThisAppId; + CFE_ES_ResourceID_t ThisAppId; CFE_TBL_RegistryRec_t *RegRecPtr=NULL; CFE_TBL_AccessDescriptor_t *AccessDescPtr=NULL; char AppName[OS_MAX_API_NAME]={"UNKNOWN"}; @@ -991,7 +991,7 @@ int32 CFE_TBL_GetAddress( void **TblPtr, CFE_TBL_Handle_t TblHandle ) { int32 Status; - uint32 ThisAppId; + CFE_ES_ResourceID_t ThisAppId; /* Assume failure at returning the table address */ *TblPtr = NULL; @@ -1022,7 +1022,7 @@ int32 CFE_TBL_GetAddress( void **TblPtr, int32 CFE_TBL_ReleaseAddress( CFE_TBL_Handle_t TblHandle ) { int32 Status; - uint32 ThisAppId; + CFE_ES_ResourceID_t ThisAppId; /* Verify that this application has the right to perform operation */ Status = CFE_TBL_ValidateAccess(TblHandle, &ThisAppId); @@ -1057,7 +1057,7 @@ int32 CFE_TBL_GetAddresses( void **TblPtrs[], { uint16 i; int32 Status; - uint32 ThisAppId; + CFE_ES_ResourceID_t ThisAppId; /* Assume failure at returning the table addresses */ for (i=0; iRegIndex]; /* Verify that the calling application is the table owner */ - if (RegRecPtr->OwnerAppId == ThisAppId) + if (CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, ThisAppId)) { RegRecPtr->NotificationMsgId = MsgId; RegRecPtr->NotificationCC = CommandCode; diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c index 8835a58b6..65b3d199e 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c @@ -336,7 +336,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, uint32 *AppIdPtr) +int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t *AppIdPtr) { int32 Status; @@ -369,15 +369,15 @@ int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, uint32 *AppIdPtr) ** NOTE: For complete prolog information, see 'cfe_tbl_internal.h' ********************************************************************/ -int32 CFE_TBL_CheckAccessRights(CFE_TBL_Handle_t TblHandle, uint32 ThisAppId) +int32 CFE_TBL_CheckAccessRights(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t ThisAppId) { int32 Status = CFE_SUCCESS; - if (ThisAppId != CFE_TBL_TaskData.Handles[TblHandle].AppId) + if (!CFE_ES_ResourceID_Equal(ThisAppId, CFE_TBL_TaskData.Handles[TblHandle].AppId)) { /* The Table Service Task always has access rights so that tables */ /* can be manipulated via ground command */ - if (ThisAppId != CFE_TBL_TaskData.TableTaskAppId) + if (!CFE_ES_ResourceID_Equal(ThisAppId, CFE_TBL_TaskData.TableTaskAppId)) { Status = CFE_TBL_ERR_NO_ACCESS; } @@ -486,7 +486,7 @@ int32 CFE_TBL_RemoveAccessLink(CFE_TBL_Handle_t TblHandle) ********************************************************************/ -int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, uint32 ThisAppId) +int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t ThisAppId) { int32 Status; CFE_TBL_AccessDescriptor_t *AccessDescPtr; @@ -509,7 +509,7 @@ int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, uint RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; /* If table is unowned, then owner must have unregistered it when we weren't looking */ - if (RegRecPtr->OwnerAppId == CFE_TBL_NOT_OWNED) + if (CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED)) { Status = CFE_TBL_ERR_UNREGISTERED; @@ -597,7 +597,7 @@ int16 CFE_TBL_FindTableInRegistry(const char *TblName) i++; /* Check to see if the record is currently being used */ - if (CFE_TBL_TaskData.Registry[i].OwnerAppId != CFE_TBL_NOT_OWNED) + if ( !CFE_ES_ResourceID_Equal(CFE_TBL_TaskData.Registry[i].OwnerAppId, CFE_TBL_NOT_OWNED) ) { /* Perform a case sensitive name comparison */ if (strcmp(TblName, CFE_TBL_TaskData.Registry[i].Name) == 0) @@ -628,7 +628,7 @@ 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_TBL_TaskData.Registry[i].OwnerAppId == CFE_TBL_NOT_OWNED) && + 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)) { RegIndx = i; @@ -678,7 +678,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, uint32 ThisAppId) +void CFE_TBL_FormTableName(char *FullTblName, const char *TblName, CFE_ES_ResourceID_t ThisAppId) { char AppName[OS_MAX_API_NAME]; @@ -1357,7 +1357,7 @@ void CFE_TBL_ByteSwapUint32(uint32 *Uint32ToSwapPtr) ** NOTE: For complete prolog information, see 'cfe_tbl_internal.h' ********************************************************************/ -int32 CFE_TBL_CleanUpApp(uint32 AppId) +int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId) { uint32 i; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; @@ -1369,7 +1369,7 @@ int32 CFE_TBL_CleanUpApp(uint32 AppId) { /* Check to see if the table to be dumped is owned by the App to be deleted */ if ((CFE_TBL_TaskData.DumpControlBlocks[i].State != CFE_TBL_DUMP_FREE) && - (CFE_TBL_TaskData.DumpControlBlocks[i].RegRecPtr->OwnerAppId == AppId)) + CFE_ES_ResourceID_Equal(CFE_TBL_TaskData.DumpControlBlocks[i].RegRecPtr->OwnerAppId, AppId)) { /* If so, then remove the dump request */ CFE_TBL_TaskData.DumpControlBlocks[i].State = CFE_TBL_DUMP_FREE; @@ -1380,7 +1380,8 @@ int32 CFE_TBL_CleanUpApp(uint32 AppId) for (i=0; iRegIndex]; /* Determine if the Application owned this particular table */ - if (RegRecPtr->OwnerAppId == AppId) + if (CFE_ES_ResourceID_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. */ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.h b/fsw/cfe-core/src/tbl/cfe_tbl_internal.h index fb7930c24..cfe1280a4 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 0xFFFFFFFF +#define CFE_TBL_NOT_OWNED CFE_ES_RESOURCEID_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, uint32 *AppIdPtr); +int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t *AppIdPtr); /*****************************************************************************/ /** @@ -116,7 +116,7 @@ int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, uint32 *AppIdPtr); ** \retval #CFE_TBL_ERR_NO_ACCESS \copydoc CFE_TBL_ERR_NO_ACCESS ** ******************************************************************************/ -int32 CFE_TBL_CheckAccessRights(CFE_TBL_Handle_t TblHandle, uint32 ThisAppId); +int32 CFE_TBL_CheckAccessRights(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_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, uint32 ThisAppId); +int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t ThisAppId); /*****************************************************************************/ @@ -262,7 +262,7 @@ CFE_TBL_Handle_t CFE_TBL_FindFreeHandle(void); ** ** ******************************************************************************/ -void CFE_TBL_FormTableName(char *FullTblName, const char *TblName, uint32 ThisAppId); +void CFE_TBL_FormTableName(char *FullTblName, const char *TblName, CFE_ES_ResourceID_t ThisAppId); /*****************************************************************************/ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task.h b/fsw/cfe-core/src/tbl/cfe_tbl_task.h index 20e57cf8b..96af49979 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 { - uint32 AppId; /**< \brief Application ID to verify access */ + CFE_ES_ResourceID_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 { - uint32 OwnerAppId; /**< \brief Application ID of App that Registered Table */ + CFE_ES_ResourceID_t OwnerAppId; /**< \brief Application ID of App that Registered Table */ uint32 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 */ @@ -316,7 +316,7 @@ typedef struct */ char PipeName[16]; /**< \brief Contains name of Table Task command pipe */ uint16 PipeDepth; /**< \brief Contains depth of Table Task command pipe */ - uint32 TableTaskAppId; /**< \brief Contains Table Task Application ID as assigned by OS AL */ + CFE_ES_ResourceID_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; 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 67274316a..c3b3140bf 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c @@ -174,7 +174,7 @@ void CFE_TBL_GetHkData(void) Count = 0; for (i=0; iOwnerAppId != CFE_TBL_NOT_OWNED) || + if (!CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED) || (RegRecPtr->HeadOfAccessList != CFE_TBL_END_OF_LIST)) { /* Fill Registry Dump Record with relevant information */ @@ -1228,7 +1228,7 @@ int32 CFE_TBL_DumpRegistryCmd(const CFE_TBL_DumpRegistry_t *data) } /* Determine the name of the owning application */ - if (RegRecPtr->OwnerAppId != CFE_TBL_NOT_OWNED) + if (!CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED)) { CFE_ES_GetAppName(DumpRecord.OwnerAppName, RegRecPtr->OwnerAppId, sizeof(DumpRecord.OwnerAppName)); } diff --git a/fsw/cfe-core/src/time/cfe_time_api.c b/fsw/cfe-core/src/time/cfe_time_api.c index f52438f6e..37e8060d7 100644 --- a/fsw/cfe-core/src/time/cfe_time_api.c +++ b/fsw/cfe-core/src/time/cfe_time_api.c @@ -758,7 +758,7 @@ void CFE_TIME_ExternalTone(void) int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) { int32 Status; - uint32 AppId; + CFE_ES_ResourceID_t AppId; uint32 AppIndex; Status = CFE_ES_GetAppID(&AppId); @@ -792,7 +792,7 @@ int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPt int32 CFE_TIME_UnregisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) { int32 Status; - uint32 AppId; + CFE_ES_ResourceID_t AppId; uint32 AppIndex; Status = CFE_ES_GetAppID(&AppId); diff --git a/fsw/cfe-core/src/time/cfe_time_utils.c b/fsw/cfe-core/src/time/cfe_time_utils.c index 64e6b92a7..fec19f7a9 100644 --- a/fsw/cfe-core/src/time/cfe_time_utils.c +++ b/fsw/cfe-core/src/time/cfe_time_utils.c @@ -1136,7 +1136,7 @@ void CFE_TIME_Set1HzAdj(CFE_TIME_SysTime_t NewAdjust, int16 Direction) /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 CFE_TIME_CleanUpApp(uint32 AppId) +int32 CFE_TIME_CleanUpApp(CFE_ES_ResourceID_t AppId) { int32 Status; uint32 AppIndex; diff --git a/fsw/cfe-core/src/time/cfe_time_utils.h b/fsw/cfe-core/src/time/cfe_time_utils.h index 0deecaa36..d89f19350 100644 --- a/fsw/cfe-core/src/time/cfe_time_utils.h +++ b/fsw/cfe-core/src/time/cfe_time_utils.h @@ -305,8 +305,8 @@ typedef struct /* ** Interrupt task ID's... */ - uint32 LocalTaskID; - uint32 ToneTaskID; + CFE_ES_ResourceID_t LocalTaskID; + CFE_ES_ResourceID_t ToneTaskID; /* ** Maximum difference from expected for external time sources... diff --git a/fsw/cfe-core/unit-test/es_UT.c b/fsw/cfe-core/unit-test/es_UT.c index be84309aa..9616d100c 100644 --- a/fsw/cfe-core/unit-test/es_UT.c +++ b/fsw/cfe-core/unit-test/es_UT.c @@ -195,19 +195,27 @@ static const UT_TaskPipeDispatchId_t UT_TPID_CFE_ES_SEND_HK = /* ** Functions */ -uint32 ES_UT_MakeAppIdForIndex(uint32 ArrayIdx) +CFE_ES_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 ArrayIdx; + return CFE_ES_ResourceID_FromInteger(ArrayIdx + CFE_ES_APPID_BASE); } -uint32 ES_UT_MakeTaskIdForIndex(uint32 ArrayIdx) +CFE_ES_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 (ArrayIdx + 0x40010000); + return CFE_ES_ResourceID_FromInteger(ArrayIdx + 0x40010000); } + +CFE_ES_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); +} + /* * Helper function to setup a single app ID in the given state, along with * a main task ID. A pointer to the App and Task record is output so the @@ -217,8 +225,8 @@ 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; - uint32 UtTaskId; - uint32 UtAppId; + CFE_ES_ResourceID_t UtTaskId; + CFE_ES_ResourceID_t UtAppId; CFE_ES_AppRecord_t *LocalAppPtr; CFE_ES_TaskRecord_t *LocalTaskPtr; @@ -274,8 +282,8 @@ 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; - uint32 UtTaskId; - uint32 UtAppId; + CFE_ES_ResourceID_t UtTaskId; + CFE_ES_ResourceID_t UtAppId; CFE_ES_TaskRecord_t *LocalTaskPtr; UtAppId = CFE_ES_AppRecordGetID(ParentApp); @@ -938,7 +946,7 @@ void TestApps(void) int Return; int j; CFE_ES_AppInfo_t AppInfo; - uint32 Id; + CFE_ES_ResourceID_t Id; CFE_ES_TaskRecord_t *UtTaskRecPtr; CFE_ES_AppRecord_t *UtAppRecPtr; @@ -1866,7 +1874,7 @@ void TestLibs(void) { CFE_ES_LibRecord_t *UtLibRecPtr; char LongLibraryName[sizeof(UtLibRecPtr->LibName)+1]; - uint32 Id; + CFE_ES_ResourceID_t Id; uint32 j; int32 Return; @@ -1923,7 +1931,8 @@ void TestLibs(void) Return == CFE_ES_LIB_ALREADY_LOADED, "CFE_ES_LoadLibrary", "Duplicate"); - UtAssert_True(Id == CFE_ES_LibRecordGetID(UtLibRecPtr), "CFE_ES_LoadLibrary() returned previous ID"); + UtAssert_True(CFE_ES_ResourceID_Equal(Id, CFE_ES_LibRecordGetID(UtLibRecPtr)), + "CFE_ES_LoadLibrary() returned previous ID"); /* Test shared library loading and initialization where the library * fails to load @@ -1975,7 +1984,8 @@ void TestLibs(void) UtLibRecPtr = CFE_ES_Global.LibTable; for (j = 0; j < CFE_PLATFORM_ES_MAX_LIBRARIES; j++) { - CFE_ES_LibRecordSetUsed(UtLibRecPtr, j); + CFE_ES_LibRecordSetUsed(UtLibRecPtr, + ES_UT_MakeLibIdForIndex(j)); ++UtLibRecPtr; } @@ -3907,8 +3917,8 @@ void TestAPI(void) uint8 Data[12]; uint32 ResetType; uint32 *ResetTypePtr; - uint32 AppId; - uint32 TaskId; + CFE_ES_ResourceID_t AppId; + CFE_ES_ResourceID_t TaskId; uint32 RunStatus; CFE_ES_TaskInfo_t TaskInfo; CFE_ES_AppInfo_t AppInfo; @@ -4183,7 +4193,7 @@ void TestAPI(void) "Get task info by ID; NULL buffer"); /* Test getting task information using the task ID - bad task ID */ - UT_SetForceFail(UT_KEY(OS_ConvertToArrayIndex), OS_ERROR); + UT_SetForceFail(UT_KEY(OS_ObjectIdToArrayIndex), OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_ES_GetTaskInfo(&TaskInfo, TaskId) == CFE_ES_ERR_TASKID, "CFE_ES_GetTaskInfo", @@ -4221,7 +4231,7 @@ void TestAPI(void) /* Test getting task information using the task ID with invalid task ID */ ES_ResetUnitTest(); - TaskId = ES_UT_MakeTaskIdForIndex(99999); + TaskId = CFE_ES_RESOURCEID_UNDEFINED; UT_Report(__FILE__, __LINE__, CFE_ES_GetTaskInfo(&TaskInfo, TaskId) == CFE_ES_ERR_TASKID, "CFE_ES_GetTaskInfo", @@ -4356,7 +4366,7 @@ void TestAPI(void) "Task ID belongs to a main task"); /* Test deleting a child task with an invalid task ID */ - UT_SetForceFail(UT_KEY(OS_ConvertToArrayIndex), OS_ERROR); + UT_SetForceFail(UT_KEY(OS_ObjectIdToArrayIndex), OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_ES_DeleteChildTask(TaskId) == CFE_ES_ERR_TASKID, "CFE_ES_DeleteChildTask", @@ -4396,7 +4406,7 @@ void TestAPI(void) /* Test deleting a child task with the task ID out of range */ ES_ResetUnitTest(); - TaskId = ES_UT_MakeTaskIdForIndex(99999); + TaskId = CFE_ES_RESOURCEID_UNDEFINED; UT_Report(__FILE__, __LINE__, CFE_ES_DeleteChildTask(TaskId) == CFE_ES_ERR_TASKID, "CFE_ES_DeleteChildTask", @@ -4618,7 +4628,7 @@ void TestAPI(void) void TestGenericCounterAPI(void) { char CounterName[11]; - uint32 CounterId; + CFE_ES_ResourceID_t CounterId; uint32 CounterCount; int i; @@ -4676,7 +4686,7 @@ void TestGenericCounterAPI(void) /* Test deleting a registered generic counter that doesn't exist */ UT_Report(__FILE__, __LINE__, - CFE_ES_DeleteGenCounter(123456) == CFE_ES_BAD_ARGUMENT, + CFE_ES_DeleteGenCounter(CFE_ES_RESOURCEID_UNDEFINED) == CFE_ES_BAD_ARGUMENT, "CFE_ES_DeleteGenCounter", "Cannot delete counter that does not exist"); @@ -4696,7 +4706,7 @@ void TestGenericCounterAPI(void) /* Test incrementing a generic counter that doesn't exist */ UT_Report(__FILE__, __LINE__, - CFE_ES_IncrementGenCounter(CFE_PLATFORM_ES_MAX_GEN_COUNTERS) + CFE_ES_IncrementGenCounter(CFE_ES_RESOURCEID_UNDEFINED) == CFE_ES_BAD_ARGUMENT, "CFE_ES_IncrementGenCounter", "Bad counter ID"); @@ -4709,7 +4719,7 @@ void TestGenericCounterAPI(void) /* Test getting a generic counter value for a counter that doesn't exist */ UT_Report(__FILE__, __LINE__, - CFE_ES_GetGenCount(123456, &CounterCount) == CFE_ES_BAD_ARGUMENT, + CFE_ES_GetGenCount(CFE_ES_RESOURCEID_UNDEFINED, &CounterCount) == CFE_ES_BAD_ARGUMENT, "CFE_ES_GetGenCount", "Bad counter ID"); @@ -4722,7 +4732,7 @@ void TestGenericCounterAPI(void) /* Test setting a generic counter value for a counter that doesn't exist */ UT_Report(__FILE__, __LINE__, - CFE_ES_SetGenCount(123456, 5) == CFE_ES_BAD_ARGUMENT, + CFE_ES_SetGenCount(CFE_ES_RESOURCEID_UNDEFINED, 5) == CFE_ES_BAD_ARGUMENT, "CFE_ES_SetGenCount", "Bad counter ID"); diff --git a/fsw/cfe-core/unit-test/evs_UT.c b/fsw/cfe-core/unit-test/evs_UT.c index 5ce7a9623..ea03557de 100644 --- a/fsw/cfe-core/unit-test/evs_UT.c +++ b/fsw/cfe-core/unit-test/evs_UT.c @@ -284,8 +284,6 @@ void Test_Init(void) UT_Text("Begin Test Init\n"); #endif - UT_SetAppID(1); /*jphfix*/ - strncpy((char *) appbitcmd.Payload.AppName, "ut_cfe_evs", sizeof(appbitcmd.Payload.AppName)); @@ -549,7 +547,7 @@ void Test_IllegalAppID(void) UT_Report(__FILE__, __LINE__, CFE_EVS_SendEventWithAppID(0, 0, - 0, + CFE_ES_RESOURCEID_UNDEFINED, "NULL") == CFE_EVS_APP_ILLEGAL_APP_ID, "CFE_EVS_SendEventWithAppID", "Illegal app ID"); @@ -574,7 +572,7 @@ void Test_IllegalAppID(void) UT_InitData(); UT_SetForceFail(UT_KEY(CFE_ES_AppID_ToIndex), CFE_ES_ERR_APPID); UT_Report(__FILE__, __LINE__, - CFE_EVS_CleanUpApp(0) == + CFE_EVS_CleanUpApp(CFE_ES_RESOURCEID_UNDEFINED) == CFE_EVS_APP_ILLEGAL_APP_ID, "CFE_EVS_CleanUpApp", "Illegal app ID"); @@ -588,7 +586,7 @@ void Test_UnregisteredApp(void) { CFE_TIME_SysTime_t time = {0, 0}; EVS_AppData_t *AppDataPtr; - uint32 AppID; + CFE_ES_ResourceID_t AppID; /* Get a local ref to the "current" AppData table entry */ EVS_GetCurrentContext(&AppDataPtr, &AppID); @@ -674,7 +672,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; - uint32 AppID; + CFE_ES_ResourceID_t AppID; CFE_TIME_SysTime_t time = {0, 0}; /* Get a local ref to the "current" AppData table entry */ @@ -808,6 +806,7 @@ void Test_FilterRegistration(void) * application */ UT_InitData(); + AppDataPtr->AppID = AppID; AppDataPtr->ActiveFlag = false; UT_Report(__FILE__, __LINE__, CFE_EVS_SendEventWithAppID(0, @@ -819,6 +818,7 @@ void Test_FilterRegistration(void) /* Test sending a timed event to a registered, filtered application */ UT_InitData(); + AppDataPtr->AppID = AppID; AppDataPtr->ActiveFlag = false; UT_Report(__FILE__, __LINE__, CFE_EVS_SendTimedEvent(time, @@ -917,7 +917,7 @@ void Test_Format(void) .SnapshotSize = sizeof(CapturedMsg) }; EVS_AppData_t *AppDataPtr; - uint32 AppID; + CFE_ES_ResourceID_t AppID; /* Get a local ref to the "current" AppData table entry */ EVS_GetCurrentContext(&AppDataPtr, &AppID); @@ -2677,7 +2677,7 @@ void Test_Misc(void) CFE_EVS_WriteLogDataFile_t writelogdatacmd; } PktBuf; - uint32 AppID; + CFE_ES_ResourceID_t AppID; EVS_AppData_t *AppDataPtr; int i; char msg[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH + 2]; @@ -2733,7 +2733,7 @@ void Test_Misc(void) /* Test successful application cleanup */ UT_InitData(); UT_Report(__FILE__, __LINE__, - CFE_EVS_CleanUpApp(0) == CFE_SUCCESS, + CFE_EVS_CleanUpApp(CFE_ES_RESOURCEID_UNDEFINED) == CFE_SUCCESS, "CFE_EVS_CleanUpApp", "Application cleanup - successful"); @@ -2786,7 +2786,7 @@ void Test_Misc(void) msg[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH] = '\0'; CFE_EVS_GlobalData.EVS_TlmPkt.Payload.MessageTruncCounter = 0; - AppDataPtr->RegisterFlag = true; + EVS_AppDataSetUsed(AppDataPtr, AppID); AppDataPtr->ActiveFlag = true; AppDataPtr->EventTypesActiveFlag |= CFE_EVS_INFORMATION_BIT; diff --git a/fsw/cfe-core/unit-test/sb_UT.c b/fsw/cfe-core/unit-test/sb_UT.c index 1e1901497..9a66e160a 100644 --- a/fsw/cfe-core/unit-test/sb_UT.c +++ b/fsw/cfe-core/unit-test/sb_UT.c @@ -116,10 +116,10 @@ const CFE_SB_MsgId_t SB_UT_BARE_TLM_MID3 = CFE_SB_MSGID_WRAP_VALUE(0x0003); * Helper function to "corrupt" a resource ID value in a consistent/predicatble way, * which can also be un-done easily. */ -uint32 UT_SB_ResourceID_Modify(uint32 InitialID, int32 Modifier) +CFE_ES_ResourceID_t UT_SB_ResourceID_Modify(CFE_ES_ResourceID_t InitialID, int32 Modifier) { - uint32 NewValue = InitialID + Modifier; - return (NewValue); + unsigned long NewValue = CFE_ES_ResourceID_ToInteger(InitialID) + Modifier; + return CFE_ES_ResourceID_FromInteger(NewValue); } /* @@ -1732,7 +1732,7 @@ void Test_DeletePipe_InvalidPipeId(void) void Test_DeletePipe_InvalidPipeOwner(void) { CFE_SB_PipeId_t PipedId; - uint32 RealOwner; + CFE_ES_ResourceID_t RealOwner; uint16 PipeDepth = 10; SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); @@ -1760,7 +1760,7 @@ void Test_DeletePipe_InvalidPipeOwner(void) void Test_DeletePipe_WithAppid(void) { CFE_SB_PipeId_t PipedId; - uint32 AppId = 0; + CFE_ES_ResourceID_t AppId; uint16 PipeDepth = 10; SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); @@ -1768,6 +1768,7 @@ void Test_DeletePipe_WithAppid(void) SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID2, PipedId)); SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID3, PipedId)); SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID4, PipedId)); + SETUP(CFE_ES_GetAppID(&AppId)); ASSERT(CFE_SB_DeletePipeWithAppId(PipedId, AppId)); @@ -1932,14 +1933,14 @@ void Test_SetPipeOpts_NotOwner(void) { CFE_SB_PipeId_t PipeID = 0; uint8 PipeTblIdx = 0; - uint32 OrigOwner = 0; + CFE_ES_ResourceID_t OrigOwner; SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); PipeTblIdx = CFE_SB_GetPipeIdx(PipeID); OrigOwner = CFE_SB.PipeTbl[PipeTblIdx].AppId; - CFE_SB.PipeTbl[PipeTblIdx].AppId = 0xFFFFFFFF; + CFE_SB.PipeTbl[PipeTblIdx].AppId = UT_SB_ResourceID_Modify(OrigOwner, 1); ASSERT_EQ(CFE_SB_SetPipeOpts(PipeID, 0), CFE_SB_BAD_ARGUMENT); CFE_SB.PipeTbl[PipeTblIdx].AppId = OrigOwner; @@ -2401,7 +2402,7 @@ void Test_Subscribe_InvalidPipeOwner(void) CFE_SB_PipeId_t PipeId; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 10; - uint32 RealOwner; + CFE_ES_ResourceID_t RealOwner; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); @@ -2494,7 +2495,7 @@ void Test_Unsubscribe_Local(void) void Test_Unsubscribe_InvalParam(void) { CFE_SB_PipeId_t TestPipe; - uint32 CallerId = 0xFFFFFFFF; + CFE_ES_ResourceID_t CallerId; uint16 PipeDepth = 50; CFE_SB_PipeId_t SavedPipeId; @@ -2588,7 +2589,7 @@ void Test_Unsubscribe_InvalidPipeOwner(void) { CFE_SB_PipeId_t PipeId; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; - uint32 RealOwner; + CFE_ES_ResourceID_t RealOwner; uint16 PipeDepth = 10; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); @@ -3549,9 +3550,8 @@ void Test_CleanupApp_API(void) CFE_SB_PipeId_t PipeId; CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl = 0; uint16 PipeDepth = 50; - uint32 AppID; + CFE_ES_ResourceID_t AppID; - UT_SetAppID(1); CFE_ES_GetAppID(&AppID); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); @@ -3567,7 +3567,7 @@ void Test_CleanupApp_API(void) /* Attempt with a bad application ID first in order to get full branch path * coverage in CFE_SB_ZeroCopyReleaseAppId */ - CFE_SB_CleanUpApp(0); + CFE_SB_CleanUpApp(CFE_ES_RESOURCEID_UNDEFINED); /* Attempt again with a valid application ID */ CFE_SB_CleanUpApp(AppID); @@ -3921,7 +3921,7 @@ void Test_OS_MutSem_ErrLogic(void) */ void Test_ReqToSendEvent_ErrLogic(void) { - uint32 TaskId; + CFE_ES_ResourceID_t TaskId; uint32 Bit = 5; /* Clear task bits, then call function, which should set the bit for @@ -4013,7 +4013,7 @@ void Test_CFE_SB_BadPipeInfo(void) CFE_SB_PipeId_t PipeId; uint16 PipeDepth = 10; CFE_SB_Qos_t CFE_SB_Default_Qos; - uint32 AppID; + CFE_ES_ResourceID_t AppID; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe1")); diff --git a/fsw/cfe-core/unit-test/tbl_UT.c b/fsw/cfe-core/unit-test/tbl_UT.c index a82e8de1a..124f81397 100644 --- a/fsw/cfe-core/unit-test/tbl_UT.c +++ b/fsw/cfe-core/unit-test/tbl_UT.c @@ -55,9 +55,10 @@ CFE_TBL_Handle_t App2TblHandle1; CFE_TBL_Handle_t App2TblHandle2; CFE_TBL_Handle_t ArrayOfHandles[2]; -static const uint32 UT_TBL_APPID_1 = 1; -static const uint32 UT_TBL_APPID_2 = 2; -static const uint32 UT_TBL_APPID_10 = 10; +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 }; void *Tbl1Ptr = NULL; void *Tbl2Ptr = NULL; @@ -1051,7 +1052,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; - uint32 AppID; + CFE_ES_ResourceID_t AppID; /* Get the AppID being used for UT */ CFE_ES_GetAppID(&AppID); @@ -1148,7 +1149,7 @@ void Test_CFE_TBL_DumpRegCmd(void) { int q; CFE_TBL_DumpRegistry_t DumpRegCmd; - uint32 AppID; + CFE_ES_ResourceID_t AppID; /* Get the AppID being used for UT */ CFE_ES_GetAppID(&AppID); @@ -1246,7 +1247,7 @@ void Test_CFE_TBL_DumpCmd(void) uint8 *BuffPtr = &Buff; CFE_TBL_LoadBuff_t Load = {0}; CFE_TBL_Dump_t DumpCmd; - uint32 AppID; + CFE_ES_ResourceID_t AppID; CFE_ES_GetAppID(&AppID); @@ -1426,7 +1427,7 @@ void Test_CFE_TBL_LoadCmd(void) CFE_FS_Header_t StdFileHeader; CFE_TBL_LoadBuff_t BufferPtr = CFE_TBL_TaskData.LoadBuffs[0]; CFE_TBL_Load_t LoadCmd; - uint32 AppID; + CFE_ES_ResourceID_t AppID; CFE_ES_GetAppID(&AppID); @@ -1790,7 +1791,6 @@ void Test_CFE_TBL_HousekeepingCmd(void) */ void Test_CFE_TBL_ApiInit(void) { - UT_SetAppID(1); UT_ResetCDS(); CFE_TBL_EarlyInit(); CFE_TBL_TaskData.TableTaskAppId = UT_TBL_APPID_10; @@ -1840,7 +1840,6 @@ void Test_CFE_TBL_Register(void) } TblName[i] = '\0'; - UT_SetAppID(1); RtnCode = CFE_TBL_Register(&TblHandle1, TblName, sizeof(UT_Table1_t), CFE_TBL_OPT_DEFAULT, NULL); @@ -2018,7 +2017,7 @@ void Test_CFE_TBL_Register(void) /* Test attempt to register table owned by another application */ UT_InitData(); - UT_SetAppID(2); + UT_SetAppID(UT_TBL_APPID_2); RtnCode = CFE_TBL_Register(&TblHandle3, "UT_Table1", sizeof(UT_Table1_t), CFE_TBL_OPT_DBL_BUFFER, NULL); @@ -2031,7 +2030,7 @@ void Test_CFE_TBL_Register(void) /* Test attempt to register existing table with a different size */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Register(&TblHandle3, "UT_Table1", sizeof(UT_Table2_t), CFE_TBL_OPT_DBL_BUFFER, NULL); @@ -2045,7 +2044,7 @@ void Test_CFE_TBL_Register(void) /* Test attempt to register a table with the same size and name */ /* a. Test setup */ UT_InitData(); - UT_SetAppID(2); + UT_SetAppID(UT_TBL_APPID_2); EventsCorrect = (UT_GetNumEventsSent() == 0); RtnCode = CFE_TBL_Share(&TblHandle3, "ut_cfe_tbl.UT_Table1"); UT_Report(__FILE__, __LINE__, @@ -2055,7 +2054,7 @@ void Test_CFE_TBL_Register(void) /* b. Perform test */ UT_InitData(); - UT_SetAppID(1); /* Restore AppID to proper value */ + UT_SetAppID(UT_TBL_APPID_1); /* Restore AppID to proper value */ RtnCode = CFE_TBL_Register(&TblHandle2, "UT_Table1", sizeof(UT_Table1_t), CFE_TBL_OPT_DBL_BUFFER, NULL); @@ -2068,9 +2067,9 @@ void Test_CFE_TBL_Register(void) /* c. Test cleanup: unregister tables */ UT_ClearEventHistory(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Unregister(TblHandle2); - UT_SetAppID(2); + UT_SetAppID(UT_TBL_APPID_2); RtnCode2 = CFE_TBL_Unregister(TblHandle3); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -2082,7 +2081,7 @@ void Test_CFE_TBL_Register(void) /* Test registering a single buffered table */ /* a. Perform test */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Register(&TblHandle1, "UT_Table1", sizeof(UT_Table1_t), CFE_TBL_OPT_DEFAULT, NULL); @@ -2490,7 +2489,7 @@ void Test_CFE_TBL_Register(void) /* Test attempt to register a double buffered table with a pool buffer * error */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); 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); @@ -2540,7 +2539,7 @@ void Test_CFE_TBL_Share(void) /* Test response when table name is not in the registry */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Share(&App1TblHandle1, "ut_cfe_tbl.NOT_Table2"); EventsCorrect = (UT_EventIsInHistory(CFE_TBL_SHARE_ERR_EID) == true && UT_GetNumEventsSent() == 1); @@ -2609,7 +2608,7 @@ void Test_CFE_TBL_Share(void) /* Test successful share of a table that has not been loaded once */ UT_InitData(); - UT_SetAppID(2); + UT_SetAppID(UT_TBL_APPID_2); RtnCode = CFE_TBL_Share(&App2TblHandle1, "ut_cfe_tbl.UT_Table3"); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -2642,7 +2641,7 @@ void Test_CFE_TBL_Unregister(void) /* Test response to unregistering a table with an invalid handle */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Unregister(CFE_PLATFORM_TBL_MAX_NUM_HANDLES); EventsCorrect = (UT_EventIsInHistory(CFE_TBL_UNREGISTER_ERR_EID) == true && UT_GetNumEventsSent() == 1); @@ -2662,13 +2661,13 @@ void Test_CFE_TBL_Unregister(void) /* Test response to unregistering an unowned table */ UT_InitData(); - UT_SetAppID(2); + UT_SetAppID(UT_TBL_APPID_2); RtnCode = CFE_TBL_Unregister(App2TblHandle2); EventsCorrect = - (UT_EventIsInHistory(CFE_TBL_UNREGISTER_ERR_EID) == false && - UT_GetNumEventsSent() == 0); + (UT_EventIsInHistory(CFE_TBL_UNREGISTER_ERR_EID) == true && + UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, - RtnCode == CFE_SUCCESS && EventsCorrect, + RtnCode == CFE_TBL_ERR_NO_ACCESS && EventsCorrect, "CFE_TBL_Unregister", "Unregister unowned table"); } @@ -2688,7 +2687,7 @@ void Test_CFE_TBL_NotifyByMessage(void) /* Set up notify by message tests */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); CFE_TBL_EarlyInit(); UT_ResetPoolBufferIndex(); @@ -2759,7 +2758,7 @@ void Test_CFE_TBL_Load(void) /* Set up for table load test */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); UT_ResetTableRegistry(); RtnCode = CFE_TBL_Register(&App1TblHandle1, "UT_Table1", sizeof(UT_Table1_t), @@ -2858,7 +2857,7 @@ void Test_CFE_TBL_Load(void) /* Set up for double buffer table load test */ /* Test setup - register a double buffered table */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Register(&App1TblHandle2, "UT_Table2x", sizeof(UT_Table1_t), @@ -3038,7 +3037,7 @@ void Test_CFE_TBL_Load(void) /* Test attempt to load a locked shared table */ /* a. Test setup part 1 */ UT_InitData(); - UT_SetAppID(2); + UT_SetAppID(UT_TBL_APPID_2); RtnCode = CFE_TBL_Share(&App2TblHandle1, "ut_cfe_tbl.UT_Table1"); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3047,7 +3046,6 @@ void Test_CFE_TBL_Load(void) "Attempt to load locked shared table (setup part 1)"); /* a. Test setup part 2 */ - UT_InitData(); RtnCode = CFE_TBL_GetAddress((void **) &App2TblPtr, App2TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3057,7 +3055,7 @@ void Test_CFE_TBL_Load(void) /* c. Perform test */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_ADDRESS, &TestTable1); EventsCorrect = (UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, @@ -3067,7 +3065,7 @@ void Test_CFE_TBL_Load(void) /* d. Test cleanup */ UT_InitData(); - UT_SetAppID(2); + UT_SetAppID(UT_TBL_APPID_2); RtnCode = CFE_TBL_ReleaseAddress(App2TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3095,7 +3093,7 @@ void Test_CFE_TBL_GetAddress(void) * does not have access */ UT_InitData(); - UT_SetAppID(3); + UT_SetAppID(UT_TBL_APPID_3); RtnCode = CFE_TBL_GetAddress((void **) &App3TblPtr, App2TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3126,7 +3124,7 @@ void Test_CFE_TBL_GetAddress(void) /* Attempt to get the address of an unregistered (unowned) table */ /* a. Test setup */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Unregister(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3136,7 +3134,7 @@ void Test_CFE_TBL_GetAddress(void) /* b. Perform test */ UT_InitData(); - UT_SetAppID(2); + UT_SetAppID(UT_TBL_APPID_2); RtnCode = CFE_TBL_GetAddress((void **) &App2TblPtr, App2TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3161,7 +3159,7 @@ void Test_CFE_TBL_ReleaseAddress(void) /* Test address release using an invalid application ID */ /* a. Test setup - register single buffered table */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); UT_ResetTableRegistry(); RtnCode = CFE_TBL_Register(&App1TblHandle1, "UT_Table1", sizeof(UT_Table1_t), @@ -3200,7 +3198,7 @@ void Test_CFE_TBL_GetAddresses(void) /* Test setup - register a double buffered table */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Register(&App1TblHandle2, "UT_Table2", sizeof(UT_Table1_t), @@ -3235,7 +3233,7 @@ void Test_CFE_TBL_GetAddresses(void) * allowed to see */ UT_InitData(); - UT_SetAppID(CFE_PLATFORM_ES_MAX_APPLICATIONS); + UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); RtnCode = CFE_TBL_GetAddresses(ArrayOfPtrsToTblPtrs, 2, ArrayOfHandles); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3260,7 +3258,7 @@ void Test_CFE_TBL_ReleaseAddresses(void) /* Test response to releasing two tables that have not been loaded */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_ReleaseAddresses(2, ArrayOfHandles); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3286,7 +3284,7 @@ void Test_CFE_TBL_Validate(void) * not allowed to see */ UT_InitData(); - UT_SetAppID(CFE_PLATFORM_ES_MAX_APPLICATIONS); + UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); RtnCode = CFE_TBL_Validate(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3299,7 +3297,7 @@ void Test_CFE_TBL_Validate(void) * pending */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Validate(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3345,7 +3343,7 @@ void Test_CFE_TBL_Manage(void) RegIndex = CFE_TBL_FindTableInRegistry("ut_cfe_tbl.UT_Table1"); RegRecPtr = &CFE_TBL_TaskData.Registry[RegIndex]; RtnCode = CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, false); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_ADDRESS, &TestTable1); EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_IN_PROGRESS_ERR_EID) == true && UT_GetNumEventsSent() == 1); @@ -3513,7 +3511,7 @@ void Test_CFE_TBL_Manage(void) /* Test response to processing an update request on a locked table */ /* a. Test setup - part 1 */ UT_InitData(); - UT_SetAppID(2); + UT_SetAppID(UT_TBL_APPID_2); RtnCode = CFE_TBL_Share(&App2TblHandle1, "ut_cfe_tbl.UT_Table1"); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3522,7 +3520,6 @@ void Test_CFE_TBL_Manage(void) "Process an update request on a locked table (setup - part 1)"); /* a. Test setup - part 2 */ - UT_InitData(); RtnCode = CFE_TBL_GetAddress((void **) &App2TblPtr, App2TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3532,7 +3529,7 @@ void Test_CFE_TBL_Manage(void) /* c. Perform test */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); /* Configure table for update */ RegRecPtr->LoadPending = true; @@ -3550,7 +3547,7 @@ void Test_CFE_TBL_Manage(void) /* Test unlocking a table by releasing the address */ UT_InitData(); - UT_SetAppID(2); + UT_SetAppID(UT_TBL_APPID_2); RtnCode = CFE_TBL_ReleaseAddress(App2TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3562,7 +3559,7 @@ void Test_CFE_TBL_Manage(void) * buffered table */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); /* Configure table for Update */ RegRecPtr->LoadPending = true; @@ -3750,7 +3747,7 @@ void Test_CFE_TBL_Update(void) * privileges */ UT_InitData(); - UT_SetAppID(2); + UT_SetAppID(UT_TBL_APPID_2); RtnCode = CFE_TBL_Update(App1TblHandle1); EventsCorrect = (UT_EventIsInHistory(CFE_TBL_UPDATE_ERR_EID) == true && UT_GetNumEventsSent() == 1); @@ -3764,7 +3761,7 @@ void Test_CFE_TBL_Update(void) * is pending */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Update(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3776,7 +3773,7 @@ void Test_CFE_TBL_Update(void) /* Test processing an update on an application with a bad ID */ UT_InitData(); - UT_SetAppID(CFE_PLATFORM_ES_MAX_APPLICATIONS); + UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); RtnCode = CFE_TBL_Update(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, @@ -3801,7 +3798,7 @@ void Test_CFE_TBL_GetStatus(void) * application is not allowed to see */ UT_InitData(); - UT_SetAppID(CFE_PLATFORM_ES_MAX_APPLICATIONS); + UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); RtnCode = CFE_TBL_GetStatus(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3814,7 +3811,7 @@ void Test_CFE_TBL_GetStatus(void) * application is not allowed to see */ UT_InitData(); - UT_SetAppID(CFE_PLATFORM_ES_MAX_APPLICATIONS); + UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); RtnCode = CFE_TBL_DumpToBuffer(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3839,7 +3836,7 @@ void Test_CFE_TBL_GetInfo(void) /* Test successfully getting information on a table */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_GetInfo(&TblInfo, "ut_cfe_tbl.UT_Table1"); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3889,7 +3886,7 @@ void Test_CFE_TBL_TblMod(void) */ /* a. Test setup */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); CFE_TBL_EarlyInit(); UT_ResetPoolBufferIndex(); @@ -4082,7 +4079,7 @@ void Test_CFE_TBL_Internal(void) /* Test setup - register a double buffered table */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_Register(&App1TblHandle2, "UT_Table3", sizeof(UT_Table1_t), @@ -4527,7 +4524,7 @@ void Test_CFE_TBL_Internal(void) /* Reset, then register tables for subsequent tests */ /* a. Reset tables */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); RtnCode = CFE_TBL_EarlyInit(); UT_Report(__FILE__, __LINE__, (RtnCode == CFE_SUCCESS), @@ -4860,7 +4857,7 @@ void Test_CFE_TBL_Internal(void) /* a. Share table */ UT_InitData(); CFE_TBL_TaskData.CritReg[0].CDSHandle = RegRecPtr->CDSHandle; - UT_SetAppID(2); + UT_SetAppID(UT_TBL_APPID_2); RtnCode = CFE_TBL_Share(&App2TblHandle1, "ut_cfe_tbl.UT_Table1"); UT_Report(__FILE__, __LINE__, RtnCode == CFE_SUCCESS, @@ -4878,7 +4875,7 @@ void Test_CFE_TBL_Internal(void) /* Test successful application cleanup */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); UT_SetForceFail(UT_KEY(CFE_ES_PutPoolBuf), -1); AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle1]; RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; @@ -4890,7 +4887,7 @@ void Test_CFE_TBL_Internal(void) UT_Report(__FILE__, __LINE__, CFE_TBL_TaskData.DumpControlBlocks[3].State == CFE_TBL_DUMP_FREE && - RegRecPtr->OwnerAppId == CFE_TBL_NOT_OWNED && + CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED) && CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].Taken == false && RegRecPtr->LoadInProgress == CFE_TBL_NO_LOAD_IN_PROGRESS, @@ -5049,7 +5046,7 @@ void Test_CFE_TBL_Internal(void) * the application doesn't own the table */ UT_InitData(); - UT_SetAppID(1); + UT_SetAppID(UT_TBL_APPID_1); UT_SetForceFail(UT_KEY(CFE_ES_PutPoolBuf), -1); CFE_TBL_TaskData.Handles[0].AppId = UT_TBL_APPID_1; AccessDescPtr = &CFE_TBL_TaskData.Handles[App1TblHandle2]; @@ -5061,7 +5058,7 @@ void Test_CFE_TBL_Internal(void) UT_Report(__FILE__, __LINE__, CFE_TBL_TaskData.DumpControlBlocks[3].State == CFE_TBL_DUMP_PENDING && - RegRecPtr->OwnerAppId == CFE_TBL_NOT_OWNED, + CFE_ES_ResourceID_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 6de03f7e2..0c0a094bd 100644 --- a/fsw/cfe-core/unit-test/time_UT.c +++ b/fsw/cfe-core/unit-test/time_UT.c @@ -43,8 +43,6 @@ /* ** External global variables */ -extern uint32 UT_AppID; - const char *TIME_SYSLOG_MSGS[] = { NULL, @@ -1233,6 +1231,7 @@ int32 ut_time_MyCallbackFunc(void) void Test_RegisterSyncCallbackTrue(void) { int32 Result; + uint32 AppIndex; #ifdef UT_VERBOSE UT_Text("Begin Test Register Synch Callback\n"); @@ -1259,8 +1258,6 @@ void Test_RegisterSyncCallbackTrue(void) */ UT_InitData(); - UT_SetAppID(1); - /* * One callback per application is allowed; the first should succeed, * the second should fail. @@ -1278,7 +1275,8 @@ void Test_RegisterSyncCallbackTrue(void) "CFE_TIME_RegisterSynchCallback", "Too Many registered callbacks"); - UT_SetAppID(2); + AppIndex = 2; + UT_SetDataBuffer(UT_KEY(CFE_ES_AppID_ToIndex), &AppIndex, sizeof(AppIndex), false); Result = CFE_TIME_RegisterSynchCallback(&ut_time_MyCallbackFunc); UT_Report(__FILE__, __LINE__, @@ -1291,7 +1289,8 @@ void Test_RegisterSyncCallbackTrue(void) * return "success" with an appid out of range, but nonetheless * we need to make sure we do not overwrite our own memory here. */ - UT_SetAppID(CFE_PLATFORM_ES_MAX_APPLICATIONS); + AppIndex = 99999; + UT_SetDataBuffer(UT_KEY(CFE_ES_AppID_ToIndex), &AppIndex, sizeof(AppIndex), false); Result = CFE_TIME_RegisterSynchCallback(&ut_time_MyCallbackFunc); UT_Report(__FILE__, __LINE__, Result == CFE_TIME_TOO_MANY_SYNCH_CALLBACKS, @@ -3212,6 +3211,7 @@ void Test_UnregisterSynchCallback(void) { uint32 i = 0; int32 Result; + uint32 AppIndex; ut_time_CallbackCalled = 0; @@ -3239,7 +3239,8 @@ void Test_UnregisterSynchCallback(void) } /* App ID 4 should not have a callback */ - UT_SetAppID(4); + AppIndex = 4; + UT_SetDataBuffer(UT_KEY(CFE_ES_AppID_ToIndex), &AppIndex, sizeof(AppIndex), false); Result = CFE_TIME_UnregisterSynchCallback(&ut_time_MyCallbackFunc); UT_Report(__FILE__, __LINE__, @@ -3252,7 +3253,8 @@ void Test_UnregisterSynchCallback(void) * the second should fail. */ /* App ID 2 should have a callback */ - UT_SetAppID(2); + AppIndex = 2; + UT_SetDataBuffer(UT_KEY(CFE_ES_AppID_ToIndex), &AppIndex, sizeof(AppIndex), false); Result = CFE_TIME_UnregisterSynchCallback(&ut_time_MyCallbackFunc); UT_Report(__FILE__, __LINE__, @@ -3260,6 +3262,7 @@ void Test_UnregisterSynchCallback(void) "CFE_TIME_UnregisterSynchCallback", "Successfully unregister callback"); + UT_SetDataBuffer(UT_KEY(CFE_ES_AppID_ToIndex), &AppIndex, sizeof(AppIndex), false); Result = CFE_TIME_UnregisterSynchCallback(&ut_time_MyCallbackFunc); UT_Report(__FILE__, __LINE__, Result == CFE_TIME_CALLBACK_NOT_REGISTERED, @@ -3298,7 +3301,7 @@ void Test_CleanUpApp(void) uint16 Count; int32 Status = CFE_SUCCESS; uint32 AppIndex; - uint32 TestAppId; + CFE_ES_ResourceID_t TestAppId; #ifdef UT_VERBOSE UT_Text("Begin Test Cleanup App\n"); @@ -3374,7 +3377,9 @@ void Test_CleanUpApp(void) /* Test response to a bad application ID - * This is effectively a no-op but here for coverage */ - Status = CFE_TIME_CleanUpApp(99999); + AppIndex = 99999; + UT_SetDataBuffer(UT_KEY(CFE_ES_AppID_ToIndex), &AppIndex, sizeof(AppIndex), false); + Status = CFE_TIME_CleanUpApp(CFE_ES_RESOURCEID_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 7daac8d34..5aa1a3546 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 uint32 UT_AppID; +static CFE_ES_ResourceID_t UT_AppID; static uint32 UT_LastCDSSize = 0; typedef union @@ -170,7 +170,6 @@ void UT_InitData(void) * This should return the UT_appname */ UT_SetDataBuffer(UT_KEY(CFE_ES_GetAppName), (uint8*)UT_appname, sizeof(UT_appname), false); - UT_SetDataBuffer(UT_KEY(CFE_ES_GetAppID), (uint8*)&UT_AppID, sizeof(UT_AppID), false); /* * Reset the OSAL stubs to the default state @@ -274,9 +273,10 @@ int32 UT_SoftwareBusSnapshotHook(void *UserObj, int32 StubRetcode, uint32 CallCo /* ** Set the application ID returned by unit test stubs */ -void UT_SetAppID(int32 AppID_in) +void UT_SetAppID(CFE_ES_ResourceID_t AppID_in) { UT_AppID = AppID_in; + UT_SetDataBuffer(UT_KEY(CFE_ES_GetAppID), (uint8*)&UT_AppID, sizeof(UT_AppID), false); } /* diff --git a/fsw/cfe-core/unit-test/ut_support.h b/fsw/cfe-core/unit-test/ut_support.h index 1ad145001..a9fc7a558 100644 --- a/fsw/cfe-core/unit-test/ut_support.h +++ b/fsw/cfe-core/unit-test/ut_support.h @@ -363,7 +363,7 @@ int32 UT_SoftwareBusSnapshotHook(void *UserObj, int32 StubRetcode, uint32 CallCo ** This function does not return a value. ** ******************************************************************************/ -void UT_SetAppID(int32 AppID_in); +void UT_SetAppID(CFE_ES_ResourceID_t AppID_in); /*****************************************************************************/ /** diff --git a/fsw/cfe-core/ut-stubs/ut_es_stubs.c b/fsw/cfe-core/ut-stubs/ut_es_stubs.c index 226061555..0878441a5 100644 --- a/fsw/cfe-core/ut-stubs/ut_es_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_es_stubs.c @@ -63,20 +63,20 @@ * 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 ((uint32)1) +#define CFE_UT_ES_DEFAULT_APPID ((CFE_ES_ResourceID_t){0x02010001}) /* * 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 ((uint32)1) +#define CFE_UT_ES_DEFAULT_TASKID ((CFE_ES_ResourceID_t){0x02020001}) /* * 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 ((uint32)0xDEADBEEF) +#define CFE_UT_ES_ID_INVALID ((CFE_ES_ResourceID_t){0xDEADBEEF}) /* ** Functions @@ -101,7 +101,7 @@ ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, +int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, uint32 *StackPtr, @@ -144,12 +144,12 @@ int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetAppID(uint32 *AppIdPtr) +int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppID), AppIdPtr); int32 status; - uint32 *IdBuff; + CFE_ES_ResourceID_t *IdBuff; uint32 BuffSize; uint32 Position; @@ -176,12 +176,12 @@ int32 CFE_ES_GetAppID(uint32 *AppIdPtr) return status; } -int32 CFE_ES_GetTaskID(uint32 *TaskIdPtr) +int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetTaskID), TaskIdPtr); int32 status; - uint32 *IdBuff; + CFE_ES_ResourceID_t *IdBuff; uint32 BuffSize; uint32 Position; @@ -229,7 +229,7 @@ int32 CFE_ES_GetTaskID(uint32 *TaskIdPtr) ** Returns either CFE_ES_ERR_APPNAME or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) +int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), AppIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), AppName); @@ -237,7 +237,7 @@ int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) uint32 UserBuffSize; uint32 BuffPosition; const char *NameBuff; - uint32 *IdBuff; + CFE_ES_ResourceID_t *IdBuff; int32 status; status = UT_DEFAULT_IMPL(CFE_ES_GetAppIDByName); @@ -290,7 +290,7 @@ int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) ** Returns CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetAppName(char *AppName, uint32 AppId, uint32 BufferLength) +int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, uint32 BufferLength) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppName), AppName); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetAppName), AppId); @@ -798,7 +798,7 @@ uint32 CFE_ES_CalculateCRC(const void *DataPtr, ** Returns CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId) +int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetTaskInfo), TaskInfo); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetTaskInfo), TaskId); @@ -1112,7 +1112,7 @@ void CFE_ES_ExitChildTask(void) UT_DEFAULT_IMPL(CFE_ES_ExitChildTask); } -int32 CFE_ES_DeleteApp(uint32 AppID) +int32 CFE_ES_DeleteApp(CFE_ES_ResourceID_t AppID) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_DeleteApp), AppID); @@ -1123,7 +1123,7 @@ int32 CFE_ES_DeleteApp(uint32 AppID) return status; } -int32 CFE_ES_DeleteChildTask(uint32 TaskId) +int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_DeleteChildTask), TaskId); @@ -1134,7 +1134,7 @@ int32 CFE_ES_DeleteChildTask(uint32 TaskId) return status; } -int32 CFE_ES_DeleteGenCounter(uint32 CounterId) +int32 CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_DeleteGenCounter), CounterId); @@ -1145,7 +1145,7 @@ int32 CFE_ES_DeleteGenCounter(uint32 CounterId) return status; } -int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId) +int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppInfo), AppInfo); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetAppInfo), AppId); @@ -1157,7 +1157,7 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId) return status; } -int32 CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count) +int32 CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetGenCount), CounterId); UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetGenCount), Count); @@ -1169,7 +1169,7 @@ int32 CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count) return status; } -int32 CFE_ES_GetGenCounterIDByName(uint32 *CounterIdPtr, const char *CounterName) +int32 CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetGenCounterIDByName), CounterIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetGenCounterIDByName), CounterName); @@ -1193,7 +1193,7 @@ int32 CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t H return status; } -int32 CFE_ES_IncrementGenCounter(uint32 CounterId) +int32 CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_IncrementGenCounter), CounterId); @@ -1204,7 +1204,7 @@ int32 CFE_ES_IncrementGenCounter(uint32 CounterId) return status; } -int32 CFE_ES_RegisterGenCounter(uint32 *CounterIdPtr, const char *CounterName) +int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_RegisterGenCounter), CounterIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_ES_RegisterGenCounter), CounterName); @@ -1216,7 +1216,7 @@ int32 CFE_ES_RegisterGenCounter(uint32 *CounterIdPtr, const char *CounterName) return status; } -int32 CFE_ES_ReloadApp(uint32 AppID, const char *AppFileName) +int32 CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_ReloadApp), AppID); UT_Stub_RegisterContext(UT_KEY(CFE_ES_ReloadApp), AppFileName); @@ -1239,7 +1239,7 @@ int32 CFE_ES_ResetCFE(uint32 ResetType) return status; } -int32 CFE_ES_RestartApp(uint32 AppID) +int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_RestartApp), AppID); @@ -1250,7 +1250,7 @@ int32 CFE_ES_RestartApp(uint32 AppID) return status; } -int32 CFE_ES_SetGenCount(uint32 CounterId, uint32 Count) +int32 CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_SetGenCount), CounterId); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_SetGenCount), Count); @@ -1262,14 +1262,14 @@ int32 CFE_ES_SetGenCount(uint32 CounterId, uint32 Count) return status; } -int32 CFE_ES_AppID_ToIndex(uint32 AppID, uint32 *Idx) +int32 CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_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 = AppID & 0xFFFF; + *Idx = CFE_ES_ResourceID_ToInteger(AppID) & 0xFFFF; return_code = UT_DEFAULT_IMPL_RC(CFE_ES_AppID_ToIndex, 1); if (return_code == 1) @@ -1286,14 +1286,14 @@ int32 CFE_ES_AppID_ToIndex(uint32 AppID, uint32 *Idx) return return_code; } -int32 CFE_ES_TaskID_ToIndex(uint32 TaskID, uint32 *Idx) +int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_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 = TaskID & 0xFFFF; + *Idx = CFE_ES_ResourceID_ToInteger(TaskID) & 0xFFFF; return_code = UT_DEFAULT_IMPL_RC(CFE_ES_TaskID_ToIndex, 1); if (return_code == 1) diff --git a/fsw/cfe-core/ut-stubs/ut_evs_stubs.c b/fsw/cfe-core/ut-stubs/ut_evs_stubs.c index 492d6c772..cfff1a4bd 100644 --- a/fsw/cfe-core/ut-stubs/ut_evs_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_evs_stubs.c @@ -240,7 +240,7 @@ int32 CFE_EVS_Register(void *Filters, ******************************************************************************/ int32 CFE_EVS_SendEventWithAppID(uint16 EventID, uint16 EventType, - uint32 AppID, + CFE_ES_ResourceID_t AppID, const char *Spec, ...) { diff --git a/modules/cfe_testcase/src/es_test.c b/modules/cfe_testcase/src/es_test.c index afe13e74e..2a8cb3784 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) { - uint32 AppId; + CFE_ES_ResourceID_t AppId; char AppNameBuf[OS_MAX_API_NAME + 4]; UtAssert_INT32_EQ(CFE_ES_GetAppID(&AppId), CFE_SUCCESS);