Index: uspace/app/msim/Makefile
===================================================================
--- uspace/app/msim/Makefile	(revision 7360332f26ff1db94b63b154f3f1c37492dc8dd1)
+++ uspace/app/msim/Makefile	(revision 6efb4d2ae69379d91c4fccc34083faf72518fd07)
@@ -36,10 +36,14 @@
 
 MSIM_HELENOS_MAKEFILE = Makefile.msim.src
-MSIM_HELENOS_PLATFORM_FILES = helenos.c helenos_input.c
+MSIM_HELENOS_PLATFORM_FILES = misc.c input.c
+MSIM_HELENOS_ARCH_DIR = arch/helenos
 MSIM_PATCHED_FILES = \
 	$(MSIM_DIST)/config.h \
 	$(MSIM_DIST)/src/$(MSIM_HELENOS_MAKEFILE) \
-	$(MSIM_DIST)/src/helenos.c \
-	$(MSIM_DIST)/src/helenos_input.c
+	$(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)/helenos.h \
+	$(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)/misc.c \
+	$(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)/input.c
+
+MSIM_EXTRA_SOURCES := $(addprefix $(MSIM_HELENOS_ARCH_DIR)/,$(MSIM_HELENOS_PLATFORM_FILES))
 
 CP = /bin/cp -f
@@ -63,8 +67,11 @@
 	$(CP) $< $@
 
-$(MSIM_DIST)/src/helenos.c: helenos.c | unpack-tarball
+$(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)/helenos.h: arch_helenos/helenos.h | unpack-tarball
 	$(CP) $< $@
 
-$(MSIM_DIST)/src/helenos_input.c: helenos_input.c | unpack-tarball
+$(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)/misc.c: arch_helenos/misc.c | unpack-tarball
+	$(CP) $< $@
+
+$(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)/input.c: arch_helenos/input.c | unpack-tarball
 	$(CP) $< $@
 
@@ -79,5 +86,5 @@
 	) | make -f - | grep 'SOURCES' >Makefile.sources
 	sed \
-		-e 's:io/input.c:$(MSIM_HELENOS_PLATFORM_FILES):' \
+		-e 's:io/input.c:$(MSIM_EXTRA_SOURCES):' \
 		-e 's:debug/gdb.c::' \
 		-e 's:arch/posix/stdin.c::' \
@@ -90,2 +97,3 @@
 unpack-tarball: $(MSIM_TARBALL)
 	tar xjf $(MSIM_TARBALL)
+	mkdir -p $(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)
Index: uspace/app/msim/arch_helenos/helenos.h
===================================================================
--- uspace/app/msim/arch_helenos/helenos.h	(revision 6efb4d2ae69379d91c4fccc34083faf72518fd07)
+++ uspace/app/msim/arch_helenos/helenos.h	(revision 6efb4d2ae69379d91c4fccc34083faf72518fd07)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012 Vojtech Horky
+ * 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 msim
+ * @{
+ */
+
+#ifndef MSIM_HELENOS_H_
+#define MSIM_HELENOS_H_
+
+char *helenos_input_get_next_command(void);
+void helenos_dprinter_init(void);
+
+#endif
+
+/**
+ * @}
+ */
+
Index: uspace/app/msim/arch_helenos/input.c
===================================================================
--- uspace/app/msim/arch_helenos/input.c	(revision 6efb4d2ae69379d91c4fccc34083faf72518fd07)
+++ uspace/app/msim/arch_helenos/input.c	(revision 6efb4d2ae69379d91c4fccc34083faf72518fd07)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2012 Vojtech Horky
+ * 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 msim
+ * @{
+ */
+/** @file HelenOS specific functions for MSIM simulator.
+ */
+#include "../../io/input.h"
+#include "../../io/output.h"
+#include "../../fault.h"
+#include "helenos.h"
+#include <tinput.h>
+#include <errno.h>
+
+static tinput_t *input_prompt;
+
+/** Terminal and readline initialization
+ *
+ */
+void input_init(void)
+{
+	input_prompt = tinput_new();
+	if (input_prompt == NULL) {
+		die(1, "Failed to intialize input.");
+	}
+	helenos_dprinter_init();
+}
+
+void input_inter(void)
+{
+}
+
+void input_shadow( void)
+{
+}
+
+void input_back( void)
+{
+}
+
+char *helenos_input_get_next_command(void)
+{
+	tinput_set_prompt(input_prompt, "[msim] ");
+
+	char *commline = NULL;
+	int rc = tinput_read(input_prompt, &commline);
+
+	if (rc == ENOENT) {
+		rc = asprintf(&commline, "quit");
+		mprintf("Quit\n");
+		if (rc != EOK) {
+			exit(1);
+		}
+	}
+
+	/* On error, it remains NULL. */
+	return commline;
+}
+
+
+bool stdin_poll(char *key)
+{
+	kbd_event_t ev;
+	suseconds_t timeout = 0;
+	errno = EOK;
+	console_flush(input_prompt->console);
+	bool has_input = console_get_kbd_event_timeout(input_prompt->console, &ev, &timeout);
+	if (!has_input) {
+		return false;
+	}
+
+	if (ev.type != KEY_PRESS)
+		return false;
+
+	*key = ev.c;
+
+	return true;
+}
+
Index: uspace/app/msim/arch_helenos/misc.c
===================================================================
--- uspace/app/msim/arch_helenos/misc.c	(revision 6efb4d2ae69379d91c4fccc34083faf72518fd07)
+++ uspace/app/msim/arch_helenos/misc.c	(revision 6efb4d2ae69379d91c4fccc34083faf72518fd07)
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2012 Vojtech Horky
+ * 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 msim
+ * @{
+ */
+/** @file HelenOS specific functions for MSIM simulator.
+ */
+#include "../../io/input.h"
+#include "../../io/output.h"
+#include "../../device/dprinter.h"
+#include "../../debug/gdb.h"
+#include "../../cmd.h"
+#include "../../fault.h"
+#include "../../device/machine.h"
+#include "helenos.h"
+#include <str.h>
+#include <malloc.h>
+#include <ctype.h>
+#include <stdio.h>
+
+/* Define when the dprinter device shall try to filter
+ * out ANSI escape sequences.
+ */
+#define IGNORE_ANSI_ESCAPE_SEQUENCES
+/* Define when you want the ANSI escape sequences to be dumped as
+ * hex numbers.
+ */
+// #define DUMP_ANSI_ESCAPE_SEQUENCES
+
+void interactive_control(void)
+{
+	tobreak = false;
+
+	if (reenter) {
+		mprintf("\n");
+		reenter = false;
+	}
+
+	stepping = 0;
+
+	while (interactive) {
+		char *commline = helenos_input_get_next_command();
+		if (commline == NULL) {
+			mprintf("Quit\n");
+			input_back();
+			exit(1);
+		}
+
+		/* Check for empty input. */
+		if (str_cmp(commline, "") == 0) {
+			interpret("step");
+		} else {
+			interpret(commline);
+		}
+
+		free(commline);
+	}
+}
+
+bool gdb_remote_init(void)
+{
+	return false;
+}
+
+void gdb_session(void)
+{
+}
+
+void gdb_handle_event(gdb_event_t event)
+{
+}
+
+
+static void (*original_printer_write)(cpu_t *, device_s *, ptr_t, uint32_t);
+static void helenos_printer_write(cpu_t *cpu, device_s *dev, ptr_t addr, uint32_t val)
+{
+#ifdef IGNORE_ANSI_ESCAPE_SEQUENCES
+	static bool inside_ansi_escape = false;
+	static bool just_ended_ansi_escape = false;
+
+	if (inside_ansi_escape) {
+#ifdef DUMP_ANSI_ESCAPE_SEQUENCES
+		fprintf(stderr, "%02" PRIx32 "'%c' ", val, val >= 32 ? val : '?');
+#endif
+		if (isalpha((int) val)) {
+			just_ended_ansi_escape = true;
+			inside_ansi_escape = false;
+#ifdef DUMP_ANSI_ESCAPE_SEQUENCES
+			fprintf(stderr, " [END]\n");
+#endif
+		}
+
+		return;
+	}
+
+	if (val == 0x1B) {
+		inside_ansi_escape = true;
+
+		if (!just_ended_ansi_escape) {
+#ifdef DUMP_ANSI_ESCAPE_SEQUENCES
+			fprintf(stderr, "\n");
+#endif
+		}
+#ifdef DUMP_ANSI_ESCAPE_SEQUENCES
+		fprintf(stderr, "ESC sequence: ");
+#endif
+
+		return;
+	}
+
+	just_ended_ansi_escape = false;
+#endif
+
+	(*original_printer_write)(cpu, dev, addr, val);
+}
+
+void helenos_dprinter_init(void)
+{
+	original_printer_write = dprinter.write;
+	dprinter.write = helenos_printer_write;
+}
+
+
Index: uspace/app/msim/helenos.c
===================================================================
--- uspace/app/msim/helenos.c	(revision 7360332f26ff1db94b63b154f3f1c37492dc8dd1)
+++ 	(revision )
@@ -1,152 +1,0 @@
-/*
- * Copyright (c) 2012 Vojtech Horky
- * 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 msim
- * @{
- */
-/** @file HelenOS specific functions for MSIM simulator.
- */
-#include "io/input.h"
-#include "io/output.h"
-#include "device/dprinter.h"
-#include "debug/gdb.h"
-#include "cmd.h"
-#include "fault.h"
-#include "device/machine.h"
-#include <str.h>
-#include <malloc.h>
-#include <ctype.h>
-#include <stdio.h>
-
-/* Define when the dprinter device shall try to filter
- * out ANSI escape sequences.
- */
-#define IGNORE_ANSI_ESCAPE_SEQUENCES
-/* Define when you want the ANSI escape sequences to be dumped as
- * hex numbers.
- */
-// #define DUMP_ANSI_ESCAPE_SEQUENCES
-
-extern char *input_helenos_get_next_command(void);
-
-void interactive_control(void)
-{
-	tobreak = false;
-
-	if (reenter) {
-		mprintf("\n");
-		reenter = false;
-	}
-
-	stepping = 0;
-
-	while (interactive) {
-		char *commline = input_helenos_get_next_command();
-		if (commline == NULL) {
-			mprintf("Quit\n");
-			input_back();
-			exit(1);
-		}
-
-		/* Check for empty input. */
-		if (str_cmp(commline, "") == 0) {
-			interpret("step");
-		} else {
-			interpret(commline);
-		}
-
-		free(commline);
-	}
-}
-
-bool gdb_remote_init(void)
-{
-	return false;
-}
-
-void gdb_session(void)
-{
-}
-
-void gdb_handle_event(gdb_event_t event)
-{
-}
-
-
-char *input_helenos_get_next_command(void);
-
-static void (*original_printer_write)(cpu_t *, device_s *, ptr_t, uint32_t);
-static void helenos_printer_write(cpu_t *cpu, device_s *dev, ptr_t addr, uint32_t val)
-{
-#ifdef IGNORE_ANSI_ESCAPE_SEQUENCES
-	static bool inside_ansi_escape = false;
-	static bool just_ended_ansi_escape = false;
-
-	if (inside_ansi_escape) {
-#ifdef DUMP_ANSI_ESCAPE_SEQUENCES
-		fprintf(stderr, "%02" PRIx32 "'%c' ", val, val >= 32 ? val : '?');
-#endif
-		if (isalpha((int) val)) {
-			just_ended_ansi_escape = true;
-			inside_ansi_escape = false;
-#ifdef DUMP_ANSI_ESCAPE_SEQUENCES
-			fprintf(stderr, " [END]\n");
-#endif
-		}
-
-		return;
-	}
-
-	if (val == 0x1B) {
-		inside_ansi_escape = true;
-
-		if (!just_ended_ansi_escape) {
-#ifdef DUMP_ANSI_ESCAPE_SEQUENCES
-			fprintf(stderr, "\n");
-#endif
-		}
-#ifdef DUMP_ANSI_ESCAPE_SEQUENCES
-		fprintf(stderr, "ESC sequence: ");
-#endif
-
-		return;
-	}
-
-	just_ended_ansi_escape = false;
-#endif
-
-	(*original_printer_write)(cpu, dev, addr, val);
-}
-
-void helenos_dprinter_init(void)
-{
-	original_printer_write = dprinter.write;
-	dprinter.write = helenos_printer_write;
-}
-
-
Index: uspace/app/msim/helenos_input.c
===================================================================
--- uspace/app/msim/helenos_input.c	(revision 7360332f26ff1db94b63b154f3f1c37492dc8dd1)
+++ 	(revision )
@@ -1,107 +1,0 @@
-/*
- * Copyright (c) 2012 Vojtech Horky
- * 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 msim
- * @{
- */
-/** @file HelenOS specific functions for MSIM simulator.
- */
-#include "io/input.h"
-#include "io/output.h"
-#include "fault.h"
-#include <tinput.h>
-#include <errno.h>
-
-static tinput_t *input_prompt;
-
-char *input_helenos_get_next_command(void);
-void helenos_dprinter_init(void);
-
-/** Terminal and readline initialization
- *
- */
-void input_init(void)
-{
-	input_prompt = tinput_new();
-	if (input_prompt == NULL) {
-		die(1, "Failed to intialize input.");
-	}
-	helenos_dprinter_init();
-}
-
-void input_inter(void)
-{
-}
-
-void input_shadow( void)
-{
-}
-
-void input_back( void)
-{
-}
-
-char *input_helenos_get_next_command(void)
-{
-	tinput_set_prompt(input_prompt, "[msim] ");
-
-	char *commline = NULL;
-	int rc = tinput_read(input_prompt, &commline);
-
-	if (rc == ENOENT) {
-		rc = asprintf(&commline, "quit");
-		mprintf("Quit\n");
-		if (rc != EOK) {
-			exit(1);
-		}
-	}
-
-	/* On error, it remains NULL. */
-	return commline;
-}
-
-
-bool stdin_poll(char *key)
-{
-	kbd_event_t ev;
-	suseconds_t timeout = 0;
-	errno = EOK;
-	console_flush(input_prompt->console);
-	bool has_input = console_get_kbd_event_timeout(input_prompt->console, &ev, &timeout);
-	if (!has_input) {
-		return false;
-	}
-
-	if (ev.type != KEY_PRESS)
-		return false;
-
-	*key = ev.c;
-
-	return true;
-}
-
