XilinxProcessorIPLib/drivers/trngpsv/src/xtrngpsv_tests.c
s32 XTrngpsv_RunHealthTest(XTrngpsv *InstancePtr)
{
	s32 Status = XTRNGPSV_FAILURE;

	XTrngpsv_UsrCfg UsrCfgTests;

	if (InstancePtr == NULL) {
		Status = (s32)XTRNGPSV_ERROR_INVALID_PARAM;
		goto END;
	}

	(void)memset((u8*)&UsrCfgTests, 0, sizeof(UsrCfgTests));

	/* Populate user config parameters of TRNGPSV driver */

	UsrCfgTests.Mode = XTRNGPSV_HRNG;
	UsrCfgTests.SeedLife = HEALTH_TEST_SEEDLIFE;
	UsrCfgTests.PredResistanceEn = XTRNGPSV_FALSE;
	UsrCfgTests.DFDisable = XTRNGPSV_FALSE;
	UsrCfgTests.DFLenMul = HEALTH_TEST_DFLENMUL;
	UsrCfgTests.PersStrPresent = XTRNGPSV_FALSE;
	UsrCfgTests.InitSeedPresent = XTRNGPSV_FALSE;

	/* Invoke Instantiate (which includes reseed) operation */
	Status = XTrngpsv_Instantiate(InstancePtr, &UsrCfgTests);
	if (Status != XTRNGPSV_SUCCESS) {
		goto SET_ERR;
	}

	/* CTF is not being monitored explicitly here since that is done as part of Reseeding
	 * during Instantiation
	 */

	/* Uninstantiate driver instance after Health Tests */
	Status = XTrngpsv_Uninstantiate(InstancePtr);

SET_ERR:
	if (Status != XTRNGPSV_SUCCESS) {
		InstancePtr->State = XTRNGPSV_ERROR;
	}

END:
	return Status;
}
/*************************************************************************************************/
/**
 * @brief
 * Health tests are entropy tests and hence should be run when the configured mode is of PTRNG or
 * HRNG mode. 1024 bits of entropy data to be generated and the CTF flag to be monitored. TRNG
 * configured in HRNG + DF serves this purpose ((7+1)*128 = 1024 bits). Since this flag is monitored
 * for every reseed, no need to monitor CTF explicitly in this test. This API is to be called at
 * startup, after instantiation (and reseeding). Even for PTRNG mode, for this test, mode to be
 * configured as HRNG (as there is no reseed operation involved in PTRNG mode).
 *
 * @param	InstancePtr is a pointer to the XTrngpsv instance to be worked on.
 *
 * @return
 *		- XTRNGPSV_SUCCESS if Health tests are successfully run.
 *		- XTRNGPSV_ERROR_INVALID_PARAM if invalid parameter passed to this function (OR)
 *		other error codes from the called functions as defined in XTrngpsv_ErrorCodes.
 *
 *************************************************************************************************/
@brief
Health tests are entropy tests and hence should be run when the configured mode is of PTRNG or
HRNG mode. 1024 bits of entropy data to be generated and the CTF flag to be monitored. TRNG
configured in HRNG + DF serves this purpose ((7+1)*128 = 1024 bits). Since this flag is monitored
for every reseed, no need to monitor CTF explicitly in this test. This API is to be called at
startup, after instantiation (and reseeding). Even for PTRNG mode, for this test, mode to be
configured as HRNG (as there is no reseed operation involved in PTRNG mode).

@param       InstancePtr is a pointer to the XTrngpsv instance to be worked on.

@return
- XTRNGPSV_SUCCESS if Health tests are successfully run.
- XTRNGPSV_ERROR_INVALID_PARAM if invalid parameter passed to this function (OR)
other error codes from the called functions as defined in XTrngpsv_ErrorCodes.
@brief Health tests are entropy tests and hence should be run when the configured mode is of PTRNG or HRNG mode . 1024 bits of entropy data to be generated and the CTF flag to be monitored . TRNG configured in HRNG + DF serves this purpose (( 7 + 1 ) * 128 = 1024 bits ) . Since this flag is monitored for every reseed no need to monitor CTF explicitly in this test . This API is to be called at startup after instantiation ( and reseeding ) . Even for PTRNG mode for this test mode to be configured as HRNG ( as there is no reseed operation involved in PTRNG mode ) . @param InstancePtr is a pointer to the XTrngpsv instance to be worked on . @return - XTRNGPSV_SUCCESS if Health tests are successfully run . - XTRNGPSV_ERROR_INVALID_PARAM if invalid parameter passed to this function ( OR ) other error codes from the called functions as defined in XTrngpsv_ErrorCodes .
s32 XTrngpsv_RunHealthTest(XTrngpsv *InstancePtr)
{
	s32 Status = XTRNGPSV_FAILURE;
	XTrngpsv_UsrCfg UsrCfgTests;
	if (InstancePtr == NULL) {
		Status = (s32)XTRNGPSV_ERROR_INVALID_PARAM;
		goto END;
	}
	(void)memset((u8*)&UsrCfgTests, 0, sizeof(UsrCfgTests));
	UsrCfgTests.Mode = XTRNGPSV_HRNG;
	UsrCfgTests.SeedLife = HEALTH_TEST_SEEDLIFE;
	UsrCfgTests.PredResistanceEn = XTRNGPSV_FALSE;
	UsrCfgTests.DFDisable = XTRNGPSV_FALSE;
	UsrCfgTests.DFLenMul = HEALTH_TEST_DFLENMUL;
	UsrCfgTests.PersStrPresent = XTRNGPSV_FALSE;
	UsrCfgTests.InitSeedPresent = XTRNGPSV_FALSE;
	Status = XTrngpsv_Instantiate(InstancePtr, &UsrCfgTests);
	if (Status != XTRNGPSV_SUCCESS) {
		goto SET_ERR;
	}
	Status = XTrngpsv_Uninstantiate(InstancePtr);
SET_ERR:
	if (Status != XTRNGPSV_SUCCESS) {
		InstancePtr->State = XTRNGPSV_ERROR;
	}
END:
	return Status;
}
s32 XTrngpsv_RunHealthTest ( XTrngpsv * InstancePtr ) { s32 Status = XTRNGPSV_FAILURE ; XTrngpsv_UsrCfg UsrCfgTests ; if ( InstancePtr == NULL ) { Status = ( s32 ) XTRNGPSV_ERROR_INVALID_PARAM ; goto END ; } ( void ) memset ( ( u8 * ) & UsrCfgTests , 0 , sizeof ( UsrCfgTests ) ) ; UsrCfgTests . Mode = XTRNGPSV_HRNG ; UsrCfgTests . SeedLife = HEALTH_TEST_SEEDLIFE ; UsrCfgTests . PredResistanceEn = XTRNGPSV_FALSE ; UsrCfgTests . DFDisable = XTRNGPSV_FALSE ; UsrCfgTests . DFLenMul = HEALTH_TEST_DFLENMUL ; UsrCfgTests . PersStrPresent = XTRNGPSV_FALSE ; UsrCfgTests . InitSeedPresent = XTRNGPSV_FALSE ; Status = XTrngpsv_Instantiate ( InstancePtr , & UsrCfgTests ) ; if ( Status != XTRNGPSV_SUCCESS ) { goto SET_ERR ; } Status = XTrngpsv_Uninstantiate ( InstancePtr ) ; SET_ERR : if ( Status != XTRNGPSV_SUCCESS ) { InstancePtr -> State = XTRNGPSV_ERROR ; } END : return Status ; }
@brief
 Health tests are entropy tests and hence should be run when the configured mode is of PTRNG or
 HRNG mode.
@brief Health tests are entropy tests and hence should be run when the configured mode is of PTRNG or HRNG mode .
/* Populate user config parameters of TRNGPSV driver */ /* Invoke Instantiate (which includes reseed) operation */ /* CTF is not being monitored explicitly here since that is done as part of Reseeding
	 * during Instantiation
	 */ /* Uninstantiate driver instance after Health Tests */