initial check-in

This commit is contained in:
cborrelli 2003-06-19 09:47:10 +00:00
parent fccd677865
commit 184c0e9e0f
3 changed files with 534 additions and 0 deletions

View File

@ -0,0 +1,76 @@
###############################################################################
# Copyright (c) 2001-2003 Swedish Institute of Computer Science.
# All rights reserved.
#
# Copyright (c) 2003 Xilinx, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS".
# 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.
#
# This file is part of the lwIP TCP/IP stack.
#
# Author: Sathya Thammanur <Sathyanarayanan.Thammanur@xilinx.com>
#
###############################################################################
OPTION psf_version = 2.1;
BEGIN LIBRARY lwip
OPTION drc = lwip_drc;
OPTION copyfiles = (Makefile);
BEGIN ARRAY emac_instances
PROPERTY desc = "List of Ethernet instances to be used with lwip";
PROPERTY size = 0;
PARAM name = emac_instname, desc = "Name of Emac instance", type = peripheral_instance;
PARAM name = eth_addr1, desc = "First byte of MAC address", type = int;
PARAM name = eth_addr2, desc = "Second byte of MAC address", type = int;
PARAM name = eth_addr3, desc = "Third byte of MAC address", type = int;
PARAM name = eth_addr4, desc = "Fourth byte of MAC address", type = int;
PARAM name = eth_addr5, desc = "Fifth byte of MAC address", type = int;
PARAM name = eth_addr6, desc = "Sixth byte of MAC address", type = int;
END ARRAY
BEGIN ARRAY gemac_instances
PROPERTY desc = "List of Gigabit Ethernet instances to be used with lwip";
PROPERTY size = 0;
PARAM name = gemac_instname, desc = "Name of GEmac instance", type = peripheral_instance;
END ARRAY
PARAM name = lwip_srcdir, desc = "Source directory of lwip", type = string;
END LIBRARY

View File

@ -0,0 +1,265 @@
###############################################################################
# Copyright (c) 2001-2003 Swedish Institute of Computer Science.
# All rights reserved.
#
# Copyright (c) 2003 Xilinx, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS".
# 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.
#
# This file is part of the lwIP TCP/IP stack.
#
# Author: Sathya Thammanur <Sathyanarayanan.Thammanur@xilinx.com>
# Author: Chris Borrelli <Chris.Borrelli@xilinx.com>
#
###############################################################################
# Globals
lappend emac_list
lappend gemac_list
###############################################################################
# lwip_drc - run drc checking (future work)
###############################################################################
proc lwip_drc {lib_handle} {
puts "LWIP DRC..."
puts " ...not implemented yet."
}
###############################################################################
# generate - generates the .c file
###############################################################################
proc generate {libname} {
global emac_list
global gemac_list
# generate emac_list of instances to be used with lwip
set emac_inst_array [xget_handle $libname "ARRAY" "emac_instances"]
if {[string compare -nocase $emac_inst_array ""] != 0} {
set emac_inst_array_elems [xget_handle $emac_inst_array "ELEMENTS" "*"]
puts "XEmac Instances : [llength $emac_inst_array_elems]"
if {[string compare -nocase $emac_inst_array_elems ""] != 0} {
set emac_list $emac_inst_array_elems
}
}
# generate gemac_list of instances to be used with lwip
set gemac_inst_array [xget_handle $libname "ARRAY" "gemac_instances"]
if {[string compare -nocase $gemac_inst_array ""] != 0} {
set gemac_inst_array_elems [xget_handle $gemac_inst_array "ELEMENTS" "*"]
puts "XGEmac Instances : [llength $gemac_inst_array_elems]"
if {[string compare -nocase $gemac_inst_array_elems ""] != 0} {
set gemac_list $gemac_inst_array_elems
}
}
# Generate XEmacIf_Config Table in xemacif_g.c file
if {[string compare -nocase $emac_list ""] != 0} {
xgen_config_file "xemacif_g.c" "XEmacIf"
}
# Generate XGEmacIf_Config Table in xgemacif_g.c file
if {[string compare -nocase $gemac_list ""] != 0} {
xgen_config_file "xgemacif_g.c" "XGEmacIf"
}
}
###############################################################################
# xgen_config_file - does the real work of generating a C header file
###############################################################################
proc xgen_config_file {file_name if_type} {
global emac_list
global gemac_list
lappend list
puts "Generating $file_name ..."
set config_file [open [file join "src" $file_name] w]
xprint_generated_header $config_file "$if_type Configuration"
puts $config_file "#include \"xparameters.h\""
set if_file [file join "netif" [format "%s.h" [string tolower $if_type]]]
puts $config_file "#include \"$if_file\""
if {[string compare -nocase $if_type "XEmacIf"] == 0} {
puts $config_file "#include \"xemac.h\""
set list $emac_list
} elseif {[string compare -nocase $if_type "XGEmacIf"] == 0} {
puts $config_file "#include \"xgemac.h\""
set list $gemac_list
}
#set list_size [llength $list]
#puts $config_file "\n/*"
#puts $config_file " * Number of $if_type Instances"
#puts $config_file " */\n"
#puts $config_file [format "#define %s_ConfigTableSize %s" $if_type $list_size]
puts $config_file "\n/*"
puts $config_file " * The configuration table for devices"
puts $config_file " */\n"
puts $config_file [format "%s_Config %s_ConfigTable\[\] =" $if_type $if_type]
puts $config_file "\{"
set start_comma ""
foreach elem $list {
puts $config_file [format "%s\t\{" $start_comma]
set comma ""
if {[string compare -nocase $if_type "XEmacIf"] == 0} {
set inst [xget_value $elem "PARAMETER" "emac_instname"]
set ethaddr1 [xget_value $elem "PARAMETER" "eth_addr1"]
set ethaddr2 [xget_value $elem "PARAMETER" "eth_addr2"]
set ethaddr3 [xget_value $elem "PARAMETER" "eth_addr3"]
set ethaddr4 [xget_value $elem "PARAMETER" "eth_addr4"]
set ethaddr5 [xget_value $elem "PARAMETER" "eth_addr5"]
set ethaddr6 [xget_value $elem "PARAMETER" "eth_addr6"]
} elseif {[string compare -nocase $if_type "XGEmacIf"] == 0} {
set inst [xget_value $elem "PARAMETER" "emac_instname"]
set ethaddr1 ""
set ethaddr2 ""
set ethaddr3 ""
set ethaddr4 ""
set ethaddr5 ""
set ethaddr6 ""
}
# Get the instance handle -
# for example, get pointer to an instance named my_opb_ethernet
# Get the handle to the interrupt port -ip2intc_irpt
# (same name in emac and gemac)
set inst_handle [xget_hwhandle $inst]
set intr_port_name "IP2INTC_Irpt"
########################################################################
# generate device id
########################################################################
puts -nonewline $config_file [format "%s\t\t%s" $comma [xget_name $inst_handle "DEVICE_ID"]]
set comma ",\n"
########################################################################
# generate intr id - doesn't work in EDK 3.2.2
########################################################################
# START : CHRISB COMMENTED THIS OUT
#set intr_id [xget_intr_name $inst_handle $intr_port_name]
#puts -nonewline $config_file [format "%s\t\t%s" $comma $intr_id]
# END : CHRISB COMMENTED THIS OUT
# START : CHRISB ADDED THIS
puts -nonewline $config_file [format "%s\t\t%s" $comma "0"]
# END : CHRISB ADDED THIS
########################################################################
# generate ethaddr
########################################################################
puts -nonewline $config_file [format "%s\t\t{{%s,%s,%s,%s,%s,%s}}" $comma $ethaddr1 $ethaddr2 $ethaddr3 $ethaddr4 $ethaddr5 $ethaddr6]
########################################################################
# generate instance ptr - always NULL because it is setup at runtime
########################################################################
puts -nonewline $config_file [format "%s\t\tNULL" $comma ]
puts -nonewline $config_file [format "\n\t\}" ]
set start_comma ",\n"
}
puts $config_file "\n\};"
close $config_file
}
###############################################################################
# This procedure does not work under EDK 3.2.2
###############################################################################
#proc xget_intr_name {periph_handle port_name} {
#
# set intr_port [xget_handle $periph_handle "PORT" $port_name]
# set intr_signal [xget_value $intr_port "VALUE"]
# #puts "intr_signal : $intr_signal"
#
# set mhs_handle [xget_handle $periph_handle "parent"]
# set source_port [xget_connected_ports_handle $mhs_handle $intr_signal "sink"]
# #puts "sourceport : $source_port"
#
# set intc_handle [xget_handle $source_port "parent"]
# set intc_name [xget_value $intc_handle "NAME"]
#
# set periph_name [xget_value $periph_handle "NAME"]
#
# set intc_drvhandle [xget_swhandle $intc_name]
# #puts "intcdrvname: [xget_value $intc_drvhandle "NAME"]"
#
# set level [xget_value $intc_drvhandle "PARAMETER" "level"]
# set intr_string ""
# if {$level == 0} {
# set intr_string "MASK"
# set retval [format "XPAR_%s_%s_%s" [string toupper $periph_name] [string toupper $port_name] [string toupper $intr_string]]
# } elseif {$level == 1} {
# set intr_string "INTR"
# set retval [format "XPAR_%s_%s_%s_%s" [string toupper $intc_name] [string toupper $periph_name] [string toupper $port_name] [string toupper $intr_string]]
# }
#
# return $retval
#}
###############################################################################
# post_generate - doesn't do anything at the moment
###############################################################################
proc post_generate {libname} {
}
###############################################################################
# execs_generate
# This procedure builds the liblwipv4.a
# library.
###############################################################################
proc execs_generate {libname} {
global errorCode
global errorInfo
set topdir [xget_value $libname "PARAMETER" "lwip_srcdir"]
puts "\n********************************"
puts " Building lwIP library"
puts "********************************\n"
puts "Using LWIP sources from directory $topdir "
if { [catch {exec bash -c "cd src;gmake all \"TOPDIR=$topdir\" >& logs"} errmsg] } {
error $errmsg $errorInfo
}
}

View File

@ -0,0 +1,193 @@
###############################################################################
# Copyright (c) 2001-2003 Swedish Institute of Computer Science.
# All rights reserved.
#
# Copyright (c) 2003 Xilinx, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS".
# 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.
#
# This file is part of the lwIP TCP/IP stack.
#
# Author: Chris Borrelli <Chris.Borrelli@xilinx.com>
#
#
# This Makefile is meant to be run from EDK (libgen). Please do not try
# try using this Makefile stand-alone on the command line; it will not work
#
COMPILER=powerpc-eabi-gcc
ARCHIVER=powerpc-eabi-ar
ARFLAGS=rs
CP=cp
COMPILERFLAGS=-Wall -gdwarf
#EXTRA_COMPILER_FLAGS = -DIPv4 -fpack-struct -msdata=eabi -mcpu=403
EXTRA_COMPILER_FLAGS = -DIPv4 -msdata=eabi -mcpu=403
LWIPDIR=$(TOPDIR)/lwip/src
ARCHDIR=$(TOPDIR)/contrib/ports/v2pro
LIB=liblwip4.a
RELEASEDIR=../../../lib
INCLUDEDIR=../../../include
INCLUDES= \
-I$(LWIPDIR)/include \
-I$(LWIPDIR)/include/ipv4 \
-I$(ARCHDIR) \
-I$(ARCHDIR)/include \
-I$(INCLUDEDIR)
INCLUDEFILES=$(TOPDIR)/lwip/src/include/ipv4/lwip \
$(TOPDIR)/lwip/src/include/lwip \
$(TOPDIR)/lwip/src/include/netif \
$(TOPDIR)/contrib/ports/v2pro/include/netif \
$(TOPDIR)/contrib/ports/v2pro/include/arch \
$(TOPDIR)/contrib/ports/v2pro/lwipopts.h
# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
COREFILES=$(LWIPDIR)/core/mem.c \
$(LWIPDIR)/core/memp.c \
$(LWIPDIR)/core/netif.c \
$(LWIPDIR)/core/pbuf.c \
$(LWIPDIR)/core/stats.c \
$(LWIPDIR)/core/sys.c \
$(LWIPDIR)/core/tcp.c \
$(LWIPDIR)/core/tcp_in.c \
$(LWIPDIR)/core/tcp_out.c \
$(LWIPDIR)/core/udp.c \
CORE4FILES=$(LWIPDIR)/core/ipv4/icmp.c \
$(LWIPDIR)/core/ipv4/ip.c \
$(LWIPDIR)/core/inet.c \
$(LWIPDIR)/core/ipv4/ip_addr.c \
$(LWIPDIR)/core/ipv4/ip_frag.c
# NETIFFILES: Files implementing various generic network interface functions.
NETIFFILES=$(LWIPDIR)/netif/etharp.c
# ARCHFILES: Archiecture specific files.
ARCHFILES=$(ARCHDIR)/lib_arch.c \
$(ARCHDIR)/perf.c \
$(ARCHDIR)/netif/xemacif.c \
xemacif_g.c
# LWIPFILES: All the above.
LWIPFILES=$(COREFILES) $(CORE4FILES) $(NETIFFILES) $(ARCHFILES)
LWIPFILESW=$(wildcard $(LWIPFILES))
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
help:
@echo ""
@echo "This Makefile generates a library for the v2pro port of lwIP."
@echo ""
@echo " Below are the targets:"
@echo ""
@echo " make lwiplibs"
@echo " This is the target that will compile all lwIP files, and"
@echo " build the library, $(LIB). The final library will be"
@echo " copied to $(RELEASEDIR)."
@echo ""
@echo " make lwipinclude"
@echo " Copies the lwIP include files into the EDK directory,"
@echo " $(INCLUDEDIR)"
@echo ""
@echo " make clean"
@echo " Removes all object files and the $(LIB) library from"
@echo " the local directory."
@echo ""
@echo " make depend"
@echo " Generates the .depend file, which contains the"
@echo " dependancies needed to compile each .c file. The"
@echo " .depend file will be generated automatically for"
@echo " other targets, so it is not nessessary to run"
@echo " make depend."
@echo ""
%.o:
@echo ""
@echo "Building File: $@"
@echo ""
$(COMPILER) $(COMPILERFLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) -c $(<:.o=.c)
all ipv4 lwiplibs: lwipinclude $(LIB)
.PHONY: all ipv4 lwiplibs lwip_include help
lwipinclude:
@for i in $(INCLUDEFILES); do \
echo ${CP} -r $$i ${INCLUDEDIR}; \
${CP} -r $$i ${INCLUDEDIR}; \
done
include:
@exit
libs:
@exit
clean:
@echo ""
@echo "Cleaning up..."
@echo ""
@rm -f *.o *.a .depend* core
depend dep: .depend
@exit
$(LIB): $(LWIPOBJS)
@echo ""
@echo "Building lwIP Library, $@"
$(ARCHIVER) $(ARFLAGS) $@ $?
@cp $@ $(RELEASEDIR)/
.depend: $(LWIPFILES) $(APPFILES)
@echo ""
@echo "Building dependancies..."
$(COMPILER) $(COMPILERFLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) \
-MM $^ > .depend || rm -f .depend
ifneq ($(MAKECMDGOALS), clean)
ifneq ($(MAKECMDGOALS), depend)
ifneq ($(MAKECMDGOALS), dep)
ifneq ($(MAKECMDGOALS), libs)
ifneq ($(MAKECMDGOALS), include)
ifneq ($(MAKECMDGOALS), help)
-include .depend
endif
endif
endif
endif
endif
endif