XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_tx.c
static void XHdcp1x_TxExchangeKsvs(XHdcp1x *InstancePtr,
		XHdcp1x_StateType *NextStatePtr)
{
	u8 Buf[8];

	/* Initialize Buf */
	memset(Buf, 0, 8);

	/* Update NextStatePtr - assume failure */
	*NextStatePtr = XHDCP1X_STATE_UNAUTHENTICATED;

	/* Read the Bksv from remote end */
	if (XHdcp1x_PortRead(InstancePtr, XHDCP1X_PORT_OFFSET_BKSV,
			Buf, 5) > 0) {
		u64 RemoteKsv = 0;

		/* Determine theRemoteKsv */
		XHDCP1X_PORT_BUF_TO_UINT(RemoteKsv, Buf,
				XHDCP1X_PORT_SIZE_BKSV * 8);

		/* Check for invalid */
		if (!XHdcp1x_TxIsKsvValid(RemoteKsv)) {
			XHdcp1x_TxDebugLog(InstancePtr, "Bksv invalid");
		}
		/* Check for revoked */
		else if (XHdcp1x_PlatformIsKsvRevoked(InstancePtr,
				RemoteKsv)) {
			XHdcp1x_TxDebugLog(InstancePtr, "Bksv is revoked");
		}
		/* Otherwise we're good to go */
		else {
			u64 LocalKsv = 0;
			u64 An = 0;
			u8 Buf_AInfo[XHDCP1X_PORT_SIZE_AINFO];

			/* Check for repeater and update InstancePtr */
			if (XHdcp1x_PortIsRepeater(InstancePtr)) {
				InstancePtr->Tx.Flags |= XVPHY_FLAG_IS_REPEATER;
			}
			else {
				InstancePtr->Tx.Flags &=
						~XVPHY_FLAG_IS_REPEATER;
			}

			/* Generate theAn */
			An = XHdcp1x_TxGenerateAn(InstancePtr);

			/* Save theAn into the state helper for use later */
			InstancePtr->Tx.StateHelper = An;

			/* Determine theLocalKsv */
			LocalKsv = XHdcp1x_CipherGetLocalKsv(InstancePtr);

			/* Load the cipher with the remote ksv */
			XHdcp1x_CipherSetRemoteKsv(InstancePtr, RemoteKsv);

			/* Clear AINFO */
			memset(Buf_AInfo, 0, XHDCP1X_PORT_SIZE_AINFO);
			XHdcp1x_PortWrite(InstancePtr, XHDCP1X_PORT_OFFSET_AINFO,
					Buf_AInfo, XHDCP1X_PORT_SIZE_AINFO);

			/* Send An to remote */
			XHDCP1X_PORT_UINT_TO_BUF(Buf, An,
					XHDCP1X_PORT_SIZE_AN * 8);
			XHdcp1x_PortWrite(InstancePtr, XHDCP1X_PORT_OFFSET_AN,
					Buf, XHDCP1X_PORT_SIZE_AN);

			/* Send AKsv to remote */
			XHDCP1X_PORT_UINT_TO_BUF(Buf, LocalKsv,
					XHDCP1X_PORT_SIZE_AKSV * 8);
			XHdcp1x_PortWrite(InstancePtr,
					XHDCP1X_PORT_OFFSET_AKSV,
					Buf, XHDCP1X_PORT_SIZE_AKSV);

			/* Update NextStatePtr */
			*NextStatePtr = XHDCP1X_STATE_COMPUTATIONS;
		}
	}
	/* Otherwise */
	else {
		/* Update the statistics */
		InstancePtr->Tx.Stats.ReadFailures++;
	}
}
/*****************************************************************************/
/**
* This function exchanges the ksvs between the two ends of the link.
*
* @param	InstancePtr is the HDCP state machine.
* @param	NextStatePtr is the next state.
*
* @return	None.
*
* @note		None.
*
******************************************************************************/
This function exchanges the ksvs between the two ends of the link.
This function exchanges the ksvs between the two ends of the link .
static void XHdcp1x_TxExchangeKsvs(XHdcp1x *InstancePtr,
		XHdcp1x_StateType *NextStatePtr)
{
	u8 Buf[8];
	memset(Buf, 0, 8);
	*NextStatePtr = XHDCP1X_STATE_UNAUTHENTICATED;
	if (XHdcp1x_PortRead(InstancePtr, XHDCP1X_PORT_OFFSET_BKSV,
			Buf, 5) > 0) {
		u64 RemoteKsv = 0;
		XHDCP1X_PORT_BUF_TO_UINT(RemoteKsv, Buf,
				XHDCP1X_PORT_SIZE_BKSV * 8);
		if (!XHdcp1x_TxIsKsvValid(RemoteKsv)) {
			XHdcp1x_TxDebugLog(InstancePtr, "Bksv invalid");
		}
		else if (XHdcp1x_PlatformIsKsvRevoked(InstancePtr,
				RemoteKsv)) {
			XHdcp1x_TxDebugLog(InstancePtr, "Bksv is revoked");
		}
		else {
			u64 LocalKsv = 0;
			u64 An = 0;
			u8 Buf_AInfo[XHDCP1X_PORT_SIZE_AINFO];
			if (XHdcp1x_PortIsRepeater(InstancePtr)) {
				InstancePtr->Tx.Flags |= XVPHY_FLAG_IS_REPEATER;
			}
			else {
				InstancePtr->Tx.Flags &=
						~XVPHY_FLAG_IS_REPEATER;
			}
			An = XHdcp1x_TxGenerateAn(InstancePtr);
			InstancePtr->Tx.StateHelper = An;
			LocalKsv = XHdcp1x_CipherGetLocalKsv(InstancePtr);
			XHdcp1x_CipherSetRemoteKsv(InstancePtr, RemoteKsv);
			memset(Buf_AInfo, 0, XHDCP1X_PORT_SIZE_AINFO);
			XHdcp1x_PortWrite(InstancePtr, XHDCP1X_PORT_OFFSET_AINFO,
					Buf_AInfo, XHDCP1X_PORT_SIZE_AINFO);
			XHDCP1X_PORT_UINT_TO_BUF(Buf, An,
					XHDCP1X_PORT_SIZE_AN * 8);
			XHdcp1x_PortWrite(InstancePtr, XHDCP1X_PORT_OFFSET_AN,
					Buf, XHDCP1X_PORT_SIZE_AN);
			XHDCP1X_PORT_UINT_TO_BUF(Buf, LocalKsv,
					XHDCP1X_PORT_SIZE_AKSV * 8);
			XHdcp1x_PortWrite(InstancePtr,
					XHDCP1X_PORT_OFFSET_AKSV,
					Buf, XHDCP1X_PORT_SIZE_AKSV);
			*NextStatePtr = XHDCP1X_STATE_COMPUTATIONS;
		}
	}
	else {
		InstancePtr->Tx.Stats.ReadFailures++;
	}
}
static void XHdcp1x_TxExchangeKsvs ( XHdcp1x * InstancePtr , XHdcp1x_StateType * NextStatePtr ) { u8 Buf [ 8 ] ; memset ( Buf , 0 , 8 ) ; * NextStatePtr = XHDCP1X_STATE_UNAUTHENTICATED ; if ( XHdcp1x_PortRead ( InstancePtr , XHDCP1X_PORT_OFFSET_BKSV , Buf , 5 ) > 0 ) { u64 RemoteKsv = 0 ; XHDCP1X_PORT_BUF_TO_UINT ( RemoteKsv , Buf , XHDCP1X_PORT_SIZE_BKSV * 8 ) ; if ( ! XHdcp1x_TxIsKsvValid ( RemoteKsv ) ) { XHdcp1x_TxDebugLog ( InstancePtr , " " ) ; } else if ( XHdcp1x_PlatformIsKsvRevoked ( InstancePtr , RemoteKsv ) ) { XHdcp1x_TxDebugLog ( InstancePtr , " " ) ; } else { u64 LocalKsv = 0 ; u64 An = 0 ; u8 Buf_AInfo [ XHDCP1X_PORT_SIZE_AINFO ] ; if ( XHdcp1x_PortIsRepeater ( InstancePtr ) ) { InstancePtr -> Tx . Flags |= XVPHY_FLAG_IS_REPEATER ; } else { InstancePtr -> Tx . Flags &= ~ XVPHY_FLAG_IS_REPEATER ; } An = XHdcp1x_TxGenerateAn ( InstancePtr ) ; InstancePtr -> Tx . StateHelper = An ; LocalKsv = XHdcp1x_CipherGetLocalKsv ( InstancePtr ) ; XHdcp1x_CipherSetRemoteKsv ( InstancePtr , RemoteKsv ) ; memset ( Buf_AInfo , 0 , XHDCP1X_PORT_SIZE_AINFO ) ; XHdcp1x_PortWrite ( InstancePtr , XHDCP1X_PORT_OFFSET_AINFO , Buf_AInfo , XHDCP1X_PORT_SIZE_AINFO ) ; XHDCP1X_PORT_UINT_TO_BUF ( Buf , An , XHDCP1X_PORT_SIZE_AN * 8 ) ; XHdcp1x_PortWrite ( InstancePtr , XHDCP1X_PORT_OFFSET_AN , Buf , XHDCP1X_PORT_SIZE_AN ) ; XHDCP1X_PORT_UINT_TO_BUF ( Buf , LocalKsv , XHDCP1X_PORT_SIZE_AKSV * 8 ) ; XHdcp1x_PortWrite ( InstancePtr , XHDCP1X_PORT_OFFSET_AKSV , Buf , XHDCP1X_PORT_SIZE_AKSV ) ; * NextStatePtr = XHDCP1X_STATE_COMPUTATIONS ; } } else { InstancePtr -> Tx . Stats . ReadFailures ++ ; } }
This function exchanges the ksvs between the two ends of the link.
This function exchanges the ksvs between the two ends of the link .
/* Initialize Buf */ /* Update NextStatePtr - assume failure */ /* Read the Bksv from remote end */ /* Determine theRemoteKsv */ /* Check for invalid */ /* Check for revoked */ /* Otherwise we're good to go */ /* Check for repeater and update InstancePtr */ /* Generate theAn */ /* Save theAn into the state helper for use later */ /* Determine theLocalKsv */ /* Load the cipher with the remote ksv */ /* Clear AINFO */ /* Send An to remote */ /* Send AKsv to remote */ /* Update NextStatePtr */ /* Otherwise */ /* Update the statistics */