lib/sw_services/xilloader/src/xloader.c
static int XLoader_ReloadImage(XilPdi *PdiPtr, u32 ImageId, const u32 *FuncID)
{
	int Status = XST_FAILURE;
	int SStatus = XST_FAILURE;
	PdiSrc_t PdiSrc = PdiPtr->PdiSrc;
	u8 PdiIndex = PdiPtr->PdiIndex;
	u8 PdiType = PdiPtr->PdiType;
	u8 PrtnNum = 0U;
	u8 Index;

	XPlmi_SetPlmMode(XPLMI_MODE_CONFIGURATION);

	for (Index = 0U; Index < (u8)PdiPtr->MetaHdr.ImgHdrTbl.NoOfImgs;
		++Index) {
		if (PdiPtr->MetaHdr.ImgHdr[Index].ImgID == ImageId) {
			PdiPtr->ImageNum = Index;
			PdiPtr->PrtnNum = PrtnNum;
			break;
		}
		PrtnNum += (u8)PdiPtr->MetaHdr.ImgHdr[Index].NoOfPrtns;
	}
	if (Index == PdiPtr->MetaHdr.ImgHdrTbl.NoOfImgs) {
		Status = XPlmi_UpdateStatus(XLOADER_ERR_IMG_ID_NOT_FOUND, 0);
		goto END;
	}

	if (FuncID != NULL) {
		if (PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum].FuncID != *FuncID) {
			Status = XPlmi_UpdateStatus(XLOADER_ERR_FUNCTION_ID_MISMATCH, 0);
			goto END;
		}
	}

	if (PdiPtr->PdiType == XLOADER_PDI_TYPE_FULL) {
		PdiPtr->CopyToMem = (u8)(XilPdi_GetCopyToMemory(
			&PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum]) >>
			XILPDI_IH_ATTRIB_COPY_MEMORY_SHIFT);
		if (PdiPtr->CopyToMem == (u8)TRUE) {
			PdiPtr->PdiSrc = XLOADER_PDI_SRC_DDR;
			PdiPtr->PdiIndex = XLOADER_DDR_INDEX;
			PdiPtr->PdiType = XLOADER_PDI_TYPE_RESTORE;
			PdiPtr->CopyToMem = (u8)FALSE;
			PdiPtr->CopyToMemAddr =
				PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum].CopyToMemoryAddr;
		}
		else {
			if (DeviceOps[PdiPtr->PdiIndex].Init != NULL) {
				Status = DeviceOps[PdiPtr->PdiIndex].Init(PdiPtr->PdiSrc);
				if (Status != XST_SUCCESS) {
					goto END;
				}
			}
		}
	}
	PdiPtr->DelayHandoff = (u8)FALSE;
	PdiPtr->DelayLoad = (u8)FALSE;

	PdiPtr->MetaHdr.DeviceCopy = DeviceOps[PdiPtr->PdiIndex].Copy;

	Status = XLoader_LoadImage(PdiPtr);

END:
	if ((PdiPtr->PdiIndex != XLOADER_DDR_INDEX) &&
		(DeviceOps[PdiPtr->PdiIndex].Release != NULL)) {
		SStatus = DeviceOps[PdiPtr->PdiIndex].Release();
		if (Status == XST_SUCCESS) {
			Status = SStatus;
		}
	}
	XPlmi_SetPlmMode(XPLMI_MODE_OPERATIONAL);
	PdiPtr->PdiSrc = PdiSrc;
	PdiPtr->PdiIndex = PdiIndex;
	PdiPtr->MetaHdr.DeviceCopy = DeviceOps[PdiPtr->PdiIndex].Copy;
	PdiPtr->PdiType = PdiType;
#ifndef PLM_DEBUG_MODE
	SStatus = XPlmi_MemSet(XPLMI_PMCRAM_CHUNK_MEMORY, XPLMI_DATA_INIT_PZM,
			XLOADER_CHUNK_SIZE / XPLMI_WORD_LEN);
	if ((Status == XST_SUCCESS) && (SStatus != XST_SUCCESS)) {
		Status = SStatus;
	}
#endif
	return Status;
}
/*****************************************************************************/
/**
 * @brief	This function is used to reload the image only in PDI. This
 * function will take ImageId as an input and based on the subsystem info
 * available, it will read the image partitions and loads them.
 *
 * @param   PdiPtr is Pdi instance pointer
 * @param   ImageId Id of the image present in PDI
 * @param   FuncID is verified with the FuncID present in PDI
 *
 * @return  XST_SUCCESS on success and error code on failure
 *
 *****************************************************************************/
@brief       This function is used to reload the image only in PDI. This
function will take ImageId as an input and based on the subsystem info
available, it will read the image partitions and loads them.

@param   PdiPtr is Pdi instance pointer
@param   ImageId Id of the image present in PDI
@param   FuncID is verified with the FuncID present in PDI

@return  XST_SUCCESS on success and error code on failure
@brief This function is used to reload the image only in PDI . This function will take ImageId as an input and based on the subsystem info available it will read the image partitions and loads them . @param PdiPtr is Pdi instance pointer @param ImageId Id of the image present in PDI @param FuncID is verified with the FuncID present in PDI @return XST_SUCCESS on success and error code on failure
static int XLoader_ReloadImage(XilPdi *PdiPtr, u32 ImageId, const u32 *FuncID)
{
	int Status = XST_FAILURE;
	int SStatus = XST_FAILURE;
	PdiSrc_t PdiSrc = PdiPtr->PdiSrc;
	u8 PdiIndex = PdiPtr->PdiIndex;
	u8 PdiType = PdiPtr->PdiType;
	u8 PrtnNum = 0U;
	u8 Index;
	XPlmi_SetPlmMode(XPLMI_MODE_CONFIGURATION);
	for (Index = 0U; Index < (u8)PdiPtr->MetaHdr.ImgHdrTbl.NoOfImgs;
		++Index) {
		if (PdiPtr->MetaHdr.ImgHdr[Index].ImgID == ImageId) {
			PdiPtr->ImageNum = Index;
			PdiPtr->PrtnNum = PrtnNum;
			break;
		}
		PrtnNum += (u8)PdiPtr->MetaHdr.ImgHdr[Index].NoOfPrtns;
	}
	if (Index == PdiPtr->MetaHdr.ImgHdrTbl.NoOfImgs) {
		Status = XPlmi_UpdateStatus(XLOADER_ERR_IMG_ID_NOT_FOUND, 0);
		goto END;
	}
	if (FuncID != NULL) {
		if (PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum].FuncID != *FuncID) {
			Status = XPlmi_UpdateStatus(XLOADER_ERR_FUNCTION_ID_MISMATCH, 0);
			goto END;
		}
	}
	if (PdiPtr->PdiType == XLOADER_PDI_TYPE_FULL) {
		PdiPtr->CopyToMem = (u8)(XilPdi_GetCopyToMemory(
			&PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum]) >>
			XILPDI_IH_ATTRIB_COPY_MEMORY_SHIFT);
		if (PdiPtr->CopyToMem == (u8)TRUE) {
			PdiPtr->PdiSrc = XLOADER_PDI_SRC_DDR;
			PdiPtr->PdiIndex = XLOADER_DDR_INDEX;
			PdiPtr->PdiType = XLOADER_PDI_TYPE_RESTORE;
			PdiPtr->CopyToMem = (u8)FALSE;
			PdiPtr->CopyToMemAddr =
				PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum].CopyToMemoryAddr;
		}
		else {
			if (DeviceOps[PdiPtr->PdiIndex].Init != NULL) {
				Status = DeviceOps[PdiPtr->PdiIndex].Init(PdiPtr->PdiSrc);
				if (Status != XST_SUCCESS) {
					goto END;
				}
			}
		}
	}
	PdiPtr->DelayHandoff = (u8)FALSE;
	PdiPtr->DelayLoad = (u8)FALSE;
	PdiPtr->MetaHdr.DeviceCopy = DeviceOps[PdiPtr->PdiIndex].Copy;
	Status = XLoader_LoadImage(PdiPtr);
END:
	if ((PdiPtr->PdiIndex != XLOADER_DDR_INDEX) &&
		(DeviceOps[PdiPtr->PdiIndex].Release != NULL)) {
		SStatus = DeviceOps[PdiPtr->PdiIndex].Release();
		if (Status == XST_SUCCESS) {
			Status = SStatus;
		}
	}
	XPlmi_SetPlmMode(XPLMI_MODE_OPERATIONAL);
	PdiPtr->PdiSrc = PdiSrc;
	PdiPtr->PdiIndex = PdiIndex;
	PdiPtr->MetaHdr.DeviceCopy = DeviceOps[PdiPtr->PdiIndex].Copy;
	PdiPtr->PdiType = PdiType;
#ifndef PLM_DEBUG_MODE
	SStatus = XPlmi_MemSet(XPLMI_PMCRAM_CHUNK_MEMORY, XPLMI_DATA_INIT_PZM,
			XLOADER_CHUNK_SIZE / XPLMI_WORD_LEN);
	if ((Status == XST_SUCCESS) && (SStatus != XST_SUCCESS)) {
		Status = SStatus;
	}
#endif
	return Status;
}
static int XLoader_ReloadImage ( XilPdi * PdiPtr , u32 ImageId , const u32 * FuncID ) { int Status = XST_FAILURE ; int SStatus = XST_FAILURE ; PdiSrc_t PdiSrc = PdiPtr -> PdiSrc ; u8 PdiIndex = PdiPtr -> PdiIndex ; u8 PdiType = PdiPtr -> PdiType ; u8 PrtnNum = 0U ; u8 Index ; XPlmi_SetPlmMode ( XPLMI_MODE_CONFIGURATION ) ; for ( Index = 0U ; Index < ( u8 ) PdiPtr -> MetaHdr . ImgHdrTbl . NoOfImgs ; ++ Index ) { if ( PdiPtr -> MetaHdr . ImgHdr [ Index ] . ImgID == ImageId ) { PdiPtr -> ImageNum = Index ; PdiPtr -> PrtnNum = PrtnNum ; break ; } PrtnNum += ( u8 ) PdiPtr -> MetaHdr . ImgHdr [ Index ] . NoOfPrtns ; } if ( Index == PdiPtr -> MetaHdr . ImgHdrTbl . NoOfImgs ) { Status = XPlmi_UpdateStatus ( XLOADER_ERR_IMG_ID_NOT_FOUND , 0 ) ; goto END ; } if ( FuncID != NULL ) { if ( PdiPtr -> MetaHdr . ImgHdr [ PdiPtr -> ImageNum ] . FuncID != * FuncID ) { Status = XPlmi_UpdateStatus ( XLOADER_ERR_FUNCTION_ID_MISMATCH , 0 ) ; goto END ; } } if ( PdiPtr -> PdiType == XLOADER_PDI_TYPE_FULL ) { PdiPtr -> CopyToMem = ( u8 ) ( XilPdi_GetCopyToMemory ( & PdiPtr -> MetaHdr . ImgHdr [ PdiPtr -> ImageNum ] ) >> XILPDI_IH_ATTRIB_COPY_MEMORY_SHIFT ) ; if ( PdiPtr -> CopyToMem == ( u8 ) TRUE ) { PdiPtr -> PdiSrc = XLOADER_PDI_SRC_DDR ; PdiPtr -> PdiIndex = XLOADER_DDR_INDEX ; PdiPtr -> PdiType = XLOADER_PDI_TYPE_RESTORE ; PdiPtr -> CopyToMem = ( u8 ) FALSE ; PdiPtr -> CopyToMemAddr = PdiPtr -> MetaHdr . ImgHdr [ PdiPtr -> ImageNum ] . CopyToMemoryAddr ; } else { if ( DeviceOps [ PdiPtr -> PdiIndex ] . Init != NULL ) { Status = DeviceOps [ PdiPtr -> PdiIndex ] . Init ( PdiPtr -> PdiSrc ) ; if ( Status != XST_SUCCESS ) { goto END ; } } } } PdiPtr -> DelayHandoff = ( u8 ) FALSE ; PdiPtr -> DelayLoad = ( u8 ) FALSE ; PdiPtr -> MetaHdr . DeviceCopy = DeviceOps [ PdiPtr -> PdiIndex ] . Copy ; Status = XLoader_LoadImage ( PdiPtr ) ; END : if ( ( PdiPtr -> PdiIndex != XLOADER_DDR_INDEX ) && ( DeviceOps [ PdiPtr -> PdiIndex ] . Release != NULL ) ) { SStatus = DeviceOps [ PdiPtr -> PdiIndex ] . Release ( ) ; if ( Status == XST_SUCCESS ) { Status = SStatus ; } } XPlmi_SetPlmMode ( XPLMI_MODE_OPERATIONAL ) ; PdiPtr -> PdiSrc = PdiSrc ; PdiPtr -> PdiIndex = PdiIndex ; PdiPtr -> MetaHdr . DeviceCopy = DeviceOps [ PdiPtr -> PdiIndex ] . Copy ; PdiPtr -> PdiType = PdiType ; #ifndef PLM_DEBUG_MODE SStatus = XPlmi_MemSet ( XPLMI_PMCRAM_CHUNK_MEMORY , XPLMI_DATA_INIT_PZM , XLOADER_CHUNK_SIZE / XPLMI_WORD_LEN ) ; if ( ( Status == XST_SUCCESS ) && ( SStatus != XST_SUCCESS ) ) { Status = SStatus ; } #endif return Status ; }
@brief       This function is used to reload the image only in PDI.
@brief This function is used to reload the image only in PDI .