XilinxProcessorIPLib/drivers/hdcp22_tx/src/xhdcp22_tx_test.c
static void XHdcp22Tx_TestReadMsg(u8* BufferPtr, u32 TestFlags)
{
	int BytesWritten = 0;
	u8 MsgId = BufferPtr[0]; /* MessageId */

	u8 Index = XHDCP22_TX_TEST_VECTOR_R2_INDEX;
	if (TEST_FLAG_SET(XHDCP22_TX_TEST_USE_TEST_VECTOR_R1, TestFlags)) {
		Index = XHDCP22_TX_TEST_VECTOR_R1_INDEX;
	}

	/* Write MessageId*/
	BufferPtr[BytesWritten++] = MsgId;
	switch (MsgId)
	{
		case XHDCP22_TX_AKE_SEND_CERT:
			/* Write HDCP22 RX certificate */
			memcpy(&BufferPtr[1], XHdcp22_Tx_Test_CertRx[Index],
			       XHDCP22_TX_CERT_SIZE);
			BytesWritten += XHDCP22_TX_CERT_SIZE;

			/* Write Rrx */
			memcpy(&BufferPtr[BytesWritten], XHdcp22_Tx_Test_Rrx[Index],
			       XHDCP22_TX_RRX_SIZE);
			BytesWritten += XHDCP22_TX_RRX_SIZE;

			/* Write RxCaps */
			memcpy(&BufferPtr[BytesWritten], XHdcp22_Tx_Test_RxCaps[Index],
			       XHDCP22_TX_RXCAPS_SIZE);
			if (TEST_FLAG_SET(XHDCP22_TX_TEST_CERT_RX, TestFlags) &&
			    TEST_FLAG_SET(XHDCP22_TX_TEST_INVALID_VALUE, TestFlags)) {
				BufferPtr[1] = ~BufferPtr[1];
			}
		break;
		case XHDCP22_TX_AKE_SEND_H_PRIME:
			/* Write HDCP22 H'Prime */
			memcpy(&BufferPtr[1], XHdcp22_Tx_Test_H1[Index], XHDCP22_TX_H_PRIME_SIZE);
			if (TEST_FLAG_SET(XHDCP22_TX_TEST_H1, TestFlags) &&
			    TEST_FLAG_SET(XHDCP22_TX_TEST_INVALID_VALUE, TestFlags)) {
				BufferPtr[1] = ~BufferPtr[1];
			}
		break;
		case XHDCP22_TX_AKE_SEND_PAIRING_INFO:
			/* Write Ekh(Km) */
			memcpy(&BufferPtr[1], XHdcp22_Tx_Test_Ekh_Km[Index],
			       XHDCP22_TX_EKH_KM_SIZE);
		break;
		case XHDCP22_TX_LC_SEND_L_PRIME:
			/* Write LC Prime */
			memcpy(&BufferPtr[1], XHdcp22_Tx_Test_L1[Index],
				   XHDCP22_TX_L_PRIME_SIZE);
			if (TEST_FLAG_SET(XHDCP22_TX_TEST_L1, TestFlags) &&
			    TEST_FLAG_SET(XHDCP22_TX_TEST_INVALID_VALUE, TestFlags)) {
				BufferPtr[1] = ~BufferPtr[1];
			}
		break;
		case XHDCP22_TX_REPEATAUTH_SEND_RECVID_LIST:
			/* Write RxInfo */
			memcpy(&BufferPtr[1], XHdcp22_Tx_Test_RxInfo, XHDCP22_TX_RXINFO_SIZE);
			BytesWritten += XHDCP22_TX_RXINFO_SIZE;

			/* Write seq_num_V */
			memcpy(&BufferPtr[BytesWritten], XHdcp22_Tx_Test_SeqNum_V, XHDCP22_TX_SEQ_NUM_V_SIZE);
			BytesWritten += XHDCP22_TX_SEQ_NUM_V_SIZE;

			/* Write V'Prime */
			memcpy(&BufferPtr[BytesWritten], XHdcp22_Tx_Test_V1, XHDCP22_TX_V_PRIME_SIZE);
			BytesWritten += XHDCP22_TX_V_PRIME_SIZE;

			/* Write Receiver ID List */
			memcpy(&BufferPtr[BytesWritten], XHdcp22_Tx_Test_RcvIDList, sizeof(XHdcp22_Tx_Test_RcvIDList));
			BytesWritten += sizeof(XHdcp22_Tx_Test_RcvIDList);

			if (TEST_FLAG_SET(XHDCP22_TX_TEST_V1, TestFlags) &&
				TEST_FLAG_SET(XHDCP22_TX_TEST_INVALID_VALUE, TestFlags)) {
				BufferPtr[1] = ~BufferPtr[1];
			}
		break;
		case XHDCP22_TX_REPEATAUTH_STREAM_READY:
			/* Write M'Prime */
			memcpy(&BufferPtr[1], XHdcp22_Tx_Test_M1, XHDCP22_TX_M_PRIME_SIZE);
			if (TEST_FLAG_SET(XHDCP22_TX_TEST_M1, TestFlags) &&
				TEST_FLAG_SET(XHDCP22_TX_TEST_INVALID_VALUE, TestFlags)) {
				BufferPtr[1] = ~BufferPtr[1];
			}
		break;
		default:
		break;
	};
}
/*****************************************************************************/
/**
*
* This function simulates a read from the DDC message buffer.
* It returns hardcoded messages with valid content unless a test flag is used
* to force invalid messages.
*
* @param  BufferPtr is a pointer to the buffer that will receive a message.
* @param  TestFlags.are possible flags to influence the read.
*
* @return None.
*
* @note   None.
*
******************************************************************************/
This function simulates a read from the DDC message buffer.
It returns hardcoded messages with valid content unless a test flag is used
to force invalid messages.
This function simulates a read from the DDC message buffer . It returns hardcoded messages with valid content unless a test flag is used to force invalid messages .
static void XHdcp22Tx_TestReadMsg(u8* BufferPtr, u32 TestFlags)
{
	int BytesWritten = 0;
	u8 MsgId = BufferPtr[0]; 
	u8 Index = XHDCP22_TX_TEST_VECTOR_R2_INDEX;
	if (TEST_FLAG_SET(XHDCP22_TX_TEST_USE_TEST_VECTOR_R1, TestFlags)) {
		Index = XHDCP22_TX_TEST_VECTOR_R1_INDEX;
	}
	BufferPtr[BytesWritten++] = MsgId;
	switch (MsgId)
	{
		case XHDCP22_TX_AKE_SEND_CERT:
			memcpy(&BufferPtr[1], XHdcp22_Tx_Test_CertRx[Index],
			       XHDCP22_TX_CERT_SIZE);
			BytesWritten += XHDCP22_TX_CERT_SIZE;
			memcpy(&BufferPtr[BytesWritten], XHdcp22_Tx_Test_Rrx[Index],
			       XHDCP22_TX_RRX_SIZE);
			BytesWritten += XHDCP22_TX_RRX_SIZE;
			memcpy(&BufferPtr[BytesWritten], XHdcp22_Tx_Test_RxCaps[Index],
			       XHDCP22_TX_RXCAPS_SIZE);
			if (TEST_FLAG_SET(XHDCP22_TX_TEST_CERT_RX, TestFlags) &&
			    TEST_FLAG_SET(XHDCP22_TX_TEST_INVALID_VALUE, TestFlags)) {
				BufferPtr[1] = ~BufferPtr[1];
			}
		break;
		case XHDCP22_TX_AKE_SEND_H_PRIME:
			memcpy(&BufferPtr[1], XHdcp22_Tx_Test_H1[Index], XHDCP22_TX_H_PRIME_SIZE);
			if (TEST_FLAG_SET(XHDCP22_TX_TEST_H1, TestFlags) &&
			    TEST_FLAG_SET(XHDCP22_TX_TEST_INVALID_VALUE, TestFlags)) {
				BufferPtr[1] = ~BufferPtr[1];
			}
		break;
		case XHDCP22_TX_AKE_SEND_PAIRING_INFO:
			memcpy(&BufferPtr[1], XHdcp22_Tx_Test_Ekh_Km[Index],
			       XHDCP22_TX_EKH_KM_SIZE);
		break;
		case XHDCP22_TX_LC_SEND_L_PRIME:
			memcpy(&BufferPtr[1], XHdcp22_Tx_Test_L1[Index],
				   XHDCP22_TX_L_PRIME_SIZE);
			if (TEST_FLAG_SET(XHDCP22_TX_TEST_L1, TestFlags) &&
			    TEST_FLAG_SET(XHDCP22_TX_TEST_INVALID_VALUE, TestFlags)) {
				BufferPtr[1] = ~BufferPtr[1];
			}
		break;
		case XHDCP22_TX_REPEATAUTH_SEND_RECVID_LIST:
			memcpy(&BufferPtr[1], XHdcp22_Tx_Test_RxInfo, XHDCP22_TX_RXINFO_SIZE);
			BytesWritten += XHDCP22_TX_RXINFO_SIZE;
			memcpy(&BufferPtr[BytesWritten], XHdcp22_Tx_Test_SeqNum_V, XHDCP22_TX_SEQ_NUM_V_SIZE);
			BytesWritten += XHDCP22_TX_SEQ_NUM_V_SIZE;
			memcpy(&BufferPtr[BytesWritten], XHdcp22_Tx_Test_V1, XHDCP22_TX_V_PRIME_SIZE);
			BytesWritten += XHDCP22_TX_V_PRIME_SIZE;
			memcpy(&BufferPtr[BytesWritten], XHdcp22_Tx_Test_RcvIDList, sizeof(XHdcp22_Tx_Test_RcvIDList));
			BytesWritten += sizeof(XHdcp22_Tx_Test_RcvIDList);
			if (TEST_FLAG_SET(XHDCP22_TX_TEST_V1, TestFlags) &&
				TEST_FLAG_SET(XHDCP22_TX_TEST_INVALID_VALUE, TestFlags)) {
				BufferPtr[1] = ~BufferPtr[1];
			}
		break;
		case XHDCP22_TX_REPEATAUTH_STREAM_READY:
			memcpy(&BufferPtr[1], XHdcp22_Tx_Test_M1, XHDCP22_TX_M_PRIME_SIZE);
			if (TEST_FLAG_SET(XHDCP22_TX_TEST_M1, TestFlags) &&
				TEST_FLAG_SET(XHDCP22_TX_TEST_INVALID_VALUE, TestFlags)) {
				BufferPtr[1] = ~BufferPtr[1];
			}
		break;
		default:
		break;
	};
}
static void XHdcp22Tx_TestReadMsg ( u8 * BufferPtr , u32 TestFlags ) { int BytesWritten = 0 ; u8 MsgId = BufferPtr [ 0 ] ; u8 Index = XHDCP22_TX_TEST_VECTOR_R2_INDEX ; if ( TEST_FLAG_SET ( XHDCP22_TX_TEST_USE_TEST_VECTOR_R1 , TestFlags ) ) { Index = XHDCP22_TX_TEST_VECTOR_R1_INDEX ; } BufferPtr [ BytesWritten ++ ] = MsgId ; switch ( MsgId ) { case XHDCP22_TX_AKE_SEND_CERT : memcpy ( & BufferPtr [ 1 ] , XHdcp22_Tx_Test_CertRx [ Index ] , XHDCP22_TX_CERT_SIZE ) ; BytesWritten += XHDCP22_TX_CERT_SIZE ; memcpy ( & BufferPtr [ BytesWritten ] , XHdcp22_Tx_Test_Rrx [ Index ] , XHDCP22_TX_RRX_SIZE ) ; BytesWritten += XHDCP22_TX_RRX_SIZE ; memcpy ( & BufferPtr [ BytesWritten ] , XHdcp22_Tx_Test_RxCaps [ Index ] , XHDCP22_TX_RXCAPS_SIZE ) ; if ( TEST_FLAG_SET ( XHDCP22_TX_TEST_CERT_RX , TestFlags ) && TEST_FLAG_SET ( XHDCP22_TX_TEST_INVALID_VALUE , TestFlags ) ) { BufferPtr [ 1 ] = ~ BufferPtr [ 1 ] ; } break ; case XHDCP22_TX_AKE_SEND_H_PRIME : memcpy ( & BufferPtr [ 1 ] , XHdcp22_Tx_Test_H1 [ Index ] , XHDCP22_TX_H_PRIME_SIZE ) ; if ( TEST_FLAG_SET ( XHDCP22_TX_TEST_H1 , TestFlags ) && TEST_FLAG_SET ( XHDCP22_TX_TEST_INVALID_VALUE , TestFlags ) ) { BufferPtr [ 1 ] = ~ BufferPtr [ 1 ] ; } break ; case XHDCP22_TX_AKE_SEND_PAIRING_INFO : memcpy ( & BufferPtr [ 1 ] , XHdcp22_Tx_Test_Ekh_Km [ Index ] , XHDCP22_TX_EKH_KM_SIZE ) ; break ; case XHDCP22_TX_LC_SEND_L_PRIME : memcpy ( & BufferPtr [ 1 ] , XHdcp22_Tx_Test_L1 [ Index ] , XHDCP22_TX_L_PRIME_SIZE ) ; if ( TEST_FLAG_SET ( XHDCP22_TX_TEST_L1 , TestFlags ) && TEST_FLAG_SET ( XHDCP22_TX_TEST_INVALID_VALUE , TestFlags ) ) { BufferPtr [ 1 ] = ~ BufferPtr [ 1 ] ; } break ; case XHDCP22_TX_REPEATAUTH_SEND_RECVID_LIST : memcpy ( & BufferPtr [ 1 ] , XHdcp22_Tx_Test_RxInfo , XHDCP22_TX_RXINFO_SIZE ) ; BytesWritten += XHDCP22_TX_RXINFO_SIZE ; memcpy ( & BufferPtr [ BytesWritten ] , XHdcp22_Tx_Test_SeqNum_V , XHDCP22_TX_SEQ_NUM_V_SIZE ) ; BytesWritten += XHDCP22_TX_SEQ_NUM_V_SIZE ; memcpy ( & BufferPtr [ BytesWritten ] , XHdcp22_Tx_Test_V1 , XHDCP22_TX_V_PRIME_SIZE ) ; BytesWritten += XHDCP22_TX_V_PRIME_SIZE ; memcpy ( & BufferPtr [ BytesWritten ] , XHdcp22_Tx_Test_RcvIDList , sizeof ( XHdcp22_Tx_Test_RcvIDList ) ) ; BytesWritten += sizeof ( XHdcp22_Tx_Test_RcvIDList ) ; if ( TEST_FLAG_SET ( XHDCP22_TX_TEST_V1 , TestFlags ) && TEST_FLAG_SET ( XHDCP22_TX_TEST_INVALID_VALUE , TestFlags ) ) { BufferPtr [ 1 ] = ~ BufferPtr [ 1 ] ; } break ; case XHDCP22_TX_REPEATAUTH_STREAM_READY : memcpy ( & BufferPtr [ 1 ] , XHdcp22_Tx_Test_M1 , XHDCP22_TX_M_PRIME_SIZE ) ; if ( TEST_FLAG_SET ( XHDCP22_TX_TEST_M1 , TestFlags ) && TEST_FLAG_SET ( XHDCP22_TX_TEST_INVALID_VALUE , TestFlags ) ) { BufferPtr [ 1 ] = ~ BufferPtr [ 1 ] ; } break ; default : break ; } ; }
This function simulates a read from the DDC message buffer.
This function simulates a read from the DDC message buffer .
/* MessageId */ /* Write MessageId*/ /* Write HDCP22 RX certificate */ /* Write Rrx */ /* Write RxCaps */ /* Write HDCP22 H'Prime */ /* Write Ekh(Km) */ /* Write LC Prime */ /* Write RxInfo */ /* Write seq_num_V */ /* Write V'Prime */ /* Write Receiver ID List */ /* Write M'Prime */