Merge remote-tracking branch 'contiki-gb/master'
diff --git a/contiki-gb/Makefile b/contiki-gb/Makefile
new file mode 100644
index 0000000..0793d01
--- /dev/null
+++ b/contiki-gb/Makefile
@@ -0,0 +1,211 @@
+# Copyright (c) 2002, Adam Dunkels.
+# 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. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. 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.
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile,v 1.2 2005/04/18 22:44:54 oliverschmidt Exp $
+#
+
+CONTIKI=../contiki
+
+include $(CONTIKI)/Makefile.common
+
+# Change the target system type here
+SYS=gbc
+
+OPT=
+
+CC=/usr/local/bin/sdcc
+AS=/usr/local/bin/as-gbz80
+LD=/usr/local/bin/link-gbz80
+
+CFLAGS=-I arch/gbc -I ctk -I uip -I conf \
+       -I $(CONTIKI)/apps -I $(CONTIKI)/ctk -I $(CONTIKI)/ek \
+       -I $(CONTIKI)/lib -I $(CONTIKI)/uip \
+       \
+	  -DCTK_CONIO \
+     -I./apps -I./ctk -I./ek -I./lib -I./uip -I./arch/gb -I./arch -I.\
+	-DCTK_THEME_H="ctk-conio.h" -D__SDCC__ -D__GAMEBOY__ \
+	-DWITH_ASCII -mgbz80 -I /usr/local/share/sdcc/include \
+	-Wall -A -A --noinvariant --noinduction --callee-saves --callee-saves-bc \
+	--nojtbound --noloopreverse --int-long-reent --float-reent --no-peep \
+	--xram-movc
+
+LDFLAGS=
+AFLAGS=-g
+
+CCFLAGS=$(CFLAGS)
+ASFLAGS=$(AFLAGS)
+
+
+%.o: %.c
+	@$(CC) -S $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	@$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: ctk/%.c
+	@$(CC) -S $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	@$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: uip/%.c
+	@$(CC) -S $(CFLAGS)  -o $(patsubst %c, %s, $(notdir $<)) $<
+	@$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/apps/%.c
+	@$(CC) -S $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	@$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/ctk/%.c
+	@$(CC) -S $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	@$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/ek/%.c
+	@$(CC) -S $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	@$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/lib/%.c
+	@$(CC) -S $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	@$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/uip/%.c
+	@$(CC) -S $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	@$(AS) -o $@ $(AFLAGS) $(*).s
+
+all: contiki
+
+contiki: contiki-main.o strncasecmp.o \
+ 	contiki.o programs.o \
+ 	ctk-conio.o ctk.o ek.o dispatcher.o
+
+		@cd arch;$(AS) $(ASFLAGS) -o ../crt0.o gb/crt0.s
+
+		@$(CC) $(CCFLAGS) -S arch/gb/conio.c -o conio.asm
+		@$(AS) $(ASFLAGS) -o conio.o conio.asm
+		@$(CC) $(CCFLAGS) -S arch/gb/_oserror.c -o _oserror.asm
+		@$(AS) $(ASFLAGS) -o _oserror.o _oserror.asm
+		@$(CC) $(CCFLAGS) -S arch/gb/font.c -o font.asm
+		@$(AS) $(ASFLAGS) -o font.o font.asm
+		@$(CC) $(CCFLAGS) -S arch/gb/memmove.c -o memmove.asm
+		@$(AS) $(ASFLAGS) -o memmove.o memmove.asm
+		@$(CC) $(CCFLAGS) -S arch/gb/vsprintf.c -o vsprintf.asm
+		@$(AS) $(ASFLAGS) -o vsprintf.o vsprintf.asm
+		@$(CC) $(CCFLAGS) -S arch/gb/ltostr.c -o ltostr.asm
+		@$(AS) $(ASFLAGS) -o ltostr.o ltostr.asm
+		@$(CC) $(CCFLAGS) -S arch/gb/get_tv.c -o get_tv.asm
+		@$(AS) $(ASFLAGS) -o get_tv.o get_tv.asm
+		@$(CC) $(CCFLAGS) -S arch/none/joytokbd.c -o joytokbd.asm
+		@$(AS) $(ASFLAGS) -o joytokbd.o joytokbd.asm
+
+		@cd arch;$(AS) $(ASFLAGS) -o  ../init_tt.o gb/init_tt.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../set_spr.o gb/set_spr.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../mv_spr.o gb/mv_spr.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../arand.o gb/arand.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../hiramcpy.o gb/hiramcpy.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../cpy_data.o gb/cpy_data.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../delay.o gb/delay.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../joystick.o gb/joystick.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../rand.o gb/rand.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../scroll_b.o gb/scroll_b.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../scroll_s.o gb/scroll_s.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../get_bk_t.o gb/get_bk_t.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../scroll_w.o gb/scroll_w.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../get_data.o gb/get_data.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../serial.o gb/serial.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../get_prop.o gb/get_prop.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../set_bk_t.o gb/set_bk_t.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../set_data.o gb/set_data.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../get_wi_t.o gb/get_wi_t.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../set_prop.o gb/set_prop.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../get_xy_t.o gb/get_xy_t.s
+		@cd arch;$(AS) $(ASFLAGS) -o  ../set_wi_t.o gb/set_wi_t.s
+		@cd arch;$(AS) $(ASFLAGS) -o   ../set_xy_t.o gb/set_xy_t.s
+
+		@cd arch;$(AS) $(ASFLAGS) -o ../fontms.o gb/fontms.s
+		@cd arch;$(AS) $(ASFLAGS) -o ../drawing.o gb/drawing.s
+
+		@$(LD) -- -z contiki.gb \
+			crt0.o \
+ 		   /usr/local/share/sdcc/lib/gbz80/crt0_rle.o \
+			$^ \
+			memmove.o \
+			vsprintf.o \
+			joytokbd.o \
+			_oserror.o \
+		   /usr/local/share/sdcc/lib/gbz80/_strcat.o \
+  		   /usr/local/share/sdcc/lib/gbz80/_strcpy.o \
+  		   /usr/local/share/sdcc/lib/gbz80/_strncpy.o \
+  		   /usr/local/share/sdcc/lib/gbz80/_strncmp.o \
+  		   /usr/local/share/sdcc/lib/gbz80/_strlen.o \
+  		   /usr/local/share/sdcc/lib/gbz80/_memcpy.o \
+  		   /usr/local/share/sdcc/lib/gbz80/_memset.o \
+		   /usr/local/share/sdcc/lib/gbz80/_modslong.o \
+		   /usr/local/share/sdcc/lib/gbz80/_divslong.o \
+		   /usr/local/share/sdcc/lib/gbz80/_modulong.o \
+		   /usr/local/share/sdcc/lib/gbz80/_divulong.o \
+		   /usr/local/share/sdcc/lib/gbz80/_mullong.o \
+		   /usr/local/share/sdcc/lib/gbz80/shift.o \
+		   /usr/local/share/sdcc/lib/gbz80/mul.o \
+		   /usr/local/share/sdcc/lib/gbz80/div.o \
+		   /usr/local/share/sdcc/lib/gbz80/stubs.o \
+			\
+			conio.o \
+			ltostr.o \
+			get_tv.o \
+ 			joystick.o\
+			font.o \
+		init_tt.o\
+		set_spr.o\
+		mv_spr.o\
+		arand.o\
+		hiramcpy.o\
+		cpy_data.o \
+		delay.o \
+		drawing.o\
+		rand.o\
+		scroll_b.o\
+		scroll_s.o\
+		get_bk_t.o \
+		scroll_w.o\
+		get_data.o \
+		serial.o\
+		get_prop.o  \
+		set_bk_t.o\
+		set_data.o\
+		get_wi_t.o \
+		set_prop.o\
+		get_xy_t.o \
+		set_wi_t.o\
+		set_xy_t.o\
+		fontms.o
+
+run:
+	@xgnuboy contiki.gb
+
+clean:
+	@rm -f *.o *~ *core contiki.gb *.s *.asm *.sym *.rel *.lst *.lnk *.map
diff --git a/contiki-gb/README b/contiki-gb/README
new file mode 100644
index 0000000..976716d
--- /dev/null
+++ b/contiki-gb/README
@@ -0,0 +1,25 @@
+This is the Gameboy (Color) port of Contiki, maintained by Groepaz/Hitmen
+<groepaz@gmx.net>.
+
+compiler: sdcc&lcc/gbdk, sdcc.sourceforge.net,	gbdk.sourceforge.net
+
+GB(C) specific stuff is enclosed into #ifdef __GAMEBOY__
+SDCC specific voodoo is enclosed into #ifdef __SDCC__
+
+have a look at arch/gb/SDCC-HACKING for some notes on sdcc-specific problems
+and how to work around them.
+
+- conio library functions work
+- contiki UI halfway works
+TODO: rearrange some code in contiki so sdcc can deal with it. also rewrite
+some stuff that sdcc chokes on in assembler. knock up a cable-wiring-sheme
+and a driver for regular rs232 using the linkport.
+
+Thanx and Acknowledgements must go to:
+
+Joshua (joshua@joshuawise.com, NonToxic @ efnet #gameboy)
+- ported ctk-gbc.c, ctk.c to sucky sdcc (gameboy(color))
+  added some sdcc voodoo to the contiki source :), also
+  helped a lot with general SDCC/GBDK related problems.
+
+have fun, groepaz/hitmen (groepaz@gmx.net)
diff --git a/contiki-gb/conf/cc-conf.h b/contiki-gb/conf/cc-conf.h
new file mode 100644
index 0000000..2897653
--- /dev/null
+++ b/contiki-gb/conf/cc-conf.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * 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. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. 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.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h,v 1.1 2003/05/19 08:21:11 gpz Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+#define CC_CONF_REGISTER_ARGS          0
+#define CC_CONF_FUNCTION_POINTER_ARGS  0
+
+#define CC_CONF_FASTCALL               
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-gb/conf/ctk-conf.h b/contiki-gb/conf/ctk-conf.h
new file mode 100644
index 0000000..40bad80
--- /dev/null
+++ b/contiki-gb/conf/ctk-conf.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * 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. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. 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.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.2 2004/06/27 12:47:44 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F3
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS         1
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS        1
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-gb/conf/ctk-conio-conf.h b/contiki-gb/conf/ctk-conio-conf.h
new file mode 100644
index 0000000..445c1f9
--- /dev/null
+++ b/contiki-gb/conf/ctk-conio-conf.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * 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. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. 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.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio-conf.h,v 1.2 2004/08/12 21:55:16 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_CONF_H__
+#define __CTK_CONIO_CONF_H__
+
+#if 0
+/* Light gray inverted color scheme: */
+#define BORDERCOLOR         COLOR_WHITE
+#define SCREENCOLOR         COLOR_WHITE
+#define BACKGROUNDCOLOR     COLOR_WHITE
+
+#define WINDOWCOLOR_FOCUS   COLOR_BLACK
+#define WINDOWCOLOR         COLOR_GRAY2
+
+#define DIALOGCOLOR         COLOR_RED
+
+#define WIDGETCOLOR_HLINK   COLOR_BLUE
+#define WIDGETCOLOR_FWIN    COLOR_BLACK
+#define WIDGETCOLOR         COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG  COLOR_RED
+#define WIDGETCOLOR_FOCUS   COLOR_BLACK
+
+#define MENUCOLOR           COLOR_BLACK
+#define OPENMENUCOLOR       COLOR_BLACK
+#define ACTIVEMENUITEMCOLOR COLOR_BLACK
+#endif /* 0 */
+
+#if 0
+/* Blue color scheme: */
+#define BORDERCOLOR         COLOR_LIGHTBLUE
+#define SCREENCOLOR         COLOR_BLUE
+#define BACKGROUNDCOLOR     COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTBLUE
+#define WINDOWCOLOR         COLOR_GRAY1
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_CYAN
+#define WIDGETCOLOR_FWIN    COLOR_LIGHTBLUE
+#define WIDGETCOLOR         COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_WHITE
+#define OPENMENUCOLOR       COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 1
+/* Black and white monocrome color scheme: */
+#define BORDERCOLOR         COLOR_BLACK
+#define SCREENCOLOR         COLOR_BLACK
+#define BACKGROUNDCOLOR     COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS   COLOR_WHITE
+#define WINDOWCOLOR         COLOR_WHITE
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_WHITE
+#define WIDGETCOLOR_FWIN    COLOR_WHITE
+#define WIDGETCOLOR         COLOR_WHITE
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_WHITE
+
+#define MENUCOLOR           COLOR_WHITE
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_WHITE
+#endif /* 0 */
+
+#if 0
+/* Blue monocrome color scheme: */
+#define BORDERCOLOR         COLOR_BLUE
+#define SCREENCOLOR         COLOR_BLUE
+#define BACKGROUNDCOLOR     COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTBLUE
+#define WINDOWCOLOR         COLOR_LIGHTBLUE
+
+#define DIALOGCOLOR         COLOR_LIGHTBLUE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_LIGHTBLUE
+#define WIDGETCOLOR         COLOR_LIGHTBLUE
+#define WIDGETCOLOR_DIALOG  COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FOCUS   COLOR_LIGHTBLUE
+
+#define MENUCOLOR           COLOR_LIGHTBLUE
+#define OPENMENUCOLOR       COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_LIGHTBLUE
+#endif /* 0 */
+
+#if 0
+/* Gray color scheme: */
+#define BORDERCOLOR         COLOR_GRAY1
+#define SCREENCOLOR         COLOR_GRAY1
+#define BACKGROUNDCOLOR     COLOR_GRAY1
+
+#define WINDOWCOLOR_FOCUS   COLOR_GRAY3
+#define WINDOWCOLOR         COLOR_GRAY2
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_GRAY3
+#define WIDGETCOLOR         COLOR_GRAY2
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_GRAY3
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 0
+/* Red color scheme: */
+#define BORDERCOLOR         COLOR_BLACK
+#define SCREENCOLOR         COLOR_BLACK
+#define BACKGROUNDCOLOR     COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTRED
+#define WINDOWCOLOR         COLOR_RED
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_YELLOW
+#define WIDGETCOLOR         COLOR_LIGHTRED
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_LIGHTRED
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+
+#endif /* __CTK_CONIO_CONF_H__ */
diff --git a/contiki-gb/conf/ek-conf.h b/contiki-gb/conf/ek-conf.h
new file mode 100644
index 0000000..bab0d23
--- /dev/null
+++ b/contiki-gb/conf/ek-conf.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * 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. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. 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.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h,v 1.1 2003/05/19 08:21:09 gpz Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_signal_t;
+typedef unsigned char ek_id_t;
+
+/* ek_ticks_t: should be defined to be the largest type that fits the
+   highest timeout value used by the system. For example, if all
+   timeouts are between 1 and 150, the ek_ticks_t can be typedef'd as
+   "unsigned char", but if the maximum timeout is over 256, "unsigned
+   short" is a better choise. */
+typedef unsigned short ek_ticks_t;
+
+/* ek_clock_t: should be defined to be the native clock ticks type
+   used by the underlying system. (Look for time_t or similar.) */
+typedef unsigned long ek_clock_t; 
+
+#define EK_CONF_NUMSIGNALS   8    /* Must be 2^n */
+typedef unsigned char ek_num_signals_t;
+
+#define EK_CONF_NUMTIMERS    2    /* Must be 2^n */
+typedef unsigned char ek_num_timers_t;
+
+#define EK_CONF_NUMLISTENERS  8    /* Must be 2^n */
+typedef unsigned char ek_num_listeners_t;
+
+#define EK_CONF_UNLISTEN 0
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-gb/conf/www-conf.h b/contiki-gb/conf/www-conf.h
new file mode 100644
index 0000000..06bca47
--- /dev/null
+++ b/contiki-gb/conf/www-conf.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * 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. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. 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.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h,v 1.1 2003/05/19 08:21:08 gpz Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+/* The size of the HTML viewing area. */
+#define WWW_CONF_WEBPAGE_WIDTH 36
+#define WWW_CONF_WEBPAGE_HEIGHT 17
+
+/* The size of the "Back" history. */
+#define WWW_CONF_HISTORY_SIZE 4
+
+/* Defines the maximum length of an URL */
+#define WWW_CONF_MAX_URLLEN 80
+
+/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+   a page. */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 10
+
+/* Turns <center> support on or off; must be on for forms to work. */
+#define WWW_CONF_RENDERSTATE 1
+
+/* Toggles support for HTML forms. */
+#define WWW_CONF_FORMS       1
+
+/* Maximum lengths for various HTML form parameters. */
+#define WWW_CONF_MAX_FORMACTIONLEN  40
+#define WWW_CONF_MAX_FORMNAMELEN    20
+#define WWW_CONF_MAX_INPUTNAMELEN   20
+#define WWW_CONF_MAX_INPUTVALUELEN  34
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-gb/contiki-main.c b/contiki-gb/contiki-main.c
new file mode 100644
index 0000000..4570644
--- /dev/null
+++ b/contiki-gb/contiki-main.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * 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. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. 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.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: contiki-main.c,v 1.1 2003/05/19 08:21:02 gpz Exp $
+ *
+ */
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "dispatcher.h"
+
+#include "simpletelnet.h"
+#include "programs.h"
+#include "email.h"
+#include "www.h"
+#include "contiki.h"
+
+#include "uip_main.h"
+#include "uip.h"
+#include "uip_arp.h"
+#if WITH_TFE
+#include "cs8900a.h"
+#endif /* WITH_TFE */
+#include "resolv.h"
+
+#include <time.h>
+#include <stdio.h>
+#include <conio.h>
+//#include <rs232.h>
+#include <time.h>
+#include <string.h>
+
+
+/*-----------------------------------------------------------------------------------*/
+int
+main(int argc, char **argv)
+{
+  /*  irqload_init();*/
+
+#ifdef WITH_UIP
+  uip_init();
+  uip_main_init();
+  resolv_init();
+
+#ifdef WITH_TFE
+  cs8900a_init();
+#endif /* WITH_TFE */
+
+  
+#ifdef WITH_RS232
+  rs232dev_init();
+#endif /* WITH_RS232 */
+  
+#ifdef WITH_TAPDEV
+  tapdev_init();
+#endif /* WITH_TAPDEV */
+
+
+#endif /* WITH_UIP */
+
+
+  conio_init();
+#if 0
+{
+ int i,j;
+ clrscr();
+ textcolor(0);bgcolor(1);
+ while(1)
+ {
+	gotoxy(0,0);
+	cprintf("%d\n\r",i++);
+	//conio_update();
+
+ 	if(kbhit())
+	{
+		cprintf("       ");
+	    cprintf("%02x",cgetc());
+		cprintf("\n\r");
+	}
+	else
+	{
+		cprintf("pressed: ---------\n\r");
+	}
+
+	j=joy_read(0);
+	cprintf("%08x\n\r",j);
+ }
+}
+#endif
+
+  ek_init();
+  dispatcher_init();
+  ctk_init();
+
+  contiki_init();
+
+  programs_init();
+
+  ctk_redraw();
+  ek_run();
+
+  clrscr();
+
+  return 0;
+
+  argv = argv;
+  argc = argc;
+}
+/*-----------------------------------------------------------------------------------*/
+
+//#include "gb.c"
diff --git a/contiki-gb/ctk/ctk-arch.h b/contiki-gb/ctk/ctk-arch.h
new file mode 100644
index 0000000..3a7c20b
--- /dev/null
+++ b/contiki-gb/ctk/ctk-arch.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * 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. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. 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.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-arch.h,v 1.1 2003/05/19 08:21:04 gpz Exp $
+ *
+ */
+#ifndef __CTK_ARCH_H__
+#define __CTK_ARCH_H__
+
+#include "gb.h"
+#include "ctk-conio.h"
+
+#endif /* __CTK_ARCH_H__ */
diff --git a/contiki-gb/uip/uip_arch.c b/contiki-gb/uip/uip_arch.c
new file mode 100644
index 0000000..50cd7f7
--- /dev/null
+++ b/contiki-gb/uip/uip_arch.c
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * 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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. 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.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.c,v 1.3 2005/02/24 22:05:24 oliverschmidt Exp $
+ *
+ */
+
+
+#include "uip.h"
+#include "uip_arch.h"
+
+#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define IP_PROTO_TCP    6
+
+/*-----------------------------------------------------------------------------------*/
+void
+uip_add_rcv_nxt(u16_t n)
+{
+  uip_conn->rcv_nxt[3] += (n & 0xff);
+  uip_conn->rcv_nxt[2] += (n >> 8);
+
+  if(uip_conn->rcv_nxt[2] < (n >> 8)) {
+    ++uip_conn->rcv_nxt[1];    
+    if(uip_conn->rcv_nxt[1] == 0) {
+      ++uip_conn->rcv_nxt[0];
+    }
+  }
+  
+  
+  if(uip_conn->rcv_nxt[3] < (n & 0xff)) {
+    ++uip_conn->rcv_nxt[2];  
+    if(uip_conn->rcv_nxt[2] == 0) {
+      ++uip_conn->rcv_nxt[1];    
+      if(uip_conn->rcv_nxt[1] == 0) {
+	++uip_conn->rcv_nxt[0];
+      }
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+uip_add32(u8_t *op32, u16_t op16)
+{
+  
+  uip_acc32[3] = op32[3] + (op16 & 0xff);
+  uip_acc32[2] = op32[2] + (op16 >> 8);
+  uip_acc32[1] = op32[1];
+  uip_acc32[0] = op32[0];
+  
+  if(uip_acc32[2] < (op16 >> 8)) {
+    ++uip_acc32[1];    
+    if(uip_acc32[1] == 0) {
+      ++uip_acc32[0];
+    }
+  }
+  
+  
+  if(uip_acc32[3] < (op16 & 0xff)) {
+    ++uip_acc32[2];  
+    if(uip_acc32[2] == 0) {
+      ++uip_acc32[1];    
+      if(uip_acc32[1] == 0) {
+	++uip_acc32[0];
+      }
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_chksum(u16_t *sdata, u16_t len)
+{
+  u16_t acc;
+  
+  for(acc = 0; len > 1; len -= 2) {
+    acc += *sdata;
+    if(acc < *sdata) {
+      /* Overflow, so we add the carry to acc (i.e., increase by
+         one). */
+      ++acc;
+    }
+    ++sdata;
+  }
+
+  /* add up any odd byte */
+  if(len == 1) {
+    acc += htons(((u16_t)(*(u8_t *)sdata)) << 8);
+    if(acc < htons(((u16_t)(*(u8_t *)sdata)) << 8)) {
+      ++acc;
+    }
+  }
+
+  return acc;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_ipchksum(void)
+{
+  return uip_chksum((u16_t *)&uip_buf[UIP_LLH_LEN], UIP_IPH_LEN);
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_tcpchksum(void)
+{
+  u16_t hsum, sum;
+
+  
+  /* Compute the checksum of the TCP header. */
+  hsum = uip_chksum((u16_t *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN], UIP_TCPH_LEN);
+
+  /* Compute the checksum of the data in the TCP packet and add it to
+     the TCP header checksum. */
+  sum = uip_chksum((u16_t *)uip_appdata,
+		   (u16_t)(((((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) -
+		   UIP_IPTCPH_LEN)));
+
+  if((sum += hsum) < hsum) {
+    ++sum;
+  }
+  
+  if((sum += BUF->srcipaddr[0]) < BUF->srcipaddr[0]) {
+    ++sum;
+  }
+  if((sum += BUF->srcipaddr[1]) < BUF->srcipaddr[1]) {
+    ++sum;
+  }
+  if((sum += BUF->destipaddr[0]) < BUF->destipaddr[0]) {
+    ++sum;
+  }
+  if((sum += BUF->destipaddr[1]) < BUF->destipaddr[1]) {
+    ++sum;
+  }
+  if((sum += (u16_t)htons((u16_t)IP_PROTO_TCP)) < (u16_t)htons((u16_t)IP_PROTO_TCP)) {
+    ++sum;
+  }
+
+  hsum = (u16_t)HTONS((((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - UIP_IPH_LEN);
+  
+  if((sum += hsum) < hsum) {
+    ++sum;
+  }
+  
+  return sum;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-gb/uip/uip_arch.h b/contiki-gb/uip/uip_arch.h
new file mode 100644
index 0000000..8c5349a
--- /dev/null
+++ b/contiki-gb/uip/uip_arch.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * 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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. 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.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.h,v 1.2 2005/01/26 23:36:36 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __UIP_ARCH_H__
+#define __UIP_ARCH_H__
+
+#include "uip.h"
+
+void uip_add_rcv_nxt(u16_t n);
+void uip_add32(u8_t *op32, u16_t op16);
+u16_t uip_chksum(u16_t *data, u16_t len);
+u16_t uip_ipchksum(void);
+u16_t uip_tcpchksum(void);
+
+#endif /* __UIP_ARCH_H__ */