XilinxProcessorIPLib/drivers/hdcp22_rx_dp/src/xhdcp22_rx.c
static void *XHdcp22Rx_StateB2(XHdcp22_Rx *InstancePtr)
{
	/* Verify arguments */
	Xil_AssertNonvoid(InstancePtr != NULL);

	int Status;
	XHdcp22_Rx_Message *MsgPtr = (XHdcp22_Rx_Message*)InstancePtr->MessageBuffer;

	/* Update state */
	InstancePtr->Info.AuthenticationStatus = XHDCP22_RX_AUTHENTICATION_BUSY;
	InstancePtr->Info.CurrentState = InstancePtr->Info.NextState;

	/* Check error condition */
	if(InstancePtr->Info.ErrorFlag & XHDCP22_RX_ERROR_FLAG_DDC_BURST)
	{
		XHdcp22Rx_ResetDdc(InstancePtr, FALSE, TRUE, TRUE, TRUE);
		XHdcp22Rx_ResetAfterError(InstancePtr);
		return (void *)XHdcp22Rx_StateB0;
	}

	/*This clears H/Pairing_Info read done interrupt*/
	XHdcp22Rx_IsReadMessageComplete(InstancePtr);

	/* Check if message is available */
	InstancePtr->MessageSize = XHdcp22Rx_PollMessage(InstancePtr);

	/* Message handling */
	if(InstancePtr->MessageSize > 0)
	{
		switch(MsgPtr->MsgId)
		{
		case XHDCP22_RX_MSG_ID_AKEINIT: /* Transition B2->B1 */
			Status = XHdcp22Rx_ProcessMessageAKEInit(InstancePtr);
			if(Status == XST_SUCCESS)
			{
				InstancePtr->Info.NextState = XHDCP22_RX_STATE_B1_SEND_AKESENDCERT;
				return (void *)XHdcp22Rx_StateB1;
			}
			XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_ERROR, XHDCP22_RX_ERROR_FLAG_PROCESSING_AKEINIT);
			XHdcp22Rx_ResetAfterError(InstancePtr);
			return (void *)XHdcp22Rx_StateB0;
		case XHDCP22_RX_MSG_ID_LCINIT:
			/* Maximum of 1024 locality check attempts allowed */
			if(InstancePtr->Info.CurrentState == XHDCP22_RX_STATE_B1_WAIT_LCINIT ||
				InstancePtr->Info.CurrentState == XHDCP22_RX_STATE_B2_WAIT_SKESENDEKS)
			{
				if(InstancePtr->Info.LCInitAttempts <= XHDCP22_RX_MAX_LCINIT)
				{
					Status = XHdcp22Rx_ProcessMessageLCInit(InstancePtr);
					if(Status == XST_SUCCESS)
					{
						InstancePtr->Info.NextState = XHDCP22_RX_STATE_B2_SEND_LCSENDLPRIME;
						break;
					}
				}
				else
				{
					XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_ERROR, XHDCP22_RX_ERROR_FLAG_MAX_LCINIT_ATTEMPTS);
				}
			}
			XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_ERROR, XHDCP22_RX_ERROR_FLAG_PROCESSING_LCINIT);
			XHdcp22Rx_ResetAfterError(InstancePtr);
			return (void *)XHdcp22Rx_StateB0;
		case XHDCP22_RX_MSG_ID_SKESENDEKS: /* Transition B2->B3 */
			if(InstancePtr->Info.CurrentState == XHDCP22_RX_STATE_B2_WAIT_SKESENDEKS)
			{
			InstancePtr->Info.NextState = XHDCP22_RX_STATE_B3_COMPUTE_KS;
			return (void *)XHdcp22Rx_StateB3;
			}
			XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_ERROR, XHDCP22_RX_ERROR_FLAG_PROCESSING_SKESENDEKS);
			XHdcp22Rx_ResetAfterError(InstancePtr);
			return (void *)XHdcp22Rx_StateB0;
		default:
			XHdcp22Rx_ResetAfterError(InstancePtr);
			return (void *)XHdcp22Rx_StateB0;
		}
	}

	/* Message send */
	switch(InstancePtr->Info.NextState)
	{
	case XHDCP22_RX_STATE_B2_SEND_LCSENDLPRIME:
		if(XHdcp22Rx_IsReadMessageComplete(InstancePtr) == TRUE)
		{
			Status = XHdcp22Rx_SendMessageLCSendLPrime(InstancePtr);
			InstancePtr->Info.NextState = XHDCP22_RX_STATE_B2_WAIT_SKESENDEKS;
		}
		break;
	default:
		break;
	}

	return (void *)XHdcp22Rx_StateB2; /* Transition B2->B2 */
}
/*****************************************************************************/
/**
* This function implements the Receiver State B2 (Compute_LPrime). The
* receiver computes LPrime required during locality check and makes
* LCSendLPrime message available for reading by the transmitter.
*
* @param    InstancePtr is a pointer to the XHdcp22_Rx core instance.
*
* @return   Pointer to the function that implements the next state.
*
* @note     When an unexpected or malformed message is received
*           the system is reset to the default state B0 to allow
*           graceful recovery from error.
******************************************************************************/
This function implements the Receiver State B2 (Compute_LPrime). The
receiver computes LPrime required during locality check and makes
LCSendLPrime message available for reading by the transmitter.
This function implements the Receiver State B2 ( Compute_LPrime ) . The receiver computes LPrime required during locality check and makes LCSendLPrime message available for reading by the transmitter .
static void *XHdcp22Rx_StateB2(XHdcp22_Rx *InstancePtr)
{
	Xil_AssertNonvoid(InstancePtr != NULL);
	int Status;
	XHdcp22_Rx_Message *MsgPtr = (XHdcp22_Rx_Message*)InstancePtr->MessageBuffer;
	InstancePtr->Info.AuthenticationStatus = XHDCP22_RX_AUTHENTICATION_BUSY;
	InstancePtr->Info.CurrentState = InstancePtr->Info.NextState;
	if(InstancePtr->Info.ErrorFlag & XHDCP22_RX_ERROR_FLAG_DDC_BURST)
	{
		XHdcp22Rx_ResetDdc(InstancePtr, FALSE, TRUE, TRUE, TRUE);
		XHdcp22Rx_ResetAfterError(InstancePtr);
		return (void *)XHdcp22Rx_StateB0;
	}
	XHdcp22Rx_IsReadMessageComplete(InstancePtr);
	InstancePtr->MessageSize = XHdcp22Rx_PollMessage(InstancePtr);
	if(InstancePtr->MessageSize > 0)
	{
		switch(MsgPtr->MsgId)
		{
		case XHDCP22_RX_MSG_ID_AKEINIT: 
			Status = XHdcp22Rx_ProcessMessageAKEInit(InstancePtr);
			if(Status == XST_SUCCESS)
			{
				InstancePtr->Info.NextState = XHDCP22_RX_STATE_B1_SEND_AKESENDCERT;
				return (void *)XHdcp22Rx_StateB1;
			}
			XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_ERROR, XHDCP22_RX_ERROR_FLAG_PROCESSING_AKEINIT);
			XHdcp22Rx_ResetAfterError(InstancePtr);
			return (void *)XHdcp22Rx_StateB0;
		case XHDCP22_RX_MSG_ID_LCINIT:
			if(InstancePtr->Info.CurrentState == XHDCP22_RX_STATE_B1_WAIT_LCINIT ||
				InstancePtr->Info.CurrentState == XHDCP22_RX_STATE_B2_WAIT_SKESENDEKS)
			{
				if(InstancePtr->Info.LCInitAttempts <= XHDCP22_RX_MAX_LCINIT)
				{
					Status = XHdcp22Rx_ProcessMessageLCInit(InstancePtr);
					if(Status == XST_SUCCESS)
					{
						InstancePtr->Info.NextState = XHDCP22_RX_STATE_B2_SEND_LCSENDLPRIME;
						break;
					}
				}
				else
				{
					XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_ERROR, XHDCP22_RX_ERROR_FLAG_MAX_LCINIT_ATTEMPTS);
				}
			}
			XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_ERROR, XHDCP22_RX_ERROR_FLAG_PROCESSING_LCINIT);
			XHdcp22Rx_ResetAfterError(InstancePtr);
			return (void *)XHdcp22Rx_StateB0;
		case XHDCP22_RX_MSG_ID_SKESENDEKS: 
			if(InstancePtr->Info.CurrentState == XHDCP22_RX_STATE_B2_WAIT_SKESENDEKS)
			{
			InstancePtr->Info.NextState = XHDCP22_RX_STATE_B3_COMPUTE_KS;
			return (void *)XHdcp22Rx_StateB3;
			}
			XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_ERROR, XHDCP22_RX_ERROR_FLAG_PROCESSING_SKESENDEKS);
			XHdcp22Rx_ResetAfterError(InstancePtr);
			return (void *)XHdcp22Rx_StateB0;
		default:
			XHdcp22Rx_ResetAfterError(InstancePtr);
			return (void *)XHdcp22Rx_StateB0;
		}
	}
	switch(InstancePtr->Info.NextState)
	{
	case XHDCP22_RX_STATE_B2_SEND_LCSENDLPRIME:
		if(XHdcp22Rx_IsReadMessageComplete(InstancePtr) == TRUE)
		{
			Status = XHdcp22Rx_SendMessageLCSendLPrime(InstancePtr);
			InstancePtr->Info.NextState = XHDCP22_RX_STATE_B2_WAIT_SKESENDEKS;
		}
		break;
	default:
		break;
	}
	return (void *)XHdcp22Rx_StateB2; 
}
static void * XHdcp22Rx_StateB2 ( XHdcp22_Rx * InstancePtr ) { Xil_AssertNonvoid ( InstancePtr != NULL ) ; int Status ; XHdcp22_Rx_Message * MsgPtr = ( XHdcp22_Rx_Message * ) InstancePtr -> MessageBuffer ; InstancePtr -> Info . AuthenticationStatus = XHDCP22_RX_AUTHENTICATION_BUSY ; InstancePtr -> Info . CurrentState = InstancePtr -> Info . NextState ; if ( InstancePtr -> Info . ErrorFlag & XHDCP22_RX_ERROR_FLAG_DDC_BURST ) { XHdcp22Rx_ResetDdc ( InstancePtr , FALSE , TRUE , TRUE , TRUE ) ; XHdcp22Rx_ResetAfterError ( InstancePtr ) ; return ( void * ) XHdcp22Rx_StateB0 ; } XHdcp22Rx_IsReadMessageComplete ( InstancePtr ) ; InstancePtr -> MessageSize = XHdcp22Rx_PollMessage ( InstancePtr ) ; if ( InstancePtr -> MessageSize > 0 ) { switch ( MsgPtr -> MsgId ) { case XHDCP22_RX_MSG_ID_AKEINIT : Status = XHdcp22Rx_ProcessMessageAKEInit ( InstancePtr ) ; if ( Status == XST_SUCCESS ) { InstancePtr -> Info . NextState = XHDCP22_RX_STATE_B1_SEND_AKESENDCERT ; return ( void * ) XHdcp22Rx_StateB1 ; } XHdcp22Rx_LogWr ( InstancePtr , XHDCP22_RX_LOG_EVT_ERROR , XHDCP22_RX_ERROR_FLAG_PROCESSING_AKEINIT ) ; XHdcp22Rx_ResetAfterError ( InstancePtr ) ; return ( void * ) XHdcp22Rx_StateB0 ; case XHDCP22_RX_MSG_ID_LCINIT : if ( InstancePtr -> Info . CurrentState == XHDCP22_RX_STATE_B1_WAIT_LCINIT || InstancePtr -> Info . CurrentState == XHDCP22_RX_STATE_B2_WAIT_SKESENDEKS ) { if ( InstancePtr -> Info . LCInitAttempts <= XHDCP22_RX_MAX_LCINIT ) { Status = XHdcp22Rx_ProcessMessageLCInit ( InstancePtr ) ; if ( Status == XST_SUCCESS ) { InstancePtr -> Info . NextState = XHDCP22_RX_STATE_B2_SEND_LCSENDLPRIME ; break ; } } else { XHdcp22Rx_LogWr ( InstancePtr , XHDCP22_RX_LOG_EVT_ERROR , XHDCP22_RX_ERROR_FLAG_MAX_LCINIT_ATTEMPTS ) ; } } XHdcp22Rx_LogWr ( InstancePtr , XHDCP22_RX_LOG_EVT_ERROR , XHDCP22_RX_ERROR_FLAG_PROCESSING_LCINIT ) ; XHdcp22Rx_ResetAfterError ( InstancePtr ) ; return ( void * ) XHdcp22Rx_StateB0 ; case XHDCP22_RX_MSG_ID_SKESENDEKS : if ( InstancePtr -> Info . CurrentState == XHDCP22_RX_STATE_B2_WAIT_SKESENDEKS ) { InstancePtr -> Info . NextState = XHDCP22_RX_STATE_B3_COMPUTE_KS ; return ( void * ) XHdcp22Rx_StateB3 ; } XHdcp22Rx_LogWr ( InstancePtr , XHDCP22_RX_LOG_EVT_ERROR , XHDCP22_RX_ERROR_FLAG_PROCESSING_SKESENDEKS ) ; XHdcp22Rx_ResetAfterError ( InstancePtr ) ; return ( void * ) XHdcp22Rx_StateB0 ; default : XHdcp22Rx_ResetAfterError ( InstancePtr ) ; return ( void * ) XHdcp22Rx_StateB0 ; } } switch ( InstancePtr -> Info . NextState ) { case XHDCP22_RX_STATE_B2_SEND_LCSENDLPRIME : if ( XHdcp22Rx_IsReadMessageComplete ( InstancePtr ) == TRUE ) { Status = XHdcp22Rx_SendMessageLCSendLPrime ( InstancePtr ) ; InstancePtr -> Info . NextState = XHDCP22_RX_STATE_B2_WAIT_SKESENDEKS ; } break ; default : break ; } return ( void * ) XHdcp22Rx_StateB2 ; }
This function implements the Receiver State B2 (Compute_LPrime).
This function implements the Receiver State B2 ( Compute_LPrime ) .
/* Verify arguments */ /* Update state */ /* Check error condition */ /*This clears H/Pairing_Info read done interrupt*/ /* Check if message is available */ /* Message handling */ /* Transition B2->B1 */ /* Maximum of 1024 locality check attempts allowed */ /* Transition B2->B3 */ /* Message send */ /* Transition B2->B2 */