From c7bf9cc575dea15ecc8780afd34ffb3503f3249b Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 27 Sep 2018 01:21:33 +0200 Subject: try to isolate netstack to library --- Makefile | 1 - driver/e1000.h | 2 +- driver/keyboard.c | 2 +- net/Makefile | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ net/eth.c | 2 +- net/icmp.c | 6 ++-- net/net_sys.h | 7 +++++ net/udp.h | 2 +- 8 files changed, 105 insertions(+), 9 deletions(-) create mode 100644 net/Makefile create mode 100644 net/net_sys.h diff --git a/Makefile b/Makefile index 7a0f2d8..2758bcc 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,6 @@ AS=i686-elf-as ############ compiler flags ############ - #https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html CFLAGS= diff --git a/driver/e1000.h b/driver/e1000.h index 7eee572..ba988bc 100644 --- a/driver/e1000.h +++ b/driver/e1000.h @@ -1,5 +1,5 @@ #include -#include "netdev.h" +#include "net/netdev.h" struct netdev e1000_init(uint32_t base); int e1000_sendPacket(const void * p_data, uint16_t p_len); void e1000_irq (int irq); diff --git a/driver/keyboard.c b/driver/keyboard.c index f667396..efbcc53 100644 --- a/driver/keyboard.c +++ b/driver/keyboard.c @@ -8,7 +8,7 @@ #include -#include "inet.h" +#include "net/inet.h" ringbuffer kb_in; diff --git a/net/Makefile b/net/Makefile new file mode 100644 index 0000000..b8ab2b6 --- /dev/null +++ b/net/Makefile @@ -0,0 +1,92 @@ + + ############## + # Fool Stack # + ############## + +############ compiler ############ + +#use our cross compiler +CC=i686-foolos-gcc +AS=i686-foolos-as + +#sorry just this +CC=i686-elf-gcc +AS=i686-elf-as + +############ compiler flags ############ + + +#https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html + +CFLAGS= +#CFLAGS+=-fvar-tracking +#CFLAGS+=-DGIT_REVISION=\"$(GIT_REVISION)\" +CFLAGS+=-ffreestanding # do we need this if using own compiler? +CFLAGS+=-nostdlib +#CFLAGS+=-Og +CFLAGS+=-O0 +#CFLAGS+=-I. +#CFLAGS+=-I/home/miguel/temp/foolos/usr/i686-foolos/include/ +#CFLAGS+=-I./asm +#CFLAGS+=-I./kernel +#CFLAGS+=-I./driver +#CFLAGS+=-I./fs +CFLAGS+=-gstabs + +#CFLAGS+=-fstack-protector-all +#CFLAGS+=-fno-zero-initialized-in-bss +#CFLAGS+=-fdata-sections -ffunction-sections + +#CFLAGS+= -w # disable all warnings +#CFLAGS+= -Wimplicit-function-declaration +CFLAGS+= -Wall +#CFLAGS+= -Wextra +#CFLAGS+= -pedantic +CFLAGS+= -Werror +CFLAGS+= -Werror=implicit-function-declaration + +CFLAGS+= -Wno-unused-variable +CFLAGS+= -Wno-unused-function +CFLAGS+= -Wno-int-conversion +CFLAGS+= -Wno-implicit-int +CFLAGS+= -Wno-incompatible-pointer-types +CFLAGS+= -Wno-discarded-qualifiers +CFLAGS+= -Wno-unused-but-set-variable + +#CFLAGS+ = -Wall -Wextra -std=c89 -pedantic -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition + +######## linker flags #################### +LDFLAGS= +LDLIBS+=-lgcc + +########## assembler flags ################# +ASFLAGS= +ASFLAGS+=-gstabs + +########## verbosity ##################3 +#V = 0 +#CC = @echo "Compiling (i686-elf-gcc) $<..."; i686-elf-gcc +#AS = @echo "Assembling (i686-elf-as) $<..."; i686-elf-as +#CC_1 = $(CCC) +#CC = $(CC_$(V)) + +############ source and object files and their deps ############ + +#source files +SOURCES= +SOURCES+=$(wildcard *.c) + +#derive object files +OBJECTS=$(patsubst %.c, %.o, $(SOURCES)) + +#derive and include deps +DEPS=$(patsubst %.c, %.d, $(SOURCES)) + +-include $(DEPS) + +tags: + @echo "Generating ctags..."; ctags --recurse=yes . + +clean: + @echo "Cleaning..."; rm -f *.d *.o tags + diff --git a/net/eth.c b/net/eth.c index 780a89a..fedcda5 100644 --- a/net/eth.c +++ b/net/eth.c @@ -1,7 +1,7 @@ +#include "net_sys.h" #include "inet.h" #include "eth.h" #include "netdev.h" -#include "lib/string/string.h" uint32_t eth_generic(struct netdev *dev, uint32_t ip, uint16_t type, uint8_t* pos,uint32_t *end) { diff --git a/net/icmp.c b/net/icmp.c index d2e4de2..3c071dd 100644 --- a/net/icmp.c +++ b/net/icmp.c @@ -1,10 +1,8 @@ +#include "net_sys.h" + #include "inet.h" #include "icmp.h" #include "ipv4.h" -#include "log.h" -#include "kmalloc.h" - -#include "lib/string/string.h" uint32_t icmp_generic(struct netdev *dev, uint32_t ip, uint8_t type, uint8_t* pos,uint8_t *end) { diff --git a/net/net_sys.h b/net/net_sys.h new file mode 100644 index 0000000..a296b41 --- /dev/null +++ b/net/net_sys.h @@ -0,0 +1,7 @@ +/** + * @file + * + * this has to be provided and linked against the fool stack + */ + +void* memcpy(void* restrict dstptr, const void* restrict srcptr, int size); diff --git a/net/udp.h b/net/udp.h index 2c30804..85aa248 100644 --- a/net/udp.h +++ b/net/udp.h @@ -1,5 +1,5 @@ -#include "netdev.h" #include +#include "netdev.h" struct udp_v4{ uint16_t src_port; -- cgit v1.2.3