lib/sw_apps/zynqmp_fsbl/src/xfsbl_partition_load.c
static u32 XFsbl_GetLoadAddress(u32 DestinationCpu, PTRSIZE * LoadAddressPtr, u32 Length)
{
	u32 Status;
	PTRSIZE Address;

	Address = *LoadAddressPtr;

	/* Update for R50 TCM address if the partition fits with in a TCM bank */
	if ((DestinationCpu == XIH_PH_ATTRB_DEST_CPU_R5_0) &&
			((Address < (XFSBL_R5_TCM_START_ADDRESS + XFSBL_R5_TCM_BANK_LENGTH))||
					((Address >= XFSBL_R5_BTCM_START_ADDRESS) &&
							(Address < (XFSBL_R5_BTCM_START_ADDRESS +
							XFSBL_R5_TCM_BANK_LENGTH)))))
	{
		/* Check if fits in to a single TCM bank or not */
		if (Length > XFSBL_R5_TCM_BANK_LENGTH)
		{
			Status = XFSBL_ERROR_LOAD_ADDRESS;
			XFsbl_Printf(DEBUG_GENERAL,
				"XFSBL_ERROR_LOAD_ADDRESS\r\n");
			goto END;
		}

		/**
		 * Update Address to the higher TCM address
		 */
		Address = XFSBL_R50_HIGH_ATCM_START_ADDRESS + Address;

	} else
		/* Update for R51 TCM address if the partition fits with in a TCM bank */
		if ((DestinationCpu == XIH_PH_ATTRB_DEST_CPU_R5_1) &&
			((Address < (XFSBL_R5_TCM_START_ADDRESS + XFSBL_R5_TCM_BANK_LENGTH))||
						((Address >= XFSBL_R5_BTCM_START_ADDRESS) &&
								(Address < (XFSBL_R5_BTCM_START_ADDRESS +
							XFSBL_R5_TCM_BANK_LENGTH)))))
	{
		/* Check if fits in to a single TCM bank or not */
		if (Length > XFSBL_R5_TCM_BANK_LENGTH)
		{
			Status = XFSBL_ERROR_LOAD_ADDRESS;
			XFsbl_Printf(DEBUG_GENERAL,
				"XFSBL_ERROR_LOAD_ADDRESS\r\n");
			goto END;
		}
		/**
		 * Update Address to the higher TCM address
		 */
		Address = XFSBL_R51_HIGH_ATCM_START_ADDRESS + Address;
	} else
	/**
	 * Update for the R5-L TCM address
	 */
	if ((DestinationCpu == XIH_PH_ATTRB_DEST_CPU_R5_L) &&
			(Address < (XFSBL_R5_TCM_START_ADDRESS +
					(XFSBL_R5_TCM_BANK_LENGTH * 4U))))
	{
		/**
		 * Check if fits to TCM or not
		 */
		if (Length > (XFSBL_R5_TCM_BANK_LENGTH * 4U))
		{
			Status = XFSBL_ERROR_LOAD_ADDRESS;
			XFsbl_Printf(DEBUG_GENERAL,
				"XFSBL_ERROR_LOAD_ADDRESS\r\n");
			goto END;
		}
		/**
		 * Update Address to the higher TCM address
		 */
		Address = XFSBL_R50_HIGH_ATCM_START_ADDRESS + Address;
	} else
	{
		/**
		 * For MISRA complaince
		 */
	}

	/**
	 * Update the LoadAddress
	 */
	*LoadAddressPtr = Address;

	Status = XFSBL_SUCCESS;
END:
	return Status;
}
/*****************************************************************************/
/**
 * This function validates the load address for R5 elfs and maps it to global
 * physical TCM address space so that any cpu can access it globally.
 *
 * @param       DestinationCpu is the cpu on which partition will run
 *
 * @param       LoadAddress will be updated according to the cpu and address
 *
 * @param       Length of the data to be copied. This is required only to
 *              check for error cases
 *
 * @return      returns the error codes described in xfsbl_error.h on any error
 *                      returns XFSBL_SUCCESS on success
 *****************************************************************************/
This function validates the load address for R5 elfs and maps it to global
physical TCM address space so that any cpu can access it globally.

@param       DestinationCpu is the cpu on which partition will run

@param       LoadAddress will be updated according to the cpu and address

@param       Length of the data to be copied. This is required only to
check for error cases

@return      returns the error codes described in xfsbl_error.h on any error
returns XFSBL_SUCCESS on success
This function validates the load address for R5 elfs and maps it to global physical TCM address space so that any cpu can access it globally . @param DestinationCpu is the cpu on which partition will run @param LoadAddress will be updated according to the cpu and address @param Length of the data to be copied . This is required only to check for error cases @return returns the error codes described in xfsbl_error . h on any error returns XFSBL_SUCCESS on success
static u32 XFsbl_GetLoadAddress(u32 DestinationCpu, PTRSIZE * LoadAddressPtr, u32 Length)
{
	u32 Status;
	PTRSIZE Address;
	Address = *LoadAddressPtr;
	if ((DestinationCpu == XIH_PH_ATTRB_DEST_CPU_R5_0) &&
			((Address < (XFSBL_R5_TCM_START_ADDRESS + XFSBL_R5_TCM_BANK_LENGTH))||
					((Address >= XFSBL_R5_BTCM_START_ADDRESS) &&
							(Address < (XFSBL_R5_BTCM_START_ADDRESS +
							XFSBL_R5_TCM_BANK_LENGTH)))))
	{
		if (Length > XFSBL_R5_TCM_BANK_LENGTH)
		{
			Status = XFSBL_ERROR_LOAD_ADDRESS;
			XFsbl_Printf(DEBUG_GENERAL,
				"XFSBL_ERROR_LOAD_ADDRESS\r\n");
			goto END;
		}
		Address = XFSBL_R50_HIGH_ATCM_START_ADDRESS + Address;
	} else
		if ((DestinationCpu == XIH_PH_ATTRB_DEST_CPU_R5_1) &&
			((Address < (XFSBL_R5_TCM_START_ADDRESS + XFSBL_R5_TCM_BANK_LENGTH))||
						((Address >= XFSBL_R5_BTCM_START_ADDRESS) &&
								(Address < (XFSBL_R5_BTCM_START_ADDRESS +
							XFSBL_R5_TCM_BANK_LENGTH)))))
	{
		if (Length > XFSBL_R5_TCM_BANK_LENGTH)
		{
			Status = XFSBL_ERROR_LOAD_ADDRESS;
			XFsbl_Printf(DEBUG_GENERAL,
				"XFSBL_ERROR_LOAD_ADDRESS\r\n");
			goto END;
		}
		Address = XFSBL_R51_HIGH_ATCM_START_ADDRESS + Address;
	} else
	if ((DestinationCpu == XIH_PH_ATTRB_DEST_CPU_R5_L) &&
			(Address < (XFSBL_R5_TCM_START_ADDRESS +
					(XFSBL_R5_TCM_BANK_LENGTH * 4U))))
	{
		if (Length > (XFSBL_R5_TCM_BANK_LENGTH * 4U))
		{
			Status = XFSBL_ERROR_LOAD_ADDRESS;
			XFsbl_Printf(DEBUG_GENERAL,
				"XFSBL_ERROR_LOAD_ADDRESS\r\n");
			goto END;
		}
		Address = XFSBL_R50_HIGH_ATCM_START_ADDRESS + Address;
	} else
	{
	}
	*LoadAddressPtr = Address;
	Status = XFSBL_SUCCESS;
END:
	return Status;
}
static u32 XFsbl_GetLoadAddress ( u32 DestinationCpu , PTRSIZE * LoadAddressPtr , u32 Length ) { u32 Status ; PTRSIZE Address ; Address = * LoadAddressPtr ; if ( ( DestinationCpu == XIH_PH_ATTRB_DEST_CPU_R5_0 ) && ( ( Address < ( XFSBL_R5_TCM_START_ADDRESS + XFSBL_R5_TCM_BANK_LENGTH ) ) || ( ( Address >= XFSBL_R5_BTCM_START_ADDRESS ) && ( Address < ( XFSBL_R5_BTCM_START_ADDRESS + XFSBL_R5_TCM_BANK_LENGTH ) ) ) ) ) { if ( Length > XFSBL_R5_TCM_BANK_LENGTH ) { Status = XFSBL_ERROR_LOAD_ADDRESS ; XFsbl_Printf ( DEBUG_GENERAL , " \r \n " ) ; goto END ; } Address = XFSBL_R50_HIGH_ATCM_START_ADDRESS + Address ; } else if ( ( DestinationCpu == XIH_PH_ATTRB_DEST_CPU_R5_1 ) && ( ( Address < ( XFSBL_R5_TCM_START_ADDRESS + XFSBL_R5_TCM_BANK_LENGTH ) ) || ( ( Address >= XFSBL_R5_BTCM_START_ADDRESS ) && ( Address < ( XFSBL_R5_BTCM_START_ADDRESS + XFSBL_R5_TCM_BANK_LENGTH ) ) ) ) ) { if ( Length > XFSBL_R5_TCM_BANK_LENGTH ) { Status = XFSBL_ERROR_LOAD_ADDRESS ; XFsbl_Printf ( DEBUG_GENERAL , " \r \n " ) ; goto END ; } Address = XFSBL_R51_HIGH_ATCM_START_ADDRESS + Address ; } else if ( ( DestinationCpu == XIH_PH_ATTRB_DEST_CPU_R5_L ) && ( Address < ( XFSBL_R5_TCM_START_ADDRESS + ( XFSBL_R5_TCM_BANK_LENGTH * 4U ) ) ) ) { if ( Length > ( XFSBL_R5_TCM_BANK_LENGTH * 4U ) ) { Status = XFSBL_ERROR_LOAD_ADDRESS ; XFsbl_Printf ( DEBUG_GENERAL , " \r \n " ) ; goto END ; } Address = XFSBL_R50_HIGH_ATCM_START_ADDRESS + Address ; } else { } * LoadAddressPtr = Address ; Status = XFSBL_SUCCESS ; END : return Status ; }
This function validates the load address for R5 elfs and maps it to global
 physical TCM address space so that any cpu can access it globally.
This function validates the load address for R5 elfs and maps it to global physical TCM address space so that any cpu can access it globally .
/* Update for R50 TCM address if the partition fits with in a TCM bank */ /* Check if fits in to a single TCM bank or not */ /**
		 * Update Address to the higher TCM address
		 */ /* Update for R51 TCM address if the partition fits with in a TCM bank */ /* Check if fits in to a single TCM bank or not */ /**
		 * Update Address to the higher TCM address
		 */ /**
	 * Update for the R5-L TCM address
	 */ /**
		 * Check if fits to TCM or not
		 */ /**
		 * Update Address to the higher TCM address
		 */ /**
		 * For MISRA complaince
		 */ /**
	 * Update the LoadAddress
	 */