source: edk_user_repository/WARP/sw_services/WARPxilnet_v3_02_a/data/WARPxilnet_v2_1_0.tcl

Last change on this file was 2165, checked in by welsh, 11 years ago

Corrected spelling mistake in define for PERFORMANCE_MONITOR

File size: 29.8 KB
Line 
1###############################################################
2# Copyright (c) 2004 Xilinx, Inc. All Rights Reserved.
3# You may copy and modify these files for your own internal use solely with
4# Xilinx programmable logic devices and  Xilinx EDK system or create IP
5# modules solely for Xilinx programmable logic devices and Xilinx EDK system.
6# No rights are granted to distribute any files unless they are distributed in
7# Xilinx programmable logic devices.
8#
9# $Id: xilnet_v2_1_0.tcl,v 1.2.8.6 2005/11/15 23:41:10 salindac Exp $
10# ##############################################################
11#uses "xillib.tcl"
12
13set ethernet_ninstances        0
14set ethernet_periphs_name_list {}
15set ethernet_use_axi           0
16set ethernet_use_temac         0
17
18
19proc get_ethernet_periphs {mhs_handle} {
20    global ethernet_ninstances
21    global ethernet_periphs_name_list
22    global ethernet_use_axi
23    global ethernet_use_temac
24
25    set ipinst_list                [xget_hw_ipinst_handle $mhs_handle "*"]
26    set ethernet_ninstances        0
27    set ethernet_use_axi           0
28    set ethernet_use_temac         0
29    set ethernet_periphs_list      {}
30    set ethernet_periphs_name_list {}
31
32    foreach periph $ipinst_list {
33        set periph_type [xget_hw_value $periph]
34        set periph_name [xget_value $periph "name"]
35       
36#        puts "\# Peripheral: type = $periph_type  name = $periph_name  "       
37
38        if { $periph_type == "axi_ethernet"     } {
39       
40            incr ethernet_use_axi
41            incr ethernet_ninstances
42            lappend ethernet_periphs_list      $periph
43            lappend ethernet_periphs_name_list $periph_name
44
45#            puts "\# Ethernet $ethernet_ninstances: type = $periph_type  name = $periph_name  "       
46        }       
47       
48        if { $periph_type == "xps_ll_temac"     ||
49             $periph_type == "opb_ethernetlite" ||
50             $periph_type == "xps_ethernetlite" } {
51
52            incr ethernet_use_temac
53            incr ethernet_ninstances
54            lappend ethernet_periphs_list      $periph
55            lappend ethernet_periphs_name_list $periph_name
56
57#            puts "\# Ethernet $ethernet_ninstances: type = $periph_type  name = $periph_name  "
58        }
59    }
60
61    return $ethernet_periphs_list
62}
63
64
65proc get_ethernet_interface_periph {mhs_handle inst_handle} {
66
67    set p2p_busifs_i [xget_hw_busifs_by_subproperty $inst_handle "BUS_TYPE" "INITIATOR"]
68     
69    # Add p2p periphs
70    foreach p2p_busif $p2p_busifs_i {
71
72        set bus_name          [string toupper [xget_hw_value $p2p_busif]]
73        set conn_busif_handle [xget_hw_connected_busifs_handle $mhs_handle $bus_name "TARGET"]
74
75        if { [string compare -nocase $conn_busif_handle ""] == 0} {
76            continue
77        } else {
78            # if there is a single match, we know if it is FIFO or DMA
79            # no need for further iterations
80            set conn_busif_name    [xget_hw_name          $conn_busif_handle]
81            set target_periph      [xget_hw_parent_handle $conn_busif_handle]
82
83            set target_type [xget_hw_value $target_periph]
84            set target_name [string toupper [xget_hw_name $target_periph]]
85
86            # puts "\# Bus Name    = $bus_name  Type = $conn_busif_name"
87            # puts "\# Target Name = $target_name  Type = $target_type"
88
89            return $target_periph
90        }
91    }
92   
93    return
94}
95
96
97proc get_periph_instances {mhs_handle inst_type} {
98    set ipinst_list                [xget_hw_ipinst_handle $mhs_handle "*"]
99    set periphs_list               {}
100
101    foreach periph $ipinst_list {
102        set periph_type [xget_hw_value $periph]
103        set periph_name [xget_value $periph "name"]
104
105        if { $periph_type == $inst_type } {
106       
107            lappend periphs_list      $periph
108
109#            puts "\# Instance: type = $periph_type  name = $periph_name  "       
110        }       
111    }
112
113    return $periphs_list
114}
115
116
117proc net_drc {lib_handle} {
118   
119    puts "XilNet DRC ..."
120}
121
122proc net_open_file {filename desc} {
123    set config_inc [open $filename w]
124    xprint_generated_header $config_inc $desc
125    return $config_inc
126}
127
128proc net_open_include_file {file_name} {
129    set filename [file join "./src/" $file_name]
130    return [net_open_file $filename "WARP/XilNet Configuration Parameters"]
131}
132
133proc net_open_config_file {file_name} {
134    set filename [file join "./src/" $file_name]
135    return [net_open_file $filename "WARP/XilNet MAC Configuration File"]
136}
137
138proc generate {lib_handle} {
139    global ethernet_ninstances
140    global ethernet_periphs_name_list
141
142    set sw_proc_handle [xget_processor]       
143    set hw_proc_handle [xget_handle $sw_proc_handle "IPINST"]
144    set mhs_handle     [xget_hw_parent_handle $hw_proc_handle]
145    set emac_inst_list [get_ethernet_periphs $mhs_handle]
146   
147    # Error checking
148    if {$ethernet_ninstances == 0} {
149        error "Invalid configuration:  0 Ethernet instances found." "" "mdt_error"
150        return
151    }   
152   
153    # Initialize variables for loop
154    set eth_inst_num      0
155    set h_file            [net_open_include_file "xilnet_config.h"]
156    set c_file            [net_open_config_file  "xilnet_config.c"]
157
158    set fifo_buf_size     [xget_value $lib_handle "PARAMETER" "fifo_buf_size"]
159    set dma_buf_size      [xget_value $lib_handle "PARAMETER" "dma_buf_size"]
160    set dma_rcvd_buf_cnt  [xget_value $lib_handle "PARAMETER" "dma_rcvd_buf_cnt"]   
161    set udp_conns         [xget_value $lib_handle "PARAMETER" "no_of_tcp_conns"]
162
163    set inf_type_list     {}
164   
165#    puts "\# --------------------------------------"
166#    puts "\# Num Ethernet instances = $ethernet_ninstances  "
167
168    print_h_file_header $h_file $udp_conns
169    print_c_file_header $c_file
170     
171    foreach inst $emac_inst_list {
172        set inst_type [xget_hw_value $inst]
173        set inst_name [string toupper [xget_hw_name $inst]]
174
175#        puts "\# Name = $inst_name  "
176#        puts "\# Type = $inst_type  "
177
178        # Print out header file delimiter
179        puts $h_file ""
180        puts $h_file "/************************* Ethernet $eth_inst_num Definitions ****************************/"
181        puts $h_file ""
182
183        # Print out c file delimiter
184        puts $c_file ""
185        puts $c_file "/************************* Ethernet $eth_inst_num Definitions ****************************/"
186        puts $c_file ""       
187       
188        if { [string compare -nocase $inst_type "opb_ethernetlite"] == 0 ||
189             [string compare -nocase $inst_type "xps_ethernetlite"] == 0} {
190
191            error "TBD:  ethernetlite not yet supported.  Please change HW design for $inst_name." "" "mdt_error"
192            return
193
194        } elseif { [string compare -nocase $inst_type "xps_ll_temac"] == 0} {
195       
196            # Determine the interface attached to the temac
197            set inf_inst          [get_ethernet_interface_periph $mhs_handle $inst]
198
199            if { [llength $inf_inst] != 0 } {
200                set inf_inst_type [xget_hw_value $inf_inst]
201                set inf_inst_name [string toupper [xget_hw_name $inf_inst]]
202               
203           } else {
204                error "Unable to find interface for $inst_name. Some common causes are
205                       1. The interface of the TEMAC is left unconnected.
206                       2. A custom peripheral is connected to the interface. The WARP Xilnet has been designed for use with the LL FIFO peripheral only." "" "mdt_error"
207            }
208
209            set inf_dma_inst          [get_periph_instances $mhs_handle "xps_central_dma"]
210
211            if { [llength $inf_dma_inst] != 0 } {
212                set inf_dma_inst_type [xget_hw_value $inf_dma_inst]
213                set inf_dma_inst_name [string toupper [xget_hw_name $inf_dma_inst]]
214               
215                print_h_file_temac $h_file $eth_inst_num $inst_name $inf_inst_name $inf_dma_inst_name $dma_rcvd_buf_cnt $fifo_buf_size
216                print_c_file_temac $c_file $eth_inst_num
217
218            } else {
219                error "Unable to find the central dma interface for $inst_name. Some common causes are
220                       1. A custom peripheral is used for dma to the temac. The WARP Xilnet has been designed for use with the CENTRAL DMA peripherals only." "" "mdt_error"
221            }
222
223            # Append one entry for TEMAC           
224            lappend inf_type_list $inst_type 
225
226        } elseif { [string compare -nocase $inst_type "axi_ethernet"] == 0} {
227
228            # Determine the interface attached to the axi_ethernet           
229            set inf_inst [get_ethernet_interface_periph $mhs_handle $inst]
230
231            if { [llength $inf_inst] != 0 } {
232                set inf_inst_type [xget_hw_value $inf_inst]
233                set inf_inst_name [string toupper [xget_hw_name $inf_inst]]
234
235                lappend inf_type_list $inf_inst_type
236               
237                switch $inf_inst_type {
238                    "axi_fifo_mm_s" {
239                        print_h_file_fifo $h_file $eth_inst_num $inst_name $inf_inst_name $dma_rcvd_buf_cnt $fifo_buf_size
240                        print_c_file_fifo $c_file $eth_inst_num
241                    }
242               
243                    "axi_dma" {
244                        print_h_file_dma $h_file $eth_inst_num $inst_name $inf_inst_name $dma_rcvd_buf_cnt $dma_buf_size
245                        print_c_file_dma $c_file $eth_inst_num
246                    }
247
248                    "default" {
249                        error "Unable to handle AXI connections for target type $target_periph_type. Some common causes are
250                               1. The AXI4 Stream interface of the AXI Ethernet is left unconnected.
251                               2. A custom peripheral is connected to the AXI interface. The WARP Xilnet has been designed for use with the AXI Streaming FIFO, and AXI DMA peripherals only." "" "mdt_error"
252                    }
253                }
254            } else {
255                error "Unable to find AXI interface for $inst_name. Some common causes are
256                       1. The AXI4 Stream interface of the AXI Ethernet is left unconnected.
257                       2. A custom peripheral is connected to the AXI interface. The WARP Xilnet has been designed for use with the AXI Streaming FIFO, and AXI DMA peripherals only." "" "mdt_error"
258            }
259
260        } else {
261            error "$inst_name is not a TEMAC or ETHERNETLITE or AXI ETHERNET core. WARPXilNet can work only with such cores." "" "mdt_error"
262        }
263
264        # increment the instance number for the next iteration of the for loop
265        incr eth_inst_num
266    }
267
268    print_h_file_footer $h_file
269    print_c_file_footer $c_file $inf_type_list
270
271    close $h_file
272    close $c_file
273   
274}
275
276
277proc print_h_file_header {file_handle udp_conns} {
278    global ethernet_ninstances
279    global ethernet_use_axi
280    global ethernet_use_temac
281   
282    puts $file_handle "\#ifndef _XILNET_CONFIG_H" 
283    puts $file_handle "\#define _XILNET_CONFIG_H" 
284    puts $file_handle ""
285    puts $file_handle "\#ifdef __cplusplus" 
286    puts $file_handle "extern \"C\" \{" 
287    puts $file_handle "\#endif" 
288    puts $file_handle ""
289
290# Uncomment the next line and clean the project to enable debug output on the UART
291#
292#   puts $file_handle "\#define _DEBUG_"
293
294# Uncomment the next line and clean the project to enable performance monitoring on oscilloscope:
295#   - Ethernet receive  toggles GPIO 1 (see xilnet_eth.c)
296#   - Ethernet transmit toggles GPIO 2 (see xilnet_eth.c)
297#
298#   puts $file_handle "\#define _PERFORMANCE_MONITOR_"
299
300    puts $file_handle ""
301    puts $file_handle "/***************************** Include Files *********************************/"
302    puts $file_handle "\#include <xilnet_xilsock.h>"
303    puts $file_handle "\#include <xilnet_eth.h>"
304    puts $file_handle ""
305   
306    if { $ethernet_use_axi != 0 } {
307        puts $file_handle "\#include <xllfifo.h>"
308        puts $file_handle "\#include <xaxidma.h>"
309    }
310   
311    if { $ethernet_use_temac != 0 } {
312        puts $file_handle "\#include <xlltemac.h>"
313        puts $file_handle "\#include <xllfifo.h>"
314        puts $file_handle "\#include <xdmacentral.h>"
315        puts $file_handle "\#include <xdmacentral_l.h>"
316    }
317
318    puts $file_handle ""
319    puts $file_handle "/*************************** Constant Definitions ****************************/"
320    puts $file_handle ""
321    puts $file_handle "// Xilnet Global Defines"
322    puts $file_handle "\#define XILNET_NUM_ETH_DEVICES                   $ethernet_ninstances                             // Define the number of Ethernet devices"
323    puts $file_handle "\#define XILNET_BD_ALIGNMENT                      XAXIDMA_BD_MINIMUM_ALIGNMENT  // Buffer Descriptor alignment"
324    puts $file_handle ""
325    puts $file_handle "// Define UDP connections"
326    puts $file_handle "\#define XILNET_MAX_UDP_CONNS                     $udp_conns                             // maximum no of open udp conns"
327    puts $file_handle "\#define NO_OF_XILSOCKS                           XILNET_MAX_UDP_CONNS          // Number of sockets per Ethernet Device"
328    puts $file_handle ""
329    puts $file_handle "// Define Ethernet interface types"
330    puts $file_handle "\#define XILNET_AXI_DMA_INF                       1"
331    puts $file_handle "\#define XILNET_AXI_FIFO_INF                      2"
332    puts $file_handle "\#define XILNET_TEMAC_INF                         3"
333    puts $file_handle ""   
334    puts $file_handle "// Define which interfaces are used"
335
336    if { $ethernet_use_axi != 0 } {
337        puts $file_handle "\#define XILNET_AXI_DMA_INF_USED"
338        puts $file_handle "\#define XILNET_AXI_FIFO_INF_USED"
339    }
340   
341    if { $ethernet_use_temac != 0 } {
342        puts $file_handle "\#define XILNET_TEMAC_INF_USED"
343    } 
344
345    puts $file_handle ""
346
347}
348
349
350proc print_h_file_fifo {file_handle inst_num inst_name inf_name num_rcv_buf buf_size} {
351
352    puts $file_handle "// Ethernet device $inst_num"
353    puts $file_handle "\#define $inst_name                                XILNET_ETH_$inst_num                  // External name of Ethernet device"
354    puts $file_handle "\#define XILNET_ETH_$inst_num                             $inst_num                             // Internal name of Ethernet device"
355    puts $file_handle ""
356    puts $file_handle [format "\#define XILNET_ETH_%s_INF_DEVICE_ID               XPAR_%s_DEVICE_ID" $inst_num $inf_name]
357    # Only one receive buffer supported for FIFO mode
358    puts $file_handle [format "\#define XILNET_ETH_%s_NUM_RECV_BUF                1" $inst_num]
359    puts $file_handle [format "\#define XILNET_ETH_%s_BUF_SIZE                    %s" $inst_num $buf_size]
360    puts $file_handle ""
361    puts $file_handle "// Variables for ETH $inst_num"
362    puts $file_handle [format "extern XLlFifo              ETH_%s_FIFO_Instance;" $inst_num]
363    puts $file_handle ""
364    puts $file_handle "// Buffers for ETH $inst_num"
365    puts $file_handle [format "extern unsigned int recvBuffer_eth_%s\[XILNET_ETH_%s_NUM_RECV_BUF*((XILNET_ETH_%s_BUF_SIZE+3)/4)\];" $inst_num $inst_num $inst_num]
366    puts $file_handle [format "extern unsigned int sendBuffer_eth_%s\[(XILNET_ETH_%s_BUF_SIZE+3)/4\];" $inst_num $inst_num]
367    puts $file_handle ""
368   
369}
370
371
372proc print_h_file_dma {file_handle inst_num inst_name inf_name num_rcv_buf buf_size} {
373
374    puts $file_handle "// Ethernet device $inst_num"
375    puts $file_handle "\#define $inst_name                                XILNET_ETH_$inst_num                  // External name of Ethernet device"
376    puts $file_handle "\#define XILNET_ETH_$inst_num                             $inst_num                             // Internal name of Ethernet device"
377    puts $file_handle ""
378    puts $file_handle [format "\#define XILNET_ETH_%s_INF_DEVICE_ID               XPAR_%s_DEVICE_ID" $inst_num $inf_name]
379    puts $file_handle [format "\#define XILNET_ETH_%s_NUM_RECV_BUF                %s" $inst_num $num_rcv_buf]
380    puts $file_handle [format "\#define XILNET_ETH_%s_BUF_SIZE                    %s" $inst_num $buf_size]
381
382    # NOTE:  For both Send and Receive, the number of buffer descriptors should equal the number of buffers
383    puts $file_handle [format "\#define XILNET_ETH_%s_RXBD_CNT                    XILNET_ETH_%s_NUM_RECV_BUF     // Number of RxBDs to use" $inst_num $inst_num]
384    puts $file_handle [format "\#define XILNET_ETH_%s_TXBD_CNT                    1                             // Number of TxBDs to use" $inst_num]
385
386    puts $file_handle [format "\#define XILNET_ETH_%s_RXBD_SPACE_BYTES           (XAxiDma_BdRingMemCalc(XILNET_BD_ALIGNMENT, XILNET_ETH_%s_RXBD_CNT))" $inst_num $inst_num]
387    puts $file_handle [format "\#define XILNET_ETH_%s_TXBD_SPACE_BYTES           (XAxiDma_BdRingMemCalc(XILNET_BD_ALIGNMENT, XILNET_ETH_%s_TXBD_CNT))" $inst_num $inst_num]
388    puts $file_handle ""
389    puts $file_handle "// Variables for ETH $inst_num"
390    puts $file_handle [format "extern XAxiDma              ETH_%s_DMA_Instance;" $inst_num]
391    puts $file_handle ""
392    puts $file_handle "// Aligned memory segments to be used for buffer descriptors"
393    puts $file_handle [format "extern char ETH_%s_RX_BD_space\[XILNET_ETH_%s_RXBD_SPACE_BYTES\] __attribute__ ((aligned(XILNET_BD_ALIGNMENT)));" $inst_num $inst_num]
394    puts $file_handle [format "extern char ETH_%s_TX_BD_space\[XILNET_ETH_%s_TXBD_SPACE_BYTES\] __attribute__ ((aligned(XILNET_BD_ALIGNMENT)));" $inst_num $inst_num]
395    puts $file_handle ""
396    puts $file_handle "// Buffers for ETH $inst_num"
397    puts $file_handle [format "extern unsigned int recvBuffer_eth_%s\[XILNET_ETH_%s_NUM_RECV_BUF*((XILNET_ETH_%s_BUF_SIZE+3)/4)\];" $inst_num $inst_num $inst_num]
398    puts $file_handle [format "extern unsigned int sendBuffer_eth_%s\[(XILNET_ETH_%s_BUF_SIZE+3)/4\];" $inst_num $inst_num]
399
400}
401
402
403proc print_h_file_temac {file_handle inst_num inst_name inf_name inf_dma_name num_rcv_buf buf_size} {
404
405    puts $file_handle "// Ethernet device $inst_num"
406    puts $file_handle "\#define $inst_name                         XILNET_ETH_$inst_num                  // External name of Ethernet device"
407    puts $file_handle "\#define XILNET_ETH_$inst_num                             $inst_num                             // Internal name of Ethernet device"
408    puts $file_handle ""
409    puts $file_handle [format "\#define XILNET_ETH_%s_INF_DEVICE_ID               XPAR_%s_DEVICE_ID" $inst_num $inf_name]
410    puts $file_handle [format "\#define XILNET_ETH_%s_INF_DMA_DEVICE_ID           XPAR_%s_DEVICE_ID" $inst_num $inf_dma_name]
411    # Only one receive buffer supported for FIFO mode
412    puts $file_handle [format "\#define XILNET_ETH_%s_NUM_RECV_BUF                1" $inst_num]
413    puts $file_handle [format "\#define XILNET_ETH_%s_BUF_SIZE                    %s" $inst_num $buf_size]
414    puts $file_handle ""
415    puts $file_handle "// Variables for ETH $inst_num"
416    puts $file_handle [format "extern XLlFifo              ETH_%s_FIFO_Instance;" $inst_num]
417    puts $file_handle [format "extern XDmaCentral          ETH_%s_DMA_Instance;" $inst_num]
418    puts $file_handle [format "extern XDmaCentral_Config  *ETH_%s_DMA_CFG_ptr;" $inst_num]
419    puts $file_handle ""
420    puts $file_handle "// Buffers for ETH $inst_num"
421    puts $file_handle [format "extern unsigned int recvBuffer_eth_%s\[XILNET_ETH_%s_NUM_RECV_BUF*((XILNET_ETH_%s_BUF_SIZE+3)/4)\];" $inst_num $inst_num $inst_num]
422    puts $file_handle [format "extern unsigned int sendBuffer_eth_%s\[(XILNET_ETH_%s_BUF_SIZE+3)/4\];" $inst_num $inst_num]
423
424}
425
426
427proc print_h_file_footer {file_handle} {
428
429    puts $file_handle ""
430    puts $file_handle "/*********************** Global Variable Definitions *************************/"
431    puts $file_handle ""
432    puts $file_handle "// Ethernet Device Structure"
433    puts $file_handle "extern xilnet_eth_device eth_device\[XILNET_NUM_ETH_DEVICES\];"
434    puts $file_handle ""
435    puts $file_handle "/*************************** Function Prototypes *****************************/"
436    puts $file_handle ""
437    puts $file_handle "void xilnet_init_eth_device_struct(unsigned int);"
438    puts $file_handle ""
439    puts $file_handle "\#endif" 
440    puts $file_handle ""
441    puts $file_handle "/*****************************************************************************/"
442    puts $file_handle ""
443
444}
445
446
447proc print_c_file_header {file_handle} {
448    global ethernet_ninstances
449   
450    puts $file_handle ""
451    puts $file_handle "/***************************** Include Files *********************************/"
452    puts $file_handle ""
453    puts $file_handle "\#include <string.h>"
454    puts $file_handle "\#include <xilnet_config.h>"
455    puts $file_handle ""
456   
457}
458
459
460proc print_c_file_fifo {file_handle inst_num} {
461
462    puts $file_handle ""
463    puts $file_handle "// Variables for ETH $inst_num"
464    puts $file_handle [format "XLlFifo              ETH_%s_FIFO_Instance;" $inst_num]
465    puts $file_handle ""
466    puts $file_handle "// Buffers for ETH $inst_num"
467    puts $file_handle [format "unsigned int recvBuffer_eth_%s\[XILNET_ETH_%s_NUM_RECV_BUF*((XILNET_ETH_%s_BUF_SIZE+3)/4)\];" $inst_num $inst_num $inst_num]
468    puts $file_handle [format "unsigned int sendBuffer_eth_%s\[(XILNET_ETH_%s_BUF_SIZE+3)/4\];" $inst_num $inst_num]
469    puts $file_handle [format "struct xilsock_socket xilsock_sockets_eth_%s\[NO_OF_XILSOCKS\];" $inst_num]
470    puts $file_handle [format "struct xilnet_udp_conn xilnet_udp_conns_eth_%s\[XILNET_MAX_UDP_CONNS\];" $inst_num]
471    puts $file_handle ""
472   
473}
474
475
476proc print_c_file_dma {file_handle inst_num} {
477
478    puts $file_handle ""
479    puts $file_handle "// Variables for ETH $inst_num"
480    puts $file_handle [format "XAxiDma              ETH_%s_DMA_Instance;" $inst_num]
481    puts $file_handle ""
482    puts $file_handle "// Aligned memory segments to be used for buffer descriptors"
483    puts $file_handle [format "char ETH_%s_RX_BD_space\[XILNET_ETH_%s_RXBD_SPACE_BYTES\] __attribute__ ((aligned(XILNET_BD_ALIGNMENT)));" $inst_num $inst_num]
484    puts $file_handle [format "char ETH_%s_TX_BD_space\[XILNET_ETH_%s_TXBD_SPACE_BYTES\] __attribute__ ((aligned(XILNET_BD_ALIGNMENT)));" $inst_num $inst_num]
485    puts $file_handle ""
486    puts $file_handle "// Buffers for ETH $inst_num"
487    puts $file_handle [format "unsigned int recvBuffer_eth_%s\[XILNET_ETH_%s_NUM_RECV_BUF*((XILNET_ETH_%s_BUF_SIZE+3)/4)\];" $inst_num $inst_num $inst_num]
488    puts $file_handle [format "unsigned int sendBuffer_eth_%s\[(XILNET_ETH_%s_BUF_SIZE+3)/4\];" $inst_num $inst_num]
489    puts $file_handle [format "struct xilsock_socket  xilsock_sockets_eth_%s\[NO_OF_XILSOCKS\];" $inst_num]
490    puts $file_handle [format "struct xilnet_udp_conn xilnet_udp_conns_eth_%s\[XILNET_MAX_UDP_CONNS\];" $inst_num]
491    puts $file_handle ""
492
493}
494
495
496proc print_c_file_temac {file_handle inst_num} {
497
498    puts $file_handle ""
499    puts $file_handle "// Variables for ETH $inst_num"
500    puts $file_handle [format "XLlFifo              ETH_%s_FIFO_Instance;" $inst_num]
501    puts $file_handle [format "XDmaCentral          ETH_%s_DMA_Instance;" $inst_num]
502    puts $file_handle ""
503    puts $file_handle "// Buffers for ETH $inst_num"
504    puts $file_handle [format "unsigned int recvBuffer_eth_%s\[XILNET_ETH_%s_NUM_RECV_BUF*((XILNET_ETH_%s_BUF_SIZE+3)/4)\];" $inst_num $inst_num $inst_num]
505    puts $file_handle [format "unsigned int sendBuffer_eth_%s\[(XILNET_ETH_%s_BUF_SIZE+3)/4\];" $inst_num $inst_num]
506    puts $file_handle [format "struct xilsock_socket  xilsock_sockets_eth_%s\[NO_OF_XILSOCKS\];" $inst_num]
507    puts $file_handle [format "struct xilnet_udp_conn xilnet_udp_conns_eth_%s\[XILNET_MAX_UDP_CONNS\];" $inst_num]
508    puts $file_handle ""
509
510}
511
512
513proc print_c_file_footer {file_handle inf_type_list} {
514
515    set inst_num      0
516
517    puts $file_handle ""
518    puts $file_handle "/*************************** Ethernet Variables ******************************/"
519    puts $file_handle ""
520    puts $file_handle ""
521    puts $file_handle "// Ethernet Device Structure"
522    puts $file_handle "xilnet_eth_device eth_device\[XILNET_NUM_ETH_DEVICES\];"
523    puts $file_handle ""
524    puts $file_handle ""
525    puts $file_handle "void xilnet_init_eth_device_struct(unsigned int eth_dev_num) \{"
526    puts $file_handle ""
527    puts $file_handle "    switch( eth_dev_num ) \{"
528
529    foreach inf_type $inf_type_list {
530
531        puts $file_handle [format "        case XILNET_ETH_%s:" $inst_num]
532       
533        switch $inf_type {
534            "axi_fifo_mm_s" {
535                puts $file_handle "            eth_device\[eth_dev_num\].inf_type             = XILNET_AXI_FIFO_INF;"
536                puts $file_handle [format "            eth_device\[eth_dev_num\].inf_id               = XILNET_ETH_%s_INF_DEVICE_ID;" $inst_num]
537                puts $file_handle [format "            eth_device\[eth_dev_num\].inf_ref              = &ETH_%s_FIFO_Instance;" $inst_num] 
538                puts $file_handle "            eth_device\[eth_dev_num\].inf_cfg_ref          = 0;"
539                puts $file_handle "            eth_device\[eth_dev_num\].inf_dma_id           = 0;"
540                puts $file_handle "            eth_device\[eth_dev_num\].inf_dma_ref          = 0;"
541                puts $file_handle "            eth_device\[eth_dev_num\].inf_dma_cfg_ref      = 0;"
542                puts $file_handle "            eth_device\[eth_dev_num\].dma_rx_ring_ref      = 0;"
543                puts $file_handle "            eth_device\[eth_dev_num\].dma_tx_ring_ref      = 0;"
544                puts $file_handle "            eth_device\[eth_dev_num\].dma_rx_bd_ref        = 0;"
545                puts $file_handle "            eth_device\[eth_dev_num\].dma_tx_bd_ref        = 0;"
546                puts $file_handle "            eth_device\[eth_dev_num\].dma_rx_bd_cnt        = 0;"
547                puts $file_handle "            eth_device\[eth_dev_num\].dma_tx_bd_cnt        = 0;"
548            }
549            "axi_dma" {
550                puts $file_handle "            eth_device\[eth_dev_num\].inf_type             = XILNET_AXI_DMA_INF;"
551                puts $file_handle [format "            eth_device\[eth_dev_num\].inf_id               = XILNET_ETH_%s_INF_DEVICE_ID;" $inst_num]
552                puts $file_handle [format "            eth_device\[eth_dev_num\].inf_ref              = &ETH_%s_DMA_Instance;" $inst_num]
553                puts $file_handle "            eth_device\[eth_dev_num\].inf_cfg_ref          = 0;"
554                puts $file_handle "            eth_device\[eth_dev_num\].inf_dma_id           = 0;"
555                puts $file_handle "            eth_device\[eth_dev_num\].inf_dma_ref          = 0;"
556                puts $file_handle "            eth_device\[eth_dev_num\].inf_dma_cfg_ref      = 0;"
557                puts $file_handle "            eth_device\[eth_dev_num\].dma_rx_ring_ref      = 0;"
558                puts $file_handle "            eth_device\[eth_dev_num\].dma_tx_ring_ref      = 0;"
559                puts $file_handle [format "            eth_device\[eth_dev_num\].dma_rx_bd_ref        = &ETH_%s_RX_BD_space;" $inst_num]
560                puts $file_handle [format "            eth_device\[eth_dev_num\].dma_tx_bd_ref        = &ETH_%s_TX_BD_space;" $inst_num]
561                puts $file_handle [format "            eth_device\[eth_dev_num\].dma_rx_bd_cnt        = XILNET_ETH_%s_RXBD_CNT;" $inst_num]
562                puts $file_handle [format "            eth_device\[eth_dev_num\].dma_tx_bd_cnt        = XILNET_ETH_%s_TXBD_CNT;" $inst_num]
563            }
564            "xps_ll_temac" {
565                puts $file_handle "            eth_device\[eth_dev_num\].inf_type             = XILNET_TEMAC_INF;"
566                puts $file_handle [format "            eth_device\[eth_dev_num\].inf_id               = XILNET_ETH_%s_INF_DEVICE_ID;" $inst_num]
567                puts $file_handle [format "            eth_device\[eth_dev_num\].inf_ref              = &ETH_%s_FIFO_Instance;" $inst_num] 
568                puts $file_handle "            eth_device\[eth_dev_num\].inf_cfg_ref          = 0;"
569                puts $file_handle [format "            eth_device\[eth_dev_num\].inf_dma_id           = XILNET_ETH_%s_INF_DMA_DEVICE_ID;" $inst_num]
570                puts $file_handle [format "            eth_device\[eth_dev_num\].inf_dma_ref          = &ETH_%s_DMA_Instance;" $inst_num] 
571                puts $file_handle "            eth_device\[eth_dev_num\].inf_dma_cfg_ref      = 0;"
572                puts $file_handle "            eth_device\[eth_dev_num\].dma_rx_ring_ref      = 0;"
573                puts $file_handle "            eth_device\[eth_dev_num\].dma_tx_ring_ref      = 0;"
574                puts $file_handle "            eth_device\[eth_dev_num\].dma_rx_bd_ref        = 0;"
575                puts $file_handle "            eth_device\[eth_dev_num\].dma_tx_bd_ref        = 0;"
576                puts $file_handle "            eth_device\[eth_dev_num\].dma_rx_bd_cnt        = 0;"
577                puts $file_handle "            eth_device\[eth_dev_num\].dma_tx_bd_cnt        = 0;"
578            }
579        }
580
581        puts $file_handle "            eth_device\[eth_dev_num\].xilsock_status_flag  = 0;"
582        puts $file_handle "            eth_device\[eth_dev_num\].sync_IP_octet        = 255;"
583        puts $file_handle "            eth_device\[eth_dev_num\].is_xilsock_init      = 0;"
584        puts $file_handle [format "            eth_device\[eth_dev_num\].xilsock_sockets      = &xilsock_sockets_eth_%s;" $inst_num]
585        puts $file_handle "            eth_device\[eth_dev_num\].is_udp_init          = 0;"
586        puts $file_handle [format "            eth_device\[eth_dev_num\].xilnet_udp_conns     = &xilnet_udp_conns_eth_%s;" $inst_num]
587        puts $file_handle [format "            eth_device\[eth_dev_num\].buf_size             = XILNET_ETH_%s_BUF_SIZE;" $inst_num]
588        puts $file_handle [format "            eth_device\[eth_dev_num\].num_recvbuf          = XILNET_ETH_%s_NUM_RECV_BUF;" $inst_num]
589        puts $file_handle [format "            eth_device\[eth_dev_num\].recvbuf              = (unsigned int *)&recvBuffer_eth_%s;" $inst_num]
590        puts $file_handle [format "            eth_device\[eth_dev_num\].sendbuf              = (unsigned int *)&sendBuffer_eth_%s;" $inst_num]
591        puts $file_handle "            break;"
592
593        incr inst_num
594    }
595   
596    puts $file_handle "        default:"
597    puts $file_handle "         xil_printf(\"  **** ERROR:  Trying to initialize Ethernet device %d.  Only %d configured in the HW.\", (eth_dev_num+1), XILNET_NUM_ETH_DEVICES);"
598    puts $file_handle "     break;"
599    puts $file_handle "    \}"
600    puts $file_handle "\}"
601    puts $file_handle ""
602    puts $file_handle ""
603    puts $file_handle "/*****************************************************************************/"
604    puts $file_handle ""
605
606}
607
Note: See TracBrowser for help on using the repository browser.