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;
+}
+
+
