Index: kernel/generic/src/console/chardev.c
===================================================================
--- kernel/generic/src/console/chardev.c	(revision aa48a9d0d69ecad1e044b42d61982d233fd9b6de)
+++ kernel/generic/src/console/chardev.c	(revision d51db079aa01ad329ce298e255b1840cd48189bb)
@@ -43,5 +43,5 @@
  * @param op Implementation of character device operations.
  */
-void chardev_initialize(char *name,chardev_t *chardev, 
+void chardev_initialize(char *name, chardev_t *chardev, 
 			chardev_operations_t *op)
 {
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision aa48a9d0d69ecad1e044b42d61982d233fd9b6de)
+++ kernel/generic/src/console/cmd.c	(revision d51db079aa01ad329ce298e255b1840cd48189bb)
@@ -564,5 +564,5 @@
 	unative_t sec = uptime->seconds1;
 	
-	printf("Up %u days, %u hours, %u minutes, %u seconds\n",
+	printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n",
 		sec / 86400, (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60);
 	
@@ -633,5 +633,5 @@
 	} else {
 		symbol = get_symtab_entry(symaddr);
-		printf("Calling %s() (%.*p)\n", symbol, sizeof(uintptr_t) * 2, symaddr);
+		printf("Calling %s() (%p)\n", symbol, symaddr);
 #ifdef ia64
 		fptr.f = symaddr;
@@ -641,5 +641,5 @@
 		f =  (unative_t (*)(void)) symaddr;
 #endif
-		printf("Result: %#zx\n", f());
+		printf("Result: %#" PRIxn "\n", f());
 	}
 	
@@ -687,5 +687,5 @@
 		unative_t f;
 		unative_t gp;
-	}fptr;
+	} fptr;
 #endif
 
@@ -699,5 +699,5 @@
 		symbol = get_symtab_entry(symaddr);
 
-		printf("Calling f(%#zx): %.*p: %s\n", arg1, sizeof(uintptr_t) * 2, symaddr, symbol);
+		printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol);
 #ifdef ia64
 		fptr.f = symaddr;
@@ -707,5 +707,5 @@
 		f =  (unative_t (*)(unative_t,...)) symaddr;
 #endif
-		printf("Result: %#zx\n", f(arg1));
+		printf("Result: %#" PRIxn "\n", f(arg1));
 	}
 	
@@ -736,6 +736,6 @@
 	} else {
 		symbol = get_symtab_entry(symaddr);
-		printf("Calling f(0x%zx,0x%zx): %.*p: %s\n", 
-		       arg1, arg2, sizeof(uintptr_t) * 2, symaddr, symbol);
+		printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n", 
+		       arg1, arg2, symaddr, symbol);
 #ifdef ia64
 		fptr.f = symaddr;
@@ -745,5 +745,5 @@
 		f =  (unative_t (*)(unative_t,unative_t,...)) symaddr;
 #endif
-		printf("Result: %#zx\n", f(arg1, arg2));
+		printf("Result: %#" PRIxn "\n", f(arg1, arg2));
 	}
 	
@@ -775,6 +775,6 @@
 	} else {
 		symbol = get_symtab_entry(symaddr);
-		printf("Calling f(0x%zx,0x%zx, 0x%zx): %.*p: %s\n", 
-		       arg1, arg2, arg3, sizeof(uintptr_t) * 2, symaddr, symbol);
+		printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n", 
+		       arg1, arg2, arg3, symaddr, symbol);
 #ifdef ia64
 		fptr.f = symaddr;
@@ -784,5 +784,5 @@
 		f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) symaddr;
 #endif
-		printf("Result: %#zx\n", f(arg1, arg2, arg3));
+		printf("Result: %#" PRIxn "\n", f(arg1, arg2, arg3));
 	}
 	
@@ -857,5 +857,5 @@
 		if (pointer)
 			addr = (uint32_t *)(*(unative_t *)addr);
-		printf("Writing 0x%x -> %.*p\n", arg1, sizeof(uintptr_t) * 2, addr);
+		printf("Writing %#" PRIx64 " -> %p\n", arg1, addr);
 		*addr = arg1;
 		
@@ -1026,5 +1026,5 @@
 	order(dt, &cycles, &suffix);
 		
-	printf("Time: %llu%c cycles\n", cycles, suffix);
+	printf("Time: %" PRIu64 "%c cycles\n", cycles, suffix);
 	
 	if (ret == NULL) {
@@ -1054,5 +1054,5 @@
 	
 	for (i = 0; i < cnt; i++) {
-		printf("%s (%d/%d) ... ", test->name, i + 1, cnt);
+		printf("%s (%u/%u) ... ", test->name, i + 1, cnt);
 		
 		/* Update and read thread accounting
@@ -1082,5 +1082,5 @@
 		data[i] = dt;
 		order(dt, &cycles, &suffix);
-		printf("OK (%llu%c cycles)\n", cycles, suffix);
+		printf("OK (%" PRIu64 "%c cycles)\n", cycles, suffix);
 	}
 	
@@ -1095,5 +1095,5 @@
 		
 		order(sum / (uint64_t) cnt, &cycles, &suffix);
-		printf("Average\t\t%llu%c\n", cycles, suffix);
+		printf("Average\t\t%" PRIu64 "%c\n", cycles, suffix);
 	}
 	
Index: kernel/generic/src/console/console.c
===================================================================
--- kernel/generic/src/console/console.c	(revision aa48a9d0d69ecad1e044b42d61982d233fd9b6de)
+++ kernel/generic/src/console/console.c	(revision d51db079aa01ad329ce298e255b1840cd48189bb)
@@ -44,20 +44,21 @@
 #include <atomic.h>
 
-#define BUFLEN 2048
-static char debug_buffer[BUFLEN];
-static size_t offset = 0;
-/** Initialize stdout to something that does not print, but does not fail
- *
- * Save data in some buffer so that it could be retrieved in the debugger
- */
-static void null_putchar(chardev_t *d, const char ch)
-{
-	if (offset >= BUFLEN)
-		offset = 0;
-	debug_buffer[offset++] = ch;
-}
+#define KLOG_SIZE 4096
+
+/**< Kernel log cyclic buffer */
+static char klog[KLOG_SIZE];
+
+/**< First kernel log characters */
+static index_t klog_start = 0;
+/**< Number of valid kernel log characters */
+static size_t klog_len = 0;
+/**< Number of stored (not printed) kernel log characters */
+static size_t klog_stored = 0;
 
 static chardev_operations_t null_stdout_ops = {
-	.write = null_putchar
+	.suspend = NULL,
+	.resume = NULL,
+	.write = NULL,
+	.read = NULL
 };
 
@@ -91,5 +92,5 @@
 		/* no other way of interacting with user, halt */
 		if (CPU)
-			printf("cpu%d: ", CPU->id);
+			printf("cpu%u: ", CPU->id);
 		else
 			printf("cpu: ");
@@ -162,6 +163,26 @@
 void putchar(char c)
 {
+	if ((klog_stored > 0) && (stdout->op->write)) {
+		/* Print charaters stored in kernel log */
+		index_t i;
+		for (i = klog_len - klog_stored; i < klog_len; i++)
+			stdout->op->write(stdout, klog[(klog_start + i) % KLOG_SIZE]);
+		klog_stored = 0;
+	}
+	
+	/* Store character in the cyclic kernel log */
+	klog[(klog_start + klog_len) % KLOG_SIZE] = c;
+	if (klog_len < KLOG_SIZE)
+		klog_len++;
+	else
+		klog_start = (klog_start + 1) % KLOG_SIZE;
+	
 	if (stdout->op->write)
 		stdout->op->write(stdout, c);
+	else {
+		/* The character is just in the kernel log */
+		if (klog_stored < klog_len)
+			klog_stored++;
+	}
 }
 
Index: kernel/generic/src/console/klog.c
===================================================================
--- kernel/generic/src/console/klog.c	(revision aa48a9d0d69ecad1e044b42d61982d233fd9b6de)
+++ 	(revision )
@@ -1,154 +1,0 @@
-/*
- * 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.
- */
-
-/** @addtogroup genericklog
- * @{
- */
-/** @file
- */
-
-#include <mm/frame.h>
-#include <sysinfo/sysinfo.h>
-#include <console/klog.h>
-#include <print.h>
-#include <ddi/device.h>
-#include <ddi/irq.h>
-#include <ddi/ddi.h>
-#include <ipc/irq.h>
-
-/** Physical memory area used for klog. */
-static parea_t klog_parea;
-	
-/*
- * For now, we use 0 as INR.
- * However, on some architectures 0 is the clock interrupt (e.g. amd64 and
- * ia32). It is therefore desirable to have architecture specific definition of
- * KLOG_VIRT_INR in the future.
- */
-#define KLOG_VIRT_INR	0
-
-/* Order of frame to be allocated for klog communication */
-#define KLOG_ORDER	0
-
-static char *klog;
-static int klogsize;
-static int klogpos;
-
-SPINLOCK_INITIALIZE(klog_lock);
-
-static irq_t klog_irq;
-
-static irq_ownership_t klog_claim(void);
-
-/** Initialize kernel logging facility
- *
- * Allocate pages that are to be shared with uspace for console data.
- * The shared area is a circular buffer. Userspace application may
- * be notified on new data with indication of position and size
- * of the data within the circular buffer.
- */
-void klog_init(void)
-{
-	void *faddr;
-
-	faddr = frame_alloc(KLOG_ORDER, FRAME_ATOMIC);
-	if (!faddr)
-		panic("Cannot allocate page for klog");
-	klog = (char *) PA2KA(faddr);
-	
-	devno_t devno = device_assign_devno();
-	
-	klog_parea.pbase = (uintptr_t) faddr;
-	klog_parea.vbase = (uintptr_t) klog;
-	klog_parea.frames = 1 << KLOG_ORDER;
-	klog_parea.cacheable = true;
-	ddi_parea_register(&klog_parea);
-
-	sysinfo_set_item_val("klog.faddr", NULL, (unative_t) faddr);
-	sysinfo_set_item_val("klog.pages", NULL, 1 << KLOG_ORDER);
-	sysinfo_set_item_val("klog.devno", NULL, devno);
-	sysinfo_set_item_val("klog.inr", NULL, KLOG_VIRT_INR);
-
-	irq_initialize(&klog_irq);
-	klog_irq.devno = devno;
-	klog_irq.inr = KLOG_VIRT_INR;
-	klog_irq.claim = klog_claim;
-	irq_register(&klog_irq);
-
-	klogsize = PAGE_SIZE << KLOG_ORDER;
-	klogpos = 0;
-}
-
-/** Allways refuse IRQ ownership.
- *
- * This is not a real IRQ, so we always decline.
- *
- * @return Always returns IRQ_DECLINE.
- */
-irq_ownership_t klog_claim(void)
-{
-	return IRQ_DECLINE;
-}
-
-static void klog_vprintf(const char *fmt, va_list args)
-{
-	int ret;
-	va_list atst;
-
-	va_copy(atst, args);
-	spinlock_lock(&klog_lock);
-
-	ret = vsnprintf(klog+klogpos, klogsize-klogpos, fmt, atst);
-	if (ret >= klogsize-klogpos) {
-		klogpos = 0;
-		if (ret >= klogsize)
-			goto out;
-	}
-	ipc_irq_send_msg_2(&klog_irq, klogpos, ret);
-	klogpos += ret;
-	if (klogpos >= klogsize)
-		klogpos = 0;
-out:
-	spinlock_unlock(&klog_lock);
-	va_end(atst);
-}
-
-/** Printf a message to kernel-uspace log */
-void klog_printf(const char *fmt, ...)
-{
-	va_list args;
-	
-	va_start(args, fmt);
-	
-	klog_vprintf(fmt, args);
-
-	va_end(args);
-}
-
-/** @}
- */
