From 095d14902a5313fcb29a2cb3a3d11ec4dccac93a Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 19 Oct 2020 16:34:18 -0400 Subject: [PATCH] Fix #28, Provide Library API similar to App API Allows the existing "CFE_ES_AppInfo_t" structure to be extended to libraries as well as applications by introducing a new value (3) for the Type field. Allows Libraries to be queried via API calls similar to App API. Also extends the Query All/Query One commands to operate on Libraries or Applications. --- fsw/cfe-core/src/es/cfe_es_api.c | 258 ++++++++++++++---- fsw/cfe-core/src/es/cfe_es_apps.c | 211 ++++---------- fsw/cfe-core/src/es/cfe_es_apps.h | 33 ++- fsw/cfe-core/src/es/cfe_es_task.c | 105 +++++-- fsw/cfe-core/src/es/cfe_es_task.h | 6 + fsw/cfe-core/src/inc/cfe_es.h | 76 +++++- fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h | 7 +- 7 files changed, 444 insertions(+), 252 deletions(-) diff --git a/fsw/cfe-core/src/es/cfe_es_api.c b/fsw/cfe-core/src/es/cfe_es_api.c index 78b2feb25..3955160bd 100644 --- a/fsw/cfe-core/src/es/cfe_es_api.c +++ b/fsw/cfe-core/src/es/cfe_es_api.c @@ -965,8 +965,10 @@ int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, uint32 Buff */ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) { - int32 ReturnCode = CFE_SUCCESS; CFE_ES_AppRecord_t *AppRecPtr; + CFE_ES_TaskRecord_t *TaskRecPtr; + int32 Status; + uint32 i; if ( AppInfo == NULL ) { @@ -976,73 +978,233 @@ int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_ResourceID_t AppId) memset(AppInfo, 0, sizeof(*AppInfo)); - /* - ** Get App Record - */ AppRecPtr = CFE_ES_LocateAppRecordByID(AppId); - if ( AppRecPtr == NULL ) + + CFE_ES_LockSharedData(__func__,__LINE__); + + if ( !CFE_ES_AppRecordIsMatch(AppRecPtr, AppId) ) { - CFE_ES_WriteToSysLog("CFE_ES_GetAppInfo: App ID Invalid: %lu\n", + /* + * 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)); - return CFE_ES_ERR_RESOURCEID_NOT_VALID; - } + + Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; + } + else + { + AppInfo->AppId = AppId; + AppInfo->Type = AppRecPtr->Type; + + CFE_ES_CopyModuleBasicInfo(&AppRecPtr->StartParams.BasicInfo, AppInfo); + CFE_ES_CopyModuleStatusInfo(&AppRecPtr->ModuleInfo, AppInfo); + + AppInfo->StackSize = AppRecPtr->StartParams.StackSize; + AppInfo->ExceptionAction = AppRecPtr->StartParams.ExceptionAction; + AppInfo->Priority = AppRecPtr->StartParams.Priority; + AppInfo->MainTaskId = AppRecPtr->MainTaskId; + + /* + ** Calculate the number of child tasks + */ + AppInfo->NumOfChildTasks = 0; + TaskRecPtr = CFE_ES_Global.TaskTable; + for (i=0; iAppId, AppId)) + { + if (CFE_ES_ResourceID_Equal(CFE_ES_TaskRecordGetID(TaskRecPtr), AppInfo->MainTaskId)) + { + /* This is the main task - capture its name and execution count */ + AppInfo->ExecutionCounter = TaskRecPtr->ExecutionCounter; + strncpy(AppInfo->MainTaskName, TaskRecPtr->TaskName, + sizeof(AppInfo->MainTaskName) - 1); + AppInfo->MainTaskName[sizeof(AppInfo->MainTaskName) - 1] = '\0'; + } + else + { + /* This is a child task, no extra info, just increment count */ + ++AppInfo->NumOfChildTasks; + } + } + ++TaskRecPtr; + } + + Status = CFE_SUCCESS; + } + + CFE_ES_UnlockSharedData(__func__,__LINE__); /* - * Note - cannot check if the AppID is active here, - * as the table is not locked. The internal function - * should lock and check. - */ - ReturnCode = CFE_ES_GetAppInfoInternal(AppRecPtr, AppInfo); - if (ReturnCode != CFE_SUCCESS) + ** Get the address information from the OSAL + */ + if (Status == CFE_SUCCESS) { - CFE_ES_WriteToSysLog("CFE_ES_GetAppInfo: App ID Not Active: %lu\n", - CFE_ES_ResourceID_ToInteger(AppId)); + CFE_ES_CopyModuleAddressInfo(AppInfo->ModuleId, AppInfo); } - return(ReturnCode); + return Status; +} + +/* +** 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 Status; + CFE_ES_LibRecord_t *LibRecPtr; + + if ( LibInfo == NULL ) + { + CFE_ES_WriteToSysLog("CFE_ES_GetLibInfo: Invalid Parameter ( Null Pointer )\n"); + return CFE_ES_ERR_BUFFER; + } + + LibRecPtr = CFE_ES_LocateLibRecordByID(LibId); + + CFE_ES_LockSharedData(__func__,__LINE__); + + if ( !CFE_ES_LibRecordIsMatch(LibRecPtr, 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)); + + Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; + } + else + { + LibInfo->AppId = CFE_ES_LibRecordGetID(LibRecPtr);; + LibInfo->Type = CFE_ES_AppType_LIBRARY; + + CFE_ES_CopyModuleBasicInfo(&LibRecPtr->BasicInfo, LibInfo); + CFE_ES_CopyModuleStatusInfo(&LibRecPtr->ModuleInfo, LibInfo); + + Status = CFE_SUCCESS; + } + + CFE_ES_UnlockSharedData(__func__,__LINE__); + + /* + ** Get the address information from the OSAL + */ + if (Status == CFE_SUCCESS) + { + CFE_ES_CopyModuleAddressInfo(LibInfo->ModuleId, LibInfo); + } + + return Status; +} + +/* +** 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) +{ + uint32 ResourceType; + int32 Status; + + ResourceType = CFE_ES_ResourceID_ToInteger(ResourceId); + ResourceType -= ResourceType & CFE_ES_RESOURCEID_MAX; + switch(ResourceType) + { + case CFE_ES_APPID_BASE: + Status = CFE_ES_GetAppInfo(ModuleInfo, ResourceId); + break; + case CFE_ES_LIBID_BASE: + Status = CFE_ES_GetLibInfo(ModuleInfo, 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)); + Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; + break; + + } + + return(Status); -} /* End of CFE_ES_GetAppInfo() */ +} /* End of CFE_ES_GetModuleInfo() */ /* ** 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) { - CFE_ES_TaskRecord_t *TaskRecPtr; - int32 ReturnCode; + CFE_ES_TaskRecord_t *TaskRecPtr; + CFE_ES_AppRecord_t *AppRecPtr; + int32 Status; - if ( TaskInfo == NULL ) - { - CFE_ES_WriteToSysLog("CFE_ES_GetTaskInfo: Invalid Parameter ( Null Pointer )\n"); - return CFE_ES_ERR_BUFFER; - } + if ( TaskInfo == NULL ) + { + CFE_ES_WriteToSysLog("CFE_ES_GetTaskInfo: Invalid Parameter ( Null Pointer )\n"); + return CFE_ES_ERR_BUFFER; + } - memset(TaskInfo, 0, sizeof(*TaskInfo)); + memset(TaskInfo, 0, sizeof(*TaskInfo)); - /* - ** Get Task Record - */ - TaskRecPtr = CFE_ES_LocateTaskRecordByID(TaskId); - if ( TaskRecPtr == NULL ) - { - CFE_ES_WriteToSysLog("CFE_ES_GetTaskInfo: Task ID Not Valid: %lu\n", - CFE_ES_ResourceID_ToInteger(TaskId)); - return CFE_ES_ERR_RESOURCEID_NOT_VALID; - } + TaskRecPtr = CFE_ES_LocateTaskRecordByID(TaskId); - /* - * Note - cannot check if the TaskID is active here, - * as the table is not locked. The internal function - * should lock and check. - */ - ReturnCode = CFE_ES_GetTaskInfoInternal(TaskRecPtr, TaskInfo); - if (ReturnCode != CFE_SUCCESS) - { - CFE_ES_WriteToSysLog("CFE_ES_GetTaskInfo: Task ID Not Active: %lu\n", - CFE_ES_ResourceID_ToInteger(TaskId)); - } + CFE_ES_LockSharedData(__func__,__LINE__); - return(ReturnCode); + if ( !CFE_ES_TaskRecordIsMatch(TaskRecPtr, 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)); + } + else + { + + /* + ** Get the Application ID and Task Name + */ + TaskInfo->AppId = TaskRecPtr->AppId; + strncpy(TaskInfo->TaskName, + CFE_ES_TaskRecordGetName(TaskRecPtr), + sizeof(TaskInfo->TaskName)-1); + TaskInfo->TaskName[sizeof(TaskInfo->TaskName)-1] = '\0'; + + /* + ** Store away the Task ID ( for the QueryAllTasks Cmd ) + */ + TaskInfo->TaskId = CFE_ES_TaskRecordGetID(TaskRecPtr); + + /* + ** Get the Execution counter for the task + */ + TaskInfo->ExecutionCounter = TaskRecPtr->ExecutionCounter; + + /* + ** Get the Application Details + */ + AppRecPtr = CFE_ES_LocateAppRecordByID(TaskRecPtr->AppId); + if (CFE_ES_AppRecordIsMatch(AppRecPtr, TaskRecPtr->AppId)) + { + strncpy(TaskInfo->AppName, + CFE_ES_AppRecordGetName(AppRecPtr), + sizeof(TaskInfo->AppName)-1); + TaskInfo->AppName[sizeof(TaskInfo->AppName)-1] = '\0'; + Status = CFE_SUCCESS; + } + else + { + /* task ID was OK but parent app ID is bad */ + Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; + } + } + + CFE_ES_UnlockSharedData(__func__,__LINE__); + + return(Status); } /* End of CFE_ES_GetTaskInfo() */ diff --git a/fsw/cfe-core/src/es/cfe_es_apps.c b/fsw/cfe-core/src/es/cfe_es_apps.c index a20402195..3800a898c 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.c +++ b/fsw/cfe-core/src/es/cfe_es_apps.c @@ -1713,7 +1713,7 @@ int32 CFE_ES_CleanupTaskResources(CFE_ES_ResourceID_t TaskId) /* **--------------------------------------------------------------------------------------- -** Name: CFE_ES_GetAppInfoInternal +** Name: CFE_ES_CopyModuleBasicInfo ** ** Purpose: Populate the cFE_ES_AppInfo structure with the data for an app. ** @@ -1721,180 +1721,71 @@ int32 CFE_ES_CleanupTaskResources(CFE_ES_ResourceID_t TaskId) ** to check the return code and log any relevant errors based on the context. **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_GetAppInfoInternal(CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_AppInfo_t *AppInfoPtr ) +void CFE_ES_CopyModuleBasicInfo(const CFE_ES_ModuleLoadParams_t *ParamsPtr, CFE_ES_AppInfo_t *AppInfoPtr) { - int32 Status; - int32 ReturnCode; - OS_module_prop_t ModuleInfo; - uint32 i; - CFE_ES_TaskRecord_t *TaskRecPtr; - CFE_ES_ResourceID_t AppId; + strncpy(AppInfoPtr->Name, ParamsPtr->Name, + sizeof(AppInfoPtr->Name)-1); + AppInfoPtr->Name[sizeof(AppInfoPtr->Name)-1] = '\0'; - CFE_ES_LockSharedData(__func__,__LINE__); - - if ( !CFE_ES_AppRecordIsUsed(AppRecPtr) ) - { - Status = CFE_ES_ERR_RESOURCEID_NOT_VALID; - } - else - { - Status = CFE_SUCCESS; - - AppId = CFE_ES_AppRecordGetID(AppRecPtr); - AppInfoPtr->AppId = AppId; - AppInfoPtr->Type = AppRecPtr->Type; - strncpy(AppInfoPtr->Name, - CFE_ES_AppRecordGetName(AppRecPtr), - sizeof(AppInfoPtr->Name)-1); - AppInfoPtr->Name[sizeof(AppInfoPtr->Name)-1] = '\0'; - - strncpy(AppInfoPtr->EntryPoint, AppRecPtr->StartParams.BasicInfo.EntryPoint, - sizeof(AppInfoPtr->EntryPoint) - 1); - AppInfoPtr->EntryPoint[sizeof(AppInfoPtr->EntryPoint) - 1] = '\0'; - - strncpy(AppInfoPtr->FileName, AppRecPtr->StartParams.BasicInfo.FileName, - sizeof(AppInfoPtr->FileName) - 1); - AppInfoPtr->FileName[sizeof(AppInfoPtr->FileName) - 1] = '\0'; - - AppInfoPtr->ModuleId = AppRecPtr->ModuleInfo.ModuleId; - AppInfoPtr->StackSize = AppRecPtr->StartParams.StackSize; - CFE_SB_SET_MEMADDR(AppInfoPtr->StartAddress, AppRecPtr->ModuleInfo.EntryAddress); - AppInfoPtr->ExceptionAction = AppRecPtr->StartParams.ExceptionAction; - AppInfoPtr->Priority = AppRecPtr->StartParams.Priority; - - AppInfoPtr->MainTaskId = AppRecPtr->MainTaskId; - - /* - ** Calculate the number of child tasks - */ - AppInfoPtr->NumOfChildTasks = 0; - TaskRecPtr = CFE_ES_Global.TaskTable; - for (i=0; iAppId, AppId) && - !CFE_ES_ResourceID_Equal(CFE_ES_TaskRecordGetID(TaskRecPtr), AppInfoPtr->MainTaskId) ) - { - AppInfoPtr->NumOfChildTasks++; - } - ++TaskRecPtr; - } - - /* - ** Get the execution counter for the main task - */ - TaskRecPtr = CFE_ES_LocateTaskRecordByID(AppInfoPtr->MainTaskId); - if (CFE_ES_TaskRecordIsMatch(TaskRecPtr,AppInfoPtr->MainTaskId)) - { - AppInfoPtr->ExecutionCounter = TaskRecPtr->ExecutionCounter; - strncpy(AppInfoPtr->MainTaskName, TaskRecPtr->TaskName, - sizeof(AppInfoPtr->MainTaskName) - 1); - AppInfoPtr->MainTaskName[sizeof(AppInfoPtr->MainTaskName) - 1] = '\0'; - } + strncpy(AppInfoPtr->EntryPoint, ParamsPtr->EntryPoint, + sizeof(AppInfoPtr->EntryPoint) - 1); + AppInfoPtr->EntryPoint[sizeof(AppInfoPtr->EntryPoint) - 1] = '\0'; - /* - ** Get the address information from the OSAL - */ - ReturnCode = OS_ModuleInfo ( AppInfoPtr->ModuleId, &ModuleInfo ); - if ( ReturnCode == OS_SUCCESS ) - { - AppInfoPtr->AddressesAreValid = - (sizeof(ModuleInfo.addr.code_address) <= sizeof(AppInfoPtr->CodeAddress)) && - ModuleInfo.addr.valid; - CFE_SB_SET_MEMADDR(AppInfoPtr->CodeAddress, ModuleInfo.addr.code_address); - CFE_SB_SET_MEMADDR(AppInfoPtr->CodeSize, ModuleInfo.addr.code_size); - CFE_SB_SET_MEMADDR(AppInfoPtr->DataAddress, ModuleInfo.addr.data_address); - CFE_SB_SET_MEMADDR(AppInfoPtr->DataSize, ModuleInfo.addr.data_size); - CFE_SB_SET_MEMADDR(AppInfoPtr->BSSAddress, ModuleInfo.addr.bss_address); - CFE_SB_SET_MEMADDR(AppInfoPtr->BSSSize, ModuleInfo.addr.bss_size); - } - else - { - AppInfoPtr->AddressesAreValid = false; - AppInfoPtr->CodeAddress = 0; - AppInfoPtr->CodeSize = 0; - AppInfoPtr->DataAddress = 0; - AppInfoPtr->DataSize = 0; - AppInfoPtr->BSSAddress = 0; - AppInfoPtr->BSSSize = 0; - } - - } - - CFE_ES_UnlockSharedData(__func__,__LINE__); - - return Status; - -} /* end function */ + strncpy(AppInfoPtr->FileName, ParamsPtr->FileName, + sizeof(AppInfoPtr->FileName) - 1); + AppInfoPtr->FileName[sizeof(AppInfoPtr->FileName) - 1] = '\0'; +} /* **--------------------------------------------------------------------------------------- -** Name: CFE_ES_GetAppInfoInternal +** Name: CFE_ES_CopyModuleStatusInfo ** -** Purpose: Populate the cFE_ES_TaskInfo structure with the data for a task. +** Purpose: Populate the cFE_ES_AppInfo structure with the data for an app. ** ** This internal function does not log any errors/events. The caller is expected ** to check the return code and log any relevant errors based on the context. **--------------------------------------------------------------------------------------- */ -int32 CFE_ES_GetTaskInfoInternal(CFE_ES_TaskRecord_t *TaskRecPtr, CFE_ES_TaskInfo_t *TaskInfoPtr) +void CFE_ES_CopyModuleStatusInfo(const CFE_ES_ModuleLoadStatus_t *StatusPtr, CFE_ES_AppInfo_t *AppInfoPtr) { - CFE_ES_AppRecord_t *AppRecPtr; - int32 ReturnCode; - - CFE_ES_LockSharedData(__func__,__LINE__); - - if ( CFE_ES_TaskRecordIsUsed(TaskRecPtr) ) - { - - /* - ** Get the Application ID and Task Name - */ - TaskInfoPtr->AppId = TaskRecPtr->AppId; - strncpy(TaskInfoPtr->TaskName, - CFE_ES_TaskRecordGetName(TaskRecPtr), - sizeof(TaskInfoPtr->TaskName)-1); - TaskInfoPtr->TaskName[sizeof(TaskInfoPtr->TaskName)-1] = '\0'; - - /* - ** Store away the Task ID ( for the QueryAllTasks Cmd ) - */ - TaskInfoPtr->TaskId = CFE_ES_TaskRecordGetID(TaskRecPtr); - - /* - ** Get the Execution counter for the task - */ - TaskInfoPtr->ExecutionCounter = TaskRecPtr->ExecutionCounter; - - /* - ** Get the Application Details - */ - AppRecPtr = CFE_ES_LocateAppRecordByID(TaskRecPtr->AppId); - if (CFE_ES_AppRecordIsMatch(AppRecPtr, TaskRecPtr->AppId)) - { - strncpy(TaskInfoPtr->AppName, - CFE_ES_AppRecordGetName(AppRecPtr), - sizeof(TaskInfoPtr->AppName)-1); - TaskInfoPtr->AppName[sizeof(TaskInfoPtr->AppName)-1] = '\0'; - ReturnCode = CFE_SUCCESS; - } - else - { - /* task ID was OK but parent app ID is bad */ - ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID; - } - } - else - { - /* task ID is bad */ - ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID; - } - - CFE_ES_UnlockSharedData(__func__,__LINE__); + AppInfoPtr->ModuleId = StatusPtr->ModuleId; + CFE_SB_SET_MEMADDR(AppInfoPtr->StartAddress, StatusPtr->EntryAddress); +} - return(ReturnCode); +/* +**--------------------------------------------------------------------------------------- +** Name: CFE_ES_CopyModuleAddressInfo +** +** Purpose: Populate the cFE_ES_AppInfo structure with the data for an app. +** +** This internal function does not log any errors/events. The caller is expected +** to check the return code and log any relevant errors based on the context. +**--------------------------------------------------------------------------------------- +*/ +void CFE_ES_CopyModuleAddressInfo(osal_id_t ModuleId, CFE_ES_AppInfo_t *AppInfoPtr) +{ + OS_module_prop_t ModuleInfo; + int32 ReturnCode; -} /* End of CFE_ES_GetTaskInfoInternal() */ + ReturnCode = OS_ModuleInfo ( ModuleId, &ModuleInfo ); + if ( ReturnCode == OS_SUCCESS ) + { + AppInfoPtr->AddressesAreValid = + (sizeof(ModuleInfo.addr.code_address) <= sizeof(AppInfoPtr->CodeAddress)) && + ModuleInfo.addr.valid; + } + else + { + AppInfoPtr->AddressesAreValid = false; + memset(&ModuleInfo, 0, sizeof(ModuleInfo)); + } + CFE_SB_SET_MEMADDR(AppInfoPtr->CodeAddress, ModuleInfo.addr.code_address); + CFE_SB_SET_MEMADDR(AppInfoPtr->CodeSize, ModuleInfo.addr.code_size); + CFE_SB_SET_MEMADDR(AppInfoPtr->DataAddress, ModuleInfo.addr.data_address); + CFE_SB_SET_MEMADDR(AppInfoPtr->DataSize, ModuleInfo.addr.data_size); + CFE_SB_SET_MEMADDR(AppInfoPtr->BSSAddress, ModuleInfo.addr.bss_address); + CFE_SB_SET_MEMADDR(AppInfoPtr->BSSSize, 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 2c7540e50..e9aaa7562 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.h +++ b/fsw/cfe-core/src/es/cfe_es_apps.h @@ -279,18 +279,33 @@ int32 CFE_ES_CleanUpApp(CFE_ES_ResourceID_t AppId); */ int32 CFE_ES_CleanupTaskResources(CFE_ES_ResourceID_t TaskId); + /* -** Populate the cFE_ES_AppInfo structure with the data for an app -** This is an internal function for use in ES. -** The newer external API is : CFE_ES_GetAppInfo +**--------------------------------------------------------------------------------------- +** Name: CFE_ES_CopyModuleBasicInfo +** +** Purpose: Populate the cFE_ES_AppInfo structure from the CFE_ES_ModuleLoadParams_t data +**--------------------------------------------------------------------------------------- */ -int32 CFE_ES_GetAppInfoInternal(CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_AppInfo_t *AppInfoPtr ); +void CFE_ES_CopyModuleBasicInfo(const CFE_ES_ModuleLoadParams_t *ParamsPtr, CFE_ES_AppInfo_t *AppInfoPtr); /* - * Populate the CFE_ES_TaskInfo_t structure with the data for a task - * This is an internal function for use in ES. - * (Equivalent pattern to CFE_ES_GetAppInfoInternal() but for tasks) - */ -int32 CFE_ES_GetTaskInfoInternal(CFE_ES_TaskRecord_t *TaskRecPtr, CFE_ES_TaskInfo_t *TaskInfoPtr ); +**--------------------------------------------------------------------------------------- +** Name: CFE_ES_CopyModuleStatusInfo +** +** Purpose: Populate the cFE_ES_AppInfo structure from the CFE_ES_ModuleLoadStatus_t data +**--------------------------------------------------------------------------------------- +*/ +void CFE_ES_CopyModuleStatusInfo(const CFE_ES_ModuleLoadStatus_t *StatusPtr, CFE_ES_AppInfo_t *AppInfoPtr); + +/* +**--------------------------------------------------------------------------------------- +** Name: CFE_ES_CopyModuleAddressInfo +** +** Purpose: Populate the cFE_ES_AppInfo structure with address information from OSAL. +**--------------------------------------------------------------------------------------- +*/ +void CFE_ES_CopyModuleAddressInfo(osal_id_t ModuleId, CFE_ES_AppInfo_t *AppInfoPtr); + #endif /* _cfe_es_apps_ */ diff --git a/fsw/cfe-core/src/es/cfe_es_task.c b/fsw/cfe-core/src/es/cfe_es_task.c index 3540b3f2a..8411d3ac7 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.c +++ b/fsw/cfe-core/src/es/cfe_es_task.c @@ -41,6 +41,7 @@ #include "cfe_version.h" #include "cfe_es_global.h" #include "cfe_es_apps.h" +#include "cfe_es_resource.h" #include "cfe_es_events.h" #include "cfe_es_verify.h" #include "cfe_es_task.h" @@ -1118,16 +1119,21 @@ int32 CFE_ES_QueryOneCmd(const CFE_ES_QueryOne_t *data) { const CFE_ES_AppNameCmd_Payload_t *cmd = &data->Payload; char LocalApp[OS_MAX_API_NAME]; - CFE_ES_ResourceID_t AppID; + CFE_ES_ResourceID_t ResourceID; int32 Result; CFE_SB_MessageStringGet(LocalApp, (char *)cmd->Application, NULL, OS_MAX_API_NAME, sizeof(cmd->Application)); - Result = CFE_ES_GetAppIDByName(&AppID, LocalApp); + Result = CFE_ES_GetAppIDByName(&ResourceID, LocalApp); + if (Result == CFE_ES_ERR_NAME_NOT_FOUND) + { + /* Also check for a matching library name */ + Result = CFE_ES_GetLibIDByName(&ResourceID, LocalApp); + } if (Result == CFE_SUCCESS) { - Result = CFE_ES_GetAppInfo(&(CFE_ES_TaskData.OneAppPacket.Payload.AppInfo), AppID); + Result = CFE_ES_GetModuleInfo(&(CFE_ES_TaskData.OneAppPacket.Payload.AppInfo), ResourceID); } /* @@ -1182,7 +1188,10 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAll_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]; + uint32 NumResources; CFE_ES_AppRecord_t *AppRecPtr; + CFE_ES_LibRecord_t *LibRecPtr; /* ** Copy the commanded filename into local buffer to ensure size limitation and to allow for modification @@ -1190,6 +1199,38 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAll_t *data) CFE_SB_MessageStringGet(QueryAllFilename, (char *)CmdPtr->FileName, CFE_PLATFORM_ES_DEFAULT_APP_LOG_FILE, OS_MAX_PATH_LEN, sizeof(CmdPtr->FileName)); + /* + * Collect list of active resource IDs. + * + * This should be done while locked, but the actual writing + * of the AppInfo data should be done while NOT locked. + */ + CFE_ES_LockSharedData(__func__, __LINE__); + NumResources = 0; + AppRecPtr = CFE_ES_Global.AppTable; + for(i=0; i < CFE_PLATFORM_ES_MAX_APPLICATIONS && + NumResources < CFE_ES_QUERY_ALL_MAX_ENTRIES; ++i) + { + if (CFE_ES_AppRecordIsUsed(AppRecPtr)) + { + ResourceList[NumResources] = CFE_ES_AppRecordGetID(AppRecPtr); + ++NumResources; + } + ++AppRecPtr; + } + LibRecPtr = CFE_ES_Global.LibTable; + for(i=0; i < CFE_PLATFORM_ES_MAX_LIBRARIES && + NumResources < CFE_ES_QUERY_ALL_MAX_ENTRIES; ++i) + { + if (CFE_ES_LibRecordIsUsed(LibRecPtr)) + { + ResourceList[NumResources] = CFE_ES_LibRecordGetID(LibRecPtr); + ++NumResources; + } + ++LibRecPtr; + } + CFE_ES_UnlockSharedData(__func__, __LINE__); + /* ** Check to see if the file already exists */ @@ -1240,21 +1281,13 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAll_t *data) /* ** Loop through the ES AppTable for main applications */ - AppRecPtr = CFE_ES_Global.AppTable; - for(i=0;iPayload; char QueryAllFilename[OS_MAX_PATH_LEN]; + CFE_ES_ResourceID_t TaskList[OS_MAX_TASKS]; + uint32 NumTasks; CFE_ES_TaskRecord_t *TaskRecPtr; + /* ** Copy the commanded filename into local buffer to ensure size limitation and to allow for modification */ CFE_SB_MessageStringGet(QueryAllFilename, (char *)CmdPtr->FileName, CFE_PLATFORM_ES_DEFAULT_TASK_LOG_FILE, OS_MAX_PATH_LEN, sizeof(CmdPtr->FileName)); + /* + * Collect list of active task IDs. + * + * This should be done while locked, but the actual writing + * of the AppInfo data should be done while NOT locked. + */ + CFE_ES_LockSharedData(__func__, __LINE__); + NumTasks = 0; + TaskRecPtr = CFE_ES_Global.TaskTable; + for(i=0; i < OS_MAX_TASKS; ++i) + { + if (CFE_ES_TaskRecordIsUsed(TaskRecPtr)) + { + TaskList[NumTasks] = CFE_ES_TaskRecordGetID(TaskRecPtr); + ++NumTasks; + } + ++TaskRecPtr; + } + CFE_ES_UnlockSharedData(__func__, __LINE__); + /* ** Check to see if the file already exists */ @@ -1371,20 +1427,13 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasks_t *data) /* ** Loop through the ES AppTable for main applications */ - TaskRecPtr = CFE_ES_Global.TaskTable; - for(i=0;i