Example for the Loop functionality of the Flow Protection component.
#include <mcuxClToolchain.h>
#include <mcuxCsslExamples.h>
#include <mcuxCsslAnalysis.h>
#define ITERATION_COUNT 10U
#define MCUXCLCSSLFLOWPROTECTION_OK 0x2EDEU
#define MCUXCLCSSLFLOWPROTECTION_NOT_OK 0x89ADU
#define MCUXCLCSSLFLOWPROTECTION_FAULT_ATTACK 0xF0FAU
{
volatile uint8_t test = 0xA0u;
for (uint32_t i = 0u; i < ITERATION_COUNT; i++)
{
MCUX_CSSL_ANALYSIS_START_SUPPRESS_INTEGER_OVERFLOW("test cannot overflow with 0xA0u as starting value and 10 iterations.")
test++;
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_INTEGER_OVERFLOW()
}
MCUXCLCSSLFLOWPROTECTION_OK,
MCUXCLCSSLFLOWPROTECTION_FAULT_ATTACK,
);
}
MCUX_CSSL_EX_FUNCTION(mcuxCsslFlowProtection_Loop_example)
{
if (MCUXCLCSSLFLOWPROTECTION_OK != returnCode)
{
return MCUX_CSSL_EX_ERROR;
}
return MCUX_CSSL_EX_OK;
}
Provides the API for the CSSL flow protection mechanism.
Definition of function identifiers for the flow protection mechanism.
#define MCUX_CSSL_FP_RESULT(...)
Extract the result value from a protected return value.
Definition mcuxCsslFlowProtection.h:422
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition mcuxCsslFlowProtection.h:166
#define MCUX_CSSL_FP_FUNCTION_ENTRY(...)
Flow protection handler for the function entry point.
Definition mcuxCsslFlowProtection.h:285
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition mcuxCsslFlowProtection.h:138
#define MCUX_CSSL_FP_FUNCTION_DEF(...)
Definition of a flow protected function.
Definition mcuxCsslFlowProtection.h:200
#define MCUX_CSSL_FP_FUNCTION_EXIT_WITH_CHECK(...)
Flow protection handler for the function exit point which includes an actual check of the code flow.
Definition mcuxCsslFlowProtection.h:367
#define MCUX_CSSL_FP_LOOP_DECL(id)
Declaration of a flow protected loop.
Definition mcuxCsslFlowProtection.h:856
#define MCUX_CSSL_FP_LOOP_ITERATIONS(id, count)
Expected number of loop iterations.
Definition mcuxCsslFlowProtection.h:919
#define MCUX_CSSL_FP_LOOP_ITERATION(...)
Perform a loop iteration.
Definition mcuxCsslFlowProtection.h:884