Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Compilable version with both lwip and uip
Lei Xia [Tue, 30 Sep 2008 21:59:13 +0000 (16:59 -0500)]
palacios/build/Makefile
palacios/include/geekos/timer.h
palacios/include/lwip/arch/perf.h
palacios/src/common/string.c
palacios/src/geekos/synch.c
palacios/src/geekos/timer.c
palacios/src/lwip/arch/sys_arch.c
palacios/src/lwip/build/Makefile
palacios/src/net/uip.c

index 12ae684..e5c0612 100644 (file)
@@ -181,7 +181,12 @@ endif
 #
 #TCPSTACK, uIP is used currently
 #
-TCPSTACK=UIP
+UIP=ON
+
+#
+#LWIP, ON -- used, OFF -- not used
+#
+LWIP=ON
 
 #
 #RAMDISK
@@ -304,11 +309,23 @@ DEVICE_OBJS := $(DEVICE_C_OBJS)
 V3LIBS := $(DECODER_LIBS)
 
 
-TCPSTACK_C_SRCS := psock.c timer.c uip_arp.c uip.c uip-fw.c uiplib.c uip-neighbor.c uip-split.c resolv.c
 
-TCPSTACK_C_OBJS := $(TCPSTACK_C_SRCS:%.c=net/%.o)
 
-TCPSTACK_OBJS := $(TCPSTACK_C_OBJS)
+ifeq ($(UIP),ON)
+       UIP_C_SRCS := psock.c timer.c uip_arp.c uip.c uip-fw.c uiplib.c uip-neighbor.c uip-split.c resolv.c
+       UIP_C_OBJS := $(UIP_C_SRCS:%.c=net/%.o)
+else
+       UIP_C_SRCS :=
+       UIP_C_OBJS :=   
+endif
+
+ifeq ($(LWIP),ON)
+       LWIP_OBJS := lwip/*.o
+else
+       LWIP_OBJS := 
+endif
+
+TCPSTACK_OBJS := $(UIP_C_OBJS) $(LWIP_OBJS)
 
 
 
@@ -477,6 +494,9 @@ rombios_link:
 vgabios_link:
        ln -s -f ../src/vmboot/vgabios/VGABIOS-lgpl-latest.bin vgabios
 
+force_lwip:
+       (cd ../src/lwip/build; make clean; make)
+
 force_rombios: rombios_link
        (cd ../src/vmboot/rombios; make clean; make)
 
@@ -486,7 +506,7 @@ force_vgabios: vgabios_link
 force_payload: force_rombios force_vgabios
        ../scripts/make_payload.pl payload_layout.txt vm_kernel
 
-inter1: force_payload
+inter1: force_payload force_lwip
        -make clean
 
 world: inter1 vmm.img
index b9f4eb4..da31415 100644 (file)
@@ -43,4 +43,6 @@ int Cancel_Timer(int id);
 
 void Micro_Delay(int us);
 
+ulong_t clock_time(void);  //return elipsed millisecs
+
 #endif  /* GEEKOS_TIMER_H */
index 1daebac..ea09f70 100644 (file)
@@ -52,6 +52,8 @@
 #define PERF_STOP(x)  /* null definition */
 #endif /* PERF */
 
+#if 0
+
 void perf_print(unsigned long c1l, unsigned long c1h,
                unsigned long c2l, unsigned long c2h,
                char *key);
@@ -60,4 +62,6 @@ void perf_print_times(struct tms *start, struct tms *end, char *key);
 
 void perf_init(char *fname);
 
+#endif
+
 #endif /* __ARCH_PERF_H__ */
index 5c82ec4..41f4b8a 100644 (file)
@@ -307,7 +307,7 @@ int fflush(FILE *stream)
     //PrintDebug("In fflush!!\n");
 
     return 0;
-}*/
+}
 
 void abort(void)
 {
index fdc1f34..c7a826c 100644 (file)
@@ -134,6 +134,24 @@ void Mutex_Unlock(struct Mutex* mutex)
 }
 
 /*
+ * Destroy Mutex
+ */
+void Mutex_Destroy(struct Mutex* mutex)
+{
+
+
+}
+
+/*
+ * Condition Destroy
+ */
+void Cond_Destroy(struct Condition* cond)
+{
+
+
+}
+
+/*
  * Initialize given condition.
  */
 void Cond_Init(struct Condition* cond)
index 9a54ff2..ec47b0b 100644 (file)
@@ -131,11 +131,6 @@ timerEvent pendingTimerEvents[MAX_TIMER_EVENTS];
  */
 volatile ulong_t g_numTicks;
 
-ulong_t clock_time(void){
-       return g_numTicks;
-}
-
-
 /*
  * Number of times the spin loop can execute during one timer tick
  */
@@ -171,6 +166,10 @@ int g_Quantum = DEFAULT_MAX_TICKS;
 #  define Debug(args...)
 #endif
 
+ulong_t clock_time(void){//in millisec
+      return g_numTicks * (1000/HZ);
+}
+
 /* ----------------------------------------------------------------------
  * Private functions
  * ---------------------------------------------------------------------- */
index f11d0ff..d5fa76d 100644 (file)
  *    will block until there is more room instead of just
  *    leaking messages.
  */
+/*
+ * Modified by Lei Xia (lxia@northwestern.edu) to fit to Palacios, 9/29/2008
+ */
 #include "lwip/debug.h"
 
 #include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
 
+#include <palacios/vmm.h>
 #include <geekos/synch.h>
 #include <geekos/kthread.h>
-#include <palacios/vmm.h>
 #include <geekos/debug.h>
+#include <geekos/timer.h>
+#include <geekos/malloc.h>
 
 #include "lwip/sys.h"
 #include "lwip/opt.h"
@@ -103,15 +103,15 @@ struct sys_thread {
 };
 
 
-static struct timeval starttime;
+//static struct timeval starttime;
 
 //static pthread_mutex_t lwprot_mutex = PTHREAD_MUTEX_INITIALIZER;
 static struct Mutex lwprot_mutex; // !!!! need to be initiated, void Mutex_Init(struct Mutex* mutex);
 
 //static pthread_t lwprot_thread = (pthread_t) 0xDEAD;
-static struct Kernel_Thread lwprot_thread = (struct Kernel_Thread) 0xDEAD;  //!!!!! how to set it to a NULL thread?
+//static struct Kernel_Thread lwprot_thread = (struct Kernel_Thread) 0xDEAD;  //!!!!! how to set it to a NULL thread?
 
-static int lwprot_count = 0;
+//static int lwprot_count = 0;
 
 static struct sys_sem *sys_sem_new_(u8_t count);
 static void sys_sem_free_(struct sys_sem *sem);
@@ -125,7 +125,7 @@ introduce_thread(struct Kernel_Thread *id /*pthread_t id*/)
 {
   struct sys_thread *thread;
   
-  thread = (struct sys_thread *)V3_Malloc(sizeof(struct sys_thread)); 
+  thread = (struct sys_thread *)Malloc(sizeof(struct sys_thread)); 
     
   if (thread != NULL) {
     //pthread_mutex_lock(&threads_mutex);
@@ -193,12 +193,12 @@ current_thread(void)
 sys_thread_t
 sys_thread_new(char *name, void (* function)(void *arg), void *arg, int stacksize, int prio)
 {
-  int code;
+  //int code;
   //pthread_t tmp;
   struct Kernel_Thread *tmp;
   struct sys_thread *st = NULL;
   
-  //tmp = (struct Kernel_Thread *)V3_Malloc(sizeof(struct Kernel_Thread));
+  //tmp = (struct Kernel_Thread *)Malloc(sizeof(struct Kernel_Thread));
   
   /* code = pthread_create(&tmp,
                         NULL, 
@@ -227,7 +227,7 @@ sys_mbox_new(int size)
 {
   struct sys_mbox *mbox;
   
-  mbox = (struct sys_mbox *)V3_Malloc(sizeof(struct sys_mbox));
+  mbox = (struct sys_mbox *)Malloc(sizeof(struct sys_mbox));
   if (mbox != NULL) {
     mbox->first = mbox->last = 0;
     mbox->mail = sys_sem_new_(0);
@@ -258,7 +258,7 @@ sys_mbox_free(struct sys_mbox *mbox)
     mbox->mail = mbox->mutex = NULL;
     /*  LWIP_DEBUGF("sys_mbox_free: mbox 0x%lx\n", mbox); */
 
-    V3_Free(mbox); 
+    Free(mbox); 
   }
 }
 /*-----------------------------------------------------------------------------------*/
@@ -421,7 +421,7 @@ sys_sem_new_(u8_t count)
 {
   struct sys_sem *sem;
   
-  sem = (struct sys_sem *)V3_Malloc(sizeof(struct sys_sem));
+  sem = (struct sys_sem *)Malloc(sizeof(struct sys_sem));
   if (sem != NULL) {
     sem->c = count;
 
@@ -567,7 +567,7 @@ sys_sem_free_(struct sys_sem *sem)
   //pthread_mutex_destroy(&(sem->mutex));
   Mutex_Destroy(&(sem->mutex));
   
-  V3_Free(sem);
+  Free(sem);
 }
 
 #if 0
@@ -610,6 +610,8 @@ sys_arch_timeouts(void)
   thread = current_thread();
   return &thread->timeouts;
 }
+
+
 /*-----------------------------------------------------------------------------------*/
 /** sys_prot_t sys_arch_protect(void)
 
@@ -625,6 +627,8 @@ that case the return value indicates that it is already protected.
 sys_arch_protect() is only required if your port is supporting an operating
 system.
 */
+
+#if 0
 sys_prot_t
 sys_arch_protect(void)
 {
@@ -659,11 +663,12 @@ sys_arch_unprotect(sys_prot_t pval)
     {
         if (--lwprot_count == 0)
         {
-            lwprot_thread = (Kernel_Thread) 0xDEAD;
+            lwprot_thread = (struc Kernel_Thread) 0xDEAD;
             Mutex_Unlock(&lwprot_mutex);
         }
     }
 }
+#endif
 
 /*-----------------------------------------------------------------------------------*/
 
@@ -675,6 +680,7 @@ sys_arch_unprotect(sys_prot_t pval)
 #define HZ 100
 #endif
 
+#if 0
 unsigned long
 sys_jiffies(void)
 {
@@ -690,6 +696,7 @@ sys_jiffies(void)
     usec /= 1000000L / HZ;
     return HZ * sec + usec;
 }
+#endif
 
 #if PPP_DEBUG
 
@@ -703,7 +710,7 @@ void ppp_trace(int level, const char *format, ...)
     va_start(args, format);
        
     //vprintf(format, args);
-    SerialPrintList(format, args);
+    PrintDebug(format, args);
        
     va_end(args);
 }
index ce16551..af7ceb3 100644 (file)
@@ -47,11 +47,11 @@ CFLAGS:=$(CFLAGS) \
 # 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.c $(LWIPDIR)/core/tcp_in.c $(LWIPDIR)/core/raw.c\
         $(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/udp.c $(LWIPDIR)/core/init.c 
 CORE4FILES=$(LWIPDIR)/core/ipv4/icmp.c $(LWIPDIR)/core/ipv4/ip.c \
        $(LWIPDIR)/core/ipv4/inet.c $(LWIPDIR)/core/ipv4/ip_addr.c \
-       $(LWIPDIR)/core/ipv4/inet_chksum.c 
+       $(LWIPDIR)/core/ipv4/inet_chksum.c $(LWIPDIR)/core/ipv4/ip_frag.c
 
 
 # APIFILES: The files which implement the sequential and socket APIs.
@@ -70,25 +70,25 @@ LWIPFILES=$(COREFILES) $(CORE4FILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES)
 LWIPFILESW=$(wildcard $(LWIPFILES))
 LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
 
-#LWIPLIB=lwip.o
+# LWIPLIB=lwip.o
 
 %.o:
        $(CC) $(CFLAGS) -c  $(LWIPFILES)
 
-all: $(LWIPOBJS) 
+all: $(LWIPOBJS)
        cp *.o $(PROJECT_ROOT)build/lwip/
 
 .PHONY: all
 
 clean:
-       rm -f *.o $(LWIPLIB) *.s .depend* *.core
+       rm -f *.o .depend*
 
 depend dep: .depend
 
 include .depend
 
-##$(LWIPLIB): $(LWIPOBJS)
-##     $(CC) -g -nostartfiles -shared -static $^ -o $@ 
+# $(LWIPLIB): $(LWIPOBJS)
+#      $(CC) -g -nostartfiles -shared -static $^ -o $@ 
 
 .depend: $(LWIPFILES)
        $(CC) $(CFLAGS) -MM $^ > .depend || rm -f .depend
index 059ef9b..0b9fa75 100644 (file)
@@ -1877,12 +1877,16 @@ uip_process(u8_t flag)
   uip_flags = 0;
   return;
 }
+
 /*---------------------------------------------------------------------------*/
+/* replicate defined in lwip.c,
 u16_t
 htons(u16_t val)
 {
   return HTONS(val);
 }
+*/
+
 /*---------------------------------------------------------------------------*/
 void
 uip_send(const void *data, int len)