diff --git a/modules/es/fsw/src/cfe_es_api.c b/modules/es/fsw/src/cfe_es_api.c index 78f9a6491..571d90114 100644 --- a/modules/es/fsw/src/cfe_es_api.c +++ b/modules/es/fsw/src/cfe_es_api.c @@ -49,10 +49,10 @@ int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr) { if (ResetSubtypePtr != NULL) { - *ResetSubtypePtr = CFE_ES_ResetDataPtr->ResetVars.ResetSubtype; + *ResetSubtypePtr = CFE_ES_Global.ResetDataPtr->ResetVars.ResetSubtype; } - return (CFE_ES_ResetDataPtr->ResetVars.ResetType); + return (CFE_ES_Global.ResetDataPtr->ResetVars.ResetType); } /* End of CFE_ES_GetResetType() */ @@ -68,13 +68,14 @@ int32 CFE_ES_ResetCFE(uint32 ResetType) /* ** Increment the processor reset count */ - CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount++; + CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount++; /* ** Before doing a Processor reset, check to see ** if the maximum number has been exceeded */ - if (CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount > CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount) + if (CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount > + CFE_ES_Global.ResetDataPtr->ResetVars.MaxProcessorResetCount) { CFE_ES_WriteToSysLog("POWER ON RESET due to max proc resets (Commanded).\n"); @@ -96,7 +97,7 @@ int32 CFE_ES_ResetCFE(uint32 ResetType) /* ** Update the reset variables */ - CFE_ES_ResetDataPtr->ResetVars.ES_CausedReset = true; + CFE_ES_Global.ResetDataPtr->ResetVars.ES_CausedReset = true; /* ** Log the reset in the ER Log diff --git a/modules/es/fsw/src/cfe_es_apps.c b/modules/es/fsw/src/cfe_es_apps.c index 1944e7153..5c17fbe74 100644 --- a/modules/es/fsw/src/cfe_es_apps.c +++ b/modules/es/fsw/src/cfe_es_apps.c @@ -993,7 +993,8 @@ bool CFE_ES_RunAppTableScan(uint32 ElapsedTime, void *Arg) /* * If the command count changes, then a scan becomes due immediately. */ - if (State->LastScanCommandCount == CFE_ES_TaskData.CommandCounter && State->BackgroundScanTimer > ElapsedTime) + if (State->LastScanCommandCount == CFE_ES_Global.TaskData.CommandCounter && + State->BackgroundScanTimer > ElapsedTime) { /* no action at this time, background scan is not due yet */ State->BackgroundScanTimer -= ElapsedTime; @@ -1008,7 +1009,7 @@ bool CFE_ES_RunAppTableScan(uint32 ElapsedTime, void *Arg) */ NumAppTimeouts = 0; State->BackgroundScanTimer = CFE_PLATFORM_ES_APP_SCAN_RATE; - State->LastScanCommandCount = CFE_ES_TaskData.CommandCounter; + State->LastScanCommandCount = CFE_ES_Global.TaskData.CommandCounter; State->PendingAppStateChanges = 0; /* diff --git a/modules/es/fsw/src/cfe_es_backgroundtask.c b/modules/es/fsw/src/cfe_es_backgroundtask.c index 6410005db..405ac575d 100644 --- a/modules/es/fsw/src/cfe_es_backgroundtask.c +++ b/modules/es/fsw/src/cfe_es_backgroundtask.c @@ -67,12 +67,12 @@ typedef struct const CFE_ES_BackgroundJobEntry_t CFE_ES_BACKGROUND_JOB_TABLE[] = { {/* ES app table background scan */ .RunFunc = CFE_ES_RunAppTableScan, - .JobArg = &CFE_ES_TaskData.BackgroundAppScanState, + .JobArg = &CFE_ES_Global.BackgroundAppScanState, .ActivePeriod = CFE_PLATFORM_ES_APP_SCAN_RATE / 4, .IdlePeriod = CFE_PLATFORM_ES_APP_SCAN_RATE}, {/* Performance Log Data Dump to file */ .RunFunc = CFE_ES_RunPerfLogDump, - .JobArg = &CFE_ES_TaskData.BackgroundPerfDumpState, + .JobArg = &CFE_ES_Global.BackgroundPerfDumpState, .ActivePeriod = CFE_PLATFORM_ES_PERF_CHILD_MS_DELAY, .IdlePeriod = CFE_PLATFORM_ES_PERF_CHILD_MS_DELAY * 1000}, {/* Check for exceptions stored in the PSP */ diff --git a/modules/es/fsw/src/cfe_es_erlog.c b/modules/es/fsw/src/cfe_es_erlog.c index 5df6e9a98..7370df0bd 100644 --- a/modules/es/fsw/src/cfe_es_erlog.c +++ b/modules/es/fsw/src/cfe_es_erlog.c @@ -84,25 +84,25 @@ int32 CFE_ES_WriteToERLogWithContext(CFE_ES_LogEntryType_Enum_t EntryType, uint3 /* ** Try to clean up an invalid ER log index variable. */ - if (CFE_ES_ResetDataPtr->ERLogIndex >= CFE_PLATFORM_ES_ER_LOG_ENTRIES) + if (CFE_ES_Global.ResetDataPtr->ERLogIndex >= CFE_PLATFORM_ES_ER_LOG_ENTRIES) { - CFE_ES_ResetDataPtr->ERLogIndex = 0; + CFE_ES_Global.ResetDataPtr->ERLogIndex = 0; } - LogIdx = CFE_ES_ResetDataPtr->ERLogIndex; + LogIdx = CFE_ES_Global.ResetDataPtr->ERLogIndex; /* ** Now that the Local Index variable is set, increment the index for the next entry. */ - CFE_ES_ResetDataPtr->ERLogIndex++; - if (CFE_ES_ResetDataPtr->ERLogIndex >= CFE_PLATFORM_ES_ER_LOG_ENTRIES) + CFE_ES_Global.ResetDataPtr->ERLogIndex++; + if (CFE_ES_Global.ResetDataPtr->ERLogIndex >= CFE_PLATFORM_ES_ER_LOG_ENTRIES) { - CFE_ES_ResetDataPtr->ERLogIndex = 0; + CFE_ES_Global.ResetDataPtr->ERLogIndex = 0; } /* ** Clear out the log entry we are about to use. */ - EntryPtr = &CFE_ES_ResetDataPtr->ERLog[LogIdx]; + EntryPtr = &CFE_ES_Global.ResetDataPtr->ERLog[LogIdx]; memset(EntryPtr, 0, sizeof(*EntryPtr)); /* @@ -111,9 +111,9 @@ int32 CFE_ES_WriteToERLogWithContext(CFE_ES_LogEntryType_Enum_t EntryType, uint3 EntryPtr->BaseInfo.LogEntryType = EntryType; EntryPtr->BaseInfo.ResetType = ResetType; EntryPtr->BaseInfo.ResetSubtype = ResetSubtype; - EntryPtr->BaseInfo.BootSource = CFE_ES_ResetDataPtr->ResetVars.BootSource; - EntryPtr->BaseInfo.ProcessorResetCount = CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount; - EntryPtr->BaseInfo.MaxProcessorResetCount = CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount; + EntryPtr->BaseInfo.BootSource = CFE_ES_Global.ResetDataPtr->ResetVars.BootSource; + EntryPtr->BaseInfo.ProcessorResetCount = CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount; + EntryPtr->BaseInfo.MaxProcessorResetCount = CFE_ES_Global.ResetDataPtr->ResetVars.MaxProcessorResetCount; /* ** Copy the ES Reset variables to the log (before they are modified by the log entry). @@ -140,7 +140,7 @@ int32 CFE_ES_WriteToERLogWithContext(CFE_ES_LogEntryType_Enum_t EntryType, uint3 /* ** Increment the number of ER log entries made */ - CFE_ES_ResetDataPtr->ERLogEntries++; + CFE_ES_Global.ResetDataPtr->ERLogEntries++; /* * Shared data update is complete @@ -188,7 +188,7 @@ bool CFE_ES_BackgroundERLogFileDataGetter(void *Meta, uint32 RecordNum, void **B if (RecordNum < CFE_PLATFORM_ES_ER_LOG_ENTRIES) { - EntryPtr = &CFE_ES_ResetDataPtr->ERLog[RecordNum]; + EntryPtr = &CFE_ES_Global.ResetDataPtr->ERLog[RecordNum]; /* First wipe the buffer before re-use */ memset(FileBufferPtr, 0, sizeof(*FileBufferPtr)); @@ -367,25 +367,25 @@ bool CFE_ES_RunExceptionScan(uint32 ElapsedTime, void *Arg) */ if (ResetType == 0) { - if (CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount >= - CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount) + if (CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount >= + CFE_ES_Global.ResetDataPtr->ResetVars.MaxProcessorResetCount) { CFE_ES_WriteToSysLog("Maximum Processor Reset count reached (%u)", - (unsigned int)CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount); + (unsigned int)CFE_ES_Global.ResetDataPtr->ResetVars.MaxProcessorResetCount); ResetType = CFE_PSP_RST_TYPE_POWERON; } else { CFE_ES_WriteToSysLog("Processor Reset count not reached (%u/%u)", - (unsigned int)CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount, - (unsigned int)CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount); + (unsigned int)CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount, + (unsigned int)CFE_ES_Global.ResetDataPtr->ResetVars.MaxProcessorResetCount); /* ** Update the reset variables */ - CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount++; - CFE_ES_ResetDataPtr->ResetVars.ES_CausedReset = true; + CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount++; + CFE_ES_Global.ResetDataPtr->ResetVars.ES_CausedReset = true; ResetType = CFE_PSP_RST_TYPE_PROCESSOR; } diff --git a/modules/es/fsw/src/cfe_es_global.h b/modules/es/fsw/src/cfe_es_global.h index bbe4ffb51..05369e76a 100644 --- a/modules/es/fsw/src/cfe_es_global.h +++ b/modules/es/fsw/src/cfe_es_global.h @@ -38,6 +38,7 @@ ** Includes */ #include "common_types.h" +#include "cfe_es_msg.h" #include "cfe_es_api_typedefs.h" #include "cfe_es_erlog_typedef.h" @@ -71,6 +72,61 @@ typedef struct uint32 NumJobsRunning; /**< Current Number of active jobs (updated by background task) */ } CFE_ES_BackgroundTaskState_t; +/* + * Background log dump state structure + * + * This structure is stored in global memory and keeps the state + * of the log dump from one iteration to the next. + * + * NOTE: This is used for log structures which are expected to be small + * enough so such that it is not necessary to throttle the file write or + * spread it over time. + * + * Therefore, the only thing necessary to be stored is whether there + * is a pending write request, and the data file name. + * + * Larger log files, such as the Perf log, must implement a state machine + * with a dedicated state data structure. + */ +typedef struct +{ + CFE_FS_FileWriteMetaData_t FileWrite; /**< FS state data - must be first */ + CFE_ES_ERLog_FileEntry_t EntryBuffer; /**< Temp holding area for record to write */ +} CFE_ES_BackgroundLogDumpGlobal_t; + +/* +** Type definition (ES task global data) +*/ +typedef struct +{ + /* + ** ES Task command interface counters + */ + uint8 CommandCounter; + uint8 CommandErrorCounter; + + /* + ** ES Task housekeeping telemetry + */ + CFE_ES_HousekeepingTlm_t HkPacket; + + /* + ** Single application telemetry + */ + CFE_ES_OneAppTlm_t OneAppPacket; + + /* + ** Memory statistics telemetry + */ + CFE_ES_MemStatsTlm_t MemStatsPacket; + + /* + ** ES Task operational data (not reported in housekeeping) + */ + CFE_SB_PipeId_t CmdPipe; + +} CFE_ES_TaskData_t; + /* ** Executive Services Global Memory Data ** This is the regular global data that is not preserved on a @@ -143,6 +199,31 @@ typedef struct CFE_ResourceId_t LastMemPoolId; CFE_ES_MemPoolRecord_t MemPoolTable[CFE_PLATFORM_ES_MAX_MEMORY_POOLS]; + /* + ** ES Task initialization data (not reported in housekeeping) + */ + CFE_ES_BackgroundLogDumpGlobal_t BackgroundERLogDumpState; + + /* + * Persistent state data associated with performance log data file writes + */ + CFE_ES_PerfDumpGlobal_t BackgroundPerfDumpState; + + /* + * Persistent state data associated with background app table scans + */ + CFE_ES_AppTableScanState_t BackgroundAppScanState; + + /* + * Task global data (formerly a separate global). + */ + CFE_ES_TaskData_t TaskData; + + /* + * Pointer to the Reset data that is preserved on a processor reset + */ + CFE_ES_ResetData_t *ResetDataPtr; + } CFE_ES_Global_t; /* @@ -150,11 +231,6 @@ typedef struct */ extern CFE_ES_Global_t CFE_ES_Global; -/* -** The Executive Services Nonvolatile Data declaration -*/ -extern CFE_ES_ResetData_t *CFE_ES_ResetDataPtr; - /* ** Functions used to lock/unlock shared data */ diff --git a/modules/es/fsw/src/cfe_es_perf.c b/modules/es/fsw/src/cfe_es_perf.c index 76935fa56..8b6c12b32 100644 --- a/modules/es/fsw/src/cfe_es_perf.c +++ b/modules/es/fsw/src/cfe_es_perf.c @@ -33,11 +33,6 @@ #include -/* -** Pointer to performance log in the reset area -*/ -CFE_ES_PerfData_t *Perf; - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Name: CFE_ES_SetupPerfVariables */ /* */ @@ -60,12 +55,13 @@ void CFE_ES_SetupPerfVariables(uint32 ResetType) uint8 Endian; } EndianCheck = {.Word = 0x0100}; - uint32 i; + uint32 i; + CFE_ES_PerfData_t *Perf; /* ** Set the pointer to the data area */ - Perf = (CFE_ES_PerfData_t *)&(CFE_ES_ResetDataPtr->Perf); + Perf = &CFE_ES_Global.ResetDataPtr->Perf; if (ResetType == CFE_PSP_RST_TYPE_PROCESSOR) { @@ -110,9 +106,15 @@ void CFE_ES_SetupPerfVariables(uint32 ResetType) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ uint32 CFE_ES_GetPerfLogDumpRemaining(void) { - CFE_ES_PerfDumpGlobal_t *PerfDumpState = &CFE_ES_TaskData.BackgroundPerfDumpState; + CFE_ES_PerfDumpGlobal_t *PerfDumpState = &CFE_ES_Global.BackgroundPerfDumpState; CFE_ES_PerfDumpState_t CurrentState = PerfDumpState->CurrentState; uint32 Result; + CFE_ES_PerfData_t * Perf; + + /* + ** Set the pointer to the data area + */ + Perf = &CFE_ES_Global.ResetDataPtr->Perf; /* note this reads the data "live" without exclusion and as such it * may change even between checking the state and checking the value. @@ -147,7 +149,13 @@ uint32 CFE_ES_GetPerfLogDumpRemaining(void) int32 CFE_ES_StartPerfDataCmd(const CFE_ES_StartPerfDataCmd_t *data) { const CFE_ES_StartPerfCmd_Payload_t *CmdPtr = &data->Payload; - CFE_ES_PerfDumpGlobal_t * PerfDumpState = &CFE_ES_TaskData.BackgroundPerfDumpState; + CFE_ES_PerfDumpGlobal_t * PerfDumpState = &CFE_ES_Global.BackgroundPerfDumpState; + CFE_ES_PerfData_t * Perf; + + /* + ** Set the pointer to the data area + */ + Perf = &CFE_ES_Global.ResetDataPtr->Perf; /* Ensure there is no file write in progress before proceeding */ if (PerfDumpState->CurrentState == CFE_ES_PerfDumpState_IDLE && @@ -158,7 +166,7 @@ int32 CFE_ES_StartPerfDataCmd(const CFE_ES_StartPerfDataCmd_t *data) if ((CmdPtr->TriggerMode >= CFE_ES_PERF_TRIGGER_START) && (CmdPtr->TriggerMode < CFE_ES_PERF_MAX_MODES)) { - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; /* Taking lock here as this might be changing states from one active mode to another. * In that case, need to make sure that the log is not written to while resetting the counters. */ @@ -178,7 +186,7 @@ int32 CFE_ES_StartPerfDataCmd(const CFE_ES_StartPerfDataCmd_t *data) } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_PERF_STARTCMD_TRIG_ERR_EID, CFE_EVS_EventType_ERROR, "Cannot start collecting performance data, trigger mode (%d) out of range (%d to %d)", (int)CmdPtr->TriggerMode, (int)CFE_ES_PERF_TRIGGER_START, (int)CFE_ES_PERF_TRIGGER_END); @@ -186,7 +194,7 @@ int32 CFE_ES_StartPerfDataCmd(const CFE_ES_StartPerfDataCmd_t *data) } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_PERF_STARTCMD_ERR_EID, CFE_EVS_EventType_ERROR, "Cannot start collecting performance data,perf data write in progress"); } /* end if */ @@ -202,7 +210,13 @@ int32 CFE_ES_StartPerfDataCmd(const CFE_ES_StartPerfDataCmd_t *data) int32 CFE_ES_StopPerfDataCmd(const CFE_ES_StopPerfDataCmd_t *data) { const CFE_ES_StopPerfCmd_Payload_t *CmdPtr = &data->Payload; - CFE_ES_PerfDumpGlobal_t * PerfDumpState = &CFE_ES_TaskData.BackgroundPerfDumpState; + CFE_ES_PerfDumpGlobal_t * PerfDumpState = &CFE_ES_Global.BackgroundPerfDumpState; + CFE_ES_PerfData_t * Perf; + + /* + ** Set the pointer to the data area + */ + Perf = &CFE_ES_Global.ResetDataPtr->Perf; /* Ensure there is no file write in progress before proceeding */ /* note - also need to check the PendingState here, in case this command @@ -220,7 +234,7 @@ int32 CFE_ES_StopPerfDataCmd(const CFE_ES_StopPerfDataCmd_t *data) PerfDumpState->PendingState = CFE_ES_PerfDumpState_INIT; CFE_ES_BackgroundWakeup(); - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_PERF_STOPCMD_EID, CFE_EVS_EventType_DEBUG, "Perf Stop Cmd Rcvd, will write %d entries.%dmS dly every %d entries", @@ -231,7 +245,7 @@ int32 CFE_ES_StopPerfDataCmd(const CFE_ES_StopPerfDataCmd_t *data) else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_PERF_STOPCMD_ERR2_EID, CFE_EVS_EventType_ERROR, "Stop performance data cmd ignored,perf data write in progress"); } /* end if */ @@ -258,6 +272,12 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) int32 Status; CFE_FS_Header_t FileHdr; size_t BlockSize; + CFE_ES_PerfData_t * Perf; + + /* + ** Set the pointer to the data area + */ + Perf = &CFE_ES_Global.ResetDataPtr->Perf; /* * each time this background job is re-entered after a time delay, @@ -472,6 +492,12 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) int32 CFE_ES_SetPerfFilterMaskCmd(const CFE_ES_SetPerfFilterMaskCmd_t *data) { const CFE_ES_SetPerfFilterMaskCmd_Payload_t *cmd = &data->Payload; + CFE_ES_PerfData_t * Perf; + + /* + ** Set the pointer to the data area + */ + Perf = &CFE_ES_Global.ResetDataPtr->Perf; if (cmd->FilterMaskNum < CFE_ES_PERF_32BIT_WORDS_IN_MASK) { @@ -482,7 +508,7 @@ int32 CFE_ES_SetPerfFilterMaskCmd(const CFE_ES_SetPerfFilterMaskCmd_t *data) "Set Performance Filter Mask Cmd rcvd, num %u, val 0x%08X", (unsigned int)cmd->FilterMaskNum, (unsigned int)cmd->FilterMask); - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; } else { @@ -490,7 +516,7 @@ int32 CFE_ES_SetPerfFilterMaskCmd(const CFE_ES_SetPerfFilterMaskCmd_t *data) "Performance Filter Mask Cmd Error,Index(%u)out of range(%u)", (unsigned int)cmd->FilterMaskNum, (unsigned int)CFE_ES_PERF_32BIT_WORDS_IN_MASK); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } return CFE_SUCCESS; @@ -504,6 +530,12 @@ int32 CFE_ES_SetPerfFilterMaskCmd(const CFE_ES_SetPerfFilterMaskCmd_t *data) int32 CFE_ES_SetPerfTriggerMaskCmd(const CFE_ES_SetPerfTriggerMaskCmd_t *data) { const CFE_ES_SetPerfTrigMaskCmd_Payload_t *cmd = &data->Payload; + CFE_ES_PerfData_t * Perf; + + /* + ** Set the pointer to the data area + */ + Perf = &CFE_ES_Global.ResetDataPtr->Perf; if (cmd->TriggerMaskNum < CFE_ES_PERF_32BIT_WORDS_IN_MASK) { @@ -514,7 +546,7 @@ int32 CFE_ES_SetPerfTriggerMaskCmd(const CFE_ES_SetPerfTriggerMaskCmd_t *data) "Set Performance Trigger Mask Cmd rcvd,num %u, val 0x%08X", (unsigned int)cmd->TriggerMaskNum, (unsigned int)cmd->TriggerMask); - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; } else { @@ -522,7 +554,7 @@ int32 CFE_ES_SetPerfTriggerMaskCmd(const CFE_ES_SetPerfTriggerMaskCmd_t *data) "Performance Trigger Mask Cmd Error,Index(%u)out of range(%u)", (unsigned int)cmd->TriggerMaskNum, (unsigned int)CFE_ES_PERF_32BIT_WORDS_IN_MASK); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } return CFE_SUCCESS; @@ -555,6 +587,12 @@ void CFE_ES_PerfLogAdd(uint32 Marker, uint32 EntryExit) { CFE_ES_PerfDataEntry_t EntryData; uint32 DataEnd; + CFE_ES_PerfData_t * Perf; + + /* + ** Set the pointer to the data area + */ + Perf = &CFE_ES_Global.ResetDataPtr->Perf; /* * If the global state is idle, exit immediately without locking or doing anything diff --git a/modules/es/fsw/src/cfe_es_start.c b/modules/es/fsw/src/cfe_es_start.c index c88b808d8..0d65c3db3 100644 --- a/modules/es/fsw/src/cfe_es_start.c +++ b/modules/es/fsw/src/cfe_es_start.c @@ -60,11 +60,6 @@ static int32 CFE_ES_MainTaskSyncDelay(uint32 AppStateId, uint32 TimeOutMilliseco */ CFE_ES_Global_t CFE_ES_Global; -/* -** Pointer to the Reset data that is preserved on a processor reset -*/ -CFE_ES_ResetData_t *CFE_ES_ResetDataPtr; - /***************************************************************************/ /* ** Code @@ -96,8 +91,9 @@ void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const cha ReturnCode = OS_MutSemCreate(&(CFE_ES_Global.SharedDataMutex), "ES_DATA_MUTEX", 0); if (ReturnCode != OS_SUCCESS) { - CFE_ES_SysLogWrite_Unsync("ES Startup: Error: ES Shared Data Mutex could not be created. RC=0x%08X\n", - (unsigned int)ReturnCode); + /* Cannot use SysLog here, since that requires the reset area to be set up */ + OS_printf("ES Startup: Error: ES Shared Data Mutex could not be created. RC=0x%08X\n", + (unsigned int)ReturnCode); /* ** Delay to allow the message to be read @@ -309,12 +305,12 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo return; } - CFE_ES_ResetDataPtr = (CFE_ES_ResetData_t *)ResetDataAddr; + CFE_ES_Global.ResetDataPtr = (CFE_ES_ResetData_t *)ResetDataAddr; /* ** Record the BootSource (bank) so it will be valid in the ER log entries. */ - CFE_ES_ResetDataPtr->ResetVars.BootSource = BootSource; + CFE_ES_Global.ResetDataPtr->ResetVars.BootSource = BootSource; /* ** Determine how the system was started. The choices are: @@ -331,8 +327,8 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo /* ** Record the reset type and subtype */ - CFE_ES_ResetDataPtr->ResetVars.ResetSubtype = StartSubtype; - CFE_ES_ResetDataPtr->ResetVars.ResetType = CFE_PSP_RST_TYPE_POWERON; + CFE_ES_Global.ResetDataPtr->ResetVars.ResetSubtype = StartSubtype; + CFE_ES_Global.ResetDataPtr->ResetVars.ResetType = CFE_PSP_RST_TYPE_POWERON; /* ** Log the power-on reset. @@ -359,9 +355,9 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo /* ** Initialize all reset counters. */ - CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount = 0; - CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount = CFE_PLATFORM_ES_MAX_PROCESSOR_RESETS; - CFE_ES_Global.DebugVars.DebugFlag = 0; + CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount = 0; + CFE_ES_Global.ResetDataPtr->ResetVars.MaxProcessorResetCount = CFE_PLATFORM_ES_MAX_PROCESSOR_RESETS; + CFE_ES_Global.DebugVars.DebugFlag = 0; } else if (StartType == CFE_PSP_RST_TYPE_PROCESSOR) { @@ -369,21 +365,21 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo ** If a Processor reset was not commanded, it must be a watchdog or other non-commanded reset ** Log the reset before updating any reset variables. */ - if (CFE_ES_ResetDataPtr->ResetVars.ES_CausedReset != true) + if (CFE_ES_Global.ResetDataPtr->ResetVars.ES_CausedReset != true) { - CFE_ES_ResetDataPtr->ResetVars.ResetType = CFE_PSP_RST_TYPE_PROCESSOR; - CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount++; + CFE_ES_Global.ResetDataPtr->ResetVars.ResetType = CFE_PSP_RST_TYPE_PROCESSOR; + CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount++; /* ** When coming up from a Processor reset that was not caused by ES, check to see ** if the maximum number has been exceeded */ - if (CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount > - CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount) + if (CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount > + CFE_ES_Global.ResetDataPtr->ResetVars.MaxProcessorResetCount) { if (StartSubtype == CFE_PSP_RST_SUBTYPE_HW_SPECIAL_COMMAND) { - CFE_ES_ResetDataPtr->ResetVars.ResetSubtype = CFE_PSP_RST_SUBTYPE_HW_SPECIAL_COMMAND; + CFE_ES_Global.ResetDataPtr->ResetVars.ResetSubtype = CFE_PSP_RST_SUBTYPE_HW_SPECIAL_COMMAND; CFE_ES_SysLogWrite_Unsync("POWER ON RESET due to max proc resets (HW Spec Cmd).\n"); /* @@ -395,7 +391,7 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo } else { - CFE_ES_ResetDataPtr->ResetVars.ResetSubtype = CFE_PSP_RST_SUBTYPE_HW_WATCHDOG; + CFE_ES_Global.ResetDataPtr->ResetVars.ResetSubtype = CFE_PSP_RST_SUBTYPE_HW_WATCHDOG; CFE_ES_SysLogWrite_Unsync("POWER ON RESET due to max proc resets (Watchdog).\n"); /* @@ -419,7 +415,7 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo { if (StartSubtype == CFE_PSP_RST_SUBTYPE_HW_SPECIAL_COMMAND) { - CFE_ES_ResetDataPtr->ResetVars.ResetSubtype = CFE_PSP_RST_SUBTYPE_HW_SPECIAL_COMMAND; + CFE_ES_Global.ResetDataPtr->ResetVars.ResetSubtype = CFE_PSP_RST_SUBTYPE_HW_SPECIAL_COMMAND; CFE_ES_SysLogWrite_Unsync("PROCESSOR RESET due to Hardware Special Command (HW Spec Cmd).\n"); /* @@ -430,7 +426,7 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo } else { - CFE_ES_ResetDataPtr->ResetVars.ResetSubtype = CFE_PSP_RST_SUBTYPE_HW_WATCHDOG; + CFE_ES_Global.ResetDataPtr->ResetVars.ResetSubtype = CFE_PSP_RST_SUBTYPE_HW_WATCHDOG; CFE_ES_SysLogWrite_Unsync("PROCESSOR RESET due to Watchdog (Watchdog).\n"); /* @@ -450,8 +446,8 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo */ else { - CFE_ES_ResetDataPtr->ResetVars.ResetType = CFE_PSP_RST_TYPE_PROCESSOR; - CFE_ES_ResetDataPtr->ResetVars.ResetSubtype = StartSubtype; + CFE_ES_Global.ResetDataPtr->ResetVars.ResetType = CFE_PSP_RST_TYPE_PROCESSOR; + CFE_ES_Global.ResetDataPtr->ResetVars.ResetSubtype = StartSubtype; } /* @@ -463,7 +459,7 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo /* ** Clear the commanded reset flag, in case a watchdog happens. */ - CFE_ES_ResetDataPtr->ResetVars.ES_CausedReset = false; + CFE_ES_Global.ResetDataPtr->ResetVars.ES_CausedReset = false; } /* diff --git a/modules/es/fsw/src/cfe_es_syslog.c b/modules/es/fsw/src/cfe_es_syslog.c index 3d203e9f2..7f0376872 100644 --- a/modules/es/fsw/src/cfe_es_syslog.c +++ b/modules/es/fsw/src/cfe_es_syslog.c @@ -84,9 +84,9 @@ void CFE_ES_SysLogClear_Unsync(void) * by simply zeroing out the indices will cover it. */ - CFE_ES_ResetDataPtr->SystemLogWriteIdx = 0; - CFE_ES_ResetDataPtr->SystemLogEndIdx = 0; - CFE_ES_ResetDataPtr->SystemLogEntryNum = 0; + CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx = 0; + CFE_ES_Global.ResetDataPtr->SystemLogEndIdx = 0; + CFE_ES_Global.ResetDataPtr->SystemLogEntryNum = 0; } /* End of CFE_ES_SysLogClear_Unsync() */ @@ -102,8 +102,8 @@ void CFE_ES_SysLogReadStart_Unsync(CFE_ES_SysLogReadBuffer_t *Buffer) size_t EndIdx; size_t TotalSize; - ReadIdx = CFE_ES_ResetDataPtr->SystemLogWriteIdx; - EndIdx = CFE_ES_ResetDataPtr->SystemLogEndIdx; + ReadIdx = CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx; + EndIdx = CFE_ES_Global.ResetDataPtr->SystemLogEndIdx; TotalSize = EndIdx; /* @@ -114,7 +114,7 @@ void CFE_ES_SysLogReadStart_Unsync(CFE_ES_SysLogReadBuffer_t *Buffer) { ++ReadIdx; --TotalSize; - if (CFE_ES_ResetDataPtr->SystemLog[ReadIdx - 1] == '\n') + if (CFE_ES_Global.ResetDataPtr->SystemLog[ReadIdx - 1] == '\n') { break; } @@ -173,10 +173,10 @@ int32 CFE_ES_SysLogAppend_Unsync(const char *LogString) * EndIdx -> indicates the entire size of the buffer * * Keeping them in local stack variables allows more efficient modification, - * since CFE_ES_ResetDataPtr may point directly into a slower NVRAM space. + * since CFE_ES_Global.ResetDataPtr may point directly into a slower NVRAM space. */ - WriteIdx = CFE_ES_ResetDataPtr->SystemLogWriteIdx; - EndIdx = CFE_ES_ResetDataPtr->SystemLogEndIdx; + WriteIdx = CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx; + EndIdx = CFE_ES_Global.ResetDataPtr->SystemLogEndIdx; /* * Check if the log message plus will fit between @@ -189,7 +189,7 @@ int32 CFE_ES_SysLogAppend_Unsync(const char *LogString) */ if ((WriteIdx + MessageLen) > CFE_PLATFORM_ES_SYSTEM_LOG_SIZE) { - if (CFE_ES_ResetDataPtr->SystemLogMode == CFE_ES_LogMode_OVERWRITE) + if (CFE_ES_Global.ResetDataPtr->SystemLogMode == CFE_ES_LogMode_OVERWRITE) { /* In "overwrite" mode, start back at the beginning of the buffer */ EndIdx = WriteIdx; @@ -219,7 +219,7 @@ int32 CFE_ES_SysLogAppend_Unsync(const char *LogString) /* * Copy the message in, EXCEPT for the last char which is probably a newline */ - memcpy(&CFE_ES_ResetDataPtr->SystemLog[WriteIdx], LogString, MessageLen - 1); + memcpy(&CFE_ES_Global.ResetDataPtr->SystemLog[WriteIdx], LogString, MessageLen - 1); WriteIdx += MessageLen; /* @@ -227,7 +227,7 @@ int32 CFE_ES_SysLogAppend_Unsync(const char *LogString) * This would have been enforced already except in cases where * the message got truncated. */ - CFE_ES_ResetDataPtr->SystemLog[WriteIdx - 1] = '\n'; + CFE_ES_Global.ResetDataPtr->SystemLog[WriteIdx - 1] = '\n'; /* * Keep track of the buffer endpoint for future reference @@ -240,9 +240,9 @@ int32 CFE_ES_SysLogAppend_Unsync(const char *LogString) /* * Export updated index values to the reset area for next time. */ - CFE_ES_ResetDataPtr->SystemLogWriteIdx = WriteIdx; - CFE_ES_ResetDataPtr->SystemLogEndIdx = EndIdx; - ++CFE_ES_ResetDataPtr->SystemLogEntryNum; + CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx = WriteIdx; + CFE_ES_Global.ResetDataPtr->SystemLogEndIdx = EndIdx; + ++CFE_ES_Global.ResetDataPtr->SystemLogEntryNum; } return (ReturnCode); @@ -323,7 +323,7 @@ void CFE_ES_SysLogReadData(CFE_ES_SysLogReadBuffer_t *Buffer) break; } - memcpy(&Buffer->Data[Buffer->BlockSize], &CFE_ES_ResetDataPtr->SystemLog[Buffer->LastOffset], BlockSize); + memcpy(&Buffer->Data[Buffer->BlockSize], &CFE_ES_Global.ResetDataPtr->SystemLog[Buffer->LastOffset], BlockSize); Buffer->BlockSize += BlockSize; Buffer->LastOffset += BlockSize; @@ -343,8 +343,8 @@ int32 CFE_ES_SysLogSetMode(CFE_ES_LogMode_Enum_t Mode) if ((Mode == CFE_ES_LogMode_OVERWRITE) || (Mode == CFE_ES_LogMode_DISCARD)) { - CFE_ES_ResetDataPtr->SystemLogMode = Mode; - Status = CFE_SUCCESS; + CFE_ES_Global.ResetDataPtr->SystemLogMode = Mode; + Status = CFE_SUCCESS; } else { @@ -544,7 +544,8 @@ int32 CFE_ES_SysLogDump(const char *Filename) else { CFE_EVS_SendEvent(CFE_ES_SYSLOG2_EID, CFE_EVS_EventType_DEBUG, "%s written:Size=%lu,Entries=%u", Filename, - (unsigned long)TotalSize, (unsigned int)CFE_ES_TaskData.HkPacket.Payload.SysLogEntries); + (unsigned long)TotalSize, + (unsigned int)CFE_ES_Global.TaskData.HkPacket.Payload.SysLogEntries); Status = CFE_SUCCESS; } diff --git a/modules/es/fsw/src/cfe_es_task.c b/modules/es/fsw/src/cfe_es_task.c index c559c6625..c21358f77 100644 --- a/modules/es/fsw/src/cfe_es_task.c +++ b/modules/es/fsw/src/cfe_es_task.c @@ -45,10 +45,13 @@ /* ** Defines */ -#define CFE_ES_PERF_TRIGGERMASK_INT_SIZE (sizeof(CFE_ES_ResetDataPtr->Perf.MetaData.TriggerMask) / sizeof(uint32)) -#define CFE_ES_PERF_TRIGGERMASK_EXT_SIZE (sizeof(CFE_ES_TaskData.HkPacket.Payload.PerfTriggerMask) / sizeof(uint32)) -#define CFE_ES_PERF_FILTERMASK_INT_SIZE (sizeof(CFE_ES_ResetDataPtr->Perf.MetaData.FilterMask) / sizeof(uint32)) -#define CFE_ES_PERF_FILTERMASK_EXT_SIZE (sizeof(CFE_ES_TaskData.HkPacket.Payload.PerfFilterMask) / sizeof(uint32)) +#define CFE_ES_PERF_TRIGGERMASK_INT_SIZE \ + (sizeof(CFE_ES_Global.ResetDataPtr->Perf.MetaData.TriggerMask) / sizeof(uint32)) +#define CFE_ES_PERF_TRIGGERMASK_EXT_SIZE \ + (sizeof(CFE_ES_Global.TaskData.HkPacket.Payload.PerfTriggerMask) / sizeof(uint32)) +#define CFE_ES_PERF_FILTERMASK_INT_SIZE (sizeof(CFE_ES_Global.ResetDataPtr->Perf.MetaData.FilterMask) / sizeof(uint32)) +#define CFE_ES_PERF_FILTERMASK_EXT_SIZE \ + (sizeof(CFE_ES_Global.TaskData.HkPacket.Payload.PerfFilterMask) / sizeof(uint32)) /* ** This define should be put in the OS API headers -- Right now it matches what the OS API uses @@ -124,7 +127,7 @@ void CFE_ES_TaskMain(void) /* ** Wait for the next Software Bus message. */ - Status = CFE_SB_ReceiveBuffer(&SBBufPtr, CFE_ES_TaskData.CmdPipe, CFE_SB_PEND_FOREVER); + Status = CFE_SB_ReceiveBuffer(&SBBufPtr, CFE_ES_Global.TaskData.CmdPipe, CFE_SB_PEND_FOREVER); /* ** Performance Time Stamp Entry @@ -352,19 +355,19 @@ int32 CFE_ES_TaskInit(void) /* ** Initialize task command execution counters */ - CFE_ES_TaskData.CommandCounter = 0; - CFE_ES_TaskData.CommandErrorCounter = 0; + CFE_ES_Global.TaskData.CommandCounter = 0; + CFE_ES_Global.TaskData.CommandErrorCounter = 0; /* ** Initialize systemlog to default Power On or Processor Reset mode */ if (CFE_ES_GetResetType(NULL) == CFE_PSP_RST_TYPE_POWERON) { - CFE_ES_ResetDataPtr->SystemLogMode = CFE_PLATFORM_ES_DEFAULT_POR_SYSLOG_MODE; + CFE_ES_Global.ResetDataPtr->SystemLogMode = CFE_PLATFORM_ES_DEFAULT_POR_SYSLOG_MODE; } else { - CFE_ES_ResetDataPtr->SystemLogMode = CFE_PLATFORM_ES_DEFAULT_PR_SYSLOG_MODE; + CFE_ES_Global.ResetDataPtr->SystemLogMode = CFE_PLATFORM_ES_DEFAULT_PR_SYSLOG_MODE; } /* @@ -380,25 +383,25 @@ int32 CFE_ES_TaskInit(void) /* ** Initialize housekeeping packet (clear user data area) */ - CFE_MSG_Init(&CFE_ES_TaskData.HkPacket.TlmHeader.Msg, CFE_SB_ValueToMsgId(CFE_ES_HK_TLM_MID), - sizeof(CFE_ES_TaskData.HkPacket)); + CFE_MSG_Init(&CFE_ES_Global.TaskData.HkPacket.TlmHeader.Msg, CFE_SB_ValueToMsgId(CFE_ES_HK_TLM_MID), + sizeof(CFE_ES_Global.TaskData.HkPacket)); /* ** Initialize single application telemetry packet */ - CFE_MSG_Init(&CFE_ES_TaskData.OneAppPacket.TlmHeader.Msg, CFE_SB_ValueToMsgId(CFE_ES_APP_TLM_MID), - sizeof(CFE_ES_TaskData.OneAppPacket)); + CFE_MSG_Init(&CFE_ES_Global.TaskData.OneAppPacket.TlmHeader.Msg, CFE_SB_ValueToMsgId(CFE_ES_APP_TLM_MID), + sizeof(CFE_ES_Global.TaskData.OneAppPacket)); /* ** Initialize memory pool statistics telemetry packet */ - CFE_MSG_Init(&CFE_ES_TaskData.MemStatsPacket.TlmHeader.Msg, CFE_SB_ValueToMsgId(CFE_ES_MEMSTATS_TLM_MID), - sizeof(CFE_ES_TaskData.MemStatsPacket)); + CFE_MSG_Init(&CFE_ES_Global.TaskData.MemStatsPacket.TlmHeader.Msg, CFE_SB_ValueToMsgId(CFE_ES_MEMSTATS_TLM_MID), + sizeof(CFE_ES_Global.TaskData.MemStatsPacket)); /* ** Create Software Bus message pipe */ - Status = CFE_SB_CreatePipe(&CFE_ES_TaskData.CmdPipe, CFE_ES_PIPE_DEPTH, CFE_ES_PIPE_NAME); + Status = CFE_SB_CreatePipe(&CFE_ES_Global.TaskData.CmdPipe, CFE_ES_PIPE_DEPTH, CFE_ES_PIPE_NAME); if (Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("ES:Cannot Create SB Pipe, RC = 0x%08X\n", (unsigned int)Status); @@ -408,7 +411,7 @@ int32 CFE_ES_TaskInit(void) /* ** Subscribe to Housekeeping request commands */ - Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_ES_SEND_HK_MID), CFE_ES_TaskData.CmdPipe); + Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_ES_SEND_HK_MID), CFE_ES_Global.TaskData.CmdPipe); if (Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("ES:Cannot Subscribe to HK packet, RC = 0x%08X\n", (unsigned int)Status); @@ -418,7 +421,7 @@ int32 CFE_ES_TaskInit(void) /* ** Subscribe to ES task ground command packets */ - Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_ES_CMD_MID), CFE_ES_TaskData.CmdPipe); + Status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CFE_ES_CMD_MID), CFE_ES_Global.TaskData.CmdPipe); if (Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("ES:Cannot Subscribe to ES ground commands, RC = 0x%08X\n", (unsigned int)Status); @@ -433,25 +436,25 @@ int32 CFE_ES_TaskInit(void) if (Status == CFE_PSP_SUCCESS) { - CFE_ES_TaskData.HkPacket.Payload.CFECoreChecksum = + CFE_ES_Global.TaskData.HkPacket.Payload.CFECoreChecksum = CFE_ES_CalculateCRC((void *)(CfeSegmentAddr), SizeofCfeSegment, 0, CFE_MISSION_ES_DEFAULT_CRC); } else { - CFE_ES_TaskData.HkPacket.Payload.CFECoreChecksum = 0xFFFF; + CFE_ES_Global.TaskData.HkPacket.Payload.CFECoreChecksum = 0xFFFF; } /* ** Initialize the version numbers in the ES Housekeeping pkt */ - CFE_ES_TaskData.HkPacket.Payload.CFEMajorVersion = CFE_MAJOR_VERSION; - CFE_ES_TaskData.HkPacket.Payload.CFEMinorVersion = CFE_MINOR_VERSION; - CFE_ES_TaskData.HkPacket.Payload.CFERevision = CFE_REVISION; - CFE_ES_TaskData.HkPacket.Payload.CFEMissionRevision = CFE_MISSION_REV; - CFE_ES_TaskData.HkPacket.Payload.OSALMajorVersion = OS_MAJOR_VERSION; - CFE_ES_TaskData.HkPacket.Payload.OSALMinorVersion = OS_MINOR_VERSION; - CFE_ES_TaskData.HkPacket.Payload.OSALRevision = OS_REVISION; - CFE_ES_TaskData.HkPacket.Payload.OSALMissionRevision = OS_MISSION_REV; + CFE_ES_Global.TaskData.HkPacket.Payload.CFEMajorVersion = CFE_MAJOR_VERSION; + CFE_ES_Global.TaskData.HkPacket.Payload.CFEMinorVersion = CFE_MINOR_VERSION; + CFE_ES_Global.TaskData.HkPacket.Payload.CFERevision = CFE_REVISION; + CFE_ES_Global.TaskData.HkPacket.Payload.CFEMissionRevision = CFE_MISSION_REV; + CFE_ES_Global.TaskData.HkPacket.Payload.OSALMajorVersion = OS_MAJOR_VERSION; + CFE_ES_Global.TaskData.HkPacket.Payload.OSALMinorVersion = OS_MINOR_VERSION; + CFE_ES_Global.TaskData.HkPacket.Payload.OSALRevision = OS_REVISION; + CFE_ES_Global.TaskData.HkPacket.Payload.OSALMissionRevision = OS_MISSION_REV; /* ** Task startup event message. @@ -466,7 +469,7 @@ int32 CFE_ES_TaskInit(void) Status = CFE_EVS_SendEvent(CFE_ES_INITSTATS_INF_EID, CFE_EVS_EventType_INFORMATION, "cFS Versions: cfe %s, osal %s, psp %s. cFE chksm %d", GLOBAL_CONFIGDATA.CfeVersion, GLOBAL_CONFIGDATA.OsalVersion, CFE_PSP_VERSION, - (int)CFE_ES_TaskData.HkPacket.Payload.CFECoreChecksum); + (int)CFE_ES_Global.TaskData.HkPacket.Payload.CFECoreChecksum); if (Status != CFE_SUCCESS) { @@ -697,7 +700,7 @@ void CFE_ES_TaskPipe(CFE_SB_Buffer_t *SBBufPtr) CFE_EVS_SendEvent(CFE_ES_CC1_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid ground command code: ID = 0x%X, CC = %d", (unsigned int)CFE_SB_MsgIdToValue(MessageID), (int)CommandCode); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; break; } break; @@ -706,7 +709,7 @@ void CFE_ES_TaskPipe(CFE_SB_Buffer_t *SBBufPtr) CFE_EVS_SendEvent(CFE_ES_MID_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid command pipe message ID: 0x%X", (unsigned int)CFE_SB_MsgIdToValue(MessageID)); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; break; } @@ -727,35 +730,37 @@ int32 CFE_ES_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) /* ** Get command execution counters, system log entry count & bytes used. */ - CFE_ES_TaskData.HkPacket.Payload.CommandCounter = CFE_ES_TaskData.CommandCounter; - CFE_ES_TaskData.HkPacket.Payload.CommandErrorCounter = CFE_ES_TaskData.CommandErrorCounter; - - CFE_ES_TaskData.HkPacket.Payload.SysLogBytesUsed = CFE_ES_MEMOFFSET_C(CFE_ES_ResetDataPtr->SystemLogEndIdx); - CFE_ES_TaskData.HkPacket.Payload.SysLogSize = CFE_ES_MEMOFFSET_C(CFE_PLATFORM_ES_SYSTEM_LOG_SIZE); - CFE_ES_TaskData.HkPacket.Payload.SysLogEntries = CFE_ES_ResetDataPtr->SystemLogEntryNum; - CFE_ES_TaskData.HkPacket.Payload.SysLogMode = CFE_ES_ResetDataPtr->SystemLogMode; - - CFE_ES_TaskData.HkPacket.Payload.ERLogIndex = CFE_ES_ResetDataPtr->ERLogIndex; - CFE_ES_TaskData.HkPacket.Payload.ERLogEntries = CFE_ES_ResetDataPtr->ERLogEntries; - - CFE_ES_TaskData.HkPacket.Payload.RegisteredCoreApps = CFE_ES_Global.RegisteredCoreApps; - CFE_ES_TaskData.HkPacket.Payload.RegisteredExternalApps = CFE_ES_Global.RegisteredExternalApps; - CFE_ES_TaskData.HkPacket.Payload.RegisteredTasks = CFE_ES_Global.RegisteredTasks; - CFE_ES_TaskData.HkPacket.Payload.RegisteredLibs = CFE_ES_Global.RegisteredLibs; - - CFE_ES_TaskData.HkPacket.Payload.ResetType = CFE_ES_ResetDataPtr->ResetVars.ResetType; - CFE_ES_TaskData.HkPacket.Payload.ResetSubtype = CFE_ES_ResetDataPtr->ResetVars.ResetSubtype; - CFE_ES_TaskData.HkPacket.Payload.ProcessorResets = CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount; - CFE_ES_TaskData.HkPacket.Payload.MaxProcessorResets = CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount; - CFE_ES_TaskData.HkPacket.Payload.BootSource = CFE_ES_ResetDataPtr->ResetVars.BootSource; - - CFE_ES_TaskData.HkPacket.Payload.PerfState = CFE_ES_ResetDataPtr->Perf.MetaData.State; - CFE_ES_TaskData.HkPacket.Payload.PerfMode = CFE_ES_ResetDataPtr->Perf.MetaData.Mode; - CFE_ES_TaskData.HkPacket.Payload.PerfTriggerCount = CFE_ES_ResetDataPtr->Perf.MetaData.TriggerCount; - CFE_ES_TaskData.HkPacket.Payload.PerfDataStart = CFE_ES_ResetDataPtr->Perf.MetaData.DataStart; - CFE_ES_TaskData.HkPacket.Payload.PerfDataEnd = CFE_ES_ResetDataPtr->Perf.MetaData.DataEnd; - CFE_ES_TaskData.HkPacket.Payload.PerfDataCount = CFE_ES_ResetDataPtr->Perf.MetaData.DataCount; - CFE_ES_TaskData.HkPacket.Payload.PerfDataToWrite = CFE_ES_GetPerfLogDumpRemaining(); + CFE_ES_Global.TaskData.HkPacket.Payload.CommandCounter = CFE_ES_Global.TaskData.CommandCounter; + CFE_ES_Global.TaskData.HkPacket.Payload.CommandErrorCounter = CFE_ES_Global.TaskData.CommandErrorCounter; + + CFE_ES_Global.TaskData.HkPacket.Payload.SysLogBytesUsed = + CFE_ES_MEMOFFSET_C(CFE_ES_Global.ResetDataPtr->SystemLogEndIdx); + CFE_ES_Global.TaskData.HkPacket.Payload.SysLogSize = CFE_ES_MEMOFFSET_C(CFE_PLATFORM_ES_SYSTEM_LOG_SIZE); + CFE_ES_Global.TaskData.HkPacket.Payload.SysLogEntries = CFE_ES_Global.ResetDataPtr->SystemLogEntryNum; + CFE_ES_Global.TaskData.HkPacket.Payload.SysLogMode = CFE_ES_Global.ResetDataPtr->SystemLogMode; + + CFE_ES_Global.TaskData.HkPacket.Payload.ERLogIndex = CFE_ES_Global.ResetDataPtr->ERLogIndex; + CFE_ES_Global.TaskData.HkPacket.Payload.ERLogEntries = CFE_ES_Global.ResetDataPtr->ERLogEntries; + + CFE_ES_Global.TaskData.HkPacket.Payload.RegisteredCoreApps = CFE_ES_Global.RegisteredCoreApps; + CFE_ES_Global.TaskData.HkPacket.Payload.RegisteredExternalApps = CFE_ES_Global.RegisteredExternalApps; + CFE_ES_Global.TaskData.HkPacket.Payload.RegisteredTasks = CFE_ES_Global.RegisteredTasks; + CFE_ES_Global.TaskData.HkPacket.Payload.RegisteredLibs = CFE_ES_Global.RegisteredLibs; + + CFE_ES_Global.TaskData.HkPacket.Payload.ResetType = CFE_ES_Global.ResetDataPtr->ResetVars.ResetType; + CFE_ES_Global.TaskData.HkPacket.Payload.ResetSubtype = CFE_ES_Global.ResetDataPtr->ResetVars.ResetSubtype; + CFE_ES_Global.TaskData.HkPacket.Payload.ProcessorResets = CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount; + CFE_ES_Global.TaskData.HkPacket.Payload.MaxProcessorResets = + CFE_ES_Global.ResetDataPtr->ResetVars.MaxProcessorResetCount; + CFE_ES_Global.TaskData.HkPacket.Payload.BootSource = CFE_ES_Global.ResetDataPtr->ResetVars.BootSource; + + CFE_ES_Global.TaskData.HkPacket.Payload.PerfState = CFE_ES_Global.ResetDataPtr->Perf.MetaData.State; + CFE_ES_Global.TaskData.HkPacket.Payload.PerfMode = CFE_ES_Global.ResetDataPtr->Perf.MetaData.Mode; + CFE_ES_Global.TaskData.HkPacket.Payload.PerfTriggerCount = CFE_ES_Global.ResetDataPtr->Perf.MetaData.TriggerCount; + CFE_ES_Global.TaskData.HkPacket.Payload.PerfDataStart = CFE_ES_Global.ResetDataPtr->Perf.MetaData.DataStart; + CFE_ES_Global.TaskData.HkPacket.Payload.PerfDataEnd = CFE_ES_Global.ResetDataPtr->Perf.MetaData.DataEnd; + CFE_ES_Global.TaskData.HkPacket.Payload.PerfDataCount = CFE_ES_Global.ResetDataPtr->Perf.MetaData.DataCount; + CFE_ES_Global.TaskData.HkPacket.Payload.PerfDataToWrite = CFE_ES_GetPerfLogDumpRemaining(); /* * Fill out the perf trigger/filter mask objects @@ -771,12 +776,12 @@ int32 CFE_ES_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) { if (PerfIdx < CFE_ES_PERF_TRIGGERMASK_INT_SIZE) { - CFE_ES_TaskData.HkPacket.Payload.PerfTriggerMask[PerfIdx] = - CFE_ES_ResetDataPtr->Perf.MetaData.TriggerMask[PerfIdx]; + CFE_ES_Global.TaskData.HkPacket.Payload.PerfTriggerMask[PerfIdx] = + CFE_ES_Global.ResetDataPtr->Perf.MetaData.TriggerMask[PerfIdx]; } else { - CFE_ES_TaskData.HkPacket.Payload.PerfTriggerMask[PerfIdx] = 0; + CFE_ES_Global.TaskData.HkPacket.Payload.PerfTriggerMask[PerfIdx] = 0; } } @@ -784,12 +789,12 @@ int32 CFE_ES_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) { if (PerfIdx < CFE_ES_PERF_FILTERMASK_INT_SIZE) { - CFE_ES_TaskData.HkPacket.Payload.PerfFilterMask[PerfIdx] = - CFE_ES_ResetDataPtr->Perf.MetaData.FilterMask[PerfIdx]; + CFE_ES_Global.TaskData.HkPacket.Payload.PerfFilterMask[PerfIdx] = + CFE_ES_Global.ResetDataPtr->Perf.MetaData.FilterMask[PerfIdx]; } else { - CFE_ES_TaskData.HkPacket.Payload.PerfFilterMask[PerfIdx] = 0; + CFE_ES_Global.TaskData.HkPacket.Payload.PerfFilterMask[PerfIdx] = 0; } } @@ -805,15 +810,15 @@ int32 CFE_ES_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) memset(&HeapProp, 0, sizeof(HeapProp)); } - CFE_ES_TaskData.HkPacket.Payload.HeapBytesFree = CFE_ES_MEMOFFSET_C(HeapProp.free_bytes); - CFE_ES_TaskData.HkPacket.Payload.HeapBlocksFree = CFE_ES_MEMOFFSET_C(HeapProp.free_blocks); - CFE_ES_TaskData.HkPacket.Payload.HeapMaxBlockSize = CFE_ES_MEMOFFSET_C(HeapProp.largest_free_block); + CFE_ES_Global.TaskData.HkPacket.Payload.HeapBytesFree = CFE_ES_MEMOFFSET_C(HeapProp.free_bytes); + CFE_ES_Global.TaskData.HkPacket.Payload.HeapBlocksFree = CFE_ES_MEMOFFSET_C(HeapProp.free_blocks); + CFE_ES_Global.TaskData.HkPacket.Payload.HeapMaxBlockSize = CFE_ES_MEMOFFSET_C(HeapProp.largest_free_block); /* ** Send housekeeping telemetry packet. */ - CFE_SB_TimeStampMsg(&CFE_ES_TaskData.HkPacket.TlmHeader.Msg); - CFE_SB_TransmitMsg(&CFE_ES_TaskData.HkPacket.TlmHeader.Msg, true); + CFE_SB_TimeStampMsg(&CFE_ES_Global.TaskData.HkPacket.TlmHeader.Msg); + CFE_SB_TransmitMsg(&CFE_ES_Global.TaskData.HkPacket.TlmHeader.Msg, true); /* ** This command does not affect the command execution counter. @@ -840,7 +845,7 @@ int32 CFE_ES_NoopCmd(const CFE_ES_NoopCmd_t *Cmd) /* ** This command will always succeed. */ - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command:\n cFS Versions: cfe %s, osal %s, psp %s", GLOBAL_CONFIGDATA.CfeVersion, @@ -857,8 +862,8 @@ int32 CFE_ES_NoopCmd(const CFE_ES_NoopCmd_t *Cmd) int32 CFE_ES_ResetCountersCmd(const CFE_ES_ResetCountersCmd_t *data) { - CFE_ES_TaskData.CommandCounter = 0; - CFE_ES_TaskData.CommandErrorCounter = 0; + CFE_ES_Global.TaskData.CommandCounter = 0; + CFE_ES_Global.TaskData.CommandErrorCounter = 0; /* ** This command will always succeed. @@ -880,7 +885,7 @@ int32 CFE_ES_RestartCmd(const CFE_ES_RestartCmd_t *data) if ((cmd->RestartType != CFE_PSP_RST_TYPE_PROCESSOR) && (cmd->RestartType != CFE_PSP_RST_TYPE_POWERON)) { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_BOOT_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid cFE restart type: %d", (int)cmd->RestartType); } @@ -927,32 +932,32 @@ int32 CFE_ES_StartAppCmd(const CFE_ES_StartAppCmd_t *data) */ if (FilenameLen < 4) { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_START_INVALID_FILENAME_ERR_EID, CFE_EVS_EventType_ERROR, "CFE_ES_StartAppCmd: invalid filename: %s", StartParams.BasicInfo.FileName); } else if (AppEntryLen <= 0) { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_START_INVALID_ENTRY_POINT_ERR_EID, CFE_EVS_EventType_ERROR, "CFE_ES_StartAppCmd: App Entry Point is empty."); } else if (AppNameLen <= 0) { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_START_NULL_APP_NAME_ERR_EID, CFE_EVS_EventType_ERROR, "CFE_ES_StartAppCmd: App Name is empty."); } else if (cmd->Priority > OS_MAX_PRIORITY) { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_START_PRIORITY_ERR_EID, CFE_EVS_EventType_ERROR, "CFE_ES_StartAppCmd: Priority is too large: %d.", (int)cmd->Priority); } else if ((cmd->ExceptionAction != CFE_ES_ExceptionAction_RESTART_APP) && (cmd->ExceptionAction != CFE_ES_ExceptionAction_PROC_RESTART)) { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_START_EXC_ACTION_ERR_EID, CFE_EVS_EventType_ERROR, "CFE_ES_StartAppCmd: Invalid Exception Action: %d.", (int)cmd->ExceptionAction); } @@ -981,13 +986,13 @@ int32 CFE_ES_StartAppCmd(const CFE_ES_StartAppCmd_t *data) */ if (Result == CFE_SUCCESS) { - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_START_INF_EID, CFE_EVS_EventType_INFORMATION, "Started %s from %s, AppID = %lu", LocalAppName, StartParams.BasicInfo.FileName, CFE_RESOURCEID_TO_ULONG(AppID)); } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_START_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to start %s from %s, RC = 0x%08X", LocalAppName, StartParams.BasicInfo.FileName, (unsigned int)Result); } @@ -1026,19 +1031,19 @@ int32 CFE_ES_StopAppCmd(const CFE_ES_StopAppCmd_t *data) */ if (Result == CFE_SUCCESS) { - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_STOP_DBG_EID, CFE_EVS_EventType_DEBUG, "Stop Application %s Initiated.", LocalApp); } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_STOP_ERR1_EID, CFE_EVS_EventType_ERROR, "Stop Application %s Failed, RC = 0x%08X", LocalApp, (unsigned int)Result); } } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_STOP_ERR2_EID, CFE_EVS_EventType_ERROR, "Stop Application %s, GetAppIDByName failed. RC = 0x%08X.", LocalApp, (unsigned int)Result); } @@ -1072,20 +1077,20 @@ int32 CFE_ES_RestartAppCmd(const CFE_ES_RestartAppCmd_t *data) */ if (Result == CFE_SUCCESS) { - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_RESTART_APP_DBG_EID, CFE_EVS_EventType_DEBUG, "Restart Application %s Initiated.", LocalApp); } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_RESTART_APP_ERR1_EID, CFE_EVS_EventType_ERROR, "Restart Application %s Failed, RC = 0x%08X", LocalApp, (unsigned int)Result); } } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_RESTART_APP_ERR2_EID, CFE_EVS_EventType_ERROR, "Restart Application %s, GetAppIDByName failed. RC = 0x%08X.", LocalApp, (unsigned int)Result); @@ -1123,20 +1128,20 @@ int32 CFE_ES_ReloadAppCmd(const CFE_ES_ReloadAppCmd_t *data) */ if (Result == CFE_SUCCESS) { - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_RELOAD_APP_DBG_EID, CFE_EVS_EventType_DEBUG, "Reload Application %s Initiated.", LocalApp); } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_RELOAD_APP_ERR1_EID, CFE_EVS_EventType_ERROR, "Reload Application %s Failed, RC = 0x%08X", LocalApp, (unsigned int)Result); } } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_RELOAD_APP_ERR2_EID, CFE_EVS_EventType_ERROR, "Reload Application %s, GetAppIDByName failed. RC = 0x%08X.", LocalApp, (unsigned int)Result); } @@ -1173,7 +1178,7 @@ int32 CFE_ES_QueryOneCmd(const CFE_ES_QueryOneCmd_t *data) if (Result == CFE_SUCCESS) { - Result = CFE_ES_GetModuleInfo(&(CFE_ES_TaskData.OneAppPacket.Payload.AppInfo), IdBuf.ResourceID); + Result = CFE_ES_GetModuleInfo(&(CFE_ES_Global.TaskData.OneAppPacket.Payload.AppInfo), IdBuf.ResourceID); } /* @@ -1184,23 +1189,23 @@ int32 CFE_ES_QueryOneCmd(const CFE_ES_QueryOneCmd_t *data) /* ** Send application status telemetry packet. */ - CFE_SB_TimeStampMsg(&CFE_ES_TaskData.OneAppPacket.TlmHeader.Msg); - Result = CFE_SB_TransmitMsg(&CFE_ES_TaskData.OneAppPacket.TlmHeader.Msg, true); + CFE_SB_TimeStampMsg(&CFE_ES_Global.TaskData.OneAppPacket.TlmHeader.Msg); + Result = CFE_SB_TransmitMsg(&CFE_ES_Global.TaskData.OneAppPacket.TlmHeader.Msg, true); if (Result == CFE_SUCCESS) { - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_ONE_APP_EID, CFE_EVS_EventType_DEBUG, "Sent %s application data", LocalApp); } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_ONE_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to send %s application data, RC = 0x%08X", LocalApp, (unsigned int)Result); } } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_ONE_APPID_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to send %s application data: GetAppIDByName Failed, RC = 0x%08X", LocalApp, (unsigned int)Result); @@ -1297,7 +1302,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) if (Result != sizeof(CFE_FS_Header_t)) { OS_close(FileDescriptor); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_WRHDR_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to write App Info file, WriteHdr RC = 0x%08X, exp %d", (unsigned int)Result, (int)sizeof(CFE_FS_Header_t)); @@ -1331,7 +1336,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) if (Result != sizeof(CFE_ES_AppInfo_t)) { OS_close(FileDescriptor); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_TASKWR_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to write App Info file, Task write RC = 0x%08X, exp %d", (unsigned int)Result, (int)sizeof(CFE_ES_AppInfo_t)); @@ -1349,14 +1354,14 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) } /* end for */ OS_close(FileDescriptor); - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_ALL_APPS_EID, CFE_EVS_EventType_DEBUG, "App Info file written to %s, Entries=%d, FileSize=%d", QueryAllFilename, (int)EntryCount, (int)FileSize); } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to write App Info file, OS_OpenCreate RC = 0x%08X", (unsigned int)Result); } @@ -1441,7 +1446,7 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) if (Result != sizeof(CFE_FS_Header_t)) { OS_close(FileDescriptor); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_TASKINFO_WRHDR_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to write Task Info file, WriteHdr RC = 0x%08X, exp %d", (unsigned int)Result, (int)sizeof(CFE_FS_Header_t)); @@ -1475,7 +1480,7 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) if (Result != sizeof(CFE_ES_TaskInfo_t)) { OS_close(FileDescriptor); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_TASKINFO_WR_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to write Task Info file, Task write RC = 0x%08X, exp %d", (unsigned int)Result, (int)sizeof(CFE_ES_TaskInfo_t)); @@ -1493,14 +1498,14 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) } /* end for */ OS_close(FileDescriptor); - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_TASKINFO_EID, CFE_EVS_EventType_DEBUG, "Task Info file written to %s, Entries=%d, FileSize=%d", QueryAllFilename, (int)EntryCount, (int)FileSize); } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_TASKINFO_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to write Task Info file, OS_OpenCreate RC = 0x%08X", (unsigned int)Result); } @@ -1527,7 +1532,7 @@ int32 CFE_ES_ClearSysLogCmd(const CFE_ES_ClearSysLogCmd_t *data) /* ** This command will always succeed... */ - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_SYSLOG1_INF_EID, CFE_EVS_EventType_INFORMATION, "Cleared Executive Services log data"); return CFE_SUCCESS; @@ -1551,14 +1556,14 @@ int32 CFE_ES_OverWriteSysLogCmd(const CFE_ES_OverWriteSysLogCmd_t *data) CFE_EVS_SendEvent(CFE_ES_ERR_SYSLOGMODE_EID, CFE_EVS_EventType_ERROR, "Set OverWriteSysLog Command: Invalid Mode setting = %d", (int)CmdPtr->Mode); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } else { CFE_EVS_SendEvent(CFE_ES_SYSLOGMODE_EID, CFE_EVS_EventType_DEBUG, "Set OverWriteSysLog Command Received with Mode setting = %d", (int)CmdPtr->Mode); - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; } return CFE_SUCCESS; @@ -1583,11 +1588,11 @@ int32 CFE_ES_WriteSysLogCmd(const CFE_ES_WriteSysLogCmd_t *data) if (Stat == CFE_SUCCESS) { - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } /* end if */ return CFE_SUCCESS; @@ -1605,23 +1610,23 @@ int32 CFE_ES_ClearERLogCmd(const CFE_ES_ClearERLogCmd_t *data) ** Clear ER log data buffer */ - memset(CFE_ES_ResetDataPtr->ERLog, 0, sizeof(CFE_ES_ResetDataPtr->ERLog)); + memset(CFE_ES_Global.ResetDataPtr->ERLog, 0, sizeof(CFE_ES_Global.ResetDataPtr->ERLog)); /* ** Reset ER log buffer index */ - CFE_ES_ResetDataPtr->ERLogIndex = 0; + CFE_ES_Global.ResetDataPtr->ERLogIndex = 0; /* ** Set Number of Entries in ER log buffer back to zero */ - CFE_ES_ResetDataPtr->ERLogEntries = 0; + CFE_ES_Global.ResetDataPtr->ERLogEntries = 0; /* ** This command will always succeed */ - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_ERLOG1_INF_EID, CFE_EVS_EventType_INFORMATION, "Cleared ES Exception and Reset Log data"); return CFE_SUCCESS; @@ -1639,7 +1644,7 @@ int32 CFE_ES_WriteERLogCmd(const CFE_ES_WriteERLogCmd_t *data) CFE_ES_BackgroundLogDumpGlobal_t * StatePtr; int32 Status; - StatePtr = &CFE_ES_TaskData.BackgroundERLogDumpState; + StatePtr = &CFE_ES_Global.BackgroundERLogDumpState; /* check if pending before overwriting fields in the structure */ if (CFE_FS_BackgroundFileDumpIsPending(&StatePtr->FileWrite)) @@ -1673,11 +1678,11 @@ int32 CFE_ES_WriteERLogCmd(const CFE_ES_WriteERLogCmd_t *data) "Error log write to file %s already in progress", StatePtr->FileWrite.FileName); /* background dump already running, consider this an error */ - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } else { - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; } return CFE_SUCCESS; @@ -1711,7 +1716,7 @@ bool CFE_ES_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, (unsigned int)ExpectedLength); result = false; - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } return (result); @@ -1730,14 +1735,14 @@ int32 CFE_ES_ResetPRCountCmd(const CFE_ES_ResetPRCountCmd_t *data) /* ** Reset the processor reset count */ - CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount = 0; + CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount = 0; /* ** This command will always succeed. */ CFE_EVS_SendEvent(CFE_ES_RESET_PR_COUNT_EID, CFE_EVS_EventType_INFORMATION, "Set Processor Reset Count to Zero"); - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; return CFE_SUCCESS; } /* End of CFE_ES_ResetPRCountCmd() */ @@ -1755,7 +1760,7 @@ int32 CFE_ES_SetMaxPRCountCmd(const CFE_ES_SetMaxPRCountCmd_t *data) /* ** Set the MAX Processor reset count */ - CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount = cmd->MaxPRCount; + CFE_ES_Global.ResetDataPtr->ResetVars.MaxProcessorResetCount = cmd->MaxPRCount; /* ** This command will always succeed. @@ -1763,7 +1768,7 @@ int32 CFE_ES_SetMaxPRCountCmd(const CFE_ES_SetMaxPRCountCmd_t *data) CFE_EVS_SendEvent(CFE_ES_SET_MAX_PR_COUNT_EID, CFE_EVS_EventType_INFORMATION, "Maximum Processor Reset Count set to: %d", (int)cmd->MaxPRCount); - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; return CFE_SUCCESS; } /* End of CFE_ES_RestartCmd() */ @@ -1789,21 +1794,21 @@ int32 CFE_ES_DeleteCDSCmd(const CFE_ES_DeleteCDSCmd_t *data) CFE_EVS_SendEvent(CFE_ES_CDS_DELETE_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "CDS '%s' is a Critical Table CDS. Must be deleted via TBL Command", LocalCdsName); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } else if (Status == CFE_ES_CDS_OWNER_ACTIVE_ERR) { CFE_EVS_SendEvent(CFE_ES_CDS_OWNER_ACTIVE_EID, CFE_EVS_EventType_ERROR, "CDS '%s' not deleted because owning app is active", LocalCdsName); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } else if (Status == CFE_ES_ERR_NAME_NOT_FOUND) { CFE_EVS_SendEvent(CFE_ES_CDS_NAME_ERR_EID, CFE_EVS_EventType_ERROR, "Unable to locate '%s' in CDS Registry", LocalCdsName); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } else if (Status != CFE_SUCCESS) { @@ -1811,14 +1816,14 @@ int32 CFE_ES_DeleteCDSCmd(const CFE_ES_DeleteCDSCmd_t *data) "Error while deleting '%s' from CDS, See SysLog.(Err=0x%08X)", LocalCdsName, (unsigned int)Status); - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } else { CFE_EVS_SendEvent(CFE_ES_CDS_DELETED_INFO_EID, CFE_EVS_EventType_INFORMATION, "Successfully removed '%s' from CDS", LocalCdsName); - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; } return CFE_SUCCESS; @@ -1848,25 +1853,25 @@ int32 CFE_ES_SendMemPoolStatsCmd(const CFE_ES_SendMemPoolStatsCmd_t *data) if (ValidHandle) { /* Extract the memory statistics from the memory pool */ - CFE_ES_GetMemPoolStats(&CFE_ES_TaskData.MemStatsPacket.Payload.PoolStats, MemHandle); + CFE_ES_GetMemPoolStats(&CFE_ES_Global.TaskData.MemStatsPacket.Payload.PoolStats, MemHandle); /* Echo the specified pool handle in the telemetry packet */ - CFE_ES_TaskData.MemStatsPacket.Payload.PoolHandle = MemHandle; + CFE_ES_Global.TaskData.MemStatsPacket.Payload.PoolHandle = MemHandle; /* ** Send memory statistics telemetry packet. */ - CFE_SB_TimeStampMsg(&CFE_ES_TaskData.MemStatsPacket.TlmHeader.Msg); - CFE_SB_TransmitMsg(&CFE_ES_TaskData.MemStatsPacket.TlmHeader.Msg, true); + CFE_SB_TimeStampMsg(&CFE_ES_Global.TaskData.MemStatsPacket.TlmHeader.Msg); + CFE_SB_TransmitMsg(&CFE_ES_Global.TaskData.MemStatsPacket.TlmHeader.Msg, true); - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_ES_TLM_POOL_STATS_INFO_EID, CFE_EVS_EventType_DEBUG, "Successfully telemetered memory pool stats for 0x%08lX", CFE_RESOURCEID_TO_ULONG(Cmd->PoolHandle)); } else { - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_INVALID_POOL_HANDLE_ERR_EID, CFE_EVS_EventType_ERROR, "Cannot telemeter memory pool stats. Illegal Handle (0x%08lX)", CFE_RESOURCEID_TO_ULONG(Cmd->PoolHandle)); @@ -1947,7 +1952,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) (int)FileSize, (int)NumEntries); /* Increment Successful Command Counter */ - CFE_ES_TaskData.CommandCounter++; + CFE_ES_Global.TaskData.CommandCounter++; } else { @@ -1956,7 +1961,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) (unsigned int)Status); /* Increment Command Error Counter */ - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } } else @@ -1966,7 +1971,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) (unsigned int)Status); /* Increment Command Error Counter */ - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } /* We are done outputting data to the dump file. Close it. */ @@ -1978,7 +1983,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) "Error creating CDS dump file '%s', Status=0x%08X", DumpFilename, (unsigned int)Status); /* Increment Command Error Counter */ - CFE_ES_TaskData.CommandErrorCounter++; + CFE_ES_Global.TaskData.CommandErrorCounter++; } return CFE_SUCCESS; diff --git a/modules/es/fsw/src/cfe_es_task.h b/modules/es/fsw/src/cfe_es_task.h index 5a5c8ffdb..dc824f3b8 100644 --- a/modules/es/fsw/src/cfe_es_task.h +++ b/modules/es/fsw/src/cfe_es_task.h @@ -72,81 +72,6 @@ ** Type definitions */ -/* - * Background log dump state structure - * - * This structure is stored in global memory and keeps the state - * of the log dump from one iteration to the next. - * - * NOTE: This is used for log structures which are expected to be small - * enough so such that it is not necessary to throttle the file write or - * spread it over time. - * - * Therefore, the only thing necessary to be stored is whether there - * is a pending write request, and the data file name. - * - * Larger log files, such as the Perf log, must implement a state machine - * with a dedicated state data structure. - */ -typedef struct -{ - CFE_FS_FileWriteMetaData_t FileWrite; /**< FS state data - must be first */ - CFE_ES_ERLog_FileEntry_t EntryBuffer; /**< Temp holding area for record to write */ -} CFE_ES_BackgroundLogDumpGlobal_t; - -/* -** Type definition (ES task global data) -*/ -typedef struct -{ - /* - ** ES Task command interface counters - */ - uint8 CommandCounter; - uint8 CommandErrorCounter; - - /* - ** ES Task housekeeping telemetry - */ - CFE_ES_HousekeepingTlm_t HkPacket; - - /* - ** Single application telemetry - */ - CFE_ES_OneAppTlm_t OneAppPacket; - - /* - ** Memory statistics telemetry - */ - CFE_ES_MemStatsTlm_t MemStatsPacket; - - /* - ** ES Task operational data (not reported in housekeeping) - */ - CFE_SB_PipeId_t CmdPipe; - - /* - ** ES Task initialization data (not reported in housekeeping) - */ - CFE_ES_BackgroundLogDumpGlobal_t BackgroundERLogDumpState; - - /* - * Persistent state data associated with performance log data file writes - */ - CFE_ES_PerfDumpGlobal_t BackgroundPerfDumpState; - - /* - * Persistent state data associated with background app table scans - */ - CFE_ES_AppTableScanState_t BackgroundAppScanState; - -} CFE_ES_TaskData_t; - -/* -** Executive Services (ES) task global data. -*/ -extern CFE_ES_TaskData_t CFE_ES_TaskData; - /*************************************************************************/ /* diff --git a/modules/es/ut-coverage/es_UT.c b/modules/es/ut-coverage/es_UT.c index 67e48dc4f..4ce41ba5c 100644 --- a/modules/es/ut-coverage/es_UT.c +++ b/modules/es/ut-coverage/es_UT.c @@ -54,9 +54,7 @@ */ #define ES_UT_CDS_LARGE_TEST_SIZE (128 * 1024) -extern CFE_ES_PerfData_t *Perf; -extern CFE_ES_Global_t CFE_ES_Global; -extern CFE_ES_TaskData_t CFE_ES_TaskData; +extern CFE_ES_Global_t CFE_ES_Global; extern int32 dummy_function(void); @@ -64,6 +62,11 @@ extern int32 dummy_function(void); ** Global variables */ +/* + * Pointer to reset data that will be re-configured/preserved across calls to ES_ResetUnitTest() + */ +static CFE_ES_ResetData_t *ES_UT_PersistentResetData = NULL; + /* Buffers to support memory pool testing */ typedef union { @@ -581,9 +584,6 @@ void UtTest_Setup(void) UT_Init("es"); UtPrintf("cFE ES Unit Test Output File\n\n"); - /* Set up the performance logging variable */ - Perf = (CFE_ES_PerfData_t *)&CFE_ES_ResetDataPtr->Perf; - UT_ADD_TEST(TestInit); UT_ADD_TEST(TestStartupErrorPaths); UT_ADD_TEST(TestResourceID); @@ -620,6 +620,15 @@ void ES_ResetUnitTest(void) CFE_ES_Global.LastMemPoolId = CFE_ResourceId_FromInteger(CFE_ES_POOLID_BASE); CFE_ES_Global.CDSVars.LastCDSBlockId = CFE_ResourceId_FromInteger(CFE_ES_CDSBLOCKID_BASE); + /* + * (Re-)Initialize the reset data pointer + * This was formerly a separate global, but now part of CFE_ES_Global. + * + * Some unit tests assume/rely on it preserving its value across tests, + * so is must be re-initialized here every time CFE_ES_Global is reset. + */ + CFE_ES_Global.ResetDataPtr = ES_UT_PersistentResetData; + } /* end ES_ResetUnitTest() */ void TestInit(void) @@ -661,6 +670,14 @@ void TestStartupErrorPaths(void) UtPrintf("Begin Test Startup Error Paths"); + /* + * Get the reference to the reset area and save it so it will be preserved + * across calls to ES_ResetUnitTest(). This is required since now the pointer + * is part of CFE_ES_Global which is zeroed out as part of test reset. Formerly + * this was a separate global which was not cleared with the other globals. + */ + UT_GetDataBuffer(UT_KEY(CFE_PSP_GetResetArea), (void **)&ES_UT_PersistentResetData, NULL, NULL); + /* Set up the startup script for reading */ strncpy(StartupScript, "CFE_LIB, /cf/apps/tst_lib.bundle, TST_LIB_Init, TST_LIB, 0, 0, 0x0, 1; " @@ -722,8 +739,8 @@ void TestStartupErrorPaths(void) /* Perform the maximum number of processor resets */ ES_ResetUnitTest(); - CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount = 0; - CFE_ES_ResetDataPtr->ResetVars.ES_CausedReset = false; + CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount = 0; + CFE_ES_Global.ResetDataPtr->ResetVars.ES_CausedReset = false; for (j = 0; j < CFE_PLATFORM_ES_MAX_PROCESSOR_RESETS; j++) { @@ -731,7 +748,7 @@ void TestStartupErrorPaths(void) } UT_Report(__FILE__, __LINE__, - CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount == CFE_PLATFORM_ES_MAX_PROCESSOR_RESETS, + CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount == CFE_PLATFORM_ES_MAX_PROCESSOR_RESETS, "CFE_ES_SetupResetVariables", "Maximum processor resets"); /* Attempt another processor reset after the maximum have occurred */ @@ -739,7 +756,7 @@ void TestStartupErrorPaths(void) UT_SetDataBuffer(UT_KEY(CFE_PSP_Restart), &ResetType, sizeof(ResetType), false); CFE_ES_SetupResetVariables(CFE_PSP_RST_TYPE_PROCESSOR, CFE_PSP_RST_SUBTYPE_POWER_CYCLE, 1); UT_Report(__FILE__, __LINE__, - CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount == CFE_PLATFORM_ES_MAX_PROCESSOR_RESETS + 1 && + CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount == CFE_PLATFORM_ES_MAX_PROCESSOR_RESETS + 1 && ResetType == CFE_PSP_RST_TYPE_POWERON && UT_GetStubCount(UT_KEY(CFE_PSP_Restart)) == 1, "CFE_ES_SetupResetVariables", "Processor reset - power cycle; exceeded maximum " @@ -757,7 +774,7 @@ void TestStartupErrorPaths(void) ES_ResetUnitTest(); UT_SetStatusBSPResetArea(OS_ERROR, 0, CFE_TIME_ToneSignalSelect_PRIMARY); UT_SetDataBuffer(UT_KEY(CFE_PSP_Panic), &PanicStatus, sizeof(PanicStatus), false); - CFE_ES_ResetDataPtr->ResetVars.ES_CausedReset = true; + CFE_ES_Global.ResetDataPtr->ResetVars.ES_CausedReset = true; CFE_ES_SetupResetVariables(CFE_PSP_RST_TYPE_PROCESSOR, CFE_PSP_RST_SUBTYPE_POWER_CYCLE, 1); UT_Report(__FILE__, __LINE__, PanicStatus == CFE_PSP_PANIC_MEMORY_ALLOC && UT_GetStubCount(UT_KEY(CFE_PSP_Panic)) == 1, @@ -766,7 +783,7 @@ void TestStartupErrorPaths(void) /* Perform a processor reset triggered by ES */ /* Added for coverage, as the "panic" case will should not cover this one */ ES_ResetUnitTest(); - CFE_ES_ResetDataPtr->ResetVars.ES_CausedReset = true; + CFE_ES_Global.ResetDataPtr->ResetVars.ES_CausedReset = true; CFE_ES_SetupResetVariables(CFE_PSP_RST_TYPE_PROCESSOR, CFE_PSP_RST_SUBTYPE_POWER_CYCLE, 1); UT_Report(__FILE__, __LINE__, UT_GetStubCount(UT_KEY(CFE_PSP_Panic)) == 0, "CFE_ES_SetupResetVariables", "Processor Reset caused by ES"); @@ -1203,8 +1220,8 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_WAITING, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_RUN; UtAppRecPtr->ControlReq.AppTimerMsec = 0; - memset(&CFE_ES_TaskData.BackgroundAppScanState, 0, sizeof(CFE_ES_TaskData.BackgroundAppScanState)); - CFE_ES_RunAppTableScan(0, &CFE_ES_TaskData.BackgroundAppScanState); + memset(&CFE_ES_Global.BackgroundAppScanState, 0, sizeof(CFE_ES_Global.BackgroundAppScanState)); + CFE_ES_RunAppTableScan(0, &CFE_ES_Global.BackgroundAppScanState); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_PCR_ERR2_EID) && UtAppRecPtr->ControlReq.AppTimerMsec == 0, "CFE_ES_RunAppTableScan", "Waiting; process control request"); @@ -1215,7 +1232,7 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_WAITING, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_EXIT; UtAppRecPtr->ControlReq.AppTimerMsec = 5000; - CFE_ES_RunAppTableScan(1000, &CFE_ES_TaskData.BackgroundAppScanState); + CFE_ES_RunAppTableScan(1000, &CFE_ES_Global.BackgroundAppScanState); UT_Report(__FILE__, __LINE__, UtAppRecPtr->ControlReq.AppTimerMsec == 4000 && UtAppRecPtr->ControlReq.AppControlRequest == CFE_ES_RunStatus_APP_EXIT, @@ -1228,7 +1245,7 @@ void TestApps(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_STOPPED, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_RUN; UtAppRecPtr->ControlReq.AppTimerMsec = 0; - CFE_ES_RunAppTableScan(0, &CFE_ES_TaskData.BackgroundAppScanState); + CFE_ES_RunAppTableScan(0, &CFE_ES_Global.BackgroundAppScanState); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_PCR_ERR2_EID) && UtAppRecPtr->ControlReq.AppTimerMsec == 0, "CFE_ES_RunAppTableScan", "Stopped; process control request"); @@ -1238,7 +1255,7 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_EARLY_INIT, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppTimerMsec = 5000; - CFE_ES_RunAppTableScan(0, &CFE_ES_TaskData.BackgroundAppScanState); + CFE_ES_RunAppTableScan(0, &CFE_ES_Global.BackgroundAppScanState); UT_Report(__FILE__, __LINE__, UT_GetNumEventsSent() == 0 && UtAppRecPtr->ControlReq.AppTimerMsec == 5000, "CFE_ES_RunAppTableScan", "Initializing; process control request"); @@ -1600,7 +1617,7 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_WAITING, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppTimerMsec = 0; - CFE_ES_RunAppTableScan(0, &CFE_ES_TaskData.BackgroundAppScanState); + CFE_ES_RunAppTableScan(0, &CFE_ES_Global.BackgroundAppScanState); UT_Report(__FILE__, __LINE__, UT_GetNumEventsSent() == 0 && UtAppRecPtr->ControlReq.AppTimerMsec == 0, "CFE_ES_RunAppTableScan", "Waiting; process control request"); @@ -1610,7 +1627,7 @@ void TestApps(void) ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); UtAppRecPtr->ControlReq.AppTimerMsec = 0; - CFE_ES_RunAppTableScan(0, &CFE_ES_TaskData.BackgroundAppScanState); + CFE_ES_RunAppTableScan(0, &CFE_ES_Global.BackgroundAppScanState); UT_Report(__FILE__, __LINE__, UT_GetNumEventsSent() == 0 && UtAppRecPtr->ControlReq.AppTimerMsec == 0, "CFE_ES_RunAppTableScan", "Running; process control request"); @@ -1876,12 +1893,12 @@ void TestERLog(void) * and non-null context with small size */ ES_ResetUnitTest(); - CFE_ES_ResetDataPtr->ERLogIndex = CFE_PLATFORM_ES_ER_LOG_ENTRIES + 1; - Return = CFE_ES_WriteToERLog(CFE_ES_LogEntryType_CORE, CFE_PSP_RST_TYPE_POWERON, 1, NULL); + CFE_ES_Global.ResetDataPtr->ERLogIndex = CFE_PLATFORM_ES_ER_LOG_ENTRIES + 1; + Return = CFE_ES_WriteToERLog(CFE_ES_LogEntryType_CORE, CFE_PSP_RST_TYPE_POWERON, 1, NULL); UT_Report(__FILE__, __LINE__, Return == CFE_SUCCESS && - !strcmp(CFE_ES_ResetDataPtr->ERLog[0].BaseInfo.Description, "No Description String Given.") && - CFE_ES_ResetDataPtr->ERLogIndex == 1, + !strcmp(CFE_ES_Global.ResetDataPtr->ERLog[0].BaseInfo.Description, "No Description String Given.") && + CFE_ES_Global.ResetDataPtr->ERLogIndex == 1, "CFE_ES_WriteToERLog", "Log entries exceeded; no description; valid context size"); /* Test non-rolling over log entry, @@ -1889,10 +1906,10 @@ void TestERLog(void) * and null context */ ES_ResetUnitTest(); - CFE_ES_ResetDataPtr->ERLogIndex = 0; - Return = CFE_ES_WriteToERLog(CFE_ES_LogEntryType_CORE, CFE_PSP_RST_TYPE_POWERON, 1, NULL); - UT_Report(__FILE__, __LINE__, Return == CFE_SUCCESS && CFE_ES_ResetDataPtr->ERLogIndex == 1, "CFE_ES_WriteToERLog", - "No log entry rollover; no description; no context"); + CFE_ES_Global.ResetDataPtr->ERLogIndex = 0; + Return = CFE_ES_WriteToERLog(CFE_ES_LogEntryType_CORE, CFE_PSP_RST_TYPE_POWERON, 1, NULL); + UT_Report(__FILE__, __LINE__, Return == CFE_SUCCESS && CFE_ES_Global.ResetDataPtr->ERLogIndex == 1, + "CFE_ES_WriteToERLog", "No log entry rollover; no description; no context"); /* Test ER log background write functions */ memset(&State, 0, sizeof(State)); @@ -2185,8 +2202,8 @@ void TestTask(void) * depending on the value that the index has reached from previous tests */ memset(&CmdBuf, 0, sizeof(CmdBuf)); - CFE_ES_ResetDataPtr->SystemLogWriteIdx = 0; - CFE_ES_ResetDataPtr->SystemLogEndIdx = CFE_ES_ResetDataPtr->SystemLogWriteIdx; + CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx = 0; + CFE_ES_Global.ResetDataPtr->SystemLogEndIdx = CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx; /* Test task main process loop with a command pipe error */ ES_ResetUnitTest(); @@ -2215,25 +2232,25 @@ void TestTask(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, NULL, NULL, NULL); UT_Report(__FILE__, __LINE__, CFE_ES_TaskInit() == CFE_SUCCESS, "CFE_ES_TaskInit", "Checksum fail, task init result"); - UT_Report(__FILE__, __LINE__, CFE_ES_TaskData.HkPacket.Payload.CFECoreChecksum == 0xFFFF, "CFE_ES_TaskInit", + UT_Report(__FILE__, __LINE__, CFE_ES_Global.TaskData.HkPacket.Payload.CFECoreChecksum == 0xFFFF, "CFE_ES_TaskInit", "Checksum fail, checksum value"); /* Test successful task main process loop - Power On Reset Path */ ES_ResetUnitTest(); /* this is needed so CFE_ES_GetAppId works */ ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, NULL, NULL, NULL); - CFE_ES_ResetDataPtr->ResetVars.ResetType = 2; + CFE_ES_Global.ResetDataPtr->ResetVars.ResetType = 2; UT_Report(__FILE__, __LINE__, - CFE_ES_TaskInit() == CFE_SUCCESS && CFE_ES_TaskData.HkPacket.Payload.CFECoreChecksum != 0xFFFF, + CFE_ES_TaskInit() == CFE_SUCCESS && CFE_ES_Global.TaskData.HkPacket.Payload.CFECoreChecksum != 0xFFFF, "CFE_ES_TaskInit", "Checksum success, POR Path"); /* Test successful task main process loop - Processor Reset Path */ ES_ResetUnitTest(); /* this is needed so CFE_ES_GetAppId works */ ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, NULL, NULL, NULL); - CFE_ES_ResetDataPtr->ResetVars.ResetType = 1; + CFE_ES_Global.ResetDataPtr->ResetVars.ResetType = 1; UT_Report(__FILE__, __LINE__, - CFE_ES_TaskInit() == CFE_SUCCESS && CFE_ES_TaskData.HkPacket.Payload.CFECoreChecksum != 0xFFFF, + CFE_ES_TaskInit() == CFE_SUCCESS && CFE_ES_Global.TaskData.HkPacket.Payload.CFECoreChecksum != 0xFFFF, "CFE_ES_TaskInit", "Checksum success, PR Path"); /* Test task main process loop with a register app failure */ @@ -2281,19 +2298,19 @@ void TestTask(void) * DISCARD, which can result in a log overflow depending on the value that * the index reaches during subsequent tests */ - CFE_ES_ResetDataPtr->SystemLogMode = CFE_ES_LogMode_OVERWRITE; + CFE_ES_Global.ResetDataPtr->SystemLogMode = CFE_ES_LogMode_OVERWRITE; /* Test a successful HK request */ ES_ResetUnitTest(); UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.NoArgsCmd), UT_TPID_CFE_ES_SEND_HK); - UT_Report(__FILE__, __LINE__, CFE_ES_TaskData.HkPacket.Payload.HeapBytesFree > 0, "CFE_ES_HousekeepingCmd", + UT_Report(__FILE__, __LINE__, CFE_ES_Global.TaskData.HkPacket.Payload.HeapBytesFree > 0, "CFE_ES_HousekeepingCmd", "HK packet - get heap successful"); /* Test the HK request with a get heap failure */ ES_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_HeapGetInfo), 1, -1); UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.NoArgsCmd), UT_TPID_CFE_ES_SEND_HK); - UT_Report(__FILE__, __LINE__, CFE_ES_TaskData.HkPacket.Payload.HeapBytesFree == 0, "CFE_ES_HousekeepingCmd", + UT_Report(__FILE__, __LINE__, CFE_ES_Global.TaskData.HkPacket.Payload.HeapBytesFree == 0, "CFE_ES_HousekeepingCmd", "HK packet - get heap fail"); /* Test successful no-op command */ @@ -2309,8 +2326,8 @@ void TestTask(void) /* Test successful cFE restart */ ES_ResetUnitTest(); - CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount = 0; - CmdBuf.RestartCmd.Payload.RestartType = CFE_PSP_RST_TYPE_PROCESSOR; + CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount = 0; + CmdBuf.RestartCmd.Payload.RestartType = CFE_PSP_RST_TYPE_PROCESSOR; UT_SetDataBuffer(UT_KEY(CFE_PSP_Restart), &ResetType, sizeof(ResetType), false); UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.RestartCmd), UT_TPID_CFE_ES_CMD_RESTART_CC); UT_Report(__FILE__, __LINE__, @@ -2721,7 +2738,7 @@ void TestTask(void) memset(&CmdBuf, 0, sizeof(CmdBuf)); strncpy(CmdBuf.WriteSysLogCmd.Payload.FileName, "filename", sizeof(CmdBuf.WriteSysLogCmd.Payload.FileName) - 1); CmdBuf.WriteSysLogCmd.Payload.FileName[sizeof(CmdBuf.WriteSysLogCmd.Payload.FileName) - 1] = '\0'; - CFE_ES_TaskData.HkPacket.Payload.SysLogEntries = 123; + CFE_ES_Global.TaskData.HkPacket.Payload.SysLogEntries = 123; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.WriteSysLogCmd), UT_TPID_CFE_ES_CMD_WRITE_SYSLOG_CC); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_SYSLOG2_EID), "CFE_ES_WriteSysLogCmd", "Write system log; success"); @@ -2747,11 +2764,11 @@ void TestTask(void) ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); UT_SetDefaultReturnValue(UT_KEY(OS_write), OS_ERROR); - CFE_ES_ResetDataPtr->SystemLogWriteIdx = - snprintf(CFE_ES_ResetDataPtr->SystemLog, sizeof(CFE_ES_ResetDataPtr->SystemLog), + CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx = + snprintf(CFE_ES_Global.ResetDataPtr->SystemLog, sizeof(CFE_ES_Global.ResetDataPtr->SystemLog), "0000-000-00:00:00.00000 Test Message\n"); - CFE_ES_ResetDataPtr->SystemLogEndIdx = CFE_ES_ResetDataPtr->SystemLogWriteIdx; - CmdBuf.WriteSysLogCmd.Payload.FileName[0] = '\0'; + CFE_ES_Global.ResetDataPtr->SystemLogEndIdx = CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx; + CmdBuf.WriteSysLogCmd.Payload.FileName[0] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.WriteSysLogCmd), UT_TPID_CFE_ES_CMD_WRITE_SYSLOG_CC); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_FILEWRITE_ERR_EID), "CFE_ES_WriteSysLogCmd", "Write system log; OS write"); @@ -2805,8 +2822,8 @@ void TestTask(void) "Scan for exceptions; processor restart"); ES_ResetUnitTest(); - CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount = 0; - CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount = 1; + CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount = 0; + CFE_ES_Global.ResetDataPtr->ResetVars.MaxProcessorResetCount = 1; UT_SetDefaultReturnValue(UT_KEY(CFE_PSP_Exception_GetCount), 1); CFE_ES_RunExceptionScan(0, NULL); /* first time should do a processor restart (limit reached) */ @@ -3199,6 +3216,14 @@ void TestPerf(void) UtPrintf("Begin Test Performance Log"); + CFE_ES_PerfData_t *Perf; + + /* + ** Set the pointer to the data area + */ + UT_GetDataBuffer(UT_KEY(CFE_PSP_GetResetArea), (void **)&ES_UT_PersistentResetData, NULL, NULL); + Perf = &ES_UT_PersistentResetData->Perf; + /* Test successful performance mask and value initialization */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, "CFE_ES", NULL, NULL); @@ -3261,9 +3286,9 @@ void TestPerf(void) ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); /* clearing the BackgroundPerfDumpState will fully reset to initial state */ - memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); - CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_INIT; - CmdBuf.PerfStartCmd.Payload.TriggerMode = CFE_ES_PERF_TRIGGER_START; + memset(&CFE_ES_Global.BackgroundPerfDumpState, 0, sizeof(CFE_ES_Global.BackgroundPerfDumpState)); + CFE_ES_Global.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_INIT; + CmdBuf.PerfStartCmd.Payload.TriggerMode = CFE_ES_PERF_TRIGGER_START; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.PerfStartCmd), UT_TPID_CFE_ES_CMD_START_PERF_DATA_CC); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_PERF_STARTCMD_ERR_EID), "CFE_ES_StartPerfDataCmd", "Cannot collect performance data; write in progress"); @@ -3272,7 +3297,7 @@ void TestPerf(void) * start command */ ES_ResetUnitTest(); - memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); + memset(&CFE_ES_Global.BackgroundPerfDumpState, 0, sizeof(CFE_ES_Global.BackgroundPerfDumpState)); memset(&CmdBuf, 0, sizeof(CmdBuf)); CmdBuf.PerfStartCmd.Payload.TriggerMode = CFE_ES_PERF_TRIGGER_START; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.PerfStartCmd), UT_TPID_CFE_ES_CMD_START_PERF_DATA_CC); @@ -3281,7 +3306,7 @@ void TestPerf(void) /* Test successful performance data collection stop */ ES_ResetUnitTest(); - memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); + memset(&CFE_ES_Global.BackgroundPerfDumpState, 0, sizeof(CFE_ES_Global.BackgroundPerfDumpState)); memset(&CmdBuf, 0, sizeof(CmdBuf)); UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.PerfStopCmd), UT_TPID_CFE_ES_CMD_STOP_PERF_DATA_CC); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_PERF_STOPCMD_EID), "CFE_ES_StopPerfDataCmd", @@ -3292,7 +3317,7 @@ void TestPerf(void) ES_ResetUnitTest(); /* clearing the BackgroundPerfDumpState will fully reset to initial state */ - memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); + memset(&CFE_ES_Global.BackgroundPerfDumpState, 0, sizeof(CFE_ES_Global.BackgroundPerfDumpState)); strncpy(CmdBuf.PerfStopCmd.Payload.DataFileName, "filename", sizeof(CmdBuf.PerfStopCmd.Payload.DataFileName) - 1); CmdBuf.PerfStopCmd.Payload.DataFileName[sizeof(CmdBuf.PerfStopCmd.Payload.DataFileName) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.PerfStopCmd), UT_TPID_CFE_ES_CMD_STOP_PERF_DATA_CC); @@ -3301,7 +3326,7 @@ void TestPerf(void) /* Test performance data collection stop with a file write in progress */ ES_ResetUnitTest(); - CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_INIT; + CFE_ES_Global.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_INIT; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.PerfStopCmd), UT_TPID_CFE_ES_CMD_STOP_PERF_DATA_CC); UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_PERF_STOPCMD_ERR2_EID), "CFE_ES_StopPerfDataCmd", "Stop performance data command ignored"); @@ -3505,52 +3530,52 @@ void TestPerf(void) /* Test perf log dump state machine */ /* Nominal call 1 - should go through up to the DELAY state */ ES_ResetUnitTest(); - memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); - CFE_ES_TaskData.BackgroundPerfDumpState.PendingState = CFE_ES_PerfDumpState_INIT; - CFE_ES_RunPerfLogDump(1000, &CFE_ES_TaskData.BackgroundPerfDumpState); - UtAssert_True(CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState == CFE_ES_PerfDumpState_DELAY, - "CFE_ES_RunPerfLogDump - CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState (%d) == DELAY (%d)", - (int)CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState, (int)CFE_ES_PerfDumpState_DELAY); + memset(&CFE_ES_Global.BackgroundPerfDumpState, 0, sizeof(CFE_ES_Global.BackgroundPerfDumpState)); + CFE_ES_Global.BackgroundPerfDumpState.PendingState = CFE_ES_PerfDumpState_INIT; + CFE_ES_RunPerfLogDump(1000, &CFE_ES_Global.BackgroundPerfDumpState); + UtAssert_True(CFE_ES_Global.BackgroundPerfDumpState.CurrentState == CFE_ES_PerfDumpState_DELAY, + "CFE_ES_RunPerfLogDump - CFE_ES_Global.BackgroundPerfDumpState.CurrentState (%d) == DELAY (%d)", + (int)CFE_ES_Global.BackgroundPerfDumpState.CurrentState, (int)CFE_ES_PerfDumpState_DELAY); UtAssert_True(UT_GetStubCount(UT_KEY(OS_OpenCreate)) == 1, "CFE_ES_RunPerfLogDump - OS_OpenCreate() called"); /* Nominal call 2 - should go through up to the remainder of states, back to IDLE */ - CFE_ES_RunPerfLogDump(1000, &CFE_ES_TaskData.BackgroundPerfDumpState); - UtAssert_True(CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState == CFE_ES_PerfDumpState_IDLE, - "CFE_ES_RunPerfLogDump - CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState (%d) == IDLE (%d)", - (int)CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState, (int)CFE_ES_PerfDumpState_IDLE); + CFE_ES_RunPerfLogDump(1000, &CFE_ES_Global.BackgroundPerfDumpState); + UtAssert_True(CFE_ES_Global.BackgroundPerfDumpState.CurrentState == CFE_ES_PerfDumpState_IDLE, + "CFE_ES_RunPerfLogDump - CFE_ES_Global.BackgroundPerfDumpState.CurrentState (%d) == IDLE (%d)", + (int)CFE_ES_Global.BackgroundPerfDumpState.CurrentState, (int)CFE_ES_PerfDumpState_IDLE); UtAssert_True(UT_GetStubCount(UT_KEY(OS_close)) == 1, "CFE_ES_RunPerfLogDump - OS_close() called"); /* Test a failure to open the output file */ /* This should go immediately back to idle, and generate CFE_ES_PERF_LOG_ERR_EID */ ES_ResetUnitTest(); - memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); - CFE_ES_TaskData.BackgroundPerfDumpState.PendingState = CFE_ES_PerfDumpState_INIT; + memset(&CFE_ES_Global.BackgroundPerfDumpState, 0, sizeof(CFE_ES_Global.BackgroundPerfDumpState)); + CFE_ES_Global.BackgroundPerfDumpState.PendingState = CFE_ES_PerfDumpState_INIT; UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), -10); - CFE_ES_RunPerfLogDump(1000, &CFE_ES_TaskData.BackgroundPerfDumpState); - UtAssert_True(CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState == CFE_ES_PerfDumpState_IDLE, - "CFE_ES_RunPerfLogDump - OS create fail, CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState (%d) " + CFE_ES_RunPerfLogDump(1000, &CFE_ES_Global.BackgroundPerfDumpState); + UtAssert_True(CFE_ES_Global.BackgroundPerfDumpState.CurrentState == CFE_ES_PerfDumpState_IDLE, + "CFE_ES_RunPerfLogDump - OS create fail, CFE_ES_Global.BackgroundPerfDumpState.CurrentState (%d) " "== IDLE (%d)", - (int)CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState, (int)CFE_ES_PerfDumpState_IDLE); + (int)CFE_ES_Global.BackgroundPerfDumpState.CurrentState, (int)CFE_ES_PerfDumpState_IDLE); UtAssert_True(UT_EventIsInHistory(CFE_ES_PERF_LOG_ERR_EID), "CFE_ES_RunPerfLogDump - OS create fail, generated CFE_ES_PERF_LOG_ERR_EID"); /* Test a failure to write to the output file */ ES_ResetUnitTest(); - memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); + memset(&CFE_ES_Global.BackgroundPerfDumpState, 0, sizeof(CFE_ES_Global.BackgroundPerfDumpState)); UT_SetDefaultReturnValue(UT_KEY(OS_write), -10); - CFE_ES_TaskData.BackgroundPerfDumpState.PendingState = CFE_ES_PerfDumpState_INIT; - CFE_ES_RunPerfLogDump(1000, &CFE_ES_TaskData.BackgroundPerfDumpState); - UtAssert_True(CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState == CFE_ES_PerfDumpState_DELAY, - "CFE_ES_RunPerfLogDump - OS_write fail, CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState (%d) == " + CFE_ES_Global.BackgroundPerfDumpState.PendingState = CFE_ES_PerfDumpState_INIT; + CFE_ES_RunPerfLogDump(1000, &CFE_ES_Global.BackgroundPerfDumpState); + UtAssert_True(CFE_ES_Global.BackgroundPerfDumpState.CurrentState == CFE_ES_PerfDumpState_DELAY, + "CFE_ES_RunPerfLogDump - OS_write fail, CFE_ES_Global.BackgroundPerfDumpState.CurrentState (%d) == " "DELAY (%d)", - (int)CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState, (int)CFE_ES_PerfDumpState_DELAY); + (int)CFE_ES_Global.BackgroundPerfDumpState.CurrentState, (int)CFE_ES_PerfDumpState_DELAY); /* This will trigger the OS_write() failure, which should go through up to the remainder of states, back to IDLE */ - CFE_ES_RunPerfLogDump(1000, &CFE_ES_TaskData.BackgroundPerfDumpState); + CFE_ES_RunPerfLogDump(1000, &CFE_ES_Global.BackgroundPerfDumpState); UtAssert_True( - CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState == CFE_ES_PerfDumpState_IDLE, - "CFE_ES_RunPerfLogDump - OS_write fail, CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState (%d) == IDLE (%d)", - (int)CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState, (int)CFE_ES_PerfDumpState_IDLE); + CFE_ES_Global.BackgroundPerfDumpState.CurrentState == CFE_ES_PerfDumpState_IDLE, + "CFE_ES_RunPerfLogDump - OS_write fail, CFE_ES_Global.BackgroundPerfDumpState.CurrentState (%d) == IDLE (%d)", + (int)CFE_ES_Global.BackgroundPerfDumpState.CurrentState, (int)CFE_ES_PerfDumpState_IDLE); UtAssert_True(UT_EventIsInHistory(CFE_ES_FILEWRITE_ERR_EID), "CFE_ES_RunPerfLogDump - OS_write fail, generated CFE_ES_FILEWRITE_ERR_EID"); @@ -3559,35 +3584,35 @@ void TestPerf(void) * so that the writing position is toward the end of the buffer. */ ES_ResetUnitTest(); - memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); - OS_OpenCreate(&CFE_ES_TaskData.BackgroundPerfDumpState.FileDesc, "UT", 0, 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; - CFE_ES_TaskData.BackgroundPerfDumpState.StateCounter = 4; - CFE_ES_RunPerfLogDump(1000, &CFE_ES_TaskData.BackgroundPerfDumpState); + memset(&CFE_ES_Global.BackgroundPerfDumpState, 0, sizeof(CFE_ES_Global.BackgroundPerfDumpState)); + OS_OpenCreate(&CFE_ES_Global.BackgroundPerfDumpState.FileDesc, "UT", 0, OS_WRITE_ONLY); + CFE_ES_Global.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_WRITE_PERF_ENTRIES; + CFE_ES_Global.BackgroundPerfDumpState.PendingState = CFE_ES_PerfDumpState_WRITE_PERF_ENTRIES; + CFE_ES_Global.BackgroundPerfDumpState.DataPos = CFE_PLATFORM_ES_PERF_DATA_BUFFER_SIZE - 2; + CFE_ES_Global.BackgroundPerfDumpState.StateCounter = 4; + CFE_ES_RunPerfLogDump(1000, &CFE_ES_Global.BackgroundPerfDumpState); /* check that the wraparound occurred */ - UtAssert_True(CFE_ES_TaskData.BackgroundPerfDumpState.DataPos == 2, + UtAssert_True(CFE_ES_Global.BackgroundPerfDumpState.DataPos == 2, "CFE_ES_RunPerfLogDump - wraparound, DataPos (%u) == 2", - (unsigned int)CFE_ES_TaskData.BackgroundPerfDumpState.DataPos); + (unsigned int)CFE_ES_Global.BackgroundPerfDumpState.DataPos); /* should have written 4 entries to the log */ - UtAssert_True(CFE_ES_TaskData.BackgroundPerfDumpState.FileSize == sizeof(CFE_ES_PerfDataEntry_t) * 4, + UtAssert_True(CFE_ES_Global.BackgroundPerfDumpState.FileSize == sizeof(CFE_ES_PerfDataEntry_t) * 4, "CFE_ES_RunPerfLogDump - wraparound, FileSize (%u) == sizeof(CFE_ES_PerfDataEntry_t) * 4", - (unsigned int)CFE_ES_TaskData.BackgroundPerfDumpState.FileSize); + (unsigned int)CFE_ES_Global.BackgroundPerfDumpState.FileSize); /* Confirm that the "CFE_ES_GetPerfLogDumpRemaining" function works. * This requires that the state is not idle, in order to get nonzero results. */ ES_ResetUnitTest(); - memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); - OS_OpenCreate(&CFE_ES_TaskData.BackgroundPerfDumpState.FileDesc, "UT", 0, OS_WRITE_ONLY); - CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_WRITE_PERF_METADATA; - CFE_ES_TaskData.BackgroundPerfDumpState.StateCounter = 10; - Perf->MetaData.DataCount = 100; + memset(&CFE_ES_Global.BackgroundPerfDumpState, 0, sizeof(CFE_ES_Global.BackgroundPerfDumpState)); + OS_OpenCreate(&CFE_ES_Global.BackgroundPerfDumpState.FileDesc, "UT", 0, OS_WRITE_ONLY); + CFE_ES_Global.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_WRITE_PERF_METADATA; + CFE_ES_Global.BackgroundPerfDumpState.StateCounter = 10; + Perf->MetaData.DataCount = 100; /* in states other than WRITE_PERF_ENTRIES, it should report the full size of the log */ UtAssert_True(CFE_ES_GetPerfLogDumpRemaining() == 100, " CFE_ES_GetPerfLogDumpRemaining - Setup Phase"); /* in WRITE_PERF_ENTRIES, it should report the StateCounter */ - CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_WRITE_PERF_ENTRIES; + CFE_ES_Global.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_WRITE_PERF_ENTRIES; UtAssert_True(CFE_ES_GetPerfLogDumpRemaining() == 10, " CFE_ES_GetPerfLogDumpRemaining - Active Phase"); } @@ -3612,10 +3637,12 @@ void TestAPI(void) /* Test resetting the cFE with a processor reset */ ES_ResetUnitTest(); - ResetType = CFE_PSP_RST_TYPE_PROCESSOR; - CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount = CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount - 1; + ResetType = CFE_PSP_RST_TYPE_PROCESSOR; + CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount = + CFE_ES_Global.ResetDataPtr->ResetVars.MaxProcessorResetCount - 1; CFE_ES_ResetCFE(ResetType); - CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount = CFE_ES_ResetDataPtr->ResetVars.MaxProcessorResetCount; + CFE_ES_Global.ResetDataPtr->ResetVars.ProcessorResetCount = + CFE_ES_Global.ResetDataPtr->ResetVars.MaxProcessorResetCount; UT_Report(__FILE__, __LINE__, CFE_ES_ResetCFE(ResetType) == CFE_ES_NOT_IMPLEMENTED && UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_POR_MAX_PROC_RESETS]) && @@ -3996,16 +4023,16 @@ void TestAPI(void) * must be truncated */ ES_ResetUnitTest(); - CFE_ES_ResetDataPtr->SystemLogWriteIdx = CFE_PLATFORM_ES_SYSTEM_LOG_SIZE - CFE_TIME_PRINTED_STRING_SIZE - 4; - CFE_ES_ResetDataPtr->SystemLogEndIdx = CFE_ES_ResetDataPtr->SystemLogWriteIdx; - CFE_ES_ResetDataPtr->SystemLogMode = CFE_ES_LogMode_DISCARD; + CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx = CFE_PLATFORM_ES_SYSTEM_LOG_SIZE - CFE_TIME_PRINTED_STRING_SIZE - 4; + CFE_ES_Global.ResetDataPtr->SystemLogEndIdx = CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx; + CFE_ES_Global.ResetDataPtr->SystemLogMode = CFE_ES_LogMode_DISCARD; UT_Report(__FILE__, __LINE__, CFE_ES_SysLogWrite_Unsync("SysLogText This message should be truncated") == CFE_ES_ERR_SYS_LOG_TRUNCATED, "CFE_ES_SysLogWrite_Internal", "Add message to log that must be truncated"); /* Reset the system log index to prevent an overflow in later tests */ - CFE_ES_ResetDataPtr->SystemLogWriteIdx = 0; - CFE_ES_ResetDataPtr->SystemLogEndIdx = 0; + CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx = 0; + CFE_ES_Global.ResetDataPtr->SystemLogEndIdx = 0; /* Test calculating a CRC on a range of memory using CRC type 8 * NOTE: This capability is not currently implemented in cFE @@ -4101,9 +4128,9 @@ void TestAPI(void) * causes the log index to be reset */ ES_ResetUnitTest(); - CFE_ES_ResetDataPtr->SystemLogWriteIdx = CFE_PLATFORM_ES_SYSTEM_LOG_SIZE; - CFE_ES_ResetDataPtr->SystemLogEndIdx = CFE_ES_ResetDataPtr->SystemLogWriteIdx; - CFE_ES_ResetDataPtr->SystemLogMode = CFE_ES_LogMode_DISCARD; + CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx = CFE_PLATFORM_ES_SYSTEM_LOG_SIZE; + CFE_ES_Global.ResetDataPtr->SystemLogEndIdx = CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx; + CFE_ES_Global.ResetDataPtr->SystemLogMode = CFE_ES_LogMode_DISCARD; UT_Report(__FILE__, __LINE__, CFE_ES_WriteToSysLog("SysLogText") == CFE_ES_ERR_SYS_LOG_FULL, "CFE_ES_WriteToSysLog", "Add message to log that resets the log index"); @@ -4111,12 +4138,12 @@ void TestAPI(void) * causes the log index to be reset */ ES_ResetUnitTest(); - CFE_ES_ResetDataPtr->SystemLogWriteIdx = CFE_PLATFORM_ES_SYSTEM_LOG_SIZE; - CFE_ES_ResetDataPtr->SystemLogEndIdx = CFE_ES_ResetDataPtr->SystemLogWriteIdx; - CFE_ES_ResetDataPtr->SystemLogMode = CFE_ES_LogMode_OVERWRITE; + CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx = CFE_PLATFORM_ES_SYSTEM_LOG_SIZE; + CFE_ES_Global.ResetDataPtr->SystemLogEndIdx = CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx; + CFE_ES_Global.ResetDataPtr->SystemLogMode = CFE_ES_LogMode_OVERWRITE; UT_Report(__FILE__, __LINE__, CFE_ES_WriteToSysLog("SysLogText") == CFE_SUCCESS && - CFE_ES_ResetDataPtr->SystemLogWriteIdx < CFE_PLATFORM_ES_SYSTEM_LOG_SIZE, + CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx < CFE_PLATFORM_ES_SYSTEM_LOG_SIZE, "CFE_ES_WriteToSysLog", "Add message to log that resets the log index"); /* Test run loop with an application error status */ @@ -5204,17 +5231,17 @@ void TestSysLog(void) /* Test loop in CFE_ES_SysLogReadStart_Unsync that ensures * reading at the start of a message */ ES_ResetUnitTest(); - CFE_ES_ResetDataPtr->SystemLogWriteIdx = 0; - CFE_ES_ResetDataPtr->SystemLogEndIdx = sizeof(CFE_ES_ResetDataPtr->SystemLog) - 1; + CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx = 0; + CFE_ES_Global.ResetDataPtr->SystemLogEndIdx = sizeof(CFE_ES_Global.ResetDataPtr->SystemLog) - 1; - memset(CFE_ES_ResetDataPtr->SystemLog, 'a', CFE_ES_ResetDataPtr->SystemLogEndIdx); - CFE_ES_ResetDataPtr->SystemLog[CFE_ES_ResetDataPtr->SystemLogEndIdx - 1] = '\n'; + memset(CFE_ES_Global.ResetDataPtr->SystemLog, 'a', CFE_ES_Global.ResetDataPtr->SystemLogEndIdx); + CFE_ES_Global.ResetDataPtr->SystemLog[CFE_ES_Global.ResetDataPtr->SystemLogEndIdx - 1] = '\n'; CFE_ES_SysLogReadStart_Unsync(&SysLogBuffer); UT_Report(__FILE__, __LINE__, - SysLogBuffer.EndIdx == sizeof(CFE_ES_ResetDataPtr->SystemLog) - 1 && - SysLogBuffer.LastOffset == sizeof(CFE_ES_ResetDataPtr->SystemLog) - 1 && + SysLogBuffer.EndIdx == sizeof(CFE_ES_Global.ResetDataPtr->SystemLog) - 1 && + SysLogBuffer.LastOffset == sizeof(CFE_ES_Global.ResetDataPtr->SystemLog) - 1 && SysLogBuffer.BlockSize == 0 && SysLogBuffer.SizeLeft == 0, "CFE_ES_SysLogReadStart_Unsync(SysLogBuffer)", "ResetDataPtr pointing to an old fragment of a message"); @@ -5250,8 +5277,8 @@ void TestSysLog(void) /* Test nominal flow through CFE_ES_SysLogDump * with multiple reads and writes */ ES_ResetUnitTest(); - CFE_ES_ResetDataPtr->SystemLogWriteIdx = 0; - CFE_ES_ResetDataPtr->SystemLogEndIdx = sizeof(CFE_ES_ResetDataPtr->SystemLog) - 1; + CFE_ES_Global.ResetDataPtr->SystemLogWriteIdx = 0; + CFE_ES_Global.ResetDataPtr->SystemLogEndIdx = sizeof(CFE_ES_Global.ResetDataPtr->SystemLog) - 1; CFE_ES_SysLogDump("fakefilename"); @@ -5304,9 +5331,9 @@ void TestBackground(void) * execute the code which counts the number of active jobs. */ ES_ResetUnitTest(); - memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); + memset(&CFE_ES_Global.BackgroundPerfDumpState, 0, sizeof(CFE_ES_Global.BackgroundPerfDumpState)); UT_SetDefaultReturnValue(UT_KEY(OS_write), -10); - CFE_ES_TaskData.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_INIT; + CFE_ES_Global.BackgroundPerfDumpState.CurrentState = CFE_ES_PerfDumpState_INIT; UT_SetDeferredRetcode(UT_KEY(OS_BinSemTimedWait), 3, -4); CFE_ES_BackgroundTask(); UT_Report(__FILE__, __LINE__, UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_BACKGROUND_TAKE]),