Skip to content

Commit

Permalink
Merge pull request #896 from jphickey/fix-894-resourceid-typedef
Browse files Browse the repository at this point in the history
Fix #894, add resource ID type
  • Loading branch information
yammajamma authored Sep 29, 2020
2 parents 003514f + 96d82c5 commit 82f1425
Show file tree
Hide file tree
Showing 46 changed files with 627 additions and 504 deletions.
158 changes: 79 additions & 79 deletions fsw/cfe-core/src/es/cfe_es_api.c

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions fsw/cfe-core/src/es/cfe_es_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens)
unsigned int Priority;
unsigned int StackSize;
unsigned int ExceptionAction;
uint32 ApplicationId;
CFE_ES_ResourceID_t ApplicationId;
int32 CreateStatus = CFE_ES_ERR_APP_CREATE;

/*
Expand Down Expand Up @@ -353,7 +353,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens)
**
**---------------------------------------------------------------------------------------
*/
int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr,
int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr,
const char *FileName,
const void *EntryPointData,
const char *AppName,
Expand Down Expand Up @@ -391,7 +391,7 @@ int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr,
AppSlotFound = true;
memset ( AppRecPtr, 0, sizeof(CFE_ES_AppRecord_t));
/* set state EARLY_INIT for OS_TaskCreate below (indicates record is in use) */
CFE_ES_AppRecordSetUsed(AppRecPtr, i);
CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_ES_ResourceID_FromInteger(i + CFE_ES_APPID_BASE));
break;
}
++AppRecPtr;
Expand Down Expand Up @@ -556,7 +556,7 @@ int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr,
**
**---------------------------------------------------------------------------------------
*/
int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr,
int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr,
const char *FileName,
const void *EntryPointData,
const char *LibName)
Expand All @@ -566,7 +566,7 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr,
size_t StringLength;
int32 Status;
uint32 LibIndex;
uint32 PendingLibId;
CFE_ES_ResourceID_t PendingLibId;
osal_id_t ModuleId;
bool IsModuleLoaded;

Expand All @@ -586,7 +586,7 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr,
IsModuleLoaded = false;
FunctionPointer = NULL;
ModuleId = OS_OBJECT_ID_UNDEFINED;
PendingLibId = 0xFFFFFFFF;
PendingLibId = CFE_ES_RESOURCEID_UNDEFINED;
Status = CFE_ES_ERR_LOAD_LIB; /* error that will be returned if no slots found */
CFE_ES_LockSharedData(__func__,__LINE__);
LibSlotPtr = CFE_ES_Global.LibTable;
Expand All @@ -608,10 +608,10 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr,
break;
}
}
else if (PendingLibId == 0xFFFFFFFF)
else if (!CFE_ES_ResourceID_IsDefined(PendingLibId))
{
/* Remember list position as possible place for new entry. */
PendingLibId = LibIndex;
PendingLibId = CFE_ES_ResourceID_FromInteger(LibIndex + CFE_ES_LIBID_BASE);
Status = CFE_SUCCESS;
}
else
Expand All @@ -629,7 +629,7 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr,

/* reserve the slot while still under lock */
strcpy(LibSlotPtr->LibName, LibName);
CFE_ES_LibRecordSetUsed(LibSlotPtr, PendingLibId);
CFE_ES_LibRecordSetUsed(LibSlotPtr, CFE_ES_RESOURCEID_RESERVED);
*LibraryIdPtr = PendingLibId;
}

Expand Down Expand Up @@ -753,6 +753,7 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr,
{
/* Increment the counter, which needs to be done under lock */
CFE_ES_LockSharedData(__func__,__LINE__);
CFE_ES_LibRecordSetUsed(LibSlotPtr, PendingLibId);
CFE_ES_Global.RegisteredLibs++;
CFE_ES_UnlockSharedData(__func__,__LINE__);
}
Expand Down Expand Up @@ -900,7 +901,7 @@ void CFE_ES_ProcessControlRequest(CFE_ES_AppRecord_t *AppRecPtr)

int32 Status;
CFE_ES_AppStartParams_t AppStartParams;
uint32 NewAppId;
CFE_ES_ResourceID_t NewAppId;

/*
** First get a copy of the Apps Start Parameters
Expand Down Expand Up @@ -1083,11 +1084,11 @@ int32 CFE_ES_CleanUpApp(CFE_ES_AppRecord_t *AppRecPtr)
{
uint32 i;
int32 Status;
uint32 MainTaskId;
uint32 CurrTaskId;
CFE_ES_ResourceID_t MainTaskId;
CFE_ES_ResourceID_t CurrTaskId;
int32 ReturnCode = CFE_SUCCESS;
CFE_ES_TaskRecord_t *TaskRecPtr;
uint32 AppId;
CFE_ES_ResourceID_t AppId;

/*
* Retrieve the abstract AppID for calling cleanup
Expand Down Expand Up @@ -1140,10 +1141,10 @@ int32 CFE_ES_CleanUpApp(CFE_ES_AppRecord_t *AppRecPtr)
{
/* delete only CHILD tasks - not the MainTaskId, which will be deleted later (below) */
if ( CFE_ES_TaskRecordIsUsed(TaskRecPtr) &&
(TaskRecPtr->AppId == AppId))
CFE_ES_ResourceID_Equal(TaskRecPtr->AppId, AppId))
{
CurrTaskId = CFE_ES_TaskRecordGetID(TaskRecPtr);
if (CurrTaskId != MainTaskId)
if (!CFE_ES_ResourceID_Equal(CurrTaskId, MainTaskId))
{
Status = CFE_ES_CleanupTaskResources(CurrTaskId);
if ( Status != CFE_SUCCESS )
Expand Down Expand Up @@ -1318,7 +1319,7 @@ void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg)
** Purpose: Clean up the OS resources associated with an individual Task
**---------------------------------------------------------------------------------------
*/
int32 CFE_ES_CleanupTaskResources(uint32 TaskId)
int32 CFE_ES_CleanupTaskResources(CFE_ES_ResourceID_t TaskId)
{
CFE_ES_CleanupState_t CleanState;
int32 Result;
Expand Down Expand Up @@ -1406,7 +1407,7 @@ int32 CFE_ES_GetAppInfoInternal(CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_AppInfo_t
OS_module_prop_t ModuleInfo;
uint32 i;
CFE_ES_TaskRecord_t *TaskRecPtr;
uint32 AppId;
CFE_ES_ResourceID_t AppId;

CFE_ES_LockSharedData(__func__,__LINE__);

Expand Down Expand Up @@ -1454,8 +1455,8 @@ int32 CFE_ES_GetAppInfoInternal(CFE_ES_AppRecord_t *AppRecPtr, CFE_ES_AppInfo_t
for (i=0; i<OS_MAX_TASKS; i++ )
{
if ( CFE_ES_TaskRecordIsUsed(TaskRecPtr) &&
TaskRecPtr->AppId == AppId &&
CFE_ES_TaskRecordGetID(TaskRecPtr) != AppInfoPtr->MainTaskId )
CFE_ES_ResourceID_Equal(TaskRecPtr->AppId, AppId) &&
!CFE_ES_ResourceID_Equal(CFE_ES_TaskRecordGetID(TaskRecPtr), AppInfoPtr->MainTaskId) )
{
AppInfoPtr->NumOfChildTasks++;
}
Expand Down
18 changes: 9 additions & 9 deletions fsw/cfe-core/src/es/cfe_es_apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ typedef struct
*/
typedef struct
{
uint32 MainTaskId; /* The Application's Main Task ID */
char MainTaskName[OS_MAX_API_NAME]; /* The Application's Main Task ID */
CFE_ES_ResourceID_t MainTaskId; /* The Application's Main Task ID */
char MainTaskName[OS_MAX_API_NAME]; /* The Application's Main Task ID */
} CFE_ES_MainTaskInfo_t;


Expand All @@ -101,6 +101,7 @@ typedef struct
*/
typedef struct
{
CFE_ES_ResourceID_t AppId; /* The actual AppID of this entry, or undefined */
CFE_ES_AppState_Enum_t AppState; /* Is the app running, or stopped, or waiting? */
uint32 Type; /* The type of App: CORE or EXTERNAL */
CFE_ES_AppStartParams_t StartParams; /* The start parameters for an App */
Expand All @@ -116,9 +117,8 @@ typedef struct
*/
typedef struct
{
bool RecordUsed; /* Is the record used(1) or available(0) */
uint32 AppId; /* The parent Application's App ID */
uint32 TaskId; /* Task ID */
CFE_ES_ResourceID_t TaskId; /* The actual TaskID of this entry, or undefined */
CFE_ES_ResourceID_t AppId; /* The parent Application's App ID */
uint32 ExecutionCounter; /* The execution counter for the Child task */
char TaskName[OS_MAX_API_NAME]; /* Task Name */

Expand All @@ -131,7 +131,7 @@ typedef struct
*/
typedef struct
{
bool RecordUsed; /* Is the record used(1) or available(0) */
CFE_ES_ResourceID_t LibId; /* The actual LibID of this entry, or undefined */
char LibName[OS_MAX_API_NAME]; /* Library Name */
} CFE_ES_LibRecord_t;

Expand Down Expand Up @@ -167,7 +167,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens);
** Internal function to create/start a new cFE app
** based on the parameters passed in
*/
int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr,
int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr,
const char *FileName,
const void *EntryPointData,
const char *AppName,
Expand All @@ -177,7 +177,7 @@ int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr,
/*
** Internal function to load a a new cFE shared Library
*/
int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr,
int32 CFE_ES_LoadLibrary(CFE_ES_ResourceID_t *LibraryIdPtr,
const char *FileName,
const void *EntryPointData,
const char *LibName);
Expand Down Expand Up @@ -221,7 +221,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_AppRecord_t *AppRecPtr);
/*
** Clean up all Task resources and detete the task
*/
int32 CFE_ES_CleanupTaskResources(uint32 TaskId);
int32 CFE_ES_CleanupTaskResources(CFE_ES_ResourceID_t TaskId);

/*
** Populate the cFE_ES_AppInfo structure with the data for an app
Expand Down
2 changes: 1 addition & 1 deletion fsw/cfe-core/src/es/cfe_es_backgroundtask.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void CFE_ES_BackgroundCleanup(void)
CFE_ES_DeleteChildTask(CFE_ES_Global.BackgroundTask.TaskID);
OS_BinSemDelete(CFE_ES_Global.BackgroundTask.WorkSem);

CFE_ES_Global.BackgroundTask.TaskID = 0;
CFE_ES_Global.BackgroundTask.TaskID = CFE_ES_RESOURCEID_UNDEFINED;
CFE_ES_Global.BackgroundTask.WorkSem = OS_OBJECT_ID_UNDEFINED;
}

Expand Down
4 changes: 2 additions & 2 deletions fsw/cfe-core/src/es/cfe_es_cds.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ int32 CFE_ES_UpdateCDSRegistry(void)
** NOTE: For complete prolog information, see 'cfe_es_cds.h'
********************************************************************/

void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, uint32 ThisAppId)
void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_ResourceID_t ThisAppId)
{
char AppName[OS_MAX_API_NAME];

Expand Down Expand Up @@ -728,7 +728,7 @@ int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices)
int32 RegIndx;
CFE_ES_CDS_RegRec_t *RegRecPtr = NULL;
char OwnerName[OS_MAX_API_NAME];
uint32 AppId;
CFE_ES_ResourceID_t AppId;
uint32 i;
char LogMessage[CFE_ES_MAX_SYSLOG_MSG_SIZE];

Expand Down
2 changes: 1 addition & 1 deletion fsw/cfe-core/src/es/cfe_es_cds.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int32 CFE_ES_UpdateCDSRegistry(void);
**
**
******************************************************************************/
void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, uint32 ThisAppId);
void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_ResourceID_t ThisAppId);

/*****************************************************************************/
/**
Expand Down
4 changes: 2 additions & 2 deletions fsw/cfe-core/src/es/cfe_es_erlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int32 CFE_ES_WriteToERLogWithContext( CFE_ES_LogEntryType_Enum_t EntryType, uint32 ResetType, uint32 ResetSubtype,
const char *Description, uint32 AppId, uint32 PspContextId)
const char *Description, CFE_ES_ResourceID_t AppId, uint32 PspContextId)
{
uint32 LogIdx;
CFE_ES_ERLog_MetaData_t *EntryPtr;
Expand Down Expand Up @@ -174,7 +174,7 @@ int32 CFE_ES_WriteToERLog( CFE_ES_LogEntryType_Enum_t EntryType, uint32 Reset
{
/* passing 0xFFFFFFFF as the appid avoids confusion with actual appid 0 */
return CFE_ES_WriteToERLogWithContext(EntryType, ResetType, ResetSubtype,
Description, 0xFFFFFFFF, CFE_ES_ERLOG_NO_CONTEXT);
Description, CFE_ES_RESOURCEID_UNDEFINED, CFE_ES_ERLOG_NO_CONTEXT);

} /* End of CFE_ES_WriteToERLog() */

Expand Down
Loading

0 comments on commit 82f1425

Please sign in to comment.