XilinxProcessorIPLib/drivers/axiethernet/examples/xaxiethernet_example_intr_sgdma.c
static int AxiEthernetSetupIntrSystem(INTC *IntcInstancePtr,
				XAxiEthernet *AxiEthernetInstancePtr,
				XAxiDma *DmaInstancePtr,
				u16 AxiEthernetIntrId,
				u16 DmaRxIntrId,
				u16 DmaTxIntrId)
{
	XAxiDma_BdRing * TxRingPtr = XAxiDma_GetTxRing(DmaInstancePtr);
	XAxiDma_BdRing * RxRingPtr = XAxiDma_GetRxRing(DmaInstancePtr);

	int Status;
#ifdef XPAR_INTC_0_DEVICE_ID
#ifndef TESTAPP_GEN
	/*
	 * Initialize the interrupt controller and connect the ISR
	 */
	Status = XIntc_Initialize(IntcInstancePtr, INTC_DEVICE_ID);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Unable to initialize the interrupt controller");
		return XST_FAILURE;
	}
#endif

#if XPAR_INTC_0_HAS_FAST == 1

	TxRingPtr_Fast = TxRingPtr;
	RxRingPtr_Fast = RxRingPtr;
	AxiEthernetInstancePtr_Fast = AxiEthernetInstancePtr;
	Status = XIntc_ConnectFastHandler(IntcInstancePtr, AxiEthernetIntrId,
						(XFastInterruptHandler) AxiEthernetErrorFastHandler);
	Status |= XIntc_ConnectFastHandler(IntcInstancePtr, DmaTxIntrId,
								(XFastInterruptHandler) TxIntrFastHandler);
	Status |= XIntc_ConnectFastHandler(IntcInstancePtr, DmaRxIntrId,
								(XFastInterruptHandler) RxIntrFastHandler);
#else
	Status = XIntc_Connect(IntcInstancePtr, AxiEthernetIntrId,
								(XInterruptHandler)AxiEthernetErrorHandler,
									AxiEthernetInstancePtr);
	Status |= XIntc_Connect(IntcInstancePtr, DmaTxIntrId,
								(XInterruptHandler) TxIntrHandler, TxRingPtr);
	Status |= XIntc_Connect(IntcInstancePtr, DmaRxIntrId,
								(XInterruptHandler) RxIntrHandler, RxRingPtr);

#endif

	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Unable to connect ISR to interrupt controller");
		return XST_FAILURE;
	}

#ifndef TESTAPP_GEN
	/*
	 * Start the interrupt controller
	 */
	Status = XIntc_Start(IntcInstancePtr, XIN_REAL_MODE);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Error starting intc");
		return XST_FAILURE;
	}
#endif


	/*
	 * Enable interrupts from the hardware
	 */
	XIntc_Enable(IntcInstancePtr, AxiEthernetIntrId);
	XIntc_Enable(IntcInstancePtr, DmaTxIntrId);
	XIntc_Enable(IntcInstancePtr, DmaRxIntrId);
#else
	XScuGic_Config *IntcConfig;


	/*
	 * Initialize the interrupt controller driver so that it is ready to
	 * use.
	 */
	IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
	if (NULL == IntcConfig) {
		return XST_FAILURE;
	}

	Status = XScuGic_CfgInitialize(IntcInstancePtr, IntcConfig,
					IntcConfig->CpuBaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}


	XScuGic_SetPriorityTriggerType(IntcInstancePtr, DmaTxIntrId, 0xA0, 0x3);

	XScuGic_SetPriorityTriggerType(IntcInstancePtr, DmaRxIntrId, 0xA0, 0x3);

	XScuGic_SetPriorityTriggerType(IntcInstancePtr, AxiEthernetIntrId, 0xA0, 0x3);
	/*
	 * Connect the device driver handler that will be called when an
	 * interrupt for the device occurs, the handler defined above performs
	 * the specific interrupt processing for the device.
	 */
	Status = XScuGic_Connect(IntcInstancePtr, DmaTxIntrId,
				(Xil_InterruptHandler)TxIntrHandler,
				TxRingPtr);
	if (Status != XST_SUCCESS) {
		return Status;
	}

	Status = XScuGic_Connect(IntcInstancePtr, DmaRxIntrId,
				(Xil_InterruptHandler)RxIntrHandler,
				RxRingPtr);
	if (Status != XST_SUCCESS) {
		return Status;
	}

	Status = XScuGic_Connect(IntcInstancePtr, AxiEthernetIntrId,
				(Xil_InterruptHandler)AxiEthernetErrorHandler,
				AxiEthernetInstancePtr);
	if (Status != XST_SUCCESS) {
		return Status;
	}

	XScuGic_Enable(IntcInstancePtr, AxiEthernetIntrId);
	XScuGic_Enable(IntcInstancePtr, DmaTxIntrId);
	XScuGic_Enable(IntcInstancePtr, DmaRxIntrId);
#endif
#ifndef TESTAPP_GEN
	Xil_ExceptionInit();

	Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
			(Xil_ExceptionHandler)INTC_HANDLER,
			(void *)(IntcInstancePtr));

	Xil_ExceptionEnable();

#endif

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function setups the interrupt system so interrupts can occur for the
* Axi Ethernet.  This function is application-specific since the actual system
* may or may not have an interrupt controller.  The Axi Ethernet could be
* directly connected to a processor without an interrupt controller.  The user
* should modify this function to fit the application.
*
* @param	IntcInstancePtr is a pointer to the instance of the Intc
*		component.
* @param	AxiEthernetInstancePtr is a pointer to the instance of the
* 		AxiEthernet component.
* @param	DmaInstancePtr is a pointer to the instance of the AXIDMA
*		component.
* @param	AxiEthernetIntrId is the Interrupt ID and is typically
*		XPAR_<INTC_instance>_<AXIETHERNET_instance>_VEC_ID
*		value from xparameters.h.
* @param	DmaRxIntrId is the interrupt id for DMA Rx and is typically
*		taken from XPAR_<AXIETHERNET_instance>_CONNECTED_DMARX_INTR
* @param	DmaTxIntrId is the interrupt id for DMA Tx and is typically
*		taken from XPAR_<AXIETHERNET_instance>_CONNECTED_DMATX_INTR
*
* @return	-XST_SUCCESS to indicate success
*		-XST_FAILURE to indicate failure
*
* @note		None.
*
******************************************************************************/
This function setups the interrupt system so interrupts can occur for the
Axi Ethernet.  This function is application-specific since the actual system
may or may not have an interrupt controller.  The Axi Ethernet could be
directly connected to a processor without an interrupt controller.  The user
should modify this function to fit the application.
This function setups the interrupt system so interrupts can occur for the Axi Ethernet . This function is application - specific since the actual system may or may not have an interrupt controller . The Axi Ethernet could be directly connected to a processor without an interrupt controller . The user should modify this function to fit the application .
static int AxiEthernetSetupIntrSystem(INTC *IntcInstancePtr,
				XAxiEthernet *AxiEthernetInstancePtr,
				XAxiDma *DmaInstancePtr,
				u16 AxiEthernetIntrId,
				u16 DmaRxIntrId,
				u16 DmaTxIntrId)
{
	XAxiDma_BdRing * TxRingPtr = XAxiDma_GetTxRing(DmaInstancePtr);
	XAxiDma_BdRing * RxRingPtr = XAxiDma_GetRxRing(DmaInstancePtr);
	int Status;
#ifdef XPAR_INTC_0_DEVICE_ID
#ifndef TESTAPP_GEN
	Status = XIntc_Initialize(IntcInstancePtr, INTC_DEVICE_ID);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Unable to initialize the interrupt controller");
		return XST_FAILURE;
	}
#endif
#if XPAR_INTC_0_HAS_FAST == 1
	TxRingPtr_Fast = TxRingPtr;
	RxRingPtr_Fast = RxRingPtr;
	AxiEthernetInstancePtr_Fast = AxiEthernetInstancePtr;
	Status = XIntc_ConnectFastHandler(IntcInstancePtr, AxiEthernetIntrId,
						(XFastInterruptHandler) AxiEthernetErrorFastHandler);
	Status |= XIntc_ConnectFastHandler(IntcInstancePtr, DmaTxIntrId,
								(XFastInterruptHandler) TxIntrFastHandler);
	Status |= XIntc_ConnectFastHandler(IntcInstancePtr, DmaRxIntrId,
								(XFastInterruptHandler) RxIntrFastHandler);
#else
	Status = XIntc_Connect(IntcInstancePtr, AxiEthernetIntrId,
								(XInterruptHandler)AxiEthernetErrorHandler,
									AxiEthernetInstancePtr);
	Status |= XIntc_Connect(IntcInstancePtr, DmaTxIntrId,
								(XInterruptHandler) TxIntrHandler, TxRingPtr);
	Status |= XIntc_Connect(IntcInstancePtr, DmaRxIntrId,
								(XInterruptHandler) RxIntrHandler, RxRingPtr);
#endif
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Unable to connect ISR to interrupt controller");
		return XST_FAILURE;
	}
#ifndef TESTAPP_GEN
	Status = XIntc_Start(IntcInstancePtr, XIN_REAL_MODE);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Error starting intc");
		return XST_FAILURE;
	}
#endif
	XIntc_Enable(IntcInstancePtr, AxiEthernetIntrId);
	XIntc_Enable(IntcInstancePtr, DmaTxIntrId);
	XIntc_Enable(IntcInstancePtr, DmaRxIntrId);
#else
	XScuGic_Config *IntcConfig;
	IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
	if (NULL == IntcConfig) {
		return XST_FAILURE;
	}
	Status = XScuGic_CfgInitialize(IntcInstancePtr, IntcConfig,
					IntcConfig->CpuBaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XScuGic_SetPriorityTriggerType(IntcInstancePtr, DmaTxIntrId, 0xA0, 0x3);
	XScuGic_SetPriorityTriggerType(IntcInstancePtr, DmaRxIntrId, 0xA0, 0x3);
	XScuGic_SetPriorityTriggerType(IntcInstancePtr, AxiEthernetIntrId, 0xA0, 0x3);
	Status = XScuGic_Connect(IntcInstancePtr, DmaTxIntrId,
				(Xil_InterruptHandler)TxIntrHandler,
				TxRingPtr);
	if (Status != XST_SUCCESS) {
		return Status;
	}
	Status = XScuGic_Connect(IntcInstancePtr, DmaRxIntrId,
				(Xil_InterruptHandler)RxIntrHandler,
				RxRingPtr);
	if (Status != XST_SUCCESS) {
		return Status;
	}
	Status = XScuGic_Connect(IntcInstancePtr, AxiEthernetIntrId,
				(Xil_InterruptHandler)AxiEthernetErrorHandler,
				AxiEthernetInstancePtr);
	if (Status != XST_SUCCESS) {
		return Status;
	}
	XScuGic_Enable(IntcInstancePtr, AxiEthernetIntrId);
	XScuGic_Enable(IntcInstancePtr, DmaTxIntrId);
	XScuGic_Enable(IntcInstancePtr, DmaRxIntrId);
#endif
#ifndef TESTAPP_GEN
	Xil_ExceptionInit();
	Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
			(Xil_ExceptionHandler)INTC_HANDLER,
			(void *)(IntcInstancePtr));
	Xil_ExceptionEnable();
#endif
	return XST_SUCCESS;
}
static int AxiEthernetSetupIntrSystem ( INTC * IntcInstancePtr , XAxiEthernet * AxiEthernetInstancePtr , XAxiDma * DmaInstancePtr , u16 AxiEthernetIntrId , u16 DmaRxIntrId , u16 DmaTxIntrId ) { XAxiDma_BdRing * TxRingPtr = XAxiDma_GetTxRing ( DmaInstancePtr ) ; XAxiDma_BdRing * RxRingPtr = XAxiDma_GetRxRing ( DmaInstancePtr ) ; int Status ; #ifdef XPAR_INTC_0_DEVICE_ID #ifndef TESTAPP_GEN Status = XIntc_Initialize ( IntcInstancePtr , INTC_DEVICE_ID ) ; if ( Status != XST_SUCCESS ) { AxiEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } #endif #if XPAR_INTC_0_HAS_FAST == 1 TxRingPtr_Fast = TxRingPtr ; RxRingPtr_Fast = RxRingPtr ; AxiEthernetInstancePtr_Fast = AxiEthernetInstancePtr ; Status = XIntc_ConnectFastHandler ( IntcInstancePtr , AxiEthernetIntrId , ( XFastInterruptHandler ) AxiEthernetErrorFastHandler ) ; Status |= XIntc_ConnectFastHandler ( IntcInstancePtr , DmaTxIntrId , ( XFastInterruptHandler ) TxIntrFastHandler ) ; Status |= XIntc_ConnectFastHandler ( IntcInstancePtr , DmaRxIntrId , ( XFastInterruptHandler ) RxIntrFastHandler ) ; #else Status = XIntc_Connect ( IntcInstancePtr , AxiEthernetIntrId , ( XInterruptHandler ) AxiEthernetErrorHandler , AxiEthernetInstancePtr ) ; Status |= XIntc_Connect ( IntcInstancePtr , DmaTxIntrId , ( XInterruptHandler ) TxIntrHandler , TxRingPtr ) ; Status |= XIntc_Connect ( IntcInstancePtr , DmaRxIntrId , ( XInterruptHandler ) RxIntrHandler , RxRingPtr ) ; #endif if ( Status != XST_SUCCESS ) { AxiEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } #ifndef TESTAPP_GEN Status = XIntc_Start ( IntcInstancePtr , XIN_REAL_MODE ) ; if ( Status != XST_SUCCESS ) { AxiEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } #endif XIntc_Enable ( IntcInstancePtr , AxiEthernetIntrId ) ; XIntc_Enable ( IntcInstancePtr , DmaTxIntrId ) ; XIntc_Enable ( IntcInstancePtr , DmaRxIntrId ) ; #else XScuGic_Config * IntcConfig ; IntcConfig = XScuGic_LookupConfig ( INTC_DEVICE_ID ) ; if ( NULL == IntcConfig ) { return XST_FAILURE ; } Status = XScuGic_CfgInitialize ( IntcInstancePtr , IntcConfig , IntcConfig -> CpuBaseAddress ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XScuGic_SetPriorityTriggerType ( IntcInstancePtr , DmaTxIntrId , 0xA0 , 0x3 ) ; XScuGic_SetPriorityTriggerType ( IntcInstancePtr , DmaRxIntrId , 0xA0 , 0x3 ) ; XScuGic_SetPriorityTriggerType ( IntcInstancePtr , AxiEthernetIntrId , 0xA0 , 0x3 ) ; Status = XScuGic_Connect ( IntcInstancePtr , DmaTxIntrId , ( Xil_InterruptHandler ) TxIntrHandler , TxRingPtr ) ; if ( Status != XST_SUCCESS ) { return Status ; } Status = XScuGic_Connect ( IntcInstancePtr , DmaRxIntrId , ( Xil_InterruptHandler ) RxIntrHandler , RxRingPtr ) ; if ( Status != XST_SUCCESS ) { return Status ; } Status = XScuGic_Connect ( IntcInstancePtr , AxiEthernetIntrId , ( Xil_InterruptHandler ) AxiEthernetErrorHandler , AxiEthernetInstancePtr ) ; if ( Status != XST_SUCCESS ) { return Status ; } XScuGic_Enable ( IntcInstancePtr , AxiEthernetIntrId ) ; XScuGic_Enable ( IntcInstancePtr , DmaTxIntrId ) ; XScuGic_Enable ( IntcInstancePtr , DmaRxIntrId ) ; #endif #ifndef TESTAPP_GEN Xil_ExceptionInit ( ) ; Xil_ExceptionRegisterHandler ( XIL_EXCEPTION_ID_INT , ( Xil_ExceptionHandler ) INTC_HANDLER , ( void * ) ( IntcInstancePtr ) ) ; Xil_ExceptionEnable ( ) ; #endif return XST_SUCCESS ; }
This function setups the interrupt system so interrupts can occur for the
Axi Ethernet.
This function setups the interrupt system so interrupts can occur for the Axi Ethernet .
/*
	 * Initialize the interrupt controller and connect the ISR
	 */ /*
	 * Start the interrupt controller
	 */ /*
	 * Enable interrupts from the hardware
	 */ /*
	 * Initialize the interrupt controller driver so that it is ready to
	 * use.
	 */ /*
	 * Connect the device driver handler that will be called when an
	 * interrupt for the device occurs, the handler defined above performs
	 * the specific interrupt processing for the device.
	 */