]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif.h
a38ec81d75fd3514eca1f8f14cda3937bd208225
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-TCP / portable / NetworkInterface / Zynq / x_emacpsif.h
1 /*\r
2  * Copyright (c) 2010-2013 Xilinx, Inc.  All rights reserved.\r
3  *\r
4  * Xilinx, Inc.\r
5  * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A\r
6  * COURTESY TO YOU.  BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS\r
7  * ONE POSSIBLE   IMPLEMENTATION OF THIS FEATURE, APPLICATION OR\r
8  * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION\r
9  * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE\r
10  * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.\r
11  * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO\r
12  * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO\r
13  * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE\r
14  * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY\r
15  * AND FITNESS FOR A PARTICULAR PURPOSE.\r
16  *\r
17  */\r
18 \r
19 #ifndef __NETIF_XEMACPSIF_H__\r
20 #define __NETIF_XEMACPSIF_H__\r
21 \r
22 #ifdef __cplusplus\r
23 extern "C" {\r
24 #endif\r
25 \r
26 #include <stdint.h>\r
27 \r
28 #include "xstatus.h"\r
29 #include "sleep.h"\r
30 #include "xparameters.h"\r
31 #include "xparameters_ps.h"     /* defines XPAR values */\r
32 #include "xil_types.h"\r
33 #include "xil_assert.h"\r
34 #include "xil_io.h"\r
35 #include "xil_exception.h"\r
36 #include "xpseudo_asm.h"\r
37 #include "xil_cache.h"\r
38 #include "xuartps.h"\r
39 #include "xscugic.h"\r
40 #include "xemacps.h"            /* defines XEmacPs API */\r
41 \r
42 //#include "netif/xpqueue.h"\r
43 //#include "xlwipconfig.h"\r
44 \r
45 void    xemacpsif_setmac(uint32_t index, uint8_t *addr);\r
46 uint8_t*        xemacpsif_getmac(uint32_t index);\r
47 //int   xemacpsif_init(struct netif *netif);\r
48 //int   xemacpsif_input(struct netif *netif);\r
49 #ifdef NOTNOW_BHILL\r
50 unsigned get_IEEE_phy_speed(XLlTemac *xlltemacp);\r
51 #endif\r
52 \r
53 /* xaxiemacif_hw.c */\r
54 void    xemacps_error_handler(XEmacPs * Temac);\r
55 \r
56 struct xBD_TYPE {\r
57         uint32_t address;\r
58         uint32_t flags;\r
59 };\r
60 \r
61 /*\r
62  * Missing declaration in 'src/xemacps_hw.h' :\r
63  * When set, the GEM DMA will automatically\r
64  * discard receive packets from the receiver packet\r
65  * buffer memory when no AHB resource is\r
66  * available.\r
67  * When low, then received packets will remain to be\r
68  * stored in the SRAM based packet buffer until\r
69  * AHB buffer resource next becomes available.\r
70  */\r
71 #define XEMACPS_DMACR_DISC_WHEN_NO_AHB_MASK             0x01000000\r
72 \r
73 #define EMAC_IF_RX_EVENT        1\r
74 #define EMAC_IF_TX_EVENT        2\r
75 #define EMAC_IF_ERR_EVENT       4\r
76 #define EMAC_IF_ALL_EVENT       7\r
77 \r
78 /* structure within each netif, encapsulating all information required for\r
79  * using a particular temac instance\r
80  */\r
81 typedef struct {\r
82         XEmacPs emacps;\r
83 \r
84         /* pointers to memory holding buffer descriptors (used only with SDMA) */\r
85         struct xBD_TYPE *rxSegments;\r
86         struct xBD_TYPE *txSegments;\r
87 \r
88         unsigned char *tx_space;\r
89         unsigned uTxUnitSize;\r
90 \r
91         char *remain_mem;\r
92         unsigned remain_siz;\r
93 \r
94         volatile int rxHead, rxTail;\r
95         volatile int txHead, txTail;\r
96 \r
97         volatile int txBusy;\r
98 \r
99         volatile uint32_t isr_events;\r
100 \r
101         unsigned int last_rx_frms_cntr;\r
102 \r
103 } xemacpsif_s;\r
104 \r
105 //extern xemacpsif_s xemacpsif;\r
106 \r
107 int     is_tx_space_available(xemacpsif_s *emac);\r
108 \r
109 /* xaxiemacif_dma.c */\r
110 \r
111 struct xNETWORK_BUFFER;\r
112 \r
113 int emacps_check_rx( xemacpsif_s *xemacpsif );\r
114 void emacps_check_tx( xemacpsif_s *xemacpsif );\r
115 int emacps_check_errors( xemacpsif_s *xemacps );\r
116 void emacps_set_rx_buffers( xemacpsif_s *xemacpsif, u32 ulCount );\r
117 \r
118 extern XStatus emacps_send_message(xemacpsif_s *xemacpsif, struct xNETWORK_BUFFER *pxBuffer, int iReleaseAfterSend );\r
119 extern unsigned Phy_Setup( XEmacPs *xemacpsp );\r
120 extern void setup_isr( xemacpsif_s *xemacpsif );\r
121 extern XStatus init_dma( xemacpsif_s *xemacpsif );\r
122 extern void start_emacps( xemacpsif_s *xemacpsif );\r
123 \r
124 void EmacEnableIntr(void);\r
125 void EmacDisableIntr(void);\r
126 \r
127 XStatus init_axi_dma(xemacpsif_s *xemacpsif);\r
128 void process_sent_bds( xemacpsif_s *xemacpsif );\r
129 \r
130 void emacps_send_handler(void *arg);\r
131 void emacps_recv_handler(void *arg);\r
132 void emacps_error_handler(void *arg,u8 Direction, u32 ErrorWord);\r
133 void HandleTxErrors(xemacpsif_s *xemacpsif);\r
134 XEmacPs_Config *xemacps_lookup_config(unsigned mac_base);\r
135 \r
136 void clean_dma_txdescs(xemacpsif_s *xemacpsif);\r
137 void resetrx_on_no_rxdata(xemacpsif_s *xemacpsif);\r
138 \r
139 #ifdef __cplusplus\r
140 }\r
141 #endif\r
142 \r
143 #endif /* __NETIF_XAXIEMACIF_H__ */\r