lib/sw_services/xilloader/src/xloader.c
int XLoader_RestartImage(u32 ImageId, u32 *FuncID)
{
	int Status = XST_FAILURE;
	XilPdi *PdiPtr = &SubsystemPdiIns;
	const XLoader_ImageStore *PdiList = XLoader_GetPdiList();
	int Index = 0;
	u64 PdiAddr;

	/*
	 * Scan through PdiList for the given ImageId and restart image from
	 * that respective PDI if ImageId is found
	 */
	 PdiPtr->PdiType = XLOADER_PDI_TYPE_PARTIAL;
	 PdiPtr->PdiSrc = XLOADER_PDI_SRC_DDR;
	for (Index = (int)PdiList->Count - 1; Index >= 0; Index--) {
		PdiAddr = PdiList->PdiAddr[Index];
		Status = XLoader_PdiInit(PdiPtr, XLOADER_PDI_SRC_DDR, PdiAddr);
		if (Status != XST_SUCCESS) {
			goto END1;
		}

		XPlmi_Printf(DEBUG_GENERAL, "Loading from PdiAddr: "
			"0x%0x%08x\n\r", (u32)(PdiAddr >> 32U),
			(u32)PdiAddr);
		Status = XLoader_ReloadImage(PdiPtr, ImageId,
				FuncID);
		if (Status != XST_SUCCESS) {
			goto END1;
		}

		Status = XLoader_StartImage(PdiPtr);
END1:
		if (Status != XST_SUCCESS) {
			if ((Status != (int)XLOADER_ERR_IMG_ID_NOT_FOUND) &&
				(Status != (int)XLOADER_ERR_FUNCTION_ID_MISMATCH)) {
				XPlmi_Printf(DEBUG_GENERAL, "Restart Image "
					"Failed with PLM Error: 0x%0x\n\r",
					Status);
				XPlmi_Printf(DEBUG_GENERAL, "Fallback to next"
					" PDI started...\n\r");
			}
		}
		else {
			goto END;
		}
	}

	/*
	 * Load image from BootPdi if the image is not found or loading is
	 * unsuccessful in the above PdiList
	 */
	PdiPtr = BootPdiPtr;
	XPlmi_Printf(DEBUG_GENERAL, "Loading from BootPdi\n\r");
	Status = XLoader_ReloadImage(PdiPtr, ImageId, FuncID);
	if (Status != XST_SUCCESS) {
		goto END;
	}

	Status = XLoader_StartImage(PdiPtr);

END:
	if (Status == XST_SUCCESS) {
		XPlmi_Out32(PMC_GLOBAL_DONE, XLOADER_PDI_LOAD_COMPLETE);
	}
	return Status;
}
/*****************************************************************************/
/**
 * @brief	This function is used to restart the image in PDI. This function
 * will take ImageId as an input and based on the subsystem info available, it
 * will read the image partitions, loads them and hand-off to the required CPUs
 * as part of the image load.
 *
 * @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 restart the image in PDI. This function
will take ImageId as an input and based on the subsystem info available, it
will read the image partitions, loads them and hand-off to the required CPUs
as part of the image load.

@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 restart the image in PDI . This function will take ImageId as an input and based on the subsystem info available it will read the image partitions loads them and hand - off to the required CPUs as part of the image load . @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
int XLoader_RestartImage(u32 ImageId, u32 *FuncID)
{
	int Status = XST_FAILURE;
	XilPdi *PdiPtr = &SubsystemPdiIns;
	const XLoader_ImageStore *PdiList = XLoader_GetPdiList();
	int Index = 0;
	u64 PdiAddr;
	 PdiPtr->PdiType = XLOADER_PDI_TYPE_PARTIAL;
	 PdiPtr->PdiSrc = XLOADER_PDI_SRC_DDR;
	for (Index = (int)PdiList->Count - 1; Index >= 0; Index--) {
		PdiAddr = PdiList->PdiAddr[Index];
		Status = XLoader_PdiInit(PdiPtr, XLOADER_PDI_SRC_DDR, PdiAddr);
		if (Status != XST_SUCCESS) {
			goto END1;
		}
		XPlmi_Printf(DEBUG_GENERAL, "Loading from PdiAddr: "
			"0x%0x%08x\n\r", (u32)(PdiAddr >> 32U),
			(u32)PdiAddr);
		Status = XLoader_ReloadImage(PdiPtr, ImageId,
				FuncID);
		if (Status != XST_SUCCESS) {
			goto END1;
		}
		Status = XLoader_StartImage(PdiPtr);
END1:
		if (Status != XST_SUCCESS) {
			if ((Status != (int)XLOADER_ERR_IMG_ID_NOT_FOUND) &&
				(Status != (int)XLOADER_ERR_FUNCTION_ID_MISMATCH)) {
				XPlmi_Printf(DEBUG_GENERAL, "Restart Image "
					"Failed with PLM Error: 0x%0x\n\r",
					Status);
				XPlmi_Printf(DEBUG_GENERAL, "Fallback to next"
					" PDI started...\n\r");
			}
		}
		else {
			goto END;
		}
	}
	PdiPtr = BootPdiPtr;
	XPlmi_Printf(DEBUG_GENERAL, "Loading from BootPdi\n\r");
	Status = XLoader_ReloadImage(PdiPtr, ImageId, FuncID);
	if (Status != XST_SUCCESS) {
		goto END;
	}
	Status = XLoader_StartImage(PdiPtr);
END:
	if (Status == XST_SUCCESS) {
		XPlmi_Out32(PMC_GLOBAL_DONE, XLOADER_PDI_LOAD_COMPLETE);
	}
	return Status;
}
int XLoader_RestartImage ( u32 ImageId , u32 * FuncID ) { int Status = XST_FAILURE ; XilPdi * PdiPtr = & SubsystemPdiIns ; const XLoader_ImageStore * PdiList = XLoader_GetPdiList ( ) ; int Index = 0 ; u64 PdiAddr ; PdiPtr -> PdiType = XLOADER_PDI_TYPE_PARTIAL ; PdiPtr -> PdiSrc = XLOADER_PDI_SRC_DDR ; for ( Index = ( int ) PdiList -> Count - 1 ; Index >= 0 ; Index -- ) { PdiAddr = PdiList -> PdiAddr [ Index ] ; Status = XLoader_PdiInit ( PdiPtr , XLOADER_PDI_SRC_DDR , PdiAddr ) ; if ( Status != XST_SUCCESS ) { goto END1 ; } XPlmi_Printf ( DEBUG_GENERAL , " " " \n \r " , ( u32 ) ( PdiAddr >> 32U ) , ( u32 ) PdiAddr ) ; Status = XLoader_ReloadImage ( PdiPtr , ImageId , FuncID ) ; if ( Status != XST_SUCCESS ) { goto END1 ; } Status = XLoader_StartImage ( PdiPtr ) ; END1 : if ( Status != XST_SUCCESS ) { if ( ( Status != ( int ) XLOADER_ERR_IMG_ID_NOT_FOUND ) && ( Status != ( int ) XLOADER_ERR_FUNCTION_ID_MISMATCH ) ) { XPlmi_Printf ( DEBUG_GENERAL , " " " \n \r " , Status ) ; XPlmi_Printf ( DEBUG_GENERAL , " " " \n \r " ) ; } } else { goto END ; } } PdiPtr = BootPdiPtr ; XPlmi_Printf ( DEBUG_GENERAL , " \n \r " ) ; Status = XLoader_ReloadImage ( PdiPtr , ImageId , FuncID ) ; if ( Status != XST_SUCCESS ) { goto END ; } Status = XLoader_StartImage ( PdiPtr ) ; END : if ( Status == XST_SUCCESS ) { XPlmi_Out32 ( PMC_GLOBAL_DONE , XLOADER_PDI_LOAD_COMPLETE ) ; } return Status ; }
@brief       This function is used to restart the image in PDI.
@brief This function is used to restart the image in PDI .
/*
	 * Scan through PdiList for the given ImageId and restart image from
	 * that respective PDI if ImageId is found
	 */ /*
	 * Load image from BootPdi if the image is not found or loading is
	 * unsuccessful in the above PdiList
	 */