2 * Copyright (c) 2010-2013 Xilinx, Inc. All rights reserved.
5 * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
6 * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
7 * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR
8 * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
9 * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE
10 * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
11 * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
12 * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO
13 * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
14 * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE.
19 #ifndef __NETIF_XEMACPSIF_H__
20 #define __NETIF_XEMACPSIF_H__
30 #include "xparameters.h"
31 #include "xparameters_ps.h" /* defines XPAR values */
32 #include "xil_types.h"
33 #include "xil_assert.h"
35 #include "xil_exception.h"
36 #include "xpseudo_asm.h"
37 #include "xil_cache.h"
38 #include "xil_printf.h"
41 #include "xemacps.h" /* defines XEmacPs API */
43 //#include "netif/xpqueue.h"
44 //#include "xlwipconfig.h"
46 void xemacpsif_setmac(uint32_t index, uint8_t *addr);
47 uint8_t* xemacpsif_getmac(uint32_t index);
48 //int xemacpsif_init(struct netif *netif);
49 //int xemacpsif_input(struct netif *netif);
51 unsigned get_IEEE_phy_speed(XLlTemac *xlltemacp);
55 void xemacps_error_handler(XEmacPs * Temac);
63 * Missing declaration in 'src/xemacps_hw.h' :
64 * When set, the GEM DMA will automatically
65 * discard receive packets from the receiver packet
66 * buffer memory when no AHB resource is
68 * When low, then received packets will remain to be
69 * stored in the SRAM based packet buffer until
70 * AHB buffer resource next becomes available.
72 #define XEMACPS_DMACR_DISC_WHEN_NO_AHB_MASK 0x01000000
74 #define EMAC_IF_RX_EVENT 1
75 #define EMAC_IF_TX_EVENT 2
76 #define EMAC_IF_ERR_EVENT 4
77 #define EMAC_IF_ALL_EVENT 7
79 /* structure within each netif, encapsulating all information required for
80 * using a particular temac instance
85 /* pointers to memory holding buffer descriptors (used only with SDMA) */
86 struct xBD_TYPE *rxSegments;
87 struct xBD_TYPE *txSegments;
89 unsigned char *tx_space;
95 volatile int rxHead, rxTail;
96 volatile int txHead, txTail;
100 volatile uint32_t isr_events;
102 unsigned int last_rx_frms_cntr;
106 //extern xemacpsif_s xemacpsif;
108 int is_tx_space_available(xemacpsif_s *emac);
110 /* xaxiemacif_dma.c */
112 struct xNETWORK_BUFFER;
114 int emacps_check_rx( xemacpsif_s *xemacpsif );
115 void emacps_check_tx( xemacpsif_s *xemacpsif );
116 int emacps_check_errors( xemacpsif_s *xemacps );
117 void emacps_set_rx_buffers( xemacpsif_s *xemacpsif, u32 ulCount );
119 extern XStatus emacps_send_message(xemacpsif_s *xemacpsif, struct xNETWORK_BUFFER *pxBuffer, int iReleaseAfterSend );
120 extern unsigned Phy_Setup( XEmacPs *xemacpsp );
121 extern void setup_isr( xemacpsif_s *xemacpsif );
122 extern XStatus init_dma( xemacpsif_s *xemacpsif );
123 extern void start_emacps( xemacpsif_s *xemacpsif );
125 void EmacEnableIntr(void);
126 void EmacDisableIntr(void);
128 XStatus init_axi_dma(xemacpsif_s *xemacpsif);
129 void process_sent_bds( xemacpsif_s *xemacpsif );
131 void emacps_send_handler(void *arg);
132 void emacps_recv_handler(void *arg);
133 void emacps_error_handler(void *arg,u8 Direction, u32 ErrorWord);
134 void HandleTxErrors(xemacpsif_s *xemacpsif);
135 XEmacPs_Config *xemacps_lookup_config(unsigned mac_base);
137 void clean_dma_txdescs(xemacpsif_s *xemacpsif);
138 void resetrx_on_no_rxdata(xemacpsif_s *xemacpsif);
144 #endif /* __NETIF_XAXIEMACIF_H__ */