diff --git a/cmake/mission_defaults.cmake b/cmake/mission_defaults.cmake index 444a1138e..2f7ee42c1 100644 --- a/cmake/mission_defaults.cmake +++ b/cmake/mission_defaults.cmake @@ -16,6 +16,7 @@ set(MISSION_CORE_MODULES "psp" "msg" "sbr" + "resourceid" ) # The "MISSION_GLOBAL_APPLIST" is a set of apps/libs that will be built diff --git a/fsw/cfe-core/src/es/cfe_es_api.c b/fsw/cfe-core/src/es/cfe_es_api.c index 15a3a8163..01b938368 100644 --- a/fsw/cfe-core/src/es/cfe_es_api.c +++ b/fsw/cfe-core/src/es/cfe_es_api.c @@ -168,7 +168,7 @@ int32 CFE_ES_ResetCFE(uint32 ResetType) /* ** Function: CFE_ES_RestartApp - See API and header file for details */ -int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) +int32 CFE_ES_RestartApp(CFE_ES_AppId_t AppID) { int32 ReturnCode = CFE_SUCCESS; CFE_ES_AppRecord_t *AppRecPtr; @@ -208,7 +208,7 @@ int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID; CFE_ES_WriteToSysLog("CFE_ES_RestartApp: Invalid Application ID received, AppID = %lu\n", - CFE_ES_ResourceID_ToInteger(AppID)); + CFE_RESOURCEID_TO_ULONG(AppID)); } /* end if */ @@ -219,7 +219,7 @@ int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) /* ** Function: CFE_ES_ReloadApp - See API and header file for details */ -int32 CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName) +int32 CFE_ES_ReloadApp(CFE_ES_AppId_t AppID, const char *AppFileName) { int32 ReturnCode = CFE_SUCCESS; os_fstat_t FileStatus; @@ -278,7 +278,7 @@ int32 CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName) /* ** Function: CFE_ES_DeleteApp - See API and header file for details */ -int32 CFE_ES_DeleteApp(CFE_ES_ResourceID_t AppID) +int32 CFE_ES_DeleteApp(CFE_ES_AppId_t AppID) { int32 ReturnCode = CFE_SUCCESS; CFE_ES_AppRecord_t *AppRecPtr = CFE_ES_LocateAppRecordByID(AppID); @@ -691,7 +691,7 @@ int32 CFE_ES_RegisterApp(void) /* ** Function: CFE_ES_GetAppIDByName - See API and header file for details */ -int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) +int32 CFE_ES_GetAppIDByName(CFE_ES_AppId_t *AppIdPtr, const char *AppName) { CFE_ES_AppRecord_t *AppRecPtr; int32 Result; @@ -711,7 +711,7 @@ int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) * in case the does not check the return code. */ Result = CFE_ES_ERR_NAME_NOT_FOUND; - *AppIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *AppIdPtr = CFE_ES_APPID_UNDEFINED; } else { @@ -728,7 +728,7 @@ int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) /* ** Function: CFE_ES_GetLibIDByName - See API and header file for details */ -int32 CFE_ES_GetLibIDByName(CFE_ES_ResourceID_t *LibIdPtr, const char *LibName) +int32 CFE_ES_GetLibIDByName(CFE_ES_LibId_t *LibIdPtr, const char *LibName) { CFE_ES_LibRecord_t *LibRecPtr; int32 Result; @@ -748,7 +748,7 @@ int32 CFE_ES_GetLibIDByName(CFE_ES_ResourceID_t *LibIdPtr, const char *LibName) * in case the does not check the return code. */ Result = CFE_ES_ERR_NAME_NOT_FOUND; - *LibIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *LibIdPtr = CFE_ES_LIBID_UNDEFINED; } else { @@ -764,7 +764,7 @@ int32 CFE_ES_GetLibIDByName(CFE_ES_ResourceID_t *LibIdPtr, const char *LibName) /* ** Function: CFE_ES_GetTaskIDByName - See API and header file for details */ -CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_ResourceID_t *TaskIdPtr, const char *TaskName) +CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName) { osal_id_t OsalId; int32 Status; @@ -780,12 +780,12 @@ CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_ResourceID_t *TaskIdPtr, const char * if (Status == OS_SUCCESS) { Result = CFE_SUCCESS; - *TaskIdPtr = CFE_ES_ResourceID_FromOSAL(OsalId); + *TaskIdPtr = CFE_ES_TaskId_FromOSAL(OsalId); } else { Result = CFE_ES_ERR_NAME_NOT_FOUND; - *TaskIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *TaskIdPtr = CFE_ES_TASKID_UNDEFINED; } return(Result); @@ -795,7 +795,7 @@ CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_ResourceID_t *TaskIdPtr, const char * /* ** Function: CFE_ES_GetAppID - See API and header file for details */ -int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) +int32 CFE_ES_GetAppID(CFE_ES_AppId_t *AppIdPtr) { CFE_ES_AppRecord_t *AppRecPtr; int32 Result; @@ -811,7 +811,7 @@ int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) } else { - *AppIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *AppIdPtr = CFE_ES_APPID_UNDEFINED; Result = CFE_ES_ERR_RESOURCEID_NOT_VALID; } @@ -824,7 +824,7 @@ int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) /* ** Function: CFE_ES_GetTaskID - See API and header file for details */ -int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) +int32 CFE_ES_GetTaskID(CFE_ES_TaskId_t *TaskIdPtr) { int32 Result; CFE_ES_TaskRecord_t *TaskRecPtr; @@ -833,7 +833,7 @@ int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) TaskRecPtr = CFE_ES_GetTaskRecordByContext(); if (TaskRecPtr == NULL) { - *TaskIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *TaskIdPtr = CFE_ES_TASKID_UNDEFINED; Result = CFE_ES_ERR_RESOURCEID_NOT_VALID; } else @@ -848,7 +848,7 @@ int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) /* ** Function: CFE_ES_GetAppName - See API and header file for details */ -int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t BufferLength) +int32 CFE_ES_GetAppName(char *AppName, CFE_ES_AppId_t AppId, size_t BufferLength) { int32 Result; CFE_ES_AppRecord_t *AppRecPtr; @@ -890,7 +890,7 @@ int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t BufferL /* ** Function: CFE_ES_GetLibName - See API and header file for details */ -int32 CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, size_t BufferLength) +int32 CFE_ES_GetLibName(char *LibName, CFE_ES_LibId_t LibId, size_t BufferLength) { int32 Result; CFE_ES_LibRecord_t *LibRecPtr; @@ -932,7 +932,7 @@ int32 CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, size_t BufferL /* ** Function: CFE_ES_GetTaskName - See API and header file for details */ -int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, size_t BufferLength) +int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_TaskId_t TaskId, size_t BufferLength) { int32 Result; osal_id_t OsalId; @@ -942,15 +942,15 @@ int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, size_t Buff return CFE_ES_BAD_ARGUMENT; } - if (!CFE_ES_ResourceID_IsDefined(TaskId)) + if (!CFE_RESOURCEID_TEST_DEFINED(TaskId)) { return CFE_ES_ERR_RESOURCEID_NOT_VALID; } /* - * Query OSAL to get the task ID + * Query OSAL to get the task name */ - OsalId = CFE_ES_ResourceID_ToOSAL(TaskId); + OsalId = CFE_ES_TaskId_ToOSAL(TaskId); Result = OS_GetResourceName(OsalId, TaskName, BufferLength); if (Result != OS_SUCCESS) @@ -965,7 +965,7 @@ int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, size_t Buff /* ** Function: CFE_ES_GetAppInfo - See API and header file for details */ -int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) +int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_AppId_t AppId) { CFE_ES_AppRecord_t *AppRecPtr; CFE_ES_TaskRecord_t *TaskRecPtr; @@ -992,13 +992,13 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) * Log a message if called with an invalid ID. */ CFE_ES_WriteToSysLog("CFE_ES_GetAppInfo: App ID not active: %lu\n", - CFE_ES_ResourceID_ToInteger(AppId)); + CFE_RESOURCEID_TO_ULONG(AppId)); Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; } else { - AppInfo->AppId = AppId; + AppInfo->ResourceId = CFE_RESOURCEID_UNWRAP(AppId); /* make into a generic resource ID */ AppInfo->Type = AppRecPtr->Type; CFE_ES_CopyModuleBasicInfo(&AppRecPtr->StartParams.BasicInfo, AppInfo); @@ -1019,9 +1019,9 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) for (i=0; iAppId, AppId)) + CFE_RESOURCEID_TEST_EQUAL(TaskRecPtr->AppId, AppId)) { - if (CFE_ES_ResourceID_Equal(CFE_ES_TaskRecordGetID(TaskRecPtr), AppInfo->MainTaskId)) + if (CFE_RESOURCEID_TEST_EQUAL(CFE_ES_TaskRecordGetID(TaskRecPtr), AppInfo->MainTaskId)) { /* This is the main task - capture its name and execution count */ AppInfo->ExecutionCounter = TaskRecPtr->ExecutionCounter; @@ -1057,7 +1057,7 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) /* ** Function: CFE_ES_GetLibInfo - See API and header file for details */ -int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_ResourceID_t LibId) +int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_LibId_t LibId) { int32 Status; CFE_ES_LibRecord_t *LibRecPtr; @@ -1082,13 +1082,13 @@ int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_ResourceID_t LibId) * Log a message if called with an invalid ID. */ CFE_ES_SysLogWrite_Unsync("CFE_ES_GetLibInfo: Lib ID not active: %lu\n", - CFE_ES_ResourceID_ToInteger(LibId)); + CFE_RESOURCEID_TO_ULONG(LibId)); Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; } else { - LibInfo->AppId = CFE_ES_LibRecordGetID(LibRecPtr);; + LibInfo->ResourceId = CFE_RESOURCEID_UNWRAP(LibId); /* make into generic ID */ LibInfo->Type = CFE_ES_AppType_LIBRARY; CFE_ES_CopyModuleBasicInfo(&LibRecPtr->BasicInfo, LibInfo); @@ -1115,24 +1115,24 @@ int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_ResourceID_t LibId) /* ** Function: CFE_ES_GetModuleInfo - See API and header file for details */ -int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ES_ResourceID_t ResourceId) +int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ResourceId_t ResourceId) { int32 Status; - switch(CFE_ES_ResourceID_GetBase(ResourceId)) + switch(CFE_ResourceId_GetBase(ResourceId)) { case CFE_ES_APPID_BASE: - Status = CFE_ES_GetAppInfo(ModuleInfo, ResourceId); + Status = CFE_ES_GetAppInfo(ModuleInfo, CFE_ES_APPID_C(ResourceId)); break; case CFE_ES_LIBID_BASE: - Status = CFE_ES_GetLibInfo(ModuleInfo, ResourceId); + Status = CFE_ES_GetLibInfo(ModuleInfo, CFE_ES_LIBID_C(ResourceId)); break; default: /* * Log a message if called with an invalid ID. */ CFE_ES_WriteToSysLog("CFE_ES_GetModuleInfo: Resource ID not valid: %lu\n", - CFE_ES_ResourceID_ToInteger(ResourceId)); + CFE_ResourceId_ToInteger(ResourceId)); Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; break; @@ -1145,7 +1145,7 @@ int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ES_ResourceID_t Res /* ** Function: CFE_ES_GetTaskInfo - See API and header file for details */ -int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId) +int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_TaskId_t TaskId) { CFE_ES_TaskRecord_t *TaskRecPtr; CFE_ES_AppRecord_t *AppRecPtr; @@ -1168,7 +1168,7 @@ int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId /* task ID is bad */ Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; CFE_ES_SysLogWrite_Unsync("CFE_ES_GetTaskInfo: Task ID Not Active: %lu\n", - CFE_ES_ResourceID_ToInteger(TaskId)); + CFE_RESOURCEID_TO_ULONG(TaskId)); } else { @@ -1221,7 +1221,7 @@ int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId /* ** Function: CFE_ES_CreateChildTask - See API and header file for details */ -int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, +int32 CFE_ES_CreateChildTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, CFE_ES_StackPointer_t StackPtr, @@ -1234,9 +1234,8 @@ int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, CFE_ES_AppRecord_t *AppRecPtr; CFE_ES_TaskRecord_t *TaskRecPtr; int32 ReturnCode; - CFE_ES_ResourceID_t TaskId; - CFE_ES_ResourceID_t ChildTaskId; - CFE_ES_ResourceID_t ParentTaskId; + CFE_ES_TaskId_t SelfTaskId; + CFE_ES_TaskId_t LocalChildTaskId; osal_id_t OsalId; /* @@ -1286,9 +1285,8 @@ int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, ** TaskID must be the same as the Parent Task ID. */ OsalId = OS_TaskGetId(); - TaskId = CFE_ES_ResourceID_FromOSAL(OsalId); - ParentTaskId = AppRecPtr->MainTaskId; - if ( CFE_ES_ResourceID_Equal(TaskId, ParentTaskId) ) + SelfTaskId = CFE_ES_TaskId_FromOSAL(OsalId); + if ( CFE_RESOURCEID_TEST_EQUAL(SelfTaskId, AppRecPtr->MainTaskId) ) { /* ** Step 2: Create the new task using the OS API call @@ -1301,16 +1299,16 @@ int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, */ if ( Result == OS_SUCCESS ) { - ChildTaskId = CFE_ES_ResourceID_FromOSAL(OsalId); - TaskRecPtr = CFE_ES_LocateTaskRecordByID(ChildTaskId); + LocalChildTaskId = CFE_ES_TaskId_FromOSAL(OsalId); + TaskRecPtr = CFE_ES_LocateTaskRecordByID(LocalChildTaskId); - CFE_ES_TaskRecordSetUsed(TaskRecPtr, ChildTaskId); + CFE_ES_TaskRecordSetUsed(TaskRecPtr, CFE_RESOURCEID_UNWRAP(LocalChildTaskId)); TaskRecPtr->AppId = CFE_ES_AppRecordGetID(AppRecPtr); strncpy(TaskRecPtr->TaskName,TaskName,sizeof(TaskRecPtr->TaskName) - 1); TaskRecPtr->TaskName[sizeof(TaskRecPtr->TaskName) - 1] = '\0'; CFE_ES_Global.RegisteredTasks++; - *TaskIdPtr = ChildTaskId; + *TaskIdPtr = CFE_ES_TaskRecordGetID(TaskRecPtr); ReturnCode = CFE_SUCCESS; } else @@ -1382,7 +1380,7 @@ int32 CFE_ES_RegisterChildTask(void) void CFE_ES_IncrementTaskCounter(void) { CFE_ES_TaskRecord_t *TaskRecPtr; - CFE_ES_ResourceID_t TaskID; + CFE_ES_TaskId_t TaskID; /* * Note this locates a task record but intentionally does _not_ @@ -1395,7 +1393,7 @@ void CFE_ES_IncrementTaskCounter(void) * Because the global data is not locked, only minimal validation * is performed. */ - TaskID = CFE_ES_ResourceID_FromOSAL(OS_TaskGetId()); + TaskID = CFE_ES_TaskId_FromOSAL(OS_TaskGetId()); TaskRecPtr = CFE_ES_LocateTaskRecordByID(TaskID); if (TaskRecPtr != NULL) { @@ -1409,7 +1407,7 @@ void CFE_ES_IncrementTaskCounter(void) /* ** Function: CFE_ES_DeleteChildTask - See API and header file for details */ -int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) +int32 CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId) { CFE_ES_TaskRecord_t *TaskRecPtr; CFE_ES_AppRecord_t *AppRecPtr; @@ -1442,7 +1440,7 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) { if ( CFE_ES_AppRecordIsUsed(AppRecPtr) ) { - if ( CFE_ES_ResourceID_Equal(AppRecPtr->MainTaskId, TaskId) ) + if ( CFE_RESOURCEID_TEST_EQUAL(AppRecPtr->MainTaskId, TaskId) ) { /* ** Error, the task Id is an App Main Task ID @@ -1459,7 +1457,7 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) /* ** Can delete the Task */ - OsalId = CFE_ES_ResourceID_ToOSAL(TaskId); + OsalId = CFE_ES_TaskId_ToOSAL(TaskId); OSReturnCode = OS_TaskDelete(OsalId); if ( OSReturnCode == OS_SUCCESS ) { @@ -1473,13 +1471,13 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) ** Report the task delete */ CFE_ES_SysLogWrite_Unsync("CFE_ES_DeleteChildTask Task %lu Deleted\n", - CFE_ES_ResourceID_ToInteger(TaskId)); + CFE_RESOURCEID_TO_ULONG(TaskId)); ReturnCode = CFE_SUCCESS; } else { CFE_ES_SysLogWrite_Unsync("CFE_ES_DeleteChildTask Error: Error Calling OS_TaskDelete: Task %lu, RC = 0x%08X\n", - CFE_ES_ResourceID_ToInteger(TaskId), (unsigned int)OSReturnCode); + CFE_RESOURCEID_TO_ULONG(TaskId), (unsigned int)OSReturnCode); ReturnCode = CFE_ES_ERR_CHILD_TASK_DELETE; } } @@ -1489,7 +1487,7 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) ** Error: The task is a cFE Application Main task */ CFE_ES_SysLogWrite_Unsync("CFE_ES_DeleteChildTask Error: Task %lu is a cFE Main Task.\n", - CFE_ES_ResourceID_ToInteger(TaskId)); + CFE_RESOURCEID_TO_ULONG(TaskId)); ReturnCode = CFE_ES_ERR_CHILD_TASK_DELETE_MAIN_TASK; } /* end if TaskMain == false */ } @@ -1499,7 +1497,7 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) ** Task ID is not in use, so it is invalid */ CFE_ES_SysLogWrite_Unsync("CFE_ES_DeleteChildTask Error: Task ID is not active: %lu\n", - CFE_ES_ResourceID_ToInteger(TaskId)); + CFE_RESOURCEID_TO_ULONG(TaskId)); ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID; } /* end if */ @@ -1513,7 +1511,7 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) ** Task ID is invalid ( too large ) */ CFE_ES_WriteToSysLog("CFE_ES_DeleteChildTask Error: Invalid Task ID: %lu\n", - CFE_ES_ResourceID_ToInteger(TaskId)); + CFE_RESOURCEID_TO_ULONG(TaskId)); ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID; } @@ -1568,7 +1566,7 @@ void CFE_ES_ExitChildTask(void) else { CFE_ES_SysLogWrite_Unsync("CFE_ES_ExitChildTask Error: Cannot Call from a cFE App Main Task. ID = %lu\n", - CFE_ES_ResourceID_ToInteger(CFE_ES_TaskRecordGetID(TaskRecPtr))); + CFE_RESOURCEID_TO_ULONG(CFE_ES_TaskRecordGetID(TaskRecPtr))); } } else @@ -1704,13 +1702,13 @@ int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, size_t BlockSize, con { int32 Status; size_t NameLen; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; char AppName[OS_MAX_API_NAME] = {"UNKNOWN"}; char CDSName[CFE_MISSION_ES_CDS_MAX_FULL_NAME_LEN] = {""}; /* Initialize output to safe value, in case this fails */ - *CDSHandlePtr = CFE_ES_RESOURCEID_UNDEFINED; + *CDSHandlePtr = CFE_ES_CDS_BAD_HANDLE; /* Check to make sure calling application is legit */ Status = CFE_ES_GetAppID(&ThisAppId); @@ -1780,7 +1778,7 @@ int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, size_t BlockSize, con * Purpose: Obtain CDS Block ID from name * See full API description in header file */ -CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_ResourceID_t *BlockIdPtr, const char *BlockName) +CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_CDSHandle_t *BlockIdPtr, const char *BlockName) { CFE_Status_t Status; CFE_ES_CDS_RegRec_t *RegRecPtr; @@ -1805,7 +1803,7 @@ CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_ResourceID_t *BlockIdPtr, const c } else { - *BlockIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *BlockIdPtr = CFE_ES_CDS_BAD_HANDLE; Status = CFE_ES_ERR_NAME_NOT_FOUND; } @@ -1820,7 +1818,7 @@ CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_ResourceID_t *BlockIdPtr, const c * Purpose: Obtain CDS Block Name from ID * See full API description in header file */ -CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_ResourceID_t BlockId, size_t BufferLength) +CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_CDSHandle_t BlockId, size_t BufferLength) { CFE_Status_t Status; CFE_ES_CDS_RegRec_t *RegRecPtr; @@ -1882,10 +1880,10 @@ int32 CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle) ** ** Purpose: Allocates a generic counter resource and assigns ID */ -int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName) +int32 CFE_ES_RegisterGenCounter(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName) { CFE_ES_GenCounterRecord_t *CountRecPtr; - CFE_ES_ResourceID_t PendingCounterId; + CFE_ResourceId_t PendingResourceId; int32 Status; if (CounterName == NULL || CounterIdPtr == NULL) @@ -1909,13 +1907,13 @@ int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *C { CFE_ES_SysLogWrite_Unsync("ES Startup: Duplicate Counter name '%s'\n", CounterName); Status = CFE_ES_ERR_DUPLICATE_NAME; - PendingCounterId = CFE_ES_RESOURCEID_UNDEFINED; + PendingResourceId = CFE_RESOURCEID_UNDEFINED; } else { /* scan for a free slot */ - PendingCounterId = CFE_ES_FindNextAvailableId(CFE_ES_Global.LastCounterId, CFE_PLATFORM_ES_MAX_GEN_COUNTERS, CFE_ES_CheckCounterIdSlotUsed); - CountRecPtr = CFE_ES_LocateCounterRecordByID(PendingCounterId); + PendingResourceId = CFE_ResourceId_FindNext(CFE_ES_Global.LastCounterId, CFE_PLATFORM_ES_MAX_GEN_COUNTERS, CFE_ES_CheckCounterIdSlotUsed); + CountRecPtr = CFE_ES_LocateCounterRecordByID(CFE_ES_COUNTERID_C(PendingResourceId)); if (CountRecPtr == NULL) { @@ -1928,15 +1926,15 @@ int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *C sizeof(CountRecPtr->CounterName) - 1); CountRecPtr->CounterName[sizeof(CountRecPtr->CounterName) - 1] = '\0'; CountRecPtr->Counter = 0; - CFE_ES_CounterRecordSetUsed(CountRecPtr, PendingCounterId); - CFE_ES_Global.LastCounterId = PendingCounterId; + CFE_ES_CounterRecordSetUsed(CountRecPtr, PendingResourceId); + CFE_ES_Global.LastCounterId = PendingResourceId; Status = CFE_SUCCESS; } } CFE_ES_UnlockSharedData(__func__,__LINE__); - *CounterIdPtr = PendingCounterId; + *CounterIdPtr = CFE_ES_COUNTERID_C(PendingResourceId); return Status; } @@ -1947,7 +1945,7 @@ int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *C ** Purpose: Delete a Generic Counter. ** */ -int32 CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId) +int32 CFE_ES_DeleteGenCounter(CFE_ES_CounterId_t CounterId) { CFE_ES_GenCounterRecord_t *CountRecPtr; int32 Status = CFE_ES_BAD_ARGUMENT; @@ -1975,7 +1973,7 @@ int32 CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId) ** Purpose: Increment a Generic Counter. ** */ -int32 CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId) +int32 CFE_ES_IncrementGenCounter(CFE_ES_CounterId_t CounterId) { int32 Status = CFE_ES_BAD_ARGUMENT; CFE_ES_GenCounterRecord_t *CountRecPtr; @@ -1996,7 +1994,7 @@ int32 CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId) ** Purpose: Sets a Generic Counter's count. ** */ -int32 CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count) +int32 CFE_ES_SetGenCount(CFE_ES_CounterId_t CounterId, uint32 Count) { int32 Status = CFE_ES_BAD_ARGUMENT; CFE_ES_GenCounterRecord_t *CountRecPtr; @@ -2016,7 +2014,7 @@ int32 CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count) ** Purpose: Gets the value of a Generic Counter. ** */ -int32 CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count) +int32 CFE_ES_GetGenCount(CFE_ES_CounterId_t CounterId, uint32 *Count) { int32 Status = CFE_ES_BAD_ARGUMENT; CFE_ES_GenCounterRecord_t *CountRecPtr; @@ -2031,7 +2029,7 @@ int32 CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count) return Status; } /* End of CFE_ES_GetGenCount() */ -int32 CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName) +int32 CFE_ES_GetGenCounterIDByName(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName) { CFE_ES_GenCounterRecord_t *CounterRecPtr; int32 Result; @@ -2054,7 +2052,7 @@ int32 CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char * in case the does not check the return code. */ Result = CFE_ES_ERR_NAME_NOT_FOUND; - *CounterIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *CounterIdPtr = CFE_ES_COUNTERID_UNDEFINED; } else { @@ -2074,7 +2072,7 @@ int32 CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char * Purpose: Obtain Counter Name from ID * See full API description in header file */ -CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_ResourceID_t CounterId, size_t BufferLength) +CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_CounterId_t CounterId, size_t BufferLength) { CFE_ES_GenCounterRecord_t *CountRecPtr; CFE_Status_t Status; @@ -2109,10 +2107,10 @@ CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_ResourceID_t Cou * A conversion function to obtain an index value correlating to an AppID * This is a zero based value that can be used for indexing into a table. */ -int32 CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx) +int32 CFE_ES_AppID_ToIndex(CFE_ES_AppId_t AppID, uint32 *Idx) { - return CFE_ES_ResourceID_ToIndex( - CFE_ES_ResourceID_ToInteger(AppID) - CFE_ES_APPID_BASE, + return CFE_ResourceId_ToIndex(CFE_RESOURCEID_UNWRAP(AppID), + CFE_ES_APPID_BASE, CFE_PLATFORM_ES_MAX_APPLICATIONS, Idx); } @@ -2121,10 +2119,10 @@ int32 CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx) * A conversion function to obtain an index value correlating to a LibID * This is a zero based value that can be used for indexing into a table. */ -int32 CFE_ES_LibID_ToIndex(CFE_ES_ResourceID_t LibId, uint32 *Idx) +int32 CFE_ES_LibID_ToIndex(CFE_ES_LibId_t LibId, uint32 *Idx) { - return CFE_ES_ResourceID_ToIndex( - CFE_ES_ResourceID_ToInteger(LibId) - CFE_ES_LIBID_BASE, + return CFE_ResourceId_ToIndex(CFE_RESOURCEID_UNWRAP(LibId), + CFE_ES_LIBID_BASE, CFE_PLATFORM_ES_MAX_LIBRARIES, Idx); } @@ -2136,17 +2134,17 @@ int32 CFE_ES_LibID_ToIndex(CFE_ES_ResourceID_t LibId, uint32 *Idx) * Task IDs come from OSAL, so this is currently a wrapper around the OSAL converter. * This is an alias for consistency with the ES AppID paradigm. */ -int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx) +int32 CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx) { osal_id_t OsalID; osal_index_t OsalIndex; - if (!CFE_ES_ResourceID_IsDefined(TaskID)) + if (!CFE_RESOURCEID_TEST_DEFINED(TaskID)) { return CFE_ES_ERR_RESOURCEID_NOT_VALID; } - OsalID = CFE_ES_ResourceID_ToOSAL(TaskID); + OsalID = CFE_ES_TaskId_ToOSAL(TaskID); if (OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, OsalID, &OsalIndex) != OS_SUCCESS) { return CFE_ES_ERR_RESOURCEID_NOT_VALID; @@ -2161,11 +2159,11 @@ int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx) * A conversion function to obtain an index value correlating to a CounterID * This is a zero based value that can be used for indexing into a table. */ -int32 CFE_ES_CounterID_ToIndex(CFE_ES_ResourceID_t CounterId, uint32 *Idx) +int32 CFE_ES_CounterID_ToIndex(CFE_ES_CounterId_t CounterId, uint32 *Idx) { - return CFE_ES_ResourceID_ToIndex( - CFE_ES_ResourceID_ToInteger(CounterId) - CFE_ES_COUNTID_BASE, - CFE_PLATFORM_ES_MAX_GEN_COUNTERS, + return CFE_ResourceId_ToIndex(CFE_RESOURCEID_UNWRAP(CounterId), + CFE_ES_COUNTID_BASE, + CFE_PLATFORM_ES_MAX_GEN_COUNTERS, Idx); } diff --git a/fsw/cfe-core/src/es/cfe_es_apps.c b/fsw/cfe-core/src/es/cfe_es_apps.c index 0e63864e1..b6de900e8 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.c +++ b/fsw/cfe-core/src/es/cfe_es_apps.c @@ -270,7 +270,11 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) unsigned long PriorityIn; unsigned long StackSizeIn; unsigned long ExceptionActionIn; - CFE_ES_ResourceID_t ApplicationId; + union + { + CFE_ES_AppId_t AppId; + CFE_ES_LibId_t LibId; + } IdBuf; int32 CreateStatus = CFE_ES_ERR_APP_CREATE; /* @@ -333,7 +337,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) /* ** Now create the application */ - CreateStatus = CFE_ES_AppCreate(&ApplicationId, FileName, + CreateStatus = CFE_ES_AppCreate(&IdBuf.AppId, FileName, EntryPoint, AppName, PriorityIn, StackSizeIn, @@ -346,7 +350,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) /* ** Now load the library */ - CreateStatus = CFE_ES_LoadLibrary(&ApplicationId, FileName, + CreateStatus = CFE_ES_LoadLibrary(&IdBuf.LibId, FileName, EntryPoint, AppName); } @@ -369,7 +373,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) ** **------------------------------------------------------------------------------------- */ -int32 CFE_ES_LoadModule(CFE_ES_ResourceID_t ResourceId, const CFE_ES_ModuleLoadParams_t* LoadParams, CFE_ES_ModuleLoadStatus_t *LoadStatus) +int32 CFE_ES_LoadModule(CFE_ResourceId_t ResourceId, const CFE_ES_ModuleLoadParams_t* LoadParams, CFE_ES_ModuleLoadStatus_t *LoadStatus) { osal_id_t ModuleId; cpuaddr StartAddr; @@ -383,7 +387,7 @@ int32 CFE_ES_LoadModule(CFE_ES_ResourceID_t ResourceId, const CFE_ES_ModuleLoadP if (LoadParams->FileName[0] != 0) { - switch(CFE_ES_ResourceID_GetBase(ResourceId)) + switch(CFE_ResourceId_GetBase(ResourceId)) { case CFE_ES_APPID_BASE: /* @@ -552,11 +556,11 @@ void CFE_ES_AppEntryPoint(void) ** **------------------------------------------------------------------------------------- */ -int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_ResourceID_t RefAppId, CFE_ES_ResourceID_t *TaskIdPtr) +int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_AppId_t RefAppId, CFE_ES_TaskId_t *TaskIdPtr) { CFE_ES_TaskRecord_t *TaskRecPtr; osal_id_t OsalTaskId; - CFE_ES_ResourceID_t TaskId; + CFE_ES_TaskId_t LocalTaskId; int32 StatusCode; int32 ReturnCode; @@ -580,8 +584,8 @@ int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_Res * The entry is not (yet) matching the task ID - it will be * initialized here. */ - TaskId = CFE_ES_ResourceID_FromOSAL(OsalTaskId); - TaskRecPtr = CFE_ES_LocateTaskRecordByID(TaskId); + LocalTaskId = CFE_ES_TaskId_FromOSAL(OsalTaskId); + TaskRecPtr = CFE_ES_LocateTaskRecordByID(LocalTaskId); if ( CFE_ES_TaskRecordIsUsed(TaskRecPtr) ) { CFE_ES_SysLogWrite_Unsync("ES Startup: Error: ES_TaskTable slot for ID %lx in use at task creation!\n", @@ -597,21 +601,21 @@ int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_Res TaskRecPtr->AppId = RefAppId; strncpy(TaskRecPtr->TaskName, StartParams->BasicInfo.Name, sizeof(TaskRecPtr->TaskName)-1); TaskRecPtr->TaskName[sizeof(TaskRecPtr->TaskName)-1] = 0; - CFE_ES_TaskRecordSetUsed(TaskRecPtr, TaskId); + CFE_ES_TaskRecordSetUsed(TaskRecPtr, CFE_RESOURCEID_UNWRAP(LocalTaskId)); /* ** Increment the registered Task count. */ CFE_ES_Global.RegisteredTasks++; ReturnCode = CFE_SUCCESS; - *TaskIdPtr = TaskId; + *TaskIdPtr = CFE_ES_TaskRecordGetID(TaskRecPtr); } else { CFE_ES_SysLogWrite_Unsync("ES Startup: AppCreate Error: TaskCreate %s Failed. EC = 0x%08X!\n", StartParams->BasicInfo.Name,(unsigned int)StatusCode); ReturnCode = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; - *TaskIdPtr = CFE_ES_RESOURCEID_UNDEFINED; + *TaskIdPtr = CFE_ES_TASKID_UNDEFINED; } CFE_ES_UnlockSharedData(__func__,__LINE__); @@ -630,7 +634,7 @@ int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_Res ** **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, +int32 CFE_ES_AppCreate(CFE_ES_AppId_t *ApplicationIdPtr, const char *FileName, const char *EntryPointName, const char *AppName, @@ -638,10 +642,10 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, size_t StackSize, CFE_ES_ExceptionAction_Enum_t ExceptionAction) { - CFE_Status_t Status; - CFE_ES_ResourceID_t MainTaskId; + CFE_Status_t Status; + CFE_ES_TaskId_t MainTaskId; CFE_ES_AppRecord_t *AppRecPtr; - CFE_ES_ResourceID_t PendingAppId; + CFE_ResourceId_t PendingResourceId; /* * The FileName must not be NULL @@ -688,8 +692,8 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, else { /* scan for a free slot */ - PendingAppId = CFE_ES_FindNextAvailableId(CFE_ES_Global.LastAppId, CFE_PLATFORM_ES_MAX_APPLICATIONS, CFE_ES_CheckAppIdSlotUsed); - AppRecPtr = CFE_ES_LocateAppRecordByID(PendingAppId); + PendingResourceId = CFE_ResourceId_FindNext(CFE_ES_Global.LastAppId, CFE_PLATFORM_ES_MAX_APPLICATIONS, CFE_ES_CheckAppIdSlotUsed); + AppRecPtr = CFE_ES_LocateAppRecordByID(CFE_ES_APPID_C(PendingResourceId)); if (AppRecPtr == NULL) { @@ -729,8 +733,8 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, AppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_RUN; AppRecPtr->ControlReq.AppTimerMsec = 0; - CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_ES_RESOURCEID_RESERVED); - CFE_ES_Global.LastAppId = PendingAppId; + CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_RESOURCEID_RESERVED); + CFE_ES_Global.LastAppId = PendingResourceId; Status = CFE_SUCCESS; } } @@ -749,18 +753,18 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, /* * Load the module based on StartParams configured above. */ - Status = CFE_ES_LoadModule(PendingAppId, &AppRecPtr->StartParams.BasicInfo, &AppRecPtr->ModuleInfo); + Status = CFE_ES_LoadModule(PendingResourceId, &AppRecPtr->StartParams.BasicInfo, &AppRecPtr->ModuleInfo); /* * If the Load was OK, then complete the initialization */ if (Status == CFE_SUCCESS) { - Status = CFE_ES_StartAppTask(&AppRecPtr->StartParams, PendingAppId, &MainTaskId); + Status = CFE_ES_StartAppTask(&AppRecPtr->StartParams, CFE_ES_APPID_C(PendingResourceId), &MainTaskId); } else { - MainTaskId = CFE_ES_RESOURCEID_UNDEFINED; + MainTaskId = CFE_ES_TASKID_UNDEFINED; } /* @@ -776,7 +780,7 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, * which turns this into a real/valid table entry */ AppRecPtr->MainTaskId = MainTaskId; - CFE_ES_AppRecordSetUsed(AppRecPtr, PendingAppId); + CFE_ES_AppRecordSetUsed(AppRecPtr, PendingResourceId); /* ** Increment the registered App counter. @@ -789,12 +793,12 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, * Set the table entry back to free */ CFE_ES_AppRecordSetFree(AppRecPtr); - PendingAppId = CFE_ES_RESOURCEID_UNDEFINED; + PendingResourceId = CFE_RESOURCEID_UNDEFINED; } CFE_ES_UnlockSharedData(__func__,__LINE__); - *ApplicationIdPtr = PendingAppId; + *ApplicationIdPtr = CFE_ES_APPID_C(PendingResourceId); return Status; @@ -808,7 +812,7 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, ** **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, +int32 CFE_ES_LoadLibrary(CFE_ES_LibId_t *LibraryIdPtr, const char *FileName, const char *EntryPointName, const char *LibName) @@ -816,7 +820,7 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, CFE_ES_LibraryEntryFuncPtr_t FunctionPointer; CFE_ES_LibRecord_t * LibSlotPtr; int32 Status; - CFE_ES_ResourceID_t PendingLibId; + CFE_ResourceId_t PendingResourceId; /* * The FileName must not be NULL @@ -835,7 +839,7 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, ** Allocate an ES_LibTable entry */ FunctionPointer = NULL; - PendingLibId = CFE_ES_RESOURCEID_UNDEFINED; + PendingResourceId = CFE_RESOURCEID_UNDEFINED; /* ** Find an ES AppTable entry, and set to RESERVED @@ -862,15 +866,15 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, CFE_ES_SysLogWrite_Unsync("ES Startup: Duplicate Lib name '%s'\n", LibName); if (LibSlotPtr != NULL) { - PendingLibId = CFE_ES_LibRecordGetID(LibSlotPtr); + PendingResourceId = CFE_RESOURCEID_UNWRAP(CFE_ES_LibRecordGetID(LibSlotPtr)); } Status = CFE_ES_ERR_DUPLICATE_NAME; } else { /* scan for a free slot */ - PendingLibId = CFE_ES_FindNextAvailableId(CFE_ES_Global.LastLibId, CFE_PLATFORM_ES_MAX_LIBRARIES, CFE_ES_CheckLibIdSlotUsed); - LibSlotPtr = CFE_ES_LocateLibRecordByID(PendingLibId); + PendingResourceId = CFE_ResourceId_FindNext(CFE_ES_Global.LastLibId, CFE_PLATFORM_ES_MAX_LIBRARIES, CFE_ES_CheckLibIdSlotUsed); + LibSlotPtr = CFE_ES_LocateLibRecordByID(CFE_ES_LIBID_C(PendingResourceId)); if (LibSlotPtr == NULL) { @@ -898,8 +902,8 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, LibSlotPtr->BasicInfo.EntryPoint[sizeof(LibSlotPtr->BasicInfo.EntryPoint)-1] = '\0'; } - CFE_ES_LibRecordSetUsed(LibSlotPtr, CFE_ES_RESOURCEID_RESERVED); - CFE_ES_Global.LastLibId = PendingLibId; + CFE_ES_LibRecordSetUsed(LibSlotPtr, CFE_RESOURCEID_RESERVED); + CFE_ES_Global.LastLibId = PendingResourceId; Status = CFE_SUCCESS; } } @@ -912,20 +916,20 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, */ if (Status != CFE_SUCCESS) { - *LibraryIdPtr = PendingLibId; + *LibraryIdPtr = CFE_ES_LIBID_C(PendingResourceId); return Status; } /* * Load the module based on StartParams configured above. */ - Status = CFE_ES_LoadModule(PendingLibId, &LibSlotPtr->BasicInfo, &LibSlotPtr->ModuleInfo); + Status = CFE_ES_LoadModule(PendingResourceId, &LibSlotPtr->BasicInfo, &LibSlotPtr->ModuleInfo); if (Status == CFE_SUCCESS) { FunctionPointer = (CFE_ES_LibraryEntryFuncPtr_t)LibSlotPtr->ModuleInfo.EntryAddress; if (FunctionPointer != NULL) { - Status = (*FunctionPointer)(PendingLibId); + Status = (*FunctionPointer)(CFE_ES_LIBID_C(PendingResourceId)); if (Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("ES Startup: Load Shared Library Init Error = 0x%08x\n", @@ -947,7 +951,7 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, * important - set the ID to its proper value * which turns this into a real/valid table entry */ - CFE_ES_LibRecordSetUsed(LibSlotPtr, PendingLibId); + CFE_ES_LibRecordSetUsed(LibSlotPtr, PendingResourceId); /* * Increment the registered Lib counter. @@ -957,12 +961,12 @@ int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, else { CFE_ES_LibRecordSetFree(LibSlotPtr); - PendingLibId = CFE_ES_RESOURCEID_UNDEFINED; + PendingResourceId = CFE_RESOURCEID_UNDEFINED; } CFE_ES_UnlockSharedData(__func__,__LINE__); - *LibraryIdPtr = PendingLibId; + *LibraryIdPtr = CFE_ES_LIBID_C(PendingResourceId); return(Status); @@ -982,7 +986,7 @@ bool CFE_ES_RunAppTableScan(uint32 ElapsedTime, void *Arg) CFE_ES_AppTableScanState_t *State = (CFE_ES_AppTableScanState_t *)Arg; uint32 i; CFE_ES_AppRecord_t *AppPtr; - CFE_ES_ResourceID_t AppTimeoutList[CFE_PLATFORM_ES_MAX_APPLICATIONS]; + CFE_ES_AppId_t AppTimeoutList[CFE_PLATFORM_ES_MAX_APPLICATIONS]; uint32 NumAppTimeouts; if (State->PendingAppStateChanges == 0) @@ -1104,14 +1108,14 @@ bool CFE_ES_RunAppTableScan(uint32 ElapsedTime, void *Arg) ** Purpose: This function will perform the requested control action for an application. **--------------------------------------------------------------------------------------- */ -void CFE_ES_ProcessControlRequest(CFE_ES_ResourceID_t AppId) +void CFE_ES_ProcessControlRequest(CFE_ES_AppId_t AppId) { CFE_ES_AppRecord_t *AppRecPtr; uint32 PendingControlReq; CFE_ES_AppStartParams_t OrigStartParams; CFE_Status_t CleanupStatus; CFE_Status_t StartupStatus; - CFE_ES_ResourceID_t NewAppId; + CFE_ES_AppId_t NewAppId; const char *ReqName; char MessageDetail[48]; uint16 EventID; @@ -1124,7 +1128,7 @@ void CFE_ES_ProcessControlRequest(CFE_ES_ResourceID_t AppId) EventType = 0; StartupStatus = CFE_SUCCESS; PendingControlReq = 0; - NewAppId = CFE_ES_RESOURCEID_UNDEFINED; + NewAppId = CFE_ES_APPID_UNDEFINED; AppRecPtr = CFE_ES_LocateAppRecordByID(AppId); memset(&OrigStartParams, 0, sizeof(OrigStartParams)); @@ -1309,12 +1313,12 @@ void CFE_ES_ProcessControlRequest(CFE_ES_ResourceID_t AppId) snprintf(MessageDetail, sizeof(MessageDetail), "Failed: CleanUpApp Error 0x%08X.",(unsigned int)CleanupStatus); } - else if (CFE_ES_ResourceID_IsDefined(NewAppId)) + else if (CFE_RESOURCEID_TEST_DEFINED(NewAppId)) { /* Record success message for event where app is restarted */ EventType = CFE_EVS_EventType_INFORMATION; snprintf(MessageDetail, sizeof(MessageDetail), "Completed, AppID=%lu", - CFE_ES_ResourceID_ToInteger(NewAppId)); + CFE_RESOURCEID_TO_ULONG(NewAppId)); } else { @@ -1336,12 +1340,12 @@ void CFE_ES_ProcessControlRequest(CFE_ES_ResourceID_t AppId) ** Purpose: Delete an application by cleaning up all of it's resources. **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_ES_CleanUpApp(CFE_ES_AppId_t AppId) { uint32 i; int32 Status; int32 ReturnCode; - CFE_ES_ResourceID_t TaskList[OS_MAX_TASKS]; + CFE_ES_TaskId_t TaskList[OS_MAX_TASKS]; CFE_ES_MemHandle_t PoolList[CFE_PLATFORM_ES_MAX_MEMORY_POOLS]; osal_id_t ModuleId; uint32 NumTasks; @@ -1385,12 +1389,12 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) for ( i = 0; i < OS_MAX_TASKS; i++ ) { if ( CFE_ES_TaskRecordIsUsed(TaskRecPtr) && - CFE_ES_ResourceID_Equal(TaskRecPtr->AppId, AppId)) + CFE_RESOURCEID_TEST_EQUAL(TaskRecPtr->AppId, AppId)) { TaskList[NumTasks] = CFE_ES_TaskRecordGetID(TaskRecPtr); /* Store the main task ID at index 0 (swap with whatever was there) */ - if (CFE_ES_ResourceID_Equal(TaskList[NumTasks], AppRecPtr->MainTaskId) && + if (CFE_RESOURCEID_TEST_EQUAL(TaskList[NumTasks], AppRecPtr->MainTaskId) && NumTasks != 0) { TaskList[NumTasks] = TaskList[0]; @@ -1398,7 +1402,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) } /* Mark record for removal */ - CFE_ES_TaskRecordSetUsed(TaskRecPtr, CFE_ES_RESOURCEID_RESERVED); + CFE_ES_TaskRecordSetUsed(TaskRecPtr, CFE_RESOURCEID_RESERVED); ++NumTasks; } @@ -1414,7 +1418,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) for ( i = 0; i < CFE_PLATFORM_ES_MAX_MEMORY_POOLS; i++ ) { if ( CFE_ES_MemPoolRecordIsUsed(MemPoolRecPtr) && - CFE_ES_ResourceID_Equal(MemPoolRecPtr->OwnerAppID, AppId)) + CFE_RESOURCEID_TEST_EQUAL(MemPoolRecPtr->OwnerAppID, AppId)) { PoolList[NumPools] = CFE_ES_MemPoolRecordGetID(MemPoolRecPtr); ++NumPools; @@ -1429,14 +1433,14 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) * This prevents reallocation of this slot while the remainder * of resources are freed. */ - CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_ES_RESOURCEID_RESERVED); + CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_RESOURCEID_RESERVED); ReturnCode = CFE_SUCCESS; } else { CFE_ES_SysLogWrite_Unsync("CFE_ES_CleanUpApp: AppID %lu is not valid for deletion\n", - CFE_ES_ResourceID_ToInteger(AppId)); + CFE_RESOURCEID_TO_ULONG(AppId)); ReturnCode = CFE_ES_APP_CLEANUP_ERR; } @@ -1497,7 +1501,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) if ( Status != CFE_SUCCESS ) { CFE_ES_WriteToSysLog("CFE_ES_CleanUpApp: CleanUpTaskResources for Task ID:%lu returned Error: 0x%08X\n", - CFE_ES_ResourceID_ToInteger(TaskList[i]), (unsigned int)Status); + CFE_RESOURCEID_TO_ULONG(TaskList[i]), (unsigned int)Status); ReturnCode = CFE_ES_APP_CLEANUP_ERR; } } @@ -1511,7 +1515,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) if ( Status != CFE_SUCCESS ) { CFE_ES_WriteToSysLog("CFE_ES_MemPoolCleanupApp: delete pool %lu returned Error: 0x%08X\n", - CFE_ES_ResourceID_ToInteger(PoolList[i]), (unsigned int)Status); + CFE_RESOURCEID_TO_ULONG(PoolList[i]), (unsigned int)Status); ReturnCode = CFE_ES_APP_CLEANUP_ERR; } } @@ -1547,10 +1551,10 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) * If not, display a log message about it - this indicates table corruption or a * bug with the record keeping. */ - if (NumTasks == 0 || !CFE_ES_ResourceID_Equal(TaskList[0], AppRecPtr->MainTaskId)) + if (NumTasks == 0 || !CFE_RESOURCEID_TEST_EQUAL(TaskList[0], AppRecPtr->MainTaskId)) { CFE_ES_SysLogWrite_Unsync("CFE_ES_CleanUpApp: MainTask ID:%lu not found when deleting AppID %lu\n", - CFE_ES_ResourceID_ToInteger(AppRecPtr->MainTaskId), CFE_ES_ResourceID_ToInteger(AppId)); + CFE_RESOURCEID_TO_ULONG(AppRecPtr->MainTaskId), CFE_RESOURCEID_TO_ULONG(AppId)); ReturnCode = CFE_ES_APP_CLEANUP_ERR; } #endif @@ -1561,7 +1565,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) for (i=0; i < NumTasks; ++i) { TaskRecPtr = CFE_ES_LocateTaskRecordByID(TaskList[i]); - if (CFE_ES_TaskRecordIsMatch(TaskRecPtr, CFE_ES_RESOURCEID_RESERVED)) + if (CFE_ES_TaskRecordIsMatch(TaskRecPtr, CFE_ES_TASKID_C(CFE_RESOURCEID_RESERVED))) { CFE_ES_TaskRecordSetFree(TaskRecPtr); } @@ -1570,7 +1574,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId) /* * Now finally delete the record and allow re-use of the slot. */ - if (CFE_ES_AppRecordIsMatch(AppRecPtr, CFE_ES_RESOURCEID_RESERVED)) + if (CFE_ES_AppRecordIsMatch(AppRecPtr, CFE_ES_APPID_C(CFE_RESOURCEID_RESERVED))) { CFE_ES_AppRecordSetFree(AppRecPtr); } @@ -1705,14 +1709,14 @@ void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg) ** any ES global data structures. It should only clean up at the OSAL level. **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_CleanupTaskResources(CFE_ES_ResourceID_t TaskId) +int32 CFE_ES_CleanupTaskResources(CFE_ES_TaskId_t TaskId) { CFE_ES_CleanupState_t CleanState; int32 Result; osal_id_t OsalId; /* Get the Task ID for calling OSAL APIs (convert type) */ - OsalId = CFE_ES_ResourceID_ToOSAL(TaskId); + OsalId = CFE_ES_TaskId_ToOSAL(TaskId); /* ** Delete all OSAL resources that belong to this task @@ -1844,5 +1848,3 @@ void CFE_ES_CopyModuleAddressInfo(osal_id_t ModuleId, CFE_ES_AppInfo_t *AppInfoP AppInfoPtr->BSSAddress = CFE_ES_MEMADDRESS_C(ModuleInfo.addr.bss_address); AppInfoPtr->BSSSize = CFE_ES_MEMOFFSET_C(ModuleInfo.addr.bss_size); } - - diff --git a/fsw/cfe-core/src/es/cfe_es_apps.h b/fsw/cfe-core/src/es/cfe_es_apps.h index 82b307e02..c03a5c2c2 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.h +++ b/fsw/cfe-core/src/es/cfe_es_apps.h @@ -129,13 +129,13 @@ typedef struct */ typedef struct { - CFE_ES_ResourceID_t AppId; /* The actual AppID of this entry, or undefined */ + CFE_ES_AppId_t AppId; /* The actual AppID of this entry, or undefined */ CFE_ES_AppState_Enum_t AppState; /* Is the app running, or stopped, or waiting? */ CFE_ES_AppType_Enum_t Type; /* The type of App: CORE or EXTERNAL */ CFE_ES_AppStartParams_t StartParams; /* The start parameters for an App */ CFE_ES_ModuleLoadStatus_t ModuleInfo; /* Runtime module information */ CFE_ES_ControlReq_t ControlReq; /* The Control Request Record for External cFE Apps */ - CFE_ES_ResourceID_t MainTaskId; /* The Application's Main Task ID */ + CFE_ES_TaskId_t MainTaskId; /* The Application's Main Task ID */ } CFE_ES_AppRecord_t; @@ -146,8 +146,8 @@ typedef struct */ typedef struct { - CFE_ES_ResourceID_t TaskId; /* The actual TaskID of this entry, or undefined */ - CFE_ES_ResourceID_t AppId; /* The parent Application's App ID */ + CFE_ES_TaskId_t TaskId; /* The actual TaskID of this entry, or undefined */ + CFE_ES_AppId_t AppId; /* The parent Application's App ID */ uint32 ExecutionCounter; /* The execution counter for the Child task */ char TaskName[OS_MAX_API_NAME]; /* Task Name */ @@ -160,7 +160,7 @@ typedef struct */ typedef struct { - CFE_ES_ResourceID_t LibId; /* The actual LibID of this entry, or undefined */ + CFE_ES_LibId_t LibId; /* The actual LibID of this entry, or undefined */ CFE_ES_ModuleLoadParams_t BasicInfo; /* Basic (static) information about the module */ CFE_ES_ModuleLoadStatus_t ModuleInfo; /* Runtime information about the module */ } CFE_ES_LibRecord_t; @@ -198,7 +198,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens); ** This only loads the code and looks up relevent runtime information. ** It does not start any tasks. */ -int32 CFE_ES_LoadModule(CFE_ES_ResourceID_t ResourceId, const CFE_ES_ModuleLoadParams_t* LoadParams, CFE_ES_ModuleLoadStatus_t *LoadStatus); +int32 CFE_ES_LoadModule(CFE_ResourceId_t ResourceId, const CFE_ES_ModuleLoadParams_t* LoadParams, CFE_ES_ModuleLoadStatus_t *LoadStatus); /* ** Internal function to determine the entry point of an app. @@ -217,13 +217,13 @@ void CFE_ES_AppEntryPoint(void); /* ** Internal function to start the main task of an app. */ -int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_ResourceID_t RefAppId, CFE_ES_ResourceID_t *TaskIdPtr); +int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_AppId_t RefAppId, CFE_ES_TaskId_t *TaskIdPtr); /* ** Internal function to create/start a new cFE app ** based on the parameters passed in */ -int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, +int32 CFE_ES_AppCreate(CFE_ES_AppId_t *ApplicationIdPtr, const char *FileName, const char *EntryPointName, const char *AppName, @@ -233,7 +233,7 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr, /* ** Internal function to load a a new cFE shared Library */ -int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr, +int32 CFE_ES_LoadLibrary(CFE_ES_LibId_t *LibraryIdPtr, const char *FileName, const char *EntryPointName, const char *LibName); @@ -267,17 +267,17 @@ bool CFE_ES_RunERLogDump(uint32 ElapsedTime, void *Arg); /* ** Perform the requested control action for an application */ -void CFE_ES_ProcessControlRequest(CFE_ES_ResourceID_t AppId); +void CFE_ES_ProcessControlRequest(CFE_ES_AppId_t AppId); /* ** Clean up all app resources and delete it */ -int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId); +int32 CFE_ES_CleanUpApp(CFE_ES_AppId_t AppId); /* ** Clean up all Task resources and detete the task */ -int32 CFE_ES_CleanupTaskResources(CFE_ES_ResourceID_t TaskId); +int32 CFE_ES_CleanupTaskResources(CFE_ES_TaskId_t TaskId); /* diff --git a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c b/fsw/cfe-core/src/es/cfe_es_backgroundtask.c index db2254b4c..e72be0a28 100644 --- a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c +++ b/fsw/cfe-core/src/es/cfe_es_backgroundtask.c @@ -232,7 +232,7 @@ void CFE_ES_BackgroundCleanup(void) CFE_ES_DeleteChildTask(CFE_ES_Global.BackgroundTask.TaskID); OS_BinSemDelete(CFE_ES_Global.BackgroundTask.WorkSem); - CFE_ES_Global.BackgroundTask.TaskID = CFE_ES_RESOURCEID_UNDEFINED; + CFE_ES_Global.BackgroundTask.TaskID = CFE_ES_TASKID_UNDEFINED; CFE_ES_Global.BackgroundTask.WorkSem = OS_OBJECT_ID_UNDEFINED; } diff --git a/fsw/cfe-core/src/es/cfe_es_cds.c b/fsw/cfe-core/src/es/cfe_es_cds.c index 2c6ff0248..4efd36cd8 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds.c +++ b/fsw/cfe-core/src/es/cfe_es_cds.c @@ -76,7 +76,7 @@ int32 CFE_ES_CDS_EarlyInit(void) return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } - CDS->LastCDSBlockId = CFE_ES_ResourceID_FromInteger(CFE_ES_CDSBLOCKID_BASE); + CDS->LastCDSBlockId = CFE_ResourceId_FromInteger(CFE_ES_CDSBLOCKID_BASE); /* Get CDS size from PSP. Note that the PSP interface * uses "uint32" for size here. */ @@ -161,24 +161,24 @@ int32 CFE_ES_CDS_EarlyInit(void) * NOTE: For complete prolog information, see 'cfe_es_cds.h' */ /*******************************************************************/ -int32 CFE_ES_CDSBlockID_ToIndex(CFE_ES_ResourceID_t BlockID, uint32 *Idx) +int32 CFE_ES_CDSHandle_ToIndex(CFE_ES_CDSHandle_t BlockID, uint32 *Idx) { - return CFE_ES_ResourceID_ToIndex( - CFE_ES_ResourceID_ToInteger(BlockID) - CFE_ES_CDSBLOCKID_BASE, + return CFE_ResourceId_ToIndex(CFE_RESOURCEID_UNWRAP(BlockID), + CFE_ES_CDSBLOCKID_BASE, CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES, Idx); } /*--------------------------------------------------------------------------------------- - * Function: CFE_ES_CheckCDSBlockIdSlotUsed + * Function: CFE_ES_CheckCDSHandleSlotUsed * * Purpose: Helper function, Aids in allocating a new ID by checking if * a given ID is available. Must be called while locked. *--------------------------------------------------------------------------------------- */ -bool CFE_ES_CheckCDSBlockIdSlotUsed(CFE_ES_ResourceID_t CheckId) +bool CFE_ES_CheckCDSHandleSlotUsed(CFE_ResourceId_t CheckId) { - return CFE_ES_CDSBlockRecordIsUsed(CFE_ES_LocateCDSBlockRecordByID(CheckId)); + return CFE_ES_CDSBlockRecordIsUsed(CFE_ES_LocateCDSBlockRecordByID(CFE_ES_CDSHANDLE_C(CheckId))); } /*******************************************************************/ @@ -188,13 +188,13 @@ bool CFE_ES_CheckCDSBlockIdSlotUsed(CFE_ES_ResourceID_t CheckId) * NOTE: For complete prolog information, see 'cfe_es_cds.h' */ /*******************************************************************/ -CFE_ES_CDS_RegRec_t* CFE_ES_LocateCDSBlockRecordByID(CFE_ES_ResourceID_t BlockID) +CFE_ES_CDS_RegRec_t* CFE_ES_LocateCDSBlockRecordByID(CFE_ES_CDSHandle_t BlockID) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; CFE_ES_CDS_RegRec_t *CDSRegRecPtr; uint32 Idx; - if (CFE_ES_CDSBlockID_ToIndex(BlockID, &Idx) == CFE_SUCCESS) + if (CFE_ES_CDSHandle_ToIndex(BlockID, &Idx) == CFE_SUCCESS) { CDSRegRecPtr = &CDS->Registry[Idx]; } @@ -327,7 +327,7 @@ int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, size_t BlockOffset; size_t OldBlockSize; size_t NewBlockSize; - CFE_ES_ResourceID_t PendingBlockId; + CFE_ResourceId_t PendingBlockId; bool IsNewEntry; bool IsNewOffset; @@ -354,13 +354,13 @@ int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, { /* in CDS a duplicate name is not necessarily an error, we * may reuse/resize the existing entry */ - PendingBlockId = CFE_ES_CDSBlockRecordGetID(RegRecPtr); + PendingBlockId = CFE_RESOURCEID_UNWRAP(CFE_ES_CDSBlockRecordGetID(RegRecPtr)); } else { /* scan for a free slot */ - PendingBlockId = CFE_ES_FindNextAvailableId(CDS->LastCDSBlockId, CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES, CFE_ES_CheckCDSBlockIdSlotUsed); - RegRecPtr = CFE_ES_LocateCDSBlockRecordByID(PendingBlockId); + PendingBlockId = CFE_ResourceId_FindNext(CDS->LastCDSBlockId, CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES, CFE_ES_CheckCDSHandleSlotUsed); + RegRecPtr = CFE_ES_LocateCDSBlockRecordByID(CFE_ES_CDSHANDLE_C(PendingBlockId)); if (RegRecPtr != NULL) { @@ -373,7 +373,7 @@ int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, else { Status = CFE_ES_NO_RESOURCE_IDS_AVAILABLE; - PendingBlockId = CFE_ES_RESOURCEID_UNDEFINED; + PendingBlockId = CFE_RESOURCEID_UNDEFINED; } } @@ -466,7 +466,7 @@ int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, Status = CFE_ES_CDS_ALREADY_EXISTS; } - *HandlePtr = PendingBlockId; + *HandlePtr = CFE_ES_CDSHANDLE_C(PendingBlockId); return (Status); @@ -677,7 +677,7 @@ int32 CFE_ES_UpdateCDSRegistry(void) ** NOTE: For complete prolog information, see 'cfe_es_cds.h' ********************************************************************/ -void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_ResourceID_t ThisAppId) +void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_AppId_t ThisAppId) { char AppName[OS_MAX_API_NAME]; @@ -854,7 +854,7 @@ int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices) int32 Status; CFE_ES_CDS_RegRec_t *RegRecPtr; char OwnerName[OS_MAX_API_NAME]; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; uint32 i; char LogMessage[CFE_ES_MAX_SYSLOG_MSG_SIZE]; size_t OldBlockSize; diff --git a/fsw/cfe-core/src/es/cfe_es_cds.h b/fsw/cfe-core/src/es/cfe_es_cds.h index e0564a4be..f1cfc26eb 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds.h +++ b/fsw/cfe-core/src/es/cfe_es_cds.h @@ -115,7 +115,7 @@ typedef struct * which has a CRC, and therefore the actual user data size is * less than this. */ - CFE_ES_ResourceID_t BlockID; /**< Abstract ID associated with this CDS block */ + CFE_ES_CDSHandle_t BlockID; /**< Abstract ID associated with this CDS block */ size_t BlockOffset; /**< Start offset of the block in CDS memory */ size_t BlockSize; /**< Size, in bytes, of the CDS memory block */ char Name[CFE_MISSION_ES_CDS_MAX_FULL_NAME_LEN]; @@ -173,7 +173,7 @@ typedef struct osal_id_t GenMutex; /**< \brief Mutex that controls access to CDS and registry */ size_t TotalSize; /**< \brief Total size of the CDS as reported by BSP */ size_t DataSize; /**< \brief Size of actual user data pool */ - CFE_ES_ResourceID_t LastCDSBlockId; /**< \brief Last issued CDS block ID */ + CFE_ResourceId_t LastCDSBlockId; /**< \brief Last issued CDS block ID */ CFE_ES_CDS_RegRec_t Registry[CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES]; /**< \brief CDS Registry (Local Copy) */ } CFE_ES_CDS_Instance_t; @@ -280,7 +280,7 @@ int32 CFE_ES_CDS_CachePreload(CFE_ES_CDS_AccessCache_t *Cache, const void *Sourc * @returns #CFE_SUCCESS if conversion successful. @copydoc CFE_SUCCESS * #CFE_ES_ERR_RESOURCEID_NOT_VALID if block ID is outside valid range */ -int32 CFE_ES_CDSBlockID_ToIndex(CFE_ES_ResourceID_t BlockID, uint32 *Idx); +int32 CFE_ES_CDSHandle_ToIndex(CFE_ES_CDSHandle_t BlockID, uint32 *Idx); /** * @brief Get a registry record within the CDS, given a block ID/handle @@ -295,7 +295,7 @@ int32 CFE_ES_CDSBlockID_ToIndex(CFE_ES_ResourceID_t BlockID, uint32 *Idx); * @param[in] BlockID the ID/handle of the CDS block to retrieve * @returns Pointer to registry record, or NULL if ID/handle invalid. */ -CFE_ES_CDS_RegRec_t* CFE_ES_LocateCDSBlockRecordByID(CFE_ES_ResourceID_t BlockID); +CFE_ES_CDS_RegRec_t* CFE_ES_LocateCDSBlockRecordByID(CFE_ES_CDSHandle_t BlockID); /** * @brief Check if a Memory Pool record is in use or free/empty @@ -310,7 +310,7 @@ CFE_ES_CDS_RegRec_t* CFE_ES_LocateCDSBlockRecordByID(CFE_ES_ResourceID_t BlockID */ static inline bool CFE_ES_CDSBlockRecordIsUsed(const CFE_ES_CDS_RegRec_t *CDSBlockRecPtr) { - return CFE_ES_ResourceID_IsDefined(CDSBlockRecPtr->BlockID); + return CFE_RESOURCEID_TEST_DEFINED(CDSBlockRecPtr->BlockID); } /** @@ -321,7 +321,7 @@ static inline bool CFE_ES_CDSBlockRecordIsUsed(const CFE_ES_CDS_RegRec_t *CDSBlo * @param[in] CDSBlockRecPtr pointer to Pool table entry * @returns BlockID of entry */ -static inline CFE_ES_ResourceID_t CFE_ES_CDSBlockRecordGetID(const CFE_ES_CDS_RegRec_t *CDSBlockRecPtr) +static inline CFE_ES_CDSHandle_t CFE_ES_CDSBlockRecordGetID(const CFE_ES_CDS_RegRec_t *CDSBlockRecPtr) { return (CDSBlockRecPtr->BlockID); } @@ -335,9 +335,9 @@ static inline CFE_ES_ResourceID_t CFE_ES_CDSBlockRecordGetID(const CFE_ES_CDS_Re * @param[in] CDSBlockRecPtr pointer to Pool table entry * @param[in] BlockID the Pool ID of this entry */ -static inline void CFE_ES_CDSBlockRecordSetUsed(CFE_ES_CDS_RegRec_t *CDSBlockRecPtr, CFE_ES_ResourceID_t BlockID) +static inline void CFE_ES_CDSBlockRecordSetUsed(CFE_ES_CDS_RegRec_t *CDSBlockRecPtr, CFE_ResourceId_t PendingId) { - CDSBlockRecPtr->BlockID = BlockID; + CDSBlockRecPtr->BlockID = CFE_ES_CDSHANDLE_C(PendingId); } /** @@ -350,7 +350,7 @@ static inline void CFE_ES_CDSBlockRecordSetUsed(CFE_ES_CDS_RegRec_t *CDSBlockRec */ static inline void CFE_ES_CDSBlockRecordSetFree(CFE_ES_CDS_RegRec_t *CDSBlockRecPtr) { - CDSBlockRecPtr->BlockID = CFE_ES_RESOURCEID_UNDEFINED; + CDSBlockRecPtr->BlockID = CFE_ES_CDS_BAD_HANDLE; } /** @@ -366,9 +366,9 @@ static inline void CFE_ES_CDSBlockRecordSetFree(CFE_ES_CDS_RegRec_t *CDSBlockRec * @param[in] BlockID expected block ID * @returns true if the entry matches the given block ID */ -static inline bool CFE_ES_CDSBlockRecordIsMatch(const CFE_ES_CDS_RegRec_t *CDSBlockRecPtr, CFE_ES_ResourceID_t BlockID) +static inline bool CFE_ES_CDSBlockRecordIsMatch(const CFE_ES_CDS_RegRec_t *CDSBlockRecPtr, CFE_ES_CDSHandle_t BlockID) { - return (CDSBlockRecPtr != NULL && CFE_ES_ResourceID_Equal(CDSBlockRecPtr->BlockID, BlockID)); + return (CDSBlockRecPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(CDSBlockRecPtr->BlockID, BlockID)); } /** @@ -396,7 +396,7 @@ static inline size_t CFE_ES_CDSBlockRecordGetUserSize(const CFE_ES_CDS_RegRec_t * * Checks if a table slot is available for a potential new ID * This is a helper function intended to be used with - * CFE_ES_FindNextAvailableID() for allocating new IDs + * CFE_ResourceId_FindNext() for allocating new IDs * * As this dereferences fields within the record, global data must be * locked prior to invoking this function. @@ -404,7 +404,7 @@ static inline size_t CFE_ES_CDSBlockRecordGetUserSize(const CFE_ES_CDS_RegRec_t * @param[in] CheckId pending/candidate Block ID to check * @returns true if the table slot for the ID is occupied, false if available */ -bool CFE_ES_CheckCDSBlockIdSlotUsed(CFE_ES_ResourceID_t CheckId); +bool CFE_ES_CheckCDSHandleSlotUsed(CFE_ResourceId_t CheckId); /*****************************************************************************/ /** @@ -519,7 +519,7 @@ int32 CFE_ES_UpdateCDSRegistry(void); ** ** ******************************************************************************/ -void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_ResourceID_t ThisAppId); +void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_AppId_t ThisAppId); /*****************************************************************************/ /** diff --git a/fsw/cfe-core/src/es/cfe_es_erlog.c b/fsw/cfe-core/src/es/cfe_es_erlog.c index 4a49a8b38..f132d918b 100644 --- a/fsw/cfe-core/src/es/cfe_es_erlog.c +++ b/fsw/cfe-core/src/es/cfe_es_erlog.c @@ -63,7 +63,7 @@ */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int32 CFE_ES_WriteToERLogWithContext( CFE_ES_LogEntryType_Enum_t EntryType, uint32 ResetType, uint32 ResetSubtype, - const char *Description, CFE_ES_ResourceID_t AppId, uint32 PspContextId) + const char *Description, CFE_ES_AppId_t AppId, uint32 PspContextId) { uint32 LogIdx; CFE_ES_ERLog_MetaData_t *EntryPtr; @@ -176,7 +176,7 @@ int32 CFE_ES_WriteToERLog( CFE_ES_LogEntryType_Enum_t EntryType, uint32 Reset { /* passing 0xFFFFFFFF as the appid avoids confusion with actual appid 0 */ return CFE_ES_WriteToERLogWithContext(EntryType, ResetType, ResetSubtype, - Description, CFE_ES_RESOURCEID_UNDEFINED, CFE_ES_ERLOG_NO_CONTEXT); + Description, CFE_ES_APPID_UNDEFINED, CFE_ES_ERLOG_NO_CONTEXT); } /* End of CFE_ES_WriteToERLog() */ @@ -359,7 +359,7 @@ bool CFE_ES_RunExceptionScan(uint32 ElapsedTime, void *Arg) */ if (OS_ObjectIdDefined(ExceptionTaskID)) { - Status = CFE_ES_GetTaskInfo( &EsTaskInfo, CFE_ES_ResourceID_FromOSAL(ExceptionTaskID) ); + Status = CFE_ES_GetTaskInfo( &EsTaskInfo, CFE_ES_TaskId_FromOSAL(ExceptionTaskID) ); /* * The App ID was found, now see if the ExceptionAction is set for a reset diff --git a/fsw/cfe-core/src/es/cfe_es_global.h b/fsw/cfe-core/src/es/cfe_es_global.h index 2e12654f7..0965ef9ea 100644 --- a/fsw/cfe-core/src/es/cfe_es_global.h +++ b/fsw/cfe-core/src/es/cfe_es_global.h @@ -65,7 +65,7 @@ */ typedef struct { - CFE_ES_ResourceID_t CounterId; /**< The actual counter ID of this entry, or undefined */ + CFE_ES_CounterId_t CounterId; /**< The actual counter ID of this entry, or undefined */ uint32 Counter; char CounterName[OS_MAX_API_NAME]; /* Counter Name */ } CFE_ES_GenCounterRecord_t; @@ -75,7 +75,7 @@ typedef struct */ typedef struct { - CFE_ES_ResourceID_t TaskID; /**< ES ID of the background task */ + CFE_ES_TaskId_t TaskID; /**< ES ID of the background task */ osal_id_t WorkSem; /**< Semaphore that is given whenever background work is pending */ uint32 NumJobsRunning; /**< Current Number of active jobs (updated by background task) */ } CFE_ES_BackgroundTaskState_t; @@ -119,20 +119,20 @@ typedef struct */ uint32 RegisteredCoreApps; uint32 RegisteredExternalApps; - CFE_ES_ResourceID_t LastAppId; + CFE_ResourceId_t LastAppId; CFE_ES_AppRecord_t AppTable[CFE_PLATFORM_ES_MAX_APPLICATIONS]; /* ** ES Shared Library Table */ uint32 RegisteredLibs; - CFE_ES_ResourceID_t LastLibId; + CFE_ResourceId_t LastLibId; CFE_ES_LibRecord_t LibTable[CFE_PLATFORM_ES_MAX_LIBRARIES]; /* ** ES Generic Counters Table */ - CFE_ES_ResourceID_t LastCounterId; + CFE_ResourceId_t LastCounterId; CFE_ES_GenCounterRecord_t CounterTable[CFE_PLATFORM_ES_MAX_GEN_COUNTERS]; /* @@ -150,7 +150,7 @@ typedef struct /* ** Memory Pools */ - CFE_ES_ResourceID_t LastMemPoolId; + CFE_ResourceId_t LastMemPoolId; CFE_ES_MemPoolRecord_t MemPoolTable[CFE_PLATFORM_ES_MAX_MEMORY_POOLS]; } CFE_ES_Global_t; diff --git a/fsw/cfe-core/src/es/cfe_es_log.h b/fsw/cfe-core/src/es/cfe_es_log.h index ebf02d67c..e52ae1c0a 100644 --- a/fsw/cfe-core/src/es/cfe_es_log.h +++ b/fsw/cfe-core/src/es/cfe_es_log.h @@ -366,6 +366,6 @@ int32 CFE_ES_WriteToERLog( CFE_ES_LogEntryType_Enum_t EntryType, uint32 Reset * \param PspContextId Identifier of extended context info stored in the PSP (if available) */ int32 CFE_ES_WriteToERLogWithContext( CFE_ES_LogEntryType_Enum_t EntryType, uint32 ResetType, uint32 ResetSubtype, - const char *Description, CFE_ES_ResourceID_t AppId, uint32 PspContextId); + const char *Description, CFE_ES_AppId_t AppId, uint32 PspContextId); #endif /* _cfe_es_log_ */ diff --git a/fsw/cfe-core/src/es/cfe_es_mempool.c b/fsw/cfe-core/src/es/cfe_es_mempool.c index 6e994aabc..4f09ff3d5 100644 --- a/fsw/cfe-core/src/es/cfe_es_mempool.c +++ b/fsw/cfe-core/src/es/cfe_es_mempool.c @@ -108,8 +108,8 @@ int32 CFE_ES_MemPoolDirectCommit(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t Offs int32 CFE_ES_MemPoolID_ToIndex(CFE_ES_MemHandle_t PoolID, uint32 *Idx) { - return CFE_ES_ResourceID_ToIndex( - CFE_ES_ResourceID_ToInteger(PoolID) - CFE_ES_POOLID_BASE, + return CFE_ResourceId_ToIndex(CFE_RESOURCEID_UNWRAP(PoolID), + CFE_ES_POOLID_BASE, CFE_PLATFORM_ES_MAX_MEMORY_POOLS, Idx); } @@ -121,9 +121,9 @@ int32 CFE_ES_MemPoolID_ToIndex(CFE_ES_MemHandle_t PoolID, uint32 *Idx) * a given table slot is available. Must be called while locked. *--------------------------------------------------------------------------------------- */ -bool CFE_ES_CheckMemPoolSlotUsed(CFE_ES_ResourceID_t CheckId) +bool CFE_ES_CheckMemPoolSlotUsed(CFE_ResourceId_t CheckId) { - return CFE_ES_MemPoolRecordIsUsed(CFE_ES_LocateMemPoolRecordByID(CheckId)); + return CFE_ES_MemPoolRecordIsUsed(CFE_ES_LocateMemPoolRecordByID(CFE_ES_MEMHANDLE_C(CheckId))); } CFE_ES_MemPoolRecord_t* CFE_ES_LocateMemPoolRecordByID(CFE_ES_MemHandle_t PoolID) @@ -174,7 +174,7 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, bool UseMutex ) { int32 Status; - CFE_ES_MemHandle_t PendingID; + CFE_ResourceId_t PendingID; CFE_ES_MemPoolRecord_t *PoolRecPtr; size_t Alignment; size_t MinimumSize; @@ -223,8 +223,8 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, CFE_ES_LockSharedData(__func__,__LINE__); /* scan for a free slot */ - PendingID = CFE_ES_FindNextAvailableId(CFE_ES_Global.LastMemPoolId, CFE_PLATFORM_ES_MAX_MEMORY_POOLS, CFE_ES_CheckMemPoolSlotUsed); - PoolRecPtr = CFE_ES_LocateMemPoolRecordByID(PendingID); + PendingID = CFE_ResourceId_FindNext(CFE_ES_Global.LastMemPoolId, CFE_PLATFORM_ES_MAX_MEMORY_POOLS, CFE_ES_CheckMemPoolSlotUsed); + PoolRecPtr = CFE_ES_LocateMemPoolRecordByID(CFE_ES_MEMHANDLE_C(PendingID)); if (PoolRecPtr == NULL) { @@ -235,7 +235,7 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, { /* Fully clear the entry, just in case of stale data */ memset(PoolRecPtr, 0, sizeof(*PoolRecPtr)); - CFE_ES_MemPoolRecordSetUsed(PoolRecPtr, CFE_ES_RESOURCEID_RESERVED); + CFE_ES_MemPoolRecordSetUsed(PoolRecPtr, CFE_RESOURCEID_RESERVED); CFE_ES_Global.LastMemPoolId = PendingID; Status = CFE_SUCCESS; } @@ -289,7 +289,7 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, ** This is needed only because OS_MutSemCreate requires ** a unique name for each semaphore created. */ - snprintf(MutexName, OS_MAX_API_NAME, "Pool%08lX", CFE_ES_ResourceID_ToInteger(PendingID)); + snprintf(MutexName, OS_MAX_API_NAME, "Pool%08lX", CFE_ResourceId_ToInteger(PendingID)); /* create a mutex to protect this memory pool */ Status = OS_MutSemCreate(&PoolRecPtr->MutexId, MutexName, 0); @@ -322,7 +322,7 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, /* * Store the actual/correct pool ID in the record. */ - CFE_ES_MemPoolRecordSetUsed(PoolRecPtr,PendingID); + CFE_ES_MemPoolRecordSetUsed(PoolRecPtr, PendingID); } else { @@ -330,7 +330,7 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, * Free the entry that was reserved earlier */ CFE_ES_MemPoolRecordSetFree(PoolRecPtr); - PendingID = CFE_ES_RESOURCEID_UNDEFINED; + PendingID = CFE_RESOURCEID_UNDEFINED; if (Status == CFE_ES_POOL_BOUNDS_ERROR) { @@ -341,8 +341,9 @@ int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, /* * Export pool ID to caller as handle + * */ - *PoolID = PendingID; + *PoolID = CFE_ES_MEMHANDLE_C(PendingID); return(Status); } @@ -407,7 +408,7 @@ int32 CFE_ES_GetPoolBuf(CFE_ES_MemPoolBuf_t *BufPtr, size_t Size ) { int32 Status; - CFE_ES_MemHandle_t AppId; + CFE_ES_AppId_t AppId; CFE_ES_MemPoolRecord_t *PoolRecPtr; size_t DataOffset; @@ -418,8 +419,8 @@ int32 CFE_ES_GetPoolBuf(CFE_ES_MemPoolBuf_t *BufPtr, { CFE_ES_GetAppID(&AppId); CFE_ES_WriteToSysLog("CFE_ES:getPoolBuf err:Bad handle(0x%08lX) AppId=%lu\n", - CFE_ES_ResourceID_ToInteger(Handle), - CFE_ES_ResourceID_ToInteger(AppId)); + CFE_RESOURCEID_TO_ULONG(Handle), + CFE_RESOURCEID_TO_ULONG(AppId)); return(CFE_ES_ERR_RESOURCEID_NOT_VALID); } @@ -533,7 +534,7 @@ int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t Handle, if (!CFE_ES_MemPoolRecordIsMatch(PoolRecPtr, Handle)) { CFE_ES_WriteToSysLog("CFE_ES:putPoolBuf err:Invalid Memory Handle (0x%08lX).\n", - CFE_ES_ResourceID_ToInteger(Handle)); + CFE_RESOURCEID_TO_ULONG(Handle)); return(CFE_ES_ERR_RESOURCEID_NOT_VALID); } @@ -600,7 +601,7 @@ int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t Handle, int32 CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t Handle) { - CFE_ES_MemHandle_t AppId; + CFE_ES_AppId_t AppId; CFE_ES_MemPoolRecord_t *PoolRecPtr; uint16 NumBuckets; uint16 Idx; @@ -612,7 +613,7 @@ int32 CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, { CFE_ES_GetAppID(&AppId); CFE_ES_WriteToSysLog("CFE_ES:getMemPoolStats err:Bad handle(0x%08lX) AppId=%lu\n", - CFE_ES_ResourceID_ToInteger(Handle), CFE_ES_ResourceID_ToInteger(AppId)); + CFE_RESOURCEID_TO_ULONG(Handle), CFE_RESOURCEID_TO_ULONG(AppId)); return(CFE_ES_ERR_RESOURCEID_NOT_VALID); } diff --git a/fsw/cfe-core/src/es/cfe_es_mempool.h b/fsw/cfe-core/src/es/cfe_es_mempool.h index 247d65110..26ac8c113 100644 --- a/fsw/cfe-core/src/es/cfe_es_mempool.h +++ b/fsw/cfe-core/src/es/cfe_es_mempool.h @@ -64,7 +64,7 @@ typedef struct * an ES app, but in that case the resource cannot be cleaned up if the * app exits unexpectedly. */ - CFE_ES_ResourceID_t OwnerAppID; + CFE_ES_AppId_t OwnerAppID; /** * Optional Mutex for serializing get/put operations @@ -121,7 +121,7 @@ CFE_ES_MemPoolRecord_t* CFE_ES_LocateMemPoolRecordByID(CFE_ES_MemHandle_t PoolID */ static inline bool CFE_ES_MemPoolRecordIsUsed(const CFE_ES_MemPoolRecord_t *PoolRecPtr) { - return CFE_ES_ResourceID_IsDefined(PoolRecPtr->PoolID); + return CFE_RESOURCEID_TEST_DEFINED(PoolRecPtr->PoolID); } /** @@ -146,9 +146,9 @@ static inline CFE_ES_MemHandle_t CFE_ES_MemPoolRecordGetID(const CFE_ES_MemPoolR * @param[in] PoolRecPtr pointer to Pool table entry * @param[in] PoolID the Pool ID of this entry */ -static inline void CFE_ES_MemPoolRecordSetUsed(CFE_ES_MemPoolRecord_t *PoolRecPtr, CFE_ES_MemHandle_t PoolID) +static inline void CFE_ES_MemPoolRecordSetUsed(CFE_ES_MemPoolRecord_t *PoolRecPtr, CFE_ResourceId_t PendingId) { - PoolRecPtr->PoolID = PoolID; + PoolRecPtr->PoolID = CFE_ES_MEMHANDLE_C(PendingId); } /** @@ -161,7 +161,7 @@ static inline void CFE_ES_MemPoolRecordSetUsed(CFE_ES_MemPoolRecord_t *PoolRecPt */ static inline void CFE_ES_MemPoolRecordSetFree(CFE_ES_MemPoolRecord_t *PoolRecPtr) { - PoolRecPtr->PoolID = CFE_ES_RESOURCEID_UNDEFINED; + PoolRecPtr->PoolID = CFE_ES_MEMHANDLE_UNDEFINED; } /** @@ -179,7 +179,7 @@ static inline void CFE_ES_MemPoolRecordSetFree(CFE_ES_MemPoolRecord_t *PoolRecPt */ static inline bool CFE_ES_MemPoolRecordIsMatch(const CFE_ES_MemPoolRecord_t *PoolRecPtr, CFE_ES_MemHandle_t PoolID) { - return (PoolRecPtr != NULL && CFE_ES_ResourceID_Equal(PoolRecPtr->PoolID, PoolID)); + return (PoolRecPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(PoolRecPtr->PoolID, PoolID)); } /** @@ -187,7 +187,7 @@ static inline bool CFE_ES_MemPoolRecordIsMatch(const CFE_ES_MemPoolRecord_t *Poo * * Checks if a table slot is available for a potential new ID * This is a helper function intended to be used with - * CFE_ES_FindNextAvailableID() for allocating new IDs + * CFE_ResourceId_FindNext() for allocating new IDs * * As this dereferences fields within the record, global data must be * locked prior to invoking this function. @@ -195,7 +195,7 @@ static inline bool CFE_ES_MemPoolRecordIsMatch(const CFE_ES_MemPoolRecord_t *Poo * @param[in] CheckId pending/candidate Pool ID to check * @returns true if the table slot for the ID is occupied, false if available */ -bool CFE_ES_CheckMemPoolSlotUsed(CFE_ES_ResourceID_t CheckId); +bool CFE_ES_CheckMemPoolSlotUsed(CFE_ResourceId_t CheckId); #endif /* _CFE_ES_MEMPOOL_H_ */ diff --git a/fsw/cfe-core/src/es/cfe_es_resource.c b/fsw/cfe-core/src/es/cfe_es_resource.c index 4035697dd..4af1cacea 100644 --- a/fsw/cfe-core/src/es/cfe_es_resource.c +++ b/fsw/cfe-core/src/es/cfe_es_resource.c @@ -43,92 +43,37 @@ /*********************************************************************/ /* - * CFE_ES_ResourceID_ToIndex - * + * Function: CFE_ES_TaskId_ToOSAL + * * For complete API information, see prototype in header */ -int32 CFE_ES_ResourceID_ToIndex(uint32 Serial, uint32 TableSize, uint32 *Idx) +osal_id_t CFE_ES_TaskId_ToOSAL(CFE_ES_TaskId_t id) { - if (Idx == NULL) - { - return CFE_ES_ERR_BUFFER; - } + osal_id_t Result; + unsigned long Val; - if (Serial > CFE_ES_RESOURCEID_MAX) - { - return CFE_ES_ERR_RESOURCEID_NOT_VALID; - } + Val = CFE_ResourceId_ToInteger(CFE_RESOURCEID_UNWRAP(id)); + Result = OS_ObjectIdFromInteger(Val ^ CFE_RESOURCEID_MARK); - *Idx = Serial % TableSize; - return CFE_SUCCESS; + return Result; } /*********************************************************************/ /* - * CFE_ES_ResourceID_ToOSAL - * - * For complete API information, see prototype in header - */ -osal_id_t CFE_ES_ResourceID_ToOSAL(CFE_ES_ResourceID_t id) -{ - unsigned long val = CFE_ES_ResourceID_ToInteger(id); - return OS_ObjectIdFromInteger(val); -} - -/*********************************************************************/ -/* - * CFE_ES_ResourceID_FromOSAL - * - * For complete API information, see prototype in header - */ -CFE_ES_ResourceID_t CFE_ES_ResourceID_FromOSAL(osal_id_t id) -{ - unsigned long val = OS_ObjectIdToInteger(id); - return CFE_ES_ResourceID_FromInteger(val); -} - -/*********************************************************************/ -/* - * CFE_ES_FindNextAvailableId - * + * Function: CFE_TaskId_FromOSAL + * * For complete API information, see prototype in header */ -CFE_ES_ResourceID_t CFE_ES_FindNextAvailableId(CFE_ES_ResourceID_t StartId, uint32 TableSize, bool (*CheckFunc)(CFE_ES_ResourceID_t)) +CFE_ES_TaskId_t CFE_ES_TaskId_FromOSAL(osal_id_t id) { - uint32 Serial; - uint32 Count; - uint32 ResourceType; - CFE_ES_ResourceID_t CheckId; - bool IsTaken; + CFE_ResourceId_t Result; + unsigned long Val; - ResourceType = CFE_ES_ResourceID_ToInteger(StartId); - Serial = ResourceType & CFE_ES_RESOURCEID_MAX; - ResourceType -= Serial; - Count = TableSize; - IsTaken = true; - - do - { - if (Count == 0) - { - CheckId = CFE_ES_RESOURCEID_UNDEFINED; - break; - } - - --Count; - ++Serial; - if (Serial >= CFE_ES_RESOURCEID_MAX) - { - Serial %= TableSize; - } - CheckId = CFE_ES_ResourceID_FromInteger(ResourceType + Serial); - - IsTaken = CheckFunc(CheckId); - } - while (IsTaken); + Val = OS_ObjectIdToInteger(id); + Result = CFE_ResourceId_FromInteger(Val ^ CFE_RESOURCEID_MARK); - return CheckId; + return CFE_ES_TASKID_C(Result); } /*********************************************************************/ @@ -249,7 +194,7 @@ CFE_ES_GenCounterRecord_t *CFE_ES_LocateCounterRecordByName(const char *Name) * * For complete API information, see prototype in header */ -CFE_ES_AppRecord_t *CFE_ES_LocateAppRecordByID(CFE_ES_ResourceID_t AppID) +CFE_ES_AppRecord_t *CFE_ES_LocateAppRecordByID(CFE_ES_AppId_t AppID) { CFE_ES_AppRecord_t *AppRecPtr; uint32 Idx; @@ -272,7 +217,7 @@ CFE_ES_AppRecord_t *CFE_ES_LocateAppRecordByID(CFE_ES_ResourceID_t AppID) * * For complete API information, see prototype in header */ -CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_ResourceID_t LibID) +CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_LibId_t LibID) { CFE_ES_LibRecord_t *LibRecPtr; uint32 Idx; @@ -295,7 +240,7 @@ CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_ResourceID_t LibID) * * For complete API information, see prototype in header */ -CFE_ES_TaskRecord_t *CFE_ES_LocateTaskRecordByID(CFE_ES_ResourceID_t TaskID) +CFE_ES_TaskRecord_t *CFE_ES_LocateTaskRecordByID(CFE_ES_TaskId_t TaskID) { CFE_ES_TaskRecord_t *TaskRecPtr; uint32 Idx; @@ -318,7 +263,7 @@ CFE_ES_TaskRecord_t *CFE_ES_LocateTaskRecordByID(CFE_ES_ResourceID_t TaskID) * * For complete API information, see prototype in header */ -CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_ResourceID_t CounterID) +CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_CounterId_t CounterID) { CFE_ES_GenCounterRecord_t *CounterRecPtr; uint32 Idx; @@ -347,12 +292,12 @@ CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_ResourceID_t Co CFE_ES_TaskRecord_t *CFE_ES_GetTaskRecordByContext(void) { CFE_ES_TaskRecord_t *TaskRecPtr; - CFE_ES_ResourceID_t TaskID; + CFE_ES_TaskId_t TaskID; /* ** Use the OS task ID to get the ES task record */ - TaskID = CFE_ES_ResourceID_FromOSAL(OS_TaskGetId()); + TaskID = CFE_ES_TaskId_FromOSAL(OS_TaskGetId()); TaskRecPtr = CFE_ES_LocateTaskRecordByID(TaskID); /* @@ -418,9 +363,9 @@ CFE_ES_AppRecord_t *CFE_ES_GetAppRecordByContext(void) * a given ID is available. Must be called while locked. * --------------------------------------------------------------------------------------- */ -bool CFE_ES_CheckCounterIdSlotUsed(CFE_ES_ResourceID_t CheckId) +bool CFE_ES_CheckCounterIdSlotUsed(CFE_ResourceId_t CheckId) { - return CFE_ES_CounterRecordIsUsed(CFE_ES_LocateCounterRecordByID(CheckId)); + return CFE_ES_CounterRecordIsUsed(CFE_ES_LocateCounterRecordByID(CFE_ES_COUNTERID_C(CheckId))); } /* @@ -431,9 +376,9 @@ bool CFE_ES_CheckCounterIdSlotUsed(CFE_ES_ResourceID_t CheckId) * a given ID is available. Must be called while locked. *--------------------------------------------------------------------------------------- */ -bool CFE_ES_CheckAppIdSlotUsed(CFE_ES_ResourceID_t CheckId) +bool CFE_ES_CheckAppIdSlotUsed(CFE_ResourceId_t CheckId) { - return CFE_ES_AppRecordIsUsed(CFE_ES_LocateAppRecordByID(CheckId)); + return CFE_ES_AppRecordIsUsed(CFE_ES_LocateAppRecordByID(CFE_ES_APPID_C(CheckId))); } /* @@ -444,9 +389,9 @@ bool CFE_ES_CheckAppIdSlotUsed(CFE_ES_ResourceID_t CheckId) * a given ID is available. Must be called while locked. * --------------------------------------------------------------------------------------- */ -bool CFE_ES_CheckLibIdSlotUsed(CFE_ES_ResourceID_t CheckId) +bool CFE_ES_CheckLibIdSlotUsed(CFE_ResourceId_t CheckId) { - return CFE_ES_LibRecordIsUsed(CFE_ES_LocateLibRecordByID(CheckId)); + return CFE_ES_LibRecordIsUsed(CFE_ES_LocateLibRecordByID(CFE_ES_LIBID_C(CheckId))); } diff --git a/fsw/cfe-core/src/es/cfe_es_resource.h b/fsw/cfe-core/src/es/cfe_es_resource.h index 91f2ddeca..327a2fd47 100644 --- a/fsw/cfe-core/src/es/cfe_es_resource.h +++ b/fsw/cfe-core/src/es/cfe_es_resource.h @@ -34,8 +34,8 @@ /* ** Include Files */ -#include "cfe_resourceid.h" -#include "private/cfe_resourceid_internal.h" +#include "cfe_resourceid_api.h" +#include "private/cfe_core_resourceid_basevalues.h" #include "cfe_es_global.h" @@ -48,7 +48,7 @@ * @param[in] AppID the app ID to locate * @return pointer to App Table entry for the given app ID */ -extern CFE_ES_AppRecord_t* CFE_ES_LocateAppRecordByID(CFE_ES_ResourceID_t AppID); +extern CFE_ES_AppRecord_t* CFE_ES_LocateAppRecordByID(CFE_ES_AppId_t AppID); /** * @brief Locate the Library table entry correlating with a given Lib ID. @@ -59,7 +59,7 @@ extern CFE_ES_AppRecord_t* CFE_ES_LocateAppRecordByID(CFE_ES_ResourceID_t AppID) * @param[in] LibID the Lib ID to locate * @return pointer to Library Table entry for the given Lib ID */ -extern CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_ResourceID_t LibID); +extern CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_LibId_t LibID); /** * @brief Locate the task table entry correlating with a given task ID. @@ -70,7 +70,7 @@ extern CFE_ES_LibRecord_t* CFE_ES_LocateLibRecordByID(CFE_ES_ResourceID_t LibID) * @param[in] TaskID the task ID to locate * @return pointer to Task Table entry for the given task ID */ -extern CFE_ES_TaskRecord_t* CFE_ES_LocateTaskRecordByID(CFE_ES_ResourceID_t TaskID); +extern CFE_ES_TaskRecord_t* CFE_ES_LocateTaskRecordByID(CFE_ES_TaskId_t TaskID); /** * @brief Locate the Counter table entry correlating with a given Counter ID. @@ -81,7 +81,7 @@ extern CFE_ES_TaskRecord_t* CFE_ES_LocateTaskRecordByID(CFE_ES_ResourceID_t Task * @param[in] CounterID the Counter ID to locate * @return pointer to Counter Table entry for the given Counter ID */ -extern CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_ResourceID_t CounterID); +extern CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_CounterId_t CounterID); /** * @brief Check if an app record is in use or free/empty @@ -96,7 +96,7 @@ extern CFE_ES_GenCounterRecord_t* CFE_ES_LocateCounterRecordByID(CFE_ES_Resource */ static inline bool CFE_ES_AppRecordIsUsed(const CFE_ES_AppRecord_t *AppRecPtr) { - return CFE_ES_ResourceID_IsDefined(AppRecPtr->AppId); + return CFE_RESOURCEID_TEST_DEFINED(AppRecPtr->AppId); } /** @@ -107,7 +107,7 @@ static inline bool CFE_ES_AppRecordIsUsed(const CFE_ES_AppRecord_t *AppRecPtr) * @param[in] AppRecPtr pointer to app table entry * @returns AppID of entry */ -static inline CFE_ES_ResourceID_t CFE_ES_AppRecordGetID(const CFE_ES_AppRecord_t *AppRecPtr) +static inline CFE_ES_AppId_t CFE_ES_AppRecordGetID(const CFE_ES_AppRecord_t *AppRecPtr) { return AppRecPtr->AppId; } @@ -124,9 +124,9 @@ static inline CFE_ES_ResourceID_t CFE_ES_AppRecordGetID(const CFE_ES_AppRecord_t * @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, CFE_ES_ResourceID_t AppID) +static inline void CFE_ES_AppRecordSetUsed(CFE_ES_AppRecord_t *AppRecPtr, CFE_ResourceId_t PendingId) { - AppRecPtr->AppId = AppID; + AppRecPtr->AppId = CFE_ES_APPID_C(PendingId); } /** @@ -142,7 +142,7 @@ static inline void CFE_ES_AppRecordSetUsed(CFE_ES_AppRecord_t *AppRecPtr, CFE_ES */ static inline void CFE_ES_AppRecordSetFree(CFE_ES_AppRecord_t *AppRecPtr) { - AppRecPtr->AppId = CFE_ES_RESOURCEID_UNDEFINED; + AppRecPtr->AppId = CFE_ES_APPID_UNDEFINED; } /** @@ -158,9 +158,9 @@ static inline void CFE_ES_AppRecordSetFree(CFE_ES_AppRecord_t *AppRecPtr) * @param[in] AppID expected app ID * @returns true if the entry matches the given app ID */ -static inline bool CFE_ES_AppRecordIsMatch(const CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_ResourceID_t AppID) +static inline bool CFE_ES_AppRecordIsMatch(const CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_AppId_t AppID) { - return (AppRecPtr != NULL && CFE_ES_ResourceID_Equal(AppRecPtr->AppId, AppID)); + return (AppRecPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(AppRecPtr->AppId, AppID)); } /** @@ -191,7 +191,7 @@ static inline const char* CFE_ES_AppRecordGetName(const CFE_ES_AppRecord_t *AppR */ static inline bool CFE_ES_LibRecordIsUsed(const CFE_ES_LibRecord_t *LibRecPtr) { - return CFE_ES_ResourceID_IsDefined(LibRecPtr->LibId); + return CFE_RESOURCEID_TEST_DEFINED(LibRecPtr->LibId); } /** @@ -202,7 +202,7 @@ static inline bool CFE_ES_LibRecordIsUsed(const CFE_ES_LibRecord_t *LibRecPtr) * @param[in] LibRecPtr pointer to Lib table entry * @returns LibID of entry */ -static inline CFE_ES_ResourceID_t CFE_ES_LibRecordGetID(const CFE_ES_LibRecord_t *LibRecPtr) +static inline CFE_ES_LibId_t CFE_ES_LibRecordGetID(const CFE_ES_LibRecord_t *LibRecPtr) { /* * The initial implementation does not store the ID in the entry; @@ -220,9 +220,9 @@ static inline CFE_ES_ResourceID_t CFE_ES_LibRecordGetID(const CFE_ES_LibRecord_t * @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, CFE_ES_ResourceID_t LibID) +static inline void CFE_ES_LibRecordSetUsed(CFE_ES_LibRecord_t *LibRecPtr, CFE_ResourceId_t PendingId) { - LibRecPtr->LibId = LibID; + LibRecPtr->LibId = CFE_ES_LIBID_C(PendingId); } /** @@ -235,7 +235,7 @@ static inline void CFE_ES_LibRecordSetUsed(CFE_ES_LibRecord_t *LibRecPtr, CFE_ES */ static inline void CFE_ES_LibRecordSetFree(CFE_ES_LibRecord_t *LibRecPtr) { - LibRecPtr->LibId = CFE_ES_RESOURCEID_UNDEFINED; + LibRecPtr->LibId = CFE_ES_LIBID_UNDEFINED; } /** @@ -251,9 +251,9 @@ static inline void CFE_ES_LibRecordSetFree(CFE_ES_LibRecord_t *LibRecPtr) * @param[in] LibID expected Lib ID * @returns true if the entry matches the given Lib ID */ -static inline bool CFE_ES_LibRecordIsMatch(const CFE_ES_LibRecord_t *LibRecPtr, CFE_ES_ResourceID_t LibID) +static inline bool CFE_ES_LibRecordIsMatch(const CFE_ES_LibRecord_t *LibRecPtr, CFE_ES_LibId_t LibID) { - return (LibRecPtr != NULL && CFE_ES_ResourceID_Equal(LibRecPtr->LibId, LibID)); + return (LibRecPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(LibRecPtr->LibId, LibID)); } /** @@ -282,7 +282,7 @@ static inline const char* CFE_ES_LibRecordGetName(const CFE_ES_LibRecord_t *LibR * @param[in] TaskRecPtr pointer to Task table entry * @returns TaskID of entry */ -static inline CFE_ES_ResourceID_t CFE_ES_TaskRecordGetID(const CFE_ES_TaskRecord_t *TaskRecPtr) +static inline CFE_ES_TaskId_t CFE_ES_TaskRecordGetID(const CFE_ES_TaskRecord_t *TaskRecPtr) { return (TaskRecPtr->TaskId); } @@ -300,7 +300,7 @@ static inline CFE_ES_ResourceID_t CFE_ES_TaskRecordGetID(const CFE_ES_TaskRecord */ static inline bool CFE_ES_TaskRecordIsUsed(const CFE_ES_TaskRecord_t *TaskRecPtr) { - return CFE_ES_ResourceID_IsDefined(TaskRecPtr->TaskId); + return CFE_RESOURCEID_TEST_DEFINED(TaskRecPtr->TaskId); } /** @@ -315,9 +315,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, CFE_ES_ResourceID_t TaskID) +static inline void CFE_ES_TaskRecordSetUsed(CFE_ES_TaskRecord_t *TaskRecPtr, CFE_ResourceId_t PendingId) { - TaskRecPtr->TaskId = TaskID; + TaskRecPtr->TaskId = CFE_ES_TASKID_C(PendingId); } /** @@ -333,7 +333,7 @@ static inline void CFE_ES_TaskRecordSetUsed(CFE_ES_TaskRecord_t *TaskRecPtr, CFE */ static inline void CFE_ES_TaskRecordSetFree(CFE_ES_TaskRecord_t *TaskRecPtr) { - TaskRecPtr->TaskId = CFE_ES_RESOURCEID_UNDEFINED; + TaskRecPtr->TaskId = CFE_ES_TASKID_UNDEFINED; } /** @@ -349,9 +349,9 @@ static inline void CFE_ES_TaskRecordSetFree(CFE_ES_TaskRecord_t *TaskRecPtr) * @param[in] TaskID The expected task ID to verify * @returns true if the entry matches the given task ID */ -static inline bool CFE_ES_TaskRecordIsMatch(const CFE_ES_TaskRecord_t *TaskRecPtr, CFE_ES_ResourceID_t TaskID) +static inline bool CFE_ES_TaskRecordIsMatch(const CFE_ES_TaskRecord_t *TaskRecPtr, CFE_ES_TaskId_t TaskID) { - return (TaskRecPtr != NULL && CFE_ES_ResourceID_Equal(TaskRecPtr->TaskId, TaskID)); + return (TaskRecPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(TaskRecPtr->TaskId, TaskID)); } /** @@ -382,7 +382,7 @@ static inline const char* CFE_ES_TaskRecordGetName(const CFE_ES_TaskRecord_t *Ta */ static inline bool CFE_ES_CounterRecordIsUsed(const CFE_ES_GenCounterRecord_t *CounterRecPtr) { - return CFE_ES_ResourceID_IsDefined(CounterRecPtr->CounterId); + return CFE_RESOURCEID_TEST_DEFINED(CounterRecPtr->CounterId); } /** @@ -393,7 +393,7 @@ static inline bool CFE_ES_CounterRecordIsUsed(const CFE_ES_GenCounterRecord_t *C * @param[in] CounterRecPtr pointer to Counter table entry * @returns CounterID of entry */ -static inline CFE_ES_ResourceID_t CFE_ES_CounterRecordGetID(const CFE_ES_GenCounterRecord_t *CounterRecPtr) +static inline CFE_ES_CounterId_t CFE_ES_CounterRecordGetID(const CFE_ES_GenCounterRecord_t *CounterRecPtr) { return CounterRecPtr->CounterId; } @@ -410,9 +410,9 @@ static inline CFE_ES_ResourceID_t CFE_ES_CounterRecordGetID(const CFE_ES_GenCoun * @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, CFE_ES_ResourceID_t CounterID) +static inline void CFE_ES_CounterRecordSetUsed(CFE_ES_GenCounterRecord_t *CounterRecPtr, CFE_ResourceId_t PendingId) { - CounterRecPtr->CounterId = CounterID; + CounterRecPtr->CounterId = CFE_ES_COUNTERID_C(PendingId); } /** @@ -428,7 +428,7 @@ static inline void CFE_ES_CounterRecordSetUsed(CFE_ES_GenCounterRecord_t *Counte */ static inline void CFE_ES_CounterRecordSetFree(CFE_ES_GenCounterRecord_t *CounterRecPtr) { - CounterRecPtr->CounterId = CFE_ES_RESOURCEID_UNDEFINED; + CounterRecPtr->CounterId = CFE_ES_COUNTERID_UNDEFINED; } /** @@ -444,9 +444,9 @@ static inline void CFE_ES_CounterRecordSetFree(CFE_ES_GenCounterRecord_t *Counte * @param[in] CounterID expected Counter ID * @returns true if the entry matches the given Counter ID */ -static inline bool CFE_ES_CounterRecordIsMatch(const CFE_ES_GenCounterRecord_t *CounterRecPtr, CFE_ES_ResourceID_t CounterID) +static inline bool CFE_ES_CounterRecordIsMatch(const CFE_ES_GenCounterRecord_t *CounterRecPtr, CFE_ES_CounterId_t CounterID) { - return (CounterRecPtr != NULL && CFE_ES_ResourceID_Equal(CounterRecPtr->CounterId, CounterID)); + return (CounterRecPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(CounterRecPtr->CounterId, CounterID)); } /** @@ -487,6 +487,59 @@ extern CFE_ES_AppRecord_t* CFE_ES_GetAppRecordByContext(void); */ extern CFE_ES_TaskRecord_t* CFE_ES_GetTaskRecordByContext(void); +/* + * OSAL <-> CFE task ID conversion + * + * CFE ES does not currently allocate its own task IDs; instead it piggybacks on top + * of the allocation that is already done by OSAL. This is partly for backward + * compatibility - historically the OSAL task IDs were used directly by CFE task APIs. + * + * This is _only_ used for tasks - for all other resource types ES should allocate + * its own identifiers independently of any other subsystem. This conversion may also + * be removed in a future version of CFE, if ES starts allocating task IDs independently + * of OSAL task IDs. + */ + +/** + * @brief Convert an ES Task ID to an OSAL task ID + * + * Task IDs created via CFE ES are also OSAL task IDs, but technically + * do refer to a different scope and therefore have a different type + * to represent them. + * + * This function facilitates converting between the types. + * + * @note With "simple" resource IDs, numeric values are the same and can be interchanged + * for backward compatibility, however they will be different when using "strict" IDs. + * New code should not assume equivalence between OSAL and ES task IDs. + * + * @sa CFE_ES_TaskId_FromOSAL + * + * @param[in] id The CFE task ID + * @returns The OSAL task ID + */ +extern osal_id_t CFE_ES_TaskId_ToOSAL(CFE_ES_TaskId_t id); + +/** + * @brief Convert an ES Task ID to an OSAL task ID + * + * Task IDs created via CFE ES are also OSAL task IDs, but technically + * do refer to a different scope and therefore have a different type + * to represent them. + * + * This function facilitates converting between the types. + * + * @note With "simple" resource IDs, numeric values are the same and can be interchanged + * for backward compatibility, however they will be different when using "strict" IDs. + * New code should not assume equivalence between OSAL and ES task IDs. + * + * @sa CFE_ES_TaskId_ToOSAL + * + * @param[in] id The OSAL task ID + * @returns The CFE task ID + */ +extern CFE_ES_TaskId_t CFE_ES_TaskId_FromOSAL(osal_id_t id); + /* * Internal functions to perform name based resource lookups * @@ -498,10 +551,12 @@ CFE_ES_LibRecord_t *CFE_ES_LocateLibRecordByName(const char *Name); CFE_ES_TaskRecord_t *CFE_ES_LocateTaskRecordByName(const char *Name); CFE_ES_GenCounterRecord_t *CFE_ES_LocateCounterRecordByName(const char *Name); -/* Availability check functions used in conjunction with CFE_ES_FindNextAvailableId() */ -bool CFE_ES_CheckAppIdSlotUsed(CFE_ES_ResourceID_t CheckId); -bool CFE_ES_CheckLibIdSlotUsed(CFE_ES_ResourceID_t CheckId); -bool CFE_ES_CheckCounterIdSlotUsed(CFE_ES_ResourceID_t CheckId); +/* Availability check functions used in conjunction with CFE_ResourceId_FindNext() */ +bool CFE_ES_CheckAppIdSlotUsed(CFE_ResourceId_t CheckId); +bool CFE_ES_CheckLibIdSlotUsed(CFE_ResourceId_t CheckId); +bool CFE_ES_CheckCounterIdSlotUsed(CFE_ResourceId_t CheckId); + + #endif /* CFE_ES_RESOURCE_H */ diff --git a/fsw/cfe-core/src/es/cfe_es_start.c b/fsw/cfe-core/src/es/cfe_es_start.c index 93d1627d3..5fcf246e7 100644 --- a/fsw/cfe-core/src/es/cfe_es_start.c +++ b/fsw/cfe-core/src/es/cfe_es_start.c @@ -182,10 +182,10 @@ void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const cha /* ** Initialize the Last Id */ - CFE_ES_Global.LastAppId = CFE_ES_ResourceID_FromInteger(CFE_ES_APPID_BASE); - CFE_ES_Global.LastLibId = CFE_ES_ResourceID_FromInteger(CFE_ES_LIBID_BASE); - CFE_ES_Global.LastCounterId = CFE_ES_ResourceID_FromInteger(CFE_ES_COUNTID_BASE); - CFE_ES_Global.LastMemPoolId = CFE_ES_ResourceID_FromInteger(CFE_ES_POOLID_BASE); + CFE_ES_Global.LastAppId = CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE); + CFE_ES_Global.LastLibId = CFE_ResourceId_FromInteger(CFE_ES_LIBID_BASE); + CFE_ES_Global.LastCounterId = CFE_ResourceId_FromInteger(CFE_ES_COUNTID_BASE); + CFE_ES_Global.LastMemPoolId = CFE_ResourceId_FromInteger(CFE_ES_POOLID_BASE); /* ** Indicate that the CFE core is now starting up / going multi-threaded @@ -742,8 +742,8 @@ void CFE_ES_CreateObjects(void) int32 ReturnCode; uint16 i; CFE_ES_AppRecord_t *AppRecPtr; - CFE_ES_ResourceID_t PendingAppId; - CFE_ES_ResourceID_t PendingTaskId; + CFE_ResourceId_t PendingAppId; + CFE_ES_TaskId_t PendingTaskId; CFE_ES_WriteToSysLog("ES Startup: Starting Object Creation calls.\n"); @@ -759,8 +759,8 @@ void CFE_ES_CreateObjects(void) */ CFE_ES_LockSharedData(__func__,__LINE__); - PendingAppId = CFE_ES_FindNextAvailableId(CFE_ES_Global.LastAppId, CFE_PLATFORM_ES_MAX_APPLICATIONS, CFE_ES_CheckAppIdSlotUsed); - AppRecPtr = CFE_ES_LocateAppRecordByID(PendingAppId); + PendingAppId = CFE_ResourceId_FindNext(CFE_ES_Global.LastAppId, CFE_PLATFORM_ES_MAX_APPLICATIONS, CFE_ES_CheckAppIdSlotUsed); + AppRecPtr = CFE_ES_LocateAppRecordByID(CFE_ES_APPID_C(PendingAppId)); if (AppRecPtr != NULL) { /* @@ -783,7 +783,7 @@ void CFE_ES_CreateObjects(void) AppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_RUN; AppRecPtr->ControlReq.AppTimerMsec = 0; - CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_ES_RESOURCEID_RESERVED); + CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_RESOURCEID_RESERVED); CFE_ES_Global.LastAppId = PendingAppId; } @@ -798,7 +798,7 @@ void CFE_ES_CreateObjects(void) ** Start the core app main task ** (core apps are already in memory - no loading needed) */ - ReturnCode = CFE_ES_StartAppTask(&AppRecPtr->StartParams, PendingAppId, &PendingTaskId); + ReturnCode = CFE_ES_StartAppTask(&AppRecPtr->StartParams, CFE_ES_APPID_C(PendingAppId), &PendingTaskId); /* * Finalize data in the app table entry, which must be done under lock. diff --git a/fsw/cfe-core/src/es/cfe_es_task.c b/fsw/cfe-core/src/es/cfe_es_task.c index 6fcf2b041..2aa1b1fb1 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.c +++ b/fsw/cfe-core/src/es/cfe_es_task.c @@ -846,7 +846,7 @@ int32 CFE_ES_RestartCmd(const CFE_ES_RestartCmd_t *data) int32 CFE_ES_StartAppCmd(const CFE_ES_StartAppCmd_t *data) { const CFE_ES_StartAppCmd_Payload_t *cmd = &data->Payload; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; int32 Result; int32 FilenameLen; int32 AppEntryLen; @@ -933,7 +933,7 @@ int32 CFE_ES_StartAppCmd(const CFE_ES_StartAppCmd_t *data) CFE_ES_TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_START_INF_EID, CFE_EVS_EventType_INFORMATION, "Started %s from %s, AppID = %lu", - LocalAppName, LocalFile, CFE_ES_ResourceID_ToInteger(AppID)); + LocalAppName, LocalFile, CFE_RESOURCEID_TO_ULONG(AppID)); } else { @@ -959,7 +959,7 @@ int32 CFE_ES_StopAppCmd(const CFE_ES_StopAppCmd_t *data) { const CFE_ES_AppNameCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; int32 Result; CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, @@ -1013,7 +1013,7 @@ int32 CFE_ES_RestartAppCmd(const CFE_ES_RestartAppCmd_t *data) { const CFE_ES_AppNameCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; int32 Result; CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, @@ -1064,7 +1064,7 @@ int32 CFE_ES_ReloadAppCmd(const CFE_ES_ReloadAppCmd_t *data) const CFE_ES_AppReloadCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; char LocalFileName[OS_MAX_PATH_LEN]; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; int32 Result; CFE_SB_MessageStringGet(LocalFileName, (char *)cmd->AppFileName, NULL, @@ -1117,22 +1117,27 @@ int32 CFE_ES_QueryOneCmd(const CFE_ES_QueryOneCmd_t *data) { const CFE_ES_AppNameCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; - CFE_ES_ResourceID_t ResourceID; + union + { + CFE_ES_AppId_t AppId; + CFE_ES_LibId_t LibId; + CFE_ResourceId_t ResourceID; + } IdBuf; int32 Result; CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, sizeof(LocalApp), sizeof(cmd->Application)); - Result = CFE_ES_GetAppIDByName(&ResourceID, LocalApp); + Result = CFE_ES_GetAppIDByName(&IdBuf.AppId, LocalApp); if (Result == CFE_ES_ERR_NAME_NOT_FOUND) { /* Also check for a matching library name */ - Result = CFE_ES_GetLibIDByName(&ResourceID, LocalApp); + Result = CFE_ES_GetLibIDByName(&IdBuf.LibId, LocalApp); } if (Result == CFE_SUCCESS) { - Result = CFE_ES_GetModuleInfo(&(CFE_ES_TaskData.OneAppPacket.Payload.AppInfo), ResourceID); + Result = CFE_ES_GetModuleInfo(&(CFE_ES_TaskData.OneAppPacket.Payload.AppInfo), IdBuf.ResourceID); } /* @@ -1187,7 +1192,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) CFE_ES_AppInfo_t AppInfo; const CFE_ES_FileNameCmd_Payload_t *CmdPtr = &data->Payload; char QueryAllFilename[OS_MAX_PATH_LEN]; - CFE_ES_ResourceID_t ResourceList[CFE_ES_QUERY_ALL_MAX_ENTRIES]; + CFE_ResourceId_t ResourceList[CFE_ES_QUERY_ALL_MAX_ENTRIES]; uint32 NumResources; CFE_ES_AppRecord_t *AppRecPtr; CFE_ES_LibRecord_t *LibRecPtr; @@ -1212,7 +1217,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) { if (CFE_ES_AppRecordIsUsed(AppRecPtr)) { - ResourceList[NumResources] = CFE_ES_AppRecordGetID(AppRecPtr); + ResourceList[NumResources] = CFE_RESOURCEID_UNWRAP(CFE_ES_AppRecordGetID(AppRecPtr)); ++NumResources; } ++AppRecPtr; @@ -1223,7 +1228,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) { if (CFE_ES_LibRecordIsUsed(LibRecPtr)) { - ResourceList[NumResources] = CFE_ES_LibRecordGetID(LibRecPtr); + ResourceList[NumResources] = CFE_RESOURCEID_UNWRAP(CFE_ES_LibRecordGetID(LibRecPtr)); ++NumResources; } ++LibRecPtr; @@ -1346,7 +1351,7 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) CFE_ES_TaskInfo_t TaskInfo; const CFE_ES_FileNameCmd_Payload_t *CmdPtr = &data->Payload; char QueryAllFilename[OS_MAX_PATH_LEN]; - CFE_ES_ResourceID_t TaskList[OS_MAX_TASKS]; + CFE_ES_TaskId_t TaskList[OS_MAX_TASKS]; uint32 NumTasks; CFE_ES_TaskRecord_t *TaskRecPtr; @@ -1817,14 +1822,14 @@ int32 CFE_ES_SendMemPoolStatsCmd(const CFE_ES_SendMemPoolStatsCmd_t *data) CFE_ES_TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_TLM_POOL_STATS_INFO_EID, CFE_EVS_EventType_DEBUG, "Successfully telemetered memory pool stats for 0x%08lX", - CFE_ES_ResourceID_ToInteger(Cmd->PoolHandle)); + CFE_RESOURCEID_TO_ULONG(Cmd->PoolHandle)); } else { CFE_ES_TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_INVALID_POOL_HANDLE_ERR_EID, CFE_EVS_EventType_ERROR, "Cannot telemeter memory pool stats. Illegal Handle (0x%08lX)", - CFE_ES_ResourceID_ToInteger(Cmd->PoolHandle)); + CFE_RESOURCEID_TO_ULONG(Cmd->PoolHandle)); } return CFE_SUCCESS; diff --git a/fsw/cfe-core/src/evs/cfe_evs.c b/fsw/cfe-core/src/evs/cfe_evs.c index 1d5f8a19a..4ca1b4abe 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; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_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; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_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; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_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, CFE_ES_ResourceID_t AppID, const char *Spec, ... ) +int32 CFE_EVS_SendEventWithAppID (uint16 EventID, uint16 EventType, CFE_ES_AppId_t AppID, const char *Spec, ... ) { int32 Status = CFE_SUCCESS; CFE_TIME_SysTime_t Time; @@ -219,7 +219,7 @@ int32 CFE_EVS_SendEventWithAppID (uint16 EventID, uint16 EventType, CFE_ES_Resou int32 CFE_EVS_SendTimedEvent (CFE_TIME_SysTime_t Time, uint16 EventID, uint16 EventType, const char *Spec, ... ) { int32 Status; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; va_list Ptr; EVS_AppData_t *AppDataPtr; @@ -252,7 +252,7 @@ int32 CFE_EVS_ResetFilter (int16 EventID) { int32 Status; EVS_BinFilter_t *FilterPtr = NULL; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; EVS_AppData_t *AppDataPtr; /* Query and verify the caller's AppID */ @@ -289,7 +289,7 @@ int32 CFE_EVS_ResetFilter (int16 EventID) int32 CFE_EVS_ResetAllFilters ( void ) { int32 Status; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; uint32 i; EVS_AppData_t *AppDataPtr; diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.c b/fsw/cfe-core/src/evs/cfe_evs_task.c index e47e449ae..e0664bdcd 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.c +++ b/fsw/cfe-core/src/evs/cfe_evs_task.c @@ -179,7 +179,7 @@ int32 CFE_EVS_EarlyInit ( void ) ** ** Assumptions and Notes: */ -int32 CFE_EVS_CleanUpApp(CFE_ES_ResourceID_t AppID) +int32 CFE_EVS_CleanUpApp(CFE_ES_AppId_t AppID) { int32 Status = CFE_SUCCESS; EVS_AppData_t *AppDataPtr; @@ -280,7 +280,7 @@ void CFE_EVS_TaskMain(void) int32 CFE_EVS_TaskInit ( void ) { int32 Status; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; /* Register EVS application */ Status = CFE_ES_RegisterApp(); @@ -727,7 +727,7 @@ int32 CFE_EVS_ReportHousekeepingCmd (const CFE_MSG_CommandHeader_t *data) /* Clear unused portion of event state data in telemetry packet */ for (i = j; i < CFE_MISSION_ES_MAX_APPLICATIONS; i++) { - AppTlmDataPtr->AppID = CFE_ES_RESOURCEID_UNDEFINED; + AppTlmDataPtr->AppID = CFE_ES_APPID_UNDEFINED; AppTlmDataPtr->AppEnableStatus = false; AppTlmDataPtr->AppMessageSentCounter = 0; } diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.h b/fsw/cfe-core/src/evs/cfe_evs_task.h index 40a5e3aea..ea270faeb 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.h +++ b/fsw/cfe-core/src/evs/cfe_evs_task.h @@ -88,8 +88,8 @@ typedef struct typedef struct { - CFE_ES_ResourceID_t AppID; - CFE_ES_ResourceID_t UnregAppID; + CFE_ES_AppId_t AppID; + CFE_ES_AppId_t UnregAppID; EVS_BinFilter_t BinFilters[CFE_PLATFORM_EVS_MAX_EVENT_FILTERS]; /* Array of binary filters */ @@ -124,7 +124,7 @@ typedef struct CFE_EVS_HousekeepingTlm_t EVS_TlmPkt; CFE_SB_PipeId_t EVS_CommandPipe; osal_id_t EVS_SharedDataMutexID; - CFE_ES_ResourceID_t EVS_AppID; + CFE_ES_AppId_t EVS_AppID; } CFE_EVS_GlobalData_t; diff --git a/fsw/cfe-core/src/evs/cfe_evs_utils.c b/fsw/cfe-core/src/evs/cfe_evs_utils.c index c1cb9b25d..63e1be974 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_utils.c +++ b/fsw/cfe-core/src/evs/cfe_evs_utils.c @@ -64,7 +64,7 @@ void EVS_OutputPort4 (char *Message); ** Assumptions and Notes: ** */ -EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_ResourceID_t AppID) +EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_AppId_t AppID) { uint32 AppIndex; EVS_AppData_t *AppDataPtr; @@ -83,9 +83,9 @@ EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_ResourceID_t AppID) } /* End EVS_GetAppDataByID */ -int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_ResourceID_t *AppIDOut) +int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_AppId_t *AppIDOut) { - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; EVS_AppData_t *AppDataPtr; int32 Status; @@ -134,7 +134,7 @@ int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_ResourceID_t *Ap int32 EVS_GetApplicationInfo (EVS_AppData_t **AppDataOut, const char *pAppName) { int32 Status; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; EVS_AppData_t *AppDataPtr; Status = CFE_ES_GetAppIDByName(&AppID, pAppName); @@ -180,12 +180,12 @@ int32 EVS_GetApplicationInfo (EVS_AppData_t **AppDataOut, const char *pAppName) ** Assumptions and Notes: ** */ -int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_t CallerID) +int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, CFE_ES_AppId_t CallerID) { char AppName[OS_MAX_API_NAME]; /* Send only one "not registered" event per application */ - if ( !CFE_ES_ResourceID_Equal(AppDataPtr->UnregAppID, CallerID) ) + if ( !CFE_RESOURCEID_TEST_EQUAL(AppDataPtr->UnregAppID, CallerID) ) { /* Increment count of "not registered" applications */ CFE_EVS_GlobalData.EVS_TlmPkt.Payload.UnregisteredAppCounter++; diff --git a/fsw/cfe-core/src/evs/cfe_evs_utils.h b/fsw/cfe-core/src/evs/cfe_evs_utils.h index b995abc4f..b2ee70d84 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_utils.h +++ b/fsw/cfe-core/src/evs/cfe_evs_utils.h @@ -63,7 +63,7 @@ * @param[in] AppID AppID to find * @returns Pointer to app table entry, or NULL if ID is invalid. */ -EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_ResourceID_t AppID); +EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_AppId_t AppID); /** * @brief Obtain the context information for the currently running app @@ -74,7 +74,7 @@ EVS_AppData_t *EVS_GetAppDataByID (CFE_ES_ResourceID_t AppID); * @param[out] AppIDOut Location to store AppID * @returns CFE_SUCCESS if successful, or relevant error code. */ -int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_ResourceID_t *AppIDOut); +int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_AppId_t *AppIDOut); /** @@ -90,7 +90,7 @@ int32 EVS_GetCurrentContext (EVS_AppData_t **AppDataOut, CFE_ES_ResourceID_t *Ap */ static inline bool EVS_AppDataIsUsed(EVS_AppData_t *AppDataPtr) { - return CFE_ES_ResourceID_IsDefined(AppDataPtr->AppID); + return CFE_RESOURCEID_TEST_DEFINED(AppDataPtr->AppID); } /** @@ -101,7 +101,7 @@ static inline bool EVS_AppDataIsUsed(EVS_AppData_t *AppDataPtr) * @param[in] AppDataPtr pointer to app table entry * @returns AppID of entry */ -static inline CFE_ES_ResourceID_t EVS_AppDataGetID(EVS_AppData_t *AppDataPtr) +static inline CFE_ES_AppId_t EVS_AppDataGetID(EVS_AppData_t *AppDataPtr) { /* * The initial implementation does not store the ID in the entry; @@ -122,7 +122,7 @@ static inline CFE_ES_ResourceID_t EVS_AppDataGetID(EVS_AppData_t *AppDataPtr) * @param[in] AppDataPtr pointer to app table entry * @param[in] AppID the app ID of this entry */ -static inline void EVS_AppDataSetUsed(EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_t AppID) +static inline void EVS_AppDataSetUsed(EVS_AppData_t *AppDataPtr, CFE_ES_AppId_t AppID) { AppDataPtr->AppID = AppID; } @@ -137,7 +137,7 @@ static inline void EVS_AppDataSetUsed(EVS_AppData_t *AppDataPtr, CFE_ES_Resource */ static inline void EVS_AppDataSetFree(EVS_AppData_t *AppDataPtr) { - AppDataPtr->AppID = CFE_ES_RESOURCEID_UNDEFINED; + AppDataPtr->AppID = CFE_ES_APPID_UNDEFINED; } /** @@ -150,16 +150,16 @@ static inline void EVS_AppDataSetFree(EVS_AppData_t *AppDataPtr) * @param[in] AppID expected app ID * @returns true if the entry matches the given app ID */ -static inline bool EVS_AppDataIsMatch(EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_t AppID) +static inline bool EVS_AppDataIsMatch(EVS_AppData_t *AppDataPtr, CFE_ES_AppId_t AppID) { - return (AppDataPtr != NULL && CFE_ES_ResourceID_Equal(AppDataPtr->AppID, AppID)); + return (AppDataPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(AppDataPtr->AppID, AppID)); } int32 EVS_GetApplicationInfo(EVS_AppData_t **AppDataOut, const char *pAppName); -int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, CFE_ES_ResourceID_t CallerID); +int32 EVS_NotRegistered (EVS_AppData_t *AppDataPtr, CFE_ES_AppId_t CallerID); bool EVS_IsFiltered(EVS_AppData_t *AppDataPtr, uint16 EventID, uint16 EventType); diff --git a/fsw/cfe-core/src/fs/cfe_fs_api.c b/fsw/cfe-core/src/fs/cfe_fs_api.c index 83d38f9f4..4f83e5f13 100644 --- a/fsw/cfe-core/src/fs/cfe_fs_api.c +++ b/fsw/cfe-core/src/fs/cfe_fs_api.c @@ -94,7 +94,7 @@ int32 CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) CFE_TIME_SysTime_t Time; int32 Result; int32 EndianCheck = 0x01020304; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; /* ** Ensure that we are at the start of the file... @@ -109,7 +109,7 @@ int32 CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) Hdr->SpacecraftID = CFE_PSP_GetSpacecraftId(); Hdr->ProcessorID = CFE_PSP_GetProcessorId(); CFE_ES_GetAppID(&AppID); - Hdr->ApplicationID = CFE_ES_ResourceID_ToInteger(AppID); + Hdr->ApplicationID = CFE_RESOURCEID_TO_ULONG(AppID); /* Fill in length field */ diff --git a/fsw/cfe-core/src/fs/cfe_fs_priv.c b/fsw/cfe-core/src/fs/cfe_fs_priv.c index 445f22de3..40c179da6 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; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; Status = OS_MutSemTake(CFE_FS.SharedDataMutexId); if (Status != OS_SUCCESS) @@ -100,7 +100,7 @@ void CFE_FS_LockSharedData(const char *FunctionName) CFE_ES_GetAppID(&AppId); CFE_ES_WriteToSysLog("FS SharedData Mutex Take Err Stat=0x%x,App=%lu,Function=%s\n", - (unsigned int)Status,CFE_ES_ResourceID_ToInteger(AppId),FunctionName); + (unsigned int)Status,CFE_RESOURCEID_TO_ULONG(AppId),FunctionName); }/* end if */ @@ -124,14 +124,14 @@ void CFE_FS_LockSharedData(const char *FunctionName) void CFE_FS_UnlockSharedData(const char *FunctionName) { int32 Status; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; Status = OS_MutSemGive(CFE_FS.SharedDataMutexId); if (Status != OS_SUCCESS) { CFE_ES_GetAppID(&AppId); CFE_ES_WriteToSysLog("FS SharedData Mutex Give Err Stat=0x%x,App=%lu,Function=%s\n", - (unsigned int)Status,CFE_ES_ResourceID_ToInteger(AppId),FunctionName); + (unsigned int)Status,CFE_RESOURCEID_TO_ULONG(AppId),FunctionName); }/* end if */ return; diff --git a/fsw/cfe-core/src/inc/cfe_es.h b/fsw/cfe-core/src/inc/cfe_es.h index b42457ac6..310dd7f30 100644 --- a/fsw/cfe-core/src/inc/cfe_es.h +++ b/fsw/cfe-core/src/inc/cfe_es.h @@ -43,7 +43,7 @@ #include "cfe_mission_cfg.h" #include "cfe_perfids.h" #include "cfe_error.h" -#include "cfe_resourceid.h" +#include "cfe_resourceid_api.h" /*****************************************************************************/ @@ -83,13 +83,40 @@ #define CFE_ES_APP_RESTART CFE_PSP_RST_TYPE_MAX /**< Application only was reset (extend the PSP enumeration here) */ /** \} */ +/** \name Conversions for ES resource IDs */ +/** \{ */ -/** \name Critical Data Store Macros */ +/* + * Conversion macros for each ES resource ID subtype + * + * These accept a generic/non-specific CFE_ResourceId_t value + * and convert it to the corresponding resource-specific type. + * + * These should only be used when with the resource ID constants, + * or where the code has confirmed or is determining the generic + * identifier does correspond to a resource of that type. + */ +#define CFE_ES_APPID_C(val) ((CFE_ES_AppId_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_TASKID_C(val) ((CFE_ES_TaskId_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_LIBID_C(val) ((CFE_ES_LibId_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_COUNTERID_C(val) ((CFE_ES_CounterId_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_MEMHANDLE_C(val) ((CFE_ES_MemHandle_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_CDSHANDLE_C(val) ((CFE_ES_CDSHandle_t)CFE_RESOURCEID_WRAP(val)) + +/** \} */ + +/** \name Type-specific initalizers for "undefined" resource IDs */ /** \{ */ -#define CFE_ES_CDS_BAD_HANDLE CFE_ES_RESOURCEID_UNDEFINED +#define CFE_ES_APPID_UNDEFINED CFE_ES_APPID_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_TASKID_UNDEFINED CFE_ES_TASKID_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_LIBID_UNDEFINED CFE_ES_LIBID_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_COUNTERID_UNDEFINED CFE_ES_COUNTERID_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_MEMHANDLE_UNDEFINED CFE_ES_MEMHANDLE_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_CDS_BAD_HANDLE CFE_ES_CDSHANDLE_C(CFE_RESOURCEID_UNDEFINED) /** \} */ + #define CFE_ES_NO_MUTEX false /**< \brief Indicates that the memory pool selection will not use a semaphore */ #define CFE_ES_USE_MUTEX true /**< \brief Indicates that the memory pool selection will use a semaphore */ @@ -117,7 +144,7 @@ ** Child Task Main Function Prototype */ typedef void (*CFE_ES_ChildTaskMainFuncPtr_t)(void); /**< \brief Required Prototype of Child Task Main Functions */ -typedef int32 (*CFE_ES_LibraryEntryFuncPtr_t)(CFE_ES_ResourceID_t LibId); /**< \brief Required Prototype of Library Initialization Functions */ +typedef int32 (*CFE_ES_LibraryEntryFuncPtr_t)(CFE_ES_LibId_t LibId); /**< \brief Required Prototype of Library Initialization Functions */ /** * @brief Type for the stack pointer of tasks. @@ -212,7 +239,7 @@ typedef void* CFE_ES_MemPoolBuf_t; * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID */ -CFE_Status_t CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx); +CFE_Status_t CFE_ES_AppID_ToIndex(CFE_ES_AppId_t AppID, uint32 *Idx); /** * @brief Obtain an index value correlating to an ES Library ID @@ -237,7 +264,7 @@ CFE_Status_t CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx); * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID */ -int32 CFE_ES_LibID_ToIndex(CFE_ES_ResourceID_t LibID, uint32 *Idx); +int32 CFE_ES_LibID_ToIndex(CFE_ES_LibId_t LibID, uint32 *Idx); /** * @brief Obtain an index value correlating to an ES Task ID @@ -262,7 +289,7 @@ int32 CFE_ES_LibID_ToIndex(CFE_ES_ResourceID_t LibID, uint32 *Idx); * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID */ -CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx); +CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx); /** * @brief Obtain an index value correlating to an ES Counter ID @@ -287,7 +314,7 @@ CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx); * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID */ -CFE_Status_t CFE_ES_CounterID_ToIndex(CFE_ES_ResourceID_t CounterID, uint32 *Idx); +CFE_Status_t CFE_ES_CounterID_ToIndex(CFE_ES_CounterId_t CounterID, uint32 *Idx); /** @} */ @@ -371,7 +398,7 @@ CFE_Status_t CFE_ES_ResetCFE(uint32 ResetType); ** \sa #CFE_ES_ReloadApp, #CFE_ES_DeleteApp ** ******************************************************************************/ -CFE_Status_t CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID); +CFE_Status_t CFE_ES_RestartApp(CFE_ES_AppId_t AppID); /*****************************************************************************/ /** @@ -398,7 +425,7 @@ CFE_Status_t CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID); ** \sa #CFE_ES_RestartApp, #CFE_ES_DeleteApp, #CFE_ES_START_APP_CC ** ******************************************************************************/ -CFE_Status_t CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName); +CFE_Status_t CFE_ES_ReloadApp(CFE_ES_AppId_t AppID, const char *AppFileName); /*****************************************************************************/ /** @@ -417,7 +444,7 @@ CFE_Status_t CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName ** \sa #CFE_ES_RestartApp, #CFE_ES_ReloadApp ** ******************************************************************************/ -CFE_Status_t CFE_ES_DeleteApp(CFE_ES_ResourceID_t AppID); +CFE_Status_t CFE_ES_DeleteApp(CFE_ES_AppId_t AppID); /**@}*/ /** @defgroup CFEAPIESAppBehavior cFE Application Behavior APIs @@ -627,7 +654,7 @@ int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr); ** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName, #CFE_ES_GetTaskInfo ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr); +CFE_Status_t CFE_ES_GetAppID(CFE_ES_AppId_t *AppIdPtr); /*****************************************************************************/ /** @@ -650,7 +677,7 @@ CFE_Status_t CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr); ** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr); +CFE_Status_t CFE_ES_GetTaskID(CFE_ES_TaskId_t *TaskIdPtr); /*****************************************************************************/ /** @@ -675,7 +702,7 @@ CFE_Status_t CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr); ** \sa #CFE_ES_GetAppID, #CFE_ES_GetAppName, #CFE_ES_GetAppInfo ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName); +CFE_Status_t CFE_ES_GetAppIDByName(CFE_ES_AppId_t *AppIdPtr, const char *AppName); /*****************************************************************************/ /** @@ -700,7 +727,7 @@ CFE_Status_t CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *Ap ** \sa #CFE_ES_GetLibName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetLibIDByName(CFE_ES_ResourceID_t *LibIdPtr, const char *LibName); +CFE_Status_t CFE_ES_GetLibIDByName(CFE_ES_LibId_t *LibIdPtr, const char *LibName); /*****************************************************************************/ /** @@ -730,7 +757,7 @@ CFE_Status_t CFE_ES_GetLibIDByName(CFE_ES_ResourceID_t *LibIdPtr, const char *Li ** \sa #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppInfo ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t BufferLength); +CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_AppId_t AppId, size_t BufferLength); /*****************************************************************************/ /** @@ -760,7 +787,7 @@ CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t ** \sa #CFE_ES_GetLibIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, size_t BufferLength); +CFE_Status_t CFE_ES_GetLibName(char *LibName, CFE_ES_LibId_t LibId, size_t BufferLength); /*****************************************************************************/ /** @@ -787,7 +814,7 @@ CFE_Status_t CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, size_t ** \sa #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId); +CFE_Status_t CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_AppId_t AppId); /*****************************************************************************/ /** @@ -816,7 +843,7 @@ CFE_Status_t CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t Ap ** \sa #CFE_ES_GetTaskID, #CFE_ES_GetTaskIDByName, #CFE_ES_GetTaskName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId); +CFE_Status_t CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_TaskId_t TaskId); /*****************************************************************************/ /** @@ -849,7 +876,7 @@ CFE_Status_t CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t ** \sa #CFE_ES_GetLibIDByName, #CFE_ES_GetLibName ** ******************************************************************************/ -int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_ResourceID_t LibId); +int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_LibId_t LibId); /*****************************************************************************/ /** @@ -883,7 +910,7 @@ int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_ResourceID_t LibId); ** \sa #CFE_ES_GetLibInfo, #CFE_ES_GetAppInfo ** ******************************************************************************/ -int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ES_ResourceID_t ResourceId); +int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ResourceId_t ResourceId); /**@}*/ @@ -950,7 +977,7 @@ CFE_Status_t CFE_ES_RegisterChildTask(void); ** \sa #CFE_ES_RegisterChildTask, #CFE_ES_DeleteChildTask, #CFE_ES_ExitChildTask ** ******************************************************************************/ -CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, +CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, CFE_ES_StackPointer_t StackPtr, @@ -981,7 +1008,7 @@ CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, ** \sa #CFE_ES_GetTaskName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_ResourceID_t *TaskIdPtr, const char *TaskName); +CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName); /*****************************************************************************/ /** @@ -1011,7 +1038,7 @@ CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_ResourceID_t *TaskIdPtr, const char * ** \sa #CFE_ES_GetTaskIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, size_t BufferLength); +CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_TaskId_t TaskId, size_t BufferLength); /*****************************************************************************/ /** @@ -1033,7 +1060,7 @@ CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, size ** \sa #CFE_ES_RegisterChildTask, #CFE_ES_CreateChildTask, #CFE_ES_ExitChildTask ** ******************************************************************************/ -CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId); +CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId); /*****************************************************************************/ /** @@ -1193,7 +1220,7 @@ CFE_Status_t CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, size_t BlockSize, ** \sa #CFE_ES_GetCDSBlockName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_ResourceID_t *BlockIdPtr, const char *BlockName); +CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_CDSHandle_t *BlockIdPtr, const char *BlockName); /*****************************************************************************/ /** @@ -1223,7 +1250,7 @@ CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_ResourceID_t *BlockIdPtr, const c ** \sa #CFE_ES_GetCDSBlockIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_ResourceID_t BlockId, size_t BufferLength); +CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_CDSHandle_t BlockId, size_t BufferLength); /*****************************************************************************/ @@ -1600,7 +1627,7 @@ void CFE_ES_PerfLogAdd(uint32 Marker, uint32 EntryExit); ** \sa #CFE_ES_IncrementGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName); +CFE_Status_t CFE_ES_RegisterGenCounter(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName); /*****************************************************************************/ /** @@ -1621,7 +1648,7 @@ CFE_Status_t CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const ** \sa #CFE_ES_IncrementGenCounter, #CFE_ES_RegisterGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId); +CFE_Status_t CFE_ES_DeleteGenCounter(CFE_ES_CounterId_t CounterId); /*****************************************************************************/ /** @@ -1642,7 +1669,7 @@ CFE_Status_t CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId); ** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId); +CFE_Status_t CFE_ES_IncrementGenCounter(CFE_ES_CounterId_t CounterId); /*****************************************************************************/ /** @@ -1665,7 +1692,7 @@ CFE_Status_t CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId); ** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count); +CFE_Status_t CFE_ES_SetGenCount(CFE_ES_CounterId_t CounterId, uint32 Count); /*****************************************************************************/ /** @@ -1688,7 +1715,7 @@ CFE_Status_t CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count); ** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count); +CFE_Status_t CFE_ES_GetGenCount(CFE_ES_CounterId_t CounterId, uint32 *Count); /*****************************************************************************/ @@ -1712,7 +1739,7 @@ CFE_Status_t CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count); ** \sa #CFE_ES_GetGenCounterName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName); +CFE_Status_t CFE_ES_GetGenCounterIDByName(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName); /*****************************************************************************/ /** @@ -1742,7 +1769,7 @@ CFE_Status_t CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, con ** \sa #CFE_ES_GetGenCounterIDByName ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_ResourceID_t CounterId, size_t BufferLength); +CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_CounterId_t CounterId, size_t BufferLength); /**@}*/ diff --git a/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h b/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h index d03927dad..36c2d1ee3 100644 --- a/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h +++ b/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h @@ -32,6 +32,7 @@ /* Use the local definitions of these types */ #include "common_types.h" +#include "cfe_resourceid_typedef.h" /** * @brief Label definitions associated with CFE_ES_LogMode_Enum_t @@ -330,23 +331,33 @@ enum CFE_ES_AppState typedef uint32 CFE_ES_AppState_Enum_t; +/** + * @brief A type for Application IDs + * + * This is the type that is used for any API accepting or returning an App ID + */ +typedef CFE_RESOURCEID_BASE_TYPE CFE_ES_AppId_t; /** - * @brief A type that provides a common, abstract identifier for - * all ES managed resources (e.g. apps, tasks, counters, etc). + * @brief A type for Task IDs * - * Fundamentally an unsigned integer but users should treat it as - * opaque, and only go through the ES API for introspection. + * This is the type that is used for any API accepting or returning a Task ID + */ +typedef CFE_RESOURCEID_BASE_TYPE CFE_ES_TaskId_t; + +/** + * @brief A type for Library IDs * - * Simple operations are provided as inline functions, which - * should alleviate the need to do direct manipulation of the value: + * This is the type that is used for any API accepting or returning a Lib ID + */ +typedef CFE_RESOURCEID_BASE_TYPE CFE_ES_LibId_t; + +/** + * @brief A type for Counter IDs * - * - Check for undefined ID value - * - Check for equality of two ID values - * - Convert ID to simple integer (typically for printing/logging) - * - Convert simple integer to ID (inverse of above) + * This is the type that is used for any API accepting or returning an Counter ID */ -typedef uint32 CFE_ES_ResourceID_t; +typedef CFE_RESOURCEID_BASE_TYPE CFE_ES_CounterId_t; /** * @brief Memory Handle type @@ -354,14 +365,14 @@ typedef uint32 CFE_ES_ResourceID_t; * Data type used to hold Handles of Memory Pools * created via CFE_ES_PoolCreate and CFE_ES_PoolCreateNoSem */ -typedef CFE_ES_ResourceID_t CFE_ES_MemHandle_t; +typedef CFE_RESOURCEID_BASE_TYPE CFE_ES_MemHandle_t; /** * @brief CDS Handle type * * Data type used to hold Handles of Critical Data Stores. See #CFE_ES_RegisterCDS */ -typedef CFE_ES_ResourceID_t CFE_ES_CDSHandle_t; +typedef CFE_RESOURCEID_BASE_TYPE CFE_ES_CDSHandle_t; /** * @brief Type used for task priority in CFE ES as diff --git a/fsw/cfe-core/src/inc/cfe_es_msg.h b/fsw/cfe-core/src/inc/cfe_es_msg.h index 7748b52df..5a2c54d16 100644 --- a/fsw/cfe-core/src/inc/cfe_es_msg.h +++ b/fsw/cfe-core/src/inc/cfe_es_msg.h @@ -1426,11 +1426,15 @@ typedef struct CFE_ES_DumpCDSRegistryCmd * * Structure that is used to provide information about an app. * It is primarily used for the QueryOne and QueryAll Commands. + * + * While this structure is primarily intended for Application info, + * it can also represent Library information where only a subset of + * the information applies. */ typedef struct CFE_ES_AppInfo { - CFE_ES_ResourceID_t AppId; /**< \cfetlmmnemonic \ES_APP_ID - \brief Application ID for this Application */ + CFE_ResourceId_t ResourceId; /**< \cfetlmmnemonic \ES_APP_ID + \brief Application or Library ID for this resource */ uint32 Type; /**< \cfetlmmnemonic \ES_APPTYPE \brief The type of App: CORE or EXTERNAL */ @@ -1464,7 +1468,7 @@ typedef struct CFE_ES_AppInfo (Restart Application OR Restart Processor) */ CFE_ES_TaskPriority_Atom_t Priority; /**< \cfetlmmnemonic \ES_PRIORITY \brief The Priority of the Application */ - CFE_ES_ResourceID_t MainTaskId; /**< \cfetlmmnemonic \ES_MAINTASKID + CFE_ES_TaskId_t MainTaskId; /**< \cfetlmmnemonic \ES_MAINTASKID \brief The Application's Main Task ID */ uint32 ExecutionCounter; /**< \cfetlmmnemonic \ES_MAINTASKEXECNT \brief The Application's Main Task Execution Counter */ @@ -1488,10 +1492,10 @@ typedef struct CFE_ES_AppInfo */ typedef struct CFE_ES_TaskInfo { - CFE_ES_ResourceID_t TaskId; /**< \brief Task Id */ + CFE_ES_TaskId_t TaskId; /**< \brief Task Id */ uint32 ExecutionCounter; /**< \brief Task Execution Counter */ char TaskName[CFE_MISSION_MAX_API_LEN]; /**< \brief Task Name */ - CFE_ES_ResourceID_t AppId; /**< \brief Parent Application ID */ + CFE_ES_AppId_t AppId; /**< \brief Parent Application ID */ char AppName[CFE_MISSION_MAX_API_LEN]; /**< \brief Parent Application Name */ } CFE_ES_TaskInfo_t; diff --git a/fsw/cfe-core/src/inc/cfe_evs.h b/fsw/cfe-core/src/inc/cfe_evs.h index 9b0a62517..dbc963982 100644 --- a/fsw/cfe-core/src/inc/cfe_evs.h +++ b/fsw/cfe-core/src/inc/cfe_evs.h @@ -275,7 +275,7 @@ CFE_Status_t CFE_EVS_SendEvent (uint16 EventID, **/ CFE_Status_t CFE_EVS_SendEventWithAppID (uint16 EventID, uint16 EventType, - CFE_ES_ResourceID_t AppID, + CFE_ES_AppId_t AppID, const char *Spec, ... ) OS_PRINTF(4,5); diff --git a/fsw/cfe-core/src/inc/cfe_evs_msg.h b/fsw/cfe-core/src/inc/cfe_evs_msg.h index 5bbc90761..cfefb1514 100644 --- a/fsw/cfe-core/src/inc/cfe_evs_msg.h +++ b/fsw/cfe-core/src/inc/cfe_evs_msg.h @@ -1154,7 +1154,7 @@ typedef CFE_EVS_AppNameEventIDMaskCmd_t CFE_EVS_SetFilterCmd_t; /* Telemetry Message Data Formats */ /**********************************/ typedef struct CFE_EVS_AppTlmData { - CFE_ES_ResourceID_t AppID; /**< \cfetlmmnemonic \EVS_APPID + CFE_ES_AppId_t AppID; /**< \cfetlmmnemonic \EVS_APPID \brief Numerical application identifier */ uint16 AppMessageSentCounter; /**< \cfetlmmnemonic \EVS_APPMSGSENTC \brief Application message sent counter */ diff --git a/fsw/cfe-core/src/inc/cfe_resourceid.h b/fsw/cfe-core/src/inc/cfe_resourceid.h deleted file mode 100644 index 199554539..000000000 --- a/fsw/cfe-core/src/inc/cfe_resourceid.h +++ /dev/null @@ -1,150 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/** - * \file cfe_resourceid.h - * - * Contains global prototypes and definitions related to resource - * management and related CFE resource IDs. - * - * A CFE ES Resource ID is a common way to identify CFE-managed resources such - * as apps, tasks, counters, memory pools, CDS blocks, and other entities. - */ - -#ifndef CFE_RESOURCEID_H -#define CFE_RESOURCEID_H - -/* -** Include Files -** -** The actual CFE_ES_ResourceID_t type is part of the ES global/extern typedefs, -** as the concept originated in ES and has been extended across all of CFE. -*/ -#include "cfe_es_extern_typedefs.h" - -/* -** Defines -*/ - -/** \name Resource ID predefined values */ -/** \{ */ - -/** - * @brief A resource ID value that represents an undefined/unused resource - * - * This constant may be used to initialize local variables of the - * CFE_ES_ResourceID_t type to a safe value that will not alias a valid ID. - * - * By design, this value is also the result of zeroing a CFE_ES_ResourceID_t - * type via standard functions like memset(), such that objects initialized - * using this method will also be set to safe values. - */ -#define CFE_ES_RESOURCEID_UNDEFINED ((CFE_ES_ResourceID_t){0}) - -/** - * @brief A resource ID value that represents a reserved entry - * - * This is not a valid value for any resource type, but is used to mark - * table entries that are not available for use. For instance, this may - * be used while setting up an entry initially. - */ -#define CFE_ES_RESOURCEID_RESERVED ((CFE_ES_ResourceID_t){0xFFFFFFFF}) - -/** \} */ - - -/** - * @brief Convert a resource ID to an integer. - * - * This is primarily intended for logging purposes, such was writing - * to debug console, event messages, or log files, using printf-like APIs. - * - * For compatibility with C library APIs, this returns an "unsigned long" - * type and should be used with the "%lx" format specifier in a printf - * format string. - * - * @note No assumptions should be made about the actual integer value, - * such as its base/range. It may be printed, but should not be modified - * or tested/compared using other arithmetic ops, and should never be used - * as the index to an array or table. See the related function - * CFE_ES_ResourceID_ToIndex() for cases where a zero-based array/table index - * is needed. - * - * @sa CFE_ES_ResourceID_FromInteger() - * - * @param[in] id Resource ID to convert - * @returns Integer value corresponding to ID - */ -static inline unsigned long CFE_ES_ResourceID_ToInteger(CFE_ES_ResourceID_t id) -{ - return ((unsigned long)id); -} - -/** - * @brief Convert an integer to a resource ID. - * - * This is the inverse of CFE_ES_ResourceID_ToInteger(), and reconstitutes - * the original CFE_ES_ResourceID_t value from the integer representation. - * - * This may be used, for instance, where an ID value is parsed from a text - * file or message using C library APIs such as scanf() or strtoul(). - * - * @sa CFE_ES_ResourceID_ToInteger() - * - * @param[in] Value Integer value to convert - * @returns ID value corresponding to integer - */ -static inline CFE_ES_ResourceID_t CFE_ES_ResourceID_FromInteger(unsigned long Value) -{ - return ((CFE_ES_ResourceID_t)Value); -} - -/** - * @brief Compare two Resource ID values for equality - * - * @param[in] id1 Resource ID to check - * @param[in] id2 Resource ID to check - * @returns true if id1 and id2 are equal, false otherwise. - */ -static inline bool CFE_ES_ResourceID_Equal(CFE_ES_ResourceID_t id1, CFE_ES_ResourceID_t id2) -{ - return (id1 == id2); -} - -/** - * @brief Check if a resource ID value is defined - * - * The constant #CFE_ES_RESOURCEID_UNDEFINED represents an undefined ID value, - * such that the expression: - * - * CFE_ES_ResourceID_IsDefined(CFE_ES_RESOURCEID_UNDEFINED) - * - * Always returns false. - * - * @param[in] id Resource ID to check - * @returns True if the ID may refer to a defined entity, false if invalid/undefined. - */ -static inline bool CFE_ES_ResourceID_IsDefined(CFE_ES_ResourceID_t id) -{ - return (id != 0); -} - - -#endif /* CFE_RESOURCEID_H */ diff --git a/fsw/cfe-core/src/inc/cfe_resourceid_api.h b/fsw/cfe-core/src/inc/cfe_resourceid_api.h new file mode 100644 index 000000000..6bdb82f11 --- /dev/null +++ b/fsw/cfe-core/src/inc/cfe_resourceid_api.h @@ -0,0 +1,258 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * \file cfe_resourceid_api.h + * + * Contains global prototypes and definitions related to resource + * management and related CFE resource IDs. + * + * A CFE ES Resource ID is a common way to identify CFE-managed resources such + * as apps, tasks, counters, memory pools, CDS blocks, and other entities. + * + * Simple operations are provided as inline functions, which + * should alleviate the need to do direct manipulation of resource IDs: + * + * - Check for undefined ID value + * - Check for equality of two ID values + * - Convert ID to simple integer (typically for printing/logging) + * - Convert simple integer to ID (inverse of above) + */ + +#ifndef CFE_RESOURCEID_API_H +#define CFE_RESOURCEID_API_H + +/* + * The basic resource ID typedef + * + * This is provided via the external resourceid library + * and may be customized by the user/mission preferences. + */ +#include "cfe_resourceid_typedef.h" + +/* +** Defines +*/ + +/** \name Resource ID predefined values */ +/** \{ */ + + +/** + * @brief A resource ID value that represents an undefined/unused resource + * + * This constant may be used to initialize local variables of the + * CFE_ResourceId_t type to a safe value that will not alias a valid ID. + * + * By design, this value is also the result of zeroing a CFE_ResourceId_t + * type via standard functions like memset(), such that objects initialized + * using this method will also be set to safe values. + */ +#define CFE_RESOURCEID_UNDEFINED ((CFE_ResourceId_t) CFE_RESOURCEID_WRAP(0)) + +/** + * @brief A resource ID value that represents a reserved entry + * + * This is not a valid value for any resource type, but is used to mark + * table entries that are not available for use. For instance, this may + * be used while setting up an entry initially. + */ +#define CFE_RESOURCEID_RESERVED ((CFE_ResourceId_t) CFE_RESOURCEID_WRAP(0xFFFFFFFF)) + +/** \} */ + +/** \name Resource ID test/conversion macros and inline functions */ +/** \{ */ + + +/** + * \brief Convert a derived (app-specific) ID directly into an "unsigned long" + * + * This generic routine is implemented as a macro so it is agnostic to the actual argument type, + * and it will evaluate correctly so long as the argument type is based on the CFE_RESOURCEID_BASE_TYPE. + * + * There is no inverse of this macro, as it depends on the actual derived type desired. + * Applications needing to recreate an ID from an integer should use CFE_ResourceId_FromInteger() + * combined with a cast/conversion to the correct/intended derived type, as needed. + * + * \note This evaluates as an "unsigned long" such that it can be used in + * printf()-style functions with the "%lx" modifier without extra casting, + * as this is the most typical use-case for representing an ID as an integer. + */ +#define CFE_RESOURCEID_TO_ULONG(id) CFE_ResourceId_ToInteger(CFE_RESOURCEID_UNWRAP(id)) + +/** + * \brief Determine if a derived (app-specific) ID is defined or not + * + * This generic routine is implemented as a macro so it is agnostic to the actual argument type, + * and it will evaluate correctly so long as the argument type is based on the CFE_RESOURCEID_BASE_TYPE. + */ +#define CFE_RESOURCEID_TEST_DEFINED(id) CFE_ResourceId_IsDefined(CFE_RESOURCEID_UNWRAP(id)) + +/** + * \brief Determine if two derived (app-specific) IDs are equal + * + * This generic routine is implemented as a macro so it is agnostic to the actual argument type, + * and it will evaluate correctly so long as the argument type is based on the CFE_RESOURCEID_BASE_TYPE. + */ +#define CFE_RESOURCEID_TEST_EQUAL(id1,id2) CFE_ResourceId_Equal(CFE_RESOURCEID_UNWRAP(id1), CFE_RESOURCEID_UNWRAP(id2)) + +/** + * @brief Convert a resource ID to an integer. + * + * This is primarily intended for logging purposes, such was writing + * to debug console, event messages, or log files, using printf-like APIs. + * + * For compatibility with C library APIs, this returns an "unsigned long" + * type and should be used with the "%lx" format specifier in a printf + * format string. + * + * @note No assumptions should be made about the actual integer value, + * such as its base/range. It may be printed, but should not be modified + * or tested/compared using other arithmetic ops, and should never be used + * as the index to an array or table. See the related function + * CFE_ResourceId_ToIndex() for cases where a zero-based array/table index + * is needed. + * + * @sa CFE_ResourceId_FromInteger() + * + * @param[in] id Resource ID to convert + * @returns Integer value corresponding to ID + */ +static inline unsigned long CFE_ResourceId_ToInteger(CFE_ResourceId_t id) +{ + return ((unsigned long)CFE_RESOURCEID_UNWRAP(id)); +} + +/** + * @brief Convert an integer to a resource ID. + * + * This is the inverse of CFE_ResourceId_ToInteger(), and reconstitutes + * the original CFE_ResourceId_t value from the integer representation. + * + * This may be used, for instance, where an ID value is parsed from a text + * file or message using C library APIs such as scanf() or strtoul(). + * + * @sa CFE_ResourceId_ToInteger() + * + * @param[in] Value Integer value to convert + * @returns ID value corresponding to integer + */ +static inline CFE_ResourceId_t CFE_ResourceId_FromInteger(unsigned long Value) +{ + return ((CFE_ResourceId_t)CFE_RESOURCEID_WRAP(Value)); +} + +/** + * @brief Compare two Resource ID values for equality + * + * @param[in] id1 Resource ID to check + * @param[in] id2 Resource ID to check + * @returns true if id1 and id2 are equal, false otherwise. + */ +static inline bool CFE_ResourceId_Equal(CFE_ResourceId_t id1, CFE_ResourceId_t id2) +{ + return (CFE_RESOURCEID_UNWRAP(id1) == CFE_RESOURCEID_UNWRAP(id2)); +} + +/** + * @brief Check if a resource ID value is defined + * + * The constant #CFE_ES_RESOURCEID_UNDEFINED represents an undefined ID value, + * such that the expression: + * + * CFE_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_ResourceId_IsDefined(CFE_ResourceId_t id) +{ + return (CFE_RESOURCEID_UNWRAP(id) != 0); +} + +/** \} */ + + +/* + * Non-inline API functions provided by the Resource ID module + */ + +/** + * @brief Get the Base value (type/category) from a resource ID value + * + * This masks out the ID serial number to obtain the base value, which is different + * for each resource type. + * + * @note The value is NOT shifted or otherwise adjusted. It should match one of the + * defined base values in @ref CFEESResourceIDBase. + * + * @param[in] ResourceId the resource ID to decode + * @returns The base value associated with that ID + */ +extern uint32 CFE_ResourceId_GetBase(CFE_ResourceId_t ResourceId); + +/** + * @brief Get the Serial Number (sequential ID) from a resource ID value + * + * This masks out the ID base value to obtain the serial number, which is different + * for each entity created. + * + * @param[in] ResourceId the resource ID to decode + * @returns The serial number associated with that ID + */ +extern uint32 CFE_ResourceId_GetSerial(CFE_ResourceId_t ResourceId); + + +/** + * @brief Locate the next resource ID which does not map to an in-use table entry + * + * This begins searching from StartId which should be the most recently issued ID + * for the resource category. This will then search for the next ID which does + * _not_ map to a table entry that is in use. That is, it does not alias any + * valid ID when converted to an array index. + * + * returns an undefined ID value if no open slots are available + * + * @param[in] StartId the last issued ID for the resource category (app, lib, etc). + * @param[in] TableSize the maximum size of the target table + * @param[in] CheckFunc a function to check if the given ID is available + * @returns Next ID value which does not map to a valid entry + * @retval #CFE_ES_RESOURCEID_UNDEFINED if no open slots. + * + */ +extern CFE_ResourceId_t CFE_ResourceId_FindNext(CFE_ResourceId_t StartId, uint32 TableSize, bool (*CheckFunc)(CFE_ResourceId_t) ); + +/** + * @brief Internal routine to aid in converting an ES resource ID to an array index + + * @param[in] Id The resource ID + * @param[in] BaseValue The respective ID base value corresponding to the ID type + * @param[in] TableSize The actual size of the internal table (MAX index value + 1) + * @param[out] Idx The output index + * @returns Status code, CFE_SUCCESS if successful. + */ +extern int32 CFE_ResourceId_ToIndex(CFE_ResourceId_t Id, uint32 BaseValue, uint32 TableSize, uint32 *Idx); + + + +#endif /* CFE_RESOURCEID_H */ diff --git a/fsw/cfe-core/src/inc/cfe_sb.h b/fsw/cfe-core/src/inc/cfe_sb.h index e5073b506..e5a3eca59 100644 --- a/fsw/cfe-core/src/inc/cfe_sb.h +++ b/fsw/cfe-core/src/inc/cfe_sb.h @@ -43,7 +43,6 @@ #include "cfe_mission_cfg.h" #include "ccsds.h" #include "cfe_time.h" -#include "cfe_resourceid.h" /* @@ -123,12 +122,18 @@ #define CFE_CLR(i,x) ((i) &= ~CFE_BIT(x)) /**< \brief Clears bit x of i */ #define CFE_TST(i,x) (((i) & CFE_BIT(x)) != 0)/**< \brief true(non zero) if bit x of i is set */ +/** + * \brief Cast/Convert a generic CFE_ResourceId_t to a CFE_SB_PipeId_t + */ +#define CFE_SB_PIPEID_C(val) ((CFE_SB_PipeId_t)CFE_RESOURCEID_WRAP(val)) + + /** * \brief A CFE_SB_PipeId_t value which is always invalid * * This may be used as a safe initializer for CFE_SB_PipeId_t values */ -#define CFE_SB_INVALID_PIPE CFE_ES_RESOURCEID_UNDEFINED +#define CFE_SB_INVALID_PIPE CFE_SB_PIPEID_C(CFE_RESOURCEID_UNDEFINED) /* ** Pipe option bit fields. @@ -160,12 +165,6 @@ typedef CFE_MSG_TelemetryHeader_t CFE_SB_TlmHdr_t; #define CFE_SB_TLM_HDR_SIZE (sizeof(CFE_MSG_TelemetryHeader_t))/**< \brief Size of telemetry header */ #endif /* CFE_OMIT_DEPRECATED_6_8 */ -/** \brief CFE_SB_PipeId_t to primitive type definition -** -** Software Bus pipe identifier used in many SB APIs -*/ -typedef CFE_ES_ResourceID_t CFE_SB_PipeId_t; - #ifndef CFE_OMIT_DEPRECATED_6_8 /** \brief Pointer to an SB Message */ typedef CFE_MSG_Message_t *CFE_SB_MsgPtr_t; diff --git a/fsw/cfe-core/src/inc/cfe_sb_extern_typedefs.h b/fsw/cfe-core/src/inc/cfe_sb_extern_typedefs.h index 8eaea63e7..ae0b7fb3a 100644 --- a/fsw/cfe-core/src/inc/cfe_sb_extern_typedefs.h +++ b/fsw/cfe-core/src/inc/cfe_sb_extern_typedefs.h @@ -33,6 +33,7 @@ #include "common_types.h" #include "cfe_mission_cfg.h" +#include "cfe_resourceid_typedef.h" /** * @brief Label definitions associated with CFE_SB_QosPriority_Enum_t @@ -111,6 +112,14 @@ typedef uint32 CFE_SB_MsgId_Atom_t; */ typedef CFE_SB_MsgId_Atom_t CFE_SB_MsgId_t; +/** \brief CFE_SB_PipeId_t to primitive type definition + * + * Software Bus pipe identifier used in many SB APIs, as well as SB Telemetry messages + * and data files. + */ +typedef CFE_RESOURCEID_BASE_TYPE CFE_SB_PipeId_t; + + #endif /* CFE_EDS_ENABLED_BUILD */ #endif /* _CFE_SB_EXTERN_TYPEDEFS_H_ */ diff --git a/fsw/cfe-core/src/inc/cfe_sb_msg.h b/fsw/cfe-core/src/inc/cfe_sb_msg.h index 953f8b4a5..e9a67517c 100644 --- a/fsw/cfe-core/src/inc/cfe_sb_msg.h +++ b/fsw/cfe-core/src/inc/cfe_sb_msg.h @@ -633,7 +633,7 @@ typedef struct CFE_SB_PipeDepthStats { typedef struct CFE_SB_PipeInfoEntry { CFE_SB_PipeId_t PipeId; /**< The runtime ID of the pipe */ - CFE_ES_ResourceID_t AppId; /**< The runtime ID of the application that owns the pipe */ + CFE_ES_AppId_t AppId; /**< The runtime ID of the application that owns the pipe */ char PipeName[CFE_MISSION_MAX_API_LEN]; /**< The Name of the pipe */ char AppName[CFE_MISSION_MAX_API_LEN]; /**< The Name of the application that owns the pipe */ uint16 MaxQueueDepth; /**< The allocated depth of the pipe (max capacity) */ diff --git a/fsw/cfe-core/src/inc/private/cfe_core_resourceid_basevalues.h b/fsw/cfe-core/src/inc/private/cfe_core_resourceid_basevalues.h new file mode 100644 index 000000000..b89c9115f --- /dev/null +++ b/fsw/cfe-core/src/inc/private/cfe_core_resourceid_basevalues.h @@ -0,0 +1,89 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * \file cfe_core_resourceid_basevalues.h + * + * Contains CFE internal prototypes and definitions related to resource + * management and related CFE resource IDs. + * + * A CFE ES Resource ID is a common way to identify CFE-managed resources such + * as apps, tasks, counters, memory pools, CDS blocks, and other entities. + */ + +#ifndef CFE_CORE_RESOURCEID_BASEVALUES_H +#define CFE_CORE_RESOURCEID_BASEVALUES_H + +/* +** Include Files +*/ +#include "cfe_resourceid_basevalue.h" + +/* + * Assign unique offsets per resource types used in CFE core apps. + * + * Applications should not use these values directly, but rather + * in conjuction with the CFE_RESOURCEID_MAKE_BASE macro provided + * by the Resource ID module. (see below) + */ +enum +{ + /* + * Note for Task ID base value -- + * This currently shares the same offset as OSAL tasks, such that + * when "simple" (non-enforcing/backward-compatible) IDs are selected, + * the CFE task IDs and the OSAL task IDs end up as the same value. + * + * The "CFE_RESOURCEID_MARK" bit still differentiates the value when + * in strict mode, so there is no overlap in that case. + */ + CFE_RESOURCEID_ES_TASKID_BASE_OFFSET = OS_OBJECT_TYPE_OS_TASK, + + /* Other ES managed resources */ + CFE_RESOURCEID_ES_APPID_BASE_OFFSET = OS_OBJECT_TYPE_USER + 1, + CFE_RESOURCEID_ES_LIBID_BASE_OFFSET = OS_OBJECT_TYPE_USER + 2, + CFE_RESOURCEID_ES_COUNTID_BASE_OFFSET = OS_OBJECT_TYPE_USER + 3, + CFE_RESOURCEID_ES_POOLID_BASE_OFFSET = OS_OBJECT_TYPE_USER + 4, + CFE_RESOURCEID_ES_CDSBLOCKID_BASE_OFFSET = OS_OBJECT_TYPE_USER + 5, + + /* SB managed resources */ + CFE_RESOURCEID_SB_PIPEID_RESOURCE_BASE_OFFSET = OS_OBJECT_TYPE_USER + 6 +}; + +/* + * Assign actual base values from the offsets above + * + * Using "enum" ensures these are resolved as integers now, as opposed at to the point of use like macros. + */ +enum +{ + /* ES managed resources */ + CFE_ES_TASKID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_ES_TASKID_BASE_OFFSET), + CFE_ES_APPID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_ES_APPID_BASE_OFFSET), + CFE_ES_LIBID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_ES_LIBID_BASE_OFFSET), + CFE_ES_COUNTID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_ES_COUNTID_BASE_OFFSET), + CFE_ES_POOLID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_ES_POOLID_BASE_OFFSET), + CFE_ES_CDSBLOCKID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_ES_CDSBLOCKID_BASE_OFFSET), + + /* SB managed resources */ + CFE_SB_PIPEID_BASE = CFE_RESOURCEID_MAKE_BASE(CFE_RESOURCEID_SB_PIPEID_RESOURCE_BASE_OFFSET) +}; + +#endif /* CFE_CORE_RESOURCEID_BASEVALUES_H */ diff --git a/fsw/cfe-core/src/inc/private/cfe_es_erlog_typedef.h b/fsw/cfe-core/src/inc/private/cfe_es_erlog_typedef.h index c2bcfe8a5..a2193ae5c 100644 --- a/fsw/cfe-core/src/inc/private/cfe_es_erlog_typedef.h +++ b/fsw/cfe-core/src/inc/private/cfe_es_erlog_typedef.h @@ -93,7 +93,7 @@ typedef struct typedef struct { CFE_ES_ERLog_BaseInfo_t BaseInfo; /**< Core Log Data */ - CFE_ES_ResourceID_t AppID; /* The application ID */ + CFE_ES_AppId_t AppID; /* The application ID */ uint32 PspContextId; /**< Reference to context information stored in PSP */ } CFE_ES_ERLog_MetaData_t; diff --git a/fsw/cfe-core/src/inc/private/cfe_private.h b/fsw/cfe-core/src/inc/private/cfe_private.h index a2f1b0152..56078a913 100644 --- a/fsw/cfe-core/src/inc/private/cfe_private.h +++ b/fsw/cfe-core/src/inc/private/cfe_private.h @@ -226,7 +226,7 @@ extern int32 CFE_FS_EarlyInit(void); ** the specified application from the Critical Data Store. ** ******************************************************************************/ -extern int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId); +extern int32 CFE_TBL_CleanUpApp(CFE_ES_AppId_t AppId); /*****************************************************************************/ /** @@ -238,7 +238,7 @@ extern int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId); ** that have been allocated to the specified Application. ** ******************************************************************************/ -extern int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId); +extern int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId); /*****************************************************************************/ /** @@ -250,7 +250,7 @@ extern int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId); ** that have been allocated to the specified Application. ** ******************************************************************************/ -extern int32 CFE_EVS_CleanUpApp(CFE_ES_ResourceID_t AppId); +extern int32 CFE_EVS_CleanUpApp(CFE_ES_AppId_t AppId); /*****************************************************************************/ /** @@ -262,7 +262,7 @@ extern int32 CFE_EVS_CleanUpApp(CFE_ES_ResourceID_t AppId); ** that have been allocated to the specified Application. ** ******************************************************************************/ -extern int32 CFE_TIME_CleanUpApp(CFE_ES_ResourceID_t AppId); +extern int32 CFE_TIME_CleanUpApp(CFE_ES_AppId_t AppId); /*****************************************************************************/ diff --git a/fsw/cfe-core/src/inc/private/cfe_resourceid_internal.h b/fsw/cfe-core/src/inc/private/cfe_resourceid_internal.h deleted file mode 100644 index cf9969fa7..000000000 --- a/fsw/cfe-core/src/inc/private/cfe_resourceid_internal.h +++ /dev/null @@ -1,165 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/** - * \file cfe_resourceid_internal.h - * - * Contains CFE internal prototypes and definitions related to resource - * management and related CFE resource IDs. - * - * A CFE ES Resource ID is a common way to identify CFE-managed resources such - * as apps, tasks, counters, memory pools, CDS blocks, and other entities. - */ - -#ifndef CFE_RESOURCEID_INTERNAL_H -#define CFE_RESOURCEID_INTERNAL_H - -/* -** Include Files -*/ -#include "cfe_resourceid.h" -#include "osapi-idmap.h" - -/* -** Defines -*/ - -/* - * Limits/definitions related to CFE_ES_ResourceID_t values. - * - * Defining based on OSAL ID values makes this object a superset of - * the OSAL ID type, such that OSAL IDs can be represented as ES resource IDs - * and not conflict with/alias each other. - * - * NOTE: This reflects a bit if "inside knowledge" about how OSAL IDs are - * constructed. The overlap between OSAL IDs and ES IDs may not always be - * consistent, and they can diverge in a future version. - */ -#define CFE_ES_RESOURCEID_SHIFT OS_OBJECT_TYPE_SHIFT -#define CFE_ES_RESOURCEID_MAX ((1 << CFE_ES_RESOURCEID_SHIFT)-1) -#define CFE_ES_RESOURCEID_MARK (0x02000000) - -/** - * @defgroup CFEResourceIDBase Resource ID base values - * @{ - */ - -/* ES managed resources */ -#define CFE_ES_APPID_BASE (CFE_ES_RESOURCEID_MARK | ((OS_OBJECT_TYPE_USER+1) << CFE_ES_RESOURCEID_SHIFT)) -#define CFE_ES_LIBID_BASE (CFE_ES_RESOURCEID_MARK | ((OS_OBJECT_TYPE_USER+2) << CFE_ES_RESOURCEID_SHIFT)) -#define CFE_ES_COUNTID_BASE (CFE_ES_RESOURCEID_MARK | ((OS_OBJECT_TYPE_USER+3) << CFE_ES_RESOURCEID_SHIFT)) -#define CFE_ES_POOLID_BASE (CFE_ES_RESOURCEID_MARK | ((OS_OBJECT_TYPE_USER+4) << CFE_ES_RESOURCEID_SHIFT)) -#define CFE_ES_CDSBLOCKID_BASE (CFE_ES_RESOURCEID_MARK | ((OS_OBJECT_TYPE_USER+5) << CFE_ES_RESOURCEID_SHIFT)) - -/* SB managed resources */ -#define CFE_SB_PIPEID_BASE (CFE_ES_RESOURCEID_MARK | ((OS_OBJECT_TYPE_USER+6) << CFE_ES_RESOURCEID_SHIFT)) - -/** @} */ - - -/** - * @brief Get the Base value (type/category) from a resource ID value - * - * This masks out the ID serial number to obtain the base value, which is different - * for each resource type. - * - * @note The value is NOT shifted or otherwise adjusted. It should match one of the - * defined base values in @ref CFEESResourceIDBase. - * - * @param[in] ResourceId the resource ID to decode - * @returns The base value associated with that ID - */ -static inline uint32 CFE_ES_ResourceID_GetBase(CFE_ES_ResourceID_t ResourceId) -{ - uint32 ResourceType = CFE_ES_ResourceID_ToInteger(ResourceId); - return (ResourceType - (ResourceType & CFE_ES_RESOURCEID_MAX)); -} - -/** - * @brief Locate the next resource ID which does not map to an in-use table entry - * - * This begins searching from StartId which should be the most recently issued ID - * for the resource category. This will then search for the next ID which does - * _not_ map to a table entry that is in use. That is, it does not alias any - * valid ID when converted to an array index. - * - * returns an undefined ID value if no open slots are available - * - * @param[in] StartId the last issued ID for the resource category (app, lib, etc). - * @param[in] TableSize the maximum size of the target table - * @param[in] CheckFunc a function to check if the given ID is available - * @returns Next ID value which does not map to a valid entry - * @retval #CFE_ES_RESOURCEID_UNDEFINED if no open slots. - * - */ -CFE_ES_ResourceID_t CFE_ES_FindNextAvailableId(CFE_ES_ResourceID_t StartId, uint32 TableSize, bool (*CheckFunc)(CFE_ES_ResourceID_t) ); - -/** - * @brief Convert an ES Task ID to an OSAL task ID - * - * Task IDs created via CFE ES are also OSAL task IDs, but technically - * do refer to a different scope and therefore have a different type - * to represent them. - * - * This function facilitates converting between the types. - * - * @note Currently the numeric values are the same and can be interchanged - * for backward compatibility, however they may diverge in a future version. - * New code should not assume equivalence between OSAL and ES task IDs. - * - * @sa CFE_ES_ResourceID_FromOSAL - * - * @param[in] id The ES task ID - * @returns The OSAL task ID - */ -osal_id_t CFE_ES_ResourceID_ToOSAL(CFE_ES_ResourceID_t id); - -/** - * @brief Convert an ES Task ID to an OSAL task ID - * - * Task IDs created via CFE ES are also OSAL task IDs, but technically - * do refer to a different scope and therefore have a different type - * to represent them. - * - * This function facilitates converting between the types. - * - * @note Currently the numeric values are the same and can be interchanged - * for backward compatibility, however they may diverge in a future version. - * New code should not assume equivalence between OSAL and ES task IDs. - * - * @sa CFE_ES_ResourceID_ToOSAL - * - * @param[in] id The OSAL task ID - * @returns The ES task ID - */ -CFE_ES_ResourceID_t CFE_ES_ResourceID_FromOSAL(osal_id_t id); - -/** - * @brief Internal routine to aid in converting an ES resource ID to an array index - - * @param[in] Serial The resource serial number (type info masked out) - * @param[in] TableSize The size of the internal table (MAX value) - * @param[out] Idx The output index - * @returns Status code, CFE_SUCCESS if successful. - */ -int32 CFE_ES_ResourceID_ToIndex(uint32 Serial, uint32 TableSize, uint32 *Idx); - - -#endif /* CFE_RESOURCEID_H */ diff --git a/fsw/cfe-core/src/sb/cfe_sb_api.c b/fsw/cfe-core/src/sb/cfe_sb_api.c index f4a8cdcf8..d881e9e7d 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_api.c +++ b/fsw/cfe-core/src/sb/cfe_sb_api.c @@ -68,6 +68,7 @@ #include "cfe_psp.h" #include "cfe_error.h" #include +#include "private/cfe_core_resourceid_basevalues.h" /* * Macro to reflect size of PipeDepthStats Telemetry array - @@ -88,8 +89,8 @@ typedef struct */ CFE_Status_t CFE_SB_PipeId_ToIndex(CFE_SB_PipeId_t PipeID, uint32 *Idx) { - return CFE_ES_ResourceID_ToIndex( - CFE_ES_ResourceID_ToInteger(PipeID) - CFE_SB_PIPEID_BASE, + return CFE_ResourceId_ToIndex(CFE_RESOURCEID_UNWRAP(PipeID), + CFE_SB_PIPEID_BASE, CFE_PLATFORM_SB_MAX_PIPES, Idx); } @@ -99,12 +100,12 @@ CFE_Status_t CFE_SB_PipeId_ToIndex(CFE_SB_PipeId_t PipeID, uint32 *Idx) */ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName) { - CFE_ES_ResourceID_t AppId; - CFE_ES_ResourceID_t TskId; + CFE_ES_AppId_t AppId; + CFE_ES_TaskId_t TskId; osal_id_t SysQueueId; int32 Status; CFE_SB_PipeD_t *PipeDscPtr; - CFE_SB_PipeId_t PendingPipeId; + CFE_ResourceId_t PendingPipeId; uint16 PendingEventId; char FullName[(OS_MAX_API_NAME * 2)]; @@ -137,8 +138,8 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * CFE_SB_LockSharedData(__func__,__LINE__); /* get first available entry in pipe table */ - PendingPipeId = CFE_ES_FindNextAvailableId(CFE_SB.LastPipeId, CFE_PLATFORM_SB_MAX_PIPES, CFE_SB_CheckPipeDescSlotUsed); - PipeDscPtr = CFE_SB_LocatePipeDescByID(PendingPipeId); + PendingPipeId = CFE_ResourceId_FindNext(CFE_SB.LastPipeId, CFE_PLATFORM_SB_MAX_PIPES, CFE_SB_CheckPipeDescSlotUsed); + PipeDscPtr = CFE_SB_LocatePipeDescByID(CFE_SB_PIPEID_C(PendingPipeId)); /* if pipe table is full, send event and return error */ if(PipeDscPtr == NULL) @@ -151,7 +152,7 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * /* Fully clear the entry, just in case of stale data */ memset(PipeDscPtr, 0, sizeof(*PipeDscPtr)); - CFE_SB_PipeDescSetUsed(PipeDscPtr, CFE_ES_RESOURCEID_RESERVED); + CFE_SB_PipeDescSetUsed(PipeDscPtr, CFE_RESOURCEID_RESERVED); CFE_SB.LastPipeId = PendingPipeId; } @@ -217,7 +218,7 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * CFE_SB_PipeDescSetFree(PipeDscPtr); PipeDscPtr = NULL; } - PendingPipeId = CFE_ES_RESOURCEID_UNDEFINED; + PendingPipeId = CFE_RESOURCEID_UNDEFINED; /* * If there is a relevant error counter, increment it now @@ -242,11 +243,11 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * /* send debug event */ CFE_EVS_SendEventWithAppID(CFE_SB_PIPE_ADDED_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, "Pipe Created:name %s,id %d,app %s", - PipeName, (int)CFE_ES_ResourceID_ToInteger(PendingPipeId), + PipeName, (int)CFE_ResourceId_ToInteger(PendingPipeId), CFE_SB_GetAppTskName(TskId,FullName)); /* give the pipe handle to the caller */ - *PipeIdPtr = PendingPipeId; + *PipeIdPtr = CFE_SB_PIPEID_C(PendingPipeId); } else { @@ -291,7 +292,7 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * */ int32 CFE_SB_DeletePipe(CFE_SB_PipeId_t PipeId) { - CFE_ES_ResourceID_t CallerId; + CFE_ES_AppId_t CallerId; int32 Status = 0; /* get the callers Application Id */ @@ -317,7 +318,7 @@ int32 CFE_SB_DeletePipe(CFE_SB_PipeId_t PipeId) ** Return: ** CFE_SUCCESS or cFE Error Code */ -int32 CFE_SB_DeletePipeWithAppId(CFE_SB_PipeId_t PipeId, CFE_ES_ResourceID_t AppId) +int32 CFE_SB_DeletePipeWithAppId(CFE_SB_PipeId_t PipeId, CFE_ES_AppId_t AppId) { int32 Status = 0; @@ -360,11 +361,11 @@ void CFE_SB_RemovePipeFromRoute(CFE_SBR_RouteId_t RouteId, void *ArgPtr) ** Return: ** CFE_SUCCESS or cFE Error Code */ -int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) +int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_AppId_t AppId) { CFE_SB_PipeD_t *PipeDscPtr; int32 Status; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; CFE_SB_BufferD_t *BufDscPtr; osal_id_t SysQueueId; char FullName[(OS_MAX_API_NAME * 2)]; @@ -388,7 +389,7 @@ int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) Status = CFE_SB_BAD_ARGUMENT; } /* check that the given AppId is the owner of the pipe */ - else if (!CFE_ES_ResourceID_Equal(AppId, PipeDscPtr->AppId)) + else if (!CFE_RESOURCEID_TEST_EQUAL(AppId, PipeDscPtr->AppId)) { PendingEventID = CFE_SB_DEL_PIPE_ERR2_EID; Status = CFE_SB_BAD_ARGUMENT; @@ -417,7 +418,7 @@ int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) * from trying to use this Pipe Desc slot, and also should prevents * any task from re-subscribing to this pipe. */ - CFE_SB_PipeDescSetUsed(PipeDscPtr, CFE_ES_RESOURCEID_RESERVED); + CFE_SB_PipeDescSetUsed(PipeDscPtr, CFE_RESOURCEID_RESERVED); } CFE_SB_UnlockSharedData(__func__,__LINE__); @@ -475,7 +476,7 @@ int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) CFE_ES_GetAppName(FullName, AppId, sizeof(FullName)); CFE_EVS_SendEventWithAppID(CFE_SB_PIPE_DELETED_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, - "Pipe Deleted:id %d,owner %s",(int)CFE_ES_ResourceID_ToInteger(PipeId), FullName); + "Pipe Deleted:id %d,owner %s",(int)CFE_RESOURCEID_TO_ULONG(PipeId), FullName); } else { @@ -488,12 +489,12 @@ int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) case CFE_SB_DEL_PIPE_ERR1_EID: CFE_EVS_SendEventWithAppID(CFE_SB_DEL_PIPE_ERR1_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Pipe Delete Error:Bad Argument,PipedId %ld,Requestor %s", - CFE_ES_ResourceID_ToInteger(PipeId),FullName); + CFE_RESOURCEID_TO_ULONG(PipeId),FullName); break; case CFE_SB_DEL_PIPE_ERR2_EID: CFE_EVS_SendEventWithAppID(CFE_SB_DEL_PIPE_ERR2_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Pipe Delete Error:Caller(%s) is not the owner of pipe %ld", - FullName, CFE_ES_ResourceID_ToInteger(PipeId)); + FullName, CFE_RESOURCEID_TO_ULONG(PipeId)); break; } } @@ -509,8 +510,8 @@ int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId) int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) { CFE_SB_PipeD_t *PipeDscPtr; - CFE_ES_ResourceID_t AppID; - CFE_ES_ResourceID_t TskId; + CFE_ES_AppId_t AppID; + CFE_ES_TaskId_t TskId; uint16 PendingEventID; int32 Status; char FullName[(OS_MAX_API_NAME * 2)]; @@ -535,7 +536,7 @@ int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) Status = CFE_SB_BAD_ARGUMENT; } /* check that the caller AppId is the owner of the pipe */ - else if( !CFE_ES_ResourceID_Equal(AppID, PipeDscPtr->AppId) ) + else if( !CFE_RESOURCEID_TEST_EQUAL(AppID, PipeDscPtr->AppId) ) { PendingEventID = CFE_SB_SETPIPEOPTS_OWNER_ERR_EID; Status = CFE_SB_BAD_ARGUMENT; @@ -560,7 +561,7 @@ int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) CFE_ES_GetAppName(FullName, AppID, sizeof(FullName)); CFE_EVS_SendEventWithAppID(CFE_SB_SETPIPEOPTS_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, - "Pipe opts set:id %lu,owner %s, opts=0x%02x",CFE_ES_ResourceID_ToInteger(PipeId), FullName, (unsigned int)Opts); + "Pipe opts set:id %lu,owner %s, opts=0x%02x",CFE_RESOURCEID_TO_ULONG(PipeId), FullName, (unsigned int)Opts); } else { @@ -572,12 +573,12 @@ int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) case CFE_SB_SETPIPEOPTS_ID_ERR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_SETPIPEOPTS_ID_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Pipe Opts Error:Bad Argument,PipedId %lu,Requestor %s", - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_SETPIPEOPTS_OWNER_ERR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_SETPIPEOPTS_OWNER_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Pipe Opts Set Error: Caller(%s) is not the owner of pipe %lu", - CFE_SB_GetAppTskName(TskId,FullName),CFE_ES_ResourceID_ToInteger(PipeId)); + CFE_SB_GetAppTskName(TskId,FullName),CFE_RESOURCEID_TO_ULONG(PipeId)); break; } } @@ -591,7 +592,7 @@ int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) int32 CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptsPtr) { int32 Status; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; uint16 PendingEventID; CFE_SB_PipeD_t *PipeDscPtr; @@ -631,7 +632,7 @@ int32 CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptsPtr) if (Status == CFE_SUCCESS) { CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPEOPTS_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, - "Pipe opts get:id %lu, opts=0x%02x",CFE_ES_ResourceID_ToInteger(PipeId), (unsigned int)*OptsPtr); + "Pipe opts get:id %lu, opts=0x%02x",CFE_RESOURCEID_TO_ULONG(PipeId), (unsigned int)*OptsPtr); } else { @@ -648,7 +649,7 @@ int32 CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptsPtr) case CFE_SB_GETPIPEOPTS_ID_ERR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPEOPTS_ID_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB.AppId, "Pipe Opts Error:Bad Argument,PipedId %lu,Requestor %s", - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); break; } } @@ -662,7 +663,7 @@ int32 CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptsPtr) int32 CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t PipeId) { int32 Status; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; uint16 PendingEventID; CFE_SB_PipeD_t *PipeDscPtr; @@ -718,7 +719,7 @@ int32 CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPENAME_EID, CFE_EVS_EventType_DEBUG,CFE_SB.AppId, "GetPipeName name=%s id=%lu", - PipeNameBuf, CFE_ES_ResourceID_ToInteger(PipeId)); + PipeNameBuf, CFE_RESOURCEID_TO_ULONG(PipeId)); } else { @@ -734,7 +735,7 @@ int32 CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t case CFE_SB_GETPIPENAME_ID_ERR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPENAME_ID_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB.AppId, "Pipe Id Error:Bad Argument,Id=%lu,Requestor %s", - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); break; } @@ -754,7 +755,7 @@ int32 CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) { int32 Status; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; uint32 Idx; char FullName[(OS_MAX_API_NAME * 2)]; uint16 PendingEventID; @@ -825,7 +826,7 @@ int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) CFE_EVS_SendEventWithAppID(CFE_SB_GETPIPEIDBYNAME_EID, CFE_EVS_EventType_DEBUG,CFE_SB.AppId, "PipeIdByName name=%s id=%lu", - PipeName, CFE_ES_ResourceID_ToInteger(*PipeIdPtr)); + PipeName, CFE_RESOURCEID_TO_ULONG(*PipeIdPtr)); } else { @@ -934,8 +935,8 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, CFE_SBR_RouteId_t RouteId; CFE_SB_PipeD_t *PipeDscPtr; int32 Status; - CFE_ES_ResourceID_t TskId; - CFE_ES_ResourceID_t AppId; + CFE_ES_TaskId_t TskId; + CFE_ES_AppId_t AppId; CFE_SB_DestinationD_t *DestPtr; uint32 DestCount; char FullName[(OS_MAX_API_NAME * 2)]; @@ -964,7 +965,7 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, PendingEventID = CFE_SB_SUB_INV_PIPE_EID; Status = CFE_SB_BAD_ARGUMENT; } - else if (!CFE_ES_ResourceID_Equal(PipeDscPtr->AppId, AppId)) + else if (!CFE_RESOURCEID_TEST_EQUAL(PipeDscPtr->AppId, AppId)) { PendingEventID = CFE_SB_SUB_INV_CALLER_EID; Status = CFE_SB_BAD_ARGUMENT; @@ -1015,7 +1016,7 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, ++DestCount; /* Check if duplicate (status stays as CFE_SUCCESS) */ - if (CFE_ES_ResourceID_Equal(DestPtr->PipeId, PipeId)) + if (CFE_RESOURCEID_TEST_EQUAL(DestPtr->PipeId, PipeId)) { PendingEventID = CFE_SB_DUP_SUBSCRIP_EID; break; @@ -1099,7 +1100,7 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, case CFE_SB_SUB_INV_CALLER_EID: CFE_EVS_SendEventWithAppID(CFE_SB_SUB_INV_CALLER_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Subscribe Err:Caller(%s) is not the owner of pipe %lu,Msg=0x%x", - CFE_SB_GetAppTskName(TskId,FullName),CFE_ES_ResourceID_ToInteger(PipeId), + CFE_SB_GetAppTskName(TskId,FullName),CFE_RESOURCEID_TO_ULONG(PipeId), (unsigned int)CFE_SB_MsgIdToValue(MsgId)); break; @@ -1107,7 +1108,7 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, CFE_EVS_SendEventWithAppID(CFE_SB_SUB_INV_PIPE_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Subscribe Err:Invalid Pipe Id,Msg=0x%x,PipeId=%lu,App %s", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(PipeId), CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId), CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_DEST_BLK_ERR_EID: @@ -1134,7 +1135,7 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, CFE_EVS_SendEventWithAppID(CFE_SB_SUB_ARG_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Subscribe Err:Bad Arg,MsgId 0x%x,PipeId %lu,app %s,scope %d", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName),Scope); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName),Scope); break; } } @@ -1144,7 +1145,7 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_RCVD_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, "Subscription Rcvd:MsgId 0x%x on %s(%lu),app %s", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - PipeName,CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + PipeName,CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); } if (Status == CFE_SUCCESS && Scope == CFE_SB_GLOBAL) @@ -1169,7 +1170,7 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, */ int32 CFE_SB_Unsubscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) { - CFE_ES_ResourceID_t CallerId; + CFE_ES_AppId_t CallerId; int32 Status = 0; /* get the callers Application Id */ @@ -1187,7 +1188,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) { - CFE_ES_ResourceID_t CallerId; + CFE_ES_AppId_t CallerId; int32 Status = 0; /* get the callers Application Id */ @@ -1224,7 +1225,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, - CFE_ES_ResourceID_t AppId) + CFE_ES_AppId_t AppId) { int32 Status = 0; @@ -1264,11 +1265,11 @@ int32 CFE_SB_UnsubscribeWithAppId(CFE_SB_MsgId_t MsgId, ** ******************************************************************************/ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId,CFE_SB_PipeId_t PipeId, - uint8 Scope,CFE_ES_ResourceID_t AppId) + uint8 Scope,CFE_ES_AppId_t AppId) { int32 Status; CFE_SBR_RouteId_t RouteId; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; CFE_SB_DestinationD_t *DestPtr; char FullName[(OS_MAX_API_NAME * 2)]; char PipeName[OS_MAX_API_NAME]; @@ -1293,7 +1294,7 @@ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId,CFE_SB_PipeId_t PipeId, Status = CFE_SB_BAD_ARGUMENT; } /* if given 'AppId' is not the owner of the pipe, send error event and return */ - else if (!CFE_ES_ResourceID_Equal(PipeDscPtr->AppId, AppId)) + else if (!CFE_RESOURCEID_TEST_EQUAL(PipeDscPtr->AppId, AppId)) { PendingEventID = CFE_SB_UNSUB_INV_CALLER_EID; Status = CFE_SB_BAD_ARGUMENT; @@ -1350,13 +1351,13 @@ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId,CFE_SB_PipeId_t PipeId, CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_INV_PIPE_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Unsubscribe Err:Invalid Pipe Id Msg=0x%x,Pipe=%lu,app=%s", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_UNSUB_INV_CALLER_EID: CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_INV_CALLER_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Unsubscribe Err:Caller(%s) is not the owner of pipe %lu,Msg=0x%x", - CFE_SB_GetAppTskName(TskId,FullName),CFE_ES_ResourceID_ToInteger(PipeId), + CFE_SB_GetAppTskName(TskId,FullName),CFE_RESOURCEID_TO_ULONG(PipeId), (unsigned int)CFE_SB_MsgIdToValue(MsgId)); break; @@ -1364,7 +1365,7 @@ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId,CFE_SB_PipeId_t PipeId, CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_ARG_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "UnSubscribe Err:Bad Arg,MsgId 0x%x,PipeId %lu,app %s,scope %d", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName),(int)Scope); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName),(int)Scope); break; } } @@ -1374,7 +1375,7 @@ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId,CFE_SB_PipeId_t PipeId, CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_REMOVED_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, "Subscription Removed:Msg 0x%x on pipe %lu,app %s", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); } return Status; @@ -1388,7 +1389,7 @@ int32 CFE_SB_TransmitMsg(CFE_MSG_Message_t *MsgPtr, bool IncrementSequenceCount int32 Status; CFE_MSG_Size_t Size = 0; CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; CFE_SB_BufferD_t *BufDscPtr; CFE_SBR_RouteId_t RouteId; @@ -1502,7 +1503,7 @@ int32 CFE_SB_TransmitMsgValidate(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Size_t *SizePtr, CFE_SBR_RouteId_t *RouteIdPtr) { - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; uint16 PendingEventID; int32 Status; @@ -1620,8 +1621,8 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_t RouteId, CFE_SB_MsgId_t MsgId) { - CFE_ES_ResourceID_t AppId; - CFE_ES_ResourceID_t TskId; + CFE_ES_AppId_t AppId; + CFE_ES_TaskId_t TskId; CFE_SB_DestinationD_t *DestPtr; CFE_SB_PipeD_t *PipeDscPtr; CFE_SB_EventBuf_t SBSndErr; @@ -1660,7 +1661,7 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, } if((PipeDscPtr->Opts & CFE_SB_PIPEOPTS_IGNOREMINE) != 0 && - CFE_ES_ResourceID_Equal(PipeDscPtr->AppId, AppId)) + CFE_RESOURCEID_TEST_EQUAL(PipeDscPtr->AppId, AppId)) { continue; }/* end if */ @@ -1825,7 +1826,7 @@ int32 CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeD_t *PipeDscPtr; CFE_SB_DestinationD_t *DestPtr; CFE_SBR_RouteId_t RouteId; - CFE_ES_ResourceID_t TskId; + CFE_ES_TaskId_t TskId; uint16 PendingEventID; osal_id_t SysQueueId; int32 SysTimeout; @@ -2043,17 +2044,17 @@ int32 CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, case CFE_SB_Q_RD_ERR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_Q_RD_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Pipe Read Err,pipe %lu,app %s,stat 0x%x", - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName),(unsigned int)RcvStatus); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName),(unsigned int)RcvStatus); break; case CFE_SB_RCV_BAD_ARG_EID: CFE_EVS_SendEventWithAppID(CFE_SB_RCV_BAD_ARG_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Rcv Err:Bad Input Arg:BufPtr 0x%lx,pipe %lu,t/o %d,app %s", - (unsigned long)BufPtr,CFE_ES_ResourceID_ToInteger(PipeId),(int)TimeOut,CFE_SB_GetAppTskName(TskId,FullName)); + (unsigned long)BufPtr,CFE_RESOURCEID_TO_ULONG(PipeId),(int)TimeOut,CFE_SB_GetAppTskName(TskId,FullName)); break; case CFE_SB_BAD_PIPEID_EID: CFE_EVS_SendEventWithAppID(CFE_SB_BAD_PIPEID_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "Rcv Err:PipeId %lu does not exist,app %s", - CFE_ES_ResourceID_ToInteger(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); + CFE_RESOURCEID_TO_ULONG(PipeId),CFE_SB_GetAppTskName(TskId,FullName)); break; } } @@ -2075,7 +2076,7 @@ CFE_SB_Buffer_t *CFE_SB_ZeroCopyGetPtr(size_t MsgSize, CFE_SB_ZeroCopyHandle_t *BufferHandle) { int32 stat1; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; cpuaddr address = 0; CFE_SB_ZeroCopyD_t *zcd = NULL; CFE_SB_BufferD_t *bd = NULL; diff --git a/fsw/cfe-core/src/sb/cfe_sb_init.c b/fsw/cfe-core/src/sb/cfe_sb_init.c index 1ddd99e66..49ecaec09 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_init.c +++ b/fsw/cfe-core/src/sb/cfe_sb_init.c @@ -40,6 +40,7 @@ #include "cfe_psp.h" #include "cfe_error.h" #include "cfe_sb_events.h" +#include "private/cfe_core_resourceid_basevalues.h" #include @@ -180,7 +181,7 @@ int32 CFE_SB_InitBuffers(void) { */ void CFE_SB_InitPipeTbl(void) { - CFE_SB.LastPipeId = CFE_ES_ResourceID_FromInteger(CFE_SB_PIPEID_BASE); + CFE_SB.LastPipeId = CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE); }/* end CFE_SB_InitPipeTbl */ diff --git a/fsw/cfe-core/src/sb/cfe_sb_priv.c b/fsw/cfe-core/src/sb/cfe_sb_priv.c index 71aa77d78..fe38eb197 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_priv.c +++ b/fsw/cfe-core/src/sb/cfe_sb_priv.c @@ -98,7 +98,7 @@ ** Return: ** None */ -int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId) { uint32 i; uint32 DelCount; @@ -114,7 +114,7 @@ int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId) for (i = 0; i < CFE_PLATFORM_SB_MAX_PIPES; ++i) { if (CFE_SB_PipeDescIsUsed(PipeDscPtr) && - CFE_ES_ResourceID_Equal(PipeDscPtr->AppId, AppId)) + CFE_RESOURCEID_TEST_EQUAL(PipeDscPtr->AppId, AppId)) { DelList[DelCount] = CFE_SB_PipeDescGetID(PipeDscPtr); ++DelCount; @@ -154,7 +154,7 @@ int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId) void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber){ int32 Status; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; Status = OS_MutSemTake(CFE_SB.SharedDataMutexId); if (Status != OS_SUCCESS) { @@ -162,7 +162,7 @@ void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber){ CFE_ES_GetAppID(&AppId); CFE_ES_WriteToSysLog("SB SharedData Mutex Take Err Stat=0x%x,App=%lu,Func=%s,Line=%d\n", - (unsigned int)Status,CFE_ES_ResourceID_ToInteger(AppId),FuncName,(int)LineNumber); + (unsigned int)Status,CFE_RESOURCEID_TO_ULONG(AppId),FuncName,(int)LineNumber); }/* end if */ @@ -189,7 +189,7 @@ void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber){ void CFE_SB_UnlockSharedData(const char *FuncName, int32 LineNumber){ int32 Status; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; Status = OS_MutSemGive(CFE_SB.SharedDataMutexId); if (Status != OS_SUCCESS) { @@ -197,7 +197,7 @@ void CFE_SB_UnlockSharedData(const char *FuncName, int32 LineNumber){ CFE_ES_GetAppID(&AppId); CFE_ES_WriteToSysLog("SB SharedData Mutex Give Err Stat=0x%x,App=%lu,Func=%s,Line=%d\n", - (unsigned int)Status,CFE_ES_ResourceID_ToInteger(AppId),FuncName,(int)LineNumber); + (unsigned int)Status,CFE_RESOURCEID_TO_ULONG(AppId),FuncName,(int)LineNumber); }/* end if */ @@ -218,7 +218,7 @@ CFE_SB_DestinationD_t *CFE_SB_GetDestPtr(CFE_SBR_RouteId_t RouteId, CFE_SB_PipeI /* Check all destinations */ while(destptr != NULL) { - if( CFE_ES_ResourceID_Equal(destptr->PipeId, PipeId) ) + if( CFE_RESOURCEID_TEST_EQUAL(destptr->PipeId, PipeId) ) { break; } @@ -303,9 +303,9 @@ CFE_SB_PipeD_t *CFE_SB_LocatePipeDescByID(CFE_SB_PipeId_t PipeId) * * Checks if a table slot is used or not (helper for allocating IDs) */ -bool CFE_SB_CheckPipeDescSlotUsed(CFE_SB_PipeId_t CheckId) +bool CFE_SB_CheckPipeDescSlotUsed(CFE_ResourceId_t CheckId) { - return CFE_SB_PipeDescIsUsed(CFE_SB_LocatePipeDescByID(CheckId)); + return CFE_SB_PipeDescIsUsed(CFE_SB_LocatePipeDescByID(CFE_SB_PIPEID_C(CheckId))); } /****************************************************************************** @@ -324,7 +324,7 @@ bool CFE_SB_CheckPipeDescSlotUsed(CFE_SB_PipeId_t CheckId) ** Note: With taskId, Parent App name and Child Task name can be queried from ES ** */ -char *CFE_SB_GetAppTskName(CFE_ES_ResourceID_t TaskId,char *FullName){ +char *CFE_SB_GetAppTskName(CFE_ES_TaskId_t TaskId,char *FullName){ CFE_ES_TaskInfo_t TaskInfo; CFE_ES_TaskInfo_t *ptr = &TaskInfo; @@ -374,7 +374,7 @@ char *CFE_SB_GetAppTskName(CFE_ES_ResourceID_t TaskId,char *FullName){ ** If the bit is set this function will return CFE_SB_DENIED. ** If bit is not set, this function set the bit and return CFE_SB_GRANTED. */ -uint32 CFE_SB_RequestToSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit){ +uint32 CFE_SB_RequestToSendEvent(CFE_ES_TaskId_t TaskId, uint32 Bit){ uint32 Indx; @@ -411,7 +411,7 @@ uint32 CFE_SB_RequestToSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit){ ** If the bit is set this function will return CFE_SB_DENIED. ** If bit is not set, this function set the bit and return CFE_SB_GRANTED. */ -void CFE_SB_FinishSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit){ +void CFE_SB_FinishSendEvent(CFE_ES_TaskId_t TaskId, uint32 Bit){ uint32 Indx; @@ -533,14 +533,14 @@ void CFE_SB_RemoveDestNode(CFE_SBR_RouteId_t RouteId, CFE_SB_DestinationD_t *Nod ** Status ** ******************************************************************************/ -int32 CFE_SB_ZeroCopyReleaseAppId(CFE_ES_ResourceID_t AppId) +int32 CFE_SB_ZeroCopyReleaseAppId(CFE_ES_AppId_t AppId) { CFE_SB_ZeroCopyD_t *prev = NULL; CFE_SB_ZeroCopyD_t *zcd = (CFE_SB_ZeroCopyD_t *) (CFE_SB.ZeroCopyTail); while(zcd != NULL){ prev = (CFE_SB_ZeroCopyD_t *) (zcd->Prev); - if( CFE_ES_ResourceID_Equal(zcd->AppID, AppId) ) + if( CFE_RESOURCEID_TEST_EQUAL(zcd->AppID, AppId) ) { CFE_SB_ZeroCopyReleasePtr((CFE_SB_Buffer_t *) zcd->Buffer, (CFE_SB_ZeroCopyHandle_t) zcd); } diff --git a/fsw/cfe-core/src/sb/cfe_sb_priv.h b/fsw/cfe-core/src/sb/cfe_sb_priv.h index 367cdf305..808645f64 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_priv.h +++ b/fsw/cfe-core/src/sb/cfe_sb_priv.h @@ -43,7 +43,6 @@ #include "cfe_time.h" #include "cfe_es.h" #include "private/cfe_sbr.h" -#include "private/cfe_resourceid_internal.h" /* ** Macro Definitions @@ -132,7 +131,7 @@ typedef struct { */ typedef struct { - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; size_t Size; void *Buffer; void *Next; @@ -151,7 +150,7 @@ typedef struct { CFE_SB_PipeId_t PipeId; uint8 Opts; uint8 Spare; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; osal_id_t SysQueueId; uint16 QueueDepth; uint16 SendErrors; @@ -184,7 +183,7 @@ typedef struct { osal_id_t SharedDataMutexId; uint32 SubscriptionReporting; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; uint32 StopRecurseFlags[OS_MAX_TASKS]; void *ZeroCopyTail; CFE_SB_PipeD_t PipeTbl[CFE_PLATFORM_SB_MAX_PIPES]; @@ -194,7 +193,7 @@ typedef struct CFE_SB_MemParams_t Mem; CFE_SB_AllSubscriptionsTlm_t PrevSubMsg; CFE_EVS_BinFilter_t EventFilters[CFE_SB_MAX_CFG_FILE_EVENTS_TO_FILTER]; - CFE_SB_PipeId_t LastPipeId; + CFE_ResourceId_t LastPipeId; } cfe_sb_t; @@ -241,11 +240,11 @@ int32 CFE_SB_ReturnBufferToPool(CFE_SB_BufferD_t *bd); void CFE_SB_ProcessCmdPipePkt(CFE_SB_Buffer_t *SBBufPtr); void CFE_SB_ResetCounters(void); void CFE_SB_SetMsgSeqCnt(CFE_MSG_Message_t *MsgPtr,uint32 Count); -char *CFE_SB_GetAppTskName(CFE_ES_ResourceID_t TaskId, char* FullName); +char *CFE_SB_GetAppTskName(CFE_ES_TaskId_t TaskId, char* FullName); CFE_SB_BufferD_t *CFE_SB_GetBufferFromPool(CFE_SB_MsgId_t MsgId, size_t Size); CFE_SB_BufferD_t *CFE_SB_GetBufferFromCaller(CFE_SB_MsgId_t MsgId, void *Address); -int32 CFE_SB_DeletePipeWithAppId(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId); -int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_ResourceID_t AppId); +int32 CFE_SB_DeletePipeWithAppId(CFE_SB_PipeId_t PipeId,CFE_ES_AppId_t AppId); +int32 CFE_SB_DeletePipeFull(CFE_SB_PipeId_t PipeId,CFE_ES_AppId_t AppId); int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Quality, @@ -253,10 +252,10 @@ int32 CFE_SB_SubscribeFull(CFE_SB_MsgId_t MsgId, uint8 Scope); int32 CFE_SB_UnsubscribeWithAppId(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, - CFE_ES_ResourceID_t AppId); + CFE_ES_AppId_t AppId); int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, - uint8 Scope, CFE_ES_ResourceID_t AppId); + uint8 Scope, CFE_ES_AppId_t AppId); int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_t RouteId, CFE_SB_MsgId_t MsgId); @@ -268,7 +267,7 @@ 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_Buffer_t *Ptr2Release, CFE_SB_ZeroCopyHandle_t BufferHandle); -int32 CFE_SB_ZeroCopyReleaseAppId(CFE_ES_ResourceID_t AppId); +int32 CFE_SB_ZeroCopyReleaseAppId(CFE_ES_AppId_t AppId); void CFE_SB_IncrBufUseCnt(CFE_SB_BufferD_t *bd); void CFE_SB_DecrBufUseCnt(CFE_SB_BufferD_t *bd); int32 CFE_SB_ValidateMsgId(CFE_SB_MsgId_t MsgId); @@ -277,8 +276,8 @@ void CFE_SB_IncrCmdCtr(int32 status); void CFE_SB_FileWriteByteCntErr(const char *Filename,uint32 Requested,uint32 Actual); void CFE_SB_SetSubscriptionReporting(uint32 state); int32 CFE_SB_SendSubscriptionReport(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Quality); -uint32 CFE_SB_RequestToSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit); -void CFE_SB_FinishSendEvent(CFE_ES_ResourceID_t TaskId, uint32 Bit); +uint32 CFE_SB_RequestToSendEvent(CFE_ES_TaskId_t TaskId, uint32 Bit); +void CFE_SB_FinishSendEvent(CFE_ES_TaskId_t TaskId, uint32 Bit); CFE_SB_DestinationD_t *CFE_SB_GetDestinationBlk(void); int32 CFE_SB_PutDestinationBlk(CFE_SB_DestinationD_t *Dest); @@ -402,7 +401,7 @@ extern CFE_SB_PipeD_t* CFE_SB_LocatePipeDescByID(CFE_SB_PipeId_t PipeId); */ static inline bool CFE_SB_PipeDescIsUsed(const CFE_SB_PipeD_t *PipeDscPtr) { - return CFE_ES_ResourceID_IsDefined(PipeDscPtr->PipeId); + return CFE_RESOURCEID_TEST_DEFINED(PipeDscPtr->PipeId); } /** @@ -430,9 +429,9 @@ static inline CFE_SB_PipeId_t CFE_SB_PipeDescGetID(const CFE_SB_PipeD_t *PipeDsc * @param[in] PipeDscPtr pointer to Pipe table entry * @param[in] PipeID the Pipe ID of this entry */ -static inline void CFE_SB_PipeDescSetUsed(CFE_SB_PipeD_t *PipeDscPtr, CFE_SB_PipeId_t PipeID) +static inline void CFE_SB_PipeDescSetUsed(CFE_SB_PipeD_t *PipeDscPtr, CFE_ResourceId_t PendingID) { - PipeDscPtr->PipeId = PipeID; + PipeDscPtr->PipeId = CFE_SB_PIPEID_C(PendingID); } /** @@ -466,11 +465,11 @@ static inline void CFE_SB_PipeDescSetFree(CFE_SB_PipeD_t *PipeDscPtr) */ static inline bool CFE_SB_PipeDescIsMatch(const CFE_SB_PipeD_t *PipeDscPtr, CFE_SB_PipeId_t PipeID) { - return (PipeDscPtr != NULL && CFE_ES_ResourceID_Equal(PipeDscPtr->PipeId, PipeID)); + return (PipeDscPtr != NULL && CFE_RESOURCEID_TEST_EQUAL(PipeDscPtr->PipeId, PipeID)); } -/* Availability check functions used in conjunction with CFE_ES_FindNextAvailableId() */ -bool CFE_SB_CheckPipeDescSlotUsed(CFE_SB_PipeId_t CheckId); +/* Availability check functions used in conjunction with CFE_ResourceId_FindNext() */ +bool CFE_SB_CheckPipeDescSlotUsed(CFE_ResourceId_t CheckId); /* diff --git a/fsw/cfe-core/src/sb/cfe_sb_task.c b/fsw/cfe-core/src/sb/cfe_sb_task.c index 1c09a6fe8..5595a81df 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_task.c +++ b/fsw/cfe-core/src/sb/cfe_sb_task.c @@ -672,19 +672,19 @@ int32 CFE_SB_EnableRouteCmd(const CFE_SB_EnableRouteCmd_t *data) CFE_EVS_SendEvent(CFE_SB_ENBL_RTE1_EID,CFE_EVS_EventType_ERROR, "Enbl Route Cmd:Route does not exist.Msg 0x%x,Pipe %lu", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(CmdPtr->Pipe)); + CFE_RESOURCEID_TO_ULONG(CmdPtr->Pipe)); break; case CFE_SB_ENBL_RTE3_EID: CFE_EVS_SendEvent(CFE_SB_ENBL_RTE3_EID,CFE_EVS_EventType_ERROR, "Enbl Route Cmd:Invalid Param.Msg 0x%x,Pipe %lu", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(CmdPtr->Pipe)); + CFE_RESOURCEID_TO_ULONG(CmdPtr->Pipe)); break; case CFE_SB_ENBL_RTE2_EID: CFE_EVS_SendEvent(CFE_SB_ENBL_RTE2_EID,CFE_EVS_EventType_DEBUG, "Enabling Route,Msg 0x%x,Pipe %lu", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(CmdPtr->Pipe)); + CFE_RESOURCEID_TO_ULONG(CmdPtr->Pipe)); break; } @@ -755,19 +755,19 @@ int32 CFE_SB_DisableRouteCmd(const CFE_SB_DisableRouteCmd_t *data) CFE_EVS_SendEvent(CFE_SB_DSBL_RTE1_EID,CFE_EVS_EventType_ERROR, "Disable Route Cmd:Route does not exist,Msg 0x%x,Pipe %lu", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(CmdPtr->Pipe)); + CFE_RESOURCEID_TO_ULONG(CmdPtr->Pipe)); break; case CFE_SB_DSBL_RTE3_EID: CFE_EVS_SendEvent(CFE_SB_DSBL_RTE3_EID,CFE_EVS_EventType_ERROR, "Disable Route Cmd:Invalid Param.Msg 0x%x,Pipe %lu", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(CmdPtr->Pipe)); + CFE_RESOURCEID_TO_ULONG(CmdPtr->Pipe)); break; case CFE_SB_DSBL_RTE2_EID: CFE_EVS_SendEvent(CFE_SB_DSBL_RTE2_EID,CFE_EVS_EventType_DEBUG, "Route Disabled,Msg 0x%x,Pipe %lu", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(CmdPtr->Pipe)); + CFE_RESOURCEID_TO_ULONG(CmdPtr->Pipe)); break; } @@ -1052,7 +1052,7 @@ int32 CFE_SB_SendSubscriptionReport(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_RPT_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId, "Sending Subscription Report Msg=0x%x,Pipe=%lu,Stat=0x%x", (unsigned int)CFE_SB_MsgIdToValue(MsgId), - CFE_ES_ResourceID_ToInteger(PipeId),(unsigned int)Status); + CFE_RESOURCEID_TO_ULONG(PipeId),(unsigned int)Status); } return Status; diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_api.c b/fsw/cfe-core/src/tbl/cfe_tbl_api.c index 3c5675541..29a000333 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_api.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_api.c @@ -61,7 +61,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, int32 Status; size_t NameLen = 0; int16 RegIndx = -1; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; char AppName[OS_MAX_API_NAME] = {"UNKNOWN"}; char TblName[CFE_TBL_MAX_FULL_NAME_LEN] = {""}; CFE_TBL_Handle_t AccessIndex; @@ -148,7 +148,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, else /* Application ID was invalid */ { CFE_ES_WriteToSysLog("CFE_TBL:Register-Bad AppId(%lu)\n", - CFE_ES_ResourceID_ToInteger(ThisAppId)); + CFE_RESOURCEID_TO_ULONG(ThisAppId)); } /* If input parameters appear acceptable, register the table */ @@ -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 ( CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, ThisAppId) ) + if ( CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, ThisAppId) ) { /* If the new table is the same size as the old, then no need to reallocate memory */ if (Size != RegRecPtr->Size) @@ -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_ES_ResourceID_Equal(CFE_TBL_TaskData.Handles[AccessIndex].AppId, ThisAppId) && + CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_TaskData.Handles[AccessIndex].AppId, ThisAppId) && (CFE_TBL_TaskData.Handles[AccessIndex].RegIndex == RegIndx)) { *TblHandlePtr = AccessIndex; @@ -210,8 +210,8 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, Status = CFE_TBL_ERR_DUPLICATE_NOT_OWNED; CFE_ES_WriteToSysLog("CFE_TBL:Register-App(%lu) Registering Duplicate Table '%s' owned by App(%lu)\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), TblName, - CFE_ES_ResourceID_ToInteger(RegRecPtr->OwnerAppId)); + CFE_RESOURCEID_TO_ULONG(ThisAppId), TblName, + CFE_RESOURCEID_TO_ULONG(RegRecPtr->OwnerAppId)); } } else /* Table not already in registry */ @@ -261,7 +261,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, if(Status < 0) { CFE_ES_WriteToSysLog("CFE_TBL:Register-1st Buf Alloc GetPool fail Stat=0x%08X MemPoolHndl=0x%08lX\n", - (unsigned int)Status, CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.Buf.PoolHdl)); + (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(CFE_TBL_TaskData.Buf.PoolHdl)); } else { @@ -287,7 +287,7 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, if(Status < 0) { CFE_ES_WriteToSysLog("CFE_TBL:Register-2nd Buf Alloc GetPool fail Stat=0x%08X MemPoolHndl=0x%08lX\n", - (unsigned int)Status, CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.Buf.PoolHdl)); + (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(CFE_TBL_TaskData.Buf.PoolHdl)); } else { @@ -516,7 +516,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, const char *TblName ) { int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; int16 RegIndx = CFE_TBL_NOT_FOUND; CFE_TBL_AccessDescriptor_t *AccessDescPtr = NULL; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; @@ -588,7 +588,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, else /* Application ID was invalid */ { CFE_ES_WriteToSysLog("CFE_TBL:Share-Bad AppId(%lu)\n", - CFE_ES_ResourceID_ToInteger(ThisAppId)); + CFE_RESOURCEID_TO_ULONG(ThisAppId)); } /* On Error conditions, notify ground of screw up */ @@ -614,7 +614,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, int32 CFE_TBL_Unregister ( CFE_TBL_Handle_t TblHandle ) { int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; CFE_TBL_AccessDescriptor_t *AccessDescPtr = NULL; char AppName[OS_MAX_API_NAME] = {"UNKNOWN"}; @@ -631,7 +631,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 (CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, ThisAppId)) + if (CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, ThisAppId)) { /* Mark table as free, although, technically, it isn't free until the */ /* linked list of Access Descriptors has no links in it. */ @@ -652,7 +652,7 @@ int32 CFE_TBL_Unregister ( CFE_TBL_Handle_t TblHandle ) else { CFE_ES_WriteToSysLog("CFE_TBL:Unregister-App(%lu) does not have access to Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } /* On Error conditions, notify ground of screw up */ @@ -685,7 +685,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, const void *SrcDataPtr ) { int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; CFE_TBL_LoadBuff_t *WorkingBufferPtr; CFE_TBL_AccessDescriptor_t *AccessDescPtr; CFE_TBL_RegistryRec_t *RegRecPtr; @@ -917,7 +917,7 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ) { int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; CFE_TBL_RegistryRec_t *RegRecPtr=NULL; CFE_TBL_AccessDescriptor_t *AccessDescPtr=NULL; char AppName[OS_MAX_API_NAME]={"UNKNOWN"}; @@ -936,13 +936,13 @@ int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ) if (Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("CFE_TBL:Update-App(%lu) fail to update Tbl '%s' (Stat=0x%08X)\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), RegRecPtr->Name, (unsigned int)Status); + CFE_RESOURCEID_TO_ULONG(ThisAppId), RegRecPtr->Name, (unsigned int)Status); } } else { CFE_ES_WriteToSysLog("CFE_TBL:Update-App(%lu) does not have access to Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } if (Status != CFE_TBL_ERR_BAD_APP_ID) @@ -998,7 +998,7 @@ int32 CFE_TBL_GetAddress( void **TblPtr, CFE_TBL_Handle_t TblHandle ) { int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; /* Assume failure at returning the table address */ *TblPtr = NULL; @@ -1017,7 +1017,7 @@ int32 CFE_TBL_GetAddress( void **TblPtr, else { CFE_ES_WriteToSysLog("CFE_TBL:GetAddress-Bad AppId=%lu\n", - CFE_ES_ResourceID_ToInteger(ThisAppId)); + CFE_RESOURCEID_TO_ULONG(ThisAppId)); } return Status; @@ -1029,7 +1029,7 @@ int32 CFE_TBL_GetAddress( void **TblPtr, int32 CFE_TBL_ReleaseAddress( CFE_TBL_Handle_t TblHandle ) { int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; /* Verify that this application has the right to perform operation */ Status = CFE_TBL_ValidateAccess(TblHandle, &ThisAppId); @@ -1049,7 +1049,7 @@ int32 CFE_TBL_ReleaseAddress( CFE_TBL_Handle_t TblHandle ) else { CFE_ES_WriteToSysLog("CFE_TBL:ReleaseAddress-App(%lu) does not have access to Tbl Handle=%u\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (unsigned int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (unsigned int)TblHandle); } return Status; @@ -1064,7 +1064,7 @@ int32 CFE_TBL_GetAddresses( void **TblPtrs[], { uint16 i; int32 Status; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; /* Assume failure at returning the table addresses */ for (i=0; i CFE_SUCCESS) { CFE_ES_WriteToSysLog("CFE_TBL:Validate-App(%lu) Validation func return code invalid (Stat=0x%08X) for '%s'\n", - CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.TableTaskAppId), (unsigned int)Status, RegRecPtr->Name); + CFE_RESOURCEID_TO_ULONG(CFE_TBL_TaskData.TableTaskAppId), (unsigned int)Status, RegRecPtr->Name); } } @@ -1247,7 +1247,7 @@ int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ) if (Status > CFE_SUCCESS) { CFE_ES_WriteToSysLog("CFE_TBL:Validate-App(%lu) Validation func return code invalid (Stat=0x%08X) for '%s'\n", - CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.TableTaskAppId), (unsigned int)Status, RegRecPtr->Name); + CFE_RESOURCEID_TO_ULONG(CFE_TBL_TaskData.TableTaskAppId), (unsigned int)Status, RegRecPtr->Name); } } @@ -1270,7 +1270,7 @@ int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ) else { CFE_ES_WriteToSysLog("CFE_TBL:Validate-App(%lu) does not have access to Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } return Status; @@ -1339,7 +1339,7 @@ int32 CFE_TBL_Manage( CFE_TBL_Handle_t TblHandle ) int32 CFE_TBL_GetStatus( CFE_TBL_Handle_t TblHandle ) { int32 Status ; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; CFE_TBL_RegistryRec_t *RegRecPtr; CFE_TBL_AccessDescriptor_t *AccessDescPtr; @@ -1370,7 +1370,7 @@ int32 CFE_TBL_GetStatus( CFE_TBL_Handle_t TblHandle ) else { CFE_ES_WriteToSysLog("CFE_TBL:GetStatus-App(%lu) does not have access to Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } return Status; @@ -1481,7 +1481,7 @@ int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle ) CFE_TBL_AccessDescriptor_t *AccessDescPtr = NULL; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; CFE_TBL_Handle_t AccessIterator; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; size_t FilenameLen = 0; /* Verify that this application has the right to perform operation */ @@ -1524,7 +1524,7 @@ int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle ) while (AccessIterator != CFE_TBL_END_OF_LIST) { /* Only notify *OTHER* applications that the contents have changed */ - if (!CFE_ES_ResourceID_Equal(CFE_TBL_TaskData.Handles[AccessIterator].AppId, ThisAppId)) + if (!CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_TaskData.Handles[AccessIterator].AppId, ThisAppId)) { CFE_TBL_TaskData.Handles[AccessIterator].Updated = true; } @@ -1535,7 +1535,7 @@ int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle ) else { CFE_ES_WriteToSysLog("CFE_TBL:Modified-App(%lu) does not have access to Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } @@ -1551,7 +1551,7 @@ int32 CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, CFE_SB_MsgId_t MsgId, int32 Status; CFE_TBL_AccessDescriptor_t *AccessDescPtr = NULL; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; - CFE_ES_ResourceID_t ThisAppId; + CFE_ES_AppId_t ThisAppId; /* Verify that this application has the right to perform operation */ Status = CFE_TBL_ValidateAccess(TblHandle, &ThisAppId); @@ -1563,7 +1563,7 @@ int32 CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, CFE_SB_MsgId_t MsgId, RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; /* Verify that the calling application is the table owner */ - if (CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, ThisAppId)) + if (CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, ThisAppId)) { RegRecPtr->NotificationMsgId = MsgId; RegRecPtr->NotificationCC = CommandCode; @@ -1574,7 +1574,7 @@ int32 CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, CFE_SB_MsgId_t MsgId, { Status = CFE_TBL_ERR_NO_ACCESS; CFE_ES_WriteToSysLog("CFE_TBL:NotifyByMsg-App(%lu) does not own Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } } diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c index afaae8f5a..47d87701f 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, CFE_ES_ResourceID_t *AppIdPtr) +int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, CFE_ES_AppId_t *AppIdPtr) { int32 Status; @@ -369,15 +369,15 @@ int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t *Ap ** NOTE: For complete prolog information, see 'cfe_tbl_internal.h' ********************************************************************/ -int32 CFE_TBL_CheckAccessRights(CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t ThisAppId) +int32 CFE_TBL_CheckAccessRights(CFE_TBL_Handle_t TblHandle, CFE_ES_AppId_t ThisAppId) { int32 Status = CFE_SUCCESS; - if (!CFE_ES_ResourceID_Equal(ThisAppId, CFE_TBL_TaskData.Handles[TblHandle].AppId)) + if (!CFE_RESOURCEID_TEST_EQUAL(ThisAppId, CFE_TBL_TaskData.Handles[TblHandle].AppId)) { /* The Table Service Task always has access rights so that tables */ /* can be manipulated via ground command */ - if (!CFE_ES_ResourceID_Equal(ThisAppId, CFE_TBL_TaskData.TableTaskAppId)) + if (!CFE_RESOURCEID_TEST_EQUAL(ThisAppId, CFE_TBL_TaskData.TableTaskAppId)) { Status = CFE_TBL_ERR_NO_ACCESS; } @@ -443,7 +443,7 @@ int32 CFE_TBL_RemoveAccessLink(CFE_TBL_Handle_t TblHandle) if (Status < 0) { CFE_ES_WriteToSysLog("CFE_TBL:RemoveAccessLink-PutPoolBuf[0] Fail Stat=0x%08X, Hndl=0x%08lX, Buf=0x%08lX\n", - (unsigned int)Status, CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.Buf.PoolHdl), (unsigned long)RegRecPtr->Buffers[0].BufferPtr); + (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(CFE_TBL_TaskData.Buf.PoolHdl), (unsigned long)RegRecPtr->Buffers[0].BufferPtr); } /* If a double buffered table, then free the second buffer as well */ @@ -455,7 +455,7 @@ int32 CFE_TBL_RemoveAccessLink(CFE_TBL_Handle_t TblHandle) if (Status < 0) { CFE_ES_WriteToSysLog("CFE_TBL:RemoveAccessLink-PutPoolBuf[1] Fail Stat=0x%08X, Hndl=0x%08lX, Buf=0x%08lX\n", - (unsigned int)Status, CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.Buf.PoolHdl), (unsigned long)RegRecPtr->Buffers[1].BufferPtr); + (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(CFE_TBL_TaskData.Buf.PoolHdl), (unsigned long)RegRecPtr->Buffers[1].BufferPtr); } } else @@ -486,7 +486,7 @@ int32 CFE_TBL_RemoveAccessLink(CFE_TBL_Handle_t TblHandle) ********************************************************************/ -int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ES_ResourceID_t ThisAppId) +int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ES_AppId_t ThisAppId) { int32 Status; CFE_TBL_AccessDescriptor_t *AccessDescPtr; @@ -509,12 +509,12 @@ int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; /* If table is unowned, then owner must have unregistered it when we weren't looking */ - if (CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED)) + if (CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED)) { Status = CFE_TBL_ERR_UNREGISTERED; CFE_ES_WriteToSysLog("CFE_TBL:GetAddressInternal-App(%lu) attempt to access unowned Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } else /* Table Registry Entry is valid */ { @@ -538,13 +538,13 @@ int32 CFE_TBL_GetAddressInternal(void **TblPtr, CFE_TBL_Handle_t TblHandle, CFE_ else { CFE_ES_WriteToSysLog("CFE_TBL:GetAddressInternal-App(%lu) does not have access to Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } } else { CFE_ES_WriteToSysLog("CFE_TBL:GetAddressInternal-App(%lu) using invalid Tbl Handle=%d\n", - CFE_ES_ResourceID_ToInteger(ThisAppId), (int)TblHandle); + CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } return Status; @@ -597,7 +597,7 @@ int16 CFE_TBL_FindTableInRegistry(const char *TblName) i++; /* Check to see if the record is currently being used */ - if ( !CFE_ES_ResourceID_Equal(CFE_TBL_TaskData.Registry[i].OwnerAppId, CFE_TBL_NOT_OWNED) ) + if ( !CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_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_ES_ResourceID_Equal(CFE_TBL_TaskData.Registry[i].OwnerAppId, CFE_TBL_NOT_OWNED) && + if (CFE_RESOURCEID_TEST_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, CFE_ES_ResourceID_t ThisAppId) +void CFE_TBL_FormTableName(char *FullTblName, const char *TblName, CFE_ES_AppId_t ThisAppId) { char AppName[OS_MAX_API_NAME]; @@ -809,7 +809,7 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, Status = CFE_TBL_ERR_NO_BUFFER_AVAIL; CFE_ES_WriteToSysLog("CFE_TBL:GetWorkingBuffer-Inactive Dbl Buff Locked for '%s' by AppId=%lu\n", - RegRecPtr->Name, CFE_ES_ResourceID_ToInteger(CFE_TBL_TaskData.Handles[AccessIterator].AppId)); + RegRecPtr->Name, CFE_RESOURCEID_TO_ULONG(CFE_TBL_TaskData.Handles[AccessIterator].AppId)); } /* Move to next access descriptor in linked list */ @@ -1356,7 +1356,7 @@ void CFE_TBL_ByteSwapUint32(uint32 *Uint32ToSwapPtr) ** NOTE: For complete prolog information, see 'cfe_tbl_internal.h' ********************************************************************/ -int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_TBL_CleanUpApp(CFE_ES_AppId_t AppId) { uint32 i; CFE_TBL_RegistryRec_t *RegRecPtr = NULL; @@ -1368,7 +1368,7 @@ int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t 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_ES_ResourceID_Equal(CFE_TBL_TaskData.DumpControlBlocks[i].RegRecPtr->OwnerAppId, AppId)) + CFE_RESOURCEID_TEST_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; @@ -1379,7 +1379,7 @@ int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId) for (i=0; iRegIndex]; /* Determine if the Application owned this particular table */ - if (CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, AppId)) + if (CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, AppId)) { /* Mark table as free, although, technically, it isn't free until the */ /* linked list of Access Descriptors has no links in it. */ @@ -1432,7 +1432,7 @@ void CFE_TBL_FindCriticalTblInfo(CFE_TBL_CritRegRec_t **CritRegRecPtr, CFE_ES_CD for (i=0; iOwnerAppId, CFE_TBL_NOT_OWNED) || + if (!CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED) || (RegRecPtr->HeadOfAccessList != CFE_TBL_END_OF_LIST)) { /* Fill Registry Dump Record with relevant information */ @@ -1224,7 +1224,7 @@ int32 CFE_TBL_DumpRegistryCmd(const CFE_TBL_DumpRegistryCmd_t *data) } /* Determine the name of the owning application */ - if (!CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED)) + if (!CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED)) { CFE_ES_GetAppName(DumpRecord.OwnerAppName, RegRecPtr->OwnerAppId, sizeof(DumpRecord.OwnerAppName)); } diff --git a/fsw/cfe-core/src/time/cfe_time_api.c b/fsw/cfe-core/src/time/cfe_time_api.c index 8fecdc9ce..71c9fd3f8 100644 --- a/fsw/cfe-core/src/time/cfe_time_api.c +++ b/fsw/cfe-core/src/time/cfe_time_api.c @@ -690,7 +690,7 @@ void CFE_TIME_ExternalTone(void) int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) { int32 Status; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; uint32 AppIndex; Status = CFE_ES_GetAppID(&AppId); @@ -723,7 +723,7 @@ int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPt int32 CFE_TIME_UnregisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) { int32 Status; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; uint32 AppIndex; Status = CFE_ES_GetAppID(&AppId); diff --git a/fsw/cfe-core/src/time/cfe_time_utils.c b/fsw/cfe-core/src/time/cfe_time_utils.c index 5c6ad95be..b1293be52 100644 --- a/fsw/cfe-core/src/time/cfe_time_utils.c +++ b/fsw/cfe-core/src/time/cfe_time_utils.c @@ -1133,7 +1133,7 @@ void CFE_TIME_Set1HzAdj(CFE_TIME_SysTime_t NewAdjust, int16 Direction) /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 CFE_TIME_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_TIME_CleanUpApp(CFE_ES_AppId_t AppId) { int32 Status; uint32 AppIndex; diff --git a/fsw/cfe-core/src/time/cfe_time_utils.h b/fsw/cfe-core/src/time/cfe_time_utils.h index 84a4c4f0d..31ebf0c50 100644 --- a/fsw/cfe-core/src/time/cfe_time_utils.h +++ b/fsw/cfe-core/src/time/cfe_time_utils.h @@ -301,8 +301,8 @@ typedef struct /* ** Interrupt task ID's... */ - CFE_ES_ResourceID_t LocalTaskID; - CFE_ES_ResourceID_t ToneTaskID; + CFE_ES_TaskId_t LocalTaskID; + CFE_ES_TaskId_t ToneTaskID; /* ** Maximum difference from expected for external time sources... diff --git a/fsw/cfe-core/unit-test/CMakeLists.txt b/fsw/cfe-core/unit-test/CMakeLists.txt index 9df8b60af..d82e8e177 100644 --- a/fsw/cfe-core/unit-test/CMakeLists.txt +++ b/fsw/cfe-core/unit-test/CMakeLists.txt @@ -84,5 +84,3 @@ endforeach(MODULE ${CFE_CORE_MODULES}) # As these are just arbitrary data, they only have to be present - they do not need to be updated execute_process(COMMAND gzip -c ${CMAKE_CURRENT_SOURCE_DIR}/fs_UT.c OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/fs_test.gz) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/fs_test.nongz "This is an ordinary file\n") - - diff --git a/fsw/cfe-core/unit-test/es_UT.c b/fsw/cfe-core/unit-test/es_UT.c index 483a8ea43..001f5d1af 100644 --- a/fsw/cfe-core/unit-test/es_UT.c +++ b/fsw/cfe-core/unit-test/es_UT.c @@ -224,39 +224,55 @@ static const UT_TaskPipeDispatchId_t UT_TPID_CFE_ES_SEND_HK = /* ** Functions */ -CFE_ES_ResourceID_t ES_UT_MakeAppIdForIndex(uint32 ArrayIdx) +CFE_ResourceId_t ES_UT_MakeAppIdForIndex(uint32 ArrayIdx) { /* UT hack - make up AppID values in a manner similar to FSW. * Real apps should never do this. */ - return CFE_ES_ResourceID_FromInteger(ArrayIdx + CFE_ES_APPID_BASE); + return CFE_ResourceId_FromInteger(ArrayIdx + CFE_ES_APPID_BASE); } -CFE_ES_ResourceID_t ES_UT_MakeTaskIdForIndex(uint32 ArrayIdx) +CFE_ResourceId_t ES_UT_MakeTaskIdForIndex(uint32 ArrayIdx) { /* UT hack - make up TaskID values in a manner similar to FSW. * Real apps should never do this. */ - return CFE_ES_ResourceID_FromInteger(ArrayIdx + 0x40010000); + uint32 Base; + + /* The base to use depends on whether STRICT mode is enabled or not */ +#ifndef CFE_RESOURCEID_STRICT //_MODE + Base = CFE_ES_TASKID_BASE; +#else + Base = 0x40010000; /* note this is NOT the same as the normal OSAL task ID base */ +#endif + + return CFE_ResourceId_FromInteger(ArrayIdx + Base); } -CFE_ES_ResourceID_t ES_UT_MakeLibIdForIndex(uint32 ArrayIdx) +CFE_ResourceId_t ES_UT_MakeLibIdForIndex(uint32 ArrayIdx) { /* UT hack - make up LibID values in a manner similar to FSW. * Real apps should never do this. */ - return CFE_ES_ResourceID_FromInteger(ArrayIdx + CFE_ES_LIBID_BASE); + return CFE_ResourceId_FromInteger(ArrayIdx + CFE_ES_LIBID_BASE); } -CFE_ES_MemHandle_t ES_UT_MakePoolIdForIndex(uint32 ArrayIdx) +CFE_ResourceId_t ES_UT_MakeCounterIdForIndex(uint32 ArrayIdx) +{ + /* UT hack - make up CounterID values in a manner similar to FSW. + * Real apps should never do this. */ + return CFE_ResourceId_FromInteger(ArrayIdx + CFE_ES_COUNTID_BASE); +} + +CFE_ResourceId_t ES_UT_MakePoolIdForIndex(uint32 ArrayIdx) { /* UT hack - make up PoolID values in a manner similar to FSW. * Real apps should never do this. */ - return CFE_ES_ResourceID_FromInteger(ArrayIdx + CFE_ES_POOLID_BASE); + return CFE_ResourceId_FromInteger(ArrayIdx + CFE_ES_POOLID_BASE); } -CFE_ES_ResourceID_t ES_UT_MakeCDSIdForIndex(uint32 ArrayIdx) +CFE_ResourceId_t ES_UT_MakeCDSIdForIndex(uint32 ArrayIdx) { /* UT hack - make up CDSID values in a manner similar to FSW. * Real apps should never do this. */ - return CFE_ES_ResourceID_FromInteger(ArrayIdx + CFE_ES_CDSBLOCKID_BASE); + return CFE_ResourceId_FromInteger(ArrayIdx + CFE_ES_CDSBLOCKID_BASE); } /* @@ -268,23 +284,23 @@ void ES_UT_SetupSingleAppId(CFE_ES_AppType_Enum_t AppType, CFE_ES_AppState_Enum_ const char *AppName, CFE_ES_AppRecord_t **OutAppRec, CFE_ES_TaskRecord_t **OutTaskRec) { osal_id_t UtOsalId; - CFE_ES_ResourceID_t UtTaskId; - CFE_ES_ResourceID_t UtAppId; + CFE_ResourceId_t UtTaskId; + CFE_ResourceId_t UtAppId; CFE_ES_AppRecord_t *LocalAppPtr; CFE_ES_TaskRecord_t *LocalTaskPtr; OS_TaskCreate(&UtOsalId, "UT", NULL, OSAL_TASK_STACK_ALLOCATE, 0, 0, 0); - UtTaskId = CFE_ES_ResourceID_FromOSAL(UtOsalId); + UtTaskId = CFE_RESOURCEID_UNWRAP(CFE_ES_TaskId_FromOSAL(UtOsalId)); UtAppId = CFE_ES_Global.LastAppId; - CFE_ES_Global.LastAppId = CFE_ES_ResourceID_FromInteger( - CFE_ES_ResourceID_ToInteger(UtAppId) + 1); + CFE_ES_Global.LastAppId = CFE_ResourceId_FromInteger( + CFE_ResourceId_ToInteger(UtAppId) + 1); - LocalTaskPtr = CFE_ES_LocateTaskRecordByID(UtTaskId); - LocalAppPtr = CFE_ES_LocateAppRecordByID(UtAppId); + LocalTaskPtr = CFE_ES_LocateTaskRecordByID(CFE_ES_TASKID_C(UtTaskId)); + LocalAppPtr = CFE_ES_LocateAppRecordByID(CFE_ES_APPID_C(UtAppId)); CFE_ES_TaskRecordSetUsed(LocalTaskPtr, UtTaskId); CFE_ES_AppRecordSetUsed(LocalAppPtr, UtAppId); - LocalTaskPtr->AppId = UtAppId; - LocalAppPtr->MainTaskId = UtTaskId; + LocalTaskPtr->AppId = CFE_ES_AppRecordGetID(LocalAppPtr); + LocalAppPtr->MainTaskId = CFE_ES_TaskRecordGetID(LocalTaskPtr); LocalAppPtr->AppState = AppState; LocalAppPtr->Type = AppType; @@ -329,17 +345,17 @@ void ES_UT_SetupSingleAppId(CFE_ES_AppType_Enum_t AppType, CFE_ES_AppState_Enum_ void ES_UT_SetupChildTaskId(const CFE_ES_AppRecord_t *ParentApp, const char *TaskName, CFE_ES_TaskRecord_t **OutTaskRec) { osal_id_t UtOsalId; - CFE_ES_ResourceID_t UtTaskId; - CFE_ES_ResourceID_t UtAppId; + CFE_ES_TaskId_t UtTaskId; + CFE_ES_AppId_t UtAppId; CFE_ES_TaskRecord_t *LocalTaskPtr; UtAppId = CFE_ES_AppRecordGetID(ParentApp); OS_TaskCreate(&UtOsalId, "C", NULL, OSAL_TASK_STACK_ALLOCATE, 0, 0, 0); - UtTaskId = CFE_ES_ResourceID_FromOSAL(UtOsalId); + UtTaskId = CFE_ES_TaskId_FromOSAL(UtOsalId); LocalTaskPtr = CFE_ES_LocateTaskRecordByID(UtTaskId); - CFE_ES_TaskRecordSetUsed(LocalTaskPtr, UtTaskId); + CFE_ES_TaskRecordSetUsed(LocalTaskPtr, CFE_RESOURCEID_UNWRAP(UtTaskId)); LocalTaskPtr->AppId = UtAppId; if (TaskName) @@ -363,14 +379,14 @@ void ES_UT_SetupChildTaskId(const CFE_ES_AppRecord_t *ParentApp, const char *Tas */ void ES_UT_SetupSingleLibId(const char *LibName, CFE_ES_LibRecord_t **OutLibRec) { - CFE_ES_ResourceID_t UtLibId; + CFE_ResourceId_t UtLibId; CFE_ES_LibRecord_t *LocalLibPtr; UtLibId = CFE_ES_Global.LastLibId; - CFE_ES_Global.LastLibId = CFE_ES_ResourceID_FromInteger( - CFE_ES_ResourceID_ToInteger(UtLibId) + 1); + CFE_ES_Global.LastLibId = CFE_ResourceId_FromInteger( + CFE_ResourceId_ToInteger(UtLibId) + 1); - LocalLibPtr = CFE_ES_LocateLibRecordByID(UtLibId); + LocalLibPtr = CFE_ES_LocateLibRecordByID(CFE_ES_LIBID_C(UtLibId)); CFE_ES_LibRecordSetUsed(LocalLibPtr, UtLibId); if (LibName) @@ -433,15 +449,15 @@ int32 ES_UT_CDSPoolCommit(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t Offset, void ES_UT_SetupMemPoolId(CFE_ES_MemPoolRecord_t **OutPoolRecPtr) { - CFE_ES_MemHandle_t UtPoolID; + CFE_ResourceId_t UtPoolID; CFE_ES_MemPoolRecord_t *LocalPoolRecPtr; UtPoolID = CFE_ES_Global.LastMemPoolId; - CFE_ES_Global.LastMemPoolId = CFE_ES_ResourceID_FromInteger( - CFE_ES_ResourceID_ToInteger(UtPoolID) + 1); + CFE_ES_Global.LastMemPoolId = CFE_ResourceId_FromInteger( + CFE_ResourceId_ToInteger(UtPoolID) + 1); - LocalPoolRecPtr = CFE_ES_LocateMemPoolRecordByID(UtPoolID); + LocalPoolRecPtr = CFE_ES_LocateMemPoolRecordByID(CFE_ES_MEMHANDLE_C(UtPoolID)); /* in order to validate the size must be nonzero */ LocalPoolRecPtr->Pool.PoolTotalSize = sizeof(UT_MemPoolDirectBuffer.Data); @@ -487,7 +503,7 @@ void ES_UT_SetupSingleCDSRegistry(const char *CDSName, size_t BlockSize, bool Is CFE_ES_CDS_RegRec_t **OutRegRec) { CFE_ES_CDS_RegRec_t *LocalRegRecPtr; - CFE_ES_ResourceID_t UtCDSID; + CFE_ResourceId_t UtCDSID; CFE_ES_GenPoolBD_t LocalBD; size_t UT_CDS_BufferSize; @@ -520,10 +536,10 @@ void ES_UT_SetupSingleCDSRegistry(const char *CDSName, size_t BlockSize, bool Is } UtCDSID = CFE_ES_Global.CDSVars.LastCDSBlockId; - CFE_ES_Global.CDSVars.LastCDSBlockId = CFE_ES_ResourceID_FromInteger( - CFE_ES_ResourceID_ToInteger(UtCDSID) + 1); + CFE_ES_Global.CDSVars.LastCDSBlockId = CFE_ResourceId_FromInteger( + CFE_ResourceId_ToInteger(UtCDSID) + 1); - LocalRegRecPtr = CFE_ES_LocateCDSBlockRecordByID(UtCDSID); + LocalRegRecPtr = CFE_ES_LocateCDSBlockRecordByID(CFE_ES_CDSHANDLE_C(UtCDSID)); if (CDSName != NULL) { strncpy(LocalRegRecPtr->Name, CDSName, @@ -664,11 +680,11 @@ void ES_ResetUnitTest(void) /* ** Initialize the Last Id */ - CFE_ES_Global.LastAppId = CFE_ES_ResourceID_FromInteger(CFE_ES_APPID_BASE); - CFE_ES_Global.LastLibId = CFE_ES_ResourceID_FromInteger(CFE_ES_LIBID_BASE); - CFE_ES_Global.LastCounterId = CFE_ES_ResourceID_FromInteger(CFE_ES_COUNTID_BASE); - CFE_ES_Global.LastMemPoolId = CFE_ES_ResourceID_FromInteger(CFE_ES_POOLID_BASE); - CFE_ES_Global.CDSVars.LastCDSBlockId = CFE_ES_ResourceID_FromInteger(CFE_ES_CDSBLOCKID_BASE); + CFE_ES_Global.LastAppId = CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE); + CFE_ES_Global.LastLibId = CFE_ResourceId_FromInteger(CFE_ES_LIBID_BASE); + CFE_ES_Global.LastCounterId = CFE_ResourceId_FromInteger(CFE_ES_COUNTID_BASE); + CFE_ES_Global.LastMemPoolId = CFE_ResourceId_FromInteger(CFE_ES_POOLID_BASE); + CFE_ES_Global.CDSVars.LastCDSBlockId = CFE_ResourceId_FromInteger(CFE_ES_CDSBLOCKID_BASE); } /* end ES_ResetUnitTest() */ @@ -1037,13 +1053,8 @@ void TestStartupErrorPaths(void) /* Test reading the object table where all app slots are taken */ ES_ResetUnitTest(); - AppRecPtr = CFE_ES_Global.AppTable; - for (j = 0; j < CFE_PLATFORM_ES_MAX_APPLICATIONS; j++) - { - CFE_ES_AppRecordSetUsed(AppRecPtr, ES_UT_MakeAppIdForIndex(j)); - ++AppRecPtr; - } + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); CFE_ES_CreateObjects(); UT_Report(__FILE__, __LINE__, UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_NO_FREE_CORE_APP_SLOTS]) == 5, @@ -1052,13 +1063,7 @@ void TestStartupErrorPaths(void) /* Test reading the object table with a NULL function pointer */ ES_ResetUnitTest(); - AppRecPtr = CFE_ES_Global.AppTable; - for (j = 0; j < CFE_PLATFORM_ES_MAX_APPLICATIONS; j++) - { - CFE_ES_AppRecordSetUsed(AppRecPtr, ES_UT_MakeAppIdForIndex(j)); - ++AppRecPtr; - } - + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); CFE_ES_ObjectTable[1].ObjectType = CFE_ES_FUNCTION_CALL; CFE_ES_CreateObjects(); UT_Report(__FILE__, __LINE__, @@ -1148,9 +1153,9 @@ void TestApps(void) { int NumBytes; int Return; - int j; CFE_ES_AppInfo_t AppInfo; - CFE_ES_ResourceID_t Id; + CFE_ES_AppId_t AppId; + CFE_ES_TaskId_t TaskId; CFE_ES_TaskRecord_t *UtTaskRecPtr; CFE_ES_AppRecord_t *UtAppRecPtr; CFE_ES_MemPoolRecord_t *UtPoolRecPtr; @@ -1258,7 +1263,7 @@ void TestApps(void) /* Test application loading and creation with a task creation failure */ ES_ResetUnitTest(); UT_SetDefaultReturnValue(UT_KEY(OS_TaskCreate), OS_ERROR); - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename", "EntryPoint", "AppName", @@ -1270,7 +1275,7 @@ void TestApps(void) /* Test application creation with NULL file name */ ES_ResetUnitTest(); - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, NULL, "EntryPoint", "AppName", @@ -1285,7 +1290,7 @@ void TestApps(void) /* Test application creation with name too long */ memset(NameBuffer, 'x', sizeof(NameBuffer)-1); NameBuffer[sizeof(NameBuffer)-1] = 0; - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", NameBuffer, @@ -1300,7 +1305,7 @@ void TestApps(void) /* Test successful application loading and creation */ ES_ResetUnitTest(); - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", "AppName", @@ -1313,7 +1318,7 @@ void TestApps(void) "Application load/create; successful"); /* Test application loading of the same name again */ - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", "AppName", @@ -1328,7 +1333,7 @@ void TestApps(void) /* Test application loading and creation where the file cannot be loaded */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_ModuleLoad), 1, -1); - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", "AppName2", @@ -1340,14 +1345,8 @@ void TestApps(void) /* Test application loading and creation where all app slots are taken */ ES_ResetUnitTest(); - UtAppRecPtr = CFE_ES_Global.AppTable; - for (j = 0; j < CFE_PLATFORM_ES_MAX_APPLICATIONS; j++) - { - CFE_ES_AppRecordSetUsed(UtAppRecPtr, ES_UT_MakeAppIdForIndex(j)); - ++UtAppRecPtr; - } - - Return = CFE_ES_AppCreate(&Id, + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", "AppName", @@ -1360,12 +1359,18 @@ void TestApps(void) "CFE_ES_AppCreate", "No free application slots available"); + /* Check operation of the CFE_ES_CheckAppIdSlotUsed() helper function */ + CFE_ES_Global.AppTable[1].AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(1)); + CFE_ES_Global.AppTable[2].AppId = CFE_ES_APPID_UNDEFINED; + UtAssert_True(CFE_ES_CheckAppIdSlotUsed(ES_UT_MakeAppIdForIndex(1)), "App Slot Used"); + UtAssert_True(!CFE_ES_CheckAppIdSlotUsed(ES_UT_MakeAppIdForIndex(2)), "App Slot Unused"); + /* Test application loading and creation where the entry point symbol * cannot be found */ ES_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_ModuleSymbolLookup), 1, -1); - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", "AppName", @@ -1382,7 +1387,7 @@ void TestApps(void) ES_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_ModuleSymbolLookup), 1, -1); UT_SetDeferredRetcode(UT_KEY(OS_ModuleUnload), 1, -1); - Return = CFE_ES_AppCreate(&Id, + Return = CFE_ES_AppCreate(&AppId, "ut/filename.x", "EntryPoint", "AppName", @@ -1399,7 +1404,7 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, &UtTaskRecPtr); - UtTaskRecPtr->AppId = CFE_ES_RESOURCEID_UNDEFINED; + UtTaskRecPtr->AppId = CFE_ES_APPID_UNDEFINED; UtAssert_NULL(CFE_ES_GetAppRecordByContext()); /* Test scanning and acting on the application table where the timer @@ -1464,8 +1469,8 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppControlRequest = 0x12345; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_PCR_ERR2_EID), "CFE_ES_ProcessControlRequest", @@ -1485,8 +1490,8 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_EXIT; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_EXIT_APP_INF_EID), "CFE_ES_ProcessControlRequest", @@ -1499,8 +1504,8 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_EXIT; UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_EXIT_APP_ERR_EID), "CFE_ES_ProcessControlRequest", @@ -1514,8 +1519,8 @@ void TestApps(void) UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_DELETE; UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_STOP_ERR3_EID), "CFE_ES_ProcessControlRequest", @@ -1529,8 +1534,8 @@ void TestApps(void) UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RESTART; UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_RESTART_APP_ERR4_EID), "CFE_ES_ProcessControlRequest", @@ -1545,8 +1550,8 @@ void TestApps(void) CFE_ES_RunStatus_SYS_RESTART; OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UT_SetDefaultReturnValue(UT_KEY(OS_TaskCreate), OS_ERROR); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_RESTART_APP_ERR3_EID), "CFE_ES_ProcessControlRequest", @@ -1560,8 +1565,8 @@ void TestApps(void) UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RELOAD; UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_RELOAD_APP_ERR4_EID), "CFE_ES_ProcessControlRequest", @@ -1576,8 +1581,8 @@ void TestApps(void) CFE_ES_RunStatus_SYS_RELOAD; OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UT_SetDefaultReturnValue(UT_KEY(OS_TaskCreate), OS_ERROR); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_RELOAD_APP_ERR3_EID), "CFE_ES_ProcessControlRequest", @@ -1599,8 +1604,8 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_ERROR; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_ERREXIT_APP_INF_EID), "CFE_ES_ProcessControlRequest", @@ -1614,8 +1619,8 @@ void TestApps(void) UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_ERROR; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_ERREXIT_APP_ERR_EID), "CFE_ES_ProcessControlRequest", @@ -1635,8 +1640,8 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_DELETE; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_STOP_INF_EID), "CFE_ES_ProcessControlRequest", @@ -1656,8 +1661,8 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RESTART; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_RESTART_APP_INF_EID), "CFE_ES_ProcessControlRequest", @@ -1677,8 +1682,8 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RELOAD; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_RELOAD_APP_INF_EID), "CFE_ES_ProcessControlRequest", @@ -1700,8 +1705,8 @@ void TestApps(void) UtAppRecPtr->StartParams.ExceptionAction = 0; UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_EXCEPTION; - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); - CFE_ES_ProcessControlRequest(Id); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + CFE_ES_ProcessControlRequest(AppId); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_PCR_ERR1_EID), "CFE_ES_ProcessControlRequest", @@ -1710,9 +1715,9 @@ void TestApps(void) /* Test populating the application information structure with data */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_GetAppInfo(&AppInfo, Id) == CFE_SUCCESS, + CFE_ES_GetAppInfo(&AppInfo, AppId) == CFE_SUCCESS, "CFE_ES_GetAppInfo", "Get application information; successful"); @@ -1721,9 +1726,9 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_GetAppInfo(NULL, Id) == CFE_ES_ERR_BUFFER, + CFE_ES_GetAppInfo(NULL, AppId) == CFE_ES_ERR_BUFFER, "CFE_ES_GetAppInfo", "Null application information pointer"); @@ -1732,10 +1737,10 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); CFE_ES_AppRecordSetFree(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_GetAppInfo(&AppInfo, Id) == CFE_ES_ERR_RESOURCEID_NOT_VALID, + CFE_ES_GetAppInfo(&AppInfo, AppId) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetAppInfo", "Application ID not active"); @@ -1743,9 +1748,9 @@ void TestApps(void) * application ID value greater than the maximum allowed */ ES_ResetUnitTest(); - Id = ES_UT_MakeAppIdForIndex(99999); + AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(99999)); UT_Report(__FILE__, __LINE__, - CFE_ES_GetAppInfo(&AppInfo, Id) == CFE_ES_ERR_RESOURCEID_NOT_VALID, + CFE_ES_GetAppInfo(&AppInfo, AppId) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetAppInfo", "Application ID exceeds maximum"); @@ -1754,10 +1759,10 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_SetDeferredRetcode(UT_KEY(OS_ModuleInfo), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_GetAppInfo(&AppInfo, Id) == CFE_SUCCESS, + CFE_ES_GetAppInfo(&AppInfo, AppId) == CFE_SUCCESS, "CFE_ES_GetAppInfo", "Module not found"); @@ -1771,9 +1776,9 @@ void TestApps(void) OS_ModuleLoad(&UtAppRecPtr->ModuleInfo.ModuleId, NULL, NULL, 0); UT_SetDefaultReturnValue(UT_KEY(OS_TaskDelete), OS_ERROR); UT_SetDefaultReturnValue(UT_KEY(OS_close), OS_ERROR); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_ES_APP_CLEANUP_ERR, + CFE_ES_CleanUpApp(AppId) == CFE_ES_APP_CLEANUP_ERR, "CFE_ES_CleanUpApp", "Task OS delete and close failure"); @@ -1785,9 +1790,9 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, NULL); ES_UT_SetupForOSCleanup(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemDelete), 1, OS_ERROR); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_ES_APP_CLEANUP_ERR, + CFE_ES_CleanUpApp(AppId) == CFE_ES_APP_CLEANUP_ERR, "CFE_ES_CleanUpApp", "Task mutex delete failure"); @@ -1797,9 +1802,9 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); UT_SetDeferredRetcode(UT_KEY(OS_ModuleUnload), 1, OS_ERROR); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_ES_APP_CLEANUP_ERR, + CFE_ES_CleanUpApp(AppId) == CFE_ES_APP_CLEANUP_ERR, "CFE_ES_CleanUpApp", "Module unload failure"); @@ -1809,9 +1814,9 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); UT_SetDeferredRetcode(UT_KEY(CFE_EVS_CleanUpApp), 1, -1); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_ES_APP_CLEANUP_ERR, + CFE_ES_CleanUpApp(AppId) == CFE_ES_APP_CLEANUP_ERR, "CFE_ES_CleanUpApp", "EVS application cleanup failure"); @@ -1821,10 +1826,10 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); ES_UT_SetupForOSCleanup(); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_SetDeferredRetcode(UT_KEY(OS_MutSemDelete), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == + CFE_ES_CleanupTaskResources(TaskId) == CFE_ES_MUT_SEM_DELETE_ERR, "CFE_ES_CleanupTaskResources", "Mutex delete failure"); @@ -1835,10 +1840,10 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); ES_UT_SetupForOSCleanup(); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_SetDeferredRetcode(UT_KEY(OS_BinSemDelete), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == + CFE_ES_CleanupTaskResources(TaskId) == CFE_ES_BIN_SEM_DELETE_ERR, "CFE_ES_CleanupTaskResources", "Binary semaphore delete failure"); @@ -1850,9 +1855,9 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); ES_UT_SetupForOSCleanup(); UT_SetDeferredRetcode(UT_KEY(OS_CountSemDelete), 1, OS_ERROR); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == + CFE_ES_CleanupTaskResources(TaskId) == CFE_ES_COUNT_SEM_DELETE_ERR, "CFE_ES_CleanupTaskResources", "Counting semaphore failure"); @@ -1864,9 +1869,9 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); ES_UT_SetupForOSCleanup(); UT_SetDeferredRetcode(UT_KEY(OS_QueueDelete), 1, OS_ERROR); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == + CFE_ES_CleanupTaskResources(TaskId) == CFE_ES_QUEUE_DELETE_ERR, "CFE_ES_CleanupTaskResources", "Queue delete failure"); @@ -1876,14 +1881,14 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); ES_UT_SetupForOSCleanup(); /* Just set OS_TimerDelete to fail. There is no requirement * that the code call OS_TimerGetInfo first. */ UT_SetDeferredRetcode(UT_KEY(OS_TimerDelete), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == + CFE_ES_CleanupTaskResources(TaskId) == CFE_ES_TIMER_DELETE_ERR, "CFE_ES_CleanupTaskResources", "Timer delete failure"); @@ -1893,12 +1898,12 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); ES_UT_SetupForOSCleanup(); UT_SetDeferredRetcode(UT_KEY(OS_TimerGetInfo), 1, OS_ERROR); UT_SetDefaultReturnValue(UT_KEY(OS_close), OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) != CFE_SUCCESS, + CFE_ES_CleanupTaskResources(TaskId) != CFE_SUCCESS, "CFE_ES_CleanupTaskResources", "File close failure"); @@ -1907,21 +1912,21 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_SetDeferredRetcode(UT_KEY(OS_TimerGetInfo), 1, OS_ERROR); UT_SetDefaultReturnValue(UT_KEY(OS_TaskDelete), OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == CFE_ES_TASK_DELETE_ERR, + CFE_ES_CleanupTaskResources(TaskId) == CFE_ES_TASK_DELETE_ERR, "CFE_ES_CleanupTaskResources", "Task delete failure"); /* Test successfully cleaning up the OS resources for a task */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_SetDeferredRetcode(UT_KEY(OS_TimerGetInfo), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == CFE_SUCCESS, + CFE_ES_CleanupTaskResources(TaskId) == CFE_SUCCESS, "CFE_ES_CleanupTaskResources", "Clean up task OS resources; successful"); @@ -1985,9 +1990,9 @@ void TestApps(void) UtPoolRecPtr->OwnerAppID = CFE_ES_AppRecordGetID(UtAppRecPtr); /* Associate a child task with the app to be deleted */ ES_UT_SetupChildTaskId(UtAppRecPtr, NULL, NULL); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_SUCCESS, + CFE_ES_CleanUpApp(AppId) == CFE_SUCCESS, "CFE_ES_CleanUpApp", "Main task ID matches task ID, nominal"); UT_Report(__FILE__, __LINE__, @@ -2007,10 +2012,10 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); ES_UT_SetupMemPoolId(&UtPoolRecPtr); UtPoolRecPtr->OwnerAppID = CFE_ES_AppRecordGetID(UtAppRecPtr); - UtPoolRecPtr->PoolID = CFE_ES_ResourceID_FromInteger(99999); /* Mismatch */ - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + UtPoolRecPtr->PoolID = CFE_ES_MEMHANDLE_C(CFE_ResourceId_FromInteger(99999)); /* Mismatch */ + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_ES_APP_CLEANUP_ERR, + CFE_ES_CleanUpApp(AppId) == CFE_ES_APP_CLEANUP_ERR, "CFE_ES_CleanUpApp", "Mem Pool delete error"); UT_Report(__FILE__, __LINE__, @@ -2034,9 +2039,9 @@ void TestApps(void) UtAppRecPtr->MainTaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_SetDefaultReturnValue(UT_KEY(OS_TaskDelete), OS_ERROR); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_ES_APP_CLEANUP_ERR, + CFE_ES_CleanUpApp(AppId) == CFE_ES_APP_CLEANUP_ERR, "CFE_ES_CleanUpApp", "Main task ID doesn't match task ID, CFE_ES_APP_CLEANUP_ERR"); UT_Report(__FILE__, __LINE__, @@ -2057,10 +2062,10 @@ void TestApps(void) /* switch the main task association (makes it wrong) */ UtAppRecPtr->MainTaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_SUCCESS, + CFE_ES_CleanUpApp(AppId) == CFE_SUCCESS, "CFE_ES_CleanUpApp", "Application ID mismatch; core application"); @@ -2081,9 +2086,9 @@ void TestApps(void) /* Setup an entry which will be deleted */ ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, &UtTaskRecPtr); - Id = CFE_ES_AppRecordGetID(UtAppRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanUpApp(Id) == CFE_SUCCESS && + CFE_ES_CleanUpApp(AppId) == CFE_SUCCESS && !CFE_ES_TaskRecordIsUsed(UtTaskRecPtr) && CFE_ES_Global.RegisteredExternalApps == 0, "CFE_ES_CleanUpApp", @@ -2095,7 +2100,7 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, &UtTaskRecPtr); - Id = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); UT_SetDeferredRetcode(UT_KEY(OS_MutSemGetInfo), 1, OS_ERROR); UT_SetDeferredRetcode(UT_KEY(OS_BinSemGetInfo), 1, OS_ERROR); UT_SetDeferredRetcode(UT_KEY(OS_CountSemGetInfo), 1, OS_ERROR); @@ -2103,64 +2108,48 @@ void TestApps(void) UT_SetDeferredRetcode(UT_KEY(OS_TimerGetInfo), 1, OS_ERROR); UT_SetDeferredRetcode(UT_KEY(OS_FDGetInfo), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_ES_CleanupTaskResources(Id) == CFE_SUCCESS, + CFE_ES_CleanupTaskResources(TaskId) == CFE_SUCCESS, "CFE_ES_CleanupTaskResources", "Get OS information failures"); } -static bool ES_UT_CheckIdSlotUsed(CFE_ES_ResourceID_t Id) -{ - return UT_DEFAULT_IMPL(ES_UT_CheckIdSlotUsed) != 0; -} - - void TestResourceID(void) { /* * Test cases for generic resource ID functions which are * not sufficiently covered by other app/lib tests. + * + * Most of the Resource ID functions have been moved to a separate module and that module + * has its own unit test which tests these APIs. + * + * This is mainly to exercise the conversion of CFE ES task IDs to OSAL task IDs and vice versa. + * The conversion is only implemented for tasks, because this is the only resource type where + * there is overlap between OSAL and CFE (they both have task records). */ - CFE_ES_ResourceID_t Id; - CFE_ES_ResourceID_t LastId; - uint32 Count; - - /* Call CFE_ES_FindNextAvailableId() using an invalid resource type */ - ES_ResetUnitTest(); - UT_SetDefaultReturnValue(UT_KEY(ES_UT_CheckIdSlotUsed), 1); - Id = CFE_ES_FindNextAvailableId(CFE_ES_RESOURCEID_UNDEFINED, 5, ES_UT_CheckIdSlotUsed); - UtAssert_True(!CFE_ES_ResourceID_IsDefined(Id), "CFE_ES_FindNextAvailableId() on undefined resource type"); + CFE_ES_TaskId_t cfe_id1, cfe_id2; + osal_id_t osal_id; - /* Verify that CFE_ES_FindNextAvailableId() does not repeat until CFE_ES_RESOURCEID_MAX is reached */ - UT_SetDefaultReturnValue(UT_KEY(ES_UT_CheckIdSlotUsed), 0); - LastId = CFE_ES_Global.LastAppId; - Count = CFE_ES_RESOURCEID_MAX-1; - while (Count > 0) - { - Id = CFE_ES_FindNextAvailableId(LastId, CFE_PLATFORM_ES_MAX_APPLICATIONS, ES_UT_CheckIdSlotUsed); - if (CFE_ES_ResourceID_ToInteger(Id) - CFE_ES_ResourceID_ToInteger(LastId) != 1) - { - /* Numbers should be incrementing by 1 each time, never decreasing */ - break; - } - - LastId = Id; - --Count; - } - UtAssert_True(Count == 0, "CFE_ES_FindNextAvailableId() allocate all resource ID space"); + /* + * In this function the actual values may or may not change, + * depending on whether strict/simple mode is in use. However + * converting to and from should result in the original value + * either way. + */ + UT_SetDefaultReturnValue(UT_KEY(OS_IdentifyObject), OS_OBJECT_TYPE_OS_TASK); + cfe_id1 = CFE_ES_TASKID_C(ES_UT_MakeTaskIdForIndex(0)); + osal_id = CFE_ES_TaskId_ToOSAL(cfe_id1); + cfe_id2 = CFE_ES_TaskId_FromOSAL(osal_id); + UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(cfe_id1, cfe_id2), "CFE_ES_TaskId_ToOSAL()/FromOSAL(): before=%lx, after=%lx", + CFE_RESOURCEID_TO_ULONG(cfe_id1), CFE_RESOURCEID_TO_ULONG(cfe_id2)); - /* Now verify that CFE_ES_FindNextAvailableId() recycles the first item again */ - Id = CFE_ES_FindNextAvailableId(LastId, CFE_PLATFORM_ES_MAX_APPLICATIONS, ES_UT_CheckIdSlotUsed); - UtAssert_True(CFE_ES_ResourceID_IsDefined(Id), "CFE_ES_FindNextAvailableId() after wrap"); - UtAssert_True(CFE_ES_ResourceID_ToInteger(Id) < (CFE_ES_APPID_BASE + CFE_PLATFORM_ES_MAX_APPLICATIONS), "CFE_ES_FindNextAvailableId() wrap ID"); } void TestLibs(void) { CFE_ES_LibRecord_t *UtLibRecPtr; char LongLibraryName[sizeof(UtLibRecPtr->BasicInfo.Name)+1]; - CFE_ES_ResourceID_t Id; - uint32 j; + CFE_ES_LibId_t Id; int32 Return; /* Test shared library loading and initialization where the initialization @@ -2231,7 +2220,7 @@ void TestLibs(void) Return == CFE_ES_ERR_DUPLICATE_NAME, "CFE_ES_LoadLibrary", "Duplicate"); - UtAssert_True(CFE_ES_ResourceID_Equal(Id, CFE_ES_LibRecordGetID(UtLibRecPtr)), + UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(Id, CFE_ES_LibRecordGetID(UtLibRecPtr)), "CFE_ES_LoadLibrary() returned previous ID"); /* Test shared library loading and initialization where the library @@ -2275,14 +2264,7 @@ void TestLibs(void) * library slots available */ ES_ResetUnitTest(); - UtLibRecPtr = CFE_ES_Global.LibTable; - for (j = 0; j < CFE_PLATFORM_ES_MAX_LIBRARIES; j++) - { - CFE_ES_LibRecordSetUsed(UtLibRecPtr, - ES_UT_MakeLibIdForIndex(j)); - ++UtLibRecPtr; - } - + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); Return = CFE_ES_LoadLibrary(&Id, "filename", "EntryPoint", @@ -2293,6 +2275,11 @@ void TestLibs(void) "CFE_ES_LoadLibrary", "No free library slots"); + /* check operation of the CFE_ES_CheckLibIdSlotUsed() function */ + CFE_ES_Global.LibTable[1].LibId = CFE_ES_LIBID_C(ES_UT_MakeLibIdForIndex(1)); + CFE_ES_Global.LibTable[2].LibId = CFE_ES_LIBID_UNDEFINED; + UtAssert_True(CFE_ES_CheckLibIdSlotUsed(ES_UT_MakeLibIdForIndex(1)), "Lib Slot Used"); + UtAssert_True(!CFE_ES_CheckLibIdSlotUsed(ES_UT_MakeLibIdForIndex(2)), "Lib Slot Unused"); /* * Test public Name+ID query/lookup API */ @@ -2302,8 +2289,8 @@ void TestLibs(void) UtAssert_INT32_EQ(CFE_ES_GetLibName(LongLibraryName, Id, sizeof(LongLibraryName)), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(&Id, "Nonexistent"), CFE_ES_ERR_NAME_NOT_FOUND); UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(&Id, LongLibraryName), CFE_SUCCESS); - UtAssert_True(CFE_ES_ResourceID_Equal(Id, CFE_ES_LibRecordGetID(UtLibRecPtr)), "Library IDs Match"); - UtAssert_INT32_EQ(CFE_ES_GetLibName(LongLibraryName, CFE_ES_RESOURCEID_UNDEFINED, sizeof(LongLibraryName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(Id, CFE_ES_LibRecordGetID(UtLibRecPtr)), "Library IDs Match"); + UtAssert_INT32_EQ(CFE_ES_GetLibName(LongLibraryName, CFE_ES_LIBID_UNDEFINED, sizeof(LongLibraryName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); UtAssert_INT32_EQ(CFE_ES_GetLibName(NULL, Id, sizeof(LongLibraryName)), CFE_ES_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(&Id, NULL), CFE_ES_BAD_ARGUMENT); } @@ -3482,7 +3469,7 @@ void TestTask(void) ES_ResetUnitTest(); UT_SetDefaultReturnValue(UT_KEY(CFE_PSP_Exception_GetCount), 1); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, &UtTaskRecPtr); - UT_ContextTask = CFE_ES_ResourceID_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); + UT_ContextTask = CFE_ES_TaskId_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); UT_SetDataBuffer(UT_KEY(CFE_PSP_Exception_GetSummary), &UT_ContextTask, sizeof(UT_ContextTask), false); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_RUN; UtAppRecPtr->StartParams.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; @@ -3503,7 +3490,7 @@ void TestTask(void) ES_ResetUnitTest(); UT_SetDefaultReturnValue(UT_KEY(CFE_PSP_Exception_GetCount), 1); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, &UtTaskRecPtr); - UT_ContextTask = CFE_ES_ResourceID_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); + UT_ContextTask = CFE_ES_TaskId_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); UT_SetDataBuffer(UT_KEY(CFE_PSP_Exception_GetSummary), &UT_ContextTask, sizeof(UT_ContextTask), false); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_RUN; UtAppRecPtr->StartParams.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; @@ -4471,8 +4458,8 @@ void TestAPI(void) uint8 Data[12]; uint32 ResetType; uint32 *ResetTypePtr; - CFE_ES_ResourceID_t AppId; - CFE_ES_ResourceID_t TaskId; + CFE_ES_AppId_t AppId; + CFE_ES_TaskId_t TaskId; uint32 RunStatus; CFE_ES_TaskInfo_t TaskInfo; CFE_ES_AppInfo_t AppInfo; @@ -4527,7 +4514,7 @@ void TestAPI(void) /* Test restarting an app that doesn't exist */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_STOPPED, NULL, &UtAppRecPtr, NULL); - AppId = ES_UT_MakeAppIdForIndex(CFE_PLATFORM_ES_MAX_APPLICATIONS-1); /* Should be within range, but not used */ + AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(CFE_PLATFORM_ES_MAX_APPLICATIONS-1)); /* Should be within range, but not used */ UT_Report(__FILE__, __LINE__, CFE_ES_RestartApp(AppId) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_RestartApp", @@ -4535,7 +4522,7 @@ void TestAPI(void) /* Test restarting an app with an ID out of range (high) */ ES_ResetUnitTest(); - AppId = ES_UT_MakeAppIdForIndex(99999); + AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(99999)); UT_Report(__FILE__, __LINE__, CFE_ES_RestartApp(AppId) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_RestartApp", @@ -4708,7 +4695,7 @@ void TestAPI(void) /* Test getting the app name with a bad app ID */ ES_ResetUnitTest(); - AppId = ES_UT_MakeAppIdForIndex(99999); + AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(99999)); UT_Report(__FILE__, __LINE__, CFE_ES_GetAppName(AppName, AppId, sizeof(AppName)) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetAppName", @@ -4717,7 +4704,7 @@ void TestAPI(void) /* Test getting the app name with that app ID out of range */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, "UT", NULL, NULL); - AppId = ES_UT_MakeAppIdForIndex(99999); + AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(99999)); UT_Report(__FILE__, __LINE__, CFE_ES_GetAppName(AppName, AppId, @@ -4782,7 +4769,7 @@ void TestAPI(void) /* Test getting task information using the task ID with invalid task ID */ ES_ResetUnitTest(); - TaskId = CFE_ES_RESOURCEID_UNDEFINED; + TaskId = CFE_ES_TASKID_UNDEFINED; UT_Report(__FILE__, __LINE__, CFE_ES_GetTaskInfo(&TaskInfo, TaskId) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetTaskInfo", @@ -4878,7 +4865,7 @@ void TestAPI(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); ES_UT_SetupChildTaskId(UtAppRecPtr, NULL, &UtTaskRecPtr); - TestObjId = CFE_ES_ResourceID_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); + TestObjId = CFE_ES_TaskId_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId), OS_ObjectIdToInteger(TestObjId)); /* Set context to that of child */ Return = CFE_ES_CreateChildTask(&TaskId, "TaskName", @@ -4957,7 +4944,7 @@ void TestAPI(void) /* Test deleting a child task with the task ID out of range */ ES_ResetUnitTest(); - TaskId = CFE_ES_RESOURCEID_UNDEFINED; + TaskId = CFE_ES_TASKID_UNDEFINED; UT_Report(__FILE__, __LINE__, CFE_ES_DeleteChildTask(TaskId) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_DeleteChildTask", @@ -4967,7 +4954,7 @@ void TestAPI(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); ES_UT_SetupChildTaskId(UtAppRecPtr, NULL, &UtTaskRecPtr); - TestObjId = CFE_ES_ResourceID_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); + TestObjId = CFE_ES_TaskId_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); UT_SetDefaultReturnValue(UT_KEY(OS_TaskGetId), OS_ObjectIdToInteger(TestObjId)); /* Set context to that of child */ CFE_ES_ExitChildTask(); UT_Report(__FILE__, __LINE__, @@ -5179,7 +5166,7 @@ void TestAPI(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, "UT", &UtAppRecPtr, &UtTaskRecPtr); TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); - UtAssert_INT32_EQ(CFE_ES_GetTaskName(AppName, CFE_ES_RESOURCEID_UNDEFINED, sizeof(AppName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_INT32_EQ(CFE_ES_GetTaskName(AppName, CFE_ES_TASKID_UNDEFINED, sizeof(AppName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); UtAssert_INT32_EQ(CFE_ES_GetTaskName(NULL, TaskId, sizeof(AppName)), CFE_ES_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_ES_GetTaskName(AppName, TaskId, sizeof(AppName)), CFE_SUCCESS); UT_SetDeferredRetcode(UT_KEY(OS_GetResourceName), 1, OS_ERROR); @@ -5194,8 +5181,8 @@ void TestAPI(void) void TestGenericCounterAPI(void) { char CounterName[11]; - CFE_ES_ResourceID_t CounterId; - CFE_ES_ResourceID_t CounterId2; + CFE_ES_CounterId_t CounterId; + CFE_ES_CounterId_t CounterId2; uint32 CounterCount; int i; @@ -5230,11 +5217,20 @@ void TestGenericCounterAPI(void) "Register maximum number of counters"); /* Test registering a generic counter after the maximum are registered */ + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_ES_RegisterGenCounter(&CounterId, "Counter999") == CFE_ES_NO_RESOURCE_IDS_AVAILABLE, "CFE_ES_RegisterGenCounter", "Maximum number of counters exceeded"); + UT_ResetState(UT_KEY(CFE_ResourceId_FindNext)); + + /* Check operation of the CFE_ES_CheckCounterIdSlotUsed() helper function */ + CFE_ES_Global.CounterTable[1].CounterId = CFE_ES_COUNTERID_C(ES_UT_MakeCounterIdForIndex(1)); + CFE_ES_Global.CounterTable[2].CounterId = CFE_ES_COUNTERID_UNDEFINED; + UtAssert_True(CFE_ES_CheckCounterIdSlotUsed(ES_UT_MakeCounterIdForIndex(1)), "Counter Slot Used"); + UtAssert_True(!CFE_ES_CheckCounterIdSlotUsed(ES_UT_MakeCounterIdForIndex(2)), "Counter Slot Unused"); + /* Test getting a registered generic counter that doesn't exist */ UT_Report(__FILE__, __LINE__, @@ -5252,7 +5248,7 @@ void TestGenericCounterAPI(void) /* Test deleting a registered generic counter that doesn't exist */ UT_Report(__FILE__, __LINE__, - CFE_ES_DeleteGenCounter(CFE_ES_RESOURCEID_UNDEFINED) == CFE_ES_BAD_ARGUMENT, + CFE_ES_DeleteGenCounter(CFE_ES_COUNTERID_UNDEFINED) == CFE_ES_BAD_ARGUMENT, "CFE_ES_DeleteGenCounter", "Cannot delete counter that does not exist"); @@ -5272,7 +5268,7 @@ void TestGenericCounterAPI(void) /* Test incrementing a generic counter that doesn't exist */ UT_Report(__FILE__, __LINE__, - CFE_ES_IncrementGenCounter(CFE_ES_RESOURCEID_UNDEFINED) + CFE_ES_IncrementGenCounter(CFE_ES_COUNTERID_UNDEFINED) == CFE_ES_BAD_ARGUMENT, "CFE_ES_IncrementGenCounter", "Bad counter ID"); @@ -5285,7 +5281,7 @@ void TestGenericCounterAPI(void) /* Test getting a generic counter value for a counter that doesn't exist */ UT_Report(__FILE__, __LINE__, - CFE_ES_GetGenCount(CFE_ES_RESOURCEID_UNDEFINED, &CounterCount) == CFE_ES_BAD_ARGUMENT, + CFE_ES_GetGenCount(CFE_ES_COUNTERID_UNDEFINED, &CounterCount) == CFE_ES_BAD_ARGUMENT, "CFE_ES_GetGenCount", "Bad counter ID"); @@ -5298,7 +5294,7 @@ void TestGenericCounterAPI(void) /* Test setting a generic counter value for a counter that doesn't exist */ UT_Report(__FILE__, __LINE__, - CFE_ES_SetGenCount(CFE_ES_RESOURCEID_UNDEFINED, 5) == CFE_ES_BAD_ARGUMENT, + CFE_ES_SetGenCount(CFE_ES_COUNTERID_UNDEFINED, 5) == CFE_ES_BAD_ARGUMENT, "CFE_ES_SetGenCount", "Bad counter ID"); @@ -5379,8 +5375,8 @@ void TestGenericCounterAPI(void) UtAssert_INT32_EQ(CFE_ES_GetGenCounterName(CounterName, CounterId, sizeof(CounterName)), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_GetGenCounterIDByName(&CounterId2, "Nonexistent"), CFE_ES_ERR_NAME_NOT_FOUND); UtAssert_INT32_EQ(CFE_ES_GetGenCounterIDByName(&CounterId2, CounterName), CFE_SUCCESS); - UtAssert_True(CFE_ES_ResourceID_Equal(CounterId, CounterId2), "Counter IDs Match"); - UtAssert_INT32_EQ(CFE_ES_GetGenCounterName(CounterName, CFE_ES_RESOURCEID_UNDEFINED, sizeof(CounterName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(CounterId, CounterId2), "Counter IDs Match"); + UtAssert_INT32_EQ(CFE_ES_GetGenCounterName(CounterName, CFE_ES_COUNTERID_UNDEFINED, sizeof(CounterName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); UtAssert_INT32_EQ(CFE_ES_GetGenCounterName(NULL, CounterId, sizeof(CounterName)), CFE_ES_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_ES_GetGenCounterIDByName(&CounterId, NULL), CFE_ES_BAD_ARGUMENT); } @@ -5525,18 +5521,18 @@ void TestCDS() ES_UT_SetupCDSGlobal(ES_UT_CDS_SMALL_TEST_SIZE); /* Set all the CDS registries to 'taken' */ - UtCDSRegRecPtr = CFE_ES_Global.CDSVars.Registry; - for (i = 0; i < CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES; i++) - { - CFE_ES_CDSBlockRecordSetUsed(UtCDSRegRecPtr, CFE_ES_RESOURCEID_RESERVED); - ++UtCDSRegRecPtr; - } - + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_ES_RegisterCDS(&CDSHandle, 4, "Name2") == CFE_ES_NO_RESOURCE_IDS_AVAILABLE, "CFE_ES_RegisterCDS", "No available entries"); + /* Check operation of the CFE_ES_CheckCDSHandleSlotUsed() helper function */ + CFE_ES_Global.CDSVars.Registry[1].BlockID = CFE_ES_CDSHANDLE_C(ES_UT_MakeCDSIdForIndex(1)); + CFE_ES_Global.CDSVars.Registry[2].BlockID = CFE_ES_CDS_BAD_HANDLE; + UtAssert_True(CFE_ES_CheckCDSHandleSlotUsed(ES_UT_MakeCDSIdForIndex(1)), "CDS Slot Used"); + UtAssert_True(!CFE_ES_CheckCDSHandleSlotUsed(ES_UT_MakeCDSIdForIndex(2)), "CDS Slot Unused"); + /* Test CDS registering using a bad app ID */ ES_ResetUnitTest(); UT_Report(__FILE__, __LINE__, @@ -5545,7 +5541,7 @@ void TestCDS() "Bad application ID"); /* Test copying to CDS with bad handle */ - CDSHandle = CFE_ES_RESOURCEID_UNDEFINED; + CDSHandle = CFE_ES_CDS_BAD_HANDLE; UT_Report(__FILE__, __LINE__, CFE_ES_CopyToCDS(CDSHandle, &TempSize) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_CopyToCDS", @@ -5856,8 +5852,8 @@ void TestCDS() UtAssert_INT32_EQ(CFE_ES_GetCDSBlockName(CDSName, CDSHandle, sizeof(CDSName)), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_GetCDSBlockIDByName(&CDSHandle, "Nonexistent"), CFE_ES_ERR_NAME_NOT_FOUND); UtAssert_INT32_EQ(CFE_ES_GetCDSBlockIDByName(&CDSHandle, CDSName), CFE_SUCCESS); - UtAssert_True(CFE_ES_ResourceID_Equal(CDSHandle, CFE_ES_CDSBlockRecordGetID(UtCDSRegRecPtr)), "CDS Handle IDs Match"); - UtAssert_INT32_EQ(CFE_ES_GetCDSBlockName(CDSName, CFE_ES_RESOURCEID_UNDEFINED, sizeof(CDSName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(CDSHandle, CFE_ES_CDSBlockRecordGetID(UtCDSRegRecPtr)), "CDS Handle IDs Match"); + UtAssert_INT32_EQ(CFE_ES_GetCDSBlockName(CDSName, CFE_ES_CDS_BAD_HANDLE, sizeof(CDSName)), CFE_ES_ERR_RESOURCEID_NOT_VALID); UtAssert_INT32_EQ(CFE_ES_GetCDSBlockName(NULL, CDSHandle, sizeof(CDSName)), CFE_ES_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_ES_GetCDSBlockIDByName(&CDSHandle, NULL), CFE_ES_BAD_ARGUMENT); @@ -5867,7 +5863,7 @@ void TestCDSMempool(void) { CFE_ES_CDS_RegRec_t *UtCdsRegRecPtr; int Data; - CFE_ES_ResourceID_t BlockHandle; + CFE_ES_CDSHandle_t BlockHandle; size_t SavedSize; size_t SavedOffset; uint8 *CdsPtr; @@ -5924,7 +5920,7 @@ void TestCDSMempool(void) /* Test CDS block write using an invalid memory handle */ ES_ResetUnitTest(); - BlockHandle = CFE_ES_ResourceID_FromInteger(7); + BlockHandle = CFE_ES_CDSHANDLE_C(CFE_ResourceId_FromInteger(7)); UT_Report(__FILE__, __LINE__, CFE_ES_CDSBlockWrite(BlockHandle, &Data) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_CDSBlockWrite", @@ -6144,8 +6140,14 @@ void TestESMempool(void) * field is not the pool start address */ PoolPtr = CFE_ES_LocateMemPoolRecordByID(PoolID2); - PoolPtr->PoolID = CFE_ES_ResourceID_FromInteger( - CFE_ES_ResourceID_ToInteger(PoolPtr->PoolID) ^ 10); /* cause it to fail validation */ + + /* + * Intentionally corrupt the Pool ID value - whether strict or simple + * types are in use, underneath the wrapper(s) lies a uint32 eventually. + * This is intentionally a type-UNSAFE access to this value. + */ + *((uint32*)&PoolPtr->PoolID) ^= 10; /* cause it to fail validation */ + UT_Report(__FILE__, __LINE__, CFE_ES_ValidateHandle(PoolID2) == false, "CFE_ES_ValidateHandle", @@ -6166,7 +6168,7 @@ void TestESMempool(void) */ UT_Report(__FILE__, __LINE__, CFE_ES_GetMemPoolStats(&Stats, - CFE_ES_RESOURCEID_UNDEFINED) == CFE_ES_ERR_RESOURCEID_NOT_VALID, + CFE_ES_MEMHANDLE_UNDEFINED) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetMemPoolStats", "Invalid handle; not pool start address"); @@ -6189,8 +6191,8 @@ void TestESMempool(void) "CFE_ES_GetPoolBufInfo", "Invalid memory pool handle"); - PoolPtr->PoolID = CFE_ES_ResourceID_FromInteger( - CFE_ES_ResourceID_ToInteger(PoolPtr->PoolID) ^ 10); /* Repair Pool2 ID */ + /* Undo the previous memory corruption */ + *((uint32*)&PoolPtr->PoolID) ^= 10; /* Repair Pool2 ID */ /* Test returning a pool buffer using an invalid memory block */ UT_Report(__FILE__, __LINE__, @@ -6266,12 +6268,7 @@ void TestESMempool(void) * Test creating a memory pool after the limit reached (no slots) */ ES_ResetUnitTest(); - PoolPtr = CFE_ES_Global.MemPoolTable; - for (i = 0; i < CFE_PLATFORM_ES_MAX_MEMORY_POOLS; ++i) - { - CFE_ES_MemPoolRecordSetUsed(PoolPtr, CFE_ES_ResourceID_FromInteger(i + CFE_ES_POOLID_BASE)); - ++PoolPtr; - } + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_ES_PoolCreateEx(&PoolID1, Buffer1, @@ -6282,6 +6279,12 @@ void TestESMempool(void) "CFE_ES_PoolCreateEx", "Memory pool limit reached"); + /* Check operation of the CFE_ES_CheckCounterIdSlotUsed() helper function */ + CFE_ES_Global.MemPoolTable[1].PoolID = CFE_ES_MEMHANDLE_C(ES_UT_MakePoolIdForIndex(1)); + CFE_ES_Global.MemPoolTable[2].PoolID = CFE_ES_MEMHANDLE_UNDEFINED; + UtAssert_True(CFE_ES_CheckMemPoolSlotUsed(ES_UT_MakePoolIdForIndex(1)), "MemPool Slot Used"); + UtAssert_True(!CFE_ES_CheckMemPoolSlotUsed(ES_UT_MakePoolIdForIndex(2)), "MemPool Slot Unused"); + /* * Test creating a memory pool with a semaphore error */ @@ -6522,13 +6525,13 @@ void TestESMempool(void) /* Test handle validation using a null handle */ UT_Report(__FILE__, __LINE__, - CFE_ES_ValidateHandle(CFE_ES_RESOURCEID_UNDEFINED) == false, + CFE_ES_ValidateHandle(CFE_ES_MEMHANDLE_UNDEFINED) == false, "CFE_ES_ValidateHandle", "NULL handle"); /* Test returning a pool buffer using a null handle */ UT_Report(__FILE__, __LINE__, - CFE_ES_PutPoolBuf(CFE_ES_RESOURCEID_UNDEFINED, addressp2) == CFE_ES_ERR_RESOURCEID_NOT_VALID, + CFE_ES_PutPoolBuf(CFE_ES_MEMHANDLE_UNDEFINED, addressp2) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_PutPoolBuf", "NULL memory handle"); @@ -6536,14 +6539,14 @@ void TestESMempool(void) ES_ResetUnitTest(); UT_Report(__FILE__, __LINE__, CFE_ES_GetPoolBuf(&addressp2, - CFE_ES_RESOURCEID_UNDEFINED, + CFE_ES_MEMHANDLE_UNDEFINED, 256) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetPoolBuf", "NULL memory handle"); /* Test getting the size of an existing pool buffer using a null handle */ UT_Report(__FILE__, __LINE__, - CFE_ES_GetPoolBufInfo(CFE_ES_RESOURCEID_UNDEFINED, addressp1) == + CFE_ES_GetPoolBufInfo(CFE_ES_MEMHANDLE_UNDEFINED, addressp1) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_GetPoolBufInfo", "NULL memory handle"); @@ -6609,7 +6612,7 @@ void TestESMempool(void) /* Test getting the size of a pool buffer with an invalid memory handle */ UT_Report(__FILE__, __LINE__, - CFE_ES_PutPoolBuf(CFE_ES_RESOURCEID_UNDEFINED, + CFE_ES_PutPoolBuf(CFE_ES_MEMHANDLE_UNDEFINED, addressp1) == CFE_ES_ERR_RESOURCEID_NOT_VALID, "CFE_ES_PutPoolBuf", diff --git a/fsw/cfe-core/unit-test/evs_UT.c b/fsw/cfe-core/unit-test/evs_UT.c index 4173a916a..d11e5eb41 100644 --- a/fsw/cfe-core/unit-test/evs_UT.c +++ b/fsw/cfe-core/unit-test/evs_UT.c @@ -566,7 +566,7 @@ void Test_IllegalAppID(void) UT_Report(__FILE__, __LINE__, CFE_EVS_SendEventWithAppID(0, 0, - CFE_ES_RESOURCEID_UNDEFINED, + CFE_ES_APPID_UNDEFINED, "NULL") == CFE_EVS_APP_ILLEGAL_APP_ID, "CFE_EVS_SendEventWithAppID", "Illegal app ID"); @@ -591,7 +591,7 @@ void Test_IllegalAppID(void) UT_InitData(); UT_SetDefaultReturnValue(UT_KEY(CFE_ES_AppID_ToIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID); UT_Report(__FILE__, __LINE__, - CFE_EVS_CleanUpApp(CFE_ES_RESOURCEID_UNDEFINED) == + CFE_EVS_CleanUpApp(CFE_ES_APPID_UNDEFINED) == CFE_EVS_APP_ILLEGAL_APP_ID, "CFE_EVS_CleanUpApp", "Illegal app ID"); @@ -605,7 +605,7 @@ void Test_UnregisteredApp(void) { CFE_TIME_SysTime_t time = {0, 0}; EVS_AppData_t *AppDataPtr; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; /* Get a local ref to the "current" AppData table entry */ EVS_GetCurrentContext(&AppDataPtr, &AppID); @@ -688,7 +688,7 @@ void Test_FilterRegistration(void) CFE_EVS_BinFilter_t filter[CFE_PLATFORM_EVS_MAX_EVENT_FILTERS + 1]; EVS_BinFilter_t *FilterPtr = NULL; EVS_AppData_t *AppDataPtr; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; CFE_TIME_SysTime_t time = {0, 0}; /* Get a local ref to the "current" AppData table entry */ @@ -929,7 +929,7 @@ void Test_Format(void) .SnapshotSize = sizeof(CapturedMsg) }; EVS_AppData_t *AppDataPtr; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; UT_EVS_MSGInitData_t MsgData; CFE_MSG_Message_t *MsgSend; @@ -2692,7 +2692,7 @@ void Test_Misc(void) CFE_EVS_WriteLogDataFileCmd_t writelogdatacmd; } PktBuf; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; EVS_AppData_t *AppDataPtr; int i; char msg[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH + 2]; @@ -2744,7 +2744,7 @@ void Test_Misc(void) /* Test successful application cleanup */ UT_InitData(); UT_Report(__FILE__, __LINE__, - CFE_EVS_CleanUpApp(CFE_ES_RESOURCEID_UNDEFINED) == CFE_SUCCESS, + CFE_EVS_CleanUpApp(CFE_ES_APPID_UNDEFINED) == CFE_SUCCESS, "CFE_EVS_CleanUpApp", "Application cleanup - successful"); diff --git a/fsw/cfe-core/unit-test/sb_UT.c b/fsw/cfe-core/unit-test/sb_UT.c index 117c4929b..9646017e6 100644 --- a/fsw/cfe-core/unit-test/sb_UT.c +++ b/fsw/cfe-core/unit-test/sb_UT.c @@ -40,6 +40,7 @@ */ #include "sb_UT.h" #include "cfe_msg_api.h" +#include "private/cfe_core_resourceid_basevalues.h" /* * A method to add an SB "Subtest" @@ -112,20 +113,32 @@ const CFE_SB_MsgId_t SB_UT_ALTERNATE_INVALID_MID = CFE_SB_MSGID_WRAP_VALUE(CFE_P const CFE_SB_MsgId_t SB_UT_BARE_CMD_MID3 = CFE_SB_MSGID_WRAP_VALUE(0x1003); const CFE_SB_MsgId_t SB_UT_BARE_TLM_MID3 = CFE_SB_MSGID_WRAP_VALUE(0x0003); -const CFE_SB_PipeId_t SB_UT_PIPEID_0 = { CFE_SB_PIPEID_BASE + 0 }; -const CFE_SB_PipeId_t SB_UT_PIPEID_1 = { CFE_SB_PIPEID_BASE + 1 }; -const CFE_SB_PipeId_t SB_UT_PIPEID_2 = { CFE_SB_PIPEID_BASE + 2 }; -const CFE_SB_PipeId_t SB_UT_PIPEID_3 = { CFE_SB_PIPEID_BASE + 3 }; -const CFE_SB_PipeId_t SB_UT_ALTERNATE_INVALID_PIPEID = { 0xDEADBEEF }; +#define SB_UT_PIPEID_0 CFE_SB_PIPEID_C(CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE + 0)) +#define SB_UT_PIPEID_1 CFE_SB_PIPEID_C(CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE + 1)) +#define SB_UT_PIPEID_2 CFE_SB_PIPEID_C(CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE + 2)) +#define SB_UT_PIPEID_3 CFE_SB_PIPEID_C(CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE + 3)) +#define SB_UT_ALTERNATE_INVALID_PIPEID CFE_SB_PIPEID_C(CFE_ResourceId_FromInteger(0xDEADBEEF)) + +/* + * Helper function to manufacture a fake pipe ID value that will validate + */ +CFE_ResourceId_t UT_SB_MakePipeIdForIndex(uint32 ArrayIdx) +{ + return CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE + ArrayIdx); +} /* * Helper function to "corrupt" a resource ID value in a consistent/predicatble way, * which can also be un-done easily. */ -CFE_ES_ResourceID_t UT_SB_ResourceID_Modify(CFE_ES_ResourceID_t InitialID, int32 Modifier) +CFE_ES_AppId_t UT_SB_AppID_Modify(CFE_ES_AppId_t InitialID, int32 Modifier) { - unsigned long NewValue = CFE_ES_ResourceID_ToInteger(InitialID) + Modifier; - return CFE_ES_ResourceID_FromInteger(NewValue); + CFE_ES_AppId_t TempValue = InitialID; + + /* Underneath the wrapper(s) the IDs are 32-bit integer values, so it can be cast */ + *((uint32*)&TempValue) += Modifier; + + return TempValue; } /* @@ -1682,7 +1695,7 @@ void Test_CreatePipe_MaxPipes(void) /* Create maximum number of pipes + 1. Only one 'create pipe' failure * expected */ - UT_SetDeferredRetcode(UT_KEY(CFE_ES_ResourceID_ToIndex), 1+CFE_PLATFORM_SB_MAX_PIPES, -1); + UT_SetDeferredRetcode(UT_KEY(CFE_ResourceId_ToIndex), 1+CFE_PLATFORM_SB_MAX_PIPES, -1); for (i = 0; i < (CFE_PLATFORM_SB_MAX_PIPES + 1); i++) { snprintf(PipeName, sizeof(PipeName), "TestPipe%ld", (long) i); @@ -1705,6 +1718,15 @@ void Test_CreatePipe_MaxPipes(void) TEARDOWN(CFE_SB_DeletePipe(PipeIdReturned[i])); } + /* + * Also validate the CFE_SB_CheckPipeDescSlotUsed() helper function in this test, + * as it is used to determine when max pipes has been hit. + */ + CFE_SB.PipeTbl[1].PipeId = CFE_SB_PIPEID_C(UT_SB_MakePipeIdForIndex(1)); + CFE_SB.PipeTbl[2].PipeId = CFE_SB_INVALID_PIPE; + ASSERT_TRUE(CFE_SB_CheckPipeDescSlotUsed(UT_SB_MakePipeIdForIndex(1))); + ASSERT_TRUE(!CFE_SB_CheckPipeDescSlotUsed(UT_SB_MakePipeIdForIndex(2))); + } /* end Test_CreatePipe_MaxPipes */ /* @@ -1729,7 +1751,7 @@ void Test_CreatePipe_SamePipeName(void) /* Second call to CFE_SB_CreatePipe with same PipeName should fail */ ASSERT_EQ(CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName), CFE_SB_PIPE_CR_ERR); - ASSERT_TRUE(CFE_ES_ResourceID_Equal(PipeId, FirstPipeId)); + ASSERT_TRUE(CFE_RESOURCEID_TEST_EQUAL(PipeId, FirstPipeId)); EVTCNT(2); @@ -1818,7 +1840,7 @@ void Test_DeletePipe_InvalidPipeOwner(void) { CFE_SB_PipeId_t PipedId; CFE_SB_PipeD_t *PipeDscPtr; - CFE_ES_ResourceID_t RealOwner; + CFE_ES_AppId_t RealOwner; uint16 PipeDepth = 10; SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); @@ -1828,7 +1850,7 @@ void Test_DeletePipe_InvalidPipeOwner(void) RealOwner = PipeDscPtr->AppId; /* Choose a value that is sure not to be owner */ - PipeDscPtr->AppId = UT_SB_ResourceID_Modify(RealOwner, 1); + PipeDscPtr->AppId = UT_SB_AppID_Modify(RealOwner, 1); ASSERT_EQ(CFE_SB_DeletePipe(PipedId), CFE_SB_BAD_ARGUMENT); EVTCNT(2); @@ -1847,7 +1869,7 @@ void Test_DeletePipe_InvalidPipeOwner(void) void Test_DeletePipe_WithAppid(void) { CFE_SB_PipeId_t PipedId; - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; uint16 PipeDepth = 10; SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); @@ -2031,14 +2053,14 @@ void Test_SetPipeOpts_NotOwner(void) { CFE_SB_PipeId_t PipeID; CFE_SB_PipeD_t *PipeDscPtr; - CFE_ES_ResourceID_t OrigOwner; + CFE_ES_AppId_t OrigOwner; SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); PipeDscPtr = CFE_SB_LocatePipeDescByID(PipeID); OrigOwner = PipeDscPtr->AppId; - PipeDscPtr->AppId = UT_SB_ResourceID_Modify(OrigOwner, 1); + PipeDscPtr->AppId = UT_SB_AppID_Modify(OrigOwner, 1); ASSERT_EQ(CFE_SB_SetPipeOpts(PipeID, 0), CFE_SB_BAD_ARGUMENT); @@ -2461,7 +2483,7 @@ void Test_Subscribe_InvalidPipeOwner(void) CFE_SB_PipeD_t *PipeDscPtr; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 10; - CFE_ES_ResourceID_t RealOwner; + CFE_ES_AppId_t RealOwner; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); @@ -2470,7 +2492,7 @@ void Test_Subscribe_InvalidPipeOwner(void) RealOwner = PipeDscPtr->AppId; /* Choose a value that is sure not to be owner */ - PipeDscPtr->AppId = UT_SB_ResourceID_Modify(RealOwner, 1); + PipeDscPtr->AppId = UT_SB_AppID_Modify(RealOwner, 1); CFE_SB_Subscribe(MsgId, PipeId); EVTCNT(3); @@ -2555,7 +2577,7 @@ void Test_Unsubscribe_Local(void) void Test_Unsubscribe_InvalParam(void) { CFE_SB_PipeId_t TestPipe; - CFE_ES_ResourceID_t CallerId; + CFE_ES_AppId_t CallerId; CFE_SB_PipeD_t *PipeDscPtr; uint16 PipeDepth = 50; CFE_SB_PipeId_t SavedPipeId; @@ -2651,7 +2673,7 @@ void Test_Unsubscribe_InvalidPipeOwner(void) CFE_SB_PipeId_t PipeId; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; CFE_SB_PipeD_t *PipeDscPtr; - CFE_ES_ResourceID_t RealOwner; + CFE_ES_AppId_t RealOwner; uint16 PipeDepth = 10; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); @@ -2663,7 +2685,7 @@ void Test_Unsubscribe_InvalidPipeOwner(void) RealOwner = PipeDscPtr->AppId; /* Choose a value that is sure not be owner */ - PipeDscPtr->AppId = UT_SB_ResourceID_Modify(RealOwner, 1); + PipeDscPtr->AppId = UT_SB_AppID_Modify(RealOwner, 1); ASSERT_EQ(CFE_SB_Unsubscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); EVTCNT(3); @@ -3572,7 +3594,7 @@ void Test_CleanupApp_API(void) CFE_SB_PipeId_t PipeId; CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl = 0; uint16 PipeDepth = 50; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; CFE_ES_GetAppID(&AppID); @@ -3589,7 +3611,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(CFE_ES_RESOURCEID_UNDEFINED); + CFE_SB_CleanUpApp(CFE_ES_APPID_UNDEFINED); /* Attempt again with a valid application ID */ CFE_SB_CleanUpApp(AppID); @@ -3851,7 +3873,7 @@ void Test_OS_MutSem_ErrLogic(void) */ void Test_ReqToSendEvent_ErrLogic(void) { - CFE_ES_ResourceID_t TaskId; + CFE_ES_TaskId_t TaskId; uint32 Bit = 5; /* Clear task bits, then call function, which should set the bit for @@ -3931,7 +3953,7 @@ void Test_CFE_SB_BadPipeInfo(void) CFE_SB_PipeD_t *PipeDscPtr; uint16 PipeDepth = 10; CFE_SB_Qos_t CFE_SB_Default_Qos; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe1")); diff --git a/fsw/cfe-core/unit-test/tbl_UT.c b/fsw/cfe-core/unit-test/tbl_UT.c index f27360e69..783f083ae 100644 --- a/fsw/cfe-core/unit-test/tbl_UT.c +++ b/fsw/cfe-core/unit-test/tbl_UT.c @@ -39,6 +39,7 @@ ** Includes */ #include "tbl_UT.h" +#include "private/cfe_core_resourceid_basevalues.h" /* ** External global variables @@ -55,10 +56,10 @@ CFE_TBL_Handle_t App2TblHandle1; CFE_TBL_Handle_t App2TblHandle2; CFE_TBL_Handle_t ArrayOfHandles[2]; -static const CFE_ES_ResourceID_t UT_TBL_APPID_1 = { 0x02010001 }; -static const CFE_ES_ResourceID_t UT_TBL_APPID_2 = { 0x02010002 }; -static const CFE_ES_ResourceID_t UT_TBL_APPID_3 = { 0x02010003 }; -static const CFE_ES_ResourceID_t UT_TBL_APPID_10 = { 0x0201000A }; +#define UT_TBL_APPID_1 CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 1)) +#define UT_TBL_APPID_2 CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 2)) +#define UT_TBL_APPID_3 CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 3)) +#define UT_TBL_APPID_10 CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 10)) void *Tbl1Ptr = NULL; void *Tbl2Ptr = NULL; @@ -1048,7 +1049,7 @@ void Test_CFE_TBL_GetHkData(void) int32 NumLoadPendingIndex = CFE_PLATFORM_TBL_MAX_NUM_TABLES - 1; int32 FreeSharedBuffIndex = CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS - 1; int32 ValTableIndex = CFE_PLATFORM_TBL_MAX_NUM_VALIDATIONS - 1; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; /* Get the AppID being used for UT */ CFE_ES_GetAppID(&AppID); @@ -1143,7 +1144,7 @@ void Test_CFE_TBL_DumpRegCmd(void) { int q; CFE_TBL_DumpRegistryCmd_t DumpRegCmd; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; /* Get the AppID being used for UT */ CFE_ES_GetAppID(&AppID); @@ -1239,7 +1240,7 @@ void Test_CFE_TBL_DumpCmd(void) uint8 *BuffPtr = &Buff; CFE_TBL_LoadBuff_t Load = {0}; CFE_TBL_DumpCmd_t DumpCmd; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; CFE_ES_GetAppID(&AppID); @@ -1419,7 +1420,7 @@ void Test_CFE_TBL_LoadCmd(void) CFE_FS_Header_t StdFileHeader; CFE_TBL_LoadBuff_t BufferPtr = CFE_TBL_TaskData.LoadBuffs[0]; CFE_TBL_LoadCmd_t LoadCmd; - CFE_ES_ResourceID_t AppID; + CFE_ES_AppId_t AppID; CFE_ES_GetAppID(&AppID); @@ -2254,7 +2255,7 @@ void Test_CFE_TBL_Register(void) /* a. Perform test */ for (i = 0; i < CFE_PLATFORM_TBL_MAX_CRITICAL_TABLES; i++) { - CFE_TBL_TaskData.CritReg[i].CDSHandle = CFE_ES_RESOURCEID_UNDEFINED; + CFE_TBL_TaskData.CritReg[i].CDSHandle = CFE_ES_CDS_BAD_HANDLE; } RtnCode = CFE_TBL_Register(&TblHandle1, "UT_Table1", @@ -3161,7 +3162,7 @@ void Test_CFE_TBL_GetAddresses(void) * allowed to see */ UT_InitData(); - UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); + UT_SetAppID(CFE_ES_APPID_UNDEFINED); RtnCode = CFE_TBL_GetAddresses(ArrayOfPtrsToTblPtrs, 2, ArrayOfHandles); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3208,7 +3209,7 @@ void Test_CFE_TBL_Validate(void) * not allowed to see */ UT_InitData(); - UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); + UT_SetAppID(CFE_ES_APPID_UNDEFINED); RtnCode = CFE_TBL_Validate(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3702,7 +3703,7 @@ void Test_CFE_TBL_Update(void) /* Test processing an update on an application with a bad ID */ UT_InitData(); - UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); + UT_SetAppID(CFE_ES_APPID_UNDEFINED); RtnCode = CFE_TBL_Update(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, @@ -3725,7 +3726,7 @@ void Test_CFE_TBL_GetStatus(void) * application is not allowed to see */ UT_InitData(); - UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); + UT_SetAppID(CFE_ES_APPID_UNDEFINED); RtnCode = CFE_TBL_GetStatus(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -3738,7 +3739,7 @@ void Test_CFE_TBL_GetStatus(void) * application is not allowed to see */ UT_InitData(); - UT_SetAppID(CFE_ES_RESOURCEID_UNDEFINED); + UT_SetAppID(CFE_ES_APPID_UNDEFINED); RtnCode = CFE_TBL_DumpToBuffer(App1TblHandle1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, @@ -4640,9 +4641,9 @@ void Test_CFE_TBL_Internal(void) for (i = 0; i < CFE_PLATFORM_TBL_MAX_CRITICAL_TABLES; i++) { - if ( CFE_ES_ResourceID_Equal(CFE_TBL_TaskData.CritReg[i].CDSHandle, RegRecPtr->CDSHandle) ) + if ( CFE_RESOURCEID_TEST_EQUAL(CFE_TBL_TaskData.CritReg[i].CDSHandle, RegRecPtr->CDSHandle) ) { - CFE_TBL_TaskData.CritReg[i].CDSHandle = CFE_ES_RESOURCEID_RESERVED; + CFE_TBL_TaskData.CritReg[i].CDSHandle = CFE_ES_CDSHANDLE_C(CFE_RESOURCEID_RESERVED); } } @@ -4690,7 +4691,7 @@ void Test_CFE_TBL_Internal(void) UT_Report(__FILE__, __LINE__, CFE_TBL_TaskData.DumpControlBlocks[3].State == CFE_TBL_DUMP_FREE && - CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED) && + CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED) && CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].Taken == false && RegRecPtr->LoadInProgress == CFE_TBL_NO_LOAD_IN_PROGRESS, @@ -4855,7 +4856,7 @@ void Test_CFE_TBL_Internal(void) UT_Report(__FILE__, __LINE__, CFE_TBL_TaskData.DumpControlBlocks[3].State == CFE_TBL_DUMP_PENDING && - CFE_ES_ResourceID_Equal(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED), + CFE_RESOURCEID_TEST_EQUAL(RegRecPtr->OwnerAppId, CFE_TBL_NOT_OWNED), "CFE_TBL_CleanUpApp", "Execute clean up - no dumped tables to delete, application " "doesn't own table"); diff --git a/fsw/cfe-core/unit-test/time_UT.c b/fsw/cfe-core/unit-test/time_UT.c index 91c922c53..190252dc5 100644 --- a/fsw/cfe-core/unit-test/time_UT.c +++ b/fsw/cfe-core/unit-test/time_UT.c @@ -3240,7 +3240,7 @@ void Test_CleanUpApp(void) uint16 Count; int32 Status = CFE_SUCCESS; uint32 AppIndex; - CFE_ES_ResourceID_t TestAppId; + CFE_ES_AppId_t TestAppId; UtPrintf("Begin Test Cleanup App"); @@ -3316,7 +3316,7 @@ void Test_CleanUpApp(void) * This is effectively a no-op but here for coverage */ AppIndex = 99999; UT_SetDataBuffer(UT_KEY(CFE_ES_AppID_ToIndex), &AppIndex, sizeof(AppIndex), false); - Status = CFE_TIME_CleanUpApp(CFE_ES_RESOURCEID_UNDEFINED); + Status = CFE_TIME_CleanUpApp(CFE_ES_APPID_UNDEFINED); UT_Report(__FILE__, __LINE__, Status == CFE_TIME_CALLBACK_NOT_REGISTERED, "CFE_TIME_CleanUpApp", diff --git a/fsw/cfe-core/unit-test/ut_support.c b/fsw/cfe-core/unit-test/ut_support.c index 62a4454f1..4b8dbc195 100644 --- a/fsw/cfe-core/unit-test/ut_support.c +++ b/fsw/cfe-core/unit-test/ut_support.c @@ -43,7 +43,7 @@ uint8 UT_Endianess; static char UT_appname[80]; static char UT_subsys[5]; -static CFE_ES_ResourceID_t UT_AppID; +static CFE_ES_AppId_t UT_AppID; static uint32 UT_LastCDSSize = 0; typedef union @@ -275,7 +275,7 @@ int32 UT_SoftwareBusSnapshotHook(void *UserObj, int32 StubRetcode, uint32 CallCo /* ** Set the application ID returned by unit test stubs */ -void UT_SetAppID(CFE_ES_ResourceID_t AppID_in) +void UT_SetAppID(CFE_ES_AppId_t AppID_in) { UT_AppID = AppID_in; UT_SetDataBuffer(UT_KEY(CFE_ES_GetAppID), (uint8*)&UT_AppID, sizeof(UT_AppID), false); diff --git a/fsw/cfe-core/unit-test/ut_support.h b/fsw/cfe-core/unit-test/ut_support.h index 4619196c5..5b3e38660 100644 --- a/fsw/cfe-core/unit-test/ut_support.h +++ b/fsw/cfe-core/unit-test/ut_support.h @@ -317,7 +317,7 @@ int32 UT_SoftwareBusSnapshotHook(void *UserObj, int32 StubRetcode, uint32 CallCo ** This function does not return a value. ** ******************************************************************************/ -void UT_SetAppID(CFE_ES_ResourceID_t AppID_in); +void UT_SetAppID(CFE_ES_AppId_t AppID_in); /*****************************************************************************/ /** diff --git a/fsw/cfe-core/ut-stubs/CMakeLists.txt b/fsw/cfe-core/ut-stubs/CMakeLists.txt index f2bc4acf6..14e388a7e 100644 --- a/fsw/cfe-core/ut-stubs/CMakeLists.txt +++ b/fsw/cfe-core/ut-stubs/CMakeLists.txt @@ -19,6 +19,7 @@ add_library(ut_cfe-core_stubs STATIC ut_es_stubs.c ut_evs_stubs.c ut_msg_stubs.c + ut_resourceid_stubs.c ut_sb_stubs.c ut_tbl_stubs.c ut_time_stubs.c diff --git a/fsw/cfe-core/ut-stubs/ut_es_stubs.c b/fsw/cfe-core/ut-stubs/ut_es_stubs.c index d169ab44b..f10629b61 100644 --- a/fsw/cfe-core/ut-stubs/ut_es_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_es_stubs.c @@ -35,6 +35,7 @@ #include #include "cfe.h" #include "private/cfe_private.h" +#include "private/cfe_core_resourceid_basevalues.h" #include "utstubs.h" #include "utassert.h" @@ -64,26 +65,26 @@ * Default value to return from calls that output an App ID, if the * test case does not provide a value */ -#define CFE_UT_ES_DEFAULT_APPID ((CFE_ES_ResourceID_t){0x02010001}) +#define CFE_UT_ES_DEFAULT_APPID CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 1)) /* * Default value to return from calls that output a Task ID, if the * test case does not provide a value */ -#define CFE_UT_ES_DEFAULT_TASKID ((CFE_ES_ResourceID_t){0x02020001}) +#define CFE_UT_ES_DEFAULT_TASKID CFE_ES_TASKID_C(CFE_ResourceId_FromInteger(CFE_ES_TASKID_BASE + 1)) /* * Default value to return from calls that output a CDS ID, if the * test case does not provide a value */ -#define CFE_UT_ES_DEFAULT_CDSID ((CFE_ES_ResourceID_t){0x02050001}) +#define CFE_UT_ES_DEFAULT_CDSID CFE_ES_CDSHANDLE_C(CFE_ResourceId_FromInteger(CFE_ES_CDSBLOCKID_BASE + 1)) /* * Invalid value to output from calls as resource ID for the * calls that return failure. If subsequently used by application code, * it will likely induce a segfault or other noticeably bad behavior. */ -#define CFE_UT_ES_ID_INVALID ((CFE_ES_ResourceID_t){0xDEADBEEF}) +#define CFE_UT_ES_ID_INVALID CFE_ResourceId_FromInteger(0xDEADBEEF) /* ** Functions @@ -108,7 +109,7 @@ ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, +CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, CFE_ES_StackPointer_t StackPtr, @@ -151,12 +152,12 @@ CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr, ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) +int32 CFE_ES_GetAppID(CFE_ES_AppId_t *AppIdPtr) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppID), AppIdPtr); int32 status; - CFE_ES_ResourceID_t *IdBuff; + CFE_ES_AppId_t *IdBuff; size_t BuffSize; size_t Position; @@ -177,18 +178,18 @@ int32 CFE_ES_GetAppID(CFE_ES_ResourceID_t *AppIdPtr) if (status < 0) { - *AppIdPtr = CFE_UT_ES_ID_INVALID; + *AppIdPtr = CFE_ES_APPID_C(CFE_UT_ES_ID_INVALID); } return status; } -int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) +int32 CFE_ES_GetTaskID(CFE_ES_TaskId_t *TaskIdPtr) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetTaskID), TaskIdPtr); int32 status; - CFE_ES_ResourceID_t *IdBuff; + CFE_ES_TaskId_t *IdBuff; size_t BuffSize; size_t Position; @@ -209,7 +210,7 @@ int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) if (status < 0) { - *TaskIdPtr = CFE_UT_ES_ID_INVALID; + *TaskIdPtr = CFE_ES_TASKID_C(CFE_UT_ES_ID_INVALID); } return status; @@ -236,7 +237,7 @@ int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr) ** Returns either CFE_ES_ERR_NAME_NOT_FOUND or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) +int32 CFE_ES_GetAppIDByName(CFE_ES_AppId_t *AppIdPtr, const char *AppName) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), AppIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), AppName); @@ -244,7 +245,7 @@ int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) size_t UserBuffSize; size_t BuffPosition; const char *NameBuff; - CFE_ES_ResourceID_t *IdBuff; + CFE_ES_AppId_t *IdBuff; int32 status; status = UT_DEFAULT_IMPL(CFE_ES_GetAppIDByName); @@ -274,7 +275,7 @@ int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) if (status < 0) { - *AppIdPtr = CFE_UT_ES_ID_INVALID; + *AppIdPtr = CFE_ES_APPID_C(CFE_UT_ES_ID_INVALID); } return status; @@ -297,7 +298,7 @@ int32 CFE_ES_GetAppIDByName(CFE_ES_ResourceID_t *AppIdPtr, const char *AppName) ** Returns CFE_SUCCESS. ** ******************************************************************************/ -CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t BufferLength) +CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_AppId_t AppId, size_t BufferLength) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppName), AppName); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetAppName), AppId); @@ -824,7 +825,7 @@ uint32 CFE_ES_CalculateCRC(const void *DataPtr, size_t DataLength, uint32 InputC ** Returns CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId) +int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_TaskId_t TaskId) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetTaskInfo), TaskInfo); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetTaskInfo), TaskId); @@ -1138,7 +1139,7 @@ void CFE_ES_ExitChildTask(void) UT_DEFAULT_IMPL(CFE_ES_ExitChildTask); } -int32 CFE_ES_DeleteApp(CFE_ES_ResourceID_t AppID) +int32 CFE_ES_DeleteApp(CFE_ES_AppId_t AppID) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_DeleteApp), AppID); @@ -1149,7 +1150,7 @@ int32 CFE_ES_DeleteApp(CFE_ES_ResourceID_t AppID) return status; } -int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) +int32 CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_DeleteChildTask), TaskId); @@ -1160,7 +1161,7 @@ int32 CFE_ES_DeleteChildTask(CFE_ES_ResourceID_t TaskId) return status; } -int32 CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId) +int32 CFE_ES_DeleteGenCounter(CFE_ES_CounterId_t CounterId) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_DeleteGenCounter), CounterId); @@ -1171,7 +1172,7 @@ int32 CFE_ES_DeleteGenCounter(CFE_ES_ResourceID_t CounterId) return status; } -int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) +int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_AppId_t AppId) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppInfo), AppInfo); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetAppInfo), AppId); @@ -1183,7 +1184,7 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) return status; } -int32 CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count) +int32 CFE_ES_GetGenCount(CFE_ES_CounterId_t CounterId, uint32 *Count) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetGenCount), CounterId); UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetGenCount), Count); @@ -1195,7 +1196,7 @@ int32 CFE_ES_GetGenCount(CFE_ES_ResourceID_t CounterId, uint32 *Count) return status; } -int32 CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName) +int32 CFE_ES_GetGenCounterIDByName(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetGenCounterIDByName), CounterIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetGenCounterIDByName), CounterName); @@ -1219,7 +1220,7 @@ int32 CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t H return status; } -int32 CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId) +int32 CFE_ES_IncrementGenCounter(CFE_ES_CounterId_t CounterId) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_IncrementGenCounter), CounterId); @@ -1230,7 +1231,7 @@ int32 CFE_ES_IncrementGenCounter(CFE_ES_ResourceID_t CounterId) return status; } -int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *CounterName) +int32 CFE_ES_RegisterGenCounter(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName) { UT_Stub_RegisterContext(UT_KEY(CFE_ES_RegisterGenCounter), CounterIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_ES_RegisterGenCounter), CounterName); @@ -1242,7 +1243,7 @@ int32 CFE_ES_RegisterGenCounter(CFE_ES_ResourceID_t *CounterIdPtr, const char *C return status; } -int32 CFE_ES_ReloadApp(CFE_ES_ResourceID_t AppID, const char *AppFileName) +int32 CFE_ES_ReloadApp(CFE_ES_AppId_t AppID, const char *AppFileName) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_ReloadApp), AppID); UT_Stub_RegisterContext(UT_KEY(CFE_ES_ReloadApp), AppFileName); @@ -1265,7 +1266,7 @@ int32 CFE_ES_ResetCFE(uint32 ResetType) return status; } -int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) +int32 CFE_ES_RestartApp(CFE_ES_AppId_t AppID) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_RestartApp), AppID); @@ -1276,7 +1277,7 @@ int32 CFE_ES_RestartApp(CFE_ES_ResourceID_t AppID) return status; } -int32 CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count) +int32 CFE_ES_SetGenCount(CFE_ES_CounterId_t CounterId, uint32 Count) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_SetGenCount), CounterId); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_SetGenCount), Count); @@ -1288,14 +1289,14 @@ int32 CFE_ES_SetGenCount(CFE_ES_ResourceID_t CounterId, uint32 Count) return status; } -int32 CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx) +int32 CFE_ES_AppID_ToIndex(CFE_ES_AppId_t AppID, uint32 *Idx) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_AppID_ToIndex), AppID); UT_Stub_RegisterContext(UT_KEY(CFE_ES_AppID_ToIndex), Idx); int32 return_code; - *Idx = CFE_ES_ResourceID_ToInteger(AppID) & 0xFFFF; + *Idx = CFE_RESOURCEID_TO_ULONG(AppID) & 0xFFFF; return_code = UT_DEFAULT_IMPL_RC(CFE_ES_AppID_ToIndex, 1); if (return_code == 1) @@ -1312,14 +1313,14 @@ int32 CFE_ES_AppID_ToIndex(CFE_ES_ResourceID_t AppID, uint32 *Idx) return return_code; } -int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx) +int32 CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_TaskID_ToIndex), TaskID); UT_Stub_RegisterContext(UT_KEY(CFE_ES_TaskID_ToIndex), Idx); int32 return_code; - *Idx = CFE_ES_ResourceID_ToInteger(TaskID) & 0xFFFF; + *Idx = CFE_RESOURCEID_TO_ULONG(TaskID) & 0xFFFF; return_code = UT_DEFAULT_IMPL_RC(CFE_ES_TaskID_ToIndex, 1); if (return_code == 1) @@ -1335,49 +1336,3 @@ int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx) return return_code; } - -CFE_ES_ResourceID_t CFE_ES_FindNextAvailableId(CFE_ES_ResourceID_t StartId, uint32 TableSize, bool (*CheckFunc)(CFE_ES_ResourceID_t)) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_FindNextAvailableId), StartId); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_FindNextAvailableId), TableSize); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_FindNextAvailableId), CheckFunc); - - int32 return_code; - - /* Using "1" by default here produces a sequential result when called multiple times */ - return_code = UT_DEFAULT_IMPL_RC(CFE_ES_FindNextAvailableId, 1); - - if (return_code < 0) - { - return CFE_ES_RESOURCEID_UNDEFINED; - } - - /* - * The test case may set the return code to indicate the offset from the start ID - */ - return CFE_ES_ResourceID_FromInteger(CFE_ES_ResourceID_ToInteger(StartId) + return_code); -} - -int32 CFE_ES_ResourceID_ToIndex(uint32 Serial, uint32 TableSize, uint32 *Idx) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_ResourceID_ToIndex), Serial); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_ResourceID_ToIndex), TableSize); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_ResourceID_ToIndex), Idx); - - int32 return_code; - - return_code = UT_DEFAULT_IMPL(CFE_ES_ResourceID_ToIndex); - - if (return_code < 0) - { - /* fill with a very bad value that should cause a problem if used */ - *Idx = 0xDEADBEEF; - } - else if (UT_Stub_CopyToLocal(UT_KEY(CFE_ES_ResourceID_ToIndex), Idx, sizeof(*Idx)) < sizeof(*Idx)) - { - /* fill with default value if unspecified by test case */ - *Idx = Serial % TableSize; - } - - return return_code; -} diff --git a/fsw/cfe-core/ut-stubs/ut_evs_stubs.c b/fsw/cfe-core/ut-stubs/ut_evs_stubs.c index 5aa12224e..991f79b19 100644 --- a/fsw/cfe-core/ut-stubs/ut_evs_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_evs_stubs.c @@ -241,7 +241,7 @@ int32 CFE_EVS_Register(void *Filters, ******************************************************************************/ int32 CFE_EVS_SendEventWithAppID(uint16 EventID, uint16 EventType, - CFE_ES_ResourceID_t AppID, + CFE_ES_AppId_t AppID, const char *Spec, ...) { @@ -288,7 +288,7 @@ int32 CFE_EVS_SendEventWithAppID(uint16 EventID, ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_EVS_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_EVS_CleanUpApp(CFE_ES_AppId_t AppId) { int32 status; diff --git a/fsw/cfe-core/ut-stubs/ut_resourceid_stubs.c b/fsw/cfe-core/ut-stubs/ut_resourceid_stubs.c new file mode 100644 index 000000000..308a6e100 --- /dev/null +++ b/fsw/cfe-core/ut-stubs/ut_resourceid_stubs.c @@ -0,0 +1,178 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* + * Includes + */ +#include "osapi.h" +#include "cfe.h" +#include "utstubs.h" +#include "cfe_resourceid_api.h" +#include "cfe_resourceid_basevalue.h" + + +uint32 CFE_ResourceId_GetBase(CFE_ResourceId_t ResourceId) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_GetBase), ResourceId); + + int32 return_code; + + return_code = UT_DEFAULT_IMPL_RC(CFE_ResourceId_GetBase, -1); + + /* If a return code value was set, return it directly */ + if (return_code >= 0) + { + return (uint32)return_code; + } + + /* otherwise mimic a typical output (mask upper bits) */ + return CFE_ResourceId_ToInteger(ResourceId) & ~((uint32)CFE_RESOURCEID_MAX); +} + +uint32 CFE_ResourceId_GetSerial(CFE_ResourceId_t ResourceId) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_GetSerial), ResourceId); + + int32 return_code; + + return_code = UT_DEFAULT_IMPL_RC(CFE_ResourceId_GetSerial, -1); + + /* If a return code value was set, return it directly */ + if (return_code >= 0) + { + return (uint32)return_code; + } + + /* otherwise mimic a typical output (mask lower bits) */ + return (CFE_ResourceId_ToInteger(ResourceId) & ((uint32)CFE_RESOURCEID_MAX)); +} + +CFE_ResourceId_t CFE_ResourceId_FindNext(CFE_ResourceId_t StartId, uint32 TableSize, bool (*CheckFunc)(CFE_ResourceId_t)) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_FindNext), StartId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_FindNext), TableSize); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_FindNext), CheckFunc); + + int32 return_code; + + /* Using "1" by default here produces a sequential result when called multiple times */ + return_code = UT_DEFAULT_IMPL_RC(CFE_ResourceId_FindNext, 1); + + if (return_code < 0) + { + return CFE_RESOURCEID_UNDEFINED; + } + + /* + * The test case may set the return code to indicate the offset from the start ID + */ + return CFE_ResourceId_FromInteger(CFE_ResourceId_ToInteger(StartId) + return_code); +} + +int32 CFE_ResourceId_ToIndex(CFE_ResourceId_t Id, uint32 BaseValue, uint32 TableSize, uint32 *Idx) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToIndex), Id); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToIndex), BaseValue); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToIndex), TableSize); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToIndex), Idx); + + int32 return_code; + + return_code = UT_DEFAULT_IMPL(CFE_ResourceId_ToIndex); + + if (return_code < 0) + { + /* fill with a very bad value that should cause a problem if used */ + *Idx = 0xDEADBEEF; + } + else if (UT_Stub_CopyToLocal(UT_KEY(CFE_ResourceId_ToIndex), Idx, sizeof(*Idx)) < sizeof(*Idx)) + { + /* fill with default value if unspecified by test case */ + if (CFE_ResourceId_IsDefined(Id)) + { + *Idx = (CFE_ResourceId_ToInteger(Id) - BaseValue) % TableSize; + } + else + { + *Idx = 0xDEADBEEF; + return_code = CFE_ES_ERR_RESOURCEID_NOT_VALID; + } + } + + return return_code; +} + +#ifdef jphfix +/*********************************************************************/ +/* + * CFE_ResourceId_ToOSAL + * + * For complete API information, see prototype in header + */ +osal_id_t CFE_ResourceId_ToOSAL(CFE_ResourceId_t id) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToOSAL), id); + + int32 return_code; + osal_id_t idbuf; + + return_code = UT_DEFAULT_IMPL(CFE_ResourceId_ToOSAL); + + if (return_code != CFE_SUCCESS) + { + idbuf = OS_OBJECT_ID_UNDEFINED; + } + else if (UT_Stub_CopyToLocal(UT_KEY(CFE_ResourceId_ToOSAL), &idbuf, sizeof(idbuf)) < sizeof(idbuf)) + { + /* default output is just the same value with the mark unset */ + idbuf = OS_ObjectIdFromInteger(CFE_ResourceId_ToInteger(id) & ~CFE_RESOURCEID_MARK); + } + + return idbuf; +} + +/*********************************************************************/ +/* + * CFE_ResourceId_FromOSAL + * + * For complete API information, see prototype in header + */ +CFE_ResourceId_t CFE_ResourceId_FromOSAL(osal_id_t id) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_FromOSAL), id); + + int32 return_code; + CFE_ResourceId_t idbuf; + + return_code = UT_DEFAULT_IMPL(CFE_ResourceId_FromOSAL); + + if (return_code != CFE_SUCCESS) + { + idbuf = CFE_RESOURCEID_UNDEFINED; + } + else if (UT_Stub_CopyToLocal(UT_KEY(CFE_ResourceId_FromOSAL), &idbuf, sizeof(idbuf)) < sizeof(idbuf)) + { + /* default output is just the same value with the mark set */ + idbuf = CFE_ResourceId_FromInteger(OS_ObjectIdToInteger(id) | CFE_RESOURCEID_MARK); + } + + return idbuf; +} +#endif diff --git a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c b/fsw/cfe-core/ut-stubs/ut_sb_stubs.c index a6bf2162d..358cc8b1a 100644 --- a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_sb_stubs.c @@ -866,7 +866,7 @@ size_t CFE_SB_GetTotalMsgLength(const CFE_MSG_Message_t *MsgPtr) ** This function does not return a value. ** ******************************************************************************/ -int32 CFE_SB_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId) { int32 status; diff --git a/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c b/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c index c2fedd38b..f9df4806a 100644 --- a/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c @@ -91,7 +91,7 @@ void CFE_TBL_TaskMain(void) ** Returns CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_TBL_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_TBL_CleanUpApp(CFE_ES_AppId_t AppId) { int32 status; diff --git a/fsw/cfe-core/ut-stubs/ut_time_stubs.c b/fsw/cfe-core/ut-stubs/ut_time_stubs.c index 51a8df2c9..6d86b9625 100644 --- a/fsw/cfe-core/ut-stubs/ut_time_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_time_stubs.c @@ -171,7 +171,7 @@ CFE_TIME_SysTime_t CFE_TIME_GetTime(void) ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_TIME_CleanUpApp(CFE_ES_ResourceID_t AppId) +int32 CFE_TIME_CleanUpApp(CFE_ES_AppId_t AppId) { int32 status; diff --git a/modules/cfe_testcase/src/es_test.c b/modules/cfe_testcase/src/es_test.c index 2a8cb3784..f98f7bf2d 100644 --- a/modules/cfe_testcase/src/es_test.c +++ b/modules/cfe_testcase/src/es_test.c @@ -35,7 +35,7 @@ void ES_Test_AppId(void) { - CFE_ES_ResourceID_t AppId; + CFE_ES_AppId_t AppId; char AppNameBuf[OS_MAX_API_NAME + 4]; UtAssert_INT32_EQ(CFE_ES_GetAppID(&AppId), CFE_SUCCESS); diff --git a/modules/resourceid/CMakeLists.txt b/modules/resourceid/CMakeLists.txt new file mode 100644 index 000000000..5550cb33d --- /dev/null +++ b/modules/resourceid/CMakeLists.txt @@ -0,0 +1,18 @@ +################################################################## +# +# cFE resource ID module CMake build recipe +# +################################################################## + +project(CFE_RESOURCEID C) + +# Module library +set(resourceid_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_resourceid_api.c) +add_library(resourceid STATIC ${resourceid_SOURCES}) + +target_include_directories(resourceid PUBLIC inc) + +# Add unit test coverage subdirectory +if(ENABLE_UNIT_TESTS) + add_subdirectory(unit-test-coverage) +endif(ENABLE_UNIT_TESTS) diff --git a/modules/resourceid/arch_build.cmake b/modules/resourceid/arch_build.cmake new file mode 100644 index 000000000..9d77078a7 --- /dev/null +++ b/modules/resourceid/arch_build.cmake @@ -0,0 +1,13 @@ +########################################################### +# +# Resource ID arch build setup +# +# This file is evaluated as part of the "prepare" stage +# and can be used to set up prerequisites for the build, +# such as generating header files +# +########################################################### + +# allow all other code to refer to the public API in the "inc" dir +# ideally this should use an interface library instead +include_directories(${CMAKE_CURRENT_LIST_DIR}/inc) diff --git a/modules/resourceid/mission_build.cmake b/modules/resourceid/mission_build.cmake new file mode 100644 index 000000000..31bd3e9d0 --- /dev/null +++ b/modules/resourceid/mission_build.cmake @@ -0,0 +1,32 @@ +########################################################### +# +# Resource ID mission build setup +# +# This file is evaluated as part of the "prepare" stage +# and can be used to set up prerequisites for the build, +# such as generating header files +# +########################################################### + +# Check if strict/enforcing typedef should be used +if (MISSION_RESOURCEID_MODE STREQUAL "STRICT") + set(RESOURCEID_HDR_FILE "cfe_resourceid_strict.h") +else () + set(RESOURCEID_HDR_FILE "cfe_resourceid_simple.h") +endif () + +# Generate the header definition files, use local default for this module) +generate_config_includefile( + FILE_NAME "cfe_resourceid_typedef.h" + FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/option/${RESOURCEID_HDR_FILE}" +) + +# Resource ID base value header +# Currently the "osal compatible" version is the only provided implementation, +# but missions can provide their own if desired to override this. +generate_config_includefile( + FILE_NAME "cfe_resourceid_basevalue.h" + FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/option/cfe_resourceid_osal_compatible.h" +) + +include_directories(${CMAKE_CURRENT_LIST_DIR}/inc) diff --git a/modules/resourceid/option/cfe_resourceid_osal_compatible.h b/modules/resourceid/option/cfe_resourceid_osal_compatible.h new file mode 100644 index 000000000..822dea588 --- /dev/null +++ b/modules/resourceid/option/cfe_resourceid_osal_compatible.h @@ -0,0 +1,79 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * \file cfe_resourceid_osal_compatible.h + * + * An implementation of CFE resource ID base values/limits that will be + * compatible with OSAL IDs. This is intended as a transitional tool to + * provide runtime value uniqueness, particularly when the "simple" (compatible) + * resource ID implementation is used. In this mode, compiler type checking + * is disabled, and so OSAL IDs can be silently interchanged with CFE IDs. + * + * However, by ensuring uniqueness in the runtime values, any ID handling + * errors may at least be detectable at runtime. + * + * This still works fine with the "strict" resource ID option, but is less + * important as the compiler type checking should prevent this type of error + * before the code even runs. + * + * The downside to this implementation is that it has a dependency on the + * OSAL ID structure. + */ + +#ifndef CFE_RESOURCEID_OSAL_COMPATIBLE_H +#define CFE_RESOURCEID_OSAL_COMPATIBLE_H + +/* +** Include Files +*/ +#include "cfe_resourceid_typedef.h" + +/* + * In this configuration, CFE resource IDs are tailored to not + * conflict/overlap with OSAL IDs, and are structured in a similar manner. + */ +#include "osapi-idmap.h" + +/* + * Limits/definitions related to CFE_ResourceId_t values. + * + * Defining based on OSAL ID values makes this object a superset of + * the OSAL ID type, such that OSAL IDs can be represented as resource IDs + * and not conflict with/alias each other. + * + * NOTE: This reflects a bit if "inside knowledge" about how OSAL IDs are + * constructed. The overlap between OSAL IDs and ES IDs may not always be + * consistent, and they can diverge in a future version. + */ +#define CFE_RESOURCEID_SHIFT OS_OBJECT_TYPE_SHIFT +#define CFE_RESOURCEID_MAX OS_OBJECT_INDEX_MASK + + +/** + * @brief A macro to generate a CFE resource ID base value from an offset + * + * Each CFE ID range is effectively an extension of OSAL ID ranges by + * starting at OS_OBJECT_TYPE_USER. + */ +#define CFE_RESOURCEID_MAKE_BASE(offset) (CFE_RESOURCEID_MARK | ((offset) << CFE_RESOURCEID_SHIFT)) + + +#endif /* CFE_RESOURCEID_OSAL_COMPATIBLE_H */ diff --git a/modules/resourceid/option/cfe_resourceid_simple.h b/modules/resourceid/option/cfe_resourceid_simple.h new file mode 100644 index 000000000..e92c31d9b --- /dev/null +++ b/modules/resourceid/option/cfe_resourceid_simple.h @@ -0,0 +1,64 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#ifndef CFE_RESOURCEID_SIMPLE_H +#define CFE_RESOURCEID_SIMPLE_H + +#include "common_types.h" + + +/** + * @brief A type that provides a common, abstract identifier for + * all ES managed resources (e.g. apps, tasks, counters, etc). + * + * Fundamentally an unsigned integer but users should treat it as + * opaque, and only go through the ES API for introspection. + */ +typedef uint32 CFE_ResourceId_t; + +/** + * @brief A macro providing a type for app-specific IDs + * + * Local ID types are just direct typedefs to CFE_ResourceId_t in this mode, + * this means all ID values can be interchanged. + */ +#define CFE_RESOURCEID_BASE_TYPE CFE_ResourceId_t + + +/** + * @brief A fixed bit that will be set in all CFE resource ID values + * + * In simple mode this is zero/disabled so that OSAL IDs and CFE IDs will + * have the same underlying values. This replicates historical behavior where + * CFE Task IDs and OSAL task IDs are same thing and are interchangable. + */ +#define CFE_RESOURCEID_MARK 0 + + +/* + * Wrap/Unwrap macros. + * + * In simple mode theese are a pass through/no-op as values are not + * wrapped/protected. + */ +#define CFE_RESOURCEID_WRAP(x) x +#define CFE_RESOURCEID_UNWRAP(x) x + +#endif /* CFE_RESOURCEID_SIMPLE_H */ diff --git a/modules/resourceid/option/cfe_resourceid_strict.h b/modules/resourceid/option/cfe_resourceid_strict.h new file mode 100644 index 000000000..b47185f39 --- /dev/null +++ b/modules/resourceid/option/cfe_resourceid_strict.h @@ -0,0 +1,87 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#ifndef CFE_RESOURCEID_STRICT_H +#define CFE_RESOURCEID_STRICT_H + +#include "common_types.h" + +/* + * Inform other code that the "strict mode" is enabled for resource IDs + * + * This in turn allows ES to adjust other macros/conversions as necessary + * to work with the strict type checking. + */ +#define CFE_RESOURCEID_STRICT_MODE + +/** + * @brief A type that provides a common, abstract identifier for + * all CFE managed resources (e.g. apps, tasks, counters, etc). + * + * Fundamentally an unsigned integer but users should treat it as + * opaque, and only go through the ES API for introspection. + * + */ +typedef struct +{ + uint32 id; +} CFE_ResourceId_t; + +/** + * @brief A macro to generate a basetype for app-specific IDs + * + * Resource IDs may be "wrapped" a second time to make a unique + * typedef for application-specific ID values. + * + * Defining this base type as a macro rather than a typedef is intentional + * such that every time this is used it makes an equivalent but different + * type. That is, it is a different type per the compiler type checking + * but has the same content/structure. + */ +#define CFE_RESOURCEID_BASE_TYPE \ + struct \ + { \ + CFE_ResourceId_t id; \ + } + + +/** + * @brief A fixed bit that should be set in all CFE resource ID values + * + * In strict mode this is nonzero so that OSAL IDs and CFE IDs will have + * different values. This means that CFE Task IDs will not be interchangable + * with OSAL task IDs, either in value or type. + */ +#define CFE_RESOURCEID_MARK 0x02000000 + + +/* + * Wrap/Unwrap macros. + * + * These are helpers for transparently accessing through wrapper types. + * + * These are not type-safe - Whenever possible applications should use + * the type-safe inline functions provided in cfe_resourceid.h instead. + */ +#define CFE_RESOURCEID_WRAP(x) {x} +#define CFE_RESOURCEID_UNWRAP(x) (x).id + + +#endif /* CFE_RESOURCEID_STRICT_H */ diff --git a/modules/resourceid/src/cfe_resourceid_api.c b/modules/resourceid/src/cfe_resourceid_api.c new file mode 100644 index 000000000..fd7a16718 --- /dev/null +++ b/modules/resourceid/src/cfe_resourceid_api.c @@ -0,0 +1,134 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: +** cfe_resource_api.c +** +** Purpose: +** Function definitions related to CFE resource management +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** cFE Flight Software Application Developers Guide +*/ + +/* +** Includes +*/ +#include +#include +#include + +#include "cfe.h" +#include "cfe_resourceid_api.h" +#include "cfe_resourceid_basevalue.h" + + +/*********************************************************************/ +/* + * CFE_ResourceId_GetBase + * + * For complete API information, see prototype in header + */ +uint32 CFE_ResourceId_GetBase(CFE_ResourceId_t ResourceId) +{ + return (CFE_ResourceId_ToInteger(ResourceId) & ~((uint32)CFE_RESOURCEID_MAX)); +} + +/*********************************************************************/ +/* + * CFE_ResourceId_GetSerial + * + * For complete API information, see prototype in header + */ +uint32 CFE_ResourceId_GetSerial(CFE_ResourceId_t ResourceId) +{ + return (CFE_ResourceId_ToInteger(ResourceId) & ((uint32)CFE_RESOURCEID_MAX)); +} + + +/*********************************************************************/ +/* + * CFE_ResourceId_ToIndex + * + * For complete API information, see prototype in header + */ +int32 CFE_ResourceId_ToIndex(CFE_ResourceId_t Id, uint32 BaseValue, uint32 TableSize, uint32 *Idx) +{ + uint32 Serial; + + if (Idx == NULL) + { + return CFE_ES_ERR_BUFFER; + } + + Serial = CFE_ResourceId_ToInteger(Id) - BaseValue; + + if (Serial > CFE_RESOURCEID_MAX || TableSize == 0) + { + return CFE_ES_ERR_RESOURCEID_NOT_VALID; + } + + *Idx = Serial % TableSize; + return CFE_SUCCESS; +} + +/*********************************************************************/ +/* + * CFE_ResourceId_FindNext + * + * For complete API information, see prototype in header + */ +CFE_ResourceId_t CFE_ResourceId_FindNext(CFE_ResourceId_t StartId, uint32 TableSize, bool (*CheckFunc)(CFE_ResourceId_t)) +{ + uint32 Serial; + uint32 Count; + uint32 ResourceType; + CFE_ResourceId_t CheckId; + bool IsTaken; + + ResourceType = CFE_ResourceId_GetBase(StartId); + Serial = CFE_ResourceId_GetSerial(StartId); + + Count = TableSize; + IsTaken = true; + + do + { + if (Count == 0) + { + CheckId = CFE_RESOURCEID_UNDEFINED; + break; + } + + --Count; + ++Serial; + if (Serial >= CFE_RESOURCEID_MAX) + { + Serial %= TableSize; + } + + CheckId = CFE_ResourceId_FromInteger(ResourceType + Serial); + IsTaken = CheckFunc(CheckId); + } while (IsTaken); + + return CheckId; +} diff --git a/modules/resourceid/unit-test-coverage/CMakeLists.txt b/modules/resourceid/unit-test-coverage/CMakeLists.txt new file mode 100644 index 000000000..42ca3bde8 --- /dev/null +++ b/modules/resourceid/unit-test-coverage/CMakeLists.txt @@ -0,0 +1,29 @@ +################################################################## +# +# cFE unit test build recipe +# +# This CMake file contains the recipe for building the cFE unit tests. +# It is invoked from the parent directory when unit tests are enabled. +# +################################################################## + +# Unit test object library sources, options, and includes +add_library(ut_resourceid_OBJS OBJECT ${resourceid_SOURCES}) +target_compile_options(ut_resourceid_OBJS PRIVATE ${UT_COVERAGE_COMPILE_FLAGS}) + +# Add executable +add_executable(resourceid_UT test_cfe_resourceid.c $) + +# allow direct use of the "option" headers no matter which is actually selected by mission +target_include_directories(resourceid_UT PRIVATE ${CFE_RESOURCEID_SOURCE_DIR}/option) + +# Also add the UT_COVERAGE_LINK_FLAGS to the link command +# This should enable coverage analysis on platforms that support this +target_link_libraries(resourceid_UT + ${UT_COVERAGE_LINK_FLAGS} + ut_assert) + +add_test(resourceid_UT resourceid_UT) +foreach(TGT ${INSTALL_TARGET_LIST}) + install(TARGETS resourceid_UT DESTINATION ${TGT}/${UT_INSTALL_SUBDIR}) +endforeach() diff --git a/modules/resourceid/unit-test-coverage/test_cfe_resourceid.c b/modules/resourceid/unit-test-coverage/test_cfe_resourceid.c new file mode 100644 index 000000000..df59ffeaa --- /dev/null +++ b/modules/resourceid/unit-test-coverage/test_cfe_resourceid.c @@ -0,0 +1,181 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* + * Includes + */ +#include "cfe.h" +#include "cfe_resourceid_api.h" +#include "cfe_resourceid_basevalue.h" +#include "utassert.h" +#include "utstubs.h" +#include "uttest.h" + +#define UT_RESOURCEID_BASE_OFFSET 37 +#define UT_RESOURCEID_TEST_SLOTS 149 /* oddball for test purposes */ + +static bool UT_ResourceId_CheckIdSlotUsed(CFE_ResourceId_t Id) +{ + return UT_DEFAULT_IMPL(UT_ResourceId_CheckIdSlotUsed) != 0; +} + + +void TestResourceID(void) +{ + /* + * Test cases for generic resource ID functions which are + * not sufficiently covered by other app/lib tests. + */ + CFE_ResourceId_t Id; + CFE_ResourceId_t LastId; + int32 status; + uint32 RefBase; + uint32 Count; + uint32 TestBase; + uint32 TestSerial; + uint32 RefSerial; + uint32 TestIndex; + uint32 RefIndex; + + /* Call CFE_ResourceId_FindNext() using an invalid resource type */ + UT_SetDefaultReturnValue(UT_KEY(UT_ResourceId_CheckIdSlotUsed), 1); + Id = CFE_ResourceId_FindNext(CFE_RESOURCEID_UNDEFINED, 5, UT_ResourceId_CheckIdSlotUsed); + UtAssert_True(!CFE_ResourceId_IsDefined(Id), "CFE_ResourceId_FindNext() on undefined resource type"); + + /* Verify that CFE_ResourceId_FindNext() does not repeat until CFE_RESOURCEID_MAX is reached */ + UT_SetDefaultReturnValue(UT_KEY(UT_ResourceId_CheckIdSlotUsed), 0); + RefBase = CFE_RESOURCEID_MAKE_BASE(UT_RESOURCEID_BASE_OFFSET); + LastId = CFE_ResourceId_FromInteger(RefBase); + RefIndex = 1; + RefSerial = 1; + + /* + * In this case it is useful/relevant to call CFE_ResourceId_FindNext() thousands + * of times, in order to exercise and verify the wrap capability. That is, when the + * serial number reaches CFE_RESOURCEID_MAX, it should wrap back around to the + * beginning again. + * + * Note in this loop only _failures_ are asserted, to de-clutter the log - + * otherwise thousands of success cases will be recorded. + */ + Count = CFE_RESOURCEID_MAX - 1; + while (Count > 0) + { + Id = CFE_ResourceId_FindNext(LastId, UT_RESOURCEID_TEST_SLOTS, UT_ResourceId_CheckIdSlotUsed); + if (CFE_ResourceId_ToInteger(Id) - CFE_ResourceId_ToInteger(LastId) != 1) + { + /* Numbers should be incrementing by 1 each time, never decreasing */ + UtAssert_Failed("ID increment error: got=%lx, previous=%lx", CFE_ResourceId_ToInteger(Id), + CFE_ResourceId_ToInteger(LastId)); + break; + } + + TestBase = CFE_ResourceId_GetBase(Id); + if (TestBase != RefBase) + { + UtAssert_Failed("ID base changed: id=%lx, expected=%lx, got=%lx", CFE_ResourceId_ToInteger(Id), + (unsigned long)RefBase, (unsigned long)TestBase); + } + TestSerial = CFE_ResourceId_GetSerial(Id); + if (TestSerial != RefSerial) + { + UtAssert_Failed("ID serial jump: id=%lx, previous=%lx, got=%lx", CFE_ResourceId_ToInteger(Id), + (unsigned long)RefSerial, (unsigned long)TestSerial); + } + + status = CFE_ResourceId_ToIndex(Id, RefBase, UT_RESOURCEID_TEST_SLOTS, &TestIndex); + if (status != CFE_SUCCESS) + { + UtAssert_Failed("CFE_ResourceId_ToIndex() failed: id=%lx, rc=%lx", CFE_ResourceId_ToInteger(Id), + (unsigned long)status); + } + + if (TestIndex != RefIndex) + { + UtAssert_Failed("ID index mismatch: id=%lx, expected=%lu, got=%lu", CFE_ResourceId_ToInteger(Id), + (unsigned long)RefIndex, (unsigned long)TestIndex); + } + + LastId = Id; + --Count; + + /* Adjust to next index value */ + ++RefIndex; + if (RefIndex >= UT_RESOURCEID_TEST_SLOTS) + { + RefIndex = 0; + } + ++RefSerial; + } + + UtAssert_True(Count == 0, "CFE_ResourceId_FindNext() allocated all resource ID space"); + + /* Now verify that CFE_ResourceId_FindNext() recycles the first item again */ + Id = CFE_ResourceId_FindNext(LastId, UT_RESOURCEID_TEST_SLOTS, UT_ResourceId_CheckIdSlotUsed); + UtAssert_True(CFE_ResourceId_IsDefined(Id), "CFE_ResourceId_FindNext() after wrap"); + UtAssert_True(CFE_ResourceId_ToInteger(Id) < (RefBase + UT_RESOURCEID_TEST_SLOTS), "CFE_ResourceId_FindNext() wrap ID"); + + /* + * Confirm outputs are as expected after wrapping around - + * indices should be sequential + */ + UtAssert_UINT32_EQ(CFE_ResourceId_GetBase(Id), RefBase); + + TestSerial = CFE_ResourceId_GetSerial(Id); + UtAssert_True(TestSerial < UT_RESOURCEID_TEST_SLOTS, "ID serial after wrap: id=%lx, previous=%lx, got=%lx", + CFE_ResourceId_ToInteger(Id), (unsigned long)RefSerial, (unsigned long)TestSerial); + + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, UT_RESOURCEID_TEST_SLOTS, &TestIndex), CFE_SUCCESS); + UtAssert_True(TestIndex == RefIndex, "ID index after wrap: id=%lx, expected=%lu, got=%lu", CFE_ResourceId_ToInteger(Id), + (unsigned long)RefIndex, (unsigned long)TestIndex); + + + /* + * Now check that CFE_ResourceId_FindNext() adheres to the CheckFunc. + * Have it search through 4 entries to find one available on the 5th slot. + */ + UT_SetDefaultReturnValue(UT_KEY(UT_ResourceId_CheckIdSlotUsed), true); + UT_SetDeferredRetcode(UT_KEY(UT_ResourceId_CheckIdSlotUsed), 5, false); + RefIndex = (RefIndex + 4) % UT_RESOURCEID_TEST_SLOTS; /* expected */ + RefSerial = TestSerial + 4; + + Id = CFE_ResourceId_FindNext(LastId, UT_RESOURCEID_TEST_SLOTS, UT_ResourceId_CheckIdSlotUsed); + TestSerial = CFE_ResourceId_GetSerial(Id); + UtAssert_True(TestSerial == RefSerial, "ID serial after search: id=%lx, previous=%lx, got=%lx", + CFE_ResourceId_ToInteger(Id), (unsigned long)RefSerial, (unsigned long)TestSerial); + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, UT_RESOURCEID_TEST_SLOTS, &TestIndex), CFE_SUCCESS); + UtAssert_True(TestIndex == RefIndex, "ID index after search: id=%lx, expected=%lu, got=%lu", CFE_ResourceId_ToInteger(Id), + (unsigned long)RefIndex, (unsigned long)TestIndex); + + + /* Validate off-nominal inputs */ + Id = CFE_ResourceId_FindNext(CFE_RESOURCEID_UNDEFINED, 0, NULL); + UtAssert_True(CFE_ResourceId_Equal(Id, CFE_RESOURCEID_UNDEFINED), "CFE_ResourceId_FindNext() bad input: id=%lx", + CFE_ResourceId_ToInteger(Id)); + + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, 1, NULL), CFE_ES_ERR_BUFFER); + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, 0, &TestIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, ~RefBase, 1, &TestIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID); +} + +void UtTest_Setup(void) +{ + UtTest_Add(TestResourceID, NULL, NULL, "Resource ID"); +}