lib/sw_services/xilnvm/examples/xilnvm_efuse_versal_client_example.c
static int XilNvm_EfuseInitAesKeys(XNvm_EfuseDataAddr *WriteEfuse,
	XNvm_EfuseAesKeys *AesKeys)
{
	int Status = XST_FAILURE;

	AesKeys->PrgmAesKey = XNVM_EFUSE_WRITE_AES_KEY;
	AesKeys->PrgmUserKey0 = XNVM_EFUSE_WRITE_USER_KEY_0;
	AesKeys->PrgmUserKey1 = XNVM_EFUSE_WRITE_USER_KEY_1;

	if (AesKeys->PrgmAesKey == TRUE) {
		Status = XilNvm_PrepareAesKeyForWrite(XNVM_EFUSE_AES_KEY,
					(u8 *)AesKeys->AesKey,
					XNVM_EFUSE_AES_KEY_LEN_IN_BITS);
		if (Status != XST_SUCCESS) {
			goto END;
		}
	}
	if (AesKeys->PrgmUserKey0 == TRUE) {
		Status = XilNvm_PrepareAesKeyForWrite(XNVM_EFUSE_USER_KEY_0,
					(u8 *)AesKeys->UserKey0,
					XNVM_EFUSE_AES_KEY_LEN_IN_BITS);
		if (Status != XST_SUCCESS) {
			goto END;
		}
	}
	if (AesKeys->PrgmUserKey1 == TRUE) {
		Status = XilNvm_PrepareAesKeyForWrite(XNVM_EFUSE_USER_KEY_1,
					(u8 *)AesKeys->UserKey1,
					XNVM_EFUSE_AES_KEY_LEN_IN_BITS);
		if (Status != XST_SUCCESS) {
			goto END;
		}
	}

	if (Status == XST_SUCCESS) {
		Xil_DCacheFlushRange((UINTPTR)AesKeys,
			sizeof(XNvm_EfuseAesKeys));
		WriteEfuse->AesKeyAddr = (UINTPTR)AesKeys;
	}

	Status = XST_SUCCESS;

END:
	return Status;
}
/****************************************************************************/
/**
 * This function is used to initialize XNvm_EfuseAesKeys structure with user
 * provided data and assign it to global struture XNvm_EfuseDataAddr to program
 * below eFuses.
 * - AES key
 * - AES User keys
 *
 * typedef struct {
 *	u8 PrgmAesKey;
 *	u8 PrgmUserKey0;
 *	u8 PrgmUserKey1;
 *	u32 AesKey[XNVM_EFUSE_AES_KEY_LEN_IN_WORDS];
 *	u32 UserKey0[XNVM_EFUSE_AES_KEY_LEN_IN_WORDS];
 *	u32 UserKey1[XNVM_EFUSE_AES_KEY_LEN_IN_WORDS];
 * }XNvm_EfuseAesKeys;
 *
 * @param	WriteEfuse	Pointer to XNvm_EfuseDataAddr structure.
 *
 * @param 	AesKeys		Pointer to XNvm_EfuseAesKeys structure.
 *
 * @return
 *		- XST_SUCCESS - If initialization of XNvm_EfuseAesKeys structure
 *				is successful
 *		- ErrorCode - On Failure
 *
 ******************************************************************************/
This function is used to initialize XNvm_EfuseAesKeys structure with user
provided data and assign it to global struture XNvm_EfuseDataAddr to program
below eFuses.
- AES key
- AES User keys







@return
- XST_SUCCESS - If initialization of XNvm_EfuseAesKeys structure
is successful
- ErrorCode - On Failure
This function is used to initialize XNvm_EfuseAesKeys structure with user provided data and assign it to global struture XNvm_EfuseDataAddr to program below eFuses . - AES key - AES User keys @return - XST_SUCCESS - If initialization of XNvm_EfuseAesKeys structure is successful - ErrorCode - On Failure
static int XilNvm_EfuseInitAesKeys(XNvm_EfuseDataAddr *WriteEfuse,
	XNvm_EfuseAesKeys *AesKeys)
{
	int Status = XST_FAILURE;
	AesKeys->PrgmAesKey = XNVM_EFUSE_WRITE_AES_KEY;
	AesKeys->PrgmUserKey0 = XNVM_EFUSE_WRITE_USER_KEY_0;
	AesKeys->PrgmUserKey1 = XNVM_EFUSE_WRITE_USER_KEY_1;
	if (AesKeys->PrgmAesKey == TRUE) {
		Status = XilNvm_PrepareAesKeyForWrite(XNVM_EFUSE_AES_KEY,
					(u8 *)AesKeys->AesKey,
					XNVM_EFUSE_AES_KEY_LEN_IN_BITS);
		if (Status != XST_SUCCESS) {
			goto END;
		}
	}
	if (AesKeys->PrgmUserKey0 == TRUE) {
		Status = XilNvm_PrepareAesKeyForWrite(XNVM_EFUSE_USER_KEY_0,
					(u8 *)AesKeys->UserKey0,
					XNVM_EFUSE_AES_KEY_LEN_IN_BITS);
		if (Status != XST_SUCCESS) {
			goto END;
		}
	}
	if (AesKeys->PrgmUserKey1 == TRUE) {
		Status = XilNvm_PrepareAesKeyForWrite(XNVM_EFUSE_USER_KEY_1,
					(u8 *)AesKeys->UserKey1,
					XNVM_EFUSE_AES_KEY_LEN_IN_BITS);
		if (Status != XST_SUCCESS) {
			goto END;
		}
	}
	if (Status == XST_SUCCESS) {
		Xil_DCacheFlushRange((UINTPTR)AesKeys,
			sizeof(XNvm_EfuseAesKeys));
		WriteEfuse->AesKeyAddr = (UINTPTR)AesKeys;
	}
	Status = XST_SUCCESS;
END:
	return Status;
}
static int XilNvm_EfuseInitAesKeys ( XNvm_EfuseDataAddr * WriteEfuse , XNvm_EfuseAesKeys * AesKeys ) { int Status = XST_FAILURE ; AesKeys -> PrgmAesKey = XNVM_EFUSE_WRITE_AES_KEY ; AesKeys -> PrgmUserKey0 = XNVM_EFUSE_WRITE_USER_KEY_0 ; AesKeys -> PrgmUserKey1 = XNVM_EFUSE_WRITE_USER_KEY_1 ; if ( AesKeys -> PrgmAesKey == TRUE ) { Status = XilNvm_PrepareAesKeyForWrite ( XNVM_EFUSE_AES_KEY , ( u8 * ) AesKeys -> AesKey , XNVM_EFUSE_AES_KEY_LEN_IN_BITS ) ; if ( Status != XST_SUCCESS ) { goto END ; } } if ( AesKeys -> PrgmUserKey0 == TRUE ) { Status = XilNvm_PrepareAesKeyForWrite ( XNVM_EFUSE_USER_KEY_0 , ( u8 * ) AesKeys -> UserKey0 , XNVM_EFUSE_AES_KEY_LEN_IN_BITS ) ; if ( Status != XST_SUCCESS ) { goto END ; } } if ( AesKeys -> PrgmUserKey1 == TRUE ) { Status = XilNvm_PrepareAesKeyForWrite ( XNVM_EFUSE_USER_KEY_1 , ( u8 * ) AesKeys -> UserKey1 , XNVM_EFUSE_AES_KEY_LEN_IN_BITS ) ; if ( Status != XST_SUCCESS ) { goto END ; } } if ( Status == XST_SUCCESS ) { Xil_DCacheFlushRange ( ( UINTPTR ) AesKeys , sizeof ( XNvm_EfuseAesKeys ) ) ; WriteEfuse -> AesKeyAddr = ( UINTPTR ) AesKeys ; } Status = XST_SUCCESS ; END : return Status ; }
This function is used to initialize XNvm_EfuseAesKeys structure with user
 provided data and assign it to global struture XNvm_EfuseDataAddr to program
 below eFuses.
This function is used to initialize XNvm_EfuseAesKeys structure with user provided data and assign it to global struture XNvm_EfuseDataAddr to program below eFuses .