summaryrefslogtreecommitdiff
path: root/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif.h
blob: bf0d174c09a5e23360892f7b192cfdd6ad79f7df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
 * Copyright (c) 2010-2013 Xilinx, Inc.  All rights reserved.
 *
 * Xilinx, Inc.
 * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
 * COURTESY TO YOU.  BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
 * ONE POSSIBLE   IMPLEMENTATION OF THIS FEATURE, APPLICATION OR
 * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
 * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE
 * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
 * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
 * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO
 * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
 * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 */

#ifndef __NETIF_XEMACPSIF_H__
#define __NETIF_XEMACPSIF_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

#include "xstatus.h"
#include "xparameters.h"
#include "xparameters_ps.h"	/* defines XPAR values */
#include "xil_types.h"
#include "xil_assert.h"
#include "xil_io.h"
#include "xil_exception.h"
#include "xpseudo_asm.h"
#include "xil_cache.h"
#include "xuartps.h"
#include "xscugic.h"
#include "xemacps.h"		/* defines XEmacPs API */

//#include "netif/xpqueue.h"
//#include "xlwipconfig.h"

void 	xemacpsif_setmac(uint32_t index, uint8_t *addr);
uint8_t*	xemacpsif_getmac(uint32_t index);
//int 	xemacpsif_init(struct netif *netif);
//int 	xemacpsif_input(struct netif *netif);
#ifdef NOTNOW_BHILL
unsigned get_IEEE_phy_speed(XLlTemac *xlltemacp);
#endif

/* xaxiemacif_hw.c */
void 	xemacps_error_handler(XEmacPs * Temac);

struct xBD_TYPE {
	uint32_t address;
	uint32_t flags;
};

/*
 * Missing declaration in 'src/xemacps_hw.h' :
 * When set, the GEM DMA will automatically
 * discard receive packets from the receiver packet
 * buffer memory when no AHB resource is
 * available.
 * When low, then received packets will remain to be
 * stored in the SRAM based packet buffer until
 * AHB buffer resource next becomes available.
 */
#define XEMACPS_DMACR_DISC_WHEN_NO_AHB_MASK		0x01000000

#define EMAC_IF_RX_EVENT	1
#define EMAC_IF_TX_EVENT	2
#define EMAC_IF_ERR_EVENT	4
#define EMAC_IF_ALL_EVENT	7

/* structure within each netif, encapsulating all information required for
 * using a particular temac instance
 */
typedef struct {
	XEmacPs emacps;

	/* pointers to memory holding buffer descriptors (used only with SDMA) */
	struct xBD_TYPE *rxSegments;
	struct xBD_TYPE *txSegments;

	unsigned char *tx_space;
	unsigned uTxUnitSize;

	char *remain_mem;
	unsigned remain_siz;

	volatile int rxHead, rxTail;
	volatile int txHead, txTail;

	volatile int txBusy;

	volatile uint32_t isr_events;

	unsigned int last_rx_frms_cntr;

} xemacpsif_s;

//extern xemacpsif_s xemacpsif;

int	is_tx_space_available(xemacpsif_s *emac);

/* xaxiemacif_dma.c */

struct xNETWORK_BUFFER;

int emacps_check_rx( xemacpsif_s *xemacpsif );
void emacps_check_tx( xemacpsif_s *xemacpsif );
int emacps_check_errors( xemacpsif_s *xemacps );
void emacps_set_rx_buffers( xemacpsif_s *xemacpsif, u32 ulCount );

extern XStatus emacps_send_message(xemacpsif_s *xemacpsif, struct xNETWORK_BUFFER *pxBuffer, int iReleaseAfterSend );
extern unsigned Phy_Setup( XEmacPs *xemacpsp );
extern void setup_isr( xemacpsif_s *xemacpsif );
extern XStatus init_dma( xemacpsif_s *xemacpsif );
extern void start_emacps( xemacpsif_s *xemacpsif );

void EmacEnableIntr(void);
void EmacDisableIntr(void);

XStatus init_axi_dma(xemacpsif_s *xemacpsif);
void process_sent_bds( xemacpsif_s *xemacpsif );

void emacps_send_handler(void *arg);
void emacps_recv_handler(void *arg);
void emacps_error_handler(void *arg,u8 Direction, u32 ErrorWord);
void HandleTxErrors(xemacpsif_s *xemacpsif);
XEmacPs_Config *xemacps_lookup_config(unsigned mac_base);

void clean_dma_txdescs(xemacpsif_s *xemacpsif);
void resetrx_on_no_rxdata(xemacpsif_s *xemacpsif);

#ifdef __cplusplus
}
#endif

#endif /* __NETIF_XAXIEMACIF_H__ */