lib/sw_apps/zynqmp_fsbl/src/xfsbl_partition_load.c
u32 XFsbl_PartitionLoad(XFsblPs * FsblInstancePtr, u32 PartitionNum)
{
	u32 Status;
#ifdef ARMR5
	u32 Index;
#endif

#ifdef XFSBL_WDT_PRESENT
	if (XFSBL_MASTER_ONLY_RESET != FsblInstancePtr->ResetReason) {
		/* Restart WDT as partition copy can take more time */
		XFsbl_RestartWdt();
	}
#endif

#ifdef XFSBL_ENABLE_DDR_SR
	XFsbl_PollForDDRReady();
#endif

	/**
	 * Load and validate the partition
	 */

	/**
	 * Partition Header Validation
	 */
	Status = XFsbl_PartitionHeaderValidation(FsblInstancePtr, PartitionNum);

	/**
	 * FSBL is not partition owner and skip this partition
	 */
	if (Status == XFSBL_SUCCESS_NOT_PARTITION_OWNER)
	{
		Status = XFSBL_SUCCESS;
		goto END;
	} else if (XFSBL_SUCCESS != Status)
	{
		goto END;
	} else {
		/**
		 *  for MISRA C compliance
		 */
	}

	/**
	 * Partition Copy
	 */
	Status = XFsbl_PartitionCopy(FsblInstancePtr, PartitionNum);
	if (XFSBL_SUCCESS != Status)
	{
		goto END;
	}

	/**
	 * Partition Validation
	 */
	Status = XFsbl_PartitionValidation(FsblInstancePtr, PartitionNum);
	if (XFSBL_SUCCESS != Status)
	{
		goto END;
	}

#ifdef ARMR5
	if(IsR5IvtBackup == TRUE) {
		XFsbl_Printf(DEBUG_DETAILED,"XFsbl_PartitionLoad:After Partition Validation\n\r"
				"Going for LOVEC HIGHVEC Mechanism for R5.\n\r");

		/*Store LOVEC 32 bytes data to R5LovecBuffer
		 * This will copy Partition vectors into R5LovecBuffer.
		 */
		(void)XFsbl_MemCpy((u8*)R5LovecBuffer,(u8*)XFSBL_R5_LOVEC,XFSBL_IVT_LENGTH);

		/**
		 * Update the Low Vector locations in R5 TCM.
		 * It will make sure after partition authentication and decryption
		 * R5 will look for exception vectors at LOVEC only.
		 */

		Index = XFSBL_R5_LOVEC;
		while (Index<32U) {
			XFsbl_Out32(Index, XFSBL_R5_LOVEC_VALUE);
			Index += 4U;
		}

		/**
		 * Make sure that Low Vector locations are written Properly.
		 * Flush the cache*/
		Xil_DCacheFlush();

		/*Set exception vector to LOVEC */
		XFsbl_SetR5ExcepVectorLoVec();

		/* Restore R5HivecBuffer to HIVEC
		 * It will make sure that we are not corrupting HIVEC area.
		 */
		(void)XFsbl_MemCpy((u8*)XFSBL_R5_HIVEC,(u8*)R5HivecBuffer,XFSBL_IVT_LENGTH);
	}
#endif

	/* Check if PMU FW load is done and handoff it to Microblaze */
	XFsbl_CheckPmuFw(FsblInstancePtr, PartitionNum);

END:
	return Status;
}
/*****************************************************************************/
/**
 * This function loads the partition
 *
 * @param	FsblInstancePtr is pointer to the XFsbl Instance
 *
 * @param	PartitionNum is the partition number in the image to be loaded
 *
 * @return	returns the error codes described in xfsbl_error.h on any error
 * 			returns XFSBL_SUCCESS on success
 *
 *****************************************************************************/
This function loads the partition
@param       FsblInstancePtr is pointer to the XFsbl Instance

@param       PartitionNum is the partition number in the image to be loaded

@return      returns the error codes described in xfsbl_error.h on any error
returns XFSBL_SUCCESS on success
This function loads the partition @param FsblInstancePtr is pointer to the XFsbl Instance @param PartitionNum is the partition number in the image to be loaded @return returns the error codes described in xfsbl_error . h on any error returns XFSBL_SUCCESS on success
u32 XFsbl_PartitionLoad(XFsblPs * FsblInstancePtr, u32 PartitionNum)
{
	u32 Status;
#ifdef ARMR5
	u32 Index;
#endif
#ifdef XFSBL_WDT_PRESENT
	if (XFSBL_MASTER_ONLY_RESET != FsblInstancePtr->ResetReason) {
		XFsbl_RestartWdt();
	}
#endif
#ifdef XFSBL_ENABLE_DDR_SR
	XFsbl_PollForDDRReady();
#endif
	Status = XFsbl_PartitionHeaderValidation(FsblInstancePtr, PartitionNum);
	if (Status == XFSBL_SUCCESS_NOT_PARTITION_OWNER)
	{
		Status = XFSBL_SUCCESS;
		goto END;
	} else if (XFSBL_SUCCESS != Status)
	{
		goto END;
	} else {
	}
	Status = XFsbl_PartitionCopy(FsblInstancePtr, PartitionNum);
	if (XFSBL_SUCCESS != Status)
	{
		goto END;
	}
	Status = XFsbl_PartitionValidation(FsblInstancePtr, PartitionNum);
	if (XFSBL_SUCCESS != Status)
	{
		goto END;
	}
#ifdef ARMR5
	if(IsR5IvtBackup == TRUE) {
		XFsbl_Printf(DEBUG_DETAILED,"XFsbl_PartitionLoad:After Partition Validation\n\r"
				"Going for LOVEC HIGHVEC Mechanism for R5.\n\r");
		(void)XFsbl_MemCpy((u8*)R5LovecBuffer,(u8*)XFSBL_R5_LOVEC,XFSBL_IVT_LENGTH);
		Index = XFSBL_R5_LOVEC;
		while (Index<32U) {
			XFsbl_Out32(Index, XFSBL_R5_LOVEC_VALUE);
			Index += 4U;
		}
		Xil_DCacheFlush();
		XFsbl_SetR5ExcepVectorLoVec();
		(void)XFsbl_MemCpy((u8*)XFSBL_R5_HIVEC,(u8*)R5HivecBuffer,XFSBL_IVT_LENGTH);
	}
#endif
	XFsbl_CheckPmuFw(FsblInstancePtr, PartitionNum);
END:
	return Status;
}
u32 XFsbl_PartitionLoad ( XFsblPs * FsblInstancePtr , u32 PartitionNum ) { u32 Status ; #ifdef ARMR5 u32 Index ; #endif #ifdef XFSBL_WDT_PRESENT if ( XFSBL_MASTER_ONLY_RESET != FsblInstancePtr -> ResetReason ) { XFsbl_RestartWdt ( ) ; } #endif #ifdef XFSBL_ENABLE_DDR_SR XFsbl_PollForDDRReady ( ) ; #endif Status = XFsbl_PartitionHeaderValidation ( FsblInstancePtr , PartitionNum ) ; if ( Status == XFSBL_SUCCESS_NOT_PARTITION_OWNER ) { Status = XFSBL_SUCCESS ; goto END ; } else if ( XFSBL_SUCCESS != Status ) { goto END ; } else { } Status = XFsbl_PartitionCopy ( FsblInstancePtr , PartitionNum ) ; if ( XFSBL_SUCCESS != Status ) { goto END ; } Status = XFsbl_PartitionValidation ( FsblInstancePtr , PartitionNum ) ; if ( XFSBL_SUCCESS != Status ) { goto END ; } #ifdef ARMR5 if ( IsR5IvtBackup == TRUE ) { XFsbl_Printf ( DEBUG_DETAILED , " \n \r " " \n \r " ) ; ( void ) XFsbl_MemCpy ( ( u8 * ) R5LovecBuffer , ( u8 * ) XFSBL_R5_LOVEC , XFSBL_IVT_LENGTH ) ; Index = XFSBL_R5_LOVEC ; while ( Index < 32U ) { XFsbl_Out32 ( Index , XFSBL_R5_LOVEC_VALUE ) ; Index += 4U ; } Xil_DCacheFlush ( ) ; XFsbl_SetR5ExcepVectorLoVec ( ) ; ( void ) XFsbl_MemCpy ( ( u8 * ) XFSBL_R5_HIVEC , ( u8 * ) R5HivecBuffer , XFSBL_IVT_LENGTH ) ; } #endif XFsbl_CheckPmuFw ( FsblInstancePtr , PartitionNum ) ; END : return Status ; }
This function loads the partition
 @param       FsblInstancePtr is pointer to the XFsbl Instance
This function loads the partition @param FsblInstancePtr is pointer to the XFsbl Instance
/* Restart WDT as partition copy can take more time */ /**
	 * Load and validate the partition
	 */ /**
	 * Partition Header Validation
	 */ /**
	 * FSBL is not partition owner and skip this partition
	 */ /**
		 *  for MISRA C compliance
		 */ /**
	 * Partition Copy
	 */ /**
	 * Partition Validation
	 */ /*Store LOVEC 32 bytes data to R5LovecBuffer
		 * This will copy Partition vectors into R5LovecBuffer.
		 */ /**
		 * Update the Low Vector locations in R5 TCM.
		 * It will make sure after partition authentication and decryption
		 * R5 will look for exception vectors at LOVEC only.
		 */ /**
		 * Make sure that Low Vector locations are written Properly.
		 * Flush the cache*/ /*Set exception vector to LOVEC */ /* Restore R5HivecBuffer to HIVEC
		 * It will make sure that we are not corrupting HIVEC area.
		 */ /* Check if PMU FW load is done and handoff it to Microblaze */