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