XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_cipher.c
u64 XHdcp1x_CipherGetLocalKsv(const XHdcp1x *InstancePtr)
{
	u32 Val = 0;
	u32 Guard = 0x400ul;
	u64 Ksv = 0;

	/* Verify arguments. */
	Xil_AssertNonvoid(InstancePtr != NULL);

	/* Check that it is not disabled */
	if (!XHdcp1x_CipherIsEnabled(InstancePtr)) {
		return (Ksv);
	}

	/* Check if the local ksv is not available */
	Val  = XHdcp1x_ReadReg(InstancePtr->Config.BaseAddress,
		XHDCP1X_CIPHER_REG_KEYMGMT_STATUS);
	Val &= XHDCP1X_CIPHER_BITMASK_KEYMGMT_STATUS_KSV_READY;
	if (Val == 0) {
		/* Abort any running Km calculation just in case */
		Val = XHdcp1x_ReadReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL);
		Val |= XHDCP1X_CIPHER_BITMASK_KEYMGMT_CONTROL_ABORT_Km;
		XHdcp1x_WriteReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL, Val);
		Val &= ~XHDCP1X_CIPHER_BITMASK_KEYMGMT_CONTROL_ABORT_Km;
		XHdcp1x_WriteReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL, Val);

		/* Load the local ksv */
		Val = XHdcp1x_ReadReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL);
		Val |= XHDCP1X_CIPHER_BITMASK_KEYMGMT_CONTROL_LOCAL_KSV;
		XHdcp1x_WriteReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL, Val);
		Val &= ~XHDCP1X_CIPHER_BITMASK_KEYMGMT_CONTROL_LOCAL_KSV;
		XHdcp1x_WriteReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL, Val);

		/* Wait until local KSV available */
		while ((!XHdcp1x_CipherLocalKsvReady(InstancePtr)) &&
			(--Guard > 0));
	}

	/* Confirm no timeout */
	if (Guard != 0) {
		/* Update Ksv */
		Ksv = XHdcp1x_ReadReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KSV_LOCAL_H);
		Ksv &= 0xFFul;
		Ksv <<= 32;
		Ksv |= XHdcp1x_ReadReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KSV_LOCAL_L);
	}

	return (Ksv);
}
/*****************************************************************************/
/**
* This function reads the local KSV value from the cipher.
*
* @param	InstancePtr is the device to query.
*
* @return	The local KSV value.
*
* @note		None.
*
******************************************************************************/
This function reads the local KSV value from the cipher.
This function reads the local KSV value from the cipher .
u64 XHdcp1x_CipherGetLocalKsv(const XHdcp1x *InstancePtr)
{
	u32 Val = 0;
	u32 Guard = 0x400ul;
	u64 Ksv = 0;
	Xil_AssertNonvoid(InstancePtr != NULL);
	if (!XHdcp1x_CipherIsEnabled(InstancePtr)) {
		return (Ksv);
	}
	Val  = XHdcp1x_ReadReg(InstancePtr->Config.BaseAddress,
		XHDCP1X_CIPHER_REG_KEYMGMT_STATUS);
	Val &= XHDCP1X_CIPHER_BITMASK_KEYMGMT_STATUS_KSV_READY;
	if (Val == 0) {
		Val = XHdcp1x_ReadReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL);
		Val |= XHDCP1X_CIPHER_BITMASK_KEYMGMT_CONTROL_ABORT_Km;
		XHdcp1x_WriteReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL, Val);
		Val &= ~XHDCP1X_CIPHER_BITMASK_KEYMGMT_CONTROL_ABORT_Km;
		XHdcp1x_WriteReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL, Val);
		Val = XHdcp1x_ReadReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL);
		Val |= XHDCP1X_CIPHER_BITMASK_KEYMGMT_CONTROL_LOCAL_KSV;
		XHdcp1x_WriteReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL, Val);
		Val &= ~XHDCP1X_CIPHER_BITMASK_KEYMGMT_CONTROL_LOCAL_KSV;
		XHdcp1x_WriteReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL, Val);
		while ((!XHdcp1x_CipherLocalKsvReady(InstancePtr)) &&
			(--Guard > 0));
	}
	if (Guard != 0) {
		Ksv = XHdcp1x_ReadReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KSV_LOCAL_H);
		Ksv &= 0xFFul;
		Ksv <<= 32;
		Ksv |= XHdcp1x_ReadReg(InstancePtr->Config.BaseAddress,
			XHDCP1X_CIPHER_REG_KSV_LOCAL_L);
	}
	return (Ksv);
}
u64 XHdcp1x_CipherGetLocalKsv ( const XHdcp1x * InstancePtr ) { u32 Val = 0 ; u32 Guard = 0x400ul ; u64 Ksv = 0 ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; if ( ! XHdcp1x_CipherIsEnabled ( InstancePtr ) ) { return ( Ksv ) ; } Val = XHdcp1x_ReadReg ( InstancePtr -> Config . BaseAddress , XHDCP1X_CIPHER_REG_KEYMGMT_STATUS ) ; Val &= XHDCP1X_CIPHER_BITMASK_KEYMGMT_STATUS_KSV_READY ; if ( Val == 0 ) { Val = XHdcp1x_ReadReg ( InstancePtr -> Config . BaseAddress , XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL ) ; Val |= XHDCP1X_CIPHER_BITMASK_KEYMGMT_CONTROL_ABORT_Km ; XHdcp1x_WriteReg ( InstancePtr -> Config . BaseAddress , XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL , Val ) ; Val &= ~ XHDCP1X_CIPHER_BITMASK_KEYMGMT_CONTROL_ABORT_Km ; XHdcp1x_WriteReg ( InstancePtr -> Config . BaseAddress , XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL , Val ) ; Val = XHdcp1x_ReadReg ( InstancePtr -> Config . BaseAddress , XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL ) ; Val |= XHDCP1X_CIPHER_BITMASK_KEYMGMT_CONTROL_LOCAL_KSV ; XHdcp1x_WriteReg ( InstancePtr -> Config . BaseAddress , XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL , Val ) ; Val &= ~ XHDCP1X_CIPHER_BITMASK_KEYMGMT_CONTROL_LOCAL_KSV ; XHdcp1x_WriteReg ( InstancePtr -> Config . BaseAddress , XHDCP1X_CIPHER_REG_KEYMGMT_CONTROL , Val ) ; while ( ( ! XHdcp1x_CipherLocalKsvReady ( InstancePtr ) ) && ( -- Guard > 0 ) ) ; } if ( Guard != 0 ) { Ksv = XHdcp1x_ReadReg ( InstancePtr -> Config . BaseAddress , XHDCP1X_CIPHER_REG_KSV_LOCAL_H ) ; Ksv &= 0xFFul ; Ksv <<= 32 ; Ksv |= XHdcp1x_ReadReg ( InstancePtr -> Config . BaseAddress , XHDCP1X_CIPHER_REG_KSV_LOCAL_L ) ; } return ( Ksv ) ; }
This function reads the local KSV value from the cipher.
This function reads the local KSV value from the cipher .
/* Verify arguments. */ /* Check that it is not disabled */ /* Check if the local ksv is not available */ /* Abort any running Km calculation just in case */ /* Load the local ksv */ /* Wait until local KSV available */ /* Confirm no timeout */ /* Update Ksv */