XilinxProcessorIPLib/drivers/pciepsu/src/xpciepsu_caps.c
u64 XPciePsu_GetCapability(XPciePsu *InstancePtr, u8 Bus, u8 Device,
		u8 Function, u8 CapId)
{
	u32 CapBase = XPciePsu_GetBaseCapability(InstancePtr, Bus, Device,
			Function);
	u32 Adr = 0;
	u64 Location = CAP_NOT_PRESENT;
	u32 Offset;


	while (CapBase != 0U) {
		Adr = CapBase;
		if (XPciePsu_ReadConfigSpace(InstancePtr, Bus, Device,
			Function, XPciePsu_GetCapabilityAddr(CapBase), &CapBase) != (u8)XST_SUCCESS) {
			break;
		}
		if (CapId == (CapBase & XPCIEPSU_CFG_CAP_ID_LOC)) {
			Offset = XPciePsu_ComposeExternalConfigAddress(
					Bus, Device, Function, XPciePsu_GetCapabilityAddr(Adr));
			Location = (InstancePtr->Config.Ecam) + (Offset);
			break;
		}
		CapBase = (u32)((CapBase >> XPCIEPSU_CAP_SHIFT) & (u32)XPCIEPSU_CAP_PTR_LOC);
	}

	return Location;
}
/******************************************************************************/
/**
* This function returns offset to the matching capability ID from the
* Function's Linked list of the capability registers.
*
* @param   InstancePtr pointer to XPciePsu Instance Pointer
* @param   Bus is the number of the Bus
* @param   Device is the number of the Device
* @param   Function is number of the Function
* @param   cap id to get capability pointer offset
*
* @return  u64 capability pointer if available
* 0 if not available.
*
*******************************************************************************/
This function returns offset to the matching capability ID from the
Function's Linked list of the capability registers.
This function returns offset to the matching capability ID from the Function ' s Linked list of the capability registers .
u64 XPciePsu_GetCapability(XPciePsu *InstancePtr, u8 Bus, u8 Device,
		u8 Function, u8 CapId)
{
	u32 CapBase = XPciePsu_GetBaseCapability(InstancePtr, Bus, Device,
			Function);
	u32 Adr = 0;
	u64 Location = CAP_NOT_PRESENT;
	u32 Offset;
	while (CapBase != 0U) {
		Adr = CapBase;
		if (XPciePsu_ReadConfigSpace(InstancePtr, Bus, Device,
			Function, XPciePsu_GetCapabilityAddr(CapBase), &CapBase) != (u8)XST_SUCCESS) {
			break;
		}
		if (CapId == (CapBase & XPCIEPSU_CFG_CAP_ID_LOC)) {
			Offset = XPciePsu_ComposeExternalConfigAddress(
					Bus, Device, Function, XPciePsu_GetCapabilityAddr(Adr));
			Location = (InstancePtr->Config.Ecam) + (Offset);
			break;
		}
		CapBase = (u32)((CapBase >> XPCIEPSU_CAP_SHIFT) & (u32)XPCIEPSU_CAP_PTR_LOC);
	}
	return Location;
}
u64 XPciePsu_GetCapability ( XPciePsu * InstancePtr , u8 Bus , u8 Device , u8 Function , u8 CapId ) { u32 CapBase = XPciePsu_GetBaseCapability ( InstancePtr , Bus , Device , Function ) ; u32 Adr = 0 ; u64 Location = CAP_NOT_PRESENT ; u32 Offset ; while ( CapBase != 0U ) { Adr = CapBase ; if ( XPciePsu_ReadConfigSpace ( InstancePtr , Bus , Device , Function , XPciePsu_GetCapabilityAddr ( CapBase ) , & CapBase ) != ( u8 ) XST_SUCCESS ) { break ; } if ( CapId == ( CapBase & XPCIEPSU_CFG_CAP_ID_LOC ) ) { Offset = XPciePsu_ComposeExternalConfigAddress ( Bus , Device , Function , XPciePsu_GetCapabilityAddr ( Adr ) ) ; Location = ( InstancePtr -> Config . Ecam ) + ( Offset ) ; break ; } CapBase = ( u32 ) ( ( CapBase >> XPCIEPSU_CAP_SHIFT ) & ( u32 ) XPCIEPSU_CAP_PTR_LOC ) ; } return Location ; }
This function returns offset to the matching capability ID from the
Function's Linked list of the capability registers.
This function returns offset to the matching capability ID from the Function ' s Linked list of the capability registers .