diff --git a/cpu/6502/6502def.h b/cpu/6502/6502def.h
index cda11b72f..656ce4a30 100644
--- a/cpu/6502/6502def.h
+++ b/cpu/6502/6502def.h
@@ -30,7 +30,7 @@
*
* Author: Oliver Schmidt
*
- * @(#)$Id: 6502def.h,v 1.19 2010/01/30 20:54:15 oliverschmidt Exp $
+ * @(#)$Id: 6502def.h,v 1.20 2010/02/04 23:52:30 oliverschmidt Exp $
*/
#ifndef __6502DEF_H__
@@ -66,6 +66,8 @@ typedef unsigned short uip_stats_t;
#define UIP_ARCH_ADD32 1
#define UIP_ARCH_CHKSUM 1
+#define LOADER_CONF_ARCH "lib/unload.h"
+
#if WITH_LOGGING
#define LOG_CONF_ENABLED 1
#define UIP_CONF_LOGGING 1
diff --git a/cpu/6502/Makefile.6502 b/cpu/6502/Makefile.6502
index eedea4e2c..44e7d1626 100644
--- a/cpu/6502/Makefile.6502
+++ b/cpu/6502/Makefile.6502
@@ -30,7 +30,7 @@
#
# Author: Oliver Schmidt
#
-# $Id: Makefile.6502,v 1.30 2009/10/18 11:34:38 oliverschmidt Exp $
+# $Id: Makefile.6502,v 1.31 2010/02/04 23:52:30 oliverschmidt Exp $
#
ifndef CC65_HOME
@@ -43,8 +43,8 @@ CONTIKI_TARGET_DIRS = . lib sys
CONTIKI_CPU_DIRS = . lib sys ctk net
CONTIKI_TARGET_SOURCEFILES = contiki-main.c
-CONTIKI_CPU_SOURCEFILES = log.c error.c config.c clock.c ctk-mouse.c \
- mtarch.c mtarch-asm.S lc-asm.S \
+CONTIKI_CPU_SOURCEFILES = log.c error.c unload.c config.c ctk-mouse.c \
+ clock.c mtarch.c mtarch-asm.S lc-asm.S \
uip_arch.c ethernet-drv.c ethernet.c
CONTIKI_SOURCEFILES += $(CTK) ctk-conio.c petsciiconv.c cfs-posix-dir.c \
diff --git a/cpu/6502/lib/unload.c b/cpu/6502/lib/unload.c
new file mode 100644
index 000000000..6e065e60f
--- /dev/null
+++ b/cpu/6502/lib/unload.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010, Swedish Institute of Computer Science.
+ * 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. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``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 INSTITUTE OR CONTRIBUTORS 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 operating system.
+ *
+ * Author: Oliver Schmidt
+ *
+ * $Id: unload.c,v 1.1 2010/02/04 23:52:30 oliverschmidt Exp $
+ */
+
+#include
+
+#include "ctk/ctk-draw.h"
+
+/*-----------------------------------------------------------------------------------*/
+void
+unload(void)
+{
+#if WITH_GUI
+ ctk_draw_init();
+#endif /* WITH_GUI */
+ exit(EXIT_SUCCESS);
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/cpu/6502/lib/unload.h b/cpu/6502/lib/unload.h
new file mode 100644
index 000000000..eac121013
--- /dev/null
+++ b/cpu/6502/lib/unload.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, Swedish Institute of Computer Science.
+ * 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. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``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 INSTITUTE OR CONTRIBUTORS 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 operating system.
+ *
+ * Author: Oliver Schmidt
+ *
+ * $Id: unload.h,v 1.1 2010/02/04 23:52:30 oliverschmidt Exp $
+ */
+
+#ifndef __UNLOAD_H__
+#define __UNLOAD_H__
+
+#define LOADER_UNLOAD unload
+
+void unload(void);
+
+#endif /* __UNLOAD_H__ */