lib/sw_services/xilloader/src/xloader.c
static int XLoader_StoreImageInfo(const XLoader_ImageInfo *ImageInfo)
{
	int Status = XST_FAILURE;
	XLoader_ImageInfo *ImageEntry;
	u32 ChangeCount;
	u32 RtCfgLen;
	u32 NodeId = NODESUBCLASS(ImageInfo->ImgID);

	if (ImageInfo->ImgID == PM_DEV_PLD_0) {
		XPlmi_Out32(XPLMI_RTCFG_USR_ACCESS_ADDR, ImageInfo->FuncID);
	}
	/* Read ChangeCount */
	ChangeCount = ((XPlmi_In32(XPLMI_RTCFG_IMGINFOTBL_LEN_ADDR) &
			XPLMI_RTCFG_IMGINFOTBL_CHANGE_CTR_MASK)
			>> XPLMI_RTCFG_IMGINFOTBL_CHANGE_CTR_SHIFT);

	if ((ImageInfo->UID != XLOADER_INVALID_UID) &&
		((NodeId == (u32)XPM_NODESUBCL_DEV_PL) ||
		(NodeId == (u32)XPM_NODESUBCL_DEV_AIE))) {
		Status = XLoader_InvalidateChildImgInfo(ImageInfo->ImgID,
				&ChangeCount);
		if (Status != XST_SUCCESS) {
			Status = XPlmi_UpdateStatus(
					XLOADER_ERR_INVALIDATE_CHILD_IMG, Status);
			goto END;
		}
	}

	ImageEntry = XLoader_GetImageInfoEntry(ImageInfo->ImgID);
	if (ImageEntry == NULL) {
		ImageInfoTbl.IsBufferFull = (u8)TRUE;
		Status = XPlmi_UpdateStatus(XLOADER_ERR_IMAGE_INFO_TBL_OVERFLOW, 0);
		goto END;
	}

	if (ImageEntry->ImgID == XLOADER_INVALID_IMG_ID) {
		ImageInfoTbl.Count++;
	}
	ChangeCount++;
	Status = Xil_SecureMemCpy(ImageEntry, sizeof(XLoader_ImageInfo), ImageInfo,
			sizeof(XLoader_ImageInfo));
	if (Status != XST_SUCCESS) {
		Status = XPlmi_UpdateStatus(XPLMI_ERR_MEMCPY_IMAGE_INFO, Status);
		goto END;
	}

	/* Update ChangeCount and number of entries in the RunTime config register */
	RtCfgLen = (ImageInfoTbl.Count & XPLMI_RTCFG_IMGINFOTBL_NUM_ENTRIES_MASK);
	RtCfgLen |= ((ChangeCount << XPLMI_RTCFG_IMGINFOTBL_CHANGE_CTR_SHIFT) &
				XPLMI_RTCFG_IMGINFOTBL_CHANGE_CTR_MASK);
	XPlmi_Out32(XPLMI_RTCFG_IMGINFOTBL_LEN_ADDR, RtCfgLen);

	Status = XST_SUCCESS;

END:
	return Status;
}
/*****************************************************************************/
/**
 * @brief	This function stores the ImageInfo to Image Info Table
 *
 * @param	ImageInfo is a Pointer to ImageInfo that has to be written.
 *
 * @return	XST_SUCCESS on success and error code on failure
 *
 *****************************************************************************/
@brief       This function stores the ImageInfo to Image Info Table
@param       ImageInfo is a Pointer to ImageInfo that has to be written.

@return      XST_SUCCESS on success and error code on failure
@brief This function stores the ImageInfo to Image Info Table @param ImageInfo is a Pointer to ImageInfo that has to be written . @return XST_SUCCESS on success and error code on failure
static int XLoader_StoreImageInfo(const XLoader_ImageInfo *ImageInfo)
{
	int Status = XST_FAILURE;
	XLoader_ImageInfo *ImageEntry;
	u32 ChangeCount;
	u32 RtCfgLen;
	u32 NodeId = NODESUBCLASS(ImageInfo->ImgID);
	if (ImageInfo->ImgID == PM_DEV_PLD_0) {
		XPlmi_Out32(XPLMI_RTCFG_USR_ACCESS_ADDR, ImageInfo->FuncID);
	}
	ChangeCount = ((XPlmi_In32(XPLMI_RTCFG_IMGINFOTBL_LEN_ADDR) &
			XPLMI_RTCFG_IMGINFOTBL_CHANGE_CTR_MASK)
			>> XPLMI_RTCFG_IMGINFOTBL_CHANGE_CTR_SHIFT);
	if ((ImageInfo->UID != XLOADER_INVALID_UID) &&
		((NodeId == (u32)XPM_NODESUBCL_DEV_PL) ||
		(NodeId == (u32)XPM_NODESUBCL_DEV_AIE))) {
		Status = XLoader_InvalidateChildImgInfo(ImageInfo->ImgID,
				&ChangeCount);
		if (Status != XST_SUCCESS) {
			Status = XPlmi_UpdateStatus(
					XLOADER_ERR_INVALIDATE_CHILD_IMG, Status);
			goto END;
		}
	}
	ImageEntry = XLoader_GetImageInfoEntry(ImageInfo->ImgID);
	if (ImageEntry == NULL) {
		ImageInfoTbl.IsBufferFull = (u8)TRUE;
		Status = XPlmi_UpdateStatus(XLOADER_ERR_IMAGE_INFO_TBL_OVERFLOW, 0);
		goto END;
	}
	if (ImageEntry->ImgID == XLOADER_INVALID_IMG_ID) {
		ImageInfoTbl.Count++;
	}
	ChangeCount++;
	Status = Xil_SecureMemCpy(ImageEntry, sizeof(XLoader_ImageInfo), ImageInfo,
			sizeof(XLoader_ImageInfo));
	if (Status != XST_SUCCESS) {
		Status = XPlmi_UpdateStatus(XPLMI_ERR_MEMCPY_IMAGE_INFO, Status);
		goto END;
	}
	RtCfgLen = (ImageInfoTbl.Count & XPLMI_RTCFG_IMGINFOTBL_NUM_ENTRIES_MASK);
	RtCfgLen |= ((ChangeCount << XPLMI_RTCFG_IMGINFOTBL_CHANGE_CTR_SHIFT) &
				XPLMI_RTCFG_IMGINFOTBL_CHANGE_CTR_MASK);
	XPlmi_Out32(XPLMI_RTCFG_IMGINFOTBL_LEN_ADDR, RtCfgLen);
	Status = XST_SUCCESS;
END:
	return Status;
}
static int XLoader_StoreImageInfo ( const XLoader_ImageInfo * ImageInfo ) { int Status = XST_FAILURE ; XLoader_ImageInfo * ImageEntry ; u32 ChangeCount ; u32 RtCfgLen ; u32 NodeId = NODESUBCLASS ( ImageInfo -> ImgID ) ; if ( ImageInfo -> ImgID == PM_DEV_PLD_0 ) { XPlmi_Out32 ( XPLMI_RTCFG_USR_ACCESS_ADDR , ImageInfo -> FuncID ) ; } ChangeCount = ( ( XPlmi_In32 ( XPLMI_RTCFG_IMGINFOTBL_LEN_ADDR ) & XPLMI_RTCFG_IMGINFOTBL_CHANGE_CTR_MASK ) >> XPLMI_RTCFG_IMGINFOTBL_CHANGE_CTR_SHIFT ) ; if ( ( ImageInfo -> UID != XLOADER_INVALID_UID ) && ( ( NodeId == ( u32 ) XPM_NODESUBCL_DEV_PL ) || ( NodeId == ( u32 ) XPM_NODESUBCL_DEV_AIE ) ) ) { Status = XLoader_InvalidateChildImgInfo ( ImageInfo -> ImgID , & ChangeCount ) ; if ( Status != XST_SUCCESS ) { Status = XPlmi_UpdateStatus ( XLOADER_ERR_INVALIDATE_CHILD_IMG , Status ) ; goto END ; } } ImageEntry = XLoader_GetImageInfoEntry ( ImageInfo -> ImgID ) ; if ( ImageEntry == NULL ) { ImageInfoTbl . IsBufferFull = ( u8 ) TRUE ; Status = XPlmi_UpdateStatus ( XLOADER_ERR_IMAGE_INFO_TBL_OVERFLOW , 0 ) ; goto END ; } if ( ImageEntry -> ImgID == XLOADER_INVALID_IMG_ID ) { ImageInfoTbl . Count ++ ; } ChangeCount ++ ; Status = Xil_SecureMemCpy ( ImageEntry , sizeof ( XLoader_ImageInfo ) , ImageInfo , sizeof ( XLoader_ImageInfo ) ) ; if ( Status != XST_SUCCESS ) { Status = XPlmi_UpdateStatus ( XPLMI_ERR_MEMCPY_IMAGE_INFO , Status ) ; goto END ; } RtCfgLen = ( ImageInfoTbl . Count & XPLMI_RTCFG_IMGINFOTBL_NUM_ENTRIES_MASK ) ; RtCfgLen |= ( ( ChangeCount << XPLMI_RTCFG_IMGINFOTBL_CHANGE_CTR_SHIFT ) & XPLMI_RTCFG_IMGINFOTBL_CHANGE_CTR_MASK ) ; XPlmi_Out32 ( XPLMI_RTCFG_IMGINFOTBL_LEN_ADDR , RtCfgLen ) ; Status = XST_SUCCESS ; END : return Status ; }
@brief       This function stores the ImageInfo to Image Info Table
 @param       ImageInfo is a Pointer to ImageInfo that has to be written.
@brief This function stores the ImageInfo to Image Info Table @param ImageInfo is a Pointer to ImageInfo that has to be written .
/* Read ChangeCount */ /* Update ChangeCount and number of entries in the RunTime config register */