lib/sw_services/xilloader/src/xloader.c
static int XLoader_IdCodeCheck(const XilPdi_ImgHdrTbl * ImgHdrTbl)
{
	int Status = XST_FAILURE;
	u32 IdCodeIHT; /**< IdCode as read from IHT */
	u32 ExtIdCodeIHT; /**< Extended IdCode as read from IHT */
	u32 IdCodeRd; /**< IdCode as read from Device */
	u32 ExtIdCodeRd; /**< Extended IdCode as read from Device */
	u8 BypassChkIHT; /**< Flag to bypass checks */
	u8 IsVC1902Es1; /**< Flag to indicate IsVC1902-ES1 device */
	u8 IsExtIdCodeZero; /**< Flag to indicate Extended IdCode is valid */

	IdCodeIHT = ImgHdrTbl->Idcode;
	IdCodeRd = XPlmi_In32(PMC_TAP_IDCODE);
	ExtIdCodeIHT = ImgHdrTbl->ExtIdCode &
				XIH_IHT_EXT_IDCODE_MASK;
	ExtIdCodeRd = Xil_In32(EFUSE_CACHE_IP_DISABLE_0)
			& EFUSE_CACHE_IP_DISABLE_0_EID_MASK;

	/* Determine and fetch the Extended IDCODE (out of two) for checks */
	if (0U == ExtIdCodeRd) {
		IsExtIdCodeZero = (u8)TRUE;
	}
	else {
		IsExtIdCodeZero = (u8)FALSE;

		if ((ExtIdCodeRd &
			EFUSE_CACHE_IP_DISABLE_0_EID_SEL_MASK) == 0U) {
			ExtIdCodeRd = (ExtIdCodeRd &
				EFUSE_CACHE_IP_DISABLE_0_EID1_MASK)
				>> EFUSE_CACHE_IP_DISABLE_0_EID1_SHIFT;
		}
		else {
			ExtIdCodeRd = (ExtIdCodeRd &
					EFUSE_CACHE_IP_DISABLE_0_EID2_MASK)
					>> EFUSE_CACHE_IP_DISABLE_0_EID2_SHIFT;
		}
	}

	/* Check if VC1902 ES1 */
	if ((IdCodeRd & PMC_TAP_IDCODE_SIREV_DVCD_MASK) ==
			PMC_TAP_IDCODE_ES1_VC1902) {
		IsVC1902Es1 = (u8)TRUE;
	}
	else {
		IsVC1902Es1 = (u8)FALSE;
	}

	/* Check if a subset of checks to be bypassed */
	if (0x1U == (ImgHdrTbl->Attr & XIH_IHT_ATTR_BYPS_MASK)) {
		BypassChkIHT = (u8)TRUE;
	}
	else {
		BypassChkIHT = (u8)FALSE;
	}

	/*
	 *  EXT_IDCODE
	 *  [26:14]is 0?  VC1902-ES1?  BYPASS?  Checks done
	 *  --------------------------------------------------------------------
	 *  		Y				Y		Y	Check IDCODE[27:0] (skip Si Rev chk)
	 *  		Y				Y		N	Check IDCODE[31:0]
	 *  		Y				N		X	Invalid combination (Error out)
	 *  		N				X		Y	Check IDCODE[27:0] (skip Si Rev chk),
	 *										check ext_idcode
	 *  		N				X		N	Check IDCODE[31:0], check ext_idcode
	 *  --------------------------------------------------------------------
	 */

	/*
	 * Error out for the invalid combination of Extended IDCODE - Device.
	 * Assumption is that only VC1902-ES1 device can have Extended IDCODE value 0
	 */
	if ((IsExtIdCodeZero == (u8)TRUE) &&
			(IsVC1902Es1 == (u8)FALSE)) {
		Status = XLOADER_ERR_EXT_ID_SI;
		goto END;
	}
	else {
		/* Do not check Si revision if bypass configured */
		if ((u8)TRUE == BypassChkIHT) {
			IdCodeIHT &= ~PMC_TAP_IDCODE_SI_REV_MASK;
			IdCodeRd &= ~PMC_TAP_IDCODE_SI_REV_MASK;
		}

		/* Do the actual IDCODE check */
		if (IdCodeIHT != IdCodeRd) {
			Status = XLOADER_ERR_IDCODE;
			goto END;
		}

		/* Do the actual Extended IDCODE check */
		if ((u8)FALSE == IsExtIdCodeZero) {
			if (ExtIdCodeIHT != ExtIdCodeRd) {
				Status = XLOADER_ERR_EXT_IDCODE;
				goto END;
			}
		}
	}

	Status = XST_SUCCESS;

END:
	return Status;
}
/****************************************************************************/
/**
*  @brief	This function performs the checks of IDCODE and EXTENDED IDCODE.
*  It also supports bypass of subset of these checks.
*
* @param	ImgHdrTbl pointer to the image header table.
*
* @return	XST_SUCCESS on success and error code on failure
*
*****************************************************************************/
@brief        This function performs the checks of IDCODE and EXTENDED IDCODE.
It also supports bypass of subset of these checks.
@brief This function performs the checks of IDCODE and EXTENDED IDCODE . It also supports bypass of subset of these checks .
static int XLoader_IdCodeCheck(const XilPdi_ImgHdrTbl * ImgHdrTbl)
{
	int Status = XST_FAILURE;
	u32 IdCodeIHT; 
	u32 ExtIdCodeIHT; 
	u32 IdCodeRd; 
	u32 ExtIdCodeRd; 
	u8 BypassChkIHT; 
	u8 IsVC1902Es1; 
	u8 IsExtIdCodeZero; 
	IdCodeIHT = ImgHdrTbl->Idcode;
	IdCodeRd = XPlmi_In32(PMC_TAP_IDCODE);
	ExtIdCodeIHT = ImgHdrTbl->ExtIdCode &
				XIH_IHT_EXT_IDCODE_MASK;
	ExtIdCodeRd = Xil_In32(EFUSE_CACHE_IP_DISABLE_0)
			& EFUSE_CACHE_IP_DISABLE_0_EID_MASK;
	if (0U == ExtIdCodeRd) {
		IsExtIdCodeZero = (u8)TRUE;
	}
	else {
		IsExtIdCodeZero = (u8)FALSE;
		if ((ExtIdCodeRd &
			EFUSE_CACHE_IP_DISABLE_0_EID_SEL_MASK) == 0U) {
			ExtIdCodeRd = (ExtIdCodeRd &
				EFUSE_CACHE_IP_DISABLE_0_EID1_MASK)
				>> EFUSE_CACHE_IP_DISABLE_0_EID1_SHIFT;
		}
		else {
			ExtIdCodeRd = (ExtIdCodeRd &
					EFUSE_CACHE_IP_DISABLE_0_EID2_MASK)
					>> EFUSE_CACHE_IP_DISABLE_0_EID2_SHIFT;
		}
	}
	if ((IdCodeRd & PMC_TAP_IDCODE_SIREV_DVCD_MASK) ==
			PMC_TAP_IDCODE_ES1_VC1902) {
		IsVC1902Es1 = (u8)TRUE;
	}
	else {
		IsVC1902Es1 = (u8)FALSE;
	}
	if (0x1U == (ImgHdrTbl->Attr & XIH_IHT_ATTR_BYPS_MASK)) {
		BypassChkIHT = (u8)TRUE;
	}
	else {
		BypassChkIHT = (u8)FALSE;
	}
	if ((IsExtIdCodeZero == (u8)TRUE) &&
			(IsVC1902Es1 == (u8)FALSE)) {
		Status = XLOADER_ERR_EXT_ID_SI;
		goto END;
	}
	else {
		if ((u8)TRUE == BypassChkIHT) {
			IdCodeIHT &= ~PMC_TAP_IDCODE_SI_REV_MASK;
			IdCodeRd &= ~PMC_TAP_IDCODE_SI_REV_MASK;
		}
		if (IdCodeIHT != IdCodeRd) {
			Status = XLOADER_ERR_IDCODE;
			goto END;
		}
		if ((u8)FALSE == IsExtIdCodeZero) {
			if (ExtIdCodeIHT != ExtIdCodeRd) {
				Status = XLOADER_ERR_EXT_IDCODE;
				goto END;
			}
		}
	}
	Status = XST_SUCCESS;
END:
	return Status;
}
static int XLoader_IdCodeCheck ( const XilPdi_ImgHdrTbl * ImgHdrTbl ) { int Status = XST_FAILURE ; u32 IdCodeIHT ; u32 ExtIdCodeIHT ; u32 IdCodeRd ; u32 ExtIdCodeRd ; u8 BypassChkIHT ; u8 IsVC1902Es1 ; u8 IsExtIdCodeZero ; IdCodeIHT = ImgHdrTbl -> Idcode ; IdCodeRd = XPlmi_In32 ( PMC_TAP_IDCODE ) ; ExtIdCodeIHT = ImgHdrTbl -> ExtIdCode & XIH_IHT_EXT_IDCODE_MASK ; ExtIdCodeRd = Xil_In32 ( EFUSE_CACHE_IP_DISABLE_0 ) & EFUSE_CACHE_IP_DISABLE_0_EID_MASK ; if ( 0U == ExtIdCodeRd ) { IsExtIdCodeZero = ( u8 ) TRUE ; } else { IsExtIdCodeZero = ( u8 ) FALSE ; if ( ( ExtIdCodeRd & EFUSE_CACHE_IP_DISABLE_0_EID_SEL_MASK ) == 0U ) { ExtIdCodeRd = ( ExtIdCodeRd & EFUSE_CACHE_IP_DISABLE_0_EID1_MASK ) >> EFUSE_CACHE_IP_DISABLE_0_EID1_SHIFT ; } else { ExtIdCodeRd = ( ExtIdCodeRd & EFUSE_CACHE_IP_DISABLE_0_EID2_MASK ) >> EFUSE_CACHE_IP_DISABLE_0_EID2_SHIFT ; } } if ( ( IdCodeRd & PMC_TAP_IDCODE_SIREV_DVCD_MASK ) == PMC_TAP_IDCODE_ES1_VC1902 ) { IsVC1902Es1 = ( u8 ) TRUE ; } else { IsVC1902Es1 = ( u8 ) FALSE ; } if ( 0x1U == ( ImgHdrTbl -> Attr & XIH_IHT_ATTR_BYPS_MASK ) ) { BypassChkIHT = ( u8 ) TRUE ; } else { BypassChkIHT = ( u8 ) FALSE ; } if ( ( IsExtIdCodeZero == ( u8 ) TRUE ) && ( IsVC1902Es1 == ( u8 ) FALSE ) ) { Status = XLOADER_ERR_EXT_ID_SI ; goto END ; } else { if ( ( u8 ) TRUE == BypassChkIHT ) { IdCodeIHT &= ~ PMC_TAP_IDCODE_SI_REV_MASK ; IdCodeRd &= ~ PMC_TAP_IDCODE_SI_REV_MASK ; } if ( IdCodeIHT != IdCodeRd ) { Status = XLOADER_ERR_IDCODE ; goto END ; } if ( ( u8 ) FALSE == IsExtIdCodeZero ) { if ( ExtIdCodeIHT != ExtIdCodeRd ) { Status = XLOADER_ERR_EXT_IDCODE ; goto END ; } } } Status = XST_SUCCESS ; END : return Status ; }
@brief        This function performs the checks of IDCODE and EXTENDED IDCODE.
@brief This function performs the checks of IDCODE and EXTENDED IDCODE .
/**< IdCode as read from IHT */ /**< Extended IdCode as read from IHT */ /**< IdCode as read from Device */ /**< Extended IdCode as read from Device */ /**< Flag to bypass checks */ /**< Flag to indicate IsVC1902-ES1 device */ /**< Flag to indicate Extended IdCode is valid */ /* Determine and fetch the Extended IDCODE (out of two) for checks */ /* Check if VC1902 ES1 */ /* Check if a subset of checks to be bypassed */ /*
	 *  EXT_IDCODE
	 *  [26:14]is 0?  VC1902-ES1?  BYPASS?  Checks done
	 *  --------------------------------------------------------------------
	 *  		Y				Y		Y	Check IDCODE[27:0] (skip Si Rev chk)
	 *  		Y				Y		N	Check IDCODE[31:0]
	 *  		Y				N		X	Invalid combination (Error out)
	 *  		N				X		Y	Check IDCODE[27:0] (skip Si Rev chk),
	 *										check ext_idcode
	 *  		N				X		N	Check IDCODE[31:0], check ext_idcode
	 *  --------------------------------------------------------------------
	 */ /*
	 * Error out for the invalid combination of Extended IDCODE - Device.
	 * Assumption is that only VC1902-ES1 device can have Extended IDCODE value 0
	 */ /* Do not check Si revision if bypass configured */ /* Do the actual IDCODE check */ /* Do the actual Extended IDCODE check */