Index: console/console.c
===================================================================
--- console/console.c	(revision c1d2c9dd2e8ed998a195ce76e6c2cb87a660d0d7)
+++ console/console.c	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
@@ -116,8 +116,9 @@
 			
 			conn = &connections[active_console];
-			if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) {
+//			if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) {
+			if ((c >= '1') && (c < '1' + CONSOLE_COUNT)) {
 				/*FIXME: draw another console content from buffer */
 
-				active_console = c - KBD_KEY_F1;
+				active_console = c - '1';
 				conn = &connections[active_console];
 
@@ -232,4 +233,6 @@
 	ipcarg_t retval, arg1 = 0xdead, arg2 = 0xbeef;
 	int i;
+
+	async_set_client_connection(client_connection);
 	
 	/* Connect to keyboard driver */
Index: fb/Makefile
===================================================================
--- fb/Makefile	(revision c1d2c9dd2e8ed998a195ce76e6c2cb87a660d0d7)
+++ fb/Makefile	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
@@ -47,5 +47,7 @@
 SOURCES = \
 	fb.c \
-	font-8x16.c
+	font-8x16.c \
+	main.c \
+	sysio.c
 
 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
Index: fb/fb.c
===================================================================
--- fb/fb.c	(revision c1d2c9dd2e8ed998a195ce76e6c2cb87a660d0d7)
+++ fb/fb.c	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
@@ -28,10 +28,8 @@
  */
 
-#include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
 #include <ddi.h>
-#include <task.h>
 #include <sysinfo.h>
 #include <align.h>
@@ -390,34 +388,4 @@
 }
 
-static int init_fb(void)
-{
-	__address fb_ph_addr;
-	unsigned int fb_width;
-	unsigned int fb_height;
-	unsigned int fb_bpp;
-	unsigned int fb_scanline;
-	__address fb_addr;
-	int a=0;
-	int i,j,k;
-	int w;
-	char text[]="HelenOS Framebuffer driver\non Virtual Framebuffer\nVFB ";
-
-	fb_ph_addr=sysinfo_value("fb.address.physical");
-	fb_width=sysinfo_value("fb.width");
-	fb_height=sysinfo_value("fb.height");
-	fb_bpp=sysinfo_value("fb.bpp");
-	fb_scanline=sysinfo_value("fb.scanline");
-
-	fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE);
-	
-	map_physmem(task_get_id(),(void *)((__address)fb_ph_addr),(void *)fb_addr,
-		    (fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH,
-		    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
-	
-	screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline);
-
-	return 0;
-}
-
 static void draw_char(int vp, char c, unsigned int row, unsigned int col)
 {
@@ -443,5 +411,5 @@
 }
 
-void client_connection(ipc_callid_t iid, ipc_call_t *icall)
+static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall)
 {
 	ipc_callid_t callid;
@@ -578,21 +546,30 @@
 }
 
-int main(int argc, char *argv[])
-{
-	char connected = 0;
-	int res;
-	ipcarg_t phonead;
-
-	if(!sysinfo_value("fb"))
-		return -1;
-
-	if ((res = ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, &phonead)) != 0) 
-		return -1;
-	
-	if (init_fb() != 0)
-		return -1;
-
-	async_manager();
-	/* Never reached */
+int fb_init(void)
+{
+	__address fb_ph_addr;
+	unsigned int fb_width;
+	unsigned int fb_height;
+	unsigned int fb_bpp;
+	unsigned int fb_scanline;
+	__address fb_addr;
+
+	async_set_client_connection(fb_client_connection);
+
+	fb_ph_addr=sysinfo_value("fb.address.physical");
+	fb_width=sysinfo_value("fb.width");
+	fb_height=sysinfo_value("fb.height");
+	fb_bpp=sysinfo_value("fb.bpp");
+	fb_scanline=sysinfo_value("fb.scanline");
+
+	fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE);
+	
+	map_physmem(task_get_id(),(void *)((__address)fb_ph_addr),(void *)fb_addr,
+		    (fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH,
+		    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
+	
+	screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline);
+
 	return 0;
 }
+
Index: fb/fb.h
===================================================================
--- fb/fb.h	(revision c1d2c9dd2e8ed998a195ce76e6c2cb87a660d0d7)
+++ fb/fb.h	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
@@ -30,6 +30,5 @@
 #define _FB_H_
 
-#include <types.h>
-#include <arch/types.h>
+int fb_init(void);
 
 #endif
Index: fb/main.c
===================================================================
--- fb/main.c	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
+++ fb/main.c	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2006 Ondrej Palkovsky
+ * 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.
+ */
+
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+#include <sysinfo.h>
+#include <async.h>
+
+#include "fb.h"
+#include "sysio.h"
+
+int main(int argc, char *argv[])
+{
+	ipcarg_t phonead;
+	int initialized = 0;
+
+	if (sysinfo_value("fb.kind") == 1) {
+		if (fb_init() == 0)
+			initialized = 1;
+	}
+	if (!initialized)
+		sysio_init();
+
+	if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, &phonead) != 0) 
+		return -1;
+	
+	async_manager();
+	/* Never reached */
+	return 0;
+}
Index: fb/sysio.c
===================================================================
--- fb/sysio.c	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
+++ fb/sysio.c	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2006 Ondrej Palkovsky
+ * 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.
+ */
+
+#include <async.h>
+#include <ipc/fb.h>
+#include <ipc/ipc.h>
+#include <libc.h>
+#include <errno.h>
+
+#include "sysio.h"
+
+/* Allow only 1 connection */
+static int client_connected = 0;
+
+static void sysput(char c)
+{
+	__SYSCALL3(SYS_IO, 1, (sysarg_t)&c, (sysarg_t) 1);
+}
+
+static void sysio_client_connection(ipc_callid_t iid, ipc_call_t *icall)
+{
+	int retval;
+	ipc_callid_t callid;
+	ipc_call_t call;
+	char c;
+
+	if (client_connected) {
+		ipc_answer_fast(iid, ELIMIT, 0,0);
+		return;
+	}
+	client_connected = 1;
+	ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */
+	while (1) {
+		callid = async_get_call(&call);
+ 		switch (IPC_GET_METHOD(call)) {
+		case IPC_M_PHONE_HUNGUP:
+			client_connected = 0;
+			ipc_answer_fast(callid,0,0,0);
+			return; /* Exit thread */
+		case FB_PUTCHAR:
+			c = IPC_GET_ARG1(call);
+			sysput(c);
+			retval = 0;
+			break;
+		case FB_GET_CSIZE:
+			ipc_answer_fast(callid, 0, 25, 80);
+			continue;
+		default:
+			retval = ENOENT;
+		}
+		ipc_answer_fast(callid,retval,0,0);
+	}
+}
+
+void sysio_init(void)
+{
+	async_set_client_connection(sysio_client_connection);
+}
Index: fb/sysio.h
===================================================================
--- fb/sysio.h	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
+++ fb/sysio.h	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2006 Ondrej Palkovsky
+ * 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.
+ */
+
+#ifndef _SYSIO_H_
+#define _SYSIO_H_
+
+void sysio_init(void);
+
+#endif
Index: libc/generic/async.c
===================================================================
--- libc/generic/async.c	(revision c1d2c9dd2e8ed998a195ce76e6c2cb87a660d0d7)
+++ libc/generic/async.c	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
@@ -129,5 +129,9 @@
 } connection_t;
 
+
 __thread connection_t *PS_connection;
+
+static void default_client_connection(ipc_callid_t callid, ipc_call_t *call);
+static async_client_conn_t client_connection = default_client_connection;
 
 /** Add microseconds to give timeval */
@@ -273,5 +277,5 @@
  * user code.
  */
-void client_connection(ipc_callid_t callid, ipc_call_t *call)
+static void default_client_connection(ipc_callid_t callid, ipc_call_t *call)
 {
 	ipc_answer_fast(callid, ENOENT, 0, 0);
@@ -671,2 +675,11 @@
 	free(msg);
 }
+
+/** Set function that is called, IPC_M_CONNECT_ME_TO is received
+ *
+ * @param conn Function that will form new psthread.
+ */
+void async_set_client_connection(async_client_conn_t conn)
+{
+	client_connection = conn;
+}
Index: libc/generic/io/stream.c
===================================================================
--- libc/generic/io/stream.c	(revision c1d2c9dd2e8ed998a195ce76e6c2cb87a660d0d7)
+++ libc/generic/io/stream.c	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
@@ -53,15 +53,7 @@
 stream_t streams[FDS] = {{0, 0, 0}};
 
-/*
-ssize_t write_stdout(void *param, const void * buf, size_t count);
-ssize_t write_stdout(void *param, const void * buf, size_t count)
-{
-	return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count);
-}*/
-
 static ssize_t write_stderr(void *param, const void *buf, size_t count)
 {
 	return count;
-	//return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count);
 }
 
@@ -78,5 +70,4 @@
 	}
 	return i;
-	//return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count);
 }
 
@@ -90,5 +81,4 @@
 	
 	return count;
-	//return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count);
 }
 
Index: libc/include/async.h
===================================================================
--- libc/include/async.h	(revision c1d2c9dd2e8ed998a195ce76e6c2cb87a660d0d7)
+++ libc/include/async.h	(revision da0c91e7eb4cbf551006cea403dc8a904df85c6e)
@@ -36,4 +36,5 @@
 
 typedef ipc_callid_t aid_t;
+typedef void (*async_client_conn_t)(ipc_callid_t callid, ipc_call_t *call);
 
 int async_manager(void);
@@ -73,8 +74,8 @@
 void async_create_manager(void);
 void async_destroy_manager(void);
+void async_set_client_connection(async_client_conn_t conn);
 int _async_init(void);
 
 /* Should be defined by application */
-void client_connection(ipc_callid_t callid, ipc_call_t *call) __attribute__((weak));
 void interrupt_received(ipc_call_t *call)  __attribute__((weak));
 
