Skip to content

Commit

Permalink
fix #393, find psp standard module
Browse files Browse the repository at this point in the history
Update to find psp module from standard list as well as global list
  • Loading branch information
Van committed Aug 9, 2023
1 parent 47d2c1e commit 3f82e7e
Showing 1 changed file with 45 additions and 8 deletions.
53 changes: 45 additions & 8 deletions fsw/shared/src/cfe_psp_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@
*
* Reserve the last 256 entries for base modules
*/
#define CFE_PSP_INTERNAL_MODULE_BASE ((CFE_PSP_MODULE_BASE | CFE_PSP_MODULE_INDEX_MASK) & ~0xFF)
#define CFE_PSP_INTERNAL_MODULE_BASE ( (CFE_PSP_MODULE_BASE | CFE_PSP_MODULE_INDEX_MASK) & ~0xFF)

static uint32 CFE_PSP_ConfigPspModuleListLength = 0;
static uint32 CFE_PSP_StandardPspModuleListLength = 0;

/***************************************************
*
Expand Down Expand Up @@ -96,10 +97,9 @@ uint32_t CFE_PSP_ModuleInitList(uint32 BaseId, CFE_StaticModuleLoadEntry_t *List
void CFE_PSP_ModuleInit(void)
{
/* First initialize the fixed set of modules for this PSP */
CFE_PSP_ModuleInitList(CFE_PSP_INTERNAL_MODULE_BASE, CFE_PSP_BASE_MODULE_LIST);
CFE_PSP_StandardPspModuleListLength = CFE_PSP_ModuleInitList(CFE_PSP_INTERNAL_MODULE_BASE, CFE_PSP_BASE_MODULE_LIST);

/* Then initialize any user-selected extension modules */
/* Only these modules can be used with CFE_PSP_Module_GetAPIEntry or CFE_PSP_Module_FindByName */
CFE_PSP_ConfigPspModuleListLength = CFE_PSP_ModuleInitList(CFE_PSP_MODULE_BASE, GLOBAL_CONFIGDATA.PspModuleList);
}

Expand All @@ -113,15 +113,32 @@ int32 CFE_PSP_Module_GetAPIEntry(uint32 PspModuleId, CFE_PSP_ModuleApi_t **API)
uint32 LocalId;

Result = CFE_PSP_INVALID_MODULE_ID;
if ((PspModuleId & ~CFE_PSP_MODULE_INDEX_MASK) == CFE_PSP_MODULE_BASE)

/* Last 256 enteries are for internal modules */
if((PspModuleId & CFE_PSP_MODULE_INDEX_MASK) >= 0xFF00 )
{
LocalId = PspModuleId & CFE_PSP_MODULE_INDEX_MASK;
if (LocalId < CFE_PSP_ConfigPspModuleListLength)
if ((PspModuleId & ~CFE_PSP_MODULE_INDEX_MASK) == CFE_PSP_MODULE_BASE)
{
*API = (CFE_PSP_ModuleApi_t *)GLOBAL_CONFIGDATA.PspModuleList[LocalId].Api;
Result = CFE_PSP_SUCCESS;
LocalId = PspModuleId & 0xFF;
if (LocalId < CFE_PSP_StandardPspModuleListLength)
{
*API = (CFE_PSP_ModuleApi_t *)CFE_PSP_BASE_MODULE_LIST[LocalId].Api;
Result = CFE_PSP_SUCCESS;
}
}
}
else
{
if ((PspModuleId & ~CFE_PSP_MODULE_INDEX_MASK) == CFE_PSP_MODULE_BASE)
{
LocalId = PspModuleId & CFE_PSP_MODULE_INDEX_MASK;
if (LocalId < CFE_PSP_ConfigPspModuleListLength)
{
*API = (CFE_PSP_ModuleApi_t *)GLOBAL_CONFIGDATA.PspModuleList[LocalId].Api;
Result = CFE_PSP_SUCCESS;
}
}
}

return Result;
}
Expand All @@ -139,6 +156,8 @@ int32 CFE_PSP_Module_FindByName(const char *ModuleName, uint32 *PspModuleId)
Entry = GLOBAL_CONFIGDATA.PspModuleList;
Result = CFE_PSP_INVALID_MODULE_NAME;
i = 0;

/* Check global list */
while (i < CFE_PSP_ConfigPspModuleListLength)
{
if (strcmp(Entry->Name, ModuleName) == 0)
Expand All @@ -151,5 +170,23 @@ int32 CFE_PSP_Module_FindByName(const char *ModuleName, uint32 *PspModuleId)
++i;
}

/* Check internal list */
if (Result != CFE_PSP_SUCCESS)
{
Entry = CFE_PSP_BASE_MODULE_LIST;
i = 0;
while (i < CFE_PSP_StandardPspModuleListLength)
{
if (strcmp(Entry->Name, ModuleName) == 0)
{
*PspModuleId = CFE_PSP_INTERNAL_MODULE_BASE | (i & CFE_PSP_MODULE_INDEX_MASK);
Result = CFE_PSP_SUCCESS;
break;
}
++Entry;
++i;
}
}

return Result;
}

0 comments on commit 3f82e7e

Please sign in to comment.