From 8e843457dd6eb153407d03f51f50a45744f295fa Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 8 Oct 2020 10:17:50 -0400 Subject: [PATCH] Fix #111, do not assume a specific core name Improve the module ID lookup when getting the CFE core text segment info. - Ideally get the ID directly from what was loaded by startCfeCore - As a fallback use the actual CFE core name from the configdata Do not use a hardcoded name. --- fsw/mcp750-vxworks/src/cfe_psp_memory.c | 45 +++++++++++++++++++------ 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/fsw/mcp750-vxworks/src/cfe_psp_memory.c b/fsw/mcp750-vxworks/src/cfe_psp_memory.c index ace5842c..6a4478d0 100644 --- a/fsw/mcp750-vxworks/src/cfe_psp_memory.c +++ b/fsw/mcp750-vxworks/src/cfe_psp_memory.c @@ -58,14 +58,6 @@ #include -/* -** Define the cFE Core loadable module name -*/ -#define CFE_MODULE_NAME_DEFAULT "cfe-core.o" - -static char CFE_MODULE_NAME[] = CFE_MODULE_NAME_DEFAULT; - - /* ** External Declarations */ @@ -505,14 +497,47 @@ int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFES STATUS status; MODULE_ID cFEModuleId; MODULE_INFO cFEModuleInfo; + cpuaddr GetModuleIdAddr; + MODULE_ID (*GetModuldIdFunc)(void); + + - if ( SizeOfCFESegment == NULL ) + if ( PtrToCFESegment == NULL || SizeOfCFESegment == NULL ) { return_code = CFE_PSP_ERROR; } else { - cFEModuleId = moduleFindByName(CFE_MODULE_NAME); + /* + * First attempt to call a function called GetCfeCoreModuleID(). + * + * If CFE core was started via the "startCfeCore" routine, this + * provides the actual module ID that was loaded by that routine, + * no matter what it is actually named. This is provided by the + * support/integration code compiled directly into the VxWorks kernel + * image. + * + * The prototype should be: + * MODULE_ID GetCfeCoreModuleID(void); + */ + cFEModuleId = NULL; + GetModuleIdAddr = 0; + return_code = OS_SymbolLookup(&GetModuleIdAddr, "GetCfeCoreModuleID"); + if ( return_code == OS_SUCCESS && GetModuleIdAddr != 0 ) + { + GetModuldIdFunc = (MODULE_ID (*)(void))GetModuleIdAddr; + cFEModuleId = GetModuldIdFunc(); + } + + /* + * If the above did not yield a valid module ID, + * then attempt to find the module ID by name. + * This assumes the core executable name as built by CMake + */ + if ( cFEModuleId == NULL ) + { + cFEModuleId = moduleFindByName((char *)GLOBAL_CONFIGDATA.Default_CoreFilename); + } if ( cFEModuleId == NULL ) {