From 2e3c2611a660daf5a846f5eba844ab65f688f7cf Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 1 May 2013 00:12:13 +0200 Subject: [PATCH] software: put network code in a library --- software/bios/Makefile | 6 ++++-- software/bios/boot.c | 4 ++-- software/bios/main.c | 2 +- software/{bios => include/net}/microudp.h | 0 software/{bios => include/net}/tftp.h | 0 software/libnet/Makefile | 24 +++++++++++++++++++++++ software/{bios => libnet}/microudp.c | 2 +- software/{bios => libnet}/tftp.c | 4 ++-- 8 files changed, 34 insertions(+), 8 deletions(-) rename software/{bios => include/net}/microudp.h (100%) rename software/{bios => include/net}/tftp.h (100%) create mode 100644 software/libnet/Makefile rename software/{bios => libnet}/microudp.c (99%) rename software/{bios => libnet}/tftp.c (98%) diff --git a/software/bios/Makefile b/software/bios/Makefile index 77f60c97..6e464112 100644 --- a/software/bios/Makefile +++ b/software/bios/Makefile @@ -1,7 +1,7 @@ M2DIR=../.. include $(M2DIR)/software/common.mak -OBJECTS=crt0.o isr.o sdram.o main.o microudp.o tftp.o boot-helper.o boot.o dataflow.o +OBJECTS=crt0.o isr.o sdram.o main.o boot-helper.o boot.o dataflow.o all: bios.bin @@ -19,9 +19,10 @@ bios-rescue.elf: linker-rescue.ld $(OBJECTS) libs %.elf: $(LD) $(LDFLAGS) -T $< -N -o $@ $(OBJECTS) \ + -L$(M2DIR)/software/libnet \ -L$(M2DIR)/software/libbase \ -L$(M2DIR)/software/libcompiler-rt \ - -lbase -lcompiler-rt + -lnet -lbase -lcompiler-rt chmod -x $@ main.o: main.c @@ -36,6 +37,7 @@ main.o: main.c libs: make -C $(M2DIR)/software/libcompiler-rt make -C $(M2DIR)/software/libbase + make -C $(M2DIR)/software/libnet flash: bios.bin m1nor bios.bin diff --git a/software/bios/boot.c b/software/bios/boot.c index 6d703f82..93d2f279 100644 --- a/software/bios/boot.c +++ b/software/bios/boot.c @@ -11,8 +11,8 @@ #include -#include "microudp.h" -#include "tftp.h" +#include +#include #include "boot.h" extern int rescue; diff --git a/software/bios/main.c b/software/bios/main.c index 8b0939fc..146882b3 100644 --- a/software/bios/main.c +++ b/software/bios/main.c @@ -11,11 +11,11 @@ #include #include +#include #include "sdram.h" #include "dataflow.h" #include "boot.h" -#include "microudp.h" enum { CSR_IE = 1, CSR_IM, CSR_IP, CSR_ICC, CSR_DCC, CSR_CC, CSR_CFG, CSR_EBA, diff --git a/software/bios/microudp.h b/software/include/net/microudp.h similarity index 100% rename from software/bios/microudp.h rename to software/include/net/microudp.h diff --git a/software/bios/tftp.h b/software/include/net/tftp.h similarity index 100% rename from software/bios/tftp.h rename to software/include/net/tftp.h diff --git a/software/libnet/Makefile b/software/libnet/Makefile new file mode 100644 index 00000000..21af8d44 --- /dev/null +++ b/software/libnet/Makefile @@ -0,0 +1,24 @@ +M2DIR=../.. +include $(M2DIR)/software/common.mak + +OBJECTS=microudp.o tftp.o + +all: libnet.a + +# pull in dependency info for *existing* .o files +-include $(OBJECTS:.o=.d) + +libnet.a: $(OBJECTS) + $(AR) clr libnet.a $(OBJECTS) + $(RANLIB) libnet.a + +%.o: %.c + $(compile-dep) + +%.o: %.S + $(assemble) + +.PHONY: clean + +clean: + rm -f $(OBJECTS) $(OBJECTS:.o=.ts) $(OBJECTS:.o=.d) libnet.a .*~ *~ diff --git a/software/bios/microudp.c b/software/libnet/microudp.c similarity index 99% rename from software/bios/microudp.c rename to software/libnet/microudp.c index 1b263260..55257d83 100644 --- a/software/bios/microudp.c +++ b/software/libnet/microudp.c @@ -6,7 +6,7 @@ #include #include -#include "microudp.h" +#include #define ETHERTYPE_ARP 0x0806 #define ETHERTYPE_IP 0x0800 diff --git a/software/bios/tftp.c b/software/libnet/tftp.c similarity index 98% rename from software/bios/tftp.c rename to software/libnet/tftp.c index a2e1bfe1..2bf0eac6 100644 --- a/software/bios/tftp.c +++ b/software/libnet/tftp.c @@ -1,8 +1,8 @@ #include #include -#include "microudp.h" -#include "tftp.h" +#include +#include #define PORT_OUT 69 #define PORT_IN 7642 -- 2.30.2