diff --git a/fsw/cfe-core/src/es/cfe_es_api.c b/fsw/cfe-core/src/es/cfe_es_api.c index 345d78f45..5799e71f5 100644 --- a/fsw/cfe-core/src/es/cfe_es_api.c +++ b/fsw/cfe-core/src/es/cfe_es_api.c @@ -926,7 +926,7 @@ int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, uint32 TaskId; uint32 ChildTaskId; uint32 ParentTaskId; - uint32 OsalId; + osal_id_t OsalId; /* ** Validate some of the arguments @@ -974,7 +974,8 @@ int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, ** First, Make sure the Calling Task is a cFE Main task. ** TaskID must be the same as the Parent Task ID. */ - TaskId = OS_TaskGetId(); + OsalId = OS_TaskGetId(); + TaskId = CFE_ES_ResourceID_FromOSAL(OsalId); ParentTaskId = AppRecPtr->TaskInfo.MainTaskId; if ( TaskId == ParentTaskId ) { @@ -997,7 +998,7 @@ int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, */ if ( Result == OS_SUCCESS ) { - ChildTaskId = OsalId; + ChildTaskId = CFE_ES_ResourceID_FromOSAL(OsalId); TaskRecPtr = CFE_ES_LocateTaskRecordByID(ChildTaskId); CFE_ES_TaskRecordSetUsed(TaskRecPtr, ChildTaskId); @@ -1091,7 +1092,7 @@ void CFE_ES_IncrementTaskCounter(void) * Because the global data is not locked, only minimal validation * is performed. */ - TaskID = OS_TaskGetId(); + TaskID = CFE_ES_ResourceID_FromOSAL(OS_TaskGetId()); TaskRecPtr = CFE_ES_LocateTaskRecordByID(TaskID); if (TaskRecPtr != NULL) { @@ -1113,6 +1114,7 @@ int32 CFE_ES_DeleteChildTask(uint32 TaskId) bool TaskIsMain = false; int32 ReturnCode = CFE_SUCCESS; int32 OSReturnCode; + osal_id_t OsalId; /* ** Make sure the task ID is within range @@ -1154,7 +1156,8 @@ int32 CFE_ES_DeleteChildTask(uint32 TaskId) /* ** Can delete the Task */ - OSReturnCode = OS_TaskDelete(TaskId); + OsalId = CFE_ES_ResourceID_ToOSAL(TaskId); + OSReturnCode = OS_TaskDelete(OsalId); if ( OSReturnCode == OS_SUCCESS ) { /* @@ -1673,7 +1676,10 @@ int32 CFE_ES_AppID_ToIndex(uint32 AppId, uint32 *Idx) */ int32 CFE_ES_TaskID_ToIndex(uint32 TaskID, uint32 *Idx) { - if (OS_ConvertToArrayIndex(TaskID, Idx) != OS_SUCCESS) + osal_id_t OsalID; + + OsalID = CFE_ES_ResourceID_ToOSAL(TaskID); + if (OS_ConvertToArrayIndex(OsalID, Idx) != OS_SUCCESS) { return CFE_ES_ERR_TASKID; } @@ -1685,6 +1691,33 @@ int32 CFE_ES_TaskID_ToIndex(uint32 TaskID, uint32 *Idx) ** Private API functions */ +/** + * Convert a CFE_ES_ResourceID_t type to an OSAL ID type. + * + * This should only be used on ES resource IDs that are known to refer to + * an OSAL resource (e.g. a task ID). + * + * Note this may result in an invalid OSAL ID if the CFE_ES_ResourceID_t did + * not actually refer to an OSAL resource. + */ +osal_id_t CFE_ES_ResourceID_ToOSAL(uint32 id) +{ + unsigned long val = (uint32)id; /* type conversion */ + return OS_ObjectIdFromInteger(val); +} + +/** + * Convert an OSAL ID type to a CFE_ES_ResourceID_t type. + * + * Any OSAL ID can also be represented as a CFE_ES_ResourceID_t + */ +uint32 CFE_ES_ResourceID_FromOSAL(osal_id_t id) +{ + unsigned long val = OS_ObjectIdToInteger(id); + return (uint32)val; /* type conversion */ +} + + /* * Note - this gets the table entry pointer but does not dereference or * otherwise check/validate said pointer, as that would have to be done while @@ -1741,7 +1774,7 @@ CFE_ES_TaskRecord_t *CFE_ES_GetTaskRecordByContext(void) /* ** Use the OS task ID to get the ES task record */ - TaskID = OS_TaskGetId(); + TaskID = CFE_ES_ResourceID_FromOSAL(OS_TaskGetId()); TaskRecPtr = CFE_ES_LocateTaskRecordByID(TaskID); /* diff --git a/fsw/cfe-core/src/es/cfe_es_apps.c b/fsw/cfe-core/src/es/cfe_es_apps.c index 444150ea8..1c3e4f30e 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.c +++ b/fsw/cfe-core/src/es/cfe_es_apps.c @@ -79,9 +79,9 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath ) const char *TokenList[CFE_ES_STARTSCRIPT_MAX_TOKENS_PER_LINE]; uint32 NumTokens; uint32 BuffLen = 0; /* Length of the current buffer */ - int32 AppFile = 0; + osal_id_t AppFile; + int32 Status; char c; - int32 ReadStatus; bool LineTooLong = false; bool FileOpened = false; @@ -94,13 +94,14 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath ) /* ** Open the file in the volatile disk. */ - AppFile = OS_open( CFE_PLATFORM_ES_VOLATILE_STARTUP_FILE, OS_READ_ONLY, 0); + Status = OS_open( CFE_PLATFORM_ES_VOLATILE_STARTUP_FILE, OS_READ_ONLY, 0); - if ( AppFile >= 0 ) + if ( Status >= 0 ) { CFE_ES_WriteToSysLog ("ES Startup: Opened ES App Startup file: %s\n", CFE_PLATFORM_ES_VOLATILE_STARTUP_FILE); FileOpened = true; + AppFile = OS_ObjectIdFromInteger(Status); } else { @@ -119,17 +120,18 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath ) /* ** Try to Open the file passed in to the cFE start. */ - AppFile = OS_open( (const char *)StartFilePath, OS_READ_ONLY, 0); + Status = OS_open( (const char *)StartFilePath, OS_READ_ONLY, 0); - if ( AppFile >= 0 ) + if ( Status >= 0 ) { CFE_ES_WriteToSysLog ("ES Startup: Opened ES App Startup file: %s\n",StartFilePath); FileOpened = true; + AppFile = OS_ObjectIdFromInteger(Status); } else { CFE_ES_WriteToSysLog ("ES Startup: Error, Can't Open ES App Startup file: %s EC = 0x%08X\n", - StartFilePath, (unsigned int)AppFile ); + StartFilePath, (unsigned int)Status ); FileOpened = false; } @@ -151,13 +153,13 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath ) */ while(1) { - ReadStatus = OS_read(AppFile, &c, 1); - if ( ReadStatus == OS_ERROR ) + Status = OS_read(AppFile, &c, 1); + if ( Status < 0 ) { - CFE_ES_WriteToSysLog ("ES Startup: Error Reading Startup file. EC = 0x%08X\n",(unsigned int)ReadStatus); + CFE_ES_WriteToSysLog ("ES Startup: Error Reading Startup file. EC = 0x%08X\n",(unsigned int)Status); break; } - else if ( ReadStatus == 0 ) + else if ( Status == 0 ) { /* ** EOF Reached @@ -365,8 +367,8 @@ int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr, int32 ReturnCode; uint32 i; bool AppSlotFound; - uint32 ModuleId; - uint32 MainTaskId; + osal_id_t ModuleId; + osal_id_t MainTaskId; CFE_ES_AppRecord_t *AppRecPtr; CFE_ES_TaskRecord_t *TaskRecPtr; @@ -514,7 +516,7 @@ int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr, /* ** Record the ES_TaskTable entry */ - AppRecPtr->TaskInfo.MainTaskId = MainTaskId; + AppRecPtr->TaskInfo.MainTaskId = CFE_ES_ResourceID_FromOSAL(MainTaskId); TaskRecPtr = CFE_ES_LocateTaskRecordByID(AppRecPtr->TaskInfo.MainTaskId); if ( CFE_ES_TaskRecordIsUsed(TaskRecPtr) ) @@ -566,7 +568,7 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr, size_t StringLength; int32 Status; uint32 CheckSlot; - uint32 ModuleId; + osal_id_t ModuleId; bool IsModuleLoaded; /* @@ -585,7 +587,7 @@ int32 CFE_ES_LoadLibrary(uint32 *LibraryIdPtr, IsModuleLoaded = false; LibSlotPtr = NULL; FunctionPointer = NULL; - ModuleId = 0; + ModuleId = OS_OBJECT_ID_UNDEFINED; Status = CFE_ES_ERR_LOAD_LIB; /* error that will be returned if no slots found */ CFE_ES_LockSharedData(__func__,__LINE__); for ( CheckSlot = 0; CheckSlot < CFE_PLATFORM_ES_MAX_LIBRARIES; CheckSlot++ ) @@ -1175,7 +1177,7 @@ int32 CFE_ES_CleanUpApp(CFE_ES_AppRecord_t *AppRecPtr) if ( Status == OS_ERROR ) { CFE_ES_SysLogWrite_Unsync("CFE_ES_CleanUpApp: Module (ID:0x%08lX) Unload failed. RC=0x%08X\n", - (unsigned long)AppRecPtr->StartParams.ModuleId, (unsigned int)Status); + OS_ObjectIdToInteger(AppRecPtr->StartParams.ModuleId), (unsigned int)Status); ReturnCode = CFE_ES_APP_CLEANUP_ERR; } CFE_ES_Global.RegisteredExternalApps--; @@ -1213,7 +1215,7 @@ typedef struct ** NOTE: This is called while holding the ES global lock **--------------------------------------------------------------------------------------- */ -void CFE_ES_CleanupObjectCallback(uint32 ObjectId, void *arg) +void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg) { CFE_ES_CleanupState_t *CleanState; int32 Status; @@ -1265,8 +1267,8 @@ void CFE_ES_CleanupObjectCallback(uint32 ObjectId, void *arg) } else { - CFE_ES_SysLogWrite_Unsync("Call to OSAL Delete Object (ID:%d) failed. RC=0x%08X\n", - (int)ObjectId, (unsigned int)Status); + CFE_ES_SysLogWrite_Unsync("Call to OSAL Delete Object (ID:%lu) failed. RC=0x%08X\n", + OS_ObjectIdToInteger(ObjectId), (unsigned int)Status); if (CleanState->OverallStatus == CFE_SUCCESS) { /* @@ -1316,10 +1318,10 @@ int32 CFE_ES_CleanupTaskResources(uint32 TaskId) CFE_ES_CleanupState_t CleanState; int32 Result; CFE_ES_TaskRecord_t *TaskRecPtr; - uint32 OsalId; + osal_id_t OsalId; /* Get the Task ID for calling OSAL APIs (convert type) */ - OsalId = TaskId; + OsalId = CFE_ES_ResourceID_ToOSAL(TaskId); /* ** Delete all OSAL resources that belong to this task diff --git a/fsw/cfe-core/src/es/cfe_es_apps.h b/fsw/cfe-core/src/es/cfe_es_apps.h index 8ea6a8559..0e6e68bd9 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.h +++ b/fsw/cfe-core/src/es/cfe_es_apps.h @@ -76,7 +76,7 @@ typedef struct uint32 StackSize; cpuaddr StartAddress; - uint32 ModuleId; + osal_id_t ModuleId; uint16 ExceptionAction; uint16 Priority; diff --git a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c b/fsw/cfe-core/src/es/cfe_es_backgroundtask.c index 5b874679e..518abb450 100644 --- a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c +++ b/fsw/cfe-core/src/es/cfe_es_backgroundtask.c @@ -246,7 +246,7 @@ void CFE_ES_BackgroundCleanup(void) OS_BinSemDelete(CFE_ES_Global.BackgroundTask.WorkSem); CFE_ES_Global.BackgroundTask.TaskID = 0; - CFE_ES_Global.BackgroundTask.WorkSem = 0; + CFE_ES_Global.BackgroundTask.WorkSem = OS_OBJECT_ID_UNDEFINED; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/fsw/cfe-core/src/es/cfe_es_cds.h b/fsw/cfe-core/src/es/cfe_es_cds.h index fb6e8963c..7055a3b56 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds.h +++ b/fsw/cfe-core/src/es/cfe_es_cds.h @@ -75,7 +75,7 @@ typedef struct typedef struct { - uint32 RegistryMutex; /**< \brief Mutex that controls access to CDS Registry */ + osal_id_t RegistryMutex; /**< \brief Mutex that controls access to CDS Registry */ uint32 CDSSize; /**< \brief Total size of the CDS as reported by BSP */ uint32 MemPoolSize; uint32 MaxNumRegEntries; /**< \brief Maximum number of Registry entries */ diff --git a/fsw/cfe-core/src/es/cfe_es_cds_mempool.h b/fsw/cfe-core/src/es/cfe_es_cds_mempool.h index a26925e49..cb8f827a8 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds_mempool.h +++ b/fsw/cfe-core/src/es/cfe_es_cds_mempool.h @@ -81,7 +81,7 @@ typedef struct { int32 SizeIndex; uint16 CheckErrCntr; uint16 RequestCntr; - uint32 MutexId; + osal_id_t MutexId; uint32 MinBlockSize; CFE_ES_CDSBlockSizeDesc_t SizeDesc[CFE_ES_CDS_NUM_BLOCK_SIZES]; } CFE_ES_CDSPool_t; diff --git a/fsw/cfe-core/src/es/cfe_es_erlog.c b/fsw/cfe-core/src/es/cfe_es_erlog.c index 03fcc7bba..98bf1c975 100644 --- a/fsw/cfe-core/src/es/cfe_es_erlog.c +++ b/fsw/cfe-core/src/es/cfe_es_erlog.c @@ -191,14 +191,14 @@ int32 CFE_ES_WriteToERLog( CFE_ES_LogEntryType_Enum_t EntryType, uint32 Reset bool CFE_ES_RunERLogDump(uint32 ElapsedTime, void *Arg) { CFE_ES_BackgroundLogDumpGlobal_t *State = (CFE_ES_BackgroundLogDumpGlobal_t *)Arg; - int32 WriteStat; + int32 Status; int32 PspStatus; CFE_FS_Header_t FileHdr; CFE_ES_ERLog_FileEntry_t FileEntry; CFE_ES_ERLog_MetaData_t *EntryPtr; uint32 FileSize; uint32 i; - int32 fd; + osal_id_t fd; if (!State->IsPending) @@ -207,26 +207,27 @@ bool CFE_ES_RunERLogDump(uint32 ElapsedTime, void *Arg) } FileSize = 0; - fd = OS_creat(State->DataFileName, OS_WRITE_ONLY); - if(fd < 0) + Status = OS_creat(State->DataFileName, OS_WRITE_ONLY); + if(Status < 0) { CFE_EVS_SendEvent(CFE_ES_ERLOG2_ERR_EID,CFE_EVS_EventType_ERROR, - "Error creating file %s, RC = 0x%08X", - State->DataFileName, (unsigned int)fd); + "Error creating file %s, RC = %d", + State->DataFileName, (int)Status); } else { + fd = OS_ObjectIdFromInteger(Status); CFE_FS_InitHeader(&FileHdr, CFE_ES_ER_LOG_DESC, CFE_FS_SubType_ES_ERLOG); /* write the cFE header to the file */ - WriteStat = CFE_FS_WriteHeader(fd, &FileHdr); - if(WriteStat != sizeof(CFE_FS_Header_t)) + Status = CFE_FS_WriteHeader(fd, &FileHdr); + if(Status != sizeof(CFE_FS_Header_t)) { - CFE_ES_FileWriteByteCntErr(State->DataFileName,sizeof(CFE_FS_Header_t),WriteStat); + CFE_ES_FileWriteByteCntErr(State->DataFileName,sizeof(CFE_FS_Header_t),Status); } else { - FileSize += WriteStat; + FileSize += Status; /* write a single ER log entry on each pass */ for(i=0;iDataFileName,sizeof(FileEntry),WriteStat); + CFE_ES_FileWriteByteCntErr(State->DataFileName,sizeof(FileEntry),Status); break; }/* end if */ - FileSize += WriteStat; + FileSize += Status; } /* end for */ @@ -315,7 +316,7 @@ bool CFE_ES_RunExceptionScan(uint32 ElapsedTime, void *Arg) uint32 PspContextId; char ReasonString[CFE_ES_ERLOG_DESCRIPTION_MAX_LENGTH]; CFE_ES_TaskInfo_t EsTaskInfo; - uint32 ExceptionTaskID; + osal_id_t ExceptionTaskID; uint32 ResetType; CFE_ES_LogEntryType_Enum_t LogType; CFE_ES_AppRecord_t *AppRecPtr; @@ -338,7 +339,7 @@ bool CFE_ES_RunExceptionScan(uint32 ElapsedTime, void *Arg) /* reason string is not available - populate with something for the log */ snprintf(ReasonString, sizeof(ReasonString), "Unknown - CFE_PSP_ExceptionGetSummary() error %ld", (long)Status); PspContextId = 0; - ExceptionTaskID = 0; + ExceptionTaskID = OS_OBJECT_ID_UNDEFINED; } /* end if */ /* @@ -346,7 +347,7 @@ bool CFE_ES_RunExceptionScan(uint32 ElapsedTime, void *Arg) * so by writing to SysLog here it becomes visible in both places. */ CFE_ES_WriteToSysLog("ExceptionID 0x%lx in TaskID %lu: %s\n", - (unsigned long)PspContextId, (unsigned long)ExceptionTaskID, ReasonString); + (unsigned long)PspContextId, OS_ObjectIdToInteger(ExceptionTaskID), ReasonString); /* * If task ID is 0, this means it was a system level exception and @@ -355,9 +356,9 @@ bool CFE_ES_RunExceptionScan(uint32 ElapsedTime, void *Arg) * Otherwise, if it was related to a task, determine the associated AppID * so the exception action can be checked. */ - if (ExceptionTaskID != 0) + if (OS_ObjectIdDefined(ExceptionTaskID)) { - Status = CFE_ES_GetTaskInfo( &EsTaskInfo, ExceptionTaskID ); + Status = CFE_ES_GetTaskInfo( &EsTaskInfo, CFE_ES_ResourceID_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 3c14a7807..867919107 100644 --- a/fsw/cfe-core/src/es/cfe_es_global.h +++ b/fsw/cfe-core/src/es/cfe_es_global.h @@ -75,7 +75,7 @@ typedef struct typedef struct { uint32 TaskID; /**< OSAL ID of the background task */ - uint32 WorkSem; /**< Semaphore that is given whenever background work is pending */ + 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; @@ -95,12 +95,12 @@ typedef struct /* ** Shared Data Semaphore */ - uint32 SharedDataMutex; + osal_id_t SharedDataMutex; /* ** Performance Data Mutex */ - uint32 PerfDataMutex; + osal_id_t PerfDataMutex; /* ** Startup Sync @@ -372,6 +372,47 @@ extern CFE_ES_AppRecord_t* CFE_ES_GetAppRecordByContext(void); */ extern CFE_ES_TaskRecord_t* CFE_ES_GetTaskRecordByContext(void); +/** + * @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(uint32 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 + */ +uint32 CFE_ES_ResourceID_FromOSAL(osal_id_t id); + + /* ** Functions used to lock/unlock shared data */ diff --git a/fsw/cfe-core/src/es/cfe_es_perf.c b/fsw/cfe-core/src/es/cfe_es_perf.c index 308514d20..0fe3fe2c6 100644 --- a/fsw/cfe-core/src/es/cfe_es_perf.c +++ b/fsw/cfe-core/src/es/cfe_es_perf.c @@ -271,7 +271,7 @@ int32 CFE_ES_StopPerfDataCmd(const CFE_ES_StopPerfData_t *data) bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) { CFE_ES_PerfDumpGlobal_t *State = (CFE_ES_PerfDumpGlobal_t *)Arg; - int32 WriteStat; + int32 Status; CFE_FS_Header_t FileHdr; uint32 BlockSize; @@ -311,7 +311,19 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) { case CFE_ES_PerfDumpState_OPEN_FILE: /* Create the file to dump to */ - State->FileDesc = OS_creat(State->DataFileName, OS_WRITE_ONLY); + Status = OS_creat(State->DataFileName, OS_WRITE_ONLY); + if (Status >= 0) + { + State->FileDesc = OS_ObjectIdFromInteger(Status); + } + else + { + State->FileDesc = OS_OBJECT_ID_UNDEFINED; + CFE_EVS_SendEvent(CFE_ES_PERF_LOG_ERR_EID,CFE_EVS_EventType_ERROR, + "Error creating file %s, RC = %d", + State->DataFileName, (int)Status); + + } State->FileSize = 0; break; @@ -352,10 +364,10 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) case CFE_ES_PerfDumpState_CLOSE_FILE: /* close the fd */ - if (State->FileDesc != 0) + if (OS_ObjectIdDefined(State->FileDesc)) { OS_close(State->FileDesc); - State->FileDesc = 0; + State->FileDesc = OS_OBJECT_ID_UNDEFINED; } break; @@ -390,12 +402,8 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) switch(State->CurrentState) { case CFE_ES_PerfDumpState_OPEN_FILE: - if(State->FileDesc < 0) + if (!OS_ObjectIdDefined(State->FileDesc)) { - CFE_EVS_SendEvent(CFE_ES_PERF_LOG_ERR_EID,CFE_EVS_EventType_ERROR, - "Error creating file %s, RC = 0x%08X", - State->DataFileName, (unsigned int)State->FileDesc); - State->PendingState = CFE_ES_PerfDumpState_IDLE; } /* end if */ break; @@ -417,7 +425,7 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) /* * State is in progress, perform work item(s) as required */ - WriteStat = 0; + Status = 0; BlockSize = 0; switch(State->CurrentState) { @@ -427,7 +435,7 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) /* predicted total length of final output */ FileHdr.Length = sizeof(CFE_ES_PerfMetaData_t) + (Perf->MetaData.DataCount * sizeof(CFE_ES_PerfDataEntry_t)); /* write the cFE header to the file */ - WriteStat = CFE_FS_WriteHeader(State->FileDesc, + Status = CFE_FS_WriteHeader(State->FileDesc, &FileHdr); BlockSize = sizeof(CFE_FS_Header_t); break; @@ -435,13 +443,13 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) case CFE_ES_PerfDumpState_WRITE_PERF_METADATA: /* write the performance metadata to the file */ BlockSize = sizeof(CFE_ES_PerfMetaData_t); - WriteStat = OS_write(State->FileDesc, + Status = OS_write(State->FileDesc, &Perf->MetaData, BlockSize); break; case CFE_ES_PerfDumpState_WRITE_PERF_ENTRIES: BlockSize = sizeof(CFE_ES_PerfDataEntry_t); - WriteStat = OS_write (State->FileDesc, + Status = OS_write (State->FileDesc, &Perf->DataBuffer[State->DataPos], BlockSize); @@ -458,9 +466,9 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) if (BlockSize != 0) { - if (WriteStat != BlockSize) + if (Status != BlockSize) { - CFE_ES_FileWriteByteCntErr(State->DataFileName, BlockSize, WriteStat); + CFE_ES_FileWriteByteCntErr(State->DataFileName, BlockSize, Status); /* skip to cleanup */ if (State->CurrentState < CFE_ES_PerfDumpState_CLEANUP) diff --git a/fsw/cfe-core/src/es/cfe_es_perf.h b/fsw/cfe-core/src/es/cfe_es_perf.h index 05d05afde..38e53d848 100644 --- a/fsw/cfe-core/src/es/cfe_es_perf.h +++ b/fsw/cfe-core/src/es/cfe_es_perf.h @@ -110,7 +110,7 @@ typedef struct CFE_ES_PerfDumpState_t PendingState; /* the pending/next state, if transitioning */ char DataFileName[OS_MAX_PATH_LEN]; /* output file name from dump command */ - int32 FileDesc; /* file descriptor for writing */ + osal_id_t FileDesc; /* file descriptor for writing */ uint32 WorkCredit; /* accumulator based on the passage of time */ uint32 StateCounter; /* number of blocks/items left in current state */ uint32 DataPos; /* last position within the Perf Log */ diff --git a/fsw/cfe-core/src/es/cfe_es_start.c b/fsw/cfe-core/src/es/cfe_es_start.c index c64d45f5a..85ba15e95 100644 --- a/fsw/cfe-core/src/es/cfe_es_start.c +++ b/fsw/cfe-core/src/es/cfe_es_start.c @@ -773,7 +773,7 @@ void CFE_ES_CreateObjects(void) bool AppSlotFound; uint16 i; uint16 j; - uint32 OsalId; + osal_id_t OsalId; CFE_ES_AppRecord_t *AppRecPtr; CFE_ES_TaskRecord_t *TaskRecPtr; @@ -872,7 +872,7 @@ void CFE_ES_CreateObjects(void) } else { - AppRecPtr->TaskInfo.MainTaskId = OsalId; + AppRecPtr->TaskInfo.MainTaskId = CFE_ES_ResourceID_FromOSAL(OsalId); TaskRecPtr = CFE_ES_LocateTaskRecordByID(AppRecPtr->TaskInfo.MainTaskId); /* diff --git a/fsw/cfe-core/src/es/cfe_es_syslog.c b/fsw/cfe-core/src/es/cfe_es_syslog.c index c71797da1..e8df4a5a7 100644 --- a/fsw/cfe-core/src/es/cfe_es_syslog.c +++ b/fsw/cfe-core/src/es/cfe_es_syslog.c @@ -468,7 +468,7 @@ void CFE_ES_SysLog_snprintf(char *Buffer, size_t BufferSize, const char *SpecStr */ int32 CFE_ES_SysLogDump(const char *Filename) { - int32 fd; + osal_id_t fd; int32 Status; size_t WritePos; size_t TotalSize; @@ -479,15 +479,17 @@ int32 CFE_ES_SysLogDump(const char *Filename) CFE_FS_Header_t FileHdr; } Buffer; - fd = OS_creat(Filename, OS_WRITE_ONLY); - if(fd < 0) + Status = OS_creat(Filename, OS_WRITE_ONLY); + if(Status < 0) { CFE_EVS_SendEvent(CFE_ES_SYSLOG2_ERR_EID,CFE_EVS_EventType_ERROR, "Error creating file %s, RC = 0x%08X", - Filename,(unsigned int)fd); + Filename,(unsigned int)Status); return CFE_ES_FILE_IO_ERR; }/* end if */ + fd = OS_ObjectIdFromInteger(Status); + CFE_FS_InitHeader(&Buffer.FileHdr, CFE_ES_SYS_LOG_DESC, CFE_FS_SubType_ES_SYSLOG); TotalSize = 0; diff --git a/fsw/cfe-core/src/es/cfe_es_task.c b/fsw/cfe-core/src/es/cfe_es_task.c index 20250b4d9..4f8122f58 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.c +++ b/fsw/cfe-core/src/es/cfe_es_task.c @@ -1175,7 +1175,7 @@ int32 CFE_ES_QueryOneCmd(const CFE_ES_QueryOne_t *data) int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAll_t *data) { CFE_FS_Header_t FileHeader; - int32 FileDescriptor; + osal_id_t FileDescriptor; uint32 i; uint32 EntryCount = 0; uint32 FileSize = 0; @@ -1194,9 +1194,10 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAll_t *data) /* ** Check to see if the file already exists */ - FileDescriptor = OS_open(QueryAllFilename, OS_READ_ONLY, 0); - if (FileDescriptor >= 0) + Result = OS_open(QueryAllFilename, OS_READ_ONLY, 0); + if (Result >= 0) { + FileDescriptor = OS_ObjectIdFromInteger(Result); OS_close(FileDescriptor); OS_remove(QueryAllFilename); } @@ -1204,9 +1205,10 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAll_t *data) /* ** Create ES task log data file */ - FileDescriptor = OS_creat(QueryAllFilename, OS_WRITE_ONLY); - if (FileDescriptor >= 0) + Result = OS_creat(QueryAllFilename, OS_WRITE_ONLY); + if (Result >= 0) { + FileDescriptor = OS_ObjectIdFromInteger(Result); /* ** Initialize cFE file header */ @@ -1290,7 +1292,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAll_t *data) { CFE_ES_TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, - "Failed to write App Info file, OS_creat RC = 0x%08X",(unsigned int)FileDescriptor); + "Failed to write App Info file, OS_creat RC = 0x%08X",(unsigned int)Result); } return CFE_SUCCESS; @@ -1305,7 +1307,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAll_t *data) int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasks_t *data) { CFE_FS_Header_t FileHeader; - int32 FileDescriptor; + osal_id_t FileDescriptor; uint32 i; uint32 EntryCount = 0; uint32 FileSize = 0; @@ -1323,9 +1325,10 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasks_t *data) /* ** Check to see if the file already exists */ - FileDescriptor = OS_open(QueryAllFilename, OS_READ_ONLY, 0); - if (FileDescriptor >= 0) + Result = OS_open(QueryAllFilename, OS_READ_ONLY, 0); + if (Result >= 0) { + FileDescriptor = OS_ObjectIdFromInteger(Result); OS_close(FileDescriptor); OS_remove(QueryAllFilename); } @@ -1333,9 +1336,10 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasks_t *data) /* ** Create ES task log data file */ - FileDescriptor = OS_creat(QueryAllFilename, OS_WRITE_ONLY); - if (FileDescriptor >= 0) + Result = OS_creat(QueryAllFilename, OS_WRITE_ONLY); + if (Result >= 0) { + FileDescriptor = OS_ObjectIdFromInteger(Result); /* ** Initialize cFE file header */ @@ -1419,7 +1423,7 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasks_t *data) { CFE_ES_TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_TASKINFO_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, - "Failed to write Task Info file, OS_creat RC = 0x%08X",(unsigned int)FileDescriptor); + "Failed to write Task Info file, OS_creat RC = 0x%08X",(unsigned int)Result); } return CFE_SUCCESS; @@ -1784,7 +1788,7 @@ int32 CFE_ES_SendMemPoolStatsCmd(const CFE_ES_SendMemPoolStats_t *data) int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistry_t *data) { CFE_FS_Header_t StdFileHeader; - int32 FileDescriptor; + osal_id_t FileDescriptor; int32 Status; int16 RegIndex=0; const CFE_ES_DumpCDSRegistryCmd_Payload_t *CmdPtr = &data->Payload; @@ -1799,10 +1803,12 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistry_t *data) OS_MAX_PATH_LEN, sizeof(CmdPtr->DumpFilename)); /* Create a new dump file, overwriting anything that may have existed previously */ - FileDescriptor = OS_creat(DumpFilename, OS_WRITE_ONLY); + Status = OS_creat(DumpFilename, OS_WRITE_ONLY); - if (FileDescriptor >= OS_SUCCESS) + if (Status >= OS_SUCCESS) { + FileDescriptor = OS_ObjectIdFromInteger(Status); + /* Initialize the standard cFE File Header for the Dump File */ CFE_FS_InitHeader(&StdFileHeader, "CDS_Registry", CFE_FS_SubType_ES_CDS_REG); @@ -1886,7 +1892,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistry_t *data) CFE_EVS_SendEvent(CFE_ES_CREATING_CDS_DUMP_ERR_EID, CFE_EVS_EventType_ERROR, "Error creating CDS dump file '%s', Status=0x%08X", - DumpFilename, (unsigned int)FileDescriptor); + DumpFilename, (unsigned int)Status); /* Increment Command Error Counter */ CFE_ES_TaskData.CommandErrorCounter++; diff --git a/fsw/cfe-core/src/es/cfe_esmempool.h b/fsw/cfe-core/src/es/cfe_esmempool.h index bf88ac2d1..b099258ef 100644 --- a/fsw/cfe-core/src/es/cfe_esmempool.h +++ b/fsw/cfe-core/src/es/cfe_esmempool.h @@ -68,7 +68,7 @@ typedef struct BlockSizeDesc_t *SizeDescPtr; uint16 CheckErrCntr; uint16 RequestCntr; - uint32 MutexId; + osal_id_t MutexId; uint32 UseMutex; BlockSizeDesc_t SizeDesc[CFE_ES_MAX_MEMPOOL_BLOCK_SIZES]; } Pool_t; diff --git a/fsw/cfe-core/src/evs/cfe_evs_log.c b/fsw/cfe-core/src/evs/cfe_evs_log.c index 20751edc7..198a3114b 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_log.c +++ b/fsw/cfe-core/src/evs/cfe_evs_log.c @@ -154,7 +154,7 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFile_t *data) int32 Result; int32 LogIndex; int32 BytesWritten; - int32 LogFileHandle; + osal_id_t LogFileHandle; uint32 i; CFE_FS_Header_t LogFileHdr; char LogFilename[OS_MAX_PATH_LEN]; @@ -172,18 +172,19 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFile_t *data) OS_MAX_PATH_LEN, sizeof(CmdPtr->LogFilename)); /* Create the log file */ - LogFileHandle = OS_creat(LogFilename, OS_WRITE_ONLY); + Result = OS_creat(LogFilename, OS_WRITE_ONLY); - if (LogFileHandle < OS_SUCCESS) + if (Result < OS_SUCCESS) { EVS_SendEvent(CFE_EVS_ERR_CRLOGFILE_EID, CFE_EVS_EventType_ERROR, "Write Log File Command Error: OS_creat = 0x%08X, filename = %s", - (unsigned int)LogFileHandle, LogFilename); + (unsigned int)Result, LogFilename); - Result = LogFileHandle; } else { + LogFileHandle = OS_ObjectIdFromInteger(Result); + /* Result will be overridden if everything works */ Result = CFE_EVS_FILE_WRITE_ERROR; diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.c b/fsw/cfe-core/src/evs/cfe_evs_task.c index 17328b985..928a083c0 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.c +++ b/fsw/cfe-core/src/evs/cfe_evs_task.c @@ -1737,7 +1737,7 @@ int32 CFE_EVS_DeleteEventFilterCmd(const CFE_EVS_DeleteEventFilter_t *data) int32 CFE_EVS_WriteAppDataFileCmd(const CFE_EVS_WriteAppDataFile_t *data) { int32 Result; - int32 FileHandle; + osal_id_t FileHandle; int32 BytesWritten; uint32 EntryCount = 0; uint32 i; @@ -1752,18 +1752,18 @@ int32 CFE_EVS_WriteAppDataFileCmd(const CFE_EVS_WriteAppDataFile_t *data) OS_MAX_PATH_LEN, sizeof(CmdPtr->AppDataFilename)); /* Create Application Data File */ - FileHandle = OS_creat(LocalName, OS_WRITE_ONLY); + Result = OS_creat(LocalName, OS_WRITE_ONLY); - if (FileHandle < OS_SUCCESS) + if (Result < OS_SUCCESS) { EVS_SendEvent(CFE_EVS_ERR_CRDATFILE_EID, CFE_EVS_EventType_ERROR, "Write App Data Command Error: OS_creat = 0x%08X, filename = %s", - (unsigned int)FileHandle, LocalName); - - Result = FileHandle; + (unsigned int)Result, LocalName); } else { + FileHandle = OS_ObjectIdFromInteger(Result); + /* Result will be overridden if everything works */ Result = CFE_EVS_FILE_WRITE_ERROR; diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.h b/fsw/cfe-core/src/evs/cfe_evs_task.h index 69584e57d..22d8eff94 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.h +++ b/fsw/cfe-core/src/evs/cfe_evs_task.h @@ -122,7 +122,7 @@ typedef struct */ CFE_EVS_HousekeepingTlm_t EVS_TlmPkt; CFE_SB_PipeId_t EVS_CommandPipe; - uint32 EVS_SharedDataMutexID; + osal_id_t EVS_SharedDataMutexID; uint32 EVS_AppID; } CFE_EVS_GlobalData_t; diff --git a/fsw/cfe-core/src/fs/cfe_fs_api.c b/fsw/cfe-core/src/fs/cfe_fs_api.c index 4b7c97beb..8e7c6cfca 100644 --- a/fsw/cfe-core/src/fs/cfe_fs_api.c +++ b/fsw/cfe-core/src/fs/cfe_fs_api.c @@ -46,7 +46,7 @@ /* ** CFE_FS_ReadHeader() - See API and header file for details */ -int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, int32 FileDes) +int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes) { int32 Result; int32 EndianCheck = 0x01020304; @@ -89,7 +89,7 @@ void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 Sub /* ** CFE_FS_WriteHeader() - See API and header file for details */ -int32 CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr) +int32 CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) { CFE_TIME_SysTime_t Time; int32 Result; @@ -158,7 +158,7 @@ int32 CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr) /* ** CFE_FS_SetTimestamp - See API and header file for details */ -int32 CFE_FS_SetTimestamp(int32 FileDes, CFE_TIME_SysTime_t NewTimestamp) +int32 CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimestamp) { int32 Result; CFE_FS_Header_t TempHdr; diff --git a/fsw/cfe-core/src/fs/cfe_fs_priv.h b/fsw/cfe-core/src/fs/cfe_fs_priv.h index 8a500c23b..199791ada 100644 --- a/fsw/cfe-core/src/fs/cfe_fs_priv.h +++ b/fsw/cfe-core/src/fs/cfe_fs_priv.h @@ -57,7 +57,7 @@ */ typedef struct { - uint32 SharedDataMutexId; + osal_id_t SharedDataMutexId; } CFE_FS_t; diff --git a/fsw/cfe-core/src/inc/cfe_es.h b/fsw/cfe-core/src/inc/cfe_es.h index 1d2328131..f5fb6d381 100644 --- a/fsw/cfe-core/src/inc/cfe_es.h +++ b/fsw/cfe-core/src/inc/cfe_es.h @@ -224,7 +224,7 @@ typedef struct uint32 StackSize; /**< \cfetlmmnemonic \ES_STACKSIZE \brief The Stack Size of the Application */ - uint32 ModuleId; /**< \cfetlmmnemonic \ES_MODULEID + osal_id_t ModuleId; /**< \cfetlmmnemonic \ES_MODULEID \brief The ID of the Loadable Module for the Application */ uint32 AddressesAreValid; /**< \cfetlmmnemonic \ES_ADDRVALID \brief Indicates that the Code, Data, and BSS addresses/sizes are valid */ diff --git a/fsw/cfe-core/src/inc/cfe_fs.h b/fsw/cfe-core/src/inc/cfe_fs.h index 782eac31b..b31839267 100644 --- a/fsw/cfe-core/src/inc/cfe_fs.h +++ b/fsw/cfe-core/src/inc/cfe_fs.h @@ -70,7 +70,7 @@ ** \sa #CFE_FS_WriteHeader ** ******************************************************************************/ -int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, int32 FileDes); +int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes); /*****************************************************************************/ /** @@ -128,7 +128,7 @@ void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 Sub ** \sa #CFE_FS_ReadHeader ** ******************************************************************************/ -int32 CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr); +int32 CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr); /*****************************************************************************/ /** @@ -153,7 +153,7 @@ int32 CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr); ** \return Execution status, see \ref CFEReturnCodes ** ******************************************************************************/ -int32 CFE_FS_SetTimestamp(int32 FileDes, CFE_TIME_SysTime_t NewTimestamp); +int32 CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimestamp); /**@}*/ diff --git a/fsw/cfe-core/src/sb/cfe_sb_api.c b/fsw/cfe-core/src/sb/cfe_sb_api.c index dab627050..3585f1a59 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_api.c +++ b/fsw/cfe-core/src/sb/cfe_sb_api.c @@ -82,7 +82,7 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * { uint32 AppId = 0xFFFFFFFF; uint32 TskId = 0; - uint32 SysQueueId = 0; + osal_id_t SysQueueId; int32 Status; CFE_SB_PipeId_t OriginalPipeIdParamValue = (PipeIdPtr == NULL) ? 0 : (*PipeIdPtr); CFE_SB_PipeId_t PipeTblIdx; @@ -561,7 +561,7 @@ int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) int32 Status = CFE_SUCCESS; int32 RtnFromVal = 0; uint32 TskId = 0; - uint32 QueueId = 0; + osal_id_t QueueId; char FullName[(OS_MAX_API_NAME * 2)]; /* get TaskId of caller for events */ @@ -593,7 +593,7 @@ int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) PipeTblIdx++) { if(CFE_SB.PipeTbl[PipeTblIdx].InUse != 0 - && CFE_SB.PipeTbl[PipeTblIdx].SysQueueId == QueueId) + && OS_ObjectIdEqual(CFE_SB.PipeTbl[PipeTblIdx].SysQueueId, QueueId)) { /* grab the ID before we release the lock */ *PipeIdPtr = CFE_SB.PipeTbl[PipeTblIdx].PipeId; diff --git a/fsw/cfe-core/src/sb/cfe_sb_priv.h b/fsw/cfe-core/src/sb/cfe_sb_priv.h index 95c252979..8a410a3a3 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_priv.h +++ b/fsw/cfe-core/src/sb/cfe_sb_priv.h @@ -48,7 +48,7 @@ #define CFE_SB_INVALID_ROUTE_IDX ((CFE_SB_MsgRouteIdx_t){ .RouteIdx = 0 }) #define CFE_SB_INVALID_MSG_KEY ((CFE_SB_MsgKey_t){ .KeyIdx = 0 }) -#define CFE_SB_UNUSED_QUEUE 0xFFFF +#define CFE_SB_UNUSED_QUEUE OS_OBJECT_ID_UNDEFINED #define CFE_SB_INVALID_PIPE 0xFF #define CFE_SB_NO_DESTINATION 0xFF #define CFE_SB_FAILED 1 @@ -249,7 +249,7 @@ typedef struct { uint8 Opts; uint8 Spare; uint32 AppId; - uint32 SysQueueId; + osal_id_t SysQueueId; uint32 LastSender; uint16 QueueDepth; uint16 SendErrors; @@ -280,7 +280,7 @@ typedef struct { ** This structure contains the SB global variables. */ typedef struct { - uint32 SharedDataMutexId; + osal_id_t SharedDataMutexId; uint32 SubscriptionReporting; uint32 SenderReporting; uint32 AppId; diff --git a/fsw/cfe-core/src/sb/cfe_sb_task.c b/fsw/cfe-core/src/sb/cfe_sb_task.c index b9a85cccd..6917043f6 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_task.c +++ b/fsw/cfe-core/src/sb/cfe_sb_task.c @@ -861,8 +861,8 @@ int32 CFE_SB_SendRtgInfo(const char *Filename) CFE_SB_MsgRouteIdx_t RtgTblIdx; const CFE_SB_RouteEntry_t* RtgTblPtr; CFE_SB_MsgKey_Atom_t MsgKeyVal; - int32 fd = 0; - int32 WriteStat; + osal_id_t fd; + int32 Status; uint32 FileSize = 0; uint32 EntryCount = 0; CFE_SB_RoutingFileEntry_t Entry; @@ -870,25 +870,27 @@ int32 CFE_SB_SendRtgInfo(const char *Filename) CFE_SB_PipeD_t *pd; CFE_SB_DestinationD_t *DestPtr; - fd = OS_creat(Filename, OS_WRITE_ONLY); - if(fd < OS_SUCCESS){ + Status = OS_creat(Filename, OS_WRITE_ONLY); + if(Status < OS_SUCCESS){ CFE_EVS_SendEvent(CFE_SB_SND_RTG_ERR1_EID,CFE_EVS_EventType_ERROR, "Error creating file %s, stat=0x%x", - Filename,(unsigned int)fd); + Filename,(unsigned int)Status); return CFE_SB_FILE_IO_ERR; }/* end if */ + fd = OS_ObjectIdFromInteger(Status); + /* clear out the cfe file header fields, then populate description and subtype */ CFE_FS_InitHeader(&FileHdr, "SB Routing Information", CFE_FS_SubType_SB_ROUTEDATA); - WriteStat = CFE_FS_WriteHeader(fd, &FileHdr); - if(WriteStat != sizeof(CFE_FS_Header_t)){ - CFE_SB_FileWriteByteCntErr(Filename,sizeof(CFE_FS_Header_t),WriteStat); + Status = CFE_FS_WriteHeader(fd, &FileHdr); + if(Status != sizeof(CFE_FS_Header_t)){ + CFE_SB_FileWriteByteCntErr(Filename,sizeof(CFE_FS_Header_t),Status); OS_close(fd); return CFE_SB_FILE_IO_ERR; }/* end if */ - FileSize = WriteStat; + FileSize = Status; /* loop through the entire MsgMap */ for(MsgKeyVal=0; MsgKeyVal < CFE_SB_MAX_NUMBER_OF_MSG_KEYS; ++MsgKeyVal) @@ -928,16 +930,16 @@ int32 CFE_SB_SendRtgInfo(const char *Filename) CFE_ES_GetAppName(&Entry.AppName[0], pd->AppId, sizeof(Entry.AppName)); CFE_SB_GetPipeName(Entry.PipeName, sizeof(Entry.PipeName), Entry.PipeId); - WriteStat = OS_write (fd, &Entry, sizeof(CFE_SB_RoutingFileEntry_t)); - if(WriteStat != sizeof(CFE_SB_RoutingFileEntry_t)){ + Status = OS_write (fd, &Entry, sizeof(CFE_SB_RoutingFileEntry_t)); + if(Status != sizeof(CFE_SB_RoutingFileEntry_t)){ CFE_SB_FileWriteByteCntErr(Filename, sizeof(CFE_SB_RoutingFileEntry_t), - WriteStat); + Status); OS_close(fd); return CFE_SB_FILE_IO_ERR; }/* end if */ - FileSize += WriteStat; + FileSize += Status; EntryCount ++; } @@ -973,46 +975,48 @@ int32 CFE_SB_SendRtgInfo(const char *Filename) int32 CFE_SB_SendPipeInfo(const char *Filename) { uint16 i; - int32 fd = 0; - int32 WriteStat; + osal_id_t fd; + int32 Status; uint32 FileSize = 0; uint32 EntryCount = 0; CFE_FS_Header_t FileHdr; - fd = OS_creat(Filename, OS_WRITE_ONLY); + Status = OS_creat(Filename, OS_WRITE_ONLY); - if(fd < OS_SUCCESS){ + if(Status < OS_SUCCESS){ CFE_EVS_SendEvent(CFE_SB_SND_RTG_ERR1_EID,CFE_EVS_EventType_ERROR, "Error creating file %s, stat=0x%x", - Filename,(unsigned int)fd); + Filename,(unsigned int)Status); return CFE_SB_FILE_IO_ERR; }/* end if */ + fd = OS_ObjectIdFromInteger(Status); + /* clear out the cfe file header fields, then populate description and subtype */ CFE_FS_InitHeader(&FileHdr, "SB Pipe Information", CFE_FS_SubType_SB_PIPEDATA); - WriteStat = CFE_FS_WriteHeader(fd, &FileHdr); - if(WriteStat != sizeof(CFE_FS_Header_t)){ - CFE_SB_FileWriteByteCntErr(Filename,sizeof(CFE_FS_Header_t),WriteStat); + Status = CFE_FS_WriteHeader(fd, &FileHdr); + if(Status != sizeof(CFE_FS_Header_t)){ + CFE_SB_FileWriteByteCntErr(Filename,sizeof(CFE_FS_Header_t),Status); OS_close(fd); return CFE_SB_FILE_IO_ERR; }/* end if */ - FileSize = WriteStat; + FileSize = Status; /* loop through the pipe table */ for(i=0;iMsgId; Entry.Index = CFE_SB_RouteIdxToValue(RtgTblIdx); - WriteStat = OS_write (fd, &Entry, sizeof(CFE_SB_MsgMapFileEntry_t)); - if(WriteStat != sizeof(CFE_SB_MsgMapFileEntry_t)){ - CFE_SB_FileWriteByteCntErr(Filename,sizeof(CFE_SB_MsgMapFileEntry_t),WriteStat); + Status = OS_write (fd, &Entry, sizeof(CFE_SB_MsgMapFileEntry_t)); + if(Status != sizeof(CFE_SB_MsgMapFileEntry_t)){ + CFE_SB_FileWriteByteCntErr(Filename,sizeof(CFE_SB_MsgMapFileEntry_t),Status); OS_close(fd); return CFE_SB_FILE_IO_ERR; }/* end if */ - FileSize += WriteStat; + FileSize += Status; EntryCount ++; }/* end for */ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c index 81f1e2d0a..8835a58b6 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c @@ -895,7 +895,7 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe int32 Status = CFE_SUCCESS; CFE_FS_Header_t StdFileHeader; CFE_TBL_File_Hdr_t TblFileHeader; - int32 FileDescriptor; + osal_id_t FileDescriptor; size_t FilenameLen = strlen(Filename); uint32 NumBytes; uint8 ExtraByte; @@ -912,18 +912,20 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe } /* Try to open the specified table file */ - FileDescriptor = OS_open(Filename, OS_READ_ONLY, 0); + Status = OS_open(Filename, OS_READ_ONLY, 0); - if (FileDescriptor < 0) + if (Status < 0) { CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_ACCESS_ERR_EID, CFE_EVS_EventType_ERROR, CFE_TBL_TaskData.TableTaskAppId, "%s: Unable to open file (FileDescriptor=%d)", - AppName, (int)FileDescriptor); + AppName, (int)Status); return CFE_TBL_ERR_ACCESS; } + FileDescriptor = OS_ObjectIdFromInteger(Status); + Status = CFE_TBL_ReadHeaders(FileDescriptor, &StdFileHeader, &TblFileHeader, Filename); if (Status != CFE_SUCCESS) @@ -1163,7 +1165,7 @@ void CFE_TBL_NotifyTblUsersOfUpdate(CFE_TBL_RegistryRec_t *RegRecPtr) ** NOTE: For complete prolog information, see 'cfe_tbl_internal.h' ********************************************************************/ -int32 CFE_TBL_ReadHeaders( int32 FileDescriptor, +int32 CFE_TBL_ReadHeaders( osal_id_t FileDescriptor, CFE_FS_Header_t *StdFileHeaderPtr, CFE_TBL_File_Hdr_t *TblFileHeaderPtr, const char *LoadFilename ) diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.h b/fsw/cfe-core/src/tbl/cfe_tbl_internal.h index 9a1177b75..fb7930c24 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_internal.h +++ b/fsw/cfe-core/src/tbl/cfe_tbl_internal.h @@ -455,7 +455,7 @@ void CFE_TBL_NotifyTblUsersOfUpdate( CFE_TBL_RegistryRec_t *RegRecPtr ); ** \retval #CFE_TBL_ERR_BAD_PROCESSOR_ID \copydoc CFE_TBL_ERR_BAD_PROCESSOR_ID ** ******************************************************************************/ -int32 CFE_TBL_ReadHeaders( int32 FileDescriptor, +int32 CFE_TBL_ReadHeaders( osal_id_t FileDescriptor, CFE_FS_Header_t *StdFileHeaderPtr, CFE_TBL_File_Hdr_t *TblFileHeaderPtr, const char *LoadFilename ); diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task.h b/fsw/cfe-core/src/tbl/cfe_tbl_task.h index 6cd8e5c3d..20e57cf8b 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task.h +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task.h @@ -324,8 +324,8 @@ typedef struct /* ** Registry Access Mutex and Load Buffer Semaphores */ - uint32 RegistryMutex; /**< \brief Mutex that controls access to Table Registry */ - uint32 WorkBufMutex; /**< \brief Mutex that controls assignment of Working Buffers */ + osal_id_t RegistryMutex; /**< \brief Mutex that controls access to Table Registry */ + osal_id_t WorkBufMutex; /**< \brief Mutex that controls assignment of Working Buffers */ CFE_ES_CDSHandle_t CritRegHandle; /**< \brief Handle to Critical Table Registry in CDS */ CFE_TBL_LoadBuff_t LoadBuffs[CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS]; /**< \brief Working table buffers shared by single buffered tables */ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c index cc49e0968..67274316a 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c @@ -59,7 +59,7 @@ int32 CFE_TBL_HousekeepingCmd(const CFE_SB_CmdHdr_t *data) uint32 i; CFE_TBL_DumpControl_t *DumpCtrlPtr; CFE_TIME_SysTime_t DumpTime; - int32 FileDescriptor; + osal_id_t FileDescriptor; /* ** Collect housekeeping data from Table Services @@ -113,10 +113,12 @@ int32 CFE_TBL_HousekeepingCmd(const CFE_SB_CmdHdr_t *data) DumpTime.Seconds = DumpCtrlPtr->DumpBufferPtr->FileCreateTimeSecs; DumpTime.Subseconds = DumpCtrlPtr->DumpBufferPtr->FileCreateTimeSubSecs; - FileDescriptor = OS_open(DumpCtrlPtr->DumpBufferPtr->DataSource, OS_READ_WRITE, 0); + Status = OS_open(DumpCtrlPtr->DumpBufferPtr->DataSource, OS_READ_WRITE, 0); - if (FileDescriptor >= 0) + if (Status >= 0) { + FileDescriptor = OS_ObjectIdFromInteger(Status); + Status = CFE_FS_SetTimestamp(FileDescriptor, DumpTime); if (Status != OS_SUCCESS) @@ -373,7 +375,7 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_Load_t *data) const CFE_TBL_LoadCmd_Payload_t *CmdPtr = &data->Payload; CFE_FS_Header_t StdFileHeader; CFE_TBL_File_Hdr_t TblFileHeader; - int32 FileDescriptor; + osal_id_t FileDescriptor; int32 Status; CFE_TBL_RegistryRec_t *RegRecPtr; CFE_TBL_LoadBuff_t *WorkingBufferPtr; @@ -385,10 +387,12 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_Load_t *data) OS_MAX_PATH_LEN, sizeof(CmdPtr->LoadFilename)); /* Try to open the specified table file */ - FileDescriptor = OS_open(LoadFilename, OS_READ_ONLY, 0); + Status = OS_open(LoadFilename, OS_READ_ONLY, 0); - if (FileDescriptor >= 0) + if (Status >= 0) { + FileDescriptor = OS_ObjectIdFromInteger(Status); + Status = CFE_TBL_ReadHeaders(FileDescriptor, &StdFileHeader, &TblFileHeader, &LoadFilename[0]); if (Status == CFE_SUCCESS) @@ -557,7 +561,7 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_Load_t *data) CFE_EVS_SendEvent(CFE_TBL_FILE_ACCESS_ERR_EID, CFE_EVS_EventType_ERROR, "Unable to open file '%s' for table load, Status = 0x%08X", - LoadFilename, (unsigned int)FileDescriptor); + LoadFilename, (unsigned int)Status); } return ReturnCode; @@ -736,7 +740,7 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *T bool FileExistedPrev = false; CFE_FS_Header_t StdFileHeader; CFE_TBL_File_Hdr_t TblFileHeader; - int32 FileDescriptor; + osal_id_t FileDescriptor; int32 Status; int32 EndianCheck = 0x01020304; @@ -744,20 +748,22 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *T memset(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t)); /* Check to see if the dump file already exists */ - FileDescriptor = OS_open(DumpFilename, OS_READ_ONLY, 0); + Status = OS_open(DumpFilename, OS_READ_ONLY, 0); - if (FileDescriptor >= 0) + if (Status >= 0) { FileExistedPrev = true; - + FileDescriptor = OS_ObjectIdFromInteger(Status); OS_close(FileDescriptor); } /* Create a new dump file, overwriting anything that may have existed previously */ - FileDescriptor = OS_creat(DumpFilename, OS_WRITE_ONLY); + Status = OS_creat(DumpFilename, OS_WRITE_ONLY); - if (FileDescriptor >= OS_SUCCESS) + if (Status >= OS_SUCCESS) { + FileDescriptor = OS_ObjectIdFromInteger(Status); + /* Initialize the standard cFE File Header for the Dump File */ CFE_FS_InitHeader(&StdFileHeader, "Table Dump Image", CFE_FS_SubType_TBL_IMG); @@ -852,7 +858,7 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *T CFE_EVS_SendEvent(CFE_TBL_CREATING_DUMP_FILE_ERR_EID, CFE_EVS_EventType_ERROR, "Error creating dump file '%s', Status=0x%08X", - DumpFilename, (unsigned int)FileDescriptor); + DumpFilename, (unsigned int)Status); } return ReturnCode; @@ -1120,7 +1126,7 @@ int32 CFE_TBL_DumpRegistryCmd(const CFE_TBL_DumpRegistry_t *data) CFE_TBL_CmdProcRet_t ReturnCode = CFE_TBL_INC_ERR_CTR; /* Assume failure */ bool FileExistedPrev = false; CFE_FS_Header_t StdFileHeader; - int32 FileDescriptor; + osal_id_t FileDescriptor; int32 Status; int16 RegIndex=0; const CFE_TBL_DumpRegistryCmd_Payload_t *CmdPtr = &data->Payload; @@ -1136,20 +1142,22 @@ int32 CFE_TBL_DumpRegistryCmd(const CFE_TBL_DumpRegistry_t *data) OS_MAX_PATH_LEN, sizeof(CmdPtr->DumpFilename)); /* Check to see if the dump file already exists */ - FileDescriptor = OS_open(DumpFilename, OS_READ_ONLY, 0); + Status = OS_open(DumpFilename, OS_READ_ONLY, 0); - if (FileDescriptor >= 0) + if (Status >= 0) { FileExistedPrev = true; - + FileDescriptor = OS_ObjectIdFromInteger(Status); OS_close(FileDescriptor); } /* Create a new dump file, overwriting anything that may have existed previously */ - FileDescriptor = OS_creat(DumpFilename, OS_WRITE_ONLY); + Status = OS_creat(DumpFilename, OS_WRITE_ONLY); - if (FileDescriptor >= OS_SUCCESS) + if (Status >= OS_SUCCESS) { + FileDescriptor = OS_ObjectIdFromInteger(Status); + /* Initialize the standard cFE File Header for the Dump File */ CFE_FS_InitHeader(&StdFileHeader, "Table Registry", CFE_FS_SubType_TBL_REG); @@ -1286,7 +1294,7 @@ int32 CFE_TBL_DumpRegistryCmd(const CFE_TBL_DumpRegistry_t *data) CFE_EVS_SendEvent(CFE_TBL_CREATING_DUMP_FILE_ERR_EID, CFE_EVS_EventType_ERROR, "Error creating dump file '%s', Status=0x%08X", - DumpFilename, (unsigned int)FileDescriptor); + DumpFilename, (unsigned int)Status); } return ReturnCode; diff --git a/fsw/cfe-core/src/time/cfe_time_task.c b/fsw/cfe-core/src/time/cfe_time_task.c index b1e0f16f9..0f7ef3a50 100644 --- a/fsw/cfe-core/src/time/cfe_time_task.c +++ b/fsw/cfe-core/src/time/cfe_time_task.c @@ -198,8 +198,8 @@ void CFE_TIME_TaskMain(void) int32 CFE_TIME_TaskInit(void) { int32 Status = CFE_SUCCESS; - uint32 TimeBaseId; - uint32 TimerId; + osal_id_t TimeBaseId; + osal_id_t TimerId; Status = CFE_ES_RegisterApp(); if(Status != CFE_SUCCESS) diff --git a/fsw/cfe-core/src/time/cfe_time_tone.c b/fsw/cfe-core/src/time/cfe_time_tone.c index 81fd8f6c6..ae1ca4295 100644 --- a/fsw/cfe-core/src/time/cfe_time_tone.c +++ b/fsw/cfe-core/src/time/cfe_time_tone.c @@ -1068,7 +1068,7 @@ void CFE_TIME_ToneUpdate(void) /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void CFE_TIME_Local1HzTimerCallback(uint32 TimerId, void *Arg) +void CFE_TIME_Local1HzTimerCallback(osal_id_t TimerId, void *Arg) { CFE_TIME_Local1HzISR(); } diff --git a/fsw/cfe-core/src/time/cfe_time_utils.h b/fsw/cfe-core/src/time/cfe_time_utils.h index 79fc6880c..0deecaa36 100644 --- a/fsw/cfe-core/src/time/cfe_time_utils.h +++ b/fsw/cfe-core/src/time/cfe_time_utils.h @@ -300,8 +300,8 @@ typedef struct /* ** Interrupt task semaphores... */ - uint32 LocalSemaphore; - uint32 ToneSemaphore; + osal_id_t LocalSemaphore; + osal_id_t ToneSemaphore; /* ** Interrupt task ID's... */ @@ -462,7 +462,7 @@ void CFE_TIME_NotifyTimeSynchApps(void); */ void CFE_TIME_Local1HzTask(void); void CFE_TIME_Local1HzStateMachine(void); -void CFE_TIME_Local1HzTimerCallback(uint32 TimerId, void *Arg); +void CFE_TIME_Local1HzTimerCallback(osal_id_t TimerId, void *Arg); #endif /* _cfe_time_utils_ */ diff --git a/fsw/cfe-core/unit-test/es_UT.c b/fsw/cfe-core/unit-test/es_UT.c index 3409dd0db..d52f07464 100644 --- a/fsw/cfe-core/unit-test/es_UT.c +++ b/fsw/cfe-core/unit-test/es_UT.c @@ -216,16 +216,14 @@ uint32 ES_UT_MakeTaskIdForIndex(uint32 ArrayIdx) void ES_UT_SetupSingleAppId(CFE_ES_AppType_Enum_t AppType, CFE_ES_AppState_Enum_t AppState, const char *AppName, CFE_ES_AppRecord_t **OutAppRec, CFE_ES_TaskRecord_t **OutTaskRec) { - uint32 UtOsalId; + osal_id_t UtOsalId; uint32 UtTaskId; uint32 UtAppId; - uint32 ArrayIdx; CFE_ES_AppRecord_t *LocalAppPtr; CFE_ES_TaskRecord_t *LocalTaskPtr; OS_TaskCreate(&UtOsalId, "UT", NULL, NULL, 0, 0, 0); - OS_ConvertToArrayIndex(UtOsalId, &ArrayIdx); - UtTaskId = UtOsalId; + UtTaskId = CFE_ES_ResourceID_FromOSAL(UtOsalId); UtAppId = ES_UT_MakeAppIdForIndex(ES_UT_NumApps); ++ES_UT_NumApps; @@ -275,19 +273,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) { - uint32 UtOsalId; + osal_id_t UtOsalId; uint32 UtTaskId; uint32 UtAppId; - uint32 ArrayIdx; CFE_ES_TaskRecord_t *LocalTaskPtr; UtAppId = CFE_ES_AppRecordGetID(ParentApp); OS_TaskCreate(&UtOsalId, "C", NULL, NULL, 0, 0, 0); - OS_ConvertToArrayIndex(UtOsalId, &ArrayIdx); - UtTaskId = UtOsalId; + UtTaskId = CFE_ES_ResourceID_FromOSAL(UtOsalId); - LocalTaskPtr = &CFE_ES_Global.TaskTable[ArrayIdx]; + LocalTaskPtr = CFE_ES_LocateTaskRecordByID(UtTaskId); CFE_ES_TaskRecordSetUsed(LocalTaskPtr, UtTaskId); LocalTaskPtr->AppId = UtAppId; @@ -345,7 +341,7 @@ int32 ES_UT_SetupOSCleanupHook(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) { - uint32 ObjList[7]; + osal_id_t ObjList[7]; /* On the first call, Use the stub functions to generate one object of * each type @@ -358,7 +354,7 @@ int32 ES_UT_SetupOSCleanupHook(void *UserObj, int32 StubRetcode, OS_BinSemCreate(&ObjList[3], NULL, 0, 0); OS_CountSemCreate(&ObjList[4], NULL, 0, 0); OS_TimerCreate(&ObjList[5], NULL, NULL, NULL); - ObjList[6] = OS_open(NULL, 0, 0); + ObjList[6] = OS_ObjectIdFromInteger(OS_open(NULL, 0, 0)); UT_SetDataBuffer((UT_EntryKey_t)&OS_ForEachObject, ObjList, sizeof(ObjList), true); @@ -2031,7 +2027,7 @@ void TestTask(void) { uint32 ResetType; uint32 UT_ContextData; - uint32 UT_ContextTask; + osal_id_t UT_ContextTask; union { CFE_SB_Msg_t Msg; @@ -2888,7 +2884,7 @@ void TestTask(void) ES_ResetUnitTest(); UT_SetForceFail(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_TaskRecordGetID(UtTaskRecPtr); + UT_ContextTask = CFE_ES_ResourceID_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; @@ -2909,7 +2905,7 @@ void TestTask(void) ES_ResetUnitTest(); UT_SetForceFail(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_TaskRecordGetID(UtTaskRecPtr); + UT_ContextTask = CFE_ES_ResourceID_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; @@ -3858,7 +3854,7 @@ void TestPerf(void) ES_ResetUnitTest(); memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); - CFE_ES_TaskData.BackgroundPerfDumpState.FileDesc = OS_creat("UT", OS_WRITE_ONLY); + CFE_ES_TaskData.BackgroundPerfDumpState.FileDesc = OS_ObjectIdFromInteger(OS_creat("UT", OS_WRITE_ONLY)); CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_WRITE_PERF_ENTRIES; CFE_ES_TaskData.BackgroundPerfDumpState.PendingState = CFE_ES_PerfDumpState_WRITE_PERF_ENTRIES; CFE_ES_TaskData.BackgroundPerfDumpState.DataPos = CFE_PLATFORM_ES_PERF_DATA_BUFFER_SIZE - 2; @@ -3879,7 +3875,7 @@ void TestPerf(void) ES_ResetUnitTest(); memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); - CFE_ES_TaskData.BackgroundPerfDumpState.FileDesc = OS_creat("UT", OS_WRITE_ONLY); + CFE_ES_TaskData.BackgroundPerfDumpState.FileDesc = OS_ObjectIdFromInteger(OS_creat("UT", OS_WRITE_ONLY)); CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_WRITE_PERF_METADATA; CFE_ES_TaskData.BackgroundPerfDumpState.StateCounter = 10; Perf->MetaData.DataCount = 100; @@ -3892,7 +3888,7 @@ void TestPerf(void) void TestAPI(void) { - uint32 TestObjId; + osal_id_t TestObjId; char AppName[32]; uint32 StackBuf[8]; int32 Return; @@ -4309,8 +4305,8 @@ 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_TaskRecordGetID(UtTaskRecPtr); - UT_SetForceFail(UT_KEY(OS_TaskGetId), (unsigned long)TestObjId); /* Set context to that of child */ + TestObjId = CFE_ES_ResourceID_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); + UT_SetForceFail(UT_KEY(OS_TaskGetId), OS_ObjectIdToInteger(TestObjId)); /* Set context to that of child */ Return = CFE_ES_CreateChildTask(&TaskId, "TaskName", TestAPI, @@ -4398,8 +4394,8 @@ 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_TaskRecordGetID(UtTaskRecPtr); - UT_SetForceFail(UT_KEY(OS_TaskGetId), (unsigned long)TestObjId); /* Set context to that of child */ + TestObjId = CFE_ES_ResourceID_ToOSAL(CFE_ES_TaskRecordGetID(UtTaskRecPtr)); + UT_SetForceFail(UT_KEY(OS_TaskGetId), OS_ObjectIdToInteger(TestObjId)); /* Set context to that of child */ CFE_ES_ExitChildTask(); UT_Report(__FILE__, __LINE__, UT_GetStubCount(UT_KEY(OS_TaskExit)) == 1, diff --git a/fsw/cfe-core/unit-test/fs_UT.c b/fsw/cfe-core/unit-test/fs_UT.c index 83080eb02..970afa6db 100644 --- a/fsw/cfe-core/unit-test/fs_UT.c +++ b/fsw/cfe-core/unit-test/fs_UT.c @@ -88,7 +88,7 @@ void Test_CFE_FS_InitHeader(void) */ void Test_CFE_FS_ReadHeader(void) { - int32 FileDes = 0; + osal_id_t FileDes = OS_OBJECT_ID_UNDEFINED; CFE_FS_Header_t Hdr; #ifdef UT_VERBOSE @@ -118,7 +118,7 @@ void Test_CFE_FS_ReadHeader(void) */ void Test_CFE_FS_WriteHeader(void) { - int32 FileDes = 0; + osal_id_t FileDes = OS_OBJECT_ID_UNDEFINED; CFE_FS_Header_t Hdr; #ifdef UT_VERBOSE @@ -148,7 +148,7 @@ void Test_CFE_FS_WriteHeader(void) */ void Test_CFE_FS_SetTimestamp(void) { - int32 FileDes = 0; + osal_id_t FileDes = OS_OBJECT_ID_UNDEFINED; CFE_TIME_SysTime_t NewTimestamp = {0, 0}; #ifdef UT_VERBOSE diff --git a/fsw/cfe-core/unit-test/sb_UT.c b/fsw/cfe-core/unit-test/sb_UT.c index 98de8a255..df0bfaf74 100644 --- a/fsw/cfe-core/unit-test/sb_UT.c +++ b/fsw/cfe-core/unit-test/sb_UT.c @@ -1833,7 +1833,7 @@ void Test_GetPipeName(void) CFE_SB_PipeId_t PipeId = 0; OS_queue_prop_t queue_info = { - "TestPipe1", 0 + "TestPipe1" }; SETUP(CFE_SB_CreatePipe(&PipeId, 4, "TestPipe1")); diff --git a/fsw/cfe-core/unit-test/tbl_UT.c b/fsw/cfe-core/unit-test/tbl_UT.c index 015c762aa..a82e8de1a 100644 --- a/fsw/cfe-core/unit-test/tbl_UT.c +++ b/fsw/cfe-core/unit-test/tbl_UT.c @@ -4069,13 +4069,14 @@ void Test_CFE_TBL_Internal(void) int32 i; CFE_FS_Header_t StdFileHeader; CFE_TBL_File_Hdr_t TblFileHeader; - int32 FileDescriptor = 0; + osal_id_t FileDescriptor; void *TblPtr; #ifdef UT_VERBOSE UT_Text("Begin Test Internal\n"); #endif + FileDescriptor = OS_OBJECT_ID_UNDEFINED; StdFileHeader.SpacecraftID = CFE_PLATFORM_TBL_VALID_SCID_1; StdFileHeader.ProcessorID = CFE_PLATFORM_TBL_VALID_PRID_1; diff --git a/fsw/cfe-core/unit-test/time_UT.c b/fsw/cfe-core/unit-test/time_UT.c index 01554ec8e..6de03f7e2 100644 --- a/fsw/cfe-core/unit-test/time_UT.c +++ b/fsw/cfe-core/unit-test/time_UT.c @@ -3198,7 +3198,7 @@ void Test_1Hz(void) CFE_TIME_TaskData.OneHzAdjust.Subseconds = 0; CFE_TIME_FinishReferenceUpdate(RefState); UT_SetBSP_Time(0, 0); - CFE_TIME_Local1HzTimerCallback(123, &Arg); + CFE_TIME_Local1HzTimerCallback(OS_ObjectIdFromInteger(123), &Arg); UT_Report(__FILE__, __LINE__, CFE_TIME_TaskData.LocalIntCounter == 2, "CFE_TIME_Local1HzTimerCallback", diff --git a/fsw/cfe-core/ut-stubs/ut_fs_stubs.c b/fsw/cfe-core/ut-stubs/ut_fs_stubs.c index 720d67729..126fe2d3a 100644 --- a/fsw/cfe-core/ut-stubs/ut_fs_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_fs_stubs.c @@ -87,7 +87,7 @@ void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 Sub ** CFE_FS_Header_t structure in bytes. ** ******************************************************************************/ -int32 CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr) +int32 CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_WriteHeader), FileDes); UT_Stub_RegisterContext(UT_KEY(CFE_FS_WriteHeader), Hdr); @@ -126,7 +126,7 @@ int32 CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr) ** CFE_FS_Header_t structure in bytes. ** ******************************************************************************/ -int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, int32 FileDes) +int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes) { UT_Stub_RegisterContext(UT_KEY(CFE_FS_ReadHeader), Hdr); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ReadHeader), FileDes); @@ -163,7 +163,7 @@ int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, int32 FileDes) ** Returns either a user-defined status flag or OS_SUCCESS. ** ******************************************************************************/ -int32 CFE_FS_SetTimestamp(int32 FileDes, CFE_TIME_SysTime_t NewTimestamp) +int32 CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimestamp) { UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_SetTimestamp), FileDes); UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_SetTimestamp), NewTimestamp);