Skip to contentSkip to conversation

minios: add lwIP 1.3.0 support

PATCH New Samuel Thibault 1 participant 1 message Jan 18, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 minios: add lwIP 1.3.0 support

minios: add lwIP 1.3.0 support

This is to be applied on top of the POSIX-time patch

only in patch2:
unchanged:

extras/mini-os/Makefile +26 -0
@@ -47,6 +47,13 @@ EXTRA_INC =
 # This must be before include minios.mk!
 include $(TARGET_ARCH_DIR)/arch.mk
 
+ifneq ($(LWIPDIR),)
+lwip=y
+DEF_CFLAGS += -DHAVE_LWIP
+DEF_CFLAGS += -I$(LWIPDIR)/src/include
+DEF_CFLAGS += -I$(LWIPDIR)/src/include/ipv4
+endif
+
 # Include common mini-os makerules.
 include minios.mk
 
@@ -90,6 +97,24 @@ arch_lib:
 arch_lib:
 	$(MAKE) --directory=$(TARGET_ARCH_DIR) || exit 1;
 
+ifeq ($(lwip),y)
+# lwIP library
+LWC	:= $(shell find $(LWIPDIR)/ -type f -name '*.c')
+LWC	:= $(filter-out %6.c %ip6_addr.c %ethernetif.c, $(LWC))
+LWC	+= lwip-arch.c lwip-net.c
+LWO	:= $(patsubst %.c,%.o,$(LWC))
+
+lwip.a: $(LWO)
+	$(RM) $@
+	$(AR) cqs $@ $^
+
+OBJS += lwip.a
+
+OBJS := $(filter-out $(LWO), $(OBJS))
+else
+OBJS := $(filter-out daytime.o lwip%.o, $(OBJS))
+endif
+
 $(TARGET): links $(OBJS) arch_lib
 	$(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(OBJS) $(LDARCHLIB) -o [email protected]
 	$(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start [email protected] [email protected]
@@ -107,6 +132,7 @@ clean:	arch_clean
 	done
 	rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
 	find . -type l | xargs rm -f
+	$(RM) lwip.a $(LWO)
 	rm -f tags TAGS
 
 

only in patch2:
unchanged:

extras/mini-os/daytime.c new file +64 -0

64 lines not on this page · raw message

only in patch2:
unchanged:

extras/mini-os/include/arch/cc.h new file +83 -0

83 lines not on this page · raw message

only in patch2:
unchanged:

extras/mini-os/include/arch/perf.h new file +15 -0
@@ -0,0 +1,15 @@
+/* 
+ * lwip/arch/perf.h
+ *
+ * Arch-specific performance measurement for lwIP running on mini-os 
+ *
+ * Tim Deegan <[email protected]>, July 2007
+ */
+
+#ifndef __LWIP_ARCH_PERF_H__
+#define __LWIP_ARCH_PERF_H__
+
+#define PERF_START    do { } while(0)
+#define PERF_STOP(_x) do { (void)(_x); } while (0)
+
+#endif /* __LWIP_ARCH_PERF_H__ */

only in patch2:
unchanged:

extras/mini-os/include/arch/sys_arch.h new file +35 -0
@@ -0,0 +1,35 @@
+/* 
+ * lwip/arch/sys_arch.h
+ *
+ * Arch-specific semaphores and mailboxes for lwIP running on mini-os 
+ *
+ * Tim Deegan <[email protected]>, July 2007
+ */
+
+#ifndef __LWIP_ARCH_SYS_ARCH_H__
+#define __LWIP_ARCH_SYS_ARCH_H__
+
+#include <os.h>
+#include <xmalloc.h>
+#include <semaphore.h>
+
+typedef struct semaphore *sys_sem_t;
+#define SYS_SEM_NULL ((sys_sem_t) NULL)
+
+struct mbox {
+    int count;
+    void **messages;
+    struct semaphore read_sem;
+    struct semaphore write_sem;
+    int writer;
+    int reader;
+};
+
+typedef struct mbox *sys_mbox_t;
+#define SYS_MBOX_NULL ((sys_mbox_t) 0)
+
+typedef struct thread *sys_thread_t;
+
+typedef unsigned long sys_prot_t;
+
+#endif /*__LWIP_ARCH_SYS_ARCH_H__ */

only in patch2:
unchanged:

extras/mini-os/include/console.h +3 -0
@@ -38,8 +38,11 @@
 
 #include<traps.h>
 
+void print(int direct, const char *fmt, va_list args);
 void printk(const char *fmt, ...);
 void xprintk(const char *fmt, ...);
+
+#define tprintk(_fmt, _args...) printk("[%s] " _fmt, current->name, ##_args) 
 
 void xencons_rx(char *buf, unsigned len, struct pt_regs *regs);
 void xencons_tx(void);

only in patch2:
unchanged:

extras/mini-os/include/lwipopts.h new file +22 -0
@@ -0,0 +1,22 @@
+/*
+ * lwipopts.h
+ *
+ * Configuration for lwIP running on mini-os 
+ *
+ * Tim Deegan <[email protected]>, July 2007
+ */
+
+#ifndef __LWIP_LWIPOPTS_H__
+#define __LWIP_LWIPOPTS_H__
+
+#define SYS_LIGHTWEIGHT_PROT 1
+#define MEM_LIBC_MALLOC 1
+#define LWIP_TIMEVAL_PRIVATE 0
+#define LWIP_DHCP 1
+#define LWIP_COMPAT_SOCKETS 0
+#define LWIP_IGMP 1
+#define MEMP_NUM_SYS_TIMEOUT 10
+#define TCP_SND_BUF 3000
+#define TCP_MSS 1500
+
+#endif /* __LWIP_LWIPOPTS_H__ */

only in patch2:
unchanged:

extras/mini-os/include/netfront.h +12 -0
@@ -1,7 +1,19 @@
 #include <wait.h>
+#ifdef HAVE_LWIP
+#include <lwip/netif.h>
+#endif
 struct netfront_dev;
 struct netfront_dev *init_netfront(char *nodename, void (*netif_rx)(unsigned char *data, int len), unsigned char rawmac[6]);
 void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len);
 void shutdown_netfront(struct netfront_dev *dev);
 
 extern struct wait_queue_head netfront_queue;
+
+#ifdef HAVE_LWIP
+/* Call this to bring up the netfront interface and the lwIP stack.
+ * N.B. _must_ be called from a thread; it's not safe to call this from 
+ * app_main(). */
+void start_networking(void);
+
+void networking_set_addr(struct ip_addr *ipaddr, struct ip_addr *netmask, struct ip_addr *gw);
+#endif

only in patch2:
unchanged:

extras/mini-os/lwip-arch.c new file +293 -0

293 lines not on this page · raw message

only in patch2:
unchanged:

extras/mini-os/lwip-net.c new file +360 -0

360 lines not on this page · raw message

only in patch2:
unchanged:

extras/mini-os/minios.mk +1 -1
@@ -6,7 +6,7 @@ debug = y
 
 # Define some default flags.
 # NB. '-Wcast-qual' is nasty, so I omitted it.
-DEF_CFLAGS := -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
+DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
 DEF_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
 DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline
 DEF_CFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)