XilinxProcessorIPLib/drivers/hdcp22_rx/src/xhdcp22_rx.c
int XHdcp22Rx_CfgInitialize(XHdcp22_Rx *InstancePtr, XHdcp22_Rx_Config *ConfigPtr,
      UINTPTR EffectiveAddr)
{
	/* Verify arguments */
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(ConfigPtr != NULL);
	Xil_AssertNonvoid(EffectiveAddr != (UINTPTR)NULL);

	int Status;

	/* Clear the instance */
	memset((void *)InstancePtr, 0, sizeof(XHdcp22_Rx));

	/* Copy configuration settings */
	memcpy((void *)&(InstancePtr->Config), (const void *)ConfigPtr, sizeof(XHdcp22_Rx_Config));

	/* Set default values */
	InstancePtr->Config.BaseAddress = EffectiveAddr;
	InstancePtr->StateFunc = (XHdcp22_Rx_StateFunc)(&XHdcp22Rx_StateB0);
	InstancePtr->Info.IsEnabled = FALSE;
	InstancePtr->Info.AuthenticationStatus = XHDCP22_RX_UNAUTHENTICATED;
	InstancePtr->Info.IsNoStoredKm = FALSE;
	InstancePtr->Info.ReauthReq = FALSE;
	InstancePtr->Info.TopologyReady = FALSE;
	InstancePtr->Info.IsEncrypted = FALSE;
	InstancePtr->Info.LCInitAttempts = 0;
	InstancePtr->Info.AuthRequestCnt = 0;
	InstancePtr->Info.ReauthRequestCnt = 0;
	InstancePtr->Info.LinkErrorCnt = 0;
	InstancePtr->Info.DdcErrorCnt = 0;
	InstancePtr->Info.ErrorFlag = XHDCP22_RX_ERROR_FLAG_NONE;
	InstancePtr->Info.ErrorFlagSticky = XHDCP22_RX_ERROR_FLAG_NONE;
	InstancePtr->Info.CurrentState = XHDCP22_RX_STATE_B0_WAIT_AKEINIT;
	InstancePtr->Info.NextState = XHDCP22_RX_STATE_B0_WAIT_AKEINIT;

	/* Set default repeater values */
	InstancePtr->Info.IsTopologyValid = FALSE;
	InstancePtr->Info.ReturnState = XHDCP22_RX_STATE_UNDEFINED;
	InstancePtr->Info.SeqNumV = 0;
	InstancePtr->Info.HasStreamManagementInfo = FALSE;
	InstancePtr->Info.SkipRead = FALSE;

	/* Set the callback functions to stubs */
	InstancePtr->Handles.DdcSetAddressCallback = XHdcp22_Rx_StubSetHandler;
	InstancePtr->Handles.IsDdcSetAddressCallbackSet = (FALSE);

	InstancePtr->Handles.DdcSetDataCallback = XHdcp22_Rx_StubSetHandler;
	InstancePtr->Handles.IsDdcSetDataCallbackSet = (FALSE);

	InstancePtr->Handles.DdcGetDataCallback = XHdcp22_Rx_StubGetHandler;
	InstancePtr->Handles.IsDdcGetDataCallbackSet = (FALSE);

	InstancePtr->Handles.DdcGetWriteBufferSizeCallback = XHdcp22_Rx_StubGetHandler;
	InstancePtr->Handles.IsDdcGetWriteBufferSizeCallbackSet = (FALSE);

	InstancePtr->Handles.DdcGetReadBufferSizeCallback = XHdcp22_Rx_StubGetHandler;
	InstancePtr->Handles.IsDdcGetReadBufferSizeCallbackRefSet = (FALSE);

	InstancePtr->Handles.DdcIsWriteBufferEmptyCallback = XHdcp22_Rx_StubGetHandler;
	InstancePtr->Handles.IsDdcIsWriteBufferEmptyCallbackSet = (FALSE);

	InstancePtr->Handles.DdcIsReadBufferEmptyCallback = XHdcp22_Rx_StubGetHandler;
	InstancePtr->Handles.IsDdcIsReadBufferEmptyCallbackSet = (FALSE);

	InstancePtr->Handles.DdcClearReadBufferCallback = XHdcp22_Rx_StubRunHandler;
	InstancePtr->Handles.IsDdcClearReadBufferCallbackSet = (FALSE);

	InstancePtr->Handles.DdcClearWriteBufferCallback = XHdcp22_Rx_StubRunHandler;
	InstancePtr->Handles.IsDdcClearWriteBufferCallbackSet = (FALSE);

	InstancePtr->Handles.AuthenticatedCallback = XHdcp22_Rx_StubRunHandler;
	InstancePtr->Handles.IsAuthenticatedCallbackSet = (FALSE);

	InstancePtr->Handles.AuthenticationRequestCallback = XHdcp22_Rx_StubRunHandler;
	InstancePtr->Handles.IsAuthenticationRequestCallbackSet = (FALSE);

	InstancePtr->Handles.StreamManageRequestCallback = XHdcp22_Rx_StubRunHandler;
	InstancePtr->Handles.IsStreamManageRequestCallbackSet = (FALSE);

	InstancePtr->Handles.TopologyUpdateCallback = XHdcp22_Rx_StubRunHandler;
	InstancePtr->Handles.IsTopologyUpdateCallbackSet = (FALSE);

	InstancePtr->Handles.IsDdcAllCallbacksSet = (FALSE);

	/* Set RXCAPS repeater mode */
	InstancePtr->RxCaps[0] = 0x02;
	InstancePtr->RxCaps[1] = 0x00;
	InstancePtr->RxCaps[2] = (InstancePtr->Config.Mode == XHDCP22_RX_RECEIVER) ? 0x00 : 0x01;

	/* Reset stored parameters */
	XHdcp22Rx_ResetParams(InstancePtr);

	/* Configure Cipher Instance */
	Status = XHdcp22Rx_InitializeCipher(InstancePtr);
	if(Status == XST_FAILURE)
	{
		return Status;
	}

	/* Configure Mmult Instance */
	Status = XHdcp22Rx_InitializeMmult(InstancePtr);
	if(Status == XST_FAILURE)
	{
		return Status;
	}

	/* Configure Rng Instance */
	Status = XHdcp22Rx_InitializeRng(InstancePtr);
	if(Status == XST_FAILURE)
	{
		return Status;
	}

	/* Configure Timer Instance */
	Status = XHdcp22Rx_InitializeTimer(InstancePtr);
	if(Status == XST_FAILURE)
	{
		return Status;
	}

	/* Reset log */
	XHdcp22Rx_LogReset(InstancePtr, FALSE);

	/* Indicate component has been initialized */
	InstancePtr->IsReady = (XIL_COMPONENT_IS_READY);
	/* Default enable broadcasting */
	InstancePtr->Hdcp22Broadcast = TRUE;

	return (XST_SUCCESS);
}
/****************************************************************************/
/**
* Initialize the instance provided by the caller based on the given
* configuration data.
*
* @param 	InstancePtr is a pointer to an XHdcp22_Rx instance.
*			The memory the pointer references must be pre-allocated by
*			the caller. Further calls to manipulate the driver through
*			the HDCP22-RX API must be made with this pointer.
* @param	Config is a reference to a structure containing information
*			about a specific HDCP22-RX device. This function
*			initializes an InstancePtr object for a specific device
*			specified by the contents of Config. This function can
*			initialize multiple instance objects with the use of multiple
*			calls giving different Config information on each call.
* @param	EffectiveAddr is the base address of the device. If address
*			translation is being used, then this parameter must reflect the
*			virtual base address. Otherwise, the physical address should be
*			used.
*
* @return	XST_SUCCESS or XST_FAILURE.
*
* @note		None.
*****************************************************************************/
Initialize the instance provided by the caller based on the given
configuration data.
Initialize the instance provided by the caller based on the given configuration data .
int XHdcp22Rx_CfgInitialize(XHdcp22_Rx *InstancePtr, XHdcp22_Rx_Config *ConfigPtr,
      UINTPTR EffectiveAddr)
{
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(ConfigPtr != NULL);
	Xil_AssertNonvoid(EffectiveAddr != (UINTPTR)NULL);
	int Status;
	memset((void *)InstancePtr, 0, sizeof(XHdcp22_Rx));
	memcpy((void *)&(InstancePtr->Config), (const void *)ConfigPtr, sizeof(XHdcp22_Rx_Config));
	InstancePtr->Config.BaseAddress = EffectiveAddr;
	InstancePtr->StateFunc = (XHdcp22_Rx_StateFunc)(&XHdcp22Rx_StateB0);
	InstancePtr->Info.IsEnabled = FALSE;
	InstancePtr->Info.AuthenticationStatus = XHDCP22_RX_UNAUTHENTICATED;
	InstancePtr->Info.IsNoStoredKm = FALSE;
	InstancePtr->Info.ReauthReq = FALSE;
	InstancePtr->Info.TopologyReady = FALSE;
	InstancePtr->Info.IsEncrypted = FALSE;
	InstancePtr->Info.LCInitAttempts = 0;
	InstancePtr->Info.AuthRequestCnt = 0;
	InstancePtr->Info.ReauthRequestCnt = 0;
	InstancePtr->Info.LinkErrorCnt = 0;
	InstancePtr->Info.DdcErrorCnt = 0;
	InstancePtr->Info.ErrorFlag = XHDCP22_RX_ERROR_FLAG_NONE;
	InstancePtr->Info.ErrorFlagSticky = XHDCP22_RX_ERROR_FLAG_NONE;
	InstancePtr->Info.CurrentState = XHDCP22_RX_STATE_B0_WAIT_AKEINIT;
	InstancePtr->Info.NextState = XHDCP22_RX_STATE_B0_WAIT_AKEINIT;
	InstancePtr->Info.IsTopologyValid = FALSE;
	InstancePtr->Info.ReturnState = XHDCP22_RX_STATE_UNDEFINED;
	InstancePtr->Info.SeqNumV = 0;
	InstancePtr->Info.HasStreamManagementInfo = FALSE;
	InstancePtr->Info.SkipRead = FALSE;
	InstancePtr->Handles.DdcSetAddressCallback = XHdcp22_Rx_StubSetHandler;
	InstancePtr->Handles.IsDdcSetAddressCallbackSet = (FALSE);
	InstancePtr->Handles.DdcSetDataCallback = XHdcp22_Rx_StubSetHandler;
	InstancePtr->Handles.IsDdcSetDataCallbackSet = (FALSE);
	InstancePtr->Handles.DdcGetDataCallback = XHdcp22_Rx_StubGetHandler;
	InstancePtr->Handles.IsDdcGetDataCallbackSet = (FALSE);
	InstancePtr->Handles.DdcGetWriteBufferSizeCallback = XHdcp22_Rx_StubGetHandler;
	InstancePtr->Handles.IsDdcGetWriteBufferSizeCallbackSet = (FALSE);
	InstancePtr->Handles.DdcGetReadBufferSizeCallback = XHdcp22_Rx_StubGetHandler;
	InstancePtr->Handles.IsDdcGetReadBufferSizeCallbackRefSet = (FALSE);
	InstancePtr->Handles.DdcIsWriteBufferEmptyCallback = XHdcp22_Rx_StubGetHandler;
	InstancePtr->Handles.IsDdcIsWriteBufferEmptyCallbackSet = (FALSE);
	InstancePtr->Handles.DdcIsReadBufferEmptyCallback = XHdcp22_Rx_StubGetHandler;
	InstancePtr->Handles.IsDdcIsReadBufferEmptyCallbackSet = (FALSE);
	InstancePtr->Handles.DdcClearReadBufferCallback = XHdcp22_Rx_StubRunHandler;
	InstancePtr->Handles.IsDdcClearReadBufferCallbackSet = (FALSE);
	InstancePtr->Handles.DdcClearWriteBufferCallback = XHdcp22_Rx_StubRunHandler;
	InstancePtr->Handles.IsDdcClearWriteBufferCallbackSet = (FALSE);
	InstancePtr->Handles.AuthenticatedCallback = XHdcp22_Rx_StubRunHandler;
	InstancePtr->Handles.IsAuthenticatedCallbackSet = (FALSE);
	InstancePtr->Handles.AuthenticationRequestCallback = XHdcp22_Rx_StubRunHandler;
	InstancePtr->Handles.IsAuthenticationRequestCallbackSet = (FALSE);
	InstancePtr->Handles.StreamManageRequestCallback = XHdcp22_Rx_StubRunHandler;
	InstancePtr->Handles.IsStreamManageRequestCallbackSet = (FALSE);
	InstancePtr->Handles.TopologyUpdateCallback = XHdcp22_Rx_StubRunHandler;
	InstancePtr->Handles.IsTopologyUpdateCallbackSet = (FALSE);
	InstancePtr->Handles.IsDdcAllCallbacksSet = (FALSE);
	InstancePtr->RxCaps[0] = 0x02;
	InstancePtr->RxCaps[1] = 0x00;
	InstancePtr->RxCaps[2] = (InstancePtr->Config.Mode == XHDCP22_RX_RECEIVER) ? 0x00 : 0x01;
	XHdcp22Rx_ResetParams(InstancePtr);
	Status = XHdcp22Rx_InitializeCipher(InstancePtr);
	if(Status == XST_FAILURE)
	{
		return Status;
	}
	Status = XHdcp22Rx_InitializeMmult(InstancePtr);
	if(Status == XST_FAILURE)
	{
		return Status;
	}
	Status = XHdcp22Rx_InitializeRng(InstancePtr);
	if(Status == XST_FAILURE)
	{
		return Status;
	}
	Status = XHdcp22Rx_InitializeTimer(InstancePtr);
	if(Status == XST_FAILURE)
	{
		return Status;
	}
	XHdcp22Rx_LogReset(InstancePtr, FALSE);
	InstancePtr->IsReady = (XIL_COMPONENT_IS_READY);
	InstancePtr->Hdcp22Broadcast = TRUE;
	return (XST_SUCCESS);
}
int XHdcp22Rx_CfgInitialize ( XHdcp22_Rx * InstancePtr , XHdcp22_Rx_Config * ConfigPtr , UINTPTR EffectiveAddr ) { Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( ConfigPtr != NULL ) ; Xil_AssertNonvoid ( EffectiveAddr != ( UINTPTR ) NULL ) ; int Status ; memset ( ( void * ) InstancePtr , 0 , sizeof ( XHdcp22_Rx ) ) ; memcpy ( ( void * ) & ( InstancePtr -> Config ) , ( const void * ) ConfigPtr , sizeof ( XHdcp22_Rx_Config ) ) ; InstancePtr -> Config . BaseAddress = EffectiveAddr ; InstancePtr -> StateFunc = ( XHdcp22_Rx_StateFunc ) ( & XHdcp22Rx_StateB0 ) ; InstancePtr -> Info . IsEnabled = FALSE ; InstancePtr -> Info . AuthenticationStatus = XHDCP22_RX_UNAUTHENTICATED ; InstancePtr -> Info . IsNoStoredKm = FALSE ; InstancePtr -> Info . ReauthReq = FALSE ; InstancePtr -> Info . TopologyReady = FALSE ; InstancePtr -> Info . IsEncrypted = FALSE ; InstancePtr -> Info . LCInitAttempts = 0 ; InstancePtr -> Info . AuthRequestCnt = 0 ; InstancePtr -> Info . ReauthRequestCnt = 0 ; InstancePtr -> Info . LinkErrorCnt = 0 ; InstancePtr -> Info . DdcErrorCnt = 0 ; InstancePtr -> Info . ErrorFlag = XHDCP22_RX_ERROR_FLAG_NONE ; InstancePtr -> Info . ErrorFlagSticky = XHDCP22_RX_ERROR_FLAG_NONE ; InstancePtr -> Info . CurrentState = XHDCP22_RX_STATE_B0_WAIT_AKEINIT ; InstancePtr -> Info . NextState = XHDCP22_RX_STATE_B0_WAIT_AKEINIT ; InstancePtr -> Info . IsTopologyValid = FALSE ; InstancePtr -> Info . ReturnState = XHDCP22_RX_STATE_UNDEFINED ; InstancePtr -> Info . SeqNumV = 0 ; InstancePtr -> Info . HasStreamManagementInfo = FALSE ; InstancePtr -> Info . SkipRead = FALSE ; InstancePtr -> Handles . DdcSetAddressCallback = XHdcp22_Rx_StubSetHandler ; InstancePtr -> Handles . IsDdcSetAddressCallbackSet = ( FALSE ) ; InstancePtr -> Handles . DdcSetDataCallback = XHdcp22_Rx_StubSetHandler ; InstancePtr -> Handles . IsDdcSetDataCallbackSet = ( FALSE ) ; InstancePtr -> Handles . DdcGetDataCallback = XHdcp22_Rx_StubGetHandler ; InstancePtr -> Handles . IsDdcGetDataCallbackSet = ( FALSE ) ; InstancePtr -> Handles . DdcGetWriteBufferSizeCallback = XHdcp22_Rx_StubGetHandler ; InstancePtr -> Handles . IsDdcGetWriteBufferSizeCallbackSet = ( FALSE ) ; InstancePtr -> Handles . DdcGetReadBufferSizeCallback = XHdcp22_Rx_StubGetHandler ; InstancePtr -> Handles . IsDdcGetReadBufferSizeCallbackRefSet = ( FALSE ) ; InstancePtr -> Handles . DdcIsWriteBufferEmptyCallback = XHdcp22_Rx_StubGetHandler ; InstancePtr -> Handles . IsDdcIsWriteBufferEmptyCallbackSet = ( FALSE ) ; InstancePtr -> Handles . DdcIsReadBufferEmptyCallback = XHdcp22_Rx_StubGetHandler ; InstancePtr -> Handles . IsDdcIsReadBufferEmptyCallbackSet = ( FALSE ) ; InstancePtr -> Handles . DdcClearReadBufferCallback = XHdcp22_Rx_StubRunHandler ; InstancePtr -> Handles . IsDdcClearReadBufferCallbackSet = ( FALSE ) ; InstancePtr -> Handles . DdcClearWriteBufferCallback = XHdcp22_Rx_StubRunHandler ; InstancePtr -> Handles . IsDdcClearWriteBufferCallbackSet = ( FALSE ) ; InstancePtr -> Handles . AuthenticatedCallback = XHdcp22_Rx_StubRunHandler ; InstancePtr -> Handles . IsAuthenticatedCallbackSet = ( FALSE ) ; InstancePtr -> Handles . AuthenticationRequestCallback = XHdcp22_Rx_StubRunHandler ; InstancePtr -> Handles . IsAuthenticationRequestCallbackSet = ( FALSE ) ; InstancePtr -> Handles . StreamManageRequestCallback = XHdcp22_Rx_StubRunHandler ; InstancePtr -> Handles . IsStreamManageRequestCallbackSet = ( FALSE ) ; InstancePtr -> Handles . TopologyUpdateCallback = XHdcp22_Rx_StubRunHandler ; InstancePtr -> Handles . IsTopologyUpdateCallbackSet = ( FALSE ) ; InstancePtr -> Handles . IsDdcAllCallbacksSet = ( FALSE ) ; InstancePtr -> RxCaps [ 0 ] = 0x02 ; InstancePtr -> RxCaps [ 1 ] = 0x00 ; InstancePtr -> RxCaps [ 2 ] = ( InstancePtr -> Config . Mode == XHDCP22_RX_RECEIVER ) ? 0x00 : 0x01 ; XHdcp22Rx_ResetParams ( InstancePtr ) ; Status = XHdcp22Rx_InitializeCipher ( InstancePtr ) ; if ( Status == XST_FAILURE ) { return Status ; } Status = XHdcp22Rx_InitializeMmult ( InstancePtr ) ; if ( Status == XST_FAILURE ) { return Status ; } Status = XHdcp22Rx_InitializeRng ( InstancePtr ) ; if ( Status == XST_FAILURE ) { return Status ; } Status = XHdcp22Rx_InitializeTimer ( InstancePtr ) ; if ( Status == XST_FAILURE ) { return Status ; } XHdcp22Rx_LogReset ( InstancePtr , FALSE ) ; InstancePtr -> IsReady = ( XIL_COMPONENT_IS_READY ) ; InstancePtr -> Hdcp22Broadcast = TRUE ; return ( XST_SUCCESS ) ; }
Initialize the instance provided by the caller based on the given
configuration data.
Initialize the instance provided by the caller based on the given configuration data .
/* Verify arguments */ /* Clear the instance */ /* Copy configuration settings */ /* Set default values */ /* Set default repeater values */ /* Set the callback functions to stubs */ /* Set RXCAPS repeater mode */ /* Reset stored parameters */ /* Configure Cipher Instance */ /* Configure Mmult Instance */ /* Configure Rng Instance */ /* Configure Timer Instance */ /* Reset log */ /* Indicate component has been initialized */ /* Default enable broadcasting */