lib/sw_services/xilplmi/src/xplmi_generic.c
static int XPlmi_DmaWriteKeyHole(XPlmi_Cmd *Cmd)
{
	int Status = XST_FAILURE;
	u64 DestAddr;
	u64 SrcAddr;
	u32 Len = Cmd->PayloadLen;
	u32 Keyholesize;
	u64 BaseAddr;
	u32 DestOffset;
	XPlmi_KeyHoleXfrParams KeyHoleXfrParams;
#ifdef PLM_PRINT_PERF_KEYHOLE
	u64 KeyHoleTime = XPlmi_GetTimerValue();
	XPlmi_PerfTime PerfTime = {0U};
#endif

	XPlmi_Printf(DEBUG_DETAILED, "%s \n\r", __func__);

	if (Cmd->ProcessedLen == 0U) {
		/* Store the destination address in resume data */
		Cmd->ResumeData[0U] = Cmd->Payload[0U];
		Cmd->ResumeData[1U] = Cmd->Payload[1U];
		Cmd->ResumeData[2U] = Cmd->Payload[2U];
		Keyholesize = Cmd->Payload[2U] * XPLMI_WORD_LEN;
		SrcAddr = (u64)(UINTPTR) &Cmd->Payload[3U];
		Len -= 3U;
		Cmd->ResumeData[3U] = 0U;
		DestOffset = 0U;
	} else {
		SrcAddr = (u64)(UINTPTR) &Cmd->Payload[0U];
		Keyholesize = Cmd->ResumeData[2U] * XPLMI_WORD_LEN;
		DestOffset = 3U;
	}

	DestAddr = (u64)Cmd->ResumeData[0U];
	DestAddr = (u64)Cmd->ResumeData[1U] | (DestAddr << 32U);
	BaseAddr = DestAddr;

	if (Cmd->KeyHoleParams.Func != NULL) {
		/* This is for direct DMA to CFI from PdiSrc bypassing PMCRAM */
		Status = XPlmi_CfiWrite(SrcAddr, DestAddr, Keyholesize, Len, Cmd);
		goto END;
	}

	DestAddr = ((((u64)Cmd->ProcessedLen - Cmd->ResumeData[3U] - DestOffset) *
			XPLMI_WORD_LEN) & (Keyholesize - 1U)) + BaseAddr;
	KeyHoleXfrParams.SrcAddr = SrcAddr;
	KeyHoleXfrParams.DestAddr = DestAddr;
	KeyHoleXfrParams.BaseAddr = BaseAddr;
	KeyHoleXfrParams.Len = Len * XPLMI_WORD_LEN;
	KeyHoleXfrParams.Keyholesize = Keyholesize;
	KeyHoleXfrParams.Flags = XPLMI_PMCDMA_0;
	KeyHoleXfrParams.Func = NULL;
	Status = XPlmi_KeyHoleXfr(&KeyHoleXfrParams);
	if (Status != XST_SUCCESS) {
		XPlmi_Printf(DEBUG_GENERAL, "DMA WRITE Key Hole Failed\n\r");
	}

END:
#ifdef PLM_PRINT_PERF_KEYHOLE
	XPlmi_MeasurePerfTime(KeyHoleTime, &PerfTime);
	XPlmi_Printf(DEBUG_PRINT_PERF, " %u.%06u ms KeyHole Run Time \r\n",
	(u32)PerfTime.TPerfMs, (u32)PerfTime.TPerfMsFrac);
#endif
	return Status;
}
/*****************************************************************************/
/**
 * @brief	This function provides DMA key hole write command execution.
 *  		Command payload parameters are
 *		- High Dest Addr
 *		- Low Dest Addr
 *		- Keyhole Size in bytes
 *		- DATA
 *
 * @param	Cmd is pointer to the command structure
 *
 * @return	XST_SUCCESS on success and error code on failure
 *
 *****************************************************************************/
@brief       This function provides DMA key hole write command execution.
Command payload parameters are
- High Dest Addr
- Low Dest Addr
- Keyhole Size in bytes
- DATA

@param       Cmd is pointer to the command structure

@return      XST_SUCCESS on success and error code on failure
@brief This function provides DMA key hole write command execution . Command payload parameters are - High Dest Addr - Low Dest Addr - Keyhole Size in bytes - DATA @param Cmd is pointer to the command structure @return XST_SUCCESS on success and error code on failure
static int XPlmi_DmaWriteKeyHole(XPlmi_Cmd *Cmd)
{
	int Status = XST_FAILURE;
	u64 DestAddr;
	u64 SrcAddr;
	u32 Len = Cmd->PayloadLen;
	u32 Keyholesize;
	u64 BaseAddr;
	u32 DestOffset;
	XPlmi_KeyHoleXfrParams KeyHoleXfrParams;
#ifdef PLM_PRINT_PERF_KEYHOLE
	u64 KeyHoleTime = XPlmi_GetTimerValue();
	XPlmi_PerfTime PerfTime = {0U};
#endif
	XPlmi_Printf(DEBUG_DETAILED, "%s \n\r", __func__);
	if (Cmd->ProcessedLen == 0U) {
		Cmd->ResumeData[0U] = Cmd->Payload[0U];
		Cmd->ResumeData[1U] = Cmd->Payload[1U];
		Cmd->ResumeData[2U] = Cmd->Payload[2U];
		Keyholesize = Cmd->Payload[2U] * XPLMI_WORD_LEN;
		SrcAddr = (u64)(UINTPTR) &Cmd->Payload[3U];
		Len -= 3U;
		Cmd->ResumeData[3U] = 0U;
		DestOffset = 0U;
	} else {
		SrcAddr = (u64)(UINTPTR) &Cmd->Payload[0U];
		Keyholesize = Cmd->ResumeData[2U] * XPLMI_WORD_LEN;
		DestOffset = 3U;
	}
	DestAddr = (u64)Cmd->ResumeData[0U];
	DestAddr = (u64)Cmd->ResumeData[1U] | (DestAddr << 32U);
	BaseAddr = DestAddr;
	if (Cmd->KeyHoleParams.Func != NULL) {
		Status = XPlmi_CfiWrite(SrcAddr, DestAddr, Keyholesize, Len, Cmd);
		goto END;
	}
	DestAddr = ((((u64)Cmd->ProcessedLen - Cmd->ResumeData[3U] - DestOffset) *
			XPLMI_WORD_LEN) & (Keyholesize - 1U)) + BaseAddr;
	KeyHoleXfrParams.SrcAddr = SrcAddr;
	KeyHoleXfrParams.DestAddr = DestAddr;
	KeyHoleXfrParams.BaseAddr = BaseAddr;
	KeyHoleXfrParams.Len = Len * XPLMI_WORD_LEN;
	KeyHoleXfrParams.Keyholesize = Keyholesize;
	KeyHoleXfrParams.Flags = XPLMI_PMCDMA_0;
	KeyHoleXfrParams.Func = NULL;
	Status = XPlmi_KeyHoleXfr(&KeyHoleXfrParams);
	if (Status != XST_SUCCESS) {
		XPlmi_Printf(DEBUG_GENERAL, "DMA WRITE Key Hole Failed\n\r");
	}
END:
#ifdef PLM_PRINT_PERF_KEYHOLE
	XPlmi_MeasurePerfTime(KeyHoleTime, &PerfTime);
	XPlmi_Printf(DEBUG_PRINT_PERF, " %u.%06u ms KeyHole Run Time \r\n",
	(u32)PerfTime.TPerfMs, (u32)PerfTime.TPerfMsFrac);
#endif
	return Status;
}
static int XPlmi_DmaWriteKeyHole ( XPlmi_Cmd * Cmd ) { int Status = XST_FAILURE ; u64 DestAddr ; u64 SrcAddr ; u32 Len = Cmd -> PayloadLen ; u32 Keyholesize ; u64 BaseAddr ; u32 DestOffset ; XPlmi_KeyHoleXfrParams KeyHoleXfrParams ; #ifdef PLM_PRINT_PERF_KEYHOLE u64 KeyHoleTime = XPlmi_GetTimerValue ( ) ; XPlmi_PerfTime PerfTime = { 0U } ; #endif XPlmi_Printf ( DEBUG_DETAILED , " \n \r " , __func__ ) ; if ( Cmd -> ProcessedLen == 0U ) { Cmd -> ResumeData [ 0U ] = Cmd -> Payload [ 0U ] ; Cmd -> ResumeData [ 1U ] = Cmd -> Payload [ 1U ] ; Cmd -> ResumeData [ 2U ] = Cmd -> Payload [ 2U ] ; Keyholesize = Cmd -> Payload [ 2U ] * XPLMI_WORD_LEN ; SrcAddr = ( u64 ) ( UINTPTR ) & Cmd -> Payload [ 3U ] ; Len -= 3U ; Cmd -> ResumeData [ 3U ] = 0U ; DestOffset = 0U ; } else { SrcAddr = ( u64 ) ( UINTPTR ) & Cmd -> Payload [ 0U ] ; Keyholesize = Cmd -> ResumeData [ 2U ] * XPLMI_WORD_LEN ; DestOffset = 3U ; } DestAddr = ( u64 ) Cmd -> ResumeData [ 0U ] ; DestAddr = ( u64 ) Cmd -> ResumeData [ 1U ] | ( DestAddr << 32U ) ; BaseAddr = DestAddr ; if ( Cmd -> KeyHoleParams . Func != NULL ) { Status = XPlmi_CfiWrite ( SrcAddr , DestAddr , Keyholesize , Len , Cmd ) ; goto END ; } DestAddr = ( ( ( ( u64 ) Cmd -> ProcessedLen - Cmd -> ResumeData [ 3U ] - DestOffset ) * XPLMI_WORD_LEN ) & ( Keyholesize - 1U ) ) + BaseAddr ; KeyHoleXfrParams . SrcAddr = SrcAddr ; KeyHoleXfrParams . DestAddr = DestAddr ; KeyHoleXfrParams . BaseAddr = BaseAddr ; KeyHoleXfrParams . Len = Len * XPLMI_WORD_LEN ; KeyHoleXfrParams . Keyholesize = Keyholesize ; KeyHoleXfrParams . Flags = XPLMI_PMCDMA_0 ; KeyHoleXfrParams . Func = NULL ; Status = XPlmi_KeyHoleXfr ( & KeyHoleXfrParams ) ; if ( Status != XST_SUCCESS ) { XPlmi_Printf ( DEBUG_GENERAL , " \n \r " ) ; } END : #ifdef PLM_PRINT_PERF_KEYHOLE XPlmi_MeasurePerfTime ( KeyHoleTime , & PerfTime ) ; XPlmi_Printf ( DEBUG_PRINT_PERF , " \r \n " , ( u32 ) PerfTime . TPerfMs , ( u32 ) PerfTime . TPerfMsFrac ) ; #endif return Status ; }
@brief       This function provides DMA key hole write command execution.
@brief This function provides DMA key hole write command execution .
/* Store the destination address in resume data */ /* This is for direct DMA to CFI from PdiSrc bypassing PMCRAM */