Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/snapshot-module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Snapshot CFS module

on:
workflow_dispatch:
inputs:
base-branch:
description: 'The base branch to merge into'
type: string
required: false
default: 'main'
ic-branch:
description: 'The temporary integration branch to create (ic)'
type: string
required: false
default: 'ic-snapshot-dev'
dev-branch:
description: 'The branch to pull in'
type: string
required: false
default: 'dev'
pr-label:
description: 'The label(s) to apply to the generated PR'
type: string
required: false
default: ''

jobs:
snapshot-module:
name: Snapshot module
uses: nasa/cFS/.github/workflows/snapshot-module-reusable.yml@dev
with:
base-branch: ${{ inputs.base-branch }}
ic-branch: ${{ inputs.ic-branch }}
dev-branch: ${{ inputs.dev-branch }}
pr-label: ${{ inputs.pr-label }}
1 change: 1 addition & 0 deletions config/default_cs_tbldefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ typedef struct
uint32 ComparisonValue; /**< \brief The Memory Integrity Value */
uint32 ByteOffset; /**< \brief Where a previous unfinished calc left off */
uint32 TempChecksumValue; /**< \brief The unfinished caluculation */
CFE_ResourceId_t ResourceID; /**< \brief ES identity of the application or library */
char Name[CFE_MISSION_MAX_API_LEN]; /**< \brief name of the app */
} CS_Res_App_Table_Entry_t;

Expand Down
6 changes: 6 additions & 0 deletions docs/cs_FunctionalRequirements.csv
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ Table Checksum Miscomparisons,CS4051,"When the CS Application is comparing a cal
,,2) increment the relevant Miscompare Counter,,,,,
,,3) Issue an event message to notify the user of the miscomparison,,,,,
Checksum State Order of Operations,CS4060,"When the CS Application is calculating checksums, the Checksum State of the table must be 'ENABLED' for an entry in the table to be checksummed, regardless of the state of ""Entry Checksum State""",,,"To ensure that individual entry checksum states are only acted upon when the overall checksumming for the table is enabled, maintaining a hierarchical control structure.",,
Application Reload Checksum Recovery,CS4070,"Before reading each checksum chunk for an Application Table entry naming an application or library, the CS Application shall resolve its Executive Services resource ID and valid code address and size, and shall:",,,"To recover from restarted or reloaded module instances without mixing their partial checksums or comparing against a prior instance baseline, while preserving corruption reporting for an unchanged instance.",nasa/CS#20; applies to background checksumming and commanded application baseline recomputation. Per-chunk lookup does not pin the module against concurrent unload.,
,,1) Record the first successfully resolved identity without reporting a reload.,,,,,
,,"2) On a changed previously recorded resource ID, discard the partial checksum and offset, invalidate the previous baseline, record the new identity, and issue an informational module/baseline-reset event without changing enable states.",,,,,
,,3) Establish a baseline after the first complete pass over the new instance and compare subsequent completed checksums against it as specified in CS4050.,,,,,
,,"4) On code address or size change with the same resource ID, restart the partial computation from offset zero while retaining the baseline.",,,,,
,,"5) On module lookup or address-validation failure, perform no CRC read, discard the partial checksum and offset, retain the last successfully resolved identity, range, and baseline, and report the failure for retry on a later attempt.",,,,,
User-Defined Memory Table,CS5000,"The CS Application shall provide a loadable User-Defined Memory Table containing at least 16 entries, each with the following parameters:",,,"To provide a configurable mechanism for defining and managing checksum parameters for user-defined memory regions, enabling flexible integrity checks.",Number of User-Defined Memory Table entries is configurable,
,,"1) ""Entry Checksum State""",,,,,
,,"2) ""Start Address""",,,,,
Expand Down
16 changes: 16 additions & 0 deletions docs/dox_src/cfs_cs.dox
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,22 @@

The format of a single entry in the Apps Results Table is defined by
#CS_Res_App_Table_Entry_t.

The ResourceID field records the ES identity of the application or library.
It precedes Name in the results entry; ground dump decoders must use the matching
results-table schema for this layout.
CS resolves this identity and the code range before each checksum chunk. If ES
reports a new identity, including a reload at the same address, CS discards the
partial checksum and old baseline and issues #CS_APP_RELOADED_INF_EID. The next
completed pass establishes the new instance's baseline. Initial discovery does
not issue a reload event. Changes to the code range under the same identity
restart the partial checksum but retain the baseline; a checksum mismatch alone
does not authorize a new baseline.

An unavailable module is skipped without reading its cached address. CS retains
its last identity and baseline and discards partial progress before retrying.
Resolving module information does not prevent a concurrent unload between the
query and the checksum read.
**/

/**
Expand Down
1 change: 1 addition & 0 deletions eds/cs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
<Entry type="BASE_TYPES/uint32" name="ComparisonValue" shortDescription="The Memory Integrity Value" />
<Entry type="BASE_TYPES/uint32" name="ByteOffset" shortDescription="Where a previous unfinished calc left off" />
<Entry type="BASE_TYPES/uint32" name="TempChecksumValue" shortDescription="The unfinished caluculation" />
<Entry type="CFE_RESOURCEID/BaseType" name="ResourceID" shortDescription="ES identity of the application or library" />
<Entry type="BASE_TYPES/ApiName" name="Name" shortDescription="name of the app" />
</EntryList>
</ContainerDataType>
Expand Down
14 changes: 14 additions & 0 deletions fsw/inc/cs_eventids.h
Original file line number Diff line number Diff line change
Expand Up @@ -1997,6 +1997,20 @@
*/
#define CS_VAL_TABLES_DEF_TBL_LONG_NAME_ERR_EID 155

/**
* \brief CS Application Or Library Reload Baseline Reset Event ID
*
* \par Type: INFORMATION
*
* \par Cause:
*
* ES reports a different resource ID for a previously resolved application or
* library. CS discards its partial checksum and old baseline, and establishes a
* new baseline when checksumming the new instance completes. Initial discovery
* of an application or library does not generate this event.
*/
#define CS_APP_RELOADED_INF_EID 156

/**@}*/

#endif
19 changes: 8 additions & 11 deletions fsw/src/cs_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ CS_AppData_t CS_AppData;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void CS_AppMain(void)
{
CFE_Status_t Result = 0;
CFE_Status_t Result;
CFE_SB_Buffer_t *BufPtr = NULL;

/* Performance Log (start time counter) */
Expand Down Expand Up @@ -153,10 +153,8 @@ void CS_AppMain(void)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
CFE_Status_t CS_AppInit(void)
{
CFE_Status_t Result = CFE_SUCCESS;

/* Register for event services */
Result = CFE_EVS_Register(NULL, 0, 0);
CFE_Status_t Result = CFE_EVS_Register(NULL, 0, 0);

if (Result != CFE_SUCCESS)
{
Expand All @@ -167,7 +165,8 @@ CFE_Status_t CS_AppInit(void)
/* Zero out all data in CS_AppData, including the housekeeping data*/
memset(&CS_AppData, 0, sizeof(CS_AppData));

CS_AppData.RunStatus = CFE_ES_RunStatus_APP_RUN;
CS_AppData.PreserveStatesOnProcessorReset = CS_PRESERVE_STATES_ON_PROCESSOR_RESET;
CS_AppData.RunStatus = CFE_ES_RunStatus_APP_RUN;

Result = CS_SbInit();
}
Expand All @@ -185,9 +184,10 @@ CFE_Status_t CS_AppInit(void)
CS_AppData.HkPacket.Payload.OSCSState = CS_OSCS_CHECKSUM_STATE;
CS_AppData.HkPacket.Payload.CfeCoreCSState = CS_CFECORE_CHECKSUM_STATE;

#if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true)
Result = CS_CreateRestoreStatesFromCDS();
#endif
if (CS_AppData.PreserveStatesOnProcessorReset)
{
Result = CS_CreateRestoreStatesFromCDS();
}
}

if (Result == CFE_SUCCESS)
Expand Down Expand Up @@ -224,8 +224,6 @@ CFE_Status_t CS_AppInit(void)
return Result;
}

#if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true)

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* CS_CreateCDS() - create CS storage area in CDS */
Expand Down Expand Up @@ -368,4 +366,3 @@ void CS_UpdateCDS(void)
}
}
}
#endif /* #if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true ) */
9 changes: 3 additions & 6 deletions fsw/src/cs_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,9 @@ typedef struct
CS_Def_App_Table_Entry_t
DefaultAppDefTable[CS_MAX_NUM_APP_TABLE_ENTRIES]; /**< \brief Default Apps definition table */

/* The following pointers locate the results for CS tables that get checksummed because they are listed in the CS
* Tables table */

#if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true)
CFE_ES_CDSHandle_t DataStoreHandle; /**< \brief Handle to critical data store created by CS */
#endif
/* Startup configuration and critical data store state */
bool PreserveStatesOnProcessorReset; /**< \brief Initialized from CS_PRESERVE_STATES_ON_PROCESSOR_RESET */
CFE_ES_CDSHandle_t DataStoreHandle; /**< \brief Handle to critical data store created by CS */
} CS_AppData_t;

/**************************************************************************
Expand Down
34 changes: 16 additions & 18 deletions fsw/src/cs_app_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ CFE_Status_t CS_DisableAppsCmd(const CS_DisableAppsCmd_t *CmdPtr)
CS_AppData.HkPacket.Payload.AppCSState = CS_ChecksumState_DISABLED;
CS_ZeroAppTempValues();

#if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true)
CS_UpdateCDS();
#endif
if (CS_AppData.PreserveStatesOnProcessorReset)
{
CS_UpdateCDS();
}

CFE_EVS_SendEvent(CS_DISABLE_APP_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of App is Disabled");
CS_AppData.HkPacket.Payload.CommandCounter++;
Expand All @@ -72,9 +73,10 @@ CFE_Status_t CS_EnableAppsCmd(const CS_EnableAppsCmd_t *CmdPtr)
{
CS_AppData.HkPacket.Payload.AppCSState = CS_ChecksumState_ENABLED;

#if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true)
CS_UpdateCDS();
#endif
if (CS_AppData.PreserveStatesOnProcessorReset)
{
CS_UpdateCDS();
}

CFE_EVS_SendEvent(CS_ENABLE_APP_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of App is Enabled");
CS_AppData.HkPacket.Payload.CommandCounter++;
Expand All @@ -93,10 +95,9 @@ CFE_Status_t CS_ReportBaselineAppCmd(const CS_ReportBaselineAppCmd_t *CmdPtr)
/* command verification variables */
CS_Res_App_Table_Entry_t *ResultsEntry;
uint32 Baseline;
char Name[OS_MAX_API_NAME];
char Name[sizeof(CmdPtr->Payload.Name)];

strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1);
Name[sizeof(Name) - 1] = '\0';
CFE_SB_MessageStringGet(Name, CmdPtr->Payload.Name, "", sizeof(Name), sizeof(CmdPtr->Payload.Name));

if (CS_GetAppResTblEntryByName(&ResultsEntry, Name))
{
Expand Down Expand Up @@ -141,13 +142,12 @@ CFE_Status_t CS_RecomputeBaselineAppCmd(const CS_RecomputeBaselineAppCmd_t *CmdP
CFE_ES_TaskId_t ChildTaskID;
CFE_Status_t Status;
CS_Res_App_Table_Entry_t *ResultsEntry;
char Name[OS_MAX_API_NAME];
char Name[sizeof(CmdPtr->Payload.Name)];

if (CS_AppData.HkPacket.Payload.RecomputeInProgress == false
&& CS_AppData.HkPacket.Payload.OneShotInProgress == false)
{
strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1);
Name[sizeof(Name) - 1] = '\0';
CFE_SB_MessageStringGet(Name, CmdPtr->Payload.Name, "", sizeof(Name), sizeof(CmdPtr->Payload.Name));

/* make sure the entry is a valid number and is defined in the table */
if (CS_GetAppResTblEntryByName(&ResultsEntry, Name))
Expand Down Expand Up @@ -219,12 +219,11 @@ CFE_Status_t CS_DisableNameAppCmd(const CS_DisableNameAppCmd_t *CmdPtr)
CS_Res_App_Table_Entry_t *ResultsEntry;
CS_Def_App_Table_Entry_t *DefinitionEntry;
CS_TableWrapper_t *tw = &CS_AppData.Tbl[CS_ChecksumType_APP_TABLE];
char Name[OS_MAX_API_NAME];
char Name[sizeof(CmdPtr->Payload.Name)];

if (CS_CheckRecomputeOneshot() == false)
{
strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1);
Name[sizeof(Name) - 1] = '\0';
CFE_SB_MessageStringGet(Name, CmdPtr->Payload.Name, "", sizeof(Name), sizeof(CmdPtr->Payload.Name));

if (CS_GetAppResTblEntryByName(&ResultsEntry, Name))
{
Expand Down Expand Up @@ -276,12 +275,11 @@ CFE_Status_t CS_EnableNameAppCmd(const CS_EnableNameAppCmd_t *CmdPtr)
CS_Res_App_Table_Entry_t *ResultsEntry;
CS_Def_App_Table_Entry_t *DefinitionEntry;
CS_TableWrapper_t *tw = &CS_AppData.Tbl[CS_ChecksumType_APP_TABLE];
char Name[OS_MAX_API_NAME];
char Name[sizeof(CmdPtr->Payload.Name)];

if (CS_CheckRecomputeOneshot() == false)
{
strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1);
Name[sizeof(Name) - 1] = '\0';
CFE_SB_MessageStringGet(Name, CmdPtr->Payload.Name, "", sizeof(Name), sizeof(CmdPtr->Payload.Name));

if (CS_GetAppResTblEntryByName(&ResultsEntry, Name))
{
Expand Down
32 changes: 18 additions & 14 deletions fsw/src/cs_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ CFE_Status_t CS_ResetCountersCmd(const CS_ResetCountersCmd_t *CmdPtr)
CFE_Status_t CS_BackgroundCheckCycleCmd(const CS_BackgroundCheckCycleCmd_t *CmdPtr)
{
/* command verification variables */
bool DoneWithCycle = false;
bool EndOfList = false;
bool DoneWithCycle;
bool EndOfList;

if (CS_AppData.HkPacket.Payload.ChecksumState == CS_ChecksumState_ENABLED)
{
Expand Down Expand Up @@ -240,9 +240,10 @@ CFE_Status_t CS_DisableCfeCoreCmd(const CS_DisableCfeCoreCmd_t *CmdPtr)
CS_AppData.HkPacket.Payload.CfeCoreCSState = CS_ChecksumState_DISABLED;
CS_ZeroCfeCoreTempValues();

#if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true)
CS_UpdateCDS();
#endif
if (CS_AppData.PreserveStatesOnProcessorReset)
{
CS_UpdateCDS();
}

CFE_EVS_SendEvent(CS_DISABLE_CFECORE_INF_EID,
CFE_EVS_EventType_INFORMATION,
Expand All @@ -262,9 +263,10 @@ CFE_Status_t CS_EnableCfeCoreCmd(const CS_EnableCfeCoreCmd_t *CmdPtr)
{
CS_AppData.HkPacket.Payload.CfeCoreCSState = CS_ChecksumState_ENABLED;

#if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true)
CS_UpdateCDS();
#endif
if (CS_AppData.PreserveStatesOnProcessorReset)
{
CS_UpdateCDS();
}

CFE_EVS_SendEvent(CS_ENABLE_CFECORE_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of cFE Core is Enabled");

Expand All @@ -283,9 +285,10 @@ CFE_Status_t CS_DisableOSCmd(const CS_DisableOSCmd_t *CmdPtr)
CS_AppData.HkPacket.Payload.OSCSState = CS_ChecksumState_DISABLED;
CS_ZeroOSTempValues();

#if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true)
CS_UpdateCDS();
#endif
if (CS_AppData.PreserveStatesOnProcessorReset)
{
CS_UpdateCDS();
}

CFE_EVS_SendEvent(CS_DISABLE_OS_INF_EID,
CFE_EVS_EventType_INFORMATION,
Expand All @@ -305,9 +308,10 @@ CFE_Status_t CS_EnableOSCmd(const CS_EnableOSCmd_t *CmdPtr)
{
CS_AppData.HkPacket.Payload.OSCSState = CS_ChecksumState_ENABLED;

#if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true)
CS_UpdateCDS();
#endif
if (CS_AppData.PreserveStatesOnProcessorReset)
{
CS_UpdateCDS();
}

CFE_EVS_SendEvent(CS_ENABLE_OS_INF_EID,
CFE_EVS_EventType_INFORMATION,
Expand Down
Loading