]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif.h
2f1b0df2041aaf60a6fab860bf08700b0991a503
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-TCP / portable / NetworkInterface / Zynq / x_emacpsif.h
1 /*
2  * Copyright (c) 2010-2013 Xilinx, Inc.  All rights reserved.
3  *
4  * Xilinx, Inc.
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.
16  *
17  */
18
19 #ifndef __NETIF_XEMACPSIF_H__
20 #define __NETIF_XEMACPSIF_H__
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 #include <stdint.h>
27
28 #include "xstatus.h"
29 #include "sleep.h"
30 #include "xparameters.h"
31 #include "xparameters_ps.h"     /* defines XPAR values */
32 #include "xil_types.h"
33 #include "xil_assert.h"
34 #include "xil_io.h"
35 #include "xil_exception.h"
36 #include "xpseudo_asm.h"
37 #include "xil_cache.h"
38 #include "xil_printf.h"
39 #include "xuartps.h"
40 #include "xscugic.h"
41 #include "xemacps.h"            /* defines XEmacPs API */
42
43 //#include "netif/xpqueue.h"
44 //#include "xlwipconfig.h"
45
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);
50 #ifdef NOTNOW_BHILL
51 unsigned get_IEEE_phy_speed(XLlTemac *xlltemacp);
52 #endif
53
54 /* xaxiemacif_hw.c */
55 void    xemacps_error_handler(XEmacPs * Temac);
56
57 struct xBD_TYPE {
58         uint32_t address;
59         uint32_t flags;
60 };
61
62 /*
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
67  * available.
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.
71  */
72 #define XEMACPS_DMACR_DISC_WHEN_NO_AHB_MASK             0x01000000
73
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
78
79 /* structure within each netif, encapsulating all information required for
80  * using a particular temac instance
81  */
82 typedef struct {
83         XEmacPs emacps;
84
85         /* pointers to memory holding buffer descriptors (used only with SDMA) */
86         struct xBD_TYPE *rxSegments;
87         struct xBD_TYPE *txSegments;
88
89         unsigned char *tx_space;
90         unsigned uTxUnitSize;
91
92         char *remain_mem;
93         unsigned remain_siz;
94
95         volatile int rxHead, rxTail;
96         volatile int txHead, txTail;
97
98         volatile int txBusy;
99
100         volatile uint32_t isr_events;
101
102         unsigned int last_rx_frms_cntr;
103
104 } xemacpsif_s;
105
106 //extern xemacpsif_s xemacpsif;
107
108 int     is_tx_space_available(xemacpsif_s *emac);
109
110 /* xaxiemacif_dma.c */
111
112 struct xNETWORK_BUFFER;
113
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 );
118
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 );
124
125 void EmacEnableIntr(void);
126 void EmacDisableIntr(void);
127
128 XStatus init_axi_dma(xemacpsif_s *xemacpsif);
129 void process_sent_bds( xemacpsif_s *xemacpsif );
130
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);
136
137 void clean_dma_txdescs(xemacpsif_s *xemacpsif);
138 void resetrx_on_no_rxdata(xemacpsif_s *xemacpsif);
139
140 #ifdef __cplusplus
141 }
142 #endif
143
144 #endif /* __NETIF_XAXIEMACIF_H__ */