lib/sw_services/xilloader/src/xloader.c
static int XLoader_LoadAndStartSubSystemImages(XilPdi *PdiPtr)
{
	int Status = XST_FAILURE;
	int SStatus = XST_FAILURE;
	u8 NoOfDelayedHandoffCpus = 0U;
	u8 DelayHandoffImageNum[XLOADER_MAX_HANDOFF_CPUS];
	u8 DelayHandoffPrtnNum[XLOADER_MAX_HANDOFF_CPUS];
	u8 Index = 0U;
	u8 ImageNum;
	u8 PrtnNum;
	u8 PrtnIndex;

	/*
	 * From the meta header present in PDI pointer, read the subsystem
	 * image details and load, start all the images
	 *
	 * For every image,
	 *   1. Read the CDO file if present
	 *   2. Send the CDO file to cdo parser which directs
	 *      CDO commands to Xilpm, and other components
	 *   3. Load partitions to respective memories
	 */
	for ( ; PdiPtr->ImageNum < (u8)PdiPtr->MetaHdr.ImgHdrTbl.NoOfImgs;
			++PdiPtr->ImageNum) {
		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) {
				Status = XLoader_DdrInit(XLOADER_HOLD_DDR);
				if (Status != XST_SUCCESS) {
					goto END;
				}
				PdiPtr->CopyToMemAddr =
						PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum].CopyToMemoryAddr;
			}
		}
		else {
			PdiPtr->CopyToMem = (u8)FALSE;
		}

		PdiPtr->DelayHandoff = (u8)(XilPdi_GetDelayHandoff(
			&PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum]) >>
			XILPDI_IH_ATTRIB_DELAY_HANDOFF_SHIFT);
		PdiPtr->DelayLoad = (u8)(XilPdi_GetDelayLoad(
			&PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum]) >>
			XILPDI_IH_ATTRIB_DELAY_LOAD_SHIFT);

		if (PdiPtr->DelayHandoff == (u8)TRUE) {
			if (PdiPtr->DelayLoad == (u8)TRUE) {
				Status = XPlmi_UpdateStatus(XLOADER_ERR_DELAY_ATTRB, 0);
				goto END;
			}

			if (NoOfDelayedHandoffCpus == XLOADER_MAX_HANDOFF_CPUS) {
				Status = XPlmi_UpdateStatus(
						XLOADER_ERR_NUM_HANDOFF_CPUS, 0);
				goto END;
			}
			DelayHandoffImageNum[NoOfDelayedHandoffCpus] =
					PdiPtr->ImageNum;
			DelayHandoffPrtnNum[NoOfDelayedHandoffCpus] =
					PdiPtr->PrtnNum;
			NoOfDelayedHandoffCpus += 1U;
		}

		Status = XLoader_LoadImage(PdiPtr);
		if (Status != XST_SUCCESS) {
			/* Check for Cfi errors */
			if (NODESUBCLASS(
				PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum].ImgID)
					== (u32)XPM_NODESUBCL_DEV_PL) {
				/*
				 * To preserve the PDI error, ignoring the
				 * Error returned by XLoader_CframeErrorHandler
				 */
				XLoader_CframeErrorHandler(
					PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum].ImgID);
			}
			goto END;
		}

		if ((PdiPtr->DelayLoad == (u8)TRUE) ||
			(PdiPtr->DelayHandoff == (u8)TRUE)) {
			continue;
		}

		Status = XLoader_StartImage(PdiPtr);
		if (Status != XST_SUCCESS) {
			goto END;
		}
	}

	/* Delay Handoff starts here */
	for ( ; Index < NoOfDelayedHandoffCpus; ++Index) {
		ImageNum = DelayHandoffImageNum[Index];
		PrtnNum = DelayHandoffPrtnNum[Index];
		PdiPtr->PrtnNum = PrtnNum;
		for (PrtnIndex = 0U;
			PrtnIndex < (u8)PdiPtr->MetaHdr.ImgHdr[ImageNum].NoOfPrtns;
			PrtnIndex++) {
			Status = XLoader_UpdateHandoffParam(PdiPtr);
			if (Status != XST_SUCCESS) {
				goto END;
			}
			PdiPtr->PrtnNum++;
		}

		Status = XLoader_StartImage(PdiPtr);
		if (Status != XST_SUCCESS) {
			goto END;
		}
	}

	Status = XST_SUCCESS;

END:
	if (DeviceOps[PdiPtr->PdiIndex].Release != NULL) {
		SStatus = DeviceOps[PdiPtr->PdiIndex].Release();
		if (Status == XST_SUCCESS) {
			Status = SStatus;
		}
	}

#ifndef PLM_DEBUG_MODE
	SStatus = XPlmi_MemSet(XPLMI_PMCRAM_CHUNK_MEMORY, XPLMI_DATA_INIT_PZM,
			XLOADER_TOTAL_CHUNK_SIZE / XPLMI_WORD_LEN);
	if (Status == XST_SUCCESS) {
		Status = SStatus;
	}
#endif

	return Status;
}
/*****************************************************************************/
/**
 * @brief	This function is used to load and start images. It reads
 * meta header, loads the images as present in the PDI and starts images based
 * on hand-off information present in PDI.
 *
 * @param	PdiPtr is Pdi instance pointer
 *
 * @return	XST_SUCCESS on success and error code on failure
 *
 *****************************************************************************/
@brief       This function is used to load and start images. It reads
meta header, loads the images as present in the PDI and starts images based
on hand-off information present in PDI.

@param       PdiPtr is Pdi instance pointer

@return      XST_SUCCESS on success and error code on failure
@brief This function is used to load and start images . It reads meta header loads the images as present in the PDI and starts images based on hand - off information present in PDI . @param PdiPtr is Pdi instance pointer @return XST_SUCCESS on success and error code on failure
static int XLoader_LoadAndStartSubSystemImages(XilPdi *PdiPtr)
{
	int Status = XST_FAILURE;
	int SStatus = XST_FAILURE;
	u8 NoOfDelayedHandoffCpus = 0U;
	u8 DelayHandoffImageNum[XLOADER_MAX_HANDOFF_CPUS];
	u8 DelayHandoffPrtnNum[XLOADER_MAX_HANDOFF_CPUS];
	u8 Index = 0U;
	u8 ImageNum;
	u8 PrtnNum;
	u8 PrtnIndex;
	for ( ; PdiPtr->ImageNum < (u8)PdiPtr->MetaHdr.ImgHdrTbl.NoOfImgs;
			++PdiPtr->ImageNum) {
		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) {
				Status = XLoader_DdrInit(XLOADER_HOLD_DDR);
				if (Status != XST_SUCCESS) {
					goto END;
				}
				PdiPtr->CopyToMemAddr =
						PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum].CopyToMemoryAddr;
			}
		}
		else {
			PdiPtr->CopyToMem = (u8)FALSE;
		}
		PdiPtr->DelayHandoff = (u8)(XilPdi_GetDelayHandoff(
			&PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum]) >>
			XILPDI_IH_ATTRIB_DELAY_HANDOFF_SHIFT);
		PdiPtr->DelayLoad = (u8)(XilPdi_GetDelayLoad(
			&PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum]) >>
			XILPDI_IH_ATTRIB_DELAY_LOAD_SHIFT);
		if (PdiPtr->DelayHandoff == (u8)TRUE) {
			if (PdiPtr->DelayLoad == (u8)TRUE) {
				Status = XPlmi_UpdateStatus(XLOADER_ERR_DELAY_ATTRB, 0);
				goto END;
			}
			if (NoOfDelayedHandoffCpus == XLOADER_MAX_HANDOFF_CPUS) {
				Status = XPlmi_UpdateStatus(
						XLOADER_ERR_NUM_HANDOFF_CPUS, 0);
				goto END;
			}
			DelayHandoffImageNum[NoOfDelayedHandoffCpus] =
					PdiPtr->ImageNum;
			DelayHandoffPrtnNum[NoOfDelayedHandoffCpus] =
					PdiPtr->PrtnNum;
			NoOfDelayedHandoffCpus += 1U;
		}
		Status = XLoader_LoadImage(PdiPtr);
		if (Status != XST_SUCCESS) {
			if (NODESUBCLASS(
				PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum].ImgID)
					== (u32)XPM_NODESUBCL_DEV_PL) {
				XLoader_CframeErrorHandler(
					PdiPtr->MetaHdr.ImgHdr[PdiPtr->ImageNum].ImgID);
			}
			goto END;
		}
		if ((PdiPtr->DelayLoad == (u8)TRUE) ||
			(PdiPtr->DelayHandoff == (u8)TRUE)) {
			continue;
		}
		Status = XLoader_StartImage(PdiPtr);
		if (Status != XST_SUCCESS) {
			goto END;
		}
	}
	for ( ; Index < NoOfDelayedHandoffCpus; ++Index) {
		ImageNum = DelayHandoffImageNum[Index];
		PrtnNum = DelayHandoffPrtnNum[Index];
		PdiPtr->PrtnNum = PrtnNum;
		for (PrtnIndex = 0U;
			PrtnIndex < (u8)PdiPtr->MetaHdr.ImgHdr[ImageNum].NoOfPrtns;
			PrtnIndex++) {
			Status = XLoader_UpdateHandoffParam(PdiPtr);
			if (Status != XST_SUCCESS) {
				goto END;
			}
			PdiPtr->PrtnNum++;
		}
		Status = XLoader_StartImage(PdiPtr);
		if (Status != XST_SUCCESS) {
			goto END;
		}
	}
	Status = XST_SUCCESS;
END:
	if (DeviceOps[PdiPtr->PdiIndex].Release != NULL) {
		SStatus = DeviceOps[PdiPtr->PdiIndex].Release();
		if (Status == XST_SUCCESS) {
			Status = SStatus;
		}
	}
#ifndef PLM_DEBUG_MODE
	SStatus = XPlmi_MemSet(XPLMI_PMCRAM_CHUNK_MEMORY, XPLMI_DATA_INIT_PZM,
			XLOADER_TOTAL_CHUNK_SIZE / XPLMI_WORD_LEN);
	if (Status == XST_SUCCESS) {
		Status = SStatus;
	}
#endif
	return Status;
}
static int XLoader_LoadAndStartSubSystemImages ( XilPdi * PdiPtr ) { int Status = XST_FAILURE ; int SStatus = XST_FAILURE ; u8 NoOfDelayedHandoffCpus = 0U ; u8 DelayHandoffImageNum [ XLOADER_MAX_HANDOFF_CPUS ] ; u8 DelayHandoffPrtnNum [ XLOADER_MAX_HANDOFF_CPUS ] ; u8 Index = 0U ; u8 ImageNum ; u8 PrtnNum ; u8 PrtnIndex ; for ( ; PdiPtr -> ImageNum < ( u8 ) PdiPtr -> MetaHdr . ImgHdrTbl . NoOfImgs ; ++ PdiPtr -> ImageNum ) { 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 ) { Status = XLoader_DdrInit ( XLOADER_HOLD_DDR ) ; if ( Status != XST_SUCCESS ) { goto END ; } PdiPtr -> CopyToMemAddr = PdiPtr -> MetaHdr . ImgHdr [ PdiPtr -> ImageNum ] . CopyToMemoryAddr ; } } else { PdiPtr -> CopyToMem = ( u8 ) FALSE ; } PdiPtr -> DelayHandoff = ( u8 ) ( XilPdi_GetDelayHandoff ( & PdiPtr -> MetaHdr . ImgHdr [ PdiPtr -> ImageNum ] ) >> XILPDI_IH_ATTRIB_DELAY_HANDOFF_SHIFT ) ; PdiPtr -> DelayLoad = ( u8 ) ( XilPdi_GetDelayLoad ( & PdiPtr -> MetaHdr . ImgHdr [ PdiPtr -> ImageNum ] ) >> XILPDI_IH_ATTRIB_DELAY_LOAD_SHIFT ) ; if ( PdiPtr -> DelayHandoff == ( u8 ) TRUE ) { if ( PdiPtr -> DelayLoad == ( u8 ) TRUE ) { Status = XPlmi_UpdateStatus ( XLOADER_ERR_DELAY_ATTRB , 0 ) ; goto END ; } if ( NoOfDelayedHandoffCpus == XLOADER_MAX_HANDOFF_CPUS ) { Status = XPlmi_UpdateStatus ( XLOADER_ERR_NUM_HANDOFF_CPUS , 0 ) ; goto END ; } DelayHandoffImageNum [ NoOfDelayedHandoffCpus ] = PdiPtr -> ImageNum ; DelayHandoffPrtnNum [ NoOfDelayedHandoffCpus ] = PdiPtr -> PrtnNum ; NoOfDelayedHandoffCpus += 1U ; } Status = XLoader_LoadImage ( PdiPtr ) ; if ( Status != XST_SUCCESS ) { if ( NODESUBCLASS ( PdiPtr -> MetaHdr . ImgHdr [ PdiPtr -> ImageNum ] . ImgID ) == ( u32 ) XPM_NODESUBCL_DEV_PL ) { XLoader_CframeErrorHandler ( PdiPtr -> MetaHdr . ImgHdr [ PdiPtr -> ImageNum ] . ImgID ) ; } goto END ; } if ( ( PdiPtr -> DelayLoad == ( u8 ) TRUE ) || ( PdiPtr -> DelayHandoff == ( u8 ) TRUE ) ) { continue ; } Status = XLoader_StartImage ( PdiPtr ) ; if ( Status != XST_SUCCESS ) { goto END ; } } for ( ; Index < NoOfDelayedHandoffCpus ; ++ Index ) { ImageNum = DelayHandoffImageNum [ Index ] ; PrtnNum = DelayHandoffPrtnNum [ Index ] ; PdiPtr -> PrtnNum = PrtnNum ; for ( PrtnIndex = 0U ; PrtnIndex < ( u8 ) PdiPtr -> MetaHdr . ImgHdr [ ImageNum ] . NoOfPrtns ; PrtnIndex ++ ) { Status = XLoader_UpdateHandoffParam ( PdiPtr ) ; if ( Status != XST_SUCCESS ) { goto END ; } PdiPtr -> PrtnNum ++ ; } Status = XLoader_StartImage ( PdiPtr ) ; if ( Status != XST_SUCCESS ) { goto END ; } } Status = XST_SUCCESS ; END : if ( DeviceOps [ PdiPtr -> PdiIndex ] . Release != NULL ) { SStatus = DeviceOps [ PdiPtr -> PdiIndex ] . Release ( ) ; if ( Status == XST_SUCCESS ) { Status = SStatus ; } } #ifndef PLM_DEBUG_MODE SStatus = XPlmi_MemSet ( XPLMI_PMCRAM_CHUNK_MEMORY , XPLMI_DATA_INIT_PZM , XLOADER_TOTAL_CHUNK_SIZE / XPLMI_WORD_LEN ) ; if ( Status == XST_SUCCESS ) { Status = SStatus ; } #endif return Status ; }
@brief       This function is used to load and start images.
@brief This function is used to load and start images .
/*
	 * From the meta header present in PDI pointer, read the subsystem
	 * image details and load, start all the images
	 *
	 * For every image,
	 *   1. Read the CDO file if present
	 *   2. Send the CDO file to cdo parser which directs
	 *      CDO commands to Xilpm, and other components
	 *   3. Load partitions to respective memories
	 */ /* Check for Cfi errors */ /*
				 * To preserve the PDI error, ignoring the
				 * Error returned by XLoader_CframeErrorHandler
				 */ /* Delay Handoff starts here */