Index: abi/include/ddi/irq.h
===================================================================
--- abi/include/ddi/irq.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ abi/include/ddi/irq.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -36,4 +36,9 @@
 #define ABI_DDI_IRQ_H_
 
+typedef struct {
+	uintptr_t base;
+	size_t size;
+} irq_pio_range_t;
+
 typedef enum {
 	/** Read 1 byte from the I/O space. */
@@ -67,25 +72,4 @@
 	CMD_PIO_WRITE_A_32,
 	
-	/** Read 1 byte from the memory space. */
-	CMD_MEM_READ_8,
-	/** Read 2 bytes from the memory space. */
-	CMD_MEM_READ_16,
-	/** Read 4 bytes from the memory space. */
-	CMD_MEM_READ_32,
-	
-	/** Write 1 byte to the memory space. */
-	CMD_MEM_WRITE_8,
-	/** Write 2 bytes to the memory space. */
-	CMD_MEM_WRITE_16,
-	/** Write 4 bytes to the memory space. */
-	CMD_MEM_WRITE_32,
-	
-	/** Write 1 byte from the source argument to the memory space. */
-	CMD_MEM_WRITE_A_8,
-	/** Write 2 bytes from the source argument to the memory space. */
-	CMD_MEM_WRITE_A_16,
-	/** Write 4 bytes from the source argument to the memory space. */
-	CMD_MEM_WRITE_A_32,
-	
 	/**
 	 * Perform a bit masking on the source argument
@@ -118,4 +102,6 @@
 
 typedef struct {
+	size_t rangecount;
+	irq_pio_range_t *ranges;
 	size_t cmdcount;
 	irq_cmd_t *cmds;
Index: abi/include/syscall.h
===================================================================
--- abi/include/syscall.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ abi/include/syscall.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -92,4 +92,6 @@
 	SYS_IRQ_UNREGISTER,
 	
+	SYS_SYSINFO_GET_KEYS_SIZE,
+	SYS_SYSINFO_GET_KEYS,
 	SYS_SYSINFO_GET_VAL_TYPE,
 	SYS_SYSINFO_GET_VALUE,
Index: boot/Makefile.build
===================================================================
--- boot/Makefile.build	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/Makefile.build	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -34,5 +34,5 @@
 OPTIMIZATION = 3
 
-DEFS = -DRELEASE=$(RELEASE) "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
+DEFS = -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
 
 GCC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/Makefile.common	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -162,4 +162,5 @@
 	$(USPACE_PATH)/app/locinfo/locinfo \
 	$(USPACE_PATH)/app/mkfat/mkfat \
+	$(USPACE_PATH)/app/mkexfat/mkexfat \
 	$(USPACE_PATH)/app/mkmfs/mkmfs \
 	$(USPACE_PATH)/app/lsusb/lsusb \
Index: boot/arch/arm32/Makefile.inc
===================================================================
--- boot/arch/arm32/Makefile.inc	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/arch/arm32/Makefile.inc	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -39,4 +39,5 @@
 BITS = 32
 ENDIANESS = LE
+EXTRA_CFLAGS = -march=armv4
 
 RD_SRVS_ESSENTIAL += \
@@ -49,4 +50,5 @@
 SOURCES = \
 	arch/$(BARCH)/src/asm.S \
+	arch/$(BARCH)/src/eabi.S \
 	arch/$(BARCH)/src/main.c \
 	arch/$(BARCH)/src/mm.c \
Index: boot/arch/arm32/src/asm.S
===================================================================
--- boot/arch/arm32/src/asm.S	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/arch/arm32/src/asm.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -60,3 +60,3 @@
 	# before passing control to the copied code.
 	#
-	bx r0
+	mov pc, r0
Index: boot/arch/arm32/src/eabi.S
===================================================================
--- boot/arch/arm32/src/eabi.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ boot/arch/arm32/src/eabi.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,92 @@
+#
+# Copyright (c) 2012 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.
+#
+
+.text
+
+.global __aeabi_idiv
+.global __aeabi_uidiv
+
+.global __aeabi_idivmod
+.global __aeabi_uidivmod
+
+.global __aeabi_ldivmod
+.global __aeabi_uldivmod
+
+__aeabi_idiv:
+	push {lr}
+	bl __divsi3
+	pop {lr}
+	mov pc, lr
+
+__aeabi_uidiv:
+	push {lr}
+	bl __udivsi3
+	pop {lr}
+	mov pc, lr
+
+__aeabi_idivmod:
+	push {lr}
+	sub sp, sp, #12
+	add r2, sp, #4
+	bl __udivmodsi3
+	ldr r1, [sp, #4]
+	add sp, sp, #12
+	pop {lr}
+	mov pc, lr
+
+__aeabi_uidivmod:
+	push {lr}
+	sub sp, sp, #12
+	add r2, sp, #4
+	bl __udivmodsi3
+	ldr r1, [sp, #4]
+	add sp, sp, #12
+	pop {lr}
+	mov pc, lr
+
+__aeabi_ldivmod:
+	push {lr}
+	sub sp, sp, #24
+	push {sp}
+	bl __divmoddi3
+	add sp, sp, #4
+	pop {r2, r3}
+	add sp, sp, #16
+	pop {lr}
+	mov pc, lr
+
+__aeabi_uldivmod:
+	push {lr}
+	sub sp, sp, #24
+	push {sp}
+	bl __udivmoddi3
+	add sp, sp, #4
+	pop {r2, r3}
+	add sp, sp, #16
+	pop {lr}
+	mov pc, lr
Index: boot/arch/ia64/src/main.c
===================================================================
--- boot/arch/ia64/src/main.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/arch/ia64/src/main.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -189,8 +189,20 @@
 	printf("\nInflating components ... ");
 	
+	/*
+	 * We will use the next available address for a copy of each component to
+	 * make sure that inflate() works with disjunctive memory regions.
+	 */
+	top = ALIGN_UP(top, PAGE_SIZE);
+
 	for (i = cnt; i > 0; i--) {
 		printf("%s ", components[i - 1].name);
 		
-		int err = inflate(components[i - 1].start, components[i - 1].size,
+		/*
+		 * Copy the component to a location which is guaranteed not to
+		 * overlap with the destination for inflate().
+		 */
+		memmove((void *) top, components[i - 1].start, components[i - 1].size);
+		
+		int err = inflate((void *) top, components[i - 1].size,
 		    dest[i - 1], components[i - 1].inflated);
 		
Index: boot/arch/ia64/src/pal_asm.S
===================================================================
--- boot/arch/ia64/src/pal_asm.S	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/arch/ia64/src/pal_asm.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -32,11 +32,16 @@
 
 pal_static_call:
-	alloc loc0 = ar.pfs, 7, 5, 0, 0
+	alloc loc0 = ar.pfs, 7, 6, 0, 0
+
+	mov loc1 = psr ;;
+	mov psr.l = r0 ;;
+	srlz.i
+	srlz.d
 	
-	mov loc1 = gp
-	mov loc2 = rp
+	mov loc2 = gp
+	mov loc3 = rp
 	
-	addl loc3 = @gprel(pal_proc), gp
-	
+	addl loc4 = @gprel(pal_proc), gp
+
 	mov r28 = in0
 	mov r29 = in1
@@ -44,12 +49,16 @@
 	mov r31 = in3 ;;
 	
-	ld8 loc3 = [loc3]
-	movl loc4 = 0f ;;
+	ld8 loc4 = [loc4]
+	movl loc5 = 0f ;;
 
-	mov b6 = loc3
-	mov rp = loc4 ;;
+	mov b6 = loc4
+	mov rp = loc5 ;;
 	br.cond.sptk.many b6
 
 0:
+	mov psr.l = loc1 ;;
+	srlz.i
+	srlz.d
+
 	cmp.ne p7,p0 = 0, in4
 	cmp.ne p8,p0 = 0, in5
@@ -60,6 +69,6 @@
 (p9)	st8 [in6] = r11
 	
-	mov gp = loc1
-	mov rp = loc2 ;;
+	mov gp = loc2
+	mov rp = loc3 ;;
 	
 	mov ar.pfs = loc0
Index: boot/arch/ia64/src/sal_asm.S
===================================================================
--- boot/arch/ia64/src/sal_asm.S	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/arch/ia64/src/sal_asm.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -29,4 +29,9 @@
 .explicit
 
+#define STACK_SCRATCH_AREA	16
+#define STACK_IN8		(0 + STACK_SCRATCH_AREA)
+#define STACK_IN9		(8 + STACK_SCRATCH_AREA)
+#define STACK_IN10		(16 + STACK_SCRATCH_AREA)
+
 .global sal_call
 
@@ -39,6 +44,8 @@
 #
 sal_call:
-	alloc loc0 = ar.pfs, 11, 5, 8, 0
+	alloc loc0 = ar.pfs, 8, 8, 8, 0
 	
+	adds sp = -STACK_SCRATCH_AREA, sp
+
 	mov loc1 = gp
 	mov loc2 = rp
@@ -57,20 +64,31 @@
 	
 	ld8 loc3 = [loc3]
-	ld8 gp = [loc4] ;;
+	ld8 gp = [loc4]
+
+	adds r14 = STACK_IN8 + STACK_SCRATCH_AREA, sp
+	adds r15 = STACK_IN9 + STACK_SCRATCH_AREA, sp
+	adds r16 = STACK_IN10 + STACK_SCRATCH_AREA, sp ;;
+
+	ld8 loc5 = [r14]
+	ld8 loc6 = [r15]
+	ld8 loc7 = [r16]
 	
 	mov b6 = loc3 ;;
 	br.call.sptk.many rp = b6
 	
-	cmp.ne p7,p0 = 0, in8
-	cmp.ne p8,p0 = 0, in9
-	cmp.ne p9,p0 = 0, in10 ;;
+	cmp.ne p7,p0 = 0, loc5 
+	cmp.ne p8,p0 = 0, loc6 
+	cmp.ne p9,p0 = 0, loc7 ;;
 	
-(p7)	st8 [in8] = r9
-(p8)	st8 [in9] = r10
-(p9)	st8 [in10] = r11
+(p7)	st8 [loc5] = r9
+(p8)	st8 [loc6] = r10
+(p9)	st8 [loc7] = r11
 	
 	mov gp = loc1
-	mov rp = loc2 ;;
+	mov rp = loc2
+
+	adds sp = STACK_SCRATCH_AREA, sp ;;
 	
 	mov ar.pfs = loc0
 	br.ret.sptk.many rp
+
Index: boot/genarch/include/division.h
===================================================================
--- boot/genarch/include/division.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/genarch/include/division.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -33,28 +33,20 @@
 #define BOOT_DIVISION_H_
 
-/* 32bit integer division */
 extern int __divsi3(int, int);
-
-/* 64bit integer division */
 extern long long __divdi3(long long, long long);
 
-/* 32bit unsigned integer division */
 extern unsigned int __udivsi3(unsigned int, unsigned int);
-
-/* 64bit unsigned integer division */
 extern unsigned long long __udivdi3(unsigned long long, unsigned long long);
 
-/* 32bit remainder of the signed division */
 extern int __modsi3(int, int);
-
-/* 64bit remainder of the signed division */
 extern long long __moddi3(long long, long long);
 
-/* 32bit remainder of the unsigned division */
 extern unsigned int __umodsi3(unsigned int, unsigned int);
-
-/* 64bit remainder of the unsigned division */
 extern unsigned long long __umoddi3(unsigned long long, unsigned long long);
 
+extern int __divmodsi3(int, int, int *);
+extern unsigned int __udivmodsi3(unsigned int, unsigned int, unsigned int *);
+
+extern long long __divmoddi3(long long, long long, long long *);
 extern unsigned long long __udivmoddi3(unsigned long long, unsigned long long,
     unsigned long long *);
Index: boot/genarch/src/division.c
===================================================================
--- boot/genarch/src/division.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/genarch/src/division.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -73,5 +73,5 @@
 {
 	unsigned long long result;
-	int steps = sizeof(unsigned long long) * 8; 
+	int steps = sizeof(unsigned long long) * 8;
 	
 	*remainder = 0;
@@ -104,5 +104,5 @@
 
 /* 32bit integer division */
-int __divsi3(int a, int b) 
+int __divsi3(int a, int b)
 {
 	unsigned int rem;
@@ -116,5 +116,5 @@
 
 /* 64bit integer division */
-long long __divdi3(long long a, long long b) 
+long long __divdi3(long long a, long long b)
 {
 	unsigned long long rem;
@@ -155,5 +155,5 @@
 
 /* 64bit remainder of the signed division */
-long long __moddi3(long long a,long  long b)
+long long __moddi3(long long a, long long b)
 {
 	unsigned long long rem;
@@ -183,4 +183,38 @@
 }
 
+int __divmodsi3(int a, int b, int *c)
+{
+	unsigned int rem;
+	int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
+	
+	if (SGN(a) == SGN(b)) {
+		*c = rem;
+		return result;
+	}
+	
+	*c = -rem;
+	return -result;
+}
+
+unsigned int __udivmodsi3(unsigned int a, unsigned int b,
+    unsigned int *c)
+{
+	return divandmod32(a, b, c);
+}
+
+long long __divmoddi3(long long a, long long b, long long *c)
+{
+	unsigned long long rem;
+	long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
+	
+	if (SGN(a) == SGN(b)) {
+		*c = rem;
+		return result;
+	}
+	
+	*c = -rem;
+	return -result;
+}
+
 unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b,
     unsigned long long *c)
Index: boot/generic/include/memstr.h
===================================================================
--- boot/generic/include/memstr.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/generic/include/memstr.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -36,4 +36,5 @@
 
 extern void *memcpy(void *, const void *, size_t);
+extern void *memmove(void *, const void *, size_t);
 
 #endif
Index: boot/generic/src/memstr.c
===================================================================
--- boot/generic/src/memstr.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/generic/src/memstr.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -51,4 +51,49 @@
 }
 
+/** Move memory block with possible overlapping.
+ *
+ * Copy cnt bytes from src address to dst address. The source
+ * and destination memory areas may overlap.
+ *
+ * @param dst Destination address to copy to.
+ * @param src Source address to copy from.
+ * @param cnt Number of bytes to copy.
+ *
+ * @return Destination address.
+ *
+ */
+void *memmove(void *dst, const void *src, size_t cnt)
+{
+	/* Nothing to do? */
+	if (src == dst)
+		return dst;
+	
+	/* Non-overlapping? */
+	if ((dst >= src + cnt) || (src >= dst + cnt))
+		return memcpy(dst, src, cnt);
+	
+	uint8_t *dp;
+	const uint8_t *sp;
+	
+	/* Which direction? */
+	if (src > dst) {
+		/* Forwards. */
+		dp = dst;
+		sp = src;
+		
+		while (cnt-- != 0)
+			*dp++ = *sp++;
+	} else {
+		/* Backwards. */
+		dp = dst + (cnt - 1);
+		sp = src + (cnt - 1);
+		
+		while (cnt-- != 0)
+			*dp-- = *sp--;
+	}
+	
+	return dst;
+}
+
 /** @}
  */
Index: boot/generic/src/str.c
===================================================================
--- boot/generic/src/str.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/generic/src/str.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -100,4 +100,11 @@
 #include <str.h>
 #include <errno.h>
+
+/** Check the condition if wchar_t is signed */
+#ifdef WCHAR_IS_UNSIGNED
+	#define WCHAR_SIGNED_CHECK(cond)  (true)
+#else
+	#define WCHAR_SIGNED_CHECK(cond)  (cond)
+#endif
 
 /** Byte mask consisting of lowest @n bits (out of 8) */
@@ -198,5 +205,5 @@
  *         code was invalid.
  */
-int chr_encode(wchar_t ch, char *str, size_t *offset, size_t size)
+int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t size)
 {
 	if (*offset >= size)
@@ -325,5 +332,5 @@
 bool ascii_check(wchar_t ch)
 {
-	if ((ch >= 0) && (ch <= 127))
+	if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127))
 		return true;
 	
@@ -338,5 +345,5 @@
 bool chr_check(wchar_t ch)
 {
-	if ((ch >= 0) && (ch <= 1114111))
+	if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111))
 		return true;
 	
Index: boot/generic/src/version.c
===================================================================
--- boot/generic/src/version.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ boot/generic/src/version.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -32,5 +32,5 @@
 
 static const char *project = "HelenOS bootloader";
-static const char *copyright = "Copyright (c) 2001-2011 HelenOS project";
+static const char *copyright = STRING(COPYRIGHT);
 static const char *release = STRING(RELEASE);
 static const char *name = STRING(NAME);
Index: contrib/conf/mips32-gx.sh
===================================================================
--- contrib/conf/mips32-gx.sh	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ contrib/conf/mips32-gx.sh	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -8,3 +8,3 @@
 fi
 
-gxemul $@ -E testmips -C R4000 -X image.boot -d d0:"$DISK_IMG"
+gxemul $@ -E oldtestmips -C R4000 -X image.boot -d d0:"$DISK_IMG"
Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/Makefile	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -90,5 +90,5 @@
 endif
 
-DEFS = -DKERNEL -DRELEASE=$(RELEASE) "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
+DEFS = -DKERNEL -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
 
 GCC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
Index: kernel/arch/amd64/include/context.h
===================================================================
--- kernel/arch/amd64/include/context.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/amd64/include/context.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,5 +38,6 @@
 #include <typedefs.h>
 
-/* According to ABI the stack MUST be aligned on 
+/*
+ * According to ABI the stack MUST be aligned on
  * 16-byte boundary. If it is not, the va_arg calling will
  * panic sooner or later
Index: kernel/arch/arm32/Makefile.inc
===================================================================
--- kernel/arch/arm32/Makefile.inc	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/arm32/Makefile.inc	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -33,5 +33,5 @@
 ATSIGN = %
 
-GCC_CFLAGS += -fno-zero-initialized-in-bss -mapcs-frame
+GCC_CFLAGS += -march=armv4
 
 BITS = 32
@@ -41,4 +41,5 @@
 	arch/$(KARCH)/src/start.S \
 	arch/$(KARCH)/src/asm.S \
+	arch/$(KARCH)/src/eabi.S \
 	arch/$(KARCH)/src/exc_handler.S \
 	arch/$(KARCH)/src/arm32.c \
Index: kernel/arch/arm32/include/context.h
===================================================================
--- kernel/arch/arm32/include/context.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/arm32/include/context.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup arm32	
+/** @addtogroup arm32
  * @{
  */
Index: kernel/arch/arm32/src/eabi.S
===================================================================
--- kernel/arch/arm32/src/eabi.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ kernel/arch/arm32/src/eabi.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,92 @@
+#
+# Copyright (c) 2012 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.
+#
+
+.text
+
+.global __aeabi_idiv
+.global __aeabi_uidiv
+
+.global __aeabi_idivmod
+.global __aeabi_uidivmod
+
+.global __aeabi_ldivmod
+.global __aeabi_uldivmod
+
+__aeabi_idiv:
+	push {lr}
+	bl __divsi3
+	pop {lr}
+	mov pc, lr
+
+__aeabi_uidiv:
+	push {lr}
+	bl __udivsi3
+	pop {lr}
+	mov pc, lr
+
+__aeabi_idivmod:
+	push {lr}
+	sub sp, sp, #12
+	add r2, sp, #4
+	bl __udivmodsi3
+	ldr r1, [sp, #4]
+	add sp, sp, #12
+	pop {lr}
+	mov pc, lr
+
+__aeabi_uidivmod:
+	push {lr}
+	sub sp, sp, #12
+	add r2, sp, #4
+	bl __udivmodsi3
+	ldr r1, [sp, #4]
+	add sp, sp, #12
+	pop {lr}
+	mov pc, lr
+
+__aeabi_ldivmod:
+	push {lr}
+	sub sp, sp, #24
+	push {sp}
+	bl __divmoddi3
+	add sp, sp, #4
+	pop {r2, r3}
+	add sp, sp, #16
+	pop {lr}
+	mov pc, lr
+
+__aeabi_uldivmod:
+	push {lr}
+	sub sp, sp, #24
+	push {sp}
+	bl __udivmoddi3
+	add sp, sp, #4
+	pop {r2, r3}
+	add sp, sp, #16
+	pop {lr}
+	mov pc, lr
Index: kernel/arch/arm32/src/mach/integratorcp/integratorcp.c
===================================================================
--- kernel/arch/arm32/src/mach/integratorcp/integratorcp.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/arm32/src/mach/integratorcp/integratorcp.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -332,8 +332,6 @@
 	sysinfo_set_item_val("kbd", NULL, true);
 	sysinfo_set_item_val("kbd.inr", NULL, ICP_KBD_IRQ);
-	sysinfo_set_item_val("kbd.address.status", NULL,
-	    (uintptr_t) icp_hw_map.kbd_stat);
-	sysinfo_set_item_val("kbd.address.data", NULL,
-	    (uintptr_t) icp_hw_map.kbd_data);
+	sysinfo_set_item_val("kbd.address.physical", NULL,
+	    ICP_KBD);
 
 }
Index: kernel/arch/arm32/src/mach/testarm/testarm.c
===================================================================
--- kernel/arch/arm32/src/mach/testarm/testarm.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/arm32/src/mach/testarm/testarm.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -121,5 +121,5 @@
 		}
 	}
-
+	
 	/*
 	 * This is the necessary evil until the userspace driver is entirely
@@ -128,5 +128,6 @@
 	sysinfo_set_item_val("kbd", NULL, true);
 	sysinfo_set_item_val("kbd.inr", NULL, GXEMUL_KBD_IRQ);
-	sysinfo_set_item_val("kbd.address.virtual", NULL, (sysarg_t) gxemul_kbd);
+	sysinfo_set_item_val("kbd.address.physical", NULL,
+	    GXEMUL_KBD_ADDRESS);
 #endif
 }
@@ -171,5 +172,5 @@
 	clock();
 	spinlock_lock(&irq->lock);
-
+	
 	/* acknowledge tick */
 	*((uint32_t *) (gxemul_rtc + GXEMUL_RTC_ACK_OFFSET))
@@ -180,11 +181,11 @@
 static void gxemul_timer_irq_init(void)
 {
-        irq_initialize(&gxemul_timer_irq);
-        gxemul_timer_irq.devno = device_assign_devno();
-        gxemul_timer_irq.inr = GXEMUL_TIMER_IRQ;
-        gxemul_timer_irq.claim = gxemul_timer_claim;
-        gxemul_timer_irq.handler = gxemul_timer_irq_handler;
-
-        irq_register(&gxemul_timer_irq);
+	irq_initialize(&gxemul_timer_irq);
+	gxemul_timer_irq.devno = device_assign_devno();
+	gxemul_timer_irq.inr = GXEMUL_TIMER_IRQ;
+	gxemul_timer_irq.claim = gxemul_timer_claim;
+	gxemul_timer_irq.handler = gxemul_timer_irq_handler;
+	
+	irq_register(&gxemul_timer_irq);
 }
 
@@ -197,6 +198,6 @@
 void gxemul_timer_irq_start(void)
 {
-        gxemul_timer_irq_init();
-        gxemul_timer_start(GXEMUL_TIMER_FREQ);
+	gxemul_timer_irq_init();
+	gxemul_timer_start(GXEMUL_TIMER_FREQ);
 }
 
@@ -226,5 +227,5 @@
 	uint32_t sources = gxemul_irqc_get_sources();
 	unsigned int i;
-
+	
 	for (i = 0; i < GXEMUL_IRQ_COUNT; i++) {
 		if (sources & (1 << i)) {
Index: kernel/arch/ia64/include/asm.h
===================================================================
--- kernel/arch/ia64/include/asm.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/ia64/include/asm.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -61,4 +61,5 @@
 	asm volatile (
 		"mf\n"
+		"mf.a\n"
 		::: "memory"
 	);
@@ -74,4 +75,5 @@
 	asm volatile (
 		"mf\n"
+		"mf.a\n"
 		::: "memory"
 	);
@@ -87,4 +89,5 @@
 	asm volatile (
 		"mf\n"
+		"mf.a\n"
 		::: "memory"
 	);
@@ -104,4 +107,9 @@
 	else
 		v = *port;
+
+	asm volatile (
+		"mf.a\n"
+		::: "memory"
+	);
 	
 	return v;
@@ -121,4 +129,9 @@
 	else
 		v = *port;
+
+	asm volatile (
+		"mf.a\n"
+		::: "memory"
+	);
 	
 	return v;
@@ -138,4 +151,9 @@
 	else
 		v = *port;
+
+	asm volatile (
+		"mf.a\n"
+		::: "memory"
+	);
 
 	return v;
Index: kernel/arch/ia64/include/context.h
===================================================================
--- kernel/arch/ia64/include/context.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/ia64/include/context.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia64	
+/** @addtogroup ia64
  * @{
  */
@@ -47,14 +47,14 @@
  * One item is put onto the stack to support get_stack_base().
  */
-#define SP_DELTA	(0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
+#define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
 
 /* RSE stack starts at the bottom of memory stack, hence the division by 2. */
-#define context_set(c, _pc, stack, size)								\
-	do {												\
-		(c)->pc = (uintptr_t) _pc;								\
-		(c)->bsp = ((uintptr_t) stack) + ALIGN_UP((size / 2), REGISTER_STACK_ALIGNMENT);	\
-		(c)->ar_pfs &= PFM_MASK; 								\
-		(c)->sp = ((uintptr_t) stack) + ALIGN_UP((size / 2), STACK_ALIGNMENT) - SP_DELTA;	\
-	} while (0);
+#define context_set(c, _pc, stack, size) \
+	do { \
+		(c)->pc = (uintptr_t) _pc; \
+		(c)->bsp = ((uintptr_t) stack) + ALIGN_UP((size / 2), REGISTER_STACK_ALIGNMENT); \
+		(c)->ar_pfs &= PFM_MASK; \
+		(c)->sp = ((uintptr_t) stack) + ALIGN_UP((size / 2), STACK_ALIGNMENT) - SP_DELTA; \
+	} while (0)
 
 /*
Index: kernel/arch/ia64/src/ia64.c
===================================================================
--- kernel/arch/ia64/src/ia64.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/ia64/src/ia64.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -144,5 +144,5 @@
 #endif
 #ifdef MACHINE_i460GX
-	platform = "i460GX";
+	platform = "pc";
 #endif
 	sysinfo_set_item_data("platform", NULL, (void *) platform,
@@ -187,6 +187,4 @@
 	sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550);
 	sysinfo_set_item_val("kbd.address.physical", NULL,
-	    (uintptr_t) NS16550_BASE);
-	sysinfo_set_item_val("kbd.address.kernel", NULL,
 	    (uintptr_t) NS16550_BASE);
 #endif
Index: kernel/arch/mips32/include/context.h
===================================================================
--- kernel/arch/mips32/include/context.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/mips32/include/context.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -42,5 +42,5 @@
  * Put one item onto the stack to support get_stack_base() and align it up.
  */
-#define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
+#define SP_DELTA  (ABI_STACK_FRAME + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
 
 #ifndef __ASM__
Index: kernel/arch/mips32/include/stack.h
===================================================================
--- kernel/arch/mips32/include/stack.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/mips32/include/stack.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup mips32	
+/** @addtogroup mips32
  * @{
  */
@@ -36,6 +36,7 @@
 #define KERN_mips32_STACK_H_
 
-#define STACK_ITEM_SIZE		4
-#define STACK_ALIGNMENT		8
+#define STACK_ITEM_SIZE  4
+#define STACK_ALIGNMENT  8
+#define ABI_STACK_FRAME  32
 
 #endif
Index: kernel/arch/mips32/src/mips32.c
===================================================================
--- kernel/arch/mips32/src/mips32.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/mips32/src/mips32.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -196,5 +196,6 @@
 	sysinfo_set_item_val("kbd", NULL, true);
 	sysinfo_set_item_val("kbd.inr", NULL, MSIM_KBD_IRQ);
-	sysinfo_set_item_val("kbd.address.virtual", NULL, MSIM_KBD_ADDRESS);
+	sysinfo_set_item_val("kbd.address.physical", NULL,
+	    PA2KA(MSIM_KBD_ADDRESS));
 #endif
 }
Index: kernel/arch/mips32/src/start.S
===================================================================
--- kernel/arch/mips32/src/start.S	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/mips32/src/start.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -241,5 +241,5 @@
 	/* $a1 contains physical address of bootinfo_t */
 	jal arch_pre_main
-	nop
+	addiu $sp, -ABI_STACK_FRAME
 	
 	j main_bsp
@@ -281,6 +281,8 @@
 	
 	move $a1, $sp
+	move $a0, $k0
 	jal exc_dispatch     /* exc_dispatch(excno, register_space) */
-	move $a0, $k0
+	addiu $sp, -ABI_STACK_FRAME
+	addiu $sp, ABI_STACK_FRAME
 	
 	REGISTERS_LOAD $sp
@@ -323,4 +325,5 @@
 	sw $t0, ISTATE_OFFSET_T0($sp)  /* save the 5th argument on the stack */
 	sw $t1, ISTATE_OFFSET_T1($sp)  /* save the 6th argument on the stack */
+	
 	jal syscall_handler
 	sw $v0, ISTATE_OFFSET_V0($sp)  /* save the syscall number on the stack */
@@ -357,6 +360,8 @@
 	move $sp, $k0
 	
+	move $a0, $sp
 	jal tlb_refill
-	move $a0, $sp 
+	addiu $sp, -ABI_STACK_FRAME
+	addiu $sp, ABI_STACK_FRAME
 	
 	REGISTERS_LOAD $sp
@@ -366,11 +371,13 @@
 cache_error_handler:
 	KERNEL_STACK_TO_K0
-	sub $k0, ISTATE_SOFT_SIZE 
+	sub $k0, ISTATE_SOFT_SIZE
 	REGISTERS_STORE_AND_EXC_RESET $k0
 	sw $sp, ISTATE_OFFSET_SP($k0)
 	move $sp, $k0
 	
+	move $a0, $sp
 	jal cache_error
-	move $a0, $sp
+	addiu $sp, -ABI_STACK_FRAME
+	addiu $sp, ABI_STACK_FRAME
 	
 	REGISTERS_LOAD $sp
Index: kernel/arch/mips64/include/context.h
===================================================================
--- kernel/arch/mips64/include/context.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/mips64/include/context.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -42,5 +42,5 @@
  * Put one item onto the stack to support get_stack_base() and align it up.
  */
-#define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
+#define SP_DELTA  (ABI_STACK_FRAME + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
 
 #ifndef __ASM__
Index: kernel/arch/mips64/include/stack.h
===================================================================
--- kernel/arch/mips64/include/stack.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/mips64/include/stack.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,4 +38,5 @@
 #define STACK_ITEM_SIZE  8
 #define STACK_ALIGNMENT  8
+#define ABI_STACK_FRAME  64
 
 #endif
Index: kernel/arch/mips64/src/start.S
===================================================================
--- kernel/arch/mips64/src/start.S	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/mips64/src/start.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -241,5 +241,5 @@
 	/* $a1 contains physical address of bootinfo_t */
 	jal arch_pre_main
-	nop
+	addiu $sp, -ABI_STACK_FRAME
 	
 	j main_bsp
@@ -281,6 +281,8 @@
 	
 	move $a1, $sp
+	move $a0, $k0
 	jal exc_dispatch     /* exc_dispatch(excno, register_space) */
-	move $a0, $k0
+	addiu $sp, -ABI_STACK_FRAME
+	addiu $sp, ABI_STACK_FRAME
 	
 	REGISTERS_LOAD $sp
@@ -323,4 +325,5 @@
 	sw $t0, ISTATE_OFFSET_T0($sp)  /* save the 5th argument on the stack */
 	sw $t1, ISTATE_OFFSET_T1($sp)  /* save the 6th argument on the stack */
+	
 	jal syscall_handler
 	sw $v0, ISTATE_OFFSET_V0($sp)  /* save the syscall number on the stack */
@@ -357,6 +360,8 @@
 	move $sp, $k0
 	
+	move $a0, $sp
 	jal tlb_refill
-	move $a0, $sp 
+	addiu $sp, -ABI_STACK_FRAME
+	addiu $sp, ABI_STACK_FRAME
 	
 	REGISTERS_LOAD $sp
@@ -366,11 +371,13 @@
 cache_error_handler:
 	KERNEL_STACK_TO_K0
-	sub $k0, ISTATE_SOFT_SIZE 
+	sub $k0, ISTATE_SOFT_SIZE
 	REGISTERS_STORE_AND_EXC_RESET $k0
 	sw $sp, ISTATE_OFFSET_SP($k0)
 	move $sp, $k0
 	
+	move $a0, $sp
 	jal cache_error
-	move $a0, $sp
+	addiu $sp, -ABI_STACK_FRAME
+	addiu $sp, ABI_STACK_FRAME
 	
 	REGISTERS_LOAD $sp
Index: kernel/arch/ppc32/src/ppc32.c
===================================================================
--- kernel/arch/ppc32/src/ppc32.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/ppc32/src/ppc32.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -130,6 +130,9 @@
 			visual = VISUAL_INDIRECT_8;
 			break;
+		case 15:
+			visual = VISUAL_RGB_5_5_5_BE;
+			break;
 		case 16:
-			visual = VISUAL_RGB_5_5_5_BE;
+			visual = VISUAL_RGB_5_6_5_BE;
 			break;
 		case 24:
@@ -173,4 +176,6 @@
 		ofw_tree_walk_by_device_type("display", display_register, NULL);
 #endif
+		/* Map OFW information into sysinfo */
+		ofw_sysinfo_map();
 		
 		/* Initialize IRQ routing */
@@ -232,6 +237,4 @@
 		sysinfo_set_item_val("cuda.inr", NULL, IRQ_CUDA);
 		sysinfo_set_item_val("cuda.address.physical", NULL, pa);
-		sysinfo_set_item_val("cuda.address.kernel", NULL,
-		    (uintptr_t) cuda);
 #endif
 	}
Index: kernel/arch/sparc64/include/context.h
===================================================================
--- kernel/arch/sparc64/include/context.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/sparc64/include/context.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup sparc64	
+/** @addtogroup sparc64
  * @{
  */
@@ -40,12 +40,13 @@
 #include <align.h>
 
-#define SP_DELTA	(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE)
+#define SP_DELTA  (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE)
 
-#define context_set(c, _pc, stack, size)			\
-	(c)->pc = ((uintptr_t) _pc) - 8;			\
-	(c)->sp = ((uintptr_t) stack) + ALIGN_UP((size), 	\
-		STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA);	\
-	(c)->fp = -STACK_BIAS
-	
+#define context_set(c, _pc, stack, size) \
+	do { \
+		(c)->pc = ((uintptr_t) _pc) - 8; \
+		(c)->sp = ((uintptr_t) stack) + ALIGN_UP((size), \
+		    STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA); \
+		(c)->fp = -STACK_BIAS; \
+	} while (0)
 
 /*
Index: kernel/arch/sparc64/src/drivers/kbd.c
===================================================================
--- kernel/arch/sparc64/src/drivers/kbd.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/sparc64/src/drivers/kbd.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -133,6 +133,4 @@
 	sysinfo_set_item_val("kbd", NULL, true);
 	sysinfo_set_item_val("kbd.inr", NULL, inr);
-	sysinfo_set_item_val("kbd.address.kernel", NULL,
-	    (uintptr_t) ns16550);
 	sysinfo_set_item_val("kbd.address.physical", NULL, pa);
 	sysinfo_set_item_val("kbd.type.ns16550", NULL, true);
Index: kernel/arch/sparc64/src/sun4u/sparc64.c
===================================================================
--- kernel/arch/sparc64/src/sun4u/sparc64.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/sparc64/src/sun4u/sparc64.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -94,4 +94,7 @@
 {
 	if (config.cpu_active == 1) {
+		/* Map OFW information into sysinfo */
+		ofw_sysinfo_map();
+		
 		/*
 		 * We have 2^11 different interrupt vectors.
Index: kernel/arch/sparc64/src/sun4v/sparc64.c
===================================================================
--- kernel/arch/sparc64/src/sun4v/sparc64.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/arch/sparc64/src/sun4v/sparc64.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -92,4 +92,7 @@
 {
 	if (config.cpu_active == 1) {
+		/* Map OFW information into sysinfo */
+		ofw_sysinfo_map();
+		
 		/*
 		 * We have 2^11 different interrupt vectors.
Index: kernel/genarch/include/ofw/ofw_tree.h
===================================================================
--- kernel/genarch/include/ofw/ofw_tree.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/genarch/include/ofw/ofw_tree.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -67,5 +67,5 @@
 
 extern void ofw_tree_init(ofw_tree_node_t *);
-extern void ofw_tree_print(void);
+extern void ofw_sysinfo_map(void);
 
 extern const char *ofw_tree_node_name(const ofw_tree_node_t *);
Index: kernel/genarch/include/softint/division.h
===================================================================
--- kernel/genarch/include/softint/division.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/genarch/include/softint/division.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -36,29 +36,22 @@
 #define KERN_DIVISION_H_
 
-/* 32bit integer division */
-int __divsi3(int a, int b);
+extern int __divsi3(int, int);
+extern long long __divdi3(long long, long long);
 
-/* 64bit integer division */
-long long __divdi3(long long a, long long b);
+extern unsigned int __udivsi3(unsigned int, unsigned int);
+extern unsigned long long __udivdi3(unsigned long long, unsigned long long);
 
-/* 32bit unsigned integer division */
-unsigned int __udivsi3(unsigned int a, unsigned int b);
+extern int __modsi3(int, int);
+extern long long __moddi3(long long, long long);
 
-/* 64bit unsigned integer division */
-unsigned long long __udivdi3(unsigned long long a, unsigned long long b);
+extern unsigned int __umodsi3(unsigned int, unsigned int);
+extern unsigned long long __umoddi3(unsigned long long, unsigned long long);
 
-/* 32bit remainder of the signed division */
-int __modsi3(int a, int b);
+extern int __divmodsi3(int, int, int *);
+extern unsigned int __udivmodsi3(unsigned int, unsigned int, unsigned int *);
 
-/* 64bit remainder of the signed division */
-long long __moddi3(long long a, long long b);
-
-/* 32bit remainder of the unsigned division */
-unsigned int __umodsi3(unsigned int a, unsigned int b);
-
-/* 64bit remainder of the unsigned division */
-unsigned long long __umoddi3(unsigned long long a, unsigned long long b);
-
-unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b, unsigned long long *c); 
+extern long long __divmoddi3(long long, long long, long long *);
+extern unsigned long long __udivmoddi3(unsigned long long, unsigned long long,
+    unsigned long long *);
 
 #endif
Index: kernel/genarch/include/softint/multiplication.h
===================================================================
--- kernel/genarch/include/softint/multiplication.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/genarch/include/softint/multiplication.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -29,14 +29,14 @@
 /** @addtogroup genarch
  * @{
- */ 
+ */
 /**
  * @file
  */
 
-#ifndef __SOFTINT_MULTIPLICATION_H__
-#define __SOFTINT_MULTIPLICATION_H__
+#ifndef KERN_MULTIPLICATION_H_
+#define KERN_MULTIPLICATION_H_
 
 /* 64 bit multiplication */
-long long __muldi3(long long a, long long b);
+extern long long __muldi3(long long, long long);
 
 #endif
@@ -44,4 +44,2 @@
 /** @}
  */
-
-
Index: kernel/genarch/src/acpi/acpi.c
===================================================================
--- kernel/genarch/src/acpi/acpi.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/genarch/src/acpi/acpi.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -102,9 +102,9 @@
 
 	/* Start with mapping the header only. */
-	vhdr = (struct acpi_sdt_header *) km_map_structure((uintptr_t) psdt,
+	vhdr = (struct acpi_sdt_header *) km_map((uintptr_t) psdt,
 	    sizeof(struct acpi_sdt_header), PAGE_READ | PAGE_NOT_CACHEABLE); 
 
 	/* Now we can map the entire structure. */
-	vsdt = (struct acpi_sdt_header *) km_map_structure((uintptr_t) psdt,
+	vsdt = (struct acpi_sdt_header *) km_map((uintptr_t) psdt,
 	    vhdr->length, PAGE_WRITE | PAGE_NOT_CACHEABLE);
 	
Index: kernel/genarch/src/ofw/ofw_tree.c
===================================================================
--- kernel/genarch/src/ofw/ofw_tree.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/genarch/src/ofw/ofw_tree.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,4 +38,5 @@
 #include <genarch/ofw/ofw_tree.h>
 #include <mm/slab.h>
+#include <sysinfo/sysinfo.h>
 #include <memstr.h>
 #include <str.h>
@@ -65,7 +66,5 @@
     const char *name)
 {
-	size_t i;
-	
-	for (i = 0; i < node->properties; i++) {
+	for (size_t i = 0; i < node->properties; i++) {
 		if (str_cmp(node->property[i].name, name) == 0)
 			return &node->property[i];
@@ -104,10 +103,8 @@
     const char *name)
 {
-	ofw_tree_node_t *cur;
-	
 	/*
 	 * Try to find the disambigued name.
 	 */
-	for (cur = node->child; cur; cur = cur->peer) {
+	for (ofw_tree_node_t *cur = node->child; cur; cur = cur->peer) {
 		if (str_cmp(cur->da_name, name) == 0)
 			return cur;
@@ -121,5 +118,5 @@
 	 * are not always fully-qualified.
 	 */
-	for (cur = node->child; cur; cur = cur->peer) {
+	for (ofw_tree_node_t *cur = node->child; cur; cur = cur->peer) {
 		if (str_cmp(ofw_tree_node_name(cur), name) == 0)
 			return cur;
@@ -141,7 +138,5 @@
     const char *dtype)
 {
-	ofw_tree_node_t *cur;
-	
-	for (cur = node->child; cur; cur = cur->peer) {
+	for (ofw_tree_node_t *cur = node->child; cur; cur = cur->peer) {
 		ofw_tree_property_t *prop =
 		    ofw_tree_getprop(cur, "device_type");
@@ -172,13 +167,11 @@
     phandle handle)
 {
-	ofw_tree_node_t *cur;
-	
-	for (cur = root; cur; cur = cur->peer) {
+	for (ofw_tree_node_t *cur = root; cur; cur = cur->peer) {
 		if (cur->node_handle == handle)
 			return cur;
 		
 		if (cur->child) {
-			ofw_tree_node_t *node
-			    = ofw_tree_find_node_by_handle(cur->child, handle);
+			ofw_tree_node_t *node =
+			    ofw_tree_find_node_by_handle(cur->child, handle);
 			if (node)
 				return node;
@@ -201,7 +194,5 @@
     const char *dtype)
 {
-	ofw_tree_node_t *cur;
-	
-	for (cur = node->peer; cur; cur = cur->peer) {
+	for (ofw_tree_node_t *cur = node->peer; cur; cur = cur->peer) {
 		ofw_tree_property_t *prop =
 		    ofw_tree_getprop(cur, "device_type");
@@ -229,9 +220,7 @@
     const char *name)
 {
-	ofw_tree_node_t *cur;
-	
-	for (cur = node->peer; cur; cur = cur->peer) {
-		ofw_tree_property_t *prop
-		    = ofw_tree_getprop(cur, "name");
+	for (ofw_tree_node_t *cur = node->peer; cur; cur = cur->peer) {
+		ofw_tree_property_t *prop =
+		    ofw_tree_getprop(cur, "name");
 		
 		if ((!prop) || (!prop->value))
@@ -259,8 +248,7 @@
 	
 	ofw_tree_node_t *node = ofw_root;
-	size_t i;
 	size_t j;
 	
-	for (i = 1; (i < str_size(path)) && (node); i = j + 1) {
+	for (size_t i = 1; (i < str_size(path)) && (node); i = j + 1) {
 		for (j = i; (j < str_size(path)) && (path[j] != '/'); j++);
 		
@@ -294,7 +282,5 @@
     const char *dtype, ofw_tree_walker_t walker, void *arg)
 {
-	ofw_tree_node_t *cur;
-	
-	for (cur = node; cur; cur = cur->peer) {
+	for (ofw_tree_node_t *cur = node; cur; cur = cur->peer) {
 		ofw_tree_property_t *prop =
 		    ofw_tree_getprop(cur, "device_type");
@@ -334,5 +320,58 @@
 }
 
-/** Print OpenFirmware device subtree rooted in a node.
+/** Get OpenFirmware node properties.
+ *
+ * @param item    Sysinfo item (unused).
+ * @param size    Size of the returned data.
+ * @param dry_run Do not get the data, just calculate the size.
+ * @param data    OpenFirmware node.
+ *
+ * @return Data containing a serialized dump of all node
+ *         properties. If the return value is not NULL, it
+ *         should be freed in the context of the sysinfo request.
+ *
+ */
+static void *ofw_sysinfo_properties(struct sysinfo_item *item, size_t *size,
+    bool dry_run, void *data)
+{
+	ofw_tree_node_t *node = (ofw_tree_node_t *) data;
+	
+	/* Compute serialized data size */
+	*size = 0;
+	for (size_t i = 0; i < node->properties; i++)
+		*size += str_size(node->property[i].name) + 1 +
+		    sizeof(node->property[i].size) + node->property[i].size;
+	
+	if (dry_run)
+		return NULL;
+	
+	void *dump = malloc(*size, FRAME_ATOMIC);
+	if (dump == NULL) {
+		*size = 0;
+		return NULL;
+	}
+	
+	/* Serialize the data */
+	size_t pos = 0;
+	for (size_t i = 0; i < node->properties; i++) {
+		/* Property name */
+		str_cpy(dump + pos, *size - pos, node->property[i].name);
+		pos += str_size(node->property[i].name) + 1;
+		
+		/* Value size */
+		memcpy(dump + pos, &node->property[i].size,
+		    sizeof(node->property[i].size));
+		pos += sizeof(node->property[i].size);
+		
+		/* Value */
+		memcpy(dump + pos, node->property[i].value,
+		    node->property[i].size);
+		pos += node->property[i].size;
+	}
+	
+	return ((void *) dump);
+}
+
+/** Map OpenFirmware device subtree rooted in a node into sysinfo.
  *
  * Child nodes are processed recursively and peer nodes are processed
@@ -343,20 +382,19 @@
  *
  */
-static void ofw_tree_node_print(ofw_tree_node_t *node, const char *path)
+static void ofw_tree_node_sysinfo(ofw_tree_node_t *node, const char *path)
 {
 	char *cur_path = (char *) malloc(PATH_MAX_LEN, 0);
-	ofw_tree_node_t *cur;
-	
-	for (cur = node; cur; cur = cur->peer) {
-		if ((cur->parent) && (path)) {
-			snprintf(cur_path, PATH_MAX_LEN, "%s/%s", path, cur->da_name);
-			printf("%s\n", cur_path);
-		} else {
-			snprintf(cur_path, PATH_MAX_LEN, "%s", cur->da_name);
-			printf("/\n");
-		}
+	
+	for (ofw_tree_node_t *cur = node; cur; cur = cur->peer) {
+		if ((cur->parent) && (path))
+			snprintf(cur_path, PATH_MAX_LEN, "%s.%s", path, cur->da_name);
+		else
+			snprintf(cur_path, PATH_MAX_LEN, "firmware.%s", cur->da_name);
+		
+		sysinfo_set_item_gen_data(cur_path, NULL, ofw_sysinfo_properties,
+		    (void *) cur);
 		
 		if (cur->child)
-			ofw_tree_node_print(cur->child, cur_path);
+			ofw_tree_node_sysinfo(cur->child, cur_path);
 	}
 	
@@ -364,8 +402,8 @@
 }
 
-/** Print the structure of the OpenFirmware device tree. */
-void ofw_tree_print(void)
-{
-	ofw_tree_node_print(ofw_root, NULL);
+/** Map the OpenFirmware device tree into sysinfo. */
+void ofw_sysinfo_map(void)
+{
+	ofw_tree_node_sysinfo(ofw_root, NULL);
 }
 
Index: kernel/genarch/src/softint/division.c
===================================================================
--- kernel/genarch/src/softint/division.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/genarch/src/softint/division.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup genarch	
+/** @addtogroup genarch
  * @{
  */
@@ -35,7 +35,7 @@
 #include <genarch/softint/division.h>
 
-#define ABSVAL(x) ((x) > 0 ? (x) : -(x))
-#define SGN(x) ((x) >= 0 ? 1 : 0)
-				      
+#define ABSVAL(x)  ((x) > 0 ? (x) : -(x))
+#define SGN(x)     ((x) >= 0 ? 1 : 0)
+
 static unsigned int divandmod32(unsigned int a, unsigned int b,
     unsigned int *remainder)
@@ -56,5 +56,5 @@
 		return 0;
 	}
-
+	
 	for (; steps > 0; steps--) {
 		/* shift one bit to remainder */
@@ -68,8 +68,7 @@
 		a <<= 1;
 	}
-
+	
 	return result;
 }
-
 
 static unsigned long long divandmod64(unsigned long long a,
@@ -77,5 +76,5 @@
 {
 	unsigned long long result;
-	int steps = sizeof(unsigned long long) * 8; 
+	int steps = sizeof(unsigned long long) * 8;
 	
 	*remainder = 0;
@@ -91,5 +90,5 @@
 		return 0;
 	}
-
+	
 	for (; steps > 0; steps--) {
 		/* shift one bit to remainder */
@@ -103,31 +102,29 @@
 		a <<= 1;
 	}
-
+	
 	return result;
 }
 
 /* 32bit integer division */
-int __divsi3(int a, int b) 
-{
-	unsigned int rem;
-	int result;
-	
-	result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
-
+int __divsi3(int a, int b)
+{
+	unsigned int rem;
+	int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
+	
 	if (SGN(a) == SGN(b))
 		return result;
+	
 	return -result;
 }
 
 /* 64bit integer division */
-long long __divdi3(long long a, long long b) 
-{
-	unsigned long long rem;
-	long long result;
-	
-	result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
-
+long long __divdi3(long long a, long long b)
+{
+	unsigned long long rem;
+	long long result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
+	
 	if (SGN(a) == SGN(b))
 		return result;
+	
 	return -result;
 }
@@ -143,5 +140,5 @@
 unsigned long long __udivdi3(unsigned long long a, unsigned long long b)
 {
-	unsigned long long  rem;
+	unsigned long long rem;
 	return divandmod64(a, b, &rem);
 }
@@ -154,7 +151,6 @@
 	
 	/* if divident is negative, remainder must be too */
-	if (!(SGN(a))) {
+	if (!(SGN(a)))
 		return -((int) rem);
-	}
 	
 	return (int) rem;
@@ -162,5 +158,5 @@
 
 /* 64bit remainder of the signed division */
-long long __moddi3(long long a,long  long b)
+long long __moddi3(long long a, long long b)
 {
 	unsigned long long rem;
@@ -168,7 +164,6 @@
 	
 	/* if divident is negative, remainder must be too */
-	if (!(SGN(a))) {
+	if (!(SGN(a)))
 		return -((long long) rem);
-	}
 	
 	return (long long) rem;
@@ -191,4 +186,38 @@
 }
 
+int __divmodsi3(int a, int b, int *c)
+{
+	unsigned int rem;
+	int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
+	
+	if (SGN(a) == SGN(b)) {
+		*c = rem;
+		return result;
+	}
+	
+	*c = -rem;
+	return -result;
+}
+
+unsigned int __udivmodsi3(unsigned int a, unsigned int b,
+    unsigned int *c)
+{
+	return divandmod32(a, b, c);
+}
+
+long long __divmoddi3(long long a, long long b, long long *c)
+{
+	unsigned long long rem;
+	long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
+	
+	if (SGN(a) == SGN(b)) {
+		*c = rem;
+		return result;
+	}
+	
+	*c = -rem;
+	return -result;
+}
+
 unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b,
     unsigned long long *c)
Index: kernel/genarch/src/softint/multiplication.c
===================================================================
--- kernel/genarch/src/softint/multiplication.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/genarch/src/softint/multiplication.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -29,5 +29,5 @@
 /** @addtogroup genarch
  * @{
- */ 
+ */
 /**
  * @file
@@ -130,5 +130,5 @@
 
 	return result;
-}	
+}
 
 /** @}
Index: kernel/generic/include/context.h
===================================================================
--- kernel/generic/include/context.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/include/context.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -41,6 +41,8 @@
 
 #define context_set_generic(ctx, _pc, stack, size) \
-	(ctx)->pc = (uintptr_t) (_pc); \
-	(ctx)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA;
+	do { \
+		(ctx)->pc = (uintptr_t) (_pc); \
+		(ctx)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \
+	} while (0)
 
 extern int context_save_arch(context_t *ctx) __attribute__((returns_twice));
Index: kernel/generic/include/ddi/irq.h
===================================================================
--- kernel/generic/include/ddi/irq.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/include/ddi/irq.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -134,6 +134,4 @@
 	/** Notification configuration structure. */
 	ipc_notif_cfg_t notif_cfg; 
-	
-	as_t *driver_as;
 } irq_t;
 
Index: kernel/generic/include/ipc/irq.h
===================================================================
--- kernel/generic/include/ipc/irq.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/include/ipc/irq.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -36,5 +36,8 @@
 #define KERN_IPC_IRQ_H_
 
-/** Maximum length of IPC IRQ program */
+/** Maximum number of IPC IRQ programmed I/O ranges. */
+#define IRQ_MAX_RANGE_COUNT	8
+
+/** Maximum length of IPC IRQ program. */
 #define IRQ_MAX_PROG_SIZE  20
 
Index: kernel/generic/include/macros.h
===================================================================
--- kernel/generic/include/macros.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/include/macros.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -69,7 +69,16 @@
     uint64_t sz2)
 {
-	uint64_t e1 = s1 + sz1;
-	uint64_t e2 = s2 + sz2;
-	
+	uint64_t e1;
+	uint64_t e2;
+
+	/* Handle the two corner cases when either sz1 or sz2 are zero. */
+	if (sz1 == 0)
+		return (s1 == s2) && (sz2 == 0);
+	e1 = s1 + sz1 - 1;	
+	if (sz2 == 0)
+		return (s1 <= s2) && (s2 <= e1);
+	e2 = s2 + sz2 - 1;
+
+	/* e1 and e2 are end addresses, the sum is imune to overflow */
 	return ((s1 <= s2) && (e1 >= e2));
 }
Index: kernel/generic/include/mm/km.h
===================================================================
--- kernel/generic/include/mm/km.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/include/mm/km.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -50,5 +50,5 @@
 
 extern uintptr_t km_map(uintptr_t, size_t, unsigned int);
-extern uintptr_t km_map_structure(uintptr_t, size_t, unsigned int);
+extern void km_unmap(uintptr_t, size_t);
 
 extern uintptr_t km_temporary_page_get(uintptr_t *, frame_flags_t);
Index: kernel/generic/include/str.h
===================================================================
--- kernel/generic/include/str.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/include/str.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -97,5 +97,5 @@
 extern bool wstr_remove(wchar_t *str, size_t pos);
 
-extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *);
+extern int str_uint64_t(const char *, char **, unsigned int, bool, uint64_t *);
 
 extern void order_suffix(const uint64_t, uint64_t *, char *);
Index: kernel/generic/include/sysinfo/sysinfo.h
===================================================================
--- kernel/generic/include/sysinfo/sysinfo.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/include/sysinfo/sysinfo.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2006 Jakub Vana
+ * Copyright (c) 2012 Martin Decky
  * All rights reserved.
  *
@@ -54,9 +55,26 @@
 struct sysinfo_item;
 
-/** Gerated numeric value function */
-typedef sysarg_t (*sysinfo_fn_val_t)(struct sysinfo_item *);
+/** Generated numeric value function */
+typedef sysarg_t (*sysinfo_fn_val_t)(struct sysinfo_item *, void *);
+
+/** Sysinfo generated numberic value data
+ *
+ */
+typedef struct {
+	sysinfo_fn_val_t fn;  /**< Generated value function */
+	void *data;           /**< Private data */
+} sysinfo_gen_val_data_t;
 
 /** Generated binary data function */
-typedef void *(*sysinfo_fn_data_t)(struct sysinfo_item *, size_t *, bool);
+typedef void *(*sysinfo_fn_data_t)(struct sysinfo_item *, size_t *, bool,
+    void *);
+
+/** Sysinfo generated binary data data
+ *
+ */
+typedef struct {
+	sysinfo_fn_data_t fn;  /**< Generated binary data function */
+	void *data;            /**< Private data */
+} sysinfo_gen_data_data_t;
 
 /** Sysinfo item binary data
@@ -72,8 +90,8 @@
  */
 typedef union {
-	sysarg_t val;               /**< Constant numberic value */
-	sysinfo_fn_val_t fn_val;    /**< Generated numeric value function */
-	sysinfo_fn_data_t fn_data;  /**< Generated binary data function */
-	sysinfo_data_t data;        /**< Constant binary data */
+	sysarg_t val;                      /**< Constant numberic value */
+	sysinfo_data_t data;               /**< Constant binary data */
+	sysinfo_gen_val_data_t gen_val;    /**< Generated numeric value function */
+	sysinfo_gen_data_data_t gen_data;  /**< Generated binary data function */
 } sysinfo_item_val_t;
 
@@ -95,5 +113,13 @@
 
 /** Generated subtree function */
-typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *, bool);
+typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *, bool, void *);
+
+/** Sysinfo generated subtree data
+ *
+ */
+typedef struct {
+	sysinfo_fn_subtree_t fn;  /**< Generated subtree function */
+	void *data;               /**< Private data */
+} sysinfo_gen_subtree_data_t;
 
 /** Sysinfo subtree (union)
@@ -101,6 +127,6 @@
  */
 typedef union {
-	struct sysinfo_item *table;     /**< Fixed subtree (list of subitems) */
-	sysinfo_fn_subtree_t get_data;  /**< Generated subtree function */
+	struct sysinfo_item *table;            /**< Fixed subtree (list of subitems) */
+	sysinfo_gen_subtree_data_t generator;  /**< Generated subtree */
 } sysinfo_subtree_t;
 
@@ -123,16 +149,18 @@
 extern void sysinfo_set_item_data(const char *, sysinfo_item_t **, void *,
     size_t);
-extern void sysinfo_set_item_fn_val(const char *, sysinfo_item_t **,
-    sysinfo_fn_val_t);
-extern void sysinfo_set_item_fn_data(const char *, sysinfo_item_t **,
-    sysinfo_fn_data_t);
+extern void sysinfo_set_item_gen_val(const char *, sysinfo_item_t **,
+    sysinfo_fn_val_t, void *);
+extern void sysinfo_set_item_gen_data(const char *, sysinfo_item_t **,
+    sysinfo_fn_data_t, void *);
 extern void sysinfo_set_item_undefined(const char *, sysinfo_item_t **);
 
 extern void sysinfo_set_subtree_fn(const char *, sysinfo_item_t **,
-    sysinfo_fn_subtree_t);
+    sysinfo_fn_subtree_t, void *);
 
 extern void sysinfo_init(void);
 extern void sysinfo_dump(sysinfo_item_t *);
 
+extern sysarg_t sys_sysinfo_get_keys_size(void *, size_t, void *);
+extern sysarg_t sys_sysinfo_get_keys(void *, size_t, void *, size_t, size_t *);
 extern sysarg_t sys_sysinfo_get_val_type(void *, size_t);
 extern sysarg_t sys_sysinfo_get_value(void *, size_t, void *);
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/console/cmd.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -906,5 +906,5 @@
 		   ((char *) argv->buffer)[0] <= '9') {
 		uint64_t value;
-		rc = str_uint64((char *) argv->buffer, NULL, 0, true, &value);
+		rc = str_uint64_t((char *) argv->buffer, NULL, 0, true, &value);
 		if (rc == EOK)
 			addr = (uintptr_t) value;
Index: kernel/generic/src/console/console.c
===================================================================
--- kernel/generic/src/console/console.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/console/console.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -57,5 +57,5 @@
 
 /** Kernel log cyclic buffer */
-static wchar_t klog[KLOG_LENGTH] __attribute__ ((aligned (PAGE_SIZE)));
+wchar_t klog[KLOG_LENGTH] __attribute__((aligned(PAGE_SIZE)));
 
 /** Kernel log initialized */
Index: kernel/generic/src/console/kconsole.c
===================================================================
--- kernel/generic/src/console/kconsole.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/console/kconsole.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -472,5 +472,5 @@
 		/* It's a number - convert it */
 		uint64_t value;
-		int rc = str_uint64(text, NULL, 0, true, &value);
+		int rc = str_uint64_t(text, NULL, 0, true, &value);
 		switch (rc) {
 		case EINVAL:
Index: kernel/generic/src/ddi/ddi.c
===================================================================
--- kernel/generic/src/ddi/ddi.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/ddi/ddi.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -166,7 +166,7 @@
 	}
 	
-	if (zones.info[znum].flags & ZONE_FIRMWARE) {
-		/*
-		 * Frames are part of firmware
+	if (zones.info[znum].flags & (ZONE_FIRMWARE | ZONE_RESERVED)) {
+		/*
+		 * Frames are part of firmware or reserved zone
 		 * -> allow mapping for privileged tasks.
 		 */
Index: kernel/generic/src/ipc/irq.c
===================================================================
--- kernel/generic/src/ipc/irq.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/ipc/irq.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -74,4 +74,6 @@
 #include <arch.h>
 #include <mm/slab.h>
+#include <mm/page.h>
+#include <mm/km.h>
 #include <errno.h>
 #include <ddi/irq.h>
@@ -81,4 +83,101 @@
 #include <console/console.h>
 #include <print.h>
+#include <macros.h>
+
+static void ranges_unmap(irq_pio_range_t *ranges, size_t rangecount)
+{
+	size_t i;
+
+	for (i = 0; i < rangecount; i++) {
+#ifdef IO_SPACE_BOUNDARY
+		if ((void *) ranges[i].base >= IO_SPACE_BOUNDARY)
+#endif
+			km_unmap(ranges[i].base, ranges[i].size);
+	}
+}
+
+static int ranges_map_and_apply(irq_pio_range_t *ranges, size_t rangecount,
+    irq_cmd_t *cmds, size_t cmdcount)
+{
+	uintptr_t *pbase;
+	size_t i, j;
+
+	/* Copy the physical base addresses aside. */
+	pbase = malloc(rangecount * sizeof(uintptr_t), 0);
+	for (i = 0; i < rangecount; i++)
+		pbase[i] = ranges[i].base;
+
+	/* Map the PIO ranges into the kernel virtual address space. */
+	for (i = 0; i < rangecount; i++) {
+#ifdef IO_SPACE_BOUNDARY
+		if ((void *) ranges[i].base < IO_SPACE_BOUNDARY)
+			continue;
+#endif
+		ranges[i].base = km_map(pbase[i], ranges[i].size,
+		    PAGE_READ | PAGE_WRITE | PAGE_KERNEL | PAGE_NOT_CACHEABLE);
+		if (!ranges[i].base) {
+			ranges_unmap(ranges, i);
+			free(pbase);
+			return ENOMEM;
+		}
+	}
+
+	/* Rewrite the pseudocode addresses from physical to kernel virtual. */
+	for (i = 0; i < cmdcount; i++) {
+		uintptr_t addr;
+		size_t size;
+
+		/* Process only commands that use an address. */
+		switch (cmds[i].cmd) {
+		case CMD_PIO_READ_8:
+        	case CMD_PIO_WRITE_8:
+        	case CMD_PIO_WRITE_A_8:
+			size = 1;
+			break;
+        	case CMD_PIO_READ_16:
+        	case CMD_PIO_WRITE_16:
+        	case CMD_PIO_WRITE_A_16:
+			size = 2;
+			break;
+        	case CMD_PIO_READ_32:
+        	case CMD_PIO_WRITE_32:
+        	case CMD_PIO_WRITE_A_32:
+			size = 4;
+			break;
+		default:
+			/* Move onto the next command. */
+			continue;
+		}
+
+		addr = (uintptr_t) cmds[i].addr;
+		
+		for (j = 0; j < rangecount; j++) {
+
+			/* Find the matching range. */
+			if (!iswithin(pbase[j], ranges[j].size, addr, size))
+				continue;
+
+			/* Switch the command to a kernel virtual address. */
+			addr -= pbase[j];
+			addr += ranges[j].base;
+
+			cmds[i].addr = (void *) addr;
+			break;
+		}
+
+		if (j == rangecount) {
+			/*
+			 * The address used in this command is outside of all
+			 * defined ranges.
+			 */
+			ranges_unmap(ranges, rangecount);
+			free(pbase);
+			return EINVAL;
+		}
+	}
+
+	free(pbase);
+	return EOK;
+}
 
 /** Free the top-half pseudocode.
@@ -90,4 +189,6 @@
 {
 	if (code) {
+		ranges_unmap(code->ranges, code->rangecount);
+		free(code->ranges);
 		free(code->cmds);
 		free(code);
@@ -104,27 +205,45 @@
 static irq_code_t *code_from_uspace(irq_code_t *ucode)
 {
+	irq_pio_range_t *ranges = NULL;
+	irq_cmd_t *cmds = NULL;
+
 	irq_code_t *code = malloc(sizeof(*code), 0);
 	int rc = copy_from_uspace(code, ucode, sizeof(*code));
-	if (rc != 0) {
-		free(code);
-		return NULL;
-	}
-	
-	if (code->cmdcount > IRQ_MAX_PROG_SIZE) {
-		free(code);
-		return NULL;
-	}
-	
-	irq_cmd_t *ucmds = code->cmds;
-	code->cmds = malloc(sizeof(code->cmds[0]) * code->cmdcount, 0);
-	rc = copy_from_uspace(code->cmds, ucmds,
+	if (rc != EOK)
+		goto error;
+	
+	if ((code->rangecount > IRQ_MAX_RANGE_COUNT) ||
+	    (code->cmdcount > IRQ_MAX_PROG_SIZE))
+		goto error;
+	
+	ranges = malloc(sizeof(code->ranges[0]) * code->rangecount, 0);
+	rc = copy_from_uspace(ranges, code->ranges,
+	    sizeof(code->ranges[0]) * code->rangecount);
+	if (rc != EOK)
+		goto error;
+
+	cmds = malloc(sizeof(code->cmds[0]) * code->cmdcount, 0);
+	rc = copy_from_uspace(cmds, code->cmds,
 	    sizeof(code->cmds[0]) * code->cmdcount);
-	if (rc != 0) {
-		free(code->cmds);
-		free(code);
-		return NULL;
-	}
-	
+	if (rc != EOK)
+		goto error;
+
+	rc = ranges_map_and_apply(ranges, code->rangecount, cmds,
+	    code->cmdcount);
+	if (rc != EOK)
+		goto error;
+
+	code->ranges = ranges;
+	code->cmds = cmds;
+
 	return code;
+
+error:
+	if (cmds)
+		free(cmds);
+	if (ranges)
+		free(ranges);
+	free(code);
+	return NULL;
 }
 
@@ -174,5 +293,4 @@
 	irq->notif_cfg.code = code;
 	irq->notif_cfg.counter = 0;
-	irq->driver_as = AS;
 	
 	/*
@@ -239,7 +357,4 @@
 	
 	ASSERT(irq->notif_cfg.answerbox == box);
-	
-	/* Free up the pseudo code and associated structures. */
-	code_free(irq->notif_cfg.code);
 	
 	/* Remove the IRQ from the answerbox's list. */
@@ -260,4 +375,7 @@
 	irq_spinlock_unlock(&box->irq_lock, false);
 	irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
+	
+	/* Free up the pseudo code and associated structures. */
+	code_free(irq->notif_cfg.code);
 	
 	/* Free up the IRQ structure. */
@@ -307,7 +425,4 @@
 		list_remove(&irq->notif_cfg.link);
 		
-		/* Free up the pseudo code and associated structures. */
-		code_free(irq->notif_cfg.code);
-		
 		/*
 		 * We need to drop the IRQ lock now because hash_table_remove()
@@ -321,6 +436,17 @@
 		/* Remove from the hash table. */
 		hash_table_remove(&irq_uspace_hash_table, key, 2);
-		
+
+		/*
+		 * Release both locks so that we can free the pseudo code.
+		 */
+		irq_spinlock_unlock(&box->irq_lock, false);
+		irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
+
+		code_free(irq->notif_cfg.code);
 		free(irq);
+		
+		/* Reacquire both locks before taking another round. */
+		irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
+		irq_spinlock_lock(&box->irq_lock, false);
 	}
 	
@@ -365,14 +491,6 @@
 		return IRQ_DECLINE;
 	
-	as_t *current_as = AS;
-	if (current_as != irq->driver_as)
-		as_switch(AS, irq->driver_as);
-	
 	for (size_t i = 0; i < code->cmdcount; i++) {
 		uint32_t dstval;
-		void *va;
-		uint8_t val8;
-		uint16_t val16;
-		uint32_t val32;
 		
 		uintptr_t srcarg = code->cmds[i].srcarg;
@@ -431,58 +549,4 @@
 			}
 			break;
-		case CMD_MEM_READ_8:
-			va = code->cmds[i].addr;
-			memcpy_from_uspace(&val8, va, sizeof(val8));
-			if (dstarg)
-				scratch[dstarg] = val8;
-			break;
-		case CMD_MEM_READ_16:
-			va = code->cmds[i].addr;
-			memcpy_from_uspace(&val16, va, sizeof(val16));
-			if (dstarg)
-				scratch[dstarg] = val16;
-			break;
-		case CMD_MEM_READ_32:
-			va = code->cmds[i].addr;
-			memcpy_from_uspace(&val32, va, sizeof(val32));
-			if (dstarg)
-				scratch[dstarg] = val32;
-			break;
-		case CMD_MEM_WRITE_8:
-			val8 = code->cmds[i].value;
-			va = code->cmds[i].addr;
-			memcpy_to_uspace(va, &val8, sizeof(val8));
-			break;
-		case CMD_MEM_WRITE_16:
-			val16 = code->cmds[i].value;
-			va = code->cmds[i].addr;
-			memcpy_to_uspace(va, &val16, sizeof(val16));
-			break;
-		case CMD_MEM_WRITE_32:
-			val32 = code->cmds[i].value;
-			va = code->cmds[i].addr;
-			memcpy_to_uspace(va, &val32, sizeof(val32));
-			break;
-		case CMD_MEM_WRITE_A_8:
-			if (srcarg) {
-				val8 = scratch[srcarg];
-				va = code->cmds[i].addr;
-				memcpy_to_uspace(va, &val8, sizeof(val8));
-			}
-			break;
-		case CMD_MEM_WRITE_A_16:
-			if (srcarg) {
-				val16 = scratch[srcarg];
-				va = code->cmds[i].addr;
-				memcpy_to_uspace(va, &val16, sizeof(val16));
-			}
-			break;
-		case CMD_MEM_WRITE_A_32:
-			if (srcarg) {
-				val32 = scratch[srcarg];
-				va = code->cmds[i].addr;
-				memcpy_to_uspace(va, &val32, sizeof(val32));
-			}
-			break;
 		case CMD_BTEST:
 			if ((srcarg) && (dstarg)) {
@@ -498,17 +562,10 @@
 			break;
 		case CMD_ACCEPT:
-			if (AS != current_as)
-				as_switch(AS, current_as);
 			return IRQ_ACCEPT;
 		case CMD_DECLINE:
 		default:
-			if (AS != current_as)
-				as_switch(AS, current_as);
 			return IRQ_DECLINE;
 		}
 	}
-	
-	if (AS != current_as)
-		as_switch(AS, current_as);
 	
 	return IRQ_DECLINE;
Index: kernel/generic/src/lib/func.c
===================================================================
--- kernel/generic/src/lib/func.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/lib/func.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -53,5 +53,5 @@
 void halt()
 {
-#ifdef CONFIG_DEBUG
+#if (defined(CONFIG_DEBUG)) && (defined(CONFIG_KCONSOLE))
 	bool rundebugger = false;
 	
Index: kernel/generic/src/lib/str.c
===================================================================
--- kernel/generic/src/lib/str.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/lib/str.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -111,4 +111,11 @@
 #include <debug.h>
 #include <macros.h>
+
+/** Check the condition if wchar_t is signed */
+#ifdef WCHAR_IS_UNSIGNED
+	#define WCHAR_SIGNED_CHECK(cond)  (true)
+#else
+	#define WCHAR_SIGNED_CHECK(cond)  (cond)
+#endif
 
 /** Byte mask consisting of lowest @n bits (out of 8) */
@@ -206,8 +213,8 @@
  *
  * @return EOK if the character was encoded successfully, EOVERFLOW if there
- *	   was not enough space in the output buffer or EINVAL if the character
- *	   code was invalid.
- */
-int chr_encode(wchar_t ch, char *str, size_t *offset, size_t size)
+ *         was not enough space in the output buffer or EINVAL if the character
+ *         code was invalid.
+ */
+int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t size)
 {
 	if (*offset >= size)
@@ -427,5 +434,5 @@
 bool ascii_check(wchar_t ch)
 {
-	if ((ch >= 0) && (ch <= 127))
+	if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127))
 		return true;
 	
@@ -440,5 +447,5 @@
 bool chr_check(wchar_t ch)
 {
-	if ((ch >= 0) && (ch <= 1114111))
+	if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111))
 		return true;
 	
@@ -893,5 +900,5 @@
  *
  */
-int str_uint64(const char *nptr, char **endptr, unsigned int base,
+int str_uint64_t(const char *nptr, char **endptr, unsigned int base,
     bool strict, uint64_t *result)
 {
Index: kernel/generic/src/main/main.c
===================================================================
--- kernel/generic/src/main/main.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/main/main.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -221,5 +221,5 @@
 	frame_init();
 	slab_cache_init();
-	ra_init();	
+	ra_init();
 	sysinfo_init();
 	btree_init();
@@ -257,5 +257,5 @@
 		for (i = 0; i < init.cnt; i++)
 			LOG("init[%zu].addr=%p, init[%zu].size=%zu",
-			    i, (void *) init.tasks[i].addr, i, init.tasks[i].size);
+			    i, (void *) init.tasks[i].paddr, i, init.tasks[i].size);
 	} else
 		printf("No init binaries found.\n");
Index: kernel/generic/src/main/version.c
===================================================================
--- kernel/generic/src/main/version.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/main/version.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,5 +38,5 @@
 
 static const char *project = "SPARTAN kernel";
-static const char *copyright = "Copyright (c) 2001-2011 HelenOS project";
+static const char *copyright = STRING(COPYRIGHT);
 static const char *release = STRING(RELEASE);
 static const char *name = STRING(NAME);
Index: kernel/generic/src/mm/frame.c
===================================================================
--- kernel/generic/src/mm/frame.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/mm/frame.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -1270,5 +1270,5 @@
 /** Adjust bounds of physical memory region according to low/high memory split.
  *
- * @param low[in]	If true, the adujstment is performed to make the region
+ * @param low[in]	If true, the adjustment is performed to make the region
  *			fit in the low memory. Otherwise the adjustment is
  *			performed to make the region fit in the high memory.
@@ -1282,5 +1282,5 @@
 bool frame_adjust_zone_bounds(bool low, uintptr_t *basep, size_t *sizep)
 {
-	uintptr_t limit = config.identity_size;
+	uintptr_t limit = KA2PA(config.identity_base) + config.identity_size;
 
 	if (low) {
Index: kernel/generic/src/mm/km.c
===================================================================
--- kernel/generic/src/mm/km.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/mm/km.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -124,17 +124,20 @@
 }
 
-uintptr_t km_map(uintptr_t paddr, size_t size, unsigned int flags)
+static uintptr_t
+km_map_aligned(uintptr_t paddr, size_t size, unsigned int flags)
 {
 	uintptr_t vaddr;
-	size_t asize;
 	size_t align;
 	uintptr_t offs;
 
-	asize = ALIGN_UP(size, PAGE_SIZE);
+	ASSERT(ALIGN_DOWN(paddr, FRAME_SIZE) == paddr);
+	ASSERT(ALIGN_UP(size, FRAME_SIZE) == size);
+
+	/* Enforce natural or at least PAGE_SIZE alignment. */
 	align = ispwr2(size) ? size : (1U << (fnzb(size) + 1));
-	vaddr = km_page_alloc(asize, max(PAGE_SIZE, align));
+	vaddr = km_page_alloc(size, max(PAGE_SIZE, align));
 
 	page_table_lock(AS_KERNEL, true);
-	for (offs = 0; offs < asize; offs += PAGE_SIZE) {
+	for (offs = 0; offs < size; offs += PAGE_SIZE) {
 		page_mapping_insert(AS_KERNEL, vaddr + offs, paddr + offs,
 		    flags);
@@ -145,14 +148,64 @@
 }
 
-uintptr_t km_map_structure(uintptr_t paddr, size_t size, unsigned int flags)
-{
-	size_t offs = paddr - ALIGN_DOWN(paddr, FRAME_SIZE); 
+static void km_unmap_aligned(uintptr_t vaddr, size_t size)
+{
+	uintptr_t offs;
+	ipl_t ipl;
+
+	ASSERT(ALIGN_DOWN(vaddr, PAGE_SIZE) == vaddr);
+	ASSERT(ALIGN_UP(size, PAGE_SIZE) == size);
+
+	page_table_lock(AS_KERNEL, true);
+
+	ipl = tlb_shootdown_start(TLB_INVL_ASID, ASID_KERNEL, 0, 0);
+
+	for (offs = 0; offs < size; offs += PAGE_SIZE)
+		page_mapping_remove(AS_KERNEL, vaddr + offs);
+
+	tlb_invalidate_asid(ASID_KERNEL);
+
+	as_invalidate_translation_cache(AS_KERNEL, 0, -1);
+	tlb_shootdown_finalize(ipl);
+	page_table_unlock(AS_KERNEL, true);
+
+	km_page_free(vaddr, size);
+}
+
+/** Map a piece of physical address space into the virtual address space.
+ *
+ * @param paddr		Physical address to be mapped. May be unaligned.
+ * @param size		Size of area starting at paddr to be mapped.
+ * @param flags		Protection flags to be used for the mapping.
+ *
+ * @return New virtual address mapped to paddr.
+ */
+uintptr_t km_map(uintptr_t paddr, size_t size, unsigned int flags)
+{
 	uintptr_t page;
-
-	page = km_map(ALIGN_DOWN(paddr, FRAME_SIZE), size + offs, flags);
+	size_t offs; 
+
+	offs = paddr - ALIGN_DOWN(paddr, FRAME_SIZE); 
+	page = km_map_aligned(ALIGN_DOWN(paddr, FRAME_SIZE),
+	    ALIGN_UP(size + offs, FRAME_SIZE), flags);
+
 	return page + offs;
 }
 
-/** Unmap kernen non-identity page.
+/** Unmap a piece of virtual address space.
+ *
+ * @param vaddr		Virtual address to be unmapped. May be unaligned, but
+ *			it must a value previously returned by km_map().
+ * @param size		Size of area starting at vaddr to be unmapped.
+ */
+void km_unmap(uintptr_t vaddr, size_t size)
+{
+	size_t offs; 
+
+	offs = vaddr - ALIGN_DOWN(vaddr, PAGE_SIZE); 
+	km_unmap_aligned(ALIGN_DOWN(vaddr, PAGE_SIZE),
+	    ALIGN_UP(size + offs, PAGE_SIZE));
+}
+
+/** Unmap kernel non-identity page.
  *
  * @param[in] page	Non-identity page to be unmapped.
Index: kernel/generic/src/mm/page.c
===================================================================
--- kernel/generic/src/mm/page.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/mm/page.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -168,9 +168,9 @@
 int page_find_mapping(uintptr_t virt, void **phys)
 {
-	mutex_lock(&AS->lock);
+	page_table_lock(AS, true);
 	
 	pte_t *pte = page_mapping_find(AS, virt, false);
 	if ((!PTE_VALID(pte)) || (!PTE_PRESENT(pte))) {
-		mutex_unlock(&AS->lock);
+		page_table_unlock(AS, true);
 		return ENOENT;
 	}
@@ -179,5 +179,5 @@
 	    (virt - ALIGN_DOWN(virt, PAGE_SIZE));
 	
-	mutex_unlock(&AS->lock);
+	page_table_unlock(AS, true);
 	
 	return EOK;
Index: kernel/generic/src/syscall/copy.c
===================================================================
--- kernel/generic/src/syscall/copy.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/syscall/copy.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -56,5 +56,5 @@
  * @param size Size of the data to be copied.
  *
- * @return 0 on success or error code from @ref errno.h.
+ * @return EOK on success or error code from @ref errno.h.
  */
 int copy_from_uspace(void *dst, const void *uspace_src, size_t size)
@@ -94,5 +94,5 @@
 
 	interrupts_restore(ipl);
-	return !rc ? EPERM : 0;
+	return !rc ? EPERM : EOK;
 }
 
Index: kernel/generic/src/syscall/syscall.c
===================================================================
--- kernel/generic/src/syscall/syscall.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/syscall/syscall.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -184,4 +184,6 @@
 	
 	/* Sysinfo syscalls. */
+	(syshandler_t) sys_sysinfo_get_keys_size,
+	(syshandler_t) sys_sysinfo_get_keys,
 	(syshandler_t) sys_sysinfo_get_val_type,
 	(syshandler_t) sys_sysinfo_get_value,
Index: kernel/generic/src/sysinfo/stats.c
===================================================================
--- kernel/generic/src/sysinfo/stats.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/sysinfo/stats.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -83,9 +83,10 @@
  *
  * @param item Sysinfo item (unused).
+ * @param data Unused.
  *
  * @return System uptime (in secords).
  *
  */
-static sysarg_t get_stats_uptime(struct sysinfo_item *item)
+static sysarg_t get_stats_uptime(struct sysinfo_item *item, void *data)
 {
 	/* This doesn't have to be very accurate */
@@ -98,4 +99,5 @@
  * @param size    Size of the returned data.
  * @param dry_run Do not get the data, just calculate the size.
+ * @param data    Unused.
  *
  * @return Data containing several stats_cpu_t structures.
@@ -104,5 +106,5 @@
  */
 static void *get_stats_cpus(struct sysinfo_item *item, size_t *size,
-    bool dry_run)
+    bool dry_run, void *data)
 {
 	*size = sizeof(stats_cpu_t) * config.cpu_count;
@@ -249,5 +251,5 @@
 	ASSERT(interrupts_disabled());
 	ASSERT(irq_spinlock_locked(&task->lock));
-
+	
 	stats_task->task_id = task->taskid;
 	str_cpy(stats_task->name, TASK_NAME_BUFLEN, task->name);
@@ -293,4 +295,5 @@
  * @param size    Size of the returned data.
  * @param dry_run Do not get the data, just calculate the size.
+ * @param data    Unused.
  *
  * @return Data containing several stats_task_t structures.
@@ -299,5 +302,5 @@
  */
 static void *get_stats_tasks(struct sysinfo_item *item, size_t *size,
-    bool dry_run)
+    bool dry_run, void *data)
 {
 	/* Messing with task structures, avoid deadlock */
@@ -350,5 +353,5 @@
 	ASSERT(interrupts_disabled());
 	ASSERT(irq_spinlock_locked(&thread->lock));
-
+	
 	stats_thread->thread_id = thread->tid;
 	stats_thread->task_id = thread->task->taskid;
@@ -398,4 +401,5 @@
  * @param size    Size of the returned data.
  * @param dry_run Do not get the data, just calculate the size.
+ * @param data    Unused.
  *
  * @return Data containing several stats_task_t structures.
@@ -404,5 +408,5 @@
  */
 static void *get_stats_threads(struct sysinfo_item *item, size_t *size,
-    bool dry_run)
+    bool dry_run, void *data)
 {
 	/* Messing with threads structures, avoid deadlock */
@@ -451,4 +455,5 @@
  * @param name    Task ID (string-encoded number).
  * @param dry_run Do not get the data, just calculate the size.
+ * @param data    Unused.
  *
  * @return Sysinfo return holder. The type of the returned
@@ -460,5 +465,6 @@
  *
  */
-static sysinfo_return_t get_stats_task(const char *name, bool dry_run)
+static sysinfo_return_t get_stats_task(const char *name, bool dry_run,
+    void *data)
 {
 	/* Initially no return value */
@@ -468,5 +474,5 @@
 	/* Parse the task ID */
 	task_id_t task_id;
-	if (str_uint64(name, NULL, 0, true, &task_id) != EOK)
+	if (str_uint64_t(name, NULL, 0, true, &task_id) != EOK)
 		return ret;
 	
@@ -520,4 +526,5 @@
  * @param name    Thread ID (string-encoded number).
  * @param dry_run Do not get the data, just calculate the size.
+ * @param data    Unused.
  *
  * @return Sysinfo return holder. The type of the returned
@@ -529,5 +536,6 @@
  *
  */
-static sysinfo_return_t get_stats_thread(const char *name, bool dry_run)
+static sysinfo_return_t get_stats_thread(const char *name, bool dry_run,
+    void *data)
 {
 	/* Initially no return value */
@@ -537,5 +545,5 @@
 	/* Parse the thread ID */
 	thread_id_t thread_id;
-	if (str_uint64(name, NULL, 0, true, &thread_id) != EOK)
+	if (str_uint64_t(name, NULL, 0, true, &thread_id) != EOK)
 		return ret;
 	
@@ -586,4 +594,5 @@
  * @param size    Size of the returned data.
  * @param dry_run Do not get the data, just calculate the size.
+ * @param data    Unused.
  *
  * @return Data containing several stats_exc_t structures.
@@ -592,5 +601,5 @@
  */
 static void *get_stats_exceptions(struct sysinfo_item *item, size_t *size,
-    bool dry_run)
+    bool dry_run, void *data)
 {
 	*size = sizeof(stats_exc_t) * IVT_ITEMS;
@@ -634,4 +643,5 @@
  * @param name    Exception number (string-encoded number).
  * @param dry_run Do not get the data, just calculate the size.
+ * @param data    Unused.
  *
  * @return Sysinfo return holder. The type of the returned
@@ -643,5 +653,6 @@
  *
  */
-static sysinfo_return_t get_stats_exception(const char *name, bool dry_run)
+static sysinfo_return_t get_stats_exception(const char *name, bool dry_run,
+    void *data)
 {
 	/* Initially no return value */
@@ -651,5 +662,5 @@
 	/* Parse the exception number */
 	uint64_t excn;
-	if (str_uint64(name, NULL, 0, true, &excn) != EOK)
+	if (str_uint64_t(name, NULL, 0, true, &excn) != EOK)
 		return ret;
 	
@@ -705,4 +716,5 @@
  * @param size    Size of the returned data.
  * @param dry_run Do not get the data, just calculate the size.
+ * @param data    Unused.
  *
  * @return Data containing stats_physmem_t.
@@ -711,5 +723,5 @@
  */
 static void *get_stats_physmem(struct sysinfo_item *item, size_t *size,
-    bool dry_run)
+    bool dry_run, void *data)
 {
 	*size = sizeof(stats_physmem_t);
@@ -735,4 +747,5 @@
  * @param size    Size of the returned data.
  * @param dry_run Do not get the data, just calculate the size.
+ * @param data    Unused.
  *
  * @return Data several load_t values.
@@ -741,5 +754,5 @@
  */
 static void *get_stats_load(struct sysinfo_item *item, size_t *size,
-    bool dry_run)
+    bool dry_run, void *data)
 {
 	*size = sizeof(load_t) * LOAD_STEPS;
@@ -810,14 +823,14 @@
 	mutex_initialize(&load_lock, MUTEX_PASSIVE);
 	
-	sysinfo_set_item_fn_val("system.uptime", NULL, get_stats_uptime);
-	sysinfo_set_item_fn_data("system.cpus", NULL, get_stats_cpus);
-	sysinfo_set_item_fn_data("system.physmem", NULL, get_stats_physmem);
-	sysinfo_set_item_fn_data("system.load", NULL, get_stats_load);
-	sysinfo_set_item_fn_data("system.tasks", NULL, get_stats_tasks);
-	sysinfo_set_item_fn_data("system.threads", NULL, get_stats_threads);
-	sysinfo_set_item_fn_data("system.exceptions", NULL, get_stats_exceptions);
-	sysinfo_set_subtree_fn("system.tasks", NULL, get_stats_task);
-	sysinfo_set_subtree_fn("system.threads", NULL, get_stats_thread);
-	sysinfo_set_subtree_fn("system.exceptions", NULL, get_stats_exception);
+	sysinfo_set_item_gen_val("system.uptime", NULL, get_stats_uptime, NULL);
+	sysinfo_set_item_gen_data("system.cpus", NULL, get_stats_cpus, NULL);
+	sysinfo_set_item_gen_data("system.physmem", NULL, get_stats_physmem, NULL);
+	sysinfo_set_item_gen_data("system.load", NULL, get_stats_load, NULL);
+	sysinfo_set_item_gen_data("system.tasks", NULL, get_stats_tasks, NULL);
+	sysinfo_set_item_gen_data("system.threads", NULL, get_stats_threads, NULL);
+	sysinfo_set_item_gen_data("system.exceptions", NULL, get_stats_exceptions, NULL);
+	sysinfo_set_subtree_fn("system.tasks", NULL, get_stats_task, NULL);
+	sysinfo_set_subtree_fn("system.threads", NULL, get_stats_thread, NULL);
+	sysinfo_set_subtree_fn("system.exceptions", NULL, get_stats_exception, NULL);
 }
 
Index: kernel/generic/src/sysinfo/sysinfo.c
===================================================================
--- kernel/generic/src/sysinfo/sysinfo.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/generic/src/sysinfo/sysinfo.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2006 Jakub Vana
+ * Copyright (c) 2012 Martin Decky
  * All rights reserved.
  *
@@ -99,5 +100,5 @@
 	    sizeof(sysinfo_item_t), 0, sysinfo_item_constructor,
 	    sysinfo_item_destructor, SLAB_CACHE_MAGDEFERRED);
-
+	
 	mutex_initialize(&sysinfo_lock, MUTEX_ACTIVE);
 }
@@ -110,5 +111,5 @@
  * @param subtree Current sysinfo (sub)tree root item.
  * @param ret     If the return value is NULL, this argument
- *                can be either also NULL (i.e. no item was
+ *                can be set either to NULL (i.e. no item was
  *                found and no data was generated) or the
  *                original pointer is used to store the value
@@ -125,5 +126,4 @@
 {
 	ASSERT(subtree != NULL);
-	ASSERT(ret != NULL);
 	
 	sysinfo_item_t *cur = subtree;
@@ -151,9 +151,14 @@
 			case SYSINFO_SUBTREE_FUNCTION:
 				/* Get generated data */
-				**ret = cur->subtree.get_data(name + i + 1, dry_run);
+				if (ret != NULL)
+					**ret = cur->subtree.generator.fn(name + i + 1,
+					    dry_run, cur->subtree.generator.data);
+				
 				return NULL;
 			default:
 				/* Not found, no data generated */
-				*ret = NULL;
+				if (ret != NULL)
+					*ret = NULL;
+				
 				return NULL;
 			}
@@ -164,5 +169,7 @@
 	
 	/* Not found, no data generated */
-	*ret = NULL;
+	if (ret != NULL)
+		*ret = NULL;
+	
 	return NULL;
 }
@@ -352,8 +359,9 @@
  *             a new root item (NULL for global sysinfo root).
  * @param fn   Numeric value generator function.
- *
- */
-void sysinfo_set_item_fn_val(const char *name, sysinfo_item_t **root,
-    sysinfo_fn_val_t fn)
+ * @param data Private data.
+ *
+ */
+void sysinfo_set_item_gen_val(const char *name, sysinfo_item_t **root,
+    sysinfo_fn_val_t fn, void *data)
 {
 	/* Protect sysinfo tree consistency */
@@ -366,5 +374,6 @@
 	if (item != NULL) {
 		item->val_type = SYSINFO_VAL_FUNCTION_VAL;
-		item->val.fn_val = fn;
+		item->val.gen_val.fn = fn;
+		item->val.gen_val.data = data;
 	}
 	
@@ -383,8 +392,9 @@
  *             a new root item (NULL for global sysinfo root).
  * @param fn   Binary data generator function.
- *
- */
-void sysinfo_set_item_fn_data(const char *name, sysinfo_item_t **root,
-    sysinfo_fn_data_t fn)
+ * @param data Private data.
+ *
+ */
+void sysinfo_set_item_gen_data(const char *name, sysinfo_item_t **root,
+    sysinfo_fn_data_t fn, void *data)
 {
 	/* Protect sysinfo tree consistency */
@@ -397,5 +407,6 @@
 	if (item != NULL) {
 		item->val_type = SYSINFO_VAL_FUNCTION_DATA;
-		item->val.fn_data = fn;
+		item->val.gen_data.fn = fn;
+		item->val.gen_data.data = data;
 	}
 	
@@ -431,8 +442,9 @@
  *             a new root item (NULL for global sysinfo root).
  * @param fn   Subtree generator function.
+ * @param data Private data to be passed to the generator.
  *
  */
 void sysinfo_set_subtree_fn(const char *name, sysinfo_item_t **root,
-    sysinfo_fn_subtree_t fn)
+    sysinfo_fn_subtree_t fn, void *data)
 {
 	/* Protect sysinfo tree consistency */
@@ -448,5 +460,6 @@
 	if ((item != NULL) && (item->subtree_type != SYSINFO_SUBTREE_TABLE)) {
 		item->subtree_type = SYSINFO_SUBTREE_FUNCTION;
-		item->subtree.get_data = fn;
+		item->subtree.generator.fn = fn;
+		item->subtree.generator.data = data;
 	}
 	
@@ -456,12 +469,11 @@
 /** Sysinfo dump indentation helper routine
  *
- * @param depth Number of indentation characters to print.
- *
- */
-NO_TRACE static void sysinfo_indent(unsigned int depth)
-{
-	unsigned int i;
-	for (i = 0; i < depth; i++)
-		printf("  ");
+ * @param depth Number of spaces to print.
+ *
+ */
+NO_TRACE static void sysinfo_indent(size_t spaces)
+{
+	for (size_t i = 0; i < spaces; i++)
+		printf(" ");
 }
 
@@ -470,15 +482,22 @@
  * Should be called with sysinfo_lock held.
  *
- * @param root  Root item of the current (sub)tree.
- * @param depth Current depth in the sysinfo tree.
- *
- */
-NO_TRACE static void sysinfo_dump_internal(sysinfo_item_t *root, unsigned int depth)
-{
-	sysinfo_item_t *cur = root;
-	
+ * @param root   Root item of the current (sub)tree.
+ * @param spaces Current indentation level.
+ *
+ */
+NO_TRACE static void sysinfo_dump_internal(sysinfo_item_t *root, size_t spaces)
+{
 	/* Walk all siblings */
-	while (cur != NULL) {
-		sysinfo_indent(depth);
+	for (sysinfo_item_t *cur = root; cur; cur = cur->next) {
+		size_t length;
+		
+		if (spaces == 0) {
+			printf("%s", cur->name);
+			length = str_length(cur->name);
+		} else {
+			sysinfo_indent(spaces);
+			printf(".%s", cur->name);
+			length = str_length(cur->name) + 1;
+		}
 		
 		sysarg_t val;
@@ -488,24 +507,23 @@
 		switch (cur->val_type) {
 		case SYSINFO_VAL_UNDEFINED:
-			printf("+ %s\n", cur->name);
+			printf(" [undefined]\n");
 			break;
 		case SYSINFO_VAL_VAL:
-			printf("+ %s -> %" PRIun" (%#" PRIxn ")\n", cur->name,
-			    cur->val.val, cur->val.val);
+			printf(" -> %" PRIun" (%#" PRIxn ")\n", cur->val.val,
+			    cur->val.val);
 			break;
 		case SYSINFO_VAL_DATA:
-			printf("+ %s (%zu bytes)\n", cur->name,
-			    cur->val.data.size);
+			printf(" (%zu bytes)\n", cur->val.data.size);
 			break;
 		case SYSINFO_VAL_FUNCTION_VAL:
-			val = cur->val.fn_val(cur);
-			printf("+ %s -> %" PRIun" (%#" PRIxn ") [generated]\n",
-			    cur->name, val, val);
+			val = cur->val.gen_val.fn(cur, cur->val.gen_val.data);
+			printf(" -> %" PRIun" (%#" PRIxn ") [generated]\n", val,
+			    val);
 			break;
 		case SYSINFO_VAL_FUNCTION_DATA:
 			/* N.B.: No data was actually returned (only a dry run) */
-			(void) cur->val.fn_data(cur, &size, true);
-			printf("+ %s (%zu bytes) [generated]\n", cur->name,
-			    size);
+			(void) cur->val.gen_data.fn(cur, &size, true,
+			    cur->val.gen_data.data);
+			printf(" (%zu bytes) [generated]\n", size);
 			break;
 		default:
@@ -518,16 +536,14 @@
 			break;
 		case SYSINFO_SUBTREE_TABLE:
-			sysinfo_dump_internal(cur->subtree.table, depth + 1);
+			sysinfo_dump_internal(cur->subtree.table, spaces + length);
 			break;
 		case SYSINFO_SUBTREE_FUNCTION:
-			sysinfo_indent(depth + 1);
-			printf("+ [generated subtree]\n");
+			sysinfo_indent(spaces + length);
+			printf("<generated subtree>\n");
 			break;
 		default:
-			sysinfo_indent(depth + 1);
-			printf("+ [unknown subtree]\n");
+			sysinfo_indent(spaces + length);
+			printf("<unknown subtree>\n");
 		}
-		
-		cur = cur->next;
 	}
 }
@@ -594,9 +610,9 @@
 			break;
 		case SYSINFO_VAL_FUNCTION_VAL:
-			ret.val = item->val.fn_val(item);
+			ret.val = item->val.gen_val.fn(item, item->val.gen_val.data);
 			break;
 		case SYSINFO_VAL_FUNCTION_DATA:
-			ret.data.data = item->val.fn_data(item, &ret.data.size,
-			    dry_run);
+			ret.data.data = item->val.gen_data.fn(item, &ret.data.size,
+			    dry_run, item->val.gen_data.data);
 			break;
 		}
@@ -635,6 +651,6 @@
 	ASSERT(path);
 	
-	if ((copy_from_uspace(path, ptr, size + 1) == 0)
-	    && (path[size] == 0)) {
+	if ((copy_from_uspace(path, ptr, size + 1) == 0) &&
+	    (path[size] == 0)) {
 		/*
 		 * Prevent other functions from messing with sysinfo while we
@@ -645,6 +661,201 @@
 		mutex_unlock(&sysinfo_lock);
 	}
+	
 	free(path);
 	return ret;
+}
+
+/** Return sysinfo keys determined by name
+ *
+ * Should be called with sysinfo_lock held.
+ *
+ * @param name    Sysinfo path.
+ * @param root    Root item of the sysinfo (sub)tree.
+ *                If it is NULL then consider the global
+ *                sysinfo tree.
+ * @param dry_run Do not actually get any generated
+ *                binary data, just calculate the size.
+ *
+ * @return Item value (constant or generated).
+ *
+ */
+NO_TRACE static sysinfo_return_t sysinfo_get_keys(const char *name,
+    sysinfo_item_t **root, bool dry_run)
+{
+	if (root == NULL)
+		root = &global_root;
+	
+	sysinfo_item_t *subtree = NULL;
+	
+	if (name[0] != 0) {
+		/* Try to find the item */
+		sysinfo_item_t *item =
+		    sysinfo_find_item(name, *root, NULL, dry_run);
+		if ((item != NULL) &&
+		    (item->subtree_type == SYSINFO_SUBTREE_TABLE))
+			subtree = item->subtree.table;
+	} else
+		subtree = *root;
+	
+	sysinfo_return_t ret;
+	
+	if (subtree != NULL) {
+		/*
+		 * Calculate the size of subkeys.
+		 */
+		size_t size = 0;
+		for (sysinfo_item_t *cur = subtree; cur; cur = cur->next)
+			size += str_size(cur->name) + 1;
+		
+		if (dry_run) {
+			ret.tag = SYSINFO_VAL_DATA;
+			ret.data.data = NULL;
+			ret.data.size = size;
+		} else {
+			/* Allocate buffer for subkeys */
+			char *names = (char *) malloc(size, FRAME_ATOMIC);
+			if (names == NULL)
+				return ret;
+			
+			size_t pos = 0;
+			for (sysinfo_item_t *cur = subtree; cur; cur = cur->next) {
+				str_cpy(names + pos, size - pos, cur->name);
+				pos += str_size(cur->name) + 1;
+			}
+			
+			/* Correct return value */
+			ret.tag = SYSINFO_VAL_DATA;
+			ret.data.data = (void *) names;
+			ret.data.size = size;
+		}
+	} else {
+		/* No item in the fixed sysinfo tree */
+		ret.tag = SYSINFO_VAL_UNDEFINED;
+	}
+	
+	return ret;
+}
+
+/** Return sysinfo keys determined by name from user space
+ *
+ * The path string passed from the user space has to be properly
+ * null-terminated (the last passed character must be null).
+ *
+ * @param ptr     Sysinfo path in the user address space.
+ * @param size    Size of the path string.
+ * @param dry_run Do not actually get any generated
+ *                binary data, just calculate the size.
+ *
+ */
+NO_TRACE static sysinfo_return_t sysinfo_get_keys_uspace(void *ptr, size_t size,
+    bool dry_run)
+{
+	sysinfo_return_t ret;
+	ret.tag = SYSINFO_VAL_UNDEFINED;
+	
+	if (size > SYSINFO_MAX_PATH)
+		return ret;
+	
+	char *path = (char *) malloc(size + 1, 0);
+	ASSERT(path);
+	
+	if ((copy_from_uspace(path, ptr, size + 1) == 0) &&
+	    (path[size] == 0)) {
+		/*
+		 * Prevent other functions from messing with sysinfo while we
+		 * are reading it.
+		 */
+		mutex_lock(&sysinfo_lock);
+		ret = sysinfo_get_keys(path, NULL, dry_run);
+		mutex_unlock(&sysinfo_lock);
+	}
+	
+	free(path);
+	return ret;
+}
+
+/** Get the sysinfo keys size (syscall)
+ *
+ * The path string passed from the user space has
+ * to be properly null-terminated (the last passed
+ * character must be null).
+ *
+ * @param path_ptr  Sysinfo path in the user address space.
+ * @param path_size Size of the path string.
+ * @param size_ptr  User space pointer where to store the
+ *                  keys size.
+ *
+ * @return Error code (EOK in case of no error).
+ *
+ */
+sysarg_t sys_sysinfo_get_keys_size(void *path_ptr, size_t path_size,
+    void *size_ptr)
+{
+	int rc;
+	
+	/*
+	 * Get the keys.
+	 *
+	 * N.B.: There is no need to free any potential keys
+	 * since we request a dry run.
+	 */
+	sysinfo_return_t ret =
+	    sysinfo_get_keys_uspace(path_ptr, path_size, true);
+	
+	/* Check return data tag */
+	if (ret.tag == SYSINFO_VAL_DATA)
+		rc = copy_to_uspace(size_ptr, &ret.data.size,
+		    sizeof(ret.data.size));
+	else
+		rc = EINVAL;
+	
+	return (sysarg_t) rc;
+}
+
+/** Get the sysinfo keys (syscall)
+ *
+ * The path string passed from the user space has
+ * to be properly null-terminated (the last passed
+ * character must be null).
+ *
+ * If the user space buffer size does not equal
+ * the actual size of the returned data, the data
+ * is truncated.
+ *
+ * The actual size of data returned is stored to
+ * size_ptr.
+ *
+ * @param path_ptr    Sysinfo path in the user address space.
+ * @param path_size   Size of the path string.
+ * @param buffer_ptr  User space pointer to the buffer where
+ *                    to store the binary data.
+ * @param buffer_size User space buffer size.
+ * @param size_ptr    User space pointer where to store the
+ *                    binary data size.
+ *
+ * @return Error code (EOK in case of no error).
+ *
+ */
+sysarg_t sys_sysinfo_get_keys(void *path_ptr, size_t path_size,
+    void *buffer_ptr, size_t buffer_size, size_t *size_ptr)
+{
+	int rc;
+	
+	/* Get the keys */
+	sysinfo_return_t ret = sysinfo_get_keys_uspace(path_ptr, path_size,
+	    false);
+	
+	/* Check return data tag */
+	if (ret.tag == SYSINFO_VAL_DATA) {
+		size_t size = min(ret.data.size, buffer_size);
+		rc = copy_to_uspace(buffer_ptr, ret.data.data, size);
+		if (rc == EOK)
+			rc = copy_to_uspace(size_ptr, &size, sizeof(size));
+		
+		free(ret.data.data);
+	} else
+		rc = EINVAL;
+	
+	return (sysarg_t) rc;
 }
 
@@ -672,6 +883,6 @@
 	
 	/*
-	 * Map generated value types to constant types (user space does not care
-	 * whether the value is constant or generated).
+	 * Map generated value types to constant types (user space does
+	 * not care whether the value is constant or generated).
 	 */
 	if (ret.tag == SYSINFO_VAL_FUNCTION_VAL)
@@ -701,10 +912,10 @@
 {
 	int rc;
-
+	
 	/*
 	 * Get the item.
 	 *
-	 * N.B.: There is no need to free any potential generated binary data
-	 * since we request a dry run.
+	 * N.B.: There is no need to free any potential generated binary
+	 * data since we request a dry run.
 	 */
 	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
@@ -741,6 +952,6 @@
 	 * Get the item.
 	 *
-	 * N.B.: There is no need to free any potential generated binary data
-	 * since we request a dry run.
+	 * N.B.: There is no need to free any potential generated binary
+	 * data since we request a dry run.
 	 */
 	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
Index: kernel/test/mm/mapping1.c
===================================================================
--- kernel/test/mm/mapping1.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/test/mm/mapping1.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -66,6 +66,10 @@
 		v = *((uint32_t *) page1);
 	
-		if (v != TEST_MAGIC)
+		if (v != TEST_MAGIC) {
+			km_unmap(page0, PAGE_SIZE);
+			km_unmap(page1, PAGE_SIZE);
+			frame_free(frame);
 			return "Criss-cross read does not match the value written.";
+		}
 
 		TPRINTF("Writing zero using the second virtual address.\n");
@@ -77,9 +81,15 @@
 		v = *((uint32_t *) page0);
 	
-		if (v != 0)
+		if (v != 0) {
+			km_unmap(page0, PAGE_SIZE);
+			km_unmap(page1, PAGE_SIZE);
+			frame_free(frame);
 			return "Criss-cross read does not match the value written.";
+		}
 	}
 
-	// FIXME: do not leak frame, page0 and page1
+	km_unmap(page0, PAGE_SIZE);
+	km_unmap(page1, PAGE_SIZE);
+	frame_free(frame);
 	
 	return NULL;
Index: kernel/test/mm/mapping1.def
===================================================================
--- kernel/test/mm/mapping1.def	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ kernel/test/mm/mapping1.def	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -3,4 +3,4 @@
 	"Mapping test",
 	&test_mapping1,
-	false
+	true	
 },
Index: tools/autotool.py
===================================================================
--- tools/autotool.py	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ tools/autotool.py	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -49,5 +49,5 @@
 
 PACKAGE_BINUTILS = "usually part of binutils"
-PACKAGE_GCC = "preferably version 4.5.1 or newer"
+PACKAGE_GCC = "preferably version 4.7.0 or newer"
 PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain"
 
@@ -66,9 +66,22 @@
 
 #define DECLARE_BUILTIN_TYPE(tag, type) \\
-	AUTOTOOL_DECLARE("builtin", "", tag, STRING(type), "", "", sizeof(type));
+	AUTOTOOL_DECLARE("builtin_size", "", tag, STRING(type), "", "", sizeof(type)); \\
+	AUTOTOOL_DECLARE("builtin_sign", "unsigned long long int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned long long int)); \\
+	AUTOTOOL_DECLARE("builtin_sign", "unsigned long int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned long int)); \\
+	AUTOTOOL_DECLARE("builtin_sign", "unsigned int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned int)); \\
+	AUTOTOOL_DECLARE("builtin_sign", "unsigned short int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned short int)); \\
+	AUTOTOOL_DECLARE("builtin_sign", "unsigned char", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned char)); \\
+	AUTOTOOL_DECLARE("builtin_sign", "signed long long int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed long long int)); \\
+	AUTOTOOL_DECLARE("builtin_sign", "signed long int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed long int)); \\
+	AUTOTOOL_DECLARE("builtin_sign", "signed int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed int)); \\
+	AUTOTOOL_DECLARE("builtin_sign", "signed short int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed short int)); \\
+	AUTOTOOL_DECLARE("builtin_sign", "signed char", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed char));
 
 #define DECLARE_INTSIZE(tag, type, strc, conc) \\
 	AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, strc, conc, sizeof(unsigned type)); \\
 	AUTOTOOL_DECLARE("intsize", "signed", tag, #type, strc, conc, sizeof(signed type));
+
+#define DECLARE_FLOATSIZE(tag, type) \\
+	AUTOTOOL_DECLARE("floatsize", "", tag, #type, "", "", sizeof(type));
 
 int main(int argc, char *argv[])
@@ -262,5 +275,5 @@
 	return int(value, base)
 
-def probe_compiler(common, sizes):
+def probe_compiler(common, intsizes, floatsizes):
 	"Generate, compile and parse probing source"
 	
@@ -270,6 +283,9 @@
 	outf.write(PROBE_HEAD)
 	
-	for typedef in sizes:
+	for typedef in intsizes:
 		outf.write("\tDECLARE_INTSIZE(\"%s\", %s, %s, %s);\n" % (typedef['tag'], typedef['type'], typedef['strc'], typedef['conc']))
+	
+	for typedef in floatsizes:
+		outf.write("\nDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
 	
 	outf.write(PROBE_TAIL)
@@ -315,5 +331,8 @@
 	signed_concs = {}
 	
-	builtins = {}
+	float_tags = {}
+	
+	builtin_sizes = {}
+	builtin_signs = {}
 	
 	for j in range(len(lines)):
@@ -352,5 +371,5 @@
 						print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL])
 				
-				if (category == "builtin"):
+				if (category == "floatsize"):
 					try:
 						value_int = decode_value(value)
@@ -358,10 +377,30 @@
 						print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
 					
-					builtins[tag] = {'name': name, 'value': value_int}
-	
-	return {'unsigned_sizes': unsigned_sizes, 'signed_sizes': signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags, 'unsigned_strcs': unsigned_strcs, 'signed_strcs': signed_strcs, 'unsigned_concs': unsigned_concs, 'signed_concs': signed_concs, 'builtins': builtins}
-
-def detect_uints(probe, bytes, tags):
-	"Detect correct types for fixed-size integer types"
+					float_tags[tag] = value_int
+				
+				if (category == "builtin_size"):
+					try:
+						value_int = decode_value(value)
+					except:
+						print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
+					
+					builtin_sizes[tag] = {'name': name, 'value': value_int}
+				
+				if (category == "builtin_sign"):
+					try:
+						value_int = decode_value(value)
+					except:
+						print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
+					
+					if (value_int == 1):
+						if (not tag in builtin_signs):
+							builtin_signs[tag] = strc;
+						elif (builtin_signs[tag] != strc):
+							print_error(["Inconsistent builtin type detection in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
+	
+	return {'unsigned_sizes': unsigned_sizes, 'signed_sizes': signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags, 'unsigned_strcs': unsigned_strcs, 'signed_strcs': signed_strcs, 'unsigned_concs': unsigned_concs, 'signed_concs': signed_concs, 'float_tags': float_tags, 'builtin_sizes': builtin_sizes, 'builtin_signs': builtin_signs}
+
+def detect_sizes(probe, bytes, inttags, floattags):
+	"Detect correct types for fixed-size types"
 	
 	macros = []
@@ -370,25 +409,25 @@
 	for b in bytes:
 		if (not b in probe['unsigned_sizes']):
-			print_error(['Unable to find appropriate unsigned integer type for %u bytes' % b,
+			print_error(['Unable to find appropriate unsigned integer type for %u bytes.' % b,
 			             COMPILER_FAIL])
 		
 		if (not b in probe['signed_sizes']):
-			print_error(['Unable to find appropriate signed integer type for %u bytes' % b,
+			print_error(['Unable to find appropriate signed integer type for %u bytes.' % b,
 			             COMPILER_FAIL])
 		
 		if (not b in probe['unsigned_strcs']):
-			print_error(['Unable to find appropriate unsigned printf formatter for %u bytes' % b,
+			print_error(['Unable to find appropriate unsigned printf formatter for %u bytes.' % b,
 			             COMPILER_FAIL])
 		
 		if (not b in probe['signed_strcs']):
-			print_error(['Unable to find appropriate signed printf formatter for %u bytes' % b,
+			print_error(['Unable to find appropriate signed printf formatter for %u bytes.' % b,
 			             COMPILER_FAIL])
 		
 		if (not b in probe['unsigned_concs']):
-			print_error(['Unable to find appropriate unsigned literal macro for %u bytes' % b,
+			print_error(['Unable to find appropriate unsigned literal macro for %u bytes.' % b,
 			             COMPILER_FAIL])
 		
 		if (not b in probe['signed_concs']):
-			print_error(['Unable to find appropriate signed literal macro for %u bytes' % b,
+			print_error(['Unable to find appropriate signed literal macro for %u bytes.' % b,
 			             COMPILER_FAIL])
 		
@@ -417,8 +456,8 @@
 			macros.append({'oldmacro': "c ## %s" % name, 'newmacro': "INT%u_C(c)" % (b * 8)})
 	
-	for tag in tags:
+	for tag in inttags:
 		newmacro = "U%s" % tag
 		if (not tag in probe['unsigned_tags']):
-			print_error(['Unable to find appropriate size macro for %s' % newmacro,
+			print_error(['Unable to find appropriate size macro for %s.' % newmacro,
 			             COMPILER_FAIL])
 		
@@ -426,7 +465,8 @@
 		macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro})
 		macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro})
+		macros.append({'oldmacro': "1", 'newmacro': 'U%s_SIZE_%s' % (tag, probe['unsigned_tags'][tag] * 8)})
 		
 		newmacro = tag
-		if (not tag in probe['unsigned_tags']):
+		if (not tag in probe['signed_tags']):
 			print_error(['Unable to find appropriate size macro for %s' % newmacro,
 			             COMPILER_FAIL])
@@ -435,8 +475,24 @@
 		macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro})
 		macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro})
+		macros.append({'oldmacro': "1", 'newmacro': '%s_SIZE_%s' % (tag, probe['signed_tags'][tag] * 8)})
+	
+	for tag in floattags:
+		if (not tag in probe['float_tags']):
+			print_error(['Unable to find appropriate size macro for %s' % tag,
+			             COMPILER_FAIL])
+		
+		macros.append({'oldmacro': "1", 'newmacro': '%s_SIZE_%s' % (tag, probe['float_tags'][tag] * 8)})
+	
+	if (not 'size' in probe['builtin_signs']):
+		print_error(['Unable to determine whether size_t is signed or unsigned.',
+		             COMPILER_FAIL])
+	
+	if (probe['builtin_signs']['size'] != 'unsigned'):
+		print_error(['The type size_t is not unsigned.',
+		             COMPILER_FAIL])
 	
 	fnd = True
 	
-	if (not 'wchar' in probe['builtins']):
+	if (not 'wchar' in probe['builtin_sizes']):
 		print_warning(['The compiler does not provide the macro __WCHAR_TYPE__',
 		               'for defining the compiler-native type wchar_t. We are',
@@ -445,5 +501,5 @@
 		fnd = False
 	
-	if (probe['builtins']['wchar']['value'] != 4):
+	if (probe['builtin_sizes']['wchar']['value'] != 4):
 		print_warning(['The compiler provided macro __WCHAR_TYPE__ for defining',
 		               'the compiler-native type wchar_t is not compliant with',
@@ -458,7 +514,16 @@
 		macros.append({'oldmacro': "__WCHAR_TYPE__", 'newmacro': "wchar_t"})
 	
+	if (not 'wchar' in probe['builtin_signs']):
+		print_error(['Unable to determine whether wchar_t is signed or unsigned.',
+		             COMPILER_FAIL])
+	
+	if (probe['builtin_signs']['wchar'] == 'unsigned'):
+		macros.append({'oldmacro': "1", 'newmacro': 'WCHAR_IS_UNSIGNED'})
+	if (probe['builtin_signs']['wchar'] == 'signed'):
+		macros.append({'oldmacro': "1", 'newmacro': 'WCHAR_IS_SIGNED'})
+	
 	fnd = True
 	
-	if (not 'wint' in probe['builtins']):
+	if (not 'wint' in probe['builtin_sizes']):
 		print_warning(['The compiler does not provide the macro __WINT_TYPE__',
 		               'for defining the compiler-native type wint_t. We are',
@@ -467,5 +532,5 @@
 		fnd = False
 	
-	if (probe['builtins']['wint']['value'] != 4):
+	if (probe['builtin_sizes']['wint']['value'] != 4):
 		print_warning(['The compiler provided macro __WINT_TYPE__ for defining',
 		               'the compiler-native type wint_t is not compliant with',
@@ -479,4 +544,13 @@
 	else:
 		macros.append({'oldmacro': "__WINT_TYPE__", 'newmacro': "wint_t"})
+	
+	if (not 'wint' in probe['builtin_signs']):
+		print_error(['Unable to determine whether wint_t is signed or unsigned.',
+		             COMPILER_FAIL])
+	
+	if (probe['builtin_signs']['wint'] == 'unsigned'):
+		macros.append({'oldmacro': "1", 'newmacro': 'WINT_IS_UNSIGNED'})
+	if (probe['builtin_signs']['wint'] == 'signed'):
+		macros.append({'oldmacro': "1", 'newmacro': 'WINT_IS_SIGNED'})
 	
 	return {'macros': macros, 'typedefs': typedefs}
@@ -571,5 +645,5 @@
 				
 				if (config['CROSS_TARGET'] == "arm32"):
-					gnu_target = "arm-linux-gnu"
+					gnu_target = "arm-linux-gnueabi"
 				
 				if (config['CROSS_TARGET'] == "ia32"):
@@ -586,5 +660,5 @@
 			if (config['PLATFORM'] == "arm32"):
 				target = config['PLATFORM']
-				gnu_target = "arm-linux-gnu"
+				gnu_target = "arm-linux-gnueabi"
 			
 			if (config['PLATFORM'] == "ia32"):
@@ -669,8 +743,13 @@
 				{'type': 'short int', 'tag': 'SHORT', 'strc': '"h"', 'conc': '"@"'},
 				{'type': 'char', 'tag': 'CHAR', 'strc': '"hh"', 'conc': '"@@"'}
+			],
+			[
+				{'type': 'long double', 'tag': 'LONG_DOUBLE'},
+				{'type': 'double', 'tag': 'DOUBLE'},
+				{'type': 'float', 'tag': 'FLOAT'}
 			]
 		)
 		
-		maps = detect_uints(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'])
+		maps = detect_sizes(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'], ['LONG_DOUBLE', 'DOUBLE', 'FLOAT'])
 		
 	finally:
Index: tools/check.sh
===================================================================
--- tools/check.sh	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ tools/check.sh	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -66,5 +66,5 @@
 do
 	echo -n ">>>> Building $P... "
-	( make distclean && make PROFILE=$P HANDS_OFF=y $1 ) >>/dev/null 2>>/dev/null
+	( make distclean && make PROFILE=$P HANDS_OFF=y "$@" ) >>/dev/null 2>>/dev/null
 	if [ $? -ne 0 ];
 	then
Index: tools/imgutil.py
===================================================================
--- tools/imgutil.py	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ tools/imgutil.py	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -92,7 +92,10 @@
 		if name in exclude_names:
 			continue
+		
 		item = ItemToPack(path, name)
+		
 		if not (item.is_dir or item.is_file):
 			continue
+		
 		yield item
 
@@ -102,7 +105,9 @@
 	inf = open(item.path, 'rb')
 	rd = 0
+	
 	while (rd < item.size):
 		data = bytes(inf.read(chunk_size))
 		yield data
 		rd += len(data)
+	
 	inf.close()
Index: tools/mkfat.py
===================================================================
--- tools/mkfat.py	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ tools/mkfat.py	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -168,46 +168,124 @@
 """
 
-def mangle_fname(name):
-	# FIXME: filter illegal characters
-	parts = name.split('.')
-	
-	if len(parts) > 0:
-		fname = parts[0]
-	else:
-		fname = ''
-	
-	if len(fname) > 8:
-		sys.stdout.write("mkfat.py: error: Directory entry " + name +
-		    " base name is longer than 8 characters\n")
-		sys.exit(1);
-	
-	return (fname + '          ').upper()[0:8]
-
-def mangle_ext(name):
-	# FIXME: filter illegal characters
-	parts = name.split('.')
-	
-	if len(parts) > 1:
-		ext = parts[1]
-	else:
-		ext = ''
-	
-	if len(parts) > 2:
-		sys.stdout.write("mkfat.py: error: Directory entry " + name +
-		    " has more than one extension\n")
-		sys.exit(1);
-	
-	if len(ext) > 3:
-		sys.stdout.write("mkfat.py: error: Directory entry " + name +
-		    " extension is longer than 3 characters\n")
-		sys.exit(1);
-	
-	return (ext + '   ').upper()[0:3]
-
-def create_dirent(name, directory, cluster, size):
+LFN_DIR_ENTRY = """little:
+	uint8_t seq                /* sequence number */
+	char name1[10]             /* first part of the name */
+	uint8_t attr               /* attributes */
+	uint8_t rec_type           /* LFN record type */
+	uint8_t checksum           /* LFN checksum */
+	char name2[12]             /* second part of the name */
+	uint16_t cluster           /* cluster */
+	char name3[4]              /* third part of the name */
+"""
+
+lchars = set(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+              'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
+              'U', 'V', 'W', 'X', 'Y', 'Z',
+              '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+              '!', '#', '$', '%', '&', '\'', '(', ')', '-', '@',
+              '^', '_', '`', '{', '}', '~', '.'])
+
+def fat_lchars(name):
+	"Filter FAT legal characters"
+	
+	filtered_name = ''
+	filtered = False
+	
+	for char in name.encode('ascii', 'replace').upper():
+		if char in lchars:
+			filtered_name += char
+		else:
+			filtered_name += b'_'
+			filtered = True
+	
+	return (filtered_name, filtered)
+
+def fat_name83(name, name83_list):
+	"Create a 8.3 name for the given name"
+	
+	ascii_name, lfn = fat_lchars(name)
+	ascii_parts = ascii_name.split('.')
+	
+	short_name = ''
+	short_ext = ''
+	
+	if len(ascii_name) > 11:
+		lfn = True
+	
+	if len(ascii_parts) > 0:
+		short_name = ascii_parts[0]
+		if len(short_name) > 8:
+			lfn = True
+	
+	if len(ascii_parts) > 1:
+		short_ext = ascii_parts[-1]
+		if len(short_ext) > 3:
+			lfn = True
+	
+	if len(ascii_parts) > 2:
+		lfn = True
+	
+	if lfn == False:
+		name83_list.append(short_name + '.' + short_ext)
+		return (short_name.ljust(8)[0:8], short_ext.ljust(3)[0:3], False)
+	
+	# For filenames with multiple extensions, we treat the last one
+	# as the actual extension. The rest of the filename is stripped
+	# of dots and concatenated to form the short name
+	for part in ascii_parts[1:-1]:
+		short_name += part
+	
+	for number in range(1, 999999):
+		number_str = ('~' + str(number)).upper()
+		
+		if len(short_name) + len(number_str) > 8:
+			short_name = short_name[0:8 - len(number_str)]
+		
+		short_name += number_str;
+		
+		if not (short_name + '.' + short_ext) in name83_list:
+			break
+	
+	name83_list.append(short_name + '.' + short_ext)
+	return (short_name.ljust(8)[0:8], short_ext.ljust(3)[0:3], True)
+
+def create_lfn_dirent(name, seq, checksum):
+	"Create LFN directory entry"
+	
+	entry = xstruct.create(LFN_DIR_ENTRY)
+	name_rest = name[26:]
+	
+	if len(name_rest) > 0:
+		entry.seq = seq
+	else:
+		entry.seq = seq | 0x40
+	
+	entry.name1 = name[0:10]
+	entry.name2 = name[10:22]
+	entry.name3 = name[22:26]
+	
+	entry.attr = 0x0F
+	entry.rec_type = 0
+	entry.checksum = checksum
+	entry.cluster = 0
+	
+	return (entry, name_rest)
+
+def lfn_checksum(name):
+	"Calculate LFN checksum"
+	
+	checksum = 0
+	for i in range(0, 11):
+		checksum = (((checksum & 1) << 7) + (checksum >> 1) + ord(name[i])) & 0xFF
+	
+	return checksum
+
+def create_dirent(name, name83_list, directory, cluster, size):
+	short_name, short_ext, lfn = fat_name83(name, name83_list)
+	
 	dir_entry = xstruct.create(DIR_ENTRY)
 	
-	dir_entry.name = mangle_fname(name).encode('ascii')
-	dir_entry.ext = mangle_ext(name).encode('ascii')
+	dir_entry.name = short_name
+	dir_entry.ext = short_ext
 	
 	if (directory):
@@ -230,5 +308,20 @@
 		dir_entry.size = size
 	
-	return dir_entry
+	if not lfn:
+		return [dir_entry]
+	
+	long_name = name.encode('utf_16_le')
+	entries = [dir_entry]
+	
+	seq = 1
+	checksum = lfn_checksum(dir_entry.name + dir_entry.ext)
+	
+	while len(long_name) > 0:
+		long_entry, long_name = create_lfn_dirent(long_name, seq, checksum)
+		entries.append(long_entry)
+		seq += 1
+	
+	entries.reverse()
+	return entries
 
 def create_dot_dirent(empty_cluster):
@@ -274,9 +367,10 @@
 	
 	directory = []
-	
-	if (not head):
+	name83_list = []
+	
+	if not head:
 		# Directory cluster preallocation
 		empty_cluster = fat.index(0)
-		fat[empty_cluster] = 0xffff
+		fat[empty_cluster] = 0xFFFF
 		
 		directory.append(create_dot_dirent(empty_cluster))
@@ -285,13 +379,13 @@
 		empty_cluster = 0
 	
-	for item in listdir_items(root):		
+	for item in listdir_items(root):
 		if item.is_file:
 			rv = write_file(item, outf, cluster_size, data_start, fat, reserved_clusters)
-			directory.append(create_dirent(item.name, False, rv[0], rv[1]))
+			directory.extend(create_dirent(item.name, name83_list, False, rv[0], rv[1]))
 		elif item.is_dir:
 			rv = recursion(False, item.path, outf, cluster_size, root_start, data_start, fat, reserved_clusters, dirent_size, empty_cluster)
-			directory.append(create_dirent(item.name, True, rv[0], rv[1]))
-	
-	if (head):
+			directory.extend(create_dirent(item.name, name83_list, True, rv[0], rv[1]))
+	
+	if head:
 		outf.seek(root_start)
 		for dir_entry in directory:
@@ -350,5 +444,5 @@
 	extra_bytes = int(sys.argv[1])
 	
-	path = os.path.abspath(sys.argv[2])
+	path = os.path.abspath(sys.argv[2].decode())
 	if (not os.path.isdir(path)):
 		print("<PATH> must be a directory")
@@ -448,5 +542,5 @@
 	
 	outf.close()
-	
+
 if __name__ == '__main__':
 	main()
Index: tools/toolchain.sh
===================================================================
--- tools/toolchain.sh	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ tools/toolchain.sh	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -53,14 +53,12 @@
 EOF
 
-BINUTILS_VERSION="2.21.1"
-BINUTILS_RELEASE="a"
-GCC_VERSION="4.6.2"
-GDB_VERSION="7.3.1"
+BINUTILS_VERSION="2.22"
+BINUTILS_RELEASE=""
+GCC_VERSION="4.7.0"
+GDB_VERSION="7.4"
 
 BASEDIR="`pwd`"
 BINUTILS="binutils-${BINUTILS_VERSION}${BINUTILS_RELEASE}.tar.bz2"
-GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
-GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
-GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
+GCC="gcc-${GCC_VERSION}.tar.bz2"
 GDB="gdb-${GDB_VERSION}.tar.bz2"
 
@@ -274,9 +272,7 @@
 	GDB_SOURCE="ftp://ftp.gnu.org/gnu/gdb/"
 	
-	download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "bde820eac53fa3a8d8696667418557ad"
-	download_fetch "${GCC_SOURCE}" "${GCC_CORE}" "780f614ab18c7a9066dec6387d7490b2"
-	download_fetch "${GCC_SOURCE}" "${GCC_OBJC}" "94043cc0d08394eddebed73f30ecad89"
-	download_fetch "${GCC_SOURCE}" "${GCC_CPP}" "87ecd60431e41096419dd8a10f76e46b"
-	download_fetch "${GDB_SOURCE}" "${GDB}" "b89a5fac359c618dda97b88645ceab47"
+	download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "ee0f10756c84979622b992a4a61ea3f5"
+	download_fetch "${GCC_SOURCE}" "${GCC}" "2a0f1d99fda235c29d40b561f81d9a77"
+	download_fetch "${GDB_SOURCE}" "${GDB}" "95a9a8305fed4d30a30a6dc28ff9d060"
 }
 
@@ -299,7 +295,5 @@
 	echo ">>> Downloading tarballs"
 	source_check "${BASEDIR}/${BINUTILS}"
-	source_check "${BASEDIR}/${GCC_CORE}"
-	source_check "${BASEDIR}/${GCC_OBJC}"
-	source_check "${BASEDIR}/${GCC_CPP}"
+	source_check "${BASEDIR}/${GCC}"
 	source_check "${BASEDIR}/${GDB}"
 	
@@ -316,7 +310,5 @@
 	
 	unpack_tarball "${BASEDIR}/${BINUTILS}" "binutils"
-	unpack_tarball "${BASEDIR}/${GCC_CORE}" "GCC Core"
-	unpack_tarball "${BASEDIR}/${GCC_OBJC}" "Objective C"
-	unpack_tarball "${BASEDIR}/${GCC_CPP}" "C++"
+	unpack_tarball "${BASEDIR}/${GCC}" "GCC"
 	unpack_tarball "${BASEDIR}/${GDB}" "GDB"
 	
@@ -378,5 +370,5 @@
 	"arm32")
 		prepare
-		build_target "arm32" "arm-linux-gnu"
+		build_target "arm32" "arm-linux-gnueabi"
 		;;
 	"ia32")
@@ -415,5 +407,5 @@
 		prepare
 		build_target "amd64" "amd64-linux-gnu"
-		build_target "arm32" "arm-linux-gnu"
+		build_target "arm32" "arm-linux-gnueabi"
 		build_target "ia32" "i686-pc-linux-gnu"
 		build_target "ia64" "ia64-pc-linux-gnu"
@@ -428,5 +420,5 @@
 		prepare
 		build_target "amd64" "amd64-linux-gnu" &
-		build_target "arm32" "arm-linux-gnu" &
+		build_target "arm32" "arm-linux-gnueabi" &
 		build_target "ia32" "i686-pc-linux-gnu" &
 		build_target "ia64" "ia64-pc-linux-gnu" &
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/Makefile	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -49,4 +49,5 @@
 	app/lsusb \
 	app/mkfat \
+	app/mkexfat \
 	app/mkmfs \
 	app/redir \
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/Makefile.common	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -149,11 +149,11 @@
 endif
 
-ifeq ($(STATIC_BUILD), y)
-BASE_LIBS = $(LIBC_PREFIX)/libc.a $(LIBSOFTINT_PREFIX)/libsoftint.a
-LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
-else
-BASE_LIBS = $(LIBC_PREFIX)/libc.so0 $(LIBSOFTINT_PREFIX)/libsofti.so0
-LFLAGS = -Bdynamic
-LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld
+ifeq ($(STATIC_BUILD),y)
+	BASE_LIBS = $(LIBC_PREFIX)/libc.a $(LIBSOFTINT_PREFIX)/libsoftint.a
+	LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
+else
+	BASE_LIBS = $(LIBC_PREFIX)/libc.so0 $(LIBSOFTINT_PREFIX)/libsofti.so0
+	LFLAGS = -Bdynamic
+	LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld
 endif
 
Index: uspace/app/bdsh/cmds/modules/cat/cat.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cat/cat.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/bdsh/cmds/modules/cat/cat.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -52,6 +52,6 @@
 #define CAT_VERSION "0.0.1"
 #define CAT_DEFAULT_BUFLEN 1024
-
-static const char *cat_oops = "That option is not yet supported\n";
+#define CAT_FULL_FILE 0
+
 static const char *hexchars = "0123456789abcdef";
 
@@ -163,10 +163,12 @@
 }
 
-static unsigned int cat_file(const char *fname, size_t blen, bool hex)
+static unsigned int cat_file(const char *fname, size_t blen, bool hex,
+    off64_t head, off64_t tail, bool tail_first)
 {
 	int fd, bytes = 0, count = 0, reads = 0;
 	char *buff = NULL;
 	int i;
-	size_t offset = 0;
+	size_t offset = 0, copied_bytes = 0;
+	off64_t file_size = 0, length = 0;
 
 	fd = open(fname, O_RDONLY);
@@ -183,8 +185,34 @@
 	}
 
+	if (tail != CAT_FULL_FILE) {
+		file_size = lseek(fd, 0, SEEK_END);
+		if (head == CAT_FULL_FILE) {
+			head = file_size;
+			length = tail;
+		} else if (tail_first) {
+			length = head;
+		} else {
+			if (tail > head)
+				tail = head;
+			length = tail;
+		}
+
+		if (tail_first) {
+			lseek(fd, (tail >= file_size) ? 0 : (file_size - tail), SEEK_SET);
+		} else {
+			lseek(fd, ((head - tail) >= file_size) ? 0 : (head - tail), SEEK_SET);
+		}
+	} else
+		length = head;
+
 	do {
-		bytes = read(fd, buff, blen);
+		bytes = read(fd, buff + copied_bytes, (
+			(length != CAT_FULL_FILE && length - (off64_t)count <= (off64_t)(blen - copied_bytes)) ?
+			(size_t)(length - count) :
+			(blen - copied_bytes) ) );
+		bytes += copied_bytes;
+		copied_bytes = 0;
+
 		if (bytes > 0) {
-			count += bytes;
 			buff[bytes] = '\0';
 			offset = 0;
@@ -193,4 +221,5 @@
 					paged_char(hexchars[((uint8_t)buff[i])/16]);
 					paged_char(hexchars[((uint8_t)buff[i])%16]);
+					paged_char(((count+i+1) & 0xf) == 0 ? '\n' : ' ');
 				}
 				else {
@@ -199,4 +228,10 @@
 						/* Reached end of string */
 						break;
+					} else if (c == U_SPECIAL && offset + 2 >= (size_t)bytes) {
+						/* If an extended character is cut off due to the size of the buffer,
+						   we will copy it over to the next buffer so it can be read correctly. */
+						copied_bytes = bytes - offset + 1;
+						memcpy(buff, buff + offset - 1, copied_bytes);
+						break;
 					}
 					paged_char(c);
@@ -204,7 +239,8 @@
 				
 			}
+			count += bytes;
 			reads++;
 		}
-	} while (bytes > 0 && !should_quit);
+	} while (bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE));
 
 	close(fd);
@@ -223,8 +259,11 @@
 int cmd_cat(char **argv)
 {
-	unsigned int argc, i, ret = 0, buffer = 0;
+	unsigned int argc, i, ret = 0;
+	size_t buffer = 0;
 	int c, opt_ind;
+	aoff64_t head = CAT_FULL_FILE, tail = CAT_FULL_FILE;
 	bool hex = false;
 	bool more = false;
+	bool tailFirst = false;
 	sysarg_t rows, cols;
 	int rc;
@@ -254,11 +293,22 @@
 			return CMD_SUCCESS;
 		case 'H':
-			printf("%s", cat_oops);
-			return CMD_FAILURE;
+			if (!optarg || str_uint64_t(optarg, NULL, 10, false, &head) != EOK ) {
+				puts("Invalid head size\n");
+				return CMD_FAILURE;
+			}
+			break;
 		case 't':
-			printf("%s", cat_oops);
-			return CMD_FAILURE;
+			if (!optarg || str_uint64_t(optarg, NULL, 10, false, &tail) != EOK ) {
+				puts("Invalid tail size\n");
+				return CMD_FAILURE;
+			}
+			if (head == CAT_FULL_FILE)
+				tailFirst = true;
+			break;
 		case 'b':
-			printf("%s", cat_oops);
+			if (!optarg || str_size_t(optarg, NULL, 10, false, &buffer) != EOK ) {
+				puts("Invalid buffer size\n");
+				return CMD_FAILURE;
+			}
 			break;
 		case 'm':
@@ -279,5 +329,5 @@
 	}
 
-	if (buffer <= 0)
+	if (buffer < 4)
 		buffer = CAT_DEFAULT_BUFLEN;
 	
@@ -295,5 +345,5 @@
 
 	for (i = optind; argv[i] != NULL && !should_quit; i++)
-		ret += cat_file(argv[i], buffer, hex);
+		ret += cat_file(argv[i], buffer, hex, head, tail, tailFirst);
 
 	if (ret)
Index: uspace/app/bdsh/cmds/modules/cat/cat.h
===================================================================
--- uspace/app/bdsh/cmds/modules/cat/cat.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/bdsh/cmds/modules/cat/cat.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -4,5 +4,5 @@
 /* Prototypes for the cat command, excluding entry points */
 
-static unsigned int cat_file(const char *, size_t, bool);
+static unsigned int cat_file(const char *, size_t, bool, off64_t, off64_t, bool);
 
 #endif /* CAT_H */
Index: uspace/app/bdsh/cmds/modules/ls/ls.c
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/bdsh/cmds/modules/ls/ls.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -42,4 +42,5 @@
 #include <sort.h>
 
+#include "ls.h"
 #include "errors.h"
 #include "config.h"
@@ -48,26 +49,30 @@
 #include "cmds.h"
 
-/* Various values that can be returned by ls_scope() */
-#define LS_BOGUS 0
-#define LS_FILE  1
-#define LS_DIR   2
-
-/** Structure to represent a directory entry.
- *
- * Useful to keep together important information
- * for sorting directory entries.
- */
-struct dir_elem_t {
-	char *name;
-	struct stat s;
-};
-
 static const char *cmdname = "ls";
+
+static ls_job_t ls;
 
 static struct option const long_options[] = {
 	{ "help", no_argument, 0, 'h' },
 	{ "unsort", no_argument, 0, 'u' },
+	{ "recursive", no_argument, 0, 'r' },
 	{ 0, 0, 0, 0 }
 };
+
+/* Prototypes for the ls command, excluding entry points. */
+static unsigned int ls_start(ls_job_t *);
+static void ls_print(struct dir_elem_t *);
+static int ls_cmp(void *, void *, void *);
+static signed int ls_scan_dir(const char *, DIR *, struct dir_elem_t **);
+static unsigned int ls_recursive(const char *, DIR *);
+static unsigned int ls_scope(const char *, struct dir_elem_t *);
+
+static unsigned int ls_start(ls_job_t *ls)
+{
+	ls->recursive = 0;
+	ls->sort = 1;
+
+	return 1;
+}
 
 /** Print an entry.
@@ -92,5 +97,4 @@
 }
 
-
 /** Compare 2 directory elements.
  *
@@ -127,5 +131,6 @@
  *				0 otherwise.
  */
-static void ls_scan_dir(const char *d, DIR *dirp, int sort)
+static signed int ls_scan_dir(const char *d, DIR *dirp, 
+    struct dir_elem_t **dir_list_ptr)
 {
 	int alloc_blocks = 20;
@@ -140,10 +145,10 @@
 	
 	if (!dirp)
-		return;
+		return -1;
 
 	buff = (char *) malloc(PATH_MAX);
 	if (!buff) {
 		cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
-		return;
+		return -1;
 	}
 	
@@ -152,5 +157,5 @@
 		cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
 		free(buff);
-		return;
+		return -1;
 	}
 	
@@ -187,5 +192,5 @@
 	}
 	
-	if (sort) {
+	if (ls.sort) {
 		if (!qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t),
 		    ls_cmp, NULL)) {
@@ -196,4 +201,23 @@
 	for (i = 0; i < nbdirs; i++)
 		ls_print(&tosort[i]);
+
+	/* Populate the directory list. */
+	if (ls.recursive) {
+		tmp = (struct dir_elem_t *) realloc(*dir_list_ptr, 
+		    nbdirs * sizeof(struct dir_elem_t));
+		if (!tmp) {
+			cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
+			goto out;
+		} 
+		*dir_list_ptr = tmp;
+
+		for (i = 0; i < nbdirs; i++) {
+			(*dir_list_ptr)[i].name = str_dup(tosort[i].name);
+			if (!(*dir_list_ptr)[i].name) {
+				cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
+				goto out;
+			}
+		}
+	}
 	
 out:
@@ -202,4 +226,103 @@
 	free(tosort);
 	free(buff);
+
+	return nbdirs;
+}
+
+/** Visit a directory recursively.
+ *
+ * ls_recursive visits all the subdirectories recursively and
+ * prints the files and directories in them.
+ *
+ * @param path	Path the current directory being visited.
+ * @param dirp	Directory stream.
+ */
+static unsigned int ls_recursive(const char *path, DIR *dirp)
+{
+	int i, nbdirs, ret;
+	unsigned int scope;
+	char *subdir_path;
+	DIR *subdirp;
+	struct dir_elem_t *dir_list;
+	
+	const char * const trailing_slash = "/";
+
+	nbdirs = 0;
+	dir_list = (struct dir_elem_t *) malloc(sizeof(struct dir_elem_t));
+
+	printf("\n%s:\n", path);
+
+	subdir_path = (char *) malloc(PATH_MAX);
+	if (!subdir_path) {
+		ret = CMD_FAILURE;
+		goto out;
+	}
+
+	nbdirs = ls_scan_dir(path, dirp, &dir_list); 
+	if (nbdirs == -1) {
+		ret = CMD_FAILURE;
+		goto out;
+	}
+
+	for (i = 0; i < nbdirs; ++i) {
+		memset(subdir_path, 0, PATH_MAX);
+
+		if (str_size(subdir_path) + str_size(path) + 1 <= PATH_MAX)
+			str_append(subdir_path, PATH_MAX, path);
+		if (path[str_size(path)-1] != '/' &&
+		    str_size(subdir_path) + str_size(trailing_slash) + 1 <= PATH_MAX)
+			str_append(subdir_path, PATH_MAX, trailing_slash);
+		if (str_size(subdir_path) +
+		    str_size(dir_list[i].name) + 1 <= PATH_MAX)
+			str_append(subdir_path, PATH_MAX, dir_list[i].name);
+
+		scope = ls_scope(subdir_path, &dir_list[i]);
+		switch (scope) {
+		case LS_FILE:
+			break;
+		case LS_DIR:
+			subdirp = opendir(subdir_path);
+			if (!subdirp) {
+				/* May have been deleted between scoping it and opening it */
+				cli_error(CL_EFAIL, "Could not stat %s", dir_list[i].name);
+				ret = CMD_FAILURE;
+				goto out;
+			}
+
+			ret = ls_recursive(subdir_path, subdirp);
+			closedir(subdirp);
+			if (ret == CMD_FAILURE)
+				goto out;
+			break;
+		case LS_BOGUS:
+			ret = CMD_FAILURE;
+			goto out;
+		}	
+	}
+   
+	ret = CMD_SUCCESS; 
+
+out:
+	for (i = 0; i < nbdirs; i++)
+		free(dir_list[i].name);
+	free(dir_list);
+	free(subdir_path);
+
+	return ret;
+}
+
+static unsigned int ls_scope(const char *path, struct dir_elem_t *de)
+{
+	if (stat(path, &de->s)) {
+		cli_error(CL_ENOENT, path);
+		return LS_BOGUS;
+	}
+
+	if (de->s.is_file)
+		return LS_FILE;
+	else if (de->s.is_directory)
+		return LS_DIR;
+
+	return LS_BOGUS;
 }
 
@@ -215,5 +338,6 @@
 		"Options:\n"
 		"  -h, --help       A short option summary\n"
-		"  -u, --unsort     Do not sort directory entries\n",
+		"  -u, --unsort     Do not sort directory entries\n"
+		"  -r, --recursive  List subdirectories recursively\n",
 		cmdname);
 	}
@@ -228,10 +352,16 @@
 	DIR *dirp;
 	int c, opt_ind;
-	int sort = 1;
+	int ret = 0;
+	unsigned int scope;
+
+	if (!ls_start(&ls)) {
+		cli_error(CL_EFAIL, "%s: Could not initialize", cmdname);
+		return CMD_FAILURE;
+	}
 
 	argc = cli_count_args(argv);
 	
 	for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
-		c = getopt_long(argc, argv, "hu", long_options, &opt_ind);
+		c = getopt_long(argc, argv, "hur", long_options, &opt_ind);
 		switch (c) {
 		case 'h':
@@ -239,5 +369,8 @@
 			return CMD_SUCCESS;
 		case 'u':
-			sort = 0;
+			ls.sort = 0;
+			break;
+		case 'r':
+			ls.recursive = 1;
 			break;
 		}
@@ -251,5 +384,5 @@
 		return CMD_FAILURE;
 	}
-	memset(de.name, 0, sizeof(PATH_MAX));
+	memset(de.name, 0, PATH_MAX);
 	
 	if (argc == 0)
@@ -257,14 +390,11 @@
 	else
 		str_cpy(de.name, PATH_MAX, argv[optind]);
-	
-	if (stat(de.name, &de.s)) {
-		cli_error(CL_ENOENT, de.name);
-		free(de.name);
-		return CMD_FAILURE;
-	}
-
-	if (de.s.is_file) {
+
+	scope = ls_scope(de.name, &de);
+	switch (scope) {
+	case LS_FILE:
 		ls_print(&de);
-	} else {
+		break;
+	case LS_DIR:
 		dirp = opendir(de.name);
 		if (!dirp) {
@@ -274,11 +404,21 @@
 			return CMD_FAILURE;
 		}
-		ls_scan_dir(de.name, dirp, sort);
+		if (ls.recursive)
+			ret = ls_recursive(de.name, dirp);
+		else  
+			ret = ls_scan_dir(de.name, dirp, NULL);
+
 		closedir(dirp);
+		break;
+	case LS_BOGUS:
+		return CMD_FAILURE;
 	}
 
 	free(de.name);
 
-	return CMD_SUCCESS;
-}
-
+	if (ret == -1 || ret == CMD_FAILURE)
+		return CMD_FAILURE;
+	else
+		return CMD_SUCCESS;
+}
+
Index: uspace/app/bdsh/cmds/modules/ls/ls.h
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/app/bdsh/cmds/modules/ls/ls.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,26 @@
+#ifndef LS_H
+#define LS_H
+
+/* Various values that can be returned by ls_scope() */
+#define LS_BOGUS 0
+#define LS_FILE  1
+#define LS_DIR   2
+
+typedef struct {
+	/* Options set at runtime. */
+	unsigned int recursive;
+	unsigned int sort;
+
+} ls_job_t;
+
+/** Structure to represent a directory entry.
+ *
+ * Useful to keep together important information
+ * for sorting directory entries.
+ */
+struct dir_elem_t {
+	char *name;
+	struct stat s;
+};
+
+#endif
Index: uspace/app/bdsh/cmds/modules/touch/entry.h
===================================================================
--- uspace/app/bdsh/cmds/modules/touch/entry.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/bdsh/cmds/modules/touch/entry.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -7,3 +7,2 @@
 
 #endif /* TOUCH_ENTRY_H */
-
Index: uspace/app/bdsh/cmds/modules/touch/touch.c
===================================================================
--- uspace/app/bdsh/cmds/modules/touch/touch.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/bdsh/cmds/modules/touch/touch.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -27,6 +27,8 @@
  */
 
-/* TODO: Options that people would expect, such as not creating the file if
- * it doesn't exist, specifying the access time, etc */
+/*
+ * TODO: Options that people would expect, such as specifying the access time,
+ * etc.
+ */
 
 #include <stdio.h>
@@ -37,4 +39,7 @@
 #include <sys/types.h>
 #include <str.h>
+#include <getopt.h>
+#include <sys/stat.h>
+#include <errno.h>
 
 #include "config.h"
@@ -47,15 +52,24 @@
 static const char *cmdname = "touch";
 
+static struct option const long_options[] = {
+	{ "no-create", no_argument, 0, 'c' },
+	{ 0, 0, 0, 0 }
+};
+
 /* Dispays help for touch in various levels */
 void help_cmd_touch(unsigned int level)
 {
 	if (level == HELP_SHORT) {
-		printf("`%s' updates access times for files\n", cmdname);
+		printf("`%s' updates access times of files\n", cmdname);
 	} else {
 		help_cmd_touch(HELP_SHORT);
-		printf("  `%s' <file>, if the file does not exist it will be "
-				"created\n", cmdname);
+		printf("Usage: `%s' [-c|--no-create] <file>...\n\n"
+		    "If the file does not exist it will be created empty,\n"
+		    "unless -c (--no-create) is supplied.\n\n"
+		    "Options:\n"
+		    "   -c, --no-create  Do not create new files\n",
+		    cmdname);
 	}
-
+	
 	return;
 }
@@ -64,39 +78,65 @@
 int cmd_touch(char **argv)
 {
-	unsigned int argc, i = 0, ret = 0;
-	int fd;
+	unsigned int argc = cli_count_args(argv);
+	unsigned int i = 0;
+	unsigned int ret = 0;
+	int c;
+	int longind;
+	bool no_create = false;
+	struct stat file_stat;
+	int fd = -1;
 	char *buff = NULL;
-
+	
 	DIR *dirp;
-
-	argc = cli_count_args(argv);
-
-	if (argc == 1) {
-		printf("%s - incorrect number of arguments. Try `help %s extended'\n",
-			cmdname, cmdname);
+	
+	for (c = 0, optind = 0, longind = 0; c != -1; ) {
+		c = getopt_long(argc, argv, "c", long_options, &longind);
+		switch (c) {
+		case 'c':
+			no_create = true;
+			break;
+		}
+	}
+	
+	if (argc - optind < 1) {
+		printf("%s: Incorrect number of arguments. Try `help %s extended'\n",
+		    cmdname, cmdname);
 		return CMD_FAILURE;
 	}
-
-	for (i = 1; i < argc; i ++) {
+	
+	for (i = optind; argv[i] != NULL; i++) {
 		buff = str_dup(argv[i]);
+		if (buff == NULL) {
+			cli_error(CL_ENOMEM, "Out of memory");
+			ret++;
+			continue;
+		}
+		
 		dirp = opendir(buff);
 		if (dirp) {
-			cli_error(CL_ENOTSUP, "%s is a directory", buff);
+			cli_error(CL_ENOTSUP, "`%s' is a directory", buff);
 			closedir(dirp);
-			ret ++;
+			free(buff);
+			ret++;
 			continue;
 		}
-
-		fd = open(buff, O_RDWR | O_CREAT);
+		
+		/* Check whether file exists if -c (--no-create) option is given */
+		if ((!no_create) || ((no_create) && (stat(buff, &file_stat) == EOK)))
+			fd = open(buff, O_RDWR | O_CREAT);
+		
 		if (fd < 0) {
-			cli_error(CL_EFAIL, "Could not update / create %s ", buff);
-			ret ++;
+			cli_error(CL_EFAIL, "Could not update or create `%s'", buff);
+			free(buff);
+			ret++;
 			continue;
-		} else
+		} else {
 			close(fd);
-
+			fd = -1;
+		}
+		
 		free(buff);
 	}
-
+	
 	if (ret)
 		return CMD_FAILURE;
@@ -104,3 +144,2 @@
 		return CMD_SUCCESS;
 }
-
Index: uspace/app/bdsh/cmds/modules/touch/touch.h
===================================================================
--- uspace/app/bdsh/cmds/modules/touch/touch.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/bdsh/cmds/modules/touch/touch.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -4,5 +4,3 @@
 /* Prototypes for the touch command, excluding entry points */
 
-
 #endif /* TOUCH_H */
-
Index: uspace/app/bdsh/cmds/modules/touch/touch_def.h
===================================================================
--- uspace/app/bdsh/cmds/modules/touch/touch_def.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/bdsh/cmds/modules/touch/touch_def.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -5,3 +5,2 @@
 	&help_cmd_touch,
 },
-
Index: uspace/app/binutils/Makefile
===================================================================
--- uspace/app/binutils/Makefile	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/binutils/Makefile	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -112,5 +112,5 @@
 endif
 ifeq ($(PLATFORM),arm32)
-TARGET = arm-linux-gnu
+TARGET = arm-linux-gnueabi
 endif
 ifeq ($(PLATFORM),ia32)
Index: uspace/app/getterm/Makefile
===================================================================
--- uspace/app/getterm/Makefile	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/getterm/Makefile	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -29,5 +29,5 @@
 
 USPACE_PREFIX = ../..
-DEFS = -DRELEASE=$(RELEASE) "-DNAME=$(NAME)"
+DEFS = -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)"
 BINARY = getterm
 
Index: uspace/app/getterm/version.c
===================================================================
--- uspace/app/getterm/version.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/getterm/version.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -40,4 +40,5 @@
 #include "version.h"
 
+static const char *copyright = STRING(COPYRIGHT);
 static const char *release = STRING(RELEASE);
 static const char *name = STRING(NAME);
@@ -61,5 +62,5 @@
 	printf("HelenOS release %s (%s)%s%s\n", release, name, revision, timestamp);
 	printf("Running on %s (%s)\n", arch, term);
-	printf("Copyright (c) 2001-2011 HelenOS project\n\n");
+	printf("%s\n\n", copyright);
 }
 
Index: uspace/app/mkexfat/Makefile
===================================================================
--- uspace/app/mkexfat/Makefile	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/app/mkexfat/Makefile	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2012 Maurizio Lombardi
+# 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.
+#
+
+USPACE_PREFIX = ../..
+LIBS = $(LIBBLOCK_PREFIX)/libblock.a
+EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX)
+BINARY = mkexfat
+
+SOURCES = \
+	mkexfat.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/app/mkexfat/exfat.h
===================================================================
--- uspace/app/mkexfat/exfat.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/app/mkexfat/exfat.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2008 Jakub Jermar
+ * Copyright (c) 2011 Oleg Romanenko
+ * 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 fs
+ * @{
+ */
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <bool.h>
+
+#define EXFAT_FILENAME_LEN	255
+#define EXFAT_NAME_PART_LEN	15
+
+#define EXFAT_TYPE_UNUSED	0x00
+#define EXFAT_TYPE_USED		0x80
+#define EXFAT_TYPE_VOLLABEL	0x83
+#define EXFAT_TYPE_BITMAP	0x81
+#define EXFAT_TYPE_UCTABLE	0x82
+#define EXFAT_TYPE_GUID		0xA0
+#define EXFAT_TYPE_FILE		0x85
+#define EXFAT_TYPE_STREAM	0xC0
+#define EXFAT_TYPE_NAME		0xC1
+
+#define EXFAT_ATTR_RDONLY	0x01
+#define EXFAT_ATTR_HIDDEN	0x02
+#define EXFAT_ATTR_SYSTEM	0x04
+#define EXFAT_ATTR_SUBDIR	0x10
+#define EXFAT_ATTR_ARCHIVE	0x20
+
+
+/* All dentry structs should have 31 byte size */
+typedef struct {
+	uint8_t 	size;
+	uint16_t 	label[11];
+	uint8_t 	_reserved[8];
+} __attribute__ ((packed)) exfat_vollabel_dentry_t;
+
+typedef struct {
+	uint8_t 	flags;
+	uint8_t 	_reserved[18];
+	uint32_t 	firstc;
+	uint64_t 	size;
+} __attribute__ ((packed)) exfat_bitmap_dentry_t;
+
+typedef struct {
+	uint8_t 	_reserved1[3];
+	uint32_t 	checksum;
+	uint8_t 	_reserved2[12];
+	uint32_t 	firstc;
+	uint64_t 	size;
+} __attribute__ ((packed)) exfat_uctable_dentry_t;
+
+typedef struct {
+	uint8_t 	count; /* Always zero */ 
+	uint16_t 	checksum;
+	uint16_t 	flags;
+	uint8_t 	guid[16];
+	uint8_t 	_reserved[10];
+} __attribute__ ((packed)) exfat_guid_dentry_t;
+
+typedef struct {
+	uint8_t 	count;
+	uint16_t 	checksum;
+	uint16_t 	attr;
+	uint8_t 	_reserved1[2];
+	uint32_t 	ctime;
+	uint32_t 	mtime;
+	uint32_t 	atime;
+	uint8_t 	ctime_fine;
+	uint8_t 	mtime_fine;
+	uint8_t 	ctime_tz;
+	uint8_t 	mtime_tz;
+	uint8_t 	atime_tz;
+	uint8_t 	_reserved2[7];
+} __attribute__ ((packed)) exfat_file_dentry_t;
+
+typedef struct {
+	uint8_t 	flags;
+	uint8_t 	_reserved1[1];
+	uint8_t 	name_size;
+	uint16_t 	hash;
+	uint8_t 	_reserved2[2];
+	uint64_t 	valid_data_size;
+	uint8_t 	_reserved3[4];
+	uint32_t 	firstc;
+	uint64_t 	data_size;
+} __attribute__ ((packed)) exfat_stream_dentry_t;
+
+typedef struct {
+	uint8_t 	flags;
+	uint16_t 	name[EXFAT_NAME_PART_LEN];
+} __attribute__ ((packed)) exfat_name_dentry_t;
+
+
+typedef struct {
+	uint8_t type;
+	union {
+		exfat_vollabel_dentry_t	vollabel;
+		exfat_bitmap_dentry_t 	bitmap;
+		exfat_uctable_dentry_t 	uctable;
+		exfat_guid_dentry_t 	guid;
+		exfat_file_dentry_t 	file;
+		exfat_stream_dentry_t 	stream;
+		exfat_name_dentry_t 	name;
+	};
+} __attribute__ ((packed)) exfat_dentry_t;
+
+
+typedef enum {
+	EXFAT_DENTRY_SKIP,
+	EXFAT_DENTRY_LAST,
+	EXFAT_DENTRY_FREE,
+	EXFAT_DENTRY_VOLLABEL,
+	EXFAT_DENTRY_BITMAP,
+	EXFAT_DENTRY_UCTABLE,
+	EXFAT_DENTRY_GUID,
+	EXFAT_DENTRY_FILE,
+	EXFAT_DENTRY_STREAM,
+	EXFAT_DENTRY_NAME
+} exfat_dentry_clsf_t;
+
+
+typedef struct exfat_bs {
+	uint8_t jump[3];            /* 0x00 jmp and nop instructions */
+	uint8_t oem_name[8];        /* 0x03 "EXFAT   " */
+	uint8_t	__reserved[53];     /* 0x0B always 0 */
+	uint64_t volume_start;      /* 0x40 partition first sector */
+	uint64_t volume_count;      /* 0x48 partition sectors count */
+	uint32_t fat_sector_start;  /* 0x50 FAT first sector */
+	uint32_t fat_sector_count;  /* 0x54 FAT sectors count */
+	uint32_t data_start_sector; /* 0x58 Data region first cluster sector */
+	uint32_t data_clusters;     /* 0x5C total clusters count */
+	uint32_t rootdir_cluster;   /* 0x60 first cluster of the root dir */
+	uint32_t volume_serial;     /* 0x64 volume serial number */
+	struct {                    /* 0x68 FS version */
+		uint8_t minor;
+		uint8_t major;
+	} __attribute__ ((packed)) version;
+	uint16_t volume_flags;     /* 0x6A volume state flags */
+	uint8_t bytes_per_sector;  /* 0x6C sector size as (1 << n) */
+	uint8_t sec_per_cluster;   /* 0x6D sectors per cluster as (1 << n) */
+	uint8_t fat_count;         /* 0x6E always 1 */
+	uint8_t drive_no;          /* 0x6F always 0x80 */
+	uint8_t allocated_percent; /* 0x70 percentage of allocated space */
+	uint8_t _reserved2[7];     /* 0x71 reserved */
+	uint8_t bootcode[390];     /* Boot code */
+	uint16_t signature;        /* the value of 0xAA55 */
+} __attribute__((__packed__)) exfat_bs_t;
+
+/**
+ * @}
+ */
Index: uspace/app/mkexfat/mkexfat.c
===================================================================
--- uspace/app/mkexfat/mkexfat.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/app/mkexfat/mkexfat.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,952 @@
+/*
+ * Copyright (c) 2012 Maurizio Lombardi
+ * 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 fs
+ * @{
+ */
+
+/**
+ * @file	mkexfat.c
+ * @brief	Tool for creating new exFAT file systems.
+ *
+ */
+
+#include <stdio.h>
+#include <libblock.h>
+#include <assert.h>
+#include <errno.h>
+#include <malloc.h>
+#include <byteorder.h>
+#include <align.h>
+#include <sys/types.h>
+#include <sys/typefmt.h>
+#include <bool.h>
+#include <str.h>
+#include <getopt.h>
+#include "exfat.h"
+#include "upcase.h"
+
+#define NAME    "mkexfat"
+
+/** First sector of the FAT */
+#define FAT_SECTOR_START 128
+
+/** First sector of the Main Extended Boot Region */
+#define EBS_SECTOR_START 1
+
+/** First sector of the Main Extended Boot Region Backup */
+#define EBS_BACKUP_SECTOR_START 13
+
+/** First sector of the Main Boot Sector */
+#define MBS_SECTOR 0
+
+/** First sector of the Main Boot Sector Backup */
+#define MBS_BACKUP_SECTOR 12
+
+/** VBR Checksum sector */
+#define VBR_CHECKSUM_SECTOR 11
+
+/** VBR Backup Checksum sector */
+#define VBR_BACKUP_CHECKSUM_SECTOR 23
+
+/** Size of the Main Extended Boot Region */
+#define EBS_SIZE 8
+
+/** Divide and round up. */
+#define div_round_up(a, b) (((a) + (b) - 1) / (b))
+
+/** The default size of each cluster is 4096 byte */
+#define DEFAULT_CLUSTER_SIZE 4096
+
+/** Index of the first free cluster on the device */
+#define FIRST_FREE_CLUSTER   2
+
+#define min(x, y) ((x) < (y) ? (x) : (y))
+
+typedef struct exfat_cfg {
+	aoff64_t volume_start;
+	aoff64_t volume_count;
+	unsigned long fat_sector_count;
+	unsigned long data_start_sector;
+	unsigned long rootdir_cluster;
+	unsigned long upcase_table_cluster;
+	unsigned long bitmap_cluster;
+	unsigned long total_clusters;
+	unsigned long allocated_clusters;
+	size_t   bitmap_size;
+	size_t   sector_size;
+	size_t   cluster_size;
+} exfat_cfg_t;
+
+
+static unsigned log2(unsigned n);
+
+static uint32_t
+vbr_checksum_start(void const *octets, size_t nbytes);
+
+static void
+vbr_checksum_update(void const *octets, size_t nbytes, uint32_t *checksum);
+
+static int
+ebs_write(service_id_t service_id, exfat_cfg_t *cfg,
+    int base, uint32_t *chksum);
+
+static int
+bitmap_write(service_id_t service_id, exfat_cfg_t *cfg);
+
+static uint32_t
+upcase_table_checksum(void const *data, size_t nbytes);
+
+static struct option const long_options[] = {
+	{"help", no_argument, 0, 'h'},
+	{"cluster-size", required_argument, 0, 'c'},
+	{"fs-size", required_argument, 0, 's'},
+};
+
+static void usage(void)
+{
+	printf("Usage: mkexfat [options] <device>\n"
+	    "-c, --cluster-size ## Specify the cluster size (Kb)\n"
+	    "-s, --fs-size ##      Specify the filesystem size (sectors)\n");
+}
+
+/** Initialize the exFAT params structure.
+ *
+ * @param cfg Pointer to the exFAT params structure to initialize.
+ */
+static void
+cfg_params_initialize(exfat_cfg_t *cfg)
+{
+	unsigned long fat_bytes;
+	unsigned long fat_cls;
+	aoff64_t const volume_bytes = (cfg->volume_count - FAT_SECTOR_START) *
+	    cfg->sector_size;
+
+	if (cfg->cluster_size != 0) {
+		/* The user already choose the cluster size he wants */
+		cfg->total_clusters = volume_bytes / cfg->cluster_size;
+		goto skip_cluster_size_set;
+	}
+
+	cfg->total_clusters = volume_bytes / DEFAULT_CLUSTER_SIZE;
+	cfg->cluster_size = DEFAULT_CLUSTER_SIZE;
+
+	/* Compute the required cluster size to index
+	 * the entire storage device and to keep the FAT
+	 * size less or equal to 64 Mb.
+	 */
+	while (cfg->total_clusters > 16000000ULL &&
+	    (cfg->cluster_size < 32 * 1024 * 1024)) {
+
+		cfg->cluster_size <<= 1;
+		cfg->total_clusters = volume_bytes / cfg->cluster_size;
+	}
+
+skip_cluster_size_set:
+
+	/* Compute the FAT size in sectors */
+	fat_bytes = (cfg->total_clusters + 3) * sizeof(uint32_t);
+	cfg->fat_sector_count = div_round_up(fat_bytes, cfg->sector_size);
+
+	/* Compute the number of the first data sector */
+	cfg->data_start_sector = ROUND_UP(FAT_SECTOR_START +
+	    cfg->fat_sector_count, cfg->cluster_size / cfg->sector_size);
+
+	/* Subtract the FAT space from the total
+	 * number of available clusters.
+	 */
+	fat_cls = div_round_up((cfg->data_start_sector -
+	    FAT_SECTOR_START) * cfg->sector_size,
+	    cfg->cluster_size);
+	if (fat_cls >= cfg->total_clusters) {
+		/* Insufficient disk space on device */
+		cfg->total_clusters = 0;
+		return;
+	}
+	cfg->total_clusters -= fat_cls;
+
+	/* Compute the bitmap size */
+	cfg->bitmap_size = div_round_up(cfg->total_clusters, 8);
+
+	/* Compute the number of clusters reserved to the bitmap */
+	cfg->allocated_clusters = div_round_up(cfg->bitmap_size,
+	    cfg->cluster_size);
+
+	/* This account for the root directory */
+	cfg->allocated_clusters++;
+
+	/* Compute the number of clusters reserved to the upcase table */
+	cfg->allocated_clusters += div_round_up(sizeof(upcase_table),
+	    cfg->cluster_size);
+
+	/* Will be set later */
+	cfg->rootdir_cluster = 0;
+
+	/* Bitmap always starts at the first free cluster */
+	cfg->bitmap_cluster = FIRST_FREE_CLUSTER;
+
+	/* The first sector of the partition is zero */
+	cfg->volume_start = 0;
+}
+
+/** Prints the exFAT structure values
+ *
+ * @param cfg Pointer to the exfat_cfg_t structure.
+ */
+static void
+cfg_print_info(exfat_cfg_t *cfg)
+{
+	printf("Sector size:           %lu\n",
+	    (unsigned long) cfg->sector_size);
+	printf("Cluster size:          %lu\n",
+	    (unsigned long) cfg->cluster_size);
+	printf("FAT size in sectors:   %lu\n", cfg->fat_sector_count);
+	printf("Data start sector:     %lu\n", cfg->data_start_sector);
+	printf("Total num of clusters: %lu\n", cfg->total_clusters);
+	printf("Total used clusters:   %lu\n", cfg->allocated_clusters);
+	printf("Bitmap size:           %lu\n", (unsigned long)
+	    div_round_up(cfg->bitmap_size, cfg->cluster_size));
+	printf("Upcase table size:     %lu\n", (unsigned long)
+	    div_round_up(sizeof(upcase_table), cfg->cluster_size));
+}
+
+/** Initialize the Main Boot Sector fields.
+ *
+ * @param mbs Pointer to the Main Boot Sector structure.
+ * @param cfg Pointer to the exFAT configuration structure.
+ * @return    Initial checksum value.
+ */
+static uint32_t
+vbr_initialize(exfat_bs_t *mbs, exfat_cfg_t *cfg)
+{
+	/* Fill the structure with zeroes */
+	memset(mbs, 0, sizeof(exfat_bs_t));
+
+	/* Init Jump Boot section */
+	mbs->jump[0] = 0xEB;
+	mbs->jump[1] = 0x76;
+	mbs->jump[2] = 0x90;
+
+	/* Set the filesystem name */
+	memcpy(mbs->oem_name, "EXFAT   ", sizeof(mbs->oem_name));
+
+	mbs->volume_start = host2uint64_t_le(cfg->volume_start);
+	mbs->volume_count = host2uint64_t_le(cfg->volume_count);
+	mbs->fat_sector_start = host2uint32_t_le(FAT_SECTOR_START);
+	mbs->fat_sector_count = host2uint32_t_le(cfg->fat_sector_count);
+	mbs->data_start_sector = host2uint32_t_le(cfg->data_start_sector);
+
+	mbs->data_clusters = host2uint32_t_le(cfg->total_clusters);
+
+	mbs->rootdir_cluster = host2uint32_t_le(cfg->rootdir_cluster);
+	mbs->volume_serial = host2uint32_t_le(0xe1028172);
+	mbs->version.major = 1;
+	mbs->version.minor = 0;
+	mbs->volume_flags = host2uint16_t_le(0);
+	mbs->bytes_per_sector = log2(cfg->sector_size);
+	mbs->sec_per_cluster = log2(cfg->cluster_size / cfg->sector_size);
+
+	/* Maximum cluster size is 32 Mb */
+	assert((mbs->bytes_per_sector + mbs->sec_per_cluster) <= 25);
+
+	mbs->fat_count = 1;
+	mbs->drive_no = 0x80;
+	mbs->allocated_percent = 0;
+	mbs->signature = host2uint16_t_le(0xAA55);
+
+	return vbr_checksum_start(mbs, sizeof(exfat_bs_t));
+}
+
+static int
+bootsec_write(service_id_t service_id, exfat_cfg_t *cfg)
+{
+	exfat_bs_t mbs;
+	uint32_t vbr_checksum;
+	uint32_t *chksum_sector;
+	int rc;
+	unsigned idx;
+
+	chksum_sector = calloc(cfg->sector_size, sizeof(uint8_t));
+	if (!chksum_sector)
+		return ENOMEM;
+
+	vbr_checksum = vbr_initialize(&mbs, cfg);
+
+	/* Write the Main Boot Sector to disk */
+	rc = block_write_direct(service_id, MBS_SECTOR, 1, &mbs);
+	if (rc != EOK)
+		goto exit;
+
+	/* Write the Main extended boot sectors to disk */
+	rc = ebs_write(service_id, cfg, EBS_SECTOR_START, &vbr_checksum);
+	if (rc != EOK)
+		goto exit;
+
+	/* Write the Main Boot Sector backup to disk */
+	rc = block_write_direct(service_id, MBS_BACKUP_SECTOR, 1, &mbs);
+	if (rc != EOK)
+		goto exit;
+
+	/* Initialize the checksum sectors */
+	for (idx = 0; idx < cfg->sector_size / sizeof(uint32_t); ++idx)
+		chksum_sector[idx] = host2uint32_t_le(vbr_checksum);
+
+	/* Write the main checksum sector to disk */
+	rc = block_write_direct(service_id,
+	    VBR_CHECKSUM_SECTOR, 1, chksum_sector);
+	if (rc != EOK)
+		goto exit;
+
+	/* Write the backup checksum sector to disk */
+	rc = block_write_direct(service_id,
+	    VBR_BACKUP_CHECKSUM_SECTOR, 1, chksum_sector);
+	if (rc != EOK)
+		goto exit;
+
+	/* Write the Main extended boot sectors backup to disk */ 
+	rc = ebs_write(service_id, cfg,
+	    EBS_BACKUP_SECTOR_START, &vbr_checksum);
+
+exit:
+	free(chksum_sector);
+	return rc;
+}
+
+/** Write the Main Extended Boot Sector to disk
+ *
+ * @param service_id  The service id.
+ * @param cfg  Pointer to the exFAT configuration structure.
+ * @param base Base sector of the EBS.
+ * @return  EOK on success or a negative error code.
+ */
+static int
+ebs_write(service_id_t service_id, exfat_cfg_t *cfg, int base,
+    uint32_t *chksum)
+{
+	uint32_t *ebs = calloc(cfg->sector_size, sizeof(uint8_t));
+	int i, rc;
+
+	if (!ebs)
+		return ENOMEM;
+
+	ebs[cfg->sector_size / 4 - 1] = host2uint32_t_le(0xAA550000);
+
+	for (i = 0; i < EBS_SIZE; ++i) {
+		vbr_checksum_update(ebs, cfg->sector_size, chksum);
+
+		rc = block_write_direct(service_id,
+		    i + base, 1, ebs);
+
+		if (rc != EOK)
+			goto exit;
+	}
+
+	/* The OEM record is not yet used
+	 * by the official exFAT implementation, we'll fill
+	 * it with zeroes.
+	 */
+
+	memset(ebs, 0, cfg->sector_size);
+	vbr_checksum_update(ebs, cfg->sector_size, chksum);
+
+	rc = block_write_direct(service_id, i++ + base, 1, ebs);
+	if (rc != EOK)
+		goto exit;
+
+	/* The next sector is reserved, fill it with zeroes too */
+	vbr_checksum_update(ebs, cfg->sector_size, chksum);
+
+	rc = block_write_direct(service_id, i + base, 1, ebs);
+	if (rc != EOK)
+		goto exit;
+
+exit:
+	free(ebs);
+	return rc;
+}
+
+/** Initialize the FAT table.
+ *
+ * @param service_id  The service id.
+ * @param cfg Pointer to the exfat_cfg structure.
+ * @return EOK on success or a negative error code.
+ */
+static int
+fat_initialize(service_id_t service_id, exfat_cfg_t *cfg)
+{
+	unsigned long i;
+	uint32_t *pfat;
+	int rc;
+
+	pfat = calloc(cfg->sector_size, 1);
+	if (!pfat)
+		return ENOMEM;
+
+	pfat[0] = host2uint32_t_le(0xFFFFFFF8);
+	pfat[1] = host2uint32_t_le(0xFFFFFFFF);
+
+	rc = block_write_direct(service_id, FAT_SECTOR_START, 1, pfat);
+	if (rc != EOK)
+		goto error;
+
+	pfat[0] = pfat[1] = 0;
+
+	for (i = 1; i < cfg->fat_sector_count; ++i) {
+		rc = block_write_direct(service_id,
+		    FAT_SECTOR_START + i, 1, pfat);
+		if (rc != EOK)
+			goto error;
+	}
+
+error:
+	free(pfat);
+	return rc;
+}
+
+/** Allocate a given number of clusters and create a cluster chain.
+ *
+ * @param service_id  The service id.
+ * @param cfg  Pointer to the exfat configuration structure.
+ * @param cur_cls  Cluster index from where to start the allocation.
+ * @param ncls  Number of clusters to allocate.
+ * @return EOK on success or a negative error code.
+ */
+static int
+fat_allocate_clusters(service_id_t service_id, exfat_cfg_t *cfg,
+    uint32_t cur_cls, unsigned long ncls)
+{
+	int rc;
+	unsigned const fat_entries = cfg->sector_size / sizeof(uint32_t);
+	aoff64_t fat_sec = cur_cls / fat_entries + FAT_SECTOR_START;
+	uint32_t *fat;
+	uint32_t next_cls = cur_cls;
+
+	cur_cls %= fat_entries;
+
+	fat = malloc(cfg->sector_size);
+	if (!fat)
+		return ENOMEM;
+
+loop:
+	rc = block_read_direct(service_id, fat_sec, 1, fat);
+	if (rc != EOK)
+		goto exit;
+
+	assert(fat[cur_cls] == 0);
+	assert(ncls > 0);
+
+	for (; cur_cls < fat_entries && ncls > 1; ++cur_cls, --ncls)
+		fat[cur_cls] = host2uint32_t_le(++next_cls);
+
+	if (cur_cls == fat_entries) {
+		/* This sector is full, there are no more free entries,
+		 * commit the changes to disk and restart from the next
+		 * sector.
+		 */
+		rc = block_write_direct(service_id, fat_sec++, 1, fat);
+		if (rc != EOK)
+			goto exit;
+		cur_cls = 0;
+		goto loop;
+	} else if (ncls == 1) {
+		/* This is the last cluster of this chain, mark it
+		 * with EOF.
+		 */
+		fat[cur_cls] = host2uint32_t_le(0xFFFFFFFF);
+	}
+
+	rc = block_write_direct(service_id, fat_sec, 1, fat);
+
+exit:
+	free(fat);
+	return rc;
+}
+
+/** Initialize the allocation bitmap.
+ *
+ * @param service_id   The service id.
+ * @param cfg  Pointer to the exfat configuration structure.
+ * @return  EOK on success or a negative error code.
+ */
+static int
+bitmap_write(service_id_t service_id, exfat_cfg_t *cfg)
+{
+	unsigned long i, sec;
+	unsigned long allocated_cls;
+	int rc = EOK;
+	bool need_reset = true;
+
+	/* Bitmap size in sectors */
+	size_t const bss = div_round_up(cfg->bitmap_size, cfg->sector_size);
+
+	uint8_t *bitmap = malloc(cfg->sector_size);
+	if (!bitmap)
+		return ENOMEM;
+
+	allocated_cls = cfg->allocated_clusters;
+
+	for (sec = 0; sec < bss; ++sec) {
+		if (need_reset) {
+			need_reset = false;
+			memset(bitmap, 0, cfg->sector_size);
+		}
+		if (allocated_cls > 0) {
+			for (i = 0; i < allocated_cls; ++i) {
+				unsigned byte_idx = i / 8;
+				unsigned bit_idx = i % 8;
+
+				if (byte_idx == cfg->sector_size)
+					break;
+				bitmap[byte_idx] |= 1 << bit_idx;
+			}
+
+			allocated_cls -= i;
+			need_reset = true;
+		}
+
+		rc = block_write_direct(service_id,
+		    cfg->data_start_sector + sec, 1, bitmap);
+		if (rc != EOK)
+			goto exit;
+	}
+
+exit:
+	free(bitmap);
+	return rc;
+}
+
+/** Write the upcase table to disk. */
+static int
+upcase_table_write(service_id_t service_id, exfat_cfg_t *cfg)
+{
+	int rc = EOK;
+	aoff64_t start_sec, nsecs, i;
+	uint8_t *table_ptr;
+	uint8_t *buf;
+	size_t table_size = sizeof(upcase_table);
+
+	buf = malloc(cfg->sector_size);
+	if (!buf)
+		return ENOENT;
+
+	/* Compute the start sector of the upcase table */
+	start_sec = cfg->data_start_sector;
+	start_sec += ((cfg->upcase_table_cluster - 2) * cfg->cluster_size) /
+	    cfg->sector_size;
+
+	/* Compute the number of sectors needed to store the table on disk */
+	nsecs = div_round_up(sizeof(upcase_table), cfg->sector_size);
+	table_ptr = (uint8_t *) upcase_table;
+
+	for (i = 0; i < nsecs; ++i,
+	    table_ptr += min(table_size, cfg->sector_size),
+	    table_size -= cfg->sector_size) {
+
+		if (table_size < cfg->sector_size) {
+			/* Reset the content of the unused part
+			 * of the last sector.
+			 */
+			memset(buf, 0, cfg->sector_size);
+		}
+		memcpy(buf, table_ptr, min(table_size, cfg->sector_size));
+
+		rc = block_write_direct(service_id,
+		    start_sec + i, 1, buf);
+		if (rc != EOK)
+			goto exit;
+	}
+
+exit:
+	free(buf);
+	return rc;
+}
+
+/** Initialize and write the root directory entries to disk.
+ *
+ * @param service_id   The service id.
+ * @param cfg   Pointer to the exFAT configuration structure.
+ * @return   EOK on success or a negative error code.
+ */
+static int
+root_dentries_write(service_id_t service_id, exfat_cfg_t *cfg)
+{
+	exfat_dentry_t *d;
+	aoff64_t rootdir_sec;
+	int rc;
+	uint8_t *data;
+	unsigned long i;
+
+	data = calloc(cfg->sector_size, 1);
+	if (!data)
+		return ENOMEM;
+
+	d = (exfat_dentry_t *) data;
+
+	/* Initialize the volume label dentry */
+	d->type = EXFAT_TYPE_VOLLABEL;
+	str_to_utf16(d->vollabel.label, 8, "HELENOS ");
+	d->vollabel.size = 8;
+
+	d++;
+
+	/* Initialize the allocation bitmap dentry */
+	d->type = EXFAT_TYPE_BITMAP;
+	d->bitmap.flags = 0; /* First FAT */
+	d->bitmap.firstc = host2uint32_t_le(cfg->bitmap_cluster);
+	d->bitmap.size = host2uint64_t_le(cfg->bitmap_size);
+
+	d++;
+
+	/* Initialize the upcase table dentry */
+	d->type = EXFAT_TYPE_UCTABLE;
+	d->uctable.checksum = host2uint32_t_le(upcase_table_checksum(
+	    upcase_table, sizeof(upcase_table)));
+	d->uctable.firstc = host2uint32_t_le(cfg->upcase_table_cluster);
+	d->uctable.size = host2uint64_t_le(sizeof(upcase_table));
+
+	/* Compute the number of the sector where the rootdir resides */
+
+	rootdir_sec = cfg->data_start_sector;
+	rootdir_sec += ((cfg->rootdir_cluster - 2) * cfg->cluster_size) /
+	    cfg->sector_size;
+
+	rc = block_write_direct(service_id, rootdir_sec, 1, data);
+	if (rc != EOK)
+		goto exit;
+
+	/* Fill the content of the sectors not used by the
+	 * root directory with zeroes.
+	 */
+	memset(data, 0, cfg->sector_size);
+	for (i = 1; i < cfg->cluster_size / cfg->sector_size; ++i) {
+		rc = block_write_direct(service_id, rootdir_sec + i, 1, data);
+		if (rc != EOK)
+			goto exit;
+	}
+
+exit:
+	free(data);
+	return rc;
+}
+
+/** Given a number (n), returns the result of log2(n).
+ *
+ * It works only if n is a power of two.
+ */
+static unsigned
+log2(unsigned n)
+{
+	unsigned r;
+
+	for (r = 0;n >> r != 1; ++r);
+
+	return r;
+}
+
+/** Initialize the VBR checksum calculation */
+static uint32_t
+vbr_checksum_start(void const *data, size_t nbytes)
+{
+	uint32_t checksum = 0;
+	size_t index;
+	uint8_t const *octets = (uint8_t *) data;
+
+	for (index = 0; index < nbytes; ++index) {
+		if (index == 106 || index == 107 || index == 112) {
+			/* Skip volume_flags and allocated_percent fields */
+			continue;
+		}
+
+		checksum = ((checksum << 31) | (checksum >> 1)) +
+		    octets[index];
+	}
+
+	return checksum;
+}
+
+/** Update the VBR checksum */
+static void
+vbr_checksum_update(void const *data, size_t nbytes, uint32_t *checksum)
+{
+	size_t index;
+	uint8_t const *octets = (uint8_t *) data;
+
+	for (index = 0; index < nbytes; ++index) {
+		*checksum = ((*checksum << 31) | (*checksum >> 1)) +
+		    octets[index];
+	}
+}
+
+/** Compute the checksum of the upcase table.
+ *
+ * @param data   Pointer to the upcase table.
+ * @param nbytes size of the upcase table in bytes.
+ * @return   Checksum value.
+ */
+static uint32_t
+upcase_table_checksum(void const *data, size_t nbytes)
+{
+	size_t index;
+	uint32_t chksum = 0;
+	uint8_t const *octets = (uint8_t *) data;
+
+	for (index = 0; index < nbytes; ++index)
+		chksum = ((chksum << 31) | (chksum >> 1)) + octets[index];
+
+	return chksum;
+}
+
+/** Check if a given number is a power of two.
+ *
+ * @param n   The number to check.
+ * @return    true if n is a power of two, false otherwise.
+ */
+static bool
+is_power_of_two(unsigned long n)
+{
+	if (n == 0)
+		return false;
+
+	return (n & (n - 1)) == 0;
+}
+
+int main (int argc, char **argv)
+{
+	exfat_cfg_t cfg;
+	uint32_t next_cls;
+	char *dev_path;
+	service_id_t service_id;
+	int rc, c, opt_ind;
+	aoff64_t user_fs_size = 0;
+
+	if (argc < 2) {
+		printf(NAME ": Error, argument missing\n");
+		usage();
+		return 1;
+	}
+
+	cfg.cluster_size = 0;
+
+	for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
+		c = getopt_long(argc, argv, "hs:c:",
+		    long_options, &opt_ind);
+		switch (c) {
+		case 'h':
+			usage();
+			return 0;
+		case 's':
+			user_fs_size = (aoff64_t) strtol(optarg, NULL, 10);
+			break;
+
+		case 'c':
+			cfg.cluster_size = strtol(optarg, NULL, 10) * 1024;
+			if (cfg.cluster_size < 4096) {
+				printf(NAME ": Error, cluster size can't"
+				    " be less than 4096 byte.\n");
+				return 1;
+			} else if (cfg.cluster_size > 32 * 1024 * 1024) {
+				printf(NAME ": Error, cluster size can't"
+				    " be greater than 32 Mb");
+				return 1;
+			}
+
+			if (!is_power_of_two(cfg.cluster_size)) {
+				printf(NAME ": Error, the size of the cluster"
+				    " must be a power of two.\n");
+				return 1;
+			}
+			break;
+		}
+	}
+
+	argv += optind;
+	dev_path = *argv;
+
+	if (!dev_path) {
+		printf(NAME ": Error, you must specify a valid block"
+		    " device.\n");
+		usage();
+		return 1;
+	}
+
+	printf("Device = %s\n", dev_path);
+
+	rc = loc_service_get_id(dev_path, &service_id, 0);
+	if (rc != EOK) {
+		printf(NAME ": Error resolving device `%s'.\n", dev_path);
+		return 2;
+	}
+
+	rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048);
+	if (rc != EOK) {
+		printf(NAME ": Error initializing libblock.\n");
+		return 2;
+	}
+
+	rc = block_get_bsize(service_id, &cfg.sector_size);
+	if (rc != EOK) {
+		printf(NAME ": Error determining device sector size.\n");
+		return 2;
+	}
+
+	user_fs_size *= cfg.sector_size;
+	if (user_fs_size > 0 && user_fs_size < 1024 * 1024) {
+		printf(NAME ": Error, fs size can't be less"
+		    " than 1 Mb.\n");
+		return 1;
+	}
+
+
+	if (cfg.sector_size > 4096) {
+		printf(NAME ": Error, sector size can't be greater" \
+		    " than 4096 bytes.\n");
+		return 2;
+	}
+
+	rc = block_get_nblocks(service_id, &cfg.volume_count);
+	if (rc != EOK) {
+		printf(NAME ": Warning, failed to obtain" \
+		    " block device size.\n");
+
+		if (user_fs_size == 0) {
+			printf(NAME ": You must specify the" \
+			    " filesystem size.\n");
+			return 1;
+		}
+	} else {
+		printf("Block device has %" PRIuOFF64 " blocks.\n",
+		    cfg.volume_count);
+	}
+
+	if (user_fs_size != 0) {
+		if (user_fs_size > cfg.volume_count * cfg.sector_size) {
+			printf(NAME ": Error, the device is not big enough"
+			    " to create a filesystem of"
+			    " the specified size.\n");
+			return 1;
+		}
+
+		cfg.volume_count = user_fs_size / cfg.sector_size;
+	}
+
+	cfg_params_initialize(&cfg);
+	cfg_print_info(&cfg);
+
+	if (cfg.total_clusters <= cfg.allocated_clusters + 2) {
+		printf(NAME ": Error, insufficient disk space on device.\n");
+		return 2;
+	}
+
+	printf("Writing the allocation table.\n");
+
+	/* Initialize the FAT table */
+	rc = fat_initialize(service_id, &cfg);
+	if (rc != EOK) {
+		printf(NAME ": Error, failed to write the FAT to disk\n");
+		return 2;
+	}
+
+	/* Allocate clusters for the bitmap */
+	rc = fat_allocate_clusters(service_id, &cfg, cfg.bitmap_cluster,
+	    div_round_up(cfg.bitmap_size, cfg.cluster_size));
+	if (rc != EOK) {
+		printf(NAME ": Error, failed to allocate" \
+		    " clusters for bitmap.\n");
+		return 2;
+	}
+
+	next_cls = cfg.bitmap_cluster +
+	    div_round_up(cfg.bitmap_size, cfg.cluster_size);
+	cfg.upcase_table_cluster = next_cls;
+
+	/* Allocate clusters for the upcase table */
+	rc = fat_allocate_clusters(service_id, &cfg, next_cls,
+	    div_round_up(sizeof(upcase_table), cfg.cluster_size));
+	if (rc != EOK) {
+		printf(NAME ":Error, failed to allocate clusters" \
+		    " for the upcase table.\n");
+		return 2;
+	}
+
+	next_cls += div_round_up(sizeof(upcase_table), cfg.cluster_size);
+	cfg.rootdir_cluster = next_cls;
+
+	/* Allocate a cluster for the root directory entry */
+	rc = fat_allocate_clusters(service_id, &cfg, next_cls, 1);
+	if (rc != EOK) {
+		printf(NAME ": Error, failed to allocate cluster" \
+		    " for the root dentry.\n");
+		return 2;
+	}
+
+	printf("Writing the allocation bitmap.\n");
+
+	/* Write the allocation bitmap to disk */
+	rc = bitmap_write(service_id, &cfg);
+	if (rc != EOK) {
+		printf(NAME ": Error, failed to write the allocation" \
+		    " bitmap to disk.\n");
+		return 2;
+	}
+
+	printf("Writing the upcase table.\n");
+
+	/* Write the upcase table to disk */
+	rc = upcase_table_write(service_id, &cfg);
+	if (rc != EOK) {
+		printf(NAME ": Error, failed to write the" \
+		    " upcase table to disk.\n");
+		return 2;
+	}
+
+	printf("Writing the root directory.\n");
+
+	rc = root_dentries_write(service_id, &cfg);
+	if (rc != EOK) {
+		printf(NAME ": Error, failed to write the root directory" \
+		    " entries to disk.\n");
+		return 2;
+	}
+
+	printf("Writing the boot sectors.\n");
+
+	rc = bootsec_write(service_id, &cfg);
+	if (rc != EOK) {
+		printf(NAME ": Error, failed to write the VBR to disk\n");
+		return 2;
+	}
+
+	printf("Success.\n");
+
+	return 0;
+}
+
+/**
+ * @}
+ */
+
Index: uspace/app/mkexfat/upcase.h
===================================================================
--- uspace/app/mkexfat/upcase.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/app/mkexfat/upcase.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,2964 @@
+/*
+ * Copyright (c) 2012 Maurizio Lombardi
+ * 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 fs
+ * @{
+ */
+
+#ifndef _UPCASE_H_
+#define _UPCASE_H_
+
+/** Up-case unicode table */
+static uint8_t const upcase_table[] = {
+    0x00, 0x00,
+    0x01, 0x00,
+    0x02, 0x00,
+    0x03, 0x00,
+    0x04, 0x00,
+    0x05, 0x00,
+    0x06, 0x00,
+    0x07, 0x00,
+    0x08, 0x00,
+    0x09, 0x00,
+    0x0a, 0x00,
+    0x0b, 0x00,
+    0x0c, 0x00,
+    0x0d, 0x00,
+    0x0e, 0x00,
+    0x0f, 0x00,
+    0x10, 0x00,
+    0x11, 0x00,
+    0x12, 0x00,
+    0x13, 0x00,
+    0x14, 0x00,
+    0x15, 0x00,
+    0x16, 0x00,
+    0x17, 0x00,
+    0x18, 0x00,
+    0x19, 0x00,
+    0x1a, 0x00,
+    0x1b, 0x00,
+    0x1c, 0x00,
+    0x1d, 0x00,
+    0x1e, 0x00,
+    0x1f, 0x00,
+    0x20, 0x00,
+    0x21, 0x00,
+    0x22, 0x00,
+    0x23, 0x00,
+    0x24, 0x00,
+    0x25, 0x00,
+    0x26, 0x00,
+    0x27, 0x00,
+    0x28, 0x00,
+    0x29, 0x00,
+    0x2a, 0x00,
+    0x2b, 0x00,
+    0x2c, 0x00,
+    0x2d, 0x00,
+    0x2e, 0x00,
+    0x2f, 0x00,
+    0x30, 0x00,
+    0x31, 0x00,
+    0x32, 0x00,
+    0x33, 0x00,
+    0x34, 0x00,
+    0x35, 0x00,
+    0x36, 0x00,
+    0x37, 0x00,
+    0x38, 0x00,
+    0x39, 0x00,
+    0x3a, 0x00,
+    0x3b, 0x00,
+    0x3c, 0x00,
+    0x3d, 0x00,
+    0x3e, 0x00,
+    0x3f, 0x00,
+    0x40, 0x00,
+    0x41, 0x00,
+    0x42, 0x00,
+    0x43, 0x00,
+    0x44, 0x00,
+    0x45, 0x00,
+    0x46, 0x00,
+    0x47, 0x00,
+    0x48, 0x00,
+    0x49, 0x00,
+    0x4a, 0x00,
+    0x4b, 0x00,
+    0x4c, 0x00,
+    0x4d, 0x00,
+    0x4e, 0x00,
+    0x4f, 0x00,
+    0x50, 0x00,
+    0x51, 0x00,
+    0x52, 0x00,
+    0x53, 0x00,
+    0x54, 0x00,
+    0x55, 0x00,
+    0x56, 0x00,
+    0x57, 0x00,
+    0x58, 0x00,
+    0x59, 0x00,
+    0x5a, 0x00,
+    0x5b, 0x00,
+    0x5c, 0x00,
+    0x5d, 0x00,
+    0x5e, 0x00,
+    0x5f, 0x00,
+    0x60, 0x00,
+    0x41, 0x00,
+    0x42, 0x00,
+    0x43, 0x00,
+    0x44, 0x00,
+    0x45, 0x00,
+    0x46, 0x00,
+    0x47, 0x00,
+    0x48, 0x00,
+    0x49, 0x00,
+    0x4a, 0x00,
+    0x4b, 0x00,
+    0x4c, 0x00,
+    0x4d, 0x00,
+    0x4e, 0x00,
+    0x4f, 0x00,
+    0x50, 0x00,
+    0x51, 0x00,
+    0x52, 0x00,
+    0x53, 0x00,
+    0x54, 0x00,
+    0x55, 0x00,
+    0x56, 0x00,
+    0x57, 0x00,
+    0x58, 0x00,
+    0x59, 0x00,
+    0x5a, 0x00,
+    0x7b, 0x00,
+    0x7c, 0x00,
+    0x7d, 0x00,
+    0x7e, 0x00,
+    0x7f, 0x00,
+    0x80, 0x00,
+    0x81, 0x00,
+    0x82, 0x00,
+    0x83, 0x00,
+    0x84, 0x00,
+    0x85, 0x00,
+    0x86, 0x00,
+    0x87, 0x00,
+    0x88, 0x00,
+    0x89, 0x00,
+    0x8a, 0x00,
+    0x8b, 0x00,
+    0x8c, 0x00,
+    0x8d, 0x00,
+    0x8e, 0x00,
+    0x8f, 0x00,
+    0x90, 0x00,
+    0x91, 0x00,
+    0x92, 0x00,
+    0x93, 0x00,
+    0x94, 0x00,
+    0x95, 0x00,
+    0x96, 0x00,
+    0x97, 0x00,
+    0x98, 0x00,
+    0x99, 0x00,
+    0x9a, 0x00,
+    0x9b, 0x00,
+    0x9c, 0x00,
+    0x9d, 0x00,
+    0x9e, 0x00,
+    0x9f, 0x00,
+    0xa0, 0x00,
+    0xa1, 0x00,
+    0xa2, 0x00,
+    0xa3, 0x00,
+    0xa4, 0x00,
+    0xa5, 0x00,
+    0xa6, 0x00,
+    0xa7, 0x00,
+    0xa8, 0x00,
+    0xa9, 0x00,
+    0xaa, 0x00,
+    0xab, 0x00,
+    0xac, 0x00,
+    0xad, 0x00,
+    0xae, 0x00,
+    0xaf, 0x00,
+    0xb0, 0x00,
+    0xb1, 0x00,
+    0xb2, 0x00,
+    0xb3, 0x00,
+    0xb4, 0x00,
+    0xb5, 0x00,
+    0xb6, 0x00,
+    0xb7, 0x00,
+    0xb8, 0x00,
+    0xb9, 0x00,
+    0xba, 0x00,
+    0xbb, 0x00,
+    0xbc, 0x00,
+    0xbd, 0x00,
+    0xbe, 0x00,
+    0xbf, 0x00,
+    0xc0, 0x00,
+    0xc1, 0x00,
+    0xc2, 0x00,
+    0xc3, 0x00,
+    0xc4, 0x00,
+    0xc5, 0x00,
+    0xc6, 0x00,
+    0xc7, 0x00,
+    0xc8, 0x00,
+    0xc9, 0x00,
+    0xca, 0x00,
+    0xcb, 0x00,
+    0xcc, 0x00,
+    0xcd, 0x00,
+    0xce, 0x00,
+    0xcf, 0x00,
+    0xd0, 0x00,
+    0xd1, 0x00,
+    0xd2, 0x00,
+    0xd3, 0x00,
+    0xd4, 0x00,
+    0xd5, 0x00,
+    0xd6, 0x00,
+    0xd7, 0x00,
+    0xd8, 0x00,
+    0xd9, 0x00,
+    0xda, 0x00,
+    0xdb, 0x00,
+    0xdc, 0x00,
+    0xdd, 0x00,
+    0xde, 0x00,
+    0xdf, 0x00,
+    0xc0, 0x00,
+    0xc1, 0x00,
+    0xc2, 0x00,
+    0xc3, 0x00,
+    0xc4, 0x00,
+    0xc5, 0x00,
+    0xc6, 0x00,
+    0xc7, 0x00,
+    0xc8, 0x00,
+    0xc9, 0x00,
+    0xca, 0x00,
+    0xcb, 0x00,
+    0xcc, 0x00,
+    0xcd, 0x00,
+    0xce, 0x00,
+    0xcf, 0x00,
+    0xd0, 0x00,
+    0xd1, 0x00,
+    0xd2, 0x00,
+    0xd3, 0x00,
+    0xd4, 0x00,
+    0xd5, 0x00,
+    0xd6, 0x00,
+    0xf7, 0x00,
+    0xd8, 0x00,
+    0xd9, 0x00,
+    0xda, 0x00,
+    0xdb, 0x00,
+    0xdc, 0x00,
+    0xdd, 0x00,
+    0xde, 0x00,
+    0x78, 0x01,
+    0x00, 0x01,
+    0x00, 0x01,
+    0x02, 0x01,
+    0x02, 0x01,
+    0x04, 0x01,
+    0x04, 0x01,
+    0x06, 0x01,
+    0x06, 0x01,
+    0x08, 0x01,
+    0x08, 0x01,
+    0x0a, 0x01,
+    0x0a, 0x01,
+    0x0c, 0x01,
+    0x0c, 0x01,
+    0x0e, 0x01,
+    0x0e, 0x01,
+    0x10, 0x01,
+    0x10, 0x01,
+    0x12, 0x01,
+    0x12, 0x01,
+    0x14, 0x01,
+    0x14, 0x01,
+    0x16, 0x01,
+    0x16, 0x01,
+    0x18, 0x01,
+    0x18, 0x01,
+    0x1a, 0x01,
+    0x1a, 0x01,
+    0x1c, 0x01,
+    0x1c, 0x01,
+    0x1e, 0x01,
+    0x1e, 0x01,
+    0x20, 0x01,
+    0x20, 0x01,
+    0x22, 0x01,
+    0x22, 0x01,
+    0x24, 0x01,
+    0x24, 0x01,
+    0x26, 0x01,
+    0x26, 0x01,
+    0x28, 0x01,
+    0x28, 0x01,
+    0x2a, 0x01,
+    0x2a, 0x01,
+    0x2c, 0x01,
+    0x2c, 0x01,
+    0x2e, 0x01,
+    0x2e, 0x01,
+    0x30, 0x01,
+    0x31, 0x01,
+    0x32, 0x01,
+    0x32, 0x01,
+    0x34, 0x01,
+    0x34, 0x01,
+    0x36, 0x01,
+    0x36, 0x01,
+    0x38, 0x01,
+    0x39, 0x01,
+    0x39, 0x01,
+    0x3b, 0x01,
+    0x3b, 0x01,
+    0x3d, 0x01,
+    0x3d, 0x01,
+    0x3f, 0x01,
+    0x3f, 0x01,
+    0x41, 0x01,
+    0x41, 0x01,
+    0x43, 0x01,
+    0x43, 0x01,
+    0x45, 0x01,
+    0x45, 0x01,
+    0x47, 0x01,
+    0x47, 0x01,
+    0x49, 0x01,
+    0x4a, 0x01,
+    0x4a, 0x01,
+    0x4c, 0x01,
+    0x4c, 0x01,
+    0x4e, 0x01,
+    0x4e, 0x01,
+    0x50, 0x01,
+    0x50, 0x01,
+    0x52, 0x01,
+    0x52, 0x01,
+    0x54, 0x01,
+    0x54, 0x01,
+    0x56, 0x01,
+    0x56, 0x01,
+    0x58, 0x01,
+    0x58, 0x01,
+    0x5a, 0x01,
+    0x5a, 0x01,
+    0x5c, 0x01,
+    0x5c, 0x01,
+    0x5e, 0x01,
+    0x5e, 0x01,
+    0x60, 0x01,
+    0x60, 0x01,
+    0x62, 0x01,
+    0x62, 0x01,
+    0x64, 0x01,
+    0x64, 0x01,
+    0x66, 0x01,
+    0x66, 0x01,
+    0x68, 0x01,
+    0x68, 0x01,
+    0x6a, 0x01,
+    0x6a, 0x01,
+    0x6c, 0x01,
+    0x6c, 0x01,
+    0x6e, 0x01,
+    0x6e, 0x01,
+    0x70, 0x01,
+    0x70, 0x01,
+    0x72, 0x01,
+    0x72, 0x01,
+    0x74, 0x01,
+    0x74, 0x01,
+    0x76, 0x01,
+    0x76, 0x01,
+    0x78, 0x01,
+    0x79, 0x01,
+    0x79, 0x01,
+    0x7b, 0x01,
+    0x7b, 0x01,
+    0x7d, 0x01,
+    0x7d, 0x01,
+    0x7f, 0x01,
+    0x43, 0x02,
+    0x81, 0x01,
+    0x82, 0x01,
+    0x82, 0x01,
+    0x84, 0x01,
+    0x84, 0x01,
+    0x86, 0x01,
+    0x87, 0x01,
+    0x87, 0x01,
+    0x89, 0x01,
+    0x8a, 0x01,
+    0x8b, 0x01,
+    0x8b, 0x01,
+    0x8d, 0x01,
+    0x8e, 0x01,
+    0x8f, 0x01,
+    0x90, 0x01,
+    0x91, 0x01,
+    0x91, 0x01,
+    0x93, 0x01,
+    0x94, 0x01,
+    0xf6, 0x01,
+    0x96, 0x01,
+    0x97, 0x01,
+    0x98, 0x01,
+    0x98, 0x01,
+    0x3d, 0x02,
+    0x9b, 0x01,
+    0x9c, 0x01,
+    0x9d, 0x01,
+    0x20, 0x02,
+    0x9f, 0x01,
+    0xa0, 0x01,
+    0xa0, 0x01,
+    0xa2, 0x01,
+    0xa2, 0x01,
+    0xa4, 0x01,
+    0xa4, 0x01,
+    0xa6, 0x01,
+    0xa7, 0x01,
+    0xa7, 0x01,
+    0xa9, 0x01,
+    0xaa, 0x01,
+    0xab, 0x01,
+    0xac, 0x01,
+    0xac, 0x01,
+    0xae, 0x01,
+    0xaf, 0x01,
+    0xaf, 0x01,
+    0xb1, 0x01,
+    0xb2, 0x01,
+    0xb3, 0x01,
+    0xb3, 0x01,
+    0xb5, 0x01,
+    0xb5, 0x01,
+    0xb7, 0x01,
+    0xb8, 0x01,
+    0xb8, 0x01,
+    0xba, 0x01,
+    0xbb, 0x01,
+    0xbc, 0x01,
+    0xbc, 0x01,
+    0xbe, 0x01,
+    0xf7, 0x01,
+    0xc0, 0x01,
+    0xc1, 0x01,
+    0xc2, 0x01,
+    0xc3, 0x01,
+    0xc4, 0x01,
+    0xc5, 0x01,
+    0xc4, 0x01,
+    0xc7, 0x01,
+    0xc8, 0x01,
+    0xc7, 0x01,
+    0xca, 0x01,
+    0xcb, 0x01,
+    0xca, 0x01,
+    0xcd, 0x01,
+    0xcd, 0x01,
+    0xcf, 0x01,
+    0xcf, 0x01,
+    0xd1, 0x01,
+    0xd1, 0x01,
+    0xd3, 0x01,
+    0xd3, 0x01,
+    0xd5, 0x01,
+    0xd5, 0x01,
+    0xd7, 0x01,
+    0xd7, 0x01,
+    0xd9, 0x01,
+    0xd9, 0x01,
+    0xdb, 0x01,
+    0xdb, 0x01,
+    0x8e, 0x01,
+    0xde, 0x01,
+    0xde, 0x01,
+    0xe0, 0x01,
+    0xe0, 0x01,
+    0xe2, 0x01,
+    0xe2, 0x01,
+    0xe4, 0x01,
+    0xe4, 0x01,
+    0xe6, 0x01,
+    0xe6, 0x01,
+    0xe8, 0x01,
+    0xe8, 0x01,
+    0xea, 0x01,
+    0xea, 0x01,
+    0xec, 0x01,
+    0xec, 0x01,
+    0xee, 0x01,
+    0xee, 0x01,
+    0xf0, 0x01,
+    0xf1, 0x01,
+    0xf2, 0x01,
+    0xf1, 0x01,
+    0xf4, 0x01,
+    0xf4, 0x01,
+    0xf6, 0x01,
+    0xf7, 0x01,
+    0xf8, 0x01,
+    0xf8, 0x01,
+    0xfa, 0x01,
+    0xfa, 0x01,
+    0xfc, 0x01,
+    0xfc, 0x01,
+    0xfe, 0x01,
+    0xfe, 0x01,
+    0x00, 0x02,
+    0x00, 0x02,
+    0x02, 0x02,
+    0x02, 0x02,
+    0x04, 0x02,
+    0x04, 0x02,
+    0x06, 0x02,
+    0x06, 0x02,
+    0x08, 0x02,
+    0x08, 0x02,
+    0x0a, 0x02,
+    0x0a, 0x02,
+    0x0c, 0x02,
+    0x0c, 0x02,
+    0x0e, 0x02,
+    0x0e, 0x02,
+    0x10, 0x02,
+    0x10, 0x02,
+    0x12, 0x02,
+    0x12, 0x02,
+    0x14, 0x02,
+    0x14, 0x02,
+    0x16, 0x02,
+    0x16, 0x02,
+    0x18, 0x02,
+    0x18, 0x02,
+    0x1a, 0x02,
+    0x1a, 0x02,
+    0x1c, 0x02,
+    0x1c, 0x02,
+    0x1e, 0x02,
+    0x1e, 0x02,
+    0x20, 0x02,
+    0x21, 0x02,
+    0x22, 0x02,
+    0x22, 0x02,
+    0x24, 0x02,
+    0x24, 0x02,
+    0x26, 0x02,
+    0x26, 0x02,
+    0x28, 0x02,
+    0x28, 0x02,
+    0x2a, 0x02,
+    0x2a, 0x02,
+    0x2c, 0x02,
+    0x2c, 0x02,
+    0x2e, 0x02,
+    0x2e, 0x02,
+    0x30, 0x02,
+    0x30, 0x02,
+    0x32, 0x02,
+    0x32, 0x02,
+    0x34, 0x02,
+    0x35, 0x02,
+    0x36, 0x02,
+    0x37, 0x02,
+    0x38, 0x02,
+    0x39, 0x02,
+    0x65, 0x2c,
+    0x3b, 0x02,
+    0x3b, 0x02,
+    0x3d, 0x02,
+    0x66, 0x2c,
+    0x3f, 0x02,
+    0x40, 0x02,
+    0x41, 0x02,
+    0x41, 0x02,
+    0x43, 0x02,
+    0x44, 0x02,
+    0x45, 0x02,
+    0x46, 0x02,
+    0x46, 0x02,
+    0x48, 0x02,
+    0x48, 0x02,
+    0x4a, 0x02,
+    0x4a, 0x02,
+    0x4c, 0x02,
+    0x4c, 0x02,
+    0x4e, 0x02,
+    0x4e, 0x02,
+    0x50, 0x02,
+    0x51, 0x02,
+    0x52, 0x02,
+    0x81, 0x01,
+    0x86, 0x01,
+    0x55, 0x02,
+    0x89, 0x01,
+    0x8a, 0x01,
+    0x58, 0x02,
+    0x8f, 0x01,
+    0x5a, 0x02,
+    0x90, 0x01,
+    0x5c, 0x02,
+    0x5d, 0x02,
+    0x5e, 0x02,
+    0x5f, 0x02,
+    0x93, 0x01,
+    0x61, 0x02,
+    0x62, 0x02,
+    0x94, 0x01,
+    0x64, 0x02,
+    0x65, 0x02,
+    0x66, 0x02,
+    0x67, 0x02,
+    0x97, 0x01,
+    0x96, 0x01,
+    0x6a, 0x02,
+    0x62, 0x2c,
+    0x6c, 0x02,
+    0x6d, 0x02,
+    0x6e, 0x02,
+    0x9c, 0x01,
+    0x70, 0x02,
+    0x71, 0x02,
+    0x9d, 0x01,
+    0x73, 0x02,
+    0x74, 0x02,
+    0x9f, 0x01,
+    0x76, 0x02,
+    0x77, 0x02,
+    0x78, 0x02,
+    0x79, 0x02,
+    0x7a, 0x02,
+    0x7b, 0x02,
+    0x7c, 0x02,
+    0x64, 0x2c,
+    0x7e, 0x02,
+    0x7f, 0x02,
+    0xa6, 0x01,
+    0x81, 0x02,
+    0x82, 0x02,
+    0xa9, 0x01,
+    0x84, 0x02,
+    0x85, 0x02,
+    0x86, 0x02,
+    0x87, 0x02,
+    0xae, 0x01,
+    0x44, 0x02,
+    0xb1, 0x01,
+    0xb2, 0x01,
+    0x45, 0x02,
+    0x8d, 0x02,
+    0x8e, 0x02,
+    0x8f, 0x02,
+    0x90, 0x02,
+    0x91, 0x02,
+    0xb7, 0x01,
+    0x93, 0x02,
+    0x94, 0x02,
+    0x95, 0x02,
+    0x96, 0x02,
+    0x97, 0x02,
+    0x98, 0x02,
+    0x99, 0x02,
+    0x9a, 0x02,
+    0x9b, 0x02,
+    0x9c, 0x02,
+    0x9d, 0x02,
+    0x9e, 0x02,
+    0x9f, 0x02,
+    0xa0, 0x02,
+    0xa1, 0x02,
+    0xa2, 0x02,
+    0xa3, 0x02,
+    0xa4, 0x02,
+    0xa5, 0x02,
+    0xa6, 0x02,
+    0xa7, 0x02,
+    0xa8, 0x02,
+    0xa9, 0x02,
+    0xaa, 0x02,
+    0xab, 0x02,
+    0xac, 0x02,
+    0xad, 0x02,
+    0xae, 0x02,
+    0xaf, 0x02,
+    0xb0, 0x02,
+    0xb1, 0x02,
+    0xb2, 0x02,
+    0xb3, 0x02,
+    0xb4, 0x02,
+    0xb5, 0x02,
+    0xb6, 0x02,
+    0xb7, 0x02,
+    0xb8, 0x02,
+    0xb9, 0x02,
+    0xba, 0x02,
+    0xbb, 0x02,
+    0xbc, 0x02,
+    0xbd, 0x02,
+    0xbe, 0x02,
+    0xbf, 0x02,
+    0xc0, 0x02,
+    0xc1, 0x02,
+    0xc2, 0x02,
+    0xc3, 0x02,
+    0xc4, 0x02,
+    0xc5, 0x02,
+    0xc6, 0x02,
+    0xc7, 0x02,
+    0xc8, 0x02,
+    0xc9, 0x02,
+    0xca, 0x02,
+    0xcb, 0x02,
+    0xcc, 0x02,
+    0xcd, 0x02,
+    0xce, 0x02,
+    0xcf, 0x02,
+    0xd0, 0x02,
+    0xd1, 0x02,
+    0xd2, 0x02,
+    0xd3, 0x02,
+    0xd4, 0x02,
+    0xd5, 0x02,
+    0xd6, 0x02,
+    0xd7, 0x02,
+    0xd8, 0x02,
+    0xd9, 0x02,
+    0xda, 0x02,
+    0xdb, 0x02,
+    0xdc, 0x02,
+    0xdd, 0x02,
+    0xde, 0x02,
+    0xdf, 0x02,
+    0xe0, 0x02,
+    0xe1, 0x02,
+    0xe2, 0x02,
+    0xe3, 0x02,
+    0xe4, 0x02,
+    0xe5, 0x02,
+    0xe6, 0x02,
+    0xe7, 0x02,
+    0xe8, 0x02,
+    0xe9, 0x02,
+    0xea, 0x02,
+    0xeb, 0x02,
+    0xec, 0x02,
+    0xed, 0x02,
+    0xee, 0x02,
+    0xef, 0x02,
+    0xf0, 0x02,
+    0xf1, 0x02,
+    0xf2, 0x02,
+    0xf3, 0x02,
+    0xf4, 0x02,
+    0xf5, 0x02,
+    0xf6, 0x02,
+    0xf7, 0x02,
+    0xf8, 0x02,
+    0xf9, 0x02,
+    0xfa, 0x02,
+    0xfb, 0x02,
+    0xfc, 0x02,
+    0xfd, 0x02,
+    0xfe, 0x02,
+    0xff, 0x02,
+    0x00, 0x03,
+    0x01, 0x03,
+    0x02, 0x03,
+    0x03, 0x03,
+    0x04, 0x03,
+    0x05, 0x03,
+    0x06, 0x03,
+    0x07, 0x03,
+    0x08, 0x03,
+    0x09, 0x03,
+    0x0a, 0x03,
+    0x0b, 0x03,
+    0x0c, 0x03,
+    0x0d, 0x03,
+    0x0e, 0x03,
+    0x0f, 0x03,
+    0x10, 0x03,
+    0x11, 0x03,
+    0x12, 0x03,
+    0x13, 0x03,
+    0x14, 0x03,
+    0x15, 0x03,
+    0x16, 0x03,
+    0x17, 0x03,
+    0x18, 0x03,
+    0x19, 0x03,
+    0x1a, 0x03,
+    0x1b, 0x03,
+    0x1c, 0x03,
+    0x1d, 0x03,
+    0x1e, 0x03,
+    0x1f, 0x03,
+    0x20, 0x03,
+    0x21, 0x03,
+    0x22, 0x03,
+    0x23, 0x03,
+    0x24, 0x03,
+    0x25, 0x03,
+    0x26, 0x03,
+    0x27, 0x03,
+    0x28, 0x03,
+    0x29, 0x03,
+    0x2a, 0x03,
+    0x2b, 0x03,
+    0x2c, 0x03,
+    0x2d, 0x03,
+    0x2e, 0x03,
+    0x2f, 0x03,
+    0x30, 0x03,
+    0x31, 0x03,
+    0x32, 0x03,
+    0x33, 0x03,
+    0x34, 0x03,
+    0x35, 0x03,
+    0x36, 0x03,
+    0x37, 0x03,
+    0x38, 0x03,
+    0x39, 0x03,
+    0x3a, 0x03,
+    0x3b, 0x03,
+    0x3c, 0x03,
+    0x3d, 0x03,
+    0x3e, 0x03,
+    0x3f, 0x03,
+    0x40, 0x03,
+    0x41, 0x03,
+    0x42, 0x03,
+    0x43, 0x03,
+    0x44, 0x03,
+    0x45, 0x03,
+    0x46, 0x03,
+    0x47, 0x03,
+    0x48, 0x03,
+    0x49, 0x03,
+    0x4a, 0x03,
+    0x4b, 0x03,
+    0x4c, 0x03,
+    0x4d, 0x03,
+    0x4e, 0x03,
+    0x4f, 0x03,
+    0x50, 0x03,
+    0x51, 0x03,
+    0x52, 0x03,
+    0x53, 0x03,
+    0x54, 0x03,
+    0x55, 0x03,
+    0x56, 0x03,
+    0x57, 0x03,
+    0x58, 0x03,
+    0x59, 0x03,
+    0x5a, 0x03,
+    0x5b, 0x03,
+    0x5c, 0x03,
+    0x5d, 0x03,
+    0x5e, 0x03,
+    0x5f, 0x03,
+    0x60, 0x03,
+    0x61, 0x03,
+    0x62, 0x03,
+    0x63, 0x03,
+    0x64, 0x03,
+    0x65, 0x03,
+    0x66, 0x03,
+    0x67, 0x03,
+    0x68, 0x03,
+    0x69, 0x03,
+    0x6a, 0x03,
+    0x6b, 0x03,
+    0x6c, 0x03,
+    0x6d, 0x03,
+    0x6e, 0x03,
+    0x6f, 0x03,
+    0x70, 0x03,
+    0x71, 0x03,
+    0x72, 0x03,
+    0x73, 0x03,
+    0x74, 0x03,
+    0x75, 0x03,
+    0x76, 0x03,
+    0x77, 0x03,
+    0x78, 0x03,
+    0x79, 0x03,
+    0x7a, 0x03,
+    0xfd, 0x03,
+    0xfe, 0x03,
+    0xff, 0x03,
+    0x7e, 0x03,
+    0x7f, 0x03,
+    0x80, 0x03,
+    0x81, 0x03,
+    0x82, 0x03,
+    0x83, 0x03,
+    0x84, 0x03,
+    0x85, 0x03,
+    0x86, 0x03,
+    0x87, 0x03,
+    0x88, 0x03,
+    0x89, 0x03,
+    0x8a, 0x03,
+    0x8b, 0x03,
+    0x8c, 0x03,
+    0x8d, 0x03,
+    0x8e, 0x03,
+    0x8f, 0x03,
+    0x90, 0x03,
+    0x91, 0x03,
+    0x92, 0x03,
+    0x93, 0x03,
+    0x94, 0x03,
+    0x95, 0x03,
+    0x96, 0x03,
+    0x97, 0x03,
+    0x98, 0x03,
+    0x99, 0x03,
+    0x9a, 0x03,
+    0x9b, 0x03,
+    0x9c, 0x03,
+    0x9d, 0x03,
+    0x9e, 0x03,
+    0x9f, 0x03,
+    0xa0, 0x03,
+    0xa1, 0x03,
+    0xa2, 0x03,
+    0xa3, 0x03,
+    0xa4, 0x03,
+    0xa5, 0x03,
+    0xa6, 0x03,
+    0xa7, 0x03,
+    0xa8, 0x03,
+    0xa9, 0x03,
+    0xaa, 0x03,
+    0xab, 0x03,
+    0x86, 0x03,
+    0x88, 0x03,
+    0x89, 0x03,
+    0x8a, 0x03,
+    0xb0, 0x03,
+    0x91, 0x03,
+    0x92, 0x03,
+    0x93, 0x03,
+    0x94, 0x03,
+    0x95, 0x03,
+    0x96, 0x03,
+    0x97, 0x03,
+    0x98, 0x03,
+    0x99, 0x03,
+    0x9a, 0x03,
+    0x9b, 0x03,
+    0x9c, 0x03,
+    0x9d, 0x03,
+    0x9e, 0x03,
+    0x9f, 0x03,
+    0xa0, 0x03,
+    0xa1, 0x03,
+    0xa3, 0x03,
+    0xa3, 0x03,
+    0xa4, 0x03,
+    0xa5, 0x03,
+    0xa6, 0x03,
+    0xa7, 0x03,
+    0xa8, 0x03,
+    0xa9, 0x03,
+    0xaa, 0x03,
+    0xab, 0x03,
+    0x8c, 0x03,
+    0x8e, 0x03,
+    0x8f, 0x03,
+    0xcf, 0x03,
+    0xd0, 0x03,
+    0xd1, 0x03,
+    0xd2, 0x03,
+    0xd3, 0x03,
+    0xd4, 0x03,
+    0xd5, 0x03,
+    0xd6, 0x03,
+    0xd7, 0x03,
+    0xd8, 0x03,
+    0xd8, 0x03,
+    0xda, 0x03,
+    0xda, 0x03,
+    0xdc, 0x03,
+    0xdc, 0x03,
+    0xde, 0x03,
+    0xde, 0x03,
+    0xe0, 0x03,
+    0xe0, 0x03,
+    0xe2, 0x03,
+    0xe2, 0x03,
+    0xe4, 0x03,
+    0xe4, 0x03,
+    0xe6, 0x03,
+    0xe6, 0x03,
+    0xe8, 0x03,
+    0xe8, 0x03,
+    0xea, 0x03,
+    0xea, 0x03,
+    0xec, 0x03,
+    0xec, 0x03,
+    0xee, 0x03,
+    0xee, 0x03,
+    0xf0, 0x03,
+    0xf1, 0x03,
+    0xf9, 0x03,
+    0xf3, 0x03,
+    0xf4, 0x03,
+    0xf5, 0x03,
+    0xf6, 0x03,
+    0xf7, 0x03,
+    0xf7, 0x03,
+    0xf9, 0x03,
+    0xfa, 0x03,
+    0xfa, 0x03,
+    0xfc, 0x03,
+    0xfd, 0x03,
+    0xfe, 0x03,
+    0xff, 0x03,
+    0x00, 0x04,
+    0x01, 0x04,
+    0x02, 0x04,
+    0x03, 0x04,
+    0x04, 0x04,
+    0x05, 0x04,
+    0x06, 0x04,
+    0x07, 0x04,
+    0x08, 0x04,
+    0x09, 0x04,
+    0x0a, 0x04,
+    0x0b, 0x04,
+    0x0c, 0x04,
+    0x0d, 0x04,
+    0x0e, 0x04,
+    0x0f, 0x04,
+    0x10, 0x04,
+    0x11, 0x04,
+    0x12, 0x04,
+    0x13, 0x04,
+    0x14, 0x04,
+    0x15, 0x04,
+    0x16, 0x04,
+    0x17, 0x04,
+    0x18, 0x04,
+    0x19, 0x04,
+    0x1a, 0x04,
+    0x1b, 0x04,
+    0x1c, 0x04,
+    0x1d, 0x04,
+    0x1e, 0x04,
+    0x1f, 0x04,
+    0x20, 0x04,
+    0x21, 0x04,
+    0x22, 0x04,
+    0x23, 0x04,
+    0x24, 0x04,
+    0x25, 0x04,
+    0x26, 0x04,
+    0x27, 0x04,
+    0x28, 0x04,
+    0x29, 0x04,
+    0x2a, 0x04,
+    0x2b, 0x04,
+    0x2c, 0x04,
+    0x2d, 0x04,
+    0x2e, 0x04,
+    0x2f, 0x04,
+    0x10, 0x04,
+    0x11, 0x04,
+    0x12, 0x04,
+    0x13, 0x04,
+    0x14, 0x04,
+    0x15, 0x04,
+    0x16, 0x04,
+    0x17, 0x04,
+    0x18, 0x04,
+    0x19, 0x04,
+    0x1a, 0x04,
+    0x1b, 0x04,
+    0x1c, 0x04,
+    0x1d, 0x04,
+    0x1e, 0x04,
+    0x1f, 0x04,
+    0x20, 0x04,
+    0x21, 0x04,
+    0x22, 0x04,
+    0x23, 0x04,
+    0x24, 0x04,
+    0x25, 0x04,
+    0x26, 0x04,
+    0x27, 0x04,
+    0x28, 0x04,
+    0x29, 0x04,
+    0x2a, 0x04,
+    0x2b, 0x04,
+    0x2c, 0x04,
+    0x2d, 0x04,
+    0x2e, 0x04,
+    0x2f, 0x04,
+    0x00, 0x04,
+    0x01, 0x04,
+    0x02, 0x04,
+    0x03, 0x04,
+    0x04, 0x04,
+    0x05, 0x04,
+    0x06, 0x04,
+    0x07, 0x04,
+    0x08, 0x04,
+    0x09, 0x04,
+    0x0a, 0x04,
+    0x0b, 0x04,
+    0x0c, 0x04,
+    0x0d, 0x04,
+    0x0e, 0x04,
+    0x0f, 0x04,
+    0x60, 0x04,
+    0x60, 0x04,
+    0x62, 0x04,
+    0x62, 0x04,
+    0x64, 0x04,
+    0x64, 0x04,
+    0x66, 0x04,
+    0x66, 0x04,
+    0x68, 0x04,
+    0x68, 0x04,
+    0x6a, 0x04,
+    0x6a, 0x04,
+    0x6c, 0x04,
+    0x6c, 0x04,
+    0x6e, 0x04,
+    0x6e, 0x04,
+    0x70, 0x04,
+    0x70, 0x04,
+    0x72, 0x04,
+    0x72, 0x04,
+    0x74, 0x04,
+    0x74, 0x04,
+    0x76, 0x04,
+    0x76, 0x04,
+    0x78, 0x04,
+    0x78, 0x04,
+    0x7a, 0x04,
+    0x7a, 0x04,
+    0x7c, 0x04,
+    0x7c, 0x04,
+    0x7e, 0x04,
+    0x7e, 0x04,
+    0x80, 0x04,
+    0x80, 0x04,
+    0x82, 0x04,
+    0x83, 0x04,
+    0x84, 0x04,
+    0x85, 0x04,
+    0x86, 0x04,
+    0x87, 0x04,
+    0x88, 0x04,
+    0x89, 0x04,
+    0x8a, 0x04,
+    0x8a, 0x04,
+    0x8c, 0x04,
+    0x8c, 0x04,
+    0x8e, 0x04,
+    0x8e, 0x04,
+    0x90, 0x04,
+    0x90, 0x04,
+    0x92, 0x04,
+    0x92, 0x04,
+    0x94, 0x04,
+    0x94, 0x04,
+    0x96, 0x04,
+    0x96, 0x04,
+    0x98, 0x04,
+    0x98, 0x04,
+    0x9a, 0x04,
+    0x9a, 0x04,
+    0x9c, 0x04,
+    0x9c, 0x04,
+    0x9e, 0x04,
+    0x9e, 0x04,
+    0xa0, 0x04,
+    0xa0, 0x04,
+    0xa2, 0x04,
+    0xa2, 0x04,
+    0xa4, 0x04,
+    0xa4, 0x04,
+    0xa6, 0x04,
+    0xa6, 0x04,
+    0xa8, 0x04,
+    0xa8, 0x04,
+    0xaa, 0x04,
+    0xaa, 0x04,
+    0xac, 0x04,
+    0xac, 0x04,
+    0xae, 0x04,
+    0xae, 0x04,
+    0xb0, 0x04,
+    0xb0, 0x04,
+    0xb2, 0x04,
+    0xb2, 0x04,
+    0xb4, 0x04,
+    0xb4, 0x04,
+    0xb6, 0x04,
+    0xb6, 0x04,
+    0xb8, 0x04,
+    0xb8, 0x04,
+    0xba, 0x04,
+    0xba, 0x04,
+    0xbc, 0x04,
+    0xbc, 0x04,
+    0xbe, 0x04,
+    0xbe, 0x04,
+    0xc0, 0x04,
+    0xc1, 0x04,
+    0xc1, 0x04,
+    0xc3, 0x04,
+    0xc3, 0x04,
+    0xc5, 0x04,
+    0xc5, 0x04,
+    0xc7, 0x04,
+    0xc7, 0x04,
+    0xc9, 0x04,
+    0xc9, 0x04,
+    0xcb, 0x04,
+    0xcb, 0x04,
+    0xcd, 0x04,
+    0xcd, 0x04,
+    0xc0, 0x04,
+    0xd0, 0x04,
+    0xd0, 0x04,
+    0xd2, 0x04,
+    0xd2, 0x04,
+    0xd4, 0x04,
+    0xd4, 0x04,
+    0xd6, 0x04,
+    0xd6, 0x04,
+    0xd8, 0x04,
+    0xd8, 0x04,
+    0xda, 0x04,
+    0xda, 0x04,
+    0xdc, 0x04,
+    0xdc, 0x04,
+    0xde, 0x04,
+    0xde, 0x04,
+    0xe0, 0x04,
+    0xe0, 0x04,
+    0xe2, 0x04,
+    0xe2, 0x04,
+    0xe4, 0x04,
+    0xe4, 0x04,
+    0xe6, 0x04,
+    0xe6, 0x04,
+    0xe8, 0x04,
+    0xe8, 0x04,
+    0xea, 0x04,
+    0xea, 0x04,
+    0xec, 0x04,
+    0xec, 0x04,
+    0xee, 0x04,
+    0xee, 0x04,
+    0xf0, 0x04,
+    0xf0, 0x04,
+    0xf2, 0x04,
+    0xf2, 0x04,
+    0xf4, 0x04,
+    0xf4, 0x04,
+    0xf6, 0x04,
+    0xf6, 0x04,
+    0xf8, 0x04,
+    0xf8, 0x04,
+    0xfa, 0x04,
+    0xfa, 0x04,
+    0xfc, 0x04,
+    0xfc, 0x04,
+    0xfe, 0x04,
+    0xfe, 0x04,
+    0x00, 0x05,
+    0x00, 0x05,
+    0x02, 0x05,
+    0x02, 0x05,
+    0x04, 0x05,
+    0x04, 0x05,
+    0x06, 0x05,
+    0x06, 0x05,
+    0x08, 0x05,
+    0x08, 0x05,
+    0x0a, 0x05,
+    0x0a, 0x05,
+    0x0c, 0x05,
+    0x0c, 0x05,
+    0x0e, 0x05,
+    0x0e, 0x05,
+    0x10, 0x05,
+    0x10, 0x05,
+    0x12, 0x05,
+    0x12, 0x05,
+    0x14, 0x05,
+    0x15, 0x05,
+    0x16, 0x05,
+    0x17, 0x05,
+    0x18, 0x05,
+    0x19, 0x05,
+    0x1a, 0x05,
+    0x1b, 0x05,
+    0x1c, 0x05,
+    0x1d, 0x05,
+    0x1e, 0x05,
+    0x1f, 0x05,
+    0x20, 0x05,
+    0x21, 0x05,
+    0x22, 0x05,
+    0x23, 0x05,
+    0x24, 0x05,
+    0x25, 0x05,
+    0x26, 0x05,
+    0x27, 0x05,
+    0x28, 0x05,
+    0x29, 0x05,
+    0x2a, 0x05,
+    0x2b, 0x05,
+    0x2c, 0x05,
+    0x2d, 0x05,
+    0x2e, 0x05,
+    0x2f, 0x05,
+    0x30, 0x05,
+    0x31, 0x05,
+    0x32, 0x05,
+    0x33, 0x05,
+    0x34, 0x05,
+    0x35, 0x05,
+    0x36, 0x05,
+    0x37, 0x05,
+    0x38, 0x05,
+    0x39, 0x05,
+    0x3a, 0x05,
+    0x3b, 0x05,
+    0x3c, 0x05,
+    0x3d, 0x05,
+    0x3e, 0x05,
+    0x3f, 0x05,
+    0x40, 0x05,
+    0x41, 0x05,
+    0x42, 0x05,
+    0x43, 0x05,
+    0x44, 0x05,
+    0x45, 0x05,
+    0x46, 0x05,
+    0x47, 0x05,
+    0x48, 0x05,
+    0x49, 0x05,
+    0x4a, 0x05,
+    0x4b, 0x05,
+    0x4c, 0x05,
+    0x4d, 0x05,
+    0x4e, 0x05,
+    0x4f, 0x05,
+    0x50, 0x05,
+    0x51, 0x05,
+    0x52, 0x05,
+    0x53, 0x05,
+    0x54, 0x05,
+    0x55, 0x05,
+    0x56, 0x05,
+    0x57, 0x05,
+    0x58, 0x05,
+    0x59, 0x05,
+    0x5a, 0x05,
+    0x5b, 0x05,
+    0x5c, 0x05,
+    0x5d, 0x05,
+    0x5e, 0x05,
+    0x5f, 0x05,
+    0x60, 0x05,
+    0x31, 0x05,
+    0x32, 0x05,
+    0x33, 0x05,
+    0x34, 0x05,
+    0x35, 0x05,
+    0x36, 0x05,
+    0x37, 0x05,
+    0x38, 0x05,
+    0x39, 0x05,
+    0x3a, 0x05,
+    0x3b, 0x05,
+    0x3c, 0x05,
+    0x3d, 0x05,
+    0x3e, 0x05,
+    0x3f, 0x05,
+    0x40, 0x05,
+    0x41, 0x05,
+    0x42, 0x05,
+    0x43, 0x05,
+    0x44, 0x05,
+    0x45, 0x05,
+    0x46, 0x05,
+    0x47, 0x05,
+    0x48, 0x05,
+    0x49, 0x05,
+    0x4a, 0x05,
+    0x4b, 0x05,
+    0x4c, 0x05,
+    0x4d, 0x05,
+    0x4e, 0x05,
+    0x4f, 0x05,
+    0x50, 0x05,
+    0x51, 0x05,
+    0x52, 0x05,
+    0x53, 0x05,
+    0x54, 0x05,
+    0x55, 0x05,
+    0x56, 0x05,
+    0xff, 0xff,
+    0xf6, 0x17,
+    0x63, 0x2c,
+    0x7e, 0x1d,
+    0x7f, 0x1d,
+    0x80, 0x1d,
+    0x81, 0x1d,
+    0x82, 0x1d,
+    0x83, 0x1d,
+    0x84, 0x1d,
+    0x85, 0x1d,
+    0x86, 0x1d,
+    0x87, 0x1d,
+    0x88, 0x1d,
+    0x89, 0x1d,
+    0x8a, 0x1d,
+    0x8b, 0x1d,
+    0x8c, 0x1d,
+    0x8d, 0x1d,
+    0x8e, 0x1d,
+    0x8f, 0x1d,
+    0x90, 0x1d,
+    0x91, 0x1d,
+    0x92, 0x1d,
+    0x93, 0x1d,
+    0x94, 0x1d,
+    0x95, 0x1d,
+    0x96, 0x1d,
+    0x97, 0x1d,
+    0x98, 0x1d,
+    0x99, 0x1d,
+    0x9a, 0x1d,
+    0x9b, 0x1d,
+    0x9c, 0x1d,
+    0x9d, 0x1d,
+    0x9e, 0x1d,
+    0x9f, 0x1d,
+    0xa0, 0x1d,
+    0xa1, 0x1d,
+    0xa2, 0x1d,
+    0xa3, 0x1d,
+    0xa4, 0x1d,
+    0xa5, 0x1d,
+    0xa6, 0x1d,
+    0xa7, 0x1d,
+    0xa8, 0x1d,
+    0xa9, 0x1d,
+    0xaa, 0x1d,
+    0xab, 0x1d,
+    0xac, 0x1d,
+    0xad, 0x1d,
+    0xae, 0x1d,
+    0xaf, 0x1d,
+    0xb0, 0x1d,
+    0xb1, 0x1d,
+    0xb2, 0x1d,
+    0xb3, 0x1d,
+    0xb4, 0x1d,
+    0xb5, 0x1d,
+    0xb6, 0x1d,
+    0xb7, 0x1d,
+    0xb8, 0x1d,
+    0xb9, 0x1d,
+    0xba, 0x1d,
+    0xbb, 0x1d,
+    0xbc, 0x1d,
+    0xbd, 0x1d,
+    0xbe, 0x1d,
+    0xbf, 0x1d,
+    0xc0, 0x1d,
+    0xc1, 0x1d,
+    0xc2, 0x1d,
+    0xc3, 0x1d,
+    0xc4, 0x1d,
+    0xc5, 0x1d,
+    0xc6, 0x1d,
+    0xc7, 0x1d,
+    0xc8, 0x1d,
+    0xc9, 0x1d,
+    0xca, 0x1d,
+    0xcb, 0x1d,
+    0xcc, 0x1d,
+    0xcd, 0x1d,
+    0xce, 0x1d,
+    0xcf, 0x1d,
+    0xd0, 0x1d,
+    0xd1, 0x1d,
+    0xd2, 0x1d,
+    0xd3, 0x1d,
+    0xd4, 0x1d,
+    0xd5, 0x1d,
+    0xd6, 0x1d,
+    0xd7, 0x1d,
+    0xd8, 0x1d,
+    0xd9, 0x1d,
+    0xda, 0x1d,
+    0xdb, 0x1d,
+    0xdc, 0x1d,
+    0xdd, 0x1d,
+    0xde, 0x1d,
+    0xdf, 0x1d,
+    0xe0, 0x1d,
+    0xe1, 0x1d,
+    0xe2, 0x1d,
+    0xe3, 0x1d,
+    0xe4, 0x1d,
+    0xe5, 0x1d,
+    0xe6, 0x1d,
+    0xe7, 0x1d,
+    0xe8, 0x1d,
+    0xe9, 0x1d,
+    0xea, 0x1d,
+    0xeb, 0x1d,
+    0xec, 0x1d,
+    0xed, 0x1d,
+    0xee, 0x1d,
+    0xef, 0x1d,
+    0xf0, 0x1d,
+    0xf1, 0x1d,
+    0xf2, 0x1d,
+    0xf3, 0x1d,
+    0xf4, 0x1d,
+    0xf5, 0x1d,
+    0xf6, 0x1d,
+    0xf7, 0x1d,
+    0xf8, 0x1d,
+    0xf9, 0x1d,
+    0xfa, 0x1d,
+    0xfb, 0x1d,
+    0xfc, 0x1d,
+    0xfd, 0x1d,
+    0xfe, 0x1d,
+    0xff, 0x1d,
+    0x00, 0x1e,
+    0x00, 0x1e,
+    0x02, 0x1e,
+    0x02, 0x1e,
+    0x04, 0x1e,
+    0x04, 0x1e,
+    0x06, 0x1e,
+    0x06, 0x1e,
+    0x08, 0x1e,
+    0x08, 0x1e,
+    0x0a, 0x1e,
+    0x0a, 0x1e,
+    0x0c, 0x1e,
+    0x0c, 0x1e,
+    0x0e, 0x1e,
+    0x0e, 0x1e,
+    0x10, 0x1e,
+    0x10, 0x1e,
+    0x12, 0x1e,
+    0x12, 0x1e,
+    0x14, 0x1e,
+    0x14, 0x1e,
+    0x16, 0x1e,
+    0x16, 0x1e,
+    0x18, 0x1e,
+    0x18, 0x1e,
+    0x1a, 0x1e,
+    0x1a, 0x1e,
+    0x1c, 0x1e,
+    0x1c, 0x1e,
+    0x1e, 0x1e,
+    0x1e, 0x1e,
+    0x20, 0x1e,
+    0x20, 0x1e,
+    0x22, 0x1e,
+    0x22, 0x1e,
+    0x24, 0x1e,
+    0x24, 0x1e,
+    0x26, 0x1e,
+    0x26, 0x1e,
+    0x28, 0x1e,
+    0x28, 0x1e,
+    0x2a, 0x1e,
+    0x2a, 0x1e,
+    0x2c, 0x1e,
+    0x2c, 0x1e,
+    0x2e, 0x1e,
+    0x2e, 0x1e,
+    0x30, 0x1e,
+    0x30, 0x1e,
+    0x32, 0x1e,
+    0x32, 0x1e,
+    0x34, 0x1e,
+    0x34, 0x1e,
+    0x36, 0x1e,
+    0x36, 0x1e,
+    0x38, 0x1e,
+    0x38, 0x1e,
+    0x3a, 0x1e,
+    0x3a, 0x1e,
+    0x3c, 0x1e,
+    0x3c, 0x1e,
+    0x3e, 0x1e,
+    0x3e, 0x1e,
+    0x40, 0x1e,
+    0x40, 0x1e,
+    0x42, 0x1e,
+    0x42, 0x1e,
+    0x44, 0x1e,
+    0x44, 0x1e,
+    0x46, 0x1e,
+    0x46, 0x1e,
+    0x48, 0x1e,
+    0x48, 0x1e,
+    0x4a, 0x1e,
+    0x4a, 0x1e,
+    0x4c, 0x1e,
+    0x4c, 0x1e,
+    0x4e, 0x1e,
+    0x4e, 0x1e,
+    0x50, 0x1e,
+    0x50, 0x1e,
+    0x52, 0x1e,
+    0x52, 0x1e,
+    0x54, 0x1e,
+    0x54, 0x1e,
+    0x56, 0x1e,
+    0x56, 0x1e,
+    0x58, 0x1e,
+    0x58, 0x1e,
+    0x5a, 0x1e,
+    0x5a, 0x1e,
+    0x5c, 0x1e,
+    0x5c, 0x1e,
+    0x5e, 0x1e,
+    0x5e, 0x1e,
+    0x60, 0x1e,
+    0x60, 0x1e,
+    0x62, 0x1e,
+    0x62, 0x1e,
+    0x64, 0x1e,
+    0x64, 0x1e,
+    0x66, 0x1e,
+    0x66, 0x1e,
+    0x68, 0x1e,
+    0x68, 0x1e,
+    0x6a, 0x1e,
+    0x6a, 0x1e,
+    0x6c, 0x1e,
+    0x6c, 0x1e,
+    0x6e, 0x1e,
+    0x6e, 0x1e,
+    0x70, 0x1e,
+    0x70, 0x1e,
+    0x72, 0x1e,
+    0x72, 0x1e,
+    0x74, 0x1e,
+    0x74, 0x1e,
+    0x76, 0x1e,
+    0x76, 0x1e,
+    0x78, 0x1e,
+    0x78, 0x1e,
+    0x7a, 0x1e,
+    0x7a, 0x1e,
+    0x7c, 0x1e,
+    0x7c, 0x1e,
+    0x7e, 0x1e,
+    0x7e, 0x1e,
+    0x80, 0x1e,
+    0x80, 0x1e,
+    0x82, 0x1e,
+    0x82, 0x1e,
+    0x84, 0x1e,
+    0x84, 0x1e,
+    0x86, 0x1e,
+    0x86, 0x1e,
+    0x88, 0x1e,
+    0x88, 0x1e,
+    0x8a, 0x1e,
+    0x8a, 0x1e,
+    0x8c, 0x1e,
+    0x8c, 0x1e,
+    0x8e, 0x1e,
+    0x8e, 0x1e,
+    0x90, 0x1e,
+    0x90, 0x1e,
+    0x92, 0x1e,
+    0x92, 0x1e,
+    0x94, 0x1e,
+    0x94, 0x1e,
+    0x96, 0x1e,
+    0x97, 0x1e,
+    0x98, 0x1e,
+    0x99, 0x1e,
+    0x9a, 0x1e,
+    0x9b, 0x1e,
+    0x9c, 0x1e,
+    0x9d, 0x1e,
+    0x9e, 0x1e,
+    0x9f, 0x1e,
+    0xa0, 0x1e,
+    0xa0, 0x1e,
+    0xa2, 0x1e,
+    0xa2, 0x1e,
+    0xa4, 0x1e,
+    0xa4, 0x1e,
+    0xa6, 0x1e,
+    0xa6, 0x1e,
+    0xa8, 0x1e,
+    0xa8, 0x1e,
+    0xaa, 0x1e,
+    0xaa, 0x1e,
+    0xac, 0x1e,
+    0xac, 0x1e,
+    0xae, 0x1e,
+    0xae, 0x1e,
+    0xb0, 0x1e,
+    0xb0, 0x1e,
+    0xb2, 0x1e,
+    0xb2, 0x1e,
+    0xb4, 0x1e,
+    0xb4, 0x1e,
+    0xb6, 0x1e,
+    0xb6, 0x1e,
+    0xb8, 0x1e,
+    0xb8, 0x1e,
+    0xba, 0x1e,
+    0xba, 0x1e,
+    0xbc, 0x1e,
+    0xbc, 0x1e,
+    0xbe, 0x1e,
+    0xbe, 0x1e,
+    0xc0, 0x1e,
+    0xc0, 0x1e,
+    0xc2, 0x1e,
+    0xc2, 0x1e,
+    0xc4, 0x1e,
+    0xc4, 0x1e,
+    0xc6, 0x1e,
+    0xc6, 0x1e,
+    0xc8, 0x1e,
+    0xc8, 0x1e,
+    0xca, 0x1e,
+    0xca, 0x1e,
+    0xcc, 0x1e,
+    0xcc, 0x1e,
+    0xce, 0x1e,
+    0xce, 0x1e,
+    0xd0, 0x1e,
+    0xd0, 0x1e,
+    0xd2, 0x1e,
+    0xd2, 0x1e,
+    0xd4, 0x1e,
+    0xd4, 0x1e,
+    0xd6, 0x1e,
+    0xd6, 0x1e,
+    0xd8, 0x1e,
+    0xd8, 0x1e,
+    0xda, 0x1e,
+    0xda, 0x1e,
+    0xdc, 0x1e,
+    0xdc, 0x1e,
+    0xde, 0x1e,
+    0xde, 0x1e,
+    0xe0, 0x1e,
+    0xe0, 0x1e,
+    0xe2, 0x1e,
+    0xe2, 0x1e,
+    0xe4, 0x1e,
+    0xe4, 0x1e,
+    0xe6, 0x1e,
+    0xe6, 0x1e,
+    0xe8, 0x1e,
+    0xe8, 0x1e,
+    0xea, 0x1e,
+    0xea, 0x1e,
+    0xec, 0x1e,
+    0xec, 0x1e,
+    0xee, 0x1e,
+    0xee, 0x1e,
+    0xf0, 0x1e,
+    0xf0, 0x1e,
+    0xf2, 0x1e,
+    0xf2, 0x1e,
+    0xf4, 0x1e,
+    0xf4, 0x1e,
+    0xf6, 0x1e,
+    0xf6, 0x1e,
+    0xf8, 0x1e,
+    0xf8, 0x1e,
+    0xfa, 0x1e,
+    0xfb, 0x1e,
+    0xfc, 0x1e,
+    0xfd, 0x1e,
+    0xfe, 0x1e,
+    0xff, 0x1e,
+    0x08, 0x1f,
+    0x09, 0x1f,
+    0x0a, 0x1f,
+    0x0b, 0x1f,
+    0x0c, 0x1f,
+    0x0d, 0x1f,
+    0x0e, 0x1f,
+    0x0f, 0x1f,
+    0x08, 0x1f,
+    0x09, 0x1f,
+    0x0a, 0x1f,
+    0x0b, 0x1f,
+    0x0c, 0x1f,
+    0x0d, 0x1f,
+    0x0e, 0x1f,
+    0x0f, 0x1f,
+    0x18, 0x1f,
+    0x19, 0x1f,
+    0x1a, 0x1f,
+    0x1b, 0x1f,
+    0x1c, 0x1f,
+    0x1d, 0x1f,
+    0x16, 0x1f,
+    0x17, 0x1f,
+    0x18, 0x1f,
+    0x19, 0x1f,
+    0x1a, 0x1f,
+    0x1b, 0x1f,
+    0x1c, 0x1f,
+    0x1d, 0x1f,
+    0x1e, 0x1f,
+    0x1f, 0x1f,
+    0x28, 0x1f,
+    0x29, 0x1f,
+    0x2a, 0x1f,
+    0x2b, 0x1f,
+    0x2c, 0x1f,
+    0x2d, 0x1f,
+    0x2e, 0x1f,
+    0x2f, 0x1f,
+    0x28, 0x1f,
+    0x29, 0x1f,
+    0x2a, 0x1f,
+    0x2b, 0x1f,
+    0x2c, 0x1f,
+    0x2d, 0x1f,
+    0x2e, 0x1f,
+    0x2f, 0x1f,
+    0x38, 0x1f,
+    0x39, 0x1f,
+    0x3a, 0x1f,
+    0x3b, 0x1f,
+    0x3c, 0x1f,
+    0x3d, 0x1f,
+    0x3e, 0x1f,
+    0x3f, 0x1f,
+    0x38, 0x1f,
+    0x39, 0x1f,
+    0x3a, 0x1f,
+    0x3b, 0x1f,
+    0x3c, 0x1f,
+    0x3d, 0x1f,
+    0x3e, 0x1f,
+    0x3f, 0x1f,
+    0x48, 0x1f,
+    0x49, 0x1f,
+    0x4a, 0x1f,
+    0x4b, 0x1f,
+    0x4c, 0x1f,
+    0x4d, 0x1f,
+    0x46, 0x1f,
+    0x47, 0x1f,
+    0x48, 0x1f,
+    0x49, 0x1f,
+    0x4a, 0x1f,
+    0x4b, 0x1f,
+    0x4c, 0x1f,
+    0x4d, 0x1f,
+    0x4e, 0x1f,
+    0x4f, 0x1f,
+    0x50, 0x1f,
+    0x59, 0x1f,
+    0x52, 0x1f,
+    0x5b, 0x1f,
+    0x54, 0x1f,
+    0x5d, 0x1f,
+    0x56, 0x1f,
+    0x5f, 0x1f,
+    0x58, 0x1f,
+    0x59, 0x1f,
+    0x5a, 0x1f,
+    0x5b, 0x1f,
+    0x5c, 0x1f,
+    0x5d, 0x1f,
+    0x5e, 0x1f,
+    0x5f, 0x1f,
+    0x68, 0x1f,
+    0x69, 0x1f,
+    0x6a, 0x1f,
+    0x6b, 0x1f,
+    0x6c, 0x1f,
+    0x6d, 0x1f,
+    0x6e, 0x1f,
+    0x6f, 0x1f,
+    0x68, 0x1f,
+    0x69, 0x1f,
+    0x6a, 0x1f,
+    0x6b, 0x1f,
+    0x6c, 0x1f,
+    0x6d, 0x1f,
+    0x6e, 0x1f,
+    0x6f, 0x1f,
+    0xba, 0x1f,
+    0xbb, 0x1f,
+    0xc8, 0x1f,
+    0xc9, 0x1f,
+    0xca, 0x1f,
+    0xcb, 0x1f,
+    0xda, 0x1f,
+    0xdb, 0x1f,
+    0xf8, 0x1f,
+    0xf9, 0x1f,
+    0xea, 0x1f,
+    0xeb, 0x1f,
+    0xfa, 0x1f,
+    0xfb, 0x1f,
+    0x7e, 0x1f,
+    0x7f, 0x1f,
+    0x88, 0x1f,
+    0x89, 0x1f,
+    0x8a, 0x1f,
+    0x8b, 0x1f,
+    0x8c, 0x1f,
+    0x8d, 0x1f,
+    0x8e, 0x1f,
+    0x8f, 0x1f,
+    0x88, 0x1f,
+    0x89, 0x1f,
+    0x8a, 0x1f,
+    0x8b, 0x1f,
+    0x8c, 0x1f,
+    0x8d, 0x1f,
+    0x8e, 0x1f,
+    0x8f, 0x1f,
+    0x98, 0x1f,
+    0x99, 0x1f,
+    0x9a, 0x1f,
+    0x9b, 0x1f,
+    0x9c, 0x1f,
+    0x9d, 0x1f,
+    0x9e, 0x1f,
+    0x9f, 0x1f,
+    0x98, 0x1f,
+    0x99, 0x1f,
+    0x9a, 0x1f,
+    0x9b, 0x1f,
+    0x9c, 0x1f,
+    0x9d, 0x1f,
+    0x9e, 0x1f,
+    0x9f, 0x1f,
+    0xa8, 0x1f,
+    0xa9, 0x1f,
+    0xaa, 0x1f,
+    0xab, 0x1f,
+    0xac, 0x1f,
+    0xad, 0x1f,
+    0xae, 0x1f,
+    0xaf, 0x1f,
+    0xa8, 0x1f,
+    0xa9, 0x1f,
+    0xaa, 0x1f,
+    0xab, 0x1f,
+    0xac, 0x1f,
+    0xad, 0x1f,
+    0xae, 0x1f,
+    0xaf, 0x1f,
+    0xb8, 0x1f,
+    0xb9, 0x1f,
+    0xb2, 0x1f,
+    0xbc, 0x1f,
+    0xb4, 0x1f,
+    0xb5, 0x1f,
+    0xb6, 0x1f,
+    0xb7, 0x1f,
+    0xb8, 0x1f,
+    0xb9, 0x1f,
+    0xba, 0x1f,
+    0xbb, 0x1f,
+    0xbc, 0x1f,
+    0xbd, 0x1f,
+    0xbe, 0x1f,
+    0xbf, 0x1f,
+    0xc0, 0x1f,
+    0xc1, 0x1f,
+    0xc2, 0x1f,
+    0xc3, 0x1f,
+    0xc4, 0x1f,
+    0xc5, 0x1f,
+    0xc6, 0x1f,
+    0xc7, 0x1f,
+    0xc8, 0x1f,
+    0xc9, 0x1f,
+    0xca, 0x1f,
+    0xcb, 0x1f,
+    0xc3, 0x1f,
+    0xcd, 0x1f,
+    0xce, 0x1f,
+    0xcf, 0x1f,
+    0xd8, 0x1f,
+    0xd9, 0x1f,
+    0xd2, 0x1f,
+    0xd3, 0x1f,
+    0xd4, 0x1f,
+    0xd5, 0x1f,
+    0xd6, 0x1f,
+    0xd7, 0x1f,
+    0xd8, 0x1f,
+    0xd9, 0x1f,
+    0xda, 0x1f,
+    0xdb, 0x1f,
+    0xdc, 0x1f,
+    0xdd, 0x1f,
+    0xde, 0x1f,
+    0xdf, 0x1f,
+    0xe8, 0x1f,
+    0xe9, 0x1f,
+    0xe2, 0x1f,
+    0xe3, 0x1f,
+    0xe4, 0x1f,
+    0xec, 0x1f,
+    0xe6, 0x1f,
+    0xe7, 0x1f,
+    0xe8, 0x1f,
+    0xe9, 0x1f,
+    0xea, 0x1f,
+    0xeb, 0x1f,
+    0xec, 0x1f,
+    0xed, 0x1f,
+    0xee, 0x1f,
+    0xef, 0x1f,
+    0xf0, 0x1f,
+    0xf1, 0x1f,
+    0xf2, 0x1f,
+    0xf3, 0x1f,
+    0xf4, 0x1f,
+    0xf5, 0x1f,
+    0xf6, 0x1f,
+    0xf7, 0x1f,
+    0xf8, 0x1f,
+    0xf9, 0x1f,
+    0xfa, 0x1f,
+    0xfb, 0x1f,
+    0xf3, 0x1f,
+    0xfd, 0x1f,
+    0xfe, 0x1f,
+    0xff, 0x1f,
+    0x00, 0x20,
+    0x01, 0x20,
+    0x02, 0x20,
+    0x03, 0x20,
+    0x04, 0x20,
+    0x05, 0x20,
+    0x06, 0x20,
+    0x07, 0x20,
+    0x08, 0x20,
+    0x09, 0x20,
+    0x0a, 0x20,
+    0x0b, 0x20,
+    0x0c, 0x20,
+    0x0d, 0x20,
+    0x0e, 0x20,
+    0x0f, 0x20,
+    0x10, 0x20,
+    0x11, 0x20,
+    0x12, 0x20,
+    0x13, 0x20,
+    0x14, 0x20,
+    0x15, 0x20,
+    0x16, 0x20,
+    0x17, 0x20,
+    0x18, 0x20,
+    0x19, 0x20,
+    0x1a, 0x20,
+    0x1b, 0x20,
+    0x1c, 0x20,
+    0x1d, 0x20,
+    0x1e, 0x20,
+    0x1f, 0x20,
+    0x20, 0x20,
+    0x21, 0x20,
+    0x22, 0x20,
+    0x23, 0x20,
+    0x24, 0x20,
+    0x25, 0x20,
+    0x26, 0x20,
+    0x27, 0x20,
+    0x28, 0x20,
+    0x29, 0x20,
+    0x2a, 0x20,
+    0x2b, 0x20,
+    0x2c, 0x20,
+    0x2d, 0x20,
+    0x2e, 0x20,
+    0x2f, 0x20,
+    0x30, 0x20,
+    0x31, 0x20,
+    0x32, 0x20,
+    0x33, 0x20,
+    0x34, 0x20,
+    0x35, 0x20,
+    0x36, 0x20,
+    0x37, 0x20,
+    0x38, 0x20,
+    0x39, 0x20,
+    0x3a, 0x20,
+    0x3b, 0x20,
+    0x3c, 0x20,
+    0x3d, 0x20,
+    0x3e, 0x20,
+    0x3f, 0x20,
+    0x40, 0x20,
+    0x41, 0x20,
+    0x42, 0x20,
+    0x43, 0x20,
+    0x44, 0x20,
+    0x45, 0x20,
+    0x46, 0x20,
+    0x47, 0x20,
+    0x48, 0x20,
+    0x49, 0x20,
+    0x4a, 0x20,
+    0x4b, 0x20,
+    0x4c, 0x20,
+    0x4d, 0x20,
+    0x4e, 0x20,
+    0x4f, 0x20,
+    0x50, 0x20,
+    0x51, 0x20,
+    0x52, 0x20,
+    0x53, 0x20,
+    0x54, 0x20,
+    0x55, 0x20,
+    0x56, 0x20,
+    0x57, 0x20,
+    0x58, 0x20,
+    0x59, 0x20,
+    0x5a, 0x20,
+    0x5b, 0x20,
+    0x5c, 0x20,
+    0x5d, 0x20,
+    0x5e, 0x20,
+    0x5f, 0x20,
+    0x60, 0x20,
+    0x61, 0x20,
+    0x62, 0x20,
+    0x63, 0x20,
+    0x64, 0x20,
+    0x65, 0x20,
+    0x66, 0x20,
+    0x67, 0x20,
+    0x68, 0x20,
+    0x69, 0x20,
+    0x6a, 0x20,
+    0x6b, 0x20,
+    0x6c, 0x20,
+    0x6d, 0x20,
+    0x6e, 0x20,
+    0x6f, 0x20,
+    0x70, 0x20,
+    0x71, 0x20,
+    0x72, 0x20,
+    0x73, 0x20,
+    0x74, 0x20,
+    0x75, 0x20,
+    0x76, 0x20,
+    0x77, 0x20,
+    0x78, 0x20,
+    0x79, 0x20,
+    0x7a, 0x20,
+    0x7b, 0x20,
+    0x7c, 0x20,
+    0x7d, 0x20,
+    0x7e, 0x20,
+    0x7f, 0x20,
+    0x80, 0x20,
+    0x81, 0x20,
+    0x82, 0x20,
+    0x83, 0x20,
+    0x84, 0x20,
+    0x85, 0x20,
+    0x86, 0x20,
+    0x87, 0x20,
+    0x88, 0x20,
+    0x89, 0x20,
+    0x8a, 0x20,
+    0x8b, 0x20,
+    0x8c, 0x20,
+    0x8d, 0x20,
+    0x8e, 0x20,
+    0x8f, 0x20,
+    0x90, 0x20,
+    0x91, 0x20,
+    0x92, 0x20,
+    0x93, 0x20,
+    0x94, 0x20,
+    0x95, 0x20,
+    0x96, 0x20,
+    0x97, 0x20,
+    0x98, 0x20,
+    0x99, 0x20,
+    0x9a, 0x20,
+    0x9b, 0x20,
+    0x9c, 0x20,
+    0x9d, 0x20,
+    0x9e, 0x20,
+    0x9f, 0x20,
+    0xa0, 0x20,
+    0xa1, 0x20,
+    0xa2, 0x20,
+    0xa3, 0x20,
+    0xa4, 0x20,
+    0xa5, 0x20,
+    0xa6, 0x20,
+    0xa7, 0x20,
+    0xa8, 0x20,
+    0xa9, 0x20,
+    0xaa, 0x20,
+    0xab, 0x20,
+    0xac, 0x20,
+    0xad, 0x20,
+    0xae, 0x20,
+    0xaf, 0x20,
+    0xb0, 0x20,
+    0xb1, 0x20,
+    0xb2, 0x20,
+    0xb3, 0x20,
+    0xb4, 0x20,
+    0xb5, 0x20,
+    0xb6, 0x20,
+    0xb7, 0x20,
+    0xb8, 0x20,
+    0xb9, 0x20,
+    0xba, 0x20,
+    0xbb, 0x20,
+    0xbc, 0x20,
+    0xbd, 0x20,
+    0xbe, 0x20,
+    0xbf, 0x20,
+    0xc0, 0x20,
+    0xc1, 0x20,
+    0xc2, 0x20,
+    0xc3, 0x20,
+    0xc4, 0x20,
+    0xc5, 0x20,
+    0xc6, 0x20,
+    0xc7, 0x20,
+    0xc8, 0x20,
+    0xc9, 0x20,
+    0xca, 0x20,
+    0xcb, 0x20,
+    0xcc, 0x20,
+    0xcd, 0x20,
+    0xce, 0x20,
+    0xcf, 0x20,
+    0xd0, 0x20,
+    0xd1, 0x20,
+    0xd2, 0x20,
+    0xd3, 0x20,
+    0xd4, 0x20,
+    0xd5, 0x20,
+    0xd6, 0x20,
+    0xd7, 0x20,
+    0xd8, 0x20,
+    0xd9, 0x20,
+    0xda, 0x20,
+    0xdb, 0x20,
+    0xdc, 0x20,
+    0xdd, 0x20,
+    0xde, 0x20,
+    0xdf, 0x20,
+    0xe0, 0x20,
+    0xe1, 0x20,
+    0xe2, 0x20,
+    0xe3, 0x20,
+    0xe4, 0x20,
+    0xe5, 0x20,
+    0xe6, 0x20,
+    0xe7, 0x20,
+    0xe8, 0x20,
+    0xe9, 0x20,
+    0xea, 0x20,
+    0xeb, 0x20,
+    0xec, 0x20,
+    0xed, 0x20,
+    0xee, 0x20,
+    0xef, 0x20,
+    0xf0, 0x20,
+    0xf1, 0x20,
+    0xf2, 0x20,
+    0xf3, 0x20,
+    0xf4, 0x20,
+    0xf5, 0x20,
+    0xf6, 0x20,
+    0xf7, 0x20,
+    0xf8, 0x20,
+    0xf9, 0x20,
+    0xfa, 0x20,
+    0xfb, 0x20,
+    0xfc, 0x20,
+    0xfd, 0x20,
+    0xfe, 0x20,
+    0xff, 0x20,
+    0x00, 0x21,
+    0x01, 0x21,
+    0x02, 0x21,
+    0x03, 0x21,
+    0x04, 0x21,
+    0x05, 0x21,
+    0x06, 0x21,
+    0x07, 0x21,
+    0x08, 0x21,
+    0x09, 0x21,
+    0x0a, 0x21,
+    0x0b, 0x21,
+    0x0c, 0x21,
+    0x0d, 0x21,
+    0x0e, 0x21,
+    0x0f, 0x21,
+    0x10, 0x21,
+    0x11, 0x21,
+    0x12, 0x21,
+    0x13, 0x21,
+    0x14, 0x21,
+    0x15, 0x21,
+    0x16, 0x21,
+    0x17, 0x21,
+    0x18, 0x21,
+    0x19, 0x21,
+    0x1a, 0x21,
+    0x1b, 0x21,
+    0x1c, 0x21,
+    0x1d, 0x21,
+    0x1e, 0x21,
+    0x1f, 0x21,
+    0x20, 0x21,
+    0x21, 0x21,
+    0x22, 0x21,
+    0x23, 0x21,
+    0x24, 0x21,
+    0x25, 0x21,
+    0x26, 0x21,
+    0x27, 0x21,
+    0x28, 0x21,
+    0x29, 0x21,
+    0x2a, 0x21,
+    0x2b, 0x21,
+    0x2c, 0x21,
+    0x2d, 0x21,
+    0x2e, 0x21,
+    0x2f, 0x21,
+    0x30, 0x21,
+    0x31, 0x21,
+    0x32, 0x21,
+    0x33, 0x21,
+    0x34, 0x21,
+    0x35, 0x21,
+    0x36, 0x21,
+    0x37, 0x21,
+    0x38, 0x21,
+    0x39, 0x21,
+    0x3a, 0x21,
+    0x3b, 0x21,
+    0x3c, 0x21,
+    0x3d, 0x21,
+    0x3e, 0x21,
+    0x3f, 0x21,
+    0x40, 0x21,
+    0x41, 0x21,
+    0x42, 0x21,
+    0x43, 0x21,
+    0x44, 0x21,
+    0x45, 0x21,
+    0x46, 0x21,
+    0x47, 0x21,
+    0x48, 0x21,
+    0x49, 0x21,
+    0x4a, 0x21,
+    0x4b, 0x21,
+    0x4c, 0x21,
+    0x4d, 0x21,
+    0x32, 0x21,
+    0x4f, 0x21,
+    0x50, 0x21,
+    0x51, 0x21,
+    0x52, 0x21,
+    0x53, 0x21,
+    0x54, 0x21,
+    0x55, 0x21,
+    0x56, 0x21,
+    0x57, 0x21,
+    0x58, 0x21,
+    0x59, 0x21,
+    0x5a, 0x21,
+    0x5b, 0x21,
+    0x5c, 0x21,
+    0x5d, 0x21,
+    0x5e, 0x21,
+    0x5f, 0x21,
+    0x60, 0x21,
+    0x61, 0x21,
+    0x62, 0x21,
+    0x63, 0x21,
+    0x64, 0x21,
+    0x65, 0x21,
+    0x66, 0x21,
+    0x67, 0x21,
+    0x68, 0x21,
+    0x69, 0x21,
+    0x6a, 0x21,
+    0x6b, 0x21,
+    0x6c, 0x21,
+    0x6d, 0x21,
+    0x6e, 0x21,
+    0x6f, 0x21,
+    0x60, 0x21,
+    0x61, 0x21,
+    0x62, 0x21,
+    0x63, 0x21,
+    0x64, 0x21,
+    0x65, 0x21,
+    0x66, 0x21,
+    0x67, 0x21,
+    0x68, 0x21,
+    0x69, 0x21,
+    0x6a, 0x21,
+    0x6b, 0x21,
+    0x6c, 0x21,
+    0x6d, 0x21,
+    0x6e, 0x21,
+    0x6f, 0x21,
+    0x80, 0x21,
+    0x81, 0x21,
+    0x82, 0x21,
+    0x83, 0x21,
+    0x83, 0x21,
+    0xff, 0xff,
+    0x4b, 0x03,
+    0xb6, 0x24,
+    0xb7, 0x24,
+    0xb8, 0x24,
+    0xb9, 0x24,
+    0xba, 0x24,
+    0xbb, 0x24,
+    0xbc, 0x24,
+    0xbd, 0x24,
+    0xbe, 0x24,
+    0xbf, 0x24,
+    0xc0, 0x24,
+    0xc1, 0x24,
+    0xc2, 0x24,
+    0xc3, 0x24,
+    0xc4, 0x24,
+    0xc5, 0x24,
+    0xc6, 0x24,
+    0xc7, 0x24,
+    0xc8, 0x24,
+    0xc9, 0x24,
+    0xca, 0x24,
+    0xcb, 0x24,
+    0xcc, 0x24,
+    0xcd, 0x24,
+    0xce, 0x24,
+    0xcf, 0x24,
+    0xff, 0xff,
+    0x46, 0x07,
+    0x00, 0x2c,
+    0x01, 0x2c,
+    0x02, 0x2c,
+    0x03, 0x2c,
+    0x04, 0x2c,
+    0x05, 0x2c,
+    0x06, 0x2c,
+    0x07, 0x2c,
+    0x08, 0x2c,
+    0x09, 0x2c,
+    0x0a, 0x2c,
+    0x0b, 0x2c,
+    0x0c, 0x2c,
+    0x0d, 0x2c,
+    0x0e, 0x2c,
+    0x0f, 0x2c,
+    0x10, 0x2c,
+    0x11, 0x2c,
+    0x12, 0x2c,
+    0x13, 0x2c,
+    0x14, 0x2c,
+    0x15, 0x2c,
+    0x16, 0x2c,
+    0x17, 0x2c,
+    0x18, 0x2c,
+    0x19, 0x2c,
+    0x1a, 0x2c,
+    0x1b, 0x2c,
+    0x1c, 0x2c,
+    0x1d, 0x2c,
+    0x1e, 0x2c,
+    0x1f, 0x2c,
+    0x20, 0x2c,
+    0x21, 0x2c,
+    0x22, 0x2c,
+    0x23, 0x2c,
+    0x24, 0x2c,
+    0x25, 0x2c,
+    0x26, 0x2c,
+    0x27, 0x2c,
+    0x28, 0x2c,
+    0x29, 0x2c,
+    0x2a, 0x2c,
+    0x2b, 0x2c,
+    0x2c, 0x2c,
+    0x2d, 0x2c,
+    0x2e, 0x2c,
+    0x5f, 0x2c,
+    0x60, 0x2c,
+    0x60, 0x2c,
+    0x62, 0x2c,
+    0x63, 0x2c,
+    0x64, 0x2c,
+    0x65, 0x2c,
+    0x66, 0x2c,
+    0x67, 0x2c,
+    0x67, 0x2c,
+    0x69, 0x2c,
+    0x69, 0x2c,
+    0x6b, 0x2c,
+    0x6b, 0x2c,
+    0x6d, 0x2c,
+    0x6e, 0x2c,
+    0x6f, 0x2c,
+    0x70, 0x2c,
+    0x71, 0x2c,
+    0x72, 0x2c,
+    0x73, 0x2c,
+    0x74, 0x2c,
+    0x75, 0x2c,
+    0x75, 0x2c,
+    0x77, 0x2c,
+    0x78, 0x2c,
+    0x79, 0x2c,
+    0x7a, 0x2c,
+    0x7b, 0x2c,
+    0x7c, 0x2c,
+    0x7d, 0x2c,
+    0x7e, 0x2c,
+    0x7f, 0x2c,
+    0x80, 0x2c,
+    0x80, 0x2c,
+    0x82, 0x2c,
+    0x82, 0x2c,
+    0x84, 0x2c,
+    0x84, 0x2c,
+    0x86, 0x2c,
+    0x86, 0x2c,
+    0x88, 0x2c,
+    0x88, 0x2c,
+    0x8a, 0x2c,
+    0x8a, 0x2c,
+    0x8c, 0x2c,
+    0x8c, 0x2c,
+    0x8e, 0x2c,
+    0x8e, 0x2c,
+    0x90, 0x2c,
+    0x90, 0x2c,
+    0x92, 0x2c,
+    0x92, 0x2c,
+    0x94, 0x2c,
+    0x94, 0x2c,
+    0x96, 0x2c,
+    0x96, 0x2c,
+    0x98, 0x2c,
+    0x98, 0x2c,
+    0x9a, 0x2c,
+    0x9a, 0x2c,
+    0x9c, 0x2c,
+    0x9c, 0x2c,
+    0x9e, 0x2c,
+    0x9e, 0x2c,
+    0xa0, 0x2c,
+    0xa0, 0x2c,
+    0xa2, 0x2c,
+    0xa2, 0x2c,
+    0xa4, 0x2c,
+    0xa4, 0x2c,
+    0xa6, 0x2c,
+    0xa6, 0x2c,
+    0xa8, 0x2c,
+    0xa8, 0x2c,
+    0xaa, 0x2c,
+    0xaa, 0x2c,
+    0xac, 0x2c,
+    0xac, 0x2c,
+    0xae, 0x2c,
+    0xae, 0x2c,
+    0xb0, 0x2c,
+    0xb0, 0x2c,
+    0xb2, 0x2c,
+    0xb2, 0x2c,
+    0xb4, 0x2c,
+    0xb4, 0x2c,
+    0xb6, 0x2c,
+    0xb6, 0x2c,
+    0xb8, 0x2c,
+    0xb8, 0x2c,
+    0xba, 0x2c,
+    0xba, 0x2c,
+    0xbc, 0x2c,
+    0xbc, 0x2c,
+    0xbe, 0x2c,
+    0xbe, 0x2c,
+    0xc0, 0x2c,
+    0xc0, 0x2c,
+    0xc2, 0x2c,
+    0xc2, 0x2c,
+    0xc4, 0x2c,
+    0xc4, 0x2c,
+    0xc6, 0x2c,
+    0xc6, 0x2c,
+    0xc8, 0x2c,
+    0xc8, 0x2c,
+    0xca, 0x2c,
+    0xca, 0x2c,
+    0xcc, 0x2c,
+    0xcc, 0x2c,
+    0xce, 0x2c,
+    0xce, 0x2c,
+    0xd0, 0x2c,
+    0xd0, 0x2c,
+    0xd2, 0x2c,
+    0xd2, 0x2c,
+    0xd4, 0x2c,
+    0xd4, 0x2c,
+    0xd6, 0x2c,
+    0xd6, 0x2c,
+    0xd8, 0x2c,
+    0xd8, 0x2c,
+    0xda, 0x2c,
+    0xda, 0x2c,
+    0xdc, 0x2c,
+    0xdc, 0x2c,
+    0xde, 0x2c,
+    0xde, 0x2c,
+    0xe0, 0x2c,
+    0xe0, 0x2c,
+    0xe2, 0x2c,
+    0xe2, 0x2c,
+    0xe4, 0x2c,
+    0xe5, 0x2c,
+    0xe6, 0x2c,
+    0xe7, 0x2c,
+    0xe8, 0x2c,
+    0xe9, 0x2c,
+    0xea, 0x2c,
+    0xeb, 0x2c,
+    0xec, 0x2c,
+    0xed, 0x2c,
+    0xee, 0x2c,
+    0xef, 0x2c,
+    0xf0, 0x2c,
+    0xf1, 0x2c,
+    0xf2, 0x2c,
+    0xf3, 0x2c,
+    0xf4, 0x2c,
+    0xf5, 0x2c,
+    0xf6, 0x2c,
+    0xf7, 0x2c,
+    0xf8, 0x2c,
+    0xf9, 0x2c,
+    0xfa, 0x2c,
+    0xfb, 0x2c,
+    0xfc, 0x2c,
+    0xfd, 0x2c,
+    0xfe, 0x2c,
+    0xff, 0x2c,
+    0xa0, 0x10,
+    0xa1, 0x10,
+    0xa2, 0x10,
+    0xa3, 0x10,
+    0xa4, 0x10,
+    0xa5, 0x10,
+    0xa6, 0x10,
+    0xa7, 0x10,
+    0xa8, 0x10,
+    0xa9, 0x10,
+    0xaa, 0x10,
+    0xab, 0x10,
+    0xac, 0x10,
+    0xad, 0x10,
+    0xae, 0x10,
+    0xaf, 0x10,
+    0xb0, 0x10,
+    0xb1, 0x10,
+    0xb2, 0x10,
+    0xb3, 0x10,
+    0xb4, 0x10,
+    0xb5, 0x10,
+    0xb6, 0x10,
+    0xb7, 0x10,
+    0xb8, 0x10,
+    0xb9, 0x10,
+    0xba, 0x10,
+    0xbb, 0x10,
+    0xbc, 0x10,
+    0xbd, 0x10,
+    0xbe, 0x10,
+    0xbf, 0x10,
+    0xc0, 0x10,
+    0xc1, 0x10,
+    0xc2, 0x10,
+    0xc3, 0x10,
+    0xc4, 0x10,
+    0xc5, 0x10,
+    0xff, 0xff,
+    0x1b, 0xd2,
+    0x21, 0xff,
+    0x22, 0xff,
+    0x23, 0xff,
+    0x24, 0xff,
+    0x25, 0xff,
+    0x26, 0xff,
+    0x27, 0xff,
+    0x28, 0xff,
+    0x29, 0xff,
+    0x2a, 0xff,
+    0x2b, 0xff,
+    0x2c, 0xff,
+    0x2d, 0xff,
+    0x2e, 0xff,
+    0x2f, 0xff,
+    0x30, 0xff,
+    0x31, 0xff,
+    0x32, 0xff,
+    0x33, 0xff,
+    0x34, 0xff,
+    0x35, 0xff,
+    0x36, 0xff,
+    0x37, 0xff,
+    0x38, 0xff,
+    0x39, 0xff,
+    0x3a, 0xff,
+    0x5b, 0xff,
+    0x5c, 0xff,
+    0x5d, 0xff,
+    0x5e, 0xff,
+    0x5f, 0xff,
+    0x60, 0xff,
+    0x61, 0xff,
+    0x62, 0xff,
+    0x63, 0xff,
+    0x64, 0xff,
+    0x65, 0xff,
+    0x66, 0xff,
+    0x67, 0xff,
+    0x68, 0xff,
+    0x69, 0xff,
+    0x6a, 0xff,
+    0x6b, 0xff,
+    0x6c, 0xff,
+    0x6d, 0xff,
+    0x6e, 0xff,
+    0x6f, 0xff,
+    0x70, 0xff,
+    0x71, 0xff,
+    0x72, 0xff,
+    0x73, 0xff,
+    0x74, 0xff,
+    0x75, 0xff,
+    0x76, 0xff,
+    0x77, 0xff,
+    0x78, 0xff,
+    0x79, 0xff,
+    0x7a, 0xff,
+    0x7b, 0xff,
+    0x7c, 0xff,
+    0x7d, 0xff,
+    0x7e, 0xff,
+    0x7f, 0xff,
+    0x80, 0xff,
+    0x81, 0xff,
+    0x82, 0xff,
+    0x83, 0xff,
+    0x84, 0xff,
+    0x85, 0xff,
+    0x86, 0xff,
+    0x87, 0xff,
+    0x88, 0xff,
+    0x89, 0xff,
+    0x8a, 0xff,
+    0x8b, 0xff,
+    0x8c, 0xff,
+    0x8d, 0xff,
+    0x8e, 0xff,
+    0x8f, 0xff,
+    0x90, 0xff,
+    0x91, 0xff,
+    0x92, 0xff,
+    0x93, 0xff,
+    0x94, 0xff,
+    0x95, 0xff,
+    0x96, 0xff,
+    0x97, 0xff,
+    0x98, 0xff,
+    0x99, 0xff,
+    0x9a, 0xff,
+    0x9b, 0xff,
+    0x9c, 0xff,
+    0x9d, 0xff,
+    0x9e, 0xff,
+    0x9f, 0xff,
+    0xa0, 0xff,
+    0xa1, 0xff,
+    0xa2, 0xff,
+    0xa3, 0xff,
+    0xa4, 0xff,
+    0xa5, 0xff,
+    0xa6, 0xff,
+    0xa7, 0xff,
+    0xa8, 0xff,
+    0xa9, 0xff,
+    0xaa, 0xff,
+    0xab, 0xff,
+    0xac, 0xff,
+    0xad, 0xff,
+    0xae, 0xff,
+    0xaf, 0xff,
+    0xb0, 0xff,
+    0xb1, 0xff,
+    0xb2, 0xff,
+    0xb3, 0xff,
+    0xb4, 0xff,
+    0xb5, 0xff,
+    0xb6, 0xff,
+    0xb7, 0xff,
+    0xb8, 0xff,
+    0xb9, 0xff,
+    0xba, 0xff,
+    0xbb, 0xff,
+    0xbc, 0xff,
+    0xbd, 0xff,
+    0xbe, 0xff,
+    0xbf, 0xff,
+    0xc0, 0xff,
+    0xc1, 0xff,
+    0xc2, 0xff,
+    0xc3, 0xff,
+    0xc4, 0xff,
+    0xc5, 0xff,
+    0xc6, 0xff,
+    0xc7, 0xff,
+    0xc8, 0xff,
+    0xc9, 0xff,
+    0xca, 0xff,
+    0xcb, 0xff,
+    0xcc, 0xff,
+    0xcd, 0xff,
+    0xce, 0xff,
+    0xcf, 0xff,
+    0xd0, 0xff,
+    0xd1, 0xff,
+    0xd2, 0xff,
+    0xd3, 0xff,
+    0xd4, 0xff,
+    0xd5, 0xff,
+    0xd6, 0xff,
+    0xd7, 0xff,
+    0xd8, 0xff,
+    0xd9, 0xff,
+    0xda, 0xff,
+    0xdb, 0xff,
+    0xdc, 0xff,
+    0xdd, 0xff,
+    0xde, 0xff,
+    0xdf, 0xff,
+    0xe0, 0xff,
+    0xe1, 0xff,
+    0xe2, 0xff,
+    0xe3, 0xff,
+    0xe4, 0xff,
+    0xe5, 0xff,
+    0xe6, 0xff,
+    0xe7, 0xff,
+    0xe8, 0xff,
+    0xe9, 0xff,
+    0xea, 0xff,
+    0xeb, 0xff,
+    0xec, 0xff,
+    0xed, 0xff,
+    0xee, 0xff,
+    0xef, 0xff,
+    0xf0, 0xff,
+    0xf1, 0xff,
+    0xf2, 0xff,
+    0xf3, 0xff,
+    0xf4, 0xff,
+    0xf5, 0xff,
+    0xf6, 0xff,
+    0xf7, 0xff,
+    0xf8, 0xff,
+    0xf9, 0xff,
+    0xfa, 0xff,
+    0xfb, 0xff,
+    0xfc, 0xff,
+    0xfd, 0xff,
+    0xfe, 0xff,
+    0xff, 0xff
+};
+
+#endif
+
+/**
+ * @}
+ */
+
+
Index: uspace/app/sbi/src/run_texpr.c
===================================================================
--- uspace/app/sbi/src/run_texpr.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/sbi/src/run_texpr.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -98,6 +98,6 @@
 {
 	stree_symbol_t *sym;
-	tdata_item_t *targ_i;
-	tdata_item_t *titem;
+	tdata_item_t *targ_i = NULL;
+	tdata_item_t *titem = NULL;;
 	tdata_object_t *tobject;
 	tdata_deleg_t *tdeleg;
@@ -139,7 +139,4 @@
 		return;
 	}
-
-	/* Make compiler happy. */
-	titem = NULL;
 
 	switch (sym->sc) {
@@ -222,5 +219,5 @@
     stree_tindex_t *tindex, tdata_item_t **res)
 {
-	tdata_item_t *base_ti;
+	tdata_item_t *base_ti = NULL;
 	tdata_item_t *titem;
 	tdata_array_t *tarray;
Index: uspace/app/sportdmp/sportdmp.c
===================================================================
--- uspace/app/sportdmp/sportdmp.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/sportdmp/sportdmp.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -27,20 +27,20 @@
  */
 
+#include <device/char_dev.h>
 #include <errno.h>
+#include <ipc/serial_ctl.h>
+#include <loc.h>
 #include <stdio.h>
-#include <devman.h>
-#include <ipc/devman.h>
-#include <device/char_dev.h>
-#include <ipc/serial_ctl.h>
 
 #define BUF_SIZE 1
 
-static void syntax_print() {
-	fprintf(stderr, "Usage: sportdmp <baud> <device_path>\n");
+static void syntax_print(void)
+{
+	fprintf(stderr, "Usage: sportdmp <baud> <device_service>\n");
 }
 
 int main(int argc, char **argv)
 {
-	const char* devpath = "/hw/pci0/00:01.0/com1/a";
+	const char* svc_path = "devices/\\hw\\pci0\\00:01.0\\com1\\a";
 	sysarg_t baud = 9600;
 	
@@ -56,5 +56,5 @@
 	
 	if (argc > 2) {
-		devpath = argv[2];
+		svc_path = argv[2];
 	}
 	
@@ -64,15 +64,15 @@
 	}
 	
-	devman_handle_t device;
-	int rc = devman_fun_get_handle(devpath, &device, IPC_FLAG_BLOCKING);
+	service_id_t svc_id;
+	int rc = loc_service_get_id(svc_path, &svc_id, IPC_FLAG_BLOCKING);
 	if (rc != EOK) {
-		fprintf(stderr, "Cannot open device %s\n", devpath);
+		fprintf(stderr, "Cannot find device service %s\n", svc_path);
 		return 1;
 	}
 	
-	async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE, device,
+	async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id,
 	    IPC_FLAG_BLOCKING);
 	if (!sess) {
-		fprintf(stderr, "Cannot connect device\n");
+		fprintf(stderr, "Failed connecting to service %s\n", svc_path);
 	}
 	
@@ -83,5 +83,5 @@
 	
 	if (rc != EOK) {
-		fprintf(stderr, "Cannot set serial properties\n");
+		fprintf(stderr, "Failed setting serial properties\n");
 		return 2;
 	}
@@ -89,5 +89,5 @@
 	uint8_t *buf = (uint8_t *) malloc(BUF_SIZE);
 	if (buf == NULL) {
-		fprintf(stderr, "Cannot allocate buffer\n");
+		fprintf(stderr, "Failed allocating buffer\n");
 		return 3;
 	}
Index: uspace/app/sysinfo/sysinfo.c
===================================================================
--- uspace/app/sysinfo/sysinfo.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/sysinfo/sysinfo.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -37,51 +37,24 @@
 #include <stdio.h>
 #include <sysinfo.h>
+#include <malloc.h>
 #include <sys/types.h>
 
-static int print_item_val(char *ipath);
-static int print_item_data(char *ipath);
-
-static void dump_bytes_hex(char *data, size_t size);
-static void dump_bytes_text(char *data, size_t size);
-
-static void print_syntax(void);
-
-int main(int argc, char *argv[])
-{
-	int rc;
-	char *ipath;
-	sysinfo_item_val_type_t tag;
-
-	if (argc != 2) {
-		print_syntax();
-		return 1;
-	}
-
-	ipath = argv[1];
-
-	tag = sysinfo_get_val_type(ipath);
-
-	/* Silence warning */
-	rc = EOK;
-
-	switch (tag) {
-	case SYSINFO_VAL_UNDEFINED:
-		printf("Error: Sysinfo item '%s' not defined.\n", ipath);
-		rc = 2;
-		break;
-	case SYSINFO_VAL_VAL:
-		rc = print_item_val(ipath);
-		break;
-	case SYSINFO_VAL_DATA:
-		rc = print_item_data(ipath);
-		break;
-	default:
-		printf("Error: Sysinfo item '%s' with unknown value type.\n",
-		    ipath);
-		rc = 2;
-		break;
-	}
-
-	return rc;
+static void dump_bytes_hex(char *data, size_t size)
+{
+	for (size_t i = 0; i < size; i++) {
+		if (i > 0)
+			putchar(' ');
+		printf("0x%02x", (uint8_t) data[i]);
+	}
+}
+
+static void dump_bytes_text(char *data, size_t size)
+{
+	size_t offset = 0;
+	
+	while (offset < size) {
+		wchar_t c = str_decode(data, &offset, size);
+		printf("%lc", (wint_t) c);
+	}
 }
 
@@ -89,15 +62,13 @@
 {
 	sysarg_t value;
-	int rc;
-
-	rc = sysinfo_get_value(ipath, &value);
+	int rc = sysinfo_get_value(ipath, &value);
 	if (rc != EOK) {
 		printf("Error reading item '%s'.\n", ipath);
 		return rc;
 	}
-
+	
 	printf("%s -> %" PRIu64 " (0x%" PRIx64 ")\n", ipath,
 	    (uint64_t) value, (uint64_t) value);
-
+	
 	return EOK;
 }
@@ -105,13 +76,11 @@
 static int print_item_data(char *ipath)
 {
-	void *data;
 	size_t size;
-
-	data = sysinfo_get_data(ipath, &size);
+	void *data = sysinfo_get_data(ipath, &size);
 	if (data == NULL) {
 		printf("Error reading item '%s'.\n", ipath);
 		return -1;
 	}
-
+	
 	printf("%s -> ", ipath);
 	dump_bytes_hex(data, size);
@@ -119,35 +88,115 @@
 	dump_bytes_text(data, size);
 	fputs("')\n", stdout);
-
+	
 	return EOK;
 }
 
-static void dump_bytes_hex(char *data, size_t size)
-{
-	size_t i;
-
-	for (i = 0; i < size; ++i) {
-		if (i > 0) putchar(' ');
-		printf("0x%02x", (uint8_t) data[i]);
-	}
-}
-
-static void dump_bytes_text(char *data, size_t size)
-{
-	wchar_t c;
-	size_t offset;
-
-	offset = 0;
-
-	while (offset < size) {
-		c = str_decode(data, &offset, size);
-		printf("%lc", (wint_t) c);
-	}
-}
-
-
-static void print_syntax(void)
-{
-	printf("Syntax: sysinfo <item_path>\n");
+static int print_item_property(char *ipath, char *iprop)
+{
+	size_t size;
+	void *data = sysinfo_get_property(ipath, iprop, &size);
+	if (data == NULL) {
+		printf("Error reading property '%s' of item '%s'.\n", iprop,
+		    ipath);
+		return -1;
+	}
+	
+	printf("%s property %s -> ", ipath, iprop);
+	dump_bytes_hex(data, size);
+	fputs(" ('", stdout);
+	dump_bytes_text(data, size);
+	fputs("')\n", stdout);
+	
+	return EOK;
+}
+
+static void print_spaces(size_t spaces)
+{
+	for (size_t i = 0; i < spaces; i++)
+		printf(" ");
+}
+
+static void print_keys(const char *path, size_t spaces)
+{
+	size_t size;
+	char *keys = sysinfo_get_keys(path, &size);
+	if ((keys == NULL) || (size == 0))
+		return;
+	
+	size_t pos = 0;
+	while (pos < size) {
+		/* Process each key with sanity checks */
+		size_t cur_size = str_nsize(keys + pos, size - pos);
+		if (keys[pos + cur_size] != 0)
+			break;
+		
+		size_t path_size = str_size(path) + cur_size + 2;
+		char *cur_path = (char *) malloc(path_size);
+		if (cur_path == NULL)
+			break;
+		
+		size_t length;
+		
+		if (path[0] != 0) {
+			print_spaces(spaces);
+			printf(".%s\n", keys + pos);
+			length = str_length(keys + pos) + 1;
+			
+			snprintf(cur_path, path_size, "%s.%s", path, keys + pos);
+		} else {
+			printf("%s\n", keys + pos);
+			length = str_length(keys + pos);
+			
+			snprintf(cur_path, path_size, "%s", keys + pos);
+		}
+		
+		print_keys(cur_path, spaces + length);
+		
+		free(cur_path);
+		pos += cur_size + 1;
+	}
+	
+	free(keys);
+}
+
+int main(int argc, char *argv[])
+{
+	int rc = 0;
+	
+	if (argc < 2) {
+		/* Print keys */
+		print_keys("", 0);
+		return rc;
+	}
+	
+	char *ipath = argv[1];
+	
+	if (argc < 3) {
+		sysinfo_item_val_type_t tag = sysinfo_get_val_type(ipath);
+		
+		switch (tag) {
+		case SYSINFO_VAL_UNDEFINED:
+			printf("Error: Sysinfo item '%s' not defined.\n", ipath);
+			rc = 2;
+			break;
+		case SYSINFO_VAL_VAL:
+			rc = print_item_val(ipath);
+			break;
+		case SYSINFO_VAL_DATA:
+			rc = print_item_data(ipath);
+			break;
+		default:
+			printf("Error: Sysinfo item '%s' with unknown value type.\n",
+			    ipath);
+			rc = 2;
+			break;
+		}
+		
+		return rc;
+	}
+	
+	char *iprop = argv[2];
+	rc = print_item_property(ipath, iprop);
+	return rc;
 }
 
Index: uspace/app/tester/Makefile
===================================================================
--- uspace/app/tester/Makefile	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/tester/Makefile	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -50,4 +50,5 @@
 	vfs/vfs1.c \
 	ipc/ping_pong.c \
+	ipc/starve.c \
 	loop/loop1.c \
 	mm/common.c \
Index: uspace/app/tester/fault/fault2.c
===================================================================
--- uspace/app/tester/fault/fault2.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/tester/fault/fault2.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -35,8 +35,6 @@
 const char *test_fault2(void)
 {
-	volatile long long var;
-	volatile int var1;
-	
-	var1 = *((aliasing_int *) (((char *) (&var)) + 1));
+	volatile long long var = 0;
+	volatile int var1 = *((aliasing_int *) (((char *) (&var)) + 1));
 	printf("Read %d\n", var1);
 	
Index: uspace/app/tester/hw/serial/serial1.c
===================================================================
--- uspace/app/tester/hw/serial/serial1.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/tester/hw/serial/serial1.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -42,6 +42,5 @@
 #include <async.h>
 #include <ipc/services.h>
-#include <ipc/devman.h>
-#include <devman.h>
+#include <loc.h>
 #include <device/char_dev.h>
 #include <str.h>
@@ -71,19 +70,19 @@
 		}
 	
-	devman_handle_t handle;
-	int res = devman_fun_get_handle("/hw/pci0/00:01.0/com1/a", &handle,
-	    IPC_FLAG_BLOCKING);
+	service_id_t svc_id;
+	int res = loc_service_get_id("devices/\\hw\\pci0\\00:01.0\\com1\\a",
+	    &svc_id, IPC_FLAG_BLOCKING);
 	if (res != EOK)
-		return "Could not get serial device handle";
-	
-	async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE, handle,
+		return "Failed getting serial port service ID";
+	
+	async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id,
 	    IPC_FLAG_BLOCKING);
 	if (!sess)
-		return "Unable to connect to serial device";
+		return "Failed connecting to serial device";
 	
 	char *buf = (char *) malloc(cnt + 1);
 	if (buf == NULL) {
 		async_hangup(sess);
-		return "Failed to allocate input buffer";
+		return "Failed allocating input buffer";
 	}
 	
@@ -112,9 +111,9 @@
 		free(buf);
 		async_hangup(sess);
-		return "Failed to set serial communication parameters";
-	}
-	
-	TPRINTF("Trying to read %zu characters from serial device "
-	    "(handle=%" PRIun ")\n", cnt, handle);
+		return "Failed setting serial communication parameters";
+	}
+	
+	TPRINTF("Trying reading %zu characters from serial device "
+	    "(svc_id=%" PRIun ")\n", cnt, svc_id);
 	
 	size_t total = 0;
@@ -130,5 +129,5 @@
 			free(buf);
 			async_hangup(sess);
-			return "Failed read from serial device";
+			return "Failed reading from serial device";
 		}
 		
@@ -165,5 +164,5 @@
 				free(buf);
 				async_hangup(sess);
-				return "Failed write to serial device";
+				return "Failed writing to serial device";
 			}
 			
Index: uspace/app/tester/ipc/starve.c
===================================================================
--- uspace/app/tester/ipc/starve.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/app/tester/ipc/starve.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <io/console.h>
+#include <async.h>
+#include "../tester.h"
+
+#define DURATION_SECS      30
+
+const char *test_starve_ipc(void)
+{
+	const char *err = NULL;
+	console_ctrl_t *console = console_init(stdin, stdout);
+	if (console == NULL) {
+		return "Failed to init connection with console.";
+	}
+	
+	struct timeval start;
+	if (gettimeofday(&start, NULL) != 0) {
+		err = "Failed getting the time";
+		goto leave;
+	}
+	
+	TPRINTF("Intensive computation shall be imagined (for %ds)...\n", DURATION_SECS);
+	TPRINTF("Press a key to terminate prematurely...\n");
+	while (true) {
+		struct timeval now;
+		if (gettimeofday(&now, NULL) != 0) {
+			err = "Failed getting the time";
+			goto leave;
+		}
+		
+		if (tv_sub(&now, &start) >= DURATION_SECS * 1000000L)
+			break;
+		
+		kbd_event_t ev;
+		suseconds_t timeout = 0;
+		bool has_event = console_get_kbd_event_timeout(console, &ev, &timeout);
+		if (has_event && (ev.type == KEY_PRESS)) {
+			TPRINTF("Key %d pressed, terminating.\n", ev.key);
+			break;
+		}
+	}
+
+	// FIXME - unless a key was pressed, the answer leaked as no one
+	// will wait for it.
+	// We cannot use async_forget() directly, though. Something like
+	// console_forget_pending_kbd_event() shall come here.
+
+	TPRINTF("Terminating...\n");
+
+leave:
+	console_done(console);
+
+	return err;
+}
Index: uspace/app/tester/ipc/starve.def
===================================================================
--- uspace/app/tester/ipc/starve.def	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/app/tester/ipc/starve.def	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,6 @@
+{
+	"starve",
+	"Demonstrate starving IPC",
+	&test_starve_ipc,
+	true
+},
Index: uspace/app/tester/print/print1.c
===================================================================
--- uspace/app/tester/print/print1.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/tester/print/print1.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -42,5 +42,5 @@
 	
 	TPRINTF("Testing printf(\"%%8.10s\", \"text\"):\n");
-	TPRINTF("Expected output: \"text\"\n");
+	TPRINTF("Expected output: \"    text\"\n");
 	TPRINTF("Real output:     \"%8.10s\"\n\n", "text");
 	
@@ -49,4 +49,8 @@
 	TPRINTF("Real output:     \"%8.10s\"\n\n", "very long text");
 	
+	TPRINTF("Testing printf(\"%%-*.*s\", 7, 7, \"text\"):\n");
+	TPRINTF("Expected output: \"text   \"\n");
+	TPRINTF("Real output:     \"%-*.*s\"\n\n", 7, 7, "text");
+	
 	return NULL;
 }
Index: uspace/app/tester/tester.c
===================================================================
--- uspace/app/tester/tester.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/tester/tester.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -60,4 +60,5 @@
 #include "vfs/vfs1.def"
 #include "ipc/ping_pong.def"
+#include "ipc/starve.def"
 #include "loop/loop1.def"
 #include "mm/malloc1.def"
Index: uspace/app/tester/tester.h
===================================================================
--- uspace/app/tester/tester.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/tester/tester.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -93,4 +93,5 @@
 extern const char *test_vfs1(void);
 extern const char *test_ping_pong(void);
+extern const char *test_starve_ipc(void);
 extern const char *test_loop1(void);
 extern const char *test_malloc1(void);
Index: uspace/app/top/screen.c
===================================================================
--- uspace/app/top/screen.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/top/screen.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -37,4 +37,5 @@
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <io/console.h>
 #include <io/style.h>
@@ -43,4 +44,5 @@
 #include <stats.h>
 #include <inttypes.h>
+#include <macros.h>
 #include "screen.h"
 #include "top.h"
@@ -48,10 +50,13 @@
 #define USEC_COUNT  1000000
 
-static sysarg_t warn_col = 0;
-static sysarg_t warn_row = 0;
 static suseconds_t timeleft = 0;
 
 console_ctrl_t *console;
 
+static sysarg_t warning_col = 0;
+static sysarg_t warning_row = 0;
+static suseconds_t warning_timeleft = 0;
+static char *warning_text = NULL;
+
 static void screen_style_normal(void)
 {
@@ -64,4 +69,10 @@
 	console_flush(console);
 	console_set_style(console, STYLE_INVERTED);
+}
+
+static void screen_style_emphasis(void)
+{
+	console_flush(console);
+	console_set_style(console, STYLE_EMPHASIS);
 }
 
@@ -126,4 +137,7 @@
 void screen_done(void)
 {
+	free(warning_text);
+	warning_text = NULL;
+
 	screen_restart(true);
 	
@@ -277,18 +291,51 @@
 }
 
-static inline void print_tasks_head(void)
+static inline void print_help_head(void)
 {
 	screen_style_inverted();
-	printf("[taskid] [thrds] [resident] [%%resi] [virtual] [%%virt]"
-	    " [%%user] [%%kern] [name");
+	printf("Help");
 	screen_newline();
 	screen_style_normal();
 }
 
-static inline void print_tasks(data_t *data)
-{
-	sysarg_t cols;
-	sysarg_t rows;
-	screen_get_size(&cols, &rows);
+static inline void print_help(void)
+{
+	sysarg_t cols;
+	sysarg_t rows;
+	screen_get_size(&cols, &rows);
+	
+	screen_newline();
+	
+	printf("Operation modes:");
+	screen_newline();
+	
+	printf(" t .. tasks statistics");
+	screen_newline();
+	
+	printf(" i .. IPC statistics");
+	screen_newline();
+	
+	printf(" e .. exceptions statistics");
+	screen_newline();
+	
+	printf("      a .. toggle display of all/hot exceptions");
+	screen_newline();
+
+	printf(" h .. toggle this help screen");
+	screen_newline();
+
+	screen_newline();
+
+	printf("Other keys:");
+	screen_newline();
+	
+	printf(" s .. choose column to sort by");
+	screen_newline();
+	
+	printf(" r .. toggle reversed sorting");
+	screen_newline();
+	
+	printf(" q .. quit");
+	screen_newline();
 	
 	sysarg_t col;
@@ -296,32 +343,4 @@
 	screen_get_pos(&col, &row);
 	
-	size_t i;
-	for (i = 0; (i < data->tasks_count) && (row < rows); i++, row++) {
-		stats_task_t *task = data->tasks + data->tasks_map[i];
-		perc_task_t *perc = data->tasks_perc + data->tasks_map[i];
-		
-		uint64_t resmem;
-		const char *resmem_suffix;
-		bin_order_suffix(task->resmem, &resmem, &resmem_suffix, true);
-		
-		uint64_t virtmem;
-		const char *virtmem_suffix;
-		bin_order_suffix(task->virtmem, &virtmem, &virtmem_suffix, true);
-		
-		printf("%-8" PRIu64 " %7zu %7" PRIu64 "%s ",
-		    task->task_id, task->threads, resmem, resmem_suffix);
-		print_percent(perc->resmem, 2);
-		printf(" %6" PRIu64 "%s ", virtmem, virtmem_suffix);
-		print_percent(perc->virtmem, 2);
-		puts(" ");
-		print_percent(perc->ucycles, 2);
-		puts(" ");
-		print_percent(perc->kcycles, 2);
-		puts(" ");
-		print_string(task->name);
-		
-		screen_newline();
-	}
-	
 	while (row < rows) {
 		screen_newline();
@@ -330,14 +349,30 @@
 }
 
-static inline void print_ipc_head(void)
-{
+static inline void print_table_head(const table_t *table)
+{
+	sysarg_t cols;
+	sysarg_t rows;
+	screen_get_size(&cols, &rows);
+
 	screen_style_inverted();
-	printf("[taskid] [cls snt] [cls rcv] [ans snt]"
-	    " [ans rcv] [irq rcv] [forward] [name");
+	for (size_t i = 0; i < table->num_columns; i++) {
+		const char *name = table->columns[i].name;
+		int width = table->columns[i].width;
+		if (i != 0) {
+			puts(" ");
+		}
+		if (width == 0) {
+			sysarg_t col;
+			sysarg_t row;
+			screen_get_pos(&col, &row);
+			width = cols - col - 1;
+		}
+		printf("[%-*.*s]", width - 2, width - 2, name);
+	}
 	screen_newline();
 	screen_style_normal();
 }
 
-static inline void print_ipc(data_t *data)
+static inline void print_table(const table_t *table)
 {
 	sysarg_t cols;
@@ -350,44 +385,58 @@
 	
 	size_t i;
-	for (i = 0; (i < data->tasks_count) && (row < rows); i++, row++) {
-		uint64_t call_sent;
-		uint64_t call_received;
-		uint64_t answer_sent;
-		uint64_t answer_received;
-		uint64_t irq_notif_received;
-		uint64_t forwarded;
-		
-		char call_sent_suffix;
-		char call_received_suffix;
-		char answer_sent_suffix;
-		char answer_received_suffix;
-		char irq_notif_received_suffix;
-		char forwarded_suffix;
-		
-		order_suffix(data->tasks[i].ipc_info.call_sent, &call_sent,
-		    &call_sent_suffix);
-		order_suffix(data->tasks[i].ipc_info.call_received,
-		    &call_received, &call_received_suffix);
-		order_suffix(data->tasks[i].ipc_info.answer_sent,
-		    &answer_sent, &answer_sent_suffix);
-		order_suffix(data->tasks[i].ipc_info.answer_received,
-		    &answer_received, &answer_received_suffix);
-		order_suffix(data->tasks[i].ipc_info.irq_notif_received,
-		    &irq_notif_received, &irq_notif_received_suffix);
-		order_suffix(data->tasks[i].ipc_info.forwarded, &forwarded,
-		    &forwarded_suffix);
-		
-		printf("%-8" PRIu64 " %8" PRIu64 "%c %8" PRIu64 "%c"
-		     " %8" PRIu64 "%c %8" PRIu64 "%c %8" PRIu64 "%c"
-		     " %8" PRIu64 "%c ", data->tasks[i].task_id,
-		     call_sent, call_sent_suffix,
-		     call_received, call_received_suffix,
-		     answer_sent, answer_sent_suffix,
-		     answer_received, answer_received_suffix,
-		     irq_notif_received, irq_notif_received_suffix,
-		     forwarded, forwarded_suffix);
-		print_string(data->tasks[i].name);
-		
-		screen_newline();
+	for (i = 0; (i < table->num_fields) && (row < rows); i++) {
+		size_t column_index = i % table->num_columns;
+		int width = table->columns[column_index].width;
+		field_t *field = &table->fields[i];
+
+		if (column_index != 0) {
+			puts(" ");
+		}
+
+		if (width == 0) {
+			screen_get_pos(&col, &row);
+			width = cols - col - 1;
+		}
+
+		switch (field->type) {
+		case FIELD_EMPTY:
+			printf("%*s", width, "");
+			break;
+		case FIELD_UINT:
+			printf("%*" PRIu64, width, field->uint);
+			break;
+		case FIELD_UINT_SUFFIX_BIN: {
+			uint64_t val = field->uint;
+			const char *suffix;
+			width -= 3;
+			bin_order_suffix(val, &val, &suffix, true);
+			printf("%*" PRIu64 "%s", width, val, suffix);
+			break;
+		}
+		case FIELD_UINT_SUFFIX_DEC: {
+			uint64_t val = field->uint;
+			char suffix;
+			width -= 1;
+			order_suffix(val, &val, &suffix);
+			printf("%*" PRIu64 "%c", width, val, suffix);
+			break;
+		}
+		case FIELD_PERCENT:
+			width -= 5; /* nnn.% */
+			if (width > 2) {
+				printf("%*s", width - 2, "");
+				width = 2;
+			}
+			print_percent(field->fixed, width);
+			break;
+		case FIELD_STRING:
+			printf("%-*.*s", width, width, field->string);
+			break;
+		}
+
+		if (column_index == table->num_columns - 1) {
+			screen_newline();
+			row++;
+		}
 	}
 	
@@ -398,13 +447,5 @@
 }
 
-static inline void print_excs_head(void)
-{
-	screen_style_inverted();
-	printf("[exc   ] [count   ] [%%count] [cycles  ] [%%cycles] [description");
-	screen_newline();
-	screen_style_normal();
-}
-
-static inline void print_excs(data_t *data)
+static inline void print_sort(table_t *table)
 {
 	sysarg_t cols;
@@ -415,28 +456,8 @@
 	sysarg_t row;
 	screen_get_pos(&col, &row);
-	
-	size_t i;
-	for (i = 0; (i < data->exceptions_count) && (row < rows); i++) {
-		/* Filter-out cold exceptions if not instructed otherwise */
-		if ((!excs_all) && (!data->exceptions[i].hot))
-			continue;
-		
-		uint64_t count;
-		uint64_t cycles;
-		
-		char count_suffix;
-		char cycles_suffix;
-		
-		order_suffix(data->exceptions[i].count, &count, &count_suffix);
-		order_suffix(data->exceptions[i].cycles, &cycles, &cycles_suffix);
-		
-		printf("%-8u %9" PRIu64 "%c  ",
-		     data->exceptions[i].id, count, count_suffix);
-		print_percent(data->exceptions_perc[i].count, 2);
-		printf(" %9" PRIu64 "%c   ", cycles, cycles_suffix);
-		print_percent(data->exceptions_perc[i].cycles, 2);
-		puts(" ");
-		print_string(data->exceptions[i].desc);
-		
+
+	size_t num = min(table->num_columns, rows - row);
+	for (size_t i = 0; i < num; i++) {
+		printf("%c - %s", table->columns[i].key, table->columns[i].name);
 		screen_newline();
 		row++;
@@ -449,37 +470,16 @@
 }
 
-static void print_help(void)
-{
-	sysarg_t cols;
-	sysarg_t rows;
-	screen_get_size(&cols, &rows);
-	
-	sysarg_t col;
-	sysarg_t row;
-	screen_get_pos(&col, &row);
-	
-	screen_newline();
-	
-	printf("Operation modes:");
-	screen_newline();
-	
-	printf(" t .. tasks statistics");
-	screen_newline();
-	
-	printf(" i .. IPC statistics");
-	screen_newline();
-	
-	printf(" e .. exceptions statistics");
-	screen_newline();
-	
-	printf("      a .. toggle display of all/hot exceptions");
-	screen_newline();
-	
-	row += 6;
-	
-	while (row < rows) {
-		screen_newline();
-		row++;
-	}
+static inline void print_warning(void)
+{
+	screen_get_pos(&warning_col, &warning_row);
+	if (warning_timeleft > 0) {
+		screen_style_emphasis();
+		print_string(warning_text);
+		screen_style_normal();
+	} else {
+		free(warning_text);
+		warning_text = NULL;
+	}
+	screen_newline();
 }
 
@@ -492,24 +492,16 @@
 	print_cpu_info(data);
 	print_physmem_info(data);
-	
-	/* Empty row for warnings */
-	screen_get_pos(&warn_col, &warn_row);
-	screen_newline();
-	
-	switch (op_mode) {
-	case OP_TASKS:
-		print_tasks_head();
-		print_tasks(data);
+	print_warning();
+	
+	switch (screen_mode) {
+	case SCREEN_TABLE:
+		print_table_head(&data->table);
+		print_table(&data->table);
 		break;
-	case OP_IPC:
-		print_ipc_head();
-		print_ipc(data);
+	case SCREEN_SORT:
+		print_sort(&data->table);
 		break;
-	case OP_EXCS:
-		print_excs_head();
-		print_excs(data);
-		break;
-	case OP_HELP:
-		print_tasks_head();
+	case SCREEN_HELP:
+		print_help_head();
 		print_help();
 	}
@@ -518,14 +510,25 @@
 }
 
-void print_warning(const char *fmt, ...)
-{
-	screen_moveto(warn_col, warn_row);
-	
+void show_warning(const char *fmt, ...)
+{
+	sysarg_t cols;
+	sysarg_t rows;
+	screen_get_size(&cols, &rows);
+
+	size_t warning_text_size = 1 + cols * sizeof(*warning_text);
+	free(warning_text);
+	warning_text = malloc(warning_text_size);
+	if (!warning_text)
+		return;
+
 	va_list args;
 	va_start(args, fmt);
-	vprintf(fmt, args);
+	vsnprintf(warning_text, warning_text_size, fmt, args);
 	va_end(args);
 	
-	screen_newline();
+	warning_timeleft = 2 * USEC_COUNT;
+
+	screen_moveto(warning_col, warning_row);
+	print_warning();
 	console_flush(console);
 }
@@ -555,8 +558,10 @@
 		kbd_event_t event;
 		
+		warning_timeleft -= timeleft;
 		if (!console_get_kbd_event_timeout(console, &event, &timeleft)) {
 			timeleft = 0;
 			return -1;
 		}
+		warning_timeleft += timeleft;
 		
 		if (event.type == KEY_PRESS)
Index: uspace/app/top/screen.h
===================================================================
--- uspace/app/top/screen.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/top/screen.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -43,5 +43,5 @@
 extern void screen_done(void);
 extern void print_data(data_t *);
-extern void print_warning(const char *, ...);
+extern void show_warning(const char *, ...);
 
 extern int tgetchar(unsigned int);
Index: uspace/app/top/top.c
===================================================================
--- uspace/app/top/top.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/top/top.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -55,7 +55,80 @@
 #define MINUTE  60
 
-op_mode_t op_mode = OP_TASKS;
-sort_mode_t sort_mode = SORT_TASK_CYCLES;
-bool excs_all = false;
+typedef enum {
+	OP_TASKS,
+	OP_IPC,
+	OP_EXCS,
+} op_mode_t;
+
+static const column_t task_columns[] = {
+	{"taskid",   't',  8},
+	{"thrds",    'h',  7},
+	{"resident", 'r', 10},
+	{"%resi",    'R',  7},
+	{"virtual",  'v',  9},
+	{"%virt",    'V',  7},
+	{"%user",    'U',  7},
+	{"%kern",    'K',  7},
+	{"name",     'd',  0},
+};
+
+enum {
+	TASK_COL_ID = 0,
+	TASK_COL_NUM_THREADS,
+	TASK_COL_RESIDENT,
+	TASK_COL_PERCENT_RESIDENT,
+	TASK_COL_VIRTUAL,
+	TASK_COL_PERCENT_VIRTUAL,
+	TASK_COL_PERCENT_USER,
+	TASK_COL_PERCENT_KERNEL,
+	TASK_COL_NAME,
+	TASK_NUM_COLUMNS,
+};
+
+static const column_t ipc_columns[] = {
+	{"taskid",  't', 8},
+	{"cls snt", 'c', 9},
+	{"cls rcv", 'C', 9},
+	{"ans snt", 'a', 9},
+	{"ans rcv", 'A', 9},
+	{"forward", 'f', 9},
+	{"name",    'd', 0},
+};
+
+enum {
+	IPC_COL_TASKID = 0,
+	IPC_COL_CLS_SNT,
+	IPC_COL_CLS_RCV,
+	IPC_COL_ANS_SNT,
+	IPC_COL_ANS_RCV,
+	IPC_COL_FORWARD,
+	IPC_COL_NAME,
+	IPC_NUM_COLUMNS,
+};
+
+static const column_t exception_columns[] = {
+	{"exc",         'e',  8},
+	{"count",       'n', 10},
+	{"%count",      'N',  8},
+	{"cycles",      'c', 10},
+	{"%cycles",     'C',  9},
+	{"description", 'd',  0},
+};
+
+enum {
+	EXCEPTION_COL_ID = 0,
+	EXCEPTION_COL_COUNT,
+	EXCEPTION_COL_PERCENT_COUNT,
+	EXCEPTION_COL_CYCLES,
+	EXCEPTION_COL_PERCENT_CYCLES,
+	EXCEPTION_COL_DESCRIPTION,
+	EXCEPTION_NUM_COLUMNS,
+};
+
+screen_mode_t screen_mode = SCREEN_TABLE;
+static op_mode_t op_mode = OP_TASKS;
+static size_t sort_column = TASK_COL_PERCENT_USER;
+static int sort_reverse = -1;
+static bool excs_all = false;
 
 static const char *read_data(data_t *target)
@@ -67,5 +140,4 @@
 	target->tasks = NULL;
 	target->tasks_perc = NULL;
-	target->tasks_map = NULL;
 	target->threads = NULL;
 	target->exceptions = NULL;
@@ -76,4 +148,9 @@
 	target->ecycles_diff = NULL;
 	target->ecount_diff = NULL;
+	target->table.name = NULL;
+	target->table.num_columns = 0;
+	target->table.columns = NULL;
+	target->table.num_fields = 0;
+	target->table.fields = NULL;
 	
 	/* Get current time */
@@ -117,9 +194,4 @@
 	if (target->tasks_perc == NULL)
 		return "Not enough memory for task utilization";
-	
-	target->tasks_map =
-	    (size_t *) calloc(target->tasks_count, sizeof(size_t));
-	if (target->tasks_map == NULL)
-		return "Not enough memory for task map";
 	
 	/* Get threads */
@@ -289,29 +361,172 @@
 static int cmp_data(void *a, void *b, void *arg)
 {
-	size_t ia = *((size_t *) a);
-	size_t ib = *((size_t *) b);
-	data_t *data = (data_t *) arg;
-	
-	uint64_t acycles = data->ucycles_diff[ia] + data->kcycles_diff[ia];
-	uint64_t bcycles = data->ucycles_diff[ib] + data->kcycles_diff[ib];
-	
-	if (acycles > bcycles)
-		return -1;
-	
-	if (acycles < bcycles)
-		return 1;
-	
+	field_t *fa = (field_t *)a + sort_column;
+	field_t *fb = (field_t *)b + sort_column;
+	
+	if (fa->type > fb->type)
+		return 1 * sort_reverse;
+
+	if (fa->type < fb->type)
+		return -1 * sort_reverse;
+
+	switch (fa->type) {
+	case FIELD_EMPTY:
+		return 0;
+	case FIELD_UINT_SUFFIX_BIN: /* fallthrough */
+	case FIELD_UINT_SUFFIX_DEC: /* fallthrough */
+	case FIELD_UINT:
+		if (fa->uint > fb->uint)
+			return 1 * sort_reverse;
+		if (fa->uint < fb->uint)
+			return -1 * sort_reverse;
+		return 0;
+	case FIELD_PERCENT:
+		if (fa->fixed.upper * fb->fixed.lower
+		    > fb->fixed.upper * fa->fixed.lower)
+			return 1 * sort_reverse;
+		if (fa->fixed.upper * fb->fixed.lower
+		    < fb->fixed.upper * fa->fixed.lower)
+			return -1 * sort_reverse;
+		return 0;
+	case FIELD_STRING:
+		return str_cmp(fa->string, fb->string) * sort_reverse;
+	}
+
 	return 0;
 }
 
-static void sort_data(data_t *data)
-{
-	size_t i;
-	
-	for (i = 0; i < data->tasks_count; i++)
-		data->tasks_map[i] = i;
-	
-	qsort((void *) data->tasks_map, data->tasks_count,
-	    sizeof(size_t), cmp_data, (void *) data);
+static void sort_table(table_t *table)
+{
+	if (sort_column >= table->num_columns)
+		sort_column = 0;
+	/* stable sort is probably best, so we use gsort */
+	gsort((void *) table->fields, table->num_fields / table->num_columns,
+	    sizeof(field_t) * table->num_columns, cmp_data, NULL);
+}
+
+static const char *fill_task_table(data_t *data)
+{
+	data->table.name = "Tasks";
+	data->table.num_columns = TASK_NUM_COLUMNS;
+	data->table.columns = task_columns;
+	data->table.num_fields = data->tasks_count * TASK_NUM_COLUMNS;
+	data->table.fields = calloc(data->table.num_fields,
+	    sizeof(field_t));
+	if (data->table.fields == NULL)
+		return "Not enough memory for table fields";
+
+	field_t *field = data->table.fields;
+	for (size_t i = 0; i < data->tasks_count; i++) {
+		stats_task_t *task = &data->tasks[i];
+		perc_task_t *perc = &data->tasks_perc[i];
+		field[TASK_COL_ID].type = FIELD_UINT;
+		field[TASK_COL_ID].uint = task->task_id;
+		field[TASK_COL_NUM_THREADS].type = FIELD_UINT;
+		field[TASK_COL_NUM_THREADS].uint = task->threads;
+		field[TASK_COL_RESIDENT].type = FIELD_UINT_SUFFIX_BIN;
+		field[TASK_COL_RESIDENT].uint = task->resmem;
+		field[TASK_COL_PERCENT_RESIDENT].type = FIELD_PERCENT;
+		field[TASK_COL_PERCENT_RESIDENT].fixed = perc->resmem;
+		field[TASK_COL_VIRTUAL].type = FIELD_UINT_SUFFIX_BIN;
+		field[TASK_COL_VIRTUAL].uint = task->virtmem;
+		field[TASK_COL_PERCENT_VIRTUAL].type = FIELD_PERCENT;
+		field[TASK_COL_PERCENT_VIRTUAL].fixed = perc->virtmem;
+		field[TASK_COL_PERCENT_USER].type = FIELD_PERCENT;
+		field[TASK_COL_PERCENT_USER].fixed = perc->ucycles;
+		field[TASK_COL_PERCENT_KERNEL].type = FIELD_PERCENT;
+		field[TASK_COL_PERCENT_KERNEL].fixed = perc->kcycles;
+		field[TASK_COL_NAME].type = FIELD_STRING;
+		field[TASK_COL_NAME].string = task->name;
+		field += TASK_NUM_COLUMNS;
+	}
+
+	return NULL;
+}
+
+static const char *fill_ipc_table(data_t *data)
+{
+	data->table.name = "IPC";
+	data->table.num_columns = IPC_NUM_COLUMNS;
+	data->table.columns = ipc_columns;
+	data->table.num_fields = data->tasks_count * IPC_NUM_COLUMNS;
+	data->table.fields = calloc(data->table.num_fields,
+	    sizeof(field_t));
+	if (data->table.fields == NULL)
+		return "Not enough memory for table fields";
+
+	field_t *field = data->table.fields;
+	for (size_t i = 0; i < data->tasks_count; i++) {
+		field[IPC_COL_TASKID].type = FIELD_UINT;
+		field[IPC_COL_TASKID].uint = data->tasks[i].task_id;
+		field[IPC_COL_CLS_SNT].type = FIELD_UINT_SUFFIX_DEC;
+		field[IPC_COL_CLS_SNT].uint = data->tasks[i].ipc_info.call_sent;
+		field[IPC_COL_CLS_RCV].type = FIELD_UINT_SUFFIX_DEC;
+		field[IPC_COL_CLS_RCV].uint = data->tasks[i].ipc_info.call_received;
+		field[IPC_COL_ANS_SNT].type = FIELD_UINT_SUFFIX_DEC;
+		field[IPC_COL_ANS_SNT].uint = data->tasks[i].ipc_info.answer_sent;
+		field[IPC_COL_ANS_RCV].type = FIELD_UINT_SUFFIX_DEC;
+		field[IPC_COL_ANS_RCV].uint = data->tasks[i].ipc_info.answer_received;
+		field[IPC_COL_FORWARD].type = FIELD_UINT_SUFFIX_DEC;
+		field[IPC_COL_FORWARD].uint = data->tasks[i].ipc_info.forwarded;
+		field[IPC_COL_NAME].type = FIELD_STRING;
+		field[IPC_COL_NAME].string = data->tasks[i].name;
+		field += IPC_NUM_COLUMNS;
+	}
+
+	return NULL;
+}
+
+static const char *fill_exception_table(data_t *data)
+{
+	data->table.name = "Exceptions";
+	data->table.num_columns = EXCEPTION_NUM_COLUMNS;
+	data->table.columns = exception_columns;
+	data->table.num_fields = data->exceptions_count *
+	    EXCEPTION_NUM_COLUMNS;
+	data->table.fields = calloc(data->table.num_fields, sizeof(field_t));
+	if (data->table.fields == NULL)
+		return "Not enough memory for table fields";
+
+	field_t *field = data->table.fields;
+	for (size_t i = 0; i < data->exceptions_count; i++) {
+		if (!excs_all && !data->exceptions[i].hot)
+			continue;
+		field[EXCEPTION_COL_ID].type = FIELD_UINT;
+		field[EXCEPTION_COL_ID].uint = data->exceptions[i].id;
+		field[EXCEPTION_COL_COUNT].type = FIELD_UINT_SUFFIX_DEC;
+		field[EXCEPTION_COL_COUNT].uint = data->exceptions[i].count;
+		field[EXCEPTION_COL_PERCENT_COUNT].type = FIELD_PERCENT;
+		field[EXCEPTION_COL_PERCENT_COUNT].fixed = data->exceptions_perc[i].count;
+		field[EXCEPTION_COL_CYCLES].type = FIELD_UINT_SUFFIX_DEC;
+		field[EXCEPTION_COL_CYCLES].uint = data->exceptions[i].cycles;
+		field[EXCEPTION_COL_PERCENT_CYCLES].type = FIELD_PERCENT;
+		field[EXCEPTION_COL_PERCENT_CYCLES].fixed = data->exceptions_perc[i].cycles;
+		field[EXCEPTION_COL_DESCRIPTION].type = FIELD_STRING;
+		field[EXCEPTION_COL_DESCRIPTION].string = data->exceptions[i].desc;
+		field += EXCEPTION_NUM_COLUMNS;
+	}
+
+	/* in case any cold exceptions were ignored */
+	data->table.num_fields = field - data->table.fields;
+
+	return NULL;
+}
+
+static const char *fill_table(data_t *data)
+{
+	if (data->table.fields != NULL) {
+		free(data->table.fields);
+		data->table.fields = NULL;
+	}
+
+	switch (op_mode) {
+	case OP_TASKS:
+		return fill_task_table(data);
+	case OP_IPC:
+		return fill_ipc_table(data);
+	case OP_EXCS:
+		return fill_exception_table(data);
+	}
+	return NULL;
 }
 
@@ -356,4 +571,7 @@
 	if (target->ecount_diff != NULL)
 		free(target->ecount_diff);
+
+	if (target->table.fields != NULL)
+		free(target->table.fields);
 }
 
@@ -367,65 +585,94 @@
 	printf("Reading initial data...\n");
 	
-	if ((ret = read_data(&data_prev)) != NULL)
+	if ((ret = read_data(&data)) != NULL)
 		goto out;
 	
 	/* Compute some rubbish to have initialised values */
-	compute_percentages(&data_prev, &data_prev);
+	compute_percentages(&data, &data);
 	
 	/* And paint screen until death */
 	while (true) {
 		int c = tgetchar(UPDATE_INTERVAL);
-		if (c < 0) {
+
+		if (c < 0) { /* timeout */
+			data_prev = data;
 			if ((ret = read_data(&data)) != NULL) {
-				free_data(&data);
+				free_data(&data_prev);
 				goto out;
 			}
 			
 			compute_percentages(&data_prev, &data);
-			sort_data(&data);
-			print_data(&data);
 			free_data(&data_prev);
-			data_prev = data;
-			
-			continue;
-		}
-		
+
+			c = -1;
+		}
+
+		if (screen_mode == SCREEN_HELP && c >= 0) {
+			if (c == 'h' || c == '?')
+				c = -1;
+			/* go back to table and handle the key */
+			screen_mode = SCREEN_TABLE;
+		}
+
+		if (screen_mode == SCREEN_SORT && c >= 0) {
+			for (size_t i = 0; i < data.table.num_columns; i++) {
+				if (data.table.columns[i].key == c) {
+					sort_column = i;
+					screen_mode = SCREEN_TABLE;
+				}
+			}
+
+			c = -1;
+		}
+
 		switch (c) {
-			case 't':
-				print_warning("Showing task statistics");
-				op_mode = OP_TASKS;
+		case -1: /* do nothing */
+			break;
+		case 't':
+			op_mode = OP_TASKS;
+			break;
+		case 'i':
+			op_mode = OP_IPC;
+			break;
+		case 'e':
+			op_mode = OP_EXCS;
+			break;
+		case 's':
+			screen_mode = SCREEN_SORT;
+			break;
+		case 'r':
+			sort_reverse = -sort_reverse;
+			break;
+		case 'h':
+		case '?':
+			screen_mode = SCREEN_HELP;
+			break;
+		case 'q':
+			goto out;
+		case 'a':
+			if (op_mode == OP_EXCS) {
+				excs_all = !excs_all;
+				if (excs_all)
+					show_warning("Showing all exceptions");
+				else
+					show_warning("Showing only hot exceptions");
 				break;
-			case 'i':
-				print_warning("Showing IPC statistics");
-				op_mode = OP_IPC;
-				break;
-			case 'e':
-				print_warning("Showing exception statistics");
-				op_mode = OP_EXCS;
-				break;
-			case 'h':
-				print_warning("Showing help");
-				op_mode = OP_HELP;
-				break;
-			case 'q':
-				goto out;
-			case 'a':
-				if (op_mode == OP_EXCS) {
-					excs_all = !excs_all;
-					if (excs_all)
-						print_warning("Showing all exceptions");
-					else
-						print_warning("Showing only hot exceptions");
-					break;
-				}
-			default:
-				print_warning("Unknown command \"%c\", use \"h\" for help", c);
-				break;
-		}
+			}
+			/* fallthrough */
+		default:
+			show_warning("Unknown command \"%c\", use \"h\" for help", c);
+			continue; /* don't redraw */
+		}
+
+		if ((ret = fill_table(&data)) != NULL) {
+			goto out;
+		}
+		sort_table(&data.table);
+		print_data(&data);
 	}
 	
 out:
 	screen_done();
-	free_data(&data_prev);
+	free_data(&data);
 	
 	if (ret != NULL) {
Index: uspace/app/top/top.h
===================================================================
--- uspace/app/top/top.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/top/top.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -51,17 +51,10 @@
 
 typedef enum {
-	OP_TASKS,
-	OP_IPC,
-	OP_EXCS,
-	OP_HELP
-} op_mode_t;
+	SCREEN_TABLE,
+	SCREEN_SORT,
+	SCREEN_HELP,
+} screen_mode_t;
 
-typedef enum {
-	SORT_TASK_CYCLES
-} sort_mode_t;
-
-extern op_mode_t op_mode;
-extern sort_mode_t sort_mode;
-extern bool excs_all;
+extern screen_mode_t screen_mode;
 
 typedef struct {
@@ -87,4 +80,32 @@
 } perc_exc_t;
 
+typedef enum {
+	FIELD_EMPTY, FIELD_UINT, FIELD_UINT_SUFFIX_BIN, FIELD_UINT_SUFFIX_DEC,
+	FIELD_PERCENT, FIELD_STRING
+} field_type_t;
+
+typedef struct {
+	field_type_t type;
+	union {
+		fixed_float fixed;
+		uint64_t uint;
+		const char *string;
+	};
+} field_t;
+
+typedef struct {
+	const char *name;
+	char key;
+	int width;
+} column_t;
+
+typedef struct {
+	const char *name;
+	size_t num_columns;
+	const column_t *columns;
+	size_t num_fields;
+	field_t *fields;
+} table_t;
+
 typedef struct {
 	time_t hours;
@@ -107,5 +128,4 @@
 	stats_task_t *tasks;
 	perc_task_t *tasks_perc;
-	size_t *tasks_map;
 	
 	size_t threads_count;
@@ -122,4 +142,6 @@
 	uint64_t *ecycles_diff;
 	uint64_t *ecount_diff;
+
+	table_t table;
 } data_t;
 
Index: uspace/app/websrv/websrv.c
===================================================================
--- uspace/app/websrv/websrv.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/app/websrv/websrv.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -200,5 +200,5 @@
 {
 	if (str_cmp(uri, "/") == 0)
-		uri = "/index.htm";
+		uri = "/index.html";
 	
 	char *fname;
Index: pace/dist/data/web/bar.htm
===================================================================
--- uspace/dist/data/web/bar.htm	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<html>
-    <head>
-	<title>Bar!</title>
-    </head>
-    <body>
-	<h1>Bar!</h1>
-
-	<a href="/">Back to top</a>
-    </body>
-</html>
Index: uspace/dist/data/web/bar.html
===================================================================
--- uspace/dist/data/web/bar.html	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/dist/data/web/bar.html	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,10 @@
+<html>
+    <head>
+	<title>Bar!</title>
+    </head>
+    <body>
+	<h1>Bar!</h1>
+
+	<a href="/">Back to top</a>
+    </body>
+</html>
Index: pace/dist/data/web/foo.htm
===================================================================
--- uspace/dist/data/web/foo.htm	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<html>
-    <head>
-	<title>Foo!</title>
-    </head>
-    <body>
-	<h1>Foo!</h1>
-
-	<a href="/">Back to top</a>
-    </body>
-</html>
Index: uspace/dist/data/web/foo.html
===================================================================
--- uspace/dist/data/web/foo.html	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/dist/data/web/foo.html	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,10 @@
+<html>
+    <head>
+	<title>Foo!</title>
+    </head>
+    <body>
+	<h1>Foo!</h1>
+
+	<a href="/">Back to top</a>
+    </body>
+</html>
Index: pace/dist/data/web/index.htm
===================================================================
--- uspace/dist/data/web/index.htm	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,19 +1,0 @@
-<html>
-    <head>
-        <title>
-    	    Hello from HelenOS!
-        </title>
-    </head>
-    <body>
-        <h1>Hello from HelenOS!</h1>
-        <img src="helenos.png" alt="" style="float: left; margin: 6px;">
-        <p>
-            This web page is brought to you by courtesy of HelenOS web server
-    	    and TCP/IP stack.
-        </p>
-	<p>
-    	    Now <a href="foo.htm">go to page foo</a> or <a href="bar.htm">go
-    	    to bar</a>.
-        </p>
-    </body>
-</html>
Index: uspace/dist/data/web/index.html
===================================================================
--- uspace/dist/data/web/index.html	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/dist/data/web/index.html	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,19 @@
+<html>
+    <head>
+        <title>
+    	    Hello from HelenOS!
+        </title>
+    </head>
+    <body>
+        <h1>Hello from HelenOS!</h1>
+        <img src="helenos.png" alt="" style="float: left; margin: 6px;">
+        <p>
+            This web page is brought to you by courtesy of HelenOS web server
+    	    and TCP/IP stack.
+        </p>
+	<p>
+    	    Now <a href="foo.html">go to page foo</a> or <a href="bar.html">go
+    	    to bar</a>.
+        </p>
+    </body>
+</html>
Index: uspace/drv/bus/isa/isa.c
===================================================================
--- uspace/drv/bus/isa/isa.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/isa/isa.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -66,6 +66,4 @@
 #include <ops/hw_res.h>
 
-#include <devman.h>
-#include <ipc/devman.h>
 #include <device/hw_res.h>
 
Index: uspace/drv/bus/usb/ehci/Makefile
===================================================================
--- uspace/drv/bus/usb/ehci/Makefile	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/ehci/Makefile	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -43,5 +43,5 @@
 SOURCES = \
 	main.c \
-	pci.c
+	res.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/bus/usb/ehci/main.c
===================================================================
--- uspace/drv/bus/usb/ehci/main.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/ehci/main.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -44,5 +44,5 @@
 #include <usb/host/hcd.h>
 
-#include "pci.h"
+#include "res.h"
 
 #define NAME "ehci"
@@ -81,5 +81,5 @@
 	int irq = 0;
 
-	int ret = pci_get_my_registers(device, &reg_base, &reg_size, &irq);
+	int ret = get_my_registers(device, &reg_base, &reg_size, &irq);
 	CHECK_RET_RETURN(ret,
 	    "Failed to get memory addresses for %" PRIun ": %s.\n",
@@ -88,5 +88,5 @@
 	    reg_base, reg_size, irq);
 
-	ret = pci_disable_legacy(device, reg_base, reg_size, irq);
+	ret = disable_legacy(device, reg_base, reg_size);
 	CHECK_RET_RETURN(ret,
 	    "Failed to disable legacy USB: %s.\n", str_error(ret));
Index: pace/drv/bus/usb/ehci/pci.c
===================================================================
--- uspace/drv/bus/usb/ehci/pci.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,391 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * 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 drvusbehci
- * @{
- */
-/**
- * @file
- * PCI related functions needed by the EHCI driver.
- */
-
-#include <errno.h>
-#include <str_error.h>
-#include <assert.h>
-#include <as.h>
-#include <devman.h>
-#include <ddi.h>
-#include <libarch/ddi.h>
-#include <device/hw_res.h>
-
-#include <usb/debug.h>
-#include <pci_dev_iface.h>
-
-#include "pci.h"
-
-#define PAGE_SIZE_MASK 0xfffff000
-
-#define HCC_PARAMS_OFFSET 0x8
-#define HCC_PARAMS_EECP_MASK 0xff
-#define HCC_PARAMS_EECP_OFFSET 8
-
-#define CMD_OFFSET 0x0
-#define STS_OFFSET 0x4
-#define INT_OFFSET 0x8
-#define CFG_OFFSET 0x40
-
-#define USBCMD_RUN 1
-#define USBSTS_HALTED (1 << 12)
-
-#define USBLEGSUP_OFFSET 0
-#define USBLEGSUP_BIOS_CONTROL (1 << 16)
-#define USBLEGSUP_OS_CONTROL (1 << 24)
-#define USBLEGCTLSTS_OFFSET 4
-
-#define DEFAULT_WAIT 1000
-#define WAIT_STEP 10
-
-#define PCI_READ(size) \
-do { \
-	async_sess_t *parent_sess = \
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, \
-	    IPC_FLAG_BLOCKING); \
-	if (!parent_sess) \
-		return ENOMEM; \
-	\
-	sysarg_t add = (sysarg_t) address; \
-	sysarg_t val; \
-	\
-	async_exch_t *exch = async_exchange_begin(parent_sess); \
-	\
-	const int ret = \
-	    async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE), \
-	        IPC_M_CONFIG_SPACE_READ_##size, add, &val); \
-	\
-	async_exchange_end(exch); \
-	async_hangup(parent_sess); \
-	\
-	assert(value); \
-	\
-	*value = val; \
-	return ret; \
-} while (0)
-
-static int pci_read32(const ddf_dev_t *dev, int address, uint32_t *value)
-{
-	PCI_READ(32);
-}
-
-static int pci_read16(const ddf_dev_t *dev, int address, uint16_t *value)
-{
-	PCI_READ(16);
-}
-
-static int pci_read8(const ddf_dev_t *dev, int address, uint8_t *value)
-{
-	PCI_READ(8);
-}
-
-#define PCI_WRITE(size) \
-do { \
-	async_sess_t *parent_sess = \
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, \
-	    IPC_FLAG_BLOCKING); \
-	if (!parent_sess) \
-		return ENOMEM; \
-	\
-	sysarg_t add = (sysarg_t) address; \
-	sysarg_t val = value; \
-	\
-	async_exch_t *exch = async_exchange_begin(parent_sess); \
-	\
-	const int ret = \
-	    async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE), \
-	        IPC_M_CONFIG_SPACE_WRITE_##size, add, val); \
-	\
-	async_exchange_end(exch); \
-	async_hangup(parent_sess); \
-	\
-	return ret; \
-} while(0)
-
-static int pci_write32(const ddf_dev_t *dev, int address, uint32_t value)
-{
-	PCI_WRITE(32);
-}
-
-static int pci_write16(const ddf_dev_t *dev, int address, uint16_t value)
-{
-	PCI_WRITE(16);
-}
-
-static int pci_write8(const ddf_dev_t *dev, int address, uint8_t value)
-{
-	PCI_WRITE(8);
-}
-
-/** Get address of registers and IRQ for given device.
- *
- * @param[in] dev Device asking for the addresses.
- * @param[out] mem_reg_address Base address of the memory range.
- * @param[out] mem_reg_size Size of the memory range.
- * @param[out] irq_no IRQ assigned to the device.
- * @return Error code.
- */
-int pci_get_my_registers(const ddf_dev_t *dev,
-    uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no)
-{
-	assert(dev != NULL);
-	
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
-	    IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-	
-	hw_resource_list_t hw_resources;
-	int rc = hw_res_get_resource_list(parent_sess, &hw_resources);
-	if (rc != EOK) {
-		async_hangup(parent_sess);
-		return rc;
-	}
-	
-	uintptr_t mem_address = 0;
-	size_t mem_size = 0;
-	bool mem_found = false;
-	
-	int irq = 0;
-	bool irq_found = false;
-	
-	size_t i;
-	for (i = 0; i < hw_resources.count; i++) {
-		hw_resource_t *res = &hw_resources.resources[i];
-		switch (res->type) {
-		case INTERRUPT:
-			irq = res->res.interrupt.irq;
-			irq_found = true;
-			usb_log_debug2("Found interrupt: %d.\n", irq);
-			break;
-		case MEM_RANGE:
-			if (res->res.mem_range.address != 0
-			    && res->res.mem_range.size != 0 ) {
-				mem_address = res->res.mem_range.address;
-				mem_size = res->res.mem_range.size;
-				usb_log_debug2("Found mem: %" PRIxn" %zu.\n",
-				    mem_address, mem_size);
-				mem_found = true;
-			}
-		default:
-			break;
-		}
-	}
-	
-	if (mem_found && irq_found) {
-		*mem_reg_address = mem_address;
-		*mem_reg_size = mem_size;
-		*irq_no = irq;
-		rc = EOK;
-	} else {
-		rc = ENOENT;
-	}
-	
-	async_hangup(parent_sess);
-	return rc;
-}
-/*----------------------------------------------------------------------------*/
-/** Calls the PCI driver with a request to enable interrupts
- *
- * @param[in] device Device asking for interrupts
- * @return Error code.
- */
-int pci_enable_interrupts(const ddf_dev_t *device)
-{
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
-	    IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-	
-	const bool enabled = hw_res_enable_interrupt(parent_sess);
-	async_hangup(parent_sess);
-	
-	return enabled ? EOK : EIO;
-}
-/*----------------------------------------------------------------------------*/
-/** Implements BIOS handoff routine as decribed in EHCI spec
- *
- * @param[in] device Device asking for interrupts
- * @return Error code.
- */
-int pci_disable_legacy(
-    const ddf_dev_t *device, uintptr_t reg_base, size_t reg_size, int irq)
-{
-	assert(device);
-	(void) pci_read16;
-	(void) pci_read8;
-	(void) pci_write16;
-
-#define CHECK_RET_RETURN(ret, message...) \
-	if (ret != EOK) { \
-		usb_log_error(message); \
-		return ret; \
-	} else (void)0
-
-	/* Map EHCI registers */
-	void *regs = NULL;
-	int ret = pio_enable((void*)reg_base, reg_size, &regs);
-	CHECK_RET_RETURN(ret, "Failed to map registers %p: %s.\n",
-	    (void *) reg_base, str_error(ret));
-
-	const uint32_t hcc_params =
-	    *(uint32_t*)(regs + HCC_PARAMS_OFFSET);
-	usb_log_debug("Value of hcc params register: %x.\n", hcc_params);
-
-	/* Read value of EHCI Extended Capabilities Pointer
-	 * position of EEC registers (points to PCI config space) */
-	const uint32_t eecp =
-	    (hcc_params >> HCC_PARAMS_EECP_OFFSET) & HCC_PARAMS_EECP_MASK;
-	usb_log_debug("Value of EECP: %x.\n", eecp);
-
-	/* Read the first EEC. i.e. Legacy Support register */
-	uint32_t usblegsup;
-	ret = pci_read32(device, eecp + USBLEGSUP_OFFSET, &usblegsup);
-	CHECK_RET_RETURN(ret, "Failed to read USBLEGSUP: %s.\n", str_error(ret));
-	usb_log_debug("USBLEGSUP: %" PRIx32 ".\n", usblegsup);
-
-	/* Request control from firmware/BIOS, by writing 1 to highest byte.
-	 * (OS Control semaphore)*/
-	usb_log_debug("Requesting OS control.\n");
-	ret = pci_write8(device, eecp + USBLEGSUP_OFFSET + 3, 1);
-	CHECK_RET_RETURN(ret, "Failed to request OS EHCI control: %s.\n",
-	    str_error(ret));
-
-	size_t wait = 0;
-	/* Wait for BIOS to release control. */
-	ret = pci_read32(device, eecp + USBLEGSUP_OFFSET, &usblegsup);
-	while ((wait < DEFAULT_WAIT) && (usblegsup & USBLEGSUP_BIOS_CONTROL)) {
-		async_usleep(WAIT_STEP);
-		ret = pci_read32(device, eecp + USBLEGSUP_OFFSET, &usblegsup);
-		wait += WAIT_STEP;
-	}
-
-
-	if ((usblegsup & USBLEGSUP_BIOS_CONTROL) == 0) {
-		usb_log_info("BIOS released control after %zu usec.\n", wait);
-	} else {
-		/* BIOS failed to hand over control, this should not happen. */
-		usb_log_warning( "BIOS failed to release control after "
-		    "%zu usecs, force it.\n", wait);
-		ret = pci_write32(device, eecp + USBLEGSUP_OFFSET,
-		    USBLEGSUP_OS_CONTROL);
-		CHECK_RET_RETURN(ret, "Failed to force OS control: %s.\n",
-		    str_error(ret));
-		/* Check capability type here, A value of 01h
-		 * identifies the capability as Legacy Support.
-		 * This extended capability requires one
-		 * additional 32-bit register for control/status information,
-		 * and this register is located at offset EECP+04h
-		 * */
-		if ((usblegsup & 0xff) == 1) {
-			/* Read the second EEC
-			 * Legacy Support and Control register */
-			uint32_t usblegctlsts;
-			ret = pci_read32(
-			    device, eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts);
-			CHECK_RET_RETURN(ret,
-			    "Failed to get USBLEGCTLSTS: %s.\n", str_error(ret));
-			usb_log_debug("USBLEGCTLSTS: %" PRIx32 ".\n",
-			    usblegctlsts);
-			/* Zero SMI enables in legacy control register.
-			 * It should prevent pre-OS code from interfering. */
-			ret = pci_write32(device, eecp + USBLEGCTLSTS_OFFSET,
-			    0xe0000000); /* three upper bits are WC */
-			CHECK_RET_RETURN(ret,
-			    "Failed(%d) zero USBLEGCTLSTS.\n", ret);
-			udelay(10);
-			ret = pci_read32(
-			    device, eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts);
-			CHECK_RET_RETURN(ret,
-			    "Failed to get USBLEGCTLSTS 2: %s.\n",
-			    str_error(ret));
-			usb_log_debug("Zeroed USBLEGCTLSTS: %" PRIx32 ".\n",
-			    usblegctlsts);
-		}
-	}
-
-
-	/* Read again Legacy Support register */
-	ret = pci_read32(device, eecp + USBLEGSUP_OFFSET, &usblegsup);
-	CHECK_RET_RETURN(ret, "Failed to read USBLEGSUP: %s.\n", str_error(ret));
-	usb_log_debug("USBLEGSUP: %" PRIx32 ".\n", usblegsup);
-
-	/*
-	 * TURN OFF EHCI FOR NOW, DRIVER WILL REINITIALIZE IT
-	 */
-
-	/* Get size of capability registers in memory space. */
-	const unsigned operation_offset = *(uint8_t*)regs;
-	usb_log_debug("USBCMD offset: %d.\n", operation_offset);
-
-	/* Zero USBCMD register. */
-	volatile uint32_t *usbcmd =
-	    (uint32_t*)((uint8_t*)regs + operation_offset + CMD_OFFSET);
-	volatile uint32_t *usbsts =
-	    (uint32_t*)((uint8_t*)regs + operation_offset + STS_OFFSET);
-	volatile uint32_t *usbconf =
-	    (uint32_t*)((uint8_t*)regs + operation_offset + CFG_OFFSET);
-	volatile uint32_t *usbint =
-	    (uint32_t*)((uint8_t*)regs + operation_offset + INT_OFFSET);
-	usb_log_debug("USBCMD value: %x.\n", *usbcmd);
-	if (*usbcmd & USBCMD_RUN) {
-		*usbsts = 0x3f; /* ack all interrupts */
-		*usbint = 0; /* disable all interrutps */
-		*usbconf = 0; /* relase control of RH ports */
-
-		*usbcmd = 0;
-		/* Wait until hc is halted */
-		while ((*usbsts & USBSTS_HALTED) == 0);
-		usb_log_info("EHCI turned off.\n");
-	} else {
-		usb_log_info("EHCI was not running.\n");
-	}
-	usb_log_debug("Registers: \n"
-	    "\t USBCMD: %x(0x00080000 = at least 1ms between interrupts)\n"
-	    "\t USBSTS: %x(0x00001000 = HC halted)\n"
-	    "\t USBINT: %x(0x0 = no interrupts).\n"
-	    "\t CONFIG: %x(0x0 = ports controlled by companion hc).\n",
-	    *usbcmd, *usbsts, *usbint, *usbconf);
-
-	return ret;
-#undef CHECK_RET_RETURN
-}
-
-/**
- * @}
- */
Index: pace/drv/bus/usb/ehci/pci.h
===================================================================
--- uspace/drv/bus/usb/ehci/pci.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2011 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 drvusbehci
- * @{
- */
-/** @file
- * PCI related functions needed by EHCI driver.
- */
-#ifndef DRV_EHCI_PCI_H
-#define DRV_EHCI_PCI_H
-
-#include <ddf/driver.h>
-
-int pci_get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
-int pci_enable_interrupts(const ddf_dev_t *);
-int pci_disable_legacy(const ddf_dev_t *, uintptr_t, size_t, int);
-
-#endif
-/**
- * @}
- */
-
Index: uspace/drv/bus/usb/ehci/res.c
===================================================================
--- uspace/drv/bus/usb/ehci/res.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/drv/bus/usb/ehci/res.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * 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 drvusbehci
+ * @{
+ */
+/**
+ * @file
+ * PCI related functions needed by the EHCI driver.
+ */
+
+#include <errno.h>
+#include <str_error.h>
+#include <assert.h>
+#include <devman.h>
+#include <ddi.h>
+#include <usb/debug.h>
+#include <device/hw_res_parsed.h>
+#include <device/pci.h>
+
+#include "res.h"
+
+#define HCC_PARAMS_OFFSET 0x8
+#define HCC_PARAMS_EECP_MASK 0xff
+#define HCC_PARAMS_EECP_OFFSET 8
+
+#define CMD_OFFSET 0x0
+#define STS_OFFSET 0x4
+#define INT_OFFSET 0x8
+#define CFG_OFFSET 0x40
+
+#define USBCMD_RUN 1
+#define USBSTS_HALTED (1 << 12)
+
+#define USBLEGSUP_OFFSET 0
+#define USBLEGSUP_BIOS_CONTROL (1 << 16)
+#define USBLEGSUP_OS_CONTROL (1 << 24)
+#define USBLEGCTLSTS_OFFSET 4
+
+#define DEFAULT_WAIT 1000
+#define WAIT_STEP 10
+
+
+/** Get address of registers and IRQ for given device.
+ *
+ * @param[in] dev Device asking for the addresses.
+ * @param[out] mem_reg_address Base address of the memory range.
+ * @param[out] mem_reg_size Size of the memory range.
+ * @param[out] irq_no IRQ assigned to the device.
+ * @return Error code.
+ */
+int get_my_registers(const ddf_dev_t *dev,
+    uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no)
+{
+	assert(dev);
+	
+	async_sess_t *parent_sess = devman_parent_device_connect(
+	    EXCHANGE_SERIALIZE, dev->handle, IPC_FLAG_BLOCKING);
+	if (!parent_sess)
+		return ENOMEM;
+	
+	hw_res_list_parsed_t hw_res;
+	hw_res_list_parsed_init(&hw_res);
+	const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0);
+	async_hangup(parent_sess);
+	if (ret != EOK) {
+		return ret;
+	}
+
+	if (hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
+		hw_res_list_parsed_clean(&hw_res);
+		return ENOENT;
+	}
+
+	if (mem_reg_address)
+		*mem_reg_address = hw_res.mem_ranges.ranges[0].address;
+	if (mem_reg_size)
+		*mem_reg_size = hw_res.mem_ranges.ranges[0].size;
+	if (irq_no)
+		*irq_no = hw_res.irqs.irqs[0];
+
+	hw_res_list_parsed_clean(&hw_res);
+	return EOK;
+}
+/*----------------------------------------------------------------------------*/
+/** Calls the PCI driver with a request to enable interrupts
+ *
+ * @param[in] device Device asking for interrupts
+ * @return Error code.
+ */
+int enable_interrupts(const ddf_dev_t *device)
+{
+	async_sess_t *parent_sess = devman_parent_device_connect(
+	    EXCHANGE_SERIALIZE, device->handle, IPC_FLAG_BLOCKING);
+	if (!parent_sess)
+		return ENOMEM;
+	
+	const bool enabled = hw_res_enable_interrupt(parent_sess);
+	async_hangup(parent_sess);
+	
+	return enabled ? EOK : EIO;
+}
+/*----------------------------------------------------------------------------*/
+/** Implements BIOS hands-off routine as described in EHCI spec
+ *
+ * @param device EHCI device
+ * @param eecp Value of EHCI Extended Capabilities pointer.
+ * @return Error code.
+ */
+static int disable_extended_caps(const ddf_dev_t *device, unsigned eecp)
+{
+	/* nothing to do */
+	if (eecp == 0)
+		return EOK;
+
+	async_sess_t *parent_sess = devman_parent_device_connect(
+	    EXCHANGE_SERIALIZE, device->handle, IPC_FLAG_BLOCKING);
+	if (!parent_sess)
+		return ENOMEM;
+
+#define CHECK_RET_HANGUP_RETURN(ret, message...) \
+	if (ret != EOK) { \
+		usb_log_error(message); \
+		async_hangup(parent_sess); \
+		return ret; \
+	} else (void)0
+
+	/* Read the first EEC. i.e. Legacy Support register */
+	uint32_t usblegsup;
+	int ret = pci_config_space_read_32(parent_sess,
+	    eecp + USBLEGSUP_OFFSET, &usblegsup);
+	CHECK_RET_HANGUP_RETURN(ret,
+	    "Failed to read USBLEGSUP: %s.\n", str_error(ret));
+	usb_log_debug("USBLEGSUP: %" PRIx32 ".\n", usblegsup);
+
+	/* Request control from firmware/BIOS by writing 1 to highest
+	 * byte. (OS Control semaphore)*/
+	usb_log_debug("Requesting OS control.\n");
+	ret = pci_config_space_write_8(parent_sess,
+	    eecp + USBLEGSUP_OFFSET + 3, 1);
+	CHECK_RET_HANGUP_RETURN(ret, "Failed to request OS EHCI control: %s.\n",
+	    str_error(ret));
+
+	size_t wait = 0;
+	/* Wait for BIOS to release control. */
+	ret = pci_config_space_read_32(
+	    parent_sess, eecp + USBLEGSUP_OFFSET, &usblegsup);
+	while ((wait < DEFAULT_WAIT) && (usblegsup & USBLEGSUP_BIOS_CONTROL)) {
+		async_usleep(WAIT_STEP);
+		ret = pci_config_space_read_32(parent_sess,
+		    eecp + USBLEGSUP_OFFSET, &usblegsup);
+		wait += WAIT_STEP;
+	}
+
+	if ((usblegsup & USBLEGSUP_BIOS_CONTROL) == 0) {
+		usb_log_info("BIOS released control after %zu usec.\n", wait);
+		async_hangup(parent_sess);
+		return EOK;
+	}
+
+	/* BIOS failed to hand over control, this should not happen. */
+	usb_log_warning( "BIOS failed to release control after "
+	    "%zu usecs, force it.\n", wait);
+	ret = pci_config_space_write_32(parent_sess,
+	    eecp + USBLEGSUP_OFFSET, USBLEGSUP_OS_CONTROL);
+	CHECK_RET_HANGUP_RETURN(ret, "Failed to force OS control: "
+	    "%s.\n", str_error(ret));
+	/*
+	 * Check capability type here, value of 01h identifies the capability
+	 * as Legacy Support. This extended capability requires one additional
+	 * 32-bit register for control/status information and this register is
+	 * located at offset EECP+04h
+	 */
+	if ((usblegsup & 0xff) == 1) {
+		/* Read the second EEC Legacy Support and Control register */
+		uint32_t usblegctlsts;
+		ret = pci_config_space_read_32(parent_sess,
+		    eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts);
+		CHECK_RET_HANGUP_RETURN(ret, "Failed to get USBLEGCTLSTS: %s.\n",
+		    str_error(ret));
+		usb_log_debug("USBLEGCTLSTS: %" PRIx32 ".\n", usblegctlsts);
+		/*
+		 * Zero SMI enables in legacy control register.
+		 * It should prevent pre-OS code from
+		 * interfering. NOTE: Three upper bits are WC
+		 */
+		ret = pci_config_space_write_32(parent_sess,
+		    eecp + USBLEGCTLSTS_OFFSET, 0xe0000000);
+		CHECK_RET_HANGUP_RETURN(ret, "Failed(%d) zero USBLEGCTLSTS.\n", ret);
+		udelay(10);
+		ret = pci_config_space_read_32(parent_sess,
+		    eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts);
+		CHECK_RET_HANGUP_RETURN(ret, "Failed to get USBLEGCTLSTS 2: %s.\n",
+		    str_error(ret));
+		usb_log_debug("Zeroed USBLEGCTLSTS: %" PRIx32 ".\n",
+		    usblegctlsts);
+	}
+
+	/* Read again Legacy Support register */
+	ret = pci_config_space_read_32(parent_sess,
+	    eecp + USBLEGSUP_OFFSET, &usblegsup);
+	CHECK_RET_HANGUP_RETURN(ret, "Failed to read USBLEGSUP: %s.\n",
+	    str_error(ret));
+	usb_log_debug("USBLEGSUP: %" PRIx32 ".\n", usblegsup);
+	async_hangup(parent_sess);
+	return EOK;
+#undef CHECK_RET_HANGUP_RETURN
+}
+
+int disable_legacy(const ddf_dev_t *device, uintptr_t reg_base, size_t reg_size)
+{
+	assert(device);
+	usb_log_debug("Disabling EHCI legacy support.\n");
+
+#define CHECK_RET_RETURN(ret, message...) \
+	if (ret != EOK) { \
+		usb_log_error(message); \
+		return ret; \
+	} else (void)0
+
+	/* Map EHCI registers */
+	void *regs = NULL;
+	int ret = pio_enable((void*)reg_base, reg_size, &regs);
+	CHECK_RET_RETURN(ret, "Failed to map registers %p: %s.\n",
+	    (void *) reg_base, str_error(ret));
+
+	usb_log_debug2("Registers mapped at: %p.\n", regs);
+
+	const uint32_t hcc_params =
+	    *(uint32_t*)(regs + HCC_PARAMS_OFFSET);
+	usb_log_debug("Value of hcc params register: %x.\n", hcc_params);
+
+	/* Read value of EHCI Extended Capabilities Pointer
+	 * position of EEC registers (points to PCI config space) */
+	const uint32_t eecp =
+	    (hcc_params >> HCC_PARAMS_EECP_OFFSET) & HCC_PARAMS_EECP_MASK;
+	usb_log_debug("Value of EECP: %x.\n", eecp);
+
+	ret = disable_extended_caps(device, eecp);
+	CHECK_RET_RETURN(ret, "Failed to disable extended capabilities: %s.\n",
+	    str_error(ret));
+
+#undef CHECK_RET_RETURN
+
+	/*
+	 * TURN OFF EHCI FOR NOW, DRIVER WILL REINITIALIZE IT IF NEEDED
+	 */
+
+	/* Get size of capability registers in memory space. */
+	const unsigned operation_offset = *(uint8_t*)regs;
+	usb_log_debug("USBCMD offset: %d.\n", operation_offset);
+
+	/* Zero USBCMD register. */
+	volatile uint32_t *usbcmd =
+	    (uint32_t*)((uint8_t*)regs + operation_offset + CMD_OFFSET);
+	volatile uint32_t *usbsts =
+	    (uint32_t*)((uint8_t*)regs + operation_offset + STS_OFFSET);
+	volatile uint32_t *usbconf =
+	    (uint32_t*)((uint8_t*)regs + operation_offset + CFG_OFFSET);
+	volatile uint32_t *usbint =
+	    (uint32_t*)((uint8_t*)regs + operation_offset + INT_OFFSET);
+	usb_log_debug("USBCMD value: %x.\n", *usbcmd);
+	if (*usbcmd & USBCMD_RUN) {
+		*usbsts = 0x3f; /* ack all interrupts */
+		*usbint = 0; /* disable all interrupts */
+		*usbconf = 0; /* release control of RH ports */
+
+		*usbcmd = 0;
+		/* Wait until hc is halted */
+		while ((*usbsts & USBSTS_HALTED) == 0);
+		usb_log_info("EHCI turned off.\n");
+	} else {
+		usb_log_info("EHCI was not running.\n");
+	}
+	usb_log_debug("Registers: \n"
+	    "\t USBCMD(%p): %x(0x00080000 = at least 1ms between interrupts)\n"
+	    "\t USBSTS(%p): %x(0x00001000 = HC halted)\n"
+	    "\t USBINT(%p): %x(0x0 = no interrupts).\n"
+	    "\t CONFIG(%p): %x(0x0 = ports controlled by companion hc).\n",
+	    usbcmd, *usbcmd, usbsts, *usbsts, usbint, *usbint, usbconf,*usbconf);
+
+	return ret;
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/ehci/res.h
===================================================================
--- uspace/drv/bus/usb/ehci/res.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/drv/bus/usb/ehci/res.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011 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 drvusbehci
+ * @{
+ */
+/** @file
+ * PCI related functions needed by EHCI driver.
+ */
+#ifndef DRV_EHCI_PCI_H
+#define DRV_EHCI_PCI_H
+
+#include <ddf/driver.h>
+
+int get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
+int enable_interrupts(const ddf_dev_t *);
+int disable_legacy(const ddf_dev_t *, uintptr_t, size_t);
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/bus/usb/ohci/Makefile
===================================================================
--- uspace/drv/bus/usb/ohci/Makefile	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/ohci/Makefile	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -50,5 +50,5 @@
 	ohci_batch.c \
 	ohci_endpoint.c \
-	pci.c \
+	res.c \
 	root_hub.c \
 	hw_struct/endpoint_descriptor.c \
Index: uspace/drv/bus/usb/ohci/hc.c
===================================================================
--- uspace/drv/bus/usb/ohci/hc.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/ohci/hc.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -47,10 +47,16 @@
     (I_SO | I_WDH | I_UE | I_RHSC)
 
-static const irq_cmd_t ohci_irq_commands[] =
-{
-	{ .cmd = CMD_MEM_READ_32, .dstarg = 1, .addr = NULL /*filled later*/ },
+static const irq_pio_range_t ohci_pio_ranges[] = {
+	{
+		.base = 0,	/* filled later */
+		.size = sizeof(ohci_regs_t)
+	}
+};
+
+static const irq_cmd_t ohci_irq_commands[] = {
+	{ .cmd = CMD_PIO_READ_32, .dstarg = 1, .addr = NULL /* filled later */ },
 	{ .cmd = CMD_BTEST, .srcarg = 1, .dstarg = 2, .value = OHCI_USED_INTERRUPTS },
 	{ .cmd = CMD_PREDICATE, .srcarg = 2, .value = 2 },
-	{ .cmd = CMD_MEM_WRITE_A_32, .srcarg = 1, .addr = NULL /*filled later*/ },
+	{ .cmd = CMD_PIO_WRITE_A_32, .srcarg = 1, .addr = NULL /* filled later */ },
 	{ .cmd = CMD_ACCEPT },
 };
@@ -63,4 +69,13 @@
 static int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
 /*----------------------------------------------------------------------------*/
+/** Get number of PIO ranges used in IRQ code.
+ * @return Number of ranges.
+ */
+size_t hc_irq_pio_range_count(void)
+{
+	return sizeof(ohci_pio_ranges) / sizeof(irq_pio_range_t);
+}
+/*----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------*/
 /** Get number of commands used in IRQ code.
  * @return Number of commands.
@@ -71,7 +86,9 @@
 }
 /*----------------------------------------------------------------------------*/
-/** Generate IRQ code commands.
- * @param[out] cmds Place to store the commands.
- * @param[in] cmd_size Size of the place (bytes).
+/** Generate IRQ code.
+ * @param[out] ranges PIO ranges buffer.
+ * @param[in] ranges_size Size of the ranges buffer (bytes).
+ * @param[out] cmds Commands buffer.
+ * @param[in] cmds_size Size of the commands buffer (bytes).
  * @param[in] regs Physical address of device's registers.
  * @param[in] reg_size Size of the register area (bytes).
@@ -79,38 +96,21 @@
  * @return Error code.
  */
-int hc_get_irq_commands(
-    irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size)
-{
-	if (cmd_size < sizeof(ohci_irq_commands)
-	    || reg_size < sizeof(ohci_regs_t))
+int
+hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[],
+    size_t cmds_size, uintptr_t regs, size_t reg_size)
+{
+	if ((ranges_size < sizeof(ohci_pio_ranges)) ||
+	    (cmds_size < sizeof(ohci_irq_commands)) ||
+	    (reg_size < sizeof(ohci_regs_t)))
 		return EOVERFLOW;
 
-	/* Create register mapping to use in IRQ handler.
-	 * This mapping should be present in kernel only.
-	 * Remove it from here when kernel knows how to create mappings
-	 * and accepts physical addresses in IRQ code.
-	 * TODO: remove */
-	ohci_regs_t *registers;
-	const int ret = pio_enable((void*)regs, reg_size, (void**)&registers);
-	if (ret != EOK)
-		return ret;
-
-	/* Some bogus access to force create mapping. DO NOT remove,
-	 * unless whole virtual addresses in irq is replaced
-	 * NOTE: Compiler won't remove this as ohci_regs_t members
-	 * are declared volatile.
-	 *
-	 * Introducing CMD_MEM set of IRQ code commands broke
-	 * assumption that IRQ code does not cause page faults.
-	 * If this happens during idling (THREAD == NULL)
-	 * it causes kernel panic.
-	 */
-	registers->revision;
+	memcpy(ranges, ohci_pio_ranges, sizeof(ohci_pio_ranges));
+	ranges[0].base = regs;
 
 	memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands));
-
-	void *address = (void*)&registers->interrupt_status;
-	cmds[0].addr = address;
-	cmds[3].addr = address;
+	ohci_regs_t *registers = (ohci_regs_t *) regs;
+	cmds[0].addr = (void *) &registers->interrupt_status;
+	cmds[3].addr = (void *) &registers->interrupt_status;
+
 	return EOK;
 }
Index: uspace/drv/bus/usb/ohci/hc.h
===================================================================
--- uspace/drv/bus/usb/ohci/hc.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/ohci/hc.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -74,7 +74,8 @@
 } hc_t;
 
+size_t hc_irq_pio_range_count(void);
 size_t hc_irq_cmd_count(void);
-int hc_get_irq_commands(
-    irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size);
+int hc_get_irq_code(irq_pio_range_t [], size_t, irq_cmd_t [], size_t, uintptr_t,
+    size_t);
 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);
 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts);
Index: uspace/drv/bus/usb/ohci/hw_struct/hcca.h
===================================================================
--- uspace/drv/bus/usb/ohci/hw_struct/hcca.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/ohci/hw_struct/hcca.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -46,6 +46,6 @@
 	uint16_t pad1;
 	uint32_t done_head;
-	uint32_t reserved[29];
-} __attribute__((packed, aligned)) hcca_t;
+	uint32_t reserved[30];
+} hcca_t;
 
 static inline void * hcca_get(void)
Index: uspace/drv/bus/usb/ohci/ohci.c
===================================================================
--- uspace/drv/bus/usb/ohci/ohci.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/ohci/ohci.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -42,5 +42,5 @@
 
 #include "ohci.h"
-#include "pci.h"
+#include "res.h"
 #include "hc.h"
 
@@ -180,5 +180,5 @@
 	int irq = 0;
 
-	ret = pci_get_my_registers(device, &reg_base, &reg_size, &irq);
+	ret = get_my_registers(device, &reg_base, &reg_size, &irq);
 	CHECK_RET_DEST_FREE_RETURN(ret,
 	    "Failed to get register memory addresses for %" PRIun ": %s.\n",
@@ -187,12 +187,19 @@
 	    (void *) reg_base, reg_size, irq);
 
-	const size_t cmd_count = hc_irq_cmd_count();
-	irq_cmd_t irq_cmds[cmd_count];
-	irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = irq_cmds };
-
-	ret =
-	    hc_get_irq_commands(irq_cmds, sizeof(irq_cmds), reg_base, reg_size);
-	CHECK_RET_DEST_FREE_RETURN(ret,
-	    "Failed to generate IRQ commands: %s.\n", str_error(ret));
+	const size_t ranges_count = hc_irq_pio_range_count();
+	const size_t cmds_count = hc_irq_cmd_count();
+	irq_pio_range_t irq_ranges[ranges_count];
+	irq_cmd_t irq_cmds[cmds_count];
+	irq_code_t irq_code = {
+		.rangecount = ranges_count,
+		.ranges = irq_ranges,
+		.cmdcount = cmds_count,
+		.cmds = irq_cmds
+	};
+
+	ret = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds,
+	    sizeof(irq_cmds), reg_base, reg_size);
+	CHECK_RET_DEST_FREE_RETURN(ret,
+	    "Failed to generate IRQ code: %s.\n", str_error(ret));
 
 
@@ -204,5 +211,5 @@
 	/* Try to enable interrupts */
 	bool interrupts = false;
-	ret = pci_enable_interrupts(device);
+	ret = enable_interrupts(device);
 	if (ret != EOK) {
 		usb_log_warning("Failed to enable interrupts: %s."
Index: pace/drv/bus/usb/ohci/pci.c
===================================================================
--- uspace/drv/bus/usb/ohci/pci.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,116 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * 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 drvusbohci
- * @{
- */
-/**
- * @file
- * PCI related functions needed by the OHCI driver.
- */
-
-#include <errno.h>
-#include <assert.h>
-#include <as.h>
-#include <devman.h>
-#include <ddi.h>
-#include <libarch/ddi.h>
-#include <device/hw_res_parsed.h>
-
-#include <usb/debug.h>
-#include <pci_dev_iface.h>
-
-#include "pci.h"
-
-/** Get address of registers and IRQ for given device.
- *
- * @param[in] dev Device asking for the addresses.
- * @param[out] mem_reg_address Base address of the memory range.
- * @param[out] mem_reg_size Size of the memory range.
- * @param[out] irq_no IRQ assigned to the device.
- * @return Error code.
- */
-int pci_get_my_registers(ddf_dev_t *dev,
-    uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no)
-{
-	assert(dev);
-
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
-	    IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-
-	hw_res_list_parsed_t hw_res;
-	hw_res_list_parsed_init(&hw_res);
-	const int ret =  hw_res_get_list_parsed(parent_sess, &hw_res, 0);
-	async_hangup(parent_sess);
-	if (ret != EOK) {
-		return ret;
-	}
-
-	/* We want one irq and one mem range. */
-	if (hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
-		hw_res_list_parsed_clean(&hw_res);
-		return EINVAL;
-	}
-
-	if (mem_reg_address)
-		*mem_reg_address = hw_res.mem_ranges.ranges[0].address;
-	if (mem_reg_size)
-		*mem_reg_size = hw_res.mem_ranges.ranges[0].size;
-	if (irq_no)
-		*irq_no = hw_res.irqs.irqs[0];
-
-	hw_res_list_parsed_clean(&hw_res);
-	return EOK;
-}
-
-/** Call the PCI driver with a request to enable interrupts
- *
- * @param[in] device Device asking for interrupts
- * @return Error code.
- */
-int pci_enable_interrupts(ddf_dev_t *device)
-{
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
-	    IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-	
-	bool enabled = hw_res_enable_interrupt(parent_sess);
-	async_hangup(parent_sess);
-	
-	return enabled ? EOK : EIO;
-}
-
-/**
- * @}
- */
Index: pace/drv/bus/usb/ohci/pci.h
===================================================================
--- uspace/drv/bus/usb/ohci/pci.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * Copyright (c) 2011 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 drvusbohci
- * @{
- */
-/** @file
- * PCI related functions needed by OHCI driver.
- */
-#ifndef DRV_OHCI_PCI_H
-#define DRV_OHCI_PCI_H
-
-#include <ddf/driver.h>
-
-int pci_get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *);
-int pci_enable_interrupts(ddf_dev_t *);
-int pci_disable_legacy(ddf_dev_t *);
-
-#endif
-/**
- * @}
- */
-
Index: uspace/drv/bus/usb/ohci/res.c
===================================================================
--- uspace/drv/bus/usb/ohci/res.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/drv/bus/usb/ohci/res.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * 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 drvusbohci
+ * @{
+ */
+/**
+ * @file
+ * PCI related functions needed by the OHCI driver.
+ */
+
+#include <errno.h>
+#include <assert.h>
+#include <devman.h>
+#include <device/hw_res_parsed.h>
+
+#include <usb/debug.h>
+
+#include "res.h"
+
+/** Get address of registers and IRQ for given device.
+ *
+ * @param[in] dev Device asking for the addresses.
+ * @param[out] mem_reg_address Base address of the memory range.
+ * @param[out] mem_reg_size Size of the memory range.
+ * @param[out] irq_no IRQ assigned to the device.
+ * @return Error code.
+ */
+int get_my_registers(const ddf_dev_t *dev,
+    uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no)
+{
+	assert(dev);
+
+	async_sess_t *parent_sess =
+	    devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
+	    IPC_FLAG_BLOCKING);
+	if (!parent_sess)
+		return ENOMEM;
+
+	hw_res_list_parsed_t hw_res;
+	hw_res_list_parsed_init(&hw_res);
+	const int ret =  hw_res_get_list_parsed(parent_sess, &hw_res, 0);
+	async_hangup(parent_sess);
+	if (ret != EOK) {
+		return ret;
+	}
+
+	/* We want one irq and one mem range. */
+	if (hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
+		hw_res_list_parsed_clean(&hw_res);
+		return EINVAL;
+	}
+
+	if (mem_reg_address)
+		*mem_reg_address = hw_res.mem_ranges.ranges[0].address;
+	if (mem_reg_size)
+		*mem_reg_size = hw_res.mem_ranges.ranges[0].size;
+	if (irq_no)
+		*irq_no = hw_res.irqs.irqs[0];
+
+	hw_res_list_parsed_clean(&hw_res);
+	return EOK;
+}
+
+/** Call the PCI driver with a request to enable interrupts
+ *
+ * @param[in] device Device asking for interrupts
+ * @return Error code.
+ */
+int enable_interrupts(const ddf_dev_t *device)
+{
+	async_sess_t *parent_sess =
+	    devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
+	    IPC_FLAG_BLOCKING);
+	if (!parent_sess)
+		return ENOMEM;
+	
+	const bool enabled = hw_res_enable_interrupt(parent_sess);
+	async_hangup(parent_sess);
+	
+	return enabled ? EOK : EIO;
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/ohci/res.h
===================================================================
--- uspace/drv/bus/usb/ohci/res.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/drv/bus/usb/ohci/res.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 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 drvusbohci
+ * @{
+ */
+/** @file
+ * PCI related functions needed by OHCI driver.
+ */
+#ifndef DRV_OHCI_RES_H
+#define DRV_OHCI_RES_H
+
+#include <ddf/driver.h>
+
+int get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
+int enable_interrupts(const ddf_dev_t *);
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/bus/usb/uhci/Makefile
===================================================================
--- uspace/drv/bus/usb/uhci/Makefile	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/uhci/Makefile	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -44,5 +44,5 @@
 	hc.c \
 	main.c \
-	pci.c \
+	res.c \
 	root_hub.c \
 	transfer_list.c \
Index: uspace/drv/bus/usb/uhci/hc.c
===================================================================
--- uspace/drv/bus/usb/uhci/hc.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/uhci/hc.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -48,7 +48,12 @@
     (UHCI_STATUS_INTERRUPT | UHCI_STATUS_ERROR_INTERRUPT)
 
-
-static const irq_cmd_t uhci_irq_commands[] =
-{
+static const irq_pio_range_t uhci_irq_pio_ranges[] = {
+	{
+		.base = 0,	/* filled later */
+		.size = sizeof(uhci_regs_t)
+	}
+};
+
+static const irq_cmd_t uhci_irq_commands[] = {
 	{ .cmd = CMD_PIO_READ_16, .dstarg = 1, .addr = NULL/*filled later*/},
 	{ .cmd = CMD_BTEST, .srcarg = 1, .dstarg = 2,
@@ -68,4 +73,12 @@
 
 /*----------------------------------------------------------------------------*/
+/** Get number of PIO ranges used in IRQ code.
+ * @return Number of ranges.
+ */
+size_t hc_irq_pio_range_count(void)
+{
+	return sizeof(uhci_irq_pio_ranges) / sizeof(irq_pio_range_t);
+}
+/*----------------------------------------------------------------------------*/
 /** Get number of commands used in IRQ code.
  * @return Number of commands.
@@ -76,7 +89,9 @@
 }
 /*----------------------------------------------------------------------------*/
-/** Generate IRQ code commands.
- * @param[out] cmds Place to store the commands.
- * @param[in] cmd_size Size of the place (bytes).
+/** Generate IRQ code.
+ * @param[out] ranges PIO ranges buffer.
+ * @param[in] ranges_size Size of the ranges buffer (bytes).
+ * @param[out] cmds Commands buffer.
+ * @param[in] cmds_size Size of the commands buffer (bytes).
  * @param[in] regs Physical address of device's registers.
  * @param[in] reg_size Size of the register area (bytes).
@@ -84,17 +99,21 @@
  * @return Error code.
  */
-int hc_get_irq_commands(
-    irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size)
-{
-	if (cmd_size < sizeof(uhci_irq_commands)
-	    || reg_size < sizeof(uhci_regs_t))
+int
+hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[],
+    size_t cmds_size, uintptr_t regs, size_t reg_size)
+{
+	if ((ranges_size < sizeof(uhci_irq_pio_ranges)) ||
+	    (cmds_size < sizeof(uhci_irq_commands)) ||
+	    (reg_size < sizeof(uhci_regs_t)))
 		return EOVERFLOW;
 
-	uhci_regs_t *registers = (uhci_regs_t*)regs;
+	memcpy(ranges, uhci_irq_pio_ranges, sizeof(uhci_irq_pio_ranges));
+	ranges[0].base = regs;
 
 	memcpy(cmds, uhci_irq_commands, sizeof(uhci_irq_commands));
-
-	cmds[0].addr = (void*)&registers->usbsts;
-	cmds[3].addr = (void*)&registers->usbsts;
+	uhci_regs_t *registers = (uhci_regs_t *) regs;
+	cmds[0].addr = &registers->usbsts;
+	cmds[3].addr = &registers->usbsts;
+
 	return EOK;
 }
Index: uspace/drv/bus/usb/uhci/hc.h
===================================================================
--- uspace/drv/bus/usb/uhci/hc.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/uhci/hc.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -121,7 +121,8 @@
 } hc_t;
 
+size_t hc_irq_pio_range_count(void);
 size_t hc_irq_cmd_count(void);
-int hc_get_irq_commands(
-    irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size);
+int hc_get_irq_code(irq_pio_range_t [], size_t, irq_cmd_t [], size_t, uintptr_t,
+    size_t);
 void hc_interrupt(hc_t *instance, uint16_t status);
 int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interupts);
Index: pace/drv/bus/usb/uhci/pci.c
===================================================================
--- uspace/drv/bus/usb/uhci/pci.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,146 +1,0 @@
-/*
- * Copyright (c) 2011 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 drvusbuhcihc
- * @{
- */
-/**
- * @file
- * PCI related functions needed by the UHCI driver.
- */
-
-#include <errno.h>
-#include <assert.h>
-#include <devman.h>
-#include <device/hw_res_parsed.h>
-
-#include <usb/debug.h>
-#include <pci_dev_iface.h>
-
-#include "pci.h"
-
-/** Get I/O address of registers and IRQ for given device.
- *
- * @param[in] dev Device asking for the addresses.
- * @param[out] io_reg_address Base address of the I/O range.
- * @param[out] io_reg_size Size of the I/O range.
- * @param[out] irq_no IRQ assigned to the device.
- * @return Error code.
- */
-int pci_get_my_registers(const ddf_dev_t *dev,
-    uintptr_t *io_reg_address, size_t *io_reg_size, int *irq_no)
-{
-	assert(dev);
-	assert(io_reg_address);
-	assert(io_reg_size);
-	assert(irq_no);
-
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
-	    IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-
-	hw_res_list_parsed_t hw_res;
-	hw_res_list_parsed_init(&hw_res);
-	const int ret =  hw_res_get_list_parsed(parent_sess, &hw_res, 0);
-	async_hangup(parent_sess);
-	if (ret != EOK) {
-		return ret;
-	}
-
-	/* We want one irq and one io range. */
-	if (hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) {
-		hw_res_list_parsed_clean(&hw_res);
-		return EINVAL;
-	}
-
-	if (io_reg_address)
-		*io_reg_address = hw_res.io_ranges.ranges[0].address;
-	if (io_reg_size)
-		*io_reg_size = hw_res.io_ranges.ranges[0].size;
-	if (irq_no)
-		*irq_no = hw_res.irqs.irqs[0];
-
-	hw_res_list_parsed_clean(&hw_res);
-	return EOK;
-}
-/*----------------------------------------------------------------------------*/
-/** Call the PCI driver with a request to enable interrupts
- *
- * @param[in] device Device asking for interrupts
- * @return Error code.
- */
-int pci_enable_interrupts(const ddf_dev_t *device)
-{
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
-	    IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-
-	const bool enabled = hw_res_enable_interrupt(parent_sess);
-	async_hangup(parent_sess);
-
-	return enabled ? EOK : EIO;
-}
-/*----------------------------------------------------------------------------*/
-/** Call the PCI driver with a request to clear legacy support register
- *
- * @param[in] device Device asking to disable interrupts
- * @return Error code.
- */
-int pci_disable_legacy(const ddf_dev_t *device)
-{
-	assert(device);
-
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
-	    IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-
-	/* See UHCI design guide for these values p.45,
-	 * write all WC bits in USB legacy register */
-	const sysarg_t address = 0xc0;
-	const sysarg_t value = 0xaf00;
-
-	async_exch_t *exch = async_exchange_begin(parent_sess);
-
-	const int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
-	    IPC_M_CONFIG_SPACE_WRITE_16, address, value);
-
-	async_exchange_end(exch);
-	async_hangup(parent_sess);
-
-	return rc;
-}
-
-/**
- * @}
- */
Index: pace/drv/bus/usb/uhci/pci.h
===================================================================
--- uspace/drv/bus/usb/uhci/pci.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2010 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 drvusbuhcihc
- * @{
- */
-/** @file
- * @brief UHCI driver PCI helper functions
- */
-#ifndef DRV_UHCI_PCI_H
-#define DRV_UHCI_PCI_H
-
-#include <ddf/driver.h>
-
-int pci_get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
-int pci_enable_interrupts(const ddf_dev_t *);
-int pci_disable_legacy(const ddf_dev_t *);
-
-#endif
-/**
- * @}
- */
-
Index: uspace/drv/bus/usb/uhci/res.c
===================================================================
--- uspace/drv/bus/usb/uhci/res.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/drv/bus/usb/uhci/res.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2011 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 drvusbuhcihc
+ * @{
+ */
+/**
+ * @file
+ * PCI related functions needed by the UHCI driver.
+ */
+
+#include <errno.h>
+#include <assert.h>
+#include <devman.h>
+#include <device/hw_res_parsed.h>
+#include <device/pci.h>
+
+#include "res.h"
+
+/** Get I/O address of registers and IRQ for given device.
+ *
+ * @param[in] dev Device asking for the addresses.
+ * @param[out] io_reg_address Base address of the I/O range.
+ * @param[out] io_reg_size Size of the I/O range.
+ * @param[out] irq_no IRQ assigned to the device.
+ * @return Error code.
+ */
+int get_my_registers(const ddf_dev_t *dev,
+    uintptr_t *io_reg_address, size_t *io_reg_size, int *irq_no)
+{
+	assert(dev);
+
+	async_sess_t *parent_sess =
+	    devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
+	    IPC_FLAG_BLOCKING);
+	if (!parent_sess)
+		return ENOMEM;
+
+	hw_res_list_parsed_t hw_res;
+	hw_res_list_parsed_init(&hw_res);
+	const int ret =  hw_res_get_list_parsed(parent_sess, &hw_res, 0);
+	async_hangup(parent_sess);
+	if (ret != EOK) {
+		return ret;
+	}
+
+	/* We want one irq and one io range. */
+	if (hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) {
+		hw_res_list_parsed_clean(&hw_res);
+		return EINVAL;
+	}
+
+	if (io_reg_address)
+		*io_reg_address = hw_res.io_ranges.ranges[0].address;
+	if (io_reg_size)
+		*io_reg_size = hw_res.io_ranges.ranges[0].size;
+	if (irq_no)
+		*irq_no = hw_res.irqs.irqs[0];
+
+	hw_res_list_parsed_clean(&hw_res);
+	return EOK;
+}
+/*----------------------------------------------------------------------------*/
+/** Call the PCI driver with a request to enable interrupts
+ *
+ * @param[in] device Device asking for interrupts
+ * @return Error code.
+ */
+int enable_interrupts(const ddf_dev_t *device)
+{
+	async_sess_t *parent_sess =
+	    devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
+	    IPC_FLAG_BLOCKING);
+	if (!parent_sess)
+		return ENOMEM;
+
+	const bool enabled = hw_res_enable_interrupt(parent_sess);
+	async_hangup(parent_sess);
+
+	return enabled ? EOK : EIO;
+}
+/*----------------------------------------------------------------------------*/
+/** Call the PCI driver with a request to clear legacy support register
+ *
+ * @param[in] device Device asking to disable interrupts
+ * @return Error code.
+ */
+int disable_legacy(const ddf_dev_t *device)
+{
+	assert(device);
+
+	async_sess_t *parent_sess = devman_parent_device_connect(
+	    EXCHANGE_SERIALIZE, device->handle, IPC_FLAG_BLOCKING);
+	if (!parent_sess)
+		return ENOMEM;
+
+	/* See UHCI design guide page 45 for these values.
+	 * Write all WC bits in USB legacy register */
+	const int rc = pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
+
+	async_hangup(parent_sess);
+	return rc;
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/uhci/res.h
===================================================================
--- uspace/drv/bus/usb/uhci/res.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/drv/bus/usb/uhci/res.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2010 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 drvusbuhcihc
+ * @{
+ */
+/** @file
+ * @brief UHCI driver PCI helper functions
+ */
+#ifndef DRV_UHCI_PCI_H
+#define DRV_UHCI_PCI_H
+
+#include <ddf/driver.h>
+
+int get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
+int enable_interrupts(const ddf_dev_t *);
+int disable_legacy(const ddf_dev_t *);
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/bus/usb/uhci/transfer_list.c
===================================================================
--- uspace/drv/bus/usb/uhci/transfer_list.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/uhci/transfer_list.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -110,6 +110,6 @@
 	assert(instance);
 	assert(uhci_batch);
-	usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name,
-	    uhci_batch->usb_batch);
+	usb_log_debug2("Batch %p adding to queue %s.\n",
+	    uhci_batch->usb_batch, instance->name);
 
 	fibril_mutex_lock(&instance->guard);
@@ -139,7 +139,7 @@
 	list_append(&uhci_batch->link, &instance->batch_list);
 
-	usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " scheduled in queue %s.\n",
-	    uhci_batch, USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch),
-	    instance->name);
+	usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT
+	    " scheduled in queue %s.\n", uhci_batch->usb_batch,
+	    USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch), instance->name);
 	fibril_mutex_unlock(&instance->guard);
 }
@@ -205,6 +205,6 @@
 	assert(fibril_mutex_is_locked(&instance->guard));
 
-	usb_log_debug2("Queue %s: removing batch(%p).\n",
-	    instance->name, uhci_batch->usb_batch);
+	usb_log_debug2("Batch %p removing from queue %s.\n",
+	    uhci_batch->usb_batch, instance->name);
 
 	/* Assume I'm the first */
@@ -228,6 +228,6 @@
 	list_remove(&uhci_batch->link);
 	usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " removed (%s) "
-	    "from %s, next: %x.\n",
-	    uhci_batch, USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch),
+	    "from %s, next: %x.\n", uhci_batch->usb_batch,
+	    USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch),
 	    qpos, instance->name, uhci_batch->qh->next);
 }
Index: uspace/drv/bus/usb/uhci/uhci.c
===================================================================
--- uspace/drv/bus/usb/uhci/uhci.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/uhci/uhci.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -41,6 +41,6 @@
 
 #include "uhci.h"
-#include "pci.h"
-
+
+#include "res.h"
 #include "hc.h"
 #include "root_hub.h"
@@ -49,12 +49,12 @@
  * and USB root hub */
 typedef struct uhci {
-	/** Pointer to DDF represenation of UHCI host controller */
+	/** Pointer to DDF representation of UHCI host controller */
 	ddf_fun_t *hc_fun;
-	/** Pointer to DDF represenation of UHCI root hub */
+	/** Pointer to DDF representation of UHCI root hub */
 	ddf_fun_t *rh_fun;
 
-	/** Internal driver's represenation of UHCI host controller */
+	/** Internal driver's representation of UHCI host controller */
 	hc_t hc;
-	/** Internal driver's represenation of UHCI root hub */
+	/** Internal driver's representation of UHCI root hub */
 	rh_t rh;
 } uhci_t;
@@ -187,5 +187,5 @@
 	int irq = 0;
 
-	ret = pci_get_my_registers(device, &reg_base, &reg_size, &irq);
+	ret = get_my_registers(device, &reg_base, &reg_size, &irq);
 	CHECK_RET_DEST_FREE_RETURN(ret,
 	    "Failed to get I/O addresses for %" PRIun ": %s.\n",
@@ -194,16 +194,23 @@
 	    (void *) reg_base, reg_size, irq);
 
-	ret = pci_disable_legacy(device);
+	ret = disable_legacy(device);
 	CHECK_RET_DEST_FREE_RETURN(ret,
 	    "Failed to disable legacy USB: %s.\n", str_error(ret));
 
-	const size_t cmd_count = hc_irq_cmd_count();
-	irq_cmd_t irq_cmds[cmd_count];
-	ret =
-	    hc_get_irq_commands(irq_cmds, sizeof(irq_cmds), reg_base, reg_size);
+	const size_t ranges_count = hc_irq_pio_range_count();
+	const size_t cmds_count = hc_irq_cmd_count();
+	irq_pio_range_t irq_ranges[ranges_count];
+	irq_cmd_t irq_cmds[cmds_count];
+	ret = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds,
+	    sizeof(irq_cmds), reg_base, reg_size);
 	CHECK_RET_DEST_FREE_RETURN(ret,
 	    "Failed to generate IRQ commands: %s.\n", str_error(ret));
 
-	irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = irq_cmds };
+	irq_code_t irq_code = {
+		.rangecount = ranges_count,
+		.ranges = irq_ranges,
+		.cmdcount = cmds_count,
+		.cmds = irq_cmds
+	};
 
         /* Register handler to avoid interrupt lockup */
@@ -213,5 +220,5 @@
 
 	bool interrupts = false;
-	ret = pci_enable_interrupts(device);
+	ret = enable_interrupts(device);
 	if (ret != EOK) {
 		usb_log_warning("Failed to enable interrupts: %s."
Index: uspace/drv/bus/usb/uhci/uhci_batch.c
===================================================================
--- uspace/drv/bus/usb/uhci/uhci_batch.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/uhci/uhci_batch.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -174,7 +174,7 @@
 			assert(uhci_batch->usb_batch->ep != NULL);
 
-			usb_log_debug("Batch(%p) found error TD(%zu):%"
+			usb_log_debug("Batch %p found error TD(%zu->%p):%"
 			    PRIx32 ".\n", uhci_batch->usb_batch, i,
-			    uhci_batch->tds[i].status);
+			    &uhci_batch->tds[i], uhci_batch->tds[i].status);
 			td_print_status(&uhci_batch->tds[i]);
 
Index: uspace/drv/bus/usb/uhcirh/port.c
===================================================================
--- uspace/drv/bus/usb/uhcirh/port.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/uhcirh/port.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -37,5 +37,4 @@
 #include <str_error.h>
 #include <async.h>
-#include <devman.h>
 
 #include <usb/usb.h>    /* usb_address_t */
Index: uspace/drv/bus/usb/usbhub/port.c
===================================================================
--- uspace/drv/bus/usb/usbhub/port.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/bus/usb/usbhub/port.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -35,5 +35,4 @@
 
 #include <bool.h>
-#include <devman.h>
 #include <errno.h>
 #include <str_error.h>
Index: uspace/drv/char/i8042/i8042.c
===================================================================
--- uspace/drv/char/i8042/i8042.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/char/i8042/i8042.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -105,4 +105,11 @@
 };
 
+static const irq_pio_range_t i8042_ranges[] = {
+	{
+		.base = 0,
+		.size = sizeof(i8042_regs_t)
+	}
+};
+
 /** i8042 Interrupt pseudo-code. */
 static const irq_cmd_t i8042_cmds[] = {
@@ -239,12 +246,20 @@
 	while (pio_read_8(&dev->regs->status) & i8042_OUTPUT_FULL)
 		(void) pio_read_8(&dev->regs->data);
-	
+
+	const size_t range_count = sizeof(i8042_ranges) /
+	    sizeof(irq_pio_range_t);
+	irq_pio_range_t ranges[range_count];
+	memcpy(ranges, i8042_ranges, sizeof(i8042_ranges));
+	ranges[0].base = (uintptr_t) regs;
+
 	const size_t cmd_count = sizeof(i8042_cmds) / sizeof(irq_cmd_t);
 	irq_cmd_t cmds[cmd_count];
 	memcpy(cmds, i8042_cmds, sizeof(i8042_cmds));
-	cmds[0].addr = (void *) &dev->regs->status;
-	cmds[3].addr = (void *) &dev->regs->data;
-	
+	cmds[0].addr = (void *) &(((i8042_regs_t *) regs)->status);
+	cmds[3].addr = (void *) &(((i8042_regs_t *) regs)->data);
+
 	irq_code_t irq_code = {
+		.rangecount = range_count,
+		.ranges = ranges,
 		.cmdcount = cmd_count,
 		.cmds = cmds
Index: uspace/drv/char/ns8250/ns8250.c
===================================================================
--- uspace/drv/char/ns8250/ns8250.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/char/ns8250/ns8250.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -74,4 +74,56 @@
 #define DLAB_MASK (1 << 7)
 
+/** Interrupt Enable Register definition. */
+#define	NS8250_IER_RXREADY	(1 << 0)
+#define	NS8250_IER_THRE		(1 << 1)
+#define	NS8250_IER_RXSTATUS	(1 << 2)
+#define	NS8250_IER_MODEM_STATUS	(1 << 3)
+
+/** Interrupt ID Register definition. */
+#define	NS8250_IID_ACTIVE	(1 << 0)
+
+/** FIFO Control Register definition. */
+#define	NS8250_FCR_FIFOENABLE	(1 << 0)
+#define	NS8250_FCR_RXFIFORESET	(1 << 1)
+#define	NS8250_FCR_TXFIFORESET	(1 << 2)
+#define	NS8250_FCR_DMAMODE	(1 << 3)
+#define	NS8250_FCR_RXTRIGGERLOW	(1 << 6)
+#define	NS8250_FCR_RXTRIGGERHI	(1 << 7)
+
+/** Line Control Register definition. */
+#define	NS8250_LCR_STOPBITS	(1 << 2)
+#define	NS8250_LCR_PARITY	(1 << 3)
+#define	NS8250_LCR_SENDBREAK	(1 << 6)
+#define	NS8250_LCR_DLAB		(1 << 7)
+
+/** Modem Control Register definition. */
+#define	NS8250_MCR_DTR		(1 << 0)
+#define	NS8250_MCR_RTS		(1 << 1)
+#define	NS8250_MCR_OUT1		(1 << 2)
+#define	NS8250_MCR_OUT2		(1 << 3)
+#define	NS8250_MCR_LOOPBACK	(1 << 4)
+#define	NS8250_MCR_ALL		(0x1f)
+
+/** Line Status Register definition. */
+#define	NS8250_LSR_RXREADY	(1 << 0)
+#define	NS8250_LSR_OE		(1 << 1)
+#define	NS8250_LSR_PE		(1 << 2)
+#define	NS8250_LSR_FE		(1 << 3)
+#define	NS8250_LSR_BREAK	(1 << 4)
+#define	NS8250_LSR_THRE		(1 << 5)
+#define	NS8250_LSR_TSE		(1 << 6)
+
+/** Modem Status Register definition. */
+#define	NS8250_MSR_DELTACTS	(1 << 0)
+#define	NS8250_MSR_DELTADSR	(1 << 1)
+#define	NS8250_MSR_RITRAILING	(1 << 2)
+#define	NS8250_MSR_DELTADCD	(1 << 3)
+#define	NS8250_MSR_CTS		(1 << 4)
+#define	NS8250_MSR_DSR		(1 << 5)
+#define	NS8250_MSR_RI		(1 << 6)
+#define	NS8250_MSR_DCD		(1 << 7)
+#define	NS8250_MSR_SIGNALS	(NS8250_MSR_CTS | NS8250_MSR_DSR \
+    | NS8250_MSR_RI | NS8250_MSR_DCD)
+
 /** Obtain soft-state structure from function node */
 #define NS8250(fnode) ((ns8250_t *) ((fnode)->dev->driver_data))
@@ -96,4 +148,15 @@
 } stop_bit_t;
 
+/** 8250 UART registers layout. */
+typedef struct {
+	ioport8_t data;		/**< Data register. */
+	ioport8_t ier;		/**< Interrupt Enable Reg. */
+	ioport8_t iid;		/**< Interrupt ID Reg. */
+	ioport8_t lcr;		/**< Line Control Reg. */
+	ioport8_t mcr;		/**< Modem Control Reg. */
+	ioport8_t lsr;		/**< Line Status Reg. */
+	ioport8_t msr;		/**< Modem Status Reg. */
+} ns8250_regs_t;
+
 /** The driver data for the serial port devices. */
 typedef struct ns8250 {
@@ -102,4 +165,6 @@
 	/** DDF function node */
 	ddf_fun_t *fun;
+	/** I/O registers **/
+	ns8250_regs_t *regs;
 	/** Is there any client conntected to the device? */
 	bool client_connected;
@@ -124,7 +189,7 @@
  *			otherwise.
  */
-static bool ns8250_received(ioport8_t *port)
-{
-	return (pio_read_8(port + 5) & 1) != 0;
+static bool ns8250_received(ns8250_regs_t *regs)
+{
+	return (pio_read_8(&regs->lsr) & NS8250_LSR_RXREADY) != 0;
 }
 
@@ -134,7 +199,7 @@
  * @return		The data read.
  */
-static uint8_t ns8250_read_8(ioport8_t *port)
-{
-	return pio_read_8(port);
+static uint8_t ns8250_read_8(ns8250_regs_t *regs)
+{
+	return pio_read_8(&regs->data);
 }
 
@@ -143,7 +208,7 @@
  * @param port		The base address of the serial port device's ports.
  */
-static bool is_transmit_empty(ioport8_t *port)
-{
-	return (pio_read_8(port + 5) & 0x20) != 0;
+static bool is_transmit_empty(ns8250_regs_t *regs)
+{
+	return (pio_read_8(&regs->lsr) & NS8250_LSR_THRE) != 0;
 }
 
@@ -153,10 +218,10 @@
  * @param c		The character to be written to the serial port device.
  */
-static void ns8250_write_8(ioport8_t *port, uint8_t c)
-{
-	while (!is_transmit_empty(port))
+static void ns8250_write_8(ns8250_regs_t *regs, uint8_t c)
+{
+	while (!is_transmit_empty(regs))
 		;
 	
-	pio_write_8(port, c);
+	pio_write_8(&regs->data, c);
 }
 
@@ -193,5 +258,5 @@
 {
 	fibril_mutex_lock(&ns->mutex);
-	ns8250_write_8(ns->port, c);
+	ns8250_write_8(ns->regs, c);
 	fibril_mutex_unlock(&ns->mutex);
 }
@@ -212,5 +277,5 @@
 		ns8250_putchar(ns, (uint8_t) buf[idx]);
 	
-	return 0;
+	return count;
 }
 
@@ -266,4 +331,6 @@
 		return false;
 	}
+
+	ns->regs = (ns8250_regs_t *)ns->port;
 	
 	return true;
@@ -279,19 +346,19 @@
 	ddf_msg(LVL_DEBUG, "ns8250_dev_probe %s", ns->dev->name);
 	
-	ioport8_t *port_addr = ns->port;
 	bool res = true;
 	uint8_t olddata;
 	
-	olddata = pio_read_8(port_addr + 4);
-	
-	pio_write_8(port_addr + 4, 0x10);
-	if (pio_read_8(port_addr + 6) & 0xf0)
+	olddata = pio_read_8(&ns->regs->mcr);
+	
+	pio_write_8(&ns->regs->mcr, NS8250_MCR_LOOPBACK);
+	if (pio_read_8(&ns->regs->msr) & NS8250_MSR_SIGNALS)
 		res = false;
 	
-	pio_write_8(port_addr + 4, 0x1f);
-	if ((pio_read_8(port_addr + 6) & 0xf0) != 0xf0)
+	pio_write_8(&ns->regs->mcr, NS8250_MCR_ALL);
+	if ((pio_read_8(&ns->regs->msr) & NS8250_MSR_SIGNALS) 
+	    != NS8250_MSR_SIGNALS)
 		res = false;
 	
-	pio_write_8(port_addr + 4, olddata);
+	pio_write_8(&ns->regs->mcr, olddata);
 	
 	if (!res) {
@@ -390,8 +457,10 @@
  * @param port		The base address of the serial port device's ports.
  */
-static inline void ns8250_port_interrupts_enable(ioport8_t *port)
-{
-	pio_write_8(port + 1, 0x1);	/* Interrupt when data received. */
-	pio_write_8(port + 4, 0xB);
+static inline void ns8250_port_interrupts_enable(ns8250_regs_t *regs)
+{
+	/* Interrupt when data received. */
+	pio_write_8(&regs->ier, NS8250_IER_RXREADY);
+	pio_write_8(&regs->mcr, NS8250_MCR_DTR | NS8250_MCR_RTS 
+	    | NS8250_MCR_OUT2);
 }
 
@@ -400,7 +469,7 @@
  * @param port		The base address of the serial port device's ports
  */
-static inline void ns8250_port_interrupts_disable(ioport8_t *port)
-{
-	pio_write_8(port + 1, 0x0);	/* Disable all interrupts. */
+static inline void ns8250_port_interrupts_disable(ns8250_regs_t *regs)
+{
+	pio_write_8(&regs->ier, 0x0);	/* Disable all interrupts. */
 }
 
@@ -431,5 +500,5 @@
 
 	/* Enable interrupt on the serial port. */
-	ns8250_port_interrupts_enable(ns->port);
+	ns8250_port_interrupts_enable(ns->regs);
 	
 	return EOK;
@@ -443,8 +512,8 @@
  * @param port		The base address of the serial port device's ports.
  */
-static inline void enable_dlab(ioport8_t *port)
-{
-	uint8_t val = pio_read_8(port + 3);
-	pio_write_8(port + 3, val | DLAB_MASK);
+static inline void enable_dlab(ns8250_regs_t *regs)
+{
+	uint8_t val = pio_read_8(&regs->lcr);
+	pio_write_8(&regs->lcr, val | NS8250_LCR_DLAB);
 }
 
@@ -453,8 +522,8 @@
  * @param port		The base address of the serial port device's ports.
  */
-static inline void clear_dlab(ioport8_t *port)
-{
-	uint8_t val = pio_read_8(port + 3);
-	pio_write_8(port + 3, val & (~DLAB_MASK));
+static inline void clear_dlab(ns8250_regs_t *regs)
+{
+	uint8_t val = pio_read_8(&regs->lcr);
+	pio_write_8(&regs->lcr, val & (~NS8250_LCR_DLAB));
 }
 
@@ -466,5 +535,5 @@
  *			if the specified baud_rate is not valid).
  */
-static int ns8250_port_set_baud_rate(ioport8_t *port, unsigned int baud_rate)
+static int ns8250_port_set_baud_rate(ns8250_regs_t *regs, unsigned int baud_rate)
 {
 	uint16_t divisor;
@@ -482,12 +551,12 @@
 	
 	/* Enable DLAB to be able to access baud rate divisor. */
-	enable_dlab(port);
+	enable_dlab(regs);
 	
 	/* Set divisor low byte. */
-	pio_write_8(port + 0, div_low);
+	pio_write_8(&regs->data, div_low);
 	/* Set divisor high byte. */
-	pio_write_8(port + 1, div_high);
-	
-	clear_dlab(port);
+	pio_write_8(&regs->ier, div_high);
+	
+	clear_dlab(regs);
 	
 	return EOK;
@@ -499,5 +568,5 @@
  * @param baud_rate	The ouput parameter to which the baud rate is stored.
  */
-static unsigned int ns8250_port_get_baud_rate(ioport8_t *port)
+static unsigned int ns8250_port_get_baud_rate(ns8250_regs_t *regs)
 {
 	uint16_t divisor;
@@ -505,12 +574,12 @@
 	
 	/* Enable DLAB to be able to access baud rate divisor. */
-	enable_dlab(port);
+	enable_dlab(regs);
 	
 	/* Get divisor low byte. */
-	div_low = pio_read_8(port + 0);
+	div_low = pio_read_8(&regs->data);
 	/* Get divisor high byte. */
-	div_high = pio_read_8(port + 1);
-	
-	clear_dlab(port);
+	div_high = pio_read_8(&regs->ier);
+	
+	clear_dlab(regs);
 	
 	divisor = (div_high << 8) | div_low;
@@ -525,11 +594,11 @@
  * @param stop_bits	The number of stop bits used (one or two).
  */
-static void ns8250_port_get_com_props(ioport8_t *port, unsigned int *parity,
+static void ns8250_port_get_com_props(ns8250_regs_t *regs, unsigned int *parity,
     unsigned int *word_length, unsigned int *stop_bits)
 {
 	uint8_t val;
 	
-	val = pio_read_8(port + 3);
-	*parity = ((val >> 3) & 7);
+	val = pio_read_8(&regs->lcr);
+	*parity = ((val >> NS8250_LCR_PARITY) & 7);
 	
 	switch (val & 3) {
@@ -548,5 +617,5 @@
 	}
 	
-	if ((val >> 2) & 1)
+	if ((val >> NS8250_LCR_STOPBITS) & 1)
 		*stop_bits = 2;
 	else
@@ -562,5 +631,5 @@
  *			is invalid.
  */
-static int ns8250_port_set_com_props(ioport8_t *port, unsigned int parity,
+static int ns8250_port_set_com_props(ns8250_regs_t *regs, unsigned int parity,
     unsigned int word_length, unsigned int stop_bits)
 {
@@ -586,8 +655,8 @@
 	switch (stop_bits) {
 	case 1:
-		val |= ONE_STOP_BIT << 2;
+		val |= ONE_STOP_BIT << NS8250_LCR_STOPBITS;
 		break;
 	case 2:
-		val |= TWO_STOP_BITS << 2;
+		val |= TWO_STOP_BITS << NS8250_LCR_STOPBITS;
 		break;
 	default:
@@ -601,5 +670,5 @@
 	case SERIAL_MARK_PARITY:
 	case SERIAL_SPACE_PARITY:
-		val |= parity << 3;
+		val |= parity << NS8250_LCR_PARITY;
 		break;
 	default:
@@ -607,5 +676,5 @@
 	}
 	
-	pio_write_8(port + 3, val);
+	pio_write_8(&regs->lcr, val);
 	
 	return EOK;
@@ -620,19 +689,20 @@
 static void ns8250_initialize_port(ns8250_t *ns)
 {
-	ioport8_t *port = ns->port;
-	
 	/* Disable interrupts. */
-	ns8250_port_interrupts_disable(port);
+	ns8250_port_interrupts_disable(ns->regs);
 	/* Set baud rate. */
-	ns8250_port_set_baud_rate(port, 38400);
+	ns8250_port_set_baud_rate(ns->regs, 38400);
 	/* 8 bits, no parity, two stop bits. */
-	ns8250_port_set_com_props(port, SERIAL_NO_PARITY, 8, 2);
+	ns8250_port_set_com_props(ns->regs, SERIAL_NO_PARITY, 8, 2);
 	/* Enable FIFO, clear them, with 14-byte threshold. */
-	pio_write_8(port + 2, 0xC7);
+	pio_write_8(&ns->regs->iid, NS8250_FCR_FIFOENABLE
+	    | NS8250_FCR_RXFIFORESET | NS8250_FCR_TXFIFORESET 
+	    | NS8250_FCR_RXTRIGGERLOW | NS8250_FCR_RXTRIGGERHI);
 	/*
 	 * RTS/DSR set (Request to Send and Data Terminal Ready lines enabled),
 	 * Aux Output2 set - needed for interrupts.
 	 */
-	pio_write_8(port + 4, 0x0B);
+	pio_write_8(&ns->regs->mcr, NS8250_MCR_DTR | NS8250_MCR_RTS
+	    | NS8250_MCR_OUT2);
 }
 
@@ -644,9 +714,9 @@
 {
 	/* Disable FIFO */
-	pio_write_8(ns->port + 2, 0x00);
+	pio_write_8(&ns->regs->iid, 0x00);
 	/* Disable DTR, RTS, OUT1, OUT2 (int. enable) */
-	pio_write_8(ns->port + 4, 0x00);
+	pio_write_8(&ns->regs->mcr, 0x00);
 	/* Disable all interrupts from the port */
-	ns8250_port_interrupts_disable(ns->port);
+	ns8250_port_interrupts_disable(ns->regs);
 }
 
@@ -658,5 +728,5 @@
 static void ns8250_read_from_device(ns8250_t *ns)
 {
-	ioport8_t *port = ns->port;
+	ns8250_regs_t *regs = ns->regs;
 	bool cont = true;
 	
@@ -664,7 +734,7 @@
 		fibril_mutex_lock(&ns->mutex);
 		
-		cont = ns8250_received(port);
+		cont = ns8250_received(regs);
 		if (cont) {
-			uint8_t val = ns8250_read_8(port);
+			uint8_t val = ns8250_read_8(regs);
 			
 			if (ns->client_connected) {
@@ -896,11 +966,11 @@
 {
 	ns8250_t *data = (ns8250_t *) dev->driver_data;
-	ioport8_t *port = data->port;
+	ns8250_regs_t *regs = data->regs;
 	
 	fibril_mutex_lock(&data->mutex);
-	ns8250_port_interrupts_disable(port);
-	*baud_rate = ns8250_port_get_baud_rate(port);
-	ns8250_port_get_com_props(port, parity, word_length, stop_bits);
-	ns8250_port_interrupts_enable(port);
+	ns8250_port_interrupts_disable(regs);
+	*baud_rate = ns8250_port_get_baud_rate(regs);
+	ns8250_port_get_com_props(regs, parity, word_length, stop_bits);
+	ns8250_port_interrupts_enable(regs);
 	fibril_mutex_unlock(&data->mutex);
 	
@@ -927,13 +997,13 @@
 	
 	ns8250_t *data = (ns8250_t *) dev->driver_data;
-	ioport8_t *port = data->port;
+	ns8250_regs_t *regs = data->regs;
 	int ret;
 	
 	fibril_mutex_lock(&data->mutex);
-	ns8250_port_interrupts_disable(port);
-	ret = ns8250_port_set_baud_rate(port, baud_rate);
+	ns8250_port_interrupts_disable(regs);
+	ret = ns8250_port_set_baud_rate(regs, baud_rate);
 	if (ret == EOK)
-		ret = ns8250_port_set_com_props(port, parity, word_length, stop_bits);
-	ns8250_port_interrupts_enable(port);
+		ret = ns8250_port_set_com_props(regs, parity, word_length, stop_bits);
+	ns8250_port_interrupts_enable(regs);
 	fibril_mutex_unlock(&data->mutex);
 	
Index: uspace/drv/char/ps2mouse/main.c
===================================================================
--- uspace/drv/char/ps2mouse/main.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/char/ps2mouse/main.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -35,5 +35,4 @@
 #include <libarch/inttypes.h>
 #include <ddf/driver.h>
-#include <devman.h>
 #include <device/hw_res_parsed.h>
 #include <errno.h>
Index: uspace/drv/char/ps2mouse/ps2mouse.c
===================================================================
--- uspace/drv/char/ps2mouse/ps2mouse.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/char/ps2mouse/ps2mouse.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -80,5 +80,5 @@
 	} \
 	if (data != (value)) { \
-		ddf_msg(LVL_ERROR, "Failed testing byte: got %hhx vs. %hhx)", \
+		ddf_msg(LVL_DEBUG, "Failed testing byte: got %hhx vs. %hhx)", \
 		    data, (value)); \
 		return EIO; \
Index: uspace/drv/char/xtkbd/main.c
===================================================================
--- uspace/drv/char/xtkbd/main.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/char/xtkbd/main.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -35,5 +35,4 @@
 #include <libarch/inttypes.h>
 #include <ddf/driver.h>
-#include <devman.h>
 #include <device/hw_res_parsed.h>
 #include <errno.h>
Index: uspace/drv/infrastructure/root/root.c
===================================================================
--- uspace/drv/infrastructure/root/root.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/infrastructure/root/root.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -53,6 +53,4 @@
 #include <ddf/driver.h>
 #include <ddf/log.h>
-#include <devman.h>
-#include <ipc/devman.h>
 
 #define NAME "root"
@@ -158,6 +156,9 @@
 	if (asprintf(&match_id, PLATFORM_FUN_MATCH_ID_FMT, platform) == -1) {
 		ddf_msg(LVL_ERROR, "Memory allocation failed.");
-		return ENOMEM;
-	}
+		free(platform);
+		return ENOMEM;
+	}
+
+	free(platform);
 
 	/* Add function. */
@@ -169,4 +170,5 @@
 	if (fun == NULL) {
 		ddf_msg(LVL_ERROR, "Error creating function %s", name);
+		free(match_id);
 		return ENOMEM;
 	}
@@ -176,4 +178,5 @@
 		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
 		    name);
+		free(match_id);
 		ddf_fun_destroy(fun);
 		return rc;
@@ -208,5 +211,5 @@
 	 * vital for the system.
 	 */
-	add_virtual_root_fun(dev);
+	(void) add_virtual_root_fun(dev);
 
 	/* Register root device's children. */
Index: uspace/drv/infrastructure/rootpc/rootpc.c
===================================================================
--- uspace/drv/infrastructure/rootpc/rootpc.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/infrastructure/rootpc/rootpc.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -48,6 +48,4 @@
 #include <ddf/driver.h>
 #include <ddf/log.h>
-#include <devman.h>
-#include <ipc/devman.h>
 #include <ipc/dev_iface.h>
 #include <ops/hw_res.h>
Index: uspace/drv/nic/e1k/e1k.c
===================================================================
--- uspace/drv/nic/e1k/e1k.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/nic/e1k/e1k.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -46,5 +46,4 @@
 #include <ddf/log.h>
 #include <ddf/interrupt.h>
-#include <devman.h>
 #include <device/hw_res_parsed.h>
 #include <device/pci.h>
@@ -226,4 +225,12 @@
 static int e1000_on_stopping(nic_t *);
 static void e1000_send_frame(nic_t *, void *, size_t);
+
+/** PIO ranges used in the IRQ code. */
+irq_pio_range_t e1000_irq_pio_ranges[] = {
+	{
+		.base = 0,
+		.size =	PAGE_SIZE,	/* XXX */
+	}
+};
 
 /** Commands to deal with interrupt
@@ -255,4 +262,7 @@
 /** Interrupt code definition */
 irq_code_t e1000_irq_code = {
+	.rangecount = sizeof(e1000_irq_pio_ranges) /
+	    sizeof(irq_pio_range_t),
+	.ranges = e1000_irq_pio_ranges,
 	.cmdcount = sizeof(e1000_irq_commands) / sizeof(irq_cmd_t),
 	.cmds = e1000_irq_commands
@@ -1251,6 +1261,7 @@
 	fibril_mutex_lock(&irq_reg_mutex);
 	
-	e1000_irq_code.cmds[0].addr = e1000->reg_base_virt + E1000_ICR;
-	e1000_irq_code.cmds[2].addr = e1000->reg_base_virt + E1000_IMC;
+	e1000_irq_code.ranges[0].base = (uintptr_t) e1000->reg_base_phys;
+	e1000_irq_code.cmds[0].addr = e1000->reg_base_phys + E1000_ICR;
+	e1000_irq_code.cmds[2].addr = e1000->reg_base_phys + E1000_IMC;
 	
 	int rc = register_interrupt_handler(nic_get_ddf_dev(nic),
Index: uspace/drv/nic/ne2k/ne2k.c
===================================================================
--- uspace/drv/nic/ne2k/ne2k.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/nic/ne2k/ne2k.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -64,4 +64,11 @@
 #define NE2K(device) ((ne2k_t *) nic_get_specific(DRIVER_DATA(device)))
 
+static irq_pio_range_t ne2k_ranges_prototype[] = {
+	{
+		.base = 0,
+		.size = NE2K_IO_SIZE, 
+	}
+};
+
 /** NE2000 kernel interrupt command sequence.
  *
@@ -122,15 +129,32 @@
 
 	if (ne2k->code.cmdcount == 0) {
-		irq_cmd_t *ne2k_cmds = malloc(sizeof(ne2k_cmds_prototype));
-		if (ne2k_cmds == NULL) {
+		irq_pio_range_t *ne2k_ranges;
+		irq_cmd_t *ne2k_cmds;
+
+		ne2k_ranges = malloc(sizeof(ne2k_ranges_prototype));
+		if (!ne2k_ranges)
+			return ENOMEM;
+		memcpy(ne2k_ranges, ne2k_ranges_prototype,
+		    sizeof(ne2k_ranges_prototype));
+		ne2k_ranges[0].base = (uintptr_t) ne2k->base_port;
+
+		ne2k_cmds = malloc(sizeof(ne2k_cmds_prototype));
+		if (!ne2k_cmds) {
+			free(ne2k_ranges);
 			return ENOMEM;
 		}
-		memcpy(ne2k_cmds, ne2k_cmds_prototype, sizeof (ne2k_cmds_prototype));
-		ne2k_cmds[0].addr = ne2k->port + DP_ISR;
-		ne2k_cmds[3].addr = ne2k->port + DP_IMR;
+		memcpy(ne2k_cmds, ne2k_cmds_prototype,
+		    sizeof(ne2k_cmds_prototype));
+		ne2k_cmds[0].addr = ne2k->base_port + DP_ISR;
+		ne2k_cmds[3].addr = ne2k->base_port + DP_IMR;
 		ne2k_cmds[4].addr = ne2k_cmds[0].addr;
-		ne2k_cmds[5].addr = ne2k->port + DP_TSR;
-
-		ne2k->code.cmdcount = sizeof(ne2k_cmds_prototype) / sizeof(irq_cmd_t);
+		ne2k_cmds[5].addr = ne2k->base_port + DP_TSR;
+
+		ne2k->code.rangecount = sizeof(ne2k_ranges_prototype) /
+		    sizeof(irq_pio_range_t);
+		ne2k->code.ranges = ne2k_ranges;
+
+		ne2k->code.cmdcount = sizeof(ne2k_cmds_prototype) /
+		    sizeof(irq_cmd_t);
 		ne2k->code.cmds = ne2k_cmds;
 	}
@@ -148,4 +172,5 @@
 		ne2k_t *ne2k = NE2K(dev);
 		if (ne2k) {
+			free(ne2k->code.ranges);
 			free(ne2k->code.cmds);
 		}
Index: uspace/drv/nic/rtl8139/driver.c
===================================================================
--- uspace/drv/nic/rtl8139/driver.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/drv/nic/rtl8139/driver.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -659,4 +659,10 @@
 
 
+irq_pio_range_t rtl8139_irq_pio_ranges[] = {
+	{
+		.base = 0,
+		.size = RTL8139_IO_SIZE
+	}
+};
 
 /** Commands to deal with interrupt
@@ -668,35 +674,37 @@
  */
 irq_cmd_t rtl8139_irq_commands[] = {
-		{
-				/* Get the interrupt status */
-				.cmd = CMD_PIO_READ_16,
-				.addr = NULL,
-				.dstarg = 2
-		},
-		{
-				.cmd = CMD_PREDICATE,
-				.value = 3,
-				.srcarg = 2
-		},
-		{
-				/* Mark interrupts as solved */
-				.cmd = CMD_PIO_WRITE_16,
-				.addr = NULL,
-				.value = 0xFFFF
-		},
-		{
-				/* Disable interrupts until interrupt routine is finished */
-				.cmd = CMD_PIO_WRITE_16,
-				.addr = NULL,
-				.value = 0x0000
-		},
-		{
-				.cmd = CMD_ACCEPT
-		}
+	{
+		/* Get the interrupt status */
+		.cmd = CMD_PIO_READ_16,
+		.addr = NULL,
+		.dstarg = 2
+	},
+	{
+		.cmd = CMD_PREDICATE,
+		.value = 3,
+		.srcarg = 2
+	},
+	{
+		/* Mark interrupts as solved */
+		.cmd = CMD_PIO_WRITE_16,
+		.addr = NULL,
+		.value = 0xFFFF
+	},
+	{
+		/* Disable interrupts until interrupt routine is finished */
+		.cmd = CMD_PIO_WRITE_16,
+		.addr = NULL,
+		.value = 0x0000
+	},
+	{
+		.cmd = CMD_ACCEPT
+	}
 };
 
 /** Interrupt code definition */
 irq_code_t rtl8139_irq_code = {
-	.cmdcount = sizeof(rtl8139_irq_commands)/sizeof(irq_cmd_t),
+	.rangecount = sizeof(rtl8139_irq_pio_ranges) / sizeof(irq_pio_range_t),
+	.ranges = rtl8139_irq_pio_ranges,
+	.cmdcount = sizeof(rtl8139_irq_commands) / sizeof(irq_cmd_t),
 	.cmds = rtl8139_irq_commands
 };
@@ -888,9 +896,10 @@
 	RTL8139_IRQ_STRUCT_LOCK();
 
-	rtl8139_irq_code.cmds[0].addr = rtl8139->io_port + ISR;
-	rtl8139_irq_code.cmds[2].addr = rtl8139->io_port + ISR;
-	rtl8139_irq_code.cmds[3].addr = rtl8139->io_port + IMR;
+	rtl8139_irq_code.ranges[0].base = (uintptr_t) rtl8139->io_addr;
+	rtl8139_irq_code.cmds[0].addr = rtl8139->io_addr + ISR;
+	rtl8139_irq_code.cmds[2].addr = rtl8139->io_addr + ISR;
+	rtl8139_irq_code.cmds[3].addr = rtl8139->io_addr + IMR;
 	int rc = register_interrupt_handler(nic_get_ddf_dev(nic_data),
-		rtl8139->irq, rtl8139_interrupt_handler, &rtl8139_irq_code);
+	    rtl8139->irq, rtl8139_interrupt_handler, &rtl8139_irq_code);
 
 	RTL8139_IRQ_STRUCT_UNLOCK();
Index: uspace/lib/c/arch/amd64/include/fibril.h
===================================================================
--- uspace/lib/c/arch/amd64/include/fibril.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/amd64/include/fibril.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,9 +38,10 @@
 #include <sys/types.h>
 
-/* According to ABI the stack MUST be aligned on 
+/*
+ * According to ABI the stack MUST be aligned on
  * 16-byte boundary. If it is not, the va_arg calling will
  * panic sooner or later
  */
-#define SP_DELTA     16
+#define SP_DELTA  16
 
 #define context_set(c, _pc, stack, size, ptls) \
Index: uspace/lib/c/arch/arm32/Makefile.common
===================================================================
--- uspace/lib/c/arch/arm32/Makefile.common	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/arm32/Makefile.common	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -28,5 +28,5 @@
 #
 
-GCC_CFLAGS += -ffixed-r9 -mtp=soft -mapcs-frame -fno-omit-frame-pointer
+GCC_CFLAGS += -ffixed-r9 -mtp=soft -fno-omit-frame-pointer -march=armv4
 
 ENDIANESS = LE
Index: uspace/lib/c/arch/arm32/include/fibril.h
===================================================================
--- uspace/lib/c/arch/arm32/include/fibril.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/arm32/include/fibril.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libcarm32	
+/** @addtogroup libcarm32
  * @{
  */
@@ -42,14 +42,14 @@
 
 /** Size of a stack item */
-#define STACK_ITEM_SIZE		4
+#define STACK_ITEM_SIZE  4
 
 /** Stack alignment - see <a href="http://www.arm.com/support/faqdev/14269.html">ABI</a> for details */
-#define STACK_ALIGNMENT		8
+#define STACK_ALIGNMENT  8
 
-#define SP_DELTA	(0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
+#define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
 
 
-/** Sets data to the context. 
- *  
+/** Sets data to the context.
+ *
  *  @param c     Context (#context_t).
  *  @param _pc   Program counter.
@@ -62,9 +62,9 @@
 		(c)->pc = (sysarg_t) (_pc); \
 		(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
- 		(c)->tls = ((sysarg_t)(ptls)) + sizeof(tcb_t) + ARM_TP_OFFSET; \
+		(c)->tls = ((sysarg_t)(ptls)) + sizeof(tcb_t) + ARM_TP_OFFSET; \
 		(c)->fp = 0; \
 	} while (0)
 
-/** Fibril context. 
+/** Fibril context.
  *
  *  Only registers preserved accross function calls are included. r9 is used 
@@ -91,5 +91,4 @@
 }
 
-
 #endif
 
Index: uspace/lib/c/arch/arm32/src/eabi.S
===================================================================
--- uspace/lib/c/arch/arm32/src/eabi.S	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/arm32/src/eabi.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2007 Pavel Jancik
+# Copyright (c) 2012 Martin Decky
 # All rights reserved.
 #
@@ -31,5 +31,68 @@
 .global __aeabi_read_tp
 
+.global __aeabi_idiv
+.global __aeabi_uidiv
+
+.global __aeabi_idivmod
+.global __aeabi_uidivmod
+
+.global __aeabi_ldivmod
+.global __aeabi_uldivmod
+
 __aeabi_read_tp:
 	mov r0, r9
 	mov pc, lr
+
+__aeabi_idiv:
+	push {lr}
+	bl __divsi3
+	pop {lr}
+	mov pc, lr
+
+__aeabi_uidiv:
+	push {lr}
+	bl __udivsi3
+	pop {lr}
+	mov pc, lr
+
+__aeabi_idivmod:
+	push {lr}
+	sub sp, sp, #12
+	add r2, sp, #4
+	bl __udivmodsi3
+	ldr r1, [sp, #4]
+	add sp, sp, #12
+	pop {lr}
+	mov pc, lr
+
+__aeabi_uidivmod:
+	push {lr}
+	sub sp, sp, #12
+	add r2, sp, #4
+	bl __udivmodsi3
+	ldr r1, [sp, #4]
+	add sp, sp, #12
+	pop {lr}
+	mov pc, lr
+
+__aeabi_ldivmod:
+	push {lr}
+	sub sp, sp, #24
+	push {sp}
+	bl __divmoddi3
+	add sp, sp, #4
+	pop {r2, r3}
+	add sp, sp, #16
+	pop {lr}
+	mov pc, lr
+
+__aeabi_uldivmod:
+	push {lr}
+	sub sp, sp, #24
+	push {sp}
+	bl __udivmoddi3
+	add sp, sp, #4
+	pop {r2, r3}
+	add sp, sp, #16
+	pop {lr}
+	mov pc, lr
Index: uspace/lib/c/arch/ia32/include/fibril.h
===================================================================
--- uspace/lib/c/arch/ia32/include/fibril.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/ia32/include/fibril.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,5 +38,6 @@
 #include <sys/types.h>
 
-/* According to ABI the stack MUST be aligned on 
+/*
+ * According to ABI the stack MUST be aligned on
  * 16-byte boundary. If it is not, the va_arg calling will
  * panic sooner or later
Index: uspace/lib/c/arch/ia64/include/ddi.h
===================================================================
--- uspace/lib/c/arch/ia64/include/ddi.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/ia64/include/ddi.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -62,4 +62,5 @@
 
 	asm volatile ("mf\n" ::: "memory");
+	asm volatile ("mf.a\n" ::: "memory");
 }
 
@@ -76,4 +77,5 @@
 
 	asm volatile ("mf\n" ::: "memory");
+	asm volatile ("mf.a\n" ::: "memory");
 }
 
@@ -90,4 +92,5 @@
 
 	asm volatile ("mf\n" ::: "memory");
+	asm volatile ("mf.a\n" ::: "memory");
 }
 
@@ -106,4 +109,6 @@
 		v = *port;
 	}
+
+	asm volatile ("mf.a\n" ::: "memory");
 
 	return v;
@@ -125,4 +130,6 @@
 	}
 
+	asm volatile ("mf.a\n" ::: "memory");
+
 	return v;
 }
@@ -134,5 +141,5 @@
 	asm volatile ("mf\n" ::: "memory");
 
-	if (port < (ioport32_t *) port) {
+	if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
 		uintptr_t prt = (uintptr_t) port;
 
@@ -143,4 +150,6 @@
 	}
 
+	asm volatile ("mf.a\n" ::: "memory");
+
 	return v;
 }
Index: uspace/lib/c/arch/ia64/include/fibril.h
===================================================================
--- uspace/lib/c/arch/ia64/include/fibril.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/ia64/include/fibril.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libcia64	
+/** @addtogroup libcia64
  * @{
  */
@@ -45,21 +45,24 @@
  * No need to allocate scratch area.
  */
-#define SP_DELTA	(0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
+#define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
 
-#define PFM_MASK        (~0x3fffffffff)
+#define PFM_MASK  (~0x3fffffffff)
 
-#define PSTHREAD_INITIAL_STACK_PAGES_NO 2
+#define PSTHREAD_INITIAL_STACK_PAGES_NO  2
+
 /* Stack is divided into two equal parts (for memory stack and register stack). */
-#define PSTHREAD_INITIAL_STACK_DIVISION 2  
+#define PSTHREAD_INITIAL_STACK_DIVISION  2
 
-#define context_set(c, _pc, stack, size, tls) 								\
-	do {												\
-		(c)->pc = (uint64_t) _pc;								\
-		(c)->bsp = ((uint64_t) stack) + size / PSTHREAD_INITIAL_STACK_DIVISION;								\
-		(c)->ar_pfs &= PFM_MASK; 								\
-		(c)->sp = ((uint64_t) stack) + ALIGN_UP((size / PSTHREAD_INITIAL_STACK_DIVISION), STACK_ALIGNMENT) - SP_DELTA;		\
-		(c)->tp = (uint64_t) tls;								\
-	} while (0);
-	
+#define context_set(c, _pc, stack, size, tls) \
+	do { \
+		(c)->pc = (uint64_t) _pc; \
+		(c)->bsp = ((uint64_t) stack) + \
+		    size / PSTHREAD_INITIAL_STACK_DIVISION; \
+		(c)->ar_pfs &= PFM_MASK; \
+		(c)->sp = ((uint64_t) stack) + \
+		    ALIGN_UP((size / PSTHREAD_INITIAL_STACK_DIVISION), STACK_ALIGNMENT) - \
+		    SP_DELTA; \
+		(c)->tp = (uint64_t) tls; \
+	} while (0)
 
 /*
Index: uspace/lib/c/arch/mips32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/mips32/Makefile.inc	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/mips32/Makefile.inc	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -28,7 +28,7 @@
 
 ARCH_SOURCES = \
-	arch/$(UARCH)/src/entry.s \
-	arch/$(UARCH)/src/entryjmp.s \
-	arch/$(UARCH)/src/thread_entry.s \
+	arch/$(UARCH)/src/entry.S \
+	arch/$(UARCH)/src/entryjmp.S \
+	arch/$(UARCH)/src/thread_entry.S \
 	arch/$(UARCH)/src/syscall.c \
 	arch/$(UARCH)/src/fibril.S \
Index: uspace/lib/c/arch/mips32/include/atomic.h
===================================================================
--- uspace/lib/c/arch/mips32/include/atomic.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/mips32/include/atomic.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -67,5 +67,5 @@
 		"	ll %0, %1\n"
 		"	addu %0, %0, %3\n"	/* same as add, but never traps on overflow */
-		"       move %2, %0\n"
+		"	move %2, %0\n"
 		"	sc %0, %1\n"
 		"	beq %0, %4, 1b\n"	/* if the atomic operation failed, try again */
Index: uspace/lib/c/arch/mips32/include/config.h
===================================================================
--- uspace/lib/c/arch/mips32/include/config.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/mips32/include/config.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -36,6 +36,6 @@
 #define LIBC_mips32_CONFIG_H_
 
-#define PAGE_WIDTH	14
-#define PAGE_SIZE	(1 << PAGE_WIDTH)
+#define PAGE_WIDTH  14
+#define PAGE_SIZE   (1 << PAGE_WIDTH)
 
 #endif
Index: uspace/lib/c/arch/mips32/include/faddr.h
===================================================================
--- uspace/lib/c/arch/mips32/include/faddr.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/mips32/include/faddr.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,5 +38,5 @@
 #include <libarch/types.h>
 
-#define FADDR(fptr)		((uintptr_t) (fptr))
+#define FADDR(fptr)  ((uintptr_t) (fptr))
 
 #endif
Index: uspace/lib/c/arch/mips32/include/fibril.h
===================================================================
--- uspace/lib/c/arch/mips32/include/fibril.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/mips32/include/fibril.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,20 +38,21 @@
 
 #include <sys/types.h>
+#include <libarch/stack.h>
+#include <align.h>
 
-/* We define our own context_set, because we need to set
- * the TLS pointer to the tcb+0x7000
+#define SP_DELTA  (ABI_STACK_FRAME + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
+
+/*
+ * We define our own context_set, because we need to set
+ * the TLS pointer to the tcb + 0x7000
  *
  * See tls_set in thread.h
  */
-#define context_set(c, _pc, stack, size, ptls) 			\
-	(c)->pc = (sysarg_t) (_pc);				\
-	(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; 	\
-        (c)->tls = ((sysarg_t)(ptls)) + 0x7000 + sizeof(tcb_t);
-
-
-/* +16 is just for sure that the called function
- * have space to store it's arguments
- */
-#define SP_DELTA	(8+16)
+#define context_set(c, _pc, stack, size, ptls) \
+	do { \
+		(c)->pc = (sysarg_t) (_pc); \
+		(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
+		(c)->tls = ((sysarg_t)(ptls)) + 0x7000 + sizeof(tcb_t); \
+	} while (0)
 
 typedef struct  {
Index: uspace/lib/c/arch/mips32/include/stack.h
===================================================================
--- uspace/lib/c/arch/mips32/include/stack.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/lib/c/arch/mips32/include/stack.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,1 @@
+../../../../../../kernel/arch/mips32/include/stack.h
Index: uspace/lib/c/arch/mips32/src/entry.S
===================================================================
--- uspace/lib/c/arch/mips32/src/entry.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/lib/c/arch/mips32/src/entry.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2005 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.
+#
+
+#include <libarch/stack.h>
+
+.text
+.section .init, "ax"
+
+.global __entry
+
+.set noreorder
+.option pic2
+
+## User-space task entry point
+#
+# $a0 ($4) contains the PCB pointer
+#
+.ent __entry
+__entry:
+	.frame $sp, ABI_STACK_FRAME, $ra
+	.cpload $t9
+	
+	# Allocate the stack frame.
+	addiu $sp, -ABI_STACK_FRAME
+	
+	# Allow PIC code
+	.cprestore 16
+	
+	# Pass pcb_ptr to __main() as the first argument. It is already
+	# in $a0. As the first argument is passed in $a0, no operation
+	# is needed.
+	
+	jal __main
+	nop
+	
+	#
+	# Not reached.
+	#
+	addiu $sp, ABI_STACK_FRAME
+.end __entry
Index: pace/lib/c/arch/mips32/src/entry.s
===================================================================
--- uspace/lib/c/arch/mips32/src/entry.s	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,59 +1,0 @@
-#
-# Copyright (c) 2005 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.
-#
-
-.text
-.section .init, "ax"
-
-.global __entry
-
-.set noreorder
-.option pic2
-
-## User-space task entry point
-#
-# $a0 ($4) contains the PCB pointer
-#
-.ent __entry
-__entry:
-	.frame $sp, 32, $31
-	.cpload $25
-
-	# Mips o32 may store its arguments on stack, make space (16 bytes),
-	# so that it could work with -O0
-	# Make space additional 16 bytes for the stack frame
-
-	addiu $sp, -32
-	.cprestore 16   # Allow PIC code
-
-	# Pass pcb_ptr to __main() as the first argument. pcb_ptr is already
-	# in $a0. As the first argument is passed in $a0, no operation
-	# is needed.
-
-	jal __main
-	nop
-.end
Index: uspace/lib/c/arch/mips32/src/entryjmp.S
===================================================================
--- uspace/lib/c/arch/mips32/src/entryjmp.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/lib/c/arch/mips32/src/entryjmp.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,53 @@
+#
+# Copyright (c) 2008 Jiri Svoboda
+# 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 <libarch/stack.h>
+
+.text
+.section .text
+.global entry_point_jmp
+.set noreorder
+
+## void entry_point_jmp(void *entry_point, void *pcb);
+#
+# $a0 (=$4) contains entry_point
+# $a1 (=$5) contains pcb
+#
+# Jump to program entry point
+.ent entry_point_jmp
+entry_point_jmp:
+	# tmp := entry_point
+	move $t9, $a0
+	
+	# Pass pcb to the entry point in $a0
+	move $a0, $a1
+	
+	jr $t9
+	addiu $sp, -ABI_STACK_FRAME
+	addiu $sp, ABI_STACK_FRAME
+.end entry_point_jmp
Index: pace/lib/c/arch/mips32/src/entryjmp.s
===================================================================
--- uspace/lib/c/arch/mips32/src/entryjmp.s	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,49 +1,0 @@
-#
-# Copyright (c) 2008 Jiri Svoboda
-# 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.
-#
-
-.text
-.section .text
-.global entry_point_jmp
-.set noreorder
-
-## void entry_point_jmp(void *entry_point, void *pcb);
-#
-# $a0 (=$4)	contains entry_point
-# $a1 (=$5)	contains pcb
-#
-# Jump to program entry point
-.ent entry_point_jmp
-entry_point_jmp:
-	# tmp := entry_point
-	move $25, $a0
-
-	# Pass pcb to the entry point in $a0
-	move $a0, $a1
-	jr $25
-	nop
-.end
Index: uspace/lib/c/arch/mips32/src/fibril.S
===================================================================
--- uspace/lib/c/arch/mips32/src/fibril.S	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/mips32/src/fibril.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -33,23 +33,23 @@
 
 #include <libarch/context_offset.h>
-	
+
 .global context_save
 .global context_restore
-	
+
 context_save:
 	CONTEXT_SAVE_ARCH_CORE $a0
-
+	
 	# context_save returns 1
 	j $ra
-	li $v0, 1	
-	
+	li $v0, 1
+
 context_restore:
 	CONTEXT_RESTORE_ARCH_CORE $a0
-
-	# Just for the jump into first function, but one instruction
-	# should not bother us
-	move $t9, $ra	
+	
+	# Just for the jump into first function,
+	# but one instruction should not bother us
+	move $t9, $ra
+	
 	# context_restore returns 0
 	j $ra
-	xor $v0, $v0	
-
+	xor $v0, $v0
Index: uspace/lib/c/arch/mips32/src/syscall.c
===================================================================
--- uspace/lib/c/arch/mips32/src/syscall.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/mips32/src/syscall.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -57,6 +57,9 @@
 		  "r" (__mips_reg_t1),
 		  "r" (__mips_reg_v0)
-		: "%ra" /* We are a function call, although C does not 
-			 * know it */
+		/*
+		 * We are a function call, although C
+		 * does not know it.
+		 */
+		: "%ra"
 	);
 	
Index: uspace/lib/c/arch/mips32/src/thread_entry.S
===================================================================
--- uspace/lib/c/arch/mips32/src/thread_entry.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/lib/c/arch/mips32/src/thread_entry.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2006 Jakub Jermar
+# 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 <libarch/stack.h>
+
+.text
+
+.set noat
+.set noreorder
+.option pic2
+
+.globl __thread_entry
+
+## User-space thread entry point for all but the first threads.
+#
+#
+.ent __thread_entry
+__thread_entry:
+	.frame $sp, ABI_STACK_FRAME, $ra
+	.cpload $t9
+	
+	#
+	# v0 contains address of uarg.
+	#
+	add $a0, $v0, 0
+	
+	# Allocate the stack frame.
+	addiu $sp, -ABI_STACK_FRAME
+	
+	# Allow PIC code
+	.cprestore 16
+	
+	jal __thread_main
+	nop
+	
+	#
+	# Not reached.
+	#
+	addiu $sp, ABI_STACK_FRAME
+.end __thread_entry
Index: pace/lib/c/arch/mips32/src/thread_entry.s
===================================================================
--- uspace/lib/c/arch/mips32/src/thread_entry.s	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,59 +1,0 @@
-#
-# Copyright (c) 2006 Jakub Jermar
-# 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.
-#
-
-.text
-	
-.set noat
-.set noreorder
-.option pic2
-	
-.globl __thread_entry
-
-## User-space thread entry point for all but the first threads.
-#
-#
-.ent __thread_entry
-__thread_entry:
-	.frame $sp, 32, $31
-	.cpload $25
-
-	#
-	# v0 contains address of uarg.
-	#
-	add $4, $2, 0
-	# Mips o32 may store its arguments on stack, make space
-	addiu $sp, -32
-	.cprestore 16
-	
-	jal __thread_main
-	nop
-		
-	#
-	# Not reached.
-	#
-.end __thread_entry
Index: uspace/lib/c/arch/mips32eb/Makefile.inc
===================================================================
--- uspace/lib/c/arch/mips32eb/Makefile.inc	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/mips32eb/Makefile.inc	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -28,7 +28,7 @@
 
 ARCH_SOURCES = \
-	arch/$(UARCH)/src/entry.s \
-	arch/$(UARCH)/src/entryjmp.s \
-	arch/$(UARCH)/src/thread_entry.s \
+	arch/$(UARCH)/src/entry.S \
+	arch/$(UARCH)/src/entryjmp.S \
+	arch/$(UARCH)/src/thread_entry.S \
 	arch/$(UARCH)/src/syscall.c \
 	arch/$(UARCH)/src/fibril.S \
Index: uspace/lib/c/arch/mips32eb/include/stack.h
===================================================================
--- uspace/lib/c/arch/mips32eb/include/stack.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/lib/c/arch/mips32eb/include/stack.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,1 @@
+../../mips32/include/stack.h
Index: uspace/lib/c/arch/mips64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/mips64/Makefile.inc	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/mips64/Makefile.inc	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -28,7 +28,7 @@
 
 ARCH_SOURCES = \
-	arch/$(UARCH)/src/entry.s \
-	arch/$(UARCH)/src/entryjmp.s \
-	arch/$(UARCH)/src/thread_entry.s \
+	arch/$(UARCH)/src/entry.S \
+	arch/$(UARCH)/src/entryjmp.S \
+	arch/$(UARCH)/src/thread_entry.S \
 	arch/$(UARCH)/src/syscall.c \
 	arch/$(UARCH)/src/fibril.S \
Index: uspace/lib/c/arch/mips64/include/fibril.h
===================================================================
--- uspace/lib/c/arch/mips64/include/fibril.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/mips64/include/fibril.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,19 +38,21 @@
 
 #include <sys/types.h>
+#include <libarch/stack.h>
+#include <align.h>
 
-/* We define our own context_set, because we need to set
- * the TLS pointer to the tcb+0x7000
+#define SP_DELTA  (ABI_STACK_FRAME + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
+
+/*
+ * We define our own context_set, because we need to set
+ * the TLS pointer to the tcb + 0x7000
  *
  * See tls_set in thread.h
  */
 #define context_set(c, _pc, stack, size, ptls) \
-	(c)->pc = (sysarg_t) (_pc); \
-	(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
-	(c)->tls = ((sysarg_t)(ptls)) + 0x7000 + sizeof(tcb_t);
-
-/* +16 is just for sure that the called function
- * have space to store it's arguments
- */
-#define SP_DELTA  (8 + 16)
+	do { \
+		(c)->pc = (sysarg_t) (_pc); \
+		(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
+		(c)->tls = ((sysarg_t)(ptls)) + 0x7000 + sizeof(tcb_t); \
+	} while (0)
 
 typedef struct {
Index: uspace/lib/c/arch/mips64/include/stack.h
===================================================================
--- uspace/lib/c/arch/mips64/include/stack.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/lib/c/arch/mips64/include/stack.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,1 @@
+../../../../../../kernel/arch/mips64/include/stack.h
Index: uspace/lib/c/arch/mips64/src/entry.S
===================================================================
--- uspace/lib/c/arch/mips64/src/entry.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/lib/c/arch/mips64/src/entry.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2005 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.
+#
+
+#include <libarch/stack.h>
+
+.text
+.section .init, "ax"
+
+.global __entry
+
+.set noreorder
+.option pic2
+
+## User-space task entry point
+#
+# $a0 ($4) contains the PCB pointer
+#
+.ent __entry
+__entry:
+	.frame $sp, ABI_STACK_FRAME, $ra
+	.cpload $t9
+	
+	# Allocate the stack frame.
+	addiu $sp, -ABI_STACK_FRAME
+	
+	# Allow PIC code
+	.cprestore 16
+	
+	# Pass pcb_ptr to __main() as the first argument. It is already
+	# in $a0. As the first argument is passed in $a0, no operation
+	# is needed.
+	
+	jal __main
+	nop
+	
+	#
+	# Not reached.
+	#
+	addiu $sp, ABI_STACK_FRAME
+.end __entry
Index: pace/lib/c/arch/mips64/src/entry.s
===================================================================
--- uspace/lib/c/arch/mips64/src/entry.s	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,57 +1,0 @@
-#
-# Copyright (c) 2005 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.
-#
-
-.text
-.section .init, "ax"
-
-.global __entry
-
-.set noreorder
-.option pic2
-
-## User-space task entry point
-#
-# $a0 ($4) contains the PCB pointer
-#
-.ent __entry
-__entry:
-	.frame $sp, 32, $31
-	.cpload $25
-	
-	# FIXME: Reflect exactly ABI specs here
-	
-	addiu $sp, -32
-	.cprestore 16   # Allow PIC code
-	
-	# Pass pcb_ptr to __main() as the first argument. pcb_ptr is already
-	# in $a0. As the first argument is passed in $a0, no operation
-	# is needed.
-	
-	jal __main
-	nop
-.end
Index: uspace/lib/c/arch/mips64/src/entryjmp.S
===================================================================
--- uspace/lib/c/arch/mips64/src/entryjmp.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/lib/c/arch/mips64/src/entryjmp.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,53 @@
+#
+# Copyright (c) 2008 Jiri Svoboda
+# 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 <libarch/stack.h>
+
+.text
+.section .text
+.global entry_point_jmp
+.set noreorder
+
+## void entry_point_jmp(void *entry_point, void *pcb);
+#
+# $a0 (=$4) contains entry_point
+# $a1 (=$5) contains pcb
+#
+# Jump to program entry point
+.ent entry_point_jmp
+entry_point_jmp:
+	# tmp := entry_point
+	move $t9, $a0
+	
+	# Pass pcb to the entry point in $a0
+	move $a0, $a1
+	
+	jr $t9
+	addiu $sp, -ABI_STACK_FRAME
+	addiu $sp, ABI_STACK_FRAME
+.end entry_point_jmp
Index: pace/lib/c/arch/mips64/src/entryjmp.s
===================================================================
--- uspace/lib/c/arch/mips64/src/entryjmp.s	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,49 +1,0 @@
-#
-# Copyright (c) 2008 Jiri Svoboda
-# 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.
-#
-
-.text
-.section .text
-.global entry_point_jmp
-.set noreorder
-
-## void entry_point_jmp(void *entry_point, void *pcb);
-#
-# $a0 (=$4) contains entry_point
-# $a1 (=$5) contains pcb
-#
-# Jump to program entry point
-.ent entry_point_jmp
-entry_point_jmp:
-	# tmp := entry_point
-	move $25, $a0
-	
-	# Pass pcb to the entry point in $a0
-	move $a0, $a1
-	jr $25
-	nop
-.end
Index: uspace/lib/c/arch/mips64/src/thread_entry.S
===================================================================
--- uspace/lib/c/arch/mips64/src/thread_entry.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
+++ uspace/lib/c/arch/mips64/src/thread_entry.S	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2006 Jakub Jermar
+# 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 <libarch/stack.h>
+
+.text
+
+.set noat
+.set noreorder
+.option pic2
+
+.globl __thread_entry
+
+## User-space thread entry point for all but the first threads.
+#
+#
+.ent __thread_entry
+__thread_entry:
+	.frame $sp, ABI_STACK_FRAME, $ra
+	.cpload $t9
+	
+	#
+	# v0 contains address of uarg.
+	#
+	add $a0, $v0, 0
+	
+	# Allocate the stack frame.
+	addiu $sp, -ABI_STACK_FRAME
+	
+	# Allow PIC code
+	.cprestore 16
+	
+	jal __thread_main
+	nop
+	
+	#
+	# Not reached.
+	#
+	addiu $sp, ABI_STACK_FRAME
+.end __thread_entry
Index: pace/lib/c/arch/mips64/src/thread_entry.s
===================================================================
--- uspace/lib/c/arch/mips64/src/thread_entry.s	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,59 +1,0 @@
-#
-# Copyright (c) 2006 Jakub Jermar
-# 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.
-#
-
-.text
-
-.set noat
-.set noreorder
-.option pic2
-
-.globl __thread_entry
-
-## User-space thread entry point for all but the first threads.
-#
-#
-.ent __thread_entry
-__thread_entry:
-	.frame $sp, 32, $31
-	.cpload $25
-	
-	#
-	# v0 contains address of uarg.
-	#
-	add $4, $2, 0
-	
-	addiu $sp, -32
-	.cprestore 16
-	
-	jal __thread_main
-	nop
-	
-	#
-	# Not reached.
-	#
-.end __thread_entry
Index: uspace/lib/c/arch/ppc32/include/fibril.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/fibril.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/ppc32/include/fibril.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libcppc32	
+/** @addtogroup libcppc32
  * @{
  */
@@ -38,15 +38,18 @@
 #include <sys/types.h>
 
-/* We define our own context_set, because we need to set
- * the TLS pointer to the tcb+0x7000
+#define SP_DELTA  16
+
+/*
+ * We define our own context_set, because we need to set
+ * the TLS pointer to the tcb + 0x7000
  *
  * See tls_set in thread.h
  */
-#define context_set(c, _pc, stack, size, ptls) 			\
-	(c)->pc = (sysarg_t) (_pc);				\
-	(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; 	\
-	(c)->tls = ((sysarg_t) (ptls)) + 0x7000 + sizeof(tcb_t);
-
-#define SP_DELTA	16
+#define context_set(c, _pc, stack, size, ptls) \
+	do { \
+		(c)->pc = (sysarg_t) (_pc); \
+		(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
+		(c)->tls = ((sysarg_t) (ptls)) + 0x7000 + sizeof(tcb_t); \
+	} while (0)
 
 typedef struct {
Index: uspace/lib/c/arch/sparc64/include/fibril.h
===================================================================
--- uspace/lib/c/arch/sparc64/include/fibril.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/arch/sparc64/include/fibril.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -40,5 +40,5 @@
 #include <align.h>
 
-#define SP_DELTA	(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE)
+#define SP_DELTA  (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE)
 
 #define context_set(c, _pc, stack, size, ptls) \
@@ -50,5 +50,5 @@
 		(c)->tp = (uint64_t) ptls; \
 	} while (0)
-	
+
 /*
  * Save only registers that must be preserved across
Index: uspace/lib/c/generic/async.c
===================================================================
--- uspace/lib/c/generic/async.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/generic/async.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -189,4 +189,10 @@
 	/** If reply was received. */
 	bool done;
+
+	/** If the message / reply should be discarded on arrival. */
+	bool forget;
+
+	/** If already destroyed. */
+	bool destroyed;
 	
 	/** Pointer to where the answer data is stored. */
@@ -240,4 +246,52 @@
 /** Identifier of the incoming connection handled by the current fibril. */
 static fibril_local connection_t *fibril_connection;
+
+static void to_event_initialize(to_event_t *to)
+{
+	struct timeval tv = { 0, 0 };
+
+	to->inlist = false;
+	to->occurred = false;
+	link_initialize(&to->link);
+	to->expires = tv;
+}
+
+static void wu_event_initialize(wu_event_t *wu)
+{
+	wu->inlist = false;
+	link_initialize(&wu->link);
+}
+
+void awaiter_initialize(awaiter_t *aw)
+{
+	aw->fid = 0;
+	aw->active = false;
+	to_event_initialize(&aw->to_event);
+	wu_event_initialize(&aw->wu_event);
+}
+
+static amsg_t *amsg_create(void)
+{
+	amsg_t *msg;
+
+	msg = malloc(sizeof(amsg_t));
+	if (msg) {
+		msg->done = false;
+		msg->forget = false;
+		msg->destroyed = false;
+		msg->dataptr = NULL;
+		msg->retval = (sysarg_t) EINVAL;
+		awaiter_initialize(&msg->wdata);
+	}
+
+	return msg;
+}
+
+static void amsg_destroy(amsg_t *msg)
+{
+	assert(!msg->destroyed);
+	msg->destroyed = true;
+	free(msg);
+}
 
 static void *default_client_data_constructor(void)
@@ -963,4 +1017,5 @@
 		
 		suseconds_t timeout;
+		unsigned int flags = SYNCH_FLAGS_NONE;
 		if (!list_empty(&timeout_list)) {
 			awaiter_t *waiter = list_get_instance(
@@ -973,17 +1028,30 @@
 				futex_up(&async_futex);
 				handle_expired_timeouts();
-				continue;
-			} else
+				/*
+				 * Notice that even if the event(s) already
+				 * expired (and thus the other fibril was
+				 * supposed to be running already),
+				 * we check for incoming IPC.
+				 *
+				 * Otherwise, a fibril that continuously
+				 * creates (almost) expired events could
+				 * prevent IPC retrieval from the kernel.
+				 */
+				timeout = 0;
+				flags = SYNCH_FLAGS_NON_BLOCKING;
+
+			} else {
 				timeout = tv_sub(&waiter->to_event.expires, &tv);
-		} else
+				futex_up(&async_futex);
+			}
+		} else {
+			futex_up(&async_futex);
 			timeout = SYNCH_NO_TIMEOUT;
-		
-		futex_up(&async_futex);
+		}
 		
 		atomic_inc(&threads_in_ipc_wait);
 		
 		ipc_call_t call;
-		ipc_callid_t callid = ipc_wait_cycle(&call, timeout,
-		    SYNCH_FLAGS_NONE);
+		ipc_callid_t callid = ipc_wait_cycle(&call, timeout, flags);
 		
 		atomic_dec(&threads_in_ipc_wait);
@@ -1100,9 +1168,13 @@
 	
 	msg->done = true;
-	if (!msg->wdata.active) {
+
+	if (msg->forget) {
+		assert(msg->wdata.active);
+		amsg_destroy(msg);
+	} else if (!msg->wdata.active) {
 		msg->wdata.active = true;
 		fibril_add_ready(msg->wdata.fid);
 	}
-	
+
 	futex_up(&async_futex);
 }
@@ -1131,17 +1203,9 @@
 		return 0;
 	
-	amsg_t *msg = malloc(sizeof(amsg_t));
+	amsg_t *msg = amsg_create();
 	if (msg == NULL)
 		return 0;
 	
-	msg->done = false;
 	msg->dataptr = dataptr;
-	
-	msg->wdata.to_event.inlist = false;
-	
-	/*
-	 * We may sleep in the next method,
-	 * but it will use its own means
-	 */
 	msg->wdata.active = true;
 	
@@ -1177,18 +1241,9 @@
 		return 0;
 	
-	amsg_t *msg = malloc(sizeof(amsg_t));
-	
+	amsg_t *msg = amsg_create();
 	if (msg == NULL)
 		return 0;
 	
-	msg->done = false;
 	msg->dataptr = dataptr;
-	
-	msg->wdata.to_event.inlist = false;
-	
-	/*
-	 * We may sleep in the next method,
-	 * but it will use its own means
-	 */
 	msg->wdata.active = true;
 	
@@ -1213,4 +1268,8 @@
 	
 	futex_down(&async_futex);
+
+	assert(!msg->forget);
+	assert(!msg->destroyed);
+
 	if (msg->done) {
 		futex_up(&async_futex);
@@ -1231,8 +1290,12 @@
 		*retval = msg->retval;
 	
-	free(msg);
+	amsg_destroy(msg);
 }
 
 /** Wait for a message sent by the async framework, timeout variant.
+ *
+ * If the wait times out, the caller may choose to either wait again by calling
+ * async_wait_for() or async_wait_timeout(), or forget the message via
+ * async_forget().
  *
  * @param amsgid  Hash of the message to wait for.
@@ -1249,10 +1312,10 @@
 	
 	amsg_t *msg = (amsg_t *) amsgid;
-	
-	/* TODO: Let it go through the event read at least once */
-	if (timeout < 0)
-		return ETIMEOUT;
-	
+
 	futex_down(&async_futex);
+
+	assert(!msg->forget);
+	assert(!msg->destroyed);
+
 	if (msg->done) {
 		futex_up(&async_futex);
@@ -1260,7 +1323,31 @@
 	}
 	
+	/*
+	 * Negative timeout is converted to zero timeout to avoid
+	 * using tv_add with negative augmenter.
+	 */
+	if (timeout < 0)
+		timeout = 0;
+
 	gettimeofday(&msg->wdata.to_event.expires, NULL);
 	tv_add(&msg->wdata.to_event.expires, timeout);
 	
+	/*
+	 * Current fibril is inserted as waiting regardless of the
+	 * "size" of the timeout.
+	 *
+	 * Checking for msg->done and immediately bailing out when
+	 * timeout == 0 would mean that the manager fibril would never
+	 * run (consider single threaded program).
+	 * Thus the IPC answer would be never retrieved from the kernel.
+	 *
+	 * Notice that the actual delay would be very small because we
+	 * - switch to manager fibril
+	 * - the manager sees expired timeout
+	 * - and thus adds us back to ready queue
+	 * - manager switches back to some ready fibril
+	 *   (prior it, it checks for incoming IPC).
+	 *
+	 */
 	msg->wdata.fid = fibril_get_id();
 	msg->wdata.active = false;
@@ -1279,8 +1366,32 @@
 		*retval = msg->retval;
 	
-	free(msg);
+	amsg_destroy(msg);
 	
 	return 0;
 }
+ 
+/** Discard the message / reply on arrival.
+ *
+ * The message will be marked to be discarded once the reply arrives in
+ * reply_received(). It is not allowed to call async_wait_for() or
+ * async_wait_timeout() on this message after a call to this function.
+ *
+ * @param amsgid  Hash of the message to forget.
+ */
+void async_forget(aid_t amsgid)
+{
+	amsg_t *msg = (amsg_t *) amsgid;
+
+	assert(msg);
+	assert(!msg->forget);
+	assert(!msg->destroyed);
+
+	futex_down(&async_futex);
+	if (msg->done)
+		amsg_destroy(msg);
+	else 
+		msg->forget = true;
+	futex_up(&async_futex);
+}
 
 /** Wait for specified time.
@@ -1293,11 +1404,9 @@
 void async_usleep(suseconds_t timeout)
 {
-	amsg_t *msg = malloc(sizeof(amsg_t));
-	
+	amsg_t *msg = amsg_create();
 	if (!msg)
 		return;
 	
 	msg->wdata.fid = fibril_get_id();
-	msg->wdata.active = false;
 	
 	gettimeofday(&msg->wdata.to_event.expires, NULL);
@@ -1313,5 +1422,5 @@
 	/* Futex is up automatically after fibril_switch() */
 	
-	free(msg);
+	amsg_destroy(msg);
 }
 
@@ -1584,6 +1693,6 @@
 	ipc_call_t result;
 	
-	amsg_t *msg = malloc(sizeof(amsg_t));
-	if (msg == NULL) {
+	amsg_t *msg = amsg_create();
+	if (!msg) {
 		free(sess);
 		errno = ENOMEM;
@@ -1591,13 +1700,5 @@
 	}
 	
-	msg->done = false;
 	msg->dataptr = &result;
-	
-	msg->wdata.to_event.inlist = false;
-	
-	/*
-	 * We may sleep in the next method,
-	 * but it will use its own means
-	 */
 	msg->wdata.active = true;
 	
@@ -1643,17 +1744,9 @@
 	ipc_call_t result;
 	
-	amsg_t *msg = malloc(sizeof(amsg_t));
-	if (msg == NULL)
+	amsg_t *msg = amsg_create();
+	if (!msg)
 		return ENOENT;
 	
-	msg->done = false;
 	msg->dataptr = &result;
-	
-	msg->wdata.to_event.inlist = false;
-	
-	/*
-	 * We may sleep in the next method,
-	 * but it will use its own means
-	 */
 	msg->wdata.active = true;
 	
@@ -2251,5 +2344,5 @@
 	    IPC_FF_ROUTE_FROM_ME);
 	if (retval != EOK) {
-		async_wait_for(msg, NULL);
+		async_forget(msg);
 		ipc_answer_0(callid, retval);
 		return retval;
@@ -2445,5 +2538,5 @@
 	    IPC_FF_ROUTE_FROM_ME);
 	if (retval != EOK) {
-		async_wait_for(msg, NULL);
+		async_forget(msg);
 		ipc_answer_0(callid, retval);
 		return retval;
Index: uspace/lib/c/generic/fibril_synch.c
===================================================================
--- uspace/lib/c/generic/fibril_synch.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/generic/fibril_synch.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -112,8 +112,7 @@
 		awaiter_t wdata;
 
+		awaiter_initialize(&wdata);
 		wdata.fid = fibril_get_id();
-		wdata.active = false;
 		wdata.wu_event.inlist = true;
-		link_initialize(&wdata.wu_event.link);
 		list_append(&wdata.wu_event.link, &fm->waiters);
 		check_for_deadlock(&fm->oi);
@@ -205,8 +204,7 @@
 		awaiter_t wdata;
 
+		awaiter_initialize(&wdata);
 		wdata.fid = (fid_t) f;
-		wdata.active = false;
 		wdata.wu_event.inlist = true;
-		link_initialize(&wdata.wu_event.link);
 		f->flags &= ~FIBRIL_WRITER;
 		list_append(&wdata.wu_event.link, &frw->waiters);
@@ -233,8 +231,7 @@
 		awaiter_t wdata;
 
+		awaiter_initialize(&wdata);
 		wdata.fid = (fid_t) f;
-		wdata.active = false;
 		wdata.wu_event.inlist = true;
-		link_initialize(&wdata.wu_event.link);
 		f->flags |= FIBRIL_WRITER;
 		list_append(&wdata.wu_event.link, &frw->waiters);
@@ -375,13 +372,8 @@
 		return ETIMEOUT;
 
+	awaiter_initialize(&wdata);
 	wdata.fid = fibril_get_id();
-	wdata.active = false;
-	
 	wdata.to_event.inlist = timeout > 0;
-	wdata.to_event.occurred = false;
-	link_initialize(&wdata.to_event.link);
-
 	wdata.wu_event.inlist = true;
-	link_initialize(&wdata.wu_event.link);
 
 	futex_down(&async_futex);
Index: uspace/lib/c/generic/io/printf_core.c
===================================================================
--- uspace/lib/c/generic/io/printf_core.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/generic/io/printf_core.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -283,5 +283,5 @@
 	/* Print leading spaces. */
 	size_t strw = str_length(str);
-	if (precision == 0)
+	if (precision == 0 || precision > strw)
 		precision = strw;
 	
@@ -331,5 +331,5 @@
 	/* Print leading spaces. */
 	size_t strw = wstr_length(str);
-	if (precision == 0)
+	if (precision == 0 || precision > strw)
 		precision = strw;
 	
Index: uspace/lib/c/generic/private/async.h
===================================================================
--- uspace/lib/c/generic/private/async.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/generic/private/async.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -81,4 +81,6 @@
 } awaiter_t;
 
+extern void awaiter_initialize(awaiter_t *);
+
 extern void __async_init(void);
 extern void async_insert_timeout(awaiter_t *);
Index: uspace/lib/c/generic/str.c
===================================================================
--- uspace/lib/c/generic/str.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/generic/str.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -46,4 +46,11 @@
 #include <mem.h>
 #include <str.h>
+
+/** Check the condition if wchar_t is signed */
+#ifdef WCHAR_IS_UNSIGNED
+	#define WCHAR_SIGNED_CHECK(cond)  (true)
+#else
+	#define WCHAR_SIGNED_CHECK(cond)  (cond)
+#endif
 
 /** Byte mask consisting of lowest @n bits (out of 8) */
@@ -261,4 +268,41 @@
 }
 
+/** Get size of string with size limit.
+ *
+ * Get the number of bytes which are used by the string @a str
+ * (excluding the NULL-terminator), but no more than @max_size bytes.
+ *
+ * @param str      String to consider.
+ * @param max_size Maximum number of bytes to measure.
+ *
+ * @return Number of bytes used by the string
+ *
+ */
+size_t str_nsize(const char *str, size_t max_size)
+{
+	size_t size = 0;
+	
+	while ((*str++ != 0) && (size < max_size))
+		size++;
+	
+	return size;
+}
+
+/** Get size of wide string with size limit.
+ *
+ * Get the number of bytes which are used by the wide string @a str
+ * (excluding the NULL-terminator), but no more than @max_size bytes.
+ *
+ * @param str      Wide string to consider.
+ * @param max_size Maximum number of bytes to measure.
+ *
+ * @return Number of bytes used by the wide string
+ *
+ */
+size_t wstr_nsize(const wchar_t *str, size_t max_size)
+{
+	return (wstr_nlength(str, max_size) * sizeof(wchar_t));
+}
+
 /** Get size of wide string with length limit.
  *
@@ -362,5 +406,5 @@
 bool ascii_check(wchar_t ch)
 {
-	if ((ch >= 0) && (ch <= 127))
+	if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127))
 		return true;
 	
@@ -375,5 +419,5 @@
 bool chr_check(wchar_t ch)
 {
-	if ((ch >= 0) && (ch <= 1114111))
+	if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111))
 		return true;
 	
@@ -476,4 +520,5 @@
  * @param count Size of the destination buffer (must be > 0).
  * @param src   Source string.
+ *
  */
 void str_cpy(char *dest, size_t size, const char *src)
@@ -508,4 +553,5 @@
  * @param src   Source string.
  * @param n     Maximum number of bytes to read from @a src.
+ *
  */
 void str_ncpy(char *dest, size_t size, const char *src, size_t n)
@@ -1498,5 +1544,5 @@
  *
  */
-int str_uint64(const char *nptr, char **endptr, unsigned int base,
+int str_uint64_t(const char *nptr, char **endptr, unsigned int base,
     bool strict, uint64_t *result)
 {
Index: uspace/lib/c/generic/sysinfo.c
===================================================================
--- uspace/lib/c/generic/sysinfo.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/generic/sysinfo.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -40,4 +40,68 @@
 #include <bool.h>
 
+/** Get sysinfo keys size
+ *
+ * @param path  Sysinfo path.
+ * @param value Pointer to store the keys size.
+ *
+ * @return EOK if the keys were successfully read.
+ *
+ */
+static int sysinfo_get_keys_size(const char *path, size_t *size)
+{
+	return (int) __SYSCALL3(SYS_SYSINFO_GET_KEYS_SIZE, (sysarg_t) path,
+	    (sysarg_t) str_size(path), (sysarg_t) size);
+}
+
+/** Get sysinfo keys
+ *
+ * @param path  Sysinfo path.
+ * @param value Pointer to store the keys size.
+ *
+ * @return Keys read from sysinfo or NULL if the
+ *         sysinfo item has no subkeys.
+ *         The returned non-NULL pointer should be
+ *         freed by free().
+ *
+ */
+char *sysinfo_get_keys(const char *path, size_t *size)
+{
+	/*
+	 * The size of the keys might change during time.
+	 * Unfortunatelly we cannot allocate the buffer
+	 * and transfer the keys as a single atomic operation.
+	 */
+	
+	/* Get the keys size */
+	int ret = sysinfo_get_keys_size(path, size);
+	if ((ret != EOK) || (size == 0)) {
+		/*
+		 * Item with no subkeys.
+		 */
+		*size = 0;
+		return NULL;
+	}
+	
+	char *data = malloc(*size);
+	if (data == NULL) {
+		*size = 0;
+		return NULL;
+	}
+	
+	/* Get the data */
+	size_t sz;
+	ret = __SYSCALL5(SYS_SYSINFO_GET_KEYS, (sysarg_t) path,
+	    (sysarg_t) str_size(path), (sysarg_t) data, (sysarg_t) *size,
+	    (sysarg_t) &sz);
+	if (ret == EOK) {
+		*size = sz;
+		return data;
+	}
+	
+	free(data);
+	*size = 0;
+	return NULL;
+}
+
 /** Get sysinfo item type
  *
@@ -70,6 +134,6 @@
 /** Get sysinfo binary data size
  *
- * @param path  Sysinfo path.
- * @param value Pointer to store the binary data size.
+ * @param path Sysinfo path.
+ * @param size Pointer to store the binary data size.
  *
  * @return EOK if the value was successfully read and
@@ -85,6 +149,6 @@
 /** Get sysinfo binary data
  *
- * @param path  Sysinfo path.
- * @param value Pointer to store the binary data size.
+ * @param path Sysinfo path.
+ * @param size Pointer to store the binary data size.
  *
  * @return Binary data read from sysinfo or NULL if the
@@ -134,4 +198,67 @@
 }
 
+/** Get sysinfo property
+ *
+ * @param path Sysinfo path.
+ * @param name Property name.
+ * @param size Pointer to store the binary data size.
+ *
+ * @return Property value read from sysinfo or NULL if the
+ *         sysinfo item value type is not binary data.
+ *         The returned non-NULL pointer should be
+ *         freed by free().
+ *
+ */
+void *sysinfo_get_property(const char *path, const char *name, size_t *size)
+{
+	size_t total_size;
+	void *data = sysinfo_get_data(path, &total_size);
+	if ((data == NULL) || (total_size == 0)) {
+		*size = 0;
+		return NULL;
+	}
+	
+	size_t pos = 0;
+	while (pos < total_size) {
+		/* Process each property with sanity checks */
+		size_t cur_size = str_nsize(data + pos, total_size - pos);
+		if (((char *) data)[pos + cur_size] != 0)
+			break;
+		
+		bool found = (str_cmp(data + pos, name) == 0);
+		
+		pos += cur_size + 1;
+		if (pos >= total_size)
+			break;
+		
+		/* Process value size */
+		size_t value_size;
+		memcpy(&value_size, data + pos, sizeof(value_size));
+		
+		pos += sizeof(value_size);
+		if ((pos >= total_size) || (pos + value_size > total_size))
+			break;
+		
+		if (found) {
+			void *value = malloc(value_size);
+			if (value == NULL)
+				break;
+			
+			memcpy(value, data + pos, value_size);
+			free(data);
+			
+			*size = value_size;
+			return value;
+		}
+		
+		pos += value_size;
+	}
+	
+	free(data);
+	
+	*size = 0;
+	return NULL;
+}
+
 /** @}
  */
Index: uspace/lib/c/include/async.h
===================================================================
--- uspace/lib/c/include/async.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/include/async.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -139,4 +139,5 @@
 extern void async_wait_for(aid_t, sysarg_t *);
 extern int async_wait_timeout(aid_t, sysarg_t *, suseconds_t);
+extern void async_forget(aid_t);
 
 extern fid_t async_new_connection(task_id_t, sysarg_t, ipc_callid_t,
Index: uspace/lib/c/include/fibril.h
===================================================================
--- uspace/lib/c/include/fibril.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/include/fibril.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -41,7 +41,9 @@
 
 #define context_set_generic(c, _pc, stack, size, ptls) \
-	(c)->pc = (sysarg_t) (_pc); \
-	(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
-	(c)->tls = (sysarg_t) (ptls);
+	do { \
+		(c)->pc = (sysarg_t) (_pc); \
+		(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
+		(c)->tls = (sysarg_t) (ptls); \
+	} while (0)
 
 #define FIBRIL_SERIALIZED  1
Index: uspace/lib/c/include/str.h
===================================================================
--- uspace/lib/c/include/str.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/include/str.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -61,4 +61,7 @@
 extern size_t wstr_size(const wchar_t *str);
 
+extern size_t str_nsize(const char *str, size_t max_size);
+extern size_t wstr_nsize(const wchar_t *str, size_t max_size);
+
 extern size_t str_lsize(const char *str, size_t max_len);
 extern size_t wstr_lsize(const wchar_t *str, size_t max_len);
@@ -103,5 +106,5 @@
 extern int str_uint16_t(const char *, char **, unsigned int, bool, uint16_t *);
 extern int str_uint32_t(const char *, char **, unsigned int, bool, uint32_t *);
-extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *);
+extern int str_uint64_t(const char *, char **, unsigned int, bool, uint64_t *);
 extern int str_size_t(const char *, char **, unsigned int, bool, size_t *);
 
Index: uspace/lib/c/include/sysinfo.h
===================================================================
--- uspace/lib/c/include/sysinfo.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/c/include/sysinfo.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -40,7 +40,9 @@
 #include <abi/sysinfo.h>
 
+extern char *sysinfo_get_keys(const char *, size_t *);
 extern sysinfo_item_val_type_t sysinfo_get_val_type(const char *);
 extern int sysinfo_get_value(const char *, sysarg_t *);
 extern void *sysinfo_get_data(const char *, size_t *);
+extern void *sysinfo_get_property(const char *, const char *, size_t *);
 
 #endif
Index: uspace/lib/drv/generic/interrupt.c
===================================================================
--- uspace/lib/drv/generic/interrupt.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/drv/generic/interrupt.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -68,4 +68,6 @@
 
 static irq_code_t default_pseudocode = {
+	0,
+	NULL,
 	sizeof(default_cmds) / sizeof(irq_cmd_t),
 	default_cmds
Index: uspace/lib/softfloat/Makefile
===================================================================
--- uspace/lib/softfloat/Makefile	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/Makefile	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -29,5 +29,5 @@
 
 USPACE_PREFIX = ../..
-EXTRA_CFLAGS = -Iinclude -Iarch/$(UARCH)/include/
+EXTRA_CFLAGS = -Iinclude
 LIBRARY = libsoftfloat
 
Index: pace/lib/softfloat/arch/abs32le/include/functions.h
===================================================================
--- uspace/lib/softfloat/arch/abs32le/include/functions.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Copyright (c) 2010 Martin Decky
- * Copyright (c) 2011 Petr Koupy
- * 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 softfloatabs32le abs32le
- * @ingroup sfl
- * @brief softfloat architecture dependent definitions
- * @{
- */
-/** @file
- */
-
-#ifndef __SOFTFLOAT_FUNCTIONS_H__
-#define __SOFTFLOAT_FUNCTIONS_H__
-
-#define float32_to_int(X) float32_to_int32(X);
-#define float32_to_long(X) float32_to_int32(X);
-#define float32_to_longlong(X) float32_to_int64(X);
-
-#define float64_to_int(X) float64_to_int32(X);
-#define float64_to_long(X) float64_to_int32(X);
-#define float64_to_longlong(X) float64_to_int64(X);
-
-#define float128_to_int(X) float128_to_int32(X);
-#define float128_to_long(X) float128_to_int32(X);
-#define float128_to_longlong(X) float128_to_int64(X);
-
-#define float32_to_uint(X) float32_to_uint32(X);
-#define float32_to_ulong(X) float32_to_uint32(X);
-#define float32_to_ulonglong(X) float32_to_uint64(X);
-
-#define float64_to_uint(X) float64_to_uint32(X);
-#define float64_to_ulong(X) float64_to_uint32(X);
-#define float64_to_ulonglong(X) float64_to_uint64(X);
-
-#define float128_to_uint(X) float128_to_uint32(X);
-#define float128_to_ulong(X) float128_to_uint32(X);
-#define float128_to_ulonglong(X) float128_to_uint64(X);
-
-#define int_to_float32(X) int32_to_float32(X);
-#define long_to_float32(X) int32_to_float32(X);
-#define longlong_to_float32(X) int64_to_float32(X);
-
-#define int_to_float64(X) int32_to_float64(X);
-#define long_to_float64(X) int32_to_float64(X);
-#define longlong_to_float64(X) int64_to_float64(X);
-
-#define int_to_float128(X) int32_to_float128(X);
-#define long_to_float128(X) int32_to_float128(X);
-#define longlong_to_float128(X) int64_to_float128(X);
-
-#define uint_to_float32(X) uint32_to_float32(X);
-#define ulong_to_float32(X) uint32_to_float32(X);
-#define ulonglong_to_float32(X) uint64_to_float32(X);
-
-#define uint_to_float64(X) uint32_to_float64(X);
-#define ulong_to_float64(X) uint32_to_float64(X);
-#define ulonglong_to_float64(X) uint64_to_float64(X);
-
-#define uint_to_float128(X) uint32_to_float128(X);
-#define ulong_to_float128(X) uint32_to_float128(X);
-#define ulonglong_to_float128(X) uint64_to_float128(X);
-
-#endif
-
-/** @}
- */
Index: pace/lib/softfloat/arch/amd64/include/functions.h
===================================================================
--- uspace/lib/softfloat/arch/amd64/include/functions.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * Copyright (c) 2011 Petr Koupy
- * 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 softfloatamd64 amd64	
- * @ingroup sfl 
- * @brief softfloat architecture dependent definitions 
- * @{
- */
-/** @file
- */
-
-#ifndef __SOFTFLOAT_FUNCTIONS_H__
-#define __SOFTFLOAT_FUNCTIONS_H__
-
-#define float32_to_int(X) float32_to_int32(X);
-#define float32_to_long(X) float32_to_int64(X);
-#define float32_to_longlong(X) float32_to_int64(X);
-
-#define float64_to_int(X) float64_to_int32(X);
-#define float64_to_long(X) float64_to_int64(X);
-#define float64_to_longlong(X) float64_to_int64(X);
-
-#define float128_to_int(X) float128_to_int32(X);
-#define float128_to_long(X) float128_to_int64(X);
-#define float128_to_longlong(X) float128_to_int64(X);
-
-#define float32_to_uint(X) float32_to_uint32(X);
-#define float32_to_ulong(X) float32_to_uint64(X);
-#define float32_to_ulonglong(X) float32_to_uint64(X);
-
-#define float64_to_uint(X) float64_to_uint32(X);
-#define float64_to_ulong(X) float64_to_uint64(X);
-#define float64_to_ulonglong(X) float64_to_uint64(X);
-
-#define float128_to_uint(X) float128_to_uint32(X);
-#define float128_to_ulong(X) float128_to_uint64(X);
-#define float128_to_ulonglong(X) float128_to_uint64(X);
-
-#define int_to_float32(X) int32_to_float32(X);
-#define long_to_float32(X) int64_to_float32(X);
-#define longlong_to_float32(X) int64_to_float32(X);
-
-#define int_to_float64(X) int32_to_float64(X);
-#define long_to_float64(X) int64_to_float64(X);
-#define longlong_to_float64(X) int64_to_float64(X);
-
-#define int_to_float128(X) int32_to_float128(X);
-#define long_to_float128(X) int64_to_float128(X);
-#define longlong_to_float128(X) int64_to_float128(X);
-
-#define uint_to_float32(X) uint32_to_float32(X);
-#define ulong_to_float32(X) uint64_to_float32(X);
-#define ulonglong_to_float32(X) uint64_to_float32(X);
-
-#define uint_to_float64(X) uint32_to_float64(X);
-#define ulong_to_float64(X) uint64_to_float64(X);
-#define ulonglong_to_float64(X) uint64_to_float64(X);
-
-#define uint_to_float128(X) uint32_to_float128(X);
-#define ulong_to_float128(X) uint64_to_float128(X);
-#define ulonglong_to_float128(X) uint64_to_float128(X);
-
-#endif
-
-/** @}
- */
Index: pace/lib/softfloat/arch/arm32/include/functions.h
===================================================================
--- uspace/lib/softfloat/arch/arm32/include/functions.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * Copyright (c) 2011 Petr Koupy
- * 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 softfloatarm32 arm32	
- * @ingroup sfl
- * @brief Softfloat architecture dependent definitions.
- * @{
- */
-/** @file 
- */
-
-#ifndef __SOFTFLOAT_FUNCTIONS_H__
-#define __SOFTFLOAT_FUNCTIONS_H__
-
-#define float32_to_int(X) float32_to_int32(X);
-#define float32_to_long(X) float32_to_int32(X);
-#define float32_to_longlong(X) float32_to_int64(X);
-
-#define float64_to_int(X) float64_to_int32(X);
-#define float64_to_long(X) float64_to_int32(X);
-#define float64_to_longlong(X) float64_to_int64(X);
-
-#define float128_to_int(X) float128_to_int32(X);
-#define float128_to_long(X) float128_to_int32(X);
-#define float128_to_longlong(X) float128_to_int64(X);
-
-#define float32_to_uint(X) float32_to_uint32(X);
-#define float32_to_ulong(X) float32_to_uint32(X);
-#define float32_to_ulonglong(X) float32_to_uint64(X);
-
-#define float64_to_uint(X) float64_to_uint32(X);
-#define float64_to_ulong(X) float64_to_uint32(X);
-#define float64_to_ulonglong(X) float64_to_uint64(X);
-
-#define float128_to_uint(X) float128_to_uint32(X);
-#define float128_to_ulong(X) float128_to_uint32(X);
-#define float128_to_ulonglong(X) float128_to_uint64(X);
-
-#define int_to_float32(X) int32_to_float32(X);
-#define long_to_float32(X) int32_to_float32(X);
-#define longlong_to_float32(X) int64_to_float32(X);
-
-#define int_to_float64(X) int32_to_float64(X);
-#define long_to_float64(X) int32_to_float64(X);
-#define longlong_to_float64(X) int64_to_float64(X);
-
-#define int_to_float128(X) int32_to_float128(X);
-#define long_to_float128(X) int32_to_float128(X);
-#define longlong_to_float128(X) int64_to_float128(X);
-
-#define uint_to_float32(X) uint32_to_float32(X);
-#define ulong_to_float32(X) uint32_to_float32(X);
-#define ulonglong_to_float32(X) uint64_to_float32(X);
-
-#define uint_to_float64(X) uint32_to_float64(X);
-#define ulong_to_float64(X) uint32_to_float64(X);
-#define ulonglong_to_float64(X) uint64_to_float64(X);
-
-#define uint_to_float128(X) uint32_to_float128(X);
-#define ulong_to_float128(X) uint32_to_float128(X);
-#define ulonglong_to_float128(X) uint64_to_float128(X);
-
-#endif
-
-/** @}
- */
Index: pace/lib/softfloat/arch/ia32/include/functions.h
===================================================================
--- uspace/lib/softfloat/arch/ia32/include/functions.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * Copyright (c) 2011 Petr Koupy
- * 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 softfloatia32 ia32	
- * @ingroup sfl
- * @brief softfloat architecture dependent definitions 
- * @{
- */
-/** @file
- */
-
-#ifndef __SOFTFLOAT_FUNCTIONS_H__
-#define __SOFTFLOAT_FUNCTIONS_H__
-
-#define float32_to_int(X) float32_to_int32(X);
-#define float32_to_long(X) float32_to_int32(X);
-#define float32_to_longlong(X) float32_to_int64(X);
-
-#define float64_to_int(X) float64_to_int32(X);
-#define float64_to_long(X) float64_to_int32(X);
-#define float64_to_longlong(X) float64_to_int64(X);
-
-#define float128_to_int(X) float128_to_int32(X);
-#define float128_to_long(X) float128_to_int32(X);
-#define float128_to_longlong(X) float128_to_int64(X);
-
-#define float32_to_uint(X) float32_to_uint32(X);
-#define float32_to_ulong(X) float32_to_uint32(X);
-#define float32_to_ulonglong(X) float32_to_uint64(X);
-
-#define float64_to_uint(X) float64_to_uint32(X);
-#define float64_to_ulong(X) float64_to_uint32(X);
-#define float64_to_ulonglong(X) float64_to_uint64(X);
-
-#define float128_to_uint(X) float128_to_uint32(X);
-#define float128_to_ulong(X) float128_to_uint32(X);
-#define float128_to_ulonglong(X) float128_to_uint64(X);
-
-#define int_to_float32(X) int32_to_float32(X);
-#define long_to_float32(X) int32_to_float32(X);
-#define longlong_to_float32(X) int64_to_float32(X);
-
-#define int_to_float64(X) int32_to_float64(X);
-#define long_to_float64(X) int32_to_float64(X);
-#define longlong_to_float64(X) int64_to_float64(X);
-
-#define int_to_float128(X) int32_to_float128(X);
-#define long_to_float128(X) int32_to_float128(X);
-#define longlong_to_float128(X) int64_to_float128(X);
-
-#define uint_to_float32(X) uint32_to_float32(X);
-#define ulong_to_float32(X) uint32_to_float32(X);
-#define ulonglong_to_float32(X) uint64_to_float32(X);
-
-#define uint_to_float64(X) uint32_to_float64(X);
-#define ulong_to_float64(X) uint32_to_float64(X);
-#define ulonglong_to_float64(X) uint64_to_float64(X);
-
-#define uint_to_float128(X) uint32_to_float128(X);
-#define ulong_to_float128(X) uint32_to_float128(X);
-#define ulonglong_to_float128(X) uint64_to_float128(X);
-
-#endif
-
-/** @}
- */
Index: pace/lib/softfloat/arch/ia64/include/functions.h
===================================================================
--- uspace/lib/softfloat/arch/ia64/include/functions.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * Copyright (c) 2011 Petr Koupy
- * 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 softfloatia64 ia64
- * @ingroup sfl 
- * @brief softfloat architecture dependent definitions 
- * @{
- */
-/** @file
- */
-
-#ifndef __SOFTFLOAT_FUNCTIONS_H__
-#define __SOFTFLOAT_FUNCTIONS_H__
-
-#define float32_to_int(X) float32_to_int32(X);
-#define float32_to_long(X) float32_to_int64(X);
-#define float32_to_longlong(X) float32_to_int64(X);
-
-#define float64_to_int(X) float64_to_int32(X);
-#define float64_to_long(X) float64_to_int64(X);
-#define float64_to_longlong(X) float64_to_int64(X);
-
-#define float128_to_int(X) float128_to_int32(X);
-#define float128_to_long(X) float128_to_int64(X);
-#define float128_to_longlong(X) float128_to_int64(X);
-
-#define float32_to_uint(X) float32_to_uint32(X);
-#define float32_to_ulong(X) float32_to_uint64(X);
-#define float32_to_ulonglong(X) float32_to_uint64(X);
-
-#define float64_to_uint(X) float64_to_uint32(X);
-#define float64_to_ulong(X) float64_to_uint64(X);
-#define float64_to_ulonglong(X) float64_to_uint64(X);
-
-#define float128_to_uint(X) float128_to_uint32(X);
-#define float128_to_ulong(X) float128_to_uint64(X);
-#define float128_to_ulonglong(X) float128_to_uint64(X);
-
-#define int_to_float32(X) int32_to_float32(X);
-#define long_to_float32(X) int64_to_float32(X);
-#define longlong_to_float32(X) int64_to_float32(X);
-
-#define int_to_float64(X) int32_to_float64(X);
-#define long_to_float64(X) int64_to_float64(X);
-#define longlong_to_float64(X) int64_to_float64(X);
-
-#define int_to_float128(X) int32_to_float128(X);
-#define long_to_float128(X) int64_to_float128(X);
-#define longlong_to_float128(X) int64_to_float128(X);
-
-#define uint_to_float32(X) uint32_to_float32(X);
-#define ulong_to_float32(X) uint64_to_float32(X);
-#define ulonglong_to_float32(X) uint64_to_float32(X);
-
-#define uint_to_float64(X) uint32_to_float64(X);
-#define ulong_to_float64(X) uint64_to_float64(X);
-#define ulonglong_to_float64(X) uint64_to_float64(X);
-
-#define uint_to_float128(X) uint32_to_float128(X);
-#define ulong_to_float128(X) uint64_to_float128(X);
-#define ulonglong_to_float128(X) uint64_to_float128(X);
-
-#endif
-
- /** @}
- */
Index: pace/lib/softfloat/arch/mips32/include/functions.h
===================================================================
--- uspace/lib/softfloat/arch/mips32/include/functions.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * Copyright (c) 2011 Petr Koupy
- * 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 softfloatmips32 mips32
- * @ingroup sfl
- * @brief softfloat architecture dependent definitions 
- * @{
- */
-/** @file
- */
-
-#ifndef __SOFTFLOAT_FUNCTIONS_H__
-#define __SOFTFLOAT_FUNCTIONS_H__
-
-#define float32_to_int(X) float32_to_int32(X);
-#define float32_to_long(X) float32_to_int32(X);
-#define float32_to_longlong(X) float32_to_int64(X);
-
-#define float64_to_int(X) float64_to_int32(X);
-#define float64_to_long(X) float64_to_int32(X);
-#define float64_to_longlong(X) float64_to_int64(X);
-
-#define float128_to_int(X) float128_to_int32(X);
-#define float128_to_long(X) float128_to_int32(X);
-#define float128_to_longlong(X) float128_to_int64(X);
-
-#define float32_to_uint(X) float32_to_uint32(X);
-#define float32_to_ulong(X) float32_to_uint32(X);
-#define float32_to_ulonglong(X) float32_to_uint64(X);
-
-#define float64_to_uint(X) float64_to_uint32(X);
-#define float64_to_ulong(X) float64_to_uint32(X);
-#define float64_to_ulonglong(X) float64_to_uint64(X);
-
-#define float128_to_uint(X) float128_to_uint32(X);
-#define float128_to_ulong(X) float128_to_uint32(X);
-#define float128_to_ulonglong(X) float128_to_uint64(X);
-
-#define int_to_float32(X) int32_to_float32(X);
-#define long_to_float32(X) int32_to_float32(X);
-#define longlong_to_float32(X) int64_to_float32(X);
-
-#define int_to_float64(X) int32_to_float64(X);
-#define long_to_float64(X) int32_to_float64(X);
-#define longlong_to_float64(X) int64_to_float64(X);
-
-#define int_to_float128(X) int32_to_float128(X);
-#define long_to_float128(X) int32_to_float128(X);
-#define longlong_to_float128(X) int64_to_float128(X);
-
-#define uint_to_float32(X) uint32_to_float32(X);
-#define ulong_to_float32(X) uint32_to_float32(X);
-#define ulonglong_to_float32(X) uint64_to_float32(X);
-
-#define uint_to_float64(X) uint32_to_float64(X);
-#define ulong_to_float64(X) uint32_to_float64(X);
-#define ulonglong_to_float64(X) uint64_to_float64(X);
-
-#define uint_to_float128(X) uint32_to_float128(X);
-#define ulong_to_float128(X) uint32_to_float128(X);
-#define ulonglong_to_float128(X) uint64_to_float128(X);
-
-#endif
-
-/** @}
- */
Index: pace/lib/softfloat/arch/mips32eb/include/functions.h
===================================================================
--- uspace/lib/softfloat/arch/mips32eb/include/functions.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * Copyright (c) 2011 Petr Koupy
- * 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 softfloatmipseb32 mipseb32	
- * @ingroup sfl
- * @brief softfloat architecture dependent definitions 
- * * @{
- */
-/** @file
- */
-
-#ifndef __SOFTFLOAT_FUNCTIONS_H__
-#define __SOFTFLOAT_FUNCTIONS_H__
-
-#define float32_to_int(X) float32_to_int32(X);
-#define float32_to_long(X) float32_to_int32(X);
-#define float32_to_longlong(X) float32_to_int64(X);
-
-#define float64_to_int(X) float64_to_int32(X);
-#define float64_to_long(X) float64_to_int32(X);
-#define float64_to_longlong(X) float64_to_int64(X);
-
-#define float128_to_int(X) float128_to_int32(X);
-#define float128_to_long(X) float128_to_int32(X);
-#define float128_to_longlong(X) float128_to_int64(X);
-
-#define float32_to_uint(X) float32_to_uint32(X);
-#define float32_to_ulong(X) float32_to_uint32(X);
-#define float32_to_ulonglong(X) float32_to_uint64(X);
-
-#define float64_to_uint(X) float64_to_uint32(X);
-#define float64_to_ulong(X) float64_to_uint32(X);
-#define float64_to_ulonglong(X) float64_to_uint64(X);
-
-#define float128_to_uint(X) float128_to_uint32(X);
-#define float128_to_ulong(X) float128_to_uint32(X);
-#define float128_to_ulonglong(X) float128_to_uint64(X);
-
-#define int_to_float32(X) int32_to_float32(X);
-#define long_to_float32(X) int32_to_float32(X);
-#define longlong_to_float32(X) int64_to_float32(X);
-
-#define int_to_float64(X) int32_to_float64(X);
-#define long_to_float64(X) int32_to_float64(X);
-#define longlong_to_float64(X) int64_to_float64(X);
-
-#define int_to_float128(X) int32_to_float128(X);
-#define long_to_float128(X) int32_to_float128(X);
-#define longlong_to_float128(X) int64_to_float128(X);
-
-#define uint_to_float32(X) uint32_to_float32(X);
-#define ulong_to_float32(X) uint32_to_float32(X);
-#define ulonglong_to_float32(X) uint64_to_float32(X);
-
-#define uint_to_float64(X) uint32_to_float64(X);
-#define ulong_to_float64(X) uint32_to_float64(X);
-#define ulonglong_to_float64(X) uint64_to_float64(X);
-
-#define uint_to_float128(X) uint32_to_float128(X);
-#define ulong_to_float128(X) uint32_to_float128(X);
-#define ulonglong_to_float128(X) uint64_to_float128(X);
-
-#endif
-
- /** @}
- */
Index: pace/lib/softfloat/arch/mips64/include/functions.h
===================================================================
--- uspace/lib/softfloat/arch/mips64/include/functions.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * Copyright (c) 2011 Petr Koupy
- * 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 softfloatmips64 mips64
- * @ingroup sfl
- * @brief softfloat architecture dependent definitions
- * @{
- */
-/** @file
- */
-
-#ifndef __SOFTFLOAT_FUNCTIONS_H__
-#define __SOFTFLOAT_FUNCTIONS_H__
-
-#define float32_to_int(X) float32_to_int32(X);
-#define float32_to_long(X) float32_to_int64(X);
-#define float32_to_longlong(X) float32_to_int64(X);
-
-#define float64_to_int(X) float64_to_int32(X);
-#define float64_to_long(X) float64_to_int64(X);
-#define float64_to_longlong(X) float64_to_int64(X);
-
-#define float128_to_int(X) float128_to_int32(X);
-#define float128_to_long(X) float128_to_int64(X);
-#define float128_to_longlong(X) float128_to_int64(X);
-
-#define float32_to_uint(X) float32_to_uint32(X);
-#define float32_to_ulong(X) float32_to_uint64(X);
-#define float32_to_ulonglong(X) float32_to_uint64(X);
-
-#define float64_to_uint(X) float64_to_uint32(X);
-#define float64_to_ulong(X) float64_to_uint64(X);
-#define float64_to_ulonglong(X) float64_to_uint64(X);
-
-#define float128_to_uint(X) float128_to_uint32(X);
-#define float128_to_ulong(X) float128_to_uint64(X);
-#define float128_to_ulonglong(X) float128_to_uint64(X);
-
-#define int_to_float32(X) int32_to_float32(X);
-#define long_to_float32(X) int64_to_float32(X);
-#define longlong_to_float32(X) int64_to_float32(X);
-
-#define int_to_float64(X) int32_to_float64(X);
-#define long_to_float64(X) int64_to_float64(X);
-#define longlong_to_float64(X) int64_to_float64(X);
-
-#define int_to_float128(X) int32_to_float128(X);
-#define long_to_float128(X) int64_to_float128(X);
-#define longlong_to_float128(X) int64_to_float128(X);
-
-#define uint_to_float32(X) uint32_to_float32(X);
-#define ulong_to_float32(X) uint64_to_float32(X);
-#define ulonglong_to_float32(X) uint64_to_float32(X);
-
-#define uint_to_float64(X) uint32_to_float64(X);
-#define ulong_to_float64(X) uint64_to_float64(X);
-#define ulonglong_to_float64(X) uint64_to_float64(X);
-
-#define uint_to_float128(X) uint32_to_float128(X);
-#define ulong_to_float128(X) uint64_to_float128(X);
-#define ulonglong_to_float128(X) uint64_to_float128(X);
-
-#endif
-
-/** @}
- */
Index: pace/lib/softfloat/arch/ppc32/include/functions.h
===================================================================
--- uspace/lib/softfloat/arch/ppc32/include/functions.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * Copyright (c) 2011 Petr Koupy
- * 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 softfloatppc32 ppc32	
- * @ingroup sfl
- * @brief softfloat architecture dependent definitions 
- * @{
- */
-/** @file
- */
-
-#ifndef __SOFTFLOAT_FUNCTIONS_H__
-#define __SOFTFLOAT_FUNCTIONS_H__
-
-#define float32_to_int(X) float32_to_int32(X);
-#define float32_to_long(X) float32_to_int32(X);
-#define float32_to_longlong(X) float32_to_int64(X);
-
-#define float64_to_int(X) float64_to_int32(X);
-#define float64_to_long(X) float64_to_int32(X);
-#define float64_to_longlong(X) float64_to_int64(X);
-
-#define float128_to_int(X) float128_to_int32(X);
-#define float128_to_long(X) float128_to_int32(X);
-#define float128_to_longlong(X) float128_to_int64(X);
-
-#define float32_to_uint(X) float32_to_uint32(X);
-#define float32_to_ulong(X) float32_to_uint32(X);
-#define float32_to_ulonglong(X) float32_to_uint64(X);
-
-#define float64_to_uint(X) float64_to_uint32(X);
-#define float64_to_ulong(X) float64_to_uint32(X);
-#define float64_to_ulonglong(X) float64_to_uint64(X);
-
-#define float128_to_uint(X) float128_to_uint32(X);
-#define float128_to_ulong(X) float128_to_uint32(X);
-#define float128_to_ulonglong(X) float128_to_uint64(X);
-
-#define int_to_float32(X) int32_to_float32(X);
-#define long_to_float32(X) int32_to_float32(X);
-#define longlong_to_float32(X) int64_to_float32(X);
-
-#define int_to_float64(X) int32_to_float64(X);
-#define long_to_float64(X) int32_to_float64(X);
-#define longlong_to_float64(X) int64_to_float64(X);
-
-#define int_to_float128(X) int32_to_float128(X);
-#define long_to_float128(X) int32_to_float128(X);
-#define longlong_to_float128(X) int64_to_float128(X);
-
-#define uint_to_float32(X) uint32_to_float32(X);
-#define ulong_to_float32(X) uint32_to_float32(X);
-#define ulonglong_to_float32(X) uint64_to_float32(X);
-
-#define uint_to_float64(X) uint32_to_float64(X);
-#define ulong_to_float64(X) uint32_to_float64(X);
-#define ulonglong_to_float64(X) uint64_to_float64(X);
-
-#define uint_to_float128(X) uint32_to_float128(X);
-#define ulong_to_float128(X) uint32_to_float128(X);
-#define ulonglong_to_float128(X) uint64_to_float128(X);
-
-#endif
-
- /** @}
- */
Index: pace/lib/softfloat/arch/sparc64/include/functions.h
===================================================================
--- uspace/lib/softfloat/arch/sparc64/include/functions.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ 	(revision )
@@ -1,94 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * Copyright (c) 2011 Petr Koupy
- * 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 softfloatsparc64 sparc64	
- * @ingroup sfl
- * @brief softfloat architecture dependent definitions 
- * @{
- */
-/** @file
- */
-
-#ifndef __SOFTFLOAT_FUNCTIONS_H__
-#define __SOFTFLOAT_FUNCTIONS_H__
-
-#define SPARC_SOFTFLOAT
-
-#define float32_to_int(X) float32_to_int32(X);
-#define float32_to_long(X) float32_to_int64(X);
-#define float32_to_longlong(X) float32_to_int64(X);
-
-#define float64_to_int(X) float64_to_int32(X);
-#define float64_to_long(X) float64_to_int64(X);
-#define float64_to_longlong(X) float64_to_int64(X);
-
-#define float128_to_int(X) float128_to_int32(X);
-#define float128_to_long(X) float128_to_int64(X);
-#define float128_to_longlong(X) float128_to_int64(X);
-
-#define float32_to_uint(X) float32_to_uint32(X);
-#define float32_to_ulong(X) float32_to_uint64(X);
-#define float32_to_ulonglong(X) float32_to_uint64(X);
-
-#define float64_to_uint(X) float64_to_uint32(X);
-#define float64_to_ulong(X) float64_to_uint64(X);
-#define float64_to_ulonglong(X) float64_to_uint64(X);
-
-#define float128_to_uint(X) float128_to_uint32(X);
-#define float128_to_ulong(X) float128_to_uint64(X);
-#define float128_to_ulonglong(X) float128_to_uint64(X);
-
-#define int_to_float32(X) int32_to_float32(X);
-#define long_to_float32(X) int64_to_float32(X);
-#define longlong_to_float32(X) int64_to_float32(X);
-
-#define int_to_float64(X) int32_to_float64(X);
-#define long_to_float64(X) int64_to_float64(X);
-#define longlong_to_float64(X) int64_to_float64(X);
-
-#define int_to_float128(X) int32_to_float128(X);
-#define long_to_float128(X) int64_to_float128(X);
-#define longlong_to_float128(X) int64_to_float128(X);
-
-#define uint_to_float32(X) uint32_to_float32(X);
-#define ulong_to_float32(X) uint64_to_float32(X);
-#define ulonglong_to_float32(X) uint64_to_float32(X);
-
-#define uint_to_float64(X) uint32_to_float64(X);
-#define ulong_to_float64(X) uint64_to_float64(X);
-#define ulonglong_to_float64(X) uint64_to_float64(X);
-
-#define uint_to_float128(X) uint32_to_float128(X);
-#define ulong_to_float128(X) uint64_to_float128(X);
-#define ulonglong_to_float128(X) uint64_to_float128(X);
-
-#endif
-
- /** @}
- */
Index: uspace/lib/softfloat/generic/add.c
===================================================================
--- uspace/lib/softfloat/generic/add.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/generic/add.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -39,6 +39,5 @@
 #include <common.h>
 
-/**
- * Add two single-precision floats with the same signs.
+/** Add two single-precision floats with the same sign.
  *
  * @param a First input operand.
@@ -46,5 +45,5 @@
  * @return Result of addition.
  */
-float32 addFloat32(float32 a, float32 b)
+float32 add_float32(float32 a, float32 b)
 {
 	int expdiff;
@@ -53,7 +52,7 @@
 	expdiff = a.parts.exp - b.parts.exp;
 	if (expdiff < 0) {
-		if (isFloat32NaN(b)) {
-			/* TODO: fix SigNaN */
-			if (isFloat32SigNaN(b)) {
+		if (is_float32_nan(b)) {
+			/* TODO: fix SigNaN */
+			if (is_float32_signan(b)) {
 			}
 
@@ -71,9 +70,9 @@
 		expdiff *= -1;
 	} else {
-		if ((isFloat32NaN(a)) || (isFloat32NaN(b))) {
-			/* TODO: fix SigNaN */
-			if (isFloat32SigNaN(a) || isFloat32SigNaN(b)) {
-			}
-			return (isFloat32NaN(a) ? a : b);
+		if ((is_float32_nan(a)) || (is_float32_nan(b))) {
+			/* TODO: fix SigNaN */
+			if (is_float32_signan(a) || is_float32_signan(b)) {
+			}
+			return (is_float32_nan(a) ? a : b);
 		}
 		
@@ -150,6 +149,5 @@
 }
 
-/**
- * Add two double-precision floats with the same signs.
+/** Add two double-precision floats with the same sign.
  *
  * @param a First input operand.
@@ -157,5 +155,5 @@
  * @return Result of addition.
  */
-float64 addFloat64(float64 a, float64 b)
+float64 add_float64(float64 a, float64 b)
 {
 	int expdiff;
@@ -165,14 +163,14 @@
 	expdiff = ((int) a.parts.exp) - b.parts.exp;
 	if (expdiff < 0) {
-		if (isFloat64NaN(b)) {
-			/* TODO: fix SigNaN */
-			if (isFloat64SigNaN(b)) {
-			}
-
-			return b;
-		}
-		
-		/* b is infinity and a not */	
-		if (b.parts.exp == FLOAT64_MAX_EXPONENT) { 
+		if (is_float64_nan(b)) {
+			/* TODO: fix SigNaN */
+			if (is_float64_signan(b)) {
+			}
+
+			return b;
+		}
+		
+		/* b is infinity and a not */
+		if (b.parts.exp == FLOAT64_MAX_EXPONENT) {
 			return b;
 		}
@@ -184,7 +182,7 @@
 		expdiff *= -1;
 	} else {
-		if (isFloat64NaN(a)) {
-			/* TODO: fix SigNaN */
-			if (isFloat64SigNaN(a) || isFloat64SigNaN(b)) {
+		if (is_float64_nan(a)) {
+			/* TODO: fix SigNaN */
+			if (is_float64_signan(a) || is_float64_signan(b)) {
 			}
 			return a;
@@ -265,6 +263,5 @@
 }
 
-/**
- * Add two quadruple-precision floats with the same signs.
+/** Add two quadruple-precision floats with the same sign.
  *
  * @param a First input operand.
@@ -272,5 +269,5 @@
  * @return Result of addition.
  */
-float128 addFloat128(float128 a, float128 b)
+float128 add_float128(float128 a, float128 b)
 {
 	int expdiff;
@@ -280,7 +277,7 @@
 	expdiff = ((int) a.parts.exp) - b.parts.exp;
 	if (expdiff < 0) {
-		if (isFloat128NaN(b)) {
-			/* TODO: fix SigNaN */
-			if (isFloat128SigNaN(b)) {
+		if (is_float128_nan(b)) {
+			/* TODO: fix SigNaN */
+			if (is_float128_signan(b)) {
 			}
 
@@ -301,7 +298,7 @@
 		expdiff *= -1;
 	} else {
-		if (isFloat128NaN(a)) {
-			/* TODO: fix SigNaN */
-			if (isFloat128SigNaN(a) || isFloat128SigNaN(b)) {
+		if (is_float128_nan(a)) {
+			/* TODO: fix SigNaN */
+			if (is_float128_signan(a) || is_float128_signan(b)) {
 			}
 			return a;
Index: uspace/lib/softfloat/generic/common.c
===================================================================
--- uspace/lib/softfloat/generic/common.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/generic/common.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -66,5 +66,5 @@
  * @return Finished double-precision float.
  */
-float64 finishFloat64(int32_t cexp, uint64_t cfrac, char sign)
+float64 finish_float64(int32_t cexp, uint64_t cfrac, char sign)
 {
 	float64 result;
@@ -140,5 +140,5 @@
  * @return Finished quadruple-precision float.
  */
-float128 finishFloat128(int32_t cexp, uint64_t cfrac_hi, uint64_t cfrac_lo, 
+float128 finish_float128(int32_t cexp, uint64_t cfrac_hi, uint64_t cfrac_lo, 
     char sign, uint64_t shift_out)
 {
@@ -238,5 +238,5 @@
  * @return Number of detected leading zeroes.
  */
-int countZeroes8(uint8_t i)
+int count_zeroes8(uint8_t i)
 {
 	return zeroTable[i];
@@ -249,10 +249,10 @@
  * @return Number of detected leading zeroes.
  */
-int countZeroes32(uint32_t i)
+int count_zeroes32(uint32_t i)
 {
 	int j;
 	for (j = 0; j < 32; j += 8) {
 		if (i & (0xFF << (24 - j))) {
-			return (j + countZeroes8(i >> (24 - j)));
+			return (j + count_zeroes8(i >> (24 - j)));
 		}
 	}
@@ -267,10 +267,10 @@
  * @return Number of detected leading zeroes.
  */
-int countZeroes64(uint64_t i)
+int count_zeroes64(uint64_t i)
 {
 	int j;
 	for (j = 0; j < 64; j += 8) {
 		if (i & (0xFFll << (56 - j))) {
-			return (j + countZeroes8(i >> (56 - j)));
+			return (j + count_zeroes8(i >> (56 - j)));
 		}
 	}
@@ -286,5 +286,5 @@
  * @param fraction Fraction with hidden bit shifted to 30th bit.
  */
-void roundFloat32(int32_t *exp, uint32_t *fraction)
+void round_float32(int32_t *exp, uint32_t *fraction)
 {
 	/* rounding - if first bit after fraction is set then round up */
@@ -312,5 +312,5 @@
  * @param fraction Fraction with hidden bit shifted to 62nd bit.
  */
-void roundFloat64(int32_t *exp, uint64_t *fraction)
+void round_float64(int32_t *exp, uint64_t *fraction)
 {
 	/* rounding - if first bit after fraction is set then round up */
@@ -339,5 +339,5 @@
  * @param frac_lo Low part of fraction part with hidden bit shifted to 126th bit.
  */
-void roundFloat128(int32_t *exp, uint64_t *frac_hi, uint64_t *frac_lo)
+void round_float128(int32_t *exp, uint64_t *frac_hi, uint64_t *frac_lo)
 {
 	uint64_t tmp_hi, tmp_lo;
Index: uspace/lib/softfloat/generic/comparison.c
===================================================================
--- uspace/lib/softfloat/generic/comparison.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/generic/comparison.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -45,5 +45,5 @@
  * @return 1 if float is NaN, 0 otherwise.
  */
-int isFloat32NaN(float32 f)
+int is_float32_nan(float32 f)
 {
 	/* NaN : exp = 0xff and nonzero fraction */
@@ -58,5 +58,5 @@
  * @return 1 if float is NaN, 0 otherwise.
  */
-int isFloat64NaN(float64 d)
+int is_float64_nan(float64 d)
 {
 	/* NaN : exp = 0x7ff and nonzero fraction */
@@ -71,5 +71,5 @@
  * @return 1 if float is NaN, 0 otherwise.
  */
-int isFloat128NaN(float128 ld)
+int is_float128_nan(float128 ld)
 {
 	/* NaN : exp = 0x7fff and nonzero fraction */
@@ -84,5 +84,5 @@
  * @return 1 if float is signalling NaN, 0 otherwise.
  */
-int isFloat32SigNaN(float32 f)
+int is_float32_signan(float32 f)
 {
 	/* SigNaN : exp = 0xff and fraction = 0xxxxx..x (binary),
@@ -98,5 +98,5 @@
  * @return 1 if float is signalling NaN, 0 otherwise.
  */
-int isFloat64SigNaN(float64 d)
+int is_float64_signan(float64 d)
 {
 	/* SigNaN : exp = 0x7ff and fraction = 0xxxxx..x (binary),
@@ -112,5 +112,5 @@
  * @return 1 if float is signalling NaN, 0 otherwise.
  */
-int isFloat128SigNaN(float128 ld)
+int is_float128_signan(float128 ld)
 {
 	/* SigNaN : exp = 0x7fff and fraction = 0xxxxx..x (binary),
@@ -128,5 +128,5 @@
  * @return 1 if float is infinite, 0 otherwise.
  */
-int isFloat32Infinity(float32 f)
+int is_float32_infinity(float32 f)
 {
 	/* NaN : exp = 0x7ff and zero fraction */
@@ -140,5 +140,5 @@
  * @return 1 if float is infinite, 0 otherwise.
  */
-int isFloat64Infinity(float64 d) 
+int is_float64_infinity(float64 d)
 {
 	/* NaN : exp = 0x7ff and zero fraction */
@@ -152,5 +152,5 @@
  * @return 1 if float is infinite, 0 otherwise.
  */
-int isFloat128Infinity(float128 ld)
+int is_float128_infinity(float128 ld)
 {
 	/* NaN : exp = 0x7fff and zero fraction */
@@ -165,7 +165,7 @@
  * @return 1 if float is zero, 0 otherwise.
  */
-int isFloat32Zero(float32 f)
-{
-	return (((f.binary) & 0x7FFFFFFF) == 0);
+int is_float32_zero(float32 f)
+{
+	return (((f.bin) & 0x7FFFFFFF) == 0);
 }
 
@@ -176,7 +176,7 @@
  * @return 1 if float is zero, 0 otherwise.
  */
-int isFloat64Zero(float64 d)
-{
-	return (((d.binary) & 0x7FFFFFFFFFFFFFFFll) == 0);
+int is_float64_zero(float64 d)
+{
+	return (((d.bin) & 0x7FFFFFFFFFFFFFFFll) == 0);
 }
 
@@ -187,12 +187,12 @@
  * @return 1 if float is zero, 0 otherwise.
  */
-int isFloat128Zero(float128 ld)
+int is_float128_zero(float128 ld)
 {
 	uint64_t tmp_hi;
 	uint64_t tmp_lo;
-
-	and128(ld.binary.hi, ld.binary.lo,
+	
+	and128(ld.bin.hi, ld.bin.lo,
 	    0x7FFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, &tmp_hi, &tmp_lo);
-
+	
 	return eq128(tmp_hi, tmp_lo, 0x0ll, 0x0ll);
 }
@@ -205,9 +205,9 @@
  * @return 1 if both floats are equal, 0 otherwise.
  */
-int isFloat32eq(float32 a, float32 b)
+int is_float32_eq(float32 a, float32 b)
 {
 	/* a equals to b or both are zeros (with any sign) */
-	return ((a.binary == b.binary) ||
-	    (((a.binary | b.binary) & 0x7FFFFFFF) == 0));
+	return ((a.bin == b.bin) ||
+	    (((a.bin | b.bin) & 0x7FFFFFFF) == 0));
 }
 
@@ -219,9 +219,9 @@
  * @return 1 if both floats are equal, 0 otherwise.
  */
-int isFloat64eq(float64 a, float64 b)
+int is_float64_eq(float64 a, float64 b)
 {
 	/* a equals to b or both are zeros (with any sign) */
-	return ((a.binary == b.binary) ||
-	    (((a.binary | b.binary) & 0x7FFFFFFFFFFFFFFFll) == 0));
+	return ((a.bin == b.bin) ||
+	    (((a.bin | b.bin) & 0x7FFFFFFFFFFFFFFFll) == 0));
 }
 
@@ -233,12 +233,12 @@
  * @return 1 if both floats are equal, 0 otherwise.
  */
-int isFloat128eq(float128 a, float128 b)
+int is_float128_eq(float128 a, float128 b)
 {
 	uint64_t tmp_hi;
 	uint64_t tmp_lo;
-
+	
 	/* both are zeros (with any sign) */
-	or128(a.binary.hi, a.binary.lo,
-	    b.binary.hi, b.binary.lo, &tmp_hi, &tmp_lo);
+	or128(a.bin.hi, a.bin.lo,
+	    b.bin.hi, b.bin.lo, &tmp_hi, &tmp_lo);
 	and128(tmp_hi, tmp_lo,
 	    0x7FFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, &tmp_hi, &tmp_lo);
@@ -246,6 +246,6 @@
 	
 	/* a equals to b */
-	int are_equal = eq128(a.binary.hi, a.binary.lo, b.binary.hi, b.binary.lo);
-
+	int are_equal = eq128(a.bin.hi, a.bin.lo, b.bin.hi, b.bin.lo);
+	
 	return are_equal || both_zero;
 }
@@ -258,20 +258,24 @@
  * @return 1 if a is lower than b, 0 otherwise.
  */
-int isFloat32lt(float32 a, float32 b) 
-{
-	if (((a.binary | b.binary) & 0x7FFFFFFF) == 0) {
-		return 0; /* +- zeroes */
+int is_float32_lt(float32 a, float32 b) 
+{
+	if (((a.bin | b.bin) & 0x7FFFFFFF) == 0) {
+		/* +- zeroes */
+		return 0;
 	}
 	
 	if ((a.parts.sign) && (b.parts.sign)) {
 		/* if both are negative, smaller is that with greater binary value */
-		return (a.binary > b.binary);
-	}
-	
-	/* lets negate signs - now will be positive numbers allways bigger than
-	 * negative (first bit will be set for unsigned integer comparison) */
-	a.parts.sign = !a.parts.sign;
-	b.parts.sign = !b.parts.sign;
-	return (a.binary < b.binary);
+		return (a.bin > b.bin);
+	}
+	
+	/*
+	 * lets negate signs - now will be positive numbers always
+	 * bigger than negative (first bit will be set for unsigned
+	 * integer comparison)
+	 */
+	a.parts.sign = !a.parts.sign;
+	b.parts.sign = !b.parts.sign;
+	return (a.bin < b.bin);
 }
 
@@ -283,20 +287,24 @@
  * @return 1 if a is lower than b, 0 otherwise.
  */
-int isFloat64lt(float64 a, float64 b)
-{
-	if (((a.binary | b.binary) & 0x7FFFFFFFFFFFFFFFll) == 0) {
-		return 0; /* +- zeroes */
-	}
-
+int is_float64_lt(float64 a, float64 b)
+{
+	if (((a.bin | b.bin) & 0x7FFFFFFFFFFFFFFFll) == 0) {
+		/* +- zeroes */
+		return 0;
+	}
+	
 	if ((a.parts.sign) && (b.parts.sign)) {
 		/* if both are negative, smaller is that with greater binary value */
-		return (a.binary > b.binary);
-	}
-
-	/* lets negate signs - now will be positive numbers allways bigger than
-	 * negative (first bit will be set for unsigned integer comparison) */
-	a.parts.sign = !a.parts.sign;
-	b.parts.sign = !b.parts.sign;
-	return (a.binary < b.binary);
+		return (a.bin > b.bin);
+	}
+	
+	/*
+	 * lets negate signs - now will be positive numbers always
+	 * bigger than negative (first bit will be set for unsigned
+	 * integer comparison)
+	 */
+	a.parts.sign = !a.parts.sign;
+	b.parts.sign = !b.parts.sign;
+	return (a.bin < b.bin);
 }
 
@@ -308,27 +316,31 @@
  * @return 1 if a is lower than b, 0 otherwise.
  */
-int isFloat128lt(float128 a, float128 b)
+int is_float128_lt(float128 a, float128 b)
 {
 	uint64_t tmp_hi;
 	uint64_t tmp_lo;
-
-	or128(a.binary.hi, a.binary.lo,
-	    b.binary.hi, b.binary.lo, &tmp_hi, &tmp_lo);
+	
+	or128(a.bin.hi, a.bin.lo,
+	    b.bin.hi, b.bin.lo, &tmp_hi, &tmp_lo);
 	and128(tmp_hi, tmp_lo,
 	    0x7FFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, &tmp_hi, &tmp_lo);
 	if (eq128(tmp_hi, tmp_lo, 0x0ll, 0x0ll)) {
-		return 0; /* +- zeroes */
-	}
-
+		/* +- zeroes */
+		return 0;
+	}
+	
 	if ((a.parts.sign) && (b.parts.sign)) {
 		/* if both are negative, smaller is that with greater binary value */
-		return lt128(b.binary.hi, b.binary.lo, a.binary.hi, a.binary.lo);
-	}
-
-	/* lets negate signs - now will be positive numbers allways bigger than
-	 * negative (first bit will be set for unsigned integer comparison) */
-	a.parts.sign = !a.parts.sign;
-	b.parts.sign = !b.parts.sign;
-	return lt128(a.binary.hi, a.binary.lo, b.binary.hi, b.binary.lo);
+		return lt128(b.bin.hi, b.bin.lo, a.bin.hi, a.bin.lo);
+	}
+	
+	/*
+	 * lets negate signs - now will be positive numbers always
+	 * bigger than negative (first bit will be set for unsigned
+	 * integer comparison)
+	 */
+	a.parts.sign = !a.parts.sign;
+	b.parts.sign = !b.parts.sign;
+	return lt128(a.bin.hi, a.bin.lo, b.bin.hi, b.bin.lo);
 }
 
@@ -340,20 +352,24 @@
  * @return 1 if a is greater than b, 0 otherwise.
  */
-int isFloat32gt(float32 a, float32 b) 
-{
-	if (((a.binary | b.binary) & 0x7FFFFFFF) == 0) {
-		return 0; /* zeroes are equal with any sign */
+int is_float32_gt(float32 a, float32 b) 
+{
+	if (((a.bin | b.bin) & 0x7FFFFFFF) == 0) {
+		/* zeroes are equal with any sign */
+		return 0;
 	}
 	
 	if ((a.parts.sign) && (b.parts.sign)) {
 		/* if both are negative, greater is that with smaller binary value */
-		return (a.binary < b.binary);
-	}
-	
-	/* lets negate signs - now will be positive numbers allways bigger than
-	 *  negative (first bit will be set for unsigned integer comparison) */
-	a.parts.sign = !a.parts.sign;
-	b.parts.sign = !b.parts.sign;
-	return (a.binary > b.binary);
+		return (a.bin < b.bin);
+	}
+	
+	/*
+	 * lets negate signs - now will be positive numbers always
+	 * bigger than negative (first bit will be set for unsigned
+	 * integer comparison)
+	 */
+	a.parts.sign = !a.parts.sign;
+	b.parts.sign = !b.parts.sign;
+	return (a.bin > b.bin);
 }
 
@@ -365,20 +381,24 @@
  * @return 1 if a is greater than b, 0 otherwise.
  */
-int isFloat64gt(float64 a, float64 b)
-{
-	if (((a.binary | b.binary) & 0x7FFFFFFFFFFFFFFFll) == 0) {
-		return 0; /* zeroes are equal with any sign */
-	}
-
+int is_float64_gt(float64 a, float64 b)
+{
+	if (((a.bin | b.bin) & 0x7FFFFFFFFFFFFFFFll) == 0) {
+		/* zeroes are equal with any sign */
+		return 0;
+	}
+	
 	if ((a.parts.sign) && (b.parts.sign)) {
 		/* if both are negative, greater is that with smaller binary value */
-		return (a.binary < b.binary);
-	}
-
-	/* lets negate signs - now will be positive numbers allways bigger than
-	 *  negative (first bit will be set for unsigned integer comparison) */
-	a.parts.sign = !a.parts.sign;
-	b.parts.sign = !b.parts.sign;
-	return (a.binary > b.binary);
+		return (a.bin < b.bin);
+	}
+	
+	/*
+	 * lets negate signs - now will be positive numbers always
+	 * bigger than negative (first bit will be set for unsigned
+	 * integer comparison)
+	 */
+	a.parts.sign = !a.parts.sign;
+	b.parts.sign = !b.parts.sign;
+	return (a.bin > b.bin);
 }
 
@@ -390,27 +410,31 @@
  * @return 1 if a is greater than b, 0 otherwise.
  */
-int isFloat128gt(float128 a, float128 b)
+int is_float128_gt(float128 a, float128 b)
 {
 	uint64_t tmp_hi;
 	uint64_t tmp_lo;
-
-	or128(a.binary.hi, a.binary.lo,
-	    b.binary.hi, b.binary.lo, &tmp_hi, &tmp_lo);
+	
+	or128(a.bin.hi, a.bin.lo,
+	    b.bin.hi, b.bin.lo, &tmp_hi, &tmp_lo);
 	and128(tmp_hi, tmp_lo,
 	    0x7FFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, &tmp_hi, &tmp_lo);
 	if (eq128(tmp_hi, tmp_lo, 0x0ll, 0x0ll)) {
-		return 0; /* zeroes are equal with any sign */
-	}
-
+		/* zeroes are equal with any sign */
+		return 0;
+	}
+	
 	if ((a.parts.sign) && (b.parts.sign)) {
 		/* if both are negative, greater is that with smaller binary value */
-		return lt128(a.binary.hi, a.binary.lo, b.binary.hi, b.binary.lo);
-	}
-
-	/* lets negate signs - now will be positive numbers allways bigger than
-	 *  negative (first bit will be set for unsigned integer comparison) */
-	a.parts.sign = !a.parts.sign;
-	b.parts.sign = !b.parts.sign;
-	return lt128(b.binary.hi, b.binary.lo, a.binary.hi, a.binary.lo);
+		return lt128(a.bin.hi, a.bin.lo, b.bin.hi, b.bin.lo);
+	}
+	
+	/*
+	 * lets negate signs - now will be positive numbers always
+	 * bigger than negative (first bit will be set for unsigned
+	 * integer comparison)
+	 */
+	a.parts.sign = !a.parts.sign;
+	b.parts.sign = !b.parts.sign;
+	return lt128(b.bin.hi, b.bin.lo, a.bin.hi, a.bin.lo);
 }
 
Index: uspace/lib/softfloat/generic/conversion.c
===================================================================
--- uspace/lib/softfloat/generic/conversion.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/generic/conversion.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -39,5 +39,5 @@
 #include <common.h>
 
-float64 convertFloat32ToFloat64(float32 a) 
+float64 float32_to_float64(float32 a)
 {
 	float64 result;
@@ -48,7 +48,7 @@
 	result.parts.fraction <<= (FLOAT64_FRACTION_SIZE - FLOAT32_FRACTION_SIZE);
 	
-	if ((isFloat32Infinity(a)) || (isFloat32NaN(a))) {
+	if ((is_float32_infinity(a)) || (is_float32_nan(a))) {
 		result.parts.exp = FLOAT64_MAX_EXPONENT;
-		/* TODO; check if its correct for SigNaNs*/
+		// TODO; check if its correct for SigNaNs
 		return result;
 	}
@@ -57,5 +57,5 @@
 	if (a.parts.exp == 0) {
 		/* normalize denormalized numbers */
-
+		
 		if (result.parts.fraction == 0) { /* fix zero */
 			result.parts.exp = 0;
@@ -77,10 +77,10 @@
 }
 
-float128 convertFloat32ToFloat128(float32 a)
+float128 float32_to_float128(float32 a)
 {
 	float128 result;
 	uint64_t frac_hi, frac_lo;
 	uint64_t tmp_hi, tmp_lo;
-
+	
 	result.parts.sign = a.parts.sign;
 	result.parts.frac_hi = 0;
@@ -91,15 +91,15 @@
 	result.parts.frac_hi = frac_hi;
 	result.parts.frac_lo = frac_lo;
-
-	if ((isFloat32Infinity(a)) || (isFloat32NaN(a))) {
+	
+	if ((is_float32_infinity(a)) || (is_float32_nan(a))) {
 		result.parts.exp = FLOAT128_MAX_EXPONENT;
-		/* TODO; check if its correct for SigNaNs*/
-		return result;
-	}
-
+		// TODO; check if its correct for SigNaNs
+		return result;
+	}
+	
 	result.parts.exp = a.parts.exp + ((int) FLOAT128_BIAS - FLOAT32_BIAS);
 	if (a.parts.exp == 0) {
 		/* normalize denormalized numbers */
-
+		
 		if (eq128(result.parts.frac_hi,
 		    result.parts.frac_lo, 0x0ll, 0x0ll)) { /* fix zero */
@@ -107,8 +107,8 @@
 			return result;
 		}
-
+		
 		frac_hi = result.parts.frac_hi;
 		frac_lo = result.parts.frac_lo;
-
+		
 		and128(frac_hi, frac_lo,
 		    FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO,
@@ -118,19 +118,19 @@
 			--result.parts.exp;
 		}
-
+		
 		++result.parts.exp;
 		result.parts.frac_hi = frac_hi;
 		result.parts.frac_lo = frac_lo;
 	}
-
-	return result;
-}
-
-float128 convertFloat64ToFloat128(float64 a)
+	
+	return result;
+}
+
+float128 float64_to_float128(float64 a)
 {
 	float128 result;
 	uint64_t frac_hi, frac_lo;
 	uint64_t tmp_hi, tmp_lo;
-
+	
 	result.parts.sign = a.parts.sign;
 	result.parts.frac_hi = 0;
@@ -141,15 +141,15 @@
 	result.parts.frac_hi = frac_hi;
 	result.parts.frac_lo = frac_lo;
-
-	if ((isFloat64Infinity(a)) || (isFloat64NaN(a))) {
+	
+	if ((is_float64_infinity(a)) || (is_float64_nan(a))) {
 		result.parts.exp = FLOAT128_MAX_EXPONENT;
-		/* TODO; check if its correct for SigNaNs*/
-		return result;
-	}
-
+		// TODO; check if its correct for SigNaNs
+		return result;
+	}
+	
 	result.parts.exp = a.parts.exp + ((int) FLOAT128_BIAS - FLOAT64_BIAS);
 	if (a.parts.exp == 0) {
 		/* normalize denormalized numbers */
-
+		
 		if (eq128(result.parts.frac_hi,
 		    result.parts.frac_lo, 0x0ll, 0x0ll)) { /* fix zero */
@@ -157,8 +157,8 @@
 			return result;
 		}
-
+		
 		frac_hi = result.parts.frac_hi;
 		frac_lo = result.parts.frac_lo;
-
+		
 		and128(frac_hi, frac_lo,
 		    FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO,
@@ -168,14 +168,14 @@
 			--result.parts.exp;
 		}
-
+		
 		++result.parts.exp;
 		result.parts.frac_hi = frac_hi;
 		result.parts.frac_lo = frac_lo;
 	}
-
-	return result;
-}
-
-float32 convertFloat64ToFloat32(float64 a) 
+	
+	return result;
+}
+
+float32 float64_to_float32(float64 a)
 {
 	float32 result;
@@ -185,24 +185,24 @@
 	result.parts.sign = a.parts.sign;
 	
-	if (isFloat64NaN(a)) {
+	if (is_float64_nan(a)) {
 		result.parts.exp = FLOAT32_MAX_EXPONENT;
 		
-		if (isFloat64SigNaN(a)) {
+		if (is_float64_signan(a)) {
 			/* set first bit of fraction nonzero */
 			result.parts.fraction = FLOAT32_HIDDEN_BIT_MASK >> 1;
 			return result;
 		}
-
+		
 		/* fraction nonzero but its first bit is zero */
 		result.parts.fraction = 0x1;
 		return result;
 	}
-
-	if (isFloat64Infinity(a)) {
+	
+	if (is_float64_infinity(a)) {
 		result.parts.fraction = 0;
 		result.parts.exp = FLOAT32_MAX_EXPONENT;
 		return result;
 	}
-
+	
 	exp = (int) a.parts.exp - FLOAT64_BIAS + FLOAT32_BIAS;
 	
@@ -239,5 +239,5 @@
 		return result;
 	}
-
+	
 	result.parts.exp = exp;
 	result.parts.fraction =
@@ -246,34 +246,34 @@
 }
 
-float32 convertFloat128ToFloat32(float128 a)
+float32 float128_to_float32(float128 a)
 {
 	float32 result;
 	int32_t exp;
 	uint64_t frac_hi, frac_lo;
-
+	
 	result.parts.sign = a.parts.sign;
-
-	if (isFloat128NaN(a)) {
+	
+	if (is_float128_nan(a)) {
 		result.parts.exp = FLOAT32_MAX_EXPONENT;
-
-		if (isFloat128SigNaN(a)) {
+		
+		if (is_float128_signan(a)) {
 			/* set first bit of fraction nonzero */
 			result.parts.fraction = FLOAT32_HIDDEN_BIT_MASK >> 1;
 			return result;
 		}
-
+		
 		/* fraction nonzero but its first bit is zero */
 		result.parts.fraction = 0x1;
 		return result;
 	}
-
-	if (isFloat128Infinity(a)) {
+	
+	if (is_float128_infinity(a)) {
 		result.parts.fraction = 0;
 		result.parts.exp = FLOAT32_MAX_EXPONENT;
 		return result;
 	}
-
+	
 	exp = (int) a.parts.exp - FLOAT128_BIAS + FLOAT32_BIAS;
-
+	
 	if (exp >= FLOAT32_MAX_EXPONENT) {
 		/* FIXME: overflow */
@@ -283,7 +283,7 @@
 	} else if (exp <= 0) {
 		/* underflow or denormalized */
-
+		
 		result.parts.exp = 0;
-
+		
 		exp *= -1;
 		if (exp > FLOAT32_FRACTION_SIZE) {
@@ -292,17 +292,17 @@
 			return result;
 		}
-
+		
 		/* denormalized */
-
+		
 		frac_hi = a.parts.frac_hi;
 		frac_lo = a.parts.frac_lo;
-
+		
 		/* denormalize and set hidden bit */
 		frac_hi |= FLOAT128_HIDDEN_BIT_MASK_HI;
-
+		
 		rshift128(frac_hi, frac_lo,
 		    (FLOAT128_FRACTION_SIZE - FLOAT32_FRACTION_SIZE + 1),
 		    &frac_hi, &frac_lo);
-
+		
 		while (exp > 0) {
 			--exp;
@@ -310,8 +310,8 @@
 		}
 		result.parts.fraction = frac_lo;
-
-		return result;
-	}
-
+		
+		return result;
+	}
+	
 	result.parts.exp = exp;
 	frac_hi = a.parts.frac_hi;
@@ -324,34 +324,34 @@
 }
 
-float64 convertFloat128ToFloat64(float128 a)
+float64 float128_to_float64(float128 a)
 {
 	float64 result;
 	int32_t exp;
 	uint64_t frac_hi, frac_lo;
-
+	
 	result.parts.sign = a.parts.sign;
-
-	if (isFloat128NaN(a)) {
+	
+	if (is_float128_nan(a)) {
 		result.parts.exp = FLOAT64_MAX_EXPONENT;
-
-		if (isFloat128SigNaN(a)) {
+		
+		if (is_float128_signan(a)) {
 			/* set first bit of fraction nonzero */
 			result.parts.fraction = FLOAT64_HIDDEN_BIT_MASK >> 1;
 			return result;
 		}
-
+		
 		/* fraction nonzero but its first bit is zero */
 		result.parts.fraction = 0x1;
 		return result;
 	}
-
-	if (isFloat128Infinity(a)) {
+	
+	if (is_float128_infinity(a)) {
 		result.parts.fraction = 0;
 		result.parts.exp = FLOAT64_MAX_EXPONENT;
 		return result;
 	}
-
+	
 	exp = (int) a.parts.exp - FLOAT128_BIAS + FLOAT64_BIAS;
-
+	
 	if (exp >= FLOAT64_MAX_EXPONENT) {
 		/* FIXME: overflow */
@@ -361,7 +361,7 @@
 	} else if (exp <= 0) {
 		/* underflow or denormalized */
-
+		
 		result.parts.exp = 0;
-
+		
 		exp *= -1;
 		if (exp > FLOAT64_FRACTION_SIZE) {
@@ -370,17 +370,17 @@
 			return result;
 		}
-
+		
 		/* denormalized */
-
+		
 		frac_hi = a.parts.frac_hi;
 		frac_lo = a.parts.frac_lo;
-
+		
 		/* denormalize and set hidden bit */
 		frac_hi |= FLOAT128_HIDDEN_BIT_MASK_HI;
-
+		
 		rshift128(frac_hi, frac_lo,
 		    (FLOAT128_FRACTION_SIZE - FLOAT64_FRACTION_SIZE + 1),
 		    &frac_hi, &frac_lo);
-
+		
 		while (exp > 0) {
 			--exp;
@@ -388,8 +388,8 @@
 		}
 		result.parts.fraction = frac_lo;
-
-		return result;
-	}
-
+		
+		return result;
+	}
+	
 	result.parts.exp = exp;
 	frac_hi = a.parts.frac_hi;
@@ -402,7 +402,5 @@
 }
 
-
-/** 
- * Helping procedure for converting float32 to uint32.
+/** Helper procedure for converting float32 to uint32.
  *
  * @param a Floating point number in normalized form
@@ -424,5 +422,5 @@
 	/* shift fraction to left so hidden bit will be the most significant bit */
 	frac <<= 32 - FLOAT32_FRACTION_SIZE - 1; 
-
+	
 	frac >>= 32 - (a.parts.exp - FLOAT32_BIAS) - 1;
 	if ((a.parts.sign == 1) && (frac != 0)) {
@@ -434,14 +432,14 @@
 }
 
-/* 
- * FIXME: Im not sure what to return if overflow/underflow happens 
- * 	- now its the biggest or the smallest int
- */ 
+/*
+ * FIXME: Im not sure what to return if overflow/underflow happens
+ *  - now its the biggest or the smallest int
+ */
 uint32_t float32_to_uint32(float32 a)
 {
-	if (isFloat32NaN(a))
+	if (is_float32_nan(a))
 		return UINT32_MAX;
 	
-	if (isFloat32Infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) {
+	if (is_float32_infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) {
 		if (a.parts.sign)
 			return UINT32_MIN;
@@ -453,14 +451,14 @@
 }
 
-/* 
- * FIXME: Im not sure what to return if overflow/underflow happens 
- * 	- now its the biggest or the smallest int
- */ 
+/*
+ * FIXME: Im not sure what to return if overflow/underflow happens
+ *  - now its the biggest or the smallest int
+ */
 int32_t float32_to_int32(float32 a)
 {
-	if (isFloat32NaN(a))
+	if (is_float32_nan(a))
 		return INT32_MAX;
 	
-	if (isFloat32Infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) {
+	if (is_float32_infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) {
 		if (a.parts.sign)
 			return INT32_MIN;
@@ -472,7 +470,5 @@
 }
 
-
-/**
- * Helping procedure for converting float32 to uint64.
+/** Helper procedure for converting float32 to uint64.
  *
  * @param a Floating point number in normalized form
@@ -483,16 +479,16 @@
 {
 	uint64_t frac;
-
+	
 	if (a.parts.exp < FLOAT32_BIAS) {
-		/*TODO: rounding*/
+		// TODO: rounding
 		return 0;
 	}
-
+	
 	frac = a.parts.fraction;
-
+	
 	frac |= FLOAT32_HIDDEN_BIT_MASK;
 	/* shift fraction to left so hidden bit will be the most significant bit */
 	frac <<= 64 - FLOAT32_FRACTION_SIZE - 1;
-
+	
 	frac >>= 64 - (a.parts.exp - FLOAT32_BIAS) - 1;
 	if ((a.parts.sign == 1) && (frac != 0)) {
@@ -500,50 +496,47 @@
 		++frac;
 	}
-
+	
 	return frac;
 }
 
-/* 
+/*
  * FIXME: Im not sure what to return if overflow/underflow happens
- * 	- now its the biggest or the smallest int
+ *  - now its the biggest or the smallest int
  */
 uint64_t float32_to_uint64(float32 a)
 {
-	if (isFloat32NaN(a))
+	if (is_float32_nan(a))
 		return UINT64_MAX;
-
-
-	if (isFloat32Infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS))) {
+	
+	if (is_float32_infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS))) {
 		if (a.parts.sign)
 			return UINT64_MIN;
-
+		
 		return UINT64_MAX;
 	}
-
+	
 	return _float32_to_uint64_helper(a);
 }
 
-/* 
+/*
  * FIXME: Im not sure what to return if overflow/underflow happens
- * 	- now its the biggest or the smallest int
+ *  - now its the biggest or the smallest int
  */
 int64_t float32_to_int64(float32 a)
 {
-	if (isFloat32NaN(a))
+	if (is_float32_nan(a))
 		return INT64_MAX;
-
-	if (isFloat32Infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS))) {
+	
+	if (is_float32_infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS))) {
 		if (a.parts.sign)
 			return INT64_MIN;
-
+		
 		return INT64_MAX;
 	}
-
+	
 	return _float32_to_uint64_helper(a);
 }
 
-
-/**
- * Helping procedure for converting float64 to uint64.
+/** Helper procedure for converting float64 to uint64.
  *
  * @param a Floating point number in normalized form
@@ -554,16 +547,16 @@
 {
 	uint64_t frac;
-
+	
 	if (a.parts.exp < FLOAT64_BIAS) {
-		/*TODO: rounding*/
+		// TODO: rounding
 		return 0;
 	}
-
+	
 	frac = a.parts.fraction;
-
+	
 	frac |= FLOAT64_HIDDEN_BIT_MASK;
 	/* shift fraction to left so hidden bit will be the most significant bit */
 	frac <<= 64 - FLOAT64_FRACTION_SIZE - 1;
-
+	
 	frac >>= 64 - (a.parts.exp - FLOAT64_BIAS) - 1;
 	if ((a.parts.sign == 1) && (frac != 0)) {
@@ -571,5 +564,5 @@
 		++frac;
 	}
-
+	
 	return frac;
 }
@@ -577,18 +570,18 @@
 /*
  * FIXME: Im not sure what to return if overflow/underflow happens
- * 	- now its the biggest or the smallest int
+ *  - now its the biggest or the smallest int
  */
 uint32_t float64_to_uint32(float64 a)
 {
-	if (isFloat64NaN(a))
+	if (is_float64_nan(a))
 		return UINT32_MAX;
-
-	if (isFloat64Infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS))) {
+	
+	if (is_float64_infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS))) {
 		if (a.parts.sign)
 			return UINT32_MIN;
-
+		
 		return UINT32_MAX;
 	}
-
+	
 	return (uint32_t) _float64_to_uint64_helper(a);
 }
@@ -596,32 +589,31 @@
 /*
  * FIXME: Im not sure what to return if overflow/underflow happens
- * 	- now its the biggest or the smallest int
+ *  - now its the biggest or the smallest int
  */
 int32_t float64_to_int32(float64 a)
 {
-	if (isFloat64NaN(a))
+	if (is_float64_nan(a))
 		return INT32_MAX;
-
-	if (isFloat64Infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS))) {
+	
+	if (is_float64_infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS))) {
 		if (a.parts.sign)
 			return INT32_MIN;
-
+		
 		return INT32_MAX;
 	}
-
+	
 	return (int32_t) _float64_to_uint64_helper(a);
 }
 
-
-/* 
+/*
  * FIXME: Im not sure what to return if overflow/underflow happens 
- * 	- now its the biggest or the smallest int
- */ 
+ *  - now its the biggest or the smallest int
+ */
 uint64_t float64_to_uint64(float64 a)
 {
-	if (isFloat64NaN(a))
+	if (is_float64_nan(a))
 		return UINT64_MAX;
 	
-	if (isFloat64Infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS))) {
+	if (is_float64_infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS))) {
 		if (a.parts.sign)
 			return UINT64_MIN;
@@ -633,14 +625,14 @@
 }
 
-/* 
+/*
  * FIXME: Im not sure what to return if overflow/underflow happens 
- * 	- now its the biggest or the smallest int
- */ 
+ *  - now its the biggest or the smallest int
+ */
 int64_t float64_to_int64(float64 a)
 {
-	if (isFloat64NaN(a))
+	if (is_float64_nan(a))
 		return INT64_MAX;
 	
-	if (isFloat64Infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS))) {
+	if (is_float64_infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS))) {
 		if (a.parts.sign)
 			return INT64_MIN;
@@ -652,7 +644,5 @@
 }
 
-
-/**
- * Helping procedure for converting float128 to uint64.
+/** Helper procedure for converting float128 to uint64.
  *
  * @param a Floating point number in normalized form
@@ -663,18 +653,18 @@
 {
 	uint64_t frac_hi, frac_lo;
-
+	
 	if (a.parts.exp < FLOAT128_BIAS) {
-		/*TODO: rounding*/
+		// TODO: rounding
 		return 0;
 	}
-
+	
 	frac_hi = a.parts.frac_hi;
 	frac_lo = a.parts.frac_lo;
-
+	
 	frac_hi |= FLOAT128_HIDDEN_BIT_MASK_HI;
 	/* shift fraction to left so hidden bit will be the most significant bit */
 	lshift128(frac_hi, frac_lo,
 	    (128 - FLOAT128_FRACTION_SIZE - 1), &frac_hi, &frac_lo);
-
+	
 	rshift128(frac_hi, frac_lo,
 	    (128 - (a.parts.exp - FLOAT128_BIAS) - 1), &frac_hi, &frac_lo);
@@ -683,5 +673,5 @@
 		add128(frac_hi, frac_lo, 0x0ll, 0x1ll, &frac_hi, &frac_lo);
 	}
-
+	
 	return frac_lo;
 }
@@ -689,18 +679,18 @@
 /*
  * FIXME: Im not sure what to return if overflow/underflow happens
- * 	- now its the biggest or the smallest int
+ *  - now its the biggest or the smallest int
  */
 uint32_t float128_to_uint32(float128 a)
 {
-	if (isFloat128NaN(a))
+	if (is_float128_nan(a))
 		return UINT32_MAX;
-
-	if (isFloat128Infinity(a) || (a.parts.exp >= (32 + FLOAT128_BIAS))) {
+	
+	if (is_float128_infinity(a) || (a.parts.exp >= (32 + FLOAT128_BIAS))) {
 		if (a.parts.sign)
 			return UINT32_MIN;
-
+		
 		return UINT32_MAX;
 	}
-
+	
 	return (uint32_t) _float128_to_uint64_helper(a);
 }
@@ -708,38 +698,37 @@
 /*
  * FIXME: Im not sure what to return if overflow/underflow happens
- * 	- now its the biggest or the smallest int
+ *  - now its the biggest or the smallest int
  */
 int32_t float128_to_int32(float128 a)
 {
-	if (isFloat128NaN(a))
+	if (is_float128_nan(a))
 		return INT32_MAX;
-
-	if (isFloat128Infinity(a) || (a.parts.exp >= (32 + FLOAT128_BIAS))) {
+	
+	if (is_float128_infinity(a) || (a.parts.exp >= (32 + FLOAT128_BIAS))) {
 		if (a.parts.sign)
 			return INT32_MIN;
-
+		
 		return INT32_MAX;
 	}
-
+	
 	return (int32_t) _float128_to_uint64_helper(a);
 }
 
-
 /*
  * FIXME: Im not sure what to return if overflow/underflow happens
- * 	- now its the biggest or the smallest int
+ *  - now its the biggest or the smallest int
  */
 uint64_t float128_to_uint64(float128 a)
 {
-	if (isFloat128NaN(a))
+	if (is_float128_nan(a))
 		return UINT64_MAX;
-
-	if (isFloat128Infinity(a) || (a.parts.exp >= (64 + FLOAT128_BIAS))) {
+	
+	if (is_float128_infinity(a) || (a.parts.exp >= (64 + FLOAT128_BIAS))) {
 		if (a.parts.sign)
 			return UINT64_MIN;
-
+		
 		return UINT64_MAX;
 	}
-
+	
 	return _float128_to_uint64_helper(a);
 }
@@ -747,21 +736,20 @@
 /*
  * FIXME: Im not sure what to return if overflow/underflow happens
- * 	- now its the biggest or the smallest int
+ *  - now its the biggest or the smallest int
  */
 int64_t float128_to_int64(float128 a)
 {
-	if (isFloat128NaN(a))
+	if (is_float128_nan(a))
 		return INT64_MAX;
-
-	if (isFloat128Infinity(a) || (a.parts.exp >= (64 + FLOAT128_BIAS))) {
+	
+	if (is_float128_infinity(a) || (a.parts.exp >= (64 + FLOAT128_BIAS))) {
 		if (a.parts.sign)
 			return INT64_MIN;
-
+		
 		return INT64_MAX;
 	}
-
+	
 	return _float128_to_uint64_helper(a);
 }
-
 
 float32 uint32_to_float32(uint32_t i)
@@ -773,11 +761,11 @@
 	result.parts.sign = 0;
 	result.parts.fraction = 0;
-
-	counter = countZeroes32(i);
-
+	
+	counter = count_zeroes32(i);
+	
 	exp = FLOAT32_BIAS + 32 - counter - 1;
 	
 	if (counter == 32) {
-		result.binary = 0;
+		result.bin = 0;
 		return result;
 	}
@@ -788,30 +776,28 @@
 		i >>= 1;
 	}
-
-	roundFloat32(&exp, &i);
-
+	
+	round_float32(&exp, &i);
+	
 	result.parts.fraction = i >> (32 - FLOAT32_FRACTION_SIZE - 2);
 	result.parts.exp = exp;
-
-	return result;
-}
-
-float32 int32_to_float32(int32_t i) 
+	
+	return result;
+}
+
+float32 int32_to_float32(int32_t i)
 {
 	float32 result;
-
-	if (i < 0) {
+	
+	if (i < 0)
 		result = uint32_to_float32((uint32_t) (-i));
-	} else {
+	else
 		result = uint32_to_float32((uint32_t) i);
-	}
 	
 	result.parts.sign = i < 0;
-
- 	return result;
-}
-
-
-float32 uint64_to_float32(uint64_t i) 
+	
+	return result;
+}
+
+float32 uint64_to_float32(uint64_t i)
 {
 	int counter;
@@ -822,11 +808,11 @@
 	result.parts.sign = 0;
 	result.parts.fraction = 0;
-
-	counter = countZeroes64(i);
-
+	
+	counter = count_zeroes64(i);
+	
 	exp = FLOAT32_BIAS + 64 - counter - 1;
 	
 	if (counter == 64) {
-		result.binary = 0;
+		result.bin = 0;
 		return result;
 	}
@@ -840,6 +826,6 @@
 	
 	j = (uint32_t) i;
-	roundFloat32(&exp, &j);
-
+	round_float32(&exp, &j);
+	
 	result.parts.fraction = j >> (32 - FLOAT32_FRACTION_SIZE - 2);
 	result.parts.exp = exp;
@@ -847,17 +833,16 @@
 }
 
-float32 int64_to_float32(int64_t i) 
+float32 int64_to_float32(int64_t i)
 {
 	float32 result;
-
-	if (i < 0) {
+	
+	if (i < 0)
 		result = uint64_to_float32((uint64_t) (-i));
-	} else {
+	else
 		result = uint64_to_float32((uint64_t) i);
-	}
 	
 	result.parts.sign = i < 0;
-
- 	return result;
+	
+	return result;
 }
 
@@ -871,42 +856,41 @@
 	result.parts.sign = 0;
 	result.parts.fraction = 0;
-
-	counter = countZeroes32(i);
-
+	
+	counter = count_zeroes32(i);
+	
 	exp = FLOAT64_BIAS + 32 - counter - 1;
 	
 	if (counter == 32) {
-		result.binary = 0;
+		result.bin = 0;
 		return result;
 	}
 	
 	frac = i;
-	frac <<= counter + 32 - 1; 
-
-	roundFloat64(&exp, &frac);
-
+	frac <<= counter + 32 - 1;
+	
+	round_float64(&exp, &frac);
+	
 	result.parts.fraction = frac >> (64 - FLOAT64_FRACTION_SIZE - 2);
 	result.parts.exp = exp;
-
-	return result;
-}
-
-float64 int32_to_float64(int32_t i) 
+	
+	return result;
+}
+
+float64 int32_to_float64(int32_t i)
 {
 	float64 result;
-
-	if (i < 0) {
+	
+	if (i < 0)
 		result = uint32_to_float64((uint32_t) (-i));
-	} else {
+	else
 		result = uint32_to_float64((uint32_t) i);
-	}
 	
 	result.parts.sign = i < 0;
-
- 	return result;
-}
-
-
-float64 uint64_to_float64(uint64_t i) 
+	
+	return result;
+}
+
+
+float64 uint64_to_float64(uint64_t i)
 {
 	int counter;
@@ -916,11 +900,11 @@
 	result.parts.sign = 0;
 	result.parts.fraction = 0;
-
-	counter = countZeroes64(i);
-
+	
+	counter = count_zeroes64(i);
+	
 	exp = FLOAT64_BIAS + 64 - counter - 1;
 	
 	if (counter == 64) {
-		result.binary = 0;
+		result.bin = 0;
 		return result;
 	}
@@ -931,7 +915,7 @@
 		i >>= 1;
 	}
-
-	roundFloat64(&exp, &i);
-
+	
+	round_float64(&exp, &i);
+	
 	result.parts.fraction = i >> (64 - FLOAT64_FRACTION_SIZE - 2);
 	result.parts.exp = exp;
@@ -939,19 +923,17 @@
 }
 
-float64 int64_to_float64(int64_t i) 
+float64 int64_to_float64(int64_t i)
 {
 	float64 result;
-
-	if (i < 0) {
+	
+	if (i < 0)
 		result = uint64_to_float64((uint64_t) (-i));
-	} else {
+	else
 		result = uint64_to_float64((uint64_t) i);
-	}
 	
 	result.parts.sign = i < 0;
-
- 	return result;
-}
-
+	
+	return result;
+}
 
 float128 uint32_to_float128(uint32_t i)
@@ -961,25 +943,25 @@
 	float128 result;
 	uint64_t frac_hi, frac_lo;
-
+	
 	result.parts.sign = 0;
 	result.parts.frac_hi = 0;
 	result.parts.frac_lo = 0;
-
-	counter = countZeroes32(i);
-
+	
+	counter = count_zeroes32(i);
+	
 	exp = FLOAT128_BIAS + 32 - counter - 1;
-
+	
 	if (counter == 32) {
-		result.binary.hi = 0;
-		result.binary.lo = 0;
-		return result;
-	}
-
+		result.bin.hi = 0;
+		result.bin.lo = 0;
+		return result;
+	}
+	
 	frac_hi = 0;
 	frac_lo = i;
 	lshift128(frac_hi, frac_lo, (counter + 96 - 1), &frac_hi, &frac_lo);
-
-	roundFloat128(&exp, &frac_hi, &frac_lo);
-
+	
+	round_float128(&exp, &frac_hi, &frac_lo);
+	
 	rshift128(frac_hi, frac_lo,
 	    (128 - FLOAT128_FRACTION_SIZE - 2), &frac_hi, &frac_lo);
@@ -987,5 +969,5 @@
 	result.parts.frac_lo = frac_lo;
 	result.parts.exp = exp;
-
+	
 	return result;
 }
@@ -994,14 +976,13 @@
 {
 	float128 result;
-
-	if (i < 0) {
+	
+	if (i < 0)
 		result = uint32_to_float128((uint32_t) (-i));
-	} else {
+	else
 		result = uint32_to_float128((uint32_t) i);
-	}
-
+	
 	result.parts.sign = i < 0;
-
- 	return result;
+	
+	return result;
 }
 
@@ -1013,25 +994,25 @@
 	float128 result;
 	uint64_t frac_hi, frac_lo;
-
+	
 	result.parts.sign = 0;
 	result.parts.frac_hi = 0;
 	result.parts.frac_lo = 0;
-
-	counter = countZeroes64(i);
-
+	
+	counter = count_zeroes64(i);
+	
 	exp = FLOAT128_BIAS + 64 - counter - 1;
-
+	
 	if (counter == 64) {
-		result.binary.hi = 0;
-		result.binary.lo = 0;
-		return result;
-	}
-
+		result.bin.hi = 0;
+		result.bin.lo = 0;
+		return result;
+	}
+	
 	frac_hi = 0;
 	frac_lo = i;
 	lshift128(frac_hi, frac_lo, (counter + 64 - 1), &frac_hi, &frac_lo);
-
-	roundFloat128(&exp, &frac_hi, &frac_lo);
-
+	
+	round_float128(&exp, &frac_hi, &frac_lo);
+	
 	rshift128(frac_hi, frac_lo,
 	    (128 - FLOAT128_FRACTION_SIZE - 2), &frac_hi, &frac_lo);
@@ -1039,5 +1020,5 @@
 	result.parts.frac_lo = frac_lo;
 	result.parts.exp = exp;
-
+	
 	return result;
 }
@@ -1046,14 +1027,13 @@
 {
 	float128 result;
-
-	if (i < 0) {
+	
+	if (i < 0)
 		result = uint64_to_float128((uint64_t) (-i));
-	} else {
+	else
 		result = uint64_to_float128((uint64_t) i);
-	}
-
+	
 	result.parts.sign = i < 0;
-
- 	return result;
+	
+	return result;
 }
 
Index: uspace/lib/softfloat/generic/div.c
===================================================================
--- uspace/lib/softfloat/generic/div.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/generic/div.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -41,12 +41,13 @@
 #include <common.h>
 
-/**
- * Divide two single-precision floats.
- * 
+/** Divide two single-precision floats.
+ *
  * @param a Nominator.
  * @param b Denominator.
+ *
  * @return Result of division.
- */
-float32 divFloat32(float32 a, float32 b) 
+ *
+ */
+float32 div_float32(float32 a, float32 b)
 {
 	float32 result;
@@ -56,24 +57,24 @@
 	result.parts.sign = a.parts.sign ^ b.parts.sign;
 	
-	if (isFloat32NaN(a)) {
-		if (isFloat32SigNaN(a)) {
-			/*FIXME: SigNaN*/
-		}
-		/*NaN*/
+	if (is_float32_nan(a)) {
+		if (is_float32_signan(a)) {
+			// FIXME: SigNaN
+		}
+		/* NaN */
 		return a;
 	}
 	
-	if (isFloat32NaN(b)) {
-		if (isFloat32SigNaN(b)) {
-			/*FIXME: SigNaN*/
-		}
-		/*NaN*/
+	if (is_float32_nan(b)) {
+		if (is_float32_signan(b)) {
+			// FIXME: SigNaN
+		}
+		/* NaN */
 		return b;
 	}
 	
-	if (isFloat32Infinity(a)) {
-		if (isFloat32Infinity(b)) {
+	if (is_float32_infinity(a)) {
+		if (is_float32_infinity(b)) {
 			/*FIXME: inf / inf */
-			result.binary = FLOAT32_NAN;
+			result.bin = FLOAT32_NAN;
 			return result;
 		}
@@ -83,7 +84,7 @@
 		return result;
 	}
-
-	if (isFloat32Infinity(b)) {
-		if (isFloat32Zero(a)) {
+	
+	if (is_float32_infinity(b)) {
+		if (is_float32_zero(a)) {
 			/* FIXME 0 / inf */
 			result.parts.exp = 0;
@@ -97,8 +98,8 @@
 	}
 	
-	if (isFloat32Zero(b)) {
-		if (isFloat32Zero(a)) {
+	if (is_float32_zero(b)) {
+		if (is_float32_zero(a)) {
 			/*FIXME: 0 / 0*/
-			result.binary = FLOAT32_NAN;
+			result.bin = FLOAT32_NAN;
 			return result;
 		}
@@ -121,8 +122,8 @@
 			return result;
 		}
-
+		
 		/* normalize it*/
 		afrac <<= 1;
-		/* afrac is nonzero => it must stop */	
+		/* afrac is nonzero => it must stop */
 		while (!(afrac & FLOAT32_HIDDEN_BIT_MASK)) {
 			afrac <<= 1;
@@ -130,8 +131,8 @@
 		}
 	}
-
+	
 	if (bexp == 0) {
 		bfrac <<= 1;
-		/* bfrac is nonzero => it must stop */	
+		/* bfrac is nonzero => it must stop */
 		while (!(bfrac & FLOAT32_HIDDEN_BIT_MASK)) {
 			bfrac <<= 1;
@@ -139,8 +140,8 @@
 		}
 	}
-
-	afrac =	(afrac | FLOAT32_HIDDEN_BIT_MASK) << (32 - FLOAT32_FRACTION_SIZE - 1);
-	bfrac =	(bfrac | FLOAT32_HIDDEN_BIT_MASK) << (32 - FLOAT32_FRACTION_SIZE);
-
+	
+	afrac = (afrac | FLOAT32_HIDDEN_BIT_MASK) << (32 - FLOAT32_FRACTION_SIZE - 1);
+	bfrac = (bfrac | FLOAT32_HIDDEN_BIT_MASK) << (32 - FLOAT32_FRACTION_SIZE);
+	
 	if (bfrac <= (afrac << 1)) {
 		afrac >>= 1;
@@ -169,6 +170,6 @@
 		++cexp;
 		cfrac >>= 1;
-	}	
-
+	}
+	
 	/* check overflow */
 	if (cexp >= FLOAT32_MAX_EXPONENT) {
@@ -178,5 +179,5 @@
 		return result;
 	}
-
+	
 	if (cexp < 0) {
 		/* FIXME: underflow */
@@ -190,5 +191,5 @@
 			cexp++;
 			cfrac >>= 1;
-		}	
+		}
 	} else {
 		result.parts.exp = (uint32_t) cexp;
@@ -197,15 +198,16 @@
 	result.parts.fraction = ((cfrac >> 6) & (~FLOAT32_HIDDEN_BIT_MASK)); 
 	
-	return result;	
+	return result;
 }
 
-/**
- * Divide two double-precision floats.
+/** Divide two double-precision floats.
  *
  * @param a Nominator.
  * @param b Denominator.
+ *
  * @return Result of division.
- */
-float64 divFloat64(float64 a, float64 b) 
+ *
+ */
+float64 div_float64(float64 a, float64 b) 
 {
 	float64 result;
@@ -217,29 +219,29 @@
 	result.parts.sign = a.parts.sign ^ b.parts.sign;
 	
-	if (isFloat64NaN(a)) {
-		if (isFloat64SigNaN(b)) {
-			/*FIXME: SigNaN*/
+	if (is_float64_nan(a)) {
+		if (is_float64_signan(b)) {
+			// FIXME: SigNaN
 			return b;
 		}
 		
-		if (isFloat64SigNaN(a)) {
-			/*FIXME: SigNaN*/
-		}
-		/*NaN*/
+		if (is_float64_signan(a)) {
+			// FIXME: SigNaN
+		}
+		/* NaN */
 		return a;
 	}
 	
-	if (isFloat64NaN(b)) {
-		if (isFloat64SigNaN(b)) {
-			/*FIXME: SigNaN*/
-		}
-		/*NaN*/
+	if (is_float64_nan(b)) {
+		if (is_float64_signan(b)) {
+			// FIXME: SigNaN
+		}
+		/* NaN */
 		return b;
 	}
 	
-	if (isFloat64Infinity(a)) {
-		if (isFloat64Infinity(b) || isFloat64Zero(b)) {
-			/*FIXME: inf / inf */
-			result.binary = FLOAT64_NAN;
+	if (is_float64_infinity(a)) {
+		if (is_float64_infinity(b) || is_float64_zero(b)) {
+			// FIXME: inf / inf
+			result.bin = FLOAT64_NAN;
 			return result;
 		}
@@ -249,7 +251,7 @@
 		return result;
 	}
-
-	if (isFloat64Infinity(b)) {
-		if (isFloat64Zero(a)) {
+	
+	if (is_float64_infinity(b)) {
+		if (is_float64_zero(a)) {
 			/* FIXME 0 / inf */
 			result.parts.exp = 0;
@@ -263,8 +265,8 @@
 	}
 	
-	if (isFloat64Zero(b)) {
-		if (isFloat64Zero(a)) {
+	if (is_float64_zero(b)) {
+		if (is_float64_zero(a)) {
 			/*FIXME: 0 / 0*/
-			result.binary = FLOAT64_NAN;
+			result.bin = FLOAT64_NAN;
 			return result;
 		}
@@ -274,5 +276,5 @@
 		return result;
 	}
-
+	
 	afrac = a.parts.fraction;
 	aexp = a.parts.exp;
@@ -287,5 +289,5 @@
 			return result;
 		}
-
+		
 		/* normalize it*/
 		aexp++;
@@ -296,5 +298,5 @@
 		}
 	}
-
+	
 	if (bexp == 0) {
 		bexp++;
@@ -305,8 +307,8 @@
 		}
 	}
-
-	afrac =	(afrac | FLOAT64_HIDDEN_BIT_MASK) << (64 - FLOAT64_FRACTION_SIZE - 2);
-	bfrac =	(bfrac | FLOAT64_HIDDEN_BIT_MASK) << (64 - FLOAT64_FRACTION_SIZE - 1);
-
+	
+	afrac = (afrac | FLOAT64_HIDDEN_BIT_MASK) << (64 - FLOAT64_FRACTION_SIZE - 2);
+	bfrac = (bfrac | FLOAT64_HIDDEN_BIT_MASK) << (64 - FLOAT64_FRACTION_SIZE - 1);
+	
 	if (bfrac <= (afrac << 1)) {
 		afrac >>= 1;
@@ -330,16 +332,17 @@
 	
 	/* round and shift */
-	result = finishFloat64(cexp, cfrac, result.parts.sign);
+	result = finish_float64(cexp, cfrac, result.parts.sign);
 	return result;
 }
 
-/**
- * Divide two quadruple-precision floats.
+/** Divide two quadruple-precision floats.
  *
  * @param a Nominator.
  * @param b Denominator.
+ *
  * @return Result of division.
- */
-float128 divFloat128(float128 a, float128 b)
+ *
+ */
+float128 div_float128(float128 a, float128 b)
 {
 	float128 result;
@@ -349,33 +352,33 @@
 	uint64_t rem_hihi, rem_hilo, rem_lohi, rem_lolo;
 	uint64_t tmp_hihi, tmp_hilo, tmp_lohi, tmp_lolo;
-
+	
 	result.parts.sign = a.parts.sign ^ b.parts.sign;
-
-	if (isFloat128NaN(a)) {
-		if (isFloat128SigNaN(b)) {
-			/*FIXME: SigNaN*/
+	
+	if (is_float128_nan(a)) {
+		if (is_float128_signan(b)) {
+			// FIXME: SigNaN
 			return b;
 		}
-
-		if (isFloat128SigNaN(a)) {
-			/*FIXME: SigNaN*/
-		}
-		/*NaN*/
+		
+		if (is_float128_signan(a)) {
+			// FIXME: SigNaN
+		}
+		/* NaN */
 		return a;
 	}
-
-	if (isFloat128NaN(b)) {
-		if (isFloat128SigNaN(b)) {
-			/*FIXME: SigNaN*/
-		}
-		/*NaN*/
+	
+	if (is_float128_nan(b)) {
+		if (is_float128_signan(b)) {
+			// FIXME: SigNaN
+		}
+		/* NaN */
 		return b;
 	}
-
-	if (isFloat128Infinity(a)) {
-		if (isFloat128Infinity(b) || isFloat128Zero(b)) {
-			/*FIXME: inf / inf */
-			result.binary.hi = FLOAT128_NAN_HI;
-			result.binary.lo = FLOAT128_NAN_LO;
+	
+	if (is_float128_infinity(a)) {
+		if (is_float128_infinity(b) || is_float128_zero(b)) {
+			// FIXME: inf / inf
+			result.bin.hi = FLOAT128_NAN_HI;
+			result.bin.lo = FLOAT128_NAN_LO;
 			return result;
 		}
@@ -386,8 +389,8 @@
 		return result;
 	}
-
-	if (isFloat128Infinity(b)) {
-		if (isFloat128Zero(a)) {
-			/* FIXME 0 / inf */
+	
+	if (is_float128_infinity(b)) {
+		if (is_float128_zero(a)) {
+			// FIXME 0 / inf
 			result.parts.exp = 0;
 			result.parts.frac_hi = 0;
@@ -395,5 +398,5 @@
 			return result;
 		}
-		/* FIXME: num / inf*/
+		// FIXME: num / inf
 		result.parts.exp = 0;
 		result.parts.frac_hi = 0;
@@ -401,13 +404,13 @@
 		return result;
 	}
-
-	if (isFloat128Zero(b)) {
-		if (isFloat128Zero(a)) {
-			/*FIXME: 0 / 0*/
-			result.binary.hi = FLOAT128_NAN_HI;
-			result.binary.lo = FLOAT128_NAN_LO;
-			return result;
-		}
-		/* FIXME: division by zero */
+	
+	if (is_float128_zero(b)) {
+		if (is_float128_zero(a)) {
+			// FIXME: 0 / 0
+			result.bin.hi = FLOAT128_NAN_HI;
+			result.bin.lo = FLOAT128_NAN_LO;
+			return result;
+		}
+		// FIXME: division by zero
 		result.parts.exp = 0;
 		result.parts.frac_hi = 0;
@@ -415,5 +418,5 @@
 		return result;
 	}
-
+	
 	afrac_hi = a.parts.frac_hi;
 	afrac_lo = a.parts.frac_lo;
@@ -422,5 +425,5 @@
 	bfrac_lo = b.parts.frac_lo;
 	bexp = b.parts.exp;
-
+	
 	/* denormalized numbers */
 	if (aexp == 0) {
@@ -431,5 +434,5 @@
 			return result;
 		}
-
+		
 		/* normalize it*/
 		aexp++;
@@ -443,5 +446,5 @@
 		}
 	}
-
+	
 	if (bexp == 0) {
 		bexp++;
@@ -455,5 +458,5 @@
 		}
 	}
-
+	
 	or128(afrac_hi, afrac_lo,
 	    FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO,
@@ -466,18 +469,18 @@
 	lshift128(bfrac_hi, bfrac_lo,
 	    (128 - FLOAT128_FRACTION_SIZE - 1), &bfrac_hi, &bfrac_lo);
-
+	
 	if (le128(bfrac_hi, bfrac_lo, afrac_hi, afrac_lo)) {
 		rshift128(afrac_hi, afrac_lo, 1, &afrac_hi, &afrac_lo);
 		aexp++;
 	}
-
+	
 	cexp = aexp - bexp + FLOAT128_BIAS - 2;
-
+	
 	cfrac_hi = div128est(afrac_hi, afrac_lo, bfrac_hi);
-
+	
 	mul128(bfrac_hi, bfrac_lo, 0x0ll, cfrac_hi,
 	    &tmp_lolo /* dummy */, &tmp_hihi, &tmp_hilo, &tmp_lohi);
-
-	/* sub192(afrac_hi, afrac_lo, 0, 
+	
+	/* sub192(afrac_hi, afrac_lo, 0,
 	 *     tmp_hihi, tmp_hilo, tmp_lohi
 	 *     &rem_hihi, &rem_hilo, &rem_lohi); */
@@ -487,8 +490,8 @@
 	}
 	rem_lohi = -tmp_lohi;
-
+	
 	while ((int64_t) rem_hihi < 0) {
 		--cfrac_hi;
-		/* add192(rem_hihi, rem_hilo, rem_lohi, 
+		/* add192(rem_hihi, rem_hilo, rem_lohi,
 		 *     0, bfrac_hi, bfrac_lo,
 		 *     &rem_hihi, &rem_hilo, &rem_lohi); */
@@ -498,11 +501,11 @@
 		}
 	}
-
+	
 	cfrac_lo = div128est(rem_hilo, rem_lohi, bfrac_lo);
-
+	
 	if ((cfrac_lo & 0x3FFF) <= 4) {
 		mul128(bfrac_hi, bfrac_lo, 0x0ll, cfrac_lo,
-	        &tmp_hihi /* dummy */, &tmp_hilo, &tmp_lohi, &tmp_lolo);
-
+		    &tmp_hihi /* dummy */, &tmp_hilo, &tmp_lohi, &tmp_lolo);
+		
 		/* sub192(rem_hilo, rem_lohi, 0,
 		 *     tmp_hilo, tmp_lohi, tmp_lolo,
@@ -513,5 +516,5 @@
 		}
 		rem_lolo = -tmp_lolo;
-
+		
 		while ((int64_t) rem_hilo < 0) {
 			--cfrac_lo;
@@ -524,13 +527,13 @@
 			}
 		}
-
+		
 		cfrac_lo |= ((rem_hilo | rem_lohi | rem_lolo) != 0 );
 	}
-
+	
 	shift_out = cfrac_lo << (64 - (128 - FLOAT128_FRACTION_SIZE - 1));
 	rshift128(cfrac_hi, cfrac_lo, (128 - FLOAT128_FRACTION_SIZE - 1),
 	    &cfrac_hi, &cfrac_lo);
-
-	result = finishFloat128(cexp, cfrac_hi, cfrac_lo, result.parts.sign, shift_out);
+	
+	result = finish_float128(cexp, cfrac_hi, cfrac_lo, result.parts.sign, shift_out);
 	return result;
 }
Index: uspace/lib/softfloat/generic/mul.c
===================================================================
--- uspace/lib/softfloat/generic/mul.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/generic/mul.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -39,27 +39,28 @@
 #include <common.h>
 
-/**
- * Multiply two single-precision floats.
+/** Multiply two single-precision floats.
  *
  * @param a First input operand.
  * @param b Second input operand.
+ *
  * @return Result of multiplication.
- */
-float32 mulFloat32(float32 a, float32 b)
+ *
+ */
+float32 mul_float32(float32 a, float32 b)
 {
 	float32 result;
 	uint64_t frac1, frac2;
 	int32_t exp;
-
+	
 	result.parts.sign = a.parts.sign ^ b.parts.sign;
 	
-	if (isFloat32NaN(a) || isFloat32NaN(b)) {
+	if (is_float32_nan(a) || is_float32_nan(b)) {
 		/* TODO: fix SigNaNs */
-		if (isFloat32SigNaN(a)) {
+		if (is_float32_signan(a)) {
 			result.parts.fraction = a.parts.fraction;
 			result.parts.exp = a.parts.exp;
 			return result;
 		}
-		if (isFloat32SigNaN(b)) { /* TODO: fix SigNaN */
+		if (is_float32_signan(b)) { /* TODO: fix SigNaN */
 			result.parts.fraction = b.parts.fraction;
 			result.parts.exp = b.parts.exp;
@@ -67,12 +68,12 @@
 		}
 		/* set NaN as result */
-		result.binary = FLOAT32_NAN;
-		return result;
-	}
-		
-	if (isFloat32Infinity(a)) { 
-		if (isFloat32Zero(b)) {
-			/* FIXME: zero * infinity */
-			result.binary = FLOAT32_NAN;
+		result.bin = FLOAT32_NAN;
+		return result;
+	}
+	
+	if (is_float32_infinity(a)) {
+		if (is_float32_zero(b)) {
+			/* FIXME: zero * infinity */
+			result.bin = FLOAT32_NAN;
 			return result;
 		}
@@ -81,9 +82,9 @@
 		return result;
 	}
-
-	if (isFloat32Infinity(b)) { 
-		if (isFloat32Zero(a)) {
-			/* FIXME: zero * infinity */
-			result.binary = FLOAT32_NAN;
+	
+	if (is_float32_infinity(b)) {
+		if (is_float32_zero(a)) {
+			/* FIXME: zero * infinity */
+			result.bin = FLOAT32_NAN;
 			return result;
 		}
@@ -92,5 +93,5 @@
 		return result;
 	}
-
+	
 	/* exp is signed so we can easy detect underflow */
 	exp = a.parts.exp + b.parts.exp;
@@ -100,5 +101,5 @@
 		/* FIXME: overflow */
 		/* set infinity as result */
-		result.binary = FLOAT32_INF;
+		result.bin = FLOAT32_INF;
 		result.parts.sign = a.parts.sign ^ b.parts.sign;
 		return result;
@@ -121,5 +122,5 @@
 	
 	frac2 = b.parts.fraction;
-
+	
 	if (b.parts.exp > 0) {
 		frac2 |= FLOAT32_HIDDEN_BIT_MASK;
@@ -127,26 +128,28 @@
 		++exp;
 	}
-
+	
 	frac1 <<= 1; /* one bit space for rounding */
-
+	
 	frac1 = frac1 * frac2;
-
+	
 	/* round and return */
-	while ((exp < FLOAT32_MAX_EXPONENT) && (frac1 >= (1 << (FLOAT32_FRACTION_SIZE + 2)))) { 
+	while ((exp < FLOAT32_MAX_EXPONENT) &&
+	    (frac1 >= (1 << (FLOAT32_FRACTION_SIZE + 2)))) {
 		/* 23 bits of fraction + one more for hidden bit (all shifted 1 bit left) */
 		++exp;
 		frac1 >>= 1;
 	}
-
+	
 	/* rounding */
 	/* ++frac1; FIXME: not works - without it is ok */
 	frac1 >>= 1; /* shift off rounding space */
 	
-	if ((exp < FLOAT32_MAX_EXPONENT) && (frac1 >= (1 << (FLOAT32_FRACTION_SIZE + 1)))) {
+	if ((exp < FLOAT32_MAX_EXPONENT) &&
+	    (frac1 >= (1 << (FLOAT32_FRACTION_SIZE + 1)))) {
 		++exp;
 		frac1 >>= 1;
 	}
-
-	if (exp >= FLOAT32_MAX_EXPONENT) {	
+	
+	if (exp >= FLOAT32_MAX_EXPONENT) {
 		/* TODO: fix overflow */
 		/* return infinity*/
@@ -157,6 +160,6 @@
 	
 	exp -= FLOAT32_FRACTION_SIZE;
-
-	if (exp <= FLOAT32_FRACTION_SIZE) { 
+	
+	if (exp <= FLOAT32_FRACTION_SIZE) {
 		/* denormalized number */
 		frac1 >>= 1; /* denormalize */
@@ -175,30 +178,31 @@
 	result.parts.fraction = frac1 & ((1 << FLOAT32_FRACTION_SIZE) - 1);
 	
-	return result;	
+	return result;
 }
 
-/**
- * Multiply two double-precision floats.
+/** Multiply two double-precision floats.
  *
  * @param a First input operand.
  * @param b Second input operand.
+ *
  * @return Result of multiplication.
- */
-float64 mulFloat64(float64 a, float64 b)
+ *
+ */
+float64 mul_float64(float64 a, float64 b)
 {
 	float64 result;
 	uint64_t frac1, frac2;
 	int32_t exp;
-
+	
 	result.parts.sign = a.parts.sign ^ b.parts.sign;
 	
-	if (isFloat64NaN(a) || isFloat64NaN(b)) {
+	if (is_float64_nan(a) || is_float64_nan(b)) {
 		/* TODO: fix SigNaNs */
-		if (isFloat64SigNaN(a)) {
+		if (is_float64_signan(a)) {
 			result.parts.fraction = a.parts.fraction;
 			result.parts.exp = a.parts.exp;
 			return result;
 		}
-		if (isFloat64SigNaN(b)) { /* TODO: fix SigNaN */
+		if (is_float64_signan(b)) { /* TODO: fix SigNaN */
 			result.parts.fraction = b.parts.fraction;
 			result.parts.exp = b.parts.exp;
@@ -206,12 +210,12 @@
 		}
 		/* set NaN as result */
-		result.binary = FLOAT64_NAN;
-		return result;
-	}
-		
-	if (isFloat64Infinity(a)) { 
-		if (isFloat64Zero(b)) {
-			/* FIXME: zero * infinity */
-			result.binary = FLOAT64_NAN;
+		result.bin = FLOAT64_NAN;
+		return result;
+	}
+	
+	if (is_float64_infinity(a)) {
+		if (is_float64_zero(b)) {
+			/* FIXME: zero * infinity */
+			result.bin = FLOAT64_NAN;
 			return result;
 		}
@@ -220,9 +224,9 @@
 		return result;
 	}
-
-	if (isFloat64Infinity(b)) { 
-		if (isFloat64Zero(a)) {
-			/* FIXME: zero * infinity */
-			result.binary = FLOAT64_NAN;
+	
+	if (is_float64_infinity(b)) {
+		if (is_float64_zero(a)) {
+			/* FIXME: zero * infinity */
+			result.bin = FLOAT64_NAN;
 			return result;
 		}
@@ -231,10 +235,10 @@
 		return result;
 	}
-
+	
 	/* exp is signed so we can easy detect underflow */
 	exp = a.parts.exp + b.parts.exp - FLOAT64_BIAS;
 	
 	frac1 = a.parts.fraction;
-
+	
 	if (a.parts.exp > 0) {
 		frac1 |= FLOAT64_HIDDEN_BIT_MASK;
@@ -244,5 +248,5 @@
 	
 	frac2 = b.parts.fraction;
-
+	
 	if (b.parts.exp > 0) {
 		frac2 |= FLOAT64_HIDDEN_BIT_MASK;
@@ -250,10 +254,10 @@
 		++exp;
 	}
-
+	
 	frac1 <<= (64 - FLOAT64_FRACTION_SIZE - 1);
 	frac2 <<= (64 - FLOAT64_FRACTION_SIZE - 2);
-
+	
 	mul64(frac1, frac2, &frac1, &frac2);
-
+	
 	frac1 |= (frac2 != 0);
 	if (frac1 & (0x1ll << 62)) {
@@ -261,27 +265,28 @@
 		exp--;
 	}
-
-	result = finishFloat64(exp, frac1, result.parts.sign);
+	
+	result = finish_float64(exp, frac1, result.parts.sign);
 	return result;
 }
 
-/**
- * Multiply two quadruple-precision floats.
+/** Multiply two quadruple-precision floats.
  *
  * @param a First input operand.
  * @param b Second input operand.
+ *
  * @return Result of multiplication.
- */
-float128 mulFloat128(float128 a, float128 b)
+ *
+ */
+float128 mul_float128(float128 a, float128 b)
 {
 	float128 result;
 	uint64_t frac1_hi, frac1_lo, frac2_hi, frac2_lo, tmp_hi, tmp_lo;
 	int32_t exp;
-
+	
 	result.parts.sign = a.parts.sign ^ b.parts.sign;
-
-	if (isFloat128NaN(a) || isFloat128NaN(b)) {
+	
+	if (is_float128_nan(a) || is_float128_nan(b)) {
 		/* TODO: fix SigNaNs */
-		if (isFloat128SigNaN(a)) {
+		if (is_float128_signan(a)) {
 			result.parts.frac_hi = a.parts.frac_hi;
 			result.parts.frac_lo = a.parts.frac_lo;
@@ -289,5 +294,5 @@
 			return result;
 		}
-		if (isFloat128SigNaN(b)) { /* TODO: fix SigNaN */
+		if (is_float128_signan(b)) { /* TODO: fix SigNaN */
 			result.parts.frac_hi = b.parts.frac_hi;
 			result.parts.frac_lo = b.parts.frac_lo;
@@ -296,14 +301,14 @@
 		}
 		/* set NaN as result */
-		result.binary.hi = FLOAT128_NAN_HI;
-		result.binary.lo = FLOAT128_NAN_LO;
-		return result;
-	}
-
-	if (isFloat128Infinity(a)) {
-		if (isFloat128Zero(b)) {
-			/* FIXME: zero * infinity */
-			result.binary.hi = FLOAT128_NAN_HI;
-			result.binary.lo = FLOAT128_NAN_LO;
+		result.bin.hi = FLOAT128_NAN_HI;
+		result.bin.lo = FLOAT128_NAN_LO;
+		return result;
+	}
+	
+	if (is_float128_infinity(a)) {
+		if (is_float128_zero(b)) {
+			/* FIXME: zero * infinity */
+			result.bin.hi = FLOAT128_NAN_HI;
+			result.bin.lo = FLOAT128_NAN_LO;
 			return result;
 		}
@@ -313,10 +318,10 @@
 		return result;
 	}
-
-	if (isFloat128Infinity(b)) {
-		if (isFloat128Zero(a)) {
-			/* FIXME: zero * infinity */
-			result.binary.hi = FLOAT128_NAN_HI;
-			result.binary.lo = FLOAT128_NAN_LO;
+	
+	if (is_float128_infinity(b)) {
+		if (is_float128_zero(a)) {
+			/* FIXME: zero * infinity */
+			result.bin.hi = FLOAT128_NAN_HI;
+			result.bin.lo = FLOAT128_NAN_LO;
 			return result;
 		}
@@ -326,22 +331,22 @@
 		return result;
 	}
-
+	
 	/* exp is signed so we can easy detect underflow */
 	exp = a.parts.exp + b.parts.exp - FLOAT128_BIAS - 1;
-
+	
 	frac1_hi = a.parts.frac_hi;
 	frac1_lo = a.parts.frac_lo;
-
+	
 	if (a.parts.exp > 0) {
 		or128(frac1_hi, frac1_lo,
-	        FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO,
-	        &frac1_hi, &frac1_lo);
-	} else {
-		++exp;
-	}
-
+		    FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO,
+		    &frac1_hi, &frac1_lo);
+	} else {
+		++exp;
+	}
+	
 	frac2_hi = b.parts.frac_hi;
 	frac2_lo = b.parts.frac_lo;
-
+	
 	if (b.parts.exp > 0) {
 		or128(frac2_hi, frac2_lo,
@@ -351,8 +356,8 @@
 		++exp;
 	}
-
+	
 	lshift128(frac2_hi, frac2_lo,
 	    128 - FLOAT128_FRACTION_SIZE, &frac2_hi, &frac2_lo);
-
+	
 	tmp_hi = frac1_hi;
 	tmp_lo = frac1_lo;
@@ -361,5 +366,5 @@
 	add128(frac1_hi, frac1_lo, tmp_hi, tmp_lo, &frac1_hi, &frac1_lo);
 	frac2_hi |= (frac2_lo != 0x0ll);
-
+	
 	if ((FLOAT128_HIDDEN_BIT_MASK_HI << 1) <= frac1_hi) {
 		frac2_hi >>= 1;
@@ -370,6 +375,6 @@
 		++exp;
 	}
-
-	result = finishFloat128(exp, frac1_hi, frac1_lo, result.parts.sign, frac2_hi);
+	
+	result = finish_float128(exp, frac1_hi, frac1_lo, result.parts.sign, frac2_hi);
 	return result;
 }
Index: uspace/lib/softfloat/generic/softfloat.c
===================================================================
--- uspace/lib/softfloat/generic/softfloat.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/generic/softfloat.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -48,494 +48,609 @@
 #include <other.h>
 
-#include <functions.h>
-
 /* Arithmetic functions */
 
 float __addsf3(float a, float b)
 {
-	float32 fa, fb;
-	fa.f = a;
-	fb.f = b;
-	if (fa.parts.sign != fb.parts.sign) {
-		if (fa.parts.sign) {
-			fa.parts.sign = 0;
-			return subFloat32(fb, fa).f;
-		};
-		fb.parts.sign = 0;
-		return subFloat32(fa, fb).f;
-	}
-	return addFloat32(fa, fb).f;
+	float_t fa;
+	float_t fb;
+	float_t res;
+	
+	fa.val = a;
+	fb.val = b;
+	
+	if (fa.data.parts.sign != fb.data.parts.sign) {
+		if (fa.data.parts.sign) {
+			fa.data.parts.sign = 0;
+			res.data = sub_float(fb.data, fa.data);
+			
+			return res.val;
+		}
+		
+		fb.data.parts.sign = 0;
+		res.data = sub_float(fa.data, fb.data);
+		
+		return res.val;
+	}
+	
+	res.data = add_float(fa.data, fb.data);
+	return res.val;
 }
 
 double __adddf3(double a, double b)
 {
-	float64 da, db;
-	da.d = a;
-	db.d = b;
-	if (da.parts.sign != db.parts.sign) {
-		if (da.parts.sign) {
-			da.parts.sign = 0;
-			return subFloat64(db, da).d;
-		};
-		db.parts.sign = 0;
-		return subFloat64(da, db).d;
-	}
-	return addFloat64(da, db).d;
+	double_t da;
+	double_t db;
+	double_t res;
+	
+	da.val = a;
+	db.val = b;
+	
+	if (da.data.parts.sign != db.data.parts.sign) {
+		if (da.data.parts.sign) {
+			da.data.parts.sign = 0;
+			res.data = sub_double(db.data, da.data);
+			
+			return res.val;
+		}
+		
+		db.data.parts.sign = 0;
+		res.data = sub_double(da.data, db.data);
+		
+		return res.val;
+	}
+	
+	res.data = add_double(da.data, db.data);
+	return res.val;
 }
 
 long double __addtf3(long double a, long double b)
 {
-	float128 ta, tb;
-	ta.ld = a;
-	tb.ld = b;
-	if (ta.parts.sign != tb.parts.sign) {
-		if (ta.parts.sign) {
-			ta.parts.sign = 0;
-			return subFloat128(tb, ta).ld;
-		};
-		tb.parts.sign = 0;
-		return subFloat128(ta, tb).ld;
-	}
-	return addFloat128(ta, tb).ld;
+	long_double_t ta;
+	long_double_t tb;
+	long_double_t res;
+	
+	ta.val = a;
+	tb.val = b;
+	
+	if (ta.data.parts.sign != tb.data.parts.sign) {
+		if (ta.data.parts.sign) {
+			ta.data.parts.sign = 0;
+			res.data = sub_long_double(tb.data, ta.data);
+			
+			return res.val;
+		}
+		
+		tb.data.parts.sign = 0;
+		res.data = sub_long_double(ta.data, tb.data);
+		
+		return res.val;
+	}
+	
+	res.data = add_long_double(ta.data, tb.data);
+	return res.val;
 }
 
 float __subsf3(float a, float b)
 {
-	float32 fa, fb;
-	fa.f = a;
-	fb.f = b;
-	if (fa.parts.sign != fb.parts.sign) {
-		fb.parts.sign = !fb.parts.sign;
-		return addFloat32(fa, fb).f;
-	}
-	return subFloat32(fa, fb).f;
+	float_t fa;
+	float_t fb;
+	float_t res;
+	
+	fa.val = a;
+	fb.val = b;
+	
+	if (fa.data.parts.sign != fb.data.parts.sign) {
+		fb.data.parts.sign = !fb.data.parts.sign;
+		res.data = add_float(fa.data, fb.data);
+		
+		return res.val;
+	}
+	
+	res.data = sub_float(fa.data, fb.data);
+	return res.val;
 }
 
 double __subdf3(double a, double b)
 {
-	float64 da, db;
-	da.d = a;
-	db.d = b;
-	if (da.parts.sign != db.parts.sign) {
-		db.parts.sign = !db.parts.sign;
-		return addFloat64(da, db).d;
-	}
-	return subFloat64(da, db).d;
+	double_t da;
+	double_t db;
+	double_t res;
+	
+	da.val = a;
+	db.val = b;
+	
+	if (da.data.parts.sign != db.data.parts.sign) {
+		db.data.parts.sign = !db.data.parts.sign;
+		res.data = add_double(da.data, db.data);
+		
+		return res.val;
+	}
+	
+	res.data = sub_double(da.data, db.data);
+	return res.val;
 }
 
 long double __subtf3(long double a, long double b)
 {
-	float128 ta, tb;
-	ta.ld = a;
-	tb.ld = b;
-	if (ta.parts.sign != tb.parts.sign) {
-		tb.parts.sign = !tb.parts.sign;
-		return addFloat128(ta, tb).ld;
-	}
-	return subFloat128(ta, tb).ld;
-}
-
-float __mulsf3(float a, float b) 
-{
-	float32 fa, fb;
-	fa.f = a;
-	fb.f = b;
-	return 	mulFloat32(fa, fb).f;
-}
-
-double __muldf3(double a, double b) 
-{
-	float64 da, db;
-	da.d = a;
-	db.d = b;
-	return 	mulFloat64(da, db).d;
+	long_double_t ta;
+	long_double_t tb;
+	long_double_t res;
+	
+	ta.val = a;
+	tb.val = b;
+	
+	if (ta.data.parts.sign != tb.data.parts.sign) {
+		tb.data.parts.sign = !tb.data.parts.sign;
+		res.data = add_long_double(ta.data, tb.data);
+		
+		return res.val;
+	}
+	
+	res.data = sub_long_double(ta.data, tb.data);
+	return res.val;
+}
+
+float __mulsf3(float a, float b)
+{
+	float_t fa;
+	float_t fb;
+	float_t res;
+	
+	fa.val = a;
+	fb.val = b;
+	
+	res.data = mul_float(fa.data, fb.data);
+	return res.val;
+}
+
+double __muldf3(double a, double b)
+{
+	double_t da;
+	double_t db;
+	double_t res;
+	
+	da.val = a;
+	db.val = b;
+	
+	res.data = mul_double(da.data, db.data);
+	return res.val;
 }
 
 long double __multf3(long double a, long double b)
 {
-	float128 ta, tb;
-	ta.ld = a;
-	tb.ld = b;
-	return 	mulFloat128(ta, tb).ld;
-}
-
-float __divsf3(float a, float b) 
-{
-	float32 fa, fb;
-	fa.f = a;
-	fb.f = b;
-	return 	divFloat32(fa, fb).f;
-}
-
-double __divdf3(double a, double b) 
-{
-	float64 da, db;
-	da.d = a;
-	db.d = b;
-	return 	divFloat64(da, db).d;
+	long_double_t ta;
+	long_double_t tb;
+	long_double_t res;
+	
+	ta.val = a;
+	tb.val = b;
+	
+	res.data = mul_long_double(ta.data, tb.data);
+	return res.val;
+}
+
+float __divsf3(float a, float b)
+{
+	float_t fa;
+	float_t fb;
+	float_t res;
+	
+	fa.val = a;
+	fb.val = b;
+	
+	res.data = div_float(fa.data, fb.data);
+	return res.val;
+}
+
+double __divdf3(double a, double b)
+{
+	double_t da;
+	double_t db;
+	double_t res;
+	
+	da.val = a;
+	db.val = b;
+	
+	res.data = div_double(da.data, db.data);
+	return res.val;
 }
 
 long double __divtf3(long double a, long double b)
 {
-	float128 ta, tb;
-	ta.ld = a;
-	tb.ld = b;
-	return 	divFloat128(ta, tb).ld;
+	long_double_t ta;
+	long_double_t tb;
+	long_double_t res;
+	
+	ta.val = a;
+	tb.val = b;
+	
+	res.data = div_long_double(ta.data, tb.data);
+	return res.val;
 }
 
 float __negsf2(float a)
 {
-	float32 fa;
-	fa.f = a;
-	fa.parts.sign = !fa.parts.sign;
-	return fa.f;
+	float_t fa;
+	
+	fa.val = a;
+	fa.data.parts.sign = !fa.data.parts.sign;
+	
+	return fa.val;
 }
 
 double __negdf2(double a)
 {
-	float64 da;
-	da.d = a;
-	da.parts.sign = !da.parts.sign;
-	return da.d;
+	double_t da;
+	
+	da.val = a;
+	da.data.parts.sign = !da.data.parts.sign;
+	
+	return da.val;
 }
 
 long double __negtf2(long double a)
 {
-	float128 ta;
-	ta.ld = a;
-	ta.parts.sign = !ta.parts.sign;
-	return ta.ld;
+	long_double_t ta;
+	
+	ta.val = a;
+	ta.data.parts.sign = !ta.data.parts.sign;
+	
+	return ta.val;
 }
 
 /* Conversion functions */
 
-double __extendsfdf2(float a) 
-{
-	float32 fa;
-	fa.f = a;
-	return convertFloat32ToFloat64(fa).d;
+double __extendsfdf2(float a)
+{
+	float_t fa;
+	double_t res;
+	
+	fa.val = a;
+	res.data = float_to_double(fa.data);
+	
+	return res.val;
 }
 
 long double __extendsftf2(float a)
 {
-	float32 fa;
-	fa.f = a;
-	return convertFloat32ToFloat128(fa).ld;
+	float_t fa;
+	long_double_t res;
+	
+	fa.val = a;
+	res.data = float_to_long_double(fa.data);
+	
+	return res.val;
 }
 
 long double __extenddftf2(double a)
 {
-	float64 da;
-	da.d = a;
-	return convertFloat64ToFloat128(da).ld;
-}
-
-float __truncdfsf2(double a) 
-{
-	float64 da;
-	da.d = a;
-	return convertFloat64ToFloat32(da).f;
+	double_t da;
+	long_double_t res;
+	
+	da.val = a;
+	res.data = double_to_long_double(da.data);
+	
+	return res.val;
+}
+
+float __truncdfsf2(double a)
+{
+	double_t da;
+	float_t res;
+	
+	da.val = a;
+	res.data = double_to_float(da.data);
+	
+	return res.val;
 }
 
 float __trunctfsf2(long double a)
 {
-	float128 ta;
-	ta.ld = a;
-	return convertFloat128ToFloat32(ta).f;
+	long_double_t ta;
+	float_t res;
+	
+	ta.val = a;
+	res.data = long_double_to_float(ta.data);
+	
+	return res.val;
 }
 
 double __trunctfdf2(long double a)
 {
-	float128 ta;
-	ta.ld = a;
-	return convertFloat128ToFloat64(ta).d;
+	long_double_t ta;
+	double_t res;
+	
+	ta.val = a;
+	res.data = long_double_to_double(ta.data);
+	
+	return res.val;
 }
 
 int __fixsfsi(float a)
 {
-	float32 fa;
-	fa.f = a;
-	
-	return float32_to_int(fa);
+	float_t fa;
+	
+	fa.val = a;
+	return float_to_int(fa.data);
 }
 
 int __fixdfsi(double a)
 {
-	float64 da;
-	da.d = a;
-	
-	return float64_to_int(da);
+	double_t da;
+	
+	da.val = a;
+	return double_to_int(da.data);
 }
 
 int __fixtfsi(long double a)
 {
-	float128 ta;
-	ta.ld = a;
-
-	return float128_to_int(ta);
+	long_double_t ta;
+	
+	ta.val = a;
+	return long_double_to_int(ta.data);
 }
  
 long __fixsfdi(float a)
 {
-	float32 fa;
-	fa.f = a;
-	
-	return float32_to_long(fa);
+	float_t fa;
+	
+	fa.val = a;
+	return float_to_long(fa.data);
 }
 
 long __fixdfdi(double a)
 {
-	float64 da;
-	da.d = a;
-	
-	return float64_to_long(da);
+	double_t da;
+	
+	da.val = a;
+	return double_to_long(da.data);
 }
 
 long __fixtfdi(long double a)
 {
-	float128 ta;
-	ta.ld = a;
-
-	return float128_to_long(ta);
+	long_double_t ta;
+	
+	ta.val = a;
+	return long_double_to_long(ta.data);
 }
  
 long long __fixsfti(float a)
 {
-	float32 fa;
-	fa.f = a;
-	
-	return float32_to_longlong(fa);
+	float_t fa;
+	
+	fa.val = a;
+	return float_to_llong(fa.data);
 }
 
 long long __fixdfti(double a)
 {
-	float64 da;
-	da.d = a;
-	
-	return float64_to_longlong(da);
+	double_t da;
+	
+	da.val = a;
+	return double_to_llong(da.data);
 }
 
 long long __fixtfti(long double a)
 {
-	float128 ta;
-	ta.ld = a;
-
-	return float128_to_longlong(ta);
+	long_double_t ta;
+	
+	ta.val = a;
+	return long_double_to_llong(ta.data);
 }
 
 unsigned int __fixunssfsi(float a)
 {
-	float32 fa;
-	fa.f = a;
-	
-	return float32_to_uint(fa);
+	float_t fa;
+	
+	fa.val = a;
+	return float_to_uint(fa.data);
 }
 
 unsigned int __fixunsdfsi(double a)
 {
-	float64 da;
-	da.d = a;
-	
-	return float64_to_uint(da);
+	double_t da;
+	
+	da.val = a;
+	return double_to_uint(da.data);
 }
 
 unsigned int __fixunstfsi(long double a)
 {
-	float128 ta;
-	ta.ld = a;
-
-	return float128_to_uint(ta);
+	long_double_t ta;
+	
+	ta.val = a;
+	return long_double_to_uint(ta.data);
 }
  
 unsigned long __fixunssfdi(float a)
 {
-	float32 fa;
-	fa.f = a;
-	
-	return float32_to_ulong(fa);
+	float_t fa;
+	
+	fa.val = a;
+	return float_to_ulong(fa.data);
 }
 
 unsigned long __fixunsdfdi(double a)
 {
-	float64 da;
-	da.d = a;
-	
-	return float64_to_ulong(da);
+	double_t da;
+	
+	da.val = a;
+	return double_to_ulong(da.data);
 }
 
 unsigned long __fixunstfdi(long double a)
 {
-	float128 ta;
-	ta.ld = a;
-
-	return float128_to_ulong(ta);
+	long_double_t ta;
+	
+	ta.val = a;
+	return long_double_to_ulong(ta.data);
 }
  
 unsigned long long __fixunssfti(float a)
 {
-	float32 fa;
-	fa.f = a;
-	
-	return float32_to_ulonglong(fa);
+	float_t fa;
+	
+	fa.val = a;
+	return float_to_ullong(fa.data);
 }
 
 unsigned long long __fixunsdfti(double a)
 {
-	float64 da;
-	da.d = a;
-	
-	return float64_to_ulonglong(da);
+	double_t da;
+	
+	da.val = a;
+	return double_to_ullong(da.data);
 }
 
 unsigned long long __fixunstfti(long double a)
 {
-	float128 ta;
-	ta.ld = a;
-
-	return float128_to_ulonglong(ta);
+	long_double_t ta;
+	
+	ta.val = a;
+	return long_double_to_ullong(ta.data);
 }
  
 float __floatsisf(int i)
 {
-	float32 fa;
-	
-	fa = int_to_float32(i);
-	return fa.f;
+	float_t res;
+	
+	res.data = int_to_float(i);
+	return res.val;
 }
 
 double __floatsidf(int i)
 {
-	float64 da;
-	
-	da = int_to_float64(i);
-	return da.d;
+	double_t res;
+	
+	res.data = int_to_double(i);
+	return res.val;
 }
 
 long double __floatsitf(int i)
 {
-	float128 ta;
-
-	ta = int_to_float128(i);
-	return ta.ld;
+	long_double_t res;
+	
+	res.data = int_to_long_double(i);
+	return res.val;
 }
  
 float __floatdisf(long i)
 {
-	float32 fa;
-	
-	fa = long_to_float32(i);
-	return fa.f;
+	float_t res;
+	
+	res.data = long_to_float(i);
+	return res.val;
 }
 
 double __floatdidf(long i)
 {
-	float64 da;
-	
-	da = long_to_float64(i);
-	return da.d;
+	double_t res;
+	
+	res.data = long_to_double(i);
+	return res.val;
 }
 
 long double __floatditf(long i)
 {
-	float128 ta;
-
-	ta = long_to_float128(i);
-	return ta.ld;
-}
- 
+	long_double_t res;
+	
+	res.data = long_to_long_double(i);
+	return res.val;
+}
+
 float __floattisf(long long i)
 {
-	float32 fa;
-	
-	fa = longlong_to_float32(i);
-	return fa.f;
+	float_t res;
+	
+	res.data = llong_to_float(i);
+	return res.val;
 }
 
 double __floattidf(long long i)
 {
-	float64 da;
-	
-	da = longlong_to_float64(i);
-	return da.d;
+	double_t res;
+	
+	res.data = llong_to_double(i);
+	return res.val;
 }
 
 long double __floattitf(long long i)
 {
-	float128 ta;
-
-	ta = longlong_to_float128(i);
-	return ta.ld;
+	long_double_t res;
+	
+	res.data = llong_to_long_double(i);
+	return res.val;
 }
 
 float __floatunsisf(unsigned int i)
 {
-	float32 fa;
-	
-	fa = uint_to_float32(i);
-	return fa.f;
+	float_t res;
+	
+	res.data = uint_to_float(i);
+	return res.val;
 }
 
 double __floatunsidf(unsigned int i)
 {
-	float64 da;
-	
-	da = uint_to_float64(i);
-	return da.d;
+	double_t res;
+	
+	res.data = uint_to_double(i);
+	return res.val;
 }
 
 long double __floatunsitf(unsigned int i)
 {
-	float128 ta;
-
-	ta = uint_to_float128(i);
-	return ta.ld;
+	long_double_t res;
+	
+	res.data = uint_to_long_double(i);
+	return res.val;
 }
  
 float __floatundisf(unsigned long i)
 {
-	float32 fa;
-	
-	fa = ulong_to_float32(i);
-	return fa.f;
+	float_t res;
+	
+	res.data = ulong_to_float(i);
+	return res.val;
 }
 
 double __floatundidf(unsigned long i)
 {
-	float64 da;
-	
-	da = ulong_to_float64(i);
-	return da.d;
+	double_t res;
+	
+	res.data = ulong_to_double(i);
+	return res.val;
 }
 
 long double __floatunditf(unsigned long i)
 {
-	float128 ta;
-
-	ta = ulong_to_float128(i);
-	return ta.ld;
+	long_double_t res;
+	
+	res.data = ulong_to_long_double(i);
+	return res.val;
 }
  
 float __floatuntisf(unsigned long long i)
 {
-	float32 fa;
-	
-	fa = ulonglong_to_float32(i);
-	return fa.f;
+	float_t res;
+	
+	res.data = ullong_to_float(i);
+	return res.val;
 }
 
 double __floatuntidf(unsigned long long i)
 {
-	float64 da;
-	
-	da = ulonglong_to_float64(i);
-	return da.d;
+	double_t res;
+	
+	res.data = ullong_to_double(i);
+	return res.val;
 }
 
 long double __floatuntitf(unsigned long long i)
 {
-	float128 ta;
-
-	ta = ulonglong_to_float128(i);
-	return ta.ld;
+	long_double_t res;
+	
+	res.data = ullong_to_long_double(i);
+	return res.val;
 }
 
@@ -544,20 +659,21 @@
 int __cmpsf2(float a, float b) 
 {
-	float32 fa, fb;
-	fa.f = a;
-	fb.f = b;
-
-	if ((isFloat32NaN(fa)) || (isFloat32NaN(fb))) {
-		return 1; /* no special constant for unordered - maybe signaled? */
-	}
-	
-	if (isFloat32eq(fa, fb)) {
-		return 0;
-	}
-	
-	if (isFloat32lt(fa, fb)) {
-		return -1;
-	}
-
+	float_t fa;
+	float_t fb;
+	
+	fa.val = a;
+	fb.val = b;
+	
+	if ((is_float_nan(fa.data)) || (is_float_nan(fb.data))) {
+		/* no special constant for unordered - maybe signaled? */
+		return 1;
+	}
+	
+	if (is_float_eq(fa.data, fb.data))
+		return 0;
+	
+	if (is_float_lt(fa.data, fb.data))
+		return -1;
+	
 	return 1;
 }
@@ -565,20 +681,21 @@
 int __cmpdf2(double a, double b)
 {
-	float64 da, db;
-	da.d = a;
-	db.d = b;
-
-	if ((isFloat64NaN(da)) || (isFloat64NaN(db))) {
-		return 1; /* no special constant for unordered - maybe signaled? */
-	}
-
-	if (isFloat64eq(da, db)) {
-		return 0;
-	}
-
-	if (isFloat64lt(da, db)) {
-		return -1;
-	}
-
+	double_t da;
+	double_t db;
+	
+	da.val = a;
+	db.val = b;
+	
+	if ((is_double_nan(da.data)) || (is_double_nan(db.data))) {
+		/* no special constant for unordered - maybe signaled? */
+		return 1;
+	}
+	
+	if (is_double_eq(da.data, db.data))
+		return 0;
+	
+	if (is_double_lt(da.data, db.data))
+		return -1;
+	
 	return 1;
 }
@@ -586,84 +703,106 @@
 int __cmptf2(long double a, long double b)
 {
-	float128 ta, tb;
-	ta.ld = a;
-	tb.ld = b;
-
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
-		return 1; /* no special constant for unordered - maybe signaled? */
-	}
-
-	if (isFloat128eq(ta, tb)) {
-		return 0;
-	}
-
-	if (isFloat128lt(ta, tb)) {
-		return -1;
-	}
-
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = a;
+	tb.val = b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) {
+		/* no special constant for unordered - maybe signaled? */
+		return 1;
+	}
+	
+	if (is_long_double_eq(ta.data, tb.data))
+		return 0;
+	
+	if (is_long_double_lt(ta.data, tb.data))
+		return -1;
+	
 	return 1;
 }
 
-int __unordsf2(float a, float b) 
-{
-	float32 fa, fb;
-	fa.f = a;
-	fb.f = b;
-	return ((isFloat32NaN(fa)) || (isFloat32NaN(fb)));
+int __unordsf2(float a, float b)
+{
+	float_t fa;
+	float_t fb;
+	
+	fa.val = a;
+	fb.val = b;
+	
+	return ((is_float_nan(fa.data)) || (is_float_nan(fb.data)));
 }
 
 int __unorddf2(double a, double b)
 {
-	float64 da, db;
-	da.d = a;
-	db.d = b;
-	return ((isFloat64NaN(da)) || (isFloat64NaN(db)));
+	double_t da;
+	double_t db;
+	
+	da.val = a;
+	db.val = b;
+	
+	return ((is_double_nan(da.data)) || (is_double_nan(db.data)));
 }
 
 int __unordtf2(long double a, long double b)
 {
-	float128 ta, tb;
-	ta.ld = a;
-	tb.ld = b;
-	return ((isFloat128NaN(ta)) || (isFloat128NaN(tb)));
-}
-
-int __eqsf2(float a, float b) 
-{
-	float32 fa, fb;
-	fa.f = a;
-	fb.f = b;
-	if ((isFloat32NaN(fa)) || (isFloat32NaN(fb))) {
-		/* TODO: sigNaNs */
-		return 1;
-	}
-	return isFloat32eq(fa, fb) - 1;
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = a;
+	tb.val = b;
+	
+	return ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data)));
+}
+
+int __eqsf2(float a, float b)
+{
+	float_t fa;
+	float_t fb;
+	
+	fa.val = a;
+	fb.val = b;
+	
+	if ((is_float_nan(fa.data)) || (is_float_nan(fb.data))) {
+		// TODO: sigNaNs
+		return 1;
+	}
+	
+	return is_float_eq(fa.data, fb.data) - 1;
 }
 
 int __eqdf2(double a, double b)
 {
-	float64 da, db;
-	da.d = a;
-	db.d = b;
-	if ((isFloat64NaN(da)) || (isFloat64NaN(db))) {
-		/* TODO: sigNaNs */
-		return 1;
-	}
-	return isFloat64eq(da, db) - 1;
+	double_t da;
+	double_t db;
+	
+	da.val = a;
+	db.val = b;
+	
+	if ((is_double_nan(da.data)) || (is_double_nan(db.data))) {
+		// TODO: sigNaNs
+		return 1;
+	}
+	
+	return is_double_eq(da.data, db.data) - 1;
 }
 
 int __eqtf2(long double a, long double b)
 {
-	float128 ta, tb;
-	ta.ld = a;
-	tb.ld = b;
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
-		/* TODO: sigNaNs */
-		return 1;
-	}
-	return isFloat128eq(ta, tb) - 1;
-}
-
-int __nesf2(float a, float b) 
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = a;
+	tb.val = b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) {
+		// TODO: sigNaNs
+		return 1;
+	}
+	
+	return is_long_double_eq(ta.data, tb.data) - 1;
+}
+
+int __nesf2(float a, float b)
 {
 	/* strange behavior, but it was in gcc documentation */
@@ -685,20 +824,20 @@
 int __gesf2(float a, float b)
 {
-	float32 fa, fb;
-	fa.f = a;
-	fb.f = b;
-
-	if ((isFloat32NaN(fa)) || (isFloat32NaN(fb))) {
-		/* TODO: sigNaNs */
-		return -1;
-	}
-	
-	if (isFloat32eq(fa, fb)) {
-		return 0;
-	}
-	
-	if (isFloat32gt(fa, fb)) {
-		return 1;
-	}
+	float_t fa;
+	float_t fb;
+	
+	fa.val = a;
+	fb.val = b;
+	
+	if ((is_float_nan(fa.data)) || (is_float_nan(fb.data))) {
+		// TODO: sigNaNs
+		return -1;
+	}
+	
+	if (is_float_eq(fa.data, fb.data))
+		return 0;
+	
+	if (is_float_gt(fa.data, fb.data))
+		return 1;
 	
 	return -1;
@@ -707,21 +846,21 @@
 int __gedf2(double a, double b)
 {
-	float64 da, db;
-	da.d = a;
-	db.d = b;
-
-	if ((isFloat64NaN(da)) || (isFloat64NaN(db))) {
-		/* TODO: sigNaNs */
-		return -1;
-	}
-
-	if (isFloat64eq(da, db)) {
-		return 0;
-	}
-
-	if (isFloat64gt(da, db)) {
-		return 1;
-	}
-
+	double_t da;
+	double_t db;
+	
+	da.val = a;
+	db.val = b;
+	
+	if ((is_double_nan(da.data)) || (is_double_nan(db.data))) {
+		// TODO: sigNaNs
+		return -1;
+	}
+	
+	if (is_double_eq(da.data, db.data))
+		return 0;
+	
+	if (is_double_gt(da.data, db.data))
+		return 1;
+	
 	return -1;
 }
@@ -729,21 +868,21 @@
 int __getf2(long double a, long double b)
 {
-	float128 ta, tb;
-	ta.ld = a;
-	tb.ld = b;
-
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
-		/* TODO: sigNaNs */
-		return -1;
-	}
-
-	if (isFloat128eq(ta, tb)) {
-		return 0;
-	}
-
-	if (isFloat128gt(ta, tb)) {
-		return 1;
-	}
-
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = a;
+	tb.val = b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) {
+		// TODO: sigNaNs
+		return -1;
+	}
+	
+	if (is_long_double_eq(ta.data, tb.data))
+		return 0;
+	
+	if (is_long_double_gt(ta.data, tb.data))
+		return 1;
+	
 	return -1;
 }
@@ -751,17 +890,18 @@
 int __ltsf2(float a, float b)
 {
-	float32 fa, fb;
-	fa.f = a;
-	fb.f = b;
-
-	if ((isFloat32NaN(fa)) || (isFloat32NaN(fb))) {
-		/* TODO: sigNaNs */
-		return 1;
-	}
-
-	if (isFloat32lt(fa, fb)) {
-		return -1;
-	}
-
+	float_t fa;
+	float_t fb;
+	
+	fa.val = a;
+	fb.val = b;
+	
+	if ((is_float_nan(fa.data)) || (is_float_nan(fb.data))) {
+		// TODO: sigNaNs
+		return 1;
+	}
+	
+	if (is_float_lt(fa.data, fb.data))
+		return -1;
+	
 	return 0;
 }
@@ -769,17 +909,18 @@
 int __ltdf2(double a, double b)
 {
-	float64 da, db;
-	da.d = a;
-	db.d = b;
-
-	if ((isFloat64NaN(da)) || (isFloat64NaN(db))) {
-		/* TODO: sigNaNs */
-		return 1;
-	}
-
-	if (isFloat64lt(da, db)) {
-		return -1;
-	}
-
+	double_t da;
+	double_t db;
+	
+	da.val = a;
+	db.val = b;
+	
+	if ((is_double_nan(da.data)) || (is_double_nan(db.data))) {
+		// TODO: sigNaNs
+		return 1;
+	}
+	
+	if (is_double_lt(da.data, db.data))
+		return -1;
+	
 	return 0;
 }
@@ -787,17 +928,18 @@
 int __lttf2(long double a, long double b)
 {
-	float128 ta, tb;
-	ta.ld = a;
-	tb.ld = b;
-
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
-		/* TODO: sigNaNs */
-		return 1;
-	}
-
-	if (isFloat128lt(ta, tb)) {
-		return -1;
-	}
-
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = a;
+	tb.val = b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) {
+		// TODO: sigNaNs
+		return 1;
+	}
+	
+	if (is_long_double_lt(ta.data, tb.data))
+		return -1;
+	
 	return 0;
 }
@@ -805,20 +947,20 @@
 int __lesf2(float a, float b)
 {
-	float32 fa, fb;
-	fa.f = a;
-	fb.f = b;
-
-	if ((isFloat32NaN(fa)) || (isFloat32NaN(fb))) {
-		/* TODO: sigNaNs */
-		return 1;
-	}
-	
-	if (isFloat32eq(fa, fb)) {
-		return 0;
-	}
-	
-	if (isFloat32lt(fa, fb)) {
-		return -1;
-	}
+	float_t fa;
+	float_t fb;
+	
+	fa.val = a;
+	fb.val = b;
+	
+	if ((is_float_nan(fa.data)) || (is_float_nan(fb.data))) {
+		// TODO: sigNaNs
+		return 1;
+	}
+	
+	if (is_float_eq(fa.data, fb.data))
+		return 0;
+	
+	if (is_float_lt(fa.data, fb.data))
+		return -1;
 	
 	return 1;
@@ -827,21 +969,21 @@
 int __ledf2(double a, double b)
 {
-	float64 da, db;
-	da.d = a;
-	db.d = b;
-
-	if ((isFloat64NaN(da)) || (isFloat64NaN(db))) {
-		/* TODO: sigNaNs */
-		return 1;
-	}
-
-	if (isFloat64eq(da, db)) {
-		return 0;
-	}
-
-	if (isFloat64lt(da, db)) {
-		return -1;
-	}
-
+	double_t da;
+	double_t db;
+	
+	da.val = a;
+	db.val = b;
+	
+	if ((is_double_nan(da.data)) || (is_double_nan(db.data))) {
+		// TODO: sigNaNs
+		return 1;
+	}
+	
+	if (is_double_eq(da.data, db.data))
+		return 0;
+	
+	if (is_double_lt(da.data, db.data))
+		return -1;
+	
 	return 1;
 }
@@ -849,21 +991,21 @@
 int __letf2(long double a, long double b)
 {
-	float128 ta, tb;
-	ta.ld = a;
-	tb.ld = b;
-
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
-		/* TODO: sigNaNs */
-		return 1;
-	}
-
-	if (isFloat128eq(ta, tb)) {
-		return 0;
-	}
-
-	if (isFloat128lt(ta, tb)) {
-		return -1;
-	}
-
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = a;
+	tb.val = b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) {
+		// TODO: sigNaNs
+		return 1;
+	}
+	
+	if (is_long_double_eq(ta.data, tb.data))
+		return 0;
+	
+	if (is_long_double_lt(ta.data, tb.data))
+		return -1;
+	
 	return 1;
 }
@@ -871,17 +1013,18 @@
 int __gtsf2(float a, float b)
 {
-	float32 fa, fb;
-	fa.f = a;
-	fb.f = b;
-
-	if ((isFloat32NaN(fa)) || (isFloat32NaN(fb))) {
-		/* TODO: sigNaNs */
-		return -1;
-	}
-
-	if (isFloat32gt(fa, fb)) {
-		return 1;
-	}
-
+	float_t fa;
+	float_t fb;
+	
+	fa.val = a;
+	fb.val = b;
+	
+	if ((is_float_nan(fa.data)) || (is_float_nan(fb.data))) {
+		// TODO: sigNaNs
+		return -1;
+	}
+	
+	if (is_float_gt(fa.data, fb.data))
+		return 1;
+	
 	return 0;
 }
@@ -889,17 +1032,18 @@
 int __gtdf2(double a, double b)
 {
-	float64 da, db;
-	da.d = a;
-	db.d = b;
-
-	if ((isFloat64NaN(da)) || (isFloat64NaN(db))) {
-		/* TODO: sigNaNs */
-		return -1;
-	}
-
-	if (isFloat64gt(da, db)) {
-		return 1;
-	}
-
+	double_t da;
+	double_t db;
+	
+	da.val = a;
+	db.val = b;
+	
+	if ((is_double_nan(da.data)) || (is_double_nan(db.data))) {
+		// TODO: sigNaNs
+		return -1;
+	}
+	
+	if (is_double_gt(da.data, db.data))
+		return 1;
+	
 	return 0;
 }
@@ -907,24 +1051,21 @@
 int __gttf2(long double a, long double b)
 {
-	float128 ta, tb;
-	ta.ld = a;
-	tb.ld = b;
-
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
-		/* TODO: sigNaNs */
-		return -1;
-	}
-
-	if (isFloat128gt(ta, tb)) {
-		return 1;
-	}
-
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = a;
+	tb.val = b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) {
+		// TODO: sigNaNs
+		return -1;
+	}
+	
+	if (is_long_double_gt(ta.data, tb.data))
+		return 1;
+	
 	return 0;
 }
 
-
-
-#ifdef SPARC_SOFTFLOAT
-
 /* SPARC quadruple-precision wrappers */
 
@@ -1016,20 +1157,19 @@
 int _Qp_cmp(long double *a, long double *b)
 {
-	float128 ta, tb;
-	ta.ld = *a;
-	tb.ld = *b;
-
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = *a;
+	tb.val = *b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data)))
 		return 3;
-	}
-
-	if (isFloat128eq(ta, tb)) {
-		return 0;
-	}
-
-	if (isFloat128lt(ta, tb)) {
-		return 1;
-	}
-
+	
+	if (is_long_double_eq(ta.data, tb.data))
+		return 0;
+	
+	if (is_long_double_lt(ta.data, tb.data))
+		return 1;
+	
 	return 2;
 }
@@ -1043,81 +1183,87 @@
 int _Qp_feq(long double *a, long double *b)
 {
-	float128 ta, tb;
-	ta.ld = *a;
-	tb.ld = *b;
-
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
-		return 0;
-	}
-
-	return isFloat128eq(ta, tb);
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = *a;
+	tb.val = *b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data)))
+		return 0;
+	
+	return is_long_double_eq(ta.data, tb.data);
 }
 
 int _Qp_fge(long double *a, long double *b)
 {
-	float128 ta, tb;
-	ta.ld = *a;
-	tb.ld = *b;
-
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
-		return 0;
-	}
-
-	return isFloat128eq(ta, tb) || isFloat128gt(ta, tb);
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = *a;
+	tb.val = *b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data)))
+		return 0;
+	
+	return is_long_double_eq(ta.data, tb.data) ||
+	    is_long_double_gt(ta.data, tb.data);
 }
 
 int _Qp_fgt(long double *a, long double *b)
 {
-	float128 ta, tb;
-	ta.ld = *a;
-	tb.ld = *b;
-
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
-		return 0;
-	}
-
-	return isFloat128gt(ta, tb);
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = *a;
+	tb.val = *b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data)))
+		return 0;
+	
+	return is_long_double_gt(ta.data, tb.data);
 }
 
 int _Qp_fle(long double*a, long double *b)
 {
-	float128 ta, tb;
-	ta.ld = *a;
-	tb.ld = *b;
-
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
-		return 0;
-	}
-
-	return isFloat128eq(ta, tb) || isFloat128lt(ta, tb);
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = *a;
+	tb.val = *b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data)))
+		return 0;
+	
+	return is_long_double_eq(ta.data, tb.data) ||
+	    is_long_double_lt(ta.data, tb.data);
 }
 
 int _Qp_flt(long double *a, long double *b)
 {
-	float128 ta, tb;
-	ta.ld = *a;
-	tb.ld = *b;
-
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
-		return 0;
-	}
-
-	return isFloat128lt(ta, tb);
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = *a;
+	tb.val = *b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data)))
+		return 0;
+	
+	return is_long_double_lt(ta.data, tb.data);
 }
 
 int _Qp_fne(long double *a, long double *b)
 {
-	float128 ta, tb;
-	ta.ld = *a;
-	tb.ld = *b;
-
-	if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) {
-		return 1;
-	}
-
-	return !isFloat128eq(ta, tb);
-}
-
-#endif
+	long_double_t ta;
+	long_double_t tb;
+	
+	ta.val = *a;
+	tb.val = *b;
+	
+	if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data)))
+		return 0;
+	
+	return !is_long_double_eq(ta.data, tb.data);
+}
 
 /** @}
Index: uspace/lib/softfloat/generic/sub.c
===================================================================
--- uspace/lib/softfloat/generic/sub.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/generic/sub.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -39,34 +39,38 @@
 #include <common.h>
 
-/**
- * Subtract two single-precision floats with the same signs.
+/** Subtract two single-precision floats with the same sign.
  *
  * @param a First input operand.
  * @param b Second input operand.
+ *
  * @return Result of substraction.
- */
-float32 subFloat32(float32 a, float32 b)
+ *
+ */
+float32 sub_float32(float32 a, float32 b)
 {
 	int expdiff;
 	uint32_t exp1, exp2, frac1, frac2;
 	float32 result;
-
-	result.f = 0;
+	
+	result.bin = 0;
 	
 	expdiff = a.parts.exp - b.parts.exp;
-	if ((expdiff < 0 ) || ((expdiff == 0) && (a.parts.fraction < b.parts.fraction))) {
-		if (isFloat32NaN(b)) {
-			/* TODO: fix SigNaN */
-			if (isFloat32SigNaN(b)) {
-			}
-			return b;
-		}
-		
-		if (b.parts.exp == FLOAT32_MAX_EXPONENT) { 
-			b.parts.sign = !b.parts.sign; /* num -(+-inf) = -+inf */
-			return b;
-		}
-		
-		result.parts.sign = !a.parts.sign; 
+	if ((expdiff < 0 ) || ((expdiff == 0) &&
+	    (a.parts.fraction < b.parts.fraction))) {
+		if (is_float32_nan(b)) {
+			if (is_float32_signan(b)) {
+				// TODO: fix SigNaN
+			}
+			
+			return b;
+		}
+		
+		if (b.parts.exp == FLOAT32_MAX_EXPONENT) {
+			/* num -(+-inf) = -+inf */
+			b.parts.sign = !b.parts.sign;
+			return b;
+		}
+		
+		result.parts.sign = !a.parts.sign;
 		
 		frac1 = b.parts.fraction;
@@ -76,18 +80,20 @@
 		expdiff *= -1;
 	} else {
-		if (isFloat32NaN(a)) {
-			/* TODO: fix SigNaN */
-			if (isFloat32SigNaN(a) || isFloat32SigNaN(b)) {
-			}
-			return a;
-		}
-		
-		if (a.parts.exp == FLOAT32_MAX_EXPONENT) { 
+		if (is_float32_nan(a)) {
+			if ((is_float32_signan(a)) || (is_float32_signan(b))) {
+				// TODO: fix SigNaN
+			}
+			
+			return a;
+		}
+		
+		if (a.parts.exp == FLOAT32_MAX_EXPONENT) {
 			if (b.parts.exp == FLOAT32_MAX_EXPONENT) {
 				/* inf - inf => nan */
-				/* TODO: fix exception */
-				result.binary = FLOAT32_NAN;
+				// TODO: fix exception
+				result.bin = FLOAT32_NAN;
 				return result;
 			}
+			
 			return a;
 		}
@@ -98,5 +104,5 @@
 		exp1 = a.parts.exp;
 		frac2 = b.parts.fraction;
-		exp2 = b.parts.exp;	
+		exp2 = b.parts.exp;
 	}
 	
@@ -105,17 +111,18 @@
 		result.parts.fraction = frac1 - frac2;
 		if (result.parts.fraction > frac1) {
-			/* TODO: underflow exception */
+			// TODO: underflow exception
 			return result;
 		}
+		
 		result.parts.exp = 0;
 		return result;
 	}
-
+	
 	/* add hidden bit */
-	frac1 |= FLOAT32_HIDDEN_BIT_MASK; 
+	frac1 |= FLOAT32_HIDDEN_BIT_MASK;
 	
 	if (exp2 == 0) {
 		/* denormalized */
-		--expdiff;	
+		--expdiff;
 	} else {
 		/* normalized */
@@ -127,10 +134,9 @@
 	frac2 <<= 6;
 	
-	if (expdiff > FLOAT32_FRACTION_SIZE + 1) {
+	if (expdiff > FLOAT32_FRACTION_SIZE + 1)
 		goto done;
-	}
 	
 	frac1 = frac1 - (frac2 >> expdiff);
-
+	
 done:
 	/* TODO: find first nonzero digit and shift result and detect possibly underflow */
@@ -143,5 +149,5 @@
 	/* rounding - if first bit after fraction is set then round up */
 	frac1 += 0x20;
-
+	
 	if (frac1 & (FLOAT32_HIDDEN_BIT_MASK << 7)) {
 		++exp1;
@@ -150,5 +156,5 @@
 	
 	/* Clear hidden bit and shift */
-	result.parts.fraction = ((frac1 >> 6) & (~FLOAT32_HIDDEN_BIT_MASK)); 
+	result.parts.fraction = ((frac1 >> 6) & (~FLOAT32_HIDDEN_BIT_MASK));
 	result.parts.exp = exp1;
 	
@@ -156,12 +162,13 @@
 }
 
-/**
- * Subtract two double-precision floats with the same signs.
+/** Subtract two double-precision floats with the same sign.
  *
  * @param a First input operand.
  * @param b Second input operand.
+ *
  * @return Result of substraction.
- */
-float64 subFloat64(float64 a, float64 b)
+ *
+ */
+float64 sub_float64(float64 a, float64 b)
 {
 	int expdiff;
@@ -169,22 +176,25 @@
 	uint64_t frac1, frac2;
 	float64 result;
-
-	result.d = 0;
+	
+	result.bin = 0;
 	
 	expdiff = a.parts.exp - b.parts.exp;
-	if ((expdiff < 0 ) || ((expdiff == 0) && (a.parts.fraction < b.parts.fraction))) {
-		if (isFloat64NaN(b)) {
-			/* TODO: fix SigNaN */
-			if (isFloat64SigNaN(b)) {
-			}
-			return b;
-		}
-		
-		if (b.parts.exp == FLOAT64_MAX_EXPONENT) { 
-			b.parts.sign = !b.parts.sign; /* num -(+-inf) = -+inf */
-			return b;
-		}
-		
-		result.parts.sign = !a.parts.sign; 
+	if ((expdiff < 0 ) ||
+	    ((expdiff == 0) && (a.parts.fraction < b.parts.fraction))) {
+		if (is_float64_nan(b)) {
+			if (is_float64_signan(b)) {
+				// TODO: fix SigNaN
+			}
+			
+			return b;
+		}
+		
+		if (b.parts.exp == FLOAT64_MAX_EXPONENT) {
+			/* num -(+-inf) = -+inf */
+			b.parts.sign = !b.parts.sign;
+			return b;
+		}
+		
+		result.parts.sign = !a.parts.sign;
 		
 		frac1 = b.parts.fraction;
@@ -194,18 +204,20 @@
 		expdiff *= -1;
 	} else {
-		if (isFloat64NaN(a)) {
-			/* TODO: fix SigNaN */
-			if (isFloat64SigNaN(a) || isFloat64SigNaN(b)) {
-			}
-			return a;
-		}
-		
-		if (a.parts.exp == FLOAT64_MAX_EXPONENT) { 
+		if (is_float64_nan(a)) {
+			if (is_float64_signan(a) || is_float64_signan(b)) {
+				// TODO: fix SigNaN
+			}
+			
+			return a;
+		}
+		
+		if (a.parts.exp == FLOAT64_MAX_EXPONENT) {
 			if (b.parts.exp == FLOAT64_MAX_EXPONENT) {
 				/* inf - inf => nan */
-				/* TODO: fix exception */
-				result.binary = FLOAT64_NAN;
+				// TODO: fix exception
+				result.bin = FLOAT64_NAN;
 				return result;
 			}
+			
 			return a;
 		}
@@ -216,5 +228,5 @@
 		exp1 = a.parts.exp;
 		frac2 = b.parts.fraction;
-		exp2 = b.parts.exp;	
+		exp2 = b.parts.exp;
 	}
 	
@@ -223,17 +235,18 @@
 		result.parts.fraction = frac1 - frac2;
 		if (result.parts.fraction > frac1) {
-			/* TODO: underflow exception */
+			// TODO: underflow exception
 			return result;
 		}
+		
 		result.parts.exp = 0;
 		return result;
 	}
-
+	
 	/* add hidden bit */
-	frac1 |= FLOAT64_HIDDEN_BIT_MASK; 
+	frac1 |= FLOAT64_HIDDEN_BIT_MASK;
 	
 	if (exp2 == 0) {
 		/* denormalized */
-		--expdiff;	
+		--expdiff;
 	} else {
 		/* normalized */
@@ -245,10 +258,9 @@
 	frac2 <<= 6;
 	
-	if (expdiff > FLOAT64_FRACTION_SIZE + 1) {
+	if (expdiff > FLOAT64_FRACTION_SIZE + 1)
 		goto done;
-	}
 	
 	frac1 = frac1 - (frac2 >> expdiff);
-
+	
 done:
 	/* TODO: find first nonzero digit and shift result and detect possibly underflow */
@@ -261,5 +273,5 @@
 	/* rounding - if first bit after fraction is set then round up */
 	frac1 += 0x20;
-
+	
 	if (frac1 & (FLOAT64_HIDDEN_BIT_MASK << 7)) {
 		++exp1;
@@ -268,5 +280,5 @@
 	
 	/* Clear hidden bit and shift */
-	result.parts.fraction = ((frac1 >> 6) & (~FLOAT64_HIDDEN_BIT_MASK)); 
+	result.parts.fraction = ((frac1 >> 6) & (~FLOAT64_HIDDEN_BIT_MASK));
 	result.parts.exp = exp1;
 	
@@ -274,12 +286,13 @@
 }
 
-/**
- * Subtract two quadruple-precision floats with the same signs.
+/** Subtract two quadruple-precision floats with the same sign.
  *
  * @param a First input operand.
  * @param b Second input operand.
+ *
  * @return Result of substraction.
- */
-float128 subFloat128(float128 a, float128 b)
+ *
+ */
+float128 sub_float128(float128 a, float128 b)
 {
 	int expdiff;
@@ -287,25 +300,27 @@
 	uint64_t frac1_hi, frac1_lo, frac2_hi, frac2_lo, tmp_hi, tmp_lo;
 	float128 result;
-
-	result.binary.hi = 0;
-	result.binary.lo = 0;
-
+	
+	result.bin.hi = 0;
+	result.bin.lo = 0;
+	
 	expdiff = a.parts.exp - b.parts.exp;
 	if ((expdiff < 0 ) || ((expdiff == 0) &&
 	    lt128(a.parts.frac_hi, a.parts.frac_lo, b.parts.frac_hi, b.parts.frac_lo))) {
-		if (isFloat128NaN(b)) {
-			/* TODO: fix SigNaN */
-			if (isFloat128SigNaN(b)) {
-			}
-			return b;
-		}
-
+		if (is_float128_nan(b)) {
+			if (is_float128_signan(b)) {
+				// TODO: fix SigNaN
+			}
+			
+			return b;
+		}
+		
 		if (b.parts.exp == FLOAT128_MAX_EXPONENT) {
-			b.parts.sign = !b.parts.sign; /* num -(+-inf) = -+inf */
-			return b;
-		}
-
+			/* num -(+-inf) = -+inf */
+			b.parts.sign = !b.parts.sign;
+			return b;
+		}
+		
 		result.parts.sign = !a.parts.sign;
-
+		
 		frac1_hi = b.parts.frac_hi;
 		frac1_lo = b.parts.frac_lo;
@@ -316,24 +331,25 @@
 		expdiff *= -1;
 	} else {
-		if (isFloat128NaN(a)) {
-			/* TODO: fix SigNaN */
-			if (isFloat128SigNaN(a) || isFloat128SigNaN(b)) {
-			}
-			return a;
-		}
-
+		if (is_float128_nan(a)) {
+			if (is_float128_signan(a) || is_float128_signan(b)) {
+				// TODO: fix SigNaN
+			}
+			
+			return a;
+		}
+		
 		if (a.parts.exp == FLOAT128_MAX_EXPONENT) {
 			if (b.parts.exp == FLOAT128_MAX_EXPONENT) {
 				/* inf - inf => nan */
-				/* TODO: fix exception */
-				result.binary.hi = FLOAT128_NAN_HI;
-				result.binary.lo = FLOAT128_NAN_LO;
+				// TODO: fix exception
+				result.bin.hi = FLOAT128_NAN_HI;
+				result.bin.lo = FLOAT128_NAN_LO;
 				return result;
 			}
 			return a;
 		}
-
+		
 		result.parts.sign = a.parts.sign;
-
+		
 		frac1_hi = a.parts.frac_hi;
 		frac1_lo = a.parts.frac_lo;
@@ -343,5 +359,5 @@
 		exp2 = b.parts.exp;
 	}
-
+	
 	if (exp1 == 0) {
 		/* both are denormalized */
@@ -350,16 +366,17 @@
 		result.parts.frac_lo = tmp_lo;
 		if (lt128(frac1_hi, frac1_lo, result.parts.frac_hi, result.parts.frac_lo)) {
-			/* TODO: underflow exception */
+			// TODO: underflow exception
 			return result;
 		}
+		
 		result.parts.exp = 0;
 		return result;
 	}
-
+	
 	/* add hidden bit */
 	or128(frac1_hi, frac1_lo,
 	    FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO,
 	    &frac1_hi, &frac1_lo);
-
+	
 	if (exp2 == 0) {
 		/* denormalized */
@@ -371,16 +388,15 @@
 		    &frac2_hi, &frac2_lo);
 	}
-
+	
 	/* create some space for rounding */
 	lshift128(frac1_hi, frac1_lo, 6, &frac1_hi, &frac1_lo);
 	lshift128(frac2_hi, frac2_lo, 6, &frac2_hi, &frac2_lo);
-
-	if (expdiff > FLOAT128_FRACTION_SIZE + 1) {
+	
+	if (expdiff > FLOAT128_FRACTION_SIZE + 1)
 		goto done;
-	}
-
+	
 	rshift128(frac2_hi, frac2_lo, expdiff, &tmp_hi, &tmp_lo);
 	sub128(frac1_hi, frac1_lo, tmp_hi, tmp_lo, &frac1_hi, &frac1_lo);
-
+	
 done:
 	/* TODO: find first nonzero digit and shift result and detect possibly underflow */
@@ -392,13 +408,13 @@
 		lshift128(frac1_hi, frac1_lo, 1, &frac1_hi, &frac1_lo);
 		/* TODO: fix underflow - frac1 == 0 does not necessary means underflow... */
-
+		
 		lshift128(FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO, 6,
 		    &tmp_hi, &tmp_lo);
 		and128(frac1_hi, frac1_lo, tmp_hi, tmp_lo, &tmp_hi, &tmp_lo);
 	}
-
+	
 	/* rounding - if first bit after fraction is set then round up */
 	add128(frac1_hi, frac1_lo, 0x0ll, 0x20ll, &frac1_hi, &frac1_lo);
-
+	
 	lshift128(FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO, 7,
 	   &tmp_hi, &tmp_lo);
@@ -408,5 +424,5 @@
 		rshift128(frac1_hi, frac1_lo, 1, &frac1_hi, &frac1_lo);
 	}
-
+	
 	/* Clear hidden bit and shift */
 	rshift128(frac1_hi, frac1_lo, 6, &frac1_hi, &frac1_lo);
@@ -416,7 +432,7 @@
 	result.parts.frac_hi = tmp_hi;
 	result.parts.frac_lo = tmp_lo;
-
+	
 	result.parts.exp = exp1;
-
+	
 	return result;
 }
Index: uspace/lib/softfloat/include/add.h
===================================================================
--- uspace/lib/softfloat/include/add.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/include/add.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -37,7 +37,8 @@
 #define __ADD_H__
 
-extern float32 addFloat32(float32, float32);
-extern float64 addFloat64(float64, float64);
-extern float128 addFloat128(float128, float128);
+extern float32 add_float32(float32, float32);
+extern float64 add_float64(float64, float64);
+extern float96 add_float96(float96, float96);
+extern float128 add_float128(float128, float128);
 
 #endif
Index: uspace/lib/softfloat/include/common.h
===================================================================
--- uspace/lib/softfloat/include/common.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/include/common.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -39,14 +39,14 @@
 #include <sftypes.h>
 
-extern float64 finishFloat64(int32_t, uint64_t, char);
-extern float128 finishFloat128(int32_t, uint64_t, uint64_t, char, uint64_t);
+extern float64 finish_float64(int32_t, uint64_t, char);
+extern float128 finish_float128(int32_t, uint64_t, uint64_t, char, uint64_t);
 
-extern int countZeroes8(uint8_t);
-extern int countZeroes32(uint32_t);
-extern int countZeroes64(uint64_t);
+extern int count_zeroes8(uint8_t);
+extern int count_zeroes32(uint32_t);
+extern int count_zeroes64(uint64_t);
 
-extern void roundFloat32(int32_t *, uint32_t *);
-extern void roundFloat64(int32_t *, uint64_t *);
-extern void roundFloat128(int32_t *, uint64_t *, uint64_t *);
+extern void round_float32(int32_t *, uint32_t *);
+extern void round_float64(int32_t *, uint64_t *);
+extern void round_float128(int32_t *, uint64_t *, uint64_t *);
 
 extern void lshift128(uint64_t, uint64_t, int, uint64_t *, uint64_t *);
Index: uspace/lib/softfloat/include/comparison.h
===================================================================
--- uspace/lib/softfloat/include/comparison.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/include/comparison.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -37,33 +37,43 @@
 #define __COMPARISON_H__
 
-extern int isFloat32NaN(float32);
-extern int isFloat32SigNaN(float32);
+extern int is_float32_nan(float32);
+extern int is_float32_signan(float32);
 
-extern int isFloat32Infinity(float32);
-extern int isFloat32Zero(float32);
+extern int is_float32_infinity(float32);
+extern int is_float32_zero(float32);
 
-extern int isFloat32eq(float32, float32);
-extern int isFloat32lt(float32, float32);
-extern int isFloat32gt(float32, float32);
+extern int is_float32_eq(float32, float32);
+extern int is_float32_lt(float32, float32);
+extern int is_float32_gt(float32, float32);
 
-extern int isFloat64NaN(float64);
-extern int isFloat64SigNaN(float64);
+extern int is_float64_nan(float64);
+extern int is_float64_signan(float64);
 
-extern int isFloat64Infinity(float64);
-extern int isFloat64Zero(float64);
+extern int is_float64_infinity(float64);
+extern int is_float64_zero(float64);
 
-extern int isFloat64eq(float64, float64);
-extern int isFloat64lt(float64, float64);
-extern int isFloat64gt(float64, float64);
+extern int is_float64_eq(float64, float64);
+extern int is_float64_lt(float64, float64);
+extern int is_float64_gt(float64, float64);
 
-extern int isFloat128NaN(float128);
-extern int isFloat128SigNaN(float128);
+extern int is_float96_nan(float96);
+extern int is_float96_signan(float96);
 
-extern int isFloat128Infinity(float128);
-extern int isFloat128Zero(float128);
+extern int is_float96_infinity(float96);
+extern int is_float96_zero(float96);
 
-extern int isFloat128eq(float128, float128);
-extern int isFloat128lt(float128, float128);
-extern int isFloat128gt(float128, float128);
+extern int is_float96_eq(float96, float96);
+extern int is_float96_lt(float96, float96);
+extern int is_float96_gt(float96, float96);
+
+extern int is_float128_nan(float128);
+extern int is_float128_signan(float128);
+
+extern int is_float128_infinity(float128);
+extern int is_float128_zero(float128);
+
+extern int is_float128_eq(float128, float128);
+extern int is_float128_lt(float128, float128);
+extern int is_float128_gt(float128, float128);
 
 #endif
Index: uspace/lib/softfloat/include/conversion.h
===================================================================
--- uspace/lib/softfloat/include/conversion.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/include/conversion.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -37,13 +37,17 @@
 #define __CONVERSION_H__
 
-extern float64 convertFloat32ToFloat64(float32);
-extern float128 convertFloat32ToFloat128(float32);
-extern float128 convertFloat64ToFloat128(float64);
+extern float64 float32_to_float64(float32);
+extern float96 float32_to_float96(float32);
+extern float128 float32_to_float128(float32);
+extern float96 float64_to_float96(float64);
+extern float128 float64_to_float128(float64);
+extern float128 float96_to_float128(float96);
 
-
-extern float32 convertFloat64ToFloat32(float64);
-extern float32 convertFloat128ToFloat32(float128);
-extern float64 convertFloat128ToFloat64(float128);
-
+extern float32 float64_to_float32(float64);
+extern float32 float96_to_float32(float96);
+extern float64 float96_to_float64(float96);
+extern float32 float128_to_float32(float128);
+extern float64 float128_to_float64(float128);
+extern float96 float128_to_float96(float128);
 
 extern uint32_t float32_to_uint32(float32);
@@ -59,4 +63,10 @@
 extern int64_t float64_to_int64(float64);
 
+extern uint32_t float96_to_uint32(float96);
+extern int32_t float96_to_int32(float96);
+
+extern uint64_t float96_to_uint64(float96);
+extern int64_t float96_to_int64(float96);
+
 extern uint32_t float128_to_uint32(float128);
 extern int32_t float128_to_int32(float128);
@@ -64,5 +74,4 @@
 extern uint64_t float128_to_uint64(float128);
 extern int64_t float128_to_int64(float128);
-
 
 extern float32 uint32_to_float32(uint32_t);
@@ -78,4 +87,10 @@
 extern float64 int64_to_float64(int64_t);
 
+extern float96 uint32_to_float96(uint32_t);
+extern float96 int32_to_float96(int32_t);
+
+extern float96 uint64_to_float96(uint64_t);
+extern float96 int64_to_float96(int64_t);
+
 extern float128 uint32_to_float128(uint32_t);
 extern float128 int32_to_float128(int32_t);
Index: uspace/lib/softfloat/include/div.h
===================================================================
--- uspace/lib/softfloat/include/div.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/include/div.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -37,7 +37,8 @@
 #define __DIV_H__
 
-extern float32 divFloat32(float32, float32);
-extern float64 divFloat64(float64, float64);
-extern float128 divFloat128(float128, float128);
+extern float32 div_float32(float32, float32);
+extern float64 div_float64(float64, float64);
+extern float96 div_float96(float96, float96);
+extern float128 div_float128(float128, float128);
 
 #endif
Index: uspace/lib/softfloat/include/mul.h
===================================================================
--- uspace/lib/softfloat/include/mul.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/include/mul.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -37,7 +37,8 @@
 #define __MUL_H__
 
-extern float32 mulFloat32(float32, float32);
-extern float64 mulFloat64(float64, float64);
-extern float128 mulFloat128(float128, float128);
+extern float32 mul_float32(float32, float32);
+extern float64 mul_float64(float64, float64);
+extern float96 mul_float96(float96, float96);
+extern float128 mul_float128(float128, float128);
 
 #endif
Index: uspace/lib/softfloat/include/sftypes.h
===================================================================
--- uspace/lib/softfloat/include/sftypes.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/include/sftypes.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -40,112 +40,566 @@
 #include <stdint.h>
 
-typedef union {
-	float f;
-	uint32_t binary;
-	
-	struct {
+/*
+ * For recognizing NaNs or infinity use specialized comparison
+ * functions, comparing with these constants is not sufficient.
+ */
+
+#define FLOAT32_NAN     UINT32_C(0x7FC00001)
+#define FLOAT32_SIGNAN  UINT32_C(0x7F800001)
+#define FLOAT32_INF     UINT32_C(0x7F800000)
+
+#define FLOAT64_NAN     UINT64_C(0x7FF8000000000001)
+#define FLOAT64_SIGNAN  UINT64_C(0x7FF0000000000001)
+#define FLOAT64_INF     UINT64_C(0x7FF0000000000000)
+
+#define FLOAT96_NAN_HI     UINT64_C(0x7FFF80000000)
+#define FLOAT96_NAN_LO     UINT32_C(0x00010000)
+#define FLOAT96_SIGNAN_HI  UINT64_C(0x7FFF00000000)
+#define FLOAT96_SIGNAN_LO  UINT32_C(0x00010000)
+
+#define FLOAT128_NAN_HI     UINT64_C(0x7FFF800000000000)
+#define FLOAT128_NAN_LO     UINT64_C(0x0000000000000001)
+#define FLOAT128_SIGNAN_HI  UINT64_C(0x7FFF000000000000)
+#define FLOAT128_SIGNAN_LO  UINT64_C(0x0000000000000001)
+#define FLOAT128_INF_HI     UINT64_C(0x7FFF000000000000)
+#define FLOAT128_INF_LO     UINT64_C(0x0000000000000000)
+
+#define FLOAT32_FRACTION_SIZE   23
+#define FLOAT64_FRACTION_SIZE   52
+#define FLOAT96_FRACTION_SIZE   64
+#define FLOAT128_FRACTION_SIZE  112
+#define FLOAT128_FRAC_HI_SIZE   48
+#define FLOAT128_FRAC_LO_SIZE   64
+
+#define FLOAT32_HIDDEN_BIT_MASK      UINT32_C(0x800000)
+#define FLOAT64_HIDDEN_BIT_MASK      UINT64_C(0x10000000000000)
+#define FLOAT128_HIDDEN_BIT_MASK_HI  UINT64_C(0x1000000000000)
+#define FLOAT128_HIDDEN_BIT_MASK_LO  UINT64_C(0x0000000000000000)
+
+#define FLOAT32_MAX_EXPONENT   0xFF
+#define FLOAT64_MAX_EXPONENT   0x7FF
+#define FLOAT96_MAX_EXPONENT   0x7FFF
+#define FLOAT128_MAX_EXPONENT  0x7FFF
+
+#define FLOAT32_BIAS   0x7F
+#define FLOAT64_BIAS   0x3FF
+#define FLOAT96_BIAS   0x3FFF
+#define FLOAT128_BIAS  0x3FFF
+
 #if defined(__BE__)
+
+typedef union {
+	uint32_t bin;
+	
+	struct {
 		uint32_t sign : 1;
 		uint32_t exp : 8;
 		uint32_t fraction : 23;
-#elif defined(__LE__)
-		uint32_t fraction : 23;
-		uint32_t exp : 8;
-		uint32_t sign : 1;
-#else
-	#error Unknown endianess
-#endif
-	} parts __attribute__ ((packed));
+	} parts __attribute__((packed));
 } float32;
 
 typedef union {
-	double d;
-	uint64_t binary;
-	
-	struct {
-#if defined(__BE__)
+	uint64_t bin;
+	
+	struct {
 		uint64_t sign : 1;
 		uint64_t exp : 11;
 		uint64_t fraction : 52;
-#elif defined(__LE__)
-		uint64_t fraction : 52;
-		uint64_t exp : 11;
+	} parts __attribute__((packed));
+} float64;
+
+typedef union {
+	struct {
+		uint64_t hi;
+		uint32_t lo;
+	} bin __attribute__((packed));
+	
+	struct {
+		uint64_t padding : 16;
 		uint64_t sign : 1;
-#else
-	#error Unknown endianess
-#endif
-	} parts __attribute__ ((packed));
-} float64;
-
-typedef union {
-	long double ld;
-	struct {
-#if defined(__BE__)
+		uint64_t exp : 15;
+		uint64_t fraction : 64;
+	} parts __attribute__((packed));
+} float96;
+
+typedef union {
+	struct {
 		uint64_t hi;
 		uint64_t lo;
-#elif defined(__LE__)
-		uint64_t lo;
-		uint64_t hi;
-#else
-	#error Unknown endianess
-#endif
-	} binary;
-
-	struct {
-#if defined(__BE__)
+	} bin __attribute__((packed));
+	
+	struct {
 		uint64_t sign : 1;
 		uint64_t exp : 15;
 		uint64_t frac_hi : 48;
 		uint64_t frac_lo : 64;
+	} parts __attribute__((packed));
+} float128;
+
 #elif defined(__LE__)
+
+typedef union {
+	uint32_t bin;
+	
+	struct {
+		uint32_t fraction : 23;
+		uint32_t exp : 8;
+		uint32_t sign : 1;
+	} parts __attribute__((packed));
+} float32;
+
+typedef union {
+	uint64_t bin;
+	
+	struct {
+		uint64_t fraction : 52;
+		uint64_t exp : 11;
+		uint64_t sign : 1;
+	} parts __attribute__((packed));
+} float64;
+
+typedef union {
+	struct {
+		uint32_t lo;
+		uint64_t hi;
+	} bin __attribute__((packed));
+	
+	struct {
+		uint64_t fraction : 64;
+		uint64_t exp : 15;
+		uint64_t sign : 1;
+		uint64_t padding : 16;
+	} parts __attribute__((packed));
+} float96;
+
+typedef union {
+	struct {
+		uint64_t lo;
+		uint64_t hi;
+	} bin __attribute__((packed));
+	
+	struct {
 		uint64_t frac_lo : 64;
 		uint64_t frac_hi : 48;
 		uint64_t exp : 15;
 		uint64_t sign : 1;
+	} parts __attribute__((packed));
+} float128;
+
 #else
 	#error Unknown endianess
 #endif
-	} parts __attribute__ ((packed));
-} float128;
-
-/*
- * For recognizing NaNs or infinity use specialized comparison functions,
- * comparing with these constants is not sufficient.
- */
-
-#define FLOAT32_NAN     0x7FC00001
-#define FLOAT32_SIGNAN  0x7F800001
-#define FLOAT32_INF     0x7F800000
-
-#define FLOAT64_NAN     0x7FF8000000000001ll
-#define FLOAT64_SIGNAN  0x7FF0000000000001ll
-#define FLOAT64_INF     0x7FF0000000000000ll
-
-#define FLOAT128_NAN_HI     0x7FFF800000000000ll
-#define FLOAT128_NAN_LO     0x0000000000000001ll
-#define FLOAT128_SIGNAN_HI  0x7FFF000000000000ll
-#define FLOAT128_SIGNAN_LO  0x0000000000000001ll
-#define FLOAT128_INF_HI     0x7FFF000000000000ll
-#define FLOAT128_INF_LO     0x0000000000000000ll
-
-#define FLOAT32_FRACTION_SIZE   23
-#define FLOAT64_FRACTION_SIZE   52
-#define FLOAT128_FRACTION_SIZE 112
-#define FLOAT128_FRAC_HI_SIZE   48
-#define FLOAT128_FRAC_LO_SIZE   64
-
-#define FLOAT32_HIDDEN_BIT_MASK      0x800000
-#define FLOAT64_HIDDEN_BIT_MASK      0x10000000000000ll
-#define FLOAT128_HIDDEN_BIT_MASK_HI  0x1000000000000ll
-#define FLOAT128_HIDDEN_BIT_MASK_LO  0x0000000000000000ll
-
-#define FLOAT32_MAX_EXPONENT  0xFF
-#define FLOAT64_MAX_EXPONENT  0x7FF
-#define FLOAT128_MAX_EXPONENT 0x7FFF
-
-#define FLOAT32_BIAS  0x7F
-#define FLOAT64_BIAS  0x3FF
-#define FLOAT80_BIAS  0x3FFF
-#define FLOAT128_BIAS 0x3FFF
+
+typedef union {
+	float val;
+	
+#if defined(FLOAT_SIZE_32)
+	float32 data;
+#elif defined(FLOAT_SIZE_64)
+	float64 data;
+#elif defined(FLOAT_SIZE_96)
+	float96 data;
+#elif defined(FLOAT_SIZE_128)
+	float128 data;
+#else
+	#error Unsupported float size
+#endif
+} float_t;
+
+typedef union {
+	double val;
+	
+#if defined(DOUBLE_SIZE_32)
+	float32 data;
+#elif defined(DOUBLE_SIZE_64)
+	float64 data;
+#elif defined(DOUBLE_SIZE_96)
+	float96 data;
+#elif defined(DOUBLE_SIZE_128)
+	float128 data;
+#else
+	#error Unsupported double size
+#endif
+} double_t;
+
+typedef union {
+	long double val;
+	
+#if defined(LONG_DOUBLE_SIZE_32)
+	float32 data;
+#elif defined(LONG_DOUBLE_SIZE_64)
+	float64 data;
+#elif defined(LONG_DOUBLE_SIZE_96)
+	float96 data;
+#elif defined(LONG_DOUBLE_SIZE_128)
+	float128 data;
+#else
+	#error Unsupported long double size
+#endif
+} long_double_t;
+
+
+#if defined(INT_SIZE_8)
+
+#define _to_int   _to_int8
+#define from_int  int8
+
+#elif defined(INT_SIZE_16)
+
+#define _to_int   _to_int16
+#define from_int  int16
+
+#elif defined(INT_SIZE_32)
+
+#define _to_int   _to_int32
+#define from_int  int32
+
+#elif defined(INT_SIZE_64)
+
+#define _to_int   _to_int64
+#define from_int  int64
+
+#endif
+
+
+#if defined(UINT_SIZE_8)
+
+#define _to_uint   _to_uint8
+#define from_uint  uint8
+
+#elif defined(UINT_SIZE_16)
+
+#define _to_uint   _to_uint16
+#define from_uint  uint16
+
+#elif defined(UINT_SIZE_32)
+
+#define _to_uint   _to_uint32
+#define from_uint  uint32
+
+#elif defined(UINT_SIZE_64)
+
+#define _to_uint   _to_uint64
+#define from_uint  uint64
+
+#endif
+
+
+#if defined(LONG_SIZE_8)
+
+#define _to_long   _to_int8
+#define from_long  int8
+
+#elif defined(LONG_SIZE_16)
+
+#define _to_long   _to_int16
+#define from_long  int16
+
+#elif defined(LONG_SIZE_32)
+
+#define _to_long   _to_int32
+#define from_long  int32
+
+#elif defined(LONG_SIZE_64)
+
+#define _to_long   _to_int64
+#define from_long  int64
+
+#endif
+
+
+#if defined(ULONG_SIZE_8)
+
+#define _to_ulong   _to_uint8
+#define from_ulong  uint8
+
+#elif defined(ULONG_SIZE_16)
+
+#define _to_ulong   _to_uint16
+#define from_ulong  uint16
+
+#elif defined(ULONG_SIZE_32)
+
+#define _to_ulong   _to_uint32
+#define from_ulong  uint32
+
+#elif defined(ULONG_SIZE_64)
+
+#define _to_ulong   _to_uint64
+#define from_ulong  uint64
+
+#endif
+
+
+#if defined(LLONG_SIZE_8)
+
+#define _to_llong   _to_int8
+#define from_llong  int8
+
+#elif defined(LLONG_SIZE_16)
+
+#define _to_llong   _to_int16
+#define from_llong  int16
+
+#elif defined(LLONG_SIZE_32)
+
+#define _to_llong   _to_int32
+#define from_llong  int32
+
+#elif defined(LLONG_SIZE_64)
+
+#define _to_llong   _to_int64
+#define from_llong  int64
+
+#endif
+
+
+#if defined(ULLONG_SIZE_8)
+
+#define _to_ullong   _to_uint8
+#define from_ullong  uint8
+
+#elif defined(ULLONG_SIZE_16)
+
+#define _to_ullong   _to_uint16
+#define from_ullong  uint16
+
+#elif defined(ULLONG_SIZE_32)
+
+#define _to_ullong   _to_uint32
+#define from_ullong  uint32
+
+#elif defined(ULLONG_SIZE_64)
+
+#define _to_ullong   _to_uint64
+#define from_ullong  uint64
+
+#endif
+
+
+#if defined(FLOAT_SIZE_32)
+
+#define add_float     add_float32
+#define sub_float     sub_float32
+#define mul_float     mul_float32
+#define div_float     div_float32
+#define _to_float     _to_float32
+#define from_float    float32
+#define is_float_nan  is_float32_nan
+#define is_float_eq   is_float32_eq
+#define is_float_lt   is_float32_lt
+#define is_float_gt   is_float32_gt
+
+#elif defined(FLOAT_SIZE_64)
+
+#define add_float     add_float64
+#define sub_float     sub_float64
+#define mul_float     mul_float64
+#define div_float     div_float64
+#define _to_float     _to_float64
+#define from_float    float64
+#define is_float_nan  is_float64_nan
+#define is_float_eq   is_float64_eq
+#define is_float_lt   is_float64_lt
+#define is_float_gt   is_float64_gt
+
+#elif defined(FLOAT_SIZE_96)
+
+#define add_float     add_float96
+#define sub_float     sub_float96
+#define mul_float     mul_float96
+#define div_float     div_float96
+#define _to_float     _to_float96
+#define from_float    float96
+#define is_float_nan  is_float96_nan
+#define is_float_eq   is_float96_eq
+#define is_float_lt   is_float96_lt
+#define is_float_gt   is_float96_gt
+
+#elif defined(FLOAT_SIZE_128)
+
+#define add_float     add_float128
+#define sub_float     sub_float128
+#define mul_float     mul_float128
+#define div_float     div_float128
+#define _to_float     _to_float128
+#define from_float    float128
+#define is_float_nan  is_float128_nan
+#define is_float_eq   is_float128_eq
+#define is_float_lt   is_float128_lt
+#define is_float_gt   is_float128_gt
+
+#endif
+
+
+#if defined(DOUBLE_SIZE_32)
+
+#define add_double     add_float32
+#define sub_double     sub_float32
+#define mul_double     mul_float32
+#define div_double     div_float32
+#define _to_double     _to_float32
+#define from_double    float32
+#define is_double_nan  is_float32_nan
+#define is_double_eq   is_float32_eq
+#define is_double_lt   is_float32_lt
+#define is_double_gt   is_float32_gt
+
+#elif defined(DOUBLE_SIZE_64)
+
+#define add_double     add_float64
+#define sub_double     sub_float64
+#define mul_double     mul_float64
+#define div_double     div_float64
+#define _to_double     _to_float64
+#define from_double    float64
+#define is_double_nan  is_float64_nan
+#define is_double_eq   is_float64_eq
+#define is_double_lt   is_float64_lt
+#define is_double_gt   is_float64_gt
+
+#elif defined(DOUBLE_SIZE_96)
+
+#define add_double     add_float96
+#define sub_double     sub_float96
+#define mul_double     mul_float96
+#define div_double     div_float96
+#define _to_double     _to_float96
+#define from_double    float96
+#define is_double_nan  is_float96_nan
+#define is_double_eq   is_float96_eq
+#define is_double_lt   is_float96_lt
+#define is_double_gt   is_float96_gt
+
+#elif defined(DOUBLE_SIZE_128)
+
+#define add_double     add_float128
+#define sub_double     sub_float128
+#define mul_double     mul_float128
+#define div_double     div_float128
+#define _to_double     _to_float128
+#define from_double    float128
+#define is_double_nan  is_float128_nan
+#define is_double_eq   is_float128_eq
+#define is_double_lt   is_float128_lt
+#define is_double_gt   is_float128_gt
+
+#endif
+
+
+#if defined(LONG_DOUBLE_SIZE_32)
+
+#define add_long_double     add_float32
+#define sub_long_double     sub_float32
+#define mul_long_double     mul_float32
+#define div_long_double     div_float32
+#define _to_long_double     _to_float32
+#define from_long_double    float32
+#define is_long_double_nan  is_float32_nan
+#define is_long_double_eq   is_float32_eq
+#define is_long_double_lt   is_float32_lt
+#define is_long_double_gt   is_float32_gt
+
+#elif defined(LONG_DOUBLE_SIZE_64)
+
+#define add_long_double     add_float64
+#define sub_long_double     sub_float64
+#define mul_long_double     mul_float64
+#define div_long_double     div_float64
+#define _to_long_double     _to_float64
+#define from_long_double    float64
+#define is_long_double_nan  is_float64_nan
+#define is_long_double_eq   is_float64_eq
+#define is_long_double_lt   is_float64_lt
+#define is_long_double_gt   is_float64_gt
+
+#elif defined(LONG_DOUBLE_SIZE_96)
+
+#define add_long_double     add_float96
+#define sub_long_double     sub_float96
+#define mul_long_double     mul_float96
+#define div_long_double     div_float96
+#define _to_long_double     _to_float96
+#define from_long_double    float96
+#define is_long_double_nan  is_float96_nan
+#define is_long_double_eq   is_float96_eq
+#define is_long_double_lt   is_float96_lt
+#define is_long_double_gt   is_float96_gt
+
+#elif defined(LONG_DOUBLE_SIZE_128)
+
+#define add_long_double     add_float128
+#define sub_long_double     sub_float128
+#define mul_long_double     mul_float128
+#define div_long_double     div_float128
+#define _to_long_double     _to_float128
+#define from_long_double    float128
+#define is_long_double_nan  is_float128_nan
+#define is_long_double_eq   is_float128_eq
+#define is_long_double_lt   is_float128_lt
+#define is_long_double_gt   is_float128_gt
+
+#endif
+
+
+#define CONCAT(a, b)       CONCAT_ARGS(a, b)
+#define CONCAT_ARGS(a, b)  a ## b
+
+#define float32_to_float32(arg)    (arg)
+#define float64_to_float64(arg)    (arg)
+#define float96_to_float96(arg)    (arg)
+#define float128_to_float128(arg)  (arg)
+
+#define float_to_double       CONCAT(from_float, _to_double)
+#define float_to_long_double  CONCAT(from_float, _to_long_double)
+#define float_to_int          CONCAT(from_float, _to_int)
+#define float_to_uint         CONCAT(from_float, _to_uint)
+#define float_to_long         CONCAT(from_float, _to_long)
+#define float_to_ulong        CONCAT(from_float, _to_ulong)
+#define float_to_llong        CONCAT(from_float, _to_llong)
+#define float_to_ullong       CONCAT(from_float, _to_ullong)
+
+#define double_to_float        CONCAT(from_double, _to_float)
+#define double_to_long_double  CONCAT(from_double, _to_long_double)
+#define double_to_int          CONCAT(from_double, _to_int)
+#define double_to_uint         CONCAT(from_double, _to_uint)
+#define double_to_long         CONCAT(from_double, _to_long)
+#define double_to_ulong        CONCAT(from_double, _to_ulong)
+#define double_to_llong        CONCAT(from_double, _to_llong)
+#define double_to_ullong       CONCAT(from_double, _to_ullong)
+
+#define long_double_to_float   CONCAT(from_long_double, _to_float)
+#define long_double_to_double  CONCAT(from_long_double, _to_double)
+#define long_double_to_int     CONCAT(from_long_double, _to_int)
+#define long_double_to_uint    CONCAT(from_long_double, _to_uint)
+#define long_double_to_long    CONCAT(from_long_double, _to_long)
+#define long_double_to_ulong   CONCAT(from_long_double, _to_ulong)
+#define long_double_to_llong   CONCAT(from_long_double, _to_llong)
+#define long_double_to_ullong  CONCAT(from_long_double, _to_ullong)
+
+#define int_to_float        CONCAT(from_int, _to_float)
+#define int_to_double       CONCAT(from_int, _to_double)
+#define int_to_long_double  CONCAT(from_int, _to_long_double)
+
+#define uint_to_float        CONCAT(from_uint, _to_float)
+#define uint_to_double       CONCAT(from_uint, _to_double)
+#define uint_to_long_double  CONCAT(from_uint, _to_long_double)
+
+#define long_to_float        CONCAT(from_long, _to_float)
+#define long_to_double       CONCAT(from_long, _to_double)
+#define long_to_long_double  CONCAT(from_long, _to_long_double)
+
+#define ulong_to_float        CONCAT(from_ulong, _to_float)
+#define ulong_to_double       CONCAT(from_ulong, _to_double)
+#define ulong_to_long_double  CONCAT(from_ulong, _to_long_double)
+
+#define llong_to_float        CONCAT(from_llong, _to_float)
+#define llong_to_double       CONCAT(from_llong, _to_double)
+#define llong_to_long_double  CONCAT(from_llong, _to_long_double)
+
+#define ullong_to_float        CONCAT(from_ullong, _to_float)
+#define ullong_to_double       CONCAT(from_ullong, _to_double)
+#define ullong_to_long_double  CONCAT(from_ullong, _to_long_double)
+
 
 #endif
Index: uspace/lib/softfloat/include/softfloat.h
===================================================================
--- uspace/lib/softfloat/include/softfloat.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/include/softfloat.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -169,8 +169,6 @@
 extern float __powisf2(float, int);
 extern double __powidf2 (double, int);
-extern long double __powitf2 (long double, int);
-extern long double __powixf2 (long double, int);
-
-
+extern long double __powitf2(long double, int);
+extern long double __powixf2(long double, int);
 
 /* SPARC quadruple-precision wrappers */
Index: uspace/lib/softfloat/include/sub.h
===================================================================
--- uspace/lib/softfloat/include/sub.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softfloat/include/sub.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -37,7 +37,8 @@
 #define __SUB_H__
 
-extern float32 subFloat32(float32, float32);
-extern float64 subFloat64(float64, float64);
-extern float128 subFloat128(float128, float128);
+extern float32 sub_float32(float32, float32);
+extern float64 sub_float64(float64, float64);
+extern float96 sub_float96(float96, float96);
+extern float128 sub_float128(float128, float128);
 
 #endif
Index: uspace/lib/softint/generic/division.c
===================================================================
--- uspace/lib/softint/generic/division.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softint/generic/division.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -37,8 +37,9 @@
 #include <division.h>
 
-#define ABSVAL(x) ( (x) > 0 ? (x) : -(x))
-#define SGN(x) ( (x) >= 0 ? 1 : 0 )
-				      
-static unsigned int divandmod32(unsigned int a, unsigned int b, unsigned int *remainder)
+#define ABSVAL(x)  ((x) > 0 ? (x) : -(x))
+#define SGN(x)     ((x) >= 0 ? 1 : 0)
+
+static unsigned int divandmod32(unsigned int a, unsigned int b,
+    unsigned int *remainder)
 {
 	unsigned int result;
@@ -53,29 +54,29 @@
 	}
 	
-	if ( a < b) {
+	if (a < b) {
 		*remainder = a;
 		return 0;
 	}
-
-	for ( ; steps > 0; steps--) {
+	
+	for (; steps > 0; steps--) {
 		/* shift one bit to remainder */
-		*remainder = ( (*remainder) << 1) | (( a >> 31) & 0x1);
+		*remainder = ((*remainder) << 1) | (( a >> 31) & 0x1);
 		result <<= 1;
 		
 		if (*remainder >= b) {
-				*remainder -= b;
-				result |= 0x1;
+			*remainder -= b;
+			result |= 0x1;
 		}
 		a <<= 1;
 	}
-
+	
 	return result;
 }
 
-
-static unsigned long long divandmod64(unsigned long long a, unsigned long long b, unsigned long long *remainder)
+static unsigned long long divandmod64(unsigned long long a,
+    unsigned long long b, unsigned long long *remainder)
 {
 	unsigned long long result;
-	int steps = sizeof(unsigned long long) * 8; 
+	int steps = sizeof(unsigned long long) * 8;
 	
 	*remainder = 0;
@@ -87,45 +88,45 @@
 	}
 	
-	if ( a < b) {
+	if (a < b) {
 		*remainder = a;
 		return 0;
 	}
-
-	for ( ; steps > 0; steps--) {
+	
+	for (; steps > 0; steps--) {
 		/* shift one bit to remainder */
-		*remainder = ( (*remainder) << 1) | ((a >> 63) & 0x1);
+		*remainder = ((*remainder) << 1) | ((a >> 63) & 0x1);
 		result <<= 1;
 		
 		if (*remainder >= b) {
-				*remainder -= b;
-				result |= 0x1;
+			*remainder -= b;
+			result |= 0x1;
 		}
 		a <<= 1;
 	}
-
+	
 	return result;
 }
 
 /* 32bit integer division */
-int __divsi3(int a, int b) 
-{
-	unsigned int rem;
-	int result;
-	
-	result = (int)divandmod32(ABSVAL(a), ABSVAL(b), &rem);
-
-	if ( SGN(a) == SGN(b)) return result;
+int __divsi3(int a, int b)
+{
+	unsigned int rem;
+	int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
+	
+	if (SGN(a) == SGN(b))
+		return result;
+	
 	return -result;
 }
 
 /* 64bit integer division */
-long long __divdi3(long long a, long long b) 
-{
-	unsigned long long rem;
-	long long result;
-	
-	result = (long long)divandmod64(ABSVAL(a), ABSVAL(b), &rem);
-
-	if ( SGN(a) == SGN(b)) return result;
+long long __divdi3(long long a, long long b)
+{
+	unsigned long long rem;
+	long long result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
+	
+	if (SGN(a) == SGN(b))
+		return result;
+	
 	return -result;
 }
@@ -141,5 +142,5 @@
 unsigned long long __udivdi3(unsigned long long a, unsigned long long b)
 {
-	unsigned long long  rem;
+	unsigned long long rem;
 	return divandmod64(a, b, &rem);
 }
@@ -152,13 +153,12 @@
 	
 	/* if divident is negative, remainder must be too */
-	if (!(SGN(a))) {
-		return -((int)rem);
-	}
-	
-	return (int)rem;
+	if (!(SGN(a)))
+		return -((int) rem);
+	
+	return (int) rem;
 }
 
 /* 64bit remainder of the signed division */
-long long __moddi3(long long a,long  long b)
+long long __moddi3(long long a, long long b)
 {
 	unsigned long long rem;
@@ -166,9 +166,8 @@
 	
 	/* if divident is negative, remainder must be too */
-	if (!(SGN(a))) {
-		return -((long long)rem);
-	}
-	
-	return (long long)rem;
+	if (!(SGN(a)))
+		return -((long long) rem);
+	
+	return (long long) rem;
 }
 
@@ -189,5 +188,40 @@
 }
 
-unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b, unsigned long long *c)
+int __divmodsi3(int a, int b, int *c)
+{
+	unsigned int rem;
+	int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
+	
+	if (SGN(a) == SGN(b)) {
+		*c = rem;
+		return result;
+	}
+	
+	*c = -rem;
+	return -result;
+}
+
+unsigned int __udivmodsi3(unsigned int a, unsigned int b,
+    unsigned int *c)
+{
+	return divandmod32(a, b, c);
+}
+
+long long __divmoddi3(long long a, long long b, long long *c)
+{
+	unsigned long long rem;
+	long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
+	
+	if (SGN(a) == SGN(b)) {
+		*c = rem;
+		return result;
+	}
+	
+	*c = -rem;
+	return -result;
+}
+
+unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b,
+    unsigned long long *c)
 {
 	return divandmod64(a, b, c);
Index: uspace/lib/softint/include/comparison.h
===================================================================
--- uspace/lib/softint/include/comparison.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softint/include/comparison.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,8 +38,8 @@
 
 /* Signed comparison (a < b => 0, a == b => 1, a > b => 2). */
-int __cmpdi2 (long long a, long long b);
+extern int __cmpdi2(long long, long long);
 
 /* Unsigned comparison (a < b => 0, a == b => 1, a > b => 2). */
-int __ucmpdi2 (unsigned long long a, unsigned long long b);
+extern int __ucmpdi2(unsigned long long, unsigned long long);
 
 #endif
Index: uspace/lib/softint/include/division.h
===================================================================
--- uspace/lib/softint/include/division.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softint/include/division.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -29,5 +29,5 @@
 /** @addtogroup softint
  * @{
- */ 
+ */
 /**
  * @file
@@ -37,30 +37,22 @@
 #define __SOFTINT_DIVISION_H__
 
+extern int __divsi3(int, int);
+extern long long __divdi3(long long, long long);
 
-/* 32bit integer division */
-int __divsi3(int a, int b);
+extern unsigned int __udivsi3(unsigned int, unsigned int);
+extern unsigned long long __udivdi3(unsigned long long, unsigned long long);
 
-/* 64bit integer division */
-long long __divdi3(long long a, long long b);
+extern int __modsi3(int, int);
+extern long long __moddi3(long long, long long);
 
-/* 32bit unsigned integer division */
-unsigned int __udivsi3(unsigned int a, unsigned int b);
+extern unsigned int __umodsi3(unsigned int, unsigned int);
+extern unsigned long long __umoddi3(unsigned long long, unsigned long long);
 
-/* 64bit unsigned integer division */
-unsigned long long __udivdi3(unsigned long long a, unsigned long long b);
+extern int __divmodsi3(int, int, int *);
+extern unsigned int __udivmodsi3(unsigned int, unsigned int, unsigned int *);
 
-/* 32bit remainder of the signed division */
-int __modsi3(int a, int b);
-
-/* 64bit remainder of the signed division */
-long long __moddi3(long long a, long long b);
-
-/* 32bit remainder of the unsigned division */
-unsigned int __umodsi3(unsigned int a, unsigned int b);
-
-/* 64bit remainder of the unsigned division */
-unsigned long long __umoddi3(unsigned long long a, unsigned long long b);
-
-unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b, unsigned long long *c); 
+extern long long __divmoddi3(long long, long long, long long *);
+extern unsigned long long __udivmoddi3(unsigned long long, unsigned long long,
+    unsigned long long *);
 
 #endif
@@ -68,3 +60,2 @@
 /** @}
  */
-
Index: uspace/lib/softint/include/lltype.h
===================================================================
--- uspace/lib/softint/include/lltype.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softint/include/lltype.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -39,6 +39,6 @@
 #include <stdint.h>
 
-#define HALF_BIT_CNT (sizeof(int32_t) * sizeof(char))
-#define WHOLE_BIT_CNT (sizeof(int64_t) * sizeof(char))
+#define HALF_BIT_CNT   (sizeof(int32_t) * sizeof(char))
+#define WHOLE_BIT_CNT  (sizeof(int64_t) * sizeof(char))
 
 #ifdef __BE__
Index: uspace/lib/softint/include/multiplication.h
===================================================================
--- uspace/lib/softint/include/multiplication.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softint/include/multiplication.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -29,5 +29,5 @@
 /** @addtogroup softint
  * @{
- */ 
+ */
 /**
  * @file
@@ -38,5 +38,5 @@
 
 /* 64 bit multiplication */
-long long __muldi3(long long a, long long b);
+extern long long __muldi3(long long, long long);
 
 #endif
Index: uspace/lib/softint/include/shift.h
===================================================================
--- uspace/lib/softint/include/shift.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/softint/include/shift.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,11 +38,11 @@
 
 /* Arithmetic/logical shift left. */
-long long __ashldi3 (long long val, int shift);
+extern long long __ashldi3(long long, int);
 
 /* Arithmetic shift right. */
-long long __ashrdi3 (long long val, int shift);
+extern long long __ashrdi3(long long, int);
 
 /* Logical shift right. */
-long long __lshrdi3 (long long val, int shift);
+extern long long __lshrdi3(long long, int);
 
 #endif
Index: uspace/lib/usb/src/ddfiface.c
===================================================================
--- uspace/lib/usb/src/ddfiface.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/usb/src/ddfiface.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -33,5 +33,4 @@
  * Implementations of DDF interfaces functions (actual implementation).
  */
-#include <ipc/devman.h>
 #include <devman.h>
 #include <async.h>
Index: uspace/lib/usb/src/dev.c
===================================================================
--- uspace/lib/usb/src/dev.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/usb/src/dev.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -122,5 +122,5 @@
 	char *ptr;
 
-	rc = str_uint64(path, &ptr, 10, false, &sid);
+	rc = str_uint64_t(path, &ptr, 10, false, &sid);
 	if (rc != EOK) {
 		return false;
Index: uspace/lib/usbvirt/src/ipc_dev.c
===================================================================
--- uspace/lib/usbvirt/src/ipc_dev.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/usbvirt/src/ipc_dev.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,5 +38,4 @@
 #include <assert.h>
 #include <async.h>
-#include <devman.h>
 #include <usbvirt/device.h>
 #include <usbvirt/ipc.h>
Index: uspace/lib/usbvirt/src/ipc_hc.c
===================================================================
--- uspace/lib/usbvirt/src/ipc_hc.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/lib/usbvirt/src/ipc_hc.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -38,5 +38,4 @@
 #include <assert.h>
 #include <async.h>
-#include <devman.h>
 #include <usbvirt/device.h>
 #include <usbvirt/ipc.h>
Index: uspace/srv/fs/exfat/exfat_bitmap.c
===================================================================
--- uspace/srv/fs/exfat/exfat_bitmap.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/fs/exfat/exfat_bitmap.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -48,5 +48,5 @@
 
 
-int bitmap_is_free(exfat_bs_t *bs, service_id_t service_id, 
+int exfat_bitmap_is_free(exfat_bs_t *bs, service_id_t service_id, 
     exfat_cluster_t clst)
 {
@@ -89,5 +89,5 @@
 }
 
-int bitmap_set_cluster(exfat_bs_t *bs, service_id_t service_id, 
+int exfat_bitmap_set_cluster(exfat_bs_t *bs, service_id_t service_id, 
     exfat_cluster_t clst)
 {
@@ -124,5 +124,5 @@
 }
 
-int bitmap_clear_cluster(exfat_bs_t *bs, service_id_t service_id, 
+int exfat_bitmap_clear_cluster(exfat_bs_t *bs, service_id_t service_id, 
     exfat_cluster_t clst)
 {
@@ -160,5 +160,5 @@
 }
 
-int bitmap_set_clusters(exfat_bs_t *bs, service_id_t service_id, 
+int exfat_bitmap_set_clusters(exfat_bs_t *bs, service_id_t service_id, 
     exfat_cluster_t firstc, exfat_cluster_t count)
 {
@@ -168,8 +168,8 @@
 
 	while (clst < firstc + count ) {
-		rc = bitmap_set_cluster(bs, service_id, clst);
+		rc = exfat_bitmap_set_cluster(bs, service_id, clst);
 		if (rc != EOK) {
 			if (clst - firstc > 0)
-				(void) bitmap_clear_clusters(bs, service_id,
+				(void) exfat_bitmap_clear_clusters(bs, service_id,
 				    firstc, clst - firstc);
 			return rc;
@@ -180,5 +180,5 @@
 }
 
-int bitmap_clear_clusters(exfat_bs_t *bs, service_id_t service_id, 
+int exfat_bitmap_clear_clusters(exfat_bs_t *bs, service_id_t service_id, 
     exfat_cluster_t firstc, exfat_cluster_t count)
 {
@@ -188,5 +188,5 @@
 
 	while (clst < firstc + count) {
-		rc = bitmap_clear_cluster(bs, service_id, clst);
+		rc = exfat_bitmap_clear_cluster(bs, service_id, clst);
 		if (rc != EOK)
 			return rc;
@@ -196,5 +196,5 @@
 }
 
-int bitmap_alloc_clusters(exfat_bs_t *bs, service_id_t service_id, 
+int exfat_bitmap_alloc_clusters(exfat_bs_t *bs, service_id_t service_id, 
     exfat_cluster_t *firstc, exfat_cluster_t count)
 {
@@ -204,8 +204,8 @@
 	while (startc < DATA_CNT(bs) + 2) {
 		endc = startc;
-		while (bitmap_is_free(bs, service_id, endc) == EOK) {
+		while (exfat_bitmap_is_free(bs, service_id, endc) == EOK) {
 			if ((endc - startc) + 1 == count) {
 				*firstc = startc;
-				return bitmap_set_clusters(bs, service_id, startc, count);
+				return exfat_bitmap_set_clusters(bs, service_id, startc, count);
 			} else
 				endc++;
@@ -217,9 +217,9 @@
 
 
-int bitmap_append_clusters(exfat_bs_t *bs, exfat_node_t *nodep, 
+int exfat_bitmap_append_clusters(exfat_bs_t *bs, exfat_node_t *nodep, 
     exfat_cluster_t count)
 {
 	if (nodep->firstc == 0) {
-		return bitmap_alloc_clusters(bs, nodep->idx->service_id, 
+		return exfat_bitmap_alloc_clusters(bs, nodep->idx->service_id, 
 		    &nodep->firstc, count);
 	} else {
@@ -228,7 +228,7 @@
 
 		clst = lastc + 1;
-		while (bitmap_is_free(bs, nodep->idx->service_id, clst) == EOK) {
+		while (exfat_bitmap_is_free(bs, nodep->idx->service_id, clst) == EOK) {
 			if (clst - lastc == count){
-				return bitmap_set_clusters(bs, nodep->idx->service_id, 
+				return exfat_bitmap_set_clusters(bs, nodep->idx->service_id, 
 				    lastc + 1, count);
 			} else
@@ -240,5 +240,5 @@
 
 
-int bitmap_free_clusters(exfat_bs_t *bs, exfat_node_t *nodep, 
+int exfat_bitmap_free_clusters(exfat_bs_t *bs, exfat_node_t *nodep, 
     exfat_cluster_t count)
 {
@@ -247,9 +247,9 @@
 	lastc -= count;
 
-	return bitmap_clear_clusters(bs, nodep->idx->service_id, lastc + 1, count);
-}
-
-
-int bitmap_replicate_clusters(exfat_bs_t *bs, exfat_node_t *nodep)
+	return exfat_bitmap_clear_clusters(bs, nodep->idx->service_id, lastc + 1, count);
+}
+
+
+int exfat_bitmap_replicate_clusters(exfat_bs_t *bs, exfat_node_t *nodep)
 {
 	int rc;
Index: uspace/srv/fs/exfat/exfat_bitmap.h
===================================================================
--- uspace/srv/fs/exfat/exfat_bitmap.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/fs/exfat/exfat_bitmap.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -42,20 +42,20 @@
 struct exfat_bs;
 
-extern int bitmap_alloc_clusters(struct exfat_bs *, service_id_t, 
+extern int exfat_bitmap_alloc_clusters(struct exfat_bs *, service_id_t, 
     exfat_cluster_t *, exfat_cluster_t);
-extern int bitmap_append_clusters(struct exfat_bs *, struct exfat_node *, 
+extern int exfat_bitmap_append_clusters(struct exfat_bs *, struct exfat_node *, 
     exfat_cluster_t);
-extern int bitmap_free_clusters(struct exfat_bs *, struct exfat_node *, 
+extern int exfat_bitmap_free_clusters(struct exfat_bs *, struct exfat_node *, 
     exfat_cluster_t);
-extern int bitmap_replicate_clusters(struct exfat_bs *, struct exfat_node *); 
+extern int exfat_bitmap_replicate_clusters(struct exfat_bs *, struct exfat_node *); 
 
-extern int bitmap_is_free(struct exfat_bs *, service_id_t, exfat_cluster_t);
-extern int bitmap_set_cluster(struct exfat_bs *, service_id_t, exfat_cluster_t);
-extern int bitmap_clear_cluster(struct exfat_bs *, service_id_t, 
+extern int exfat_bitmap_is_free(struct exfat_bs *, service_id_t, exfat_cluster_t);
+extern int exfat_bitmap_set_cluster(struct exfat_bs *, service_id_t, exfat_cluster_t);
+extern int exfat_bitmap_clear_cluster(struct exfat_bs *, service_id_t, 
     exfat_cluster_t);
 
-extern int bitmap_set_clusters(struct exfat_bs *, service_id_t, 
+extern int exfat_bitmap_set_clusters(struct exfat_bs *, service_id_t, 
     exfat_cluster_t, exfat_cluster_t);
-extern int bitmap_clear_clusters(struct exfat_bs *, service_id_t, 
+extern int exfat_bitmap_clear_clusters(struct exfat_bs *, service_id_t, 
     exfat_cluster_t, exfat_cluster_t);
 
Index: uspace/srv/fs/exfat/exfat_dentry.c
===================================================================
--- uspace/srv/fs/exfat/exfat_dentry.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/fs/exfat/exfat_dentry.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -130,5 +130,5 @@
 }
 
-size_t utf16_length(const uint16_t *wstr)
+size_t exfat_utf16_length(const uint16_t *wstr)
 {
 	size_t len = 0;
Index: uspace/srv/fs/exfat/exfat_dentry.h
===================================================================
--- uspace/srv/fs/exfat/exfat_dentry.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/fs/exfat/exfat_dentry.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -160,5 +160,5 @@
 extern bool exfat_valid_name(const char *);
 
-extern size_t utf16_length(const uint16_t *);
+extern size_t exfat_utf16_length(const uint16_t *);
 
 
Index: uspace/srv/fs/exfat/exfat_directory.c
===================================================================
--- uspace/srv/fs/exfat/exfat_directory.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/fs/exfat/exfat_directory.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -371,5 +371,5 @@
 	ds.stream.valid_data_size = 0;
 	ds.stream.data_size = 0;
-	ds.stream.name_size = utf16_length(wname);
+	ds.stream.name_size = exfat_utf16_length(wname);
 	ds.stream.hash = host2uint16_t_le(exfat_name_hash(wname, uctable, 
 	    uctable_chars));
Index: uspace/srv/fs/exfat/exfat_fat.c
===================================================================
--- uspace/srv/fs/exfat/exfat_fat.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/fs/exfat/exfat_fat.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -127,5 +127,5 @@
 {
 	exfat_cluster_t firstc = nodep->firstc;
-	exfat_cluster_t currc;
+	exfat_cluster_t currc = 0;
 	aoff64_t relbn = bn;
 	int rc;
@@ -314,5 +314,5 @@
 	    clst++) {
 		/* Need to rewrite because of multiple exfat_bitmap_get calls */
-		if (bitmap_is_free(bs, service_id, clst) == EOK) {
+		if (exfat_bitmap_is_free(bs, service_id, clst) == EOK) {
 			/*
 			 * The cluster is free. Put it into our stack
@@ -325,5 +325,5 @@
 				goto exit_error;
 			found++;
-			rc = bitmap_set_cluster(bs, service_id, clst);
+			rc = exfat_bitmap_set_cluster(bs, service_id, clst);
 			if (rc != EOK)
 				goto exit_error;
@@ -346,5 +346,5 @@
 	/* If something wrong - free the clusters */
 	while (found--) {
-		(void) bitmap_clear_cluster(bs, service_id, lifo[found]);
+		(void) exfat_bitmap_clear_cluster(bs, service_id, lifo[found]);
 		(void) exfat_set_cluster(bs, service_id, lifo[found], 0);
 	}
@@ -378,5 +378,5 @@
 		if (rc != EOK)
 			return rc;
-		rc = bitmap_clear_cluster(bs, service_id, firstc);
+		rc = exfat_bitmap_clear_cluster(bs, service_id, firstc);
 		if (rc != EOK)
 			return rc;
Index: uspace/srv/fs/exfat/exfat_ops.c
===================================================================
--- uspace/srv/fs/exfat/exfat_ops.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/fs/exfat/exfat_ops.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -405,5 +405,5 @@
 
 	if (!nodep->fragmented) {
-		rc = bitmap_append_clusters(bs, nodep, clusters);
+		rc = exfat_bitmap_append_clusters(bs, nodep, clusters);
 		if (rc != ENOSPC)
 			return rc;
@@ -411,5 +411,5 @@
 			nodep->fragmented = true;
 			nodep->dirty = true;		/* need to sync node */
-			rc = bitmap_replicate_clusters(bs, nodep);
+			rc = exfat_bitmap_replicate_clusters(bs, nodep);
 			if (rc != EOK)
 				return rc;
@@ -457,5 +457,5 @@
 
 		clsts = prev_clsts - new_clsts;
-		rc = bitmap_free_clusters(bs, nodep, clsts);
+		rc = exfat_bitmap_free_clusters(bs, nodep, clsts);
 		if (rc != EOK)
 			return rc;
@@ -704,5 +704,5 @@
 				nodep->firstc);
 		else
-			rc = bitmap_free_clusters(bs, nodep, 
+			rc = exfat_bitmap_free_clusters(bs, nodep, 
 			    ROUND_UP(nodep->size, BPC(bs)) / BPC(bs));
 	} 
@@ -758,9 +758,5 @@
 
 	fibril_mutex_unlock(&parentp->idx->lock);
-	if (rc != EOK)
-		return rc;
-
 	fibril_mutex_lock(&childp->idx->lock);
-
 
 	childp->idx->pfc = parentp->firstc;
@@ -1463,5 +1459,8 @@
 	}
 
-	(void) exfat_node_put(fn);
+	int rc2 = exfat_node_put(fn);
+	if (rc == EOK && rc2 != EOK)
+		rc = rc2;
+
 	return rc;
 }
Index: uspace/srv/fs/fat/fat_dentry.c
===================================================================
--- uspace/srv/fs/fat/fat_dentry.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/fs/fat/fat_dentry.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -334,5 +334,5 @@
 	while (i < count) {
 		if ((ch = str_decode(src, &off, STR_NO_LIMIT)) != 0) {
-			if (ascii_check(ch) & IS_D_CHAR(ch))
+			if (ascii_check(ch) && IS_D_CHAR(ch))
 				*dst = toupper(ch);
 			else
Index: uspace/srv/fs/fat/fat_directory.c
===================================================================
--- uspace/srv/fs/fat/fat_directory.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/fs/fat/fat_directory.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -162,4 +162,11 @@
 	int rc;
 
+	void *data;
+	fat_instance_t *instance;
+
+	rc = fs_instance_get(di->nodep->idx->service_id, &data);
+	assert(rc == EOK);
+	instance = (fat_instance_t *) data;
+	
 	do {
 		rc = fat_directory_get(di, &d);
@@ -177,5 +184,5 @@
 				long_entry_count--;
 				if ((FAT_LFN_ORDER(d) == long_entry_count) && 
-					(checksum == FAT_LFN_CHKSUM(d))) {
+				    (checksum == FAT_LFN_CHKSUM(d))) {
 					/* Right order! */
 					fat_lfn_get_entry(d, wname,
@@ -189,5 +196,5 @@
 					long_entry = false;
 				}
-			} else if (FAT_IS_LFN(d)) {
+			} else if (FAT_IS_LFN(d) && instance->lfn_enabled) {
 				/* We found Last long entry! */
 				if (FAT_LFN_COUNT(d) <= FAT_LFN_MAX_COUNT) {
@@ -308,5 +315,5 @@
 		checksum = fat_dentry_chksum(de->name);
 
-		rc = fat_directory_seek(di, start_pos+long_entry_count);
+		rc = fat_directory_seek(di, start_pos + long_entry_count);
 		if (rc != EOK)
 			return rc;
Index: uspace/srv/hid/fb/port/ega.c
===================================================================
--- uspace/srv/hid/fb/port/ega.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/hid/fb/port/ega.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -117,5 +117,5 @@
 	uint8_t glyph;
 	
-	if ((field->ch >= 0) && (field->ch < 128))
+	if (ascii_check(field->ch))
 		glyph = field->ch;
 	else
Index: uspace/srv/hid/fb/port/kchar.c
===================================================================
--- uspace/srv/hid/fb/port/kchar.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/hid/fb/port/kchar.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -48,5 +48,5 @@
 static void kchar_putchar(wchar_t ch)
 {
-	if ((ch >= 0) && (ch < 128))
+	if (ascii_check(ch))
 		*kchar.addr = ch;
 	else
Index: uspace/srv/hid/fb/port/kfb.c
===================================================================
--- uspace/srv/hid/fb/port/kfb.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/hid/fb/port/kfb.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -409,6 +409,6 @@
 	charfield_t *field = screenbuffer_field_at(vp->backbuf, col, row);
 	
-	pixel_t bgcolor;
-	pixel_t fgcolor;
+	pixel_t bgcolor = 0;
+	pixel_t fgcolor = 0;
 	attrs_rgb(field->attrs, &bgcolor, &fgcolor);
 	
@@ -525,6 +525,6 @@
 	}
 	
-	pixel_t bgcolor;
-	pixel_t fgcolor;
+	pixel_t bgcolor = 0;
+	pixel_t fgcolor = 0;
 	attrs_rgb(vp->attrs, &bgcolor, &fgcolor);
 	
Index: uspace/srv/hid/fb/port/niagara.c
===================================================================
--- uspace/srv/hid/fb/port/niagara.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/hid/fb/port/niagara.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -68,5 +68,5 @@
 static void niagara_putchar(wchar_t ch)
 {
-	if ((ch >= 0) && (ch < 128))
+	if (ascii_check(ch))
 		niagara_putc(ch);
 	else
Index: uspace/srv/hid/input/port/gxemul.c
===================================================================
--- uspace/srv/hid/input/port/gxemul.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/hid/input/port/gxemul.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -57,4 +57,11 @@
 static kbd_dev_t *kbd_dev;
 
+static irq_pio_range_t gxemul_ranges[] = {
+	{
+		.base = 0,
+		.size = 1
+	}
+};
+
 static irq_cmd_t gxemul_cmds[] = {
 	{ 
@@ -69,4 +76,6 @@
 
 static irq_code_t gxemul_kbd = {
+	sizeof(gxemul_ranges) / sizeof(irq_pio_range_t),
+	gxemul_ranges,
 	sizeof(gxemul_cmds) / sizeof(irq_cmd_t),
 	gxemul_cmds
@@ -81,5 +90,5 @@
 	
 	sysarg_t addr;
-	if (sysinfo_get_value("kbd.address.virtual", &addr) != EOK)
+	if (sysinfo_get_value("kbd.address.physical", &addr) != EOK)
 		return -1;
 	
@@ -89,4 +98,5 @@
 	
 	async_set_interrupt_received(gxemul_irq_handler);
+	gxemul_ranges[0].base = addr;
 	gxemul_cmds[0].addr = (void *) addr;
 	irq_register(inr, device_assign_devno(), 0, &gxemul_kbd);
Index: uspace/srv/hid/input/port/msim.c
===================================================================
--- uspace/srv/hid/input/port/msim.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/hid/input/port/msim.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -57,4 +57,11 @@
 static kbd_dev_t *kbd_dev;
 
+static irq_pio_range_t msim_ranges[] = {
+	{
+		.base = 0,
+		.size = 1
+	}
+};
+
 static irq_cmd_t msim_cmds[] = {
 	{
@@ -69,4 +76,6 @@
 
 static irq_code_t msim_kbd = {
+	sizeof(msim_ranges) / sizeof(irq_pio_range_t),
+	msim_ranges,
 	sizeof(msim_cmds) / sizeof(irq_cmd_t),
 	msim_cmds
@@ -79,6 +88,6 @@
 	kbd_dev = kdev;
 
-	sysarg_t vaddr;
-	if (sysinfo_get_value("kbd.address.virtual", &vaddr) != EOK)
+	sysarg_t paddr;
+	if (sysinfo_get_value("kbd.address.physical", &paddr) != EOK)
 		return -1;
 	
@@ -87,5 +96,6 @@
 		return -1;
 	
-	msim_cmds[0].addr = (void *) vaddr;
+	msim_ranges[0].base = paddr;
+	msim_cmds[0].addr = (void *) paddr;
 	async_set_interrupt_received(msim_irq_handler);
 	irq_register(inr, device_assign_devno(), 0, &msim_kbd);
Index: uspace/srv/hid/input/port/ns16550.c
===================================================================
--- uspace/srv/hid/input/port/ns16550.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/hid/input/port/ns16550.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -70,4 +70,11 @@
 #define LSR_DATA_READY  0x01
 
+static irq_pio_range_t ns16550_ranges[] = {
+	{
+		.base = 0,
+		.size = 8
+	}
+};
+
 static irq_cmd_t ns16550_cmds[] = {
 	{
@@ -98,4 +105,6 @@
 
 irq_code_t ns16550_kbd = {
+	sizeof(ns16550_ranges) / sizeof(irq_pio_range_t),
+	ns16550_ranges,
 	sizeof(ns16550_cmds) / sizeof(irq_cmd_t),
 	ns16550_cmds
@@ -105,5 +114,4 @@
 
 static uintptr_t ns16550_physical;
-static uintptr_t ns16550_kernel;
 
 static kbd_dev_t *kbd_dev;
@@ -124,13 +132,11 @@
 		return -1;
 	
-	if (sysinfo_get_value("kbd.address.kernel", &ns16550_kernel) != EOK)
-		return -1;
-	
 	sysarg_t inr;
 	if (sysinfo_get_value("kbd.inr", &inr) != EOK)
 		return -1;
 	
-	ns16550_kbd.cmds[0].addr = (void *) (ns16550_kernel + LSR_REG);
-	ns16550_kbd.cmds[3].addr = (void *) (ns16550_kernel + RBR_REG);
+	ns16550_kbd.ranges[0].base = ns16550_physical;
+	ns16550_kbd.cmds[0].addr = (void *) (ns16550_physical + LSR_REG);
+	ns16550_kbd.cmds[3].addr = (void *) (ns16550_physical + RBR_REG);
 	
 	async_set_interrupt_received(ns16550_irq_handler);
Index: uspace/srv/hid/input/port/pl050.c
===================================================================
--- uspace/srv/hid/input/port/pl050.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/hid/input/port/pl050.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -61,5 +61,15 @@
 static kbd_dev_t *kbd_dev;
 
+#define PL050_STAT	4
+#define PL050_DATA	8
+
 #define PL050_STAT_RXFULL  (1 << 4)
+
+static irq_pio_range_t pl050_ranges[] = {
+	{
+		.base = 0,
+		.size = 9, 
+	}
+};
 
 static irq_cmd_t pl050_cmds[] = {
@@ -91,4 +101,6 @@
 
 static irq_code_t pl050_kbd = {
+	sizeof(pl050_ranges) / sizeof(irq_pio_range_t),
+	pl050_ranges,
 	sizeof(pl050_cmds) / sizeof(irq_cmd_t),
 	pl050_cmds
@@ -102,13 +114,10 @@
 	
 	sysarg_t addr;
-	if (sysinfo_get_value("kbd.address.status", &addr) != EOK)
+	if (sysinfo_get_value("kbd.address.physical", &addr) != EOK)
 		return -1;
 	
-	pl050_kbd.cmds[0].addr = (void *) addr;
-	
-	if (sysinfo_get_value("kbd.address.data", &addr) != EOK)
-		return -1;
-	
-	pl050_kbd.cmds[3].addr = (void *) addr;
+	pl050_kbd.ranges[0].base = addr;
+	pl050_kbd.cmds[0].addr = (void *) addr + PL050_STAT;
+	pl050_kbd.cmds[3].addr = (void *) addr + PL050_DATA;
 	
 	sysarg_t inr;
Index: uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
===================================================================
--- uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -62,4 +62,6 @@
 
 static irq_code_t ts_irq_code = {
+	0,
+	NULL,
 	sizeof(ts_irq_cmds) / sizeof(irq_cmd_t),
 	ts_irq_cmds
Index: uspace/srv/hw/bus/cuda_adb/cuda_adb.c
===================================================================
--- uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -104,4 +104,11 @@
 enum {
 	ADB_MAX_ADDR	= 16
+};
+
+static irq_pio_range_t cuda_ranges[] = {
+	{
+		.base = 0,
+		.size = sizeof(cuda_t) 
+	}
 };
 
@@ -130,4 +137,6 @@
 
 static irq_code_t cuda_irq_code = {
+	sizeof(cuda_ranges) / sizeof(irq_pio_range_t),
+	cuda_ranges,
 	sizeof(cuda_cmds) / sizeof(irq_cmd_t),
 	cuda_cmds
@@ -255,7 +264,4 @@
 		return -1;
 	
-	if (sysinfo_get_value("cuda.address.kernel", &(instance->cuda_kernel)) != EOK)
-		return -1;
-	
 	void *vaddr;
 	if (pio_enable((void *) instance->cuda_physical, sizeof(cuda_t), &vaddr) != 0)
@@ -274,5 +280,6 @@
 	pio_write_8(&dev->ier, IER_CLR | ALL_INT);
 
-	cuda_irq_code.cmds[0].addr = (void *) &((cuda_t *) instance->cuda_kernel)->ifr;
+	cuda_irq_code.ranges[0].base = (uintptr_t) instance->cuda_physical;
+	cuda_irq_code.cmds[0].addr = (void *) &((cuda_t *) instance->cuda_physical)->ifr;
 	async_set_interrupt_received(cuda_irq_handler);
 	irq_register(10, device_assign_devno(), 0, &cuda_irq_code);
Index: uspace/srv/hw/bus/cuda_adb/cuda_adb.h
===================================================================
--- uspace/srv/hw/bus/cuda_adb/cuda_adb.h	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/hw/bus/cuda_adb/cuda_adb.h	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -111,5 +111,4 @@
 	cuda_t *cuda;
 	uintptr_t cuda_physical;
-	uintptr_t cuda_kernel;
 
 	uint8_t rcv_buf[CUDA_RCV_BUF_SIZE];
Index: uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
===================================================================
--- uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -60,4 +60,6 @@
 
 static irq_code_t uart_irq_code = {
+	0,
+	NULL,
 	sizeof(uart_irq_cmds) / sizeof(irq_cmd_t),
 	uart_irq_cmds
Index: version
===================================================================
--- version	(revision 06a1d07797fc4e18922cbd44b9d0ee795f27b1ad)
+++ version	(revision b1213b0d019ee5b8bf4ee139ae99b9a3fdf827a0)
@@ -46,2 +46,3 @@
 
 NAME = Sashimi
+COPYRIGHT = Copyright (c) 2001-2012 HelenOS project
