Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ HelenOS.config	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -594,4 +594,5 @@
 @ "16"
 @ "24"
+@ "32"
 ! [(PLATFORM=ia32|PLATFORM=amd64|MACHINE=beagleboardxm)&CONFIG_HID_OUT!=none&CONFIG_FB=y] CONFIG_BFB_BPP (choice)
 
Index: abi/include/abi/errno.h
===================================================================
--- abi/include/abi/errno.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ abi/include/abi/errno.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -62,5 +62,5 @@
 #define EPARTY         -8
 
-#define EEXISTS        -9   /* Entry already exists */
+#define EEXIST         -9   /* Entry already exists */
 #define EBADMEM        -10  /* Bad memory pointer */
 #define ENOTSUP        -11  /* Not supported */
Index: abi/include/abi/fourcc.h
===================================================================
--- abi/include/abi/fourcc.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ abi/include/abi/fourcc.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011 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.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef ABI_FOURCC_H_
+#define ABI_FOURCC_H_
+
+#include "../../../common.h"
+
+#define FOURCC(a, b, c, d) \
+	(((UINT32_T) (a)) | (((UINT32_T) (b)) << 8) | \
+	    (((UINT32_T) (c)) << 16) | (((UINT32_T) (d)) << 24))
+
+#define CC_COMPACT(a) \
+	((UINT32_T) (a) & 0x7f)
+
+#define FOURCC_COMPACT(a, b, c, d) \
+	((CC_COMPACT(a) << 4) | (CC_COMPACT(b) << 11) | \
+	    (CC_COMPACT(c) << 18) | (CC_COMPACT(d) << 25))
+
+#endif
+
+/** @}
+ */
Index: abi/include/abi/ipc/interfaces.h
===================================================================
--- abi/include/abi/ipc/interfaces.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ abi/include/abi/ipc/interfaces.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2014 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.
+ */
+
+/** @addtogroup genericipc
+ * @{
+ */
+/**
+ * @file interface.h
+ * @brief List of all known interfaces and their codes.
+ */
+
+#ifndef ABI_IPC_INTERFACES_H_
+#define ABI_IPC_INTERFACES_H_
+
+#include <abi/fourcc.h>
+
+#define IFACE_EXCHANGE_MASK  0x03
+#define IFACE_MOD_MASK       0x04
+
+/** Interface exchange management style
+ *
+ */
+typedef enum {
+	/** No explicit exchange management
+	 *
+	 * Suitable for protocols which use a single
+	 * IPC message per exchange only.
+	 */
+	IFACE_EXCHANGE_ATOMIC = 0x00,
+	
+	/** Exchange management via mutual exclusion
+	 *
+	 * Suitable for any kind of client/server
+	 * communication, but with possibly limited
+	 * parallelism.
+	 */
+	IFACE_EXCHANGE_SERIALIZE = 0x01,
+	
+	/** Exchange management via connection cloning
+	 *
+	 * Suitable for servers which support client
+	 * connection tracking and connection cloning.
+	 */
+	IFACE_EXCHANGE_PARALLEL = 0x02
+} iface_exch_mgmt_t;
+
+/** Interface modifiers
+ *
+ */
+typedef enum {
+	IFACE_MOD_NONE = 0x00,
+	IFACE_MOD_CALLBACK = 0x04
+} iface_mod_t;
+
+typedef enum {
+	INTERFACE_LOADER =
+	    FOURCC_COMPACT('l', 'o', 'a', 'd') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_LOGGER_WRITER =
+	    FOURCC_COMPACT('l', 'o', 'g', 'w') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_LOGGER_CONTROL =
+	    FOURCC_COMPACT('l', 'o', 'g', 'c') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_CORECFG =
+	    FOURCC_COMPACT('c', 'c', 'f', 'g') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_FS =
+	    FOURCC_COMPACT('f', 's', ' ', ' ') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_VFS =
+	    FOURCC_COMPACT('v', 'f', 's', ' ') | IFACE_EXCHANGE_PARALLEL,
+	INTERFACE_VFS_DRIVER =
+	    FOURCC_COMPACT('v', 'f', 's', 'd') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_VFS_DRIVER_CB =
+	    FOURCC_COMPACT('v', 'f', 's', 'd') | IFACE_EXCHANGE_PARALLEL | IFACE_MOD_CALLBACK,
+	INTERFACE_BLOCK =
+	    FOURCC_COMPACT('b', 'l', 'd', 'v') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_BLOCK_CB =
+	    FOURCC_COMPACT('b', 'l', 'd', 'v') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_CONSOLE =
+	    FOURCC_COMPACT('c', 'o', 'n', 's') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_INPUT =
+	    FOURCC_COMPACT('i', 'n', 'd', 'v') | IFACE_EXCHANGE_ATOMIC,
+	INTERFACE_INPUT_CB =
+	    FOURCC_COMPACT('i', 'n', 'd', 'v') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_OUTPUT =
+	    FOURCC_COMPACT('o', 'u', 'd', 'v') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_COMPOSITOR =
+	    FOURCC_COMPACT('c', 'm', 'p', 's') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_HOUND =
+	    FOURCC_COMPACT('h', 'o', 'u', 'n') | IFACE_EXCHANGE_PARALLEL,
+	INTERFACE_VISUALIZER_CB =
+	    FOURCC_COMPACT('v', 's', 'd', 'v') | IFACE_EXCHANGE_PARALLEL | IFACE_MOD_CALLBACK,
+	INTERFACE_LOC_SUPPLIER =
+	    FOURCC_COMPACT('l', 'o', 'c', 's') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_LOC_CONSUMER =
+	    FOURCC_COMPACT('l', 'o', 'c', 'c') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_LOC_CB =
+	    FOURCC_COMPACT('l', 'o', 'c', ' ') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_DEVMAN_DEVICE =
+	    FOURCC_COMPACT('d', 'v', 'd', 'v') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_DEVMAN_PARENT =
+	    FOURCC_COMPACT('d', 'v', 'p', 't') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_IRC =
+	    FOURCC_COMPACT('i', 'r', 'c', ' ') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_DDF =
+	    FOURCC_COMPACT('d', 'd', 'f', ' ') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_DDF_DEVMAN =
+	    FOURCC_COMPACT('d', 'd', 'f', 'm') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_DDF_CLIENT =
+	    FOURCC_COMPACT('d', 'd', 'f', 'c') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_DDF_DRIVER =
+	    FOURCC_COMPACT('d', 'd', 'f', 'd') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_INET =
+	    FOURCC_COMPACT('i', 'n', 'e', 't') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_INET_CB =
+	    FOURCC_COMPACT('i', 'n', 'e', 't') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_INETCFG =
+	    FOURCC_COMPACT('i', 'c', 'f', 'g') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_INETPING =
+	    FOURCC_COMPACT('i', 'p', 'n', 'g') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_INETPING_CB =
+	    FOURCC_COMPACT('i', 'p', 'n', 'g') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_DHCP =
+	    FOURCC_COMPACT('d', 'h', 'c', 'p') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_DNSR =
+	    FOURCC_COMPACT('d', 'n', 's', 'r') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_IPLINK =
+	    FOURCC_COMPACT('i', 'p', 'l', 'k') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_IPLINK_CB =
+	    FOURCC_COMPACT('i', 'p', 'l', 'k') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_TCP =
+	    FOURCC_COMPACT('t', 'c', 'p', ' ') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_TCP_CB =
+	    FOURCC_COMPACT('t', 'c', 'p', ' ') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_UDP =
+	    FOURCC_COMPACT('u', 'd', 'p', ' ') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_UDP_CB =
+	    FOURCC_COMPACT('u', 'd', 'p', ' ') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_CLIPBOARD =
+	    FOURCC_COMPACT('c', 'l', 'i', 'p') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_CHAR_CB =
+	    FOURCC_COMPACT('b', 'l', 'd', 'v') | IFACE_EXCHANGE_PARALLEL | IFACE_MOD_CALLBACK,
+	INTERFACE_AUDIO_PCM_CB =
+	    FOURCC_COMPACT('a', 'p', 'c', 'm') | IFACE_EXCHANGE_PARALLEL | IFACE_MOD_CALLBACK,
+	INTERFACE_NIC_CB =
+	    FOURCC_COMPACT('n', 'i', 'c', ' ') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_USBVIRT_CB =
+	    FOURCC_COMPACT('u', 's', 'b', 'v') | IFACE_EXCHANGE_PARALLEL | IFACE_MOD_CALLBACK,
+	INTERFACE_ADB_CB =
+	    FOURCC_COMPACT('a', 'd', 'b', ' ') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_MOUSE_CB =
+	    FOURCC_COMPACT('m', 'o', 'u', 's') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_KBD_CB =
+	    FOURCC_COMPACT('k', 'b', 'd', ' ') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_VOL =
+	    FOURCC_COMPACT('v', 'o', 'l', ' ') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_VBD =
+	    FOURCC_COMPACT('v', 'b', 'd', ' ') | IFACE_EXCHANGE_SERIALIZE
+} iface_t;
+
+#endif
+
+/** @}
+ */
Index: boot/arch/arm32/src/asm.S
===================================================================
--- boot/arch/arm32/src/asm.S	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ boot/arch/arm32/src/asm.S	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -75,18 +75,18 @@
 	bic	r4, r4, #(1 << CP15_C1_DC)
 
-	# Disable I-cache and Branche predictors.
+	# Disable I-cache and Branch predictors.
 	bic	r4, r4, #(1 << CP15_C1_IC)
+#ifdef PROCESSOR_ARCH_armv6
 	bic	r4, r4, #(1 << CP15_C1_BP)
+#endif
 	
 	mcr	p15, 0, r4, c1, c0, 0
 #endif
-
-
 	
-	#Wait for the operations to complete
+	# Wait for the operations to complete
 #ifdef PROCESSOR_ARCH_armv7_a
 	dsb
 #else
-	#cp15 dsb, r4 is ignored (should be zero)
+	# cp15 dsb, r4 is ignored (should be zero)
 	mov r4, #0
 	mcr p15, 0, r4, c7, c10, 4
@@ -98,9 +98,9 @@
 	nop
 
-	#Wait for the operations to complete
+	# Wait for the operations to complete
 #ifdef PROCESSOR_ARCH_armv7_a
 	isb
 	nop
-#else
+#elif defined(PROCESSOR_ARCH_armv6)
 	# cp15 isb
 	mcr p15, 0, r4, c7, c5, 4
Index: boot/arch/arm32/src/main.c
===================================================================
--- boot/arch/arm32/src/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ boot/arch/arm32/src/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -47,4 +47,5 @@
 #include <errno.h>
 #include <inflate.h>
+#include <arch/cp15.h>
 
 #define TOP2ADDR(top)  (((void *) PA2KA(BOOT_OFFSET)) + (top))
@@ -55,8 +56,26 @@
 static inline void clean_dcache_poc(void *address, size_t size)
 {
-	const uintptr_t addr = (uintptr_t)address;
-	for (uintptr_t a = addr; a < addr + size; a += 4) {
-		/* DCCMVAC - clean by address to the point of coherence */
-		asm volatile ("mcr p15, 0, %[a], c7, c10, 1\n" :: [a]"r"(a) : );
+	const uintptr_t addr = (uintptr_t) address;
+
+#if !defined(PROCESSOR_ARCH_armv7_a)
+	bool sep;
+	if (MIDR_read() != CTR_read()) {
+		sep = (CTR_read() & CTR_SEP_FLAG) == CTR_SEP_FLAG;
+	} else {
+		printf("Unknown cache type.\n");
+		halt();
+	}
+#endif
+
+	for (uintptr_t a = ALIGN_DOWN(addr, CP15_C7_MVA_ALIGN); a < addr + size;
+	    a += CP15_C7_MVA_ALIGN) {
+#if defined(PROCESSOR_ARCH_armv7_a)
+		DCCMVAC_write(a);
+#else
+		if (sep)
+			DCCMVA_write(a);
+		else
+			CCMVA_write(a);
+#endif
 	}
 }
Index: boot/arch/arm32/src/mm.c
===================================================================
--- boot/arch/arm32/src/mm.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ boot/arch/arm32/src/mm.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -143,5 +143,5 @@
 	pte->should_be_zero_1 = 0;
 	pte->access_permission_0 = PTE_AP_USER_NO_KERNEL_RW;
-#ifdef PROCESSOR_ARCH_armv7_a
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
 	/*
 	 * Keeps this setting in sync with memory type attributes in:
@@ -152,7 +152,7 @@
 	pte->tex = section_cacheable(frame) ? 5 : 0;
 	pte->cacheable = section_cacheable(frame) ? 0 : 0;
-	pte->bufferable = section_cacheable(frame) ? 1 : 0;
+	pte->bufferable = section_cacheable(frame) ? 1 : 1;
 #else
-	pte->bufferable = 1;
+	pte->bufferable = section_cacheable(frame);
 	pte->cacheable = section_cacheable(frame);
 	pte->tex = 0;
@@ -189,5 +189,8 @@
 	 */
 	uint32_t val = (uint32_t)boot_pt & TTBR_ADDR_MASK;
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
+	// FIXME: TTBR_RGN_WBWA_CACHE is unpredictable on ARMv6
 	val |= TTBR_RGN_WBWA_CACHE | TTBR_C_FLAG;
+#endif
 	TTBR0_write(val);
 }
Index: contrib/qfs/qfs.sh
===================================================================
--- contrib/qfs/qfs.sh	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ contrib/qfs/qfs.sh	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -29,5 +29,5 @@
 #
 
-VERSION=2.3.0
+VERSION=2.4.0
 BASENAME=qemu-${VERSION}
 BASENAME_MASTER=qemu-master
@@ -36,5 +36,5 @@
 URL=http://wiki.qemu-project.org/download/${TARBALL}
 REPO=git://git.qemu.org/qemu.git
-MD5="2fab3ea4460de9b57192e5b8b311f221"
+MD5="186ee8194140a484a455f8e3c74589f4"
 
 if [ "$1" == "--master" ]; then
Index: kernel/arch/arm32/include/arch/atomic.h
===================================================================
--- kernel/arch/arm32/include/arch/atomic.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/arch/arm32/include/arch/atomic.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -78,5 +78,6 @@
  *
  */
-NO_TRACE static inline void atomic_dec(atomic_t *val) {
+NO_TRACE static inline void atomic_dec(atomic_t *val)
+{
 	atomic_add(val, -1);
 }
Index: kernel/arch/arm32/include/arch/barrier.h
===================================================================
--- kernel/arch/arm32/include/arch/barrier.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/arch/arm32/include/arch/barrier.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -38,5 +38,7 @@
 
 #ifdef KERNEL
+#include <arch/cache.h>
 #include <arch/cp15.h>
+#include <align.h>
 #else
 #include <libarch/cp15.h>
@@ -71,8 +73,16 @@
  * CP15 implementation is mandatory only for armv6+.
  */
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
 #define memory_barrier()  CP15DMB_write(0)
-#define read_barrier()    CP15DSB_write(0)
+#else
+#define memory_barrier()  CP15DSB_write(0)
+#endif
+#define read_barrier()    CP15DSB_write(0) 
 #define write_barrier()   read_barrier()
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
 #define inst_barrier()    CP15ISB_write(0)
+#else
+#define inst_barrier()
+#endif
 #else
 /* Older manuals mention syscalls as a way to implement cache coherency and
@@ -103,12 +113,10 @@
 
 #if defined PROCESSOR_ARCH_armv7_a | defined PROCESSOR_ARCH_armv6 | defined KERNEL
-/* Available on all supported arms,
- * invalidates entire ICache so the written value does not matter. */
 //TODO might be PL1 only on armv5-
 #define smc_coherence(a) \
 do { \
-	DCCMVAU_write((uint32_t)(a));  /* Flush changed memory */\
+	dcache_clean_mva_pou(ALIGN_DOWN((uintptr_t) a, CP15_C7_MVA_ALIGN)); \
 	write_barrier();               /* Wait for completion */\
-	ICIALLU_write(0);              /* Flush ICache */\
+	icache_invalidate();\
 	inst_barrier();                /* Wait for Inst refetch */\
 } while (0)
@@ -117,5 +125,6 @@
 #define smc_coherence_block(a, l) \
 do { \
-	for (uintptr_t addr = (uintptr_t)a; addr < (uintptr_t)a + l; addr += 4)\
+	for (uintptr_t addr = (uintptr_t) a; addr < (uintptr_t) a + l; \
+	    addr += CP15_C7_MVA_ALIGN) \
 		smc_coherence(addr); \
 } while (0)
Index: kernel/arch/arm32/include/arch/cache.h
===================================================================
--- kernel/arch/arm32/include/arch/cache.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/arch/arm32/include/arch/cache.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -37,4 +37,6 @@
 #define KERN_arm32_CACHE_H_
 
+#include <typedefs.h>
+
 unsigned dcache_levels(void);
 
@@ -43,5 +45,7 @@
 void cpu_dcache_flush(void);
 void cpu_dcache_flush_invalidate(void);
-void icache_invalidate(void);
+extern void icache_invalidate(void);
+extern void dcache_invalidate(void);
+extern void dcache_clean_mva_pou(uintptr_t);
 
 #endif
Index: kernel/arch/arm32/include/arch/cp15.h
===================================================================
--- kernel/arch/arm32/include/arch/cp15.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/arch/arm32/include/arch/cp15.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -118,8 +118,19 @@
 };
 CONTROL_REG_GEN_READ(CTR, c0, 0, c0, 1);
+
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
 CONTROL_REG_GEN_READ(TCMR, c0, 0, c0, 2);
+
+enum {
+	TLBTR_SEP_FLAG = 1,
+};
+
 CONTROL_REG_GEN_READ(TLBTR, c0, 0, c0, 3);
+#endif
+
+#if defined(PROCESSOR_ARCH_armv7_a)
 CONTROL_REG_GEN_READ(MPIDR, c0, 0, c0, 5);
 CONTROL_REG_GEN_READ(REVIDR, c0, 0, c0, 6);
+#endif
 
 enum {
@@ -309,4 +320,5 @@
 enum {
 	TTBR_ADDR_MASK = 0xffffff80,
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
 	TTBR_NOS_FLAG = 1 << 5,
 	TTBR_RGN_MASK = 0x3 << 3,
@@ -317,12 +329,17 @@
 	TTBR_S_FLAG = 1 << 1,
 	TTBR_C_FLAG = 1 << 0,
+#endif
 };
 CONTROL_REG_GEN_READ(TTBR0, c2, 0, c0, 0);
 CONTROL_REG_GEN_WRITE(TTBR0, c2, 0, c0, 0);
+
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
 CONTROL_REG_GEN_READ(TTBR1, c2, 0, c0, 1);
 CONTROL_REG_GEN_WRITE(TTBR1, c2, 0, c0, 1);
 CONTROL_REG_GEN_READ(TTBCR, c2, 0, c0, 2);
 CONTROL_REG_GEN_WRITE(TTBCR, c2, 0, c0, 2);
-
+#endif
+
+#if defined(PROCESSOR_ARCH_armv7)
 CONTROL_REG_GEN_READ(HTCR, c2, 4, c0, 2);
 CONTROL_REG_GEN_WRITE(HTCR, c2, 4, c0, 2);
@@ -339,4 +356,5 @@
 CONTROL_REG_GEN_READ(VTTBRH, c2, 0, c2, 6);
 CONTROL_REG_GEN_WRITE(VTTBRH, c2, 0, c2, 6);
+#endif
 
 CONTROL_REG_GEN_READ(DACR, c3, 0, c0, 0);
@@ -373,71 +391,167 @@
 CONTROL_REG_GEN_WRITE(HPFAR, c6, 4, c0, 4);
 
-/* Cache maintenance, address translation and other */
-CONTROL_REG_GEN_WRITE(WFI, c7, 0, c0, 4); /* armv6 only */
-CONTROL_REG_GEN_WRITE(ICIALLLUIS, c7, 0, c1, 0);
-CONTROL_REG_GEN_WRITE(BPIALLIS, c7, 0, c1, 6);
-CONTROL_REG_GEN_READ(PAR, c7, 0, c4, 0);
-CONTROL_REG_GEN_WRITE(PAR, c7, 0, c4, 0);
-CONTROL_REG_GEN_READ(PARH, c7, 0, c7, 0);   /* PAE */
-CONTROL_REG_GEN_WRITE(PARH, c7, 0, c7, 0);   /* PAE */
-CONTROL_REG_GEN_WRITE(ICIALLU, c7, 0, c5, 0);
-CONTROL_REG_GEN_WRITE(ICIMVAU, c7, 0, c5, 1);
+/*
+ * Cache maintenance, address translation and other
+ */
+
+#if defined(PROCESSOR_cortex_a8)
+#define CP15_C7_MVA_ALIGN	64
+#elif defined(PROCESSOR_arm1176)
+#define CP15_C7_MVA_ALIGN	32
+#elif defined(PROCESSOR_arm926ej_s)
+#define CP15_C7_MVA_ALIGN	32
+#elif defined(PROCESSOR_arm920t)
+#define CP15_C7_MVA_ALIGN	32
+#else
+#error Unknow MVA alignment
+#endif
+
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
 CONTROL_REG_GEN_WRITE(CP15ISB, c7, 0, c5, 4);
 CONTROL_REG_GEN_WRITE(BPIALL, c7, 0, c5, 6);
 CONTROL_REG_GEN_WRITE(BPIMVA, c7, 0, c5, 7);
-
+#endif
+
+#if !defined(PROCESSOR_arm920t)
+CONTROL_REG_GEN_WRITE(DCISW, c7, 0, c6, 2);
+#endif
+
+#if defined(PROCESSOR_arm920t) || !defined(PROCESSOR_ARCH_armv4)
+CONTROL_REG_GEN_WRITE(DCCSW, c7, 0, c10, 2);
+#endif
+
+CONTROL_REG_GEN_WRITE(CP15DSB, c7, 0, c10, 4);
+
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
+CONTROL_REG_GEN_WRITE(CP15DMB, c7, 0, c10, 5);
+#endif
+
+#if defined(PROCESSOR_arm920t) || !defined(PROCESSOR_ARCH_armv4)
+CONTROL_REG_GEN_WRITE(DCCISW, c7, 0, c14, 2);
+#endif
+
+#if defined(PROCESSOR_ARCH_armv7_a)
+CONTROL_REG_GEN_WRITE(ICIALLLUIS, c7, 0, c1, 0);
+CONTROL_REG_GEN_WRITE(BPIALLIS, c7, 0, c1, 6);
+CONTROL_REG_GEN_READ(PAR, c7, 0, c4, 0); /* Security Extensions */
+CONTROL_REG_GEN_WRITE(PAR, c7, 0, c4, 0); /* Security Extensions */
+CONTROL_REG_GEN_WRITE(ICIALLU, c7, 0, c5, 0);
+CONTROL_REG_GEN_WRITE(ICIMVAU, c7, 0, c5, 1);
 CONTROL_REG_GEN_WRITE(DCIMVAC, c7, 0, c6, 1);
-CONTROL_REG_GEN_WRITE(DCISW, c7, 0, c6, 2);
-
-CONTROL_REG_GEN_WRITE(ATS1CPR, c7, 0, c8, 0);
-CONTROL_REG_GEN_WRITE(ATS1CPW, c7, 0, c8, 1);
-CONTROL_REG_GEN_WRITE(ATS1CUR, c7, 0, c8, 2);
-CONTROL_REG_GEN_WRITE(ATS1CUW, c7, 0, c8, 3);
-CONTROL_REG_GEN_WRITE(ATS12NSOPR, c7, 0, c8, 4);
-CONTROL_REG_GEN_WRITE(ATS12NSOPW, c7, 0, c8, 5);
-CONTROL_REG_GEN_WRITE(ATS12NSOUR, c7, 0, c8, 6);
-CONTROL_REG_GEN_WRITE(ATS12NSOUW, c7, 0, c8, 7);
-
-
+CONTROL_REG_GEN_READ(PARH, c7, 0, c7, 0); /* PAE */
+CONTROL_REG_GEN_WRITE(PARH, c7, 0, c7, 0); /* PAE */
+CONTROL_REG_GEN_WRITE(ATS1CPR, c7, 0, c8, 0); /* Security Extensions */
+CONTROL_REG_GEN_WRITE(ATS1CPW, c7, 0, c8, 1); /* Security Extensions */
+CONTROL_REG_GEN_WRITE(ATS1CUR, c7, 0, c8, 2); /* Security Extensions */
+CONTROL_REG_GEN_WRITE(ATS1CUW, c7, 0, c8, 3); /* Security Extensions */
+CONTROL_REG_GEN_WRITE(ATS12NSOPR, c7, 0, c8, 4); /* Security Extensions */
+CONTROL_REG_GEN_WRITE(ATS12NSOPW, c7, 0, c8, 5); /* Security Extensions */
+CONTROL_REG_GEN_WRITE(ATS12NSOUR, c7, 0, c8, 6); /* Security Extensions */
+CONTROL_REG_GEN_WRITE(ATS12NSOUW, c7, 0, c8, 7); /* Security Extensions */
+CONTROL_REG_GEN_WRITE(ATS1HR, c7, 4, c8, 0); /* Virtualization Extensions */
+CONTROL_REG_GEN_WRITE(ATS1HW, c7, 4, c8, 1); /* Virtualization Extensions */
 CONTROL_REG_GEN_WRITE(DCCMVAC, c7, 0, c10, 1);
-CONTROL_REG_GEN_WRITE(DCCSW, c7, 0, c10, 2);
-CONTROL_REG_GEN_WRITE(CP15DSB, c7, 0, c10, 4);
-CONTROL_REG_GEN_WRITE(CP15DMB, c7, 0, c10, 5);
 CONTROL_REG_GEN_WRITE(DCCMVAU, c7, 0, c11, 1);
-
-CONTROL_REG_GEN_WRITE(PFI, c7, 0, c11, 1); /* armv6 only */
-
 CONTROL_REG_GEN_WRITE(DCCIMVAC, c7, 0, c14, 1);
-CONTROL_REG_GEN_WRITE(DCCISW, c7, 0, c14, 2);
-
-CONTROL_REG_GEN_WRITE(ATS1HR, c7, 4, c8, 0);
-CONTROL_REG_GEN_WRITE(ATS1HW, c7, 4, c8, 1);
+#else
+
+#if defined(PROCESSOR_arm920t) || !defined(PROCESSOR_ARCH_armv4)
+CONTROL_REG_GEN_WRITE(WFI, c7, 0, c0, 4);
+#endif
+
+CONTROL_REG_GEN_WRITE(ICIALL, c7, 0, c5, 0);
+CONTROL_REG_GEN_WRITE(ICIMVA, c7, 0, c5, 1);
+
+#if !defined(PROCESSOR_ARCH_armv4)
+CONTROL_REG_GEN_WRITE(ICISW, c7, 0, c5, 2);
+#endif
+
+CONTROL_REG_GEN_WRITE(DCIALL, c7, 0, c6, 0);
+CONTROL_REG_GEN_WRITE(DCIMVA, c7, 0, c6, 1);
+CONTROL_REG_GEN_WRITE(CIALL, c7, 0, c7, 0);
+CONTROL_REG_GEN_WRITE(CIMVA, c7, 0, c7, 1);
+
+#if !defined(PROCESSOR_ARCH_armv4)
+CONTROL_REG_GEN_WRITE(CISW, c7, 0, c7, 2);
+#endif
+
+#if defined(PROCESSOR_ARCH_armv4) || defined(PROCESSOR_ARCH_armv6)
+CONTROL_REG_GEN_WRITE(DCCALL, c7, 0, c10, 0);
+#endif
+
+CONTROL_REG_GEN_WRITE(DCCMVA, c7, 0, c10, 1);
+
+#if defined(PROCESSOR_ARCH_armv4) || defined(PROCESSOR_ARCH_armv6)
+CONTROL_REG_GEN_WRITE(CCALL, c7, 0, c11, 0);
+#endif
+
+CONTROL_REG_GEN_WRITE(CCMVA, c7, 0, c11, 1);
+
+#if !defined(PROCESSOR_ARCH_armv4)
+CONTROL_REG_GEN_WRITE(CCSW, c7, 0, c11, 2);
+#endif
+
+#if defined(PROCESSOR_arm920t) || !defined(PROCESSOR_ARCH_armv4)
+CONTROL_REG_GEN_WRITE(PFIMVA, c7, 0, c13, 1);
+#endif
+
+#if defined(PROCESSOR_ARCH_armv4) || defined(PROCESSOR_ARCH_armv6)
+CONTROL_REG_GEN_WRITE(DCCIALL, c7, 0, c14, 0);
+#endif
+
+CONTROL_REG_GEN_WRITE(DCCIMVA, c7, 0, c14, 1);
+
+#if defined(PROCESSOR_ARCH_armv4) || defined(PROCESSOR_ARCH_armv6)
+CONTROL_REG_GEN_WRITE(CCIALL, c7, 0, c15, 0);
+#endif
+
+CONTROL_REG_GEN_WRITE(CCIMVA, c7, 0, c15, 1);
+
+#if defined(PROCESSOR_ARCH_armv5) || defined(PROCESSOR_ARCH_armv6)
+CONTROL_REG_GEN_WRITE(CCISW, c7, 0, c15, 2);
+#endif
+
+#endif
 
 /* TLB maintenance */
+#if defined(PROCESSOR_ARCH_armv7_a)
 CONTROL_REG_GEN_WRITE(TLBIALLIS, c8, 0, c3, 0); /* Inner shareable */
 CONTROL_REG_GEN_WRITE(TLBIMVAIS, c8, 0, c3, 1); /* Inner shareable */
 CONTROL_REG_GEN_WRITE(TLBIASIDIS, c8, 0, c3, 2); /* Inner shareable */
 CONTROL_REG_GEN_WRITE(TLBIMVAAIS, c8, 0, c3, 3); /* Inner shareable */
+#endif
 
 CONTROL_REG_GEN_WRITE(ITLBIALL, c8, 0, c5, 0);
 CONTROL_REG_GEN_WRITE(ITLBIMVA, c8, 0, c5, 1);
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
 CONTROL_REG_GEN_WRITE(ITLBIASID, c8, 0, c5, 2);
+#endif
 
 CONTROL_REG_GEN_WRITE(DTLBIALL, c8, 0, c6, 0);
 CONTROL_REG_GEN_WRITE(DTLBIMVA, c8, 0, c6, 1);
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
 CONTROL_REG_GEN_WRITE(DTLBIASID, c8, 0, c6, 2);
+#endif
 
 CONTROL_REG_GEN_WRITE(TLBIALL, c8, 0, c7, 0);
 CONTROL_REG_GEN_WRITE(TLBIMVA, c8, 0, c7, 1);
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
 CONTROL_REG_GEN_WRITE(TLBIASID, c8, 0, c7, 2);
+#endif
+#if defined(PROCESSOR_ARCH_armv7_a)
 CONTROL_REG_GEN_WRITE(TLBIMVAA, c8, 0, c7, 3);
-
+#endif
+
+#if defined(PROCESSOR_ARCH_armv7_a)
 CONTROL_REG_GEN_WRITE(TLBIALLHIS, c8, 4, c3, 0); /* Inner shareable */
 CONTROL_REG_GEN_WRITE(TLBIMVAHIS, c8, 4, c3, 1); /* Inner shareable */
 CONTROL_REG_GEN_WRITE(TLBIALLNSNHIS, c8, 4, c3, 4); /* Inner shareable */
-
+#endif
+
+#if defined(PROCESSOR_ARCH_armv7_a)
 CONTROL_REG_GEN_WRITE(TLBIALLH, c8, 4, c7, 0);
 CONTROL_REG_GEN_WRITE(TLBIMVAH, c8, 4, c7, 1);
 CONTROL_REG_GEN_WRITE(TLBIALLNSNHS, c8, 4, c7, 4);
+#endif
 
 /* c9 are performance monitoring resgisters */
Index: kernel/arch/arm32/include/arch/mm/page.h
===================================================================
--- kernel/arch/arm32/include/arch/mm/page.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/arch/arm32/include/arch/mm/page.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -154,5 +154,8 @@
 {
 	uint32_t val = (uint32_t)pt & TTBR_ADDR_MASK;
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
+	// FIXME: TTBR_RGN_WBWA_CACHE is unpredictable on ARMv6
 	val |= TTBR_RGN_WBWA_CACHE | TTBR_C_FLAG;
+#endif
 	TTBR0_write(val);
 }
Index: kernel/arch/arm32/include/arch/mm/page_armv4.h
===================================================================
--- kernel/arch/arm32/include/arch/mm/page_armv4.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/arch/arm32/include/arch/mm/page_armv4.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -123,5 +123,5 @@
 do { \
 	for (unsigned i = 0; i < count; ++i) \
-		DCCMVAU_write((uintptr_t)(pt + i)); \
+		dcache_clean_mva_pou((uintptr_t)(pt + i)); \
 	read_barrier(); \
 } while (0)
Index: kernel/arch/arm32/include/arch/mm/page_armv6.h
===================================================================
--- kernel/arch/arm32/include/arch/mm/page_armv6.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/arch/arm32/include/arch/mm/page_armv6.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -156,8 +156,7 @@
 do { \
 	for (unsigned i = 0; i < count; ++i) \
-		DCCMVAU_write((uintptr_t)(pt + i)); \
+		dcache_clean_mva_pou((uintptr_t)(pt + i)); \
 	read_barrier(); \
 } while (0)
-
 
 /** Returns level 0 page table entry flags.
@@ -258,6 +257,8 @@
 	if (flags & PAGE_CACHEABLE) {
 		/*
-		 * Write-through, write-allocate memory, see ch. B3.8.2
-		 * (p. B3-1358) of ARM Architecture reference manual.
+		 * Outer and inner write-back, write-allocate memory,
+		 * see ch. B3.8.2 (p. B3-1358) of ARM Architecture reference
+		 * manual.
+		 *
 		 * Make sure the memory type is correct, and in sync with:
 		 * init_boot_pt (boot/arch/arm32/src/mm.c)
@@ -278,12 +279,7 @@
 	}
 	
-#if defined(PROCESSOR_ARCH_armv6)
-	/* FIXME: this disables caches */
-	p->shareable = 1;
-#else
 	/* Shareable is ignored for devices (non-cacheable),
 	 * turn it off for normal memory. */
 	p->shareable = 0;
-#endif
 	
 	p->non_global = !(flags & PAGE_GLOBAL);
Index: kernel/arch/arm32/src/cpu/cpu.c
===================================================================
--- kernel/arch/arm32/src/cpu/cpu.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/arch/arm32/src/cpu/cpu.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -130,5 +130,8 @@
 {
 	uint32_t control_reg = SCTLR_read();
-	
+
+	dcache_invalidate();
+	read_barrier();
+
 	/* Turn off tex remap, RAZ/WI prior to armv7 */
 	control_reg &= ~SCTLR_TEX_REMAP_EN_FLAG;
@@ -322,5 +325,45 @@
 void icache_invalidate(void)
 {
+#if defined(PROCESSOR_ARCH_armv7_a)
 	ICIALLU_write(0);
+#else
+	ICIALL_write(0);
+#endif
+}
+
+#if !defined(PROCESSOR_ARCH_armv7_a)
+static bool cache_is_unified(void)
+{
+	if (MIDR_read() != CTR_read()) {
+		/* We have the CTR register */
+		return (CTR_read() & CTR_SEP_FLAG) != CTR_SEP_FLAG;
+	} else {
+		panic("Unknown cache type");
+	}
+}
+#endif
+
+void dcache_invalidate(void)
+{
+#if defined(PROCESSOR_ARCH_armv7_a)
+	dcache_flush_invalidate();
+#else
+	if (cache_is_unified())
+		CIALL_write(0);
+	else
+		DCIALL_write(0);
+#endif
+}
+
+void dcache_clean_mva_pou(uintptr_t mva)
+{
+#if defined(PROCESSOR_ARCH_armv7_a)
+	DCCMVAU_write(mva);
+#else
+	if (cache_is_unified())
+		CCMVA_write(mva);
+	else
+		DCCMVA_write(mva);
+#endif
 }
 
Index: kernel/arch/arm32/src/mm/tlb.c
===================================================================
--- kernel/arch/arm32/src/mm/tlb.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/arch/arm32/src/mm/tlb.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -79,6 +79,20 @@
 static inline void invalidate_page(uintptr_t page)
 {
-	//TODO: What about TLBIMVAA?
+#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
+	if (TLBTR_read() & TLBTR_SEP_FLAG) {
+		ITLBIMVA_write(page);
+		DTLBIMVA_write(page);
+	} else {
+		TLBIMVA_write(page);
+	}
+#elif defined(PROCESSOR_arm920t)
+	ITLBIMVA_write(page);
+	DTLBIMVA_write(page);
+#elif defined(PROCESSOR_arm926ej_s)
 	TLBIMVA_write(page);
+#else
+#error Unknown TLB type
+#endif
+
 	/*
 	 * "A TLB maintenance operation is only guaranteed to be complete after
Index: kernel/generic/include/adt/list.h
===================================================================
--- kernel/generic/include/adt/list.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/generic/include/adt/list.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -53,7 +53,7 @@
 
 
-extern int list_member(const link_t *, const list_t *);
+extern bool list_member(const link_t *, const list_t *);
 extern void list_splice(list_t *, link_t *);
-extern unsigned int list_count(const list_t *);
+extern unsigned long list_count(const list_t *);
 
 
@@ -220,5 +220,5 @@
  *
  */
-NO_TRACE static inline int list_empty(const list_t *list)
+NO_TRACE static inline bool list_empty(const list_t *list)
 {
 	return (list->head.next == &list->head);
@@ -353,7 +353,7 @@
  *
  */
-static inline link_t *list_nth(list_t *list, unsigned int n)
-{
-	unsigned int cnt = 0;
+static inline link_t *list_nth(list_t *list, unsigned long n)
+{
+	unsigned long cnt = 0;
 	link_t *link;
 	
Index: kernel/generic/src/adt/list.c
===================================================================
--- kernel/generic/src/adt/list.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/generic/src/adt/list.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -52,5 +52,5 @@
  *
  */
-int list_member(const link_t *link, const list_t *list)
+bool list_member(const link_t *link, const list_t *list)
 {
 	bool found = false;
@@ -99,7 +99,7 @@
  * @return		Number of items in the list.
  */
-unsigned int list_count(const list_t *list)
+unsigned long list_count(const list_t *list)
 {
-	unsigned int count = 0;
+	unsigned long count = 0;
 	
 	link_t *link = list_first(list);
Index: kernel/generic/src/console/console.c
===================================================================
--- kernel/generic/src/console/console.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/generic/src/console/console.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -437,5 +437,5 @@
 	}
 
-	return size;
+	return EOK;
 }
 
Index: kernel/generic/src/ipc/event.c
===================================================================
--- kernel/generic/src/ipc/event.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/generic/src/ipc/event.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -251,5 +251,5 @@
  *
  * @return EOK if the subscription was successful.
- * @return EEXISTS if the notifications of the given type are
+ * @return EEXIST if the notifications of the given type are
  *         already subscribed.
  *
@@ -269,5 +269,5 @@
 		res = EOK;
 	} else
-		res = EEXISTS;
+		res = EEXIST;
 	
 	spinlock_unlock(&event->lock);
@@ -282,5 +282,5 @@
  *
  * @return EOK if the subscription was successful.
- * @return EEXISTS if the notifications of the given type are
+ * @return EEXIST if the notifications of the given type are
  *         already subscribed.
  *
@@ -334,5 +334,5 @@
  * @return EOK on success.
  * @return ELIMIT on unknown event type.
- * @return EEXISTS if the notifications of the given type are
+ * @return EEXIST if the notifications of the given type are
  *         already subscribed.
  *
Index: kernel/generic/src/ipc/irq.c
===================================================================
--- kernel/generic/src/ipc/irq.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ kernel/generic/src/ipc/irq.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -351,5 +351,5 @@
 		
 		free(irq);
-		return EEXISTS;
+		return EEXIST;
 	}
 	
Index: tools/xcw/bin/helenos-bld-config
===================================================================
--- tools/xcw/bin/helenos-bld-config	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ tools/xcw/bin/helenos-bld-config	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,60 @@
+#!/bin/bash
+#
+# Copyright (c) 2015 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.
+#
+# Get build configration information
+# HelenOS Cross Compiler Wrapper (XCW)
+# Facilitate cross-compiling external software to HelenOS
+#
+
+SRC_ROOT="$(dirname "$0")/../../.."
+MAKEFILE_COMMON="$SRC_ROOT"/Makefile.common
+MAKEFILE_CONFIG="$SRC_ROOT"/Makefile.config
+
+# Extract simple 'name = value' variable definition from Makefile
+function extract_field
+{
+	field_name="$1"
+	file_name="$2"
+
+	sed -n "s/^$field_name = \\(.*\\)$/\\1/p" "$file_name"
+}
+
+case ".$1" in
+(.--cc) extract_field "CC" "$MAKEFILE_COMMON";;
+(.--ld) extract_field "LD" "$MAKEFILE_COMMON";;
+(.--uarch) extract_field "UARCH" "$MAKEFILE_CONFIG";;
+(.--endian)
+	UARCH=`extract_field "UARCH" "$MAKEFILE_CONFIG"`
+	ENDIAN=`extract_field "ENDIANESS" "$SRC_ROOT/uspace/lib/c/arch/$UARCH/Makefile.common"`
+	echo "__${ENDIAN}__"
+	;;
+(*)
+	echo "Unknown option $1" >&2
+	echo "Usage: helenos-pkg-config {--cc|--ld|--uarch|--endian}" >&2
+	exit 1;;
+esac
Index: tools/xcw/bin/helenos-cc
===================================================================
--- tools/xcw/bin/helenos-cc	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ tools/xcw/bin/helenos-cc	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Copyright (c) 2015 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.
+#
+# C Compiler (cc) wrapper
+# HelenOS Cross Compiler Wrapper (XCW)
+# Facilitate cross-compiling external software to HelenOS
+#
+
+XCW="$(dirname "$0")"
+SRC_ROOT="$XCW/../../.."
+UARCH="$("$XCW"/helenos-bld-config --uarch)"
+CC="$("$XCW"/helenos-bld-config --cc)"
+ENDIAN="$("$XCW"/helenos-bld-config --endian)"
+
+echo helenos-cc "$@"
+"$CC" \
+    -O3 -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32LE -finput-charset=UTF-8 \
+    -ffreestanding -fno-builtin -nostdlib -nostdinc \
+    -Wall -Wextra -Wno-clobbered -Wno-unused-parameter -Wmissing-prototypes \
+    -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings -ggdb \
+    -fno-omit-frame-pointer \
+    -D "$ENDIAN" \
+    "$@" \
+    -I"$SRC_ROOT"/uspace/lib/c/include \
+    -I"$SRC_ROOT"/abi/include \
+    -I"$SRC_ROOT"/uspace/lib/c/arch/"$UARCH"/include
Index: tools/xcw/bin/helenos-ld
===================================================================
--- tools/xcw/bin/helenos-ld	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ tools/xcw/bin/helenos-ld	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Copyright (c) 2015 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.
+#
+# Link editor (ld) wrapper
+# HelenOS Cross Compiler Wrapper (XCW)
+# Facilitate cross-compiling external software to HelenOS
+#
+
+XCW="$(dirname "$0")"
+SRC_ROOT="$XCW/../../.."
+UARCH="$("$XCW"/helenos-bld-config --uarch)"
+LD="$("$XCW"/helenos-bld-config --ld)"
+
+echo helenos-ld "$@"
+"$LD" \
+    -n -T "$SRC_ROOT"/uspace/lib/c/arch/"$UARCH"/_link.ld \
+    "$@" \
+    "$SRC_ROOT"/uspace/lib/c/libc.a
Index: tools/xcw/bin/helenos-pkg-config
===================================================================
--- tools/xcw/bin/helenos-pkg-config	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ tools/xcw/bin/helenos-pkg-config	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,85 @@
+#!/bin/bash
+#
+# Copyright (c) 2015 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.
+#
+# pkg-config-like tool for HelenOS libraries
+# HelenOS Cross Compiler Wrapper (XCW)
+# Facilitate cross-compiling external software to HelenOS
+#
+
+XCW="$(dirname "$0")"
+SRC_ROOT="$XCW/../../.."
+UARCH="$("$XCW"/helenos-bld-config --uarch)"
+
+libmath_cflags="-I$SRC_ROOT/uspace/lib/math/include\
+    -I$SRC_ROOT/uspace/lib/math/arch/$UARCH/include"
+libmath_libs="$SRC_ROOT/uspace/lib/math/libmath.a"
+
+libgui_cflags="-I$SRC_ROOT/uspace/lib/gui"
+libgui_libs="$SRC_ROOT/uspace/lib/gui/libgui.a"
+
+libdraw_cflags="-I$SRC_ROOT/uspace/lib/draw"
+libdraw_libs="$SRC_ROOT/uspace/lib/draw/libdraw.a \
+    $SRC_ROOT/uspace/lib/softrend/libsoftrend.a"
+
+action=none
+pkg=
+
+while [ ".$1" != . ] ; do
+	case ".$1" in
+	(.--cflags) action=cflags;;
+	(.--libs) action=libs;;
+	(.-*) echo "Uknwown option $1" >&2; exit 1;;
+	(.*)
+	    case "$1" in
+	    (libgui) ;;
+	    (libdraw) ;;
+	    (libmath) ;;
+	    (*) echo "Unknown package $1" >&2; exit 1;;
+	    esac
+
+	    echo "$pkg" | grep -w "$1" >/dev/null 2>&1
+	    if [ $? -ne 0 ] ; then
+		    pkg="$pkg $1"
+	    fi;;
+	esac
+	shift 1
+done
+
+if [ ."$pkg" = . ]; then
+	echo "Package name(s) required." >&2
+	exit 1
+fi
+
+for p in $pkg ; do
+	case "$action" in
+	(cflags) eval "printf ' %s' \$${p}_cflags";;
+	(libs) eval "printf ' %s' \$${p}_libs";;
+	esac
+done
+
+echo
Index: tools/xcw/demo/Makefile
===================================================================
--- tools/xcw/demo/Makefile	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ tools/xcw/demo/Makefile	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,61 @@
+#
+# Copyright (c) 2015 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.
+#
+# Example cross-build for HelenOS using XCW (HelenOS Cross Compiler Wrapper)
+# This allows an external (cross-platform) application to be compiled for
+# HelenOS by changing the compiler/linker helenos-cc/helenos-ld and adding
+# platform-specific support. To configure use of HelenOS libraries one can use
+# helenos-pkg-config. The HelenOS source tree containing XCW must be configured
+# and build for XCW to work as a cross compiler.
+#
+# Example commands to build this demo:
+#
+#    cd <helenos-source-dir>
+#    make distclean && make -j 4 PROFILE=amd64
+#    cd <helenos-source-dir>/tools/xcw/demo
+#    export PATH=$PATH:<helenos-source-dir>/tools/xcw/bin
+#    make
+#
+
+CC = helenos-cc
+LD = helenos-ld
+CFLAGS = -std=gnu99 -Wall `helenos-pkg-config --cflags libgui libdraw libmath`
+LIBS = `helenos-pkg-config --libs libgui libdraw libmath`
+output = viewer
+objects = viewer.o
+
+default: $(output)
+all: $(output)
+
+clean:
+	rm -f $(output) $(objects)
+
+$(output): $(objects)
+	$(LD) -o $@ $^ $(LIBS)
+
+%.o: %.c
+	$(CC) -c $(CFLAGS) -o $@ $<
Index: tools/xcw/demo/viewer.c
===================================================================
--- tools/xcw/demo/viewer.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ tools/xcw/demo/viewer.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,1 @@
+../../../uspace/app/viewer/viewer.c
Index: uspace/app/barber/barber.c
===================================================================
--- uspace/app/barber/barber.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/barber/barber.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -267,5 +267,5 @@
 			link_initialize(&dev->link);
 			dev->svc_id = svcs[i];
-			dev->sess = loc_service_connect(EXCHANGE_SERIALIZE, svcs[i], 0);
+			dev->sess = loc_service_connect(svcs[i], INTERFACE_DDF, 0);
 			
 			list_append(&dev->link, &led_devs);
Index: uspace/app/bdsh/cmds/builtins/cd/cd.c
===================================================================
--- uspace/app/bdsh/cmds/builtins/cd/cd.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/cmds/builtins/cd/cd.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -57,8 +57,6 @@
 	previous_directory_set = true;
 
-	int rc = chdir(new_dir);
-	if (rc != EOK) {
-		return rc;
-	}
+	if (chdir(new_dir) != 0)
+		return errno;
 
 	str_cpy(previous_directory, PATH_MAX, previous_directory_tmp);
Index: uspace/app/bdsh/cmds/modules/cat/cat.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cat/cat.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/cmds/modules/cat/cat.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -244,5 +244,4 @@
 		
 		bytes = read(fd, buff + copied_bytes, bytes_to_read);
-		bytes += copied_bytes;
 		copied_bytes = 0;
 
Index: uspace/app/bdsh/cmds/modules/cp/cp.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cp/cp.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/cmds/modules/cp/cp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -27,4 +27,5 @@
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -84,5 +85,5 @@
 	int r = stat(path, &s);
 
-	if (r)
+	if (r != 0)
 		return TYPE_NONE;
 	else if (s.is_directory)
@@ -234,5 +235,5 @@
 			 */
 			if (force && !interactive) {
-				if (unlink(dest_path)) {
+				if (unlink(dest_path) != 0) {
 					printf("Unable to remove %s\n",
 					    dest_path);
@@ -245,5 +246,5 @@
 				if (overwrite) {
 					printf("Overwriting file: %s\n", dest_path);
-					if (unlink(dest_path)) {
+					if (unlink(dest_path) != 0) {
 						printf("Unable to remove %s\n", dest_path);
 						goto exit;
@@ -294,5 +295,5 @@
 				merge_paths(dest_path, PATH_MAX, src_dirname);
 
-				if (mkdir(dest_path, 0) == -1) {
+				if (mkdir(dest_path, 0) != 0) {
 					printf("Unable to create "
 					    "dest directory %s\n", dest_path);
@@ -308,5 +309,5 @@
 			 * e.g. cp -r /src /data/new_dir_src
 			 */
-			if (mkdir(dest_path, 0)) {
+			if (mkdir(dest_path, 0) != 0) {
 				printf("Unable to create "
 				    "dest directory %s\n", dest_path);
@@ -405,6 +406,6 @@
 	}
 
-	while ((bytes = read_all(fd1, buff, blen)) > 0) {
-		if ((bytes = write_all(fd2, buff, bytes)) < 0)
+	while ((bytes = read(fd1, buff, blen)) > 0) {
+		if ((bytes = write(fd2, buff, bytes)) < 0)
 			break;
 		copied += bytes;
@@ -412,5 +413,5 @@
 
 	if (bytes < 0) {
-		printf("\nError copying %s, (%d)\n", src, bytes);
+		printf("\nError copying %s, (%d)\n", src, errno);
 		copied = bytes;
 	}
Index: uspace/app/bdsh/cmds/modules/ls/ls.c
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/cmds/modules/ls/ls.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -31,4 +31,5 @@
  * As more stuff is completed and exposed in libc, this will improve */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -187,5 +188,5 @@
 		if (rc != 0) {
 			printf("ls: skipping bogus node %s\n", buff);
-			printf("rc=%d\n", rc);
+			printf("error=%d\n", errno);
 			goto out;
 		}
@@ -314,5 +315,5 @@
 static unsigned int ls_scope(const char *path, struct dir_elem_t *de)
 {
-	if (stat(path, &de->s)) {
+	if (stat(path, &de->s) != 0) {
 		cli_error(CL_ENOENT, "%s", path);
 		return LS_BOGUS;
@@ -376,18 +377,23 @@
 		}
 	}
-	
+
 	argc -= optind;
-	
+
 	de.name = (char *) malloc(PATH_MAX);
 	if (!de.name) {
-		cli_error(CL_ENOMEM, "%s: ", cmdname);
+		cli_error(CL_ENOMEM, "%s: Out of memory", cmdname);
 		return CMD_FAILURE;
 	}
 	memset(de.name, 0, PATH_MAX);
-	
-	if (argc == 0)
-		getcwd(de.name, PATH_MAX);
-	else
+
+	if (argc == 0) {
+		if (getcwd(de.name, PATH_MAX) == NULL) {
+			cli_error(CL_EFAIL, "%s: Failed determining working "
+			    "directory", cmdname);
+			return CMD_FAILURE;
+		}
+	} else {
 		str_cpy(de.name, PATH_MAX, argv[optind]);
+	}
 
 	scope = ls_scope(de.name, &de);
Index: uspace/app/bdsh/cmds/modules/mkdir/mkdir.c
===================================================================
--- uspace/app/bdsh/cmds/modules/mkdir/mkdir.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/cmds/modules/mkdir/mkdir.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -89,5 +89,5 @@
 {
 	/* Ensure we would always work with absolute and canonified path. */
-	char *path = absolutize(user_path, NULL);
+	char *path = vfs_absolutize(user_path, NULL);
 	if (path == NULL) {
 		cli_error(CL_ENOMEM, "%s: path too big?", cmdname);
@@ -95,12 +95,10 @@
 	}
 
-	int rc;
 	int ret = 0;
 
 	if (!create_parents) {
-		rc = mkdir(path, 0);
-		if (rc != EOK) {
+		if (mkdir(path, 0) != 0) {
 			cli_error(CL_EFAIL, "%s: could not create %s (%s)",
-			    cmdname, path, str_error(rc));
+			    cmdname, path, str_error(errno));
 			ret = 1;
 		}
@@ -137,12 +135,8 @@
 			char slash_char = path[prev_off];
 			path[prev_off] = 0;
-			rc = mkdir(path, 0);
-			if (rc == EEXIST) {
-				rc = EOK;
-			}
-
-			if (rc != EOK) {
+
+			if (mkdir(path, 0) != 0 && errno != EEXIST) {
 				cli_error(CL_EFAIL, "%s: could not create %s (%s)",
-				    cmdname, path, str_error(rc));
+				    cmdname, path, str_error(errno));
 				ret = 1;
 				goto leave;
@@ -152,8 +146,7 @@
 		}
 		/* Create the final directory. */
-		rc = mkdir(path, 0);
-		if (rc != EOK) {
+		if (mkdir(path, 0) != 0) {
 			cli_error(CL_EFAIL, "%s: could not create %s (%s)",
-			    cmdname, path, str_error(rc));
+			    cmdname, path, str_error(errno));
 			ret = 1;
 		}
@@ -214,5 +207,6 @@
 
 	if (follow && (argv[optind] != NULL)) {
-		chdir(argv[optind]);
+		if (chdir(argv[optind]) != 0)
+			printf("%s: Error switching to directory.", cmdname);
 	}
 
Index: uspace/app/bdsh/cmds/modules/mkfile/mkfile.c
===================================================================
--- uspace/app/bdsh/cmds/modules/mkfile/mkfile.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/cmds/modules/mkfile/mkfile.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -27,4 +27,5 @@
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -166,8 +167,10 @@
 
 		if ((rc2 = lseek(fd, file_size - 1, SEEK_SET)) < 0)
-			goto exit;
+			goto error;
 
 		rc2 = write(fd, &byte, sizeof(char));
-		goto exit;
+		if (rc2 < 0)
+			goto error;
+		return CMD_SUCCESS;
 	}
 
@@ -183,5 +186,5 @@
 		rc = write(fd, buffer, to_write);
 		if (rc <= 0) {
-			printf("%s: Error writing file (%zd).\n", cmdname, rc);
+			printf("%s: Error writing file (%d).\n", cmdname, errno);
 			close(fd);
 			return CMD_FAILURE;
@@ -191,12 +194,11 @@
 
 	free(buffer);
-exit:
-	rc = close(fd);
-
-	if (rc != 0 || rc2 < 0) {
-		printf("%s: Error writing file (%zd).\n", cmdname, rc);
-		return CMD_FAILURE;
-	}
+
+	if (close(fd) < 0)
+		goto error;
 
 	return CMD_SUCCESS;
+error:
+	printf("%s: Error writing file (%d).\n", cmdname, errno);
+	return CMD_FAILURE;
 }
Index: uspace/app/bdsh/cmds/modules/mount/mount.c
===================================================================
--- uspace/app/bdsh/cmds/modules/mount/mount.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/cmds/modules/mount/mount.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -72,5 +72,5 @@
 	int rc;
 
-	get_mtab_list(&mtab_list);
+	vfs_get_mtab_list(&mtab_list);
 
 	list_foreach(mtab_list, link, mtab_ent_t, mtab_ent) {
@@ -150,5 +150,5 @@
 		mopts = t_argv[4];
 
-	rc = mount(t_argv[1], t_argv[2], dev, mopts, 0, instance);
+	rc = vfs_mount(t_argv[1], t_argv[2], dev, mopts, 0, instance);
 	if (rc != EOK) {
 		printf("Unable to mount %s filesystem to %s on %s (rc=%d)\n",
Index: uspace/app/bdsh/cmds/modules/mv/mv.c
===================================================================
--- uspace/app/bdsh/cmds/modules/mv/mv.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/cmds/modules/mv/mv.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -60,7 +60,7 @@
 
 	rc = rename(argv[1], argv[2]);
-	if (rc != EOK) {
-		printf("Unable to rename %s to %s (rc=%d)\n",
-		    argv[1], argv[2], rc);
+	if (rc != 0) {
+		printf("Unable to rename %s to %s (error=%d)\n",
+		    argv[1], argv[2], errno);
 		return CMD_FAILURE;
 	}
Index: uspace/app/bdsh/cmds/modules/pwd/pwd.c
===================================================================
--- uspace/app/bdsh/cmds/modules/pwd/pwd.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/cmds/modules/pwd/pwd.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -56,7 +56,6 @@
 
 	memset(buff, 0, PATH_MAX);
-	getcwd(buff, PATH_MAX);
 
-	if (! buff) {
+	if (getcwd(buff, PATH_MAX) == NULL) {
 		cli_error(CL_EFAIL,
 			"Unable to determine the current working directory");
Index: uspace/app/bdsh/cmds/modules/rm/rm.c
===================================================================
--- uspace/app/bdsh/cmds/modules/rm/rm.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/cmds/modules/rm/rm.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -27,4 +27,5 @@
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -131,5 +132,5 @@
 static unsigned int rm_single(const char *path)
 {
-	if (unlink(path)) {
+	if (unlink(path) != 0) {
 		cli_error(CL_EFAIL, "rm: could not remove file %s", path);
 		return 1;
@@ -150,5 +151,5 @@
 
 	fd = open(path, O_RDONLY);
-	if (fd > 0) {
+	if (fd >= 0) {
 		close(fd);
 		return RM_FILE;
@@ -210,5 +211,5 @@
 	rc = rmdir(path);
 	if (rc == 0)
-		return ret;
+		return errno;
 
 	cli_error(CL_ENOTSUP, "Can not remove %s", path);
Index: uspace/app/bdsh/cmds/modules/touch/touch.c
===================================================================
--- uspace/app/bdsh/cmds/modules/touch/touch.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/cmds/modules/touch/touch.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -123,5 +123,5 @@
 		
 		/* Check whether file exists if -c (--no-create) option is given */
-		if ((!no_create) || ((no_create) && (stat(buff, &file_stat) == EOK)))
+		if ((!no_create) || ((no_create) && (stat(buff, &file_stat) == 0)))
 			fd = open(buff, O_RDWR | O_CREAT);
 		
Index: uspace/app/bdsh/cmds/modules/unmount/unmount.c
===================================================================
--- uspace/app/bdsh/cmds/modules/unmount/unmount.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/cmds/modules/unmount/unmount.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -66,5 +66,5 @@
 	}
 
-	rc = unmount(argv[1]);
+	rc = vfs_unmount(argv[1]);
 	if (rc != EOK) {
 		printf("Unable to unmount %s (rc=%d)\n", argv[1], rc);
Index: uspace/app/bdsh/compl.c
===================================================================
--- uspace/app/bdsh/compl.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/compl.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -360,5 +360,5 @@
 				asprintf(&ent_path, "%s/%s", *cs->path, dent->d_name);
 				struct stat ent_stat;
-				if (stat(ent_path, &ent_stat) != EOK) {
+				if (stat(ent_path, &ent_stat) != 0) {
 					/* Error */
 					free(ent_path);
Index: uspace/app/bdsh/config.h
===================================================================
--- uspace/app/bdsh/config.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/config.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -46,6 +46,6 @@
 /* How many words (arguments) are permitted, how big can a whole
  * sentence be? Similar to ARG_MAX */
-#define WORD_MAX 255
-#define INPUT_MAX 1024
+#define WORD_MAX 1023
+#define INPUT_MAX 4096
 
 /* Leftovers from Autoconf */
Index: uspace/app/bdsh/errors.h
===================================================================
--- uspace/app/bdsh/errors.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/errors.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -42,5 +42,5 @@
 #define CL_ENOTSUP 6
 #define CL_EEXEC   7
-#define CL_EEXISTS 8
+#define CL_EEXIST  8
 #define CL_ETOOBIG 9
 
Index: uspace/app/bdsh/exec.c
===================================================================
--- uspace/app/bdsh/exec.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/bdsh/exec.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -61,5 +61,5 @@
 
 	fd = open(f, O_RDONLY);
-	if (fd > -1) {
+	if (fd >= 0) {
 		close(fd);
 		return 0;
@@ -113,5 +113,5 @@
 	
 	for (i = 0; i < 3 && files[i] != NULL; i++) {
-		if (fhandle(files[i], &file_handles[i]) == EOK) {
+		if (vfs_fhandle(files[i], &file_handles[i]) == EOK) {
 			file_handles_p[i] = &file_handles[i];
 		}
Index: uspace/app/blkdump/blkdump.c
===================================================================
--- uspace/app/blkdump/blkdump.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/blkdump/blkdump.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -142,5 +142,5 @@
 	}
 
-	rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048);
+	rc = block_init(service_id, 2048);
 	if (rc != EOK)  {
 		printf(NAME ": Error initializing libblock.\n");
Index: uspace/app/date/date.c
===================================================================
--- uspace/app/date/date.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/date/date.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -136,6 +136,5 @@
 
 	/* Connect to the device */
-	async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE,
-	    svc_id, 0);
+	async_sess_t *sess = loc_service_connect(svc_id, INTERFACE_DDF, 0);
 	if (!sess) {
 		printf(NAME ": Cannot connect to the device\n");
Index: uspace/app/df/df.c
===================================================================
--- uspace/app/df/df.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/df/df.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -119,10 +119,14 @@
 
 	LIST_INITIALIZE(mtab_list);
-	get_mtab_list(&mtab_list);
+	vfs_get_mtab_list(&mtab_list);
 
 	print_header();
 	list_foreach(mtab_list, link, mtab_ent_t, mtab_ent) {
-		statfs(mtab_ent->mp, &st);
-		print_statfs(&st, mtab_ent->fs_name, mtab_ent->mp);
+		if (statfs(mtab_ent->mp, &st) == 0) {
+			print_statfs(&st, mtab_ent->fs_name, mtab_ent->mp);
+		} else {
+			fprintf(stderr, "Cannot get information for '%s' (%d).\n",
+			    mtab_ent->mp, errno);
+		}
 	}
 
Index: uspace/app/hdisk/hdisk.c
===================================================================
--- uspace/app/hdisk/hdisk.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/hdisk/hdisk.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -82,5 +82,5 @@
 	label.device = dev_handle;
 	
-	rc = block_init(EXCHANGE_ATOMIC, dev_handle, 512);
+	rc = block_init(dev_handle, 512);
 	if (rc != EOK) {
 		printf("Error during libblock init: %d - %s.\n", rc, str_error(rc));
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/init/init.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -126,5 +126,5 @@
 		opts = "restore";
 	
-	int rc = mount(fstype, ROOT_MOUNT_POINT, ROOT_DEVICE, opts,
+	int rc = vfs_mount(fstype, ROOT_MOUNT_POINT, ROOT_DEVICE, opts,
 	    IPC_FLAG_BLOCKING, 0);
 	return mount_report("Root filesystem", ROOT_MOUNT_POINT, fstype,
@@ -143,5 +143,5 @@
 static bool mount_locfs(void)
 {
-	int rc = mount(LOCFS_FS_TYPE, LOCFS_MOUNT_POINT, "", "",
+	int rc = vfs_mount(LOCFS_FS_TYPE, LOCFS_MOUNT_POINT, "", "",
 	    IPC_FLAG_BLOCKING, 0);
 	return mount_report("Location service filesystem", LOCFS_MOUNT_POINT,
@@ -152,5 +152,5 @@
 {
 	struct stat s;
-	if (stat(path, &s) == ENOENT) {
+	if (stat(path, &s) != 0) {
 		printf("%s: Unable to stat %s\n", NAME, path);
 		return ENOENT;
@@ -299,5 +299,5 @@
 static bool mount_tmpfs(void)
 {
-	int rc = mount(TMPFS_FS_TYPE, TMPFS_MOUNT_POINT, "", "", 0, 0);
+	int rc = vfs_mount(TMPFS_FS_TYPE, TMPFS_MOUNT_POINT, "", "", 0, 0);
 	return mount_report("Temporary filesystem", TMPFS_MOUNT_POINT,
 	    TMPFS_FS_TYPE, NULL, rc);
Index: uspace/app/mixerctl/mixerctl.c
===================================================================
--- uspace/app/mixerctl/mixerctl.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/mixerctl/mixerctl.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -155,6 +155,5 @@
 	}
 
-	async_sess_t *session = loc_service_connect(
-	    EXCHANGE_ATOMIC, mixer_sid, 0);
+	async_sess_t *session = loc_service_connect(mixer_sid, INTERFACE_DDF, 0);
 	if (!session) {
 		printf("Failed connecting mixer service '%s'.\n", service);
Index: uspace/app/mkbd/main.c
===================================================================
--- uspace/app/mkbd/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/mkbd/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -231,6 +231,5 @@
 	}
 	
-	async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE,
-	    dev_handle, 0);
+	async_sess_t *sess = devman_device_connect(dev_handle, 0);
 	if (!sess) {
 		printf(NAME ": failed to connect to the device (handle %"
Index: uspace/app/mkexfat/mkexfat.c
===================================================================
--- uspace/app/mkexfat/mkexfat.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/mkexfat/mkexfat.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -803,5 +803,5 @@
 	}
 
-	rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048);
+	rc = block_init(service_id, 2048);
 	if (rc != EOK) {
 		printf(NAME ": Error initializing libblock.\n");
Index: uspace/app/mkfat/mkfat.c
===================================================================
--- uspace/app/mkfat/mkfat.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/mkfat/mkfat.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -162,5 +162,5 @@
 	}
 
-	rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048);
+	rc = block_init(service_id, 2048);
 	if (rc != EOK)  {
 		printf(NAME ": Error initializing libblock.\n");
Index: uspace/app/mkmfs/mkmfs.c
===================================================================
--- uspace/app/mkmfs/mkmfs.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/mkmfs/mkmfs.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -209,5 +209,5 @@
 	}
 
-	rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048);
+	rc = block_init(service_id, 2048);
 	if (rc != EOK)  {
 		printf(NAME ": Error initializing libblock.\n");
Index: uspace/app/nic/nic.c
===================================================================
--- uspace/app/nic/nic.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/nic/nic.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -99,5 +99,5 @@
 	printf("Using device: %s\n", svc_name);
 
-	sess = loc_service_connect(EXCHANGE_SERIALIZE, nics[i], 0);
+	sess = loc_service_connect(nics[i], INTERFACE_DDF, 0);
 	if (sess == NULL) {
 		printf("Error connecting to service.\n");
@@ -117,10 +117,10 @@
 	int rc;
 
-	sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id, 0);
+	sess = loc_service_connect(svc_id, INTERFACE_DDF, 0);
 	if (sess == NULL) {
 		printf("Error connecting to service.\n");
 		goto error;
 	}
-
+	
 	rc = nic_get_address(sess, &info->address);
 	if (rc != EOK) {
Index: uspace/app/sportdmp/sportdmp.c
===================================================================
--- uspace/app/sportdmp/sportdmp.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/sportdmp/sportdmp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -111,5 +111,5 @@
 
 
-	async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id,
+	async_sess_t *sess = loc_service_connect(svc_id, INTERFACE_DDF,
 	    IPC_FLAG_BLOCKING);
 	if (!sess) {
Index: uspace/app/taskdump/elf_core.c
===================================================================
--- uspace/app/taskdump/elf_core.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/taskdump/elf_core.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -207,5 +207,5 @@
 	}
 
-	rc = write_all(fd, &elf_hdr, sizeof(elf_hdr));
+	rc = write(fd, &elf_hdr, sizeof(elf_hdr));
 	if (rc != sizeof(elf_hdr)) {
 		printf("Failed writing ELF header.\n");
@@ -215,5 +215,5 @@
 
 	for (i = 0; i < n_ph; ++i) {
-		rc = write_all(fd, &p_hdr[i], sizeof(p_hdr[i]));
+		rc = write(fd, &p_hdr[i], sizeof(p_hdr[i]));
 		if (rc != sizeof(p_hdr[i])) {
 			printf("Failed writing program header.\n");
@@ -236,5 +236,5 @@
 	note.type = NT_PRSTATUS;
 
-	rc = write_all(fd, &note, sizeof(elf_note_t));
+	rc = write(fd, &note, sizeof(elf_note_t));
 	if (rc != sizeof(elf_note_t)) {
 		printf("Failed writing note header.\n");
@@ -243,5 +243,5 @@
 	}
 
-	rc = write_all(fd, "CORE", note.namesz);
+	rc = write(fd, "CORE", note.namesz);
 	if (rc != (ssize_t) note.namesz) {
 		printf("Failed writing note header.\n");
@@ -257,5 +257,5 @@
 	}
 
-	rc = write_all(fd, &pr_status, sizeof(elf_prstatus_t));
+	rc = write(fd, &pr_status, sizeof(elf_prstatus_t));
 	if (rc != sizeof(elf_prstatus_t)) {
 		printf("Failed writing register data.\n");
@@ -321,5 +321,5 @@
 		}
 
-		rc = write_all(fd, buffer, to_copy);
+		rc = write(fd, buffer, to_copy);
 		if (rc != (ssize_t) to_copy) {
 			printf("Failed writing memory contents.\n");
Index: uspace/app/taskdump/symtab.c
===================================================================
--- uspace/app/taskdump/symtab.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/taskdump/symtab.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -88,5 +88,5 @@
 	}
 
-	rc = read_all(fd, &elf_hdr, sizeof(elf_header_t));
+	rc = read(fd, &elf_hdr, sizeof(elf_header_t));
 	if (rc != sizeof(elf_header_t)) {
 		printf("failed reading elf header\n");
@@ -310,5 +310,5 @@
 		return EIO;
 
-	rc = read_all(fd, sec_hdr, sizeof(elf_section_header_t));
+	rc = read(fd, sec_hdr, sizeof(elf_section_header_t));
 	if (rc != sizeof(elf_section_header_t))
 		return EIO;
@@ -346,5 +346,5 @@
 	}
 
-	rc = read_all(fd, *ptr, size);
+	rc = read(fd, *ptr, size);
 	if (rc != (ssize_t) size) {
 		printf("failed reading chunk\n");
Index: uspace/app/tester/float/float2.c
===================================================================
--- uspace/app/tester/float/float2.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/tester/float/float2.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2014 Martin Decky
+ * Copyright (c) 2015 Jiri Svoboda
  * All rights reserved.
  *
@@ -27,4 +28,5 @@
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -32,6 +34,7 @@
 #include "../tester.h"
 
-#define OPERANDS   10
-#define PRECISION  100000000
+#define OPERANDS         10
+#define PRECISIONF    10000
+#define PRECISION 100000000
 
 static double arguments[OPERANDS] = {
@@ -39,6 +42,97 @@
 };
 
-static double results_trunc[OPERANDS] = {
-	3.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1080.0, -600.0, 1.0
+static double arguments_acos[OPERANDS] = {
+	-0.936456687291, -0.504846104600, 0.862318872288, 0.964966028492,
+	0.987353618220, 1.0, -0.194939922623, 0.978471923925, -0.999023478833,
+	0.540302305868
+};
+
+static double arguments_asin[OPERANDS] = {
+	-0.350783227690, -0.863209366649, -0.506365641110, -0.262374853704,
+	0.158533380044, 0.0, 0.980815184715, -0.206379975025, -0.044182448332,
+	0.841470984808
+};
+
+static double arguments_atan[OPERANDS] = {
+	3.5, 100.0, 50.0, 768.3156, 1080.499999, 1.0, 66.0,
+	2.718281828459045, 9.9, 0.001
+};
+
+static double arguments_exp[OPERANDS] = {
+	3.5, -2.1, 50.0, 0.0, 1.0, 13.2, -1.1, -5.5, 0.1, -66.0
+};
+
+static double arguments_log[OPERANDS] = {
+	3.5, 100.0, 50.0, 768.3156, 1080.499999, 1.0, 66.0,
+	2.718281828459045, 9.9, 0.001
+};
+
+static double arguments_sqrt[OPERANDS] = {
+	3.5, 100.0, 50.0, 768.3156, 1080.499999, 1.0, 66.0,
+	2.718281828459045, 9.9, 0.001
+};
+
+static double arguments_tanh[OPERANDS] = {
+	3.5, -2.1, 50.0, 0.0, 1.0, 13.2, -1.1, -5.5, 0.000001, -66000000.0
+};
+
+static double results_acos[OPERANDS] = {
+	2.783185307180, 2.100000000000, 0.530964914873, 0.265482457437,
+	0.159205070272, 0.000000000000, 1.766992524091, 0.207873834887,
+	3.097395817941, 1.000000000000
+};
+
+static double results_asin[OPERANDS] = {
+	-0.358407346411, -1.041592653590, -0.530964914874, -0.265482457437,
+	0.159205070273, 0.000000000000, 1.374600129498, -0.207873834889,
+	-0.044196835651, 1.000000000000
+};
+
+static double results_atan[OPERANDS] = {
+	1.292496667790, 1.560796660108, 1.550798992822, 1.569494779052,
+	1.569870829603, 0.785398163397, 1.555645970920, 1.218282905017,
+	1.470127674637, 0.000999999667
+};
+
+static double results_ceil[OPERANDS] = {
+	4.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 769.0, 1081.0, -600.0, 1.0
+};
+
+static double results_cos[OPERANDS] = {
+	-0.936456687291, -0.504846104600, 0.862318872288, 0.964966028492,
+	0.987353618220, 1.0, -0.194939922623, 0.978471923925, -0.999023478833,
+	0.540302305868
+};
+
+static double results_cosh[OPERANDS] = {
+	16.572824671057, 4.144313170410, 2592352764293536022528.000000000000,
+	1.000000000000, 1.543080634815, 270182.468624271103, 1.668518553822,
+	122.348009517829, 1.005004168056, 23035933171656458903220125696.0
+};
+
+static double results_fabs[OPERANDS] = {
+	3.5, 2.1, 100.0, 50.0, 1024.0, 0.0, 768.3156, 1080.499999, 600.0, 1.0
+};
+
+static double results_floor[OPERANDS] = {
+	3.0, -3.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1080.0, -600.0, 1.0
+};
+
+static double results_exp[OPERANDS] = {
+	33.115451958692, 0.122456428253, 5184705528587072045056.0,
+	1.000000000000, 2.718281828459, 540364.937246691552, 0.332871083698,
+	0.004086771438, 1.105170918076, 0.000000000000
+};
+
+static double results_log[OPERANDS] = {
+	1.252762968495, 4.605170185988, 3.912023005428, 6.644200586236,
+	6.985179175021, 0.000000000000, 4.189654742026, 1.000000000000,
+	2.292534757141, -6.907755278982
+};
+
+static double results_log10[OPERANDS] = {
+	0.544068044350, 2.000000000000, 1.698970004336, 2.885539651261,
+	3.033624770817, 0.000000000000, 1.819543935542, 0.434294481903,
+	0.995635194598, -3.000000000000
 };
 
@@ -49,53 +143,413 @@
 };
 
-static double results_cos[OPERANDS] = {
-	-0.936456687291, -0.504846104600, 0.862318872288, 0.964966028492,
-	0.987353618220, 1.0, -0.194939922623, 0.978471923925, -0.999023478833,
-	0.540302305868
-};
+static double results_sinh[OPERANDS] = {
+	16.542627287635, -4.021856742157, 2592352764293536022528.000000000000,
+	0.000000000000, 1.175201193644, 270182.468622420449, -1.335647470124,
+	-122.343922746391, 0.100166750020, -23035933171656458903220125696.0
+};
+
+static double results_sqrt[OPERANDS] = {
+	1.870828693387, 10.000000000000, 7.071067811865, 27.718506453271,
+	32.870959812576, 1.000000000000, 8.124038404636, 1.648721270700,
+	3.146426544510, 0.031622776602
+};
+
+static double results_tan[OPERANDS] = {
+	0.374585640159, 1.709846542905, -0.587213915157, -0.271900611998,
+	0.160563932839, 0.000000000000, -5.031371570891, -0.210920691722,
+	0.044225635601, 1.557407724655
+};
+
+static double results_tanh[OPERANDS] = {
+	0.998177897611, -0.970451936613, 1.000000000000, 0.000000000000,
+	0.761594155956, 0.999999999993, -0.800499021761, -0.999966597156,
+	0.000001000000, -1.000000000000
+};
+
+static double results_trunc[OPERANDS] = {
+	3.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1080.0, -600.0, 1.0
+};
+
+static bool cmp_float(float a, float b)
+{
+	float r;
+
+	/* XXX Need fabsf() */
+	if (b < 1.0 / PRECISIONF && b > -1.0 / PRECISIONF)
+		r = a;
+	else
+		r = a / b - 1.0;
+
+	/* XXX Need fabsf() */
+	if (r < 0.0)
+		r = -r;
+
+	return r < 1.0 / PRECISIONF;
+}
+
+static bool cmp_double(double a, double b)
+{
+	double r;
+
+	/* XXX Need fabs() */
+	if (b < 1.0 / PRECISION && b > -1.0 / PRECISION)
+		r = a;
+	else
+		r = a / b - 1.0;
+
+	/* XXX Need fabs() */
+	if (r < 0.0)
+		r = -r;
+
+	return r < 1.0 / PRECISION;
+}
 
 const char *test_float2(void)
 {
 	bool fail = false;
-	
+if (0) {
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = acos(arguments_acos[i]);
+
+		if (!cmp_double(res, results_acos[i])) {
+			TPRINTF("Double precision acos failed "
+			    "(%lf != %lf, arg %u)\n", res, results_acos[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = acosf(arguments_acos[i]);
+
+		if (!cmp_float(res, results_acos[i])) {
+			TPRINTF("Single precision acos failed "
+			    "(%f != %lf, arg %u)\n", res, results_acos[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = asin(arguments_asin[i]);
+
+		if (!cmp_double(res, results_asin[i])) {
+			TPRINTF("Double precision asin failed "
+			    "(%lf != %lf, arg %u)\n", res, results_asin[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = asinf(arguments_asin[i]);
+
+		if (!cmp_float(res, results_asin[i])) {
+			TPRINTF("Single precision asin failed "
+			    "(%f != %lf, arg %u)\n", res, results_asin[i], i);
+			fail = true;
+		}
+	}
+}
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = atan(arguments_atan[i]);
+
+		if (!cmp_double(res, results_atan[i])) {
+			TPRINTF("Double precision atan failed "
+			    "(%.12lf != %.12lf, arg %u)\n", res, results_atan[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = atanf(arguments_atan[i]);
+
+		if (!cmp_float(res, results_atan[i])) {
+			TPRINTF("Single precision atan failed "
+			    "(%f != %lf, arg %u)\n", res, results_atan[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = ceil(arguments[i]);
+
+		if (!cmp_double(res, results_ceil[i])) {
+			TPRINTF("Double precision ceil failed "
+			    "(%lf != %lf, arg %u)\n", res, results_ceil[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = ceilf(arguments[i]);
+
+		if (!cmp_float(res, results_ceil[i])) {
+			TPRINTF("Single precision ceil failed "
+			    "(%f != %lf, arg %u)\n", res, results_ceil[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = cos(arguments[i]);
+
+		if (!cmp_double(res, results_cos[i])) {
+			TPRINTF("Double precision cos failed "
+			    "(%lf != %lf, arg %u)\n", res, results_cos[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = cosf(arguments[i]);
+
+		if (!cmp_float(res, results_cos[i])) {
+			TPRINTF("Single precision cos failed "
+			    "(%f != %lf, arg %u)\n", res, results_cos[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = cosh(arguments_exp[i]);
+
+		if (!cmp_double(res, results_cosh[i])) {
+			TPRINTF("Double precision cosh failed "
+			    "(%lf != %lf, arg %u)\n", res, results_cosh[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = coshf(arguments_exp[i]);
+
+		if (!cmp_float(res, results_cosh[i])) {
+			TPRINTF("Single precision cosh failed "
+			    "(%f != %lf, arg %u)\n", res, results_cosh[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = exp(arguments_exp[i]);
+
+		if (!cmp_double(res, results_exp[i])) {
+			TPRINTF("Double precision exp failed "
+			    "(%lf != %lf, arg %u)\n", res, results_exp[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = expf(arguments_exp[i]);
+
+		if (!cmp_float(res, results_exp[i])) {
+			TPRINTF("Single precision exp failed "
+			    "(%f != %lf, arg %u)\n", res, results_exp[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = fabs(arguments[i]);
+
+		if (!cmp_double(res, results_fabs[i])) {
+			TPRINTF("Double precision fabs failed "
+			    "(%lf != %lf, arg %u)\n", res, results_fabs[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = fabsf(arguments[i]);
+
+		if (!cmp_float(res, results_fabs[i])) {
+			TPRINTF("Single precision fabs failed "
+			    "(%f != %lf, arg %u)\n", res, results_fabs[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = floor(arguments[i]);
+
+		if (!cmp_double(res, results_floor[i])) {
+			TPRINTF("Double precision floor failed "
+			    "(%lf != %lf, arg %u)\n", res, results_floor[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = floorf(arguments[i]);
+
+		if (!cmp_float(res, results_floor[i])) {
+			TPRINTF("Single precision floor failed "
+			    "(%f != %lf, arg %u)\n", res, results_floor[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = log(arguments_log[i]);
+
+		if (!cmp_double(res, results_log[i])) {
+			TPRINTF("Double precision log failed "
+			    "(%lf != %lf, arg %u)\n", res, results_log[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = logf(arguments_log[i]);
+
+		if (!cmp_float(res, results_log[i])) {
+			TPRINTF("Single precision log failed "
+			    "(%f != %lf, arg %u)\n", res, results_log[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = log10(arguments_log[i]);
+
+		if (!cmp_double(res, results_log10[i])) {
+			TPRINTF("Double precision log10 failed "
+			    "(%lf != %lf, arg %u)\n", res, results_log10[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = log10f(arguments_log[i]);
+
+		if (!cmp_float(res, results_log10[i])) {
+			TPRINTF("Single precision log10 failed "
+			    "(%f != %lf, arg %u)\n", res, results_log10[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = sin(arguments[i]);
+
+		if (!cmp_double(res, results_sin[i])) {
+			TPRINTF("Double precision sin failed "
+			    "(%lf != %lf, arg %u)\n", res, results_sin[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = sinf(arguments[i]);
+
+		if (!cmp_float(res, results_sin[i])) {
+			TPRINTF("Single precision sin failed "
+			    "(%f != %lf, arg %u)\n", res, results_sin[i], i);
+			fail = true;
+		}
+	}
+;
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = sinh(arguments_exp[i]);
+
+		if (!cmp_double(res, results_sinh[i])) {
+			TPRINTF("Double precision sinh failed "
+			    "(%lf != %lf, arg %u)\n", res, results_sinh[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = sinhf(arguments_exp[i]);
+
+		if (!cmp_float(res, results_sinh[i])) {
+			TPRINTF("Single precision sinh failed "
+			    "(%f != %lf, arg %u)\n", res, results_sinh[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = sqrt(arguments_sqrt[i]);
+
+		if (!cmp_double(res, results_sqrt[i])) {
+			TPRINTF("Double precision sqrt failed "
+			    "(%lf != %lf, arg %u)\n", res, results_sqrt[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = sqrtf(arguments_sqrt[i]);
+
+		if (!cmp_float(res, results_sqrt[i])) {
+			TPRINTF("Single precision sqrt failed "
+			    "(%f != %lf, arg %u)\n", res, results_sqrt[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = tan(arguments[i]);
+
+		if (!cmp_double(res, results_tan[i])) {
+			TPRINTF("Double precision tan failed "
+			    "(%lf != %lf, arg %u)\n", res, results_tan[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = tanf(arguments[i]);
+
+		if (!cmp_float(res, results_tan[i])) {
+			TPRINTF("Single precision tan failed "
+			    "(%f != %lf, arg %u)\n", res, results_tan[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = tanh(arguments_tanh[i]);
+
+		if (!cmp_double(res, results_tanh[i])) {
+			TPRINTF("Double precision tanh failed "
+			    "(%lf != %lf, arg %u)\n", res, results_tanh[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = tanhf(arguments_tanh[i]);
+
+		if (!cmp_float(res, results_tanh[i])) {
+			TPRINTF("Single precision tanh failed "
+			    "(%f != %lf, arg %u)\n", res, results_tanh[i], i);
+			fail = true;
+		}
+	}
+
 	for (unsigned int i = 0; i < OPERANDS; i++) {
 		double res = trunc(arguments[i]);
-		int64_t res_int = (int64_t) (res * PRECISION);
-		int64_t corr_int = (int64_t) (results_trunc[i] * PRECISION);
-		
-		if (res_int != corr_int) {
-			TPRINTF("Double truncation failed (%" PRId64 " != %" PRId64
-			    ", arg %u)\n", res_int, corr_int, i);
-			fail = true;
-		}
-	}
-	
-	for (unsigned int i = 0; i < OPERANDS; i++) {
-		double res = sin(arguments[i]);
-		int64_t res_int = (int64_t) (res * PRECISION);
-		int64_t corr_int = (int64_t) (results_sin[i] * PRECISION);
-		
-		if (res_int != corr_int) {
-			TPRINTF("Double sine failed (%" PRId64 " != %" PRId64
-			    ", arg %u)\n", res_int, corr_int, i);
-			fail = true;
-		}
-	}
-	
-	for (unsigned int i = 0; i < OPERANDS; i++) {
-		double res = cos(arguments[i]);
-		int64_t res_int = (int64_t) (res * PRECISION);
-		int64_t corr_int = (int64_t) (results_cos[i] * PRECISION);
-		
-		if (res_int != corr_int) {
-			TPRINTF("Double cosine failed (%" PRId64 " != %" PRId64
-			    ", arg %u)\n", res_int, corr_int, i);
-			fail = true;
-		}
-	}
-	
+
+		if (!cmp_double(res, results_trunc[i])) {
+			TPRINTF("Double precision trunc failed "
+			    "(%lf != %lf, arg %u)\n", res, results_trunc[i], i);
+			fail = true;
+		}
+	}
+
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		float res = truncf(arguments[i]);
+
+		if (!cmp_float(res, results_trunc[i])) {
+			TPRINTF("Single precision trunc failed "
+			    "(%f != %lf, arg %u)\n", res, results_trunc[i], i);
+			fail = true;
+		}
+	}
+
 	if (fail)
 		return "Floating point imprecision";
-	
+
 	return NULL;
 }
Index: uspace/app/tester/hw/misc/virtchar1.c
===================================================================
--- uspace/app/tester/hw/misc/virtchar1.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/tester/hw/misc/virtchar1.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -58,5 +58,5 @@
 	int fd = open(path, O_RDONLY);
 	if (fd < 0) {
-		TPRINTF("   ...error: %s\n", str_error(fd));
+		TPRINTF("   ...error: %s\n", str_error(errno));
 		if (fd == ENOENT) {
 			TPRINTF("   (error was ENOENT: " \
@@ -69,5 +69,5 @@
 	
 	TPRINTF(" Asking for session...\n");
-	async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd);
+	async_sess_t *sess = vfs_fd_session(fd, INTERFACE_DDF);
 	if (!sess) {
 		close(fd);
Index: uspace/app/tester/hw/serial/serial1.c
===================================================================
--- uspace/app/tester/hw/serial/serial1.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/tester/hw/serial/serial1.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -76,5 +76,5 @@
 		return "Failed getting serial port service ID";
 	
-	async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id,
+	async_sess_t *sess = loc_service_connect(svc_id, INTERFACE_DDF,
 	    IPC_FLAG_BLOCKING);
 	if (!sess)
Index: uspace/app/tester/mm/common.c
===================================================================
--- uspace/app/tester/mm/common.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/tester/mm/common.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -309,5 +309,5 @@
 		return NULL;
 	
-	unsigned int idx = rand() % mem_blocks_count;
+	unsigned long idx = rand() % mem_blocks_count;
 	link_t *entry = list_nth(&mem_blocks, idx);
 	
Index: uspace/app/tester/tester.h
===================================================================
--- uspace/app/tester/tester.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/tester/tester.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -60,5 +60,5 @@
 	do { \
 		if (!test_quiet) { \
-			fprintf(stderr, (format), ##__VA_ARGS__); \
+			fprintf(stdout, (format), ##__VA_ARGS__); \
 		} \
 	} while (0)
Index: uspace/app/tester/vfs/vfs1.c
===================================================================
--- uspace/app/tester/vfs/vfs1.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/tester/vfs/vfs1.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -70,7 +70,6 @@
 const char *test_vfs1(void)
 {
-	int rc;
-	if ((rc = mkdir(TEST_DIRECTORY, 0)) != 0) {
-		TPRINTF("rc=%d\n", rc);
+	if (mkdir(TEST_DIRECTORY, 0) != 0) {
+		TPRINTF("rc=%d\n", errno);
 		return "mkdir() failed";
 	}
@@ -93,5 +92,7 @@
 	
 	char buf[BUF_SIZE];
+	TPRINTF("read..\n");
 	while ((cnt = read(fd0, buf, BUF_SIZE))) {
+		TPRINTF("read returns %zd\n", cnt);
 		if (cnt < 0)
 			return "read() failed";
@@ -112,13 +113,13 @@
 		return rv;
 	
-	if (rename(TEST_FILE, TEST_FILE2))
+	if (rename(TEST_FILE, TEST_FILE2) != 0)
 		return "rename() failed";
 	TPRINTF("Renamed %s to %s\n", TEST_FILE, TEST_FILE2);
 	
-	if (unlink(TEST_FILE2))
+	if (unlink(TEST_FILE2) != 0)
 		return "unlink() failed";
 	TPRINTF("Unlinked %s\n", TEST_FILE2);
 	
-	if (rmdir(TEST_DIRECTORY))
+	if (rmdir(TEST_DIRECTORY) != 0)
 		return "rmdir() failed";
 	TPRINTF("Removed directory %s\n", TEST_DIRECTORY);
Index: uspace/app/tetris/scores.c
===================================================================
--- uspace/app/tetris/scores.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/tetris/scores.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -233,4 +233,9 @@
 
 	f = fopen("/data/tetris.sco", "wb");
+	if (f == NULL) {
+		printf("Error creating table\n");
+		return;
+	}
+	
 	cnt = fwrite(scores, sizeof(struct highscore), NUMSPOTS, f);
 	rc = fclose(f);
Index: uspace/app/trace/errors.c
===================================================================
--- uspace/app/trace/errors.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/trace/errors.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -46,5 +46,5 @@
 	[-EPERM]	= { "EPERM",		"Permission denied" },
 	[-EHANGUP]	= { "EHANGUP",		"Answerbox closed connection" },
-	[-EEXISTS]	= { "EEXISTS",		"Entry already exists" },
+	[-EEXIST]	= { "EEXIST",		"Entry already exists" },
 	[-EBADMEM]	= { "EBADMEM",		"Bad memory pointer" },
 
Index: uspace/app/trace/ipcp.c
===================================================================
--- uspace/app/trace/ipcp.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/trace/ipcp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -303,5 +303,5 @@
 	    (retval == 0)) {
 		/* Connected to a service (through NS) */
-		service = IPC_GET_ARG1(pcall->question);
+		service = IPC_GET_ARG2(pcall->question);
 		proto = proto_get_by_srv(service);
 		if (proto == NULL)
Index: uspace/app/trace/trace.c
===================================================================
--- uspace/app/trace/trace.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/trace/trace.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -57,5 +57,5 @@
 #include "proto.h"
 #include <ipc/services.h>
-#include "../../srv/vfs/vfs.h"
+#include <ipc/vfs.h>
 #include <ipc/console.h>
 
@@ -528,15 +528,15 @@
 	int fd_stderr;
 	
-	if ((stdin != NULL) && (fhandle(stdin, &fd_stdin) == EOK))
+	if ((stdin != NULL) && (vfs_fhandle(stdin, &fd_stdin) == EOK))
 		files[0] = &fd_stdin;
 	else
 		files[0] = NULL;
 	
-	if ((stdout != NULL) && (fhandle(stdout, &fd_stdout) == EOK))
+	if ((stdout != NULL) && (vfs_fhandle(stdout, &fd_stdout) == EOK))
 		files[1] = &fd_stdout;
 	else
 		files[1] = NULL;
 	
-	if ((stderr != NULL) && (fhandle(stderr, &fd_stderr) == EOK))
+	if ((stderr != NULL) && (vfs_fhandle(stderr, &fd_stderr) == EOK))
 		files[2] = &fd_stderr;
 	else
Index: uspace/app/untar/main.c
===================================================================
--- uspace/app/untar/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/untar/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -103,13 +103,10 @@
 static int handle_directory(const tar_header_t *header, FILE *tarfile)
 {
-	int rc = mkdir(header->filename, 0755);
-	if ((rc == EEXIST) || (rc == EEXISTS)) {
-		// printf("Note: directory %s already exists.\n", header->filename);
-		rc = EOK;
-	}
-	if (rc != EOK) {
-		fprintf(stderr, "Failed to create directory %s: %s.\n",
-		    header->filename, str_error(rc));
-		return rc;
+	if (mkdir(header->filename, 0755) != 0) {
+		if (errno != EEXIST) {
+			fprintf(stderr, "Failed to create directory %s: %s.\n",
+			    header->filename, str_error(errno));
+			return errno;
+		}
 	}
 
Index: uspace/app/viewer/viewer.c
===================================================================
--- uspace/app/viewer/viewer.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/viewer/viewer.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -98,10 +98,10 @@
 {
 	int fd = open(fname, O_RDONLY);
-	if (fd < 0)
+	if (fd != 0)
 		return false;
 	
 	struct stat stat;
 	int rc = fstat(fd, &stat);
-	if (rc != EOK) {
+	if (rc != 0) {
 		close(fd);
 		return false;
@@ -114,5 +114,5 @@
 	}
 	
-	ssize_t rd = read_all(fd, tga, stat.size);
+	ssize_t rd = read(fd, tga, stat.size);
 	if ((rd < 0) || (rd != (ssize_t) stat.size)) {
 		free(tga);
Index: uspace/app/vuhid/device.c
===================================================================
--- uspace/app/vuhid/device.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/vuhid/device.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -123,5 +123,5 @@
 	/* Already used interface. */
 	if (iface->vuhid_data != NULL) {
-		return EEXISTS;
+		return EEXIST;
 	}
 
Index: uspace/app/wifi_supplicant/wifi_supplicant.c
===================================================================
--- uspace/app/wifi_supplicant/wifi_supplicant.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/app/wifi_supplicant/wifi_supplicant.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -121,5 +121,5 @@
 	
 	async_sess_t *sess =
-	    loc_service_connect(EXCHANGE_SERIALIZE, wifis[i], 0);
+	    loc_service_connect(wifis[i], INTERFACE_DDF, 0);
 	if (sess == NULL) {
 		printf("Error connecting to service.\n");
Index: uspace/drv/audio/hdaudio/hdaudio.c
===================================================================
--- uspace/drv/audio/hdaudio/hdaudio.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/audio/hdaudio/hdaudio.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -175,6 +175,5 @@
 
 	ddf_msg(LVL_NOTE, "create parent sess");
-	hda->parent_sess = ddf_dev_parent_sess_create(dev,
-	    EXCHANGE_SERIALIZE);
+	hda->parent_sess = ddf_dev_parent_sess_create(dev);
 	if (hda->parent_sess == NULL) {
 		ddf_msg(LVL_ERROR, "Failed connecting parent driver.\n");
Index: uspace/drv/audio/sb16/dsp.c
===================================================================
--- uspace/drv/audio/sb16/dsp.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/audio/sb16/dsp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -159,5 +159,5 @@
 static inline int setup_dma(sb_dsp_t *dsp, uintptr_t pa, size_t size)
 {
-	async_sess_t *sess = devman_parent_device_connect(EXCHANGE_ATOMIC,
+	async_sess_t *sess = devman_parent_device_connect(
 	    ddf_dev_get_handle(dsp->sb_dev), IPC_FLAG_BLOCKING);
 
@@ -307,5 +307,5 @@
 
 	assert(dsp->buffer.data);
-	async_sess_t *sess = devman_parent_device_connect(EXCHANGE_ATOMIC,
+	async_sess_t *sess = devman_parent_device_connect(
 	    ddf_dev_get_handle(dsp->sb_dev), IPC_FLAG_BLOCKING);
 
Index: uspace/drv/audio/sb16/main.c
===================================================================
--- uspace/drv/audio/sb16/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/audio/sb16/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -178,5 +178,5 @@
 
 	async_sess_t *parent_sess = devman_parent_device_connect(
-	    EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
+	    ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
 	if (!parent_sess)
 		return ENOMEM;
@@ -245,5 +245,5 @@
 {
 	async_sess_t *parent_sess = devman_parent_device_connect(
-	    EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
+	    ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
 	if (!parent_sess)
 		return ENOMEM;
Index: uspace/drv/block/ahci/ahci.c
===================================================================
--- uspace/drv/block/ahci/ahci.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/block/ahci/ahci.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1140,5 +1140,5 @@
 	
 	/* Connect to parent device */
-	ahci->parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
+	ahci->parent_sess = ddf_dev_parent_sess_create(dev);
 	if (ahci->parent_sess == NULL)
 		return NULL;
Index: uspace/drv/block/ata_bd/main.c
===================================================================
--- uspace/drv/block/ata_bd/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/block/ata_bd/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -68,6 +68,5 @@
 	int rc;
 
-	parent_sess = ddf_dev_parent_sess_create(dev,
-	    EXCHANGE_SERIALIZE);
+	parent_sess = ddf_dev_parent_sess_create(dev);
 	if (parent_sess == NULL)
 		return ENOMEM;
Index: uspace/drv/block/ddisk/ddisk.c
===================================================================
--- uspace/drv/block/ddisk/ddisk.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/block/ddisk/ddisk.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -286,5 +286,5 @@
 	int rc;
 
-	parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
+	parent_sess = ddf_dev_parent_sess_create(dev);
 	if (parent_sess == NULL)
 		return ENOMEM;
Index: uspace/drv/bus/amba/amba.c
===================================================================
--- uspace/drv/bus/amba/amba.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/bus/amba/amba.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -333,5 +333,5 @@
 	
 	bus->dnode = dnode;
-	async_sess_t *sess = ddf_dev_parent_sess_create(dnode, EXCHANGE_SERIALIZE);
+	async_sess_t *sess = ddf_dev_parent_sess_create(dnode);
 	if (sess == NULL) {
 		ddf_msg(LVL_ERROR, "amba_dev_add failed to connect to the "
Index: uspace/drv/bus/isa/isa.c
===================================================================
--- uspace/drv/bus/isa/isa.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/bus/isa/isa.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -270,5 +270,5 @@
 	}
 
-	r = read_all(fd, buf, len);
+	r = read(fd, buf, len);
 	if (r < 0) {
 		ddf_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path);
@@ -616,5 +616,5 @@
 	list_initialize(&isa->functions);
 
-	sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
+	sess = ddf_dev_parent_sess_create(dev);
 	if (sess == NULL) {
 		ddf_msg(LVL_ERROR, "isa_dev_add failed to connect to the "
Index: uspace/drv/bus/pci/pciintel/pci.c
===================================================================
--- uspace/drv/bus/pci/pciintel/pci.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/bus/pci/pciintel/pci.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -664,5 +664,5 @@
 	bus->dnode = dnode;
 	
-	sess = ddf_dev_parent_sess_create(dnode, EXCHANGE_SERIALIZE);
+	sess = ddf_dev_parent_sess_create(dnode);
 	if (sess == NULL) {
 		ddf_msg(LVL_ERROR, "pci_dev_add failed to connect to the "
Index: uspace/drv/bus/usb/ehci/res.c
===================================================================
--- uspace/drv/bus/usb/ehci/res.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/bus/usb/ehci/res.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -81,5 +81,5 @@
 	
 	async_sess_t *parent_sess = devman_parent_device_connect(
-	    EXCHANGE_SERIALIZE, ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
+	    ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
 	if (!parent_sess)
 		return ENOMEM;
@@ -115,5 +115,5 @@
 {
 	async_sess_t *parent_sess = devman_parent_device_connect(
-	    EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
+	    ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
 	if (!parent_sess)
 		return ENOMEM;
@@ -138,5 +138,5 @@
 
 	async_sess_t *parent_sess = devman_parent_device_connect(
-	    EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
+	    ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
 	if (!parent_sess)
 		return ENOMEM;
Index: uspace/drv/bus/usb/ohci/res.c
===================================================================
--- uspace/drv/bus/usb/ohci/res.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/bus/usb/ohci/res.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -57,6 +57,6 @@
 
 	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE,
-	    ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
+	    devman_parent_device_connect(ddf_dev_get_handle(dev),
+	    IPC_FLAG_BLOCKING);
 	if (!parent_sess)
 		return ENOMEM;
@@ -93,6 +93,6 @@
 {
 	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE,
-	    ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
+	    devman_parent_device_connect(ddf_dev_get_handle(device),
+	    IPC_FLAG_BLOCKING);
 	if (!parent_sess)
 		return ENOMEM;
Index: uspace/drv/bus/usb/uhci/res.c
===================================================================
--- uspace/drv/bus/usb/uhci/res.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/bus/usb/uhci/res.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -55,6 +55,6 @@
 
 	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE,
-	    ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
+	    devman_parent_device_connect(ddf_dev_get_handle(dev),
+	    IPC_FLAG_BLOCKING);
 	if (!parent_sess)
 		return ENOMEM;
@@ -91,6 +91,6 @@
 {
 	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE,
-	    ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
+	    devman_parent_device_connect(ddf_dev_get_handle(device),
+	    IPC_FLAG_BLOCKING);
 	if (!parent_sess)
 		return ENOMEM;
@@ -112,5 +112,5 @@
 
 	async_sess_t *parent_sess = devman_parent_device_connect(
-	    EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
+	    ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
 	if (!parent_sess)
 		return ENOMEM;
Index: uspace/drv/bus/usb/uhcirh/main.c
===================================================================
--- uspace/drv/bus/usb/uhcirh/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/bus/usb/uhcirh/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -131,6 +131,6 @@
 {
 	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE,
-	    ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
+	    devman_parent_device_connect(ddf_dev_get_handle(dev),
+	    IPC_FLAG_BLOCKING);
 	if (!parent_sess)
 		return ENOMEM;
Index: uspace/drv/char/grlib_uart/grlib_uart.c
===================================================================
--- uspace/drv/char/grlib_uart/grlib_uart.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/char/grlib_uart/grlib_uart.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -381,6 +381,5 @@
 	
 	/* Connect to the parent's driver. */
-	async_sess_t *parent_sess = ddf_dev_parent_sess_create(ns->dev,
-	    EXCHANGE_SERIALIZE);
+	async_sess_t *parent_sess = ddf_dev_parent_sess_create(ns->dev);
 	if (parent_sess == NULL) {
 		ddf_msg(LVL_ERROR, "Failed to connect to parent driver of "
Index: uspace/drv/char/i8042/main.c
===================================================================
--- uspace/drv/char/i8042/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/char/i8042/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -61,6 +61,5 @@
 	assert(dev);
 	
-	async_sess_t *parent_sess = ddf_dev_parent_sess_create(
-	    dev, EXCHANGE_SERIALIZE);
+	async_sess_t *parent_sess = ddf_dev_parent_sess_create(dev);
 	if (parent_sess == NULL)
 		return ENOMEM;
Index: uspace/drv/char/ns8250/ns8250.c
===================================================================
--- uspace/drv/char/ns8250/ns8250.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/char/ns8250/ns8250.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -391,5 +391,5 @@
 	
 	/* Connect to the parent's driver. */
-	parent_sess = ddf_dev_parent_sess_create(ns->dev, EXCHANGE_SERIALIZE);
+	parent_sess = ddf_dev_parent_sess_create(ns->dev);
 	if (parent_sess == NULL) {
 		ddf_msg(LVL_ERROR, "Failed to connect to parent driver of "
Index: uspace/drv/char/pl050/pl050.c
===================================================================
--- uspace/drv/char/pl050/pl050.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/char/pl050/pl050.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -167,6 +167,5 @@
 	pl050->buf_rp = pl050->buf_wp = 0;
 
-	pl050->parent_sess = ddf_dev_parent_sess_create(pl050->dev,
-	    EXCHANGE_SERIALIZE);
+	pl050->parent_sess = ddf_dev_parent_sess_create(pl050->dev);
 	if (pl050->parent_sess == NULL) {
 		ddf_msg(LVL_ERROR, "Failed connecitng parent driver.");
Index: uspace/drv/char/ps2mouse/ps2mouse.c
===================================================================
--- uspace/drv/char/ps2mouse/ps2mouse.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/char/ps2mouse/ps2mouse.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -116,5 +116,5 @@
 {
 	mouse->client_sess = NULL;
-	mouse->parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
+	mouse->parent_sess = ddf_dev_parent_sess_create(dev);
 	if (!mouse->parent_sess)
 		return ENOMEM;
Index: uspace/drv/char/xtkbd/xtkbd.c
===================================================================
--- uspace/drv/char/xtkbd/xtkbd.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/char/xtkbd/xtkbd.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -417,5 +417,5 @@
 	
 	kbd->client_sess = NULL;
-	kbd->parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
+	kbd->parent_sess = ddf_dev_parent_sess_create(dev);
 	
 	if (!kbd->parent_sess) {
Index: uspace/drv/test/test1/test1.c
===================================================================
--- uspace/drv/test/test1/test1.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/test/test1/test1.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -186,5 +186,5 @@
 		(void) register_fun_verbose(dev,
 		    "cloning myself twice ;-)", "clone",
-		    "virtual&test1", 10, EEXISTS, NULL);
+		    "virtual&test1", 10, EEXIST, NULL);
 	} else if (str_cmp(dev_name, "clone") == 0) {
 		(void) register_fun_verbose(dev,
Index: uspace/drv/time/cmos-rtc/cmos-rtc.c
===================================================================
--- uspace/drv/time/cmos-rtc/cmos-rtc.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/drv/time/cmos-rtc/cmos-rtc.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -213,5 +213,5 @@
 	/* Connect to the parent's driver */
 
-	parent_sess = ddf_dev_parent_sess_create(rtc->dev, EXCHANGE_SERIALIZE);
+	parent_sess = ddf_dev_parent_sess_create(rtc->dev);
 	if (!parent_sess) {
 		ddf_msg(LVL_ERROR, "Failed to connect to parent driver\
Index: uspace/lib/bithenge/src/file.c
===================================================================
--- uspace/lib/bithenge/src/file.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/bithenge/src/file.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -114,5 +114,5 @@
 	struct stat stat;
 	int rc = fstat(fd, &stat);
-	if (rc != EOK) {
+	if (rc != 0) {
 		if (needs_close)
 			close(fd);
@@ -157,5 +157,5 @@
 	int fd = open(filename, O_RDONLY);
 	if (fd < 0)
-		return fd;
+		return errno;
 
 	return new_file_blob(out, fd, true);
Index: uspace/lib/bithenge/src/helenos/block.c
===================================================================
--- uspace/lib/bithenge/src/helenos/block.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/bithenge/src/helenos/block.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -102,5 +102,5 @@
 	// Initialize libblock
 	int rc;
-	rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048);
+	rc = block_init(service_id, 2048);
 	if (rc != EOK)
 		return rc;
Index: uspace/lib/block/block.c
===================================================================
--- uspace/lib/block/block.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/block/block.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -144,10 +144,9 @@
 }
 
-int block_init(exch_mgmt_t mgmt, service_id_t service_id,
-    size_t comm_size)
+int block_init(service_id_t service_id, size_t comm_size)
 {
 	bd_t *bd;
 
-	async_sess_t *sess = loc_service_connect(mgmt, service_id,
+	async_sess_t *sess = loc_service_connect(service_id, INTERFACE_BLOCK,
 	    IPC_FLAG_BLOCKING);
 	if (!sess) {
Index: uspace/lib/block/block.h
===================================================================
--- uspace/lib/block/block.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/block/block.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -99,5 +99,5 @@
 };
 
-extern int block_init(exch_mgmt_t, service_id_t, size_t);
+extern int block_init(service_id_t, size_t);
 extern void block_fini(service_id_t);
 
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/Makefile	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -67,5 +67,4 @@
 	generic/bd_srv.c \
 	generic/cap.c \
-	generic/cfg.c \
 	generic/clipboard.c \
 	generic/corecfg.c \
Index: uspace/lib/c/arch/abs32le/include/libarch/stddef.h
===================================================================
--- uspace/lib/c/arch/abs32le/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/abs32le/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcabs32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_abs32_STDDEF_H_
+#define LIBC_abs32_STDDEF_H_
+
+#include <libarch/common.h>
+
+typedef uint32_t size_t;
+typedef int32_t ptrdiff_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/abs32le/include/libarch/stdint.h
===================================================================
--- uspace/lib/c/arch/abs32le/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/abs32le/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcabs32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_abs32_STDINT_H_
+#define LIBC_abs32_STDINT_H_
+
+#include <libarch/common.h>
+
+#define SIZE_MAX UINT32_MAX
+
+#define UINTPTR_MAX UINT32_MAX
+typedef uint32_t uintptr_t;
+
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+typedef int32_t intptr_t;
+
+#define UINTMAX_MAX UINT64_MAX
+typedef uint64_t uintmax_t;
+
+#define INTMAX_MAX INT64_MAX
+typedef int64_t intmax_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/abs32le/include/libarch/types.h
===================================================================
--- uspace/lib/c/arch/abs32le/include/libarch/types.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/arch/abs32le/include/libarch/types.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,10 +36,9 @@
 #define LIBC_abs32le_TYPES_H_
 
+#include <libarch/common.h>
+#include <libarch/stddef.h>
+#include <libarch/stdint.h>
+
 #define __32_BITS__
-
-#include <libarch/common.h>
-
-#define SIZE_MIN  UINT32_MIN
-#define SIZE_MAX  UINT32_MAX
 
 #define SSIZE_MIN  INT32_MIN
@@ -50,8 +49,5 @@
 
 typedef int32_t ssize_t;
-typedef uint32_t size_t;
 
-typedef uint32_t uintptr_t;
-typedef int32_t intptr_t;
 typedef uint32_t atomic_count_t;
 typedef int32_t atomic_signed_t;
Index: uspace/lib/c/arch/amd64/include/libarch/stddef.h
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/amd64/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcamd64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_amd64_STDDEF_H_
+#define LIBC_amd64_STDDEF_H_
+
+#include <libarch/common.h>
+
+typedef uint64_t size_t;
+typedef int64_t ptrdiff_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/amd64/include/libarch/stdint.h
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/amd64/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcamd64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_amd64_STDINT_H_
+#define LIBC_amd64_STDINT_H_
+
+#include <libarch/common.h>
+
+#define SIZE_MIN  UINT64_MIN
+#define SIZE_MAX  UINT64_MAX
+
+#define UINTPTR_MAX UINT64_MAX
+typedef uint64_t uintptr_t;
+
+#define INTPTR_MIN INT64_MIN
+#define INTPTR_MAX INT64_MAX
+typedef int64_t intptr_t;
+
+#define UINTMAX_MAX UINT64_MAX
+typedef uint64_t uintmax_t;
+
+#define INTMAX_MAX INT64_MAX
+typedef int64_t intmax_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/amd64/include/libarch/types.h
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/types.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/arch/amd64/include/libarch/types.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,10 +36,9 @@
 #define LIBC_amd64_TYPES_H_
 
+#include <libarch/common.h>
+#include <libarch/stddef.h>
+#include <libarch/stdint.h>
+
 #define __64_BITS__
-
-#include <libarch/common.h>
-
-#define SIZE_MIN  UINT64_MIN
-#define SIZE_MAX  UINT64_MAX
 
 #define SSIZE_MIN  INT64_MIN
@@ -50,8 +49,5 @@
 
 typedef int64_t ssize_t;
-typedef uint64_t size_t;
 
-typedef uint64_t uintptr_t;
-typedef int64_t intptr_t;
 typedef uint64_t atomic_count_t;
 typedef int64_t atomic_signed_t;
Index: uspace/lib/c/arch/arm32/include/libarch/stddef.h
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/arm32/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcarm32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_arm32_STDDEF_H_
+#define LIBC_arm32_STDDEF_H_
+
+#include <libarch/common.h>
+
+typedef uint32_t size_t;
+typedef int32_t ptrdiff_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/arm32/include/libarch/stdint.h
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/arm32/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcarm32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_arm32_STDINT_H_
+#define LIBC_arm32_STDINT_H_
+
+#include <libarch/common.h>
+
+#define SIZE_MIN  UINT32_MIN
+#define SIZE_MAX  UINT32_MAX
+
+#define UINTPTR_MAX UINT32_MAX
+typedef uint32_t uintptr_t;
+
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+typedef int32_t intptr_t;
+
+#define UINTMAX_MAX UINT64_MAX
+typedef uint64_t uintmax_t;
+
+#define INTMAX_MAX INT64_MAX
+typedef int64_t intmax_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/arm32/include/libarch/types.h
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/types.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/arch/arm32/include/libarch/types.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -37,10 +37,9 @@
 #define LIBC_arm32_TYPES_H_
 
+#include <libarch/common.h>
+#include <libarch/stddef.h>
+#include <libarch/stdint.h>
+
 #define __32_BITS__
-
-#include <libarch/common.h>
-
-#define SIZE_MIN  UINT32_MIN
-#define SIZE_MAX  UINT32_MAX
 
 #define SSIZE_MIN  INT32_MIN
@@ -51,8 +50,5 @@
 
 typedef int32_t ssize_t;
-typedef uint32_t size_t;
 
-typedef uint32_t uintptr_t;
-typedef int32_t intptr_t;
 typedef uint32_t atomic_count_t;
 typedef int32_t atomic_signed_t;
Index: uspace/lib/c/arch/ia32/include/libarch/stddef.h
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/ia32/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcia32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_ia32_STDDEF_H_
+#define LIBC_ia32_STDDEF_H_
+
+#include <libarch/common.h>
+
+typedef uint32_t size_t;
+typedef int32_t ptrdiff_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/ia32/include/libarch/stdint.h
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/ia32/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcia32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_ia32_STDINT_H_
+#define LIBC_ia32_STDINT_H_
+
+#include <libarch/common.h>
+
+#define SIZE_MIN  UINT32_MIN
+#define SIZE_MAX  UINT32_MAX
+
+#define UINTPTR_MAX UINT32_MAX
+typedef uint32_t uintptr_t;
+
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+typedef int32_t intptr_t;
+
+#define UINTMAX_MAX UINT64_MAX
+typedef uint64_t uintmax_t;
+
+#define INTMAX_MAX INT64_MAX
+typedef int64_t intmax_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/ia32/include/libarch/types.h
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/types.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/arch/ia32/include/libarch/types.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,10 +36,9 @@
 #define LIBC_ia32_TYPES_H_
 
+#include <libarch/common.h>
+#include <libarch/stddef.h>
+#include <libarch/stdint.h>
+
 #define __32_BITS__
-
-#include <libarch/common.h>
-
-#define SIZE_MIN  UINT32_MIN
-#define SIZE_MAX  UINT32_MAX
 
 #define SSIZE_MIN  INT32_MIN
@@ -52,6 +51,4 @@
 typedef uint32_t size_t;
 
-typedef uint32_t uintptr_t;
-typedef int32_t intptr_t;
 typedef uint32_t atomic_count_t;
 typedef int32_t atomic_signed_t;
Index: uspace/lib/c/arch/ia64/include/libarch/stddef.h
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/ia64/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcia64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_ia64_STDDEF_H_
+#define LIBC_ia64_STDDEF_H_
+
+#include <libarch/common.h>
+
+typedef uint64_t size_t;
+typedef int64_t ptrdiff_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/ia64/include/libarch/stdint.h
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/ia64/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcia64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_ia64_STDINT_H_
+#define LIBC_ia64_STDINT_H_
+
+#include <libarch/common.h>
+
+#define SIZE_MIN  UINT64_MIN
+#define SIZE_MAX  UINT64_MAX
+
+#define UINTPTR_MAX UINT64_MAX
+typedef uint64_t uintptr_t;
+
+#define INTPTR_MIN INT64_MIN
+#define INTPTR_MAX INT64_MAX
+typedef int64_t intptr_t;
+
+#define UINTMAX_MAX UINT64_MAX
+typedef uint64_t uintmax_t;
+
+#define INTMAX_MAX INT64_MAX
+typedef int64_t intmax_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/ia64/include/libarch/types.h
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/types.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/arch/ia64/include/libarch/types.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,10 +36,9 @@
 #define LIBC_ia64_TYPES_H_
 
+#include <libarch/common.h>
+#include <libarch/stddef.h>
+#include <libarch/stdint.h>
+
 #define __64_BITS__
-
-#include <libarch/common.h>
-
-#define SIZE_MIN  UINT64_MIN
-#define SIZE_MAX  UINT64_MAX
 
 #define SSIZE_MIN  INT64_MIN
@@ -50,8 +49,5 @@
 
 typedef int64_t ssize_t;
-typedef uint64_t size_t;
 
-typedef uint64_t uintptr_t;
-typedef int64_t intptr_t;
 typedef uint64_t atomic_count_t;
 typedef int64_t atomic_signed_t;
Index: uspace/lib/c/arch/mips32/include/libarch/stddef.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/mips32/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcmips32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_mips32_STDDEF_H_
+#define LIBC_mips32_STDDEF_H_
+
+#include <libarch/common.h>
+
+typedef uint32_t size_t;
+typedef int32_t ptrdiff_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/mips32/include/libarch/stdint.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/mips32/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcmips32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_mips32_STDINT_H_
+#define LIBC_mips32_STDINT_H_
+
+#include <libarch/common.h>
+
+#define SIZE_MIN  UINT32_MIN
+#define SIZE_MAX  UINT32_MAX
+
+#define UINTPTR_MAX UINT32_MAX
+typedef uint32_t uintptr_t;
+
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+typedef int32_t intptr_t;
+
+#define UINTMAX_MAX UINT64_MAX
+typedef uint64_t uintmax_t;
+
+#define INTMAX_MAX INT64_MAX
+typedef int64_t intmax_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/mips32/include/libarch/types.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/types.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/arch/mips32/include/libarch/types.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -37,10 +37,9 @@
 #define LIBC_mips32_TYPES_H_
 
+#include <libarch/common.h>
+#include <libarch/stddef.h>
+#include <libarch/stdint.h>
+
 #define __32_BITS__
-
-#include <libarch/common.h>
-
-#define SIZE_MIN  UINT32_MIN
-#define SIZE_MAX  UINT32_MAX
 
 #define SSIZE_MIN  INT32_MIN
@@ -51,8 +50,5 @@
 
 typedef int32_t ssize_t;
-typedef uint32_t size_t;
 
-typedef uint32_t uintptr_t;
-typedef int32_t intptr_t;
 typedef uint32_t atomic_count_t;
 typedef int32_t atomic_signed_t;
Index: uspace/lib/c/arch/mips32eb/include/libarch/stddef.h
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/mips32eb/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,1 @@
+../../../mips32/include/libarch/stddef.h
Index: uspace/lib/c/arch/mips32eb/include/libarch/stdint.h
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/mips32eb/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,1 @@
+../../../mips32/include/libarch/stdint.h
Index: uspace/lib/c/arch/ppc32/include/libarch/stddef.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/ppc32/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcppc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_ppc32_STDDEF_H_
+#define LIBC_ppc32_STDDEF_H_
+
+#include <libarch/common.h>
+
+typedef uint32_t size_t;
+typedef int32_t ptrdiff_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/ppc32/include/libarch/stdint.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/ppc32/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcppc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_ppc32_STDINT_H_
+#define LIBC_ppc32_STDINT_H_
+
+#include <libarch/common.h>
+
+#define SIZE_MIN  UINT32_MIN
+#define SIZE_MAX  UINT32_MAX
+
+#define UINTPTR_MAX UINT32_MAX
+typedef uint32_t uintptr_t;
+
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+typedef int32_t intptr_t;
+
+#define UINTMAX_MAX UINT64_MAX
+typedef uint64_t uintmax_t;
+
+#define INTMAX_MAX INT64_MAX
+typedef int64_t intmax_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/ppc32/include/libarch/types.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/types.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/arch/ppc32/include/libarch/types.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,10 +36,9 @@
 #define LIBC_ppc32_TYPES_H_
 
+#include <libarch/common.h>
+#include <libarch/stddef.h>
+#include <libarch/stdint.h>
+
 #define __32_BITS__
-
-#include <libarch/common.h>
-
-#define SIZE_MIN  UINT32_MIN
-#define SIZE_MAX  UINT32_MAX
 
 #define SSIZE_MIN  INT32_MIN
@@ -50,8 +49,5 @@
 
 typedef int32_t ssize_t;
-typedef uint32_t size_t;
 
-typedef uint32_t uintptr_t;
-typedef int32_t intptr_t;
 typedef uint32_t atomic_count_t;
 typedef int32_t atomic_signed_t;
Index: uspace/lib/c/arch/sparc32/include/libarch/stddef.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/sparc32/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcsparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc32_STDDEF_H_
+#define LIBC_sparc32_STDDEF_H_
+
+#include <libarch/common.h>
+
+typedef uint32_t size_t;
+typedef int32_t ptrdiff_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/stdint.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/sparc32/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcsparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc32_STDINT_H_
+#define LIBC_sparc32_STDINT_H_
+
+#include <libarch/common.h>
+
+#define SIZE_MIN  UINT32_MIN
+#define SIZE_MAX  UINT32_MAX
+
+#define UINTPTR_MAX UINT32_MAX
+typedef uint32_t uintptr_t;
+
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+typedef int32_t intptr_t;
+
+#define UINTMAX_MAX UINT64_MAX
+typedef uint64_t uintmax_t;
+
+#define INTMAX_MAX INT64_MAX
+typedef int64_t intmax_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/types.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/types.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/arch/sparc32/include/libarch/types.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,10 +36,9 @@
 #define LIBC_sparc32_TYPES_H_
 
+#include <libarch/common.h>
+#include <libarch/stddef.h>
+#include <libarch/stdint.h>
+
 #define __32_BITS__
-
-#include <libarch/common.h>
-
-#define SIZE_MIN  UINT32_MIN
-#define SIZE_MAX  UINT32_MAX
 
 #define SSIZE_MIN  INT32_MIN
@@ -50,8 +49,5 @@
 
 typedef int32_t ssize_t;
-typedef uint32_t size_t;
 
-typedef uint32_t uintptr_t;
-typedef int32_t intptr_t;
 typedef uint32_t atomic_count_t;
 typedef int32_t atomic_signed_t;
Index: uspace/lib/c/arch/sparc64/include/libarch/stddef.h
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/sparc64/include/libarch/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcsparc64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc64_STDDEF_H_
+#define LIBC_sparc64_STDDEF_H_
+
+#include <libarch/common.h>
+
+typedef uint64_t size_t;
+typedef int64_t ptrdiff_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc64/include/libarch/stdint.h
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/arch/sparc64/include/libarch/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcsparc64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc64_STDINT_H_
+#define LIBC_sparc64_STDINT_H_
+
+#include <libarch/common.h>
+
+#define SIZE_MIN  UINT64_MIN
+#define SIZE_MAX  UINT64_MAX
+
+#define UINTPTR_MAX UINT64_MAX
+typedef uint64_t uintptr_t;
+
+#define INTPTR_MIN INT64_MIN
+#define INTPTR_MAX INT64_MAX
+typedef int64_t intptr_t;
+
+#define UINTMAX_MAX UINT64_MAX
+typedef uint64_t uintmax_t;
+
+#define INTMAX_MAX INT64_MAX
+typedef int64_t intmax_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc64/include/libarch/types.h
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/types.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/arch/sparc64/include/libarch/types.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,10 +36,9 @@
 #define LIBC_sparc64_TYPES_H_
 
+#include <libarch/common.h>
+#include <libarch/stddef.h>
+#include <libarch/stdint.h>
+
 #define __64_BITS__
-
-#include <libarch/common.h>
-
-#define SIZE_MIN  UINT64_MIN
-#define SIZE_MAX  UINT64_MAX
 
 #define SSIZE_MIN  INT64_MIN
@@ -50,8 +49,5 @@
 
 typedef int64_t ssize_t;
-typedef uint64_t size_t;
 
-typedef uint64_t uintptr_t;
-typedef int64_t intptr_t;
 typedef uint64_t atomic_count_t;
 typedef int64_t atomic_signed_t;
Index: uspace/lib/c/generic/adt/list.c
===================================================================
--- uspace/lib/c/generic/adt/list.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/adt/list.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -53,5 +53,5 @@
  *
  */
-int list_member(const link_t *link, const list_t *list)
+bool list_member(const link_t *link, const list_t *list)
 {
 	bool found = false;
@@ -98,7 +98,7 @@
  * @return		Number of items in the list.
  */
-unsigned int list_count(const list_t *list)
+unsigned long list_count(const list_t *list)
 {
-	unsigned int count = 0;
+	unsigned long count = 0;
 	
 	link_t *link = list_first(list);
Index: uspace/lib/c/generic/async.c
===================================================================
--- uspace/lib/c/generic/async.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/async.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -77,5 +77,5 @@
  *   }
  *
- *   my_client_connection(icallid, *icall)
+ *   port_handler(icallid, *icall)
  *   {
  *     if (want_refuse) {
@@ -123,4 +123,7 @@
 	list_t exch_list;
 	
+	/** Session interface */
+	iface_t iface;
+	
 	/** Exchange management style */
 	exch_mgmt_t mgmt;
@@ -189,8 +192,8 @@
 	/** If reply was received. */
 	bool done;
-
+	
 	/** If the message / reply should be discarded on arrival. */
 	bool forget;
-
+	
 	/** If already destroyed. */
 	bool destroyed;
@@ -232,8 +235,7 @@
 	/** Identification of the opening call. */
 	ipc_callid_t callid;
+	
 	/** Call data of the opening call. */
 	ipc_call_t call;
-	/** Local argument or NULL if none. */
-	void *carg;
 	
 	/** Identification of the closing call. */
@@ -241,6 +243,40 @@
 	
 	/** Fibril function that will be used to handle the connection. */
-	async_client_conn_t cfibril;
+	async_port_handler_t handler;
+	
+	/** Client data */
+	void *data;
 } connection_t;
+
+/** Interface data */
+typedef struct {
+	ht_link_t link;
+	
+	/** Interface ID */
+	iface_t iface;
+	
+	/** Futex protecting the hash table */
+	futex_t futex;
+	
+	/** Interface ports */
+	hash_table_t port_hash_table;
+	
+	/** Next available port ID */
+	port_id_t port_id_avail;
+} interface_t;
+
+/* Port data */
+typedef struct {
+	ht_link_t link;
+	
+	/** Port ID */
+	port_id_t id;
+	
+	/** Port connection handler */
+	async_port_handler_t handler;
+	
+	/** Client data */
+	void *data;
+} port_t;
 
 /* Notification data */
@@ -264,5 +300,5 @@
 {
 	struct timeval tv = { 0, 0 };
-
+	
 	to->inlist = false;
 	to->occurred = false;
@@ -287,7 +323,5 @@
 static amsg_t *amsg_create(void)
 {
-	amsg_t *msg;
-
-	msg = malloc(sizeof(amsg_t));
+	amsg_t *msg = malloc(sizeof(amsg_t));
 	if (msg) {
 		msg->done = false;
@@ -298,5 +332,5 @@
 		awaiter_initialize(&msg->wdata);
 	}
-
+	
 	return msg;
 }
@@ -335,7 +369,8 @@
 }
 
-/** Default fibril function that gets called to handle new connection.
- *
- * This function is defined as a weak symbol - to be redefined in user code.
+/** Default fallback fibril function.
+ *
+ * This fallback fibril function gets called on incomming
+ * connections that do not have a specific handler defined.
  *
  * @param callid Hash of the incoming call.
@@ -344,5 +379,5 @@
  *
  */
-static void default_client_connection(ipc_callid_t callid, ipc_call_t *call,
+static void default_fallback_port_handler(ipc_callid_t callid, ipc_call_t *call,
     void *arg)
 {
@@ -350,18 +385,114 @@
 }
 
-static async_client_conn_t client_connection = default_client_connection;
+static async_port_handler_t fallback_port_handler =
+    default_fallback_port_handler;
+static void *fallback_port_data = NULL;
+
+static hash_table_t interface_hash_table;
+
+static size_t interface_key_hash(void *key)
+{
+	iface_t iface = *(iface_t *) key;
+	return iface;
+}
+
+static size_t interface_hash(const ht_link_t *item)
+{
+	interface_t *interface = hash_table_get_inst(item, interface_t, link);
+	return interface_key_hash(&interface->iface);
+}
+
+static bool interface_key_equal(void *key, const ht_link_t *item)
+{
+	iface_t iface = *(iface_t *) key;
+	interface_t *interface = hash_table_get_inst(item, interface_t, link);
+	return iface == interface->iface;
+}
+
+/** Operations for the port hash table. */
+static hash_table_ops_t interface_hash_table_ops = {
+	.hash = interface_hash,
+	.key_hash = interface_key_hash,
+	.key_equal = interface_key_equal,
+	.equal = NULL,
+	.remove_callback = NULL
+};
+
+static size_t port_key_hash(void *key)
+{
+	port_id_t port_id = *(port_id_t *) key;
+	return port_id;
+}
+
+static size_t port_hash(const ht_link_t *item)
+{
+	port_t *port = hash_table_get_inst(item, port_t, link);
+	return port_key_hash(&port->id);
+}
+
+static bool port_key_equal(void *key, const ht_link_t *item)
+{
+	port_id_t port_id = *(port_id_t *) key;
+	port_t *port = hash_table_get_inst(item, port_t, link);
+	return port_id == port->id;
+}
+
+/** Operations for the port hash table. */
+static hash_table_ops_t port_hash_table_ops = {
+	.hash = port_hash,
+	.key_hash = port_key_hash,
+	.key_equal = port_key_equal,
+	.equal = NULL,
+	.remove_callback = NULL
+};
+
+static interface_t *async_new_interface(iface_t iface)
+{
+	interface_t *interface =
+	    (interface_t *) malloc(sizeof(interface_t));
+	if (!interface)
+		return NULL;
+	
+	bool ret = hash_table_create(&interface->port_hash_table, 0, 0,
+	    &port_hash_table_ops);
+	if (!ret) {
+		free(interface);
+		return NULL;
+	}
+	
+	interface->iface = iface;
+	futex_initialize(&interface->futex, 1);
+	interface->port_id_avail = 0;
+	
+	hash_table_insert(&interface_hash_table, &interface->link);
+	
+	return interface;
+}
+
+static port_t *async_new_port(interface_t *interface,
+    async_port_handler_t handler, void *data)
+{
+	port_t *port = (port_t *) malloc(sizeof(port_t));
+	if (!port)
+		return NULL;
+	
+	futex_down(&interface->futex);
+	
+	port_id_t id = interface->port_id_avail;
+	interface->port_id_avail++;
+	
+	port->id = id;
+	port->handler = handler;
+	port->data = data;
+	
+	hash_table_insert(&interface->port_hash_table, &port->link);
+	
+	futex_up(&interface->futex);
+	
+	return port;
+}
+
 static size_t notification_handler_stksz = FIBRIL_DFLT_STK_SIZE;
 
-/** Setter for client_connection function pointer.
- *
- * @param conn Function that will implement a new connection fibril.
- *
- */
-void async_set_client_connection(async_client_conn_t conn)
-{
-	assert(client_connection == default_client_connection);
-	client_connection = conn;
-}
-
 /** Set the stack size for the notification handler notification fibrils.
  *
@@ -387,4 +518,46 @@
  */
 static FIBRIL_CONDVAR_INITIALIZE(avail_phone_cv);
+
+int async_create_port(iface_t iface, async_port_handler_t handler,
+    void *data, port_id_t *port_id)
+{
+	if ((iface & IFACE_MOD_MASK) == IFACE_MOD_CALLBACK)
+		return EINVAL;
+	
+	interface_t *interface;
+	
+	futex_down(&async_futex);
+	
+	ht_link_t *link = hash_table_find(&interface_hash_table, &iface);
+	if (link)
+		interface = hash_table_get_inst(link, interface_t, link);
+	else
+		interface = async_new_interface(iface);
+	
+	if (!interface) {
+		futex_up(&async_futex);
+		return ENOMEM;
+	}
+	
+	port_t *port = async_new_port(interface, handler, data);
+	if (!port) {
+		futex_up(&async_futex);
+		return ENOMEM;
+	}
+	
+	*port_id = port->id;
+	
+	futex_up(&async_futex);
+	
+	return EOK;
+}
+
+void async_set_fallback_port_handler(async_port_handler_t handler, void *data)
+{
+	assert(handler != NULL);
+	
+	fallback_port_handler = handler;
+	fallback_port_data = data;
+}
 
 static hash_table_t client_hash_table;
@@ -457,4 +630,258 @@
 	.remove_callback = NULL
 };
+
+static client_t *async_client_get(task_id_t client_id, bool create)
+{
+	client_t *client = NULL;
+	
+	futex_down(&async_futex);
+	ht_link_t *link = hash_table_find(&client_hash_table, &client_id);
+	if (link) {
+		client = hash_table_get_inst(link, client_t, link);
+		atomic_inc(&client->refcnt);
+	} else if (create) {
+		client = malloc(sizeof(client_t));
+		if (client) {
+			client->in_task_id = client_id;
+			client->data = async_client_data_create();
+			
+			atomic_set(&client->refcnt, 1);
+			hash_table_insert(&client_hash_table, &client->link);
+		}
+	}
+	
+	futex_up(&async_futex);
+	return client;
+}
+
+static void async_client_put(client_t *client)
+{
+	bool destroy;
+	
+	futex_down(&async_futex);
+	
+	if (atomic_predec(&client->refcnt) == 0) {
+		hash_table_remove(&client_hash_table, &client->in_task_id);
+		destroy = true;
+	} else
+		destroy = false;
+	
+	futex_up(&async_futex);
+	
+	if (destroy) {
+		if (client->data)
+			async_client_data_destroy(client->data);
+		
+		free(client);
+	}
+}
+
+/** Wrapper for client connection fibril.
+ *
+ * When a new connection arrives, a fibril with this implementing
+ * function is created.
+ *
+ * @param arg Connection structure pointer.
+ *
+ * @return Always zero.
+ *
+ */
+static int connection_fibril(void *arg)
+{
+	assert(arg);
+	
+	/*
+	 * Setup fibril-local connection pointer.
+	 */
+	fibril_connection = (connection_t *) arg;
+	
+	/*
+	 * Add our reference for the current connection in the client task
+	 * tracking structure. If this is the first reference, create and
+	 * hash in a new tracking structure.
+	 */
+	
+	client_t *client = async_client_get(fibril_connection->in_task_id, true);
+	if (!client) {
+		ipc_answer_0(fibril_connection->callid, ENOMEM);
+		return 0;
+	}
+	
+	fibril_connection->client = client;
+	
+	/*
+	 * Call the connection handler function.
+	 */
+	fibril_connection->handler(fibril_connection->callid,
+	    &fibril_connection->call, fibril_connection->data);
+	
+	/*
+	 * Remove the reference for this client task connection.
+	 */
+	async_client_put(client);
+	
+	/*
+	 * Remove myself from the connection hash table.
+	 */
+	futex_down(&async_futex);
+	hash_table_remove(&conn_hash_table, &fibril_connection->in_phone_hash);
+	futex_up(&async_futex);
+	
+	/*
+	 * Answer all remaining messages with EHANGUP.
+	 */
+	while (!list_empty(&fibril_connection->msg_queue)) {
+		msg_t *msg =
+		    list_get_instance(list_first(&fibril_connection->msg_queue),
+		    msg_t, link);
+		
+		list_remove(&msg->link);
+		ipc_answer_0(msg->callid, EHANGUP);
+		free(msg);
+	}
+	
+	/*
+	 * If the connection was hung-up, answer the last call,
+	 * i.e. IPC_M_PHONE_HUNGUP.
+	 */
+	if (fibril_connection->close_callid)
+		ipc_answer_0(fibril_connection->close_callid, EOK);
+	
+	free(fibril_connection);
+	return 0;
+}
+
+/** Create a new fibril for a new connection.
+ *
+ * Create new fibril for connection, fill in connection structures
+ * and insert it into the hash table, so that later we can easily
+ * do routing of messages to particular fibrils.
+ *
+ * @param in_task_id    Identification of the incoming connection.
+ * @param in_phone_hash Identification of the incoming connection.
+ * @param callid        Hash of the opening IPC_M_CONNECT_ME_TO call.
+ *                      If callid is zero, the connection was opened by
+ *                      accepting the IPC_M_CONNECT_TO_ME call and this
+ *                      function is called directly by the server.
+ * @param call          Call data of the opening call.
+ * @param handler       Connection handler.
+ * @param data          Client argument to pass to the connection handler.
+ *
+ * @return New fibril id or NULL on failure.
+ *
+ */
+static fid_t async_new_connection(task_id_t in_task_id, sysarg_t in_phone_hash,
+    ipc_callid_t callid, ipc_call_t *call, async_port_handler_t handler,
+    void *data)
+{
+	connection_t *conn = malloc(sizeof(*conn));
+	if (!conn) {
+		if (callid)
+			ipc_answer_0(callid, ENOMEM);
+		
+		return (uintptr_t) NULL;
+	}
+	
+	conn->in_task_id = in_task_id;
+	conn->in_phone_hash = in_phone_hash;
+	list_initialize(&conn->msg_queue);
+	conn->callid = callid;
+	conn->close_callid = 0;
+	conn->handler = handler;
+	conn->data = data;
+	
+	if (call)
+		conn->call = *call;
+	
+	/* We will activate the fibril ASAP */
+	conn->wdata.active = true;
+	conn->wdata.fid = fibril_create(connection_fibril, conn);
+	
+	if (conn->wdata.fid == 0) {
+		free(conn);
+		
+		if (callid)
+			ipc_answer_0(callid, ENOMEM);
+		
+		return (uintptr_t) NULL;
+	}
+	
+	/* Add connection to the connection hash table */
+	
+	futex_down(&async_futex);
+	hash_table_insert(&conn_hash_table, &conn->link);
+	futex_up(&async_futex);
+	
+	fibril_add_ready(conn->wdata.fid);
+	
+	return conn->wdata.fid;
+}
+
+/** Wrapper for making IPC_M_CONNECT_TO_ME calls using the async framework.
+ *
+ * Ask through phone for a new connection to some service.
+ *
+ * @param exch    Exchange for sending the message.
+ * @param iface   Callback interface.
+ * @param arg1    User defined argument.
+ * @param arg2    User defined argument.
+ * @param handler Callback handler.
+ * @param data    Handler data.
+ * @param port_id ID of the newly created port.
+ *
+ * @return Zero on success or a negative error code.
+ *
+ */
+int async_create_callback_port(async_exch_t *exch, iface_t iface, sysarg_t arg1,
+    sysarg_t arg2, async_port_handler_t handler, void *data, port_id_t *port_id)
+{
+	if ((iface & IFACE_MOD_CALLBACK) != IFACE_MOD_CALLBACK)
+		return EINVAL;
+	
+	if (exch == NULL)
+		return ENOENT;
+	
+	ipc_call_t answer;
+	aid_t req = async_send_3(exch, IPC_M_CONNECT_TO_ME, iface, arg1, arg2,
+	    &answer);
+	
+	sysarg_t ret;
+	async_wait_for(req, &ret);
+	if (ret != EOK)
+		return (int) ret;
+	
+	sysarg_t phone_hash = IPC_GET_ARG5(answer);
+	interface_t *interface;
+	
+	futex_down(&async_futex);
+	
+	ht_link_t *link = hash_table_find(&interface_hash_table, &iface);
+	if (link)
+		interface = hash_table_get_inst(link, interface_t, link);
+	else
+		interface = async_new_interface(iface);
+	
+	if (!interface) {
+		futex_up(&async_futex);
+		return ENOMEM;
+	}
+	
+	port_t *port = async_new_port(interface, handler, data);
+	if (!port) {
+		futex_up(&async_futex);
+		return ENOMEM;
+	}
+	
+	*port_id = port->id;
+	
+	futex_up(&async_futex);
+	
+	fid_t fid = async_new_connection(answer.in_task_id, phone_hash,
+	    0, NULL, handler, data);
+	if (fid == (uintptr_t) NULL)
+		return ENOMEM;
+	
+	return EOK;
+}
 
 static size_t notification_key_hash(void *key)
@@ -866,5 +1293,6 @@
 	}
 	
-	msg_t *msg = list_get_instance(list_first(&conn->msg_queue), msg_t, link);
+	msg_t *msg = list_get_instance(list_first(&conn->msg_queue),
+	    msg_t, link);
 	list_remove(&msg->link);
 	
@@ -877,50 +1305,4 @@
 }
 
-static client_t *async_client_get(task_id_t client_id, bool create)
-{
-	client_t *client = NULL;
-
-	futex_down(&async_futex);
-	ht_link_t *link = hash_table_find(&client_hash_table, &client_id);
-	if (link) {
-		client = hash_table_get_inst(link, client_t, link);
-		atomic_inc(&client->refcnt);
-	} else if (create) {
-		client = malloc(sizeof(client_t));
-		if (client) {
-			client->in_task_id = client_id;
-			client->data = async_client_data_create();
-		
-			atomic_set(&client->refcnt, 1);
-			hash_table_insert(&client_hash_table, &client->link);
-		}
-	}
-
-	futex_up(&async_futex);
-	return client;
-}
-
-static void async_client_put(client_t *client)
-{
-	bool destroy;
-
-	futex_down(&async_futex);
-	
-	if (atomic_predec(&client->refcnt) == 0) {
-		hash_table_remove(&client_hash_table, &client->in_task_id);
-		destroy = true;
-	} else
-		destroy = false;
-	
-	futex_up(&async_futex);
-	
-	if (destroy) {
-		if (client->data)
-			async_client_data_destroy(client->data);
-		
-		free(client);
-	}
-}
-
 void *async_get_client_data(void)
 {
@@ -934,9 +1316,10 @@
 	if (!client)
 		return NULL;
+	
 	if (!client->data) {
 		async_client_put(client);
 		return NULL;
 	}
-
+	
 	return client->data;
 }
@@ -945,155 +1328,34 @@
 {
 	client_t *client = async_client_get(client_id, false);
-
+	
 	assert(client);
 	assert(client->data);
-
+	
 	/* Drop the reference we got in async_get_client_data_by_hash(). */
 	async_client_put(client);
-
+	
 	/* Drop our own reference we got at the beginning of this function. */
 	async_client_put(client);
 }
 
-/** Wrapper for client connection fibril.
- *
- * When a new connection arrives, a fibril with this implementing function is
- * created. It calls client_connection() and does the final cleanup.
- *
- * @param arg Connection structure pointer.
- *
- * @return Always zero.
- *
- */
-static int connection_fibril(void *arg)
-{
-	assert(arg);
-	
-	/*
-	 * Setup fibril-local connection pointer.
-	 */
-	fibril_connection = (connection_t *) arg;
-	
-	/*
-	 * Add our reference for the current connection in the client task
-	 * tracking structure. If this is the first reference, create and
-	 * hash in a new tracking structure.
-	 */
-
-	client_t *client = async_client_get(fibril_connection->in_task_id, true);
-	if (!client) {
-		ipc_answer_0(fibril_connection->callid, ENOMEM);
-		return 0;
-	}
-
-	fibril_connection->client = client;
-	
-	/*
-	 * Call the connection handler function.
-	 */
-	fibril_connection->cfibril(fibril_connection->callid,
-	    &fibril_connection->call, fibril_connection->carg);
-	
-	/*
-	 * Remove the reference for this client task connection.
-	 */
-	async_client_put(client);
-	
-	/*
-	 * Remove myself from the connection hash table.
-	 */
+static port_t *async_find_port(iface_t iface, port_id_t port_id)
+{
+	port_t *port = NULL;
+	
 	futex_down(&async_futex);
-	hash_table_remove(&conn_hash_table, &fibril_connection->in_phone_hash);
+	
+	ht_link_t *link = hash_table_find(&interface_hash_table, &iface);
+	if (link) {
+		interface_t *interface =
+		    hash_table_get_inst(link, interface_t, link);
+		
+		link = hash_table_find(&interface->port_hash_table, &port_id);
+		if (link)
+			port = hash_table_get_inst(link, port_t, link);
+	}
+	
 	futex_up(&async_futex);
 	
-	/*
-	 * Answer all remaining messages with EHANGUP.
-	 */
-	while (!list_empty(&fibril_connection->msg_queue)) {
-		msg_t *msg =
-		    list_get_instance(list_first(&fibril_connection->msg_queue),
-		    msg_t, link);
-		
-		list_remove(&msg->link);
-		ipc_answer_0(msg->callid, EHANGUP);
-		free(msg);
-	}
-	
-	/*
-	 * If the connection was hung-up, answer the last call,
-	 * i.e. IPC_M_PHONE_HUNGUP.
-	 */
-	if (fibril_connection->close_callid)
-		ipc_answer_0(fibril_connection->close_callid, EOK);
-	
-	free(fibril_connection);
-	return 0;
-}
-
-/** Create a new fibril for a new connection.
- *
- * Create new fibril for connection, fill in connection structures and insert
- * it into the hash table, so that later we can easily do routing of messages to
- * particular fibrils.
- *
- * @param in_task_id    Identification of the incoming connection.
- * @param in_phone_hash Identification of the incoming connection.
- * @param callid        Hash of the opening IPC_M_CONNECT_ME_TO call.
- *                      If callid is zero, the connection was opened by
- *                      accepting the IPC_M_CONNECT_TO_ME call and this function
- *                      is called directly by the server.
- * @param call          Call data of the opening call.
- * @param cfibril       Fibril function that should be called upon opening the
- *                      connection.
- * @param carg          Extra argument to pass to the connection fibril
- *
- * @return New fibril id or NULL on failure.
- *
- */
-fid_t async_new_connection(task_id_t in_task_id, sysarg_t in_phone_hash,
-    ipc_callid_t callid, ipc_call_t *call,
-    async_client_conn_t cfibril, void *carg)
-{
-	connection_t *conn = malloc(sizeof(*conn));
-	if (!conn) {
-		if (callid)
-			ipc_answer_0(callid, ENOMEM);
-		
-		return (uintptr_t) NULL;
-	}
-	
-	conn->in_task_id = in_task_id;
-	conn->in_phone_hash = in_phone_hash;
-	list_initialize(&conn->msg_queue);
-	conn->callid = callid;
-	conn->close_callid = 0;
-	conn->carg = carg;
-	
-	if (call)
-		conn->call = *call;
-	
-	/* We will activate the fibril ASAP */
-	conn->wdata.active = true;
-	conn->cfibril = cfibril;
-	conn->wdata.fid = fibril_create(connection_fibril, conn);
-	
-	if (conn->wdata.fid == 0) {
-		free(conn);
-		
-		if (callid)
-			ipc_answer_0(callid, ENOMEM);
-		
-		return (uintptr_t) NULL;
-	}
-	
-	/* Add connection to the connection hash table */
-	
-	futex_down(&async_futex);
-	hash_table_insert(&conn_hash_table, &conn->link);
-	futex_up(&async_futex);
-	
-	fibril_add_ready(conn->wdata.fid);
-	
-	return conn->wdata.fid;
+	return port;
 }
 
@@ -1111,5 +1373,5 @@
 	assert(call);
 	
-	/* Unrouted call - take some default action */
+	/* Kernel notification */
 	if ((callid & IPC_CALLID_NOTIFICATION)) {
 		process_notification(callid, call);
@@ -1117,10 +1379,31 @@
 	}
 	
-	switch (IPC_GET_IMETHOD(*call)) {
-	case IPC_M_CLONE_ESTABLISH:
-	case IPC_M_CONNECT_ME_TO:
+	/* New connection */
+	if (IPC_GET_IMETHOD(*call) == IPC_M_CONNECT_ME_TO) {
+		iface_t iface = (iface_t) IPC_GET_ARG1(*call);
+		sysarg_t in_phone_hash = IPC_GET_ARG5(*call);
+		
+		async_notification_handler_t handler = fallback_port_handler;
+		void *data = fallback_port_data;
+		
+		// TODO: Currently ignores all ports but the first one
+		port_t *port = async_find_port(iface, 0);
+		if (port) {
+			handler = port->handler;
+			data = port->data;
+		}
+		
+		async_new_connection(call->in_task_id, in_phone_hash, callid,
+		    call, handler, data);
+		return;
+	}
+	
+	/* Cloned connection */
+	if (IPC_GET_IMETHOD(*call) == IPC_M_CLONE_ESTABLISH) {
+		// TODO: Currently ignores ports altogether
+		
 		/* Open new connection with fibril, etc. */
 		async_new_connection(call->in_task_id, IPC_GET_ARG5(*call),
-		    callid, call, client_connection, NULL);
+		    callid, call, fallback_port_handler, fallback_port_data);
 		return;
 	}
@@ -1283,4 +1566,8 @@
 void __async_init(void)
 {
+	if (!hash_table_create(&interface_hash_table, 0, 0,
+	    &interface_hash_table_ops))
+		abort();
+	
 	if (!hash_table_create(&client_hash_table, 0, 0, &client_hash_table_ops))
 		abort();
@@ -1297,4 +1584,5 @@
 		abort();
 	
+	session_ns->iface = 0;
 	session_ns->mgmt = EXCHANGE_ATOMIC;
 	session_ns->phone = PHONE_NS;
@@ -1343,5 +1631,5 @@
 	
 	msg->done = true;
-
+	
 	if (msg->forget) {
 		assert(msg->wdata.active);
@@ -1351,5 +1639,5 @@
 		fibril_add_ready(msg->wdata.fid);
 	}
-
+	
 	futex_up(&async_futex);
 }
@@ -1443,8 +1731,8 @@
 	
 	futex_down(&async_futex);
-
+	
 	assert(!msg->forget);
 	assert(!msg->destroyed);
-
+	
 	if (msg->done) {
 		futex_up(&async_futex);
@@ -1487,10 +1775,10 @@
 	
 	amsg_t *msg = (amsg_t *) amsgid;
-
+	
 	futex_down(&async_futex);
-
+	
 	assert(!msg->forget);
 	assert(!msg->destroyed);
-
+	
 	if (msg->done) {
 		futex_up(&async_futex);
@@ -1504,5 +1792,5 @@
 	if (timeout < 0)
 		timeout = 0;
-
+	
 	getuptime(&msg->wdata.to_event.expires);
 	tv_add_diff(&msg->wdata.to_event.expires, timeout);
@@ -1557,10 +1845,11 @@
 {
 	amsg_t *msg = (amsg_t *) amsgid;
-
+	
 	assert(msg);
 	assert(!msg->forget);
 	assert(!msg->destroyed);
-
+	
 	futex_down(&async_futex);
+	
 	if (msg->done) {
 		amsg_destroy(msg);
@@ -1569,4 +1858,5 @@
 		msg->forget = true;
 	}
+	
 	futex_up(&async_futex);
 }
@@ -1814,5 +2104,4 @@
  * @param arg2            User defined argument.
  * @param arg3            User defined argument.
- * @param client_receiver Connection handing routine.
  *
  * @return Zero on success or a negative error code.
@@ -1820,25 +2109,17 @@
  */
 int async_connect_to_me(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2,
-    sysarg_t arg3, async_client_conn_t client_receiver, void *carg)
+    sysarg_t arg3)
 {
 	if (exch == NULL)
 		return ENOENT;
 	
-	sysarg_t phone_hash;
+	ipc_call_t answer;
+	aid_t req = async_send_3(exch, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3,
+	    &answer);
+	
 	sysarg_t rc;
-
-	aid_t req;
-	ipc_call_t answer;
-	req = async_send_3(exch, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3,
-	    &answer);
 	async_wait_for(req, &rc);
 	if (rc != EOK)
 		return (int) rc;
-
-	phone_hash = IPC_GET_ARG5(answer);
-
-	if (client_receiver != NULL)
-		async_new_connection(answer.in_task_id, phone_hash, 0, NULL,
-		    client_receiver, carg);
 	
 	return EOK;
@@ -1900,4 +2181,5 @@
 	}
 	
+	sess->iface = 0;
 	sess->mgmt = mgmt;
 	sess->phone = phone;
@@ -1969,5 +2251,4 @@
 	int phone = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
 	    0);
-	
 	if (phone < 0) {
 		errno = phone;
@@ -1976,4 +2257,5 @@
 	}
 	
+	sess->iface = 0;
 	sess->mgmt = mgmt;
 	sess->phone = phone;
@@ -1992,4 +2274,55 @@
 }
 
+/** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework.
+ *
+ * Ask through phone for a new connection to some service and block until
+ * success.
+ *
+ * @param exch  Exchange for sending the message.
+ * @param iface Connection interface.
+ * @param arg2  User defined argument.
+ * @param arg3  User defined argument.
+ *
+ * @return New session on success or NULL on error.
+ *
+ */
+async_sess_t *async_connect_me_to_iface(async_exch_t *exch, iface_t iface,
+    sysarg_t arg2, sysarg_t arg3)
+{
+	if (exch == NULL) {
+		errno = ENOENT;
+		return NULL;
+	}
+	
+	async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
+	if (sess == NULL) {
+		errno = ENOMEM;
+		return NULL;
+	}
+	
+	int phone = async_connect_me_to_internal(exch->phone, iface, arg2,
+	    arg3, 0);
+	if (phone < 0) {
+		errno = phone;
+		free(sess);
+		return NULL;
+	}
+	
+	sess->iface = iface;
+	sess->phone = phone;
+	sess->arg1 = iface;
+	sess->arg2 = arg2;
+	sess->arg3 = arg3;
+	
+	fibril_mutex_initialize(&sess->remote_state_mtx);
+	sess->remote_state_data = NULL;
+	
+	list_initialize(&sess->exch_list);
+	fibril_mutex_initialize(&sess->mutex);
+	atomic_set(&sess->refcnt, 0);
+	
+	return sess;
+}
+
 /** Set arguments for new connections.
  *
@@ -2047,4 +2380,5 @@
 	}
 	
+	sess->iface = 0;
 	sess->mgmt = mgmt;
 	sess->phone = phone;
@@ -2063,4 +2397,55 @@
 }
 
+/** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework.
+ *
+ * Ask through phone for a new connection to some service and block until
+ * success.
+ *
+ * @param exch  Exchange for sending the message.
+ * @param iface Connection interface.
+ * @param arg2  User defined argument.
+ * @param arg3  User defined argument.
+ *
+ * @return New session on success or NULL on error.
+ *
+ */
+async_sess_t *async_connect_me_to_blocking_iface(async_exch_t *exch, iface_t iface,
+    sysarg_t arg2, sysarg_t arg3)
+{
+	if (exch == NULL) {
+		errno = ENOENT;
+		return NULL;
+	}
+	
+	async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
+	if (sess == NULL) {
+		errno = ENOMEM;
+		return NULL;
+	}
+	
+	int phone = async_connect_me_to_internal(exch->phone, iface, arg2,
+	    arg3, IPC_FLAG_BLOCKING);
+	if (phone < 0) {
+		errno = phone;
+		free(sess);
+		return NULL;
+	}
+	
+	sess->iface = iface;
+	sess->phone = phone;
+	sess->arg1 = iface;
+	sess->arg2 = arg2;
+	sess->arg3 = arg3;
+	
+	fibril_mutex_initialize(&sess->remote_state_mtx);
+	sess->remote_state_data = NULL;
+	
+	list_initialize(&sess->exch_list);
+	fibril_mutex_initialize(&sess->mutex);
+	atomic_set(&sess->refcnt, 0);
+	
+	return sess;
+}
+
 /** Connect to a task specified by id.
  *
@@ -2081,4 +2466,5 @@
 	}
 	
+	sess->iface = 0;
 	sess->mgmt = EXCHANGE_ATOMIC;
 	sess->phone = phone;
@@ -2158,5 +2544,9 @@
 		return NULL;
 	
-	async_exch_t *exch;
+	exch_mgmt_t mgmt = sess->mgmt;
+	if (sess->iface != 0)
+		mgmt = sess->iface & IFACE_EXCHANGE_MASK;
+	
+	async_exch_t *exch = NULL;
 	
 	fibril_mutex_lock(&async_sess_mutex);
@@ -2177,6 +2567,6 @@
 		 */
 		
-		if ((sess->mgmt == EXCHANGE_ATOMIC) ||
-		    (sess->mgmt == EXCHANGE_SERIALIZE)) {
+		if ((mgmt == EXCHANGE_ATOMIC) ||
+		    (mgmt == EXCHANGE_SERIALIZE)) {
 			exch = (async_exch_t *) malloc(sizeof(async_exch_t));
 			if (exch != NULL) {
@@ -2186,12 +2576,11 @@
 				exch->phone = sess->phone;
 			}
-		} else {  /* EXCHANGE_PARALLEL */
+		} else if (mgmt == EXCHANGE_PARALLEL) {
+			int phone;
+			
+		retry:
 			/*
 			 * Make a one-time attempt to connect a new data phone.
 			 */
-			
-			int phone;
-			
-retry:
 			phone = async_connect_me_to_internal(sess->phone, sess->arg1,
 			    sess->arg2, sess->arg3, 0);
@@ -2235,5 +2624,5 @@
 		atomic_inc(&sess->refcnt);
 		
-		if (sess->mgmt == EXCHANGE_SERIALIZE)
+		if (mgmt == EXCHANGE_SERIALIZE)
 			fibril_mutex_lock(&sess->mutex);
 	}
@@ -2255,7 +2644,11 @@
 	assert(sess != NULL);
 	
+	exch_mgmt_t mgmt = sess->mgmt;
+	if (sess->iface != 0)
+		mgmt = sess->iface & IFACE_EXCHANGE_MASK;
+	
 	atomic_dec(&sess->refcnt);
 	
-	if (sess->mgmt == EXCHANGE_SERIALIZE)
+	if (mgmt == EXCHANGE_SERIALIZE)
 		fibril_mutex_unlock(&sess->mutex);
 	
@@ -2694,26 +3087,26 @@
 	}
 	
-	void *_data;
+	void *arg_data;
 	
 	if (nullterm)
-		_data = malloc(size + 1);
+		arg_data = malloc(size + 1);
 	else
-		_data = malloc(size);
-	
-	if (_data == NULL) {
+		arg_data = malloc(size);
+	
+	if (arg_data == NULL) {
 		ipc_answer_0(callid, ENOMEM);
 		return ENOMEM;
 	}
 	
-	int rc = async_data_write_finalize(callid, _data, size);
+	int rc = async_data_write_finalize(callid, arg_data, size);
 	if (rc != EOK) {
-		free(_data);
+		free(arg_data);
 		return rc;
 	}
 	
 	if (nullterm)
-		((char *) _data)[size] = 0;
-	
-	*data = _data;
+		((char *) arg_data)[size] = 0;
+	
+	*data = arg_data;
 	if (received != NULL)
 		*received = size;
@@ -2813,4 +3206,5 @@
 	}
 	
+	sess->iface = 0;
 	sess->mgmt = mgmt;
 	sess->phone = phone;
@@ -2862,4 +3256,5 @@
 	}
 	
+	sess->iface = 0;
 	sess->mgmt = mgmt;
 	sess->phone = phone;
@@ -2907,4 +3302,5 @@
 		return NULL;
 	
+	sess->iface = 0;
 	sess->mgmt = mgmt;
 	sess->phone = phone;
@@ -2934,8 +3330,8 @@
 {
 	assert(callid);
-
+	
 	ipc_call_t call;
 	*callid = async_get_call(&call);
-
+	
 	if (IPC_GET_IMETHOD(call) != IPC_M_STATE_CHANGE_AUTHORIZE)
 		return false;
@@ -2947,5 +3343,5 @@
 	if (arg3)
 		*arg3 = IPC_GET_ARG3(call);
-
+	
 	return true;
 }
Index: uspace/lib/c/generic/bd.c
===================================================================
--- uspace/lib/c/generic/bd.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/bd.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -57,5 +57,8 @@
 	async_exch_t *exch = async_exchange_begin(sess);
 	
-	int rc = async_connect_to_me(exch, 0, 0, 0, bd_cb_conn, bd);
+	port_id_t port;
+	int rc = async_create_callback_port(exch, INTERFACE_BLOCK_CB, 0, 0,
+	    bd_cb_conn, bd, &port);
+	
 	async_exchange_end(exch);
 	
Index: pace/lib/c/generic/cfg.c
===================================================================
--- uspace/lib/c/generic/cfg.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ 	(revision )
@@ -1,441 +1,0 @@
-/*
- * Copyright (c) 2011 Radim Vansa
- * 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 libc
- * @{
- */
-/** @file cfg.c
- * @brief Configuration files manipulation implementation.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <str.h>
-#include <errno.h>
-#include <assert.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <cfg.h>
-
-/**
- * @param data Configuration file data
- *
- * @return Anonymous section in the configuration file.
- * @return NULL if there is no such section (it is empty)
- *
- */
-const cfg_section_t *cfg_anonymous(const cfg_file_t *data)
-{
-	assert(data != NULL);
-	
-	if (list_empty(&data->sections))
-		return NULL;
-	
-	link_t *link = list_first(&data->sections);
-	const cfg_section_t *section = cfg_section_instance(link);
-	if (section->title[0] != 0)
-		return NULL;
-	
-	return section;
-}
-
-/**
- * @param data Configuration file data
- *
- * @return True if the file contains no data
- *         (no sections, neither anonymous).
- * @return False otherwise.
- *
- */
-bool cfg_empty(const cfg_file_t *data)
-{
-	assert(data != NULL);
-	
-	if (list_empty(&data->sections))
-		return true;
-	
-	cfg_file_foreach(data, section) {
-		if (!list_empty(&section->entries))
-			return false;
-	}
-	
-	return true;
-}
-
-/** Read file contents into memory.
- *
- * @param path Path to the file
- * @param buf  Pointer to pointer to buffer where
- *             the file contents will be stored
- *
- * @return EOK if the file was successfully loaded.
- * @return ENOMEM if there was not enough memory to load the file
- * @return EIO if there was a problem with reading the file
- * @return Other error code if there was a problem openening the file
- *
- */
-static int cfg_read(const char *path, char **buf)
-{
-	assert(buf != NULL);
-	
-	int fd = open(path, O_RDONLY);
-	if (fd < 0)
-		return fd;
-	
-	size_t len = lseek(fd, 0, SEEK_END);
-	lseek(fd, 0, SEEK_SET);
-	
-	*buf = malloc(len + 1);
-	if (*buf == NULL) {
-		close(fd);
-		return ENOMEM;
-	}
-	
-	ssize_t rd = read_all(fd, *buf, len);
-	if (rd < 0) {
-		free(*buf);
-		close(fd);
-		return EIO;
-	}
-	
-	(*buf)[len] = 0;
-	close(fd);
-	
-	return EOK;
-}
-
-static inline void null_back(char *back)
-{
-	do {
-		*back = 0;
-		back--;
-	} while (isspace(*back));
-}
-
-/** Allocate and initialize a new entry.
- *
- * @param key   Entry key
- * @param value Entry value
- *
- * @return New entry
- * @return NULL if there was not enough memory
- *
- */
-static cfg_entry_t *cfg_new_entry(const char *key, const char *value)
-{
-	cfg_entry_t *entry = malloc(sizeof(cfg_entry_t));
-	if (entry == NULL)
-		return NULL;
-	
-	link_initialize(&entry->link);
-	entry->key = key;
-	entry->value = value;
-	
-	return entry;
-}
-
-/** Allocate and initialize a new section.
- *
- * @param title Section title
- *
- * @return New section
- * @return NULL if there was not enough memory
- *
- */
-static cfg_section_t *cfg_new_section(const char *title)
-{
-	cfg_section_t *sec = malloc(sizeof(cfg_section_t));
-	if (sec == NULL)
-		return NULL;
-	
-	link_initialize(&sec->link);
-	
-	if (title != NULL)
-		sec->title = title;
-	else
-		sec->title = "";
-	
-	list_initialize(&sec->entries);
-	sec->entry_count = 0;
-	
-	return sec;
-}
-
-/** Skip whitespaces
- *
- */
-static inline void skip_whitespaces(char **buffer)
-{
-	while (isspace(**buffer))
-		(*buffer)++;
-}
-
-static inline int starts_comment(char c)
-{
-	return ((c == ';') || (c == '#'));
-}
-
-/** Load file content into memory
- *
- * Parse the file into sections and entries
- * and initialize data with this info.
- *
- * @param path Path to the configuration file
- * @param data Configuration file data
- *
- * @return EOK if the file was successfully loaded
- * @return EBADF if the configuration file has bad format.
- * @return ENOMEM if there was not enough memory
- * @return Error code from cfg_read()
- *
- */
-int cfg_load(const char *path, cfg_file_t *data)
-{
-	char *buffer;
-	int res = cfg_read(path, &buffer);
-	if (res != EOK)
-		return res;
-	
-	list_initialize(&data->sections);
-	data->section_count = 0;
-	data->data = buffer;
-	
-	cfg_section_t *curr_section = NULL;
-	skip_whitespaces(&buffer);
-	
-	while (*buffer) {
-		while (starts_comment(*buffer)) {
-			while ((*buffer) && (*buffer != '\n'))
-				buffer++;
-			
-			skip_whitespaces(&buffer);
-		}
-		
-		if (*buffer == '[') {
-			buffer++;
-			skip_whitespaces(&buffer);
-			
-			const char *title = buffer;
-			while ((*buffer) && (*buffer != ']') && (*buffer != '\n'))
-				buffer++;
-			
-			if (*buffer != ']') {
-				cfg_unload(data);
-				return EBADF;
-			}
-			
-			null_back(buffer);
-			buffer++;
-			
-			cfg_section_t *sec = cfg_new_section(title);
-			if (sec == NULL) {
-				cfg_unload(data);
-				return ENOMEM;
-			}
-			
-			list_append(&sec->link, &data->sections);
-			data->section_count++;
-			curr_section = sec;
-		} else if (*buffer) {
-			const char *key = buffer;
-			while ((*buffer) && (*buffer != '=') && (*buffer != '\n'))
-				buffer++;
-			
-			if (*buffer != '=') {
-				cfg_unload(data);
-				return EBADF;
-			}
-			
-			/* null = and whitespaces before */
-			null_back(buffer);
-			buffer++;
-			skip_whitespaces(&buffer);
-			
-			while (starts_comment(*buffer)) {
-				while ((*buffer) && (*buffer != '\n'))
-					buffer++;
-				
-				skip_whitespaces(&buffer);
-			}
-			
-			const char *value = buffer;
-			/* Empty value is correct value */
-			if (*buffer) {
-				while ((*buffer) && (*buffer != '\n'))
-					buffer++;
-				
-				if (*buffer) {
-					null_back(buffer);
-					buffer++;
-				} else
-					null_back(buffer);
-			}
-			
-			/* Create anonymous section if not present */
-			if (curr_section == NULL) {
-				curr_section = cfg_new_section(NULL);
-				if (curr_section == NULL) {
-					cfg_unload(data);
-					return ENOMEM;
-				}
-				
-				list_append(&curr_section->link, &data->sections);
-			}
-			
-			cfg_entry_t *entry = cfg_new_entry(key, value);
-			if (entry == NULL) {
-				cfg_unload(data);
-				return ENOMEM;
-			}
-			
-			list_append(&entry->link, &curr_section->entries);
-			curr_section->entry_count++;
-		}
-		
-		skip_whitespaces(&buffer);
-	}
-	
-	return EOK;
-}
-
-/** Load file content into memory (with path)
- *
- * Parse the file (with path) into sections and entries
- * and initialize data with this info.
- *
- */
-int cfg_load_path(const char *path, const char *fname, cfg_file_t *data)
-{
-	size_t sz = str_size(path) + str_size(fname) + 2;
-	char *name = malloc(sz);
-	if (name == NULL)
-		return ENOMEM;
-	
-	snprintf(name, sz, "%s/%s", path, fname);
-	int rc = cfg_load(name, data);
-	
-	free(name);
-	
-	return rc;
-}
-
-/** Deallocate memory used by entry
- *
- */
-static void cfg_free_entry(const cfg_entry_t *entry)
-{
-	assert(entry != NULL);
-	free(entry);
-}
-
-/** Deallocate memory used by all entries
- *
- * Deallocate memory used by all entries within a section
- * and the memory used by the section itself.
- *
- */
-static void cfg_free_section(const cfg_section_t *section)
-{
-	assert(section != NULL);
-	
-	link_t *cur;
-	link_t *next;
-	
-	for (cur = section->entries.head.next;
-	    cur != &section->entries.head;
-	    cur = next) {
-		next = cur->next;
-		cfg_free_entry(cfg_entry_instance(cur));
-	}
-	
-	free(section);
-}
-
-/** Deallocate memory used by configuration data
- *
- * Deallocate all inner sections and entries.
- *
- */
-void cfg_unload(cfg_file_t *data)
-{
-	assert(data != NULL);
-	
-	link_t *cur, *next;
-	for (cur = data->sections.head.next;
-	    cur != &data->sections.head;
-	    cur = next) {
-		next = cur->next;
-		cfg_free_section(cfg_section_instance(cur));
-	}
-	
-	free(data->data);
-}
-
-/** Find a section in the configuration data
- *
- * @param data  Configuration data
- * @param title Title of the section to search for
- *
- * @return Found section
- * @return NULL if there is no section with such title
- *
- */
-const cfg_section_t *cfg_find_section(const cfg_file_t *data, const char *title)
-{
-	cfg_file_foreach(data, section) {
-		if (str_cmp(section->title, title) == 0)
-			return section;
-	}
-	
-	return NULL;
-}
-
-/** Find entry value in the configuration data
- *
- * @param section Section in which to search
- * @param key     Key of the entry we to search for
- *
- * @return Value of the entry
- * @return NULL if there is no entry with such key
- *
- */
-const char *cfg_find_value(const cfg_section_t *section, const char *key)
-{
-	cfg_section_foreach(section, entry) {
-		if (str_cmp(entry->key, key) == 0)
-			return entry->value;
-	}
-	
-	return NULL;
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/clipboard.c
===================================================================
--- uspace/lib/c/generic/clipboard.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/clipboard.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -61,6 +61,6 @@
 	
 	while (clip_sess == NULL)
-		clip_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
-		    SERVICE_CLIPBOARD, 0, 0);
+		clip_sess = service_connect_blocking(SERVICE_CLIPBOARD,
+		    INTERFACE_CLIPBOARD, 0);
 	
 	fibril_mutex_unlock(&clip_mutex);
Index: uspace/lib/c/generic/corecfg.c
===================================================================
--- uspace/lib/c/generic/corecfg.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/corecfg.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -50,5 +50,5 @@
 		return ENOENT;
 
-	corecfg_sess = loc_service_connect(EXCHANGE_SERIALIZE, corecfg_svc,
+	corecfg_sess = loc_service_connect(corecfg_svc, INTERFACE_CORECFG,
 	    IPC_FLAG_BLOCKING);
 	if (corecfg_sess == NULL)
Index: uspace/lib/c/generic/devman.c
===================================================================
--- uspace/lib/c/generic/devman.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/devman.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -77,8 +77,8 @@
  *
  */
-async_exch_t *devman_exchange_begin_blocking(devman_interface_t iface)
+async_exch_t *devman_exchange_begin_blocking(iface_t iface)
 {
 	switch (iface) {
-	case DEVMAN_DRIVER:
+	case INTERFACE_DDF_DRIVER:
 		fibril_mutex_lock(&devman_driver_block_mutex);
 		
@@ -89,6 +89,6 @@
 			if (devman_driver_block_sess == NULL)
 				devman_driver_block_sess =
-				    service_connect_blocking(EXCHANGE_PARALLEL,
-				    SERVICE_DEVMAN, DEVMAN_DRIVER, 0);
+				    service_connect_blocking(SERVICE_DEVMAN,
+				    INTERFACE_DDF_DRIVER, 0);
 		}
 		
@@ -99,5 +99,5 @@
 		
 		return async_exchange_begin(devman_driver_block_sess);
-	case DEVMAN_CLIENT:
+	case INTERFACE_DDF_CLIENT:
 		fibril_mutex_lock(&devman_client_block_mutex);
 		
@@ -108,6 +108,6 @@
 			if (devman_client_block_sess == NULL)
 				devman_client_block_sess =
-				    service_connect_blocking(EXCHANGE_SERIALIZE,
-				    SERVICE_DEVMAN, DEVMAN_CLIENT, 0);
+				    service_connect_blocking(SERVICE_DEVMAN,
+				    INTERFACE_DDF_CLIENT, 0);
 		}
 		
@@ -130,14 +130,14 @@
  *
  */
-async_exch_t *devman_exchange_begin(devman_interface_t iface)
+async_exch_t *devman_exchange_begin(iface_t iface)
 {
 	switch (iface) {
-	case DEVMAN_DRIVER:
+	case INTERFACE_DDF_DRIVER:
 		fibril_mutex_lock(&devman_driver_mutex);
 		
 		if (devman_driver_sess == NULL)
 			devman_driver_sess =
-			    service_connect(EXCHANGE_PARALLEL, SERVICE_DEVMAN,
-			    DEVMAN_DRIVER, 0);
+			    service_connect(SERVICE_DEVMAN,
+			    INTERFACE_DDF_DRIVER, 0);
 		
 		fibril_mutex_unlock(&devman_driver_mutex);
@@ -147,11 +147,11 @@
 		
 		return async_exchange_begin(devman_driver_sess);
-	case DEVMAN_CLIENT:
+	case INTERFACE_DDF_CLIENT:
 		fibril_mutex_lock(&devman_client_mutex);
 		
 		if (devman_client_sess == NULL)
 			devman_client_sess =
-			    service_connect(EXCHANGE_SERIALIZE, SERVICE_DEVMAN,
-			    DEVMAN_CLIENT, 0);
+			    service_connect(SERVICE_DEVMAN,
+			    INTERFACE_DDF_CLIENT, 0);
 		
 		fibril_mutex_unlock(&devman_client_mutex);
@@ -179,5 +179,5 @@
 int devman_driver_register(const char *name)
 {
-	async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_DRIVER);
+	async_exch_t *exch = devman_exchange_begin_blocking(INTERFACE_DDF_DRIVER);
 	
 	ipc_call_t answer;
@@ -192,6 +192,6 @@
 	}
 	
-	exch = devman_exchange_begin(DEVMAN_DRIVER);
-	async_connect_to_me(exch, 0, 0, 0, NULL, NULL);
+	exch = devman_exchange_begin(INTERFACE_DDF_DRIVER);
+	async_connect_to_me(exch, 0, 0, 0);
 	devman_exchange_end(exch);
 	
@@ -217,6 +217,6 @@
     match_id_list_t *match_ids, devman_handle_t devh, devman_handle_t *funh)
 {
-	int match_count = list_count(&match_ids->ids);
-	async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_DRIVER);
+	unsigned long match_count = list_count(&match_ids->ids);
+	async_exch_t *exch = devman_exchange_begin_blocking(INTERFACE_DDF_DRIVER);
 	
 	ipc_call_t answer;
@@ -268,5 +268,5 @@
     const char *cat_name)
 {
-	async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_DRIVER);
+	async_exch_t *exch = devman_exchange_begin_blocking(INTERFACE_DDF_DRIVER);
 	
 	ipc_call_t answer;
@@ -287,15 +287,14 @@
 }
 
-async_sess_t *devman_device_connect(exch_mgmt_t mgmt, devman_handle_t handle,
-    unsigned int flags)
+async_sess_t *devman_device_connect(devman_handle_t handle, unsigned int flags)
 {
 	async_sess_t *sess;
 	
 	if (flags & IPC_FLAG_BLOCKING)
-		sess = service_connect_blocking(mgmt, SERVICE_DEVMAN,
-			    DEVMAN_CONNECT_TO_DEVICE, handle);
+		sess = service_connect_blocking(SERVICE_DEVMAN,
+		    INTERFACE_DEVMAN_DEVICE, handle);
 	else
-		sess = service_connect(mgmt, SERVICE_DEVMAN,
-			    DEVMAN_CONNECT_TO_DEVICE, handle);
+		sess = service_connect(SERVICE_DEVMAN,
+		    INTERFACE_DEVMAN_DEVICE, handle);
 	
 	return sess;
@@ -314,5 +313,5 @@
 	sysarg_t retval;
 	
-	exch = devman_exchange_begin_blocking(DEVMAN_DRIVER);
+	exch = devman_exchange_begin_blocking(INTERFACE_DDF_DRIVER);
 	retval = async_req_1_0(exch, DEVMAN_REMOVE_FUNCTION, (sysarg_t) funh);
 	devman_exchange_end(exch);
@@ -323,5 +322,5 @@
 int devman_drv_fun_online(devman_handle_t funh)
 {
-	async_exch_t *exch = devman_exchange_begin(DEVMAN_DRIVER);
+	async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_DRIVER);
 	if (exch == NULL)
 		return ENOMEM;
@@ -335,5 +334,5 @@
 int devman_drv_fun_offline(devman_handle_t funh)
 {
-	async_exch_t *exch = devman_exchange_begin(DEVMAN_DRIVER);
+	async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_DRIVER);
 	if (exch == NULL)
 		return ENOMEM;
@@ -345,15 +344,15 @@
 }
 
-async_sess_t *devman_parent_device_connect(exch_mgmt_t mgmt,
-    devman_handle_t handle, unsigned int flags)
+async_sess_t *devman_parent_device_connect(devman_handle_t handle,
+    unsigned int flags)
 {
 	async_sess_t *sess;
 	
 	if (flags & IPC_FLAG_BLOCKING)
-		sess = service_connect_blocking(mgmt, SERVICE_DEVMAN,
-			    DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle);
+		sess = service_connect_blocking(SERVICE_DEVMAN,
+		    INTERFACE_DEVMAN_PARENT, handle);
 	else
-		sess = service_connect(mgmt, SERVICE_DEVMAN,
-			    DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle);
+		sess = service_connect_blocking(SERVICE_DEVMAN,
+		    INTERFACE_DEVMAN_PARENT, handle);
 	
 	return sess;
@@ -366,7 +365,7 @@
 	
 	if (flags & IPC_FLAG_BLOCKING)
-		exch = devman_exchange_begin_blocking(DEVMAN_CLIENT);
+		exch = devman_exchange_begin_blocking(INTERFACE_DDF_CLIENT);
 	else {
-		exch = devman_exchange_begin(DEVMAN_CLIENT);
+		exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
 		if (exch == NULL)
 			return ENOMEM;
@@ -409,5 +408,5 @@
 	sysarg_t dretval;
 	
-	exch = devman_exchange_begin_blocking(DEVMAN_CLIENT);
+	exch = devman_exchange_begin_blocking(INTERFACE_DDF_CLIENT);
 	
 	ipc_call_t answer;
@@ -474,5 +473,5 @@
 int devman_fun_online(devman_handle_t funh)
 {
-	async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
+	async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
 	if (exch == NULL)
 		return ENOMEM;
@@ -486,5 +485,5 @@
 int devman_fun_offline(devman_handle_t funh)
 {
-	async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
+	async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
 	if (exch == NULL)
 		return ENOMEM;
@@ -499,5 +498,5 @@
     devman_handle_t *handle_buf, size_t buf_size, size_t *act_size)
 {
-	async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_CLIENT);
+	async_exch_t *exch = devman_exchange_begin_blocking(INTERFACE_DDF_CLIENT);
 
 	ipc_call_t answer;
@@ -578,5 +577,5 @@
 int devman_fun_get_child(devman_handle_t funh, devman_handle_t *devh)
 {
-	async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
+	async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
 	if (exch == NULL)
 		return ENOMEM;
@@ -598,5 +597,5 @@
 int devman_dev_get_parent(devman_handle_t devh, devman_handle_t *funh)
 {
-	async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
+	async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
 	if (exch == NULL)
 		return ENOMEM;
@@ -611,5 +610,5 @@
 int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle)
 {
-	async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
+	async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
 	if (exch == NULL)
 		return ENOMEM;
@@ -639,5 +638,5 @@
 	async_exch_t *exch;
 
-	exch = devman_exchange_begin(DEVMAN_CLIENT);
+	exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
 	if (exch == NULL)
 		return ENOMEM;
@@ -694,5 +693,5 @@
 {
 	sysarg_t state;
-	async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
+	async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
 	if (exch == NULL)
 		return ENOMEM;
@@ -711,5 +710,5 @@
 int devman_driver_load(devman_handle_t drvh)
 {
-	async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
+	async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
 	if (exch == NULL)
 		return ENOMEM;
Index: uspace/lib/c/generic/dhcp.c
===================================================================
--- uspace/lib/c/generic/dhcp.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/dhcp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -56,5 +56,5 @@
 		return ENOENT;
 
-	dhcp_sess = loc_service_connect(EXCHANGE_SERIALIZE, dhcp_svc,
+	dhcp_sess = loc_service_connect(dhcp_svc, INTERFACE_DHCP,
 	    IPC_FLAG_BLOCKING);
 	if (dhcp_sess == NULL)
Index: uspace/lib/c/generic/dnsr.c
===================================================================
--- uspace/lib/c/generic/dnsr.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/dnsr.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -52,5 +52,5 @@
 		    IPC_FLAG_BLOCKING);
 		
-		dnsr_sess = loc_service_connect(EXCHANGE_SERIALIZE, dnsr_svc,
+		dnsr_sess = loc_service_connect(dnsr_svc, INTERFACE_DNSR,
 		    IPC_FLAG_BLOCKING);
 	}
Index: uspace/lib/c/generic/elf/elf_load.c
===================================================================
--- uspace/lib/c/generic/elf/elf_load.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/elf/elf_load.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -97,5 +97,5 @@
 	int fd;
 	int rc;
-	
+
 	fd = open(file_name, O_RDONLY);
 	if (fd < 0) {
@@ -147,5 +147,5 @@
 	int i, rc;
 
-	rc = read_all(elf->fd, header, sizeof(elf_header_t));
+	rc = read(elf->fd, header, sizeof(elf_header_t));
 	if (rc != sizeof(elf_header_t)) {
 		DPRINTF("Read error.\n"); 
@@ -209,5 +209,5 @@
 		        + i * sizeof(elf_segment_header_t), SEEK_SET);
 
-		rc = read_all(elf->fd, &segment_hdr,
+		rc = read(elf->fd, &segment_hdr,
 		    sizeof(elf_segment_header_t));
 		if (rc != sizeof(elf_segment_header_t)) {
@@ -231,5 +231,5 @@
 		    + i * sizeof(elf_section_header_t), SEEK_SET);
 
-		rc = read_all(elf->fd, &section_hdr,
+		rc = read(elf->fd, &section_hdr,
 		    sizeof(elf_section_header_t));
 		if (rc != sizeof(elf_section_header_t)) {
@@ -399,5 +399,5 @@
 		if (now > left) now = left;
 
-		rc = read_all(elf->fd, dp, now);
+		rc = read(elf->fd, dp, now);
 
 		if (rc != (ssize_t) now) { 
Index: uspace/lib/c/generic/inet.c
===================================================================
--- uspace/lib/c/generic/inet.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/inet.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -48,5 +48,9 @@
 	ipc_call_t answer;
 	aid_t req = async_send_0(exch, INET_CALLBACK_CREATE, &answer);
-	int rc = async_connect_to_me(exch, 0, 0, 0, inet_cb_conn, NULL);
+	
+	port_id_t port;
+	int rc = async_create_callback_port(exch, INTERFACE_INET_CB, 0, 0,
+	    inet_cb_conn, NULL, &port);
+	
 	async_exchange_end(exch);
 	
@@ -83,5 +87,5 @@
 		return ENOENT;
 	
-	inet_sess = loc_service_connect(EXCHANGE_SERIALIZE, inet_svc,
+	inet_sess = loc_service_connect(inet_svc, INTERFACE_INET,
 	    IPC_FLAG_BLOCKING);
 	if (inet_sess == NULL)
Index: uspace/lib/c/generic/inet/addr.c
===================================================================
--- uspace/lib/c/generic/inet/addr.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/inet/addr.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -306,5 +306,5 @@
 		i++;
 
-		if (*cur == '\0')
+		if (*cur == '\0' || *cur == '/')
 			break;
 
@@ -317,4 +317,8 @@
 
 	if (prefix != NULL) {
+		if (*cur != '/')
+			return EINVAL;
+		cur++;
+
 		*prefix = strtoul(cur, &cur, 10);
 		if (*prefix > 32)
Index: uspace/lib/c/generic/inet/endpoint.c
===================================================================
--- uspace/lib/c/generic/inet/endpoint.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/inet/endpoint.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,4 +36,10 @@
 #include <mem.h>
 
+/** Initialize endpoint structure.
+ *
+ * Sets any address, any port number.
+ *
+ * @param ep Endpoint
+ */
 void inet_ep_init(inet_ep_t *ep)
 {
@@ -41,4 +47,10 @@
 }
 
+/** Initialize endpoint pair structure.
+ *
+ * Sets any address, any port number for both local and remote sides.
+ *
+ * @param ep2 Endpoint pair
+ */
 void inet_ep2_init(inet_ep2_t *ep2)
 {
Index: uspace/lib/c/generic/inet/tcp.c
===================================================================
--- uspace/lib/c/generic/inet/tcp.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/inet/tcp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -44,10 +44,21 @@
 static int tcp_conn_fibril(void *);
 
-/** Incoming TCP connection info */
+/** Incoming TCP connection info
+ *
+ * Used to pass information about incoming TCP connection to the connection
+ * fibril
+ */
 typedef struct {
+	/** Listener who received the connection */
 	tcp_listener_t *lst;
+	/** Incoming connection */
 	tcp_conn_t *conn;
 } tcp_in_conn_t;
 
+/** Create callback connection from TCP service.
+ *
+ * @param tcp TCP service
+ * @return EOK on success or negative error code
+ */
 static int tcp_callback_create(tcp_t *tcp)
 {
@@ -55,5 +66,9 @@
 
 	aid_t req = async_send_0(exch, TCP_CALLBACK_CREATE, NULL);
-	int rc = async_connect_to_me(exch, 0, 0, 0, tcp_cb_conn, tcp);
+	
+	port_id_t port;
+	int rc = async_create_callback_port(exch, INTERFACE_TCP_CB, 0, 0,
+	    tcp_cb_conn, tcp, &port);
+	
 	async_exchange_end(exch);
 
@@ -67,4 +82,10 @@
 }
 
+/** Create TCP client instance.
+ *
+ * @param  rtcp Place to store pointer to new TCP client
+ * @return EOK on success, ENOMEM if out of memory, EIO if service
+ *         cannot be contacted
+ */
 int tcp_create(tcp_t **rtcp)
 {
@@ -91,5 +112,5 @@
 	}
 
-	tcp->sess = loc_service_connect(EXCHANGE_SERIALIZE, tcp_svcid,
+	tcp->sess = loc_service_connect(tcp_svcid, INTERFACE_TCP,
 	    IPC_FLAG_BLOCKING);
 	if (tcp->sess == NULL) {
@@ -111,4 +132,8 @@
 }
 
+/** Destroy TCP client instance.
+ *
+ * @param tcp TCP client
+ */
 void tcp_destroy(tcp_t *tcp)
 {
@@ -126,4 +151,14 @@
 }
 
+/** Create new TCP connection
+ *
+ * @param tcp   TCP client instance
+ * @param id    Connection ID
+ * @param cb    Callbacks
+ * @param arg   Callback argument
+ * @param rconn Place to store pointer to new connection
+ *
+ * @return EOK on success, ENOMEM if out of memory
+ */
 static int tcp_conn_new(tcp_t *tcp, sysarg_t id, tcp_cb_t *cb, void *arg,
     tcp_conn_t **rconn)
@@ -150,4 +185,26 @@
 }
 
+/** Create new TCP connection.
+ *
+ * Open a connection to the specified destination. This function returns
+ * even before the connection is established (or not). When the connection
+ * is established, @a cb->connected is called. If the connection fails,
+ * @a cb->conn_failed is called. Alternatively, the caller can call
+ * @c tcp_conn_wait_connected() to wait for connection to complete or fail.
+ * Other callbacks are available to monitor the changes in connection state.
+ *
+ * @a epp must specify the remote address and port. Both local address and
+ * port are optional. If local address is not specified, address selection
+ * will take place. If local port number is not specified, a suitable
+ * free dynamic port number will be allocated.
+ *
+ * @param tcp   TCP client
+ * @param epp   Internet endpoint pair
+ * @param cb    Callbacks
+ * @param arg   Argument to callbacks
+ * @param rconn Place to store pointer to new connection
+ *
+ * @return EOK on success or negative error code.
+ */
 int tcp_conn_create(tcp_t *tcp, inet_ep2_t *epp, tcp_cb_t *cb, void *arg,
     tcp_conn_t **rconn)
@@ -186,4 +243,11 @@
 }
 
+/** Destroy TCP connection.
+ *
+ * Destroy TCP connection. The caller should destroy all connections
+ * he created before destroying the TCP client and before terminating.
+ *
+ * @param conn TCP connection
+ */
 void tcp_conn_destroy(tcp_conn_t *conn)
 {
@@ -203,4 +267,12 @@
 }
 
+/** Get connection based on its ID.
+ *
+ * @param tcp   TCP client
+ * @param id    Connection ID
+ * @param rconn Place to store pointer to connection
+ *
+ * @return EOK on success, EINVAL if no connection with the given ID exists
+ */
 static int tcp_conn_get(tcp_t *tcp, sysarg_t id, tcp_conn_t **rconn)
 {
@@ -215,4 +287,9 @@
 }
 
+/** Get the user/callback argument for a connection.
+ *
+ * @param conn TCP connection
+ * @return User argument associated with connection
+ */
 void *tcp_conn_userptr(tcp_conn_t *conn)
 {
@@ -220,4 +297,25 @@
 }
 
+/** Create a TCP connection listener.
+ *
+ * A listener listens for connections on the set of endpoints specified
+ * by @a ep. Each time a new incoming connection is established,
+ * @a lcb->new_conn is called (and passed @a larg). Also, the new connection
+ * will have callbacks set to @a cb and argument to @a arg.
+ *
+ * @a ep must specify a valid port number. @a ep may specify an address
+ * or link to listen on. If it does not, the listener will listen on
+ * all links/addresses.
+ *
+ * @param tcp  TCP client
+ * @param ep   Internet endpoint
+ * @param lcb  Listener callbacks
+ * @param larg Listener callback argument
+ * @param cb   Connection callbacks for every new connection
+ * @param arg  Connection argument for every new connection
+ * @param rlst Place to store pointer to new listener
+ *
+ * @return EOK on success or negative error code
+ */
 int tcp_listener_create(tcp_t *tcp, inet_ep_t *ep, tcp_listen_cb_t *lcb,
     void *larg, tcp_cb_t *cb, void *arg, tcp_listener_t **rlst)
@@ -265,4 +363,8 @@
 }
 
+/** Destroy TCP connection listener.
+ *
+ * @param lst Listener
+ */
 void tcp_listener_destroy(tcp_listener_t *lst)
 {
@@ -282,4 +384,12 @@
 }
 
+/** Get TCP connection listener based on its ID.
+ *
+ * @param tcp TCP client
+ * @param id  Listener ID
+ * @param rlst Place to store pointer to listener
+ *
+ * @return EOK on success, EINVAL if no listener with the given ID is found
+ */
 static int tcp_listener_get(tcp_t *tcp, sysarg_t id, tcp_listener_t **rlst)
 {
@@ -294,4 +404,9 @@
 }
 
+/** Get callback/user argument associated with listener.
+ *
+ * @param lst Listener
+ * @return Callback/user argument
+ */
 void *tcp_listener_userptr(tcp_listener_t *lst)
 {
@@ -299,4 +414,14 @@
 }
 
+/** Wait until connection is either established or connection fails.
+ *
+ * Can be called after calling tcp_conn_create() to block until connection
+ * either completes or fails. If the connection fails, EIO is returned.
+ * In this case the connection still exists, but is in a failed
+ * state.
+ *
+ * @param conn Connection
+ * @return EOK if connection is established, EIO otherwise
+ */
 int tcp_conn_wait_connected(tcp_conn_t *conn)
 {
@@ -315,4 +440,12 @@
 }
 
+/** Send data over TCP connection.
+ *
+ * @param conn  Connection
+ * @param data  Data
+ * @param bytes Data size in bytes
+ *
+ * @return EOK on success or negative error code
+ */
 int tcp_conn_send(tcp_conn_t *conn, const void *data, size_t bytes)
 {
@@ -340,5 +473,11 @@
 }
 
-
+/** Send FIN.
+ *
+ * Send FIN, indicating no more data will be send over the connection.
+ *
+ * @param conn Connection
+ * @return EOK on success or negative error code
+ */
 int tcp_conn_send_fin(tcp_conn_t *conn)
 {
@@ -352,4 +491,9 @@
 }
 
+/** Push connection.
+ *
+ * @param conn Connection
+ * @return EOK on success or negative error code
+ */
 int tcp_conn_push(tcp_conn_t *conn)
 {
@@ -363,4 +507,9 @@
 }
 
+/** Reset connection.
+ *
+ * @param conn Connection
+ * @return EOK on success or negative error code
+ */
 int tcp_conn_reset(tcp_conn_t *conn)
 {
@@ -374,4 +523,21 @@
 }
 
+/** Read received data from connection without blocking.
+ *
+ * If any received data is pending on the connection, up to @a bsize bytes
+ * are copied to @a buf and the acutal number is stored in @a *nrecv.
+ * The entire buffer of @a bsize bytes is filled except when less data
+ * is currently available or FIN is received. EOK is returned.
+ *
+ * If no received data is pending, returns EAGAIN.
+ *
+ * @param conn Connection
+ * @param buf  Buffer
+ * @param bsize Buffer size
+ * @param nrecv Place to store actual number of received bytes
+ *
+ * @return EOK on success, EAGAIN if no received data is pending, or other
+ *         negative error code in case of other error
+ */
 int tcp_conn_recv(tcp_conn_t *conn, void *buf, size_t bsize, size_t *nrecv)
 {
@@ -408,5 +574,20 @@
 }
 
-int tcp_conn_recv_wait(tcp_conn_t *conn, void *buf, size_t bsize, size_t *nrecv)
+/** Read received data from connection with blocking.
+ *
+ * Wait for @a bsize bytes of data to be received and copy them to
+ * @a buf. Less data may be returned if FIN is received on the connection.
+ * The actual If any received data is written to @a *nrecv and EOK
+ * is returned on success.
+ *
+ * @param conn Connection
+ * @param buf  Buffer
+ * @param bsize Buffer size
+ * @param nrecv Place to store actual number of received bytes
+ *
+ * @return EOK on success or negative error code
+ */
+int tcp_conn_recv_wait(tcp_conn_t *conn, void *buf, size_t bsize,
+    size_t *nrecv)
 {
 	async_exch_t *exch;
@@ -450,4 +631,10 @@
 }
 
+/** Connection established event.
+ *
+ * @param tcp TCP client
+ * @param iid Call ID
+ * @param icall Call data
+ */
 static void tcp_ev_connected(tcp_t *tcp, ipc_callid_t iid, ipc_call_t *icall)
 {
@@ -472,4 +659,10 @@
 }
 
+/** Connection failed event.
+ *
+ * @param tcp TCP client
+ * @param iid Call ID
+ * @param icall Call data
+ */
 static void tcp_ev_conn_failed(tcp_t *tcp, ipc_callid_t iid, ipc_call_t *icall)
 {
@@ -494,4 +687,10 @@
 }
 
+/** Connection reset event.
+ *
+ * @param tcp TCP client
+ * @param iid Call ID
+ * @param icall Call data
+ */
 static void tcp_ev_conn_reset(tcp_t *tcp, ipc_callid_t iid, ipc_call_t *icall)
 {
@@ -516,4 +715,10 @@
 }
 
+/** Data available event.
+ *
+ * @param tcp TCP client
+ * @param iid Call ID
+ * @param icall Call data
+ */
 static void tcp_ev_data(tcp_t *tcp, ipc_callid_t iid, ipc_call_t *icall)
 {
@@ -539,4 +744,10 @@
 }
 
+/** Urgent data event.
+ *
+ * @param tcp TCP client
+ * @param iid Call ID
+ * @param icall Call data
+ */
 static void tcp_ev_urg_data(tcp_t *tcp, ipc_callid_t iid, ipc_call_t *icall)
 {
@@ -544,4 +755,10 @@
 }
 
+/** New connection event.
+ *
+ * @param tcp TCP client
+ * @param iid Call ID
+ * @param icall Call data
+ */
 static void tcp_ev_new_conn(tcp_t *tcp, ipc_callid_t iid, ipc_call_t *icall)
 {
@@ -590,4 +807,10 @@
 }
 
+/** Callback connection handler.
+ *
+ * @param iid Connect call ID
+ * @param icall Connect call data
+ * @param arg Argument, TCP client
+ */
 static void tcp_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
@@ -636,5 +859,8 @@
 }
 
-/** Fibril for handling incoming TCP connection in background */
+/** Fibril for handling incoming TCP connection in background.
+ *
+ * @param arg Argument, incoming connection information (@c tcp_in_conn_t)
+ */
 static int tcp_conn_fibril(void *arg)
 {
Index: uspace/lib/c/generic/inet/udp.c
===================================================================
--- uspace/lib/c/generic/inet/udp.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/inet/udp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -43,4 +43,9 @@
 static void udp_cb_conn(ipc_callid_t, ipc_call_t *, void *);
 
+/** Create callback connection from UDP service.
+ *
+ * @param udp UDP service
+ * @return EOK on success or negative error code
+ */
 static int udp_callback_create(udp_t *udp)
 {
@@ -48,5 +53,9 @@
 
 	aid_t req = async_send_0(exch, UDP_CALLBACK_CREATE, NULL);
-	int rc = async_connect_to_me(exch, 0, 0, 0, udp_cb_conn, udp);
+	
+	port_id_t port;
+	int rc = async_create_callback_port(exch, INTERFACE_UDP_CB, 0, 0,
+	    udp_cb_conn, udp, &port);
+	
 	async_exchange_end(exch);
 
@@ -60,4 +69,10 @@
 }
 
+/** Create UDP client instance.
+ *
+ * @param  rudp Place to store pointer to new UDP client
+ * @return EOK on success, ENOMEM if out of memory, EIO if service
+ *         cannot be contacted
+ */
 int udp_create(udp_t **rudp)
 {
@@ -83,5 +98,5 @@
 	}
 
-	udp->sess = loc_service_connect(EXCHANGE_SERIALIZE, udp_svcid,
+	udp->sess = loc_service_connect(udp_svcid, INTERFACE_UDP,
 	    IPC_FLAG_BLOCKING);
 	if (udp->sess == NULL) {
@@ -103,4 +118,8 @@
 }
 
+/** Destroy UDP client instance.
+ *
+ * @param udp UDP client
+ */
 void udp_destroy(udp_t *udp)
 {
@@ -118,5 +137,28 @@
 }
 
-int udp_assoc_create(udp_t *udp, inet_ep2_t *ep2, udp_cb_t *cb, void *arg,
+/** Create new UDP association.
+ *
+ * Create a UDP association that allows sending and receiving messages.
+ *
+ * @a epp may specify remote address and port, in which case only messages
+ * from that remote endpoint will be received. Also, that remote endpoint
+ * is used as default when @c NULL is passed as destination to
+ * udp_assoc_send_msg.
+ *
+ * @a epp may specify a local link or address. If it does not, the association
+ * will listen on all local links/addresses. If @a epp does not specify
+ * a local port number, a free dynamic port number will be allocated.
+ *
+ * The caller is informed about incoming data by invoking @a cb->recv_msg
+ *
+ * @param udp    UDP client
+ * @param epp    Internet endpoint pair
+ * @param cb     Callbacks
+ * @param arg    Argument to callbacks
+ * @param rassoc Place to store pointer to new association
+ *
+ * @return EOK on success or negative error code.
+ */
+int udp_assoc_create(udp_t *udp, inet_ep2_t *epp, udp_cb_t *cb, void *arg,
     udp_assoc_t **rassoc)
 {
@@ -131,5 +173,5 @@
 	exch = async_exchange_begin(udp->sess);
 	aid_t req = async_send_0(exch, UDP_ASSOC_CREATE, &answer);
-	sysarg_t rc = async_data_write_start(exch, (void *)ep2,
+	sysarg_t rc = async_data_write_start(exch, (void *)epp,
 	    sizeof(inet_ep2_t));
 	async_exchange_end(exch);
@@ -161,4 +203,11 @@
 }
 
+/** Destroy UDP association.
+ *
+ * Destroy UDP association. The caller should destroy all associations
+ * he created before destroying the UDP client and before terminating.
+ *
+ * @param assoc UDP association
+ */
 void udp_assoc_destroy(udp_assoc_t *assoc)
 {
@@ -178,4 +227,13 @@
 }
 
+/** Send message via UDP association.
+ *
+ * @param assoc Association
+ * @param dest	Destination endpoint or @c NULL to use association's remote ep.
+ * @param data	Message data
+ * @param bytes Message size in bytes
+ *
+ * @return EOK on success or negative error code
+ */
 int udp_assoc_send_msg(udp_assoc_t *assoc, inet_ep_t *dest, void *data,
     size_t bytes)
@@ -211,4 +269,9 @@
 }
 
+/** Get the user/callback argument for an association.
+ *
+ * @param assoc UDP association
+ * @return User argument associated with association
+ */
 void *udp_assoc_userptr(udp_assoc_t *assoc)
 {
@@ -216,4 +279,13 @@
 }
 
+/** Get size of received message in bytes.
+ *
+ * Assuming jumbo messages can be received, the caller first needs to determine
+ * the size of the received message by calling this function, then they can
+ * read the message piece-wise using udp_rmsg_read().
+ *
+ * @param rmsg Received message
+ * @return Size of received message in bytes
+ */
 size_t udp_rmsg_size(udp_rmsg_t *rmsg)
 {
@@ -221,4 +293,13 @@
 }
 
+/** Read part of received message.
+ *
+ * @param rmsg  Received message
+ * @param off   Start offset
+ * @param buf   Buffer for storing data
+ * @param bsize Buffer size
+ *
+ * @return EOK on success or negative error code.
+ */
 int udp_rmsg_read(udp_rmsg_t *rmsg, size_t off, void *buf, size_t bsize)
 {
@@ -245,4 +326,12 @@
 }
 
+/** Get remote endpoint of received message.
+ *
+ * Place the remote endpoint (the one from which the message was supposedly
+ * sent) to @a ep.
+ *
+ * @param rmsg Received message
+ * @param ep   Place to store remote endpoint
+ */
 void udp_rmsg_remote_ep(udp_rmsg_t *rmsg, inet_ep_t *ep)
 {
@@ -250,4 +339,9 @@
 }
 
+/** Get type of received ICMP error message.
+ *
+ * @param rerr Received error message
+ * @return Error message type
+ */
 uint8_t udp_rerr_type(udp_rerr_t *rerr)
 {
@@ -255,4 +349,9 @@
 }
 
+/** Get code of received ICMP error message.
+ *
+ * @param rerr Received error message
+ * @return Error message code
+ */
 uint8_t udp_rerr_code(udp_rerr_t *rerr)
 {
@@ -260,4 +359,11 @@
 }
 
+/** Get information about the next received message from UDP service.
+ *
+ * @param udp  UDP client
+ * @param rmsg Place to store message information
+ *
+ * @return EOK on success or negative error code
+ */
 static int udp_rmsg_info(udp_t *udp, udp_rmsg_t *rmsg)
 {
@@ -288,4 +394,9 @@
 }
 
+/** Discard next received message in UDP service.
+ *
+ * @param udp UDP client
+ * @return EOK on success or negative error code
+ */
 static int udp_rmsg_discard(udp_t *udp)
 {
@@ -299,4 +410,12 @@
 }
 
+/** Get association based on its ID.
+ *
+ * @param udp    UDP client
+ * @param id     Association ID
+ * @param rassoc Place to store pointer to association
+ *
+ * @return EOK on success, EINVAL if no association with the given ID exists
+ */
 static int udp_assoc_get(udp_t *udp, sysarg_t id, udp_assoc_t **rassoc)
 {
@@ -311,4 +430,13 @@
 }
 
+/** Handle 'data' event, i.e. some message(s) arrived.
+ *
+ * For each received message, get information about it, call @c recv_msg
+ * callback and discard it.
+ *
+ * @param udp UDP client
+ * @param iid IPC message ID
+ * @param icall IPC message
+ */
 static void udp_ev_data(udp_t *udp, ipc_callid_t iid, ipc_call_t *icall)
 {
@@ -340,4 +468,10 @@
 }
 
+/** UDP service callback connection.
+ *
+ * @param iid Connect message ID
+ * @param icall Connect message
+ * @param arg Argument, UDP client
+ */
 static void udp_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
Index: uspace/lib/c/generic/inetcfg.c
===================================================================
--- uspace/lib/c/generic/inetcfg.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/inetcfg.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -120,10 +120,10 @@
 	assert(inetcfg_sess == NULL);
 	
-	rc = loc_service_get_id(SERVICE_NAME_INETCFG, &inet_svc,
+	rc = loc_service_get_id(SERVICE_NAME_INET, &inet_svc,
 	    IPC_FLAG_BLOCKING);
 	if (rc != EOK)
 		return ENOENT;
 	
-	inetcfg_sess = loc_service_connect(EXCHANGE_SERIALIZE, inet_svc,
+	inetcfg_sess = loc_service_connect(inet_svc, INTERFACE_INETCFG,
 	    IPC_FLAG_BLOCKING);
 	if (inetcfg_sess == NULL)
Index: uspace/lib/c/generic/inetping.c
===================================================================
--- uspace/lib/c/generic/inetping.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/inetping.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -53,10 +53,10 @@
 	inetping_ev_ops = ev_ops;
 
-	rc = loc_service_get_id(SERVICE_NAME_INETPING, &inetping_svc,
+	rc = loc_service_get_id(SERVICE_NAME_INET, &inetping_svc,
 	    IPC_FLAG_BLOCKING);
 	if (rc != EOK)
 		return ENOENT;
 
-	inetping_sess = loc_service_connect(EXCHANGE_SERIALIZE, inetping_svc,
+	inetping_sess = loc_service_connect(inetping_svc, INTERFACE_INETPING,
 	    IPC_FLAG_BLOCKING);
 	if (inetping_sess == NULL)
@@ -65,5 +65,8 @@
 	async_exch_t *exch = async_exchange_begin(inetping_sess);
 
-	rc = async_connect_to_me(exch, 0, 0, 0, inetping_cb_conn, NULL);
+	port_id_t port;
+	rc = async_create_callback_port(exch, INTERFACE_INETPING_CB, 0, 0,
+	    inetping_cb_conn, NULL, &port);
+	
 	async_exchange_end(exch);
 
Index: uspace/lib/c/generic/io/console.c
===================================================================
--- uspace/lib/c/generic/io/console.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/io/console.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -49,5 +49,5 @@
 		return NULL;
 	
-	ctrl->input_sess = fsession(EXCHANGE_SERIALIZE, ifile);
+	ctrl->input_sess = vfs_fsession(ifile, INTERFACE_CONSOLE);
 	if (!ctrl->input_sess) {
 		free(ctrl);
@@ -55,5 +55,5 @@
 	}
 	
-	ctrl->output_sess = fsession(EXCHANGE_SERIALIZE, ofile);
+	ctrl->output_sess = vfs_fsession(ofile, INTERFACE_CONSOLE);
 	if (!ctrl->output_sess) {
 		free(ctrl);
Index: uspace/lib/c/generic/io/input.c
===================================================================
--- uspace/lib/c/generic/io/input.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/io/input.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -58,5 +58,8 @@
 	async_exch_t *exch = async_exchange_begin(sess);
 
-	int rc = async_connect_to_me(exch, 0, 0, 0, input_cb_conn, input);
+	port_id_t port;
+	int rc = async_create_callback_port(exch, INTERFACE_INPUT_CB, 0, 0,
+	    input_cb_conn, input, &port);
+	
 	async_exchange_end(exch);
 
Index: uspace/lib/c/generic/io/io.c
===================================================================
--- uspace/lib/c/generic/io/io.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/io/io.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -231,5 +231,5 @@
 	if (stream->buf == NULL) {
 		errno = ENOMEM;
-		return -1;
+		return EOF;
 	}
 	
@@ -299,5 +299,6 @@
 }
 
-int fclose(FILE *stream)
+
+static int _fclose_nofree(FILE *stream)
 {
 	int rc = 0;
@@ -312,4 +313,16 @@
 	
 	list_remove(&stream->link);
+	
+	if (rc != 0) {
+		/* errno was set by close() */
+		return EOF;
+	}
+	
+	return 0;
+}
+
+int fclose(FILE *stream)
+{
+	int rc = _fclose_nofree(stream);
 	
 	if ((stream != &stdin_null)
@@ -318,12 +331,30 @@
 		free(stream);
 	
-	stream = NULL;
-	
-	if (rc != 0) {
-		/* errno was set by close() */
-		return EOF;
-	}
-	
-	return 0;
+	return rc;
+}
+
+FILE *freopen(const char *path, const char *mode, FILE *stream)
+{
+	FILE *nstr;
+	
+	if (path == NULL) {
+		/* Changing mode is not supported */
+		return NULL;
+	}
+	
+	(void) _fclose_nofree(stream);
+	nstr = fopen(path, mode);
+	if (nstr == NULL) {
+		free(stream);
+		return NULL;
+	}
+	
+	list_remove(&nstr->link);
+	*stream = *nstr;
+	list_append(&stream->link, &files);
+	
+	free(nstr);
+	
+	return stream;
 }
 
@@ -334,4 +365,7 @@
  * @param nmemb  Number of records to read.
  * @param stream Pointer to the stream.
+ *
+ * @return Number of elements successfully read. On error this is less than
+ *         nmemb, stream error indicator is set and errno is set.
  */
 static size_t _fread(void *buf, size_t size, size_t nmemb, FILE *stream)
@@ -348,9 +382,10 @@
 		ssize_t rd = read(stream->fd, buf + done, left);
 		
-		if (rd < 0)
+		if (rd < 0) {
+			/* errno was set by read() */
 			stream->error = true;
-		else if (rd == 0)
+		} else if (rd == 0) {
 			stream->eof = true;
-		else {
+		} else {
 			left -= rd;
 			done += rd;
@@ -367,4 +402,7 @@
  * @param nmemb  Number of records to write.
  * @param stream Pointer to the stream.
+ *
+ * @return Number of elements successfully written. On error this is less than
+ *         nmemb, stream error indicator is set and errno is set.
  */
 static size_t _fwrite(const void *buf, size_t size, size_t nmemb, FILE *stream)
@@ -372,4 +410,5 @@
 	size_t left;
 	size_t done;
+	int rc;
 
 	if (size == 0 || nmemb == 0)
@@ -381,15 +420,29 @@
 	while ((left > 0) && (!stream->error)) {
 		ssize_t wr;
+		size_t uwr;
 		
-		if (stream->kio)
-			wr = kio_write(buf + done, left);
-		else
+		if (stream->kio) {
+			uwr = 0;
+			rc = kio_write(buf + done, left, &uwr);
+			if (rc != EOK)
+				errno = rc;
+		} else {
 			wr = write(stream->fd, buf + done, left);
+			if (wr >= 0) {
+				uwr = (size_t)wr;
+				rc = EOK;
+			} else {
+				/* errno was set by write */
+				uwr = 0;
+				rc = errno;
+			}
+		}
 		
-		if (wr <= 0)
+		if (rc != EOK) {
+			/* errno was set above */
 			stream->error = true;
-		else {
-			left -= wr;
-			done += wr;
+		} else {
+			left -= uwr;
+			done += uwr;
 		}
 	}
@@ -401,5 +454,8 @@
 }
 
-/** Read some data in stream buffer. */
+/** Read some data in stream buffer.
+ *
+ * On error, stream error indicator is set and errno is set.
+ */
 static void _ffillbuf(FILE *stream)
 {
@@ -410,4 +466,5 @@
 	rc = read(stream->fd, stream->buf, stream->buf_size);
 	if (rc < 0) {
+		/* errno was set by read() */
 		stream->error = true;
 		return;
@@ -434,10 +491,21 @@
 
 	/* If buffer has prefetched read data, we need to seek back. */
-	if (bytes_used > 0 && stream->buf_state == _bs_read)
-		lseek(stream->fd, - (ssize_t) bytes_used, SEEK_CUR);
+	if (bytes_used > 0 && stream->buf_state == _bs_read) {
+		off64_t rc;
+		rc = lseek(stream->fd, - (ssize_t) bytes_used, SEEK_CUR);
+		if (rc == (off64_t)-1) {
+			/* errno was set by lseek */
+			stream->error = 1;
+			return;
+		}
+	}
 
 	/* If buffer has unwritten data, we need to write them out. */
-	if (bytes_used > 0 && stream->buf_state == _bs_write)
+	if (bytes_used > 0 && stream->buf_state == _bs_write) {
 		(void) _fwrite(stream->buf_tail, 1, bytes_used, stream);
+		/* On error stream error indicator and errno are set by _fwrite */
+		if (stream->error)
+			return;
+	}
 
 	stream->buf_head = stream->buf;
@@ -466,8 +534,19 @@
 		return 0;
 
+	bytes_left = size * nmemb;
+	total_read = 0;
+	dp = (uint8_t *) dest;
+
+	/* Bytes from ungetc() buffer */
+	while (stream->ungetc_chars > 0 && bytes_left > 0) {
+		*dp++ = stream->ungetc_buf[--stream->ungetc_chars];
+		++total_read;
+		--bytes_left;
+	}
+
 	/* If not buffered stream, read in directly. */
 	if (stream->btype == _IONBF) {
-		now = _fread(dest, size, nmemb, stream);
-		return now;
+		total_read += _fread(dest, 1, bytes_left, stream);
+		return total_read / size;
 	}
 
@@ -482,14 +561,12 @@
 	}
 
-	bytes_left = size * nmemb;
-	total_read = 0;
-	dp = (uint8_t *) dest;
-
 	while ((!stream->error) && (!stream->eof) && (bytes_left > 0)) {
 		if (stream->buf_head == stream->buf_tail)
 			_ffillbuf(stream);
 
-		if (stream->error || stream->eof)
+		if (stream->error || stream->eof) {
+			/* On error errno was set by _ffillbuf() */
 			break;
+		}
 
 		data_avail = stream->buf_head - stream->buf_tail;
@@ -546,5 +623,4 @@
 	if (stream->buf_state == _bs_read)
 		_fflushbuf(stream);
-
 
 	/* Perform lazy allocation of stream buffer. */
@@ -584,5 +660,6 @@
 			/* Only need to drain buffer. */
 			_fflushbuf(stream);
-			need_flush = false;
+			if (!stream->error)
+				need_flush = false;
 		}
 	}
@@ -618,5 +695,8 @@
 int fputs(const char *str, FILE *stream)
 {
-	return fwrite(str, str_size(str), 1, stream);
+	(void) fwrite(str, str_size(str), 1, stream);
+	if (ferror(stream))
+		return EOF;
+	return 0;
 }
 
@@ -674,14 +754,38 @@
 }
 
+int ungetc(int c, FILE *stream)
+{
+	if (c == EOF)
+		return EOF;
+
+	if (stream->ungetc_chars >= UNGETC_MAX)
+		return EOF;
+
+	stream->ungetc_buf[stream->ungetc_chars++] =
+	    (uint8_t)c;
+
+	stream->eof = false;
+	return (uint8_t)c;
+}
+
 int fseek(FILE *stream, off64_t offset, int whence)
 {
 	off64_t rc;
 
+	if (stream->error)
+		return EOF;
+
 	_fflushbuf(stream);
+	if (stream->error) {
+		/* errno was set by _fflushbuf() */
+		return EOF;
+	}
+
+	stream->ungetc_chars = 0;
 
 	rc = lseek(stream->fd, offset, whence);
 	if (rc == (off64_t) (-1)) {
-		/* errno has been set by lseek64. */
-		return -1;
+		/* errno has been set by lseek() */
+		return EOF;
 	}
 
@@ -692,6 +796,22 @@
 off64_t ftell(FILE *stream)
 {
+	off64_t pos;
+	
+	if (stream->error)
+		return EOF;
+	
 	_fflushbuf(stream);
-	return lseek(stream->fd, 0, SEEK_CUR);
+	if (stream->error) {
+		/* errno was set by _fflushbuf() */
+		return EOF;
+	}
+
+	pos = lseek(stream->fd, 0, SEEK_CUR);
+	if (pos == (off64_t) -1) {
+		/* errno was set by lseek */
+		return (off64_t) -1;
+	}
+	
+	return pos - stream->ungetc_chars;
 }
 
@@ -703,9 +823,16 @@
 int fflush(FILE *stream)
 {
+	if (stream->error)
+		return EOF;
+	
 	_fflushbuf(stream);
+	if (stream->error) {
+		/* errno was set by _fflushbuf() */
+		return EOF;
+	}
 	
 	if (stream->kio) {
 		kio_update();
-		return EOK;
+		return 0;
 	}
 	
@@ -716,8 +843,13 @@
 		 */
 		stream->need_sync = false;
-		return fsync(stream->fd);
-	}
-	
-	return ENOENT;
+		if (fsync(stream->fd) != 0) {
+			/* errno was set by fsync() */
+			return EOF;
+		}
+
+		return 0;
+	}
+	
+	return 0;
 }
 
@@ -742,5 +874,5 @@
 	if (stream->kio) {
 		errno = EBADF;
-		return -1;
+		return EOF;
 	}
 	
@@ -748,9 +880,9 @@
 }
 
-async_sess_t *fsession(exch_mgmt_t mgmt, FILE *stream)
+async_sess_t *vfs_fsession(FILE *stream, iface_t iface)
 {
 	if (stream->fd >= 0) {
 		if (stream->sess == NULL)
-			stream->sess = fd_session(mgmt, stream->fd);
+			stream->sess = vfs_fd_session(stream->fd, iface);
 		
 		return stream->sess;
@@ -760,5 +892,5 @@
 }
 
-int fhandle(FILE *stream, int *handle)
+int vfs_fhandle(FILE *stream, int *handle)
 {
 	if (stream->fd >= 0) {
Index: uspace/lib/c/generic/io/kio.c
===================================================================
--- uspace/lib/c/generic/io/kio.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/io/kio.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -43,12 +43,11 @@
 #include <io/printf_core.h>
 
-size_t kio_write(const void *buf, size_t size)
+int kio_write(const void *buf, size_t size, size_t *nwritten)
 {
-	ssize_t ret = (ssize_t) __SYSCALL3(SYS_KIO, KIO_WRITE, (sysarg_t) buf, size);
+	int rc = (int) __SYSCALL3(SYS_KIO, KIO_WRITE, (sysarg_t) buf, size);
 	
-	if (ret >= 0)
-		return (size_t) ret;
-	
-	return 0;
+	if (rc == EOK)
+		*nwritten = size;
+	return rc;
 }
 
@@ -84,5 +83,8 @@
 static int kio_vprintf_str_write(const char *str, size_t size, void *data)
 {
-	size_t wr = kio_write(str, size);
+	size_t wr;
+	
+	wr = 0;
+	(void) kio_write(str, size, &wr);
 	return str_nlength(str, wr);
 }
@@ -92,4 +94,5 @@
 	size_t offset = 0;
 	size_t chars = 0;
+	size_t wr;
 	
 	while (offset < size) {
@@ -98,5 +101,5 @@
 		
 		if (chr_encode(str[chars], buf, &sz, STR_BOUNDS(1)) == EOK)
-			kio_write(buf, sz);
+			kio_write(buf, sz, &wr);
 		
 		chars++;
Index: uspace/lib/c/generic/io/log.c
===================================================================
--- uspace/lib/c/generic/io/log.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/io/log.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -166,5 +166,6 @@
 		return ENOMEM;
 
-	logger_session = service_connect_blocking(EXCHANGE_SERIALIZE, SERVICE_LOGGER, LOGGER_INTERFACE_WRITER, 0);
+	logger_session = service_connect_blocking(SERVICE_LOGGER,
+	    INTERFACE_LOGGER_WRITER, 0);
 	if (logger_session == NULL) {
 		return ENOMEM;
Index: uspace/lib/c/generic/io/logctl.c
===================================================================
--- uspace/lib/c/generic/io/logctl.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/io/logctl.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -48,6 +48,6 @@
 
 	if (logger_session == NULL) {
-		logger_session = service_connect_blocking(EXCHANGE_SERIALIZE,
-		    SERVICE_LOGGER, LOGGER_INTERFACE_CONTROL, 0);
+		logger_session = service_connect_blocking(SERVICE_LOGGER,
+		    INTERFACE_LOGGER_CONTROL, 0);
 		if (logger_session == NULL)
 			return ENOMEM;
Index: uspace/lib/c/generic/iplink.c
===================================================================
--- uspace/lib/c/generic/iplink.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/iplink.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -59,6 +59,9 @@
 	
 	async_exch_t *exch = async_exchange_begin(sess);
-	
-	int rc = async_connect_to_me(exch, 0, 0, 0, iplink_cb_conn, iplink);
+
+	port_id_t port;
+	int rc = async_create_callback_port(exch, INTERFACE_IPLINK_CB, 0, 0,
+	    iplink_cb_conn, iplink, &port);
+	
 	async_exchange_end(exch);
 	
Index: uspace/lib/c/generic/irc.c
===================================================================
--- uspace/lib/c/generic/irc.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/irc.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -51,6 +51,5 @@
 	assert(irc_sess == NULL);
 
-	irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
-	    SERVICE_IRC, 0, 0);
+	irc_sess = service_connect_blocking(SERVICE_IRC, INTERFACE_IRC, 0);
 
 	if (irc_sess == NULL)
Index: uspace/lib/c/generic/loader.c
===================================================================
--- uspace/lib/c/generic/loader.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/loader.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -69,5 +69,5 @@
 	
 	async_sess_t *sess =
-	    service_connect_blocking(EXCHANGE_SERIALIZE, SERVICE_LOAD, 0, 0);
+	    service_connect_blocking(SERVICE_LOADER, INTERFACE_LOADER, 0);
 	if (sess == NULL) {
 		free(ldr);
@@ -124,5 +124,5 @@
 		return ENOMEM;
 	
-	if (!getcwd(cwd, MAX_PATH_LEN + 1))
+	if (getcwd(cwd, MAX_PATH_LEN + 1) == NULL)
 		str_cpy(cwd, MAX_PATH_LEN + 1, "/");
 	
@@ -162,5 +162,5 @@
 {
 	size_t pa_len;
-	char *pa = absolutize(path, &pa_len);
+	char *pa = vfs_absolutize(path, &pa_len);
 	if (!pa)
 		return ENOMEM;
Index: uspace/lib/c/generic/loc.c
===================================================================
--- uspace/lib/c/generic/loc.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/loc.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -107,9 +107,13 @@
 	if (!loc_callback_created) {
 		async_exch_t *exch =
-		    loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+		    loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 		
 		ipc_call_t answer;
 		aid_t req = async_send_0(exch, LOC_CALLBACK_CREATE, &answer);
-		int rc = async_connect_to_me(exch, 0, 0, 0, loc_cb_conn, NULL);
+		
+		port_id_t port;
+		int rc = async_create_callback_port(exch, INTERFACE_LOC_CB, 0, 0,
+		    loc_cb_conn, NULL, &port);
+		
 		loc_exchange_end(exch);
 		
@@ -135,8 +139,8 @@
  *
  */
-async_exch_t *loc_exchange_begin_blocking(loc_interface_t iface)
+async_exch_t *loc_exchange_begin_blocking(iface_t iface)
 {
 	switch (iface) {
-	case LOC_PORT_SUPPLIER:
+	case INTERFACE_LOC_SUPPLIER:
 		fibril_mutex_lock(&loc_supp_block_mutex);
 		
@@ -147,6 +151,6 @@
 			if (loc_supp_block_sess == NULL)
 				loc_supp_block_sess =
-				    service_connect_blocking(EXCHANGE_SERIALIZE,
-				    SERVICE_LOC, LOC_PORT_SUPPLIER, 0);
+				    service_connect_blocking(SERVICE_LOC,
+				    INTERFACE_LOC_SUPPLIER, 0);
 		}
 		
@@ -157,5 +161,5 @@
 		
 		return async_exchange_begin(loc_supp_block_sess);
-	case LOC_PORT_CONSUMER:
+	case INTERFACE_LOC_CONSUMER:
 		fibril_mutex_lock(&loc_cons_block_mutex);
 		
@@ -166,6 +170,6 @@
 			if (loc_cons_block_sess == NULL)
 				loc_cons_block_sess =
-				    service_connect_blocking(EXCHANGE_SERIALIZE,
-				    SERVICE_LOC, LOC_PORT_CONSUMER, 0);
+				    service_connect_blocking(SERVICE_LOC,
+				    INTERFACE_LOC_CONSUMER, 0);
 		}
 		
@@ -188,14 +192,14 @@
  *
  */
-async_exch_t *loc_exchange_begin(loc_interface_t iface)
+async_exch_t *loc_exchange_begin(iface_t iface)
 {
 	switch (iface) {
-	case LOC_PORT_SUPPLIER:
+	case INTERFACE_LOC_SUPPLIER:
 		fibril_mutex_lock(&loc_supplier_mutex);
 		
 		if (loc_supplier_sess == NULL)
 			loc_supplier_sess =
-			    service_connect(EXCHANGE_SERIALIZE, SERVICE_LOC,
-			    LOC_PORT_SUPPLIER, 0);
+			    service_connect(SERVICE_LOC,
+			    INTERFACE_LOC_SUPPLIER, 0);
 		
 		fibril_mutex_unlock(&loc_supplier_mutex);
@@ -205,11 +209,11 @@
 		
 		return async_exchange_begin(loc_supplier_sess);
-	case LOC_PORT_CONSUMER:
+	case INTERFACE_LOC_CONSUMER:
 		fibril_mutex_lock(&loc_consumer_mutex);
 		
 		if (loc_consumer_sess == NULL)
 			loc_consumer_sess =
-			    service_connect(EXCHANGE_SERIALIZE, SERVICE_LOC,
-			    LOC_PORT_CONSUMER, 0);
+			    service_connect(SERVICE_LOC,
+			    INTERFACE_LOC_CONSUMER, 0);
 		
 		fibril_mutex_unlock(&loc_consumer_mutex);
@@ -237,5 +241,5 @@
 int loc_server_register(const char *name)
 {
-	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_SUPPLIER);
+	async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_SUPPLIER);
 	
 	ipc_call_t answer;
@@ -250,6 +254,6 @@
 	}
 	
-	exch = loc_exchange_begin(LOC_PORT_SUPPLIER);
-	async_connect_to_me(exch, 0, 0, 0, NULL, NULL);
+	exch = loc_exchange_begin(INTERFACE_LOC_SUPPLIER);
+	async_connect_to_me(exch, 0, 0, 0);
 	loc_exchange_end(exch);
 	
@@ -260,24 +264,14 @@
 /** Register new service.
  *
- * The @p interface is used when forwarding connection to the server.
- * If not 0, the first argument is the interface and the second argument
- * is the service ID.
- *
- * When the interface is zero (default), the first argument is directly
- * the handle (to ensure backward compatibility).
- *
- * @param      fqsn      Fully qualified service name
- * @param[out] sid       Service ID of new service
- * @param      interface Interface when forwarding
- *
- */
-int loc_service_register_with_iface(const char *fqsn,
-    service_id_t *sid, sysarg_t interface)
-{
-	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_SUPPLIER);
+ * @param      fqsn  Fully qualified service name
+ * @param[out] sid   Service ID of new service
+ *
+ */
+int loc_service_register(const char *fqsn, service_id_t *sid)
+{
+	async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_SUPPLIER);
 	
 	ipc_call_t answer;
-	aid_t req = async_send_2(exch, LOC_SERVICE_REGISTER, interface, 0,
-	    &answer);
+	aid_t req = async_send_0(exch, LOC_SERVICE_REGISTER, &answer);
 	sysarg_t retval = async_data_write_start(exch, fqsn, str_size(fqsn));
 	
@@ -304,15 +298,4 @@
 }
 
-/** Register new service.
- *
- * @param fqsn Fully qualified service name
- * @param sid  Output: ID of new service
- *
- */
-int loc_service_register(const char *fqdn, service_id_t *sid)
-{
-	return loc_service_register_with_iface(fqdn, sid, 0);
-}
-
 /** Unregister service.
  *
@@ -324,5 +307,5 @@
 	sysarg_t retval;
 	
-	exch = loc_exchange_begin_blocking(LOC_PORT_SUPPLIER);
+	exch = loc_exchange_begin_blocking(INTERFACE_LOC_SUPPLIER);
 	retval = async_req_1_0(exch, LOC_SERVICE_UNREGISTER, sid);
 	loc_exchange_end(exch);
@@ -337,7 +320,7 @@
 	
 	if (flags & IPC_FLAG_BLOCKING)
-		exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+		exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 	else {
-		exch = loc_exchange_begin(LOC_PORT_CONSUMER);
+		exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER);
 		if (exch == NULL)
 			return errno;
@@ -390,5 +373,5 @@
 	
 	*name = NULL;
-	exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 	
 	ipc_call_t answer;
@@ -470,7 +453,7 @@
 	
 	if (flags & IPC_FLAG_BLOCKING)
-		exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+		exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 	else {
-		exch = loc_exchange_begin(LOC_PORT_CONSUMER);
+		exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER);
 		if (exch == NULL)
 			return errno;
@@ -519,7 +502,7 @@
 	
 	if (flags & IPC_FLAG_BLOCKING)
-		exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+		exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 	else {
-		exch = loc_exchange_begin(LOC_PORT_CONSUMER);
+		exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER);
 		if (exch == NULL)
 			return errno;
@@ -556,5 +539,5 @@
 loc_object_type_t loc_id_probe(service_id_t handle)
 {
-	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 	
 	sysarg_t type;
@@ -569,5 +552,5 @@
 }
 
-async_sess_t *loc_service_connect(exch_mgmt_t mgmt, service_id_t handle,
+async_sess_t *loc_service_connect(service_id_t handle, iface_t iface,
     unsigned int flags)
 {
@@ -575,9 +558,7 @@
 	
 	if (flags & IPC_FLAG_BLOCKING)
-		sess = service_connect_blocking(mgmt, SERVICE_LOC,
-		    LOC_CONNECT_TO_SERVICE, handle);
+		sess = service_connect_blocking(SERVICE_LOC, iface, handle);
 	else
-		sess = service_connect(mgmt, SERVICE_LOC,
-		    LOC_CONNECT_TO_SERVICE, handle);
+		sess = service_connect(SERVICE_LOC, iface, handle);
 	
 	return sess;
@@ -586,5 +567,5 @@
 int loc_null_create(void)
 {
-	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 	
 	sysarg_t null_id;
@@ -601,5 +582,5 @@
 void loc_null_destroy(int null_id)
 {
-	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 	async_req_1_0(exch, LOC_NULL_DESTROY, (sysarg_t) null_id);
 	loc_exchange_end(exch);
@@ -627,5 +608,5 @@
 	sysarg_t retval;
 	
-	exch = loc_exchange_begin_blocking(LOC_PORT_SUPPLIER);
+	exch = loc_exchange_begin_blocking(INTERFACE_LOC_SUPPLIER);
 	retval = async_req_2_0(exch, LOC_SERVICE_ADD_TO_CAT, svc_id, cat_id);
 	loc_exchange_end(exch);
@@ -648,5 +629,5 @@
 size_t loc_count_namespaces(void)
 {
-	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 	size_t size = loc_count_namespaces_internal(exch);
 	loc_exchange_end(exch);
@@ -657,5 +638,5 @@
 size_t loc_count_services(service_id_t ns_handle)
 {
-	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 	size_t size = loc_count_services_internal(exch, ns_handle);
 	loc_exchange_end(exch);
@@ -668,5 +649,5 @@
 	/* Loop until read is succesful */
 	while (true) {
-		async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+		async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 		size_t count = loc_count_namespaces_internal(exch);
 		loc_exchange_end(exch);
@@ -679,5 +660,5 @@
 			return 0;
 		
-		exch = loc_exchange_begin(LOC_PORT_CONSUMER);
+		exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER);
 		
 		ipc_call_t answer;
@@ -717,5 +698,5 @@
 	/* Loop until read is succesful */
 	while (true) {
-		async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+		async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 		size_t count = loc_count_services_internal(exch, ns_handle);
 		loc_exchange_end(exch);
@@ -728,5 +709,5 @@
 			return 0;
 		
-		exch = loc_exchange_begin(LOC_PORT_CONSUMER);
+		exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER);
 		
 		ipc_call_t answer;
@@ -765,5 +746,5 @@
     sysarg_t *id_buf, size_t buf_size, size_t *act_size)
 {
-	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
 
 	ipc_call_t answer;
Index: uspace/lib/c/generic/ns.c
===================================================================
--- uspace/lib/c/generic/ns.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/ns.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -40,8 +40,8 @@
 #include "private/ns.h"
 
-int service_register(sysarg_t service)
+int service_register(service_t service)
 {
 	async_exch_t *exch = async_exchange_begin(session_ns);
-	int rc = async_connect_to_me(exch, service, 0, 0, NULL, NULL);
+	int rc = async_connect_to_me(exch, 0, service, 0);
 	async_exchange_end(exch);
 	
@@ -49,6 +49,6 @@
 }
 
-async_sess_t *service_connect(exch_mgmt_t mgmt, services_t service, sysarg_t arg2,
-    sysarg_t arg3)
+
+async_sess_t *service_connect(service_t service, iface_t iface, sysarg_t arg3)
 {
 	async_exch_t *exch = async_exchange_begin(session_ns);
@@ -57,5 +57,5 @@
 	
 	async_sess_t *sess =
-	    async_connect_me_to(mgmt, exch, service, arg2, arg3);
+	    async_connect_me_to_iface(exch, iface, service, arg3);
 	async_exchange_end(exch);
 	
@@ -68,17 +68,15 @@
 	 * first argument for non-initial connections.
 	 */
-	async_sess_args_set(sess, arg2, arg3, 0);
+	async_sess_args_set(sess, iface, arg3, 0);
 	
 	return sess;
 }
 
-async_sess_t *service_connect_blocking(exch_mgmt_t mgmt, services_t service,
-    sysarg_t arg2, sysarg_t arg3)
+async_sess_t *service_connect_blocking(service_t service, iface_t iface,
+    sysarg_t arg3)
 {
 	async_exch_t *exch = async_exchange_begin(session_ns);
-	if (!exch)
-		return NULL;
 	async_sess_t *sess =
-	    async_connect_me_to_blocking(mgmt, exch, service, arg2, arg3);
+	    async_connect_me_to_blocking_iface(exch, iface, service, arg3);
 	async_exchange_end(exch);
 	
@@ -91,43 +89,9 @@
 	 * first argument for non-initial connections.
 	 */
-	async_sess_args_set(sess, arg2, arg3, 0);
+	async_sess_args_set(sess, iface, arg3, 0);
 	
 	return sess;
 }
 
-/** Create bidirectional connection with a service
- *
- * @param[in] service         Service.
- * @param[in] arg1            First parameter.
- * @param[in] arg2            Second parameter.
- * @param[in] arg3            Third parameter.
- * @param[in] client_receiver Message receiver.
- *
- * @return Session to the service.
- * @return Other error codes as defined by async_connect_to_me().
- *
- */
-async_sess_t *service_bind(services_t service, sysarg_t arg1, sysarg_t arg2,
-    sysarg_t arg3, async_client_conn_t client_receiver)
-{
-	/* Connect to the needed service */
-	async_sess_t *sess =
-	    service_connect_blocking(EXCHANGE_SERIALIZE, service, 0, 0);
-	if (sess != NULL) {
-		/* Request callback connection */
-		async_exch_t *exch = async_exchange_begin(sess);
-		int rc = async_connect_to_me(exch, arg1, arg2, arg3,
-		    client_receiver, NULL);
-		async_exchange_end(exch);
-		
-		if (rc != EOK) {
-			async_hangup(sess);
-			errno = rc;
-			return NULL;
-		}
-	}
-	
-	return sess;
-}
 
 int ns_ping(void)
Index: uspace/lib/c/generic/private/stdio.h
===================================================================
--- uspace/lib/c/generic/private/stdio.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/private/stdio.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -39,4 +39,7 @@
 #include <stdio.h>
 #include <async.h>
+
+/** Maximum characters that can be pushed back by ungetc() */
+#define UNGETC_MAX 1
 
 struct _IO_FILE {
@@ -82,4 +85,10 @@
 	/** Points to end of occupied space when in read mode. */
 	uint8_t *buf_tail;
+
+	/** Pushed back characters */
+	uint8_t ungetc_buf[UNGETC_MAX];
+
+	/** Number of pushed back characters */
+	int ungetc_chars;
 };
 
Index: uspace/lib/c/generic/task.c
===================================================================
--- uspace/lib/c/generic/task.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/task.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -112,15 +112,15 @@
 	int fd_stderr;
 	
-	if ((stdin != NULL) && (fhandle(stdin, &fd_stdin) == EOK))
+	if ((stdin != NULL) && (vfs_fhandle(stdin, &fd_stdin) == EOK))
 		files[0] = &fd_stdin;
 	else
 		files[0] = NULL;
 	
-	if ((stdout != NULL) && (fhandle(stdout, &fd_stdout) == EOK))
+	if ((stdout != NULL) && (vfs_fhandle(stdout, &fd_stdout) == EOK))
 		files[1] = &fd_stdout;
 	else
 		files[1] = NULL;
 	
-	if ((stderr != NULL) && (fhandle(stderr, &fd_stderr) == EOK))
+	if ((stderr != NULL) && (vfs_fhandle(stderr, &fd_stderr) == EOK))
 		files[2] = &fd_stderr;
 	else
Index: uspace/lib/c/generic/time.c
===================================================================
--- uspace/lib/c/generic/time.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/time.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -611,6 +611,6 @@
 			goto fallback;
 		
-		clock_conn = loc_service_connect(EXCHANGE_SERIALIZE,
-		    svc_id, IPC_FLAG_BLOCKING);
+		clock_conn = loc_service_connect(svc_id, INTERFACE_DDF,
+		    IPC_FLAG_BLOCKING);
 		if (!clock_conn)
 			goto fallback;
Index: uspace/lib/c/generic/vbd.c
===================================================================
--- uspace/lib/c/generic/vbd.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/vbd.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -33,4 +33,5 @@
  */
 
+#include <abi/ipc/interfaces.h>
 #include <errno.h>
 #include <ipc/services.h>
@@ -65,5 +66,5 @@
 	}
 
-	vbd->sess = loc_service_connect(EXCHANGE_SERIALIZE, vbd_svcid,
+	vbd->sess = loc_service_connect(vbd_svcid, INTERFACE_VBD,
 	    IPC_FLAG_BLOCKING);
 	if (vbd->sess == NULL) {
Index: uspace/lib/c/generic/vfs/vfs.c
===================================================================
--- uspace/lib/c/generic/vfs/vfs.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/vfs/vfs.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -75,6 +75,6 @@
 	
 	while (vfs_sess == NULL)
-		vfs_sess = service_connect_blocking(EXCHANGE_PARALLEL, SERVICE_VFS,
-		    0, 0);
+		vfs_sess = service_connect_blocking(SERVICE_VFS, INTERFACE_VFS,
+		    0);
 	
 	fibril_mutex_unlock(&vfs_mutex);
@@ -93,5 +93,5 @@
 }
 
-char *absolutize(const char *path, size_t *retlen)
+char *vfs_absolutize(const char *path, size_t *retlen)
 {
 	char *ncwd_path;
@@ -101,10 +101,10 @@
 	size_t size = str_size(path);
 	if (*path != '/') {
-		if (!cwd_path) {
+		if (cwd_path == NULL) {
 			fibril_mutex_unlock(&cwd_mutex);
 			return NULL;
 		}
 		ncwd_path_nc = malloc(cwd_size + 1 + size + 1);
-		if (!ncwd_path_nc) {
+		if (ncwd_path_nc == NULL) {
 			fibril_mutex_unlock(&cwd_mutex);
 			return NULL;
@@ -115,5 +115,5 @@
 	} else {
 		ncwd_path_nc = malloc(size + 1);
-		if (!ncwd_path_nc) {
+		if (ncwd_path_nc == NULL) {
 			fibril_mutex_unlock(&cwd_mutex);
 			return NULL;
@@ -123,5 +123,5 @@
 	str_append(ncwd_path_nc, cwd_size + 1 + size + 1, path);
 	ncwd_path = canonify(ncwd_path_nc, retlen);
-	if (!ncwd_path) {
+	if (ncwd_path == NULL) {
 		fibril_mutex_unlock(&cwd_mutex);
 		free(ncwd_path_nc);
@@ -135,5 +135,5 @@
 	ncwd_path = str_dup(ncwd_path);
 	free(ncwd_path_nc);
-	if (!ncwd_path) {
+	if (ncwd_path == NULL) {
 		fibril_mutex_unlock(&cwd_mutex);
 		return NULL;
@@ -143,5 +143,5 @@
 }
 
-int mount(const char *fs_name, const char *mp, const char *fqsn,
+int vfs_mount(const char *fs_name, const char *mp, const char *fqsn,
     const char *opts, unsigned int flags, unsigned int instance)
 {
@@ -171,6 +171,6 @@
 	
 	size_t mpa_size;
-	char *mpa = absolutize(mp, &mpa_size);
-	if (!mpa) {
+	char *mpa = vfs_absolutize(mp, &mpa_size);
+	if (mpa == NULL) {
 		if (null_id != -1)
 			loc_null_destroy(null_id);
@@ -255,5 +255,5 @@
 }
 
-int unmount(const char *mp)
+int vfs_unmount(const char *mp)
 {
 	sysarg_t rc;
@@ -263,6 +263,6 @@
 	char *mpa;
 	
-	mpa = absolutize(mp, &mpa_size);
-	if (!mpa)
+	mpa = vfs_absolutize(mp, &mpa_size);
+	if (mpa == NULL)
 		return ENOMEM;
 	
@@ -289,5 +289,16 @@
 }
 
-static int open_internal(const char *abs, size_t abs_size, int lflag, int oflag)
+/** Open file (internal).
+ *
+ * @param abs Absolute path to file
+ * @param abs_size Size of @a abs string
+ * @param lflag L_xxx flags
+ * @param oflag O_xxx flags
+ * @param fd Place to store new file descriptor
+ *
+ * @return EOK on success, non-zero error code on error
+ */
+static int open_internal(const char *abs, size_t abs_size, int lflag, int oflag,
+    int *fd)
 {
 	async_exch_t *exch = vfs_exchange_begin();
@@ -315,20 +326,44 @@
 	    return (int) rc;
 	
-	return (int) IPC_GET_ARG1(answer);
-}
-
+	*fd = (int) IPC_GET_ARG1(answer);
+	return EOK;
+}
+
+/** Open file.
+ *
+ * @param path File path
+ * @param oflag O_xxx flags
+ * @param mode File mode (only with O_CREAT)
+ *
+ * @return Nonnegative file descriptor on success. On error -1 is returned
+ *         and errno is set.
+ */
 int open(const char *path, int oflag, ...)
 {
 	size_t abs_size;
-	char *abs = absolutize(path, &abs_size);
-	if (!abs)
-		return ENOMEM;
-	
-	int ret = open_internal(abs, abs_size, L_FILE, oflag);
+	char *abs = vfs_absolutize(path, &abs_size);
+	int fd = -1;
+	
+	if (abs == NULL) {
+		errno = ENOMEM;
+		return -1;
+	}
+	
+	int rc = open_internal(abs, abs_size, L_FILE, oflag, &fd);
 	free(abs);
 	
-	return ret;
-}
-
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+	
+	return fd;
+}
+
+/** Close file.
+ *
+ * @param fildes File descriptor
+ * @return Zero on success. On error -1 is returned and errno is set.
+ */
 int close(int fildes)
 {
@@ -339,8 +374,27 @@
 	vfs_exchange_end(exch);
 	
-	return (int) rc;
-}
-
-ssize_t read(int fildes, void *buf, size_t nbyte)
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+	
+	return 0;
+}
+
+/** Read bytes from file.
+ *
+ * Read up to @a nbyte bytes from file. The actual number of bytes read
+ * may be lower, but greater than zero if there are any bytes available.
+ * If there are no bytes available for reading, then the function will
+ * return success with zero bytes read.
+ *
+ * @param fildes File descriptor
+ * @param buf Buffer
+ * @param nbyte Maximum number of bytes to read
+ * @param nread Place to store actual number of bytes read (0 or more)
+ *
+ * @return EOK on success, non-zero error code on error.
+ */
+static int _read_short(int fildes, void *buf, size_t nbyte, ssize_t *nread)
 {
 	sysarg_t rc;
@@ -357,22 +411,38 @@
 	if (rc != EOK) {
 		vfs_exchange_end(exch);
-
+		
 		sysarg_t rc_orig;
 		async_wait_for(req, &rc_orig);
-
+		
 		if (rc_orig == EOK)
-			return (ssize_t) rc;
+			return rc;
 		else
-			return (ssize_t) rc_orig;
-	}
+			return rc_orig;
+	}
+	
 	vfs_exchange_end(exch);
 	async_wait_for(req, &rc);
-	if (rc == EOK)
-		return (ssize_t) IPC_GET_ARG1(answer);
-	else
+	
+	if (rc != EOK)
 		return rc;
-}
-
-ssize_t write(int fildes, const void *buf, size_t nbyte) 
+	
+	*nread = (ssize_t) IPC_GET_ARG1(answer);
+	return EOK;
+}
+
+/** Write bytes to file.
+ *
+ * Write up to @a nbyte bytes from file. The actual number of bytes written
+ * may be lower, but greater than zero.
+ *
+ * @param fildes File descriptor
+ * @param buf Buffer
+ * @param nbyte Maximum number of bytes to write
+ * @param nread Place to store actual number of bytes written (0 or more)
+ *
+ * @return EOK on success, non-zero error code on error.
+ */
+static int _write_short(int fildes, const void *buf, size_t nbyte,
+    ssize_t *nwritten)
 {
 	sysarg_t rc;
@@ -389,25 +459,28 @@
 	if (rc != EOK) {
 		vfs_exchange_end(exch);
-
+		
 		sysarg_t rc_orig;
 		async_wait_for(req, &rc_orig);
-
+		
 		if (rc_orig == EOK)
-			return (ssize_t) rc;
+			return rc;
 		else
-			return (ssize_t) rc_orig;
-	}
+			return rc_orig;
+	}
+	
 	vfs_exchange_end(exch);
 	async_wait_for(req, &rc);
-	if (rc == EOK)
-		return (ssize_t) IPC_GET_ARG1(answer);
-	else
-		return -1;
-}
-
-/** Read entire buffer.
- *
- * In face of short reads this function continues reading until either
- * the entire buffer is read or no more data is available (at end of file).
+	
+	if (rc != EOK)
+		return rc;
+	
+	*nwritten = (ssize_t) IPC_GET_ARG1(answer);
+	return EOK;
+}
+
+/** Read data.
+ *
+ * Read up to @a nbytes bytes from file if available. This function always reads
+ * all the available bytes up to @a nbytes.
  *
  * @param fildes	File descriptor
@@ -415,26 +488,29 @@
  * @param nbytes	Number of bytes to read
  *
- * @return		On success, positive number of bytes read.
- *			On failure, negative error code from read().
- */
-ssize_t read_all(int fildes, void *buf, size_t nbyte)
+ * @return		On success, nonnegative number of bytes read.
+ *			On failure, -1 and sets errno.
+ */
+ssize_t read(int fildes, void *buf, size_t nbyte)
 {
 	ssize_t cnt = 0;
 	size_t nread = 0;
 	uint8_t *bp = (uint8_t *) buf;
-
+	int rc;
+	
 	do {
 		bp += cnt;
 		nread += cnt;
-		cnt = read(fildes, bp, nbyte - nread);
-	} while (cnt > 0 && (nbyte - nread - cnt) > 0);
-
-	if (cnt < 0)
-		return cnt;
-
+		rc = _read_short(fildes, bp, nbyte - nread, &cnt);
+	} while (rc == EOK && cnt > 0 && (nbyte - nread - cnt) > 0);
+	
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+	
 	return nread + cnt;
 }
 
-/** Write entire buffer.
+/** Write data.
  *
  * This function fails if it cannot write exactly @a len bytes to the file.
@@ -444,28 +520,33 @@
  * @param nbytes	Number of bytes to write
  *
- * @return		EOK on error, return value from write() if writing
- *			failed.
- */
-ssize_t write_all(int fildes, const void *buf, size_t nbyte)
+ * @return		On success, nonnegative number of bytes written.
+ *			On failure, -1 and sets errno.
+ */
+ssize_t write(int fildes, const void *buf, size_t nbyte)
 {
 	ssize_t cnt = 0;
 	ssize_t nwritten = 0;
 	const uint8_t *bp = (uint8_t *) buf;
+	int rc;
 
 	do {
 		bp += cnt;
 		nwritten += cnt;
-		cnt = write(fildes, bp, nbyte - nwritten);
-	} while (cnt > 0 && ((ssize_t )nbyte - nwritten - cnt) > 0);
-
-	if (cnt < 0)
-		return cnt;
-
-	if ((ssize_t)nbyte - nwritten - cnt > 0)
-		return EIO;
+		rc = _write_short(fildes, bp, nbyte - nwritten, &cnt);
+	} while (rc == EOK && ((ssize_t )nbyte - nwritten - cnt) > 0);
+
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
 
 	return nbyte;
 }
 
+/** Synchronize file.
+ *
+ * @param fildes File descriptor
+ * @return 0 on success. On error returns -1 and sets errno.
+ */
 int fsync(int fildes)
 {
@@ -474,7 +555,21 @@
 	vfs_exchange_end(exch);
 	
-	return (int) rc;
-}
-
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+	
+	return 0;
+}
+
+/** Seek to a position.
+ *
+ * @param fildes File descriptor
+ * @param offset Offset
+ * @param whence SEEK_SET, SEEK_CUR or SEEK_END
+ *
+ * @return On success the nonnegative offset from start of file. On error
+ *         returns (off64_t)-1 and sets errno.
+ */
 off64_t lseek(int fildes, off64_t offset, int whence)
 {
@@ -489,10 +584,21 @@
 	vfs_exchange_end(exch);
 	
-	if (rc != EOK)
+	if (rc != EOK) {
+		errno = rc;
 		return (off64_t) -1;
+	}
 	
 	return (off64_t) MERGE_LOUP32(newoff_lo, newoff_hi);
 }
 
+/** Truncate file to a specified length.
+ *
+ * Truncate file so that its size is exactly @a length
+ *
+ * @param fildes File descriptor
+ * @param length Length
+ *
+ * @return 0 on success, -1 on error and sets errno.
+ */
 int ftruncate(int fildes, aoff64_t length)
 {
@@ -504,7 +610,19 @@
 	vfs_exchange_end(exch);
 	
-	return (int) rc;
-}
-
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+	
+	return 0;
+}
+
+/** Get file status.
+ *
+ * @param fildes File descriptor
+ * @param stat Place to store file information
+ *
+ * @return 0 on success, -1 on error and sets errno.
+ */
 int fstat(int fildes, struct stat *stat)
 {
@@ -518,19 +636,36 @@
 	if (rc != EOK) {
 		vfs_exchange_end(exch);
-
+		
 		sysarg_t rc_orig;
 		async_wait_for(req, &rc_orig);
-
-		if (rc_orig == EOK)
-			return (ssize_t) rc;
-		else
-			return (ssize_t) rc_orig;
-	}
+		
+		if (rc_orig != EOK)
+			rc = rc_orig;
+		if (rc != EOK) {
+			errno = rc;
+			return -1;
+		}
+		
+		return 0;
+	}
+	
 	vfs_exchange_end(exch);
 	async_wait_for(req, &rc);
-
-	return rc;
-}
-
+	
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+	
+	return 0;
+}
+
+/** Get file status.
+ *
+ * @param path Path to file
+ * @param stat Place to store file information
+ *
+ * @return 0 on success, -1 on error and sets errno.
+ */
 int stat(const char *path, struct stat *stat)
 {
@@ -540,7 +675,9 @@
 	
 	size_t pa_size;
-	char *pa = absolutize(path, &pa_size);
-	if (!pa)
-		return ENOMEM;
+	char *pa = vfs_absolutize(path, &pa_size);
+	if (pa == NULL) {
+		errno = ENOMEM;
+		return -1;
+	}
 	
 	async_exch_t *exch = vfs_exchange_begin();
@@ -552,4 +689,195 @@
 		free(pa);
 		async_wait_for(req, &rc_orig);
+		if (rc_orig != EOK)
+			rc = rc_orig;
+		if (rc != EOK) {
+			errno = rc;
+			return -1;
+		}
+	}
+	rc = async_data_read_start(exch, stat, sizeof(struct stat));
+	if (rc != EOK) {
+		vfs_exchange_end(exch);
+		free(pa);
+		async_wait_for(req, &rc_orig);
+		if (rc_orig != EOK)
+			rc = rc_orig;
+		if (rc != EOK) {
+			errno = rc;
+			return -1;
+		}
+	}
+	vfs_exchange_end(exch);
+	free(pa);
+	async_wait_for(req, &rc);
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+	return 0;
+}
+
+/** Open directory.
+ *
+ * @param dirname Directory pathname
+ *
+ * @return Non-NULL pointer on success. On error returns @c NULL and sets errno.
+ */
+DIR *opendir(const char *dirname)
+{
+	DIR *dirp = malloc(sizeof(DIR));
+	int fd = -1;
+	
+	if (dirp == NULL) {
+		errno = ENOMEM;
+		return NULL;
+	}
+	
+	size_t abs_size;
+	char *abs = vfs_absolutize(dirname, &abs_size);
+	if (abs == NULL) {
+		free(dirp);
+		errno = ENOMEM;
+		return NULL;
+	}
+	
+	int rc = open_internal(abs, abs_size, L_DIRECTORY, 0, &fd);
+	free(abs);
+	
+	if (rc != EOK) {
+		free(dirp);
+		errno = rc;
+		return NULL;
+	}
+	
+	dirp->fd = fd;
+	return dirp;
+}
+
+/** Read directory entry.
+ *
+ * @param dirp Open directory
+ * @return Non-NULL pointer to directory entry on success. On error returns
+ *         @c NULL and sets errno.
+ */
+struct dirent *readdir(DIR *dirp)
+{
+	int rc;
+	ssize_t len;
+	
+	rc = _read_short(dirp->fd, &dirp->res.d_name[0], NAME_MAX + 1, &len);
+	if (rc != EOK) {
+		errno = rc;
+		return NULL;
+	}
+	
+	(void) len;
+	return &dirp->res;
+}
+
+/** Rewind directory position to the beginning.
+ *
+ * @param dirp Open directory
+ */
+void rewinddir(DIR *dirp)
+{
+	(void) lseek(dirp->fd, 0, SEEK_SET);
+}
+
+/** Close directory.
+ *
+ * @param dirp Open directory
+ * @return 0 on success. On error returns -1 and sets errno.
+ */
+int closedir(DIR *dirp)
+{
+	int rc;
+	
+	rc = close(dirp->fd);
+	free(dirp);
+
+	/* On error errno was set by close() */
+	return rc;
+}
+
+/** Create directory.
+ *
+ * @param path Path
+ * @param mode File mode
+ * @return 0 on success. On error returns -1 and sets errno.
+ */
+int mkdir(const char *path, mode_t mode)
+{
+	sysarg_t rc;
+	aid_t req;
+	
+	size_t pa_size;
+	char *pa = vfs_absolutize(path, &pa_size);
+	if (pa == NULL) {
+		errno = ENOMEM;
+		return -1;
+	}
+	
+	async_exch_t *exch = vfs_exchange_begin();
+	
+	req = async_send_1(exch, VFS_IN_MKDIR, mode, NULL);
+	rc = async_data_write_start(exch, pa, pa_size);
+	if (rc != EOK) {
+		vfs_exchange_end(exch);
+		free(pa);
+		
+		sysarg_t rc_orig;
+		async_wait_for(req, &rc_orig);
+		
+		if (rc_orig != EOK)
+			rc = rc_orig;
+		
+		if (rc != EOK) {
+			errno = rc;
+			return -1;
+		}
+		
+		return 0;
+	}
+	
+	vfs_exchange_end(exch);
+	free(pa);
+	async_wait_for(req, &rc);
+	
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+	
+	return 0;
+}
+
+/** Unlink a file or directory.
+ *
+ * @param path Path to file or empty directory
+ * @param lflag L_xxx flag (L_NONE, L_FILE or L_DIRECTORY)
+ * @return EOK on success, non-zero error code on error
+ */
+static int _unlink(const char *path, int lflag)
+{
+	sysarg_t rc;
+	aid_t req;
+	
+	size_t pa_size;
+	char *pa = vfs_absolutize(path, &pa_size);
+	if (pa == NULL)
+		return ENOMEM;
+	
+	async_exch_t *exch = vfs_exchange_begin();
+	
+	req = async_send_1(exch, VFS_IN_UNLINK, lflag, NULL);
+	rc = async_data_write_start(exch, pa, pa_size);
+	if (rc != EOK) {
+		vfs_exchange_end(exch);
+		free(pa);
+
+		sysarg_t rc_orig;
+		async_wait_for(req, &rc_orig);
+
 		if (rc_orig == EOK)
 			return (int) rc;
@@ -557,14 +885,4 @@
 			return (int) rc_orig;
 	}
-	rc = async_data_read_start(exch, stat, sizeof(struct stat));
-	if (rc != EOK) {
-		vfs_exchange_end(exch);
-		free(pa);
-		async_wait_for(req, &rc_orig);
-		if (rc_orig == EOK)
-			return (int) rc;
-		else
-			return (int) rc_orig;
-	}
 	vfs_exchange_end(exch);
 	free(pa);
@@ -573,123 +891,47 @@
 }
 
-DIR *opendir(const char *dirname)
-{
-	DIR *dirp = malloc(sizeof(DIR));
-	if (!dirp)
-		return NULL;
-	
-	size_t abs_size;
-	char *abs = absolutize(dirname, &abs_size);
-	if (!abs) {
-		free(dirp);
-		return NULL;
-	}
-	
-	int ret = open_internal(abs, abs_size, L_DIRECTORY, 0);
-	free(abs);
-	
-	if (ret < 0) {
-		free(dirp);
-		return NULL;
-	}
-	
-	dirp->fd = ret;
-	return dirp;
-}
-
-struct dirent *readdir(DIR *dirp)
-{
-	ssize_t len = read(dirp->fd, &dirp->res.d_name[0], NAME_MAX + 1);
-	if (len <= 0)
-		return NULL;
-	return &dirp->res;
-}
-
-void rewinddir(DIR *dirp)
-{
-	(void) lseek(dirp->fd, 0, SEEK_SET);
-}
-
-int closedir(DIR *dirp)
-{
-	(void) close(dirp->fd);
-	free(dirp);
+/** Unlink file or directory.
+ *
+ * @param path Path
+ * @return EOk on success, error code on error
+ */
+int unlink(const char *path)
+{
+	int rc;
+
+	rc = _unlink(path, L_NONE);
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+
 	return 0;
 }
 
-int mkdir(const char *path, mode_t mode)
-{
-	sysarg_t rc;
-	aid_t req;
-	
-	size_t pa_size;
-	char *pa = absolutize(path, &pa_size);
-	if (!pa)
-		return ENOMEM;
-	
-	async_exch_t *exch = vfs_exchange_begin();
-	
-	req = async_send_1(exch, VFS_IN_MKDIR, mode, NULL);
-	rc = async_data_write_start(exch, pa, pa_size);
-	if (rc != EOK) {
-		vfs_exchange_end(exch);
-		free(pa);
-
-		sysarg_t rc_orig;
-		async_wait_for(req, &rc_orig);
-
-		if (rc_orig == EOK)
-			return (int) rc;
-		else
-			return (int) rc_orig;
-	}
-	vfs_exchange_end(exch);
-	free(pa);
-	async_wait_for(req, &rc);
-	return rc;
-}
-
-static int _unlink(const char *path, int lflag)
-{
-	sysarg_t rc;
-	aid_t req;
-	
-	size_t pa_size;
-	char *pa = absolutize(path, &pa_size);
-	if (!pa)
-		return ENOMEM;
-	
-	async_exch_t *exch = vfs_exchange_begin();
-	
-	req = async_send_1(exch, VFS_IN_UNLINK, lflag, NULL);
-	rc = async_data_write_start(exch, pa, pa_size);
-	if (rc != EOK) {
-		vfs_exchange_end(exch);
-		free(pa);
-
-		sysarg_t rc_orig;
-		async_wait_for(req, &rc_orig);
-
-		if (rc_orig == EOK)
-			return (int) rc;
-		else
-			return (int) rc_orig;
-	}
-	vfs_exchange_end(exch);
-	free(pa);
-	async_wait_for(req, &rc);
-	return rc;
-}
-
-int unlink(const char *path)
-{
-	return _unlink(path, L_NONE);
-}
-
+/** Remove empty directory.
+ *
+ * @param path Path
+ * @return 0 on success. On error returns -1 and sets errno.
+ */
 int rmdir(const char *path)
 {
-	return _unlink(path, L_DIRECTORY);
-}
-
+	int rc;
+
+	rc = _unlink(path, L_DIRECTORY);
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+
+	return 0;
+}
+
+/** Rename directory entry.
+ *
+ * @param old Old name
+ * @param new New name
+ *
+ * @return 0 on success. On error returns -1 and sets errno.
+ */
 int rename(const char *old, const char *new)
 {
@@ -699,13 +941,16 @@
 	
 	size_t olda_size;
-	char *olda = absolutize(old, &olda_size);
-	if (!olda)
-		return ENOMEM;
+	char *olda = vfs_absolutize(old, &olda_size);
+	if (olda == NULL) {
+		errno = ENOMEM;
+		return -1;
+	}
 
 	size_t newa_size;
-	char *newa = absolutize(new, &newa_size);
-	if (!newa) {
+	char *newa = vfs_absolutize(new, &newa_size);
+	if (newa == NULL) {
 		free(olda);
-		return ENOMEM;
+		errno = ENOMEM;
+		return -1;
 	}
 	
@@ -719,8 +964,11 @@
 		free(newa);
 		async_wait_for(req, &rc_orig);
-		if (rc_orig == EOK)
-			return (int) rc;
-		else
-			return (int) rc_orig;
+		if (rc_orig != EOK)
+			rc = rc_orig;
+		if (rc != EOK) {
+			errno = rc;
+			return -1;
+		}
+		return 0;
 	}
 	rc = async_data_write_start(exch, newa, newa_size);
@@ -730,8 +978,11 @@
 		free(newa);
 		async_wait_for(req, &rc_orig);
-		if (rc_orig == EOK)
-			return (int) rc;
-		else
-			return (int) rc_orig;
+		if (rc_orig != EOK)
+			rc = rc_orig;
+		if (rc != EOK) {
+			errno = rc;
+			return -1;
+		}
+		return 0;
 	}
 	vfs_exchange_end(exch);
@@ -739,7 +990,18 @@
 	free(newa);
 	async_wait_for(req, &rc);
-	return rc;
-}
-
+
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+
+	return 0;
+}
+
+/** Remove directory entry.
+ *
+ * @param path Path
+ * @return 0 on success. On error returns -1 and sets errno.
+ */
 int remove(const char *path)
 {
@@ -747,16 +1009,26 @@
 }
 
+/** Change working directory.
+ *
+ * @param path Path
+ * @return 0 on success. On error returns -1 and sets errno.
+ */
 int chdir(const char *path)
 {
 	size_t abs_size;
-	char *abs = absolutize(path, &abs_size);
-	if (!abs)
-		return ENOMEM;
-	
-	int fd = open_internal(abs, abs_size, L_DIRECTORY, O_DESC);
-	
-	if (fd < 0) {
+	char *abs = vfs_absolutize(path, &abs_size);
+	int fd = -1;
+	
+	if (abs == NULL) {
+		errno = ENOMEM;
+		return -1;
+	}
+	
+	int rc = open_internal(abs, abs_size, L_DIRECTORY, O_DESC, &fd);
+	
+	if (rc != EOK) {
 		free(abs);
-		return ENOENT;
+		errno = rc;
+		return -1;
 	}
 	
@@ -765,5 +1037,4 @@
 	if (cwd_fd >= 0)
 		close(cwd_fd);
-	
 	
 	if (cwd_path)
@@ -775,11 +1046,19 @@
 	
 	fibril_mutex_unlock(&cwd_mutex);
-	return EOK;
-}
-
+	return 0;
+}
+
+/** Get current working directory path.
+ *
+ * @param buf Buffer
+ * @param size Size of @a buf
+ * @return On success returns @a buf. On failure returns @c NULL and sets errno.
+ */
 char *getcwd(char *buf, size_t size)
 {
-	if (size == 0)
+	if (size == 0) {
+		errno = EINVAL;
 		return NULL;
+	}
 	
 	fibril_mutex_lock(&cwd_mutex);
@@ -787,4 +1066,5 @@
 	if ((cwd_size == 0) || (size < cwd_size + 1)) {
 		fibril_mutex_unlock(&cwd_mutex);
+		errno = ERANGE;
 		return NULL;
 	}
@@ -796,21 +1076,34 @@
 }
 
-async_sess_t *fd_session(exch_mgmt_t mgmt, int fildes)
+/** Open session to service represented by a special file.
+ *
+ * Given that the file referred to by @a fildes represents a service,
+ * open a session to that service.
+ *
+ * @param fildes File descriptor
+ * @param iface Interface to connect to (XXX Should be automatic)
+ * @return On success returns session pointer. On error returns @c NULL.
+ */
+async_sess_t *vfs_fd_session(int fildes, iface_t iface)
 {
 	struct stat stat;
 	int rc = fstat(fildes, &stat);
-	if (rc != 0) {
-		errno = rc;
+	if (rc != 0)
 		return NULL;
-	}
-	
-	if (!stat.service) {
-		errno = ENOENT;
+	
+	if (stat.service == 0)
 		return NULL;
-	}
-	
-	return loc_service_connect(mgmt, stat.service, 0);
-}
-
+	
+	return loc_service_connect(stat.service, iface, 0);
+}
+
+/** Duplicate open file.
+ *
+ * Duplicate open file under a new file descriptor.
+ *
+ * @param oldfd Old file descriptor
+ * @param newfd New file descriptor
+ * @return 0 on success. On error -1 is returned and errno is set
+ */
 int dup2(int oldfd, int newfd)
 {
@@ -823,10 +1116,15 @@
 	
 	if (rc == EOK)
-		return (int) ret;
-	
-	return (int) rc;
-}
-
-int fd_wait(void)
+		rc = ret;
+	
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+	
+	return 0;
+}
+
+int vfs_fd_wait(void)
 {
 	async_exch_t *exch = vfs_exchange_begin();
@@ -843,5 +1141,5 @@
 }
 
-int get_mtab_list(list_t *mtab_list)
+int vfs_get_mtab_list(list_t *mtab_list)
 {
 	sysarg_t rc;
@@ -863,5 +1161,5 @@
 
 		mtab_ent = malloc(sizeof(mtab_ent_t));
-		if (!mtab_ent) {
+		if (mtab_ent == NULL) {
 			rc = ENOMEM;
 			goto exit;
@@ -904,4 +1202,10 @@
 }
 
+/** Get filesystem statistics.
+ *
+ * @param path Mount point path
+ * @param st Buffer for storing information
+ * @return 0 on success. On error -1 is returned and errno is set.
+ */
 int statfs(const char *path, struct statfs *st)
 {
@@ -910,7 +1214,9 @@
 	size_t pa_size;
 
-	char *pa = absolutize(path, &pa_size);
-	if (!pa)
-		return ENOMEM;
+	char *pa = vfs_absolutize(path, &pa_size);
+	if (pa == NULL) {
+		errno = ENOMEM;
+		return -1;
+	}
 
 	async_exch_t *exch = vfs_exchange_begin();
@@ -927,5 +1233,12 @@
 	free(pa);
 	async_wait_for(req, &rc_orig);
-	return (int) (rc_orig != EOK ? rc_orig : rc);
+	rc = (rc_orig != EOK ? rc_orig : rc);
+
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+
+	return 0;
 }
 
Index: uspace/lib/c/generic/vol.c
===================================================================
--- uspace/lib/c/generic/vol.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/generic/vol.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -33,4 +33,5 @@
  */
 
+#include <abi/ipc/interfaces.h>
 #include <errno.h>
 #include <ipc/services.h>
@@ -60,9 +61,9 @@
 	rc = loc_service_get_id(SERVICE_NAME_VOLSRV, &vol_svcid, 0);
 	if (rc != EOK) {
-		rc = EIO;
+		rc = ENOENT;
 		goto error;
 	}
 
-	vol->sess = loc_service_connect(EXCHANGE_SERIALIZE, vol_svcid, 0);
+	vol->sess = loc_service_connect(vol_svcid, INTERFACE_VOL, 0);
 	if (vol->sess == NULL) {
 		rc = EIO;
Index: uspace/lib/c/include/adt/list.h
===================================================================
--- uspace/lib/c/include/adt/list.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/adt/list.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -133,5 +133,5 @@
 
 /** Returns true if the link is definitely part of a list. False if not sure. */
-static inline int link_in_use(link_t *link)
+static inline bool link_in_use(link_t *link)
 {
 	return link->prev != NULL && link->next != NULL;
@@ -237,5 +237,5 @@
  *
  */
-static inline int list_empty(const list_t *list)
+static inline bool list_empty(const list_t *list)
 {
 	return (list->head.next == &list->head);
@@ -357,7 +357,7 @@
  *
  */
-static inline link_t *list_nth(list_t *list, unsigned int n)
-{
-	unsigned int cnt = 0;
+static inline link_t *list_nth(list_t *list, unsigned long n)
+{
+	unsigned long cnt = 0;
 	
 	link_t *link = list_first(list);
@@ -396,7 +396,7 @@
 }
 
-extern int list_member(const link_t *, const list_t *);
+extern bool list_member(const link_t *, const list_t *);
 extern void list_concat(list_t *, list_t *);
-extern unsigned int list_count(const list_t *);
+extern unsigned long list_count(const list_t *);
 
 #endif
Index: uspace/lib/c/include/async.h
===================================================================
--- uspace/lib/c/include/async.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/async.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -48,19 +48,22 @@
 #include <abi/ddi/irq.h>
 #include <abi/ipc/event.h>
+#include <abi/ipc/interfaces.h>
 
 typedef ipc_callid_t aid_t;
+typedef sysarg_t port_id_t;
 
 typedef void *(*async_client_data_ctor_t)(void);
 typedef void (*async_client_data_dtor_t)(void *);
 
-/** Client connection handler
+/** Port connection handler
  *
  * @param callid ID of incoming call or 0 if connection initiated from
- *               inside using async_connect_to_me()
+ *               inside using async_create_callback_port()
  * @param call   Incoming call or 0 if connection initiated from inside
- * @param arg    Local argument passed from async_new_connection() or
- *               async_connect_to_me()
- */
-typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *, void *);
+ *               using async_create_callback_port()
+ * @param arg    Local argument.
+ *
+ */
+typedef void (*async_port_handler_t)(ipc_callid_t, ipc_call_t *, void *);
 
 /** Notification handler */
@@ -80,4 +83,12 @@
 	EXCHANGE_ATOMIC = 0,
 	
+	/** Exchange management via mutual exclusion
+	 *
+	 * Suitable for any kind of client/server communication,
+	 * but can limit parallelism.
+	 *
+	 */
+	EXCHANGE_SERIALIZE = 1,
+	
 	/** Exchange management via phone cloning
 	 *
@@ -87,13 +98,5 @@
 	 *
 	 */
-	EXCHANGE_PARALLEL,
-	
-	/** Exchange management via mutual exclusion
-	 *
-	 * Suitable for any kind of client/server communication,
-	 * but can limit parallelism.
-	 *
-	 */
-	EXCHANGE_SERIALIZE
+	EXCHANGE_PARALLEL = 2
 } exch_mgmt_t;
 
@@ -147,7 +150,4 @@
 extern void async_forget(aid_t);
 
-extern fid_t async_new_connection(task_id_t, sysarg_t, ipc_callid_t,
-    ipc_call_t *, async_client_conn_t, void *);
-
 extern void async_usleep(suseconds_t);
 extern void async_create_manager(void);
@@ -160,5 +160,10 @@
 extern void async_put_client_data_by_id(task_id_t);
 
-extern void async_set_client_connection(async_client_conn_t);
+extern int async_create_port(iface_t, async_port_handler_t, void *,
+    port_id_t *);
+extern void async_set_fallback_port_handler(async_port_handler_t, void *);
+extern int async_create_callback_port(async_exch_t *, iface_t, sysarg_t,
+    sysarg_t, async_port_handler_t, void *, port_id_t *);
+
 extern void async_set_notification_handler_stack_size(size_t);
 
@@ -343,10 +348,13 @@
 extern async_sess_t *async_connect_me_to(exch_mgmt_t, async_exch_t *, sysarg_t,
     sysarg_t, sysarg_t);
+extern async_sess_t *async_connect_me_to_iface(async_exch_t *, iface_t,
+    sysarg_t, sysarg_t);
 extern async_sess_t *async_connect_me_to_blocking(exch_mgmt_t, async_exch_t *,
     sysarg_t, sysarg_t, sysarg_t);
+extern async_sess_t *async_connect_me_to_blocking_iface(async_exch_t *, iface_t,
+    sysarg_t, sysarg_t);
 extern async_sess_t *async_connect_kbox(task_id_t);
 
-extern int async_connect_to_me(async_exch_t *, sysarg_t, sysarg_t, sysarg_t,
-    async_client_conn_t, void *);
+extern int async_connect_to_me(async_exch_t *, sysarg_t, sysarg_t, sysarg_t);
 
 extern int async_hangup(async_sess_t *);
Index: pace/lib/c/include/cfg.h
===================================================================
--- uspace/lib/c/include/cfg.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ 	(revision )
@@ -1,104 +1,0 @@
-/*
- * Copyright (c) 2011 Radim Vansa
- * 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 libc
- * @{
- */
-/**
- * @file cfg.h
- * @brief Simple interface for configuration files manipulation.
- */
-
-#ifndef LIBC_CFG_H_
-#define LIBC_CFG_H_
-
-#include <adt/list.h>
-#include <sys/types.h>
-#include <stdbool.h>
-
-/**
- * One key-value pair
- */
-typedef struct {
-	link_t link;
-	
-	const char *key;
-	const char *value;
-} cfg_entry_t;
-
-/**
- * One section in the configuration file.
- * Has own title (or is anonymous) and contains entries.
- */
-typedef struct {
-	link_t link;
-	
-	const char *title;
-	list_t entries;
-	size_t entry_count;
-} cfg_section_t;
-
-/**
- * The configuration file data. The whole file is loaded
- * into memory and strings in sections (titles) or entries
- * (keys and values) are only pointers to this memory.
- * Therefore all the text data are allocated and deallocated
- * only once, if you want to use the strings after unloading
- * the configuration file, you have to copy them.
- */
-typedef struct {
-	list_t sections;
-	size_t section_count;
-	const char *data;
-} cfg_file_t;
-
-#define cfg_file_foreach(file, cur) \
-	list_foreach((file)->sections, link, const cfg_section_t, (cur))
-
-#define cfg_section_instance(cur) \
-	list_get_instance((cur), const cfg_section_t, link)
-
-#define cfg_section_foreach(section, cur) \
-	list_foreach((section)->entries, link, const cfg_entry_t, (cur))
-
-#define cfg_entry_instance(cur) \
-	list_get_instance((cur), const cfg_entry_t, link)
-
-extern int cfg_load(const char *, cfg_file_t *);
-extern int cfg_load_path(const char *, const char *, cfg_file_t *);
-extern void cfg_unload(cfg_file_t *);
-extern bool cfg_empty(const cfg_file_t *);
-extern const cfg_section_t *cfg_find_section(const cfg_file_t *, const char *);
-extern const char *cfg_find_value(const cfg_section_t *, const char *);
-extern const cfg_section_t *cfg_anonymous(const cfg_file_t *);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/devman.h
===================================================================
--- uspace/lib/c/include/devman.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/devman.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -42,6 +42,6 @@
 #include <stdbool.h>
 
-extern async_exch_t *devman_exchange_begin_blocking(devman_interface_t);
-extern async_exch_t *devman_exchange_begin(devman_interface_t);
+extern async_exch_t *devman_exchange_begin_blocking(iface_t);
+extern async_exch_t *devman_exchange_begin(iface_t);
 extern void devman_exchange_end(async_exch_t *);
 
@@ -53,7 +53,6 @@
 extern int devman_drv_fun_offline(devman_handle_t);
 
-extern async_sess_t *devman_device_connect(exch_mgmt_t, devman_handle_t,
-    unsigned int);
-extern async_sess_t *devman_parent_device_connect(exch_mgmt_t, devman_handle_t,
+extern async_sess_t *devman_device_connect(devman_handle_t, unsigned int);
+extern async_sess_t *devman_parent_device_connect(devman_handle_t,
     unsigned int);
 
Index: uspace/lib/c/include/errno.h
===================================================================
--- uspace/lib/c/include/errno.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/errno.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -47,12 +47,12 @@
 #define ENOTDIR       (-258)
 #define ENOSPC        (-259)
-#define EEXIST        (-260)
 #define ENOTEMPTY     (-261)
 #define EBADF         (-262)
-#define ERANGE        (-263)
-#define EXDEV         (-264)
-#define EIO           (-265)
-#define EMLINK        (-266)
-#define ENXIO         (-267)
+#define EDOM          (-263)
+#define ERANGE        (-264)
+#define EXDEV         (-265)
+#define EIO           (-266)
+#define EMLINK        (-267)
+#define ENXIO         (-268)
 
 /** Bad checksum. */
Index: pace/lib/c/include/fourcc.h
===================================================================
--- uspace/lib/c/include/fourcc.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ 	(revision )
@@ -1,49 +1,0 @@
-/*
- * Copyright (c) 2011 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.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#ifndef LIBC_FOURCC_H_
-#define LIBC_FOURCC_H_
-
-#include <libarch/common.h>
-
-typedef uint32_t fourcc_t;
-
-#define FOURCC(a, b, c, d) \
-	(((UINT32_T) (a)) | (((UINT32_T) (b)) << 8) | \
-	    (((UINT32_T) (c)) << 16) | (((UINT32_T) (d)) << 24))
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/helenos
===================================================================
--- uspace/lib/c/include/helenos	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/c/include/helenos	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,1 @@
+.
Index: uspace/lib/c/include/io/kio.h
===================================================================
--- uspace/lib/c/include/io/kio.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/io/kio.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -40,5 +40,5 @@
 #include <io/verify.h>
 
-extern size_t kio_write(const void *, size_t);
+extern int kio_write(const void *, size_t, size_t *);
 extern void kio_update(void);
 extern void kio_command(const void *, size_t);
Index: uspace/lib/c/include/ipc/devman.h
===================================================================
--- uspace/lib/c/include/ipc/devman.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/ipc/devman.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -141,12 +141,4 @@
 
 typedef enum {
-	DEVMAN_DRIVER = 1,
-	DEVMAN_CLIENT,
-	DEVMAN_CONNECT_TO_DEVICE,
-	DEVMAN_CONNECT_FROM_LOC,
-	DEVMAN_CONNECT_TO_PARENTS_DEVICE
-} devman_interface_t;
-
-typedef enum {
 	DEVMAN_DRIVER_REGISTER = IPC_FIRST_USER_METHOD,
 	DEVMAN_ADD_FUNCTION,
Index: pace/lib/c/include/ipc/driver.h
===================================================================
--- uspace/lib/c/include/ipc/driver.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/*
- * Copyright (c) 2010 Lenka Trochtova 
- * 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 libdrv
- * @{
- */
-/** @file
- */
-
-#ifndef IPC_DRIVER_H_
-#define IPC_DRIVER_H_
-
-typedef enum {
-	DRIVER_DEVMAN = 1,
-	DRIVER_CLIENT,
-	DRIVER_DRIVER
-} driver_interface_t;
-
-
-#endif
-
-
-/**
- * @}
- */
Index: uspace/lib/c/include/ipc/inet.h
===================================================================
--- uspace/lib/c/include/ipc/inet.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/ipc/inet.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -37,16 +37,4 @@
 
 #include <ipc/common.h>
-
-/** Inet ports */
-typedef enum {
-	/** Default port */
-	INET_PORT_DEFAULT = 1,
-	/** Configuration port */
-	INET_PORT_CFG,
-	/** Ping service port */
-	INET_PORT_PING,
-	/** Ping6 service port */
-	INET_PORT_PING6
-} inet_port_t;
 
 /** Requests on Inet default port */
Index: uspace/lib/c/include/ipc/loc.h
===================================================================
--- uspace/lib/c/include/ipc/loc.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/ipc/loc.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -76,20 +76,4 @@
 } loc_event_t;
 
-/** Ports provided by location service.
- *
- * Every process that connects to loc must ask one of following
- * ports, otherwise connection will be refused.
- *
- */
-typedef enum {
-	/** Service supplier (server) port */
-	LOC_PORT_SUPPLIER = 1,
-	/** Service consumer (client) port */
-	LOC_PORT_CONSUMER,
-	/** Create new connection to instance of device that
-	    is specified by second argument of call. */
-	LOC_CONNECT_TO_SERVICE
-} loc_interface_t;
-
 typedef struct {
 	service_id_t id;
Index: uspace/lib/c/include/ipc/logger.h
===================================================================
--- uspace/lib/c/include/ipc/logger.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/ipc/logger.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -69,11 +69,4 @@
 } logger_writer_request_t;
 
-typedef enum {
-	/** Interface for controlling logger behavior. */
-	LOGGER_INTERFACE_CONTROL,
-	/** Interface for servers writing to the log. */
-	LOGGER_INTERFACE_WRITER
-} logger_interface_t;
-
 #endif
 
Index: uspace/lib/c/include/ipc/services.h
===================================================================
--- uspace/lib/c/include/ipc/services.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/ipc/services.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -38,9 +38,10 @@
 #define LIBC_SERVICES_H_
 
-#include <fourcc.h>
+#include <sys/types.h>
+#include <abi/fourcc.h>
 
 typedef enum {
 	SERVICE_NONE       = 0,
-	SERVICE_LOAD       = FOURCC('l', 'o', 'a', 'd'),
+	SERVICE_LOADER     = FOURCC('l', 'o', 'a', 'd'),
 	SERVICE_VFS        = FOURCC('v', 'f', 's', ' '),
 	SERVICE_LOC        = FOURCC('l', 'o', 'c', ' '),
@@ -49,18 +50,15 @@
 	SERVICE_IRC        = FOURCC('i', 'r', 'c', ' '),
 	SERVICE_CLIPBOARD  = FOURCC('c', 'l', 'i', 'p'),
-} services_t;
+} service_t;
 
-#define SERVICE_NAME_CORECFG	"corecfg"
-#define SERVICE_NAME_DHCP       "net/dhcp"
-#define SERVICE_NAME_DNSR       "net/dnsr"
-#define SERVICE_NAME_INET       "net/inet"
-#define SERVICE_NAME_INETCFG    "net/inetcfg"
-#define SERVICE_NAME_INETPING   "net/inetping"
-#define SERVICE_NAME_INETPING6  "net/inetping6"
-#define SERVICE_NAME_NETCONF    "net/netconf"
-#define SERVICE_NAME_UDP	"net/udp"
-#define SERVICE_NAME_TCP	"net/tcp"
-#define SERVICE_NAME_VBD	"vbd"
-#define SERVICE_NAME_VOLSRV	"volsrv"
+#define SERVICE_NAME_CORECFG  "corecfg"
+#define SERVICE_NAME_DHCP     "net/dhcp"
+#define SERVICE_NAME_DNSR     "net/dnsr"
+#define SERVICE_NAME_INET     "net/inet"
+#define SERVICE_NAME_NETCONF  "net/netconf"
+#define SERVICE_NAME_UDP      "net/udp"
+#define SERVICE_NAME_TCP      "net/tcp"
+#define SERVICE_NAME_VBD      "vbd"
+#define SERVICE_NAME_VOLSRV   "volsrv"
 
 #endif
Index: uspace/lib/c/include/loc.h
===================================================================
--- uspace/lib/c/include/loc.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/loc.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -42,12 +42,10 @@
 typedef void (*loc_cat_change_cb_t)(void);
 
-extern async_exch_t *loc_exchange_begin_blocking(loc_interface_t);
-extern async_exch_t *loc_exchange_begin(loc_interface_t);
+extern async_exch_t *loc_exchange_begin_blocking(iface_t);
+extern async_exch_t *loc_exchange_begin(iface_t);
 extern void loc_exchange_end(async_exch_t *);
 
 extern int loc_server_register(const char *);
 extern int loc_service_register(const char *, service_id_t *);
-extern int loc_service_register_with_iface(const char *, service_id_t *,
-    sysarg_t);
 extern int loc_service_unregister(service_id_t);
 extern int loc_service_add_to_cat(service_id_t, category_id_t);
@@ -65,5 +63,5 @@
 extern loc_object_type_t loc_id_probe(service_id_t);
 
-extern async_sess_t *loc_service_connect(exch_mgmt_t, service_id_t,
+extern async_sess_t *loc_service_connect(service_id_t, iface_t,
     unsigned int);
 
Index: uspace/lib/c/include/ns.h
===================================================================
--- uspace/lib/c/include/ns.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/ns.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -41,10 +41,7 @@
 #include <async.h>
 
-extern int service_register(sysarg_t);
-extern async_sess_t *service_connect(exch_mgmt_t, services_t, sysarg_t, sysarg_t);
-extern async_sess_t *service_connect_blocking(exch_mgmt_t, services_t, sysarg_t,
-    sysarg_t);
-extern async_sess_t *service_bind(services_t, sysarg_t, sysarg_t, sysarg_t,
-    async_client_conn_t);
+extern int service_register(service_t);
+extern async_sess_t *service_connect(service_t, iface_t, sysarg_t);
+extern async_sess_t *service_connect_blocking(service_t, iface_t, sysarg_t);
 
 extern int ns_ping(void);
Index: uspace/lib/c/include/stdint.h
===================================================================
--- uspace/lib/c/include/stdint.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -60,5 +60,5 @@
 #define UINT64_MAX  UINT64_C(0xFFFFFFFFFFFFFFFF)
 
-#include <libarch/types.h>
+#include <libarch/stdint.h>
 
 /* off64_t */
Index: uspace/lib/c/include/stdio.h
===================================================================
--- uspace/lib/c/include/stdio.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/stdio.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -109,4 +109,6 @@
 extern int puts(const char *);
 
+extern int ungetc(int, FILE *);
+
 /* Formatted string output functions */
 extern int fprintf(FILE *, const char*, ...)
@@ -132,4 +134,5 @@
 extern FILE *fopen(const char *, const char *);
 extern FILE *fdopen(int, const char *);
+extern FILE *freopen(const char *, const char *, FILE *);
 extern int fclose(FILE *);
 
Index: uspace/lib/c/include/sys/statfs.h
===================================================================
--- uspace/lib/c/include/sys/statfs.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/sys/statfs.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -46,4 +46,5 @@
 
 extern int statfs(const char *, struct statfs *);
+
 #endif
 
Index: uspace/lib/c/include/sys/types.h
===================================================================
--- uspace/lib/c/include/sys/types.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/sys/types.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -46,4 +46,6 @@
 typedef uint64_t aoff64_t;
 
+typedef uint32_t fourcc_t;
+
 typedef volatile uint8_t ioport8_t;
 typedef volatile uint16_t ioport16_t;
Index: uspace/lib/c/include/unistd.h
===================================================================
--- uspace/lib/c/include/unistd.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/unistd.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -63,7 +63,4 @@
 extern ssize_t read(int, void *, size_t);
 
-extern ssize_t read_all(int, void *, size_t);
-extern ssize_t write_all(int, const void *, size_t);
-
 extern off64_t lseek(int, off64_t, int);
 extern int ftruncate(int, aoff64_t);
Index: uspace/lib/c/include/vfs/vfs.h
===================================================================
--- uspace/lib/c/include/vfs/vfs.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/vfs/vfs.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -50,17 +50,18 @@
 
 
-extern char *absolutize(const char *, size_t *);
+extern char *vfs_absolutize(const char *, size_t *);
 
-extern int mount(const char *, const char *, const char *, const char *,
+extern int vfs_mount(const char *, const char *, const char *, const char *,
     unsigned int, unsigned int);
-extern int unmount(const char *);
+extern int vfs_unmount(const char *);
 
-extern int fhandle(FILE *, int *);
+extern int vfs_fhandle(FILE *, int *);
 
-extern int fd_wait(void);
-extern int get_mtab_list(list_t *mtab_list);
+extern int vfs_fd_wait(void);
+extern int vfs_get_mtab_list(list_t *mtab_list);
 
 extern async_exch_t *vfs_exchange_begin(void);
 extern void vfs_exchange_end(async_exch_t *);
+
 #endif
 
Index: uspace/lib/c/include/vfs/vfs_sess.h
===================================================================
--- uspace/lib/c/include/vfs/vfs_sess.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/c/include/vfs/vfs_sess.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -39,6 +39,6 @@
 #include <stdio.h>
 
-extern async_sess_t *fd_session(exch_mgmt_t, int);
-extern async_sess_t *fsession(exch_mgmt_t, FILE *);
+extern async_sess_t *vfs_fd_session(int, iface_t);
+extern async_sess_t *vfs_fsession(FILE *, iface_t);
 
 #endif
Index: uspace/lib/crypto/Makefile
===================================================================
--- uspace/lib/crypto/Makefile	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/crypto/Makefile	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -33,5 +33,6 @@
 	crypto.c \
 	aes.c \
-	rc4.c
+	rc4.c \
+	crc16_ibm.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/crypto/crc16_ibm.c
===================================================================
--- uspace/lib/crypto/crc16_ibm.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/crypto/crc16_ibm.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @file crc16_ibm.c
+ *
+ * Implementation of CRC16-IBM (polynomial = 0xA001)
+ *
+ */
+
+#include "crypto.h"
+
+static const uint16_t crct[256] = {
+	0x0000,	0xc0c1,	0xc181,	0x0140,	0xc301,	0x03c0,	0x0280,	0xc241,
+	0xc601,	0x06c0,	0x0780,	0xc741,	0x0500,	0xc5c1,	0xc481,	0x0440,
+	0xcc01,	0x0cc0,	0x0d80,	0xcd41,	0x0f00,	0xcfc1,	0xce81,	0x0e40,
+	0x0a00,	0xcac1,	0xcb81,	0x0b40,	0xc901,	0x09c0,	0x0880,	0xc841,
+	0xd801,	0x18c0,	0x1980,	0xd941,	0x1b00,	0xdbc1,	0xda81,	0x1a40,
+	0x1e00,	0xdec1,	0xdf81,	0x1f40,	0xdd01,	0x1dc0,	0x1c80,	0xdc41,
+	0x1400,	0xd4c1,	0xd581,	0x1540,	0xd701,	0x17c0,	0x1680,	0xd641,
+	0xd201,	0x12c0,	0x1380,	0xd341,	0x1100,	0xd1c1,	0xd081,	0x1040,
+	0xf001,	0x30c0,	0x3180,	0xf141,	0x3300,	0xf3c1,	0xf281,	0x3240,
+	0x3600,	0xf6c1,	0xf781,	0x3740,	0xf501,	0x35c0,	0x3480,	0xf441,
+	0x3c00,	0xfcc1,	0xfd81,	0x3d40,	0xff01,	0x3fc0,	0x3e80,	0xfe41,
+	0xfa01,	0x3ac0,	0x3b80,	0xfb41,	0x3900,	0xf9c1,	0xf881,	0x3840,
+	0x2800,	0xe8c1,	0xe981,	0x2940,	0xeb01,	0x2bc0,	0x2a80,	0xea41,
+	0xee01,	0x2ec0,	0x2f80,	0xef41,	0x2d00,	0xedc1,	0xec81,	0x2c40,
+	0xe401,	0x24c0,	0x2580,	0xe541,	0x2700,	0xe7c1,	0xe681,	0x2640,
+	0x2200,	0xe2c1,	0xe381,	0x2340,	0xe101,	0x21c0,	0x2080,	0xe041,
+	0xa001,	0x60c0,	0x6180,	0xa141,	0x6300,	0xa3c1,	0xa281,	0x6240,
+	0x6600,	0xa6c1,	0xa781,	0x6740,	0xa501,	0x65c0,	0x6480,	0xa441,
+	0x6c00,	0xacc1,	0xad81,	0x6d40,	0xaf01,	0x6fc0,	0x6e80,	0xae41,
+	0xaa01,	0x6ac0,	0x6b80,	0xab41,	0x6900,	0xa9c1,	0xa881,	0x6840,
+	0x7800,	0xb8c1,	0xb981,	0x7940,	0xbb01,	0x7bc0,	0x7a80,	0xba41,
+	0xbe01,	0x7ec0,	0x7f80,	0xbf41,	0x7d00,	0xbdc1,	0xbc81,	0x7c40,
+	0xb401,	0x74c0,	0x7580,	0xb541,	0x7700,	0xb7c1,	0xb681,	0x7640,
+	0x7200,	0xb2c1,	0xb381,	0x7340,	0xb101,	0x71c0,	0x7080,	0xb041,
+	0x5000,	0x90c1,	0x9181,	0x5140,	0x9301,	0x53c0,	0x5280,	0x9241,
+	0x9601,	0x56c0,	0x5780,	0x9741,	0x5500,	0x95c1,	0x9481,	0x5440,
+	0x9c01,	0x5cc0,	0x5d80,	0x9d41,	0x5f00,	0x9fc1,	0x9e81,	0x5e40,
+	0x5a00,	0x9ac1,	0x9b81,	0x5b40,	0x9901,	0x59c0,	0x5880,	0x9841,
+	0x8801,	0x48c0,	0x4980,	0x8941,	0x4b00,	0x8bc1,	0x8a81,	0x4a40,
+	0x4e00,	0x8ec1,	0x8f81,	0x4f40,	0x8d01,	0x4dc0,	0x4c80,	0x8c41,
+	0x4400,	0x84c1,	0x8581,	0x4540,	0x8701,	0x47c0,	0x4680,	0x8641,
+	0x8201,	0x42c0,	0x4380,	0x8341,	0x4100,	0x81c1,	0x8081,	0x4040
+};
+
+/* Compute a CRC16
+ *
+ * @param crc    Init value of the CRC
+ * @param buf    Pointer to the data
+ * @param len    Size of the buffer
+ *
+ * @return       Value of the CRC.
+ */
+uint16_t crc16_ibm(uint16_t crc, uint8_t *buf, size_t len)
+{
+	while (len--) {
+		crc ^= *buf++;
+		crc = (crc >> 8) ^ crct[crc & 0x00FF];
+	}
+
+	return crc;
+}
+
Index: uspace/lib/crypto/crypto.h
===================================================================
--- uspace/lib/crypto/crypto.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/crypto/crypto.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -56,3 +56,5 @@
 extern int pbkdf2(uint8_t *, size_t, uint8_t *, size_t, uint8_t *);
 
+extern uint16_t crc16_ibm(uint16_t crc, uint8_t *buf, size_t len);
+
 #endif
Index: uspace/lib/draw/codec/webp.c
===================================================================
--- uspace/lib/draw/codec/webp.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/draw/codec/webp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -38,6 +38,7 @@
 #include <align.h>
 #include <stdbool.h>
-#include <fourcc.h>
 #include <pixconv.h>
+#include <sys/types.h>
+#include <abi/fourcc.h>
 #include "webp.h"
 
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/drv/generic/driver.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -53,6 +53,4 @@
 #include <devman.h>
 
-#include <ipc/driver.h>
-
 #include "dev_iface.h"
 #include "ddf/driver.h"
@@ -130,5 +128,10 @@
 	
 	char *dev_name = NULL;
-	async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
+	int rc = async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
+	if (rc != EOK) {
+		async_answer_0(iid, rc);
+		return;
+	}
+	
 	dev->name = dev_name;
 	
@@ -278,5 +281,6 @@
 }
 
-static void driver_connection_devman(ipc_callid_t iid, ipc_call_t *icall)
+static void driver_connection_devman(ipc_callid_t iid, ipc_call_t *icall,
+    void *arg)
 {
 	/* Accept connection */
@@ -436,45 +440,14 @@
 }
 
-static void driver_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
+static void driver_connection_driver(ipc_callid_t iid, ipc_call_t *icall,
+    void *arg)
 {
 	driver_connection_gen(iid, icall, true);
 }
 
-static void driver_connection_client(ipc_callid_t iid, ipc_call_t *icall)
+static void driver_connection_client(ipc_callid_t iid, ipc_call_t *icall,
+    void *arg)
 {
 	driver_connection_gen(iid, icall, false);
-}
-
-/** Function for handling connections to device driver. */
-static void driver_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
-{
-	sysarg_t conn_type;
-
-	if (iid == 0) {
-		/* Callback connection from devman */
-		/* XXX Use separate handler for this type of connection */
-		conn_type = DRIVER_DEVMAN;
-	} else {
-		conn_type = IPC_GET_ARG1(*icall);
-	}
-
-	/* Select interface */
-	switch (conn_type) {
-	case DRIVER_DEVMAN:
-		/* Handle request from device manager */
-		driver_connection_devman(iid, icall);
-		break;
-	case DRIVER_DRIVER:
-		/* Handle request from drivers of child devices */
-		driver_connection_driver(iid, icall);
-		break;
-	case DRIVER_CLIENT:
-		/* Handle request from client applications */
-		driver_connection_client(iid, icall);
-		break;
-	default:
-		/* No such interface */
-		async_answer_0(iid, ENOENT);
-	}
 }
 
@@ -620,12 +593,13 @@
  * The session will be automatically closed when @a dev is destroyed.
  *
- * @param dev	Device
- * @param mgmt	Exchange management style
- * @return	New session or NULL if session could not be created
- */
-async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *dev, exch_mgmt_t mgmt)
+ * @param dev Device
+ *
+ * @return New session or NULL if session could not be created
+ *
+ */
+async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *dev)
 {
 	assert(dev->parent_sess == NULL);
-	dev->parent_sess = devman_parent_device_connect(mgmt, dev->handle,
+	dev->parent_sess = devman_parent_device_connect(dev->handle,
 	    IPC_FLAG_BLOCKING);
 
@@ -916,5 +890,5 @@
  * This allows handling connections the non-devman way.
  */
-void ddf_fun_set_conn_handler(ddf_fun_t *fun, async_client_conn_t conn)
+void ddf_fun_set_conn_handler(ddf_fun_t *fun, async_port_handler_t conn)
 {
 	assert(fun->ops == NULL);
@@ -955,9 +929,21 @@
 	 * incoming connections.
 	 */
-	async_set_client_connection(driver_connection);
-	int rc = devman_driver_register(driver->name);
+	port_id_t port;
+	int rc = async_create_port(INTERFACE_DDF_DRIVER, driver_connection_driver,
+	    NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	rc = async_create_port(INTERFACE_DDF_DEVMAN, driver_connection_devman,
+	    NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	async_set_fallback_port_handler(driver_connection_client, NULL);
+	
+	rc = devman_driver_register(driver->name);
 	if (rc != EOK) {
 		printf("Error: Failed to register driver with device manager "
-		    "(%s).\n", (rc == EEXISTS) ? "driver already started" :
+		    "(%s).\n", (rc == EEXIST) ? "driver already started" :
 		    str_error(rc));
 		
Index: uspace/lib/drv/generic/private/driver.h
===================================================================
--- uspace/lib/drv/generic/private/driver.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/drv/generic/private/driver.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -96,5 +96,5 @@
 	
 	/** Connection handler or @c NULL to use the DDF default handler. */
-	async_client_conn_t conn_handler;
+	async_port_handler_t conn_handler;
 	
 	/** Link in the list of functions handled by the driver */
Index: uspace/lib/drv/generic/remote_ahci.c
===================================================================
--- uspace/lib/drv/generic/remote_ahci.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/drv/generic/remote_ahci.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -72,6 +72,5 @@
 	
 	if ((devn_size > 5) && (str_lcmp(devn, "ahci_", 5) == 0)) {
-		async_sess_t *sess = devman_device_connect(EXCHANGE_PARALLEL,
-		    funh, IPC_FLAG_BLOCKING);
+		async_sess_t *sess = devman_device_connect(funh, IPC_FLAG_BLOCKING);
 		
 		if (sess) {
Index: uspace/lib/drv/generic/remote_audio_pcm.c
===================================================================
--- uspace/lib/drv/generic/remote_audio_pcm.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/drv/generic/remote_audio_pcm.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -146,6 +146,5 @@
 	if (ret != EOK)
 		return NULL;
-	return devman_device_connect(EXCHANGE_SERIALIZE, device_handle,
-	    IPC_FLAG_BLOCKING);
+	return devman_device_connect(device_handle, IPC_FLAG_BLOCKING);
 }
 
@@ -158,5 +157,5 @@
 audio_pcm_sess_t *audio_pcm_open_service(service_id_t id)
 {
-	return loc_service_connect(EXCHANGE_SERIALIZE, id, IPC_FLAG_BLOCKING);
+	return loc_service_connect(id, INTERFACE_DDF, IPC_FLAG_BLOCKING);
 }
 
@@ -316,5 +315,5 @@
  */
 int audio_pcm_register_event_callback(audio_pcm_sess_t *sess,
-    async_client_conn_t event_callback, void *arg)
+    async_port_handler_t event_callback, void *arg)
 {
 	if (!event_callback)
@@ -322,9 +321,13 @@
 
 	async_exch_t *exch = async_exchange_begin(sess);
+	
 	int ret = async_req_1_0(exch, DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_REGISTER_EVENTS);
 	if (ret == EOK) {
-		ret = async_connect_to_me(exch, 0, 0, 0, event_callback, arg);
-	}
+		port_id_t port;
+		ret = async_create_callback_port(exch, INTERFACE_AUDIO_PCM_CB, 0, 0,
+		    event_callback, arg, &port);
+	}
+	
 	async_exchange_end(exch);
 	return ret;
Index: uspace/lib/drv/generic/remote_nic.c
===================================================================
--- uspace/lib/drv/generic/remote_nic.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/drv/generic/remote_nic.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -126,5 +126,5 @@
  *
  */
-int nic_callback_create(async_sess_t *dev_sess, async_client_conn_t cfun,
+int nic_callback_create(async_sess_t *dev_sess, async_port_handler_t cfun,
     void *carg)
 {
@@ -137,5 +137,7 @@
 	    NIC_CALLBACK_CREATE, &answer);
 	
-	rc = async_connect_to_me(exch, 0, 0, 0, cfun, carg);
+	port_id_t port;
+	rc = async_create_callback_port(exch, INTERFACE_NIC_CB, 0, 0,
+	    cfun, carg, &port);
 	if (rc != EOK) {
 		async_forget(req);
Index: uspace/lib/drv/include/audio_pcm_iface.h
===================================================================
--- uspace/lib/drv/include/audio_pcm_iface.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/drv/include/audio_pcm_iface.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -85,5 +85,5 @@
 int audio_pcm_query_cap(audio_pcm_sess_t *, audio_cap_t);
 int audio_pcm_register_event_callback(audio_pcm_sess_t *,
-    async_client_conn_t, void *);
+    async_port_handler_t, void *);
 int audio_pcm_unregister_event_callback(audio_pcm_sess_t *);
 
Index: uspace/lib/drv/include/ddf/driver.h
===================================================================
--- uspace/lib/drv/include/ddf/driver.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/drv/include/ddf/driver.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -117,5 +117,5 @@
 extern devman_handle_t ddf_dev_get_handle(ddf_dev_t *);
 extern const char *ddf_dev_get_name(ddf_dev_t *);
-extern async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *, exch_mgmt_t);
+extern async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *);
 extern async_sess_t *ddf_dev_parent_sess_get(ddf_dev_t *);
 extern ddf_fun_t *ddf_fun_create(ddf_dev_t *, fun_type_t, const char *);
@@ -133,5 +133,5 @@
 extern int ddf_fun_add_match_id(ddf_fun_t *, const char *, int);
 extern void ddf_fun_set_ops(ddf_fun_t *, ddf_dev_ops_t *);
-extern void ddf_fun_set_conn_handler(ddf_fun_t *, async_client_conn_t);
+extern void ddf_fun_set_conn_handler(ddf_fun_t *, async_port_handler_t);
 extern int ddf_fun_add_to_category(ddf_fun_t *, const char *);
 
Index: uspace/lib/drv/include/nic_iface.h
===================================================================
--- uspace/lib/drv/include/nic_iface.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/drv/include/nic_iface.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -48,5 +48,5 @@
 
 extern int nic_send_frame(async_sess_t *, void *, size_t);
-extern int nic_callback_create(async_sess_t *, async_client_conn_t, void *);
+extern int nic_callback_create(async_sess_t *, async_port_handler_t, void *);
 extern int nic_get_state(async_sess_t *, nic_device_state_t *);
 extern int nic_set_state(async_sess_t *, nic_device_state_t);
Index: uspace/lib/ext4/Makefile
===================================================================
--- uspace/lib/ext4/Makefile	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/ext4/Makefile	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -29,6 +29,6 @@
 USPACE_PREFIX = ../..
 LIBRARY = libext4
-EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX)
-LIBS = $(LIBBLOCK_PREFIX)/libblock.a
+EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBCRYPTO_PREFIX)
+LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBCRYPTO_PREFIX)/libcrypto.a
 
 SOURCES = \
@@ -36,5 +36,4 @@
 	libext4_bitmap.c \
 	libext4_block_group.c \
-	libext4_crc.c \
 	libext4_directory.c \
 	libext4_directory_index.c \
Index: uspace/lib/ext4/libext4.h
===================================================================
--- uspace/lib/ext4/libext4.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/ext4/libext4.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -37,5 +37,4 @@
 #include "libext4_bitmap.h"
 #include "libext4_block_group.h"
-#include "libext4_crc.h"
 #include "libext4_directory.h"
 #include "libext4_directory_index.h"
Index: uspace/lib/ext4/libext4_balloc.c
===================================================================
--- uspace/lib/ext4/libext4_balloc.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/ext4/libext4_balloc.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -39,27 +39,4 @@
 #include "libext4.h"
 
-/** Compute number of block group from block address.
- *
- * @param sb         Superblock pointer.
- * @param block_addr Absolute address of block.
- *
- * @return Block group index
- *
- */
-static uint32_t ext4_balloc_get_bgid_of_block(ext4_superblock_t *sb,
-    uint32_t block_addr)
-{
-	uint32_t blocks_per_group =
-	    ext4_superblock_get_blocks_per_group(sb);
-	uint32_t first_block =
-	    ext4_superblock_get_first_data_block(sb);
-	
-	/* First block == 0 or 1 */
-	if (first_block == 0)
-		return block_addr / blocks_per_group;
-	else
-		return (block_addr - 1) / blocks_per_group;
-}
-
 /** Free block.
  *
@@ -76,5 +53,5 @@
 	
 	/* Compute indexes */
-	uint32_t block_group = ext4_balloc_get_bgid_of_block(sb, block_addr);
+	uint32_t block_group = ext4_filesystem_blockaddr2group(sb, block_addr);
 	uint32_t index_in_group =
 	    ext4_filesystem_blockaddr2_index_in_group(sb, block_addr);
@@ -135,25 +112,18 @@
 }
 
-/** Free continuous set of blocks.
- *
- * @param inode_ref Inode, where the blocks are allocated
- * @param first     First block to release
- * @param count     Number of blocks to release
- *
- */
-int ext4_balloc_free_blocks(ext4_inode_ref_t *inode_ref,
+static int ext4_balloc_free_blocks_internal(ext4_inode_ref_t *inode_ref,
     uint32_t first, uint32_t count)
 {
 	ext4_filesystem_t *fs = inode_ref->fs;
 	ext4_superblock_t *sb = fs->superblock;
-	
+
 	/* Compute indexes */
-	uint32_t block_group_first =
-	    ext4_balloc_get_bgid_of_block(sb, first);
-	uint32_t block_group_last =
-	    ext4_balloc_get_bgid_of_block(sb, first + count - 1);
-	
+	uint32_t block_group_first = ext4_filesystem_blockaddr2group(sb,
+	    first);
+	uint32_t block_group_last = ext4_filesystem_blockaddr2group(sb,
+	    first + count - 1);
+
 	assert(block_group_first == block_group_last);
-	
+
 	/* Load block group reference */
 	ext4_block_group_ref_t *bg_ref;
@@ -161,12 +131,12 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	uint32_t index_in_group_first =
 	    ext4_filesystem_blockaddr2_index_in_group(sb, first);
-	
+
 	/* Load block with bitmap */
 	uint32_t bitmap_block_addr =
 	    ext4_block_group_get_block_bitmap(bg_ref->block_group, sb);
-	
+
 	block_t *bitmap_block;
 	rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0);
@@ -175,9 +145,9 @@
 		return rc;
 	}
-	
+
 	/* Modify bitmap */
 	ext4_bitmap_free_bits(bitmap_block->data, index_in_group_first, count);
 	bitmap_block->dirty = true;
-	
+
 	/* Release block with bitmap */
 	rc = block_put(bitmap_block);
@@ -187,7 +157,7 @@
 		return rc;
 	}
-	
+
 	uint32_t block_size = ext4_superblock_get_block_size(sb);
-	
+
 	/* Update superblock free blocks count */
 	uint32_t sb_free_blocks =
@@ -195,5 +165,5 @@
 	sb_free_blocks += count;
 	ext4_superblock_set_free_blocks_count(sb, sb_free_blocks);
-	
+
 	/* Update inode blocks count */
 	uint64_t ino_blocks =
@@ -202,5 +172,5 @@
 	ext4_inode_set_blocks_count(sb, inode_ref->inode, ino_blocks);
 	inode_ref->dirty = true;
-	
+
 	/* Update block group free blocks count */
 	uint32_t free_blocks =
@@ -210,9 +180,52 @@
 	    sb, free_blocks);
 	bg_ref->dirty = true;
-	
+
 	/* Release block group reference */
 	return ext4_filesystem_put_block_group_ref(bg_ref);
 }
 
+/** Free continuous set of blocks.
+ *
+ * @param inode_ref Inode, where the blocks are allocated
+ * @param first     First block to release
+ * @param count     Number of blocks to release
+ *
+ */
+int ext4_balloc_free_blocks(ext4_inode_ref_t *inode_ref,
+    uint32_t first, uint32_t count)
+{
+	int r;
+	uint32_t gid;
+	uint64_t limit;
+	ext4_filesystem_t *fs = inode_ref->fs;
+	ext4_superblock_t *sb = fs->superblock;
+
+	while (count) {
+		gid = ext4_filesystem_blockaddr2group(sb, first);
+		limit = ext4_filesystem_index_in_group2blockaddr(sb, 0,
+		    gid + 1);
+
+		if ((first + count) >= limit) {
+			/* This extent spans over 2 or more block groups,
+			 * we'll break it into smaller parts.
+			 */
+			uint32_t s = limit - first;
+
+			r = ext4_balloc_free_blocks_internal(inode_ref,
+			    first, s);
+			if (r != EOK)
+				return r;
+
+			first = limit;
+			count -= s;
+		} else {
+			return ext4_balloc_free_blocks_internal(inode_ref,
+			    first, count);
+		}
+	}
+
+	return EOK;
+}
+
 /** Compute first block for data in block group.
  *
@@ -227,28 +240,42 @@
     ext4_block_group_ref_t *bg_ref)
 {
-	uint32_t block_group_count = ext4_superblock_get_block_group_count(sb);
-	uint32_t inode_table_first_block =
-	    ext4_block_group_get_inode_table_first_block(bg_ref->block_group, sb);
-	uint16_t inode_table_item_size = ext4_superblock_get_inode_size(sb);
-	uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(sb);
-	uint32_t block_size = ext4_superblock_get_block_size(sb);
-	uint32_t inode_table_bytes;
-	
-	if (bg_ref->index < block_group_count - 1) {
-		inode_table_bytes = inodes_per_group * inode_table_item_size;
-	} else {
-		/* Last block group could be smaller */
-		uint32_t inodes_count_total = ext4_superblock_get_inodes_count(sb);
-		inode_table_bytes =
-		    (inodes_count_total - ((block_group_count - 1) * inodes_per_group)) *
-		    inode_table_item_size;
-	}
-	
-	uint32_t inode_table_blocks = inode_table_bytes / block_size;
-	
-	if (inode_table_bytes % block_size)
-		inode_table_blocks++;
-	
-	return inode_table_first_block + inode_table_blocks;
+	uint32_t r;
+	uint64_t itable = ext4_block_group_get_inode_table_first_block(
+	    bg_ref->block_group, sb);
+	uint32_t itable_sz = ext4_filesystem_bg_get_itable_size(sb, bg_ref);
+
+	if (!ext4_superblock_has_feature_incompatible(sb,
+	    EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
+		/* If we are not using FLEX_BG, the first data block
+		 * is always after the inode table.
+		 */
+		r = itable + itable_sz;
+		return ext4_filesystem_blockaddr2_index_in_group(sb, r);
+	}
+
+	uint64_t bbmap = ext4_block_group_get_block_bitmap(bg_ref->block_group,
+	    sb);
+	uint64_t ibmap = ext4_block_group_get_inode_bitmap(bg_ref->block_group,
+	    sb);
+
+	r = ext4_filesystem_index_in_group2blockaddr(sb, 0, bg_ref->index);
+	r += ext4_filesystem_bg_get_backup_blocks(bg_ref);
+
+	if (ext4_filesystem_blockaddr2group(sb, bbmap) != bg_ref->index)
+		bbmap = -1; /* Invalid */
+
+	if (ext4_filesystem_blockaddr2group(sb, ibmap) != bg_ref->index)
+		ibmap = -1;
+
+	while (1) {
+		if (r == bbmap || r == ibmap)
+			r++;
+		else if (r >= itable && r < (itable + itable_sz))
+			r = itable + itable_sz;
+		else
+			break;
+	}
+
+	return r;
 }
 
@@ -264,12 +291,12 @@
 	*goal = 0;
 	ext4_superblock_t *sb = inode_ref->fs->superblock;
-	
+
 	uint64_t inode_size = ext4_inode_get_size(sb, inode_ref->inode);
 	uint32_t block_size = ext4_superblock_get_block_size(sb);
 	uint32_t inode_block_count = inode_size / block_size;
-	
+
 	if (inode_size % block_size != 0)
 		inode_block_count++;
-	
+
 	/* If inode has some blocks, get last block address + 1 */
 	if (inode_block_count > 0) {
@@ -278,18 +305,16 @@
 		if (rc != EOK)
 			return rc;
-		
+
 		if (goal != 0) {
 			(*goal)++;
 			return EOK;
 		}
-		
 		/* If goal == 0, sparse file -> continue */
 	}
-	
+
 	/* Identify block group of inode */
 	uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(sb);
 	uint32_t block_group = (inode_ref->index - 1) / inodes_per_group;
-	block_size = ext4_superblock_get_block_size(sb);
-	
+
 	/* Load block group reference */
 	ext4_block_group_ref_t *bg_ref;
@@ -298,30 +323,7 @@
 	if (rc != EOK)
 		return rc;
-	
-	/* Compute indexes */
-	uint32_t block_group_count = ext4_superblock_get_block_group_count(sb);
-	uint32_t inode_table_first_block =
-	    ext4_block_group_get_inode_table_first_block(bg_ref->block_group, sb);
-	uint16_t inode_table_item_size = ext4_superblock_get_inode_size(sb);
-	uint32_t inode_table_bytes;
-	
-	/* Check for last block group */
-	if (block_group < block_group_count - 1) {
-		inode_table_bytes = inodes_per_group * inode_table_item_size;
-	} else {
-		/* Last block group could be smaller */
-		uint32_t inodes_count_total = ext4_superblock_get_inodes_count(sb);
-		inode_table_bytes =
-		    (inodes_count_total - ((block_group_count - 1) * inodes_per_group)) *
-		    inode_table_item_size;
-	}
-	
-	uint32_t inode_table_blocks = inode_table_bytes / block_size;
-	
-	if (inode_table_bytes % block_size)
-		inode_table_blocks++;
-	
-	*goal = inode_table_first_block + inode_table_blocks;
-	
+
+	*goal = ext4_balloc_get_first_data_block_in_group(sb, bg_ref);
+
 	return ext4_filesystem_put_block_group_ref(bg_ref);
 }
@@ -353,5 +355,5 @@
 	
 	/* Load block group number for goal and relative index */
-	uint32_t block_group = ext4_balloc_get_bgid_of_block(sb, goal);
+	uint32_t block_group = ext4_filesystem_blockaddr2group(sb, goal);
 	uint32_t index_in_group =
 	    ext4_filesystem_blockaddr2_index_in_group(sb, goal);
@@ -626,5 +628,5 @@
 	
 	/* Compute indexes */
-	uint32_t block_group = ext4_balloc_get_bgid_of_block(sb, fblock);
+	uint32_t block_group = ext4_filesystem_blockaddr2group(sb, fblock);
 	uint32_t index_in_group =
 	    ext4_filesystem_blockaddr2_index_in_group(sb, fblock);
Index: pace/lib/ext4/libext4_crc.c
===================================================================
--- uspace/lib/ext4/libext4_crc.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * Copyright (c) 2012 Frantisek Princ
- * 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 libext4
- * @{
- */
-
-/**
- * @file  libext4_crc.c
- */
-
-#include "libext4.h"
-
-uint16_t crc16(uint16_t crc, const uint8_t *buffer, size_t len)
-{
-	// TODO
-	return 0;
-}
-
-/**
- * @}
- */
Index: pace/lib/ext4/libext4_crc.h
===================================================================
--- uspace/lib/ext4/libext4_crc.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ 	(revision )
@@ -1,42 +1,0 @@
-/*
- * Copyright (c) 2012 Frantisek Princ
- * 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 libext4
- * @{
- */
-
-#ifndef LIBEXT4_LIBEXT4_CRC_H_
-#define LIBEXT4_LIBEXT4_CRC_H_
-
-extern uint16_t crc16(uint16_t, const uint8_t *, size_t);
-
-#endif
-
-/**
- * @}
- */
Index: uspace/lib/ext4/libext4_filesystem.c
===================================================================
--- uspace/lib/ext4/libext4_filesystem.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/ext4/libext4_filesystem.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -40,4 +40,6 @@
 #include <malloc.h>
 #include <ipc/vfs.h>
+#include <align.h>
+#include <crypto.h>
 #include "libext4.h"
 
@@ -53,4 +55,5 @@
     enum cache_mode cmode)
 {
+	int rc;
 	ext4_superblock_t *temp_superblock = NULL;
 
@@ -58,5 +61,5 @@
 
 	/* Initialize block library (4096 is size of communication channel) */
-	int rc = block_init(EXCHANGE_SERIALIZE, fs->device, 4096);
+	rc = block_init(fs->device, 4096);
 	if (rc != EOK)
 		goto err;
@@ -139,5 +142,5 @@
 	/* Release memory space for superblock */
 	free(fs->superblock);
-	
+
 	/* Finish work with block library */
 	block_cache_fini(fs->device);
@@ -250,4 +253,19 @@
 }
 
+/** Convert the absolute block number to group number
+ *
+ * @param sb    Pointer to the superblock
+ * @param b     Absolute block number
+ *
+ * @return      Group number
+ */
+uint32_t ext4_filesystem_blockaddr2group(ext4_superblock_t *sb, uint64_t b)
+{
+	uint32_t blocks_per_group = ext4_superblock_get_blocks_per_group(sb);
+	uint32_t first_block = ext4_superblock_get_first_data_block(sb);
+
+	return (b - first_block) / blocks_per_group;
+}
+
 /** Initialize block bitmap in block group.
  *
@@ -259,6 +277,13 @@
 static int ext4_filesystem_init_block_bitmap(ext4_block_group_ref_t *bg_ref)
 {
+	uint64_t itb;
+	uint32_t sz;
+	uint32_t i;
+
 	/* Load bitmap */
-	uint32_t bitmap_block_addr = ext4_block_group_get_block_bitmap(
+	ext4_superblock_t *sb = bg_ref->fs->superblock;
+	uint64_t bitmap_block_addr = ext4_block_group_get_block_bitmap(
+	    bg_ref->block_group, bg_ref->fs->superblock);
+	uint64_t bitmap_inode_addr = ext4_block_group_get_inode_bitmap(
 	    bg_ref->block_group, bg_ref->fs->superblock);
 	
@@ -272,19 +297,40 @@
 	
 	/* Initialize all bitmap bits to zero */
-	uint32_t block_size = ext4_superblock_get_block_size(bg_ref->fs->superblock);
+	uint32_t block_size = ext4_superblock_get_block_size(sb);
 	memset(bitmap, 0, block_size);
 	
-	/* Determine first block and first data block in group */
-	uint32_t first_idx = 0;
-	
-	uint32_t first_data = ext4_balloc_get_first_data_block_in_group(
-	    bg_ref->fs->superblock, bg_ref);
-	uint32_t first_data_idx = ext4_filesystem_blockaddr2_index_in_group(
-	    bg_ref->fs->superblock, first_data);
-	
+	/* Determine the number of reserved blocks in the group */
+	uint32_t reserved_cnt = ext4_filesystem_bg_get_backup_blocks(bg_ref);
+
 	/* Set bits from to first block to first data block - 1 to one (allocated) */
-	for (uint32_t block = first_idx; block < first_data_idx; ++block)
+	for (uint32_t block = 0; block < reserved_cnt; ++block)
 		ext4_bitmap_set_bit(bitmap, block);
-	
+
+	uint32_t bitmap_block_gid = ext4_filesystem_blockaddr2group(sb,
+	    bitmap_block_addr);
+	if (bitmap_block_gid == bg_ref->index) {
+		ext4_bitmap_set_bit(bitmap,
+		    ext4_filesystem_blockaddr2_index_in_group(sb, bitmap_block_addr));
+	}
+
+	uint32_t bitmap_inode_gid = ext4_filesystem_blockaddr2group(sb,
+	    bitmap_inode_addr);
+	if (bitmap_inode_gid == bg_ref->index) {
+		ext4_bitmap_set_bit(bitmap,
+		    ext4_filesystem_blockaddr2_index_in_group(sb, bitmap_inode_addr));
+	}
+
+	itb = ext4_block_group_get_inode_table_first_block(bg_ref->block_group,
+	    sb);
+	sz = ext4_filesystem_bg_get_itable_size(sb, bg_ref);
+
+	for (i = 0; i < sz; ++i, ++itb) {
+		uint32_t gid = ext4_filesystem_blockaddr2group(sb, itb);
+		if (gid == bg_ref->index) {
+			ext4_bitmap_set_bit(bitmap,
+			    ext4_filesystem_blockaddr2_index_in_group(sb, itb));
+		}
+	}
+
 	bitmap_block->dirty = true;
 	
@@ -423,5 +469,5 @@
 	}
 	
-	/* Inititialize in-memory representation */
+	/* Initialize in-memory representation */
 	newref->block_group = newref->block->data + offset;
 	newref->fs = fs;
@@ -488,5 +534,5 @@
 	/* If checksum not supported, 0 will be returned */
 	uint16_t crc = 0;
-	
+
 	/* Compute the checksum only if the filesystem supports it */
 	if (ext4_superblock_has_feature_read_only(sb,
@@ -501,11 +547,11 @@
 		
 		/* Initialization */
-		crc = crc16(~0, sb->uuid, sizeof(sb->uuid));
+		crc = crc16_ibm(~0, sb->uuid, sizeof(sb->uuid));
 		
 		/* Include index of block group */
-		crc = crc16(crc, (uint8_t *) &le_group, sizeof(le_group));
+		crc = crc16_ibm(crc, (uint8_t *) &le_group, sizeof(le_group));
 		
 		/* Compute crc from the first part (stop before checksum field) */
-		crc = crc16(crc, (uint8_t *) bg, offset);
+		crc = crc16_ibm(crc, (uint8_t *) bg, offset);
 		
 		/* Skip checksum */
@@ -516,5 +562,5 @@
 		    EXT4_FEATURE_INCOMPAT_64BIT)) &&
 		    (offset < ext4_superblock_get_desc_size(sb)))
-			crc = crc16(crc, ((uint8_t *) bg) + offset,
+			crc = crc16_ibm(crc, ((uint8_t *) bg) + offset,
 			    ext4_superblock_get_desc_size(sb) - offset);
 	}
@@ -523,7 +569,130 @@
 }
 
+/** Get the size of the block group's inode table
+ *
+ * @param sb     Pointer to the superblock
+ * @param bg_ref Pointer to the block group reference
+ *
+ * @return       Size of the inode table in blocks.
+ */
+uint32_t ext4_filesystem_bg_get_itable_size(ext4_superblock_t *sb,
+    ext4_block_group_ref_t *bg_ref)
+{
+	uint32_t itable_size;
+	uint32_t block_group_count = ext4_superblock_get_block_group_count(sb);
+	uint16_t inode_table_item_size = ext4_superblock_get_inode_size(sb);
+	uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(sb);
+	uint32_t block_size = ext4_superblock_get_block_size(sb);
+
+	if (bg_ref->index < block_group_count - 1) {
+		itable_size = inodes_per_group * inode_table_item_size;
+	} else {
+		/* Last block group could be smaller */
+		uint32_t inodes_count_total = ext4_superblock_get_inodes_count(sb);
+		itable_size =
+		    (inodes_count_total - ((block_group_count - 1) * inodes_per_group)) *
+		    inode_table_item_size;
+	}
+
+	return ROUND_UP(itable_size, block_size) / block_size;
+}
+
+/* Check if n is a power of p */
+static bool is_power_of(uint32_t n, unsigned p)
+{
+	if (p == 1 && n != p)
+		return false;
+
+	while (n != p) {
+		if (n < p)
+			return false;
+		else if ((n % p) != 0)
+			return false;
+
+		n /= p;
+	}
+
+	return true;
+}
+
+/** Get the number of blocks used by superblock + gdt + reserved gdt backups
+ *
+ * @param bg    Pointer to block group
+ *
+ * @return      Number of blocks
+ */
+uint32_t ext4_filesystem_bg_get_backup_blocks(ext4_block_group_ref_t *bg)
+{
+	uint32_t const idx = bg->index;
+	uint32_t r = 0;
+	bool has_backups = false;
+	ext4_superblock_t *sb = bg->fs->superblock;
+
+	/* First step: determine if the block group contains the backups */
+
+	if (idx <= 1)
+		has_backups = true;
+	else {
+		if (ext4_superblock_has_feature_compatible(sb,
+		    EXT4_FEATURE_COMPAT_SPARSE_SUPER2)) {
+			uint32_t g1, g2;
+
+			ext4_superblock_get_backup_groups_sparse2(sb,
+			    &g1, &g2);
+
+			if (idx == g1 || idx == g2)
+				has_backups = true;
+		} else if (!ext4_superblock_has_feature_read_only(sb,
+		    EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
+			/* Very old fs were all block groups have
+			 * superblock and block descriptors backups.
+			 */
+			has_backups = true;
+		} else {
+			if ((idx & 1) && (is_power_of(idx, 3) ||
+			    is_power_of(idx, 5) || is_power_of(idx, 7)))
+				has_backups = true;
+		}
+	}
+
+	if (has_backups) {
+		uint32_t bg_count;
+		uint32_t bg_desc_sz;
+		uint32_t gdt_table; /* Size of the GDT in blocks */
+		uint32_t block_size = ext4_superblock_get_block_size(sb);
+
+		/* Now we know that this block group has backups,
+		 * we have to compute how many blocks are reserved
+		 * for them
+		 */
+
+		if (idx == 0 && block_size == 1024) {
+			/* Special case for first group were the boot block
+			 * resides
+			 */
+			r++;
+		}
+
+		/* This accounts for the superblock */
+		r++;
+
+		/* Add the number of blocks used for the GDT */
+		bg_count = ext4_superblock_get_block_group_count(sb);
+		bg_desc_sz = ext4_superblock_get_desc_size(sb);
+		gdt_table = ROUND_UP(bg_count * bg_desc_sz, block_size) /
+		    block_size;
+
+		r += gdt_table;
+
+		/* And now the number of reserved GDT blocks */
+		r += ext4_superblock_get_reserved_gdt_blocks(sb);
+	}
+
+	return r;
+}
+
 /** Put reference to block group.
  *
- * @oaram ref Pointer for reference to be put back
+ * @param ref Pointer for reference to be put back
  *
  * @return Error code
Index: uspace/lib/ext4/libext4_filesystem.h
===================================================================
--- uspace/lib/ext4/libext4_filesystem.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/ext4/libext4_filesystem.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -47,4 +47,5 @@
 extern uint32_t ext4_filesystem_index_in_group2blockaddr(ext4_superblock_t *,
     uint32_t, uint32_t);
+extern uint32_t ext4_filesystem_blockaddr2group(ext4_superblock_t *, uint64_t);
 extern int ext4_filesystem_get_block_group_ref(ext4_filesystem_t *, uint32_t,
     ext4_block_group_ref_t **);
@@ -64,4 +65,7 @@
 extern int ext4_filesystem_append_inode_block(ext4_inode_ref_t *, uint32_t *,
     uint32_t *);
+uint32_t ext4_filesystem_bg_get_backup_blocks(ext4_block_group_ref_t *bg);
+uint32_t ext4_filesystem_bg_get_itable_size(ext4_superblock_t *sb,
+    ext4_block_group_ref_t *bg_ref);
 
 #endif
Index: uspace/lib/ext4/libext4_ialloc.c
===================================================================
--- uspace/lib/ext4/libext4_ialloc.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/ext4/libext4_ialloc.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -195,6 +195,18 @@
 		uint32_t used_dirs = ext4_block_group_get_used_dirs_count(bg, sb);
 		
-		/* Check if this block group is good candidate for allocation */
-		if ((free_inodes >= avg_free_inodes) && (free_blocks > 0)) {
+		/*
+		 * Check if this block group is a good candidate
+		 * for allocation.
+		 *
+		 * The criterion is based on the average number
+		 * of free inodes, unless we examine the last block
+		 * group. In that case the last block group might
+		 * have less than the average number of free inodes,
+		 * but it still needs to be taken as a candidate
+		 * because the previous block groups have zero free
+		 * blocks.
+		 */
+		if (((free_inodes >= avg_free_inodes) || (bgid == bg_count - 1)) &&
+		    (free_blocks > 0)) {
 			/* Load block with bitmap */
 			uint32_t bitmap_block_addr = ext4_block_group_get_inode_bitmap(
Index: uspace/lib/ext4/libext4_superblock.c
===================================================================
--- uspace/lib/ext4/libext4_superblock.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/ext4/libext4_superblock.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1298,4 +1298,52 @@
 }
 
+/** Get the backup groups used with SPARSE_SUPER2
+ *
+ * @param sb    Pointer to the superblock
+ * @param g1    Output pointer to the first backup group
+ * @param g2    Output pointer to the second backup group
+ */
+void ext4_superblock_get_backup_groups_sparse2(ext4_superblock_t *sb,
+    uint32_t *g1, uint32_t *g2)
+{
+	*g1 = uint32_t_le2host(sb->backup_bgs[0]);
+	*g2 = uint32_t_le2host(sb->backup_bgs[1]);
+}
+
+/** Set the backup groups (SPARSE SUPER2)
+ *
+ * @param sb    Pointer to the superblock
+ * @param g1    Index of the first group
+ * @param g2    Index of the second group
+ */
+void ext4_superblock_set_backup_groups_sparse2(ext4_superblock_t *sb,
+    uint32_t g1, uint32_t g2)
+{
+	sb->backup_bgs[0] = host2uint32_t_le(g1);
+	sb->backup_bgs[1] = host2uint32_t_le(g2);
+}
+
+/** Get the number of blocks (per group) reserved to GDT expansion
+ *
+ * @param sb    Pointer to the superblock
+ *
+ * @return      Number of blocks
+ */
+uint32_t ext4_superblock_get_reserved_gdt_blocks(ext4_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->reserved_gdt_blocks);
+}
+
+/** Set the number of blocks (per group) reserved to GDT expansion
+ *
+ * @param sb    Pointer to the superblock
+ * @param n     Number of reserved blocks
+ */
+void ext4_superblock_set_reserved_gdt_blocks(ext4_superblock_t *sb,
+    uint32_t n)
+{
+	sb->reserved_gdt_blocks = host2uint32_t_le(n);
+}
+
 /**
  * @}
Index: uspace/lib/ext4/libext4_superblock.h
===================================================================
--- uspace/lib/ext4/libext4_superblock.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/ext4/libext4_superblock.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -135,4 +135,13 @@
 extern void ext4_superblock_set_flags(ext4_superblock_t *, uint32_t);
 
+extern void ext4_superblock_get_backup_groups_sparse2(ext4_superblock_t *sb,
+    uint32_t *g1, uint32_t *g2);
+extern void ext4_superblock_set_backup_groups_sparse2(ext4_superblock_t *sb,
+    uint32_t g1, uint32_t g2);
+
+extern uint32_t ext4_superblock_get_reserved_gdt_blocks(ext4_superblock_t *sb);
+extern void ext4_superblock_set_reserved_gdt_blocks(ext4_superblock_t *sb,
+    uint32_t n);
+
 /* More complex superblock functions */
 extern bool ext4_superblock_has_flag(ext4_superblock_t *, uint32_t);
Index: uspace/lib/ext4/libext4_types.h
===================================================================
--- uspace/lib/ext4/libext4_types.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/ext4/libext4_types.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -83,7 +83,7 @@
 	 * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
 	 */
-	uint8_t s_prealloc_blocks;       /* Number of blocks to try to preallocate */
-	uint8_t s_prealloc_dir_blocks;   /* Number to preallocate for dirs */
-	uint16_t s_reserved_gdt_blocks;  /* Per group desc for online growth */
+	uint8_t prealloc_blocks;        /* Number of blocks to try to preallocate */
+	uint8_t prealloc_dir_blocks;    /* Number to preallocate for dirs */
+	uint16_t reserved_gdt_blocks;   /* Per group desc for online growth */
 	
 	/*
@@ -133,6 +133,11 @@
 	uint64_t last_error_block;          /* Block involved of last error */
 	uint8_t last_error_func[32];        /* Function where the error happened */
-	uint8_t mount_opts[64];
-	uint32_t padding[112];              /* Padding to the end of the block */
+	uint8_t mount_opts[64];             /* String containing the mount options */
+	uint32_t usr_quota_inum;            /* Inode number of user quota file */
+	uint32_t grp_quota_inum;            /* Inode number of group quota file */
+	uint32_t overhead_blocks;           /* Overhead blocks/clusters */
+	uint32_t backup_bgs[2];             /* Block groups containing superblock backups (if SPARSE_SUPER2) */
+	uint32_t encrypt_algos;             /* Encrypt algorithm in use */
+	uint32_t padding[105];              /* Padding to the end of the block */
 } __attribute__((packed)) ext4_superblock_t;
 
@@ -176,4 +181,5 @@
 #define EXT4_FEATURE_COMPAT_RESIZE_INODE   0x0010
 #define EXT4_FEATURE_COMPAT_DIR_INDEX      0x0020
+#define EXT4_FEATURE_COMPAT_SPARSE_SUPER2  0x0200
 
 /*
@@ -208,5 +214,6 @@
 	(EXT4_FEATURE_INCOMPAT_FILETYPE | \
 	EXT4_FEATURE_INCOMPAT_EXTENTS | \
-	EXT4_FEATURE_INCOMPAT_64BIT)
+	EXT4_FEATURE_INCOMPAT_64BIT | \
+	EXT4_FEATURE_INCOMPAT_FLEX_BG)
 
 #define EXT4_FEATURE_RO_COMPAT_SUPP \
Index: uspace/lib/fdisk/src/fdisk.c
===================================================================
--- uspace/lib/fdisk/src/fdisk.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/fdisk/src/fdisk.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -228,5 +228,5 @@
 
 	if (!info->blk_inited) {
-		rc = block_init(EXCHANGE_SERIALIZE, info->svcid, 2048);
+		rc = block_init(info->svcid, 2048);
 		if (rc != EOK)
 			return rc;
@@ -559,5 +559,5 @@
 	int rc;
 
-	rc = block_init(EXCHANGE_SERIALIZE, dev->sid, 2048);
+	rc = block_init(dev->sid, 2048);
 	if (rc != EOK)
 		return rc;
Index: uspace/lib/fs/libfs.c
===================================================================
--- uspace/lib/fs/libfs.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/fs/libfs.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -342,5 +342,7 @@
 	 * Ask VFS for callback connection.
 	 */
-	async_connect_to_me(exch, 0, 0, 0, vfs_connection, NULL);
+	port_id_t port;
+	rc = async_create_callback_port(exch, INTERFACE_VFS_DRIVER_CB, 0, 0,
+	    vfs_connection, NULL, &port);
 	
 	/*
@@ -371,5 +373,5 @@
 	 * the same connection fibril as well.
 	 */
-	async_set_client_connection(vfs_connection);
+	async_set_fallback_port_handler(vfs_connection, NULL);
 	
 	return IPC_GET_RETVAL(answer);
Index: uspace/lib/gpt/libgpt.c
===================================================================
--- uspace/lib/gpt/libgpt.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/gpt/libgpt.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -137,5 +137,5 @@
 int gpt_read_header(gpt_label_t *label, service_id_t dev_handle)
 {
-	int rc = block_init(EXCHANGE_ATOMIC, dev_handle, 512);
+	int rc = block_init(dev_handle, 512);
 	if (rc != EOK)
 		return rc;
@@ -191,5 +191,5 @@
 {
 	/* The comm_size argument (the last one) is ignored */
-	int rc = block_init(EXCHANGE_ATOMIC, dev_handle, 4096);
+	int rc = block_init(dev_handle, 4096);
 	if ((rc != EOK) && (rc != EEXIST))
 		return rc;
@@ -288,6 +288,5 @@
 	}
 	
-	int rc = block_init(EXCHANGE_SERIALIZE, label->device,
-	    sizeof(gpt_entry_t));
+	int rc = block_init(label->device, sizeof(gpt_entry_t));
 	if (rc != EOK) {
 		gpt_free_partitions(label->parts);
@@ -348,5 +347,5 @@
 {
 	/* comm_size of 4096 is ignored */
-	int rc = block_init(EXCHANGE_ATOMIC, dev_handle, 4096);
+	int rc = block_init(dev_handle, 4096);
 	if ((rc != EOK) && (rc != EEXIST))
 		return rc;
Index: uspace/lib/graph/graph.c
===================================================================
--- uspace/lib/graph/graph.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/graph/graph.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -606,6 +606,6 @@
 {
 	/* Find the visualizer or renderer with the given service ID. */
-	visualizer_t *vs = graph_get_visualizer(IPC_GET_ARG1(*icall));
-	renderer_t *rnd = graph_get_renderer(IPC_GET_ARG1(*icall));
+	visualizer_t *vs = graph_get_visualizer(IPC_GET_ARG2(*icall));
+	renderer_t *rnd = graph_get_renderer(IPC_GET_ARG2(*icall));
 	
 	if (vs != NULL)
Index: uspace/lib/gui/terminal.c
===================================================================
--- uspace/lib/gui/terminal.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/gui/terminal.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -679,5 +679,5 @@
 	
 	list_foreach(terms, link, terminal_t, cur) {
-		if (cur->dsid == (service_id_t) IPC_GET_ARG1(*icall)) {
+		if (cur->dsid == (service_id_t) IPC_GET_ARG2(*icall)) {
 			term = cur;
 			break;
@@ -744,5 +744,5 @@
 	term->top_row = 0;
 	
-	async_set_client_connection(term_connection);
+	async_set_fallback_port_handler(term_connection, NULL);
 	con_srvs_init(&term->srvs);
 	term->srvs.ops = &con_ops;
Index: uspace/lib/gui/window.c
===================================================================
--- uspace/lib/gui/window.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/gui/window.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -623,6 +623,6 @@
 	}
 	
-	async_sess_t *reg_sess = loc_service_connect(EXCHANGE_SERIALIZE,
-	    reg_dsid, 0);
+	async_sess_t *reg_sess =
+	    loc_service_connect(reg_dsid, INTERFACE_COMPOSITOR, 0);
 	if (reg_sess == NULL) {
 		free(win);
@@ -639,5 +639,5 @@
 	}
 	
-	win->osess = loc_service_connect(EXCHANGE_SERIALIZE, out_dsid, 0);
+	win->osess = loc_service_connect(out_dsid, INTERFACE_COMPOSITOR, 0);
 	if (win->osess == NULL) {
 		free(win);
@@ -645,5 +645,5 @@
 	}
 	
-	win->isess = loc_service_connect(EXCHANGE_SERIALIZE, in_dsid, 0);
+	win->isess = loc_service_connect(in_dsid, INTERFACE_COMPOSITOR, 0);
 	if (win->isess == NULL) {
 		async_hangup(win->osess);
Index: uspace/lib/hound/src/protocol.c
===================================================================
--- uspace/lib/hound/src/protocol.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/hound/src/protocol.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -97,5 +97,5 @@
 	if (ret != EOK)
 		return NULL;
-	return loc_service_connect(EXCHANGE_PARALLEL, id, IPC_FLAG_BLOCKING);
+	return loc_service_connect(id, INTERFACE_HOUND, IPC_FLAG_BLOCKING);
 }
 
Index: uspace/lib/label/src/mbr.c
===================================================================
--- uspace/lib/label/src/mbr.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/label/src/mbr.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -536,5 +536,5 @@
 		}
 		if (label->ext_part != NULL) {
-			rc = EEXISTS;
+			rc = EEXIST;
 			goto error;
 		}
Index: uspace/lib/math/Makefile
===================================================================
--- uspace/lib/math/Makefile	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/Makefile	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -41,6 +41,25 @@
 
 GENERIC_SOURCES = \
+	generic/acos.c \
+	generic/asin.c \
+	generic/atan.c \
+	generic/atan2.c \
+	generic/ceil.c \
+	generic/cosh.c \
+	generic/exp.c \
+	generic/fabs.c \
+	generic/floor.c \
+	generic/fmod.c \
+	generic/frexp.c \
+	generic/ldexp.c \
+	generic/log.c \
+	generic/log10.c \
+	generic/modf.c \
+	generic/pow.c \
+	generic/sinh.c \
+	generic/sqrt.c \
+	generic/tan.c \
+	generic/tanh.c \
 	generic/trig.c \
-	generic/mod.c \
 	generic/trunc.c
 
Index: uspace/lib/math/arch/abs32le/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/abs32le/include/libarch/math.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/abs32le/include/libarch/math.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2014 Martin Decky
+ * Copyright (c) 2015 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,33 +37,487 @@
 #define LIBMATH_abs32le_MATH_H_
 
+#include <acos.h>
+#include <asin.h>
+#include <atan.h>
+#include <atan2.h>
+#include <ceil.h>
+#include <cosh.h>
+#include <exp.h>
+#include <fabs.h>
+#include <floor.h>
+#include <fmod.h>
+#include <frexp.h>
+#include <ldexp.h>
+#include <log.h>
+#include <log10.h>
 #include <mathtypes.h>
-#include <mod.h>
+#include <modf.h>
+#include <pow.h>
+#include <sinh.h>
+#include <sqrt.h>
+#include <tan.h>
+#include <tanh.h>
+#include <trig.h>
 #include <trunc.h>
-#include <trig.h>
+
+#define HUGE_VAL FLOAT64_INF
+
+static inline float64_t acos_f64(float64_t val)
+{
+	return float64_acos(val);
+}
+
+static inline float32_t acos_f32(float32_t val)
+{
+	return float32_acos(val);
+}
+
+static inline float64_t asin_f64(float64_t val)
+{
+	return float64_asin(val);
+}
+
+static inline float32_t asin_f32(float32_t val)
+{
+	return float32_asin(val);
+}
+
+static inline float64_t atan_f64(float64_t val)
+{
+	return float64_atan(val);
+}
+
+static inline float32_t atan_f32(float32_t val)
+{
+	return float32_atan(val);
+}
+
+static inline float64_t atan2_f64(float64_t y, float64_t x)
+{
+	return float64_atan2(y, x);
+}
+
+static inline float32_t atan2_f32(float32_t y, float32_t x)
+{
+	return float32_atan2(y, x);
+}
+
+static inline float64_t ceil_f64(float64_t val)
+{
+	return float64_ceil(val);
+}
+
+static inline float32_t ceil_f32(float32_t val)
+{
+	return float32_ceil(val);
+}
+
+static inline float64_t cos_f64(float64_t val)
+{
+	return float64_cos(val);
+}
+
+static inline float32_t cos_f32(float32_t val)
+{
+	return float32_cos(val);
+}
+
+static inline float64_t cosh_f64(float64_t val)
+{
+	return float64_cosh(val);
+}
+
+static inline float32_t cosh_f32(float32_t val)
+{
+	return float32_cosh(val);
+}
+
+static inline float64_t exp_f64(float64_t val)
+{
+	return float64_exp(val);
+}
+
+static inline float32_t exp_f32(float32_t val)
+{
+	return float32_exp(val);
+}
+
+static inline float64_t fabs_f64(float64_t val)
+{
+	return float64_fabs(val);
+}
+
+static inline float32_t fabs_f32(float32_t val)
+{
+	return float32_fabs(val);
+}
+
+static inline float64_t floor_f64(float64_t val)
+{
+	return float64_floor(val);
+}
+
+static inline float32_t floor_f32(float32_t val)
+{
+	return float32_floor(val);
+}
+static inline float64_t fmod_f64(float64_t dividend, float64_t divisor)
+{
+	return float64_fmod(dividend, divisor);
+}
+
+static inline float64_t fmod_f32(float32_t dividend, float32_t divisor)
+{
+	return float32_fmod(dividend, divisor);
+}
+
+static inline float64_t frexp_f64(float64_t x, int *exp)
+{
+	return float64_frexp(x, exp);
+}
+
+static inline float64_t frexp_f32(float32_t x, int *exp)
+{
+	return float32_frexp(x, exp);
+}
+
+static inline float64_t ldexp_f64(float64_t x, int exp)
+{
+	return float64_ldexp(x, exp);
+}
+
+static inline float64_t ldexp_f32(float32_t x, int exp)
+{
+	return float32_ldexp(x, exp);
+}
+
+static inline float64_t log_f64(float64_t val)
+{
+	return float64_log(val);
+}
+
+static inline float32_t log_f32(float32_t val)
+{
+	return float32_log(val);
+}
+
+static inline float64_t log10_f64(float64_t val)
+{
+	return float64_log10(val);
+}
+
+static inline float32_t log10_f32(float32_t val)
+{
+	return float32_log10(val);
+}
+
+static inline float64_t modf_f64(float64_t value, float64_t *iptr)
+{
+	return float64_modf(value, iptr);
+}
+
+static inline float64_t modf_f32(float32_t value, float32_t *iptr)
+{
+	return float32_modf(value, iptr);
+}
+
+static inline float64_t pow_f64(float64_t x, float64_t y)
+{
+	return float64_pow(x, y);
+}
+
+static inline float32_t pow_f32(float32_t x, float32_t y)
+{
+	return float32_pow(x, y);
+}
+
+static inline float64_t sin_f64(float64_t val)
+{
+	return float64_sin(val);
+}
+
+static inline float32_t sin_f32(float32_t val)
+{
+	return float32_sin(val);
+}
+
+static inline float64_t sinh_f64(float64_t val)
+{
+	return float64_sinh(val);
+}
+
+static inline float32_t sinh_f32(float32_t val)
+{
+	return float32_sinh(val);
+}
+
+static inline float64_t sqrt_f64(float64_t val)
+{
+	return float64_sqrt(val);
+}
+
+static inline float32_t sqrt_f32(float32_t val)
+{
+	return float32_sqrt(val);
+}
+
+static inline float64_t tan_f64(float64_t val)
+{
+	return float64_tan(val);
+}
+
+static inline float32_t tan_f32(float32_t val)
+{
+	return float32_tan(val);
+}
+
+static inline float64_t tanh_f64(float64_t val)
+{
+	return float64_tanh(val);
+}
+
+static inline float32_t tanh_f32(float32_t val)
+{
+	return float32_tanh(val);
+}
+
+static inline float64_t trunc_f64(float64_t val)
+{
+	return float64_trunc(val);
+}
+
+static inline float32_t trunc_f32(float32_t val)
+{
+	return float32_trunc(val);
+}
+
+static inline float64_t acos(float64_t val)
+{
+	return acos_f64(val);
+}
+
+static inline float32_t acosf(float32_t val)
+{
+	return acos_f32(val);
+}
+
+static inline float64_t asin(float64_t val)
+{
+	return asin_f64(val);
+}
+
+static inline float32_t asinf(float32_t val)
+{
+	return asin_f32(val);
+}
+
+static inline float64_t atan(float64_t val)
+{
+	return atan_f64(val);
+}
+
+static inline float32_t atanf(float32_t val)
+{
+	return atan_f32(val);
+}
+
+static inline float64_t atan2(float64_t y, float64_t x)
+{
+	return atan2_f64(y, x);
+}
+
+static inline float32_t atan2f(float32_t y, float32_t x)
+{
+	return atan2_f32(y, x);
+}
+
+static inline float64_t ceil(float64_t val)
+{
+	return ceil_f64(val);
+}
+
+static inline float32_t ceilf(float32_t val)
+{
+	return ceil_f32(val);
+}
+
+static inline float64_t cos(float64_t val)
+{
+	return cos_f64(val);
+}
+
+static inline float32_t cosf(float32_t val)
+{
+	return cos_f32(val);
+}
+
+static inline float64_t cosh(float64_t val)
+{
+	return cosh_f64(val);
+}
+
+static inline float32_t coshf(float32_t val)
+{
+	return cosh_f32(val);
+}
+
+static inline float64_t exp(float64_t val)
+{
+	return exp_f64(val);
+}
+
+static inline float32_t expf(float32_t val)
+{
+	return exp_f32(val);
+}
+
+static inline float64_t fabs(float64_t val)
+{
+	return fabs_f64(val);
+}
+
+static inline float32_t fabsf(float32_t val)
+{
+	return fabs_f32(val);
+}
+
+static inline float64_t floor(float64_t val)
+{
+	return floor_f64(val);
+}
+
+static inline float32_t floorf(float32_t val)
+{
+	return floor_f32(val);
+}
 
 static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return float64_mod(dividend, divisor);
+	return fmod_f64(dividend, divisor);
+}
+
+static inline float32_t fmodf(float32_t dividend, float32_t divisor)
+{
+	return fmod_f32(dividend, divisor);
+}
+
+static inline float64_t frexp(float64_t x, int *exp)
+{
+	return frexp_f64(x, exp);
+}
+
+static inline float32_t frexpf(float32_t x, int *exp)
+{
+	return frexp_f32(x, exp);
+}
+
+static inline float64_t ldexp(float64_t x, int exp)
+{
+	return ldexp_f64(x, exp);
+}
+
+static inline float32_t ldexpf(float32_t x, int exp)
+{
+	return ldexp_f32(x, exp);
+}
+
+static inline float64_t log(float64_t val)
+{
+	return log_f64(val);
+}
+
+static inline float32_t logf(float32_t val)
+{
+	return log_f32(val);
+}
+
+static inline float64_t log10(float64_t val)
+{
+	return log10_f64(val);
+}
+
+static inline float32_t log10f(float32_t val)
+{
+	return log10_f32(val);
+}
+
+static inline float64_t modf(float64_t value, float64_t *iptr)
+{
+	return modf_f64(value, iptr);
+}
+
+static inline float32_t modff(float32_t value, float32_t *iptr)
+{
+	return modf_f32(value, iptr);
+}
+
+static inline float64_t pow(float64_t x, float64_t y)
+{
+	return pow_f64(x, y);
+}
+
+static inline float32_t powf(float32_t x, float32_t y)
+{
+	return pow_f32(x, y);
+}
+
+static inline float64_t sin(float64_t val)
+{
+	return sin_f64(val);
+}
+
+static inline float32_t sinf(float32_t val)
+{
+	return sin_f32(val);
+}
+
+static inline float64_t sinh(float64_t val)
+{
+	return sinh_f64(val);
+}
+
+static inline float32_t sinhf(float32_t val)
+{
+	return sinh_f32(val);
+}
+
+static inline float64_t sqrt(float64_t val)
+{
+	return sqrt_f64(val);
+}
+
+static inline float32_t sqrtf(float32_t val)
+{
+	return sqrt_f32(val);
+}
+
+static inline float64_t tan(float64_t val)
+{
+	return tan_f64(val);
+}
+
+static inline float32_t tanf(float32_t val)
+{
+	return tan_f32(val);
+}
+
+static inline float64_t tanh(float64_t val)
+{
+	return tanh_f64(val);
+}
+
+static inline float32_t tanhf(float32_t val)
+{
+	return tanh_f32(val);
 }
 
 static inline float64_t trunc(float64_t val)
 {
-	float64_u arg;
-	arg.val = val;
-	
-	float64_u ret;
-	ret.data = trunc_float64(arg.data);
-	
-	return ret.val;
-}
-
-static inline float64_t sin(float64_t val)
-{
-	return float64_sin(val);
-}
-
-static inline float64_t cos(float64_t val)
-{
-	return float64_cos(val);
+	return trunc_f64(val);
+}
+
+static inline float32_t truncf(float32_t val)
+{
+	return trunc_f32(val);
 }
 
Index: uspace/lib/math/arch/amd64/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/amd64/include/libarch/math.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/amd64/include/libarch/math.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2014 Martin Decky
+ * Copyright (c) 2015 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,15 +37,479 @@
 #define LIBMATH_amd64_MATH_H_
 
+#include <acos.h>
+#include <asin.h>
+#include <atan.h>
+#include <atan2.h>
+#include <ceil.h>
+#include <cosh.h>
+#include <exp.h>
+#include <fabs.h>
+#include <floor.h>
+#include <fmod.h>
+#include <frexp.h>
+#include <ldexp.h>
+#include <log.h>
+#include <log10.h>
 #include <mathtypes.h>
-#include <mod.h>
+#include <modf.h>
+#include <pow.h>
+#include <sinh.h>
+#include <sqrt.h>
+#include <tan.h>
+#include <tanh.h>
+#include <trig.h>
+#include <trunc.h>
+
+#define HUGE_VAL FLOAT64_INF
+
+static inline float64_t acos_f64(float64_t val)
+{
+	return float64_acos(val);
+}
+
+static inline float32_t acos_f32(float32_t val)
+{
+	return float32_acos(val);
+}
+
+static inline float64_t asin_f64(float64_t val)
+{
+	return float64_asin(val);
+}
+
+static inline float32_t asin_f32(float32_t val)
+{
+	return float32_asin(val);
+}
+
+static inline float64_t atan_f64(float64_t val)
+{
+	return float64_atan(val);
+}
+
+static inline float32_t atan_f32(float32_t val)
+{
+	return float32_atan(val);
+}
+
+static inline float64_t atan2_f64(float64_t y, float64_t x)
+{
+	return float64_atan2(y, x);
+}
+
+static inline float32_t atan2_f32(float32_t y, float32_t x)
+{
+	return float32_atan2(y, x);
+}
+
+static inline float64_t ceil_f64(float64_t val)
+{
+	return float64_ceil(val);
+}
+
+static inline float32_t ceil_f32(float32_t val)
+{
+	return float32_ceil(val);
+}
+
+extern float64_t cos_f64(float64_t);
+
+static inline float32_t cos_f32(float32_t val)
+{
+	return (float32_t)cos_f64((float64_t)val);
+}
+
+static inline float64_t cosh_f64(float64_t val)
+{
+	return float64_cosh(val);
+}
+
+static inline float32_t cosh_f32(float32_t val)
+{
+	return float32_cosh(val);
+}
+
+static inline float64_t exp_f64(float64_t val)
+{
+	return float64_exp(val);
+}
+
+static inline float32_t exp_f32(float32_t val)
+{
+	return float32_exp(val);
+}
+
+static inline float64_t fabs_f64(float64_t val)
+{
+	return float64_fabs(val);
+}
+
+static inline float32_t fabs_f32(float32_t val)
+{
+	return float32_fabs(val);
+}
+
+static inline float64_t floor_f64(float64_t val)
+{
+	return float64_floor(val);
+}
+
+static inline float32_t floor_f32(float32_t val)
+{
+	return float32_floor(val);
+}
+static inline float64_t fmod_f64(float64_t dividend, float64_t divisor)
+{
+	return float64_fmod(dividend, divisor);
+}
+
+static inline float64_t fmod_f32(float32_t dividend, float32_t divisor)
+{
+	return float32_fmod(dividend, divisor);
+}
+
+static inline float64_t frexp_f64(float64_t x, int *exp)
+{
+	return float64_frexp(x, exp);
+}
+
+static inline float64_t frexp_f32(float32_t x, int *exp)
+{
+	return float32_frexp(x, exp);
+}
+
+static inline float64_t ldexp_f64(float64_t x, int exp)
+{
+	return float64_ldexp(x, exp);
+}
+
+static inline float64_t ldexp_f32(float32_t x, int exp)
+{
+	return float32_ldexp(x, exp);
+}
+
+static inline float64_t log_f64(float64_t val)
+{
+	return float64_log(val);
+}
+
+static inline float32_t log_f32(float32_t val)
+{
+	return float32_log(val);
+}
+
+static inline float64_t log10_f64(float64_t val)
+{
+	return float64_log10(val);
+}
+
+static inline float32_t log10_f32(float32_t val)
+{
+	return float32_log10(val);
+}
+
+static inline float64_t modf_f64(float64_t value, float64_t *iptr)
+{
+	return float64_modf(value, iptr);
+}
+
+static inline float64_t modf_f32(float32_t value, float32_t *iptr)
+{
+	return float32_modf(value, iptr);
+}
+
+static inline float64_t pow_f64(float64_t x, float64_t y)
+{
+	return float64_pow(x, y);
+}
+
+static inline float32_t pow_f32(float32_t x, float32_t y)
+{
+	return float32_pow(x, y);
+}
+
+extern float64_t sin_f64(float64_t);
+
+static inline float32_t sin_f32(float32_t val)
+{
+	return (float32_t)sin_f64((float64_t)val);
+}
+
+static inline float64_t sinh_f64(float64_t val)
+{
+	return float64_sinh(val);
+}
+
+static inline float32_t sinh_f32(float32_t val)
+{
+	return float32_sinh(val);
+}
+
+static inline float64_t sqrt_f64(float64_t val)
+{
+	return float64_sqrt(val);
+}
+
+static inline float32_t sqrt_f32(float32_t val)
+{
+	return float32_sqrt(val);
+}
+
+static inline float64_t tan_f64(float64_t val)
+{
+	return float64_tan(val);
+}
+
+static inline float32_t tan_f32(float32_t val)
+{
+	return float32_tan(val);
+}
+
+static inline float64_t tanh_f64(float64_t val)
+{
+	return float64_tanh(val);
+}
+
+static inline float32_t tanh_f32(float32_t val)
+{
+	return float32_tanh(val);
+}
+
+extern float64_t trunc_f64(float64_t);
+
+static inline float32_t trunc_f32(float32_t val)
+{
+	return (float32_t)trunc_f64((float64_t)val);
+}
+
+static inline float64_t acos(float64_t val)
+{
+	return acos_f64(val);
+}
+
+static inline float32_t acosf(float32_t val)
+{
+	return acos_f32(val);
+}
+
+static inline float64_t asin(float64_t val)
+{
+	return asin_f64(val);
+}
+
+static inline float32_t asinf(float32_t val)
+{
+	return asin_f32(val);
+}
+
+static inline float64_t atan(float64_t val)
+{
+	return atan_f64(val);
+}
+
+static inline float32_t atanf(float32_t val)
+{
+	return atan_f32(val);
+}
+
+static inline float64_t atan2(float64_t y, float64_t x)
+{
+	return atan2_f64(y, x);
+}
+
+static inline float32_t atan2f(float32_t y, float32_t x)
+{
+	return atan2_f32(y, x);
+}
+
+static inline float64_t ceil(float64_t val)
+{
+	return ceil_f64(val);
+}
+
+static inline float32_t ceilf(float32_t val)
+{
+	return ceil_f32(val);
+}
+
+static inline float64_t cos(float64_t val)
+{
+	return cos_f64(val);
+}
+
+static inline float32_t cosf(float32_t val)
+{
+	return cos_f32(val);
+}
+
+static inline float64_t cosh(float64_t val)
+{
+	return cosh_f64(val);
+}
+
+static inline float32_t coshf(float32_t val)
+{
+	return cosh_f32(val);
+}
+
+static inline float64_t exp(float64_t val)
+{
+	return exp_f64(val);
+}
+
+static inline float32_t expf(float32_t val)
+{
+	return exp_f32(val);
+}
+
+static inline float64_t fabs(float64_t val)
+{
+	return fabs_f64(val);
+}
+
+static inline float32_t fabsf(float32_t val)
+{
+	return fabs_f32(val);
+}
+
+static inline float64_t floor(float64_t val)
+{
+	return floor_f64(val);
+}
+
+static inline float32_t floorf(float32_t val)
+{
+	return floor_f32(val);
+}
 
 static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return float64_mod(dividend, divisor);
-}
-
-extern float64_t sin(float64_t);
-extern float64_t cos(float64_t);
-extern float64_t trunc(float64_t);
+	return fmod_f64(dividend, divisor);
+}
+
+static inline float32_t fmodf(float32_t dividend, float32_t divisor)
+{
+	return fmod_f32(dividend, divisor);
+}
+
+static inline float64_t frexp(float64_t x, int *exp)
+{
+	return frexp_f64(x, exp);
+}
+
+static inline float32_t frexpf(float32_t x, int *exp)
+{
+	return frexp_f32(x, exp);
+}
+
+static inline float64_t ldexp(float64_t x, int exp)
+{
+	return ldexp_f64(x, exp);
+}
+
+static inline float32_t ldexpf(float32_t x, int exp)
+{
+	return ldexp_f32(x, exp);
+}
+
+static inline float64_t log(float64_t val)
+{
+	return log_f64(val);
+}
+
+static inline float32_t logf(float32_t val)
+{
+	return log_f32(val);
+}
+
+static inline float64_t log10(float64_t val)
+{
+	return log10_f64(val);
+}
+
+static inline float32_t log10f(float32_t val)
+{
+	return log10_f32(val);
+}
+
+static inline float64_t modf(float64_t value, float64_t *iptr)
+{
+	return modf_f64(value, iptr);
+}
+
+static inline float32_t modff(float32_t value, float32_t *iptr)
+{
+	return modf_f32(value, iptr);
+}
+
+static inline float64_t pow(float64_t x, float64_t y)
+{
+	return pow_f64(x, y);
+}
+
+static inline float32_t powf(float32_t x, float32_t y)
+{
+	return pow_f32(x, y);
+}
+
+static inline float64_t sin(float64_t val)
+{
+	return sin_f64(val);
+}
+
+static inline float32_t sinf(float32_t val)
+{
+	return sin_f32(val);
+}
+
+static inline float64_t sinh(float64_t val)
+{
+	return sinh_f64(val);
+}
+
+static inline float32_t sinhf(float32_t val)
+{
+	return sinh_f32(val);
+}
+
+static inline float64_t sqrt(float64_t val)
+{
+	return sqrt_f64(val);
+}
+
+static inline float32_t sqrtf(float32_t val)
+{
+	return sqrt_f32(val);
+}
+
+static inline float64_t tan(float64_t val)
+{
+	return tan_f64(val);
+}
+
+static inline float32_t tanf(float32_t val)
+{
+	return tan_f32(val);
+}
+
+static inline float64_t tanh(float64_t val)
+{
+	return tanh_f64(val);
+}
+
+static inline float32_t tanhf(float32_t val)
+{
+	return tanh_f32(val);
+}
+
+static inline float64_t trunc(float64_t val)
+{
+	return trunc_f64(val);
+}
+
+static inline float32_t truncf(float32_t val)
+{
+	return trunc_f32(val);
+}
 
 #endif
Index: uspace/lib/math/arch/amd64/src/cos.S
===================================================================
--- uspace/lib/math/arch/amd64/src/cos.S	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/amd64/src/cos.S	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -31,7 +31,7 @@
 .text
 
-.global cos
+.global cos_f64
 
-cos:
+cos_f64:
 	pushq %rbp
 	movq %rsp, %rbp
Index: uspace/lib/math/arch/amd64/src/sin.S
===================================================================
--- uspace/lib/math/arch/amd64/src/sin.S	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/amd64/src/sin.S	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -31,7 +31,7 @@
 .text
 
-.global sin
+.global sin_f64
 
-sin:
+sin_f64:
 	pushq %rbp
 	movq %rsp, %rbp
Index: uspace/lib/math/arch/amd64/src/trunc.S
===================================================================
--- uspace/lib/math/arch/amd64/src/trunc.S	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/amd64/src/trunc.S	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -31,7 +31,7 @@
 .text
 
-.global trunc
+.global trunc_f64
 
-trunc:
+trunc_f64:
 	pushq %rbp
 	movq %rsp, %rbp
Index: uspace/lib/math/arch/arm32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/arm32/include/libarch/math.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/arm32/include/libarch/math.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2014 Martin Decky
+ * Copyright (c) 2015 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,33 +37,487 @@
 #define LIBMATH_arm32_MATH_H_
 
+#include <acos.h>
+#include <asin.h>
+#include <atan.h>
+#include <atan2.h>
+#include <ceil.h>
+#include <cosh.h>
+#include <exp.h>
+#include <fabs.h>
+#include <floor.h>
+#include <fmod.h>
+#include <frexp.h>
+#include <ldexp.h>
+#include <log.h>
+#include <log10.h>
 #include <mathtypes.h>
-#include <mod.h>
+#include <modf.h>
+#include <pow.h>
+#include <sinh.h>
+#include <sqrt.h>
+#include <tan.h>
+#include <tanh.h>
+#include <trig.h>
 #include <trunc.h>
-#include <trig.h>
+
+#define HUGE_VAL FLOAT64_INF
+
+static inline float64_t acos_f64(float64_t val)
+{
+	return float64_acos(val);
+}
+
+static inline float32_t acos_f32(float32_t val)
+{
+	return float32_acos(val);
+}
+
+static inline float64_t asin_f64(float64_t val)
+{
+	return float64_asin(val);
+}
+
+static inline float32_t asin_f32(float32_t val)
+{
+	return float32_asin(val);
+}
+
+static inline float64_t atan_f64(float64_t val)
+{
+	return float64_atan(val);
+}
+
+static inline float32_t atan_f32(float32_t val)
+{
+	return float32_atan(val);
+}
+
+static inline float64_t atan2_f64(float64_t y, float64_t x)
+{
+	return float64_atan2(y, x);
+}
+
+static inline float32_t atan2_f32(float32_t y, float32_t x)
+{
+	return float32_atan2(y, x);
+}
+
+static inline float64_t ceil_f64(float64_t val)
+{
+	return float64_ceil(val);
+}
+
+static inline float32_t ceil_f32(float32_t val)
+{
+	return float32_ceil(val);
+}
+
+static inline float64_t cos_f64(float64_t val)
+{
+	return float64_cos(val);
+}
+
+static inline float32_t cos_f32(float32_t val)
+{
+	return float32_cos(val);
+}
+
+static inline float64_t cosh_f64(float64_t val)
+{
+	return float64_cosh(val);
+}
+
+static inline float32_t cosh_f32(float32_t val)
+{
+	return float32_cosh(val);
+}
+
+static inline float64_t exp_f64(float64_t val)
+{
+	return float64_exp(val);
+}
+
+static inline float32_t exp_f32(float32_t val)
+{
+	return float32_exp(val);
+}
+
+static inline float64_t fabs_f64(float64_t val)
+{
+	return float64_fabs(val);
+}
+
+static inline float32_t fabs_f32(float32_t val)
+{
+	return float32_fabs(val);
+}
+
+static inline float64_t floor_f64(float64_t val)
+{
+	return float64_floor(val);
+}
+
+static inline float32_t floor_f32(float32_t val)
+{
+	return float32_floor(val);
+}
+static inline float64_t fmod_f64(float64_t dividend, float64_t divisor)
+{
+	return float64_fmod(dividend, divisor);
+}
+
+static inline float64_t fmod_f32(float32_t dividend, float32_t divisor)
+{
+	return float32_fmod(dividend, divisor);
+}
+
+static inline float64_t frexp_f64(float64_t x, int *exp)
+{
+	return float64_frexp(x, exp);
+}
+
+static inline float64_t frexp_f32(float32_t x, int *exp)
+{
+	return float32_frexp(x, exp);
+}
+
+static inline float64_t ldexp_f64(float64_t x, int exp)
+{
+	return float64_ldexp(x, exp);
+}
+
+static inline float64_t ldexp_f32(float32_t x, int exp)
+{
+	return float32_ldexp(x, exp);
+}
+
+static inline float64_t log_f64(float64_t val)
+{
+	return float64_log(val);
+}
+
+static inline float32_t log_f32(float32_t val)
+{
+	return float32_log(val);
+}
+
+static inline float64_t log10_f64(float64_t val)
+{
+	return float64_log10(val);
+}
+
+static inline float32_t log10_f32(float32_t val)
+{
+	return float32_log10(val);
+}
+
+static inline float64_t modf_f64(float64_t value, float64_t *iptr)
+{
+	return float64_modf(value, iptr);
+}
+
+static inline float64_t modf_f32(float32_t value, float32_t *iptr)
+{
+	return float32_modf(value, iptr);
+}
+
+static inline float64_t pow_f64(float64_t x, float64_t y)
+{
+	return float64_pow(x, y);
+}
+
+static inline float32_t pow_f32(float32_t x, float32_t y)
+{
+	return float32_pow(x, y);
+}
+
+static inline float64_t sin_f64(float64_t val)
+{
+	return float64_sin(val);
+}
+
+static inline float32_t sin_f32(float32_t val)
+{
+	return float32_sin(val);
+}
+
+static inline float64_t sinh_f64(float64_t val)
+{
+	return float64_sinh(val);
+}
+
+static inline float32_t sinh_f32(float32_t val)
+{
+	return float32_sinh(val);
+}
+
+static inline float64_t sqrt_f64(float64_t val)
+{
+	return float64_sqrt(val);
+}
+
+static inline float32_t sqrt_f32(float32_t val)
+{
+	return float32_sqrt(val);
+}
+
+static inline float64_t tan_f64(float64_t val)
+{
+	return float64_tan(val);
+}
+
+static inline float32_t tan_f32(float32_t val)
+{
+	return float32_tan(val);
+}
+
+static inline float64_t tanh_f64(float64_t val)
+{
+	return float64_tanh(val);
+}
+
+static inline float32_t tanh_f32(float32_t val)
+{
+	return float32_tanh(val);
+}
+
+static inline float64_t trunc_f64(float64_t val)
+{
+	return float64_trunc(val);
+}
+
+static inline float32_t trunc_f32(float32_t val)
+{
+	return float32_trunc(val);
+}
+
+static inline float64_t acos(float64_t val)
+{
+	return acos_f64(val);
+}
+
+static inline float32_t acosf(float32_t val)
+{
+	return acos_f32(val);
+}
+
+static inline float64_t asin(float64_t val)
+{
+	return asin_f64(val);
+}
+
+static inline float32_t asinf(float32_t val)
+{
+	return asin_f32(val);
+}
+
+static inline float64_t atan(float64_t val)
+{
+	return atan_f64(val);
+}
+
+static inline float32_t atanf(float32_t val)
+{
+	return atan_f32(val);
+}
+
+static inline float64_t atan2(float64_t y, float64_t x)
+{
+	return atan2_f64(y, x);
+}
+
+static inline float32_t atan2f(float32_t y, float32_t x)
+{
+	return atan2_f32(y, x);
+}
+
+static inline float64_t ceil(float64_t val)
+{
+	return ceil_f64(val);
+}
+
+static inline float32_t ceilf(float32_t val)
+{
+	return ceil_f32(val);
+}
+
+static inline float64_t cos(float64_t val)
+{
+	return cos_f64(val);
+}
+
+static inline float32_t cosf(float32_t val)
+{
+	return cos_f32(val);
+}
+
+static inline float64_t cosh(float64_t val)
+{
+	return cosh_f64(val);
+}
+
+static inline float32_t coshf(float32_t val)
+{
+	return cosh_f32(val);
+}
+
+static inline float64_t exp(float64_t val)
+{
+	return exp_f64(val);
+}
+
+static inline float32_t expf(float32_t val)
+{
+	return exp_f32(val);
+}
+
+static inline float64_t fabs(float64_t val)
+{
+	return fabs_f64(val);
+}
+
+static inline float32_t fabsf(float32_t val)
+{
+	return fabs_f32(val);
+}
+
+static inline float64_t floor(float64_t val)
+{
+	return floor_f64(val);
+}
+
+static inline float32_t floorf(float32_t val)
+{
+	return floor_f32(val);
+}
 
 static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return float64_mod(dividend, divisor);
+	return fmod_f64(dividend, divisor);
+}
+
+static inline float32_t fmodf(float32_t dividend, float32_t divisor)
+{
+	return fmod_f32(dividend, divisor);
+}
+
+static inline float64_t frexp(float64_t x, int *exp)
+{
+	return frexp_f64(x, exp);
+}
+
+static inline float32_t frexpf(float32_t x, int *exp)
+{
+	return frexp_f32(x, exp);
+}
+
+static inline float64_t ldexp(float64_t x, int exp)
+{
+	return ldexp_f64(x, exp);
+}
+
+static inline float32_t ldexpf(float32_t x, int exp)
+{
+	return ldexp_f32(x, exp);
+}
+
+static inline float64_t log(float64_t val)
+{
+	return log_f64(val);
+}
+
+static inline float32_t logf(float32_t val)
+{
+	return log_f32(val);
+}
+
+static inline float64_t log10(float64_t val)
+{
+	return log10_f64(val);
+}
+
+static inline float32_t log10f(float32_t val)
+{
+	return log10_f32(val);
+}
+
+static inline float64_t modf(float64_t value, float64_t *iptr)
+{
+	return modf_f64(value, iptr);
+}
+
+static inline float32_t modff(float32_t value, float32_t *iptr)
+{
+	return modf_f32(value, iptr);
+}
+
+static inline float64_t pow(float64_t x, float64_t y)
+{
+	return pow_f64(x, y);
+}
+
+static inline float32_t powf(float32_t x, float32_t y)
+{
+	return pow_f32(x, y);
+}
+
+static inline float64_t sin(float64_t val)
+{
+	return sin_f64(val);
+}
+
+static inline float32_t sinf(float32_t val)
+{
+	return sin_f32(val);
+}
+
+static inline float64_t sinh(float64_t val)
+{
+	return sinh_f64(val);
+}
+
+static inline float32_t sinhf(float32_t val)
+{
+	return sinh_f32(val);
+}
+
+static inline float64_t sqrt(float64_t val)
+{
+	return sqrt_f64(val);
+}
+
+static inline float32_t sqrtf(float32_t val)
+{
+	return sqrt_f32(val);
+}
+
+static inline float64_t tan(float64_t val)
+{
+	return tan_f64(val);
+}
+
+static inline float32_t tanf(float32_t val)
+{
+	return tan_f32(val);
+}
+
+static inline float64_t tanh(float64_t val)
+{
+	return tanh_f64(val);
+}
+
+static inline float32_t tanhf(float32_t val)
+{
+	return tanh_f32(val);
 }
 
 static inline float64_t trunc(float64_t val)
 {
-	float64_u arg;
-	arg.val = val;
-	
-	float64_u ret;
-	ret.data = trunc_float64(arg.data);
-	
-	return ret.val;
-}
-
-static inline float64_t sin(float64_t val)
-{
-	return float64_sin(val);
-}
-
-static inline float64_t cos(float64_t val)
-{
-	return float64_cos(val);
+	return trunc_f64(val);
+}
+
+static inline float32_t truncf(float32_t val)
+{
+	return trunc_f32(val);
 }
 
Index: uspace/lib/math/arch/ia32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/ia32/include/libarch/math.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/ia32/include/libarch/math.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2014 Martin Decky
+ * Copyright (c) 2015 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,15 +37,479 @@
 #define LIBMATH_ia32_MATH_H_
 
+#include <acos.h>
+#include <asin.h>
+#include <atan.h>
+#include <atan2.h>
+#include <ceil.h>
+#include <cosh.h>
+#include <exp.h>
+#include <fabs.h>
+#include <floor.h>
+#include <fmod.h>
+#include <frexp.h>
+#include <ldexp.h>
+#include <log.h>
+#include <log10.h>
 #include <mathtypes.h>
-#include <mod.h>
+#include <modf.h>
+#include <pow.h>
+#include <sinh.h>
+#include <sqrt.h>
+#include <tan.h>
+#include <tanh.h>
+#include <trig.h>
+#include <trunc.h>
+
+#define HUGE_VAL FLOAT64_INF
+
+static inline float64_t acos_f64(float64_t val)
+{
+	return float64_acos(val);
+}
+
+static inline float32_t acos_f32(float32_t val)
+{
+	return float32_acos(val);
+}
+
+static inline float64_t asin_f64(float64_t val)
+{
+	return float64_asin(val);
+}
+
+static inline float32_t asin_f32(float32_t val)
+{
+	return float32_asin(val);
+}
+
+static inline float64_t atan_f64(float64_t val)
+{
+	return float64_atan(val);
+}
+
+static inline float32_t atan_f32(float32_t val)
+{
+	return float32_atan(val);
+}
+
+static inline float64_t atan2_f64(float64_t y, float64_t x)
+{
+	return float64_atan2(y, x);
+}
+
+static inline float32_t atan2_f32(float32_t y, float32_t x)
+{
+	return float32_atan2(y, x);
+}
+
+static inline float64_t ceil_f64(float64_t val)
+{
+	return float64_ceil(val);
+}
+
+static inline float32_t ceil_f32(float32_t val)
+{
+	return float32_ceil(val);
+}
+
+extern float64_t cos_f64(float64_t);
+
+static inline float32_t cos_f32(float32_t val)
+{
+	return (float32_t)cos_f64((float64_t)val);
+}
+
+static inline float64_t cosh_f64(float64_t val)
+{
+	return float64_cosh(val);
+}
+
+static inline float32_t cosh_f32(float32_t val)
+{
+	return float32_cosh(val);
+}
+
+static inline float64_t exp_f64(float64_t val)
+{
+	return float64_exp(val);
+}
+
+static inline float32_t exp_f32(float32_t val)
+{
+	return float32_exp(val);
+}
+
+static inline float64_t fabs_f64(float64_t val)
+{
+	return float64_fabs(val);
+}
+
+static inline float32_t fabs_f32(float32_t val)
+{
+	return float32_fabs(val);
+}
+
+static inline float64_t floor_f64(float64_t val)
+{
+	return float64_floor(val);
+}
+
+static inline float32_t floor_f32(float32_t val)
+{
+	return float32_floor(val);
+}
+static inline float64_t fmod_f64(float64_t dividend, float64_t divisor)
+{
+	return float64_fmod(dividend, divisor);
+}
+
+static inline float64_t fmod_f32(float32_t dividend, float32_t divisor)
+{
+	return float32_fmod(dividend, divisor);
+}
+
+static inline float64_t frexp_f64(float64_t x, int *exp)
+{
+	return float64_frexp(x, exp);
+}
+
+static inline float64_t frexp_f32(float32_t x, int *exp)
+{
+	return float32_frexp(x, exp);
+}
+
+static inline float64_t ldexp_f64(float64_t x, int exp)
+{
+	return float64_ldexp(x, exp);
+}
+
+static inline float64_t ldexp_f32(float32_t x, int exp)
+{
+	return float32_ldexp(x, exp);
+}
+
+static inline float64_t log_f64(float64_t val)
+{
+	return float64_log(val);
+}
+
+static inline float32_t log_f32(float32_t val)
+{
+	return float32_log(val);
+}
+
+static inline float64_t log10_f64(float64_t val)
+{
+	return float64_log10(val);
+}
+
+static inline float32_t log10_f32(float32_t val)
+{
+	return float32_log10(val);
+}
+
+static inline float64_t modf_f64(float64_t value, float64_t *iptr)
+{
+	return float64_modf(value, iptr);
+}
+
+static inline float64_t modf_f32(float32_t value, float32_t *iptr)
+{
+	return float32_modf(value, iptr);
+}
+
+static inline float64_t pow_f64(float64_t x, float64_t y)
+{
+	return float64_pow(x, y);
+}
+
+static inline float32_t pow_f32(float32_t x, float32_t y)
+{
+	return float32_pow(x, y);
+}
+
+extern float64_t sin_f64(float64_t);
+
+static inline float32_t sin_f32(float32_t val)
+{
+	return (float32_t)sin_f64((float64_t)val);
+}
+
+static inline float64_t sinh_f64(float64_t val)
+{
+	return float64_sinh(val);
+}
+
+static inline float32_t sinh_f32(float32_t val)
+{
+	return float32_sinh(val);
+}
+
+static inline float64_t sqrt_f64(float64_t val)
+{
+	return float64_sqrt(val);
+}
+
+static inline float32_t sqrt_f32(float32_t val)
+{
+	return float32_sqrt(val);
+}
+
+static inline float64_t tan_f64(float64_t val)
+{
+	return float64_tan(val);
+}
+
+static inline float32_t tan_f32(float32_t val)
+{
+	return float32_tan(val);
+}
+
+static inline float64_t tanh_f64(float64_t val)
+{
+	return float64_tanh(val);
+}
+
+static inline float32_t tanh_f32(float32_t val)
+{
+	return float32_tanh(val);
+}
+
+extern float64_t trunc_f64(float64_t);
+
+static inline float32_t trunc_f32(float32_t val)
+{
+	return (float32_t)trunc_f64((float64_t)val);
+}
+
+static inline float64_t acos(float64_t val)
+{
+	return acos_f64(val);
+}
+
+static inline float32_t acosf(float32_t val)
+{
+	return acos_f32(val);
+}
+
+static inline float64_t asin(float64_t val)
+{
+	return asin_f64(val);
+}
+
+static inline float32_t asinf(float32_t val)
+{
+	return asin_f32(val);
+}
+
+static inline float64_t atan(float64_t val)
+{
+	return atan_f64(val);
+}
+
+static inline float32_t atanf(float32_t val)
+{
+	return atan_f32(val);
+}
+
+static inline float64_t atan2(float64_t y, float64_t x)
+{
+	return atan2_f64(y, x);
+}
+
+static inline float32_t atan2f(float32_t y, float32_t x)
+{
+	return atan2_f32(y, x);
+}
+
+static inline float64_t ceil(float64_t val)
+{
+	return ceil_f64(val);
+}
+
+static inline float32_t ceilf(float32_t val)
+{
+	return ceil_f32(val);
+}
+
+static inline float64_t cos(float64_t val)
+{
+	return cos_f64(val);
+}
+
+static inline float32_t cosf(float32_t val)
+{
+	return cos_f32(val);
+}
+
+static inline float64_t cosh(float64_t val)
+{
+	return cosh_f64(val);
+}
+
+static inline float32_t coshf(float32_t val)
+{
+	return cosh_f32(val);
+}
+
+static inline float64_t exp(float64_t val)
+{
+	return exp_f64(val);
+}
+
+static inline float32_t expf(float32_t val)
+{
+	return exp_f32(val);
+}
+
+static inline float64_t fabs(float64_t val)
+{
+	return fabs_f64(val);
+}
+
+static inline float32_t fabsf(float32_t val)
+{
+	return fabs_f32(val);
+}
+
+static inline float64_t floor(float64_t val)
+{
+	return floor_f64(val);
+}
+
+static inline float32_t floorf(float32_t val)
+{
+	return floor_f32(val);
+}
 
 static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return float64_mod(dividend, divisor);
-}
-
-extern float64_t sin(float64_t);
-extern float64_t cos(float64_t);
-extern float64_t trunc(float64_t);
+	return fmod_f64(dividend, divisor);
+}
+
+static inline float32_t fmodf(float32_t dividend, float32_t divisor)
+{
+	return fmod_f32(dividend, divisor);
+}
+
+static inline float64_t frexp(float64_t x, int *exp)
+{
+	return frexp_f64(x, exp);
+}
+
+static inline float32_t frexpf(float32_t x, int *exp)
+{
+	return frexp_f32(x, exp);
+}
+
+static inline float64_t ldexp(float64_t x, int exp)
+{
+	return ldexp_f64(x, exp);
+}
+
+static inline float32_t ldexpf(float32_t x, int exp)
+{
+	return ldexp_f32(x, exp);
+}
+
+static inline float64_t log(float64_t val)
+{
+	return log_f64(val);
+}
+
+static inline float32_t logf(float32_t val)
+{
+	return log_f32(val);
+}
+
+static inline float64_t log10(float64_t val)
+{
+	return log10_f64(val);
+}
+
+static inline float32_t log10f(float32_t val)
+{
+	return log10_f32(val);
+}
+
+static inline float64_t modf(float64_t value, float64_t *iptr)
+{
+	return modf_f64(value, iptr);
+}
+
+static inline float32_t modff(float32_t value, float32_t *iptr)
+{
+	return modf_f32(value, iptr);
+}
+
+static inline float64_t pow(float64_t x, float64_t y)
+{
+	return pow_f64(x, y);
+}
+
+static inline float32_t powf(float32_t x, float32_t y)
+{
+	return pow_f32(x, y);
+}
+
+static inline float64_t sin(float64_t val)
+{
+	return sin_f64(val);
+}
+
+static inline float32_t sinf(float32_t val)
+{
+	return sin_f32(val);
+}
+
+static inline float64_t sinh(float64_t val)
+{
+	return sinh_f64(val);
+}
+
+static inline float32_t sinhf(float32_t val)
+{
+	return sinh_f32(val);
+}
+
+static inline float64_t sqrt(float64_t val)
+{
+	return sqrt_f64(val);
+}
+
+static inline float32_t sqrtf(float32_t val)
+{
+	return sqrt_f32(val);
+}
+
+static inline float64_t tan(float64_t val)
+{
+	return tan_f64(val);
+}
+
+static inline float32_t tanf(float32_t val)
+{
+	return tan_f32(val);
+}
+
+static inline float64_t tanh(float64_t val)
+{
+	return tanh_f64(val);
+}
+
+static inline float32_t tanhf(float32_t val)
+{
+	return tanh_f32(val);
+}
+
+static inline float64_t trunc(float64_t val)
+{
+	return trunc_f64(val);
+}
+
+static inline float32_t truncf(float32_t val)
+{
+	return trunc_f32(val);
+}
 
 #endif
Index: uspace/lib/math/arch/ia32/src/cos.S
===================================================================
--- uspace/lib/math/arch/ia32/src/cos.S	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/ia32/src/cos.S	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -31,7 +31,7 @@
 .text
 
-.global cos
+.global cos_f64
 
-cos:
+cos_f64:
 	# compute cosine (no stack frame)
 	
Index: uspace/lib/math/arch/ia32/src/sin.S
===================================================================
--- uspace/lib/math/arch/ia32/src/sin.S	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/ia32/src/sin.S	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -31,7 +31,7 @@
 .text
 
-.global sin
+.global sin_f64
 
-sin:
+sin_f64:
 	# compute sine (no stack frame)
 	
Index: uspace/lib/math/arch/ia32/src/trunc.S
===================================================================
--- uspace/lib/math/arch/ia32/src/trunc.S	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/ia32/src/trunc.S	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -31,7 +31,7 @@
 .text
 
-.global trunc
+.global trunc_f64
 
-trunc:
+trunc_f64:
 	pushl %ebp
 	movl %esp, %ebp
Index: uspace/lib/math/arch/ia64/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/ia64/include/libarch/math.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/ia64/include/libarch/math.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2014 Martin Decky
+ * Copyright (c) 2015 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,33 +37,487 @@
 #define LIBMATH_ia64_MATH_H_
 
+#include <acos.h>
+#include <asin.h>
+#include <atan.h>
+#include <atan2.h>
+#include <ceil.h>
+#include <cosh.h>
+#include <exp.h>
+#include <fabs.h>
+#include <floor.h>
+#include <fmod.h>
+#include <frexp.h>
+#include <ldexp.h>
+#include <log.h>
+#include <log10.h>
 #include <mathtypes.h>
-#include <mod.h>
+#include <modf.h>
+#include <pow.h>
+#include <sinh.h>
+#include <sqrt.h>
+#include <tan.h>
+#include <tanh.h>
+#include <trig.h>
 #include <trunc.h>
-#include <trig.h>
+
+#define HUGE_VAL FLOAT64_INF
+
+static inline float64_t acos_f64(float64_t val)
+{
+	return float64_acos(val);
+}
+
+static inline float32_t acos_f32(float32_t val)
+{
+	return float32_acos(val);
+}
+
+static inline float64_t asin_f64(float64_t val)
+{
+	return float64_asin(val);
+}
+
+static inline float32_t asin_f32(float32_t val)
+{
+	return float32_asin(val);
+}
+
+static inline float64_t atan_f64(float64_t val)
+{
+	return float64_atan(val);
+}
+
+static inline float32_t atan_f32(float32_t val)
+{
+	return float32_atan(val);
+}
+
+static inline float64_t atan2_f64(float64_t y, float64_t x)
+{
+	return float64_atan2(y, x);
+}
+
+static inline float32_t atan2_f32(float32_t y, float32_t x)
+{
+	return float32_atan2(y, x);
+}
+
+static inline float64_t ceil_f64(float64_t val)
+{
+	return float64_ceil(val);
+}
+
+static inline float32_t ceil_f32(float32_t val)
+{
+	return float32_ceil(val);
+}
+
+static inline float64_t cos_f64(float64_t val)
+{
+	return float64_cos(val);
+}
+
+static inline float32_t cos_f32(float32_t val)
+{
+	return float32_cos(val);
+}
+
+static inline float64_t cosh_f64(float64_t val)
+{
+	return float64_cosh(val);
+}
+
+static inline float32_t cosh_f32(float32_t val)
+{
+	return float32_cosh(val);
+}
+
+static inline float64_t exp_f64(float64_t val)
+{
+	return float64_exp(val);
+}
+
+static inline float32_t exp_f32(float32_t val)
+{
+	return float32_exp(val);
+}
+
+static inline float64_t fabs_f64(float64_t val)
+{
+	return float64_fabs(val);
+}
+
+static inline float32_t fabs_f32(float32_t val)
+{
+	return float32_fabs(val);
+}
+
+static inline float64_t floor_f64(float64_t val)
+{
+	return float64_floor(val);
+}
+
+static inline float32_t floor_f32(float32_t val)
+{
+	return float32_floor(val);
+}
+static inline float64_t fmod_f64(float64_t dividend, float64_t divisor)
+{
+	return float64_fmod(dividend, divisor);
+}
+
+static inline float64_t fmod_f32(float32_t dividend, float32_t divisor)
+{
+	return float32_fmod(dividend, divisor);
+}
+
+static inline float64_t frexp_f64(float64_t x, int *exp)
+{
+	return float64_frexp(x, exp);
+}
+
+static inline float64_t frexp_f32(float32_t x, int *exp)
+{
+	return float32_frexp(x, exp);
+}
+
+static inline float64_t ldexp_f64(float64_t x, int exp)
+{
+	return float64_ldexp(x, exp);
+}
+
+static inline float64_t ldexp_f32(float32_t x, int exp)
+{
+	return float32_ldexp(x, exp);
+}
+
+static inline float64_t log_f64(float64_t val)
+{
+	return float64_log(val);
+}
+
+static inline float32_t log_f32(float32_t val)
+{
+	return float32_log(val);
+}
+
+static inline float64_t log10_f64(float64_t val)
+{
+	return float64_log10(val);
+}
+
+static inline float32_t log10_f32(float32_t val)
+{
+	return float32_log10(val);
+}
+
+static inline float64_t modf_f64(float64_t value, float64_t *iptr)
+{
+	return float64_modf(value, iptr);
+}
+
+static inline float64_t modf_f32(float32_t value, float32_t *iptr)
+{
+	return float32_modf(value, iptr);
+}
+
+static inline float64_t pow_f64(float64_t x, float64_t y)
+{
+	return float64_pow(x, y);
+}
+
+static inline float32_t pow_f32(float32_t x, float32_t y)
+{
+	return float32_pow(x, y);
+}
+
+static inline float64_t sin_f64(float64_t val)
+{
+	return float64_sin(val);
+}
+
+static inline float32_t sin_f32(float32_t val)
+{
+	return float32_sin(val);
+}
+
+static inline float64_t sinh_f64(float64_t val)
+{
+	return float64_sinh(val);
+}
+
+static inline float32_t sinh_f32(float32_t val)
+{
+	return float32_sinh(val);
+}
+
+static inline float64_t sqrt_f64(float64_t val)
+{
+	return float64_sqrt(val);
+}
+
+static inline float32_t sqrt_f32(float32_t val)
+{
+	return float32_sqrt(val);
+}
+
+static inline float64_t tan_f64(float64_t val)
+{
+	return float64_tan(val);
+}
+
+static inline float32_t tan_f32(float32_t val)
+{
+	return float32_tan(val);
+}
+
+static inline float64_t tanh_f64(float64_t val)
+{
+	return float64_tanh(val);
+}
+
+static inline float32_t tanh_f32(float32_t val)
+{
+	return float32_tanh(val);
+}
+
+static inline float64_t trunc_f64(float64_t val)
+{
+	return float64_trunc(val);
+}
+
+static inline float32_t trunc_f32(float32_t val)
+{
+	return float32_trunc(val);
+}
+
+static inline float64_t acos(float64_t val)
+{
+	return acos_f64(val);
+}
+
+static inline float32_t acosf(float32_t val)
+{
+	return acos_f32(val);
+}
+
+static inline float64_t asin(float64_t val)
+{
+	return asin_f64(val);
+}
+
+static inline float32_t asinf(float32_t val)
+{
+	return asin_f32(val);
+}
+
+static inline float64_t atan(float64_t val)
+{
+	return atan_f64(val);
+}
+
+static inline float32_t atanf(float32_t val)
+{
+	return atan_f32(val);
+}
+
+static inline float64_t atan2(float64_t y, float64_t x)
+{
+	return atan2_f64(y, x);
+}
+
+static inline float32_t atan2f(float32_t y, float32_t x)
+{
+	return atan2_f32(y, x);
+}
+
+static inline float64_t ceil(float64_t val)
+{
+	return ceil_f64(val);
+}
+
+static inline float32_t ceilf(float32_t val)
+{
+	return ceil_f32(val);
+}
+
+static inline float64_t cos(float64_t val)
+{
+	return cos_f64(val);
+}
+
+static inline float32_t cosf(float32_t val)
+{
+	return cos_f32(val);
+}
+
+static inline float64_t cosh(float64_t val)
+{
+	return cosh_f64(val);
+}
+
+static inline float32_t coshf(float32_t val)
+{
+	return cosh_f32(val);
+}
+
+static inline float64_t exp(float64_t val)
+{
+	return exp_f64(val);
+}
+
+static inline float32_t expf(float32_t val)
+{
+	return exp_f32(val);
+}
+
+static inline float64_t fabs(float64_t val)
+{
+	return fabs_f64(val);
+}
+
+static inline float32_t fabsf(float32_t val)
+{
+	return fabs_f32(val);
+}
+
+static inline float64_t floor(float64_t val)
+{
+	return floor_f64(val);
+}
+
+static inline float32_t floorf(float32_t val)
+{
+	return floor_f32(val);
+}
 
 static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return float64_mod(dividend, divisor);
+	return fmod_f64(dividend, divisor);
+}
+
+static inline float32_t fmodf(float32_t dividend, float32_t divisor)
+{
+	return fmod_f32(dividend, divisor);
+}
+
+static inline float64_t frexp(float64_t x, int *exp)
+{
+	return frexp_f64(x, exp);
+}
+
+static inline float32_t frexpf(float32_t x, int *exp)
+{
+	return frexp_f32(x, exp);
+}
+
+static inline float64_t ldexp(float64_t x, int exp)
+{
+	return ldexp_f64(x, exp);
+}
+
+static inline float32_t ldexpf(float32_t x, int exp)
+{
+	return ldexp_f32(x, exp);
+}
+
+static inline float64_t log(float64_t val)
+{
+	return log_f64(val);
+}
+
+static inline float32_t logf(float32_t val)
+{
+	return log_f32(val);
+}
+
+static inline float64_t log10(float64_t val)
+{
+	return log10_f64(val);
+}
+
+static inline float32_t log10f(float32_t val)
+{
+	return log10_f32(val);
+}
+
+static inline float64_t modf(float64_t value, float64_t *iptr)
+{
+	return modf_f64(value, iptr);
+}
+
+static inline float32_t modff(float32_t value, float32_t *iptr)
+{
+	return modf_f32(value, iptr);
+}
+
+static inline float64_t pow(float64_t x, float64_t y)
+{
+	return pow_f64(x, y);
+}
+
+static inline float32_t powf(float32_t x, float32_t y)
+{
+	return pow_f32(x, y);
+}
+
+static inline float64_t sin(float64_t val)
+{
+	return sin_f64(val);
+}
+
+static inline float32_t sinf(float32_t val)
+{
+	return sin_f32(val);
+}
+
+static inline float64_t sinh(float64_t val)
+{
+	return sinh_f64(val);
+}
+
+static inline float32_t sinhf(float32_t val)
+{
+	return sinh_f32(val);
+}
+
+static inline float64_t sqrt(float64_t val)
+{
+	return sqrt_f64(val);
+}
+
+static inline float32_t sqrtf(float32_t val)
+{
+	return sqrt_f32(val);
+}
+
+static inline float64_t tan(float64_t val)
+{
+	return tan_f64(val);
+}
+
+static inline float32_t tanf(float32_t val)
+{
+	return tan_f32(val);
+}
+
+static inline float64_t tanh(float64_t val)
+{
+	return tanh_f64(val);
+}
+
+static inline float32_t tanhf(float32_t val)
+{
+	return tanh_f32(val);
 }
 
 static inline float64_t trunc(float64_t val)
 {
-	float64_u arg;
-	arg.val = val;
-	
-	float64_u ret;
-	ret.data = trunc_float64(arg.data);
-	
-	return ret.val;
-}
-
-static inline float64_t sin(float64_t val)
-{
-	return float64_sin(val);
-}
-
-static inline float64_t cos(float64_t val)
-{
-	return float64_cos(val);
+	return trunc_f64(val);
+}
+
+static inline float32_t truncf(float32_t val)
+{
+	return trunc_f32(val);
 }
 
Index: uspace/lib/math/arch/mips32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/mips32/include/libarch/math.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/mips32/include/libarch/math.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2014 Martin Decky
+ * Copyright (c) 2015 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,33 +37,487 @@
 #define LIBMATH_mips32_MATH_H_
 
+#include <acos.h>
+#include <asin.h>
+#include <atan.h>
+#include <atan2.h>
+#include <ceil.h>
+#include <cosh.h>
+#include <exp.h>
+#include <fabs.h>
+#include <floor.h>
+#include <fmod.h>
+#include <frexp.h>
+#include <ldexp.h>
+#include <log.h>
+#include <log10.h>
 #include <mathtypes.h>
-#include <mod.h>
+#include <modf.h>
+#include <pow.h>
+#include <sinh.h>
+#include <sqrt.h>
+#include <tan.h>
+#include <tanh.h>
+#include <trig.h>
 #include <trunc.h>
-#include <trig.h>
+
+#define HUGE_VAL FLOAT64_INF
+
+static inline float64_t acos_f64(float64_t val)
+{
+	return float64_acos(val);
+}
+
+static inline float32_t acos_f32(float32_t val)
+{
+	return float32_acos(val);
+}
+
+static inline float64_t asin_f64(float64_t val)
+{
+	return float64_asin(val);
+}
+
+static inline float32_t asin_f32(float32_t val)
+{
+	return float32_asin(val);
+}
+
+static inline float64_t atan_f64(float64_t val)
+{
+	return float64_atan(val);
+}
+
+static inline float32_t atan_f32(float32_t val)
+{
+	return float32_atan(val);
+}
+
+static inline float64_t atan2_f64(float64_t y, float64_t x)
+{
+	return float64_atan2(y, x);
+}
+
+static inline float32_t atan2_f32(float32_t y, float32_t x)
+{
+	return float32_atan2(y, x);
+}
+
+static inline float64_t ceil_f64(float64_t val)
+{
+	return float64_ceil(val);
+}
+
+static inline float32_t ceil_f32(float32_t val)
+{
+	return float32_ceil(val);
+}
+
+static inline float64_t cos_f64(float64_t val)
+{
+	return float64_cos(val);
+}
+
+static inline float32_t cos_f32(float32_t val)
+{
+	return float32_cos(val);
+}
+
+static inline float64_t cosh_f64(float64_t val)
+{
+	return float64_cosh(val);
+}
+
+static inline float32_t cosh_f32(float32_t val)
+{
+	return float32_cosh(val);
+}
+
+static inline float64_t exp_f64(float64_t val)
+{
+	return float64_exp(val);
+}
+
+static inline float32_t exp_f32(float32_t val)
+{
+	return float32_exp(val);
+}
+
+static inline float64_t fabs_f64(float64_t val)
+{
+	return float64_fabs(val);
+}
+
+static inline float32_t fabs_f32(float32_t val)
+{
+	return float32_fabs(val);
+}
+
+static inline float64_t floor_f64(float64_t val)
+{
+	return float64_floor(val);
+}
+
+static inline float32_t floor_f32(float32_t val)
+{
+	return float32_floor(val);
+}
+static inline float64_t fmod_f64(float64_t dividend, float64_t divisor)
+{
+	return float64_fmod(dividend, divisor);
+}
+
+static inline float64_t fmod_f32(float32_t dividend, float32_t divisor)
+{
+	return float32_fmod(dividend, divisor);
+}
+
+static inline float64_t frexp_f64(float64_t x, int *exp)
+{
+	return float64_frexp(x, exp);
+}
+
+static inline float64_t frexp_f32(float32_t x, int *exp)
+{
+	return float32_frexp(x, exp);
+}
+
+static inline float64_t ldexp_f64(float64_t x, int exp)
+{
+	return float64_ldexp(x, exp);
+}
+
+static inline float64_t ldexp_f32(float32_t x, int exp)
+{
+	return float32_ldexp(x, exp);
+}
+
+static inline float64_t log_f64(float64_t val)
+{
+	return float64_log(val);
+}
+
+static inline float32_t log_f32(float32_t val)
+{
+	return float32_log(val);
+}
+
+static inline float64_t log10_f64(float64_t val)
+{
+	return float64_log10(val);
+}
+
+static inline float32_t log10_f32(float32_t val)
+{
+	return float32_log10(val);
+}
+
+static inline float64_t modf_f64(float64_t value, float64_t *iptr)
+{
+	return float64_modf(value, iptr);
+}
+
+static inline float64_t modf_f32(float32_t value, float32_t *iptr)
+{
+	return float32_modf(value, iptr);
+}
+
+static inline float64_t pow_f64(float64_t x, float64_t y)
+{
+	return float64_pow(x, y);
+}
+
+static inline float32_t pow_f32(float32_t x, float32_t y)
+{
+	return float32_pow(x, y);
+}
+
+static inline float64_t sin_f64(float64_t val)
+{
+	return float64_sin(val);
+}
+
+static inline float32_t sin_f32(float32_t val)
+{
+	return float32_sin(val);
+}
+
+static inline float64_t sinh_f64(float64_t val)
+{
+	return float64_sinh(val);
+}
+
+static inline float32_t sinh_f32(float32_t val)
+{
+	return float32_sinh(val);
+}
+
+static inline float64_t sqrt_f64(float64_t val)
+{
+	return float64_sqrt(val);
+}
+
+static inline float32_t sqrt_f32(float32_t val)
+{
+	return float32_sqrt(val);
+}
+
+static inline float64_t tan_f64(float64_t val)
+{
+	return float64_tan(val);
+}
+
+static inline float32_t tan_f32(float32_t val)
+{
+	return float32_tan(val);
+}
+
+static inline float64_t tanh_f64(float64_t val)
+{
+	return float64_tanh(val);
+}
+
+static inline float32_t tanh_f32(float32_t val)
+{
+	return float32_tanh(val);
+}
+
+static inline float64_t trunc_f64(float64_t val)
+{
+	return float64_trunc(val);
+}
+
+static inline float32_t trunc_f32(float32_t val)
+{
+	return float32_trunc(val);
+}
+
+static inline float64_t acos(float64_t val)
+{
+	return acos_f64(val);
+}
+
+static inline float32_t acosf(float32_t val)
+{
+	return acos_f32(val);
+}
+
+static inline float64_t asin(float64_t val)
+{
+	return asin_f64(val);
+}
+
+static inline float32_t asinf(float32_t val)
+{
+	return asin_f32(val);
+}
+
+static inline float64_t atan(float64_t val)
+{
+	return atan_f64(val);
+}
+
+static inline float32_t atanf(float32_t val)
+{
+	return atan_f32(val);
+}
+
+static inline float64_t atan2(float64_t y, float64_t x)
+{
+	return atan2_f64(y, x);
+}
+
+static inline float32_t atan2f(float32_t y, float32_t x)
+{
+	return atan2_f32(y, x);
+}
+
+static inline float64_t ceil(float64_t val)
+{
+	return ceil_f64(val);
+}
+
+static inline float32_t ceilf(float32_t val)
+{
+	return ceil_f32(val);
+}
+
+static inline float64_t cos(float64_t val)
+{
+	return cos_f64(val);
+}
+
+static inline float32_t cosf(float32_t val)
+{
+	return cos_f32(val);
+}
+
+static inline float64_t cosh(float64_t val)
+{
+	return cosh_f64(val);
+}
+
+static inline float32_t coshf(float32_t val)
+{
+	return cosh_f32(val);
+}
+
+static inline float64_t exp(float64_t val)
+{
+	return exp_f64(val);
+}
+
+static inline float32_t expf(float32_t val)
+{
+	return exp_f32(val);
+}
+
+static inline float64_t fabs(float64_t val)
+{
+	return fabs_f64(val);
+}
+
+static inline float32_t fabsf(float32_t val)
+{
+	return fabs_f32(val);
+}
+
+static inline float64_t floor(float64_t val)
+{
+	return floor_f64(val);
+}
+
+static inline float32_t floorf(float32_t val)
+{
+	return floor_f32(val);
+}
 
 static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return float64_mod(dividend, divisor);
+	return fmod_f64(dividend, divisor);
+}
+
+static inline float32_t fmodf(float32_t dividend, float32_t divisor)
+{
+	return fmod_f32(dividend, divisor);
+}
+
+static inline float64_t frexp(float64_t x, int *exp)
+{
+	return frexp_f64(x, exp);
+}
+
+static inline float32_t frexpf(float32_t x, int *exp)
+{
+	return frexp_f32(x, exp);
+}
+
+static inline float64_t ldexp(float64_t x, int exp)
+{
+	return ldexp_f64(x, exp);
+}
+
+static inline float32_t ldexpf(float32_t x, int exp)
+{
+	return ldexp_f32(x, exp);
+}
+
+static inline float64_t log(float64_t val)
+{
+	return log_f64(val);
+}
+
+static inline float32_t logf(float32_t val)
+{
+	return log_f32(val);
+}
+
+static inline float64_t log10(float64_t val)
+{
+	return log10_f64(val);
+}
+
+static inline float32_t log10f(float32_t val)
+{
+	return log10_f32(val);
+}
+
+static inline float64_t modf(float64_t value, float64_t *iptr)
+{
+	return modf_f64(value, iptr);
+}
+
+static inline float32_t modff(float32_t value, float32_t *iptr)
+{
+	return modf_f32(value, iptr);
+}
+
+static inline float64_t pow(float64_t x, float64_t y)
+{
+	return pow_f64(x, y);
+}
+
+static inline float32_t powf(float32_t x, float32_t y)
+{
+	return pow_f32(x, y);
+}
+
+static inline float64_t sin(float64_t val)
+{
+	return sin_f64(val);
+}
+
+static inline float32_t sinf(float32_t val)
+{
+	return sin_f32(val);
+}
+
+static inline float64_t sinh(float64_t val)
+{
+	return sinh_f64(val);
+}
+
+static inline float32_t sinhf(float32_t val)
+{
+	return sinh_f32(val);
+}
+
+static inline float64_t sqrt(float64_t val)
+{
+	return sqrt_f64(val);
+}
+
+static inline float32_t sqrtf(float32_t val)
+{
+	return sqrt_f32(val);
+}
+
+static inline float64_t tan(float64_t val)
+{
+	return tan_f64(val);
+}
+
+static inline float32_t tanf(float32_t val)
+{
+	return tan_f32(val);
+}
+
+static inline float64_t tanh(float64_t val)
+{
+	return tanh_f64(val);
+}
+
+static inline float32_t tanhf(float32_t val)
+{
+	return tanh_f32(val);
 }
 
 static inline float64_t trunc(float64_t val)
 {
-	float64_u arg;
-	arg.val = val;
-	
-	float64_u ret;
-	ret.data = trunc_float64(arg.data);
-	
-	return ret.val;
-}
-
-static inline float64_t sin(float64_t val)
-{
-	return float64_sin(val);
-}
-
-static inline float64_t cos(float64_t val)
-{
-	return float64_cos(val);
+	return trunc_f64(val);
+}
+
+static inline float32_t truncf(float32_t val)
+{
+	return trunc_f32(val);
 }
 
Index: uspace/lib/math/arch/mips32eb/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/mips32eb/include/libarch/math.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/mips32eb/include/libarch/math.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2014 Martin Decky
+ * Copyright (c) 2015 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,33 +37,487 @@
 #define LIBMATH_mips32eb_MATH_H_
 
+#include <acos.h>
+#include <asin.h>
+#include <atan.h>
+#include <atan2.h>
+#include <ceil.h>
+#include <cosh.h>
+#include <exp.h>
+#include <fabs.h>
+#include <floor.h>
+#include <fmod.h>
+#include <frexp.h>
+#include <ldexp.h>
+#include <log.h>
+#include <log10.h>
 #include <mathtypes.h>
-#include <mod.h>
+#include <modf.h>
+#include <pow.h>
+#include <sinh.h>
+#include <sqrt.h>
+#include <tan.h>
+#include <tanh.h>
+#include <trig.h>
 #include <trunc.h>
-#include <trig.h>
+
+#define HUGE_VAL FLOAT64_INF
+
+static inline float64_t acos_f64(float64_t val)
+{
+	return float64_acos(val);
+}
+
+static inline float32_t acos_f32(float32_t val)
+{
+	return float32_acos(val);
+}
+
+static inline float64_t asin_f64(float64_t val)
+{
+	return float64_asin(val);
+}
+
+static inline float32_t asin_f32(float32_t val)
+{
+	return float32_asin(val);
+}
+
+static inline float64_t atan_f64(float64_t val)
+{
+	return float64_atan(val);
+}
+
+static inline float32_t atan_f32(float32_t val)
+{
+	return float32_atan(val);
+}
+
+static inline float64_t atan2_f64(float64_t y, float64_t x)
+{
+	return float64_atan2(y, x);
+}
+
+static inline float32_t atan2_f32(float32_t y, float32_t x)
+{
+	return float32_atan2(y, x);
+}
+
+static inline float64_t ceil_f64(float64_t val)
+{
+	return float64_ceil(val);
+}
+
+static inline float32_t ceil_f32(float32_t val)
+{
+	return float32_ceil(val);
+}
+
+static inline float64_t cos_f64(float64_t val)
+{
+	return float64_cos(val);
+}
+
+static inline float32_t cos_f32(float32_t val)
+{
+	return float32_cos(val);
+}
+
+static inline float64_t cosh_f64(float64_t val)
+{
+	return float64_cosh(val);
+}
+
+static inline float32_t cosh_f32(float32_t val)
+{
+	return float32_cosh(val);
+}
+
+static inline float64_t exp_f64(float64_t val)
+{
+	return float64_exp(val);
+}
+
+static inline float32_t exp_f32(float32_t val)
+{
+	return float32_exp(val);
+}
+
+static inline float64_t fabs_f64(float64_t val)
+{
+	return float64_fabs(val);
+}
+
+static inline float32_t fabs_f32(float32_t val)
+{
+	return float32_fabs(val);
+}
+
+static inline float64_t floor_f64(float64_t val)
+{
+	return float64_floor(val);
+}
+
+static inline float32_t floor_f32(float32_t val)
+{
+	return float32_floor(val);
+}
+static inline float64_t fmod_f64(float64_t dividend, float64_t divisor)
+{
+	return float64_fmod(dividend, divisor);
+}
+
+static inline float64_t fmod_f32(float32_t dividend, float32_t divisor)
+{
+	return float32_fmod(dividend, divisor);
+}
+
+static inline float64_t frexp_f64(float64_t x, int *exp)
+{
+	return float64_frexp(x, exp);
+}
+
+static inline float64_t frexp_f32(float32_t x, int *exp)
+{
+	return float32_frexp(x, exp);
+}
+
+static inline float64_t ldexp_f64(float64_t x, int exp)
+{
+	return float64_ldexp(x, exp);
+}
+
+static inline float64_t ldexp_f32(float32_t x, int exp)
+{
+	return float32_ldexp(x, exp);
+}
+
+static inline float64_t log_f64(float64_t val)
+{
+	return float64_log(val);
+}
+
+static inline float32_t log_f32(float32_t val)
+{
+	return float32_log(val);
+}
+
+static inline float64_t log10_f64(float64_t val)
+{
+	return float64_log10(val);
+}
+
+static inline float32_t log10_f32(float32_t val)
+{
+	return float32_log10(val);
+}
+
+static inline float64_t modf_f64(float64_t value, float64_t *iptr)
+{
+	return float64_modf(value, iptr);
+}
+
+static inline float64_t modf_f32(float32_t value, float32_t *iptr)
+{
+	return float32_modf(value, iptr);
+}
+
+static inline float64_t pow_f64(float64_t x, float64_t y)
+{
+	return float64_pow(x, y);
+}
+
+static inline float32_t pow_f32(float32_t x, float32_t y)
+{
+	return float32_pow(x, y);
+}
+
+static inline float64_t sin_f64(float64_t val)
+{
+	return float64_sin(val);
+}
+
+static inline float32_t sin_f32(float32_t val)
+{
+	return float32_sin(val);
+}
+
+static inline float64_t sinh_f64(float64_t val)
+{
+	return float64_sinh(val);
+}
+
+static inline float32_t sinh_f32(float32_t val)
+{
+	return float32_sinh(val);
+}
+
+static inline float64_t sqrt_f64(float64_t val)
+{
+	return float64_sqrt(val);
+}
+
+static inline float32_t sqrt_f32(float32_t val)
+{
+	return float32_sqrt(val);
+}
+
+static inline float64_t tan_f64(float64_t val)
+{
+	return float64_tan(val);
+}
+
+static inline float32_t tan_f32(float32_t val)
+{
+	return float32_tan(val);
+}
+
+static inline float64_t tanh_f64(float64_t val)
+{
+	return float64_tanh(val);
+}
+
+static inline float32_t tanh_f32(float32_t val)
+{
+	return float32_tanh(val);
+}
+
+static inline float64_t trunc_f64(float64_t val)
+{
+	return float64_trunc(val);
+}
+
+static inline float32_t trunc_f32(float32_t val)
+{
+	return float32_trunc(val);
+}
+
+static inline float64_t acos(float64_t val)
+{
+	return acos_f64(val);
+}
+
+static inline float32_t acosf(float32_t val)
+{
+	return acos_f32(val);
+}
+
+static inline float64_t asin(float64_t val)
+{
+	return asin_f64(val);
+}
+
+static inline float32_t asinf(float32_t val)
+{
+	return asin_f32(val);
+}
+
+static inline float64_t atan(float64_t val)
+{
+	return atan_f64(val);
+}
+
+static inline float32_t atanf(float32_t val)
+{
+	return atan_f32(val);
+}
+
+static inline float64_t atan2(float64_t y, float64_t x)
+{
+	return atan2_f64(y, x);
+}
+
+static inline float32_t atan2f(float32_t y, float32_t x)
+{
+	return atan2_f32(y, x);
+}
+
+static inline float64_t ceil(float64_t val)
+{
+	return ceil_f64(val);
+}
+
+static inline float32_t ceilf(float32_t val)
+{
+	return ceil_f32(val);
+}
+
+static inline float64_t cos(float64_t val)
+{
+	return cos_f64(val);
+}
+
+static inline float32_t cosf(float32_t val)
+{
+	return cos_f32(val);
+}
+
+static inline float64_t cosh(float64_t val)
+{
+	return cosh_f64(val);
+}
+
+static inline float32_t coshf(float32_t val)
+{
+	return cosh_f32(val);
+}
+
+static inline float64_t exp(float64_t val)
+{
+	return exp_f64(val);
+}
+
+static inline float32_t expf(float32_t val)
+{
+	return exp_f32(val);
+}
+
+static inline float64_t fabs(float64_t val)
+{
+	return fabs_f64(val);
+}
+
+static inline float32_t fabsf(float32_t val)
+{
+	return fabs_f32(val);
+}
+
+static inline float64_t floor(float64_t val)
+{
+	return floor_f64(val);
+}
+
+static inline float32_t floorf(float32_t val)
+{
+	return floor_f32(val);
+}
 
 static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return float64_mod(dividend, divisor);
+	return fmod_f64(dividend, divisor);
+}
+
+static inline float32_t fmodf(float32_t dividend, float32_t divisor)
+{
+	return fmod_f32(dividend, divisor);
+}
+
+static inline float64_t frexp(float64_t x, int *exp)
+{
+	return frexp_f64(x, exp);
+}
+
+static inline float32_t frexpf(float32_t x, int *exp)
+{
+	return frexp_f32(x, exp);
+}
+
+static inline float64_t ldexp(float64_t x, int exp)
+{
+	return ldexp_f64(x, exp);
+}
+
+static inline float32_t ldexpf(float32_t x, int exp)
+{
+	return ldexp_f32(x, exp);
+}
+
+static inline float64_t log(float64_t val)
+{
+	return log_f64(val);
+}
+
+static inline float32_t logf(float32_t val)
+{
+	return log_f32(val);
+}
+
+static inline float64_t log10(float64_t val)
+{
+	return log10_f64(val);
+}
+
+static inline float32_t log10f(float32_t val)
+{
+	return log10_f32(val);
+}
+
+static inline float64_t modf(float64_t value, float64_t *iptr)
+{
+	return modf_f64(value, iptr);
+}
+
+static inline float32_t modff(float32_t value, float32_t *iptr)
+{
+	return modf_f32(value, iptr);
+}
+
+static inline float64_t pow(float64_t x, float64_t y)
+{
+	return pow_f64(x, y);
+}
+
+static inline float32_t powf(float32_t x, float32_t y)
+{
+	return pow_f32(x, y);
+}
+
+static inline float64_t sin(float64_t val)
+{
+	return sin_f64(val);
+}
+
+static inline float32_t sinf(float32_t val)
+{
+	return sin_f32(val);
+}
+
+static inline float64_t sinh(float64_t val)
+{
+	return sinh_f64(val);
+}
+
+static inline float32_t sinhf(float32_t val)
+{
+	return sinh_f32(val);
+}
+
+static inline float64_t sqrt(float64_t val)
+{
+	return sqrt_f64(val);
+}
+
+static inline float32_t sqrtf(float32_t val)
+{
+	return sqrt_f32(val);
+}
+
+static inline float64_t tan(float64_t val)
+{
+	return tan_f64(val);
+}
+
+static inline float32_t tanf(float32_t val)
+{
+	return tan_f32(val);
+}
+
+static inline float64_t tanh(float64_t val)
+{
+	return tanh_f64(val);
+}
+
+static inline float32_t tanhf(float32_t val)
+{
+	return tanh_f32(val);
 }
 
 static inline float64_t trunc(float64_t val)
 {
-	float64_u arg;
-	arg.val = val;
-	
-	float64_u ret;
-	ret.data = trunc_float64(arg.data);
-	
-	return ret.val;
-}
-
-static inline float64_t sin(float64_t val)
-{
-	return float64_sin(val);
-}
-
-static inline float64_t cos(float64_t val)
-{
-	return float64_cos(val);
+	return trunc_f64(val);
+}
+
+static inline float32_t truncf(float32_t val)
+{
+	return trunc_f32(val);
 }
 
Index: uspace/lib/math/arch/ppc32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/ppc32/include/libarch/math.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/ppc32/include/libarch/math.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2014 Martin Decky
+ * Copyright (c) 2015 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,33 +37,487 @@
 #define LIBMATH_ppc32_MATH_H_
 
+#include <acos.h>
+#include <asin.h>
+#include <atan.h>
+#include <atan2.h>
+#include <ceil.h>
+#include <cosh.h>
+#include <exp.h>
+#include <fabs.h>
+#include <floor.h>
+#include <fmod.h>
+#include <frexp.h>
+#include <ldexp.h>
+#include <log.h>
+#include <log10.h>
 #include <mathtypes.h>
-#include <mod.h>
+#include <modf.h>
+#include <pow.h>
+#include <sinh.h>
+#include <sqrt.h>
+#include <tan.h>
+#include <tanh.h>
+#include <trig.h>
 #include <trunc.h>
-#include <trig.h>
+
+#define HUGE_VAL FLOAT64_INF
+
+static inline float64_t acos_f64(float64_t val)
+{
+	return float64_acos(val);
+}
+
+static inline float32_t acos_f32(float32_t val)
+{
+	return float32_acos(val);
+}
+
+static inline float64_t asin_f64(float64_t val)
+{
+	return float64_asin(val);
+}
+
+static inline float32_t asin_f32(float32_t val)
+{
+	return float32_asin(val);
+}
+
+static inline float64_t atan_f64(float64_t val)
+{
+	return float64_atan(val);
+}
+
+static inline float32_t atan_f32(float32_t val)
+{
+	return float32_atan(val);
+}
+
+static inline float64_t atan2_f64(float64_t y, float64_t x)
+{
+	return float64_atan2(y, x);
+}
+
+static inline float32_t atan2_f32(float32_t y, float32_t x)
+{
+	return float32_atan2(y, x);
+}
+
+static inline float64_t ceil_f64(float64_t val)
+{
+	return float64_ceil(val);
+}
+
+static inline float32_t ceil_f32(float32_t val)
+{
+	return float32_ceil(val);
+}
+
+static inline float64_t cos_f64(float64_t val)
+{
+	return float64_cos(val);
+}
+
+static inline float32_t cos_f32(float32_t val)
+{
+	return float32_cos(val);
+}
+
+static inline float64_t cosh_f64(float64_t val)
+{
+	return float64_cosh(val);
+}
+
+static inline float32_t cosh_f32(float32_t val)
+{
+	return float32_cosh(val);
+}
+
+static inline float64_t exp_f64(float64_t val)
+{
+	return float64_exp(val);
+}
+
+static inline float32_t exp_f32(float32_t val)
+{
+	return float32_exp(val);
+}
+
+static inline float64_t fabs_f64(float64_t val)
+{
+	return float64_fabs(val);
+}
+
+static inline float32_t fabs_f32(float32_t val)
+{
+	return float32_fabs(val);
+}
+
+static inline float64_t floor_f64(float64_t val)
+{
+	return float64_floor(val);
+}
+
+static inline float32_t floor_f32(float32_t val)
+{
+	return float32_floor(val);
+}
+static inline float64_t fmod_f64(float64_t dividend, float64_t divisor)
+{
+	return float64_fmod(dividend, divisor);
+}
+
+static inline float64_t fmod_f32(float32_t dividend, float32_t divisor)
+{
+	return float32_fmod(dividend, divisor);
+}
+
+static inline float64_t frexp_f64(float64_t x, int *exp)
+{
+	return float64_frexp(x, exp);
+}
+
+static inline float64_t frexp_f32(float32_t x, int *exp)
+{
+	return float32_frexp(x, exp);
+}
+
+static inline float64_t ldexp_f64(float64_t x, int exp)
+{
+	return float64_ldexp(x, exp);
+}
+
+static inline float64_t ldexp_f32(float32_t x, int exp)
+{
+	return float32_ldexp(x, exp);
+}
+
+static inline float64_t log_f64(float64_t val)
+{
+	return float64_log(val);
+}
+
+static inline float32_t log_f32(float32_t val)
+{
+	return float32_log(val);
+}
+
+static inline float64_t log10_f64(float64_t val)
+{
+	return float64_log10(val);
+}
+
+static inline float32_t log10_f32(float32_t val)
+{
+	return float32_log10(val);
+}
+
+static inline float64_t modf_f64(float64_t value, float64_t *iptr)
+{
+	return float64_modf(value, iptr);
+}
+
+static inline float64_t modf_f32(float32_t value, float32_t *iptr)
+{
+	return float32_modf(value, iptr);
+}
+
+static inline float64_t pow_f64(float64_t x, float64_t y)
+{
+	return float64_pow(x, y);
+}
+
+static inline float32_t pow_f32(float32_t x, float32_t y)
+{
+	return float32_pow(x, y);
+}
+
+static inline float64_t sin_f64(float64_t val)
+{
+	return float64_sin(val);
+}
+
+static inline float32_t sin_f32(float32_t val)
+{
+	return float32_sin(val);
+}
+
+static inline float64_t sinh_f64(float64_t val)
+{
+	return float64_sinh(val);
+}
+
+static inline float32_t sinh_f32(float32_t val)
+{
+	return float32_sinh(val);
+}
+
+static inline float64_t sqrt_f64(float64_t val)
+{
+	return float64_sqrt(val);
+}
+
+static inline float32_t sqrt_f32(float32_t val)
+{
+	return float32_sqrt(val);
+}
+
+static inline float64_t tan_f64(float64_t val)
+{
+	return float64_tan(val);
+}
+
+static inline float32_t tan_f32(float32_t val)
+{
+	return float32_tan(val);
+}
+
+static inline float64_t tanh_f64(float64_t val)
+{
+	return float64_tanh(val);
+}
+
+static inline float32_t tanh_f32(float32_t val)
+{
+	return float32_tanh(val);
+}
+
+static inline float64_t trunc_f64(float64_t val)
+{
+	return float64_trunc(val);
+}
+
+static inline float32_t trunc_f32(float32_t val)
+{
+	return float32_trunc(val);
+}
+
+static inline float64_t acos(float64_t val)
+{
+	return acos_f64(val);
+}
+
+static inline float32_t acosf(float32_t val)
+{
+	return acos_f32(val);
+}
+
+static inline float64_t asin(float64_t val)
+{
+	return asin_f64(val);
+}
+
+static inline float32_t asinf(float32_t val)
+{
+	return asin_f32(val);
+}
+
+static inline float64_t atan(float64_t val)
+{
+	return atan_f64(val);
+}
+
+static inline float32_t atanf(float32_t val)
+{
+	return atan_f32(val);
+}
+
+static inline float64_t atan2(float64_t y, float64_t x)
+{
+	return atan2_f64(y, x);
+}
+
+static inline float32_t atan2f(float32_t y, float32_t x)
+{
+	return atan2_f32(y, x);
+}
+
+static inline float64_t ceil(float64_t val)
+{
+	return ceil_f64(val);
+}
+
+static inline float32_t ceilf(float32_t val)
+{
+	return ceil_f32(val);
+}
+
+static inline float64_t cos(float64_t val)
+{
+	return cos_f64(val);
+}
+
+static inline float32_t cosf(float32_t val)
+{
+	return cos_f32(val);
+}
+
+static inline float64_t cosh(float64_t val)
+{
+	return cosh_f64(val);
+}
+
+static inline float32_t coshf(float32_t val)
+{
+	return cosh_f32(val);
+}
+
+static inline float64_t exp(float64_t val)
+{
+	return exp_f64(val);
+}
+
+static inline float32_t expf(float32_t val)
+{
+	return exp_f32(val);
+}
+
+static inline float64_t fabs(float64_t val)
+{
+	return fabs_f64(val);
+}
+
+static inline float32_t fabsf(float32_t val)
+{
+	return fabs_f32(val);
+}
+
+static inline float64_t floor(float64_t val)
+{
+	return floor_f64(val);
+}
+
+static inline float32_t floorf(float32_t val)
+{
+	return floor_f32(val);
+}
 
 static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return float64_mod(dividend, divisor);
-}
-
-static inline double trunc(double val)
-{
-	float64_u arg;
-	arg.val = val;
-	
-	float64_u ret;
-	ret.data = trunc_float64(arg.data);
-	
-	return ret.val;
+	return fmod_f64(dividend, divisor);
+}
+
+static inline float32_t fmodf(float32_t dividend, float32_t divisor)
+{
+	return fmod_f32(dividend, divisor);
+}
+
+static inline float64_t frexp(float64_t x, int *exp)
+{
+	return frexp_f64(x, exp);
+}
+
+static inline float32_t frexpf(float32_t x, int *exp)
+{
+	return frexp_f32(x, exp);
+}
+
+static inline float64_t ldexp(float64_t x, int exp)
+{
+	return ldexp_f64(x, exp);
+}
+
+static inline float32_t ldexpf(float32_t x, int exp)
+{
+	return ldexp_f32(x, exp);
+}
+
+static inline float64_t log(float64_t val)
+{
+	return log_f64(val);
+}
+
+static inline float32_t logf(float32_t val)
+{
+	return log_f32(val);
+}
+
+static inline float64_t log10(float64_t val)
+{
+	return log10_f64(val);
+}
+
+static inline float32_t log10f(float32_t val)
+{
+	return log10_f32(val);
+}
+
+static inline float64_t modf(float64_t value, float64_t *iptr)
+{
+	return modf_f64(value, iptr);
+}
+
+static inline float32_t modff(float32_t value, float32_t *iptr)
+{
+	return modf_f32(value, iptr);
+}
+
+static inline float64_t pow(float64_t x, float64_t y)
+{
+	return pow_f64(x, y);
+}
+
+static inline float32_t powf(float32_t x, float32_t y)
+{
+	return pow_f32(x, y);
 }
 
 static inline float64_t sin(float64_t val)
 {
-	return float64_sin(val);
-}
-
-static inline float64_t cos(float64_t val)
-{
-	return float64_cos(val);
+	return sin_f64(val);
+}
+
+static inline float32_t sinf(float32_t val)
+{
+	return sin_f32(val);
+}
+
+static inline float64_t sinh(float64_t val)
+{
+	return sinh_f64(val);
+}
+
+static inline float32_t sinhf(float32_t val)
+{
+	return sinh_f32(val);
+}
+
+static inline float64_t sqrt(float64_t val)
+{
+	return sqrt_f64(val);
+}
+
+static inline float32_t sqrtf(float32_t val)
+{
+	return sqrt_f32(val);
+}
+
+static inline float64_t tan(float64_t val)
+{
+	return tan_f64(val);
+}
+
+static inline float32_t tanf(float32_t val)
+{
+	return tan_f32(val);
+}
+
+static inline float64_t tanh(float64_t val)
+{
+	return tanh_f64(val);
+}
+
+static inline float32_t tanhf(float32_t val)
+{
+	return tanh_f32(val);
+}
+
+static inline float64_t trunc(float64_t val)
+{
+	return trunc_f64(val);
+}
+
+static inline float32_t truncf(float32_t val)
+{
+	return trunc_f32(val);
 }
 
Index: uspace/lib/math/arch/sparc32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/sparc32/include/libarch/math.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/sparc32/include/libarch/math.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2014 Martin Decky
+ * Copyright (c) 2015 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,33 +37,487 @@
 #define LIBMATH_sparc32_MATH_H_
 
+#include <acos.h>
+#include <asin.h>
+#include <atan.h>
+#include <atan2.h>
+#include <ceil.h>
+#include <cosh.h>
+#include <exp.h>
+#include <fabs.h>
+#include <floor.h>
+#include <fmod.h>
+#include <frexp.h>
+#include <ldexp.h>
+#include <log.h>
+#include <log10.h>
 #include <mathtypes.h>
-#include <mod.h>
+#include <modf.h>
+#include <pow.h>
+#include <sinh.h>
+#include <sqrt.h>
+#include <tan.h>
+#include <tanh.h>
+#include <trig.h>
 #include <trunc.h>
-#include <trig.h>
+
+#define HUGE_VAL FLOAT64_INF
+
+static inline float64_t acos_f64(float64_t val)
+{
+	return float64_acos(val);
+}
+
+static inline float32_t acos_f32(float32_t val)
+{
+	return float32_acos(val);
+}
+
+static inline float64_t asin_f64(float64_t val)
+{
+	return float64_asin(val);
+}
+
+static inline float32_t asin_f32(float32_t val)
+{
+	return float32_asin(val);
+}
+
+static inline float64_t atan_f64(float64_t val)
+{
+	return float64_atan(val);
+}
+
+static inline float32_t atan_f32(float32_t val)
+{
+	return float32_atan(val);
+}
+
+static inline float64_t atan2_f64(float64_t y, float64_t x)
+{
+	return float64_atan2(y, x);
+}
+
+static inline float32_t atan2_f32(float32_t y, float32_t x)
+{
+	return float32_atan2(y, x);
+}
+
+static inline float64_t ceil_f64(float64_t val)
+{
+	return float64_ceil(val);
+}
+
+static inline float32_t ceil_f32(float32_t val)
+{
+	return float32_ceil(val);
+}
+
+static inline float64_t cos_f64(float64_t val)
+{
+	return float64_cos(val);
+}
+
+static inline float32_t cos_f32(float32_t val)
+{
+	return float32_cos(val);
+}
+
+static inline float64_t cosh_f64(float64_t val)
+{
+	return float64_cosh(val);
+}
+
+static inline float32_t cosh_f32(float32_t val)
+{
+	return float32_cosh(val);
+}
+
+static inline float64_t exp_f64(float64_t val)
+{
+	return float64_exp(val);
+}
+
+static inline float32_t exp_f32(float32_t val)
+{
+	return float32_exp(val);
+}
+
+static inline float64_t fabs_f64(float64_t val)
+{
+	return float64_fabs(val);
+}
+
+static inline float32_t fabs_f32(float32_t val)
+{
+	return float32_fabs(val);
+}
+
+static inline float64_t floor_f64(float64_t val)
+{
+	return float64_floor(val);
+}
+
+static inline float32_t floor_f32(float32_t val)
+{
+	return float32_floor(val);
+}
+static inline float64_t fmod_f64(float64_t dividend, float64_t divisor)
+{
+	return float64_fmod(dividend, divisor);
+}
+
+static inline float64_t fmod_f32(float32_t dividend, float32_t divisor)
+{
+	return float32_fmod(dividend, divisor);
+}
+
+static inline float64_t frexp_f64(float64_t x, int *exp)
+{
+	return float64_frexp(x, exp);
+}
+
+static inline float64_t frexp_f32(float32_t x, int *exp)
+{
+	return float32_frexp(x, exp);
+}
+
+static inline float64_t ldexp_f64(float64_t x, int exp)
+{
+	return float64_ldexp(x, exp);
+}
+
+static inline float64_t ldexp_f32(float32_t x, int exp)
+{
+	return float32_ldexp(x, exp);
+}
+
+static inline float64_t log_f64(float64_t val)
+{
+	return float64_log(val);
+}
+
+static inline float32_t log_f32(float32_t val)
+{
+	return float32_log(val);
+}
+
+static inline float64_t log10_f64(float64_t val)
+{
+	return float64_log10(val);
+}
+
+static inline float32_t log10_f32(float32_t val)
+{
+	return float32_log10(val);
+}
+
+static inline float64_t modf_f64(float64_t value, float64_t *iptr)
+{
+	return float64_modf(value, iptr);
+}
+
+static inline float64_t modf_f32(float32_t value, float32_t *iptr)
+{
+	return float32_modf(value, iptr);
+}
+
+static inline float64_t pow_f64(float64_t x, float64_t y)
+{
+	return float64_pow(x, y);
+}
+
+static inline float32_t pow_f32(float32_t x, float32_t y)
+{
+	return float32_pow(x, y);
+}
+
+static inline float64_t sin_f64(float64_t val)
+{
+	return float64_sin(val);
+}
+
+static inline float32_t sin_f32(float32_t val)
+{
+	return float32_sin(val);
+}
+
+static inline float64_t sinh_f64(float64_t val)
+{
+	return float64_sinh(val);
+}
+
+static inline float32_t sinh_f32(float32_t val)
+{
+	return float32_sinh(val);
+}
+
+static inline float64_t sqrt_f64(float64_t val)
+{
+	return float64_sqrt(val);
+}
+
+static inline float32_t sqrt_f32(float32_t val)
+{
+	return float32_sqrt(val);
+}
+
+static inline float64_t tan_f64(float64_t val)
+{
+	return float64_tan(val);
+}
+
+static inline float32_t tan_f32(float32_t val)
+{
+	return float32_tan(val);
+}
+
+static inline float64_t tanh_f64(float64_t val)
+{
+	return float64_tanh(val);
+}
+
+static inline float32_t tanh_f32(float32_t val)
+{
+	return float32_tanh(val);
+}
+
+static inline float64_t trunc_f64(float64_t val)
+{
+	return float64_trunc(val);
+}
+
+static inline float32_t trunc_f32(float32_t val)
+{
+	return float32_trunc(val);
+}
+
+static inline float64_t acos(float64_t val)
+{
+	return acos_f64(val);
+}
+
+static inline float32_t acosf(float32_t val)
+{
+	return acos_f32(val);
+}
+
+static inline float64_t asin(float64_t val)
+{
+	return asin_f64(val);
+}
+
+static inline float32_t asinf(float32_t val)
+{
+	return asin_f32(val);
+}
+
+static inline float64_t atan(float64_t val)
+{
+	return atan_f64(val);
+}
+
+static inline float32_t atanf(float32_t val)
+{
+	return atan_f32(val);
+}
+
+static inline float64_t atan2(float64_t y, float64_t x)
+{
+	return atan2_f64(y, x);
+}
+
+static inline float32_t atan2f(float32_t y, float32_t x)
+{
+	return atan2_f32(y, x);
+}
+
+static inline float64_t ceil(float64_t val)
+{
+	return ceil_f64(val);
+}
+
+static inline float32_t ceilf(float32_t val)
+{
+	return ceil_f32(val);
+}
+
+static inline float64_t cos(float64_t val)
+{
+	return cos_f64(val);
+}
+
+static inline float32_t cosf(float32_t val)
+{
+	return cos_f32(val);
+}
+
+static inline float64_t cosh(float64_t val)
+{
+	return cosh_f64(val);
+}
+
+static inline float32_t coshf(float32_t val)
+{
+	return cosh_f32(val);
+}
+
+static inline float64_t exp(float64_t val)
+{
+	return exp_f64(val);
+}
+
+static inline float32_t expf(float32_t val)
+{
+	return exp_f32(val);
+}
+
+static inline float64_t fabs(float64_t val)
+{
+	return fabs_f64(val);
+}
+
+static inline float32_t fabsf(float32_t val)
+{
+	return fabs_f32(val);
+}
+
+static inline float64_t floor(float64_t val)
+{
+	return floor_f64(val);
+}
+
+static inline float32_t floorf(float32_t val)
+{
+	return floor_f32(val);
+}
 
 static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return float64_mod(dividend, divisor);
+	return fmod_f64(dividend, divisor);
+}
+
+static inline float32_t fmodf(float32_t dividend, float32_t divisor)
+{
+	return fmod_f32(dividend, divisor);
+}
+
+static inline float64_t frexp(float64_t x, int *exp)
+{
+	return frexp_f64(x, exp);
+}
+
+static inline float32_t frexpf(float32_t x, int *exp)
+{
+	return frexp_f32(x, exp);
+}
+
+static inline float64_t ldexp(float64_t x, int exp)
+{
+	return ldexp_f64(x, exp);
+}
+
+static inline float32_t ldexpf(float32_t x, int exp)
+{
+	return ldexp_f32(x, exp);
+}
+
+static inline float64_t log(float64_t val)
+{
+	return log_f64(val);
+}
+
+static inline float32_t logf(float32_t val)
+{
+	return log_f32(val);
+}
+
+static inline float64_t log10(float64_t val)
+{
+	return log10_f64(val);
+}
+
+static inline float32_t log10f(float32_t val)
+{
+	return log10_f32(val);
+}
+
+static inline float64_t modf(float64_t value, float64_t *iptr)
+{
+	return modf_f64(value, iptr);
+}
+
+static inline float32_t modff(float32_t value, float32_t *iptr)
+{
+	return modf_f32(value, iptr);
+}
+
+static inline float64_t pow(float64_t x, float64_t y)
+{
+	return pow_f64(x, y);
+}
+
+static inline float32_t powf(float32_t x, float32_t y)
+{
+	return pow_f32(x, y);
+}
+
+static inline float64_t sin(float64_t val)
+{
+	return sin_f64(val);
+}
+
+static inline float32_t sinf(float32_t val)
+{
+	return sin_f32(val);
+}
+
+static inline float64_t sinh(float64_t val)
+{
+	return sinh_f64(val);
+}
+
+static inline float32_t sinhf(float32_t val)
+{
+	return sinh_f32(val);
+}
+
+static inline float64_t sqrt(float64_t val)
+{
+	return sqrt_f64(val);
+}
+
+static inline float32_t sqrtf(float32_t val)
+{
+	return sqrt_f32(val);
+}
+
+static inline float64_t tan(float64_t val)
+{
+	return tan_f64(val);
+}
+
+static inline float32_t tanf(float32_t val)
+{
+	return tan_f32(val);
+}
+
+static inline float64_t tanh(float64_t val)
+{
+	return tanh_f64(val);
+}
+
+static inline float32_t tanhf(float32_t val)
+{
+	return tanh_f32(val);
 }
 
 static inline float64_t trunc(float64_t val)
 {
-	float64_u arg;
-	arg.val = val;
-	
-	float64_u ret;
-	ret.data = trunc_float64(arg.data);
-	
-	return ret.val;
-}
-
-static inline float64_t sin(float64_t val)
-{
-	return float64_sin(val);
-}
-
-static inline float64_t cos(float64_t val)
-{
-	return float64_cos(val);
+	return trunc_f64(val);
+}
+
+static inline float32_t truncf(float32_t val)
+{
+	return trunc_f32(val);
 }
 
Index: uspace/lib/math/arch/sparc64/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/sparc64/include/libarch/math.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/arch/sparc64/include/libarch/math.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2014 Martin Decky
+ * Copyright (c) 2015 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,33 +37,487 @@
 #define LIBMATH_sparc64_MATH_H_
 
+#include <acos.h>
+#include <asin.h>
+#include <atan.h>
+#include <atan2.h>
+#include <ceil.h>
+#include <cosh.h>
+#include <exp.h>
+#include <fabs.h>
+#include <floor.h>
+#include <fmod.h>
+#include <frexp.h>
+#include <ldexp.h>
+#include <log.h>
+#include <log10.h>
 #include <mathtypes.h>
-#include <mod.h>
+#include <modf.h>
+#include <pow.h>
+#include <sinh.h>
+#include <sqrt.h>
+#include <tan.h>
+#include <tanh.h>
+#include <trig.h>
 #include <trunc.h>
-#include <trig.h>
+
+#define HUGE_VAL FLOAT64_INF
+
+static inline float64_t acos_f64(float64_t val)
+{
+	return float64_acos(val);
+}
+
+static inline float32_t acos_f32(float32_t val)
+{
+	return float32_acos(val);
+}
+
+static inline float64_t asin_f64(float64_t val)
+{
+	return float64_asin(val);
+}
+
+static inline float32_t asin_f32(float32_t val)
+{
+	return float32_asin(val);
+}
+
+static inline float64_t atan_f64(float64_t val)
+{
+	return float64_atan(val);
+}
+
+static inline float32_t atan_f32(float32_t val)
+{
+	return float32_atan(val);
+}
+
+static inline float64_t atan2_f64(float64_t y, float64_t x)
+{
+	return float64_atan2(y, x);
+}
+
+static inline float32_t atan2_f32(float32_t y, float32_t x)
+{
+	return float32_atan2(y, x);
+}
+
+static inline float64_t ceil_f64(float64_t val)
+{
+	return float64_ceil(val);
+}
+
+static inline float32_t ceil_f32(float32_t val)
+{
+	return float32_ceil(val);
+}
+
+static inline float64_t cos_f64(float64_t val)
+{
+	return float64_cos(val);
+}
+
+static inline float32_t cos_f32(float32_t val)
+{
+	return float32_cos(val);
+}
+
+static inline float64_t cosh_f64(float64_t val)
+{
+	return float64_cosh(val);
+}
+
+static inline float32_t cosh_f32(float32_t val)
+{
+	return float32_cosh(val);
+}
+
+static inline float64_t exp_f64(float64_t val)
+{
+	return float64_exp(val);
+}
+
+static inline float32_t exp_f32(float32_t val)
+{
+	return float32_exp(val);
+}
+
+static inline float64_t fabs_f64(float64_t val)
+{
+	return float64_fabs(val);
+}
+
+static inline float32_t fabs_f32(float32_t val)
+{
+	return float32_fabs(val);
+}
+
+static inline float64_t floor_f64(float64_t val)
+{
+	return float64_floor(val);
+}
+
+static inline float32_t floor_f32(float32_t val)
+{
+	return float32_floor(val);
+}
+static inline float64_t fmod_f64(float64_t dividend, float64_t divisor)
+{
+	return float64_fmod(dividend, divisor);
+}
+
+static inline float64_t fmod_f32(float32_t dividend, float32_t divisor)
+{
+	return float32_fmod(dividend, divisor);
+}
+
+static inline float64_t frexp_f64(float64_t x, int *exp)
+{
+	return float64_frexp(x, exp);
+}
+
+static inline float64_t frexp_f32(float32_t x, int *exp)
+{
+	return float32_frexp(x, exp);
+}
+
+static inline float64_t ldexp_f64(float64_t x, int exp)
+{
+	return float64_ldexp(x, exp);
+}
+
+static inline float64_t ldexp_f32(float32_t x, int exp)
+{
+	return float32_ldexp(x, exp);
+}
+
+static inline float64_t log_f64(float64_t val)
+{
+	return float64_log(val);
+}
+
+static inline float32_t log_f32(float32_t val)
+{
+	return float32_log(val);
+}
+
+static inline float64_t log10_f64(float64_t val)
+{
+	return float64_log10(val);
+}
+
+static inline float32_t log10_f32(float32_t val)
+{
+	return float32_log10(val);
+}
+
+static inline float64_t modf_f64(float64_t value, float64_t *iptr)
+{
+	return float64_modf(value, iptr);
+}
+
+static inline float64_t modf_f32(float32_t value, float32_t *iptr)
+{
+	return float32_modf(value, iptr);
+}
+
+static inline float64_t pow_f64(float64_t x, float64_t y)
+{
+	return float64_pow(x, y);
+}
+
+static inline float32_t pow_f32(float32_t x, float32_t y)
+{
+	return float32_pow(x, y);
+}
+
+static inline float64_t sin_f64(float64_t val)
+{
+	return float64_sin(val);
+}
+
+static inline float32_t sin_f32(float32_t val)
+{
+	return float32_sin(val);
+}
+
+static inline float64_t sinh_f64(float64_t val)
+{
+	return float64_sinh(val);
+}
+
+static inline float32_t sinh_f32(float32_t val)
+{
+	return float32_sinh(val);
+}
+
+static inline float64_t sqrt_f64(float64_t val)
+{
+	return float64_sqrt(val);
+}
+
+static inline float32_t sqrt_f32(float32_t val)
+{
+	return float32_sqrt(val);
+}
+
+static inline float64_t tan_f64(float64_t val)
+{
+	return float64_tan(val);
+}
+
+static inline float32_t tan_f32(float32_t val)
+{
+	return float32_tan(val);
+}
+
+static inline float64_t tanh_f64(float64_t val)
+{
+	return float64_tanh(val);
+}
+
+static inline float32_t tanh_f32(float32_t val)
+{
+	return float32_tanh(val);
+}
+
+static inline float64_t trunc_f64(float64_t val)
+{
+	return float64_trunc(val);
+}
+
+static inline float32_t trunc_f32(float32_t val)
+{
+	return float32_trunc(val);
+}
+
+static inline float64_t acos(float64_t val)
+{
+	return acos_f64(val);
+}
+
+static inline float32_t acosf(float32_t val)
+{
+	return acos_f32(val);
+}
+
+static inline float64_t asin(float64_t val)
+{
+	return asin_f64(val);
+}
+
+static inline float32_t asinf(float32_t val)
+{
+	return asin_f32(val);
+}
+
+static inline float64_t atan(float64_t val)
+{
+	return atan_f64(val);
+}
+
+static inline float32_t atanf(float32_t val)
+{
+	return atan_f32(val);
+}
+
+static inline float64_t atan2(float64_t y, float64_t x)
+{
+	return atan2_f64(y, x);
+}
+
+static inline float32_t atan2f(float32_t y, float32_t x)
+{
+	return atan2_f32(y, x);
+}
+
+static inline float64_t ceil(float64_t val)
+{
+	return ceil_f64(val);
+}
+
+static inline float32_t ceilf(float32_t val)
+{
+	return ceil_f32(val);
+}
+
+static inline float64_t cos(float64_t val)
+{
+	return cos_f64(val);
+}
+
+static inline float32_t cosf(float32_t val)
+{
+	return cos_f32(val);
+}
+
+static inline float64_t cosh(float64_t val)
+{
+	return cosh_f64(val);
+}
+
+static inline float32_t coshf(float32_t val)
+{
+	return cosh_f32(val);
+}
+
+static inline float64_t exp(float64_t val)
+{
+	return exp_f64(val);
+}
+
+static inline float32_t expf(float32_t val)
+{
+	return exp_f32(val);
+}
+
+static inline float64_t fabs(float64_t val)
+{
+	return fabs_f64(val);
+}
+
+static inline float32_t fabsf(float32_t val)
+{
+	return fabs_f32(val);
+}
+
+static inline float64_t floor(float64_t val)
+{
+	return floor_f64(val);
+}
+
+static inline float32_t floorf(float32_t val)
+{
+	return floor_f32(val);
+}
 
 static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return float64_mod(dividend, divisor);
+	return fmod_f64(dividend, divisor);
+}
+
+static inline float32_t fmodf(float32_t dividend, float32_t divisor)
+{
+	return fmod_f32(dividend, divisor);
+}
+
+static inline float64_t frexp(float64_t x, int *exp)
+{
+	return frexp_f64(x, exp);
+}
+
+static inline float32_t frexpf(float32_t x, int *exp)
+{
+	return frexp_f32(x, exp);
+}
+
+static inline float64_t ldexp(float64_t x, int exp)
+{
+	return ldexp_f64(x, exp);
+}
+
+static inline float32_t ldexpf(float32_t x, int exp)
+{
+	return ldexp_f32(x, exp);
+}
+
+static inline float64_t log(float64_t val)
+{
+	return log_f64(val);
+}
+
+static inline float32_t logf(float32_t val)
+{
+	return log_f32(val);
+}
+
+static inline float64_t log10(float64_t val)
+{
+	return log10_f64(val);
+}
+
+static inline float32_t log10f(float32_t val)
+{
+	return log10_f32(val);
+}
+
+static inline float64_t modf(float64_t value, float64_t *iptr)
+{
+	return modf_f64(value, iptr);
+}
+
+static inline float32_t modff(float32_t value, float32_t *iptr)
+{
+	return modf_f32(value, iptr);
+}
+
+static inline float64_t pow(float64_t x, float64_t y)
+{
+	return pow_f64(x, y);
+}
+
+static inline float32_t powf(float32_t x, float32_t y)
+{
+	return pow_f32(x, y);
+}
+
+static inline float64_t sin(float64_t val)
+{
+	return sin_f64(val);
+}
+
+static inline float32_t sinf(float32_t val)
+{
+	return sin_f32(val);
+}
+
+static inline float64_t sinh(float64_t val)
+{
+	return sinh_f64(val);
+}
+
+static inline float32_t sinhf(float32_t val)
+{
+	return sinh_f32(val);
+}
+
+static inline float64_t sqrt(float64_t val)
+{
+	return sqrt_f64(val);
+}
+
+static inline float32_t sqrtf(float32_t val)
+{
+	return sqrt_f32(val);
+}
+
+static inline float64_t tan(float64_t val)
+{
+	return tan_f64(val);
+}
+
+static inline float32_t tanf(float32_t val)
+{
+	return tan_f32(val);
+}
+
+static inline float64_t tanh(float64_t val)
+{
+	return tanh_f64(val);
+}
+
+static inline float32_t tanhf(float32_t val)
+{
+	return tanh_f32(val);
 }
 
 static inline float64_t trunc(float64_t val)
 {
-	float64_u arg;
-	arg.val = val;
-	
-	float64_u ret;
-	ret.data = trunc_float64(arg.data);
-	
-	return ret.val;
-}
-
-static inline float64_t sin(float64_t val)
-{
-	return float64_sin(val);
-}
-
-static inline float64_t cos(float64_t val)
-{
-	return float64_cos(val);
+	return trunc_f64(val);
+}
+
+static inline float32_t truncf(float32_t val)
+{
+	return trunc_f32(val);
 }
 
Index: uspace/lib/math/generic/acos.c
===================================================================
--- uspace/lib/math/generic/acos.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/acos.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <acos.h>
+#include <errno.h>
+#include <math.h>
+
+/** Inverse cosine (32-bit floating point)
+ *
+ * Compute inverse cosine value.
+ *
+ * @param arg Inversecosine argument.
+ *
+ * @return Inverse cosine value.
+ *
+ */
+float32_t float32_acos(float32_t arg)
+{
+	if (arg < -1.0 || arg > 1.0) {
+		errno = EDOM;
+		return FLOAT32_NAN;
+	}
+
+	return M_PI_2 - asin_f32(arg);
+}
+
+/** Inverse cosine (64-bit floating point)
+ *
+ * Compute inverse cosine value.
+ *
+ * @param arg Inversecosine argument.
+ *
+ * @return Inverse cosine value.
+ *
+ */
+float64_t float64_acos(float64_t arg)
+{
+	if (arg < -1.0 || arg > 1.0) {
+		errno = EDOM;
+		return FLOAT64_NAN;
+	}
+
+	return M_PI_2 - asin_f64(arg);
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/asin.c
===================================================================
--- uspace/lib/math/generic/asin.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/asin.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <asin.h>
+#include <errno.h>
+#include <math.h>
+
+/** Inverse sine (32-bit floating point)
+ *
+ * Compute inverse sine value.
+ *
+ * @param arg Inverse sine argument.
+ *
+ * @return Inverse sine value.
+ *
+ */
+float32_t float32_asin(float32_t arg)
+{
+	float32_t aval;
+	
+	if (arg < -1.0 || arg > 1.0) {
+		errno = EDOM;
+		return FLOAT32_NAN;
+	}
+	
+	aval = 2.0 * atan_f32(arg / (1.0 + sqrt_f32(1.0 - arg*arg)));
+	if (arg > 0.0)
+		return aval;
+	else
+		return -aval;
+}
+
+/** Inverse sine (64-bit floating point)
+ *
+ * Compute inverse sine value.
+ *
+ * @param arg Inverse sine argument.
+ *
+ * @return Inverse sine value.
+ *
+ */
+float64_t float64_asin(float64_t arg)
+{
+	float64_t aval;
+	
+	if (arg < -1.0 || arg > 1.0) {
+		errno = EDOM;
+		return FLOAT64_NAN;
+	}
+	
+	aval = 2.0 * atan_f64(arg / (1.0 + sqrt_f64(1.0 - arg*arg)));
+	if (arg > 0.0)
+		return aval;
+	else
+		return -aval;
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/atan.c
===================================================================
--- uspace/lib/math/generic/atan.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/atan.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <atan.h>
+#include <errno.h>
+#include <math.h>
+
+#define SERIES_DEGREE_32 13
+#define SERIES_DEGREE_64 33
+
+/** Inverse tangent approximation by Euler's series (32-bit floating point)
+ *
+ * Compute the approximation of inverse tangent by a
+ * series found by Leonhard Euler (using the first SERIES_DEGREE terms).
+ *
+ * @param arg Inverse tangent argument.
+ *
+ * @return Inverse tangent value approximation.
+ *
+ */
+static float32_t series_atan_32(float32_t arg)
+{
+	float32_t sum = 0;
+	float32_t a = arg / (1.0 + arg * arg);
+	
+	/*
+	 * atan(z) = sum(n=0, +inf) [ (2^2n) * (n!)^2 / (2n + 1)! *
+	 *    z^(2n+1) / (1 + z^2)^(n+1) ]
+	 */
+	
+	for (unsigned int n = 0; n < SERIES_DEGREE_32; n++) {
+		if (n > 0) {
+			a = a * n * n;
+			a = a / (2.0 * n + 1.0) / (2.0 * n);
+		}
+		sum += a;
+		a = a * 4.0 * arg * arg / (1.0 + arg * arg);
+	}
+	
+	return sum;
+}
+
+/** Inverse tangent approximation by Euler's series (64-bit floating point)
+ *
+ * Compute the approximation of inverse tangent by a
+ * series found by Leonhard Euler (using the first SERIES_DEGREE terms).
+ *
+ * @param arg Inverse tangent argument.
+ *
+ * @return Inverse tangent value approximation.
+ *
+ */
+static float64_t series_atan_64(float64_t arg)
+{
+	float64_t sum = 0;
+	float64_t a = arg / (1.0 + arg * arg);
+	
+	/*
+	 * atan(z) = sum(n=0, +inf) [ (2^2n) * (n!)^2 / (2n + 1)! *
+	 *    z^(2n+1) / (1 + z^2)^(n+1) ]
+	 */
+	
+	for (unsigned int n = 0; n < SERIES_DEGREE_64; n++) {
+		if (n > 0) {
+			a = a * n * n;
+			a = a / (2.0 * n + 1.0) / (2.0 * n);
+		}
+		sum += a;
+		a = a * 4.0 * arg * arg / (1.0 + arg * arg);
+	}
+	
+	return sum;
+}
+
+/** Inverse tangent (32-bit floating point)
+ *
+ * Compute inverse sine value.
+ *
+ * @param arg Inverse sine argument.
+ *
+ * @return Inverse sine value.
+ *
+ */
+float32_t float32_atan(float32_t arg)
+{
+	if (arg < -1.0 || arg > 1.0)
+		return 2.0 * series_atan_32(arg / (1.0 + sqrt_f32(1.0 + arg*arg)));
+	else
+		return series_atan_32(arg);
+}
+
+/** Inverse tangent (64-bit floating point)
+ *
+ * Compute inverse sine value.
+ *
+ * @param arg Inverse sine argument.
+ *
+ * @return Inverse sine value.
+ *
+ */
+float64_t float64_atan(float64_t arg)
+{
+	if (arg < -1.0 || arg > 1.0)
+		return 2.0 * series_atan_64(arg / (1.0 + sqrt_f64(1.0 + arg*arg)));
+	else
+		return series_atan_64(arg);
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/atan2.c
===================================================================
--- uspace/lib/math/generic/atan2.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/atan2.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <atan2.h>
+#include <errno.h>
+#include <math.h>
+
+/** Inverse tangent of two variables (32-bit floating point)
+ *
+ * @param y
+ * @param x
+ *
+ * @return Inverse tangent of @a y / @a x.
+ *
+ */
+float32_t float32_atan2(float32_t y, float32_t x)
+{
+	if (x >= 0)
+		return atan_f32(y / x);
+	else if (y >= 0)
+		return M_PI - atan_f32(y / -x);
+	else
+		return -M_PI + atan_f32(y / -x);
+}
+
+/** Inverse tangent of two variables (64-bit floating point)
+ *
+ * @param y
+ * @param x
+ *
+ * @return Inverse tangent of @a y / @a x.
+ *
+ */
+float64_t float64_atan2(float64_t y, float64_t x)
+{
+	if (x >= 0)
+		return atan_f64(y / x);
+	else if (y >= 0)
+		return M_PI - atan_f64(y / -x);
+	else
+		return -M_PI + atan_f64(y / -x);
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/ceil.c
===================================================================
--- uspace/lib/math/generic/ceil.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/ceil.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <ceil.h>
+#include <math.h>
+#include <mathtypes.h>
+
+/** Ceiling (round towards positive infinity, 32-bit floating point)
+ *
+ * @param val Floating point number.
+ *
+ * @return Number rounded towards positive infinity.
+ */
+float32_t float32_ceil(float32_t val)
+{
+	float32_u t;
+	float32_u v;
+	float32_u r;
+	
+	v.val = val;
+	t.val = trunc_f32(val);
+	
+	if (v.data.parts.sign == 1 || val == t.val) {
+		r = t;
+	} else {
+		r.val = t.val + 1.0;
+	}
+	
+	return r.val;
+}
+
+/** Ceiling (round towards positive infinity, 64-bit floating point)
+ *
+ * @param val Floating point number.
+ *
+ * @return Number rounded towards positive infinity.
+ */
+float64_t float64_ceil(float64_t val)
+{
+	float64_u t;
+	float64_u v;
+	float64_u r;
+	
+	v.val = val;
+	t.val = trunc_f64(val);
+	
+	if (v.data.parts.sign == 1 || val == t.val) {
+		r = t;
+	} else {
+		r.val = t.val + 1.0;
+	}
+	
+	return r.val;
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/cosh.c
===================================================================
--- uspace/lib/math/generic/cosh.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/cosh.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <cosh.h>
+#include <math.h>
+
+/** Hyperbolic cosine (32-bit floating point)
+ *
+ * Compute hyperbolic cosine value.
+ *
+ * @param arg Hyperbolic angle
+ *
+ * @return Hyperbolic cosine.
+ *
+ */
+float32_t float32_cosh(float32_t arg)
+{
+	return (exp_f32(arg) + exp_f32(-arg)) / 2.0;
+}
+
+/** Hyperbolic cosine (64-bit floating point)
+ *
+ * Compute hyperbolic cosine value.
+ *
+ * @param arg Hyperbolic angle
+ *
+ * @return Hyperbolic cosine.
+ *
+ */
+float64_t float64_cosh(float64_t arg)
+{
+	return (exp_f64(arg) + exp_f64(-arg)) / 2.0;
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/exp.c
===================================================================
--- uspace/lib/math/generic/exp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/exp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2015 Jiri Svoboda
+ * Copyright (c) 2014 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <exp.h>
+#include <math.h>
+
+#define TAYLOR_DEGREE_32 13
+#define TAYLOR_DEGREE_64 21
+
+/** Precomputed values for factorial (starting from 1!) */
+static float64_t factorials[TAYLOR_DEGREE_64] = {
+	1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800,
+	479001600, 6227020800.0L, 87178291200.0L, 1307674368000.0L,
+	20922789888000.0L, 355687428096000.0L, 6402373705728000.0L,
+	121645100408832000.0L, 2432902008176640000.0L, 51090942171709440000.0L
+};
+
+/** Exponential approximation by Taylor series (32-bit floating point)
+ *
+ * Compute the approximation of exponential by a Taylor
+ * series (using the first TAYLOR_DEGREE terms).
+ * The approximation is reasonably accurate for
+ * arguments within the interval XXXX.
+ *
+ * @param arg Argument.
+ *
+ * @return Exponential value approximation.
+ *
+ */
+static float32_t taylor_exp_32(float32_t arg)
+{
+	float32_t ret = 1;
+	float32_t nom = 1;
+	
+	for (unsigned int i = 0; i < TAYLOR_DEGREE_32; i++) {
+		nom *= arg;
+		ret += nom / factorials[i];
+	}
+	
+	return ret;
+}
+
+/** Exponential approximation by Taylor series (64-bit floating point)
+ *
+ * Compute the approximation of exponential by a Taylor
+ * series (using the first TAYLOR_DEGREE terms).
+ * The approximation is reasonably accurate for
+ * arguments within the interval XXXX.
+ *
+ * @param arg Argument.
+ *
+ * @return Exponential value approximation.
+ *
+ */
+static float64_t taylor_exp_64(float64_t arg)
+{
+	float64_t ret = 1;
+	float64_t nom = 1;
+	
+	for (unsigned int i = 0; i < TAYLOR_DEGREE_64; i++) {
+		nom *= arg;
+		ret += nom / factorials[i];
+	}
+	
+	return ret;
+}
+
+/** Exponential (32-bit floating point)
+ *
+ * Compute exponential value.
+ *
+ * @param arg Exponential argument.
+ *
+ * @return Exponential value.
+ *
+ */
+float32_t float32_exp(float32_t arg)
+{
+	float32_t f;
+	float32_t i;
+	float32_u r;
+
+	/*
+	 * e^a = (2 ^ log2(e))^a = 2 ^ (log2(e) * a)
+	 * log2(e) * a = i + f | f in [0, 1]
+	 * e ^ a = 2 ^ (i + f) = 2^f * 2^i = (e ^ log(2))^f * 2^i =
+	 * e^(log(2)*f) * 2^i
+	 */
+
+	i = trunc_f32(arg * M_LOG2E);
+	f = arg * M_LOG2E - i;
+
+	r.val = taylor_exp_32(M_LN2 * f);
+	r.data.parts.exp += i;
+	return r.val;
+}
+
+/** Exponential (64-bit floating point)
+ *
+ * Compute exponential value.
+ *
+ * @param arg Exponential argument.
+ *
+ * @return Exponential value.
+ *
+ */
+float64_t float64_exp(float64_t arg)
+{
+	float64_t f;
+	float64_t i;
+	float64_u r;
+
+	/*
+	 * e^a = (2 ^ log2(e))^a = 2 ^ (log2(e) * a)
+	 * log2(e) * a = i + f | f in [0, 1]
+	 * e ^ a = 2 ^ (i + f) = 2^f * 2^i = (e ^ log(2))^f * 2^i =
+	 * e^(log(2)*f) * 2^i
+	 */
+
+	i = trunc_f64(arg * M_LOG2E);
+	f = arg * M_LOG2E - i;
+
+	r.val = taylor_exp_64(M_LN2 * f);
+	r.data.parts.exp += i;
+	return r.val;
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/fabs.c
===================================================================
--- uspace/lib/math/generic/fabs.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/fabs.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <math.h>
+#include <fabs.h>
+
+/** Absolute value (32-bit floating point)
+ *
+ * Compute absolute value.
+ *
+ * @param arg Argument.
+ *
+ * @return Absolute value.
+ *
+ */
+float32_t float32_fabs(float32_t arg)
+{
+	if (arg < 0.0)
+		return -arg;
+	else
+		return arg;
+}
+
+/** Absolute value (64-bit floating point)
+ *
+ * Compute absolute value.
+ *
+ * @param arg Argument.
+ *
+ * @return Absolute value.
+ *
+ */
+float64_t float64_fabs(float64_t arg)
+{
+	if (arg < 0.0)
+		return -arg;
+	else
+		return arg;
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/floor.c
===================================================================
--- uspace/lib/math/generic/floor.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/floor.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <floor.h>
+#include <math.h>
+#include <mathtypes.h>
+
+/** Ceiling (round towards negative infinity, 32-bit floating point)
+ *
+ * @param val Floating point number.
+ *
+ * @return Number rounded towards negative infinity.
+ */
+
+float32_t float32_floor(float32_t val)
+{
+	float32_t t;
+	float32_u v;
+	
+	v.val = val;
+	t = trunc_f32(val);
+	
+	if (v.data.parts.sign == 0 || val == t)
+		return t;
+	else
+		return t - 1.0;
+}
+
+/** Ceiling (round towards negative infinity, 64-bit floating point)
+ *
+ * @param val Floating point number.
+ *
+ * @return Number rounded towards negative infinity.
+ */
+
+float64_t float64_floor(float64_t val)
+{
+	float64_t t;
+	float64_u v;
+	
+	v.val = val;
+	t = trunc_f64(val);
+	
+	if (v.data.parts.sign == 0 || val == t)
+		return t;
+	else
+		return t - 1.0;
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/fmod.c
===================================================================
--- uspace/lib/math/generic/fmod.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/fmod.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2014 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <fmod.h>
+#include <math.h>
+
+/** Remainder function (32-bit floating point)
+ *
+ * Calculate the modulo of dividend by divisor.
+ *
+ * This is a very basic implementation that uses
+ * division and multiplication (instead of exact
+ * arithmetics). Thus the result might be very
+ * imprecise (depending on the magnitude of the
+ * arguments).
+ *
+ * @param dividend Dividend.
+ * @param divisor  Divisor.
+ *
+ * @return Modulo.
+ *
+ */
+float32_t float32_fmod(float32_t dividend, float32_t divisor)
+{
+	// FIXME: replace with exact arithmetics
+	
+	float32_t quotient = trunc_f32(dividend / divisor);
+	
+	return (dividend - quotient * divisor);
+}
+
+/** Remainder function (64-bit floating point)
+ *
+ * Calculate the modulo of dividend by divisor.
+ *
+ * This is a very basic implementation that uses
+ * division and multiplication (instead of exact
+ * arithmetics). Thus the result might be very
+ * imprecise (depending on the magnitude of the
+ * arguments).
+ *
+ * @param dividend Dividend.
+ * @param divisor  Divisor.
+ *
+ * @return Modulo.
+ *
+ */
+float64_t float64_fmod(float64_t dividend, float64_t divisor)
+{
+	// FIXME: replace with exact arithmetics
+	
+	float64_t quotient = trunc_f64(dividend / divisor);
+	
+	return (dividend - quotient * divisor);
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/frexp.c
===================================================================
--- uspace/lib/math/generic/frexp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/frexp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <frexp.h>
+#include <math.h>
+
+/** Break single precision number into fraction and exponent
+ *
+ * Return f and *exp such that x = f * 2^(*exp) and f is in [0.5,1)
+ *
+ * @param x Number
+ * @param exp Place to store exponent
+ *
+ * @return f
+ *
+ */
+float32_t float32_frexp(float32_t x, int *exp)
+{
+	float32_u u;
+
+	u.val = x;
+	*exp = u.data.parts.exp - FLOAT32_BIAS;
+	u.data.parts.exp = FLOAT32_BIAS;
+
+	return u.val;
+}
+
+/** Break double precision number into fraction and exponent
+ *
+ * Return f and *exp such that x = f * 2^(*exp) and f is in [0.5,1)
+ *
+ * @param x Number
+ * @param exp Place to store exponent
+ *
+ * @return f
+ *
+ */
+float64_t float64_frexp(float64_t x, int *exp)
+{
+	float64_u u;
+
+	u.val = x;
+	*exp = u.data.parts.exp - FLOAT64_BIAS;
+	u.data.parts.exp = FLOAT64_BIAS;
+
+	return u.val;
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/ldexp.c
===================================================================
--- uspace/lib/math/generic/ldexp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/ldexp.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <errno.h>
+#include <ldexp.h>
+#include <math.h>
+
+/** Single precision multiply by power of two
+ *
+ * Compute x * 2^exp.
+ *
+ * @param x Number
+ * @param exp Exponent
+ *
+ * @return x * 2^exp
+ *
+ */
+float32_t float32_ldexp(float32_t x, int exp)
+{
+	float32_u u;
+	int e;
+
+	u.val = x;
+	e = u.data.parts.exp + exp;
+
+	if (e < 0) {
+		/* XXX Can we return denormalized numbers? */
+		return 0.0;
+	} else if (e > FLOAT32_MAX_EXPONENT) {
+		errno = ERANGE;
+		if (e < 0)
+			return -FLOAT32_INF;
+		else
+			return FLOAT32_INF;
+	} else {
+		/* Adjust exponent */
+		u.data.parts.exp = e;
+		return u.val;
+	}
+}
+
+/** Double precision multiply by power of two
+ *
+ * Compute x * 2^exp.
+ *
+ * @param x Number
+ * @param y Exponent
+ *
+ * @return x * 2^exp
+ *
+ */
+float64_t float64_ldexp(float64_t x, int exp)
+{
+	float64_u u;
+	int e;
+
+	u.val = x;
+	e = u.data.parts.exp + exp;
+
+	if (e < 0) {
+		/* XXX Can we return denormalized numbers? */
+		return 0.0;
+	} else if (e > FLOAT64_MAX_EXPONENT) {
+		errno = ERANGE;
+		if (e < 0)
+			return -FLOAT64_INF;
+		else
+			return FLOAT64_INF;
+	} else {
+		/* Adjust exponent */
+		u.data.parts.exp = e;
+		return u.val;
+	}
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/log.c
===================================================================
--- uspace/lib/math/generic/log.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/log.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2015 Jiri Svoboda
+ * Copyright (c) 2014 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <log.h>
+#include <math.h>
+
+#define TAYLOR_DEGREE_32  31
+#define TAYLOR_DEGREE_64  63
+
+/** log(1 - arg) approximation by Taylor series (32-bit floating point)
+ *
+ * Compute the approximation of log(1 - arg) by a Taylor
+ * series (using the first TAYLOR_DEGREE terms).
+ * arg must be within [-1, 1].
+ *
+ * @param arg Argument.
+ *
+ * @return log(1 - arg)
+ *
+ */
+static float32_t taylor_log_32(float32_t arg)
+{
+	float32_t ret = 0;
+	float32_t num = 1;
+	
+	for (unsigned int i = 1; i <= TAYLOR_DEGREE_32; i++) {
+		num *= arg;
+		
+		if ((i % 2) == 0)
+			ret += num / i;
+		else
+			ret -= num / i;
+	}
+	
+	return ret;
+}
+
+/** log(1 - arg) approximation by Taylor series (64-bit floating point)
+ *
+ * Compute the approximation of log(1 - arg) by a Taylor
+ * series (using the first TAYLOR_DEGREE terms).
+ * arg must be within [-1, 1].
+ *
+ * @param arg Argument.
+ *
+ * @return log(1 - arg)
+ *
+ */
+static float64_t taylor_log_64(float64_t arg)
+{
+	float64_t ret = 0;
+	float64_t num = 1;
+	
+	for (unsigned int i = 1; i <= TAYLOR_DEGREE_64; i++) {
+		num *= arg;
+		
+		if ((i % 2) == 0)
+			ret += num / i;
+		else
+			ret -= num / i;
+	}
+	
+	return ret;
+}
+
+/** Natural logarithm (32-bit floating point)
+ *
+ * @param arg Argument.
+ *
+ * @return Logarithm.
+ *
+ */
+float32_t float32_log(float32_t arg)
+{
+	float32_u m;
+	int e;
+	
+	m.val = arg;
+	/*
+	 * Factor arg into m * 2^e where m has exponent -1,
+	 * which means it is in [1.0000..e-1, 1.1111..e-1] = [0.5, 1.0]
+	 * so the argument to taylor_log_32 will be in [0, 0.5]
+	 * ensuring that we get at least one extra bit of precision
+	 * in each iteration.
+	 */
+	e = m.data.parts.exp - (FLOAT32_BIAS - 1);
+	m.data.parts.exp = FLOAT32_BIAS - 1;
+	
+	/*
+	 * arg = m * 2^e ; log(arg) = log(m) + log(2^e) =
+	 * log(m) + log2(2^e) / log2(e) = log(m) + e / log2(e)
+	 */
+	return - taylor_log_32(m.val - 1.0) + e / M_LOG2E;
+}
+
+/** Natural logarithm (64-bit floating point)
+ *
+ * @param arg Argument.
+ *
+ * @return Logarithm.
+ *
+ */
+float64_t float64_log(float64_t arg)
+{
+	float64_u m;
+	int e;
+	
+	m.val = arg;
+	
+	/*
+	 * Factor arg into m * 2^e where m has exponent -1,
+	 * which means it is in [1.0000..e-1, 1.1111..e-1] = [0.5, 1.0]
+	 * so the argument to taylor_log_32 will be in [0, 0.5]
+	 * ensuring that we get at least one extra bit of precision
+	 * in each iteration.
+	 */
+	e = m.data.parts.exp - (FLOAT64_BIAS - 1);
+	m.data.parts.exp = FLOAT64_BIAS - 1;
+	
+	/*
+	 * arg = m * 2^e ; log(arg) = log(m) + log(2^e) =
+	 * log(m) + log2(2^e) / log2(e) = log(m) + e / log2(e)
+	 */
+	return - taylor_log_64(m.val - 1.0) + e / M_LOG2E;
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/log10.c
===================================================================
--- uspace/lib/math/generic/log10.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/log10.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <log10.h>
+#include <math.h>
+
+/** Decimal logarithm (32-bit floating point)
+ *
+ * Compute logarithm value.
+ *
+ * @param arg Logarithm argument.
+ *
+ * @return Logarithm value.
+ *
+ */
+float32_t float32_log10(float32_t arg)
+{
+	return log_f32(arg) / M_LN10;
+}
+
+/** Decimal logarithm (64-bit floating point)
+ *
+ * Compute logarithm value.
+ *
+ * @param arg Logarithm argument.
+ *
+ * @return Logarithm value.
+ *
+ */
+float64_t float64_log10(float64_t arg)
+{
+	return log_f64(arg) / M_LN10;
+}
+
+
+/** @}
+ */
Index: pace/lib/math/generic/mod.c
===================================================================
--- uspace/lib/math/generic/mod.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ 	(revision )
@@ -1,64 +1,0 @@
-/*
- * Copyright (c) 2014 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.
- */
-
-/** @addtogroup libmath
- * @{
- */
-/** @file
- */
-
-#include <math.h>
-#include <mod.h>
-
-/** Double precision modulo
- *
- * Calculate the modulo of dividend by divisor.
- *
- * This is a very basic implementation that uses
- * division and multiplication (instead of exact
- * arithmetics). Thus the result might be very
- * imprecise (depending on the magnitude of the
- * arguments).
- *
- * @param dividend Dividend.
- * @param divisor  Divisor.
- *
- * @return Modulo.
- *
- */
-float64_t float64_mod(float64_t dividend, float64_t divisor)
-{
-	// FIXME: replace with exact arithmetics
-	
-	float64_t quotient = trunc(dividend / divisor);
-	
-	return (dividend - quotient * divisor);
-}
-
-/** @}
- */
Index: uspace/lib/math/generic/modf.c
===================================================================
--- uspace/lib/math/generic/modf.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/modf.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <math.h>
+#include <modf.h>
+
+/** Remainder function (32-bit floating point)
+ *
+ * Calculate the modulo of dividend by divisor.
+ *
+ * This is a very basic implementation that uses
+ * division and multiplication (instead of exact
+ * arithmetics). Thus the result might be very
+ * imprecise (depending on the magnitude of the
+ * arguments).
+ *
+ * @param dividend Dividend.
+ * @param divisor  Divisor.
+ *
+ * @return Modulo.
+ *
+ */
+float32_t float32_modf(float32_t value, float32_t *iptr)
+{
+	*iptr = trunc_f32(value);
+	return value - *iptr;
+}
+
+/** Remainder function (64-bit floating point)
+ *
+ * Calculate the modulo of dividend by divisor.
+ *
+ * This is a very basic implementation that uses
+ * division and multiplication (instead of exact
+ * arithmetics). Thus the result might be very
+ * imprecise (depending on the magnitude of the
+ * arguments).
+ *
+ * @param dividend Dividend.
+ * @param divisor  Divisor.
+ *
+ * @return Modulo.
+ *
+ */
+float64_t float64_modf(float64_t value, float64_t *iptr)
+{
+	*iptr = trunc_f64(value);
+	return value - *iptr;
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/pow.c
===================================================================
--- uspace/lib/math/generic/pow.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/pow.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2015 Jiri Svoboda
+ * Copyright (c) 2014 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <math.h>
+#include <pow.h>
+
+/** Single precision power
+ *
+ * Compute power value.
+ *
+ * @param x Base
+ * @param y Exponent
+ *
+ * @return Cosine value.
+ *
+ */
+float32_t float32_pow(float32_t x, float32_t y)
+{
+	/* x^y = (e ^ log(x))^y = e ^ (log(x) * y) */
+	return exp_f32(log_f32(x) * y);
+}
+
+/** Double precision power
+ *
+ * Compute power value.
+ *
+ * @param x Base
+ * @param y Exponent
+ *
+ * @return Cosine value.
+ *
+ */
+float64_t float64_pow(float64_t x, float64_t y)
+{
+	/* x^y = (e ^ log(x))^y = e ^ (log(x) * y) */
+	return exp_f64(log_f64(x) * y);
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/sinh.c
===================================================================
--- uspace/lib/math/generic/sinh.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/sinh.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <math.h>
+#include <sinh.h>
+
+/** Hyperbolic sine (32-bit floating point)
+ *
+ * Compute hyperbolic sine value.
+ *
+ * @param arg Hyperbolic angle
+ *
+ * @return Hyperbolic sine.
+ *
+ */
+float32_t float32_sinh(float32_t arg)
+{
+	return (exp_f32(arg) - exp_f32(-arg)) / 2.0;
+}
+
+/** Hyperbolic sine (64-bit floating point)
+ *
+ * Compute hyperbolic sine value.
+ *
+ * @param arg Hyperbolic angle
+ *
+ * @return Hyperbolic sine.
+ *
+ */
+float64_t float64_sinh(float64_t arg)
+{
+	return (exp_f64(arg) - exp_f64(-arg)) / 2.0;
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/sqrt.c
===================================================================
--- uspace/lib/math/generic/sqrt.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/sqrt.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <math.h>
+#include <sqrt.h>
+
+/** Single precision square root
+ *
+ * Compute square root.
+ *
+ * @param val Value
+ *
+ * @return Square root.
+ *
+ */
+float32_t float32_sqrt(float32_t val)
+{
+	return pow_f32(val, 0.5);
+}
+
+/** Double precision square root
+ *
+ * Compute squre root.
+ *
+ * @param val Value
+ *
+ * @return Square root.
+ *
+ */
+float64_t float64_sqrt(float64_t val)
+{
+	return pow_f64(val, 0.5);
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/tan.c
===================================================================
--- uspace/lib/math/generic/tan.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/tan.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <math.h>
+#include <tan.h>
+
+/** Tangent (32-bit floating point)
+ *
+ * Compute tangent value.
+ *
+ * @param arg Tangent argument.
+ *
+ * @return Tangent value.
+ *
+ */
+float32_t float32_tan(float32_t arg)
+{
+	return sin_f32(arg) / cos_f32(arg);
+}
+
+/** Sine (64-bit floating point)
+ *
+ * Compute sine value.
+ *
+ * @param arg Sine argument.
+ *
+ * @return Sine value.
+ *
+ */
+float64_t float64_tan(float64_t arg)
+{
+	return sin_f64(arg) / cos_f64(arg);
+}
+
+
+/** @}
+ */
Index: uspace/lib/math/generic/tanh.c
===================================================================
--- uspace/lib/math/generic/tanh.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/generic/tanh.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <math.h>
+#include <tanh.h>
+
+/** Hyperbolic tangent (32-bit floating point)
+ *
+ * Compute hyperbolic tangent value.
+ *
+ * @param arg Hyperbolic angle
+ *
+ * @return Hyperbolic tangent.
+ *
+ */
+float32_t float32_tanh(float32_t arg)
+{
+	float32_t em2x;
+
+	if (arg > 9.0)
+		return 1.0;
+	if (arg < -9.0)
+		return -1.0;
+
+	em2x = exp_f32(-2.0 * arg);
+	return (1.0 - em2x) / (1.0 + em2x);
+}
+
+/** Hyperbolic tangent (64-bit floating point)
+ *
+ * Compute hyperbolic tangent value.
+ *
+ * @param arg Hyperbolic angle
+ *
+ * @return Hyperbolic tangent.
+ *
+ */
+float64_t float64_tanh(float64_t arg)
+{
+	float64_t em2x;
+
+	if (arg > 19.0)
+		return 1.0;
+	if (arg < -19.0)
+		return -1.0;
+
+	em2x = exp_f64(-2.0 * arg);
+	return (1.0 - em2x) / (1.0 + em2x);
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/trig.c
===================================================================
--- uspace/lib/math/generic/trig.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/generic/trig.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,3 +1,4 @@
 /*
+ * Copyright (c) 2015 Jiri Svoboda
  * Copyright (c) 2014 Martin Decky
  * All rights reserved.
@@ -36,13 +37,16 @@
 #include <trig.h>
 
-#define TAYLOR_DEGREE  13
+#define TAYLOR_DEGREE_32 13
+#define TAYLOR_DEGREE_64 21
 
 /** Precomputed values for factorial (starting from 1!) */
-static float64_t factorials[TAYLOR_DEGREE] = {
+static float64_t factorials[TAYLOR_DEGREE_64] = {
 	1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800,
-	479001600, 6227020800
+	479001600, 6227020800.0L, 87178291200.0L, 1307674368000.0L,
+	20922789888000.0L, 355687428096000.0L, 6402373705728000.0L,
+	121645100408832000.0L, 2432902008176640000.0L, 51090942171709440000.0L
 };
 
-/** Sine approximation by Taylor series
+/** Sine approximation by Taylor series (32-bit floating point)
  *
  * Compute the approximation of sine by a Taylor
@@ -56,10 +60,10 @@
  *
  */
-static float64_t taylor_sin(float64_t arg)
-{
-	float64_t ret = 0;
-	float64_t nom = 1;
-	
-	for (unsigned int i = 0; i < TAYLOR_DEGREE; i++) {
+static float32_t taylor_sin_32(float32_t arg)
+{
+	float32_t ret = 0;
+	float32_t nom = 1;
+	
+	for (unsigned int i = 0; i < TAYLOR_DEGREE_32; i++) {
 		nom *= arg;
 		
@@ -73,5 +77,34 @@
 }
 
-/** Cosine approximation by Taylor series
+/** Sine approximation by Taylor series (64-bit floating point)
+ *
+ * Compute the approximation of sine by a Taylor
+ * series (using the first TAYLOR_DEGREE terms).
+ * The approximation is reasonably accurate for
+ * arguments within the interval [-pi/4, pi/4].
+ *
+ * @param arg Sine argument.
+ *
+ * @return Sine value approximation.
+ *
+ */
+static float64_t taylor_sin_64(float64_t arg)
+{
+	float64_t ret = 0;
+	float64_t nom = 1;
+	
+	for (unsigned int i = 0; i < TAYLOR_DEGREE_64; i++) {
+		nom *= arg;
+		
+		if ((i % 4) == 0)
+			ret += nom / factorials[i];
+		else if ((i % 4) == 2)
+			ret -= nom / factorials[i];
+	}
+	
+	return ret;
+}
+
+/** Cosine approximation by Taylor series (32-bit floating point)
  *
  * Compute the approximation of cosine by a Taylor
@@ -85,10 +118,10 @@
  *
  */
-static float64_t taylor_cos(float64_t arg)
-{
-	float64_t ret = 1;
-	float64_t nom = 1;
-	
-	for (unsigned int i = 0; i < TAYLOR_DEGREE; i++) {
+static float32_t taylor_cos_32(float32_t arg)
+{
+	float32_t ret = 1;
+	float32_t nom = 1;
+	
+	for (unsigned int i = 0; i < TAYLOR_DEGREE_32; i++) {
 		nom *= arg;
 		
@@ -102,5 +135,34 @@
 }
 
-/** Sine value for values within base period
+/** Cosine approximation by Taylor series (64-bit floating point)
+ *
+ * Compute the approximation of cosine by a Taylor
+ * series (using the first TAYLOR_DEGREE terms).
+ * The approximation is reasonably accurate for
+ * arguments within the interval [-pi/4, pi/4].
+ *
+ * @param arg Cosine argument.
+ *
+ * @return Cosine value approximation.
+ *
+ */
+static float64_t taylor_cos_64(float64_t arg)
+{
+	float64_t ret = 1;
+	float64_t nom = 1;
+	
+	for (unsigned int i = 0; i < TAYLOR_DEGREE_64; i++) {
+		nom *= arg;
+		
+		if ((i % 4) == 1)
+			ret -= nom / factorials[i];
+		else if ((i % 4) == 3)
+			ret += nom / factorials[i];
+	}
+	
+	return ret;
+}
+
+/** Sine value for values within base period (32-bit floating point)
  *
  * Compute the value of sine for arguments within
@@ -114,5 +176,5 @@
  *
  */
-static float64_t base_sin(float64_t arg)
+static float32_t base_sin_32(float32_t arg)
 {
 	unsigned int period = arg / (M_PI / 4);
@@ -120,20 +182,53 @@
 	switch (period) {
 	case 0:
-		return taylor_sin(arg);
+		return taylor_sin_32(arg);
 	case 1:
 	case 2:
-		return taylor_cos(arg - M_PI / 2);
+		return taylor_cos_32(arg - M_PI / 2);
 	case 3:
 	case 4:
-		return -taylor_sin(arg - M_PI);
+		return -taylor_sin_32(arg - M_PI);
 	case 5:
 	case 6:
-		return -taylor_cos(arg - 3 * M_PI / 2);
+		return -taylor_cos_32(arg - 3 * M_PI / 2);
 	default:
-		return taylor_sin(arg - 2 * M_PI);
-	}
-}
-
-/** Cosine value for values within base period
+		return taylor_sin_32(arg - 2 * M_PI);
+	}
+}
+
+/** Sine value for values within base period (64-bit floating point)
+ *
+ * Compute the value of sine for arguments within
+ * the base period [0, 2pi]. For arguments outside
+ * the base period the returned values can be
+ * very inaccurate or even completely wrong.
+ *
+ * @param arg Sine argument.
+ *
+ * @return Sine value.
+ *
+ */
+static float64_t base_sin_64(float64_t arg)
+{
+	unsigned int period = arg / (M_PI / 4);
+	
+	switch (period) {
+	case 0:
+		return taylor_sin_64(arg);
+	case 1:
+	case 2:
+		return taylor_cos_64(arg - M_PI / 2);
+	case 3:
+	case 4:
+		return -taylor_sin_64(arg - M_PI);
+	case 5:
+	case 6:
+		return -taylor_cos_64(arg - 3 * M_PI / 2);
+	default:
+		return taylor_sin_64(arg - 2 * M_PI);
+	}
+}
+
+/** Cosine value for values within base period (32-bit floating point)
  *
  * Compute the value of cosine for arguments within
@@ -147,5 +242,5 @@
  *
  */
-static float64_t base_cos(float64_t arg)
+static float32_t base_cos_32(float32_t arg)
 {
 	unsigned int period = arg / (M_PI / 4);
@@ -153,20 +248,53 @@
 	switch (period) {
 	case 0:
-		return taylor_cos(arg);
+		return taylor_cos_32(arg);
 	case 1:
 	case 2:
-		return -taylor_sin(arg - M_PI / 2);
+		return -taylor_sin_32(arg - M_PI / 2);
 	case 3:
 	case 4:
-		return -taylor_cos(arg - M_PI);
+		return -taylor_cos_32(arg - M_PI);
 	case 5:
 	case 6:
-		return taylor_sin(arg - 3 * M_PI / 2);
+		return taylor_sin_32(arg - 3 * M_PI / 2);
 	default:
-		return taylor_cos(arg - 2 * M_PI);
-	}
-}
-
-/** Double precision sine
+		return taylor_cos_32(arg - 2 * M_PI);
+	}
+}
+
+/** Cosine value for values within base period (64-bit floating point)
+ *
+ * Compute the value of cosine for arguments within
+ * the base period [0, 2pi]. For arguments outside
+ * the base period the returned values can be
+ * very inaccurate or even completely wrong.
+ *
+ * @param arg Cosine argument.
+ *
+ * @return Cosine value.
+ *
+ */
+static float64_t base_cos_64(float64_t arg)
+{
+	unsigned int period = arg / (M_PI / 4);
+	
+	switch (period) {
+	case 0:
+		return taylor_cos_64(arg);
+	case 1:
+	case 2:
+		return -taylor_sin_64(arg - M_PI / 2);
+	case 3:
+	case 4:
+		return -taylor_cos_64(arg - M_PI);
+	case 5:
+	case 6:
+		return taylor_sin_64(arg - 3 * M_PI / 2);
+	default:
+		return taylor_cos_64(arg - 2 * M_PI);
+	}
+}
+
+/** Sine (32-bit floating point)
  *
  * Compute sine value.
@@ -177,15 +305,34 @@
  *
  */
+float32_t float32_sin(float32_t arg)
+{
+	float32_t base_arg = fmod_f32(arg, 2 * M_PI);
+	
+	if (base_arg < 0)
+		return -base_sin_32(-base_arg);
+	
+	return base_sin_32(base_arg);
+}
+
+/** Sine (64-bit floating point)
+ *
+ * Compute sine value.
+ *
+ * @param arg Sine argument.
+ *
+ * @return Sine value.
+ *
+ */
 float64_t float64_sin(float64_t arg)
 {
-	float64_t base_arg = fmod(arg, 2 * M_PI);
+	float64_t base_arg = fmod_f64(arg, 2 * M_PI);
 	
 	if (base_arg < 0)
-		return -base_sin(-base_arg);
-	
-	return base_sin(base_arg);
-}
-
-/** Double precision cosine
+		return -base_sin_64(-base_arg);
+	
+	return base_sin_64(base_arg);
+}
+
+/** Cosine (32-bit floating point)
  *
  * Compute cosine value.
@@ -196,12 +343,31 @@
  *
  */
+float32_t float32_cos(float32_t arg)
+{
+	float32_t base_arg = fmod_f32(arg, 2 * M_PI);
+	
+	if (base_arg < 0)
+		return base_cos_32(-base_arg);
+	
+	return base_cos_32(base_arg);
+}
+
+/** Cosine (64-bit floating point)
+ *
+ * Compute cosine value.
+ *
+ * @param arg Cosine argument.
+ *
+ * @return Cosine value.
+ *
+ */
 float64_t float64_cos(float64_t arg)
 {
-	float64_t base_arg = fmod(arg, 2 * M_PI);
+	float64_t base_arg = fmod_f64(arg, 2 * M_PI);
 	
 	if (base_arg < 0)
-		return base_cos(-base_arg);
-	
-	return base_cos(base_arg);
+		return base_cos_64(-base_arg);
+	
+	return base_cos_64(base_arg);
 }
 
Index: uspace/lib/math/generic/trunc.c
===================================================================
--- uspace/lib/math/generic/trunc.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/generic/trunc.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,3 +1,4 @@
 /*
+ * Copyright (c) 2015 Jiri Svoboda
  * Copyright (c) 2014 Martin Decky
  * All rights reserved.
@@ -38,4 +39,46 @@
 /** Truncate fractional part (round towards zero)
  *
+ * Truncate the fractional part of IEEE 754 single
+ * precision floating point number by zeroing fraction
+ * bits, effectively rounding the number towards zero
+ * to the nearest whole number.
+ *
+ * If the argument is infinity or NaN, an exception
+ * should be indicated. This is not implemented yet.
+ *
+ * @param val Floating point number.
+ *
+ * @return Number rounded towards zero.
+ *
+ */
+float32_t float32_trunc(float32_t val)
+{
+	float32_u v;
+	int32_t exp;
+	
+	v.val = val;
+	exp = v.data.parts.exp - FLOAT32_BIAS;
+	
+	if (exp < 0) {
+		/* -1 < val < 1 => result is +0 or -0 */
+		v.data.parts.exp = 0;
+		v.data.parts.fraction = 0;
+	} else if (exp >= FLOAT32_FRACTION_SIZE) {
+		if (exp == 1024) {
+			/* val is +inf, -inf or NaN => trigger an exception */
+			// FIXME TODO
+		}
+		
+		/* All bits in val are relevant for the result */
+	} else {
+		/* Truncate irrelevant fraction bits */
+		v.data.parts.fraction &= ~(UINT32_C(0x007fffff) >> exp);
+	}
+	
+	return v.val;
+}
+
+/** Truncate fractional part (round towards zero)
+ *
  * Truncate the fractional part of IEEE 754 double
  * precision floating point number by zeroing fraction
@@ -51,12 +94,16 @@
  *
  */
-float64 trunc_float64(float64 val)
+float64_t float64_trunc(float64_t val)
 {
-	int32_t exp = val.parts.exp - FLOAT64_BIAS;
+	float64_u v;
+	int32_t exp;
+	
+	v.val = val;
+	exp = v.data.parts.exp - FLOAT64_BIAS;
 	
 	if (exp < 0) {
 		/* -1 < val < 1 => result is +0 or -0 */
-		val.parts.exp = 0;
-		val.parts.fraction = 0;
+		v.data.parts.exp = 0;
+		v.data.parts.fraction = 0;
 	} else if (exp >= FLOAT64_FRACTION_SIZE) {
 		if (exp == 1024) {
@@ -68,8 +115,8 @@
 	} else {
 		/* Truncate irrelevant fraction bits */
-		val.parts.fraction &= ~(UINT64_C(0x000fffffffffffff) >> exp);
+		v.data.parts.fraction &= ~(UINT64_C(0x000fffffffffffff) >> exp);
 	}
 	
-	return val;
+	return v.val;
 }
 
Index: uspace/lib/math/include/acos.h
===================================================================
--- uspace/lib/math/include/acos.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/acos.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_ACOS_H_
+#define LIBMATH_ACOS_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_acos(float32_t);
+extern float64_t float64_acos(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/asin.h
===================================================================
--- uspace/lib/math/include/asin.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/asin.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_ASIN_H_
+#define LIBMATH_ASIN_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_asin(float32_t);
+extern float64_t float64_asin(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/atan.h
===================================================================
--- uspace/lib/math/include/atan.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/atan.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_ATAN_H_
+#define LIBMATH_ATAN_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_atan(float32_t);
+extern float64_t float64_atan(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/atan2.h
===================================================================
--- uspace/lib/math/include/atan2.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/atan2.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_ATAN2_H_
+#define LIBMATH_ATAN2_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_atan2(float32_t, float32_t);
+extern float64_t float64_atan2(float64_t, float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/ceil.h
===================================================================
--- uspace/lib/math/include/ceil.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/ceil.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_CEIL_H_
+#define LIBMATH_CEIL_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_ceil(float32_t);
+extern float64_t float64_ceil(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/cosh.h
===================================================================
--- uspace/lib/math/include/cosh.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/cosh.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_COSH_H_
+#define LIBMATH_COSH_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_cosh(float32_t);
+extern float64_t float64_cosh(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/exp.h
===================================================================
--- uspace/lib/math/include/exp.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/exp.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_EXP_H_
+#define LIBMATH_EXP_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_exp(float32_t);
+extern float64_t float64_exp(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/fabs.h
===================================================================
--- uspace/lib/math/include/fabs.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/fabs.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_FABS_H_
+#define LIBMATH_FABS_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_fabs(float32_t);
+extern float64_t float64_fabs(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/floor.h
===================================================================
--- uspace/lib/math/include/floor.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/floor.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_FLOOR_H_
+#define LIBMATH_FLOOR_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_floor(float32_t);
+extern float64_t float64_floor(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/fmod.h
===================================================================
--- uspace/lib/math/include/fmod.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/fmod.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_FMOD_H_
+#define LIBMATH_FMOD_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_fmod(float32_t, float32_t);
+extern float64_t float64_fmod(float64_t, float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/frexp.h
===================================================================
--- uspace/lib/math/include/frexp.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/frexp.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_FREXP_H_
+#define LIBMATH_FREXP_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_frexp(float32_t, int *);
+extern float64_t float64_frexp(float64_t, int *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/ldexp.h
===================================================================
--- uspace/lib/math/include/ldexp.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/ldexp.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_LDEXP_H_
+#define LIBMATH_LDEXP_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_ldexp(float32_t, int);
+extern float64_t float64_ldexp(float64_t, int);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/log.h
===================================================================
--- uspace/lib/math/include/log.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/log.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_LOG_H_
+#define LIBMATH_LOG_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_log(float32_t);
+extern float64_t float64_log(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/log10.h
===================================================================
--- uspace/lib/math/include/log10.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/log10.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_LOG10_H_
+#define LIBMATH_LOG10_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_log10(float32_t);
+extern float64_t float64_log10(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/math.h
===================================================================
--- uspace/lib/math/include/math.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/include/math.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2011 Petr Koupy
+ * Copyright (c) 2015 Jiri Svoboda
  * All rights reserved.
  *
@@ -38,5 +39,9 @@
 #include <libarch/math.h>
 
-#define M_PI  3.14159265358979323846
+#define M_LN10 2.30258509299404568402
+#define M_LN2 0.69314718055994530942
+#define M_LOG2E 1.4426950408889634074
+#define M_PI 3.14159265358979323846
+#define M_PI_2 1.57079632679489661923
 
 #endif
Index: pace/lib/math/include/mod.h
===================================================================
--- uspace/lib/math/include/mod.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ 	(revision )
@@ -1,43 +1,0 @@
-/*
- * Copyright (c) 2014 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.
- */
-
-/** @addtogroup libmath
- * @{
- */
-/** @file
- */
-
-#ifndef LIBMATH_MOD_H_
-#define LIBMATH_MOD_H_
-
-extern float64_t float64_mod(float64_t, float64_t);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/math/include/modf.h
===================================================================
--- uspace/lib/math/include/modf.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/modf.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_MODF_H_
+#define LIBMATH_MODF_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_modf(float32_t, float32_t *);
+extern float64_t float64_modf(float64_t, float64_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/pow.h
===================================================================
--- uspace/lib/math/include/pow.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/pow.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_POW_H_
+#define LIBMATH_POW_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_pow(float32_t, float32_t);
+extern float64_t float64_pow(float64_t, float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/sinh.h
===================================================================
--- uspace/lib/math/include/sinh.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/sinh.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_SINH_H_
+#define LIBMATH_SINH_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_sinh(float32_t);
+extern float64_t float64_sinh(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/sqrt.h
===================================================================
--- uspace/lib/math/include/sqrt.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/sqrt.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_SQRT_H_
+#define LIBMATH_SQRT_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_sqrt(float32_t);
+extern float64_t float64_sqrt(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/tan.h
===================================================================
--- uspace/lib/math/include/tan.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/tan.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_TAN_H_
+#define LIBMATH_TAN_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_tan(float32_t);
+extern float64_t float64_tan(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/tanh.h
===================================================================
--- uspace/lib/math/include/tanh.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
+++ uspace/lib/math/include/tanh.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_TANH_H_
+#define LIBMATH_TANH_H_
+
+#include <mathtypes.h>
+
+extern float32_t float32_tanh(float32_t);
+extern float64_t float64_tanh(float64_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/trig.h
===================================================================
--- uspace/lib/math/include/trig.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/include/trig.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,5 +36,9 @@
 #define LIBMATH_TRIG_H_
 
+#include <mathtypes.h>
+
+extern float32_t float32_sin(float32_t);
 extern float64_t float64_sin(float64_t);
+extern float32_t float32_cos(float32_t);
 extern float64_t float64_cos(float64_t);
 
Index: uspace/lib/math/include/trunc.h
===================================================================
--- uspace/lib/math/include/trunc.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/math/include/trunc.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -38,5 +38,6 @@
 #include <mathtypes.h>
 
-extern float64 trunc_float64(float64);
+extern float32_t float32_trunc(float32_t);
+extern float64_t float64_trunc(float64_t);
 
 #endif
Index: uspace/lib/mbr/libmbr.c
===================================================================
--- uspace/lib/mbr/libmbr.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/mbr/libmbr.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -109,5 +109,5 @@
 	}
 	
-	int rc = block_init(EXCHANGE_ATOMIC, dev_handle, 512);
+	int rc = block_init(dev_handle, 512);
 	if (rc != EOK)
 		return rc;
@@ -133,5 +133,5 @@
 int mbr_write_mbr(mbr_label_t *label, service_id_t dev_handle)
 {
-	int rc = block_init(EXCHANGE_ATOMIC, dev_handle, 512);
+	int rc = block_init(dev_handle, 512);
 	if (rc != EOK)
 		return rc;
@@ -227,5 +227,5 @@
 		label->mbr = mbr_alloc_mbr();
 	
-	int rc = block_init(EXCHANGE_ATOMIC, dev_handle, 512);
+	int rc = block_init(dev_handle, 512);
 	if (rc != EOK)
 		return rc;
@@ -413,5 +413,5 @@
 mbr_err_val mbr_add_partition(mbr_label_t *label, mbr_part_t *part)
 {
-	int rc = block_init(EXCHANGE_ATOMIC, label->device, 512);
+	int rc = block_init(label->device, 512);
 	if ((rc != EOK) && (rc != EEXIST))
 		return ERR_LIBBLOCK;
@@ -622,5 +622,5 @@
 	uint32_t addr = base;
 	
-	int rc = block_init(EXCHANGE_ATOMIC, label->device, 512);
+	int rc = block_init(label->device, 512);
 	if (rc != EOK)
 		goto end;
Index: uspace/lib/nettl/src/amap.c
===================================================================
--- uspace/lib/nettl/src/amap.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/nettl/src/amap.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,4 +36,16 @@
  * Manages allocations of endpoints / endpoint pairs (corresponding to
  * UDP associations, TCP listeners and TCP connections)
+ *
+ * An association map contains different types of entries, based on which
+ * set of attributes (key) they specify. In order from most specific to the
+ * least specific one:
+ *
+ *  - repla (remote endpoint, local address)
+ *  - laddr (local address)
+ *  - llink (local link)
+ *  - unspec (unspecified)
+ *
+ * In the unspecified case only the local port is known and the entry matches
+ * all remote and local addresses.
  */
 
@@ -47,4 +59,9 @@
 #include <stdlib.h>
 
+/** Create association map.
+ *
+ * @param rmap Place to store pointer to new association map
+ * @return EOk on success, ENOMEM if out of memory
+ */
 int amap_create(amap_t **rmap)
 {
@@ -73,4 +90,8 @@
 }
 
+/** Destroy association map.
+ *
+ * @param map Association map
+ */
 void amap_destroy(amap_t *map)
 {
@@ -79,5 +100,15 @@
 }
 
-/** Find exact repla */
+/** Find exact repla.
+ *
+ * Find repla (remote endpoint, local address) entry by exact match.
+ *
+ * @param map Association map
+ * @param rep Remote endpoint
+ * @param la  Local address
+ * @param rrepla Place to store pointer to repla
+ *
+ * @return EOK on success, ENOENT if not found
+ */
 static int amap_repla_find(amap_t *map, inet_ep_t *rep, inet_addr_t *la,
     amap_repla_t **rrepla)
@@ -113,4 +144,15 @@
 }
 
+/** Insert repla.
+ *
+ * Insert new repla (remote endpoint, local address) entry to association map.
+ *
+ * @param amap   Association map
+ * @param rep    Remote endpoint
+ * @param la     Local address
+ * @param rrepla Place to store pointer to new repla
+ *
+ * @return EOK on success, ENOMEM if out of memory
+ */
 static int amap_repla_insert(amap_t *map, inet_ep_t *rep, inet_addr_t *la,
     amap_repla_t **rrepla)
@@ -139,4 +181,11 @@
 }
 
+/** Remove repla from association map.
+ *
+ * Remove repla (remote endpoint, local address) from association map.
+ *
+ * @param map   Association map
+ * @param repla Repla
+ */
 static void amap_repla_remove(amap_t *map, amap_repla_t *repla)
 {
@@ -146,5 +195,14 @@
 }
 
-/** Find exact laddr */
+/** Find exact laddr.
+ *
+ * Find laddr (local address) entry by exact match.
+ *
+ * @param map    Association map
+ * @param addr   Address
+ * @param rladdr Place to store pointer to laddr entry
+ *
+ * @return EOK on success, ENOENT if not found.
+ */
 static int amap_laddr_find(amap_t *map, inet_addr_t *addr,
     amap_laddr_t **rladdr)
@@ -161,4 +219,13 @@
 }
 
+/** Insert laddr.
+ *
+ * Insert new laddr (local address) entry to association map.
+ *
+ * @param addr   Local address
+ * @param rladdr Place to store pointer to new laddr
+ *
+ * @return EOK on success, ENOMEM if out of memory
+ */
 static int amap_laddr_insert(amap_t *map, inet_addr_t *addr,
     amap_laddr_t **rladdr)
@@ -186,4 +253,11 @@
 }
 
+/** Remove laddr from association map.
+ *
+ * Remove laddr (local address) entry from association map.
+ *
+ * @param map   Association map
+ * @param laddr Laddr entry
+ */
 static void amap_laddr_remove(amap_t *map, amap_laddr_t *laddr)
 {
@@ -193,5 +267,14 @@
 }
 
-/** Find exact llink */
+/** Find exact llink.
+ *
+ * Find llink (local link) entry by exact match.
+ *
+ * @param map     Association map
+ * @param link_id Local link ID
+ * @param rllink  Place to store pointer to llink entry
+ *
+ * @return EOK on success, ENOENT if not found.
+ */
 static int amap_llink_find(amap_t *map, sysarg_t link_id,
     amap_llink_t **rllink)
@@ -208,4 +291,13 @@
 }
 
+/** Insert llink.
+ *
+ * Insert new llink (local link) entry to association map.
+ *
+ * @param link_id Local link
+ * @param rllink  Place to store pointer to new llink
+ *
+ * @return EOK on success, ENOMEM if out of memory
+ */
 static int amap_llink_insert(amap_t *map, sysarg_t link_id,
     amap_llink_t **rllink)
@@ -233,4 +325,11 @@
 }
 
+/** Remove llink from association map.
+ *
+ * Remove llink (local link) entry from association map.
+ *
+ * @param map   Association map
+ * @param llink Llink entry
+ */
 static void amap_llink_remove(amap_t *map, amap_llink_t *llink)
 {
@@ -240,4 +339,17 @@
 }
 
+/** Insert endpoint pair into map with repla as key.
+ *
+ * If local port number is not specified, it is allocated.
+ *
+ * @param map Association map
+ * @param epp Endpoint pair, possibly with local port inet_port_any
+ * @param arg arg User value
+ * @param flags Flags
+ * @param aepp Place to store actual endpoint pair, possibly with allocated port
+ *
+ * @return EOK on success, EEXIST if conflicting epp exists,
+ *         ENOMEM if out of memory
+ */
 static int amap_insert_repla(amap_t *map, inet_ep2_t *epp, void *arg,
     amap_flags_t flags, inet_ep2_t *aepp)
@@ -272,4 +384,17 @@
 }
 
+/** Insert endpoint pair into map with laddr as key.
+ *
+ * If local port number is not specified, it is allocated.
+ *
+ * @param map Association map
+ * @param epp Endpoint pair, possibly with local port inet_port_any
+ * @param arg arg User value
+ * @param flags Flags
+ * @param aepp Place to store actual endpoint pair, possibly with allocated port
+ *
+ * @return EOK on success, EEXIST if conflicting epp exists,
+ *         ENOMEM if out of memory
+ */
 static int amap_insert_laddr(amap_t *map, inet_ep2_t *epp, void *arg,
     amap_flags_t flags, inet_ep2_t *aepp)
@@ -303,4 +428,17 @@
 }
 
+/** Insert endpoint pair into map with llink as key.
+ *
+ * If local port number is not specified, it is allocated.
+ *
+ * @param map Association map
+ * @param epp Endpoint pair, possibly with local port inet_port_any
+ * @param arg arg User value
+ * @param flags Flags
+ * @param aepp Place to store actual endpoint pair, possibly with allocated port
+ *
+ * @return EOK on success, EEXIST if conflicting epp exists,
+ *         ENOMEM if out of memory
+ */
 static int amap_insert_llink(amap_t *map, inet_ep2_t *epp, void *arg,
     amap_flags_t flags, inet_ep2_t *aepp)
@@ -334,27 +472,7 @@
 }
 
-static int amap_insert_unspec(amap_t *map, inet_ep2_t *epp, void *arg,
-    amap_flags_t flags, inet_ep2_t *aepp)
-{
-	inet_ep2_t mepp;
-	int rc;
-
-	log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_insert_unspec()");
-	mepp = *epp;
-
-	rc = portrng_alloc(map->unspec, epp->local.port, arg, flags,
-	    &mepp.local.port);
-	if (rc != EOK) {
-		return rc;
-	}
-
-	*aepp = mepp;
-	return EOK;
-}
-
-/** Insert endpoint pair into map.
- *
- * If local endpoint is not fully specified, it is filled in (determine
- * source address, allocate port number). Checks for conflicting endpoint pair.
+/** Insert endpoint pair into map with unspec as key.
+ *
+ * If local port number is not specified, it is allocated.
  *
  * @param map Association map
@@ -364,5 +482,38 @@
  * @param aepp Place to store actual endpoint pair, possibly with allocated port
  *
- * @return EOK on success, EEXISTS if conflicting epp exists,
+ * @return EOK on success, EEXIST if conflicting epp exists,
+ *         ENOMEM if out of memory
+ */
+static int amap_insert_unspec(amap_t *map, inet_ep2_t *epp, void *arg,
+    amap_flags_t flags, inet_ep2_t *aepp)
+{
+	inet_ep2_t mepp;
+	int rc;
+
+	log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_insert_unspec()");
+	mepp = *epp;
+
+	rc = portrng_alloc(map->unspec, epp->local.port, arg, flags,
+	    &mepp.local.port);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	*aepp = mepp;
+	return EOK;
+}
+
+/** Insert endpoint pair into map.
+ *
+ * If local endpoint is not fully specified, it is filled in (determine
+ * source address, allocate port number). Checks for conflicting endpoint pair.
+ *
+ * @param map Association map
+ * @param epp Endpoint pair, possibly with local port inet_port_any
+ * @param arg arg User value
+ * @param flags Flags
+ * @param aepp Place to store actual endpoint pair, possibly with allocated port
+ *
+ * @return EOK on success, EEXIST if conflicting epp exists,
  *         ENOMEM if out of memory
  */
@@ -417,4 +568,12 @@
 }
 
+/** Remove endpoint pair using repla as key from map.
+ *
+ * The endpoint pair must be present in the map, otherwise behavior
+ * is unspecified.
+ *
+ * @param map Association map
+ * @param epp Endpoint pair
+ */
 static void amap_remove_repla(amap_t *map, inet_ep2_t *epp)
 {
@@ -434,4 +593,12 @@
 }
 
+/** Remove endpoint pair using laddr as key from map.
+ *
+ * The endpoint pair must be present in the map, otherwise behavior
+ * is unspecified.
+ *
+ * @param map Association map
+ * @param epp Endpoint pair
+ */
 static void amap_remove_laddr(amap_t *map, inet_ep2_t *epp)
 {
@@ -451,4 +618,12 @@
 }
 
+/** Remove endpoint pair using llink as key from map.
+ *
+ * The endpoint pair must be present in the map, otherwise behavior
+ * is unspecified.
+ *
+ * @param map Association map
+ * @param epp Endpoint pair
+ */
 static void amap_remove_llink(amap_t *map, inet_ep2_t *epp)
 {
@@ -468,4 +643,12 @@
 }
 
+/** Remove endpoint pair using unspec as key from map.
+ *
+ * The endpoint pair must be present in the map, otherwise behavior
+ * is unspecified.
+ *
+ * @param map Association map
+ * @param epp Endpoint pair
+ */
 static void amap_remove_unspec(amap_t *map, inet_ep2_t *epp)
 {
@@ -473,4 +656,12 @@
 }
 
+/** Remove endpoint pair from map.
+ *
+ * The endpoint pair must be present in the map, otherwise behavior
+ * is unspecified.
+ *
+ * @param map Association map
+ * @param epp Endpoint pair
+ */
 void amap_remove(amap_t *map, inet_ep2_t *epp)
 {
Index: uspace/lib/nettl/src/portrng.c
===================================================================
--- uspace/lib/nettl/src/portrng.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/nettl/src/portrng.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -46,4 +46,9 @@
 #include <io/log.h>
 
+/** Create port range.
+ *
+ * @param rpr Place to store pointer to new port range
+ * @return EOK on success, ENOMEM if out of memory
+ */
 int portrng_create(portrng_t **rpr)
 {
@@ -62,4 +67,8 @@
 }
 
+/** Destroy port range.
+ *
+ * @param pr Port range
+ */
 void portrng_destroy(portrng_t *pr)
 {
@@ -69,4 +78,19 @@
 }
 
+/** Allocate port number from port range.
+ *
+ * @param pr    Port range
+ * @param pnum  Port number to allocate specific port, or zero to allocate
+ *              any valid port from range
+ * @param arg   User argument to set for port
+ * @param flags Flags, @c pf_allow_system to allow ports from system range
+ *              to be specified by @a pnum.
+ * @param apnum Place to store allocated port number
+ *
+ * @return EOK on success, ENOENT if no free port number found, EEXIST
+ *         if @a pnum is specified but it is already allocated,
+ *         EINVAL if @a pnum is specified from the system range, but
+ *         @c pf_allow_system was not set.
+ */
 int portrng_alloc(portrng_t *pr, uint16_t pnum, void *arg,
     portrng_flags_t flags, uint16_t *apnum)
@@ -113,5 +137,5 @@
 			if (port->pn == pnum) {
 				log_msg(LOG_DEFAULT, LVL_DEBUG2, "port already used");
-				return EEXISTS;
+				return EEXIST;
 			}
 		}
@@ -131,4 +155,12 @@
 }
 
+/** Find allocated port number and return its argument.
+ *
+ * @param pr   Port range
+ * @param pnum Port number
+ * @param rarg Place to store user argument
+ *
+ * @return EOK on success, ENOENT if specified port number is not allocated
+ */
 int portrng_find_port(portrng_t *pr, uint16_t pnum, void **rarg)
 {
@@ -143,4 +175,9 @@
 }
 
+/** Free port in port range.
+ *
+ * @param pr   Port range
+ * @param pnum Port number
+ */
 void portrng_free_port(portrng_t *pr, uint16_t pnum)
 {
@@ -158,4 +195,9 @@
 }
 
+/** Determine if port range is empty.
+ *
+ * @param pr Port range
+ * @return @c true if no ports are allocated from @a pr, @c false otherwise
+ */
 bool portrng_empty(portrng_t *pr)
 {
Index: uspace/lib/nic/src/nic_driver.c
===================================================================
--- uspace/lib/nic/src/nic_driver.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/nic/src/nic_driver.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -249,5 +249,5 @@
 	
 	/* Connect to the parent's driver. */
-	parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
+	parent_sess = ddf_dev_parent_sess_create(dev);
 	if (parent_sess == NULL)
 		return EPARTY;
Index: uspace/lib/pcut/src/os/helenos.c
===================================================================
--- uspace/lib/pcut/src/os/helenos.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/pcut/src/os/helenos.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -220,5 +220,5 @@
 	fibril_mutex_unlock(&forced_termination_mutex);
 
-	read_all(tempfile, extra_output_buffer, OUTPUT_BUFFER_SIZE);
+	read(tempfile, extra_output_buffer, OUTPUT_BUFFER_SIZE);
 
 leave_close_tempfile:
Index: uspace/lib/posix/include/posix/inttypes.h
===================================================================
--- uspace/lib/posix/include/posix/inttypes.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/posix/include/posix/inttypes.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -43,7 +43,7 @@
 #include "libc/inttypes.h"
 
-extern __POSIX_DEF__(intmax_t) __POSIX_DEF__(strtoimax)(const char *restrict nptr,
+extern intmax_t __POSIX_DEF__(strtoimax)(const char *restrict nptr,
     char **restrict endptr, int base);
-extern __POSIX_DEF__(uintmax_t) __POSIX_DEF__(strtoumax)(const char *restrict nptr,
+extern uintmax_t __POSIX_DEF__(strtoumax)(const char *restrict nptr,
     char **restrict endptr, int base);
 
Index: uspace/lib/posix/include/posix/stddef.h
===================================================================
--- uspace/lib/posix/include/posix/stddef.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/posix/include/posix/stddef.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -48,7 +48,4 @@
 #define offsetof(type,member) ((size_t) &(((type *) 0)->member))
 
-typedef ssize_t __POSIX_DEF__(ptrdiff_t);
-
-
 #endif /* POSIX_STDDEF_H_ */
 
Index: uspace/lib/posix/include/posix/stdint.h
===================================================================
--- uspace/lib/posix/include/posix/stdint.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/posix/include/posix/stdint.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -104,12 +104,10 @@
 #include "libc/sys/types.h"
 
-typedef int64_t __POSIX_DEF__(intmax_t);
-typedef uint64_t __POSIX_DEF__(uintmax_t);
-
-
 /*
  * Fast* and least* integer types.
  *
- * The definitions below are definitely safe if not the best.
+ * The definitions below are correct as long as uint8/16/32/64_t are defined.
+ * Considering the entire rest of the system would break down if they were not,
+ * these definitions are just fine.
  */
 typedef uint8_t uint_least8_t;
Index: uspace/lib/posix/source/fcntl.c
===================================================================
--- uspace/lib/posix/source/fcntl.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/posix/source/fcntl.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -112,11 +112,5 @@
 	}
 
-	int rc = open(pathname, flags, mode);
-	if (rc < 0) {
-		errno = -rc;
-		rc = -1;
-	}
-
-	return rc;
+	return negerrno(open, pathname, flags, mode);
 }
 
Index: uspace/lib/posix/source/internal/common.h
===================================================================
--- uspace/lib/posix/source/internal/common.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/posix/source/internal/common.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -48,10 +48,9 @@
 	} while (0)
 
-/* A little helper macro to avoid typing this over and over. */
-#define errnify(func, ...) ({ \
+/* Convert negative errno to positive errno */
+#define negerrno(func, ...) ({ \
 	int rc = func(__VA_ARGS__); \
 	if (rc < 0) { \
-		errno = -rc; \
-		rc = -1; \
+		errno = -errno; \
 	} \
 	rc; \
Index: uspace/lib/posix/source/stdio.c
===================================================================
--- uspace/lib/posix/source/stdio.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/posix/source/stdio.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -55,10 +55,4 @@
 #include "libc/sys/stat.h"
 
-
-/* not the best of solutions, but freopen and ungetc will eventually
- * need to be implemented in libc anyway
- */
-#include "../../c/generic/private/stdio.h"
-
 /** Clears the stream's error and end-of-file indicators.
  *
@@ -67,6 +61,5 @@
 void posix_clearerr(FILE *stream)
 {
-	stream->error = 0;
-	stream->eof = 0;
+	clearerr(stream);
 }
 
@@ -101,10 +94,5 @@
 int posix_fputs(const char *restrict s, FILE *restrict stream)
 {
-	int rc = fputs(s, stream);
-	if (rc == 0) {
-		return EOF;
-	} else {
-		return 0;
-	}
+	return fputs(s, stream);
 }
 
@@ -118,33 +106,5 @@
 int posix_ungetc(int c, FILE *stream)
 {
-	uint8_t b = (uint8_t) c;
-
-	bool can_unget =
-	    /* Provided character is legal. */
-	    c != EOF &&
-	    /* Stream is consistent. */
-	    !stream->error &&
-	    /* Stream is buffered. */
-	    stream->btype != _IONBF &&
-	    /* Last operation on the stream was a read operation. */
-	    stream->buf_state == _bs_read &&
-	    /* Stream buffer is already allocated (i.e. there was already carried
-	     * out either write or read operation on the stream). This is probably
-	     * redundant check but let's be safe. */
-	    stream->buf != NULL &&
-	    /* There is still space in the stream to retreat. POSIX demands the
-	     * possibility to unget at least 1 character. It should be always
-	     * possible, assuming the last operation on the stream read at least 1
-	     * character, because the buffer is refilled in the lazily manner. */
-	    stream->buf_tail > stream->buf;
-
-	if (can_unget) {
-		--stream->buf_tail;
-		stream->buf_tail[0] = b;
-		stream->eof = false;
-		return (int) b;
-	} else {
-		return EOF;
-	}
+	return ungetc(c, stream);
 }
 
@@ -254,43 +214,5 @@
     const char *restrict mode, FILE *restrict stream)
 {
-	assert(mode != NULL);
-	assert(stream != NULL);
-	
-	if (filename == NULL) {
-		/* POSIX allows this to be imlementation-defined. HelenOS currently
-		 * does not support changing the mode. */
-		// FIXME: handle mode change once it is supported
-		return stream;
-	}
-	
-	/* Open a new stream. */
-	FILE* new = fopen(filename, mode);
-	if (new == NULL) {
-		fclose(stream);
-		/* errno was set by fopen() */
-		return NULL;
-	}
-	
-	/* Close the original stream without freeing it (ignoring errors). */
-	if (stream->buf != NULL) {
-		fflush(stream);
-	}
-	if (stream->sess != NULL) {
-		async_hangup(stream->sess);
-	}
-	if (stream->fd >= 0) {
-		close(stream->fd);
-	}
-	list_remove(&stream->link);
-	
-	/* Move the new stream to the original location. */
-	memcpy(stream, new, sizeof (FILE));
-	free(new);
-	
-	/* Update references in the file list. */
-	stream->link.next->prev = &stream->link;
-	stream->link.prev->next = &stream->link;
-	
-	return stream;
+	return freopen(filename, mode, stream);
 }
 
@@ -393,11 +315,5 @@
 int posix_fflush(FILE *stream)
 {
-	int rc = fflush(stream);
-	if (rc < 0) {
-		errno = -rc;
-		return EOF;
-	} else {
-		return 0;
-	}
+	return negerrno(fflush, stream);
 }
 
@@ -429,4 +345,6 @@
 {
 	ssize_t wr = write(*(int *) fd, str, size);
+	if (wr < 0)
+		return errno;
 	return str_nlength(str, wr);
 }
@@ -657,23 +575,5 @@
 int posix_remove(const char *path)
 {
-	struct stat st;
-	int rc = stat(path, &st);
-	
-	if (rc != EOK) {
-		errno = -rc;
-		return -1;
-	}
-	
-	if (st.is_directory) {
-		rc = rmdir(path);
-	} else {
-		rc = unlink(path);
-	}
-	
-	if (rc != EOK) {
-		errno = -rc;
-		return -1;
-	}
-	return 0;
+	return negerrno(remove, path);
 }
 
@@ -687,5 +587,5 @@
 int posix_rename(const char *old, const char *new)
 {
-	return errnify(rename, old, new);
+	return negerrno(rename, old, new);
 }
 
Index: uspace/lib/posix/source/stdio/scanf.c
===================================================================
--- uspace/lib/posix/source/stdio/scanf.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/posix/source/stdio/scanf.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -698,6 +698,6 @@
 							break;
 						case LMOD_j: ;
-							posix_uintmax_t *pj = va_arg(arg, posix_uintmax_t *);
-							*pj = (posix_uintmax_t) ures;
+							uintmax_t *pj = va_arg(arg, uintmax_t *);
+							*pj = (uintmax_t) ures;
 							break;
 						case LMOD_z: ;
@@ -740,6 +740,6 @@
 							break;
 						case LMOD_j: ;
-							posix_intmax_t *pj = va_arg(arg, posix_intmax_t *);
-							*pj = (posix_intmax_t) sres;
+							intmax_t *pj = va_arg(arg, intmax_t *);
+							*pj = (intmax_t) sres;
 							break;
 						case LMOD_z: ;
@@ -748,6 +748,6 @@
 							break;
 						case LMOD_t: ;
-							posix_ptrdiff_t *pt = va_arg(arg, posix_ptrdiff_t *);
-							*pt = (posix_ptrdiff_t) sres;
+							ptrdiff_t *pt = va_arg(arg, ptrdiff_t *);
+							*pt = (ptrdiff_t) sres;
 							break;
 						default:
Index: uspace/lib/posix/source/stdlib.c
===================================================================
--- uspace/lib/posix/source/stdlib.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/posix/source/stdlib.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -278,5 +278,5 @@
 	 * to be updated when that support is implemented.
 	 */
-	char* absolute = absolutize(name, NULL);
+	char* absolute = vfs_absolutize(name, NULL);
 	
 	if (absolute == NULL) {
Index: uspace/lib/posix/source/stdlib/strtol.c
===================================================================
--- uspace/lib/posix/source/stdlib/strtol.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/posix/source/stdlib/strtol.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -43,7 +43,4 @@
 #include "posix/inttypes.h"
 #include "posix/limits.h"
-
-#define intmax_t posix_intmax_t
-#define uintmax_t posix_uintmax_t
 
 /**
Index: uspace/lib/posix/source/sys/stat.c
===================================================================
--- uspace/lib/posix/source/sys/stat.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/posix/source/sys/stat.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -80,10 +80,7 @@
 {
 	struct stat hst;
-	int rc = fstat(fd, &hst);
-	if (rc < 0) {
-		/* fstat() returns negative error code instead of using errno. */
-		errno = -rc;
-		return -1;
-	}
+	int rc = negerrno(fstat, fd, &hst);
+	if (rc < 0)
+		return rc;
 	stat_to_posix(st, &hst);
 	return 0;
@@ -113,10 +110,7 @@
 {
 	struct stat hst;
-	int rc = stat(path, &hst);
-	if (rc < 0) {
-		/* stat() returns negative error code instead of using errno. */
-		errno = -rc;
-		return -1;
-	}
+	int rc = negerrno(stat, path, &hst);
+	if (rc < 0)
+		return rc;
 	stat_to_posix(st, &hst);
 	return 0;
Index: uspace/lib/posix/source/unistd.c
===================================================================
--- uspace/lib/posix/source/unistd.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/posix/source/unistd.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -105,31 +105,12 @@
 char *posix_getcwd(char *buf, size_t size)
 {
-	/* Native getcwd() does not set any errno despite the fact that general
-	 * usage pattern of this function depends on it (caller is repeatedly
-	 * guessing the required size of the buffer by checking for ERANGE on
-	 * failure). */
-	if (size == 0) {
-		errno = EINVAL;
+	char *p = getcwd(buf, size);
+
+	if (p == NULL) {
+		errno = -errno;
 		return NULL;
 	}
-	
-	/* Save the original value to comply with the "no modification on
-	 * success" semantics.
-	 */
-	int orig_errno = errno;
-	errno = EOK;
-	
-	char *ret = getcwd(buf, size);
-	if (ret == NULL) {
-		/* Check errno to avoid shadowing other possible errors. */
-		if (errno == EOK) {
-			errno = ERANGE;
-		}
-	} else {
-		/* Success, restore previous errno value. */
-		errno = orig_errno;
-	}
-	
-	return ret;
+
+	return p;
 }
 
@@ -141,5 +122,5 @@
 int posix_chdir(const char *path)
 {
-	return errnify(chdir, path);
+	return negerrno(chdir, path);
 }
 
@@ -194,5 +175,5 @@
 int posix_close(int fildes)
 {
-	return errnify(close, fildes);
+	return negerrno(close, fildes);
 }
 
@@ -207,5 +188,5 @@
 ssize_t posix_read(int fildes, void *buf, size_t nbyte)
 {
-	return errnify(read, fildes, buf, nbyte);
+	return negerrno(read, fildes, buf, nbyte);
 }
 
@@ -220,5 +201,5 @@
 ssize_t posix_write(int fildes, const void *buf, size_t nbyte)
 {
-	return errnify(write, fildes, buf, nbyte);
+	return negerrno(write, fildes, buf, nbyte);
 }
 
@@ -234,5 +215,5 @@
 posix_off_t posix_lseek(int fildes, posix_off_t offset, int whence)
 {
-	return errnify(lseek, fildes, offset, whence);
+	return negerrno(lseek, fildes, offset, whence);
 }
 
@@ -245,5 +226,5 @@
 int posix_fsync(int fildes)
 {
-	return errnify(fsync, fildes);
+	return negerrno(fsync, fildes);
 }
 
@@ -257,5 +238,5 @@
 int posix_ftruncate(int fildes, posix_off_t length)
 {
-	return errnify(ftruncate, fildes, (aoff64_t) length);
+	return negerrno(ftruncate, fildes, (aoff64_t) length);
 }
 
@@ -268,5 +249,5 @@
 int posix_rmdir(const char *path)
 {
-	return errnify(rmdir, path);
+	return negerrno(rmdir, path);
 }
 
@@ -279,5 +260,5 @@
 int posix_unlink(const char *path)
 {
-	return errnify(unlink, path);
+	return negerrno(unlink, path);
 }
 
@@ -303,5 +284,5 @@
 int posix_dup2(int fildes, int fildes2)
 {
-	return errnify(dup2, fildes, fildes2);
+	return negerrno(dup2, fildes, fildes2);
 }
 
@@ -321,7 +302,7 @@
 		 * Check file existence by attempting to open it.
 		 */
-		int fd = open(path, O_RDONLY);
+		int fd = negerrno(open, path, O_RDONLY);
 		if (fd < 0) {
-			errno = -fd;
+			/* errno was set by open() */
 			return -1;
 		}
Index: uspace/lib/usb/src/dev.c
===================================================================
--- uspace/lib/usb/src/dev.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/usb/src/dev.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -50,6 +50,5 @@
 {
 	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_ATOMIC, device_handle,
-	        IPC_FLAG_BLOCKING);
+	    devman_parent_device_connect(device_handle, IPC_FLAG_BLOCKING);
 	if (!parent_sess)
 		return ENOMEM;
Index: uspace/lib/usb/src/hc.c
===================================================================
--- uspace/lib/usb/src/hc.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/usb/src/hc.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -51,6 +51,5 @@
 		assert(connection->hc_sess == NULL);
 		/* Parallel exchange for us */
-		connection->hc_sess = devman_device_connect(EXCHANGE_PARALLEL,
-		        connection->hc_handle, 0);
+		connection->hc_sess = devman_device_connect(connection->hc_handle, 0);
 		if (!connection->hc_sess) {
 			fibril_mutex_unlock(&connection->guard);
Index: uspace/lib/usbdev/src/pipesinit.c
===================================================================
--- uspace/lib/usbdev/src/pipesinit.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/usbdev/src/pipesinit.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -190,5 +190,5 @@
 
 	if (ep_mapping->present) {
-		return EEXISTS;
+		return EEXIST;
 	}
 
Index: uspace/lib/usbhost/src/usb_device_manager.c
===================================================================
--- uspace/lib/usbhost/src/usb_device_manager.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/usbhost/src/usb_device_manager.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -150,5 +150,5 @@
 	if (instance->devices[address].handle != 0) {
 		fibril_mutex_unlock(&instance->guard);
-		return EEXISTS;
+		return EEXIST;
 	}
 	instance->devices[address].handle = handle;
Index: uspace/lib/usbhost/src/usb_endpoint_manager.c
===================================================================
--- uspace/lib/usbhost/src/usb_endpoint_manager.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/usbhost/src/usb_endpoint_manager.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -253,5 +253,5 @@
 	if (endpoint != NULL) {
 		fibril_mutex_unlock(&instance->guard);
-		return EEXISTS;
+		return EEXIST;
 	}
 	list_append(&ep->link, get_list(instance, ep->address));
@@ -339,5 +339,5 @@
 	if (ep != NULL) {
 		fibril_mutex_unlock(&instance->guard);
-		return EEXISTS;
+		return EEXIST;
 	}
 
Index: uspace/lib/usbvirt/src/device.c
===================================================================
--- uspace/lib/usbvirt/src/device.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/lib/usbvirt/src/device.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -93,5 +93,5 @@
 	
 	async_sess_t *hcd_sess =
-	    devman_device_connect(EXCHANGE_SERIALIZE, handle, 0);
+	    devman_device_connect(handle, 0);
 	if (!hcd_sess)
 		return ENOMEM;
@@ -101,5 +101,9 @@
 	
 	async_exch_t *exch = async_exchange_begin(hcd_sess);
-	rc = async_connect_to_me(exch, 0, 0, 0, callback_connection, NULL);
+	
+	port_id_t port;
+	rc = async_create_callback_port(exch, INTERFACE_USBVIRT_CB, 0, 0,
+	    callback_connection, NULL, &port);
+	
 	async_exchange_end(exch);
 	
Index: uspace/srv/audio/hound/audio_sink.c
===================================================================
--- uspace/srv/audio/hound/audio_sink.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/audio/hound/audio_sink.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -103,5 +103,5 @@
 	if (!pcm_format_is_any(&sink->format)) {
 		log_debug("Sink %s already has a format", sink->name);
-		return EEXISTS;
+		return EEXIST;
 	}
 	const pcm_format_t old_format = sink->format;
Index: uspace/srv/audio/hound/hound.c
===================================================================
--- uspace/srv/audio/hound/hound.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/audio/hound/hound.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -267,5 +267,5 @@
 		if (dev->id == id) {
 			log_debug("Device with id %zu is already present", id);
-			return EEXISTS;
+			return EEXIST;
 		}
 	}
@@ -274,5 +274,5 @@
 	if (dev) {
 		log_debug("Device with name %s is already present", name);
-		return EEXISTS;
+		return EEXIST;
 	}
 
@@ -341,5 +341,5 @@
 		log_debug("Source by that name already exists");
 		fibril_mutex_unlock(&hound->list_guard);
-		return EEXISTS;
+		return EEXIST;
 	}
 	list_append(&source->link, &hound->sources);
@@ -365,5 +365,5 @@
 		log_debug("Sink by that name already exists");
 		fibril_mutex_unlock(&hound->list_guard);
-		return EEXISTS;
+		return EEXIST;
 	}
 	list_append(&sink->link, &hound->sinks);
@@ -420,5 +420,5 @@
 
 	fibril_mutex_lock(&hound->list_guard);
-	const size_t count = list_count(&hound->sources);
+	const unsigned long count = list_count(&hound->sources);
 	if (count == 0) {
 		*list = NULL;
@@ -429,5 +429,5 @@
 	const char **names = calloc(count, sizeof(char *));
 	int ret = names ? EOK : ENOMEM;
-	for (size_t i = 0; i < count && ret == EOK; ++i) {
+	for (unsigned long i = 0; i < count && ret == EOK; ++i) {
 		link_t *slink = list_nth(&hound->sources, i);
 		audio_source_t *source = audio_source_list_instance(slink);
Index: uspace/srv/audio/hound/hound_ctx.c
===================================================================
--- uspace/srv/audio/hound/hound_ctx.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/audio/hound/hound_ctx.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -403,5 +403,5 @@
 		return ENOMEM;
 	}
-	log_verbose("CTX: %p: Mixing %u streams", ctx,
+	log_verbose("CTX: %p: Mixing %lu streams", ctx,
 	    list_count(&ctx->streams));
 	pcm_format_silence(buffer, size, &source->format);
@@ -413,5 +413,5 @@
 			log_warning("Not enough data in stream buffer");
 	}
-	log_verbose("CTX: %p. Pushing audio to %u connections", ctx,
+	log_verbose("CTX: %p. Pushing audio to %lu connections", ctx,
 	    list_count(&source->connections));
 	list_foreach(source->connections, source_link, connection_t, conn) {
Index: uspace/srv/audio/hound/main.c
===================================================================
--- uspace/srv/audio/hound/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/audio/hound/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -85,5 +85,5 @@
 	hound_iface.server = &hound;
 	hound_service_set_server_iface(&hound_iface);
-	async_set_client_connection(hound_connection_handler);
+	async_set_fallback_port_handler(hound_connection_handler, NULL);
 
 	service_id_t id = 0;
Index: uspace/srv/bd/file_bd/file_bd.c
===================================================================
--- uspace/srv/bd/file_bd/file_bd.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/bd/file_bd/file_bd.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -157,5 +157,5 @@
 	bd_srvs.ops = &file_bd_ops;
 	
-	async_set_client_connection(file_bd_connection);
+	async_set_fallback_port_handler(file_bd_connection, NULL);
 	int rc = loc_server_register(NAME);
 	if (rc != EOK) {
Index: uspace/srv/bd/part/guid_part/guid_part.c
===================================================================
--- uspace/srv/bd/part/guid_part/guid_part.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/bd/part/guid_part/guid_part.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -160,5 +160,5 @@
 	}
 
-	rc = block_init(EXCHANGE_SERIALIZE, indev_sid, 2048);
+	rc = block_init(indev_sid, 2048);
 	if (rc != EOK)  {
 		printf(NAME ": could not init libblock.\n");
@@ -185,5 +185,5 @@
 
 	/* Register server with location service. */
-	async_set_client_connection(gpt_connection);
+	async_set_fallback_port_handler(gpt_connection, NULL);
 	rc = loc_server_register(NAME);
 	if (rc != EOK) {
@@ -339,7 +339,7 @@
 
 	/* Get the device handle. */
-	dh = IPC_GET_ARG1(*icall);
-
-	/* 
+	dh = IPC_GET_ARG2(*icall);
+
+	/*
 	 * Determine which partition device is the client connecting to.
 	 * A linear search is not terribly fast, but we only do this
Index: uspace/srv/bd/part/mbr_part/mbr_part.c
===================================================================
--- uspace/srv/bd/part/mbr_part/mbr_part.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/bd/part/mbr_part/mbr_part.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -210,5 +210,5 @@
 	}
 
-	rc = block_init(EXCHANGE_SERIALIZE, indev_sid, 2048);
+	rc = block_init(indev_sid, 2048);
 	if (rc != EOK)  {
 		printf(NAME ": could not init libblock.\n");
@@ -235,5 +235,5 @@
 
 	/* Register server with location service. */
-	async_set_client_connection(mbr_connection);
+	async_set_fallback_port_handler(mbr_connection, NULL);
 	rc = loc_server_register(NAME);
 	if (rc != EOK) {
@@ -416,7 +416,7 @@
 
 	/* Get the device handle. */
-	dh = IPC_GET_ARG1(*icall);
-
-	/* 
+	dh = IPC_GET_ARG2(*icall);
+
+	/*
 	 * Determine which partition device is the client connecting to.
 	 * A linear search is not terribly fast, but we only do this
Index: uspace/srv/bd/rd/rd.c
===================================================================
--- uspace/srv/bd/rd/rd.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/bd/rd/rd.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -178,5 +178,5 @@
 	bd_srvs.ops = &rd_bd_ops;
 	
-	async_set_client_connection(rd_client_conn);
+	async_set_fallback_port_handler(rd_client_conn, NULL);
 	ret = loc_server_register(NAME);
 	if (ret != EOK) {
Index: uspace/srv/bd/sata_bd/sata_bd.c
===================================================================
--- uspace/srv/bd/sata_bd/sata_bd.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/bd/sata_bd/sata_bd.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -172,5 +172,5 @@
 
 	/* Get the device service ID. */
-	dsid = IPC_GET_ARG1(*icall);
+	dsid = IPC_GET_ARG2(*icall);
 
 	/* Determine which disk device is the client connecting to. */
@@ -247,5 +247,5 @@
 	int rc;
 	
-	async_set_client_connection(sata_bd_connection);
+	async_set_fallback_port_handler(sata_bd_connection, NULL);
 	rc = loc_server_register(NAME);
 	if (rc < 0) {
Index: uspace/srv/bd/vbd/disk.c
===================================================================
--- uspace/srv/bd/vbd/disk.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/bd/vbd/disk.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -360,5 +360,5 @@
 	rc = vbds_disk_by_svcid(sid, &disk);
 	if (rc == EOK)
-		return EEXISTS;
+		return EEXIST;
 
 	disk = calloc(1, sizeof(vbds_disk_t));
@@ -374,5 +374,5 @@
 
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "block_init(%zu)", sid);
-	rc = block_init(EXCHANGE_SERIALIZE, sid, 2048);
+	rc = block_init(sid, 2048);
 	if (rc != EOK) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, "Failed opening block device %s.",
@@ -872,5 +872,5 @@
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_bd_conn()");
 
-	svcid = IPC_GET_ARG1(*icall);
+	svcid = IPC_GET_ARG2(*icall);
 
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_bd_conn() - svcid=%zu", svcid);
Index: uspace/srv/bd/vbd/vbd.c
===================================================================
--- uspace/srv/bd/vbd/vbd.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/bd/vbd/vbd.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -64,5 +64,5 @@
 		return rc;
 
-	async_set_client_connection(vbds_client_conn);
+	async_set_fallback_port_handler(vbds_client_conn, NULL);
 
 	rc = loc_server_register(NAME);
@@ -415,5 +415,5 @@
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_client_conn()");
 
-	sid = (service_id_t)IPC_GET_ARG1(*icall);
+	sid = (service_id_t)IPC_GET_ARG2(*icall);
 
 	if (sid == ctl_sid)
Index: uspace/srv/clipboard/clipboard.c
===================================================================
--- uspace/srv/clipboard/clipboard.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/clipboard/clipboard.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -180,5 +180,5 @@
 	printf("%s: HelenOS clipboard service\n", NAME);
 	
-	async_set_client_connection(clip_connection);
+	async_set_fallback_port_handler(clip_connection, NULL);
 	int rc = service_register(SERVICE_CLIPBOARD);
 	if (rc != EOK)
Index: uspace/srv/devman/client_conn.c
===================================================================
--- uspace/srv/devman/client_conn.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/devman/client_conn.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -726,5 +726,5 @@
 
 /** Function for handling connections from a client to the device manager. */
-void devman_connection_client(ipc_callid_t iid, ipc_call_t *icall)
+void devman_connection_client(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
 	/* Accept connection. */
Index: uspace/srv/devman/client_conn.h
===================================================================
--- uspace/srv/devman/client_conn.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/devman/client_conn.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,5 +36,5 @@
 #include "devman.h"
 
-extern void devman_connection_client(ipc_callid_t, ipc_call_t *);
+extern void devman_connection_client(ipc_callid_t, ipc_call_t *, void *);
 
 #endif
Index: uspace/srv/devman/driver.c
===================================================================
--- uspace/srv/devman/driver.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/devman/driver.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,5 +36,4 @@
 #include <sys/stat.h>
 #include <io/log.h>
-#include <ipc/driver.h>
 #include <loc.h>
 #include <str_error.h>
@@ -143,5 +142,5 @@
 	/* Check whether the driver's binary exists. */
 	struct stat s;
-	if (stat(drv->binary_path, &s) == ENOENT) { /* FIXME!! */
+	if (stat(drv->binary_path, &s) != 0) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, "Driver not found at path `%s'.",
 		    drv->binary_path);
@@ -573,11 +572,11 @@
 	
 	if (rc != EOK) {
-		/* TODO handle error */
-	}
-
-	/* Wait for answer from the driver. */
-	async_wait_for(req, &rc);
-
-	switch(rc) {
+		async_forget(req);
+	} else {
+		/* Wait for answer from the driver. */
+		async_wait_for(req, &rc);
+	}
+
+	switch (rc) {
 	case EOK:
 		dev->state = DEVICE_USABLE;
@@ -592,6 +591,4 @@
 	
 	dev->passed_to_driver = true;
-
-	return;
 }
 
Index: uspace/srv/devman/drv_conn.c
===================================================================
--- uspace/srv/devman/drv_conn.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/devman/drv_conn.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -49,5 +49,4 @@
 #include <io/log.h>
 #include <ipc/devman.h>
-#include <ipc/driver.h>
 #include <loc.h>
 
@@ -102,5 +101,5 @@
 		    driver->name);
 		fibril_mutex_unlock(&driver->driver_mutex);
-		async_answer_0(callid, EEXISTS);
+		async_answer_0(callid, EEXIST);
 		return NULL;
 	}
@@ -131,5 +130,5 @@
 	}
 	/* FIXME: Work around problem with callback sessions */
-	async_sess_args_set(driver->sess, DRIVER_DEVMAN, 0, 0);
+	async_sess_args_set(driver->sess, INTERFACE_DDF_DEVMAN, 0, 0);
 	
 	log_msg(LOG_DEFAULT, LVL_NOTE,
@@ -279,5 +278,5 @@
 		fibril_rwlock_write_unlock(&tree->rwlock);
 		dev_del_ref(pdev);
-		async_answer_0(callid, EEXISTS);
+		async_answer_0(callid, EEXIST);
 		printf(NAME ": Warning, driver tried to register `%s' twice.\n",
 		    fun_name);
@@ -587,5 +586,5 @@
 
 /** Function for handling connections from a driver to the device manager. */
-void devman_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
+void devman_connection_driver(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
 	client_t *client;
Index: uspace/srv/devman/drv_conn.h
===================================================================
--- uspace/srv/devman/drv_conn.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/devman/drv_conn.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -37,5 +37,5 @@
 #include "devman.h"
 
-extern void devman_connection_driver(ipc_callid_t, ipc_call_t *);
+extern void devman_connection_driver(ipc_callid_t, ipc_call_t *, void *);
 
 #endif
Index: uspace/srv/devman/loc.c
===================================================================
--- uspace/srv/devman/loc.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/devman/loc.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -59,6 +59,5 @@
 	}
 	
-	loc_service_register_with_iface(loc_pathname,
-	    &fun->service_id, DEVMAN_CONNECT_FROM_LOC);
+	loc_service_register(loc_pathname, &fun->service_id);
 	
 	tree_add_loc_function(tree, fun);
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/devman/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -49,5 +49,4 @@
 #include <io/log.h>
 #include <ipc/devman.h>
-#include <ipc/driver.h>
 #include <loc.h>
 
@@ -66,23 +65,23 @@
 dev_tree_t device_tree;
 
-static void devman_forward(ipc_callid_t iid, ipc_call_t *icall,
-    bool drv_to_parent)
+static void devman_connection_device(ipc_callid_t iid, ipc_call_t *icall,
+    void *arg)
 {
 	devman_handle_t handle = IPC_GET_ARG2(*icall);
-	devman_handle_t fwd_h;
-	fun_node_t *fun = NULL;
 	dev_node_t *dev = NULL;
 	
-	fun = find_fun_node(&device_tree, handle);
-	if (fun == NULL)
+	fun_node_t *fun = find_fun_node(&device_tree, handle);
+	if (fun == NULL) {
 		dev = find_dev_node(&device_tree, handle);
-	else {
+	} else {
 		fibril_rwlock_read_lock(&device_tree.rwlock);
+		
 		dev = fun->dev;
 		if (dev != NULL)
 			dev_add_ref(dev);
+		
 		fibril_rwlock_read_unlock(&device_tree.rwlock);
 	}
-
+	
 	/*
 	 * For a valid function to connect to we need a device. The root
@@ -97,6 +96,6 @@
 		goto cleanup;
 	}
-
-	if (fun == NULL && !drv_to_parent) {
+	
+	if (fun == NULL) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, NAME ": devman_forward error - cannot "
 		    "connect to handle %" PRIun ", refers to a device.",
@@ -106,19 +105,8 @@
 	}
 	
-	driver_t *driver = NULL;
-	
 	fibril_rwlock_read_lock(&device_tree.rwlock);
 	
-	if (drv_to_parent) {
-		/* Connect to parent function of a device (or device function). */
-		if (dev->pfun->dev != NULL)
-			driver = dev->pfun->dev->drv;
-		
-		fwd_h = dev->pfun->handle;
-	} else {
-		/* Connect to the specified function */
-		driver = dev->drv;
-		fwd_h = handle;
-	}
+	/* Connect to the specified function */
+	driver_t *driver = dev->drv;
 	
 	fibril_rwlock_read_unlock(&device_tree.rwlock);
@@ -130,10 +118,4 @@
 		goto cleanup;
 	}
-	
-	int method;
-	if (drv_to_parent)
-		method = DRIVER_DRIVER;
-	else
-		method = DRIVER_CLIENT;
 	
 	if (!driver->sess) {
@@ -143,5 +125,5 @@
 		goto cleanup;
 	}
-
+	
 	if (fun != NULL) {
 		log_msg(LOG_DEFAULT, LVL_DEBUG,
@@ -155,5 +137,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(driver->sess);
-	async_forward_fast(iid, exch, method, fwd_h, 0, IPC_FF_NONE);
+	async_forward_fast(iid, exch, INTERFACE_DDF_CLIENT, handle, 0, IPC_FF_NONE);
 	async_exchange_end(exch);
 	
@@ -166,20 +148,95 @@
 }
 
-/** Function for handling connections from a client forwarded by the location
- * service to the device manager. */
-static void devman_connection_loc(ipc_callid_t iid, ipc_call_t *icall)
-{
+static void devman_connection_parent(ipc_callid_t iid, ipc_call_t *icall,
+    void *arg)
+{
+	devman_handle_t handle = IPC_GET_ARG2(*icall);
+	dev_node_t *dev = NULL;
+	
+	fun_node_t *fun = find_fun_node(&device_tree, handle);
+	if (fun == NULL) {
+		dev = find_dev_node(&device_tree, handle);
+	} else {
+		fibril_rwlock_read_lock(&device_tree.rwlock);
+		
+		dev = fun->dev;
+		if (dev != NULL)
+			dev_add_ref(dev);
+		
+		fibril_rwlock_read_unlock(&device_tree.rwlock);
+	}
+	
+	/*
+	 * For a valid function to connect to we need a device. The root
+	 * function, for example, has no device and cannot be connected to.
+	 * This means @c dev needs to be valid regardless whether we are
+	 * connecting to a device or to a function.
+	 */
+	if (dev == NULL) {
+		log_msg(LOG_DEFAULT, LVL_ERROR, "IPC forwarding failed - no device or "
+		    "function with handle %" PRIun " was found.", handle);
+		async_answer_0(iid, ENOENT);
+		goto cleanup;
+	}
+	
+	driver_t *driver = NULL;
+	
+	fibril_rwlock_read_lock(&device_tree.rwlock);
+	
+	/* Connect to parent function of a device (or device function). */
+	if (dev->pfun->dev != NULL)
+		driver = dev->pfun->dev->drv;
+	
+	devman_handle_t fun_handle = dev->pfun->handle;
+	
+	fibril_rwlock_read_unlock(&device_tree.rwlock);
+	
+	if (driver == NULL) {
+		log_msg(LOG_DEFAULT, LVL_ERROR, "IPC forwarding refused - " \
+		    "the device %" PRIun " is not in usable state.", handle);
+		async_answer_0(iid, ENOENT);
+		goto cleanup;
+	}
+	
+	if (!driver->sess) {
+		log_msg(LOG_DEFAULT, LVL_ERROR,
+		    "Could not forward to driver `%s'.", driver->name);
+		async_answer_0(iid, EINVAL);
+		goto cleanup;
+	}
+	
+	if (fun != NULL) {
+		log_msg(LOG_DEFAULT, LVL_DEBUG,
+		    "Forwarding request for `%s' function to driver `%s'.",
+		    fun->pathname, driver->name);
+	} else {
+		log_msg(LOG_DEFAULT, LVL_DEBUG,
+		    "Forwarding request for `%s' device to driver `%s'.",
+		    dev->pfun->pathname, driver->name);
+	}
+	
+	async_exch_t *exch = async_exchange_begin(driver->sess);
+	async_forward_fast(iid, exch, INTERFACE_DDF_DRIVER, fun_handle, 0, IPC_FF_NONE);
+	async_exchange_end(exch);
+	
+cleanup:
+	if (dev != NULL)
+		dev_del_ref(dev);
+	
+	if (fun != NULL)
+		fun_del_ref(fun);
+}
+
+static void devman_forward(ipc_callid_t iid, ipc_call_t *icall, void *arg)
+{
+	iface_t iface = IPC_GET_ARG1(*icall);
 	service_id_t service_id = IPC_GET_ARG2(*icall);
-	fun_node_t *fun;
-	dev_node_t *dev;
-	devman_handle_t handle;
-	driver_t *driver;
-
-	fun = find_loc_tree_function(&device_tree, service_id);
+	
+	fun_node_t *fun = find_loc_tree_function(&device_tree, service_id);
 	
 	fibril_rwlock_read_lock(&device_tree.rwlock);
 	
-	if (fun == NULL || fun->dev == NULL || fun->dev->drv == NULL) {
-		log_msg(LOG_DEFAULT, LVL_WARN, "devman_connection_loc(): function "
+	if ((fun == NULL) || (fun->dev == NULL) || (fun->dev->drv == NULL)) {
+		log_msg(LOG_DEFAULT, LVL_WARN, "devman_forward(): function "
 		    "not found.\n");
 		fibril_rwlock_read_unlock(&device_tree.rwlock);
@@ -188,49 +245,19 @@
 	}
 	
-	dev = fun->dev;
-	driver = dev->drv;
-	handle = fun->handle;
+	dev_node_t *dev = fun->dev;
+	driver_t *driver = dev->drv;
+	devman_handle_t handle = fun->handle;
 	
 	fibril_rwlock_read_unlock(&device_tree.rwlock);
 	
 	async_exch_t *exch = async_exchange_begin(driver->sess);
-	async_forward_fast(iid, exch, DRIVER_CLIENT, handle, 0,
-	    IPC_FF_NONE);
+	async_forward_fast(iid, exch, iface, handle, 0, IPC_FF_NONE);
 	async_exchange_end(exch);
 	
 	log_msg(LOG_DEFAULT, LVL_DEBUG,
-	    "Forwarding loc service request for `%s' function to driver `%s'.",
+	    "Forwarding service request for `%s' function to driver `%s'.",
 	    fun->pathname, driver->name);
-
+	
 	fun_del_ref(fun);
-}
-
-/** Function for handling connections to device manager. */
-static void devman_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
-{
-	/* Select port. */
-	switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
-	case DEVMAN_DRIVER:
-		devman_connection_driver(iid, icall);
-		break;
-	case DEVMAN_CLIENT:
-		devman_connection_client(iid, icall);
-		break;
-	case DEVMAN_CONNECT_TO_DEVICE:
-		/* Connect client to selected device. */
-		devman_forward(iid, icall, false);
-		break;
-	case DEVMAN_CONNECT_FROM_LOC:
-		/* Someone connected through loc node. */
-		devman_connection_loc(iid, icall);
-		break;
-	case DEVMAN_CONNECT_TO_PARENTS_DEVICE:
-		/* Connect client to selected device. */
-		devman_forward(iid, icall, true);
-		break;
-	default:
-		/* No such interface */
-		async_answer_0(iid, ENOENT);
-	}
 }
 
@@ -298,5 +325,27 @@
 	async_set_client_data_constructor(devman_client_data_create);
 	async_set_client_data_destructor(devman_client_data_destroy);
-	async_set_client_connection(devman_connection);
+	
+	port_id_t port;
+	rc = async_create_port(INTERFACE_DDF_DRIVER,
+	    devman_connection_driver, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	rc = async_create_port(INTERFACE_DDF_CLIENT,
+	    devman_connection_client, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	rc = async_create_port(INTERFACE_DEVMAN_DEVICE,
+	    devman_connection_device, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	rc = async_create_port(INTERFACE_DEVMAN_PARENT,
+	    devman_connection_parent, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	async_set_fallback_port_handler(devman_forward, NULL);
 	
 	if (!devman_init()) {
Index: uspace/srv/devman/match.c
===================================================================
--- uspace/srv/devman/match.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/devman/match.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -31,4 +31,5 @@
  */
 
+#include <errno.h>
 #include <fcntl.h>
 #include <io/log.h>
@@ -197,5 +198,5 @@
 	if (fd < 0) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, "Unable to open `%s' for reading: %s.",
-		    conf_path, str_error(fd));
+		    conf_path, str_error(errno));
 		goto cleanup;
 	}
@@ -217,8 +218,8 @@
 	}
 	
-	ssize_t read_bytes = read_all(fd, buf, len);
+	ssize_t read_bytes = read(fd, buf, len);
 	if (read_bytes <= 0) {
-		log_msg(LOG_DEFAULT, LVL_ERROR, "Unable to read file '%s' (%zd).", conf_path,
-		    read_bytes);
+		log_msg(LOG_DEFAULT, LVL_ERROR, "Unable to read file '%s' (%d).", conf_path,
+		    errno);
 		goto cleanup;
 	}
Index: uspace/srv/fs/cdfs/cdfs.c
===================================================================
--- uspace/srv/fs/cdfs/cdfs.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/cdfs/cdfs.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -73,6 +73,6 @@
 	}
 	
-	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
-	    SERVICE_VFS, 0, 0);
+	async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
+	    INTERFACE_VFS_DRIVER, 0);
 	if (!vfs_sess) {
 		printf("%s: Unable to connect to VFS\n", NAME);
Index: uspace/srv/fs/cdfs/cdfs_ops.c
===================================================================
--- uspace/srv/fs/cdfs/cdfs_ops.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/cdfs/cdfs_ops.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1025,5 +1025,5 @@
 {
 	/* Initialize the block layer */
-	int rc = block_init(EXCHANGE_SERIALIZE, service_id, BLOCK_SIZE);
+	int rc = block_init(service_id, BLOCK_SIZE);
 	if (rc != EOK)
 		return rc;
Index: uspace/srv/fs/exfat/exfat.c
===================================================================
--- uspace/srv/fs/exfat/exfat.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/exfat/exfat.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -75,6 +75,6 @@
 		goto err;
 
-	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
-	    SERVICE_VFS, 0, 0);
+	async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
+	    INTERFACE_VFS_DRIVER, 0);
 	if (!vfs_sess) {
 		printf(NAME ": failed to connect to VFS\n");
Index: uspace/srv/fs/exfat/exfat_ops.c
===================================================================
--- uspace/srv/fs/exfat/exfat_ops.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/exfat/exfat_ops.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1067,5 +1067,5 @@
 
 	/* initialize libblock */
-	rc = block_init(EXCHANGE_SERIALIZE, service_id, BS_SIZE);
+	rc = block_init(service_id, BS_SIZE);
 	if (rc != EOK)
 		return rc;
Index: uspace/srv/fs/ext4fs/Makefile
===================================================================
--- uspace/srv/fs/ext4fs/Makefile	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/ext4fs/Makefile	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -28,6 +28,7 @@
 
 USPACE_PREFIX = ../../..
-LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBFS_PREFIX)/libfs.a $(LIBEXT4_PREFIX)/libext4.a
-EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) -I$(LIBEXT4_PREFIX)
+LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBFS_PREFIX)/libfs.a \
+    $(LIBEXT4_PREFIX)/libext4.a $(LIBCRYPTO_PREFIX)/libcrypto.a
+EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) -I$(LIBEXT4_PREFIX) -I$(LIBCRYPTO_PREFIX)
 BINARY = ext4fs
 STATIC_NEEDED = y
Index: uspace/srv/fs/ext4fs/ext4fs.c
===================================================================
--- uspace/srv/fs/ext4fs/ext4fs.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/ext4fs/ext4fs.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -65,6 +65,6 @@
 	}
 	
-	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
-	    SERVICE_VFS, 0, 0);
+	async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
+	    INTERFACE_VFS_DRIVER, 0);
 	if (!vfs_sess) {
 		printf("%s: Failed to connect to VFS\n", NAME);
Index: uspace/srv/fs/fat/fat.c
===================================================================
--- uspace/srv/fs/fat/fat.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/fat/fat.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -75,6 +75,6 @@
 		goto err;
 	
-	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
-	    SERVICE_VFS, 0, 0);
+	async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
+	    INTERFACE_VFS_DRIVER, 0);
 	if (!vfs_sess) {
 		printf(NAME ": failed to connect to VFS\n");
Index: uspace/srv/fs/fat/fat_ops.c
===================================================================
--- uspace/srv/fs/fat/fat_ops.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/fat/fat_ops.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -939,5 +939,5 @@
 
 	/* initialize libblock */
-	rc = block_init(EXCHANGE_SERIALIZE, service_id, BS_SIZE);
+	rc = block_init(service_id, BS_SIZE);
 	if (rc != EOK) {
 		free(instance);
Index: uspace/srv/fs/locfs/locfs.c
===================================================================
--- uspace/srv/fs/locfs/locfs.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/locfs/locfs.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -77,6 +77,6 @@
 	}
 	
-	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
-	    SERVICE_VFS, 0, 0);
+	async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
+	    INTERFACE_VFS_DRIVER, 0);
 	if (!vfs_sess) {
 		printf("%s: Unable to connect to VFS\n", NAME);
Index: uspace/srv/fs/locfs/locfs_ops.c
===================================================================
--- uspace/srv/fs/locfs/locfs_ops.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/locfs/locfs_ops.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -264,6 +264,6 @@
 			fibril_mutex_unlock(&services_mutex);
 			
-			async_sess_t *sess = loc_service_connect(
-			    EXCHANGE_SERIALIZE, node->service_id, 0);
+			async_sess_t *sess = loc_service_connect(node->service_id,
+			    INTERFACE_FS, 0);
 			
 			fibril_mutex_lock(&services_mutex);
Index: uspace/srv/fs/mfs/mfs.c
===================================================================
--- uspace/srv/fs/mfs/mfs.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/mfs/mfs.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -73,6 +73,6 @@
 	}
 
-	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
-	    SERVICE_VFS, 0, 0);
+	async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
+	    INTERFACE_VFS_DRIVER, 0);
 
 	if (!vfs_sess) {
Index: uspace/srv/fs/mfs/mfs_ops.c
===================================================================
--- uspace/srv/fs/mfs/mfs_ops.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/mfs/mfs_ops.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -161,5 +161,5 @@
 
 	/* initialize libblock */
-	rc = block_init(EXCHANGE_SERIALIZE, service_id, 4096);
+	rc = block_init(service_id, 4096);
 	if (rc != EOK)
 		return rc;
Index: uspace/srv/fs/tmpfs/tmpfs.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/tmpfs/tmpfs.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -80,6 +80,6 @@
 	}
 	
-	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
-	    SERVICE_VFS, 0, 0);
+	async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
+	    INTERFACE_VFS_DRIVER, 0);
 	if (!vfs_sess) {
 		printf(NAME ": Unable to connect to VFS\n");
Index: uspace/srv/fs/tmpfs/tmpfs_dump.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs_dump.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/tmpfs/tmpfs_dump.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -169,5 +169,5 @@
 	int rc;
 
-	rc = block_init(EXCHANGE_SERIALIZE, dsid, TMPFS_COMM_SIZE);
+	rc = block_init(dsid, TMPFS_COMM_SIZE);
 	if (rc != EOK)
 		return false; 
Index: uspace/srv/fs/udf/udf.c
===================================================================
--- uspace/srv/fs/udf/udf.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/udf/udf.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -74,5 +74,5 @@
 	
 	async_sess_t *vfs_sess =
-	    service_connect_blocking(EXCHANGE_SERIALIZE, SERVICE_VFS, 0, 0);
+	    service_connect_blocking(SERVICE_VFS, INTERFACE_VFS_DRIVER, 0);
 	if (!vfs_sess) {
 		log_msg(LOG_DEFAULT, LVL_FATAL, "Failed to connect to VFS");
Index: uspace/srv/fs/udf/udf_ops.c
===================================================================
--- uspace/srv/fs/udf/udf_ops.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/fs/udf/udf_ops.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -325,5 +325,5 @@
 	
 	/* initialize block cache */
-	int rc = block_init(EXCHANGE_SERIALIZE, service_id, MAX_SIZE);
+	int rc = block_init(service_id, MAX_SIZE);
 	if (rc != EOK)
 		return rc;
Index: uspace/srv/hid/compositor/compositor.c
===================================================================
--- uspace/srv/hid/compositor/compositor.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/compositor/compositor.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -896,5 +896,5 @@
 	ipc_call_t call;
 	ipc_callid_t callid;
-	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*icall);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG2(*icall);
 
 	/* Allocate resources for new window and register it to the location service. */
@@ -1175,5 +1175,5 @@
 	async_sess_t *sess;
 
-	sess = loc_service_connect(EXCHANGE_SERIALIZE, sid, 0);
+	sess = loc_service_connect(sid, INTERFACE_DDF, 0);
 	if (sess == NULL) {
 		printf("%s: Unable to connect to visualizer %s\n", NAME, svc);
@@ -1182,5 +1182,9 @@
 
 	async_exch_t *exch = async_exchange_begin(sess);
-	rc = async_connect_to_me(exch, sid, 0, 0, vsl_notifications, NULL);
+	
+	port_id_t port;
+	rc = async_create_callback_port(exch, INTERFACE_VISUALIZER_CB, 0, 0,
+	    vsl_notifications, NULL, &port);
+	
 	async_exchange_end(exch);
 
@@ -2145,5 +2149,5 @@
 	}
 
-	sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0);
+	sess = loc_service_connect(dsid, INTERFACE_INPUT, 0);
 	if (sess == NULL) {
 		printf("%s: Unable to connect to input service %s\n", NAME,
@@ -2240,5 +2244,5 @@
 	
 	/* Register compositor server. */
-	async_set_client_connection(client_connection);
+	async_set_fallback_port_handler(client_connection, NULL);
 	
 	int rc = loc_server_register(NAME);
Index: uspace/srv/hid/console/console.c
===================================================================
--- uspace/srv/hid/console/console.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/console/console.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -508,5 +508,5 @@
 	
 	for (size_t i = 0; i < CONSOLE_COUNT; i++) {
-		if (consoles[i].dsid == (service_id_t) IPC_GET_ARG1(*icall)) {
+		if (consoles[i].dsid == (service_id_t) IPC_GET_ARG2(*icall)) {
 			cons = &consoles[i];
 			break;
@@ -536,5 +536,5 @@
 	}
 
-	sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0);
+	sess = loc_service_connect(dsid, INTERFACE_INPUT, 0);
 	if (sess == NULL) {
 		printf("%s: Unable to connect to input service %s\n", NAME,
@@ -561,5 +561,5 @@
 	int rc = loc_service_get_id(svc, &dsid, 0);
 	if (rc == EOK) {
-		sess = loc_service_connect(EXCHANGE_SERIALIZE, dsid, 0);
+		sess = loc_service_connect(dsid, INTERFACE_OUTPUT, 0);
 		if (sess == NULL) {
 			printf("%s: Unable to connect to output service %s\n",
@@ -586,5 +586,5 @@
 	
 	/* Register server */
-	async_set_client_connection(client_connection);
+	async_set_fallback_port_handler(client_connection, NULL);
 	rc = loc_server_register(NAME);
 	if (rc != EOK) {
Index: uspace/srv/hid/input/ctl/kbdev.c
===================================================================
--- uspace/srv/hid/input/ctl/kbdev.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/input/ctl/kbdev.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -94,6 +94,6 @@
 static int kbdev_ctl_init(kbd_dev_t *kdev)
 {
-	async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE,
-	    kdev->svc_id, 0);
+	async_sess_t *sess = loc_service_connect(kdev->svc_id,
+	    INTERFACE_DDF, 0);
 	if (sess == NULL) {
 		printf("%s: Failed starting session with '%s.'\n", NAME,
@@ -120,5 +120,8 @@
 	}
 	
-	int rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev);
+	port_id_t port;
+	int rc = async_create_callback_port(exch, INTERFACE_KBD_CB, 0, 0,
+	    kbdev_callback_conn, kbdev, &port);
+	
 	if (rc != EOK) {
 		printf("%s: Failed creating callback connection from '%s'.\n",
Index: uspace/srv/hid/input/input.c
===================================================================
--- uspace/srv/hid/input/input.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/input/input.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -745,6 +745,6 @@
 	if (irc_service) {
 		while (irc_sess == NULL)
-			irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
-			    SERVICE_IRC, 0, 0);
+			irc_sess = service_connect_blocking(SERVICE_IRC,
+			    INTERFACE_IRC, 0);
 	}
 	
@@ -758,5 +758,5 @@
 	async_set_client_data_constructor(client_data_create);
 	async_set_client_data_destructor(client_data_destroy);
-	async_set_client_connection(client_connection);
+	async_set_fallback_port_handler(client_connection, NULL);
 	
 	int rc = loc_server_register(NAME);
Index: uspace/srv/hid/input/port/adb.c
===================================================================
--- uspace/srv/hid/input/port/adb.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/input/port/adb.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -69,5 +69,5 @@
 		return rc;
 	
-	dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
+	dev_sess = loc_service_connect(service_id, INTERFACE_DDF, 0);
 	if (dev_sess == NULL) {
 		printf("%s: Failed to connect to device\n", NAME);
@@ -82,5 +82,8 @@
 	}
 	
-	rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL);
+	port_id_t port;
+	rc = async_create_callback_port(exch, INTERFACE_ADB_CB, 0, 0,
+	    kbd_port_events, NULL, &port);
+	
 	async_exchange_end(exch);
 	if (rc != EOK) {
Index: uspace/srv/hid/input/port/adb_mouse.c
===================================================================
--- uspace/srv/hid/input/port/adb_mouse.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/input/port/adb_mouse.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -84,5 +84,5 @@
 		return rc;
 	
-	dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
+	dev_sess = loc_service_connect(service_id, INTERFACE_DDF, 0);
 	if (dev_sess == NULL) {
 		printf("%s: Failed to connect to device\n", NAME);
@@ -98,5 +98,8 @@
 	
 	/* NB: The callback connection is slotted for removal */
-	rc = async_connect_to_me(exch, 0, 0, 0, mouse_port_events, NULL);
+	port_id_t port;
+	rc = async_create_callback_port(exch, INTERFACE_ADB_CB, 0, 0,
+	    mouse_port_events, NULL, &port);
+	
 	async_exchange_end(exch);
 	if (rc != EOK) {
Index: uspace/srv/hid/input/port/chardev.c
===================================================================
--- uspace/srv/hid/input/port/chardev.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/input/port/chardev.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -84,5 +84,5 @@
 	}
 	
-	dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id,
+	dev_sess = loc_service_connect(service_id, INTERFACE_DDF,
 	    IPC_FLAG_BLOCKING);
 	if (dev_sess == NULL) {
@@ -98,6 +98,8 @@
 	}
 	
-	/* NB: The callback connection is slotted for removal */
-	rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL);
+	port_id_t port;
+	rc = async_create_callback_port(exch, INTERFACE_CHAR_CB, 0, 0,
+	    kbd_port_events, NULL, &port);
+	
 	async_exchange_end(exch);
 	
Index: uspace/srv/hid/input/proto/mousedev.c
===================================================================
--- uspace/srv/hid/input/proto/mousedev.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/input/proto/mousedev.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -118,6 +118,5 @@
 static int mousedev_proto_init(mouse_dev_t *mdev)
 {
-	async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE,
-	    mdev->svc_id, 0);
+	async_sess_t *sess = loc_service_connect(mdev->svc_id, INTERFACE_DDF, 0);
 	if (sess == NULL) {
 		printf("%s: Failed starting session with '%s'\n", NAME,
@@ -143,5 +142,8 @@
 	}
 	
-	int rc = async_connect_to_me(exch, 0, 0, 0, mousedev_callback_conn, mousedev);
+	port_id_t port;
+	int rc = async_create_callback_port(exch, INTERFACE_MOUSE_CB, 0, 0,
+	    mousedev_callback_conn, mousedev, &port);
+	
 	async_exchange_end(exch);
 	async_hangup(sess);
Index: uspace/srv/hid/isdv4_tablet/main.c
===================================================================
--- uspace/srv/hid/isdv4_tablet/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/isdv4_tablet/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -69,8 +69,10 @@
 	async_sess_t *sess =
 	    async_callback_receive(EXCHANGE_SERIALIZE);
+	
 	fibril_mutex_lock(&client_mutex);
-		if (client_sess == NULL) {
-			client_sess = sess;
-		}
+	
+	if (client_sess == NULL)
+		client_sess = sess;
+	
 	fibril_mutex_unlock(&client_mutex);
 
@@ -262,5 +264,5 @@
 	printf(NAME ": Using serial port %s\n", serial_port_name);
 
-	async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id,
+	async_sess_t *sess = loc_service_connect(svc_id, INTERFACE_DDF,
 	    IPC_FLAG_BLOCKING);
 	if (!sess) {
@@ -306,5 +308,5 @@
 	fibril_add_ready(fibril);
 
-	async_set_client_connection(mouse_connection);
+	async_set_fallback_port_handler(mouse_connection, NULL);
 	rc = loc_server_register(NAME);
 	if (rc != EOK) {
Index: uspace/srv/hid/output/output.c
===================================================================
--- uspace/srv/hid/output/output.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/output/output.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -460,5 +460,5 @@
 	
 	/* Register server */
-	async_set_client_connection(client_connection);
+	async_set_fallback_port_handler(client_connection, NULL);
 	int rc = loc_server_register(NAME);
 	if (rc != EOK) {
Index: uspace/srv/hid/remcons/remcons.c
===================================================================
--- uspace/srv/hid/remcons/remcons.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/remcons/remcons.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -217,5 +217,5 @@
 {
 	/* Find the user. */
-	telnet_user_t *user = telnet_user_get_for_client_connection(IPC_GET_ARG1(*icall));
+	telnet_user_t *user = telnet_user_get_for_client_connection(IPC_GET_ARG2(*icall));
 	if (user == NULL) {
 		async_answer_0(iid, ENOENT);
@@ -348,5 +348,5 @@
 	inet_ep_t ep;
 
-	async_set_client_connection(client_connection);
+	async_set_fallback_port_handler(client_connection, NULL);
 	rc = loc_server_register(NAME);
 	if (rc != EOK) {
Index: uspace/srv/hid/rfb/main.c
===================================================================
--- uspace/srv/hid/rfb/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/rfb/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -215,5 +215,5 @@
 	vis->dev_ctx = NULL;
 
-	async_set_client_connection(client_connection);
+	async_set_fallback_port_handler(client_connection, NULL);
 
 	int rc = loc_server_register(NAME);
Index: uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
===================================================================
--- uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -85,5 +85,5 @@
 	printf("%s: S3C24xx touchscreen driver\n", NAME);
 	
-	async_set_client_connection(s3c24xx_ts_connection);
+	async_set_fallback_port_handler(s3c24xx_ts_connection, NULL);
 	int rc = loc_server_register(NAME);
 	if (rc != EOK) {
Index: uspace/srv/hw/bus/cuda_adb/cuda_adb.c
===================================================================
--- uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -169,5 +169,5 @@
 	}
 
-	async_set_client_connection(cuda_connection);
+	async_set_fallback_port_handler(cuda_connection, NULL);
 	rc = loc_server_register(NAME);
 	if (rc < 0) {
@@ -214,5 +214,5 @@
 
 	/* Get the device handle. */
-	dsid = IPC_GET_ARG1(*icall);
+	dsid = IPC_GET_ARG2(*icall);
 
 	/* Determine which disk device is the client connecting to. */
Index: uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
===================================================================
--- uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -77,5 +77,5 @@
 	printf("%s: S3C24xx on-chip UART driver\n", NAME);
 	
-	async_set_client_connection(s3c24xx_uart_connection);
+	async_set_fallback_port_handler(s3c24xx_uart_connection, NULL);
 	int rc = loc_server_register(NAME);
 	if (rc != EOK) {
Index: uspace/srv/hw/irc/apic/apic.c
===================================================================
--- uspace/srv/hw/irc/apic/apic.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hw/irc/apic/apic.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -215,5 +215,5 @@
 	}
 	
-	async_set_client_connection(apic_connection);
+	async_set_fallback_port_handler(apic_connection, NULL);
 	service_register(SERVICE_IRC);
 	
Index: uspace/srv/hw/irc/i8259/i8259.c
===================================================================
--- uspace/srv/hw/irc/i8259/i8259.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hw/irc/i8259/i8259.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -153,5 +153,5 @@
 	}
 	
-	async_set_client_connection(i8259_connection);
+	async_set_fallback_port_handler(i8259_connection, NULL);
 	service_register(SERVICE_IRC);
 	
Index: uspace/srv/hw/irc/icp-ic/icp-ic.c
===================================================================
--- uspace/srv/hw/irc/icp-ic/icp-ic.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hw/irc/icp-ic/icp-ic.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -150,5 +150,5 @@
 	icpic_regs = (icpic_regs_t *)regs;
 
-	async_set_client_connection(icpic_connection);
+	async_set_fallback_port_handler(icpic_connection, NULL);
 	service_register(SERVICE_IRC);
 
Index: uspace/srv/hw/irc/obio/obio.c
===================================================================
--- uspace/srv/hw/irc/obio/obio.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/hw/irc/obio/obio.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -137,5 +137,5 @@
 	printf("%s: OBIO registers with base at %zu\n", NAME, base_phys);
 	
-	async_set_client_connection(obio_connection);
+	async_set_fallback_port_handler(obio_connection, NULL);
 	service_register(SERVICE_IRC);
 	
Index: uspace/srv/loader/main.c
===================================================================
--- uspace/srv/loader/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/loader/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -249,5 +249,5 @@
 		}
 		async_state_change_finalize(callid, vfs_exch);
-		fd = fd_wait();
+		fd = vfs_fd_wait();
 		assert(fd == (int) filc);
 	}
@@ -443,6 +443,5 @@
 int main(int argc, char *argv[])
 {
-	/* Set a handler of incomming connections. */
-	async_set_client_connection(ldr_connection);
+	async_set_fallback_port_handler(ldr_connection, NULL);
 	
 	/* Introduce this task to the NS (give it our task ID). */
@@ -452,9 +451,15 @@
 		return rc;
 	
-	/* Register at naming service. */
-	rc = service_register(SERVICE_LOAD);
+	/* Create port */
+	port_id_t port;
+	rc = async_create_port(INTERFACE_LOADER, ldr_connection, NULL, &port);
 	if (rc != EOK)
 		return rc;
 	
+	/* Register at naming service. */
+	rc = service_register(SERVICE_LOADER);
+	if (rc != EOK)
+		return rc;
+	
 	async_manager();
 	
Index: uspace/srv/locsrv/locsrv.c
===================================================================
--- uspace/srv/locsrv/locsrv.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/locsrv/locsrv.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -412,5 +412,5 @@
 {
 	if (server == NULL)
-		return EEXISTS;
+		return EEXIST;
 	
 	fibril_mutex_lock(&servers_list_mutex);
@@ -467,7 +467,4 @@
 	}
 	
-	/* Set the interface, if any. */
-	service->forward_interface = IPC_GET_ARG1(*icall);
-
 	/* Get fqsn */
 	char *fqsn;
@@ -514,5 +511,5 @@
 		free(service->name);
 		free(service);
-		async_answer_0(iid, EEXISTS);
+		async_answer_0(iid, EEXIST);
 		return;
 	}
@@ -702,5 +699,5 @@
  *
  */
-static void loc_forward(ipc_callid_t callid, ipc_call_t *call)
+static void loc_forward(ipc_callid_t callid, ipc_call_t *call, void *arg)
 {
 	fibril_mutex_lock(&services_list_mutex);
@@ -709,4 +706,5 @@
 	 * Get ID from request
 	 */
+	iface_t iface = IPC_GET_ARG1(*call);
 	service_id_t id = IPC_GET_ARG2(*call);
 	loc_service_t *svc = loc_service_find_id(id);
@@ -719,11 +717,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(svc->server->sess);
-	
-	if (svc->forward_interface == 0)
-		async_forward_fast(callid, exch, svc->id, 0, 0, IPC_FF_NONE);
-	else
-		async_forward_fast(callid, exch, svc->forward_interface,
-		    svc->id, 0, IPC_FF_NONE);
-	
+	async_forward_fast(callid, exch, iface, svc->id, 0, IPC_FF_NONE);
 	async_exchange_end(exch);
 	
@@ -959,5 +951,5 @@
 	    loc_namespace_find_id(IPC_GET_ARG1(*icall));
 	if (namespace == NULL)
-		async_answer_0(iid, EEXISTS);
+		async_answer_0(iid, EEXIST);
 	else
 		async_answer_1(iid, EOK, namespace->refcnt);
@@ -1382,5 +1374,5 @@
  *
  */
-static void loc_connection_supplier(ipc_callid_t iid, ipc_call_t *icall)
+static void loc_connection_supplier(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
 	/* Accept connection */
@@ -1440,5 +1432,5 @@
  *
  */
-static void loc_connection_consumer(ipc_callid_t iid, ipc_call_t *icall)
+static void loc_connection_consumer(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
 	/* Accept connection */
@@ -1507,27 +1499,4 @@
 }
 
-/** Function for handling connections to location service
- *
- */
-static void loc_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
-{
-	/* Select interface */
-	switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
-	case LOC_PORT_SUPPLIER:
-		loc_connection_supplier(iid, icall);
-		break;
-	case LOC_PORT_CONSUMER:
-		loc_connection_consumer(iid, icall);
-		break;
-	case LOC_CONNECT_TO_SERVICE:
-		/* Connect client to selected service */
-		loc_forward(iid, icall);
-		break;
-	default:
-		/* No such interface */
-		async_answer_0(iid, ENOENT);
-	}
-}
-
 /**
  *
@@ -1542,12 +1511,23 @@
 	}
 	
-	/* Set a handler of incomming connections */
-	async_set_client_connection(loc_connection);
-	
-	/* Register location service at naming service */
-	int rc = service_register(SERVICE_LOC);
+	port_id_t port;
+	int rc = async_create_port(INTERFACE_LOC_SUPPLIER,
+	    loc_connection_supplier, NULL, &port);
 	if (rc != EOK)
 		return rc;
 	
+	rc = async_create_port(INTERFACE_LOC_CONSUMER,
+	    loc_connection_consumer, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	/* Set a handler of incomming connections */
+	async_set_fallback_port_handler(loc_forward, NULL);
+	
+	/* Register location service at naming service */
+	rc = service_register(SERVICE_LOC);
+	if (rc != EOK)
+		return rc;
+	
 	printf("%s: Accepting connections\n", NAME);
 	async_manager();
Index: uspace/srv/locsrv/locsrv.h
===================================================================
--- uspace/srv/locsrv/locsrv.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/locsrv/locsrv.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -107,7 +107,4 @@
 	/** Supplier of this service */
 	loc_server_t *server;
-	
-	/** Use this interface when forwarding to server. */
-	sysarg_t forward_interface;
 } loc_service_t;
 
Index: uspace/srv/logger/main.c
===================================================================
--- uspace/srv/logger/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/logger/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -48,19 +48,14 @@
 #include "logger.h"
 
-static void connection_handler(ipc_callid_t iid, ipc_call_t *icall, void *arg)
+static void connection_handler_control(ipc_callid_t iid, ipc_call_t *icall,
+    void *arg)
 {
-	logger_interface_t iface = IPC_GET_ARG1(*icall);
+	logger_connection_handler_control(iid);
+}
 
-	switch (iface) {
-	case LOGGER_INTERFACE_CONTROL:
-		logger_connection_handler_control(iid);
-		break;
-	case LOGGER_INTERFACE_WRITER:
-		logger_connection_handler_writer(iid);
-		break;
-	default:
-		async_answer_0(iid, EINVAL);
-		break;
-	}
+static void connection_handler_writer(ipc_callid_t iid, ipc_call_t *icall,
+    void *arg)
+{
+	logger_connection_handler_writer(iid);
 }
 
@@ -73,8 +68,17 @@
 		parse_level_settings(argv[i]);
 	}
-
-	async_set_client_connection(connection_handler);
 	
-	int rc = service_register(SERVICE_LOGGER);
+	port_id_t port;
+	int rc = async_create_port(INTERFACE_LOGGER_CONTROL,
+	    connection_handler_control, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	rc = async_create_port(INTERFACE_LOGGER_WRITER,
+	    connection_handler_writer, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	rc = service_register(SERVICE_LOGGER);
 	if (rc != EOK) {
 		printf(NAME ": failed to register: %s.\n", str_error(rc));
Index: uspace/srv/net/dhcp/main.c
===================================================================
--- uspace/srv/net/dhcp/main.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/dhcp/main.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -65,5 +65,5 @@
 	}
 
-	async_set_client_connection(dhcp_client_conn);
+	async_set_fallback_port_handler(dhcp_client_conn, NULL);
 
 	rc = loc_server_register(NAME);
Index: uspace/srv/net/dnsrsrv/dnsrsrv.c
===================================================================
--- uspace/srv/net/dnsrsrv/dnsrsrv.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/dnsrsrv/dnsrsrv.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -64,5 +64,5 @@
 	}
 
-	async_set_client_connection(dnsr_client_conn);
+	async_set_fallback_port_handler(dnsr_client_conn, NULL);
 
 	rc = loc_server_register(NAME);
Index: uspace/srv/net/ethip/ethip.c
===================================================================
--- uspace/srv/net/ethip/ethip.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/ethip/ethip.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -79,5 +79,5 @@
 static int ethip_init(void)
 {
-	async_set_client_connection(ethip_client_conn);
+	async_set_fallback_port_handler(ethip_client_conn, NULL);
 	
 	int rc = loc_server_register(NAME);
@@ -147,5 +147,5 @@
 	service_id_t sid;
 
-	sid = (service_id_t)IPC_GET_ARG1(*icall);
+	sid = (service_id_t) IPC_GET_ARG2(*icall);
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_client_conn(%u)", (unsigned)sid);
 	nic = ethip_nic_find_by_iplink_sid(sid);
Index: uspace/srv/net/ethip/ethip_nic.c
===================================================================
--- uspace/srv/net/ethip/ethip_nic.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/ethip/ethip_nic.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -162,5 +162,5 @@
 	}
 	
-	nic->sess = loc_service_connect(EXCHANGE_SERIALIZE, sid, 0);
+	nic->sess = loc_service_connect(sid, INTERFACE_DDF, 0);
 	if (nic->sess == NULL) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, "Failed connecting '%s'", nic->svc_name);
Index: uspace/srv/net/inetsrv/addrobj.c
===================================================================
--- uspace/srv/net/inetsrv/addrobj.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/inetsrv/addrobj.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -87,5 +87,5 @@
 		/* Duplicate address name */
 		fibril_mutex_unlock(&addr_list_lock);
-		return EEXISTS;
+		return EEXIST;
 	}
 
Index: uspace/srv/net/inetsrv/inet_link.c
===================================================================
--- uspace/srv/net/inetsrv/inet_link.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/inetsrv/inet_link.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -177,5 +177,5 @@
 	}
 
-	ilink->sess = loc_service_connect(EXCHANGE_SERIALIZE, sid, 0);
+	ilink->sess = loc_service_connect(sid, INTERFACE_IPLINK, 0);
 	if (ilink->sess == NULL) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, "Failed connecting '%s'", ilink->svc_name);
Index: uspace/srv/net/inetsrv/inetsrv.c
===================================================================
--- uspace/srv/net/inetsrv/inetsrv.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/inetsrv/inetsrv.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -77,16 +77,30 @@
 };
 
-static void inet_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg);
-
 static FIBRIL_MUTEX_INITIALIZE(client_list_lock);
 static LIST_INITIALIZE(client_list);
 
+static void inet_default_conn(ipc_callid_t, ipc_call_t *, void *);
+
 static int inet_init(void)
 {
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_init()");
 	
-	async_set_client_connection(inet_client_conn);
-	
-	int rc = loc_server_register(NAME);
+	port_id_t port;
+	int rc = async_create_port(INTERFACE_INET,
+	    inet_default_conn, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	rc = async_create_port(INTERFACE_INETCFG,
+	    inet_cfg_conn, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	rc = async_create_port(INTERFACE_INETPING,
+	    inetping_conn, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	rc = loc_server_register(NAME);
 	if (rc != EOK) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering server (%d).", rc);
@@ -95,20 +109,5 @@
 	
 	service_id_t sid;
-	rc = loc_service_register_with_iface(SERVICE_NAME_INET, &sid,
-	    INET_PORT_DEFAULT);
-	if (rc != EOK) {
-		log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service (%d).", rc);
-		return EEXIST;
-	}
-	
-	rc = loc_service_register_with_iface(SERVICE_NAME_INETCFG, &sid,
-	    INET_PORT_CFG);
-	if (rc != EOK) {
-		log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service (%d).", rc);
-		return EEXIST;
-	}
-	
-	rc = loc_service_register_with_iface(SERVICE_NAME_INETPING, &sid,
-	    INET_PORT_PING);
+	rc = loc_service_register(SERVICE_NAME_INET, &sid);
 	if (rc != EOK) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service (%d).", rc);
@@ -429,26 +428,4 @@
 }
 
-static void inet_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
-{
-	sysarg_t port;
-
-	port = IPC_GET_ARG1(*icall);
-
-	switch (port) {
-	case INET_PORT_DEFAULT:
-		inet_default_conn(iid, icall, arg);
-		break;
-	case INET_PORT_CFG:
-		inet_cfg_conn(iid, icall, arg);
-		break;
-	case INET_PORT_PING:
-		inetping_conn(iid, icall, arg);
-		break;
-	default:
-		async_answer_0(iid, ENOTSUP);
-		break;
-	}
-}
-
 static inet_client_t *inet_client_find(uint8_t proto)
 {
Index: uspace/srv/net/loopip/loopip.c
===================================================================
--- uspace/srv/net/loopip/loopip.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/loopip/loopip.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -100,5 +100,5 @@
 static int loopip_init(void)
 {
-	async_set_client_connection(loopip_client_conn);
+	async_set_fallback_port_handler(loopip_client_conn, NULL);
 	
 	int rc = loc_server_register(NAME);
Index: uspace/srv/net/nconfsrv/nconfsrv.c
===================================================================
--- uspace/srv/net/nconfsrv/nconfsrv.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/nconfsrv/nconfsrv.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -77,5 +77,5 @@
 	}
 
-	async_set_client_connection(ncs_client_conn);
+	async_set_fallback_port_handler(ncs_client_conn, NULL);
 
 	rc = loc_server_register(NAME);
Index: uspace/srv/net/slip/slip.c
===================================================================
--- uspace/srv/net/slip/slip.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/slip/slip.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -300,5 +300,5 @@
 	slip_iplink.ops = &slip_iplink_ops;
 
-	async_set_client_connection(slip_client_conn);
+	async_set_fallback_port_handler(slip_client_conn, NULL);
 
 	rc = loc_server_register(NAME);
@@ -328,5 +328,5 @@
 	 * char_dev at the same time.
 	 */
-	sess_out = loc_service_connect(EXCHANGE_SERIALIZE, svcid, 0);
+	sess_out = loc_service_connect(svcid, INTERFACE_DDF, 0);
 	if (!sess_out) {
 		log_msg(LOG_DEFAULT, LVL_ERROR,
@@ -337,5 +337,5 @@
 	slip_iplink.arg = sess_out;
 
-	sess_in = loc_service_connect(EXCHANGE_SERIALIZE, svcid, 0);
+	sess_in = loc_service_connect(svcid, INTERFACE_DDF, 0);
 	if (!sess_in) {
 		log_msg(LOG_DEFAULT, LVL_ERROR,
Index: uspace/srv/net/tcp/conn.c
===================================================================
--- uspace/srv/net/tcp/conn.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/tcp/conn.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -1223,5 +1223,5 @@
 		rc = amap_insert(amap, &conn->ident, conn, af_allow_system, &aepp);
 		if (rc != EOK) {
-			assert(rc != EEXISTS);
+			assert(rc != EEXIST);
 			assert(rc == ENOMEM);
 			log_msg(LOG_DEFAULT, LVL_ERROR, "Out of memory.");
Index: uspace/srv/net/tcp/service.c
===================================================================
--- uspace/srv/net/tcp/service.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/tcp/service.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup udp
+/** @addtogroup tcp
  * @{
  */
@@ -44,4 +44,5 @@
 #include <loc.h>
 #include <macros.h>
+#include <mem.h>
 #include <stdlib.h>
 
@@ -53,4 +54,5 @@
 #define NAME "tcp"
 
+/** Maximum amount of data transferred in one send call */
 #define MAX_MSG_SIZE DATA_XFER_LIMIT
 
@@ -67,4 +69,5 @@
 static int tcp_cconn_create(tcp_client_t *, tcp_conn_t *, tcp_cconn_t **);
 
+/** Connection callbacks to tie us to lower layer */
 static tcp_cb_t tcp_service_cb = {
 	.cstate_change = tcp_service_cstate_change,
@@ -72,4 +75,5 @@
 };
 
+/** Sentinel connection callbacks to tie us to lower layer */
 static tcp_cb_t tcp_service_lst_cb = {
 	.cstate_change = tcp_service_lst_cstate_change,
@@ -77,4 +81,10 @@
 };
 
+/** Connection state has changed.
+ *
+ * @param conn      Connection
+ * @param arg       Argument (not used)
+ * @param old_state Previous connection state
+ */
 static void tcp_service_cstate_change(tcp_conn_t *conn, void *arg,
     tcp_cstate_t old_state)
@@ -108,4 +118,10 @@
 }
 
+/** Sentinel connection state has changed.
+ *
+ * @param conn      Connection
+ * @param arg       Argument (not used)
+ * @param old_state Previous connection state
+ */
 static void tcp_service_lst_cstate_change(tcp_conn_t *conn, void *arg,
     tcp_cstate_t old_state)
@@ -169,4 +185,9 @@
 }
 
+/** Received data became available on connection.
+ *
+ * @param conn Connection
+ * @param arg  Client connection
+ */
 static void tcp_service_recv_data(tcp_conn_t *conn, void *arg)
 {
@@ -176,4 +197,8 @@
 }
 
+/** Send 'data' event to client.
+ *
+ * @param cconn Client connection
+ */
 static void tcp_ev_data(tcp_cconn_t *cconn)
 {
@@ -192,4 +217,8 @@
 }
 
+/** Send 'connected' event to client.
+ *
+ * @param cconn Client connection
+ */
 static void tcp_ev_connected(tcp_cconn_t *cconn)
 {
@@ -205,4 +234,8 @@
 }
 
+/** Send 'conn_failed' event to client.
+ *
+ * @param cconn Client connection
+ */
 static void tcp_ev_conn_failed(tcp_cconn_t *cconn)
 {
@@ -218,4 +251,8 @@
 }
 
+/** Send 'conn_reset' event to client.
+ *
+ * @param cconn Client connection
+ */
 static void tcp_ev_conn_reset(tcp_cconn_t *cconn)
 {
@@ -231,5 +268,9 @@
 }
 
-/** New incoming connection */
+/** Send 'new_conn' event to client.
+ *
+ * @param clst Client listener that received the connection
+ * @param cconn New client connection
+ */
 static void tcp_ev_new_conn(tcp_clst_t *clst, tcp_cconn_t *cconn)
 {
@@ -246,4 +287,14 @@
 }
 
+/** Create client connection.
+ *
+ * This effectively adds a connection into a client's namespace.
+ *
+ * @param client TCP client
+ * @param conn   Connection
+ * @param rcconn Place to store pointer to new client connection
+ *
+ * @return EOK on success or ENOMEM if out of memory
+ */
 static int tcp_cconn_create(tcp_client_t *client, tcp_conn_t *conn,
     tcp_cconn_t **rcconn)
@@ -272,4 +323,8 @@
 }
 
+/** Destroy client connection.
+ *
+ * @param cconn Client connection
+ */
 static void tcp_cconn_destroy(tcp_cconn_t *cconn)
 {
@@ -278,4 +333,15 @@
 }
 
+/** Create client listener.
+ *
+ * Create client listener based on sentinel connection.
+ * XXX Implement actual listener in protocol core
+ *
+ * @param client TCP client
+ * @param conn   Sentinel connection
+ * @param rclst  Place to store pointer to new client listener
+ *
+ * @return EOK on success or ENOMEM if out of memory
+ */
 static int tcp_clistener_create(tcp_client_t *client, tcp_conn_t *conn,
     tcp_clst_t **rclst)
@@ -304,4 +370,8 @@
 }
 
+/** Destroy client listener.
+ *
+ * @param clst Client listener
+ */
 static void tcp_clistener_destroy(tcp_clst_t *clst)
 {
@@ -310,4 +380,13 @@
 }
 
+/** Get client connection by ID.
+ *
+ * @param client Client
+ * @param id     Client connection ID
+ * @param rcconn Place to store pointer to client connection
+ *
+ * @return EOK on success, ENOENT if no client connection with the given ID
+ *         is found.
+ */
 static int tcp_cconn_get(tcp_client_t *client, sysarg_t id,
     tcp_cconn_t **rcconn)
@@ -323,4 +402,13 @@
 }
 
+/** Get client listener by ID.
+ *
+ * @param client Client
+ * @param id     Client connection ID
+ * @param rclst  Place to store pointer to client listener
+ *
+ * @return EOK on success, ENOENT if no client listener with the given ID
+ *         is found.
+ */
 static int tcp_clistener_get(tcp_client_t *client, sysarg_t id,
     tcp_clst_t **rclst)
@@ -336,5 +424,14 @@
 }
 
-
+/** Create connection.
+ *
+ * Handle client request to create connection (with parameters unmarshalled).
+ *
+ * @param client   TCP client
+ * @param epp      Endpoint pair
+ * @param rconn_id Place to store ID of new connection
+ *
+ * @return EOK on success or negative error code
+ */
 static int tcp_conn_create_impl(tcp_client_t *client, inet_ep2_t *epp,
     sysarg_t *rconn_id)
@@ -376,4 +473,12 @@
 }
 
+/** Destroy connection.
+ *
+ * Handle client request to destroy connection (with parameters unmarshalled).
+ *
+ * @param client  TCP client
+ * @param conn_id Connection ID
+ * @return EOK on success, ENOENT if no such connection is found
+ */
 static int tcp_conn_destroy_impl(tcp_client_t *client, sysarg_t conn_id)
 {
@@ -393,4 +498,14 @@
 }
 
+/** Create listener.
+ *
+ * Handle client request to create listener (with parameters unmarshalled).
+ *
+ * @param client  TCP client
+ * @param ep      Endpoint
+ * @param rlst_id Place to store ID of new listener
+ *
+ * @return EOK on success or negative error code
+*/
 static int tcp_listener_create_impl(tcp_client_t *client, inet_ep_t *ep,
     sysarg_t *rlst_id)
@@ -430,4 +545,13 @@
 }
 
+/** Destroy listener.
+ *
+ * Handle client request to destroy listener (with parameters unmarshalled).
+ *
+ * @param client TCP client
+ * @param lst_id Listener ID
+ *
+ * @return EOK on success, ENOENT if no such listener is found
+ */
 static int tcp_listener_destroy_impl(tcp_client_t *client, sysarg_t lst_id)
 {
@@ -446,4 +570,13 @@
 }
 
+/** Send FIN.
+ *
+ * Handle client request to send FIN (with parameters unmarshalled).
+ *
+ * @param client  TCP client
+ * @param conn_id Connection ID
+ *
+ * @return EOK on success or negative error code
+ */
 static int tcp_conn_send_fin_impl(tcp_client_t *client, sysarg_t conn_id)
 {
@@ -462,4 +595,13 @@
 }
 
+/** Push connection.
+ *
+ * Handle client request to push connection (with parameters unmarshalled).
+ *
+ * @param client  TCP client
+ * @param conn_id Connection ID
+ *
+ * @return EOK on success or negative error code
+ */
 static int tcp_conn_push_impl(tcp_client_t *client, sysarg_t conn_id)
 {
@@ -478,4 +620,13 @@
 }
 
+/** Reset connection.
+ *
+ * Handle client request to reset connection (with parameters unmarshalled).
+ *
+ * @param client  TCP client
+ * @param conn_id Connection ID
+ *
+ * @return EOK on success or negative error code
+ */
 static int tcp_conn_reset_impl(tcp_client_t *client, sysarg_t conn_id)
 {
@@ -493,4 +644,15 @@
 }
 
+/** Send data over connection..
+ *
+ * Handle client request to send data (with parameters unmarshalled).
+ *
+ * @param client  TCP client
+ * @param conn_id Connection ID
+ * @param data    Data buffer
+ * @param size    Data size in bytes
+ *
+ * @return EOK on success or negative error code
+ */
 static int tcp_conn_send_impl(tcp_client_t *client, sysarg_t conn_id,
     void *data, size_t size)
@@ -510,4 +672,16 @@
 }
 
+/** Receive data from connection.
+ *
+ * Handle client request to receive data (with parameters unmarshalled).
+ *
+ * @param client  TCP client
+ * @param conn_id Connection ID
+ * @param data    Data buffer
+ * @param size    Buffer size in bytes
+ * @param nrecv   Place to store actual number of bytes received
+ *
+ * @return EOK on success or negative error code
+ */
 static int tcp_conn_recv_impl(tcp_client_t *client, sysarg_t conn_id,
     void *data, size_t size, size_t *nrecv)
@@ -540,4 +714,12 @@
 }
 
+/** Create client callback session.
+ *
+ * Handle client request to create callback session.
+ *
+ * @param client  TCP client
+ * @param iid     Async request ID
+ * @param icall   Async request data
+ */
 static void tcp_callback_create_srv(tcp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -555,4 +737,12 @@
 }
 
+/** Create connection.
+ *
+ * Handle client request to create connection.
+ *
+ * @param client   TCP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void tcp_conn_create_srv(tcp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -594,4 +784,12 @@
 }
 
+/** Destroy connection.
+ *
+ * Handle client request to destroy connection.
+ *
+ * @param client   TCP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void tcp_conn_destroy_srv(tcp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -607,4 +805,12 @@
 }
 
+/** Create listener.
+ *
+ * Handle client request to create listener.
+ *
+ * @param client   TCP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void tcp_listener_create_srv(tcp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -646,4 +852,12 @@
 }
 
+/** Destroy listener.
+ *
+ * Handle client request to destroy listener.
+ *
+ * @param client   TCP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void tcp_listener_destroy_srv(tcp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -659,4 +873,12 @@
 }
 
+/** Send FIN.
+ *
+ * Handle client request to send FIN.
+ *
+ * @param client   TCP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void tcp_conn_send_fin_srv(tcp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -672,4 +894,12 @@
 }
 
+/** Push connection.
+ *
+ * Handle client request to push connection.
+ *
+ * @param client   TCP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void tcp_conn_push_srv(tcp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -685,4 +915,12 @@
 }
 
+/** Reset connection.
+ *
+ * Handle client request to reset connection.
+ *
+ * @param client   TCP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void tcp_conn_reset_srv(tcp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -698,4 +936,12 @@
 }
 
+/** Send data via connection..
+ *
+ * Handle client request to send data via connection.
+ *
+ * @param client   TCP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void tcp_conn_send_srv(tcp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -750,4 +996,12 @@
 }
 
+/** Read received data from connection without blocking.
+ *
+ * Handle client request to read received data via connection without blocking.
+ *
+ * @param client   TCP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void tcp_conn_recv_srv(tcp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -798,4 +1052,12 @@
 }
 
+/** Read received data from connection with blocking.
+ *
+ * Handle client request to read received data via connection with blocking.
+ *
+ * @param client   TCP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void tcp_conn_recv_wait_srv(tcp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -851,6 +1113,8 @@
 }
 
-#include <mem.h>
-
+/** Initialize TCP client structure.
+ *
+ * @param client TCP client
+ */
 static void tcp_client_init(tcp_client_t *client)
 {
@@ -861,12 +1125,16 @@
 }
 
+/** Finalize TCP client structure.
+ *
+ * @param client TCP client
+ */
 static void tcp_client_fini(tcp_client_t *client)
 {
 	tcp_cconn_t *cconn;
-	size_t n;
+	unsigned long n;
 
 	n = list_count(&client->cconn);
 	if (n != 0) {
-		log_msg(LOG_DEFAULT, LVL_WARN, "Client with %zu active "
+		log_msg(LOG_DEFAULT, LVL_WARN, "Client with %lu active "
 		    "connections closed session", n);
 
@@ -882,5 +1150,5 @@
 	n = list_count(&client->clst);
 	if (n != 0) {
-		log_msg(LOG_DEFAULT, LVL_WARN, "Client with %zu active "
+		log_msg(LOG_DEFAULT, LVL_WARN, "Client with %lu active "
 		    "listeners closed session", n);
 		/* XXX Destroy listeners */
@@ -891,4 +1159,10 @@
 }
 
+/** Handle TCP client connection.
+ *
+ * @param iid   Connect call ID
+ * @param icall Connect call data
+ * @param arg   Connection argument
+ */
 static void tcp_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
@@ -961,4 +1235,8 @@
 }
 
+/** Initialize TCP service.
+ *
+ * @return EOK on success or negative error code.
+ */
 int tcp_service_init(void)
 {
@@ -966,5 +1244,5 @@
 	service_id_t sid;
 
-	async_set_client_connection(tcp_client_conn);
+	async_set_fallback_port_handler(tcp_client_conn, NULL);
 
 	rc = loc_server_register(NAME);
Index: uspace/srv/net/tcp/tcp_type.h
===================================================================
--- uspace/srv/net/tcp/tcp_type.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/tcp/tcp_type.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -47,4 +47,5 @@
 struct tcp_conn;
 
+/** Connection state */
 typedef enum {
 	/** Listen */
@@ -101,4 +102,5 @@
 } tcp_error_t;
 
+/** Transfer flags */
 typedef enum {
 	XF_PUSH		= 0x1,
@@ -106,4 +108,8 @@
 } xflags_t;
 
+/** Control message bits
+ *
+ * Note this is not the actual on-the-wire encoding
+ */
 typedef enum {
 	CTL_SYN		= 0x1,
@@ -128,4 +134,5 @@
 } tcp_tqueue_t;
 
+/** Active or passive connection */
 typedef enum {
 	ap_active,
@@ -133,4 +140,5 @@
 } acpass_t;
 
+/** Flags for TCP open operation */
 typedef enum {
 	tcp_open_nonblock = 1
@@ -264,5 +272,5 @@
 } tcp_segment_t;
 
-
+/** Receive queue entry */
 typedef struct {
 	link_t link;
@@ -279,4 +287,5 @@
 } tcp_squeue_entry_t;
 
+/** Incoming queue entry */
 typedef struct {
 	link_t link;
@@ -291,4 +300,9 @@
 } tcp_tqueue_entry_t;
 
+/** Continuation of processing.
+ *
+ * When processing incoming segment, are we done or should we continue
+ * processing it?
+ */
 typedef enum {
 	cp_continue,
Index: uspace/srv/net/udp/service.c
===================================================================
--- uspace/srv/net/udp/service.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/udp/service.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -52,12 +52,22 @@
 #define NAME "udp"
 
+/** Maximum message size */
 #define MAX_MSG_SIZE DATA_XFER_LIMIT
 
 static void udp_cassoc_recv_msg(void *, inet_ep2_t *, udp_msg_t *);
 
+/** Callbacks to tie us to association layer */
 static udp_assoc_cb_t udp_cassoc_cb = {
 	.recv_msg = udp_cassoc_recv_msg
 };
 
+/** Add message to client receive queue.
+ *
+ * @param cassoc Client association
+ * @param epp    Endpoint pair on which message was received
+ * @param msg    Message
+ *
+ * @return EOK on success, ENOMEM if out of memory
+ */
 static int udp_cassoc_queue_msg(udp_cassoc_t *cassoc, inet_ep2_t *epp,
     udp_msg_t *msg)
@@ -86,4 +96,8 @@
 }
 
+/** Send 'data' event to client.
+ *
+ * @param client Client
+ */
 static void udp_ev_data(udp_client_t *client)
 {
@@ -99,4 +113,14 @@
 }
 
+/** Create client association.
+ *
+ * This effectively adds an association into a client's namespace.
+ *
+ * @param client  Client
+ * @param assoc   Association
+ * @param rcassoc Place to store pointer to new client association
+ *
+ * @return EOK on soccess, ENOMEM if out of memory
+ */
 static int udp_cassoc_create(udp_client_t *client, udp_assoc_t *assoc,
     udp_cassoc_t **rcassoc)
@@ -125,4 +149,8 @@
 }
 
+/** Destroy client association.
+ *
+ * @param cassoc Client association
+ */
 static void udp_cassoc_destroy(udp_cassoc_t *cassoc)
 {
@@ -131,4 +159,13 @@
 }
 
+/** Get client association by ID.
+ *
+ * @param client  Client
+ * @param id      Client association ID
+ * @param rcassoc Place to store pointer to client association
+ *
+ * @return EOK on success, ENOENT if no client association with the given ID
+ *         is found.
+ */
 static int udp_cassoc_get(udp_client_t *client, sysarg_t id,
     udp_cassoc_t **rcassoc)
@@ -144,4 +181,12 @@
 }
 
+/** Message received on client association.
+ *
+ * Used as udp_assoc_cb.recv_msg callback.
+ *
+ * @param arg Callback argument, client association
+ * @param epp Endpoint pair where message was received
+ * @param msg Message
+ */
 static void udp_cassoc_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg)
 {
@@ -152,4 +197,14 @@
 }
 
+/** Create association.
+ *
+ * Handle client request to create association (with parameters unmarshalled).
+ *
+ * @param client    UDP client
+ * @param epp       Endpoint pair
+ * @param rassoc_id Place to store ID of new association
+ *
+ * @return EOK on success or negative error code
+ */
 static int udp_assoc_create_impl(udp_client_t *client, inet_ep2_t *epp,
     sysarg_t *rassoc_id)
@@ -189,4 +244,12 @@
 }
 
+/** Destroy association.
+ *
+ * Handle client request to destroy association (with parameters unmarshalled).
+ *
+ * @param client   UDP client
+ * @param assoc_id Association ID
+ * @return EOK on success, ENOENT if no such association is found
+ */
 static int udp_assoc_destroy_impl(udp_client_t *client, sysarg_t assoc_id)
 {
@@ -207,4 +270,17 @@
 }
 
+/** Send message via association.
+ *
+ * Handle client request to send message (with parameters unmarshalled).
+ *
+ * @param client   UDP client
+ * @param assoc_id Association ID
+ * @param dest     Destination endpoint or @c NULL to use the default from
+ *                 association
+ * @param data     Message data
+ * @param size     Message size
+ *
+ * @return EOK on success or negative error code
+ */
 static int udp_assoc_send_msg_impl(udp_client_t *client, sysarg_t assoc_id,
     inet_ep_t *dest, void *data, size_t size)
@@ -227,4 +303,12 @@
 }
 
+/** Create callback session.
+ *
+ * Handle client request to create callback session.
+ *
+ * @param client   UDP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void udp_callback_create_srv(udp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -242,4 +326,12 @@
 }
 
+/** Create association.
+ *
+ * Handle client request to create association.
+ *
+ * @param client   UDP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void udp_assoc_create_srv(udp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -281,4 +373,12 @@
 }
 
+/** Destroy association.
+ *
+ * Handle client request to destroy association.
+ *
+ * @param client   UDP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void udp_assoc_destroy_srv(udp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -294,4 +394,12 @@
 }
 
+/** Send message via association.
+ *
+ * Handle client request to send message.
+ *
+ * @param client   UDP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void udp_assoc_send_msg_srv(udp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -368,4 +476,9 @@
 }
 
+/** Get next received message.
+ *
+ * @param client UDP Client
+ * @return Pointer to queue entry for next received message
+ */
 static udp_crcv_queue_entry_t *udp_rmsg_get_next(udp_client_t *client)
 {
@@ -379,4 +492,12 @@
 }
 
+/** Get info on first received message.
+ *
+ * Handle client request to get information on received message.
+ *
+ * @param client   UDP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void udp_rmsg_info_srv(udp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -418,4 +539,12 @@
 }
 
+/** Read data from first received message.
+ *
+ * Handle client request to read data from first received message.
+ *
+ * @param client   UDP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void udp_rmsg_read_srv(udp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -460,4 +589,13 @@
 }
 
+/** Discard first received message.
+ *
+ * Handle client request to discard first received message, advancing
+ * to the next one.
+ *
+ * @param client   UDP client
+ * @param iid      Async request ID
+ * @param icall    Async request data
+ */
 static void udp_rmsg_discard_srv(udp_client_t *client, ipc_callid_t iid,
     ipc_call_t *icall)
@@ -480,8 +618,14 @@
 }
 
+/** Handle UDP client connection.
+ *
+ * @param iid   Connect call ID
+ * @param icall Connect call data
+ * @param arg   Connection argument
+ */
 static void udp_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
 	udp_client_t client;
-	size_t n;
+	unsigned long n;
 
 	/* Accept the connection */
@@ -541,5 +685,5 @@
 	if (n != 0) {
 		log_msg(LOG_DEFAULT, LVL_WARN, "udp_client_conn: "
-		    "Client with %zu active associations closed session.", n);
+		    "Client with %lu active associations closed session.", n);
 		/* XXX Clean up */
 	}
@@ -551,4 +695,8 @@
 }
 
+/** Initialize UDP service.
+ *
+ * @return EOK on success or negative error code.
+ */
 int udp_service_init(void)
 {
@@ -556,5 +704,5 @@
 	service_id_t sid;
 
-	async_set_client_connection(udp_client_conn);
+	async_set_fallback_port_handler(udp_client_conn, NULL);
 
 	rc = loc_server_register(NAME);
Index: uspace/srv/net/udp/udp_type.h
===================================================================
--- uspace/srv/net/udp/udp_type.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/net/udp/udp_type.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -46,4 +46,5 @@
 #define UDP_FRAGMENT_SIZE 65535
 
+/** UDP error codes */
 typedef enum {
 	UDP_EOK,
@@ -84,5 +85,7 @@
 } udp_pdu_t;
 
+/** Association callbacks */
 typedef struct {
+	/** Message received */
 	void (*recv_msg)(void *, inet_ep2_t *, udp_msg_t *);
 } udp_assoc_cb_t;
@@ -124,4 +127,5 @@
 } udp_assoc_status_t;
 
+/** UDP receive queue entry */
 typedef struct {
 	/** Link to receive queue */
@@ -133,4 +137,8 @@
 } udp_rcv_queue_entry_t;
 
+/** UDP client association.
+ *
+ * Ties a UDP association into the namespace of a client
+ */
 typedef struct udp_cassoc {
 	/** Association */
@@ -143,4 +151,5 @@
 } udp_cassoc_t;
 
+/** UDP client receive queue entry */
 typedef struct {
 	/** Link to receive queue */
@@ -154,4 +163,5 @@
 } udp_crcv_queue_entry_t;
 
+/** UDP client */
 typedef struct udp_client {
 	/** Client callback session */
Index: uspace/srv/ns/clonable.c
===================================================================
--- uspace/srv/ns/clonable.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/ns/clonable.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -46,7 +46,8 @@
 typedef struct {
 	link_t link;
-	sysarg_t service;
-	ipc_call_t call;
+	service_t service;
+	iface_t iface;
 	ipc_callid_t callid;
+	sysarg_t arg3;
 } cs_req_t;
 
@@ -61,7 +62,7 @@
 
 /** Return true if @a service is clonable. */
-bool service_clonable(int service)
+bool service_clonable(service_t service)
 {
-	return (service == SERVICE_LOAD);
+	return (service == SERVICE_LOADER);
 }
 
@@ -73,10 +74,8 @@
  *
  */
-void register_clonable(sysarg_t service, sysarg_t phone, ipc_call_t *call,
+void register_clonable(service_t service, sysarg_t phone, ipc_call_t *call,
     ipc_callid_t callid)
 {
-	link_t *req_link;
-
-	req_link = list_first(&cs_req);
+	link_t *req_link = list_first(&cs_req);
 	if (req_link == NULL) {
 		/* There was no pending connection request. */
@@ -90,10 +89,10 @@
 	
 	/* Currently we can only handle a single type of clonable service. */
-	assert(csr->service == SERVICE_LOAD);
+	assert(csr->service == SERVICE_LOADER);
 	
 	ipc_answer_0(callid, EOK);
 	
-	ipc_forward_fast(csr->callid, phone, IPC_GET_ARG2(csr->call),
-	    IPC_GET_ARG3(csr->call), 0, IPC_FF_NONE);
+	ipc_forward_fast(csr->callid, phone, csr->iface, csr->arg3, 0,
+	    IPC_FF_NONE);
 	
 	free(csr);
@@ -104,4 +103,5 @@
  *
  * @param service Service to be connected to.
+ * @param iface   Interface to be connected to.
  * @param call    Pointer to call structure.
  * @param callid  Call ID of the request.
@@ -110,8 +110,8 @@
  *
  */
-void connect_to_clonable(sysarg_t service, ipc_call_t *call,
+void connect_to_clonable(service_t service, iface_t iface, ipc_call_t *call,
     ipc_callid_t callid)
 {
-	assert(service == SERVICE_LOAD);
+	assert(service == SERVICE_LOADER);
 	
 	cs_req_t *csr = malloc(sizeof(cs_req_t));
@@ -132,6 +132,7 @@
 	link_initialize(&csr->link);
 	csr->service = service;
-	csr->call = *call;
+	csr->iface = iface;
 	csr->callid = callid;
+	csr->arg3 = IPC_GET_ARG3(*call);
 	
 	/*
Index: uspace/srv/ns/clonable.h
===================================================================
--- uspace/srv/ns/clonable.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/ns/clonable.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,11 +36,14 @@
 #include <ipc/common.h>
 #include <sys/types.h>
+#include <ipc/services.h>
+#include <abi/ipc/interfaces.h>
 #include <stdbool.h>
 
 extern int clonable_init(void);
 
-extern bool service_clonable(int);
-extern void register_clonable(sysarg_t, sysarg_t, ipc_call_t *, ipc_callid_t);
-extern void connect_to_clonable(sysarg_t, ipc_call_t *, ipc_callid_t);
+extern bool service_clonable(service_t);
+extern void register_clonable(service_t, sysarg_t, ipc_call_t *,
+    ipc_callid_t);
+extern void connect_to_clonable(service_t, iface_t, ipc_call_t *, ipc_callid_t);
 
 #endif
Index: uspace/srv/ns/ns.c
===================================================================
--- uspace/srv/ns/ns.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/ns/ns.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -38,4 +38,6 @@
 #include <ipc/ipc.h>
 #include <ipc/ns.h>
+#include <ipc/services.h>
+#include <abi/ipc/interfaces.h>
 #include <stdio.h>
 #include <errno.h>
@@ -73,4 +75,8 @@
 		sysarg_t retval;
 		
+		iface_t iface;
+		service_t service;
+		sysarg_t phone;
+		
 		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
@@ -78,27 +84,29 @@
 			break;
 		case IPC_M_CONNECT_TO_ME:
+			service = IPC_GET_ARG2(call);
+			phone = IPC_GET_ARG5(call);
+			
 			/*
 			 * Server requests service registration.
 			 */
-			if (service_clonable(IPC_GET_ARG1(call))) {
-				register_clonable(IPC_GET_ARG1(call),
-				    IPC_GET_ARG5(call), &call, callid);
+			if (service_clonable(service)) {
+				register_clonable(service, phone, &call, callid);
 				continue;
-			} else {
-				retval = register_service(IPC_GET_ARG1(call),
-				    IPC_GET_ARG5(call), &call);
-			}
+			} else
+				retval = register_service(service, phone, &call);
+			
 			break;
 		case IPC_M_CONNECT_ME_TO:
+			iface = IPC_GET_ARG1(call);
+			service = IPC_GET_ARG2(call);
+			
 			/*
 			 * Client requests to be connected to a service.
 			 */
-			if (service_clonable(IPC_GET_ARG1(call))) {
-				connect_to_clonable(IPC_GET_ARG1(call),
-				    &call, callid);
+			if (service_clonable(service)) {
+				connect_to_clonable(service, iface, &call, callid);
 				continue;
 			} else {
-				connect_to_service(IPC_GET_ARG1(call), &call,
-				    callid);
+				connect_to_service(service, iface, &call, callid);
 				continue;
 			}
Index: uspace/srv/ns/service.c
===================================================================
--- uspace/srv/ns/service.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/ns/service.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -40,29 +40,37 @@
 #include "ns.h"
 
-
 /** Service hash table item. */
 typedef struct {
 	ht_link_t link;
-	sysarg_t service;        /**< Service ID. */
-	sysarg_t phone;          /**< Phone registered with the service. */
-	sysarg_t in_phone_hash;  /**< Incoming phone hash. */
+	
+	/** Service ID */
+	service_t service;
+	
+	/** Phone registered with the interface */
+	sysarg_t phone;
+	
+	/** Incoming phone hash */
+	sysarg_t in_phone_hash;
 } hashed_service_t;
 
-
 static size_t service_key_hash(void *key)
 {
-	return *(sysarg_t*)key;
+	return *(service_t *) key;
 }
 
 static size_t service_hash(const ht_link_t *item)
 {
-	hashed_service_t *hs = hash_table_get_inst(item, hashed_service_t, link);
-	return hs->service;
+	hashed_service_t *service =
+	    hash_table_get_inst(item, hashed_service_t, link);
+	
+	return service->service;
 }
 
 static bool service_key_equal(void *key, const ht_link_t *item)
 {
-	hashed_service_t *hs = hash_table_get_inst(item, hashed_service_t, link);
-	return hs->service == *(sysarg_t*)key;
+	hashed_service_t *service =
+	    hash_table_get_inst(item, hashed_service_t, link);
+	
+	return service->service == *(service_t *) key;
 }
 
@@ -82,8 +90,8 @@
 typedef struct {
 	link_t link;
-	sysarg_t service;        /**< Number of the service. */
-	ipc_callid_t callid;     /**< Call ID waiting for the connection */
-	sysarg_t arg2;           /**< Second argument */
-	sysarg_t arg3;           /**< Third argument */
+	service_t service;    /**< Service ID */
+	iface_t iface;        /**< Interface ID */
+	ipc_callid_t callid;  /**< Call ID waiting for the connection */
+	sysarg_t arg3;        /**< Third argument */
 } pending_conn_t;
 
@@ -92,6 +100,7 @@
 int service_init(void)
 {
-	if (!hash_table_create(&service_hash_table, 0, 0, &service_hash_table_ops)) {
-		printf(NAME ": No memory available for services\n");
+	if (!hash_table_create(&service_hash_table, 0, 0,
+	    &service_hash_table_ops)) {
+		printf("%s: No memory available for services\n", NAME);
 		return ENOMEM;
 	}
@@ -106,15 +115,16 @@
 {
 loop:
-	list_foreach(pending_conn, link, pending_conn_t, pr) {
-		ht_link_t *link = hash_table_find(&service_hash_table, &pr->service);
+	list_foreach(pending_conn, link, pending_conn_t, pending) {
+		ht_link_t *link = hash_table_find(&service_hash_table, &pending->service);
 		if (!link)
 			continue;
 		
-		hashed_service_t *hs = hash_table_get_inst(link, hashed_service_t, link);
-		(void) ipc_forward_fast(pr->callid, hs->phone, pr->arg2,
-		    pr->arg3, 0, IPC_FF_NONE);
-		
-		list_remove(&pr->link);
-		free(pr);
+		hashed_service_t *hashed_service = hash_table_get_inst(link, hashed_service_t, link);
+		(void) ipc_forward_fast(pending->callid, hashed_service->phone,
+		    pending->iface, pending->arg3, 0, IPC_FF_NONE);
+		
+		list_remove(&pending->link);
+		free(pending);
+		
 		goto loop;
 	}
@@ -130,17 +140,19 @@
  *
  */
-int register_service(sysarg_t service, sysarg_t phone, ipc_call_t *call)
+int register_service(service_t service, sysarg_t phone, ipc_call_t *call)
 {
 	if (hash_table_find(&service_hash_table, &service))
-		return EEXISTS;
-	
-	hashed_service_t *hs = (hashed_service_t *) malloc(sizeof(hashed_service_t));
-	if (!hs)
+		return EEXIST;
+	
+	hashed_service_t *hashed_service =
+	    (hashed_service_t *) malloc(sizeof(hashed_service_t));
+	if (!hashed_service)
 		return ENOMEM;
 	
-	hs->service = service;
-	hs->phone = phone;
-	hs->in_phone_hash = call->in_phone_hash;
-	hash_table_insert(&service_hash_table, &hs->link);
+	hashed_service->service = service;
+	hashed_service->phone = phone;
+	hashed_service->in_phone_hash = call->in_phone_hash;
+	
+	hash_table_insert(&service_hash_table, &hashed_service->link);
 	
 	return EOK;
@@ -150,4 +162,5 @@
  *
  * @param service Service to be connected to.
+ * @param iface   Interface to be connected to.
  * @param call    Pointer to call structure.
  * @param callid  Call ID of the request.
@@ -156,34 +169,39 @@
  *
  */
-void connect_to_service(sysarg_t service, ipc_call_t *call, ipc_callid_t callid)
-{
+void connect_to_service(service_t service, iface_t iface, ipc_call_t *call,
+    ipc_callid_t callid)
+{
+	sysarg_t arg3 = IPC_GET_ARG3(*call);
+	sysarg_t flags = IPC_GET_ARG4(*call);
 	sysarg_t retval;
 	
 	ht_link_t *link = hash_table_find(&service_hash_table, &service);
 	if (!link) {
-		if (IPC_GET_ARG4(*call) & IPC_FLAG_BLOCKING) {
+		if (flags & IPC_FLAG_BLOCKING) {
 			/* Blocking connection, add to pending list */
-			pending_conn_t *pr =
+			pending_conn_t *pending =
 			    (pending_conn_t *) malloc(sizeof(pending_conn_t));
-			if (!pr) {
+			if (!pending) {
 				retval = ENOMEM;
 				goto out;
 			}
 			
-			link_initialize(&pr->link);
-			pr->service = service;
-			pr->callid = callid;
-			pr->arg2 = IPC_GET_ARG2(*call);
-			pr->arg3 = IPC_GET_ARG3(*call);
-			list_append(&pr->link, &pending_conn);
+			link_initialize(&pending->link);
+			pending->service = service;
+			pending->iface = iface;
+			pending->callid = callid;
+			pending->arg3 = arg3;
+			
+			list_append(&pending->link, &pending_conn);
 			return;
 		}
+		
 		retval = ENOENT;
 		goto out;
 	}
 	
-	hashed_service_t *hs = hash_table_get_inst(link, hashed_service_t, link);
-	(void) ipc_forward_fast(callid, hs->phone, IPC_GET_ARG2(*call),
-	    IPC_GET_ARG3(*call), 0, IPC_FF_NONE);
+	hashed_service_t *hashed_service = hash_table_get_inst(link, hashed_service_t, link);
+	(void) ipc_forward_fast(callid, hashed_service->phone, iface, arg3,
+	    0, IPC_FF_NONE);
 	return;
 	
Index: uspace/srv/ns/service.h
===================================================================
--- uspace/srv/ns/service.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/ns/service.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -36,10 +36,12 @@
 #include <sys/types.h>
 #include <ipc/common.h>
+#include <ipc/services.h>
+#include <abi/ipc/interfaces.h>
 
 extern int service_init(void);
 extern void process_pending_conn(void);
 
-extern int register_service(sysarg_t, sysarg_t, ipc_call_t *);
-extern void connect_to_service(sysarg_t, ipc_call_t *, ipc_callid_t);
+extern int register_service(service_t, sysarg_t, ipc_call_t *);
+extern void connect_to_service(service_t, iface_t, ipc_call_t *, ipc_callid_t);
 
 #endif
Index: uspace/srv/ns/task.c
===================================================================
--- uspace/srv/ns/task.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/ns/task.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -231,10 +231,9 @@
 int ns_task_id_intro(ipc_call_t *call)
 {
-	
 	task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call));
-
+	
 	ht_link_t *link = hash_table_find(&phone_to_id, &call->in_phone_hash);
 	if (link != NULL)
-		return EEXISTS;
+		return EEXIST;
 	
 	p2i_entry_t *entry = (p2i_entry_t *) malloc(sizeof(p2i_entry_t));
Index: uspace/srv/taskmon/taskmon.c
===================================================================
--- uspace/srv/taskmon/taskmon.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/taskmon/taskmon.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -147,5 +147,5 @@
 	}
 	
-	async_set_client_connection(corecfg_client_conn);
+	async_set_fallback_port_handler(corecfg_client_conn, NULL);
 	
 	int rc = loc_server_register(NAME);
Index: uspace/srv/vfs/vfs.c
===================================================================
--- uspace/srv/vfs/vfs.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/vfs/vfs.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -74,8 +74,8 @@
 			break;
 		case VFS_IN_MOUNT:
-			vfs_mount(callid, &call);
+			vfs_mount_srv(callid, &call);
 			break;
 		case VFS_IN_UNMOUNT:
-			vfs_unmount(callid, &call);
+			vfs_unmount_srv(callid, &call);
 			break;
 		case VFS_IN_OPEN:
@@ -181,5 +181,5 @@
 	 * Set a connection handling function/fibril.
 	 */
-	async_set_client_connection(vfs_connection);
+	async_set_fallback_port_handler(vfs_connection, NULL);
 
 	/*
Index: uspace/srv/vfs/vfs.h
===================================================================
--- uspace/srv/vfs/vfs.h	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/vfs/vfs.h	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -205,6 +205,6 @@
 
 extern void vfs_register(ipc_callid_t, ipc_call_t *);
-extern void vfs_mount(ipc_callid_t, ipc_call_t *);
-extern void vfs_unmount(ipc_callid_t, ipc_call_t *);
+extern void vfs_mount_srv(ipc_callid_t, ipc_call_t *);
+extern void vfs_unmount_srv(ipc_callid_t, ipc_call_t *);
 extern void vfs_open(ipc_callid_t, ipc_call_t *);
 extern void vfs_sync(ipc_callid_t, ipc_call_t *);
Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/vfs/vfs_ops.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -266,5 +266,5 @@
 }
 
-void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
+void vfs_mount_srv(ipc_callid_t rid, ipc_call_t *request)
 {
 	service_id_t service_id;
@@ -405,5 +405,5 @@
 }
 
-void vfs_unmount(ipc_callid_t rid, ipc_call_t *request)
+void vfs_unmount_srv(ipc_callid_t rid, ipc_call_t *request)
 {
 	int rc;
Index: uspace/srv/vfs/vfs_register.c
===================================================================
--- uspace/srv/vfs/vfs_register.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/vfs/vfs_register.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -113,5 +113,5 @@
 void vfs_register(ipc_callid_t rid, ipc_call_t *request)
 {
-	dprintf("Processing VFS_REGISTER request received from %p.\n",
+	dprintf("Processing VFS_REGISTER request received from %zx.\n",
 	    request->in_phone_hash);
 	
@@ -162,5 +162,5 @@
 		fibril_mutex_unlock(&fs_list_lock);
 		free(fs_info);
-		async_answer_0(rid, EEXISTS);
+		async_answer_0(rid, EEXIST);
 		return;
 	}
@@ -196,5 +196,5 @@
 	ipc_callid_t callid;
 	if (!async_share_in_receive(&callid, &size)) {
-		dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call));
+		dprintf("Unexpected call\n");
 		list_remove(&fs_info->fs_link);
 		fibril_mutex_unlock(&fs_list_lock);
@@ -210,5 +210,5 @@
 	 */
 	if (size != PLB_SIZE) {
-		dprintf("Client suggests wrong size of PFB, size = %d\n", size);
+		dprintf("Client suggests wrong size of PFB, size = %zu\n", size);
 		list_remove(&fs_info->fs_link);
 		fibril_mutex_unlock(&fs_list_lock);
Index: uspace/srv/volsrv/empty.c
===================================================================
--- uspace/srv/volsrv/empty.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/volsrv/empty.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -96,5 +96,5 @@
 	bool empty;
 
-	rc = block_init(EXCHANGE_SERIALIZE, sid, 2048);
+	rc = block_init(sid, 2048);
 	if (rc != EOK) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, "Error opening "
@@ -186,5 +186,5 @@
 	size_t block_size;
 
-	rc = block_init(EXCHANGE_SERIALIZE, sid, 2048);
+	rc = block_init(sid, 2048);
 	if (rc != EOK) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, "Error opening "
Index: uspace/srv/volsrv/volsrv.c
===================================================================
--- uspace/srv/volsrv/volsrv.c	(revision 3feeab2bb1fdb0b4062cc7b3e6c493d1552814dc)
+++ uspace/srv/volsrv/volsrv.c	(revision ff381a79ad697b23cc01e3f8a66966d2d2cbd7dc)
@@ -65,5 +65,5 @@
 		return rc;
 
-	async_set_client_connection(vol_client_conn);
+	async_set_fallback_port_handler(vol_client_conn, NULL);
 
 	rc = loc_server_register(NAME);
