]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif.h
Sync FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP with the version in GitHub at (23665258ca...
[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 "xil_printf.h"\r
39 #include "xuartps.h"\r
40 #include "xscugic.h"\r
41 #include "xemacps.h"            /* defines XEmacPs API */\r
42 \r
43 //#include "netif/xpqueue.h"\r
44 //#include "xlwipconfig.h"\r
45 \r
46 void    xemacpsif_setmac(uint32_t index, uint8_t *addr);\r
47 uint8_t*        xemacpsif_getmac(uint32_t index);\r
48 //int   xemacpsif_init(struct netif *netif);\r
49 //int   xemacpsif_input(struct netif *netif);\r
50 #ifdef NOTNOW_BHILL\r
51 unsigned get_IEEE_phy_speed(XLlTemac *xlltemacp);\r
52 #endif\r
53 \r
54 /* xaxiemacif_hw.c */\r
55 void    xemacps_error_handler(XEmacPs * Temac);\r
56 \r
57 struct xBD_TYPE {\r
58         uint32_t address;\r
59         uint32_t flags;\r
60 };\r
61 \r
62 /*\r
63  * Missing declaration in 'src/xemacps_hw.h' :\r
64  * When set, the GEM DMA will automatically\r
65  * discard receive packets from the receiver packet\r
66  * buffer memory when no AHB resource is\r
67  * available.\r
68  * When low, then received packets will remain to be\r
69  * stored in the SRAM based packet buffer until\r
70  * AHB buffer resource next becomes available.\r
71  */\r
72 #define XEMACPS_DMACR_DISC_WHEN_NO_AHB_MASK             0x01000000\r
73 \r
74 #define EMAC_IF_RX_EVENT        1\r
75 #define EMAC_IF_TX_EVENT        2\r
76 #define EMAC_IF_ERR_EVENT       4\r
77 #define EMAC_IF_ALL_EVENT       7\r
78 \r
79 /* structure within each netif, encapsulating all information required for\r
80  * using a particular temac instance\r
81  */\r
82 typedef struct {\r
83         XEmacPs emacps;\r
84 \r
85         /* pointers to memory holding buffer descriptors (used only with SDMA) */\r
86         struct xBD_TYPE *rxSegments;\r
87         struct xBD_TYPE *txSegments;\r
88 \r
89         unsigned char *tx_space;\r
90         unsigned uTxUnitSize;\r
91 \r
92         char *remain_mem;\r
93         unsigned remain_siz;\r
94 \r
95         volatile int rxHead, rxTail;\r
96         volatile int txHead, txTail;\r
97 \r
98         volatile int txBusy;\r
99 \r
100         volatile uint32_t isr_events;\r
101 \r
102         unsigned int last_rx_frms_cntr;\r
103 \r
104 } xemacpsif_s;\r
105 \r
106 //extern xemacpsif_s xemacpsif;\r
107 \r
108 int     is_tx_space_available(xemacpsif_s *emac);\r
109 \r
110 /* xaxiemacif_dma.c */\r
111 \r
112 struct xNETWORK_BUFFER;\r
113 \r
114 int emacps_check_rx( xemacpsif_s *xemacpsif );\r
115 void emacps_check_tx( xemacpsif_s *xemacpsif );\r
116 int emacps_check_errors( xemacpsif_s *xemacps );\r
117 void emacps_set_rx_buffers( xemacpsif_s *xemacpsif, u32 ulCount );\r
118 \r
119 extern XStatus emacps_send_message(xemacpsif_s *xemacpsif, struct xNETWORK_BUFFER *pxBuffer, int iReleaseAfterSend );\r
120 extern unsigned Phy_Setup( XEmacPs *xemacpsp );\r
121 extern void setup_isr( xemacpsif_s *xemacpsif );\r
122 extern XStatus init_dma( xemacpsif_s *xemacpsif );\r
123 extern void start_emacps( xemacpsif_s *xemacpsif );\r
124 \r
125 void EmacEnableIntr(void);\r
126 void EmacDisableIntr(void);\r
127 \r
128 XStatus init_axi_dma(xemacpsif_s *xemacpsif);\r
129 void process_sent_bds( xemacpsif_s *xemacpsif );\r
130 \r
131 void emacps_send_handler(void *arg);\r
132 void emacps_recv_handler(void *arg);\r
133 void emacps_error_handler(void *arg,u8 Direction, u32 ErrorWord);\r
134 void HandleTxErrors(xemacpsif_s *xemacpsif);\r
135 XEmacPs_Config *xemacps_lookup_config(unsigned mac_base);\r
136 \r
137 void clean_dma_txdescs(xemacpsif_s *xemacpsif);\r
138 void resetrx_on_no_rxdata(xemacpsif_s *xemacpsif);\r
139 \r
140 #ifdef __cplusplus\r
141 }\r
142 #endif\r
143 \r
144 #endif /* __NETIF_XAXIEMACIF_H__ */\r