Index: kernel/generic/include/arch.h
===================================================================
--- kernel/generic/include/arch.h	(revision 72bcb25fd2166818d63b580efcafdf265183c0c8)
+++ kernel/generic/include/arch.h	(revision f74bbaf20e8d8be55495c56affc5b17ef6ea2bf0)
@@ -75,5 +75,9 @@
 extern void arch_pre_smp_init(void);
 extern void arch_post_smp_init(void);
+
 extern void calibrate_delay_loop(void);
+
+extern void reboot(void);
+extern void arch_reboot(void);
 
 #endif
Index: kernel/generic/include/proc/task.h
===================================================================
--- kernel/generic/include/proc/task.h	(revision 72bcb25fd2166818d63b580efcafdf265183c0c8)
+++ kernel/generic/include/proc/task.h	(revision f74bbaf20e8d8be55495c56affc5b17ef6ea2bf0)
@@ -112,4 +112,5 @@
 
 extern void task_init(void);
+extern void task_done(void);
 extern task_t *task_create(as_t *as, char *name);
 extern void task_destroy(task_t *t);
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 72bcb25fd2166818d63b580efcafdf265183c0c8)
+++ kernel/generic/src/console/cmd.c	(revision f74bbaf20e8d8be55495c56affc5b17ef6ea2bf0)
@@ -49,4 +49,5 @@
 #include <adt/list.h>
 #include <arch.h>
+#include <config.h>
 #include <func.h>
 #include <macros.h>
@@ -80,5 +81,13 @@
 static cmd_info_t exit_info = {
 	.name = "exit",
-	.description = "Exit kconsole",
+	.description = "Exit kconsole.",
+	.argc = 0
+};
+
+static int cmd_reboot(cmd_arg_t *argv);
+static cmd_info_t reboot_info = {
+	.name = "reboot",
+	.description = "Reboot.",
+	.func = cmd_reboot,
 	.argc = 0
 };
@@ -430,4 +439,5 @@
 	&desc_info,
 	&exit_info,
+	&reboot_info,
 	&halt_info,
 	&help_info,
@@ -505,4 +515,19 @@
 }
 
+
+/** Reboot the system.
+ *
+ * @param argv Argument vector.
+ *
+ * @return 0 on failure, 1 on success.
+ */
+int cmd_reboot(cmd_arg_t *argv)
+{
+	reboot();
+	
+	/* Not reached */
+	return 1;
+}
+
 /** Describe specified command.
  *
Index: kernel/generic/src/main/shutdown.c
===================================================================
--- kernel/generic/src/main/shutdown.c	(revision f74bbaf20e8d8be55495c56affc5b17ef6ea2bf0)
+++ kernel/generic/src/main/shutdown.c	(revision f74bbaf20e8d8be55495c56affc5b17ef6ea2bf0)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - 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.
+ */
+
+/** @addtogroup main
+ * @{
+ */
+
+/**
+ * @file
+ * @brief 	Shutdown procedures.
+ */
+
+#include <arch.h>
+#include <print.h>
+
+void reboot(void)
+{
+	task_done();
+	
+#ifdef CONFIG_DEBUG
+	printf("Rebooting the system\n");
+#endif
+	
+	arch_reboot();
+}
+
+/** @}
+ */
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 72bcb25fd2166818d63b580efcafdf265183c0c8)
+++ kernel/generic/src/proc/task.c	(revision f74bbaf20e8d8be55495c56affc5b17ef6ea2bf0)
@@ -94,4 +94,47 @@
 }
 
+/** Kill all tasks except the current task.
+ *
+ */
+void task_done(void)
+{
+	task_t *t;
+	do { /* Repeat until there are any tasks except TASK */
+		
+		/* Messing with task structures, avoid deadlock */
+		ipl_t ipl = interrupts_disable();
+		spinlock_lock(&tasks_lock);
+		
+		t = NULL;
+		link_t *cur;
+		for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) {
+			btree_node_t *node = list_get_instance(cur, btree_node_t, leaf_link);
+			
+			unsigned int i;
+			for (i = 0; i < node->keys; i++) {
+				if ((task_t *) node->value[i] != TASK) {
+					t = (task_t *) node->value[i];
+					break;
+				}
+			}
+		}
+		
+		if (t != NULL) {
+			task_id_t id = t->taskid;
+			
+			spinlock_unlock(&tasks_lock);
+			interrupts_restore(ipl);
+			
+#ifdef CONFIG_DEBUG
+			printf("Killing task %llu\n", id);
+#endif			
+			task_kill(id);
+		} else {
+			spinlock_unlock(&tasks_lock);
+			interrupts_restore(ipl);
+		}
+		
+	} while (t != NULL);
+}
 
 /** Create new task
@@ -374,5 +417,5 @@
 	ipl_t ipl;
 	
-	/* Messing with thread structures, avoid deadlock */
+	/* Messing with task structures, avoid deadlock */
 	ipl = interrupts_disable();
 	spinlock_lock(&tasks_lock);
