XilinxProcessorIPLib/drivers/usbps/src/xusbps_endpoint.c
static void XUsbPs_EpListInit(XUsbPs_DeviceConfig *DevCfgPtr)
{
	int	EpNum;
	u8	*p;

	XUsbPs_Endpoint	*Ep;
	XUsbPs_EpConfig	*EpCfg;

	/* Set up the XUsbPs_Endpoint array. This array is used to define the
	 * location of the Queue Head list and the Transfer Descriptors in the
	 * block of DMA memory that has been passed into the driver.
	 *
	 * 'p' is used to set the pointers in the local data structure.
	 * Initially 'p' is pointed to the beginning of the DMAable memory
	 * block. As pointers are assigned, 'p' is incremented by the size of
	 * the respective object.
	 */
	Ep	= DevCfgPtr->Ep;
	EpCfg	= DevCfgPtr->EpCfg;

	/* Start off with 'p' pointing to the (aligned) beginning of the DMA
	 * buffer.
	 */
	p = (u8 *) DevCfgPtr->PhysAligned;


	/* Initialize the Queue Head pointer list.
	 *
	 * Each endpoint has two Queue Heads. One for the OUT direction and one
	 * for the IN direction. An OUT Queue Head is always followed by an IN
	 * Queue Head.
	 *
	 * Queue Head alignment is XUSBPS_dQH_ALIGN.
	 *
	 * Note that we have to reserve space here for unused endpoints.
	 */
	for (EpNum = 0; EpNum < DevCfgPtr->NumEndpoints; ++EpNum) {
		/* OUT Queue Head */
		Ep[EpNum].Out.dQH = (XUsbPs_dQH *) p;
		p += XUSBPS_dQH_ALIGN;

		/* IN Queue Head */
		Ep[EpNum].In.dQH = (XUsbPs_dQH *) p;
		p += XUSBPS_dQH_ALIGN;
	}


	/* 'p' now points to the first address after the Queue Head list. The
	 * Transfer Descriptors start here.
	 *
	 * Each endpoint has a variable number of Transfer Descriptors
	 * depending on user configuration.
	 *
	 * Transfer Descriptor alignment is XUSBPS_dTD_ALIGN.
	 */
	for (EpNum = 0; EpNum < DevCfgPtr->NumEndpoints; ++EpNum) {
		/* OUT Descriptors.
		 */
		if (XUSBPS_EP_TYPE_NONE != EpCfg[EpNum].Out.Type) {
			Ep[EpNum].Out.dTDs		= (XUsbPs_dTD *) p;
			Ep[EpNum].Out.dTDCurr	= (XUsbPs_dTD *) p;
			p += XUSBPS_dTD_ALIGN * EpCfg[EpNum].Out.NumBufs;
		}

		/* IN Descriptors.
		 */
		if (XUSBPS_EP_TYPE_NONE != EpCfg[EpNum].In.Type) {
			Ep[EpNum].In.dTDs		= (XUsbPs_dTD *) p;
			Ep[EpNum].In.dTDHead	= (XUsbPs_dTD *) p;
			Ep[EpNum].In.dTDTail	= (XUsbPs_dTD *) p;
			p += XUSBPS_dTD_ALIGN * EpCfg[EpNum].In.NumBufs;
		}
	}


	/* 'p' now points to the first address after the Transfer Descriptors.
	 * The data buffers for the OUT Transfer Descriptors start here.
	 *
	 * Note that IN (TX) Transfer Descriptors are not assigned buffers at
	 * this point. Buffers will be assigned when the user calls the send()
	 * function.
	 */
	for (EpNum = 0; EpNum < DevCfgPtr->NumEndpoints; ++EpNum) {

		if (XUSBPS_EP_TYPE_NONE != EpCfg[EpNum].Out.Type) {
			/* If BufSize for this endpoint is set to 0 it means
			 * that we do not need to attach a buffer to this
			 * descriptor. We also initialize it's buffer pointer
			 * to NULL.
			 */
			if (0 == EpCfg[EpNum].Out.BufSize) {
				Ep[EpNum].Out.dTDBufs = NULL;
				continue;
			}

			Ep[EpNum].Out.dTDBufs = p;
			p += EpCfg[EpNum].Out.BufSize * EpCfg[EpNum].Out.NumBufs;
		}
	}


	/* Initialize the endpoint event handlers to NULL.
	 */
	for (EpNum = 0; EpNum < DevCfgPtr->NumEndpoints; ++EpNum) {
		Ep[EpNum].Out.HandlerFunc = NULL;
		Ep[EpNum].In.HandlerFunc  = NULL;
		Ep[EpNum].Out.HandlerIsoFunc = NULL;
		Ep[EpNum].In.HandlerIsoFunc  = NULL;
	}
}
/*****************************************************************************/
/**
*
* This function initializes the endpoint pointer data structure.
*
* The function sets up the local data structure with the aligned addresses for
* the Queue Head and Transfer Descriptors.
*
* @param	DevCfgPtr is pointer to the XUsbPs DEVICE configuration
*		structure.
*
* @return	none
*
* @note
* 		Endpoints of type XUSBPS_EP_TYPE_NONE are not used in the
* 		system. Therefore no memory is reserved for them.
*
******************************************************************************/
This function initializes the endpoint pointer data structure.
The function sets up the local data structure with the aligned addresses for
the Queue Head and Transfer Descriptors.
This function initializes the endpoint pointer data structure . The function sets up the local data structure with the aligned addresses for the Queue Head and Transfer Descriptors .
static void XUsbPs_EpListInit(XUsbPs_DeviceConfig *DevCfgPtr)
{
	int	EpNum;
	u8	*p;
	XUsbPs_Endpoint	*Ep;
	XUsbPs_EpConfig	*EpCfg;
	Ep	= DevCfgPtr->Ep;
	EpCfg	= DevCfgPtr->EpCfg;
	p = (u8 *) DevCfgPtr->PhysAligned;
	for (EpNum = 0; EpNum < DevCfgPtr->NumEndpoints; ++EpNum) {
		Ep[EpNum].Out.dQH = (XUsbPs_dQH *) p;
		p += XUSBPS_dQH_ALIGN;
		Ep[EpNum].In.dQH = (XUsbPs_dQH *) p;
		p += XUSBPS_dQH_ALIGN;
	}
	for (EpNum = 0; EpNum < DevCfgPtr->NumEndpoints; ++EpNum) {
		if (XUSBPS_EP_TYPE_NONE != EpCfg[EpNum].Out.Type) {
			Ep[EpNum].Out.dTDs		= (XUsbPs_dTD *) p;
			Ep[EpNum].Out.dTDCurr	= (XUsbPs_dTD *) p;
			p += XUSBPS_dTD_ALIGN * EpCfg[EpNum].Out.NumBufs;
		}
		if (XUSBPS_EP_TYPE_NONE != EpCfg[EpNum].In.Type) {
			Ep[EpNum].In.dTDs		= (XUsbPs_dTD *) p;
			Ep[EpNum].In.dTDHead	= (XUsbPs_dTD *) p;
			Ep[EpNum].In.dTDTail	= (XUsbPs_dTD *) p;
			p += XUSBPS_dTD_ALIGN * EpCfg[EpNum].In.NumBufs;
		}
	}
	for (EpNum = 0; EpNum < DevCfgPtr->NumEndpoints; ++EpNum) {
		if (XUSBPS_EP_TYPE_NONE != EpCfg[EpNum].Out.Type) {
			if (0 == EpCfg[EpNum].Out.BufSize) {
				Ep[EpNum].Out.dTDBufs = NULL;
				continue;
			}
			Ep[EpNum].Out.dTDBufs = p;
			p += EpCfg[EpNum].Out.BufSize * EpCfg[EpNum].Out.NumBufs;
		}
	}
	for (EpNum = 0; EpNum < DevCfgPtr->NumEndpoints; ++EpNum) {
		Ep[EpNum].Out.HandlerFunc = NULL;
		Ep[EpNum].In.HandlerFunc  = NULL;
		Ep[EpNum].Out.HandlerIsoFunc = NULL;
		Ep[EpNum].In.HandlerIsoFunc  = NULL;
	}
}
static void XUsbPs_EpListInit ( XUsbPs_DeviceConfig * DevCfgPtr ) { int EpNum ; u8 * p ; XUsbPs_Endpoint * Ep ; XUsbPs_EpConfig * EpCfg ; Ep = DevCfgPtr -> Ep ; EpCfg = DevCfgPtr -> EpCfg ; p = ( u8 * ) DevCfgPtr -> PhysAligned ; for ( EpNum = 0 ; EpNum < DevCfgPtr -> NumEndpoints ; ++ EpNum ) { Ep [ EpNum ] . Out . dQH = ( XUsbPs_dQH * ) p ; p += XUSBPS_dQH_ALIGN ; Ep [ EpNum ] . In . dQH = ( XUsbPs_dQH * ) p ; p += XUSBPS_dQH_ALIGN ; } for ( EpNum = 0 ; EpNum < DevCfgPtr -> NumEndpoints ; ++ EpNum ) { if ( XUSBPS_EP_TYPE_NONE != EpCfg [ EpNum ] . Out . Type ) { Ep [ EpNum ] . Out . dTDs = ( XUsbPs_dTD * ) p ; Ep [ EpNum ] . Out . dTDCurr = ( XUsbPs_dTD * ) p ; p += XUSBPS_dTD_ALIGN * EpCfg [ EpNum ] . Out . NumBufs ; } if ( XUSBPS_EP_TYPE_NONE != EpCfg [ EpNum ] . In . Type ) { Ep [ EpNum ] . In . dTDs = ( XUsbPs_dTD * ) p ; Ep [ EpNum ] . In . dTDHead = ( XUsbPs_dTD * ) p ; Ep [ EpNum ] . In . dTDTail = ( XUsbPs_dTD * ) p ; p += XUSBPS_dTD_ALIGN * EpCfg [ EpNum ] . In . NumBufs ; } } for ( EpNum = 0 ; EpNum < DevCfgPtr -> NumEndpoints ; ++ EpNum ) { if ( XUSBPS_EP_TYPE_NONE != EpCfg [ EpNum ] . Out . Type ) { if ( 0 == EpCfg [ EpNum ] . Out . BufSize ) { Ep [ EpNum ] . Out . dTDBufs = NULL ; continue ; } Ep [ EpNum ] . Out . dTDBufs = p ; p += EpCfg [ EpNum ] . Out . BufSize * EpCfg [ EpNum ] . Out . NumBufs ; } } for ( EpNum = 0 ; EpNum < DevCfgPtr -> NumEndpoints ; ++ EpNum ) { Ep [ EpNum ] . Out . HandlerFunc = NULL ; Ep [ EpNum ] . In . HandlerFunc = NULL ; Ep [ EpNum ] . Out . HandlerIsoFunc = NULL ; Ep [ EpNum ] . In . HandlerIsoFunc = NULL ; } }
This function initializes the endpoint pointer data structure.
This function initializes the endpoint pointer data structure .
/* Set up the XUsbPs_Endpoint array. This array is used to define the
	 * location of the Queue Head list and the Transfer Descriptors in the
	 * block of DMA memory that has been passed into the driver.
	 *
	 * 'p' is used to set the pointers in the local data structure.
	 * Initially 'p' is pointed to the beginning of the DMAable memory
	 * block. As pointers are assigned, 'p' is incremented by the size of
	 * the respective object.
	 */ /* Start off with 'p' pointing to the (aligned) beginning of the DMA
	 * buffer.
	 */ /* Initialize the Queue Head pointer list.
	 *
	 * Each endpoint has two Queue Heads. One for the OUT direction and one
	 * for the IN direction. An OUT Queue Head is always followed by an IN
	 * Queue Head.
	 *
	 * Queue Head alignment is XUSBPS_dQH_ALIGN.
	 *
	 * Note that we have to reserve space here for unused endpoints.
	 */ /* OUT Queue Head */ /* IN Queue Head */ /* 'p' now points to the first address after the Queue Head list. The
	 * Transfer Descriptors start here.
	 *
	 * Each endpoint has a variable number of Transfer Descriptors
	 * depending on user configuration.
	 *
	 * Transfer Descriptor alignment is XUSBPS_dTD_ALIGN.
	 */ /* OUT Descriptors.
		 */ /* IN Descriptors.
		 */ /* 'p' now points to the first address after the Transfer Descriptors.
	 * The data buffers for the OUT Transfer Descriptors start here.
	 *
	 * Note that IN (TX) Transfer Descriptors are not assigned buffers at
	 * this point. Buffers will be assigned when the user calls the send()
	 * function.
	 */ /* If BufSize for this endpoint is set to 0 it means
			 * that we do not need to attach a buffer to this
			 * descriptor. We also initialize it's buffer pointer
			 * to NULL.
			 */ /* Initialize the endpoint event handlers to NULL.
	 */